semiotic 3.5.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +62 -4
- package/README.md +19 -12
- package/ai/componentMetadata.cjs +9 -2
- package/ai/dist/mcp-server.js +253 -3
- package/ai/examples.md +27 -0
- package/ai/schema.json +319 -49
- package/ai/system-prompt.md +1 -1
- package/dist/components/ai/audienceProfile.d.ts +90 -0
- package/dist/components/ai/audiences.d.ts +31 -0
- package/dist/components/ai/chartCapabilities.d.ts +55 -0
- package/dist/components/ai/chartCapabilityTypes.d.ts +196 -0
- package/dist/components/ai/diffProfile.d.ts +51 -0
- package/dist/components/ai/inferIntent.d.ts +24 -0
- package/dist/components/ai/intents.d.ts +34 -0
- package/dist/components/ai/profileData.d.ts +16 -0
- package/dist/components/ai/qualityFixtures.d.ts +2 -0
- package/dist/components/ai/qualityScorecard.d.ts +82 -0
- package/dist/components/ai/repairChartConfig.d.ts +73 -0
- package/dist/components/ai/streamingTypes.d.ts +64 -0
- package/dist/components/ai/suggestCharts.d.ts +76 -0
- package/dist/components/ai/suggestDashboard.d.ts +92 -0
- package/dist/components/ai/suggestStreamCharts.d.ts +34 -0
- package/dist/components/ai/suggestStretchCharts.d.ts +60 -0
- package/dist/components/ai/useChartSuggestions.d.ts +22 -0
- package/dist/components/charts/geo/ChoroplethMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/DistanceCartogram.capability.d.ts +2 -0
- package/dist/components/charts/geo/FlowMap.capability.d.ts +2 -0
- package/dist/components/charts/geo/ProportionalSymbolMap.capability.d.ts +2 -0
- package/dist/components/charts/index.d.ts +4 -4
- package/dist/components/charts/network/ChordDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/CirclePack.capability.d.ts +2 -0
- package/dist/components/charts/network/ForceDirectedGraph.capability.d.ts +2 -0
- package/dist/components/charts/network/OrbitDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/ProcessSankey.capability.d.ts +2 -0
- package/dist/components/charts/network/SankeyDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/TreeDiagram.capability.d.ts +2 -0
- package/dist/components/charts/network/Treemap.capability.d.ts +2 -0
- package/dist/components/charts/network/Treemap.d.ts +8 -0
- package/dist/components/charts/ordinal/BarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/BoxPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DonutChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/DotPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/FunnelChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GaugeChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/GaugeChart.d.ts +10 -0
- package/dist/components/charts/ordinal/GroupedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/Histogram.d.ts +4 -2
- package/dist/components/charts/ordinal/LikertChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/LikertChart.d.ts +1 -1
- package/dist/components/charts/ordinal/LikertChart.defaults.d.ts +1 -0
- package/dist/components/charts/ordinal/PieChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/RidgelinePlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/StackedBarChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwarmPlot.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/SwimlaneChart.capability.d.ts +2 -0
- package/dist/components/charts/ordinal/ViolinPlot.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHeatmap.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +22 -0
- package/dist/components/charts/realtime/RealtimeLineChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +7 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +0 -34
- package/dist/components/charts/shared/gaugeGradient.d.ts +62 -0
- package/dist/components/charts/shared/hooks.d.ts +2 -2
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -2
- package/dist/components/charts/shared/types.d.ts +11 -2
- package/dist/components/charts/shared/useChartSetup.d.ts +2 -2
- package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
- package/dist/components/charts/xy/AreaChart.capability.d.ts +10 -0
- package/dist/components/charts/xy/AreaChart.d.ts +15 -0
- package/dist/components/charts/xy/BubbleChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/CandlestickChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/ConnectedScatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/DifferenceChart.capability.d.ts +8 -0
- package/dist/components/charts/xy/Heatmap.capability.d.ts +9 -0
- package/dist/components/charts/xy/LineChart.capability.d.ts +9 -0
- package/dist/components/charts/xy/MinimapChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/MultiAxisLineChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.capability.d.ts +2 -0
- package/dist/components/charts/xy/QuadrantChart.d.ts +5 -2
- package/dist/components/charts/xy/QuadrantChart.defaults.d.ts +2 -0
- package/dist/components/charts/xy/Scatterplot.capability.d.ts +2 -0
- package/dist/components/charts/xy/StackedAreaChart.capability.d.ts +2 -0
- package/dist/components/data/DataSummarizer.d.ts +45 -0
- package/dist/components/semiotic-ai.d.ts +36 -1
- package/dist/components/semiotic-realtime.d.ts +3 -3
- package/dist/components/semiotic-server.d.ts +1 -0
- package/dist/components/semiotic-xy.d.ts +2 -2
- package/dist/components/semiotic.d.ts +5 -4
- package/dist/components/server/renderToStaticSVG.d.ts +2 -0
- package/dist/components/server/staticLegend.d.ts +35 -0
- package/dist/components/store/ThemeStore.d.ts +2 -0
- package/dist/components/store/useChartFocus.d.ts +43 -0
- package/dist/components/store/useChartInterrogation.d.ts +141 -0
- package/dist/components/stream/NetworkSVGOverlay.d.ts +2 -1
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -1
- package/dist/components/stream/SVGOverlay.d.ts +2 -1
- package/dist/components/stream/SceneToSVG.d.ts +1 -1
- package/dist/components/stream/geoTypes.d.ts +2 -1
- package/dist/components/stream/hoverUtils.d.ts +1 -0
- package/dist/components/stream/legendRenderer.d.ts +2 -1
- package/dist/components/stream/networkTypes.d.ts +2 -1
- package/dist/components/stream/ordinalTypes.d.ts +16 -2
- package/dist/components/stream/renderers/wedgePathBuilder.d.ts +31 -0
- package/dist/components/stream/types.d.ts +2 -1
- package/dist/components/types/legendTypes.d.ts +15 -0
- package/dist/components/types/marginType.d.ts +17 -3
- 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.d.ts +36 -1
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-realtime.d.ts +3 -3
- package/dist/semiotic-server.d.ts +1 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-xy.d.ts +2 -2
- package/dist/semiotic.d.ts +5 -4
- 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/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +25 -24
package/dist/semiotic-ai.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
"use strict";const e=require("react/jsx-runtime"),t=require("react"),o=require("d3-selection"),n=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-shape"),a=require("d3-array"),l=require("d3-hierarchy"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function g(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}const p=f(t),y=g(c),m=Object.freeze([]);function v(e){if(!e)return m;let t=!1;for(let o=0;e.length>o;o++){const n=e[o];if(null==n||"object"!=typeof n){t=!0;break}}if(!t)return e;const o=[];for(const t of e)null!=t&&"object"==typeof t&&o.push(t);return o}function b(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n+1>>1;t[i]>e?n=i-1:o=i}return t[o]}function x(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n>>1;e>t[i]?o=i+1:n=i}return t[o]}function k({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:g,binBoundaries:f,snapDuring:p,streaming:y}){const m=t.useRef(null),v=t.useRef(null),k=t.useRef(d);k.current=d;const w=t.useRef(u);w.current=u;const A=t.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),j=t.useRef(A);j.current=A;const S=t.useRef(!1),O=t.useRef(null);return t.useEffect(()=>{if(!m.current)return;const e=o.select(m.current).select(".brush-g"),t="x"===c?n.brushX():"y"===c?n.brushY():n.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",o=>{if(S.current)return;const n=w.current;if(!n)return;if(!o.selection)return O.current=null,void k.current(null);let s,a;if("x"===c){const[e,t]=o.selection;s=[n.x.invert(e),n.x.invert(t)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===c){const[e,t]=o.selection;s=[n.x.invert(0),n.x.invert(i)],a=[n.y.invert(t),n.y.invert(e)]}else{const[[e,t],[i,r]]=o.selection;s=[n.x.invert(e),n.x.invert(i)],a=[n.y.invert(r),n.y.invert(t)]}if("bin"===g&&"y"!==c&&("end"===o.type||"brush"===o.type&&p)){const i=j.current;i&&i.length>0?s=function(e,t){return 0===t.length?e:[b(e[0],t),x(e[1],t)]}(s,i):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const n=o.selection;e.call(t.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const l={x:s,y:a};O.current=l,k.current(l)}),e.call(t),v.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),v.current=null}},[i,r,c,g,h,p]),t.useEffect(()=>{if(!(y&&u&&v.current&&O.current))return;if(!m.current)return;if("y"===c)return;const e=O.current,t=u.x.domain()[0],n=o.select(m.current).select(".brush-g");if(t>=e.x[1])return S.current=!0,n.call(v.current.move,null),S.current=!1,O.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=j.current;e&&e.length>0?i=x(t,e):h&&h>0&&(i=Math.ceil(t/h)*h)}if(i>=e.x[1])return S.current=!0,n.call(v.current.move,null),S.current=!1,O.current=null,void k.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(S.current=!0,"x"===c)n.call(v.current.move,[s,a]);else{const t=u.y(e.y[1]),o=u.y(e.y[0]);n.call(v.current.move,[[s,t],[a,o]])}if(S.current=!1,r){const t={x:[i,e.x[1]],y:e.y};O.current=t,k.current(t)}},[u,y,c,g,h]),e.jsx("svg",{ref:m,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 w{constructor(e,t){var o,n;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(o=null==t?void 0:t.chunkThreshold)&&void 0!==o?o:5e3,this.chunkSize=null!==(n=null==t?void 0:t.chunkSize)&&void 0!==n?n:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=v(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}setReplacementData(e){if(e=v(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let o=0;e.length>o;o++){const n=e[o];null!=n&&"object"==typeof n&&(this.pushBuffer.push(n),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function A(o){let n=null;const i=()=>(n||(n=t.createContext(null)),n),r=j(o);return[function({children:n,initialState:r}){const s=t.useRef(r),a=t.useMemo(()=>j(o,s.current),[]),l=i();return e.jsx(l.Provider,{value:a,children:n})},e=>{var o;const n=i(),s=null!==(o=t.useContext(n))&&void 0!==o?o:r,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(s.getState()),[s]),c=t.useCallback(()=>a.current(s.getState()),[s]);return t.useSyncExternalStore(s.subscribe,l,c)}]}function j(e,t){const o=new EventTarget;let n=Object.assign(Object.assign({},e(function(e){n=Object.assign(Object.assign({},n),e(n)),o.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>n,subscribe:function(e){return o.addEventListener("update",e),()=>o.removeEventListener("update",e)}}}function S(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 O(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:M})})),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 M=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],C={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}},_={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}},P={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:M,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function L(e,t){if("light"===t)return C;if("dark"===t)return _;if("high-contrast"===t)return P;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?_:C;return O(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 O(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||{})}))}const[T,R]=A(e=>({theme:C,setTheme(t){e(e=>({theme:L(e.theme,t)}))}}));class B{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 o of e){const e=this.push(o);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 o=0;this._size>o;o++)e(this.buffer[(t+o)%this._capacity],o)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e[o]=this.buffer[(t+o)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),o=[];for(;t.length>e;)o.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 o}update(e,t){const o=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(n+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),o.push(e),this.buffer[r]=t(s)}}return o}remove(e){const t=[],o=[];if(this.forEach(n=>{e(n)?o.push(n):t.push(n)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return o}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class N{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function E(e,t,o,n,i){const r=new Map;for(const s of e){const e=t(s),a=o(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/n)*n;let c=r.get(l);if(c||(c={start:l,end:l+n,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 D(e,t,o,n,i,r){const s=[];for(const i of e){const e=o(i),r=n(i);Number.isFinite(e)&&Number.isFinite(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 I(e,t,o,n,i,r,s,a){const l=[];for(const r of e){const e=o(r),s=n(r);if(!Number.isFinite(e)||!Number.isFinite(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 H(e,t,o,n){var i,r,s;const a=new Map;if("silhouette"===n)for(const n of e){let e=0;for(const i of t)e+=o(i,n)||0;a.set(n,-e/2)}else if("wiggle"===n){e.length>0&&a.set(e[0],0);for(let n=1;e.length>n;n++){const r=e[n-1],s=e[n];let l=0,c=0,u=0;for(const e of t){const t=o(e,s)||0;l+=(2*u+t)*(t-(o(e,r)||0)),c+=t,u+=t}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(e.length>0){let n=0;for(const i of e){let e=0;for(const n of t)e+=o(n,i)||0;n+=(null!==(r=a.get(i))&&void 0!==r?r:0)+e/2}const i=n/e.length;for(const t of e)a.set(t,(null!==(s=a.get(t))&&void 0!==s?s:0)-i)}}else for(const t of e)a.set(t,0);return a}function F(e,t,o,n,i,r,s){const a=o(e),l=n(e);if(!Number.isFinite(a)||!Number.isFinite(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 W(e,t,o,n,i,r,s){return{type:"rect",x:e,y:t,w:o,h:n,style:i,datum:r,group:s}}function $(e,t,o,n,i,r,s){const a={type:"heatcell",x:e,y:t,w:o,h:n,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 z(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function Y(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function G(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function q(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function X(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,o){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(o)}`}function U(e){const t=e.map(X),o=t.length-1;return e=>{if(0>=e){const[e,o,n]=t[0];return V(e,o,n)}if(e>=1){const[e,n,i]=t[o];return V(e,n,i)}const n=e*o,i=Math.floor(n),r=n-i,[s,a,l]=t[i],[c,u,d]=t[i+1];return V(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const K=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Q=U(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Z=U(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=U(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=U(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=U(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),oe=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ne=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ie=U(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),re=U(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),se=U(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ae=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),le=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ce=U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),ue=U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),de=U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),he=U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),ge=U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),fe=U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),pe=U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),ye={category10:K,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Q,reds:Z,greens:J,oranges:ee,purples:te,viridis:ne,plasma:ie},me=K,ve=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],be=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],xe=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 ke(e,t,o){if("function"==typeof t){const n=t(e);return o&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||xe.has(t)}(n)?o(n):n}const n=(null==e?void 0:e[t])+"";return o?o(n):me[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(n))%me.length]}function we(e,t,o="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=n.every(e=>!isNaN(Number(e)));if(Array.isArray(o))return i.scaleOrdinal().domain(n).range(o).unknown("#999");const s=ye[o]||ye.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of n){const o=Number(t);o>e&&(e=o)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:me;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Ae(e,t,o=[3,20],n){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!n)return i;const[r,s]=n,[a,l]=o;if(s===r)return(a+l)/2;let c=(i-r)/(s-r);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function je(e,t,o){var n,i,r;if(1>=o)return 1;const s=null!==(n=e.minOpacity)&&void 0!==n?n:.1,a=o-1-t;switch(e.type){case"linear":return s+(1-a/(o-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:o/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*o)>a?1:s;default:return 1}}function Se(e,t,o){var n;const i=null!==(n=e.duration)&&void 0!==n?n:500,r=o-t;return i>r?1-r/i:0}function Oe(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Me(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Ce(e,t,o){return e+(t-e)*o}function _e(){return"undefined"!=typeof performance?performance.now():Date.now()}function Pe(e,t,o){var n,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 o=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${o}:${n}`;if(null!=o&&null!=n)return`p:${o}:${n}`}return"p:"+o;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:o}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+o:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Le(e,t,o,n){return"function"==typeof t.style?t.style(n||{},o):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(o,n)}function Te(e,t,o,n){if(!e.scales)return null;const i=[],r=[];for(const o of t){const t=e.getX(o);if(!Number.isFinite(t))continue;const s=n.getTop(o),a=n.getBottom(o);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=e.scales.x(t),c=e.scales.y(s),u=e.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:Le(e,n,o,t[0]),datum:t,group:o,interactive:n.interactive}}function Re(e){const t=[],o=[];if(!e)return{perSeries:t,aggregate:o};for(const n of e)n.perSeries?t.push(n):o.push(n);return{perSeries:t,aggregate:o}}function Be(e,t,o){const n=[];for(const i of o){const o=Te(e,t,"__ribbon_aggregate",i);o&&n.push(o)}return n}function Ne(e,t,o,n){const i=[];for(const r of n){const n=Te(e,t,o,r);n&&i.push(n)}return i}function Ee(e,t){if(!e)return{};if(!t||0===t.length)return e;const o=[];for(const n of t){if("band"!==n.kind)continue;const t=n.getTop(e),i=n.getBottom(e);Number.isFinite(i)&&Number.isFinite(t)&&o.push({y0:i,y1:t})}return 0===o.length?e:Object.assign(Object.assign({},e),{band:o[0],bands:o})}function De(e,t,o,n){var i;if(!e.config.pointStyle)return;const r=null!=n?n:e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const s of n.data){let n=e.config.pointStyle(s);!n.fill&&t&&(n=Object.assign(Object.assign({},n),{fill:t}));const a=null!==(i=n.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=F(s,e.scales,e.getX,r,a,n,l);c&&o.push(c)}}}const Ie={topOpacity:.8,bottomOpacity:.05};function He(e){var t,o;if(e)return!0===e?Ie:"colorStops"in e?e:{topOpacity:null!==(t=e.topOpacity)&&void 0!==t?t:Ie.topOpacity,bottomOpacity:null!==(o=e.bottomOpacity)&&void 0!==o?o:Ie.bottomOpacity}}const Fe={blues:Q,reds:Z,greens:J,viridis:ne,oranges:ee,purples:te,greys:oe,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le},We=new Map;function $e(e,t){const o="function"==typeof e?e:o=>o[e||t];return e=>{const t=o(e);return null==t?NaN:+t}}function ze(e){const t=[],o=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=$e(o&&e.valueAccessor||e.yAccessor,o?"value":"y");if(e.boundsAccessor){const o=Y(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const i=o(e);return Number.isFinite(i)&&0!==i?t+i:t},getBottom:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const i=o(e);return Number.isFinite(i)&&0!==i?t-i:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const o=Array.isArray(e.band)?e.band:[e.band];for(const e of o)t.push({kind:"band",getTop:$e(e.y1Accessor,"y1"),getBottom:$e(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}class Ye{constructor(e){if(this.xExtent=new N,this.yExtent=new N,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._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.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=e,this.buffer=new B(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=Y(e.timeAccessor||e.xAccessor,"time"),this.getY=Y(e.valueAccessor||e.yAccessor,"value")):(this.getX=Y(e.xAccessor,"x"),this.getY=Y(e.yAccessor,"y")),this.getGroup=q(e.groupAccessor),this.getCategory=q(e.categoryAccessor),this.getSize=e.sizeAccessor?Y(e.sizeAccessor,"size"):void 0,this.getColor=q(e.colorAccessor),this.getY0=e.y0Accessor?Y(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ze(e),this.getPointId=q(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,o=null!=e.closeAccessor;this.getOpen=t?Y(e.openAccessor,"open"):void 0,this.getHigh=Y(e.highAccessor,"high"),this.getLow=Y(e.lowAccessor,"low"),this.getClose=o?Y(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!o}e.pulse&&(this.timestampBuffer=new B(e.windowSize))}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&this.yExtent.push(o),Number.isFinite(n)&&this.yExtent.push(n)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return!1;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._lastBoundedInsertsRef=e.inserts,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?Y(this.config.timeAccessor||this.config.xAccessor,"time"):Y(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],o=this.config.xAccessor,n="function"==typeof o?o(t):t[o||"x"],i=n instanceof Date,r="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=i||r,r){const e="string"==typeof o?o:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(o(e)instanceof Date?o(e):new Date(o(e)))}}const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)if(this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o));else{this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o));for(const e of this.resolvedRibbons){const t=e.getTop(o),n=e.getBottom(o);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(n)&&this.yExtent.push(n)}}}else for(const o 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(o);if(this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o));else{this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o));for(const e of this.resolvedRibbons){const t=e.getTop(o),n=e.getBottom(o);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(n)&&this.yExtent.push(n)}}if(null!=e)if(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));else{this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&this.yExtent.evict(o),Number.isFinite(n)&&this.yExtent.evict(n)}}}return!0}computeScene(e){var t,o,n,r,s,a,l,c,u,d,h,g,f,p;const{config:y,buffer:m}=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);this.xExtent.dirty&&this.xExtent.recalculate(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),b=this.xExtent.extent,x=this.yExtent.extent;let k=y.xExtent?[null!==(o=y.xExtent[0])&&void 0!==o?o:b[0],null!==(n=y.xExtent[1])&&void 0!==n?n:b[1]]:b,w=y.yExtent?[null!==(r=y.yExtent[0])&&void 0!==r?r:x[0],null!==(s=y.yExtent[1])&&void 0!==s?s:x[1]]:x;const A=y.yExtent&&null!=y.yExtent[0]&&null!=y.yExtent[1],j="exact"===y.axisExtent;if("stackedarea"===y.chartType&&!A&&m.size>0)if(y.normalize)w=[0,j?1:1+y.extentPadding];else{const e=`${m.size}:${this._ingestVersion}:${null!==(a=y.baseline)&&void 0!==a?a:"zero"}:${null!==(l=y.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)w=this._stackExtentCache.yDomain;else{const t=this.groupData(v),o=new Map,n=new Set;let i=0;const r=new Map,s=new Map;for(const e of t){const t=new Map;let a=0;for(const o of e.data){const e=this.getX(o),s=this.getY(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),n.add(e),a+=s;const l=(r.get(e)||0)+s;r.set(e,l),l>i&&(i=l)}o.set(e.key,t),s.set(e.key,a)}const a=null!==(c=y.stackOrder)&&void 0!==c?c:"key",l=(e,t)=>t>e?-1:e>t?1:0;let f;if("insideOut"===a){const e=[...t].map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(t))&&void 0!==o?o:0)-(null!==(n=s.get(e))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}),o=[],n=[];let i=0,r=0;for(const t of e)r>i?(o.push(t),i+=null!==(u=s.get(t))&&void 0!==u?u:0):(n.push(t),r+=null!==(d=s.get(t))&&void 0!==d?d:0);f=[...n.reverse(),...o]}else f="asc"===a?t.map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(e))&&void 0!==o?o:0)-(null!==(n=s.get(t))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}):"desc"===a?t.map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(t))&&void 0!==o?o:0)-(null!==(n=s.get(e))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}):t.map(e=>e.key).sort(l);if("wiggle"===y.baseline||"silhouette"===y.baseline){const e=Array.from(n).sort((e,t)=>e-t),t=H(e,f,(e,t)=>{var n;return(null===(n=o.get(e))||void 0===n?void 0:n.get(t))||0},y.baseline);let i=1/0,s=-1/0;for(const o of e){const e=null!==(h=t.get(o))&&void 0!==h?h:0,n=null!==(g=r.get(o))&&void 0!==g?g:0;i>e&&(i=e),e+n>s&&(s=e+n)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=j?0:a>0?a*y.extentPadding:1;w=[i-l,s+l]}else w=[0,i+(j?0:i>0?i*y.extentPadding:1)];this._stackExtentCache={key:e,yDomain:w}}}else if("bar"===y.chartType&&y.binSize&&!A&&m.size>0){const[,e]=function(e,t,o,n,i){const r=E(e,t,o,n,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]}(m,this.getX,this.getY,y.binSize,this.getCategory);w=[0,j?e:e+e*y.extentPadding]}else if("waterfall"===y.chartType&&!A&&m.size>0){const[e,t]=function(e,t){let o=0,n=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,o>i&&(o=i),i>n&&(n=i))}return[o,n]}(m,this.getY),o=t-e,n=j?0:o>0?o*y.extentPadding:1;w=[Math.min(0,e-Math.abs(n)),Math.max(0,t+Math.abs(n))]}else if(!A&&w[0]!==1/0){if(this.resolvedRibbons.length>0)for(const e of v)for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&(w[0]>o&&(w[0]=o),o>w[1]&&(w[1]=o)),Number.isFinite(n)&&(w[0]>n&&(w[0]=n),n>w[1]&&(w[1]=n))}const e=w[1]-w[0],t=j?0:e>0?e*y.extentPadding:1,o=null===(f=y.yExtent)||void 0===f?void 0:f[0],n=null===(p=y.yExtent)||void 0===p?void 0:p[1];w=[null!=o?w[0]:w[0]-t,null!=n?w[1]:w[1]+t],"log"!==y.yScaleType||w[0]>0||0>=x[0]||j||(w[0]=null!=o?w[0]:x[0]/(1+y.extentPadding))}if(y.yExtent&&!A){const e=y.yExtent[0],t=y.yExtent[1];null==e&&null==t||(w=[null!=e?e:w[0],null!=t?t:w[1]])}if(k[0]===1/0||k[1]===-1/0)if("time"===y.xScaleType){const e=Date.now();k=[e-864e5,e]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const S="streaming"===y.runtimeMode,O=Math.max(0,Math.min(y.scalePadding||0,Math.min(e.width,e.height)/2-1));if(S)if("x"==("up"===(M=y.arrowOfTime)||"down"===M?"y":"x")){const t="right"===y.arrowOfTime?[O,e.width-O]:[e.width-O,O];this.scales={x:i.scaleLinear().domain(k).range(t),y:i.scaleLinear().domain(w).range([e.height-O,O])}}else{const t="down"===y.arrowOfTime?[O,e.height-O]:[e.height-O,O];this.scales={x:i.scaleLinear().domain(w).range([O,e.width-O]),y:i.scaleLinear().domain(k).range(t)}}else{const t=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)};this.scales={x:t(y.xScaleType,k,[O,e.width-O]),y:t(y.yScaleType,w,[e.height-O,O])}}var M;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),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,o=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>o&&(o=e.r));if(this._maxPointRadius=o,Ye.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(n[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,o=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const n of e.path)n[0]*=t,n[1]*=o;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=o;for(const n of e.bottomPath)n[0]*=t,n[1]*=o;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*o,width:e.clipRect.width*t,height:e.clipRect.height*o});break;case"point":e.x*=t,e.y*=o;break;case"rect":case"heatcell":e.x*=t,e.y*=o,e.w*=t,e.h*=o;break;case"candlestick":e.x*=t,e.openY*=o,e.closeY*=o,e.highY*=o,e.lowY*=o}const n=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)},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,n,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 o,n,i,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(o=c.layoutMargin)&&void 0!==o?o:{top:0,right:0,bottom:0,left:0},d={data:t,scales:u,dimensions:{width:e.width,height:e.height,margin:l,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(n=c.themeSemantic)&&void 0!==n?n:{},categorical:null!==(i=c.themeCategorical)&&void 0!==i?i:ve},resolveColor:(e,t)=>{var o,n;const i=this.resolveGroupColor(e);if(i)return i;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(n=null===(o=c.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==n?n:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(a=h.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===t.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(c.chartType){case"line":return function(e,t){var o;const n=e.groupData(t),i=[],r=null===(o=e.config.annotations)||void 0===o?void 0:o.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Re(e.ribbons);if(r.length>0&&i.push(...Be(e,t,r)),o.length>0)for(const t of n)i.push(...Ne(e,t.data,t.key,o))}for(const t of n){const o=e.resolveLineStyle(t.key,t.data[0]),n=D(t.data,e.scales,e.getX,e.getY,o,t.key);r&&r.length>0&&(n.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),i.push(n)}return De(e,n,i),i}(d,t);case"area":return function(e,t){const o=e.groupData(t),n=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Re(e.ribbons);if(r.length>0&&n.push(...Be(e,t,r)),i.length>0)for(const t of o)n.push(...Ne(e,t.data,t.key,i))}const i=e.scales.y.domain()[0],r=e.getY0?t=>{const o=e.getY0(t);return null==o?i:o}:void 0;for(const t of o){const o=e.resolveAreaStyle(t.key,t.data[0]),s=I(t.data,e.scales,e.getX,e.getY,i,o,t.key,r),a=He(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),n.push(s)}return De(e,o,n),n}(d,t);case"mixed":return function(e,t){const o=e.groupData(t),n=[],i=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Re(e.ribbons);if(r.length>0&&n.push(...Be(e,t,r)),i.length>0)for(const t of o)n.push(...Ne(e,t.data,t.key,i))}const r=e.scales.y.domain()[0],s=e.getY0?t=>{const o=e.getY0(t);return null==o?r:o}:void 0;for(const t of o)if(i.has(t.key)){const o=e.resolveAreaStyle(t.key,t.data[0]),i=I(t.data,e.scales,e.getX,e.getY,r,o,t.key,s),a=He(e.config.gradientFill);a&&(i.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}else{const o=e.resolveLineStyle(t.key,t.data[0]),i=D(t.data,e.scales,e.getX,e.getY,o,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}return De(e,o,n),n}(d,t);case"stackedarea":return function(e,t){var o,n,i,r;const s=e.groupData(t),a=null!==(o=e.config.stackOrder)&&void 0!==o?o:"key",l=()=>s.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const t=new Map;for(const o of s){let n=0;for(const t of o.data){const o=e.getX(t),i=e.getY(t);Number.isFinite(o)&&Number.isFinite(i)&&(n+=i)}t.set(o.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===a)s.sort((e,n)=>{var i,r;const s=(null!==(i=t.get(e.key))&&void 0!==i?i:0)-(null!==(r=t.get(n.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)});else if("desc"===a)s.sort((e,n)=>{var i,r;const s=(null!==(i=t.get(n.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)});else{const e=[...s].sort((e,n)=>{var i,r;const s=(null!==(i=t.get(n.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)}),r=[],a=[];let l=0,c=0;for(const o of e)c>l?(r.push(o),l+=null!==(n=t.get(o.key))&&void 0!==n?n:0):(a.push(o),c+=null!==(i=t.get(o.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,u=e.config.normalize?"zero":null!==(r=e.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(e,t,o,n,i,r,s,a="zero"){var l,c;const u=new Set;for(const t of e)for(const e of t.data){const t=o(e);Number.isFinite(t)&&u.add(t)}const d=Array.from(u).sort((e,t)=>e-t),h=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=o(i),r=n(i);Number.isFinite(t)&&Number.isFinite(r)&&e.set(t,(e.get(t)||0)+r)}h.set(t.key,e)}let g;if(r){g=new Map;for(const t of d){let o=0;for(const n of e)o+=(null===(l=h.get(n.key))||void 0===l?void 0:l.get(t))||0;g.set(t,o||1)}}const f=H(d,e.map(e=>e.key),(e,t)=>{var o;return(null===(o=h.get(e))||void 0===o?void 0:o.get(t))||0},a),p=[],y=new Map,m=new Map;for(const e of d)m.set(e,null!==(c=f.get(e))&&void 0!==c?c:0);for(const o of e){const e=h.get(o.key),n=[],a=[],l=new Map;for(const o of d){let i=e.get(o)||0;const s=m.get(o);r&&(i/=g.get(o));const c=s+i,u=t.x(o);a.push([u,t.y(s)]),n.push([u,t.y(c)]),m.set(o,c),l.set(o,c)}y.set(o.key,l);const c={type:"area",topPath:n,bottomPath:a,style:i(o.key,o.data[0]),datum:o.data,group:o.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(s,e.scales,e.getX,e.getY,(t,o)=>e.resolveAreaStyle(t,o),e.config.normalize,c,u),g=d;if(e.config.pointStyle){const t=new WeakMap;for(const o of s){const n=h.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=o=>{var n;return null!==(n=t.get(o))&&void 0!==n?n:e.getY(o)};De(e,s,g,o)}return g}(d,t);case"scatter":case"bubble":return function(e,t){var o;const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=null;if(e.getSize&&!e.config.pointStyle){const o=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(o.length>0){let e=1/0,t=-1/0;for(const n of o)e>n&&(e=n),n>t&&(t=n);s=o=>e===t?(r[0]+r[1])/2:r[0]+(o-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7";for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(o);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const c=e.getPointId?e.getPointId(o)+"":void 0,u=F(o,e.scales,e.getX,e.getY,r,t,c);u&&n.push(u)}return n}(d,t);case"heatmap":return function(e,t,o){if(e.config.heatmapAggregation)return function(e,t,o){var n,i,r;const s=Math.max(1,Math.floor(null!==(n=e.config.heatmapXBins)&&void 0!==n?n: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=Y(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 o=0;t.length>o;o++){const n=t[o],i=e.getX(n),r=e.getY(n);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/f),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(n);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=o.width/s,A=o.height/a,j=e.config.showValues,S=e.config.heatmapValueFormat,O=[];for(let e=0;a>e;e++){const t=e*s;for(let o=0;s>o;o++){const n=t+o;if(0===m[n])continue;let i;switch(l){case"sum":i=v[n];break;case"mean":i=v[n]/m[n];break;default:i=m[n]}const r=(i-b)/k;O.push($(o*w,(a-1-e)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:o,yi:e,value:i,count:m[n],sum:v[n],xCenter:u+(o+.5)*f,yCenter:h+(e+.5)*p,agg:l},j?{value:i,showValues:!0,valueFormat:S}:void 0))}}return O}(e,t,o);if(0===t.length)return[];const n=Y(e.config.valueAccessor,"value"),i=G(e.config.xAccessor,"x"),r=G(e.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const o=t[e],n=i(o),u=r(o);l[e]=n,c[e]=u,s.has(n)||s.set(n,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),g=Array.from(a.keys()),f=h.every(e=>"number"==typeof e&&!isNaN(e)),p=g.every(e=>"number"==typeof e&&!isNaN(e));if(f){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}const y=new Float64Array(t.length),m=new Float64Array(t.length),v=Array(t.length),b=new Map;let x=0;for(let e=0;t.length>e;e++){const o=t[e],i=s.get(l[e]),r=a.get(c[e]);if(void 0===i||void 0===r)continue;const d=n(o),h=r*u+i,g=b.get(h);let f;void 0!==g?f=g:(f=x++,b.set(h,f)),y[f]=h,m[f]=d,v[f]=o}let k=1/0,w=-1/0;for(let e=0;x>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in Fe?e:"blues";let o=We.get(t);if(o)return o;o=Array(256);const n=Fe[t]||Q;for(let e=0;256>e;e++)o[e]=n(e/255);return We.set(t,o),o}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),j=255/(w-k||1),S=o.width/u,O=o.height/d,M=e.config.showValues,C=e.config.heatmapValueFormat,_=[];for(let e=0;x>e;e++){const t=m[e];if(!isFinite(t))continue;const o=y[e],n=o%u;_.push($(n*S,(d-1-(o-n)/u)*O,S,O,A[Math.min((t-k)*j+.5|0,255)],v[e],M?{value:t,showValues:!0,valueFormat:C}:void 0))}return _}(d,t,e);case"bar":{const e=function(e,t){var o,n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=E(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 o of e.categories.keys())t.add(o);const o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),s=Array.from(t).filter(e=>!n.has(e)).sort(),a=o.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===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary,h=null==u?void 0:u.gap,g="number"!=typeof h||0>h?1:h,f={};(null==u?void 0:u.stroke)&&(f.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(f.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(f.opacity=u.opacity);for(const t of i.values()){const o=Math.max(t.start,l),i=Math.min(t.end,c);if(o>=i)continue;const h=a.x(o),p=a.x(i),y=Math.abs(p-h),m=y>g+1?g:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&t.categories.size>0){let o=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r),h=(null===(n=e.config.barColors)||void 0===n?void 0:n[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(W(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},f),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),o+=r}}else{const e=a.y(0),o=a.y(t.total);s.push(W(v,Math.min(e,o),b,Math.abs(e-o),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},f),{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:s,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(d,t);return this._barCategoryCache=null!==(l=d.barCategoryCache)&&void 0!==l?l:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var o,n,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(o=c.radius)&&void 0!==o?o:3,d=null!==(r=null!==(n=c.fill)&&void 0!==n?n: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,f=c.strokeWidth;for(const o of t){const t=e.getX(o),n=e.getY(o);if(null==n||Number.isNaN(n))continue;const i=e.scales.x(t),r=e.scales.y(n);let s=d;if(e.getCategory){const t=e.getCategory(o);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:f},datum:o};e.getPointId&&(c.pointId=e.getPointId(o)+""),l.push(c)}return l}(d,t);case"waterfall":return function(e,t,o){var n,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,g=t.filter(t=>{const o=e.getY(t),n=e.getX(t);return null!=o&&!Number.isNaN(o)&&null!=n&&isFinite(n)});if(0===g.length)return u;const f=null!==(r=null!==(n=null==h?void 0:h.positiveColor)&&void 0!==n?n:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",p=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 n=g[t],i=e.getX(n),r=e.getY(n),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+o.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const A=d.y(x),j=d.y(s),S=Math.min(A,j),O=Math.abs(A-j),M={fill:0>r?p:f,stroke:m,strokeWidth:v};null!=b&&(M.opacity=b),u.push(W(k,S,w,O,M,Object.assign(Object.assign({},n),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,t,e);case"candlestick":return function(e,t){var o,n;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(o=e.config.candlestickRangeMode)&&void 0!==o&&o;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!==(n=s.bodyWidth)&&void 0!==n?n:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let o=1;h.length>o;o++){const n=Math.abs(e.scales.x(h[o])-e.scales.x(h[o-1]));n>0&&t>n&&(t=n)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else g=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const n=e.getHigh(o),s=e.getLow(o);if(null==n||Number.isNaN(n)||null==s||Number.isNaN(s))continue;const a=i?n:e.getOpen(o),h=i?s:e.getClose(o);if(!i&&[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(n),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:o};i&&(p.isRange=!0),r.push(p)}return r}(d,t);default:return[]}}resolveBoundsStyle(e,t){var o;const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||(null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?je(o,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,o){var n,i;const r=o.length;if(1>=r)return;const s=new Map;for(let e=0;o.length>e;e++)s.set(o[e],e);for(const o of t){if("line"===o.type){const t=Array.isArray(o.datum)?o.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let o=0;t.length>o;o++){const a=s.get(t[o]);null!=a?(n[o]=je(e,a,r),1>n[o]&&(i=!0)):n[o]=1}i&&(o._decayOpacities=n);continue}if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[],n=o.topPath?o.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let o=0;t.length>o;o++){const n=s.get(t[o]);null!=n?(i[o]=je(e,n,r),1>i[o]&&(a=!0)):i[o]=1}a&&(o._decayOpacities=i)}else{let i=1;for(const o of t){const t=s.get(o);if(null!=t){const o=je(e,t,r);i>o&&(i=o)}}if(1>i){const e=Array(n);e.fill(i),o._decayOpacities=e}}continue}const t=s.get(o.datum);if(null==t)continue;const a=je(e,t,r);if("heatcell"===o.type)o.style={opacity:a};else if("candlestick"===o.type)o._decayOpacity=a;else{const e=null!==(i=null===(n=o.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;o.style=Object.assign(Object.assign({},o.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,o,n){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;o.length>e;e++)c.set(o[e],e);for(const o of t){if("line"===o.type)continue;if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[o.datum];let i=0;for(const o of t){const t=c.get(o);if(null==t)continue;const r=n.get(t);if(null==r)continue;const a=Se(e,r,s);a>i&&(i=a)}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const t=c.get(o.datum);if(null==t)continue;const i=n.get(t);if(null==i)continue;const r=Se(e,i,s);r>0&&(o._pulseIntensity=r,o._pulseColor=a,o._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var o;if(!t||0===t.size)return!1;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(o=e.duration)&&void 0!==o?o:500,r=t.peek();return null!=r&&i>n-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,o,n){var i,r,s,a;o.clear(),n.clear();for(let l=0;t.length>l;l++){const c=t[l],u=Pe(e,c,l);u&&("point"===c.type?o.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?o.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?o.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?o.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?n.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&&n.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,o;this.prevPositionMap.clear(),this.prevPathMap.clear();const n=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=Pe(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:n,w:t.w,h:0,opacity:null!==(o=t.style.opacity)&&void 0!==o?o: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,o,n,i){var r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,j,S,O,M,C,_,P,L,T,R,B,N,E,D,I,H,F,W,$,z,Y,G;if(0===n.size&&0===i.size)return o;const q=null!==(r=t.duration)&&void 0!==r?r:300;if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}let X=!1;const V=new Set,U=new Set;for(let t=0;o.scene.length>t;t++){const r=o.scene[t],P=Pe(e,r,t);if(!P)continue;if(r._transitionKey=P,"line"===r.type||"area"===r.type){const e=i.get(P);if(e){if(U.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]];X=!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]];X=!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}),X=!0;continue}const L=n.get(P);if("point"===r.type)if(L){V.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,X=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("rect"===r.type)if(L){V.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!==(f=L.w)&&void 0!==f?f:r.w,r.h=null!==(p=L.h)&&void 0!==p?p:r.h,X=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("heatcell"===r.type)if(L){V.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,X=!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}),X=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){V.add(P);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(j=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==j?j: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!==(S=L.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(O=L.highY)&&void 0!==O?O:r.highY,r.lowY=null!==(M=L.lowY)&&void 0!==M?M:r.lowY,X=!0)}else r._targetOpacity=null!==(_=null===(C=r.style)||void 0===C?void 0:C.opacity)&&void 0!==_?_:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[e,t]of i)if(!U.has(e))if(e.startsWith("l:")&&t.path){const n={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};o.exitNodes.push(n),X=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={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};o.exitNodes.push(n),X=!0}for(const[e,t]of n)if(!V.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(T=t.r)&&void 0!==T?T:3,style:{opacity:null!==(R=t.opacity)&&void 0!==R?R:1},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(B=t.w)&&void 0!==B?B:0,h:null!==(N=t.h)&&void 0!==N?N:0,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(D=t.w)&&void 0!==D?D:0,h:null!==(I=t.h)&&void 0!==I?I:0,fill:"#999",datum:null,style:{opacity:null!==(H=t.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("c:")){const n=null!==(F=t.openY)&&void 0!==F?F:t.y,i={type:"candlestick",x:t.x,openY:n,closeY:null!==(W=t.closeY)&&void 0!==W?W:n,highY:null!==($=t.highY)&&void 0!==$?$:n,lowY:null!==(z=t.lowY)&&void 0!==z?z:n,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};o.exitNodes.push(i)}X=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),X&&(o.activeTransition={startTime:_e(),duration:q}),o}(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},o=function(e,t,o,n){var i,r,s,a,l,c;if(!o.activeTransition)return!1;const u=Me(e,o.activeTransition),d=Oe(u,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of o.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style.opacity=Ce(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Ce(o.x,e._targetX,d),e.y=Ce(o.y,e._targetY,d),void 0!==e._targetR&&void 0!==o.r&&(e.r=Ce(o.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(r=o.opacity)&&void 0!==r?r:1:0;e.style.opacity=Ce(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Ce(o.x,e._targetX,d),e.y=Ce(o.y,e._targetY,d),void 0!==o.w&&(e.w=Ce(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Ce(o.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(s=o.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Ce(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Ce(o.x,e._targetX,d),e.y=Ce(o.y,e._targetY,d),void 0!==o.w&&(e.w=Ce(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Ce(o.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(a=o.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Ce(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Ce(o.x,e._targetX,d),void 0!==o.openY&&(e.openY=Ce(o.openY,e._targetOpenY,d)),void 0!==o.closeY&&(e.closeY=Ce(o.closeY,e._targetCloseY,d)),void 0!==o.highY&&(e.highY=Ce(o.highY,e._targetHighY,d)),void 0!==o.lowY&&(e.lowY=Ce(o.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:Ce(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,o=e._targetPath;if(t&&o&&t.length===e.path.length)for(let n=0;e.path.length>n;n++)e.path[n][0]=Ce(t[n][0],o[n][0],d),e.path[n][1]=Ce(t[n][1],o[n][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:Ce(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,o=e._prevBottomPath,n=e._targetTopPath,i=e._targetBottomPath;if(t&&n&&t.length===e.topPath.length)for(let o=0;e.topPath.length>o;o++)e.topPath[o][0]=Ce(t[o][0],n[o][0],d),e.topPath[o][1]=Ce(t[o][1],n[o][1],d);if(o&&i&&o.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Ce(o[t][0],i[t][0],d),e.bottomPath[t][1]=Ce(o[t][1],i[t][1],d)}}if(u>=1){for(const e of o.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 o=0;e.path.length>o;o++)e.path[o]=t[o];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,o=e._targetBottomPath;if(t)for(let o=0;e.topPath.length>o;o++)e.topPath[o]=t[o];if(o)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=o[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}return o.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,o}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const o of e){const e=this.getGroup(o);t.has(e)||t.set(e,[]),t.get(e).push(o)}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 o of e){const e=this.getColor(o);e&&t.add(e)}const o=Array.from(t).sort(),n=o.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,r=new Map;for(let e=0;o.length>e;e++)r.set(o[e],i[e%i.length]);return this._colorMapCache={key:n,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var o;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}const i=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;return n&&"object"==typeof n?{stroke:n.stroke||i||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var o,n;if(this.config.areaStyle){const o=this.config.areaStyle(t||{});if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const i=this.config.lineStyle;if("function"==typeof i){const o=i(t||{},e);if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const r=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.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 o=(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)||ve;if(0===o.length)return null;const n=o[this._groupColorCounter%o.length];if(this._groupColorCounter++,this._groupColorMap.set(e,n),this._groupColorMap.size>Ye.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);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 o=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(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._lastBoundedInsertsRef=null,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,o,n,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||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,e);const l="chartType"in e&&e.chartType!==r.chartType||"runtimeMode"in e&&e.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const c=l||!z(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(o=r.xAccessor)&&void 0!==o?o:r.timeAccessor),u=l||!z(null!==(n=e.yAccessor)&&void 0!==n?n:e.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=Y(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=Y(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=Y(this.config.xAccessor,"x"),this.getY=Y(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ze(this.config)),s=!0,a=!0)}if("groupAccessor"in e&&!z(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?q(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!z(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?q(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!z(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?Y(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!z(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!z(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?Y(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in e&&!z(e.boundsAccessor,r.boundsAccessor)||"band"in e&&e.band!==r.band||"boundsStyle"in e&&e.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=ze(this.config),s=!0,a=!0),"pointIdAccessor"in e&&!z(e.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?q(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in e&&!z(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!z(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!z(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!z(e.lowAccessor,r.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?Y(this.config.openAccessor,"open"):void 0,this.getHigh=Y(this.config.highAccessor,"high"),this.getLow=Y(this.config.lowAccessor,"low"),this.getClose=t?Y(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0,a=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of t)if(e[o]!==r[o]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Ge(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:p.createElement(p.Fragment,null,...t)}function qe(e,t,o){return o.x>e||e>o.x+o.w||o.y>t||t>o.y+o.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:o.x+o.w/2,cy:o.y+o.h/2}}function Xe(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function Ve(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ue(e,t){const o=Ve(e);if(!o)return!1;const n=Ve(t);return!n||o.getFullYear()!==n.getFullYear()||o.getMonth()!==n.getMonth()}function Ke(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Qe(e,t,o,n,i){const r=Math.max(n,i+5,12),s=t-r,a=t+r,l=o-r,c=o+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-o,a=Math.sqrt(r*r+s*s);Xe(e.r,n)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}Ye.GROUP_COLOR_MAP_CAP=1e3,Ye.QUADTREE_THRESHOLD=500;const Ze=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Je=new WeakMap;let et=0,tt=!1,ot=null,nt=null,it=null;function rt(e,t){var o,n;if(!t)return t;const i=Ze.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(o=i[2])||void 0===o?void 0:o.trim())||t;!function(){if(tt)return;if("undefined"==typeof window||"undefined"==typeof document)return;tt=!0;const e=()=>{et++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(ot=new MutationObserver(e),ot.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{nt=window.matchMedia("(prefers-color-scheme: dark)"),it=e,"function"==typeof nt.addEventListener?nt.addEventListener("change",it):"function"==typeof nt.addListener&&nt.addListener(it)}catch(e){}}();let s=Je.get(r);s&&s.version===et||(s={version:et,map:new Map},Je.set(r,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(n=i[2])||void 0===n?void 0:n.trim())||t;return s.map.set(t,l),l}function st(e,t){const o=e.fillStyle,n="#010203";try{e.fillStyle=n,e.fillStyle=t}catch(t){return e.fillStyle=o,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=o,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===n&&t.trim().toLowerCase()!==n)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 at(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function lt(e,t,o){return null==t?o:"string"!=typeof t?t:rt(e,t)||o}function ct(e,t,o,n,i,r,s){if("colorStops"in t){const o=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>o.length)return null;const a=e.createLinearGradient(n,i,r,s);for(const e of o)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:l}=t;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=e.createLinearGradient(n,i,r,s),[h,g,f]=st(e,o);return d.addColorStop(0,`rgba(${h},${g},${f},${c})`),d.addColorStop(1,`rgba(${h},${g},${f},${u})`),d}function ut(e,t,o,n,i,r){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(o,n,i,r);for(const e of s)a.addColorStop(e.offset,e.color);return a}const dt=new WeakMap;function ht(e,t){const o=at(t);if(!o)return e;const n=dt.get(e);if(n)return n;const i=function(e,t,o=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const n=[];let i=null;const r={moveTo(e,t){i=[e,t],n.push([e,t])},lineTo(e,t){i=[e,t],n.push([e,t])},bezierCurveTo(e,t,r,s,a,l){if(!i)return i=[a,l],void n.push([a,l]);const[c,u]=i;for(let i=1;o>=i;i++){const d=i/o,h=1-d;n.push([h*h*h*c+3*h*h*d*e+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,o,r){i=[o,r],n.push([o,r])}};return s.line().x(e=>e[0]).y(e=>e[1]).curve(t).context(r)(e),n}(e,o);return dt.set(e,i),i}function gt(e,t,o,n=30,i,r=0){let s=null;if(i){const e=Qe(i,t,o,n,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=pt(r,t,o,n);break;case"line":e=yt(r,t,o,n);break;case"rect":if(null==r.datum)break;e=vt(r,t,o);break;case"heatcell":e=bt(r,t,o);break;case"area":if(!1===r.interactive)break;e=kt(r,t,o);break;case"candlestick":e=xt(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function ft(e,t,o){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const n=wt(e,t);if(0>n)return null;if(Math.abs(e[n][0]-t)>o)return null;let i=n,r=n;n>0&&e[n][0]>=t?(i=n-1,r=n):e.length-1>n&&(i=n,r=n+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 pt(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function yt(e,t,o,n=30){var i,r;if(0===e.path.length)return null;const s=wt(e.path,t);if(0>s)return null;const[a,l]=e.path[s];let c;if(e.path.length>1){let n=1/0;const i=Math.max(0,s-1),r=Math.min(e.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=e.path[s],[a,l]=e.path[s+1],c=mt(t,o,i,r,a,l);n>c&&(n=c)}c=n}else{const e=t-a,n=o-l;c=Math.sqrt(e*e+n*n)}const u=e.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,n)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:a,y:l,distance:c}}function mt(e,t,o,n,i,r){const s=i-o,a=r-n,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-o,2)+Math.pow(t-n,2));let c=((e-o)*s+(t-n)*a)/l;c=Math.max(0,Math.min(1,c));const u=n+c*a;return Math.sqrt(Math.pow(e-(o+c*s),2)+Math.pow(t-u,2))}function vt(e,t,o){const n=qe(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function bt(e,t,o){const n=qe(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function xt(e,t,o){const n=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-n-3>t||t>e.x+n+3||e.highY-3>o||o>e.lowY+3)){const n=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=o-n;return{node:e,datum:e.datum,x:e.x,y:n,distance:Math.sqrt(r*r+s*s)}}return null}function kt(e,t,o){if(0===e.topPath.length)return null;const n=wt(e.topPath,t);if(0>n)return null;const[i,r]=e.topPath[n],s=t-i,a=o-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:i,y:r,distance:l}}function wt(e,t){if(0===e.length)return-1;let o=0,n=e.length-1;for(;n>o;){const i=o+n>>1;t>e[i][0]?o=i+1:n=i}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}function At(e){var t,o;const n=new Map;for(const o of e){const e=null!==(t=o.group)&&void 0!==t?t:"_default";let i=n.get(e);i||(i=[],n.set(e,i)),i.push(o)}for(const e of n.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(n.keys()).sort((e,t)=>{const o=n.get(e),i=n.get(t);return(o.length>0?o[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(n.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===(o=r[e].datum)||void 0===o?void 0:o.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:n,idToIdx:s}}function jt(e,t){var o,n;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!==(o=r.group)&&void 0!==o?o:"_default",indexInGroup:null!==(n=r._groupIndex)&&void 0!==n?n:0}}function St(e,t,o){const{group:n,indexInGroup:i}=t,r=o.byGroup.get(n);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=o.groups.indexOf(n);return o.groups.length-1>e?Ot(o,o.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=o.groups.indexOf(n);return e>0?Ot(o,o.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*o.flat.length)),o.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*o.flat.length)),0);case"Home":return 0;case"End":return o.flat.length-1;case"Escape":return-1;default:return null}}function Ot(e,t,o){const n=e.byGroup.get(t);let i=0,r=Math.abs(n[0].x-o.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-o.x);r>t&&(r=t,i=e)}return n[i]._flatIndex}function Mt(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Ct(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}function _t(e,o,n,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=o.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),n.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}const Pt={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 Lt(e,t,o,n){let i;return i="function"==typeof o?o(e):(0,Pt[o])(n(e,t)),i}function Tt(){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 Rt(e,t,o){return o&&o.size>0?o.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Bt=(t,o,n,i,r,s,a,l,c,u)=>{const{type:d="fill",styleFn:h,items:g}=t,f=[];let p=0;const y=!(!o&&!n),m="isolate"===u||void 0===u&&null!=r;return g.forEach((t,u)=>{const v=Lt(t,u,d,h),b=Rt(t,i,r),x=r&&r.size>0&&r.has(t.label);f.push(e.jsxs("g",{transform:`translate(0,${p})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(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 n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(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 o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:y?e=>{c(l,u),n&&n(t);const o=e.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"},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(Tt,{}),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)),p+=22}),f};function Nt({config:t,orientation:o="vertical",width:n=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+p.useId();if("horizontal"===o){const t=12,o=Math.min(n,200),a=Math.max(0,(n-o)/2),u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[0]+o*(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+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:o,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+o,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 o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[1]-o*(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 Et(t){const{legendGroups:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical"}=t,[h,g]=p.useState(0),[f,y]=p.useState(0),m=p.useCallback((e,t)=>{g(e),y(t)},[]),v="vertical"===d?(({legendGroups:t,width:o,customClickBehavior:n,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:o,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:Bt(t,n,i,r,s,a,l,g,c,u)},"legend-group-"+g)),d+=22*t.items.length+8}),h})({legendGroups:o||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:a}):(({legendGroups:t,height:o,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d})=>{let h=0;const g=[];t.forEach((t,o)=>{let f=0;t.label&&(f+=16);const p=((t,o,n,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:g,items:f}=t,p=[];let y=0,m=0;const v=!(!o&&!n),b="isolate"===u||void 0===u&&null!=r;f.forEach((t,u)=>{const x=Lt(t,u,h,g),k=Rt(t,i,r),w=r&&r.size>0&&r.has(t.label),A=26+7*t.label.length;d&&d>0&&y>0&&y+A>d&&(m++,y=0),p.push(e.jsxs("g",{transform:`translate(${y},${22*m})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(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 n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(u+("ArrowRight"===e.key?1:-1)+f.length)%f.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:v?e=>{c(l,u),n&&n(t);const o=e.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"},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(Tt,{}),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+=A});let x=0,k=0;for(const e of f){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:p,offset:x,totalRows:w,totalHeight:22*w}})(t,i,r,s,a,l,c,o,u,d,n);f+=p.offset+5,g.push(Object.assign(Object.assign({label:t.label},p),{offset:f,totalRows:p.totalRows,totalHeight:p.totalHeight})),h+=f+12});let f=h>n?0:Math.max(0,(n-h)/2);const p=[];return g.forEach((n,i)=>{const r=t[i];r.label&&(p.push(e.jsx("text",{transform:`translate(${f},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)),f+=16),p.push(e.jsx("g",{className:"legend-item",transform:`translate(${f},0)`,children:n.items},"legend-group-"+i)),f+=n.offset+5,t[i+1]&&p.push(e.jsx("line",{stroke:"gray",x1:f,y1:-8,x2:f,y2:(n.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),f+=12}),e.jsx("g",{children:p})})({legendGroups:o||[],title:l,height:u,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:h,focusedItemIndex:f,onFocusedIndexChange:m,legendInteraction:a}),b=!(!n&&!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 Dt(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function It(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Ht(t){const{legend:o,totalWidth:n,totalHeight:i,margin:r,legendPosition:s="right",title:a,legendHoverBehavior:l,legendClickBehavior:c,legendHighlightedCategory:u,legendIsolatedCategories:d,legendInteraction:h}=t;if(!o)return null;const g="top"===s||"bottom"===s;let f,p;return"left"===s?(f=4,p=r.top):"top"===s?(f=0,p=a?32:8):"bottom"===s?(f=0,p=i-r.bottom+50):(f=n-r.right+10,p=r.top),e.jsx("g",{transform:`translate(${f}, ${p})`,children:It(o)?e.jsx(Nt,{config:o.gradient,orientation:g?"horizontal":"vertical",width:g?n:100}):Dt(o)?e.jsx(Et,{legendGroups:o.legendGroups,title:"",width:g?n:100,orientation:g?"horizontal":"vertical",customHoverBehavior:l,customClickBehavior:c,highlightedCategory:u,isolatedCategories:d,legendInteraction:h}):o})}function Ft(e){return"string"==typeof e?{type:e}:e}function Wt({orient:o,config:n,values:i,scale:r,size:s,length:l}){const c=function(e){var t,o,n,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(o=e.fill)&&void 0!==o?o:"#4e79a7",fillOpacity:null!==(n=e.fillOpacity)&&void 0!==n?n:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),u="top"===o||"bottom"===o,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const n=t[Math.floor(.25*o)],i=t[Math.floor(.5*o)],r=t[Math.floor(.75*o)],s=r-n;return{q1:n,median:i,q3:r,whiskerLow:Math.max(t[0],n-1.5*s),whiskerHigh:Math.min(t[o-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*n,20),f=(n-g)/2+4;if(u){const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="top"===o?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:u,y1:m+y*(f+g/2),x2:p,y2:m+y*(f+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*f,x2:u,y2:m+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:p,y1:m+y*f,x2:p,y2:m+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,n),y:"top"===o?m-f-g:m+f,width:Math.abs(n-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"===o?m-f-g:m+f,x2:i,y2:"top"===o?m-f:m+f+g,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="left"===o?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:m+y*(f+g/2),y1:u,x2:m+y*(f+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:u,x2:m+y*(f+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:p,x2:m+y*(f+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===o?m-f-g:m+f,y:Math.min(t,n),width:g,height:Math.abs(n-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===o?m-f-g:m+f,y1:i,x2:"left"===o?m-f:m+f+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-"+o,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*n;if(u){const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:n,y:"top"===o?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===o?-4-s:4,y:Math.min(n,n+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=n/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(n/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===o?-(t-s):t-s}`:`${"left"===o?-(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*(n/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===o?-(t+a):t+a}`:`${"left"===o?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+o,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*n,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===o?-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*n,s=r((e.x0+e.x1)/2);t.push(`L${"left"===o?-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-"+o,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,o,u,4]);return d?e.jsx("g",{className:"marginal-"+o,"data-testid":"marginal-"+o,children:d}):null}function $t(e,t=120,o=8){if(!e)return[];const n=Math.max(1,Math.floor(t/o)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>n?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function zt(e,t,o,n){return"curly"===e?n?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:n?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function Yt(t,o,n,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(o)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>o?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>o?"end":"start";const f=16,p=s?u?[s]:$t(s,c):[],y=r?u?[r]:$t(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))";p.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold",children:p.map((t,o)=>e.jsx("tspan",{x:m,dy:0===o?0:f,children:t},o))},"annotation-note-title")),v=p.length*f),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:g,y:v,children:y.map((t,o)=>e.jsx("tspan",{x:m,dy:0===o?0:f,children:t},o))},"annotation-note-label"));let k=null;if((s||r)&&(0!==o||0!==n))if("topBottom"===d){const t=Math.min(c,120);let o=0,n=t;"end"===g?(o=-t,n=0):"middle"===g&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:o,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let o=0,n=t;"bottom"===h?(o=-t,n=0):"middle"===h&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:o,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let A=0;return"topBottom"===d?A=0>n?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${o},${n})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:b}),k]})}function Gt(t,o,n,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==o?void 0:o.radius)||0)+((null==o?void 0:o.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==o?void 0:o.width)||0,i=(null==o?void 0:o.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==o?void 0:o.custom)&&a.push(...Array.isArray(o.custom)?o.custom:[o.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==o?void 0:o.x)){const i=(o.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(o.y1||0)-s,x2:i,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==o?void 0:o.y)){const i=(o.y||0)-s;a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:i,x2:(o.x2||0)-t,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==o?void 0:o.x1)||void 0!==(null==o?void 0:o.x2)?a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:0,x2:(o.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==o?void 0:o.y1)&&void 0===(null==o?void 0:o.y2)||a.push(e.jsx("line",{x1:0,y1:(o.y1||0)-s,x2:0,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==o?void 0:o.width)&&void 0!==s?s:null==o?void 0:o.height;void 0!==t&&a.push(e.jsx("path",{d:zt((null==o?void 0:o.type)||"curly",t,(null==o?void 0:o.depth)||30,void 0===(null==o?void 0:o.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function qt(t,o,n,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,n=s.height||0;if(e>0||n>0){const i=e/2,r=n/2,s=t-i,a=o-r;if(0!==s||0!==a){const t=Math.abs(s),o=Math.abs(a),u=e/2,d=n/2,h=t*d>o*u?u/t:d/o;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,o=s.depth||30;void 0!==e?(l=e/2,c=o):void 0!==t&&(l=o,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==o)){const n=Math.atan2(o,t);l=Math.cos(n)*e,c=Math.sin(n)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(o-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,s=Math.atan2(o-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+n*Math.cos(s+r)},${c+n*Math.sin(s+r)}L${l+n*Math.cos(s-r)},${c+n*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 Xt(t){const{x:o=0,y:n=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:f,events:p={},"data-testid":y}=t,m=new Set(Array.isArray(f)?f:[]);let v=i||0,b=r||0;null!=s&&(v=s-o),null!=a&&(b=a-n);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(${o},${n})`,"data-testid":y},p,{children:[!m.has("connector")&&qt(v,b,c,h,x,u),!m.has("subject")&&Gt(x,u,h,o,n),!m.has("note")&&Yt(l,v,b,h)]}))}function Vt(t){var o,n;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!==(o=i.dx)&&void 0!==o?o:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((o,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:o[0],y:o[1],nx:t,ny:a});return e.jsx(Xt,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+n)});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(Xt,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Ut(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.x)&&void 0!==n?n: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 Kt(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==n?n: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 Qt(e,t,o){var n,i,r,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const r=o.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(n=o.stickyPositionCache)||void 0===n||n.set(t,e),e}}const r=function(e){var t,o,n,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(o=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==o?o:null===(n=e.scales)||void 0===n?void 0:n.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)}}(o);return r&&(null===(i=o.stickyPositionCache)||void 0===i||i.set(t,r)),r}let l=null,c=null;if(null!=e.pointId&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Ut(e,o),c=Kt(e,o)),null!=l&&null!=c)return null===(r=o.stickyPositionCache)||void 0===r||r.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=o.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function Zt(e,t,o,n=50){return!(-n>e||e>(o.width||0)+n||-n>t||t>(o.height||0)+n)}const Jt={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};function eo(t){return function(t,o,n){var i,r,a,c,u,d,h,g,f,p,m,v,b,x,k,w,A,j,S,O,M,C,_,P,L,T,R,B,N,E,D,I,H,F,W,$,z,Y,G,q,X,V,U,K,Q,Z,J,ee;switch(t.type){case"label":{const i=Qt(t,o,n);if(!i)return null;const{x:r,y:s}=i;return Zt(r,s,n)?e.jsx(Vt,{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-"+o):null}case"callout":{const i=Qt(t,o,n);if(!i)return null;const{x:r,y:s}=i;return Zt(r,s,n)?e.jsx(Vt,{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-"+o):null}case"x-threshold":{const i=Ut(null!=t.value?Object.assign(Object.assign({},t),{x:t.value}):t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(n.height||0)-4:"center"===s?(n.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:n.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-"+o)}case"y-threshold":{const i=Kt(null!=t.value?Object.assign(Object.assign({},t),{y:t.value}):t,n);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=(n.width||0)/2,l="middle"):(a=(n.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:n.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-"+o)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),n),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),n),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-"+o)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),n),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),n)})).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-"+o)}case"highlight":{const i=n.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((o,i)=>{const r=Ut(o,n),a=Kt(o,n);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(o):t.r||6,c="function"==typeof t.style?t.style(o):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const i=Ut(t,n),r=Kt(t,n);return e.jsx(Vt,{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-"+o)}case"trend":{const s=n.data||[];if(2>s.length)return null;const l=n.xAccessor||"x",g=n.yAccessor||"y",f="ordinal"===n.frameType,p="horizontal"===n.projection,m=f?l:null,v=f?g:null;let b;const x=[],k=new Map;if(f&&m&&v){for(const e of s){const t=e[m];if(null==t)continue;const o=t+"";k.has(o)||(k.set(o,x.length),x.push(o))}b=s.map(e=>{const t=e[m],o=e[v];if(null==t||null==o)return null;const n=k.get(t+"");return null!=n?[n,+o]:null}).filter(e=>null!==e)}else b=s.map(e=>[e[l],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>b.length)return null;const w=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(a=n.scales)||void 0===a?void 0:a.time,A=null!==(u=null===(c=n.scales)||void 0===c?void 0:c.y)&&void 0!==u?u:null===(d=n.scales)||void 0===d?void 0:d.value;if(!w||!A)return null;const j=e=>t=>{const o=Math.max(0,Math.floor(t)),n=Math.min(x.length-1,o+1),i=t-o,r=e(x[o]);return r+(e(x[n])-r)*i},S=w,O=A;let M;if(f)if(p){const e=j(O);M=(t,o)=>[S(o),e(t)]}else{const e=j(S);M=(t,o)=>[e(t),O(o)]}else M=(e,t)=>[S(e),O(t)];const C=t.method||"linear";let _;_="loess"===C?function(e,t=.3){const o=e.length;if(2>o)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.max(2,Math.ceil(t*o)),a=[];for(let e=0;o>e;e++){const t=i[e],n=i.map(e=>Math.abs(e-t)),l=n.slice().sort((e,t)=>e-t)[Math.min(s-1,o-1)]||1,c=[];for(let e=0;o>e;e++){const t=0===l?0:n[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;o>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],g+=t*i[e]*i[e],f+=t*i[e]*r[e])}if(0===u){a.push([t,r[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}(b,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===C?y.default.polynomial(b,{order:t.order||2}):y.default.linear(b)).points;const P=_.map(([e,t])=>{const[o,n]=M(e,t);return`${o},${n}`}).join(" "),L=t.color||"#6366f1",T=_[_.length-1],[R,B]=M(T[0],T[1]);return e.jsxs("g",{children:[e.jsx("polyline",{points:P,fill:"none",stroke:L,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:R+4,y:B-4,fill:L,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const i=null!==(f=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==f?f:null===(p=n.scales)||void 0===p?void 0:p.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:n.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:n.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+o)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",a=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,l=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(j=n.scales)||void 0===j?void 0:j.value;if(!a||!l)return null;const c=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[c]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=Jt[n.curve||"linear"]||s.curveLinear,f=s.area().x(e=>a(e[r])).y0(e=>l(e[u])).y1(e=>l(e[c])).curve(g)(h);if(!f)return null;const p=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:f,fill:p,fillOpacity:null!==(S=t.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:a(h[h.length-1][r])+4,y:l(h[h.length-1][c])-4,fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",s=null!==(M=null===(O=n.scales)||void 0===O?void 0:O.x)&&void 0!==M?M:null===(C=n.scales)||void 0===C?void 0:C.time,a=null!==(P=null===(_=n.scales)||void 0===_?void 0:_.y)&&void 0!==P?P:null===(L=n.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!==(T=t.threshold)&&void 0!==T?T:2,g=c-h*d,f=!1!==t.showBand,p=t.fill||"#6366f1",y=null!==(R=t.fillOpacity)&&void 0!==R?R:.1,m=t.anomalyColor||"#ef4444",v=null!==(B=t.anomalyRadius)&&void 0!==B?B: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:[f&&e.jsx("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((t,o)=>{const i=Ut(t,n),r=Kt(t,n);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-"+o)}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",s=n.yAccessor||"y",a=null!==(E=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==E?E:null===(D=n.scales)||void 0===D?void 0:D.time,l=null!==(H=null===(I=n.scales)||void 0===I?void 0:I.y)&&void 0!==H?H:null===(F=n.scales)||void 0===F?void 0:F.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=y.default.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,o,n)=>e+o*Math.pow(t,n),0)}else{const e=c.length;let t=0,o=0,n=0,i=0;for(const[e,r]of c)t+=e,o+=r,n+=e*e,i+=e*r;const r=e*n-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*o)/r,a=(o-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,p=c.reduce((e,t)=>e+Math.pow(t[0]-f,2),0),m=null!==(W=t.confidence)&&void 0!==W?W:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==($=t.steps)&&void 0!==$?$: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 A=[];for(const e of w){const t=u(e),o=g*Math.sqrt(1+1/d+(p>0?Math.pow(e-f,2)/p:0))*v;A.push({x:e,yCenter:t,yUpper:t+o,yLower:t-o})}const j=`M${A.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),O=`${a(x)},${l(u(x))}`,M=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:j,fill:t.fill||"#6366f1",fillOpacity:null!==(z=t.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),e.jsx("polyline",{points:`${O} ${S}`,fill:"none",stroke:M,strokeWidth:null!==(Y=t.strokeWidth)&&void 0!==Y?Y:2,strokeDasharray:null!==(G=t.strokeDasharray)&&void 0!==G?G:"6,3"}),t.label&&A.length>0&&e.jsx("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:M,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=Qt(t,o,n);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!Zt(i,r,n))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!==(K=t.content)&&void 0!==K?K: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-"+o)}case"text":{const i=Qt(t,o,n);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-"+o)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,s=null===(Q=n.scales)||void 0===Q?void 0:Q.o,a=null===(Z=n.scales)||void 0===Z?void 0:Z.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,c=r(s)?s:r(a)?a:r(l)?l:null;if(!c)return null;const u=c(i+"");if(null==u)return null;const d=c.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",g=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,f=t.label;return e.jsxs("g",(n.projection?"vertical"===n.projection:c===a)?{children:[e.jsx("rect",{x:u,y:0,width:d,height:n.height||0,fill:h,fillOpacity:g}),f&&e.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]}:{children:[e.jsx("rect",{x:0,y:u,width:n.width||0,height:d,fill:h,fillOpacity:g}),f&&e.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+o)}default:return null}}}let to={positions:new Map};const oo=new Set;function no(){for(const e of oo)e()}function io(e,t){const o=to.positions.get(e);if(null==o?void 0:o.locked)return;if(!o||o.sourceId!==t)return;const n=new Map(to.positions);n.delete(e),to={positions:n},no()}function ro(e,t){const o=to.positions.get(e);if(!(null==o?void 0:o.locked))return;if(t&&o.sourceId!==t)return;const n=new Map(to.positions);n.delete(e),to={positions:n},no()}function so(){return to}function ao(e){return oo.add(e),()=>oo.delete(e)}const lo={positions:new Map};function co(){return()=>{}}function uo(){return lo}function ho(e,t,o){return"exact"===o?function(e,t){const o=e.domain(),n=o[0],i=o[o.length-1],r=n instanceof Date,s=n instanceof Date?n.getTime():n,a=i instanceof Date?i.getTime():i;if(2>t||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(t-1),c=Array(t);for(let e=0;t>e;e++){const o=e===t-1?a:s+e*l;c[e]=r?new Date(o):o}return c}(e,t):e.ticks(t)}function go(e,t,o){if("edges"===e){if(t)return"start";if(o)return"end"}return"middle"}function fo(e,t,o){if("edges"===e){if(t)return"hanging";if(o)return"auto"}return"middle"}function po(e){if(0===e.length)return{min:null,max:null};let t=1/0,o=-1/0;for(const n of e)t>n.pixel&&(t=n.pixel),n.pixel>o&&(o=n.pixel);return{min:t,max:o}}function yo(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function mo(e,t,o){if("left"===e||"right"===e){const n="left"===e?o:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+n;for(let e=0;r>e;e++){const o=8*(e+1);s+=`L${Math.min(8*e+4,t)},${n+4*i}`,s+=`L${Math.min(o,t)},${n}`}return s}{const n="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(o/8);let s=`M${n},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${n+4*i},${Math.min(8*e+4,o)}`,s+=`L${n},${Math.min(t,o)}`}return s}}function vo(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:g,axisExtent:f}=o,p=t.useMemo(()=>{var e,t;if(!l)return[];const o=null==u?void 0:u.find(e=>"bottom"===e.orient),i=(null==o?void 0:o.tickFormat)||h||bo,r=Math.max(2,Math.floor(n/70)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5,a=null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(l.x,"exact"===f?Math.max(2,s):Math.min(s,r),f),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:l.x(e),label:i(e,t,c)})),g=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return xo(d,Math.max(55,g+8))},[l,u,h,n,f]),y=t.useMemo(()=>{var e,t;if(!l)return[];const o=null==u?void 0:u.find(e=>"left"===e.orient),n=(null==o?void 0:o.tickFormat)||g||bo,r=Math.max(2,Math.floor(i/30)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5;return xo((null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(l.y,"exact"===f?Math.max(2,s):Math.min(s,r),f)).map(e=>({value:e,pixel:l.y(e),label:n(e)})),22)},[l,u,g,i,f]),m=d&&l,v=c&&l;if(!m&&!v)return null;const b=null==u?void 0:u.find(e=>"bottom"===e.orient),x=null==u?void 0:u.find(e=>"left"===e.orient),k=v&&(!b||!1!==b.baseline),w=v&&(!x||!1!==x.baseline),A=(null==b?void 0:b.jaggedBase)||!1,j=(null==x?void 0:x.jaggedBase)||!1,S="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:[m&&(()=>{var t,o;const r=yo(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=yo(null===(o=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[p.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+o)),y.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+o))]})})(),k&&!A&&e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:S,strokeWidth:1}),A&&e.jsx("path",{d:mo("bottom",n,i),fill:"none",stroke:S,strokeWidth:1}),w&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:S,strokeWidth:1}),j&&e.jsx("path",{d:mo("left",n,i),fill:"none",stroke:S,strokeWidth:1})]})})}function bo(e,t,o){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function xo(e,t){if(2>=e.length)return e;const o=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-o[o.length-1].pixel)||o.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-o[o.length-1].pixel)?o[o.length-1]=n:o.push(n),o}function ko(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,axes:h,xLabel:g,yLabel:f,yLabelRight:p,xFormat:y,yFormat:m,axisExtent:v,showGrid:b,title:x,legend:k,legendHoverBehavior:w,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S,legendPosition:O="right",foregroundGraphics:M,marginalGraphics:C,xValues:_,yValues:P,annotations:L,svgAnnotationRules:T,xAccessor:R,yAccessor:B,annotationData:N,pointNodes:E,curve:D,underlayRendered:I,canvasObscuresUnderlay:H=!0,linkedCrosshairName:F,linkedCrosshairSourceId:W,children:$}=o,z=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=(null==o?void 0:o.tickFormat)||y||bo,i=Math.max(2,Math.floor(r/70)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5,a=null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(u.x,"exact"===v?Math.max(2,s):Math.min(s,i),v),l=a.map(e=>e.valueOf()),c=a.map((e,t)=>({value:e,pixel:u.x(e),label:n(e,t,l)})),g=c.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),f=(null==o?void 0:o.autoRotate)?Math.max(20,Math.min(g+8,55)):Math.max(55,g+8);let p=xo(c,f);if(p.length>1&&(p=p.filter((e,t)=>0===t||e.label+""!=p[t-1].label+"")),(null==o?void 0:o.includeMax)&&p.length>0&&"exact"!==v&&!(null==o?void 0:o.tickValues)){const e=u.x.domain()[1],t=u.x(e),o=p[p.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e,p.length,l);f>t-o&&p.length>1&&(p=p.slice(0,-1)),p.push({value:e,pixel:t,label:i})}}return p},[d,u,h,y,r,v]),Y=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"left"===e.orient),n=(null==o?void 0:o.tickFormat)||m||bo,i=Math.max(2,Math.floor(s/30)),r=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5;let a=xo((null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:n(e)})),22);if(a.length>1&&(a=a.filter((e,t)=>0===t||e.label+""!=a[t-1].label+"")),(null==o?void 0:o.includeMax)&&a.length>0&&"exact"!==v&&!(null==o?void 0:o.tickValues)){const e=u.y.domain()[1],t=u.y(e),o=a[a.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&a.length>1&&(a=a.slice(0,-1)),a.push({value:e,pixel:t,label:i})}}return a},[d,u,h,m,s,v]),G=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"right"===e.orient);if(!o)return[];const n=o.tickFormat||m||bo,i=Math.max(2,Math.floor(s/30)),r=null!==(e=o.ticks)&&void 0!==e?e:5;return xo((null!==(t=o.tickValues)&&void 0!==t?t:ho(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:n(e)})),22)},[d,u,h,m,s,v]),q=t.useRef(new Map),X=t.useRef(null!==(n=null==L?void 0:L.length)&&void 0!==n?n:0),V=null!==(i=null==L?void 0:L.length)&&void 0!==i?i:0;X.current!==V&&(X.current=V,q.current=new Map);const U=t.useMemo(()=>{if(!L||0===L.length)return null;const e=eo(),t={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:R,yAccessor:B,width:r,height:s,data:N,frameType:"xy",pointNodes:E,curve:D,stickyPositionCache:q.current};return L.map((o,n)=>{if(T){const i=T(o,n,t);return null!=i?i:e(o,n,t)}return e(o,n,t)}).filter(Boolean)},[L,T,r,s,R,B,N,u,E,D]),K=function(e){var o;const n=t.useSyncExternalStore(e?ao:co,e?so:uo,e?so:uo);return e&&null!==(o=n.positions.get(e))&&void 0!==o?o:null}(F);return t.useEffect(()=>{if(!(null==K?void 0:K.locked)||!F)return;const e=e=>{"Escape"===e.key&&ro(F)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==K?void 0:K.locked,F]),d||x||k||M||C||U&&U.length>0||b||$||K?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof x?x:"XY Chart"}),e.jsx("desc",{children:"string"==typeof x?x+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[b&&u&&(!I||H)&&(()=>{var t,o;const n=yo(null===(t=null==h?void 0:h.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=yo(null===(o=null==h?void 0:h.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[z.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"xgrid-"+o)),Y.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+o))]})})(),d&&u&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=!t||!1!==t.baseline,i=!o||!1!==o.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,d=null==t?void 0:t.landmarkTicks,y="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",b=!!(null==o?void 0:o.autoRotate)&&z.length>1&&(()=>{const e=r/Math.max(z.length-1,1);return z.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x={fontSize:"var(--semiotic-tick-font-size, 10px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 10px) + 1px)"},w={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=null==o?void 0:o.tickAnchor,j=null==t?void 0:t.tickAnchor,S=po(z),O=po(Y);return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!I||H)&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:y,strokeWidth:1}),(!I||H)&&l&&e.jsx("path",{d:mo("bottom",r,s),fill:"none",stroke:y,strokeWidth:1}),z.map((t,o)=>{const n=!!u&&("function"==typeof u?u(t.value,o):Ue(t.value,o>0?z[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":go(A,t.pixel===S.min,t.pixel===S.max),fontWeight:n?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},n?k:x),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:Object.assign({textAlign:"center",userSelect:"none"},x),children:t.label})})]},"xtick-"+o)}),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!I||H)&&n&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:y,strokeWidth:1}),(!I||H)&&a&&e.jsx("path",{d:mo("left",r,s),fill:"none",stroke:y,strokeWidth:1}),Y.map((t,o)=>{const n=!!d&&("function"==typeof d?d(t.value,o):Ue(t.value,o>0?Y[o-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:fo(j,t.pixel===O.min,t.pixel===O.max),fontWeight:n?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},n?k:x),children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},x),children:t.label})})]},"ytick-"+o)}),(()=>{const o=(null==t?void 0:t.label)||f;return o?e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:o}):null})()]}),(()=>{const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t||0===G.length)return null;const o=!1!==t.baseline,n=t.landmarkTicks,i=t.label||p,a=t.tickAnchor,l=po(G);return e.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:y,strokeWidth:1}),G.map((t,o)=>{const i=!!n&&("function"==typeof n?n(t.value,o):Ue(t.value,o>0?G[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${r},${t.pixel})`,children:[e.jsx("line",{x2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:fo(a,t.pixel===l.min,t.pixel===l.max),fontWeight:i?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?k:x),children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"left",userSelect:"none"},x),children:t.label})})]},"ytick-r-"+o)}),i&&e.jsx("text",{x:r+c.right-15,y:s/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${r+c.right-15}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:i})]})})()]})})(),U,C&&u&&_&&P&&e.jsxs(e.Fragment,{children:[C.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(Wt,{orient:"top",config:Ft(C.top),values:_,scale:u.x,size:c.top,length:r})}),C.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx(Wt,{orient:"bottom",config:Ft(C.bottom),values:_,scale:u.x,size:c.bottom,length:r})}),C.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(Wt,{orient:"left",config:Ft(C.left),values:P,scale:u.y,size:c.left,length:s})}),C.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx(Wt,{orient:"right",config:Ft(C.right),values:P,scale:u.y,size:c.right,length:s})})]}),M,K&&K.sourceId!==W&&(null==u?void 0:u.x)&&(()=>{const t=u.x(K.xValue);if(null==t||0>t||t>r)return null;const o=K.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),$]}),x&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof x?x:null}),Ht({legend:k,totalWidth:a,totalHeight:l,margin:c,legendPosition:O,title:x,legendHoverBehavior:w,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S})]}):null}function wo(e){var t,o,n,i;return(null!==(t=e.tl)&&void 0!==t?t:0)>0||(null!==(o=e.tr)&&void 0!==o?o:0)>0||(null!==(n=e.br)&&void 0!==n?n:0)>0||(null!==(i=e.bl)&&void 0!==i?i:0)>0}function Ao(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const o=Math.min(e.w,e.h)/2,n=e=>Math.max(0,Math.min(null!=e?e:0,o));return{tl:n(t.tl),tr:n(t.tr),br:n(t.br),bl:n(t.bl)}}const jo=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function So(e){var t,o;const{innerRadius:n,outerRadius:i,startAngle:r,endAngle:s}=e,a=0>=n;if(0>=(null!==(t=e.cornerRadius)&&void 0!==t?t:0)||!e.roundStart&&!e.roundEnd){if(a){const e=jo(i,r),t=jo(i,s);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=jo(i,r),t=jo(i,s),o=jo(n,s),l=jo(n,r),c=s-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${t.x},${t.y} L${o.x},${o.y} A${n},${n} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(o=e.cornerRadius)&&void 0!==o?o:0,(i-n)/2));if(0===l)return So(Object.assign(Object.assign({},e),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,n+l))),d=(s-r)/2,h=!!e.roundStart&&d>c,g=!!e.roundEnd&&d>c;if(!h&&!g)return So(Object.assign(Object.assign({},e),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const f=r+(h?c:0),p=s-(g?c:0),y=r+(h?u:0),m=s-(g?u:0),v=jo(i,f),b=jo(i,p),x=(i-l)*Math.cos(c),k=jo(x,r),w=jo(x,s),A=a?null:jo(n,m),j=a?null:jo(n,y),S=a?0:(n+l)*Math.cos(u),O=a?null:jo(S,r),M=a?null:jo(S,s),C=p-f>Math.PI?1:0,_=a?0:m-y>Math.PI?1:0;let P="";if(h)P+=`M${k.x},${k.y}`,P+=` A${l},${l} 0 0 1 ${v.x},${v.y}`;else{const e=jo(i,r);P+=`M${e.x},${e.y}`}if(g)P+=` A${i},${i} 0 ${C} 1 ${b.x},${b.y}`,P+=` A${l},${l} 0 0 1 ${w.x},${w.y}`;else{const e=jo(i,s);P+=` A${i},${i} 0 ${C} 1 ${e.x},${e.y}`}if(a)P+=" L0,0";else{if(g)P+=` L${M.x},${M.y}`,P+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const e=jo(n,s);P+=` L${e.x},${e.y}`}if(h)P+=` A${n},${n} 0 ${_} 0 ${j.x},${j.y}`,P+=` A${l},${l} 0 0 1 ${O.x},${O.y}`;else{const e=jo(n,r);P+=` A${n},${n} 0 ${_} 0 ${e.x},${e.y}`}}return P+=" Z",P}const Oo={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Mo(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}const Co="undefined"==typeof window||"undefined"==typeof document,_o="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function Po(){const[e,o]=t.useState(!1);return _o(()=>{o(!0)},[]),e}const Lo=()=>()=>{},To=()=>!1,Ro=()=>!0;function Bo(){const e=t.useSyncExternalStore(Lo,To,Ro);return t.useRef(e).current}function No(e){const{hydrated:o,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=e;_o(()=>{var e,t;o&&n&&(null===(t=null===(e=i.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),r.current=!0,s.current()},[o,n]);const l=t.useRef(a);l.current=a,t.useEffect(()=>()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)},[])}function Eo(e){const o=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Io(e,t);if(!Ho(e)||!Ho(t))return!1;const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(const n of o){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;const o=e[n],i=t[n];if(!Object.is(o,i))if(Array.isArray(o)&&Array.isArray(i)){if(!Io(o,i))return!1}else{if(!Ho(o)||!Ho(i))return!1;if(!Do(o,i))return!1}}return!0}(o.current,e)||(o.current=e),o.current}function Do(e,t){const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(const n of o){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!Object.is(e[n],t[n]))return!1}return!0}function Io(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(!Object.is(e[o],t[o]))return!1;return!0}function Ho(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}const Fo=p.createContext(null);function Wo({children:t}){const[o,n]=p.useState(!1),i=p.useMemo(()=>({visible:o,setVisible:n}),[o]);return e.jsx(Fo.Provider,{value:i,children:t})}function $o(){return p.useContext(Fo)}const zo={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function Yo(e,t){if(!e||0===e.length)return t+", empty";const o={};for(const t of e){const e=t.type+"";o[e]=(o[e]||0)+1}const n=[],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(o).sort((e,t)=>{const o=r.indexOf(e),n=r.indexOf(t);return(-1===o?999:o)-(-1===n?999:n)});for(const e of s)n.push(`${o[e]} ${i[e]||e}`);return`${t}, ${n.join(", ")}`}function Go(e,t,o){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?o+", empty":`${o}, ${n.join(", ")}`}const qo=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Xo={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"},Vo={marginBottom:8,paddingRight:28,color:"var(--semiotic-text-secondary, #666)",fontSize:12,letterSpacing:"0.01em"},Uo={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)"},Ko={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Qo={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)"},Zo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},Jo={textAlign:"left",fontSize:11,color:"var(--semiotic-text-secondary, #999)",marginBottom:4,fontStyle:"italic"};function en({scene:t,chartType:o,tableId:n,chartTitle:i}){var r;const[s,a]=p.useState(!1),l=$o(),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=p.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${o} ${n}`:"Data summary for "+o,g=p.useCallback(()=>{s||c||a(!0)},[s,c]),f=p.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 n?e.jsx("span",{id:n,tabIndex:-1,style:zo}):null;if(!u)return e.jsx("div",{id:n,tabIndex:-1,onFocus:g,style:zo,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,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,j,S;const O=[];if(!Array.isArray(e))return O;for(const M of e)if(M&&"object"==typeof M)try{switch(M.type){case"point":O.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 o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.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 o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&O.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:{},r=null!==(o=null!==(t=e.category)&&void 0!==t?t:M.group)&&void 0!==o?o:"",s=null!==(i=null!==(n=e.value)&&void 0!==n?n:e.__aggregateValue)&&void 0!==i?i:e.total;O.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":O.push({label:"Cell",values:{x:M.x,y:M.y,value:M.value}});break;case"wedge":O.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=M.datum)||void 0===r?void 0:r.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":O.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":O.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":O.push({label:"Candlestick",values:{x:M.x,open:M.open,high:M.high,low:M.low,close:M.close}});break;case"geoarea":O.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===(j=M.datum)||void 0===j?void 0:j.value)&&void 0!==S?S:""}})}}catch(e){}return O}(t),m=function(e){if(!e||0===e.length)return[];const t=new Set;for(const o of e)if(o&&o.values)for(const e of Object.keys(o.values))t.add(e);const o=[];for(const n of t){const t=[],i=new Set;for(const o of e){if(!o||!o.values)continue;const e=o.values[n];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 o of t)e>o&&(e=o),o>i&&(i=o),r+=o;o.push({name:n,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);o.push({name:n,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return o}(y),v=function(e,t){const o=[e+" data points."];for(const e of t)if(e.numeric)o.push(`${e.name}: ${qo(e.min)} to ${qo(e.max)}, mean ${qo(e.mean)}.`);else{const t=e.uniqueValues,n=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");o.push(`${e.name}: ${n}.`)}return o.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:n,tabIndex:-1,onBlur:f,style:Xo,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:Uo,children:"×"}),e.jsx("div",{role:"note",style:Vo,children:v}),e.jsxs("table",{role:"table","aria-label":"Sample data for "+o,style:Ko,children:[e.jsxs("caption",{style:Jo,children:["First ",b.length," of ",y.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Qo,children:"type"}),k.map(t=>e.jsx("th",{style:Qo,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Zo,children:t.label}),k.map(o=>{return e.jsx("td",{style:Zo,children:(n=t.values[o],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":qo(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},o);var n})]},o))})]})]})}function tn({nodes:t,edges:o,chartType:n,tableId:i,chartTitle:r}){var s,a,l,c,u,d,h,g,f,y,m,v,b,x;const[k,w]=p.useState(!1),A=$o(),j=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,S=k||j,O=r?"Data summary for "+r:i?`Data summary for ${n} ${i}`:"Data summary for "+n,M=p.useRef(null),C=p.useCallback(()=>{k||j||w(!0)},[k,j]),_=p.useCallback(e=>{var t;j||(null===(t=M.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[j]);if(!t||0===t.length)return i?e.jsx("span",{id:i,tabIndex:-1,style:zo}):null;if(!S)return e.jsx("div",{id:i,tabIndex:-1,onFocus:C,style:zo,role:"region","aria-label":O,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",o.length," edges)"]})});const P=Array.isArray(t)?t:[],L=Array.isArray(o)?o:[],T=new Map,R=new Map,B=new Map,N=new Map;for(const e of L){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,o="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=o&&""!==o){const e=o+"";R.set(e,(null!==(u=R.get(e))&&void 0!==u?u:0)+1),N.set(e,(null!==(d=N.get(e))&&void 0!==d?d:0)+i)}if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+1),B.set(e,(null!==(g=B.get(e))&&void 0!==g?g:0)+i)}}const E=[];for(let e=0;P.length>e;e++){const t=P[e];if(!t||"object"!=typeof t)continue;const o=null!==(y=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:t.id,n=null!=o?o+"":"node-"+e,i=null!==(m=T.get(n))&&void 0!==m?m:0,r=null!==(v=R.get(n))&&void 0!==v?v:0,s=null!==(b=B.get(n))&&void 0!==b?b:0,a=null!==(x=N.get(n))&&void 0!==x?x:0;E.push({id:n,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}E.sort((e,t)=>t.degree-e.degree);let D=0,I=0;if(E.length>0){let e=0;for(const t of E)e+=t.degree,t.degree>I&&(I=t.degree);D=e/E.length}const H=L.some(e=>{var t;const o=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==o?void 0:o.value)&&Number.isFinite(o.value)}),F=[`${E.length} nodes, ${L.length} edges.`];E.length>0&&F.push(`Mean degree: ${qo(D)}, max degree: ${I}.`);const W=E.slice(0,5);return e.jsxs("div",{ref:M,id:i,tabIndex:-1,onBlur:_,style:Xo,role:"region","aria-label":O,children:[e.jsx("button",{type:"button",onClick:()=>{j&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:Uo,children:"×"}),e.jsx("div",{role:"note",style:Vo,children:F.join(" ")}),e.jsxs("table",{role:"table","aria-label":"Node degree summary for "+n,style:Ko,children:[e.jsxs("caption",{style:Jo,children:["Top ",W.length," of ",E.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Qo,children:"id"}),e.jsx("th",{style:Qo,children:"degree"}),e.jsx("th",{style:Qo,children:"in"}),e.jsx("th",{style:Qo,children:"out"}),H&&e.jsx("th",{style:Qo,children:"w. degree"}),H&&e.jsx("th",{style:Qo,children:"w. in"}),H&&e.jsx("th",{style:Qo,children:"w. out"})]})}),e.jsx("tbody",{children:W.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:Zo,children:t.id}),e.jsx("td",{style:Zo,children:t.degree}),e.jsx("td",{style:Zo,children:t.inDeg}),e.jsx("td",{style:Zo,children:t.outDeg}),H&&e.jsx("td",{style:Zo,children:qo(t.wDegree)}),H&&e.jsx("td",{style:Zo,children:qo(t.wInDeg)}),H&&e.jsx("td",{style:Zo,children:qo(t.wOutDeg)})]},o))})]})]})}function on({summary:t}){return t?e.jsx("div",{role:"note",style:zo,children:t}):null}function nn({tableId:t}){return e.jsx("a",{href:"#"+t,style:zo,onClick:e=>{e.preventDefault();const o=document.getElementById(t);o&&requestAnimationFrame(()=>o.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,zo)},children:"Skip to data table"})}function rn({hoverPoint:t}){let o="";if(t){const e=t.data||t;o="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:zo,children:o})}const sn="var(--semiotic-focus, #005fcc)";function an({active:t,hoverPoint:o,margin:n,size:i,shape:r="circle",width:s,height:a}){if(!t||!o)return null;const l=o.x+n.left,c=o.y+n.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),o=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-o/2-3,width:t+6,height:o+6,rx:3,fill:"none",stroke:sn,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:sn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:sn,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})}const ln={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 cn(e,t){return"function"==typeof t?t(e):e[t]}function un(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 dn(t={}){const{fields:o,title:n,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(n){const e=cn(t,n);a=un(e,i)}if(o&&o.length>0)o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=cn(t,n);l.push({label:o,value:un(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const o of e)if(void 0!==t[o]){a=un(t[o],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=un(t[e[0]],i))}}const c=Object.assign(Object.assign({},ln),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,o)=>e.jsxs("div",{style:{marginTop:0===o&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},o))]})}}function hn(){return t=>{var o,n,i,r,s,a,l;const c=t.allSeries;if(!c||0===c.length){const r=null!==(n=null===(o=t.data)||void 0===o?void 0:o.value)&&void 0!==n?n:null===(i=t.data)||void 0===i?void 0:i.y;return e.jsx("div",{className:"semiotic-tooltip",style:ln,children:e.jsx("div",{children:un(r)})})}const u=null!==(a=null!==(r=t.xValue)&&void 0!==r?r:null===(s=t.data)||void 0===s?void 0:s.time)&&void 0!==a?a:null===(l=t.data)||void 0===l?void 0:l.x;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[null!=u&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:un(u)}),c.map((t,o)=>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:un(t.value)})]},o))]})}}function gn(t){if(!0!==t){if("function"==typeof t){const o=t;return t=>{var n;const i=!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(n=t.data)&&void 0!==n?n:{}:t,r=o(i);return null==r?null:e.jsx("div",{className:"semiotic-tooltip",style:ln,children:r})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?dn(t):dn())}}function fn({x:t,y:o,containerWidth:n,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(t)&&Number.isFinite(o),u=p.useRef(null),[d,h]=p.useState(null);p.useLayoutEffect(()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect();h(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,n,i]);let g;g=d?`translate(${d.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-o?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>o?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!p.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const o=e.props;if("string"==typeof o.className&&o.className.trim().length>0)return!0;const n=o.style;if(n&&"object"==typeof n){if(null!=n.background&&""!==n.background)return!0;if(null!=n.backgroundColor&&""!==n.backgroundColor)return!0}return!1}(s),y=f?null:ln;return c?e.jsx("div",{ref:u,className:f?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:r.left+t,top:r.top+o,transform:g,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}function pn(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const o=e;return o.addListener(t),()=>o.removeListener(t)}function yn(e,o,n){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!o&&!n)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:o}=t.contentRect;s(t=>t&&t.w===e&&t.h===o?t:{w:e,h:o})}});return t.observe(e),()=>t.disconnect()},[o,n]),[i,[o&&r?r.w:e[0],n&&r?r.h:e[1]]]}const mn="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function vn(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function bn(e){const o=function(){const[e,o]=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 o(e.matches),pn(e,e=>o(e.matches))},[]),e}(),n=t.useRef(o);n.current=o;const[i,r]=yn(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=vn(e.foregroundGraphics,r,s),u=vn(e.backgroundGraphics,r,s),d=R(e=>e.theme),{transition:h,introEnabled:g}=function(e,t){var o,n;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(o=window.matchMedia)||void 0===o?void 0:o.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+p.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),A=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),j=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),S=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 O=e.themeDirtyRef;return mn(()=>{O&&(et++,O.current=!0,v())},[d,v,O]),{reducedMotion:o,reducedMotionRef:n,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:g,tableId:f,rafRef:y,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:j,onPointerLeave:S}}function xn(e,t,o,n){const i=e.getContext("2d");if(!i)return null;const r=t[0]*n,s=t[1]*n,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(n,0,0,n,0,0),i.translate(o.left,o.top),i}function kn(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function wn(e,t,o){let n=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(n=o.color):e>o.value&&(n=o.color);return n}function An(e,t,o,n,i,r){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const o=t[e][0]-t[e-1][0],n=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(o*o+n*n))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=o,e.lineWidth=n,e.lineCap=r;for(let o=0;t.length-1>o;o++){const n=(s[o]+s[o+1])/2;let r=i;l>n&&(r*=n/l),l>a-n&&(r*=(a-n)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[o][0],t[o][1]),e.lineTo(t[o+1][0],t[o+1][1]),e.stroke()}}const jn=(e,t,o,n)=>{var i,r;const a=t.filter(e=>"line"===e.type);for(const l of a){if(2>l.path.length)continue;const c=l._introClipFraction;void 0!==c&&1>c&&(e.save(),e.beginPath(),e.rect(0,0,n.width*c,n.height),e.clip());const u=l.style.stroke||"#007bff",d=rt(e,u)||u,h=l.style.strokeWidth||2,g=l.colorThresholds,f=l.rawValues;if(e.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(e.globalAlpha=l.style.opacity),e.lineWidth=h,e.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const v=null!==(i=l.style.opacity)&&void 0!==i?i:1;An(e,l.path,d,h,v,l.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=at(l.curve),y=g&&g.length>0&&f&&f.length===l.path.length,m=l._decayOpacities;if(m&&m.length===l.path.length&&!y){e.strokeStyle=d;const b=null!==(r=l.style.opacity)&&void 0!==r?r:1;for(let x=0;l.path.length-1>x;x++)e.globalAlpha=.5*(m[x]+m[x+1])*b,e.beginPath(),e.moveTo(l.path[x][0],l.path[x][1]),e.lineTo(l.path[x+1][0],l.path[x+1][1]),e.stroke()}else if(y){let k=null,w=null,A=null,j=null,S=!1;function O(t,o,n){e.beginPath(),e.strokeStyle=t,e.moveTo(o,n),S=!0}function M(){S&&(e.stroke(),S=!1)}for(let C=0;l.path.length>C;C++){const[_,P]=l.path[C],L=f[C],T=wn(L,g,d);if(null!==k&&null!==j&&null!==A){if(T===j)e.lineTo(_,P);else{const R=[];for(const B of g){const N=B.value;(A>N||N>L)&&(N>A||L>N)||A===N||L===N||R.push({t:(N-A)/(L-A)})}R.sort((e,t)=>e.t-t.t);for(const E of R){const D=k+(_-k)*E.t,I=w+(P-w)*E.t,H=wn(A+(L-A)*Math.min(E.t+1e-4,1),g,d);e.lineTo(D,I),M(),O(H,D,I)}e.lineTo(_,P)}k=_,w=P,A=L,j=T}else O(T,_,P),k=_,w=P,A=L,j=T}M()}else{e.beginPath();const F=l.strokeGradient&&l.path.length>=2?ut(e,l.strokeGradient,l.path[0][0],0,l.path[l.path.length-1][0],0):null;if(e.strokeStyle=F||d,p)s.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(l.path);else{const[W,$]=l.path[0];e.moveTo(W,$);for(let z=1;l.path.length>z;z++)e.lineTo(l.path[z][0],l.path[z][1])}e.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=l.style.fillOpacity,e.fillStyle=lt(e,l.style.fill,l.style.fill),p&&!y)s.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(l.path);else{const[G,q]=l.path[0];e.moveTo(G,q);for(let X=1;l.path.length>X;X++)e.lineTo(l.path[X][0],l.path[X][1])}const Y=l.path[0][0];e.lineTo(l.path[l.path.length-1][0],n.height),e.lineTo(Y,n.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Sn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function On(e,t,o=.3){Sn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Mn(e,t,o=.6){var n,i,r,s,a;if(!Sn(t))return;const l=null!==(n=t._pulseGlowRadius)&&void 0!==n?n: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*o,e.stroke()}function Cn(e,t,o,n=.35){Sn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function _n(e,t){const o=at(t.curve);if(!o||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath()}else{const n=s.area().x(e=>e[0]).y0((e,o)=>t.bottomPath[o][1]).y1(e=>e[1]).curve(o).context(e);e.beginPath(),n(t.topPath)}}const Pn=(e,t,o,n)=>{var i,r,a;const l=t.filter(e=>"area"===e.type);for(const t of l){if(2>t.topPath.length)continue;let o=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),o=!0);const l=t._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,n.width*l,n.height),e.clip());const c=lt(e,t.style.fill,"#4e79a7"),u=t._decayOpacities;if(u&&u.length===t.topPath.length){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=c;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(u[n]+u[n+1])*o,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=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(u[o]+u[o+1]),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.stroke()}e.globalAlpha=1;continue}const d=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(_n(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 n=-1/0;for(const e of t.bottomPath)e[1]>n&&(n=e[1]);const i=ct(e,t.fillGradient,"string"==typeof c?c:"#4e79a7",0,o,0,n);e.fillStyle=i||c,e.globalAlpha=d}else{const o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=o*d,e.fillStyle=c}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(_n(e,t),Cn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=d;const o=t.strokeGradient&&t.topPath.length>=2?ut(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=o||rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=at(t.curve);if(e.beginPath(),n)s.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 o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1])}e.stroke()}void 0!==l&&1>l&&e.restore(),o&&e.restore(),e.globalAlpha=1}},Ln=(e,t,o,n)=>{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 o=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=lt(e,t.style.fill,"#4e79a7"),e.fill(),t.style.stroke&&(e.strokeStyle=lt(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth||1,e.stroke()),Mn(e,t),e.globalAlpha=1}}finally{e.restore()}}};function Tn(e,t){const{x:o,y:n,w:i,h:r}=t,{tl:s,tr:a,br:l,bl:c}=Ao(t);e.beginPath(),e.moveTo(o+s,n),e.lineTo(o+i-a,n),a>0&&e.arcTo(o+i,n,o+i,n+a,a),e.lineTo(o+i,n+r-l),l>0&&e.arcTo(o+i,n+r,o+i-l,n+r,l),e.lineTo(o+c,n+r),c>0&&e.arcTo(o,n+r,o,n+r-c,c),e.lineTo(o,n+s),s>0&&e.arcTo(o,n,o+s,n,s),e.closePath()}function Rn(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}const Bn=(e,t,o,n)=>{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)Nn(e,t);else if(t.cornerRadii&&wo(t.cornerRadii)){const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=Rn(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o,Tn(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=Rn(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o;const r=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+l-r,a),e.arcTo(s+l,a,s+l,a+r,r),e.lineTo(s+l,a+c-r),e.arcTo(s+l,a+c,s+l-r,a+c,r),e.lineTo(s,a+c);break;case"left":e.moveTo(s+l,a),e.lineTo(s+r,a),e.arcTo(s,a,s,a+r,r),e.lineTo(s,a+c-r),e.arcTo(s,a+c,s+r,a+c,r),e.lineTo(s+l,a+c);break;case"bottom":e.moveTo(s,a),e.lineTo(s+l,a),e.lineTo(s+l,a+c-r),e.arcTo(s+l,a+c,s+l-r,a+c,r),e.lineTo(s+r,a+c),e.arcTo(s,a+c,s,a+c-r,r);break;default:e.moveTo(s,a+c),e.lineTo(s,a+r),e.arcTo(s,a,s+r,a,r),e.lineTo(s+l-r,a),e.arcTo(s+l,a,s+l,a+r,r),e.lineTo(s+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=Rn(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}On(e,t),e.globalAlpha=1}};function Nn(e,t){const o=t.style.icon,n=t.style.iconPadding||2,i=Math.min(t.w,t.h)-n;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+n,s=t.x+(t.w-i)/2;for(let n=t.y+t.h-i;n>=t.y-i;n-=r)e.drawImage(o,s,n,i,i)}else{const r=i+n,s=t.y+(t.h-i)/2;for(let n=t.x;t.x+t.w>n;n+=r)e.drawImage(o,n,s,i,i)}e.restore()}function En(e,t,o,n){return Object.assign({data:e,x:t,y:o,__semioticHoverData:!0},n)}function Dn(e){const[t,o,n]=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*o+.114*n>128?"#000":"#fff"}function In(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Hn=(e,t,o,n)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const o=t.style;if(null!=(null==o?void 0:o.opacity)&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=rt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),On(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const o=t.valueFormat?t.valueFormat(t.value):In(t.value),n=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=Dn(t.fill),e.font=n+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(o,i,r)}}}finally{e.restore()}},Fn=(e,t,o,n)=>{var i,r,s;for(const o of t){if("candlestick"!==o.type)continue;const t=o;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=rt(e,t.wickColor)||t.wickColor,c=60>n.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 o=Math.max(2,Math.min(t.bodyWidth/2,.12*n.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,o,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,o,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const o=Math.min(t.openY,t.closeY),n=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=rt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1))}c&&d(),e.restore()}};function Wn(e,t){if(!t)return[];const o=new Set,n=[];for(const i of e){if(!i||"object"!=typeof i)continue;const e="function"==typeof t?t(i):i[t];if(null==e)continue;const r=e+"";o.has(r)||(o.add(r),n.push(r))}return n}function $n(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function zn(e,t,o,n){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:{key:void 0,fn:null}}function Yn(e,t,o){return n=>{if(!n||!o||!e.fn&&!t.fn)return n;let i=!1;const r=n.map(o=>{const n=e.fn&&e.key&&!(e.key in o),r=t.fn&&t.key&&!(t.key in o);if(!n&&!r)return o;i=!0;const s=Object.assign({},o);return n&&(s[e.key]=e.fn(o)),r&&(s[t.key]=t.fn(o)),s});return i?r:n}}const Gn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function qn(e){const t=e[1]-e[0],o=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:o>t?e=>{const t=new Date(e);return`${Gn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*o>t?e=>{const t=new Date(e);return`${Gn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Xn={line:[Pn,jn,Ln],area:[Pn,Ln],stackedarea:[Pn,Ln],scatter:[Ln],bubble:[Ln],heatmap:[Hn],bar:[Bn],swarm:[Ln],waterfall:[(e,t,o,n)=>{var i;Bn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){e.save(),e.strokeStyle=rt(e,a)||a,e.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const n=r[t],i=r[t+1],s=n.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=o.y(s.cumEnd),c=n.x+n.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Fn],mixed:[Pn,jn,Ln],custom:[Pn,Bn,Hn,jn,Ln,Fn]},Vn={top:20,right:20,bottom:30,left:40},Un={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 Kn(e,t){const o=e.trim();if(/^#[0-9a-f]{3}$/i.test(o)){const e=o[1],n=o[2],i=o[3];return`#${e}${e}${n}${n}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(o))return`${o}${t}`;const n=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return n?`rgba(${n[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:o}const Qn={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 Zn({hover:t}){var o,n,i;const r=e=>null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+"",s=null!==(o=t.data)&&void 0!==o?o:{},a=null!==(n=s.y)&&void 0!==n?n:s.value,l=null!==(i=s.x)&&void 0!==i?i:s.time;return e.jsxs("div",{className:"semiotic-tooltip",style:Qn,children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(a)}),e.jsx("div",{style:{opacity:.7,fontSize:11},children:r(l)})]})}Zn.ownsChrome=!0;const Jn=t.forwardRef(function(o,n){var i,r,s,a,l,c,u,d,h,g,f,y,m;const{chartType:b,runtimeMode:x,data:A,chunkThreshold:j,chunkSize:O,xAccessor:M,yAccessor:C,colorAccessor:_,sizeAccessor:P,groupAccessor:L,lineDataAccessor:T,curve:R,normalize:B,baseline:N,stackOrder:E,binSize:D,valueAccessor:I,arrowOfTime:H="right",windowMode:F="sliding",windowSize:W=200,timeAccessor:$,xExtent:z,yExtent:Y,extentPadding:G=.1,scalePadding:q,sizeRange:X,size:V=[500,300],responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,lineStyle:ee,pointStyle:te,areaStyle:oe,barStyle:ne,waterfallStyle:ie,swarmStyle:re,barColors:se,colorScheme:ae,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:he,lineGradient:ge,areaGroups:fe,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,showAxes:xe=!0,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:Se,yFormat:Oe,axisExtent:Me,tickFormatTime:Ce,tickFormatValue:_e,hoverAnnotation:Pe,tooltipContent:Le,customHoverBehavior:Te,customClickBehavior:Re,enableHover:Be,hoverRadius:Ne=30,tooltipMode:De,annotations:Ie,svgAnnotationRules:He,showGrid:Fe,legend:We,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendCategoryAccessor:Ue,onCategoriesChange:Ke,backgroundGraphics:Qe,foregroundGraphics:Ze,canvasPreRenderers:Je,svgPreRenderers:et,title:tt,categoryAccessor:ot,brush:nt,onBrush:it,decay:st,pulse:at,transition:lt,animate:ct,staleness:ut,heatmapAggregation:dt,heatmapXBins:pt,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,marginalGraphics:bt,pointIdAccessor:xt,xScaleType:kt,yScaleType:Ot,accessibleTable:Mt=!0,description:Pt,summary:Lt,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt,customLayout:Bt,layoutConfig:Nt}=o,Et=t.useId().replace(/:/g,""),Dt=t.useRef(!1),It=bn({sizeProp:V,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:Vn,animate:ct,transitionProp:lt,themeDirtyRef:Dt}),Ht=Po(),Ft=Bo(),{reducedMotionRef:Wt,responsiveRef:$t,size:zt,currentTheme:Yt,transition:Gt,introEnabled:qt,tableId:Xt,rafRef:Vt,renderFnRef:Ut,scheduleRender:Kt}=It;let Qt=It.margin;if(bt){const e=60,t=Object.assign({},It.margin);bt.top&&e>t.top&&(t.top=e),bt.bottom&&e>t.bottom&&(t.bottom=e),bt.left&&e>t.left&&(t.left=e),bt.right&&e>t.right&&(t.right=e),Qt=t}const Zt="function"==typeof Ze?Ze({size:zt,margin:Qt}):Ze,Jt="function"==typeof Qe?Qe({size:zt,margin:Qt}):Qe,eo=zt[0]-Qt.left-Qt.right,to=zt[1]-Qt.top-Qt.bottom,oo=t.useMemo(()=>v(A),[A]),no=null!=Pe?Pe:Be,io=t.useRef(null),ro=t.useRef(null),[so,ao]=t.useState(0),[lo,co]=t.useState(null),uo=t.useRef(null),ho=t.useRef(null),[go,fo]=t.useState(null),po=t.useRef(Un.primary),yo=t.useRef([]),mo=t.useRef(Ue),bo=t.useRef(Ke);mo.current=Ue,bo.current=Ke;const[xo,wo]=t.useState(!1),[Ao,jo]=t.useState([]),[So,Oo]=t.useState([]),_o="streaming"===x||["bar","swarm","waterfall"].includes(b),Lo=t.useMemo(()=>{var e,t,o;return{chartType:b,runtimeMode:_o?"streaming":"bounded",windowSize:W,windowMode:F,arrowOfTime:_o?H:"right",extentPadding:G,scalePadding:q,axisExtent:Me,xAccessor:M,yAccessor:C,timeAccessor:_o?$:void 0,valueAccessor:I,colorAccessor:_,sizeAccessor:P,groupAccessor:L||(T?"_lineGroup":void 0),categoryAccessor:ot,lineDataAccessor:T,xScaleType:kt,yScaleType:Ot,xExtent:z,yExtent:Y,sizeRange:X,binSize:D,normalize:B,baseline:N,stackOrder:E,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:!0===he?{topOpacity:.8,bottomOpacity:.05}:!1===he?void 0:he,areaGroups:fe?new Set(fe):void 0,lineGradient:ge,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,lineStyle:ee,pointStyle:te,areaStyle:oe,swarmStyle:re,waterfallStyle:ie,colorScheme:ae,barColors:se,barStyle:ne,annotations:Ie,decay:st,pulse:at,transition:Gt,introAnimation:qt,staleness:ut,heatmapAggregation:dt,heatmapXBins:pt,heatmapYBins:yt,showValues:mt,heatmapValueFormat:vt,pointIdAccessor:xt,curve:R,themeCategorical:null===(e=null==Yt?void 0:Yt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(Yt),themeSequential:null===(t=null==Yt?void 0:Yt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==Yt?void 0:Yt.colors)||void 0===o?void 0:o.diverging,customLayout:Bt,layoutConfig:Nt,layoutMargin:Qt}},[b,W,F,H,G,q,Me,M,C,$,I,kt,Ot,_,P,L,ot,T,z,Y,X,D,B,N,E,le,ce,ue,de,he,ge,fe,pe,ye,me,ve,be,ee,te,oe,re,ie,ne,ae,se,Ie,st,at,null==Gt?void 0:Gt.duration,null==Gt?void 0:Gt.easing,qt,ut,dt,pt,yt,mt,vt,_o,xt,R,Yt,Bt,Nt,Qt]),To=Eo(Lo),Ro=t.useRef(null);Ro.current||(Ro.current=new Ye(To));const Do=t.useCallback(()=>{var e,t;const o=mo.current,n=bo.current;if(!n||!o)return;const i=Wn(null!==(t=null===(e=Ro.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],o);$n(i,yo.current)||(yo.current=i,n(i))},[]);t.useEffect(()=>{var e;null===(e=Ro.current)||void 0===e||e.updateConfig(To),Dt.current=!0,Kt()},[To,Kt]);const Io=t.useRef(null);Io.current||(Io.current=new w(e=>{const t=Ro.current;t&&t.ingest(e)&&(Dt.current=!0,Kt())},{chunkThreshold:j,chunkSize:O})),t.useEffect(()=>{var e;null===(e=Io.current)||void 0===e||e.updateChunkOptions({chunkThreshold:j,chunkSize:O})},[j,O]);const Ho=t.useCallback(e=>{var t;null===(t=Io.current)||void 0===t||t.push(e)},[]),Fo=t.useCallback(e=>{var t;null===(t=Io.current)||void 0===t||t.pushMany(e)},[]),Wo=t.useCallback(()=>{var e,t;null===(e=Io.current)||void 0===e||e.clear(),null===(t=Ro.current)||void 0===t||t.clear(),Dt.current=!0,Kt()},[Kt]);t.useImperativeHandle(n,()=>({push:Ho,pushMany:Fo,remove:e=>{var t,o,n;null===(t=Io.current)||void 0===t||t.flush();const i=null!==(n=null===(o=Ro.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];return i.length>0&&(uo.current&&i.some(e=>{var t;return e===(null===(t=uo.current)||void 0===t?void 0:t.data)})&&(uo.current=null,fo(null)),Dt.current=!0,Kt()),i},update:(e,t)=>{var o,n,i;null===(o=Io.current)||void 0===o||o.flush();const r=null!==(i=null===(n=Ro.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(Dt.current=!0,Kt()),r},clear:Wo,getData:()=>{var e,t,o;return null===(e=Io.current)||void 0===e||e.flush(),null!==(o=null===(t=Ro.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Ro.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Ro.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Ho,Fo,Wo,Kt]),t.useEffect(()=>{var e,t;if(A){if(T&&oo.length>0&&"object"==typeof oo[0]&&null!==oo[0]){const t="string"==typeof T?T:"coordinates";if(Array.isArray(oo[0][t])){const o=[];for(const e of oo){const n=e[t];if(Array.isArray(n)){const t=e.label||e.id||e.key;if(null!=t)for(const e of n)o.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of n)o.push(e)}}return void(null===(e=Io.current)||void 0===e||e.setBoundedData(o))}}null===(t=Io.current)||void 0===t||t.setBoundedData(oo)}},[A,oo,T]);const{hoverHandlerRef:$o,hoverLeaveRef:zo,onPointerMove:Go,onPointerLeave:qo}=It;$o.current=e=>{var t,o;if(!no)return;const n=io.current;if(!n)return;const i=n.getBoundingClientRect(),r=e.clientX-i.left-Qt.left,s=e.clientY-i.top-Qt.top;if(0>r||r>eo||0>s||s>to)return void(uo.current&&(uo.current=null,ho.current=null,fo(null),Te&&(Te(null),Dt.current=!0),Kt()));const a=Ro.current;if(!a||0===a.scene.length)return;const l=gt(a.scene,r,s,Ne,a.quadtree,a.maxPointRadius),c="multi"===De,u=()=>{uo.current&&(uo.current=null,ho.current=null,fo(null),Te&&Te(null),Kt())};if(!l&&!c)return void u();const d=c||!l?r:l.x,h=c||!l?s:l.y;let g=En((null==l?void 0:l.datum)?Ee(l.datum,a.resolvedRibbons):{},d,h);if(c&&a.scene.length>0&&a.scales){const e=function(e,t,o=30){const n=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=ft(ht(e.path,e.curve),t,o);if(null===r)continue;const s=wt(e.path,t);n.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=ht(e.topPath,e.curve),s=ht(e.bottomPath,e.curve),a=ft(r,t,o);if(null===a)continue;const l=ft(s,t,o),c=wt(e.topPath,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:null!=l?l:void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return n}(a.scene,d,Math.max(Ne,eo));if(e.length>0){const t=a.scales.y.invert,o=a.scales.x.invert,n=po.current,i=o?o(d):d;if(l)g.xValue=i,g.xPx=d;else{const e={xValue:i};"string"==typeof M&&(e[M]=i),g=En(e,d,h,{xValue:i,xPx:d})}g.allSeries=e.map(e=>{const o=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===b&&null!=i?o-i:o,valuePx:e.y,color:e.color||n,datum:Ee(e.datum,a.resolvedRibbons)}})}}l||(null===(t=g.allSeries)||void 0===t?void 0:t.length)?(uo.current=g,ho.current=null!==(o=null==l?void 0:l.node)&&void 0!==o?o:null,fo(g),Te&&(Te(g),Dt.current=!0),Kt()):u()},zo.current=()=>{uo.current&&(uo.current=null,ho.current=null,fo(null),Te&&(Te(null),Dt.current=!0),Kt())};const Xo=t.useRef(()=>{});Xo.current=e=>{if(!Re)return;const t=io.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Qt.left,i=e.clientY-o.top-Qt.top;if(0>n||n>eo||0>i||i>to)return void Re(null);const r=Ro.current;if(!r||0===r.scene.length)return void Re(null);const s=gt(r.scene,n,i,Ne,r.quadtree,r.maxPointRadius);Re(s?En(s.datum||{},s.x,s.y):null)};const Vo=t.useCallback(e=>Xo.current(e),[]),Uo=t.useRef(-1),Ko=t.useRef(null),Qo=t.useRef(null),Zo=t.useCallback(e=>{const t=Ro.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(Qo.current&&Qo.current.version===o)n=Qo.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const e=r,o=Array.isArray(e.datum)?e.datum:[],n=null!==(t=e.group)&&void 0!==t?t:"_default";for(let t=0;e.path.length>t&&o.length>t;t++)i.push({x:e.path[t][0],y:e.path[t][1],datum:o[t],shape:"circle",group:n});break}case"area":{const e=r,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:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(n=r.group)&&void 0!==n?n:"_default"});break;case"heatcell":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=At(e),Qo.current={version:o,graph:n}}const i=Uo.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Uo.current=0;const o=n.flat[0];Ko.current={shape:o.shape,w:o.w,h:o.h};const i=Ct(Object.assign(Object.assign({},o),{datum:Ee(o.datum,t.resolvedRibbons)}));return uo.current=i,fo(i),Te&&Te(i),void Kt()}const r=jt(n,i),s=St(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return Uo.current=-1,Ko.current=null,uo.current=null,ho.current=null,fo(null),Te&&Te(null),void Kt();Uo.current=s;const a=n.flat[s];Ko.current={shape:a.shape,w:a.w,h:a.h};const l=Ct(Object.assign(Object.assign({},a),{datum:Ee(a.datum,t.resolvedRibbons)}));uo.current=l,fo(l),Te&&Te(l),Kt()},[Te,Kt]),Jo=t.useCallback(e=>{Uo.current=-1,Ko.current=null,Go(e)},[Go]);Ut.current=()=>{var e,t;Vt.current=0;const o=io.current,n=ro.current;if(!o||!n)return;const i=Ro.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Wt.current?r+1e6:r),a=!Wt.current&&s,l=Dt.current||s;l&&!a&&(i.computeScene({width:eo,height:to}),Do());const c=kn(),u=function(e){if(!e)return Un;const t=getComputedStyle(e),o=t.getPropertyValue("--semiotic-border").trim(),n=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=n||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=o||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||o||r?{axisStroke:l||Un.axisStroke,tickText:s||Un.tickText,crosshair:s?Kn(s,"66"):Un.crosshair,hoverFill:c?Kn(c,"4D"):Un.hoverFill,hoverStroke:s?Kn(s,"99"):Un.hoverStroke,pointRing:c||Un.pointRing,primary:r||Un.primary}:Un}(o);po.current=u.primary;const d=null!==(e=null==ut?void 0:ut.threshold)&&void 0!==e?e:5e3,h=ut&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=xn(o,zt,Qt,c);if(e){if(e.clearRect(-Qt.left,-Qt.top,zt[0],zt[1]),h&&(e.globalAlpha=null!==(t=null==ut?void 0:ut.dimOpacity)&&void 0!==t?t:.5),"transparent"!==J&&!Qe){const t=getComputedStyle(o).getPropertyValue("--semiotic-bg").trim(),n=J||(t&&"transparent"!==t?t:null),i=n?rt(e,n):null;i&&(e.fillStyle=i,e.fillRect(-Qt.left,-Qt.top,zt[0],zt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,eo,to),e.clip()),Je&&i.scales)for(const t of Je)e.save(),t(e,i.scene,i.scales,{width:eo,height:to}),e.restore();const n=Bt?Xn.custom:Xn[b];if(n&&i.scales)for(const t of n)t(e,i.scene,i.scales,{width:eo,height:to});e.restore(),h&&(e.globalAlpha=1)}}{const e=xn(n,zt,Qt,c);if(e&&(e.clearRect(-Qt.left,-Qt.top,zt[0],zt[1]),no&&uo.current&&i.scales&&function(e,t,o,n,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,n),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,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 o=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 o="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||o||null:o||t.stroke||null}(r)||s.primary;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,uo.current,eo,to,"object"==typeof no?no:{},ho.current,u),ho.current&&Array.isArray(Pe))){const t=Pe.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,o,n,i){var r;if(!o)return;const s="group"in o?o.group:void 0;if(void 0!==s)for(const o of t){if("line"!==o.type)continue;if(o.group!==s)continue;if(2>o.path.length)continue;const t="function"==typeof n.style?o.datum?n.style(o.datum):{}:n.style||{};e.save(),e.beginPath(),e.moveTo(o.path[0][0],o.path[0][1]);for(let t=1;o.path.length>t;t++)e.lineTo(o.path[t][0],o.path[t][1]);e.strokeStyle=t.stroke||o.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(o.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,ho.current,t,u)}}l&&o&&o.setAttribute("aria-label",Yo(i.scene,b+" chart"));const g=Dt.current;if(Dt.current=!1,g&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!lo||e(lo.x.domain()[0])!==e(i.scales.x.domain()[0])||e(lo.x.domain()[1])!==e(i.scales.x.domain()[1])||e(lo.y.domain()[0])!==e(i.scales.y.domain()[0])||e(lo.y.domain()[1])!==e(i.scales.y.domain()[1])||lo.x.range()[0]!==i.scales.x.range()[0]||lo.x.range()[1]!==i.scales.x.range()[1]||lo.y.range()[0]!==i.scales.y.range()[0]||lo.y.range()[1]!==i.scales.y.range()[1])&&co(i.scales),bt){const e=i.getData(),t="function"==typeof M?M:e=>e[M||"x"],o="function"==typeof C?C:e=>e[C||"y"];jo(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Oo(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Ie&&Ie.length>0&&ao(e=>e+1),(null==ut?void 0:ut.showBadge)&&wo(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Vt.current=requestAnimationFrame(()=>Ut.current()))},No({hydrated:Ht,wasHydratingFromSSR:Ft,storeRef:Ro,dirtyRef:Dt,renderFnRef:Ut,cleanup:()=>{var e;return null===(e=Io.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{Dt.current=!0,Kt()},[b,eo,to,xe,J,ee,Je,Kt]),_t(ut,Ro,Dt,Kt,xo,wo);const tn=t.useMemo(()=>{if(Se||Ce)return;const e=Ro.current;return(null==e?void 0:e.xIsDate)&&lo?qn(lo.x.domain()):void 0},[Se,Ce,lo]),sn=Se||Ce||tn,ln=no&&go?Le?Le(go):e.jsx(Zn,{hover:go}):null,cn=ln?e.jsx(fn,{x:go.x,y:go.y,containerWidth:eo,containerHeight:to,margin:Qt,className:"stream-frame-tooltip",children:ln}):null,un=Ko.current,dn=e.jsx(an,{active:Uo.current>=0,hoverPoint:go,margin:Qt,size:zt,shape:null==un?void 0:un.shape,width:null==un?void 0:un.w,height:null==un?void 0:un.h}),hn=zn(M,$,"__semiotic_resolvedX","__semiotic_resolvedTime"),gn=zn(C,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),pn=hn.key,yn=gn.key,mn=Yn(hn,gn,Ie&&Ie.length>0||!1);if(Co||!Ht&&Ft){const t=Ro.current;t&&A&&(t.ingest({inserts:oo,bounded:!0}),t.computeScene({width:eo,height:to}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,a=sn||(()=>{if((null==t?void 0:t.xIsDate)&&n)return qn(n.x.domain())})();return e.jsxs("div",{ref:$t,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":Pt||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:U?"100%":zt[0],height:K?"100%":zt[1]},children:[e.jsx(on,{summary:Lt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:zt[0],height:zt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Qt.left},${Qt.top})`,children:Jt}),e.jsxs("g",{transform:`translate(${Qt.left},${Qt.top})`,children:[J&&e.jsx("rect",{x:0,y:0,width:eo,height:to,fill:J}),et&&n&&et.map((t,i)=>e.jsx(p.Fragment,{children:t(o,n,{width:eo,height:to})},"svgpre-"+i)),o.map((t,o)=>function(t,o,n){var i,r,s,a,l;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+o)}case"area":{const l=t;if(0===l.topPath.length)return null;const c=`M${l.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...l.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(l.clipRect){const t=`${n?n+"-":""}area-clip-${o}`;return e.jsxs("g",{children:[e.jsx("defs",{children:e.jsx("clipPath",{id:t,children:e.jsx("rect",{x:l.clipRect.x,y:l.clipRect.y,width:l.clipRect.width,height:l.clipRect.height})})}),e.jsx("path",{d:c,fill:Mo(l.style.fill),fillOpacity:null!==(r=null!==(i=l.style.fillOpacity)&&void 0!==i?i:l.style.opacity)&&void 0!==r?r:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+o)}return e.jsx("path",{d:c,fill:Mo(l.style.fill),fillOpacity:null!==(a=null!==(s=l.style.fillOpacity)&&void 0!==s?s:l.style.opacity)&&void 0!==a?a:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth},"area-"+o)}case"point":{const n=t;return e.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:Mo(n.style.fill),opacity:null!==(l=n.style.opacity)&&void 0!==l?l:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Mo(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+o)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[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]}(n.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),e.jsx("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+o)}return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+o)}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),s=n.isUp?n.upColor:n.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),e.jsx("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+o)}default:return null}}(t,o,Et)).filter(Boolean)]})]}),e.jsx(ko,{width:eo,height:to,totalWidth:zt[0],totalHeight:zt[1],margin:Qt,scales:n,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:a,yFormat:Oe||_e,axisExtent:Me,showGrid:Fe,title:tt,legend:We,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,foregroundGraphics:Ge(Zt,null===(s=Ro.current)||void 0===s?void 0:s.customLayoutOverlays),marginalGraphics:bt,xValues:[],yValues:[],annotations:Ie,svgAnnotationRules:He,annotationFrame:0,xAccessor:pn,yAccessor:yn,annotationData:mn(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof R?R:void 0,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt})]})}return e.jsxs("div",{ref:$t,className:"stream-xy-frame"+(Z?" "+Z:""),role:"group","aria-label":Pt||("string"==typeof tt?tt:"XY chart"),tabIndex:0,style:{position:"relative",width:U?"100%":zt[0],height:K?"100%":zt[1],overflow:"visible"},onKeyDown:Zo,children:[Mt&&e.jsx(nn,{tableId:Xt}),Mt&&e.jsx(en,{scene:null!==(l=null===(a=Ro.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:b+" chart",tableId:Xt,chartTitle:"string"==typeof tt?tt:void 0}),e.jsx(on,{summary:Lt}),e.jsxs("div",{role:"img","aria-label":Pt||("string"==typeof tt?tt:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:no?Jo:void 0,onMouseLeave:no?qo:void 0,onClick:Re?Vo:void 0,children:[Jt&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:zt[0],height:zt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Qt.left},${Qt.top})`,children:Jt})}),e.jsx(vo,{width:eo,height:to,totalWidth:zt[0],totalHeight:zt[1],margin:Qt,scales:lo,showAxes:xe,axes:ke,showGrid:Fe,xFormat:sn,yFormat:Oe||_e,axisExtent:Me}),e.jsx("canvas",{ref:io,"aria-label":Yo(null!==(u=null===(c=Ro.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],b+" chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:ro,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(rn,{hoverPoint:go}),e.jsx(ko,{width:eo,height:to,totalWidth:zt[0],totalHeight:zt[1],margin:Qt,scales:lo,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:sn,yFormat:Oe||_e,axisExtent:Me,showGrid:Fe,title:tt,legend:We,legendHoverBehavior:$e,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,foregroundGraphics:Ge(Zt,null===(d=Ro.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:bt,xValues:Ao,yValues:So,annotations:Ie,svgAnnotationRules:He,annotationFrame:so,xAccessor:pn,yAccessor:yn,annotationData:mn(null===(h=Ro.current)||void 0===h?void 0:h.getData()),pointNodes:null===(g=Ro.current)||void 0===g?void 0:g.scene.filter(e=>"point"===e.type),curve:"string"==typeof R?R:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==J&&!Qe,linkedCrosshairName:Tt,linkedCrosshairSourceId:Rt}),(nt||it)&&e.jsx(k,{width:eo,height:to,totalWidth:zt[0],totalHeight:zt[1],margin:Qt,dimension:null!==(f=null==nt?void 0:nt.dimension)&&void 0!==f?f:"xy",scales:lo,onBrush:null!=it?it:()=>{},binSize:D,snap:null==nt?void 0:nt.snap,binBoundaries:null!==(y=null==nt?void 0:nt.binBoundaries)&&void 0!==y?y:"bar"===b?null===(m=Ro.current)||void 0===m?void 0:m.getBinBoundaries():void 0,snapDuring:null==nt?void 0:nt.snapDuring,streaming:"streaming"===x}),(null==ut?void 0:ut.showBadge)&&e.jsx("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:xo?"#dc3545":"#28a745",color:"white"}),children:xo?"STALE":"LIVE"}),dn,cn]})]})});Jn.displayName="StreamXYFrame";const ei=t.createContext(null);function ti({colors:o,categories:n,colorScheme:i="category10",children:r}){const s=t.useMemo(()=>{if(o)return o;if(n){const e=Array.isArray(i)?i:ye[i]||me,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[o,n,i]);return e.jsx(ei.Provider,{value:s,children:r})}function oi(){return t.useContext(ei)}function ni(e){const t=[];for(const[o,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[o]));else{const[e,i]=n.range;t.push(t=>{const n=t[o];return n>=e&&i>=n})}return e=>t.every(t=>t(e))}function ii(e,t){const o=[];for(const[n,i]of e.clauses)"crossfilter"===e.resolution&&n===t||o.push(ni(i));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function ri(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}ti.displayName="CategoryColorProvider";const[si,ai]=A(e=>({selections:new Map,setClause(t,o){e(e=>{const n=new Map(e.selections),i=ri(n,t),r=new Map(i.clauses);return r.set(o.clientId,o),n.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:n}})},clearClause(t,o){e(e=>{const n=e.selections.get(t);if(!n)return{};const i=new Map(e.selections),r=new Map(n.clauses);return r.delete(o),i.set(t,Object.assign(Object.assign({},n),{clauses:r})),{selections:i}})},setResolution(t,o){e(e=>{const n=new Map(e.selections),i=ri(n,t);return n.set(t,Object.assign(Object.assign({},i),{resolution:o})),{selections:n}})},clearSelection(t){e(e=>{const o=new Map(e.selections),n=o.get(t);return n&&o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[li,ci]=A(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const o=e.observations;return o.push(t),o.length>e.maxObservations&&o.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function ui(e){const o=t.useId(),n=e.clientId||o,{name:i}=e,r=ai(e=>e.selections.get(i)),s=ai(e=>e.setClause),a=ai(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?ii(r,n):()=>!0,[r,n]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"point",values:new Set(n)};s(i,{clientId:n,type:"point",fields:t})},[n,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"interval",range:n};s(i,{clientId:n,type:"interval",fields:t})},[n,i,s]),clear:t.useCallback(()=>{a(i,n)},[a,i,n]),clientId:n}}function di(e){const o=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=ui({name:o});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,a,o]),predicate:i,isActive:r}}function hi(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function gi(e){const{name:o,xField:n,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=ui({name:o}),c=n&&i?"xyBrush":n?"xBrush":"yBrush",u=t.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&hi(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&hi(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,n,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}function fi(e={}){const{limit:o=50,types:n,chartId:i}=e,r=ci(e=>e.version),s=ci(e=>e.observations),a=ci(e=>e.clearObservations),l=t.useMemo(()=>{let e=s;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return i&&(e=e.filter(e=>e.chartId===i)),e.length>o&&(e=e.slice(e.length-o)),e},[s,n,i,o,r]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:a}}const pi=t.createContext(!1),yi=t.createContext(null),mi="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function vi(e){const t=new Set,o=[];for(const n of e)t.has(n)||(t.add(n),o.push(n));return o}function bi(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function xi(e){const o=t.useContext(yi),n=t.useId(),i=vi(e),r=t.useRef([]);bi(r.current,i)||(r.current=i);const s=r.current;mi(()=>{if(o)return()=>o.unregisterCategories(n)},[o,n]),mi(()=>{o&&o.registerCategories(n,s)},[o,n,s])}function ki({selections:e}){const o=ai(e=>e.setResolution);return t.useEffect(()=>{for(const[t,n]of Object.entries(e))n.resolution&&o(t,n.resolution)},[e,o]),null}function wi({categoryColors:o,interaction:n,selectionName:i,field:r}){const s=Object.entries(o),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=di({name:i,fields:[r]}),u=ui({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[g,f]=t.useState(null),p=t.useRef(u.selectPoints);p.current=u.selectPoints;const y=t.useRef(u.clear);y.current=u.clear,t.useEffect(()=>{"isolate"===n&&(d.size>0?p.current({[r]:Array.from(d)}):y.current())},[n,d,r]);const m=t.useCallback(e=>{"highlight"===n&&(e?(f(e.label),c.onHover({[r]:e.label})):(f(null),c.onHover(null)))},[n,r,c]),v=t.useCallback(e=>{"isolate"===n&&h(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===a.length?new Set:o})},[n,a.length]),[b,[x]]=yn([0,0],!0,!1),k=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let o=0,n=1;for(const i of e){const e=26+7*i.length;o>0&&o+e>t&&(n++,o=0),o+=e}return n}(s.map(([e])=>e),x),[s,x]);return 0===s.length?null: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(Et,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:d})})})}function Ai({children:o,selections:n,showLegend:i,legendPosition:r="top",legendInteraction:s="none",legendSelectionName:a="legend",legendField:l="category"}){const c=oi(),[u,d]=t.useState({}),h=t.useRef({}),g=t.useMemo(()=>({registerCategories:(e,t)=>{const o=vi(t);d(t=>{var n;return bi(null!==(n=t[e])&&void 0!==n?n:[],o)?t:Object.assign(Object.assign({},t),{[e]:o})})},unregisterCategories:e=>{d(t=>{if(!(e in t))return t;const o=Object.assign({},t);return delete o[e],o})}}),[]),f=t.useMemo(()=>{const e=[];for(const t of Object.values(u))for(const o of t)e.push(o);return vi(e)},[u]),p=t.useMemo(()=>{var e;const t=null!=c?c:{},o=h.current;let n=Object.keys(t).length+Object.keys(o).length;for(const e of f)t[e]||o[e]||(o[e]=me[n%me.length],n++);const i=Object.assign({},t);for(const n of f)i[n]=null!==(e=t[n])&&void 0!==e?e:o[n];return i},[c,f]),y=void 0===i||i,m=y&&Object.keys(p).length>0;return e.jsx(si,{children:e.jsxs(li,{children:[n&&e.jsx(ki,{selections:n}),e.jsx(yi.Provider,{value:g,children:e.jsx(ti,{colors:p,children:e.jsxs(pi.Provider,{value:m,children:[y&&"top"===r&&e.jsx(wi,{categoryColors:p,interaction:s,selectionName:a,field:l}),o,y&&"bottom"===r&&e.jsx(wi,{categoryColors:p,interaction:s,selectionName:a,field:l})]})})})]})})}function ji({data:e,colorBy:t,colorScale:o,getColor:n,strokeColor:i,strokeWidth:r,categories:s}){const a=(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?n(s,t,o):o?o(i):ve[r%ve.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",o={fill:t,stroke:t};return void 0!==i&&(o.stroke=i),void 0!==r&&(o.strokeWidth=r),o},type:"fill",items:a,label:""}]}}function Si(e){return e?"string"==typeof e?{name:e}:e:null}function Oi(e,t,o){return t?(n,...i)=>{var r;const s=Object.assign({},e(n,...i));if(t.isActive)if(t.predicate(n))(null==o?void 0:o.selectedStyle)&&Object.assign(s,o.selectedStyle);else{const e=null!==(r=null==o?void 0:o.unselectedOpacity)&&void 0!==r?r:.5;s.opacity=e,s.fillOpacity=e,s.strokeOpacity=e,(null==o?void 0:o.unselectedStyle)&&Object.assign(s,o.unselectedStyle)}return s}:e}const Mi={light:C,dark:_,"high-contrast":P,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Ci(e){return Mi[e]}const _i=p.createContext(void 0),Pi="undefined"==typeof window?p.useEffect:p.useLayoutEffect;function Li(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return Ci(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function Ti({theme:e}){const t=R(e=>e.setTheme),o=R(e=>e.theme),n=p.useRef(o);n.current=o;const i=p.useRef(null);p.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return o.matches&&(i.current=n.current===P?C:n.current,t("high-contrast")),pn(o,e=>{var o,r;e.matches?(i.current=n.current===P?null!==(o=i.current)&&void 0!==o?o:C:n.current,t("high-contrast")):(function(e,t){e(t===C?"light":t===_?"dark":t===P?"high-contrast":t)}(t,null!==(r=i.current)&&void 0!==r?r:C),i.current=null)})},[e,t]);const r=p.useRef(!1);return Pi(()=>{r.current?void 0!==e&&t(Li(e)):r.current=!0},[e,t]),null}function Ri({children:t}){var o,n,i,r,s;const a=R(e=>e.theme),l=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({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(s=a.tooltip)||void 0===s?void 0:s.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),a.colors.annotation?{"--semiotic-annotation-color":a.colors.annotation}:{}),null!=a.typography.legendSize?{"--semiotic-legend-font-size":a.typography.legendSize+"px"}:{}),null!=a.typography.titleFontSize?{"--semiotic-title-font-size":a.typography.titleFontSize+"px"}:{}),null!=a.typography.tickFontFamily?{"--semiotic-tick-font-family":a.typography.tickFontFamily}:{}),null!=a.typography.tickSize?{"--semiotic-tick-font-size":a.typography.tickSize+"px"}:{}),null!=a.typography.labelSize?{"--semiotic-axis-label-font-size":a.typography.labelSize+"px"}:{}),{"--semiotic-secondary":a.colors.secondary||a.colors.primary,"--semiotic-surface":a.colors.surface||a.colors.background}),a.colors.success?{"--semiotic-success":a.colors.success}:{}),a.colors.danger?{"--semiotic-danger":a.colors.danger}:{}),a.colors.warning?{"--semiotic-warning":a.colors.warning}:{}),a.colors.error?{"--semiotic-error":a.colors.error}:{}),a.colors.info?{"--semiotic-info":a.colors.info}:{}),c=p.useContext(_i),u={};return c&&(u["data-semiotic-theme"]=c),e.jsx("div",Object.assign({style:l},u,{children:t}))}function Bi(){return R(e=>e.theme)}const Ni="#007bff";function Ei(e,t,o){var n;const i=null!==(n=e.xValue)&&void 0!==n?n:null==t?void 0:t[o];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function Di(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?Object.assign(Object.assign({},t),{xValue:e.xValue}):t||{}}function Ii(){var e;const t=Bi(),o=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return o&&o.length>0?o:void 0}function Hi(e,t,o,n,i){if(e)return e;let r;if(Array.isArray(o))r=o;else if(t&&t.length>0)r=t;else if("string"==typeof o){const e=ye[o];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(i.has(n)||i.set(n,i.size),r[i.get(n)%r.length]):r[0]:Ni}function Fi(e,o,n){const i=oi(),r=Ii();return t.useMemo(()=>{var t;if(!o)return;const s=null!==(t=null!=n?n:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof o){const t=Array.from(new Set(e.map(e=>o(e)+"")));if(i&&Object.keys(i).length>0){const e=we(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return we(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=we(e,o,s);return e=>i[e]||t(e)}return we(e,o,s)}if(i&&Object.keys(i).length>0){const e=we([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,o,n,i,r])}function Wi(e,o,n){return t.useMemo(()=>{if(!o||"auto"===o||"function"==typeof o)return e;const t=[...e],i=function(e){return"function"==typeof e?e:t=>t[e]}(n);return t.sort("asc"===o?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,o,n])}function $i({selection:e,linkedHover:o,fallbackFields:n=[],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}(o,n),g=ui({name:(null==e?void 0:e.name)||"__unused__"}),f=di({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=ci(e=>e.pushObservation),y=e?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:o=>{var n;return("string"==typeof o[t]?o[t]:(null!==(n=o[t])&&void 0!==n?n:"")+"")===e}}},[c,m,b]),k=t.useCallback(e=>{var t,n;if(o)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 o=Ei(e,t,h.xField);null!=o&&function(e,t,o){const n=to.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===o||(to={positions:new Map(to.positions).set(e,{xValue:t,sourceId:o})},no())}(h.name||"hover",o,d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&io(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 o=null==t?void 0:t[b];v(null!=o?o+"":null)}else v(null);if(r||p){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const i=Di(e),s=Object.assign(Object.assign({},o),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});r&&r(e),p&&p(e)}}},[o,f,h,d,r,s,a,p,c,b]),w=t.useCallback(e=>{var t,o,n,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 o=Ei(e,t,h.xField);null!=o&&function(e,t,o){const n=to.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(to.positions);return t.delete(e),to={positions:t},no(),!1}to={positions:new Map(to.positions).set(e,{xValue:t,sourceId:o,locked:!0})},no()}(h.name||"hover",o,d)}if(e&&l){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),l(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0})}if(r||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const o=Di(e),s=Object.assign(Object.assign({},t),{type:"click",datum:o||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),p&&p(e)}}},[l,r,p,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{ro(e,d),io(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 zi(e,t){const o="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==o?void 0:o.mode))return{linkedCrosshairName:o.name||"hover",linkedCrosshairSourceId:t}}function Yi({data:e,colorBy:o,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(pi),u=null!==t.useContext(yi),d=void 0!==i?i:!c&&!!o,h=!!o&&(d||u),g=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const n of e){const e="function"==typeof o?o(n):n[o];null!=e&&t.add(e+"")}return Array.from(t)},[l,o,e,h]);xi(u&&o?g:[]);const f=t.useMemo(()=>{if(!d||!o)return;const t=ji({data:e,colorBy:o,colorScale:n,getColor:ke,categories:g});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,o,e,n,g]),p=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),o=t=>null!=e[t];return f&&("right"===r&&!o("right")&&110>t.right?t.right=110:"left"===r&&!o("left")&&110>t.left?t.left=110:"top"===r&&!o("top")&&50>t.top?t.top=50:"bottom"===r&&!o("bottom")&&80>t.bottom&&(t.bottom=80)),t},[a,s,f,r]);return{legend:f,margin:p,legendPosition:r}}function Gi(e,o,n){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 o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=t.useMemo(()=>{if(!e||"none"===e||!o)return null;const t="string"==typeof o?o:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof o?o(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof o?o(e):null;return s.has(n)}}:null},[e,o,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const qi={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 Xi(e,t,o){var n,i,r,s,a,l,c;const u=qi[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==o?void 0:o.width)?u.width:o.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==o?void 0:o.height)?u.height:o.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:Vi(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function Vi(e,t,o){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===o?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function Ui(e){return"string"==typeof e?e:"value"}function Ki(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function Qi(e,t){if(!t)return Ki(e);try{const o=t(e);return null==o?Ki(e):o}catch(t){return Ki(e)}}function Zi(e,t){return"function"==typeof t?t(e):e[t]}function Ji(e,t){if(!e)return[];const o=[];return(Array.isArray(e)?e:[e]).forEach((e,n)=>{const i="string"==typeof(null==e?void 0:e.y1Accessor)?e.y1Accessor:"high";o.push({label:"string"==typeof(null==e?void 0:e.y0Accessor)?e.y0Accessor:"low",accessor:e=>{var t,o,i,r;return null!==(i=null===(o=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[n])||void 0===o?void 0:o.y0)&&void 0!==i?i:0===n?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y0:void 0},format:t}),o.push({label:i,accessor:e=>{var t,o,i,r;return null!==(i=null===(o=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[n])||void 0===o?void 0:o.y1)&&void 0!==i?i:0===n?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y1:void 0},format:t})}),o}function er(t){const o=t.find(e=>"title"===e.role),n=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=o?Qi(Zi(i,o.accessor),o.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((t,o)=>{const n=Qi(Zi(i,t.accessor),t.format);return e.jsxs("div",{style:o>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:n})]},o)})]})}}function tr({categoryAccessor:t,valueAccessor:o,groupAccessor:n,groupLabel:i,pieData:r=!1,valueFormat:s}){return a=>{var l;const c=r?(null===(l=a.data)||void 0===l?void 0:l[0])||a.data||a:a.data||a,u=Zi(c,t),d=Zi(c,o),h=n?Zi(c,n):void 0;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[e.jsx("div",{style:{fontWeight:"bold"},children:Ki(u)}),e.jsx("div",{style:{marginTop:4},children:Qi(d,s)}),null!=h&&e.jsxs("div",{style:{marginTop:2,opacity:.8},children:[i||Ui(n),": ",Ki(h)]})]})}}function or({componentName:t,message:o,diagnosticHint:n,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:o}),n&&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:n})]})})}class nr extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var o,n;null===(n=(o=this.props).onError)||void 0===n||n.call(o,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,o=this.state.error;return"function"==typeof t?t(o):void 0!==t?t:e.jsx(or,{componentName:"ChartErrorBoundary",message:o.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var ir;const rr="undefined"!=typeof process&&"production"!==(null===(ir=process.env)||void 0===ir?void 0:ir.NODE_ENV);function sr({componentName:t,width:o,height:n,children:i}){return e.jsx(nr,{fallback:i=>e.jsx(or,{componentName:t,message:i.message,width:o,height:n}),children:i})}const ar={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"},lr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function cr(t,o,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},ar),{width:o,height:n}),children:i||"No data available"}):null}function ur(t,o,n,i){if(!t)return null;if(!1===i)return null;if(null!=i)return e.jsx("div",{style:{width:o,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(n/40)),s=Math.max(8,Math.floor(n/(3*r))),a=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(s+a)-a))/2);return e.jsx("div",{style:{width:o,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},lr),{position:"absolute",top:l+n*(s+a),left:Math.floor(.1*o),width:30+(37*n+13)%50+"%",height:s,opacity:.5+n%2*.2})},n))})}function dr(e,t,o,n){if(!rr)return;if(!t||0===t.length)return;if("string"!=typeof n)return;const i=t[0];if(!i||"object"!=typeof i)return;if(n in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${o} "${n}" not found in data. Available keys: ${r}`)}function hr(e,t){const o=e.length,n=t.length,i=Array(n+1);for(let e=0;n>=e;e++)i[e]=e;for(let r=1;o>=r;r++){let o=i[0];i[0]=r;for(let s=1;n>=s;s++){const n=i[s];i[s]=e[r-1]===t[s-1]?o:1+Math.min(o,i[s],i[s-1]),o=n}}return i[n]}function gr(e,t,o=3){let n,i=o+1;for(const o of t){const t=hr(e.toLowerCase(),o.toLowerCase());i>t&&(i=t,n=o)}return i>o?void 0:n}function fr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function pr(e,t){var o;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(o=gr(e,t,3))&&void 0!==o?o:null)}function yr({componentName:e,data:t,accessors:o,requiredProps:n}){if(n)for(const[t,o]of Object.entries(n))if(null==o)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(o){const n=fr(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[i,r]of Object.entries(o))if(r&&"string"==typeof r&&!(r in n)){const o=pr(r,t),n=o?` Try ${i}="${o}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}function mr({componentName:e,data:t,dataLabel:o="data"}){return null==t?`${e}: No ${o} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${o} 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}function vr({componentName:e,nodes:t,edges:o,nodesRequired:n=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==o)return null;if(i&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!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 o=fr(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[n,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in o)){const o=pr(i,t),r=o?` Try ${n}="${o}".`:"";return`${e}: ${n} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}function br(e){const o=R(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==o)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:o})},[e,o])}function xr(e){const{data:o,rawData:n,colorBy:i,colorScheme:r,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:b,hoverHighlight:x,loading:k,loadingContent:w,emptyContent:A,width:j,height:S}=e,O=void 0===n,M=t.useMemo(()=>v(o),[o]),[C,_]=t.useState([]),P=t.useCallback(e=>{_(t=>t.length===e.length&&t.every((t,o)=>t===e[o])?t:e)},[]),L="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:T,hoverSelectionHook:R,customHoverBehavior:B,customClickBehavior:N,crosshairSourceId:E}=$i({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:b,hoverHighlight:x,colorByField:L}),D=zi(c,E),I=Fi(M,i,r),H=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of M){const o="function"==typeof i?i(t):t[i];null!=o&&e.add(o+"")}return Array.from(e)},[M,i]),F=t.useMemo(()=>O&&C.length>0?C:H,[O,C,H]),W=Gi(s,i,F),$=t.useMemo(()=>R||(W.legendSelectionHook?W.legendSelectionHook:T),[R,W.legendSelectionHook,T]),z=br(l),Y=Ii(),G=oi(),q=t.useMemo(()=>{if(I)return I;if(!i||0===F.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:Y&&Y.length>0?Y:ve,t="__streamCat",o=we(F.map(e=>({[t]:e})),t,e);return e=>(null==G?void 0:G[e])||o(e)||"#999"},[I,i,F,r,Y,G]),{legend:X,margin:V,legendPosition:U}=Yi({data:M,colorBy:i,colorScale:q,showLegend:p,legendPosition:a,userMargin:y,defaults:m,categories:F}),K=t.useMemo(()=>{const e={};return X&&(e.legend=X,e.legendPosition=U),s&&"none"!==s&&(e.legendHoverBehavior=W.onLegendHover,e.legendClickBehavior=W.onLegendClick,e.legendHighlightedCategory=W.highlightedCategory,e.legendIsolatedCategories=W.isolatedCategories),O&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=P),e},[X,U,s,W.onLegendHover,W.onLegendClick,W.highlightedCategory,W.isolatedCategories,O,i,P]),Q=Array.isArray(n)?v(n):n,Z=ur(k,j,S,w),J=Z?null:cr(Q,j,S,A);return{data:M,colorScale:I,allCategories:F,legendState:W,effectiveSelectionHook:$,activeSelectionHook:T,customHoverBehavior:B,customClickBehavior:N,legend:X,margin:V,legendPosition:U,earlyReturn:Z||J||null,legendBehaviorProps:K,crosshairProps:D,resolvedSelection:z}}function kr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),o)}:(...e)=>Object.assign({},o)}function wr(e){const{lineWidth:o=2,colorBy:n,colorScale:i,color:r,resolveStroke:s,fillArea:a,areaOpacity:l=.3,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:g}=e,f=t.useMemo(()=>(e,t)=>{const c={strokeWidth:o},u=!0===a||Array.isArray(a)&&null!=t&&a.includes(t);let d;return s?d=s(e,t):n?i&&(d=ke(e,n,i)):d=r||Ni,void 0!==d&&(c.stroke=d,u&&(c.fill=d,c.fillOpacity=l)),c},[o,n,i,r,s,a,l]),p=t.useMemo(()=>kr(f,{stroke:c,strokeWidth:u,opacity:d}),[f,c,u,d]);return t.useMemo(()=>Oi(p,null!=h?h:null,g),[p,h,g])}function Ar(e,o){const{variant:n,frameRef:i,overrides:r,deps:s}=o;t.useImperativeHandle(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n;return null!==(n=null===(o=e.current)||void 0===o?void 0:o.remove(t))&&void 0!==n?n:[]},update:(t,o)=>{var n,i;return null!==(i=null===(n=e.current)||void 0===n?void 0:n.update(t,o))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==o?o:null}}}if("network"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n,i,r,s;const a=Array.isArray(t)?t:[t],l=null!==(i=null===(n=null===(o=e.current)||void 0===o?void 0:o.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==i?i:[],c=[];for(const t of a){const o=l.find(e=>e.id===t);o&&c.push(Object.assign(Object.assign({},null!==(r=o.data)&&void 0!==r?r:{}),{id:t})),null===(s=e.current)||void 0===s||s.removeNode(t)}return c},update:(t,o)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var n;const i=null===(n=e.current)||void 0===n?void 0:n.updateNode(t,o);return i?[Object.assign(Object.assign({},i),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o,n,i;return null!==(i=null===(n=null===(o=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==i?i:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n;return null!==(n=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==n?n:[]},update:(t,o)=>{var n,i,r;const s=null!==(i=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==i?i:[];for(const t of s)null===(r=e.current)||void 0===r||r.push(o(t));return s},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]}}}const o=t;return{push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,i,r;const s=null!==(i=null===(n=o.current)||void 0===n?void 0:n.removeLine(e))&&void 0!==i?i:[];for(const e of s)null===(r=o.current)||void 0===r||r.pushLine(t(e));return s},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.getLines())&&void 0!==t?t:[]}}}(n,i);return Object.assign(Object.assign({},e),r)},null!=s?s:[])}function jr(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){e.done?i(e.value):function(e){return e instanceof o?e:new o(function(t){t(e)})}(e.value).then(s,a)}l((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Sr="__forecastSegment";let Or=null;function Mr(){return jr(this,void 0,void 0,function*(){return Or||(Or=yield Promise.resolve().then(function(){return zu})),Or})}const Cr="__semiotic_resolvedX",_r="__semiotic_resolvedY";function Pr(e){const{data:o,xAccessor:n,yAccessor:i,forecast:r,anomaly:s,groupBy:a}=e,l="string"==typeof n?n:Cr,c="string"==typeof i?i:_r,u=t.useMemo(()=>{if(!r&&!s)return o;const e="function"==typeof n,t="function"==typeof i;return e||t?o.map(o=>{const r=Object.assign({},o);return e&&(r[Cr]=n(o)),t&&(r[_r]=i(o)),r}):o},[o,r,s,n,i]),[d,h]=t.useState(null),[g,f]=t.useState([]),p=t.useRef(r),y=t.useRef(s);return t.useEffect(()=>{if(!r&&!s)return void((p.current||y.current)&&(h(null),f([]),p.current=r,y.current=s));let e=!1;const t=r!==p.current||s!==y.current;if(p.current=r,y.current=s,t&&(h(null),f([])),r){const t=a&&"string"==typeof a&&"object"==typeof r?Object.assign(Object.assign({},r),{_groupBy:a}):r;(function(...e){return jr(this,void 0,void 0,function*(){return(yield Mr()).buildForecast(...e)})})(u,l,c,t,s).then(t=>{e||(h(t),f(t.annotations))}).catch(()=>{e||(h(null),f([]))})}else s&&function(...e){return jr(this,void 0,void 0,function*(){return(yield Mr()).buildAnomalyAnnotations(...e)})}(s).then(t=>{e||(h(null),f(t))}).catch(()=>{e||f([])});return()=>{e=!0}},[u,r,s,l,c,a]),{effectiveData:d?d.processedData:o,statisticalAnnotations:g,hasForecast:!!d,xAccessorKey:l,yAccessorKey:c}}const Lr=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);Ar(n,{variant:"xy",frameRef:s});const a=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,axisExtent:g,xAccessor:f="x",yAccessor:p="y",lineBy:y,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:x,curve:k="linear",showPoints:w=!1,pointRadius:A=3,fillArea:j=!1,areaOpacity:S=.3,lineWidth:O=2,lineGradient:M,tooltip:C,pointIdAccessor:_,annotations:P,directLabel:L,gapStrategy:T="break",anomaly:R,forecast:B,band:N,xExtent:E,yExtent:D,frameProps:I={},selection:H,linkedHover:F,onObservation:W,onClick:$,hoverHighlight:z,hoverRadius:Y,chartId:G,loading:q,loadingContent:X,emptyContent:V,legendInteraction:U,legendPosition:K,xScaleType:Q,yScaleType:Z,color:J,stroke:ee,strokeWidth:te,opacity:oe}=o,{width:ne,height:ie,enableHover:re,showGrid:se,showLegend:ae,title:le,description:ce,summary:ue,accessibleTable:de,xLabel:he,yLabel:ge}=a,fe=t.useMemo(()=>v(l),[l]);dr("LineChart",fe,"xAccessor",f),dr("LineChart",fe,"yAccessor",p);const{effectiveData:pe,statisticalAnnotations:ye}=Pr({data:fe,xAccessor:f,yAccessor:p,forecast:B,anomaly:R,groupBy:y}),me="__compoundGroup",ve=!(!B||!y),be=ve?me:B?Sr:y,xe=t.useMemo(()=>{if(!ve)return pe;const e="function"==typeof y?y:e=>e[y];return pe.map(t=>{const o=Object.assign({},t);return o[me]=`${e(t)}__${t[Sr]||"observed"}`,o})},[pe,ve,y]),we=ve?xe:pe,Ae=t.useMemo(()=>{if(!B)return;const e=B.upperBounds,t=B.lowerBounds;if(!e&&!t)return;const o="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,n="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=pe;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)),o){const t=o(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(n){const t=n(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[B,pe,p]),je=t.useCallback(e=>{const t="function"==typeof f?f(e):e[f],o="function"==typeof p?p(e):e[p];return null==t||null==o||Number.isNaN(t)||Number.isNaN(o)},[f,p]),Se=void 0!==(null===(i=we[0])||void 0===i?void 0:i[m]),Oe=t.useMemo(()=>{if(Se)return we;if(be){const e=we.reduce((e,t)=>{const o="function"==typeof be?be(t):t[be];if(!e[o]){const n={[m]:[]};"string"==typeof be&&(n[be]=o),ve&&(n[Sr]=t[Sr],"string"==typeof y&&(n[y]=t[y])),e[o]=n}return e[o][m].push(t),e},{});return Object.values(e)}return[{[m]:we}]},[we,be,m,Se]),{gapProcessedLineData:Me,hasGaps:Ce}=t.useMemo(()=>{if("interpolate"===T){let e=!1;const t=[];for(const o of Oe){const n=(o[m]||[]).filter(t=>!je(t)||(e=!0,!1));n.length>0&&t.push(Object.assign(Object.assign({},o),{[m]:n}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===T){let e=!1;const t=[];for(const o of Oe){const n=o[m]||[];let i=[],r=0;const s=be&&"string"==typeof be?o[be]:void 0;for(const a of n)if(je(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},o),{[m]: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({},o),{[m]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===T){let e=!1;const t="string"==typeof p?p:"y",o=[];for(const n of Oe){const i=n[m]||[],r=[];for(const o of i)je(o)?(e=!0,r.push(Object.assign(Object.assign({},o),{[t]:0}))):r.push(o);o.push(Object.assign(Object.assign({},n),{[m]:r}))}return{gapProcessedLineData:o,hasGaps:e}}return{gapProcessedLineData:Oe,hasGaps:!1}},[Oe,T,m,je,be,p]),_e="object"==typeof L?L:{},Pe=_e.position||"end",Le=_e.fontSize||11,Te=t.useMemo(()=>{var e;if(!L||!b)return[];const t="function"==typeof b?b:e=>e[b],o=new Set;for(const n of Me){const i=n[m]||[];if(0===i.length)continue;const r=null!==(e=t("end"===Pe?i[i.length-1]:i[0]))&&void 0!==e?e:t(n);if(null==r)continue;const s=r+"";""!==s&&o.add(s)}return Array.from(o)},[L,b,Me,m,Pe]),Re=t.useMemo(()=>{if(!L)return a.marginDefaults;const e=Te.reduce((e,t)=>Math.max(e,t.length*(.6*Le)),0)+10,t="end"===Pe?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[t]:Math.max(a.marginDefaults[t]||0,e)})},[L,Te,Le,Pe,a.marginDefaults]),Be=xr({data:pe,rawData:l,colorBy:b,colorScheme:x,legendInteraction:U,legendPosition:K,selection:H,linkedHover:F,fallbackFields:b?["string"==typeof b?b:""]:[],unwrapData:!1,onObservation:W,onClick:$,hoverHighlight:z,chartType:"LineChart",chartId:G,showLegend:(!L||void 0!==ae)&&ae,userMargin:c,marginDefaults:Re,loading:q,loadingContent:X,emptyContent:V,width:ne,height:ie}),Ne=Be.colorScale,Ee=Be.customHoverBehavior,De=Be.customClickBehavior,Ie=Be.crosshairProps,He=wr({lineWidth:O,colorBy:b,colorScale:Ne,color:J,fillArea:j,areaOpacity:S,stroke:ee,strokeWidth:te,opacity:oe,effectiveSelectionHook:Be.effectiveSelectionHook,resolvedSelection:Be.resolvedSelection}),[Fe,We]=t.useState(null);t.useEffect(()=>{if(!B)return void We(null);let e=!1;return function(...e){return jr(this,void 0,void 0,function*(){return(yield Mr()).createSegmentLineStyle(...e)})}(He,B).then(t=>{e||We(()=>t)}).catch(()=>{e||We(null)}),()=>{e=!0}},[He,B]);const $e=Fe||He,ze=t.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return b?Ne&&(t.fill=ke(e.parentLine||e,b,Ne)):t.fill=J||Ni,t}},[w,A,b,Ne,J]),Ye=Array.isArray(j)?"mixed":j?"area":"line",Ge=t.useMemo(()=>{var e;if(!L||!b)return[];const t="function"==typeof f?f:e=>e[f],o="function"==typeof p?p:e=>e[p],n="function"==typeof b?b:e=>e[b],i=new Map;for(const t of Me){const o=t[m]||[];if(0===o.length)continue;const r="end"===Pe?o[o.length-1]:o[0],s=null!==(e=n(r))&&void 0!==e?e:n(t);if(null==s)continue;const a=s+"";""===a||i.has(a)||i.set(a,r)}const r=Array.from(i.entries()).map(([e,n])=>({type:"text",label:e,["string"==typeof f?f:"x"]:t(n),["string"==typeof p?p:"y"]:o(n),dx:"end"===Pe?6:-6,dy:0,color:Ne?Ne(e):Ni,fontSize:Le}));r.sort((e,t)=>{const o="string"==typeof p?p:"y";return e[o]-t[o]});for(let e=1;r.length>e;e++){const t="string"==typeof p?p:"y",o=r[e-1],n=r[e];Le+2>Math.abs(n[t]+n.dy-(o[t]+o.dy))&&(n.dy+=Le+2)}return r},[L,b,Ne,Me,m,f,p,Pe,Le]),qe=Be.margin,Xe=y||b,Ve=t.useMemo(()=>er([{label:he||Ui(f),accessor:f,role:"x",format:d},{label:ge||Ui(p),accessor:p,role:"y",format:h},...Xe?[{label:Ui(Xe),accessor:Xe,role:"group"}]:[],...Ji(N,h)]),[f,p,he,ge,Xe,d,h,N]),Ue=yr({componentName:"LineChart",data:Se?(null===(r=pe[0])||void 0===r?void 0:r[m])||[]:l,accessors:{xAccessor:f,yAccessor:p}}),Ke=t.useMemo(()=>Se||be||Ce?Me.flatMap(e=>{const t=e[m]||[];return be&&"string"==typeof be?t.map(t=>Object.assign(Object.assign({},t),{[be]:e[be]})):t}):we,[Me,m,Se,be,we,Ce]),Qe=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(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Ye},Array.isArray(j)&&{areaGroups:j}),M&&{lineGradient:M}),null!=Y&&{hoverRadius:Y}),null!=l&&{data:Ke}),{xAccessor:f,yAccessor:p,xScaleType:Q,yScaleType:Z}),E&&{xExtent:E}),!D||null==D[0]&&null==D[1]?Ae?{yExtent:Ae}:{}:{yExtent:D}),{groupAccessor:"break"===T&&Ce?"_gapSegment":be||void 0}),N&&{band:N}),{curve:k,lineStyle:$e}),w&&{pointStyle:ze}),{size:[ne,ie],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:qe,showAxes:a.showAxes,xLabel:he,yLabel:ge,xFormat:d,yFormat:h}),void 0!==g&&{axisExtent:g}),{enableHover:re,showGrid:se}),Be.legendBehaviorProps),le&&{title:le}),ce&&{description:ce}),ue&&{summary:ue}),void 0!==de&&{accessibleTable:de}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===C?()=>null:"multi"===C?hn():gn(C)||Ve}),"multi"===C&&{tooltipMode:"multi"}),(F||W||$||z)&&{customHoverBehavior:Ee}),(W||$||F)&&{customClickBehavior:De}),_&&{pointIdAccessor:_}),((null==P?void 0:P.length)||ye.length||Ge.length)&&{annotations:[...P||[],...ye,...Ge]}),Ie),I);return Be.earlyReturn?Be.earlyReturn:Ue?e.jsx(or,{componentName:"LineChart",message:Ue,width:ne,height:ie}):e.jsx(sr,{componentName:"LineChart",width:ne,height:ie,children:e.jsx(Jn,Object.assign({ref:s},Qe))})});function Tr(e){const{title:t,description:o,summary:n,accessibleTable:i,className:r,animate:s,axisExtent:a}=e,l={};return t&&(l.title=t),o&&(l.description=o),n&&(l.summary=n),void 0!==i&&(l.accessibleTable=i),r&&(l.className=r),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),l}function Rr(e){const{linkedHover:t,onObservation:o,onClick:n,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=e,l={};return(t||o||n||i)&&(l.customHoverBehavior=r),(a?o||n||t:o||n)&&(l.customClickBehavior=s),l}function Br(e){const{tooltip:t,defaultTooltipContent:o}=e;return{tooltipContent:!1===t?()=>null:gn(t)||o}}function Nr(e){var o;const{safeData:n,data:i,areaBy:r,lineDataAccessor:s,colorBy:a,colorScale:l,color:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:g,resolvedSelection:f,areaOpacity:p,showLine:y,lineWidth:m,showPoints:v,pointRadius:b,xAccessor:x,yAccessor:k,xLabel:w,yLabel:A,xFormat:j,yFormat:S,groupField:O}=e,M=void 0!==(null===(o=n[0])||void 0===o?void 0:o[s]),C=t.useMemo(()=>{if(null==i)return[];if(!M&&!r)return n;let e;if(M)e=n;else{const t=r,o=n.reduce((e,o)=>{const n="function"==typeof t?t(o):o[t];if(!e[n]){const o={[s]:[]};"string"==typeof t&&(o[t]=n),e[n]=o}return e[n][s].push(o),e},{});e=Object.values(o)}return e.flatMap(e=>{const t=e[s]||[];return r&&"string"==typeof r?t.map(t=>Object.assign(Object.assign({},t),{[r]:e[r]})):t})},[i,n,r,s,M]),_=t.useMemo(()=>e=>{const t={};if(a){if(l){const o=ke(e,a,l);t.fill=o,y?(t.stroke=o,t.strokeWidth=m):t.stroke="none"}}else{const e=c||Ni;t.fill=e,y?(t.stroke=e,t.strokeWidth=m):t.stroke="none"}return t.fillOpacity=p,t},[a,l,c,p,y,m]),P=t.useMemo(()=>kr(_,{stroke:u,strokeWidth:d,opacity:h}),[_,u,d,h]);return{flattenedData:C,lineStyle:t.useMemo(()=>Oi(P,null!=g?g:null,f),[P,g,f]),pointStyle:t.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return a?l&&(t.fill=ke(e.parentLine||e,a,l)):t.fill=c||Ni,t}},[v,b,a,l,c]),defaultTooltipContent:t.useMemo(()=>er([{label:w||Ui(x),accessor:x,role:"x",format:j},{label:A||Ui(k),accessor:k,role:"y",format:S},...O?[{label:Ui(O),accessor:O,role:"group"}]:[],...Ji(e.band,S)]),[x,k,w,A,O,j,S,e.band])}}Lr.displayName="LineChart";const Er=t.forwardRef(function(o,n){const i=t.useRef(null);Ar(n,{variant:"xy",frameRef:i});const r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,y0Accessor:f,gradientFill:p=!1,lineDataAccessor:y="coordinates",colorBy:m,colorScheme:b,curve:x="monotoneX",areaOpacity:k=.7,lineGradient:w,showLine:A=!0,lineWidth:j=2,showPoints:S=!1,pointRadius:O=3,tooltip:M,annotations:C,forecast:_,anomaly:P,band:L,xExtent:T,yExtent:R,frameProps:B={},selection:N,linkedHover:E,onObservation:D,onClick:I,hoverHighlight:H,chartId:F,loading:W,loadingContent:$,emptyContent:z,legendInteraction:Y,legendPosition:G,color:q,stroke:X,strokeWidth:V,opacity:U}=o,{width:K,height:Q,enableHover:Z,showGrid:J,showLegend:ee,title:te,description:oe,summary:ne,accessibleTable:ie,xLabel:re,yLabel:se}=r,ae=t.useMemo(()=>v(s),[s]);dr("AreaChart",ae,"xAccessor",d),dr("AreaChart",ae,"yAccessor",h);const le=xr({data:ae,rawData:s,colorBy:m,colorScheme:b,legendInteraction:Y,legendPosition:G,selection:N,linkedHover:E,fallbackFields:m?["string"==typeof m?m:""]:[],unwrapData:!1,onObservation:D,onClick:I,hoverHighlight:H,chartType:"AreaChart",chartId:F,showLegend:ee,userMargin:a,marginDefaults:r.marginDefaults,loading:W,loadingContent:$,emptyContent:z,width:K,height:Q}),{effectiveData:ce,statisticalAnnotations:ue}=Pr({data:ae,xAccessor:d,yAccessor:h,forecast:_,anomaly:P,groupBy:g}),{flattenedData:de,lineStyle:he,pointStyle:ge,defaultTooltipContent:fe}=Nr({safeData:ce,data:s,areaBy:g,lineDataAccessor:y,colorBy:m,colorScale:le.colorScale,color:q,stroke:X,strokeWidth:V,opacity:U,effectiveSelectionHook:le.effectiveSelectionHook,resolvedSelection:le.resolvedSelection,areaOpacity:k,showLine:A,lineWidth:j,showPoints:S,pointRadius:O,xAccessor:d,yAccessor:h,xLabel:re,yLabel:se,xFormat:c,yFormat:u,groupField:g||m,band:L}),pe=yr({componentName:"AreaChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),ye=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:de}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0}),f&&{y0Accessor:f}),L&&{band:L}),p&&{gradientFill:p}),w&&{lineGradient:w}),{curve:x,lineStyle:he}),S&&ge&&{pointStyle:ge}),{size:[K,Q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:le.margin,showAxes:r.showAxes,xLabel:re,yLabel:se,xFormat:c,yFormat:u,enableHover:Z}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:J}),le.legendBehaviorProps),Tr({title:te,description:oe,summary:ne,accessibleTable:ie,className:l,animate:o.animate,axisExtent:o.axisExtent})),"multi"===M?{tooltipContent:hn(),tooltipMode:"multi"}:Br({tooltip:M,defaultTooltipContent:fe})),Rr({linkedHover:E,onObservation:D,onClick:I,hoverHighlight:H,customHoverBehavior:le.customHoverBehavior,customClickBehavior:le.customClickBehavior})),(C&&C.length>0||ue.length>0)&&{annotations:[...C||[],...ue]}),T&&{xExtent:T}),R&&{yExtent:R}),le.crosshairProps),B);return le.earlyReturn?le.earlyReturn:pe?e.jsx(or,{componentName:"AreaChart",message:pe,width:K,height:Q}):e.jsx(sr,{componentName:"AreaChart",width:K,height:Q,children:e.jsx(Jn,Object.assign({ref:i},ye))})});function Dr(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}Er.displayName="AreaChart";const Ir=t.forwardRef(function(o,n){const i=t.useRef(null),r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:g="b",seriesALabel:f="A",seriesBLabel:p="B",seriesAColor:y="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:b=!0,lineWidth:x=1.5,showPoints:k=!1,pointRadius:w=3,curve:A="linear",areaOpacity:j=.6,gradientFill:S,tooltip:O,annotations:M,xExtent:C,yExtent:_,frameProps:P={},selection:L,linkedHover:T,onObservation:R,onClick:B,hoverHighlight:N,chartId:E,loading:D,loadingContent:I,emptyContent:H,legendInteraction:F,legendPosition:W,pointIdAccessor:$,windowSize:z}=o,{width:Y,height:G,enableHover:q,showGrid:X,showLegend:V,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=r,te=t.useMemo(()=>"function"==typeof d?e=>Dr(d(e)):e=>Dr(e[d]),[d]),oe=t.useMemo(()=>"function"==typeof h?e=>Dr(h(e)):e=>Dr(e[h]),[h]),ne=t.useMemo(()=>"function"==typeof g?e=>Dr(g(e)):e=>Dr(e[g]),[g]),[ie,re]=t.useState([]),se=t.useRef([]),ae=null==s,le=t.useMemo(()=>v(ae?ie:s),[ae,ie,s]),ce=t.useMemo(()=>function(e,t,o,n){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];let s=0,a=null,l=null,c=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>r.push(e),g=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;i.length>e;e++){const r=i[e],f=t(r),p=o(r),y=n(r);if(!Number.isFinite(f)||!Number.isFinite(p)||!Number.isFinite(y))continue;const m=u(p,y);if(null!==m)if(null!=a){if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{const o=p-l.a-(y-l.b);if(0!==o){const n=Math.max(0,Math.min(1,(l.b-l.a)/o));e=l.x+n*(f-l.x),t=l.a+n*(p-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;c.length>e;e++)g(c[e],a)}else for(const e of c)g(e,a);c=[],h({__x:f,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:f,a:p,b:y,w:m}}else{a=m;for(const e of c)g(e,a);c=[],h({__x:f,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:f,a:p,b:y,w:m}}else c.push({x:f,y:p,datum:r})}for(const e of c)g(e,null!=a?a:"A");return r}(le,te,oe,ne),[le,te,oe,ne]),ue=t.useMemo(()=>b?function(e,t,o,n){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];for(const e of i){const i=t(e),s=o(e),a=n(e);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(le,te,oe,ne):[],[b,le,te,oe,ne]),de=t.useMemo(()=>[...ce,...ue],[ce,ue]),he=t.useMemo(()=>{const e=new Set;for(const t of ce)e.add(t.__diffSegment);return Array.from(e)},[ce]);t.useImperativeHandle(n,()=>{const e=e=>{const t=z&&e.length>z?e.slice(e.length-z):e;se.current=t,re(t)},t=$?"function"==typeof $?$:e=>e[$]:null;return{push:t=>e([...se.current,t]),pushMany:t=>e([...se.current,...t]),remove:o=>{if(!t)return[];const n=Array.isArray(o)?o:[o],i=[],r=[];for(const e of se.current)n.includes(t(e))?i.push(e):r.push(e);return e(r),i},update:(o,n)=>{if(!t)return[];const i=Array.isArray(o)?o:[o],r=[],s=se.current.map(e=>{if(i.includes(t(e))){const t=n(e);return r.push(t),t}return e});return e(s),r},clear:()=>e([]),getData:()=>ae?se.current:le,getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}},[ae,le,$,z]);const ge=xr({data:le,rawData:s,colorBy:"__diffWinner",colorScheme:[y,m],legendInteraction:F,legendPosition:W,selection:L,linkedHover:T,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:B,hoverHighlight:N,chartType:"DifferenceChart",chartId:E,showLegend:V,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:I,emptyContent:H,width:Y,height:G}),fe=t.useMemo(()=>{if(!1!==V)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:f,color:y},{label:p,color:m}]}]}},[V,f,p,y,m]),pe=t.useCallback(e=>{const t=e.__diffSegment;return{fill:"A"==((null==t?void 0:t.endsWith("-A"))?"A":"B")?y:m,stroke:"none",fillOpacity:j}},[y,m,j]),ye=t.useCallback(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?y:m,strokeWidth:x,fill:"none"}),[y,m,x]),me=t.useCallback(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?y:m,r:w}),[y,m,w]),ve=t.useCallback(t=>{var o;const n=t.data,i=t.allSeries,r=null!==(o=t.xValue)&&void 0!==o?o:null==n?void 0:n.__x;let s=null==n?void 0:n.__valA,a=null==n?void 0:n.__valB;if(i&&i.length>0){const e=i.find(e=>"line-A"===e.group),t=i.find(e=>"line-B"===e.group);null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(s=e.value),null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value)}if(null!=r&&(null==s||null==a)){const e=le.find(e=>te(e)===r);e&&(null==s&&(s=oe(e)),null==a&&(a=ne(e)))}const l=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",u=c&&null!=r?c(r):null!=r?r+"":"";return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[u&&e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:u}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),e.jsxs("span",{children:[f,": ",l(s)]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),e.jsxs("span",{children:[p,": ",l(a)]})]}),null!=s&&null!=a&&Number.isFinite(s)&&Number.isFinite(a)&&e.jsxs("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",l(s-a)]})]})},[le,te,oe,ne,c,y,m,f,p]),be="multi"===O,xe=t.useMemo(()=>!1===O?()=>null:be?ve:gn(O)||ve,[O,be,ve]),ke=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:"mixed",data:de,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:he,curve:A,areaStyle:pe,lineStyle:ye},k&&{pointStyle:me}),{size:[Y,G],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ge.margin,showAxes:r.showAxes,xLabel:J,yLabel:ee,xFormat:c,yFormat:u,enableHover:q,showGrid:X}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),fe&&{legend:fe,legendPosition:ge.legendPosition}),Tr({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:o.animate,axisExtent:o.axisExtent})),{tooltipContent:xe}),be&&{tooltipMode:"multi"}),Rr({linkedHover:T,onObservation:R,onClick:B,hoverHighlight:N,customHoverBehavior:ge.customHoverBehavior,customClickBehavior:ge.customClickBehavior})),M&&M.length>0&&{annotations:M}),C&&{xExtent:C}),_&&{yExtent:_}),ge.crosshairProps),P);return ge.earlyReturn?ge.earlyReturn:e.jsx(sr,{componentName:"DifferenceChart",width:Y,height:G,children:e.jsx(Jn,Object.assign({ref:i},ke))})});"function"==typeof Ir&&(Ir.displayName="DifferenceChart");const Hr=t.forwardRef(function(o,n){const i=t.useRef(null),r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,lineDataAccessor:f="coordinates",colorBy:p,colorScheme:y,curve:m="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:j=!1,baseline:S="zero",stackOrder:O,tooltip:M,annotations:C,xExtent:_,yExtent:P,frameProps:L={},selection:T,linkedHover:R,onObservation:B,onClick:N,hoverHighlight:E,chartId:D,loading:I,loadingContent:H,emptyContent:F,legendInteraction:W,legendPosition:$,color:z,stroke:Y,strokeWidth:G,opacity:q}=o,{width:X,height:V,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,xLabel:oe,yLabel:ne}=r,ie=t.useMemo(()=>v(s),[s]),re=p||g;Ar(n,{variant:"xy",frameRef:i});const se=xr({data:ie,rawData:s,colorBy:re,colorScheme:y,legendInteraction:W,legendPosition:$,selection:T,linkedHover:R,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:B,onClick:N,hoverHighlight:E,chartType:"StackedAreaChart",chartId:D,showLegend:Q,userMargin:a,marginDefaults:r.marginDefaults,loading:I,loadingContent:H,emptyContent:F,width:X,height:V}),{flattenedData:ae,lineStyle:le,pointStyle:ce,defaultTooltipContent:ue}=Nr({safeData:ie,data:s,areaBy:g,lineDataAccessor:f,colorBy:re,colorScale:se.colorScale,color:z,stroke:Y,strokeWidth:G,opacity:q,effectiveSelectionHook:se.effectiveSelectionHook,resolvedSelection:se.resolvedSelection,areaOpacity:b,showLine:x,lineWidth:k,showPoints:w,pointRadius:A,xAccessor:d,yAccessor:h,xLabel:oe,yLabel:ne,xFormat:c,yFormat:u,groupField:g||p}),de=yr({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),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:"stackedarea"},null!=s&&{data:ae}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0,curve:m,normalize:j,baseline:j?"zero":S,stackOrder:O,lineStyle:le}),w&&ce&&{pointStyle:ce}),{size:[X,V],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se.margin,showAxes:r.showAxes,xLabel:oe,yLabel:ne,xFormat:c,yFormat:u,enableHover:U}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:K}),se.legendBehaviorProps),Tr({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:o.animate,axisExtent:o.axisExtent})),"multi"===M?{tooltipContent:hn(),tooltipMode:"multi"}:Br({tooltip:M,defaultTooltipContent:ue})),Rr({linkedHover:R,onObservation:B,onClick:N,hoverHighlight:E,customHoverBehavior:se.customHoverBehavior,customClickBehavior:se.customClickBehavior})),C&&C.length>0&&{annotations:C}),_&&{xExtent:_}),P&&{yExtent:P}),se.crosshairProps),L);return se.earlyReturn?se.earlyReturn:de?e.jsx(or,{componentName:"StackedAreaChart",message:de,width:X,height:V}):e.jsx(sr,{componentName:"StackedAreaChart",width:X,height:V,children:e.jsx(Jn,Object.assign({ref:i},he))})});function Fr(e){const{colorBy:o,colorScale:n,color:i,pointRadius:r=5,radiusFn:s,fillOpacity:a=1,fallbackFill:l,baseStyleExtras:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:g,resolvedSelection:f,colorDatumAccessor:p}=e,y=t.useMemo(()=>e=>{const t="function"==typeof c?c(e):c,u=t?Object.assign({},t):{};if(void 0===u.fillOpacity&&(u.fillOpacity=a),void 0===u.fill)if(o){if(n){const t=p?p(e):e;u.fill=ke(t,o,n)}}else u.fill=l?l(e):i||Ni;return void 0===u.r&&(u.r=s?s(e):r),u},[o,n,i,r,s,a,l,c,p]),m=t.useMemo(()=>kr(y,{stroke:u,strokeWidth:d,opacity:h}),[y,u,d,h]);return t.useMemo(()=>Oi(m,null!=g?g:null,f),[m,g,f])}function Wr(e){const{accessor:o,data:n,isPushMode:i}=e,r=t.useRef(null),[s,a]=t.useState(0),l=t.useCallback(e=>{if(!i||!o)return;let t=!1;for(const n of e){const e="function"==typeof o?o(n):n[o];if(null==e)continue;const i="number"==typeof e?e:Number(e);Number.isFinite(i)&&(r.current?(r.current[0]>i&&(r.current[0]=i,t=!0),i>r.current[1]&&(r.current[1]=i,t=!0)):(r.current=[i,i],t=!0))}t&&a(e=>e+1)},[i,o]),c=t.useCallback(()=>{i&&(r.current=null,a(e=>e+1))},[i]),u=t.useMemo(()=>{var e;if(i)return null!==(e=r.current)&&void 0!==e?e:void 0;if(!o||0===n.length)return;const t="function"==typeof o?o:e=>e[o];let s=1/0,a=-1/0;for(const e of n){const o=t(e);if(null==o)continue;const n="number"==typeof o?o:Number(o);Number.isFinite(n)&&(s>n&&(s=n),n>a&&(a=n))}return Number.isFinite(s)&&Number.isFinite(a)?[s,a]:void 0},[n,o,i,s]);return{domain:u,trackPushed:l,reset:c}}function $r(e){var t;if(!e)return;const o="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({type:"trend",method:null!==(t=o.method)&&void 0!==t?t:"linear"},null!=o.bandwidth&&{bandwidth:o.bandwidth}),null!=o.order&&{order:o.order}),null!=o.color&&{color:o.color}),null!=o.strokeWidth&&{strokeWidth:o.strokeWidth}),null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray}),null!=o.label&&{label:o.label})}Hr.displayName="StackedAreaChart";const zr=t.forwardRef(function(o,n){const i=t.useRef(null),r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xScaleType:g,yScaleType:f,colorBy:y,colorScheme:m,sizeBy:b,sizeRange:x=[3,15],pointRadius:k=5,pointOpacity:w=.8,tooltip:A,marginalGraphics:j,pointIdAccessor:S,annotations:O,regression:M,forecast:C,anomaly:_,xExtent:P,yExtent:L,frameProps:T={},selection:R,linkedHover:B,linkedBrush:N,onObservation:E,onClick:D,hoverHighlight:I,chartId:H,loading:F,loadingContent:W,emptyContent:$,legendInteraction:z,legendPosition:Y,color:G,stroke:q,strokeWidth:X,opacity:V}=o,{width:U,height:K,enableHover:Q,showGrid:Z,showLegend:J,title:ee,description:te,summary:oe,accessibleTable:ne,xLabel:ie,yLabel:re}=r,se=t.useMemo(()=>v(s),[s]),ae=void 0===s,{domain:le,trackPushed:ce,reset:ue}=Wr({accessor:b,data:se,isPushMode:ae}),de=t.useCallback(e=>{var t;ce([e]),null===(t=i.current)||void 0===t||t.push(e)},[ce]),he=t.useCallback(e=>{var t;ce(e),null===(t=i.current)||void 0===t||t.pushMany(e)},[ce]);Ar(n,{variant:"xy",frameRef:i,overrides:{push:de,pushMany:he,clear:()=>{var e;ue(),null===(e=i.current)||void 0===e||e.clear()}},deps:[de,he,ue]});const ge=xr({data:se,rawData:s,colorBy:y,colorScheme:m,legendInteraction:z,legendPosition:Y,selection:R,linkedHover:B,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:E,onClick:D,hoverHighlight:I,chartType:"Scatterplot",chartId:H,showLegend:J,userMargin:a,marginDefaults:r.marginDefaults,loading:F,loadingContent:W,emptyContent:$,width:U,height:K}),fe=Si(N),pe=gi({name:(null==fe?void 0:fe.name)||"__unused_brush__",xField:(null==fe?void 0:fe.xField)||("string"==typeof d?d:void 0),yField:(null==fe?void 0:fe.yField)||("string"==typeof h?h:void 0)}),ye=fe?"xyBrush"===pe.brushInteraction.brush?"xy":"xBrush"===pe.brushInteraction.brush?"x":"y":void 0,me=p.useRef(pe.brushInteraction);me.current=pe.brushInteraction;const ve=t.useCallback(e=>{const t=me.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(ge.earlyReturn)return ge.earlyReturn;dr("Scatterplot",se,"xAccessor",d),dr("Scatterplot",se,"yAccessor",h);const be=t.useMemo(()=>b?null!=le?le:[0,1]:void 0,[b,le]),xe=t.useMemo(()=>b?e=>Ae(e,b,x,be):void 0,[b,x,be]),ke=Fr({colorBy:y,colorScale:ge.colorScale,color:G,pointRadius:k,fillOpacity:w,radiusFn:xe,stroke:q,strokeWidth:X,opacity:V,effectiveSelectionHook:ge.effectiveSelectionHook,resolvedSelection:ge.resolvedSelection}),we=t.useMemo(()=>er([{label:ie||Ui(d),accessor:d,role:"x",format:c},{label:re||Ui(h),accessor:h,role:"y",format:u},...y?[{label:Ui(y),accessor:y,role:"color"}]:[],...b?[{label:Ui(b),accessor:b,role:"size"}]:[]]),[d,h,ie,re,y,b,c,u]),{effectiveData:je,statisticalAnnotations:Se}=Pr({data:se,xAccessor:d,yAccessor:h,forecast:C,anomaly:_}),Oe=t.useMemo(()=>{const e=$r(M);return e||0!==Se.length?[...e?[e]:[],...O||[],...Se]:O},[M,O,Se]),Me=yr({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(Me)return e.jsx(or,{componentName:"Scatterplot",message:Me,width:U,height:K});const 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({chartType:"scatter"},null!=s&&{data:je}),{xAccessor:d,yAccessor:h,xScaleType:g,yScaleType:f,colorAccessor:y||void 0,sizeAccessor:b||void 0,sizeRange:x,pointStyle:ke,colorScheme:m,size:[U,K],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ge.margin,showAxes:r.showAxes,xLabel:ie,yLabel:re,xFormat:c,yFormat:u,enableHover:Q,showGrid:Z}),ge.legendBehaviorProps),Tr({title:ee,description:te,summary:oe,accessibleTable:ne,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:A,defaultTooltipContent:we})),Rr({linkedHover:B,onObservation:E,onClick:D,hoverHighlight:I,customHoverBehavior:ge.customHoverBehavior,customClickBehavior:ge.customClickBehavior})),j&&{marginalGraphics:j}),S&&{pointIdAccessor:S}),Oe&&Oe.length>0&&{annotations:Oe}),P&&{xExtent:P}),L&&{yExtent:L}),fe&&{brush:{dimension:ye},onBrush:ve}),ge.crosshairProps),T);return e.jsx(sr,{componentName:"Scatterplot",width:U,height:K,children:e.jsx(Jn,Object.assign({ref:i},Ce))})});function Yr(e,t){return ne(1===t?.5:e/(t-1))}zr.displayName="Scatterplot";const Gr=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);Ar(n,{variant:"xy",frameRef:s});const a=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:g="x",yAccessor:f="y",orderAccessor:p,orderLabel:y,pointRadius:m=4,tooltip:v,pointIdAccessor:b,annotations:x,regression:k,forecast:w,anomaly:A,xExtent:j,yExtent:S,frameProps:O={},selection:M,linkedHover:C,onObservation:_,onClick:P,hoverHighlight:L,chartId:T,loading:R,loadingContent:B,emptyContent:N,legendInteraction:E,stroke:D,strokeWidth:I,opacity:H}=o,{width:F,height:W,enableHover:$,showGrid:z,title:Y,description:G,summary:q,accessibleTable:X,xLabel:V,yLabel:U}=a,K=l||[],{safeData:Q,orderMap:Z}=t.useMemo(()=>{const e="function"==typeof g?g:e=>e[g],t="function"==typeof f?f:e=>e[f];let o=K;if(p&&K.length>0){const e="function"==typeof p?p:e=>e[p];o=[...K].sort((t,o)=>{const n=e(t),i=e(o);return(n instanceof Date?n.getTime():+n)-(i instanceof Date?i.getTime():+i)})}const n=new WeakMap;let i=0;for(const n of o){const o=e(n),r=t(n);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&i++}let r=0;for(const s of o){const o=e(s),a=t(s);null!=o&&null!=a&&isFinite(o)&&isFinite(a)&&n.set(s,{idx:r++,total:i})}return{safeData:o,orderMap:n}},[K,p,g,f]);dr("ConnectedScatterplot",Q,"xAccessor",g),dr("ConnectedScatterplot",Q,"yAccessor",f);const J=xr({data:Q,rawData:l,colorBy:void 0,colorScheme:void 0,legendInteraction:E,selection:M,linkedHover:C,fallbackFields:[],unwrapData:!1,onObservation:_,onClick:P,hoverHighlight:L,chartType:"ConnectedScatterplot",chartId:T,showLegend:void 0,userMargin:c,marginDefaults:{top:50,right:40,bottom:60,left:70},loading:R,loadingContent:B,emptyContent:N,width:F,height:W}),ee=null!==(r=null===(i=J.resolvedSelection)||void 0===i?void 0:i.unselectedOpacity)&&void 0!==r?r:.5,te=t.useMemo(()=>(e,t)=>{var o,n,i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return;const a=null===(o=J.effectiveSelectionHook)||void 0===o?void 0:o.isActive,l=null===(n=J.effectiveSelectionHook)||void 0===n?void 0:n.predicate,c=100>s.length,u=s.length;e.lineCap="round";for(let t=0;u-1>t;t++){const o=s[t],n=s[t+1],d=Yr(t,u),h=!a||!l||l(null!==(i=o.datum)&&void 0!==i?i:o)||l(null!==(r=n.datum)&&void 0!==r?r:n),g=a?h?1:ee:1;c&&(e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(n.x,n.y),e.strokeStyle="white",e.lineWidth=m+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(n.x,n.y),e.strokeStyle=d,e.lineWidth=m,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[m,J.effectiveSelectionHook,ee]),oe=t.useMemo(()=>[te],[te]),ne=t.useMemo(()=>(t,o,n)=>{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 o=s[t],n=s[t+1],u=Yr(t,a),d="number"==typeof(null===(i=o.style)||void 0===i?void 0:i.opacity)?o.style.opacity:1,h="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(d,h);l&&c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:m+2,strokeLinecap:"round",opacity:.5*g},"halo-"+t)),c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:u,strokeWidth:m,strokeLinecap:"round",opacity:g},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[m]),ie=t.useMemo(()=>[ne],[ne]),re=t.useMemo(()=>e=>{var t,o;const n=Z.get(e),i=null!==(t=null==n?void 0:n.idx)&&void 0!==t?t:0,r=null!==(o=null==n?void 0:n.total)&&void 0!==o?o:1;return{fill:r>0?Yr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,Z]),se=Fr({colorScale:void 0,baseStyleExtras:re,stroke:D,strokeWidth:I,opacity:H,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),ae=y||("string"==typeof p?p:"Order"),le=t.useMemo(()=>er([{label:V||Ui(g),accessor:g,role:"x",format:d},{label:U||Ui(f),accessor:f,role:"y",format:h},...p?[{label:ae,accessor:p,role:"group"}]:[]]),[g,f,V,U,p,ae,d,h]),ce=yr({componentName:"ConnectedScatterplot",data:l,accessors:{xAccessor:g,yAccessor:f}}),{effectiveData:ue,statisticalAnnotations:de}=Pr({data:Q,xAccessor:g,yAccessor:f,forecast:w,anomaly:A}),he=$r(k),ge=he||de.length>0?[...he?[he]:[],...x||[],...de]:x,fe=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!=l&&{data:ue}),{xAccessor:g,yAccessor:f,pointStyle:se,size:[F,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,showAxes:a.showAxes,xLabel:V,yLabel:U,xFormat:d,yFormat:h,enableHover:$,showGrid:z}),Tr({title:Y,description:G,summary:q,accessibleTable:X,className:u,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:v,defaultTooltipContent:le})),Rr({linkedHover:C,onObservation:_,onClick:P,hoverHighlight:L,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior})),b&&{pointIdAccessor:b}),{canvasPreRenderers:oe,svgPreRenderers:ie}),ge&&ge.length>0&&{annotations:ge}),j&&{xExtent:j}),S&&{yExtent:S}),J.crosshairProps),O);return J.earlyReturn?J.earlyReturn:ce?e.jsx(or,{componentName:"ConnectedScatterplot",message:ce,width:F,height:W}):e.jsx(sr,{componentName:"ConnectedScatterplot",width:F,height:W,children:e.jsx(Jn,Object.assign({ref:s},fe))})});Gr.displayName="ConnectedScatterplot";const qr=t.forwardRef(function(o,n){const i=t.useRef(null),r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:x="white",tooltip:k,marginalGraphics:w,pointIdAccessor:A,annotations:j,regression:S,xExtent:O,yExtent:M,frameProps:C={},selection:_,linkedHover:P,linkedBrush:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:N,loading:E,loadingContent:D,emptyContent:I,legendInteraction:H,legendPosition:F,color:W,stroke:$,strokeWidth:z,opacity:Y}=o,{width:G,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,oe=t.useMemo(()=>v(s),[s]),ne=void 0===s,ie=xr({data:oe,rawData:s,colorBy:p,colorScheme:y,legendInteraction:H,legendPosition:F,selection:_,linkedHover:P,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:T,onClick:R,hoverHighlight:B,chartType:"BubbleChart",chartId:N,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:E,loadingContent:D,emptyContent:I,width:G,height:q}),{domain:re,trackPushed:se,reset:ae}=Wr({accessor:g,data:oe,isPushMode:ne}),le=t.useCallback(e=>{var t;se([e]),null===(t=i.current)||void 0===t||t.push(e)},[se]),ce=t.useCallback(e=>{var t;se(e),null===(t=i.current)||void 0===t||t.pushMany(e)},[se]);Ar(n,{variant:"xy",frameRef:i,overrides:{push:le,pushMany:ce,clear:()=>{var e;ae(),null===(e=i.current)||void 0===e||e.clear()}},deps:[le,ce,ae]});const ue=Si(L);gi({name:(null==ue?void 0:ue.name)||"__unused_brush__",xField:(null==ue?void 0:ue.xField)||("string"==typeof d?d:void 0),yField:(null==ue?void 0:ue.yField)||("string"==typeof h?h:void 0)});const de=t.useMemo(()=>({stroke:x,strokeWidth:b}),[x,b]),he=t.useMemo(()=>null!=re?re:[0,1],[re]),ge=t.useCallback(e=>Ae(e,g,f,he),[g,f,he]),fe=Fr({colorBy:p,colorScale:ie.colorScale,color:W,fillOpacity:m,radiusFn:ge,baseStyleExtras:de,stroke:$,strokeWidth:z,opacity:Y,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection}),pe=t.useMemo(()=>er([{label:ee||Ui(d),accessor:d,role:"x",format:c},{label:te||Ui(h),accessor:h,role:"y",format:u},{label:Ui(g),accessor:g,role:"size"},...p?[{label:Ui(p),accessor:p,role:"color"}]:[]]),[d,h,ee,te,g,p,c,u]),ye=yr({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:g}});if(ye)return e.jsx(or,{componentName:"BubbleChart",message:ye,width:G,height:q});const me=$r(S),ve=me?[me,...j||[]]:j,be=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:oe}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:fe,colorScheme:y,size:[G,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ie.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ie.legendBehaviorProps),Tr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:k,defaultTooltipContent:pe})),Rr({linkedHover:P,onObservation:T,onClick:R,hoverHighlight:B,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior})),w&&{marginalGraphics:w}),A&&{pointIdAccessor:A}),ve&&ve.length>0&&{annotations:ve}),O&&{xExtent:O}),M&&{yExtent:M}),ie.crosshairProps),C);return ie.earlyReturn?ie.earlyReturn:e.jsx(sr,{componentName:"BubbleChart",width:G,height:q,children:e.jsx(Jn,Object.assign({ref:i},be))})});qr.displayName="BubbleChart";const Xr=t.forwardRef(function(o,n){var r;const s=t.useRef(null);Ar(n,{variant:"xy",frameRef:s});const a=Xi(o.mode,{width:o.width,height:o.height,showGrid:void 0,enableHover:o.enableHover,showLegend:void 0,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xAccessor:d="x",yAccessor:h="y",valueAccessor:g="value",xFormat:f,yFormat:p,colorScheme:y,customColorScale:m,showValues:b=!1,valueFormat:x,tooltip:k,annotations:w,xExtent:A,yExtent:j,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:B,showLegend:N,legendPosition:E,legendInteraction:D}=o,{width:I,height:H,enableHover:F,title:W,description:$,summary:z,accessibleTable:Y,xLabel:G,yLabel:q}=a,X=ur(T,I,H,R),V=X?null:cr(l,I,H,B),U=t.useMemo(()=>v(l),[l]),K=function(){var e;const t=Bi();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),ce=null!==(r=null!=y?y:K)&&void 0!==r?r:"blues",ue=null!=N&&N,de=null!=E?E:"right",{margin:he}=Yi({data:U,colorBy:ue?"value":void 0,colorScale:void 0,showLegend:ue,legendPosition:de,userMargin:c,defaults:a.marginDefaults}),{customHoverBehavior:ge,customClickBehavior:fe,crosshairSourceId:pe}=$i({selection:O,linkedHover:M,fallbackFields:[],onObservation:C,onClick:_,chartType:"Heatmap",chartId:L,hoverHighlight:P,colorByField:void 0});br(O);const ye=zi(M,pe);Gi(D,void 0,[]);const me=t.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),ve=t.useMemo(()=>{const e=U.map(me);return[Math.min(...e),Math.max(...e)]},[U,me]),be=t.useMemo(()=>"custom"===ce&&m?m:i.scaleSequential({blues:Q,reds:Z,greens:J,viridis:ne,oranges:ee,purples:te,greys:oe,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le}[ce]||Q).domain(ve),[ce,m,ve]),xe=t.useMemo(()=>er([{label:G||Ui(d),accessor:d,role:"x",format:f},{label:q||Ui(h),accessor:h,role:"y",format:p},{label:Ui(g),accessor:g,role:"value",format:x}]),[d,h,G,q,g,f,p,x]),ke=yr({componentName:"Heatmap",data:l,accessors:{xAccessor:d,yAccessor:h,valueAccessor:g}}),we=t.useMemo(()=>{if(ue)return{gradient:{colorFn:e=>be(e),domain:ve,label:"string"==typeof g?g:"value",format:x}}},[ue,be,ve,g,x]),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({chartType:"heatmap"},null!=l&&{data:U}),{xAccessor:d,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==ce?ce:void 0,showValues:b,heatmapValueFormat:x,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:he,showAxes:a.showAxes,xLabel:G,yLabel:q,xFormat:f,yFormat:p,enableHover:F}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),we&&{legend:we,legendPosition:de}),Tr({title:W,description:$,summary:z,accessibleTable:Y,className:u,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:k,defaultTooltipContent:xe})),Rr({linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,customHoverBehavior:ge,customClickBehavior:fe})),w&&w.length>0&&{annotations:w}),A&&{xExtent:A}),j&&{yExtent:j}),ye),S);return X||V||(ke?e.jsx(or,{componentName:"Heatmap",message:ke,width:I,height:H}):e.jsx(sr,{componentName:"Heatmap",width:I,height:H,children:e.jsx(Jn,Object.assign({ref:s},Ae))}))});Xr.displayName="Heatmap";const Vr="__splomIdx",Ur={top:4,bottom:4,left:4,right:4};function Kr({frameRef:i,cellSize:r,onBrush:s}){const a=t.useRef(null),l=r-Ur.left-Ur.right,c=r-Ur.top-Ur.bottom;return t.useEffect(()=>{if(!a.current)return;const e=o.select(a.current).select(".brush-g"),t=n.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const o=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void s(null);const[[n,r],[a,l]]=e.selection,c=[[o.x.invert(n),o.y.invert(r)],[o.x.invert(a),o.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(${Ur.left},${Ur.top})`})})}function Qr({data:o,xField:n,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:g,onPointHover:f}){const p=t.useRef(null),y=ui({name:u,clientId:`splom-${n}-${i}`}),m=gi({name:u,xField:n,yField:i}),v=ui({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==f||f(null));const t=e.data,o=null==t?void 0:t[Vr];void 0!==o&&(b({[Vr]:[o]}),null==f||f(t,e.x+Ur.left,e.y+Ur.top))},[b,f]),w=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?ke(e,l,c):Ni,"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(Jn,{ref:p,chartType:"scatter",data:o,size:[r,r],xAccessor:n,yAccessor:i,pointStyle:w,margin:Ur,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.jsx(Kr,{frameRef:p,cellSize:r,xField:n,yField:i,onBrush:x})]})}function Zr({data:o,field:n,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=ui({name:c,clientId:"splom-diag-"+n}),g=ui({name:u,clientId:`splom-diag-${n}-hover`}),f="hover"===d?g:h,p=f.isActive,y=f.predicate,m=t.useMemo(()=>{const e=o.map(e=>e[n]).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(o.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)),f=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of o){const o=e[n];if(null==o||isNaN(o))continue;const r=Math.min(Math.floor((o-t)/i),s-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 o=0;return e.map((e,n)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})}),b=f.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=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}},[o,n,s,r,p,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,o)=>t.map((t,n)=>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):Ni,opacity:p?.3:.6},`bg-${o}-${n}`))):m.bars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Ni,opacity:p?.3:.6},"bg-"+o)),p&&(m.categories.length>0?m.selectedCategoryBars.map((t,o)=>t.map((t,n)=>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):Ni,opacity:.7},`sel-${o}-${n}`))):m.selectedBars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Ni,opacity:.7},"sel-"+o)))]})}function Jr({label:t,cellSize:o}){return e.jsx("svg",{width:o,height:o,children:e.jsx("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function es(o){const{data:n,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:y=!0,unselectedOpacity:m=.1,showGrid:v=!1,tooltip:b,showLegend:x,idAccessor:k,className:w,onObservation:A,chartId:j}=o,S="splom",O="splom-hover",M=y?"hover":f?"brush":"hover",C=ai(e=>e.clearSelection),[_,P]=t.useState(null),L=t.useCallback(()=>{C(O),P(null)},[C,O]),T=t.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[Vr]?e:Object.assign(Object.assign({},e),{[Vr]:t})),[n]),R=Fi(T,s,a),B=void 0!==x?x:!!s,N=t.useMemo(()=>{if(!B||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(T.map(t=>t[e]))].map(e=>({label:e+"",color:R?R(e+""):Ni})):null},[B,s,T,R]),E=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:[N&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:N.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:E,onMouseLeave:"hover"===M?L:void 0,children:[i.map((t,o)=>e.jsxs(p.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((n,i)=>o===i?"label"===h?e.jsx(Jr,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(Zr,{data:T,field:t,label:r[t]||t,cellSize:l,bins:g,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:m,mode:M},"diag-"+t):e.jsx(Qr,{data:T,xField:n,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:O,unselectedOpacity:m,showGrid:v,tooltip:b,mode:M,onPointHover:"hover"===M?(e,r,s)=>{e?(P({datum:e,xField:n,yField:t,colIndex:i,rowIndex:o,px:null!=r?r:0,py:null!=s?s:0}),A&&A({type:"hover",datum:e,x:null!=r?r:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:j})):(P(null),A&&A({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:j}))}:void 0},`cell-${t}-${n}`))]},"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"===M&&(()=>{const t=_.datum,o=r[_.xField]||_.xField,n=r[_.yField]||_.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=k?"function"==typeof k?k(t):t[k]:"Row "+t[Vr];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:[o,": ",null!=t[_.xField]?Number(t[_.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[n,": ",null!=t[_.yField]?Number(t[_.yField]).toFixed(1):"–"]}),null!=i&&e.jsxs("div",{style:{opacity:.8},children:["string"==typeof s?s:"group",": ",i+""]})]})})()]})}function ts(t){const{brushMode:o="crossfilter",hoverMode:n=!0}=t,i={};return!n&&o&&(i.splom={resolution:o}),n&&(i["splom-hover"]={resolution:"union"}),e.jsx(Ai,{selections:i,children:e.jsx(es,Object.assign({},t))})}function os({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),f=i+s.left+s.right,p=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?n.brushX().extent([[0,0],[i,r]]):n.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 o=("x"===l?a.x:a.y).invert;if(!o)return;const n=[o(t[0]),o(t[1])];u(n)}),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=o.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(g.current=!0,c){const o=[t(c[0]),t(c[1])];e.call(h.current.move,o)}else e.call(h.current.move,null);g.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`})})}function ns(o){var n,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:b="y",lineBy:x,lineDataAccessor:k="coordinates",colorBy:w,colorScheme:A,curve:j="linear",lineWidth:S=2,fillArea:O=!1,areaOpacity:M=.3,showPoints:C=!1,pointRadius:_=3,enableHover:P=!0,showGrid:L=!1,showLegend:T,legendPosition:R,tooltip:B,minimap:N={},renderBefore:E=!1,onBrush:D,brushExtent:I,yExtent:H,frameProps:F={},loading:W,loadingContent:$,emptyContent:z}=o,Y=ur(W,s,a,$),G=Y?null:cr(r,s,a,z),q=t.useMemo(()=>v(r),[r]),[X,V]=t.useState(null),U=null!=I?I:X,K=t.useCallback(e=>{I||V(e),null==D||D(e)},[I,D]),Q=t.useRef(null),[Z,J]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const o=()=>{var n,i;if(t)return;const r=null===(i=null===(n=Q.current)||void 0===n?void 0:n.getScales)||void 0===i?void 0:i.call(n);r?J(r):e=requestAnimationFrame(o)};return e=requestAnimationFrame(o),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const ee=void 0!==(null===(n=q[0])||void 0===n?void 0:n[k]),te=t.useMemo(()=>{if(ee)return q;if(x){const e=q.reduce((e,t)=>{const o="function"==typeof x?x(t):t[x];if(!e[o]){const t={[k]:[]};"string"==typeof x&&(t[x]=o),e[o]=t}return e[o][k].push(t),e},{});return Object.values(e)}return[{[k]:q}]},[q,x,k,ee]),oe=t.useMemo(()=>ee||x?te.flatMap(e=>{const t=e[k]||[];return x&&"string"==typeof x?t.map(t=>Object.assign(Object.assign({},t),{[x]:e[x]})):t}):q,[te,k,ee,x,q]),ne=Fi(q,w,A),ie=wr({lineWidth:S,colorBy:w,colorScale:ne,fillArea:O,areaOpacity:M}),re=t.useMemo(()=>{if(N.lineStyle)return N.lineStyle},[N.lineStyle]),se=wr({lineWidth:1,colorBy:w,colorScale:ne}),ae=null!=re?re:se,le=t.useMemo(()=>{if(C)return e=>{const t={r:_,fillOpacity:1};return t.fill=w?ke(e.parentLine||e,w,ne):Ni,t}},[C,_,w,ne]),{legend:ce,margin:ue,legendPosition:de}=Yi({data:te,colorBy:w,colorScale:ne,showLegend:T,legendPosition:R,userMargin:l}),he=N.height||60,ge=t.useMemo(()=>{var e,t,o,n,i,r,s,a;return{top:null!==(t=null===(e=N.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=N.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(r=null===(i=N.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ue.left,right:null!==(a=null===(s=N.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:ue.right}},[N.margin,ue]),fe=N.brushDirection||"x",pe=yr({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:b}});if(pe)return e.jsx(or,{componentName:"MinimapChart",message:pe,width:s,height:a});const ye=O?"area":"line",me=t.useMemo(()=>er([{label:g||Ui(m),accessor:m,role:"x",format:p},{label:f||Ui(b),accessor:b,role:"y",format:y}]),[m,b,g,f,p,y]),ve=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ye,data:oe,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ie},C&&{pointStyle:le}),{size:[s,a],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ue,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:P,showGrid:L}),ce&&{legend:ce,legendPosition:de}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),{tooltipContent:!1===B?()=>null:gn(B)||me}),U&&{xExtent:U}),H&&{yExtent:H}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),F),be=Object.assign({chartType:ye,data:oe,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ae,size:[s,he+ge.top+ge.bottom],margin:ge,showAxes:null!==(i=N.showAxes)&&void 0!==i&&i,background:N.background,enableHover:!1},H&&{yExtent:H}),xe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(Jn,Object.assign({ref:Q},be)),e.jsx(os,{width:s-ge.left-ge.right,height:he,margin:ge,scales:Z,brushDirection:fe,extent:U,onBrush:K})]},"minimap"),we=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(Jn,Object.assign({},ve))},"main");return Y||G||e.jsx(sr,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[E?xe:we,E?we:xe]})})}ts.displayName="ScatterplotMatrix",ns.displayName="MinimapChart";const is=t.forwardRef(function(o,n){const i=t.useRef(null);Ar(n,{variant:"xy",frameRef:i});const r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:b=12,colorBy:x,colorScheme:k,sizeBy:w,sizeRange:A=[3,15],pointRadius:j=5,pointOpacity:S=.8,tooltip:O,pointIdAccessor:M,annotations:C,frameProps:_={},selection:P,linkedHover:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:N,loading:E,loadingContent:D,emptyContent:I,legendInteraction:H,legendPosition:F,color:W,stroke:$,strokeWidth:z,opacity:Y}=o,{width:G,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,oe=t.useMemo(()=>v(s),[s]),ne=xr({data:oe,rawData:s,colorBy:x,colorScheme:k,legendInteraction:H,legendPosition:F,selection:P,linkedHover:L,fallbackFields:"string"==typeof x?[x]:[],unwrapData:!1,onObservation:T,onClick:R,hoverHighlight:B,chartType:"QuadrantChart",chartId:N,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:E,loadingContent:D,emptyContent:I,width:G,height:q});dr("QuadrantChart",oe,"xAccessor",d),dr("QuadrantChart",oe,"yAccessor",h);const ie=t.useMemo(()=>{if(!oe.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let o=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of oe){const a=e(s),l=t(s);isFinite(a)&&(o>a&&(o=a),a>n&&(n=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=g&&isFinite(g)&&(o>g&&(o=g),g>n&&(n=g)),null!=f&&isFinite(f)&&(i>f&&(i=f),f>r&&(r=f)),o===1/0)return;const s=.1*(n-o)||1,a=.1*(r-i)||1;return{xExtent:[o-s,n+s],yExtent:[i-a,r+a]}},[oe,d,h,g,f]),re=t.useMemo(()=>{if(!w||0===oe.length)return;const e=oe.map(e=>"function"==typeof w?w(e):e[w]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[oe,w]),se=t.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),ae=t.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),le=t.useMemo(()=>e=>{const t=se(e),o=ae(e),n=null!=g?t>=g:void 0,i=null!=f?o>=f:void 0;return void 0===i||void 0===n?W||Ni:i&&n?p.topRight.color:i&&!n?p.topLeft.color:!i&&n?p.bottomRight.color:p.bottomLeft.color},[se,ae,g,f,p,W]),ce=t.useMemo(()=>w?e=>Ae(e,w,A,re):void 0,[w,A,re]),ue=Fr({colorBy:x,colorScale:ne.colorScale,color:W,pointRadius:j,fillOpacity:S,radiusFn:ce,fallbackFill:le,stroke:$,strokeWidth:z,opacity:Y,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection}),de=t.useMemo(()=>{if(!oe.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof x&&e.add(x),"string"==typeof w&&e.add(w);const t=oe[0];for(const o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[oe,d,h,x,w]),he=t.useMemo(()=>er([...de?[{label:de,accessor:de,role:"title"}]:[],{label:ee||Ui(d),accessor:d,role:"x",format:c},{label:te||Ui(h),accessor:h,role:"y",format:u},...x?[{label:Ui(x),accessor:x,role:"color"}]:[],...w?[{label:Ui(w),accessor:w,role:"size"}]:[]]),[de,d,h,ee,te,x,w,c,u]),ge=yr({componentName:"QuadrantChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),fe=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,o,n,i)=>{var r;if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const s=i.width,a=i.height,l=null!=g?n.x(g):s/2,c=null!=f?n.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!==(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,f,p,y]),pe=t.useMemo(()=>m?[...fe,(e,t,o,n)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const i=n.width,r=n.height,s=null!=g?o.x(g):i/2,a=null!=f?o.y(f):r/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${b}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,i-8,8),e.fillStyle=p.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(p.bottomLeft.label,8,r-8),e.fillStyle=p.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(p.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:fe,[fe,m,b,p,g,f]),ye=t.useMemo(()=>{const e=_.canvasPreRenderers||[];return[...pe,...e]},[pe,_.canvasPreRenderers]),me=t.useMemo(()=>{var t;const o={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,n,i)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=i.width,s=i.height,a=null!=g?n.x(g):r/2,l=null!=f?n.y(f):s/2;if(null!=g&&!isFinite(a))return null;if(null!=f&&!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:p.topLeft,x:0,y:0,w:c,h:u},{config:p.topRight,x:c,y:0,w:r-c,h:u},{config:p.bottomLeft,x:0,y:u,w:c,h:s-u},{config:p.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,o)=>{var n;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!==(n=t.config.opacity)&&void 0!==n?n:.08},"qf-"+o):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),m&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+b,fill:p.topLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:p.topLeft.label}),e.jsx("text",{x:r-8,y:8+b,fill:p.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:p.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:p.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:p.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:p.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:p.bottomRight.label})]})]})}]},[g,f,p,y,m,b]),ve=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:oe}),{xAccessor:d,yAccessor:h,colorAccessor:x||void 0,sizeAccessor:w||void 0,sizeRange:A,pointStyle:ue,colorScheme:k,size:[G,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ie&&{xExtent:ie.xExtent,yExtent:ie.yExtent}),ne.legendBehaviorProps),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:!1===O?()=>null:!0===O||void 0===O?he:gn(O)||he}),(L||T||R||B)&&{customHoverBehavior:ne.customHoverBehavior}),(T||R||L)&&{customClickBehavior:ne.customClickBehavior}),M&&{pointIdAccessor:M}),C&&C.length>0&&{annotations:C}),{canvasPreRenderers:ye}),ne.crosshairProps),_),ye.length>0&&{canvasPreRenderers:ye}),{svgPreRenderers:me});return ne.earlyReturn?ne.earlyReturn:ge?e.jsx(or,{componentName:"QuadrantChart",message:ge,width:G,height:q}):e.jsx(sr,{componentName:"QuadrantChart",width:G,height:q,children:e.jsx(Jn,Object.assign({ref:i},ve))})});is.displayName="QuadrantChart";const rs="__ma_unitized",ss="__ma_series";function as(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function ls(e,t){return t[0]+e*(t[1]-t[0])}const cs=t.forwardRef(function(o,n){var i;const r=t.useRef(null),s=t.useRef([]),a=t.useRef(o.series);a.current=o.series,t.useImperativeHandle(n,()=>{const e=()=>{var e;return(null!==(e=a.current)&&void 0!==e?e:[]).filter(e=>null!=e&&"object"==typeof e)};return{push:t=>{if(!r.current)return;const o=e(),n=t;for(let e=0;o.length>e&&2>e;e++){const t=o[e],i=t.extent||s.current[e];if(!i)continue;const a=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(n);null!=a&&isFinite(a)&&r.current.push(Object.assign(Object.assign({},n),{[rs]:as(a,i),[ss]:t.label||"Series "+(e+1)}))}},pushMany:t=>{if(!r.current)return;const o=e(),n=[];for(const e of t)for(let t=0;o.length>t&&2>t;t++){const i=o[t],r=i.extent||s.current[t];if(!r)continue;const a=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(e);null!=a&&isFinite(a)&&n.push(Object.assign(Object.assign({},e),{[rs]:as(a,r),[ss]:i.label||"Series "+(t+1)}))}r.current.pushMany(n)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},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 l=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,accessibleTable:o.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:g="x",series:f,colorScheme:y,curve:m="monotoneX",lineWidth:b=2,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,legendPosition:R,stroke:B,strokeWidth:N,opacity:E}=o,{width:D,height:I,enableHover:H,showGrid:F,showLegend:W=!0,title:$,description:z,summary:Y,accessibleTable:G,xLabel:q}=l,X=t.useMemo(()=>v(c),[c]),V=t.useMemo(()=>v(f),[f]),U=V,K=2===V.length;"undefined"==typeof process||"production"===(null===(i=process.env)||void 0===i?void 0:i.NODE_ENV)||K||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${V.length}. Rendering as a standard multi-line chart.`);const Q=ur(_,D,I,P),Z=Q?null:cr(c,D,I,L),J=Ii(),ee=t.useMemo(()=>{let e;if(Array.isArray(y))e=y;else if(J&&J.length>0)e=J;else{const t=ye[y];e=Array.isArray(t)?t:me}return U.map((t,o)=>t.color||e[o%e.length])},[U,y,J]),te=t.useMemo(()=>V.map((e,t)=>e.label||"Series "+(t+1)),[V]),{unitizedData:oe,extents:ne}=t.useMemo(()=>{if(0===X.length){const e=V.map(e=>e.extent||null).filter(Boolean);return e.length===V.length&&(s.current=e),{unitizedData:[],extents:e.length===V.length?e:[]}}const e=V.map(e=>e.extent||function(e,t){let o=1/0,n=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>n&&(n=e))}if(!isFinite(o)||!isFinite(n))return[0,1];if(o===n){const e=0===o?1:.1*Math.abs(o);return[o-e,n+e]}return[o,n]}(X,e.yAccessor));if(s.current=e,!K){const t=[];for(const e of X)for(let o=0;V.length>o;o++){const n=V[o],i=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[rs]:i,[ss]:te[o]}))}return{unitizedData:t,extents:e}}const t=[];for(const o of X)for(let n=0;2>n;n++){const i=V[n],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(o);null!=r&&t.push(Object.assign(Object.assign({},o),{[rs]:as(r,e[n]),[ss]:te[n]}))}return{unitizedData:t,extents:e}},[X,V,K,te]),ie=t.useMemo(()=>{if(K&&ne.length>=2)return[{orient:"left",label:te[0],tickFormat:V[0].format||(e=>{const t=ls(e,ne[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:te[1],tickFormat:V[1].format||(e=>{const t=ls(e,ne[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[K,ne,V,te]),re=xr({data:t.useMemo(()=>oe.length>0?oe:te.map(e=>({[ss]:e})),[oe,te]),rawData:c,colorBy:ss,colorScheme:ee,legendInteraction:T,legendPosition:R,selection:A,linkedHover:j,fallbackFields:[ss],unwrapData:!1,onObservation:S,onClick:O,hoverHighlight:M,chartType:"MultiAxisLineChart",chartId:C,showLegend:W,userMargin:u,marginDefaults:K?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:_,loadingContent:P,emptyContent:L,width:D,height:I});if(re.earlyReturn)return re.earlyReturn;const se=t.useMemo(()=>{const e=new Map;return te.forEach((t,o)=>e.set(t,ee[o])),e},[te,ee]),ae=wr({lineWidth:b,resolveStroke:t.useCallback(e=>se.get(e[ss])||ee[0],[se,ee]),stroke:B,strokeWidth:N,opacity:E,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection}),le=t.useMemo(()=>{if(!1===x)return()=>null;return gn(x)||(e=>{var t;const o=e.data||e,n=o[ss],i=te.indexOf(n),r=o[rs],s=K&&i>=0&&ne[i]?ls(r,ne[i]):r,a=i>=0&&(null===(t=V[i])||void 0===t?void 0:t.format)?V[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(o):o[g];return p.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},p.createElement("div",{style:{fontWeight:600,marginBottom:4,color:ee[i]||"inherit"}},n),p.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),p.createElement("div",null,`${n}: ${a(s)}`))})},[x,te,ee,ne,K,V,g]),ce=yr({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:g}}),ue=K?[0,1]:void 0,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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=c&&{data:oe}),{xAccessor:g,yAccessor:rs,groupAccessor:ss,lineStyle:ae,colorScheme:ee,size:[D,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:re.margin,showAxes:l.showAxes}),ie&&{axes:ie}),{xLabel:q}),K?{}:{yLabel:te[0]}),{xFormat:h}),K&&ue&&{yExtent:ue}),{enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:F,curve:m}),re.legendBehaviorProps),$&&{title:$}),z&&{description:z}),Y&&{summary:Y}),void 0!==G&&{accessibleTable:G}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:le}),k&&{annotations:k}),(j||S||O||M)&&{customHoverBehavior:re.customHoverBehavior}),(S||O||j)&&{customClickBehavior:re.customClickBehavior}),re.crosshairProps),w);return Q||Z||(ce?e.jsx(or,{componentName:"MultiAxisLineChart",message:ce,width:D,height:I}):e.jsx(sr,{componentName:"MultiAxisLineChart",width:D,height:I,children:e.jsx(Jn,Object.assign({ref:r},de))}))});cs.displayName="MultiAxisLineChart";const us=t.forwardRef(function(o,n){const i=t.useRef(null);Ar(n,{variant:"xy",frameRef:i});const r=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:g="low",openAccessor:f,closeAccessor:p,candlestickStyle:y,tooltip:m,annotations:b,xExtent:x,yExtent:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:O,chartId:M,loading:C,loadingContent:_,emptyContent:P}=o,{width:L,height:T,enableHover:R,showGrid:B,title:N,description:E,summary:D,accessibleTable:I,xLabel:H,yLabel:F}=r,W=ur(C,L,T,_),$=W?null:cr(s,L,T,P),z=t.useMemo(()=>v(s),[s]),Y=null==f||null==p;dr("CandlestickChart",z,"xAccessor",d),dr("CandlestickChart",z,"highAccessor",h),dr("CandlestickChart",z,"lowAccessor",g),Y||(dr("CandlestickChart",z,"openAccessor",f),dr("CandlestickChart",z,"closeAccessor",p));const{customHoverBehavior:G,customClickBehavior:q,crosshairSourceId:X}=$i({selection:A,linkedHover:j,onObservation:S,onClick:O,chartType:"CandlestickChart",chartId:M}),V=zi(j,X),U=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===o.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,o.mode]),K=t.useMemo(()=>{const e=[{label:H||Ui(d),accessor:d,role:"x",format:c}];return Y?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:g,format:u})):(e.push({label:"Open",accessor:f,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:g,format:u}),e.push({label:"Close",accessor:p,format:u})),er(e)},[d,H,c,u,h,g,f,p,Y]),Q=yr({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:g},!Y&&{openAccessor:f,closeAccessor:p})}),Z=Math.max(2,Math.min(12,Math.round(L/40))),J=L>200?.1:.02,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({chartType:"candlestick"},null!=s&&{data:z}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:g}),!Y&&{openAccessor:f,closeAccessor:p}),y&&{candlestickStyle:y}),{scalePadding:Z,extentPadding:J,size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U,showAxes:r.showAxes,xLabel:H,yLabel:F,xFormat:c,yFormat:u,enableHover:R,showGrid:B}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),Tr({title:N,description:E,summary:D,accessibleTable:I,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:K})),Rr({linkedHover:j,onObservation:S,onClick:O,customHoverBehavior:G,customClickBehavior:q})),b&&b.length>0&&{annotations:b}),x&&{xExtent:x}),k&&{yExtent:k}),V),w);return W||$||(Q?e.jsx(or,{componentName:"CandlestickChart",message:Q,width:L,height:T}):e.jsx(sr,{componentName:"CandlestickChart",width:L,height:T,children:e.jsx(Jn,Object.assign({ref:i},ee))}))});function ds(e,t){var o;const{columns:n,config:i,resolvePieceStyle:r}=e,s=[],a=Math.min(t.width,t.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle&&Object.keys(n).length>1&&(null!==(o=i.cornerRadius)&&void 0!==o?o:0)>0,h=Object.values(n);for(let e=0;h.length>e;e++){const t=h[e],o=c+t.pctStart*u,n=c+(t.pctStart+t.pct)*u,g=r(t.pieceData[0],t.name),f=0===e,p=e===h.length-1,y=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:o,endAngle:n},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:g,datum:t.pieceData,category:t.name});d&&(y.roundedEnds={start:f,end:p}),s.push(y)}return s}function hs(e){var t,o,n;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=a.quantile(e,.5))&&void 0!==o?o:(r+s)/2,q3:null!==(n=a.quantile(e,.75))&&void 0!==n?n:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}function gs(e,t,o){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=ye[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:o}function fs(e){return 0===e.length?()=>"#4e79a7":t=>{var o;let n=0;for(let e=0;t.length>e;e++)n=31*n+t.charCodeAt(e)|0;return null!==(o=e[Math.abs(n)%e.length])&&void 0!==o?o:"#4e79a7"}}us.displayName="CandlestickChart";const ps={bar:function(e,t){var o,n,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p="horizontal"===h,y=a.normalize,m=[];if(c){const e=new Set;for(const t of Object.values(s))for(const o of t.pieceData){const t=c(o);e.has(t)||(e.add(t),m.push(t))}}else m.push("_default");for(const e of Object.values(s)){const t=new Map;for(const o of e.pieceData){const e=c?c(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=l(o),n.pieces.push(o)}let o=0;if(y)for(const e of t.values())o+=Math.abs(e.total);let n=0,i=0;for(const r of m){const s=t.get(r);if(!s)continue;let a=s.total;y&&o>0&&(a/=o);const l=u(s.pieces[0],c?r:e.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:e.name});if(f){const t=d(0>a?i:n+a),o=0>a?d(i+a)-d(i):d(n)-d(n+a);g.push(W(e.x,t,e.width,Math.abs(o),l,h,r)),0>a?i+=a:n+=a}else if(p){const t=d(0>a?i+a:n),o=0>a?d(i)-d(i+a):d(n+a)-d(n);g.push(W(t,e.x,Math.abs(o),e.width,l,h,r)),0>a?i+=a:n+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const e of g){if("rect"!==e.type)continue;const t=null!==(n=null===(o=e.datum)||void 0===o?void 0:o.__aggregateValue)&&void 0!==n?n:0;e.roundedEdge=v?0>t?"bottom":"top":0>t?"left":"right",a.gradientFill&&(e.fillGradient=a.gradientFill)}if(b>0){const e=new Map;for(const t of g){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>{var t,o;return(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)>=0}),o=t.filter(e=>{var t,o;return 0>(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)});e.length>0&&(e.reduce(v?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=b),o.length>0&&(o.reduce(v?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=b)}}return g},clusterbar:function(e,t){const{scales:o,columns:n,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h=[],g=new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";g.has(e)||(g.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,o=.2*t,n=t-o,i=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";i.has(e)||i.set(e,[]),i.get(e).push(t)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),g=a(i,h[s]);if(d){const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(W(r,Math.min(a,d),n,Math.abs(a-d),g,i,h[s]))}else{const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push(W(Math.min(a,d),r,Math.abs(d-a),n,g,i,h[s]))}}}}const p=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);p>0&&(e.roundedTop=p),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",i.gradientFill&&(e.fillGradient=i.gradientFill)}return u},point:function(e,t){var o,n;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=i,d=[],h="vertical"===u,g="radial"===u,f=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(o=t.__rIndex)&&void 0!==o?o:0,r=null!==(n=t.__rValue)&&void 0!==n?n:s(t),u=f&&a[i]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,o=u(r);b=Math.cos(t)*o,x=Math.sin(t)*o}else h?(b=e.middle,x=u(r)):(b=u(r),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:o,columns:n,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="vertical"===a;for(const e of Object.values(n)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const n=e.pieceData[o],a=i(n),u=r(n,e.name),d=u.r||4,h=(7919*o%100/100-.5)*t*.8,g=c?e.middle+h:s(a),f=c?s(a):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:n})}}return l},pie:ds,donut:ds,boxplot:function(e,t){var o,n,i,r,s,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:g}=e,{r:f,projection:p}=c,y=[],m="vertical"===p,v=!1!==d.showOutliers;for(const t of Object.values(u)){const c=t.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===c.length)continue;const u=c[0],d=c[c.length-1],p=null!==(o=a.quantile(c,.25))&&void 0!==o?o:u,b=null!==(n=a.quantile(c,.5))&&void 0!==n?n:(u+d)/2,x=null!==(i=a.quantile(c,.75))&&void 0!==i?i:d,k=x-p,w=p-1.5*k,A=x+1.5*k,j=null!==(r=c.find(e=>e>=w))&&void 0!==r?r:u,S=null!==(s=[...c].reverse().find(e=>A>=e))&&void 0!==s?s:d,O=g(t.pieceData[0],t.name),M=[];if(v)for(const e of t.pieceData){const o=h(e);if(w>o||o>A){const n=m?t.middle:f(o),i=m?f(o):t.middle;M.push({px:n,py:i,value:o,datum:e})}}if(y.push({type:"boxplot",x:m?t.middle:0,y:m?0:t.middle,projection:m?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(j),q1Pos:f(p),medianPos:f(b),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:j,q1:p,median:b,q3:x,max:S,mean:c.reduce((e,t)=>e+t,0)/c.length},style:O,datum:t.pieceData,category:t.name,outliers:M}),v)for(const t of M)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:O.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:t.datum})}return y},violin:function(e,t){var o,n,i;const{scales:r,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],l=(s-r)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-r)/l),p-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(r)}`;for(let t=0;p>t;t++){const o=d(r+(t+.5)*l);b+=` L ${e.middle+h[t]/m*v} ${o}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const o=d(r+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${o}`}b+=" Z"}else{b=`M ${d(r)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(r+(t+.5)*l)} ${e.middle-h[t]/m*v}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(r+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=a.quantile(t,.25))&&void 0!==o?o:r,c=null!==(n=a.quantile(t,.5))&&void 0!==n?n:(r+s)/2,u=null!==(i=a.quantile(t,.75))&&void 0!==i?i:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(r)),width:e.width,height:Math.abs(d(s)-d(r))}:{x:Math.min(d(r),d(s)),y:e.x,width:Math.abs(d(s)-d(r)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:hs(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l}=n,c=[],u=r.bins||25,d=r.normalize,h=null===(o=l.domain)||void 0===o?void 0:o.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const o=null!=g&&isFinite(g)?g:Math.min(...t),n=null!=f&&isFinite(f)?f:Math.max(...t),i=(n-o)/u||1,r=Array(u).fill(0);for(const e of t)o>e||e>n||r[Math.min(Math.floor((e-o)/i),u-1)]++;const h=t.length,p=Math.max(...r,1),y=a(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===r[t])continue;const n=(d?r[t]/h:r[t]/p)*e.width*.9,s=l(o+t*i),a=l(o+(t+1)*i);c.push(W(Math.min(s,a),e.x+e.width-n,Math.abs(a-s),n,y,{bin:t,count:r[t],range:[o+t*i,o+(t+1)*i],category:e.name},e.name))}}return c},ridgeline:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=n,u=[],d=r.bins||20,h="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(n)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(n+(e+.5)*r)} ${t-c[e]/f*y}`;m+=` L ${l(i)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(n)}`;for(let e=0;d>e;e++){const o=l(n+(e+.5)*r);m+=` L ${t+c[e]/f*y} ${o}`}m+=` L ${t} ${l(i)} Z`}const v=h?{x:Math.min(l(n),l(i)),y:e.x,width:Math.abs(l(i)-l(n)),height:e.width}:{x:e.x,y:Math.min(l(i),l(n)),width:e.width,height:Math.abs(l(i)-l(n))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:hs(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(o=p.fillOpacity)&&void 0!==o?o:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:o,columns:n,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const o=i(t);if(!o)continue;const[n,a]=o,u=r(t,e.name);if(c){const o=s(Math.min(n,a)),i=s(Math.max(n,a));l.push(W(o,e.x,i-o,e.width,u,t,e.name))}else{const o=s(Math.max(n,a)),i=s(Math.min(n,a));l.push(W(e.x,o,e.width,i-o,u,t,e.name))}}return l},funnel:function(e,t){var o,n,r,s,a,l,c,u;const{columns:d,getR:h,getStack:g,resolvePieceStyle:f}=e,p=[],y=t.width/2,m=!1!==e.config.showLabels,v=e.scales.o.domain().map(e=>d[e]).filter(Boolean);if(0===v.length)return p;const b=[],x=new Set;for(const e of v)for(const t of e.pieceData){const e=g?g(t):"_default";x.has(e)||(x.add(e),b.push(e))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const e of v){const t=new Map;let o=0;for(const n of e.pieceData){const e=g?g(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=h(n);i.total+=r,i.pieces.push(n),o+=r}w.push({col:e,groups:t,stepTotal:o}),k||o>A&&(A=o)}if(k)for(const e of w){let t=0,o=0;for(let n=0;b.length>n;n++){const i=e.groups.get(b[n]);i&&(n%2==0?t+=i.total:o+=i.total)}const n=Math.max(t,o);n>A&&(A=n)}if(0===A)return p;const j=new Map;for(const e of b){const t=w[0].groups.get(e);j.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const S=w[0].stepTotal,O=k?.95*y:.9*t.width,M=i.scaleLinear().domain([0,A]).range([0,O]),C=null!==(n=e.config.connectorOpacity)&&void 0!==n?n:.3;let _=new Map;for(let t=0;w.length>t;t++){const o=w[t],n=o.col,i=0===t,d=n.width,h=.55*d,g=n.x+(d-h)/2,v=new Map;if(k){let e=0;for(const t of b){const n=o.groups.get(t);n&&(e+=M(n.total))}let t=y,r=y;for(let s=0;b.length>s;s++){const l=b[s],c=o.groups.get(l);if(!c)continue;const u=M(c.total),d=s%2==0,x=d?t:r-u;d?t+=u:r-=u;const k=f(c.pieces[0],l),w=null!==(a=j.get(l))&&void 0!==a?a:c.total,A=w>0?c.total/w*100:0,S=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:n.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=g,S.__funnelRowWidth=e),S.__funnelValueLabelX=x+u/2,S.__funnelValueLabelY=g,S.__funnelBarW=u),p.push(W(x,g,u,h,k,S,l)),v.set(l,{x:x,y:g,w:u,h:h})}}else{const e=o.stepTotal,t=M(e),a=y-t/2,l=b[0],c="_default"!==l,u=null!==(s=null===(r=o.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:n.pieceData[0],d=c?l:n.name,x=f(u,d),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:i,category:c?l:n.name});m&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=g,w.__funnelRowWidth=t,w.__funnelValueLabelX=y,w.__funnelValueLabelY=g,w.__funnelBarW=t),p.push(W(a,g,t,h,x,w,d)),v.set(l,{x:a,y:g,w:t,h:h})}if(t>0&&_.size>0){const t=k?b:[b[0]];for(const i of t){const t=_.get(i),r=v.get(i);if(!t||!r)continue;const s=(()=>{const e=o.groups.get(i);return f(e?e.pieces[0]:n.pieceData[0],"_default"===i?n.name:i)})(),a={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:C},datum:null!==(u=null===(c=o.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:n.pieceData[0],category:"_default"===i?n.name:i};p.push(a)}}_=v}return p},"bar-funnel":function(e,t){var o,n,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>s[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let o=0;for(const n of e.pieceData){const e=l?l(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=a(n);i.total+=r,i.pieces.push(n),o+=r}y.push({col:e,groups:t,stepTotal:o})}const m=new Map;for(const e of g){const t=null===(o=y[0])||void 0===o?void 0:o.groups.get(e);m.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const v=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],o=t.col,n=0===e,s=e>0?y[e-1]:null,a=o.width/b,l=a*x,u=a-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(i=m.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,A=n?0:Math.max(0,w-y),j=o.x+e*a+l/2,S=v(y),O=v(0)-S,M=c(f.pieces[0],p?h:o.name),C=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name,__barFunnelLabelX:j+u/2,__barFunnelLabelY:v(y+A)});if(d.push(W(j,S,u,O,M,C,p?h:o.name)),A>0){const e=v(y+A),t=S-e,n=Object.assign({},M),i=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name});d.push(W(j,e,u,t,n,i,p?h:o.name))}}}return d},swimlane:function(e,t){var o;const{scales:n,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],d="horizontal"===c,h=e.config.gradientFill,g=d?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:null!==(o=f.opacity)&&void 0!==o?o:1,[n,r]=l.range(),s=Math.min(n,r),a=Math.abs(r-n);for(const o of Object.values(i)){const n={fill:e,opacity:t},i=d?W(s,o.x,a,o.width,n,null,"__track__"):W(o.x,s,o.width,a,n,null,"__track__");u.push(i)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=u.length;for(const o of e.pieceData){const n=Math.abs(r(o));if(0===n)continue;const i=s?s(o):e.name,c=a(o,i);let f;if(d){const r=l(t),s=l(t+n);f=W(r,e.x,s-r,e.width,c,o,i)}else{const r=l(t+n),s=l(t);f=W(e.x,r,e.width,s-r,c,o,i)}h&&(f.fillGradient=h,f.roundedEdge=g),u.push(f),t+=n}if(p>0&&u.length>o){const e=u.slice(o),t=e[0],n=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(t.cornerRadii={tl:p,bl:p},n.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},n.cornerRadii={tl:p,tr:p})}}return u}};class ys{constructor(e){this.rExtent=new N,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new B(e.windowSize),this.getO=q(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>Y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new N)):(this.getR=Y(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=q(e.stackBy),this.getGroup=q(e.groupBy),this.getColor=q(e.colorAccessor),this.getConnector=q(e.connectorAccessor),this.getDataId=q(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new B(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=o.toArray(),r=t.projection||"vertical",s=t.oExtent||this.resolveCategories(n),a=this.computeValueDomain(n,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1));let d,h;if(c){d=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,n=t.innerRadius||0;h=i.scaleLinear().domain(a).range([n,o])}else l?(d=i.scaleBand().domain(s).range([0,e.height]).padding(u),h=i.scaleLinear().domain(a).range([0,e.width])):(d=i.scaleBand().domain(s).range([0,e.width]).padding(u),h=i.scaleLinear().domain(a).range([e.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(o,n);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=t.extentPadding)&&void 0!==s?s:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?i.scaleLinear().domain([c,u]).range([0,e.width]):i.scaleLinear().domain([c,u]).range([e.height,0])}):[];let g=n;this.rAccessors.length>1&&(g=n.flatMap(e=>this.rAccessors.map((t,o)=>Object.assign(Object.assign({},e),{__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(g,s,d,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,e),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let i=null;if(o){i=new Set;for(const t of e)i.add(this.getO(t))}const r=i?Array.from(this.categories).filter(e=>i.has(e)):Array.from(this.categories);if(o&&void 0===n){const e=Math.max(50,3*i.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===n?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){var o,n,i,r,s;const a=this.config.chartType,l=null!==(o=this.config.extentPadding)&&void 0!==o?o:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const t=new Map,o=new Map;for(const n of e){const e=this.getO(n),i=this.getR(n);0>i?o.set(e,(o.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>u&&(u=e);for(const e of o.values())c>e&&(c=e)}else if("bar"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=this.getR(o);t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e),c>e&&(c=e)}else if("swimlane"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=Math.abs(this.getR(o));t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===a||"bar-funnel"===a)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const e=u-c,t=e>0?e*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=t)}return[c,u]}buildColumns(e,t,o,n,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===n)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==n){u=new Map;let e=0;for(const o of t){const t=a.get(o)||[];let n;n="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(o,n),e+=n}const r=("horizontal"===n?i.height:i.width)-o.padding()*o.step()*t.length;if(e>0)for(const[t,o]of u)u.set(t,o/e*r)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?n/l:0;let c,g;u?(c=h,g=u.get(e)||o.bandwidth(),h+=g+o.padding()*o.step()):(c=null!==(r=o(e))&&void 0!==r?r:0,g=o.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:o.padding()*o.step(),pieceData:t,pct:i,pctStart:d},d+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){var o,n;if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(e,t);let r;try{r=this.config.customLayout(i)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(o=r.overlays)&&void 0!==o?o:null,null!==(n=r.nodes)&&void 0!==n?n:[]}this.customLayoutOverlays=null;const i=this.getSceneContext(),r=ps[this.config.chartType];let s=r?r(i,t):[];if(this.getConnector&&this.scales){const e=function(e,t){var o,n;const{scales:i,config:r,getConnector:s,getO:a}=e;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let n,i;"point"===e.type?(n=e.x,i=e.y):(n=e.x+e.w/2,i=e.y+("vertical"===c?0:e.h/2)),u.has(o)||u.set(o,[]),u.get(o).push({x:n,y:i,datum:t,category:a(t)})}const d=i.o.domain(),h=r.connectorStyle;for(const[t,i]of u)if(i.length>=2){i.sort((e,t)=>d.indexOf(e.category)-d.indexOf(t.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.border)||(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:t})}}return l}(i,s);s=[...e,...s]}return s}buildLayoutContext(e,t){var o,n,i;const r=this.config,s=null!==(o=r.layoutMargin)&&void 0!==o?o:{top:0,right:0,bottom:0,left:0},a=gs(r.colorScheme,r.themeCategorical,ve),l=this.scales;return{data:e,scales:{o:l.o,r:l.r,projection:l.projection},dimensions:{width:t.width,height:t.height,margin:s,plot:"radial"===l.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(n=r.themeSemantic)&&void 0!==n?n:{},categorical:[...a]},resolveColor:fs(a),config:null!==(i=r.layoutConfig)&&void 0!==i?i:{}}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const o=this.config.pieceStyle(e,t);return o&&!o.fill&&t?Object.assign(Object.assign({},o),{fill:this.getColorFromScheme(t)}):o}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,n=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,n),n}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?je(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=new Map;for(let o=0;e.length>o;o++)t.set(e[o],o);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=this.config.categoryAccessor||this.config.oAccessor,o="function"==typeof t,n=o?null:t||"category",i=new Map;for(let r=0;e.length>r;r++){const s=e[r],a=o?t(s):s[n];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let e=0,t=0;for(const o of this.scene)"point"===o.type&&(e++,o.r>t&&(t=o.r));if(this._maxPointRadius=t,ys.QUADTREE_THRESHOLD>=e)return void(this._pointQuadtree=null);const o=Array(e);let n=0;for(const e of this.scene)"point"===e.type&&(o[n++]=e);this._pointQuadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){var o,n;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var o,n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=this.config.pulse.duration)&&void 0!==o?o:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(t);let u=null;for(const o of e){if("connector"===o.type||"violin"===o.type||"boxplot"===o.type)continue;if("wedge"===o.type){const e=o.category;if(!e)continue;u||(u=this.getCategoryIndexMap(t));const n=u.get(e);if(!n)continue;let i=0;for(let e=0;n.length>e;e++){const t=this.timestampBuffer.get(n[e]);if(null==t)continue;const o=r-t;if(s>o){const e=1-o/s;e>i&&(i=e)}}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const e=c.get(o.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const i=r-n;s>i&&(o._pulseIntensity=1-i/s,o._pulseColor=a,o._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}synthesizeIntroPositions(){var e,t,o,n,i;this.prevPositionMap.clear();const r=new Map,s=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.r(0))&&void 0!==t?t:0,a="horizontal"!==(null===(o=this.scales)||void 0===o?void 0:o.projection);let l;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],o=this.getNodeKey(t,r);o&&("rect"===t.type?this.prevPositionMap.set(o,a?{x:t.x,y:s,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}:{x:s,y:t.y,w:0,h:t.h,opacity:null!==(i=t.style.opacity)&&void 0!==i?i:1}):"point"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,r:0,opacity:0}):"wedge"===t.type&&(void 0===l&&(l=t.startAngle),this.prevPositionMap.set(o,{x:t.cx,y:t.cy,startAngle:l,endAngle:l,innerRadius:t.innerRadius,outerRadius:t.outerRadius,opacity:0})))}}getNodeKey(e,t){var o,n,i;if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(o)||0;return t.set(o,n+1),`${o}:${n}`}return"rect"===e.type?`r:${e.group||""}:${null!==(n=null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==n?n:""}`:"wedge"===e.type?"w:"+(null!==(i=e.category)&&void 0!==i?i:""):null}snapshotPositions(){var e;this.prevPositionMap.clear();const t=new Map;for(let o=0;this.scene.length>o;o++){const n=this.scene[o],i=this.getNodeKey(n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:null!==(e=n.style.opacity)&&void 0!==e?e:1}))}}startTransition(){var e,t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let w=!1;const A=new Set,j=new Map;for(let e=0;this.scene.length>e;e++){const c=this.scene[e],u=this.getNodeKey(c,j);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(t=c.style.opacity)&&void 0!==t?t:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const e=c.startAngle;c.startAngle=e,c.endAngle=e,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:e,endAngle:e,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)if(!A.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(c=t.r)&&void 0!==c?c:3,style:{opacity:null!==(u=t.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(d=t.w)&&void 0!==d?d:0,h:null!==(h=t.h)&&void 0!==h?h:0,style:{opacity:null!==(g=t.opacity)&&void 0!==g?g:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const o=((null!==(f=t.startAngle)&&void 0!==f?f:0)+(null!==(p=t.endAngle)&&void 0!==p?p:0))/2,n={type:"wedge",cx:t.x,cy:t.y,innerRadius:null!==(y=t.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(m=t.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=t.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=t.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=t.opacity)&&void 0!==x?x:1},datum:null,category:e.slice(2),_targetStartAngle:o,_targetEndAngle:o,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:_e(),duration:k})}advanceTransition(e){var t,o,n,i;if(!this.activeTransition)return!1;const r=Me(e,this.activeTransition),s=Oe(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=Ce(i,e._targetOpacity,s)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=Ce(n.x,e._targetX,s),e.y=Ce(n.y,e._targetY,s)),void 0!==e._targetR&&void 0!==(null==n?void 0:n.r)&&(e.r=Ce(n.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=Ce(i,e._targetOpacity,s)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Ce(o.x,e._targetX,s),e.y=Ce(o.y,e._targetY,s),void 0!==o.w&&(e.w=Ce(o.w,e._targetW,s),e.h=Ce(o.h,e._targetH,s))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),n=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Ce(n,e._targetOpacity,s)})}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Ce(o.startAngle,e._targetStartAngle,s),e.endAngle=Ce(o.endAngle,e._targetEndAngle,s))}}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,i}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),i.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){const t=Object.assign({},this.config);if(("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!z(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!z(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!z(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),("categoryAccessor"in e||"oAccessor"in e)&&(z(e.categoryAccessor||e.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=q(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in e||"rAccessor"in e){const o=e.valueAccessor||e.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(o)?o:[o],r=Array.isArray(n)?n:[n];if(i.length!==r.length||i.some((e,t)=>!z(e,r[t]))){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>Y(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new N)):(this.getR=Y(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!z(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?q(this.config.stackBy):void 0),"groupBy"in e&&!z(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?q(this.config.groupBy):void 0),"colorAccessor"in e&&!z(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!z(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?q(this.config.connectorAccessor):void 0)}}function ms(e,t,o){const n=qe(t,o,e);return n.hit?{datum:e.datum,x:n.cx,y:e.y,distance:0,category:e.group}:null}function vs(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function bs(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;const s=Ke(Math.atan2(i,n)),a=Ke(e.startAngle),l=Ke(e.endAngle);if(!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function xs(e,t,o){const n=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-n>t||t>e.x+n||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const i=e.y-n,r=e.y+n;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>o||o>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function ks(e,t,o){if(!e.bounds)return null;const{x:n,y:i,width:r,height:s}=e.bounds;return n>t||t>n+r||i>o||o>i+s?null:{datum:e.datum,x:n+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}function ws(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,showGrid:u,rFormat:d}=o,{rTickValues:h,axisExtent:g}=o,f="radial"===(null==l?void 0:l.projection),p="horizontal"===(null==l?void 0:l.projection),y=t.useMemo(()=>!l||f?[]:(h||ho(l.r,5,g)).map(e=>({value:e,pixel:l.r(e),label:(d||As)(e)})),[l,d,f,h,g]),m=u&&l&&!f,v=c&&l&&!f;return m||v?e.jsx("svg",{width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m&&e.jsx("g",{className:"ordinal-grid",children:y.map((t,o)=>e.jsx("line",{x1:p?t.pixel:0,y1:p?0:t.pixel,x2:p?t.pixel:n,y2:p?i:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),v&&e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,p?{children:[e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function As(e){return Math.round(100*e)/100+""}function js(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,showCategoryTicks:h,oLabel:g,rLabel:f,oFormat:p,rFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:j="right",foregroundGraphics:S,annotations:O,svgAnnotationRules:M,xAccessor:C,yAccessor:_,annotationData:P,underlayRendered:L,children:T}=o,R="radial"===(null==u?void 0:u.projection),B="horizontal"===(null==u?void 0:u.projection),N=!1!==h,E=t.useMemo(()=>d&&N&&u&&!R?u.o.domain().map((e,t)=>{var o;return{value:e,pixel:(null!==(o=u.o(e))&&void 0!==o?o:0)+u.o.bandwidth()/2,label:p?p(e,t):e}}):[],[d,N,u,p,R]),D=o.rTickValues,I=o.tickLabelEdgeAlign,H=o.axisExtent,F=t.useMemo(()=>d&&u&&!R?(D||ho(u.r,5,H)).map(e=>({value:e,pixel:u.r(e),label:(y||As)(e)})):[],[d,u,y,R,D,H]),W=t.useRef(new Map),$=t.useRef(null!==(n=null==O?void 0:O.length)&&void 0!==n?n:0),z=null!==(i=null==O?void 0:O.length)&&void 0!==i?i:0;$.current!==z&&($.current=z,W.current=new Map);const Y=t.useMemo(()=>{if(!O||0===O.length)return null;const e=eo(),t="horizontal"===(null==u?void 0:u.projection),o=(null==u?void 0:u.o)?e=>{var t;return(null!==(t=u.o(e))&&void 0!==t?t:0)+u.o.bandwidth()/2}:null,n={scales:u?{x:t?u.r:o||u.r,y:t&&o||u.r,time:u.r,value:u.r,o:u.o}:null,timeAxis:"x",xAccessor:C,yAccessor:_,width:r,height:s,data:P,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return O.map((t,o)=>{if(M){const i=M(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[O,M,r,s,u,C,_,P]);return d||v||b||S||Y&&Y.length>0||m||T?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof v?v:"Ordinal Chart"}),e.jsx("desc",{children:"string"==typeof v?v+" — ordinal data visualization":"Ordinal data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[m&&u&&!R&&!L&&e.jsx("g",{className:"ordinal-grid",children:F.map((t,o)=>e.jsx("line",{x1:B?t.pixel:0,y1:B?0:t.pixel,x2:B?t.pixel:r,y2:B?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),d&&u&&!R&&(()=>{const t={fontSize:"var(--semiotic-tick-font-size, 10px)"},o={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return e.jsx("g",{className:"ordinal-axes",children:e.jsxs(e.Fragment,B?{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),E.map((o,n)=>e.jsxs("g",{transform:`translate(0,${o.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof o.label||"number"==typeof o.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},t),children:o.label})})]},"cat-"+n)),g&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!L&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!L&&(null==u?void 0:u.r)&&(()=>{const t=u.r(0);return t>1&&r-1>t?e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),F.map((o,n)=>{const i=I?0===n?"start":n===F.length-1?"end":"middle":"middle";return e.jsxs("g",{transform:`translate(${o.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{y:18,textAnchor:i,fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label})]},"val-"+n)}),f&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:f})]})]}:{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!L&&(()=>{const t=(null==u?void 0:u.r)?u.r(0):s,o=0>t||t>s?s:t;return e.jsx("line",{x1:0,y1:o,x2:r,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),E.map((o,n)=>e.jsxs("g",{transform:`translate(${o.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof o.label||"number"==typeof o.label?e.jsx("text",{y:18,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"center",userSelect:"none"},t),children:o.label})})]},"cat-"+n)),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!L&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),F.map((o,n)=>e.jsxs("g",{transform:`translate(0,${o.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label})]},"val-"+n)),f&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:f})]})]})})})(),Y,S,T]}),v&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof v?v:null}),Ht({legend:b,totalWidth:a,totalHeight:l,margin:c,legendPosition:j,title:v,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})]}):null}function Ss({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,scales:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(u);g.current=u;const f=t.useRef(c);f.current=c;const p=t.useRef(!1),y=t.useRef(null),m="horizontal"===(null==c?void 0:c.projection),v=t.useRef(m);return v.current=m,t.useEffect(()=>{if(!d.current)return;const e=o.select(d.current).select(".brush-g"),t=m?n.brushX():n.brushY();return t.extent([[0,0],[i,r]]),t.on("brush end",e=>{if(p.current)return;const t=f.current;if(!t)return;if(!e.selection)return y.current=null,void g.current(null);const[o,n]=e.selection;let i;i=v.current?[t.r.invert(o),t.r.invert(n)]:[t.r.invert(n),t.r.invert(o)];const r={r:i};y.current=r,g.current(r)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),h.current=null}},[i,r,m]),t.useEffect(()=>{if(!c||!h.current||!y.current)return;if(!d.current)return;const e=y.current,t=o.select(d.current).select(".brush-g"),n=c.r(e.r[0]),i=c.r(e.r[1]);m?(p.current=!0,t.call(h.current.move,[n,i]),p.current=!1):(p.current=!0,t.call(h.current.move,[i,n]),p.current=!1)},[c,m]),e.jsx("svg",{ref:d,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`,style:{pointerEvents:"all"}})})}function Os(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}function Ms(e,t){const o={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},n=s.arc().cornerRadius(t.cornerRadius)(o);if(!n)return;e.save(),e.translate(t.cx,t.cy);const i=new Path2D(n);e.fill(i),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(i),e.restore()}ys.QUADTREE_THRESHOLD=500;const Cs=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"wedge"===e.type);for(const t of s){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:1,n=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(e.globalAlpha=o*n,e.fillStyle=("string"==typeof t.style.fill?rt(e,t.style.fill):t.style.fill)||"#007bff",t.roundedEnds){t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1);const o=So({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds.start,roundEnd:t.roundedEnds.end});e.save(),e.translate(t.cx,t.cy);const n=new Path2D(o);e.fill(n),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(n),e.restore()}else t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),Ms(e,t)):(Os(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()));t._pulseIntensity&&t._pulseIntensity>0&&(Os(e,t),Cn(e,t)),e.globalAlpha=1}},_s=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const o=t.columnWidth/2,n="vertical"===t.projection,s=rt(e,"var(--semiotic-primary, #007bff)"),a=rt(e,"var(--semiotic-text, #333)"),l=t.style.fill,c="string"==typeof l?rt(e,l)||l:null!=l?l:s,u=t.style.stroke,d="string"==typeof u?rt(e,u)||u:a,h=t.style.strokeWidth||1,g=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=d,e.lineWidth=h,e.beginPath(),n?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),n?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=g,e.fillStyle=c,n){const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,n,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-o,n,t.columnWidth,i)}else{const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(n,t.y-o,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(n,t.y-o,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),n?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},Ps=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=("string"==typeof t.style.fill?rt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const o=t.iqrLine.centerPos,n=!1!==t.iqrLine.isVertical;e.beginPath(),n?(e.moveTo(o,t.iqrLine.q1Pos),e.lineTo(o,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,o),e.lineTo(t.iqrLine.q3Pos,o)),e.stroke(),e.beginPath(),n?e.arc(o,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,o,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Ls=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=o.fillOpacity)&&void 0!==i?i:o.opacity)&&void 0!==r?r:.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=rt(e,o.style.stroke)||("string"==typeof o.style.fill?rt(e,o.style.fill):o.style.fill)||rt(e,"var(--semiotic-border, #999)"),e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=null!==(s=o.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},Ts=(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const o=t.points;if(o.length>=4){e.globalAlpha=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1,e.beginPath(),e.moveTo(o[0][0],o[0][1]);for(let t=1;o.length>t;t++)e.lineTo(o[t][0],o[t][1]);e.closePath(),e.fillStyle=(null===(s=t.style)||void 0===s?void 0:s.fill)||"#999",e.fill(),(null===(a=t.style)||void 0===a?void 0:a.stroke)&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}};function Rs(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Bs(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Ns=null;const Es=new Map;function Ds(e,t){const o=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,n=Es.get(o);if(void 0!==n)return n;const i=function(e={},t){const{background:o="transparent",stroke:n="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*r));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Ns||(Ns=document.createElement("canvas")),Ns.width=e,Ns.height=e,Ns)}(a)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;o&&"transparent"!==o?(c.fillStyle=o,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=n,c.lineWidth=i,c.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=r)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*a,a),c.stroke()}else{c.save(),c.translate(a/2,a/2),c.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=r)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Es.set(o,i),i}function Is(e,t,o,n,i,r){e.moveTo(t+r,o),e.lineTo(t+n-r,o),e.quadraticCurveTo(t+n,o,t+n,o+r),e.lineTo(t+n,o+i-r),e.quadraticCurveTo(t+n,o+i,t+n-r,o+i),e.lineTo(t+r,o+i),e.quadraticCurveTo(t,o+i,t,o+i-r),e.lineTo(t,o+r),e.quadraticCurveTo(t,o,t+r,o),e.closePath()}function Hs(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Fs(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const Ws=e=>[Ls,...e],$s={bar:Ws([Bn]),clusterbar:Ws([Bn]),point:Ws([Ln]),swarm:Ws([Ln]),pie:[Cs],donut:[Cs],boxplot:Ws([_s,Ln]),violin:Ws([Ps]),histogram:Ws([Bn]),ridgeline:Ws([Ps]),timeline:Ws([Bn]),funnel:[Bn,Ts,(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>{var t,o;return null!=(null===(t=e.datum)||void 0===t?void 0:t.__funnelStepLabel)||null!=(null===(o=e.datum)||void 0===o?void 0:o.__funnelValueLabelX)})){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(!o.__funnelStepLabel)continue;const n=o.__funnelStepLabel;if(e.measureText(n).width+16>(null!==(r=null!==(i=o.__funnelRowWidth)&&void 0!==i?i:o.__funnelBarW)&&void 0!==r?r:0))continue;const s=o.__funnelStepLabelX,a=o.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(n,s,a),e.fillStyle="#fff",e.fillText(n,s,a)}e.font="bold 13px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(null==o.__funnelValueLabelX)continue;const n=null!==(s=o.__funnelBarW)&&void 0!==s?s:0;if(60>n)continue;const i=o.__funnelValue;if(null==i||0===i)continue;const r=o.__funnelPercent,l=!0===o.__funnelIsFirstStep;let c;if(c=l?Rs(i):null!=r?`${Rs(i)} (${Bs(r)})`:Rs(i),e.measureText(c).width+16>n){if(l||null==r)continue;if(c=Rs(i),e.measureText(c).width+16>n)continue}const u=o.__funnelValueLabelX,d=(null!==(a=o.__funnelValueLabelY)&&void 0!==a?a:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[Bn,(e,t,o,n)=>{var i,r;const s=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of s){const o=("string"==typeof t.style.fill?t.style.fill:null)||rt(e,"var(--semiotic-border, #999)"),n=Ds(o,e);e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),n?e.fillStyle=n:(e.fillStyle=o,e.globalAlpha=.4*(null!==(r=t.style.opacity)&&void 0!==r?r:1)),e.fill(),e.globalAlpha=1}},(e,t,o,n)=>{const i=t.filter(e=>{var t,o;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(o=e.datum)||void 0===o?void 0:o.__barFunnelLabelX)});if(0===i.length)return;const r=function(e,t){const[o,n,i]=st(e,t);return(.2126*o+.7152*n+.0722*i)/255>.6}(e,rt(e,"var(--semiotic-text, #333)")),s=r?"#1f2937":"#ffffff",a=r?"rgba(255,255,255,0.18)":"rgba(0,0,0,0.12)",l=r?"#f3f4f6":"#1a1a1a",c=l;for(const t of i){const o=t.datum;if(!o)continue;const n=o.__barFunnelValue;if(null==n)continue;if(25>t.w)continue;const i=o.__barFunnelPercent,r=!(!0===o.__barFunnelIsFirstStep)&&null!=i,u=r?Fs(i):"",d=Hs(n);e.font="bold 13px sans-serif";const h=r?e.measureText(u).width:0;e.font="11px sans-serif";const g=e.measureText(d).width,f=Math.max(h,g)+12,p=r?32:17,y=o.__barFunnelLabelX,m=y-f/2,v=o.__barFunnelLabelY-p-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=s,e.beginPath(),Is(e,m,v,f,p,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),Is(e,m,v,f,p,4),e.stroke(),e.textAlign="center",e.textBaseline="top",r?(e.font="bold 13px sans-serif",e.fillStyle=l,e.fillText(u,y,v+3),e.font="11px sans-serif",e.fillStyle=c,e.fillText(d,y,v+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=l,e.fillText(d,y,v+3))}e.lineWidth=1}],swimlane:Ws([Bn]),custom:Ws([Bn,Ln,Cs,_s,Ps,Ts])},zs={top:50,right:40,bottom:60,left:70},Ys={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function Gs({hover:t}){var o,n,i,r,s,a;const l=t.data||{},c=t.stats,u=t.category;if(Array.isArray(l)){const t=u||(null===(o=l[0])||void 0===o?void 0:o.category)||"";if(c)return e.jsxs("div",{className:"semiotic-tooltip",style:Ys,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:["n = ",c.n]}),e.jsxs("div",{children:["Min: ",c.min.toLocaleString()]}),e.jsxs("div",{children:["Q1: ",c.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",c.median.toLocaleString()]}),e.jsxs("div",{children:["Q3: ",c.q3.toLocaleString()]}),e.jsxs("div",{children:["Max: ",c.max.toLocaleString()]}),e.jsxs("div",{style:{opacity:.8},children:["Mean: ",c.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const n=l.length;return e.jsxs("div",{className:"semiotic-tooltip",style:Ys,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:[n," items"]})]})}if(null!=l.bin&&null!=l.count){const t=l.range||[];return e.jsxs("div",{className:"semiotic-tooltip",style:Ys,children:[l.category&&e.jsx("div",{style:{fontWeight:"bold"},children:l.category+""}),e.jsxs("div",{children:["Count: ",l.count]}),2===t.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)]})]})}const d=t.__oAccessor,h=t.__rAccessor,g=t.__chartType;if("swarm"===g||"point"===g){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:Ys,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}const f=(d&&null!=l[d]?l[d]:null)||l.category||l.name||l.group||l.__rName||"",p=null!==(a=null!==(s=null!==(r=null!==(i=null!==(n=l.__aggregateValue)&&void 0!==n?n:h&&null!=l[h]?l[h]:null)&&void 0!==i?i:l.value)&&void 0!==r?r:l.__rValue)&&void 0!==s?s:l.pct)&&void 0!==a?a:"";if(!f&&""===p){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:Ys,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}return e.jsxs("div",{className:"semiotic-tooltip",style:Ys,children:[f&&e.jsx("div",{style:{fontWeight:"bold"},children:f+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}Gs.ownsChrome=!0;const qs=t.forwardRef(function(o,n){var i,r,a,l,c,u,d,h,g,f,y;const{chartType:m,runtimeMode:b,data:x,oAccessor:k="category",rAccessor:A="value",colorAccessor:j,stackBy:O,groupBy:M,multiAxis:C,timeAccessor:_,valueAccessor:P,categoryAccessor:L,projection:T="vertical",size:R=[600,400],responsiveWidth:B,responsiveHeight:N,margin:E,barPadding:D,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:W,innerRadius:$,cornerRadius:z,normalize:Y,startAngle:G,sweepAngle:q,dynamicColumnWidth:X,bins:V,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:oe,rExtent:ne,oExtent:ie,extentPadding:re=.05,oSort:se,windowMode:ae="sliding",windowSize:le=200,pieceStyle:ce,summaryStyle:ue,colorScheme:de,barColors:he,showAxes:ge=!0,showCategoryTicks:fe,categoryLabel:pe,valueLabel:ye,categoryFormat:me,valueFormat:ve,oLabel:be,rLabel:xe,oFormat:ke,rFormat:we,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,enableHover:Oe=!0,hoverAnnotation:Me,tooltipContent:Ce,customHoverBehavior:_e,annotations:Pe,svgAnnotationRules:Le,showGrid:Te=!1,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:Ie,legendCategoryAccessor:He,onCategoriesChange:Fe,backgroundGraphics:We,foregroundGraphics:$e,title:ze,className:Ye,background:qe,centerContent:Xe,decay:Ve,pulse:Ue,transition:Ke,animate:Ze,staleness:Je,brush:et,onBrush:tt,accessibleTable:ot=!0,description:nt,summary:it,customLayout:st,layoutConfig:at}=o,lt=t.useRef(!0),ct=bn({sizeProp:R,responsiveWidth:B,responsiveHeight:N,userMargin:E,marginDefault:zs,foregroundGraphics:$e,backgroundGraphics:We,animate:Ze,transitionProp:Ke,themeDirtyRef:lt}),{reducedMotionRef:ut,responsiveRef:dt,size:ht,margin:gt,adjustedWidth:ft,adjustedHeight:pt,resolvedForeground:yt,resolvedBackground:mt,currentTheme:vt,transition:bt,introEnabled:xt,tableId:kt,rafRef:wt,renderFnRef:Ot,scheduleRender:Mt}=ct,Pt=Po(),Lt=Bo(),Tt=t.useMemo(()=>v(x),[x]),Rt=null!=pe?pe:be,Bt=null!=ye?ye:xe,Nt=null!=me?me:ke,Et=null!=ve?ve:we,Dt=t.useRef(null),It=t.useRef(null),Ht=t.useRef([]),Ft=t.useRef(He),Wt=t.useRef(Fe);Ft.current=He,Wt.current=Fe;const[$t,zt]=t.useState(null),[Yt,Gt]=t.useState(null),[qt,Xt]=t.useState(0),[Vt,Ut]=t.useState(!1),[Kt,Qt]=t.useState(null),Zt=t.useCallback(()=>{var e,t;Qt(null!==(t=null===(e=no.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]),Jt=Oe||Me,eo="streaming"===b,to=t.useMemo(()=>{var e,t,o;return{chartType:m,runtimeMode:eo?"streaming":"bounded",windowSize:le,windowMode:ae,extentPadding:re,projection:T,oAccessor:eo?void 0:k,rAccessor:eo?void 0:A,colorAccessor:j,stackBy:O,groupBy:M,multiAxis:C,timeAccessor:eo?_:void 0,valueAccessor:eo?P||("string"==typeof A||"function"==typeof A?A:void 0):void 0,categoryAccessor:eo?L||k:void 0,rExtent:ne,oExtent:ie,axisExtent:Se,barPadding:D,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:W,innerRadius:$,cornerRadius:z,normalize:Y,startAngle:G,sweepAngle:q,dynamicColumnWidth:X,bins:V,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:oe,oSort:se,pieceStyle:ce,summaryStyle:ue,colorScheme:de,themeCategorical:null===(e=null==vt?void 0:vt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(vt),themeSequential:null===(t=null==vt?void 0:vt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==vt?void 0:vt.colors)||void 0===o?void 0:o.diverging,barColors:he,decay:Ve,pulse:Ue,transition:bt,introAnimation:xt,staleness:Je,customLayout:st,layoutConfig:at,layoutMargin:gt}},[m,le,ae,re,T,k,A,j,O,M,C,_,P,L,ne,ie,Se,D,I,H,F,W,$,z,Y,G,q,X,V,U,K,Q,Z,J,ee,te,oe,se,ce,ue,de,he,Ve,Ue,null==bt?void 0:bt.duration,null==bt?void 0:bt.easing,xt,Je,eo,vt,st,at,gt]),oo=Eo(to),no=t.useRef(null);no.current||(no.current=new ys(oo));const io=t.useCallback(()=>{var e,t;const o=Ft.current,n=Wt.current;if(!n||!o)return;const i=Wn(null!==(t=null===(e=no.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],o);$n(i,Ht.current)||(Ht.current=i,n(i))},[]);t.useEffect(()=>{var e;null===(e=no.current)||void 0===e||e.updateConfig(oo),lt.current=!0,Mt()},[oo,Mt]);const ro=t.useRef(null);ro.current||(ro.current=new w(e=>{const t=no.current;t&&t.ingest(e)&&(lt.current=!0,Mt())}));const so=t.useCallback(e=>{var t;null===(t=ro.current)||void 0===t||t.push(e)},[]),ao=t.useCallback(e=>{var t;null===(t=ro.current)||void 0===t||t.pushMany(e)},[]),lo=t.useCallback(()=>{var e,t;null===(e=ro.current)||void 0===e||e.clear(),null===(t=no.current)||void 0===t||t.clear(),lt.current=!0,Mt()},[Mt]),co=t.useCallback(e=>{var t,o;null===(t=ro.current)||void 0===t||t.clearLastData(),null===(o=ro.current)||void 0===o||o.setReplacementData(e)},[]);t.useImperativeHandle(n,()=>({push:so,pushMany:ao,replace:co,remove:e=>{var t,o,n,i;null===(t=ro.current)||void 0===t||t.flush();const r=null!==(n=null===(o=no.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];if(r.length>0){const e=null===(i=It.current)||void 0===i?void 0:i.data;!!It.current&&r.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(It.current=null,zt(null)),lt.current=!0,Mt()}return r},update:(e,t)=>{var o,n,i;null===(o=ro.current)||void 0===o||o.flush();const r=null!==(i=null===(n=no.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(lt.current=!0,Mt()),r},clear:lo,getData:()=>{var e,t,o;return null===(e=ro.current)||void 0===e||e.flush(),null!==(o=null===(t=no.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=no.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[so,ao,co,lo,Mt]),t.useEffect(()=>{var e;x&&(null===(e=ro.current)||void 0===e||e.setBoundedData(Tt))},[x,Tt]);const{hoverHandlerRef:uo,hoverLeaveRef:ho,onPointerMove:go,onPointerLeave:fo}=ct;uo.current=e=>{if(!Jt)return;const t=Dt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-gt.left,i=e.clientY-o.top-gt.top;if(0>n||n>ft||0>i||i>pt)return void(It.current&&(It.current=null,zt(null),_e&&_e(null),Mt()));const r=no.current;if(!r||0===r.scene.length)return;const s="radial"===T,a=function(e,t,o,n=30,i,r=0){let s=null;if(i){const e=Qe(i,t,o,n,r);e&&(s={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"rect":if(null==r.datum)break;e=ms(r,t,o);break;case"point":if(i)break;e=vs(r,t,o,n);break;case"wedge":e=bs(r,t,o);break;case"boxplot":e=xs(r,t,o);break;case"violin":e=ks(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(r.scene,s?n-ft/2:n,s?i-pt/2:i,30,r.pointQuadtree,r.maxPointRadius);if(!a)return void(It.current&&(It.current=null,zt(null),_e&&_e(null),Mt()));const l=En(a.datum||{},a.x,a.y,Object.assign(Object.assign(Object.assign({},a.stats&&{stats:a.stats}),a.category&&{category:a.category}),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m}));It.current=l,zt(l),_e&&(_e(l),lt.current=!0),Mt()},ho.current=()=>{It.current&&(It.current=null,zt(null),_e&&(_e(null),lt.current=!0),Mt())};const po=t.useRef(-1),yo=t.useRef(null),mo=t.useRef(null),vo=t.useCallback(e=>{const t=no.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(mo.current&&mo.current.version===o)n=mo.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)if("rect"===r.type&&null!=r.x){if(null==r.datum)continue;const e=null!==(o=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==o?o:"";i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(n=r.group)&&void 0!==n?n:e})}else if("point"===r.type)i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});else if("wedge"===r.type&&null!=r.cx){const e=((r.startAngle||0)+(r.endAngle||0))/2,t=((r.innerRadius||0)+(r.outerRadius||50))/2;i.push({x:r.cx+Math.cos(e)*t,y:r.cy+Math.sin(e)*t,datum:r.datum,shape:"wedge",group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=At(e),mo.current={version:o,graph:n}}const i=po.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),po.current=0;const t=n.flat[0];yo.current={shape:t.shape,w:t.w,h:t.h};const o=Object.assign(Object.assign({},Ct(t)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});return It.current=o,zt(o),_e&&_e(o),void Mt()}const r=jt(n,i),s=St(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return po.current=-1,yo.current=null,It.current=null,zt(null),_e&&_e(null),void Mt();po.current=s;const a=n.flat[s];yo.current={shape:a.shape,w:a.w,h:a.h};const l=Object.assign(Object.assign({},Ct(a)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});It.current=l,zt(l),_e&&_e(l),Mt()},[_e,Mt]),bo=t.useCallback(e=>{po.current=-1,yo.current=null,go(e)},[go]);Ot.current=()=>{var e,t;wt.current=0;const o=Dt.current;if(!o)return;const n=o.getContext("2d");if(!n)return;const i=no.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(ut.current?r+1e6:r),a=!ut.current&&s,l=lt.current;l&&!s&&(i.computeScene({width:ft,height:pt}),io(),Zt(),lt.current=!1),(l||a)&&o.setAttribute("aria-label",Yo(i.scene,m+" chart"));const c=kn(),u=ht[0]*c,d=ht[1]*c;o.width===u&&o.height===d||(o.width=u,o.height=d,o.style.width=ht[0]+"px",o.style.height=ht[1]+"px"),n.setTransform(c,0,0,c,0,0),n.clearRect(0,0,ht[0],ht[1]);const h=null!==(e=null==Je?void 0:Je.threshold)&&void 0!==e?e:5e3,g=Je&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(g&&(n.globalAlpha=null!==(t=null==Je?void 0:Je.dimOpacity)&&void 0!==t?t:.5),"transparent"!==qe&&!We){const e=o?getComputedStyle(o).getPropertyValue("--semiotic-bg").trim():"",t=qe||(e&&"transparent"!==e?e:null),i=t?rt(n,t):null;i&&(n.fillStyle=i,n.fillRect(0,0,ht[0],ht[1]))}const f="radial"===T;n.save(),n.beginPath(),n.rect(gt.left,gt.top,ft,pt),n.clip(),f?(n.save(),n.translate(gt.left+ft/2,gt.top+pt/2)):n.translate(gt.left,gt.top);const p=st?$s.custom:$s[m]||[],y={width:ft,height:pt};for(const e of p)e(n,i.scene,i.scales,y);f&&n.restore(),n.restore(),g&&(n.globalAlpha=1),l&&i.scales&&(Gt(i.scales),Xt(e=>e+1)),(null==Je?void 0:Je.showBadge)&&Ut(!!g),(a||null!=i.activeTransition||i.hasActivePulses)&&(wt.current=requestAnimationFrame(()=>Ot.current()))},No({hydrated:Pt,wasHydratingFromSSR:Lt,storeRef:no,dirtyRef:lt,renderFnRef:Ot,cleanup:()=>{var e;return null===(e=ro.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{lt.current=!0,Mt()},[m,ft,pt,ge,qe,Mt]),_t(Je,no,lt,Mt,Vt,Ut);const xo=Jt&&$t?Ce?Ce($t):e.jsx(Gs,{hover:$t}):null,ko="radial"===T,jo=xo?e.jsx(fn,{x:$t?ko?$t.x+ft/2:$t.x:0,y:$t?ko?$t.y+pt/2:$t.y:0,containerWidth:ft,containerHeight:pt,margin:gt,className:"stream-ordinal-tooltip",children:xo}):null,_o=zn(k,void 0,"__semiotic_resolvedO",""),Lo=zn(A,void 0,"__semiotic_resolvedR",""),To=_o.key,Ro=Lo.key,Do=Yn(_o,Lo,Pe&&Pe.length>0||!1);if(Co||!Pt&&Lt){const t=no.current;t&&x&&(t.ingest({inserts:Tt,bounded:!0}),t.computeScene({width:ft,height:pt}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,l="radial"===T,c=l?gt.left+ft/2:gt.left,u=l?gt.top+pt/2:gt.top;return e.jsxs("div",{ref:dt,className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"img","aria-label":nt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:B?"100%":ht[0],height:N?"100%":ht[1]},children:[e.jsx(on,{summary:it}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ht[0],height:ht[1],style:{position:"absolute",left:0,top:0},children:[mt&&e.jsx("g",{transform:`translate(${gt.left},${gt.top})`,children:mt}),e.jsxs("g",{transform:`translate(${c},${u})`,children:[qe&&e.jsx("rect",{x:0,y:0,width:ft,height:pt,fill:qe}),o.map((t,o)=>function(t,o){var n,i,r,a,l;const c=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",u=e=>`ord-${t.type}-${c}-${o}-${e}`,d=`ord-${t.type}-${c}-${o}`;switch(t.type){case"rect":{const o=t,n=function(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}(d)+"-grad",i=function(t,o){const n=t.fillGradient;if(!n)return null;let i=t.x,r=t.y,s=t.x,a=t.y+t.h;"bottom"===t.roundedEdge?(r=t.y+t.h,a=t.y):"right"===t.roundedEdge?(i=t.x+t.w,r=t.y,s=t.x,a=t.y):"left"===t.roundedEdge&&(i=t.x,r=t.y,s=t.x+t.w,a=t.y);const l=[];if("colorStops"in n){const t=n.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;for(let o=0;t.length>o;o++)l.push(e.jsx("stop",{offset:t[o].offset,stopColor:t[o].color},o))}else{const o=Mo(t.style.fill);l.push(e.jsx("stop",{offset:0,stopColor:o,stopOpacity:n.topOpacity},"0")),l.push(e.jsx("stop",{offset:1,stopColor:o,stopOpacity:n.bottomOpacity},"1"))}return e.jsx("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(o,n),r=i?`url(#${n})`:Mo(o.style.fill);if(o.cornerRadii&&wo(o.cornerRadii)){const t=function(e){const{x:t,y:o,w:n,h:i}=e,{tl:r,tr:s,br:a,bl:l}=Ao(e);let c=`M${t+r},${o}`;return c+=` L${t+n-s},${o}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+n},${o+s}`),c+=` L${t+n},${o+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+n-a},${o+i}`),c+=` L${t+l},${o+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${o+i-l}`),c+=` L${t},${o+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${t+r},${o}`),c+=" Z",c}(o);return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:t,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}if(o.roundedTop&&o.roundedTop>0){const t=Math.min(o.roundedTop,o.w/2,o.h/2),{x:n,y:s,w:a,h:l}=o;let c;switch(o.roundedEdge){case"right":c=`M${n},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n},${s+l} Z`;break;case"left":c=`M${n+a},${s} L${n+t},${s} A${t},${t} 0 0 0 ${n},${s+t} L${n},${s+l-t} A${t},${t} 0 0 0 ${n+t},${s+l} L${n+a},${s+l} Z`;break;case"bottom":c=`M${n},${s} L${n+a},${s} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n+t},${s+l} A${t},${t} 0 0 1 ${n},${s+l-t} Z`;break;default:c=`M${n},${s+l} L${n},${s+t} A${t},${t} 0 0 1 ${n+t},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l} Z`}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:c,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},d)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Mo(o.style.fill),opacity:null!==(n=o.style.opacity)&&void 0!==n?n:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}case"wedge":{const o=t;let n;if(o.roundedEnds)n=So({innerRadius:o.innerRadius,outerRadius:o.outerRadius,startAngle:o.startAngle,endAngle:o.endAngle,cornerRadius:o.cornerRadius,roundStart:o.roundedEnds.start,roundEnd:o.roundedEnds.end});else{const e=s.arc().innerRadius(o.innerRadius).outerRadius(o.outerRadius).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2);o.cornerRadius&&e.cornerRadius(o.cornerRadius),n=e(Oo)||""}return e.jsx("path",{d:n,transform:`translate(${o.cx},${o.cy})`,fill:Mo(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},d)}case"boxplot":{const o=t,n=o.columnWidth/2;return e.jsxs("g","vertical"===o.projection?{children:[e.jsx("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:o.x-n,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:Mo(o.style.fill),fillOpacity:null!==(i=o.style.fillOpacity)&&void 0!==i?i:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-n,y1:o.medianPos,x2:o.x+n,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.x-.5*n,y1:o.minPos,x2:o.x+.5*n,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-.5*n,y1:o.maxPos,x2:o.x+.5*n,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[e.jsx("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-n,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:Mo(o.style.fill),fillOpacity:null!==(r=o.style.fillOpacity)&&void 0!==r?r:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.medianPos,y1:o.y-n,x2:o.medianPos,y2:o.y+n,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.minPos,y1:o.y-.5*n,x2:o.minPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.maxPos,y1:o.y-.5*n,x2:o.maxPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1})]},d)}case"violin":{const o=t,n=[e.jsx("path",{d:o.pathString,transform:o.translateX||o.translateY?`translate(${o.translateX},${o.translateY})`:void 0,fill:Mo(o.style.fill),fillOpacity:null!==(a=o.style.fillOpacity)&&void 0!==a?a:.6,stroke:o.style.stroke||"#333",strokeWidth:o.style.strokeWidth||1},u("path"))];if(o.iqrLine&&o.bounds){const t=o.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?n.push(e.jsx("line",{x1:i,y1:o.iqrLine.q1Pos,x2:i,y2:o.iqrLine.q3Pos,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:i,cy:o.iqrLine.medianPos,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med"))):n.push(e.jsx("line",{x1:o.iqrLine.q1Pos,y1:r,x2:o.iqrLine.q3Pos,y2:r,stroke:o.style.stroke||"#333",strokeWidth:2},u("iqr")),e.jsx("circle",{cx:o.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},u("med")))}return e.jsx("g",{children:n},d)}case"connector":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(l=t.style.opacity)&&void 0!==l?l:.5},d);case"trapezoid":{const o=t,n=o.points.map(e=>`${e[0]},${e[1]}`).join(" ");return e.jsx("polygon",{points:n,fill:Mo(o.style.fill,"#999"),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},d)}default:return null}}(t,o)).filter(Boolean)]})]}),e.jsx(js,{width:ft,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:gt,scales:n,showAxes:ge,showCategoryTicks:fe,oLabel:Rt,rLabel:Bt,oFormat:Nt,rFormat:Et,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,showGrid:Te,title:ze,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:Ie,foregroundGraphics:Ge(yt,null===(a=no.current)||void 0===a?void 0:a.customLayoutOverlays),annotations:Pe,svgAnnotationRules:Le,annotationFrame:0,xAccessor:To,yAccessor:Ro,annotationData:Do(null==t?void 0:t.getData())}),Xe&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:gt.left+ft/2,top:gt.top+pt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Xe})]})}return e.jsxs("div",{ref:dt,className:"stream-ordinal-frame"+(Ye?" "+Ye:""),role:"group","aria-label":nt||("string"==typeof ze?ze:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:B?"100%":ht[0],height:N?"100%":ht[1],overflow:"visible"},onKeyDown:vo,children:[ot&&e.jsx(nn,{tableId:kt}),ot&&e.jsx(en,{scene:null!==(c=null===(l=no.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],chartType:m+" chart",tableId:kt,chartTitle:"string"==typeof ze?ze:void 0}),e.jsx(on,{summary:it}),e.jsxs("div",{role:"img","aria-label":nt||("string"==typeof ze?ze:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:Jt?bo:void 0,onMouseLeave:Jt?fo:void 0,children:[mt&&e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:ht[0],height:ht[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${gt.left},${gt.top})`,children:mt})}),e.jsx(ws,{width:ft,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:gt,scales:Yt,showAxes:ge,showGrid:Te,rFormat:Et,rTickValues:Ae,axisExtent:Se}),e.jsx("canvas",{ref:Dt,"aria-label":Yo(null!==(d=null===(u=no.current)||void 0===u?void 0:u.scene)&&void 0!==d?d:[],m+" chart"),style:{position:"absolute",top:0,left:0,width:ht[0],height:ht[1]}}),e.jsx(rn,{hoverPoint:$t}),e.jsx(js,{width:ft,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:gt,scales:Yt,showAxes:ge,showCategoryTicks:fe,oLabel:Rt,rLabel:Bt,oFormat:Nt,rFormat:Et,rTickValues:Ae,axisExtent:Se,showGrid:Te,title:ze,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:Ee,legendIsolatedCategories:De,legendPosition:Ie,foregroundGraphics:Ge(yt,Kt),annotations:Pe,svgAnnotationRules:Le,annotationFrame:qt,xAccessor:To,yAccessor:Ro,annotationData:Do(null===(h=no.current)||void 0===h?void 0:h.getData()),underlayRendered:!0}),(et||tt)&&"radial"!==T&&e.jsx(Ss,{width:ft,height:pt,totalWidth:ht[0],totalHeight:ht[1],margin:gt,scales:Yt,onBrush:tt||(()=>{})}),Xe&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:gt.left+ft/2,top:gt.top+pt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Xe}),(null==Je?void 0:Je.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===Je.badgePosition?{top:4,left:4}:"bottom-left"===Je.badgePosition?{bottom:4,left:4}:"bottom-right"===Je.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Vt?"#dc3545":"#28a745",color:"white"}),children:Vt?"STALE":"LIVE"}),e.jsx(an,{active:po.current>=0,hoverPoint:$t,margin:gt,size:ht,shape:null===(g=yo.current)||void 0===g?void 0:g.shape,width:null===(f=yo.current)||void 0===f?void 0:f.w,height:null===(y=yo.current)||void 0===y?void 0:y.h}),jo]})]})});function Xs({ref:e,frameRef:o,setup:n}){return t.useImperativeHandle(e,()=>({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,i;return null!==(i=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[]},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:[]},getScales:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[o]),{effectiveLegendProps:n.legendBehaviorProps,effectiveMargin:n.margin}}function Vs(e){const{colorBy:o,colorScale:n,color:i,themeCategorical:r,colorScheme:s,categoryIndexMap:a,userPieceStyle:l,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:g,cycleByCategory:f=!1,baseStyleExtras:p,linkStrokeToFill:y=!1}=e,m=t.useMemo(()=>(e,t)=>{const l="function"==typeof p?p(e,t):p,c=l?Object.assign({},l):{};if(void 0===c.fill)if(o){if(!n)return c;c.fill=ke(e,o,n)}else c.fill=Hi(i,r,s,f?t:void 0,a);return y&&void 0===c.stroke&&void 0!==c.fill&&(c.stroke=c.fill),c},[o,n,i,r,s,a,f,p,y]),v=t.useMemo(()=>kr(l?"function"==typeof l?(e,t)=>Object.assign(Object.assign({},m(e,t)),l(e,t)||{}):(e,t)=>Object.assign(Object.assign({},m(e,t)),l):m,{stroke:c,strokeWidth:u,opacity:d}),[m,l,c,u,d]);return t.useMemo(()=>Oi(v,null!=h?h:null,g),[v,h,g])}qs.displayName="StreamOrdinalFrame";const Us=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sort:p=!1,barPadding:y=40,roundedTop:m,gradientFill:b=!1,baselinePadding:x=!1,tooltip:k,annotations:w,regression:A,valueExtent:j,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:E,color:D,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:W,categoryFormat:$,dataIdAccessor:z}=o,{width:Y,height:G,enableHover:q,showGrid:X,showLegend:V,title:U,description:K,summary:Q,accessibleTable:Z,categoryLabel:J,valueLabel:ee}=i,te=t.useMemo(()=>v(s),[s]),oe=xr({data:te,rawData:s,colorBy:g,colorScheme:f,legendInteraction:N,legendPosition:E,selection:O,linkedHover:M,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:C,onClick:_,hoverHighlight:P,chartType:"BarChart",chartId:L,showLegend:V,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:Y,height:G}),{effectiveLegendProps:ne,effectiveMargin:ie}=Xs({ref:n,frameRef:r,setup:oe});if(oe.earlyReturn)return oe.earlyReturn;dr("BarChart",te,"categoryAccessor",c),dr("BarChart",te,"valueAccessor",u);const re=Wi(te,p,u),se=Ii(),ae=t.useMemo(()=>new Map,[te]),le=Vs({colorBy:g,colorScale:oe.colorScale,color:D,themeCategorical:se,colorScheme:f,categoryIndexMap:ae,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection}),ce=t.useMemo(()=>tr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",valueFormat:h}),[c,u,g,h]),ue=yr({componentName:"BarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(or,{componentName:"BarChart",message:ue,width:Y,height:G});const de=$r(A),he=de?[de,...w||[]]:w,ge=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:"bar"},null!=s&&{data:re}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[Y,G],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ie,barPadding:y}),null!=m&&{roundedTop:m}),b&&{gradientFill:!0===b?{topOpacity:.8,bottomOpacity:.05}:b}),z&&{dataIdAccessor:z}),{baselinePadding:x,enableHover:q,showAxes:i.showAxes,oLabel:J,rLabel:ee,rFormat:h}),$&&{oFormat:$}),{showGrid:X,showCategoryTicks:W,oSort:p}),ne),Tr({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:k,defaultTooltipContent:ce})),Rr({linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior})),he&&he.length>0&&{annotations:he}),j&&{rExtent:j}),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"BarChart",width:Y,height:G,children:e.jsx(qs,Object.assign({ref:r},ge))})});Us.displayName="BarChart";const Ks=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",stackBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,normalize:y=!1,sort:m=!1,barPadding:b=40,roundedTop:x,baselinePadding:k=!1,tooltip:w,annotations:A,valueExtent:j,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:E,color:D,stroke:I,strokeWidth:H,opacity:F,categoryFormat:W}=o,{width:$,height:z,enableHover:Y,showGrid:G,showLegend:q,title:X,description:V,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=f||u,te=xr({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:N,legendPosition:E,selection:O,linkedHover:M,fallbackFields:ee?["string"==typeof ee?ee:""]:[],unwrapData:!0,onObservation:C,onClick:_,hoverHighlight:P,chartType:"StackedBarChart",chartId:L,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:$,height:z});if(te.earlyReturn)return te.earlyReturn;const oe=Ii(),ne=t.useMemo(()=>new Map,[J]),ie=Vs({colorBy:ee,colorScale:te.colorScale,color:D,themeCategorical:oe,colorScheme:p,categoryIndexMap:ne,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=t.useMemo(()=>tr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),se=yr({componentName:"StackedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{stackBy:u}}),{effectiveLegendProps:ae,effectiveMargin:le}=Xs({ref:n,frameRef:r,setup:te}),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({chartType:"bar"},null!=s&&{data:J}),{oAccessor:c,rAccessor:d,stackBy:u,normalize:y,oSort:m,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ie,size:[$,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:le,barPadding:b}),null!=x&&{roundedTop:x}),{baselinePadding:k,enableHover:Y}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),W&&{oFormat:W}),{showGrid:G}),ae),Tr({title:X,description:V,summary:U,accessibleTable:K,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:w,defaultTooltipContent:re})),Rr({linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior})),A&&A.length>0&&{annotations:A}),j&&{rExtent:j}),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return se?e.jsx(or,{componentName:"StackedBarChart",message:se,width:$,height:z}):e.jsx(sr,{componentName:"StackedBarChart",width:$,height:z,children:e.jsx(qs,Object.assign({ref:r},ce))})});Ks.displayName="StackedBarChart";const Qs=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",groupBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,sort:y=!1,barPadding:m=60,roundedTop:b,baselinePadding:x=!1,tooltip:k,annotations:w,valueExtent:A,frameProps:j={},selection:S,linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,chartId:P,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:E,stroke:D,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:W,height:$,enableHover:z,showGrid:Y,showLegend:G,title:q,description:X,summary:V,accessibleTable:U,categoryLabel:K,valueLabel:Q}=i,Z=t.useMemo(()=>v(s),[s]),J=f||u,ee=xr({data:Z,rawData:s,colorBy:J,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:J?["string"==typeof J?J:""]:[],unwrapData:!0,onObservation:M,onClick:C,hoverHighlight:_,chartType:"GroupedBarChart",chartId:P,showLegend:G,userMargin:a,marginDefaults:i.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:W,height:$});if(ee.earlyReturn)return ee.earlyReturn;const te=Ii(),oe=t.useMemo(()=>new Map,[Z]),ne=Vs({colorBy:J,colorScale:ee.colorScale,color:E,themeCategorical:te,colorScheme:p,categoryIndexMap:oe,userPieceStyle:j.pieceStyle,stroke:D,strokeWidth:I,opacity:H,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ie=t.useMemo(()=>tr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),re=yr({componentName:"GroupedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{groupBy:u}}),{effectiveLegendProps:se,effectiveMargin:ae}=Xs({ref:n,frameRef:r,setup:ee}),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({chartType:"clusterbar"},null!=s&&{data:Z}),{oAccessor:c,rAccessor:d,groupBy:u,oSort:y,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ne,size:[W,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ae,barPadding:m}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:K,rLabel:Q,rFormat:g}),F&&{oFormat:F}),{showGrid:Y}),se),Tr({title:q,description:X,summary:V,accessibleTable:U,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:k,defaultTooltipContent:ie})),Rr({linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior})),w&&w.length>0&&{annotations:w}),A&&{rExtent:A}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return re?e.jsx(or,{componentName:"GroupedBarChart",message:re,width:W,height:$}):e.jsx(sr,{componentName:"GroupedBarChart",width:W,height:$,children:e.jsx(qs,Object.assign({ref:r},le))})});function Zs({brushProp:e,onBrushProp:o,linkedBrush:n,valueAccessor:i}){const r=Si("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),s=gi({name:(null==r?void 0:r.name)||"__unused_ordinal_brush__",xField:(null==r?void 0:r.xField)||("string"==typeof i?i:"value")}),a=t.useRef(s.brushInteraction);a.current=s.brushInteraction;const l=t.useCallback(e=>{if(r){a.current.end(e?e.r:null)}null==o||o(e)},[o,r]),c=!!(e||n||o);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}Qs.displayName="GroupedBarChart";const Js=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:b=.7,categoryPadding:x=20,tooltip:k,annotations:w,valueExtent:A,brush:j,onBrush:S,linkedBrush:O,frameProps:M={},selection:C,linkedHover:_,onObservation:P,onClick:L,hoverHighlight:T,chartId:R,loading:B,loadingContent:N,emptyContent:E,legendInteraction:D,legendPosition:I,color:H,stroke:F,strokeWidth:W,opacity:$,showCategoryTicks:z,categoryFormat:Y}=o,{width:G,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=i,oe=t.useMemo(()=>v(s),[s]),ne=xr({data:oe,rawData:s,colorBy:g,colorScheme:f,legendInteraction:D,legendPosition:I,selection:C,linkedHover:_,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:P,onClick:L,hoverHighlight:T,chartType:"SwarmPlot",chartId:R,showLegend:U,userMargin:a,marginDefaults:i.marginDefaults,loading:B,loadingContent:N,emptyContent:E,width:G,height:q}),ie=Zs({brushProp:j,onBrushProp:S,linkedBrush:O,valueAccessor:u});if(ne.earlyReturn)return ne.earlyReturn;const re=t.useMemo(()=>{if(!p)return;const e=oe.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[oe,p]),se=Ii(),ae=t.useMemo(()=>new Map,[oe]),le=Vs({colorBy:g,colorScale:ne.colorScale,color:H,themeCategorical:se,colorScheme:f,categoryIndexMap:ae,userPieceStyle:null==M?void 0:M.pieceStyle,stroke:F,strokeWidth:W,opacity:$,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection,baseStyleExtras:e=>({fillOpacity:b,r:p?Ae(e,p,y,re):m})}),ce=t.useMemo(()=>tr({categoryAccessor:c,valueAccessor:u,groupAccessor:g||void 0,valueFormat:h}),[c,u,g,h]),ue=yr({componentName:"SwarmPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(or,{componentName:"SwarmPlot",message:ue,width:G,height:q});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({chartType:"swarm"},null!=s&&{data:oe}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[G,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne.margin,barPadding:x,enableHover:X}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:ee,rLabel:te,rFormat:h}),Y&&{oFormat:Y}),{showGrid:V,showCategoryTicks:z}),ne.legendBehaviorProps),Tr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:k,defaultTooltipContent:ce})),Rr({linkedHover:_,onObservation:P,onClick:L,hoverHighlight:T,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior})),w&&w.length>0&&{annotations:w}),A&&{rExtent:A}),ie.brushStreamProps),Object.fromEntries(Object.entries(M).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"SwarmPlot",width:G,height:q,children:e.jsx(qs,Object.assign({ref:r},de))})});function ea(t){return o=>{var n;const i=o.category||o.data&&(null===(n=o.data[0])||void 0===n?void 0:n.category)||"",r=o.stats||(o.data||o).stats;if(r&&null!=r.median)return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),null!=r.n&&e.jsxs("div",{children:["n = ",r.n]}),null!=r.min&&e.jsxs("div",{children:["Min: ",r.min.toLocaleString()]}),null!=r.q1&&e.jsxs("div",{children:["Q1: ",r.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",r.median.toLocaleString()]}),null!=r.q3&&e.jsxs("div",{children:["Q3: ",r.q3.toLocaleString()]}),null!=r.max&&e.jsxs("div",{children:["Max: ",r.max.toLocaleString()]}),null!=r.mean&&e.jsxs("div",{style:{opacity:.8},children:["Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(null==t?void 0:t.valueAccessor){const n=t.valueAccessor,r=(Array.isArray(o.data)?o.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),s=r.length,a=s>0?s%2!=0?r[Math.floor(s/2)]:(r[s/2-1]+r[s/2])/2:null;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),s>0&&e.jsxs("div",{children:["n = ",s]}),null!=a&&e.jsxs("div",{children:["Median: ",a.toLocaleString()]})]})}return e.jsx("div",{className:"semiotic-tooltip",style:ln,children:e.jsx("div",{style:{fontWeight:"bold"},children:i+""})})}}Js.displayName="SwarmPlot";const ta=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,showOutliers:p=!0,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,frameProps:k={},selection:w,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:O,chartId:M,loading:C,loadingContent:_,emptyContent:P,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:N,opacity:E,showCategoryTicks:D,categoryFormat:I}=o,{width:H,height:F,enableHover:W,showGrid:$,showLegend:z,title:Y,description:G,summary:q,accessibleTable:X,categoryLabel:V,valueLabel:U}=i,K=t.useMemo(()=>v(s),[s]),Q=xr({data:K,rawData:s,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:T,selection:w,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:O,chartType:"BoxPlot",chartId:M,showLegend:z,userMargin:a,marginDefaults:i.marginDefaults,loading:C,loadingContent:_,emptyContent:P,width:H,height:F});if(Q.earlyReturn)return Q.earlyReturn;const Z=Ii(),J=t.useMemo(()=>new Map,[K]),ee=Vs({colorBy:g,colorScale:Q.colorScale,color:R,themeCategorical:Z,colorScheme:f,categoryIndexMap:J,userPieceStyle:void 0,stroke:B,strokeWidth:N,opacity:E,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),te=t.useMemo(()=>ea(),[]),oe=yr({componentName:"BoxPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(oe)return e.jsx(or,{componentName:"BoxPlot",message:oe,width:H,height:F});const 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({chartType:"boxplot"},null!=s&&{data:K}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ee,showOutliers:p,size:[H,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q.margin,barPadding:y,enableHover:W}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:h}),I&&{oFormat:I}),{showGrid:$,showCategoryTicks:D}),Q.legendBehaviorProps),Tr({title:Y,description:G,summary:q,accessibleTable:X,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:te})),Rr({linkedHover:A,onObservation:j,onClick:S,hoverHighlight:O,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior})),b&&b.length>0&&{annotations:b}),x&&{rExtent:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"BoxPlot",width:H,height:F,children:e.jsx(qs,Object.assign({ref:r},ne))})});ta.displayName="BoxPlot";const oa=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:"horizontal"}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",bins:d=25,relative:h=!1,valueFormat:g,colorBy:f,colorScheme:p,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,brush:k,onBrush:w,linkedBrush:A,frameProps:j={},selection:S,linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,chartId:P,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:E,stroke:D,strokeWidth:I,opacity:H,showCategoryTicks:F,categoryFormat:W}=o,{width:$,height:z,enableHover:Y,showGrid:G,showLegend:q,title:X,description:V,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=xr({data:J,rawData:s,colorBy:f,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:M,onClick:C,hoverHighlight:_,chartType:"Histogram",chartId:P,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:$,height:z}),te=Zs({brushProp:k,onBrushProp:w,linkedBrush:A,valueAccessor:u});if(ee.earlyReturn)return ee.earlyReturn;const oe=t.useMemo(()=>{if(0===J.length)return;const e="function"==typeof u?u:e=>e[u];let t=1/0,o=-1/0;for(const n of J){const i=e(n);null!=i&&isFinite(i)&&(t>i&&(t=i),i>o&&(o=i))}return t>o?void 0:[t,o]},[J,u]),ne=Ii(),ie=t.useMemo(()=>new Map,[J]),re=Vs({colorBy:f,colorScale:ee.colorScale,color:E,themeCategorical:ne,colorScheme:p,categoryIndexMap:ie,userPieceStyle:void 0,stroke:D,strokeWidth:I,opacity:H,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),se=t.useMemo(()=>t=>{const o=t.data||t,n=o.category||t.category||"",i=o.count,r=o.range;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[n&&e.jsx("div",{style:{fontWeight:"bold"},children:n+""}),null!=i&&e.jsxs("div",{children:["Count: ",i]}),r&&2===r.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]),ae=yr({componentName:"Histogram",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(or,{componentName:"Histogram",message:ae,width:$,height:z});const 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({chartType:"histogram"},null!=s&&{data:J}),{oAccessor:c,rAccessor:u,projection:"horizontal",summaryStyle:re,bins:d,normalize:h}),x?{rExtent:x}:oe&&{rExtent:oe}),{size:[$,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee.margin,barPadding:y,enableHover:Y}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),W&&{oFormat:W}),{showGrid:G,showCategoryTicks:F}),ee.legendBehaviorProps),Tr({title:X,description:V,summary:U,accessibleTable:K,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:se})),Rr({linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior})),b&&b.length>0&&{annotations:b}),te.brushStreamProps),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"Histogram",width:$,height:z,children:e.jsx(qs,Object.assign({ref:r},le))})});oa.displayName="Histogram";const na=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",bins:h=25,showIQR:g=!0,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:m=20,tooltip:b,annotations:x,valueExtent:k,brush:w,onBrush:A,linkedBrush:j,frameProps:S={},selection:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:E,color:D,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:W,categoryFormat:$}=o,{width:z,height:Y,enableHover:G,showGrid:q,showLegend:X,title:V,description:U,summary:K,accessibleTable:Q,categoryLabel:Z,valueLabel:J}=i,ee=t.useMemo(()=>v(s),[s]),te=xr({data:ee,rawData:s,colorBy:p,colorScheme:y,legendInteraction:N,legendPosition:E,selection:O,linkedHover:M,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:C,onClick:_,hoverHighlight:P,chartType:"ViolinPlot",chartId:L,showLegend:X,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:z,height:Y}),oe=Zs({brushProp:w,onBrushProp:A,linkedBrush:j,valueAccessor:u});if(te.earlyReturn)return te.earlyReturn;const ne=Ii(),ie=t.useMemo(()=>new Map,[ee]),re=Vs({colorBy:p,colorScale:te.colorScale,color:D,themeCategorical:ne,colorScheme:y,categoryIndexMap:ie,userPieceStyle:void 0,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),se=t.useMemo(()=>ea({valueAccessor:u}),[u]),ae=yr({componentName:"ViolinPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(or,{componentName:"ViolinPlot",message:ae,width:z,height:Y});const 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({chartType:"violin"},null!=s&&{data:ee}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:re,bins:h,showIQR:g,size:[z,Y],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te.margin,barPadding:m,enableHover:G}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Z,rLabel:J,rFormat:f}),$&&{oFormat:$}),{showGrid:q,showCategoryTicks:W}),te.legendBehaviorProps),Tr({title:V,description:U,summary:K,accessibleTable:Q,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:b,defaultTooltipContent:se})),Rr({linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior})),x&&x.length>0&&{annotations:x}),k&&{rExtent:k}),oe.brushStreamProps),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"ViolinPlot",width:z,height:Y,children:e.jsx(qs,Object.assign({ref:r},le))})});na.displayName="ViolinPlot";const ia=t.forwardRef(function(o,n){var i;const r=Xi(o.mode,{width:o.width,height:o.height,showGrid:null===(i=o.showGrid)||void 0===i||i,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),s=t.useRef(null);Ar(n,{variant:"xy",frameRef:s});const{data:a,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,sort:y="auto",dotRadius:m=5,categoryPadding:b=10,tooltip:x,annotations:k,regression:w,valueExtent:A,frameProps:j={},selection:S,linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,chartId:P,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:E,stroke:D,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:W,height:$,enableHover:z,showGrid:Y,showLegend:G,title:q,description:X,summary:V,accessibleTable:U,categoryLabel:K,valueLabel:Q}=r,Z=t.useMemo(()=>v(a),[a]),J=xr({data:Z,rawData:a,colorBy:f,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof u?u:""],unwrapData:!0,onObservation:M,onClick:C,hoverHighlight:_,chartType:"DotPlot",chartId:P,showLegend:G,userMargin:l,marginDefaults:r.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:W,height:$});if(J.earlyReturn)return J.earlyReturn;const ee=Wi(Z,y,d),te=Ii(),oe=t.useMemo(()=>new Map,[Z]),ne=Vs({colorBy:f,colorScale:J.colorScale,color:E,themeCategorical:te,colorScheme:p,categoryIndexMap:oe,userPieceStyle:null==j?void 0:j.pieceStyle,stroke:D,strokeWidth:I,opacity:H,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection,baseStyleExtras:{r:m,fillOpacity:.8}}),ie=t.useMemo(()=>tr({categoryAccessor:u,valueAccessor:d,valueFormat:g}),[u,d,g]),re=yr({componentName:"DotPlot",data:a,accessors:{categoryAccessor:u,valueAccessor:d}});if(re)return e.jsx(or,{componentName:"DotPlot",message:re,width:W,height:$});const se=$r(w),ae=se?[se,...k||[]]:k,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({chartType:"point"},null!=a&&{data:ee}),{oAccessor:u,rAccessor:d,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ne,size:[W,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,barPadding:b,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:r.showAxes,oLabel:K,rLabel:Q,rFormat:g}),F&&{oFormat:F}),{showGrid:Y,oSort:y}),J.legendBehaviorProps),Tr({title:q,description:X,summary:V,accessibleTable:U,className:c,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:x,defaultTooltipContent:ie})),Rr({linkedHover:O,onObservation:M,onClick:C,hoverHighlight:_,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior})),ae&&ae.length>0&&{annotations:ae}),A&&{rExtent:A}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"DotPlot",width:W,height:$,children:e.jsx(qs,Object.assign({ref:s},le))})});ia.displayName="DotPlot";const ra=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",bins:h=20,amplitude:g=1.5,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:m=5,tooltip:b,annotations:x,valueExtent:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:O,hoverHighlight:M,chartId:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:N,strokeWidth:E,opacity:D,showCategoryTicks:I,categoryFormat:H}=o,{width:F,height:W,enableHover:$,showGrid:z,showLegend:Y,title:G,description:q,summary:X,accessibleTable:V,categoryLabel:U,valueLabel:K}=i,Q=t.useMemo(()=>v(s),[s]),Z=xr({data:Q,rawData:s,colorBy:p,colorScheme:y,legendInteraction:T,legendPosition:R,selection:A,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:O,hoverHighlight:M,chartType:"RidgelinePlot",chartId:C,showLegend:Y,userMargin:a,marginDefaults:i.marginDefaults,loading:_,loadingContent:P,emptyContent:L,width:F,height:W});if(Z.earlyReturn)return Z.earlyReturn;const J=Ii(),ee=t.useMemo(()=>new Map,[Q]),te=Vs({colorBy:p,colorScale:Z.colorScale,color:B,themeCategorical:J,colorScheme:y,categoryIndexMap:ee,userPieceStyle:void 0,stroke:N,strokeWidth:E,opacity:D,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),oe=t.useMemo(()=>ea(),[]),ne=yr({componentName:"RidgelinePlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ne)return e.jsx(or,{componentName:"RidgelinePlot",message:ne,width:F,height:W});const 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({chartType:"ridgeline"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:te,bins:h,size:[F,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:m,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:f}),H&&{oFormat:H}),{showGrid:z,showCategoryTicks:I,oSort:!1,amplitude:g}),Z.legendBehaviorProps),Tr({title:G,description:q,summary:X,accessibleTable:V,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:b,defaultTooltipContent:oe})),Rr({linkedHover:j,onObservation:S,onClick:O,hoverHighlight:M,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior})),x&&x.length>0&&{annotations:x}),k&&{rExtent:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"RidgelinePlot",width:F,height:W,children:e.jsx(qs,Object.assign({ref:r},ie))})});ra.displayName="RidgelinePlot";const sa=t.forwardRef(function(o,n){var i,r;const s=Xi(o.mode,{width:null!==(i=o.width)&&void 0!==i?i:400,height:null!==(r=o.height)&&void 0!==r?r:400,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:o.showCategoryTicks}),a=t.useRef(null),{data:l,margin:c,className:u,categoryAccessor:d="category",valueAccessor:h="value",colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:O,loading:M,loadingContent:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:E,height:D,enableHover:I,showLegend:H,title:F,description:W,summary:$,accessibleTable:z}=s,Y=t.useMemo(()=>v(l),[l]),G=g||d,q=xr({data:Y,rawData:l,colorBy:G,colorScheme:f,legendInteraction:P,legendPosition:L,selection:k,linkedHover:w,fallbackFields:G?["string"==typeof G?G:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"PieChart",chartId:O,showLegend:H,userMargin:c,marginDefaults:s.marginDefaults,loading:M,loadingContent:C,emptyContent:_,width:E,height:D});if(q.earlyReturn)return q.earlyReturn;const X=Ii(),V=t.useMemo(()=>new Map,[Y]),U=Vs({colorBy:G,colorScale:q.colorScale,color:T,themeCategorical:X,colorScheme:f,categoryIndexMap:V,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),K=t.useMemo(()=>tr({categoryAccessor:d,valueAccessor:h,groupAccessor:g&&g!==d?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[d,h,g]),Q=yr({componentName:"PieChart",data:l,accessors:{categoryAccessor:d,valueAccessor:h}}),{effectiveLegendProps:Z,effectiveMargin:J}=Xs({ref:n,frameRef:a,setup:q}),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({chartType:"pie"},null!=l&&{data:Y}),{oAccessor:d,rAccessor:h,projection:"radial",pieceStyle:U,startAngle:p}),null!=y&&{cornerRadius:y}),{size:[E,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J,enableHover:I}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),Z),Tr({title:F,description:W,summary:$,accessibleTable:z,className:u,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:K})),Rr({linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,customHoverBehavior:q.customHoverBehavior,customClickBehavior:q.customClickBehavior})),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return Q?e.jsx(or,{componentName:"PieChart",message:Q,width:E,height:D}):e.jsx(sr,{componentName:"PieChart",width:E,height:D,children:e.jsx(qs,Object.assign({ref:a},ee))})});sa.displayName="PieChart";const aa=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover,showCategoryTicks:o.showCategoryTicks},{width:400,height:400}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d,centerContent:h,colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:O,loading:M,loadingContent:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:E,height:D,enableHover:I,showLegend:H,title:F,description:W,summary:$,accessibleTable:z}=i,Y=t.useMemo(()=>v(s),[s]),G=g||c,q=xr({data:Y,rawData:s,colorBy:G,colorScheme:f,legendInteraction:P,legendPosition:L,selection:k,linkedHover:w,fallbackFields:G?["string"==typeof G?G:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"DonutChart",chartId:O,showLegend:H,userMargin:a,marginDefaults:i.marginDefaults,loading:M,loadingContent:C,emptyContent:_,width:E,height:D});if(q.earlyReturn)return q.earlyReturn;const X=null!=d?d:Math.max(2,.15*Math.min(E,D)),V=Ii(),U=t.useMemo(()=>new Map,[Y]),K=Vs({colorBy:G,colorScale:q.colorScale,color:T,themeCategorical:V,colorScheme:f,categoryIndexMap:U,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),Q=t.useMemo(()=>tr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),Z=yr({componentName:"DonutChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}}),{effectiveLegendProps:J,effectiveMargin:ee}=Xs({ref:n,frameRef:r,setup:q}),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({chartType:"donut"},null!=s&&{data:Y}),{oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:K,innerRadius:X,startAngle:p}),null!=y&&{cornerRadius:y}),{centerContent:h,size:[E,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee,enableHover:I}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),J),Tr({title:F,description:W,summary:$,accessibleTable:z,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:Q})),Rr({linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,customHoverBehavior:q.customHoverBehavior,customClickBehavior:q.customClickBehavior})),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return Z?e.jsx(or,{componentName:"DonutChart",message:Z,width:E,height:D}):e.jsx(sr,{componentName:"DonutChart",width:E,height:D,children:e.jsx(qs,Object.assign({ref:r},te))})});function la(e=240){const t=360-e,o=180+t/2,n=o*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:o,startAngleRad:n,offsetRad:-Math.PI/2+n}}aa.displayName="DonutChart";const ca=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:!1,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:300,height:250}),r=t.useRef(null),s="context"===o.mode,{compactMode:a}=i,{value:l,min:c=0,max:u=100,thresholds:d,color:h,backgroundColor:g="var(--semiotic-grid, #e0e0e0)",arcWidth:f=.3,cornerRadius:p,showNeedle:y=!0,needleColor:m="var(--semiotic-text, #333)",centerContent:v,valueFormat:b,showScaleLabels:x=!a,sweep:k=240,fillZones:w=!0,tooltip:A,annotations:j,frameProps:S={},className:O,stroke:M,strokeWidth:C,opacity:_}=o,{width:P,height:L,title:T,description:R,summary:B,accessibleTable:N}=i,E=Math.max(c,Math.min(u,l)),D=u-c||1,I=(E-c)/D,{gaugeData:H,pieceStyle:F,gaugeAnnotations:W}=t.useMemo(()=>{const e=[],t=new Map,o=[];let n=d&&d.length>0?[...d].sort((e,t)=>e.value-t.value):[{value:u,color:h||"var(--semiotic-primary, #007bff)"}];n=n.map(e=>Object.assign(Object.assign({},e),{value:Math.max(c,Math.min(u,e.value))})),u>n[n.length-1].value&&n.push({value:u,color:n[n.length-1].color});let i=c;for(let o=0;n.length>o;o++){const r=n[o],s=(r.value-i)/D;if(w){const n=(i-c)/D,a=Math.max(0,Math.min(I,(r.value-c)/D)-n),l=s-a;if(a>0){const n="fill-"+o;e.push({category:n,value:a,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}if(l>0){const n="bg-"+o;e.push({category:n,value:l,_zone:r.label||"Zone "+(o+1),_isFill:!1}),t.set(n,{fill:g,opacity:.4})}}else{const n="zone-"+o;e.push({category:n,value:s,_zone:r.label||"Zone "+(o+1),_isFill:!0}),t.set(n,{fill:r.color})}i=r.value}if(x&&d&&d.length>0)for(const e of d)e.value>c&&u>e.value&&o.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:e,pieceStyle:(e,o)=>t.get(o||e.category)||{fill:g},gaugeAnnotations:o}},[l,c,u,d,h,g,I,D,x,w]),$=t.useMemo(()=>kr(F,{stroke:M,strokeWidth:C,opacity:_}),[F,M,C,_]),{sweepRad:z,startAngleDeg:Y}=la(k),G=function(e=240){const{sweepRad:t,offsetRad:o}=la(e),n=[[Math.cos(o),Math.sin(o)],[Math.cos(o+t),Math.sin(o+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-o)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||n.push([Math.cos(e),Math.sin(e)]);const i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.min(...i),a=Math.max(...i),l=Math.min(...r),c=Math.max(...r);return{minX:s,maxX:a,minY:l,maxY:c,width:a-s,height:c-l,cx:(s+a)/2,cy:(l+c)/2}}(k),q=Math.min(10,Math.max(1,Math.min(P,L)/12)),X=G.cx,V=G.cy,U=Math.max(4,Math.min((P-2*q)/G.width,(L-2*q)/G.height)-2),K=Math.max(0,Math.min(U-1.5,U*(1-f))),Q=P/2-X*U,Z=L/2-V*U,J=2*(U+4),ee=t.useMemo(()=>{if(a&&null==v)return null;if(null!=v)return"function"==typeof v?v(E,c,u):v;const t=b?b(E):Math.round(E)+"";return e.jsxs("div",{style:{textAlign:"center",lineHeight:1.2},children:[e.jsx("div",{style:{fontSize:Math.max(16,.3*U),fontWeight:700,color:"var(--semiotic-text, #333)"},children:t}),x&&e.jsxs("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",u]})]})},[v,E,c,u,b,x,U,a]),te=t.useMemo(()=>s&&null==v?{type:"gauge-value",text:b?b(E):Math.round(E)+""}:null,[s,v,E,b]),oe=t.useMemo(()=>{if(!y)return null;const e=-Math.PI/2+Y*Math.PI/180+I*z,t=K>20?K-8:U-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:m}},[y,I,Y,z,K,m]),ne=t.useMemo(()=>(t,o,n)=>{if("gauge-needle"===t.type){const i=(n.width||P)/2,r=(n.height||L)/2,s=Math.max(1,U-K),a=Math.max(1,Math.min(2.5,.4*s)),l=Math.max(1,Math.min(5,.6*s));return e.jsxs("g",{transform:`translate(${i},${r})`,children:[e.jsx("line",{x1:0,y1:0,x2:t.tipX,y2:t.tipY,stroke:t.color,strokeWidth:a,strokeLinecap:"round"}),e.jsx("circle",{cx:0,cy:0,r:l,fill:t.color})]},"gauge-needle-"+o)}if("gauge-label"===t.type){const i=-Math.PI/2+Y*Math.PI/180+(t.value-c)/D*z,r=K-14,s=(n.height||L)/2;return e.jsx("text",{x:(n.width||P)/2+Math.cos(i)*r,y:s+Math.sin(i)*r,textAnchor:"middle",dominantBaseline:"middle",fontSize:9,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none"},children:t.label},"gauge-label-"+o)}return"gauge-value"===t.type?e.jsx("text",{x:(n.width||P)/2,y:(n.height||L)/2-.2*K,textAnchor:"middle",dominantBaseline:"middle",fontSize:Math.max(12,Math.min(22,.28*U)),fontWeight:700,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:t.text},"gauge-value-"+o):null},[P,L,c,D,Y,z,K,U]),ie=t.useMemo(()=>{const e=[...W,...j||[]];return oe&&e.push(oe),te&&e.push(te),e},[W,j,oe,te]),re=t.useMemo(()=>t=>{var o;const n=(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o[0])||(null==t?void 0:t.data)||t,i=null==n?void 0:n._isFill;return e.jsxs("div",{className:"semiotic-tooltip",style:{padding:"6px 10px",background:"var(--semiotic-tooltip-bg, white)",borderRadius:"var(--semiotic-tooltip-radius, 6px)",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0,0,0,0.15))"},children:[e.jsx("div",{style:{fontWeight:600},children:(null==n?void 0:n._zone)||""}),e.jsx("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:i?"Current: "+Math.round(E):"Remaining"})]})},[E]);if(0===H.length)return e.jsx(or,{componentName:"GaugeChart",message:"No data to display",width:P,height:L});const se=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:H,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:$,innerRadius:K,startAngle:Y,sweepAngle:k},null!=p&&{cornerRadius:p}),{centerContent:ee,size:[P,L],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:{top:Z-J/2,bottom:L-Z-J/2,left:Q-J/2,right:P-Q-J/2},enableHover:i.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===A?()=>null:gn(A)||re,svgAnnotationRules:ne}),ie.length>0&&{annotations:ie}),T&&{title:T}),R&&{description:R}),B&&{summary:B}),void 0!==N&&{accessibleTable:N}),O&&{className:O}),null!=o.animate&&{animate:o.animate}),S);return e.jsx(sr,{componentName:"GaugeChart",width:P,height:L,children:e.jsx(qs,Object.assign({ref:r},se))})});ca.displayName="GaugeChart";const ua=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:!1,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:!1}),r=t.useRef(null);Ar(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,stepAccessor:c="step",valueAccessor:u="value",categoryAccessor:d,colorBy:h,colorScheme:g,orientation:f="horizontal",connectorOpacity:p=.3,showLabels:y=!0,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:O,loading:M,loadingContent:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N,categoryFormat:E}=o,D="vertical"===f,{width:I,height:H,enableHover:F,showLegend:W,title:$,description:z,summary:Y,accessibleTable:G}=i,q=D?{top:$?60:40,right:20,bottom:60,left:60}:{top:$?40:10,right:10,bottom:10,left:10},X=t.useMemo(()=>v(s),[s]),V=h||d,U=!V,K=xr({data:X,rawData:s,colorBy:V,colorScheme:g,legendInteraction:P,legendPosition:L,selection:k,linkedHover:w,fallbackFields:V?["string"==typeof V?V:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"FunnelChart",chartId:O,showLegend:W,userMargin:a,marginDefaults:q,loading:M,loadingContent:C,emptyContent:_,width:I,height:H});if(K.earlyReturn)return K.earlyReturn;dr("FunnelChart",X,"stepAccessor",c),dr("FunnelChart",X,"valueAccessor",u);const Q=Ii(),Z=t.useMemo(()=>new Map,[X]),J=t.useMemo(()=>{if(U)return T||((null==Q?void 0:Q[0])?Q[0]:Array.isArray(g)&&g[0]?g[0]:"#4e79a7")},[U,T,Q,g]),ee=Vs({colorBy:J?void 0:V,colorScale:K.colorScale,color:null!=J?J:T,themeCategorical:Q,colorScheme:g,categoryIndexMap:Z,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection}),te=t.useMemo(()=>t=>{var o,n,i,r,s,a;const l=(null==t?void 0:t.data)||t,c=(null==l?void 0:l.__funnelStep)||(null==l?void 0:l.__barFunnelStep)||(null==l?void 0:l.step)||"",u=null!==(i=null!==(n=null!==(o=null==l?void 0:l.__funnelValue)&&void 0!==o?o:null==l?void 0:l.__barFunnelValue)&&void 0!==n?n:null==l?void 0:l.value)&&void 0!==i?i:"",d=null!==(r=null==l?void 0:l.__funnelPercent)&&void 0!==r?r:null==l?void 0:l.__barFunnelPercent,h=null!==(s=null==l?void 0:l.__funnelIsFirstStep)&&void 0!==s?s:null==l?void 0:l.__barFunnelIsFirstStep,g=null==l?void 0:l.__barFunnelIsDropoff,f=null!==(a=null==l?void 0:l.__barFunnelCategory)&&void 0!==a?a:null==l?void 0:l.category,p=null==d||h?"":` (${.05>Math.abs(d-Math.round(d))?Math.round(d)+"%":d.toFixed(1)+"%"})`;return e.jsxs("div",{className:"semiotic-tooltip",style:ln,children:[c&&e.jsx("div",{style:{fontWeight:"bold"},children:c+""}),f&&f!==c&&e.jsx("div",{style:{marginTop:2,opacity:.8},children:f+""}),g&&e.jsx("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),e.jsxs("div",{style:{marginTop:4},children:[u+"",p]})]})},[]),oe=yr({componentName:"FunnelChart",data:s,accessors:{stepAccessor:c,valueAccessor:u}});if(oe)return e.jsx(or,{componentName:"FunnelChart",message:oe,width:I,height:H});const 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(Object.assign({chartType:D?"bar-funnel":"funnel"},null!=s&&{data:X}),{oAccessor:c,rAccessor:u}),d&&{stackBy:d}),{projection:D?"vertical":"horizontal",barPadding:D?40:0,pieceStyle:ee,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:K.margin,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:D,showCategoryTicks:D}),E&&{oFormat:E}),{showGrid:D}),!D&&{connectorOpacity:p}),{showLabels:y}),K.legendBehaviorProps),$&&{title:$}),z&&{description:z}),Y&&{summary:Y}),void 0!==G&&{accessibleTable:G}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:!0===m||null==m?te:gn(m)||te}),(w||A||j||S)&&{customHoverBehavior:K.customHoverBehavior}),(A||j||w)&&{customClickBehavior:K.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return e.jsx(sr,{componentName:"FunnelChart",width:I,height:H,children:e.jsx(qs,Object.assign({ref:r},ne))})});ua.displayName="FunnelChart";const da={RdBu:ce,PiYG:ue,PRGn:de,BrBG:he,RdYlBu:ge,RdYlGn:fe,Spectral:pe},ha="__likert_neutral_neg",ga="__likert_neutral_pos";function fa(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function pa(e,t,o,n,i,r){const s=new Map,a=new Set(t);for(const l of e){const e=o(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(n){const e=n(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const i=t[o];c.set(i,(c.get(i)||0)+1)}else if(i&&r){const e=i(l),t=r(l);if(!a.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,o]of s){let n=0;for(const e of t)n+=o.get(e)||0;if(0!==n)for(let i=0;t.length>i;i++){const r=t[i],s=o.get(r)||0;l.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/n*100,__likertLevelIndex:i})}}return l}function ya(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(n&&e===i){const e=t.__likertPct/2;r.push(Object.assign(Object.assign({},t),{__likertLevel:ha,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:ga,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function ma(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=new Map;for(const t of e){const e=r.get(t.__likertCategory)||[];e.push(t),r.set(t.__likertCategory,e)}const s=[];for(const[,e]of r){const t=new Map;let r,a;for(const o of e)o.__likertLevel===ha?r=o:o.__likertLevel===ga?a=o:t.set(o.__likertLevelIndex,o);n&&r&&s.push(r);for(let e=i-1;e>=0;e--){const o=t.get(e);o&&s.push(o)}n&&a&&s.push(a);for(let e=n?i+1:i;o>e;e++){const o=t.get(e);o&&s.push(o)}}return s}const va=new Map,ba=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="question",valueAccessor:u,levelAccessor:d,countAccessor:h="count",levels:g,orientation:f="horizontal",colorScheme:y,barPadding:m=20,tooltip:v,annotations:b,valueExtent:x,frameProps:k={},selection:w,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:O,chartId:M,valueFormat:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,legendPosition:R,categoryFormat:B,stroke:N,strokeWidth:E,opacity:D}=o,{width:I,height:H,enableHover:F,showGrid:W,showLegend:$,title:z,description:Y,summary:G,accessibleTable:q,categoryLabel:X,valueLabel:V}=i,U="horizontal"===f,K=void 0===s,Q=!d,Z=function(){var e;const t=Bi();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.diverging)||void 0}(),J=t.useMemo(()=>y&&Array.isArray(y)&&y.length>=g.length?y:function(e,t){if(0>=e)return[];if(t){const o=da[t];if(o){if(1===e)return[o(.5)];const t=[];for(let n=0;e>n;n++)t.push(o(n/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],i="#a8a8a8";if(1===e)return[i];const r=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);r&&a.push(i);for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);return a}(g.length,Z),[y,g.length,Z]),ee=t.useMemo(()=>{const e=new Map;for(let t=0;g.length>t;t++)e.set(g[t],J[t]||"#888");return e},[g,J]),{processedData:te,reAggregate:oe,accumulatorRef:ne}=function({data:e,levels:o,categoryAccessor:n,valueAccessor:i,levelAccessor:r,countAccessor:s,isDiverging:a,frameRef:l}){const c=!r,u=t.useMemo(()=>fa(n,"question"),[n]),d=t.useMemo(()=>c?fa(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:fa(r,"level"),[c,r]),g=t.useMemo(()=>c?null:fa(s,"count"),[c,s]),f=e||[],p=t.useRef([]),y=t.useMemo(()=>{if(0===f.length)return[];let e=pa(f,o,u,d,h,g);return a&&(e=ya(e,o),e=ma(e,o)),e},[f,o,u,d,h,g,a]),m=t.useCallback(e=>{var t;let n=pa(e,o,u,d,h,g);a&&(n=ya(n,o),n=ma(n,o)),null===(t=l.current)||void 0===t||t.replace(n)},[o,u,d,h,g,a,l]);return{processedData:y,reAggregate:m,accumulatorRef:p}}({data:s,levels:g,categoryAccessor:c,valueAccessor:u,levelAccessor:d,countAccessor:h,isDiverging:U,frameRef:r}),ie="__likertLevelLabel",re=function({isPushMode:e,colorBy:o,colorScheme:n,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=oi(),d=Ii(),h=t.useCallback(e=>{const t=e[o];return null!=t?t+"":null},[o]),g=t.useCallback(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=h(e);null==t||s.current.has(t)||(s.current.add(t),a.current.push(t),n=!0)}n&&c(e=>e+1)},[e,o,h]),f=t.useCallback(t=>{if(!e||!o)return;const n=Array.from(new Set(t.map(String))),i=a.current;i.length===n.length&&i.every((e,t)=>e===n[t])||(s.current=new Set(n),a.current=n,c(e=>e+1))},[e,o]),p=t.useCallback(e=>t=>{g([t]),e(t)},[g]),y=t.useCallback(e=>t=>{g(t),e(t)},[g]),m=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]);xi(e&&o?a.current:[]);const v=t.useMemo(()=>{if(!e||!o||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(n)&&n.length>0||"string"==typeof n&&n.length>0?n:d&&d.length>0?d:ve,s=o,l=t.map(e=>({[s]:e})),c=we(l,s,r);return ji({data:l,colorBy:s,colorScale:e=>(null==u?void 0:u[e])||c(e)||"#999",getColor:ke})},[e,o,i,n,u,d,l]),b=t.useMemo(()=>{if(v)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[v,r]);return{wrapPush:p,wrapPushMany:y,resetCategories:m,categories:a.current,categoryDomainProps:e&&o?{legendCategoryAccessor:o,onCategoriesChange:f}:{},streamingLegend:v,streamingMarginAdjust:b}}({isPushMode:K,colorBy:ie,colorScheme:J,showLegend:$,legendPosition:R}),se=t.useCallback(re.wrapPush(e=>{ne.current.push(e),oe(ne.current)}),[re.wrapPush,oe,ne]),ae=t.useCallback(re.wrapPushMany(e=>{ne.current.push(...e),oe(ne.current)}),[re.wrapPushMany,oe,ne]);t.useImperativeHandle(n,()=>({push:se,pushMany:ae,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ne.current=[],re.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}}),[se,ae,re.resetCategories,ne]);const le=xr({data:te,rawData:s,colorBy:ie,colorScheme:J,legendInteraction:T,legendPosition:R,selection:w,linkedHover:A,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:O,chartType:"LikertChart",chartId:M,showLegend:$,userMargin:a,marginDefaults:i.marginDefaults,loading:_,loadingContent:P,emptyContent:L,width:I,height:H});if(le.earlyReturn)return le.earlyReturn;const ce=t.useMemo(()=>{const e=g.length;return e%2!=0&&ee.get(g[Math.floor(e/2)])||"#888"},[g,ee]),ue=Vs({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:va,userPieceStyle:null==k?void 0:k.pieceStyle,stroke:N,strokeWidth:E,opacity:D,effectiveSelectionHook:le.effectiveSelectionHook,resolvedSelection:le.resolvedSelection,baseStyleExtras:e=>{var t,o;const n=e.__likertLevelLabel||(null===(t=e.data)||void 0===t?void 0:t.__likertLevelLabel),i=e.__likertLevel||(null===(o=e.data)||void 0===o?void 0:o.__likertLevel);if(i===ha||i===ga)return{fill:ce};const r=n||i;return r&&ee.has(r)?{fill:ee.get(r)}:{fill:"#888"}}}),de=t.useMemo(()=>{const e=g.length;return e%2!=0?g[Math.floor(e/2)]:""},[g]),he=t.useMemo(()=>e=>{const t=e.data||e,o=t.__likertLevel||"Unknown",n=o===ha||o===ga?de:o,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=o===ha||o===ga?2*r:r,a=t.__likertCount||0;return p.createElement("div",{className:"semiotic-tooltip",style:ln},p.createElement("div",{style:{fontWeight:"bold"}},i),p.createElement("div",{style:{marginTop:4}},`${n}: ${s.toFixed(1)}% (n=${a})`))},[de]),ge=t.useMemo(()=>{if(!g||2>g.length)return"LikertChart requires `levels` with at least 2 entries.";if(u&&d)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(d&&!h)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==s&&0===s.length)return null;const e={categoryAccessor:c};return Q?u&&(e.valueAccessor=u):(d&&(e.levelAccessor=d),h&&(e.countAccessor=h)),yr({componentName:"LikertChart",data:s,accessors:e,requiredProps:{levels:g}})},[s,c,u,d,h,g,Q]),fe=t.useMemo(()=>[{styleFn:e=>({fill:ee.get(e.label)||"#888"}),items:g.map(e=>({label:e})),label:""}],[g,ee]),pe=t.useMemo(()=>!1!==$?Object.assign(Object.assign({},le.legendBehaviorProps),{legend:{legendGroups:fe},legendPosition:R||le.legendPosition||"bottom"}):le.legendBehaviorProps,[le.legendBehaviorProps,le.legendPosition,R,$,fe]),ye=t.useMemo(()=>{const e=Object.assign({},le.margin);if(K&&!1!==$){const t=R||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(re.streamingMarginAdjust)for(const[t,o]of Object.entries(re.streamingMarginAdjust))o>e[t]&&(e[t]=o);return U&&100>e.left&&(e.left=100),e},[le.margin,re.streamingMarginAdjust,U,K,$,R]),me=t.useMemo(()=>C||(U?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[U,C]),be=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:"bar"},null!=s&&{data:te}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:U?"horizontal":"vertical",pieceStyle:ue,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ye,barPadding:m,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:X,rLabel:V||(U?void 0:"Percentage"),rFormat:me}),B&&{oFormat:B}),{showGrid:W}),pe),z&&{title:z}),Y&&{description:Y}),G&&{summary:G}),void 0!==q&&{accessibleTable:q}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:!1===v?()=>null:!0===v?he:gn(v)||he}),(A||j||S||O)&&{customHoverBehavior:le.customHoverBehavior}),(j||S||A)&&{customClickBehavior:le.customClickBehavior}),b&&b.length>0&&{annotations:b}),x&&{rExtent:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return ge?e.jsx(or,{componentName:"LikertChart",message:ge,width:I,height:H}):e.jsx(sr,{componentName:"LikertChart",width:I,height:H,children:e.jsx(qs,Object.assign({ref:r},be))})});ba.displayName="LikertChart";const xa=t.forwardRef(function(o,n){const i=Xi(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",subcategoryAccessor:u,valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,barPadding:y,tooltip:m,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:A={},selection:j,linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,loadingContent:L,emptyContent:T,legendInteraction:R,legendPosition:B,color:N,stroke:E,strokeWidth:D,opacity:I,categoryFormat:H,rTickValues:F,tickLabelEdgeAlign:W,showCategoryTicks:$,gradientFill:z,trackFill:Y,roundedTop:G,valueExtent:q}=o,{width:X,height:V,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,categoryLabel:oe,valueLabel:ne}=i,ie=t.useMemo(()=>v(s),[s]),re=f||u,se=t.useMemo(()=>{if(null!=y)return y;if("sparkline"!==o.mode)return 40;const e=new Set(ie.map(e=>"function"==typeof c?c(e):e[c])),t=Math.max(1,e.size);return t>1?Math.max(0,Math.min(1,(("horizontal"===h?V:X)-2*t)/(t-1))):1},[y,o.mode,ie,c,h,X,V]),ae=xr({data:ie,rawData:s,colorBy:re,colorScheme:p,legendInteraction:R,legendPosition:B,selection:j,linkedHover:S,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:C,chartType:"SwimlaneChart",chartId:_,showLegend:Q,userMargin:a,marginDefaults:i.marginDefaults,loading:P,loadingContent:L,emptyContent:T,width:X,height:V}),le=Zs({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:d});if(ae.earlyReturn)return ae.earlyReturn;const ce=Ii(),ue=t.useMemo(()=>new Map,[ie]),de=Vs({colorBy:re,colorScale:ae.colorScale,color:N,themeCategorical:ce,colorScheme:p,categoryIndexMap:ue,userPieceStyle:null==A?void 0:A.pieceStyle,stroke:E,strokeWidth:D,opacity:I,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.resolvedSelection,cycleByCategory:!0}),he=t.useMemo(()=>tr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ge=yr({componentName:"SwimlaneChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d,subcategoryAccessor:u},requiredProps:{subcategoryAccessor:u}}),{effectiveLegendProps:fe,effectiveMargin:pe}=Xs({ref:n,frameRef:r,setup:ae}),ye=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:"swimlane"},null!=s&&{data:ie}),{oAccessor:c,rAccessor:d,stackBy:u,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:de,size:[X,V],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:pe,barPadding:se,enableHover:U}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:!1===$?void 0:oe,rLabel:ne,rFormat:g}),F&&{rTickValues:F}),null!=W&&{tickLabelEdgeAlign:W}),H&&{oFormat:H}),void 0!==$&&{showCategoryTicks:$}),{showGrid:K}),fe),Tr({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:o.animate,axisExtent:o.axisExtent})),Br({tooltip:m,defaultTooltipContent:he})),Rr({linkedHover:S,onObservation:O,onClick:M,hoverHighlight:C,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior})),b&&b.length>0&&{annotations:b}),z&&{gradientFill:!0===z?{topOpacity:.8,bottomOpacity:.05}:z}),null!=Y&&{trackFill:Y}),null!=G&&{roundedTop:G}),q&&{rExtent:q}),le.brushStreamProps),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return ge?e.jsx(or,{componentName:"SwimlaneChart",message:ge,width:X,height:V}):e.jsx(sr,{componentName:"SwimlaneChart",width:X,height:V,children:e.jsx(qs,Object.assign({ref:r},ye))})});xa.displayName="SwimlaneChart";const ka={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},wa={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Aa{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const o=this.particles[t];return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,o,n){var i;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const a=o[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(r);continue}const l=n&&null!==(i=n[s.edgeIndex])&&void 0!==i?i:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?ja(a.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let o=0;e>o;o++)t.length>o?this.particles[o]=t[o]:(this.particles[o]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(o));this.capacity=e}}function ja(e,t,o,n){if(e.circular&&e.segments)return void function(e,t,o,n,i){const r=e.length,s=t*r,a=Math.min(Math.floor(s),r-1),l=s-a,[c,u,d,h]=e[a];Sa(c,u,d,h,l,i);const g=h.x-c.x,f=h.y-c.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;i.x+=-f/p*o*n*2,i.y+=e*o*n*2}}(e.segments,t,o,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[i,r,s,a]=e.points;Sa(i,r,s,a,t,n);const l=a.x-i.x,c=a.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;n.x+=-c/u*o*e.halfWidth*2,n.y+=t*o*e.halfWidth*2}}function Sa(e,t,o,n,i,r){const s=1-i,a=s*s,l=a*s,c=i*i,u=c*i;r.x=l*e.x+3*a*i*t.x+3*s*c*o.x+u*n.x,r.y=l*e.y+3*a*i*t.y+3*s*c*o.y+u*n.y}function Oa(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function Ma(e,t){var o,n=[],i=[],r=[],s={},a=[];function l(e){r[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],r[t]&&l(t)})}function c(e){var t,n,d=!1;for(i.push(e),r[e]=!0,t=0;a[e].length>t;t++)(n=a[e][t])===o?(u(o,i),d=!0):r[n]||(d=c(n));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[n=a[e][t]];h||(s[n]=h={}),h[n]=!0}return i.pop(),d}function u(e,t){var o=[].concat(t).concat(e);n.push(o)}function d(t){!function(t){for(var o=0;e.length>o;o++)o>=t&&e[o]||(e[o]=[]),e[o]=e[o].filter(function(e){return e>=t})}(t);for(var o,n=function(e){for(var t=e.length,o=Array(t),n=Array(t),i=Array(t),r=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)o[l]=-1,n[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(o[t]=n[t]=u,i[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>r[t]){for(var f=r[t];g.length>f;++f){var p=g[f];if(0>o[p]){o[p]=n[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(n[t]=0|Math.min(n[t],n[p])),0>s[p]||a[t].push(s[p])}r[t]=f}else{if(n[t]===o[t]){var y=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(i[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(v);for(f=0;m.length>f;f++)for(var k=0;m[f].length>k;k++)x[--v]=m[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>o[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),i=n.components.filter(function(e){return e.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],o=s);var l=i[o];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:r,adjList:c}}o=0;for(var h=e.length;h>o;){var g=d(o);if(o=g.leastVertex,a=g.adjList){for(var f=0;a.length>f;f++)for(var p=0;a[f].length>p;p++){var y=a[f][p];r[+y]=!1,s[y]={}}c(o),o+=1}else o=h}return n}function Ca(e){return e.y0-e.y1>0?"up":"down"}function _a(e,t){return t(e.source)==t(e.target)}function Pa(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var o=0;return e.target.targetLinks.forEach(function(e){o=e.circular?o+1:o}),1>=t&&1>=o}function La(e){return e.target.x0-e.source.x1}function Ta(e,t){var o=Ba(e),n=La(t)/Math.tan(o);return"up"==Ca(e)?e.y1-n:e.y1+n}function Ra(e,t){var o=Ba(e),n=La(t)/Math.tan(o);return"up"==Ca(e)?e.y1+n:e.y1-n}function Ba(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Na(e,t){return t(e)}function Ea(e){return Ia(e.source)}function Da(e){return Ia(e.target)}function Ia(e){return(e.y0+e.y1)/2}function Ha(e){return e.virtual?0:e.value}function Fa(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!_a(e,t)?o+1:o});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!_a(e,t)?n+1:n}),o+n}function Wa(e){return e.target.depth}function $a(e,t){return e.sourceLinks.length?e.depth:t-1}function za(e,t){return e.y0-t.y0}function Ya(e,t){return t.y0-e.y0}function Ga(e,t){return e.y1-t.y1}function qa(e,t){return t.y1-e.y1}function Xa(e,t){return Ua(e.source,t.source)||e.index-t.index}function Va(e,t){return Ua(e.target,t.target)||e.index-t.index}function Ua(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Ka(e,t){return Qa(e)==Qa(t)?"bottom"==e.circularLinkType?Ya(e,t):za(e,t):Qa(t)-Qa(e)}function Qa(e){return e.target.column-e.source.column}function Za(e,t){return Ja(e)==Ja(t)}function Ja(e){return e.y0-e.y1>0?"up":"down"}function el(e,t,o,n,i){let r=e;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(r.links,function(e){return e.source.y0});r.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=r.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),tl(r.links.filter(function(e){return"top"==e.circularLinkType}),t,o),tl(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,o),r.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,_a(e,t)&&Pa(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,a=e.circularLinkType,c=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?Ya:za);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?qa:Ga),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,o=e.y0,n=e.target.x0,i=e.y1,r=(t+n)/2;return"M"+t+","+o+"C"+r+","+o+" "+r+","+i+" "+n+","+i}(e)}),r}function tl(e,t,o){e.sort(Ka);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(_a(e,t)&&Pa(e))e.circularPathData.verticalBuffer=r+e._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ol(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=l>r?l:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function ol(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function nl(e){return function(){return e}}function il(e){return e.index}function rl(e){return e.nodes}function sl(e){return e.links}function al(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(i,r){var s=i.length;if(t)i.sort(t);else if(r>0){var a=new Map;i.forEach(function(e,t){var o,n,i,r=(n=0,i=0,(o=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Ia(e.source)*t,n+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Ia(e.target)*t,n+=t}}),n>0?i/n:NaN);a.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var o=a.get(e),n=a.get(t),i=o.bc,r=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?o.idx-n.idx:1:-1:i-r})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?Fa(t,o)-Fa(e,o):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==n.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==Fa(t,o)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function ll(e,t,o,n,i,r){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=r;c>0;--c)u(l*=.99,o),d();function u(t,o){var n=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&Fa(i,o)>0){var c=a.mean(i.sourceLinks,Da),u=a.mean(i.targetLinks,Ea),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ia(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==n-1&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var g=a.mean(i.sourceLinks,Da),f=a.mean(i.targetLinks,Ea),p=((g&&f?(g+f)/2:g||f)-Ia(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(o){var r,s,a,l=e.y0,c=o.length;for(o.sort(t||Ua),a=0;c>a;++a)(s=l-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+n;if((s=l-n-e.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=o[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function cl(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Va),e.targetLinks.sort(Xa)}),e.nodes.forEach(function(e){var t=e.y0,o=t,n=e.y1,i=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=o+e.width/2,o+=e.width)})})}function ul(){var e=0,t=0,o=1,n=1,i=24,r=8,s=null,l=il,c=$a,u=void 0,d=32,h=2,g=rl,f=sl;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=o,g.y1=n,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var o=function(e,t){var o=new Map;return a.group(e,t).forEach(function(e,t){o.set(t,e[0])}),o}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,i=e.target;"object"!=typeof n&&(n=e.source=Oa(o,n)),"object"!=typeof i&&(i=e.target=Oa(o,i)),n.sourceLinks.push(e),i.targetLinks.push(e)})}(g,l),function(e,t){var o=0;if(null==t){for(var n=[],i=0;e.links.length>i;i++){var r=e.links[i],s=r.source.index,a=r.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var l=Ma(n);l.sort(function(e,t){return e.length-t.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=o++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=o++)})}(g,u),function(e,t){var o=0,n=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:n>o?"top":"bottom","top"==i.circularLinkType?o++:n++,e.nodes.forEach(function(e){Na(e,t)!=Na(i.source,t)&&Na(e,t)!=Na(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),_a(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Ha),a.sum(e.targetLinks,Ha)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,o){var n,i,r;if(null!=t){e.nodes.sort(function(e,o){return t(e)<t(o)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?o(e,r):e.column})}(g,u,c);var f=r;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(n-t)*s/(y-1)))}(function(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=a.min(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var r=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(r>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-o)/r),t.x1=t.x0+o}:function(t){t.x0=e.x0,t.x1=t.x0+o})})(g,f,i),al(g,u,l),ll(g,u,l,f,f,d),cl(g),el(g,l,h,10,8),al(g,u,l),ll(g,u,l,f,f,d),cl(g),el(g,l,h,10,8),function(e,t){let o=e;o.nodes.forEach(function(e){e.y+(e.y1-e.y0)>o.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-o.y1));var n=o.links.filter(function(o){return Na(o.source,t)==Na(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!Za(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=Ta(t,e);return e.y1-o}if(t.target.column>e.target.column)return Ta(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y0=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})})}(g,l),function(e,t){let o=e;o.nodes.forEach(function(e){var n=o.links.filter(function(o){return Na(o.target,t)==Na(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!Za(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=Ra(t,e);return e.y0-o}if(t.source.column>e.source.column)return Ra(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y1=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})})}(g,l),function(e){var t=e.nodes,o=e.links,n=!1,i=!1;if(o.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==n||0==i){var r=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-r);function c(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),o.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,o=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+o}),e.targetLinks.forEach(function(e){e.y1=e.y1+o})})}}(g),el(g,l,h,10,8)}(p),p}return p.update=function(e){return cl(e),el(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(r=+e,p):r},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:nl(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:nl(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:nl(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:nl(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],o=+i[1][0],n=+i[1][1],p):[[e,t],[o,n]]},p.size=function(i){return arguments.length?(e=t=0,o=+i[0],n=+i[1],p):[o-e,n-t]},p}function dl(e){const{sx:t,sTop:o,sBot:n,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=e,c=(o+n)/2,u=(r+s)/2;return{pathD:[`M${t},${o}`,`C${a},${o} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(n-o)/2}}}const hl=e=>{let t,o,n,i,r,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=u.interpolateNumber(r,s),l=a(.5),c=a(.5),`M${t},${r}C${t},${l} ${o},${c} ${o},${s}L${n},${s}C${n},${c} ${i},${l} ${i},${r}Z`;const d=e.sankeyWidth/2,h=u.interpolateNumber(e.source.x1,e.target.x0),{pathD:g}=dl({sx:e.source.x1,sTop:e.y0-d,sBot:e.y0+d,tx:e.target.x0,tTop:e.y1-d,tBot:e.y1+d,cp1X:h(.5),cp2X:h(.5)});return g};function gl(e){var t;const o=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const t=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${t},${n-o}L${t+a},${n-o}L${t+a},${n+o}L${t},${n+o}ZM${r},${s-o}L${r-l},${s-o}L${r-l},${s+o}L${r},${s+o}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(n,15));return`M${r},${s-h*o}L${c},${s-h*o}L${c+n},${s-h*o+h*g}L${c+n},${d+h*n-h*g}L${c+n-g},${d+h*n}L${u-n+g},${d+h*n}L${u-n},${d+h*n-h*g}L${u-n},${l-h*o+h*g}L${u-n+g},${l-h*o}L${a},${l-h*o}L${a},${l+h*o}L${u+n},${l+h*o}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${s+h*o}L${r},${s+h*o}Z`}const fl=new Set,pl=new WeakMap;function yl(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let o=pl.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,pl.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;fl.has(e)||(fl.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,o,n)}});return o.set(t,n),n}const ml={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(Wa))-1:0},justify:$a};function vl(e){return"string"==typeof e?e:e.id}const bl={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r,s,a,l,c,u;if(0===e.length)return;const d="vertical"===o.orientation?"down":"right",h=o.nodeAlign||"justify",g=null!==(i=o.nodeWidth)&&void 0!==i?i:15,f=null!==(r=o.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=o.iterations)&&void 0!==s?s:100,y=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=ul().extent(v).links(m).nodes(y).nodeAlign(ml[h]||$a).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,o=1/0,i=-1/0;for(const n of y)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),o>n.y0&&(o=n.y0),n.y1>i&&(i=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(null!==(l=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==l?l:0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=t-e,s=i-o,u=n[0],d=n[1];if(r>0&&s>0&&(0>e||0>o||t>u||i>d)){const t=Math.min(u/r,d/s),n=-e*t+(u-r*t)/2,i=-o*t+(d-s*t)/2;for(const e of y)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of m)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const o=e.circularPathData;o.sourceX=o.sourceX*t+n,o.targetX=o.targetX*t+n,o.sourceY=o.sourceY*t+i,o.targetY=o.targetY*t+i,o.rightFullExtent=o.rightFullExtent*t+n,o.leftFullExtent=o.leftFullExtent*t+n,o.verticalFullExtent=o.verticalFullExtent*t+i,o.rightInnerExtent=o.rightInnerExtent*t+n,o.leftInnerExtent=o.leftInnerExtent*t+n,o.verticalRightInnerExtent=o.verticalRightInnerExtent*t+i,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*t+i,o.rightSmallArcRadius*=t,o.rightLargeArcRadius*=t,o.leftSmallArcRadius*=t,o.leftLargeArcRadius*=t,o.sourceWidth*=t,o.rightNodeBuffer*=t,o.leftNodeBuffer*=t,o.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=vl(e.source),o=vl(e.target),n=k.get(e._edgeKey?e._edgeKey:`${t}\0${o}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=d;const i=x.get(t),r=x.get(o);i&&(n.source=i),r&&(n.target=r)}}},buildScene(e,t,o,n){var i,r,s,a,l,c;const u="vertical"===o.orientation?"down":"right",d=o.nodeStyle,h=o.edgeStyle,g=null!==(i=o.edgeOpacity)&&void 0!==i?i:.5,f=o.edgeColorBy||"source",p=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:K,y=new Map;e.forEach((e,t)=>{y.set(e.id,p[t%p.length])});const m=[],v=[],b=[],x=new Map;for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const n=d?d(yl(t,"nodeStyle")):{},i={fill:n.fill||y.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};x.set(t.id,("string"==typeof i.fill?i.fill:null)||y.get(t.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:t.y0,y:t.x0,w:o,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:o,style:i,datum:t,id:t.id,label:t.id})}const k=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of k){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof f?f(e)||i:"target"===f?x.get(n.id)||y.get(n.id)||i:x.get(t.id)||y.get(t.id)||i;const u=h?h(yl(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,o=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),r=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=u.fill||i;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-o}L${t.sourceX+n},${t.sourceY-o}L${t.sourceX+n},${t.sourceY+o}L${t.sourceX},${t.sourceY+o}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:g,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-o}L${t.targetX-r},${t.targetY-o}L${t.targetX-r},${t.targetY+o}L${t.targetX},${t.targetY+o}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:g,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-r,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?gl(e):hl(e),!d)continue;const p={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:g,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:p,datum:e})}if(!1!==o.showLabels){const t=(w=o.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const r=t?t(o):o.id;if(!r)continue;let s,a,l;"down"===u?(s=o.y0+(o.y1-o.y0)/2,a=o.x1+14,l="start"):(n[0]/2>o.x0+e/2?(s=o.x0-6,l="end"):(s=o.x1+6,l="start"),a=o.y0+i/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},xl={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r;if(0===e.length)return;const s=null!==(i=o.forceStrength)&&void 0!==i?i:.1,a=n[0]/2,l=n[1]/2,c=o.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=null==c?void 0:c.get(t.id);e?u++:o?(t.x=o.x,t.y=o.y,u++):h.push(t)}const g=u>0&&.3>=(e.length>0?h.length/e.length:1);if(g){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of h){const n=kl(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const i=wl(e.id),r=i%360*(Math.PI/180),s=10+i%20;e.x=t/n.length+s*Math.cos(r),e.y=o/n.length+s*Math.sin(r)}else{const t=wl(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=a+n*Math.cos(o),e.y=l+n*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),i=o*t;n.x=a+e*Math.cos(i),n.y=l+e*Math.sin(i)}}}const f=null!==(r=o.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===o.iterations?0:g?40:f,y=Al(o.nodeSize,o.nodeSizeRange,e),m=e=>y(e);if(p>0){const o=d.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(a,l).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));o.links(e),n.force("link",o)}g?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;p>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.edgeStyle,g=Al(o.nodeSize,o.nodeSizeRange,e),f=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:K,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=[],m=[],v=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=g(yl(t,"nodeSize")),n=d?d(yl(t,"nodeStyle")):{},a={fill:n.fill||p.get(t.id)||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:2,opacity:n.opacity};y.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:b.get(e.source),n="object"==typeof e.target?e.target:b.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const i=h?h(yl(e,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=o.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=o.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==o.showLabels){const t=(x=o.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=g(yl(o,"nodeSize"));v.push({x:o.x,y:o.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function kl(e,t,o){const n=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=o.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function wl(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function Al(e,t,o){var n,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=o.map(t=>{var o;return null===(o=t.data)||void 0===o?void 0:o[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(n=a.min(l))&&void 0!==n?n:0,u=null!==(r=a.max(l))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var o;const n=null===(o=t.data)||void 0===o?void 0:o[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const jl=K,Sl={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:a}=o,l=Math.min(n[0],n[1])/2,c=l-r,u=n[0]/2,d=n[1]/2,g=(f=o.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=p.get("string"==typeof e.source?e.source:e.source.id),n=p.get(t);if(void 0===o||void 0===n)continue;const i=g(e);m[o][n]=i}const v=h.chord().padAngle(i);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const t of x){const o=e[t.index],n=k.centroid({innerRadius:c,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});o.x=n[0]+u,o.y=n[1]+d,o.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);o&&(e.source=o),n&&(e.target=n)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const o=e[t.source.index].id,n=e[t.target.index].id,i=A.get(`${o}\0${n}`)||A.get(`${n}\0${o}`);i&&(i.__chordData=t)}},buildScene(e,t,o,n){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=o,u=Math.min(n[0],n[1])/2,d=u-l,g=n[0]/2,f=n[1]/2,p=o.nodeStyle,y=o.edgeStyle,m=o.edgeColorBy||"source",v=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:jl,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=h.ribbon().radius(d),k=[],w=[],A=[];for(let t=0;e.length>t;t++){const o=e[t],n=o.__arcData;if(!n)continue;let r;r=p?p(yl(o,"nodeStyle")).fill||b.get(o.id)||v[t%v.length]:b.get(o.id)||v[t%v.length];const s=p?p(yl(o,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};k.push({type:"arc",cx:g,cy:f,innerR:d,outerR:u,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=x(t);if(!n)continue;const i=Ol(n,g,f);let l=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(yl(e,"edgeStyle")).fill||l;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===m&&o?l=b.get(o.id)||l:t&&(l=b.get(t.id)||l)}const u=y?y(yl(e,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:e})}if(!1!==o.showLabels){const t=(j=o.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null,n=u+12;for(const o of e){const e=o.__arcData;if(!e)continue;const i=t?t(o):o.id;if(!i)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;A.push({x:g+Math.cos(s)*n,y:f+Math.sin(s)*n,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var j;return{sceneNodes:k,sceneEdges:w,labels:A}}};function Ol(e,t,o){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const i=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("C"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;3>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("Q"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;2>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("A"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&(i.push(Number(n[r])+t+""),r++),n.length>r&&(i.push(Number(n[r])+o+""),r++);else"Z"===e||"z"===e?(i.push(e),r++):(i.push(n[r]),r++)}return i.join(" ")}const Ml=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Cl(e){const[t,o,n]=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*o+.114*n>150?"#222":"#fff"}function _l(e,t,o){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+o}function Pl(e){return e?"function"==typeof e?e:t=>{var o;return(null===(o=t.data)||void 0===o?void 0:o[e])||t[e]||t.id}:null}function Ll(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ml}function Tl(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function Rl(e,t,o,n,i){if("horizontal"===i){const i=(e+o)/2;return`M ${e},${t} C ${i},${t} ${i},${n} ${o},${n}`}if("radial"===i){const i=(e+o)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+n)/2} T ${o},${n}`}{const i=(t+n)/2;return`M ${e},${t} C ${e},${i} ${o},${i} ${o},${n}`}}const Bl={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,n){var i;const r=o.__hierarchyRoot;if(!r)return;const s=o.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(o.childrenAccessor),c=o.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>Number(e[c])||0:e=>Number(e.value)||0,d=l.hierarchy(r,a);d.sum(u),d.sort((e,t)=>{var o,n;return(null!==(o=t.value)&&void 0!==o?o:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,g]=n;switch(s){case"tree":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.tree();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"cluster":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.cluster();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"treemap":!function(e,t,o,n){var i,r;const s=null!==(i=t.padding)&&void 0!==i?i:4,a=null!==(r=t.paddingTop)&&void 0!==r?r:0,c=l.treemap().size([o,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,o,h,g);break;case"circlepack":!function(e,t,o,n){var i;const r=null!==(i=t.padding)&&void 0!==i?i:4;l.pack().size([o,n]).padding(r)(e)}(d,o,h,g);break;case"partition":!function(e,t,o,n){var i;l.partition().size([o,n]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,o,h,g)}const f=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;f.length>t;t++){const n=f[t],r={id:_l(n,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=n.value)&&void 0!==i?i:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?Nl(r,n,o):"treemap"===s||"partition"===s?El(r,n):"circlepack"===s&&Dl(r,n),r.__hierarchyNode=n,e.push(r),p.set(n,r)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const o=p.get(e.parent),n=p.get(e);o&&n&&t.push({source:o,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,n){const i=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,n,i,r){var s,a,l,c,u,d,h,g;const f=[],p=[],y=[],m=o.treeOrientation||"vertical",v="radial"===m,b=n[0]/2,x=n[1]/2,k="number"==typeof(w=o.nodeSize)?w:5;var w;for(const t of e){let e=t.x,n=t.y;v&&(e+=b,n+=x);const r=i(yl(t,"nodeStyle"));let l=r.fill||Tl(o);if(o.colorByDepth&&void 0!==t.depth){const e=Ll(o);l=e[t.depth%e.length]}const c={fill:l,stroke:r.stroke||(null===(s=o.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};f.push({type:"circle",cx:e,cy:n,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const A=null!==(l=o.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=t.x,s=t.y,a=n.x,l=n.y;v&&(i+=b,s+=x,a+=b,l+=x);const g=Rl(i,s,a,l,m),f=r(yl(e,"edgeStyle")),y={fill:"none",stroke:f.stroke||(null===(c=o.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=o.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=f.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=f.opacity)&&void 0!==h?h:A};p.push({type:"curved",pathD:g,style:y,datum:e})}if(!1!==o.showLabels){const t=Pl(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let n,i,r,s=o.x,a=o.y;if(v&&(s+=b,a+=x),v){const e=s-b,t=a-x,o=Math.sqrt(e*e+t*t);o>0?(n=s+e/o*10,i=a+t/o*10,r=0>e?"end":"start"):(n=s,i=a-12,r="middle")}else"horizontal"===m?((null===(g=o.data)||void 0===g?void 0:g.children)&&0!==o.data.children.length?(n=s-k-6,r="end"):(n=s+k+6,r="start"),i=a):(n=s,i=a+k+14,r="middle");y.push({x:n,y:i,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:f,sceneEdges:p,labels:y}}(e,t,o,n,i,r);case"treemap":case"partition":return function(e,t,o,n){var i,r,s,a,l;const c=[],u=[];for(const o of e){const e=o.x1-o.x0,s=o.y1-o.y0;if(0>=e||0>=s)continue;const a=n(yl(o,"nodeStyle"));let l=a.fill||Tl(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ll(t);l=e[o.depth%e.length]}const u={fill:l,stroke:a.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:o.x0,y:o.y0,w:e,h:s,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=Pl(t.nodeLabel),i=t.labelMode||"leaf",r="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===i&&!h)continue;if("parent"===i&&h)continue}const g=o?o(c):c.id;if(!g)continue;if((h?30:40)>e||(h?16:14)>d)continue;let f=n(yl(c,"nodeStyle")).fill||Tl(t);if(t.colorByDepth&&void 0!==c.depth){const e=Ll(t);f=e[c.depth%e.length]}const p="string"==typeof f?Cl(f):null!==(l=null===(a=t.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:g+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:g+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,o,0,i);case"circlepack":return function(e,t,o,n){var i,r,s,a,l,c,u,d,h,g;const f=[],p=[];for(const o of e){const e=null!==(i=o.__radius)&&void 0!==i?i:5;if(0>=e)continue;const l=n(yl(o,"nodeStyle"));let c=l.fill||Tl(t);if(t.colorByDepth&&void 0!==o.depth){const e=Ll(t);c=e[o.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(r=t.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};f.push({type:"circle",cx:o.x,cy:o.y,r:e,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=Pl(t.nodeLabel);for(const i of e){const e=null!==(l=i.__radius)&&void 0!==l?l:5,r=o?o(i):i.id;if(!r)continue;if(15>e)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=n(yl(i,"nodeStyle")).fill||Tl(t);if(t.colorByDepth&&void 0!==i.depth){const e=Ll(t);a=e[i.depth%e.length]}if(s){const o="string"==typeof a?Cl(a):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";p.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:o})}else p.push({x:i.x,y:i.y-e+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(g=t.themeSemantic)||void 0===g?void 0:g.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:f,sceneEdges:[],labels:p}}(e,o,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Nl(e,t,o){const n=o.treeOrientation||"vertical";if("radial"===n){const o=t.x,n=t.y;e.x=n*Math.cos(o-Math.PI/2),e.y=n*Math.sin(o-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function El(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function Dl(e,t){var o;const n=null!==(o=t.r)&&void 0!==o?o:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function Il(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const Hl={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,o,n){const i=o.__hierarchyRoot;i&&function(e,t,o,n,i){var r,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(o.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var o;return(null!==(o=e[t])&&void 0!==o?o:"")+""}}(o.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),d=null!==(r=o.orbitSize)&&void 0!==r?r:2.95,h=null!==(a=o.orbitEccentricity)&&void 0!==a?a:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=Il(o);p.metaMap.clear(),n.length=0,i.length=0;const y=new Map;function m(e){var t;const o=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,o+1),0===o?e:`${e}__${o}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,o,r,a,d,h,y){const v=l(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let A=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const j=(b+1)/x,S={id:o,depth:h,data:t,parentId:o},O=y?d/g(S)*j:d*j,M=s.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),C=M(w),_=f(S);for(let t=0;w.length>t;t++){const s=(C[t].startAngle+C[t].endAngle)/2,l=w[t],u=m(c(l)),d=r+O*Math.sin(s),g=a+O*Math.cos(s)*_;n.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:O,angle:s,depth:h,parentId:o,eccentricity:_}),i.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),e(l,u,d,g,O,h+1,!0)}A+=k}}(e,k,v,b,x,1,!1)}(i,n,o,e,t)},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.nodeSize,g="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,f=[],p=[],y=[];if(!1!==o.orbitShowRings){const t=Il(o),n=new Map;for(const t of e)n.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const o=`${e.parentId}:${e.ring}`;i.has(o)||i.set(o,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:o,ecc:n}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;p.push({type:"line",x1:e+o*Math.sin(a),y1:t+o*Math.cos(a)*n,x2:e+o*Math.sin(l),y2:t+o*Math.cos(l)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=g(yl(t,"nodeSize")),n=d?d(yl(t,"nodeStyle")):{},c={fill:n.fill||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:m.get(e.source),o="object"==typeof e.target?e.target:m.get(e.target);t&&o&&(null!=t.x&&null!=o.x&&p.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(o.showLabels){const t=o.nodeLabel;for(const o of e){const e=g(yl(o,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(o):t&&null!==(u=null===(c=o.data)||void 0===c?void 0:c[t])&&void 0!==u?u:o.id;y.push({x:o.x,y:o.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:p,labels:y}},tick:(e,t,o,n,i)=>!1!==o.orbitAnimated&&(function(e,t){var o,n;const i=Il(t),r=null!==(o=t.orbitSpeed)&&void 0!==o?o:.25,s=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const o=null!==(t=e.depth)&&void 0!==t?t:0;return(o%2==0?1:-1)/(o+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=c.get(e.parentId);if(!o)continue;const n=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(n),t.y=o.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,o),!0)},Fl={sankey:bl,force:xl,chord:Sl,tree:Bl,cluster:Bl,treemap:Bl,circlepack:Bl,partition:Bl,orbit:Hl};function Wl(e){return Fl[e]}class $l{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},ka),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Aa(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},ka),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new Aa(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,o){const{nodeIDAccessor:n="id",sourceAccessor:i="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof n?n:e=>e[n],l="function"==typeof i?i:e=>e[i],c="function"==typeof r?r:e=>e[r],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},zl(e)),{data:t}))}for(let e=0;t.length>e;e++){const o=t[e],n=l(o)+"",i=c(o)+"",r=u(o),s=null==r?NaN:Number(r),a=Number.isFinite(s)?s:1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},zl(n)),{data:o})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},zl(i)),{data:o}));const d=`${n}\0${i}\0${e}`,h={source:n,target:i,value:a,y0:0,y1:0,sankeyWidth:0,data:o,_edgeKey:d};o&&"object"==typeof o&&Yl(o.bezier)&&(h.bezier=o.bezier),this.edges.set(d,h)}this.runLayout(o)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:n}=e,i=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,zl(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(o)||(this.nodes.set(o,zl(o)),this.nodeTimestamps.set(o,s),this.tension+=this.tensionConfig.newNode,r=!0);const a=this.edgeKey(t,o),l=this.edges.get(a);let c=!1;return l?(l.value+=n,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,r=!0),i||r||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,o,n,i,r,s,a,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=Wl(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const a of u)if(void 0!==a._prevX0){const l=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(o=a._prevX0)&&void 0!==o?o:0),c=(null!==(n=a._prevY1)&&void 0!==n?n:0)-(null!==(i=a._prevY0)&&void 0!==i?i:0);e.set(a.id,{x:(null!==(r=a._prevX0)&&void 0!==r?r:0)+l/2,y:(null!==(s=a._prevY0)&&void 0!==s?s:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,o]of this._lastPositionSnapshot)e.has(t)||e.set(t,o);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],o=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=o,this.edges.set(o,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const o=e.get(t.id);o&&(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const g=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),f=null!==(l=null===(a=this.config.transition)||void 0===a?void 0:a.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&f>0){const t=e[0]/2,o=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=o,e._prevY1=o;for(const e of this.edges.values())e._prevY0=o,e._prevY1=o,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f}}else g&&f>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=e,this.previousEdgeKeys=t}buildScene(e){var t,o,n,i,r,s;const a=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=gs(this.config.colorScheme,this.config.themeCategorical,K),u={nodes:a,edges:l,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:null!==(t=this.config.themeSemantic)&&void 0!==t?t:{},categorical:[...c]},resolveColor:fs(c),config:null!==(o=this.config.layoutConfig)&&void 0!==o?o:{}};let d;try{d=this.config.customNetworkLayout(u)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(n=d.sceneNodes)&&void 0!==n?n:[],this.sceneEdges=null!==(i=d.sceneEdges)&&void 0!==i?i:[],this.labels=null!==(r=d.labels)&&void 0!==r?r:[],void(this.customLayoutOverlays=null!==(s=d.overlays)&&void 0!==s?s:null)}this.customLayoutOverlays=null;const c=Wl(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(a,l,this.config,e);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const e=Wl(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=Wl(this.config.chartType);if(!(null==o?void 0:o.tick))return!1;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return o.tick(n,i,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Me(e,this.transition),o=Oe(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Ce(e._prevX0,e._targetX0,o),e.x1=Ce(e._prevX1,e._targetX1,o),e.y0=Ce(e._prevY0,e._targetY0,o),e.y1=Ce(e._prevY1,e._targetY1,o));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Ce(e._prevY0,e._targetY0,o),e.y1=Ce(e._prevY1,e._targetY1,o),e.sankeyWidth=Ce(e._prevSankeyWidth,e._targetSankeyWidth,o));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const o=null==e?void 0:e.get(t.id);o&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const o=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(o){e._prevY0=o.y0,e._prevY1=o.y1,e._prevSankeyWidth=o.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,o="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&o&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,o))}buildStandardBezier(e,t,o){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,r=o.x0,s=u.interpolateNumber(i,r);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:r}],halfWidth:n}}const i=t.x1,r=o.x0,s=u.interpolateNumber(i,r);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:r,y:e.y1}],halfWidth:n}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,o=e.circularPathData;if(!o)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(o.rightFullExtent-o.sourceX))),n=Math.max(15,Math.min(40,.33*(o.targetX-o.leftFullExtent)));return{circular:!0,segments:[[{x:o.sourceX,y:o.sourceY},{x:o.sourceX+.33*e,y:o.sourceY},{x:o.sourceX+.66*e,y:o.sourceY},{x:o.sourceX+e,y:o.sourceY}],[{x:o.targetX-n,y:o.targetY},{x:o.targetX-.66*n,y:o.targetY},{x:o.targetX-.33*n,y:o.targetY},{x:o.targetX,y:o.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.targetY,y:o.leftFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.rightFullExtent,y:o.sourceY},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const i=[];for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1],r=o.x-t.x,s=o.y-t.y;i.push([t,{x:t.x+r/3,y:t.y+s/3},{x:t.x+2*r/3,y:t.y+2*s/3},o])}return{circular:!0,segments:i,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,o,n,i,r;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(o=s.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=s.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const n=this.nodeTimestamps.get(o);if(!n)continue;const i=e-n;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const o=t.datum;if(!o)continue;const n="object"==typeof o.source?null===(i=o.source)||void 0===i?void 0:i.id:o.source,s="object"==typeof o.target?null===(r=o.target)||void 0===r?void 0:r.id:o.target;if(!n||!s)continue;const c=this.edgeTimestamps.get(`${n}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const o=this.config.decay;if(!o)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const i=this._decaySortedNodes,r=new Map;for(let e=0;i.length>e;e++)r.set(i[e][0],e);for(const i of this.sceneNodes){const s=i.id;if(!s)continue;const a=r.get(s);if(void 0===a)continue;const l=je(o,a,n),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const o=e-this.lastTopologyChangeTime;if(o>=2e3)return;const n=1-o/2e3;for(const e of this.sceneNodes){const o=e.id;o&&this.addedNodes.has(o)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,o;const n=this.config.thresholds;if(!n)return;const i=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",r=null!==(o=n.criticalColor)&&void 0!==o?o:"#ef4444",s=!1!==n.pulse;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const a=this.nodes.get(o);if(!a)continue;const l=n.metric(a);let c=null;void 0===n.critical||n.critical>l?void 0===n.warning||n.warning>l||(c=i):c=r,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),s&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const o=e.metric(t);if(void 0!==e.warning&&o>=e.warning||void 0!==e.critical&&o>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const o="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>o-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var o;const n=this.nodes.get(e);if(!n)return null;const i=n.data?Object.assign({},n.data):{};return n.data=t(null!==(o=n.data)&&void 0!==o?o:{}),this.layoutVersion++,i}updateEdge(e,t,o){var n;const i=this.config.valueAccessor,r="function"==typeof i?i:i?e=>e[i]:e=>e.value,s=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t){s.push(i.data?Object.assign({},i.data):{}),i.data=o(null!==(n=i.data)&&void 0!==n?n:{});const e=r(i.data);null!=e&&(i.value=Number(e))}return s.length>0&&this.layoutVersion++,s}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)!==e&&("string"==typeof o.target?o.target:o.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const o=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)i.data&&n(i.data)===e&&o.push(t)}else for(const[n,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&o.push(n);for(const e of o)this.edges.delete(e),this.edgeTimestamps.delete(e);return o.length>0&&this.layoutVersion++,o.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function zl(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function Yl(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!Gl(e))return!1;return!0}return Gl(t.points)}function Gl(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}function ql(e,t,o,n,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=Xl(t,o,n,i);if(e)if("rect"===t.type){const o=t.w*t.h;a>o&&(r=e,a=o)}else s>e.distance&&(r=e,s=e.distance)}if(r)return r;for(const e of t){if(!1===e.interactive)continue;const t=Zl(e,o,n);t&&s>t.distance&&(r=t,s=t.distance)}return r}function Xl(e,t,o,n=30){switch(e.type){case"circle":return function(e,t,o,n=30){const i=t-e.cx,r=o-e.cy,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,o,n);case"rect":return function(e,t,o){const n=qe(t,o,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,o);case"arc":return function(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerR-2>r||r>e.outerR+2)return null;const s=Ke(Math.atan2(i,n)),a=Ke(e.startAngle),l=Ke(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);default:return null}}let Vl=null,Ul=null;function Kl(){return Ul||(Vl=document.createElement("canvas"),Vl.width=1,Vl.height=1,Ul=Vl.getContext("2d")),Ul}function Ql(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function Zl(e,t,o){switch(e.type){case"bezier":return function(e,t,o){if(!e.pathD)return null;const n=Ql(e),i=Kl();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);case"line":return function(e,t,o){const n=e.x2-e.x1,i=e.y2-e.y1,r=n*n+i*i;if(0===r)return null;let s=((t-e.x1)*n+(o-e.y1)*i)/r;s=Math.max(0,Math.min(1,s));const a=e.x1+s*n,l=e.y1+s*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(o-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;const n=Ql(e),i=Kl();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);default:return null}}function Jl(t){const{width:o,height:n,totalWidth:i,totalHeight:r,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g,legendPosition:f="right",foregroundGraphics:y,sceneNodes:m,annotations:v,svgAnnotationRules:b}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[a.map((t,o)=>e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+o)),v&&v.filter(e=>"widget"!==e.type).map((t,i)=>{if(b){const r=b(t,i,{width:o,height:n,sceneNodes:m});if(r)return e.jsx(p.Fragment,{children:r},"annotation-"+i)}return null}),y]}),l&&"string"==typeof l?e.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:i,height:s.top,children:l}):null,Ht({legend:c,totalWidth:i,totalHeight:r,margin:s,legendPosition:f,title:l,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g})]}),null==v?void 0:v.filter(e=>"widget"===e.type&&e.nodeId&&m).map((t,o)=>{var n,i,r,a,l,c,u,d,h;const g=m.find(e=>{var o,n,i,r,s;return e.id===t.nodeId||(null===(o=e.datum)||void 0===o?void 0:o.id)===t.nodeId||(null===(i=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===i?void 0:i.id)===t.nodeId||(null===(s=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===t.nodeId});if(!g)return null;const f=s.left+(null!==(n=g.cx)&&void 0!==n?n:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(i=g.x)&&void 0!==i?i:0),p=s.top+(null!==(r=g.cy)&&void 0!==r?r:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),y=null!==(l=t.dx)&&void 0!==l?l:0,v=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:f+y-b/2,top:p+v-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+o)})]})}function ec(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function tc(e,t){var o,n,i,r,s,a;if(!t.pathD)return;e.save();const l=ec(t);if(t.style.fill&&"none"!==t.style.fill){const s=t._gradient;if(s){const i=e.createLinearGradient(s.x0,0,s.x1,0),r=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,a="string"==typeof t.style.fill?t.style.fill:"#999",l=rt(e,a)||a;i.addColorStop(0,1===s.from?l:"transparent"),i.addColorStop(1,1===s.to?l:"transparent"),e.fillStyle=i,e.globalAlpha=r}else e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(s=t.style.strokeWidth)&&void 0!==s?s:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function oc(e,t){var o,n;e.save();const i=t.style.stroke||"#999";e.strokeStyle=rt(e,i)||i,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function nc(e,t){var o,n,i,r;if(!t.pathD)return;e.save();const s=ec(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.3*(null!==(r=t.style.opacity)&&void 0!==r?r:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(s)),e.restore()}function ic(e,t){var o,n;if(!t.pathD)return;e.save();const i=ec(t),r=t.style.stroke||"#999";e.strokeStyle=rt(e,r)||r,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(i),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(i)),e.restore()}Jl.displayName="NetworkSVGOverlay";const rc={top:20,right:80,bottom:20,left:80},sc={top:40,right:40,bottom:40,left:40},ac=new Set(["chord","force","circlepack","orbit"]),lc=[800,600],cc={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 uc({data:t}){var o,n,i,r,s,a;if("edge"===t.nodeOrEdge){const o=t.data;return o?e.jsxs("div",{className:"semiotic-tooltip",style:cc,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof o.source?o.source.id:o.source," → ","object"==typeof o.target?o.target.id:o.target]}),null!=o.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof o.value?o.value.toLocaleString():o.value+""]})]}):null}const l=t.data;if(!l)return null;const c=l.__hierarchyNode;if(c){const t=[];let s=c;for(;s;){const e=null!==(r=null!==(n=null===(o=s.data)||void 0===o?void 0:o.name)&&void 0!==n?n:null===(i=s.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=e&&t.unshift(e+""),s=s.parent}t.length>1&&t.shift();const a=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:cc,children:[e.jsx("div",{children:t.map((t,o)=>e.jsxs("span",{children:[o>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),o===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},o))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(s=l.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:cc,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}uc.ownsChrome=!0;const dc=t.forwardRef(function(o,n){var i,r,a,l,c,u,d,h,g,f,p,y,m,b,x,k,w,A;const{chartType:j,nodes:O,edges:M,data:C,initialEdges:_,nodeIDAccessor:P="id",sourceAccessor:L="source",targetAccessor:T="target",valueAccessor:R="value",edgeIdAccessor:B,childrenAccessor:N,hierarchySum:E,orientation:D="horizontal",nodeAlign:I="justify",nodePaddingRatio:H=.05,nodeWidth:F=15,iterations:W=300,forceStrength:$=.1,padAngle:z=.01,groupWidth:Y=20,sortGroups:G,edgeSort:q,treeOrientation:X="vertical",edgeType:V="curve",padding:U,paddingTop:K,tensionConfig:Q,showParticles:Z=!1,particleStyle:J,nodeStyle:ee,edgeStyle:te,colorBy:oe,colorScheme:ne="category10",edgeColorBy:ie="source",edgeOpacity:re=.5,colorByDepth:se=!1,nodeSize:ae=8,nodeSizeRange:le=[5,20],nodeLabel:ce,showLabels:ue=!0,labelMode:de,size:he=lc,responsiveWidth:ge,responsiveHeight:fe,margin:pe,className:ye,background:ve,enableHover:be=!0,tooltipContent:xe,customHoverBehavior:ke,customClickBehavior:we,onObservation:Ae,chartId:je,onTopologyChange:Se,annotations:Oe,svgAnnotationRules:Me,legend:Ce,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Le,legendHighlightedCategory:Te,legendIsolatedCategories:Re,title:Be,foregroundGraphics:Ne,backgroundGraphics:Ee,decay:De,pulse:Ie,transition:He,animate:Fe,staleness:We,thresholds:$e,accessibleTable:ze=!0,description:Ye,summary:qe,orbitMode:Xe,orbitSize:Ve,orbitSpeed:Ue,orbitRevolution:Ke,orbitRevolutionStyle:Qe,orbitEccentricity:Ze,orbitShowRings:Je,orbitAnimated:et,customNetworkLayout:tt,layoutConfig:ot}=o,nt=ac.has(j)?sc:rc,it=t.useRef(!0),st=bn({sizeProp:he,responsiveWidth:ge,responsiveHeight:fe,userMargin:pe,marginDefault:nt,foregroundGraphics:Ne,backgroundGraphics:Ee,animate:Fe,transitionProp:He,themeDirtyRef:it}),{reducedMotionRef:at,responsiveRef:lt,size:ct,margin:ut,adjustedWidth:dt,adjustedHeight:ht,resolvedForeground:gt,resolvedBackground:ft,transition:pt,introEnabled:yt,tableId:mt,rafRef:vt,renderFnRef:bt,scheduleRender:xt,currentTheme:kt}=st,wt=Po(),Ot=Bo(),Ct=t.useMemo(()=>v(O),[O]),Pt=t.useMemo(()=>Array.isArray(M)?v(M):M,[M]),Lt=t.useMemo(()=>Object.assign(Object.assign({},ka),Q),[Q]),Tt=t.useMemo(()=>Object.assign(Object.assign({},wa),J),[J]),Rt=t.useMemo(()=>{var e;return{chartType:j,nodeIDAccessor:P,sourceAccessor:L,targetAccessor:T,valueAccessor:R,edgeIdAccessor:B,childrenAccessor:N,hierarchySum:E,orientation:D,nodeAlign:I,nodePaddingRatio:H,nodeWidth:F,iterations:W,forceStrength:$,padAngle:z,groupWidth:Y,sortGroups:G,edgeSort:q,treeOrientation:X,edgeType:V,padding:U,paddingTop:K,tensionConfig:Lt,showParticles:Z,particleStyle:Tt,nodeStyle:ee,edgeStyle:te,nodeLabel:ce,showLabels:ue,labelMode:de,colorBy:oe,colorScheme:ne,themeCategorical:null===(e=null==kt?void 0:kt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(kt),edgeColorBy:ie,edgeOpacity:re,colorByDepth:se,nodeSize:ae,nodeSizeRange:le,decay:De,pulse:Ie,transition:pt,introAnimation:yt,staleness:We,thresholds:$e,orbitMode:Xe,orbitSize:Ve,orbitSpeed:Ue,orbitRevolution:Ke,orbitRevolutionStyle:Qe,orbitEccentricity:Ze,orbitShowRings:Je,orbitAnimated:et,customNetworkLayout:tt,layoutConfig:ot}},[j,P,L,T,R,N,E,D,I,H,F,W,$,z,Y,G,q,X,V,U,K,Lt,Z,Tt,ee,te,ce,ue,de,oe,ne,ie,re,se,ae,le,De,Ie,null==pt?void 0:pt.duration,null==pt?void 0:pt.easing,yt,We,$e,Xe,Ve,Ue,Ke,Qe,Ze,Je,et,kt,tt,ot]),Bt=Eo(Rt),Nt=t.useRef(null),Et=t.useRef(0),Dt=t.useRef(0),It=t.useRef(!1),Ht=t.useRef(null);Ht.current||(Ht.current=new $l(Bt));const[Ft,Wt]=t.useState(null),[$t,zt]=t.useState(0),[Yt,Gt]=t.useState(0),[qt,Xt]=t.useState(!1),[Vt,Ut]=t.useState(null),Kt=t.useRef(null),Qt=t.useRef(new Map),Zt=t.useRef(0),Jt=t.useCallback(e=>{if("function"==typeof oe)return oe(e)+"";if("string"==typeof oe&&e.data){const t=e.data[oe];if(void 0!==t){if(!Qt.current.has(t+"")){const e=Array.isArray(ne)?ne:me;Qt.current.set(t+"",e[Zt.current++%e.length])}return Qt.current.get(t+"")}}if(Qt.current.has(e.id))return Qt.current.get(e.id);const t=Array.isArray(ne)?ne:me,o=oe?t[Zt.current++%t.length]:t[0];return Qt.current.set(e.id,o),o},[oe,ne]),eo=(null===(i=null==kt?void 0:kt.colors)||void 0===i?void 0:i.border)||(null===(r=null==kt?void 0:kt.colors)||void 0===r?void 0:r.secondary)||(null===(a=null==kt?void 0:kt.colors)||void 0===a?void 0:a.primary)||"#999",to=t.useCallback(e=>{var t,o;return e?"object"==typeof e?e:null!==(o=null===(t=Ht.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==o?o:null:null},[]),oo=t.useCallback(e=>{if("function"==typeof ie)return ie(e);const t=to(e.source),o=to(e.target);return"target"===ie&&o?Jt(o):t?Jt(t):eo},[ie,Jt,eo,to]),no=t.useCallback(e=>{if("function"==typeof Tt.color){const t=to(e.source);return t?Tt.color(e,t):eo}if(!(null==J?void 0:J.colorBy))return oo(e);const t=Tt.colorBy,o=to(e.source),n=to(e.target);return"target"===t&&n?Jt(n):o?Jt(o):eo},[null==J?void 0:J.colorBy,Tt.color,Tt.colorBy,Jt,oo,eo,to]),io=("sankey"===j||!!tt)&&Z||!!Ie||null!==(c=null===(l=Ht.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=Ht.current)||void 0===e||e.updateConfig(Bt),it.current=!0,xt()},[Bt,xt]);const ro=t.useCallback(()=>{var e,t;Ut(null!==(t=null===(e=Ht.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);t.useEffect(()=>{var e;const t=Ht.current;if(t){t.buildScene([dt,ht]),ro();for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Qt.current.set(o.id,o.style.fill);it.current=!0,xt()}},[kt,dt,ht,xt,ro]);const so=t.useCallback(()=>{var e;const t=Ht.current;if(!t)return;t.runLayout([dt,ht]),t.buildScene([dt,ht]),ro(),it.current=!0;for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Qt.current.set(o.id,o.style.fill);const o=Array.isArray(ne)?ne:me,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Qt.current.has(t.id)||Qt.current.set(t.id,o[e%o.length])}if(Zt.current=n.length,zt(t.layoutVersion),Se){const{nodes:e,edges:o}=t.getLayoutData();Se(e,o)}},[dt,ht,Se,ne,ro]),ao=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=Ht.current;t&&(t.ingestEdge(e)&&so(),xt())},[so,xt]),lo=t.useCallback(e=>{const t=Ht.current;if(!t)return;let o=!1;for(const n of e)null!=n&&"object"==typeof n&&t.ingestEdge(n)&&(o=!0);o&&so(),xt()},[so,xt]),co=t.useCallback(()=>{var e;null===(e=Ht.current)||void 0===e||e.clear(),Qt.current.clear(),Zt.current=0,zt(0),Wt(null),Kt.current=null,it.current=!0,xt()},[xt]),uo=t.useCallback(()=>{const e=Ht.current;e&&(e.tension+=999,so(),xt())},[so,xt]);t.useImperativeHandle(n,()=>({push:ao,pushMany:lo,removeNode:e=>{var t,o,n;const i=null!==(o=null===(t=Ht.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==o&&o;if(i){const t=(null===(n=Kt.current)||void 0===n?void 0:n.data)?"function"==typeof P?P(Kt.current.data):Kt.current.data[P]:void 0;Kt.current&&"node"===Kt.current.nodeOrEdge&&t===e&&(Kt.current=null,Wt(null)),Qt.current.delete(e),so(),it.current=!0,xt()}return i},removeEdge:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ht.current)||void 0===o?void 0:o.removeEdge(e,t))&&void 0!==n&&n;if(i){if(Kt.current&&"edge"===Kt.current.nodeOrEdge){const o=Kt.current.data;let n;n=void 0!==t?("object"==typeof(null==o?void 0:o.source)?o.source.id:null==o?void 0:o.source)===e&&("object"==typeof(null==o?void 0:o.target)?o.target.id:null==o?void 0:o.target)===t:!B||!o||("function"==typeof B?B:e=>null==e?void 0:e[B])(o)===e,n&&(Kt.current=null,Wt(null))}so(),it.current=!0,xt()}return i},updateNode:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ht.current)||void 0===o?void 0:o.updateNode(e,t))&&void 0!==n?n:null;return i&&(it.current=!0,xt()),i},updateEdge:(e,t,o)=>{var n,i;const r=null!==(i=null===(n=Ht.current)||void 0===n?void 0:n.updateEdge(e,t,o))&&void 0!==i?i:[];return r.length>0&&(so(),it.current=!0,xt()),r},clear:co,getTopology:()=>{var e,t;return null!==(t=null===(e=Ht.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ht.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:uo,getTension:()=>{var e,t;return null!==(t=null===(e=Ht.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[ao,lo,co,uo,so,xt]);const ho=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),go=ho?C||(Array.isArray(M)?void 0:M):void 0;t.useEffect(()=>{var e;const t=Ht.current;if(t)if(ho&&go)t.ingestHierarchy(go,[dt,ht]),t.buildScene([dt,ht]),ro(),it.current=!0,xt();else{const o=Ct,n=Array.isArray(Pt)?Pt:[];if(0===o.length&&0===n.length)return;t.ingestBounded(o,n,[dt,ht]),t.buildScene([dt,ht]),ro();for(const o of t.sceneNodes)o.id&&(null===(e=o.style)||void 0===e?void 0:e.fill)&&Qt.current.set(o.id,o.style.fill+"");const i=Array.isArray(ne)?ne:me,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Qt.current.has(t.id)||Qt.current.set(t.id,i[e%i.length])}Zt.current=r.length,it.current=!0,xt()}},[Ct,Pt,C,go,ho,dt,ht,Bt,xt,ne,ro]),t.useEffect(()=>{_&&_.length>0&&lo(_)},[]);const fo=t.useCallback(e=>{if(ke&&ke(e),Ae){const t=Date.now();Ae(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:je}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:je})}},[ke,Ae,je]),po=t.useCallback(e=>{if(we&&we(e),Ae){const t=Date.now();Ae(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:je}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:je})}},[we,Ae,je]),{hoverHandlerRef:yo,hoverLeaveRef:mo,onPointerMove:vo,onPointerLeave:bo}=st;yo.current=e=>{if(!be)return;const t=Nt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ut.left,i=e.clientY-o.top-ut.top;if(0>n||n>dt||0>i||i>ht)return void(Kt.current&&(Kt.current=null,Wt(null),fo&&(fo(null),it.current=!0),xt()));const r=Ht.current;if(!r)return;const s=ql(r.sceneNodes,r.sceneEdges,n,i);if(!s)return void(Kt.current&&(Kt.current=null,Wt(null),fo&&(fo(null),it.current=!0),xt()));const a=En(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Kt.current=a,Wt(a),fo&&(fo(a),it.current=!0),xt()},mo.current=()=>{Kt.current&&(Kt.current=null,Wt(null),fo&&(fo(null),it.current=!0),xt())};const xo=t.useRef(()=>{});xo.current=e=>{if(!we&&!Ae)return;const t=Nt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ut.left,i=e.clientY-o.top-ut.top;if(0>n||n>dt||0>i||i>ht)return;const r=Ht.current;if(!r)return;const s=ql(r.sceneNodes,r.sceneEdges,n,i);po(s?En(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const ko=t.useCallback(e=>xo.current(e),[]),wo=t.useRef(-1),Ao=t.useRef(null),jo=t.useRef(-1),So=t.useCallback(e=>{var t;const o=Ht.current;if(!o)return;const n=function(e){var t,o,n,i,r,s;const a=[];for(const l of e)if("circle"===l.type&&null!=l.cx){if(0>=l.r)continue;a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(o=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==o?o:"_default"})}else if("rect"===l.type&&null!=l.x){if(0>=l.w||0>=l.h)continue;a.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(i=null===(n=l.datum)||void 0===n?void 0:n.id)&&void 0!==i?i:"_default"})}else"arc"===l.type&&null!=l.cx&&a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(s=null===(r=l.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(o.sceneNodes);if(0===n.length)return;const i=At(n),r=wo.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),wo.current=0,jo.current=-1;const t=i.flat[0];Ao.current={shape:t.shape,w:t.w,h:t.h};const o=En(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Kt.current=o,Wt(o),fo&&(fo(o),it.current=!0),void xt()}const s=jt(i,r),a=function(e,t,o,n,i){var r,s,a;const l=o.flat[t.flatIndex];if(!l)return St(e,t,o);const c=null===(r=l.datum)||void 0===r?void 0:r.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(s=function(e,t,o){let n=null,i=1/0;for(let r=0;e.flat.length>r;r++){const s=e.flat[r];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(o){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,n=r)}return n}(o,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return n!==t.flatIndex&&(i.current=-1),n}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var o;const n=e+"",i=[];for(const e of t){const t=null!==(o=e.datum)&&void 0!==o?o:e,r=Mt(t.source),s=Mt(t.target),a=null!=r,l=null!=s;a&&r+""===n&&l?i.push(s+""):l&&s+""===n&&a&&i.push(r+"")}return i}(c,n);if(0===e.length)return t.flatIndex;const r=null!==(a=o.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>r?t.flatIndex:(i.current=-1,r)}default:{const n=St(e,t,o);return null!==n&&n!==t.flatIndex&&(i.current=-1),n}}}(e.key,s,i,null!==(t=o.sceneEdges)&&void 0!==t?t:[],jo);if(null===a)return;if(e.preventDefault(),0>a)return wo.current=-1,Ao.current=null,jo.current=-1,Kt.current=null,Wt(null),fo&&(fo(null),it.current=!0),void xt();wo.current=a;const l=i.flat[a];Ao.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Kt.current=c,Wt(c),fo&&(fo(c),it.current=!0),xt()},[fo,xt]),_o=t.useCallback(e=>{wo.current=-1,Ao.current=null,vo(e)},[vo]);bt.current=()=>{var e,t,o,n,i,r,s;vt.current=0;const a=Nt.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=Ht.current;if(!c)return;const u=performance.now(),d=Et.current?Math.min((u-Et.current)/1e3,.1):.016;Et.current=u;const h=c.advanceTransition(at.current?u+1e6:u),g=!at.current&&h,f=!at.current&&c.tickAnimation([dt,ht],d);(h||it.current||f)&&c.buildScene([dt,ht]);const p=kn();if(!xn(a,ct,ut,p))return;if(l.clearRect(-ut.left,-ut.top,ct[0],ct[1]),ve){const e=rt(l,ve);e&&(l.fillStyle=e,l.fillRect(0,0,dt,ht))}De&&c.applyDecay(),Ie&&c.applyPulse(u),$e&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,m=We&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(m&&(l.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const o of t)switch(o.type){case"bezier":tc(e,o);break;case"line":oc(e,o);break;case"ribbon":nc(e,o);break;case"curved":ic(e,o)}}(l,c.sceneEdges),function(e,t){var o,n,i;for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),On(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("circle"!==r.type)continue;const t=r;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),Mn(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("arc"!==r.type)continue;const t=r;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),e.restore()}}(l,c.sceneNodes),Z&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,o,n){var i,r;const s=null!==(i=n.spawnRate)&&void 0!==i?i:wa.spawnRate,a=null!==(r=n.maxPerEdge)&&void 0!==r?r:wa.maxPerEdge;for(let n=0;t.length>n;n++){const i=t[n];if(!i.bezier)continue;if(e.countForEdge(n)>=a)continue;const r=i.value*s*o*(i.bezier.circular?.3:1),l=Math.floor(r),c=r-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<a;t++)e.spawn(n)}}(c.particlePool,e,d,Tt);const t=.5*(null!==(o=Tt.speedMultiplier)&&void 0!==o?o:1);let n;if(Tt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,n),function(e,t,o,n,i){var r,s;const a=null!==(r=n.radius)&&void 0!==r?r:wa.radius,l=null!==(s=n.opacity)&&void 0!==s?s:wa.opacity;e.globalAlpha=l;for(let r=0;t.particles.length>r;r++){const s=t.particles[r];if(!s.active)continue;const l=o[s.edgeIndex];if(!l)continue;let c;c="string"==typeof n.color&&"inherit"!==n.color?n.color:i(l),e.fillStyle=rt(e,c)||c,e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}e.globalAlpha=1}(l,c.particlePool,e,Tt,no)}}m&&(l.globalAlpha=1);const v=it.current;if(it.current=!1,v||g||f){const e=Nt.current;e&&e.setAttribute("aria-label",Go(null!==(i=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==i?i:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}const b=v||g||f||It.current;b&&u-Dt.current>=33?(Gt(e=>e+1),Dt.current=u,It.current=!1):It.current=!!b,(io||g||null!=c.transition||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||It.current)&&(vt.current=requestAnimationFrame(()=>bt.current()))},No({hydrated:wt,wasHydratingFromSSR:Ot,storeRef:Ht,dirtyRef:it,renderFnRef:bt}),t.useEffect(()=>{it.current=!0,xt()},[j,dt,ht,ve,xt]),_t(We,Ht,it,xt,qt,Xt);const Lo=be&&Ft?e.jsx(fn,{x:Ft.x,y:Ft.y,containerWidth:dt,containerHeight:ht,margin:ut,className:"stream-network-tooltip",zIndex:2,children:xe?xe(Ft):e.jsx(uc,{data:Ft})}):null;if(Co||!wt&&Ot){const t=Ht.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),o=e?C||(Array.isArray(M)?void 0:M):void 0;if(e&&o)t.ingestHierarchy(o,[dt,ht]),t.buildScene([dt,ht]);else{const e=Ct,o=Array.isArray(Pt)?Pt:[];(e.length>0||o.length>0)&&(t.ingestBounded(e,o,[dt,ht]),t.buildScene([dt,ht]))}}const o=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],i=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{ref:lt,className:"stream-network-frame"+(ye?" "+ye:""),role:"img","aria-label":Ye||("string"==typeof Be?Be:"Network chart"),style:{position:"relative",width:ge?"100%":ct[0],height:fe?"100%":ct[1]},children:[e.jsx(on,{summary:qe}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ct[0],height:ct[1],style:{position:"absolute",left:0,top:0},children:[ft&&e.jsx("g",{transform:`translate(${ut.left},${ut.top})`,children:ft}),e.jsxs("g",{transform:`translate(${ut.left},${ut.top})`,children:[ve&&e.jsx("rect",{x:0,y:0,width:dt,height:ht,fill:ve}),n.map((t,o)=>function(t,o){switch(t.type){case"line":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+o);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+o)}default:return null}}(t,o)).filter(Boolean),o.map((t,o)=>function(t,o){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+o)}case"arc":{const n=t,i=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Oo)||"";return e.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+o)}default:return null}}(t,o)).filter(Boolean),i.map((t,o)=>function(t,o){return e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+o)}(t,o)).filter(Boolean)]})]}),e.jsx(Jl,{width:dt,height:ht,totalWidth:ct[0],totalHeight:ct[1],margin:ut,labels:i,sceneNodes:o,title:Be,legend:Ce,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Le,legendHighlightedCategory:Te,legendIsolatedCategories:Re,foregroundGraphics:Ge(gt,null===(g=Ht.current)||void 0===g?void 0:g.customLayoutOverlays),annotations:Oe,svgAnnotationRules:Me,annotationFrame:0})]})}const To=Ht.current;return e.jsxs("div",{ref:lt,className:"stream-network-frame"+(ye?" "+ye:""),role:"group","aria-label":Ye||("string"==typeof Be?Be:"Network chart"),tabIndex:0,style:{position:"relative",width:ge?"100%":ct[0],height:fe?"100%":ct[1],overflow:"visible"},onKeyDown:So,children:[ze&&e.jsx(nn,{tableId:mt}),ze&&e.jsx(tn,{nodes:null!==(f=null==To?void 0:To.sceneNodes)&&void 0!==f?f:[],edges:null!==(p=null==To?void 0:To.sceneEdges)&&void 0!==p?p:[],chartType:"Network chart",tableId:mt,chartTitle:"string"==typeof Be?Be:void 0}),e.jsx(on,{summary:qe}),e.jsxs("div",{role:"img","aria-label":Ye||("string"==typeof Be?Be:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?_o:void 0,onMouseLeave:be?bo:void 0,onClick:we||Ae?ko:void 0,children:[ft&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ct[0],height:ct[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${ut.left},${ut.top})`,children:ft})}),e.jsx("canvas",{ref:Nt,"aria-label":Go(null!==(m=null===(y=null==To?void 0:To.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==m?m:0,null!==(x=null===(b=null==To?void 0:To.sceneEdges)||void 0===b?void 0:b.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(rn,{hoverPoint:Ft}),e.jsx(Jl,{width:dt,height:ht,totalWidth:ct[0],totalHeight:ct[1],margin:ut,labels:(null==To?void 0:To.labels)||[],sceneNodes:null==To?void 0:To.sceneNodes,title:Be,legend:Ce,legendPosition:_e,legendHoverBehavior:Pe,legendClickBehavior:Le,legendHighlightedCategory:Te,legendIsolatedCategories:Re,foregroundGraphics:Ge(gt,Vt),annotations:Oe,svgAnnotationRules:Me,annotationFrame:Yt}),e.jsx(an,{active:wo.current>=0,hoverPoint:Ft,margin:ut,size:ct,shape:null===(k=Ao.current)||void 0===k?void 0:k.shape,width:null===(w=Ao.current)||void 0===w?void 0:w.w,height:null===(A=Ao.current)||void 0===A?void 0:A.h}),Lo,(null==We?void 0:We.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:qt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:qt?"STALE":"LIVE"})]})]})});function hc(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function gc(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function fc(e){return"function"==typeof e?e:t=>t[e]||1}function pc({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a=Object.assign({fillOpacity:i},r);if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=ke(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=ke(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function yc(e){const{nodes:o,edges:n,inferNodes:i=!0,sourceAccessor:r="source",targetAccessor:s="target",colorBy:a,colorScheme:l,showLegend:c,legendPosition:u,legendInteraction:d,selection:h,linkedHover:g,onObservation:f,onClick:p,chartType:y,chartId:m,marginDefaults:b,userMargin:x,width:k,height:w,loading:A,loadingContent:j,emptyContent:S,emptyDataKey:O="edges"}=e,M=t.useMemo(()=>v(n),[n]),C=t.useMemo(()=>v(o),[o]),_=ur(A,k,w,j),P=_?null:cr("nodes"===O?void 0===o?void 0:C:void 0===n?void 0:M,k,w,S),L=t.useMemo(()=>i?gc(C,M,r,s):C,[i,C,M,r,s]),T=Fi(L,a,l),R=Ii(),B=t.useMemo(()=>{if(Array.isArray(l))return l;if(R&&R.length>0)return R;if("string"==typeof l){const e=ye[l];if(Array.isArray(e)&&e.length>0)return e}return me},[l,R]),N=t.useMemo(()=>{if(!a)return[];const e=new Set;for(const t of L){const o="function"==typeof a?a(t):t[a];null!=o&&e.add(o+"")}return Array.from(e)},[L,a]),E=Gi(d,a,N),{legend:D,margin:I,legendPosition:H}=Yi({data:L,colorBy:a,colorScale:T,showLegend:c,legendPosition:u,userMargin:x,defaults:b,categories:N}),F=$i({selection:h,linkedHover:g,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:p,chartType:y,chartId:m}),{customHoverBehavior:W,customClickBehavior:$,activeSelectionHook:z,hoverSelectionHook:Y,crosshairSourceId:G}=F;return{safeNodes:L,safeEdges:M,colorScale:T,effectivePalette:B,themeCategorical:R,allCategories:N,legendState:E,legend:D,margin:I,legendPosition:H,customHoverBehavior:W,customClickBehavior:$,activeSelectionHook:z,hoverSelectionHook:Y,crosshairSourceId:G,loadingEl:_,emptyEl:P}}dc.displayName="StreamNetworkFrame";const mc=t.forwardRef(function(o,n){var i;const r=t.useRef(null);Ar(n,{variant:"network",frameRef:r});const s=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:g="source",targetAccessor:f="target",nodeLabel:p,colorBy:y,colorScheme:m,nodeSize:v=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:A=300,forceStrength:j=.1,tooltip:S,frameProps:O={},onObservation:M,onClick:C,chartId:_,selection:P,linkedHover:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:E,stroke:D,strokeWidth:I,opacity:H}=o,F=null!==(i=null!=d?d:h)&&void 0!==i?i:"id",{width:W,height:$,enableHover:z,showLegend:Y,showLabels:G=!1,title:q,description:X,summary:V,accessibleTable:U}=s,K=yc({nodes:a,edges:l,inferNodes:!1,sourceAccessor:g,targetAccessor:f,colorBy:y,colorScheme:m,showLegend:Y,legendPosition:E,legendInteraction:N,selection:P,linkedHover:L,onObservation:M,onClick:C,chartType:"ForceDirectedGraph",chartId:_,marginDefaults:s.marginDefaults,userMargin:c,width:W,height:$,loading:T,loadingContent:R,emptyContent:B,emptyDataKey:"nodes"}),Q=t.useMemo(()=>new Map,[]),Z=t.useMemo(()=>e=>{const t={};return t.fill=y?ke(e.data||e,y,K.colorScale):Hi(void 0,K.themeCategorical,m,void 0,Q),"number"==typeof v&&(t.r=v),t},[y,K.colorScale,v,K.themeCategorical,m,Q]),J=t.useMemo(()=>kr(Z,{stroke:D,strokeWidth:I,opacity:H}),[Z,D,I,H]),ee=t.useMemo(()=>e=>({stroke:k,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:w}),[x,k,w]),te=t.useMemo(()=>kr(ee,{stroke:D,strokeWidth:I,opacity:H}),[ee,D,I,H]),oe=t.useMemo(()=>{if(G&&p)return"function"==typeof p?p:e=>{var t,o,n;return null!==(n=null!==(o=null===(t=e.data)||void 0===t?void 0:t[p])&&void 0!==o?o:e[p])&&void 0!==n?n:e.id}},[G,p]),ne=vr({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:F}});return ne?e.jsx(or,{componentName:"ForceDirectedGraph",message:ne,width:W,height:$}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e.jsx(sr,{componentName:"ForceDirectedGraph",width:W,height:$,children:e.jsx(dc,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:K.safeNodes},null!=l&&{edges:K.safeEdges},{size:[W,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:K.margin,nodeIDAccessor:F,sourceAccessor:g,targetAccessor:f,iterations:A,forceStrength:j,nodeStyle:J,edgeStyle:te,colorBy:y,colorScheme:K.effectivePalette,nodeSize:v,nodeSizeRange:b,nodeLabel:oe,showLabels:G,enableHover:z,tooltipContent:!1===S?()=>null:gn(S)||void 0,customHoverBehavior:L||M||C?K.customHoverBehavior:void 0,customClickBehavior:M||C?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},N&&"none"!==N&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:u,title:q,description:X,summary:V,accessibleTable:U},null!=o.animate&&{animate:o.animate},O))})});mc.displayName="ForceDirectedGraph";const vc=t.forwardRef(function(o,n){const i=t.useRef(null);Ar(n,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}});const r=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:y="source",padAngle:m=.01,groupWidth:v=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:A={},onObservation:j,onClick:S,chartId:O,selection:M,linkedHover:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:E,height:D,enableHover:I,showLabels:H=!0,title:F,description:W,summary:$,accessibleTable:z}=r,Y=yc({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:p,showLegend:!1,legendInteraction:T,selection:M,linkedHover:C,onObservation:j,onClick:S,chartType:"ChordDiagram",chartId:O,marginDefaults:r.marginDefaults,userMargin:l,width:E,height:D,loading:_,loadingContent:P,emptyContent:L}),G=t.useMemo(()=>new Map,[]),q=Y.safeNodes.length>0,X=t.useMemo(()=>{if(q)return(e,t)=>{var o,n;const i={stroke:"black",strokeWidth:1};if(f)i.fill=ke(e.data||e,f,Y.colorScale);else{const r=Array.isArray(p)?p:ye[p]||me,s=Array.isArray(r)?r:me,a=null!==(n=null!==(o=e.index)&&void 0!==o?o:t)&&void 0!==n?n:0;i.fill=s[a%s.length]}return i}},[q,f,Y.colorScale,p]),V=t.useMemo(()=>X?kr(X,{stroke:R,strokeWidth:B,opacity:N}):void 0,[X,R,B,N]),U=t.useMemo(()=>{if(q)return pc({edgeColorBy:y,colorBy:f,colorScale:Y.colorScale,nodeStyleFn:V||(e=>({fill:Hi(void 0,Y.themeCategorical,p,void 0,G)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[q,y,f,Y.colorScale,V,k,Y.themeCategorical,p,G]),K=t.useMemo(()=>U?kr(U,{stroke:R,strokeWidth:B,opacity:N}):void 0,[U,R,B,N]),Q=t.useMemo(()=>{if(!H)return;const e=x||g;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[H,x,g]),Z=vr({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return Z?e.jsx(or,{componentName:"ChordDiagram",message:Z,width:E,height:D}):Y.loadingEl?Y.loadingEl:Y.emptyEl?Y.emptyEl:e.jsx(sr,{componentName:"ChordDiagram",width:E,height:D,children:e.jsx(dc,Object.assign({ref:i,chartType:"chord"},Y.safeNodes.length>0&&{nodes:Y.safeNodes},null!=a&&{edges:Y.safeEdges},{size:[E,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Y.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:m,groupWidth:v,sortGroups:b,nodeStyle:V,edgeStyle:K,colorBy:f,colorScheme:Y.effectivePalette,edgeColorBy:y,edgeOpacity:k,nodeLabel:Q,showLabels:H,enableHover:I,tooltipContent:!1===w?()=>null:gn(w)||void 0,customHoverBehavior:C||j||S?Y.customHoverBehavior:void 0,customClickBehavior:j||S?Y.customClickBehavior:void 0},T&&"none"!==T&&{legendHoverBehavior:Y.legendState.onLegendHover,legendClickBehavior:Y.legendState.onLegendClick,legendHighlightedCategory:Y.legendState.highlightedCategory,legendIsolatedCategories:Y.legendState.isolatedCategories},{className:c,title:F,description:W,summary:$,accessibleTable:z},null!=o.animate&&{animate:o.animate},A))})});vc.displayName="ChordDiagram";const bc=t.forwardRef(function(o,n){const i=t.useRef(null);Ar(n,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}});const r=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:800,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:y="source",orientation:m="horizontal",nodeAlign:v="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:A,tooltip:j,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,loadingContent:T,emptyContent:R,showLegend:B,legendPosition:N,legendInteraction:E,stroke:D,strokeWidth:I,opacity:H}=o,{width:F,height:W,enableHover:$,showLabels:z=!0,title:Y,description:G,summary:q,accessibleTable:X}=r,V=yc({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:p,showLegend:B,legendPosition:N,legendInteraction:E,selection:_,linkedHover:P,onObservation:O,onClick:M,chartType:"SankeyDiagram",chartId:C,marginDefaults:r.marginDefaults,userMargin:l,width:F,height:W,loading:L,loadingContent:T,emptyContent:R}),U=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?ke(e.data||e,f,V.colorScale):Hi(void 0,V.themeCategorical,p,void 0,U),t},[f,V.colorScale,V.themeCategorical,p,U]),Q=t.useMemo(()=>kr(K,{stroke:D,strokeWidth:I,opacity:H}),[K,D,I,H]),Z=t.useMemo(()=>pc({edgeColorBy:y,colorBy:f,colorScale:V.colorScale,nodeStyleFn:Q,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,f,V.colorScale,Q,w]),J=t.useMemo(()=>kr(Z,{stroke:D,strokeWidth:I,opacity:H}),[Z,D,I,H]),ee=t.useMemo(()=>{if(!z)return;const e=k||g;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[z,k,g]),te=vr({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return te?e.jsx(or,{componentName:"SankeyDiagram",message:te,width:F,height:W}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:e.jsx(sr,{componentName:"SankeyDiagram",width:F,height:W,children:e.jsx(dc,Object.assign({ref:i,chartType:"sankey"},V.safeNodes.length>0&&{nodes:V.safeNodes},null!=a&&{edges:V.safeEdges},{size:[F,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:V.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:m,nodeAlign:v,nodePaddingRatio:b,nodeWidth:x,nodeStyle:Q,edgeStyle:J,colorBy:f,colorScheme:V.effectivePalette,edgeColorBy:y,edgeOpacity:w,edgeSort:A,nodeLabel:ee,showLabels:z,enableHover:$,tooltipContent:!1===j?()=>null:gn(j)||void 0,customHoverBehavior:P||O||M?V.customHoverBehavior:void 0,customClickBehavior:O||M?V.customClickBehavior:void 0,legend:V.legend,legendPosition:V.legendPosition},E&&"none"!==E&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},{className:c,title:Y,description:G,summary:q,accessibleTable:X},null!=o.animate&&{animate:o.animate},S))})});function xc(e,t,o){const n=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of n)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>{var o,n;return e.time-t.time||(null!==(o=s[e.kind])&&void 0!==o?o:99)-(null!==(n=s[t.kind])&&void 0!==n?n:99)})},l=r.length?Math.min(...r.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const g=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const f=[];let p=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?p:y);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?p:y);if(n>0){const i=g(e.time);f.push({time:i,delta:-n,kind:"transfer-out",side:t}),f.push({time:i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?p-=n:y-=n,"top"===e.side?p+=n:y+=n,o-=n}o>0&&null!==u&&(f.push({time:u,delta:+o,kind:"create",side:e.side}),"top"===e.side?p+=o:y+=o)}"top"===e.side?p-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?p+=t:y+=t}r.push(...f),a();let m=0,v=0,b=0,x=0,k=0;const w=[],A=new Map;for(const e of r){if(w.push({t:e.time,topMass:m,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:v;A.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:v+=e.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:e.time,topMass:m,botMass:v})}const j=[];let S=0;for(;w.length>S;){let e=S;for(;w.length>e+1&&w[e+1].t===w[S].t;)e++;j.push(w[S]);for(let t=S+1;e>=t;t++){const e=j[j.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||j.push(w[t])}S=e+1}const O=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let M=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===M||M>e.systemInTime)&&(M=e.systemInTime);let C=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===C||e.systemOutTime>C)&&(C=e.systemOutTime);if(j.length>0){const e=j[j.length-1],t=Math.max(null!=O?O:-1/0,null!=C?C:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&j.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=j[0],n=Math.min(null!=c?c:1/0,null!=M?M:1/0);Number.isFinite(n)&&o.t>n&&o.topMass+o.botMass>0&&j.unshift({t:n,topMass:o.topMass,botMass:o.botMass})}return{samples:j,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function kc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function wc(e,t){return e.map(e=>({t:kc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Ac(e,t,o){const n=e.value*o;if("out"===e.kind){const i=e.sideMassBefore*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}const i=e.sideMassAfter*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}function jc(e,t){let o=0;for(let n=0;t.length>n;n++)for(let i=n+1;t.length>i;i++){const r=t[n],s=t[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&e[s.source]>e[r.source]!=e[s.target]>e[r.target]&&o++)}return o}function Sc(e,t){let o=0;for(const n of t)o+=Math.abs(e[n.source]-e[n.target])*(n.value||1);return o}function Oc(e,t){return 1e3*jc(e,t)+Sc(e,t)}function Mc(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function Cc(e,t,o){e.length>8||o.length>40?(function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=Mc(e,t),s=Oc(t,o);for(let a=0;n>a;a++){const n=Array(i).fill(0),a=Array(i).fill(0);for(const e of o){const o=t[e.source],i=t[e.target];n[o]+=i*(e.value||1),a[o]+=e.value||1,n[i]+=o*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?n[e]/a[e]:e)-(a[t]>0?n[t]/a[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=Oc(t,o);if(s>d)s=d,r=Mc(e,t);else if(d===s)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=Oc(t,o);for(let s=0;n>s;s++){let n=!1;for(let s=0;i-1>s;s++){const i=e[s];e[s]=e[s+1],e[s+1]=i;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=Oc(t,o);if(r>a)r=a,n=!0;else{const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!n)break}}(e,t,o,6)):function(e,t,o){const n=e.length;if(1>=n)return;const i=Object.assign({},t),r=Object.keys(i),s=Array.from({length:n},(e,t)=>t),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const e of r)l[e]=a[i[e]];const e=Oc(l,o);u>e&&(u=e,c=s.slice())},h=(e,t)=>{const o=s[e],n=s[t];s[e]=n,s[t]=o,a[o]=t,a[n]=e};d();const g=Array(n).fill(0);let f=0;for(;n>f;)f>g[f]?(h(f%2==0?0:g[f],f),d(),g[f]++,f=0):(g[f]=0,f++);const p=c.map(t=>e[t]),y=new Map;c.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of p)e.push(t)}(e,t,o)}function _c(e,t,o,n,i){var r,s,a,l,c,u,d,h;const{plotH:g,padding:f,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=i,b={},x={};for(const t of e)b[t.id]=o[t.id].topPeak||0,x[t.id]=o[t.id].botPeak||0;const k="half"===v,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}w[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},j=[];if("reuse"===y){const o=new Map;for(const t of e)o.set(t.id,0);const i=new Map;for(const t of e)i.set(t.id,0);for(const e of t)i.set(e.target,(null!==(r=i.get(e.target))&&void 0!==r?r:0)+1);const d=[];for(const t of e)0===(null!==(s=i.get(t.id))&&void 0!==s?s:0)&&d.push(t.id);for(;d.length;){const e=d.shift();for(const t of null!==(a=n.outgoing[e])&&void 0!==a?a:[]){const n=(null!==(l=o.get(e))&&void 0!==l?l:0)+1;n>(null!==(c=o.get(t.target))&&void 0!==c?c:0)&&o.set(t.target,n),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&d.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var n,i;const r=null!==(n=o.get(e.id))&&void 0!==n?n:0,s=null!==(i=o.get(t.id))&&void 0!==i?i:0;return r!==s?r-s:w[e.id].start-w[t.id].start}),g=e.filter(e=>null===w[e.id].start);for(const e of[...h,...g]){const t=w[e.id];let o=-1;for(let e=0;j.length>e;e++){const n=j[e].occupants[j[e].occupants.length-1];if(null===t.start||void 0===n||t.start>=n.end){o=e;break}}-1===o&&(j.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=j.length-1),j[o].occupants.push({id:e.id,end:null!==(u=null==t?void 0:t.end)&&void 0!==u?u:-1/0}),j[o].peak.topPeak=Math.max(j[o].peak.topPeak,b[e.id]),j[o].peak.botPeak=Math.max(j[o].peak.botPeak,x[e.id]),A[e.id]=o}}else e.forEach((e,t)=>{var o,n;j.push({occupants:[{id:e.id,end:null!==(n=null===(o=w[e.id])||void 0===o?void 0:o.end)&&void 0!==n?n:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),A[e.id]=t});let S=null,O=null,M=null,C=null;const _=()=>{S=jc(A,t),M=Sc(A,t)},P=()=>{O=jc(A,t),C=Sc(A,t)};"crossing-min"===m?(_(),Cc(j,A,t),P()):"inside-out"===m?(_(),function(e,t){const o=e.length;if(1>=o)return;const n=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>n(t.slot)-n(e.slot)),r=Array(o),s=Math.floor((o-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let e=1;i.length>e;e++)e%2==1&&o>l||0>a?r[l++]=i[e].idx:r[a--]=i[e].idx;const c=r.map(t=>e[t]),u=new Map;r.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(j,A),P()):"crossing-min+inside-out"===m&&(_(),Cc(j,A,t),function(e,t,o){const n=e.length;if(1>=n)return;const i=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((n-1)/2);let s=Oc(t,o);for(const{slot:a}of i){const i=e.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=e[i];e.splice(i,1),e.splice(l,0,c);const u=new Map;for(let e=0;n>e;e++)u.set(e,e);if(l>i){for(let e=i+1;l>=e;e++)u.set(e,e-1);u.set(i,l)}else{for(let e=l;i>e;e++)u.set(e,e+1);u.set(i,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Oc(t,o);if(d>s){const o=e[l];e.splice(l,1),e.splice(i,0,o);const r=new Map;for(let e=0;n>e;e++)r.set(e,e);if(i>l){for(let e=l+1;i>=e;e++)r.set(e,e-1);r.set(l,i)}else{for(let e=i;l>e;e++)r.set(e,e+1);r.set(l,i)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else s=d}}(j,A,t),P());const L=j.map(e=>{const t=new Map;for(const n of e.occupants){const e=o[n.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let o={top:0,bot:0};for(const[n,i]of e){if(n>t)break;o=i}return o},R=[];for(let e=0;j.length-1>e;e++){const t=L[e],o=L[e+1],n=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let i=0;for(const e of n){const n=T(t,e),r=T(o,e);n.bot+r.top>i&&(i=n.bot+r.top)}R.push(i)}const B=[];let N=f+(null!==(h=null===(d=j[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;j.length>0&&B.push(N);for(let e=1;j.length>e;e++)N+=R[e-1]*p+f,B.push(N);if(j.length>0&&(N+=j[j.length-1].peak.botPeak*p+f),N>g){const e=g/N;for(let t=0;B.length>t;t++)B[t]*=e}const E=0===j.length?0:j[0].peak.topPeak+R.reduce((e,t)=>e+t,0)+j[j.length-1].peak.botPeak,D={};for(const t of e)D[t.id]=B[A[t.id]];return{effectiveSlotsHeight:E,centerlines:D,laneLifetime:w,slots:j,slotByNode:A,slotCenter:B,crossingsBefore:S,crossingsAfter:O,lengthBefore:M,lengthAfter:C}}bc.displayName="SankeyDiagram";const Pc=e=>{var t,o;const{bands:n=[],ribbons:i=[],showLabels:r=!0}=e.config,s=[];for(const e of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of n)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of n)s.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(o=e.strokeWidth)&&void 0!==o?o:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const a=r?n.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:n.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:a}};function Lc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Tc(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Rc(e,t){return"function"==typeof e?e(t):t[e]}const Bc=t.forwardRef(function(o,n){const{nodes:r,edges:s,domain:a,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",startTimeAccessor:g="startTime",endTimeAccessor:f="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:y,xExtentAccessor:m="xExtent",edgeIdAccessor:b="id",colorBy:x,colorScheme:k,showLegend:w,legendPosition:A="right",pairing:j="temporal",packing:S="reuse",laneOrder:O="crossing-min",ribbonLane:M="both",lifetimeMode:C="half",showLaneRails:_=!1,showQualityReadout:P=!1,showLabels:L=!0,width:T=600,height:R=400,margin:B,title:N,description:E,summary:D,accessibleTable:I,responsiveWidth:H,responsiveHeight:F,loading:W,loadingContent:$,emptyContent:z,edgeOpacity:Y=.35,timeFormat:G,valueFormat:q,tooltip:X,enableHover:V=!0,onObservation:U,onClick:K,showParticles:Q=!1,particleStyle:Z,chartId:J,frameProps:ee={}}=o,[te,oe]=t.useState([]),[ne,ie]=t.useState([]),re=t.useRef(te),se=t.useRef(ne);re.current=te,se.current=ne;const ae=t.useCallback(e=>{re.current=e,oe(e)},[]),le=t.useCallback(e=>{se.current=e,ie(e)},[]),ce=void 0!==s,ue=v(ce?s:te),de=t.useMemo(()=>{const e=v(null!=r?r:[]),t=ne;if(0===e.length&&0===t.length)return gc([],ue,u,d);const o=new Set,n=[];for(const t of e){const e=Rc(c,t)+"";o.has(e)||(o.add(e),n.push(t))}for(const e of t){const t=Rc(c,e)+"";o.has(t)||(o.add(t),n.push(e))}const i=gc([],ue,u,d);for(const e of i)o.has(e.id)||(o.add(e.id),n.push(e));return n},[r,ne,ue,c,u,d]),he=t.useRef(null),ge=t.useCallback((e,t)=>{const o=Rc(b,e);return null!=o?o+"":`${Rc(u,e)}-${Rc(d,e)}-${t}`},[b,u,d]),fe=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=Rc(u,t)&&null!=Rc(d,t)},[u,d]);Ar(n,{variant:"network",frameRef:he,overrides:{push(e){if(fe(e)){if(ce)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ae([...re.current,e])}else le([...se.current,e])},pushMany(e){const t=[],o=[];for(const n of e)fe(n)?t.push(n):o.push(n);t.length>0&&(ce?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ae([...re.current,...t])),o.length>0&&le([...se.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!ce){const e=re.current,n=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(ge(r,i))?o.push(r):n.push(r)}n.length!==e.length&&ae(n)}const n=se.current,i=[];for(const e of n){const n=Rc(c,e)+"";t.has(n)?o.push(e):i.push(e)}return i.length!==n.length&&le(i),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!ce){let e=!1;const i=re.current.map((i,r)=>o.has(ge(i,r))?(n.push(i),e=!0,t(i)):i);e&&ae(i)}let i=!1;const r=se.current.map(e=>{const r=Rc(c,e)+"";return o.has(r)?(n.push(e),i=!0,t(e)):e});return i&&le(r),n},clear(){var e;ce||ae([]),le([]),null===(e=he.current)||void 0===e||e.clear()},getData:()=>null!=ue?ue:[],getScales:()=>null},deps:[ce,fe,ge,c,ue,ae,le]});const pe=ge,ye=t.useCallback(e=>Rc(c,e)+"",[c]),{nodes:me,edges:ve,domain:be,rawNodeById:xe,rawEdgeById:we}=t.useMemo(()=>{const e=(null!=de?de:[]).map(e=>{const t={id:ye(e),__raw:e},o=m?Rc(m,e):null;if(Array.isArray(o)&&2===o.length){const e=Tc(o[0]),n=Tc(o[1]);Number.isFinite(e)&&Number.isFinite(n)&&(t.xExtent=[e,n])}return t}),t=(null!=ue?ue:[]).map((e,t)=>{const o={id:pe(e,t),source:Rc(u,e)+"",target:Rc(d,e)+"",value:Number(Rc(h,e)),startTime:Tc(Rc(g,e)),endTime:Tc(Rc(f,e)),__raw:e};if(p){const t=Tc(Rc(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(y){const t=Tc(Rc(y,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Tc(a[0]),Tc(a[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[de,ue,a,ye,pe,m,u,d,h,g,f,p,y]),Ae=yc({nodes:de,edges:ue,inferNodes:!1,sourceAccessor:u,targetAccessor:d,colorBy:x,colorScheme:k,showLegend:!1,legendPosition:A,selection:void 0,linkedHover:void 0,onObservation:U,onClick:K,chartType:"ProcessSankey",chartId:J,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:B,width:T,height:R,loading:W,loadingContent:$,emptyContent:z}),je=(null!=w?w:!!x)&&!!x,Se=t.useCallback(e=>null!=B&&("number"==typeof B||null!=B[e]),[B]),Oe=t.useMemo(()=>{const e=Object.assign({},Ae.margin);return je&&("right"===A&&!Se("right")&&140>e.right?e.right=140:"bottom"===A&&!Se("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Ae.margin,je,A,Se]),Me=T-Oe.left-Oe.right,Ce=R-Oe.top-Oe.bottom,_e=t.useMemo(()=>function(e,t,o){const n=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,s=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&s&&s&&o[1]>=o[0]||n.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||n.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||n.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}(me,ve,be),[me,ve,be]),Pe=t.useMemo(()=>_e.length>0?null:function(e,t,o){var n;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=o,c=function(e,t){const o={},n={};for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),u=function(e,t,o,n="value"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===n?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const s=[...o.values()];s.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?r:i);return s};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=o});else if(0===e.length)a(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=o});else{const t=a(n,"source"),o=a(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)s.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)s.get(t.id).sourceSide=n}}}return s}(e,t,c,r);let d={};for(const t of e)d[t.id]=xc(t,c,u);const h=_c(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),g=new Set;for(const e of t){const t=h.slotByNode[e.source],o=h.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=u.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(g.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],n=new Set(e.map(e=>u.get(e.id).sourceSide)),i=new Set(o.map(e=>u.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)h.slotByNode[t.source]===h.slotByNode[t.target]&&(u.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)h.slotByNode[o.source]===h.slotByNode[o.target]&&(u.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const n=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===u.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===u.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=n(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=o.filter(t=>!g.has(t.id)&&u.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=xc(t,c,u);const f=_c(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(n=f.effectiveSlotsHeight)&&void 0!==n?n:f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(f.slots.length+1,1)),m=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,v=_c(e,t,d,c,{plotH:i,padding:y,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:y,compressedPadding:12>y,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(me,ve,{plotH:Ce,pairing:j,packing:S,laneOrder:O,lifetimeMode:C}),[_e,me,ve,Ce,j,S,O,C]),Le=t.useMemo(()=>i.scaleTime().domain(be).range([0,Me]),[be,Me]),Te=t.useCallback((e,t)=>{if(x&&de){const t=xe.get(e);if(t)return ke(t,x,Ae.colorScale)}return Ae.effectivePalette[t%Ae.effectivePalette.length]||"#475569"},[x,de,xe,Ae.colorScale,Ae.effectivePalette]),Re=t.useMemo(()=>{const e=new Map;return me.forEach((t,o)=>e.set(t.id,o)),e},[me]),Be=t.useMemo(()=>{if(!Pe)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=Pe,n=[],i=[];return me.forEach((i,r)=>{var s;const a=t[i.id];if(!a||0===a.samples.length)return;const l=function(e,t,o,n,i){if(0===e.length)return null;const r=wc(e,i),s=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let l=`M${n(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${s(e)}`;l+=` L${n(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${a(e)}`;return l+" Z"}(a.samples,e[i.id],o,Le,be);if(!l)return;const c=wc(a.samples,be),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=e[i.id]+(u.botMass-u.topMass)*o/2,h=Te(i.id,r),g=null!==(s=xe.get(i.id))&&void 0!==s?s:i,f=function(e,t,o,n,i){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const s=o.valueScale,a=o.centerlines[e],l=wc(r.samples,i),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=n(c.t),h=n(u.t),g=e=>n(kc(e,i)),f=[],p=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),n=g(o.startTime),i=t-20,r=Math.max(d,i);if(n>r){const[o,l]=Ac(e,a,s);f.push({pathD:p(r,o,n,l),x0:i,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),n=g(o.endTime),i=t+20,r=Math.min(h,i);if(r>n){const[o,l]=Ac(e,a,s);f.push({pathD:p(n,o,r,l),x0:t,x1:i,from:1,to:0})}}}}return f}(i.id,ve,Pe,Le,be);n.push(Object.assign(Object.assign({id:i.id,pathD:l,fill:h,stroke:h,strokeWidth:.5},f.length>0&&{gradientStubs:f}),{rawDatum:g,labelX:Le(u.t)-4,labelY:d,labelText:i.id}))}),ve.forEach(n=>{var r,s,a,l;const c=null===(r=t[n.source])||void 0===r?void 0:r.localAttachments.get(n.id),u=null===(s=t[n.target])||void 0===s?void 0:s.localAttachments.get(n.id);if(!c||!u)return;const d=null!==(a=Re.get(n.source))&&void 0!==a?a:0,h=Te(n.source,d),g=function(e,t,o,n,i,r,s,a){const l=i,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=r(c(e.time)),d=r(c(o.time)),h=e.value*l,g=o.value*l,f=e.sideMassBefore*l,p=o.sideMassAfter*l;let y,m,v,b;"top"===e.side?(y=t-f,m=y+h):(m=t+f,y=m-h),"top"===o.side?(v=n-p,b=v+g):(b=n+p,v=b-g);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:y,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,e[n.source],u,e[n.target],o,Le,M,be),{pathD:f,bezier:p}=dl(g),y=null!==(l=we.get(n.id))&&void 0!==l?l:n;i.push({id:n.id,pathD:f,fill:h,opacity:Y,rawDatum:y,bezier:p})}),{bands:n,ribbons:i}},[Pe,me,ve,Le,be,Te,xe,we,M,Y,Re]),Ne=t.useMemo(()=>({bands:Be.bands,ribbons:Be.ribbons,showLabels:L}),[Be,L]),Ee=t.useMemo(()=>{if(!je||!x)return;const e=new Map;(null!=de?de:[]).forEach((t,o)=>{const n=Rc(x,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:Te(ye(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[je,x,de,Te,ye]),De=t.useMemo(()=>!1!==X&&V?void 0===X||!0===X?null:gn(X)||null:null,[X,V]),Ie=t.useCallback(e=>G?G(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[G]),He=t.useCallback(e=>q?q(e):e+"",[q]),Fe=t.useCallback(t=>{if(!t||!t.data)return null;const o=t.data;if(!Lc(o))return null;const n=o.data;if(De)return De(n);if("band"===o.__kind){const t=o.id,n=Pe?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(Pe.nodeData[t]):[],i=5,r=n.length>i?n.length:null,s=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[Object.assign(Object.assign({},o[0]),{mark:"min"}),Object.assign(Object.assign({},o[Math.floor(.25*n)]),{mark:"q25"}),Object.assign(Object.assign({},o[Math.floor(.5*n)]),{mark:"median"}),Object.assign(Object.assign({},o[Math.floor(.75*n)]),{mark:"q75"}),Object.assign(Object.assign({},o[n]),{mark:"max"})],r=new Set,s=[];for(const e of i)r.has(e.t)||(r.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(n,i);return e.jsxs("div",{style:{minWidth:160},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:t}),s.length>0&&e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{opacity:.6},children:[e.jsx("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),e.jsx("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=r&&e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:{paddingRight:8},children:Ie(t.t)}),e.jsx("td",{style:{textAlign:"right"},children:He(t.total)}),null!=r&&e.jsx("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:t.mark})]},o))})]}),null!=r&&e.jsxs("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",s.length," of ",r," samples"]})]})}const i=n,r=Rc(u,i),s=Rc(d,i),a=Rc(h,i),l=Rc(g,i),c=Rc(f,i);return e.jsxs("div",{style:{minWidth:160},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:[r+""," → ",s+""]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"value"}),e.jsx("span",{style:{textAlign:"right"},children:He(Number(a))})]}),null!=l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"start"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(Tc(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(Tc(c))})]})]})]})},[Pe,De,Ie,He,u,d,h,g,f]),We=t.useMemo(()=>{if(!Pe)return null;const{centerlines:t,laneLifetime:o,nodeData:n,valueScale:i,compressedPadding:r,crossingsBefore:s,crossingsAfter:a,lengthBefore:c,lengthAfter:u}=Pe;let d=null,h=null;for(const e of me){const t=o[e.id];if(!t||null===t.start||null===t.end)continue;const n=Le(t.start),i=Le(t.end);(null===d||d>n)&&(d=n),(null===h||i>h)&&(h=i)}const g=e=>Math.max(0,Math.min(Me,e)),f=g(null!=d?d:0),p=Math.max(f,g(null!=h?h:Me));return e.jsxs("g",{children:[P&&null!==(null!=a?a:null)&&e.jsxs("text",{x:Me,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",s," → ",a," ","edge length: ",Math.round(c)," → ",Math.round(u)]}),r&&e.jsx("text",{x:Me,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((t,o)=>{const n=Le(Tc(t.date));return f-.5>n||n>p+.5?null:e.jsx("line",{x1:n,y1:0,x2:n,y2:Ce,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+o)}),_&&me.map((r,s)=>{const a=o[r.id];if(!a||null===a.start)return null;const l=n[r.id],c=l?{topPeak:l.topPeak,botPeak:l.botPeak}:{topPeak:0,botPeak:0},u=t[r.id]+(c.botPeak-c.topPeak)*i/2,d=Le(a.start),h=Le(a.end),g=Te(r.id,s);return e.jsxs("g",{children:[e.jsx("line",{x1:d,y1:u,x2:h,y2:u,stroke:g,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e.jsx("line",{x1:d,y1:u-4,x2:d,y2:u+4,stroke:g,strokeOpacity:.5}),e.jsx("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:g,strokeOpacity:.5})]},"lane-"+r.id)}),e.jsx("line",{x1:f,y1:Ce+4,x2:p,y2:Ce+4,stroke:"#94a3b8"}),l.map((t,o)=>{const n=Tc(t.date),i=Le(n);if(f-.5>i||i>p+.5)return null;const r=null!=t.label?t.label:G?G(new Date(n)):"";return e.jsxs("g",{transform:`translate(${i},${Ce+4})`,children:[e.jsx("line",{y2:6,stroke:"#94a3b8"}),e.jsx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:r})]},o)})]})},[Pe,l,Le,Me,Ce,_,me,Te,P,G]),$e=t.useMemo(()=>(null!=de?de:[]).map(e=>({id:ye(e),data:e})),[de,ye]),ze=t.useMemo(()=>{const e=new Map;for(const t of Be.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Be]),Ye=t.useMemo(()=>(null!=ue?ue:[]).map((e,t)=>{const o=pe(e,t),n=Number(Rc(h,e));return{id:o,source:Rc(u,e)+"",target:Rc(d,e)+"",value:Number.isFinite(n)?n:0,bezier:ze.get(o),data:e}}),[ue,pe,u,d,h,ze]),Ge=Ae.loadingEl,qe=Ae.emptyEl;return _e.length>0?e.jsxs("svg",{width:T,height:R,role:"img","aria-label":null!=N?N:"Process Sankey validation failed",children:[e.jsx("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),_e.map((t,o)=>{return e.jsx("text",{x:20,y:56+18*o,fontSize:12,fill:"#64748b",children:"• "+(n=t,"invalid-node-time"===n.kind?`node ${n.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===n.kind?`edge ${n.id} has an invalid startTime or endTime`:"invalid-domain"===n.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===n.kind?`edge ${n.id} must have a positive finite value`:"missing-node"===n.kind?`edge ${n.id} references missing ${n.endpoint} node "${n.nodeId}"`:"backward-edge"===n.kind?`edge ${n.id} (${n.source}->${n.target}) ends before it starts`:n.kind)},o);var n})]}):Ge||qe||e.jsx(dc,Object.assign({ref:he,chartType:"force",nodes:$e,edges:Ye,customNetworkLayout:Pc,layoutConfig:Ne,size:[T,R],responsiveWidth:H,responsiveHeight:F,margin:Oe,title:N,description:null!=E?E:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:D,accessibleTable:I,enableHover:V,tooltipContent:!1===X?()=>null:Fe,backgroundGraphics:We,showParticles:Q,particleStyle:Z,legend:Ee,legendPosition:A,onObservation:U,customClickBehavior:K?e=>{if(!e||!e.data)return;const t=e.data;Lc(t)&&K(t.data,{x:e.x,y:e.y})}:void 0,chartId:J,colorScheme:Array.isArray(k)?k:void 0},ee))});function Nc(o){const n=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,layout:a="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g,colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:y,nodeSize:m=5,tooltip:v,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:A,linkedHover:j,loading:S,loadingContent:O,legendInteraction:M,stroke:C,strokeWidth:_,opacity:P}=o,{width:L,height:T,enableHover:R,showLabels:B=!0,title:N,description:E,summary:D,accessibleTable:I}=n,H=yc({nodes:t.useMemo(()=>hc(null!=i?i:null,c),[i,c]),edges:void 0,inferNodes:!1,colorBy:f?void 0:h,colorScheme:g,showLegend:!1,legendInteraction:M,selection:A,linkedHover:j,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:n.marginDefaults,userMargin:r,width:L,height:T,loading:S,loadingContent:O}),F=t.useMemo(()=>new Map,[]),W=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?be[(e.depth||0)%be.length]:h?ke(e.data||e,h,H.colorScale):Hi(void 0,H.themeCategorical,g,void 0,F),t},[h,f,H.colorScale,H.themeCategorical,g,F]),$=t.useMemo(()=>kr(W,{stroke:C,strokeWidth:_,opacity:P}),[W,C,_,P]),z=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),Y=t.useMemo(()=>kr(z,{stroke:C,strokeWidth:_,opacity:P}),[z,C,_,P]),G=t.useMemo(()=>{if("treemap"===a||"circlepack"===a||"partition"===a)return fc(u)},[a,u]),q=mr({componentName:"TreeDiagram",data:i});return q?e.jsx(or,{componentName:"TreeDiagram",message:q,width:L,height:T}):H.loadingEl?H.loadingEl:e.jsx(sr,{componentName:"TreeDiagram",width:L,height:T,children:e.jsx(dc,Object.assign({chartType:a},null!=i&&{data:i},{size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:H.margin,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:G,treeOrientation:l,edgeType:p,nodeStyle:$,edgeStyle:Y,colorBy:h,colorScheme:H.effectivePalette,colorByDepth:f,nodeSize:m,nodeLabel:B?y||d:void 0,showLabels:B,enableHover:R,tooltipContent:!1===v?()=>null:gn(v)||void 0,customHoverBehavior:j||x||k?H.customHoverBehavior:void 0,customClickBehavior:x||k?H.customClickBehavior:void 0},M&&"none"!==M&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:s,title:N,description:E,summary:D,accessibleTable:I},null!=o.animate&&{animate:o.animate},b))})}function Ec(o){const n=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:y,tooltip:m,frameProps:v={},selection:b,linkedHover:x,onObservation:k,onClick:w,chartId:A,loading:j,loadingContent:S,legendInteraction:O,stroke:M,strokeWidth:C,opacity:_}=o,{width:P,height:L,enableHover:T,showLabels:R=!0,title:B,description:N,summary:E,accessibleTable:D}=n,I=yc({nodes:t.useMemo(()=>hc(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:O,selection:b,linkedHover:x,onObservation:k,onClick:w,chartType:"Treemap",chartId:A,marginDefaults:n.marginDefaults,userMargin:r,width:P,height:L,loading:j,loadingContent:S}),H=br(b),F=I.customHoverBehavior,W=t.useCallback(e=>{if(!e)return F(null);const t=e.data||e;F({data:(null==t?void 0:t.data)||t})},[F]),$=t.useMemo(()=>new Map,[]),z=t.useMemo(()=>e=>{const t={stroke:"#fff",strokeWidth:1,strokeOpacity:.8};return t.fill=h?be[(e.depth||0)%be.length]:u?ke(e.data||e,u,I.colorScale):Hi(void 0,I.themeCategorical,d,void 0,$),t},[u,h,I.colorScale,I.themeCategorical,d,$]),Y=t.useMemo(()=>kr(z,{stroke:M,strokeWidth:C,opacity:_}),[z,M,C,_]),G=t.useMemo(()=>I.activeSelectionHook?e=>{var t;const o=Object.assign({},Y(e));if(I.activeSelectionHook.isActive)if(I.activeSelectionHook.predicate(e.data||e))(null==H?void 0:H.selectedStyle)&&Object.assign(o,H.selectedStyle);else{const e=null!==(t=null==H?void 0:H.unselectedOpacity)&&void 0!==t?t:.5;o.opacity=e,o.fillOpacity=e,o.strokeOpacity=e,(null==H?void 0:H.unselectedStyle)&&Object.assign(o,H.unselectedStyle)}return o}:Y,[Y,I.activeSelectionHook,H]),q=t.useMemo(()=>fc(l),[l]),X=void 0!==y?y:!R||"parent"!==g&&"all"!==g?void 0:18,V=mr({componentName:"Treemap",data:i});return V?e.jsx(or,{componentName:"Treemap",message:V,width:P,height:L}):I.loadingEl?I.loadingEl:e.jsx(sr,{componentName:"Treemap",width:P,height:L,children:e.jsx(dc,Object.assign({chartType:"treemap"},null!=i&&{data:i},{size:[P,L],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:I.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:q,padding:p,paddingTop:X,nodeStyle:G,colorBy:u,colorScheme:I.effectivePalette,colorByDepth:h,nodeLabel:R?f||c:void 0,showLabels:R,labelMode:g,enableHover:T,tooltipContent:!1===m?()=>null:gn(m)||void 0},(x||k||w)&&{customHoverBehavior:W},(k||w)&&{customClickBehavior:I.customClickBehavior},O&&"none"!==O&&{legendHoverBehavior:I.legendState.onLegendHover,legendClickBehavior:I.legendState.onLegendClick,legendHighlightedCategory:I.legendState.highlightedCategory,legendIsolatedCategories:I.legendState.isolatedCategories},{className:s,title:B,description:N,summary:E,accessibleTable:D},null!=o.animate&&{animate:o.animate},v))})}function Dc(o){const n=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:y,frameProps:m={},onObservation:v,onClick:b,chartId:x,selection:k,linkedHover:w,loading:A,loadingContent:j,legendInteraction:S,stroke:O,strokeWidth:M,opacity:C}=o,{width:_,height:P,enableHover:L,showLabels:T=!0,title:R,description:B,summary:N,accessibleTable:E}=n,D=yc({nodes:t.useMemo(()=>hc(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:S,selection:k,linkedHover:w,onObservation:v,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:n.marginDefaults,userMargin:r,width:_,height:P,loading:A,loadingContent:j}),I=t.useMemo(()=>new Map,[]),H=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=h?be[(e.depth||0)%be.length]:u?ke(e.data||e,u,D.colorScale):Hi(void 0,D.themeCategorical,d,void 0,I),t},[u,h,D.colorScale,f,D.themeCategorical,d,I]),F=t.useMemo(()=>kr(H,{stroke:O,strokeWidth:M,opacity:C}),[H,O,M,C]),W=t.useMemo(()=>fc(l),[l]),$=mr({componentName:"CirclePack",data:i});return $?e.jsx(or,{componentName:"CirclePack",message:$,width:_,height:P}):D.loadingEl?D.loadingEl:e.jsx(sr,{componentName:"CirclePack",width:_,height:P,children:e.jsx(dc,Object.assign({chartType:"circlepack"},null!=i&&{data:i},{size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:D.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:W,padding:p,nodeStyle:F,colorBy:u,colorScheme:D.effectivePalette,colorByDepth:h,nodeLabel:T?g||c:void 0,showLabels:T,enableHover:L,tooltipContent:!1===y?()=>null:gn(y)||void 0,customHoverBehavior:w||v||b?D.customHoverBehavior:void 0,customClickBehavior:v||b?D.customClickBehavior:void 0},S&&"none"!==S&&{legendHoverBehavior:D.legendState.onLegendHover,legendClickBehavior:D.legendState.onLegendClick,legendHighlightedCategory:D.legendState.highlightedCategory,legendIsolatedCategories:D.legendState.isolatedCategories},{className:s,title:R,description:B,summary:N,accessibleTable:E},null!=o.animate&&{animate:o.animate},m))})}Bc.displayName="ProcessSankey",Nc.displayName="TreeDiagram",Ec.displayName="Treemap",Dc.displayName="CirclePack";const Ic=be;function Hc(o){const n=Xi(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:g=2.95,speed:f=.25,revolution:p,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:A,annotations:j,frameProps:S={},onObservation:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,loadingContent:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:E,height:D,enableHover:I,title:H,description:F,summary:W,accessibleTable:$}=n,z=yc({nodes:t.useMemo(()=>hc(i,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:!1,legendInteraction:void 0,selection:_,linkedHover:P,onObservation:O,onClick:M,chartType:"OrbitDiagram",chartId:C,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:E,height:D,loading:L,loadingContent:T}),Y=t.useMemo(()=>new Map,[]),G=t.useMemo(()=>{if(Array.isArray(u))return u;const e=ye[u];return Array.isArray(e)?e:me},[u]),q=t.useMemo(()=>e=>{var t;const o={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return o.fill=d?n?G[0]:Ic[(e.depth||0)%Ic.length]:c?ke(e.data||e,c,z.colorScale):Hi(void 0,z.themeCategorical,u,void 0,Y),o.opacity=n?1:.85,o},[c,d,z.colorScale,G,z.themeCategorical,u,Y]),X=t.useMemo(()=>kr(q,{stroke:R,strokeWidth:B,opacity:N}),[q,R,B,N]),V=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),U=t.useMemo(()=>{if(z.customHoverBehavior)return e=>{z.customHoverBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[z.customHoverBehavior]),K=t.useMemo(()=>{if(z.customClickBehavior)return e=>{z.customClickBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[z.customClickBehavior]),Q=mr({componentName:"OrbitDiagram",data:i});return Q?e.jsx(or,{componentName:"OrbitDiagram",message:Q,width:E,height:D}):z.loadingEl?z.loadingEl:e.jsx(sr,{componentName:"OrbitDiagram",width:E,height:D,children:e.jsx(dc,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[E,D],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:z.margin,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:X,edgeStyle:V,colorBy:c,colorScheme:z.effectivePalette,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===w?()=>null:gn(w)||void 0,customHoverBehavior:P||O||M?U:void 0,customClickBehavior:O||M?K:void 0,foregroundGraphics:A,annotations:j,className:s,title:H,description:F,summary:W,orbitMode:h,orbitSize:g,orbitSpeed:f,orbitRevolution:p,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:$},null!=o.animate&&{animate:o.animate},S))})}Hc.displayName="OrbitDiagram";const Fc={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},Wc={opacity:.7,marginRight:4};function $c(e,t,o){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:o]}function zc(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function Yc(t={}){const{timeAccessor:o,valueAccessor:n,xLabel:i="x",yLabel:r="y"}=t;return t=>{var s;const a=null!==(s=null==t?void 0:t.data)&&void 0!==s?s:null,l=$c(a,o,"time"),c=$c(a,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:Fc,children:[e.jsxs("div",{children:[e.jsxs("span",{style:Wc,children:[i,":"]}),zc(l)]}),e.jsxs("div",{children:[e.jsxs("span",{style:Wc,children:[r,":"]}),zc(c)]})]})}}function Gc(e,t){var o;return null!=e?e:Math.max(null!==(o=null==t?void 0:t.length)&&void 0!==o?o:0,200)}const qc=t.forwardRef(function(o,n){var i,r,s,a,l;const c=Xi(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,stroke:w="#007bff",strokeWidth:A=2,strokeDasharray:j,opacity:S,background:O,tooltipContent:M,tooltip:C,onHover:_,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:E,transition:D,linkedHover:I,selection:H,onObservation:F,chartId:W,loading:$,loadingContent:z,emptyContent:Y,emphasis:G,legendPosition:q}=o,X=c.showAxes,V=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(l=null!=M?M:C)&&void 0!==l?l:Yc({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=$i({selection:H,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeLineChart",chartId:W}),ee=t.useCallback(e=>{_&&_(e),J(e)},[_,J]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Z.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const te=ur($,K[0],K[1],z),oe=te?null:cr(y,K[0],K[1],Y),ne={stroke:w,strokeWidth:A,strokeDasharray:j};null!=S&&(ne.opacity=S);const ie=Gc(p,y);return te||oe||e.jsx(Jn,{ref:Z,chartType:"line",runtimeMode:"streaming",size:K,margin:U,className:G?`${h||""} semiotic-emphasis-${G}`.trim():h,arrowOfTime:g,windowMode:f,windowSize:ie,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,lineStyle:ne,showAxes:X,background:O,hoverAnnotation:V,tooltipContent:Q,customHoverBehavior:ee,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:E,transition:D,pointIdAccessor:o.pointIdAccessor,legendPosition:q})});qc.displayName="RealtimeLineChart";const Xc=t.forwardRef(function(o,n){var i,r,s,a,l;const c=Xi(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,showAxes:o.showAxes,enableHover:null!=o.enableHover?!!o.enableHover:void 0,linkedHover:o.linkedHover}),{binSize:u,size:d,margin:h,className:g,arrowOfTime:f="right",windowMode:p="sliding",windowSize:y,data:m,timeAccessor:v,valueAccessor:b,timeExtent:x,valueExtent:k,extentPadding:w,categoryAccessor:A,colors:j,fill:S,stroke:O,strokeWidth:M,opacity:C,gap:_,background:P,tooltipContent:L,tooltip:T,onHover:R,annotations:B,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:D,linkedHover:I,selection:H,decay:F,pulse:W,staleness:$,transition:z,onObservation:Y,chartId:G,loading:q,loadingContent:X,emptyContent:V,emphasis:U,legendPosition:K,brush:Q,onBrush:Z,linkedBrush:J}=o,ee=c.showAxes,te=c.enableHover,oe=null!=h?h:c.marginDefaults,ne=null!=d?d:[c.width,c.height],ie=null!==(l=null!=L?L:T)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n}=t;return t=>{var i;const r=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:null;if(null==(null==r?void 0:r.binStart)||null==(null==r?void 0:r.binEnd)){const t=$c(r,o,"time"),i=$c(r,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:Fc,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"x:"}),zc(t)]}),e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"y:"}),zc(i)]})]})}return e.jsxs("div",{className:"semiotic-tooltip",style:Fc,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"range:"}),zc(r.binStart),"–",zc(r.binEnd)]}),null!=r.total&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"count:"}),zc(r.total)]}),null!=r.category&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"category:"}),zc(r.category)]})]})}}({timeAccessor:v,valueAccessor:b}),re=t.useRef(null),{customHoverBehavior:se}=$i({selection:H,linkedHover:I,unwrapData:!0,onObservation:Y,chartType:"RealtimeHistogram",chartId:G}),ae=t.useCallback(e=>{R&&R(e),se(e)},[R,se]),le=!0===Q?{dimension:"x",snap:"bin"}:"x"===Q?{dimension:"x"}:"object"==typeof Q?Q:void 0,ce=Si(J),ue=gi(Object.assign({name:(null==ce?void 0:ce.name)||"__unused_hist_brush__",xField:(null==ce?void 0:ce.xField)||("string"==typeof v?v:"time")},(null==ce?void 0:ce.yField)?{yField:ce.yField}:{})),de=t.useRef(ue.brushInteraction);de.current=ue.brushInteraction;const he=t.useCallback(e=>{if(Z&&Z(e),Y&&Y(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:G}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:G}),ce){const t=de.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[Z,Y,G,ce]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=re.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=re.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=re.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=re.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=re.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=re.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=re.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ge=ur(q,ne[0],ne[1],X),fe=ge?null:cr(m,ne[0],ne[1],V),pe={};null!=S&&(pe.fill=S),null!=O&&(pe.stroke=O),null!=M&&(pe.strokeWidth=M),null!=C&&(pe.opacity=C),null!=_&&(pe.gap=_);const ye=U?`${g||""} semiotic-emphasis-${U}`.trim():g,me=Gc(y,m);return ge||fe||e.jsx(Jn,{ref:re,chartType:"bar",runtimeMode:"streaming",size:ne,margin:oe,className:ye,arrowOfTime:f,windowMode:p,windowSize:me,data:m,timeAccessor:v,valueAccessor:b,xExtent:x,yExtent:k,extentPadding:w,binSize:u,categoryAccessor:A,barColors:j,barStyle:pe,showAxes:ee,background:P,hoverAnnotation:te,tooltipContent:ie,customHoverBehavior:ae,annotations:B,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:D,decay:F,pulse:W,staleness:$,transition:z,pointIdAccessor:o.pointIdAccessor,legendPosition:K,brush:le||(J?{dimension:"x"}:void 0),onBrush:le||J?he:void 0})});Xc.displayName="RealtimeHistogram";const Vc=t.forwardRef(function(o,n){var i,r,s,a,l;const c=Xi(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,radius:j,fill:S,opacity:O,stroke:M,strokeWidth:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:N,tickFormatValue:E,linkedHover:D,selection:I,onObservation:H,chartId:F,loading:W,loadingContent:$,emptyContent:z,emphasis:Y,legendPosition:G}=o,q=c.showAxes,X=c.enableHover,V=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(l=null!=P?P:L)&&void 0!==l?l:Yc({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=$i({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeSwarmChart",chartId:F}),J=t.useCallback(e=>{T&&T(e),Z(e)},[T,Z]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Q.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Q.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ee=ur(W,U[0],U[1],$),te=ee?null:cr(y,U[0],U[1],z),oe={};null!=j&&(oe.radius=j),null!=S&&(oe.fill=S),null!=O&&(oe.opacity=O),null!=M&&(oe.stroke=M),null!=C&&(oe.strokeWidth=C);const ne=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,ie=Gc(p,y);return ee||te||e.jsx(Jn,{ref:Q,chartType:"swarm",runtimeMode:"streaming",size:U,margin:V,className:ne,arrowOfTime:g,windowMode:f,windowSize:ie,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,categoryAccessor:w,barColors:A,swarmStyle:oe,showAxes:q,background:_,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:R,svgAnnotationRules:B,tickFormatTime:N,tickFormatValue:E,legendPosition:G,pointIdAccessor:o.pointIdAccessor})});Vc.displayName="RealtimeSwarmChart";const Uc=t.forwardRef(function(o,n){var i,r,s,a,l;const c=Xi(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,positiveColor:w,negativeColor:A,connectorStroke:j,connectorWidth:S,gap:O,stroke:M,strokeWidth:C,opacity:_,background:P,tooltipContent:L,tooltip:T,onHover:R,annotations:B,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:D,linkedHover:I,selection:H,onObservation:F,chartId:W,loading:$,loadingContent:z,emptyContent:Y,emphasis:G,legendPosition:q}=o,X=c.showAxes,V=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(l=null!=L?L:T)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n}=t;return t=>{var i,r;const s=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:null,a=$c(s,o,"time"),l=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:$c(s,n,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof l?0>l?zc(l):"+"+zc(l):zc(l);return e.jsxs("div",{className:"semiotic-tooltip",style:Fc,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"x:"}),zc(a)]}),e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"Δ:"}),u]}),null!=c&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"total:"}),zc(c)]})]})}}({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=$i({selection:H,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeWaterfallChart",chartId:W}),ee=t.useCallback(e=>{R&&R(e),J(e)},[R,J]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Z.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const te=ur($,K[0],K[1],z),oe=te?null:cr(y,K[0],K[1],Y),ne={};null!=w&&(ne.positiveColor=w),null!=A&&(ne.negativeColor=A),null!=j&&(ne.connectorStroke=j),null!=S&&(ne.connectorWidth=S),null!=O&&(ne.gap=O),null!=M&&(ne.stroke=M),null!=C&&(ne.strokeWidth=C),null!=_&&(ne.opacity=_);const ie=G?`${h||""} semiotic-emphasis-${G}`.trim():h,re=Gc(p,y);return te||oe||e.jsx(Jn,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:K,margin:U,className:ie,arrowOfTime:g,windowMode:f,windowSize:re,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,waterfallStyle:ne,showAxes:X,background:P,hoverAnnotation:V,tooltipContent:Q,customHoverBehavior:ee,annotations:B,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:D,legendPosition:q,pointIdAccessor:o.pointIdAccessor})});Uc.displayName="RealtimeWaterfallChart";const Kc=t.forwardRef(function(o,n){var i,r,s,a,l;const c=Xi(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,timeExtent:x,valueExtent:k,extentPadding:w,heatmapXBins:A=20,heatmapYBins:j=20,aggregation:S="count",background:O,tooltipContent:M,tooltip:C,onHover:_,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:E,linkedHover:D,selection:I,onObservation:H,chartId:F,loading:W,loadingContent:$,emptyContent:z,emphasis:Y,legendPosition:G}=o,q=c.showAxes,X=c.enableHover,V=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(l=null!=M?M:C)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n,xLabel:i="x",yLabel:r="y"}=t;return t=>{var s,a,l,c;const u=null!==(s=null==t?void 0:t.data)&&void 0!==s?s:null,d=null!==(a=null==u?void 0:u.xCenter)&&void 0!==a?a:$c(u,o,"time"),h=null!==(l=null==u?void 0:u.yCenter)&&void 0!==l?l:$c(u,n,"value"),g=null==u?void 0:u.count,f=null==u?void 0:u.sum,p=null==u?void 0:u.value,y=null!==(c=null==u?void 0:u.agg)&&void 0!==c?c:"count";return e.jsxs("div",{className:"semiotic-tooltip",style:Fc,children:[e.jsxs("div",{children:[e.jsxs("span",{style:Wc,children:[i,":"]}),zc(d)]}),e.jsxs("div",{children:[e.jsxs("span",{style:Wc,children:[r,":"]}),zc(h)]}),null!=g&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"count:"}),zc(g)]}),"sum"===y&&null!=f&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"sum:"}),zc(f)]}),"mean"===y&&null!=p&&e.jsxs("div",{children:[e.jsx("span",{style:Wc,children:"mean:"}),zc(p)]})]})}}({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=$i({selection:I,linkedHover:D,unwrapData:!0,onObservation:H,chartType:"RealtimeHeatmap",chartId:F}),J=t.useCallback(e=>{_&&_(e),Z(e)},[_,Z]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Q.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Q.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ee=ur(W,U[0],U[1],$),te=ee?null:cr(y,U[0],U[1],z),oe=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,ne=Gc(p,y);return ee||te||e.jsx(Jn,{ref:Q,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:V,className:oe,arrowOfTime:g,windowMode:f,windowSize:ne,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,xExtent:x,yExtent:k,extentPadding:w,heatmapXBins:A,heatmapYBins:j,heatmapAggregation:S,showAxes:q,background:O,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:E,legendPosition:G,pointIdAccessor:o.pointIdAccessor})});Kc.displayName="RealtimeHeatmap";const[Qc]=A(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function Zc(e,t){return jr(this,void 0,void 0,function*(){const{format:o="png",filename:n="chart",scale:i=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),l=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",l.width+""),a.getAttribute("height")||a.setAttribute("height",l.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),Jc(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);eu(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*i,o=l.height*i,s=document.createElement("canvas");s.width=t,s.height=o;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,o),c.scale(i,i);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(a),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),s.toBlob(o=>{o?(eu(o,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function Jc(e,t){var o;const n=e.children,i=t.children,r=window.getComputedStyle(e),s=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of s){const n=r.getPropertyValue(e);n&&"none"!==n&&""!==n&&(null===(o=t.style)||void 0===o||o.setProperty(e,n))}for(let e=0;Math.min(n.length,i.length)>e;e++)Jc(n[e],i[e])}function eu(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}const tu={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"},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"}},ou={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},nu={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},iu=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],ru=["vertical","horizontal"],su={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:iu},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:iu},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}})},DifferenceChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","seriesAAccessor","seriesBAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{data:{type:"array"},xAccessor:{type:["string","function"]},seriesAAccessor:{type:["string","function"]},seriesBAccessor:{type:["string","function"]},seriesALabel:{type:"string"},seriesBLabel:{type:"string"},seriesAColor:{type:"string"},seriesBColor:{type:"string"},showLines:{type:"boolean"},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},curve:{type:"string",enum:iu},areaOpacity:{type:"number"},gradientFill:{type:["boolean","object"]},xExtent:{type:"array"},yExtent:{type:"array"},pointIdAccessor:{type:["string","function"]},windowSize:{type:"number"}})},StackedAreaChart:{required:["data","areaBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:iu},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({},tu),ou),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{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"},regression:{type:["boolean","string","object"]}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),ou),{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({},tu),ou),{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({},tu),ou),{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({},tu),ou),{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({},tu),ou),{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"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},regression:{type:["boolean","string","object"]}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},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({},tu),nu),{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:ru},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},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({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},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({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},tu),nu),{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({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},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({},tu),nu),{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({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:ru},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"},regression:{type:["boolean","string","object"]}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},tu),{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({},tu),{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:"none",dataAccessors:[],props:Object.assign(Object.assign({},tu),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},arcWidth:{type:"number"},cornerRadius:{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({},tu),nu),{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({},tu),nu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},roundedTop:{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({},tu),{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({},tu),{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:ru},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"}})},ProcessSankey:{required:["domain"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},tu),{nodes:{type:"array"},edges:{type:"array"},domain:{type:"array"},axisTicks:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},startTimeAccessor:{type:["string","function"]},endTimeAccessor:{type:["string","function"]},xExtentAccessor:{type:["string","function"]},edgeIdAccessor:{type:["string","function"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},pairing:{type:"string",enum:["value","temporal"]},packing:{type:"string",enum:["off","reuse"]},laneOrder:{type:"string",enum:["insertion","crossing-min","inside-out","crossing-min+inside-out"]},ribbonLane:{type:"string",enum:["source","target","both"]},lifetimeMode:{type:"string",enum:["full","half"]},showLaneRails:{type:"boolean"},showQualityReadout:{type:"boolean"},edgeOpacity:{type:"number"},timeFormat:{type:"function"},valueFormat:{type:"function"},showParticles:{type:"boolean"},particleStyle:{type:"object"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},tu),{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({},tu),{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({},tu),{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({},tu),{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({},tu),{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({},tu),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},tu),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},tu),{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({},tu),{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({},tu),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]},lineIdAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},tu),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function au(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function lu(e,t){const o=[],n=su[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(su).join(", ")}`]};for(const i of n.required)null==t[i]&&o.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=n.props[e];if(t){if(!au(i,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;o.push(`"${e}" should be ${n}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&o.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(n.props),r=new Set(i);for(const n of Object.keys(t))if(void 0!==t[n]&&!r.has(n)){const t=gr(n,i),r=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${i.join(", ")}.`;o.push(r)}if("array"===n.dataShape){const i=t.data,r={};for(const e of n.dataAccessors){const o=t[e];"string"==typeof o&&(r[e]=o)}const s=yr({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&o.push(s)}else if("object"===n.dataShape){const n=mr({componentName:e,data:t.data});n&&o.push(n)}else if("network"===n.dataShape){const i=vr({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});i&&o.push(i)}return{valid:0===o.length,errors:o}}const cu=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),uu=new Set(["data","nodes","edges"]),du="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function hu(e){return jr(this,arguments,void 0,function*(e,t="json"){const o="jsx"===t?gu(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(o)})}function gu(e){const{component:t,props:o}=e,n=["<"+t];for(const[e,t]of Object.entries(o))if("string"==typeof t)n.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)n.push(" "+e);else if("boolean"==typeof t&&!1===t)n.push(` ${e}={false}`);else if("number"==typeof t)n.push(` ${e}={${t}}`);else{const o=JSON.stringify(t);n.push(80>o.length?` ${e}={${o}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return n.push("/>"),n.join("\n")}function fu(){const t=function(){const e=p.useContext(Fo);return e?()=>e.setVisible(e=>!e):null}();return t?e.jsx("button",{className:"semiotic-chart-action",onClick:t,title:"Data summary","aria-label":"Toggle data summary",style:bu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}const pu={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function yu({height:t}){return e.jsx("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function mu({error:t}){return e.jsx("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:e.jsx("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:t})})}const vu=p.forwardRef(function({title:t,subtitle:o,children:n,width:i="100%",height:r=400,actions:s,chartConfig:a,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:f,style:y},m){const v=p.useRef(null),b=p.useRef(null),[x,k]=p.useState(!1),w=!1!==(null==s?void 0:s.export)&&void 0!==(null==s?void 0:s.export),A=!1!==(null==s?void 0:s.fullscreen)&&void 0!==(null==s?void 0:s.fullscreen),j=!1!==(null==s?void 0:s.copyConfig)&&void 0!==(null==s?void 0:s.copyConfig)&&a,S=!0===(null==s?void 0:s.dataSummary),O="object"==typeof(null==s?void 0:s.export)?s.export:{},M="object"==typeof(null==s?void 0:s.copyConfig)?s.copyConfig.format:"json",C=p.useCallback(e=>jr(this,void 0,void 0,function*(){b.current&&(yield Zc(b.current,Object.assign(Object.assign({},O),e)))}),[O]),_=p.useCallback(()=>{v.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):v.current.requestFullscreen().catch(()=>{}))},[]),P=p.useCallback(e=>jr(this,void 0,void 0,function*(){a&&(yield hu(a,e||M||"json"))}),[a,M]);p.useEffect(()=>{const e=()=>{k(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(m,()=>({export:C,toggleFullscreen:_,copyConfig:P,element:v.current}),[C,_,P]);const L=t||o||l||w||A||j||S||h,T=c?e.jsx(yu,{height:r}):u?e.jsx(mu,{error:u}):d?e.jsx(nr,{children:n}):n;return R=e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.jsxs("div",{ref:v,className:"semiotic-chart-container"+(f?" "+f:""),style:Object.assign(Object.assign({width:i,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},x?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y),children:[L&&e.jsxs("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[e.jsxs("div",{className:"semiotic-chart-title-area",children:[t&&e.jsx("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:t}),o&&e.jsx("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:o})]}),e.jsxs("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4},children:[l,w&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>C(),title:"Export chart","aria-label":"Export chart",style:bu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.jsx("path",{d:"M2 12h10"})]})}),S&&e.jsx(fu,{}),A&&e.jsx("button",{className:"semiotic-chart-action",onClick:_,title:x?"Exit fullscreen":"Fullscreen","aria-label":x?"Exit fullscreen":"Enter fullscreen",style:bu,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsxs(e.Fragment,x?{children:[e.jsx("path",{d:"M9 1v4h4"}),e.jsx("path",{d:"M5 13V9H1"}),e.jsx("path",{d:"M13 5H9V1"}),e.jsx("path",{d:"M1 9h4v4"})]}:{children:[e.jsx("path",{d:"M1 5V1h4"}),e.jsx("path",{d:"M13 9v4H9"}),e.jsx("path",{d:"M9 1h4v4"}),e.jsx("path",{d:"M5 13H1V9"})]})})}),j&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>P(),title:"Copy config","aria-label":"Copy chart configuration",style:bu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.jsx("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),h&&e.jsx("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:pu[h].bg,color:pu[h].color,lineHeight:"18px"},children:h})]})]}),e.jsxs("div",{className:"semiotic-chart-body",ref:b,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},x?{flex:1}:{height:r}),children:[T,g]})]})]}),S?e.jsx(Wo,{children:R}):R;var R}),bu={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function xu({children:t,columns:o="auto",minCellWidth:n=300,gap:i=16,className:r,style:s}){const a="number"==typeof o?o:void 0;return e.jsx("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===o?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${o}, 1fr)`,gap:i,width:"100%"},s),children:p.Children.map(t,t=>p.isValidElement(t)?"primary"!==t.props.emphasis||void 0!==a&&2>a?t:e.jsx("div",{style:{gridColumn:"span 2"},children:t}):t)})}function ku({children:t,context:o,position:n="right",contextSize:i=250,gap:r=12,className:s,style:a}){const l="left"===n||"right"===n,c="left"===n||"top"===n,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:r,width:"100%"},a),d=l?{flex:`0 0 ${i}px`,width:i,minHeight:0}:{flex:`0 0 ${i}px`,height:i,minWidth:0};return e.jsxs("div",{className:"semiotic-context-layout"+(s?" "+s:""),style:u,children:[e.jsx("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:t}),e.jsx("div",{style:d,children:o})]})}xu.displayName="ChartGrid",ku.displayName="ContextLayout";function wu({children:o,position:n="right",size:i=300,trigger:r="click",chartId:s,observation:a,dismissOnEmpty:l=!0,showClose:c=!0,onToggle:u,className:d,style:h}){const[g,f]=t.useState(null),[p,y]=t.useState(null),[m,v]=t.useState(!1),[b,x]=t.useState(!1),k=t.useRef(null),w=t.useRef(void 0),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:j}=fi({types:A,chartId:s,limit:1}),S=void 0!==a?a:j;t.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;f(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!l||"click-end"!==S.type&&"hover-end"!==S.type||O()},[S]),t.useEffect(()=>{null==u||u(m)},[m,u]);const O=t.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),f(null),y(null)},200)},[]);if(t.useEffect(()=>()=>clearTimeout(w.current),[]),!g&&!b)return null;const M=g&&p?o(g,p):null;if(null===M&&!b)return null;const C=function(e,t,o,n){const i={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},i),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:o?"translateX(0)":`translateX(${t}px)`,opacity:o?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:o?"translateY(0)":`translateY(${t}px)`,opacity:o?1:0}:{top:"50%",left:"50%",transform:o?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:o?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,i,m,b);return e.jsxs("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${d?" "+d:""}`,style:Object.assign(Object.assign({},C),h),children:[c&&e.jsx("button",{className:"semiotic-details-close",onClick:O,"aria-label":"Close details",style:Au,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:M})]})}const Au={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};wu.displayName="DetailsPanel";const ju=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Su=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Ou=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Mu=new Set(["LineChart","AreaChart","StackedAreaChart"]),Cu=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function _u(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[o,n,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(o)+.7152*r(n)+.0722*r(i)}function Pu(e,t){const o=_u(e),n=_u(t);return null===o||null===n?null:(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const Lu=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Tu(e){return"nominal"===e||"ordinal"===e}function Ru(e){return"quantitative"===e||"temporal"===e}const Bu={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},Nu={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},Eu={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function Du(e,t,o,n,i){var r,s;(null==e?void 0:e.field)&&(o.xAccessor=n?"value":e.field),(null==t?void 0:t.field)&&(o.yAccessor=i?"value":t.field),(null===(r=null==e?void 0:e.axis)||void 0===r?void 0:r.title)&&(o.xLabel=e.axis.title),(null===(s=null==t?void 0:t.axis)||void 0===s?void 0:s.title)&&(o.yLabel=t.axis.title)}function Iu(e,t,o){const n={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(o.length>0){n.warnings=o;for(const e of o)console.warn("[semiotic/fromVegaLite] "+e)}return n}function Hu(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)*(1-t)),i=Math.round(parseInt(o[2],16)*(1-t)),r=Math.round(parseInt(o[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function Fu(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*t),i=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*t),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}const Wu="__forecastSegment";function $u(e,t){return"function"==typeof t?t(e):!!e[t]}const zu=Object.freeze({__proto__:null,SEGMENT_FIELD:Wu,buildAnomalyAnnotations:function(e){var t,o,n;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(o=e.bandOpacity)&&void 0!==o?o:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(n=e.anomalyRadius)&&void 0!==n?n:6,label:e.label}]},buildForecast:function(e,t,o,n,i){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,o,n,i){var r,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}=n,b=e.map(e=>{let t="observed";return u&&$u(e,u)?t="forecast":c&&$u(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[Wu]:t})}),x=n._groupBy,k=[];if(x){const e=new Map;for(const t of b){const o=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(o)||e.set(o,[]),e.get(o).push(t)}const t=[];for(const[,o]of e)for(let e=0;o.length-1>e;e++)o[e][Wu]!==o[e+1][Wu]&&(t.push(Object.assign(Object.assign({},o[e+1]),{[Wu]:o[e][Wu]})),t.push(Object.assign(Object.assign({},o[e]),{[Wu]:o[e+1][Wu]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][Wu]!==b[e+1][Wu]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[Wu]:b[e][Wu]})),k.push(Object.assign(Object.assign({},b[e]),{[Wu]:b[e+1][Wu]})));if(n.trainUnderline){const e=[];for(const t of k)"training"===t[Wu]&&e.push(Object.assign(Object.assign({},t),{[Wu]:"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 o of k)"function"==typeof h&&(o[e]=h(o)),"function"==typeof g&&(o[t]=g(o));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=n.anomalyStyle,t={type:"highlight",filter:e=>$u(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,n,i):function(e,t,o,n,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=n;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const o of e)o[t]>l?p.push(Object.assign(Object.assign({},o),{[Wu]:"observed"})):f.push(Object.assign(Object.assign({},o),{[Wu]:"training"}));const y=f.map(e=>[e[t],e[o]]).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 n=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=n*s-i*i;if(Math.abs(l)>1e-12){const s=(n*a-i*r)/l,f=(r-s*i)/n,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(n-2,1)),k=y.reduce((e,t)=>e+t[0],0)/n,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,j=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...j),O=y.length>1?(y[n-1][0]-y[0][0])/(n-1):1;for(let e=1;c>=e;e++){const i=S+e*O,r=p(i),s=x*Math.sqrt(1+1/n+(w>0?Math.pow(i-k,2)/w:0))*A;v.push({[t]:i,[o]:r,[Wu]:"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(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[Wu]:"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),{[Wu]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,o,n,i);var r},createSegmentLineStyle:function(e,t){var o,n;const i=null!==(o=t.trainDasharray)&&void 0!==o?o:"8,4",r=null!==(n=t.forecastDasharray)&&void 0!==n?n:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const o=e(t),n=t[Wu];if("training"===n){let e=o.stroke;return"darken"===c?e=Hu(o.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===n){let e=o.stroke||"#666";return"lighten"===d&&(e=Fu(e,.4)),Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:void 0})}return"forecast"===n?Object.assign(Object.assign(Object.assign({},o),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):o}},darkenColor:Hu,lightenColor:Fu});exports.AreaChart=Er,exports.BarChart=Us,exports.BoxPlot=ta,exports.BubbleChart=qr,exports.CandlestickChart=us,exports.CategoryColorProvider=ti,exports.ChartContainer=vu,exports.ChartGrid=xu,exports.ChordDiagram=vc,exports.CirclePack=Dc,exports.ConnectedScatterplot=Gr,exports.ContextLayout=ku,exports.DetailsPanel=wu,exports.DifferenceChart=Ir,exports.DonutChart=aa,exports.DotPlot=ia,exports.ForceDirectedGraph=mc,exports.FunnelChart=ua,exports.GaugeChart=ca,exports.GroupedBarChart=Qs,exports.Heatmap=Xr,exports.Histogram=oa,exports.LikertChart=ba,exports.LineChart=Lr,exports.LinkedCharts=Ai,exports.MinimapChart=ns,exports.MultiAxisLineChart=cs,exports.MultiLineTooltip=function(t={}){const{fields:o=[],title:n,format:i,style:r={},className:s="",showLabels:a=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(n){const e=cn(t,n);c.push({value:un(e,i)})}o&&Array.isArray(o)&&o.length>0?o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=un(cn(t,n),r);c.push({label:a?o:void 0,value:s})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:a?e:void 0,value:un(t[e],i)})});const u=Object.assign(Object.assign({},ln),r);return Array.isArray(c)&&0!==c.length?e.jsx("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+s).trim(),style:u,children:c.map((t,o)=>e.jsxs("div",{style:{marginBottom:c.length-1>o?"4px":0},children:[t.label&&e.jsxs("strong",{children:[t.label,l]}),t.value]},o))}):null}},exports.OrbitDiagram=Hc,exports.PieChart=sa,exports.ProcessSankey=Bc,exports.QuadrantChart=is,exports.RealtimeHeatmap=Kc,exports.RealtimeHistogram=Xc,exports.RealtimeLineChart=qc,exports.RealtimeSwarmChart=Vc,exports.RealtimeWaterfallChart=Uc,exports.RidgelinePlot=ra,exports.SankeyDiagram=bc,exports.Scatterplot=zr,exports.ScatterplotMatrix=ts,exports.StackedAreaChart=Hr,exports.StackedBarChart=Ks,exports.SwarmPlot=Js,exports.SwimlaneChart=xa,exports.ThemeProvider=function({theme:t,children:o}){const n="string"==typeof t&&Ci(t)?t:void 0,i=p.useMemo(()=>function(e){return void 0!==e?L(C,Li(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?P:C}(t),[t]);return e.jsx(T,{initialState:{theme:i},children:e.jsxs(_i.Provider,{value:n,children:[e.jsx(Ti,{theme:t}),e.jsx(Ri,{children:o})]})})},exports.TooltipProvider=Qc,exports.TreeDiagram=Nc,exports.Treemap=Ec,exports.ViolinPlot=na,exports.configToJSX=gu,exports.copyConfig=hu,exports.deserializeSelections=function(e){const t=new Map;for(const[o,n]of Object.entries(e)){const e=new Map;for(const t of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:new Set(n.values)}:{type:"interval",range:n.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:o})}t.set(o,{name:n.name,resolution:n.resolution,clauses:e})}return t},exports.diagnoseConfig=function(e,t){const o=[],n=lu(e,t);for(const e of n.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return su[e]?(function(e,t,o){const n=su[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&o.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"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&o.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,o),function(e,t,o){const n=t.width,i=t.height;if(void 0===n||"number"==typeof n&&n>0||o.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||o.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,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&o.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,o),function(e,t,o){const n=su[e];if(!n||"array"!==n.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 n.dataAccessors){const n=t[e];"string"==typeof n&&(n in r||o.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,o),function(e,t,o){ju.has(e)&&Array.isArray(t.data)&&o.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,o),function(e,t,o){Su.has(e)&&(t.edges||t.data||o.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,o),function(e,t,o){const n=su[e];if(!n||"array"!==n.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&&o.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,o),function(e,t,o){t.linkedHover&&!t.selection&&o.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,o),function(e,t,o){var n;if(!Ou.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&o.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!==(n=i[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,o),function(e,t,o){if(!Mu.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=t.yAccessor||"y";"string"==typeof i&&n.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&o.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,o),function(e,t,o){var n,i;const r=null!==(n=t.width)&&void 0!==n?n: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||o.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||o.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,o),function(e,t,o){var n;const i=su[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 o=0;a>o;o++){const i=null===(n=r[o])||void 0===n?void 0:n[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&o.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,o),function(e,t,o){if(!Cu.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&o.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} 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,o),function(e,t,o){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const i=n.bottom;"number"==typeof i&&70>i&&o.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,o),function(e,t,o){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&o.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,o),function(e,t,o){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const r=i[n];"string"==typeof r&&o.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" 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,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=Pu(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&o.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,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const i=n.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=Pu(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&o.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,o),function(e,t,o){const n="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;n||i||r||o.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,o),function(e,t,o){const n=[];for(const e of Lu)"function"==typeof t[e]&&n.push(e);n.length>0&&o.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.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,o),{ok:o.every(e=>"warning"===e.severity),diagnoses:o}):{ok:0===o.length,diagnoses:o}},exports.exportChart=Zc,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!su[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:du(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const o=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(escape(atob(o)));return JSON.parse(n)},exports.fromVegaLite=function(e){var t,o,n,i,r,s,a,l,c,u,d,h;const g=[],{type:f,markProps:p}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}(e,["type"])}}(e.mark),y=e.encoding||{},m=y.x,v=y.y,b=y.color,x=y.size,k=y.theta,w=y.opacity;let A;(null===(t=e.data)||void 0===t?void 0:t.values)?A=e.data.values:(null===(o=e.data)||void 0===o?void 0:o.url)&&g.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&g.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&g.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&g.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||y.facet||y.row||y.column)&&g.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&g.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&g.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const j={};e.width&&(j.width=e.width),e.height&&(j.height=e.height);const S=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(S&&(j.title=S),(null==b?void 0:b.field)&&(j.colorBy=b.field,null===(n=b.scale)||void 0===n?void 0:n.scheme)){const e=Bu[b.scale.scheme];e&&(j.colorScheme=e)}void 0!==(null==w?void 0:w.value)&&(j.pointOpacity=w.value);const O=null==m?void 0:m.aggregate,M=null==v?void 0:v.aggregate;if(A&&(O||M)){const e=M?v:m,t=M?m:v,o=Eu[e.aggregate];if(o&&(null==t?void 0:t.field)&&e.field)A=function(e,t){const{groupBy:o,value:n,agg:i="sum"}=t,r=new Map;for(const t of e){const e=t[o]+"";r.has(e)||r.set(e,[]),r.get(e).push(Number(t[n]))}const s=[];for(const[e,t]of r){let n;switch(i){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=Math.min(...t);break;case"max":n=Math.max(...t);break;default:n=t.reduce((e,t)=>e+t,0)}s.push({[o]:e,value:n})}return s}(A,{groupBy:t.field,value:e.field,agg:o});else if(("count"===o||"count"===e.aggregate)&&(null==t?void 0:t.field)&&A){const e=new Map;for(const o of A){const n=o[t.field]+"";e.set(n,(e.get(n)||0)+1)}A=Array.from(e,([e,o])=>({[t.field]:e,value:o}))}}if((null==m?void 0:m.bin)||(null==v?void 0:v.bin)){const e="Histogram";A&&(j.data=A),(null==m?void 0:m.bin)?(j.valueAccessor=m.field,(null==v?void 0:v.field)&&(j.categoryAccessor=v.field),(null===(i=m.axis)||void 0===i?void 0:i.title)&&(j.valueLabel=m.axis.title)):(null==v?void 0:v.bin)&&(j.valueAccessor=v.field,(null==m?void 0:m.field)&&(j.categoryAccessor=m.field),(null===(r=v.axis)||void 0===r?void 0:r.title)&&(j.valueLabel=v.axis.title));const t=(null==m?void 0:m.bin)||(null==v?void 0:v.bin),o="object"==typeof t?t.maxbins:void 0;return o&&(j.bins=o),Iu(e,j,g)}let C;switch(f){case"bar":C=function(e,t,o,n,i,r,s){var a,l,c,u,d,h;let g;return(null==o?void 0:o.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",n.stackBy=o.field):g="BarChart",Tu(null==e?void 0:e.type)&&Ru(null==t?void 0:t.type)?(n.categoryAccessor=e.field,n.valueAccessor=s?"value":t.field,(null===(a=null==e?void 0:e.axis)||void 0===a?void 0:a.title)&&(n.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(n.valueLabel=t.axis.title)):Ru(null==e?void 0:e.type)&&Tu(null==t?void 0:t.type)?(n.categoryAccessor=t.field,n.valueAccessor=r?"value":e.field,n.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(n.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(n.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(n.categoryAccessor=e.field),(null==t?void 0:t.field)&&(n.valueAccessor=s?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(n.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(n.valueLabel=t.axis.title)),i&&(n.data=i),g}(m,v,b,j,A,O,M);break;case"line":if(C="LineChart",Du(m,v,j,O,M),(null==b?void 0:b.field)&&(j.lineBy=b.field),p.interpolate){const e=Nu[p.interpolate];e&&(j.curve=e)}!0===p.point&&(j.showPoints=!0),A&&(j.data=A);break;case"area":if((null==b?void 0:b.field)?(C="StackedAreaChart",j.areaBy=b.field):C="AreaChart",Du(m,v,j,O,M),p.interpolate){const e=Nu[p.interpolate];e&&(j.curve=e)}void 0!==p.opacity&&(j.areaOpacity=p.opacity),A&&(j.data=A);break;case"point":case"circle":case"square":(null==x?void 0:x.field)?(C="BubbleChart",j.sizeBy=x.field,(null===(s=x.scale)||void 0===s?void 0:s.range)&&(j.sizeRange=x.scale.range)):C="Scatterplot",Du(m,v,j,O,M),A&&(j.data=A);break;case"rect":C="Heatmap",(null==m?void 0:m.field)&&(j.xAccessor=m.field),(null==v?void 0:v.field)&&(j.yAccessor=v.field),(null==b?void 0:b.field)&&(j.valueAccessor=b.field,delete j.colorBy),(null===(a=null==m?void 0:m.axis)||void 0===a?void 0:a.title)&&(j.xLabel=m.axis.title),(null===(l=null==v?void 0:v.axis)||void 0===l?void 0:l.title)&&(j.yLabel=v.axis.title),A&&(j.data=A);break;case"arc":p.innerRadius&&p.innerRadius>0?(C="DonutChart",j.innerRadius=p.innerRadius):C="PieChart",(null==k?void 0:k.field)?j.valueAccessor=k.field:(null==v?void 0:v.field)&&(j.valueAccessor=M?"value":v.field),(null==b?void 0:b.field)&&(j.categoryAccessor=b.field),(null==m?void 0:m.field)&&!(null==k?void 0:k.field)&&(j.categoryAccessor=m.field),A&&(j.data=A);break;case"tick":C="DotPlot",Tu(null==m?void 0:m.type)?(j.categoryAccessor=m.field,(null==v?void 0:v.field)&&(j.valueAccessor=M?"value":v.field),(null===(c=null==m?void 0:m.axis)||void 0===c?void 0:c.title)&&(j.categoryLabel=m.axis.title),(null===(u=null==v?void 0:v.axis)||void 0===u?void 0:u.title)&&(j.valueLabel=v.axis.title)):Tu(null==v?void 0:v.type)?(j.categoryAccessor=v.field,(null==m?void 0:m.field)&&(j.valueAccessor=O?"value":m.field),j.orientation="horizontal",(null===(d=null==v?void 0:v.axis)||void 0===d?void 0:d.title)&&(j.categoryLabel=v.axis.title),(null===(h=null==m?void 0:m.axis)||void 0===h?void 0:h.title)&&(j.valueLabel=m.axis.title)):((null==m?void 0:m.field)&&(j.categoryAccessor=m.field),(null==v?void 0:v.field)&&(j.valueAccessor=M?"value":v.field)),A&&(j.data=A);break;default:g.push(`Unsupported mark type "${f}". Defaulting to Scatterplot.`),C="Scatterplot",Du(m,v,j,O,M),A&&(j.data=A)}return Iu(C,j,g)},exports.serializeSelections=function(e){const t={};for(const[o,n]of e){const e=[];for(const[,t]of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:Array.from(n.values)}:{type:"interval",range:n.range};e.push({clientId:t.clientId,type:t.type,fields:o})}t[o]={name:n.name,resolution:n.resolution,clauses:e}}return t},exports.toConfig=function(e,t,o){if(!su[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(su).join(", ")}`);const n=!1!==(null==o?void 0:o.includeData),i={};for(const[e,o]of Object.entries(t))null!=o&&(cu.has(e)||!n&&uu.has(e)||"function"!=typeof o&&((null==o?void 0:o.$$typeof)||(i[e]=du(o))));return Object.assign({component:e,props:i,version:"1",createdAt:(new Date).toISOString()},(null==o?void 0:o.selections)?{selections:o.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.useBrushSelection=gi,exports.useCategoryColors=oi,exports.useChartObserver=fi,exports.useFilteredData=function(e,o,n){const i=ai(e=>e.selections.get(o));return t.useMemo(()=>{if(!i||0===i.clauses.size)return e;const t=ii(i,n);return e.filter(t)},[e,i,n])},exports.useLinkedHover=di,exports.useSelection=ui,exports.useTheme=Bi,exports.validateProps=lu;
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),o=require("d3-selection"),n=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-shape"),a=require("d3-array"),l=require("d3-hierarchy"),c=require("regression"),u=require("d3-interpolate"),d=require("d3-force"),h=require("d3-chord");function g(e){return e&&e.__esModule?e:{default:e}}function f(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const o in e)if("default"!==o){const n=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,n.get?n:{enumerable:!0,get:function(){return e[o]}})}return t.default=e,Object.freeze(t)}const p=f(t),y=g(c),m=Object.freeze([]);function v(e){if(!e)return m;let t=!1;for(let o=0;e.length>o;o++){const n=e[o];if(null==n||"object"!=typeof n){t=!0;break}}if(!t)return e;const o=[];for(const t of e)null!=t&&"object"==typeof t&&o.push(t);return o}function b(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n+1>>1;t[i]>e?n=i-1:o=i}return t[o]}function x(e,t){let o=0,n=t.length-1;for(;n>o;){const i=o+n>>1;e>t[i]?o=i+1:n=i}return t[o]}function k({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:g,binBoundaries:f,snapDuring:p,streaming:y}){const m=t.useRef(null),v=t.useRef(null),k=t.useRef(d);k.current=d;const w=t.useRef(u);w.current=u;const A=t.useMemo(()=>f?[...f].sort((e,t)=>e-t):void 0,[f]),j=t.useRef(A);j.current=A;const S=t.useRef(!1),C=t.useRef(null);return t.useEffect(()=>{if(!m.current)return;const e=o.select(m.current).select(".brush-g"),t="x"===c?n.brushX():"y"===c?n.brushY():n.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",o=>{if(S.current)return;const n=w.current;if(!n)return;if(!o.selection)return C.current=null,void k.current(null);let s,a;if("x"===c){const[e,t]=o.selection;s=[n.x.invert(e),n.x.invert(t)],a=[n.y.invert(r),n.y.invert(0)]}else if("y"===c){const[e,t]=o.selection;s=[n.x.invert(0),n.x.invert(i)],a=[n.y.invert(t),n.y.invert(e)]}else{const[[e,t],[i,r]]=o.selection;s=[n.x.invert(e),n.x.invert(i)],a=[n.y.invert(r),n.y.invert(t)]}if("bin"===g&&"y"!==c&&("end"===o.type||"brush"===o.type&&p)){const i=j.current;i&&i.length>0?s=function(e,t){return 0===t.length?e:[b(e[0],t),x(e[1],t)]}(s,i):h&&h>0&&(s=[Math.floor(s[0]/h)*h,Math.ceil(s[1]/h)*h]);const r=n.x(s[0]),a=n.x(s[1]);if(S.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const n=o.selection;e.call(t.move,[[r,n[0][1]],[a,n[1][1]]])}S.current=!1}const l={x:s,y:a};C.current=l,k.current(l)}),e.call(t),v.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),v.current=null}},[i,r,c,g,h,p]),t.useEffect(()=>{if(!(y&&u&&v.current&&C.current))return;if(!m.current)return;if("y"===c)return;const e=C.current,t=u.x.domain()[0],n=o.select(m.current).select(".brush-g");if(t>=e.x[1])return S.current=!0,n.call(v.current.move,null),S.current=!1,C.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=j.current;e&&e.length>0?i=x(t,e):h&&h>0&&(i=Math.ceil(t/h)*h)}if(i>=e.x[1])return S.current=!0,n.call(v.current.move,null),S.current=!1,C.current=null,void k.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(S.current=!0,"x"===c)n.call(v.current.move,[s,a]);else{const t=u.y(e.y[1]),o=u.y(e.y[0]);n.call(v.current.move,[[s,t],[a,o]])}if(S.current=!1,r){const t={x:[i,e.x[1]],y:e.y};C.current=t,k.current(t)}},[u,y,c,g,h]),e.jsx("svg",{ref:m,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 w{constructor(e,t){var o,n;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(o=null==t?void 0:t.chunkThreshold)&&void 0!==o?o:5e3,this.chunkSize=null!==(n=null==t?void 0:t.chunkSize)&&void 0!==n?n:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(e=v(e),this.lastBoundedData===e)return;if(this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}setReplacementData(e){if(e=v(e),this.lastBoundedData=e,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.pushBuffer=[],this.flushScheduled=!1,this.chunkThreshold>=e.length)return void this.callback({inserts:e,bounded:!0,preserveCategoryOrder:!0});this.callback({inserts:e.slice(0,this.chunkSize),bounded:!0,preserveCategoryOrder:!0,totalSize:e.length});let t=this.chunkSize;const o=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const n=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,n),bounded:!1}),t=n,this.chunkTimer=e.length>t?requestAnimationFrame(o):0};this.chunkTimer=requestAnimationFrame(o)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let o=0;e.length>o;o++){const n=e[o];null!=n&&"object"==typeof n&&(this.pushBuffer.push(n),t++)}0!==t&&this.scheduleFlush()}flush(){this.flushPushBuffer()}clear(){this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0),this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1}}function A(o){let n=null;const i=()=>(n||(n=t.createContext(null)),n),r=j(o);return[function({children:n,initialState:r}){const s=t.useRef(r),a=t.useMemo(()=>j(o,s.current),[]),l=i();return e.jsx(l.Provider,{value:a,children:n})},e=>{var o;const n=i(),s=null!==(o=t.useContext(n))&&void 0!==o?o:r,a=t.useRef(e);a.current=e;const l=t.useCallback(()=>a.current(s.getState()),[s]),c=t.useCallback(()=>a.current(s.getState()),[s]);return t.useSyncExternalStore(s.subscribe,l,c)}]}function j(e,t){const o=new EventTarget;let n=Object.assign(Object.assign({},e(function(e){n=Object.assign(Object.assign({},n),e(n)),o.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>n,subscribe:function(e){return o.addEventListener("update",e),()=>o.removeEventListener("update",e)}}}function S(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 C(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:O})})),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 O=["#0072B2","#E69F00","#009E73","#CC79A7","#56B4E9","#D55E00","#F0E442","#000000"],M={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}},P={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}},_={mode:"light",colors:{primary:"#0000cc",secondary:"#333333",categorical:O,sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#000000",textSecondary:"#333333",grid:"#999999",border:"#000000",focus:"#0000cc",selection:"#0000cc",selectionOpacity:.1,success:"#006400",danger:"#cc0000",warning:"#b15a00",error:"#8b0000",info:"#0000cc"},typography:{fontFamily:"system-ui, sans-serif",titleSize:18,labelSize:14,tickSize:12},tooltip:{background:"#000000",text:"#ffffff",borderRadius:"4px",fontSize:"14px",shadow:"0 2px 8px rgba(0, 0, 0, 0.3)"},borderRadius:"4px"};function L(e,t){if("light"===t)return M;if("dark"===t)return P;if("high-contrast"===t)return _;if("string"==typeof t)return void 0!==console&&console.warn(`[ThemeStore] Unknown theme preset "${t}". Keeping current theme.`),e;if(t.mode&&"auto"!==t.mode){const e="dark"===t.mode?P:M;return C(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 C(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||{})}))}const[T,R]=A(e=>({theme:M,setTheme(t){e(e=>({theme:L(e.theme,t)}))}}));class B{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 o of e){const e=this.push(o);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 o=0;this._size>o;o++)e(this.buffer[(t+o)%this._capacity],o)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let o=0;this._size>o;o++)e[o]=this.buffer[(t+o)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),o=[];for(;t.length>e;)o.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 o}update(e,t){const o=[],n=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(n+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),o.push(e),this.buffer[r]=t(s)}}return o}remove(e){const t=[],o=[];if(this.forEach(n=>{e(n)?o.push(n):t.push(n)}),0===o.length)return o;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return o}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class N{constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const o of e){const e=t?t(o):o;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function D(e,t,o,n,i){const r=new Map;for(const s of e){const e=t(s),a=o(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/n)*n;let c=r.get(l);if(c||(c={start:l,end:l+n,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 E(e,t,o,n,i,r){const s=[];for(const i of e){const e=o(i),r=n(i);Number.isFinite(e)&&Number.isFinite(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 I(e,t,o,n,i,r,s,a){const l=[];for(const r of e){const e=o(r),s=n(r);if(!Number.isFinite(e)||!Number.isFinite(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 H(e,t,o,n){var i,r,s;const a=new Map;if("silhouette"===n)for(const n of e){let e=0;for(const i of t)e+=o(i,n)||0;a.set(n,-e/2)}else if("wiggle"===n){e.length>0&&a.set(e[0],0);for(let n=1;e.length>n;n++){const r=e[n-1],s=e[n];let l=0,c=0,u=0;for(const e of t){const t=o(e,s)||0;l+=(2*u+t)*(t-(o(e,r)||0)),c+=t,u+=t}const d=null!==(i=a.get(r))&&void 0!==i?i:0;a.set(s,d-(c>0?l/(2*c):0))}if(e.length>0){let n=0;for(const i of e){let e=0;for(const n of t)e+=o(n,i)||0;n+=(null!==(r=a.get(i))&&void 0!==r?r:0)+e/2}const i=n/e.length;for(const t of e)a.set(t,(null!==(s=a.get(t))&&void 0!==s?s:0)-i)}}else for(const t of e)a.set(t,0);return a}function F(e,t,o,n,i,r,s){const a=o(e),l=n(e);if(!Number.isFinite(a)||!Number.isFinite(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 $(e,t,o,n,i,r,s){return{type:"rect",x:e,y:t,w:o,h:n,style:i,datum:r,group:s}}function W(e,t,o,n,i,r,s){const a={type:"heatcell",x:e,y:t,w:o,h:n,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 z(e,t){return e===t||typeof e==typeof t&&"function"==typeof e&&"function"==typeof t&&""+e==""+t}function G(e,t){if("function"==typeof e)return t=>+e(t);const o=e||t;return e=>+e[o]}function Y(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function q(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function X(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function V(e,t,o){const n=e=>e.toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(o)}`}function U(e){const t=e.map(X),o=t.length-1;return e=>{if(0>=e){const[e,o,n]=t[0];return V(e,o,n)}if(e>=1){const[e,n,i]=t[o];return V(e,n,i)}const n=e*o,i=Math.floor(n),r=n-i,[s,a,l]=t[i],[c,u,d]=t[i+1];return V(Math.round(s+(c-s)*r),Math.round(a+(u-a)*r),Math.round(l+(d-l)*r))}}const K=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Q=U(["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]),Z=U(["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]),J=U(["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]),ee=U(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]),te=U(["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]),oe=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),ne=U(["#440154","#482878","#3e4989","#31688e","#26828e","#1f9e89","#35b779","#6ece58","#b5de2b","#fde725"]),ie=U(["#0d0887","#41049d","#6a00a8","#8f0da4","#b12a90","#cb4679","#e16462","#f1844b","#fca636","#fcce25","#f0f921"]),re=U(["#000004","#160b39","#420a68","#6a176e","#932667","#bc3754","#dd513a","#f3771a","#fca50a","#f6d746","#fcffa4"]),se=U(["#000004","#140e36","#3b0f70","#641a80","#8c2981","#b73779","#de4968","#f7705c","#fe9f6d","#fecf92","#fcfdbf"]),ae=U(["#00224e","#123570","#3b496c","#575d6d","#707173","#8a8678","#a59c74","#c3b369","#e1cc55","#fee838","#ffea46"]),le=U(["#23171b","#4a58dd","#3f9ee9","#46c7af","#7eed5a","#cdf134","#fbb91f","#f56918","#c52f06","#7a0403"]),ce=U(["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]),ue=U(["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]),de=U(["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]),he=U(["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]),ge=U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),fe=U(["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]),pe=U(["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]),ye={category10:K,tableau10:["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc949","#af7aa1","#ff9da7","#9c755f","#bab0ab"],set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],blues:Q,reds:Z,greens:J,oranges:ee,purples:te,viridis:ne,plasma:ie},me=K,ve=["#4e79a7","#f28e2b","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],be=["#f0f0f0","#b5d4ea","#f4c2a1","#b8dab2","#d4b5e0","#f9e0a2","#a8d8d8"],xe=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 ke(e,t,o){if("function"==typeof t){const n=t(e);return o&&n&&"string"==typeof n&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||xe.has(t)}(n)?o(n):n}const n=(null==e?void 0:e[t])+"";return o?o(n):me[Math.abs(function(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o),t&=t;return Math.abs(t)}(n))%me.length]}function we(e,t,o="category10"){const n=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=n.every(e=>!isNaN(Number(e)));if(Array.isArray(o))return i.scaleOrdinal().domain(n).range(o).unknown("#999");const s=ye[o]||ye.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of n){const o=Number(t);o>e&&(e=o)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:me;return i.scaleOrdinal().domain(n).range(e).unknown("#999")}}function Ae(e,t,o=[3,20],n){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!n)return i;const[r,s]=n,[a,l]=o;if(s===r)return(a+l)/2;let c=(i-r)/(s-r);return 0>c?c=0:c>1&&(c=1),a+c*(l-a)}function je(e,t,o){var n,i,r;if(1>=o)return 1;const s=null!==(n=e.minOpacity)&&void 0!==n?n:.1,a=o-1-t;switch(e.type){case"linear":return s+(1-a/(o-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:o/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*o)>a?1:s;default:return 1}}function Se(e,t,o){var n;const i=null!==(n=e.duration)&&void 0!==n?n:500,r=o-t;return i>r?1-r/i:0}function Ce(e,t="ease-out-cubic"){return"linear"===t?e:1-Math.pow(1-e,3)}function Oe(e,t){return Math.min((e-t.startTime)/t.duration,1)}function Me(e,t,o){return e+(t-e)*o}function Pe(){return"undefined"!=typeof performance?performance.now():Date.now()}function _e(e,t,o){var n,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 o=e.getX(t.datum),n=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${o}:${n}`;if(null!=o&&null!=n)return`p:${o}:${n}`}return"p:"+o;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(n=t.datum)||void 0===n?void 0:n.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:o}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+o:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Le(e,t,o,n){return"function"==typeof t.style?t.style(n||{},o):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(o,n)}function Te(e,t,o,n){if(!e.scales)return null;const i=[],r=[];for(const o of t){const t=e.getX(o);if(!Number.isFinite(t))continue;const s=n.getTop(o),a=n.getBottom(o);if(!Number.isFinite(s)||!Number.isFinite(a))continue;const l=e.scales.x(t),c=e.scales.y(s),u=e.scales.y(a);Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(u)&&(i.push([l,c]),r.push([l,u]))}return 2>i.length?null:{type:"area",topPath:i,bottomPath:r,style:Le(e,n,o,t[0]),datum:t,group:o,interactive:n.interactive}}function Re(e){const t=[],o=[];if(!e)return{perSeries:t,aggregate:o};for(const n of e)n.perSeries?t.push(n):o.push(n);return{perSeries:t,aggregate:o}}function Be(e,t,o){const n=[];for(const i of o){const o=Te(e,t,"__ribbon_aggregate",i);o&&n.push(o)}return n}function Ne(e,t,o,n){const i=[];for(const r of n){const n=Te(e,t,o,r);n&&i.push(n)}return i}function De(e,t){if(!e)return{};if(!t||0===t.length)return e;const o=[];for(const n of t){if("band"!==n.kind)continue;const t=n.getTop(e),i=n.getBottom(e);Number.isFinite(i)&&Number.isFinite(t)&&o.push({y0:i,y1:t})}return 0===o.length?e:Object.assign(Object.assign({},e),{band:o[0],bands:o})}function Ee(e,t,o,n){var i;if(!e.config.pointStyle)return;const r=null!=n?n:e.getY;for(const n of t){const t=e.resolveGroupColor(n.key);for(const s of n.data){let n=e.config.pointStyle(s);!n.fill&&t&&(n=Object.assign(Object.assign({},n),{fill:t}));const a=null!==(i=n.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=F(s,e.scales,e.getX,r,a,n,l);c&&o.push(c)}}}const Ie={topOpacity:.8,bottomOpacity:.05};function He(e){var t,o;if(e)return!0===e?Ie:"colorStops"in e?e:{topOpacity:null!==(t=e.topOpacity)&&void 0!==t?t:Ie.topOpacity,bottomOpacity:null!==(o=e.bottomOpacity)&&void 0!==o?o:Ie.bottomOpacity}}const Fe={blues:Q,reds:Z,greens:J,viridis:ne,oranges:ee,purples:te,greys:oe,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le},$e=new Map;function We(e,t){const o="function"==typeof e?e:o=>o[e||t];return e=>{const t=o(e);return null==t?NaN:+t}}function ze(e){const t=[],o=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,n=We(o&&e.valueAccessor||e.yAccessor,o?"value":"y");if(e.boundsAccessor){const o=G(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const i=o(e);return Number.isFinite(i)&&0!==i?t+i:t},getBottom:e=>{const t=n(e);if(!Number.isFinite(t))return NaN;const i=o(e);return Number.isFinite(i)&&0!==i?t-i:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const o=Array.isArray(e.band)?e.band:[e.band];for(const e of o)t.push({kind:"band",getTop:We(e.y1Accessor,"y1"),getBottom:We(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}class Ge{constructor(e){if(this.xExtent=new N,this.yExtent=new N,this.resolvedRibbons=[],this.timestampBuffer=null,this.activeTransition=null,this._hasRenderedOnce=!1,this.prevPositionMap=new Map,this.prevPathMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this._colorMapCache=null,this._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.customLayoutOverlays=null,this.xIsDate=!1,this._quadtree=null,this._maxPointRadius=0,this._lastBoundedInsertsRef=null,this.config=e,this.buffer=new B(e.windowSize),this.growingCap=e.windowSize,["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode?(this.getX=G(e.timeAccessor||e.xAccessor,"time"),this.getY=G(e.valueAccessor||e.yAccessor,"value")):(this.getX=G(e.xAccessor,"x"),this.getY=G(e.yAccessor,"y")),this.getGroup=q(e.groupAccessor),this.getCategory=q(e.categoryAccessor),this.getSize=e.sizeAccessor?G(e.sizeAccessor,"size"):void 0,this.getColor=q(e.colorAccessor),this.getY0=e.y0Accessor?G(e.y0Accessor,"y0"):void 0,this.resolvedRibbons=ze(e),this.getPointId=q(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,o=null!=e.closeAccessor;this.getOpen=t?G(e.openAccessor,"open"):void 0,this.getHigh=G(e.highAccessor,"high"),this.getLow=G(e.lowAccessor,"low"),this.getClose=o?G(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!o}e.pulse&&(this.timestampBuffer=new B(e.windowSize))}pushDatumYExtent(e){if("candlestick"===this.config.chartType&&this.getHigh&&this.getLow)return this.yExtent.push(this.getHigh(e)),void this.yExtent.push(this.getLow(e));this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&this.yExtent.push(o),Number.isFinite(n)&&this.yExtent.push(n)}}rebuildYExtent(){this.yExtent.clear();for(const e of this.buffer)this.pushDatumYExtent(e)}rebuildExtents(){this.xExtent.clear(),this.yExtent.clear();for(const e of this.buffer)this.xExtent.push(this.getX(e)),this.pushDatumYExtent(e)}ingest(e){if(e.bounded&&this._lastBoundedInsertsRef===e.inserts)return!1;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._lastBoundedInsertsRef=e.inserts,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?G(this.config.timeAccessor||this.config.xAccessor,"time"):G(this.config.xAccessor,"x"),this.xIsDate=!1,e.inserts.length>0){const t=e.inserts[0],o=this.config.xAccessor,n="function"==typeof o?o(t):t[o||"x"],i=n instanceof Date,r="string"==typeof n&&n.length>=10&&!isNaN(new Date(n).getTime())&&isNaN(Number(n));if(this.xIsDate=i||r,r){const e="string"==typeof o?o:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(o(e)instanceof Date?o(e):new Date(o(e)))}}const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)if(this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o));else{this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o));for(const e of this.resolvedRibbons){const t=e.getTop(o),n=e.getBottom(o);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(n)&&this.yExtent.push(n)}}}else for(const o 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(o);if(this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(o)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(o)),this.yExtent.push(this.getLow(o));else{this.yExtent.push(this.getY(o)),this.getY0&&this.yExtent.push(this.getY0(o));for(const e of this.resolvedRibbons){const t=e.getTop(o),n=e.getBottom(o);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(n)&&this.yExtent.push(n)}}if(null!=e)if(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));else{this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e));for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&this.yExtent.evict(o),Number.isFinite(n)&&this.yExtent.evict(n)}}}return!0}computeScene(e){var t,o,n,r,s,a,l,c,u,d,h,g,f,p;const{config:y,buffer:m}=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);this.xExtent.dirty&&this.xExtent.recalculate(m,this.getX),this.yExtent.dirty&&this.rebuildYExtent();const v=this.getBufferArray(),b=this.xExtent.extent,x=this.yExtent.extent;let k=y.xExtent?[null!==(o=y.xExtent[0])&&void 0!==o?o:b[0],null!==(n=y.xExtent[1])&&void 0!==n?n:b[1]]:b,w=y.yExtent?[null!==(r=y.yExtent[0])&&void 0!==r?r:x[0],null!==(s=y.yExtent[1])&&void 0!==s?s:x[1]]:x;const A=y.yExtent&&null!=y.yExtent[0]&&null!=y.yExtent[1],j="exact"===y.axisExtent;if("stackedarea"===y.chartType&&!A&&m.size>0)if(y.normalize)w=[0,j?1:1+y.extentPadding];else{const e=`${m.size}:${this._ingestVersion}:${null!==(a=y.baseline)&&void 0!==a?a:"zero"}:${null!==(l=y.stackOrder)&&void 0!==l?l:"key"}`;if(this._stackExtentCache&&this._stackExtentCache.key===e)w=this._stackExtentCache.yDomain;else{const t=this.groupData(v),o=new Map,n=new Set;let i=0;const r=new Map,s=new Map;for(const e of t){const t=new Map;let a=0;for(const o of e.data){const e=this.getX(o),s=this.getY(o);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),n.add(e),a+=s;const l=(r.get(e)||0)+s;r.set(e,l),l>i&&(i=l)}o.set(e.key,t),s.set(e.key,a)}const a=null!==(c=y.stackOrder)&&void 0!==c?c:"key",l=(e,t)=>t>e?-1:e>t?1:0;let f;if("insideOut"===a){const e=[...t].map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(t))&&void 0!==o?o:0)-(null!==(n=s.get(e))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}),o=[],n=[];let i=0,r=0;for(const t of e)r>i?(o.push(t),i+=null!==(u=s.get(t))&&void 0!==u?u:0):(n.push(t),r+=null!==(d=s.get(t))&&void 0!==d?d:0);f=[...n.reverse(),...o]}else f="asc"===a?t.map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(e))&&void 0!==o?o:0)-(null!==(n=s.get(t))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}):"desc"===a?t.map(e=>e.key).sort((e,t)=>{var o,n;const i=(null!==(o=s.get(t))&&void 0!==o?o:0)-(null!==(n=s.get(e))&&void 0!==n?n:0);return 0!==i?i:l(e,t)}):t.map(e=>e.key).sort(l);if("wiggle"===y.baseline||"silhouette"===y.baseline){const e=Array.from(n).sort((e,t)=>e-t),t=H(e,f,(e,t)=>{var n;return(null===(n=o.get(e))||void 0===n?void 0:n.get(t))||0},y.baseline);let i=1/0,s=-1/0;for(const o of e){const e=null!==(h=t.get(o))&&void 0!==h?h:0,n=null!==(g=r.get(o))&&void 0!==g?g:0;i>e&&(i=e),e+n>s&&(s=e+n)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=j?0:a>0?a*y.extentPadding:1;w=[i-l,s+l]}else w=[0,i+(j?0:i>0?i*y.extentPadding:1)];this._stackExtentCache={key:e,yDomain:w}}}else if("bar"===y.chartType&&y.binSize&&!A&&m.size>0){const[,e]=function(e,t,o,n,i){const r=D(e,t,o,n,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]}(m,this.getX,this.getY,y.binSize,this.getCategory);w=[0,j?e:e+e*y.extentPadding]}else if("waterfall"===y.chartType&&!A&&m.size>0){const[e,t]=function(e,t){let o=0,n=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,o>i&&(o=i),i>n&&(n=i))}return[o,n]}(m,this.getY),o=t-e,n=j?0:o>0?o*y.extentPadding:1;w=[Math.min(0,e-Math.abs(n)),Math.max(0,t+Math.abs(n))]}else if(!A&&w[0]!==1/0){if(this.resolvedRibbons.length>0)for(const e of v)for(const t of this.resolvedRibbons){const o=t.getTop(e),n=t.getBottom(e);Number.isFinite(o)&&(w[0]>o&&(w[0]=o),o>w[1]&&(w[1]=o)),Number.isFinite(n)&&(w[0]>n&&(w[0]=n),n>w[1]&&(w[1]=n))}const e=w[1]-w[0],t=j?0:e>0?e*y.extentPadding:1,o=null===(f=y.yExtent)||void 0===f?void 0:f[0],n=null===(p=y.yExtent)||void 0===p?void 0:p[1];w=[null!=o?w[0]:w[0]-t,null!=n?w[1]:w[1]+t],"log"!==y.yScaleType||w[0]>0||0>=x[0]||j||(w[0]=null!=o?w[0]:x[0]/(1+y.extentPadding))}if(y.yExtent&&!A){const e=y.yExtent[0],t=y.yExtent[1];null==e&&null==t||(w=[null!=e?e:w[0],null!=t?t:w[1]])}if(k[0]===1/0||k[1]===-1/0)if("time"===y.xScaleType){const e=Date.now();k=[e-864e5,e]}else k=[0,1];w[0]!==1/0&&w[1]!==-1/0||(w=[0,1]);const S="streaming"===y.runtimeMode,C=Math.max(0,Math.min(y.scalePadding||0,Math.min(e.width,e.height)/2-1));if(S)if("x"==("up"===(O=y.arrowOfTime)||"down"===O?"y":"x")){const t="right"===y.arrowOfTime?[C,e.width-C]:[e.width-C,C];this.scales={x:i.scaleLinear().domain(k).range(t),y:i.scaleLinear().domain(w).range([e.height-C,C])}}else{const t="down"===y.arrowOfTime?[C,e.height-C]:[e.height-C,C];this.scales={x:i.scaleLinear().domain(w).range([C,e.width-C]),y:i.scaleLinear().domain(k).range(t)}}else{const t=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)};this.scales={x:t(y.xScaleType,k,[C,e.width-C]),y:t(y.yScaleType,w,[e.height-C,C])}}var O;this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(e,v),this.config.decay&&this.applyDecay(this.scene,v),this.config.pulse&&this.applyPulse(this.scene,v),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,o=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>o&&(o=e.r));if(this._maxPointRadius=o,Ge.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const n=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(n[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,o=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const n of e.path)n[0]*=t,n[1]*=o;break;case"area":for(const n of e.topPath)n[0]*=t,n[1]*=o;for(const n of e.bottomPath)n[0]*=t,n[1]*=o;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*o,width:e.clipRect.width*t,height:e.clipRect.height*o});break;case"point":e.x*=t,e.y*=o;break;case"rect":case"heatcell":e.x*=t,e.y*=o,e.w*=t,e.h*=o;break;case"candlestick":e.x*=t,e.openY*=o,e.closeY*=o,e.highY*=o,e.lowY*=o}const n=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,o)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(o).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(o):i.scaleLinear().domain(t).range(o)},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,n,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 o,n,i,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(o=c.layoutMargin)&&void 0!==o?o:{top:0,right:0,bottom:0,left:0},d={data:t,scales:u,dimensions:{width:e.width,height:e.height,margin:l,plot:{x:0,y:0,width:e.width,height:e.height}},theme:{semantic:null!==(n=c.themeSemantic)&&void 0!==n?n:{},categorical:null!==(i=c.themeCategorical)&&void 0!==i?i:ve},resolveColor:(e,t)=>{var o,n;const i=this.resolveGroupColor(e);if(i)return i;const r=this.resolveLineStyle(e,t);return r.stroke?r.stroke:"string"==typeof r.fill?r.fill:null!==(n=null===(o=c.themeSemantic)||void 0===o?void 0:o.primary)&&void 0!==n?n:"#4e79a7"},config:null!==(r=c.layoutConfig)&&void 0!==r?r:{}};let h;try{h=c.customLayout(d)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customLayout threw:",e),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(s=h.overlays)&&void 0!==s?s:null,null!==(a=h.nodes)&&void 0!==a?a:[]}if(this.customLayoutOverlays=null,0===t.length)return[];const d={scales:u,config:c,getX:this.getX,getY:this.getY,getY0:this.getY0,getSize:this.getSize,getColor:this.getColor,getGroup:this.getGroup,getCategory:this.getCategory,getPointId:this.getPointId,ribbons:this.resolvedRibbons,getOpen:this.getOpen,getHigh:this.getHigh,getLow:this.getLow,getClose:this.getClose,resolveLineStyle:(e,t)=>this.resolveLineStyle(e,t),resolveAreaStyle:(e,t)=>this.resolveAreaStyle(e,t),resolveBoundsStyle:(e,t)=>this.resolveBoundsStyle(e,t),resolveColorMap:e=>this.resolveColorMap(e),resolveGroupColor:e=>this.resolveGroupColor(e),groupData:e=>this.groupData(e),barCategoryCache:this._barCategoryCache};switch(c.chartType){case"line":return function(e,t){var o;const n=e.groupData(t),i=[],r=null===(o=e.config.annotations)||void 0===o?void 0:o.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:o,aggregate:r}=Re(e.ribbons);if(r.length>0&&i.push(...Be(e,t,r)),o.length>0)for(const t of n)i.push(...Ne(e,t.data,t.key,o))}for(const t of n){const o=e.resolveLineStyle(t.key,t.data[0]),n=E(t.data,e.scales,e.getX,e.getY,o,t.key);r&&r.length>0&&(n.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(n.curve=e.config.curve),e.config.lineGradient&&(n.strokeGradient=e.config.lineGradient),i.push(n)}return Ee(e,n,i),i}(d,t);case"area":return function(e,t){const o=e.groupData(t),n=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Re(e.ribbons);if(r.length>0&&n.push(...Be(e,t,r)),i.length>0)for(const t of o)n.push(...Ne(e,t.data,t.key,i))}const i=e.scales.y.domain()[0],r=e.getY0?t=>{const o=e.getY0(t);return null==o?i:o}:void 0;for(const t of o){const o=e.resolveAreaStyle(t.key,t.data[0]),s=I(t.data,e.scales,e.getX,e.getY,i,o,t.key,r),a=He(e.config.gradientFill);a&&(s.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(s.curve=e.config.curve),e.config.lineGradient&&(s.strokeGradient=e.config.lineGradient),n.push(s)}return Ee(e,o,n),n}(d,t);case"mixed":return function(e,t){const o=e.groupData(t),n=[],i=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Re(e.ribbons);if(r.length>0&&n.push(...Be(e,t,r)),i.length>0)for(const t of o)n.push(...Ne(e,t.data,t.key,i))}const r=e.scales.y.domain()[0],s=e.getY0?t=>{const o=e.getY0(t);return null==o?r:o}:void 0;for(const t of o)if(i.has(t.key)){const o=e.resolveAreaStyle(t.key,t.data[0]),i=I(t.data,e.scales,e.getX,e.getY,r,o,t.key,s),a=He(e.config.gradientFill);a&&(i.fillGradient=a),e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}else{const o=e.resolveLineStyle(t.key,t.data[0]),i=E(t.data,e.scales,e.getX,e.getY,o,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),n.push(i)}return Ee(e,o,n),n}(d,t);case"stackedarea":return function(e,t){var o,n,i,r;const s=e.groupData(t),a=null!==(o=e.config.stackOrder)&&void 0!==o?o:"key",l=()=>s.sort((e,t)=>t.key>e.key?-1:e.key>t.key?1:0);if("key"===a)l();else if("asc"===a||"desc"===a||"insideOut"===a){const t=new Map;for(const o of s){let n=0;for(const t of o.data){const o=e.getX(t),i=e.getY(t);Number.isFinite(o)&&Number.isFinite(i)&&(n+=i)}t.set(o.key,n)}const o=(e,t)=>t>e?-1:e>t?1:0;if("asc"===a)s.sort((e,n)=>{var i,r;const s=(null!==(i=t.get(e.key))&&void 0!==i?i:0)-(null!==(r=t.get(n.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)});else if("desc"===a)s.sort((e,n)=>{var i,r;const s=(null!==(i=t.get(n.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)});else{const e=[...s].sort((e,n)=>{var i,r;const s=(null!==(i=t.get(n.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:o(e.key,n.key)}),r=[],a=[];let l=0,c=0;for(const o of e)c>l?(r.push(o),l+=null!==(n=t.get(o.key))&&void 0!==n?n:0):(a.push(o),c+=null!==(i=t.get(o.key))&&void 0!==i?i:0);s.length=0,s.push(...a.reverse(),...r)}}else l();const c=e.config.curve&&"linear"!==e.config.curve?e.config.curve:void 0,u=e.config.normalize?"zero":null!==(r=e.config.baseline)&&void 0!==r?r:"zero",{nodes:d,stackedTops:h}=function(e,t,o,n,i,r,s,a="zero"){var l,c;const u=new Set;for(const t of e)for(const e of t.data){const t=o(e);Number.isFinite(t)&&u.add(t)}const d=Array.from(u).sort((e,t)=>e-t),h=new Map;for(const t of e){const e=new Map;for(const i of t.data){const t=o(i),r=n(i);Number.isFinite(t)&&Number.isFinite(r)&&e.set(t,(e.get(t)||0)+r)}h.set(t.key,e)}let g;if(r){g=new Map;for(const t of d){let o=0;for(const n of e)o+=(null===(l=h.get(n.key))||void 0===l?void 0:l.get(t))||0;g.set(t,o||1)}}const f=H(d,e.map(e=>e.key),(e,t)=>{var o;return(null===(o=h.get(e))||void 0===o?void 0:o.get(t))||0},a),p=[],y=new Map,m=new Map;for(const e of d)m.set(e,null!==(c=f.get(e))&&void 0!==c?c:0);for(const o of e){const e=h.get(o.key),n=[],a=[],l=new Map;for(const o of d){let i=e.get(o)||0;const s=m.get(o);r&&(i/=g.get(o));const c=s+i,u=t.x(o);a.push([u,t.y(s)]),n.push([u,t.y(c)]),m.set(o,c),l.set(o,c)}y.set(o.key,l);const c={type:"area",topPath:n,bottomPath:a,style:i(o.key,o.data[0]),datum:o.data,group:o.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(s,e.scales,e.getX,e.getY,(t,o)=>e.resolveAreaStyle(t,o),e.config.normalize,c,u),g=d;if(e.config.pointStyle){const t=new WeakMap;for(const o of s){const n=h.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=o=>{var n;return null!==(n=t.get(o))&&void 0!==n?n:e.getY(o)};Ee(e,s,g,o)}return g}(d,t);case"scatter":case"bubble":return function(e,t){var o;const n=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=null;if(e.getSize&&!e.config.pointStyle){const o=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(o.length>0){let e=1/0,t=-1/0;for(const n of o)e>n&&(e=n),n>t&&(t=n);s=o=>e===t?(r[0]+r[1])/2:r[0]+(o-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7";for(const o of t){let t=e.config.pointStyle?e.config.pointStyle(o):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(o);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const n=e.getColor(o);n&&a.has(n)&&(t=Object.assign(Object.assign({},t),{fill:a.get(n)}))}const c=e.getPointId?e.getPointId(o)+"":void 0,u=F(o,e.scales,e.getX,e.getY,r,t,c);u&&n.push(u)}return n}(d,t);case"heatmap":return function(e,t,o){if(e.config.heatmapAggregation)return function(e,t,o){var n,i,r;const s=Math.max(1,Math.floor(null!==(n=e.config.heatmapXBins)&&void 0!==n?n: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=G(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 o=0;t.length>o;o++){const n=t[o],i=e.getX(n),r=e.getY(n);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/f),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const g=d*s+l;m[g]++;const y=c(n);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=o.width/s,A=o.height/a,j=e.config.showValues,S=e.config.heatmapValueFormat,C=[];for(let e=0;a>e;e++){const t=e*s;for(let o=0;s>o;o++){const n=t+o;if(0===m[n])continue;let i;switch(l){case"sum":i=v[n];break;case"mean":i=v[n]/m[n];break;default:i=m[n]}const r=(i-b)/k;C.push(W(o*w,(a-1-e)*A,w,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:o,yi:e,value:i,count:m[n],sum:v[n],xCenter:u+(o+.5)*f,yCenter:h+(e+.5)*p,agg:l},j?{value:i,showValues:!0,valueFormat:S}:void 0))}}return C}(e,t,o);if(0===t.length)return[];const n=G(e.config.valueAccessor,"value"),i=Y(e.config.xAccessor,"x"),r=Y(e.config.yAccessor,"y"),s=new Map,a=new Map,l=Array(t.length),c=Array(t.length);for(let e=0;t.length>e;e++){const o=t[e],n=i(o),u=r(o);l[e]=n,c[e]=u,s.has(n)||s.set(n,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),g=Array.from(a.keys()),f=h.every(e=>"number"==typeof e&&!isNaN(e)),p=g.every(e=>"number"==typeof e&&!isNaN(e));if(f){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(p){g.sort((e,t)=>e-t),a.clear();for(let e=0;g.length>e;e++)a.set(g[e],e)}const y=new Float64Array(t.length),m=new Float64Array(t.length),v=Array(t.length),b=new Map;let x=0;for(let e=0;t.length>e;e++){const o=t[e],i=s.get(l[e]),r=a.get(c[e]);if(void 0===i||void 0===r)continue;const d=n(o),h=r*u+i,g=b.get(h);let f;void 0!==g?f=g:(f=x++,b.set(h,f)),y[f]=h,m[f]=d,v[f]=o}let k=1/0,w=-1/0;for(let e=0;x>e;e++){const t=m[e];isFinite(t)&&(k>t&&(k=t),t>w&&(w=t))}if(!isFinite(k)||!isFinite(w))return[];const A=function(e){const t=e in Fe?e:"blues";let o=$e.get(t);if(o)return o;o=Array(256);const n=Fe[t]||Q;for(let e=0;256>e;e++)o[e]=n(e/255);return $e.set(t,o),o}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),j=255/(w-k||1),S=o.width/u,C=o.height/d,O=e.config.showValues,M=e.config.heatmapValueFormat,P=[];for(let e=0;x>e;e++){const t=m[e];if(!isFinite(t))continue;const o=y[e],n=o%u;P.push(W(n*S,(d-1-(o-n)/u)*C,S,C,A[Math.min((t-k)*j+.5|0,255)],v[e],O?{value:t,showValues:!0,valueFormat:M}:void 0))}return P}(d,t,e);case"bar":{const e=function(e,t){var o,n;if(!e.config.binSize)return{nodes:[],binBoundaries:[]};const i=D(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 o of e.categories.keys())t.add(o);const o=e.config.barColors?Object.keys(e.config.barColors):[],n=new Set(o),s=Array.from(t).filter(e=>!n.has(e)).sort(),a=o.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===(o=e.config.themeSemantic)||void 0===o?void 0:o.primary,h=null==u?void 0:u.gap,g="number"!=typeof h||0>h?1:h,f={};(null==u?void 0:u.stroke)&&(f.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(f.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(f.opacity=u.opacity);for(const t of i.values()){const o=Math.max(t.start,l),i=Math.min(t.end,c);if(o>=i)continue;const h=a.x(o),p=a.x(i),y=Math.abs(p-h),m=y>g+1?g:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&t.categories.size>0){let o=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(o),c=a.y(o+r),h=(null===(n=e.config.barColors)||void 0===n?void 0:n[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push($(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},f),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),o+=r}}else{const e=a.y(0),o=a.y(t.total);s.push($(v,Math.min(e,o),b,Math.abs(e-o),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},f),{binStart:t.start,binEnd:t.end,total:t.total}))}}const p=new Set;for(const e of i.values())p.add(e.start),p.add(e.end);return{nodes:s,binBoundaries:Array.from(p).sort((e,t)=>e-t)}}(d,t);return this._barCategoryCache=null!==(l=d.barCategoryCache)&&void 0!==l?l:null,this._binBoundaries=e.binBoundaries,e.nodes}case"swarm":return function(e,t){var o,n,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(o=c.radius)&&void 0!==o?o:3,d=null!==(r=null!==(n=c.fill)&&void 0!==n?n: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,f=c.strokeWidth;for(const o of t){const t=e.getX(o),n=e.getY(o);if(null==n||Number.isNaN(n))continue;const i=e.scales.x(t),r=e.scales.y(n);let s=d;if(e.getCategory){const t=e.getCategory(o);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:f},datum:o};e.getPointId&&(c.pointId=e.getPointId(o)+""),l.push(c)}return l}(d,t);case"waterfall":return function(e,t,o){var n,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,g=t.filter(t=>{const o=e.getY(t),n=e.getX(t);return null!=o&&!Number.isNaN(o)&&null!=n&&isFinite(n)});if(0===g.length)return u;const f=null!==(r=null!==(n=null==h?void 0:h.positiveColor)&&void 0!==n?n:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",p=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 n=g[t],i=e.getX(n),r=e.getY(n),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+o.width/10,k=Math.min(l,c)+y/2,w=Math.max(l,c)-y/2-k;if(0>=w){x=s;continue}const A=d.y(x),j=d.y(s),S=Math.min(A,j),C=Math.abs(A-j),O={fill:0>r?p:f,stroke:m,strokeWidth:v};null!=b&&(O.opacity=b),u.push($(k,S,w,C,O,Object.assign(Object.assign({},n),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,t,e);case"candlestick":return function(e,t){var o,n;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(o=e.config.candlestickRangeMode)&&void 0!==o&&o;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!==(n=s.bodyWidth)&&void 0!==n?n:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let o=1;h.length>o;o++){const n=Math.abs(e.scales.x(h[o])-e.scales.x(h[o-1]));n>0&&t>n&&(t=n)}g=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else g=6;for(const o of t){const t=e.getX(o);if(null==t||Number.isNaN(t))continue;const n=e.getHigh(o),s=e.getLow(o);if(null==n||Number.isNaN(n)||null==s||Number.isNaN(s))continue;const a=i?n:e.getOpen(o),h=i?s:e.getClose(o);if(!i&&[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(n),lowY:e.scales.y(s),bodyWidth:g,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:f,datum:o};i&&(p.isRange=!0),r.push(p)}return r}(d,t);default:return[]}}resolveBoundsStyle(e,t){var o;const n=this.config.boundsStyle;return"function"==typeof n?n(t||{},e):n&&"object"==typeof n?n:{fill:this.resolveLineStyle(e,t).stroke||(null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?je(o,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,o){var n,i;const r=o.length;if(1>=r)return;const s=new Map;for(let e=0;o.length>e;e++)s.set(o[e],e);for(const o of t){if("line"===o.type){const t=Array.isArray(o.datum)?o.datum:[];if(2>t.length)continue;const n=Array(t.length);let i=!1;for(let o=0;t.length>o;o++){const a=s.get(t[o]);null!=a?(n[o]=je(e,a,r),1>n[o]&&(i=!0)):n[o]=1}i&&(o._decayOpacities=n);continue}if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[],n=o.topPath?o.topPath.length:t.length;if(2>n)continue;if(t.length===n){const i=Array(n);let a=!1;for(let o=0;t.length>o;o++){const n=s.get(t[o]);null!=n?(i[o]=je(e,n,r),1>i[o]&&(a=!0)):i[o]=1}a&&(o._decayOpacities=i)}else{let i=1;for(const o of t){const t=s.get(o);if(null!=t){const o=je(e,t,r);i>o&&(i=o)}}if(1>i){const e=Array(n);e.fill(i),o._decayOpacities=e}}continue}const t=s.get(o.datum);if(null==t)continue;const a=je(e,t,r);if("heatcell"===o.type)o.style={opacity:a};else if("candlestick"===o.type)o._decayOpacity=a;else{const e=null!==(i=null===(n=o.style)||void 0===n?void 0:n.opacity)&&void 0!==i?i:1;o.style=Object.assign(Object.assign({},o.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,o,n){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;o.length>e;e++)c.set(o[e],e);for(const o of t){if("line"===o.type)continue;if("area"===o.type){const t=Array.isArray(o.datum)?o.datum:[o.datum];let i=0;for(const o of t){const t=c.get(o);if(null==t)continue;const r=n.get(t);if(null==r)continue;const a=Se(e,r,s);a>i&&(i=a)}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const t=c.get(o.datum);if(null==t)continue;const i=n.get(t);if(null==i)continue;const r=Se(e,i,s);r>0&&(o._pulseIntensity=r,o._pulseColor=a,o._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var o;if(!t||0===t.size)return!1;const n="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(o=e.duration)&&void 0!==o?o:500,r=t.peek();return null!=r&&i>n-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,o,n){var i,r,s,a;o.clear(),n.clear();for(let l=0;t.length>l;l++){const c=t[l],u=_e(e,c,l);u&&("point"===c.type?o.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?o.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?o.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?o.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?n.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&&n.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,o;this.prevPositionMap.clear(),this.prevPathMap.clear();const n=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=_e(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:n,w:t.w,h:0,opacity:null!==(o=t.style.opacity)&&void 0!==o?o: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,o,n,i){var r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,j,S,C,O,M,P,_,L,T,R,B,N,D,E,I,H,F,$,W,z,G,Y;if(0===n.size&&0===i.size)return o;const q=null!==(r=t.duration)&&void 0!==r?r:300;if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}let X=!1;const V=new Set,U=new Set;for(let t=0;o.scene.length>t;t++){const r=o.scene[t],_=_e(e,r,t);if(!_)continue;if(r._transitionKey=_,"line"===r.type||"area"===r.type){const e=i.get(_);if(e){if(U.add(_),"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]];X=!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]];X=!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}),X=!0;continue}const L=n.get(_);if("point"===r.type)if(L){V.add(_);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,X=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("rect"===r.type)if(L){V.add(_);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!==(f=L.w)&&void 0!==f?f:r.w,r.h=null!==(p=L.h)&&void 0!==p?p:r.h,X=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),X=!0;else if("heatcell"===r.type)if(L){V.add(_);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,X=!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}),X=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){V.add(_);const e={x:r.x,openY:r.openY,closeY:r.closeY,highY:r.highY,lowY:r.lowY};r._targetOpacity=null!==(j=null===(A=r.style)||void 0===A?void 0:A.opacity)&&void 0!==j?j: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!==(S=L.closeY)&&void 0!==S?S:r.closeY,r.highY=null!==(C=L.highY)&&void 0!==C?C:r.highY,r.lowY=null!==(O=L.lowY)&&void 0!==O?O:r.lowY,X=!0)}else r._targetOpacity=null!==(P=null===(M=r.style)||void 0===M?void 0:M.opacity)&&void 0!==P?P:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),X=!0}for(const[e,t]of i)if(!U.has(e))if(e.startsWith("l:")&&t.path){const n={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(_=t.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:e,datum:null};o.exitNodes.push(n),X=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const n={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};o.exitNodes.push(n),X=!0}for(const[e,t]of n)if(!V.has(e)){if(e.startsWith("p:")){const n={type:"point",x:t.x,y:t.y,r:null!==(T=t.r)&&void 0!==T?T:3,style:{opacity:null!==(R=t.opacity)&&void 0!==R?R:1},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("r:")){const n={type:"rect",x:t.x,y:t.y,w:null!==(B=t.w)&&void 0!==B?B:0,h:null!==(N=t.h)&&void 0!==N?N:0,style:{opacity:null!==(D=t.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("h:")){const n={type:"heatcell",x:t.x,y:t.y,w:null!==(E=t.w)&&void 0!==E?E:0,h:null!==(I=t.h)&&void 0!==I?I:0,fill:"#999",datum:null,style:{opacity:null!==(H=t.opacity)&&void 0!==H?H:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(n)}else if(e.startsWith("c:")){const n=null!==(F=t.openY)&&void 0!==F?F:t.y,i={type:"candlestick",x:t.x,openY:n,closeY:null!==($=t.closeY)&&void 0!==$?$:n,highY:null!==(W=t.highY)&&void 0!==W?W:n,lowY:null!==(z=t.lowY)&&void 0!==z?z:n,bodyWidth:null!==(G=t.w)&&void 0!==G?G:6,upColor:"#999",downColor:"#999",wickColor:"#999",wickWidth:1,isUp:!0,datum:null,style:{opacity:null!==(Y=t.opacity)&&void 0!==Y?Y:1},_targetOpacity:0,_transitionKey:e};o.exitNodes.push(i)}X=!0}return o.exitNodes.length>0&&(o.scene=[...o.scene,...o.exitNodes]),X&&(o.activeTransition={startTime:Pe(),duration:q}),o}(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},o=function(e,t,o,n){var i,r,s,a,l,c;if(!o.activeTransition)return!1;const u=Oe(e,o.activeTransition),d=Ce(u,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of o.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,r=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style.opacity=Me(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Me(o.x,e._targetX,d),e.y=Me(o.y,e._targetY,d),void 0!==e._targetR&&void 0!==o.r&&(e.r=Me(o.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(r=o.opacity)&&void 0!==r?r:1:0;e.style.opacity=Me(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Me(o.x,e._targetX,d),e.y=Me(o.y,e._targetY,d),void 0!==o.w&&(e.w=Me(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Me(o.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(s=o.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Me(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Me(o.x,e._targetX,d),e.y=Me(o.y,e._targetY,d),void 0!==o.w&&(e.w=Me(o.w,e._targetW,d)),void 0!==o.h&&(e.h=Me(o.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const o=t?n.get(t):void 0,i=o?null!==(a=o.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Me(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const o=n.get(t);if(!o)continue;e.x=Me(o.x,e._targetX,d),void 0!==o.openY&&(e.openY=Me(o.openY,e._targetOpenY,d)),void 0!==o.closeY&&(e.closeY=Me(o.closeY,e._targetCloseY,d)),void 0!==o.highY&&(e.highY=Me(o.highY,e._targetHighY,d)),void 0!==o.lowY&&(e.lowY=Me(o.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:Me(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,o=e._targetPath;if(t&&o&&t.length===e.path.length)for(let n=0;e.path.length>n;n++)e.path[n][0]=Me(t[n][0],o[n][0],d),e.path[n][1]=Me(t[n][1],o[n][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:Me(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,o=e._prevBottomPath,n=e._targetTopPath,i=e._targetBottomPath;if(t&&n&&t.length===e.topPath.length)for(let o=0;e.topPath.length>o;o++)e.topPath[o][0]=Me(t[o][0],n[o][0],d),e.topPath[o][1]=Me(t[o][1],n[o][1],d);if(o&&i&&o.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Me(o[t][0],i[t][0],d),e.bottomPath[t][1]=Me(o[t][1],i[t][1],d)}}if(u>=1){for(const e of o.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 o=0;e.path.length>o;o++)e.path[o]=t[o];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,o=e._targetBottomPath;if(t)for(let o=0;e.topPath.length>o;o++)e.topPath[o]=t[o];if(o)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=o[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(o.exitNodes.length>0){const e=new Set(o.exitNodes);o.scene=o.scene.filter(t=>!e.has(t)),o.exitNodes=[]}return o.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,o}cancelIntroAnimation(){this.prevPositionMap.clear(),this.prevPathMap.clear(),this.activeTransition=null;for(const e of this.scene)"line"!==e.type&&"area"!==e.type||(e._introClipFraction=void 0)}groupData(e){if(!this.getGroup)return[{key:"_default",data:e}];const t=new Map;for(const o of e){const e=this.getGroup(o);t.has(e)||t.set(e,[]),t.get(e).push(o)}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 o of e){const e=this.getColor(o);e&&t.add(e)}const o=Array.from(t).sort(),n=o.join("\0");if(this._colorMapCache&&this._colorMapCache.key===n)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,r=new Map;for(let e=0;o.length>e;e++)r.set(o[e],i[e%i.length]);return this._colorMapCache={key:n,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var o;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}const i=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;return n&&"object"==typeof n?{stroke:n.stroke||i||"#007bff",strokeWidth:n.strokeWidth||2,strokeDasharray:n.strokeDasharray,fill:n.fill,fillOpacity:n.fillOpacity,opacity:n.opacity}:{stroke:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var o,n;if(this.config.areaStyle){const o=this.config.areaStyle(t||{});if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const i=this.config.lineStyle;if("function"==typeof i){const o=i(t||{},e);if(o&&!o.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},o),{fill:t,stroke:o.stroke||t})}return o}const r=null===(o=this.config.themeSemantic)||void 0===o?void 0:o.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(n=i.fillOpacity)&&void 0!==n?n:.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 o=(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)||ve;if(0===o.length)return null;const n=o[this._groupColorCounter%o.length];if(this._groupColorCounter++,this._groupColorMap.set(e,n),this._groupColorMap.size>Ge.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return n}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);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 o=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(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._lastBoundedInsertsRef=null,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,o,n,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||"boundsAccessor"in e||"band"in e||"y0Accessor"in e||"openAccessor"in e||"highAccessor"in e||"lowAccessor"in e||"closeAccessor"in e||"groupAccessor"in e||"categoryAccessor"in e||"chartType"in e||"runtimeMode"in e)&&(this._stackExtentCache=null);let s=!1,a=!1;Object.assign(this.config,e);const l="chartType"in e&&e.chartType!==r.chartType||"runtimeMode"in e&&e.runtimeMode!==r.runtimeMode;if(l||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e){const c=l||!z(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(o=r.xAccessor)&&void 0!==o?o:r.timeAccessor),u=l||!z(null!==(n=e.yAccessor)&&void 0!==n?n:e.valueAccessor,null!==(i=r.yAccessor)&&void 0!==i?i:r.valueAccessor);(c||u)&&(["bar","swarm","waterfall"].includes(this.config.chartType)||"streaming"===this.config.runtimeMode?(this.getX=G(this.config.timeAccessor||this.config.xAccessor,"time"),this.getY=G(this.config.valueAccessor||this.config.yAccessor,"value")):(this.getX=G(this.config.xAccessor,"x"),this.getY=G(this.config.yAccessor,"y")),u&&this.resolvedRibbons.some(e=>"bounds"===e.kind)&&(this.resolvedRibbons=ze(this.config)),s=!0,a=!0)}if("groupAccessor"in e&&!z(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?q(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!z(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?q(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!z(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?G(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!z(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!z(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?G(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in e&&!z(e.boundsAccessor,r.boundsAccessor)||"band"in e&&e.band!==r.band||"boundsStyle"in e&&e.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=ze(this.config),s=!0,a=!0),"pointIdAccessor"in e&&!z(e.pointIdAccessor,r.pointIdAccessor)&&(this.getPointId=null!=this.config.pointIdAccessor?q(this.config.pointIdAccessor):void 0,s=!0),"candlestick"===this.config.chartType&&(l||"openAccessor"in e&&!z(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!z(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!z(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!z(e.lowAccessor,r.lowAccessor))){const e=null!=this.config.openAccessor,t=null!=this.config.closeAccessor;this.getOpen=e?G(this.config.openAccessor,"open"):void 0,this.getHigh=G(this.config.highAccessor,"high"),this.getLow=G(this.config.lowAccessor,"low"),this.getClose=t?G(this.config.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!e&&!t,s=!0,a=!0}if(!s){const t=Object.keys(e).filter(e=>!e.endsWith("Accessor")&&"timeAccessor"!==e&&"valueAccessor"!==e);for(const o of t)if(e[o]!==r[o]){s=!0;break}}s&&(a&&this.rebuildExtents(),this.needsFullRebuild=!0)}}function Ye(...e){const t=e.filter(e=>null!=e);return 0===t.length?null:1===t.length?t[0]:p.createElement(p.Fragment,null,...t)}function qe(e,t,o){return o.x>e||e>o.x+o.w||o.y>t||t>o.y+o.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:o.x+o.w/2,cy:o.y+o.h/2}}function Xe(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function Ve(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ue(e,t){const o=Ve(e);if(!o)return!1;const n=Ve(t);return!n||o.getFullYear()!==n.getFullYear()||o.getMonth()!==n.getMonth()}function Ke(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Qe(e,t,o,n,i){const r=Math.max(n,i+5,12),s=t-r,a=t+r,l=o-r,c=o+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-o,a=Math.sqrt(r*r+s*s);Xe(e.r,n)>=a&&d>a&&(u=e,d=a),i=i.next}while(i)}return!1}),u?{node:u,distance:d}:null}Ge.GROUP_COLOR_MAP_CAP=1e3,Ge.QUADTREE_THRESHOLD=500;const Ze=/^var\(\s*(--[^,)]+)(?:\s*,\s*([^)]+))?\s*\)$/,Je=new WeakMap;let et=0,tt=!1,ot=null,nt=null,it=null;function rt(e,t){var o,n;if(!t)return t;const i=Ze.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(o=i[2])||void 0===o?void 0:o.trim())||t;!function(){if(tt)return;if("undefined"==typeof window||"undefined"==typeof document)return;tt=!0;const e=()=>{et++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(ot=new MutationObserver(e),ot.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{nt=window.matchMedia("(prefers-color-scheme: dark)"),it=e,"function"==typeof nt.addEventListener?nt.addEventListener("change",it):"function"==typeof nt.addListener&&nt.addListener(it)}catch(e){}}();let s=Je.get(r);s&&s.version===et||(s={version:et,map:new Map},Je.set(r,s));const a=s.map.get(t);if(void 0!==a)return a;const l=getComputedStyle(r).getPropertyValue(i[1]).trim()||(null===(n=i[2])||void 0===n?void 0:n.trim())||t;return s.map.set(t,l),l}function st(e,t){const o=e.fillStyle,n="#010203";try{e.fillStyle=n,e.fillStyle=t}catch(t){return e.fillStyle=o,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=o,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===n&&t.trim().toLowerCase()!==n)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 at(e){switch(e){case"monotoneX":return s.curveMonotoneX;case"monotoneY":return s.curveMonotoneY;case"cardinal":return s.curveCardinal;case"catmullRom":return s.curveCatmullRom;case"step":return s.curveStep;case"stepBefore":return s.curveStepBefore;case"stepAfter":return s.curveStepAfter;case"basis":return s.curveBasis;case"natural":return s.curveNatural;default:return null}}function lt(e,t,o){return null==t?o:"string"!=typeof t?t:rt(e,t)||o}function ct(e,t,o,n,i,r,s){if("colorStops"in t){const o=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>o.length)return null;const a=e.createLinearGradient(n,i,r,s);for(const e of o)a.addColorStop(e.offset,e.color);return a}const{topOpacity:a,bottomOpacity:l}=t;if(!Number.isFinite(a)||!Number.isFinite(l))return null;const c=Math.max(0,Math.min(1,a)),u=Math.max(0,Math.min(1,l)),d=e.createLinearGradient(n,i,r,s),[h,g,f]=st(e,o);return d.addColorStop(0,`rgba(${h},${g},${f},${c})`),d.addColorStop(1,`rgba(${h},${g},${f},${u})`),d}function ut(e,t,o,n,i,r){const s=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>s.length)return null;const a=e.createLinearGradient(o,n,i,r);for(const e of s)a.addColorStop(e.offset,e.color);return a}const dt=new WeakMap;function ht(e,t){const o=at(t);if(!o)return e;const n=dt.get(e);if(n)return n;const i=function(e,t,o=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const n=[];let i=null;const r={moveTo(e,t){i=[e,t],n.push([e,t])},lineTo(e,t){i=[e,t],n.push([e,t])},bezierCurveTo(e,t,r,s,a,l){if(!i)return i=[a,l],void n.push([a,l]);const[c,u]=i;for(let i=1;o>=i;i++){const d=i/o,h=1-d;n.push([h*h*h*c+3*h*h*d*e+3*h*d*d*r+d*d*d*a,h*h*h*u+3*h*h*d*t+3*h*d*d*s+d*d*d*l])}i=[a,l]},closePath(){},arc(){},rect(){},arcTo(){},quadraticCurveTo(e,t,o,r){i=[o,r],n.push([o,r])}};return s.line().x(e=>e[0]).y(e=>e[1]).curve(t).context(r)(e),n}(e,o);return dt.set(e,i),i}function gt(e,t,o,n=30,i,r=0){let s=null;if(i){const e=Qe(i,t,o,n,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=pt(r,t,o,n);break;case"line":e=yt(r,t,o,n);break;case"rect":if(null==r.datum)break;e=vt(r,t,o);break;case"heatcell":e=bt(r,t,o);break;case"area":if(!1===r.interactive)break;e=kt(r,t,o);break;case"candlestick":e=xt(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function ft(e,t,o){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const n=wt(e,t);if(0>n)return null;if(Math.abs(e[n][0]-t)>o)return null;let i=n,r=n;n>0&&e[n][0]>=t?(i=n-1,r=n):e.length-1>n&&(i=n,r=n+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 pt(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function yt(e,t,o,n=30){var i,r;if(0===e.path.length)return null;const s=wt(e.path,t);if(0>s)return null;const[a,l]=e.path[s];let c;if(e.path.length>1){let n=1/0;const i=Math.max(0,s-1),r=Math.min(e.path.length-2,s);for(let s=i;r>=s;s++){const[i,r]=e.path[s],[a,l]=e.path[s+1],c=mt(t,o,i,r,a,l);n>c&&(n=c)}c=n}else{const e=t-a,n=o-l;c=Math.sqrt(e*e+n*n)}const u=e.style,d=null!==(r=null!==(i=u.strokeWidth)&&void 0!==i?i:u.lineWidth)&&void 0!==r?r:1;return c>Math.max(5,d/2+2,n)?null:{node:e,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:a,y:l,distance:c}}function mt(e,t,o,n,i,r){const s=i-o,a=r-n,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-o,2)+Math.pow(t-n,2));let c=((e-o)*s+(t-n)*a)/l;c=Math.max(0,Math.min(1,c));const u=n+c*a;return Math.sqrt(Math.pow(e-(o+c*s),2)+Math.pow(t-u,2))}function vt(e,t,o){const n=qe(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function bt(e,t,o){const n=qe(t,o,e);return n.hit?{node:e,datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}function xt(e,t,o){const n=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-n-3>t||t>e.x+n+3||e.highY-3>o||o>e.lowY+3)){const n=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=o-n;return{node:e,datum:e.datum,x:e.x,y:n,distance:Math.sqrt(r*r+s*s)}}return null}function kt(e,t,o){if(0===e.topPath.length)return null;const n=wt(e.topPath,t);if(0>n)return null;const[i,r]=e.topPath[n],s=t-i,a=o-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[n]?e.datum[n]:e.datum,x:i,y:r,distance:l}}function wt(e,t){if(0===e.length)return-1;let o=0,n=e.length-1;for(;n>o;){const i=o+n>>1;t>e[i][0]?o=i+1:n=i}return o>0&&Math.abs(e[o][0]-t)>=Math.abs(e[o-1][0]-t)?o-1:o}function At(e){var t,o;const n=new Map;for(const o of e){const e=null!==(t=o.group)&&void 0!==t?t:"_default";let i=n.get(e);i||(i=[],n.set(e,i)),i.push(o)}for(const e of n.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(n.keys()).sort((e,t)=>{const o=n.get(e),i=n.get(t);return(o.length>0?o[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(n.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===(o=r[e].datum)||void 0===o?void 0:o.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:n,idToIdx:s}}function jt(e,t){var o,n;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!==(o=r.group)&&void 0!==o?o:"_default",indexInGroup:null!==(n=r._groupIndex)&&void 0!==n?n:0}}function St(e,t,o){const{group:n,indexInGroup:i}=t,r=o.byGroup.get(n);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=o.groups.indexOf(n);return o.groups.length-1>e?Ct(o,o.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=o.groups.indexOf(n);return e>0?Ct(o,o.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*o.flat.length)),o.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*o.flat.length)),0);case"Home":return 0;case"End":return o.flat.length-1;case"Escape":return-1;default:return null}}function Ct(e,t,o){const n=e.byGroup.get(t);let i=0,r=Math.abs(n[0].x-o.x);for(let e=1;n.length>e;e++){const t=Math.abs(n[e].x-o.x);r>t&&(r=t,i=e)}return n[i]._flatIndex}function Ot(e){return"object"==typeof e&&null!==e&&"id"in e?e.id:e}function Mt(e){return{data:e.datum||{},x:e.x,y:e.y,__semioticHoverData:!0}}function Pt(e,o,n,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=o.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),n.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}const _t={fill:(t,o)=>e.jsx("rect",{style:t,width:o,height:o}),line:(t,o)=>e.jsx("line",{style:t,x1:0,y1:0,x2:o,y2:o})};function Lt(e,t,o,n,i){let r;return r="function"==typeof o?o(e):(0,_t[o])(n(e,t),i),r}function Tt({swatchSize:t}){return e.jsx("path",{d:`M${.25*t},${.55*t} L${.45*t},${.75*t} L${.8*t},${.3*t}`,fill:"none",stroke:"white",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}function Rt(e,t,o){return o&&o.size>0?o.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Bt=(t,o,n,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:g,items:f}=t,p=[];let y=0;const m=!(!o&&!n),v="isolate"===u||void 0===u&&null!=r,{swatchSize:b,labelGap:x,rowHeight:k}=d;return f.forEach((t,u)=>{const d=Lt(t,u,h,g,b),w=Rt(t,i,r),A=r&&r.size>0&&r.has(t.label);p.push(e.jsxs("g",{transform:`translate(0,${y})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:m?l===s&&u===a?0:-1:void 0,role:m?"option":void 0,"aria-selected":m&&v?A||!1:void 0,"aria-current":m&&!v&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:m?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+f.length)%f.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:m?e=>{c(l,u),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:w,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[m&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:b+x+2+7*t.label.length,height:b+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),d,A&&e.jsx(Tt,{swatchSize:b}),e.jsx("text",{y:b/2,x:b+x,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+u)),y+=k}),p};function Nt({config:t,orientation:o="vertical",width:n=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+p.useId();if("horizontal"===o){const t=12,o=Math.min(n,200),a=Math.max(0,(n-o)/2),u=[];for(let t=0;64>=t;t++){const o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[0]+o*(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+o/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:o,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+o,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 o=t/64;u.push(e.jsx("stop",{offset:100*o+"%",stopColor:i(r[1]-o*(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 Dt(t){const{legendGroups:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical",legendLayout:h}=t,g=function(e){var t,o,n,i,r;const s=Math.max(1,null!==(t=null==e?void 0:e.swatchSize)&&void 0!==t?t:16),a=Math.max(s,null!==(o=null==e?void 0:e.rowHeight)&&void 0!==o?o:22);return{swatchSize:s,labelGap:Math.max(0,null!==(n=null==e?void 0:e.labelGap)&&void 0!==n?n:6),itemGap:Math.max(0,null!==(i=null==e?void 0:e.itemGap)&&void 0!==i?i:10),rowHeight:a,align:"left"===(null==e?void 0:e.align)?"start":"right"===(null==e?void 0:e.align)?"end":null!==(r=null==e?void 0:e.align)&&void 0!==r?r:"start",maxWidth:null==e?void 0:e.maxWidth}}(h),[f,y]=p.useState(0),[m,v]=p.useState(0),b=p.useCallback((e,t)=>{y(e),v(t)},[]),x="vertical"===d?(({legendGroups:t,width:o,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const g=[];return t.forEach((t,f)=>{h+=5,g.push(e.jsx("line",{stroke:"gray",x1:0,y1:h,x2:o,y2:h},"legend-top-line legend-symbol-"+f)),h+=8,t.label&&(h+=16,g.push(e.jsx("text",{y:h,className:"legend-group-label",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label},"legend-text-"+f)),h+=8),g.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:Bt(t,n,i,r,s,a,l,f,c,u,d)},"legend-group-"+f)),h+=t.items.length*d.rowHeight+8}),g})({legendGroups:o||[],width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:g}):(({legendGroups:t,height:o,width:n,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var g;let f=0;const p=[];t.forEach((t,o)=>{var g;let y=0;t.label&&(y+=16);const m=((t,o,n,i,r,s,a,l,c,u,d,h)=>{const{type:g="fill",styleFn:f,items:p}=t,y=[],{swatchSize:m,labelGap:v,itemGap:b,rowHeight:x,align:k}=d,w=!(!o&&!n),A="isolate"===u||void 0===u&&null!=r,j=p.map(e=>m+v+7*e.label.length),S=[];let C=0,O=0;j.forEach((e,t)=>{const o=0===O?e:O+b+e;h&&h>0&&O>0&&o>h?(S.push({start:C,end:t,width:O}),C=t,O=e):O=o}),p.length>0&&S.push({start:C,end:p.length,width:O}),S.forEach((t,u)=>{let d="center"===k?Math.max(0,((null!=h?h:t.width)-t.width)/2):"end"===k?Math.max(0,(null!=h?h:t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=p[h],k=Lt(t,h,g,f,m),S=Rt(t,i,r),C=r&&r.size>0&&r.has(t.label);y.push(e.jsxs("g",{transform:`translate(${d},${u*x})`,onClick:o?()=>o(t):void 0,onMouseEnter:n?()=>n(t):void 0,onMouseLeave:n?()=>n(null):void 0,tabIndex:w?l===s&&h===a?0:-1:void 0,role:w?"option":void 0,"aria-selected":w&&A?C||!1:void 0,"aria-current":w&&!A&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:w?e=>{var n;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),o&&o(t)),"ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();const t=(h+("ArrowRight"===e.key?1:-1)+p.length)%p.length;c(l,t);const o=null===(n=e.currentTarget.parentElement)||void 0===n?void 0:n.children[t];o instanceof SVGElement&&o.focus()}}:void 0,onFocus:w?e=>{c(l,h),n&&n(t);const o=e.currentTarget.querySelector(".semiotic-legend-focus-ring");o&&o.setAttribute("visibility","visible")}:void 0,onBlur:w?e=>{n&&n(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:w?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[w&&e.jsx("rect",{className:"semiotic-legend-focus-ring",x:-2,y:-2,width:m+v+2+7*t.label.length,height:m+4,fill:"none",stroke:"var(--semiotic-focus, #005fcc)",strokeWidth:2,rx:3,visibility:"hidden"}),k,C&&e.jsx(Tt,{swatchSize:m}),e.jsx("text",{y:m/2,x:m+v,dominantBaseline:"central",style:{fontSize:"var(--semiotic-legend-font-size, 12px)"},fill:"var(--semiotic-text, #333)",children:t.label})]},"legend-item-"+h)),d+=j[h]+b}});const M=Math.max(0,...S.map(e=>e.width)),P=S.length;return{items:y,offset:M,totalRows:P,totalHeight:P*x}})(t,i,r,s,a,l,c,o,u,d,h,null!==(g=h.maxWidth)&&void 0!==g?g:n);y+=m.offset+5,p.push(Object.assign(Object.assign({label:t.label},m),{offset:y,totalRows:m.totalRows,totalHeight:m.totalHeight})),f+=y+12});const y=null!==(g=h.maxWidth)&&void 0!==g?g:n;let m=f>y?0:"center"===h.align?Math.max(0,(y-f)/2):"end"===h.align?Math.max(0,y-f):0;const v=[];return p.forEach((n,i)=>{const r=t[i];r.label&&(v.push(e.jsx("text",{transform:`translate(${m},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)),m+=16),v.push(e.jsx("g",{className:"legend-item",transform:`translate(${m},0)`,children:n.items},"legend-group-"+i)),m+=n.offset+5,t[i+1]&&v.push(e.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(n.totalHeight||o)+0+8},"legend-top-line legend-symbol-"+i)),m+=12}),e.jsx("g",{children:v})})({legendGroups:o||[],title:l,height:u,width:c,customClickBehavior:n,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:f,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:g}),k=!(!n&&!i);return e.jsxs("g",{role:k?"listbox":void 0,"aria-multiselectable":!(!k||"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}),x]})}function Et(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function It(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Ht(t){var o;const{legend:n,totalWidth:i,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g,legendInteraction:f}=t;if(!n)return null;const p="top"===a||"bottom"===a,y=!!c,m=Math.max(1,p?null!==(o=null==l?void 0:l.maxWidth)&&void 0!==o?o:Math.max(0,i-s.left-s.right):100);let v,b;return"left"===a?(v=Math.max(4,s.left-m-10),b=s.top):"top"===a?(v=s.left,b=y?32:8):"bottom"===a?(v=s.left,b=r-s.bottom+38):(v=i-s.right+10,b=s.top),e.jsx("g",{transform:`translate(${v}, ${b})`,children:It(n)?e.jsx(Nt,{config:n.gradient,orientation:p?"horizontal":"vertical",width:m}):Et(n)?e.jsx(Dt,{legendGroups:n.legendGroups,title:"",width:m,orientation:p?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:g,legendInteraction:f}):n})}function Ft(e){return"string"==typeof e?{type:e}:e}function $t({orient:o,config:n,values:i,scale:r,size:s,length:l}){const c=function(e){var t,o,n,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(o=e.fill)&&void 0!==o?o:"#4e79a7",fillOpacity:null!==(n=e.fillOpacity)&&void 0!==n?n:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(n),u="top"===o||"bottom"===o,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),n=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),o=t.length;if(0===o)return null;const n=t[Math.floor(.25*o)],i=t[Math.floor(.5*o)],r=t[Math.floor(.75*o)],s=r-n;return{q1:n,median:i,q3:r,whiskerLow:Math.max(t[0],n-1.5*s),whiskerHigh:Math.min(t[o-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*n,20),f=(n-g)/2+4;if(u){const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="top"===o?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:u,y1:m+y*(f+g/2),x2:p,y2:m+y*(f+g/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*f,x2:u,y2:m+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:p,y1:m+y*f,x2:p,y2:m+y*(f+g),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,n),y:"top"===o?m-f-g:m+f,width:Math.abs(n-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"===o?m-f-g:m+f,x2:i,y2:"top"===o?m-f:m+f+g,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),n=r(l),i=r(a),u=r(d),p=r(h),y="left"===o?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+o,children:[e.jsx("line",{x1:m+y*(f+g/2),y1:u,x2:m+y*(f+g/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:u,x2:m+y*(f+g),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*f,y1:p,x2:m+y*(f+g),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===o?m-f-g:m+f,y:Math.min(t,n),width:g,height:Math.abs(n-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===o?m-f-g:m+f,y1:i,x2:"left"===o?m-f:m+f+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-"+o,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*n;if(u){const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:n,y:"top"===o?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const n=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===o?-4-s:4,y:Math.min(n,n+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=n/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(n/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===o?-(t-s):t-s}`:`${"left"===o?-(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*(n/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===o?-(t+a):t+a}`:`${"left"===o?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+o,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*n,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===o?-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*n,s=r((e.x0+e.x1)/2);t.push(`L${"left"===o?-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-"+o,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,o,u,4]);return d?e.jsx("g",{className:"marginal-"+o,"data-testid":"marginal-"+o,children:d}):null}function Wt(e,t=120,o=8){if(!e)return[];const n=Math.max(1,Math.floor(t/o)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>n?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function zt(e,t,o,n){return"curly"===e?n?`M0,0 C${.6*o},0 ${.4*o},${t/2} ${o},${t/2} C${.4*o},${t/2} ${.6*o},${t} 0,${t}`:`M0,0 C0,${.6*o} ${t/2},${.4*o} ${t/2},${o} C${t/2},${.4*o} ${t},${.6*o} ${t},0`:n?`M0,0 L${o},0 L${o},${t} L0,${t}`:`M0,0 L0,${o} L${t},${o} L${t},0`}function Gt(t,o,n,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(o)>Math.abs(n)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>o?"right":"left":0>n?"bottom":"top");let g="start";"topBottom"===d?"right"===h?g="end":"middle"===h&&(g="middle"):g=0>o?"end":"start";const f=16,p=s?u?[s]:Wt(s,c):[],y=r?u?[r]:Wt(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))";p.length>0&&(b.push(e.jsx("text",{className:"annotation-note-title",fill:x,textAnchor:g,fontWeight:"bold",children:p.map((t,o)=>e.jsx("tspan",{x:m,dy:0===o?0:f,children:t},o))},"annotation-note-title")),v=p.length*f),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:g,y:v,children:y.map((t,o)=>e.jsx("tspan",{x:m,dy:0===o?0:f,children:t},o))},"annotation-note-label"));let k=null;if((s||r)&&(0!==o||0!==n))if("topBottom"===d){const t=Math.min(c,120);let o=0,n=t;"end"===g?(o=-t,n=0):"middle"===g&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:o,x2:n,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*f+(y.length>0?f:0);let o=0,n=t;"bottom"===h?(o=-t,n=0):"middle"===h&&(o=-t/2,n=t/2),k=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:o,y2:n,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const w=Math.max(0,p.length+y.length-1)*f;let A=0;return"topBottom"===d?A=0>n?-(w+2):18:"leftRight"===d&&(A="middle"===h?-(w+f+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>n?-(w+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${o},${n})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:b}),k]})}function Yt(t,o,n,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==o?void 0:o.radius)||0)+((null==o?void 0:o.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==o?void 0:o.width)||0,i=(null==o?void 0:o.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==o?void 0:o.custom)&&a.push(...Array.isArray(o.custom)?o.custom:[o.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==o?void 0:o.x)){const i=(o.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(o.y1||0)-s,x2:i,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==o?void 0:o.y)){const i=(o.y||0)-s;a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:i,x2:(o.x2||0)-t,y2:i,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==o?void 0:o.x1)||void 0!==(null==o?void 0:o.x2)?a.push(e.jsx("line",{x1:(o.x1||0)-t,y1:0,x2:(o.x2||0)-t,y2:0,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==o?void 0:o.y1)&&void 0===(null==o?void 0:o.y2)||a.push(e.jsx("line",{x1:0,y1:(o.y1||0)-s,x2:0,y2:(o.y2||0)-s,stroke:n||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==o?void 0:o.width)&&void 0!==s?s:null==o?void 0:o.height;void 0!==t&&a.push(e.jsx("path",{d:zt((null==o?void 0:o.type)||"curly",t,(null==o?void 0:o.depth)||30,void 0===(null==o?void 0:o.width)),fill:"none",stroke:n||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function qt(t,o,n,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,n=s.height||0;if(e>0||n>0){const i=e/2,r=n/2,s=t-i,a=o-r;if(0!==s||0!==a){const t=Math.abs(s),o=Math.abs(a),u=e/2,d=n/2,h=t*d>o*u?u/t:d/o;l=i+s*h,c=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,o=s.depth||30;void 0!==e?(l=e/2,c=o):void 0!==t&&(l=o,c=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==o)){const n=Math.atan2(o,t);l=Math.cos(n)*e,c=Math.sin(n)*e}}if(Math.sqrt(Math.pow(t-l,2)+Math.pow(o-c,2))>.5&&(a.push(e.jsx("line",{x1:l,y1:c,x2:t,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"},"connector-line")),"arrow"===(null==n?void 0:n.end))){const n=10,r=16/180*Math.PI,s=Math.atan2(o-c,t-l);a.push(e.jsx("path",{d:`M${l},${c}L${l+n*Math.cos(s+r)},${c+n*Math.sin(s+r)}L${l+n*Math.cos(s-r)},${c+n*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 Xt(t){const{x:o=0,y:n=0,dx:i,dy:r,nx:s,ny:a,note:l,connector:c,subject:u,type:d,color:h,className:g,disable:f,events:p={},"data-testid":y}=t,m=new Set(Array.isArray(f)?f:[]);let v=i||0,b=r||0;null!=s&&(v=s-o),null!=a&&(b=a-n);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(${o},${n})`,"data-testid":y},p,{children:[!m.has("connector")&&qt(v,b,c,h,x,u),!m.has("subject")&&Yt(x,u,h,o,n),!m.has("note")&&Gt(l,v,b,h)]}))}function Vt(t){var o,n;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!==(o=i.dx)&&void 0!==o?o:0),a=i.ny||r[0][1]+(null!==(n=i.dy)&&void 0!==n?n:0),l=r.map((o,n)=>{const r=Object.assign({},i,{note:0===n?i.note:{label:""},x:o[0],y:o[1],nx:t,ny:a});return e.jsx(Xt,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+n)});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(Xt,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Ut(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.x)&&void 0!==n?n: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 Kt(e,t){var o,n,i;const r=null!==(n=null===(o=t.scales)||void 0===o?void 0:o.y)&&void 0!==n?n: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 Qt(e,t,o){var n,i,r,s;const a=e.anchor||"fixed";if("latest"===a){if(null!=e.pointId&&o.pointNodes&&o.pointNodes.length>0)for(let i=o.pointNodes.length-1;i>=0;i--){const r=o.pointNodes[i];if(r.pointId===e.pointId){const e={x:r.x,y:r.y};return null===(n=o.stickyPositionCache)||void 0===n||n.set(t,e),e}}const r=function(e){var t,o,n,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(o=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==o?o:null===(n=e.scales)||void 0===n?void 0:n.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)}}(o);return r&&(null===(i=o.stickyPositionCache)||void 0===i||i.set(t,r)),r}let l=null,c=null;if(null!=e.pointId&&o.pointNodes){const t=o.pointNodes.find(t=>t.pointId===e.pointId);t&&(l=t.x,c=t.y)}if(null!=l&&null!=c||(l=Ut(e,o),c=Kt(e,o)),null!=l&&null!=c)return null===(r=o.stickyPositionCache)||void 0===r||r.set(t,{x:l,y:c}),{x:l,y:c};if("sticky"===a){const e=null===(s=o.stickyPositionCache)||void 0===s?void 0:s.get(t);if(e)return e}return null}function Zt(e,t,o,n=50){return!(-n>e||e>(o.width||0)+n||-n>t||t>(o.height||0)+n)}const Jt={linear:s.curveLinear,monotoneX:s.curveMonotoneX,monotoneY:s.curveMonotoneY,step:s.curveStep,stepAfter:s.curveStepAfter,stepBefore:s.curveStepBefore,basis:s.curveBasis,cardinal:s.curveCardinal,catmullRom:s.curveCatmullRom};function eo(t){return function(t,o,n){var i,r,a,c,u,d,h,g,f,p,m,v,b,x,k,w,A,j,S,C,O,M,P,_,L,T,R,B,N,D,E,I,H,F,$,W,z,G,Y,q,X,V,U,K,Q,Z,J,ee;switch(t.type){case"label":{const i=Qt(t,o,n);if(!i)return null;const{x:r,y:s}=i;return Zt(r,s,n)?e.jsx(Vt,{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-"+o):null}case"callout":{const i=Qt(t,o,n);if(!i)return null;const{x:r,y:s}=i;return Zt(r,s,n)?e.jsx(Vt,{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-"+o):null}case"x-threshold":{const i=Ut(null!=t.value?Object.assign(Object.assign({},t),{x:t.value}):t,n);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(n.height||0)-4:"center"===s?(n.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:n.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-"+o)}case"y-threshold":{const i=Kt(null!=t.value?Object.assign(Object.assign({},t),{y:t.value}):t,n);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=(n.width||0)/2,l="middle"):(a=(n.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:n.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-"+o)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),n),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),n),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-"+o)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),n),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),n)})).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-"+o)}case"highlight":{const i=n.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((o,i)=>{const r=Ut(o,n),a=Kt(o,n);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(o):t.r||6,c="function"==typeof t.style?t.style(o):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+o)}case"bracket":{const i=Ut(t,n),r=Kt(t,n);return e.jsx(Vt,{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-"+o)}case"trend":{const s=n.data||[];if(2>s.length)return null;const l=n.xAccessor||"x",g=n.yAccessor||"y",f="ordinal"===n.frameType,p="horizontal"===n.projection,m=f?l:null,v=f?g:null;let b;const x=[],k=new Map;if(f&&m&&v){for(const e of s){const t=e[m];if(null==t)continue;const o=t+"";k.has(o)||(k.set(o,x.length),x.push(o))}b=s.map(e=>{const t=e[m],o=e[v];if(null==t||null==o)return null;const n=k.get(t+"");return null!=n?[n,+o]:null}).filter(e=>null!==e)}else b=s.map(e=>[e[l],e[g]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>b.length)return null;const w=null!==(r=null===(i=n.scales)||void 0===i?void 0:i.x)&&void 0!==r?r:null===(a=n.scales)||void 0===a?void 0:a.time,A=null!==(u=null===(c=n.scales)||void 0===c?void 0:c.y)&&void 0!==u?u:null===(d=n.scales)||void 0===d?void 0:d.value;if(!w||!A)return null;const j=e=>t=>{const o=Math.max(0,Math.floor(t)),n=Math.min(x.length-1,o+1),i=t-o,r=e(x[o]);return r+(e(x[n])-r)*i},S=w,C=A;let O;if(f)if(p){const e=j(C);O=(t,o)=>[S(o),e(t)]}else{const e=j(S);O=(t,o)=>[e(t),C(o)]}else O=(e,t)=>[S(e),C(t)];const M=t.method||"linear";let P;P="loess"===M?function(e,t=.3){const o=e.length;if(2>o)return e.slice();const n=e.slice().sort((e,t)=>e[0]-t[0]),i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.max(2,Math.ceil(t*o)),a=[];for(let e=0;o>e;e++){const t=i[e],n=i.map(e=>Math.abs(e-t)),l=n.slice().sort((e,t)=>e-t)[Math.min(s-1,o-1)]||1,c=[];for(let e=0;o>e;e++){const t=0===l?0:n[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;o>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],g+=t*i[e]*i[e],f+=t*i[e]*r[e])}if(0===u){a.push([t,r[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}(b,null!==(h=t.bandwidth)&&void 0!==h?h:.3):("polynomial"===M?y.default.polynomial(b,{order:t.order||2}):y.default.linear(b)).points;const _=P.map(([e,t])=>{const[o,n]=O(e,t);return`${o},${n}`}).join(" "),L=t.color||"#6366f1",T=P[P.length-1],[R,B]=O(T[0],T[1]);return e.jsxs("g",{children:[e.jsx("polyline",{points:_,fill:"none",stroke:L,strokeWidth:t.strokeWidth||2,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:R+4,y:B-4,fill:L,fontSize:11,children:t.label})]},"ann-"+o)}case"band":{const i=null!==(f=null===(g=n.scales)||void 0===g?void 0:g.y)&&void 0!==f?f:null===(p=n.scales)||void 0===p?void 0:p.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:n.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:n.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+o)}case"envelope":{const i=n.data||[];if(2>i.length)return null;const r=n.xAccessor||"x",a=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,l=null!==(A=null===(w=n.scales)||void 0===w?void 0:w.y)&&void 0!==A?A:null===(j=n.scales)||void 0===j?void 0:j.value;if(!a||!l)return null;const c=t.upperAccessor||"upperBounds",u=t.lowerAccessor||"lowerBounds",d=t.filter,h=i.filter(e=>null!=e[c]&&null!=e[u]&&!(d&&!d(e))).sort((e,t)=>e[r]-t[r]);if(2>h.length)return null;const g=Jt[n.curve||"linear"]||s.curveLinear,f=s.area().x(e=>a(e[r])).y0(e=>l(e[u])).y1(e=>l(e[c])).curve(g)(h);if(!f)return null;const p=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:f,fill:p,fillOpacity:null!==(S=t.fillOpacity)&&void 0!==S?S:.15,stroke:"none"}),t.label&&h.length>0&&e.jsx("text",{x:a(h[h.length-1][r])+4,y:l(h[h.length-1][c])-4,fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"anomaly-band":{const i=n.data||[];if(2>i.length)return null;const r=n.yAccessor||"y",s=null!==(O=null===(C=n.scales)||void 0===C?void 0:C.x)&&void 0!==O?O:null===(M=n.scales)||void 0===M?void 0:M.time,a=null!==(_=null===(P=n.scales)||void 0===P?void 0:P.y)&&void 0!==_?_:null===(L=n.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!==(T=t.threshold)&&void 0!==T?T:2,g=c-h*d,f=!1!==t.showBand,p=t.fill||"#6366f1",y=null!==(R=t.fillOpacity)&&void 0!==R?R:.1,m=t.anomalyColor||"#ef4444",v=null!==(B=t.anomalyRadius)&&void 0!==B?B: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:[f&&e.jsx("rect",{x:0,y:Math.min(b,x),width:n.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),k.map((t,o)=>{const i=Ut(t,n),r=Kt(t,n);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-"+o)}),t.label&&e.jsx("text",{x:(n.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+o)}case"forecast":{const i=n.data||[];if(3>i.length)return null;const r=n.xAccessor||"x",s=n.yAccessor||"y",a=null!==(D=null===(N=n.scales)||void 0===N?void 0:N.x)&&void 0!==D?D:null===(E=n.scales)||void 0===E?void 0:E.time,l=null!==(H=null===(I=n.scales)||void 0===I?void 0:I.y)&&void 0!==H?H:null===(F=n.scales)||void 0===F?void 0:F.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=y.default.polynomial(c,{order:t.order||2}).equation;u=t=>e.reduce((e,o,n)=>e+o*Math.pow(t,n),0)}else{const e=c.length;let t=0,o=0,n=0,i=0;for(const[e,r]of c)t+=e,o+=r,n+=e*e,i+=e*r;const r=e*n-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*o)/r,a=(o-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,p=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!==(W=t.steps)&&void 0!==W?W: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 A=[];for(const e of w){const t=u(e),o=g*Math.sqrt(1+1/d+(p>0?Math.pow(e-f,2)/p:0))*v;A.push({x:e,yCenter:t,yUpper:t+o,yLower:t-o})}const j=`M${A.map(e=>`${a(e.x)},${l(e.yUpper)}`).join(" L")} L${A.slice().reverse().map(e=>`${a(e.x)},${l(e.yLower)}`).join(" L")} Z`,S=A.map(e=>`${a(e.x)},${l(e.yCenter)}`).join(" "),C=`${a(x)},${l(u(x))}`,O=t.strokeColor||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:j,fill:t.fill||"#6366f1",fillOpacity:null!==(z=t.fillOpacity)&&void 0!==z?z:.15,stroke:"none"}),e.jsx("polyline",{points:`${C} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(G=t.strokeWidth)&&void 0!==G?G:2,strokeDasharray:null!==(Y=t.strokeDasharray)&&void 0!==Y?Y:"6,3"}),t.label&&A.length>0&&e.jsx("text",{x:a(A[A.length-1].x)+4,y:l(A[A.length-1].yCenter)-4,fill:O,fontSize:11,children:t.label})]},"ann-"+o)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=Qt(t,o,n);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!Zt(i,r,n))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!==(K=t.content)&&void 0!==K?K: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-"+o)}case"text":{const i=Qt(t,o,n);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-"+o)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,s=null===(Q=n.scales)||void 0===Q?void 0:Q.o,a=null===(Z=n.scales)||void 0===Z?void 0:Z.x,l=null===(J=n.scales)||void 0===J?void 0:J.y,c=r(s)?s:r(a)?a:r(l)?l:null;if(!c)return null;const u=c(i+"");if(null==u)return null;const d=c.bandwidth(),h=t.color||"var(--semiotic-primary, #4589ff)",g=null!==(ee=t.opacity)&&void 0!==ee?ee:.15,f=t.label;return e.jsxs("g",(n.projection?"vertical"===n.projection:c===a)?{children:[e.jsx("rect",{x:u,y:0,width:d,height:n.height||0,fill:h,fillOpacity:g}),f&&e.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]}:{children:[e.jsx("rect",{x:0,y:u,width:n.width||0,height:d,fill:h,fillOpacity:g}),f&&e.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:f})]},"ann-"+o)}default:return null}}}let to={positions:new Map};const oo=new Set;function no(){for(const e of oo)e()}function io(e,t){const o=to.positions.get(e);if(null==o?void 0:o.locked)return;if(!o||o.sourceId!==t)return;const n=new Map(to.positions);n.delete(e),to={positions:n},no()}function ro(e,t){const o=to.positions.get(e);if(!(null==o?void 0:o.locked))return;if(t&&o.sourceId!==t)return;const n=new Map(to.positions);n.delete(e),to={positions:n},no()}function so(){return to}function ao(e){return oo.add(e),()=>oo.delete(e)}const lo={positions:new Map};function co(){return()=>{}}function uo(){return lo}function ho(e,t,o){return"exact"===o?function(e,t){const o=e.domain(),n=o[0],i=o[o.length-1],r=n instanceof Date,s=n instanceof Date?n.getTime():n,a=i instanceof Date?i.getTime():i;if(2>t||s===a)return r?[new Date(s),new Date(a)]:[s,a];const l=(a-s)/(t-1),c=Array(t);for(let e=0;t>e;e++){const o=e===t-1?a:s+e*l;c[e]=r?new Date(o):o}return c}(e,t):e.ticks(t)}function go(e,t,o){if("edges"===e){if(t)return"start";if(o)return"end"}return"middle"}function fo(e,t,o){if("edges"===e){if(t)return"hanging";if(o)return"auto"}return"middle"}function po(e){if(0===e.length)return{min:null,max:null};let t=1/0,o=-1/0;for(const n of e)t>n.pixel&&(t=n.pixel),n.pixel>o&&(o=n.pixel);return{min:t,max:o}}function yo(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function mo(e,t,o){if("left"===e||"right"===e){const n="left"===e?o:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+n;for(let e=0;r>e;e++){const o=8*(e+1);s+=`L${Math.min(8*e+4,t)},${n+4*i}`,s+=`L${Math.min(o,t)},${n}`}return s}{const n="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(o/8);let s=`M${n},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${n+4*i},${Math.min(8*e+4,o)}`,s+=`L${n},${Math.min(t,o)}`}return s}}function vo(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:g,axisExtent:f}=o,p=t.useMemo(()=>{var e,t;if(!l)return[];const o=null==u?void 0:u.find(e=>"bottom"===e.orient),i=(null==o?void 0:o.tickFormat)||h||bo,r=Math.max(2,Math.floor(n/70)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5,a=null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(l.x,"exact"===f?Math.max(2,s):Math.min(s,r),f),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:l.x(e),label:i(e,t,c)})),g=d.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:"number"==typeof t.label?6.5*(t.label+"").length:60),0);return xo(d,Math.max(55,g+8))},[l,u,h,n,f]),y=t.useMemo(()=>{var e,t;if(!l)return[];const o=null==u?void 0:u.find(e=>"left"===e.orient),n=(null==o?void 0:o.tickFormat)||g||bo,r=Math.max(2,Math.floor(i/30)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5;return xo((null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(l.y,"exact"===f?Math.max(2,s):Math.min(s,r),f)).map(e=>({value:e,pixel:l.y(e),label:n(e)})),22)},[l,u,g,i,f]),m=d&&l,v=c&&l;if(!m&&!v)return null;const b=null==u?void 0:u.find(e=>"bottom"===e.orient),x=null==u?void 0:u.find(e=>"left"===e.orient),k=v&&(!b||!1!==b.baseline),w=v&&(!x||!1!==x.baseline),A=(null==b?void 0:b.jaggedBase)||!1,j=(null==x?void 0:x.jaggedBase)||!1,S="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:[m&&(()=>{var t,o;const r=yo(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=yo(null===(o=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[p.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+o)),y.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:n,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+o))]})})(),k&&!A&&e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:S,strokeWidth:1}),A&&e.jsx("path",{d:mo("bottom",n,i),fill:"none",stroke:S,strokeWidth:1}),w&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:S,strokeWidth:1}),j&&e.jsx("path",{d:mo("left",n,i),fill:"none",stroke:S,strokeWidth:1})]})})}function bo(e,t,o){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function xo(e,t){if(2>=e.length)return e;const o=[e[0]];for(let n=1;e.length-1>n;n++)t>Math.abs(e[n].pixel-o[o.length-1].pixel)||o.push(e[n]);const n=e[e.length-1];return t>Math.abs(n.pixel-o[o.length-1].pixel)?o[o.length-1]=n:o.push(n),o}function ko(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,axes:h,xLabel:g,yLabel:f,yLabelRight:p,xFormat:y,yFormat:m,axisExtent:v,showGrid:b,title:x,legend:k,legendHoverBehavior:w,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S,legendPosition:C="right",legendLayout:O,foregroundGraphics:M,marginalGraphics:P,xValues:_,yValues:L,annotations:T,svgAnnotationRules:R,xAccessor:B,yAccessor:N,annotationData:D,pointNodes:E,curve:I,underlayRendered:H,canvasObscuresUnderlay:F=!0,linkedCrosshairName:$,linkedCrosshairSourceId:W,children:z}=o,G=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=(null==o?void 0:o.tickFormat)||y||bo,i=Math.max(2,Math.floor(r/70)),s=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5,a=null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(u.x,"exact"===v?Math.max(2,s):Math.min(s,i),v),l=a.map(e=>e.valueOf()),c=a.map((e,t)=>({value:e,pixel:u.x(e),label:n(e,t,l)})),g=c.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),f=(null==o?void 0:o.autoRotate)?Math.max(20,Math.min(g+8,55)):Math.max(55,g+8);let p=xo(c,f);if(p.length>1&&(p=p.filter((e,t)=>0===t||e.label+""!=p[t-1].label+"")),(null==o?void 0:o.includeMax)&&p.length>0&&"exact"!==v&&!(null==o?void 0:o.tickValues)){const e=u.x.domain()[1],t=u.x(e),o=p[p.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e,p.length,l);f>t-o&&p.length>1&&(p=p.slice(0,-1)),p.push({value:e,pixel:t,label:i})}}return p},[d,u,h,y,r,v]),Y=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"left"===e.orient),n=(null==o?void 0:o.tickFormat)||m||bo,i=Math.max(2,Math.floor(s/30)),r=null!==(e=null==o?void 0:o.ticks)&&void 0!==e?e:5;let a=xo((null!==(t=null==o?void 0:o.tickValues)&&void 0!==t?t:ho(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:n(e)})),22);if(a.length>1&&(a=a.filter((e,t)=>0===t||e.label+""!=a[t-1].label+"")),(null==o?void 0:o.includeMax)&&a.length>0&&"exact"!==v&&!(null==o?void 0:o.tickValues)){const e=u.y.domain()[1],t=u.y(e),o=a[a.length-1].pixel;if(Math.abs(t-o)>1){const i=n(e);22>Math.abs(t-o)&&a.length>1&&(a=a.slice(0,-1)),a.push({value:e,pixel:t,label:i})}}return a},[d,u,h,m,s,v]),q=t.useMemo(()=>{var e,t;if(!d||!u)return[];const o=null==h?void 0:h.find(e=>"right"===e.orient);if(!o)return[];const n=o.tickFormat||m||bo,i=Math.max(2,Math.floor(s/30)),r=null!==(e=o.ticks)&&void 0!==e?e:5;return xo((null!==(t=o.tickValues)&&void 0!==t?t:ho(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:n(e)})),22)},[d,u,h,m,s,v]),X=t.useRef(new Map),V=t.useRef(null!==(n=null==T?void 0:T.length)&&void 0!==n?n:0),U=null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0;V.current!==U&&(V.current=U,X.current=new Map);const K=t.useMemo(()=>{if(!T||0===T.length)return null;const e=eo(),t={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:B,yAccessor:N,width:r,height:s,data:D,frameType:"xy",pointNodes:E,curve:I,stickyPositionCache:X.current};return T.map((o,n)=>{if(R){const i=R(o,n,t);return null!=i?i:e(o,n,t)}return e(o,n,t)}).filter(Boolean)},[T,R,r,s,B,N,D,u,E,I]),Q=function(e){var o;const n=t.useSyncExternalStore(e?ao:co,e?so:uo,e?so:uo);return e&&null!==(o=n.positions.get(e))&&void 0!==o?o:null}($);return t.useEffect(()=>{if(!(null==Q?void 0:Q.locked)||!$)return;const e=e=>{"Escape"===e.key&&ro($)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==Q?void 0:Q.locked,$]),d||x||k||M||P||K&&K.length>0||b||z||Q?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof x?x:"XY Chart"}),e.jsx("desc",{children:"string"==typeof x?x+" — XY data visualization":"XY data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[b&&u&&(!H||F)&&(()=>{var t,o;const n=yo(null===(t=null==h?void 0:h.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=yo(null===(o=null==h?void 0:h.find(e=>"left"===e.orient))||void 0===o?void 0:o.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[G.map((t,o)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:n},"xgrid-"+o)),Y.map((t,o)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+o))]})})(),d&&u&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),o=null==h?void 0:h.find(e=>"bottom"===e.orient),n=!t||!1!==t.baseline,i=!o||!1!==o.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==o?void 0:o.jaggedBase)||!1,u=null==o?void 0:o.landmarkTicks,d=null==t?void 0:t.landmarkTicks,y="var(--semiotic-border, #ccc)",m="var(--semiotic-text-secondary, var(--semiotic-text, #666))",v="var(--semiotic-text, #333)",b=!!(null==o?void 0:o.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})(),x={fontSize:"var(--semiotic-tick-font-size, 10px)"},k={fontSize:"calc(var(--semiotic-tick-font-size, 10px) + 1px)"},w={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=null==o?void 0:o.tickAnchor,j=null==t?void 0:t.tickAnchor,S=po(G),C=po(Y);return e.jsxs("g",{className:"stream-axes",style:{fontFamily:"var(--semiotic-font-family, sans-serif)"},children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[(!H||F)&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:y,strokeWidth:1}),(!H||F)&&l&&e.jsx("path",{d:mo("bottom",r,s),fill:"none",stroke:y,strokeWidth:1}),G.map((t,o)=>{const n=!!u&&("function"==typeof u?u(t.value,o):Ue(t.value,o>0?G[o-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":go(A,t.pixel===S.min,t.pixel===S.max),fontWeight:n?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},n?k:x),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:Object.assign({textAlign:"center",userSelect:"none"},x),children:t.label})})]},"xtick-"+o)}),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!H||F)&&n&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:y,strokeWidth:1}),(!H||F)&&a&&e.jsx("path",{d:mo("left",r,s),fill:"none",stroke:y,strokeWidth:1}),Y.map((t,o)=>{const n=!!d&&("function"==typeof d?d(t.value,o):Ue(t.value,o>0?Y[o-1].value:void 0));return e.jsxs("g",{transform:`translate(0,${t.pixel})`,children:[e.jsx("line",{x2:-5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:fo(j,t.pixel===C.min,t.pixel===C.max),fontWeight:n?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},n?k:x),children:t.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},x),children:t.label})})]},"ytick-"+o)}),(()=>{const o=(null==t?void 0:t.label)||f;return o?e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:v,transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:o}):null})()]}),(()=>{const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t||0===q.length)return null;const o=!1!==t.baseline,n=t.landmarkTicks,i=t.label||p,a=t.tickAnchor,l=po(q);return e.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[o&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:y,strokeWidth:1}),q.map((t,o)=>{const i=!!n&&("function"==typeof n?n(t.value,o):Ue(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:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{x:8,textAnchor:"start",dominantBaseline:fo(a,t.pixel===l.min,t.pixel===l.max),fontWeight:i?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},i?k:x),children:t.label}):e.jsx("foreignObject",{x:8,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"left",userSelect:"none"},x),children:t.label})})]},"ytick-r-"+o)}),i&&e.jsx("text",{x:r+c.right-15,y:s/2,textAnchor:"middle",fill:v,transform:`rotate(90, ${r+c.right-15}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},w),children:i})]})})()]})})(),K,P&&u&&_&&L&&e.jsxs(e.Fragment,{children:[P.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx($t,{orient:"top",config:Ft(P.top),values:_,scale:u.x,size:c.top,length:r})}),P.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx($t,{orient:"bottom",config:Ft(P.bottom),values:_,scale:u.x,size:c.bottom,length:r})}),P.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx($t,{orient:"left",config:Ft(P.left),values:L,scale:u.y,size:c.left,length:s})}),P.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx($t,{orient:"right",config:Ft(P.right),values:L,scale:u.y,size:c.right,length:s})})]}),M,Q&&Q.sourceId!==W&&(null==u?void 0:u.x)&&(()=>{const t=u.x(Q.xValue);if(null==t||0>t||t>r)return null;const o=Q.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:o?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:o?1.5:1,strokeDasharray:o?"6,3":"4,4",pointerEvents:"none"})})(),z]}),x&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof x?x:null}),Ht({legend:k,totalWidth:a,totalHeight:l,margin:c,legendPosition:C,title:x,legendLayout:O,legendHoverBehavior:w,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S})]}):null}function wo(e){var t,o,n,i;return(null!==(t=e.tl)&&void 0!==t?t:0)>0||(null!==(o=e.tr)&&void 0!==o?o:0)>0||(null!==(n=e.br)&&void 0!==n?n:0)>0||(null!==(i=e.bl)&&void 0!==i?i:0)>0}function Ao(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const o=Math.min(e.w,e.h)/2,n=e=>Math.max(0,Math.min(null!=e?e:0,o));return{tl:n(t.tl),tr:n(t.tr),br:n(t.br),bl:n(t.bl)}}const jo=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function So(e){var t,o;const{innerRadius:n,outerRadius:i,startAngle:r,endAngle:s}=e,a=0>=n;if(0>=(null!==(t=e.cornerRadius)&&void 0!==t?t:0)||!e.roundStart&&!e.roundEnd){if(a){const e=jo(i,r),t=jo(i,s);return`M0,0 L${e.x},${e.y} A${i},${i} 0 ${s-r>Math.PI?1:0} 1 ${t.x},${t.y} Z`}const e=jo(i,r),t=jo(i,s),o=jo(n,s),l=jo(n,r),c=s-r>Math.PI?1:0;return`M${e.x},${e.y} A${i},${i} 0 ${c} 1 ${t.x},${t.y} L${o.x},${o.y} A${n},${n} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(o=e.cornerRadius)&&void 0!==o?o:0,(i-n)/2));if(0===l)return So(Object.assign(Object.assign({},e),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const c=Math.asin(Math.min(1,l/Math.max(1e-9,i-l))),u=a?0:Math.asin(Math.min(1,l/Math.max(1e-9,n+l))),d=s-r,h=e.roundStart&&e.roundEnd?d/2:d,g=!!e.roundStart&&h>c,f=!!e.roundEnd&&h>c;if(!g&&!f)return So(Object.assign(Object.assign({},e),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const p=r+(g?c:0),y=s-(f?c:0),m=r+(g?u:0),v=s-(f?u:0),b=jo(i,p),x=jo(i,y),k=(i-l)*Math.cos(c),w=jo(k,r),A=jo(k,s),j=a?null:jo(n,v),S=a?null:jo(n,m),C=a?0:(n+l)*Math.cos(u),O=a?null:jo(C,r),M=a?null:jo(C,s),P=y-p>Math.PI?1:0,_=a?0:v-m>Math.PI?1:0;let L="";if(g)L+=`M${w.x},${w.y}`,L+=` A${l},${l} 0 0 1 ${b.x},${b.y}`;else{const e=jo(i,r);L+=`M${e.x},${e.y}`}if(f)L+=` A${i},${i} 0 ${P} 1 ${x.x},${x.y}`,L+=` A${l},${l} 0 0 1 ${A.x},${A.y}`;else{const e=jo(i,s);L+=` A${i},${i} 0 ${P} 1 ${e.x},${e.y}`}if(a)L+=" L0,0";else{if(f)L+=` L${M.x},${M.y}`,L+=` A${l},${l} 0 0 1 ${j.x},${j.y}`;else{const e=jo(n,s);L+=` L${e.x},${e.y}`}if(g)L+=` A${n},${n} 0 ${_} 0 ${S.x},${S.y}`,L+=` A${l},${l} 0 0 1 ${O.x},${O.y}`;else{const e=jo(n,r);L+=` A${n},${n} 0 ${_} 0 ${e.x},${e.y}`}}return L+=" Z",L}function Co(e){const t=So({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),o=[],n=e.colors;if(n.length>0){const t=(e.endAngle-e.startAngle)/n.length;for(let i=0;n.length>i;i++)o.push({d:So({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+i*t,endAngle:e.endAngle}),color:n[i]})}return{clipPath:t,slices:o}}const Oo={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Mo(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function Po(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}const _o="undefined"==typeof window||"undefined"==typeof document,Lo="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function To(){const[e,o]=t.useState(!1);return Lo(()=>{o(!0)},[]),e}const Ro=()=>()=>{},Bo=()=>!1,No=()=>!0;function Do(){const e=t.useSyncExternalStore(Ro,Bo,No);return t.useRef(e).current}function Eo(e){const{hydrated:o,wasHydratingFromSSR:n,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=e;Lo(()=>{var e,t;o&&n&&(null===(t=null===(e=i.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),r.current=!0,s.current()},[o,n]);const l=t.useRef(a);l.current=a,t.useEffect(()=>()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.call(l)},[])}function Io(e){const o=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return Fo(e,t);if(!$o(e)||!$o(t))return!1;const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(const n of o){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;const o=e[n],i=t[n];if(!Object.is(o,i))if(Array.isArray(o)&&Array.isArray(i)){if(!Fo(o,i))return!1}else{if(!$o(o)||!$o(i))return!1;if(!Ho(o,i))return!1}}return!0}(o.current,e)||(o.current=e),o.current}function Ho(e,t){const o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(const n of o){if(!Object.prototype.hasOwnProperty.call(t,n))return!1;if(!Object.is(e[n],t[n]))return!1}return!0}function Fo(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(!Object.is(e[o],t[o]))return!1;return!0}function $o(e){if(null===e||"object"!=typeof e)return!1;if(Array.isArray(e))return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}const Wo=p.createContext(null);function zo({children:t}){const[o,n]=p.useState(!1),i=p.useMemo(()=>({visible:o,setVisible:n}),[o]);return e.jsx(Wo.Provider,{value:i,children:t})}function Go(){return p.useContext(Wo)}const Yo={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function qo(e,t){if(!e||0===e.length)return t+", empty";const o={};for(const t of e){if(null===(null==t?void 0:t.datum))continue;const e=t.type+"";o[e]=(o[e]||0)+1}if(0===Object.keys(o).length)return t+", empty";const n=[],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(o).sort((e,t)=>{const o=r.indexOf(e),n=r.indexOf(t);return(-1===o?999:o)-(-1===n?999:n)});for(const e of s)n.push(`${o[e]} ${i[e]||e}`);return`${t}, ${n.join(", ")}`}function Xo(e,t,o){const n=[];return e>0&&n.push(e+" nodes"),t>0&&n.push(t+" edges"),0===n.length?o+", empty":`${o}, ${n.join(", ")}`}const Vo=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""},Uo="semiotic-accessible-data-table",Ko=Uo+" semiotic-accessible-data-table-hidden",Qo=Uo+" semiotic-accessible-data-table-visible",Zo=Qo+" semiotic-accessible-data-table-network",Jo={position:"absolute",top:0,left:0,right:0,zIndex:"var(--semiotic-data-table-z-index, var(--semiotic-overlay-z-index, 20))",padding:"14px 16px 12px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontFamily:"var(--semiotic-font-family, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif)",fontSize:13,lineHeight:1.5,color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",borderRadius:"var(--semiotic-border-radius, 0px) var(--semiotic-border-radius, 0px) 0 0"},en={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},tn={position:"absolute",top:10,right:10,width:22,height:22,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",cursor:"pointer",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:13,lineHeight:1,padding:0,borderRadius:"var(--semiotic-border-radius, 4px)"},on={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},nn={textAlign:"left",padding:"5px 10px",borderBottom:"2px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",fontWeight:600,fontSize:11,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))"},rn={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},sn={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #999))",marginBottom:4,fontStyle:"italic"};function an({scene:t,chartType:o,tableId:n,chartTitle:i}){var r;const[s,a]=p.useState(!1),l=Go(),c=null!==(r=null==l?void 0:l.visible)&&void 0!==r&&r,u=s||c,d=p.useRef(null),h=i?"Data summary for "+i:n?`Data summary for ${o} ${n}`:"Data summary for "+o,g=p.useCallback(()=>{s||c||a(!0)},[s,c]),f=p.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 n?e.jsx("span",{id:n,tabIndex:-1,style:Yo}):null;if(!u)return e.jsx("div",{id:n,className:Ko,tabIndex:-1,onFocus:g,style:Yo,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,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x,k,w,A,j,S;const C=[];if(!Array.isArray(e))return C;for(const O of e)if(O&&"object"==typeof O&&null!==O.datum)try{switch(O.type){case"point":C.push({label:"Point",values:{x:O.x,y:O.y}});break;case"line":{const e=O.path,t=Array.isArray(O.datum)?O.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&C.push({label:"Line point",values:{x:t[0],y:t[1]}})}break}case"area":{const e=O.topPath,t=Array.isArray(O.datum)?O.datum:[];if(!Array.isArray(e))break;for(let o=0;e.length>o&&t.length>o;o++){const t=e[o];Array.isArray(t)&&C.push({label:"Area point",values:{x:t[0],y:t[1]}})}break}case"rect":{const e=null!=O.datum&&"object"==typeof O.datum?O.datum:{},r=null!==(o=null!==(t=e.category)&&void 0!==t?t:O.group)&&void 0!==o?o:"",s=null!==(i=null!==(n=e.value)&&void 0!==n?n:e.__aggregateValue)&&void 0!==i?i:e.total;C.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":C.push({label:"Cell",values:{x:O.x,y:O.y,value:O.value}});break;case"wedge":C.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=O.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=O.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=O.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":C.push({label:"Node",values:{id:null!==(h=null===(d=O.datum)||void 0===d?void 0:d.id)&&void 0!==h?h:"",x:null!==(g=O.cx)&&void 0!==g?g:O.x,y:null!==(f=O.cy)&&void 0!==f?f:O.y}});break;case"arc":C.push({label:"Arc",values:{id:null!==(y=null===(p=O.datum)||void 0===p?void 0:p.id)&&void 0!==y?y:"",x:null!==(m=O.cx)&&void 0!==m?m:O.x,y:null!==(v=O.cy)&&void 0!==v?v:O.y}});break;case"candlestick":C.push({label:"Candlestick",values:{x:O.x,open:O.open,high:O.high,low:O.low,close:O.close}});break;case"geoarea":C.push({label:"Region",values:{name:null!==(A=null!==(k=null===(x=null===(b=O.datum)||void 0===b?void 0:b.properties)||void 0===x?void 0:x.name)&&void 0!==k?k:null===(w=O.datum)||void 0===w?void 0:w.name)&&void 0!==A?A:"",value:null!==(S=null===(j=O.datum)||void 0===j?void 0:j.value)&&void 0!==S?S:""}})}}catch(e){}return C}(t),m=function(e){if(!e||0===e.length)return[];const t=new Set;for(const o of e)if(o&&o.values)for(const e of Object.keys(o.values))t.add(e);const o=[];for(const n of t){const t=[],i=new Set;for(const o of e){if(!o||!o.values)continue;const e=o.values[n];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 o of t)e>o&&(e=o),o>i&&(i=o),r+=o;o.push({name:n,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);o.push({name:n,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return o}(y),v=function(e,t){const o=[e+" data points."];for(const e of t)if(e.numeric)o.push(`${e.name}: ${Vo(e.min)} to ${Vo(e.max)}, mean ${Vo(e.mean)}.`);else{const t=e.uniqueValues,n=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");o.push(`${e.name}: ${n}.`)}return o.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:n,className:Qo,tabIndex:-1,onBlur:f,style:Jo,role:"region","aria-label":h,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{c&&l&&l.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:tn,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:en,children:v}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+o,style:on,children:[e.jsxs("caption",{className:"semiotic-accessible-data-table-caption",style:sn,children:["First ",b.length," of ",y.length," data points"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:nn,children:"type"}),k.map(t=>e.jsx("th",{style:nn,children:t},t))]})}),e.jsx("tbody",{children:b.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:rn,children:t.label}),k.map(o=>{return e.jsx("td",{style:rn,children:(n=t.values[o],null==n||""===n?"—":"number"==typeof n?Number.isNaN(n)?"—":Vo(n):"boolean"==typeof n?n?"true":"false":"object"==typeof n?"—":n+"")},o);var n})]},o))})]})]})}function ln({nodes:t,edges:o,chartType:n,tableId:i,chartTitle:r}){var s,a,l,c,u,d,h,g,f,y,m,v,b,x;const[k,w]=p.useState(!1),A=Go(),j=null!==(s=null==A?void 0:A.visible)&&void 0!==s&&s,S=k||j,C=r?"Data summary for "+r:i?`Data summary for ${n} ${i}`:"Data summary for "+n,O=p.useRef(null),M=p.useCallback(()=>{k||j||w(!0)},[k,j]),P=p.useCallback(e=>{var t;j||(null===(t=O.current)||void 0===t?void 0:t.contains(e.relatedTarget))||w(!1)},[j]);if(!t||0===t.length)return i?e.jsx("span",{id:i,tabIndex:-1,style:Yo}):null;if(!S)return e.jsx("div",{id:i,className:Ko,tabIndex:-1,onFocus:M,style:Yo,role:"region","aria-label":C,children:e.jsxs("button",{type:"button",onClick:()=>w(!0),children:["View data summary (",t.length," nodes, ",o.length," edges)"]})});const _=Array.isArray(t)?t:[],L=Array.isArray(o)?o:[],T=new Map,R=new Map,B=new Map,N=new Map;for(const e of L){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,o="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,n="object"==typeof t.target?null===(c=t.target)||void 0===c?void 0:c.id:t.target,i="number"==typeof t.value&&Number.isFinite(t.value)?t.value:0;if(null!=o&&""!==o){const e=o+"";R.set(e,(null!==(u=R.get(e))&&void 0!==u?u:0)+1),N.set(e,(null!==(d=N.get(e))&&void 0!==d?d:0)+i)}if(null!=n&&""!==n){const e=n+"";T.set(e,(null!==(h=T.get(e))&&void 0!==h?h:0)+1),B.set(e,(null!==(g=B.get(e))&&void 0!==g?g:0)+i)}}const D=[];for(let e=0;_.length>e;e++){const t=_[e];if(!t||"object"!=typeof t)continue;const o=null!==(y=null===(f=t.datum)||void 0===f?void 0:f.id)&&void 0!==y?y:t.id,n=null!=o?o+"":"node-"+e,i=null!==(m=T.get(n))&&void 0!==m?m:0,r=null!==(v=R.get(n))&&void 0!==v?v:0,s=null!==(b=B.get(n))&&void 0!==b?b:0,a=null!==(x=N.get(n))&&void 0!==x?x:0;D.push({id:n,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}D.sort((e,t)=>t.degree-e.degree);let E=0,I=0;if(D.length>0){let e=0;for(const t of D)e+=t.degree,t.degree>I&&(I=t.degree);E=e/D.length}const H=L.some(e=>{var t;const o=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==o?void 0:o.value)&&Number.isFinite(o.value)}),F=[`${D.length} nodes, ${L.length} edges.`];D.length>0&&F.push(`Mean degree: ${Vo(E)}, max degree: ${I}.`);const $=D.slice(0,5);return e.jsxs("div",{ref:O,id:i,className:Zo,tabIndex:-1,onBlur:P,style:Jo,role:"region","aria-label":C,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{j&&A&&A.setVisible(!1),w(!1)},"aria-label":"Close data summary",style:tn,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:en,children:F.join(" ")}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+n,style:on,children:[e.jsxs("caption",{className:"semiotic-accessible-data-table-caption",style:sn,children:["Top ",$.length," of ",D.length," nodes by degree"]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:nn,children:"id"}),e.jsx("th",{style:nn,children:"degree"}),e.jsx("th",{style:nn,children:"in"}),e.jsx("th",{style:nn,children:"out"}),H&&e.jsx("th",{style:nn,children:"w. degree"}),H&&e.jsx("th",{style:nn,children:"w. in"}),H&&e.jsx("th",{style:nn,children:"w. out"})]})}),e.jsx("tbody",{children:$.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:rn,children:t.id}),e.jsx("td",{style:rn,children:t.degree}),e.jsx("td",{style:rn,children:t.inDeg}),e.jsx("td",{style:rn,children:t.outDeg}),H&&e.jsx("td",{style:rn,children:Vo(t.wDegree)}),H&&e.jsx("td",{style:rn,children:Vo(t.wInDeg)}),H&&e.jsx("td",{style:rn,children:Vo(t.wOutDeg)})]},o))})]})]})}function cn({summary:t}){return t?e.jsx("div",{role:"note",style:Yo,children:t}):null}function un({tableId:t}){return e.jsx("a",{href:"#"+t,style:Yo,onClick:e=>{e.preventDefault();const o=document.getElementById(t);o&&requestAnimationFrame(()=>o.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,Yo)},children:"Skip to data table"})}function dn({hoverPoint:t}){let o="";if(t){const e=t.data||t;o="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:Yo,children:o})}const hn="var(--semiotic-focus, #005fcc)";function gn({active:t,hoverPoint:o,margin:n,size:i,shape:r="circle",width:s,height:a}){if(!t||!o)return null;const l=o.x+n.left,c=o.y+n.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),o=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-o/2-3,width:t+6,height:o+6,rx:3,fill:"none",stroke:hn,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:hn,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:hn,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 fn(e){return Array.isArray(e)?e[0]:e}function pn(e,t,o,n){return Object.assign({data:fn(e),x:t,y:o,__semioticHoverData:!0},n)}const yn={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 mn(e,t){return"function"==typeof t?t(e):e[t]}function vn(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 bn(t={}){const{fields:o,title:n,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(n){const e=mn(t,n);a=vn(e,i)}if(o&&o.length>0)o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=mn(t,n);l.push({label:o,value:vn(s,r)})});else if(!n){const e=["value","y","name","id","label"];for(const o of e)if(void 0!==t[o]){a=vn(t[o],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=vn(t[e[0]],i))}}const c=Object.assign(Object.assign({},yn),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,o)=>e.jsxs("div",{style:{marginTop:0===o&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},o))]})}}function xn(){return t=>{var o,n,i,r,s,a,l;const c=t.allSeries;if(!c||0===c.length){const r=null!==(n=null===(o=t.data)||void 0===o?void 0:o.value)&&void 0!==n?n:null===(i=t.data)||void 0===i?void 0:i.y;return e.jsx("div",{className:"semiotic-tooltip",style:yn,children:e.jsx("div",{children:vn(r)})})}const u=null!==(a=null!==(r=t.xValue)&&void 0!==r?r:null===(s=t.data)||void 0===s?void 0:s.time)&&void 0!==a?a:null===(l=t.data)||void 0===l?void 0:l.x;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[null!=u&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:vn(u)}),c.map((t,o)=>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:vn(t.value)})]},o))]})}}function kn(t){if(!0!==t){if("function"==typeof t){const o=t;return t=>{var n;const i=fn(!0===(null==t?void 0:t.__semioticHoverData)||t&&void 0!==t.data&&"number"==typeof t.x&&"number"==typeof t.y&&t&&("node"===t.type||"edge"===t.type||void 0!==t.nodeOrEdge||void 0!==t.allSeries||void 0!==t.stats||void 0!==t.__chartType)?null!==(n=t.data)&&void 0!==n?n:{}:t),r=o(i);return null==r?null:e.jsx("div",{className:"semiotic-tooltip",style:yn,children:r})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?bn(t):bn())}}function wn({x:t,y:o,containerWidth:n,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(t)&&Number.isFinite(o),u=p.useRef(null),[d,h]=p.useState(null);p.useLayoutEffect(()=>{const e=u.current;if(!e)return;const t=e.getBoundingClientRect();h(e=>e&&e.width===t.width&&e.height===t.height?e:{width:t.width,height:t.height})},[s,a,n,i]);let g;g=d?`translate(${d.width+12>n-t?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-o?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*n?"calc(-100% - 12px)":"12px"}, ${.3*i>o?"4px":"calc(-100% - 4px)"})`;const f=function(e){if(!p.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const o=e.props;if("string"==typeof o.className&&o.className.trim().length>0)return!0;const n=o.style;if(n&&"object"==typeof n){if(null!=n.background&&""!==n.background)return!0;if(null!=n.backgroundColor&&""!==n.backgroundColor)return!0}return!1}(s),y=f?null:yn;return c?e.jsx("div",{ref:u,className:f?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:r.left+t,top:r.top+o,transform:g,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}function An(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const o=e;return o.addListener(t),()=>o.removeListener(t)}function jn(e,o,n){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!o&&!n)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:o}=t.contentRect;s(t=>t&&t.w===e&&t.h===o?t:{w:e,h:o})}});return t.observe(e),()=>t.disconnect()},[o,n]),[i,[o&&r?r.w:e[0],n&&r?r.h:e[1]]]}const Sn="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function Cn(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function On(e){const o=function(){const[e,o]=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 o(e.matches),An(e,e=>o(e.matches))},[]),e}(),n=t.useRef(o);n.current=o;const[i,r]=jn(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=Cn(e.foregroundGraphics,r,s),u=Cn(e.backgroundGraphics,r,s),d=R(e=>e.theme),{transition:h,introEnabled:g}=function(e,t){var o,n;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(o=window.matchMedia)||void 0===o?void 0:o.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(n=e.duration)&&void 0!==n?n:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),f="semiotic-table-"+p.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),A=t.useCallback(()=>{w.current=0;const e=k.current;k.current=null,e&&b.current(e)},[]),j=t.useCallback(e=>{k.current={clientX:e.clientX,clientY:e.clientY},0===w.current&&(w.current=requestAnimationFrame(A))},[A]),S=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 C=e.themeDirtyRef;return Sn(()=>{C&&(et++,C.current=!0,v())},[d,v,C]),{reducedMotion:o,reducedMotionRef:n,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:g,tableId:f,rafRef:y,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:j,onPointerLeave:S}}function Mn(e,t,o,n){const i=e.getContext("2d");if(!i)return null;const r=t[0]*n,s=t[1]*n,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(n,0,0,n,0,0),i.translate(o.left,o.top),i}function Pn(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function _n(e,t,o){let n=o;for(const o of t)"lesser"===o.thresholdType?o.value>e&&(n=o.color):e>o.value&&(n=o.color);return n}function Ln(e,t,o,n,i,r){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const o=t[e][0]-t[e-1][0],n=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(o*o+n*n))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=o,e.lineWidth=n,e.lineCap=r;for(let o=0;t.length-1>o;o++){const n=(s[o]+s[o+1])/2;let r=i;l>n&&(r*=n/l),l>a-n&&(r*=(a-n)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[o][0],t[o][1]),e.lineTo(t[o+1][0],t[o+1][1]),e.stroke()}}const Tn=(e,t,o,n)=>{var i,r;const a=t.filter(e=>"line"===e.type);for(const l of a){if(2>l.path.length)continue;const c=l._introClipFraction;void 0!==c&&1>c&&(e.save(),e.beginPath(),e.rect(0,0,n.width*c,n.height),e.clip());const u=l.style.stroke||"#007bff",d=rt(e,u)||u,h=l.style.strokeWidth||2,g=l.colorThresholds,f=l.rawValues;if(e.setLineDash(l.style.strokeDasharray?l.style.strokeDasharray.split(/[\s,]+/).map(Number):[]),null!=l.style.opacity&&(e.globalAlpha=l.style.opacity),e.lineWidth=h,e.lineCap=l.style.strokeLinecap||"butt",l.style._edgeFade){const v=null!==(i=l.style.opacity)&&void 0!==i?i:1;Ln(e,l.path,d,h,v,l.style.strokeLinecap||"butt"),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt";continue}const p=at(l.curve),y=g&&g.length>0&&f&&f.length===l.path.length,m=l._decayOpacities;if(m&&m.length===l.path.length&&!y){e.strokeStyle=d;const b=null!==(r=l.style.opacity)&&void 0!==r?r:1;for(let x=0;l.path.length-1>x;x++)e.globalAlpha=.5*(m[x]+m[x+1])*b,e.beginPath(),e.moveTo(l.path[x][0],l.path[x][1]),e.lineTo(l.path[x+1][0],l.path[x+1][1]),e.stroke()}else if(y){let k=null,w=null,A=null,j=null,S=!1;function C(t,o,n){e.beginPath(),e.strokeStyle=t,e.moveTo(o,n),S=!0}function O(){S&&(e.stroke(),S=!1)}for(let M=0;l.path.length>M;M++){const[P,_]=l.path[M],L=f[M],T=_n(L,g,d);if(null!==k&&null!==j&&null!==A){if(T===j)e.lineTo(P,_);else{const R=[];for(const B of g){const N=B.value;(A>N||N>L)&&(N>A||L>N)||A===N||L===N||R.push({t:(N-A)/(L-A)})}R.sort((e,t)=>e.t-t.t);for(const D of R){const E=k+(P-k)*D.t,I=w+(_-w)*D.t,H=_n(A+(L-A)*Math.min(D.t+1e-4,1),g,d);e.lineTo(E,I),O(),C(H,E,I)}e.lineTo(P,_)}k=P,w=_,A=L,j=T}else C(T,P,_),k=P,w=_,A=L,j=T}O()}else{e.beginPath();const F=l.strokeGradient&&l.path.length>=2?ut(e,l.strokeGradient,l.path[0][0],0,l.path[l.path.length-1][0],0):null;if(e.strokeStyle=F||d,p)s.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(l.path);else{const[$,W]=l.path[0];e.moveTo($,W);for(let z=1;l.path.length>z;z++)e.lineTo(l.path[z][0],l.path[z][1])}e.stroke()}if(l.style.fill&&l.style.fillOpacity&&l.style.fillOpacity>0){if(e.beginPath(),e.globalAlpha=l.style.fillOpacity,e.fillStyle=lt(e,l.style.fill,l.style.fill),p&&!y)s.line().x(e=>e[0]).y(e=>e[1]).curve(p).context(e)(l.path);else{const[Y,q]=l.path[0];e.moveTo(Y,q);for(let X=1;l.path.length>X;X++)e.lineTo(l.path[X][0],l.path[X][1])}const G=l.path[0][0];e.lineTo(l.path[l.path.length-1][0],n.height),e.lineTo(G,n.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function Rn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Bn(e,t,o=.3){Rn(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function Nn(e,t,o=.6){var n,i,r,s,a;if(!Rn(t))return;const l=null!==(n=t._pulseGlowRadius)&&void 0!==n?n: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*o,e.stroke()}function Dn(e,t,o,n=.35){Rn(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function En(e,t){const o=at(t.curve);if(!o||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1]);for(let o=t.bottomPath.length-1;o>=0;o--)e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]);e.closePath()}else{const n=s.area().x(e=>e[0]).y0((e,o)=>t.bottomPath[o][1]).y1(e=>e[1]).curve(o).context(e);e.beginPath(),n(t.topPath)}}const In=(e,t,o,n)=>{var i,r,a;const l=t.filter(e=>"area"===e.type);for(const t of l){if(2>t.topPath.length)continue;let o=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),o=!0);const l=t._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,n.width*l,n.height),e.clip());const c=lt(e,t.style.fill,"#4e79a7"),u=t._decayOpacities;if(u&&u.length===t.topPath.length){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=c;for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(u[n]+u[n+1])*o,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=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(u[o]+u[o+1]),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.stroke()}e.globalAlpha=1;continue}const d=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(En(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 n=-1/0;for(const e of t.bottomPath)e[1]>n&&(n=e[1]);const i=ct(e,t.fillGradient,"string"==typeof c?c:"#4e79a7",0,o,0,n);e.fillStyle=i||c,e.globalAlpha=d}else{const o=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=o*d,e.fillStyle=c}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(En(e,t),Dn(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=d;const o=t.strokeGradient&&t.topPath.length>=2?ut(e,t.strokeGradient,t.topPath[0][0],0,t.topPath[t.topPath.length-1][0],0):null;e.strokeStyle=o||rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const n=at(t.curve);if(e.beginPath(),n)s.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 o=1;t.topPath.length>o;o++)e.lineTo(t.topPath[o][0],t.topPath[o][1])}e.stroke()}void 0!==l&&1>l&&e.restore(),o&&e.restore(),e.globalAlpha=1}},Hn=(e,t,o,n)=>{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 o=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=o&&(e.globalAlpha=o),e.fillStyle=lt(e,t.style.fill,"#4e79a7"),e.fill(),t.style.stroke&&(e.strokeStyle=lt(e,t.style.stroke,t.style.stroke),e.lineWidth=t.style.strokeWidth||1,e.stroke()),Nn(e,t),e.globalAlpha=1}}finally{e.restore()}}};function Fn(e,t){const{x:o,y:n,w:i,h:r}=t,{tl:s,tr:a,br:l,bl:c}=Ao(t);e.beginPath(),e.moveTo(o+s,n),e.lineTo(o+i-a,n),a>0&&e.arcTo(o+i,n,o+i,n+a,a),e.lineTo(o+i,n+r-l),l>0&&e.arcTo(o+i,n+r,o+i-l,n+r,l),e.lineTo(o+c,n+r),c>0&&e.arcTo(o,n+r,o,n+r-c,c),e.lineTo(o,n+s),s>0&&e.arcTo(o,n,o+s,n,s),e.closePath()}function $n(e){switch(e.roundedEdge){case"bottom":return{x0:e.x,y0:e.y+e.h,x1:e.x,y1:e.y};case"right":return{x0:e.x+e.w,y0:e.y,x1:e.x,y1:e.y};case"left":return{x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y};default:return{x0:e.x,y0:e.y,x1:e.x,y1:e.y+e.h}}}const Wn=(e,t,o,n)=>{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)zn(e,t);else if(t.cornerRadii&&wo(t.cornerRadii)){const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=$n(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o,Fn(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else if(t.roundedTop&&t.roundedTop>0){const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=$n(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o;const r=Math.min(t.roundedTop,t.w/2,t.h/2);e.beginPath();const{x:s,y:a,w:l,h:c}=t;switch(t.roundedEdge){case"right":e.moveTo(s,a),e.lineTo(s+l-r,a),e.arcTo(s+l,a,s+l,a+r,r),e.lineTo(s+l,a+c-r),e.arcTo(s+l,a+c,s+l-r,a+c,r),e.lineTo(s,a+c);break;case"left":e.moveTo(s+l,a),e.lineTo(s+r,a),e.arcTo(s,a,s,a+r,r),e.lineTo(s,a+c-r),e.arcTo(s,a+c,s+r,a+c,r),e.lineTo(s+l,a+c);break;case"bottom":e.moveTo(s,a),e.lineTo(s+l,a),e.lineTo(s+l,a+c-r),e.arcTo(s+l,a+c,s+l-r,a+c,r),e.lineTo(s+r,a+c),e.arcTo(s,a+c,s,a+c-r,r);break;default:e.moveTo(s,a+c),e.lineTo(s,a+r),e.arcTo(s,a,s+r,a,r),e.lineTo(s+l-r,a),e.arcTo(s+l,a,s+l,a+r,r),e.lineTo(s+l,a+c)}e.closePath(),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke())}else{const o=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),n=$n(t),i=t.fillGradient&&"string"==typeof o?ct(e,t.fillGradient,o,n.x0,n.y0,n.x1,n.y1):null;e.fillStyle=i||o,e.fillRect(t.x,t.y,t.w,t.h),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.strokeRect(t.x,t.y,t.w,t.h))}Bn(e,t),e.globalAlpha=1}};function zn(e,t){const o=t.style.icon,n=t.style.iconPadding||2,i=Math.min(t.w,t.h)-n;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+n,s=t.x+(t.w-i)/2;for(let n=t.y+t.h-i;n>=t.y-i;n-=r)e.drawImage(o,s,n,i,i)}else{const r=i+n,s=t.y+(t.h-i)/2;for(let n=t.x;t.x+t.w>n;n+=r)e.drawImage(o,n,s,i,i)}e.restore()}function Gn(e){const[t,o,n]=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*o+.114*n>128?"#000":"#fff"}function Yn(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const qn=(e,t,o,n)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const o=t.style;if(null!=(null==o?void 0:o.opacity)&&(e.globalAlpha=o.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=rt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),Bn(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const o=t.valueFormat?t.valueFormat(t.value):Yn(t.value),n=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=Gn(t.fill),e.font=n+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(o,i,r)}}}finally{e.restore()}},Xn=(e,t,o,n)=>{var i,r,s;for(const o of t){if("candlestick"!==o.type)continue;const t=o;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=rt(e,t.wickColor)||t.wickColor,c=60>n.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 o=Math.max(2,Math.min(t.bodyWidth/2,.12*n.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,o,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,o,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const o=Math.min(t.openY,t.closeY),n=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=rt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,o,t.bodyWidth,Math.max(n,1))}c&&d(),e.restore()}};function Vn(e,t){if(!t)return[];const o=new Set,n=[];for(const i of e){if(!i||"object"!=typeof i)continue;const e="function"==typeof t?t(i):i[t];if(null==e)continue;const r=e+"";o.has(r)||(o.add(r),n.push(r))}return n}function Un(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function Kn(e,t,o,n){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:o,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:n,fn:t}:{key:void 0,fn:null}}function Qn(e,t,o){return n=>{if(!n||!o||!e.fn&&!t.fn)return n;let i=!1;const r=n.map(o=>{const n=e.fn&&e.key&&!(e.key in o),r=t.fn&&t.key&&!(t.key in o);if(!n&&!r)return o;i=!0;const s=Object.assign({},o);return n&&(s[e.key]=e.fn(o)),r&&(s[t.key]=t.fn(o)),s});return i?r:n}}const Zn=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Jn(e){const t=e[1]-e[0],o=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:o>t?e=>{const t=new Date(e);return`${Zn[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*o>t?e=>{const t=new Date(e);return`${Zn[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const ei={line:[In,Tn,Hn],area:[In,Hn],stackedarea:[In,Hn],scatter:[Hn],bubble:[Hn],heatmap:[qn],bar:[Wn],swarm:[Hn],waterfall:[(e,t,o,n)=>{var i;Wn(e,t);const r=t.filter(e=>"rect"===e.type);if(2>r.length)return;const s=r[0].datum,a=null==s?void 0:s._connectorStroke;if(a){e.save(),e.strokeStyle=rt(e,a)||a,e.lineWidth=null!==(i=null==s?void 0:s._connectorWidth)&&void 0!==i?i:1,e.setLineDash([]);for(let t=0;r.length-1>t;t++){const n=r[t],i=r[t+1],s=n.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=o.y(s.cumEnd),c=n.x+n.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Xn],mixed:[In,Tn,Hn],custom:[In,Wn,qn,Tn,Hn,Xn]},ti={top:20,right:20,bottom:30,left:40},oi={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 ni(e,t){const o=e.trim();if(/^#[0-9a-f]{3}$/i.test(o)){const e=o[1],n=o[2],i=o[3];return`#${e}${e}${n}${n}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(o))return`${o}${t}`;const n=o.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return n?`rgba(${n[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:o}const ii={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 ri({hover:t}){var o,n,i;const r=e=>null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+"",s=null!==(o=t.data)&&void 0!==o?o:{},a=null!==(n=s.y)&&void 0!==n?n:s.value,l=null!==(i=s.x)&&void 0!==i?i:s.time;return e.jsxs("div",{className:"semiotic-tooltip",style:ii,children:[e.jsx("div",{style:{fontWeight:600,marginBottom:2},children:r(a)}),e.jsx("div",{style:{opacity:.7,fontSize:11},children:r(l)})]})}ri.ownsChrome=!0;const si=t.forwardRef(function(o,n){var i,r,s,a,l,c,u,d,h,g,f,y,m;const{chartType:b,runtimeMode:x,data:A,chunkThreshold:j,chunkSize:C,xAccessor:O,yAccessor:M,colorAccessor:P,sizeAccessor:_,groupAccessor:L,lineDataAccessor:T,curve:R,normalize:B,baseline:N,stackOrder:D,binSize:E,valueAccessor:I,arrowOfTime:H="right",windowMode:F="sliding",windowSize:$=200,timeAccessor:W,xExtent:z,yExtent:G,extentPadding:Y=.1,scalePadding:q,sizeRange:X,size:V=[500,300],responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,lineStyle:ee,pointStyle:te,areaStyle:oe,barStyle:ne,waterfallStyle:ie,swarmStyle:re,barColors:se,colorScheme:ae,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:he,lineGradient:ge,areaGroups:fe,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,showAxes:xe=!0,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:Se,yFormat:Ce,axisExtent:Oe,tickFormatTime:Me,tickFormatValue:Pe,hoverAnnotation:_e,tooltipContent:Le,customHoverBehavior:Te,customClickBehavior:Re,enableHover:Be,hoverRadius:Ne=30,tooltipMode:Ee,annotations:Ie,svgAnnotationRules:He,showGrid:Fe,legend:$e,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendLayout:Ue,legendCategoryAccessor:Ke,onCategoriesChange:Qe,backgroundGraphics:Ze,foregroundGraphics:Je,canvasPreRenderers:et,svgPreRenderers:tt,title:ot,categoryAccessor:nt,brush:it,onBrush:st,decay:at,pulse:lt,transition:ct,animate:ut,staleness:dt,heatmapAggregation:pt,heatmapXBins:yt,heatmapYBins:mt,showValues:vt,heatmapValueFormat:bt,marginalGraphics:xt,pointIdAccessor:kt,xScaleType:Ct,yScaleType:Ot,accessibleTable:_t=!0,description:Lt,summary:Tt,linkedCrosshairName:Rt,linkedCrosshairSourceId:Bt,customLayout:Nt,layoutConfig:Dt}=o,Et=t.useId().replace(/:/g,""),It=t.useRef(!1),Ht=On({sizeProp:V,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:ti,animate:ut,transitionProp:ct,themeDirtyRef:It}),Ft=To(),$t=Do(),{reducedMotionRef:Wt,responsiveRef:zt,size:Gt,currentTheme:Yt,transition:qt,introEnabled:Xt,tableId:Vt,rafRef:Ut,renderFnRef:Kt,scheduleRender:Qt}=Ht;let Zt=Ht.margin;if(xt){const e=60,t=Object.assign({},Ht.margin);xt.top&&e>t.top&&(t.top=e),xt.bottom&&e>t.bottom&&(t.bottom=e),xt.left&&e>t.left&&(t.left=e),xt.right&&e>t.right&&(t.right=e),Zt=t}const Jt="function"==typeof Je?Je({size:Gt,margin:Zt}):Je,eo="function"==typeof Ze?Ze({size:Gt,margin:Zt}):Ze,to=Gt[0]-Zt.left-Zt.right,oo=Gt[1]-Zt.top-Zt.bottom,no=t.useMemo(()=>v(A),[A]),io=null!=_e?_e:Be,ro=t.useRef(null),so=t.useRef(null),[ao,lo]=t.useState(0),[co,uo]=t.useState(null),ho=t.useRef(null),go=t.useRef(null),[fo,po]=t.useState(null),yo=t.useRef(oi.primary),mo=t.useRef([]),bo=t.useRef(Ke),xo=t.useRef(Qe);bo.current=Ke,xo.current=Qe;const[wo,Ao]=t.useState(!1),[jo,So]=t.useState([]),[Co,Oo]=t.useState([]),Po="streaming"===x||["bar","swarm","waterfall"].includes(b),Lo=t.useMemo(()=>{var e,t,o;return{chartType:b,runtimeMode:Po?"streaming":"bounded",windowSize:$,windowMode:F,arrowOfTime:Po?H:"right",extentPadding:Y,scalePadding:q,axisExtent:Oe,xAccessor:O,yAccessor:M,timeAccessor:Po?W:void 0,valueAccessor:I,colorAccessor:P,sizeAccessor:_,groupAccessor:L||(T?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:T,xScaleType:Ct,yScaleType:Ot,xExtent:z,yExtent:G,sizeRange:X,binSize:E,normalize:B,baseline:N,stackOrder:D,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:!0===he?{topOpacity:.8,bottomOpacity:.05}:!1===he?void 0:he,areaGroups:fe?new Set(fe):void 0,lineGradient:ge,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,lineStyle:ee,pointStyle:te,areaStyle:oe,swarmStyle:re,waterfallStyle:ie,colorScheme:ae,barColors:se,barStyle:ne,annotations:Ie,decay:at,pulse:lt,transition:qt,introAnimation:Xt,staleness:dt,heatmapAggregation:pt,heatmapXBins:yt,heatmapYBins:mt,showValues:vt,heatmapValueFormat:bt,pointIdAccessor:kt,curve:R,themeCategorical:null===(e=null==Yt?void 0:Yt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(Yt),themeSequential:null===(t=null==Yt?void 0:Yt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==Yt?void 0:Yt.colors)||void 0===o?void 0:o.diverging,customLayout:Nt,layoutConfig:Dt,layoutMargin:Zt}},[b,$,F,H,Y,q,Oe,O,M,W,I,Ct,Ot,P,_,L,nt,T,z,G,X,E,B,N,D,le,ce,ue,de,he,ge,fe,pe,ye,me,ve,be,ee,te,oe,re,ie,ne,ae,se,Ie,at,lt,null==qt?void 0:qt.duration,null==qt?void 0:qt.easing,Xt,dt,pt,yt,mt,vt,bt,Po,kt,R,Yt,Nt,Dt,Zt]),Ro=Io(Lo),Bo=t.useRef(null);Bo.current||(Bo.current=new Ge(Ro));const No=t.useCallback(()=>{var e,t;const o=bo.current,n=xo.current;if(!n||!o)return;const i=Vn(null!==(t=null===(e=Bo.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],o);Un(i,mo.current)||(mo.current=i,n(i))},[]);t.useEffect(()=>{var e;null===(e=Bo.current)||void 0===e||e.updateConfig(Ro),It.current=!0,Qt()},[Ro,Qt]);const Ho=t.useRef(null);Ho.current||(Ho.current=new w(e=>{const t=Bo.current;t&&t.ingest(e)&&(It.current=!0,Qt())},{chunkThreshold:j,chunkSize:C})),t.useEffect(()=>{var e;null===(e=Ho.current)||void 0===e||e.updateChunkOptions({chunkThreshold:j,chunkSize:C})},[j,C]);const Fo=t.useCallback(e=>{var t;null===(t=Ho.current)||void 0===t||t.push(e)},[]),$o=t.useCallback(e=>{var t;null===(t=Ho.current)||void 0===t||t.pushMany(e)},[]),Wo=t.useCallback(()=>{var e,t;null===(e=Ho.current)||void 0===e||e.clear(),null===(t=Bo.current)||void 0===t||t.clear(),It.current=!0,Qt()},[Qt]);t.useImperativeHandle(n,()=>({push:Fo,pushMany:$o,remove:e=>{var t,o,n;null===(t=Ho.current)||void 0===t||t.flush();const i=null!==(n=null===(o=Bo.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];return i.length>0&&(ho.current&&i.some(e=>{var t;return e===(null===(t=ho.current)||void 0===t?void 0:t.data)})&&(ho.current=null,po(null)),It.current=!0,Qt()),i},update:(e,t)=>{var o,n,i;null===(o=Ho.current)||void 0===o||o.flush();const r=null!==(i=null===(n=Bo.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(It.current=!0,Qt()),r},clear:Wo,getData:()=>{var e,t,o;return null===(e=Ho.current)||void 0===e||e.flush(),null!==(o=null===(t=Bo.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Bo.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=Bo.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Fo,$o,Wo,Qt]),t.useEffect(()=>{var e,t;if(A){if(T&&no.length>0&&"object"==typeof no[0]&&null!==no[0]){const t="string"==typeof T?T:"coordinates";if(Array.isArray(no[0][t])){const o=[];for(const e of no){const n=e[t];if(Array.isArray(n)){const t=e.label||e.id||e.key;if(null!=t)for(const e of n)o.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of n)o.push(e)}}return void(null===(e=Ho.current)||void 0===e||e.setBoundedData(o))}}null===(t=Ho.current)||void 0===t||t.setBoundedData(no)}},[A,no,T]);const{hoverHandlerRef:zo,hoverLeaveRef:Go,onPointerMove:Yo,onPointerLeave:Xo}=Ht;zo.current=e=>{var t,o;if(!io)return;const n=ro.current;if(!n)return;const i=n.getBoundingClientRect(),r=e.clientX-i.left-Zt.left,s=e.clientY-i.top-Zt.top;if(0>r||r>to||0>s||s>oo)return void(ho.current&&(ho.current=null,go.current=null,po(null),Te&&(Te(null),It.current=!0),Qt()));const a=Bo.current;if(!a||0===a.scene.length)return;const l=gt(a.scene,r,s,Ne,a.quadtree,a.maxPointRadius),c="multi"===Ee,u=()=>{ho.current&&(ho.current=null,go.current=null,po(null),Te&&Te(null),Qt())};if(!l&&!c)return void u();const d=c||!l?r:l.x,h=c||!l?s:l.y;let g=pn((null==l?void 0:l.datum)?De(l.datum,a.resolvedRibbons):{},d,h);if(c&&a.scene.length>0&&a.scales){const e=function(e,t,o=30){const n=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=ft(ht(e.path,e.curve),t,o);if(null===r)continue;const s=wt(e.path,t);n.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=ht(e.topPath,e.curve),s=ht(e.bottomPath,e.curve),a=ft(r,t,o);if(null===a)continue;const l=ft(s,t,o),c=wt(e.topPath,t);n.push({node:i,datum:Array.isArray(e.datum)&&e.datum[c]?e.datum[c]:e.datum,x:e.topPath[c][0],y:a,y0:null!=l?l:void 0,group:e.group,color:"string"==typeof e.style.stroke?e.style.stroke:"string"==typeof e.style.fill?e.style.fill:void 0})}return n}(a.scene,d,Math.max(Ne,to));if(e.length>0){const t=a.scales.y.invert,o=a.scales.x.invert,n=yo.current,i=o?o(d):d;if(l)g.xValue=i,g.xPx=d;else{const e={xValue:i};"string"==typeof O&&(e[O]=i),g=pn(e,d,h,{xValue:i,xPx:d})}g.allSeries=e.map(e=>{const o=t?t(e.y):e.y,i=null!=e.y0?t?t(e.y0):e.y0:void 0;return{group:e.group||"",value:"stackedarea"===b&&null!=i?o-i:o,valuePx:e.y,color:e.color||n,datum:De(e.datum,a.resolvedRibbons)}})}}l||(null===(t=g.allSeries)||void 0===t?void 0:t.length)?(ho.current=g,go.current=null!==(o=null==l?void 0:l.node)&&void 0!==o?o:null,po(g),Te&&(Te(g),It.current=!0),Qt()):u()},Go.current=()=>{ho.current&&(ho.current=null,go.current=null,po(null),Te&&(Te(null),It.current=!0),Qt())};const Vo=t.useRef(()=>{});Vo.current=e=>{if(!Re)return;const t=ro.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-Zt.left,i=e.clientY-o.top-Zt.top;if(0>n||n>to||0>i||i>oo)return void Re(null);const r=Bo.current;if(!r||0===r.scene.length)return void Re(null);const s=gt(r.scene,n,i,Ne,r.quadtree,r.maxPointRadius);Re(s?pn(s.datum||{},s.x,s.y):null)};const Uo=t.useCallback(e=>Vo.current(e),[]),Ko=t.useRef(-1),Qo=t.useRef(null),Zo=t.useRef(null),Jo=t.useCallback(e=>{const t=Bo.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(Zo.current&&Zo.current.version===o)n=Zo.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)switch(r.type){case"point":i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});break;case"line":{const e=r,o=Array.isArray(e.datum)?e.datum:[],n=null!==(t=e.group)&&void 0!==t?t:"_default";for(let t=0;e.path.length>t&&o.length>t;t++)i.push({x:e.path[t][0],y:e.path[t][1],datum:o[t],shape:"circle",group:n});break}case"area":{const e=r,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:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(n=r.group)&&void 0!==n?n:"_default"});break;case"heatcell":i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=At(e),Zo.current={version:o,graph:n}}const i=Ko.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),Ko.current=0;const o=n.flat[0];Qo.current={shape:o.shape,w:o.w,h:o.h};const i=Mt(Object.assign(Object.assign({},o),{datum:De(o.datum,t.resolvedRibbons)}));return ho.current=i,po(i),Te&&Te(i),void Qt()}const r=jt(n,i),s=St(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return Ko.current=-1,Qo.current=null,ho.current=null,go.current=null,po(null),Te&&Te(null),void Qt();Ko.current=s;const a=n.flat[s];Qo.current={shape:a.shape,w:a.w,h:a.h};const l=Mt(Object.assign(Object.assign({},a),{datum:De(a.datum,t.resolvedRibbons)}));ho.current=l,po(l),Te&&Te(l),Qt()},[Te,Qt]),en=t.useCallback(e=>{Ko.current=-1,Qo.current=null,Yo(e)},[Yo]);Kt.current=()=>{var e,t;Ut.current=0;const o=ro.current,n=so.current;if(!o||!n)return;const i=Bo.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(Wt.current?r+1e6:r),a=!Wt.current&&s,l=It.current||s;l&&!a&&(i.computeScene({width:to,height:oo}),No());const c=Pn(),u=function(e){if(!e)return oi;const t=getComputedStyle(e),o=t.getPropertyValue("--semiotic-border").trim(),n=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=n||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=o||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||o||r?{axisStroke:l||oi.axisStroke,tickText:s||oi.tickText,crosshair:s?ni(s,"66"):oi.crosshair,hoverFill:c?ni(c,"4D"):oi.hoverFill,hoverStroke:s?ni(s,"99"):oi.hoverStroke,pointRing:c||oi.pointRing,primary:r||oi.primary}:oi}(o);yo.current=u.primary;const d=null!==(e=null==dt?void 0:dt.threshold)&&void 0!==e?e:5e3,h=dt&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=Mn(o,Gt,Zt,c);if(e){if(e.clearRect(-Zt.left,-Zt.top,Gt[0],Gt[1]),h&&(e.globalAlpha=null!==(t=null==dt?void 0:dt.dimOpacity)&&void 0!==t?t:.5),"transparent"!==J&&!Ze){const t=getComputedStyle(o).getPropertyValue("--semiotic-bg").trim(),n=J||(t&&"transparent"!==t?t:null),i=n?rt(e,n):null;i&&(e.fillStyle=i,e.fillRect(-Zt.left,-Zt.top,Gt[0],Gt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,to,oo),e.clip()),et&&i.scales)for(const t of et)e.save(),t(e,i.scene,i.scales,{width:to,height:oo}),e.restore();const n=Nt?ei.custom:ei[b];if(n&&i.scales)for(const t of n)t(e,i.scene,i.scales,{width:to,height:oo});e.restore(),h&&(e.globalAlpha=1)}}{const e=Mn(n,Gt,Zt,c);if(e&&(e.clearRect(-Zt.left,-Zt.top,Gt[0],Gt[1]),io&&ho.current&&i.scales&&function(e,t,o,n,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,n),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(o,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 o=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 o="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||o||null:o||t.stroke||null}(r)||s.primary;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,ho.current,to,oo,"object"==typeof io?io:{},go.current,u),go.current&&Array.isArray(_e))){const t=_e.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,o,n,i){var r;if(!o)return;const s="group"in o?o.group:void 0;if(void 0!==s)for(const o of t){if("line"!==o.type)continue;if(o.group!==s)continue;if(2>o.path.length)continue;const t="function"==typeof n.style?o.datum?n.style(o.datum):{}:n.style||{};e.save(),e.beginPath(),e.moveTo(o.path[0][0],o.path[0][1]);for(let t=1;o.path.length>t;t++)e.lineTo(o.path[t][0],o.path[t][1]);e.strokeStyle=t.stroke||o.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(o.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,go.current,t,u)}}l&&o&&o.setAttribute("aria-label",qo(i.scene,b+" chart"));const g=It.current;if(It.current=!1,g&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!co||e(co.x.domain()[0])!==e(i.scales.x.domain()[0])||e(co.x.domain()[1])!==e(i.scales.x.domain()[1])||e(co.y.domain()[0])!==e(i.scales.y.domain()[0])||e(co.y.domain()[1])!==e(i.scales.y.domain()[1])||co.x.range()[0]!==i.scales.x.range()[0]||co.x.range()[1]!==i.scales.x.range()[1]||co.y.range()[0]!==i.scales.y.range()[0]||co.y.range()[1]!==i.scales.y.range()[1])&&uo(i.scales),xt){const e=i.getData(),t="function"==typeof O?O:e=>e[O||"x"],o="function"==typeof M?M:e=>e[M||"y"];So(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Oo(e.map(e=>o(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}g&&Ie&&Ie.length>0&&lo(e=>e+1),(null==dt?void 0:dt.showBadge)&&Ao(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Ut.current=requestAnimationFrame(()=>Kt.current()))},Eo({hydrated:Ft,wasHydratingFromSSR:$t,storeRef:Bo,dirtyRef:It,renderFnRef:Kt,cleanup:()=>{var e;return null===(e=Ho.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{It.current=!0,Qt()},[b,to,oo,xe,J,ee,et,Qt]),Pt(dt,Bo,It,Qt,wo,Ao);const tn=t.useMemo(()=>{if(Se||Me)return;const e=Bo.current;return(null==e?void 0:e.xIsDate)&&co?Jn(co.x.domain()):void 0},[Se,Me,co]),on=Se||Me||tn,nn=io&&fo?Le?Le(fo):e.jsx(ri,{hover:fo}):null,rn=nn?e.jsx(wn,{x:fo.x,y:fo.y,containerWidth:to,containerHeight:oo,margin:Zt,className:"stream-frame-tooltip",children:nn}):null,sn=Qo.current,ln=e.jsx(gn,{active:Ko.current>=0,hoverPoint:fo,margin:Zt,size:Gt,shape:null==sn?void 0:sn.shape,width:null==sn?void 0:sn.w,height:null==sn?void 0:sn.h}),hn=Kn(O,W,"__semiotic_resolvedX","__semiotic_resolvedTime"),fn=Kn(M,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),yn=hn.key,mn=fn.key,vn=Qn(hn,fn,Ie&&Ie.length>0||!1);if(_o||!Ft&&$t){const t=Bo.current;t&&A&&(t.ingest({inserts:no,bounded:!0}),t.computeScene({width:to,height:oo}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,a=on||(()=>{if((null==t?void 0:t.xIsDate)&&n)return Jn(n.x.domain())})();return e.jsxs("div",{ref:zt,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":Lt||("string"==typeof ot?ot:"XY chart"),style:{position:"relative",width:U?"100%":Gt[0],height:K?"100%":Gt[1]},children:[e.jsx(cn,{summary:Tt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Gt[0],height:Gt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Zt.left},${Zt.top})`,children:eo}),e.jsxs("g",{transform:`translate(${Zt.left},${Zt.top})`,children:[J&&e.jsx("rect",{x:0,y:0,width:to,height:oo,fill:J}),tt&&n&&tt.map((t,i)=>e.jsx(p.Fragment,{children:t(o,n,{width:to,height:oo})},"svgpre-"+i)),o.map((t,o)=>function(t,o,n){var i,r,s,a,l;switch(t.type){case"line":{const n=t;if(0===n.path.length)return null;const i="M"+n.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:n.style.stroke||"#4e79a7",strokeWidth:n.style.strokeWidth||2,strokeDasharray:n.style.strokeDasharray,opacity:n.style.opacity},"line-"+o)}case"area":{const l=t;if(0===l.topPath.length)return null;const c=`M${l.topPath.map(([e,t])=>`${e},${t}`).join("L")}L${[...l.bottomPath].reverse().map(([e,t])=>`${e},${t}`).join("L")}Z`;if(l.clipRect){const t=`${n?n+"-":""}area-clip-${o}`;return e.jsxs("g",{children:[e.jsx("defs",{children:e.jsx("clipPath",{id:t,children:e.jsx("rect",{x:l.clipRect.x,y:l.clipRect.y,width:l.clipRect.width,height:l.clipRect.height})})}),e.jsx("path",{d:c,fill:Mo(l.style.fill),fillOpacity:null!==(r=null!==(i=l.style.fillOpacity)&&void 0!==i?i:l.style.opacity)&&void 0!==r?r:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth,clipPath:`url(#${t})`})]},"area-"+o)}return e.jsx("path",{d:c,fill:Mo(l.style.fill),fillOpacity:null!==(a=null!==(s=l.style.fillOpacity)&&void 0!==s?s:l.style.opacity)&&void 0!==a?a:.7,stroke:l.style.stroke,strokeWidth:l.style.strokeWidth},"area-"+o)}case"point":{const n=t;return e.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:Mo(n.style.fill),opacity:null!==(l=n.style.opacity)&&void 0!==l?l:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"point-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Mo(n.style.fill),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},"rect-"+o)}case"heatcell":{const n=t;if(n.showValues&&null!=n.value&&n.w>=20&&n.h>=20){const t=n.valueFormat?n.valueFormat(n.value):Number.isInteger(n.value)?n.value+"":100>Math.abs(n.value)?1>Math.abs(n.value)?n.value.toPrecision(3):n.value.toFixed(1):n.value.toFixed(0),[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]}(n.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(n.w,n.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill}),e.jsx("text",{x:n.x+n.w/2,y:n.y+n.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+o)}return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:n.fill},"heatcell-"+o)}case"candlestick":{const n=t,i=Math.min(n.openY,n.closeY),r=Math.max(Math.abs(n.openY-n.closeY),1),s=n.isUp?n.upColor:n.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:n.x,y1:n.highY,x2:n.x,y2:n.lowY,stroke:n.wickColor,strokeWidth:n.wickWidth}),e.jsx("rect",{x:n.x-n.bodyWidth/2,y:i,width:n.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+o)}default:return null}}(t,o,Et)).filter(Boolean)]})]}),e.jsx(ko,{width:to,height:oo,totalWidth:Gt[0],totalHeight:Gt[1],margin:Zt,scales:n,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:a,yFormat:Ce||Pe,axisExtent:Oe,showGrid:Fe,title:ot,legend:$e,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendLayout:Ue,foregroundGraphics:Ye(Jt,null===(s=Bo.current)||void 0===s?void 0:s.customLayoutOverlays),marginalGraphics:xt,xValues:[],yValues:[],annotations:Ie,svgAnnotationRules:He,annotationFrame:0,xAccessor:yn,yAccessor:mn,annotationData:vn(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof R?R:void 0,linkedCrosshairName:Rt,linkedCrosshairSourceId:Bt})]})}return e.jsxs("div",{ref:zt,className:"stream-xy-frame"+(Z?" "+Z:""),role:"group","aria-label":Lt||("string"==typeof ot?ot:"XY chart"),tabIndex:0,style:{position:"relative",width:U?"100%":Gt[0],height:K?"100%":Gt[1],overflow:"visible"},onKeyDown:Jo,children:[_t&&e.jsx(un,{tableId:Vt}),_t&&e.jsx(an,{scene:null!==(l=null===(a=Bo.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:b+" chart",tableId:Vt,chartTitle:"string"==typeof ot?ot:void 0}),e.jsx(cn,{summary:Tt}),e.jsxs("div",{role:"img","aria-label":Lt||("string"==typeof ot?ot:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:io?en:void 0,onMouseLeave:io?Xo:void 0,onClick:Re?Uo:void 0,children:[eo&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Gt[0],height:Gt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Zt.left},${Zt.top})`,children:eo})}),e.jsx(vo,{width:to,height:oo,totalWidth:Gt[0],totalHeight:Gt[1],margin:Zt,scales:co,showAxes:xe,axes:ke,showGrid:Fe,xFormat:on,yFormat:Ce||Pe,axisExtent:Oe}),e.jsx("canvas",{ref:ro,"aria-label":qo(null!==(u=null===(c=Bo.current)||void 0===c?void 0:c.scene)&&void 0!==u?u:[],b+" chart"),style:{position:"absolute",left:0,top:0}}),e.jsx("canvas",{ref:so,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(dn,{hoverPoint:fo}),e.jsx(ko,{width:to,height:oo,totalWidth:Gt[0],totalHeight:Gt[1],margin:Zt,scales:co,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:on,yFormat:Ce||Pe,axisExtent:Oe,showGrid:Fe,title:ot,legend:$e,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendLayout:Ue,foregroundGraphics:Ye(Jt,null===(d=Bo.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:xt,xValues:jo,yValues:Co,annotations:Ie,svgAnnotationRules:He,annotationFrame:ao,xAccessor:yn,yAccessor:mn,annotationData:vn(null===(h=Bo.current)||void 0===h?void 0:h.getData()),pointNodes:null===(g=Bo.current)||void 0===g?void 0:g.scene.filter(e=>"point"===e.type),curve:"string"==typeof R?R:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==J&&!Ze,linkedCrosshairName:Rt,linkedCrosshairSourceId:Bt}),(it||st)&&e.jsx(k,{width:to,height:oo,totalWidth:Gt[0],totalHeight:Gt[1],margin:Zt,dimension:null!==(f=null==it?void 0:it.dimension)&&void 0!==f?f:"xy",scales:co,onBrush:null!=st?st:()=>{},binSize:E,snap:null==it?void 0:it.snap,binBoundaries:null!==(y=null==it?void 0:it.binBoundaries)&&void 0!==y?y:"bar"===b?null===(m=Bo.current)||void 0===m?void 0:m.getBinBoundaries():void 0,snapDuring:null==it?void 0:it.snapDuring,streaming:"streaming"===x}),(null==dt?void 0:dt.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===dt.badgePosition?{top:4,left:4}:"bottom-left"===dt.badgePosition?{bottom:4,left:4}:"bottom-right"===dt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:wo?"#dc3545":"#28a745",color:"white"}),children:wo?"STALE":"LIVE"}),ln,rn]})]})});si.displayName="StreamXYFrame";const ai=t.createContext(null);function li({colors:o,categories:n,colorScheme:i="category10",children:r}){const s=t.useMemo(()=>{if(o)return o;if(n){const e=Array.isArray(i)?i:ye[i]||me,t={};for(let o=0;n.length>o;o++)t[n[o]]=e[o%e.length];return t}return{}},[o,n,i]);return e.jsx(ai.Provider,{value:s,children:r})}function ci(){return t.useContext(ai)}function ui(e){const t=[];for(const[o,n]of Object.entries(e.fields))if("point"===n.type)t.push(e=>n.values.has(e[o]));else{const[e,i]=n.range;t.push(t=>{const n=t[o];return n>=e&&i>=n})}return e=>t.every(t=>t(e))}function di(e,t){const o=[];for(const[n,i]of e.clauses)"crossfilter"===e.resolution&&n===t||o.push(ui(i));return 0===o.length?()=>!0:"intersect"===e.resolution?e=>o.every(t=>t(e)):e=>o.some(t=>t(e))}function hi(e,t){let o=e.get(t);return o||(o={name:t,resolution:"union",clauses:new Map},e.set(t,o)),o}li.displayName="CategoryColorProvider";const[gi,fi]=A(e=>({selections:new Map,setClause(t,o){e(e=>{const n=new Map(e.selections),i=hi(n,t),r=new Map(i.clauses);return r.set(o.clientId,o),n.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:n}})},clearClause(t,o){e(e=>{const n=e.selections.get(t);if(!n)return{};const i=new Map(e.selections),r=new Map(n.clauses);return r.delete(o),i.set(t,Object.assign(Object.assign({},n),{clauses:r})),{selections:i}})},setResolution(t,o){e(e=>{const n=new Map(e.selections),i=hi(n,t);return n.set(t,Object.assign(Object.assign({},i),{resolution:o})),{selections:n}})},clearSelection(t){e(e=>{const o=new Map(e.selections),n=o.get(t);return n&&o.set(t,Object.assign(Object.assign({},n),{clauses:new Map})),{selections:o}})}})),[pi,yi]=A(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const o=e.observations;return o.push(t),o.length>e.maxObservations&&o.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function mi(e){const o=t.useId(),n=e.clientId||o,{name:i}=e,r=fi(e=>e.selections.get(i)),s=fi(e=>e.setClause),a=fi(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?di(r,n):()=>!0,[r,n]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"point",values:new Set(n)};s(i,{clientId:n,type:"point",fields:t})},[n,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[o,n]of Object.entries(e))t[o]={type:"interval",range:n};s(i,{clientId:n,type:"interval",fields:t})},[n,i,s]),clear:t.useCallback(()=>{a(i,n)},[a,i,n]),clientId:n}}function vi(e){const o=e.name||"hover",{fields:n}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=mi({name:o});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const o of n){const n=e[o];void 0!==n&&(t[o]=[n])}Object.keys(t).length>0&&s(t)},[n,s,a,o]),predicate:i,isActive:r}}function bi(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function xi(e){const{name:o,xField:n,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=mi({name:o}),c=n&&i?"xyBrush":n?"xBrush":"yBrush",u=t.useCallback(e=>{if(!e)return void l();const t={};"xyBrush"===c&&function(e){return 2===e.length&&Array.isArray(e[0])&&2===e[0].length&&Array.isArray(e[1])&&2===e[1].length}(e)?(n&&(t[n]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&bi(e)?n&&(t[n]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&bi(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,n,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}function ki(e={}){const{limit:o=50,types:n,chartId:i}=e,r=yi(e=>e.version),s=yi(e=>e.observations),a=yi(e=>e.clearObservations),l=t.useMemo(()=>{let e=s;if(n&&n.length>0){const t=new Set(n);e=e.filter(e=>t.has(e.type))}return i&&(e=e.filter(e=>e.chartId===i)),e.length>o&&(e=e.slice(e.length-o)),e},[s,n,i,o,r]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:a}}const wi=t.createContext(!1),Ai=t.createContext(null),ji="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function Si(e){const t=new Set,o=[];for(const n of e)t.has(n)||(t.add(n),o.push(n));return o}function Ci(e,t){if(e.length!==t.length)return!1;for(let o=0;e.length>o;o++)if(e[o]!==t[o])return!1;return!0}function Oi(e){const o=t.useContext(Ai),n=t.useId(),i=Si(e),r=t.useRef([]);Ci(r.current,i)||(r.current=i);const s=r.current;ji(()=>{if(o)return()=>o.unregisterCategories(n)},[o,n]),ji(()=>{o&&o.registerCategories(n,s)},[o,n,s])}function Mi({selections:e}){const o=fi(e=>e.setResolution);return t.useEffect(()=>{for(const[t,n]of Object.entries(e))n.resolution&&o(t,n.resolution)},[e,o]),null}function Pi({categoryColors:o,interaction:n,selectionName:i,field:r}){const s=Object.entries(o),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=vi({name:i,fields:[r]}),u=mi({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[g,f]=t.useState(null),p=t.useRef(u.selectPoints);p.current=u.selectPoints;const y=t.useRef(u.clear);y.current=u.clear,t.useEffect(()=>{"isolate"===n&&(d.size>0?p.current({[r]:Array.from(d)}):y.current())},[n,d,r]);const m=t.useCallback(e=>{"highlight"===n&&(e?(f(e.label),c.onHover({[r]:e.label})):(f(null),c.onHover(null)))},[n,r,c]),v=t.useCallback(e=>{"isolate"===n&&h(t=>{const o=new Set(t);return o.has(e.label)?o.delete(e.label):o.add(e.label),o.size===a.length?new Set:o})},[n,a.length]),[b,[x]]=jn([0,0],!0,!1),k=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let o=0,n=1;for(const i of e){const e=26+7*i.length;o>0&&o+e>t&&(n++,o=0),o+=e}return n}(s.map(([e])=>e),x),[s,x]);return 0===s.length?null: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(Dt,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===n?m:void 0,customClickBehavior:"isolate"===n?v:void 0,highlightedCategory:g,isolatedCategories:d})})})}function _i({children:o,selections:n,showLegend:i,legendPosition:r="top",legendInteraction:s="none",legendSelectionName:a="legend",legendField:l="category"}){const c=ci(),[u,d]=t.useState({}),h=t.useRef({}),g=t.useMemo(()=>({registerCategories:(e,t)=>{const o=Si(t);d(t=>{var n;return Ci(null!==(n=t[e])&&void 0!==n?n:[],o)?t:Object.assign(Object.assign({},t),{[e]:o})})},unregisterCategories:e=>{d(t=>{if(!(e in t))return t;const o=Object.assign({},t);return delete o[e],o})}}),[]),f=t.useMemo(()=>{const e=[];for(const t of Object.values(u))for(const o of t)e.push(o);return Si(e)},[u]),p=t.useMemo(()=>{var e;const t=null!=c?c:{},o=h.current;let n=Object.keys(t).length+Object.keys(o).length;for(const e of f)t[e]||o[e]||(o[e]=me[n%me.length],n++);const i=Object.assign({},t);for(const n of f)i[n]=null!==(e=t[n])&&void 0!==e?e:o[n];return i},[c,f]),y=void 0===i||i,m=y&&Object.keys(p).length>0;return e.jsx(gi,{children:e.jsxs(pi,{children:[n&&e.jsx(Mi,{selections:n}),e.jsx(Ai.Provider,{value:g,children:e.jsx(li,{colors:p,children:e.jsxs(wi.Provider,{value:m,children:[y&&"top"===r&&e.jsx(Pi,{categoryColors:p,interaction:s,selectionName:a,field:l}),o,y&&"bottom"===r&&e.jsx(Pi,{categoryColors:p,interaction:s,selectionName:a,field:l})]})})})]})})}function Li({data:e,colorBy:t,colorScale:o,getColor:n,strokeColor:i,strokeWidth:r,categories:s}){const a=(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?n(s,t,o):o?o(i):ve[r%ve.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",o={fill:t,stroke:t};return void 0!==i&&(o.stroke=i),void 0!==r&&(o.strokeWidth=r),o},type:"fill",items:a,label:""}]}}function Ti(e){return e?"string"==typeof e?{name:e}:e:null}function Ri(e,t,o){return t?(n,...i)=>{var r;const s=Object.assign({},e(n,...i));if(t.isActive)if(t.predicate(n))(null==o?void 0:o.selectedStyle)&&Object.assign(s,o.selectedStyle);else{const e=null!==(r=null==o?void 0:o.unselectedOpacity)&&void 0!==r?r:.5;s.opacity=e,s.fillOpacity=e,s.strokeOpacity=e,(null==o?void 0:o.unselectedStyle)&&Object.assign(s,o.unselectedStyle)}return s}:e}const Bi={light:M,dark:P,"high-contrast":_,pastels:{mode:"light",colors:{primary:"#c9a0dc",secondary:"#b8a8c8",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#fdf6f0",surface:"#fff5ee",text:"#4a3728",textSecondary:"#8b7355",grid:"#e8d5c4",border:"#e8d5c4",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#9ad4a3",danger:"#e8869a",warning:"#f0c888",error:"#c86070",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#7f8c9b",grid:"#d8dce3",border:"#d8dce3",focus:"#2563eb",annotation:"#2563eb",success:"#10b981",danger:"#ef4444",warning:"#f59e0b",error:"#dc2626",info:"#2563eb"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#e45050",success:"#2d7a3d",danger:"#c8303a",warning:"#d4a843",error:"#a02028",info:"#3a86c8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:18,labelSize:12,tickSize:10,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:10},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function Ni(e){return Bi[e]}const Di=p.createContext(void 0),Ei="undefined"==typeof window?p.useEffect:p.useLayoutEffect;function Ii(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return Ni(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function Hi({theme:e}){const t=R(e=>e.setTheme),o=R(e=>e.theme),n=p.useRef(o);n.current=o;const i=p.useRef(null);p.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const o=window.matchMedia("(forced-colors: active)");return o.matches&&(i.current=n.current===_?M:n.current,t("high-contrast")),An(o,e=>{var o,r;e.matches?(i.current=n.current===_?null!==(o=i.current)&&void 0!==o?o:M:n.current,t("high-contrast")):(function(e,t){e(t===M?"light":t===P?"dark":t===_?"high-contrast":t)}(t,null!==(r=i.current)&&void 0!==r?r:M),i.current=null)})},[e,t]);const r=p.useRef(!1);return Ei(()=>{r.current?void 0!==e&&t(Ii(e)):r.current=!0},[e,t]),null}function Fi({children:t}){var o,n,i,r,s;const a=R(e=>e.theme),l=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({position:"relative","--semiotic-bg":a.colors.background,"--semiotic-text":a.colors.text,"--semiotic-text-secondary":a.colors.textSecondary,"--semiotic-grid":a.colors.grid,"--semiotic-border":a.colors.border,"--semiotic-cell-border":a.colors.cellBorder||a.colors.border,"--semiotic-primary":a.colors.primary,"--semiotic-font-family":a.typography.fontFamily},a.colors.focus?{"--semiotic-focus":a.colors.focus}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(n=a.tooltip)||void 0===n?void 0:n.text)?{"--semiotic-tooltip-text":a.tooltip.text}:{}),(null===(i=a.tooltip)||void 0===i?void 0:i.borderRadius)?{"--semiotic-tooltip-radius":a.tooltip.borderRadius}:{}),(null===(r=a.tooltip)||void 0===r?void 0:r.fontSize)?{"--semiotic-tooltip-font-size":a.tooltip.fontSize}:{}),(null===(s=a.tooltip)||void 0===s?void 0:s.shadow)?{"--semiotic-tooltip-shadow":a.tooltip.shadow}:{}),a.borderRadius?{"--semiotic-border-radius":a.borderRadius}:{}),a.colors.selection?{"--semiotic-selection-color":a.colors.selection}:{}),null!=a.colors.selectionOpacity?{"--semiotic-selection-opacity":a.colors.selectionOpacity+""}:{}),a.colors.diverging?{"--semiotic-diverging":a.colors.diverging}:{}),a.colors.annotation?{"--semiotic-annotation-color":a.colors.annotation}:{}),null!=a.typography.legendSize?{"--semiotic-legend-font-size":a.typography.legendSize+"px"}:{}),null!=a.typography.titleFontSize?{"--semiotic-title-font-size":a.typography.titleFontSize+"px"}:{}),null!=a.typography.tickFontFamily?{"--semiotic-tick-font-family":a.typography.tickFontFamily}:{}),null!=a.typography.tickSize?{"--semiotic-tick-font-size":a.typography.tickSize+"px"}:{}),null!=a.typography.labelSize?{"--semiotic-axis-label-font-size":a.typography.labelSize+"px"}:{}),{"--semiotic-secondary":a.colors.secondary||a.colors.primary,"--semiotic-surface":a.colors.surface||a.colors.background}),a.colors.success?{"--semiotic-success":a.colors.success}:{}),a.colors.danger?{"--semiotic-danger":a.colors.danger}:{}),a.colors.warning?{"--semiotic-warning":a.colors.warning}:{}),a.colors.error?{"--semiotic-error":a.colors.error}:{}),a.colors.info?{"--semiotic-info":a.colors.info}:{}),c=p.useContext(Di),u={};return c&&(u["data-semiotic-theme"]=c),e.jsx("div",Object.assign({style:l},u,{children:t}))}function $i(){return R(e=>e.theme)}const Wi="#007bff";function zi(e,t,o){var n;const i=null!==(n=e.xValue)&&void 0!==n?n:null==t?void 0:t[o];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function Gi(e){let t=e.data||e.datum||e;return Array.isArray(t)&&(t=t[0]),null!=e.xValue&&t&&"object"==typeof t&&!Array.isArray(t)&&null==t.xValue?Object.assign(Object.assign({},t),{xValue:e.xValue}):t||{}}function Yi(){var e;const t=$i(),o=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return o&&o.length>0?o:void 0}function qi(e,t,o,n,i){if(e)return e;let r;if(Array.isArray(o))r=o;else if(t&&t.length>0)r=t;else if("string"==typeof o){const e=ye[o];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=n?(i.has(n)||i.set(n,i.size),r[i.get(n)%r.length]):r[0]:Wi}function Xi(e,o,n){const i=ci(),r=Yi();return t.useMemo(()=>{var t;if(!o)return;const s=null!==(t=null!=n?n:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof o){const t=Array.from(new Set(e.map(e=>o(e)+"")));if(i&&Object.keys(i).length>0){const e=we(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return we(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=we(e,o,s);return e=>i[e]||t(e)}return we(e,o,s)}if(i&&Object.keys(i).length>0){const e=we([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,o,n,i,r])}function Vi(e,o,n){return t.useMemo(()=>{if(!o||"auto"===o||"function"==typeof o)return e;const t=[...e],i=function(e){return"function"==typeof e?e:t=>t[e]}(n);return t.sort("asc"===o?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,o,n])}function Ui({selection:e,linkedHover:o,fallbackFields:n=[],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}(o,n),g=mi({name:(null==e?void 0:e.name)||"__unused__"}),f=vi({name:(null==h?void 0:h.name)||"hover",fields:(null==h?void 0:h.fields)||n||[]}),p=yi(e=>e.pushObservation),y=e?{isActive:g.isActive,predicate:g.predicate}:null,[m,v]=t.useState(null),b=u||n[0],x=t.useMemo(()=>{if(!c||null==m||!b)return null;const e=m,t=b;return{isActive:!0,predicate:o=>{var n;return("string"==typeof o[t]?o[t]:(null!==(n=o[t])&&void 0!==n?n:"")+"")===e}}},[c,m,b]),k=t.useCallback(e=>{var t,n;if(o)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 o=zi(e,t,h.xField);null!=o&&function(e,t,o){const n=to.positions.get(e);(null==n?void 0:n.locked)||n&&n.xValue===t&&n.sourceId===o||(to={positions:new Map(to.positions).set(e,{xValue:t,sourceId:o})},no())}(h.name||"hover",o,d)}"x-position"!==(null==h?void 0:h.mode)&&f.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&io(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 o=null==t?void 0:t[b];v(null!=o?o+"":null)}else v(null);if(r||p){const o={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const i=Gi(e),s=Object.assign(Object.assign({},o),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},o),{type:"hover-end"});r&&r(e),p&&p(e)}}},[o,f,h,d,r,s,a,p,c,b]),w=t.useCallback(e=>{var t,o,n,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 o=zi(e,t,h.xField);null!=o&&function(e,t,o){const n=to.positions.get(e);if(null==n?void 0:n.locked){const t=new Map(to.positions);return t.delete(e),to={positions:t},no(),!1}to={positions:new Map(to.positions).set(e,{xValue:t,sourceId:o,locked:!0})},no()}(h.name||"hover",o,d)}if(e&&l){let n=e.data||e.datum||e;Array.isArray(n)&&(n=n[0]),l(n,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0})}if(r||p){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const o=Gi(e),s=Object.assign(Object.assign({},t),{type:"click",datum:o||{},x:null!==(n=e.x)&&void 0!==n?n:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),p&&p(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),p&&p(e)}}},[l,r,p,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{ro(e,d),io(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 Ki(e,t){const o="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==o?void 0:o.mode))return{linkedCrosshairName:o.name||"hover",linkedCrosshairSourceId:t}}function Qi({data:e,colorBy:o,colorScale:n,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(wi),u=null!==t.useContext(Ai),d=void 0!==i?i:!c&&!!o,h=!!o&&(d||u),g=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const n of e){const e="function"==typeof o?o(n):n[o];null!=e&&t.add(e+"")}return Array.from(t)},[l,o,e,h]);Oi(u&&o?g:[]);const f=t.useMemo(()=>{if(!d||!o)return;const t=Li({data:e,colorBy:o,colorScale:n,getColor:ke,categories:g});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,o,e,n,g]),p=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=t=>{const o=e[t];return"number"==typeof o?o:a[t]},o={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},n=t=>"number"==typeof e[t];return f&&("right"===r&&!n("right")&&110>o.right?o.right=110:"left"===r&&!n("left")&&110>o.left?o.left=110:"top"===r&&!n("top")&&50>o.top?o.top=50:"bottom"===r&&!n("bottom")&&80>o.bottom&&(o.bottom=80)),o},[a,s,f,r]);return{legend:f,margin:p,legendPosition:r}}function Zi(e,o,n){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 o=new Set(e);return o.has(t.label)?o.delete(t.label):o.add(t.label),o.size===n.length?new Set:o})},[e,n.length]),u=t.useMemo(()=>{if(!e||"none"===e||!o)return null;const t="string"==typeof o?o:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof o?o(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const n=t?e[t]:"function"==typeof o?o(e):null;return s.has(n)}}:null},[e,o,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Ji={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 er(e,t,o){var n,i,r,s,a,l,c;const u=Ji[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(n=t.width)&&void 0!==n?n:e&&"primary"!==e||!(null==o?void 0:o.width)?u.width:o.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==o?void 0:o.height)?u.height:o.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:tr(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function tr(e,t,o){if(!1!==t)return e;const n=Object.assign({},e);return"horizontal"===o?n.left=Math.min(n.left,15):n.bottom=Math.min(n.bottom,15),n}function or(e){return"string"==typeof e?e:"value"}function nr(e){return null==e?"–":"number"==typeof e?Math.abs(e)>9999?e.toLocaleString():e+"":e instanceof Date?e.toLocaleDateString():e+""}function ir(e,t){if(!t)return nr(e);try{const o=t(e);return null==o?nr(e):o}catch(t){return nr(e)}}function rr(e,t){return"function"==typeof t?t(e):e[t]}function sr(e,t){if(!e)return[];const o=[];return(Array.isArray(e)?e:[e]).forEach((e,n)=>{const i="string"==typeof(null==e?void 0:e.y1Accessor)?e.y1Accessor:"high";o.push({label:"string"==typeof(null==e?void 0:e.y0Accessor)?e.y0Accessor:"low",accessor:e=>{var t,o,i,r;return null!==(i=null===(o=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[n])||void 0===o?void 0:o.y0)&&void 0!==i?i:0===n?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y0:void 0},format:t}),o.push({label:i,accessor:e=>{var t,o,i,r;return null!==(i=null===(o=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[n])||void 0===o?void 0:o.y1)&&void 0!==i?i:0===n?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y1:void 0},format:t})}),o}function ar(t){const o=t.find(e=>"title"===e.role),n=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=o?ir(rr(i,o.accessor),o.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:n.length>0?4:0},children:r}),n.map((t,o)=>{const n=ir(rr(i,t.accessor),t.format);return e.jsxs("div",{style:o>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:n})]},o)})]})}}function lr({categoryAccessor:t,valueAccessor:o,groupAccessor:n,groupLabel:i,pieData:r=!1,valueFormat:s}){return a=>{var l;const c=r?(null===(l=a.data)||void 0===l?void 0:l[0])||a.data||a:a.data||a,u=rr(c,t),d=rr(c,o),h=n?rr(c,n):void 0;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[e.jsx("div",{style:{fontWeight:"bold"},children:nr(u)}),e.jsx("div",{style:{marginTop:4},children:ir(d,s)}),null!=h&&e.jsxs("div",{style:{marginTop:2,opacity:.8},children:[i||or(n),": ",nr(h)]})]})}}function cr({componentName:t,message:o,diagnosticHint:n,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:o}),n&&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:n})]})})}class ur extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var o,n;null===(n=(o=this.props).onError)||void 0===n||n.call(o,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,o=this.state.error;return"function"==typeof t?t(o):void 0!==t?t:e.jsx(cr,{componentName:"ChartErrorBoundary",message:o.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var dr;const hr="undefined"!=typeof process&&"production"!==(null===(dr=process.env)||void 0===dr?void 0:dr.NODE_ENV);function gr({componentName:t,width:o,height:n,children:i}){return e.jsx(ur,{fallback:i=>e.jsx(cr,{componentName:t,message:i.message,width:o,height:n}),children:i})}const fr={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"},pr={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function yr(t,o,n,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},fr),{width:o,height:n}),children:i||"No data available"}):null}function mr(t,o,n,i){if(!t)return null;if(!1===i)return null;if(null!=i)return e.jsx("div",{style:{width:o,height:n,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(n/40)),s=Math.max(8,Math.floor(n/(3*r))),a=Math.max(6,Math.floor(n/(2.5*r))),l=Math.floor((n-(r*(s+a)-a))/2);return e.jsx("div",{style:{width:o,height:n,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(t,n)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},pr),{position:"absolute",top:l+n*(s+a),left:Math.floor(.1*o),width:30+(37*n+13)%50+"%",height:s,opacity:.5+n%2*.2})},n))})}function vr(e,t,o,n){if(!hr)return;if(!t||0===t.length)return;if("string"!=typeof n)return;const i=t[0];if(!i||"object"!=typeof i)return;if(n in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${o} "${n}" not found in data. Available keys: ${r}`)}function br(e,t){const o=e.length,n=t.length,i=Array(n+1);for(let e=0;n>=e;e++)i[e]=e;for(let r=1;o>=r;r++){let o=i[0];i[0]=r;for(let s=1;n>=s;s++){const n=i[s];i[s]=e[r-1]===t[s-1]?o:1+Math.min(o,i[s],i[s-1]),o=n}}return i[n]}function xr(e,t,o=3){let n,i=o+1;for(const o of t){const t=br(e.toLowerCase(),o.toLowerCase());i>t&&(i=t,n=o)}return i>o?void 0:n}function kr(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function wr(e,t){var o;if(0===t.length)return null;const n=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(n)||n.includes(e.toLowerCase()))||(null!==(o=xr(e,t,3))&&void 0!==o?o:null)}function Ar({componentName:e,data:t,accessors:o,requiredProps:n}){if(n)for(const[t,o]of Object.entries(n))if(null==o)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(o){const n=kr(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[i,r]of Object.entries(o))if(r&&"string"==typeof r&&!(r in n)){const o=wr(r,t),n=o?` Try ${i}="${o}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${n}`}}}return null}function jr({componentName:e,data:t,dataLabel:o="data"}){return null==t?`${e}: No ${o} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${o} 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}function Sr({componentName:e,nodes:t,edges:o,nodesRequired:n=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==o)return null;if(i&&(!o||!Array.isArray(o)||0===o.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(n&&(!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 o=kr(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[n,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in o)){const o=wr(i,t),r=o?` Try ${n}="${o}".`:"";return`${e}: ${n} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}function Cr(e){const o=R(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,n;if(void 0!==e||void 0!==o)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(n=null==e?void 0:e.unselectedOpacity)&&void 0!==n?n:o})},[e,o])}function Or(e){const{data:o,rawData:n,colorBy:i,colorScheme:r,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:b,hoverHighlight:x,loading:k,loadingContent:w,emptyContent:A,width:j,height:S}=e,C=void 0===n,O=t.useMemo(()=>v(o),[o]),[M,P]=t.useState([]),_=t.useCallback(e=>{P(t=>t.length===e.length&&t.every((t,o)=>t===e[o])?t:e)},[]),L="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:T,hoverSelectionHook:R,customHoverBehavior:B,customClickBehavior:N,crosshairSourceId:D}=Ui({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:b,hoverHighlight:x,colorByField:L}),E=Ki(c,D),I=Xi(O,i,r),H=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of O){const o="function"==typeof i?i(t):t[i];null!=o&&e.add(o+"")}return Array.from(e)},[O,i]),F=t.useMemo(()=>C&&M.length>0?M:H,[C,M,H]),$=Zi(s,i,F),W=t.useMemo(()=>R||($.legendSelectionHook?$.legendSelectionHook:T),[R,$.legendSelectionHook,T]),z=Cr(l),G=Yi(),Y=ci(),q=t.useMemo(()=>{if(I)return I;if(!i||0===F.length)return;const e=Array.isArray(r)&&r.length>0||"string"==typeof r&&r.length>0?r:G&&G.length>0?G:ve,t="__streamCat",o=we(F.map(e=>({[t]:e})),t,e);return e=>(null==Y?void 0:Y[e])||o(e)||"#999"},[I,i,F,r,G,Y]),{legend:X,margin:V,legendPosition:U}=Qi({data:O,colorBy:i,colorScale:q,showLegend:p,legendPosition:a,userMargin:y,defaults:m,categories:F}),K=t.useMemo(()=>{const e={};return X&&(e.legend=X,e.legendPosition=U),s&&"none"!==s&&(e.legendHoverBehavior=$.onLegendHover,e.legendClickBehavior=$.onLegendClick,e.legendHighlightedCategory=$.highlightedCategory,e.legendIsolatedCategories=$.isolatedCategories),C&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=_),e},[X,U,s,$.onLegendHover,$.onLegendClick,$.highlightedCategory,$.isolatedCategories,C,i,_]),Q=Array.isArray(n)?v(n):n,Z=mr(k,j,S,w),J=Z?null:yr(Q,j,S,A);return{data:O,colorScale:I,allCategories:F,legendState:$,effectiveSelectionHook:W,activeSelectionHook:T,customHoverBehavior:B,customClickBehavior:N,legend:X,margin:V,legendPosition:U,earlyReturn:Z||J||null,legendBehaviorProps:K,crosshairProps:E,resolvedSelection:z}}function Mr(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const o={};return void 0!==t.stroke&&(o.stroke=t.stroke),void 0!==t.strokeWidth&&(o.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(o.opacity=t.opacity),e?(...t)=>{const n=e(...t)||{};return Object.assign(Object.assign({},n),o)}:(...e)=>Object.assign({},o)}function Pr(e){const{lineWidth:o=2,colorBy:n,colorScale:i,color:r,resolveStroke:s,fillArea:a,areaOpacity:l=.3,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:g}=e,f=t.useMemo(()=>(e,t)=>{const c={strokeWidth:o},u=!0===a||Array.isArray(a)&&null!=t&&a.includes(t);let d;return s?d=s(e,t):n?i&&(d=ke(e,n,i)):d=r||Wi,void 0!==d&&(c.stroke=d,u&&(c.fill=d,c.fillOpacity=l)),c},[o,n,i,r,s,a,l]),p=t.useMemo(()=>Mr(f,{stroke:c,strokeWidth:u,opacity:d}),[f,c,u,d]);return t.useMemo(()=>Ri(p,null!=h?h:null,g),[p,h,g])}function _r(e,o){const{variant:n,frameRef:i,overrides:r,deps:s}=o;t.useImperativeHandle(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n;return null!==(n=null===(o=e.current)||void 0===o?void 0:o.remove(t))&&void 0!==n?n:[]},update:(t,o)=>{var n,i;return null!==(i=null===(n=e.current)||void 0===n?void 0:n.update(t,o))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==o?o:null}}}if("network"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n,i,r,s;const a=Array.isArray(t)?t:[t],l=null!==(i=null===(n=null===(o=e.current)||void 0===o?void 0:o.getTopology())||void 0===n?void 0:n.nodes)&&void 0!==i?i:[],c=[];for(const t of a){const o=l.find(e=>e.id===t);o&&c.push(Object.assign(Object.assign({},null!==(r=o.data)&&void 0!==r?r:{}),{id:t})),null===(s=e.current)||void 0===s||s.removeNode(t)}return c},update:(t,o)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var n;const i=null===(n=e.current)||void 0===n?void 0:n.updateNode(t,o);return i?[Object.assign(Object.assign({},i),{id:t})]:[]}),clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o,n,i;return null!==(i=null===(n=null===(o=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===o?void 0:o.nodes)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==i?i:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.push(t)},pushMany:t=>{var o;return null===(o=e.current)||void 0===o?void 0:o.pushMany(t)},remove:t=>{var o,n;return null!==(n=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==n?n:[]},update:(t,o)=>{var n,i,r;const s=null!==(i=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==i?i:[];for(const t of s)null===(r=e.current)||void 0===r||r.push(o(t));return s},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,o;return null!==(o=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]}}}const o=t;return{push:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=o.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,n;return null!==(n=null===(t=o.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,i,r;const s=null!==(i=null===(n=o.current)||void 0===n?void 0:n.removeLine(e))&&void 0!==i?i:[];for(const e of s)null===(r=o.current)||void 0===r||r.pushLine(t(e));return s},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.getLines())&&void 0!==t?t:[]}}}(n,i);return Object.assign(Object.assign({},e),r)},null!=s?s:[])}function Lr(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&0>t.indexOf(n)&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);n.length>i;i++)0>t.indexOf(n[i])&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(o[n[i]]=e[n[i]])}return o}function Tr(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){e.done?i(e.value):function(e){return e instanceof o?e:new o(function(t){t(e)})}(e.value).then(s,a)}l((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const Rr="__forecastSegment";let Br=null;function Nr(){return Tr(this,void 0,void 0,function*(){return Br||(Br=yield Promise.resolve().then(function(){return yg})),Br})}const Dr="__semiotic_resolvedX",Er="__semiotic_resolvedY";function Ir(e){const{data:o,xAccessor:n,yAccessor:i,forecast:r,anomaly:s,groupBy:a}=e,l="string"==typeof n?n:Dr,c="string"==typeof i?i:Er,u=t.useMemo(()=>{if(!r&&!s)return o;const e="function"==typeof n,t="function"==typeof i;return e||t?o.map(o=>{const r=Object.assign({},o);return e&&(r[Dr]=n(o)),t&&(r[Er]=i(o)),r}):o},[o,r,s,n,i]),[d,h]=t.useState(null),[g,f]=t.useState([]),p=t.useRef(r),y=t.useRef(s);return t.useEffect(()=>{if(!r&&!s)return void((p.current||y.current)&&(h(null),f([]),p.current=r,y.current=s));let e=!1;const t=r!==p.current||s!==y.current;if(p.current=r,y.current=s,t&&(h(null),f([])),r){const t=a&&"string"==typeof a&&"object"==typeof r?Object.assign(Object.assign({},r),{_groupBy:a}):r;(function(...e){return Tr(this,void 0,void 0,function*(){return(yield Nr()).buildForecast(...e)})})(u,l,c,t,s).then(t=>{e||(h(t),f(t.annotations))}).catch(()=>{e||(h(null),f([]))})}else s&&function(...e){return Tr(this,void 0,void 0,function*(){return(yield Nr()).buildAnomalyAnnotations(...e)})}(s).then(t=>{e||(h(null),f(t))}).catch(()=>{e||f([])});return()=>{e=!0}},[u,r,s,l,c,a]),{effectiveData:d?d.processedData:o,statisticalAnnotations:g,hasForecast:!!d,xAccessorKey:l,yAccessorKey:c}}const Hr=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);_r(n,{variant:"xy",frameRef:s});const a=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,axisExtent:g,xAccessor:f="x",yAccessor:p="y",lineBy:y,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:x,curve:k="linear",showPoints:w=!1,pointRadius:A=3,fillArea:j=!1,areaOpacity:S=.3,lineWidth:C=2,lineGradient:O,tooltip:M,pointIdAccessor:P,annotations:_,directLabel:L,gapStrategy:T="break",anomaly:R,forecast:B,band:N,xExtent:D,yExtent:E,frameProps:I={},selection:H,linkedHover:F,onObservation:$,onClick:W,hoverHighlight:z,hoverRadius:G,chartId:Y,loading:q,loadingContent:X,emptyContent:V,legendInteraction:U,legendPosition:K,xScaleType:Q,yScaleType:Z,color:J,stroke:ee,strokeWidth:te,opacity:oe}=o,{width:ne,height:ie,enableHover:re,showGrid:se,showLegend:ae,title:le,description:ce,summary:ue,accessibleTable:de,xLabel:he,yLabel:ge}=a,fe=t.useMemo(()=>v(l),[l]);vr("LineChart",fe,"xAccessor",f),vr("LineChart",fe,"yAccessor",p);const{effectiveData:pe,statisticalAnnotations:ye}=Ir({data:fe,xAccessor:f,yAccessor:p,forecast:B,anomaly:R,groupBy:y}),me="__compoundGroup",ve=!(!B||!y),be=ve?me:B?Rr:y,xe=t.useMemo(()=>{if(!ve)return pe;const e="function"==typeof y?y:e=>e[y];return pe.map(t=>{const o=Object.assign({},t);return o[me]=`${e(t)}__${t[Rr]||"observed"}`,o})},[pe,ve,y]),we=ve?xe:pe,Ae=b||y,je=t.useMemo(()=>{if(!B)return;const e=B.upperBounds,t=B.lowerBounds;if(!e&&!t)return;const o="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,n="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=pe;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)),o){const t=o(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(n){const t=n(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[B,pe,p]),Se=t.useCallback(e=>{const t="function"==typeof f?f(e):e[f],o="function"==typeof p?p(e):e[p];return null==t||null==o||Number.isNaN(t)||Number.isNaN(o)},[f,p]),Ce=void 0!==(null===(i=we[0])||void 0===i?void 0:i[m]),Oe=t.useMemo(()=>{if(Ce)return we;if(be){const e=we.reduce((e,t)=>{const o="function"==typeof be?be(t):t[be];if(!e[o]){const n={[m]:[]};"string"==typeof be&&(n[be]=o),ve&&(n[Rr]=t[Rr],"string"==typeof y&&(n[y]=t[y])),e[o]=n}return e[o][m].push(t),e},{});return Object.values(e)}return[{[m]:we}]},[we,be,m,Ce]),{gapProcessedLineData:Me,hasGaps:Pe}=t.useMemo(()=>{if("interpolate"===T){let e=!1;const t=[];for(const o of Oe){const n=(o[m]||[]).filter(t=>!Se(t)||(e=!0,!1));n.length>0&&t.push(Object.assign(Object.assign({},o),{[m]:n}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===T){let e=!1;const t=[];for(const o of Oe){const n=o[m]||[];let i=[],r=0;const s=be&&"string"==typeof be?o[be]:void 0;for(const a of n)if(Se(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},o),{[m]: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({},o),{[m]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===T){let e=!1;const t="string"==typeof p?p:"y",o=[];for(const n of Oe){const i=n[m]||[],r=[];for(const o of i)Se(o)?(e=!0,r.push(Object.assign(Object.assign({},o),{[t]:0}))):r.push(o);o.push(Object.assign(Object.assign({},n),{[m]:r}))}return{gapProcessedLineData:o,hasGaps:e}}return{gapProcessedLineData:Oe,hasGaps:!1}},[Oe,T,m,Se,be,p]),_e="object"==typeof L?L:{},Le=_e.position||"end",Te=_e.fontSize||11,Re=t.useMemo(()=>{var e;if(!L||!Ae)return[];const t="function"==typeof Ae?Ae:e=>e[Ae],o=new Set;for(const n of Me){const i=n[m]||[];if(0===i.length)continue;const r=null!==(e=t("end"===Le?i[i.length-1]:i[0]))&&void 0!==e?e:t(n);if(null==r)continue;const s=r+"";""!==s&&o.add(s)}return Array.from(o)},[L,Ae,Me,m,Le]),Be=t.useMemo(()=>{if(!L)return a.marginDefaults;const e=Re.reduce((e,t)=>Math.max(e,t.length*(.6*Te)),0)+10,t="end"===Le?"right":"left";return Object.assign(Object.assign({},a.marginDefaults),{[t]:Math.max(a.marginDefaults[t]||0,e)})},[L,Re,Te,Le,a.marginDefaults]),Ne=Or({data:pe,rawData:l,colorBy:Ae,colorScheme:x,legendInteraction:U,legendPosition:K,selection:H,linkedHover:F,fallbackFields:Ae?["string"==typeof Ae?Ae:""]:[],unwrapData:!1,onObservation:$,onClick:W,hoverHighlight:z,chartType:"LineChart",chartId:Y,showLegend:(!L||void 0!==ae)&&ae,userMargin:c,marginDefaults:Be,loading:q,loadingContent:X,emptyContent:V,width:ne,height:ie}),De=Ne.colorScale,Ee=Ne.customHoverBehavior,Ie=Ne.customClickBehavior,He=Ne.crosshairProps,Fe=Pr({lineWidth:C,colorBy:Ae,colorScale:De,color:J,fillArea:j,areaOpacity:S,stroke:ee,strokeWidth:te,opacity:oe,effectiveSelectionHook:Ne.effectiveSelectionHook,resolvedSelection:Ne.resolvedSelection}),[$e,We]=t.useState(null);t.useEffect(()=>{if(!B)return void We(null);let e=!1;return function(...e){return Tr(this,void 0,void 0,function*(){return(yield Nr()).createSegmentLineStyle(...e)})}(Fe,B).then(t=>{e||We(()=>t)}).catch(()=>{e||We(null)}),()=>{e=!0}},[Fe,B]);const ze=$e||Fe,Ge=t.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return Ae?De&&(t.fill=ke(e.parentLine||e,Ae,De)):t.fill=J||Wi,t}},[w,A,Ae,De,J]),Ye=Array.isArray(j)?"mixed":j?"area":"line",qe=t.useMemo(()=>{var e;if(!L||!Ae)return[];const t="function"==typeof f?f:e=>e[f],o="function"==typeof p?p:e=>e[p],n="function"==typeof Ae?Ae:e=>e[Ae],i=new Map;for(const t of Me){const o=t[m]||[];if(0===o.length)continue;const r="end"===Le?o[o.length-1]:o[0],s=null!==(e=n(r))&&void 0!==e?e:n(t);if(null==s)continue;const a=s+"";""===a||i.has(a)||i.set(a,r)}const r=Array.from(i.entries()).map(([e,n])=>({type:"text",label:e,["string"==typeof f?f:"x"]:t(n),["string"==typeof p?p:"y"]:o(n),dx:"end"===Le?6:-6,dy:0,color:De?De(e):Wi,fontSize:Te}));r.sort((e,t)=>{const o="string"==typeof p?p:"y";return e[o]-t[o]});for(let e=1;r.length>e;e++){const t="string"==typeof p?p:"y",o=r[e-1],n=r[e];Te+2>Math.abs(n[t]+n.dy-(o[t]+o.dy))&&(n.dy+=Te+2)}return r},[L,Ae,De,Me,m,f,p,Le,Te]),Xe=Ne.margin,Ve=y||b,Ue=t.useMemo(()=>ar([{label:he||or(f),accessor:f,role:"x",format:d},{label:ge||or(p),accessor:p,role:"y",format:h},...Ve?[{label:or(Ve),accessor:Ve,role:"group"}]:[],...sr(N,h)]),[f,p,he,ge,Ve,d,h,N]),Ke=Ar({componentName:"LineChart",data:Ce?(null===(r=pe[0])||void 0===r?void 0:r[m])||[]:l,accessors:{xAccessor:f,yAccessor:p}}),Qe=t.useMemo(()=>Ce||be||Pe?Me.flatMap(e=>{const t=e[m]||[];return be&&"string"==typeof be?t.map(t=>Object.assign(Object.assign({},t),{[be]:e[be]})):t}):we,[Me,m,Ce,be,we,Pe]),Ze=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(Object.assign(Object.assign(Object.assign(Object.assign({chartType:Ye},Array.isArray(j)&&{areaGroups:j}),O&&{lineGradient:O}),null!=G&&{hoverRadius:G}),null!=l&&{data:Qe}),{xAccessor:f,yAccessor:p,xScaleType:Q,yScaleType:Z}),D&&{xExtent:D}),!E||null==E[0]&&null==E[1]?je?{yExtent:je}:{}:{yExtent:E}),{groupAccessor:"break"===T&&Pe?"_gapSegment":be||void 0}),N&&{band:N}),{curve:k,lineStyle:ze}),w&&{pointStyle:Ge}),{size:[ne,ie],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Xe,showAxes:a.showAxes,xLabel:he,yLabel:ge,xFormat:d,yFormat:h}),void 0!==g&&{axisExtent:g}),{enableHover:re,showGrid:se}),Ne.legendBehaviorProps),le&&{title:le}),ce&&{description:ce}),ue&&{summary:ue}),void 0!==de&&{accessibleTable:de}),u&&{className:u}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===M?()=>null:"multi"===M?xn():kn(M)||Ue}),"multi"===M&&{tooltipMode:"multi"}),(F||$||W||z)&&{customHoverBehavior:Ee}),($||W||F)&&{customClickBehavior:Ie}),P&&{pointIdAccessor:P}),((null==_?void 0:_.length)||ye.length||qe.length)&&{annotations:[..._||[],...ye,...qe]}),He),I);return Ne.earlyReturn?Ne.earlyReturn:Ke?e.jsx(cr,{componentName:"LineChart",message:Ke,width:ne,height:ie}):e.jsx(gr,{componentName:"LineChart",width:ne,height:ie,children:e.jsx(si,Object.assign({ref:s},Ze))})});function Fr(e){const{title:t,description:o,summary:n,accessibleTable:i,className:r,animate:s,axisExtent:a}=e,l={};return t&&(l.title=t),o&&(l.description=o),n&&(l.summary=n),void 0!==i&&(l.accessibleTable=i),r&&(l.className=r),null!=s&&(l.animate=s),void 0!==a&&(l.axisExtent=a),l}function $r(e){const{linkedHover:t,onObservation:o,onClick:n,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=e,l={};return(t||o||n||i)&&(l.customHoverBehavior=r),(a?o||n||t:o||n)&&(l.customClickBehavior=s),l}function Wr(e){const{tooltip:t,defaultTooltipContent:o}=e;return{tooltipContent:!1===t?()=>null:kn(t)||o}}function zr(e){var o;const{safeData:n,data:i,areaBy:r,lineDataAccessor:s,colorBy:a,colorScale:l,color:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:g,resolvedSelection:f,areaOpacity:p,showLine:y,lineWidth:m,showPoints:v,pointRadius:b,xAccessor:x,yAccessor:k,xLabel:w,yLabel:A,xFormat:j,yFormat:S,groupField:C}=e,O=void 0!==(null===(o=n[0])||void 0===o?void 0:o[s]),M=t.useMemo(()=>{if(null==i)return[];if(!O&&!r)return n;let e;if(O)e=n;else{const t=r,o=n.reduce((e,o)=>{const n="function"==typeof t?t(o):o[t];if(!e[n]){const o={[s]:[]};"string"==typeof t&&(o[t]=n),e[n]=o}return e[n][s].push(o),e},{});e=Object.values(o)}return e.flatMap(e=>{const t=e[s]||[];return r&&"string"==typeof r?t.map(t=>Object.assign(Object.assign({},t),{[r]:e[r]})):t})},[i,n,r,s,O]),P=t.useMemo(()=>e=>{const t={};if(a){if(l){const o=ke(e,a,l);t.fill=o,y?(t.stroke=o,t.strokeWidth=m):t.stroke="none"}}else{const e=c||Wi;t.fill=e,y?(t.stroke=e,t.strokeWidth=m):t.stroke="none"}return t.fillOpacity=p,t},[a,l,c,p,y,m]),_=t.useMemo(()=>Mr(P,{stroke:u,strokeWidth:d,opacity:h}),[P,u,d,h]);return{flattenedData:M,lineStyle:t.useMemo(()=>Ri(_,null!=g?g:null,f),[_,g,f]),pointStyle:t.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return a?l&&(t.fill=ke(e.parentLine||e,a,l)):t.fill=c||Wi,t}},[v,b,a,l,c]),defaultTooltipContent:t.useMemo(()=>ar([{label:w||or(x),accessor:x,role:"x",format:j},{label:A||or(k),accessor:k,role:"y",format:S},...C?[{label:or(C),accessor:C,role:"group"}]:[],...sr(e.band,S)]),[x,k,w,A,C,j,S,e.band])}}function Gr(e,t){if(null==t)return e;const o=e.trim(),n=o.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(n){const e=n[1],o=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(o.slice(0,2),16)}, ${parseInt(o.slice(2,4),16)}, ${parseInt(o.slice(4,6),16)}, ${t})`}if(o.startsWith("rgba(")){const e=o.lastIndexOf(","),n=o.lastIndexOf(")");if(-1!==e&&n>e)return`${o.slice(0,e+1)} ${t})`}return o.startsWith("rgb(")?o.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}Hr.displayName="LineChart";const Yr=t.forwardRef(function(o,n){const i=t.useRef(null);_r(n,{variant:"xy",frameRef:i});const r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,y0Accessor:f,gradientFill:p=!1,semanticGradient:y,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:x,curve:k="monotoneX",areaOpacity:w=.7,lineGradient:A,showLine:j=!0,lineWidth:S=2,showPoints:C=!1,pointRadius:O=3,tooltip:M,annotations:P,forecast:_,anomaly:L,band:T,xExtent:R,yExtent:B,frameProps:N={},selection:D,linkedHover:E,onObservation:I,onClick:H,hoverHighlight:F,chartId:$,loading:W,loadingContent:z,emptyContent:G,legendInteraction:Y,legendPosition:q,color:X,stroke:V,strokeWidth:U,opacity:K}=o,{width:Q,height:Z,enableHover:J,showGrid:ee,showLegend:te,title:oe,description:ne,summary:ie,accessibleTable:re,xLabel:se,yLabel:ae}=r,le=t.useMemo(()=>v(s),[s]),ce=b||g,ue=t.useMemo(()=>{return y&&y.length>0?{colorStops:(e=y,e.filter(e=>Number.isFinite(e.at)).map(e=>({offset:1-Math.max(0,Math.min(100,e.at))/100,color:Gr(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset))}:p;var e},[y,p]);vr("AreaChart",le,"xAccessor",d),vr("AreaChart",le,"yAccessor",h);const de=Or({data:le,rawData:s,colorBy:ce,colorScheme:x,legendInteraction:Y,legendPosition:q,selection:D,linkedHover:E,fallbackFields:ce?["string"==typeof ce?ce:""]:[],unwrapData:!1,onObservation:I,onClick:H,hoverHighlight:F,chartType:"AreaChart",chartId:$,showLegend:te,userMargin:a,marginDefaults:r.marginDefaults,loading:W,loadingContent:z,emptyContent:G,width:Q,height:Z}),{effectiveData:he,statisticalAnnotations:ge}=Ir({data:le,xAccessor:d,yAccessor:h,forecast:_,anomaly:L,groupBy:g}),{flattenedData:fe,lineStyle:pe,pointStyle:ye,defaultTooltipContent:me}=zr({safeData:he,data:s,areaBy:g,lineDataAccessor:m,colorBy:ce,colorScale:de.colorScale,color:X,stroke:V,strokeWidth:U,opacity:K,effectiveSelectionHook:de.effectiveSelectionHook,resolvedSelection:de.resolvedSelection,areaOpacity:w,showLine:j,lineWidth:S,showPoints:C,pointRadius:O,xAccessor:d,yAccessor:h,xLabel:se,yLabel:ae,xFormat:c,yFormat:u,groupField:g||b,band:T}),ve=Ar({componentName:"AreaChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),be=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:fe}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0}),f&&{y0Accessor:f}),T&&{band:T}),ue&&{gradientFill:ue}),A&&{lineGradient:A}),{curve:k,lineStyle:pe}),C&&ye&&{pointStyle:ye}),{size:[Q,Z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:de.margin,showAxes:r.showAxes,xLabel:se,yLabel:ae,xFormat:c,yFormat:u,enableHover:J}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:ee}),de.legendBehaviorProps),Fr({title:oe,description:ne,summary:ie,accessibleTable:re,className:l,animate:o.animate,axisExtent:o.axisExtent})),"multi"===M?{tooltipContent:xn(),tooltipMode:"multi"}:Wr({tooltip:M,defaultTooltipContent:me})),$r({linkedHover:E,onObservation:I,onClick:H,hoverHighlight:F,customHoverBehavior:de.customHoverBehavior,customClickBehavior:de.customClickBehavior})),(P&&P.length>0||ge.length>0)&&{annotations:[...P||[],...ge]}),R&&{xExtent:R}),B&&{yExtent:B}),de.crosshairProps),N);return de.earlyReturn?de.earlyReturn:ve?e.jsx(cr,{componentName:"AreaChart",message:ve,width:Q,height:Z}):e.jsx(gr,{componentName:"AreaChart",width:Q,height:Z,children:e.jsx(si,Object.assign({ref:i},be))})});function qr(e){if(null==e)return NaN;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();if("string"==typeof e){if(""===e.trim())return NaN;const t=+e;return Number.isFinite(t)?t:NaN}return NaN}Yr.displayName="AreaChart";const Xr=t.forwardRef(function(o,n){const i=t.useRef(null),r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:g="b",seriesALabel:f="A",seriesBLabel:p="B",seriesAColor:y="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:b=!0,lineWidth:x=1.5,showPoints:k=!1,pointRadius:w=3,curve:A="linear",areaOpacity:j=.6,gradientFill:S,tooltip:C,annotations:O,xExtent:M,yExtent:P,frameProps:_={},selection:L,linkedHover:T,onObservation:R,onClick:B,hoverHighlight:N,chartId:D,loading:E,loadingContent:I,emptyContent:H,legendInteraction:F,legendPosition:$,pointIdAccessor:W,windowSize:z}=o,{width:G,height:Y,enableHover:q,showGrid:X,showLegend:V,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=r,te=t.useMemo(()=>"function"==typeof d?e=>qr(d(e)):e=>qr(e[d]),[d]),oe=t.useMemo(()=>"function"==typeof h?e=>qr(h(e)):e=>qr(e[h]),[h]),ne=t.useMemo(()=>"function"==typeof g?e=>qr(g(e)):e=>qr(e[g]),[g]),[ie,re]=t.useState([]),se=t.useRef([]),ae=null==s,le=t.useMemo(()=>v(ae?ie:s),[ae,ie,s]),ce=t.useMemo(()=>function(e,t,o,n){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];let s=0,a=null,l=null,c=[];const u=(e,t)=>e>t?"A":t>e?"B":null,d=e=>`seg-${s}-${e}`,h=e=>r.push(e),g=(e,t)=>{h({__x:e.x,__y:e.y,__y0:e.y,__diffSegment:d(t),__diffWinner:t,__valA:e.y,__valB:e.y,__sourceDatum:e.datum})};for(let e=0;i.length>e;e++){const r=i[e],f=t(r),p=o(r),y=n(r);if(!Number.isFinite(f)||!Number.isFinite(p)||!Number.isFinite(y))continue;const m=u(p,y);if(null!==m)if(null!=a){if(l&&l.w!==m){let e,t;if(c.length>0)e=c[0].x,t=c[0].y;else{const o=p-l.a-(y-l.b);if(0!==o){const n=Math.max(0,Math.min(1,(l.b-l.a)/o));e=l.x+n*(f-l.x),t=l.a+n*(p-l.a)}else e=l.x,t=l.a}h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t}),s++,a=m,h({__x:e,__y:t,__y0:t,__diffSegment:d(a),__diffWinner:a,__valA:t,__valB:t});for(let e=1;c.length>e;e++)g(c[e],a)}else for(const e of c)g(e,a);c=[],h({__x:f,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:f,a:p,b:y,w:m}}else{a=m;for(const e of c)g(e,a);c=[],h({__x:f,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:f,a:p,b:y,w:m}}else c.push({x:f,y:p,datum:r})}for(const e of c)g(e,null!=a?a:"A");return r}(le,te,oe,ne),[le,te,oe,ne]),ue=t.useMemo(()=>b?function(e,t,o,n){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,o)=>t(e)-t(o)),r=[];for(const e of i){const i=t(e),s=o(e),a=n(e);Number.isFinite(s)&&r.push({__x:i,__y:s,__diffSegment:"line-A"}),Number.isFinite(a)&&r.push({__x:i,__y:a,__diffSegment:"line-B"})}return r}(le,te,oe,ne):[],[b,le,te,oe,ne]),de=t.useMemo(()=>[...ce,...ue],[ce,ue]),he=t.useMemo(()=>{const e=new Set;for(const t of ce)e.add(t.__diffSegment);return Array.from(e)},[ce]);t.useImperativeHandle(n,()=>{const e=e=>{const t=z&&e.length>z?e.slice(e.length-z):e;se.current=t,re(t)},t=W?"function"==typeof W?W:e=>e[W]:null;return{push:t=>e([...se.current,t]),pushMany:t=>e([...se.current,...t]),remove:o=>{if(!t)return[];const n=Array.isArray(o)?o:[o],i=[],r=[];for(const e of se.current)n.includes(t(e))?i.push(e):r.push(e);return e(r),i},update:(o,n)=>{if(!t)return[];const i=Array.isArray(o)?o:[o],r=[],s=se.current.map(e=>{if(i.includes(t(e))){const t=n(e);return r.push(t),t}return e});return e(s),r},clear:()=>e([]),getData:()=>ae?se.current:le,getScales:()=>{var e,t;return null!==(t=null===(e=i.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}},[ae,le,W,z]);const ge=Or({data:le,rawData:s,colorBy:"__diffWinner",colorScheme:[y,m],legendInteraction:F,legendPosition:$,selection:L,linkedHover:T,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:B,hoverHighlight:N,chartType:"DifferenceChart",chartId:D,showLegend:V,userMargin:a,marginDefaults:r.marginDefaults,loading:E,loadingContent:I,emptyContent:H,width:G,height:Y}),fe=t.useMemo(()=>{if(!1!==V)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:f,color:y},{label:p,color:m}]}]}},[V,f,p,y,m]),pe=t.useCallback(e=>{const t=e.__diffSegment;return{fill:"A"==((null==t?void 0:t.endsWith("-A"))?"A":"B")?y:m,stroke:"none",fillOpacity:j}},[y,m,j]),ye=t.useCallback(e=>({stroke:"A"==("line-A"===e.__diffSegment?"A":"B")?y:m,strokeWidth:x,fill:"none"}),[y,m,x]),me=t.useCallback(e=>({fill:"A"==("line-A"===e.__diffSegment?"A":"B")?y:m,r:w}),[y,m,w]),ve=t.useCallback(t=>{var o;const n=t.data,i=t.allSeries,r=null!==(o=t.xValue)&&void 0!==o?o:null==n?void 0:n.__x;let s=null==n?void 0:n.__valA,a=null==n?void 0:n.__valB;if(i&&i.length>0){const e=i.find(e=>"line-A"===e.group),t=i.find(e=>"line-B"===e.group);null!=(null==e?void 0:e.value)&&Number.isFinite(e.value)&&(s=e.value),null!=(null==t?void 0:t.value)&&Number.isFinite(t.value)&&(a=t.value)}if(null!=r&&(null==s||null==a)){const e=le.find(e=>te(e)===r);e&&(null==s&&(s=oe(e)),null==a&&(a=ne(e)))}const l=e=>null!=e&&Number.isFinite(e)?""+Math.round(100*e)/100:"—",u=c&&null!=r?c(r):null!=r?r+"":"";return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[u&&e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:u}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:10,height:10,background:y,display:"inline-block",borderRadius:2}}),e.jsxs("span",{children:[f,": ",l(s)]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:10,height:10,background:m,display:"inline-block",borderRadius:2}}),e.jsxs("span",{children:[p,": ",l(a)]})]}),null!=s&&null!=a&&Number.isFinite(s)&&Number.isFinite(a)&&e.jsxs("div",{style:{marginTop:4,opacity:.7},children:["Δ = ",l(s-a)]})]})},[le,te,oe,ne,c,y,m,f,p]),be="multi"===C,xe=t.useMemo(()=>!1===C?()=>null:be?ve:kn(C)||ve,[C,be,ve]),ke=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:"mixed",data:de,xAccessor:"__x",yAccessor:"__y",y0Accessor:"__y0",groupAccessor:"__diffSegment",areaGroups:he,curve:A,areaStyle:pe,lineStyle:ye},k&&{pointStyle:me}),{size:[G,Y],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ge.margin,showAxes:r.showAxes,xLabel:J,yLabel:ee,xFormat:c,yFormat:u,enableHover:q,showGrid:X}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),fe&&{legend:fe,legendPosition:ge.legendPosition}),Fr({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:o.animate,axisExtent:o.axisExtent})),{tooltipContent:xe}),be&&{tooltipMode:"multi"}),$r({linkedHover:T,onObservation:R,onClick:B,hoverHighlight:N,customHoverBehavior:ge.customHoverBehavior,customClickBehavior:ge.customClickBehavior})),O&&O.length>0&&{annotations:O}),M&&{xExtent:M}),P&&{yExtent:P}),ge.crosshairProps),_);return ge.earlyReturn?ge.earlyReturn:e.jsx(gr,{componentName:"DifferenceChart",width:G,height:Y,children:e.jsx(si,Object.assign({ref:i},ke))})});"function"==typeof Xr&&(Xr.displayName="DifferenceChart");const Vr=t.forwardRef(function(o,n){const i=t.useRef(null),r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:g,lineDataAccessor:f="coordinates",colorBy:p,colorScheme:y,curve:m="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:k=2,showPoints:w=!1,pointRadius:A=3,normalize:j=!1,baseline:S="zero",stackOrder:C,tooltip:O,annotations:M,xExtent:P,yExtent:_,frameProps:L={},selection:T,linkedHover:R,onObservation:B,onClick:N,hoverHighlight:D,chartId:E,loading:I,loadingContent:H,emptyContent:F,legendInteraction:$,legendPosition:W,color:z,stroke:G,strokeWidth:Y,opacity:q}=o,{width:X,height:V,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,xLabel:oe,yLabel:ne}=r,ie=t.useMemo(()=>v(s),[s]),re=p||g;_r(n,{variant:"xy",frameRef:i});const se=Or({data:ie,rawData:s,colorBy:re,colorScheme:y,legendInteraction:$,legendPosition:W,selection:T,linkedHover:R,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:B,onClick:N,hoverHighlight:D,chartType:"StackedAreaChart",chartId:E,showLegend:Q,userMargin:a,marginDefaults:r.marginDefaults,loading:I,loadingContent:H,emptyContent:F,width:X,height:V}),{flattenedData:ae,lineStyle:le,pointStyle:ce,defaultTooltipContent:ue}=zr({safeData:ie,data:s,areaBy:g,lineDataAccessor:f,colorBy:re,colorScale:se.colorScale,color:z,stroke:G,strokeWidth:Y,opacity:q,effectiveSelectionHook:se.effectiveSelectionHook,resolvedSelection:se.resolvedSelection,areaOpacity:b,showLine:x,lineWidth:k,showPoints:w,pointRadius:A,xAccessor:d,yAccessor:h,xLabel:oe,yLabel:ne,xFormat:c,yFormat:u,groupField:g||p}),de=Ar({componentName:"StackedAreaChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),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:"stackedarea"},null!=s&&{data:ae}),{xAccessor:d,yAccessor:h,groupAccessor:g||void 0,curve:m,normalize:j,baseline:j?"zero":S,stackOrder:C,lineStyle:le}),w&&ce&&{pointStyle:ce}),{size:[X,V],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:se.margin,showAxes:r.showAxes,xLabel:oe,yLabel:ne,xFormat:c,yFormat:u,enableHover:U}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:K}),se.legendBehaviorProps),Fr({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:o.animate,axisExtent:o.axisExtent})),"multi"===O?{tooltipContent:xn(),tooltipMode:"multi"}:Wr({tooltip:O,defaultTooltipContent:ue})),$r({linkedHover:R,onObservation:B,onClick:N,hoverHighlight:D,customHoverBehavior:se.customHoverBehavior,customClickBehavior:se.customClickBehavior})),M&&M.length>0&&{annotations:M}),P&&{xExtent:P}),_&&{yExtent:_}),se.crosshairProps),L);return se.earlyReturn?se.earlyReturn:de?e.jsx(cr,{componentName:"StackedAreaChart",message:de,width:X,height:V}):e.jsx(gr,{componentName:"StackedAreaChart",width:X,height:V,children:e.jsx(si,Object.assign({ref:i},he))})});function Ur(e){const{colorBy:o,colorScale:n,color:i,pointRadius:r=5,radiusFn:s,fillOpacity:a=1,fallbackFill:l,baseStyleExtras:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:g,resolvedSelection:f,colorDatumAccessor:p}=e,y=t.useMemo(()=>e=>{const t="function"==typeof c?c(e):c,u=t?Object.assign({},t):{};if(void 0===u.fillOpacity&&(u.fillOpacity=a),void 0===u.fill)if(o){if(n){const t=p?p(e):e;u.fill=ke(t,o,n)}}else u.fill=l?l(e):i||Wi;return void 0===u.r&&(u.r=s?s(e):r),u},[o,n,i,r,s,a,l,c,p]),m=t.useMemo(()=>Mr(y,{stroke:u,strokeWidth:d,opacity:h}),[y,u,d,h]);return t.useMemo(()=>Ri(m,null!=g?g:null,f),[m,g,f])}function Kr(e){const{accessor:o,data:n,isPushMode:i}=e,r=t.useRef(null),[s,a]=t.useState(0),l=t.useCallback(e=>{if(!i||!o)return;let t=!1;for(const n of e){const e="function"==typeof o?o(n):n[o];if(null==e)continue;const i="number"==typeof e?e:Number(e);Number.isFinite(i)&&(r.current?(r.current[0]>i&&(r.current[0]=i,t=!0),i>r.current[1]&&(r.current[1]=i,t=!0)):(r.current=[i,i],t=!0))}t&&a(e=>e+1)},[i,o]),c=t.useCallback(()=>{i&&(r.current=null,a(e=>e+1))},[i]),u=t.useMemo(()=>{var e;if(i)return null!==(e=r.current)&&void 0!==e?e:void 0;if(!o||0===n.length)return;const t="function"==typeof o?o:e=>e[o];let s=1/0,a=-1/0;for(const e of n){const o=t(e);if(null==o)continue;const n="number"==typeof o?o:Number(o);Number.isFinite(n)&&(s>n&&(s=n),n>a&&(a=n))}return Number.isFinite(s)&&Number.isFinite(a)?[s,a]:void 0},[n,o,i,s]);return{domain:u,trackPushed:l,reset:c}}function Qr(e){var t;if(!e)return;const o="boolean"==typeof e?{}:"string"==typeof e?{method:e}:e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({type:"trend",method:null!==(t=o.method)&&void 0!==t?t:"linear"},null!=o.bandwidth&&{bandwidth:o.bandwidth}),null!=o.order&&{order:o.order}),null!=o.color&&{color:o.color}),null!=o.strokeWidth&&{strokeWidth:o.strokeWidth}),null!=o.strokeDasharray&&{strokeDasharray:o.strokeDasharray}),null!=o.label&&{label:o.label})}Vr.displayName="StackedAreaChart";const Zr=t.forwardRef(function(o,n){const i=t.useRef(null),r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xScaleType:g,yScaleType:f,colorBy:y,colorScheme:m,sizeBy:b,sizeRange:x=[3,15],pointRadius:k=5,pointOpacity:w=.8,tooltip:A,marginalGraphics:j,pointIdAccessor:S,annotations:C,regression:O,forecast:M,anomaly:P,xExtent:_,yExtent:L,frameProps:T={},selection:R,linkedHover:B,linkedBrush:N,onObservation:D,onClick:E,hoverHighlight:I,chartId:H,loading:F,loadingContent:$,emptyContent:W,legendInteraction:z,legendPosition:G,color:Y,stroke:q,strokeWidth:X,opacity:V}=o,{width:U,height:K,enableHover:Q,showGrid:Z,showLegend:J,title:ee,description:te,summary:oe,accessibleTable:ne,xLabel:ie,yLabel:re}=r,se=t.useMemo(()=>v(s),[s]),ae=void 0===s,{domain:le,trackPushed:ce,reset:ue}=Kr({accessor:b,data:se,isPushMode:ae}),de=t.useCallback(e=>{var t;ce([e]),null===(t=i.current)||void 0===t||t.push(e)},[ce]),he=t.useCallback(e=>{var t;ce(e),null===(t=i.current)||void 0===t||t.pushMany(e)},[ce]);_r(n,{variant:"xy",frameRef:i,overrides:{push:de,pushMany:he,clear:()=>{var e;ue(),null===(e=i.current)||void 0===e||e.clear()}},deps:[de,he,ue]});const ge=Or({data:se,rawData:s,colorBy:y,colorScheme:m,legendInteraction:z,legendPosition:G,selection:R,linkedHover:B,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:D,onClick:E,hoverHighlight:I,chartType:"Scatterplot",chartId:H,showLegend:J,userMargin:a,marginDefaults:r.marginDefaults,loading:F,loadingContent:$,emptyContent:W,width:U,height:K}),fe=Ti(N),pe=xi({name:(null==fe?void 0:fe.name)||"__unused_brush__",xField:(null==fe?void 0:fe.xField)||("string"==typeof d?d:void 0),yField:(null==fe?void 0:fe.yField)||("string"==typeof h?h:void 0)}),ye=fe?"xyBrush"===pe.brushInteraction.brush?"xy":"xBrush"===pe.brushInteraction.brush?"x":"y":void 0,me=p.useRef(pe.brushInteraction);me.current=pe.brushInteraction;const ve=t.useCallback(e=>{const t=me.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(ge.earlyReturn)return ge.earlyReturn;vr("Scatterplot",se,"xAccessor",d),vr("Scatterplot",se,"yAccessor",h);const be=t.useMemo(()=>b?null!=le?le:[0,1]:void 0,[b,le]),xe=t.useMemo(()=>b?e=>Ae(e,b,x,be):void 0,[b,x,be]),ke=Ur({colorBy:y,colorScale:ge.colorScale,color:Y,pointRadius:k,fillOpacity:w,radiusFn:xe,stroke:q,strokeWidth:X,opacity:V,effectiveSelectionHook:ge.effectiveSelectionHook,resolvedSelection:ge.resolvedSelection}),we=t.useMemo(()=>ar([{label:ie||or(d),accessor:d,role:"x",format:c},{label:re||or(h),accessor:h,role:"y",format:u},...y?[{label:or(y),accessor:y,role:"color"}]:[],...b?[{label:or(b),accessor:b,role:"size"}]:[]]),[d,h,ie,re,y,b,c,u]),{effectiveData:je,statisticalAnnotations:Se}=Ir({data:se,xAccessor:d,yAccessor:h,forecast:M,anomaly:P}),Ce=t.useMemo(()=>{const e=Qr(O);return e||0!==Se.length?[...e?[e]:[],...C||[],...Se]:C},[O,C,Se]),Oe=Ar({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(Oe)return e.jsx(cr,{componentName:"Scatterplot",message:Oe,width:U,height:K});const Me=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:je}),{xAccessor:d,yAccessor:h,xScaleType:g,yScaleType:f,colorAccessor:y||void 0,sizeAccessor:b||void 0,sizeRange:x,pointStyle:ke,colorScheme:m,size:[U,K],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ge.margin,showAxes:r.showAxes,xLabel:ie,yLabel:re,xFormat:c,yFormat:u,enableHover:Q,showGrid:Z}),ge.legendBehaviorProps),Fr({title:ee,description:te,summary:oe,accessibleTable:ne,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:A,defaultTooltipContent:we})),$r({linkedHover:B,onObservation:D,onClick:E,hoverHighlight:I,customHoverBehavior:ge.customHoverBehavior,customClickBehavior:ge.customClickBehavior})),j&&{marginalGraphics:j}),S&&{pointIdAccessor:S}),Ce&&Ce.length>0&&{annotations:Ce}),_&&{xExtent:_}),L&&{yExtent:L}),fe&&{brush:{dimension:ye},onBrush:ve}),ge.crosshairProps),T);return e.jsx(gr,{componentName:"Scatterplot",width:U,height:K,children:e.jsx(si,Object.assign({ref:i},Me))})});function Jr(e,t){return ne(1===t?.5:e/(t-1))}Zr.displayName="Scatterplot";const es=t.forwardRef(function(o,n){var i,r;const s=t.useRef(null);_r(n,{variant:"xy",frameRef:s});const a=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:g="x",yAccessor:f="y",orderAccessor:p,orderLabel:y,pointRadius:m=4,tooltip:v,pointIdAccessor:b,annotations:x,regression:k,forecast:w,anomaly:A,xExtent:j,yExtent:S,frameProps:C={},selection:O,linkedHover:M,onObservation:P,onClick:_,hoverHighlight:L,chartId:T,loading:R,loadingContent:B,emptyContent:N,legendInteraction:D,stroke:E,strokeWidth:I,opacity:H}=o,{width:F,height:$,enableHover:W,showGrid:z,title:G,description:Y,summary:q,accessibleTable:X,xLabel:V,yLabel:U}=a,K=l||[],{safeData:Q,orderMap:Z}=t.useMemo(()=>{const e="function"==typeof g?g:e=>e[g],t="function"==typeof f?f:e=>e[f];let o=K;if(p&&K.length>0){const e="function"==typeof p?p:e=>e[p];o=[...K].sort((t,o)=>{const n=e(t),i=e(o);return(n instanceof Date?n.getTime():+n)-(i instanceof Date?i.getTime():+i)})}const n=new WeakMap;let i=0;for(const n of o){const o=e(n),r=t(n);null!=o&&null!=r&&isFinite(o)&&isFinite(r)&&i++}let r=0;for(const s of o){const o=e(s),a=t(s);null!=o&&null!=a&&isFinite(o)&&isFinite(a)&&n.set(s,{idx:r++,total:i})}return{safeData:o,orderMap:n}},[K,p,g,f]);vr("ConnectedScatterplot",Q,"xAccessor",g),vr("ConnectedScatterplot",Q,"yAccessor",f);const J=Or({data:Q,rawData:l,colorBy:void 0,colorScheme:void 0,legendInteraction:D,selection:O,linkedHover:M,fallbackFields:[],unwrapData:!1,onObservation:P,onClick:_,hoverHighlight:L,chartType:"ConnectedScatterplot",chartId:T,showLegend:void 0,userMargin:c,marginDefaults:{top:50,right:40,bottom:60,left:70},loading:R,loadingContent:B,emptyContent:N,width:F,height:$}),ee=null!==(r=null===(i=J.resolvedSelection)||void 0===i?void 0:i.unselectedOpacity)&&void 0!==r?r:.5,te=t.useMemo(()=>(e,t)=>{var o,n,i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return;const a=null===(o=J.effectiveSelectionHook)||void 0===o?void 0:o.isActive,l=null===(n=J.effectiveSelectionHook)||void 0===n?void 0:n.predicate,c=100>s.length,u=s.length;e.lineCap="round";for(let t=0;u-1>t;t++){const o=s[t],n=s[t+1],d=Jr(t,u),h=!a||!l||l(null!==(i=o.datum)&&void 0!==i?i:o)||l(null!==(r=n.datum)&&void 0!==r?r:n),g=a?h?1:ee:1;c&&(e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(n.x,n.y),e.strokeStyle="white",e.lineWidth=m+2,e.globalAlpha=.5*g,e.stroke()),e.beginPath(),e.moveTo(o.x,o.y),e.lineTo(n.x,n.y),e.strokeStyle=d,e.lineWidth=m,e.globalAlpha=g,e.stroke()}e.globalAlpha=1},[m,J.effectiveSelectionHook,ee]),oe=t.useMemo(()=>[te],[te]),ne=t.useMemo(()=>(t,o,n)=>{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 o=s[t],n=s[t+1],u=Jr(t,a),d="number"==typeof(null===(i=o.style)||void 0===i?void 0:i.opacity)?o.style.opacity:1,h="number"==typeof(null===(r=n.style)||void 0===r?void 0:r.opacity)?n.style.opacity:1,g=Math.min(d,h);l&&c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:"white",strokeWidth:m+2,strokeLinecap:"round",opacity:.5*g},"halo-"+t)),c.push(e.jsx("line",{x1:o.x,y1:o.y,x2:n.x,y2:n.y,stroke:u,strokeWidth:m,strokeLinecap:"round",opacity:g},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[m]),ie=t.useMemo(()=>[ne],[ne]),re=t.useMemo(()=>e=>{var t,o;const n=Z.get(e),i=null!==(t=null==n?void 0:n.idx)&&void 0!==t?t:0,r=null!==(o=null==n?void 0:n.total)&&void 0!==o?o:1;return{fill:r>0?Jr(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,Z]),se=Ur({colorScale:void 0,baseStyleExtras:re,stroke:E,strokeWidth:I,opacity:H,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),ae=y||("string"==typeof p?p:"Order"),le=t.useMemo(()=>ar([{label:V||or(g),accessor:g,role:"x",format:d},{label:U||or(f),accessor:f,role:"y",format:h},...p?[{label:ae,accessor:p,role:"group"}]:[]]),[g,f,V,U,p,ae,d,h]),ce=Ar({componentName:"ConnectedScatterplot",data:l,accessors:{xAccessor:g,yAccessor:f}}),{effectiveData:ue,statisticalAnnotations:de}=Ir({data:Q,xAccessor:g,yAccessor:f,forecast:w,anomaly:A}),he=Qr(k),ge=he||de.length>0?[...he?[he]:[],...x||[],...de]:x,fe=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!=l&&{data:ue}),{xAccessor:g,yAccessor:f,pointStyle:se,size:[F,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,showAxes:a.showAxes,xLabel:V,yLabel:U,xFormat:d,yFormat:h,enableHover:W,showGrid:z}),Fr({title:G,description:Y,summary:q,accessibleTable:X,className:u,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:v,defaultTooltipContent:le})),$r({linkedHover:M,onObservation:P,onClick:_,hoverHighlight:L,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior})),b&&{pointIdAccessor:b}),{canvasPreRenderers:oe,svgPreRenderers:ie}),ge&&ge.length>0&&{annotations:ge}),j&&{xExtent:j}),S&&{yExtent:S}),J.crosshairProps),C);return J.earlyReturn?J.earlyReturn:ce?e.jsx(cr,{componentName:"ConnectedScatterplot",message:ce,width:F,height:$}):e.jsx(gr,{componentName:"ConnectedScatterplot",width:F,height:$,children:e.jsx(si,Object.assign({ref:s},fe))})});es.displayName="ConnectedScatterplot";const ts=t.forwardRef(function(o,n){const i=t.useRef(null),r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:g,sizeRange:f=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:x="white",tooltip:k,marginalGraphics:w,pointIdAccessor:A,annotations:j,regression:S,xExtent:C,yExtent:O,frameProps:M={},selection:P,linkedHover:_,linkedBrush:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:N,loading:D,loadingContent:E,emptyContent:I,legendInteraction:H,legendPosition:F,color:$,stroke:W,strokeWidth:z,opacity:G}=o,{width:Y,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,oe=t.useMemo(()=>v(s),[s]),ne=void 0===s,ie=Or({data:oe,rawData:s,colorBy:p,colorScheme:y,legendInteraction:H,legendPosition:F,selection:P,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:T,onClick:R,hoverHighlight:B,chartType:"BubbleChart",chartId:N,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:E,emptyContent:I,width:Y,height:q}),{domain:re,trackPushed:se,reset:ae}=Kr({accessor:g,data:oe,isPushMode:ne}),le=t.useCallback(e=>{var t;se([e]),null===(t=i.current)||void 0===t||t.push(e)},[se]),ce=t.useCallback(e=>{var t;se(e),null===(t=i.current)||void 0===t||t.pushMany(e)},[se]);_r(n,{variant:"xy",frameRef:i,overrides:{push:le,pushMany:ce,clear:()=>{var e;ae(),null===(e=i.current)||void 0===e||e.clear()}},deps:[le,ce,ae]});const ue=Ti(L);xi({name:(null==ue?void 0:ue.name)||"__unused_brush__",xField:(null==ue?void 0:ue.xField)||("string"==typeof d?d:void 0),yField:(null==ue?void 0:ue.yField)||("string"==typeof h?h:void 0)});const de=t.useMemo(()=>({stroke:x,strokeWidth:b}),[x,b]),he=t.useMemo(()=>null!=re?re:[0,1],[re]),ge=t.useCallback(e=>Ae(e,g,f,he),[g,f,he]),fe=Ur({colorBy:p,colorScale:ie.colorScale,color:$,fillOpacity:m,radiusFn:ge,baseStyleExtras:de,stroke:W,strokeWidth:z,opacity:G,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection}),pe=t.useMemo(()=>ar([{label:ee||or(d),accessor:d,role:"x",format:c},{label:te||or(h),accessor:h,role:"y",format:u},{label:or(g),accessor:g,role:"size"},...p?[{label:or(p),accessor:p,role:"color"}]:[]]),[d,h,ee,te,g,p,c,u]),ye=Ar({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:g}});if(ye)return e.jsx(cr,{componentName:"BubbleChart",message:ye,width:Y,height:q});const me=Qr(S),ve=me?[me,...j||[]]:j,be=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:oe}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:g,sizeRange:f,pointStyle:fe,colorScheme:y,size:[Y,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ie.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),ie.legendBehaviorProps),Fr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:pe})),$r({linkedHover:_,onObservation:T,onClick:R,hoverHighlight:B,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior})),w&&{marginalGraphics:w}),A&&{pointIdAccessor:A}),ve&&ve.length>0&&{annotations:ve}),C&&{xExtent:C}),O&&{yExtent:O}),ie.crosshairProps),M);return ie.earlyReturn?ie.earlyReturn:e.jsx(gr,{componentName:"BubbleChart",width:Y,height:q,children:e.jsx(si,Object.assign({ref:i},be))})});ts.displayName="BubbleChart";const os=t.forwardRef(function(o,n){var r;const s=t.useRef(null);_r(n,{variant:"xy",frameRef:s});const a=er(o.mode,{width:o.width,height:o.height,showGrid:void 0,enableHover:o.enableHover,showLegend:void 0,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:l,margin:c,className:u,xAccessor:d="x",yAccessor:h="y",valueAccessor:g="value",xFormat:f,yFormat:p,colorScheme:y,customColorScale:m,showValues:b=!1,valueFormat:x,tooltip:k,annotations:w,xExtent:A,yExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:R,emptyContent:B,showLegend:N,legendPosition:D,legendInteraction:E}=o,{width:I,height:H,enableHover:F,title:$,description:W,summary:z,accessibleTable:G,xLabel:Y,yLabel:q}=a,X=mr(T,I,H,R),V=X?null:yr(l,I,H,B),U=t.useMemo(()=>v(l),[l]),K=function(){var e;const t=$i();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.sequential)||void 0}(),ce=null!==(r=null!=y?y:K)&&void 0!==r?r:"blues",ue=null!=N&&N,de=null!=D?D:"right",{margin:he}=Qi({data:U,colorBy:ue?"value":void 0,colorScale:void 0,showLegend:ue,legendPosition:de,userMargin:c,defaults:a.marginDefaults}),{customHoverBehavior:ge,customClickBehavior:fe,crosshairSourceId:pe}=Ui({selection:C,linkedHover:O,fallbackFields:[],onObservation:M,onClick:P,chartType:"Heatmap",chartId:L,hoverHighlight:_,colorByField:void 0});Cr(C);const ye=Ki(O,pe);Zi(E,void 0,[]);const me=t.useMemo(()=>"function"==typeof g?e=>g(e):e=>e[g],[g]),ve=t.useMemo(()=>{const e=U.map(me);return[Math.min(...e),Math.max(...e)]},[U,me]),be=t.useMemo(()=>"custom"===ce&&m?m:i.scaleSequential({blues:Q,reds:Z,greens:J,viridis:ne,oranges:ee,purples:te,greys:oe,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le}[ce]||Q).domain(ve),[ce,m,ve]),xe=t.useMemo(()=>ar([{label:Y||or(d),accessor:d,role:"x",format:f},{label:q||or(h),accessor:h,role:"y",format:p},{label:or(g),accessor:g,role:"value",format:x}]),[d,h,Y,q,g,f,p,x]),ke=Ar({componentName:"Heatmap",data:l,accessors:{xAccessor:d,yAccessor:h,valueAccessor:g}}),we=t.useMemo(()=>{if(ue)return{gradient:{colorFn:e=>be(e),domain:ve,label:"string"==typeof g?g:"value",format:x}}},[ue,be,ve,g,x]),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({chartType:"heatmap"},null!=l&&{data:U}),{xAccessor:d,yAccessor:h,valueAccessor:g,colorScheme:"custom"!==ce?ce:void 0,showValues:b,heatmapValueFormat:x,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:he,showAxes:a.showAxes,xLabel:Y,yLabel:q,xFormat:f,yFormat:p,enableHover:F}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),we&&{legend:we,legendPosition:de}),Fr({title:$,description:W,summary:z,accessibleTable:G,className:u,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:xe})),$r({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:ge,customClickBehavior:fe})),w&&w.length>0&&{annotations:w}),A&&{xExtent:A}),j&&{yExtent:j}),ye),S);return X||V||(ke?e.jsx(cr,{componentName:"Heatmap",message:ke,width:I,height:H}):e.jsx(gr,{componentName:"Heatmap",width:I,height:H,children:e.jsx(si,Object.assign({ref:s},Ae))}))});os.displayName="Heatmap";const ns="__splomIdx",is={top:4,bottom:4,left:4,right:4};function rs({frameRef:i,cellSize:r,onBrush:s}){const a=t.useRef(null),l=r-is.left-is.right,c=r-is.top-is.bottom;return t.useEffect(()=>{if(!a.current)return;const e=o.select(a.current).select(".brush-g"),t=n.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const o=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!o)return;if(!e.selection)return void s(null);const[[n,r],[a,l]]=e.selection,c=[[o.x.invert(n),o.y.invert(r)],[o.x.invert(a),o.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(${is.left},${is.top})`})})}function ss({data:o,xField:n,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:g,onPointHover:f}){const p=t.useRef(null),y=mi({name:u,clientId:`splom-${n}-${i}`}),m=xi({name:u,xField:n,yField:i}),v=mi({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==f||f(null));const t=e.data,o=null==t?void 0:t[ns];void 0!==o&&(b({[ns]:[o]}),null==f||f(t,e.x+is.left,e.y+is.top))},[b,f]),w=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?ke(e,l,c):Wi,"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(si,{ref:p,chartType:"scatter",data:o,size:[r,r],xAccessor:n,yAccessor:i,pointStyle:w,margin:is,showAxes:!1,enableHover:"hover"===g,customHoverBehavior:"hover"===g?k:void 0,tooltipContent:"hover"===g?()=>null:void 0}),"brush"===g&&e.jsx(rs,{frameRef:p,cellSize:r,xField:n,yField:i,onBrush:x})]})}function as({data:o,field:n,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=mi({name:c,clientId:"splom-diag-"+n}),g=mi({name:u,clientId:`splom-diag-${n}-hover`}),f="hover"===d?g:h,p=f.isActive,y=f.predicate,m=t.useMemo(()=>{const e=o.map(e=>e[n]).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(o.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)),f=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of o){const o=e[n];if(null==o||isNaN(o))continue;const r=Math.min(Math.floor((o-t)/i),s-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 o=0;return e.map((e,n)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=i,a})}),b=f.map((e,t)=>{let o=0;return e.map((e,n)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:o,category:c[n]};return o+=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}},[o,n,s,r,p,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,o)=>t.map((t,n)=>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):Wi,opacity:p?.3:.6},`bg-${o}-${n}`))):m.bars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Wi,opacity:p?.3:.6},"bg-"+o)),p&&(m.categories.length>0?m.selectedCategoryBars.map((t,o)=>t.map((t,n)=>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):Wi,opacity:.7},`sel-${o}-${n}`))):m.selectedBars.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:Wi,opacity:.7},"sel-"+o)))]})}function ls({label:t,cellSize:o}){return e.jsx("svg",{width:o,height:o,children:e.jsx("text",{x:o/2,y:o/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function cs(o){const{data:n,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:g=20,brushMode:f="crossfilter",hoverMode:y=!0,unselectedOpacity:m=.1,showGrid:v=!1,tooltip:b,showLegend:x,idAccessor:k,className:w,onObservation:A,chartId:j}=o,S="splom",C="splom-hover",O=y?"hover":f?"brush":"hover",M=fi(e=>e.clearSelection),[P,_]=t.useState(null),L=t.useCallback(()=>{M(C),_(null)},[M,C]),T=t.useMemo(()=>(n||[]).map((e,t)=>void 0!==e[ns]?e:Object.assign(Object.assign({},e),{[ns]:t})),[n]),R=Xi(T,s,a),B=void 0!==x?x:!!s,N=t.useMemo(()=>{if(!B||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(T.map(t=>t[e]))].map(e=>({label:e+"",color:R?R(e+""):Wi})):null},[B,s,T,R]),D=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:[N&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:N.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:D,onMouseLeave:"hover"===O?L:void 0,children:[i.map((t,o)=>e.jsxs(p.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((n,i)=>o===i?"label"===h?e.jsx(ls,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(as,{data:T,field:t,label:r[t]||t,cellSize:l,bins:g,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:C,unselectedOpacity:m,mode:O},"diag-"+t):e.jsx(ss,{data:T,xField:n,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:R,brushSelectionName:S,hoverSelectionName:C,unselectedOpacity:m,showGrid:v,tooltip:b,mode:O,onPointHover:"hover"===O?(e,r,s)=>{e?(_({datum:e,xField:n,yField:t,colIndex:i,rowIndex:o,px:null!=r?r:0,py:null!=s?s:0}),A&&A({type:"hover",datum:e,x:null!=r?r:0,y:null!=s?s:0,timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:j})):(_(null),A&&A({type:"hover-end",timestamp:Date.now(),chartType:"ScatterplotMatrix",chartId:j}))}:void 0},`cell-${t}-${n}`))]},"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))]}),P&&"hover"===O&&(()=>{const t=P.datum,o=r[P.xField]||P.xField,n=r[P.yField]||P.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=k?"function"==typeof k?k(t):t[k]:"Row "+t[ns];return e.jsxs("div",{style:{position:"absolute",left:40+P.colIndex*(l+c)+P.px,top:P.rowIndex*(l+c)+P.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:[o,": ",null!=t[P.xField]?Number(t[P.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[n,": ",null!=t[P.yField]?Number(t[P.yField]).toFixed(1):"–"]}),null!=i&&e.jsxs("div",{style:{opacity:.8},children:["string"==typeof s?s:"group",": ",i+""]})]})})()]})}function us(t){const{brushMode:o="crossfilter",hoverMode:n=!0}=t,i={};return!n&&o&&(i.splom={resolution:o}),n&&(i["splom-hover"]={resolution:"union"}),e.jsx(_i,{selections:i,children:e.jsx(cs,Object.assign({},t))})}function ds({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),f=i+s.left+s.right,p=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=o.select(d.current).select(".brush-group"),t="x"===l?n.brushX().extent([[0,0],[i,r]]):n.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 o=("x"===l?a.x:a.y).invert;if(!o)return;const n=[o(t[0]),o(t[1])];u(n)}),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=o.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(g.current=!0,c){const o=[t(c[0]),t(c[1])];e.call(h.current.move,o)}else e.call(h.current.move,null);g.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:f,height:p,style:{position:"absolute",top:0,left:0,pointerEvents:"all"},children:e.jsx("g",{className:"brush-group",transform:`translate(${s.left},${s.top})`})})}function hs(o){var n,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:g,yLabel:f,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:b="y",lineBy:x,lineDataAccessor:k="coordinates",colorBy:w,colorScheme:A,curve:j="linear",lineWidth:S=2,fillArea:C=!1,areaOpacity:O=.3,showPoints:M=!1,pointRadius:P=3,enableHover:_=!0,showGrid:L=!1,showLegend:T,legendPosition:R,tooltip:B,minimap:N={},renderBefore:D=!1,onBrush:E,brushExtent:I,yExtent:H,frameProps:F={},loading:$,loadingContent:W,emptyContent:z}=o,G=mr($,s,a,W),Y=G?null:yr(r,s,a,z),q=t.useMemo(()=>v(r),[r]),[X,V]=t.useState(null),U=null!=I?I:X,K=t.useCallback(e=>{I||V(e),null==E||E(e)},[I,E]),Q=t.useRef(null),[Z,J]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const o=()=>{var n,i;if(t)return;const r=null===(i=null===(n=Q.current)||void 0===n?void 0:n.getScales)||void 0===i?void 0:i.call(n);r?J(r):e=requestAnimationFrame(o)};return e=requestAnimationFrame(o),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const ee=void 0!==(null===(n=q[0])||void 0===n?void 0:n[k]),te=t.useMemo(()=>{if(ee)return q;if(x){const e=q.reduce((e,t)=>{const o="function"==typeof x?x(t):t[x];if(!e[o]){const t={[k]:[]};"string"==typeof x&&(t[x]=o),e[o]=t}return e[o][k].push(t),e},{});return Object.values(e)}return[{[k]:q}]},[q,x,k,ee]),oe=t.useMemo(()=>ee||x?te.flatMap(e=>{const t=e[k]||[];return x&&"string"==typeof x?t.map(t=>Object.assign(Object.assign({},t),{[x]:e[x]})):t}):q,[te,k,ee,x,q]),ne=Xi(q,w,A),ie=Pr({lineWidth:S,colorBy:w,colorScale:ne,fillArea:C,areaOpacity:O}),re=t.useMemo(()=>{if(N.lineStyle)return N.lineStyle},[N.lineStyle]),se=Pr({lineWidth:1,colorBy:w,colorScale:ne}),ae=null!=re?re:se,le=t.useMemo(()=>{if(M)return e=>{const t={r:P,fillOpacity:1};return t.fill=w?ke(e.parentLine||e,w,ne):Wi,t}},[M,P,w,ne]),{legend:ce,margin:ue,legendPosition:de}=Qi({data:te,colorBy:w,colorScale:ne,showLegend:T,legendPosition:R,userMargin:l}),he=N.height||60,ge=t.useMemo(()=>{var e,t,o,n,i,r,s,a;return{top:null!==(t=null===(e=N.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=N.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(r=null===(i=N.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ue.left,right:null!==(a=null===(s=N.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:ue.right}},[N.margin,ue]),fe=N.brushDirection||"x",pe=Ar({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:b}});if(pe)return e.jsx(cr,{componentName:"MinimapChart",message:pe,width:s,height:a});const ye=C?"area":"line",me=t.useMemo(()=>ar([{label:g||or(m),accessor:m,role:"x",format:p},{label:f||or(b),accessor:b,role:"y",format:y}]),[m,b,g,f,p,y]),ve=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:ye,data:oe,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ie},M&&{pointStyle:le}),{size:[s,a],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ue,showAxes:!0,xLabel:g,yLabel:f,xFormat:p,yFormat:y,enableHover:_,showGrid:L}),ce&&{legend:ce,legendPosition:de}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),{tooltipContent:!1===B?()=>null:kn(B)||me}),U&&{xExtent:U}),H&&{yExtent:H}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),F),be=Object.assign({chartType:ye,data:oe,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ae,size:[s,he+ge.top+ge.bottom],margin:ge,showAxes:null!==(i=N.showAxes)&&void 0!==i&&i,background:N.background,enableHover:!1},H&&{yExtent:H}),xe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(si,Object.assign({ref:Q},be)),e.jsx(ds,{width:s-ge.left-ge.right,height:he,margin:ge,scales:Z,brushDirection:fe,extent:U,onBrush:K})]},"minimap"),we=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(si,Object.assign({},ve))},"main");return G||Y||e.jsx(gr,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[D?xe:we,D?we:xe]})})}us.displayName="ScatterplotMatrix",hs.displayName="MinimapChart";const gs={label:"Low / High",color:"#E9C46A",opacity:.08},fs={label:"High / High",color:"#2A9D8F",opacity:.08},ps={label:"Low / Low",color:"#E76F51",opacity:.08},ys={label:"High / Low",color:"#86BBD8",opacity:.08};function ms(e,t){var o,n,i;return{label:null!==(o=null==t?void 0:t.label)&&void 0!==o?o:e.label,color:null!==(n=null==t?void 0:t.color)&&void 0!==n?n:e.color,opacity:null!==(i=null==t?void 0:t.opacity)&&void 0!==i?i:e.opacity}}const vs=t.forwardRef(function(o,n){const i=t.useRef(null);_r(n,{variant:"xy",frameRef:i});const r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:g,yCenter:f,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:b=12,colorBy:x,colorScheme:k,sizeBy:w,sizeRange:A=[3,15],pointRadius:j=5,pointOpacity:S=.8,tooltip:C,pointIdAccessor:O,annotations:M,frameProps:P={},selection:_,linkedHover:L,onObservation:T,onClick:R,hoverHighlight:B,chartId:N,loading:D,loadingContent:E,emptyContent:I,legendInteraction:H,legendPosition:F,color:$,stroke:W,strokeWidth:z,opacity:G}=o,{width:Y,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,oe=t.useMemo(()=>({topLeft:ms(gs,null==p?void 0:p.topLeft),topRight:ms(fs,null==p?void 0:p.topRight),bottomLeft:ms(ps,null==p?void 0:p.bottomLeft),bottomRight:ms(ys,null==p?void 0:p.bottomRight)}),[p]),ne=t.useMemo(()=>v(s),[s]),ie=Or({data:ne,rawData:s,colorBy:x,colorScheme:k,legendInteraction:H,legendPosition:F,selection:_,linkedHover:L,fallbackFields:"string"==typeof x?[x]:[],unwrapData:!1,onObservation:T,onClick:R,hoverHighlight:B,chartType:"QuadrantChart",chartId:N,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:E,emptyContent:I,width:Y,height:q});vr("QuadrantChart",ne,"xAccessor",d),vr("QuadrantChart",ne,"yAccessor",h);const re=t.useMemo(()=>{if(!ne.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let o=1/0,n=-1/0,i=1/0,r=-1/0;for(const s of ne){const a=e(s),l=t(s);isFinite(a)&&(o>a&&(o=a),a>n&&(n=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=g&&isFinite(g)&&(o>g&&(o=g),g>n&&(n=g)),null!=f&&isFinite(f)&&(i>f&&(i=f),f>r&&(r=f)),o===1/0)return;const s=.1*(n-o)||1,a=.1*(r-i)||1;return{xExtent:[o-s,n+s],yExtent:[i-a,r+a]}},[ne,d,h,g,f]),se=t.useMemo(()=>{if(!w||0===ne.length)return;const e=ne.map(e=>"function"==typeof w?w(e):e[w]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[ne,w]),ae=t.useMemo(()=>"function"==typeof d?d:e=>+e[d],[d]),le=t.useMemo(()=>"function"==typeof h?h:e=>+e[h],[h]),ce=t.useMemo(()=>e=>{const t=ae(e),o=le(e),n=null!=g?t>=g:void 0,i=null!=f?o>=f:void 0;return void 0===i||void 0===n?$||Wi:i&&n?oe.topRight.color:i&&!n?oe.topLeft.color:!i&&n?oe.bottomRight.color:oe.bottomLeft.color},[ae,le,g,f,oe,$]),ue=t.useMemo(()=>w?e=>Ae(e,w,A,se):void 0,[w,A,se]),de=Ur({colorBy:x,colorScale:ie.colorScale,color:$,pointRadius:j,fillOpacity:S,radiusFn:ue,fallbackFill:ce,stroke:W,strokeWidth:z,opacity:G,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection}),he=t.useMemo(()=>{if(!ne.length)return;const e=new Set;"string"==typeof d&&e.add(d),"string"==typeof h&&e.add(h),"string"==typeof x&&e.add(x),"string"==typeof w&&e.add(w);const t=ne[0];for(const o of Object.keys(t))if(!o.startsWith("_")&&!e.has(o)&&"string"==typeof t[o])return o},[ne,d,h,x,w]),ge=t.useMemo(()=>ar([...he?[{label:he,accessor:he,role:"title"}]:[],{label:ee||or(d),accessor:d,role:"x",format:c},{label:te||or(h),accessor:h,role:"y",format:u},...x?[{label:or(x),accessor:x,role:"color"}]:[],...w?[{label:or(w),accessor:w,role:"size"}]:[]]),[he,d,h,ee,te,x,w,c,u]),fe=Ar({componentName:"QuadrantChart",data:s,accessors:{xAccessor:d,yAccessor:h}}),pe=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,o,n,i)=>{var r;if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const s=i.width,a=i.height,l=null!=g?n.x(g):s/2,c=null!=f?n.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:oe.topLeft,x:0,y:0,w:u,h:d},{config:oe.topRight,x:u,y:0,w:s-u,h:d},{config:oe.bottomLeft,x:0,y:d,w:u,h:a-d},{config:oe.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,f,oe,y]),ye=t.useMemo(()=>m?[...pe,(e,t,o,n)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const i=n.width,r=n.height,s=null!=g?o.x(g):i/2,a=null!=f?o.y(f):r/2;(null==g||isFinite(s))&&(null==f||isFinite(a))&&(e.font=`600 ${b}px sans-serif`,e.globalAlpha=.5,e.fillStyle=oe.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(oe.topLeft.label,8,8),e.fillStyle=oe.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(oe.topRight.label,i-8,8),e.fillStyle=oe.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(oe.bottomLeft.label,8,r-8),e.fillStyle=oe.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(oe.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:pe,[pe,m,b,oe,g,f]),me=t.useMemo(()=>{const e=P.canvasPreRenderers||[];return[...ye,...e]},[ye,P.canvasPreRenderers]),ve=t.useMemo(()=>{var t;const o={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,n,i)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return null;const r=i.width,s=i.height,a=null!=g?n.x(g):r/2,l=null!=f?n.y(f):s/2;if(null!=g&&!isFinite(a))return null;if(null!=f&&!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:oe.topLeft,x:0,y:0,w:c,h:u},{config:oe.topRight,x:c,y:0,w:r-c,h:u},{config:oe.bottomLeft,x:0,y:u,w:c,h:s-u},{config:oe.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,o)=>{var n;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!==(n=t.config.opacity)&&void 0!==n?n:.08},"qf-"+o):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:o.stroke,strokeWidth:o.strokeWidth,strokeDasharray:o.dashArray}),m&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+b,fill:oe.topLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:oe.topLeft.label}),e.jsx("text",{x:r-8,y:8+b,fill:oe.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:oe.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:oe.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:oe.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:oe.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:oe.bottomRight.label})]})]})}]},[g,f,oe,y,m,b]),be=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:ne}),{xAccessor:d,yAccessor:h,colorAccessor:x||void 0,sizeAccessor:w||void 0,sizeRange:A,pointStyle:de,colorScheme:k,size:[Y,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ie.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:X,showGrid:V}),re&&{xExtent:re.xExtent,yExtent:re.yExtent}),ie.legendBehaviorProps),K&&{title:K}),Q&&{description:Q}),Z&&{summary:Z}),void 0!==J&&{accessibleTable:J}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:!1===C?()=>null:!0===C||void 0===C?ge:kn(C)||ge}),(L||T||R||B)&&{customHoverBehavior:ie.customHoverBehavior}),(T||R||L)&&{customClickBehavior:ie.customClickBehavior}),O&&{pointIdAccessor:O}),M&&M.length>0&&{annotations:M}),{canvasPreRenderers:me}),ie.crosshairProps),P),me.length>0&&{canvasPreRenderers:me}),{svgPreRenderers:ve});return ie.earlyReturn?ie.earlyReturn:fe?e.jsx(cr,{componentName:"QuadrantChart",message:fe,width:Y,height:q}):e.jsx(gr,{componentName:"QuadrantChart",width:Y,height:q,children:e.jsx(si,Object.assign({ref:i},be))})});vs.displayName="QuadrantChart";const bs="__ma_unitized",xs="__ma_series";function ks(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function ws(e,t){return t[0]+e*(t[1]-t[0])}const As=t.forwardRef(function(o,n){var i;const r=t.useRef(null),s=t.useRef([]),a=t.useRef(o.series);a.current=o.series,t.useImperativeHandle(n,()=>{const e=()=>{var e;return(null!==(e=a.current)&&void 0!==e?e:[]).filter(e=>null!=e&&"object"==typeof e)};return{push:t=>{if(!r.current)return;const o=e(),n=t;for(let e=0;o.length>e&&2>e;e++){const t=o[e],i=t.extent||s.current[e];if(!i)continue;const a=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(n);null!=a&&isFinite(a)&&r.current.push(Object.assign(Object.assign({},n),{[bs]:ks(a,i),[xs]:t.label||"Series "+(e+1)}))}},pushMany:t=>{if(!r.current)return;const o=e(),n=[];for(const e of t)for(let t=0;o.length>t&&2>t;t++){const i=o[t],r=i.extent||s.current[t];if(!r)continue;const a=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(e);null!=a&&isFinite(a)&&n.push(Object.assign(Object.assign({},e),{[bs]:ks(a,r),[xs]:i.label||"Series "+(t+1)}))}r.current.pushMany(n)},remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},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 l=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,xLabel:o.xLabel,accessibleTable:o.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:g="x",series:f,colorScheme:y,curve:m="monotoneX",lineWidth:b=2,tooltip:x,annotations:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,chartId:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:R,stroke:B,strokeWidth:N,opacity:D}=o,{width:E,height:I,enableHover:H,showGrid:F,showLegend:$=!0,title:W,description:z,summary:G,accessibleTable:Y,xLabel:q}=l,X=t.useMemo(()=>v(c),[c]),V=t.useMemo(()=>v(f),[f]),U=V,K=2===V.length;"undefined"==typeof process||"production"===(null===(i=process.env)||void 0===i?void 0:i.NODE_ENV)||K||console.warn(`[MultiAxisLineChart] Expected exactly 2 series for dual-axis mode, got ${V.length}. Rendering as a standard multi-line chart.`);const Q=mr(P,E,I,_),Z=Q?null:yr(c,E,I,L),J=Yi(),ee=t.useMemo(()=>{let e;if(Array.isArray(y))e=y;else if(J&&J.length>0)e=J;else{const t=ye[y];e=Array.isArray(t)?t:me}return U.map((t,o)=>t.color||e[o%e.length])},[U,y,J]),te=t.useMemo(()=>V.map((e,t)=>e.label||"Series "+(t+1)),[V]),{unitizedData:oe,extents:ne}=t.useMemo(()=>{if(0===X.length){const e=V.map(e=>e.extent||null).filter(Boolean);return e.length===V.length&&(s.current=e),{unitizedData:[],extents:e.length===V.length?e:[]}}const e=V.map(e=>e.extent||function(e,t){let o=1/0,n=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(o>e&&(o=e),e>n&&(n=e))}if(!isFinite(o)||!isFinite(n))return[0,1];if(o===n){const e=0===o?1:.1*Math.abs(o);return[o-e,n+e]}return[o,n]}(X,e.yAccessor));if(s.current=e,!K){const t=[];for(const e of X)for(let o=0;V.length>o;o++){const n=V[o],i=("function"==typeof n.yAccessor?n.yAccessor:e=>e[n.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[bs]:i,[xs]:te[o]}))}return{unitizedData:t,extents:e}}const t=[];for(const o of X)for(let n=0;2>n;n++){const i=V[n],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(o);null!=r&&t.push(Object.assign(Object.assign({},o),{[bs]:ks(r,e[n]),[xs]:te[n]}))}return{unitizedData:t,extents:e}},[X,V,K,te]),ie=t.useMemo(()=>{if(K&&ne.length>=2)return[{orient:"left",label:te[0],tickFormat:V[0].format||(e=>{const t=ws(e,ne[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:te[1],tickFormat:V[1].format||(e=>{const t=ws(e,ne[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[K,ne,V,te]),re=Or({data:t.useMemo(()=>oe.length>0?oe:te.map(e=>({[xs]:e})),[oe,te]),rawData:c,colorBy:xs,colorScheme:ee,legendInteraction:T,legendPosition:R,selection:A,linkedHover:j,fallbackFields:[xs],unwrapData:!1,onObservation:S,onClick:C,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:M,showLegend:$,userMargin:u,marginDefaults:K?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:P,loadingContent:_,emptyContent:L,width:E,height:I});if(re.earlyReturn)return re.earlyReturn;const se=t.useMemo(()=>{const e=new Map;return te.forEach((t,o)=>e.set(t,ee[o])),e},[te,ee]),ae=Pr({lineWidth:b,resolveStroke:t.useCallback(e=>se.get(e[xs])||ee[0],[se,ee]),stroke:B,strokeWidth:N,opacity:D,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection}),le=t.useMemo(()=>{if(!1===x)return()=>null;return kn(x)||(e=>{var t;const o=e.data||e,n=o[xs],i=te.indexOf(n),r=o[bs],s=K&&i>=0&&ne[i]?ws(r,ne[i]):r,a=i>=0&&(null===(t=V[i])||void 0===t?void 0:t.format)?V[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof g?g(o):o[g];return p.createElement("div",{style:{padding:"6px 10px",fontFamily:"var(--semiotic-font-family, sans-serif)",fontSize:"var(--semiotic-tooltip-font-size, 13px)"}},p.createElement("div",{style:{fontWeight:600,marginBottom:4,color:ee[i]||"inherit"}},n),p.createElement("div",null,`${"string"==typeof g?g:"x"}: ${l}`),p.createElement("div",null,`${n}: ${a(s)}`))})},[x,te,ee,ne,K,V,g]),ce=Ar({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:g}}),ue=K?[0,1]:void 0,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(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"line"},null!=c&&{data:oe}),{xAccessor:g,yAccessor:bs,groupAccessor:xs,lineStyle:ae,colorScheme:ee,size:[E,I],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:re.margin,showAxes:l.showAxes}),ie&&{axes:ie}),{xLabel:q}),K?{}:{yLabel:te[0]}),{xFormat:h}),K&&ue&&{yExtent:ue}),{enableHover:H}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),{showGrid:F,curve:m}),re.legendBehaviorProps),W&&{title:W}),z&&{description:z}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),d&&{className:d}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:le}),k&&{annotations:k}),(j||S||C||O)&&{customHoverBehavior:re.customHoverBehavior}),(S||C||j)&&{customClickBehavior:re.customClickBehavior}),re.crosshairProps),w);return Q||Z||(ce?e.jsx(cr,{componentName:"MultiAxisLineChart",message:ce,width:E,height:I}):e.jsx(gr,{componentName:"MultiAxisLineChart",width:E,height:I,children:e.jsx(si,Object.assign({ref:r},de))}))});As.displayName="MultiAxisLineChart";const js=t.forwardRef(function(o,n){const i=t.useRef(null);_r(n,{variant:"xy",frameRef:i});const r=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,title:o.title,xLabel:o.xLabel,yLabel:o.yLabel,description:o.description,summary:o.summary,accessibleTable:o.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:g="low",openAccessor:f,closeAccessor:p,candlestickStyle:y,tooltip:m,annotations:b,xExtent:x,yExtent:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:C,chartId:O,loading:M,loadingContent:P,emptyContent:_}=o,{width:L,height:T,enableHover:R,showGrid:B,title:N,description:D,summary:E,accessibleTable:I,xLabel:H,yLabel:F}=r,$=mr(M,L,T,P),W=$?null:yr(s,L,T,_),z=t.useMemo(()=>v(s),[s]),G=null==f||null==p;vr("CandlestickChart",z,"xAccessor",d),vr("CandlestickChart",z,"highAccessor",h),vr("CandlestickChart",z,"lowAccessor",g),G||(vr("CandlestickChart",z,"openAccessor",f),vr("CandlestickChart",z,"closeAccessor",p));const{customHoverBehavior:Y,customClickBehavior:q,crosshairSourceId:X}=Ui({selection:A,linkedHover:j,onObservation:S,onClick:C,chartType:"CandlestickChart",chartId:O}),V=Ki(j,X),U=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===o.mode?Object.assign(Object.assign({},e),{top:0,bottom:0}):e;return null==a?t:Object.assign(Object.assign({},t),function(e){if(null==e)return;if("number"==typeof e)return{top:e,right:e,bottom:e,left:e};const t={};return"number"==typeof e.top&&(t.top=e.top),"number"==typeof e.right&&(t.right=e.right),"number"==typeof e.bottom&&(t.bottom=e.bottom),"number"==typeof e.left&&(t.left=e.left),t}(a))},[a,r.marginDefaults,o.mode]),K=t.useMemo(()=>{const e=[{label:H||or(d),accessor:d,role:"x",format:c}];return G?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:g,format:u})):(e.push({label:"Open",accessor:f,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:g,format:u}),e.push({label:"Close",accessor:p,format:u})),ar(e)},[d,H,c,u,h,g,f,p,G]),Q=Ar({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:g},!G&&{openAccessor:f,closeAccessor:p})}),Z=Math.max(2,Math.min(12,Math.round(L/40))),J=L>200?.1:.02,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({chartType:"candlestick"},null!=s&&{data:z}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:g}),!G&&{openAccessor:f,closeAccessor:p}),y&&{candlestickStyle:y}),{scalePadding:Z,extentPadding:J,size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:U,showAxes:r.showAxes,xLabel:H,yLabel:F,xFormat:c,yFormat:u,enableHover:R,showGrid:B}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),Fr({title:N,description:D,summary:E,accessibleTable:I,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:K})),$r({linkedHover:j,onObservation:S,onClick:C,customHoverBehavior:Y,customClickBehavior:q})),b&&b.length>0&&{annotations:b}),x&&{xExtent:x}),k&&{yExtent:k}),V),w);return $||W||(Q?e.jsx(cr,{componentName:"CandlestickChart",message:Q,width:L,height:T}):e.jsx(gr,{componentName:"CandlestickChart",width:L,height:T,children:e.jsx(si,Object.assign({ref:i},ee))}))});function Ss(e,t){var o;const{columns:n,config:i,resolvePieceStyle:r}=e,s=[],a=Math.min(t.width,t.height)/2-4,l="donut"===i.chartType?i.innerRadius||60:0,c=-Math.PI/2+(i.startAngle||0)*Math.PI/180,u=null!=i.sweepAngle?i.sweepAngle*Math.PI/180:2*Math.PI,d=null!=i.sweepAngle&&360>i.sweepAngle,h=Object.values(n),g=h.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),f=d&&!g&&h.length>1&&(null!==(o=i.cornerRadius)&&void 0!==o?o:0)>0;for(let e=0;h.length>e;e++){const t=h[e],o=t.pieceData[0],n="number"==typeof(null==o?void 0:o._pctStart)?o._pctStart:t.pctStart,d=c+n*u,g=c+(n+("number"==typeof(null==o?void 0:o._pct)?o._pct:t.pct))*u,p=r(t.pieceData[0],t.name),y=0===e,m=e===h.length-1,v=Object.assign(Object.assign({type:"wedge",cx:0,cy:0,innerRadius:l,outerRadius:a,startAngle:d,endAngle:g},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:p,datum:(null==o?void 0:o._nonInteractive)?null:t.pieceData,category:t.name});(null==o?void 0:o._roundedEnds)?v.roundedEnds=o._roundedEnds:f&&(v.roundedEnds={start:y,end:m}),(null==o?void 0:o._gradientBand)&&(v._gradientBand=o._gradientBand),s.push(v)}return s}function Cs(e){var t,o,n;const i=e.length,r=e[0],s=e[i-1];return{n:i,min:r,q1:null!==(t=a.quantile(e,.25))&&void 0!==t?t:r,median:null!==(o=a.quantile(e,.5))&&void 0!==o?o:(r+s)/2,q3:null!==(n=a.quantile(e,.75))&&void 0!==n?n:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}function Os(e,t,o){if(Array.isArray(e)&&e.length>0)return e;if("string"==typeof e){const t=ye[e];if(Array.isArray(t)&&t.length>0)return t}return t&&t.length>0?t:o}function Ms(e){return 0===e.length?()=>"#4e79a7":t=>{var o;let n=0;for(let e=0;t.length>e;e++)n=31*n+t.charCodeAt(e)|0;return null!==(o=e[Math.abs(n)%e.length])&&void 0!==o?o:"#4e79a7"}}js.displayName="CandlestickChart";const Ps={bar:function(e,t){var o,n,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p="horizontal"===h,y=a.normalize,m=[];if(c){const e=new Set;for(const t of Object.values(s))for(const o of t.pieceData){const t=c(o);e.has(t)||(e.add(t),m.push(t))}}else m.push("_default");for(const e of Object.values(s)){const t=new Map;for(const o of e.pieceData){const e=c?c(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const n=t.get(e);n.total+=l(o),n.pieces.push(o)}let o=0;if(y)for(const e of t.values())o+=Math.abs(e.total);let n=0,i=0;for(const r of m){const s=t.get(r);if(!s)continue;let a=s.total;y&&o>0&&(a/=o);const l=u(s.pieces[0],c?r:e.name),h=Object.assign(Object.assign({},s.pieces[0]),{__aggregateValue:s.total,__pieceCount:s.pieces.length,category:e.name});if(f){const t=d(0>a?i:n+a),o=0>a?d(i+a)-d(i):d(n)-d(n+a);g.push($(e.x,t,e.width,Math.abs(o),l,h,r)),0>a?i+=a:n+=a}else if(p){const t=d(0>a?i+a:n),o=0>a?d(i)-d(i+a):d(n+a)-d(n);g.push($(t,e.x,Math.abs(o),e.width,l,h,r)),0>a?i+=a:n+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const e of g){if("rect"!==e.type)continue;const t=null!==(n=null===(o=e.datum)||void 0===o?void 0:o.__aggregateValue)&&void 0!==n?n:0;e.roundedEdge=v?0>t?"bottom":"top":0>t?"left":"right",a.gradientFill&&(e.fillGradient=a.gradientFill)}if(b>0){const e=new Map;for(const t of g){if("rect"!==t.type)continue;const o=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(o)||e.set(o,[]),e.get(o).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>{var t,o;return(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)>=0}),o=t.filter(e=>{var t,o;return 0>(null!==(o=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==o?o:0)});e.length>0&&(e.reduce(v?(e,t)=>t.y>e.y?e:t:(e,t)=>e.x+e.w>t.x+t.w?e:t).roundedTop=b),o.length>0&&(o.reduce(v?(e,t)=>e.y+e.h>t.y+t.h?e:t:(e,t)=>t.x>e.x?e:t).roundedTop=b)}}return g},clusterbar:function(e,t){const{scales:o,columns:n,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="vertical"===c,h=[],g=new Set;for(const e of Object.values(n))for(const t of e.pieceData){const e=s?s(t):"_default";g.has(e)||(g.add(e),h.push(e))}const f=h.length||1;for(const e of Object.values(n)){const t=e.width/f,o=.2*t,n=t-o,i=new Map;for(const t of e.pieceData){const e=s?s(t):"_default";i.has(e)||i.set(e,[]),i.get(e).push(t)}for(let s=0;h.length>s;s++){const c=i.get(h[s])||[];for(const i of c){const c=r(i),g=a(i,h[s]);if(d){const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push($(r,Math.min(a,d),n,Math.abs(a-d),g,i,h[s]))}else{const r=e.x+s*t+o/2,a=l(0),d=l(c);u.push($(Math.min(a,d),r,Math.abs(d-a),n,g,i,h[s]))}}}}const p=i.roundedTop&&i.roundedTop>0?Math.max(0,i.roundedTop):0;for(const e of u){if("rect"!==e.type)continue;if(null==e.datum)continue;const t=r(e.datum);p>0&&(e.roundedTop=p),e.roundedEdge=d?0>t?"bottom":"top":0>t?"left":"right",i.gradientFill&&(e.fillGradient=i.gradientFill)}return u},point:function(e,t){var o,n;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=i,d=[],h="vertical"===u,g="radial"===u,f=a.length>0,p=2*Math.PI,y=-Math.PI/2;for(const e of Object.values(r))for(const t of e.pieceData){const i=null!==(o=t.__rIndex)&&void 0!==o?o:0,r=null!==(n=t.__rValue)&&void 0!==n?n:s(t),u=f&&a[i]||c,m=l(t,e.name),v=m.r||5;let b,x;if(g){const t=y+(e.pctStart+e.pct/2)*p,o=u(r);b=Math.cos(t)*o,x=Math.sin(t)*o}else h?(b=e.middle,x=u(r)):(b=u(r),x=e.middle);d.push({type:"point",x:b,y:x,r:v,style:m,datum:t})}return d},swarm:function(e,t){const{scales:o,columns:n,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="vertical"===a;for(const e of Object.values(n)){const t=e.width/2;for(let o=0;e.pieceData.length>o;o++){const n=e.pieceData[o],a=i(n),u=r(n,e.name),d=u.r||4,h=(7919*o%100/100-.5)*t*.8,g=c?e.middle+h:s(a),f=c?s(a):e.middle+h;l.push({type:"point",x:g,y:f,r:d,style:u,datum:n})}}return l},pie:Ss,donut:Ss,boxplot:function(e,t){var o,n,i,r,s,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:g}=e,{r:f,projection:p}=c,y=[],m="vertical"===p,v=!1!==d.showOutliers;for(const t of Object.values(u)){const c=t.pieceData.map(e=>h(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(0===c.length)continue;const u=c[0],d=c[c.length-1],p=null!==(o=a.quantile(c,.25))&&void 0!==o?o:u,b=null!==(n=a.quantile(c,.5))&&void 0!==n?n:(u+d)/2,x=null!==(i=a.quantile(c,.75))&&void 0!==i?i:d,k=x-p,w=p-1.5*k,A=x+1.5*k,j=null!==(r=c.find(e=>e>=w))&&void 0!==r?r:u,S=null!==(s=[...c].reverse().find(e=>A>=e))&&void 0!==s?s:d,C=g(t.pieceData[0],t.name),O=[];if(v)for(const e of t.pieceData){const o=h(e);if(w>o||o>A){const n=m?t.middle:f(o),i=m?f(o):t.middle;O.push({px:n,py:i,value:o,datum:e})}}if(y.push({type:"boxplot",x:m?t.middle:0,y:m?0:t.middle,projection:m?"vertical":"horizontal",columnWidth:.6*t.width,minPos:f(j),q1Pos:f(p),medianPos:f(b),q3Pos:f(x),maxPos:f(S),stats:{n:c.length,min:j,q1:p,median:b,q3:x,max:S,mean:c.reduce((e,t)=>e+t,0)/c.length},style:C,datum:t.pieceData,category:t.name,outliers:O}),v)for(const t of O)y.push({type:"point",x:t.px,y:t.py,r:3,style:{fill:C.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:.6},datum:t.datum})}return y},violin:function(e,t){var o,n,i;const{scales:r,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=r,g=[],f="vertical"===h,p=l.bins||20,y=!1!==l.showIQR;for(const e of Object.values(s)){const t=e.pieceData.map(e=>c(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const r=t[0],s=t[t.length-1],l=(s-r)/p||1,h=Array(p).fill(0);for(const e of t)h[Math.min(Math.floor((e-r)/l),p-1)]++;const m=Math.max(...h,1),v=e.width/2*.9;let b="";if(f){b=`M ${e.middle} ${d(r)}`;for(let t=0;p>t;t++){const o=d(r+(t+.5)*l);b+=` L ${e.middle+h[t]/m*v} ${o}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const o=d(r+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${o}`}b+=" Z"}else{b=`M ${d(r)} ${e.middle}`;for(let t=0;p>t;t++)b+=` L ${d(r+(t+.5)*l)} ${e.middle-h[t]/m*v}`;b+=` L ${d(s)} ${e.middle}`;for(let t=p-1;t>=0;t--)b+=` L ${d(r+(t+.5)*l)} ${e.middle+h[t]/m*v}`;b+=" Z"}const x=u(e.pieceData[0],e.name);let k;if(y&&t.length>=4){const l=null!==(o=a.quantile(t,.25))&&void 0!==o?o:r,c=null!==(n=a.quantile(t,.5))&&void 0!==n?n:(r+s)/2,u=null!==(i=a.quantile(t,.75))&&void 0!==i?i:s;k={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:f}}const w=f?{x:e.x,y:Math.min(d(s),d(r)),width:e.width,height:Math.abs(d(s)-d(r))}:{x:Math.min(d(r),d(s)),y:e.x,width:Math.abs(d(s)-d(r)),height:e.width};g.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:w,iqrLine:k,stats:Cs(t),style:x,datum:e.pieceData,category:e.name})}return g},histogram:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l}=n,c=[],u=r.bins||25,d=r.normalize,h=null===(o=l.domain)||void 0===o?void 0:o.call(l),g=h?+h[0]:void 0,f=h?+h[1]:void 0;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e));if(0===t.length)continue;const o=null!=g&&isFinite(g)?g:Math.min(...t),n=null!=f&&isFinite(f)?f:Math.max(...t),i=(n-o)/u||1,r=Array(u).fill(0);for(const e of t)o>e||e>n||r[Math.min(Math.floor((e-o)/i),u-1)]++;const h=t.length,p=Math.max(...r,1),y=a(e.pieceData[0],e.name);for(let t=0;u>t;t++){if(0===r[t])continue;const n=(d?r[t]/h:r[t]/p)*e.width*.9,s=l(o+t*i),a=l(o+(t+1)*i);c.push($(Math.min(s,a),e.x+e.width-n,Math.abs(a-s),n,y,{bin:t,count:r[t],range:[o+t*i,o+(t+1)*i],category:e.name},e.name))}}return c},ridgeline:function(e,t){var o;const{scales:n,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=n,u=[],d=r.bins||20,h="horizontal"===c,g=r.amplitude||1.5;for(const e of Object.values(i)){const t=e.pieceData.map(e=>s(e)).filter(e=>null!=e&&!isNaN(e)).sort((e,t)=>e-t);if(2>t.length)continue;const n=t[0],i=t[t.length-1],r=(i-n)/d||1,c=Array(d).fill(0);for(const e of t)n>e||e>i||c[Math.min(Math.floor((e-n)/r),d-1)]++;const f=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*g;let m="";if(h){const t=e.x+e.width;m=`M ${l(n)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(n+(e+.5)*r)} ${t-c[e]/f*y}`;m+=` L ${l(i)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(n)}`;for(let e=0;d>e;e++){const o=l(n+(e+.5)*r);m+=` L ${t+c[e]/f*y} ${o}`}m+=` L ${t} ${l(i)} Z`}const v=h?{x:Math.min(l(n),l(i)),y:e.x,width:Math.abs(l(i)-l(n)),height:e.width}:{x:e.x,y:Math.min(l(i),l(n)),width:e.width,height:Math.abs(l(i)-l(n))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:Cs(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(o=p.fillOpacity)&&void 0!==o?o:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:o,columns:n,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=o,l=[],c="horizontal"===a;for(const e of Object.values(n))for(const t of e.pieceData){const o=i(t);if(!o)continue;const[n,a]=o,u=r(t,e.name);if(c){const o=s(Math.min(n,a)),i=s(Math.max(n,a));l.push($(o,e.x,i-o,e.width,u,t,e.name))}else{const o=s(Math.max(n,a)),i=s(Math.min(n,a));l.push($(e.x,o,e.width,i-o,u,t,e.name))}}return l},funnel:function(e,t){var o,n,r,s,a,l,c,u;const{columns:d,getR:h,getStack:g,resolvePieceStyle:f}=e,p=[],y=t.width/2,m=!1!==e.config.showLabels,v=e.scales.o.domain().map(e=>d[e]).filter(Boolean);if(0===v.length)return p;const b=[],x=new Set;for(const e of v)for(const t of e.pieceData){const e=g?g(t):"_default";x.has(e)||(x.add(e),b.push(e))}const k=b.length>1&&"_default"!==b[0],w=[];let A=0;for(const e of v){const t=new Map;let o=0;for(const n of e.pieceData){const e=g?g(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=h(n);i.total+=r,i.pieces.push(n),o+=r}w.push({col:e,groups:t,stepTotal:o}),k||o>A&&(A=o)}if(k)for(const e of w){let t=0,o=0;for(let n=0;b.length>n;n++){const i=e.groups.get(b[n]);i&&(n%2==0?t+=i.total:o+=i.total)}const n=Math.max(t,o);n>A&&(A=n)}if(0===A)return p;const j=new Map;for(const e of b){const t=w[0].groups.get(e);j.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const S=w[0].stepTotal,C=k?.95*y:.9*t.width,O=i.scaleLinear().domain([0,A]).range([0,C]),M=null!==(n=e.config.connectorOpacity)&&void 0!==n?n:.3;let P=new Map;for(let t=0;w.length>t;t++){const o=w[t],n=o.col,i=0===t,d=n.width,h=.55*d,g=n.x+(d-h)/2,v=new Map;if(k){let e=0;for(const t of b){const n=o.groups.get(t);n&&(e+=O(n.total))}let t=y,r=y;for(let s=0;b.length>s;s++){const l=b[s],c=o.groups.get(l);if(!c)continue;const u=O(c.total),d=s%2==0,x=d?t:r-u;d?t+=u:r-=u;const k=f(c.pieces[0],l),w=null!==(a=j.get(l))&&void 0!==a?a:c.total,A=w>0?c.total/w*100:0,S=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:n.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(S.__funnelStepLabel=n.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=g,S.__funnelRowWidth=e),S.__funnelValueLabelX=x+u/2,S.__funnelValueLabelY=g,S.__funnelBarW=u),p.push($(x,g,u,h,k,S,l)),v.set(l,{x:x,y:g,w:u,h:h})}}else{const e=o.stepTotal,t=O(e),a=y-t/2,l=b[0],c="_default"!==l,u=null!==(s=null===(r=o.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:n.pieceData[0],d=c?l:n.name,x=f(u,d),k=S>0?e/S*100:0,w=Object.assign(Object.assign({},u),{__funnelValue:e,__funnelPercent:k,__funnelStep:n.name,__funnelIsFirstStep:i,category:c?l:n.name});m&&(w.__funnelStepLabel=n.name,w.__funnelStepLabelX=y,w.__funnelStepLabelY=g,w.__funnelRowWidth=t,w.__funnelValueLabelX=y,w.__funnelValueLabelY=g,w.__funnelBarW=t),p.push($(a,g,t,h,x,w,d)),v.set(l,{x:a,y:g,w:t,h:h})}if(t>0&&P.size>0){const t=k?b:[b[0]];for(const i of t){const t=P.get(i),r=v.get(i);if(!t||!r)continue;const s=(()=>{const e=o.groups.get(i);return f(e?e.pieces[0]:n.pieceData[0],"_default"===i?n.name:i)})(),a={type:"trapezoid",points:[[t.x,t.y+t.h],[t.x+t.w,t.y+t.h],[r.x+r.w,r.y],[r.x,r.y]],style:{fill:s.fill||(null===(l=e.config.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",opacity:M},datum:null!==(u=null===(c=o.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:n.pieceData[0],category:"_default"===i?n.name:i};p.push(a)}}P=v}return p},"bar-funnel":function(e,t){var o,n,i,r;const{columns:s,getR:a,getStack:l,resolvePieceStyle:c,scales:u}=e,d=[],h=u.o.domain().map(e=>s[e]).filter(Boolean);if(0===h.length)return d;const g=[],f=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";f.has(e)||(f.add(e),g.push(e))}const p=g.length>1&&"_default"!==g[0],y=[];for(const e of h){const t=new Map;let o=0;for(const n of e.pieceData){const e=l?l(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=a(n);i.total+=r,i.pieces.push(n),o+=r}y.push({col:e,groups:t,stepTotal:o})}const m=new Map;for(const e of g){const t=null===(o=y[0])||void 0===o?void 0:o.groups.get(e);m.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const v=u.r,b=p?g.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],o=t.col,n=0===e,s=e>0?y[e-1]:null,a=o.width/b,l=a*x,u=a-l;for(let e=0;g.length>e;e++){const h=g[e],f=t.groups.get(h);if(!f)continue;const y=f.total,b=null!==(i=m.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,k=null==s?void 0:s.groups.get(h),w=null!==(r=null==k?void 0:k.total)&&void 0!==r?r:y,A=n?0:Math.max(0,w-y),j=o.x+e*a+l/2,S=v(y),C=v(0)-S,O=c(f.pieces[0],p?h:o.name),M=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:n,__barFunnelIsDropoff:!1,__barFunnelStep:o.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name,__barFunnelLabelX:j+u/2,__barFunnelLabelY:v(y+A)});if(d.push($(j,S,u,C,O,M,p?h:o.name)),A>0){const e=v(y+A),t=S-e,n=Object.assign({},O),i=Object.assign(Object.assign({},f.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:o.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:o.name});d.push($(j,e,u,t,n,i,p?h:o.name))}}}return d},swimlane:function(e,t){var o;const{scales:n,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],d="horizontal"===c,h=e.config.gradientFill,g=d?"left":"bottom",f=e.config.trackFill;if(f){const e="string"==typeof f?f:f.color,t="string"==typeof f?1:null!==(o=f.opacity)&&void 0!==o?o:1,[n,r]=l.range(),s=Math.min(n,r),a=Math.abs(r-n);for(const o of Object.values(i)){const n={fill:e,opacity:t},i=d?$(s,o.x,a,o.width,n,null,"__track__"):$(o.x,s,o.width,a,n,null,"__track__");u.push(i)}}const p=e.config.roundedTop&&e.config.roundedTop>0?Math.max(0,e.config.roundedTop):0;for(const e of Object.values(i)){let t=0;const o=u.length;for(const o of e.pieceData){const n=Math.abs(r(o));if(0===n)continue;const i=s?s(o):e.name,c=a(o,i);let f;if(d){const r=l(t),s=l(t+n);f=$(r,e.x,s-r,e.width,c,o,i)}else{const r=l(t+n),s=l(t);f=$(e.x,r,e.width,s-r,c,o,i)}h&&(f.fillGradient=h,f.roundedEdge=g),u.push(f),t+=n}if(p>0&&u.length>o){const e=u.slice(o),t=e[0],n=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(t.cornerRadii={tl:p,bl:p},n.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},n.cornerRadii={tl:p,tr:p})}}return u}};class _s{constructor(e){this.rExtent=new N,this.rExtents=[],this.rAccessors=[],this.categories=new Set,this._hasStreamingData=!1,this._colorSchemeMap=null,this._colorSchemeIndex=0,this.timestampBuffer=null,this.activeTransition=null,this.prevPositionMap=new Map,this.exitNodes=[],this.lastIngestTime=0,this.scales=null,this.multiScales=[],this.scene=[],this.columns={},this.customLayoutOverlays=null,this.version=0,this._dataVersion=0,this._pointQuadtree=null,this._maxPointRadius=0,this._datumIndexCache=null,this._categoryIndexCache=null,this._hasRenderedOnce=!1,this.config=e,this.buffer=new B(e.windowSize),this.getO=q(e.categoryAccessor||e.oAccessor,"category");const t=e.valueAccessor||e.rAccessor;Array.isArray(t)?(this.rAccessors=t.map(e=>G(e,"value")),this.getR=this.rAccessors[0],this.rExtents=t.map(()=>new N)):(this.getR=G(t,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent]),this.getStack=q(e.stackBy),this.getGroup=q(e.groupBy),this.getColor=q(e.colorAccessor),this.getConnector=q(e.connectorAccessor),this.getDataId=q(e.dataIdAccessor),e.pulse&&(this.timestampBuffer=new B(e.windowSize))}ingest(e){const t="undefined"!=typeof performance?performance.now():Date.now();if(this.lastIngestTime=t,this._dataVersion++,e.bounded){this.buffer.clear(),this.rExtent.clear();for(const e of this.rExtents)e.clear();e.preserveCategoryOrder?this._hasStreamingData=!0:this.categories.clear(),this.timestampBuffer&&this.timestampBuffer.clear();const o=e.totalSize||e.inserts.length;o>this.buffer.capacity&&(this.buffer.resize(o),this.timestampBuffer&&o>this.timestampBuffer.capacity&&this.timestampBuffer.resize(o));for(const o of e.inserts)this.buffer.push(o),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o)}else{this._hasStreamingData=!0;for(const o of e.inserts){const e=this.buffer.push(o);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(o)),this.pushValueExtent(o),null!=e&&this.evictValueExtent(e)}}return!0}pushValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.push(t[0]),this.rExtent.push(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].push(this.rAccessors[t](e));this.rExtent.push(this.getR(e))}else this.rExtent.push(this.getR(e))}evictValueExtent(e){if("timeline"===this.config.chartType){const t=this.getRawRange(e);t&&(this.rExtent.evict(t[0]),this.rExtent.evict(t[1]))}else if(this.rAccessors.length>1){for(let t=0;this.rAccessors.length>t;t++)this.rExtents[t].evict(this.rAccessors[t](e));this.rExtent.evict(this.getR(e))}else this.rExtent.evict(this.getR(e))}getRawRange(e){const t=this.config.valueAccessor||this.config.rAccessor;if(!t)return null;const o="function"==typeof t?t(e):e[t];return Array.isArray(o)&&o.length>=2?[+o[0],+o[1]]:null}computeScene(e){const{config:t,buffer:o}=this;if(0===o.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(o,this.getR);const n=o.toArray(),r=t.projection||"vertical",s=t.oExtent||this.resolveCategories(n),a=this.computeValueDomain(n,s),l="horizontal"===r,c="radial"===r,u=Math.min(.9,Math.max(0,null!=t.barPadding?t.barPadding/("vertical"===r?e.width:e.height):.1));let d,h;if(c){d=i.scaleBand().domain(s).range([0,1]).padding(0);const o=Math.min(e.width,e.height)/2,n=t.innerRadius||0;h=i.scaleLinear().domain(a).range([n,o])}else l?(d=i.scaleBand().domain(s).range([0,e.height]).padding(u),h=i.scaleLinear().domain(a).range([0,e.width])):(d=i.scaleBand().domain(s).range([0,e.width]).padding(u),h=i.scaleLinear().domain(a).range([e.height,0]));this.scales={o:d,r:h,projection:r},this.multiScales=this.rAccessors.length>1&&t.multiAxis?this.rAccessors.map((n,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(o,n);let[c,u]=a.extent;c===1/0&&(c=0,u=1);const d=null!==(s=t.extentPadding)&&void 0!==s?s:.05,h=u-c,g=h>0?h*d:1;return c-=g,u+=g,c>0&&(c=0),l?i.scaleLinear().domain([c,u]).range([0,e.width]):i.scaleLinear().domain([c,u]).range([e.height,0])}):[];let g=n;this.rAccessors.length>1&&(g=n.flatMap(e=>this.rAccessors.map((t,o)=>Object.assign(Object.assign({},e),{__rIndex:o,__rValue:t(e),__rName:this.resolveRAccessorName(o)})))),this.columns=this.buildColumns(g,s,d,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(g,e),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,n),this.config.pulse&&this.applyPulse(this.scene,n),this.config.transition&&!this._hasRenderedOnce&&this.scene.length>0&&(this.config.introAnimation&&this.synthesizeIntroPositions(),this._hasRenderedOnce=!0),this.config.transition&&this.prevPositionMap.size>0&&this.startTransition(),this.version++}resolveRAccessorName(e){const t=this.config.valueAccessor||this.config.rAccessor,o=Array.isArray(t)?t[e]:t;return"string"==typeof o?o:"value"+e}resolveCategories(e){const t=this.config.oSort,o="streaming"===this.config.runtimeMode||this._hasStreamingData,n="auto"===t?void 0:t;let i=null;if(o){i=new Set;for(const t of e)i.add(this.getO(t))}const r=i?Array.from(this.categories).filter(e=>i.has(e)):Array.from(this.categories);if(o&&void 0===n){const e=Math.max(50,3*i.size);if(this.categories.size>e){let t=this.categories.size-e;for(const e of this.categories){if(0>=t)break;i.has(e)||(this.categories.delete(e),t--)}}return r}if(!1===n)return r;if("function"==typeof n)return r.sort(n);const s=new Map;for(const t of e){const e=this.getO(t);s.set(e,(s.get(e)||0)+Math.abs(this.getR(t)))}return r.sort("asc"===n?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){var o,n,i,r,s;const a=this.config.chartType,l=null!==(o=this.config.extentPadding)&&void 0!==o?o:.05;if("radial"===this.config.projection&&("pie"===a||"donut"===a))return[0,1];let c=0,u=0;if("bar"===a&&this.getStack&&this.config.normalize)c=0,u=1;else if("bar"===a&&this.getStack){const t=new Map,o=new Map;for(const n of e){const e=this.getO(n),i=this.getR(n);0>i?o.set(e,(o.get(e)||0)+i):t.set(e,(t.get(e)||0)+i)}for(const e of t.values())e>u&&(u=e);for(const e of o.values())c>e&&(c=e)}else if("bar"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=this.getR(o);t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e),c>e&&(c=e)}else if("swimlane"===a){const t=new Map;for(const o of e){const e=this.getO(o),n=Math.abs(this.getR(o));t.set(e,(t.get(e)||0)+n)}for(const e of t.values())e>u&&(u=e)}else if("clusterbar"===a||"bar-funnel"===a)for(const t of e){const e=this.getR(t);e>u&&(u=e),c>e&&(c=e)}else{const e=this.rExtent.extent[0],t=this.rExtent.extent[1];e!==1/0&&(c=e),t!==-1/0&&(u=t)}this.config.rExtent&&(null!=this.config.rExtent[0]&&(c=this.config.rExtent[0]),null!=this.config.rExtent[1]&&(u=this.config.rExtent[1]));const d="bar"===a||"clusterbar"===a||"bar-funnel"===a||"swimlane"===a;if(d&&null==(null===(n=this.config.rExtent)||void 0===n?void 0:n[0])&&null==(null===(i=this.config.rExtent)||void 0===i?void 0:i[1])&&(c>0&&(c=0),0>u&&(u=0)),"bar-funnel"!==a&&"exact"!==this.config.axisExtent){const e=u-c,t=e>0?e*l:1;null!=(null===(r=this.config.rExtent)||void 0===r?void 0:r[0])||d&&!this.config.baselinePadding&&0===c||(c-=t),null!=(null===(s=this.config.rExtent)||void 0===s?void 0:s[1])||d&&!this.config.baselinePadding&&0===u||"swimlane"===a||(u+=t)}return[c,u]}buildColumns(e,t,o,n,i){var r;const s={},a=new Map;for(const t of e){const e=this.getO(t);a.has(e)||a.set(e,[]),a.get(e).push(t)}let l=0;if("radial"===n)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==n){u=new Map;let e=0;for(const o of t){const t=a.get(o)||[];let n;n="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(o,n),e+=n}const r=("horizontal"===n?i.height:i.width)-o.padding()*o.step()*t.length;if(e>0)for(const[t,o]of u)u.set(t,o/e*r)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],n=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?n/l:0;let c,g;u?(c=h,g=u.get(e)||o.bandwidth(),h+=g+o.padding()*o.step()):(c=null!==(r=o(e))&&void 0!==r?r:0,g=o.bandwidth()),s[e]={name:e,x:c,y:0,width:g,middle:c+g/2,padding:o.padding()*o.step(),pieceData:t,pct:i,pctStart:d},d+=i}return s}getSceneContext(){return{scales:this.scales,columns:this.columns,config:this.config,getR:this.getR,getStack:this.getStack,getGroup:this.getGroup,getColor:this.getColor,getConnector:this.getConnector,getO:this.getO,multiScales:this.multiScales,rAccessors:this.rAccessors,resolvePieceStyle:(e,t)=>this.resolvePieceStyle(e,t),resolveSummaryStyle:(e,t)=>this.resolveSummaryStyle(e,t),getRawRange:e=>this.getRawRange(e)}}buildSceneNodes(e,t){var o,n;if(!this.scales)return[];if(this.config.customLayout){const i=this.buildLayoutContext(e,t);let r;try{r=this.config.customLayout(i)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] ordinal customLayout threw:",e),this.customLayoutOverlays=null,[]}return this.customLayoutOverlays=null!==(o=r.overlays)&&void 0!==o?o:null,null!==(n=r.nodes)&&void 0!==n?n:[]}this.customLayoutOverlays=null;const i=this.getSceneContext(),r=Ps[this.config.chartType];let s=r?r(i,t):[];if(this.getConnector&&this.scales){const e=function(e,t){var o,n;const{scales:i,config:r,getConnector:s,getO:a}=e;if(!s||!i)return[];const l=[],{projection:c}=i,u=new Map;for(const e of t){if("point"!==e.type&&"rect"!==e.type)continue;const t=e.datum;if(!t)continue;const o=s(t);if(!o)continue;let n,i;"point"===e.type?(n=e.x,i=e.y):(n=e.x+e.w/2,i=e.y+("vertical"===c?0:e.h/2)),u.has(o)||u.set(o,[]),u.get(o).push({x:n,y:i,datum:t,category:a(t)})}const d=i.o.domain(),h=r.connectorStyle;for(const[t,i]of u)if(i.length>=2){i.sort((e,t)=>d.indexOf(e.category)-d.indexOf(t.category));for(let r=0;i.length-1>r;r++){const s=i[r],a=i[r+1],c="function"==typeof h?h(s.datum):h||{stroke:(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.border)||(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.secondary)||"#999",strokeWidth:1,opacity:.5};l.push({type:"connector",x1:s.x,y1:s.y,x2:a.x,y2:a.y,style:c,datum:s.datum,group:t})}}return l}(i,s);s=[...e,...s]}return s}buildLayoutContext(e,t){var o,n,i;const r=this.config,s=null!==(o=r.layoutMargin)&&void 0!==o?o:{top:0,right:0,bottom:0,left:0},a=Os(r.colorScheme,r.themeCategorical,ve),l=this.scales;return{data:e,scales:{o:l.o,r:l.r,projection:l.projection},dimensions:{width:t.width,height:t.height,margin:s,plot:"radial"===l.projection?{x:-t.width/2,y:-t.height/2,width:t.width,height:t.height}:{x:0,y:0,width:t.width,height:t.height}},theme:{semantic:null!==(n=r.themeSemantic)&&void 0!==n?n:{},categorical:[...a]},resolveColor:Ms(a),config:null!==(i=r.layoutConfig)&&void 0!==i?i:{}}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const o=this.config.pieceStyle(e,t);return o&&!o.fill&&t?Object.assign(Object.assign({},o),{fill:this.getColorFromScheme(t)}):o}return this.config.pieceStyle&&"object"==typeof this.config.pieceStyle?this.config.pieceStyle:this.config.barColors&&t?{fill:this.config.barColors[t]||"#007bff"}:t?{fill:this.getColorFromScheme(t)}:{fill:"#007bff"}}getColorFromScheme(e){this._colorSchemeMap||(this._colorSchemeMap=new Map);const t=this._colorSchemeMap.get(e);if(t)return t;const o=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,n=o[this._colorSchemeIndex%o.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,n),n}resolveSummaryStyle(e,t){return"function"==typeof this.config.summaryStyle?this.config.summaryStyle(e,t):this.config.summaryStyle&&"object"==typeof this.config.summaryStyle?this.config.summaryStyle:{fill:"#007bff",fillOpacity:.6,stroke:"#007bff",strokeWidth:1}}computeDecayOpacity(e,t){const o=this.config.decay;return o&&t>1?je(o,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=new Map;for(let o=0;e.length>o;o++)t.set(e[o],o);return this._datumIndexCache={version:this._dataVersion,map:t},t}getCategoryIndexMap(e){if(this._categoryIndexCache&&this._categoryIndexCache.version===this._dataVersion)return this._categoryIndexCache.map;const t=this.config.categoryAccessor||this.config.oAccessor,o="function"==typeof t,n=o?null:t||"category",i=new Map;for(let r=0;e.length>r;r++){const s=e[r],a=o?t(s):s[n];let l=i.get(a);l||(l=[],i.set(a,l)),l.push(r)}return this._categoryIndexCache={version:this._dataVersion,map:i},i}rebuildPointQuadtree(){let e=0,t=0;for(const o of this.scene)"point"===o.type&&(e++,o.r>t&&(t=o.r));if(this._maxPointRadius=t,_s.QUADTREE_THRESHOLD>=e)return void(this._pointQuadtree=null);const o=Array(e);let n=0;for(const e of this.scene)"point"===e.type&&(o[n++]=e);this._pointQuadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){var o,n;if(!this.config.decay)return;const i=t.length;if(1>=i)return;const r=this.getDatumIndexMap(t);for(const t of e){if("connector"===t.type||"violin"===t.type||"boxplot"===t.type||"wedge"===t.type)continue;const e=r.get(t.datum);if(null==e)continue;const s=this.computeDecayOpacity(e,i),a=null!==(n=null===(o=t.style)||void 0===o?void 0:o.opacity)&&void 0!==n?n:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var o,n,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(o=this.config.pulse.duration)&&void 0!==o?o:500,a=null!==(n=this.config.pulse.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",l=null!==(i=this.config.pulse.glowRadius)&&void 0!==i?i:4,c=this.getDatumIndexMap(t);let u=null;for(const o of e){if("connector"===o.type||"violin"===o.type||"boxplot"===o.type)continue;if("wedge"===o.type){const e=o.category;if(!e)continue;u||(u=this.getCategoryIndexMap(t));const n=u.get(e);if(!n)continue;let i=0;for(let e=0;n.length>e;e++){const t=this.timestampBuffer.get(n[e]);if(null==t)continue;const o=r-t;if(s>o){const e=1-o/s;e>i&&(i=e)}}i>0&&(o._pulseIntensity=i,o._pulseColor=a);continue}const e=c.get(o.datum);if(null==e)continue;const n=this.timestampBuffer.get(e);if(null==n)continue;const i=r-n;s>i&&(o._pulseIntensity=1-i/s,o._pulseColor=a,o._pulseGlowRadius=l)}}get hasActivePulses(){var e;if(!this.config.pulse||!this.timestampBuffer||0===this.timestampBuffer.size)return!1;const t="undefined"!=typeof performance?performance.now():Date.now(),o=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,n=this.timestampBuffer.peek();return null!=n&&o>t-n}synthesizeIntroPositions(){var e,t,o,n,i;this.prevPositionMap.clear();const r=new Map,s=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.r(0))&&void 0!==t?t:0,a="horizontal"!==(null===(o=this.scales)||void 0===o?void 0:o.projection);let l;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],o=this.getNodeKey(t,r);o&&("rect"===t.type?this.prevPositionMap.set(o,a?{x:t.x,y:s,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}:{x:s,y:t.y,w:0,h:t.h,opacity:null!==(i=t.style.opacity)&&void 0!==i?i:1}):"point"===t.type?this.prevPositionMap.set(o,{x:t.x,y:t.y,r:0,opacity:0}):"wedge"===t.type&&(void 0===l&&(l=t.startAngle),this.prevPositionMap.set(o,{x:t.cx,y:t.cy,startAngle:l,endAngle:l,innerRadius:t.innerRadius,outerRadius:t.outerRadius,opacity:0})))}}getNodeKey(e,t){var o,n,i;if("point"===e.type){const o=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,n=t.get(o)||0;return t.set(o,n+1),`${o}:${n}`}return"rect"===e.type?`r:${e.group||""}:${null!==(n=null===(o=e.datum)||void 0===o?void 0:o.category)&&void 0!==n?n:""}`:"wedge"===e.type?"w:"+(null!==(i=e.category)&&void 0!==i?i:""):null}snapshotPositions(){var e;this.prevPositionMap.clear();const t=new Map;for(let o=0;this.scene.length>o;o++){const n=this.scene[o],i=this.getNodeKey(n,t);i&&("point"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,r:n.r,opacity:n.style.opacity}):"rect"===n.type?this.prevPositionMap.set(i,{x:n.x,y:n.y,w:n.w,h:n.h,opacity:n.style.opacity}):"wedge"===n.type&&this.prevPositionMap.set(i,{x:n.cx,y:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,opacity:null!==(e=n.style.opacity)&&void 0!==e?e:1}))}}startTransition(){var e,t,o,n,i,r,s,a,l,c,u,d,h,g,f,p,y,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const k=null!==(e=this.config.transition.duration)&&void 0!==e?e:300;if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}let w=!1;const A=new Set,j=new Map;for(let e=0;this.scene.length>e;e++){const c=this.scene[e],u=this.getNodeKey(c,j);if(!u)continue;c._transitionKey=u;const d=this.prevPositionMap.get(u);if("point"===c.type)d?(A.add(u),c._targetOpacity=null!==(t=c.style.opacity)&&void 0!==t?t:1,(d.x!==c.x||d.y!==c.y||void 0!==d.r&&d.r!==c.r)&&(c._targetX=c.x,c._targetY=c.y,c._targetR=c.r,c.x=d.x,c.y=d.y,void 0!==d.r&&(c.r=d.r),w=!0)):(c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,d.x===c.x&&d.y===c.y&&d.w===c.w&&d.h===c.h||(c._targetX=c.x,c._targetY=c.y,c._targetW=c.w,c._targetH=c.h,c.x=d.x,c.y=d.y,c.w=null!==(i=d.w)&&void 0!==i?i:c.w,c.h=null!==(r=d.h)&&void 0!==r?r:c.h,w=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),w=!0);else if("wedge"===c.type)if(d)A.add(u),c._targetOpacity=null!==(a=c.style.opacity)&&void 0!==a?a:1,d.startAngle===c.startAngle&&d.endAngle===c.endAngle||(c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle,c.startAngle=d.startAngle,c.endAngle=d.endAngle,w=!0);else{c._targetOpacity=null!==(l=c.style.opacity)&&void 0!==l?l:1,c._targetStartAngle=c.startAngle,c._targetEndAngle=c.endAngle;const e=c.startAngle;c.startAngle=e,c.endAngle=e,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),this.prevPositionMap.set(u,{x:c.cx,y:c.cy,startAngle:e,endAngle:e,innerRadius:c.innerRadius,outerRadius:c.outerRadius,opacity:0}),w=!0}}this.exitNodes=[];for(const[e,t]of this.prevPositionMap)if(!A.has(e)){if(e.startsWith("p:"))this.exitNodes.push({type:"point",x:t.x,y:t.y,r:null!==(c=t.r)&&void 0!==c?c:3,style:{opacity:null!==(u=t.opacity)&&void 0!==u?u:1},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("r:"))this.exitNodes.push({type:"rect",x:t.x,y:t.y,w:null!==(d=t.w)&&void 0!==d?d:0,h:null!==(h=t.h)&&void 0!==h?h:0,style:{opacity:null!==(g=t.opacity)&&void 0!==g?g:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const o=((null!==(f=t.startAngle)&&void 0!==f?f:0)+(null!==(p=t.endAngle)&&void 0!==p?p:0))/2,n={type:"wedge",cx:t.x,cy:t.y,innerRadius:null!==(y=t.innerRadius)&&void 0!==y?y:0,outerRadius:null!==(m=t.outerRadius)&&void 0!==m?m:100,startAngle:null!==(v=t.startAngle)&&void 0!==v?v:0,endAngle:null!==(b=t.endAngle)&&void 0!==b?b:0,style:{opacity:null!==(x=t.opacity)&&void 0!==x?x:1},datum:null,category:e.slice(2),_targetStartAngle:o,_targetEndAngle:o,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(n)}w=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),w&&(this.activeTransition={startTime:Pe(),duration:k})}advanceTransition(e){var t,o,n,i;if(!this.activeTransition)return!1;const r=Oe(e,this.activeTransition),s=Ce(r,"linear"===(null===(t=this.config.transition)||void 0===t?void 0:t.easing)?"linear":"ease-out-cubic");for(const e of this.scene){const t=e._transitionKey;if(t)if("point"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),i=n?null!==(o=n.opacity)&&void 0!==o?o:1:0;e.style.opacity=Me(i,e._targetOpacity,s)}const n=this.prevPositionMap.get(t);void 0!==e._targetX&&n&&(e.x=Me(n.x,e._targetX,s),e.y=Me(n.y,e._targetY,s)),void 0!==e._targetR&&void 0!==(null==n?void 0:n.r)&&(e.r=Me(n.r,e._targetR,s))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),i=o?null!==(n=o.opacity)&&void 0!==n?n:1:0;e.style.opacity=Me(i,e._targetOpacity,s)}if(void 0===e._targetX)continue;const o=this.prevPositionMap.get(t);if(!o)continue;e.x=Me(o.x,e._targetX,s),e.y=Me(o.y,e._targetY,s),void 0!==o.w&&(e.w=Me(o.w,e._targetW,s),e.h=Me(o.h,e._targetH,s))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const o=this.prevPositionMap.get(t),n=o?null!==(i=o.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Me(n,e._targetOpacity,s)})}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const o=this.prevPositionMap.get(t);o&&void 0!==o.startAngle&&(e.startAngle=Me(o.startAngle,e._targetStartAngle,s),e.endAngle=Me(o.endAngle,e._targetEndAngle,s))}}}if(r>=1){for(const e of this.scene)if(void 0!==e._targetOpacity&&(e.style=Object.assign(Object.assign({},e.style||{}),{opacity:0===e._targetOpacity?0:e._targetOpacity}),e._targetOpacity=void 0),"point"===e.type){if(void 0===e._targetX&&void 0===e._targetR)continue;void 0!==e._targetX&&(e.x=e._targetX,e.y=e._targetY),void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else"wedge"===e.type&&void 0!==e._targetStartAngle&&(e.startAngle=e._targetStartAngle,e.endAngle=e._targetEndAngle,e._targetStartAngle=void 0,e._targetEndAngle=void 0);if(this.exitNodes.length>0){const e=new Set(this.exitNodes);this.scene=this.scene.filter(t=>!e.has(t)),this.exitNodes=[]}return this.activeTransition=null,!1}return!0}cancelIntroAnimation(){this.prevPositionMap.clear(),this.activeTransition=null}getData(){return this.buffer.toArray()}remove(e){if(!this.getDataId)throw Error("remove() requires dataIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,n=e=>t.has(o(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,o)=>{n(e)&&t.add(o)}),this.timestampBuffer.clear();for(let o=0;e.length>o;o++)t.has(o)||this.timestampBuffer.push(e[o])}const i=this.buffer.remove(n);if(0===i.length)return i;for(const e of i)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach(e=>this.categories.add(this.getO(e))),this._dataVersion++,this.version++,i}update(e,t){if(!this.getDataId)throw Error("update() requires dataIdAccessor to be configured");const o=new Set(Array.isArray(e)?e:[e]),n=this.getDataId,i=new Set;this.buffer.forEach((e,t)=>{o.has(n(e))&&i.add(t)});const r=this.buffer.update(e=>o.has(n(e)),t);if(0===r.length)return r;for(const e of r)this.evictValueExtent(e);return this.categories.clear(),this.buffer.forEach((e,t)=>{this.categories.add(this.getO(e)),i.has(t)&&this.pushValueExtent(e)}),this._dataVersion++,this.version++,r}clear(){this.buffer.clear(),this.rExtent.clear(),this.categories.clear(),this._hasStreamingData=!1,this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this.scales=null,this.scene=[],this.columns={},this._pointQuadtree=null,this._maxPointRadius=0,this._dataVersion++,this.version++}get size(){return this.buffer.size}getOAccessor(){return this.getO}getRAccessor(){return this.getR}updateConfig(e){const t=Object.assign({},this.config);if(("colorScheme"in e&&e.colorScheme!==t.colorScheme||"themeCategorical"in e&&e.themeCategorical!==t.themeCategorical||"colorAccessor"in e&&!z(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!z(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!z(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),("categoryAccessor"in e||"oAccessor"in e)&&(z(e.categoryAccessor||e.oAccessor,t.categoryAccessor||t.oAccessor)||(this.getO=q(this.config.categoryAccessor||this.config.oAccessor,"category"),this.categories.clear())),"valueAccessor"in e||"rAccessor"in e){const o=e.valueAccessor||e.rAccessor,n=t.valueAccessor||t.rAccessor,i=Array.isArray(o)?o:[o],r=Array.isArray(n)?n:[n];if(i.length!==r.length||i.some((e,t)=>!z(e,r[t]))){const e=this.config.valueAccessor||this.config.rAccessor;Array.isArray(e)?(this.rAccessors=e.map(e=>G(e,"value")),this.getR=this.rAccessors[0],this.rExtents=e.map(()=>new N)):(this.getR=G(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!z(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?q(this.config.stackBy):void 0),"groupBy"in e&&!z(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?q(this.config.groupBy):void 0),"colorAccessor"in e&&!z(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!z(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?q(this.config.connectorAccessor):void 0)}}function Ls(e,t,o){const n=qe(t,o,e);return n.hit?{datum:e.datum,x:n.cx,y:e.y,distance:0,category:e.group}:null}function Ts(e,t,o,n=30){const i=t-e.x,r=o-e.y,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function Rs(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;const s=Ke(Math.atan2(i,n)),a=Ke(e.startAngle),l=Ke(e.endAngle);if(!(a>l?s>=a||l>=s:s>=a&&l>=s))return null;const c=(e.startAngle+e.endAngle)/2,u=(e.innerRadius+e.outerRadius)/2;return{datum:e.datum,x:e.cx+Math.cos(c)*u,y:e.cy+Math.sin(c)*u,distance:0,category:e.category}}function Bs(e,t,o){const n=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-n>t||t>e.x+n||Math.min(e.minPos,e.maxPos)>o||o>Math.max(e.minPos,e.maxPos)))return{datum:e.datum,x:e.x,y:e.medianPos,distance:0,category:e.category,stats:e.stats}}else{const i=e.y-n,r=e.y+n;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>o||o>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function Ns(e,t,o){if(!e.bounds)return null;const{x:n,y:i,width:r,height:s}=e.bounds;return n>t||t>n+r||i>o||o>i+s?null:{datum:e.datum,x:n+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}function Ds(o){const{width:n,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,showGrid:u,rFormat:d}=o,{rTickValues:h,axisExtent:g}=o,f="radial"===(null==l?void 0:l.projection),p="horizontal"===(null==l?void 0:l.projection),y=t.useMemo(()=>!l||f?[]:(h||ho(l.r,5,g)).map(e=>({value:e,pixel:l.r(e),label:(d||Es)(e)})),[l,d,f,h,g]),m=u&&l&&!f,v=c&&l&&!f;return m||v?e.jsx("svg",{width:r,height:s,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:e.jsxs("g",{transform:`translate(${a.left},${a.top})`,children:[m&&e.jsx("g",{className:"ordinal-grid",children:y.map((t,o)=>e.jsx("line",{x1:p?t.pixel:0,y1:p?0:t.pixel,x2:p?t.pixel:n,y2:p?i:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),v&&e.jsx(e.Fragment,{children:e.jsxs(e.Fragment,p?{children:[e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[e.jsx("line",{x1:0,y1:i,x2:n,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]})})]})}):null}function Es(e){return Math.round(100*e)/100+""}function Is(o){var n,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,showCategoryTicks:h,oLabel:g,rLabel:f,oFormat:p,rFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A,legendPosition:j="right",legendLayout:S,foregroundGraphics:C,annotations:O,svgAnnotationRules:M,xAccessor:P,yAccessor:_,annotationData:L,underlayRendered:T,children:R}=o,B="radial"===(null==u?void 0:u.projection),N="horizontal"===(null==u?void 0:u.projection),D=!1!==h,E=t.useMemo(()=>d&&D&&u&&!B?u.o.domain().map((e,t)=>{var o;return{value:e,pixel:(null!==(o=u.o(e))&&void 0!==o?o:0)+u.o.bandwidth()/2,label:p?p(e,t):e}}):[],[d,D,u,p,B]),I=o.rTickValues,H=o.tickLabelEdgeAlign,F=o.axisExtent,$=t.useMemo(()=>d&&u&&!B?(I||ho(u.r,5,F)).map(e=>({value:e,pixel:u.r(e),label:(y||Es)(e)})):[],[d,u,y,B,I,F]),W=t.useRef(new Map),z=t.useRef(null!==(n=null==O?void 0:O.length)&&void 0!==n?n:0),G=null!==(i=null==O?void 0:O.length)&&void 0!==i?i:0;z.current!==G&&(z.current=G,W.current=new Map);const Y=t.useMemo(()=>{if(!O||0===O.length)return null;const e=eo(),t="horizontal"===(null==u?void 0:u.projection),o=(null==u?void 0:u.o)?e=>{var t;return(null!==(t=u.o(e))&&void 0!==t?t:0)+u.o.bandwidth()/2}:null,n={scales:u?{x:t?u.r:o||u.r,y:t&&o||u.r,time:u.r,value:u.r,o:u.o}:null,timeAxis:"x",xAccessor:P,yAccessor:_,width:r,height:s,data:L,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return O.map((t,o)=>{if(M){const i=M(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[O,M,r,s,u,P,_,L]);return d||v||b||C||Y&&Y.length>0||m||R?e.jsxs("svg",{role:"img",width:a,height:l,overflow:"visible",style:{position:"absolute",top:0,left:0,pointerEvents:"none",overflow:"visible"},children:[e.jsx("title",{children:"string"==typeof v?v:"Ordinal Chart"}),e.jsx("desc",{children:"string"==typeof v?v+" — ordinal data visualization":"Ordinal data visualization"}),e.jsxs("g",{transform:`translate(${c.left},${c.top})`,children:[m&&u&&!B&&!T&&e.jsx("g",{className:"ordinal-grid",children:$.map((t,o)=>e.jsx("line",{x1:N?t.pixel:0,y1:N?0:t.pixel,x2:N?t.pixel:r,y2:N?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),d&&u&&!B&&(()=>{const t={fontSize:"var(--semiotic-tick-font-size, 10px)"},o={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return e.jsx("g",{className:"ordinal-axes",children:e.jsxs(e.Fragment,N?{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!T&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),E.map((o,n)=>e.jsxs("g",{transform:`translate(0,${o.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof o.label||"number"==typeof o.label?e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label}):e.jsx("foreignObject",{x:-68,y:-12,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"right",userSelect:"none"},t),children:o.label})})]},"cat-"+n)),g&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!T&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!T&&(null==u?void 0:u.r)&&(()=>{const t=u.r(0);return t>1&&r-1>t?e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1,strokeDasharray:"4,4"}):null})(),$.map((o,n)=>{const i=H?0===n?"start":n===$.length-1?"end":"middle":"middle";return e.jsxs("g",{transform:`translate(${o.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{y:18,textAnchor:i,fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label})]},"val-"+n)}),f&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:f})]})]}:{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!T&&(()=>{const t=(null==u?void 0:u.r)?u.r(0):s,o=0>t||t>s?s:t;return e.jsx("line",{x1:0,y1:o,x2:r,y2:o,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),E.map((o,n)=>e.jsxs("g",{transform:`translate(${o.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof o.label||"number"==typeof o.label?e.jsx("text",{y:18,textAnchor:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label}):e.jsx("foreignObject",{x:-30,y:6,width:60,height:24,style:{overflow:"visible"},children:e.jsx("div",{style:Object.assign({textAlign:"center",userSelect:"none"},t),children:o.label})})]},"cat-"+n)),g&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:"var(--semiotic-text, #333)",className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:g})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!T&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),$.map((o,n)=>e.jsxs("g",{transform:`translate(0,${o.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),e.jsx("text",{x:-8,textAnchor:"end",dominantBaseline:"middle",fill:"var(--semiotic-text-secondary, #666)",className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},t),children:o.label})]},"val-"+n)),f&&e.jsx("text",{x:15-c.left,y:s/2,textAnchor:"middle",fill:"var(--semiotic-text, #333)",transform:`rotate(-90, ${15-c.left}, ${s/2})`,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},o),children:f})]})]})})})(),Y,C,R]}),v&&e.jsx("text",{x:a/2,y:20,textAnchor:"middle",fontWeight:"bold",fill:"var(--semiotic-text, #333)",className:"semiotic-chart-title",style:{userSelect:"none",fontSize:"var(--semiotic-title-font-size, 14px)"},children:"string"==typeof v?v:null}),Ht({legend:b,totalWidth:a,totalHeight:l,margin:c,legendPosition:j,title:v,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:k,legendHighlightedCategory:w,legendIsolatedCategories:A})]}):null}function Hs({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,scales:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),g=t.useRef(u);g.current=u;const f=t.useRef(c);f.current=c;const p=t.useRef(!1),y=t.useRef(null),m="horizontal"===(null==c?void 0:c.projection),v=t.useRef(m);return v.current=m,t.useEffect(()=>{if(!d.current)return;const e=o.select(d.current).select(".brush-g"),t=m?n.brushX():n.brushY();return t.extent([[0,0],[i,r]]),t.on("brush end",e=>{if(p.current)return;const t=f.current;if(!t)return;if(!e.selection)return y.current=null,void g.current(null);const[o,n]=e.selection;let i;i=v.current?[t.r.invert(o),t.r.invert(n)]:[t.r.invert(n),t.r.invert(o)];const r={r:i};y.current=r,g.current(r)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null),h.current=null}},[i,r,m]),t.useEffect(()=>{if(!c||!h.current||!y.current)return;if(!d.current)return;const e=y.current,t=o.select(d.current).select(".brush-g"),n=c.r(e.r[0]),i=c.r(e.r[1]);m?(p.current=!0,t.call(h.current.move,[n,i]),p.current=!1):(p.current=!0,t.call(h.current.move,[i,n]),p.current=!1)},[c,m]),e.jsx("svg",{ref:d,width:s,height:a,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:e.jsx("g",{className:"brush-g",transform:`translate(${l.left},${l.top})`,style:{pointerEvents:"all"}})})}function Fs(e,t){var o,n,i,r;const s=t._gradientBand.colors;if(0===s.length)return;const{clipPath:a,slices:l}=Co({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:null===(n=null===(o=t.roundedEnds)||void 0===o?void 0:o.start)||void 0===n||n,roundEnd:null===(r=null===(i=t.roundedEnds)||void 0===i?void 0:i.end)||void 0===r||r,colors:s}),c=new Path2D(a);e.save(),e.translate(t.cx,t.cy),e.clip(c);for(const t of l)e.fillStyle=rt(e,t.color)||t.color||"#007bff",e.fill(new Path2D(t.d));e.restore(),t.style.stroke&&"none"!==t.style.stroke&&(e.save(),e.translate(t.cx,t.cy),e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(c),e.restore())}function $s(e,t){e.beginPath(),t.innerRadius>0?(e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerRadius,t.endAngle,t.startAngle,!0)):(e.moveTo(t.cx,t.cy),e.arc(t.cx,t.cy,t.outerRadius,t.startAngle,t.endAngle)),e.closePath()}function Ws(e,t){const o={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},n=s.arc().cornerRadius(t.cornerRadius)(o);if(!n)return;e.save(),e.translate(t.cx,t.cy);const i=new Path2D(n);e.fill(i),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(i),e.restore()}_s.QUADTREE_THRESHOLD=500;const zs=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"wedge"===e.type);for(const t of s){const o=null!==(i=t.style.fillOpacity)&&void 0!==i?i:1,n=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(e.globalAlpha=o*n,t._gradientBand&&t._gradientBand.colors.length>0)Fs(e,t),t._pulseIntensity&&t._pulseIntensity>0&&($s(e,t),Dn(e,t)),e.globalAlpha=1;else{if(e.fillStyle=("string"==typeof t.style.fill?rt(e,t.style.fill):t.style.fill)||"#007bff",t.roundedEnds){t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1);const o=So({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:t.roundedEnds.start,roundEnd:t.roundedEnds.end});e.save(),e.translate(t.cx,t.cy);const n=new Path2D(o);e.fill(n),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(n),e.restore()}else t.cornerRadius?(t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1),Ws(e,t)):($s(e,t),e.fill(),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()));t._pulseIntensity&&t._pulseIntensity>0&&($s(e,t),Dn(e,t)),e.globalAlpha=1}}},Gs=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const o=t.columnWidth/2,n="vertical"===t.projection,s=rt(e,"var(--semiotic-primary, #007bff)"),a=rt(e,"var(--semiotic-text, #333)"),l=t.style.fill,c="string"==typeof l?rt(e,l)||l:null!=l?l:s,u=t.style.stroke,d="string"==typeof u?rt(e,u)||u:a,h=t.style.strokeWidth||1,g=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6;if(e.save(),e.strokeStyle=d,e.lineWidth=h,e.beginPath(),n?(e.moveTo(t.x,t.minPos),e.lineTo(t.x,t.maxPos)):(e.moveTo(t.minPos,t.y),e.lineTo(t.maxPos,t.y)),e.stroke(),e.beginPath(),n?(e.moveTo(t.x-.4*o,t.minPos),e.lineTo(t.x+.4*o,t.minPos),e.moveTo(t.x-.4*o,t.maxPos),e.lineTo(t.x+.4*o,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*o),e.lineTo(t.minPos,t.y+.4*o),e.moveTo(t.maxPos,t.y-.4*o),e.lineTo(t.maxPos,t.y+.4*o)),e.stroke(),e.globalAlpha=g,e.fillStyle=c,n){const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-o,n,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-o,n,t.columnWidth,i)}else{const n=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(n,t.y-o,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(n,t.y-o,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),n?(e.moveTo(t.x-o,t.medianPos),e.lineTo(t.x+o,t.medianPos)):(e.moveTo(t.medianPos,t.y-o),e.lineTo(t.medianPos,t.y+o)),e.stroke(),e.restore()}},Ys=(e,t,o,n)=>{var i,r;const s=t.filter(e=>"violin"===e.type);for(const t of s){e.save(),(t.translateX||t.translateY)&&e.translate(t.translateX,t.translateY);const o=new Path2D(t.pathString);if(e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.6,e.fillStyle=("string"==typeof t.style.fill?rt(e,t.style.fill):t.style.fill)||"#007bff",e.fill(o),e.globalAlpha=1,t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke(o)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const o=t.iqrLine.centerPos,n=!1!==t.iqrLine.isVertical;e.beginPath(),n?(e.moveTo(o,t.iqrLine.q1Pos),e.lineTo(o,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,o),e.lineTo(t.iqrLine.q3Pos,o)),e.stroke(),e.beginPath(),n?e.arc(o,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,o,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},qs=(e,t,o,n)=>{var i,r,s;const a=t.filter(e=>"connector"===e.type);if(0===a.length)return;const l=new Map;for(const e of a){const t=e.group||"_default";l.has(t)||l.set(t,[]),l.get(t).push(e)}for(const[,t]of l){if(0===t.length)continue;const o=t[0].style;if(o.fill&&"none"!==o.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const o of t)e.lineTo(o.x2,o.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=o.fillOpacity)&&void 0!==i?i:o.opacity)&&void 0!==r?r:.3,e.fillStyle=o.fill,e.fill(),e.globalAlpha=1}for(const o of t)e.beginPath(),e.moveTo(o.x1,o.y1),e.lineTo(o.x2,o.y2),e.strokeStyle=rt(e,o.style.stroke)||("string"==typeof o.style.fill?rt(e,o.style.fill):o.style.fill)||rt(e,"var(--semiotic-border, #999)"),e.lineWidth=o.style.strokeWidth||1,e.globalAlpha=null!==(s=o.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},Xs=(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const o=t.points;if(o.length>=4){e.globalAlpha=null!==(r=null===(i=t.style)||void 0===i?void 0:i.opacity)&&void 0!==r?r:1,e.beginPath(),e.moveTo(o[0][0],o[0][1]);for(let t=1;o.length>t;t++)e.lineTo(o[t][0],o[t][1]);e.closePath(),e.fillStyle=(null===(s=t.style)||void 0===s?void 0:s.fill)||"#999",e.fill(),(null===(a=t.style)||void 0===a?void 0:a.stroke)&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||1,e.stroke()),e.globalAlpha=1}}};function Vs(e){return 1e6>e?1e4>e?1e3>e?e+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function Us(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Ks=null;const Qs=new Map;function Zs(e,t){const o=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,n=Qs.get(o);if(void 0!==n)return n;const i=function(e={},t){const{background:o="transparent",stroke:n="#000",lineWidth:i=1.5,spacing:r=6,angle:s=45}=e,a=Math.max(8,Math.ceil(2*r));let l;try{l=function(e){return"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(e,e):(Ks||(Ks=document.createElement("canvas")),Ks.width=e,Ks.height=e,Ks)}(a)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;o&&"transparent"!==o?(c.fillStyle=o,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=n,c.lineWidth=i,c.lineCap="square";const u=s*Math.PI/180;if(45===s||-45===s){const e=s>0?1:-1;for(let t=-a;2*a>=t;t+=r)c.beginPath(),c.moveTo(t,0),c.lineTo(t+e*a,a),c.stroke()}else{c.save(),c.translate(a/2,a/2),c.rotate(u);const e=2*a;for(let t=-e;e>=t;t+=r)c.beginPath(),c.moveTo(-e,t),c.lineTo(e,t),c.stroke();c.restore()}return(t||c).createPattern(l,"repeat")}({background:e,stroke:"rgba(255,255,255,0.5)",lineWidth:1.5,spacing:6,angle:45},t);return Qs.set(o,i),i}function Js(e,t,o,n,i,r){e.moveTo(t+r,o),e.lineTo(t+n-r,o),e.quadraticCurveTo(t+n,o,t+n,o+r),e.lineTo(t+n,o+i-r),e.quadraticCurveTo(t+n,o+i,t+n-r,o+i),e.lineTo(t+r,o+i),e.quadraticCurveTo(t,o+i,t,o+i-r),e.lineTo(t,o+r),e.quadraticCurveTo(t,o,t+r,o),e.closePath()}function ea(e){return 1e6>e?1e4>e?1e3>e?Math.round(e)+"":(e/1e3).toFixed(1)+"K":(e/1e3).toFixed(0)+"K":(e/1e6).toFixed(1)+"M"}function ta(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const oa=e=>[qs,...e],na={bar:oa([Wn]),clusterbar:oa([Wn]),point:oa([Hn]),swarm:oa([Hn]),pie:[zs],donut:[zs],boxplot:oa([Gs,Hn]),violin:oa([Ys]),histogram:oa([Wn]),ridgeline:oa([Ys]),timeline:oa([Wn]),funnel:[Wn,Xs,(e,t,o,n)=>{var i,r,s,a;const l=t.filter(e=>"rect"===e.type&&null!=e.datum);if(0!==l.length&&l.some(e=>{var t,o;return null!=(null===(t=e.datum)||void 0===t?void 0:t.__funnelStepLabel)||null!=(null===(o=e.datum)||void 0===o?void 0:o.__funnelValueLabelX)})){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(!o.__funnelStepLabel)continue;const n=o.__funnelStepLabel;if(e.measureText(n).width+16>(null!==(r=null!==(i=o.__funnelRowWidth)&&void 0!==i?i:o.__funnelBarW)&&void 0!==r?r:0))continue;const s=o.__funnelStepLabelX,a=o.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(n,s,a),e.fillStyle="#fff",e.fillText(n,s,a)}e.font="bold 13px sans-serif";for(const t of l){const o=t.datum;if(!o)continue;if(null==o.__funnelValueLabelX)continue;const n=null!==(s=o.__funnelBarW)&&void 0!==s?s:0;if(60>n)continue;const i=o.__funnelValue;if(null==i||0===i)continue;const r=o.__funnelPercent,l=!0===o.__funnelIsFirstStep;let c;if(c=l?Vs(i):null!=r?`${Vs(i)} (${Us(r)})`:Vs(i),e.measureText(c).width+16>n){if(l||null==r)continue;if(c=Vs(i),e.measureText(c).width+16>n)continue}const u=o.__funnelValueLabelX,d=(null!==(a=o.__funnelValueLabelY)&&void 0!==a?a:t.y)+14+5;e.textAlign="center",e.strokeStyle="rgba(0,0,0,0.5)",e.lineWidth=3,e.strokeText(c,u,d),e.fillStyle="#fff",e.fillText(c,u,d)}e.lineWidth=1,e.lineJoin="miter"}}],"bar-funnel":[Wn,(e,t,o,n)=>{var i,r;const s=t.filter(e=>{var t;return"rect"===e.type&&!0===(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)});for(const t of s){const o=("string"==typeof t.style.fill?t.style.fill:null)||rt(e,"var(--semiotic-border, #999)"),n=Zs(o,e);e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.beginPath(),e.rect(t.x,t.y,t.w,t.h),n?e.fillStyle=n:(e.fillStyle=o,e.globalAlpha=.4*(null!==(r=t.style.opacity)&&void 0!==r?r:1)),e.fill(),e.globalAlpha=1}},(e,t,o,n)=>{const i=t.filter(e=>{var t,o;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(o=e.datum)||void 0===o?void 0:o.__barFunnelLabelX)});if(0===i.length)return;const r=function(e,t){const[o,n,i]=st(e,t);return(.2126*o+.7152*n+.0722*i)/255>.6}(e,rt(e,"var(--semiotic-text, #333)")),s=r?"#1f2937":"#ffffff",a=r?"rgba(255,255,255,0.18)":"rgba(0,0,0,0.12)",l=r?"#f3f4f6":"#1a1a1a",c=l;for(const t of i){const o=t.datum;if(!o)continue;const n=o.__barFunnelValue;if(null==n)continue;if(25>t.w)continue;const i=o.__barFunnelPercent,r=!(!0===o.__barFunnelIsFirstStep)&&null!=i,u=r?ta(i):"",d=ea(n);e.font="bold 13px sans-serif";const h=r?e.measureText(u).width:0;e.font="11px sans-serif";const g=e.measureText(d).width,f=Math.max(h,g)+12,p=r?32:17,y=o.__barFunnelLabelX,m=y-f/2,v=o.__barFunnelLabelY-p-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=s,e.beginPath(),Js(e,m,v,f,p,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),Js(e,m,v,f,p,4),e.stroke(),e.textAlign="center",e.textBaseline="top",r?(e.font="bold 13px sans-serif",e.fillStyle=l,e.fillText(u,y,v+3),e.font="11px sans-serif",e.fillStyle=c,e.fillText(d,y,v+3+13+2)):(e.font="bold 11px sans-serif",e.fillStyle=l,e.fillText(d,y,v+3))}e.lineWidth=1}],swimlane:oa([Wn]),custom:oa([Wn,Hn,zs,Gs,Ys,Xs])},ia={top:50,right:40,bottom:60,left:70},ra={background:"rgba(0, 0, 0, 0.85)",color:"white",padding:"6px 10px",borderRadius:"4px",fontSize:"13px",lineHeight:"1.4",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.15)",pointerEvents:"none",whiteSpace:"nowrap"};function sa({hover:t}){var o,n,i,r,s,a;const l=t.data||{},c=t.stats,u=t.category;if(Array.isArray(l)){const t=u||(null===(o=l[0])||void 0===o?void 0:o.category)||"";if(c)return e.jsxs("div",{className:"semiotic-tooltip",style:ra,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:["n = ",c.n]}),e.jsxs("div",{children:["Min: ",c.min.toLocaleString()]}),e.jsxs("div",{children:["Q1: ",c.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",c.median.toLocaleString()]}),e.jsxs("div",{children:["Q3: ",c.q3.toLocaleString()]}),e.jsxs("div",{children:["Max: ",c.max.toLocaleString()]}),e.jsxs("div",{style:{opacity:.8},children:["Mean: ",c.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});const n=l.length;return e.jsxs("div",{className:"semiotic-tooltip",style:ra,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:[n," items"]})]})}if(null!=l.bin&&null!=l.count){const t=l.range||[];return e.jsxs("div",{className:"semiotic-tooltip",style:ra,children:[l.category&&e.jsx("div",{style:{fontWeight:"bold"},children:l.category+""}),e.jsxs("div",{children:["Count: ",l.count]}),2===t.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(t[0]).toFixed(1)," – ",Number(t[1]).toFixed(1)]})]})}const d=t.__oAccessor,h=t.__rAccessor,g=t.__chartType;if("swarm"===g||"point"===g){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:ra,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}const f=(d&&null!=l[d]?l[d]:null)||l.category||l.name||l.group||l.__rName||"",p=null!==(a=null!==(s=null!==(r=null!==(i=null!==(n=l.__aggregateValue)&&void 0!==n?n:h&&null!=l[h]?l[h]:null)&&void 0!==i?i:l.value)&&void 0!==r?r:l.__rValue)&&void 0!==s?s:l.pct)&&void 0!==a?a:"";if(!f&&""===p){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:ra,children:t.map(([t,o])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof o?o.toLocaleString():o+""]},t))})}return e.jsxs("div",{className:"semiotic-tooltip",style:ra,children:[f&&e.jsx("div",{style:{fontWeight:"bold"},children:f+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}sa.ownsChrome=!0;const aa=t.forwardRef(function(o,n){var i,r,a,l,c,u,d,h,g,f,y;const{chartType:m,runtimeMode:b,data:x,oAccessor:k="category",rAccessor:A="value",colorAccessor:j,stackBy:C,groupBy:O,multiAxis:M,timeAccessor:P,valueAccessor:_,categoryAccessor:L,projection:T="vertical",size:R=[600,400],responsiveWidth:B,responsiveHeight:N,margin:D,barPadding:E,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:$,innerRadius:W,cornerRadius:z,normalize:G,startAngle:Y,sweepAngle:q,dynamicColumnWidth:X,bins:V,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:oe,rExtent:ne,oExtent:ie,extentPadding:re=.05,oSort:se,windowMode:ae="sliding",windowSize:le=200,pieceStyle:ce,summaryStyle:ue,colorScheme:de,barColors:he,showAxes:ge=!0,showCategoryTicks:fe,categoryLabel:pe,valueLabel:ye,categoryFormat:me,valueFormat:ve,oLabel:be,rLabel:xe,oFormat:ke,rFormat:we,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,enableHover:Ce=!0,hoverAnnotation:Oe,tooltipContent:Me,customHoverBehavior:Pe,annotations:_e,svgAnnotationRules:Le,showGrid:Te=!1,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ie,legendLayout:He,legendCategoryAccessor:Fe,onCategoriesChange:$e,backgroundGraphics:We,foregroundGraphics:ze,title:Ge,className:qe,background:Xe,centerContent:Ve,decay:Ue,pulse:Ke,transition:Ze,animate:Je,staleness:et,brush:tt,onBrush:ot,accessibleTable:nt=!0,description:it,summary:st,customLayout:at,layoutConfig:lt}=o,ct=t.useRef(!0),ut=On({sizeProp:R,responsiveWidth:B,responsiveHeight:N,userMargin:D,marginDefault:ia,foregroundGraphics:ze,backgroundGraphics:We,animate:Je,transitionProp:Ze,themeDirtyRef:ct}),{reducedMotionRef:dt,responsiveRef:ht,size:gt,margin:ft,adjustedWidth:pt,adjustedHeight:yt,resolvedForeground:mt,resolvedBackground:vt,currentTheme:bt,transition:xt,introEnabled:kt,tableId:wt,rafRef:Ct,renderFnRef:Ot,scheduleRender:_t}=ut,Lt=To(),Tt=Do(),Rt=t.useMemo(()=>v(x),[x]),Bt=null!=pe?pe:be,Nt=null!=ye?ye:xe,Dt=null!=me?me:ke,Et=null!=ve?ve:we,It=t.useRef(null),Ht=t.useRef(null),Ft=t.useRef([]),$t=t.useRef(Fe),Wt=t.useRef($e);$t.current=Fe,Wt.current=$e;const[zt,Gt]=t.useState(null),[Yt,qt]=t.useState(null),[Xt,Vt]=t.useState(0),[Ut,Kt]=t.useState(!1),[Qt,Zt]=t.useState(null),Jt=t.useCallback(()=>{var e,t;Zt(null!==(t=null===(e=io.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]),eo=Ce||Oe,to="streaming"===b,oo=t.useMemo(()=>{var e,t,o;return{chartType:m,runtimeMode:to?"streaming":"bounded",windowSize:le,windowMode:ae,extentPadding:re,projection:T,oAccessor:to?void 0:k,rAccessor:to?void 0:A,colorAccessor:j,stackBy:C,groupBy:O,multiAxis:M,timeAccessor:to?P:void 0,valueAccessor:to?_||("string"==typeof A||"function"==typeof A?A:void 0):void 0,categoryAccessor:to?L||k:void 0,rExtent:ne,oExtent:ie,axisExtent:Se,barPadding:E,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:$,innerRadius:W,cornerRadius:z,normalize:G,startAngle:Y,sweepAngle:q,dynamicColumnWidth:X,bins:V,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:oe,oSort:se,pieceStyle:ce,summaryStyle:ue,colorScheme:de,themeCategorical:null===(e=null==bt?void 0:bt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(bt),themeSequential:null===(t=null==bt?void 0:bt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==bt?void 0:bt.colors)||void 0===o?void 0:o.diverging,barColors:he,decay:Ue,pulse:Ke,transition:xt,introAnimation:kt,staleness:et,customLayout:at,layoutConfig:lt,layoutMargin:ft}},[m,le,ae,re,T,k,A,j,C,O,M,P,_,L,ne,ie,Se,E,I,H,F,$,W,z,G,Y,q,X,V,U,K,Q,Z,J,ee,te,oe,se,ce,ue,de,he,Ue,Ke,null==xt?void 0:xt.duration,null==xt?void 0:xt.easing,kt,et,to,bt,at,lt,ft]),no=Io(oo),io=t.useRef(null);io.current||(io.current=new _s(no));const ro=t.useCallback(()=>{var e,t;const o=$t.current,n=Wt.current;if(!n||!o)return;const i=Vn(null!==(t=null===(e=io.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],o);Un(i,Ft.current)||(Ft.current=i,n(i))},[]);t.useEffect(()=>{var e;null===(e=io.current)||void 0===e||e.updateConfig(no),ct.current=!0,_t()},[no,_t]);const so=t.useRef(null);so.current||(so.current=new w(e=>{const t=io.current;t&&t.ingest(e)&&(ct.current=!0,_t())}));const ao=t.useCallback(e=>{var t;null===(t=so.current)||void 0===t||t.push(e)},[]),lo=t.useCallback(e=>{var t;null===(t=so.current)||void 0===t||t.pushMany(e)},[]),co=t.useCallback(()=>{var e,t;null===(e=so.current)||void 0===e||e.clear(),null===(t=io.current)||void 0===t||t.clear(),ct.current=!0,_t()},[_t]),uo=t.useCallback(e=>{var t,o;null===(t=so.current)||void 0===t||t.clearLastData(),null===(o=so.current)||void 0===o||o.setReplacementData(e)},[]);t.useImperativeHandle(n,()=>({push:ao,pushMany:lo,replace:uo,remove:e=>{var t,o,n,i;null===(t=so.current)||void 0===t||t.flush();const r=null!==(n=null===(o=io.current)||void 0===o?void 0:o.remove(e))&&void 0!==n?n:[];if(r.length>0){const e=null===(i=Ht.current)||void 0===i?void 0:i.data;!!Ht.current&&r.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Ht.current=null,Gt(null)),ct.current=!0,_t()}return r},update:(e,t)=>{var o,n,i;null===(o=so.current)||void 0===o||o.flush();const r=null!==(i=null===(n=io.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[];return r.length>0&&(ct.current=!0,_t()),r},clear:co,getData:()=>{var e,t,o;return null===(e=so.current)||void 0===e||e.flush(),null!==(o=null===(t=io.current)||void 0===t?void 0:t.getData())&&void 0!==o?o:[]},getScales:()=>{var e,t;return null!==(t=null===(e=io.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[ao,lo,uo,co,_t]),t.useEffect(()=>{var e;x&&(null===(e=so.current)||void 0===e||e.setBoundedData(Rt))},[x,Rt]);const{hoverHandlerRef:ho,hoverLeaveRef:go,onPointerMove:fo,onPointerLeave:po}=ut;ho.current=e=>{if(!eo)return;const t=It.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-ft.left,i=e.clientY-o.top-ft.top;if(0>n||n>pt||0>i||i>yt)return void(Ht.current&&(Ht.current=null,Gt(null),Pe&&Pe(null),_t()));const r=io.current;if(!r||0===r.scene.length)return;const s="radial"===T,a=function(e,t,o,n=30,i,r=0){let s=null;if(i){const e=Qe(i,t,o,n,r);e&&(s={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"rect":if(null==r.datum)break;e=Ls(r,t,o);break;case"point":if(i)break;e=Ts(r,t,o,n);break;case"wedge":if(null===r.datum)break;e=Rs(r,t,o);break;case"boxplot":e=Bs(r,t,o);break;case"violin":e=Ns(r,t,o)}e&&n>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(r.scene,s?n-pt/2:n,s?i-yt/2:i,30,r.pointQuadtree,r.maxPointRadius);if(!a)return void(Ht.current&&(Ht.current=null,Gt(null),Pe&&Pe(null),_t()));const l=pn(a.datum||{},a.x,a.y,Object.assign(Object.assign(Object.assign({},a.stats&&{stats:a.stats}),a.category&&{category:a.category}),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m}));Ht.current=l,Gt(l),Pe&&(Pe(l),ct.current=!0),_t()},go.current=()=>{Ht.current&&(Ht.current=null,Gt(null),Pe&&(Pe(null),ct.current=!0),_t())};const yo=t.useRef(-1),mo=t.useRef(null),vo=t.useRef(null),bo=t.useCallback(e=>{const t=io.current;if(!t||0===t.scene.length)return;const o=t.version;let n;if(vo.current&&vo.current.version===o)n=vo.current.graph;else{const e=function(e){var t,o,n;const i=[];for(const r of e)if("rect"===r.type&&null!=r.x){if(null==r.datum)continue;const e=null!==(o=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==o?o:"";i.push({x:r.x+r.w/2,y:r.y+r.h/2,datum:r.datum,shape:"rect",w:r.w,h:r.h,group:null!==(n=r.group)&&void 0!==n?n:e})}else if("point"===r.type)i.push({x:r.x,y:r.y,datum:r.datum,shape:"circle",group:"_default"});else if("wedge"===r.type&&null!=r.cx){if(null===r.datum)continue;const e=((r.startAngle||0)+(r.endAngle||0))/2,t=((r.innerRadius||0)+(r.outerRadius||50))/2;i.push({x:r.cx+Math.cos(e)*t,y:r.cy+Math.sin(e)*t,datum:r.datum,shape:"wedge",group:"_default"})}return i.sort((e,t)=>e.x-t.x||e.y-t.y),i}(t.scene);if(0===e.length)return;n=At(e),vo.current={version:o,graph:n}}const i=yo.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),yo.current=0;const t=n.flat[0];mo.current={shape:t.shape,w:t.w,h:t.h};const o=Object.assign(Object.assign({},Mt(t)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});return Ht.current=o,Gt(o),Pe&&Pe(o),void _t()}const r=jt(n,i),s=St(e.key,r,n);if(null===s)return;if(e.preventDefault(),0>s)return yo.current=-1,mo.current=null,Ht.current=null,Gt(null),Pe&&Pe(null),void _t();yo.current=s;const a=n.flat[s];mo.current={shape:a.shape,w:a.w,h:a.h};const l=Object.assign(Object.assign({},Mt(a)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});Ht.current=l,Gt(l),Pe&&Pe(l),_t()},[Pe,_t]),xo=t.useCallback(e=>{yo.current=-1,mo.current=null,fo(e)},[fo]);Ot.current=()=>{var e,t;Ct.current=0;const o=It.current;if(!o)return;const n=o.getContext("2d");if(!n)return;const i=io.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(dt.current?r+1e6:r),a=!dt.current&&s,l=ct.current;l&&!s&&(i.computeScene({width:pt,height:yt}),ro(),Jt(),ct.current=!1),(l||a)&&o.setAttribute("aria-label",qo(i.scene,m+" chart"));const c=Pn(),u=gt[0]*c,d=gt[1]*c;o.width===u&&o.height===d||(o.width=u,o.height=d,o.style.width=gt[0]+"px",o.style.height=gt[1]+"px"),n.setTransform(c,0,0,c,0,0),n.clearRect(0,0,gt[0],gt[1]);const h=null!==(e=null==et?void 0:et.threshold)&&void 0!==e?e:5e3,g=et&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(g&&(n.globalAlpha=null!==(t=null==et?void 0:et.dimOpacity)&&void 0!==t?t:.5),"transparent"!==Xe&&!We){const e=o?getComputedStyle(o).getPropertyValue("--semiotic-bg").trim():"",t=Xe||(e&&"transparent"!==e?e:null),i=t?rt(n,t):null;i&&(n.fillStyle=i,n.fillRect(0,0,gt[0],gt[1]))}const f="radial"===T;n.save(),n.beginPath(),n.rect(ft.left,ft.top,pt,yt),n.clip(),f?(n.save(),n.translate(ft.left+pt/2,ft.top+yt/2)):n.translate(ft.left,ft.top);const p=at?na.custom:na[m]||[],y={width:pt,height:yt};for(const e of p)e(n,i.scene,i.scales,y);f&&n.restore(),n.restore(),g&&(n.globalAlpha=1),l&&i.scales&&(qt(i.scales),Vt(e=>e+1)),(null==et?void 0:et.showBadge)&&Kt(!!g),(a||null!=i.activeTransition||i.hasActivePulses)&&(Ct.current=requestAnimationFrame(()=>Ot.current()))},Eo({hydrated:Lt,wasHydratingFromSSR:Tt,storeRef:io,dirtyRef:ct,renderFnRef:Ot,cleanup:()=>{var e;return null===(e=so.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{ct.current=!0,_t()},[m,pt,yt,ge,Xe,_t]),Pt(et,io,ct,_t,Ut,Kt);const ko=eo&&zt?Me?Me(zt):e.jsx(sa,{hover:zt}):null,jo="radial"===T,Lo=ko?e.jsx(wn,{x:zt?jo?zt.x+pt/2:zt.x:0,y:zt?jo?zt.y+yt/2:zt.y:0,containerWidth:pt,containerHeight:yt,margin:ft,className:"stream-ordinal-tooltip",children:ko}):null,Ro=Kn(k,void 0,"__semiotic_resolvedO",""),Bo=Kn(A,void 0,"__semiotic_resolvedR",""),No=Ro.key,Ho=Bo.key,Fo=Qn(Ro,Bo,_e&&_e.length>0||!1);if(_o||!Lt&&Tt){const t=io.current;t&&x&&(t.ingest({inserts:Rt,bounded:!0}),t.computeScene({width:pt,height:yt}));const o=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],n=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,l="radial"===T,c=l?ft.left+pt/2:ft.left,u=l?ft.top+yt/2:ft.top;return e.jsxs("div",{ref:ht,className:"stream-ordinal-frame"+(qe?" "+qe:""),role:"img","aria-label":it||("string"==typeof Ge?Ge:"Ordinal chart"),style:{position:"relative",width:B?"100%":gt[0],height:N?"100%":gt[1]},children:[e.jsx(cn,{summary:st}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:gt[0],height:gt[1],style:{position:"absolute",left:0,top:0},children:[vt&&e.jsx("g",{transform:`translate(${ft.left},${ft.top})`,children:vt}),e.jsxs("g",{transform:`translate(${c},${u})`,children:[Xe&&e.jsx("rect",{x:0,y:0,width:pt,height:yt,fill:Xe}),o.map((t,o)=>function(t,o,n){var i,r,a,l,c,u,d,h,g;const f=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",y=e=>`ord-${t.type}-${f}-${o}-${e}`,m=`ord-${t.type}-${f}-${o}`;switch(t.type){case"rect":{const o=t,n=Po(m)+"-grad",i=function(t,o){const n=t.fillGradient;if(!n)return null;let i=t.x,r=t.y,s=t.x,a=t.y+t.h;"bottom"===t.roundedEdge?(r=t.y+t.h,a=t.y):"right"===t.roundedEdge?(i=t.x+t.w,r=t.y,s=t.x,a=t.y):"left"===t.roundedEdge&&(i=t.x,r=t.y,s=t.x+t.w,a=t.y);const l=[];if("colorStops"in n){const t=n.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;for(let o=0;t.length>o;o++)l.push(e.jsx("stop",{offset:t[o].offset,stopColor:t[o].color},o))}else{const o=Mo(t.style.fill);l.push(e.jsx("stop",{offset:0,stopColor:o,stopOpacity:n.topOpacity},"0")),l.push(e.jsx("stop",{offset:1,stopColor:o,stopOpacity:n.bottomOpacity},"1"))}return e.jsx("linearGradient",{id:o,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(o,n),r=i?`url(#${n})`:Mo(o.style.fill);if(o.cornerRadii&&wo(o.cornerRadii)){const t=function(e){const{x:t,y:o,w:n,h:i}=e,{tl:r,tr:s,br:a,bl:l}=Ao(e);let c=`M${t+r},${o}`;return c+=` L${t+n-s},${o}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+n},${o+s}`),c+=` L${t+n},${o+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+n-a},${o+i}`),c+=` L${t+l},${o+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${o+i-l}`),c+=` L${t},${o+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${t+r},${o}`),c+=" Z",c}(o);return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:t,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}if(o.roundedTop&&o.roundedTop>0){const t=Math.min(o.roundedTop,o.w/2,o.h/2),{x:n,y:s,w:a,h:l}=o;let c;switch(o.roundedEdge){case"right":c=`M${n},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n},${s+l} Z`;break;case"left":c=`M${n+a},${s} L${n+t},${s} A${t},${t} 0 0 0 ${n},${s+t} L${n},${s+l-t} A${t},${t} 0 0 0 ${n+t},${s+l} L${n+a},${s+l} Z`;break;case"bottom":c=`M${n},${s} L${n+a},${s} L${n+a},${s+l-t} A${t},${t} 0 0 1 ${n+a-t},${s+l} L${n+t},${s+l} A${t},${t} 0 0 1 ${n},${s+l-t} Z`;break;default:c=`M${n},${s+l} L${n},${s+t} A${t},${t} 0 0 1 ${n+t},${s} L${n+a-t},${s} A${t},${t} 0 0 1 ${n+a},${s+t} L${n+a},${s+l} Z`}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:c,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:r,opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth})]},m)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:Mo(o.style.fill),opacity:null!==(i=o.style.opacity)&&void 0!==i?i:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},m)}case"wedge":{const i=t;if(i._gradientBand&&i._gradientBand.colors.length>0){const t=Po(`${n?n+"-":""}gauge-grad-${i.category||m}-${o}`),{clipPath:s,slices:u}=Co({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:null===(a=null===(r=i.roundedEnds)||void 0===r?void 0:r.start)||void 0===a||a,roundEnd:null===(c=null===(l=i.roundedEnds)||void 0===l?void 0:l.end)||void 0===c||c,colors:i._gradientBand.colors});return e.jsxs("g",{transform:`translate(${i.cx},${i.cy})`,opacity:i.style.opacity,fillOpacity:i.style.fillOpacity,children:[e.jsx("defs",{children:e.jsx("clipPath",{id:t,children:e.jsx("path",{d:s})})}),e.jsx("g",{clipPath:`url(#${t})`,children:u.map((t,o)=>e.jsx("path",{d:t.d,fill:Mo(t.color)},o))}),i.style.stroke&&"none"!==i.style.stroke&&e.jsx("path",{d:s,fill:"none",stroke:i.style.stroke,strokeWidth:i.style.strokeWidth})]},m)}let u;if(i.roundedEnds)u=So({innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,cornerRadius:i.cornerRadius,roundStart:i.roundedEnds.start,roundEnd:i.roundedEnds.end});else{const e=s.arc().innerRadius(i.innerRadius).outerRadius(i.outerRadius).startAngle(i.startAngle+Math.PI/2).endAngle(i.endAngle+Math.PI/2);i.cornerRadius&&e.cornerRadius(i.cornerRadius),u=e(Oo)||""}return e.jsx("path",{d:u,transform:`translate(${i.cx},${i.cy})`,fill:Mo(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},m)}case"boxplot":{const o=t,n=o.columnWidth/2;return e.jsxs("g","vertical"===o.projection?{children:[e.jsx("line",{x1:o.x,y1:o.minPos,x2:o.x,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:o.x-n,y:Math.min(o.q1Pos,o.q3Pos),width:o.columnWidth,height:Math.abs(o.q3Pos-o.q1Pos),fill:Mo(o.style.fill),fillOpacity:null!==(u=o.style.fillOpacity)&&void 0!==u?u:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-n,y1:o.medianPos,x2:o.x+n,y2:o.medianPos,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.x-.5*n,y1:o.minPos,x2:o.x+.5*n,y2:o.minPos,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.x-.5*n,y1:o.maxPos,x2:o.x+.5*n,y2:o.maxPos,stroke:o.style.stroke||"#333",strokeWidth:1})]}:{children:[e.jsx("line",{x1:o.minPos,y1:o.y,x2:o.maxPos,y2:o.y,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:Math.min(o.q1Pos,o.q3Pos),y:o.y-n,width:Math.abs(o.q3Pos-o.q1Pos),height:o.columnWidth,fill:Mo(o.style.fill),fillOpacity:null!==(d=o.style.fillOpacity)&&void 0!==d?d:.6,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.medianPos,y1:o.y-n,x2:o.medianPos,y2:o.y+n,stroke:o.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:o.minPos,y1:o.y-.5*n,x2:o.minPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:o.maxPos,y1:o.y-.5*n,x2:o.maxPos,y2:o.y+.5*n,stroke:o.style.stroke||"#333",strokeWidth:1})]},m)}case"violin":{const o=t,n=[e.jsx("path",{d:o.pathString,transform:o.translateX||o.translateY?`translate(${o.translateX},${o.translateY})`:void 0,fill:Mo(o.style.fill),fillOpacity:null!==(h=o.style.fillOpacity)&&void 0!==h?h:.6,stroke:o.style.stroke||"#333",strokeWidth:o.style.strokeWidth||1},y("path"))];if(o.iqrLine&&o.bounds){const t=o.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?n.push(e.jsx("line",{x1:i,y1:o.iqrLine.q1Pos,x2:i,y2:o.iqrLine.q3Pos,stroke:o.style.stroke||"#333",strokeWidth:2},y("iqr")),e.jsx("circle",{cx:i,cy:o.iqrLine.medianPos,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},y("med"))):n.push(e.jsx("line",{x1:o.iqrLine.q1Pos,y1:r,x2:o.iqrLine.q3Pos,y2:r,stroke:o.style.stroke||"#333",strokeWidth:2},y("iqr")),e.jsx("circle",{cx:o.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:o.style.stroke||"#333",strokeWidth:1},y("med")))}return e.jsx("g",{children:n},m)}case"connector":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:null!==(g=t.style.opacity)&&void 0!==g?g:.5},m);case"trapezoid":{const o=t,n=o.points.map(e=>`${e[0]},${e[1]}`).join(" ");return e.jsx("polygon",{points:n,fill:Mo(o.style.fill,"#999"),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},m)}default:return null}}(t,o,wt)).filter(Boolean)]})]}),e.jsx(Is,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:n,showAxes:ge,showCategoryTicks:fe,oLabel:Bt,rLabel:Nt,oFormat:Dt,rFormat:Et,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,showGrid:Te,title:Ge,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ie,legendLayout:He,foregroundGraphics:Ye(mt,null===(a=io.current)||void 0===a?void 0:a.customLayoutOverlays),annotations:_e,svgAnnotationRules:Le,annotationFrame:0,xAccessor:No,yAccessor:Ho,annotationData:Fo(null==t?void 0:t.getData())}),Ve&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:ft.left+pt/2,top:ft.top+yt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Ve})]})}return e.jsxs("div",{ref:ht,className:"stream-ordinal-frame"+(qe?" "+qe:""),role:"group","aria-label":it||("string"==typeof Ge?Ge:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:B?"100%":gt[0],height:N?"100%":gt[1],overflow:"visible"},onKeyDown:bo,children:[nt&&e.jsx(un,{tableId:wt}),nt&&e.jsx(an,{scene:null!==(c=null===(l=io.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],chartType:m+" chart",tableId:wt,chartTitle:"string"==typeof Ge?Ge:void 0}),e.jsx(cn,{summary:st}),e.jsxs("div",{role:"img","aria-label":it||("string"==typeof Ge?Ge:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:eo?xo:void 0,onMouseLeave:eo?po:void 0,children:[vt&&e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:gt[0],height:gt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${ft.left},${ft.top})`,children:vt})}),e.jsx(Ds,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Yt,showAxes:ge,showGrid:Te,rFormat:Et,rTickValues:Ae,axisExtent:Se}),e.jsx("canvas",{ref:It,"aria-label":qo(null!==(d=null===(u=io.current)||void 0===u?void 0:u.scene)&&void 0!==d?d:[],m+" chart"),style:{position:"absolute",top:0,left:0,width:gt[0],height:gt[1]}}),e.jsx(dn,{hoverPoint:zt}),e.jsx(Is,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Yt,showAxes:ge,showCategoryTicks:fe,oLabel:Bt,rLabel:Nt,oFormat:Dt,rFormat:Et,rTickValues:Ae,axisExtent:Se,showGrid:Te,title:Ge,legend:Re,legendHoverBehavior:Be,legendClickBehavior:Ne,legendHighlightedCategory:De,legendIsolatedCategories:Ee,legendPosition:Ie,legendLayout:He,foregroundGraphics:Ye(mt,Qt),annotations:_e,svgAnnotationRules:Le,annotationFrame:Xt,xAccessor:No,yAccessor:Ho,annotationData:Fo(null===(h=io.current)||void 0===h?void 0:h.getData()),underlayRendered:!0}),(tt||ot)&&"radial"!==T&&e.jsx(Hs,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Yt,onBrush:ot||(()=>{})}),Ve&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:ft.left+pt/2,top:ft.top+yt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Ve}),(null==et?void 0:et.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===et.badgePosition?{top:4,left:4}:"bottom-left"===et.badgePosition?{bottom:4,left:4}:"bottom-right"===et.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Ut?"#dc3545":"#28a745",color:"white"}),children:Ut?"STALE":"LIVE"}),e.jsx(gn,{active:yo.current>=0,hoverPoint:zt,margin:ft,size:gt,shape:null===(g=mo.current)||void 0===g?void 0:g.shape,width:null===(f=mo.current)||void 0===f?void 0:f.w,height:null===(y=mo.current)||void 0===y?void 0:y.h}),Lo]})]})});function la({ref:e,frameRef:o,setup:n}){return t.useImperativeHandle(e,()=>({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,i;return null!==(i=null===(n=o.current)||void 0===n?void 0:n.update(e,t))&&void 0!==i?i:[]},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:[]},getScales:()=>{var e,t;return null!==(t=null===(e=o.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[o]),{effectiveLegendProps:n.legendBehaviorProps,effectiveMargin:n.margin}}function ca(e){const{colorBy:o,colorScale:n,color:i,themeCategorical:r,colorScheme:s,categoryIndexMap:a,userPieceStyle:l,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:g,cycleByCategory:f=!1,baseStyleExtras:p,linkStrokeToFill:y=!1}=e,m=t.useMemo(()=>(e,t)=>{const l="function"==typeof p?p(e,t):p,c=l?Object.assign({},l):{};if(void 0===c.fill)if(o){if(!n)return c;c.fill=ke(e,o,n)}else c.fill=qi(i,r,s,f?t:void 0,a);return y&&void 0===c.stroke&&void 0!==c.fill&&(c.stroke=c.fill),c},[o,n,i,r,s,a,f,p,y]),v=t.useMemo(()=>Mr(l?"function"==typeof l?(e,t)=>Object.assign(Object.assign({},m(e,t)),l(e,t)||{}):(e,t)=>Object.assign(Object.assign({},m(e,t)),l):m,{stroke:c,strokeWidth:u,opacity:d}),[m,l,c,u,d]);return t.useMemo(()=>Ri(v,null!=h?h:null,g),[v,h,g])}aa.displayName="StreamOrdinalFrame";const ua=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sort:p=!1,barPadding:y=40,roundedTop:m,gradientFill:b=!1,baselinePadding:x=!1,tooltip:k,annotations:w,regression:A,valueExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:D,color:E,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:$,categoryFormat:W,dataIdAccessor:z}=o,{width:G,height:Y,enableHover:q,showGrid:X,showLegend:V,title:U,description:K,summary:Q,accessibleTable:Z,categoryLabel:J,valueLabel:ee}=i,te=t.useMemo(()=>v(s),[s]),oe=Or({data:te,rawData:s,colorBy:g,colorScheme:f,legendInteraction:N,legendPosition:D,selection:C,linkedHover:O,fallbackFields:g?["string"==typeof g?g:""]:[],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:_,chartType:"BarChart",chartId:L,showLegend:V,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:G,height:Y}),{effectiveLegendProps:ne,effectiveMargin:ie}=la({ref:n,frameRef:r,setup:oe});if(oe.earlyReturn)return oe.earlyReturn;vr("BarChart",te,"categoryAccessor",c),vr("BarChart",te,"valueAccessor",u);const re=Vi(te,p,u),se=Yi(),ae=t.useMemo(()=>new Map,[te]),le=ca({colorBy:g,colorScale:oe.colorScale,color:E,themeCategorical:se,colorScheme:f,categoryIndexMap:ae,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection}),ce=t.useMemo(()=>lr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",valueFormat:h}),[c,u,g,h]),ue=Ar({componentName:"BarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(cr,{componentName:"BarChart",message:ue,width:G,height:Y});const de=Qr(A),he=de?[de,...w||[]]:w,ge=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:"bar"},null!=s&&{data:re}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[G,Y],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ie,barPadding:y}),null!=m&&{roundedTop:m}),b&&{gradientFill:!0===b?{topOpacity:.8,bottomOpacity:.05}:b}),z&&{dataIdAccessor:z}),{baselinePadding:x,enableHover:q,showAxes:i.showAxes,oLabel:J,rLabel:ee,rFormat:h}),W&&{oFormat:W}),{showGrid:X,showCategoryTicks:$,oSort:p}),ne),Fr({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:ce})),$r({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior})),he&&he.length>0&&{annotations:he}),j&&{rExtent:j}),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"BarChart",width:G,height:Y,children:e.jsx(aa,Object.assign({ref:r},ge))})});ua.displayName="BarChart";const da=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",stackBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,normalize:y=!1,sort:m=!1,barPadding:b=40,roundedTop:x,baselinePadding:k=!1,tooltip:w,annotations:A,valueExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:D,color:E,stroke:I,strokeWidth:H,opacity:F,categoryFormat:$}=o,{width:W,height:z,enableHover:G,showGrid:Y,showLegend:q,title:X,description:V,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=f||u,te=Or({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:N,legendPosition:D,selection:C,linkedHover:O,fallbackFields:ee?["string"==typeof ee?ee:""]:[],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:_,chartType:"StackedBarChart",chartId:L,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:W,height:z});if(te.earlyReturn)return te.earlyReturn;const oe=Yi(),ne=t.useMemo(()=>new Map,[J]),ie=ca({colorBy:ee,colorScale:te.colorScale,color:E,themeCategorical:oe,colorScheme:p,categoryIndexMap:ne,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=t.useMemo(()=>lr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),se=Ar({componentName:"StackedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{stackBy:u}}),{effectiveLegendProps:ae,effectiveMargin:le}=la({ref:n,frameRef:r,setup:te}),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({chartType:"bar"},null!=s&&{data:J}),{oAccessor:c,rAccessor:d,stackBy:u,normalize:y,oSort:m,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ie,size:[W,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:le,barPadding:b}),null!=x&&{roundedTop:x}),{baselinePadding:k,enableHover:G}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),$&&{oFormat:$}),{showGrid:Y}),ae),Fr({title:X,description:V,summary:U,accessibleTable:K,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:w,defaultTooltipContent:re})),$r({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior})),A&&A.length>0&&{annotations:A}),j&&{rExtent:j}),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return se?e.jsx(cr,{componentName:"StackedBarChart",message:se,width:W,height:z}):e.jsx(gr,{componentName:"StackedBarChart",width:W,height:z,children:e.jsx(aa,Object.assign({ref:r},ce))})});da.displayName="StackedBarChart";const ha=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",groupBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:g,colorBy:f,colorScheme:p,sort:y=!1,barPadding:m=60,roundedTop:b,baselinePadding:x=!1,tooltip:k,annotations:w,valueExtent:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:D,stroke:E,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:$,height:W,enableHover:z,showGrid:G,showLegend:Y,title:q,description:X,summary:V,accessibleTable:U,categoryLabel:K,valueLabel:Q}=i,Z=t.useMemo(()=>v(s),[s]),J=f||u,ee=Or({data:Z,rawData:s,colorBy:J,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:C,fallbackFields:J?["string"==typeof J?J:""]:[],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:P,chartType:"GroupedBarChart",chartId:_,showLegend:Y,userMargin:a,marginDefaults:i.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:$,height:W});if(ee.earlyReturn)return ee.earlyReturn;const te=Yi(),oe=t.useMemo(()=>new Map,[Z]),ne=ca({colorBy:J,colorScale:ee.colorScale,color:D,themeCategorical:te,colorScheme:p,categoryIndexMap:oe,userPieceStyle:j.pieceStyle,stroke:E,strokeWidth:I,opacity:H,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ie=t.useMemo(()=>lr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),re=Ar({componentName:"GroupedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{groupBy:u}}),{effectiveLegendProps:se,effectiveMargin:ae}=la({ref:n,frameRef:r,setup:ee}),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({chartType:"clusterbar"},null!=s&&{data:Z}),{oAccessor:c,rAccessor:d,groupBy:u,oSort:y,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ne,size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ae,barPadding:m}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:K,rLabel:Q,rFormat:g}),F&&{oFormat:F}),{showGrid:G}),se),Fr({title:q,description:X,summary:V,accessibleTable:U,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:ie})),$r({linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior})),w&&w.length>0&&{annotations:w}),A&&{rExtent:A}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return re?e.jsx(cr,{componentName:"GroupedBarChart",message:re,width:$,height:W}):e.jsx(gr,{componentName:"GroupedBarChart",width:$,height:W,children:e.jsx(aa,Object.assign({ref:r},le))})});function ga({brushProp:e,onBrushProp:o,linkedBrush:n,valueAccessor:i}){const r=Ti("string"==typeof n?n:n?{name:n.name,xField:n.rField}:void 0),s=xi({name:(null==r?void 0:r.name)||"__unused_ordinal_brush__",xField:(null==r?void 0:r.xField)||("string"==typeof i?i:"value")}),a=t.useRef(s.brushInteraction);a.current=s.brushInteraction;const l=t.useCallback(e=>{if(r){a.current.end(e?e.r:null)}null==o||o(e)},[o,r]),c=!!(e||n||o);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}ha.displayName="GroupedBarChart";const fa=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,sizeBy:p,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:b=.7,categoryPadding:x=20,tooltip:k,annotations:w,valueExtent:A,brush:j,onBrush:S,linkedBrush:C,frameProps:O={},selection:M,linkedHover:P,onObservation:_,onClick:L,hoverHighlight:T,chartId:R,loading:B,loadingContent:N,emptyContent:D,legendInteraction:E,legendPosition:I,color:H,stroke:F,strokeWidth:$,opacity:W,showCategoryTicks:z,categoryFormat:G}=o,{width:Y,height:q,enableHover:X,showGrid:V,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=i,oe=t.useMemo(()=>v(s),[s]),ne=Or({data:oe,rawData:s,colorBy:g,colorScheme:f,legendInteraction:E,legendPosition:I,selection:M,linkedHover:P,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:_,onClick:L,hoverHighlight:T,chartType:"SwarmPlot",chartId:R,showLegend:U,userMargin:a,marginDefaults:i.marginDefaults,loading:B,loadingContent:N,emptyContent:D,width:Y,height:q}),ie=ga({brushProp:j,onBrushProp:S,linkedBrush:C,valueAccessor:u});if(ne.earlyReturn)return ne.earlyReturn;const re=t.useMemo(()=>{if(!p)return;const e=oe.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[oe,p]),se=Yi(),ae=t.useMemo(()=>new Map,[oe]),le=ca({colorBy:g,colorScale:ne.colorScale,color:H,themeCategorical:se,colorScheme:f,categoryIndexMap:ae,userPieceStyle:null==O?void 0:O.pieceStyle,stroke:F,strokeWidth:$,opacity:W,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection,baseStyleExtras:e=>({fillOpacity:b,r:p?Ae(e,p,y,re):m})}),ce=t.useMemo(()=>lr({categoryAccessor:c,valueAccessor:u,groupAccessor:g||void 0,valueFormat:h}),[c,u,g,h]),ue=Ar({componentName:"SwarmPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(cr,{componentName:"SwarmPlot",message:ue,width:Y,height:q});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({chartType:"swarm"},null!=s&&{data:oe}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[Y,q],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ne.margin,barPadding:x,enableHover:X}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:ee,rLabel:te,rFormat:h}),G&&{oFormat:G}),{showGrid:V,showCategoryTicks:z}),ne.legendBehaviorProps),Fr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:ce})),$r({linkedHover:P,onObservation:_,onClick:L,hoverHighlight:T,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior})),w&&w.length>0&&{annotations:w}),A&&{rExtent:A}),ie.brushStreamProps),Object.fromEntries(Object.entries(O).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"SwarmPlot",width:Y,height:q,children:e.jsx(aa,Object.assign({ref:r},de))})});function pa(t){return o=>{var n;const i=o.category||o.data&&(null===(n=o.data[0])||void 0===n?void 0:n.category)||"",r=o.stats||(o.data||o).stats;if(r&&null!=r.median)return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),null!=r.n&&e.jsxs("div",{children:["n = ",r.n]}),null!=r.min&&e.jsxs("div",{children:["Min: ",r.min.toLocaleString()]}),null!=r.q1&&e.jsxs("div",{children:["Q1: ",r.q1.toLocaleString()]}),e.jsxs("div",{children:["Median: ",r.median.toLocaleString()]}),null!=r.q3&&e.jsxs("div",{children:["Q3: ",r.q3.toLocaleString()]}),null!=r.max&&e.jsxs("div",{children:["Max: ",r.max.toLocaleString()]}),null!=r.mean&&e.jsxs("div",{style:{opacity:.8},children:["Mean: ",r.mean.toLocaleString(void 0,{maximumFractionDigits:2})]})]});if(null==t?void 0:t.valueAccessor){const n=t.valueAccessor,r=(Array.isArray(o.data)?o.data:[]).map(e=>Number("function"==typeof n?n(e):e[n])).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t),s=r.length,a=s>0?s%2!=0?r[Math.floor(s/2)]:(r[s/2-1]+r[s/2])/2:null;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[i&&e.jsx("div",{style:{fontWeight:"bold"},children:i+""}),s>0&&e.jsxs("div",{children:["n = ",s]}),null!=a&&e.jsxs("div",{children:["Median: ",a.toLocaleString()]})]})}return e.jsx("div",{className:"semiotic-tooltip",style:yn,children:e.jsx("div",{style:{fontWeight:"bold"},children:i+""})})}}fa.displayName="SwarmPlot";const ya=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:g,colorScheme:f,showOutliers:p=!0,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,frameProps:k={},selection:w,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:C,chartId:O,loading:M,loadingContent:P,emptyContent:_,legendInteraction:L,legendPosition:T,color:R,stroke:B,strokeWidth:N,opacity:D,showCategoryTicks:E,categoryFormat:I}=o,{width:H,height:F,enableHover:$,showGrid:W,showLegend:z,title:G,description:Y,summary:q,accessibleTable:X,categoryLabel:V,valueLabel:U}=i,K=t.useMemo(()=>v(s),[s]),Q=Or({data:K,rawData:s,colorBy:g,colorScheme:f,legendInteraction:L,legendPosition:T,selection:w,linkedHover:A,fallbackFields:g?["string"==typeof g?g:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:C,chartType:"BoxPlot",chartId:O,showLegend:z,userMargin:a,marginDefaults:i.marginDefaults,loading:M,loadingContent:P,emptyContent:_,width:H,height:F});if(Q.earlyReturn)return Q.earlyReturn;const Z=Yi(),J=t.useMemo(()=>new Map,[K]),ee=ca({colorBy:g,colorScale:Q.colorScale,color:R,themeCategorical:Z,colorScheme:f,categoryIndexMap:J,userPieceStyle:void 0,stroke:B,strokeWidth:N,opacity:D,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),te=t.useMemo(()=>pa(),[]),oe=Ar({componentName:"BoxPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(oe)return e.jsx(cr,{componentName:"BoxPlot",message:oe,width:H,height:F});const 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({chartType:"boxplot"},null!=s&&{data:K}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ee,showOutliers:p,size:[H,F],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Q.margin,barPadding:y,enableHover:$}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:U,rFormat:h}),I&&{oFormat:I}),{showGrid:W,showCategoryTicks:E}),Q.legendBehaviorProps),Fr({title:G,description:Y,summary:q,accessibleTable:X,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:te})),$r({linkedHover:A,onObservation:j,onClick:S,hoverHighlight:C,customHoverBehavior:Q.customHoverBehavior,customClickBehavior:Q.customClickBehavior})),b&&b.length>0&&{annotations:b}),x&&{rExtent:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"BoxPlot",width:H,height:F,children:e.jsx(aa,Object.assign({ref:r},ne))})});ya.displayName="BoxPlot";const ma=e=>{const t=null==e?void 0:e.category;return null==t?"All":t+""},va=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:"horizontal"}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c=ma,valueAccessor:u="value",bins:d=25,relative:h=!1,valueFormat:g,colorBy:f,colorScheme:p,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,brush:k,onBrush:w,linkedBrush:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:D,stroke:E,strokeWidth:I,opacity:H,showCategoryTicks:F,categoryFormat:$}=o,{width:W,height:z,enableHover:G,showGrid:Y,showLegend:q,title:X,description:V,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=Or({data:J,rawData:s,colorBy:f,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:P,chartType:"Histogram",chartId:_,showLegend:q,userMargin:a,marginDefaults:i.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:W,height:z}),te=ga({brushProp:k,onBrushProp:w,linkedBrush:A,valueAccessor:u});if(ee.earlyReturn)return ee.earlyReturn;const oe=t.useMemo(()=>{if(0===J.length)return;const e="function"==typeof u?u:e=>e[u];let t=1/0,o=-1/0;for(const n of J){const i=e(n);null!=i&&isFinite(i)&&(t>i&&(t=i),i>o&&(o=i))}return t>o?void 0:[t,o]},[J,u]),ne=Yi(),ie=t.useMemo(()=>new Map,[J]),re=ca({colorBy:f,colorScale:ee.colorScale,color:D,themeCategorical:ne,colorScheme:p,categoryIndexMap:ie,userPieceStyle:void 0,stroke:E,strokeWidth:I,opacity:H,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),se=t.useMemo(()=>t=>{const o=t.data||t,n=o.category||t.category||"",i=o.count,r=o.range;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[n&&e.jsx("div",{style:{fontWeight:"bold"},children:n+""}),null!=i&&e.jsxs("div",{children:["Count: ",i]}),r&&2===r.length&&e.jsxs("div",{style:{opacity:.8},children:[Number(r[0]).toFixed(1)," – ",Number(r[1]).toFixed(1)]})]})},[]),ae=Ar({componentName:"Histogram",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(cr,{componentName:"Histogram",message:ae,width:W,height:z});const 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({chartType:"histogram"},null!=s&&{data:J}),{oAccessor:c,rAccessor:u,projection:"horizontal",summaryStyle:re,bins:d,normalize:h}),x?{rExtent:x}:oe&&{rExtent:oe}),{size:[W,z],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee.margin,barPadding:y,enableHover:G}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),$&&{oFormat:$}),{showGrid:Y,showCategoryTicks:F}),ee.legendBehaviorProps),Fr({title:X,description:V,summary:U,accessibleTable:K,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:se})),$r({linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior})),b&&b.length>0&&{annotations:b}),te.brushStreamProps),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"Histogram",width:W,height:z,children:e.jsx(aa,Object.assign({ref:r},le))})});va.displayName="Histogram";const ba=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",bins:h=25,showIQR:g=!0,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:m=20,tooltip:b,annotations:x,valueExtent:k,brush:w,onBrush:A,linkedBrush:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:D,color:E,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:$,categoryFormat:W}=o,{width:z,height:G,enableHover:Y,showGrid:q,showLegend:X,title:V,description:U,summary:K,accessibleTable:Q,categoryLabel:Z,valueLabel:J}=i,ee=t.useMemo(()=>v(s),[s]),te=Or({data:ee,rawData:s,colorBy:p,colorScheme:y,legendInteraction:N,legendPosition:D,selection:C,linkedHover:O,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:_,chartType:"ViolinPlot",chartId:L,showLegend:X,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:R,emptyContent:B,width:z,height:G}),oe=ga({brushProp:w,onBrushProp:A,linkedBrush:j,valueAccessor:u});if(te.earlyReturn)return te.earlyReturn;const ne=Yi(),ie=t.useMemo(()=>new Map,[ee]),re=ca({colorBy:p,colorScale:te.colorScale,color:E,themeCategorical:ne,colorScheme:y,categoryIndexMap:ie,userPieceStyle:void 0,stroke:I,strokeWidth:H,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),se=t.useMemo(()=>pa({valueAccessor:u}),[u]),ae=Ar({componentName:"ViolinPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(cr,{componentName:"ViolinPlot",message:ae,width:z,height:G});const 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({chartType:"violin"},null!=s&&{data:ee}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:re,bins:h,showIQR:g,size:[z,G],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:te.margin,barPadding:m,enableHover:Y}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Z,rLabel:J,rFormat:f}),W&&{oFormat:W}),{showGrid:q,showCategoryTicks:$}),te.legendBehaviorProps),Fr({title:V,description:U,summary:K,accessibleTable:Q,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:b,defaultTooltipContent:se})),$r({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior})),x&&x.length>0&&{annotations:x}),k&&{rExtent:k}),oe.brushStreamProps),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"ViolinPlot",width:z,height:G,children:e.jsx(aa,Object.assign({ref:r},le))})});ba.displayName="ViolinPlot";const xa=t.forwardRef(function(o,n){var i;const r=er(o.mode,{width:o.width,height:o.height,showGrid:null===(i=o.showGrid)||void 0===i||i,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),s=t.useRef(null);_r(n,{variant:"xy",frameRef:s});const{data:a,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,sort:y="auto",dotRadius:m=5,categoryPadding:b=10,tooltip:x,annotations:k,regression:w,valueExtent:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:R,legendInteraction:B,legendPosition:N,color:D,stroke:E,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:$,height:W,enableHover:z,showGrid:G,showLegend:Y,title:q,description:X,summary:V,accessibleTable:U,categoryLabel:K,valueLabel:Q}=r,Z=t.useMemo(()=>v(a),[a]),J=Or({data:Z,rawData:a,colorBy:f,colorScheme:p,legendInteraction:B,legendPosition:N,selection:S,linkedHover:C,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof u?u:""],unwrapData:!0,onObservation:O,onClick:M,hoverHighlight:P,chartType:"DotPlot",chartId:_,showLegend:Y,userMargin:l,marginDefaults:r.marginDefaults,loading:L,loadingContent:T,emptyContent:R,width:$,height:W});if(J.earlyReturn)return J.earlyReturn;const ee=Vi(Z,y,d),te=Yi(),oe=t.useMemo(()=>new Map,[Z]),ne=ca({colorBy:f,colorScale:J.colorScale,color:D,themeCategorical:te,colorScheme:p,categoryIndexMap:oe,userPieceStyle:null==j?void 0:j.pieceStyle,stroke:E,strokeWidth:I,opacity:H,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection,baseStyleExtras:{r:m,fillOpacity:.8}}),ie=t.useMemo(()=>lr({categoryAccessor:u,valueAccessor:d,valueFormat:g}),[u,d,g]),re=Ar({componentName:"DotPlot",data:a,accessors:{categoryAccessor:u,valueAccessor:d}});if(re)return e.jsx(cr,{componentName:"DotPlot",message:re,width:$,height:W});const se=Qr(w),ae=se?[se,...k||[]]:k,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({chartType:"point"},null!=a&&{data:ee}),{oAccessor:u,rAccessor:d,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:ne,size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J.margin,barPadding:b,enableHover:z}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:r.showAxes,oLabel:K,rLabel:Q,rFormat:g}),F&&{oFormat:F}),{showGrid:G,oSort:y}),J.legendBehaviorProps),Fr({title:q,description:X,summary:V,accessibleTable:U,className:c,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:x,defaultTooltipContent:ie})),$r({linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior})),ae&&ae.length>0&&{annotations:ae}),A&&{rExtent:A}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"DotPlot",width:$,height:W,children:e.jsx(aa,Object.assign({ref:s},le))})});xa.displayName="DotPlot";const ka=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",bins:h=20,amplitude:g=1.5,valueFormat:f,colorBy:p,colorScheme:y,categoryPadding:m=5,tooltip:b,annotations:x,valueExtent:k,frameProps:w={},selection:A,linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,chartId:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:R,color:B,stroke:N,strokeWidth:D,opacity:E,showCategoryTicks:I,categoryFormat:H}=o,{width:F,height:$,enableHover:W,showGrid:z,showLegend:G,title:Y,description:q,summary:X,accessibleTable:V,categoryLabel:U,valueLabel:K}=i,Q=t.useMemo(()=>v(s),[s]),Z=Or({data:Q,rawData:s,colorBy:p,colorScheme:y,legendInteraction:T,legendPosition:R,selection:A,linkedHover:j,fallbackFields:p?["string"==typeof p?p:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:S,onClick:C,hoverHighlight:O,chartType:"RidgelinePlot",chartId:M,showLegend:G,userMargin:a,marginDefaults:i.marginDefaults,loading:P,loadingContent:_,emptyContent:L,width:F,height:$});if(Z.earlyReturn)return Z.earlyReturn;const J=Yi(),ee=t.useMemo(()=>new Map,[Q]),te=ca({colorBy:p,colorScale:Z.colorScale,color:B,themeCategorical:J,colorScheme:y,categoryIndexMap:ee,userPieceStyle:void 0,stroke:N,strokeWidth:D,opacity:E,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),oe=t.useMemo(()=>pa(),[]),ne=Ar({componentName:"RidgelinePlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ne)return e.jsx(cr,{componentName:"RidgelinePlot",message:ne,width:F,height:$});const 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({chartType:"ridgeline"},null!=s&&{data:Q}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:te,bins:h,size:[F,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:Z.margin,barPadding:m,enableHover:W}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:f}),H&&{oFormat:H}),{showGrid:z,showCategoryTicks:I,oSort:!1,amplitude:g}),Z.legendBehaviorProps),Fr({title:Y,description:q,summary:X,accessibleTable:V,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:b,defaultTooltipContent:oe})),$r({linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior})),x&&x.length>0&&{annotations:x}),k&&{rExtent:k}),Object.fromEntries(Object.entries(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"RidgelinePlot",width:F,height:$,children:e.jsx(aa,Object.assign({ref:r},ie))})});ka.displayName="RidgelinePlot";const wa=t.forwardRef(function(o,n){var i,r;const s=er(o.mode,{width:null!==(i=o.width)&&void 0!==i?i:400,height:null!==(r=o.height)&&void 0!==r?r:400,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:o.showCategoryTicks}),a=t.useRef(null),{data:l,margin:c,className:u,categoryAccessor:d="category",valueAccessor:h="value",colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:D,height:E,enableHover:I,showLegend:H,title:F,description:$,summary:W,accessibleTable:z}=s,G=t.useMemo(()=>v(l),[l]),Y=g||d,q=Or({data:G,rawData:l,colorBy:Y,colorScheme:f,legendInteraction:_,legendPosition:L,selection:k,linkedHover:w,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"PieChart",chartId:C,showLegend:H,userMargin:c,marginDefaults:s.marginDefaults,loading:O,loadingContent:M,emptyContent:P,width:D,height:E});if(q.earlyReturn)return q.earlyReturn;const X=Yi(),V=t.useMemo(()=>new Map,[G]),U=ca({colorBy:Y,colorScale:q.colorScale,color:T,themeCategorical:X,colorScheme:f,categoryIndexMap:V,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),K=t.useMemo(()=>lr({categoryAccessor:d,valueAccessor:h,groupAccessor:g&&g!==d?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[d,h,g]),Q=Ar({componentName:"PieChart",data:l,accessors:{categoryAccessor:d,valueAccessor:h}}),{effectiveLegendProps:Z,effectiveMargin:J}=la({ref:n,frameRef:a,setup:q}),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({chartType:"pie"},null!=l&&{data:G}),{oAccessor:d,rAccessor:h,projection:"radial",pieceStyle:U,startAngle:p}),null!=y&&{cornerRadius:y}),{size:[D,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:J,enableHover:I}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),Z),Fr({title:F,description:$,summary:W,accessibleTable:z,className:u,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:K})),$r({linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,customHoverBehavior:q.customHoverBehavior,customClickBehavior:q.customClickBehavior})),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return Q?e.jsx(cr,{componentName:"PieChart",message:Q,width:D,height:E}):e.jsx(gr,{componentName:"PieChart",width:D,height:E,children:e.jsx(aa,Object.assign({ref:a},ee))})});wa.displayName="PieChart";const Aa=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover,showCategoryTicks:o.showCategoryTicks},{width:400,height:400}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",innerRadius:d,centerContent:h,colorBy:g,colorScheme:f,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:D,height:E,enableHover:I,showLegend:H,title:F,description:$,summary:W,accessibleTable:z}=i,G=t.useMemo(()=>v(s),[s]),Y=g||c,q=Or({data:G,rawData:s,colorBy:Y,colorScheme:f,legendInteraction:_,legendPosition:L,selection:k,linkedHover:w,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"DonutChart",chartId:C,showLegend:H,userMargin:a,marginDefaults:i.marginDefaults,loading:O,loadingContent:M,emptyContent:P,width:D,height:E});if(q.earlyReturn)return q.earlyReturn;const X=null!=d?d:Math.max(2,.15*Math.min(D,E)),V=Yi(),U=t.useMemo(()=>new Map,[G]),K=ca({colorBy:Y,colorScale:q.colorScale,color:T,themeCategorical:V,colorScheme:f,categoryIndexMap:U,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),Q=t.useMemo(()=>lr({categoryAccessor:c,valueAccessor:u,groupAccessor:g&&g!==c?g:void 0,groupLabel:"string"==typeof g?g:"group",pieData:!0}),[c,u,g]),Z=Ar({componentName:"DonutChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}}),{effectiveLegendProps:J,effectiveMargin:ee}=la({ref:n,frameRef:r,setup:q}),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({chartType:"donut"},null!=s&&{data:G}),{oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:K,innerRadius:X,startAngle:p}),null!=y&&{cornerRadius:y}),{centerContent:h,size:[D,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ee,enableHover:I}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:!1}),J),Fr({title:F,description:$,summary:W,accessibleTable:z,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:Q})),$r({linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,customHoverBehavior:q.customHoverBehavior,customClickBehavior:q.customClickBehavior})),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return Z?e.jsx(cr,{componentName:"DonutChart",message:Z,width:D,height:E}):e.jsx(gr,{componentName:"DonutChart",width:D,height:E,children:e.jsx(aa,Object.assign({ref:r},te))})});function ja(e=240){const t=360-e,o=180+t/2,n=o*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:o,startAngleRad:n,offsetRad:-Math.PI/2+n}}function Sa(e){return Math.max(0,Math.min(1,e))}function Ca(e){const t=e.trim();if(t.startsWith("#")){let e=t.slice(1);if(3===e.length&&(e=e.split("").map(e=>e+e).join("")),6===e.length&&/^[0-9a-f]{6}$/i.test(e))return[parseInt(e.slice(0,2),16),parseInt(e.slice(2,4),16),parseInt(e.slice(4,6),16)]}const o=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(o){const e=[Number(o[1]),Number(o[2]),Number(o[3])];if(e.every(Number.isFinite))return e}return null}function Oa(e,t,o){const n=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${n(e)}${n(t)}${n(o)}`}function Ma(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Sa(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===o.length)return"#999999";if(1===o.length)return o[0].color;const n=Sa(t);if(o[0].offset>=n)return o[0].color;if(n>=o[o.length-1].offset)return o[o.length-1].color;for(let e=0;o.length-1>e;e++){const t=o[e],i=o[e+1];if(t.offset>n||n>i.offset)continue;const r=i.offset-t.offset,s=r>0?(n-t.offset)/r:0,a=Ca(t.color),l=Ca(i.color);if(!a||!l)return.5>s?t.color:i.color;const[c,u,d]=a,[h,g,f]=l;return Oa(c+(h-c)*s,u+(g-u)*s,d+(f-d)*s)}return o[o.length-1].color}function Pa(e,t,o){return`${e}-${t}`}Aa.displayName="DonutChart";const _a=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:!1,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:300,height:250}),r=t.useRef(null),s="context"===o.mode,{compactMode:a}=i,{value:l,min:c=0,max:u=100,thresholds:d,gradientFill:h,color:g,backgroundColor:f="var(--semiotic-grid, #e0e0e0)",arcWidth:p=.3,cornerRadius:y,showNeedle:m=!0,needleColor:v="var(--semiotic-text, #333)",centerContent:b,valueFormat:x,showScaleLabels:k=!a,sweep:w=240,fillZones:A=!0,tooltip:j,annotations:S,frameProps:C={},className:O,stroke:M,strokeWidth:P,opacity:_}=o,{width:L,height:T,title:R,description:B,summary:N,accessibleTable:D}=i,E=h&&"object"==typeof h?h:void 0,I=Math.max(c,Math.min(u,l)),H=u-c||1,F=(I-c)/H,{gaugeData:$,pieceStyle:W,gaugeAnnotations:z}=t.useMemo(()=>function(e){const{min:t,max:o,value:n,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=o-t||1,h=(Math.max(t,Math.min(o,n))-t)/d;let g=i&&i.length>0?[...i].sort((e,t)=>e.value-t.value):[{value:o,color:r||"#007bff"}];g=g.map(e=>Object.assign(Object.assign({},e),{value:Math.max(t,Math.min(o,e.value))})),o>g[g.length-1].value&&g.push({value:o,color:g[g.length-1].color});const f=!!c&&c.colorStops.length>=2,p=[],y=new Map,m=[];if(f){const e=a?h:1,t=Pa("bg",0);if(p.push({category:t,value:1,_zone:"Track",_isFill:!1,_pctStart:0,_pct:1,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0}),y.set(t,{fill:s,opacity:.4}),e>0){const t=Math.max(1,Math.floor(u)),o=Math.max(1,Math.min(t,Math.round(e*t))),n=[];for(let t=0;o>t;t++)n.push(Ma(c.colorStops,e*(t+.5)/o));const i=Pa("fill",0);p.push({category:i,value:e,_zone:"Gradient",_isFill:!0,_pctStart:0,_pct:e,_roundedEnds:{start:!0,end:!0},_nonInteractive:!0,_gradientBand:{colors:n}}),y.set(i,{fill:n[0]||s})}}else{let e=t;for(let o=0;g.length>o;o++){const n=g[o],i=(n.value-e)/d,r=(e-t)/d,l=(n.value-t)/d,c=Math.max(0,(a?Math.min(h,l):l)-r),u=a?Math.max(0,i-c):0;if(c>0){const e=Pa("fill",o);p.push({category:e,value:c,_zone:n.label||"Zone "+(o+1),_isFill:!0}),y.set(e,{fill:n.color})}if(u>0){const e=Pa("bg",o);p.push({category:e,value:u,_zone:n.label||"Zone "+(o+1),_isFill:!1}),y.set(e,{fill:s,opacity:.4})}e=n.value}}if(l&&i&&i.length>0)for(const e of i)e.value>t&&o>e.value&&m.push({type:"gauge-label",value:e.value,label:e.label||e.value+""});return{gaugeData:p,pieceStyle:(e,t)=>y.get(t||e.category)||{fill:s},gaugeAnnotations:m}}({min:c,max:u,value:l,thresholds:d,fillColor:g,backgroundColor:f,fillZones:A,showScaleLabels:k,gradientFill:E}),[l,c,u,d,g,f,k,A,E]),G=t.useMemo(()=>Mr(W,{stroke:M,strokeWidth:P,opacity:_}),[W,M,P,_]),{sweepRad:Y,startAngleDeg:q}=ja(w),X=function(e=240){const{sweepRad:t,offsetRad:o}=ja(e),n=[[Math.cos(o),Math.sin(o)],[Math.cos(o+t),Math.sin(o+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-o)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||n.push([Math.cos(e),Math.sin(e)]);const i=n.map(e=>e[0]),r=n.map(e=>e[1]),s=Math.min(...i),a=Math.max(...i),l=Math.min(...r),c=Math.max(...r);return{minX:s,maxX:a,minY:l,maxY:c,width:a-s,height:c-l,cx:(s+a)/2,cy:(l+c)/2}}(w),V=Math.min(10,Math.max(1,Math.min(L,T)/12)),U=X.cx,K=X.cy,Q=Math.max(4,Math.min((L-2*V)/X.width,(T-2*V)/X.height)-2),Z=Math.max(0,Math.min(Q-1.5,Q*(1-p))),J=L/2-U*Q,ee=T/2-K*Q,te=2*(Q+4),oe=t.useMemo(()=>{if(a&&null==b)return null;if(null!=b)return"function"==typeof b?b(I,c,u):b;const t=x?x(I):Math.round(I)+"";return e.jsxs("div",{style:{textAlign:"center",lineHeight:1.2},children:[e.jsx("div",{style:{fontSize:Math.max(16,.3*Q),fontWeight:700,color:"var(--semiotic-text, #333)"},children:t}),k&&e.jsxs("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",u]})]})},[b,I,c,u,x,k,Q,a]),ne=t.useMemo(()=>s&&null==b?{type:"gauge-value",text:x?x(I):Math.round(I)+""}:null,[s,b,I,x]),ie=t.useMemo(()=>{if(!m)return null;const e=-Math.PI/2+q*Math.PI/180+F*Y,t=Z>20?Z-8:Q-1;return{type:"gauge-needle",tipX:Math.cos(e)*t,tipY:Math.sin(e)*t,color:v}},[m,F,q,Y,Z,v]),re=t.useMemo(()=>(t,o,n)=>{if("gauge-needle"===t.type){const i=(n.width||L)/2,r=(n.height||T)/2,s=Math.max(1,Q-Z),a=Math.max(1,Math.min(2.5,.4*s)),l=Math.max(1,Math.min(5,.6*s));return e.jsxs("g",{transform:`translate(${i},${r})`,children:[e.jsx("line",{x1:0,y1:0,x2:t.tipX,y2:t.tipY,stroke:t.color,strokeWidth:a,strokeLinecap:"round"}),e.jsx("circle",{cx:0,cy:0,r:l,fill:t.color})]},"gauge-needle-"+o)}if("gauge-label"===t.type){const i=-Math.PI/2+q*Math.PI/180+(t.value-c)/H*Y,r=(n.width||L)/2,s=(n.height||T)/2,a=Z-1,l=Q+1,u=Math.cos(i)*a,d=Math.sin(i)*a,h=Math.cos(i)*l,g=Math.sin(i)*l,f=Q+10,p=Math.cos(i)*f,y=Math.sin(i)*f,m=((i+Math.PI/2)/(2*Math.PI)*12+12)%12;let v="middle",b="middle";return m>=11||1>m?(v="middle",b="auto"):m>=1&&5>m?(v="start",b="middle"):m>=5&&7>m?(v="middle",b="hanging"):(v="end",b="middle"),e.jsxs("g",{transform:`translate(${r},${s})`,children:[e.jsx("line",{x1:u,y1:d,x2:h,y2:g,stroke:"var(--semiotic-border)",strokeWidth:2,strokeLinecap:"round"}),e.jsx("text",{x:p,y:y,textAnchor:v,dominantBaseline:b,fill:"var(--semiotic-text-secondary, #666)",style:{userSelect:"none",fontSize:"var(--semiotic-gauge-label-font-size, 10px)"},children:t.label})]},"gauge-label-"+o)}return"gauge-value"===t.type?e.jsx("text",{x:(n.width||L)/2,y:(n.height||T)/2-.2*Z,textAnchor:"middle",dominantBaseline:"middle",fontSize:Math.max(12,Math.min(22,.28*Q)),fontWeight:700,fill:"var(--semiotic-text, #333)",style:{userSelect:"none"},children:t.text},"gauge-value-"+o):null},[L,T,c,H,q,Y,Z,Q]),se=t.useMemo(()=>{const e=[...z,...S||[]];return ie&&e.push(ie),ne&&e.push(ne),e},[z,S,ie,ne]),ae=t.useMemo(()=>t=>{var o;const n=(null===(o=null==t?void 0:t.data)||void 0===o?void 0:o[0])||(null==t?void 0:t.data)||t,i=null==n?void 0:n._isFill;return e.jsxs("div",{className:"semiotic-tooltip",style:{padding:"6px 10px",background:"var(--semiotic-tooltip-bg, white)",borderRadius:"var(--semiotic-tooltip-radius, 6px)",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0,0,0,0.15))"},children:[e.jsx("div",{style:{fontWeight:600},children:(null==n?void 0:n._zone)||""}),e.jsx("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:i?"Current: "+Math.round(I):"Remaining"})]})},[I]);if(0===$.length)return e.jsx(cr,{componentName:"GaugeChart",message:"No data to display",width:L,height:T});const le=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut",data:$,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:G,innerRadius:Z,startAngle:q,sweepAngle:w},null!=y&&{cornerRadius:y}),{centerContent:oe,size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:{top:ee-te/2,bottom:T-ee-te/2,left:J-te/2,right:L-J-te/2},enableHover:i.enableHover,showAxes:!1,showCategoryTicks:!1,tooltipContent:!1===j?()=>null:kn(j)||ae,svgAnnotationRules:re}),se.length>0&&{annotations:se}),R&&{title:R}),B&&{description:B}),N&&{summary:N}),void 0!==D&&{accessibleTable:D}),O&&{className:O}),null!=o.animate&&{animate:o.animate}),C);return e.jsx(gr,{componentName:"GaugeChart",width:L,height:T,children:e.jsx(aa,Object.assign({ref:r},le))})});_a.displayName="GaugeChart";const La=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:!1,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,showCategoryTicks:!1}),r=t.useRef(null);_r(n,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,stepAccessor:c="step",valueAccessor:u="value",categoryAccessor:d,colorBy:h,colorScheme:g,orientation:f="horizontal",connectorOpacity:p=.3,showLabels:y=!0,tooltip:m,annotations:b,frameProps:x={},selection:k,linkedHover:w,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:R,strokeWidth:B,opacity:N,categoryFormat:D}=o,E="vertical"===f,{width:I,height:H,enableHover:F,showLegend:$,title:W,description:z,summary:G,accessibleTable:Y}=i,q=E?{top:W?60:40,right:20,bottom:60,left:60}:{top:W?40:10,right:10,bottom:10,left:10},X=t.useMemo(()=>v(s),[s]),V=h||d,U=!V,K=Or({data:X,rawData:s,colorBy:V,colorScheme:g,legendInteraction:_,legendPosition:L,selection:k,linkedHover:w,fallbackFields:V?["string"==typeof V?V:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"FunnelChart",chartId:C,showLegend:$,userMargin:a,marginDefaults:q,loading:O,loadingContent:M,emptyContent:P,width:I,height:H});if(K.earlyReturn)return K.earlyReturn;vr("FunnelChart",X,"stepAccessor",c),vr("FunnelChart",X,"valueAccessor",u);const Q=Yi(),Z=t.useMemo(()=>new Map,[X]),J=t.useMemo(()=>{if(U)return T||((null==Q?void 0:Q[0])?Q[0]:Array.isArray(g)&&g[0]?g[0]:"#4e79a7")},[U,T,Q,g]),ee=ca({colorBy:J?void 0:V,colorScale:K.colorScale,color:null!=J?J:T,themeCategorical:Q,colorScheme:g,categoryIndexMap:Z,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:B,opacity:N,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection}),te=t.useMemo(()=>t=>{var o,n,i,r,s,a;const l=(null==t?void 0:t.data)||t,c=(null==l?void 0:l.__funnelStep)||(null==l?void 0:l.__barFunnelStep)||(null==l?void 0:l.step)||"",u=null!==(i=null!==(n=null!==(o=null==l?void 0:l.__funnelValue)&&void 0!==o?o:null==l?void 0:l.__barFunnelValue)&&void 0!==n?n:null==l?void 0:l.value)&&void 0!==i?i:"",d=null!==(r=null==l?void 0:l.__funnelPercent)&&void 0!==r?r:null==l?void 0:l.__barFunnelPercent,h=null!==(s=null==l?void 0:l.__funnelIsFirstStep)&&void 0!==s?s:null==l?void 0:l.__barFunnelIsFirstStep,g=null==l?void 0:l.__barFunnelIsDropoff,f=null!==(a=null==l?void 0:l.__barFunnelCategory)&&void 0!==a?a:null==l?void 0:l.category,p=null==d||h?"":` (${.05>Math.abs(d-Math.round(d))?Math.round(d)+"%":d.toFixed(1)+"%"})`;return e.jsxs("div",{className:"semiotic-tooltip",style:yn,children:[c&&e.jsx("div",{style:{fontWeight:"bold"},children:c+""}),f&&f!==c&&e.jsx("div",{style:{marginTop:2,opacity:.8},children:f+""}),g&&e.jsx("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),e.jsxs("div",{style:{marginTop:4},children:[u+"",p]})]})},[]),oe=Ar({componentName:"FunnelChart",data:s,accessors:{stepAccessor:c,valueAccessor:u}});if(oe)return e.jsx(cr,{componentName:"FunnelChart",message:oe,width:I,height:H});const 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(Object.assign({chartType:E?"bar-funnel":"funnel"},null!=s&&{data:X}),{oAccessor:c,rAccessor:u}),d&&{stackBy:d}),{projection:E?"vertical":"horizontal",barPadding:E?40:0,pieceStyle:ee,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:K.margin,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:E,showCategoryTicks:E}),D&&{oFormat:D}),{showGrid:E}),!E&&{connectorOpacity:p}),{showLabels:y}),K.legendBehaviorProps),W&&{title:W}),z&&{description:z}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),{tooltipContent:!1===m?()=>null:!0===m||null==m?te:kn(m)||te}),(w||A||j||S)&&{customHoverBehavior:K.customHoverBehavior}),(A||j||w)&&{customClickBehavior:K.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return e.jsx(gr,{componentName:"FunnelChart",width:I,height:H,children:e.jsx(aa,Object.assign({ref:r},ne))})});La.displayName="FunnelChart";const Ta={RdBu:ce,PiYG:ue,PRGn:de,BrBG:he,RdYlBu:ge,RdYlGn:fe,Spectral:pe},Ra="__likert_neutral_neg",Ba="__likert_neutral_pos";function Na(e,t){if("function"==typeof e)return e;const o=e||t;return e=>e[o]}function Da(e,t,o,n,i,r){const s=new Map,a=new Set(t);for(const l of e){const e=o(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(n){const e=n(l);if(null==e||!Number.isFinite(e))continue;if(!Number.isInteger(e)){"production"!==process.env.NODE_ENV&&console.warn("[LikertChart] Ignoring non-integer Likert score:",e);continue}const o=e-1;if(0>o||o>=t.length)continue;const i=t[o];c.set(i,(c.get(i)||0)+1)}else if(i&&r){const e=i(l),t=r(l);if(!a.has(e))continue;c.set(e,(c.get(e)||0)+(Number.isFinite(t)?t:0))}}const l=[];for(const[e,o]of s){let n=0;for(const e of t)n+=o.get(e)||0;if(0!==n)for(let i=0;t.length>i;i++){const r=t[i],s=o.get(r)||0;l.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/n*100,__likertLevelIndex:i})}}return l}function Ea(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(n&&e===i){const e=t.__likertPct/2;r.push(Object.assign(Object.assign({},t),{__likertLevel:Ra,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:Ba,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function Ia(e,t){const o=t.length,n=o%2!=0,i=Math.floor(o/2),r=new Map;for(const t of e){const e=r.get(t.__likertCategory)||[];e.push(t),r.set(t.__likertCategory,e)}const s=[];for(const[,e]of r){const t=new Map;let r,a;for(const o of e)o.__likertLevel===Ra?r=o:o.__likertLevel===Ba?a=o:t.set(o.__likertLevelIndex,o);n&&r&&s.push(r);for(let e=i-1;e>=0;e--){const o=t.get(e);o&&s.push(o)}n&&a&&s.push(a);for(let e=n?i+1:i;o>e;e++){const o=t.get(e);o&&s.push(o)}}return s}const Ha=["Very Low","Low","Neutral","High","Very High"],Fa=new Map,$a=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="question",valueAccessor:u,levelAccessor:d,countAccessor:h="count",levels:g=Ha,orientation:f="horizontal",colorScheme:y,barPadding:m=20,tooltip:v,annotations:b,valueExtent:x,frameProps:k={},selection:w,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:C,chartId:O,valueFormat:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:R,categoryFormat:B,stroke:N,strokeWidth:D,opacity:E}=o,{width:I,height:H,enableHover:F,showGrid:$,showLegend:W,title:z,description:G,summary:Y,accessibleTable:q,categoryLabel:X,valueLabel:V}=i,U="horizontal"===f,K=void 0===s,Q=!d,Z=function(){var e;const t=$i();return(null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.diverging)||void 0}(),J=t.useMemo(()=>y&&Array.isArray(y)&&y.length>=g.length?y:function(e,t){if(0>=e)return[];if(t){const o=Ta[t];if(o){if(1===e)return[o(.5)];const t=[];for(let n=0;e>n;n++)t.push(o(n/(e-1)));return t}}const o=["#da1e28","#ff8389","#ffb3b8"],n=["#a6c8ff","#4589ff","#0043ce"],i="#a8a8a8";if(1===e)return[i];const r=e%2!=0,s=Math.floor(e/2),a=[];for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);r&&a.push(i);for(let e=0;s>e;e++)a.push(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);return a}(g.length,Z),[y,g.length,Z]),ee=t.useMemo(()=>{const e=new Map;for(let t=0;g.length>t;t++)e.set(g[t],J[t]||"#888");return e},[g,J]),{processedData:te,reAggregate:oe,accumulatorRef:ne}=function({data:e,levels:o,categoryAccessor:n,valueAccessor:i,levelAccessor:r,countAccessor:s,isDiverging:a,frameRef:l}){const c=!r,u=t.useMemo(()=>Na(n,"question"),[n]),d=t.useMemo(()=>c?Na(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:Na(r,"level"),[c,r]),g=t.useMemo(()=>c?null:Na(s,"count"),[c,s]),f=e||[],p=t.useRef([]),y=t.useMemo(()=>{if(0===f.length)return[];let e=Da(f,o,u,d,h,g);return a&&(e=Ea(e,o),e=Ia(e,o)),e},[f,o,u,d,h,g,a]),m=t.useCallback(e=>{var t;let n=Da(e,o,u,d,h,g);a&&(n=Ea(n,o),n=Ia(n,o)),null===(t=l.current)||void 0===t||t.replace(n)},[o,u,d,h,g,a,l]);return{processedData:y,reAggregate:m,accumulatorRef:p}}({data:s,levels:g,categoryAccessor:c,valueAccessor:u,levelAccessor:d,countAccessor:h,isDiverging:U,frameRef:r}),ie="__likertLevelLabel",re=function({isPushMode:e,colorBy:o,colorScheme:n,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=ci(),d=Yi(),h=t.useCallback(e=>{const t=e[o];return null!=t?t+"":null},[o]),g=t.useCallback(t=>{if(!e||!o)return;let n=!1;for(const e of t){if(!e||"object"!=typeof e)continue;const t=h(e);null==t||s.current.has(t)||(s.current.add(t),a.current.push(t),n=!0)}n&&c(e=>e+1)},[e,o,h]),f=t.useCallback(t=>{if(!e||!o)return;const n=Array.from(new Set(t.map(String))),i=a.current;i.length===n.length&&i.every((e,t)=>e===n[t])||(s.current=new Set(n),a.current=n,c(e=>e+1))},[e,o]),p=t.useCallback(e=>t=>{g([t]),e(t)},[g]),y=t.useCallback(e=>t=>{g(t),e(t)},[g]),m=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]);Oi(e&&o?a.current:[]);const v=t.useMemo(()=>{if(!e||!o||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(n)&&n.length>0||"string"==typeof n&&n.length>0?n:d&&d.length>0?d:ve,s=o,l=t.map(e=>({[s]:e})),c=we(l,s,r);return Li({data:l,colorBy:s,colorScale:e=>(null==u?void 0:u[e])||c(e)||"#999",getColor:ke})},[e,o,i,n,u,d,l]),b=t.useMemo(()=>{if(v)return"right"===r?{right:110}:"left"===r?{left:110}:"top"===r?{top:50}:"bottom"===r?{bottom:80}:{right:110}},[v,r]);return{wrapPush:p,wrapPushMany:y,resetCategories:m,categories:a.current,categoryDomainProps:e&&o?{legendCategoryAccessor:o,onCategoriesChange:f}:{},streamingLegend:v,streamingMarginAdjust:b}}({isPushMode:K,colorBy:ie,colorScheme:J,showLegend:W,legendPosition:R}),se=t.useCallback(re.wrapPush(e=>{ne.current.push(e),oe(ne.current)}),[re.wrapPush,oe,ne]),ae=t.useCallback(re.wrapPushMany(e=>{ne.current.push(...e),oe(ne.current)}),[re.wrapPushMany,oe,ne]);t.useImperativeHandle(n,()=>({push:se,pushMany:ae,remove:e=>{var t,o;return null!==(o=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=r.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;ne.current=[],re.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}}),[se,ae,re.resetCategories,ne]);const le=Or({data:te,rawData:s,colorBy:ie,colorScheme:J,legendInteraction:T,legendPosition:R,selection:w,linkedHover:A,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:C,chartType:"LikertChart",chartId:O,showLegend:W,userMargin:a,marginDefaults:i.marginDefaults,loading:P,loadingContent:_,emptyContent:L,width:I,height:H});if(le.earlyReturn)return le.earlyReturn;const ce=t.useMemo(()=>{const e=g.length;return e%2!=0&&ee.get(g[Math.floor(e/2)])||"#888"},[g,ee]),ue=ca({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:Fa,userPieceStyle:null==k?void 0:k.pieceStyle,stroke:N,strokeWidth:D,opacity:E,effectiveSelectionHook:le.effectiveSelectionHook,resolvedSelection:le.resolvedSelection,baseStyleExtras:e=>{var t,o;const n=e.__likertLevelLabel||(null===(t=e.data)||void 0===t?void 0:t.__likertLevelLabel),i=e.__likertLevel||(null===(o=e.data)||void 0===o?void 0:o.__likertLevel);if(i===Ra||i===Ba)return{fill:ce};const r=n||i;return r&&ee.has(r)?{fill:ee.get(r)}:{fill:"#888"}}}),de=t.useMemo(()=>{const e=g.length;return e%2!=0?g[Math.floor(e/2)]:""},[g]),he=t.useMemo(()=>e=>{const t=e.data||e,o=t.__likertLevel||"Unknown",n=o===Ra||o===Ba?de:o,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=o===Ra||o===Ba?2*r:r,a=t.__likertCount||0;return p.createElement("div",{className:"semiotic-tooltip",style:yn},p.createElement("div",{style:{fontWeight:"bold"}},i),p.createElement("div",{style:{marginTop:4}},`${n}: ${s.toFixed(1)}% (n=${a})`))},[de]),ge=t.useMemo(()=>{if(!g||2>g.length)return"LikertChart requires `levels` with at least 2 entries.";if(u&&d)return"LikertChart: provide either `valueAccessor` (raw responses) or `levelAccessor` + `countAccessor` (pre-aggregated), not both.";if(d&&!h)return"LikertChart: pre-aggregated mode requires both `levelAccessor` and `countAccessor`.";if(void 0!==s&&0===s.length)return null;const e={categoryAccessor:c};return Q?u&&(e.valueAccessor=u):(d&&(e.levelAccessor=d),h&&(e.countAccessor=h)),Ar({componentName:"LikertChart",data:s,accessors:e,requiredProps:{levels:g}})},[s,c,u,d,h,g,Q]),fe=t.useMemo(()=>[{styleFn:e=>({fill:ee.get(e.label)||"#888"}),items:g.map(e=>({label:e})),label:""}],[g,ee]),pe=t.useMemo(()=>!1!==W?Object.assign(Object.assign({},le.legendBehaviorProps),{legend:{legendGroups:fe},legendPosition:R||le.legendPosition||"bottom"}):le.legendBehaviorProps,[le.legendBehaviorProps,le.legendPosition,R,W,fe]),ye=t.useMemo(()=>{const e=Object.assign({},le.margin);if(K&&!1!==W){const t=R||"bottom";"bottom"===t&&80>e.bottom?e.bottom=80:"top"===t&&50>e.top?e.top=50:"right"===t&&110>e.right?e.right=110:"left"===t&&110>e.left&&(e.left=110)}else if(re.streamingMarginAdjust)for(const[t,o]of Object.entries(re.streamingMarginAdjust))o>e[t]&&(e[t]=o);return U&&100>e.left&&(e.left=100),e},[le.margin,re.streamingMarginAdjust,U,K,W,R]),me=t.useMemo(()=>M||(U?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[U,M]),be=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:"bar"},null!=s&&{data:te}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:U?"horizontal":"vertical",pieceStyle:ue,size:[I,H],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:ye,barPadding:m,enableHover:F}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:X,rLabel:V||(U?void 0:"Percentage"),rFormat:me}),B&&{oFormat:B}),{showGrid:$}),pe),z&&{title:z}),G&&{description:G}),Y&&{summary:Y}),void 0!==q&&{accessibleTable:q}),l&&{className:l}),null!=o.animate&&{animate:o.animate}),void 0!==o.axisExtent&&{axisExtent:o.axisExtent}),{tooltipContent:!1===v?()=>null:!0===v?he:kn(v)||he}),(A||j||S||C)&&{customHoverBehavior:le.customHoverBehavior}),(j||S||A)&&{customClickBehavior:le.customClickBehavior}),b&&b.length>0&&{annotations:b}),x&&{rExtent:x}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return ge?e.jsx(cr,{componentName:"LikertChart",message:ge,width:I,height:H}):e.jsx(gr,{componentName:"LikertChart",width:I,height:H,children:e.jsx(aa,Object.assign({ref:r},be))})});$a.displayName="LikertChart";const Wa=t.forwardRef(function(o,n){const i=er(o.mode,{width:o.width,height:o.height,showGrid:o.showGrid,enableHover:o.enableHover,showLegend:o.showLegend,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,categoryLabel:o.categoryLabel,valueLabel:o.valueLabel,showCategoryTicks:o.showCategoryTicks,orientation:o.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",subcategoryAccessor:u,valueAccessor:d="value",orientation:h="horizontal",valueFormat:g,colorBy:f,colorScheme:p,barPadding:y,tooltip:m,annotations:b,brush:x,onBrush:k,linkedBrush:w,frameProps:A={},selection:j,linkedHover:S,onObservation:C,onClick:O,hoverHighlight:M,chartId:P,loading:_,loadingContent:L,emptyContent:T,legendInteraction:R,legendPosition:B,color:N,stroke:D,strokeWidth:E,opacity:I,categoryFormat:H,rTickValues:F,tickLabelEdgeAlign:$,showCategoryTicks:W,gradientFill:z,trackFill:G,roundedTop:Y,valueExtent:q}=o,{width:X,height:V,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,categoryLabel:oe,valueLabel:ne}=i,ie=t.useMemo(()=>v(s),[s]),re=f||u,se=t.useMemo(()=>{if(null!=y)return y;if("sparkline"!==o.mode)return 40;const e=new Set(ie.map(e=>"function"==typeof c?c(e):e[c])),t=Math.max(1,e.size);return t>1?Math.max(0,Math.min(1,(("horizontal"===h?V:X)-2*t)/(t-1))):1},[y,o.mode,ie,c,h,X,V]),ae=Or({data:ie,rawData:s,colorBy:re,colorScheme:p,legendInteraction:R,legendPosition:B,selection:j,linkedHover:S,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!0,onObservation:C,onClick:O,hoverHighlight:M,chartType:"SwimlaneChart",chartId:P,showLegend:Q,userMargin:a,marginDefaults:i.marginDefaults,loading:_,loadingContent:L,emptyContent:T,width:X,height:V}),le=ga({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:d});if(ae.earlyReturn)return ae.earlyReturn;const ce=Yi(),ue=t.useMemo(()=>new Map,[ie]),de=ca({colorBy:re,colorScale:ae.colorScale,color:N,themeCategorical:ce,colorScheme:p,categoryIndexMap:ue,userPieceStyle:null==A?void 0:A.pieceStyle,stroke:D,strokeWidth:E,opacity:I,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.resolvedSelection,cycleByCategory:!0}),he=t.useMemo(()=>lr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:g}),[u,c,d,g]),ge=Ar({componentName:"SwimlaneChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d,subcategoryAccessor:u},requiredProps:{subcategoryAccessor:u}}),{effectiveLegendProps:fe,effectiveMargin:pe}=la({ref:n,frameRef:r,setup:ae}),ye=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:"swimlane"},null!=s&&{data:ie}),{oAccessor:c,rAccessor:d,stackBy:u,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:de,size:[X,V],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:pe,barPadding:se,enableHover:U}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:!1===W?void 0:oe,rLabel:ne,rFormat:g}),F&&{rTickValues:F}),null!=$&&{tickLabelEdgeAlign:$}),H&&{oFormat:H}),void 0!==W&&{showCategoryTicks:W}),{showGrid:K}),fe),Fr({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:he})),$r({linkedHover:S,onObservation:C,onClick:O,hoverHighlight:M,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior})),b&&b.length>0&&{annotations:b}),z&&{gradientFill:!0===z?{topOpacity:.8,bottomOpacity:.05}:z}),null!=G&&{trackFill:G}),null!=Y&&{roundedTop:Y}),q&&{rExtent:q}),le.brushStreamProps),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return ge?e.jsx(cr,{componentName:"SwimlaneChart",message:ge,width:X,height:V}):e.jsx(gr,{componentName:"SwimlaneChart",width:X,height:V,children:e.jsx(aa,Object.assign({ref:r},ye))})});Wa.displayName="SwimlaneChart";const za={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Ga={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Ya{constructor(e){this.capacity=e,this.particles=Array(e),this._freeIndices=Array(e);for(let t=0;e>t;t++)this.particles[t]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices[t]=e-1-t}spawn(e){const t=this._freeIndices.pop();if(void 0===t)return null;const o=this.particles[t];return o.active=!0,o.t=0,o.offset=Math.random()-.5,o.edgeIndex=e,o.x=0,o.y=0,o}step(e,t,o,n){var i;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const a=o[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(r);continue}const l=n&&null!==(i=n[s.edgeIndex])&&void 0!==i?i:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?qa(a.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let o=0;this.capacity>o;o++)this.particles[o].active&&this.particles[o].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let o=0;e>o;o++)t.length>o?this.particles[o]=t[o]:(this.particles[o]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(o));this.capacity=e}}function qa(e,t,o,n){if(e.circular&&e.segments)return void function(e,t,o,n,i){const r=e.length,s=t*r,a=Math.min(Math.floor(s),r-1),l=s-a,[c,u,d,h]=e[a];Xa(c,u,d,h,l,i);const g=h.x-c.x,f=h.y-c.y,p=Math.sqrt(g*g+f*f);if(p>.001){const e=g/p;i.x+=-f/p*o*n*2,i.y+=e*o*n*2}}(e.segments,t,o,e.halfWidth,n);if(!e.points)return n.x=0,void(n.y=0);const[i,r,s,a]=e.points;Xa(i,r,s,a,t,n);const l=a.x-i.x,c=a.y-i.y,u=Math.sqrt(l*l+c*c);if(u>.001){const t=l/u;n.x+=-c/u*o*e.halfWidth*2,n.y+=t*o*e.halfWidth*2}}function Xa(e,t,o,n,i,r){const s=1-i,a=s*s,l=a*s,c=i*i,u=c*i;r.x=l*e.x+3*a*i*t.x+3*s*c*o.x+u*n.x,r.y=l*e.y+3*a*i*t.y+3*s*c*o.y+u*n.y}function Va(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function Ua(e,t){var o,n=[],i=[],r=[],s={},a=[];function l(e){r[e]=!1,s.hasOwnProperty(e)&&Object.keys(s[e]).forEach(function(t){delete s[e][t],r[t]&&l(t)})}function c(e){var t,n,d=!1;for(i.push(e),r[e]=!0,t=0;a[e].length>t;t++)(n=a[e][t])===o?(u(o,i),d=!0):r[n]||(d=c(n));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[n=a[e][t]];h||(s[n]=h={}),h[n]=!0}return i.pop(),d}function u(e,t){var o=[].concat(t).concat(e);n.push(o)}function d(t){!function(t){for(var o=0;e.length>o;o++)o>=t&&e[o]||(e[o]=[]),e[o]=e[o].filter(function(e){return e>=t})}(t);for(var o,n=function(e){for(var t=e.length,o=Array(t),n=Array(t),i=Array(t),r=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)o[l]=-1,n[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function g(t){var l=[t],c=[t];for(o[t]=n[t]=u,i[t]=!0,u+=1;c.length>0;){var g=e[t=c[c.length-1]];if(g.length>r[t]){for(var f=r[t];g.length>f;++f){var p=g[f];if(0>o[p]){o[p]=n[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(n[t]=0|Math.min(n[t],n[p])),0>s[p]||a[t].push(s[p])}r[t]=f}else{if(n[t]===o[t]){var y=[],m=[],v=0;for(f=l.length-1;f>=0;--f){var b=l[f];if(i[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===t){l.length=f;break}}d.push(y);var x=Array(v);for(f=0;m.length>f;f++)for(var k=0;m[f].length>k;k++)x[--v]=m[f][k];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>o[l]&&g(l);for(l=0;h.length>l;l++){var f=h[l];if(0!==f.length){f.sort(function(e,t){return e-t}),c=[f[0]];for(var p=1;f.length>p;p++)f[p]!==f[p-1]&&c.push(f[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),i=n.components.filter(function(e){return e.length>1}),r=1/0,s=0;i.length>s;s++)for(var a=0;i[s].length>a;a++)r>i[s][a]&&(r=i[s][a],o=s);var l=i[o];if(!l)return!1;var c=e.map(function(e,t){return-1===l.indexOf(t)?[]:e.filter(function(e){return-1!==l.indexOf(e)})});return{leastVertex:r,adjList:c}}o=0;for(var h=e.length;h>o;){var g=d(o);if(o=g.leastVertex,a=g.adjList){for(var f=0;a.length>f;f++)for(var p=0;a[f].length>p;p++){var y=a[f][p];r[+y]=!1,s[y]={}}c(o),o+=1}else o=h}return n}function Ka(e){return e.y0-e.y1>0?"up":"down"}function Qa(e,t){return t(e.source)==t(e.target)}function Za(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var o=0;return e.target.targetLinks.forEach(function(e){o=e.circular?o+1:o}),1>=t&&1>=o}function Ja(e){return e.target.x0-e.source.x1}function el(e,t){var o=ol(e),n=Ja(t)/Math.tan(o);return"up"==Ka(e)?e.y1-n:e.y1+n}function tl(e,t){var o=ol(e),n=Ja(t)/Math.tan(o);return"up"==Ka(e)?e.y1+n:e.y1-n}function ol(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function nl(e,t){return t(e)}function il(e){return sl(e.source)}function rl(e){return sl(e.target)}function sl(e){return(e.y0+e.y1)/2}function al(e){return e.virtual?0:e.value}function ll(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!Qa(e,t)?o+1:o});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!Qa(e,t)?n+1:n}),o+n}function cl(e){return e.target.depth}function ul(e,t){return e.sourceLinks.length?e.depth:t-1}function dl(e,t){return e.y0-t.y0}function hl(e,t){return t.y0-e.y0}function gl(e,t){return e.y1-t.y1}function fl(e,t){return t.y1-e.y1}function pl(e,t){return ml(e.source,t.source)||e.index-t.index}function yl(e,t){return ml(e.target,t.target)||e.index-t.index}function ml(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function vl(e,t){return bl(e)==bl(t)?"bottom"==e.circularLinkType?hl(e,t):dl(e,t):bl(t)-bl(e)}function bl(e){return e.target.column-e.source.column}function xl(e,t){return kl(e)==kl(t)}function kl(e){return e.y0-e.y1>0?"up":"down"}function wl(e,t,o,n,i){let r=e;var s=Math.max(8,.15*(r.y1-r.y0));r.links.forEach(function(e){e.circular&&(e._circularWidth=Math.min(e.width,s))});var l=a.min(r.links,function(e){return e.source.y0});r.links.forEach(function(e){e.circular&&(e.circularPathData={})});var c=r.links.filter(function(e){return e.circular});return c.sort(function(e,t){return t.value-e.value}),c.forEach(function(e,t){e._circularStub=t>=4}),Al(r.links.filter(function(e){return"top"==e.circularLinkType}),t,o),Al(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,o),r.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+n,e.circularPathData.rightNodeBuffer=5,e.circularPathData.leftNodeBuffer=5,e.circularPathData.sourceWidth=e.source.x1-e.source.x0,e.circularPathData.sourceX=e.source.x0+e.circularPathData.sourceWidth,e.circularPathData.targetX=e.target.x0,e.circularPathData.sourceY=e.y0,e.circularPathData.targetY=e.y1,Qa(e,t)&&Za(e))e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2,"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=e.source.y1+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=e.source.y0-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius);else{var s=e.source.column,a=e.circularLinkType,c=r.links.filter(function(e){return e.source.column==s&&e.circularLinkType==a});c.sort("bottom"==e.circularLinkType?hl:dl);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),s=e.target.column,(c=r.links.filter(function(e){return e.target.column==s&&e.circularLinkType==a})).sort("bottom"==e.circularLinkType?fl:gl),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=n+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=n+e._circularWidth/2+i*o+u),u+=t._circularWidth||t.width}),"bottom"==e.circularLinkType?(e.circularPathData.verticalFullExtent=Math.max(r.y1,e.source.y1,e.target.y1)+i+e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent-e.circularPathData.leftLargeArcRadius):(e.circularPathData.verticalFullExtent=l-i-e.circularPathData.verticalBuffer,e.circularPathData.verticalRightInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.rightLargeArcRadius,e.circularPathData.verticalLeftInnerExtent=e.circularPathData.verticalFullExtent+e.circularPathData.leftLargeArcRadius)}e.circularPathData.rightInnerExtent=e.circularPathData.sourceX+e.circularPathData.rightNodeBuffer,e.circularPathData.leftInnerExtent=e.circularPathData.targetX-e.circularPathData.leftNodeBuffer,e.circularPathData.rightFullExtent=e.circularPathData.sourceX+e.circularPathData.rightLargeArcRadius+e.circularPathData.rightNodeBuffer,e.circularPathData.leftFullExtent=e.circularPathData.targetX-e.circularPathData.leftLargeArcRadius-e.circularPathData.leftNodeBuffer}e.path=e.circular?function(e){return"top"==e.circularLinkType?"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 0 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY-e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 0 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 0 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY-e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 0 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY:"M"+e.circularPathData.sourceX+" "+e.circularPathData.sourceY+" L"+e.circularPathData.rightInnerExtent+" "+e.circularPathData.sourceY+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightSmallArcRadius+" 0 0 1 "+e.circularPathData.rightFullExtent+" "+(e.circularPathData.sourceY+e.circularPathData.rightSmallArcRadius)+" L"+e.circularPathData.rightFullExtent+" "+e.circularPathData.verticalRightInnerExtent+" A"+e.circularPathData.rightLargeArcRadius+" "+e.circularPathData.rightLargeArcRadius+" 0 0 1 "+e.circularPathData.rightInnerExtent+" "+e.circularPathData.verticalFullExtent+" L"+e.circularPathData.leftInnerExtent+" "+e.circularPathData.verticalFullExtent+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftLargeArcRadius+" 0 0 1 "+e.circularPathData.leftFullExtent+" "+e.circularPathData.verticalLeftInnerExtent+" L"+e.circularPathData.leftFullExtent+" "+(e.circularPathData.targetY+e.circularPathData.leftSmallArcRadius)+" A"+e.circularPathData.leftLargeArcRadius+" "+e.circularPathData.leftSmallArcRadius+" 0 0 1 "+e.circularPathData.leftInnerExtent+" "+e.circularPathData.targetY+" L"+e.circularPathData.targetX+" "+e.circularPathData.targetY}(e):function(e){var t=e.source.x1,o=e.y0,n=e.target.x0,i=e.y1,r=(t+n)/2;return"M"+t+","+o+"C"+r+","+o+" "+r+","+i+" "+n+","+i}(e)}),r}function Al(e,t,o){e.sort(vl);var n=e.filter(function(e){return!e._circularStub});return e.forEach(function(e,i){var r=0;if(e._circularStub)e.circularPathData.verticalBuffer=0;else if(Qa(e,t)&&Za(e))e.circularPathData.verticalBuffer=r+e._circularWidth/2;else{for(var s=0;n.length>s;s++){var a=n[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&jl(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+o;r=l>r?l:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function jl(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function Sl(e){return function(){return e}}function Cl(e){return e.index}function Ol(e){return e.nodes}function Ml(e){return e.links}function Pl(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});n.forEach(function(i,r){var s=i.length;if(t)i.sort(t);else if(r>0){var a=new Map;i.forEach(function(e,t){var o,n,i,r=(n=0,i=0,(o=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=sl(e.source)*t,n+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=sl(e.target)*t,n+=t}}),n>0?i/n:NaN);a.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var o=a.get(e),n=a.get(t),i=o.bc,r=n.bc;if(e.circularLinkType!==t.circularLinkType){if("top"==e.circularLinkType&&"bottom"==t.circularLinkType)return-1;if("bottom"==e.circularLinkType&&"top"==t.circularLinkType)return 1;if("top"==e.circularLinkType)return-1;if("top"==t.circularLinkType)return 1;if("bottom"==e.circularLinkType)return 1;if("bottom"==t.circularLinkType)return-1}return isNaN(i)||isNaN(r)?isNaN(i)?isNaN(r)?o.idx-n.idx:1:-1:i-r})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?ll(t,o)-ll(e,o):"top"==e.circularLinkType&&"bottom"==t.circularLinkType||"top"==e.circularLinkType&&0==t.partOfCycle||0==e.partOfCycle&&"bottom"==t.circularLinkType?-1:0});i.forEach(function(t,i){t.depth==n.length-1&&1==s||0==t.depth&&1==s?(t.y0=e.y1/2-t.value*e.ky,t.y1=t.y0+t.value*e.ky):t.partOfCycle?0==ll(t,o)?(t.y0=e.y1/2+i,t.y1=t.y0+t.value*e.ky):"top"==t.circularLinkType?(t.y0=e.y0+i,t.y1=t.y0+t.value*e.ky):(t.y0=e.y1-t.value*e.ky-i,t.y1=t.y0+t.value*e.ky):0==e.y0||0==e.y1?(t.y0=(e.y1-e.y0)/s*i,t.y1=t.y0+t.value*e.ky):(t.y0=(e.y1-e.y0)/2-s/2+i,t.y1=t.y0+t.value*e.ky)})})}function _l(e,t,o,n,i,r){var s=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});d();for(var l=1,c=r;c>0;--c)u(l*=.99,o),d();function u(t,o){var n=s.length;s.forEach(function(i){var r=i.length,s=i[0].depth;i.forEach(function(i){var l;if(i.sourceLinks.length||i.targetLinks.length)if(i.partOfCycle&&ll(i,o)>0){var c=a.mean(i.sourceLinks,rl),u=a.mean(i.targetLinks,il),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-sl(i))*t*.3;i.y0+=h,i.y1+=h}}else if(0==s&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(s==n-1&&1==r)i.y0=e.y1/2-(l=i.y1-i.y0)/2,i.y1=e.y1/2+l/2;else if(1==i.targetLinks.length&&1==i.targetLinks[0].source.sourceLinks.length)l=i.y1-i.y0,i.y0=i.targetLinks[0].source.y0,i.y1=i.y0+l;else{var g=a.mean(i.sourceLinks,rl),f=a.mean(i.targetLinks,il),p=((g&&f?(g+f)/2:g||f)-sl(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(o){var r,s,a,l=e.y0,c=o.length;for(o.sort(t||ml),a=0;c>a;++a)(s=l-(r=o[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+n;if((s=l-n-e.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=o[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function Ll(e){e.nodes.forEach(function(e){e.sourceLinks.sort(yl),e.targetLinks.sort(pl)}),e.nodes.forEach(function(e){var t=e.y0,o=t,n=e.y1,i=n;e.sourceLinks.forEach(function(e){e.circular?(e.y0=n-e.width/2,n-=e.width):(e.y0=t+e.width/2,t+=e.width)}),e.targetLinks.forEach(function(e){e.circular?(e.y1=i-e.width/2,i-=e.width):(e.y1=o+e.width/2,o+=e.width)})})}function Tl(){var e=0,t=0,o=1,n=1,i=24,r=8,s=null,l=Cl,c=ul,u=void 0,d=32,h=2,g=Ol,f=Ml;function p(){var p={nodes:g.apply(null,arguments),links:f.apply(null,arguments)};return function(g){g.x0=e,g.y0=t,g.x1=o,g.y1=n,g.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var o=function(e,t){var o=new Map;return a.group(e,t).forEach(function(e,t){o.set(t,e[0])}),o}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var n=e.source,i=e.target;"object"!=typeof n&&(n=e.source=Va(o,n)),"object"!=typeof i&&(i=e.target=Va(o,i)),n.sourceLinks.push(e),i.targetLinks.push(e)})}(g,l),function(e,t){var o=0;if(null==t){for(var n=[],i=0;e.links.length>i;i++){var r=e.links[i],s=r.source.index,a=r.target.index;n[s]||(n[s]=[]),n[a]||(n[a]=[]),-1===n[s].indexOf(a)&&n[s].push(a)}var l=Ua(n);l.sort(function(e,t){return e.length-t.length});var c={};for(i=0;l.length>i;i++){var u=l[i].slice(-2);c[u[0]]||(c[u[0]]={}),c[u[0]][u[1]]=!0}e.links.forEach(function(e){var t=e.target.index,n=e.source.index;t===n||c[n]&&c[n][t]?(e.circular=!0,e.circularLinkID=o++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=o++)})}(g,u),function(e,t){var o=0,n=0;e.links.forEach(function(i){i.circular&&(i.circularLinkType=i.source.circularLinkType||i.target.circularLinkType?i.source.circularLinkType?i.source.circularLinkType:i.target.circularLinkType:n>o?"top":"bottom","top"==i.circularLinkType?o++:n++,e.nodes.forEach(function(e){nl(e,t)!=nl(i.source,t)&&nl(e,t)!=nl(i.target,t)||(e.circularLinkType=i.circularLinkType)}))}),e.links.forEach(function(e){e.circular&&(e.source.circularLinkType==e.target.circularLinkType&&(e.circularLinkType=e.source.circularLinkType),Qa(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(g,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,al),a.sum(e.targetLinks,al)),e.sourceLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)}),e.targetLinks.forEach(function(t){t.circular&&(e.partOfCycle=!0,e.circularLinkType=t.circularLinkType)})})}(g),function(e,t,o){var n,i,r;if(null!=t){e.nodes.sort(function(e,o){return t(e)<t(o)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(n=e.nodes,i=[],r=0;n.length;++r,n=i,i=[])n.forEach(function(e){e.height=r,e.targetLinks.forEach(function(e){0>i.indexOf(e.source)&&!e.circular&&i.push(e.source)})});e.nodes.forEach(function(e){e.column=null==t?o(e,r):e.column})}(g,u,c);var f=r;if(null!==s){var p=a.groups(g.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]}),y=a.max(p,function(e){return e.length});y>1&&(f=Math.max(1,(n-t)*s/(y-1)))}(function(e,t,o){var n=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});e.py=t;var i=a.min(n,function(t){return(e.y1-e.y0-(t.length-1)*e.py)/a.sum(t,function(e){return e.value})});e.ky=i,e.links.forEach(function(t){t.width=t.value*e.ky});var r=a.max(e.nodes,function(e){return e.column});e.nodes.forEach(r>0?function(t){t.x0=e.x0+t.column*((e.x1-e.x0-o)/r),t.x1=t.x0+o}:function(t){t.x0=e.x0,t.x1=t.x0+o})})(g,f,i),Pl(g,u,l),_l(g,u,l,f,f,d),Ll(g),wl(g,l,h,10,8),Pl(g,u,l),_l(g,u,l,f,f,d),Ll(g),wl(g,l,h,10,8),function(e,t){let o=e;o.nodes.forEach(function(e){e.y+(e.y1-e.y0)>o.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-o.y1));var n=o.links.filter(function(o){return nl(o.source,t)==nl(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!xl(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=el(t,e);return e.y1-o}if(t.target.column>e.target.column)return el(e,t)-t.y1}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.target.column===t.target.column?e.target.y1-t.target.y1:t.target.column-e.target.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.target.column===t.target.column?t.target.y1-e.target.y1:e.target.column-t.target.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y0=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y0=e.y1-s-t.width/2}})})}(g,l),function(e,t){let o=e;o.nodes.forEach(function(e){var n=o.links.filter(function(o){return nl(o.target,t)==nl(e,t)}),i=n.length;i>1&&n.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!xl(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=tl(t,e);return e.y0-o}if(t.source.column>e.source.column)return tl(e,t)-t.y0}return e.circular&&!t.circular?"top"==e.circularLinkType?-1:1:t.circular&&!e.circular?"top"==t.circularLinkType?1:-1:e.circular&&t.circular?e.circularLinkType===t.circularLinkType&&"top"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:e.source.column-t.source.column:e.circularLinkType===t.circularLinkType&&"bottom"==e.circularLinkType?e.source.column===t.source.column?e.source.y1-t.source.y1:t.source.column-e.source.column:"top"==e.circularLinkType?-1:1:void 0});var r=e.y0;n.forEach(function(e){e.y1=r+e.width/2,r+=e.width}),n.forEach(function(t,o){if("bottom"==t.circularLinkType){for(var r=o+1,s=0;i>r;r++)s+=n[r].width;t.y1=e.y1-s-t.width/2}})})}(g,l),function(e){var t=e.nodes,o=e.links,n=!1,i=!1;if(o.forEach(function(e){"top"==e.circularLinkType?n=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==n||0==i){var r=a.min(t,function(e){return e.y0}),s=a.max(t,function(e){return e.y1}),l=(e.y1-e.y0)/(s-r);function c(t){return(t-r)/(s-r)*(e.y1-e.y0)+e.y0}1>l?(t.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1)}),o.forEach(function(e){e.y0=c(e.y0),e.y1=c(e.y1),e.width=e.width*l})):t.forEach(function(e){var t=e.y1-e.y0,o=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+o}),e.targetLinks.forEach(function(e){e.y1=e.y1+o})})}}(g),wl(g,l,h,10,8)}(p),p}return p.update=function(e){return Ll(e),wl(e,l,h,10,8),e},p.nodeWidth=function(e){return arguments.length?(i=+e,p):i},p.nodePadding=function(e){return arguments.length?(r=+e,p):r},p.nodePaddingRatio=function(e){return arguments.length?(s=+e,p):s},p.nodes=function(e){return arguments.length?(g="function"==typeof e?e:Sl(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:Sl(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:Sl(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:Sl(e),p):c},p.nodeSort=function(e){return arguments.length?(u=e,p):u},p.iterations=function(e){return arguments.length?(d=+e,p):d},p.circularLinkGap=function(e){return arguments.length?(h=+e,p):h},p.extent=function(i){return arguments.length?(e=+i[0][0],t=+i[0][1],o=+i[1][0],n=+i[1][1],p):[[e,t],[o,n]]},p.size=function(i){return arguments.length?(e=t=0,o=+i[0],n=+i[1],p):[o-e,n-t]},p}function Rl(e){const{sx:t,sTop:o,sBot:n,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=e,c=(o+n)/2,u=(r+s)/2;return{pathD:[`M${t},${o}`,`C${a},${o} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${n} ${t},${n}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(n-o)/2}}}const Bl=e=>{let t,o,n,i,r,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,o=e.y1-e.sankeyWidth/2,n=e.y1+e.sankeyWidth/2,i=e.y0+e.sankeyWidth/2,r=e.source.x1,s=e.target.x0,a=u.interpolateNumber(r,s),l=a(.5),c=a(.5),`M${t},${r}C${t},${l} ${o},${c} ${o},${s}L${n},${s}C${n},${c} ${i},${l} ${i},${r}Z`;const d=e.sankeyWidth/2,h=u.interpolateNumber(e.source.x1,e.target.x0),{pathD:g}=Rl({sx:e.source.x1,sTop:e.y0-d,sBot:e.y0+d,tx:e.target.x0,tTop:e.y1-d,tBot:e.y1+d,cp1X:h(.5),cp2X:h(.5)});return g};function Nl(e){var t;const o=e.sankeyWidth/2,n=(null!==(t=e._circularWidth)&&void 0!==t?t:e.sankeyWidth)/2,i=e.circularPathData;if(!i)return null;if("down"===e.direction)return null;if(e._circularStub){const t=i.sourceX,n=i.sourceY,r=i.targetX,s=i.targetY;if("object"!=typeof e.source||!e.source||"object"!=typeof e.target||!e.target)return null;const a=Math.max(15,Math.min(40,.33*(i.rightFullExtent-t))),l=Math.max(15,Math.min(40,.33*(r-i.leftFullExtent)));return`M${t},${n-o}L${t+a},${n-o}L${t+a},${n+o}L${t},${n+o}ZM${r},${s-o}L${r-l},${s-o}L${r-l},${s+o}L${r},${s+o}Z`}const r=i.sourceX,s=i.sourceY,a=i.targetX,l=i.targetY,c=i.rightFullExtent,u=i.leftFullExtent,d=i.verticalFullExtent,h="bottom"===e.circularLinkType?1:-1,g=Math.max(4,Math.min(n,15));return`M${r},${s-h*o}L${c},${s-h*o}L${c+n},${s-h*o+h*g}L${c+n},${d+h*n-h*g}L${c+n-g},${d+h*n}L${u-n+g},${d+h*n}L${u-n},${d+h*n-h*g}L${u-n},${l-h*o+h*g}L${u-n+g},${l-h*o}L${a},${l-h*o}L${a},${l+h*o}L${u+n},${l+h*o}L${u+n},${d-h*n}L${c-n},${d-h*n}L${c-n},${s+h*o}L${r},${s+h*o}Z`}const Dl=new Set,El=new WeakMap;function Il(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let o=El.get(e);if(o){const e=o.get(t);if(e)return e}else o=new Map,El.set(e,o);const n=new Proxy(e,{get(e,o,n){if("string"==typeof o&&!(o in e)&&e.data&&o in e.data){const e=`${t}:${o}`;Dl.has(e)||(Dl.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${o}" on the wrapper object, but it only exists on ".data". Use d.data.${o} (or d.data?.${o}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,o,n)}});return o.set(t,n),n}const Hl={left:function(e){return e.depth},right:function(e,t){return t-1-e.height},center:function(e){return e.targetLinks.length?e.depth:e.sourceLinks.length?Math.min.apply(Math,e.sourceLinks.map(cl))-1:0},justify:ul};function Fl(e){return"string"==typeof e?e:e.id}const $l={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r,s,a,l,c,u;if(0===e.length)return;const d="vertical"===o.orientation?"down":"right",h=o.nodeAlign||"justify",g=null!==(i=o.nodeWidth)&&void 0!==i?i:15,f=null!==(r=o.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=o.iterations)&&void 0!==s?s:100,y=e.map(e=>Object.assign({},e)),m=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id,value:Math.sqrt(Math.max(1,e.value||1))}));let v;v="down"===d?[[0,0],[n[1],n[0]]]:[[0,0],[n[0],n[1]]];const b=Tl().extent(v).links(m).nodes(y).nodeAlign(Hl[h]||ul).nodeId(e=>e.id).nodeWidth(g).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(f),b();{let e=1/0,t=-1/0,o=1/0,i=-1/0;for(const n of y)e>n.x0&&(e=n.x0),n.x1>t&&(t=n.x1),o>n.y0&&(o=n.y0),n.y1>i&&(i=n.y1);for(const n of m){if(!n.circular||!n.circularPathData)continue;const r=n.circularPathData,s=(null!==(l=null!==(a=n._circularWidth)&&void 0!==a?a:n.width)&&void 0!==l?l:0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),o>r.verticalFullExtent-s&&(o=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=t-e,s=i-o,u=n[0],d=n[1];if(r>0&&s>0&&(0>e||0>o||t>u||i>d)){const t=Math.min(u/r,d/s),n=-e*t+(u-r*t)/2,i=-o*t+(d-s*t)/2;for(const e of y)e.x0=e.x0*t+n,e.x1=e.x1*t+n,e.y0=e.y0*t+i,e.y1=e.y1*t+i;for(const e of m)if(e.y0=e.y0*t+i,e.y1=e.y1*t+i,e.width=(null!==(c=e.width)&&void 0!==c?c:0)*t,e._circularWidth&&(e._circularWidth*=t),e.circular&&e.circularPathData){const o=e.circularPathData;o.sourceX=o.sourceX*t+n,o.targetX=o.targetX*t+n,o.sourceY=o.sourceY*t+i,o.targetY=o.targetY*t+i,o.rightFullExtent=o.rightFullExtent*t+n,o.leftFullExtent=o.leftFullExtent*t+n,o.verticalFullExtent=o.verticalFullExtent*t+i,o.rightInnerExtent=o.rightInnerExtent*t+n,o.leftInnerExtent=o.leftInnerExtent*t+n,o.verticalRightInnerExtent=o.verticalRightInnerExtent*t+i,o.verticalLeftInnerExtent=o.verticalLeftInnerExtent*t+i,o.rightSmallArcRadius*=t,o.rightLargeArcRadius*=t,o.leftSmallArcRadius*=t,o.leftLargeArcRadius*=t,o.sourceWidth*=t,o.rightNodeBuffer*=t,o.leftNodeBuffer*=t,o.arcRadius*=t}}}const x=new Map;for(const t of e)x.set(t.id,t);for(const e of y){const t=x.get(e.id);t&&(t.x0=e.x0,t.x1=e.x1,t.y0=e.y0,t.y1=e.y1,t.value=e.value,t.depth=e.depth,t.sourceLinks=e.sourceLinks,t.targetLinks=e.targetLinks,t.width=e.x1-e.x0,t.height=e.y1-e.y0,t.x=e.x0+(e.x1-e.x0)/2,t.y=e.y0+(e.y1-e.y0)/2)}const k=new Map;for(const e of t)k.set(e._edgeKey?e._edgeKey:`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const e of m){const t=Fl(e.source),o=Fl(e.target),n=k.get(e._edgeKey?e._edgeKey:`${t}\0${o}`);if(n){n.y0=e.y0,n.y1=e.y1,n.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,n.circular=!!e.circular,n.circularPathData=e.circularPathData,n._circularWidth=e._circularWidth,n._circularStub=e._circularStub,n.path=e.path,n.circularLinkType=e.circularLinkType,n.direction=d;const i=x.get(t),r=x.get(o);i&&(n.source=i),r&&(n.target=r)}}},buildScene(e,t,o,n){var i,r,s,a,l,c;const u="vertical"===o.orientation?"down":"right",d=o.nodeStyle,h=o.edgeStyle,g=null!==(i=o.edgeOpacity)&&void 0!==i?i:.5,f=o.edgeColorBy||"source",p=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:K,y=new Map;e.forEach((e,t)=>{y.set(e.id,p[t%p.length])});const m=[],v=[],b=[],x=new Map;for(const t of e){const e=t.x1-t.x0,o=t.y1-t.y0;if(0>=e||0>=o)continue;const n=d?d(Il(t,"nodeStyle")):{},i={fill:n.fill||y.get(t.id)||"#4d430c",stroke:n.stroke,strokeWidth:n.strokeWidth,opacity:n.opacity};x.set(t.id,("string"==typeof i.fill?i.fill:null)||y.get(t.id)||"#4d430c"),m.push("down"===u?{type:"rect",x:t.y0,y:t.x0,w:o,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:o,style:i,datum:t,id:t.id,label:t.id})}const k=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of k){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof f?f(e)||i:"target"===f?x.get(n.id)||y.get(n.id)||i:x.get(t.id)||y.get(t.id)||i;const u=h?h(Il(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,o=e.sankeyWidth/2,n=Math.max(15,Math.min(40,.33*(t.rightFullExtent-t.sourceX))),r=Math.max(15,Math.min(40,.33*(t.targetX-t.leftFullExtent))),s=u.fill||i;v.push({type:"bezier",pathD:`M${t.sourceX},${t.sourceY-o}L${t.sourceX+n},${t.sourceY-o}L${t.sourceX+n},${t.sourceY+o}L${t.sourceX},${t.sourceY+o}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:g,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+n}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-o}L${t.targetX-r},${t.targetY-o}L${t.targetX-r},${t.targetY+o}L${t.targetX},${t.targetY+o}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:g,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"left",from:0,to:1,x0:t.targetX-r,x1:t.targetX}});continue}let d;if(d=e.circular&&e.circularPathData?Nl(e):Bl(e),!d)continue;const p={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:g,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};v.push({type:"bezier",pathD:d,bezierCache:e.bezier,style:p,datum:e})}if(!1!==o.showLabels){const t=(w=o.nodeLabel)?"function"==typeof w?w:e=>e[w]||e.id:null;for(const o of e){const e=o.x1-o.x0,i=o.y1-o.y0;if(0>=e||0>=i)continue;const r=t?t(o):o.id;if(!r)continue;let s,a,l;"down"===u?(s=o.y0+(o.y1-o.y0)/2,a=o.x1+14,l="start"):(n[0]/2>o.x0+e/2?(s=o.x0-6,l="end"):(s=o.x1+6,l="start"),a=o.y0+i/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var w;return{sceneNodes:m,sceneEdges:v,labels:b}}},Wl={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,o,n){var i,r;if(0===e.length)return;const s=null!==(i=o.forceStrength)&&void 0!==i?i:.1,a=n[0]/2,l=n[1]/2,c=o.__previousPositions;let u=0;const h=[];for(const t of e){const e=null!=t.x&&null!=t.y&&(0!==t.x||0!==t.y),o=null==c?void 0:c.get(t.id);e?u++:o?(t.x=o.x,t.y=o.y,u++):h.push(t)}const g=u>0&&.3>=(e.length>0?h.length/e.length:1);if(g){const o=new Map;for(const t of e)o.set(t.id,t);for(const e of h){const n=zl(e.id,t,o);if(n.length>0){let t=0,o=0;for(const e of n)t+=e.x,o+=e.y;const i=Gl(e.id),r=i%360*(Math.PI/180),s=10+i%20;e.x=t/n.length+s*Math.cos(r),e.y=o/n.length+s*Math.sin(r)}else{const t=Gl(e.id),o=t%360*(Math.PI/180),n=15+t%30;e.x=a+n*Math.cos(o),e.y=l+n*Math.sin(o)}}}else{const t=2.399963229728653;for(let o=0;e.length>o;o++){const n=e[o];if(null==n.x||null==n.y||0===n.x&&0===n.y){const e=10*Math.sqrt(o+.5),i=o*t;n.x=a+e*Math.cos(i),n.y=l+e*Math.sin(i)}}}const f=null!==(r=o.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===o.iterations?0:g?40:f,y=Yl(o.nodeSize,o.nodeSizeRange,e),m=e=>y(e);if(p>0){const o=d.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),n=d.forceSimulation().force("charge",d.forceManyBody().strength(e=>-25*m(e))).force("center",d.forceCenter(a,l).strength(.8)).force("x",d.forceX(a).strength(.15)).force("y",d.forceY(l).strength(.15));if(n.nodes(e),t.length>0){const e=t.map(e=>Object.assign(Object.assign({},e),{source:"string"==typeof e.source?e.source:e.source.id,target:"string"==typeof e.target?e.target:e.target.id}));o.links(e),n.force("link",o)}g?n.alpha(.3):.1>n.alpha()&&n.alpha(1),n.stop();for(let e=0;p>e;++e)n.tick()}for(const t of e){if(null==t.x||null==t.y)continue;const e=m(t);t.x=Math.max(e,Math.min(n[0]-e,t.x)),t.y=Math.max(e,Math.min(n[1]-e,t.y)),t.x0=0,t.x1=0,t.y0=0,t.y1=0}const v=new Map;for(const t of e)v.set(t.id,t);for(const e of t){if("string"==typeof e.source){const t=v.get(e.source);t&&(e.source=t)}if("string"==typeof e.target){const t=v.get(e.target);t&&(e.target=t)}}},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.edgeStyle,g=Yl(o.nodeSize,o.nodeSizeRange,e),f=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:K,p=new Map;e.forEach((e,t)=>{p.set(e.id,f[t%f.length])});const y=[],m=[],v=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=g(Il(t,"nodeSize")),n=d?d(Il(t,"nodeStyle")):{},a={fill:n.fill||p.get(t.id)||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:2,opacity:n.opacity};y.push({type:"circle",cx:t.x,cy:t.y,r:e,style:a,datum:t,id:t.id,label:t.id})}const b=new Map;for(const t of e)b.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:b.get(e.source),n="object"==typeof e.target?e.target:b.get(e.target);if(!t||!n)continue;if(null==t.x||null==t.y)continue;if(null==n.x||null==n.y)continue;const i=h?h(Il(e,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=o.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=o.themeSemantic)||void 0===l?void 0:l.secondary)||"#999",strokeWidth:null!==(c=i.strokeWidth)&&void 0!==c?c:1,opacity:null!==(u=i.opacity)&&void 0!==u?u:.6};m.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:r,datum:e})}if(!1!==o.showLabels){const t=(x=o.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const o of e){if(null==o.x||null==o.y)continue;const e=t?t(o):o.id;if(!e)continue;const n=g(Il(o,"nodeSize"));v.push({x:o.x,y:o.y-n-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function zl(e,t,o){const n=[];for(const i of t){const t="string"==typeof i.source?i.source:i.source.id,r="string"==typeof i.target?i.target:i.target.id;let s=null;if(t===e?s=r:r===e&&(s=t),s){const e=o.get(s);!e||0===e.x&&0===e.y||n.push({x:e.x,y:e.y})}}return n}function Gl(e){let t=0;for(let o=0;e.length>o;o++)t=(t<<5)-t+e.charCodeAt(o)|0;return Math.abs(t)}function Yl(e,t,o){var n,r;if(null==e)return()=>8;if("number"==typeof e)return()=>e;if("function"==typeof e)return t=>e(t)||8;const s=t||[5,20],l=o.map(t=>{var o;return null===(o=t.data)||void 0===o?void 0:o[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(n=a.min(l))&&void 0!==n?n:0,u=null!==(r=a.max(l))&&void 0!==r?r:1;if(c===u)return()=>(s[0]+s[1])/2;const d=i.scaleLinear().domain([c,u]).range(s).clamp(!0);return t=>{var o;const n=null===(o=t.data)||void 0===o?void 0:o[e];return null==n||"number"!=typeof n?s[0]:d(n)}}const ql=K,Xl={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,o,n){if(0===e.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:a}=o,l=Math.min(n[0],n[1])/2,c=l-r,u=n[0]/2,d=n[1]/2,g=(f=o.valueAccessor)?"function"==typeof f?f:e=>{var t;return null!==(t=e[f])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var f;const p=new Map;for(let t=0;e.length>t;t++)p.set(e[t].id,t);const y=e.length,m=Array.from({length:y},()=>Array.from({length:y},()=>0));for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=p.get("string"==typeof e.source?e.source:e.source.id),n=p.get(t);if(void 0===o||void 0===n)continue;const i=g(e);m[o][n]=i}const v=h.chord().padAngle(i);a&&v.sortGroups(a);const b=v(m),x=b.groups,k=s.arc().innerRadius(c).outerRadius(l);for(const t of x){const o=e[t.index],n=k.centroid({innerRadius:c,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});o.x=n[0]+u,o.y=n[1]+d,o.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const w=new Map;for(const t of e)w.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,o=w.get("string"==typeof e.source?e.source:e.source.id),n=w.get(t);o&&(e.source=o),n&&(e.target=n)}const A=new Map;for(const e of t)A.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,e);for(const t of b){const o=e[t.source.index].id,n=e[t.target.index].id,i=A.get(`${o}\0${n}`)||A.get(`${n}\0${o}`);i&&(i.__chordData=t)}},buildScene(e,t,o,n){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=o,u=Math.min(n[0],n[1])/2,d=u-l,g=n[0]/2,f=n[1]/2,p=o.nodeStyle,y=o.edgeStyle,m=o.edgeColorBy||"source",v=Array.isArray(o.colorScheme)?o.colorScheme:o.themeCategorical&&o.themeCategorical.length>0?o.themeCategorical:ql,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=h.ribbon().radius(d),k=[],w=[],A=[];for(let t=0;e.length>t;t++){const o=e[t],n=o.__arcData;if(!n)continue;let r;r=p?p(Il(o,"nodeStyle")).fill||b.get(o.id)||v[t%v.length]:b.get(o.id)||v[t%v.length];const s=p?p(Il(o,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};k.push({type:"arc",cx:g,cy:f,innerR:d,outerR:u,startAngle:n.startAngle-Math.PI/2,endAngle:n.endAngle-Math.PI/2,style:a,datum:o,id:o.id,label:o.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const n=x(t);if(!n)continue;const i=Vl(n,g,f);let l=(null===(r=o.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=o.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(Il(e,"edgeStyle")).fill||l;else{const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;"target"===m&&o?l=b.get(o.id)||l:t&&(l=b.get(t.id)||l)}const u=y?y(Il(e,"edgeStyle")):{},d={fill:l,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:c,stroke:u.stroke||"none",strokeWidth:u.strokeWidth,opacity:u.opacity};w.push({type:"ribbon",pathD:i,style:d,datum:e})}if(!1!==o.showLabels){const t=(j=o.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null,n=u+12;for(const o of e){const e=o.__arcData;if(!e)continue;const i=t?t(o):o.id;if(!i)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;A.push({x:g+Math.cos(s)*n,y:f+Math.sin(s)*n,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var j;return{sceneNodes:k,sceneEdges:w,labels:A}}};function Vl(e,t,o){const n=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!n)return e;const i=[];let r=0;for(;n.length>r;){const e=n[r];if("M"===e||"L"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("C"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;3>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("Q"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)for(let e=0;2>e&&n.length>r&&!isNaN(Number(n[r]));e++)i.push(Number(n[r])+t+""),r++,n.length>r&&!isNaN(Number(n[r]))&&(i.push(Number(n[r])+o+""),r++);else if("A"===e)for(i.push(e),r++;n.length>r&&!isNaN(Number(n[r]));)i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&i.push(n[r++]),n.length>r&&(i.push(Number(n[r])+t+""),r++),n.length>r&&(i.push(Number(n[r])+o+""),r++);else"Z"===e||"z"===e?(i.push(e),r++):(i.push(n[r]),r++)}return i.join(" ")}const Ul=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function Kl(e){const[t,o,n]=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*o+.114*n>150?"#222":"#fff"}function Ql(e,t,o){const n=t.nodeIDAccessor;return"function"==typeof n?n(e.data)+"":"string"==typeof n&&void 0!==e.data[n]?e.data[n]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+o}function Zl(e){return e?"function"==typeof e?e:t=>{var o;return(null===(o=t.data)||void 0===o?void 0:o[e])||t[e]||t.id}:null}function Jl(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Ul}function ec(e){var t;return Array.isArray(e.colorScheme)&&e.colorScheme.length>0?e.colorScheme[0]:(null===(t=e.themeSemantic)||void 0===t?void 0:t.primary)?e.themeSemantic.primary:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical[0]:"#4d430c"}function tc(e,t,o,n,i){if("horizontal"===i){const i=(e+o)/2;return`M ${e},${t} C ${i},${t} ${i},${n} ${o},${n}`}if("radial"===i){const i=(e+o)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+n)/2} T ${o},${n}`}{const i=(t+n)/2;return`M ${e},${t} C ${e},${i} ${o},${i} ${o},${n}`}}const oc={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,o,n){var i;const r=o.__hierarchyRoot;if(!r)return;const s=o.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(o.childrenAccessor),c=o.hierarchySum,u="function"==typeof c?c:"string"==typeof c?e=>Number(e[c])||0:e=>Number(e.value)||0,d=l.hierarchy(r,a);d.sum(u),d.sort((e,t)=>{var o,n;return(null!==(o=t.value)&&void 0!==o?o:0)-(null!==(n=e.value)&&void 0!==n?n:0)});const[h,g]=n;switch(s){case"tree":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.tree();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"cluster":!function(e,t,o,n){const i=t.treeOrientation||"vertical",r=l.cluster();r.size("horizontal"===i?[n,o]:"radial"===i?[2*Math.PI,Math.min(o,n)/2*.8]:[o,n]),r(e)}(d,o,h,g);break;case"treemap":!function(e,t,o,n){var i,r;const s=null!==(i=t.padding)&&void 0!==i?i:4,a=null!==(r=t.paddingTop)&&void 0!==r?r:0,c=l.treemap().size([o,n]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,o,h,g);break;case"circlepack":!function(e,t,o,n){var i;const r=null!==(i=t.padding)&&void 0!==i?i:4;l.pack().size([o,n]).padding(r)(e)}(d,o,h,g);break;case"partition":!function(e,t,o,n){var i;l.partition().size([o,n]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,o,h,g)}const f=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;f.length>t;t++){const n=f[t],r={id:Ql(n,o,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=n.value)&&void 0!==i?i:0,depth:n.depth,data:n.data,createdByFrame:!0};"tree"===s||"cluster"===s?nc(r,n,o):"treemap"===s||"partition"===s?ic(r,n):"circlepack"===s&&rc(r,n),r.__hierarchyNode=n,e.push(r),p.set(n,r)}if("tree"===s||"cluster"===s)for(const e of f)if(e.parent){const o=p.get(e.parent),n=p.get(e);o&&n&&t.push({source:o,target:n,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,o,n){const i=o.nodeStyle||(()=>({})),r=o.edgeStyle||(()=>({}));switch(o.chartType){case"tree":case"cluster":return function(e,t,o,n,i,r){var s,a,l,c,u,d,h,g;const f=[],p=[],y=[],m=o.treeOrientation||"vertical",v="radial"===m,b=n[0]/2,x=n[1]/2,k="number"==typeof(w=o.nodeSize)?w:5;var w;for(const t of e){let e=t.x,n=t.y;v&&(e+=b,n+=x);const r=i(Il(t,"nodeStyle"));let l=r.fill||ec(o);if(o.colorByDepth&&void 0!==t.depth){const e=Jl(o);l=e[t.depth%e.length]}const c={fill:l,stroke:r.stroke||(null===(s=o.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};f.push({type:"circle",cx:e,cy:n,r:k,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const A=null!==(l=o.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;if(!t||!n)continue;let i=t.x,s=t.y,a=n.x,l=n.y;v&&(i+=b,s+=x,a+=b,l+=x);const g=tc(i,s,a,l,m),f=r(Il(e,"edgeStyle")),y={fill:"none",stroke:f.stroke||(null===(c=o.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=o.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=f.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=f.opacity)&&void 0!==h?h:A};p.push({type:"curved",pathD:g,style:y,datum:e})}if(!1!==o.showLabels){const t=Zl(o.nodeLabel);for(const o of e){const e=t?t(o):o.id;if(!e)continue;let n,i,r,s=o.x,a=o.y;if(v&&(s+=b,a+=x),v){const e=s-b,t=a-x,o=Math.sqrt(e*e+t*t);o>0?(n=s+e/o*10,i=a+t/o*10,r=0>e?"end":"start"):(n=s,i=a-12,r="middle")}else"horizontal"===m?((null===(g=o.data)||void 0===g?void 0:g.children)&&0!==o.data.children.length?(n=s-k-6,r="end"):(n=s+k+6,r="start"),i=a):(n=s,i=a+k+14,r="middle");y.push({x:n,y:i,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:f,sceneEdges:p,labels:y}}(e,t,o,n,i,r);case"treemap":case"partition":return function(e,t,o,n){var i,r,s,a,l;const c=[],u=[];for(const o of e){const e=o.x1-o.x0,s=o.y1-o.y0;if(0>=e||0>=s)continue;const a=n(Il(o,"nodeStyle"));let l=a.fill||ec(t);if(t.colorByDepth&&void 0!==o.depth){const e=Jl(t);l=e[o.depth%e.length]}const u={fill:l,stroke:a.stroke||(null===(i=t.themeSemantic)||void 0===i?void 0:i.surface)||"#fff",strokeWidth:null!==(r=a.strokeWidth)&&void 0!==r?r:1,opacity:a.opacity};c.push({type:"rect",x:o.x0,y:o.y0,w:e,h:s,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=Zl(t.nodeLabel),i=t.labelMode||"leaf",r="partition"===t.chartType;for(const c of e){const e=c.x1-c.x0,d=c.y1-c.y0;if(0>=e||0>=d)continue;const h=!((null===(s=c.data)||void 0===s?void 0:s.children)&&c.data.children.length>0);if(!r){if("leaf"===i&&!h)continue;if("parent"===i&&h)continue}const g=o?o(c):c.id;if(!g)continue;if((h?30:40)>e||(h?16:14)>d)continue;let f=n(Il(c,"nodeStyle")).fill||ec(t);if(t.colorByDepth&&void 0!==c.depth){const e=Jl(t);f=e[c.depth%e.length]}const p="string"==typeof f?Kl(f):null!==(l=null===(a=t.themeSemantic)||void 0===a?void 0:a.text)&&void 0!==l?l:"#000";u.push(h?{x:c.x0+e/2,y:c.y0+d/2,text:g+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,Math.min(e,d)/6)),fill:p}:{x:c.x0+4,y:c.y0+12,text:g+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,o,0,i);case"circlepack":return function(e,t,o,n){var i,r,s,a,l,c,u,d,h,g;const f=[],p=[];for(const o of e){const e=null!==(i=o.__radius)&&void 0!==i?i:5;if(0>=e)continue;const l=n(Il(o,"nodeStyle"));let c=l.fill||ec(t);if(t.colorByDepth&&void 0!==o.depth){const e=Jl(t);c=e[o.depth%e.length]}const u={fill:c,stroke:l.stroke||(null===(r=t.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=l.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=l.opacity)&&void 0!==a?a:.7};f.push({type:"circle",cx:o.x,cy:o.y,r:e,style:u,datum:o,id:o.id,label:o.id,depth:o.depth})}if(!1!==t.showLabels){const o=Zl(t.nodeLabel);for(const i of e){const e=null!==(l=i.__radius)&&void 0!==l?l:5,r=o?o(i):i.id;if(!r)continue;if(15>e)continue;const s=!((null===(c=i.data)||void 0===c?void 0:c.children)&&i.data.children.length>0);let a=n(Il(i,"nodeStyle")).fill||ec(t);if(t.colorByDepth&&void 0!==i.depth){const e=Jl(t);a=e[i.depth%e.length]}if(s){const o="string"==typeof a?Kl(a):null!==(d=null===(u=t.themeSemantic)||void 0===u?void 0:u.text)&&void 0!==d?d:"#000";p.push({x:i.x,y:i.y,text:r+"",anchor:"middle",baseline:"middle",fontSize:Math.min(11,Math.max(8,e/3)),fill:o})}else p.push({x:i.x,y:i.y-e+14,text:r+"",anchor:"middle",baseline:"hanging",fontSize:Math.min(11,Math.max(8,e/3)),fill:(null===(h=t.themeSemantic)||void 0===h?void 0:h.text)||"#000",stroke:(null===(g=t.themeSemantic)||void 0===g?void 0:g.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:f,sceneEdges:[],labels:p}}(e,o,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function nc(e,t,o){const n=o.treeOrientation||"vertical";if("radial"===n){const o=t.x,n=t.y;e.x=n*Math.cos(o-Math.PI/2),e.y=n*Math.sin(o-Math.PI/2)}else"horizontal"===n?(e.x=t.y,e.y=t.x):(e.x=t.x,e.y=t.y);e.x0=e.x-5,e.x1=e.x+5,e.y0=e.y-5,e.y1=e.y+5,e.width=10,e.height=10}function ic(e,t){e.x0=t.x0,e.x1=t.x1,e.y0=t.y0,e.y1=t.y1,e.x=(t.x0+t.x1)/2,e.y=(t.y0+t.y1)/2,e.width=t.x1-t.x0,e.height=t.y1-t.y0}function rc(e,t){var o;const n=null!==(o=t.r)&&void 0!==o?o:0;e.x=t.x,e.y=t.y,e.x0=t.x-n,e.x1=t.x+n,e.y0=t.y-n,e.y1=t.y+n,e.width=2*n,e.height=2*n,e.__radius=n}function sc(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const ac={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,o,n){const i=o.__hierarchyRoot;i&&function(e,t,o,n,i){var r,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(o.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var o;return(null!==(o=e[t])&&void 0!==o?o:"")+""}}(o.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(o.orbitMode),d=null!==(r=o.orbitSize)&&void 0!==r?r:2.95,h=null!==(a=o.orbitEccentricity)&&void 0!==a?a:1,g="number"==typeof d?()=>d:d,f="number"==typeof h?()=>h:h,p=sc(o);p.metaMap.clear(),n.length=0,i.length=0;const y=new Map;function m(e){var t;const o=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,o+1),0===o?e:`${e}__${o}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,k=m(c(e));n.push({id:k,x:v,y:b,x0:v,x1:v,y0:b,y1:b,width:0,height:0,value:0,depth:0,data:e}),p.metaMap.set(k,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,o,r,a,d,h,y){const v=l(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,k=0,w=0;for(;b>k;)k+=u[Math.min(w,u.length-1)],w++,x++;let A=0;for(let b=0;x>b;b++){const k=u[Math.min(b,u.length-1)],w=v.slice(A,A+k);if(!w.length)break;const j=(b+1)/x,S={id:o,depth:h,data:t,parentId:o},C=y?d/g(S)*j:d*j,O=s.pie().value(e=>{var t;return(null===(t=l(e))||void 0===t?void 0:t.length)?4:1}).sort(null),M=O(w),P=f(S);for(let t=0;w.length>t;t++){const s=(M[t].startAngle+M[t].endAngle)/2,l=w[t],u=m(c(l)),d=r+C*Math.sin(s),g=a+C*Math.cos(s)*P;n.push({id:u,x:d,y:g,x0:d,x1:d,y0:g,y1:g,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:C,angle:s,depth:h,parentId:o,eccentricity:P}),i.push({source:o,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:o,target:u}}),e(l,u,d,g,C,h+1,!0)}A+=k}}(e,k,v,b,x,1,!1)}(i,n,o,e,t)},buildScene(e,t,o,n){var i,r,s,a,l,c,u;const d=o.nodeStyle,h=o.nodeSize,g="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,f=[],p=[],y=[];if(!1!==o.orbitShowRings){const t=sc(o),n=new Map;for(const t of e)n.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=n.get(e.parentId);if(!t)continue;const o=`${e.parentId}:${e.ring}`;i.has(o)||i.set(o,{parentX:t.x,parentY:t.y,ring:e.ring,ecc:e.eccentricity})}const r=48,s={stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1};for(const[,{parentX:e,parentY:t,ring:o,ecc:n}]of i)for(let i=0;r>i;i++){const a=i/r*Math.PI*2,l=(i+1)/r*Math.PI*2;p.push({type:"line",x1:e+o*Math.sin(a),y1:t+o*Math.cos(a)*n,x2:e+o*Math.sin(l),y2:t+o*Math.cos(l)*n,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=g(Il(t,"nodeSize")),n=d?d(Il(t,"nodeStyle")):{},c={fill:n.fill||(null===(i=o.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:n.stroke||(null===(r=o.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=n.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=n.opacity)&&void 0!==a?a:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};f.push({type:"circle",cx:t.x,cy:t.y,r:e,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const m=new Map;for(const t of e)m.set(t.id,t);for(const e of t){const t="object"==typeof e.source?e.source:m.get(e.source),o="object"==typeof e.target?e.target:m.get(e.target);t&&o&&(null!=t.x&&null!=o.x&&p.push({type:"line",x1:t.x,y1:t.y,x2:o.x,y2:o.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(o.showLabels){const t=o.nodeLabel;for(const o of e){const e=g(Il(o,"nodeSize"));if(4>=e)continue;const n="function"==typeof t?t(o):t&&null!==(u=null===(c=o.data)||void 0===c?void 0:c[t])&&void 0!==u?u:o.id;y.push({x:o.x,y:o.y+e+12,text:n+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:f,sceneEdges:p,labels:y}},tick:(e,t,o,n,i)=>!1!==o.orbitAnimated&&(function(e,t){var o,n;const i=sc(t),r=null!==(o=t.orbitSpeed)&&void 0!==o?o:.25,s=null!==(n=t.orbitRevolution)&&void 0!==n?n:function(e){switch(e){case"decay":return e=>{var t;return Math.pow(.6,null!==(t=e.depth)&&void 0!==t?t:0)};case"alternate":return e=>{var t;const o=null!==(t=e.depth)&&void 0!==t?t:0;return(o%2==0?1:-1)/(o+1)};default:return e=>{var t;return 1/((null!==(t=e.depth)&&void 0!==t?t:0)+1)}}}(t.orbitRevolutionStyle),a=(("undefined"!=typeof performance?performance.now():Date.now())-i.startTime)/1e3,l=r*(Math.PI/6),c=new Map;for(const t of e)c.set(t.id,t);for(const t of e){const e=i.metaMap.get(t.id);if(!e||!e.parentId)continue;const o=c.get(e.parentId);if(!o)continue;const n=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=o.x+e.ring*Math.sin(n),t.y=o.y+e.ring*Math.cos(n)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,o),!0)},lc={sankey:$l,force:Wl,chord:Xl,tree:oc,cluster:oc,treemap:oc,circlepack:oc,partition:oc,orbit:ac};function cc(e){return lc[e]}class uc{constructor(e){this.nodes=new Map,this.edges=new Map,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.customLayoutOverlays=null,this.particlePool=null,this.transition=null,this._hasRenderedOnce=!1,this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,this.lastIngestTime=0,this.nodeTimestamps=new Map,this.edgeTimestamps=new Map,this._decaySortedNodes=null,this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set,this.lastTopologyChangeTime=0,this.previousNodeIds=new Set,this.previousEdgeKeys=new Set,this._lastPositionSnapshot=null,this.config=e,this.tensionConfig=Object.assign(Object.assign({},za),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Ya(2e3))}updateConfig(e){const t=this.config;t.__orbitState&&(e.__orbitState=t.__orbitState),t.__hierarchyRoot&&(e.__hierarchyRoot=t.__hierarchyRoot),this.config=e,this.tensionConfig=Object.assign(Object.assign({},za),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new Ya(2e3))}ingestHierarchy(e,t){this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.config.__hierarchyRoot=e,this.runLayout(t),this._boundedPrevSnapshot=null}ingestBounded(e,t,o){const{nodeIDAccessor:n="id",sourceAccessor:i="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof n?n:e=>e[n],l="function"==typeof i?i:e=>e[i],c="function"==typeof r?r:e=>e[r],u="function"==typeof s?s:e=>{var t;return null!==(t=e[s])&&void 0!==t?t:1};this._boundedPrevSnapshot=new Map;for(const[e,t]of this.nodes)0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1||this._boundedPrevSnapshot.set(e,{x0:t.x0,x1:t.x1,y0:t.y0,y1:t.y1});this._boundedEdgeSnapshot=new Map;for(const[,e]of this.edges)e.sankeyWidth>0&&this._boundedEdgeSnapshot.set(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`,{y0:e.y0,y1:e.y1,sankeyWidth:e.sankeyWidth});this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const t of e){const e=a(t)+"";this.nodes.set(e,Object.assign(Object.assign({},dc(e)),{data:t}))}for(let e=0;t.length>e;e++){const o=t[e],n=l(o)+"",i=c(o)+"",r=u(o),s=null==r?NaN:Number(r),a=Number.isFinite(s)?s:1;this.nodes.has(n)||this.nodes.set(n,Object.assign(Object.assign({},dc(n)),{data:o})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},dc(i)),{data:o}));const d=`${n}\0${i}\0${e}`,h={source:n,target:i,value:a,y0:0,y1:0,sankeyWidth:0,data:o,_edgeKey:d};o&&"object"==typeof o&&hc(o.bezier)&&(h.bezier=o.bezier),this.edges.set(d,h)}this.runLayout(o)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:o,value:n}=e,i=0===this.nodes.size;let r=!1;const s="undefined"!=typeof performance?performance.now():Date.now();this.lastIngestTime=s,this._decaySortedNodes=null,this.nodes.has(t)||(this.nodes.set(t,dc(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(o)||(this.nodes.set(o,dc(o)),this.nodeTimestamps.set(o,s),this.tension+=this.tensionConfig.newNode,r=!0);const a=this.edgeKey(t,o),l=this.edges.get(a);let c=!1;return l?(l.value+=n,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:o,value:n,y0:0,y1:0,sankeyWidth:0}),this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.newEdge,r=!0),i||r||c||this.tension>=this.tensionConfig.threshold}runLayout(e){var t,o,n,i,r,s,a,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=cc(this.config.chartType);if(!c)return;let u=Array.from(this.nodes.values());const d=Array.from(this.edges.values());if(0===u.length&&!c.hierarchical)return;if(this.prepareForRelayout(),c.supportsStreaming&&!c.hierarchical){const e=new Map;for(const a of u)if(void 0!==a._prevX0){const l=(null!==(t=a._prevX1)&&void 0!==t?t:0)-(null!==(o=a._prevX0)&&void 0!==o?o:0),c=(null!==(n=a._prevY1)&&void 0!==n?n:0)-(null!==(i=a._prevY0)&&void 0!==i?i:0);e.set(a.id,{x:(null!==(r=a._prevX0)&&void 0!==r?r:0)+l/2,y:(null!==(s=a._prevY0)&&void 0!==s?s:0)+c/2})}else 0===a.x&&0===a.y||e.set(a.id,{x:a.x,y:a.y});if(this._lastPositionSnapshot)for(const[t,o]of this._lastPositionSnapshot)e.has(t)||e.set(t,o);this.config.__previousPositions=e.size>0?e:void 0}if(c.computeLayout(u,d,this.config,e),this.config.__previousPositions=void 0,c.hierarchical&&u.length>0){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null;for(const e of u)this.nodes.set(e.id,e);for(let e=0;d.length>e;e++){const t=d[e],o=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=o,this.edges.set(o,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const o=e.get(t.id);o&&(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,u=Array.from(this.nodes.values())}this.finalizeLayout();const h=new Map;for(const e of this.nodes.values())0===e.x&&0===e.y||h.set(e.id,{x:e.x,y:e.y});this._lastPositionSnapshot=h,this.saveTargetPositions();const g=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),f=null!==(l=null===(a=this.config.transition)||void 0===a?void 0:a.duration)&&void 0!==l?l:this.tensionConfig.transitionDuration;if(!this._hasRenderedOnce&&this.config.introAnimation&&["sankey","tree","treemap","circlepack","partition"].includes(this.config.chartType)&&u.length>0&&f>0){const t=e[0]/2,o=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=o,e._prevY1=o;for(const e of this.edges.values())e._prevY0=o,e._prevY1=o,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f}}else g&&f>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:f});this._hasRenderedOnce=!0,this.recordTopologyDiff(),this.layoutVersion++}recordTopologyDiff(){const e=new Set(this.nodes.keys()),t=new Set(this.edges.keys());this.addedNodes=new Set,this.removedNodes=new Set,this.addedEdges=new Set,this.removedEdges=new Set;for(const t of e)this.previousNodeIds.has(t)||this.addedNodes.add(t);for(const t of this.previousNodeIds)e.has(t)||this.removedNodes.add(t);for(const e of t)this.previousEdgeKeys.has(e)||this.addedEdges.add(e);for(const e of this.previousEdgeKeys)t.has(e)||this.removedEdges.add(e);(this.addedNodes.size>0||this.removedNodes.size>0||this.addedEdges.size>0||this.removedEdges.size>0)&&(this.lastTopologyChangeTime="undefined"!=typeof performance?performance.now():Date.now()),this.previousNodeIds=e,this.previousEdgeKeys=t}buildScene(e){var t,o,n,i,r,s;const a=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=Os(this.config.colorScheme,this.config.themeCategorical,K),u={nodes:a,edges:l,dimensions:{width:e[0],height:e[1],plot:{x:0,y:0,width:e[0],height:e[1]}},theme:{semantic:null!==(t=this.config.themeSemantic)&&void 0!==t?t:{},categorical:[...c]},resolveColor:Ms(c),config:null!==(o=this.config.layoutConfig)&&void 0!==o?o:{}};let d;try{d=this.config.customNetworkLayout(u)}catch(e){return"production"!==process.env.NODE_ENV&&console.error("[semiotic] customNetworkLayout threw:",e),this.sceneNodes=[],this.sceneEdges=[],this.labels=[],void(this.customLayoutOverlays=null)}return this.sceneNodes=null!==(n=d.sceneNodes)&&void 0!==n?n:[],this.sceneEdges=null!==(i=d.sceneEdges)&&void 0!==i?i:[],this.labels=null!==(r=d.labels)&&void 0!==r?r:[],void(this.customLayoutOverlays=null!==(s=d.overlays)&&void 0!==s?s:null)}this.customLayoutOverlays=null;const c=cc(this.config.chartType);if(!c)return;const{sceneNodes:u,sceneEdges:d,labels:h}=c.buildScene(a,l,this.config,e);this.sceneNodes=u,this.sceneEdges=d,this.labels=h}get isAnimating(){const e=cc(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=cc(this.config.chartType);if(!(null==o?void 0:o.tick))return!1;const n=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return o.tick(n,i,this.config,e,t)}cancelIntroAnimation(){this.transition=null;for(const e of this.nodes.values())e._prevX0=void 0,e._prevX1=void 0,e._prevY0=void 0,e._prevY1=void 0;for(const e of this.edges.values())e._prevY0=void 0,e._prevY1=void 0,e._prevSankeyWidth=void 0,e._introFromZero=!1}advanceTransition(e){if(!this.transition)return!1;const t=Oe(e,this.transition),o=Ce(t);for(const e of this.nodes.values())void 0===e._targetX0||void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=Me(e._prevX0,e._targetX0,o),e.x1=Me(e._prevX1,e._targetX1,o),e.y0=Me(e._prevY0,e._targetY0,o),e.y1=Me(e._prevY1,e._targetY1,o));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Me(e._prevY0,e._targetY0,o),e.y1=Me(e._prevY1,e._targetY1,o),e.sankeyWidth=Me(e._prevSankeyWidth,e._targetSankeyWidth,o));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const o=null==e?void 0:e.get(t.id);o&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=o.x0,t._prevX1=o.x1,t._prevY0=o.y0,t._prevY1=o.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const o=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(o){e._prevY0=o.y0,e._prevY1=o.y1,e._prevSankeyWidth=o.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,o="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&o&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,o))}buildStandardBezier(e,t,o){const n=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,r=o.x0,s=u.interpolateNumber(i,r);return{circular:!1,points:[{x:e.y0,y:i},{x:e.y0,y:s(.5)},{x:e.y1,y:s(.5)},{x:e.y1,y:r}],halfWidth:n}}const i=t.x1,r=o.x0,s=u.interpolateNumber(i,r);return{circular:!1,points:[{x:i,y:e.y0},{x:s(.5),y:e.y0},{x:s(.5),y:e.y1},{x:r,y:e.y1}],halfWidth:n}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,o=e.circularPathData;if(!o)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(o.rightFullExtent-o.sourceX))),n=Math.max(15,Math.min(40,.33*(o.targetX-o.leftFullExtent)));return{circular:!0,segments:[[{x:o.sourceX,y:o.sourceY},{x:o.sourceX+.33*e,y:o.sourceY},{x:o.sourceX+.66*e,y:o.sourceY},{x:o.sourceX+e,y:o.sourceY}],[{x:o.targetX-n,y:o.targetY},{x:o.targetX-.66*n,y:o.targetY},{x:o.targetX-.33*n,y:o.targetY},{x:o.targetX,y:o.targetY}]],halfWidth:t}}let n;n="down"===e.direction?[{x:o.sourceY,y:o.sourceX},{x:o.sourceY,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.rightFullExtent},{x:o.verticalFullExtent,y:o.leftFullExtent},{x:o.targetY,y:o.leftFullExtent},{x:o.targetY,y:o.targetX}]:[{x:o.sourceX,y:o.sourceY},{x:o.rightFullExtent,y:o.sourceY},{x:o.rightFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.verticalFullExtent},{x:o.leftFullExtent,y:o.targetY},{x:o.targetX,y:o.targetY}];const i=[];for(let e=0;n.length-1>e;e++){const t=n[e],o=n[e+1],r=o.x-t.x,s=o.y-t.y;i.push([t,{x:t.x+r/3,y:t.y+s/3},{x:t.x+2*r/3,y:t.y+2*s/3},o])}return{circular:!0,segments:i,halfWidth:t}}rebuildAllBeziers(){for(const e of this.nodes.values())e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;for(const e of this.edges.values())this.updateEdgeBezier(e)}applyPulse(e){var t,o,n,i,r;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(o=s.color)&&void 0!==o?o:"rgba(255,255,255,0.6)",c=null!==(n=s.glowRadius)&&void 0!==n?n:4;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const n=this.nodeTimestamps.get(o);if(!n)continue;const i=e-n;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const o=t.datum;if(!o)continue;const n="object"==typeof o.source?null===(i=o.source)||void 0===i?void 0:i.id:o.source,s="object"==typeof o.target?null===(r=o.target)||void 0===r?void 0:r.id:o.target;if(!n||!s)continue;const c=this.edgeTimestamps.get(`${n}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const o=this.config.decay;if(!o)return;const n=this.nodeTimestamps.size;if(1>=n)return;this._decaySortedNodes||(this._decaySortedNodes=Array.from(this.nodeTimestamps.entries()).sort((e,t)=>e[1]-t[1]));const i=this._decaySortedNodes,r=new Map;for(let e=0;i.length>e;e++)r.set(i[e][0],e);for(const i of this.sceneNodes){const s=i.id;if(!s)continue;const a=r.get(s);if(void 0===a)continue;const l=je(o,a,n),c=null!==(t=null===(e=i.style)||void 0===e?void 0:e.opacity)&&void 0!==t?t:1;i.style=Object.assign(Object.assign({},i.style),{opacity:c*l})}}applyTopologyDiff(e){var t;if(0===this.addedNodes.size)return;const o=e-this.lastTopologyChangeTime;if(o>=2e3)return;const n=1-o/2e3;for(const e of this.sceneNodes){const o=e.id;o&&this.addedNodes.has(o)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,n),e._pulseColor="rgba(34, 197, 94, 0.7)",e._pulseGlowRadius=8)}}get hasActiveTopologyDiff(){return 0!==this.addedNodes.size&&2e3>("undefined"!=typeof performance?performance.now():Date.now())-this.lastTopologyChangeTime}applyThresholds(e){var t,o;const n=this.config.thresholds;if(!n)return;const i=null!==(t=n.warningColor)&&void 0!==t?t:"#f59e0b",r=null!==(o=n.criticalColor)&&void 0!==o?o:"#ef4444",s=!1!==n.pulse;for(const t of this.sceneNodes){const o=t.id;if(!o)continue;const a=this.nodes.get(o);if(!a)continue;const l=n.metric(a);let c=null;void 0===n.critical||n.critical>l?void 0===n.warning||n.warning>l||(c=i):c=r,c&&(t.style=Object.assign(Object.assign({},t.style),{fill:c}),s&&(t._pulseIntensity=.6+.4*Math.sin(e/300),t._pulseColor=c,t._pulseGlowRadius=6))}}get hasActiveThresholds(){const e=this.config.thresholds;if(!e)return!1;for(const t of this.nodes.values()){const o=e.metric(t);if(void 0!==e.warning&&o>=e.warning||void 0!==e.critical&&o>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const o="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>o-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var o;const n=this.nodes.get(e);if(!n)return null;const i=n.data?Object.assign({},n.data):{};return n.data=t(null!==(o=n.data)&&void 0!==o?o:{}),this.layoutVersion++,i}updateEdge(e,t,o){var n;const i=this.config.valueAccessor,r="function"==typeof i?i:i?e=>e[i]:e=>e.value,s=[];for(const[,i]of this.edges)if(("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t){s.push(i.data?Object.assign({},i.data):{}),i.data=o(null!==(n=i.data)&&void 0!==n?n:{});const e=r(i.data);null!=e&&(i.value=Number(e))}return s.length>0&&this.layoutVersion++,s}removeNode(e){if(!this.nodes.has(e))return!1;this.nodes.delete(e),this.nodeTimestamps.delete(e);for(const[t,o]of this.edges)("string"==typeof o.source?o.source:o.source.id)!==e&&("string"==typeof o.target?o.target:o.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const o=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const n="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)i.data&&n(i.data)===e&&o.push(t)}else for(const[n,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&o.push(n);for(const e of o)this.edges.delete(e),this.edgeTimestamps.delete(e);return o.length>0&&this.layoutVersion++,o.length>0}clear(){this.nodes.clear(),this.edges.clear(),this._decaySortedNodes=null,this.tension=0,this.layoutVersion=0,this.sceneNodes=[],this.sceneEdges=[],this.labels=[],this.transition=null,this._hasRenderedOnce=!1,this.lastIngestTime=0,this._lastPositionSnapshot=null,this.nodeTimestamps.clear(),this.edgeTimestamps.clear(),this.particlePool&&this.particlePool.clear()}}function dc(e){return{id:e,x0:0,x1:0,y0:0,y1:0,x:0,y:0,width:0,height:0,value:0,createdByFrame:!0}}function hc(e){if(!e||"object"!=typeof e)return!1;const t=e;if("boolean"!=typeof t.circular)return!1;if("number"!=typeof t.halfWidth||!Number.isFinite(t.halfWidth))return!1;if(t.circular){if(!Array.isArray(t.segments)||0===t.segments.length)return!1;for(const e of t.segments)if(!gc(e))return!1;return!0}return gc(t.points)}function gc(e){if(!Array.isArray(e)||4!==e.length)return!1;for(const t of e){if(!t||"object"!=typeof t)return!1;const e=t;if("number"!=typeof e.x||!Number.isFinite(e.x))return!1;if("number"!=typeof e.y||!Number.isFinite(e.y))return!1}return!0}function fc(e,t,o,n,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=pc(t,o,n,i);if(e)if("rect"===t.type){const o=t.w*t.h;a>o&&(r=e,a=o)}else s>e.distance&&(r=e,s=e.distance)}if(r)return r;for(const e of t){if(!1===e.interactive)continue;const t=xc(e,o,n);t&&s>t.distance&&(r=t,s=t.distance)}return r}function pc(e,t,o,n=30){switch(e.type){case"circle":return function(e,t,o,n=30){const i=t-e.cx,r=o-e.cy,s=Math.sqrt(i*i+r*r);return s>Xe(e.r,n)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,o,n);case"rect":return function(e,t,o){const n=qe(t,o,e);return n.hit?{type:"node",datum:e.datum,x:n.cx,y:n.cy,distance:0}:null}(e,t,o);case"arc":return function(e,t,o){const n=t-e.cx,i=o-e.cy,r=Math.sqrt(n*n+i*i);if(e.innerR-2>r||r>e.outerR+2)return null;const s=Ke(Math.atan2(i,n)),a=Ke(e.startAngle),l=Ke(e.endAngle);if(a>l?s>=a||l>=s:s>=a&&l>=s){const t=(e.startAngle+e.endAngle)/2,o=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+o*Math.cos(t),y:e.cy+o*Math.sin(t),distance:0}}return null}(e,t,o);default:return null}}let yc=null,mc=null;function vc(){return mc||(yc=document.createElement("canvas"),yc.width=1,yc.height=1,mc=yc.getContext("2d")),mc}function bc(e){if(e._cachedPath2D&&e._cachedPath2DSource===e.pathD)return e._cachedPath2D;try{return e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD,e._cachedPath2D}catch(e){return null}}function xc(e,t,o){switch(e.type){case"bezier":return function(e,t,o){if(!e.pathD)return null;const n=bc(e),i=vc();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);case"line":return function(e,t,o){const n=e.x2-e.x1,i=e.y2-e.y1,r=n*n+i*i;if(0===r)return null;let s=((t-e.x1)*n+(o-e.y1)*i)/r;s=Math.max(0,Math.min(1,s));const a=e.x1+s*n,l=e.y1+s*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(o-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,o);case"ribbon":case"curved":return function(e,t,o){if(!e.pathD)return null;const n=bc(e),i=vc();if(!n||!i)return null;try{if(i.isPointInPath(n,t,o))return{type:"edge",datum:e.datum,x:t,y:o,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(n,t,o);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:o,distance:4}}catch(e){}return null}(e,t,o);default:return null}}function kc(t){const{width:o,height:n,totalWidth:i,totalHeight:r,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g,legendPosition:f="right",legendLayout:y,foregroundGraphics:m,sceneNodes:v,annotations:b,svgAnnotationRules:x}=t;return e.jsxs(e.Fragment,{children:[e.jsxs("svg",{role:"img",width:i,height:r,style:{position:"absolute",top:0,left:0,pointerEvents:"none"},children:[e.jsx("title",{children:"string"==typeof l?l:"Network Chart"}),e.jsx("desc",{children:"string"==typeof l?l+" — network data visualization":"Network data visualization"}),e.jsxs("g",{transform:`translate(${s.left},${s.top})`,children:[a.map((t,o)=>e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"start",dominantBaseline:t.baseline||"middle",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"currentColor",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,style:{pointerEvents:"none"},children:t.text},"label-"+o)),b&&b.filter(e=>"widget"!==e.type).map((t,i)=>{if(x){const r=x(t,i,{width:o,height:n,sceneNodes:v});if(r)return e.jsx(p.Fragment,{children:r},"annotation-"+i)}return null}),m]}),l&&"string"==typeof l?e.jsx("text",{x:i/2,y:16,textAnchor:"middle",fontWeight:600,fill:"currentColor",className:"semiotic-chart-title",style:{fontSize:"var(--semiotic-title-font-size, 14px)"},children:l}):l?e.jsx("foreignObject",{x:0,y:0,width:i,height:s.top,children:l}):null,Ht({legend:c,totalWidth:i,totalHeight:r,margin:s,legendPosition:f,title:l,legendLayout:y,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:g})]}),null==b?void 0:b.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,o)=>{var n,i,r,a,l,c,u,d,h;const g=v.find(e=>{var o,n,i,r,s;return e.id===t.nodeId||(null===(o=e.datum)||void 0===o?void 0:o.id)===t.nodeId||(null===(i=null===(n=e.datum)||void 0===n?void 0:n.data)||void 0===i?void 0:i.id)===t.nodeId||(null===(s=null===(r=e.datum)||void 0===r?void 0:r.data)||void 0===s?void 0:s.name)===t.nodeId});if(!g)return null;const f=s.left+(null!==(n=g.cx)&&void 0!==n?n:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(i=g.x)&&void 0!==i?i:0),p=s.top+(null!==(r=g.cy)&&void 0!==r?r:null!=g.y&&null!=g.h?g.y+g.h/2:null!==(a=g.y)&&void 0!==a?a:0),y=null!==(l=t.dx)&&void 0!==l?l:0,m=null!==(c=t.dy)&&void 0!==c?c:-16,b=null!==(u=t.width)&&void 0!==u?u:32,x=null!==(d=t.height)&&void 0!==d?d:32,k=null!==(h=t.content)&&void 0!==h?h:e.jsx("span",{style:{fontSize:18,cursor:"default"},children:"ℹ️"});return e.jsx("div",{style:{position:"absolute",left:f+y-b/2,top:p+m-x/2,width:b,height:x,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",zIndex:5},children:k},"widget-"+o)})]})}function wc(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function Ac(e,t){var o,n,i,r,s,a;if(!t.pathD)return;e.save();const l=wc(t);if(t.style.fill&&"none"!==t.style.fill){const s=t._gradient;if(s){const i=e.createLinearGradient(s.x0,0,s.x1,0),r=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,a="string"==typeof t.style.fill?t.style.fill:"#999",l=rt(e,a)||a;i.addColorStop(0,1===s.from?l:"transparent"),i.addColorStop(1,1===s.to?l:"transparent"),e.fillStyle=i,e.globalAlpha=r}else e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(r=null!==(i=t.style.fillOpacity)&&void 0!==i?i:t.style.opacity)&&void 0!==r?r:.5;e.fill(l)}t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(s=t.style.strokeWidth)&&void 0!==s?s:.5,e.globalAlpha=.5*(null!==(a=t.style.opacity)&&void 0!==a?a:1),e.stroke(l)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.2*t._pulseIntensity,e.fill(l)),e.restore()}function jc(e,t){var o,n;e.save();const i=t.style.stroke||"#999";e.strokeStyle=rt(e,i)||i,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.strokeDasharray&&e.setLineDash(t.style.strokeDasharray.split(/[\s,]+/).map(Number)),e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke(),t._pulseIntensity&&t._pulseIntensity>0&&(e.setLineDash([]),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=(null!==(n=t.style.strokeWidth)&&void 0!==n?n:1)+3*t._pulseIntensity,e.globalAlpha=.4*t._pulseIntensity,e.beginPath(),e.moveTo(t.x1,t.y1),e.lineTo(t.x2,t.y2),e.stroke()),e.restore()}function Sc(e,t){var o,n,i,r;if(!t.pathD)return;e.save();const s=wc(t);t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=null!==(o=t.style.fillOpacity)&&void 0!==o?o:t.style.opacity)&&void 0!==n?n:.5,e.fill(s)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(i=t.style.strokeWidth)&&void 0!==i?i:.5,e.globalAlpha=.3*(null!==(r=t.style.opacity)&&void 0!==r?r:1),e.stroke(s)),t._pulseIntensity&&t._pulseIntensity>0&&(e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.globalAlpha=.25*t._pulseIntensity,e.fill(s)),e.restore()}function Cc(e,t){var o,n;if(!t.pathD)return;e.save();const i=wc(t),r=t.style.stroke||"#999";e.strokeStyle=rt(e,r)||r,e.lineWidth=null!==(o=t.style.strokeWidth)&&void 0!==o?o:1,void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.stroke(i),t.style.fill&&"none"!==t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,e.globalAlpha=null!==(n=t.style.fillOpacity)&&void 0!==n?n:.1,e.fill(i)),e.restore()}kc.displayName="NetworkSVGOverlay";const Oc={top:20,right:80,bottom:20,left:80},Mc={top:40,right:40,bottom:40,left:40},Pc=new Set(["chord","force","circlepack","orbit"]),_c=[800,600],Lc={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 Tc({data:t}){var o,n,i,r,s,a;if("edge"===t.nodeOrEdge){const o=t.data;return o?e.jsxs("div",{className:"semiotic-tooltip",style:Lc,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof o.source?o.source.id:o.source," → ","object"==typeof o.target?o.target.id:o.target]}),null!=o.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof o.value?o.value.toLocaleString():o.value+""]})]}):null}const l=t.data;if(!l)return null;const c=l.__hierarchyNode;if(c){const t=[];let s=c;for(;s;){const e=null!==(r=null!==(n=null===(o=s.data)||void 0===o?void 0:o.name)&&void 0!==n?n:null===(i=s.data)||void 0===i?void 0:i.id)&&void 0!==r?r:l.id;null!=e&&t.unshift(e+""),s=s.parent}t.length>1&&t.shift();const a=t.length-1;return e.jsxs("div",{className:"semiotic-tooltip",style:Lc,children:[e.jsx("div",{children:t.map((t,o)=>e.jsxs("span",{children:[o>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),o===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},o))}),null!=l.value&&l.value>0&&e.jsx("div",{style:{marginTop:4,opacity:.8},children:"number"==typeof l.value?l.value.toLocaleString():l.value+""})]})}const u=((null===(s=l.sourceLinks)||void 0===s?void 0:s.length)||0)+((null===(a=l.targetLinks)||void 0===a?void 0:a.length)||0),d=(l.sourceLinks||[]).reduce((e,t)=>e+(t.value||0),0)+(l.targetLinks||[]).reduce((e,t)=>e+(t.value||0),0);return e.jsxs("div",{className:"semiotic-tooltip",style:Lc,children:[e.jsx("div",{style:{fontWeight:600},children:l.id}),null!=l.value&&l.value>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Total:"," ","number"==typeof l.value?l.value.toLocaleString():l.value+""]}),u>0&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Connections: ",u,d!==u&&` (weighted: ${d.toLocaleString()})`]})]})}Tc.ownsChrome=!0;const Rc=t.forwardRef(function(o,n){var i,r,a,l,c,u,d,h,g,f,p,y,m,b,x,k,w,A;const{chartType:j,nodes:C,edges:O,data:M,initialEdges:P,nodeIDAccessor:_="id",sourceAccessor:L="source",targetAccessor:T="target",valueAccessor:R="value",edgeIdAccessor:B,childrenAccessor:N,hierarchySum:D,orientation:E="horizontal",nodeAlign:I="justify",nodePaddingRatio:H=.05,nodeWidth:F=15,iterations:$=300,forceStrength:W=.1,padAngle:z=.01,groupWidth:G=20,sortGroups:Y,edgeSort:q,treeOrientation:X="vertical",edgeType:V="curve",padding:U,paddingTop:K,tensionConfig:Q,showParticles:Z=!1,particleStyle:J,nodeStyle:ee,edgeStyle:te,colorBy:oe,colorScheme:ne="category10",edgeColorBy:ie="source",edgeOpacity:re=.5,colorByDepth:se=!1,nodeSize:ae=8,nodeSizeRange:le=[5,20],nodeLabel:ce,showLabels:ue=!0,labelMode:de,size:he=_c,responsiveWidth:ge,responsiveHeight:fe,margin:pe,className:ye,background:ve,enableHover:be=!0,tooltipContent:xe,customHoverBehavior:ke,customClickBehavior:we,onObservation:Ae,chartId:je,onTopologyChange:Se,annotations:Ce,svgAnnotationRules:Oe,legend:Me,legendPosition:Pe,legendLayout:_e,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Be,title:Ne,foregroundGraphics:De,backgroundGraphics:Ee,decay:Ie,pulse:He,transition:Fe,animate:$e,staleness:We,thresholds:ze,accessibleTable:Ge=!0,description:qe,summary:Xe,orbitMode:Ve,orbitSize:Ue,orbitSpeed:Ke,orbitRevolution:Qe,orbitRevolutionStyle:Ze,orbitEccentricity:Je,orbitShowRings:et,orbitAnimated:tt,customNetworkLayout:ot,layoutConfig:nt}=o,it=Pc.has(j)?Mc:Oc,st=t.useRef(!0),at=On({sizeProp:he,responsiveWidth:ge,responsiveHeight:fe,userMargin:pe,marginDefault:it,foregroundGraphics:De,backgroundGraphics:Ee,animate:$e,transitionProp:Fe,themeDirtyRef:st}),{reducedMotionRef:lt,responsiveRef:ct,size:ut,margin:dt,adjustedWidth:ht,adjustedHeight:gt,resolvedForeground:ft,resolvedBackground:pt,transition:yt,introEnabled:mt,tableId:vt,rafRef:bt,renderFnRef:xt,scheduleRender:kt,currentTheme:wt}=at,Ct=To(),Mt=Do(),_t=t.useMemo(()=>v(C),[C]),Lt=t.useMemo(()=>Array.isArray(O)?v(O):O,[O]),Tt=t.useMemo(()=>Object.assign(Object.assign({},za),Q),[Q]),Rt=t.useMemo(()=>Object.assign(Object.assign({},Ga),J),[J]),Bt=t.useMemo(()=>{var e;return{chartType:j,nodeIDAccessor:_,sourceAccessor:L,targetAccessor:T,valueAccessor:R,edgeIdAccessor:B,childrenAccessor:N,hierarchySum:D,orientation:E,nodeAlign:I,nodePaddingRatio:H,nodeWidth:F,iterations:$,forceStrength:W,padAngle:z,groupWidth:G,sortGroups:Y,edgeSort:q,treeOrientation:X,edgeType:V,padding:U,paddingTop:K,tensionConfig:Tt,showParticles:Z,particleStyle:Rt,nodeStyle:ee,edgeStyle:te,nodeLabel:ce,showLabels:ue,labelMode:de,colorBy:oe,colorScheme:ne,themeCategorical:null===(e=null==wt?void 0:wt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(wt),edgeColorBy:ie,edgeOpacity:re,colorByDepth:se,nodeSize:ae,nodeSizeRange:le,decay:Ie,pulse:He,transition:yt,introAnimation:mt,staleness:We,thresholds:ze,orbitMode:Ve,orbitSize:Ue,orbitSpeed:Ke,orbitRevolution:Qe,orbitRevolutionStyle:Ze,orbitEccentricity:Je,orbitShowRings:et,orbitAnimated:tt,customNetworkLayout:ot,layoutConfig:nt}},[j,_,L,T,R,N,D,E,I,H,F,$,W,z,G,Y,q,X,V,U,K,Tt,Z,Rt,ee,te,ce,ue,de,oe,ne,ie,re,se,ae,le,Ie,He,null==yt?void 0:yt.duration,null==yt?void 0:yt.easing,mt,We,ze,Ve,Ue,Ke,Qe,Ze,Je,et,tt,wt,ot,nt]),Nt=Io(Bt),Dt=t.useRef(null),Et=t.useRef(0),It=t.useRef(0),Ht=t.useRef(!1),Ft=t.useRef(null);Ft.current||(Ft.current=new uc(Nt));const[$t,Wt]=t.useState(null),[zt,Gt]=t.useState(0),[Yt,qt]=t.useState(0),[Xt,Vt]=t.useState(!1),[Ut,Kt]=t.useState(null),Qt=t.useRef(null),Zt=t.useRef(new Map),Jt=t.useRef(0),eo=t.useCallback(e=>{if("function"==typeof oe)return oe(e)+"";if("string"==typeof oe&&e.data){const t=e.data[oe];if(void 0!==t){if(!Zt.current.has(t+"")){const e=Array.isArray(ne)?ne:me;Zt.current.set(t+"",e[Jt.current++%e.length])}return Zt.current.get(t+"")}}if(Zt.current.has(e.id))return Zt.current.get(e.id);const t=Array.isArray(ne)?ne:me,o=oe?t[Jt.current++%t.length]:t[0];return Zt.current.set(e.id,o),o},[oe,ne]),to=(null===(i=null==wt?void 0:wt.colors)||void 0===i?void 0:i.border)||(null===(r=null==wt?void 0:wt.colors)||void 0===r?void 0:r.secondary)||(null===(a=null==wt?void 0:wt.colors)||void 0===a?void 0:a.primary)||"#999",oo=t.useCallback(e=>{var t,o;return e?"object"==typeof e?e:null!==(o=null===(t=Ft.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==o?o:null:null},[]),no=t.useCallback(e=>{if("function"==typeof ie)return ie(e);const t=oo(e.source),o=oo(e.target);return"target"===ie&&o?eo(o):t?eo(t):to},[ie,eo,to,oo]),io=t.useCallback(e=>{if("function"==typeof Rt.color){const t=oo(e.source);return t?Rt.color(e,t):to}if(!(null==J?void 0:J.colorBy))return no(e);const t=Rt.colorBy,o=oo(e.source),n=oo(e.target);return"target"===t&&n?eo(n):o?eo(o):to},[null==J?void 0:J.colorBy,Rt.color,Rt.colorBy,eo,no,to,oo]),ro=("sankey"===j||!!ot)&&Z||!!He||null!==(c=null===(l=Ft.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=Ft.current)||void 0===e||e.updateConfig(Nt),st.current=!0,kt()},[Nt,kt]);const so=t.useCallback(()=>{var e,t;Kt(null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);t.useEffect(()=>{var e;const t=Ft.current;if(t){t.buildScene([ht,gt]),so();for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Zt.current.set(o.id,o.style.fill);st.current=!0,kt()}},[wt,ht,gt,kt,so]);const ao=t.useCallback(()=>{var e;const t=Ft.current;if(!t)return;t.runLayout([ht,gt]),t.buildScene([ht,gt]),so(),st.current=!0;for(const o of t.sceneNodes)o.id&&"string"==typeof(null===(e=o.style)||void 0===e?void 0:e.fill)&&Zt.current.set(o.id,o.style.fill);const o=Array.isArray(ne)?ne:me,n=Array.from(t.nodes.values());for(let e=0;n.length>e;e++){const t=n[e];Zt.current.has(t.id)||Zt.current.set(t.id,o[e%o.length])}if(Jt.current=n.length,Gt(t.layoutVersion),Se){const{nodes:e,edges:o}=t.getLayoutData();Se(e,o)}},[ht,gt,Se,ne,so]),lo=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=Ft.current;t&&(t.ingestEdge(e)&&ao(),kt())},[ao,kt]),co=t.useCallback(e=>{const t=Ft.current;if(!t)return;let o=!1;for(const n of e)null!=n&&"object"==typeof n&&t.ingestEdge(n)&&(o=!0);o&&ao(),kt()},[ao,kt]),uo=t.useCallback(()=>{var e;null===(e=Ft.current)||void 0===e||e.clear(),Zt.current.clear(),Jt.current=0,Gt(0),Wt(null),Qt.current=null,st.current=!0,kt()},[kt]),ho=t.useCallback(()=>{const e=Ft.current;e&&(e.tension+=999,ao(),kt())},[ao,kt]);t.useImperativeHandle(n,()=>({push:lo,pushMany:co,removeNode:e=>{var t,o,n;const i=null!==(o=null===(t=Ft.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==o&&o;if(i){const t=(null===(n=Qt.current)||void 0===n?void 0:n.data)?"function"==typeof _?_(Qt.current.data):Qt.current.data[_]:void 0;Qt.current&&"node"===Qt.current.nodeOrEdge&&t===e&&(Qt.current=null,Wt(null)),Zt.current.delete(e),ao(),st.current=!0,kt()}return i},removeEdge:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ft.current)||void 0===o?void 0:o.removeEdge(e,t))&&void 0!==n&&n;if(i){if(Qt.current&&"edge"===Qt.current.nodeOrEdge){const o=Qt.current.data;let n;n=void 0!==t?("object"==typeof(null==o?void 0:o.source)?o.source.id:null==o?void 0:o.source)===e&&("object"==typeof(null==o?void 0:o.target)?o.target.id:null==o?void 0:o.target)===t:!B||!o||("function"==typeof B?B:e=>null==e?void 0:e[B])(o)===e,n&&(Qt.current=null,Wt(null))}ao(),st.current=!0,kt()}return i},updateNode:(e,t)=>{var o,n;const i=null!==(n=null===(o=Ft.current)||void 0===o?void 0:o.updateNode(e,t))&&void 0!==n?n:null;return i&&(st.current=!0,kt()),i},updateEdge:(e,t,o)=>{var n,i;const r=null!==(i=null===(n=Ft.current)||void 0===n?void 0:n.updateEdge(e,t,o))&&void 0!==i?i:[];return r.length>0&&(ao(),st.current=!0,kt()),r},clear:uo,getTopology:()=>{var e,t;return null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=Ft.current;return e?{addedNodes:Array.from(e.addedNodes),removedNodes:Array.from(e.removedNodes),addedEdges:Array.from(e.addedEdges),removedEdges:Array.from(e.removedEdges)}:{addedNodes:[],removedNodes:[],addedEdges:[],removedEdges:[]}},relayout:ho,getTension:()=>{var e,t;return null!==(t=null===(e=Ft.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[lo,co,uo,ho,ao,kt]);const go=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),fo=go?M||(Array.isArray(O)?void 0:O):void 0;t.useEffect(()=>{var e;const t=Ft.current;if(t)if(go&&fo)t.ingestHierarchy(fo,[ht,gt]),t.buildScene([ht,gt]),so(),st.current=!0,kt();else{const o=_t,n=Array.isArray(Lt)?Lt:[];if(0===o.length&&0===n.length)return;t.ingestBounded(o,n,[ht,gt]),t.buildScene([ht,gt]),so();for(const o of t.sceneNodes)o.id&&(null===(e=o.style)||void 0===e?void 0:e.fill)&&Zt.current.set(o.id,o.style.fill+"");const i=Array.isArray(ne)?ne:me,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];Zt.current.has(t.id)||Zt.current.set(t.id,i[e%i.length])}Jt.current=r.length,st.current=!0,kt()}},[_t,Lt,M,fo,go,ht,gt,Nt,kt,ne,so]),t.useEffect(()=>{P&&P.length>0&&co(P)},[]);const po=t.useCallback(e=>{if(ke&&ke(e),Ae){const t=Date.now();Ae(e?{type:"hover",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:je}:{type:"hover-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:je})}},[ke,Ae,je]),yo=t.useCallback(e=>{if(we&&we(e),Ae){const t=Date.now();Ae(e?{type:"click",datum:e.data||{},x:e.x,y:e.y,timestamp:t,chartType:"StreamNetworkFrame",chartId:je}:{type:"click-end",timestamp:t,chartType:"StreamNetworkFrame",chartId:je})}},[we,Ae,je]),{hoverHandlerRef:mo,hoverLeaveRef:vo,onPointerMove:bo,onPointerLeave:xo}=at;mo.current=e=>{if(!be)return;const t=Dt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-dt.left,i=e.clientY-o.top-dt.top;if(0>n||n>ht||0>i||i>gt)return void(Qt.current&&(Qt.current=null,Wt(null),po&&(po(null),st.current=!0),kt()));const r=Ft.current;if(!r)return;const s=fc(r.sceneNodes,r.sceneEdges,n,i);if(!s)return void(Qt.current&&(Qt.current=null,Wt(null),po&&(po(null),st.current=!0),kt()));const a=pn(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Qt.current=a,Wt(a),po&&(po(a),st.current=!0),kt()},vo.current=()=>{Qt.current&&(Qt.current=null,Wt(null),po&&(po(null),st.current=!0),kt())};const ko=t.useRef(()=>{});ko.current=e=>{if(!we&&!Ae)return;const t=Dt.current;if(!t)return;const o=t.getBoundingClientRect(),n=e.clientX-o.left-dt.left,i=e.clientY-o.top-dt.top;if(0>n||n>ht||0>i||i>gt)return;const r=Ft.current;if(!r)return;const s=fc(r.sceneNodes,r.sceneEdges,n,i);yo(s?pn(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const wo=t.useCallback(e=>ko.current(e),[]),Ao=t.useRef(-1),jo=t.useRef(null),So=t.useRef(-1),Co=t.useCallback(e=>{var t;const o=Ft.current;if(!o)return;const n=function(e){var t,o,n,i,r,s;const a=[];for(const l of e)if("circle"===l.type&&null!=l.cx){if(0>=l.r)continue;a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(o=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==o?o:"_default"})}else if("rect"===l.type&&null!=l.x){if(0>=l.w||0>=l.h)continue;a.push({x:l.x+l.w/2,y:l.y+l.h/2,datum:l.datum,shape:"rect",w:l.w,h:l.h,group:null!==(i=null===(n=l.datum)||void 0===n?void 0:n.id)&&void 0!==i?i:"_default"})}else"arc"===l.type&&null!=l.cx&&a.push({x:l.cx,y:l.cy,datum:l.datum,shape:"circle",group:null!==(s=null===(r=l.datum)||void 0===r?void 0:r.id)&&void 0!==s?s:"_default"});return a.sort((e,t)=>e.x-t.x||e.y-t.y),a}(o.sceneNodes);if(0===n.length)return;const i=At(n),r=Ao.current;if(0>r){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown","Enter"].includes(e.key))return;e.preventDefault(),Ao.current=0,So.current=-1;const t=i.flat[0];jo.current={shape:t.shape,w:t.w,h:t.h};const o=pn(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Qt.current=o,Wt(o),po&&(po(o),st.current=!0),void kt()}const s=jt(i,r),a=function(e,t,o,n,i){var r,s,a;const l=o.flat[t.flatIndex];if(!l)return St(e,t,o);const c=null===(r=l.datum)||void 0===r?void 0:r.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const n=null!==(s=function(e,t,o){let n=null,i=1/0;for(let r=0;e.flat.length>r;r++){const s=e.flat[r];if(s===t)continue;const a=s.x-t.x,l=s.y-t.y;let c=!1;switch(o){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,n=r)}return n}(o,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return n!==t.flatIndex&&(i.current=-1),n}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var o;const n=e+"",i=[];for(const e of t){const t=null!==(o=e.datum)&&void 0!==o?o:e,r=Ot(t.source),s=Ot(t.target),a=null!=r,l=null!=s;a&&r+""===n&&l?i.push(s+""):l&&s+""===n&&a&&i.push(r+"")}return i}(c,n);if(0===e.length)return t.flatIndex;const r=null!==(a=o.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>r?t.flatIndex:(i.current=-1,r)}default:{const n=St(e,t,o);return null!==n&&n!==t.flatIndex&&(i.current=-1),n}}}(e.key,s,i,null!==(t=o.sceneEdges)&&void 0!==t?t:[],So);if(null===a)return;if(e.preventDefault(),0>a)return Ao.current=-1,jo.current=null,So.current=-1,Qt.current=null,Wt(null),po&&(po(null),st.current=!0),void kt();Ao.current=a;const l=i.flat[a];jo.current={shape:l.shape,w:l.w,h:l.h};const c={data:l.datum||{},x:l.x,y:l.y,__semioticHoverData:!0,nodeOrEdge:"node"};Qt.current=c,Wt(c),po&&(po(c),st.current=!0),kt()},[po,kt]),Po=t.useCallback(e=>{Ao.current=-1,jo.current=null,bo(e)},[bo]);xt.current=()=>{var e,t,o,n,i,r,s;bt.current=0;const a=Dt.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=Ft.current;if(!c)return;const u=performance.now(),d=Et.current?Math.min((u-Et.current)/1e3,.1):.016;Et.current=u;const h=c.advanceTransition(lt.current?u+1e6:u),g=!lt.current&&h,f=!lt.current&&c.tickAnimation([ht,gt],d);(h||st.current||f)&&c.buildScene([ht,gt]);const p=Pn();if(!Mn(a,ut,dt,p))return;if(l.clearRect(-dt.left,-dt.top,ut[0],ut[1]),ve){const e=rt(l,ve);e&&(l.fillStyle=e,l.fillRect(0,0,ht,gt))}Ie&&c.applyDecay(),He&&c.applyPulse(u),ze&&c.applyThresholds(u),c.applyTopologyDiff(u);const y=null!==(e=null==We?void 0:We.threshold)&&void 0!==e?e:5e3,m=We&&c.lastIngestTime>0&&u-c.lastIngestTime>y;if(m&&(l.globalAlpha=null!==(t=null==We?void 0:We.dimOpacity)&&void 0!==t?t:.5),function(e,t){for(const o of t)switch(o.type){case"bezier":Ac(e,o);break;case"line":jc(e,o);break;case"ribbon":Sc(e,o);break;case"curved":Cc(e,o)}}(l,c.sceneEdges),function(e,t){var o,n,i;for(const r of t){if("rect"!==r.type)continue;const t=r;t.w>0&&t.h>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fillRect(t.x,t.y,t.w,t.h)),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),Bn(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("circle"!==r.type)continue;const t=r;t.r>0&&(e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.r,0,2*Math.PI),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),Nn(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var o,n,i;for(const r of t){if("arc"!==r.type)continue;const t=r;e.save(),void 0!==t.style.opacity&&(e.globalAlpha=t.style.opacity),e.beginPath(),e.arc(t.cx,t.cy,t.outerR,t.startAngle,t.endAngle),e.arc(t.cx,t.cy,t.innerR,t.endAngle,t.startAngle,!0),e.closePath(),t.style.fill&&(e.fillStyle="string"==typeof t.style.fill&&rt(e,t.style.fill)||t.style.fill,void 0!==t.style.fillOpacity&&(e.globalAlpha=(null!==(o=t.style.opacity)&&void 0!==o?o:1)*t.style.fillOpacity),e.fill()),t.style.stroke&&"none"!==t.style.stroke&&(e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),e.restore()}}(l,c.sceneNodes),Z&&c.particlePool&&!m){const e=Array.from(c.edges.values());if(e.length>0){!function(e,t,o,n){var i,r;const s=null!==(i=n.spawnRate)&&void 0!==i?i:Ga.spawnRate,a=null!==(r=n.maxPerEdge)&&void 0!==r?r:Ga.maxPerEdge;for(let n=0;t.length>n;n++){const i=t[n];if(!i.bezier)continue;if(e.countForEdge(n)>=a)continue;const r=i.value*s*o*(i.bezier.circular?.3:1),l=Math.floor(r),c=r-l;let u=l;Math.random()<c&&u++;for(let t=0;u>t&&e.countForEdge(n)<a;t++)e.spawn(n)}}(c.particlePool,e,d,Rt);const t=.5*(null!==(o=Rt.speedMultiplier)&&void 0!==o?o:1);let n;if(Rt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);n=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,n),function(e,t,o,n,i){var r,s;const a=null!==(r=n.radius)&&void 0!==r?r:Ga.radius,l=null!==(s=n.opacity)&&void 0!==s?s:Ga.opacity;e.globalAlpha=l;for(let r=0;t.particles.length>r;r++){const s=t.particles[r];if(!s.active)continue;const l=o[s.edgeIndex];if(!l)continue;let c;c="string"==typeof n.color&&"inherit"!==n.color?n.color:i(l),e.fillStyle=rt(e,c)||c,e.beginPath(),e.arc(s.x,s.y,a,0,2*Math.PI),e.fill()}e.globalAlpha=1}(l,c.particlePool,e,Rt,io)}}m&&(l.globalAlpha=1);const v=st.current;if(st.current=!1,v||g||f){const e=Dt.current;e&&e.setAttribute("aria-label",Xo(null!==(i=null===(n=c.sceneNodes)||void 0===n?void 0:n.length)&&void 0!==i?i:0,null!==(s=null===(r=c.sceneEdges)||void 0===r?void 0:r.length)&&void 0!==s?s:0,"Network chart"))}const b=v||g||f||Ht.current;b&&u-It.current>=33?(qt(e=>e+1),It.current=u,Ht.current=!1):Ht.current=!!b,(ro||g||null!=c.transition||f||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Ht.current)&&(bt.current=requestAnimationFrame(()=>xt.current()))},Eo({hydrated:Ct,wasHydratingFromSSR:Mt,storeRef:Ft,dirtyRef:st,renderFnRef:xt}),t.useEffect(()=>{st.current=!0,kt()},[j,ht,gt,ve,kt]),Pt(We,Ft,st,kt,Xt,Vt);const Lo=be&&$t?e.jsx(wn,{x:$t.x,y:$t.y,containerWidth:ht,containerHeight:gt,margin:dt,className:"stream-network-tooltip",zIndex:2,children:xe?xe($t):e.jsx(Tc,{data:$t})}):null;if(_o||!Ct&&Mt){const t=Ft.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),o=e?M||(Array.isArray(O)?void 0:O):void 0;if(e&&o)t.ingestHierarchy(o,[ht,gt]),t.buildScene([ht,gt]);else{const e=_t,o=Array.isArray(Lt)?Lt:[];(e.length>0||o.length>0)&&(t.ingestBounded(e,o,[ht,gt]),t.buildScene([ht,gt]))}}const o=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],n=null!==(d=null==t?void 0:t.sceneEdges)&&void 0!==d?d:[],i=null!==(h=null==t?void 0:t.labels)&&void 0!==h?h:[];return e.jsxs("div",{ref:ct,className:"stream-network-frame"+(ye?" "+ye:""),role:"img","aria-label":qe||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:ge?"100%":ut[0],height:fe?"100%":ut[1]},children:[e.jsx(cn,{summary:Xe}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:ut[0],height:ut[1],style:{position:"absolute",left:0,top:0},children:[pt&&e.jsx("g",{transform:`translate(${dt.left},${dt.top})`,children:pt}),e.jsxs("g",{transform:`translate(${dt.left},${dt.top})`,children:[ve&&e.jsx("rect",{x:0,y:0,width:ht,height:gt,fill:ve}),n.map((t,o)=>function(t,o){switch(t.type){case"line":return e.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.style.stroke||"#999",strokeWidth:t.style.strokeWidth||1,opacity:t.style.opacity},"net-edge-"+o);case"bezier":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"ribbon":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"#999"),fillOpacity:n.style.fillOpacity,stroke:n.style.stroke||"none",strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-edge-"+o)}case"curved":{const n=t;return e.jsx("path",{d:n.pathD,fill:Mo(n.style.fill,"none"),stroke:n.style.stroke||"#999",strokeWidth:n.style.strokeWidth||1,opacity:n.style.opacity},"net-edge-"+o)}default:return null}}(t,o)).filter(Boolean),o.map((t,o)=>function(t,o){switch(t.type){case"circle":{const n=t;return e.jsx("circle",{cx:n.cx,cy:n.cy,r:n.r,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-circle-"+o)}case"rect":{const n=t;return e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-rect-"+o)}case"arc":{const n=t,i=s.arc().innerRadius(n.innerR).outerRadius(n.outerR).startAngle(n.startAngle+Math.PI/2).endAngle(n.endAngle+Math.PI/2)(Oo)||"";return e.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:Mo(n.style.fill),stroke:n.style.stroke,strokeWidth:n.style.strokeWidth,opacity:n.style.opacity},"net-arc-"+o)}default:return null}}(t,o)).filter(Boolean),i.map((t,o)=>function(t,o){return e.jsx("text",{x:t.x,y:t.y,textAnchor:t.anchor||"middle",dominantBaseline:t.baseline||"auto",fontSize:t.fontSize||11,fontWeight:t.fontWeight,fill:t.fill||"#333",stroke:t.stroke,strokeWidth:t.strokeWidth,paintOrder:t.paintOrder,children:t.text},"net-label-"+o)}(t,o)).filter(Boolean)]})]}),e.jsx(kc,{width:ht,height:gt,totalWidth:ut[0],totalHeight:ut[1],margin:dt,labels:i,sceneNodes:o,title:Ne,legend:Me,legendPosition:Pe,legendLayout:_e,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Be,foregroundGraphics:Ye(ft,null===(g=Ft.current)||void 0===g?void 0:g.customLayoutOverlays),annotations:Ce,svgAnnotationRules:Oe,annotationFrame:0})]})}const Ro=Ft.current;return e.jsxs("div",{ref:ct,className:"stream-network-frame"+(ye?" "+ye:""),role:"group","aria-label":qe||("string"==typeof Ne?Ne:"Network chart"),tabIndex:0,style:{position:"relative",width:ge?"100%":ut[0],height:fe?"100%":ut[1],overflow:"visible"},onKeyDown:Co,children:[Ge&&e.jsx(un,{tableId:vt}),Ge&&e.jsx(ln,{nodes:null!==(f=null==Ro?void 0:Ro.sceneNodes)&&void 0!==f?f:[],edges:null!==(p=null==Ro?void 0:Ro.sceneEdges)&&void 0!==p?p:[],chartType:"Network chart",tableId:vt,chartTitle:"string"==typeof Ne?Ne:void 0}),e.jsx(cn,{summary:Xe}),e.jsxs("div",{role:"img","aria-label":qe||("string"==typeof Ne?Ne:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?Po:void 0,onMouseLeave:be?xo:void 0,onClick:we||Ae?wo:void 0,children:[pt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:ut[0],height:ut[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${dt.left},${dt.top})`,children:pt})}),e.jsx("canvas",{ref:Dt,"aria-label":Xo(null!==(m=null===(y=null==Ro?void 0:Ro.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==m?m:0,null!==(x=null===(b=null==Ro?void 0:Ro.sceneEdges)||void 0===b?void 0:b.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(dn,{hoverPoint:$t}),e.jsx(kc,{width:ht,height:gt,totalWidth:ut[0],totalHeight:ut[1],margin:dt,labels:(null==Ro?void 0:Ro.labels)||[],sceneNodes:null==Ro?void 0:Ro.sceneNodes,title:Ne,legend:Me,legendPosition:Pe,legendLayout:_e,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Be,foregroundGraphics:Ye(ft,Ut),annotations:Ce,svgAnnotationRules:Oe,annotationFrame:Yt}),e.jsx(gn,{active:Ao.current>=0,hoverPoint:$t,margin:dt,size:ut,shape:null===(k=jo.current)||void 0===k?void 0:k.shape,width:null===(w=jo.current)||void 0===w?void 0:w.w,height:null===(A=jo.current)||void 0===A?void 0:A.h}),Lo,(null==We?void 0:We.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===We.badgePosition?{top:4,left:4}:"bottom-left"===We.badgePosition?{bottom:4,left:4}:"bottom-right"===We.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{background:Xt?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Xt?"STALE":"LIVE"})]})]})});function Bc(e,t){if(!e)return[];const o=[],n=e=>{o.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(n)};return n(e),o}function Nc(e,t,o,n){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof o?o(e):e[o],r="function"==typeof n?n(e):e[n];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function Dc(e){return"function"==typeof e?e:t=>t[e]||1}function Ec({edgeColorBy:e,colorBy:t,colorScale:o,nodeStyleFn:n,edgeOpacity:i,baseStyle:r={}}){return s=>{const a=Object.assign({fillOpacity:i},r);if("function"==typeof e)a.fill=e(s);else if("source"===e){const e="object"==typeof s.source?s.source:null;t&&e?a.fill=ke(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=ke(e.data||e,t,o):e&&(a.fill=n(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function Ic(e){const{nodes:o,edges:n,inferNodes:i=!0,sourceAccessor:r="source",targetAccessor:s="target",colorBy:a,colorScheme:l,showLegend:c,legendPosition:u,legendInteraction:d,selection:h,linkedHover:g,onObservation:f,onClick:p,chartType:y,chartId:m,marginDefaults:b,userMargin:x,width:k,height:w,loading:A,loadingContent:j,emptyContent:S,emptyDataKey:C="edges"}=e,O=t.useMemo(()=>v(n),[n]),M=t.useMemo(()=>v(o),[o]),P=mr(A,k,w,j),_=P?null:yr("nodes"===C?void 0===o?void 0:M:void 0===n?void 0:O,k,w,S),L=t.useMemo(()=>i?Nc(M,O,r,s):M,[i,M,O,r,s]),T=Xi(L,a,l),R=Yi(),B=t.useMemo(()=>{if(Array.isArray(l))return l;if(R&&R.length>0)return R;if("string"==typeof l){const e=ye[l];if(Array.isArray(e)&&e.length>0)return e}return me},[l,R]),N=t.useMemo(()=>{if(!a)return[];const e=new Set;for(const t of L){const o="function"==typeof a?a(t):t[a];null!=o&&e.add(o+"")}return Array.from(e)},[L,a]),D=Zi(d,a,N),{legend:E,margin:I,legendPosition:H}=Qi({data:L,colorBy:a,colorScale:T,showLegend:c,legendPosition:u,userMargin:x,defaults:b,categories:N}),F=Ui({selection:h,linkedHover:g,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:f,onClick:p,chartType:y,chartId:m}),{customHoverBehavior:$,customClickBehavior:W,activeSelectionHook:z,hoverSelectionHook:G,crosshairSourceId:Y}=F;return{safeNodes:L,safeEdges:O,colorScale:T,effectivePalette:B,themeCategorical:R,allCategories:N,legendState:D,legend:E,margin:I,legendPosition:H,customHoverBehavior:$,customClickBehavior:W,activeSelectionHook:z,hoverSelectionHook:G,crosshairSourceId:Y,loadingEl:P,emptyEl:_}}Rc.displayName="StreamNetworkFrame";const Hc=t.forwardRef(function(o,n){var i;const r=t.useRef(null);_r(n,{variant:"network",frameRef:r});const s=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLegend:o.showLegend,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:g="source",targetAccessor:f="target",nodeLabel:p,colorBy:y,colorScheme:m,nodeSize:v=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:k="#999",edgeOpacity:w=.6,iterations:A=300,forceStrength:j=.1,tooltip:S,frameProps:C={},onObservation:O,onClick:M,chartId:P,selection:_,linkedHover:L,loading:T,loadingContent:R,emptyContent:B,legendInteraction:N,legendPosition:D,stroke:E,strokeWidth:I,opacity:H}=o,F=null!==(i=null!=d?d:h)&&void 0!==i?i:"id",{width:$,height:W,enableHover:z,showLegend:G,showLabels:Y=!1,title:q,description:X,summary:V,accessibleTable:U}=s,K=Ic({nodes:a,edges:l,inferNodes:!1,sourceAccessor:g,targetAccessor:f,colorBy:y,colorScheme:m,showLegend:G,legendPosition:D,legendInteraction:N,selection:_,linkedHover:L,onObservation:O,onClick:M,chartType:"ForceDirectedGraph",chartId:P,marginDefaults:s.marginDefaults,userMargin:c,width:$,height:W,loading:T,loadingContent:R,emptyContent:B,emptyDataKey:"nodes"}),Q=t.useMemo(()=>new Map,[]),Z=t.useMemo(()=>e=>{const t={};return t.fill=y?ke(e.data||e,y,K.colorScale):qi(void 0,K.themeCategorical,m,void 0,Q),"number"==typeof v&&(t.r=v),t},[y,K.colorScale,v,K.themeCategorical,m,Q]),J=t.useMemo(()=>Mr(Z,{stroke:E,strokeWidth:I,opacity:H}),[Z,E,I,H]),ee=t.useMemo(()=>e=>({stroke:k,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:w}),[x,k,w]),te=t.useMemo(()=>Mr(ee,{stroke:E,strokeWidth:I,opacity:H}),[ee,E,I,H]),oe=t.useMemo(()=>{if(Y&&p)return"function"==typeof p?p:e=>{var t,o,n;return null!==(n=null!==(o=null===(t=e.data)||void 0===t?void 0:t[p])&&void 0!==o?o:e[p])&&void 0!==n?n:e.id}},[Y,p]),ne=Sr({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:F}});return ne?e.jsx(cr,{componentName:"ForceDirectedGraph",message:ne,width:$,height:W}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e.jsx(gr,{componentName:"ForceDirectedGraph",width:$,height:W,children:e.jsx(Rc,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:K.safeNodes},null!=l&&{edges:K.safeEdges},{size:[$,W],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:K.margin,nodeIDAccessor:F,sourceAccessor:g,targetAccessor:f,iterations:A,forceStrength:j,nodeStyle:J,edgeStyle:te,colorBy:y,colorScheme:K.effectivePalette,nodeSize:v,nodeSizeRange:b,nodeLabel:oe,showLabels:Y,enableHover:z,tooltipContent:!1===S?()=>null:kn(S)||void 0,customHoverBehavior:L||O||M?K.customHoverBehavior:void 0,customClickBehavior:O||M?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},N&&"none"!==N&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:u,title:q,description:X,summary:V,accessibleTable:U},null!=o.animate&&{animate:o.animate},C))})});Hc.displayName="ForceDirectedGraph";const Fc=t.forwardRef(function(o,n){const i=t.useRef(null);_r(n,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}});const r=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:y="source",padAngle:m=.01,groupWidth:v=20,sortGroups:b,nodeLabel:x,edgeOpacity:k=.5,tooltip:w,frameProps:A={},onObservation:j,onClick:S,chartId:C,selection:O,linkedHover:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:D,height:E,enableHover:I,showLabels:H=!0,title:F,description:$,summary:W,accessibleTable:z}=r,G=Ic({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:p,showLegend:!1,legendInteraction:T,selection:O,linkedHover:M,onObservation:j,onClick:S,chartType:"ChordDiagram",chartId:C,marginDefaults:r.marginDefaults,userMargin:l,width:D,height:E,loading:P,loadingContent:_,emptyContent:L}),Y=t.useMemo(()=>new Map,[]),q=G.safeNodes.length>0,X=t.useMemo(()=>{if(q)return(e,t)=>{var o,n;const i={stroke:"black",strokeWidth:1};if(f)i.fill=ke(e.data||e,f,G.colorScale);else{const r=Array.isArray(p)?p:ye[p]||me,s=Array.isArray(r)?r:me,a=null!==(n=null!==(o=e.index)&&void 0!==o?o:t)&&void 0!==n?n:0;i.fill=s[a%s.length]}return i}},[q,f,G.colorScale,p]),V=t.useMemo(()=>X?Mr(X,{stroke:R,strokeWidth:B,opacity:N}):void 0,[X,R,B,N]),U=t.useMemo(()=>{if(q)return Ec({edgeColorBy:y,colorBy:f,colorScale:G.colorScale,nodeStyleFn:V||(e=>({fill:qi(void 0,G.themeCategorical,p,void 0,Y)})),edgeOpacity:k,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:k}})},[q,y,f,G.colorScale,V,k,G.themeCategorical,p,Y]),K=t.useMemo(()=>U?Mr(U,{stroke:R,strokeWidth:B,opacity:N}):void 0,[U,R,B,N]),Q=t.useMemo(()=>{if(!H)return;const e=x||g;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[H,x,g]),Z=Sr({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return Z?e.jsx(cr,{componentName:"ChordDiagram",message:Z,width:D,height:E}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:e.jsx(gr,{componentName:"ChordDiagram",width:D,height:E,children:e.jsx(Rc,Object.assign({ref:i,chartType:"chord"},G.safeNodes.length>0&&{nodes:G.safeNodes},null!=a&&{edges:G.safeEdges},{size:[D,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:G.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:m,groupWidth:v,sortGroups:b,nodeStyle:V,edgeStyle:K,colorBy:f,colorScheme:G.effectivePalette,edgeColorBy:y,edgeOpacity:k,nodeLabel:Q,showLabels:H,enableHover:I,tooltipContent:!1===w?()=>null:kn(w)||void 0,customHoverBehavior:M||j||S?G.customHoverBehavior:void 0,customClickBehavior:j||S?G.customClickBehavior:void 0},T&&"none"!==T&&{legendHoverBehavior:G.legendState.onLegendHover,legendClickBehavior:G.legendState.onLegendClick,legendHighlightedCategory:G.legendState.highlightedCategory,legendIsolatedCategories:G.legendState.isolatedCategories},{className:c,title:F,description:$,summary:W,accessibleTable:z},null!=o.animate&&{animate:o.animate},A))})});Fc.displayName="ChordDiagram";const $c=t.forwardRef(function(o,n){const i=t.useRef(null);_r(n,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,o,n;return null!==(n=null===(o=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==n?n:[]}}});const r=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:800,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:g="id",colorBy:f,colorScheme:p,edgeColorBy:y="source",orientation:m="horizontal",nodeAlign:v="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:k,edgeOpacity:w=.5,edgeSort:A,tooltip:j,frameProps:S={},onObservation:C,onClick:O,chartId:M,selection:P,linkedHover:_,loading:L,loadingContent:T,emptyContent:R,showLegend:B,legendPosition:N,legendInteraction:D,stroke:E,strokeWidth:I,opacity:H}=o,{width:F,height:$,enableHover:W,showLabels:z=!0,title:G,description:Y,summary:q,accessibleTable:X}=r,V=Ic({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:p,showLegend:B,legendPosition:N,legendInteraction:D,selection:P,linkedHover:_,onObservation:C,onClick:O,chartType:"SankeyDiagram",chartId:M,marginDefaults:r.marginDefaults,userMargin:l,width:F,height:$,loading:L,loadingContent:T,emptyContent:R}),U=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?ke(e.data||e,f,V.colorScale):qi(void 0,V.themeCategorical,p,void 0,U),t},[f,V.colorScale,V.themeCategorical,p,U]),Q=t.useMemo(()=>Mr(K,{stroke:E,strokeWidth:I,opacity:H}),[K,E,I,H]),Z=t.useMemo(()=>Ec({edgeColorBy:y,colorBy:f,colorScale:V.colorScale,nodeStyleFn:Q,edgeOpacity:w,baseStyle:{stroke:"none",strokeWidth:0}}),[y,f,V.colorScale,Q,w]),J=t.useMemo(()=>Mr(Z,{stroke:E,strokeWidth:I,opacity:H}),[Z,E,I,H]),ee=t.useMemo(()=>{if(!z)return;const e=k||g;return"function"==typeof e?e:t=>{var o,n,i;return null!==(i=null!==(n=null===(o=t.data)||void 0===o?void 0:o[e])&&void 0!==n?n:t[e])&&void 0!==i?i:t.id}},[z,k,g]),te=Sr({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return te?e.jsx(cr,{componentName:"SankeyDiagram",message:te,width:F,height:$}):V.loadingEl?V.loadingEl:V.emptyEl?V.emptyEl:e.jsx(gr,{componentName:"SankeyDiagram",width:F,height:$,children:e.jsx(Rc,Object.assign({ref:i,chartType:"sankey"},V.safeNodes.length>0&&{nodes:V.safeNodes},null!=a&&{edges:V.safeEdges},{size:[F,$],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:V.margin,nodeIDAccessor:g,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:m,nodeAlign:v,nodePaddingRatio:b,nodeWidth:x,nodeStyle:Q,edgeStyle:J,colorBy:f,colorScheme:V.effectivePalette,edgeColorBy:y,edgeOpacity:w,edgeSort:A,nodeLabel:ee,showLabels:z,enableHover:W,tooltipContent:!1===j?()=>null:kn(j)||void 0,customHoverBehavior:_||C||O?V.customHoverBehavior:void 0,customClickBehavior:C||O?V.customClickBehavior:void 0,legend:V.legend,legendPosition:V.legendPosition},D&&"none"!==D&&{legendHoverBehavior:V.legendState.onLegendHover,legendClickBehavior:V.legendState.onLegendClick,legendHighlightedCategory:V.legendState.highlightedCategory,legendIsolatedCategories:V.legendState.isolatedCategories},{className:c,title:G,description:Y,summary:q,accessibleTable:X},null!=o.animate&&{animate:o.animate},S))})});function Wc(e,t,o){const n=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of n)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:o.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:o.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>{var o,n;return e.time-t.time||(null!==(o=s[e.kind])&&void 0!==o?o:99)-(null!==(n=s[t.kind])&&void 0!==n?n:99)})},l=r.length?Math.min(...r.map(e=>e.time)):null,c=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[0])?e.xExtent[0]:null,u=null!=c?c-1:null!=l&&Number.isFinite(l)?l-1:null,d=[...new Set(r.map(e=>e.time))].sort((e,t)=>e-t),h=new Map;for(let e=1;d.length>e;e++)h.set(d[e],d[e-1]);const g=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const f=[];let p=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let o=t-("top"===e.side?p:y);if(o>0){const t="top"===e.side?"bot":"top",n=Math.min(o,"top"===t?p:y);if(n>0){const i=g(e.time);f.push({time:i,delta:-n,kind:"transfer-out",side:t}),f.push({time:i,delta:+n,kind:"transfer-in",side:e.side}),"top"===t?p-=n:y-=n,"top"===e.side?p+=n:y+=n,o-=n}o>0&&null!==u&&(f.push({time:u,delta:+o,kind:"create",side:e.side}),"top"===e.side?p+=o:y+=o)}"top"===e.side?p-=t:y-=t}else if("in"===e.kind){const t=Math.abs(e.delta);"top"===e.side?p+=t:y+=t}r.push(...f),a();let m=0,v=0,b=0,x=0,k=0;const w=[],A=new Map;for(const e of r){if(w.push({t:e.time,topMass:m,botMass:v}),("in"===e.kind||"out"===e.kind)&&e.edge){const t="top"===e.side?m:v;A.set(e.edge.id,{side:e.side,time:e.time,sideMassBefore:t,sideMassAfter:t+e.delta,kind:e.kind,value:Math.abs(e.delta)})}"top"===e.side?m+=e.delta:v+=e.delta,m+v>b&&(b=m+v),m>x&&(x=m),v>k&&(k=v),w.push({t:e.time,topMass:m,botMass:v})}const j=[];let S=0;for(;w.length>S;){let e=S;for(;w.length>e+1&&w[e+1].t===w[S].t;)e++;j.push(w[S]);for(let t=S+1;e>=t;t++){const e=j[j.length-1];w[t].topMass===e.topMass&&w[t].botMass===e.botMass||j.push(w[t])}S=e+1}const C=Array.isArray(e.xExtent)&&Number.isFinite(e.xExtent[1])?e.xExtent[1]:null;let O=null;for(const e of i)null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&e.startTime>e.systemInTime&&(null===O||O>e.systemInTime)&&(O=e.systemInTime);let M=null;for(const e of n)null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>e.endTime&&(null===M||e.systemOutTime>M)&&(M=e.systemOutTime);if(j.length>0){const e=j[j.length-1],t=Math.max(null!=C?C:-1/0,null!=M?M:-1/0);Number.isFinite(t)&&t>e.t&&e.topMass+e.botMass>0&&j.push({t:t,topMass:e.topMass,botMass:e.botMass});const o=j[0],n=Math.min(null!=c?c:1/0,null!=O?O:1/0);Number.isFinite(n)&&o.t>n&&o.topMass+o.botMass>0&&j.unshift({t:n,topMass:o.topMass,botMass:o.botMass})}return{samples:j,peak:b,topPeak:x,botPeak:k,localAttachments:A}}function zc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Gc(e,t){return e.map(e=>({t:zc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Yc(e,t,o){const n=e.value*o;if("out"===e.kind){const i=e.sideMassBefore*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}const i=e.sideMassAfter*o;if("top"===e.side){const e=t-i;return[e,e+n]}const r=t+i;return[r-n,r]}function qc(e,t){let o=0;for(let n=0;t.length>n;n++)for(let i=n+1;t.length>i;i++){const r=t[n],s=t[i];r.source!==s.source&&r.target!==s.target&&r.source!==s.target&&r.target!==s.source&&(Math.min(r.endTime,s.endTime)>Math.max(r.startTime,s.startTime)&&e[s.source]>e[r.source]!=e[s.target]>e[r.target]&&o++)}return o}function Xc(e,t){let o=0;for(const n of t)o+=Math.abs(e[n.source]-e[n.target])*(n.value||1);return o}function Vc(e,t){return 1e3*qc(e,t)+Xc(e,t)}function Uc(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function Kc(e,t,o){e.length>8||o.length>40?(function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=Uc(e,t),s=Vc(t,o);for(let a=0;n>a;a++){const n=Array(i).fill(0),a=Array(i).fill(0);for(const e of o){const o=t[e.source],i=t[e.target];n[o]+=i*(e.value||1),a[o]+=e.value||1,n[i]+=o*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?n[e]/a[e]:e)-(a[t]>0?n[t]/a[t]:t)),c=l.map(t=>e[t]),u=new Map;l.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t);const d=Vc(t,o);if(s>d)s=d,r=Uc(e,t);else if(d===s)break}!function(e,t,o){e.length=0;for(const t of o.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(o.map))t[e]=o.map[e]}(e,t,r)}(e,t,o,6),function(e,t,o,n=6){const i=e.length;if(1>=i)return;let r=Vc(t,o);for(let s=0;n>s;s++){let n=!1;for(let s=0;i-1>s;s++){const i=e[s];e[s]=e[s+1],e[s+1]=i;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s);const a=Vc(t,o);if(r>a)r=a,n=!0;else{const o=e[s];e[s]=e[s+1],e[s+1]=o;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!n)break}}(e,t,o,6)):function(e,t,o){const n=e.length;if(1>=n)return;const i=Object.assign({},t),r=Object.keys(i),s=Array.from({length:n},(e,t)=>t),a=s.slice(),l=Object.assign({},i);let c=s.slice(),u=1/0;const d=()=>{for(const e of r)l[e]=a[i[e]];const e=Vc(l,o);u>e&&(u=e,c=s.slice())},h=(e,t)=>{const o=s[e],n=s[t];s[e]=n,s[t]=o,a[o]=t,a[n]=e};d();const g=Array(n).fill(0);let f=0;for(;n>f;)f>g[f]?(h(f%2==0?0:g[f],f),d(),g[f]++,f=0):(g[f]=0,f++);const p=c.map(t=>e[t]),y=new Map;c.forEach((e,t)=>y.set(e,t));for(const e of Object.keys(t))t[e]=y.get(t[e]);e.length=0;for(const t of p)e.push(t)}(e,t,o)}function Qc(e,t,o,n,i){var r,s,a,l,c,u,d,h;const{plotH:g,padding:f,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=i,b={},x={};for(const t of e)b[t.id]=o[t.id].topPeak||0,x[t.id]=o[t.id].botPeak||0;const k="half"===v,w={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,o=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=o&&Number.isFinite(o)?o:-1/0;for(const e of n.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=k?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of n.incoming[t.id]){const t=k?(e.startTime+e.endTime)/2:e.startTime;i>t&&(i=t),e.endTime>r&&(r=e.endTime),null!=e.systemOutTime&&Number.isFinite(e.systemOutTime)&&e.systemOutTime>r&&(r=e.systemOutTime)}w[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},j=[];if("reuse"===y){const o=new Map;for(const t of e)o.set(t.id,0);const i=new Map;for(const t of e)i.set(t.id,0);for(const e of t)i.set(e.target,(null!==(r=i.get(e.target))&&void 0!==r?r:0)+1);const d=[];for(const t of e)0===(null!==(s=i.get(t.id))&&void 0!==s?s:0)&&d.push(t.id);for(;d.length;){const e=d.shift();for(const t of null!==(a=n.outgoing[e])&&void 0!==a?a:[]){const n=(null!==(l=o.get(e))&&void 0!==l?l:0)+1;n>(null!==(c=o.get(t.target))&&void 0!==c?c:0)&&o.set(t.target,n),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&d.push(t.target)}}const h=[...e].filter(e=>null!==w[e.id].start).sort((e,t)=>{var n,i;const r=null!==(n=o.get(e.id))&&void 0!==n?n:0,s=null!==(i=o.get(t.id))&&void 0!==i?i:0;return r!==s?r-s:w[e.id].start-w[t.id].start}),g=e.filter(e=>null===w[e.id].start);for(const e of[...h,...g]){const t=w[e.id];let o=-1;for(let e=0;j.length>e;e++){const n=j[e].occupants[j[e].occupants.length-1];if(null===t.start||void 0===n||t.start>=n.end){o=e;break}}-1===o&&(j.push({occupants:[],peak:{topPeak:0,botPeak:0}}),o=j.length-1),j[o].occupants.push({id:e.id,end:null!==(u=null==t?void 0:t.end)&&void 0!==u?u:-1/0}),j[o].peak.topPeak=Math.max(j[o].peak.topPeak,b[e.id]),j[o].peak.botPeak=Math.max(j[o].peak.botPeak,x[e.id]),A[e.id]=o}}else e.forEach((e,t)=>{var o,n;j.push({occupants:[{id:e.id,end:null!==(n=null===(o=w[e.id])||void 0===o?void 0:o.end)&&void 0!==n?n:-1/0}],peak:{topPeak:b[e.id],botPeak:x[e.id]}}),A[e.id]=t});let S=null,C=null,O=null,M=null;const P=()=>{S=qc(A,t),O=Xc(A,t)},_=()=>{C=qc(A,t),M=Xc(A,t)};"crossing-min"===m?(P(),Kc(j,A,t),_()):"inside-out"===m?(P(),function(e,t){const o=e.length;if(1>=o)return;const n=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>n(t.slot)-n(e.slot)),r=Array(o),s=Math.floor((o-1)/2);r[s]=i[0].idx;let a=s-1,l=s+1;for(let e=1;i.length>e;e++)e%2==1&&o>l||0>a?r[l++]=i[e].idx:r[a--]=i[e].idx;const c=r.map(t=>e[t]),u=new Map;r.forEach((e,t)=>u.set(e,t));for(const e of Object.keys(t))t[e]=u.get(t[e]);e.length=0;for(const t of c)e.push(t)}(j,A),_()):"crossing-min+inside-out"===m&&(P(),Kc(j,A,t),function(e,t,o){const n=e.length;if(1>=n)return;const i=e.map(e=>{return{slot:e,size:(t=e,t.peak.topPeak+t.peak.botPeak)};var t}).sort((e,t)=>t.size-e.size),r=Math.floor((n-1)/2);let s=Vc(t,o);for(const{slot:a}of i){const i=e.indexOf(a);if(0>i)continue;const l=r;if(i===l)continue;const c=e[i];e.splice(i,1),e.splice(l,0,c);const u=new Map;for(let e=0;n>e;e++)u.set(e,e);if(l>i){for(let e=i+1;l>=e;e++)u.set(e,e-1);u.set(i,l)}else{for(let e=l;i>e;e++)u.set(e,e+1);u.set(i,l)}for(const e of Object.keys(t))t[e]=u.get(t[e]);const d=Vc(t,o);if(d>s){const o=e[l];e.splice(l,1),e.splice(i,0,o);const r=new Map;for(let e=0;n>e;e++)r.set(e,e);if(i>l){for(let e=l+1;i>=e;e++)r.set(e,e-1);r.set(l,i)}else{for(let e=i;l>e;e++)r.set(e,e+1);r.set(l,i)}for(const e of Object.keys(t))t[e]=r.get(t[e])}else s=d}}(j,A,t),_());const L=j.map(e=>{const t=new Map;for(const n of e.occupants){const e=o[n.id];if(e)for(const o of e.samples){const e=t.get(o.t)||{top:0,bot:0};t.set(o.t,{top:Math.max(e.top,o.topMass),bot:Math.max(e.bot,o.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let o={top:0,bot:0};for(const[n,i]of e){if(n>t)break;o=i}return o},R=[];for(let e=0;j.length-1>e;e++){const t=L[e],o=L[e+1],n=new Set([...t.map(e=>e[0]),...o.map(e=>e[0])]);let i=0;for(const e of n){const n=T(t,e),r=T(o,e);n.bot+r.top>i&&(i=n.bot+r.top)}R.push(i)}const B=[];let N=f+(null!==(h=null===(d=j[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;j.length>0&&B.push(N);for(let e=1;j.length>e;e++)N+=R[e-1]*p+f,B.push(N);if(j.length>0&&(N+=j[j.length-1].peak.botPeak*p+f),N>g){const e=g/N;for(let t=0;B.length>t;t++)B[t]*=e}const D=0===j.length?0:j[0].peak.topPeak+R.reduce((e,t)=>e+t,0)+j[j.length-1].peak.botPeak,E={};for(const t of e)E[t.id]=B[A[t.id]];return{effectiveSlotsHeight:D,centerlines:E,laneLifetime:w,slots:j,slotByNode:A,slotCenter:B,crossingsBefore:S,crossingsAfter:C,lengthBefore:O,lengthAfter:M}}$c.displayName="SankeyDiagram";const Zc=e=>{var t,o;const{bands:n=[],ribbons:i=[],showLabels:r=!0}=e.config,s=[];for(const e of i)s.push(Object.assign(Object.assign({type:"bezier",pathD:e.pathD},e.bezier&&{bezierCache:e.bezier}),{style:{fill:e.fill,opacity:e.opacity,stroke:"none"},datum:{__kind:"ribbon",data:e.rawDatum,id:e.id}}));for(const e of n)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const o=e.gradientStubs[t];s.push({type:"bezier",pathD:o.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:o.x0,x1:o.x1,from:o.from,to:o.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of n)s.push({type:"bezier",pathD:e.pathD,style:Object.assign(Object.assign({},e.gradientStubs&&e.gradientStubs.length>0?{fill:"none"}:{fill:e.fill,fillOpacity:.86}),{stroke:null!==(t=e.stroke)&&void 0!==t?t:e.fill,strokeWidth:null!==(o=e.strokeWidth)&&void 0!==o?o:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const a=r?n.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:n.map(e=>({type:"circle",id:e.id,cx:-1e4,cy:-1e4,r:0,style:{fill:e.fill},datum:{__kind:"band",data:e.rawDatum,id:e.id}})),sceneEdges:s,labels:a}};function Jc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function eu(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function tu(e,t){return"function"==typeof e?e(t):t[e]}const ou=t.forwardRef(function(o,n){const{nodes:r,edges:s,domain:a,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",startTimeAccessor:g="startTime",endTimeAccessor:f="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:y,xExtentAccessor:m="xExtent",edgeIdAccessor:b="id",colorBy:x,colorScheme:k,showLegend:w,legendPosition:A="right",pairing:j="temporal",packing:S="reuse",laneOrder:C="crossing-min",ribbonLane:O="both",lifetimeMode:M="half",showLaneRails:P=!1,showQualityReadout:_=!1,showLabels:L=!0,width:T=600,height:R=400,margin:B,title:N,description:D,summary:E,accessibleTable:I,responsiveWidth:H,responsiveHeight:F,loading:$,loadingContent:W,emptyContent:z,edgeOpacity:G=.35,timeFormat:Y,valueFormat:q,tooltip:X,enableHover:V=!0,onObservation:U,onClick:K,showParticles:Q=!1,particleStyle:Z,chartId:J,frameProps:ee={}}=o,[te,oe]=t.useState([]),[ne,ie]=t.useState([]),re=t.useRef(te),se=t.useRef(ne);re.current=te,se.current=ne;const ae=t.useCallback(e=>{re.current=e,oe(e)},[]),le=t.useCallback(e=>{se.current=e,ie(e)},[]),ce=void 0!==s,ue=v(ce?s:te),de=t.useMemo(()=>{const e=v(null!=r?r:[]),t=ne;if(0===e.length&&0===t.length)return Nc([],ue,u,d);const o=new Set,n=[];for(const t of e){const e=tu(c,t)+"";o.has(e)||(o.add(e),n.push(t))}for(const e of t){const t=tu(c,e)+"";o.has(t)||(o.add(t),n.push(e))}const i=Nc([],ue,u,d);for(const e of i)o.has(e.id)||(o.add(e.id),n.push(e));return n},[r,ne,ue,c,u,d]),he=t.useRef(null),ge=t.useCallback((e,t)=>{const o=tu(b,e);return null!=o?o+"":`${tu(u,e)}-${tu(d,e)}-${t}`},[b,u,d]),fe=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=tu(u,t)&&null!=tu(d,t)},[u,d]);_r(n,{variant:"network",frameRef:he,overrides:{push(e){if(fe(e)){if(ce)return void console.warn("ProcessSankey.push: edge ignored — `edges` prop is controlled.");ae([...re.current,e])}else le([...se.current,e])},pushMany(e){const t=[],o=[];for(const n of e)fe(n)?t.push(n):o.push(n);t.length>0&&(ce?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ae([...re.current,...t])),o.length>0&&le([...se.current,...o])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),o=[];if(!ce){const e=re.current,n=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(ge(r,i))?o.push(r):n.push(r)}n.length!==e.length&&ae(n)}const n=se.current,i=[];for(const e of n){const n=tu(c,e)+"";t.has(n)?o.push(e):i.push(e)}return i.length!==n.length&&le(i),o},update(e,t){const o=new Set(Array.isArray(e)?e:[e]),n=[];if(!ce){let e=!1;const i=re.current.map((i,r)=>o.has(ge(i,r))?(n.push(i),e=!0,t(i)):i);e&&ae(i)}let i=!1;const r=se.current.map(e=>{const r=tu(c,e)+"";return o.has(r)?(n.push(e),i=!0,t(e)):e});return i&&le(r),n},clear(){var e;ce||ae([]),le([]),null===(e=he.current)||void 0===e||e.clear()},getData:()=>null!=ue?ue:[],getScales:()=>null},deps:[ce,fe,ge,c,ue,ae,le]});const pe=ge,ye=t.useCallback(e=>tu(c,e)+"",[c]),{nodes:me,edges:ve,domain:be,rawNodeById:xe,rawEdgeById:we}=t.useMemo(()=>{const e=(null!=de?de:[]).map(e=>{const t={id:ye(e),__raw:e},o=m?tu(m,e):null;if(Array.isArray(o)&&2===o.length){const e=eu(o[0]),n=eu(o[1]);Number.isFinite(e)&&Number.isFinite(n)&&(t.xExtent=[e,n])}return t}),t=(null!=ue?ue:[]).map((e,t)=>{const o={id:pe(e,t),source:tu(u,e)+"",target:tu(d,e)+"",value:Number(tu(h,e)),startTime:eu(tu(g,e)),endTime:eu(tu(f,e)),__raw:e};if(p){const t=eu(tu(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(y){const t=eu(tu(y,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[eu(a[0]),eu(a[1])],n=new Map;for(const t of e)null!=t.__raw&&n.set(t.id,t.__raw);const i=new Map;for(const e of t)null!=e.__raw&&i.set(e.id,e.__raw);return{nodes:e,edges:t,domain:o,rawNodeById:n,rawEdgeById:i}},[de,ue,a,ye,pe,m,u,d,h,g,f,p,y]),Ae=Ic({nodes:de,edges:ue,inferNodes:!1,sourceAccessor:u,targetAccessor:d,colorBy:x,colorScheme:k,showLegend:!1,legendPosition:A,selection:void 0,linkedHover:void 0,onObservation:U,onClick:K,chartType:"ProcessSankey",chartId:J,marginDefaults:{top:30,right:80,bottom:40,left:80},userMargin:B,width:T,height:R,loading:$,loadingContent:W,emptyContent:z}),je=(null!=w?w:!!x)&&!!x,Se=t.useCallback(e=>null!=B&&("number"==typeof B||null!=B[e]),[B]),Ce=t.useMemo(()=>{const e=Object.assign({},Ae.margin);return je&&("right"===A&&!Se("right")&&140>e.right?e.right=140:"bottom"===A&&!Se("bottom")&&80>e.bottom&&(e.bottom=80)),e},[Ae.margin,je,A,Se]),Oe=T-Ce.left-Ce.right,Me=R-Ce.top-Ce.bottom,Pe=t.useMemo(()=>function(e,t,o){const n=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(o)&&2===o.length,s=r&&Number.isFinite(o[0])&&Number.isFinite(o[1]);r&&s&&s&&o[1]>=o[0]||n.push({kind:"invalid-domain"});for(const t of e)null!=t.xExtent&&(Array.isArray(t.xExtent)&&2===t.xExtent.length&&Number.isFinite(t.xExtent[0])&&Number.isFinite(t.xExtent[1])&&t.xExtent[1]>=t.xExtent[0]||n.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||n.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||n.push({kind:"missing-node",id:e.id,endpoint:"target",nodeId:e.target}),Number.isFinite(e.startTime)&&Number.isFinite(e.endTime)?(Number.isFinite(e.value)&&e.value>0||n.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||n.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):n.push({kind:"invalid-edge-time",id:e.id});return n}(me,ve,be),[me,ve,be]),_e=t.useMemo(()=>Pe.length>0?null:function(e,t,o){var n;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=o,c=function(e,t){const o={},n={};for(const t of e)o[t.id]=[],n[t.id]=[];for(const e of t)n[e.source]&&n[e.source].push(e),o[e.target]&&o[e.target].push(e);return{incoming:o,outgoing:n}}(e,t),u=function(e,t,o,n="value"){const i="temporal"===n?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===n?(e,t)=>e.startTime-t.startTime:(e,t)=>t.value-e.value,s=new Map;for(const e of t)s.set(e.id,{});const a=(e,t)=>{const o=new Map;for(const n of e){const e=n[t];o.has(e)||o.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=o.get(e);i.edges.push(n),i.total+=n.value,i.earliestStart=Math.min(i.earliestStart,n.startTime),i.latestEnd=Math.max(i.latestEnd,n.endTime)}const s=[...o.values()];s.sort("temporal"===n?(e,o)=>"target"===t?e.earliestStart-o.earliestStart:e.latestEnd-o.latestEnd:(e,t)=>t.total-e.total);for(const e of s)e.edges.sort("target"===t?r:i);return s};for(const t of e){const e=o.outgoing[t.id],n=o.incoming[t.id];if(0===n.length)a(e,"target").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=o});else if(0===e.length)a(n,"source").forEach((e,t)=>{const o=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=o});else{const t=a(n,"source"),o=a(e,"target"),i=Math.max(t.length,o.length);for(let e=0;i>e;e++){const n=e%2==0?"top":"bot";if(t[e])for(const o of t[e].edges)s.get(o.id).targetSide=n;if(o[e])for(const t of o[e].edges)s.get(t.id).sourceSide=n}}}return s}(e,t,c,r);let d={};for(const t of e)d[t.id]=Wc(t,c,u);const h=Qc(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),g=new Set;for(const e of t){const t=h.slotByNode[e.source],o=h.slotByNode[e.target];if(void 0===t||void 0===o)continue;const n=u.get(e.id);t!==o?t>o?(n.sourceSide="top",n.targetSide="bot"):(n.sourceSide="bot",n.targetSide="top"):(g.add(e.id),n.sourceSide="bot",n.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],o=c.incoming[t.id],n=new Set(e.map(e=>u.get(e.id).sourceSide)),i=new Set(o.map(e=>u.get(e.id).targetSide));if(1===n.size&&o.length>0){const e=[...n][0];for(const t of o)h.slotByNode[t.source]===h.slotByNode[t.target]&&(u.get(t.id).targetSide=e)}if(1===i.size&&e.length>0){const t=[...i][0];for(const o of e)h.slotByNode[o.source]===h.slotByNode[o.target]&&(u.get(o.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],o=c.outgoing[t.id];if(0===e.length||0===o.length)continue;const n=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const o of e)"top"===u.get(o.id).targetSide?t.inTop+=o.value:t.inBot+=o.value;for(const e of o)"top"===u.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=n(),r="top"===e?i.outTop-i.inTop:i.outBot-i.inBot,s="top"===t?i.inTop-i.outTop:i.inBot-i.outBot;if(0>=r||0>=s)return!1;const a=Math.min(r,s),l=o.filter(t=>!g.has(t.id)&&u.get(t.id).sourceSide===e&&a>=t.value).sort((e,t)=>t.value-e.value);return 0!==l.length&&(u.get(l[0].id).sourceSide=t,!0)};let r=o.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=Wc(t,c,u);const f=Qc(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(n=f.effectiveSlotsHeight)&&void 0!==n?n:f.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(f.slots.length+1,1)),m=p>0?Math.max(0,(i-y*(f.slots.length+1))/p):1,v=Qc(e,t,d,c,{plotH:i,padding:y,valueScale:m,packing:s,laneOrder:a,lifetimeMode:l});return{nodeData:d,sides:u,valueScale:m,padding:y,compressedPadding:12>y,centerlines:v.centerlines,laneLifetime:v.laneLifetime,slots:v.slots,slotByNode:v.slotByNode,crossingsBefore:v.crossingsBefore,crossingsAfter:v.crossingsAfter,lengthBefore:v.lengthBefore,lengthAfter:v.lengthAfter}}(me,ve,{plotH:Me,pairing:j,packing:S,laneOrder:C,lifetimeMode:M}),[Pe,me,ve,Me,j,S,C,M]),Le=t.useMemo(()=>i.scaleTime().domain(be).range([0,Oe]),[be,Oe]),Te=t.useCallback((e,t)=>{if(x&&de){const t=xe.get(e);if(t)return ke(t,x,Ae.colorScale)}return Ae.effectivePalette[t%Ae.effectivePalette.length]||"#475569"},[x,de,xe,Ae.colorScale,Ae.effectivePalette]),Re=t.useMemo(()=>{const e=new Map;return me.forEach((t,o)=>e.set(t.id,o)),e},[me]),Be=t.useMemo(()=>{if(!_e)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:o}=_e,n=[],i=[];return me.forEach((i,r)=>{var s;const a=t[i.id];if(!a||0===a.samples.length)return;const l=function(e,t,o,n,i){if(0===e.length)return null;const r=Gc(e,i),s=e=>t-r[e].topMass*o,a=e=>t+r[e].botMass*o;let l=`M${n(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${n(r[e].t)},${s(e)}`;l+=` L${n(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${n(r[e].t)},${a(e)}`;return l+" Z"}(a.samples,e[i.id],o,Le,be);if(!l)return;const c=Gc(a.samples,be),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=e[i.id]+(u.botMass-u.topMass)*o/2,h=Te(i.id,r),g=null!==(s=xe.get(i.id))&&void 0!==s?s:i,f=function(e,t,o,n,i){const r=o.nodeData[e];if(!r||0===r.samples.length)return[];const s=o.valueScale,a=o.centerlines[e],l=Gc(r.samples,i),c=l.find(e=>e.topMass+e.botMass>0)||l[0],u=[...l].reverse().find(e=>e.topMass+e.botMass>0)||l[l.length-1],d=n(c.t),h=n(u.t),g=e=>n(zc(e,i)),f=[],p=(e,t,o,n)=>`M${e},${t} L${o},${t} L${o},${n} L${e},${n} Z`;for(const o of t){if(o.source===e&&null!=o.systemInTime&&Number.isFinite(o.systemInTime)){const e=r.localAttachments.get(o.id);if(e&&"out"===e.kind&&o.startTime>o.systemInTime){const t=g(o.systemInTime),n=g(o.startTime),i=t-20,r=Math.max(d,i);if(n>r){const[o,l]=Yc(e,a,s);f.push({pathD:p(r,o,n,l),x0:i,x1:t,from:0,to:1})}}}if(o.target===e&&null!=o.systemOutTime&&Number.isFinite(o.systemOutTime)){const e=r.localAttachments.get(o.id);if(e&&"in"===e.kind&&o.systemOutTime>o.endTime){const t=g(o.systemOutTime),n=g(o.endTime),i=t+20,r=Math.min(h,i);if(r>n){const[o,l]=Yc(e,a,s);f.push({pathD:p(n,o,r,l),x0:t,x1:i,from:1,to:0})}}}}return f}(i.id,ve,_e,Le,be);n.push(Object.assign(Object.assign({id:i.id,pathD:l,fill:h,stroke:h,strokeWidth:.5},f.length>0&&{gradientStubs:f}),{rawDatum:g,labelX:Le(u.t)-4,labelY:d,labelText:i.id}))}),ve.forEach(n=>{var r,s,a,l;const c=null===(r=t[n.source])||void 0===r?void 0:r.localAttachments.get(n.id),u=null===(s=t[n.target])||void 0===s?void 0:s.localAttachments.get(n.id);if(!c||!u)return;const d=null!==(a=Re.get(n.source))&&void 0!==a?a:0,h=Te(n.source,d),g=function(e,t,o,n,i,r,s,a){const l=i,c=e=>a?Math.max(a[0],Math.min(a[1],e)):e,u=r(c(e.time)),d=r(c(o.time)),h=e.value*l,g=o.value*l,f=e.sideMassBefore*l,p=o.sideMassAfter*l;let y,m,v,b;"top"===e.side?(y=t-f,m=y+h):(m=t+f,y=m-h),"top"===o.side?(v=n-p,b=v+g):(b=n+p,v=b-g);const x="source"===s?u+.85*(d-u):"target"===s?u+.15*(d-u):(u+d)/2;return{sx:u,sTop:y,sBot:m,tx:d,tTop:v,tBot:b,cp1X:x,cp2X:x}}(c,e[n.source],u,e[n.target],o,Le,O,be),{pathD:f,bezier:p}=Rl(g),y=null!==(l=we.get(n.id))&&void 0!==l?l:n;i.push({id:n.id,pathD:f,fill:h,opacity:G,rawDatum:y,bezier:p})}),{bands:n,ribbons:i}},[_e,me,ve,Le,be,Te,xe,we,O,G,Re]),Ne=t.useMemo(()=>({bands:Be.bands,ribbons:Be.ribbons,showLabels:L}),[Be,L]),De=t.useMemo(()=>{if(!je||!x)return;const e=new Map;(null!=de?de:[]).forEach((t,o)=>{const n=tu(x,t),i=null==n?"":n+"";i&&!e.has(i)&&e.set(i,{label:i,color:Te(ye(t),o)})});const t=Array.from(e.values());return 0!==t.length?{legendGroups:[{type:"fill",label:"",items:t,styleFn:e=>{const t=e.color||"#333";return{fill:t,stroke:t}}}]}:void 0},[je,x,de,Te,ye]),Ee=t.useMemo(()=>!1!==X&&V?void 0===X||!0===X?null:kn(X)||null:null,[X,V]),Ie=t.useCallback(e=>Y?Y(new Date(e)):Number.isFinite(e)?1e10>Math.abs(e)?Number.isInteger(e)?e+"":e.toFixed(2):new Date(e).toISOString().slice(0,10):"",[Y]),He=t.useCallback(e=>q?q(e):e+"",[q]),Fe=t.useCallback(t=>{if(!t||!t.data)return null;const o=t.data;if(!Jc(o))return null;const n=o.data;if(Ee)return Ee(n);if("band"===o.__kind){const t=o.id,n=_e?function(e){if(!e)return[];const t=new Set,o=[];for(const n of e.samples){const e=n.topMass+n.botMass,i=`${n.t}:${e}`;t.has(i)||(t.add(i),o.push({t:n.t,total:e}))}return o}(_e.nodeData[t]):[],i=5,r=n.length>i?n.length:null,s=function(e,t=5){if(t>=e.length)return e.slice();const o=[...e].sort((e,t)=>e.total-t.total),n=o.length-1,i=[Object.assign(Object.assign({},o[0]),{mark:"min"}),Object.assign(Object.assign({},o[Math.floor(.25*n)]),{mark:"q25"}),Object.assign(Object.assign({},o[Math.floor(.5*n)]),{mark:"median"}),Object.assign(Object.assign({},o[Math.floor(.75*n)]),{mark:"q75"}),Object.assign(Object.assign({},o[n]),{mark:"max"})],r=new Set,s=[];for(const e of i)r.has(e.t)||(r.add(e.t),s.push(e));return s.sort((e,t)=>e.t-t.t)}(n,i);return e.jsxs("div",{style:{minWidth:160},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4},children:t}),s.length>0&&e.jsxs("table",{style:{borderCollapse:"collapse",fontSize:11,width:"100%"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{opacity:.6},children:[e.jsx("th",{style:{textAlign:"left",fontWeight:500,paddingRight:8},children:"Time"}),e.jsx("th",{style:{textAlign:"right",fontWeight:500},children:"Mass"}),null!=r&&e.jsx("th",{})]})}),e.jsx("tbody",{children:s.map((t,o)=>e.jsxs("tr",{children:[e.jsx("td",{style:{paddingRight:8},children:Ie(t.t)}),e.jsx("td",{style:{textAlign:"right"},children:He(t.total)}),null!=r&&e.jsx("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:t.mark})]},o))})]}),null!=r&&e.jsxs("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",s.length," of ",r," samples"]})]})}const i=n,r=tu(u,i),s=tu(d,i),a=tu(h,i),l=tu(g,i),c=tu(f,i);return e.jsxs("div",{style:{minWidth:160},children:[e.jsxs("div",{style:{fontWeight:600,marginBottom:4},children:[r+""," → ",s+""]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:8,fontSize:11},children:[null!=a&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"value"}),e.jsx("span",{style:{textAlign:"right"},children:He(Number(a))})]}),null!=l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"start"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(eu(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(eu(c))})]})]})]})},[_e,Ee,Ie,He,u,d,h,g,f]),$e=t.useMemo(()=>{if(!_e)return null;const{centerlines:t,laneLifetime:o,nodeData:n,valueScale:i,compressedPadding:r,crossingsBefore:s,crossingsAfter:a,lengthBefore:c,lengthAfter:u}=_e;let d=null,h=null;for(const e of me){const t=o[e.id];if(!t||null===t.start||null===t.end)continue;const n=Le(t.start),i=Le(t.end);(null===d||d>n)&&(d=n),(null===h||i>h)&&(h=i)}const g=e=>Math.max(0,Math.min(Oe,e)),f=g(null!=d?d:0),p=Math.max(f,g(null!=h?h:Oe));return e.jsxs("g",{children:[_&&null!==(null!=a?a:null)&&e.jsxs("text",{x:Oe,y:-12,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:["crossings: ",s," → ",a," ","edge length: ",Math.round(c)," → ",Math.round(u)]}),r&&e.jsx("text",{x:Oe,y:2,fontSize:10,fill:"#94a3b8",textAnchor:"end",children:"dense layout: lane gaps compressed"}),l.map((t,o)=>{const n=Le(eu(t.date));return f-.5>n||n>p+.5?null:e.jsx("line",{x1:n,y1:0,x2:n,y2:Me,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+o)}),P&&me.map((r,s)=>{const a=o[r.id];if(!a||null===a.start)return null;const l=n[r.id],c=l?{topPeak:l.topPeak,botPeak:l.botPeak}:{topPeak:0,botPeak:0},u=t[r.id]+(c.botPeak-c.topPeak)*i/2,d=Le(a.start),h=Le(a.end),g=Te(r.id,s);return e.jsxs("g",{children:[e.jsx("line",{x1:d,y1:u,x2:h,y2:u,stroke:g,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e.jsx("line",{x1:d,y1:u-4,x2:d,y2:u+4,stroke:g,strokeOpacity:.5}),e.jsx("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:g,strokeOpacity:.5})]},"lane-"+r.id)}),e.jsx("line",{x1:f,y1:Me+4,x2:p,y2:Me+4,stroke:"#94a3b8"}),l.map((t,o)=>{const n=eu(t.date),i=Le(n);if(f-.5>i||i>p+.5)return null;const r=null!=t.label?t.label:Y?Y(new Date(n)):"";return e.jsxs("g",{transform:`translate(${i},${Me+4})`,children:[e.jsx("line",{y2:6,stroke:"#94a3b8"}),e.jsx("text",{y:20,textAnchor:"middle",fontSize:11,fill:"#475569",children:r})]},o)})]})},[_e,l,Le,Oe,Me,P,me,Te,_,Y]),We=t.useMemo(()=>(null!=de?de:[]).map(e=>({id:ye(e),data:e})),[de,ye]),ze=t.useMemo(()=>{const e=new Map;for(const t of Be.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Be]),Ge=t.useMemo(()=>(null!=ue?ue:[]).map((e,t)=>{const o=pe(e,t),n=Number(tu(h,e));return{id:o,source:tu(u,e)+"",target:tu(d,e)+"",value:Number.isFinite(n)?n:0,bezier:ze.get(o),data:e}}),[ue,pe,u,d,h,ze]),Ye=Ae.loadingEl,qe=Ae.emptyEl;return Pe.length>0?e.jsxs("svg",{width:T,height:R,role:"img","aria-label":null!=N?N:"Process Sankey validation failed",children:[e.jsx("text",{x:20,y:30,fontSize:13,fontWeight:600,fill:"var(--semiotic-danger, #dc2626)",children:"ProcessSankey: data invalid"}),Pe.map((t,o)=>{return e.jsx("text",{x:20,y:56+18*o,fontSize:12,fill:"#64748b",children:"• "+(n=t,"invalid-node-time"===n.kind?`node ${n.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===n.kind?`edge ${n.id} has an invalid startTime or endTime`:"invalid-domain"===n.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===n.kind?`edge ${n.id} must have a positive finite value`:"missing-node"===n.kind?`edge ${n.id} references missing ${n.endpoint} node "${n.nodeId}"`:"backward-edge"===n.kind?`edge ${n.id} (${n.source}->${n.target}) ends before it starts`:n.kind)},o);var n})]}):Ye||qe||e.jsx(Rc,Object.assign({ref:he,chartType:"force",nodes:We,edges:Ge,customNetworkLayout:Zc,layoutConfig:Ne,size:[T,R],responsiveWidth:H,responsiveHeight:F,margin:Ce,title:N,description:null!=D?D:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:E,accessibleTable:I,enableHover:V,tooltipContent:!1===X?()=>null:Fe,backgroundGraphics:$e,showParticles:Q,particleStyle:Z,legend:De,legendPosition:A,onObservation:U,customClickBehavior:K?e=>{if(!e||!e.data)return;const t=e.data;Jc(t)&&K(t.data,{x:e.x,y:e.y})}:void 0,chartId:J,colorScheme:Array.isArray(k)?k:void 0},ee))});function nu(o){const n=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,layout:a="tree",orientation:l="vertical",childrenAccessor:c="children",valueAccessor:u="value",nodeIdAccessor:d="name",colorBy:h,colorScheme:g,colorByDepth:f=!1,edgeStyle:p="curve",nodeLabel:y,nodeSize:m=5,tooltip:v,frameProps:b={},onObservation:x,onClick:k,chartId:w,selection:A,linkedHover:j,loading:S,loadingContent:C,legendInteraction:O,stroke:M,strokeWidth:P,opacity:_}=o,{width:L,height:T,enableHover:R,showLabels:B=!0,title:N,description:D,summary:E,accessibleTable:I}=n,H=Ic({nodes:t.useMemo(()=>Bc(null!=i?i:null,c),[i,c]),edges:void 0,inferNodes:!1,colorBy:f?void 0:h,colorScheme:g,showLegend:!1,legendInteraction:O,selection:A,linkedHover:j,onObservation:x,onClick:k,chartType:"TreeDiagram",chartId:w,marginDefaults:n.marginDefaults,userMargin:r,width:L,height:T,loading:S,loadingContent:C}),F=t.useMemo(()=>new Map,[]),$=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=f?be[(e.depth||0)%be.length]:h?ke(e.data||e,h,H.colorScale):qi(void 0,H.themeCategorical,g,void 0,F),t},[h,f,H.colorScale,H.themeCategorical,g,F]),W=t.useMemo(()=>Mr($,{stroke:M,strokeWidth:P,opacity:_}),[$,M,P,_]),z=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),G=t.useMemo(()=>Mr(z,{stroke:M,strokeWidth:P,opacity:_}),[z,M,P,_]),Y=t.useMemo(()=>{if("treemap"===a||"circlepack"===a||"partition"===a)return Dc(u)},[a,u]),q=jr({componentName:"TreeDiagram",data:i});return q?e.jsx(cr,{componentName:"TreeDiagram",message:q,width:L,height:T}):H.loadingEl?H.loadingEl:e.jsx(gr,{componentName:"TreeDiagram",width:L,height:T,children:e.jsx(Rc,Object.assign({chartType:a},null!=i&&{data:i},{size:[L,T],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:H.margin,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:Y,treeOrientation:l,edgeType:p,nodeStyle:W,edgeStyle:G,colorBy:h,colorScheme:H.effectivePalette,colorByDepth:f,nodeSize:m,nodeLabel:B?y||d:void 0,showLabels:B,enableHover:R,tooltipContent:!1===v?()=>null:kn(v)||void 0,customHoverBehavior:j||x||k?H.customHoverBehavior:void 0,customClickBehavior:x||k?H.customClickBehavior:void 0},O&&"none"!==O&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:s,title:N,description:D,summary:E,accessibleTable:I},null!=o.animate&&{animate:o.animate},b))})}function iu(o){const n=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary,linkedHover:o.linkedHover},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,labelMode:g="leaf",nodeLabel:f,padding:p=4,paddingTop:y,nodeStyle:m,tooltip:v,frameProps:b={},selection:x,linkedHover:k,onObservation:w,onClick:A,chartId:j,loading:S,loadingContent:C,legendInteraction:O,stroke:M,strokeWidth:P,opacity:_}=o,{nodeStyle:L}=b,T=Lr(b,["nodeStyle"]),{width:R,height:B,enableHover:N,showLabels:D=!0,title:E,description:I,summary:H,accessibleTable:F}=n,$=Ic({nodes:t.useMemo(()=>Bc(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:O,selection:x,linkedHover:k,onObservation:w,onClick:A,chartType:"Treemap",chartId:j,marginDefaults:n.marginDefaults,userMargin:r,width:R,height:B,loading:S,loadingContent:C}),W=Cr(x),z=$.customHoverBehavior,G=t.useCallback(e=>{if(!e)return z(null);const t=e.data||e;z({data:(null==t?void 0:t.data)||t})},[z]),Y=t.useMemo(()=>new Map,[]),q=t.useMemo(()=>e=>{const t={stroke:"var(--semiotic-cell-border, var(--semiotic-border, #fff))",strokeWidth:1,strokeOpacity:.8};return t.fill=h?be[(e.depth||0)%be.length]:u?ke(e.data||e,u,$.colorScale):qi(void 0,$.themeCategorical,d,void 0,Y),t},[u,h,$.colorScale,$.themeCategorical,d,Y]),X=t.useMemo(()=>m||L?e=>{var t,o;return Object.assign(Object.assign(Object.assign({},q(e)),L&&null!==(t=L(e))&&void 0!==t?t:{}),m&&null!==(o=m(e))&&void 0!==o?o:{})}:q,[q,m,L]),V=t.useMemo(()=>Mr(X,{stroke:M,strokeWidth:P,opacity:_}),[X,M,P,_]),U=t.useMemo(()=>$.activeSelectionHook?e=>{var t;const o=Object.assign({},V(e));if($.activeSelectionHook.isActive)if($.activeSelectionHook.predicate(e.data||e))(null==W?void 0:W.selectedStyle)&&Object.assign(o,W.selectedStyle);else{const e=null!==(t=null==W?void 0:W.unselectedOpacity)&&void 0!==t?t:.5;o.opacity=e,o.fillOpacity=e,o.strokeOpacity=e,(null==W?void 0:W.unselectedStyle)&&Object.assign(o,W.unselectedStyle)}return o}:V,[V,$.activeSelectionHook,W]),K=t.useMemo(()=>Dc(l),[l]),Q=void 0!==y?y:!D||"parent"!==g&&"all"!==g?void 0:18,Z=jr({componentName:"Treemap",data:i});return Z?e.jsx(cr,{componentName:"Treemap",message:Z,width:R,height:B}):$.loadingEl?$.loadingEl:e.jsx(gr,{componentName:"Treemap",width:R,height:B,children:e.jsx(Rc,Object.assign({chartType:"treemap"},null!=i&&{data:i},{size:[R,B],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:$.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:K,padding:p,paddingTop:Q,nodeStyle:U,colorBy:u,colorScheme:$.effectivePalette,colorByDepth:h,nodeLabel:D?f||c:void 0,showLabels:D,labelMode:g,enableHover:N,tooltipContent:!1===v?()=>null:kn(v)||void 0},(k||w||A)&&{customHoverBehavior:G},(w||A)&&{customClickBehavior:$.customClickBehavior},O&&"none"!==O&&{legendHoverBehavior:$.legendState.onLegendHover,legendClickBehavior:$.legendState.onLegendClick,legendHighlightedCategory:$.legendState.highlightedCategory,legendIsolatedCategories:$.legendState.isolatedCategories},{className:s,title:E,description:I,summary:H,accessibleTable:F},null!=o.animate&&{animate:o.animate},T))})}function ru(o){const n=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",valueAccessor:l="value",nodeIdAccessor:c="name",colorBy:u,colorScheme:d,colorByDepth:h=!1,nodeLabel:g,circleOpacity:f=.7,padding:p=4,tooltip:y,frameProps:m={},onObservation:v,onClick:b,chartId:x,selection:k,linkedHover:w,loading:A,loadingContent:j,legendInteraction:S,stroke:C,strokeWidth:O,opacity:M}=o,{width:P,height:_,enableHover:L,showLabels:T=!0,title:R,description:B,summary:N,accessibleTable:D}=n,E=Ic({nodes:t.useMemo(()=>Bc(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:S,selection:k,linkedHover:w,onObservation:v,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:n.marginDefaults,userMargin:r,width:P,height:_,loading:A,loadingContent:j}),I=t.useMemo(()=>new Map,[]),H=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:f};return t.fill=h?be[(e.depth||0)%be.length]:u?ke(e.data||e,u,E.colorScale):qi(void 0,E.themeCategorical,d,void 0,I),t},[u,h,E.colorScale,f,E.themeCategorical,d,I]),F=t.useMemo(()=>Mr(H,{stroke:C,strokeWidth:O,opacity:M}),[H,C,O,M]),$=t.useMemo(()=>Dc(l),[l]),W=jr({componentName:"CirclePack",data:i});return W?e.jsx(cr,{componentName:"CirclePack",message:W,width:P,height:_}):E.loadingEl?E.loadingEl:e.jsx(gr,{componentName:"CirclePack",width:P,height:_,children:e.jsx(Rc,Object.assign({chartType:"circlepack"},null!=i&&{data:i},{size:[P,_],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:E.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:$,padding:p,nodeStyle:F,colorBy:u,colorScheme:E.effectivePalette,colorByDepth:h,nodeLabel:T?g||c:void 0,showLabels:T,enableHover:L,tooltipContent:!1===y?()=>null:kn(y)||void 0,customHoverBehavior:w||v||b?E.customHoverBehavior:void 0,customClickBehavior:v||b?E.customClickBehavior:void 0},S&&"none"!==S&&{legendHoverBehavior:E.legendState.onLegendHover,legendClickBehavior:E.legendState.onLegendClick,legendHighlightedCategory:E.legendState.highlightedCategory,legendIsolatedCategories:E.legendState.isolatedCategories},{className:s,title:R,description:B,summary:N,accessibleTable:D},null!=o.animate&&{animate:o.animate},m))})}ou.displayName="ProcessSankey",nu.displayName="TreeDiagram",iu.displayName="Treemap",ru.displayName="CirclePack";const su=be;function au(o){const n=er(o.mode,{width:o.width,height:o.height,enableHover:o.enableHover,showLabels:o.showLabels,title:o.title,description:o.description,accessibleTable:o.accessibleTable,summary:o.summary},{width:600,height:600}),{data:i,margin:r,className:s,childrenAccessor:a="children",nodeIdAccessor:l="name",colorBy:c,colorScheme:u,colorByDepth:d=!1,orbitMode:h="flat",orbitSize:g=2.95,speed:f=.25,revolution:p,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:k=!0,tooltip:w,foregroundGraphics:A,annotations:j,frameProps:S={},onObservation:C,onClick:O,chartId:M,selection:P,linkedHover:_,loading:L,loadingContent:T,stroke:R,strokeWidth:B,opacity:N}=o,{width:D,height:E,enableHover:I,title:H,description:F,summary:$,accessibleTable:W}=n,z=Ic({nodes:t.useMemo(()=>Bc(i,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:d?void 0:c,colorScheme:u,showLegend:!1,legendInteraction:void 0,selection:P,linkedHover:_,onObservation:C,onClick:O,chartType:"OrbitDiagram",chartId:M,marginDefaults:{top:10,right:10,bottom:10,left:10},userMargin:r,width:D,height:E,loading:L,loadingContent:T}),G=t.useMemo(()=>new Map,[]),Y=t.useMemo(()=>{if(Array.isArray(u))return u;const e=ye[u];return Array.isArray(e)?e:me},[u]),q=t.useMemo(()=>e=>{var t;const o={stroke:"#fff",strokeWidth:1},n=0===(null!==(t=e.depth)&&void 0!==t?t:0);return o.fill=d?n?Y[0]:su[(e.depth||0)%su.length]:c?ke(e.data||e,c,z.colorScale):qi(void 0,z.themeCategorical,u,void 0,G),o.opacity=n?1:.85,o},[c,d,z.colorScale,Y,z.themeCategorical,u,G]),X=t.useMemo(()=>Mr(q,{stroke:R,strokeWidth:B,opacity:N}),[q,R,B,N]),V=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),U=t.useMemo(()=>{if(z.customHoverBehavior)return e=>{z.customHoverBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[z.customHoverBehavior]),K=t.useMemo(()=>{if(z.customClickBehavior)return e=>{z.customClickBehavior(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[z.customClickBehavior]),Q=jr({componentName:"OrbitDiagram",data:i});return Q?e.jsx(cr,{componentName:"OrbitDiagram",message:Q,width:D,height:E}):z.loadingEl?z.loadingEl:e.jsx(gr,{componentName:"OrbitDiagram",width:D,height:E,children:e.jsx(Rc,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[D,E],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:z.margin,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:X,edgeStyle:V,colorBy:c,colorScheme:z.effectivePalette,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!k&&I,tooltipContent:k?void 0:!1===w?()=>null:kn(w)||void 0,customHoverBehavior:_||C||O?U:void 0,customClickBehavior:C||O?K:void 0,foregroundGraphics:A,annotations:j,className:s,title:H,description:F,summary:$,orbitMode:h,orbitSize:g,orbitSpeed:f,orbitRevolution:p,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:k,accessibleTable:W},null!=o.animate&&{animate:o.animate},S))})}au.displayName="OrbitDiagram";const lu={background:"var(--semiotic-tooltip-bg, rgba(0, 0, 0, 0.85))",color:"var(--semiotic-tooltip-text, #f3f4f6)",padding:"6px 10px",borderRadius:"var(--semiotic-tooltip-radius, 4px)",fontSize:"var(--semiotic-tooltip-font-size, 12px)",fontFamily:"var(--semiotic-tick-font-family, var(--semiotic-font-family, sans-serif))",boxShadow:"var(--semiotic-tooltip-shadow, 0 2px 8px rgba(0, 0, 0, 0.25))",lineHeight:1.4,pointerEvents:"none",whiteSpace:"nowrap"},cu={opacity:.7,marginRight:4};function uu(e,t,o){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:o]}function du(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function hu(t={}){const{timeAccessor:o,valueAccessor:n,xLabel:i="x",yLabel:r="y"}=t;return t=>{var s;const a=null!==(s=null==t?void 0:t.data)&&void 0!==s?s:null,l=uu(a,o,"time"),c=uu(a,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:lu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:cu,children:[i,":"]}),du(l)]}),e.jsxs("div",{children:[e.jsxs("span",{style:cu,children:[r,":"]}),du(c)]})]})}}function gu(e,t){var o;return null!=e?e:Math.max(null!==(o=null==t?void 0:t.length)&&void 0!==o?o:0,200)}const fu=t.forwardRef(function(o,n){var i,r,s,a,l;const c=er(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,stroke:w="#007bff",strokeWidth:A=2,strokeDasharray:j,opacity:S,background:C,tooltipContent:O,tooltip:M,onHover:P,annotations:_,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:D,transition:E,linkedHover:I,selection:H,onObservation:F,chartId:$,loading:W,loadingContent:z,emptyContent:G,emphasis:Y,legendPosition:q}=o,X=c.showAxes,V=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(l=null!=O?O:M)&&void 0!==l?l:hu({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=Ui({selection:H,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeLineChart",chartId:$}),ee=t.useCallback(e=>{P&&P(e),J(e)},[P,J]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Z.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const te=mr(W,K[0],K[1],z),oe=te?null:yr(y,K[0],K[1],G),ne={stroke:w,strokeWidth:A,strokeDasharray:j};null!=S&&(ne.opacity=S);const ie=gu(p,y);return te||oe||e.jsx(si,{ref:Z,chartType:"line",runtimeMode:"streaming",size:K,margin:U,className:Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,arrowOfTime:g,windowMode:f,windowSize:ie,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,lineStyle:ne,showAxes:X,background:C,hoverAnnotation:V,tooltipContent:Q,customHoverBehavior:ee,annotations:_,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:D,transition:E,pointIdAccessor:o.pointIdAccessor,legendPosition:q})});function pu(e,t,o){const n="function"==typeof t?t(e):e[null!=t?t:o];if(null==n)return null;if(n instanceof Date)return n.getTime();if("string"==typeof n&&""===n.trim())return null;const i=Number(n);return Number.isFinite(i)?i:null}fu.displayName="RealtimeLineChart";const yu=t.forwardRef(function(o,n){var i,r,s,a,l;const c=er(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,showAxes:o.showAxes,enableHover:null!=o.enableHover?!!o.enableHover:void 0,linkedHover:o.linkedHover}),{binSize:u,size:d,margin:h,className:g,arrowOfTime:f="right",windowMode:p="sliding",windowSize:y,data:m,timeAccessor:v,valueAccessor:b,direction:x="up",timeExtent:k,valueExtent:w,extentPadding:A,categoryAccessor:j,colors:S,fill:C,stroke:O,strokeWidth:M,opacity:P,gap:_,background:L,tooltipContent:T,tooltip:R,onHover:B,annotations:N,svgAnnotationRules:D,tickFormatTime:E,tickFormatValue:I,linkedHover:H,selection:F,decay:$,pulse:W,staleness:z,transition:G,onObservation:Y,chartId:q,loading:X,loadingContent:V,emptyContent:U,emphasis:K,legendPosition:Q,brush:Z,onBrush:J,linkedBrush:ee}=o,te=c.showAxes,oe=c.enableHover,ne=null!=h?h:c.marginDefaults,ie=null!=d?d:[c.width,c.height],re=null!==(l=null!=T?T:R)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n}=t;return t=>{var i;const r=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:null;if(null==(null==r?void 0:r.binStart)||null==(null==r?void 0:r.binEnd)){const t=uu(r,o,"time"),i=uu(r,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:lu,children:[e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"x:"}),du(t)]}),e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"y:"}),du(i)]})]})}return e.jsxs("div",{className:"semiotic-tooltip",style:lu,children:[e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"range:"}),du(r.binStart),"–",du(r.binEnd)]}),null!=r.total&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"count:"}),du(r.total)]}),null!=r.category&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"category:"}),du(r.category)]})]})}}({timeAccessor:v,valueAccessor:b}),se=t.useRef(null),{customHoverBehavior:ae}=Ui({selection:F,linkedHover:H,unwrapData:!0,onObservation:Y,chartType:"RealtimeHistogram",chartId:q}),le=t.useCallback(e=>{B&&B(e),ae(e)},[B,ae]),ce=!0===Z?{dimension:"x",snap:"bin"}:"x"===Z?{dimension:"x"}:"object"==typeof Z?Z:void 0,ue=Ti(ee),de=xi(Object.assign({name:(null==ue?void 0:ue.name)||"__unused_hist_brush__",xField:(null==ue?void 0:ue.xField)||("string"==typeof v?v:"time")},(null==ue?void 0:ue.yField)?{yField:ue.yField}:{})),he=t.useRef(de.brushInteraction);he.current=de.brushInteraction;const ge=t.useCallback(e=>{if(J&&J(e),Y&&Y(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:q}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:q}),ue){const t=he.current;t.end(e?"xBrush"===t.brush?e.x:"yBrush"===t.brush?e.y:[[e.x[0],e.y[0]],[e.x[1],e.y[1]]]:null)}},[J,Y,q,ue]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=se.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=se.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=se.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=se.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=se.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=se.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=se.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const fe=mr(X,ie[0],ie[1],V),pe=fe?null:yr(m,ie[0],ie[1],U),ye={};null!=C&&(ye.fill=C),null!=O&&(ye.stroke=O),null!=M&&(ye.strokeWidth=M),null!=P&&(ye.opacity=P),null!=_&&(ye.gap=_);const me=K?`${g||""} semiotic-emphasis-${K}`.trim():g,ve=gu(y,m),be=t.useMemo(()=>"down"!==x?w:function({data:e,valueAccessor:t,timeAccessor:o,binSize:n,valueExtent:i,extentPadding:r}){var s;if(i)return[i[1],i[0]];if(!e||0===e.length)return;const a=new Map;for(const i of e){const e=pu(i,o,"time"),r=pu(i,t,"value");if(null==e||null==r)continue;const l=Math.floor(e/n)*n;a.set(l,(null!==(s=a.get(l))&&void 0!==s?s:0)+r)}let l=0;for(const e of a.values())e>l&&(l=e);return[l>0?l+l*(null!=r?r:.1):1,0]}({data:m,valueAccessor:b,timeAccessor:v,binSize:u,valueExtent:w,extentPadding:A}),[x,m,b,v,u,w,A]);return fe||pe||e.jsx(si,{ref:se,chartType:"bar",runtimeMode:"streaming",size:ie,margin:ne,className:me,arrowOfTime:f,windowMode:p,windowSize:ve,data:m,timeAccessor:v,valueAccessor:b,xExtent:k,yExtent:be,extentPadding:A,binSize:u,categoryAccessor:j,barColors:S,barStyle:ye,showAxes:te,background:L,hoverAnnotation:oe,tooltipContent:re,customHoverBehavior:le,annotations:N,svgAnnotationRules:D,tickFormatTime:E,tickFormatValue:I,decay:$,pulse:W,staleness:z,transition:G,pointIdAccessor:o.pointIdAccessor,legendPosition:Q,brush:ce||(ee?{dimension:"x"}:void 0),onBrush:ce||ee?ge:void 0})});function mu(t){return e.jsx(yu,Object.assign({},t,{windowMode:"growing"}))}yu.displayName="RealtimeHistogram",mu.displayName="TemporalHistogram";const vu=t.forwardRef(function(o,n){var i,r,s,a,l;const c=er(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,categoryAccessor:w,colors:A,radius:j,fill:S,opacity:C,stroke:O,strokeWidth:M,background:P,tooltipContent:_,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:B,tickFormatTime:N,tickFormatValue:D,linkedHover:E,selection:I,onObservation:H,chartId:F,loading:$,loadingContent:W,emptyContent:z,emphasis:G,legendPosition:Y}=o,q=c.showAxes,X=c.enableHover,V=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(l=null!=_?_:L)&&void 0!==l?l:hu({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=Ui({selection:I,linkedHover:E,unwrapData:!0,onObservation:H,chartType:"RealtimeSwarmChart",chartId:F}),J=t.useCallback(e=>{T&&T(e),Z(e)},[T,Z]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Q.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Q.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ee=mr($,U[0],U[1],W),te=ee?null:yr(y,U[0],U[1],z),oe={};null!=j&&(oe.radius=j),null!=S&&(oe.fill=S),null!=C&&(oe.opacity=C),null!=O&&(oe.stroke=O),null!=M&&(oe.strokeWidth=M);const ne=G?`${h||""} semiotic-emphasis-${G}`.trim():h,ie=gu(p,y);return ee||te||e.jsx(si,{ref:Q,chartType:"swarm",runtimeMode:"streaming",size:U,margin:V,className:ne,arrowOfTime:g,windowMode:f,windowSize:ie,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,categoryAccessor:w,barColors:A,swarmStyle:oe,showAxes:q,background:P,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:R,svgAnnotationRules:B,tickFormatTime:N,tickFormatValue:D,legendPosition:Y,pointIdAccessor:o.pointIdAccessor})});vu.displayName="RealtimeSwarmChart";const bu=t.forwardRef(function(o,n){var i,r,s,a,l;const c=er(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:k,positiveColor:w,negativeColor:A,connectorStroke:j,connectorWidth:S,gap:C,stroke:O,strokeWidth:M,opacity:P,background:_,tooltipContent:L,tooltip:T,onHover:R,annotations:B,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:E,linkedHover:I,selection:H,onObservation:F,chartId:$,loading:W,loadingContent:z,emptyContent:G,emphasis:Y,legendPosition:q}=o,X=c.showAxes,V=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(l=null!=L?L:T)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n}=t;return t=>{var i,r;const s=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:null,a=uu(s,o,"time"),l=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:uu(s,n,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof l?0>l?du(l):"+"+du(l):du(l);return e.jsxs("div",{className:"semiotic-tooltip",style:lu,children:[e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"x:"}),du(a)]}),e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"Δ:"}),u]}),null!=c&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"total:"}),du(c)]})]})}}({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=Ui({selection:H,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeWaterfallChart",chartId:$}),ee=t.useCallback(e=>{R&&R(e),J(e)},[R,J]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Z.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Z.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const te=mr(W,K[0],K[1],z),oe=te?null:yr(y,K[0],K[1],G),ne={};null!=w&&(ne.positiveColor=w),null!=A&&(ne.negativeColor=A),null!=j&&(ne.connectorStroke=j),null!=S&&(ne.connectorWidth=S),null!=C&&(ne.gap=C),null!=O&&(ne.stroke=O),null!=M&&(ne.strokeWidth=M),null!=P&&(ne.opacity=P);const ie=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,re=gu(p,y);return te||oe||e.jsx(si,{ref:Z,chartType:"waterfall",runtimeMode:"streaming",size:K,margin:U,className:ie,arrowOfTime:g,windowMode:f,windowSize:re,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:k,waterfallStyle:ne,showAxes:X,background:_,hoverAnnotation:V,tooltipContent:Q,customHoverBehavior:ee,annotations:B,svgAnnotationRules:N,tickFormatTime:D,tickFormatValue:E,legendPosition:q,pointIdAccessor:o.pointIdAccessor})});bu.displayName="RealtimeWaterfallChart";const xu=t.forwardRef(function(o,n){var i,r,s,a,l;const c=er(o.mode,{width:null!==(r=null===(i=o.size)||void 0===i?void 0:i[0])&&void 0!==r?r:o.width,height:null!==(a=null===(s=o.size)||void 0===s?void 0:s[1])&&void 0!==a?a:o.height,enableHover:null!=o.enableHover?!!o.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:g="right",windowMode:f="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,timeExtent:x,valueExtent:k,extentPadding:w,heatmapXBins:A=20,heatmapYBins:j=20,aggregation:S="count",background:C,tooltipContent:O,tooltip:M,onHover:P,annotations:_,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:D,linkedHover:E,selection:I,onObservation:H,chartId:F,loading:$,loadingContent:W,emptyContent:z,emphasis:G,legendPosition:Y}=o,q=c.showAxes,X=c.enableHover,V=null!=d?d:c.marginDefaults,U=null!=u?u:[c.width,c.height],K=null!==(l=null!=O?O:M)&&void 0!==l?l:function(t={}){const{timeAccessor:o,valueAccessor:n,xLabel:i="x",yLabel:r="y"}=t;return t=>{var s,a,l,c;const u=null!==(s=null==t?void 0:t.data)&&void 0!==s?s:null,d=null!==(a=null==u?void 0:u.xCenter)&&void 0!==a?a:uu(u,o,"time"),h=null!==(l=null==u?void 0:u.yCenter)&&void 0!==l?l:uu(u,n,"value"),g=null==u?void 0:u.count,f=null==u?void 0:u.sum,p=null==u?void 0:u.value,y=null!==(c=null==u?void 0:u.agg)&&void 0!==c?c:"count";return e.jsxs("div",{className:"semiotic-tooltip",style:lu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:cu,children:[i,":"]}),du(d)]}),e.jsxs("div",{children:[e.jsxs("span",{style:cu,children:[r,":"]}),du(h)]}),null!=g&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"count:"}),du(g)]}),"sum"===y&&null!=f&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"sum:"}),du(f)]}),"mean"===y&&null!=p&&e.jsxs("div",{children:[e.jsx("span",{style:cu,children:"mean:"}),du(p)]})]})}}({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=Ui({selection:I,linkedHover:E,unwrapData:!0,onObservation:H,chartType:"RealtimeHeatmap",chartId:F}),J=t.useCallback(e=>{P&&P(e),Z(e)},[P,Z]);t.useImperativeHandle(n,()=>({push:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=Q.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=Q.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,n;return null!==(n=null===(o=Q.current)||void 0===o?void 0:o.update(e,t))&&void 0!==n?n:[]},clear:()=>{var e;return null===(e=Q.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=Q.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ee=mr($,U[0],U[1],W),te=ee?null:yr(y,U[0],U[1],z),oe=G?`${h||""} semiotic-emphasis-${G}`.trim():h,ne=gu(p,y);return ee||te||e.jsx(si,{ref:Q,chartType:"heatmap",runtimeMode:"streaming",size:U,margin:V,className:oe,arrowOfTime:g,windowMode:f,windowSize:ne,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,xExtent:x,yExtent:k,extentPadding:w,heatmapXBins:A,heatmapYBins:j,heatmapAggregation:S,showAxes:q,background:C,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:_,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:B,pulse:N,staleness:D,legendPosition:Y,pointIdAccessor:o.pointIdAccessor})});xu.displayName="RealtimeHeatmap";const[ku]=A(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function wu(e,t){return Tr(this,void 0,void 0,function*(){const{format:o="png",filename:n="chart",scale:i=2,background:r="white"}=t||{},s=e.querySelector("svg");if(!s)throw Error("No SVG element found in the container");const a=s.cloneNode(!0),l=s.getBoundingClientRect();if(a.getAttribute("width")||a.setAttribute("width",l.width+""),a.getAttribute("height")||a.setAttribute("height",l.height+""),a.getAttribute("xmlns")||a.setAttribute("xmlns","http://www.w3.org/2000/svg"),Au(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);ju(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),n+".svg")}else{const t=l.width*i,o=l.height*i,s=document.createElement("canvas");s.width=t,s.height=o;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,o),c.scale(i,i);const u=e.querySelector("canvas");u&&c.drawImage(u,0,0,l.width,l.height);const d=(new XMLSerializer).serializeToString(a),h=new Blob([d],{type:"image/svg+xml;charset=utf-8"}),g=URL.createObjectURL(h),f=new Image;f.width=l.width,f.height=l.height,yield new Promise((e,t)=>{f.onload=()=>{c.drawImage(f,0,0),s.toBlob(o=>{o?(ju(o,n+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(g)},f.onerror=()=>{URL.revokeObjectURL(g),t(Error("Failed to load SVG image"))},f.src=g})}})}function Au(e,t){var o;const n=e.children,i=t.children,r=window.getComputedStyle(e),s=["fill","stroke","stroke-width","stroke-dasharray","opacity","fill-opacity","stroke-opacity","font-family","font-size","font-weight","text-anchor","dominant-baseline"];for(const e of s){const n=r.getPropertyValue(e);n&&"none"!==n&&""!==n&&(null===(o=t.style)||void 0===o||o.setProperty(e,n))}for(let e=0;Math.min(n.length,i.length)>e;e++)Au(n[e],i[e])}function ju(e,t){const o=URL.createObjectURL(e),n=document.createElement("a");n.href=o,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(o)}const Su={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"},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"}},Cu={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},Ou={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},Mu=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],Pu=["vertical","horizontal"],_u={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Mu},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},fillArea:{type:"boolean"},areaOpacity:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}})},AreaChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Mu},gradientFill:{type:["boolean","object"]},semanticGradient:{type:"array"},areaOpacity:{type:"number"},showLine:{type:"boolean"},lineWidth:{type:"number"},forecast:{type:"object"},anomaly:{type:"object"},band:{type:["object","array"]}})},DifferenceChart:{required:[],dataShape:"array",dataAccessors:["xAccessor","seriesAAccessor","seriesBAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{data:{type:"array"},xAccessor:{type:["string","function"]},seriesAAccessor:{type:["string","function"]},seriesBAccessor:{type:["string","function"]},seriesALabel:{type:"string"},seriesBLabel:{type:"string"},seriesAColor:{type:"string"},seriesBColor:{type:"string"},showLines:{type:"boolean"},lineWidth:{type:"number"},showPoints:{type:"boolean"},pointRadius:{type:"number"},curve:{type:"string",enum:Mu},areaOpacity:{type:"number"},gradientFill:{type:["boolean","object"]},xExtent:{type:"array"},yExtent:{type:"array"},pointIdAccessor:{type:["string","function"]},windowSize:{type:"number"}})},StackedAreaChart:{required:["data","areaBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:Mu},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({},Su),Cu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},sizeBy:{type:["string","function"]},sizeRange:{type:"array"},pointRadius:{type:"number"},pointOpacity:{type:"number"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}})},BubbleChart:{required:["data","sizeBy"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{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"},regression:{type:["boolean","string","object"]}})},Heatmap:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{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:[],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Cu),{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({},Su),Cu),{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({},Su),Cu),{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({},Su),Cu),{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"},regression:{type:["boolean","string","object"]},forecast:{type:"object"},anomaly:{type:"object"}})},BarChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"},regression:{type:["boolean","string","object"]}})},StackedBarChart:{required:["data","stackBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},normalize:{type:"boolean"},sort:{type:["boolean","string","function"]},barPadding:{type:"number"},roundedTop:{type:"number"}})},LikertChart:{required:[],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor","levelAccessor","countAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Ou),{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:Pu},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},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({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},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({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},Su),Ou),{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({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},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({},Su),Ou),{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({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:Pu},sort:{type:["boolean","string","function"]},dotRadius:{type:"number"},categoryPadding:{type:"number"},regression:{type:["boolean","string","object"]}})},PieChart:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign({},Su),{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({},Su),{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:"none",dataAccessors:[],props:Object.assign(Object.assign({},Su),{value:{type:"number"},min:{type:"number"},max:{type:"number"},thresholds:{type:"array"},gradientFill:{type:"object"},arcWidth:{type:"number"},cornerRadius:{type:"number"},sweep:{type:"number"},fillZones:{type:"boolean"},showNeedle:{type:"boolean"},needleColor:{type:"string"},color:{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({},Su),Ou),{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({},Su),Ou),{data:{type:"array"},categoryAccessor:{type:["string","function"]},subcategoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:["horizontal","vertical"]},barPadding:{type:"number"},roundedTop:{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({},Su),{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({},Su),{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:Pu},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"}})},ProcessSankey:{required:["domain"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Su),{nodes:{type:"array"},edges:{type:"array"},domain:{type:"array"},axisTicks:{type:"array"},sourceAccessor:{type:["string","function"]},targetAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},nodeIdAccessor:{type:["string","function"]},startTimeAccessor:{type:["string","function"]},endTimeAccessor:{type:["string","function"]},xExtentAccessor:{type:["string","function"]},edgeIdAccessor:{type:["string","function"]},legendPosition:{type:"string",enum:["right","left","top","bottom"]},pairing:{type:"string",enum:["value","temporal"]},packing:{type:"string",enum:["off","reuse"]},laneOrder:{type:"string",enum:["insertion","crossing-min","inside-out","crossing-min+inside-out"]},ribbonLane:{type:"string",enum:["source","target","both"]},lifetimeMode:{type:"string",enum:["full","half"]},showLaneRails:{type:"boolean"},showQualityReadout:{type:"boolean"},edgeOpacity:{type:"number"},timeFormat:{type:"function"},valueFormat:{type:"function"},showParticles:{type:"boolean"},particleStyle:{type:"object"}})},ChordDiagram:{required:["edges"],dataShape:"network",dataAccessors:["sourceAccessor","targetAccessor"],props:Object.assign(Object.assign({},Su),{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({},Su),{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({},Su),{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"]},nodeStyle:{type:"function"}})},CirclePack:{required:["data"],dataShape:"object",dataAccessors:[],props:Object.assign(Object.assign({},Su),{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({},Su),{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"},direction:{type:"string",enum:["up","down"]},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"}}},TemporalHistogram:{required:["data","binSize"],dataShape:"array",dataAccessors:["timeAccessor","valueAccessor","categoryAccessor"],props:{data:{type:"array"},binSize:{type:"number"},direction:{type:"string",enum:["up","down"]},size:{type:"array"},width:{type:"number"},height:{type:"number"},margin:{type:"object"},className:{type:"string"},timeAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},categoryAccessor:{type:["string","function"]},colors:{type:"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"},fill:{type:"string"},stroke:{type:"string"},strokeWidth:{type:"number"},gap:{type:"number"},linkedHover:{type:["boolean","string","object"]},brush:{type:["boolean","string","object"]},onBrush:{type:"function"},linkedBrush:{type:["string","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({},Su),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Su),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},Su),{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({},Su),{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({},Su),{flows:{type:"array"},nodes:{type:"array"},valueAccessor:{type:["string","function"]},lineIdAccessor:{type:["string","function"]}})},DistanceCartogram:{required:["points"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},Su),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function Lu(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function Tu(e,t){const o=[],n=_u[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(_u).join(", ")}`]};for(const i of n.required)null==t[i]&&o.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=n.props[e];if(t){if(!Lu(i,t.type)){const n=Array.isArray(t.type)?t.type.join(" | "):t.type;o.push(`"${e}" should be ${n}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&o.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(n.props),r=new Set(i);for(const n of Object.keys(t))if(void 0!==t[n]&&!r.has(n)){const t=xr(n,i),r=t?`Unknown prop "${n}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${n}" for ${e}. Valid props: ${i.join(", ")}.`;o.push(r)}if("array"===n.dataShape){const i=t.data,r={};for(const e of n.dataAccessors){const o=t[e];"string"==typeof o&&(r[e]=o)}const s=Ar({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&o.push(s)}else if("object"===n.dataShape){const n=jr({componentName:e,data:t.data});n&&o.push(n)}else if("network"===n.dataShape){const i=Sr({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:n.required.includes("nodes"),edgesRequired:n.required.includes("edges")});i&&o.push(i)}return{valid:0===o.length,errors:o}}const Ru=new Set(["tooltip","onObservation","xFormat","yFormat","valueFormat","svgAnnotationRules","tooltipContent","onHover","tickFormatTime","tickFormatValue","edgeSort","sortGroups","centerContent","frameProps","controls","oFormat","rFormat","oSort","pieceStyle","summaryStyle","nodeStyle","edgeStyle","customHoverBehavior","customClickBehavior","customDoubleClickBehavior","onBrush","onTopologyChange","backgroundGraphics","foregroundGraphics","legend"]),Bu=new Set(["data","nodes","edges"]),Nu="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Du(e){return Tr(this,arguments,void 0,function*(e,t="json"){const o="jsx"===t?Eu(e):JSON.stringify(e,null,2);if("undefined"==typeof navigator||!navigator.clipboard)throw Error("Clipboard API not available. copyConfig requires a browser environment.");yield navigator.clipboard.writeText(o)})}function Eu(e){const{component:t,props:o}=e,n=["<"+t];for(const[e,t]of Object.entries(o))if("string"==typeof t)n.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)n.push(" "+e);else if("boolean"==typeof t&&!1===t)n.push(` ${e}={false}`);else if("number"==typeof t)n.push(` ${e}={${t}}`);else{const o=JSON.stringify(t);n.push(80>o.length?` ${e}={${o}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return n.push("/>"),n.join("\n")}function Iu(){const t=function(){const e=p.useContext(Wo);return e?()=>e.setVisible(e=>!e):null}();return t?e.jsx("button",{className:"semiotic-chart-action",onClick:t,title:"Data summary","aria-label":"Toggle data summary",style:zu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1",y:"1",width:"12",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"6",width:"8",height:"3",rx:"0.5"}),e.jsx("rect",{x:"1",y:"11",width:"5",height:"2",rx:"0.5"})]})}):null}const Hu={live:{bg:"#22c55e",color:"#fff"},stale:{bg:"#ef4444",color:"#fff"},paused:{bg:"#eab308",color:"#000"},error:{bg:"#ef4444",color:"#fff"},static:{bg:"#6b7280",color:"#fff"}};function Fu({height:t}){return e.jsx("div",{role:"status","aria-busy":"true","aria-label":"Loading chart",style:{width:"100%",height:t,background:"linear-gradient(90deg, var(--semiotic-border, #e0e0e0) 25%, var(--semiotic-bg, #f5f5f5) 50%, var(--semiotic-border, #e0e0e0) 75%)",backgroundSize:"200% 100%",animation:"semiotic-skeleton-pulse 1.5s ease-in-out infinite",borderRadius:4}})}function $u({error:t}){return e.jsx("div",{role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"100%",height:"100%",minHeight:120,padding:24,boxSizing:"border-box"},children:e.jsx("div",{style:{textAlign:"center",maxWidth:400,fontSize:14,color:"var(--semiotic-text-secondary, #666)",lineHeight:1.5},children:t})})}const Wu=p.forwardRef(function({title:t,subtitle:o,children:n,width:i="100%",height:r=400,actions:s,chartConfig:a,controls:l,loading:c=!1,error:u,errorBoundary:d=!1,status:h,detailsPanel:g,className:f,style:y},m){const v=p.useRef(null),b=p.useRef(null),[x,k]=p.useState(!1),w=!1!==(null==s?void 0:s.export)&&void 0!==(null==s?void 0:s.export),A=!1!==(null==s?void 0:s.fullscreen)&&void 0!==(null==s?void 0:s.fullscreen),j=!1!==(null==s?void 0:s.copyConfig)&&void 0!==(null==s?void 0:s.copyConfig)&&a,S=!0===(null==s?void 0:s.dataSummary),C="object"==typeof(null==s?void 0:s.export)?s.export:{},O="object"==typeof(null==s?void 0:s.copyConfig)?s.copyConfig.format:"json",M=p.useCallback(e=>Tr(this,void 0,void 0,function*(){b.current&&(yield wu(b.current,Object.assign(Object.assign({},C),e)))}),[C]),P=p.useCallback(()=>{v.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):v.current.requestFullscreen().catch(()=>{}))},[]),_=p.useCallback(e=>Tr(this,void 0,void 0,function*(){a&&(yield Du(a,e||O||"json"))}),[a,O]);p.useEffect(()=>{const e=()=>{k(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(m,()=>({export:M,toggleFullscreen:P,copyConfig:_,element:v.current}),[M,P,_]);const L=t||o||l||w||A||j||S||h,T=c?e.jsx(Fu,{height:r}):u?e.jsx($u,{error:u}):d?e.jsx(ur,{children:n}):n;return R=e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"@keyframes semiotic-skeleton-pulse {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n}"}}),e.jsxs("div",{ref:v,className:"semiotic-chart-container"+(f?" "+f:""),style:Object.assign(Object.assign({width:i,border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:"var(--semiotic-border-radius, 8px)",overflow:"hidden",background:"var(--semiotic-bg, #fff)",fontFamily:"var(--semiotic-font-family, sans-serif)",position:"relative"},x?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),y),children:[L&&e.jsxs("div",{className:"semiotic-chart-header",style:{padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"flex-start",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"},children:[e.jsxs("div",{className:"semiotic-chart-title-area",children:[t&&e.jsx("div",{className:"semiotic-chart-title",style:{fontSize:14,fontWeight:600,color:"var(--semiotic-text, #333)"},children:t}),o&&e.jsx("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:o})]}),e.jsxs("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4},children:[l,w&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>M(),title:"Export chart","aria-label":"Export chart",style:zu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M7 2v8M3.5 7L7 10.5 10.5 7"}),e.jsx("path",{d:"M2 12h10"})]})}),S&&e.jsx(Iu,{}),A&&e.jsx("button",{className:"semiotic-chart-action",onClick:P,title:x?"Exit fullscreen":"Fullscreen","aria-label":x?"Exit fullscreen":"Enter fullscreen",style:zu,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsxs(e.Fragment,x?{children:[e.jsx("path",{d:"M9 1v4h4"}),e.jsx("path",{d:"M5 13V9H1"}),e.jsx("path",{d:"M13 5H9V1"}),e.jsx("path",{d:"M1 9h4v4"})]}:{children:[e.jsx("path",{d:"M1 5V1h4"}),e.jsx("path",{d:"M13 9v4H9"}),e.jsx("path",{d:"M9 1h4v4"}),e.jsx("path",{d:"M5 13H1V9"})]})})}),j&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>_(),title:"Copy config","aria-label":"Copy chart configuration",style:zu,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"5",width:"8",height:"8",rx:"1"}),e.jsx("path",{d:"M9 5V2a1 1 0 00-1-1H2a1 1 0 00-1 1v6a1 1 0 001 1h3"})]})}),h&&e.jsx("div",{className:"semiotic-chart-status","aria-live":"polite","aria-atomic":"true",style:{padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",background:Hu[h].bg,color:Hu[h].color,lineHeight:"18px"},children:h})]})]}),e.jsxs("div",{className:"semiotic-chart-body",ref:b,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},x?{flex:1}:{height:r}),children:[T,g]})]})]}),S?e.jsx(zo,{children:R}):R;var R}),zu={width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0};function Gu({children:t,columns:o="auto",minCellWidth:n=300,gap:i=16,className:r,style:s}){const a="number"==typeof o?o:void 0;return e.jsx("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===o?`repeat(auto-fill, minmax(${n}px, 1fr))`:`repeat(${o}, 1fr)`,gap:i,width:"100%"},s),children:p.Children.map(t,t=>p.isValidElement(t)?"primary"!==t.props.emphasis||void 0!==a&&2>a?t:e.jsx("div",{style:{gridColumn:"span 2"},children:t}):t)})}function Yu({children:t,context:o,position:n="right",contextSize:i=250,gap:r=12,className:s,style:a}){const l="left"===n||"right"===n,c="left"===n||"top"===n,u=Object.assign({display:"flex",flexDirection:l?c?"row-reverse":"row":c?"column-reverse":"column",gap:r,width:"100%"},a),d=l?{flex:`0 0 ${i}px`,width:i,minHeight:0}:{flex:`0 0 ${i}px`,height:i,minWidth:0};return e.jsxs("div",{className:"semiotic-context-layout"+(s?" "+s:""),style:u,children:[e.jsx("div",{style:{flex:"1 1 0%",minWidth:0,minHeight:0},children:t}),e.jsx("div",{style:d,children:o})]})}Gu.displayName="ChartGrid",Yu.displayName="ContextLayout";function qu({children:o,position:n="right",size:i=300,trigger:r="click",chartId:s,observation:a,dismissOnEmpty:l=!0,showClose:c=!0,onToggle:u,className:d,style:h}){const[g,f]=t.useState(null),[p,y]=t.useState(null),[m,v]=t.useState(!1),[b,x]=t.useState(!1),k=t.useRef(null),w=t.useRef(void 0),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:j}=ki({types:A,chartId:s,limit:1}),S=void 0!==a?a:j;t.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;f(e.datum),y(e),m||(v(!0),x(!0),clearTimeout(w.current),w.current=setTimeout(()=>x(!1),200))}else!l||"click-end"!==S.type&&"hover-end"!==S.type||C()},[S]),t.useEffect(()=>{null==u||u(m)},[m,u]);const C=t.useCallback(()=>{x(!0),v(!1),clearTimeout(w.current),w.current=setTimeout(()=>{x(!1),f(null),y(null)},200)},[]);if(t.useEffect(()=>()=>clearTimeout(w.current),[]),!g&&!b)return null;const O=g&&p?o(g,p):null;if(null===O&&!b)return null;const M=function(e,t,o,n){const i={position:"absolute",background:"var(--semiotic-bg, #fff)",borderColor:"var(--semiotic-border, #e0e0e0)",borderStyle:"solid",borderWidth:0,boxSizing:"border-box",zIndex:10,display:"flex",flexDirection:"column",transition:n?"transform 200ms ease-out, opacity 200ms ease-out":void 0};return Object.assign(Object.assign({},i),"right"===e?{top:0,right:0,width:t,height:"100%",borderLeftWidth:1,padding:"12px 16px",transform:o?"translateX(0)":`translateX(${t}px)`,opacity:o?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:o?"translateY(0)":`translateY(${t}px)`,opacity:o?1:0}:{top:"50%",left:"50%",transform:o?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:o?1:0,width:Math.min(t,400),maxHeight:"80%",borderWidth:1,borderRadius:8,padding:"16px 20px",boxShadow:"0 8px 32px rgba(0,0,0,0.12)"})}(n,i,m,b);return e.jsxs("div",{ref:k,className:`semiotic-details-panel semiotic-details-${n}${d?" "+d:""}`,style:Object.assign(Object.assign({},M),h),children:[c&&e.jsx("button",{className:"semiotic-details-close",onClick:C,"aria-label":"Close details",style:Xu,children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",children:e.jsx("path",{d:"M2 2l8 8M10 2l-8 8"})})}),e.jsx("div",{className:"semiotic-details-content",style:{overflow:"auto",flex:1},children:O})]})}const Xu={position:"absolute",top:8,right:8,width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",cursor:"pointer",borderRadius:4,color:"var(--semiotic-text-secondary, #666)",padding:0,zIndex:1};qu.displayName="DetailsPanel";const Vu=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Uu=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Ku=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Qu=new Set(["LineChart","AreaChart","StackedAreaChart"]),Zu=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Ju(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[o,n,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(o)+.7152*r(n)+.0722*r(i)}function ed(e,t){const o=Ju(e),n=Ju(t);return null===o||null===n?null:(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const td=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function od(e){return"nominal"===e||"ordinal"===e}function nd(e){return"quantitative"===e||"temporal"===e}const id={category10:"category10",category20:"category20",category20b:"category20",category20c:"category20",accent:"accent",dark2:"dark2",paired:"paired",pastel1:"pastel1",pastel2:"pastel2",set1:"set1",set2:"set2",set3:"set3",tableau10:"category10",tableau20:"category20"},rd={linear:"linear","monotone-x":"monotoneX","monotone-y":"monotoneY",monotone:"monotoneX",step:"step","step-after":"stepAfter","step-before":"stepBefore",basis:"basis",cardinal:"cardinal","catmull-rom":"catmullRom"},sd={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ad(e,t,o,n,i){var r,s;(null==e?void 0:e.field)&&(o.xAccessor=n?"value":e.field),(null==t?void 0:t.field)&&(o.yAccessor=i?"value":t.field),(null===(r=null==e?void 0:e.axis)||void 0===r?void 0:r.title)&&(o.xLabel=e.axis.title),(null===(s=null==t?void 0:t.axis)||void 0===s?void 0:s.title)&&(o.yLabel=t.axis.title)}function ld(e,t,o){const n={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(o.length>0){n.warnings=o;for(const e of o)console.warn("[semiotic/fromVegaLite] "+e)}return n}const cd=/^\d{4}[-/]\d{2}/,ud=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function dd(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?cd.test(e)&&!Number.isNaN(Date.parse(e))?"date":ud.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function hd(e){let t=1/0,o=-1/0;for(let n=0;e.length>n;n++){const i=e[n];t>i&&(t=i),i>o&&(o=i)}return{min:t,max:o}}function gd(e){const t=e.length;if(0===t)return NaN;const o=t>>1;return t%2==0?(e[o-1]+e[o])/2:e[o]}function fd(e,t={}){var o,n;const{maxDistinct:i=10,sampleSize:r=5,keyScanRows:s=100}=t;if(!Array.isArray(e)||0===e.length)return{rowCount:0,fields:{},sample:[]};const a=new Set,l=Math.min(e.length,s);for(let t=0;l>t;t++){const o=e[t];if(o&&"object"==typeof o)for(const e of Object.keys(o))a.add(e)}const c={};for(const t of a){const r=[];for(let n=0;e.length>n;n++){const i=null===(o=e[n])||void 0===o?void 0:o[t];null!=i&&r.push(i)}if(0===r.length){c[t]={type:"unknown"};continue}const s=dd(r[0]);if("numeric"===s){const e=[];for(let t=0;r.length>t;t++){const o=Number(r[t]);Number.isFinite(o)&&e.push(o)}if(0===e.length){c[t]={type:"unknown"};continue}const{min:o,max:n}=hd(e);let i=0;for(let t=0;e.length>t;t++)i+=e[t];const s=[...e].sort((e,t)=>e-t);c[t]={type:"numeric",min:o,max:n,mean:i/e.length,median:gd(s)}}else if("date"===s){const e=[];for(let t=0;r.length>t;t++){const o=r[t],n=o instanceof Date?o.getTime():Date.parse(o);Number.isFinite(n)&&e.push(n)}if(0===e.length){c[t]={type:"unknown"};continue}const{min:o,max:n}=hd(e);c[t]={type:"date",min:new Date(o).toISOString(),max:new Date(n).toISOString()}}else if("categorical"===s){const e=new Map;for(let t=0;r.length>t;t++){const o=r[t]+"";e.set(o,(null!==(n=e.get(o))&&void 0!==n?n:0)+1)}const o=[...e.entries()].sort((e,t)=>t[1]-e[1]).slice(0,i).map(([e,t])=>({value:e,count:t}));c[t]={type:"categorical",distinctCount:e.size,topValues:o,distinctValues:e.size>i?void 0:o.map(e=>e.value)}}else c[t]={type:"unknown"}}return{rowCount:e.length,fields:c,sample:e.slice(0,r)}}const pd=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,yd=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,md=/(size|magnitude|volume|weight|count|amount)/i,vd=/^(category|label|name|type|group|region|segment|kind|class)$/i,bd=/^(series|group|type|category|segment|cohort|product)$/i,xd=new Set(["numeric"]),kd=new Set(["numeric","date"]),wd=new Set(["numeric"]),Ad=new Set(["date"]),jd=new Set(["categorical","boolean"]);function Sd(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function Cd(e,t){return t.test(e)?.2:0}function Od(e,t){var o;let n=null;for(let i=0;e.length>i;i++){const r=null===(o=e[i])||void 0===o?void 0:o[t];if(null==r)continue;const s=r instanceof Date?r.getTime():Number(r);if(!Number.isFinite(s))return!1;if(null!==n&&n>s)return!1;n=s}return null!==n}function Md(e,t,o,n,i={}){const r=[];for(const[s,a]of Object.entries(e)){const e=Sd(a);if(!o.has(e))continue;let l,c=.5;c+=Cd(s,n),"categorical"===a.type&&(l=a.distinctCount,!l||2>l||l>12||(c+=.2),l&&l>50&&(c-=.2)),"numeric"===a.type&&Number.isFinite(a.min)&&Number.isFinite(a.max)&&a.max>a.min&&(c+=.1);const u={field:s,kind:e,quality:Math.max(0,Math.min(1,c)),distinctCount:l};!i.computeMonotonic||"numeric"!==e&&"date"!==e||(u.monotonic=Od(t,s),u.monotonic&&(u.quality=Math.min(1,u.quality+.2))),r.push(u)}return r.sort((e,t)=>t.quality-e.quality),r}function Pd(e,t){var o;const n=new Set;for(let i=0;e.length>i;i++){const r=null===(o=e[i])||void 0===o?void 0:o[t];null!=r&&n.add(r+"")}return n.size}const _d=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,Ld=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,Td=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,Rd=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,Bd=/^(value|weight|amount|count|magnitude|volume)$/i;function Nd(e,t){return e.find(e=>t.test(e))}function Dd(e,t={}){var o,n,i,r,s,a,l;const c=fd(null!=e?e:[]),u=Array.isArray(e)?e:[],d=function(e){var t;if(e&&"object"==typeof e&&!Array.isArray(e)){const o=e;if("FeatureCollection"===o.type&&Array.isArray(o.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:o.features,points:Array.isArray(o.points)?o.points:void 0,flows:Array.isArray(o.flows)?o.flows:void 0}};if(Array.isArray(o.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:o};if(Array.isArray(o.nodes)&&(Array.isArray(o.edges)||Array.isArray(o.links))){const e=null!==(t=o.edges)&&void 0!==t?t:o.links;return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:o.nodes,edges:e}}}}return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!1}}(t.rawInput);if(!d.hasNetwork&&!d.hasHierarchy&&!d.hasGeo){const e=function(e){var t,o;if(3>e.length)return null;const n=e[0];if(!n||"object"!=typeof n)return null;const i=Object.keys(n),r=Nd(i,_d),s=Nd(i,Ld);if(!r||!s||r===s)return null;const a=Nd(i,Td),l=Nd(i,Rd),c=Nd(i,Bd),u=[];for(const t of e){if(!t)continue;const e=t[r],o=t[s];if(null==e||null==o)continue;const n=(e+"").trim(),i=(o+"").trim();n&&i&&n!==i&&u.push(t)}if(3>u.length)return null;const d=new Map,h=new Map,g=new Map;for(const e of u){const o=(e[r]+"").trim(),n=(e[s]+"").trim();d.has(o)||d.set(o,{id:o,label:o}),d.has(n)||d.set(n,{id:n,label:n});const i=`${o}->${n}`,u=c?Number(e[c]):1,f=Number.isFinite(u)?u:1;h.set(i,(null!==(t=h.get(i))&&void 0!==t?t:0)+f),g.has(i)||g.set(i,Object.assign(Object.assign({source:o,target:n},a?{startTime:e[a]}:{}),l?{endTime:e[l]}:{}))}const f=[];for(const[e,t]of g)f.push(Object.assign(Object.assign({},t),{value:null!==(o=h.get(e))&&void 0!==o?o:1}));return{nodes:Array.from(d.values()),edges:f}}(u);e&&(d.hasNetwork=!0,d.network=e)}const h=Md(c.fields,u,kd,pd,{computeMonotonic:!0}),g=Md(c.fields,u,wd,yd),f=Md(c.fields,u,xd,md),p=Md(c.fields,u,jd,vd),y=Md(c.fields,u,jd,bd),m=Md(c.fields,u,Ad,/(date|time|timestamp)/i,{computeMonotonic:!0}),v=null===(o=m[0])||void 0===o?void 0:o.field;let b=v,x=v?"time":"none";if(!b){const e=h.find(e=>pd.test(e.field)&&"numeric"===e.kind);e&&(b=e.field,x="named")}const k=null===(n=g.find(e=>e.field!==b))||void 0===n?void 0:n.field;if(!b&&k){const e=Object.entries(c.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(b=e.find(e=>e!==k),b&&(x="scatter"))}const w=null===(i=f.find(e=>e.field!==b&&e.field!==k))||void 0===i?void 0:i.field,A="time"===x||"named"===x,j=p.map(e=>e.field);let S,C;A?(C=null!==(r=t.seriesField)&&void 0!==r?r:j[0],S=j.find(e=>e!==C)):(S=j[0],C=null!==(s=t.seriesField)&&void 0!==s?s:j.find(e=>e!==S));const O=S?Pd(u,S):void 0,M=C?Pd(u,C):void 0,P=b?Pd(u,b):void 0,_=!!b&&function(e,t){var o;const n=new Set;for(let i=0;e.length>i;i++){const r=null===(o=e[i])||void 0===o?void 0:o[t];if(null==r)continue;const s=r+"";if(n.has(s))return!0;n.add(s)}return!1}(u,b),L=null!==(l=null===(a=h.find(e=>e.field===b))||void 0===a?void 0:a.monotonic)&&void 0!==l&&l,T=m.length>0;return Object.assign(Object.assign({},c),{data:u,candidates:{x:h,y:g,size:f,category:p,series:y,time:m},primary:{x:b,y:k,size:w,category:S,series:C,time:v},categoryCount:O,seriesCount:M,uniqueXCount:P,hasRepeatedX:_,monotonicX:L,hasTimeAxis:T,hasHierarchy:d.hasHierarchy,hasNetwork:d.hasNetwork,hasGeo:d.hasGeo,xProvenance:x,network:d.network,hierarchy:d.hierarchy,geo:d.geo})}const Ed={component:"LineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:5,accuracy:4,precision:4},fits:e=>{var t;if(2>e.rowCount)return"needs at least 2 rows";if(!e.primary.x)return"needs a numeric or time x field";if(!e.primary.y)return"needs a numeric y field";const o=null===(t=e.candidates.x.find(t=>t.field===e.primary.x))||void 0===t?void 0:t.kind;return o&&"numeric"!==o&&"date"!==o?`x field "${e.primary.x}" is ${o}, LineChart needs numeric or time`:"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence"},intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?!e.uniqueXCount||4>e.uniqueXCount?3:!e.seriesCount||2>e.seriesCount?4:5:1,"compare-series":e=>"scatter"!==e.xProvenance||e.monotonicX?!e.seriesCount||2>e.seriesCount?1:e.seriesCount>8?2:4:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?4:1,"outlier-detection":2,correlation:2},caveats:e=>{const t=[];return!e.hasRepeatedX||e.seriesCount&&e.seriesCount>=2||t.push("x values repeat — consider aggregating or adding a series field"),e.seriesCount&&e.seriesCount>8&&t.push(e.seriesCount+" series may produce a spaghetti chart"),t},variants:[{key:"linear",label:"Linear trend",props:{curve:"linear",showPoints:!1},tags:["linear"]},{key:"smooth",label:"Smooth trend",description:"Monotone smoothing — emphasizes the shape over individual points.",props:{curve:"monotoneX",showPoints:!1},tags:["smooth","narrative"],intentDeltas:{trend:1,"outlier-detection":-2},rubricDeltas:{precision:-1},caveats:["smoothing hides individual outliers"]},{key:"stepped-with-points",label:"Discrete steps",description:"Step curve plus visible points — for state changes or discrete events.",props:{curve:"step",showPoints:!0,pointRadius:3},tags:["step","discrete"],intentDeltas:{"change-detection":1,trend:-1},rubricDeltas:{precision:1}}],buildProps:(e,t)=>{var o;const n={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(n.lineBy=e.primary.series,n.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(n.xScaleType="time"),Object.assign(Object.assign({},n),null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},Id={component:"AreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>3>e.rowCount?"needs at least 3 rows":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a numeric or time x field",intentScores:{trend:e=>"scatter"!==e.xProvenance||e.monotonicX?e.seriesCount&&e.seriesCount>=2||!e.uniqueXCount||4>e.uniqueXCount?3:5:1,"change-detection":e=>"scatter"!==e.xProvenance||e.monotonicX?3:1},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&t.push(`showing only the leading "${e.primary.series}" series — for multi-series comparison use LineChart or DifferenceChart`),t},variants:[{key:"smooth",label:"Smooth gradient",props:{curve:"monotoneX"},tags:["smooth","gradient","narrative"]},{key:"linear",label:"Linear",props:{curve:"linear",gradientFill:!1,areaOpacity:.5},tags:["linear"]},{key:"stepped",label:"Stepped",props:{curve:"stepAfter"},tags:["step"],intentDeltas:{"change-detection":1}}],buildProps:(e,t)=>{var o,n;let i=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,n=e.primary.y,r=new Map;for(const i of e.data){const e=i[t];if(null==e||""===e)continue;const s=Number(i[n]);r.set(e,(null!==(o=r.get(e))&&void 0!==o?o:0)+(Number.isFinite(s)?s:0))}let s,a=-1/0;for(const[e,t]of r)t>a&&(a=t,s=e);null!=s&&r.size>0&&(i=e.data.filter(e=>e[t]===s))}const r={data:i,xAccessor:e.primary.x,yAccessor:e.primary.y,gradientFill:!0,areaOpacity:.55};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(r.xScaleType="time"),Object.assign(Object.assign({},r),null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})}},Hd={component:"StackedAreaChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.y?!e.seriesCount||2>e.seriesCount?"needs 2+ stack groups (series field)":e.seriesCount>10?e.seriesCount+" series is too many to stack legibly":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — stacking only makes sense across a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{"composition-over-time":5,"part-to-whole":e=>e.hasTimeAxis?4:3,trend:3,"compare-series":2},caveats:()=>["readability of individual layers degrades below the baseline"],variants:[{key:"baseline-zero",label:"Zero baseline",props:{baseline:"zero",stackOrder:"key"},tags:["zero-baseline"]},{key:"streamgraph",label:"Streamgraph",description:"Wiggle baseline + inside-out ordering — emphasizes momentum over precise totals.",props:{baseline:"wiggle",stackOrder:"insideOut",showLine:!1},tags:["streamgraph","narrative"],intentDeltas:{"composition-over-time":0,trend:1,"part-to-whole":-2},rubricDeltas:{accuracy:-1,precision:-1},caveats:["streamgraph hides absolute totals; precise reads not possible"]},{key:"centered",label:"Centered baseline",props:{baseline:"silhouette",stackOrder:"insideOut"},tags:["silhouette"],intentDeltas:{"part-to-whole":-1}}],buildProps:(e,t)=>{var o;const n={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,areaBy:e.primary.series,colorBy:e.primary.series};return e.hasTimeAxis&&e.primary.x===e.primary.time&&(n.xScaleType="time"),Object.assign(Object.assign({},n),null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},Fd={component:"Scatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:5,precision:5},fits:e=>{var t;if(3>e.rowCount)return"needs at least 3 rows";if(!e.primary.x)return"needs a numeric x field";if(!e.primary.y)return"needs a numeric y field";const o=null===(t=e.candidates.x.find(t=>t.field===e.primary.x))||void 0===t?void 0:t.kind;return"date"===o?null:o&&"numeric"!==o?`x field "${e.primary.x}" is ${o}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,o=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&o.length>=2?4:5},"outlier-detection":5,distribution:3,"compare-series":e=>!e.seriesCount||2>e.seriesCount||e.seriesCount>6?1:3,rank:1},variants:[{key:"points",label:"Points only",props:{},tags:["points"]},{key:"with-trend",label:"Points with regression line",props:{regression:"linear"},tags:["regression","trend"],intentDeltas:{correlation:0,trend:1}}],buildProps:(e,t)=>{var o;const n={data:e.data},i="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:void 0,r=i?e.candidates.y.filter(e=>e.field!==i).map(e=>e.field):[];return i&&r.length>=2?(n.xAccessor=r[0],n.yAccessor=r[1]):(n.xAccessor=e.primary.x,n.yAccessor=e.primary.y,e.primary.size&&(n.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(n.colorBy=e.primary.series),Object.assign(Object.assign({},n),null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},$d={component:"ConnectedScatterplot",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 ordered points":e.primary.x?e.primary.y?e.monotonicX||e.hasTimeAxis?null:"needs an ordered x sequence":"needs a y field":"needs an x field",intentScores:{trend:3,correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,o=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&o.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{var t,o;const n={data:e.data},i="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,r=i?e.candidates.y.filter(e=>e.field!==i).map(e=>e.field):[];return i&&r.length>=2?(n.xAccessor=r[0],n.yAccessor=r[1],n.orderAccessor=i):(n.xAccessor=e.primary.x,n.yAccessor=e.primary.y,n.orderAccessor=null!==(t=e.primary.time)&&void 0!==t?t:e.primary.x),e.primary.series&&6>=(null!==(o=e.seriesCount)&&void 0!==o?o:0)&&(n.colorBy=e.primary.series),n}},Wd={component:"BubbleChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?e.primary.size?null:"needs a third numeric measure for bubble size":"needs a numeric y field":"needs a numeric x field",intentScores:{correlation:4,"compare-categories":3,"outlier-detection":4},caveats:()=>["bubble area is harder to compare than length — large dynamic ranges distort"],buildProps:e=>{var t;return Object.assign({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y,sizeBy:e.primary.size},e.primary.series&&6>=(null!==(t=e.seriesCount)&&void 0!==t?t:0)?{colorBy:e.primary.series}:{})}},zd={component:"QuadrantChart",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>4>e.rowCount?"needs at least 4 points":e.primary.x?e.primary.y?null:"needs a numeric y field":"needs a numeric x field",intentScores:{"compare-categories":2,correlation:3,"outlier-detection":3},buildProps:e=>{var t;const o=e.primary.x,n=e.primary.y,i=e.fields[o],r=e.fields[n],s="numeric"===(null==i?void 0:i.type)?i.median:void 0,a="numeric"===(null==r?void 0:r.type)?r.median:void 0;return Object.assign(Object.assign(Object.assign(Object.assign({data:e.data,xAccessor:o,yAccessor:n},void 0!==s?{xCenter:s}:{}),void 0!==a?{yCenter:a}:{}),e.primary.series&&6>=(null!==(t=e.seriesCount)&&void 0!==t?t:0)?{colorBy:e.primary.series}:{}),{quadrants:{topLeft:Object.assign({},gs),topRight:Object.assign({},fs),bottomLeft:Object.assign({},ps),bottomRight:Object.assign({},ys)}})}},Gd={component:"MultiAxisLineChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>4>e.rowCount?"needs at least 4 rows":e.primary.x?2>Object.entries(e.fields).filter(([t,o])=>"numeric"===o.type&&t!==e.primary.x).map(([e])=>e).length?"needs at least 2 numeric measures":"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — multi-axis lines need a shared sequence":"needs an x field",intentScores:{"compare-series":4,trend:3,correlation:3},caveats:()=>["dual axes can mislead — only use when measures share interpretation"],buildProps:e=>{const t=Object.entries(e.fields).filter(([t,o])=>"numeric"===o.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},Yd={component:"MinimapChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:4,accuracy:4,precision:4},fits:e=>30>e.rowCount?"minimap pays off only on long sequences (30+ rows)":e.primary.x?e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — minimap previews a sequence":"needs a numeric y field":"needs an ordered x field",intentScores:{trend:4,"change-detection":4,"outlier-detection":3},buildProps:e=>Object.assign({data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y},e.hasTimeAxis&&e.primary.x===e.primary.time?{xScaleType:"time"}:{})},qd={component:"DifferenceChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{var t;return 4>e.rowCount?"needs at least 4 rows":e.primary.x?e.primary.series?!e.seriesCount||2>e.seriesCount?`needs 2+ series (got ${null!==(t=e.seriesCount)&&void 0!==t?t:0})`:e.primary.y?"scatter"!==e.xProvenance||e.monotonicX?null:"needs an ordered/temporal x — given x looks like a scatter pattern, not a sequence":"needs a numeric y field":"needs a series field with at least two groups":"needs an x field (numeric or time)"},intentScores:{"compare-series":5,"change-detection":4,trend:3},caveats:e=>{const t=[];return e.seriesCount&&e.seriesCount>2&&t.push(`showing the top 2 of ${e.seriesCount} series — for full multi-series comparison use LineChart`),t},buildProps:e=>{var t,o,n;const i=e.primary.x,r=e.primary.y,s=e.primary.series,a=e=>null!=e&&(e+"").length>0,l=new Map;for(const o of e.data){const e=o[s];if(!a(e))continue;const n=e+"",i=Number(o[r]);l.set(n,(null!==(t=l.get(n))&&void 0!==t?t:0)+(Number.isFinite(i)?i:0))}const c=[...l.entries()].sort((e,t)=>t[1]-e[1]),u=null===(o=c[0])||void 0===o?void 0:o[0],d=null===(n=c[1])||void 0===n?void 0:n[0],h=e=>e instanceof Date?e.getTime():e,g=new Map;for(const t of e.data){const e=t[s];if(!a(e))continue;const o=e+"";if(o!==u&&o!==d)continue;const n=t[i],l=t[r],c=h(n);let f=g.get(c);f||(f={[i]:n},g.set(c,f)),o===u?f.a=l:o===d&&(f.b=l)}return{data:Array.from(g.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:i,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:u,seriesBLabel:d}}},Xd={component:"CandlestickChart",family:"time-series",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{if(4>e.rowCount)return"needs at least 4 rows";if(!e.primary.x)return"needs an x field (typically date)";const t=new Set(Object.keys(e.fields).map(e=>e.toLowerCase())),o=t.has("high"),n=t.has("low");return o&&n?null:"needs at minimum high/low fields (open/close optional)"},intentScores:{"change-detection":4,trend:3,"outlier-detection":3},buildProps:e=>{const t=Object.keys(e.fields),o=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:o("high"),lowAccessor:o("low"),openAccessor:o("open"),closeAccessor:o("close")}}},Vd={component:"Heatmap",family:"relationship",importPath:"semiotic/xy",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>{var t;if(4>e.rowCount)return"needs at least 4 cells";if(!e.primary.y)return"needs a numeric value to encode in cell color";const o=e.candidates.category.length;return o>=2||o>=1&&e.hasTimeAxis?(null!==(t=e.uniqueXCount)&&void 0!==t?t:0)>50?"too many x cells for a legible heatmap":null:"needs two categorical-or-time dimensions for the axes"},intentScores:{correlation:3,distribution:2,"compare-categories":e=>2>e.candidates.category.length?1:4,"composition-over-time":e=>e.hasTimeAxis&&e.candidates.category.length>=1?4:1},caveats:e=>{var t;const o=[];return(null!==(t=e.uniqueXCount)&&void 0!==t?t:0)>30&&o.push("many x values — cells will be narrow"),o},variants:[{key:"default",label:"Sequential color",props:{},tags:["sequential"]},{key:"show-values",label:"With cell labels",props:{showValues:!0},tags:["labeled"],intentDeltas:{"compare-categories":1},rubricDeltas:{precision:1},caveats:["cell labels crowd dense matrices"]}],buildProps:(e,t)=>{var o,n,i,r;const s=e.candidates.category.map(e=>e.field),a=null!==(o=e.primary.time)&&void 0!==o?o:s[0],l=null!==(i=null!==(n=s.find(e=>e!==a))&&void 0!==n?n:s[0])&&void 0!==i?i:e.primary.series;return Object.assign({data:e.data,xAccessor:a,yAccessor:l,valueAccessor:e.primary.y},null!==(r=null==t?void 0:t.props)&&void 0!==r?r:{})}},Ud={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},fits:e=>{var t,o;return e.primary.category?e.primary.y?1>(null!==(t=e.categoryCount)&&void 0!==t?t:0)?"needs at least 1 category":(null!==(o=e.categoryCount)&&void 0!==o?o:0)>50?"too many categories — consider aggregating or use a different chart":null:"needs a numeric value field":"needs a category field"},intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"part-to-whole":e=>{var t;return(null!==(t=e.categoryCount)&&void 0!==t?t:0)>8?2:3},distribution:1},variants:[{key:"sorted-desc",label:"Ranked",props:{sort:"desc"},tags:["sorted","ranked"],intentDeltas:{rank:0,"compare-categories":0}},{key:"source-order",label:"Source order",props:{sort:!1},tags:["source-order"],intentDeltas:{rank:-2}},{key:"horizontal",label:"Horizontal bars",props:{orientation:"horizontal",sort:"desc"},tags:["horizontal","ranked"],intentDeltas:{rank:1},rubricDeltas:{precision:1}}],buildProps:(e,t)=>{var o;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},Kd={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},fits:e=>{var t,o,n;return e.primary.category?e.primary.y?e.primary.series?2>(null!==(t=e.seriesCount)&&void 0!==t?t:0)?"needs 2+ groups":(null!==(o=e.seriesCount)&&void 0!==o?o:0)>6?e.seriesCount+" groups is too many for grouped bars":(null!==(n=e.categoryCount)&&void 0!==n?n:0)>25?"too many categories for grouped bars":null:"needs a series field to group by":"needs a numeric value field":"needs a category field"},intentScores:{"compare-categories":5,"compare-series":4,rank:3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,groupBy:e.primary.series,colorBy:e.primary.series})},Qd={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{var t,o;return e.primary.category?e.primary.y?e.primary.series?2>(null!==(t=e.seriesCount)&&void 0!==t?t:0)?"needs 2+ stack groups":(null!==(o=e.seriesCount)&&void 0!==o?o:0)>8?e.seriesCount+" stacked groups is too many":null:"needs a series field to stack by":"needs a numeric value field":"needs a category field"},intentScores:{"part-to-whole":4,"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":2},caveats:()=>["only the bottom segment shares a baseline; others are harder to compare across categories"],variants:[{key:"absolute",label:"Absolute stacks",props:{normalize:!1},tags:["absolute"]},{key:"normalized",label:"100% stacked",description:"Each bar normalized to 1 — emphasizes composition, hides totals.",props:{normalize:!0},tags:["normalized","part-to-whole"],intentDeltas:{"part-to-whole":1,"compare-categories":-1},caveats:["absolute magnitudes are no longer comparable across bars"]}],buildProps:(e,t)=>{var o;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},Zd={component:"DotPlot",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:5,precision:5},fits:e=>{var t;return e.primary.category?e.primary.y?(null!==(t=e.categoryCount)&&void 0!==t?t:0)>30?"too many categories for a dot plot":null:"needs a numeric value field":"needs a category field"},intentScores:{"compare-categories":e=>e.categoryCount?10>e.rowCount/e.categoryCount?5:3:0,rank:5,"outlier-detection":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},Jd={component:"PieChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:3,precision:2},fits:e=>{var t;if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const o=null!==(t=e.categoryCount)&&void 0!==t?t:0;return 2>o?"needs 2+ categories":o>8?o+" slices is too many for a pie chart":null},intentScores:{"part-to-whole":4,"compare-categories":2,rank:1},caveats:()=>["angle comparisons are less accurate than length — prefer a bar chart unless part-to-whole is the explicit message"],variants:[{key:"pie",label:"Pie",props:{},tags:["pie"]},{key:"donut",label:"Donut",description:"Hollow center — easier to fit a label or KPI inside.",props:{innerRadius:60},tags:["donut"]}],buildProps:(e,t)=>{var o;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},eh={component:"DonutChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>{var t;if(!e.primary.category)return"needs a category field";if(!e.primary.y)return"needs a numeric value field";const o=null!==(t=e.categoryCount)&&void 0!==t?t:0;return 2>o?"needs 2+ categories":o>8?o+" slices is too many for a donut":null},intentScores:{"part-to-whole":4,"compare-categories":2},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,innerRadius:40})},th=/(stage|step|funnel|status|outcome|phase)/i,oh={component:"FunnelChart",family:"flow",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.primary.y?Object.keys(e.fields).find(e=>th.test(e))?null:"needs a stage/step/funnel-named field":"needs a numeric value field",intentScores:{flow:4,rank:3,"part-to-whole":2},caveats:()=>["readers infer conversion drop-off — make sure rows actually represent sequential stages"],buildProps:e=>{const t=Object.keys(e.fields).find(e=>th.test(e));return Object.assign({data:e.data,stepAccessor:t,valueAccessor:e.primary.y},e.primary.category&&e.primary.category!==t?{categoryAccessor:e.primary.category}:{})}},nh={component:"GaugeChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:2,precision:2},fits:e=>e.rowCount>1?"GaugeChart shows a single value — provide a 1-row dataset or use BarChart":e.primary.y?null:"needs a numeric value",intentScores:{"compare-categories":1,rank:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,o=e.data[0],n=o?Number(o[t]):0,i=e.fields[t],r="numeric"===(null==i?void 0:i.type)?i.max:100;return{value:Number.isFinite(n)?n:0,min:0,max:r}}},ih=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,rh={component:"LikertChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.primary.category?e.primary.y?Object.keys(e.fields).find(e=>ih.test(e))?null:"needs an ordinal rating/level field (rating, score, level...)":"needs a numeric rating/count field":"needs a category (question) field",intentScores:{"compare-categories":4,distribution:3,"part-to-whole":3},buildProps:e=>{const t=Object.keys(e.fields).find(e=>ih.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:[...Ha]}}},sh={component:"SwimlaneChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{var t;return e.primary.category?e.primary.series?e.primary.y?2>(null!==(t=e.categoryCount)&&void 0!==t?t:0)?"needs 2+ categories":null:"needs a numeric value field":"needs a sub-category (lane) field":"needs a category field"},intentScores:{"compare-categories":4,"composition-over-time":e=>e.hasTimeAxis?3:1,"compare-series":3},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,subcategoryAccessor:e.primary.series,valueAccessor:e.primary.y,colorBy:e.primary.series})},ah={component:"Histogram",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{if(10>e.rowCount)return"histograms need at least ~10 observations";if(!e.primary.y)return"needs a numeric field to bin";const t=e.primary.y,o=e.candidates.y.find(e=>e.field===t);return void 0!==(null==o?void 0:o.distinctCount)&&6>o.distinctCount?"too few distinct numeric values; a bar chart of counts is a better fit":null},intentScores:{distribution:5,"outlier-detection":3,"compare-categories":1},variants:[{key:"count-bins",label:"Count bins",props:{bins:10,relative:!1},tags:["count"]},{key:"share-bins",label:"Share bins (relative)",props:{bins:10,relative:!0},tags:["share"],intentDeltas:{distribution:0}}],buildProps:(e,t)=>{var o;return Object.assign({data:e.data,valueAccessor:e.primary.y},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},lh={component:"BoxPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{var t;return e.primary.y?e.primary.category?3>e.rowCount/Math.max(null!==(t=e.categoryCount)&&void 0!==t?t:1,1)?"needs 3+ observations per category":null:"needs a category to split distributions":"needs a numeric field"},intentScores:{distribution:5,"compare-categories":4,"outlier-detection":4},buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},ch={component:"SwarmPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:4},fits:e=>{var t;return e.primary.y?e.primary.category?4>e.rowCount/Math.max(null!==(t=e.categoryCount)&&void 0!==t?t:1,1)?"needs 4+ observations per category":e.rowCount>2e3?"too many points for a swarm — consider a violin or box":null:"needs a category":"needs a numeric field"},intentScores:{distribution:4,"outlier-detection":5,"compare-categories":3},buildProps:e=>Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},e.primary.series&&e.primary.series!==e.primary.category?{colorBy:e.primary.series}:{})},uh={component:"ViolinPlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>{var t;return e.primary.y?e.primary.category?6>e.rowCount/Math.max(null!==(t=e.categoryCount)&&void 0!==t?t:1,1)?"needs 6+ observations per category":null:"needs a category to split distributions":"needs a numeric field"},intentScores:{distribution:5,"compare-categories":4},variants:[{key:"density",label:"Density only",props:{showIQR:!1},tags:["density"]},{key:"density-iqr",label:"Density with IQR",props:{showIQR:!0},tags:["density","iqr"],intentDeltas:{distribution:0},rubricDeltas:{precision:1}}],buildProps:(e,t)=>{var o;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}},dh={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},fits:e=>{var t,o;return e.primary.y?e.primary.category?3>(null!==(t=e.categoryCount)&&void 0!==t?t:0)?"needs 3+ categories to make a ridgeline meaningful":6>e.rowCount/Math.max(null!==(o=e.categoryCount)&&void 0!==o?o:1,1)?"needs 6+ observations per category":null:"needs a category dimension to stack distributions":"needs a numeric field"},intentScores:{distribution:4,"compare-categories":3,"composition-over-time":2},caveats:()=>["readers can confuse overlapping ridges — limit categories or use small multiples"],buildProps:e=>({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y})},hh={component:"ForceDirectedGraph",family:"network",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.nodes.length?"needs at least 2 nodes":1>e.network.edges.length?"needs at least 1 edge":null:"needs a {nodes, edges} network passed via rawInput",intentScores:{flow:3,correlation:2},caveats:e=>{var t,o;return(null!==(o=null===(t=e.network)||void 0===t?void 0:t.nodes.length)&&void 0!==o?o:0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[]},buildProps:e=>{var t,o,n,i;return{nodes:null!==(o=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==o?o:[],edges:null!==(i=null===(n=e.network)||void 0===n?void 0:n.edges)&&void 0!==i?i:[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}}},gh={component:"SankeyDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.hasNetwork&&e.network?2>e.network.edges.length?"needs 2+ weighted edges":null:"needs a {nodes, edges} network with edge weights",intentScores:{flow:5,"part-to-whole":3},buildProps:e=>{var t,o,n,i;return{nodes:null!==(o=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==o?o:[],edges:null!==(i=null===(n=e.network)||void 0===n?void 0:n.edges)&&void 0!==i?i:[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"}}},fh={component:"ChordDiagram",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.hasNetwork&&e.network?3>e.network.nodes.length?"needs 3+ nodes":3>e.network.edges.length?"needs 3+ edges":null:"needs a {nodes, edges} network",intentScores:{flow:4},caveats:()=>["chord diagrams trade accuracy for symmetry; use Sankey if direction matters"],buildProps:e=>{var t,o,n,i;return{nodes:null!==(o=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==o?o:[],edges:null!==(i=null===(n=e.network)||void 0===n?void 0:n.edges)&&void 0!==i?i:[],valueAccessor:"value"}}},ph={component:"ProcessSankey",family:"flow",importPath:"semiotic/network",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>{if(!e.hasNetwork||!e.network)return"needs a {nodes, edges} network";const t=e.network.edges[0];return t?void 0===t.startTime&&void 0===t.start||void 0===t.endTime&&void 0===t.end?"edges need both startTime and endTime (or start/end) for a temporal sankey":null:"needs at least one edge with start/end times"},intentScores:{flow:5,"composition-over-time":4,"change-detection":3},buildProps:e=>{var t,o,n,i,r;const s={nodes:null!==(o=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==o?o:[],edges:null!==(i=null===(n=e.network)||void 0===n?void 0:n.edges)&&void 0!==i?i:[],pairing:"temporal",laneOrder:"crossing-min"},a=null===(r=e.network)||void 0===r?void 0:r.edges[0];return a&&(void 0===a.startTime&&void 0!==a.start&&(s.startTimeAccessor="start"),void 0===a.endTime&&void 0!==a.end&&(s.endTimeAccessor="end")),s}},yh={component:"TreeDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root (object with children) via rawInput",intentScores:{hierarchy:5},variants:[{key:"vertical-tree",label:"Vertical tree",props:{layout:"tree",orientation:"vertical"},tags:["vertical"]},{key:"horizontal-cluster",label:"Horizontal cluster",props:{layout:"cluster",orientation:"horizontal"},tags:["horizontal"]}],buildProps:(e,t)=>{var o,n;return Object.assign({data:null!==(o=e.hierarchy)&&void 0!==o?o:{name:"root",children:[]}},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})}},mh={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":4,"compare-categories":3},caveats:()=>["rectangle area comparisons are less precise than length — prefer a bar chart for ranking"],buildProps:e=>{var t;return{data:null!==(t=e.hierarchy)&&void 0!==t?t:{name:"root",children:[]},valueAccessor:"value"}}},vh={component:"CirclePack",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:3,accuracy:3,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":3},caveats:()=>["circle area is harder to compare than rectangle area"],buildProps:e=>{var t;return{data:null!==(t=e.hierarchy)&&void 0!==t?t:{name:"root",children:[]},valueAccessor:"value"}}},bh={component:"OrbitDiagram",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:1,accuracy:2,precision:2},fits:e=>e.hasHierarchy&&e.hierarchy?null:"needs a hierarchical root",intentScores:{hierarchy:3},caveats:()=>["decorative — readers without context will not infer hierarchy easily"],buildProps:e=>{var t;return{data:null!==(t=e.hierarchy)&&void 0!==t?t:{name:"root",children:[]},orbitMode:"solar"}}},xh={component:"ChoroplethMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:4,accuracy:3,precision:2},fits:e=>e.hasGeo&&e.geo?1>e.geo.features.length?"needs at least 1 area feature":null:"needs a GeoJSON FeatureCollection via rawInput",intentScores:{geo:5,"compare-categories":3},caveats:()=>["large areas dominate visual weight regardless of measurement"],buildProps:e=>{var t,o,n;return{areas:null!==(o=null===(t=e.geo)||void 0===t?void 0:t.features)&&void 0!==o?o:[],valueAccessor:null!==(n=e.primary.y)&&void 0!==n?n:"value"}}},kh={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>{var t,o,n;return e.hasGeo&&e.geo?(null!==(o=null===(t=e.geo.points)||void 0===t?void 0:t.length)&&void 0!==o?o:0)>0||0!==(null!==(n=e.geo.features.length)&&void 0!==n?n:0)?null:"needs points or area features":"needs a GeoJSON FeatureCollection (with points or area centroids)"},intentScores:{geo:4,rank:3,"compare-categories":3},buildProps:e=>{var t,o,n,i,r;return{points:null!==(o=null===(t=e.geo)||void 0===t?void 0:t.points)&&void 0!==o?o:[],areas:null!==(i=null===(n=e.geo)||void 0===n?void 0:n.features)&&void 0!==i?i:void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:null!==(r=e.primary.size)&&void 0!==r?r:"value"}}},wh={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>{var t,o;return e.hasGeo&&e.geo?(null===(t=e.geo.flows)||void 0===t?void 0:t.length)?(null===(o=e.geo.points)||void 0===o?void 0:o.length)?null:"needs point nodes with lat/lon":"needs flow records (source/target/value)":"needs a geo dataset"},intentScores:{geo:4,flow:5},buildProps:e=>{var t,o,n,i;return{flows:null!==(o=null===(t=e.geo)||void 0===t?void 0:t.flows)&&void 0!==o?o:[],nodes:null!==(i=null===(n=e.geo)||void 0===n?void 0:n.points)&&void 0!==i?i:[],valueAccessor:"value"}}},Ah={component:"DistanceCartogram",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:1,accuracy:3,precision:3},fits:e=>{var t;return e.hasGeo&&e.geo?(null===(t=e.geo.points)||void 0===t?void 0:t.length)?null:"needs point nodes with lat/lon and a cost field":"needs a geo dataset"},intentScores:{geo:3,rank:3,"compare-categories":2},caveats:()=>["non-standard projection — requires explanation for most readers"],buildProps:e=>{var t,o;return{points:null!==(o=null===(t=e.geo)||void 0===t?void 0:t.points)&&void 0!==o?o:[],costAccessor:"cost"}}},jh=[Ed,Id,Hd,Fd,$d,Wd,zd,Gd,Yd,qd,Xd,Vd,Ud,Kd,Qd,Zd,Jd,eh,oh,nh,rh,sh,ah,lh,ch,uh,dh,hh,gh,fh,ph,yh,mh,vh,bh,xh,kh,wh,Ah],Sh=new Map;function Ch(){if(0===Sh.size)return jh;const e=new Map;for(const t of jh)e.set(t.component,t);for(const[t,o]of Sh)e.set(t,o);return Array.from(e.values())}function Oh(e){return Ch().find(t=>t.component===e)}function Mh(e,t,o,n){var i,r,s;if(!n)return{score:e,rubric:t};const a=null===(i=n.familiarity)||void 0===i?void 0:i[o],l=null!=a?a:t.familiarity,c=null===(r=n.targets)||void 0===r?void 0:r[o];let u,d=0;if(void 0!==a&&(d+=.5*(a-3)),c){const e=Math.max(1,Math.min(3,null!==(s=c.weight)&&void 0!==s?s:1));d+=1*("increase"===c.direction?1:-1)*e,u=c.reason?`${n.name?n.name+": ":""}${c.reason}`:`${n.name?n.name+" ":""}target: ${c.direction} ${o}`}return{score:e+d,rubric:Object.assign(Object.assign({},t),{familiarity:l}),appliedReason:u}}function Ph(e,t,o){var n,i;return o&&null!==(i=null===(n=o.familiarity)||void 0===n?void 0:n[e])&&void 0!==i?i:t}function _h(e){return e&&2===e.exposureLevel?4:3}function Lh(e,t){if(void 0===e)return 0;const o="function"==typeof e?e(t):e;return Number.isFinite(o)?Math.max(0,Math.min(5,o)):0}function Th(e,t){var o;if(!(null==t?void 0:t.intentDeltas))return e;const n=Object.assign({},e);for(const[e,i]of Object.entries(t.intentDeltas)){const t=null!==(o=n[e])&&void 0!==o?o:0;n[e]=Math.max(0,Math.min(5,t+i))}return n}function Rh(e,t){var o,n,i;return(null==t?void 0:t.rubricDeltas)?function(e){const t=e=>Math.max(1,Math.min(5,Math.round(e)));return{familiarity:t(e.familiarity),accuracy:t(e.accuracy),precision:t(e.precision)}}({familiarity:e.familiarity+(null!==(o=t.rubricDeltas.familiarity)&&void 0!==o?o:0),accuracy:e.accuracy+(null!==(n=t.rubricDeltas.accuracy)&&void 0!==n?n:0),precision:e.precision+(null!==(i=t.rubricDeltas.precision)&&void 0!==i?i:0)}):e}function Bh(e,t,o,n){var i;const r=[],s=n.map(e=>{var t;return{intent:e,score:null!==(t=o[e])&&void 0!==t?t:0}}).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of s)r.push(`Strong fit for ${e} (${t}/5)`);return t.primary.x&&t.primary.y&&r.push(`x = ${t.primary.x}, y = ${t.primary.y}`),t.seriesCount&&t.seriesCount>1&&r.push(`${t.seriesCount} series detected on field "${null!==(i=t.primary.series)&&void 0!==i?i:"series"}"`),r}function Nh(e,t){var o;if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let n=0;for(const i of t)n+=null!==(o=e[i])&&void 0!==o?o:0;return n/t.length}function Dh(e,t={}){var o,n,i,r,s;const a=null!==(o=t.profile)&&void 0!==o?o:Dd(null!=e?e:[],{rawInput:t.rawInput,seriesField:t.seriesField}),l=null!==(n=t.capabilities)&&void 0!==n?n:Ch(),c=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],u=!1!==t.includeVariants,d=null!==(i=t.minScore)&&void 0!==i?i:0,h=null!==(r=t.maxResults)&&void 0!==r?r:10,g=t.allow?new Set(t.allow):null,f=t.deny?new Set(t.deny):null,p=[];for(const e of l){if(g&&!g.has(e.component))continue;if(f&&f.has(e.component))continue;if(null!==e.fits(a))continue;const o={};for(const[t,n]of Object.entries(e.intentScores))o[t]=Lh(n,a);const n=e.caveats?Array.from(e.caveats(a)):[],i=u&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const r of i){const i=Th(o,r),l=Mh(Nh(i,c),Rh(e.rubric,r),e.component,t.audience);if(d>l.score)continue;const u=Bh(0,a,i,c);l.appliedReason&&u.push(l.appliedReason);const h=[...n,...null!==(s=null==r?void 0:r.caveats)&&void 0!==s?s:[]],g=e.buildProps(a,r);p.push({component:e.component,family:e.family,importPath:e.importPath,variant:r,score:l.score,intentScores:i,rubric:l.rubric,reasons:u,caveats:h,props:g})}}return p.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),p.slice(0,h)}function Eh(e,t={}){var o,n;const i=null!==(o=t.profile)&&void 0!==o?o:Dd(null!=e?e:[],{rawInput:t.rawInput,seriesField:t.seriesField}),r=null!==(n=t.capabilities)&&void 0!==n?n:Ch(),s=t.allow?new Set(t.allow):null,a=t.deny?new Set(t.deny):null,l=[];for(const e of r){if(s&&!s.has(e.component))continue;if(a&&a.has(e.component))continue;const t=e.fits(i);null!==t&&l.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:Dh(e,Object.assign(Object.assign({},t),{profile:i})),rejected:l,profile:i}}const Ih=["hover","hover-end","click","click-end","selection","selection-end","brush-end"],Hh=[{intent:"outlier-detection",weight:4,patterns:[/\b(outlier|outliers|anomal|anomaly|anomalies|extreme|extremes|unusual|stands? out|sticks? out|odd one)\b/i,/\b(peak|peaks|highest|lowest|biggest spike|spike|min|max|maximum|minimum)\b/i]},{intent:"trend",weight:4,patterns:[/\b(trend|trends|trending|trajectory|over time|across time|growth|decline|rising|falling|increasing|decreasing)\b/i,/\b(history|historical|evolved|evolution|change over)\b/i]},{intent:"change-detection",weight:3,patterns:[/\b(when did|what changed|shift|shifted|breakpoint|inflection|turning point|sudden|abrupt)\b/i]},{intent:"rank",weight:4,patterns:[/\b(rank|ranking|ranked|biggest|smallest|largest|order by|sorted|best|worst|leaderboard)\b/i,/\btop\s+(\d+|sellers?|performers?|picks?|results?|categories|items?)\b/i,/\bbottom\s+(\d+|results?|items?)\b/i,/\b(who has the most|which.*most|which.*highest|which.*lowest)\b/i]},{intent:"part-to-whole",weight:4,patterns:[/\b(share|shares|composition|portion|portions|fraction|percentage of|percent of|breakdown|make up|made up of|slice|slices)\b/i,/\b(part of|part to whole|piece of the pie|how much of)\b/i]},{intent:"composition-over-time",weight:5,patterns:[/\b(composition.*time|share.*over time|share.*across|how.*mix.*changed|stacked.*time)\b/i,/\b(over time.*share|over time.*composition|over time.*breakdown)\b/i]},{intent:"distribution",weight:4,patterns:[/\b(distribution|distributions|spread|variance|variation|histogram|skew|skewed|range of|how.*spread|shape of|bell curve)\b/i,/\b(typical value|typical range|where do most|mode|median)\b/i]},{intent:"correlation",weight:4,patterns:[/\b(correl|correlation|relationship|related to|connected to|associated|connection between|relate to)\b/i,/\b(\w+ vs\.? \w+|\w+ versus \w+|\w+ against \w+|scatter)\b/i]},{intent:"compare-series",weight:3,patterns:[/\b(compare.*series|compare.*groups|compare.*cohorts|side by side|group.*vs|series.*vs)\b/i,/\b(how do.*compare|each group|each series|each cohort)\b/i]},{intent:"compare-categories",weight:3,patterns:[/\b(compare.*categor|category.*compar|which is bigger|how does.*compare|differences? between)\b/i]},{intent:"flow",weight:4,patterns:[/\b(flow|flows|transition|transitions|movement|moved from|funnel|conversion|drop[- ]off|sankey|chord)\b/i,/\b(from.*to|source.*target|path|journey|pipeline)\b/i]},{intent:"hierarchy",weight:4,patterns:[/\b(hierarchy|hierarchical|tree|nested|parent.*child|subcategory|sub-?categor|drill down|drilldown|breakdown by level)\b/i]},{intent:"geo",weight:5,patterns:[/\b(geographic|geography|geospatial|map|maps|country|countries|cities|latitude|longitude|spatial|cartogr|choropleth)\b/i,/\b(city|us state|each state|the states)\b/i,/\bacross\s+(countries|states|regions|cities|the world|the country)\b/i]}];function Fh(e,t={}){var o,n,i,r,s,a,l,c,u,d,h,g;const f=t.audience;if(!f)return[];const p=null!==(o=t.profile)&&void 0!==o?o:Dd(null!=e?e:[],{rawInput:t.rawInput}),y=_h(f),m=null!==(n=t.scoreTolerance)&&void 0!==n?n:1.5,v=null!==(i=t.maxResults)&&void 0!==i?i:5,b=Ch(),x=new Map;for(const e of b)x.set(e.component,Ph(e.component,e.rubric.familiarity,f));const k=Dh(e,{profile:p,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),w=k.filter(e=>{var t;return(null!==(t=x.get(e.component))&&void 0!==t?t:e.rubric.familiarity)>=4}),A=w[0],j=[];for(const e of k)(null!==(r=x.get(e.component))&&void 0!==r?r:e.rubric.familiarity)>y||("increase"===(null===(a=null===(s=f.targets)||void 0===s?void 0:s[e.component])||void 0===a?void 0:a.direction)||!A||m>=A.score-e.score)&&j.push({stretch:e,familiar:A});const S=new Set,C=[];for(const{stretch:e,familiar:t}of j){const o=`${e.component}/${null!==(c=null===(l=e.variant)||void 0===l?void 0:l.key)&&void 0!==c?c:"base"}`;if(S.has(o))continue;S.add(o);const n=null!==(u=x.get(e.component))&&void 0!==u?u:e.rubric.familiarity,i=null===(d=f.targets)||void 0===d?void 0:d[e.component],r=null!==(h=null==i?void 0:i.reason)&&void 0!==h?h:"increase"===(null==i?void 0:i.direction)?`${null!==(g=f.name)&&void 0!==g?g:"your audience"} is growing adoption of ${e.component}`:t?`${e.component} is on the data, and within reach of ${t.component} which you're already familiar with`:e.component+" fits this data and would expand your team's vocabulary";if(C.push({suggestion:e,replacing:null==t?void 0:t.component,rationale:r,familiarity:n}),C.length>=v)break}return C}const $h={name:"Executive",familiarity:{BarChart:5,LineChart:5,PieChart:5,DonutChart:4,GaugeChart:5,AreaChart:4,FunnelChart:4,ChoroplethMap:4,Histogram:3,Heatmap:3,StackedBarChart:3,StackedAreaChart:3,Scatterplot:3,BubbleChart:3,GroupedBarChart:3,DotPlot:3,BoxPlot:2,ViolinPlot:1,SwarmPlot:1,RidgelinePlot:1,MultiAxisLineChart:2,CandlestickChart:2,DifferenceChart:2,QuadrantChart:3,LikertChart:3,SwimlaneChart:2,MinimapChart:2,ConnectedScatterplot:1,SankeyDiagram:2,TreeDiagram:3,Treemap:3,CirclePack:2,OrbitDiagram:1,ChordDiagram:1,ProcessSankey:2,ForceDirectedGraph:1,ProportionalSymbolMap:3,FlowMap:2,DistanceCartogram:1},targets:{PieChart:{direction:"decrease",weight:1,reason:"shifting from share-by-angle toward share-by-length for accuracy"},BarChart:{direction:"increase",weight:1}},exposureLevel:1},Wh={name:"Analyst",familiarity:{BarChart:5,LineChart:5,PieChart:4,DonutChart:4,AreaChart:5,StackedAreaChart:4,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:4,BoxPlot:4,DotPlot:4,GaugeChart:3,FunnelChart:4,LikertChart:4,QuadrantChart:4,SwimlaneChart:4,MinimapChart:4,DifferenceChart:3,MultiAxisLineChart:4,CandlestickChart:3,ConnectedScatterplot:3,ViolinPlot:3,SwarmPlot:3,RidgelinePlot:2,TreeDiagram:4,Treemap:4,CirclePack:3,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:3,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:2},targets:{PieChart:{direction:"decrease",weight:1},BoxPlot:{direction:"increase",weight:1,reason:"team is shifting from averages to distribution-aware comparisons"}},exposureLevel:1},zh={name:"Data scientist",familiarity:{BarChart:5,LineChart:5,PieChart:3,DonutChart:3,AreaChart:5,StackedAreaChart:5,StackedBarChart:5,GroupedBarChart:5,Histogram:5,Heatmap:5,Scatterplot:5,BubbleChart:5,BoxPlot:5,ViolinPlot:5,SwarmPlot:4,RidgelinePlot:4,DotPlot:4,QuadrantChart:4,LikertChart:4,DifferenceChart:4,MultiAxisLineChart:4,ConnectedScatterplot:4,GaugeChart:2,FunnelChart:3,SwimlaneChart:3,MinimapChart:4,CandlestickChart:3,TreeDiagram:4,Treemap:4,CirclePack:4,SankeyDiagram:4,ProcessSankey:3,ChordDiagram:3,OrbitDiagram:2,ForceDirectedGraph:4,ChoroplethMap:4,ProportionalSymbolMap:4,FlowMap:3,DistanceCartogram:3},targets:{PieChart:{direction:"decrease",weight:2,reason:"preferring length-encoded comparisons for precision"},BarChart:{direction:"decrease",weight:1,reason:"promoting distribution-aware charts over single-value bars when raw observations are available"},BoxPlot:{direction:"increase",weight:1},ViolinPlot:{direction:"increase",weight:1}},exposureLevel:2},Gh={executive:$h,analyst:Wh,"data-scientist":zh},Yh={component:"RealtimeHeatmap",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field for the x axis",intentScores:{trend:e=>"high"===e.throughput?4:2,distribution:3,"change-detection":3,"compare-series":e=>e.fields.find(e=>"series"===e.role||"categorical"===e.kind&&"category"!==e.role)?4:1},buildProps:e=>{var t,o,n;const i=null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,r=null===(o=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind))||void 0===o?void 0:o.name,s=null===(n=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role))||void 0===n?void 0:n.name;return Object.assign({timeAccessor:i,valueAccessor:r},s?{categoryAccessor:s}:{})}},qh=[{component:"RealtimeLineChart",importPath:"semiotic/realtime",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"y"===e.role||"value"===e.role)?"high"===e.throughput?"for high-throughput streams, prefer RealtimeHeatmap or RealtimeWaterfallChart":null:"needs a numeric value field":"needs a date/time field for the x axis",intentScores:{trend:5,"change-detection":4,"outlier-detection":2},caveats:e=>{const t=[];return"cumulative"===e.retention&&t.push("cumulative retention will eventually exhaust the buffer — set a windowSize or downsample"),t},buildProps:e=>{var t,o;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(o=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind))||void 0===o?void 0:o.name}}},{component:"RealtimeHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric field to bin":"needs a time field",intentScores:{distribution:5,"outlier-detection":4,"change-detection":2},buildProps:e=>{var t,o;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===o?void 0:o.name}}},{component:"RealtimeSwarmChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:4},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?e.fields.some(e=>"categorical"===e.kind||"category"===e.role)?null:"needs a category to swarm by":"needs a numeric field":"needs a time field (points are placed at (time, value))",intentScores:{"outlier-detection":5,distribution:4,"compare-categories":3},caveats:e=>"high"===e.throughput?["high-throughput swarms get crowded — consider RealtimeHistogram"]:[],buildProps:e=>{var t,o,n;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===o?void 0:o.name,categoryAccessor:null===(n=e.fields.find(e=>"category"===e.role||"categorical"===e.kind))||void 0===n?void 0:n.name}}},{component:"RealtimeWaterfallChart",importPath:"semiotic/realtime",rubric:{familiarity:2,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?null:"needs a numeric value field":"needs a time field",intentScores:{"change-detection":5,trend:3,"outlier-detection":4,distribution:e=>"high"===e.throughput?4:2},buildProps:e=>{var t,o;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(o=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===o?void 0:o.name}}},Yh,{component:"TemporalHistogram",importPath:"semiotic/realtime",rubric:{familiarity:3,accuracy:4,precision:3},fits:e=>e.fields.some(e=>"date"===e.kind||"x"===e.role)?e.fields.some(e=>"numeric"===e.kind||"value"===e.role)?"windowed"===e.retention?"windowed retention is RealtimeHistogram's job; TemporalHistogram serves bounded/cumulative data":null:"needs a numeric value field":"needs a time field",intentScores:{distribution:5,"change-detection":3,trend:2},buildProps:e=>{var t,o;const n=null===(t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===t?void 0:t.name;return{timeAccessor:null===(o=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===o?void 0:o.name,valueAccessor:n}}}],Xh=new Map;function Vh(){if(0===Xh.size)return qh;const e=new Map;for(const t of qh)e.set(t.component,t);for(const[t,o]of Xh)e.set(t,o);return Array.from(e.values())}function Uh(e,t){if(void 0===e)return 0;const o="function"==typeof e?e(t):e;return Number.isFinite(o)?Math.max(0,Math.min(5,o)):0}function Kh(e,t){var o;if(0===t.length){const t=Object.values(e).filter(e=>"number"==typeof e&&e>0);return 0===t.length?0:t.reduce((e,t)=>e+t,0)/t.length}let n=0;for(const i of t)n+=null!==(o=e[i])&&void 0!==o?o:0;return n/t.length}function Qh(e,t,o){const n=[],i=o.map(e=>{var o;return{intent:e,score:null!==(o=t[e])&&void 0!==o?o:0}}).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of i)n.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&n.push(`tuned for ${e.throughput} throughput`),n}const Zh=["x","y","size","category","series","time"];function Jh(e,t){const o=e.fields[t];return o?"numeric"===o.type?"numeric":"categorical"===o.type?"categorical":"date"===o.type?"date":"unknown":"unknown"}function eg(e){const t=new Set;for(const o of Ch())null===o.fits(e)&&t.add(o.component);return t}const tg=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,o)=>e.map(e=>({month:e,revenue:800+e*(200+40*o)+150*Math.sin(e),region:t})))})(),og=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),ng=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],ig=Array.from({length:150},(e,t)=>({respondent_id:t+1,satisfaction:Math.max(1,Math.min(10,6+2*Math.sin(t/7)+3*Math.random()-1)),cohort:["Beta","GA","Enterprise"][t%3]})),rg=Array.from({length:80},(e,t)=>{const o=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:o,grade:Math.min(100,1.8*o+30+20*(Math.random()-.5))}}),sg=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),ag=[{product:"Widget",region:"EU",units:480},{product:"Widget",region:"NA",units:620},{product:"Widget",region:"APAC",units:290},{product:"Gadget",region:"EU",units:320},{product:"Gadget",region:"NA",units:740},{product:"Gadget",region:"APAC",units:410},{product:"Sprocket",region:"EU",units:200},{product:"Sprocket",region:"NA",units:380},{product:"Sprocket",region:"APAC",units:150},{product:"Whatsit",region:"EU",units:290},{product:"Whatsit",region:"NA",units:550},{product:"Whatsit",region:"APAC",units:180}],lg=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:tg,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:tg,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:tg,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:og,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:ng,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:ng,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:ig,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:ig,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:rg,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:rg,intent:"outlier-detection",expected:["Scatterplot"]},{name:"conversion funnel, intent=flow",shape:"4 stages, descending values",data:[{stage:"Visit",users:1e4},{stage:"Signup",users:2400},{stage:"Trial",users:1100},{stage:"Paid",users:380}],intent:"flow",expected:["FunnelChart"]},{name:"org chart, intent=hierarchy",shape:"3-deep org tree",data:[],rawInput:{name:"Acme",children:[{name:"Engineering",children:[{name:"Platform",value:18},{name:"Product",value:22}]},{name:"Sales",children:[{name:"EMEA",value:12},{name:"AMER",value:26}]},{name:"Ops",value:9}]},intent:"hierarchy",expected:["TreeDiagram","Treemap","CirclePack"]},{name:"approval workflow transitions, intent=flow",shape:"5 nodes / 4 weighted edges",data:[],rawInput:{nodes:[{id:"draft"},{id:"review"},{id:"approved"},{id:"shipped"},{id:"rejected"}],edges:[{source:"draft",target:"review",value:100},{source:"review",target:"approved",value:60},{source:"review",target:"rejected",value:40},{source:"approved",target:"shipped",value:58}]},intent:"flow",expected:["SankeyDiagram","ChordDiagram"]},{name:"US states with values, intent=geo",shape:"3 polygon features with numeric values",data:[],rawInput:{type:"FeatureCollection",features:[{type:"Feature",id:"CA",properties:{name:"California",value:39},geometry:{type:"Polygon",coordinates:[[[-124,32],[-114,32],[-114,42],[-124,42],[-124,32]]]}},{type:"Feature",id:"TX",properties:{name:"Texas",value:29},geometry:{type:"Polygon",coordinates:[[[-106,26],[-93,26],[-93,36],[-106,36],[-106,26]]]}},{type:"Feature",id:"NY",properties:{name:"New York",value:19},geometry:{type:"Polygon",coordinates:[[[-79,40],[-72,40],[-72,45],[-79,45],[-79,40]]]}}]},intent:"geo",expected:["ChoroplethMap","ProportionalSymbolMap"]},{name:"country economies, intent=correlation",shape:"10 countries × 3 numeric measures (gdp, hours, population)",data:[{country:"USA",gdp_per_capita:70,hours_worked:1700,population_size:330},{country:"UK",gdp_per_capita:48,hours_worked:1500,population_size:67},{country:"Germany",gdp_per_capita:53,hours_worked:1330,population_size:84},{country:"Japan",gdp_per_capita:40,hours_worked:1600,population_size:125},{country:"France",gdp_per_capita:45,hours_worked:1480,population_size:67},{country:"Italy",gdp_per_capita:38,hours_worked:1700,population_size:60},{country:"Spain",gdp_per_capita:32,hours_worked:1640,population_size:47},{country:"Canada",gdp_per_capita:52,hours_worked:1690,population_size:38},{country:"Australia",gdp_per_capita:56,hours_worked:1700,population_size:26},{country:"South Korea",gdp_per_capita:35,hours_worked:1900,population_size:52}],intent:"correlation",expected:["Scatterplot","BubbleChart"]},{name:"website metrics with 3 measures, intent=compare-series",shape:"24 months × 3 numeric measures with different ranges",data:Array.from({length:24},(e,t)=>({month:t+1,page_views:Math.round(5e4+1200*t+8e3*Math.sin(t/3)),conversion_rate:2.5+.8*Math.sin(t/4)+.05*t,avg_session_seconds:Math.round(120+2*t+15*Math.cos(t/5))})),intent:"compare-series",expected:["MultiAxisLineChart","LineChart"]},{name:"sales by region and product, intent=compare-series",shape:"12 rows = 4 products × 3 regions",data:ag,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:ag,intent:"part-to-whole",expected:["StackedBarChart","PieChart"]},{name:"revenue vs expenses, intent=compare-series",shape:"48 rows = 24 months × 2 series",data:[...Array.from({length:24},(e,t)=>({month:t+1,amount:100+8*t+25*Math.sin(t/3),series:"revenue"})),...Array.from({length:24},(e,t)=>({month:t+1,amount:80+6*t+15*Math.cos(t/4),series:"expenses"}))],intent:"compare-series",expected:["DifferenceChart","LineChart","GroupedBarChart"]},{name:"stock OHLC prices, intent=change-detection",shape:"30 days × open/high/low/close",data:Array.from({length:30},(e,t)=>{const o=100+1.2*t+8*Math.sin(t/4),n=o+4*(Math.random()-.5),i=o+4*(Math.random()-.5);return{day:t+1,open:n,high:Math.max(n,i)+3*Math.random(),low:Math.min(n,i)-3*Math.random(),close:i}}),intent:"change-detection",expected:["CandlestickChart","LineChart"]},{name:"unemployment vs inflation by year, intent=correlation",shape:"20 years × 2 measures, ordered by year",data:Array.from({length:20},(e,t)=>({year:2005+t,unemployment:5+2*Math.sin(t/2)+(t>4&&10>t?3:0),inflation:2+1.5*Math.cos(t/3)})),intent:"correlation",expected:["ConnectedScatterplot","Scatterplot"]},{name:"transition events, intent=flow",shape:"11 stage transitions across 3 deals with startTime + value",data:[{case:"deal-001",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T09:00:00",value:18},{case:"deal-001",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-01T13:00:00",value:16},{case:"deal-001",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-02T11:00:00",value:14},{case:"deal-001",stage:"Proposal",nextStage:"Closed Won",startTime:"2024-04-04T09:00:00",value:12},{case:"deal-002",stage:"Inbound Lead",nextStage:"Qualified",startTime:"2024-04-01T10:00:00",value:10},{case:"deal-002",stage:"Qualified",nextStage:"Discovery",startTime:"2024-04-02T09:00:00",value:9},{case:"deal-002",stage:"Discovery",nextStage:"Proposal",startTime:"2024-04-03T09:00:00",value:7},{case:"deal-002",stage:"Proposal",nextStage:"Closed Lost",startTime:"2024-04-04T11:00:00",value:5},{case:"deal-003",stage:"Signup",nextStage:"Activated",startTime:"2024-04-01T08:30:00",value:28},{case:"deal-003",stage:"Activated",nextStage:"Trial",startTime:"2024-04-01T10:00:00",value:24},{case:"deal-003",stage:"Trial",nextStage:"Subscribed",startTime:"2024-04-02T10:00:00",value:18}],intent:"flow",expected:["SankeyDiagram","ProcessSankey","ChordDiagram"]},{name:"flat single column",shape:"50 rows, one numeric column",data:sg,expected:["Histogram"]},{name:"sparse 3-row data, intent=rank",shape:"3 rows total",data:[{name:"A",value:12},{name:"B",value:34},{name:"C",value:8}],intent:"rank",expected:["BarChart","DotPlot"]}],cg=[{id:"trend",label:"Trend over time",description:"How a single metric changes over an ordered sequence (typically time).",familyHint:"time-series"},{id:"compare-series",label:"Compare series",description:"Compare multiple measured series across a shared x domain.",familyHint:"time-series"},{id:"compare-categories",label:"Compare categories",description:"Compare a single measure across discrete categories.",familyHint:"categorical"},{id:"rank",label:"Rank",description:"Show category ordering by a measure (largest to smallest).",familyHint:"categorical"},{id:"part-to-whole",label:"Part to whole",description:"Show how individual categories share a total.",familyHint:"categorical"},{id:"distribution",label:"Distribution",description:"Show the shape, spread, and central tendency of a numeric variable.",familyHint:"distribution"},{id:"correlation",label:"Correlation",description:"Show the relationship between two (or more) numeric variables.",familyHint:"relationship"},{id:"flow",label:"Flow",description:"Show movement, transitions, or transfers between states.",familyHint:"flow"},{id:"hierarchy",label:"Hierarchy",description:"Show parent/child structure or nested totals.",familyHint:"hierarchy"},{id:"geo",label:"Geography",description:"Show values bound to geographic locations or regions.",familyHint:"geo"},{id:"outlier-detection",label:"Outlier detection",description:"Surface individual data points that diverge from the rest.",familyHint:"distribution"},{id:"composition-over-time",label:"Composition over time",description:"Show how the share of categories changes across an ordered sequence.",familyHint:"time-series"},{id:"change-detection",label:"Change detection",description:"Surface where or when a metric shifted meaningfully.",familyHint:"time-series"}],ug=new Map(cg.map(e=>[e.id,e])),dg=new Set(cg.map(e=>e.id));function hg(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)*(1-t)),i=Math.round(parseInt(o[2],16)*(1-t)),r=Math.round(parseInt(o[3],16)*(1-t));return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function gg(e,t=.5){const o=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!o)return e;const n=Math.round(parseInt(o[1],16)+(255-parseInt(o[1],16))*t),i=Math.round(parseInt(o[2],16)+(255-parseInt(o[2],16))*t),r=Math.round(parseInt(o[3],16)+(255-parseInt(o[3],16))*t);return`#${n.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}const fg="__forecastSegment";function pg(e,t){return"function"==typeof t?t(e):!!e[t]}const yg=Object.freeze({__proto__:null,SEGMENT_FIELD:fg,buildAnomalyAnnotations:function(e){var t,o,n;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(o=e.bandOpacity)&&void 0!==o?o:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(n=e.anomalyRadius)&&void 0!==n?n:6,label:e.label}]},buildForecast:function(e,t,o,n,i){return(r=n).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,o,n,i){var r,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}=n,b=e.map(e=>{let t="observed";return u&&pg(e,u)?t="forecast":c&&pg(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[fg]:t})}),x=n._groupBy,k=[];if(x){const e=new Map;for(const t of b){const o=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(o)||e.set(o,[]),e.get(o).push(t)}const t=[];for(const[,o]of e)for(let e=0;o.length-1>e;e++)o[e][fg]!==o[e+1][fg]&&(t.push(Object.assign(Object.assign({},o[e+1]),{[fg]:o[e][fg]})),t.push(Object.assign(Object.assign({},o[e]),{[fg]:o[e+1][fg]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][fg]!==b[e+1][fg]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[fg]:b[e][fg]})),k.push(Object.assign(Object.assign({},b[e]),{[fg]:b[e+1][fg]})));if(n.trainUnderline){const e=[];for(const t of k)"training"===t[fg]&&e.push(Object.assign(Object.assign({},t),{[fg]:"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 o of k)"function"==typeof h&&(o[e]=h(o)),"function"==typeof g&&(o[t]=g(o));w.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:f,fillOpacity:p,label:v})}if(d){const e=n.anomalyStyle,t={type:"highlight",filter:e=>pg(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,n,i):function(e,t,o,n,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:g}=n;if(null==l)return{processedData:e,annotations:[]};const f=[],p=[];for(const o of e)o[t]>l?p.push(Object.assign(Object.assign({},o),{[fg]:"observed"})):f.push(Object.assign(Object.assign({},o),{[fg]:"training"}));const y=f.map(e=>[e[t],e[o]]).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 n=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=n*s-i*i;if(Math.abs(l)>1e-12){const s=(n*a-i*r)/l,f=(r-s*i)/n,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(n-2,1)),k=y.reduce((e,t)=>e+t[0],0)/n,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,j=e.map(e=>e[t]).filter(e=>null!=e&&isFinite(e)),S=Math.max(...j),C=y.length>1?(y[n-1][0]-y[0][0])/(n-1):1;for(let e=1;c>=e;e++){const i=S+e*C,r=p(i),s=x*Math.sqrt(1+1/n+(w>0?Math.pow(i-k,2)/w:0))*A;v.push({[t]:i,[o]:r,[fg]:"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(...f),f.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},f[f.length-1]),{[fg]:"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),{[fg]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,o,n,i);var r},createSegmentLineStyle:function(e,t){var o,n;const i=null!==(o=t.trainDasharray)&&void 0!==o?o:"8,4",r=null!==(n=t.forecastDasharray)&&void 0!==n?n:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const o=e(t),n=t[fg];if("training"===n){let e=o.stroke;return"darken"===c?e=hg(o.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===n){let e=o.stroke||"#666";return"lighten"===d&&(e=gg(e,.4)),Object.assign(Object.assign({},o),{stroke:e,strokeDasharray:void 0})}return"forecast"===n?Object.assign(Object.assign(Object.assign({},o),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):o}},darkenColor:hg,lightenColor:gg});exports.AreaChart=Yr,exports.AreaChartCapability=Id,exports.BUILT_IN_AUDIENCES=Gh,exports.BUILT_IN_INTENT_IDS=dg,exports.BarChart=ua,exports.BarChartCapability=Ud,exports.BoxPlot=ya,exports.BoxPlotCapability=lh,exports.BubbleChart=ts,exports.BubbleChartCapability=Wd,exports.CANONICAL_FIXTURES=lg,exports.CandlestickChart=js,exports.CandlestickChartCapability=Xd,exports.CategoryColorProvider=li,exports.ChartContainer=Wu,exports.ChartGrid=Gu,exports.ChordDiagram=Fc,exports.ChordDiagramCapability=fh,exports.ChoroplethMapCapability=xh,exports.CirclePack=ru,exports.CirclePackCapability=vh,exports.ConnectedScatterplot=es,exports.ConnectedScatterplotCapability=$d,exports.ContextLayout=Yu,exports.DetailsPanel=qu,exports.DifferenceChart=Xr,exports.DifferenceChartCapability=qd,exports.DistanceCartogramCapability=Ah,exports.DonutChart=Aa,exports.DonutChartCapability=eh,exports.DotPlot=xa,exports.DotPlotCapability=Zd,exports.FlowMapCapability=wh,exports.ForceDirectedGraph=Hc,exports.ForceDirectedGraphCapability=hh,exports.FunnelChart=La,exports.FunnelChartCapability=oh,exports.GaugeChart=_a,exports.GaugeChartCapability=nh,exports.GroupedBarChart=ha,exports.GroupedBarChartCapability=Kd,exports.Heatmap=os,exports.HeatmapCapability=Vd,exports.Histogram=va,exports.HistogramCapability=ah,exports.LikertChart=$a,exports.LikertChartCapability=rh,exports.LineChart=Hr,exports.LineChartCapability=Ed,exports.LinkedCharts=_i,exports.MinimapChart=hs,exports.MinimapChartCapability=Yd,exports.MultiAxisLineChart=As,exports.MultiAxisLineChartCapability=Gd,exports.MultiLineTooltip=function(t={}){const{fields:o=[],title:n,format:i,style:r={},className:s="",showLabels:a=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(n){const e=mn(t,n);c.push({value:vn(e,i)})}o&&Array.isArray(o)&&o.length>0?o.forEach(e=>{let o,n,r;"string"==typeof e?(o=e,n=e,r=i):(o=e.label,n=e.accessor||e.key||"",r=e.format||i);const s=vn(mn(t,n),r);c.push({label:a?o:void 0,value:s})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:a?e:void 0,value:vn(t[e],i)})});const u=Object.assign(Object.assign({},yn),r);return Array.isArray(c)&&0!==c.length?e.jsx("div",{className:("semiotic-tooltip semiotic-tooltip-multiline "+s).trim(),style:u,children:c.map((t,o)=>e.jsxs("div",{style:{marginBottom:c.length-1>o?"4px":0},children:[t.label&&e.jsxs("strong",{children:[t.label,l]}),t.value]},o))}):null}},exports.OrbitDiagram=au,exports.OrbitDiagramCapability=bh,exports.PieChart=wa,exports.PieChartCapability=Jd,exports.ProcessSankey=ou,exports.ProcessSankeyCapability=ph,exports.ProportionalSymbolMapCapability=kh,exports.QuadrantChart=vs,exports.QuadrantChartCapability=zd,exports.RealtimeHeatmap=xu,exports.RealtimeHistogram=yu,exports.RealtimeLineChart=fu,exports.RealtimeSwarmChart=vu,exports.RealtimeWaterfallChart=bu,exports.RidgelinePlot=ka,exports.RidgelinePlotCapability=dh,exports.SankeyDiagram=$c,exports.SankeyDiagramCapability=gh,exports.Scatterplot=Zr,exports.ScatterplotCapability=Fd,exports.ScatterplotMatrix=us,exports.StackedAreaChart=Vr,exports.StackedAreaChartCapability=Hd,exports.StackedBarChart=da,exports.StackedBarChartCapability=Qd,exports.SwarmPlot=fa,exports.SwarmPlotCapability=ch,exports.SwimlaneChart=Wa,exports.SwimlaneChartCapability=sh,exports.TemporalHistogram=mu,exports.ThemeProvider=function({theme:t,children:o}){const n="string"==typeof t&&Ni(t)?t:void 0,i=p.useMemo(()=>function(e){return void 0!==e?L(M,Ii(e)):"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(forced-colors: active)").matches?_:M}(t),[t]);return e.jsx(T,{initialState:{theme:i},children:e.jsxs(Di.Provider,{value:n,children:[e.jsx(Hi,{theme:t}),e.jsx(Fi,{children:o})]})})},exports.TooltipProvider=ku,exports.TreeDiagram=nu,exports.TreeDiagramCapability=yh,exports.Treemap=iu,exports.TreemapCapability=mh,exports.ViolinPlot=ba,exports.ViolinPlotCapability=uh,exports.analystPersona=Wh,exports.applyAudienceBias=Mh,exports.configToJSX=Eu,exports.copyConfig=Du,exports.dataScientistPersona=zh,exports.deserializeSelections=function(e){const t=new Map;for(const[o,n]of Object.entries(e)){const e=new Map;for(const t of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:new Set(n.values)}:{type:"interval",range:n.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:o})}t.set(o,{name:n.name,resolution:n.resolution,clauses:e})}return t},exports.diagnoseConfig=function(e,t){const o=[],n=Tu(e,t);for(const e of n.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return _u[e]?(function(e,t,o){const n=_u[e];if(n){if("array"===n.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&o.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"===n.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&o.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,o),function(e,t,o){const n=t.width,i=t.height;if(void 0===n||"number"==typeof n&&n>0||o.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(n)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||o.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,n]=t.size;(null!=e&&0>=e||null!=n&&0>=n)&&o.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${n}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,o),function(e,t,o){const n=_u[e];if(!n||"array"!==n.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 n.dataAccessors){const n=t[e];"string"==typeof n&&(n in r||o.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${n}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,o),function(e,t,o){Vu.has(e)&&Array.isArray(t.data)&&o.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,o),function(e,t,o){Uu.has(e)&&(t.edges||t.data||o.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,o),function(e,t,o){const n=_u[e];if(!n||"array"!==n.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&&o.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,o),function(e,t,o){t.linkedHover&&!t.selection&&o.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,o),function(e,t,o){var n;if(!Ku.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&o.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!==(n=i[1])&&void 0!==n?n:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,o),function(e,t,o){if(!Qu.has(e))return;if(t.gapStrategy)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=t.yAccessor||"y";"string"==typeof i&&n.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&o.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,o),function(e,t,o){var n,i;const r=null!==(n=t.width)&&void 0!==n?n: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||o.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||o.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,o),function(e,t,o){var n;const i=_u[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 o=0;a>o;o++){const i=null===(n=r[o])||void 0===n?void 0:n[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&o.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,o),function(e,t,o){if(!Zu.has(e))return;const n=t.barPadding;"number"==typeof n&&10>n&&o.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${n} 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,o),function(e,t,o){if("bottom"!==t.legendPosition)return;const n=t.margin;if(!n||"object"!=typeof n)return;const i=n.bottom;"number"==typeof i&&70>i&&o.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,o),function(e,t,o){var n;if(!t.showLegend)return;if("right"!==(null!==(n=t.legendPosition)&&void 0!==n?n:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&o.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,o),function(e,t,o){if("Heatmap"!==e)return;const n=t.data;if(!n||!Array.isArray(n)||0===n.length)return;const i=n[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const n=t[e];if("string"!=typeof n)continue;const r=i[n];"string"==typeof r&&o.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${n}" 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,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ed(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&o.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,o),function(e,t,o){const n=t.colorScheme;if(!n||!Array.isArray(n)||2>n.length)return;const i=n.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=ed(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&o.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,o),function(e,t,o){const n="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;n||i||r||o.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,o),function(e,t,o){const n=[];for(const e of td)"function"==typeof t[e]&&n.push(e);n.length>0&&o.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${n.length>1?"s":""} detected: ${n.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,o),{ok:o.every(e=>"warning"===e.severity),diagnoses:o}):{ok:0===o.length,diagnoses:o}},exports.diffProfile=function(e,t){const o=new Set(Object.keys(e.fields)),n=new Set(Object.keys(t.fields)),i=[],r=[];for(const e of n)o.has(e)||i.push(e);for(const e of o)n.has(e)||r.push(e);i.sort(),r.sort();const s=[];for(const i of n){if(!o.has(i))continue;const n=Jh(e,i),r=Jh(t,i);n!==r&&s.push({field:i,from:n,to:r})}s.sort((e,t)=>e.field.localeCompare(t.field));const a=[];for(const o of Zh){const n=e.primary[o],i=t.primary[o];n!==i&&a.push({role:o,from:n,to:i})}const l=eg(e),c=eg(t),u=Array.from(l).filter(e=>!c.has(e)).sort(),d=Array.from(c).filter(e=>!l.has(e)).sort();return{rowCountChange:t.rowCount-e.rowCount,added:i,removed:r,typeChanges:s,primaryChanges:a,becameUnfit:u,becameFit:d,unchanged:0===i.length&&0===r.length&&0===s.length&&0===a.length&&0===u.length&&0===d.length&&e.rowCount===t.rowCount}},exports.effectiveFamiliarity=Ph,exports.executivePersona=$h,exports.explainCapabilityFit=Eh,exports.exportChart=wu,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!_u[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:Nu(e.props)}},exports.fromURL=function(e){const t=new URLSearchParams(e.includes("?")?e.split("?")[1]:e).get("sc");if(!t)throw Error("No chart config found in URL (missing 'sc' parameter)");const o=t.replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(escape(atob(o)));return JSON.parse(n)},exports.fromVegaLite=function(e){var t,o,n,i,r,s,a,l,c,u,d,h;const g=[],{type:f,markProps:p}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:Lr(e,["type"])}}(e.mark),y=e.encoding||{},m=y.x,v=y.y,b=y.color,x=y.size,k=y.theta,w=y.opacity;let A;(null===(t=e.data)||void 0===t?void 0:t.values)?A=e.data.values:(null===(o=e.data)||void 0===o?void 0:o.url)&&g.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&g.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&g.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&g.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||y.facet||y.row||y.column)&&g.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&g.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&g.push("Selections/params are not supported. Use Semiotic's LinkedCharts and selection props for interactivity.");const j={};e.width&&(j.width=e.width),e.height&&(j.height=e.height);const S=function(e){if(e)return"string"==typeof e?e:e.text}(e.title);if(S&&(j.title=S),(null==b?void 0:b.field)&&(j.colorBy=b.field,null===(n=b.scale)||void 0===n?void 0:n.scheme)){const e=id[b.scale.scheme];e&&(j.colorScheme=e)}void 0!==(null==w?void 0:w.value)&&(j.pointOpacity=w.value);const C=null==m?void 0:m.aggregate,O=null==v?void 0:v.aggregate;if(A&&(C||O)){const e=O?v:m,t=O?m:v,o=sd[e.aggregate];if(o&&(null==t?void 0:t.field)&&e.field)A=function(e,t){const{groupBy:o,value:n,agg:i="sum"}=t,r=new Map;for(const t of e){const e=t[o]+"";r.has(e)||r.set(e,[]),r.get(e).push(Number(t[n]))}const s=[];for(const[e,t]of r){let n;switch(i){case"count":n=t.length;break;case"mean":n=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":n=Math.min(...t);break;case"max":n=Math.max(...t);break;default:n=t.reduce((e,t)=>e+t,0)}s.push({[o]:e,value:n})}return s}(A,{groupBy:t.field,value:e.field,agg:o});else if(("count"===o||"count"===e.aggregate)&&(null==t?void 0:t.field)&&A){const e=new Map;for(const o of A){const n=o[t.field]+"";e.set(n,(e.get(n)||0)+1)}A=Array.from(e,([e,o])=>({[t.field]:e,value:o}))}}if((null==m?void 0:m.bin)||(null==v?void 0:v.bin)){const e="Histogram";A&&(j.data=A),(null==m?void 0:m.bin)?(j.valueAccessor=m.field,(null==v?void 0:v.field)&&(j.categoryAccessor=v.field),(null===(i=m.axis)||void 0===i?void 0:i.title)&&(j.valueLabel=m.axis.title)):(null==v?void 0:v.bin)&&(j.valueAccessor=v.field,(null==m?void 0:m.field)&&(j.categoryAccessor=m.field),(null===(r=v.axis)||void 0===r?void 0:r.title)&&(j.valueLabel=v.axis.title));const t=(null==m?void 0:m.bin)||(null==v?void 0:v.bin),o="object"==typeof t?t.maxbins:void 0;return o&&(j.bins=o),ld(e,j,g)}let M;switch(f){case"bar":M=function(e,t,o,n,i,r,s){var a,l,c,u,d,h;let g;return(null==o?void 0:o.field)&&!1!==(null==e?void 0:e.stack)&&!1!==(null==t?void 0:t.stack)&&null!==(null==e?void 0:e.stack)&&null!==(null==t?void 0:t.stack)?(g="StackedBarChart",n.stackBy=o.field):g="BarChart",od(null==e?void 0:e.type)&&nd(null==t?void 0:t.type)?(n.categoryAccessor=e.field,n.valueAccessor=s?"value":t.field,(null===(a=null==e?void 0:e.axis)||void 0===a?void 0:a.title)&&(n.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(n.valueLabel=t.axis.title)):nd(null==e?void 0:e.type)&&od(null==t?void 0:t.type)?(n.categoryAccessor=t.field,n.valueAccessor=r?"value":e.field,n.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(n.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(n.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(n.categoryAccessor=e.field),(null==t?void 0:t.field)&&(n.valueAccessor=s?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(n.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(n.valueLabel=t.axis.title)),i&&(n.data=i),g}(m,v,b,j,A,C,O);break;case"line":if(M="LineChart",ad(m,v,j,C,O),(null==b?void 0:b.field)&&(j.lineBy=b.field),p.interpolate){const e=rd[p.interpolate];e&&(j.curve=e)}!0===p.point&&(j.showPoints=!0),A&&(j.data=A);break;case"area":if((null==b?void 0:b.field)?(M="StackedAreaChart",j.areaBy=b.field):M="AreaChart",ad(m,v,j,C,O),p.interpolate){const e=rd[p.interpolate];e&&(j.curve=e)}void 0!==p.opacity&&(j.areaOpacity=p.opacity),A&&(j.data=A);break;case"point":case"circle":case"square":(null==x?void 0:x.field)?(M="BubbleChart",j.sizeBy=x.field,(null===(s=x.scale)||void 0===s?void 0:s.range)&&(j.sizeRange=x.scale.range)):M="Scatterplot",ad(m,v,j,C,O),A&&(j.data=A);break;case"rect":M="Heatmap",(null==m?void 0:m.field)&&(j.xAccessor=m.field),(null==v?void 0:v.field)&&(j.yAccessor=v.field),(null==b?void 0:b.field)&&(j.valueAccessor=b.field,delete j.colorBy),(null===(a=null==m?void 0:m.axis)||void 0===a?void 0:a.title)&&(j.xLabel=m.axis.title),(null===(l=null==v?void 0:v.axis)||void 0===l?void 0:l.title)&&(j.yLabel=v.axis.title),A&&(j.data=A);break;case"arc":p.innerRadius&&p.innerRadius>0?(M="DonutChart",j.innerRadius=p.innerRadius):M="PieChart",(null==k?void 0:k.field)?j.valueAccessor=k.field:(null==v?void 0:v.field)&&(j.valueAccessor=O?"value":v.field),(null==b?void 0:b.field)&&(j.categoryAccessor=b.field),(null==m?void 0:m.field)&&!(null==k?void 0:k.field)&&(j.categoryAccessor=m.field),A&&(j.data=A);break;case"tick":M="DotPlot",od(null==m?void 0:m.type)?(j.categoryAccessor=m.field,(null==v?void 0:v.field)&&(j.valueAccessor=O?"value":v.field),(null===(c=null==m?void 0:m.axis)||void 0===c?void 0:c.title)&&(j.categoryLabel=m.axis.title),(null===(u=null==v?void 0:v.axis)||void 0===u?void 0:u.title)&&(j.valueLabel=v.axis.title)):od(null==v?void 0:v.type)?(j.categoryAccessor=v.field,(null==m?void 0:m.field)&&(j.valueAccessor=C?"value":m.field),j.orientation="horizontal",(null===(d=null==v?void 0:v.axis)||void 0===d?void 0:d.title)&&(j.categoryLabel=v.axis.title),(null===(h=null==m?void 0:m.axis)||void 0===h?void 0:h.title)&&(j.valueLabel=m.axis.title)):((null==m?void 0:m.field)&&(j.categoryAccessor=m.field),(null==v?void 0:v.field)&&(j.valueAccessor=O?"value":v.field)),A&&(j.data=A);break;default:g.push(`Unsupported mark type "${f}". Defaulting to Scatterplot.`),M="Scatterplot",ad(m,v,j,C,O),A&&(j.data=A)}return ld(M,j,g)},exports.getCapabilities=Ch,exports.getCapability=Oh,exports.getIntent=function(e){return ug.get(e)},exports.getStreamCapabilities=Vh,exports.inferIntent=function(e){var t;if("string"!=typeof e||0===e.trim().length)return null;const o=new Map;for(const n of Hh)for(const i of n.patterns)if(i.test(e)){const e=null!==(t=o.get(n.intent))&&void 0!==t?t:0;o.set(n.intent,Math.min(5,0===e?n.weight:e+.5));break}if(0===o.size)return null;const n=Array.from(o.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[i,...r]=n;return{intent:i.intent,confidence:i.confidence,alternates:r}},exports.listIntents=function(){return Array.from(ug.values())},exports.profileData=Dd,exports.registerChartCapability=function(e){Sh.set(e.component,e)},exports.registerIntent=function(e){ug.set(e.id,e)},exports.registerStreamChartCapability=function(e){Xh.set(e.component,e)},exports.repairChartConfig=function(e,t,o={}){var n,i;const r=null!==(n=o.profile)&&void 0!==n?n:Dd(null!=t?t:[],{rawInput:o.rawInput}),s=Oh(e),a=null!==(i=o.maxAlternatives)&&void 0!==i?i:3;if(!s)return{status:"unknown",component:e,alternatives:Dh(t,{profile:r,intent:o.intent,maxResults:a,includeVariants:!1}),profile:r};const l=s.fits(r);return null===l?{status:"ok",component:e,profile:r}:{status:"alternative",component:e,reason:l,alternatives:Dh(t,{profile:r,intent:o.intent,maxResults:a,deny:[e],includeVariants:!1}),profile:r}},exports.runQualityScorecard=function(e,t=Ch()){var o,n,i,r,s,a,l,c;const u=new Map;for(const e of t)u.set(e.component,{component:e.component,family:e.family,fitsOn:0,rejectedOn:0,inTopThreeOn:0,expertAgreementCount:0,averageScore:0,caveatCoverage:0,variantUtilization:0});const d=new Map,h=new Map,g=new Map,f=new Map,p=[];for(const s of e){let e,a;try{e=Dd(s.data,{rawInput:s.rawInput}),a=Eh(s.data,{profile:e,intent:s.intent,capabilities:t,maxResults:40})}catch(e){p.push({fixture:s.name,shape:s.shape,intent:s.intent,expected:s.expected,topPick:void 0,topThree:[],fittingCount:0,rejectedCount:0,expertAgreement:!1,noFitHonored:null});continue}const l=a.fitting.slice(0,3).map(e=>{var t;return{component:e.component,variantKey:null===(t=e.variant)||void 0===t?void 0:t.key,score:e.score}}),c=s.expected&&s.expected.length>0?l.some(e=>s.expected.includes(e.component)):null;p.push({fixture:s.name,shape:s.shape,intent:s.intent,expected:s.expected,topPick:l[0],topThree:l,fittingCount:a.fitting.length,rejectedCount:a.rejected.length,expertAgreement:c,noFitHonored:!0===s.expectsNoFit?0===a.fitting.length:null});for(const e of a.fitting){const t=u.get(e.component);t&&(t.fitsOn+=1,d.set(e.component,(null!==(o=d.get(e.component))&&void 0!==o?o:0)+e.score),h.set(e.component,(null!==(n=h.get(e.component))&&void 0!==n?n:0)+1),e.caveats.length>0&&g.set(e.component,(null!==(i=g.get(e.component))&&void 0!==i?i:0)+1),e.variant&&f.set(e.component,(null!==(r=f.get(e.component))&&void 0!==r?r:0)+1))}for(const e of a.rejected){const t=u.get(e.component);t&&(t.rejectedOn+=1)}for(const e of l){const t=u.get(e.component);t&&(t.inTopThreeOn+=1)}if(s.expected&&c)for(const e of l)if(s.expected.includes(e.component)){const t=u.get(e.component);t&&(t.expertAgreementCount+=1)}}for(const e of u.values()){const t=null!==(s=h.get(e.component))&&void 0!==s?s:0;e.averageScore=0===t?0:(null!==(a=d.get(e.component))&&void 0!==a?a:0)/t,e.caveatCoverage=0===t?0:(null!==(l=g.get(e.component))&&void 0!==l?l:0)/t,e.variantUtilization=0===t?0:(null!==(c=f.get(e.component))&&void 0!==c?c:0)/t}const y=Array.from(u.values()).sort((e,t)=>{const o=e.expertAgreementCount-t.expertAgreementCount;return 0!==o?o:t.fitsOn-e.fitsOn}),m=p.filter(e=>null!==e.expertAgreement),v=0===m.length?0:m.filter(e=>!0===e.expertAgreement).length/m.length,b=Array.from(h.values()).reduce((e,t)=>e+t,0),x=Array.from(g.values()).reduce((e,t)=>e+t,0),k=Array.from(f.values()).reduce((e,t)=>e+t,0);return{perCapability:y,perFixture:p,summary:{fixtureCount:e.length,capabilityCount:t.length,expertAgreementRate:v,overallCaveatCoverage:0===b?0:x/b,overallVariantUtilization:0===b?0:k/b}}},exports.scoreChart=function(e,t,o={}){var n,i,r;const s=Ch().find(t=>t.component===e);if(!s)return{reason:`No capability registered for "${e}"`};const a=null!==(n=o.profile)&&void 0!==n?n:Dd(null!=t?t:[]),l=s.fits(a);if(null!==l)return{reason:l};const c=o.variantKey?null===(i=s.variants)||void 0===i?void 0:i.find(e=>e.key===o.variantKey):void 0,u=o.intent?Array.isArray(o.intent)?o.intent:[o.intent]:[],d={};for(const[e,t]of Object.entries(s.intentScores))d[e]=Lh(t,a);const h=Th(d,c),g=Nh(h,u),f=Rh(s.rubric,c),p=Bh(0,a,h,u),y=[...s.caveats?s.caveats(a):[],...null!==(r=null==c?void 0:c.caveats)&&void 0!==r?r:[]];return{component:s.component,family:s.family,importPath:s.importPath,variant:c,score:g,intentScores:h,rubric:f,reasons:p,caveats:y,props:s.buildProps(a,c)}},exports.serializeSelections=function(e){const t={};for(const[o,n]of e){const e=[];for(const[,t]of n.clauses){const o={};for(const[e,n]of Object.entries(t.fields))o[e]="point"===n.type?{type:"point",values:Array.from(n.values)}:{type:"interval",range:n.range};e.push({clientId:t.clientId,type:t.type,fields:o})}t[o]={name:n.name,resolution:n.resolution,clauses:e}}return t},exports.stretchFamiliarityCeiling=_h,exports.suggestCharts=Dh,exports.suggestDashboard=function(e,t={}){var o,n,i,r,s,a,l,c,u,d,h;const g=null!==(o=t.profile)&&void 0!==o?o:Dd(null!=e?e:[],{rawInput:t.rawInput}),f=null!==(n=t.maxPanels)&&void 0!==n?n:6,p=!1!==t.diversifyByFamily,y=null!==(i=t.intents)&&void 0!==i?i:function(e){const t=[];return e.hasTimeAxis&&(t.push("trend"),e.seriesCount&&e.seriesCount>=2&&t.push("compare-series","composition-over-time"),t.push("change-detection")),e.categoryCount&&t.push("rank","compare-categories","part-to-whole"),e.primary.y&&e.rowCount>=10&&t.push("distribution"),2>Object.values(e.fields).filter(e=>"numeric"===e.type).length||t.push("correlation","outlier-detection"),e.hasHierarchy&&t.push("hierarchy"),e.hasNetwork&&t.push("flow"),e.hasGeo&&t.push("geo"),Array.from(new Set(t))}(g),m=[],v=[],b=[],x=new Set,k=new Set;for(const o of y){if(m.length>=f){b.push(o);continue}const n=Dh(e,{profile:g,intent:o,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let i;for(const e of n){const t=`${e.component}/${null!==(s=null===(r=e.variant)||void 0===r?void 0:r.key)&&void 0!==s?s:"base"}`;if(!(k.has(t)||p&&x.has(e.family))){i=e;break}}if(!i&&p)for(const e of n){const t=`${e.component}/${null!==(l=null===(a=e.variant)||void 0===a?void 0:a.key)&&void 0!==l?l:"base"}`;if(!k.has(t)){i=e;break}}i?(m.push({intent:o,suggestion:i}),v.push(o),x.add(i.family),k.add(`${i.component}/${null!==(u=null===(c=i.variant)||void 0===c?void 0:c.key)&&void 0!==u?u:"base"}`)):b.push(o)}return{panels:m,intentsCovered:v,intentsMissing:b,stretchPanels:t.audience&&(null!==(d=t.audience.exposureLevel)&&void 0!==d?d:1)>0?Fh(e,{profile:g,audience:t.audience,deny:Array.from(k).map(e=>e.split("/")[0]),maxResults:null!==(h=t.maxStretchPanels)&&void 0!==h?h:Math.min(3,f)}):[],profile:g}},exports.suggestStreamCharts=function(e,t={}){var o,n,i;const r=null!==(o=t.capabilities)&&void 0!==o?o:Vh(),s=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],a=null!==(n=t.minScore)&&void 0!==n?n:0,l=null!==(i=t.maxResults)&&void 0!==i?i:10,c=t.allow?new Set(t.allow):null,u=t.deny?new Set(t.deny):null,d=[];for(const t of r){if(c&&!c.has(t.component))continue;if(u&&u.has(t.component))continue;if(null!==t.fits(e))continue;const o={};for(const[n,i]of Object.entries(t.intentScores))o[n]=Uh(i,e);const n=Kh(o,s);if(a>n)continue;const i=Object.assign({},t.rubric),r=t.caveats?Array.from(t.caveats(e)):[],l=Qh(e,o,s),h=t.buildProps(e);d.push({component:t.component,family:"realtime",importPath:t.importPath,score:n,intentScores:o,rubric:i,reasons:l,caveats:r,props:h})}return d.sort((e,t)=>t.score!==e.score?t.score-e.score:t.rubric.accuracy!==e.rubric.accuracy?t.rubric.accuracy-e.rubric.accuracy:t.rubric.familiarity-e.rubric.familiarity),d.slice(0,l)},exports.suggestStretchCharts=Fh,exports.summarizeData=fd,exports.toConfig=function(e,t,o){if(!_u[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(_u).join(", ")}`);const n=!1!==(null==o?void 0:o.includeData),i={};for(const[e,o]of Object.entries(t))null!=o&&(Ru.has(e)||!n&&Bu.has(e)||"function"!=typeof o&&((null==o?void 0:o.$$typeof)||(i[e]=Nu(o))));return Object.assign({component:e,props:i,version:"1",createdAt:(new Date).toISOString()},(null==o?void 0:o.selections)?{selections:o.selections}:{})},exports.toURL=function(e){const t=JSON.stringify(e);return"sc="+btoa(unescape(encodeURIComponent(t))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},exports.unregisterChartCapability=function(e){Sh.delete(e)},exports.unregisterStreamChartCapability=function(e){Xh.delete(e)},exports.useBrushSelection=xi,exports.useCategoryColors=ci,exports.useChartFocus=function(e={}){const{chartId:o,types:n=Ih}=e,{latest:i}=ki({chartId:o,types:n,limit:1});return t.useMemo(()=>{if(!i)return null;if("hover-end"===i.type||"selection-end"===i.type||"brush-end"===i.type||"click-end"===i.type)return null;let e;if("selection"===i.type)e=i.selection.fields;else{if("hover"!==i.type&&"click"!==i.type)return null;e=i.datum}return e&&"object"==typeof e?{datum:e,x:i.x,y:i.y,source:i.type}:null},[i])},exports.useChartInterrogation=function(e){const{data:o,onQuery:n,initialAnnotations:i,componentName:r,props:s,includeProfile:a,includeSuggestions:l,suggestionsIntent:c,suggestionsMax:u,focus:d}=e,[h,g]=t.useState([]),[f,p]=t.useState([]),[y,m]=t.useState(!1),[v,b]=t.useState(null),x=t.useMemo(()=>fd(null!=o?o:[]),[o]),k=a||l,w=t.useMemo(()=>k?Dd(null!=o?o:[]):void 0,[k,o]),A=t.useMemo(()=>l&&w?Dh(o,{profile:w,intent:c,maxResults:null!=u?u:5}):void 0,[l,w,o,c,u]),j=t.useRef(n);j.current=n;const S=t.useRef(r);S.current=r;const C=t.useRef(s);C.current=s;const O=t.useRef(o);O.current=o;const M=t.useRef(x);M.current=x;const P=t.useRef(w);P.current=w;const _=t.useRef(A);_.current=A;const L=t.useRef(d);L.current=d;const T=t.useCallback(e=>Tr(this,void 0,void 0,function*(){var t,o;const n=e.trim();if(n){m(!0),b(null),g(e=>[...e,{role:"user",text:n}]);try{const e=yield j.current(n,{data:null!==(t=O.current)&&void 0!==t?t:[],summary:M.current,profile:P.current,suggestions:_.current,componentName:S.current,props:C.current,focus:null!==(o=L.current)&&void 0!==o?o:void 0});g(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&p(e.annotations)}catch(e){b(e instanceof Error?e:Error(e+"")),g(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}])}finally{m(!1)}}}),[]),R=t.useCallback(({text:e,annotations:t})=>{const o=e.trim();o&&(g(e=>[...e,{role:"assistant",text:o}]),t&&t.length>0&&p(e=>[...e,...t]))},[]),B=t.useCallback(()=>{g([]),p([]),b(null)},[]);return{ask:T,announce:R,history:h,summary:x,annotations:t.useMemo(()=>{const e=null!=i?i:[];return 0===e.length?f:0===f.length?e:[...e,...f]},[i,f]),loading:y,error:v,reset:B}},exports.useChartObserver=ki,exports.useChartSuggestions=function(e,o={}){const{intent:n,allow:i,deny:r,maxResults:s,includeVariants:a,minScore:l,rawInput:c,seriesField:u,capabilities:d,audience:h,profile:g}=o,f=t.useMemo(()=>null!=g?g:Dd(null!=e?e:[],{rawInput:c,seriesField:u}),[g,e,c,u]);return{suggestions:t.useMemo(()=>Dh(e,{intent:n,allow:i,deny:r,maxResults:s,includeVariants:a,minScore:l,capabilities:d,audience:h,profile:f}),[e,n,i,r,s,a,l,d,h,f]),profile:f}},exports.useFilteredData=function(e,o,n){const i=fi(e=>e.selections.get(o));return t.useMemo(()=>{if(!i||0===i.clauses.size)return e;const t=di(i,n);return e.filter(t)},[e,i,n])},exports.useLinkedHover=vi,exports.useSelection=mi,exports.useTheme=$i,exports.validateProps=Tu;
|