semiotic 3.5.4 → 3.7.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 +196 -175
- package/README.md +52 -15
- package/ai/cli.js +41 -0
- package/ai/componentMetadata.cjs +11 -2
- package/ai/dist/mcp-server.js +454 -4
- package/ai/examples.md +98 -0
- package/ai/schema.json +614 -9
- package/ai/system-prompt.md +5 -2
- package/dist/components/AccessibleNavTree.d.ts +25 -0
- package/dist/components/Annotation.d.ts +40 -14
- package/dist/components/ChartContainer.d.ts +32 -2
- package/dist/components/ai/annotationProvenance.d.ts +349 -0
- package/dist/components/ai/audienceProfile.d.ts +147 -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 +254 -0
- package/dist/components/ai/chartRoles.d.ts +27 -0
- package/dist/components/ai/conversationArc.d.ts +379 -0
- package/dist/components/ai/dataScaleProfile.d.ts +320 -0
- package/dist/components/ai/describeChart.d.ts +114 -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/navigationTree.d.ts +45 -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/readerGrounding.d.ts +70 -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 +109 -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/ai/useConversationArc.d.ts +89 -0
- package/dist/components/ai/useNavigationSync.d.ts +61 -0
- package/dist/components/ai/variantDiscovery.d.ts +168 -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 +1 -1
- 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/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/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/RealtimeHeatmap.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeHistogram.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeHistogram.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeLineChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeLineChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeSwarmChart.d.ts +3 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.capability.d.ts +2 -0
- package/dist/components/charts/realtime/RealtimeWaterfallChart.d.ts +3 -0
- package/dist/components/charts/realtime/TemporalHistogram.capability.d.ts +7 -0
- package/dist/components/charts/shared/annotationHierarchy.d.ts +42 -0
- package/dist/components/charts/shared/annotationResolvers.d.ts +3 -2
- package/dist/components/charts/shared/annotationRules.d.ts +16 -0
- package/dist/components/charts/shared/annotationTypes.d.ts +14 -0
- package/dist/components/charts/shared/auditAccessibility.d.ts +90 -0
- package/dist/components/charts/shared/chartSpecs.d.ts +2 -37
- package/dist/components/charts/shared/diagnoseConfig.d.ts +4 -6
- package/dist/components/charts/shared/selectionUtils.d.ts +5 -2
- package/dist/components/charts/shared/streamPropsHelpers.d.ts +2 -0
- package/dist/components/charts/shared/types.d.ts +5 -1
- package/dist/components/charts/value/BigNumber.capability.d.ts +13 -0
- package/dist/components/charts/value/BigNumber.d.ts +14 -0
- package/dist/components/charts/value/formatting.d.ts +40 -0
- package/dist/components/charts/value/thresholdSparkline.d.ts +40 -0
- package/dist/components/charts/value/types.d.ts +292 -0
- package/dist/components/charts/xy/AreaChart.capability.d.ts +10 -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/realtime/lifecycleBands.d.ts +44 -0
- package/dist/components/realtime/types.d.ts +23 -8
- package/dist/components/recipes/annotationDensity.d.ts +69 -0
- package/dist/components/recipes/annotationLayout.d.ts +93 -0
- package/dist/components/semiotic-ai.d.ts +58 -0
- package/dist/components/semiotic-realtime.d.ts +2 -0
- package/dist/components/semiotic-recipes.d.ts +4 -0
- package/dist/components/semiotic-utils.d.ts +8 -0
- package/dist/components/semiotic-value.d.ts +55 -0
- package/dist/components/semiotic-xy.d.ts +1 -1
- package/dist/components/semiotic.d.ts +8 -1
- package/dist/components/server/staticAnnotations.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/AccessibleDataTable.d.ts +10 -1
- package/dist/components/stream/NetworkSVGOverlay.d.ts +11 -5
- package/dist/components/stream/OrdinalSVGOverlay.d.ts +2 -0
- package/dist/components/stream/SVGOverlay.d.ts +2 -0
- package/dist/components/stream/geoTypes.d.ts +3 -0
- package/dist/components/stream/networkTypes.d.ts +2 -0
- package/dist/components/stream/ordinalTypes.d.ts +2 -0
- package/dist/components/stream/types.d.ts +2 -0
- package/dist/geo.min.js +1 -1
- package/dist/geo.module.min.js +1 -1
- package/dist/network.min.js +1 -1
- package/dist/network.module.min.js +1 -1
- package/dist/ordinal.min.js +1 -1
- package/dist/ordinal.module.min.js +1 -1
- package/dist/realtime.min.js +1 -1
- package/dist/realtime.module.min.js +1 -1
- package/dist/semiotic-ai.d.ts +58 -0
- package/dist/semiotic-ai.min.js +1 -1
- package/dist/semiotic-ai.module.min.js +1 -1
- package/dist/semiotic-realtime.d.ts +2 -0
- package/dist/semiotic-recipes.d.ts +4 -0
- package/dist/semiotic-recipes.min.js +1 -1
- package/dist/semiotic-recipes.module.min.js +1 -1
- package/dist/semiotic-themes.min.js +1 -1
- package/dist/semiotic-themes.module.min.js +1 -1
- package/dist/semiotic-utils.d.ts +8 -0
- package/dist/semiotic-utils.min.js +1 -1
- package/dist/semiotic-utils.module.min.js +1 -1
- package/dist/semiotic-value.d.ts +55 -0
- package/dist/semiotic-value.min.js +2 -0
- package/dist/semiotic-value.module.min.js +2 -0
- package/dist/semiotic-xy.d.ts +1 -1
- package/dist/semiotic.d.ts +8 -1
- package/dist/semiotic.min.js +1 -1
- package/dist/semiotic.module.min.js +1 -1
- package/dist/server.min.js +1 -1
- package/dist/server.module.min.js +1 -1
- package/dist/xy.min.js +1 -1
- package/dist/xy.module.min.js +1 -1
- package/package.json +28 -5
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 N{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 E{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 B(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 $(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 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 Ne(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 Ee(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 Be(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},$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=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:We(e.y1Accessor,"y1"),getBottom:We(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}class Ye{constructor(e){if(this.xExtent=new E,this.yExtent=new E,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 N(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 N(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=B(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(...Ne(e,t,r)),o.length>0)for(const t of n)i.push(...Ee(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(...Ne(e,t,r)),i.length>0)for(const t of o)n.push(...Ee(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(...Ne(e,t,r)),i.length>0)for(const t of o)n.push(...Ee(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(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 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=$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,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(W(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=B(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),O=Math.abs(A-j),M={fill:0>r?p:f,stroke:m,strokeWidth:v};null!=b&&(M.opacity=b),u.push($(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,N,E,B,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!==(N=t.w)&&void 0!==N?N:0,h:null!==(E=t.h)&&void 0!==E?E:0,style:{opacity:null!==(B=t.opacity)&&void 0!==B?B: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!==($=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!==(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,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,Pt[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 Nt=(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 Et({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 Bt(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:Nt(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 O=0,M=0;j.forEach((e,t)=>{const o=0===M?e:M+b+e;h&&h>0&&M>0&&o>h?(S.push({start:O,end:t,width:M}),O=t,M=e):M=o}),p.length>0&&S.push({start:O,end:p.length,width:M}),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),O=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?O||!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,O&&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 C=Math.max(0,...S.map(e=>e.width)),_=S.length;return{items:y,offset:C,totalRows:_,totalHeight:_*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 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){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(Et,{config:n.gradient,orientation:p?"horizontal":"vertical",width:m}):Dt(n)?e.jsx(Bt,{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 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]: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 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,N,E,B,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,N]=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:N-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!==(N=t.anomalyRadius)&&void 0!==N?N: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!==(B=null===(E=n.scales)||void 0===E?void 0:E.x)&&void 0!==B?B: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!==($=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(" "),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",legendLayout:M,foregroundGraphics:C,marginalGraphics:_,xValues:P,yValues:L,annotations:T,svgAnnotationRules:R,xAccessor:N,yAccessor:E,annotationData:B,pointNodes:D,curve:I,underlayRendered:H,canvasObscuresUnderlay:F=!0,linkedCrosshairName:$,linkedCrosshairSourceId:W,children:z}=o,Y=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]),G=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:N,yAccessor:E,width:r,height:s,data:B,frameType:"xy",pointNodes:D,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,N,E,B,u,D,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||C||_||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:[Y.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)),G.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)&&Y.length>1&&(()=>{const e=r/Math.max(Y.length-1,1);return Y.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),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(Y),O=po(G);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}),Y.map((t,o)=>{const n=!!u&&("function"==typeof u?u(t.value,o):Ue(t.value,o>0?Y[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}),G.map((t,o)=>{const n=!!d&&("function"==typeof d?d(t.value,o):Ue(t.value,o>0?G[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===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,_&&u&&P&&L&&e.jsxs(e.Fragment,{children:[_.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx($t,{orient:"top",config:Ft(_.top),values:P,scale:u.x,size:c.top,length:r})}),_.bottom&&e.jsx("g",{transform:`translate(0, ${s})`,children:e.jsx($t,{orient:"bottom",config:Ft(_.bottom),values:P,scale:u.x,size:c.bottom,length:r})}),_.left&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx($t,{orient:"left",config:Ft(_.left),values:L,scale:u.y,size:c.left,length:s})}),_.right&&e.jsx("g",{transform:`translate(${r}, 0)`,children:e.jsx($t,{orient:"right",config:Ft(_.right),values:L,scale:u.y,size:c.right,length:s})})]}),C,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:O,title:x,legendLayout:M,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),O=a?0:(n+l)*Math.cos(u),M=a?null:jo(O,r),C=a?null:jo(O,s),_=y-p>Math.PI?1:0,P=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 ${_} 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 ${_} 1 ${e.x},${e.y}`}if(a)L+=" L0,0";else{if(f)L+=` L${C.x},${C.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 ${P} 0 ${S.x},${S.y}`,L+=` A${l},${l} 0 0 1 ${M.x},${M.y}`;else{const e=jo(n,r);L+=` A${n},${n} 0 ${P} 0 ${e.x},${e.y}`}}return L+=" Z",L}function Oo(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 Mo={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function Co(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function _o(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}const Po="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=()=>()=>{},No=()=>!1,Eo=()=>!0;function Bo(){const e=t.useSyncExternalStore(Ro,No,Eo);return t.useRef(e).current}function Do(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 Yo(){return p.useContext(Wo)}const Go={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=Yo(),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:Go}):null;if(!u)return e.jsx("div",{id:n,className:Ko,tabIndex:-1,onFocus:g,style:Go,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&&null!==M.datum)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}: ${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=Yo(),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:Go}):null;if(!S)return e.jsx("div",{id:i,className:Ko,tabIndex:-1,onFocus:C,style:Go,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,N=new Map,E=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),E.set(e,(null!==(d=E.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),N.set(e,(null!==(g=N.get(e))&&void 0!==g?g:0)+i)}}const B=[];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=N.get(n))&&void 0!==b?b:0,a=null!==(x=E.get(n))&&void 0!==x?x:0;B.push({id:n,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}B.sort((e,t)=>t.degree-e.degree);let D=0,I=0;if(B.length>0){let e=0;for(const t of B)e+=t.degree,t.degree>I&&(I=t.degree);D=e/B.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=[`${B.length} nodes, ${L.length} edges.`];B.length>0&&F.push(`Mean degree: ${Vo(D)}, max degree: ${I}.`);const $=B.slice(0,5);return e.jsxs("div",{ref:M,id:i,className:Zo,tabIndex:-1,onBlur:_,style:Jo,role:"region","aria-label":O,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 ",B.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:Go,children:t}):null}function un({tableId:t}){return e.jsx("a",{href:"#"+t,style:Go,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,Go)},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:Go,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 On(e,t,o){return"function"==typeof e?e({size:t,margin:o}):e}function Mn(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=On(e.foregroundGraphics,r,s),u=On(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 Sn(()=>{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 Cn(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 _n(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function Pn(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 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=Pn(L,g,d);if(null!==k&&null!==j&&null!==A){if(T===j)e.lineTo(_,P);else{const R=[];for(const N of g){const E=N.value;(A>E||E>L)&&(E>A||L>E)||A===E||L===E||R.push({t:(E-A)/(L-A)})}R.sort((e,t)=>e.t-t.t);for(const B of R){const D=k+(_-k)*B.t,I=w+(P-w)*B.t,H=Pn(A+(L-A)*Math.min(B.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 Rn(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function Nn(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 En(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 Bn(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 Dn(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(Dn(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&&(Dn(e,t),Bn(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()),En(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))}Nn(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 Yn(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 Gn(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),Nn(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):Gn(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=Yn(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:O,xAccessor:M,yAccessor:C,colorAccessor:_,sizeAccessor:P,groupAccessor:L,lineDataAccessor:T,curve:R,normalize:N,baseline:E,stackOrder:B,binSize:D,valueAccessor:I,arrowOfTime:H="right",windowMode:F="sliding",windowSize:$=200,timeAccessor:W,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:Ne,hoverRadius:Ee=30,tooltipMode:De,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:Ot,yScaleType:Mt,accessibleTable:Pt=!0,description:Lt,summary:Tt,linkedCrosshairName:Rt,linkedCrosshairSourceId:Nt,customLayout:Et,layoutConfig:Bt}=o,Dt=t.useId().replace(/:/g,""),It=t.useRef(!1),Ht=Mn({sizeProp:V,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:ti,animate:ut,transitionProp:ct,themeDirtyRef:It}),Ft=To(),$t=Bo(),{reducedMotionRef:Wt,responsiveRef:zt,size:Yt,currentTheme:Gt,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:Yt,margin:Zt}):Je,eo="function"==typeof Ze?Ze({size:Yt,margin:Zt}):Ze,to=Yt[0]-Zt.left-Zt.right,oo=Yt[1]-Zt.top-Zt.bottom,no=t.useMemo(()=>v(A),[A]),io=null!=Pe?Pe:Ne,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([]),[Oo,Mo]=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:$,windowMode:F,arrowOfTime:_o?H:"right",extentPadding:G,scalePadding:q,axisExtent:Me,xAccessor:M,yAccessor:C,timeAccessor:_o?W:void 0,valueAccessor:I,colorAccessor:_,sizeAccessor:P,groupAccessor:L||(T?"_lineGroup":void 0),categoryAccessor:nt,lineDataAccessor:T,xScaleType:Ot,yScaleType:Mt,xExtent:z,yExtent:Y,sizeRange:X,binSize:D,normalize:N,baseline:E,stackOrder:B,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==Gt?void 0:Gt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(Gt),themeSequential:null===(t=null==Gt?void 0:Gt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(o=null==Gt?void 0:Gt.colors)||void 0===o?void 0:o.diverging,customLayout:Et,layoutConfig:Bt,layoutMargin:Zt}},[b,$,F,H,G,q,Me,M,C,W,I,Ot,Mt,_,P,L,nt,T,z,Y,X,D,N,E,B,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,_o,kt,R,Gt,Et,Bt,Zt]),Ro=Io(Lo),No=t.useRef(null);No.current||(No.current=new Ye(Ro));const Eo=t.useCallback(()=>{var e,t;const o=bo.current,n=xo.current;if(!n||!o)return;const i=Vn(null!==(t=null===(e=No.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=No.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=No.current;t&&t.ingest(e)&&(It.current=!0,Qt())},{chunkThreshold:j,chunkSize:O})),t.useEffect(()=>{var e;null===(e=Ho.current)||void 0===e||e.updateChunkOptions({chunkThreshold:j,chunkSize:O})},[j,O]);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=No.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=No.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=No.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=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},getExtents:()=>{var e,t;return null!==(t=null===(e=No.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:Yo,onPointerMove:Go,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=No.current;if(!a||0===a.scene.length)return;const l=gt(a.scene,r,s,Ee,a.quadtree,a.maxPointRadius),c="multi"===De,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)?Be(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(Ee,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 M&&(e[M]=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:Be(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()},Yo.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=No.current;if(!r||0===r.scene.length)return void Re(null);const s=gt(r.scene,n,i,Ee,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=No.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=Ct(Object.assign(Object.assign({},o),{datum:Be(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=Ct(Object.assign(Object.assign({},a),{datum:Be(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,Go(e)},[Go]);Kt.current=()=>{var e,t;Ut.current=0;const o=ro.current,n=so.current;if(!o||!n)return;const i=No.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}),Eo());const c=_n(),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=Cn(o,Yt,Zt,c);if(e){if(e.clearRect(-Zt.left,-Zt.top,Yt[0],Yt[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,Yt[0],Yt[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=Et?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=Cn(n,Yt,Zt,c);if(e&&(e.clearRect(-Zt.left,-Zt.top,Yt[0],Yt[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(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,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 M?M:e=>e[M||"x"],o="function"==typeof C?C:e=>e[C||"y"];So(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Mo(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()))},Do({hydrated:Ft,wasHydratingFromSSR:$t,storeRef:No,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]),_t(dt,No,It,Qt,wo,Ao);const tn=t.useMemo(()=>{if(Se||Ce)return;const e=No.current;return(null==e?void 0:e.xIsDate)&&co?Jn(co.x.domain()):void 0},[Se,Ce,co]),on=Se||Ce||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:Yt,shape:null==sn?void 0:sn.shape,width:null==sn?void 0:sn.w,height:null==sn?void 0:sn.h}),hn=Kn(M,W,"__semiotic_resolvedX","__semiotic_resolvedTime"),fn=Kn(C,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),yn=hn.key,mn=fn.key,vn=Qn(hn,fn,Ie&&Ie.length>0||!1);if(Po||!Ft&&$t){const t=No.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%":Yt[0],height:K?"100%":Yt[1]},children:[e.jsx(cn,{summary:Tt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Yt[0],height:Yt[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:Co(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:Co(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:Co(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:Co(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,Dt)).filter(Boolean)]})]}),e.jsx(ko,{width:to,height:oo,totalWidth:Yt[0],totalHeight:Yt[1],margin:Zt,scales:n,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:a,yFormat:Oe||_e,axisExtent:Me,showGrid:Fe,title:ot,legend:$e,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendLayout:Ue,foregroundGraphics:Ge(Jt,null===(s=No.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:Nt})]})}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%":Yt[0],height:K?"100%":Yt[1],overflow:"visible"},onKeyDown:Jo,children:[Pt&&e.jsx(un,{tableId:Vt}),Pt&&e.jsx(an,{scene:null!==(l=null===(a=No.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:Yt[0],height:Yt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Zt.left},${Zt.top})`,children:eo})}),e.jsx(vo,{width:to,height:oo,totalWidth:Yt[0],totalHeight:Yt[1],margin:Zt,scales:co,showAxes:xe,axes:ke,showGrid:Fe,xFormat:on,yFormat:Oe||_e,axisExtent:Me}),e.jsx("canvas",{ref:ro,"aria-label":qo(null!==(u=null===(c=No.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:Yt[0],totalHeight:Yt[1],margin:Zt,scales:co,showAxes:xe,axes:ke,xLabel:we,yLabel:Ae,yLabelRight:je,xFormat:on,yFormat:Oe||_e,axisExtent:Me,showGrid:Fe,title:ot,legend:$e,legendHoverBehavior:We,legendClickBehavior:ze,legendHighlightedCategory:qe,legendIsolatedCategories:Xe,legendPosition:Ve,legendLayout:Ue,foregroundGraphics:Ge(Jt,null===(d=No.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:xt,xValues:jo,yValues:Oo,annotations:Ie,svgAnnotationRules:He,annotationFrame:ao,xAccessor:yn,yAccessor:mn,annotationData:vn(null===(h=No.current)||void 0===h?void 0:h.getData()),pointNodes:null===(g=No.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:Nt}),(it||st)&&e.jsx(k,{width:to,height:oo,totalWidth:Yt[0],totalHeight:Yt[1],margin:Zt,dimension:null!==(f=null==it?void 0:it.dimension)&&void 0!==f?f:"xy",scales:co,onBrush:null!=st?st:()=>{},binSize:D,snap:null==it?void 0:it.snap,binBoundaries:null!==(y=null==it?void 0:it.binBoundaries)&&void 0!==y?y:"bar"===b?null===(m=No.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 Oi(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 Mi(e){const o=t.useContext(Ai),n=t.useId(),i=Si(e),r=t.useRef([]);Oi(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 Ci({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 _i({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(Bt,{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 Pi({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 Oi(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(Ci,{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(_i,{categoryColors:p,interaction:s,selectionName:a,field:l}),o,y&&"bottom"===r&&e.jsx(_i,{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 Ni={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 Ei(e){return Ni[e]}const Bi=p.createContext(void 0),Di="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 Ei(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===P?C:n.current,t("high-contrast")),An(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 Di(()=>{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(Bi),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 Yi(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 Gi(){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=Gi();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=Yi(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=Yi(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]);Mi(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 Or(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 Mr(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:N,customClickBehavior:E,crosshairSourceId:B}=Ui({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:g,chartId:f,onClick:b,hoverHighlight:x,colorByField:L}),D=Ki(c,B),I=Xi(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]),$=Zi(s,i,F),W=t.useMemo(()=>R||($.legendSelectionHook?$.legendSelectionHook:T),[R,$.legendSelectionHook,T]),z=Or(l),Y=Gi(),G=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: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}=Qi({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=$.onLegendHover,e.legendClickBehavior=$.onLegendClick,e.legendHighlightedCategory=$.highlightedCategory,e.legendIsolatedCategories=$.isolatedCategories),O&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=P),e},[X,U,s,$.onLegendHover,$.onLegendClick,$.highlightedCategory,$.isolatedCategories,O,i,P]),Q=Array.isArray(n)?v(n):n,Z=mr(k,j,S,w),J=Z?null:yr(Q,j,S,A);return{data:M,colorScale:I,allCategories:F,legendState:$,effectiveSelectionHook:W,activeSelectionHook:T,customHoverBehavior:N,customClickBehavior:E,legend:X,margin:V,legendPosition:U,earlyReturn:Z||J||null,legendBehaviorProps:K,crosshairProps:D,resolvedSelection:z}}function Cr(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 _r(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(()=>Cr(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 Pr(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 Nr=null;function Er(){return Tr(this,void 0,void 0,function*(){return Nr||(Nr=yield Promise.resolve().then(function(){return sd})),Nr})}const Br="__semiotic_resolvedX",Dr="__semiotic_resolvedY";function Ir(e){const{data:o,xAccessor:n,yAccessor:i,forecast:r,anomaly:s,groupBy:a}=e,l="string"==typeof n?n:Br,c="string"==typeof i?i:Dr,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[Br]=n(o)),t&&(r[Dr]=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 Er()).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 Er()).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);Pr(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:O=2,lineGradient:M,tooltip:C,pointIdAccessor:_,annotations:P,directLabel:L,gapStrategy:T="break",anomaly:R,forecast:N,band:E,xExtent:B,yExtent:D,frameProps:I={},selection:H,linkedHover:F,onObservation:$,onClick:W,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]);vr("LineChart",fe,"xAccessor",f),vr("LineChart",fe,"yAccessor",p);const{effectiveData:pe,statisticalAnnotations:ye}=Ir({data:fe,xAccessor:f,yAccessor:p,forecast:N,anomaly:R,groupBy:y}),me="__compoundGroup",ve=!(!N||!y),be=ve?me:N?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(!N)return;const e=N.upperBounds,t=N.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},[N,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]),Oe=void 0!==(null===(i=we[0])||void 0===i?void 0:i[m]),Me=t.useMemo(()=>{if(Oe)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,Oe]),{gapProcessedLineData:Ce,hasGaps:_e}=t.useMemo(()=>{if("interpolate"===T){let e=!1;const t=[];for(const o of Me){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 Me){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 Me){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:Me,hasGaps:!1}},[Me,T,m,Se,be,p]),Pe="object"==typeof L?L:{},Le=Pe.position||"end",Te=Pe.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 Ce){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,Ce,m,Le]),Ne=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]),Ee=Mr({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:G,showLegend:(!L||void 0!==ae)&&ae,userMargin:c,marginDefaults:Ne,loading:q,loadingContent:X,emptyContent:V,width:ne,height:ie}),Be=Ee.colorScale,De=Ee.customHoverBehavior,Ie=Ee.customClickBehavior,He=Ee.crosshairProps,Fe=_r({lineWidth:O,colorBy:Ae,colorScale:Be,color:J,fillArea:j,areaOpacity:S,stroke:ee,strokeWidth:te,opacity:oe,effectiveSelectionHook:Ee.effectiveSelectionHook,resolvedSelection:Ee.resolvedSelection}),[$e,We]=t.useState(null);t.useEffect(()=>{if(!N)return void We(null);let e=!1;return function(...e){return Tr(this,void 0,void 0,function*(){return(yield Er()).createSegmentLineStyle(...e)})}(Fe,N).then(t=>{e||We(()=>t)}).catch(()=>{e||We(null)}),()=>{e=!0}},[Fe,N]);const ze=$e||Fe,Ye=t.useMemo(()=>{if(w)return e=>{const t={r:A,fillOpacity:1};return Ae?Be&&(t.fill=ke(e.parentLine||e,Ae,Be)):t.fill=J||Wi,t}},[w,A,Ae,Be,J]),Ge=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 Ce){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:Be?Be(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,Be,Ce,m,f,p,Le,Te]),Xe=Ee.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(E,h)]),[f,p,he,ge,Ve,d,h,E]),Ke=Ar({componentName:"LineChart",data:Oe?(null===(r=pe[0])||void 0===r?void 0:r[m])||[]:l,accessors:{xAccessor:f,yAccessor:p}}),Qe=t.useMemo(()=>Oe||be||_e?Ce.flatMap(e=>{const t=e[m]||[];return be&&"string"==typeof be?t.map(t=>Object.assign(Object.assign({},t),{[be]:e[be]})):t}):we,[Ce,m,Oe,be,we,_e]),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:Ge},Array.isArray(j)&&{areaGroups:j}),M&&{lineGradient:M}),null!=Y&&{hoverRadius:Y}),null!=l&&{data:Qe}),{xAccessor:f,yAccessor:p,xScaleType:Q,yScaleType:Z}),B&&{xExtent:B}),!D||null==D[0]&&null==D[1]?je?{yExtent:je}:{}:{yExtent:D}),{groupAccessor:"break"===T&&_e?"_gapSegment":be||void 0}),E&&{band:E}),{curve:k,lineStyle:ze}),w&&{pointStyle:Ye}),{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}),Ee.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?xn():kn(C)||Ue}),"multi"===C&&{tooltipMode:"multi"}),(F||$||W||z)&&{customHoverBehavior:De}),($||W||F)&&{customClickBehavior:Ie}),_&&{pointIdAccessor:_}),((null==P?void 0:P.length)||ye.length||qe.length)&&{annotations:[...P||[],...ye,...qe]}),He),I);return Ee.earlyReturn?Ee.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: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||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]),P=t.useMemo(()=>Cr(_,{stroke:u,strokeWidth:d,opacity:h}),[_,u,d,h]);return{flattenedData:C,lineStyle:t.useMemo(()=>Ri(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||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},...O?[{label:or(O),accessor:O,role:"group"}]:[],...sr(e.band,S)]),[x,k,w,A,O,j,S,e.band])}}function Yr(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 Gr=t.forwardRef(function(o,n){const i=t.useRef(null);Pr(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:O=!1,pointRadius:M=3,tooltip:C,annotations:_,forecast:P,anomaly:L,band:T,xExtent:R,yExtent:N,frameProps:E={},selection:B,linkedHover:D,onObservation:I,onClick:H,hoverHighlight:F,chartId:$,loading:W,loadingContent:z,emptyContent:Y,legendInteraction:G,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:Yr(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=Mr({data:le,rawData:s,colorBy:ce,colorScheme:x,legendInteraction:G,legendPosition:q,selection:B,linkedHover:D,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:Y,width:Q,height:Z}),{effectiveData:he,statisticalAnnotations:ge}=Ir({data:le,xAccessor:d,yAccessor:h,forecast:P,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:O,pointRadius:M,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}),O&&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"===C?{tooltipContent:xn(),tooltipMode:"multi"}:Wr({tooltip:C,defaultTooltipContent:me})),$r({linkedHover:D,onObservation:I,onClick:H,hoverHighlight:F,customHoverBehavior:de.customHoverBehavior,customClickBehavior:de.customClickBehavior})),(_&&_.length>0||ge.length>0)&&{annotations:[..._||[],...ge]}),R&&{xExtent:R}),N&&{yExtent:N}),de.crosshairProps),E);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}Gr.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:O,annotations:M,xExtent:C,yExtent:_,frameProps:P={},selection:L,linkedHover:T,onObservation:R,onClick:N,hoverHighlight:E,chartId:B,loading:D,loadingContent:I,emptyContent:H,legendInteraction:F,legendPosition:$,pointIdAccessor:W,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=>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=Mr({data:le,rawData:s,colorBy:"__diffWinner",colorScheme:[y,m],legendInteraction:F,legendPosition:$,selection:L,linkedHover:T,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:R,onClick:N,hoverHighlight:E,chartType:"DifferenceChart",chartId:B,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: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"===O,xe=t.useMemo(()=>!1===O?()=>null:be?ve:kn(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}),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:N,hoverHighlight:E,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(gr,{componentName:"DifferenceChart",width:Y,height:G,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:O,tooltip:M,annotations:C,xExtent:_,yExtent:P,frameProps:L={},selection:T,linkedHover:R,onObservation:N,onClick:E,hoverHighlight:B,chartId:D,loading:I,loadingContent:H,emptyContent:F,legendInteraction:$,legendPosition:W,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;Pr(n,{variant:"xy",frameRef:i});const se=Mr({data:ie,rawData:s,colorBy:re,colorScheme:y,legendInteraction:$,legendPosition:W,selection:T,linkedHover:R,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:N,onClick:E,hoverHighlight:B,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}=zr({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=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: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),Fr({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:o.animate,axisExtent:o.axisExtent})),"multi"===M?{tooltipContent:xn(),tooltipMode:"multi"}:Wr({tooltip:M,defaultTooltipContent:ue})),$r({linkedHover:R,onObservation:N,onClick:E,hoverHighlight:B,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(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(()=>Cr(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:O,regression:M,forecast:C,anomaly:_,xExtent:P,yExtent:L,frameProps:T={},selection:R,linkedHover:N,linkedBrush:E,onObservation:B,onClick:D,hoverHighlight:I,chartId:H,loading:F,loadingContent:$,emptyContent:W,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}=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]);Pr(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=Mr({data:se,rawData:s,colorBy:y,colorScheme:m,legendInteraction:z,legendPosition:Y,selection:R,linkedHover:N,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:B,onClick:D,hoverHighlight:I,chartType:"Scatterplot",chartId:H,showLegend:J,userMargin:a,marginDefaults:r.marginDefaults,loading:F,loadingContent:$,emptyContent:W,width:U,height:K}),fe=Ti(E),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:G,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:C,anomaly:_}),Oe=t.useMemo(()=>{const e=Qr(M);return e||0!==Se.length?[...e?[e]:[],...O||[],...Se]:O},[M,O,Se]),Me=Ar({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(Me)return e.jsx(cr,{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),Fr({title:ee,description:te,summary:oe,accessibleTable:ne,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:A,defaultTooltipContent:we})),$r({linkedHover:N,onObservation:B,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(gr,{componentName:"Scatterplot",width:U,height:K,children:e.jsx(si,Object.assign({ref:i},Ce))})});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);Pr(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:O={},selection:M,linkedHover:C,onObservation:_,onClick:P,hoverHighlight:L,chartId:T,loading:R,loadingContent:N,emptyContent:E,legendInteraction:B,stroke:D,strokeWidth:I,opacity:H}=o,{width:F,height:$,enableHover:W,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]);vr("ConnectedScatterplot",Q,"xAccessor",g),vr("ConnectedScatterplot",Q,"yAccessor",f);const J=Mr({data:Q,rawData:l,colorBy:void 0,colorScheme:void 0,legendInteraction:B,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:N,emptyContent:E,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:D,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:Y,description:G,summary:q,accessibleTable:X,className:u,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:v,defaultTooltipContent:le})),$r({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(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:O,yExtent:M,frameProps:C={},selection:_,linkedHover:P,linkedBrush:L,onObservation:T,onClick:R,hoverHighlight:N,chartId:E,loading:B,loadingContent:D,emptyContent:I,legendInteraction:H,legendPosition:F,color:$,stroke:W,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=Mr({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:N,chartType:"BubbleChart",chartId:E,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:B,loadingContent:D,emptyContent:I,width:G,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]);Pr(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:Y,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:G,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:[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),Fr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:pe})),$r({linkedHover:P,onObservation:T,onClick:R,hoverHighlight:N,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(gr,{componentName:"BubbleChart",width:G,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);Pr(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:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:N,showLegend:E,legendPosition:B,legendInteraction:D}=o,{width:I,height:H,enableHover:F,title:$,description:W,summary:z,accessibleTable:Y,xLabel:G,yLabel:q}=a,X=mr(T,I,H,R),V=X?null:yr(l,I,H,N),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!=E&&E,de=null!=B?B:"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:O,linkedHover:M,fallbackFields:[],onObservation:C,onClick:_,chartType:"Heatmap",chartId:L,hoverHighlight:P,colorByField:void 0});Or(O);const ye=Ki(M,pe);Zi(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(()=>ar([{label:G||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,G,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:G,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:Y,className:u,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:xe})),$r({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(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",O="splom-hover",M=y?"hover":f?"brush":"hover",C=fi(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[ns]?e:Object.assign(Object.assign({},e),{[ns]:t})),[n]),R=Xi(T,s,a),N=void 0!==x?x:!!s,E=t.useMemo(()=>{if(!N||!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},[N,s,T,R]),B=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:[E&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:E.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:B,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(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:O,unselectedOpacity:m,mode:M},"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: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[ns];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 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(Pi,{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:O=!1,areaOpacity:M=.3,showPoints:C=!1,pointRadius:_=3,enableHover:P=!0,showGrid:L=!1,showLegend:T,legendPosition:R,tooltip:N,minimap:E={},renderBefore:B=!1,onBrush:D,brushExtent:I,yExtent:H,frameProps:F={},loading:$,loadingContent:W,emptyContent:z}=o,Y=mr($,s,a,W),G=Y?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==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=Xi(q,w,A),ie=_r({lineWidth:S,colorBy:w,colorScale:ne,fillArea:O,areaOpacity:M}),re=t.useMemo(()=>{if(E.lineStyle)return E.lineStyle},[E.lineStyle]),se=_r({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):Wi,t}},[C,_,w,ne]),{legend:ce,margin:ue,legendPosition:de}=Qi({data:te,colorBy:w,colorScale:ne,showLegend:T,legendPosition:R,userMargin:l}),he=E.height||60,ge=t.useMemo(()=>{var e,t,o,n,i,r,s,a;return{top:null!==(t=null===(e=E.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(n=null===(o=E.margin)||void 0===o?void 0:o.bottom)&&void 0!==n?n:20,left:null!==(r=null===(i=E.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ue.left,right:null!==(a=null===(s=E.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:ue.right}},[E.margin,ue]),fe=E.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=O?"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},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===N?()=>null:kn(N)||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=E.showAxes)&&void 0!==i&&i,background:E.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 Y||G||e.jsx(gr,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[B?xe:we,B?we:xe]})})}us.displayName="ScatterplotMatrix",hs.displayName="MinimapChart";const gs=t.forwardRef(function(o,n){const i=t.useRef(null);Pr(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:O,pointIdAccessor:M,annotations:C,frameProps:_={},selection:P,linkedHover:L,onObservation:T,onClick:R,hoverHighlight:N,chartId:E,loading:B,loadingContent:D,emptyContent:I,legendInteraction:H,legendPosition:F,color:$,stroke:W,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=Mr({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:N,chartType:"QuadrantChart",chartId:E,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:B,loadingContent:D,emptyContent:I,width:G,height:q});vr("QuadrantChart",oe,"xAccessor",d),vr("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?$||Wi:i&&n?p.topRight.color:i&&!n?p.topLeft.color:!i&&n?p.bottomRight.color:p.bottomLeft.color},[se,ae,g,f,p,$]),ce=t.useMemo(()=>w?e=>Ae(e,w,A,re):void 0,[w,A,re]),ue=Ur({colorBy:x,colorScale:ne.colorScale,color:$,pointRadius:j,fillOpacity:S,radiusFn:ce,fallbackFill:le,stroke:W,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(()=>ar([...de?[{label:de,accessor:de,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"}]:[]]),[de,d,h,ee,te,x,w,c,u]),ge=Ar({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:kn(O)||he}),(L||T||R||N)&&{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(cr,{componentName:"QuadrantChart",message:ge,width:G,height:q}):e.jsx(gr,{componentName:"QuadrantChart",width:G,height:q,children:e.jsx(si,Object.assign({ref:i},ve))})});gs.displayName="QuadrantChart";const fs="__ma_unitized",ps="__ma_series";function ys(e,t){const o=t[1]-t[0];return 0===o?.5:(e-t[0])/o}function ms(e,t){return t[0]+e*(t[1]-t[0])}const vs=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),{[fs]:ys(a,i),[ps]: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),{[fs]:ys(a,r),[ps]: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:O,hoverHighlight:M,chartId:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,legendPosition:R,stroke:N,strokeWidth:E,opacity:B}=o,{width:D,height:I,enableHover:H,showGrid:F,showLegend:$=!0,title:W,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=mr(_,D,I,P),Z=Q?null:yr(c,D,I,L),J=Gi(),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),{[fs]:i,[ps]: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),{[fs]:ys(r,e[n]),[ps]: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=ms(e,ne[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:te[1],tickFormat:V[1].format||(e=>{const t=ms(e,ne[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[K,ne,V,te]),re=Mr({data:t.useMemo(()=>oe.length>0?oe:te.map(e=>({[ps]:e})),[oe,te]),rawData:c,colorBy:ps,colorScheme:ee,legendInteraction:T,legendPosition:R,selection:A,linkedHover:j,fallbackFields:[ps],unwrapData:!1,onObservation:S,onClick:O,hoverHighlight:M,chartType:"MultiAxisLineChart",chartId:C,showLegend:$,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=_r({lineWidth:b,resolveStroke:t.useCallback(e=>se.get(e[ps])||ee[0],[se,ee]),stroke:N,strokeWidth:E,opacity:B,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[ps],i=te.indexOf(n),r=o[fs],s=K&&i>=0&&ne[i]?ms(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:fs,groupAccessor:ps,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),W&&{title:W}),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(cr,{componentName:"MultiAxisLineChart",message:ce,width:D,height:I}):e.jsx(gr,{componentName:"MultiAxisLineChart",width:D,height:I,children:e.jsx(si,Object.assign({ref:r},de))}))});vs.displayName="MultiAxisLineChart";const bs=t.forwardRef(function(o,n){const i=t.useRef(null);Pr(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:O,chartId:M,loading:C,loadingContent:_,emptyContent:P}=o,{width:L,height:T,enableHover:R,showGrid:N,title:E,description:B,summary:D,accessibleTable:I,xLabel:H,yLabel:F}=r,$=mr(C,L,T,_),W=$?null:yr(s,L,T,P),z=t.useMemo(()=>v(s),[s]),Y=null==f||null==p;vr("CandlestickChart",z,"xAccessor",d),vr("CandlestickChart",z,"highAccessor",h),vr("CandlestickChart",z,"lowAccessor",g),Y||(vr("CandlestickChart",z,"openAccessor",f),vr("CandlestickChart",z,"closeAccessor",p));const{customHoverBehavior:G,customClickBehavior:q,crosshairSourceId:X}=Ui({selection:A,linkedHover:j,onObservation:S,onClick:O,chartType:"CandlestickChart",chartId:M}),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 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})),ar(e)},[d,H,c,u,h,g,f,p,Y]),Q=Ar({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:N}),o.pointIdAccessor&&{pointIdAccessor:o.pointIdAccessor}),Fr({title:E,description:B,summary:D,accessibleTable:I,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:m,defaultTooltipContent:K})),$r({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(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 xs(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 ks(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 ws(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 As(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"}}bs.displayName="CandlestickChart";const js={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:xs,donut:xs,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:ks(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:ks(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,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($(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($(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($(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($(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 Ss{constructor(e){this.rExtent=new E,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 N(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 E)):(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 N(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=js[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=ws(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:As(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,Ss.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 E)):(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 Os(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 Ms(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 Cs(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 _s(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 Ps(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 Ls(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||Ts)(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 Ts(e){return Math.round(100*e)/100+""}function Rs(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:O,annotations:M,svgAnnotationRules:C,xAccessor:_,yAccessor:P,annotationData:L,underlayRendered:T,children:R}=o,N="radial"===(null==u?void 0:u.projection),E="horizontal"===(null==u?void 0:u.projection),B=!1!==h,D=t.useMemo(()=>d&&B&&u&&!N?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,B,u,p,N]),I=o.rTickValues,H=o.tickLabelEdgeAlign,F=o.axisExtent,$=t.useMemo(()=>d&&u&&!N?(I||ho(u.r,5,F)).map(e=>({value:e,pixel:u.r(e),label:(y||Ts)(e)})):[],[d,u,y,N,I,F]),W=t.useRef(new Map),z=t.useRef(null!==(n=null==M?void 0:M.length)&&void 0!==n?n:0),Y=null!==(i=null==M?void 0:M.length)&&void 0!==i?i:0;z.current!==Y&&(z.current=Y,W.current=new Map);const G=t.useMemo(()=>{if(!M||0===M.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:_,yAccessor:P,width:r,height:s,data:L,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return M.map((t,o)=>{if(C){const i=C(t,o,n);return null!=i?i:e(t,o,n)}return e(t,o,n)}).filter(Boolean)},[M,C,r,s,u,_,P,L]);return d||v||b||O||G&&G.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&&!N&&!T&&e.jsx("g",{className:"ordinal-grid",children:$.map((t,o)=>e.jsx("line",{x1:E?t.pixel:0,y1:E?0:t.pixel,x2:E?t.pixel:r,y2:E?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+o))}),d&&u&&!N&&(()=>{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,E?{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}),D.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})})(),D.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})]})]})})})(),G,O,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 Ns({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 Es(e,t){var o,n,i,r;const s=t._gradientBand.colors;if(0===s.length)return;const{clipPath:a,slices:l}=Oo({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 Bs(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 Ds(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()}Ss.QUADTREE_THRESHOLD=500;const Is=(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)Es(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(Bs(e,t),Bn(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),Ds(e,t)):(Bs(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&&(Bs(e,t),Bn(e,t)),e.globalAlpha=1}}},Hs=(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()}},Fs=(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()}},$s=(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}},Ws=(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 zs(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 Ys(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let Gs=null;const qs=new Map;function Xs(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):(Gs||(Gs=document.createElement("canvas")),Gs.width=e,Gs.height=e,Gs)}(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 Vs(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 Us(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 Ks(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const Qs=e=>[$s,...e],Zs={bar:Qs([Wn]),clusterbar:Qs([Wn]),point:Qs([Hn]),swarm:Qs([Hn]),pie:[Is],donut:[Is],boxplot:Qs([Hs,Hn]),violin:Qs([Fs]),histogram:Qs([Wn]),ridgeline:Qs([Fs]),timeline:Qs([Wn]),funnel:[Wn,Ws,(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?zs(i):null!=r?`${zs(i)} (${Ys(r)})`:zs(i),e.measureText(c).width+16>n){if(l||null==r)continue;if(c=zs(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=Xs(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?Ks(i):"",d=Us(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(),Vs(e,m,v,f,p,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),Vs(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:Qs([Wn]),custom:Qs([Wn,Hn,Is,Hs,Fs,Ws])},Js={top:50,right:40,bottom:60,left:70},ea={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 ta({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:ea,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:ea,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:ea,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:ea,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:ea,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:ea,children:[f&&e.jsx("div",{style:{fontWeight:"bold"},children:f+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}ta.ownsChrome=!0;const oa=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:N,responsiveHeight:E,margin:B,barPadding:D,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:$,innerRadius:W,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:Ne,legendClickBehavior:Ee,legendHighlightedCategory:Be,legendIsolatedCategories:De,legendPosition:Ie,legendLayout:He,legendCategoryAccessor:Fe,onCategoriesChange:$e,backgroundGraphics:We,foregroundGraphics:ze,title:Ye,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=Mn({sizeProp:R,responsiveWidth:N,responsiveHeight:E,userMargin:B,marginDefault:Js,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:Ot,renderFnRef:Mt,scheduleRender:Pt}=ut,Lt=To(),Tt=Bo(),Rt=t.useMemo(()=>v(x),[x]),Nt=null!=pe?pe:be,Et=null!=ye?ye:xe,Bt=null!=me?me:ke,Dt=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,Yt]=t.useState(null),[Gt,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=Oe||Me,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:O,groupBy:M,multiAxis:C,timeAccessor:to?_:void 0,valueAccessor:to?P||("string"==typeof A||"function"==typeof A?A:void 0):void 0,categoryAccessor:to?L||k:void 0,rExtent:ne,oExtent:ie,axisExtent:Se,barPadding:D,roundedTop:I,gradientFill:H,trackFill:F,baselinePadding:$,innerRadius:W,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==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,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,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 Ss(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,Pt()},[no,Pt]);const so=t.useRef(null);so.current||(so.current=new w(e=>{const t=io.current;t&&t.ingest(e)&&(ct.current=!0,Pt())}));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,Pt()},[Pt]),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,Yt(null)),ct.current=!0,Pt()}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,Pt()),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,Pt]),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,Yt(null),_e&&_e(null),Pt()));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=Os(r,t,o);break;case"point":if(i)break;e=Ms(r,t,o,n);break;case"wedge":if(null===r.datum)break;e=Cs(r,t,o);break;case"boxplot":e=_s(r,t,o);break;case"violin":e=Ps(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,Yt(null),_e&&_e(null),Pt()));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,Yt(l),_e&&(_e(l),ct.current=!0),Pt()},go.current=()=>{Ht.current&&(Ht.current=null,Yt(null),_e&&(_e(null),ct.current=!0),Pt())};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({},Ct(t)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});return Ht.current=o,Yt(o),_e&&_e(o),void Pt()}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,Yt(null),_e&&_e(null),void Pt();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({},Ct(a)),{__oAccessor:"string"==typeof k?k:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});Ht.current=l,Yt(l),_e&&_e(l),Pt()},[_e,Pt]),xo=t.useCallback(e=>{yo.current=-1,mo.current=null,fo(e)},[fo]);Mt.current=()=>{var e,t;Ot.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=_n(),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?Zs.custom:Zs[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)&&(Ot.current=requestAnimationFrame(()=>Mt.current()))},Do({hydrated:Lt,wasHydratingFromSSR:Tt,storeRef:io,dirtyRef:ct,renderFnRef:Mt,cleanup:()=>{var e;return null===(e=so.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{ct.current=!0,Pt()},[m,pt,yt,ge,Xe,Pt]),_t(et,io,ct,Pt,Ut,Kt);const ko=eo&&zt?Ce?Ce(zt):e.jsx(ta,{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",""),No=Kn(A,void 0,"__semiotic_resolvedR",""),Eo=Ro.key,Ho=No.key,Fo=Qn(Ro,No,Pe&&Pe.length>0||!1);if(Po||!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 Ye?Ye:"Ordinal chart"),style:{position:"relative",width:N?"100%":gt[0],height:E?"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=_o(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=Co(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})`:Co(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:Co(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=_o(`${n?n+"-":""}gauge-grad-${i.category||m}-${o}`),{clipPath:s,slices:u}=Oo({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:Co(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(Mo)||""}return e.jsx("path",{d:u,transform:`translate(${i.cx},${i.cy})`,fill:Co(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:Co(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:Co(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:Co(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:Co(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(Rs,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:n,showAxes:ge,showCategoryTicks:fe,oLabel:Nt,rLabel:Et,oFormat:Bt,rFormat:Dt,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,showGrid:Te,title:Ye,legend:Re,legendHoverBehavior:Ne,legendClickBehavior:Ee,legendHighlightedCategory:Be,legendIsolatedCategories:De,legendPosition:Ie,legendLayout:He,foregroundGraphics:Ge(mt,null===(a=io.current)||void 0===a?void 0:a.customLayoutOverlays),annotations:Pe,svgAnnotationRules:Le,annotationFrame:0,xAccessor:Eo,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 Ye?Ye:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:N?"100%":gt[0],height:E?"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 Ye?Ye:void 0}),e.jsx(cn,{summary:st}),e.jsxs("div",{role:"img","aria-label":it||("string"==typeof Ye?Ye:"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(Ls,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Gt,showAxes:ge,showGrid:Te,rFormat:Dt,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(Rs,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Gt,showAxes:ge,showCategoryTicks:fe,oLabel:Nt,rLabel:Et,oFormat:Bt,rFormat:Dt,rTickValues:Ae,axisExtent:Se,showGrid:Te,title:Ye,legend:Re,legendHoverBehavior:Ne,legendClickBehavior:Ee,legendHighlightedCategory:Be,legendIsolatedCategories:De,legendPosition:Ie,legendLayout:He,foregroundGraphics:Ge(mt,Qt),annotations:Pe,svgAnnotationRules:Le,annotationFrame:Xt,xAccessor:Eo,yAccessor:Ho,annotationData:Fo(null===(h=io.current)||void 0===h?void 0:h.getData()),underlayRendered:!0}),(tt||ot)&&"radial"!==T&&e.jsx(Ns,{width:pt,height:yt,totalWidth:gt[0],totalHeight:gt[1],margin:ft,scales:Gt,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 na({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 ia(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(()=>Cr(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])}oa.displayName="StreamOrdinalFrame";const ra=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:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:N,legendInteraction:E,legendPosition:B,color:D,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:$,categoryFormat:W,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=Mr({data:te,rawData:s,colorBy:g,colorScheme:f,legendInteraction:E,legendPosition:B,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:N,width:Y,height:G}),{effectiveLegendProps:ne,effectiveMargin:ie}=na({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=Gi(),ae=t.useMemo(()=>new Map,[te]),le=ia({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(()=>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:Y,height:G});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:[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}),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: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(gr,{componentName:"BarChart",width:Y,height:G,children:e.jsx(oa,Object.assign({ref:r},ge))})});ra.displayName="BarChart";const sa=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:O,linkedHover:M,onObservation:C,onClick:_,hoverHighlight:P,chartId:L,loading:T,loadingContent:R,emptyContent:N,legendInteraction:E,legendPosition:B,color:D,stroke:I,strokeWidth:H,opacity:F,categoryFormat:$}=o,{width:W,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=Mr({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:E,legendPosition:B,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:N,width:W,height:z});if(te.earlyReturn)return te.earlyReturn;const oe=Gi(),ne=t.useMemo(()=>new Map,[J]),ie=ia({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(()=>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}=na({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:Y}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),$&&{oFormat:$}),{showGrid:G}),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: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(cr,{componentName:"StackedBarChart",message:se,width:W,height:z}):e.jsx(gr,{componentName:"StackedBarChart",width:W,height:z,children:e.jsx(oa,Object.assign({ref:r},ce))})});sa.displayName="StackedBarChart";const aa=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:O,onObservation:M,onClick:C,hoverHighlight:_,chartId:P,loading:L,loadingContent:T,emptyContent:R,legendInteraction:N,legendPosition:E,color:B,stroke:D,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:$,height:W,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=Mr({data:Z,rawData:s,colorBy:J,colorScheme:p,legendInteraction:N,legendPosition:E,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:$,height:W});if(ee.earlyReturn)return ee.earlyReturn;const te=Gi(),oe=t.useMemo(()=>new Map,[Z]),ne=ia({colorBy:J,colorScale:ee.colorScale,color:B,themeCategorical:te,colorScheme:p,categoryIndexMap:oe,userPieceStyle:j.pieceStyle,stroke:D,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}=na({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),Fr({title:q,description:X,summary:V,accessibleTable:U,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:ie})),$r({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(cr,{componentName:"GroupedBarChart",message:re,width:$,height:W}):e.jsx(gr,{componentName:"GroupedBarChart",width:$,height:W,children:e.jsx(oa,Object.assign({ref:r},le))})});function la({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}:{}}}aa.displayName="GroupedBarChart";const ca=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);Pr(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:N,loadingContent:E,emptyContent:B,legendInteraction:D,legendPosition:I,color:H,stroke:F,strokeWidth:$,opacity:W,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=Mr({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:N,loadingContent:E,emptyContent:B,width:G,height:q}),ie=la({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=Gi(),ae=t.useMemo(()=>new Map,[oe]),le=ia({colorBy:g,colorScale:ne.colorScale,color:H,themeCategorical:se,colorScheme:f,categoryIndexMap:ae,userPieceStyle:null==M?void 0:M.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: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),Fr({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:o.animate,axisExtent:o.axisExtent})),Wr({tooltip:k,defaultTooltipContent:ce})),$r({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(gr,{componentName:"SwarmPlot",width:G,height:q,children:e.jsx(oa,Object.assign({ref:r},de))})});function ua(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+""})})}}ca.displayName="SwarmPlot";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);Pr(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:N,strokeWidth:E,opacity:B,showCategoryTicks:D,categoryFormat:I}=o,{width:H,height:F,enableHover:$,showGrid:W,showLegend:z,title:Y,description:G,summary:q,accessibleTable:X,categoryLabel:V,valueLabel:U}=i,K=t.useMemo(()=>v(s),[s]),Q=Mr({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=Gi(),J=t.useMemo(()=>new Map,[K]),ee=ia({colorBy:g,colorScale:Q.colorScale,color:R,themeCategorical:Z,colorScheme:f,categoryIndexMap:J,userPieceStyle:void 0,stroke:N,strokeWidth:E,opacity:B,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),te=t.useMemo(()=>ua(),[]),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:D}),Q.legendBehaviorProps),Fr({title:Y,description:G,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: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(gr,{componentName:"BoxPlot",width:H,height:F,children:e.jsx(oa,Object.assign({ref:r},ne))})});da.displayName="BoxPlot";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:"horizontal"}),r=t.useRef(null);Pr(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:N,legendPosition:E,color:B,stroke:D,strokeWidth:I,opacity:H,showCategoryTicks:F,categoryFormat:$}=o,{width:W,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=Mr({data:J,rawData:s,colorBy:f,colorScheme:p,legendInteraction:N,legendPosition:E,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:W,height:z}),te=la({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=Gi(),ie=t.useMemo(()=>new Map,[J]),re=ia({colorBy:f,colorScale:ee.colorScale,color:B,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: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:Y}),o.dataIdAccessor&&{dataIdAccessor:o.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:g}),$&&{oFormat:$}),{showGrid:G,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: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(gr,{componentName:"Histogram",width:W,height:z,children:e.jsx(oa,Object.assign({ref:r},le))})});ha.displayName="Histogram";const ga=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);Pr(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:N,legendInteraction:E,legendPosition:B,color:D,stroke:I,strokeWidth:H,opacity:F,showCategoryTicks:$,categoryFormat:W}=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=Mr({data:ee,rawData:s,colorBy:p,colorScheme:y,legendInteraction:E,legendPosition:B,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:N,width:z,height:Y}),oe=la({brushProp:w,onBrushProp:A,linkedBrush:j,valueAccessor:u});if(te.earlyReturn)return te.earlyReturn;const ne=Gi(),ie=t.useMemo(()=>new Map,[ee]),re=ia({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(()=>ua({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: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}),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: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(gr,{componentName:"ViolinPlot",width:z,height:Y,children:e.jsx(oa,Object.assign({ref:r},le))})});ga.displayName="ViolinPlot";const fa=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);Pr(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:N,legendPosition:E,color:B,stroke:D,strokeWidth:I,opacity:H,categoryFormat:F}=o,{width:$,height:W,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=Mr({data:Z,rawData:a,colorBy:f,colorScheme:p,legendInteraction:N,legendPosition:E,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:$,height:W});if(J.earlyReturn)return J.earlyReturn;const ee=Vi(Z,y,d),te=Gi(),oe=t.useMemo(()=>new Map,[Z]),ne=ia({colorBy:f,colorScale:J.colorScale,color:B,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(()=>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:Y,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: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(gr,{componentName:"DotPlot",width:$,height:W,children:e.jsx(oa,Object.assign({ref:s},le))})});fa.displayName="DotPlot";const pa=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);Pr(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:N,stroke:E,strokeWidth:B,opacity:D,showCategoryTicks:I,categoryFormat:H}=o,{width:F,height:$,enableHover:W,showGrid:z,showLegend:Y,title:G,description:q,summary:X,accessibleTable:V,categoryLabel:U,valueLabel:K}=i,Q=t.useMemo(()=>v(s),[s]),Z=Mr({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:$});if(Z.earlyReturn)return Z.earlyReturn;const J=Gi(),ee=t.useMemo(()=>new Map,[Q]),te=ia({colorBy:p,colorScale:Z.colorScale,color:N,themeCategorical:J,colorScheme:y,categoryIndexMap:ee,userPieceStyle:void 0,stroke:E,strokeWidth:B,opacity:D,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),oe=t.useMemo(()=>ua(),[]),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:G,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: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(gr,{componentName:"RidgelinePlot",width:F,height:$,children:e.jsx(oa,Object.assign({ref:r},ie))})});pa.displayName="RidgelinePlot";const ya=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:O,loading:M,loadingContent:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:N,opacity:E}=o,{width:B,height:D,enableHover:I,showLegend:H,title:F,description:$,summary:W,accessibleTable:z}=s,Y=t.useMemo(()=>v(l),[l]),G=g||d,q=Mr({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:B,height:D});if(q.earlyReturn)return q.earlyReturn;const X=Gi(),V=t.useMemo(()=>new Map,[Y]),U=ia({colorBy:G,colorScale:q.colorScale,color:T,themeCategorical:X,colorScheme:f,categoryIndexMap:V,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:N,opacity:E,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}=na({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:[B,D],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:B,height:D}):e.jsx(gr,{componentName:"PieChart",width:B,height:D,children:e.jsx(oa,Object.assign({ref:a},ee))})});ya.displayName="PieChart";const ma=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:O,loading:M,loadingContent:C,emptyContent:_,legendInteraction:P,legendPosition:L,color:T,stroke:R,strokeWidth:N,opacity:E}=o,{width:B,height:D,enableHover:I,showLegend:H,title:F,description:$,summary:W,accessibleTable:z}=i,Y=t.useMemo(()=>v(s),[s]),G=g||c,q=Mr({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:B,height:D});if(q.earlyReturn)return q.earlyReturn;const X=null!=d?d:Math.max(2,.15*Math.min(B,D)),V=Gi(),U=t.useMemo(()=>new Map,[Y]),K=ia({colorBy:G,colorScale:q.colorScale,color:T,themeCategorical:V,colorScheme:f,categoryIndexMap:U,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:R,strokeWidth:N,opacity:E,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}=na({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:[B,D],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:B,height:D}):e.jsx(gr,{componentName:"DonutChart",width:B,height:D,children:e.jsx(oa,Object.assign({ref:r},te))})});function va(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 ba(e){return Math.max(0,Math.min(1,e))}function xa(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 ka(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 wa(e,t){const o=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:ba(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=ba(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=xa(t.color),l=xa(i.color);if(!a||!l)return.5>s?t.color:i.color;const[c,u,d]=a,[h,g,f]=l;return ka(c+(h-c)*s,u+(g-u)*s,d+(f-d)*s)}return o[o.length-1].color}function Aa(e,t,o){return`${e}-${t}`}ma.displayName="DonutChart";const ja=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:O={},className:M,stroke:C,strokeWidth:_,opacity:P}=o,{width:L,height:T,title:R,description:N,summary:E,accessibleTable:B}=i,D=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=Aa("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(wa(c.colorStops,e*(t+.5)/o));const i=Aa("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=Aa("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=Aa("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:D}),[l,c,u,d,g,f,k,A,D]),Y=t.useMemo(()=>Cr(W,{stroke:C,strokeWidth:_,opacity:P}),[W,C,_,P]),{sweepRad:G,startAngleDeg:q}=va(w),X=function(e=240){const{sweepRad:t,offsetRad:o}=va(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*G,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,G,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*G,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,G,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:Y,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}),N&&{description:N}),E&&{summary:E}),void 0!==B&&{accessibleTable:B}),M&&{className:M}),null!=o.animate&&{animate:o.animate}),O);return e.jsx(gr,{componentName:"GaugeChart",width:L,height:T,children:e.jsx(oa,Object.assign({ref:r},le))})});ja.displayName="GaugeChart";const Sa=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);Pr(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:N,opacity:E,categoryFormat:B}=o,D="vertical"===f,{width:I,height:H,enableHover:F,showLegend:$,title:W,description:z,summary:Y,accessibleTable:G}=i,q=D?{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=Mr({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:$,userMargin:a,marginDefaults:q,loading:M,loadingContent:C,emptyContent:_,width:I,height:H});if(K.earlyReturn)return K.earlyReturn;vr("FunnelChart",X,"stepAccessor",c),vr("FunnelChart",X,"valueAccessor",u);const Q=Gi(),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=ia({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:N,opacity:E,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: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}),B&&{oFormat:B}),{showGrid:D}),!D&&{connectorOpacity:p}),{showLabels:y}),K.legendBehaviorProps),W&&{title:W}),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: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(oa,Object.assign({ref:r},ne))})});Sa.displayName="FunnelChart";const Oa={RdBu:ce,PiYG:ue,PRGn:de,BrBG:he,RdYlBu:ge,RdYlGn:fe,Spectral:pe},Ma="__likert_neutral_neg",Ca="__likert_neutral_pos";function _a(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 La(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:Ma,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:Ca,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function Ta(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===Ma?r=o:o.__likertLevel===Ca?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 Ra=new Map,Na=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,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:N,stroke:E,strokeWidth:B,opacity:D}=o,{width:I,height:H,enableHover:F,showGrid:$,showLegend:W,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=$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=Oa[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(()=>_a(n,"question"),[n]),d=t.useMemo(()=>c?_a(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:_a(r,"level"),[c,r]),g=t.useMemo(()=>c?null:_a(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=La(e,o),e=Ta(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=La(n,o),n=Ta(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=Gi(),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)},[]);Mi(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=Mr({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:W,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=ia({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:Ra,userPieceStyle:null==k?void 0:k.pieceStyle,stroke:E,strokeWidth:B,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===Ma||i===Ca)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===Ma||o===Ca?de:o,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=o===Ma||o===Ca?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(()=>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}),N&&{oFormat:N}),{showGrid:$}),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:kn(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(cr,{componentName:"LikertChart",message:ge,width:I,height:H}):e.jsx(gr,{componentName:"LikertChart",width:I,height:H,children:e.jsx(oa,Object.assign({ref:r},be))})});Na.displayName="LikertChart";const Ea=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:O,onClick:M,hoverHighlight:C,chartId:_,loading:P,loadingContent:L,emptyContent:T,legendInteraction:R,legendPosition:N,color:E,stroke:B,strokeWidth:D,opacity:I,categoryFormat:H,rTickValues:F,tickLabelEdgeAlign:$,showCategoryTicks:W,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=Mr({data:ie,rawData:s,colorBy:re,colorScheme:p,legendInteraction:R,legendPosition:N,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=la({brushProp:x,onBrushProp:k,linkedBrush:w,valueAccessor:d});if(ae.earlyReturn)return ae.earlyReturn;const ce=Gi(),ue=t.useMemo(()=>new Map,[ie]),de=ia({colorBy:re,colorScale:ae.colorScale,color:E,themeCategorical:ce,colorScheme:p,categoryIndexMap:ue,userPieceStyle:null==A?void 0:A.pieceStyle,stroke:B,strokeWidth:D,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}=na({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: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(cr,{componentName:"SwimlaneChart",message:ge,width:X,height:V}):e.jsx(gr,{componentName:"SwimlaneChart",width:X,height:V,children:e.jsx(oa,Object.assign({ref:r},ye))})});Ea.displayName="SwimlaneChart";const Ba={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},Da={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Ia{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?Ha(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 Ha(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];Fa(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;Fa(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 Fa(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 $a(e,t){var o=e.get(t);if(!o)throw Error("missing: "+t);return o}function Wa(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 za(e){return e.y0-e.y1>0?"up":"down"}function Ya(e,t){return t(e.source)==t(e.target)}function Ga(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 qa(e){return e.target.x0-e.source.x1}function Xa(e,t){var o=Ua(e),n=qa(t)/Math.tan(o);return"up"==za(e)?e.y1-n:e.y1+n}function Va(e,t){var o=Ua(e),n=qa(t)/Math.tan(o);return"up"==za(e)?e.y1+n:e.y1-n}function Ua(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Ka(e,t){return t(e)}function Qa(e){return Ja(e.source)}function Za(e){return Ja(e.target)}function Ja(e){return(e.y0+e.y1)/2}function el(e){return e.virtual?0:e.value}function tl(e,t){var o=0;e.sourceLinks.forEach(function(e){o=e.circular&&!Ya(e,t)?o+1:o});var n=0;return e.targetLinks.forEach(function(e){n=e.circular&&!Ya(e,t)?n+1:n}),o+n}function ol(e){return e.target.depth}function nl(e,t){return e.sourceLinks.length?e.depth:t-1}function il(e,t){return e.y0-t.y0}function rl(e,t){return t.y0-e.y0}function sl(e,t){return e.y1-t.y1}function al(e,t){return t.y1-e.y1}function ll(e,t){return ul(e.source,t.source)||e.index-t.index}function cl(e,t){return ul(e.target,t.target)||e.index-t.index}function ul(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function dl(e,t){return hl(e)==hl(t)?"bottom"==e.circularLinkType?rl(e,t):il(e,t):hl(t)-hl(e)}function hl(e){return e.target.column-e.source.column}function gl(e,t){return fl(e)==fl(t)}function fl(e){return e.y0-e.y1>0?"up":"down"}function pl(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}),yl(r.links.filter(function(e){return"top"==e.circularLinkType}),t,o),yl(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,Ya(e,t)&&Ga(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?rl:il);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?al:sl),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 yl(e,t,o){e.sort(dl);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(Ya(e,t)&&Ga(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&&ml(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 ml(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function vl(e){return function(){return e}}function bl(e){return e.index}function xl(e){return e.nodes}function kl(e){return e.links}function wl(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+=Ja(e.source)*t,n+=t}}),o.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Ja(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?tl(t,o)-tl(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==tl(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 Al(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&&tl(i,o)>0){var c=a.mean(i.sourceLinks,Za),u=a.mean(i.targetLinks,Qa),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Ja(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,Za),f=a.mean(i.targetLinks,Qa),p=((g&&f?(g+f)/2:g||f)-Ja(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||ul),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 jl(e){e.nodes.forEach(function(e){e.sourceLinks.sort(cl),e.targetLinks.sort(ll)}),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 Sl(){var e=0,t=0,o=1,n=1,i=24,r=8,s=null,l=bl,c=nl,u=void 0,d=32,h=2,g=xl,f=kl;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=$a(o,n)),"object"!=typeof i&&(i=e.target=$a(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=Wa(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){Ka(e,t)!=Ka(i.source,t)&&Ka(e,t)!=Ka(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),Ya(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,el),a.sum(e.targetLinks,el)),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),wl(g,u,l),Al(g,u,l,f,f,d),jl(g),pl(g,l,h,10,8),wl(g,u,l),Al(g,u,l,f,f,d),jl(g),pl(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 Ka(o.source,t)==Ka(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(!gl(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var o=Xa(t,e);return e.y1-o}if(t.target.column>e.target.column)return Xa(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 Ka(o.target,t)==Ka(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(!gl(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var o=Va(t,e);return e.y0-o}if(t.source.column>e.source.column)return Va(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),pl(g,l,h,10,8)}(p),p}return p.update=function(e){return jl(e),pl(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:vl(e),p):g},p.links=function(e){return arguments.length?(f="function"==typeof e?e:vl(e),p):f},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:vl(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:vl(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 Ol(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 Ml=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}=Ol({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 Cl(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 _l=new Set,Pl=new WeakMap;function Ll(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}`;_l.has(e)||(_l.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 Tl={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(ol))-1:0},justify:nl};function Rl(e){return"string"==typeof e?e:e.id}const Nl={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=Sl().extent(v).links(m).nodes(y).nodeAlign(Tl[h]||nl).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=Rl(e.source),o=Rl(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(Ll(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(Ll(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?Cl(e):Ml(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}}},El={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=Bl(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=Dl(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=Dl(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=Il(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=Il(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(Ll(t,"nodeSize")),n=d?d(Ll(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(Ll(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(Ll(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 Bl(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 Dl(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 Il(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 Hl=K,Fl={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:Hl,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(Ll(o,"nodeStyle")).fill||b.get(o.id)||v[t%v.length]:b.get(o.id)||v[t%v.length];const s=p?p(Ll(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=$l(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(Ll(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(Ll(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 $l(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 Wl=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function zl(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 Yl(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 Gl(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 ql(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Wl}function Xl(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 Vl(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 Ul={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:Yl(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?Kl(r,n,o):"treemap"===s||"partition"===s?Ql(r,n):"circlepack"===s&&Zl(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(Ll(t,"nodeStyle"));let l=r.fill||Xl(o);if(o.colorByDepth&&void 0!==t.depth){const e=ql(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=Vl(i,s,a,l,m),f=r(Ll(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=Gl(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(Ll(o,"nodeStyle"));let l=a.fill||Xl(t);if(t.colorByDepth&&void 0!==o.depth){const e=ql(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=Gl(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(Ll(c,"nodeStyle")).fill||Xl(t);if(t.colorByDepth&&void 0!==c.depth){const e=ql(t);f=e[c.depth%e.length]}const p="string"==typeof f?zl(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(Ll(o,"nodeStyle"));let c=l.fill||Xl(t);if(t.colorByDepth&&void 0!==o.depth){const e=ql(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=Gl(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(Ll(i,"nodeStyle")).fill||Xl(t);if(t.colorByDepth&&void 0!==i.depth){const e=ql(t);a=e[i.depth%e.length]}if(s){const o="string"==typeof a?zl(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 Kl(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 Ql(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 Zl(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 Jl(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const ec={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=Jl(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=Jl(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(Ll(t,"nodeSize")),n=d?d(Ll(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(Ll(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=Jl(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)},tc={sankey:Nl,force:El,chord:Fl,tree:Ul,cluster:Ul,treemap:Ul,circlepack:Ul,partition:Ul,orbit:ec};function oc(e){return tc[e]}class nc{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({},Ba),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Ia(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({},Ba),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new Ia(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({},ic(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({},ic(n)),{data:o})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},ic(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&&rc(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,ic(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(o)||(this.nodes.set(o,ic(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=oc(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=ws(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:As(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=oc(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=oc(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const o=oc(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 ic(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 rc(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(!sc(e))return!1;return!0}return sc(t.points)}function sc(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 ac(e,t,o,n,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=lc(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=gc(e,o,n);t&&s>t.distance&&(r=t,s=t.distance)}return r}function lc(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 cc=null,uc=null;function dc(){return uc||(cc=document.createElement("canvas"),cc.width=1,cc.height=1,uc=cc.getContext("2d")),uc}function hc(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 gc(e,t,o){switch(e.type){case"bezier":return function(e,t,o){if(!e.pathD)return null;const n=hc(e),i=dc();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=hc(e),i=dc();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 fc(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 pc(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function yc(e,t){var o,n,i,r,s,a;if(!t.pathD)return;e.save();const l=pc(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 mc(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 vc(e,t){var o,n,i,r;if(!t.pathD)return;e.save();const s=pc(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 bc(e,t){var o,n;if(!t.pathD)return;e.save();const i=pc(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()}fc.displayName="NetworkSVGOverlay";const xc={top:20,right:80,bottom:20,left:80},kc={top:40,right:40,bottom:40,left:40},wc=new Set(["chord","force","circlepack","orbit"]),Ac=[800,600],jc={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 Sc({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:jc,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:jc,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:jc,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()})`]})]})}Sc.ownsChrome=!0;const Oc=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:N,childrenAccessor:E,hierarchySum:B,orientation:D="horizontal",nodeAlign:I="justify",nodePaddingRatio:H=.05,nodeWidth:F=15,iterations:$=300,forceStrength:W=.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=Ac,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,legendLayout:Pe,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Ne,title:Ee,foregroundGraphics:Be,backgroundGraphics:De,decay:Ie,pulse:He,transition:Fe,animate:$e,staleness:We,thresholds:ze,accessibleTable:Ye=!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=wc.has(j)?kc:xc,st=t.useRef(!0),at=Mn({sizeProp:he,responsiveWidth:ge,responsiveHeight:fe,userMargin:pe,marginDefault:it,foregroundGraphics:Be,backgroundGraphics:De,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,Ot=To(),Ct=Bo(),Pt=t.useMemo(()=>v(O),[O]),Lt=t.useMemo(()=>Array.isArray(M)?v(M):M,[M]),Tt=t.useMemo(()=>Object.assign(Object.assign({},Ba),Q),[Q]),Rt=t.useMemo(()=>Object.assign(Object.assign({},Da),J),[J]),Nt=t.useMemo(()=>{var e;return{chartType:j,nodeIDAccessor:P,sourceAccessor:L,targetAccessor:T,valueAccessor:R,edgeIdAccessor:N,childrenAccessor:E,hierarchySum:B,orientation:D,nodeAlign:I,nodePaddingRatio:H,nodeWidth:F,iterations:$,forceStrength:W,padAngle:z,groupWidth:Y,sortGroups:G,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,P,L,T,R,E,B,D,I,H,F,$,W,z,Y,G,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]),Et=Io(Nt),Bt=t.useRef(null),Dt=t.useRef(0),It=t.useRef(0),Ht=t.useRef(!1),Ft=t.useRef(null);Ft.current||(Ft.current=new nc(Et));const[$t,Wt]=t.useState(null),[zt,Yt]=t.useState(0),[Gt,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(Et),st.current=!0,kt()},[Et,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,Yt(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,Yt(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 P?P(Qt.current.data):Qt.current.data[P]: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:!N||!o||("function"==typeof N?N:e=>null==e?void 0:e[N])(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?C||(Array.isArray(M)?void 0:M):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=Pt,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()}},[Pt,Lt,C,fo,go,ht,gt,Et,kt,ne,so]),t.useEffect(()=>{_&&_.length>0&&co(_)},[]);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=Bt.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=ac(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=Bt.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=ac(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),Oo=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=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:[],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]),_o=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=Bt.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=Ft.current;if(!c)return;const u=performance.now(),d=Dt.current?Math.min((u-Dt.current)/1e3,.1):.016;Dt.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=_n();if(!Cn(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":yc(e,o);break;case"line":mc(e,o);break;case"ribbon":vc(e,o);break;case"curved":bc(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)),Nn(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()),En(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:Da.spawnRate,a=null!==(r=n.maxPerEdge)&&void 0!==r?r:Da.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:Da.radius,l=null!==(s=n.opacity)&&void 0!==s?s:Da.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=Bt.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()))},Do({hydrated:Ot,wasHydratingFromSSR:Ct,storeRef:Ft,dirtyRef:st,renderFnRef:xt}),t.useEffect(()=>{st.current=!0,kt()},[j,ht,gt,ve,kt]),_t(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(Sc,{data:$t})}):null;if(Po||!Ot&&Ct){const t=Ft.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,[ht,gt]),t.buildScene([ht,gt]);else{const e=Pt,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 Ee?Ee:"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:Co(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:Co(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:Co(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:Co(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:Co(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)(Mo)||"";return e.jsx("path",{d:i,transform:`translate(${n.cx},${n.cy})`,fill:Co(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(fc,{width:ht,height:gt,totalWidth:ut[0],totalHeight:ut[1],margin:dt,labels:i,sceneNodes:o,title:Ee,legend:Ce,legendPosition:_e,legendLayout:Pe,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Ne,foregroundGraphics:Ge(ft,null===(g=Ft.current)||void 0===g?void 0:g.customLayoutOverlays),annotations:Oe,svgAnnotationRules:Me,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 Ee?Ee:"Network chart"),tabIndex:0,style:{position:"relative",width:ge?"100%":ut[0],height:fe?"100%":ut[1],overflow:"visible"},onKeyDown:Oo,children:[Ye&&e.jsx(un,{tableId:vt}),Ye&&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 Ee?Ee:void 0}),e.jsx(cn,{summary:Xe}),e.jsxs("div",{role:"img","aria-label":qe||("string"==typeof Ee?Ee:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?_o: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:Bt,"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(fc,{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:Ee,legend:Ce,legendPosition:_e,legendLayout:Pe,legendHoverBehavior:Le,legendClickBehavior:Te,legendHighlightedCategory:Re,legendIsolatedCategories:Ne,foregroundGraphics:Ge(ft,Ut),annotations:Oe,svgAnnotationRules:Me,annotationFrame:Gt}),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 Mc(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 Cc(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 _c(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 Lc(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]),_=mr(A,k,w,j),P=_?null:yr("nodes"===O?void 0===o?void 0:C:void 0===n?void 0:M,k,w,S),L=t.useMemo(()=>i?Cc(C,M,r,s):C,[i,C,M,r,s]),T=Xi(L,a,l),R=Gi(),N=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]),E=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]),B=Zi(d,a,E),{legend:D,margin:I,legendPosition:H}=Qi({data:L,colorBy:a,colorScale:T,showLegend:c,legendPosition:u,userMargin:x,defaults:b,categories:E}),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:Y,crosshairSourceId:G}=F;return{safeNodes:L,safeEdges:M,colorScale:T,effectivePalette:N,themeCategorical:R,allCategories:E,legendState:B,legend:D,margin:I,legendPosition:H,customHoverBehavior:$,customClickBehavior:W,activeSelectionHook:z,hoverSelectionHook:Y,crosshairSourceId:G,loadingEl:_,emptyEl:P}}Oc.displayName="StreamNetworkFrame";const Tc=t.forwardRef(function(o,n){var i;const r=t.useRef(null);Pr(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:O={},onObservation:M,onClick:C,chartId:_,selection:P,linkedHover:L,loading:T,loadingContent:R,emptyContent:N,legendInteraction:E,legendPosition:B,stroke:D,strokeWidth:I,opacity:H}=o,F=null!==(i=null!=d?d:h)&&void 0!==i?i:"id",{width:$,height:W,enableHover:z,showLegend:Y,showLabels:G=!1,title:q,description:X,summary:V,accessibleTable:U}=s,K=Lc({nodes:a,edges:l,inferNodes:!1,sourceAccessor:g,targetAccessor:f,colorBy:y,colorScheme:m,showLegend:Y,legendPosition:B,legendInteraction:E,selection:P,linkedHover:L,onObservation:M,onClick:C,chartType:"ForceDirectedGraph",chartId:_,marginDefaults:s.marginDefaults,userMargin:c,width:$,height:W,loading:T,loadingContent:R,emptyContent:N,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(()=>Cr(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(()=>Cr(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=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(Oc,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:kn(S)||void 0,customHoverBehavior:L||M||C?K.customHoverBehavior:void 0,customClickBehavior:M||C?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},E&&"none"!==E&&{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))})});Tc.displayName="ForceDirectedGraph";const Rc=t.forwardRef(function(o,n){const i=t.useRef(null);Pr(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:O,selection:M,linkedHover:C,loading:_,loadingContent:P,emptyContent:L,legendInteraction:T,stroke:R,strokeWidth:N,opacity:E}=o,{width:B,height:D,enableHover:I,showLabels:H=!0,title:F,description:$,summary:W,accessibleTable:z}=r,Y=Lc({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:B,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?Cr(X,{stroke:R,strokeWidth:N,opacity:E}):void 0,[X,R,N,E]),U=t.useMemo(()=>{if(q)return Pc({edgeColorBy:y,colorBy:f,colorScale:Y.colorScale,nodeStyleFn:V||(e=>({fill:qi(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?Cr(U,{stroke:R,strokeWidth:N,opacity:E}):void 0,[U,R,N,E]),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:B,height:D}):Y.loadingEl?Y.loadingEl:Y.emptyEl?Y.emptyEl:e.jsx(gr,{componentName:"ChordDiagram",width:B,height:D,children:e.jsx(Oc,Object.assign({ref:i,chartType:"chord"},Y.safeNodes.length>0&&{nodes:Y.safeNodes},null!=a&&{edges:Y.safeEdges},{size:[B,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:kn(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:$,summary:W,accessibleTable:z},null!=o.animate&&{animate:o.animate},A))})});Rc.displayName="ChordDiagram";const Nc=t.forwardRef(function(o,n){const i=t.useRef(null);Pr(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:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,loadingContent:T,emptyContent:R,showLegend:N,legendPosition:E,legendInteraction:B,stroke:D,strokeWidth:I,opacity:H}=o,{width:F,height:$,enableHover:W,showLabels:z=!0,title:Y,description:G,summary:q,accessibleTable:X}=r,V=Lc({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:f,colorScheme:p,showLegend:N,legendPosition:E,legendInteraction:B,selection:_,linkedHover:P,onObservation:O,onClick:M,chartType:"SankeyDiagram",chartId:C,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(()=>Cr(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(()=>Cr(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=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(Oc,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:P||O||M?V.customHoverBehavior:void 0,customClickBehavior:O||M?V.customClickBehavior:void 0,legend:V.legend,legendPosition:V.legendPosition},B&&"none"!==B&&{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 Ec(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 Bc(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function Dc(e,t){return e.map(e=>({t:Bc(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Ic(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 Hc(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 Fc(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 $c(e,t){return 1e3*Hc(e,t)+Fc(e,t)}function Wc(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function zc(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=Wc(e,t),s=$c(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=$c(t,o);if(s>d)s=d,r=Wc(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=$c(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=$c(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=$c(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 Yc(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=Hc(A,t),M=Fc(A,t)},P=()=>{O=Hc(A,t),C=Fc(A,t)};"crossing-min"===m?(_(),zc(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&&(_(),zc(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=$c(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=$c(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 N=[];let E=f+(null!==(h=null===(d=j[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;j.length>0&&N.push(E);for(let e=1;j.length>e;e++)E+=R[e-1]*p+f,N.push(E);if(j.length>0&&(E+=j[j.length-1].peak.botPeak*p+f),E>g){const e=g/E;for(let t=0;N.length>t;t++)N[t]*=e}const B=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]=N[A[t.id]];return{effectiveSlotsHeight:B,centerlines:D,laneLifetime:w,slots:j,slotByNode:A,slotCenter:N,crossingsBefore:S,crossingsAfter:O,lengthBefore:M,lengthAfter:C}}Nc.displayName="SankeyDiagram";const Gc=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 qc(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Xc(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function Vc(e,t){return"function"==typeof e?e(t):t[e]}const Uc=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:N,title:E,description:B,summary:D,accessibleTable:I,responsiveWidth:H,responsiveHeight:F,loading:$,loadingContent:W,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 Cc([],ue,u,d);const o=new Set,n=[];for(const t of e){const e=Vc(c,t)+"";o.has(e)||(o.add(e),n.push(t))}for(const e of t){const t=Vc(c,e)+"";o.has(t)||(o.add(t),n.push(e))}const i=Cc([],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=Vc(b,e);return null!=o?o+"":`${Vc(u,e)}-${Vc(d,e)}-${t}`},[b,u,d]),fe=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=Vc(u,t)&&null!=Vc(d,t)},[u,d]);Pr(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=Vc(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=Vc(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=>Vc(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?Vc(m,e):null;if(Array.isArray(o)&&2===o.length){const e=Xc(o[0]),n=Xc(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:Vc(u,e)+"",target:Vc(d,e)+"",value:Number(Vc(h,e)),startTime:Xc(Vc(g,e)),endTime:Xc(Vc(f,e)),__raw:e};if(p){const t=Xc(Vc(p,e));Number.isFinite(t)&&(o.systemInTime=t)}if(y){const t=Xc(Vc(y,e));Number.isFinite(t)&&(o.systemOutTime=t)}return o}),o=[Xc(a[0]),Xc(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=Lc({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:N,width:T,height:R,loading:$,loadingContent:W,emptyContent:z}),je=(null!=w?w:!!x)&&!!x,Se=t.useCallback(e=>null!=N&&("number"==typeof N||null!=N[e]),[N]),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]=Ec(t,c,u);const h=Yc(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]=Ec(t,c,u);const f=Yc(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=Yc(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]),Ne=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=Dc(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=Dc(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=Dc(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(Bc(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]=Ic(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]=Ic(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}=Ol(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]),Ee=t.useMemo(()=>({bands:Ne.bands,ribbons:Ne.ribbons,showLabels:L}),[Ne,L]),Be=t.useMemo(()=>{if(!je||!x)return;const e=new Map;(null!=de?de:[]).forEach((t,o)=>{const n=Vc(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:kn(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(!qc(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=Vc(u,i),s=Vc(d,i),a=Vc(h,i),l=Vc(g,i),c=Vc(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(Xc(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(Xc(c))})]})]})]})},[Pe,De,Ie,He,u,d,h,g,f]),$e=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(Xc(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=Xc(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]),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 Ne.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Ne]),Ye=t.useMemo(()=>(null!=ue?ue:[]).map((e,t)=>{const o=pe(e,t),n=Number(Vc(h,e));return{id:o,source:Vc(u,e)+"",target:Vc(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!=E?E:"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(Oc,Object.assign({ref:he,chartType:"force",nodes:We,edges:Ye,customNetworkLayout:Gc,layoutConfig:Ee,size:[T,R],responsiveWidth:H,responsiveHeight:F,margin:Oe,title:E,description:null!=B?B:"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:$e,showParticles:Q,particleStyle:Z,legend:Be,legendPosition:A,onObservation:U,customClickBehavior:K?e=>{if(!e||!e.data)return;const t=e.data;qc(t)&&K(t.data,{x:e.x,y:e.y})}:void 0,chartId:J,colorScheme:Array.isArray(k)?k:void 0},ee))});function Kc(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:O,legendInteraction:M,stroke:C,strokeWidth:_,opacity:P}=o,{width:L,height:T,enableHover:R,showLabels:N=!0,title:E,description:B,summary:D,accessibleTable:I}=n,H=Lc({nodes:t.useMemo(()=>Mc(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,[]),$=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(()=>Cr($,{stroke:C,strokeWidth:_,opacity:P}),[$,C,_,P]),z=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),Y=t.useMemo(()=>Cr(z,{stroke:C,strokeWidth:_,opacity:P}),[z,C,_,P]),G=t.useMemo(()=>{if("treemap"===a||"circlepack"===a||"partition"===a)return _c(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(Oc,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:W,edgeStyle:Y,colorBy:h,colorScheme:H.effectivePalette,colorByDepth:f,nodeSize:m,nodeLabel:N?y||d:void 0,showLabels:N,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},M&&"none"!==M&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:s,title:E,description:B,summary:D,accessibleTable:I},null!=o.animate&&{animate:o.animate},b))})}function Qc(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:O,legendInteraction:M,stroke:C,strokeWidth:_,opacity:P}=o,{nodeStyle:L}=b,T=Lr(b,["nodeStyle"]),{width:R,height:N,enableHover:E,showLabels:B=!0,title:D,description:I,summary:H,accessibleTable:F}=n,$=Lc({nodes:t.useMemo(()=>Mc(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:M,selection:x,linkedHover:k,onObservation:w,onClick:A,chartType:"Treemap",chartId:j,marginDefaults:n.marginDefaults,userMargin:r,width:R,height:N,loading:S,loadingContent:O}),W=Or(x),z=$.customHoverBehavior,Y=t.useCallback(e=>{if(!e)return z(null);const t=e.data||e;z({data:(null==t?void 0:t.data)||t})},[z]),G=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,G),t},[u,h,$.colorScale,$.themeCategorical,d,G]),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(()=>Cr(X,{stroke:C,strokeWidth:_,opacity:P}),[X,C,_,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(()=>_c(l),[l]),Q=void 0!==y?y:!B||"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:N}):$.loadingEl?$.loadingEl:e.jsx(gr,{componentName:"Treemap",width:R,height:N,children:e.jsx(Oc,Object.assign({chartType:"treemap"},null!=i&&{data:i},{size:[R,N],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:B?f||c:void 0,showLabels:B,labelMode:g,enableHover:E,tooltipContent:!1===v?()=>null:kn(v)||void 0},(k||w||A)&&{customHoverBehavior:Y},(w||A)&&{customClickBehavior:$.customClickBehavior},M&&"none"!==M&&{legendHoverBehavior:$.legendState.onLegendHover,legendClickBehavior:$.legendState.onLegendClick,legendHighlightedCategory:$.legendState.highlightedCategory,legendIsolatedCategories:$.legendState.isolatedCategories},{className:s,title:D,description:I,summary:H,accessibleTable:F},null!=o.animate&&{animate:o.animate},T))})}function Zc(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:O,strokeWidth:M,opacity:C}=o,{width:_,height:P,enableHover:L,showLabels:T=!0,title:R,description:N,summary:E,accessibleTable:B}=n,D=Lc({nodes:t.useMemo(()=>Mc(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):qi(void 0,D.themeCategorical,d,void 0,I),t},[u,h,D.colorScale,f,D.themeCategorical,d,I]),F=t.useMemo(()=>Cr(H,{stroke:O,strokeWidth:M,opacity:C}),[H,O,M,C]),$=t.useMemo(()=>_c(l),[l]),W=jr({componentName:"CirclePack",data:i});return W?e.jsx(cr,{componentName:"CirclePack",message:W,width:_,height:P}):D.loadingEl?D.loadingEl:e.jsx(gr,{componentName:"CirclePack",width:_,height:P,children:e.jsx(Oc,Object.assign({chartType:"circlepack"},null!=i&&{data:i},{size:[_,P],responsiveWidth:o.responsiveWidth,responsiveHeight:o.responsiveHeight,margin:D.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:$,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:kn(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:N,summary:E,accessibleTable:B},null!=o.animate&&{animate:o.animate},m))})}Uc.displayName="ProcessSankey",Kc.displayName="TreeDiagram",Qc.displayName="Treemap",Zc.displayName="CirclePack";const Jc=be;function eu(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:O,onClick:M,chartId:C,selection:_,linkedHover:P,loading:L,loadingContent:T,stroke:R,strokeWidth:N,opacity:E}=o,{width:B,height:D,enableHover:I,title:H,description:F,summary:$,accessibleTable:W}=n,z=Lc({nodes:t.useMemo(()=>Mc(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:B,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]:Jc[(e.depth||0)%Jc.length]:c?ke(e.data||e,c,z.colorScale):qi(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(()=>Cr(q,{stroke:R,strokeWidth:N,opacity:E}),[q,R,N,E]),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:B,height:D}):z.loadingEl?z.loadingEl:e.jsx(gr,{componentName:"OrbitDiagram",width:B,height:D,children:e.jsx(Oc,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[B,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:kn(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:$,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))})}eu.displayName="OrbitDiagram";const tu={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"},ou={opacity:.7,marginRight:4};function nu(e,t,o){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:o]}function iu(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function ru(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=nu(a,o,"time"),c=nu(a,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:tu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:ou,children:[i,":"]}),iu(l)]}),e.jsxs("div",{children:[e.jsxs("span",{style:ou,children:[r,":"]}),iu(c)]})]})}}function su(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 au=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:O,tooltipContent:M,tooltip:C,onHover:_,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:N,pulse:E,staleness:B,transition:D,linkedHover:I,selection:H,onObservation:F,chartId:$,loading:W,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:ru({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=>{_&&_(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=mr(W,K[0],K[1],z),oe=te?null:yr(y,K[0],K[1],Y),ne={stroke:w,strokeWidth:A,strokeDasharray:j};null!=S&&(ne.opacity=S);const ie=su(p,y);return te||oe||e.jsx(si,{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:N,pulse:E,staleness:B,transition:D,pointIdAccessor:o.pointIdAccessor,legendPosition:q})});function lu(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}au.displayName="RealtimeLineChart";const cu=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:O,stroke:M,strokeWidth:C,opacity:_,gap:P,background:L,tooltipContent:T,tooltip:R,onHover:N,annotations:E,svgAnnotationRules:B,tickFormatTime:D,tickFormatValue:I,linkedHover:H,selection:F,decay:$,pulse:W,staleness:z,transition:Y,onObservation:G,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=nu(r,o,"time"),i=nu(r,n,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:tu,children:[e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"x:"}),iu(t)]}),e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"y:"}),iu(i)]})]})}return e.jsxs("div",{className:"semiotic-tooltip",style:tu,children:[e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"range:"}),iu(r.binStart),"–",iu(r.binEnd)]}),null!=r.total&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"count:"}),iu(r.total)]}),null!=r.category&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"category:"}),iu(r.category)]})]})}}({timeAccessor:v,valueAccessor:b}),se=t.useRef(null),{customHoverBehavior:ae}=Ui({selection:F,linkedHover:H,unwrapData:!0,onObservation:G,chartType:"RealtimeHistogram",chartId:q}),le=t.useCallback(e=>{N&&N(e),ae(e)},[N,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),G&&G(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,G,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!=O&&(ye.fill=O),null!=M&&(ye.stroke=M),null!=C&&(ye.strokeWidth=C),null!=_&&(ye.opacity=_),null!=P&&(ye.gap=P);const me=K?`${g||""} semiotic-emphasis-${K}`.trim():g,ve=su(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=lu(i,o,"time"),r=lu(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:E,svgAnnotationRules:B,tickFormatTime:D,tickFormatValue:I,decay:$,pulse:W,staleness:z,transition:Y,pointIdAccessor:o.pointIdAccessor,legendPosition:Q,brush:ce||(ee?{dimension:"x"}:void 0),onBrush:ce||ee?ge:void 0})});function uu(t){return e.jsx(cu,Object.assign({},t,{windowMode:"growing"}))}cu.displayName="RealtimeHistogram",uu.displayName="TemporalHistogram";const du=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:O,stroke:M,strokeWidth:C,background:_,tooltipContent:P,tooltip:L,onHover:T,annotations:R,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:B,linkedHover:D,selection:I,onObservation:H,chartId:F,loading:$,loadingContent:W,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:ru({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=Ui({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=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!=O&&(oe.opacity=O),null!=M&&(oe.stroke=M),null!=C&&(oe.strokeWidth=C);const ne=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,ie=su(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:_,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:R,svgAnnotationRules:N,tickFormatTime:E,tickFormatValue:B,legendPosition:G,pointIdAccessor:o.pointIdAccessor})});du.displayName="RealtimeSwarmChart";const hu=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:O,stroke:M,strokeWidth:C,opacity:_,background:P,tooltipContent:L,tooltip:T,onHover:R,annotations:N,svgAnnotationRules:E,tickFormatTime:B,tickFormatValue:D,linkedHover:I,selection:H,onObservation:F,chartId:$,loading:W,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=nu(s,o,"time"),l=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:nu(s,n,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof l?0>l?iu(l):"+"+iu(l):iu(l);return e.jsxs("div",{className:"semiotic-tooltip",style:tu,children:[e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"x:"}),iu(a)]}),e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"Δ:"}),u]}),null!=c&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"total:"}),iu(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],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=su(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:P,hoverAnnotation:V,tooltipContent:Q,customHoverBehavior:ee,annotations:N,svgAnnotationRules:E,tickFormatTime:B,tickFormatValue:D,legendPosition:q,pointIdAccessor:o.pointIdAccessor})});hu.displayName="RealtimeWaterfallChart";const gu=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:O,tooltipContent:M,tooltip:C,onHover:_,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:N,pulse:E,staleness:B,linkedHover:D,selection:I,onObservation:H,chartId:F,loading:$,loadingContent:W,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:nu(u,o,"time"),h=null!==(l=null==u?void 0:u.yCenter)&&void 0!==l?l:nu(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:tu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:ou,children:[i,":"]}),iu(d)]}),e.jsxs("div",{children:[e.jsxs("span",{style:ou,children:[r,":"]}),iu(h)]}),null!=g&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"count:"}),iu(g)]}),"sum"===y&&null!=f&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"sum:"}),iu(f)]}),"mean"===y&&null!=p&&e.jsxs("div",{children:[e.jsx("span",{style:ou,children:"mean:"}),iu(p)]})]})}}({timeAccessor:m,valueAccessor:v}),Q=t.useRef(null),{customHoverBehavior:Z}=Ui({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=mr($,U[0],U[1],W),te=ee?null:yr(y,U[0],U[1],z),oe=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,ne=su(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:O,hoverAnnotation:X,tooltipContent:K,customHoverBehavior:J,annotations:P,svgAnnotationRules:L,tickFormatTime:T,tickFormatValue:R,decay:N,pulse:E,staleness:B,legendPosition:G,pointIdAccessor:o.pointIdAccessor})});gu.displayName="RealtimeHeatmap";const[fu]=A(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function pu(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"),yu(s,a),"svg"===o){const e=(new XMLSerializer).serializeToString(a);mu(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?(mu(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 yu(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++)yu(n[e],i[e])}function mu(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 vu={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"}},bu={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},xu={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},ku=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],wu=["vertical","horizontal"],Au={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},vu),bu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ku},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({},vu),bu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ku},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({},vu),bu),{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:ku},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({},vu),bu),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:ku},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({},vu),bu),{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({},vu),bu),{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({},vu),bu),{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({},vu),bu),{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({},vu),bu),{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({},vu),bu),{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({},vu),bu),{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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),xu),{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:wu},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},vu),xu),{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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),xu),{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({},vu),xu),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:wu},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({},vu),{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({},vu),{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({},vu),{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({},vu),xu),{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({},vu),xu),{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({},vu),{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({},vu),{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:wu},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({},vu),{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({},vu),{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({},vu),{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({},vu),{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({},vu),{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({},vu),{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({},vu),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},vu),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},vu),{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({},vu),{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({},vu),{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({},vu),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})}};function ju(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function Su(e,t){const o=[],n=Au[e];if(!n)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(Au).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(!ju(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 Ou=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"]),Mu=new Set(["data","nodes","edges"]),Cu="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function _u(e){return Tr(this,arguments,void 0,function*(e,t="json"){const o="jsx"===t?Pu(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 Pu(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 Lu(){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: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 Tu={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 Ru({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 Nu({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 Eu=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=>Tr(this,void 0,void 0,function*(){b.current&&(yield pu(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=>Tr(this,void 0,void 0,function*(){a&&(yield _u(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(Ru,{height:r}):u?e.jsx(Nu,{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:()=>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(Lu,{}),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:Tu[h].bg,color:Tu[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}),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 Du({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 Iu({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})]})}Du.displayName="ChartGrid",Iu.displayName="ContextLayout";function Hu({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||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:Fu,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 Fu={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};Hu.displayName="DetailsPanel";const $u=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Wu=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),zu=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Yu=new Set(["LineChart","AreaChart","StackedAreaChart"]),Gu=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function qu(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 Xu(e,t){const o=qu(e),n=qu(t);return null===o||null===n?null:(Math.max(o,n)+.05)/(Math.min(o,n)+.05)}const Vu=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"];function Uu(e){return"nominal"===e||"ordinal"===e}function Ku(e){return"quantitative"===e||"temporal"===e}const Qu={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"},Zu={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"},Ju={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function ed(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 td(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 od(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 nd(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 id="__forecastSegment";function rd(e,t){return"function"==typeof t?t(e):!!e[t]}const sd=Object.freeze({__proto__:null,SEGMENT_FIELD:id,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&&rd(e,u)?t="forecast":c&&rd(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[id]: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][id]!==o[e+1][id]&&(t.push(Object.assign(Object.assign({},o[e+1]),{[id]:o[e][id]})),t.push(Object.assign(Object.assign({},o[e]),{[id]:o[e+1][id]})));k.push(...b,...t)}else for(let e=0;b.length>e;e++)k.push(b[e]),b.length-1>e&&b[e][id]!==b[e+1][id]&&(k.push(Object.assign(Object.assign({},b[e+1]),{[id]:b[e][id]})),k.push(Object.assign(Object.assign({},b[e]),{[id]:b[e+1][id]})));if(n.trainUnderline){const e=[];for(const t of k)"training"===t[id]&&e.push(Object.assign(Object.assign({},t),{[id]:"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=>rd(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),{[id]:"observed"})):f.push(Object.assign(Object.assign({},o),{[id]:"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,[id]:"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]),{[id]:"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),{[id]:"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[id];if("training"===n){let e=o.stroke;return"darken"===c?e=od(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=nd(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:od,lightenColor:nd});exports.AreaChart=Gr,exports.BarChart=ra,exports.BoxPlot=da,exports.BubbleChart=ts,exports.CandlestickChart=bs,exports.CategoryColorProvider=li,exports.ChartContainer=Eu,exports.ChartGrid=Du,exports.ChordDiagram=Rc,exports.CirclePack=Zc,exports.ConnectedScatterplot=es,exports.ContextLayout=Iu,exports.DetailsPanel=Hu,exports.DifferenceChart=Xr,exports.DonutChart=ma,exports.DotPlot=fa,exports.ForceDirectedGraph=Tc,exports.FunnelChart=Sa,exports.GaugeChart=ja,exports.GroupedBarChart=aa,exports.Heatmap=os,exports.Histogram=ha,exports.LikertChart=Na,exports.LineChart=Hr,exports.LinkedCharts=Pi,exports.MinimapChart=hs,exports.MultiAxisLineChart=vs,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=eu,exports.PieChart=ya,exports.ProcessSankey=Uc,exports.QuadrantChart=gs,exports.RealtimeHeatmap=gu,exports.RealtimeHistogram=cu,exports.RealtimeLineChart=au,exports.RealtimeSwarmChart=du,exports.RealtimeWaterfallChart=hu,exports.RidgelinePlot=pa,exports.SankeyDiagram=Nc,exports.Scatterplot=Zr,exports.ScatterplotMatrix=us,exports.StackedAreaChart=Vr,exports.StackedBarChart=sa,exports.SwarmPlot=ca,exports.SwimlaneChart=Ea,exports.TemporalHistogram=uu,exports.ThemeProvider=function({theme:t,children:o}){const n="string"==typeof t&&Ei(t)?t:void 0,i=p.useMemo(()=>function(e){return void 0!==e?L(C,Ii(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(Bi.Provider,{value:n,children:[e.jsx(Hi,{theme:t}),e.jsx(Fi,{children:o})]})})},exports.TooltipProvider=fu,exports.TreeDiagram=Kc,exports.Treemap=Qc,exports.ViolinPlot=ga,exports.configToJSX=Pu,exports.copyConfig=_u,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=Su(e,t);for(const e of n.errors)o.push({severity:"error",code:"VALIDATION",message:e,fix:""});return Au[e]?(function(e,t,o){const n=Au[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=Au[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){$u.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){Wu.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=Au[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(!zu.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(!Yu.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=Au[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(!Gu.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=Xu(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=Xu(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 Vu)"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=pu,exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!Au[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:Cu(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=Qu[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=Ju[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),td(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",Uu(null==e?void 0:e.type)&&Ku(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)):Ku(null==e?void 0:e.type)&&Uu(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",ed(m,v,j,O,M),(null==b?void 0:b.field)&&(j.lineBy=b.field),p.interpolate){const e=Zu[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",ed(m,v,j,O,M),p.interpolate){const e=Zu[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",ed(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",Uu(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)):Uu(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",ed(m,v,j,O,M),A&&(j.data=A)}return td(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(!Au[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(Au).join(", ")}`);const n=!1!==(null==o?void 0:o.includeData),i={};for(const[e,o]of Object.entries(t))null!=o&&(Ou.has(e)||!n&&Mu.has(e)||"function"!=typeof o&&((null==o?void 0:o.$$typeof)||(i[e]=Cu(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=xi,exports.useCategoryColors=ci,exports.useChartObserver=ki,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=Su;
|
|
2
|
+
"use strict";const e=require("react/jsx-runtime"),t=require("react"),n=require("d3-selection"),o=require("d3-brush"),i=require("d3-scale"),r=require("d3-quadtree"),s=require("d3-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 f(e){return e&&e.__esModule?e:{default:e}}function g(e){if(e&&e.__esModule)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}return t.default=e,Object.freeze(t)}const p=g(t),y=f(c),m=Object.freeze([]);function v(e){if(!e)return m;let t=!1;for(let n=0;e.length>n;n++){const o=e[n];if(null==o||"object"!=typeof o){t=!0;break}}if(!t)return e;const n=[];for(const t of e)null!=t&&"object"==typeof t&&n.push(t);return n}function b(e,t){let n=0,o=t.length-1;for(;o>n;){const i=n+o+1>>1;t[i]>e?o=i-1:n=i}return t[n]}function x(e,t){let n=0,o=t.length-1;for(;o>n;){const i=n+o>>1;e>t[i]?n=i+1:o=i}return t[n]}function w({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,dimension:c,scales:u,onBrush:d,binSize:h,snap:f,binBoundaries:g,snapDuring:p,streaming:y}){const m=t.useRef(null),v=t.useRef(null),w=t.useRef(d);w.current=d;const k=t.useRef(u);k.current=u;const A=t.useMemo(()=>g?[...g].sort((e,t)=>e-t):void 0,[g]),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=n.select(m.current).select(".brush-g"),t="x"===c?o.brushX():"y"===c?o.brushY():o.brush();return t.extent([[0,0],[i,r]]),t.on("brush end",n=>{if(S.current)return;const o=k.current;if(!o)return;if(!n.selection)return C.current=null,void w.current(null);let s,a;if("x"===c){const[e,t]=n.selection;s=[o.x.invert(e),o.x.invert(t)],a=[o.y.invert(r),o.y.invert(0)]}else if("y"===c){const[e,t]=n.selection;s=[o.x.invert(0),o.x.invert(i)],a=[o.y.invert(t),o.y.invert(e)]}else{const[[e,t],[i,r]]=n.selection;s=[o.x.invert(e),o.x.invert(i)],a=[o.y.invert(r),o.y.invert(t)]}if("bin"===f&&"y"!==c&&("end"===n.type||"brush"===n.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=o.x(s[0]),a=o.x(s[1]);if(S.current=!0,"x"===c)e.call(t.move,[r,a]);else if("xy"===c){const o=n.selection;e.call(t.move,[[r,o[0][1]],[a,o[1][1]]])}S.current=!1}const l={x:s,y:a};C.current=l,w.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,f,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],o=n.select(m.current).select(".brush-g");if(t>=e.x[1])return S.current=!0,o.call(v.current.move,null),S.current=!1,C.current=null,void w.current(null);let i=e.x[0],r=!1;if(t>e.x[0]){if(i=t,"bin"===f){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,o.call(v.current.move,null),S.current=!1,C.current=null,void w.current(null);r=!0}const s=u.x(i),a=u.x(e.x[1]);if(S.current=!0,"x"===c)o.call(v.current.move,[s,a]);else{const t=u.y(e.y[1]),n=u.y(e.y[0]);o.call(v.current.move,[[s,t],[a,n]])}if(S.current=!1,r){const t={x:[i,e.x[1]],y:e.y};C.current=t,w.current(t)}},[u,y,c,f,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 k{constructor(e,t){var n,o;this.lastBoundedData=null,this.chunkTimer=0,this.pushBuffer=[],this.flushScheduled=!1,this.callback=e,this.chunkThreshold=null!==(n=null==t?void 0:t.chunkThreshold)&&void 0!==n?n:5e3,this.chunkSize=null!==(o=null==t?void 0:t.chunkSize)&&void 0!==o?o:5e3}updateChunkOptions(e){null!=e.chunkThreshold&&(this.chunkThreshold=e.chunkThreshold),null!=e.chunkSize&&(this.chunkSize=e.chunkSize)}clearLastData(){this.lastBoundedData=null,this.pushBuffer=[],this.flushScheduled=!1,this.chunkTimer&&(cancelAnimationFrame(this.chunkTimer),this.chunkTimer=0)}setBoundedData(e){if(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 n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}setReplacementData(e){if(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 n=()=>{if(t>=e.length)return void(this.chunkTimer=0);if(e!==this.lastBoundedData)return void(this.chunkTimer=0);const o=Math.min(t+this.chunkSize,e.length);this.callback({inserts:e.slice(t,o),bounded:!1}),t=o,this.chunkTimer=e.length>t?requestAnimationFrame(n):0};this.chunkTimer=requestAnimationFrame(n)}flushPushBuffer(){if(this.flushScheduled=!1,0===this.pushBuffer.length)return;const e=this.pushBuffer;this.pushBuffer=[],this.callback({inserts:e,bounded:!1})}scheduleFlush(){this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>this.flushPushBuffer()))}push(e){null!=e&&"object"==typeof e&&(this.pushBuffer.push(e),this.scheduleFlush())}pushMany(e){if(0===e.length)return;let t=0;for(let n=0;e.length>n;n++){const o=e[n];null!=o&&"object"==typeof o&&(this.pushBuffer.push(o),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(n){let o=null;const i=()=>(o||(o=t.createContext(null)),o),r=j(n);return[function({children:o,initialState:r}){const s=t.useRef(r),a=t.useMemo(()=>j(n,s.current),[]),l=i();return e.jsx(l.Provider,{value:a,children:o})},e=>{var n;const o=i(),s=null!==(n=t.useContext(o))&&void 0!==n?n: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 n=new EventTarget;let o=Object.assign(Object.assign({},e(function(e){o=Object.assign(Object.assign({},o),e(o)),n.dispatchEvent(new Event("update"))})),null!=t?t:{});return{getState:()=>o,subscribe:function(e){return n.addEventListener("update",e),()=>n.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:12}},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:12}},_={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,N]=A(e=>({theme:M,setTheme(t){e(e=>({theme:L(e.theme,t)}))}}));class R{constructor(e){if(this._capacity=e,this.head=0,this._size=0,1>e)throw Error("RingBuffer capacity must be at least 1");this.buffer=Array(e)}push(e){let t;return this._size===this._capacity?t=this.buffer[this.head]:this._size++,this.buffer[this.head]=e,this.head=(this.head+1)%this._capacity,t}pushMany(e){const t=[];for(const n of e){const e=this.push(n);void 0!==e&&t.push(e)}return t}get(e){if(e>=0&&this._size>e)return this.buffer[(this.head-this._size+e+this._capacity)%this._capacity]}peek(){if(0!==this._size)return this.buffer[(this.head-1+this._capacity)%this._capacity]}peekOldest(){if(0!==this._size)return this.buffer[(this.head-this._size+this._capacity)%this._capacity]}[Symbol.iterator](){let e=0;return{next:()=>this._size>e?{done:!1,value:this.get(e++)}:{done:!0,value:void 0}}}forEach(e){const t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e(this.buffer[(t+n)%this._capacity],n)}toArray(){const e=Array(this._size),t=(this.head-this._size+this._capacity)%this._capacity;for(let n=0;this._size>n;n++)e[n]=this.buffer[(t+n)%this._capacity];return e}resize(e){if(1>e)throw Error("RingBuffer capacity must be at least 1");const t=this.toArray(),n=[];for(;t.length>e;)n.push(t.shift());this._capacity=e,this.buffer=Array(e),this.head=0,this._size=0;for(const e of t)this.push(e);return n}update(e,t){const n=[],o=(this.head-this._size+this._capacity)%this._capacity;for(let i=0;this._size>i;i++){const r=(o+i)%this._capacity,s=this.buffer[r];if(e(s)){let e;e="object"!=typeof s||null===s?s:Array.isArray(s)?[...s]:Object.assign({},s),n.push(e),this.buffer[r]=t(s)}}return n}remove(e){const t=[],n=[];if(this.forEach(o=>{e(o)?n.push(o):t.push(o)}),0===n.length)return n;this.buffer=Array(this._capacity),this.head=0,this._size=0;for(const e of t)this.push(e);return n}clear(){this.buffer=Array(this._capacity),this.head=0,this._size=0}get size(){return this._size}get capacity(){return this._capacity}get full(){return this._size===this._capacity}}class ${constructor(){this._min=1/0,this._max=-1/0,this._dirty=!1}push(e){Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}evict(e){e!==this._min&&e!==this._max||(this._dirty=!0)}recalculate(e,t){this._min=1/0,this._max=-1/0;for(const n of e){const e=t?t(n):n;Number.isFinite(e)&&(this._min>e&&(this._min=e),e>this._max&&(this._max=e))}this._dirty=!1}clear(){this._min=1/0,this._max=-1/0,this._dirty=!1}get extent(){return[this._min,this._max]}get min(){return this._min}get max(){return this._max}get dirty(){return this._dirty}}function D(e,t,n,o,i){const r=new Map;for(const s of e){const e=t(s),a=n(s);if(null==e||null==a||Number.isNaN(e)||Number.isNaN(a))continue;const l=Math.floor(e/o)*o;let c=r.get(l);if(c||(c={start:l,end:l+o,total:0,categories:new Map},r.set(l,c)),c.total+=a,i){const e=i(s);c.categories.set(e,(c.categories.get(e)||0)+a)}}return r}function B(e,t,n,o,i,r){const s=[];for(const i of e){const e=n(i),r=o(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,n,o,i,r,s,a){const l=[];for(const r of e){const e=n(r),s=o(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 E(e,t,n,o){var i,r,s;const a=new Map;if("silhouette"===o)for(const o of e){let e=0;for(const i of t)e+=n(i,o)||0;a.set(o,-e/2)}else if("wiggle"===o){e.length>0&&a.set(e[0],0);for(let o=1;e.length>o;o++){const r=e[o-1],s=e[o];let l=0,c=0,u=0;for(const e of t){const t=n(e,s)||0;l+=(2*u+t)*(t-(n(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 o=0;for(const i of e){let e=0;for(const o of t)e+=n(o,i)||0;o+=(null!==(r=a.get(i))&&void 0!==r?r:0)+e/2}const i=o/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,n,o,i,r,s){const a=n(e),l=o(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 H(e,t,n,o,i,r,s){return{type:"rect",x:e,y:t,w:n,h:o,style:i,datum:r,group:s}}function z(e,t,n,o,i,r,s){const a={type:"heatcell",x:e,y:t,w:n,h:o,fill:i,datum:r};return(null==s?void 0:s.showValues)&&(a.showValues=!0,a.value=s.value,s.valueFormat&&(a.valueFormat=s.valueFormat)),a}function W(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 n=e||t;return e=>+e[n]}function Y(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function q(e,t){return"function"==typeof e?e:e?t=>t[e]+"":t?e=>e[t]+"":void 0}function V(e){return[parseInt(e.slice(1,3),16),parseInt(e.slice(3,5),16),parseInt(e.slice(5,7),16)]}function X(e,t,n){const o=e=>e.toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function U(e){const t=e.map(V),n=t.length-1;return e=>{if(0>=e){const[e,n,o]=t[0];return X(e,n,o)}if(e>=1){const[e,o,i]=t[n];return X(e,o,i)}const o=e*n,i=Math.floor(o),r=o-i,[s,a,l]=t[i],[c,u,d]=t[i+1];return X(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"]),ne=U(["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]),oe=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"]),fe=U(["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]),ge=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:oe,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 we(e,t,n){if("function"==typeof t){const o=t(e);return n&&o&&"string"==typeof o&&!function(e){const t=e.toLowerCase();return t.startsWith("#")||t.startsWith("rgb")||t.startsWith("hsl")||xe.has(t)}(o)?n(o):o}const o=(null==e?void 0:e[t])+"";return n?n(o):me[Math.abs(function(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n),t&=t;return Math.abs(t)}(o))%me.length]}function ke(e,t,n="category10"){const o=Array.from(new Set(e.map(e=>null==e?void 0:e[t]).filter(e=>null!=e).map(e=>e+""))),r=o.every(e=>!isNaN(Number(e)));if(Array.isArray(n))return i.scaleOrdinal().domain(o).range(n).unknown("#999");const s=ye[n]||ye.category10;if(r&&"function"==typeof s){let e=-1/0;for(const t of o){const n=Number(t);n>e&&(e=n)}return t=>s(Number(t)/e)}{const e=Array.isArray(s)?s:me;return i.scaleOrdinal().domain(o).range(e).unknown("#999")}}function Ae(e,t,n=[3,20],o){let i;if(i="function"==typeof t?t(e):null==e?void 0:e[t],!o)return i;const[r,s]=o,[a,l]=n;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,n){var o,i,r;if(1>=n)return 1;const s=null!==(o=e.minOpacity)&&void 0!==o?o:.1,a=n-1-t;switch(e.type){case"linear":return s+(1-a/(n-1))*(1-s);case"exponential":{const t=null!==(i=e.halfLife)&&void 0!==i?i:n/2;return s+Math.pow(.5,a/t)*(1-s)}case"step":return(null!==(r=e.stepThreshold)&&void 0!==r?r:.5*n)>a?1:s;default:return 1}}function Se(e,t,n){var o;const i=null!==(o=e.duration)&&void 0!==o?o:500,r=n-t;return i>r?1-r/i:0}function 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,n){return e+(t-e)*n}function Pe(){return"undefined"!=typeof performance?performance.now():Date.now()}function _e(e,t,n){var o,i,r,s;if(t._transitionKey)return t._transitionKey;switch(t.type){case"point":if(t.pointId)return"p:"+t.pointId;if("streaming"===e.runtimeMode&&t.datum){const n=e.getX(t.datum),o=e.getY(t.datum);if(e.getCategory)return`p:${e.getCategory(t.datum)}:${n}:${o}`;if(null!=n&&null!=o)return`p:${n}:${o}`}return"p:"+n;case"rect":return`r:${t.group||""}:${null!==(s=null!==(i=null===(o=t.datum)||void 0===o?void 0:o.binStart)&&void 0!==i?i:null===(r=t.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:n}`;case"heatcell":return`h:${t.x}_${t.y}`;case"candlestick":return null==t.datum?"c:"+n:"c:"+e.getX(t.datum);case"line":return"l:"+(t.group||"_default");case"area":return"a:"+(t.group||"_default");default:return null}}function Le(e,t,n,o){return"function"==typeof t.style?t.style(o||{},n):t.style&&"object"==typeof t.style?t.style:e.resolveBoundsStyle(n,o)}function Te(e,t,n,o){if(!e.scales)return null;const i=[],r=[];for(const n of t){const t=e.getX(n);if(!Number.isFinite(t))continue;const s=o.getTop(n),a=o.getBottom(n);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,o,n,t[0]),datum:t,group:n,interactive:o.interactive}}function Ne(e){const t=[],n=[];if(!e)return{perSeries:t,aggregate:n};for(const o of e)o.perSeries?t.push(o):n.push(o);return{perSeries:t,aggregate:n}}function Re(e,t,n){const o=[];for(const i of n){const n=Te(e,t,"__ribbon_aggregate",i);n&&o.push(n)}return o}function $e(e,t,n,o){const i=[];for(const r of o){const o=Te(e,t,n,r);o&&i.push(o)}return i}function De(e,t){if(!e)return{};if(!t||0===t.length)return e;const n=[];for(const o of t){if("band"!==o.kind)continue;const t=o.getTop(e),i=o.getBottom(e);Number.isFinite(i)&&Number.isFinite(t)&&n.push({y0:i,y1:t})}return 0===n.length?e:Object.assign(Object.assign({},e),{band:n[0],bands:n})}function Be(e,t,n,o){var i;if(!e.config.pointStyle)return;const r=null!=o?o:e.getY;for(const o of t){const t=e.resolveGroupColor(o.key);for(const s of o.data){let o=e.config.pointStyle(s);!o.fill&&t&&(o=Object.assign(Object.assign({},o),{fill:t}));const a=null!==(i=o.r)&&void 0!==i?i:3,l=e.getPointId?e.getPointId(s)+"":void 0,c=F(s,e.scales,e.getX,r,a,o,l);c&&n.push(c)}}}const Ie={topOpacity:.8,bottomOpacity:.05};function Ee(e){var t,n;if(e)return!0===e?Ie:"colorStops"in e?e:{topOpacity:null!==(t=e.topOpacity)&&void 0!==t?t:Ie.topOpacity,bottomOpacity:null!==(n=e.bottomOpacity)&&void 0!==n?n:Ie.bottomOpacity}}const Fe={blues:Q,reds:Z,greens:J,viridis:oe,oranges:ee,purples:te,greys:ne,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le},He=new Map;function ze(e,t){const n="function"==typeof e?e:n=>n[e||t];return e=>{const t=n(e);return null==t?NaN:+t}}function We(e){const t=[],n=["bar","swarm","waterfall"].includes(e.chartType)||"streaming"===e.runtimeMode,o=ze(n&&e.valueAccessor||e.yAccessor,n?"value":"y");if(e.boundsAccessor){const n=G(e.boundsAccessor,"bounds");t.push({kind:"bounds",getTop:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t+i:t},getBottom:e=>{const t=o(e);if(!Number.isFinite(t))return NaN;const i=n(e);return Number.isFinite(i)&&0!==i?t-i:t},style:e.boundsStyle,perSeries:!0,interactive:!1})}if(e.band){const n=Array.isArray(e.band)?e.band:[e.band];for(const e of n)t.push({kind:"band",getTop:ze(e.y1Accessor,"y1"),getBottom:ze(e.y0Accessor,"y0"),style:e.style,perSeries:!1!==e.perSeries,interactive:!0===e.interactive})}return t}class Ge{constructor(e){if(this.xExtent=new $,this.yExtent=new $,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 R(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=We(e),this.getPointId=q(e.pointIdAccessor),"candlestick"===e.chartType){const t=null!=e.openAccessor,n=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=n?G(e.closeAccessor,"close"):void 0,this.config.candlestickRangeMode=!t&&!n}e.pulse&&(this.timestampBuffer=new R(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 n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.push(n),Number.isFinite(o)&&this.yExtent.push(o)}}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],n=this.config.xAccessor,o="function"==typeof n?n(t):t[n||"x"],i=o instanceof Date,r="string"==typeof o&&o.length>=10&&!isNaN(new Date(o).getTime())&&isNaN(Number(o));if(this.xIsDate=i||r,r){const e="string"==typeof n?n:void 0;this.getX=e?t=>+new Date(t[e]):e=>+(n(e)instanceof Date?n(e):new Date(n(e)))}}const n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)if(this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const e of this.resolvedRibbons){const t=e.getTop(n),o=e.getBottom(n);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(o)&&this.yExtent.push(o)}}}else for(const n of e.inserts){if("growing"===this.config.windowMode&&this.buffer.full){const e=this.config.maxCapacity||1e6;e>this.growingCap&&(this.growingCap=Math.min(2*this.growingCap,e),this.buffer.resize(this.growingCap),this.timestampBuffer&&this.timestampBuffer.resize(this.growingCap))}const e=this.buffer.push(n);if(this.timestampBuffer&&this.timestampBuffer.push(t),this.xExtent.push(this.getX(n)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow)this.yExtent.push(this.getHigh(n)),this.yExtent.push(this.getLow(n));else{this.yExtent.push(this.getY(n)),this.getY0&&this.yExtent.push(this.getY0(n));for(const e of this.resolvedRibbons){const t=e.getTop(n),o=e.getBottom(n);Number.isFinite(t)&&this.yExtent.push(t),Number.isFinite(o)&&this.yExtent.push(o)}}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 n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&this.yExtent.evict(n),Number.isFinite(o)&&this.yExtent.evict(o)}}}return!0}computeScene(e){var t,n,o,r,s,a,l,c,u,d,h,f,g,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 w=y.xExtent?[null!==(n=y.xExtent[0])&&void 0!==n?n:b[0],null!==(o=y.xExtent[1])&&void 0!==o?o:b[1]]:b,k=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)k=[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)k=this._stackExtentCache.yDomain;else{const t=this.groupData(v),n=new Map,o=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 n of e.data){const e=this.getX(n),s=this.getY(n);if(!Number.isFinite(e)||!Number.isFinite(s))continue;t.set(e,(t.get(e)||0)+s),o.add(e),a+=s;const l=(r.get(e)||0)+s;r.set(e,l),l>i&&(i=l)}n.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 g;if("insideOut"===a){const e=[...t].map(e=>e.key).sort((e,t)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o:0);return 0!==i?i:l(e,t)}),n=[],o=[];let i=0,r=0;for(const t of e)r>i?(n.push(t),i+=null!==(u=s.get(t))&&void 0!==u?u:0):(o.push(t),r+=null!==(d=s.get(t))&&void 0!==d?d:0);g=[...o.reverse(),...n]}else g="asc"===a?t.map(e=>e.key).sort((e,t)=>{var n,o;const i=(null!==(n=s.get(e))&&void 0!==n?n:0)-(null!==(o=s.get(t))&&void 0!==o?o:0);return 0!==i?i:l(e,t)}):"desc"===a?t.map(e=>e.key).sort((e,t)=>{var n,o;const i=(null!==(n=s.get(t))&&void 0!==n?n:0)-(null!==(o=s.get(e))&&void 0!==o?o: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(o).sort((e,t)=>e-t),t=E(e,g,(e,t)=>{var o;return(null===(o=n.get(e))||void 0===o?void 0:o.get(t))||0},y.baseline);let i=1/0,s=-1/0;for(const n of e){const e=null!==(h=t.get(n))&&void 0!==h?h:0,o=null!==(f=r.get(n))&&void 0!==f?f:0;i>e&&(i=e),e+o>s&&(s=e+o)}Number.isFinite(i)&&Number.isFinite(s)||(i=0,s=0);const a=s-i,l=j?0:a>0?a*y.extentPadding:1;k=[i-l,s+l]}else k=[0,i+(j?0:i>0?i*y.extentPadding:1)];this._stackExtentCache={key:e,yDomain:k}}}else if("bar"===y.chartType&&y.binSize&&!A&&m.size>0){const[,e]=function(e,t,n,o,i){const r=D(e,t,n,o,i);if(0===r.size)return[0,0];let s=0;for(const e of r.values())e.total>s&&(s=e.total);return[0,s]}(m,this.getX,this.getY,y.binSize,this.getCategory);k=[0,j?e:e+e*y.extentPadding]}else if("waterfall"===y.chartType&&!A&&m.size>0){const[e,t]=function(e,t){let n=0,o=0,i=0;for(const r of e){const e=t(r);null==e||Number.isNaN(e)||(i+=e,n>i&&(n=i),i>o&&(o=i))}return[n,o]}(m,this.getY),n=t-e,o=j?0:n>0?n*y.extentPadding:1;k=[Math.min(0,e-Math.abs(o)),Math.max(0,t+Math.abs(o))]}else if(!A&&k[0]!==1/0){if(this.resolvedRibbons.length>0)for(const e of v)for(const t of this.resolvedRibbons){const n=t.getTop(e),o=t.getBottom(e);Number.isFinite(n)&&(k[0]>n&&(k[0]=n),n>k[1]&&(k[1]=n)),Number.isFinite(o)&&(k[0]>o&&(k[0]=o),o>k[1]&&(k[1]=o))}const e=k[1]-k[0],t=j?0:e>0?e*y.extentPadding:1,n=null===(g=y.yExtent)||void 0===g?void 0:g[0],o=null===(p=y.yExtent)||void 0===p?void 0:p[1];k=[null!=n?k[0]:k[0]-t,null!=o?k[1]:k[1]+t],"log"!==y.yScaleType||k[0]>0||0>=x[0]||j||(k[0]=null!=n?k[0]:x[0]/(1+y.extentPadding))}if(y.yExtent&&!A){const e=y.yExtent[0],t=y.yExtent[1];null==e&&null==t||(k=[null!=e?e:k[0],null!=t?t:k[1]])}if(w[0]===1/0||w[1]===-1/0)if("time"===y.xScaleType){const e=Date.now();w=[e-864e5,e]}else w=[0,1];k[0]!==1/0&&k[1]!==-1/0||(k=[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(w).range(t),y:i.scaleLinear().domain(k).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(k).range([C,e.width-C]),y:i.scaleLinear().domain(w).range(t)}}else{const t=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):i.scaleLinear().domain(t).range(n)};this.scales={x:t(y.xScaleType,w,[C,e.width-C]),y:t(y.yScaleType,k,[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,n=0;for(const e of this.scene)"point"===e.type&&(t++,e.r>n&&(n=e.r));if(this._maxPointRadius=n,Ge.QUADTREE_THRESHOLD>=t)return void(this._quadtree=null);const o=Array(t);let i=0;for(const e of this.scene)"point"===e.type&&(o[i++]=e);this._quadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(o)}get quadtree(){return this._quadtree}get maxPointRadius(){return this._maxPointRadius}remapScene(e){const t=e.width/this.lastLayout.width,n=e.height/this.lastLayout.height;for(const e of this.scene)switch(e.type){case"line":for(const o of e.path)o[0]*=t,o[1]*=n;break;case"area":for(const o of e.topPath)o[0]*=t,o[1]*=n;for(const o of e.bottomPath)o[0]*=t,o[1]*=n;e.clipRect&&(e.clipRect={x:e.clipRect.x*t,y:e.clipRect.y*n,width:e.clipRect.width*t,height:e.clipRect.height*n});break;case"point":e.x*=t,e.y*=n;break;case"rect":case"heatcell":e.x*=t,e.y*=n,e.w*=t,e.h*=n;break;case"candlestick":e.x*=t,e.openY*=n,e.closeY*=n,e.highY*=n,e.lowY*=n}const o=this.scales.x.domain(),r=this.scales.y.domain(),s=this.scales.x.range(),a=this.scales.y.range(),l=(e,t,n)=>{if("log"===e){const e=[Math.max(t[0],1e-6),Math.max(t[1],1e-6)];return i.scaleLog().domain(e).range(n).clamp(!0)}return"time"===e?i.scaleTime().domain([new Date(t[0]),new Date(t[1])]).range(n):i.scaleLinear().domain(t).range(n)},c=Math.max(0,Math.min(this.config.scalePadding||0,Math.min(e.width,e.height)/2-1)),u=a[1]>a[0];this.scales={x:l(this.config.xScaleType,o,s[0]>s[1]?[e.width-c,c]:[c,e.width-c]),y:l(this.config.yScaleType,r,u?[c,e.height-c]:[e.height-c,c])},this.lastLayout={width:e.width,height:e.height},this.rebuildQuadtree(),this.version++}buildSceneNodes(e,t){var n,o,i,r,s,a,l;const{config:c,scales:u}=this;if(!u)return[];if(c.customLayout){const l=null!==(n=c.layoutMargin)&&void 0!==n?n:{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!==(o=c.themeSemantic)&&void 0!==o?o:{},categorical:null!==(i=c.themeCategorical)&&void 0!==i?i:ve},resolveColor:(e,t)=>{var n,o;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!==(o=null===(n=c.themeSemantic)||void 0===n?void 0:n.primary)&&void 0!==o?o:"#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 n;const o=e.groupData(t),i=[],r=null===(n=e.config.annotations)||void 0===n?void 0:n.filter(e=>"threshold"===e.type&&e.color).map(e=>({value:e.value,color:e.color,thresholdType:e.thresholdType||"greater"}));if(e.ribbons&&e.ribbons.length>0){const{perSeries:n,aggregate:r}=Ne(e.ribbons);if(r.length>0&&i.push(...Re(e,t,r)),n.length>0)for(const t of o)i.push(...$e(e,t.data,t.key,n))}for(const t of o){const n=e.resolveLineStyle(t.key,t.data[0]),o=B(t.data,e.scales,e.getX,e.getY,n,t.key);r&&r.length>0&&(o.colorThresholds=r),e.config.curve&&"linear"!==e.config.curve&&(o.curve=e.config.curve),e.config.lineGradient&&(o.strokeGradient=e.config.lineGradient),i.push(o)}return Be(e,o,i),i}(d,t);case"area":return function(e,t){const n=e.groupData(t),o=[];if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Ne(e.ribbons);if(r.length>0&&o.push(...Re(e,t,r)),i.length>0)for(const t of n)o.push(...$e(e,t.data,t.key,i))}const i=e.scales.y.domain()[0],r=e.getY0?t=>{const n=e.getY0(t);return null==n?i:n}:void 0;for(const t of n){const n=e.resolveAreaStyle(t.key,t.data[0]),s=I(t.data,e.scales,e.getX,e.getY,i,n,t.key,r),a=Ee(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),o.push(s)}return Be(e,n,o),o}(d,t);case"mixed":return function(e,t){const n=e.groupData(t),o=[],i=e.config.areaGroups||new Set;if(e.ribbons&&e.ribbons.length>0){const{perSeries:i,aggregate:r}=Ne(e.ribbons);if(r.length>0&&o.push(...Re(e,t,r)),i.length>0)for(const t of n)o.push(...$e(e,t.data,t.key,i))}const r=e.scales.y.domain()[0],s=e.getY0?t=>{const n=e.getY0(t);return null==n?r:n}:void 0;for(const t of n)if(i.has(t.key)){const n=e.resolveAreaStyle(t.key,t.data[0]),i=I(t.data,e.scales,e.getX,e.getY,r,n,t.key,s),a=Ee(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),o.push(i)}else{const n=e.resolveLineStyle(t.key,t.data[0]),i=B(t.data,e.scales,e.getX,e.getY,n,t.key);e.config.curve&&"linear"!==e.config.curve&&(i.curve=e.config.curve),e.config.lineGradient&&(i.strokeGradient=e.config.lineGradient),o.push(i)}return Be(e,n,o),o}(d,t);case"stackedarea":return function(e,t){var n,o,i,r;const s=e.groupData(t),a=null!==(n=e.config.stackOrder)&&void 0!==n?n:"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 n of s){let o=0;for(const t of n.data){const n=e.getX(t),i=e.getY(t);Number.isFinite(n)&&Number.isFinite(i)&&(o+=i)}t.set(n.key,o)}const n=(e,t)=>t>e?-1:e>t?1:0;if("asc"===a)s.sort((e,o)=>{var i,r;const s=(null!==(i=t.get(e.key))&&void 0!==i?i:0)-(null!==(r=t.get(o.key))&&void 0!==r?r:0);return 0!==s?s:n(e.key,o.key)});else if("desc"===a)s.sort((e,o)=>{var i,r;const s=(null!==(i=t.get(o.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:n(e.key,o.key)});else{const e=[...s].sort((e,o)=>{var i,r;const s=(null!==(i=t.get(o.key))&&void 0!==i?i:0)-(null!==(r=t.get(e.key))&&void 0!==r?r:0);return 0!==s?s:n(e.key,o.key)}),r=[],a=[];let l=0,c=0;for(const n of e)c>l?(r.push(n),l+=null!==(o=t.get(n.key))&&void 0!==o?o:0):(a.push(n),c+=null!==(i=t.get(n.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,n,o,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=n(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=n(i),r=o(i);Number.isFinite(t)&&Number.isFinite(r)&&e.set(t,(e.get(t)||0)+r)}h.set(t.key,e)}let f;if(r){f=new Map;for(const t of d){let n=0;for(const o of e)n+=(null===(l=h.get(o.key))||void 0===l?void 0:l.get(t))||0;f.set(t,n||1)}}const g=E(d,e.map(e=>e.key),(e,t)=>{var n;return(null===(n=h.get(e))||void 0===n?void 0:n.get(t))||0},a),p=[],y=new Map,m=new Map;for(const e of d)m.set(e,null!==(c=g.get(e))&&void 0!==c?c:0);for(const n of e){const e=h.get(n.key),o=[],a=[],l=new Map;for(const n of d){let i=e.get(n)||0;const s=m.get(n);r&&(i/=f.get(n));const c=s+i,u=t.x(n);a.push([u,t.y(s)]),o.push([u,t.y(c)]),m.set(n,c),l.set(n,c)}y.set(n.key,l);const c={type:"area",topPath:o,bottomPath:a,style:i(n.key,n.data[0]),datum:n.data,group:n.key};s&&(c.curve=s),p.push(c)}return{nodes:p,stackedTops:y}}(s,e.scales,e.getX,e.getY,(t,n)=>e.resolveAreaStyle(t,n),e.config.normalize,c,u),f=d;if(e.config.pointStyle){const t=new WeakMap;for(const n of s){const o=h.get(n.key);if(o)for(const i of n.data){const n=e.getX(i),r=e.getY(i);null==n||Number.isNaN(n)||null==r||Number.isNaN(r)||!o.has(n)||t.set(i,o.get(n))}}const n=n=>{var o;return null!==(o=t.get(n))&&void 0!==o?o:e.getY(n)};Be(e,s,f,n)}return f}(d,t);case"scatter":case"bubble":return function(e,t){var n;const o=[],i="bubble"===e.config.chartType?10:5,r=e.config.sizeRange||[3,15];let s=null;if(e.getSize&&!e.config.pointStyle){const n=t.map(t=>e.getSize(t)).filter(e=>null!=e&&!Number.isNaN(e));if(n.length>0){let e=1/0,t=-1/0;for(const o of n)e>o&&(e=o),o>t&&(t=o);s=n=>e===t?(r[0]+r[1])/2:r[0]+(n-e)/(t-e)*(r[1]-r[0])}}const a=e.getColor?e.resolveColorMap(t):null,l=(null===(n=e.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7";for(const n of t){let t=e.config.pointStyle?e.config.pointStyle(n):{fill:l,opacity:.8},r=t.r||i;if(s&&e.getSize){const t=e.getSize(n);null==t||Number.isNaN(t)||(r=s(t))}if(a&&e.getColor&&!t.fill){const o=e.getColor(n);o&&a.has(o)&&(t=Object.assign(Object.assign({},t),{fill:a.get(o)}))}const c=e.getPointId?e.getPointId(n)+"":void 0,u=F(n,e.scales,e.getX,e.getY,r,t,c);u&&o.push(u)}return o}(d,t);case"heatmap":return function(e,t,n){if(e.config.heatmapAggregation)return function(e,t,n){var o,i,r;const s=Math.max(1,Math.floor(null!==(o=e.config.heatmapXBins)&&void 0!==o?o:20)),a=Math.max(1,Math.floor(null!==(i=e.config.heatmapYBins)&&void 0!==i?i:20)),l=null!==(r=e.config.heatmapAggregation)&&void 0!==r?r:"count",c=G(e.config.valueAccessor,"value");if(!e.scales||0===t.length)return[];const[u,d]=e.scales.x.domain(),[h,f]=e.scales.y.domain(),g=(d-u||1)/s,p=(f-h||1)/a,y=s*a;if(y>1e6)return[];const m=new Int32Array(y),v=new Float64Array(y);for(let n=0;t.length>n;n++){const o=t[n],i=e.getX(o),r=e.getY(o);if(!isFinite(i)||!isFinite(r))continue;const l=Math.min(Math.floor((i-u)/g),s-1),d=Math.min(Math.floor((r-h)/p),a-1);if(0>l||0>d)continue;const f=d*s+l;m[f]++;const y=c(o);v[f]+=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 w=x-b||1,k=n.width/s,A=n.height/a,j=e.config.showValues,S=e.config.heatmapValueFormat,C=[];for(let e=0;a>e;e++){const t=e*s;for(let n=0;s>n;n++){const o=t+n;if(0===m[o])continue;let i;switch(l){case"sum":i=v[o];break;case"mean":i=v[o]/m[o];break;default:i=m[o]}const r=(i-b)/w;C.push(z(n*k,(a-1-e)*A,k,A,`rgb(${220-(180*r+.5)|0},${220-(100*r+.5)|0},${255-(50*r+.5)|0})`,{xi:n,yi:e,value:i,count:m[o],sum:v[o],xCenter:u+(n+.5)*g,yCenter:h+(e+.5)*p,agg:l},j?{value:i,showValues:!0,valueFormat:S}:void 0))}}return C}(e,t,n);if(0===t.length)return[];const o=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 n=t[e],o=i(n),u=r(n);l[e]=o,c[e]=u,s.has(o)||s.set(o,s.size),a.has(u)||a.set(u,a.size)}const u=s.size,d=a.size;if(0===u||0===d)return[];const h=Array.from(s.keys()),f=Array.from(a.keys()),g=h.every(e=>"number"==typeof e&&!isNaN(e)),p=f.every(e=>"number"==typeof e&&!isNaN(e));if(g){h.sort((e,t)=>e-t),s.clear();for(let e=0;h.length>e;e++)s.set(h[e],e)}if(p){f.sort((e,t)=>e-t),a.clear();for(let e=0;f.length>e;e++)a.set(f[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 n=t[e],i=s.get(l[e]),r=a.get(c[e]);if(void 0===i||void 0===r)continue;const d=o(n),h=r*u+i,f=b.get(h);let g;void 0!==f?g=f:(g=x++,b.set(h,g)),y[g]=h,m[g]=d,v[g]=n}let w=1/0,k=-1/0;for(let e=0;x>e;e++){const t=m[e];isFinite(t)&&(w>t&&(w=t),t>k&&(k=t))}if(!isFinite(w)||!isFinite(k))return[];const A=function(e){const t=e in Fe?e:"blues";let n=He.get(t);if(n)return n;n=Array(256);const o=Fe[t]||Q;for(let e=0;256>e;e++)n[e]=o(e/255);return He.set(t,n),n}("string"==typeof e.config.colorScheme?e.config.colorScheme:e.config.themeSequential||"blues"),j=255/(k-w||1),S=n.width/u,C=n.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 n=y[e],o=n%u;P.push(z(o*S,(d-1-(n-o)/u)*C,S,C,A[Math.min((t-w)*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 n,o;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 n of e.categories.keys())t.add(n);const n=e.config.barColors?Object.keys(e.config.barColors):[],o=new Set(n),s=Array.from(t).filter(e=>!o.has(e)).sort(),a=n.filter(e=>t.has(e)),l=a.join("\0")+""+s.join("\0");e.barCategoryCache&&e.barCategoryCache.key===l?r=e.barCategoryCache.order:(r=[...a,...s],e.barCategoryCache={key:l,order:r})}const s=[],a=e.scales,[l,c]=a.x.domain(),u=e.config.barStyle,d=null===(n=e.config.themeSemantic)||void 0===n?void 0:n.primary,h=null==u?void 0:u.gap,f="number"!=typeof h||0>h?1:h,g={};(null==u?void 0:u.stroke)&&(g.stroke=u.stroke),"number"==typeof(null==u?void 0:u.strokeWidth)&&(g.strokeWidth=u.strokeWidth),"number"==typeof(null==u?void 0:u.opacity)&&(g.opacity=u.opacity);for(const t of i.values()){const n=Math.max(t.start,l),i=Math.min(t.end,c);if(n>=i)continue;const h=a.x(n),p=a.x(i),y=Math.abs(p-h),m=y>f+1?f:0,v=Math.min(h,p)+m/2,b=Math.max(y-m,1);if(b>0)if(r&&t.categories.size>0){let n=0;for(const i of r){const r=t.categories.get(i)||0;if(0===r)continue;const l=a.y(n),c=a.y(n+r),h=(null===(o=e.config.barColors)||void 0===o?void 0:o[i])||(null==u?void 0:u.fill)||d||"#4e79a7";s.push(H(v,Math.min(l,c),b,Math.abs(l-c),Object.assign({fill:h},g),{binStart:t.start,binEnd:t.end,total:t.total,category:i,categoryValue:r},i)),n+=r}}else{const e=a.y(0),n=a.y(t.total);s.push(H(v,Math.min(e,n),b,Math.abs(e-n),Object.assign({fill:(null==u?void 0:u.fill)||d||"#007bff"},g),{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 n,o,i,r,s,a;const l=[],c=e.config.swarmStyle||{},u=null!==(n=c.radius)&&void 0!==n?n:3,d=null!==(r=null!==(o=c.fill)&&void 0!==o?o:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.primary)&&void 0!==r?r:"#007bff",h=null!==(s=c.opacity)&&void 0!==s?s:.7,f=c.stroke,g=c.strokeWidth;for(const n of t){const t=e.getX(n),o=e.getY(n);if(null==o||Number.isNaN(o))continue;const i=e.scales.x(t),r=e.scales.y(o);let s=d;if(e.getCategory){const t=e.getCategory(n);s=(null===(a=e.config.barColors)||void 0===a?void 0:a[t])||s}const c={type:"point",x:i,y:r,r:u,style:{fill:s,opacity:h,stroke:f,strokeWidth:g},datum:n};e.getPointId&&(c.pointId=e.getPointId(n)+""),l.push(c)}return l}(d,t);case"waterfall":return function(e,t,n){var o,i,r,s,a,l,c;const u=[],d=e.scales,h=e.config.waterfallStyle,f=t.filter(t=>{const n=e.getY(t),o=e.getX(t);return null!=n&&!Number.isNaN(n)&&null!=o&&isFinite(o)});if(0===f.length)return u;const g=null!==(r=null!==(o=null==h?void 0:h.positiveColor)&&void 0!==o?o:null===(i=e.config.themeSemantic)||void 0===i?void 0:i.success)&&void 0!==r?r:"#28a745",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;f.length>t;t++){const o=f[t],i=e.getX(o),r=e.getY(o),s=x+r;let a;a=f.length-1>t?e.getX(f[t+1])-i:t>0?i-e.getX(f[t-1]):0;const l=d.x(i),c=0!==a?d.x(i+a):l+n.width/10,w=Math.min(l,c)+y/2,k=Math.max(l,c)-y/2-w;if(0>=k){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:g,stroke:m,strokeWidth:v};null!=b&&(O.opacity=b),u.push(H(w,S,k,C,O,Object.assign(Object.assign({},o),{baseline:x,cumEnd:s,delta:r,_connectorStroke:null==h?void 0:h.connectorStroke,_connectorWidth:null==h?void 0:h.connectorWidth}))),x=s}return u}(d,t,e);case"candlestick":return function(e,t){var n,o;if(!e.getHigh||!e.getLow||!e.scales)return[];const i=null!==(n=e.config.candlestickRangeMode)&&void 0!==n&&n;if(!(i||e.getOpen&&e.getClose))return[];const r=[],s=e.config.candlestickStyle||{},a=s.rangeColor||"#6366f1",l=i?a:s.upColor||"#28a745",c=i?a:s.downColor||"#dc3545",u=i?a:s.wickColor||"#333",d=s.wickWidth||(i?2:1),h=t.map(t=>e.getX(t)).filter(e=>null!=e&&!Number.isNaN(e)).sort((e,t)=>e-t);let f=null!==(o=s.bodyWidth)&&void 0!==o?o:0;if(null==s.bodyWidth)if(h.length>1){let t=1/0;for(let n=1;h.length>n;n++){const o=Math.abs(e.scales.x(h[n])-e.scales.x(h[n-1]));o>0&&t>o&&(t=o)}f=t!==1/0?Math.max(2,Math.min(.6*t,20)):6}else f=6;for(const n of t){const t=e.getX(n);if(null==t||Number.isNaN(t))continue;const o=e.getHigh(n),s=e.getLow(n);if(null==o||Number.isNaN(o)||null==s||Number.isNaN(s))continue;const a=i?o:e.getOpen(n),h=i?s:e.getClose(n);if(!i&&[a,h].some(e=>null==e||Number.isNaN(e)))continue;const g=h>=a,p={type:"candlestick",x:e.scales.x(t),openY:e.scales.y(a),closeY:e.scales.y(h),highY:e.scales.y(o),lowY:e.scales.y(s),bodyWidth:f,upColor:l,downColor:c,wickColor:u,wickWidth:d,isUp:g,datum:n};i&&(p.isRange=!0),r.push(p)}return r}(d,t);default:return[]}}resolveBoundsStyle(e,t){var n;const o=this.config.boundsStyle;return"function"==typeof o?o(t||{},e):o&&"object"==typeof o?o:{fill:this.resolveLineStyle(e,t).stroke||(null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary)||"#4e79a7",fillOpacity:.2,stroke:"none"}}computeDecayOpacity(e,t){const n=this.config.decay;return n&&t>1?je(n,e,t):1}applyDecay(e,t){this.config.decay&&function(e,t,n){var o,i;const r=n.length;if(1>=r)return;const s=new Map;for(let e=0;n.length>e;e++)s.set(n[e],e);for(const n of t){if("line"===n.type){const t=Array.isArray(n.datum)?n.datum:[];if(2>t.length)continue;const o=Array(t.length);let i=!1;for(let n=0;t.length>n;n++){const a=s.get(t[n]);null!=a?(o[n]=je(e,a,r),1>o[n]&&(i=!0)):o[n]=1}i&&(n._decayOpacities=o);continue}if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[],o=n.topPath?n.topPath.length:t.length;if(2>o)continue;if(t.length===o){const i=Array(o);let a=!1;for(let n=0;t.length>n;n++){const o=s.get(t[n]);null!=o?(i[n]=je(e,o,r),1>i[n]&&(a=!0)):i[n]=1}a&&(n._decayOpacities=i)}else{let i=1;for(const n of t){const t=s.get(n);if(null!=t){const n=je(e,t,r);i>n&&(i=n)}}if(1>i){const e=Array(o);e.fill(i),n._decayOpacities=e}}continue}const t=s.get(n.datum);if(null==t)continue;const a=je(e,t,r);if("heatcell"===n.type)n.style={opacity:a};else if("candlestick"===n.type)n._decayOpacity=a;else{const e=null!==(i=null===(o=n.style)||void 0===o?void 0:o.opacity)&&void 0!==i?i:1;n.style=Object.assign(Object.assign({},n.style),{opacity:e*a})}}}(this.config.decay,e,t)}applyPulse(e,t){this.config.pulse&&this.timestampBuffer&&function(e,t,n,o){var i,r;const s="undefined"!=typeof performance?performance.now():Date.now(),a=null!==(i=e.color)&&void 0!==i?i:"rgba(255,255,255,0.6)",l=null!==(r=e.glowRadius)&&void 0!==r?r:4,c=new Map;for(let e=0;n.length>e;e++)c.set(n[e],e);for(const n of t){if("line"===n.type)continue;if("area"===n.type){const t=Array.isArray(n.datum)?n.datum:[n.datum];let i=0;for(const n of t){const t=c.get(n);if(null==t)continue;const r=o.get(t);if(null==r)continue;const a=Se(e,r,s);a>i&&(i=a)}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const t=c.get(n.datum);if(null==t)continue;const i=o.get(t);if(null==i)continue;const r=Se(e,i,s);r>0&&(n._pulseIntensity=r,n._pulseColor=a,n._pulseGlowRadius=l)}}(this.config.pulse,e,t,this.timestampBuffer)}get hasActivePulses(){return!!this.config.pulse&&function(e,t){var n;if(!t||0===t.size)return!1;const o="undefined"!=typeof performance?performance.now():Date.now(),i=null!==(n=e.duration)&&void 0!==n?n:500,r=t.peek();return null!=r&&i>o-r}(this.config.pulse,this.timestampBuffer)}get transitionContext(){return{runtimeMode:this.config.runtimeMode,getX:this.getX,getY:this.getY,getCategory:this.getCategory}}snapshotPositions(){!function(e,t,n,o){var i,r,s,a;n.clear(),o.clear();for(let l=0;t.length>l;l++){const c=t[l],u=_e(e,c,l);u&&("point"===c.type?n.set(u,{x:c.x,y:c.y,r:c.r,opacity:c.style.opacity}):"rect"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:c.style.opacity}):"heatcell"===c.type?n.set(u,{x:c.x,y:c.y,w:c.w,h:c.h,opacity:null===(i=c.style)||void 0===i?void 0:i.opacity}):"candlestick"===c.type?n.set(u,{x:c.x,y:c.openY,w:c.bodyWidth,openY:c.openY,closeY:c.closeY,highY:c.highY,lowY:c.lowY,opacity:null===(r=c.style)||void 0===r?void 0:r.opacity}):"line"===c.type?o.set(u,{path:c.path.map(e=>[e[0],e[1]]),opacity:null===(s=c.style)||void 0===s?void 0:s.opacity}):"area"===c.type&&o.set(u,{topPath:c.topPath.map(e=>[e[0],e[1]]),bottomPath:c.bottomPath.map(e=>[e[0],e[1]]),opacity:null===(a=c.style)||void 0===a?void 0:a.opacity}))}}(this.transitionContext,this.scene,this.prevPositionMap,this.prevPathMap)}synthesizeIntroPositions(){var e,t,n;this.prevPositionMap.clear(),this.prevPathMap.clear();const o=null!==(t=null===(e=this.scales)||void 0===e?void 0:e.y(0))&&void 0!==t?t:0;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],i=_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:o,w:t.w,h:0,opacity:null!==(n=t.style.opacity)&&void 0!==n?n:1}):"heatcell"===t.type?this.prevPositionMap.set(i,{x:t.x,y:t.y,w:t.w,h:t.h,opacity:0}):"line"===t.type?(t._introClipFraction=0,this.prevPathMap.set(i,{path:t.path.map(e=>[e[0],e[1]]),opacity:t.style.opacity})):"area"===t.type&&(t._introClipFraction=0,this.prevPathMap.set(i,{topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),opacity:t.style.opacity})))}}startTransition(){if(!this.config.transition)return;const e=function(e,t,n,o,i){var r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x,w,k,A,j,S,C,O,M,P,_,L,T,N,R,$,D,B,I,E,F,H,z,W,G,Y;if(0===o.size&&0===i.size)return n;const q=null!==(r=t.duration)&&void 0!==r?r:300;if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}let V=!1;const X=new Set,U=new Set;for(let t=0;n.scene.length>t;t++){const r=n.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]];V=!0}else if("area"===r.type&&e.topPath&&e.bottomPath&&e.topPath.length===r.topPath.length&&e.bottomPath.length===r.bottomPath.length){r._targetTopPath=r.topPath.map(e=>[e[0],e[1]]),r._targetBottomPath=r.bottomPath.map(e=>[e[0],e[1]]),r._prevTopPath=e.topPath,r._prevBottomPath=e.bottomPath;for(let t=0;r.topPath.length>t;t++)r.topPath[t]=[e.topPath[t][0],e.topPath[t][1]];for(let t=0;r.bottomPath.length>t;t++)r.bottomPath[t]=[e.bottomPath[t][0],e.bottomPath[t][1]];V=!0}r._targetOpacity=null!==(s=r.style.opacity)&&void 0!==s?s:1,r._startOpacity=null!==(l=null!==(a=e.opacity)&&void 0!==a?a:r.style.opacity)&&void 0!==l?l:1}else r._targetOpacity=null!==(c=r.style.opacity)&&void 0!==c?c:1,r._startOpacity=0,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;continue}const L=o.get(_);if("point"===r.type)if(L){X.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,V=!0)}else r._targetOpacity=null!==(h=r.style.opacity)&&void 0!==h?h:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("rect"===r.type)if(L){X.add(_);const e={x:r.x,y:r.y,w:r.w,h:r.h};r._targetOpacity=null!==(f=r.style.opacity)&&void 0!==f?f: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!==(g=L.w)&&void 0!==g?g:r.w,r.h=null!==(p=L.h)&&void 0!==p?p:r.h,V=!0)}else r._targetOpacity=null!==(y=r.style.opacity)&&void 0!==y?y:1,r.style=Object.assign(Object.assign({},r.style),{opacity:0}),V=!0;else if("heatcell"===r.type)if(L){X.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,V=!0)}else r._targetOpacity=null!==(k=null===(w=r.style)||void 0===w?void 0:w.opacity)&&void 0!==k?k:1,r.style=Object.assign(Object.assign({},r.style||{}),{opacity:0}),V=!0;else if("candlestick"===r.type)if(L&&null!=L.openY){X.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,V=!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}),V=!0}for(const[e,t]of i)if(!U.has(e))if(e.startsWith("l:")&&t.path){const o={type:"line",path:t.path.map(e=>[e[0],e[1]]),group:e.slice(2),style:{stroke:"#999",strokeWidth:1,opacity:null!==(_=t.opacity)&&void 0!==_?_:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),V=!0}else if(e.startsWith("a:")&&t.topPath&&t.bottomPath){const o={type:"area",topPath:t.topPath.map(e=>[e[0],e[1]]),bottomPath:t.bottomPath.map(e=>[e[0],e[1]]),group:e.slice(2),style:{fill:"#999",opacity:null!==(L=t.opacity)&&void 0!==L?L:1},_targetOpacity:0,_transitionKey:e,datum:null};n.exitNodes.push(o),V=!0}for(const[e,t]of o)if(!X.has(e)){if(e.startsWith("p:")){const o={type:"point",x:t.x,y:t.y,r:null!==(T=t.r)&&void 0!==T?T:3,style:{opacity:null!==(N=t.opacity)&&void 0!==N?N:1},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("r:")){const o={type:"rect",x:t.x,y:t.y,w:null!==(R=t.w)&&void 0!==R?R:0,h:null!==($=t.h)&&void 0!==$?$:0,style:{opacity:null!==(D=t.opacity)&&void 0!==D?D:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("h:")){const o={type:"heatcell",x:t.x,y:t.y,w:null!==(B=t.w)&&void 0!==B?B:0,h:null!==(I=t.h)&&void 0!==I?I:0,fill:"#999",datum:null,style:{opacity:null!==(E=t.opacity)&&void 0!==E?E:1},_targetOpacity:0,_transitionKey:e};n.exitNodes.push(o)}else if(e.startsWith("c:")){const o=null!==(F=t.openY)&&void 0!==F?F:t.y,i={type:"candlestick",x:t.x,openY:o,closeY:null!==(H=t.closeY)&&void 0!==H?H:o,highY:null!==(z=t.highY)&&void 0!==z?z:o,lowY:null!==(W=t.lowY)&&void 0!==W?W:o,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};n.exitNodes.push(i)}V=!0}return n.exitNodes.length>0&&(n.scene=[...n.scene,...n.exitNodes]),V&&(n.activeTransition={startTime:Pe(),duration:q}),n}(this.transitionContext,this.config.transition,{scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},this.prevPositionMap,this.prevPathMap);this.scene=e.scene,this.exitNodes=e.exitNodes,this.activeTransition=e.activeTransition}advanceTransition(e){if(!this.activeTransition||!this.config.transition)return!1;const t={scene:this.scene,exitNodes:this.exitNodes,activeTransition:this.activeTransition},n=function(e,t,n,o){var i,r,s,a,l,c;if(!n.activeTransition)return!1;const u=Oe(e,n.activeTransition),d=Ce(u,"linear"===t.easing?"linear":"ease-out-cubic");for(const e of n.scene){const t=e._transitionKey;if("point"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,r=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style.opacity=Me(r,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Me(n.x,e._targetX,d),e.y=Me(n.y,e._targetY,d),void 0!==e._targetR&&void 0!==n.r&&(e.r=Me(n.r,e._targetR,d))}else if("rect"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(r=n.opacity)&&void 0!==r?r:1:0;e.style.opacity=Me(i,e._targetOpacity,d)}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Me(n.x,e._targetX,d),e.y=Me(n.y,e._targetY,d),void 0!==n.w&&(e.w=Me(n.w,e._targetW,d)),void 0!==n.h&&(e.h=Me(n.h,e._targetH,d))}else if("heatcell"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(s=n.opacity)&&void 0!==s?s:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Me(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Me(n.x,e._targetX,d),e.y=Me(n.y,e._targetY,d),void 0!==n.w&&(e.w=Me(n.w,e._targetW,d)),void 0!==n.h&&(e.h=Me(n.h,e._targetH,d))}else if("candlestick"===e.type){if(void 0!==e._targetOpacity){const n=t?o.get(t):void 0,i=n?null!==(a=n.opacity)&&void 0!==a?a:1:0;e.style=Object.assign(Object.assign({},e.style||{}),{opacity:Me(i,e._targetOpacity,d)})}if(void 0===e._targetX)continue;if(!t)continue;const n=o.get(t);if(!n)continue;e.x=Me(n.x,e._targetX,d),void 0!==n.openY&&(e.openY=Me(n.openY,e._targetOpenY,d)),void 0!==n.closeY&&(e.closeY=Me(n.closeY,e._targetCloseY,d)),void 0!==n.highY&&(e.highY=Me(n.highY,e._targetHighY,d)),void 0!==n.lowY&&(e.lowY=Me(n.lowY,e._targetLowY,d))}else if("line"===e.type){if(void 0!==e._targetOpacity){const t=null!==(l=e._startOpacity)&&void 0!==l?l:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Me(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevPath,n=e._targetPath;if(t&&n&&t.length===e.path.length)for(let o=0;e.path.length>o;o++)e.path[o][0]=Me(t[o][0],n[o][0],d),e.path[o][1]=Me(t[o][1],n[o][1],d)}else if("area"===e.type){if(void 0!==e._targetOpacity){const t=null!==(c=e._startOpacity)&&void 0!==c?c:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Me(t,e._targetOpacity,d)})}void 0!==e._introClipFraction&&(e._introClipFraction=d);const t=e._prevTopPath,n=e._prevBottomPath,o=e._targetTopPath,i=e._targetBottomPath;if(t&&o&&t.length===e.topPath.length)for(let n=0;e.topPath.length>n;n++)e.topPath[n][0]=Me(t[n][0],o[n][0],d),e.topPath[n][1]=Me(t[n][1],o[n][1],d);if(n&&i&&n.length===e.bottomPath.length)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t][0]=Me(n[t][0],i[t][0],d),e.bottomPath[t][1]=Me(n[t][1],i[t][1],d)}}if(u>=1){for(const e of n.scene){if(void 0!==e._targetOpacity){const t=e._targetOpacity;e.style=Object.assign(Object.assign({},"line"===e.type||"area"===e.type?e.style:e.style||{}),{opacity:0===t?0:t}),e._targetOpacity=void 0}if("point"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,void 0!==e._targetR&&(e.r=e._targetR),e._targetX=void 0,e._targetY=void 0,e._targetR=void 0}else if("rect"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("heatcell"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,e.y=e._targetY,e.w=e._targetW,e.h=e._targetH,e._targetX=void 0,e._targetY=void 0,e._targetW=void 0,e._targetH=void 0}else if("candlestick"===e.type){if(void 0===e._targetX)continue;e.x=e._targetX,void 0!==e._targetOpenY&&(e.openY=e._targetOpenY),void 0!==e._targetCloseY&&(e.closeY=e._targetCloseY),void 0!==e._targetHighY&&(e.highY=e._targetHighY),void 0!==e._targetLowY&&(e.lowY=e._targetLowY),e._targetX=void 0,e._targetOpenY=void 0,e._targetCloseY=void 0,e._targetHighY=void 0,e._targetLowY=void 0}else if("line"===e.type){const t=e._targetPath;if(t)for(let n=0;e.path.length>n;n++)e.path[n]=t[n];e._prevPath=void 0,e._targetPath=void 0,e._introClipFraction=void 0}else if("area"===e.type){const t=e._targetTopPath,n=e._targetBottomPath;if(t)for(let n=0;e.topPath.length>n;n++)e.topPath[n]=t[n];if(n)for(let t=0;e.bottomPath.length>t;t++)e.bottomPath[t]=n[t];e._prevTopPath=void 0,e._prevBottomPath=void 0,e._targetTopPath=void 0,e._targetBottomPath=void 0,e._introClipFraction=void 0}}if(n.exitNodes.length>0){const e=new Set(n.exitNodes);n.scene=n.scene.filter(t=>!e.has(t)),n.exitNodes=[]}return n.activeTransition=null,!1}return!0}(e,this.config.transition,t,this.prevPositionMap);return this.scene=t.scene,this.exitNodes=t.exitNodes,this.activeTransition=t.activeTransition,n}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 n of e){const e=this.getGroup(n);t.has(e)||t.set(e,[]),t.get(e).push(n)}return Array.from(t.entries()).map(([e,t])=>({key:e,data:t}))}resolveColorMap(e){if(this._colorMapCache&&this._colorMapCache.version===this._ingestVersion)return this._colorMapCache.map;const t=new Set;for(const n of e){const e=this.getColor(n);e&&t.add(e)}const n=Array.from(t).sort(),o=n.join("\0");if(this._colorMapCache&&this._colorMapCache.key===o)return this._colorMapCache.version=this._ingestVersion,this._colorMapCache.map;const i=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,r=new Map;for(let e=0;n.length>e;e++)r.set(n[e],i[e%i.length]);return this._colorMapCache={key:o,map:r,version:this._ingestVersion},r}resolveLineStyle(e,t){var n;const o=this.config.lineStyle;if("function"==typeof o){const n=o(t||{},e);if(n&&!n.stroke&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{stroke:t})}return n}const i=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;return o&&"object"==typeof o?{stroke:o.stroke||i||"#007bff",strokeWidth:o.strokeWidth||2,strokeDasharray:o.strokeDasharray,fill:o.fill,fillOpacity:o.fillOpacity,opacity:o.opacity}:{stroke:this.resolveGroupColor(e)||i||"#007bff",strokeWidth:2}}resolveAreaStyle(e,t){var n,o;if(this.config.areaStyle){const n=this.config.areaStyle(t||{});if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const i=this.config.lineStyle;if("function"==typeof i){const n=i(t||{},e);if(n&&!n.fill&&e){const t=this.resolveGroupColor(e);if(t)return Object.assign(Object.assign({},n),{fill:t,stroke:n.stroke||t})}return n}const r=null===(n=this.config.themeSemantic)||void 0===n?void 0:n.primary;if(i&&"object"==typeof i)return{fill:i.fill||i.stroke||r||"#4e79a7",fillOpacity:null!==(o=i.fillOpacity)&&void 0!==o?o:.7,stroke:i.stroke||r||"#4e79a7",strokeWidth:i.strokeWidth||2};const s=this.resolveGroupColor(e)||r||"#4e79a7";return{fill:s,fillOpacity:.7,stroke:s,strokeWidth:2}}resolveGroupColor(e){if(this._colorMapCache){const t=this._colorMapCache.map.get(e);if(t)return t}const t=this._groupColorMap.get(e);if(t)return t;const n=(Array.isArray(this.config.colorScheme)&&this.config.colorScheme.length>0?this.config.colorScheme:null)||(Array.isArray(this.config.themeCategorical)&&this.config.themeCategorical.length>0?this.config.themeCategorical:null)||ve;if(0===n.length)return null;const o=n[this._groupColorCounter%n.length];if(this._groupColorCounter++,this._groupColorMap.set(e,o),this._groupColorMap.size>Ge.GROUP_COLOR_MAP_CAP){const e=this._groupColorMap.keys().next().value;void 0!==e&&this._groupColorMap.delete(e)}return o}getBufferArray(){return!this._bufferDirty&&this._bufferArrayCache||(this._bufferArrayCache=this.buffer.toArray(),this._bufferDirty=!1),this._bufferArrayCache}getData(){return this.getBufferArray()}remove(e){if(!this.getPointId)throw Error("remove() requires pointIdAccessor to be configured");this.config.transition&&this.scene.length>0&&this.snapshotPositions();const t=new Set(Array.isArray(e)?e:[e]),n=this.getPointId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const e of i)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,i}update(e,t){if(!this.getPointId)throw Error("update() requires pointIdAccessor to be configured");const n=new Set(Array.isArray(e)?e:[e]),o=this.getPointId,i=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&i.add(t)});const r=this.buffer.update(e=>n.has(o(e)),t);if(0===r.length)return r;for(const e of r)this.xExtent.evict(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.evict(this.getHigh(e)),this.yExtent.evict(this.getLow(e))):(this.yExtent.evict(this.getY(e)),this.getY0&&this.yExtent.evict(this.getY0(e)));return this.buffer.forEach((e,t)=>{i.has(t)&&(this.xExtent.push(this.getX(e)),"candlestick"===this.config.chartType&&this.getHigh&&this.getLow?(this.yExtent.push(this.getHigh(e)),this.yExtent.push(this.getLow(e))):(this.yExtent.push(this.getY(e)),this.getY0&&this.yExtent.push(this.getY0(e))))}),this.needsFullRebuild=!0,this._bufferDirty=!0,this._ingestVersion++,r}getBinBoundaries(){return this._binBoundaries}getExtents(){return this.xExtent.min===1/0?null:{x:this.xExtent.extent,y:this.yExtent.extent}}clear(){this.buffer.clear(),this.xExtent.clear(),this.yExtent.clear(),this._hasRenderedOnce=!1,this.timestampBuffer&&this.timestampBuffer.clear(),this.prevPositionMap.clear(),this.prevPathMap.clear(),this.exitNodes=[],this.activeTransition=null,this.lastIngestTime=0,this._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,n,o,i;const r=Object.assign({},this.config);("colorScheme"in e||"themeCategorical"in e||"colorAccessor"in e)&&(this._colorMapCache=null,this._groupColorMap=new Map,this._groupColorCounter=0),("barColors"in e||"colorScheme"in e)&&(this._barCategoryCache=null),("normalize"in e||"extentPadding"in e||"xAccessor"in e||"yAccessor"in e||"timeAccessor"in e||"valueAccessor"in e||"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||!W(null!==(t=e.xAccessor)&&void 0!==t?t:e.timeAccessor,null!==(n=r.xAccessor)&&void 0!==n?n:r.timeAccessor),u=l||!W(null!==(o=e.yAccessor)&&void 0!==o?o: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=We(this.config)),s=!0,a=!0)}if("groupAccessor"in e&&!W(e.groupAccessor,r.groupAccessor)&&(this.getGroup=null!=this.config.groupAccessor?q(this.config.groupAccessor):void 0,s=!0),"categoryAccessor"in e&&!W(e.categoryAccessor,r.categoryAccessor)&&(this.getCategory=null!=this.config.categoryAccessor?q(this.config.categoryAccessor):void 0,s=!0),"sizeAccessor"in e&&!W(e.sizeAccessor,r.sizeAccessor)&&(this.getSize=this.config.sizeAccessor?G(this.config.sizeAccessor,"size"):void 0,s=!0),"colorAccessor"in e&&!W(e.colorAccessor,r.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0,s=!0),"y0Accessor"in e&&!W(e.y0Accessor,r.y0Accessor)&&(this.getY0=this.config.y0Accessor?G(this.config.y0Accessor,"y0"):void 0,s=!0,a=!0),("boundsAccessor"in e&&!W(e.boundsAccessor,r.boundsAccessor)||"band"in e&&e.band!==r.band||"boundsStyle"in e&&e.boundsStyle!==r.boundsStyle)&&(this.resolvedRibbons=We(this.config),s=!0,a=!0),"pointIdAccessor"in e&&!W(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&&!W(e.openAccessor,r.openAccessor)||"closeAccessor"in e&&!W(e.closeAccessor,r.closeAccessor)||"highAccessor"in e&&!W(e.highAccessor,r.highAccessor)||"lowAccessor"in e&&!W(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 n of t)if(e[n]!==r[n]){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,n){return n.x>e||e>n.x+n.w||n.y>t||t>n.y+n.h?{hit:!1,cx:0,cy:0}:{hit:!0,cx:n.x+n.w/2,cy:n.y+n.h/2}}function Ve(e,t=30){return Math.max((null!=e?e:4)+5,12,t)}function Xe(e){return e instanceof Date?e:"number"==typeof e&&e>1e9?new Date(e):null}function Ue(e,t){const n=Xe(e);if(!n)return!1;const o=Xe(t);return!o||n.getFullYear()!==o.getFullYear()||n.getMonth()!==o.getMonth()}function Ke(e){let t=e%(2*Math.PI);return 0>t&&(t+=2*Math.PI),t}function Qe(e,t,n,o,i){const r=Math.max(o,i+5,12),s=t-r,a=t+r,l=n-r,c=n+r;let u=null,d=1/0;return e.visit((e,i,r,h,f)=>{if(i>a||s>h||r>c||l>f)return!0;if(!e.length){let i=e;do{const e=i.data,r=e.x-t,s=e.y-n,a=Math.sqrt(r*r+s*s);Ve(e.r,o)>=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,nt=null,ot=null,it=null;function rt(e,t){var n,o;if(!t)return t;const i=Ze.exec(t);if(!i)return t;const r=e.canvas;if(!r)return(null===(n=i[2])||void 0===n?void 0:n.trim())||t;!function(){if(tt)return;if("undefined"==typeof window||"undefined"==typeof document)return;tt=!0;const e=()=>{et++};if("undefined"!=typeof MutationObserver&&document.documentElement&&(nt=new MutationObserver(e),nt.observe(document.documentElement,{attributes:!0,attributeFilter:["class","style","data-theme","data-semiotic-theme"]})),"function"==typeof window.matchMedia)try{ot=window.matchMedia("(prefers-color-scheme: dark)"),it=e,"function"==typeof ot.addEventListener?ot.addEventListener("change",it):"function"==typeof ot.addListener&&ot.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===(o=i[2])||void 0===o?void 0:o.trim())||t;return s.map.set(t,l),l}function st(e,t){const n=e.fillStyle,o="#010203";try{e.fillStyle=o,e.fillStyle=t}catch(t){return e.fillStyle=n,[78,121,167]}const i=e.fillStyle;if(e.fillStyle=n,"string"!=typeof i)return[78,121,167];if(i.toLowerCase()===o&&t.trim().toLowerCase()!==o)return[78,121,167];if(i.startsWith("#"))return[parseInt(i.slice(1,3),16),parseInt(i.slice(3,5),16),parseInt(i.slice(5,7),16)];const r=i.match(/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return r?[+r[1],+r[2],+r[3]]:[78,121,167]}function 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,n){return null==t?n:"string"!=typeof t?t:rt(e,t)||n}function ct(e,t,n,o,i,r,s){if("colorStops"in t){const n=t.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>n.length)return null;const a=e.createLinearGradient(o,i,r,s);for(const e of n)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(o,i,r,s),[h,f,g]=st(e,n);return d.addColorStop(0,`rgba(${h},${f},${g},${c})`),d.addColorStop(1,`rgba(${h},${f},${g},${u})`),d}function ut(e,t,n,o,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(n,o,i,r);for(const e of s)a.addColorStop(e.offset,e.color);return a}const dt=new WeakMap;function ht(e,t){const n=at(t);if(!n)return e;const o=dt.get(e);if(o)return o;const i=function(e,t,n=8){if(!t||2>e.length)return e.map(([e,t])=>[e,t]);const o=[];let i=null;const r={moveTo(e,t){i=[e,t],o.push([e,t])},lineTo(e,t){i=[e,t],o.push([e,t])},bezierCurveTo(e,t,r,s,a,l){if(!i)return i=[a,l],void o.push([a,l]);const[c,u]=i;for(let i=1;n>=i;i++){const d=i/n,h=1-d;o.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,n,r){i=[n,r],o.push([n,r])}};return s.line().x(e=>e[0]).y(e=>e[1]).curve(t).context(r)(e),o}(e,n);return dt.set(e,i),i}function ft(e,t,n,o=30,i,r=0){let s=null;if(i){const e=Qe(i,t,n,o,r);e&&(s={node:e.node,datum:e.node.datum,x:e.node.x,y:e.node.y,distance:e.distance})}for(const r of e){let e=null;switch(r.type){case"point":if(i)break;e=pt(r,t,n,o);break;case"line":e=yt(r,t,n,o);break;case"rect":if(null==r.datum)break;e=vt(r,t,n);break;case"heatcell":e=bt(r,t,n);break;case"area":if(!1===r.interactive)break;e=wt(r,t,n);break;case"candlestick":e=xt(r,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}function gt(e,t,n){if(0===e.length)return null;if(e[0][0]>t||t>e[e.length-1][0])return null;const o=kt(e,t);if(0>o)return null;if(Math.abs(e[o][0]-t)>n)return null;let i=o,r=o;o>0&&e[o][0]>=t?(i=o-1,r=o):e.length-1>o&&(i=o,r=o+1);const[s,a]=e[i],[l,c]=e[r];return l===s?a:a+Math.max(0,Math.min(1,(t-s)/(l-s)))*(c-a)}function pt(e,t,n,o=30){const i=t-e.x,r=n-e.y,s=Math.sqrt(i*i+r*r);return s>Ve(e.r,o)?null:{node:e,datum:e.datum,x:e.x,y:e.y,distance:s}}function yt(e,t,n,o=30){var i,r;if(0===e.path.length)return null;const s=kt(e.path,t);if(0>s)return null;const[a,l]=e.path[s];let c;if(e.path.length>1){let o=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,n,i,r,a,l);o>c&&(o=c)}c=o}else{const e=t-a,o=n-l;c=Math.sqrt(e*e+o*o)}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,o)?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,n,o,i,r){const s=i-n,a=r-o,l=s*s+a*a;if(0===l)return Math.sqrt(Math.pow(e-n,2)+Math.pow(t-o,2));let c=((e-n)*s+(t-o)*a)/l;c=Math.max(0,Math.min(1,c));const u=o+c*a;return Math.sqrt(Math.pow(e-(n+c*s),2)+Math.pow(t-u,2))}function vt(e,t,n){const o=qe(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function bt(e,t,n){const o=qe(t,n,e);return o.hit?{node:e,datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}function xt(e,t,n){const o=e.bodyWidth/2,i=Math.min(e.openY,e.closeY);if(!(e.x-o-3>t||t>e.x+o+3||e.highY-3>n||n>e.lowY+3)){const o=i+Math.max(Math.max(e.openY,e.closeY)-i,1)/2,r=t-e.x,s=n-o;return{node:e,datum:e.datum,x:e.x,y:o,distance:Math.sqrt(r*r+s*s)}}return null}function wt(e,t,n){if(0===e.topPath.length)return null;const o=kt(e.topPath,t);if(0>o)return null;const[i,r]=e.topPath[o],s=t-i,a=n-r,l=Math.sqrt(s*s+a*a);return{node:e,datum:Array.isArray(e.datum)&&e.datum[o]?e.datum[o]:e.datum,x:i,y:r,distance:l}}function kt(e,t){if(0===e.length)return-1;let n=0,o=e.length-1;for(;o>n;){const i=n+o>>1;t>e[i][0]?n=i+1:o=i}return n>0&&Math.abs(e[n][0]-t)>=Math.abs(e[n-1][0]-t)?n-1:n}function At(e){var t,n;const o=new Map;for(const n of e){const e=null!==(t=n.group)&&void 0!==t?t:"_default";let i=o.get(e);i||(i=[],o.set(e,i)),i.push(n)}for(const e of o.values()){e.sort((e,t)=>e.x-t.x||e.y-t.y);for(let t=0;e.length>t;t++)e[t]._groupIndex=t}const i=Array.from(o.keys()).sort((e,t)=>{const n=o.get(e),i=o.get(t);return(n.length>0?n[0].y:0)-(i.length>0?i[0].y:0)}),r=Array.from(o.values()).flat();r.sort((e,t)=>e.x-t.x||e.y-t.y);const s=new Map;for(let e=0;r.length>e;e++){r[e]._flatIndex=e;const t=null===(n=r[e].datum)||void 0===n?void 0:n.id;null!=t&&s.set(t+"",e)}return{flat:r,groups:i,byGroup:o,idToIdx:s}}function jt(e,t){var n,o;if(0===e.flat.length)return{flatIndex:-1,group:"_default",indexInGroup:-1};const i=Math.max(0,Math.min(t,e.flat.length-1)),r=e.flat[i];return{flatIndex:i,group:null!==(n=r.group)&&void 0!==n?n:"_default",indexInGroup:null!==(o=r._groupIndex)&&void 0!==o?o:0}}function St(e,t,n){const{group:o,indexInGroup:i}=t,r=n.byGroup.get(o);switch(e){case"ArrowRight":return r.length-1>i?r[i+1]._flatIndex:t.flatIndex;case"ArrowLeft":return i>0?r[i-1]._flatIndex:t.flatIndex;case"ArrowDown":{const e=n.groups.indexOf(o);return n.groups.length-1>e?Ct(n,n.groups[e+1],r[i]):t.flatIndex}case"ArrowUp":{const e=n.groups.indexOf(o);return e>0?Ct(n,n.groups[e-1],r[i]):t.flatIndex}case"PageDown":return Math.min(t.flatIndex+Math.max(1,Math.floor(.1*n.flat.length)),n.flat.length-1);case"PageUp":return Math.max(t.flatIndex-Math.max(1,Math.floor(.1*n.flat.length)),0);case"Home":return 0;case"End":return n.flat.length-1;case"Escape":return-1;default:return null}}function Ct(e,t,n){const o=e.byGroup.get(t);let i=0,r=Math.abs(o[0].x-n.x);for(let e=1;o.length>e;e++){const t=Math.abs(o[e].x-n.x);r>t&&(r=t,i=e)}return o[i]._flatIndex}function 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,n,o,i,r,s){t.useEffect(()=>{if(!e)return;const t=setInterval(()=>{var t;const a=n.current;if(!a||0===a.lastIngestTime)return;const l="undefined"!=typeof performance?performance.now():Date.now(),c=null!==(t=e.threshold)&&void 0!==t?t:5e3,u=l-a.lastIngestTime>c;u!==r&&(s(u),o.current=!0,i())},1e3);return()=>clearInterval(t)},[e,r,i])}const _t={fill:(t,n)=>e.jsx("rect",{style:t,width:n,height:n}),line:(t,n)=>e.jsx("line",{style:t,x1:0,y1:0,x2:n,y2:n})};function Lt(e,t,n,o,i){let r;return r="function"==typeof n?n(e):(0,_t[n])(o(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 Nt(e,t,n){return n&&n.size>0?n.has(e.label)?1:.3:null!=t?e.label===t?1:.3:1}const Rt=(t,n,o,i,r,s,a,l,c,u,d)=>{const{type:h="fill",styleFn:f,items:g}=t,p=[];let y=0;const m=!(!n&&!o),v="isolate"===u||void 0===u&&null!=r,{swatchSize:b,labelGap:x,rowHeight:w}=d;return g.forEach((t,u)=>{const d=Lt(t,u,h,f,b),k=Nt(t,i,r),A=r&&r.size>0&&r.has(t.label);p.push(e.jsxs("g",{transform:`translate(0,${y})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(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 o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(t)),"ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault();const t=(u+("ArrowDown"===e.key?1:-1)+g.length)%g.length;c(l,t);const n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:m?e=>{c(l,u),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:m?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:m?"pointer":"default",opacity:k,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+=w}),p};function $t({config:t,orientation:n="vertical",width:o=100}){const{colorFn:i,domain:r,label:s,format:a}=t,l=a||(e=>Math.round(100*e)/100+""),c="grad-legend-"+p.useId();if("horizontal"===n){const t=12,n=Math.min(o,200),a=Math.max(0,(o-n)/2),u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[0]+n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:u})}),s&&e.jsx("text",{x:a+n/2,y:-4,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("rect",{x:a,y:0,width:n,height:t,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:a,y:t+12,textAnchor:"start",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])}),e.jsx("text",{x:a+n,y:t+12,textAnchor:"end",fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])})]})}const u=[];for(let t=0;64>=t;t++){const n=t/64;u.push(e.jsx("stop",{offset:100*n+"%",stopColor:i(r[1]-n*(r[1]-r[0]))},t))}return e.jsxs("g",{"aria-label":s||"Gradient legend",children:[s&&e.jsx("text",{x:7,y:-6,textAnchor:"middle",fontSize:11,fill:"var(--semiotic-text, #333)",children:s}),e.jsx("defs",{children:e.jsx("linearGradient",{id:c,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:u})}),e.jsx("rect",{x:0,y:0,width:14,height:100,fill:`url(#${c})`,rx:2}),e.jsx("text",{x:19,y:10,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[1])}),e.jsx("text",{x:19,y:100,fontSize:10,fill:"var(--semiotic-text-secondary, #666)",children:l(r[0])})]})}function Dt(t){const{legendGroups:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,legendInteraction:a,title:l="Legend",width:c=100,height:u=20,orientation:d="vertical",legendLayout:h}=t,f=function(e){var t,n,o,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!==(n=null==e?void 0:e.rowHeight)&&void 0!==n?n:22);return{swatchSize:s,labelGap:Math.max(0,null!==(o=null==e?void 0:e.labelGap)&&void 0!==o?o: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),[g,y]=p.useState(0),[m,v]=p.useState(0),b=p.useCallback((e,t)=>{y(e),v(t)},[]),x="vertical"===d?(({legendGroups:t,width:n,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:a,focusedItemIndex:l,onFocusedIndexChange:c,legendInteraction:u,metrics:d})=>{let h=24;const f=[];return t.forEach((t,g)=>{h+=5,f.push(e.jsx("line",{stroke:"gray",x1:0,y1:h,x2:n,y2:h},"legend-top-line legend-symbol-"+g)),h+=8,t.label&&(h+=16,f.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-"+g)),h+=8),f.push(e.jsx("g",{className:"legend-item",transform:`translate(0,${h})`,children:Rt(t,o,i,r,s,a,l,g,c,u,d)},"legend-group-"+g)),h+=t.items.length*d.rowHeight+8}),f})({legendGroups:n||[],width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:f}):(({legendGroups:t,height:n,width:o,customClickBehavior:i,customHoverBehavior:r,highlightedCategory:s,isolatedCategories:a,focusedGroupIndex:l,focusedItemIndex:c,onFocusedIndexChange:u,legendInteraction:d,metrics:h})=>{var f;let g=0;const p=[];t.forEach((t,n)=>{var f;let y=0;t.label&&(y+=16);const m=((t,n,o,i,r,s,a,l,c,u,d,h)=>{const{type:f="fill",styleFn:g,items:p}=t,y=[],{swatchSize:m,labelGap:v,itemGap:b,rowHeight:x,align:w}=d,k=!(!n&&!o),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 n=0===O?e:O+b+e;h&&h>0&&O>0&&n>h?(S.push({start:C,end:t,width:O}),C=t,O=e):O=n}),p.length>0&&S.push({start:C,end:p.length,width:O}),S.forEach((t,u)=>{let d="center"===w?Math.max(0,((null!=h?h:t.width)-t.width)/2):"end"===w?Math.max(0,(null!=h?h:t.width)-t.width):0;for(let h=t.start;t.end>h;h++){const t=p[h],w=Lt(t,h,f,g,m),S=Nt(t,i,r),C=r&&r.size>0&&r.has(t.label);y.push(e.jsxs("g",{transform:`translate(${d},${u*x})`,onClick:n?()=>n(t):void 0,onMouseEnter:o?()=>o(t):void 0,onMouseLeave:o?()=>o(null):void 0,tabIndex:k?l===s&&h===a?0:-1:void 0,role:k?"option":void 0,"aria-selected":k&&A?C||!1:void 0,"aria-current":k&&!A&&null!=i&&t.label===i||void 0,"aria-label":t.label,onKeyDown:k?e=>{var o;if("Enter"!==e.key&&" "!==e.key||(e.preventDefault(),n&&n(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 n=null===(o=e.currentTarget.parentElement)||void 0===o?void 0:o.children[t];n instanceof SVGElement&&n.focus()}}:void 0,onFocus:k?e=>{c(l,h),o&&o(t);const n=e.currentTarget.querySelector(".semiotic-legend-focus-ring");n&&n.setAttribute("visibility","visible")}:void 0,onBlur:k?e=>{o&&o(null);const t=e.currentTarget.querySelector(".semiotic-legend-focus-ring");t&&t.setAttribute("visibility","hidden")}:void 0,style:{cursor:k?"pointer":"default",opacity:S,transition:"opacity 150ms ease",pointerEvents:"all",outline:"none"},children:[k&&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"}),w,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,n,u,d,h,null!==(f=h.maxWidth)&&void 0!==f?f:o);y+=m.offset+5,p.push(Object.assign(Object.assign({label:t.label},m),{offset:y,totalRows:m.totalRows,totalHeight:m.totalHeight})),g+=y+12});const y=null!==(f=h.maxWidth)&&void 0!==f?f:o;let m=g>y?0:"center"===h.align?Math.max(0,(y-g)/2):"end"===h.align?Math.max(0,y-g):0;const v=[];return p.forEach((o,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:o.items},"legend-group-"+i)),m+=o.offset+5,t[i+1]&&v.push(e.jsx("line",{stroke:"gray",x1:m,y1:-8,x2:m,y2:(o.totalHeight||n)+0+8},"legend-top-line legend-symbol-"+i)),m+=12}),e.jsx("g",{children:v})})({legendGroups:n||[],title:l,height:u,width:c,customClickBehavior:o,customHoverBehavior:i,highlightedCategory:r,isolatedCategories:s,focusedGroupIndex:g,focusedItemIndex:m,onFocusedIndexChange:b,legendInteraction:a,metrics:f}),w=!(!o&&!i);return e.jsxs("g",{role:w?"listbox":void 0,"aria-multiselectable":!(!w||"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 Bt(e){return"object"==typeof e&&null!==e&&"legendGroups"in e}function It(e){return"object"==typeof e&&null!==e&&"gradient"in e}function Et(t){var n;const{legend:o,totalWidth:i,totalHeight:r,margin:s,legendPosition:a="right",legendLayout:l,title:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendInteraction:g}=t;if(!o)return null;const p="top"===a||"bottom"===a,y=!!c,m=Math.max(1,p?null!==(n=null==l?void 0:l.maxWidth)&&void 0!==n?n: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(o)?e.jsx($t,{config:o.gradient,orientation:p?"horizontal":"vertical",width:m}):Bt(o)?e.jsx(Dt,{legendGroups:o.legendGroups,title:"",width:m,orientation:p?"horizontal":"vertical",legendLayout:l,customHoverBehavior:u,customClickBehavior:d,highlightedCategory:h,isolatedCategories:f,legendInteraction:g}):o})}function Ft(e){return"string"==typeof e?{type:e}:e}function Ht({orient:n,config:o,values:i,scale:r,size:s,length:l}){const c=function(e){var t,n,o,i,r;return{type:e.type,bins:null!==(t=e.bins)&&void 0!==t?t:20,fill:null!==(n=e.fill)&&void 0!==n?n:"#4e79a7",fillOpacity:null!==(o=e.fillOpacity)&&void 0!==o?o:.5,stroke:null!==(i=e.stroke)&&void 0!==i?i:"none",strokeWidth:null!==(r=e.strokeWidth)&&void 0!==r?r:1}}(o),u="top"===n||"bottom"===n,d=t.useMemo(()=>{if(0===i.length)return null;const t=r.domain(),o=s-8;if("boxplot"===c.type){const t=function(e){const t=[...e].sort((e,t)=>e-t),n=t.length;if(0===n)return null;const o=t[Math.floor(.25*n)],i=t[Math.floor(.5*n)],r=t[Math.floor(.75*n)],s=r-o;return{q1:o,median:i,q3:r,whiskerLow:Math.max(t[0],o-1.5*s),whiskerHigh:Math.min(t[n-1],r+1.5*s)}}(i);if(!t)return null;const{q1:s,median:a,q3:l,whiskerLow:d,whiskerHigh:h}=t,f=Math.min(.5*o,20),g=(o-f)/2+4;if(u){const t=r(s),o=r(l),i=r(a),u=r(d),p=r(h),y="top"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:u,y1:m+y*(g+f/2),x2:p,y2:m+y*(g+f/2),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:u,y1:m+y*g,x2:u,y2:m+y*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:p,y1:m+y*g,x2:p,y2:m+y*(g+f),stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:Math.min(t,o),y:"top"===n?m-g-f:m+g,width:Math.abs(o-t),height:f,fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:i,y1:"top"===n?m-g-f:m+g,x2:i,y2:"top"===n?m-g:m+g+f,stroke:c.fill,strokeWidth:2})]})}{const t=r(s),o=r(l),i=r(a),u=r(d),p=r(h),y="left"===n?-1:1,m=0;return e.jsxs("g",{"data-testid":"marginal-boxplot-"+n,children:[e.jsx("line",{x1:m+y*(g+f/2),y1:u,x2:m+y*(g+f/2),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*g,y1:u,x2:m+y*(g+f),y2:u,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:m+y*g,y1:p,x2:m+y*(g+f),y2:p,stroke:c.fill,strokeWidth:c.strokeWidth}),e.jsx("rect",{x:"left"===n?m-g-f:m+g,y:Math.min(t,o),width:f,height:Math.abs(o-t),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth}),e.jsx("line",{x1:"left"===n?m-g-f:m+g,y1:i,x2:"left"===n?m-g:m+g+f,y2:i,stroke:c.fill,strokeWidth:2})]})}}const d=a.bin().domain(t).thresholds(c.bins)(i);if(0===d.length)return null;const h=Math.max(...d.map(e=>e.length));if(0===h)return null;if("histogram"===c.type)return e.jsx("g",{"data-testid":"marginal-histogram-"+n,children:d.map((t,i)=>{if(null==t.x0||null==t.x1)return null;const s=t.length/h*o;if(u){const o=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:o,y:"top"===n?-4-s:4,width:Math.max(a,.5),height:s,fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}{const o=r(t.x0),a=r(t.x1)-r(t.x0);return e.jsx("rect",{x:"left"===n?-4-s:4,y:Math.min(o,o+a),width:s,height:Math.abs(a),fill:c.fill,fillOpacity:c.fillOpacity,stroke:c.stroke,strokeWidth:c.strokeWidth},i)}})});if("violin"===c.type){const t=o/2+4,i=[];for(const e of d){if(null==e.x0||null==e.x1)continue;const s=e.length/h*(o/2),a=r((e.x0+e.x1)/2);i.push(u?`${a},${"top"===n?-(t-s):t-s}`:`${"left"===n?-(t-s):t-s},${a}`)}for(let e=d.length-1;e>=0;e--){const s=d[e];if(null==s.x0||null==s.x1)continue;const a=s.length/h*(o/2),l=r((s.x0+s.x1)/2);i.push(u?`${l},${"top"===n?-(t+a):t+a}`:`${"left"===n?-(t+a):t+a},${l}`)}return e.jsx("g",{"data-testid":"marginal-violin-"+n,children:e.jsx("polygon",{points:i.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}if("ridgeline"===c.type){const t=[];if(u){const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${i},${e}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,s=r((e.x0+e.x1)/2);t.push(`L${s},${"top"===n?-i-4:i+4}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${s},${e}`),t.push("Z")}else{const e=0,i=null!=d[0].x0?r(d[0].x0):0;t.push(`M${e},${i}`);for(const e of d){if(null==e.x0||null==e.x1)continue;const i=e.length/h*o,s=r((e.x0+e.x1)/2);t.push(`L${"left"===n?-i-4:i+4},${s}`)}const s=null!=d[d.length-1].x1?r(d[d.length-1].x1):l;t.push(`L${e},${s}`),t.push("Z")}return e.jsx("g",{"data-testid":"marginal-ridgeline-"+n,children:e.jsx("path",{d:t.join(" "),fill:c.fill,fillOpacity:c.fillOpacity,stroke:"none"===c.stroke?c.fill:c.stroke,strokeWidth:c.strokeWidth})})}return null},[i,r,c,s,l,n,u,4]);return d?e.jsx("g",{className:"marginal-"+n,"data-testid":"marginal-"+n,children:d}):null}function zt(e,t=120,n=8){if(!e)return[];const o=Math.max(1,Math.floor(t/n)),i=e.split(/\s+/),r=[];let s="";for(const e of i)s&&s.length+1+e.length>o?(r.push(s),s=e):s=s?`${s} ${e}`:e;return s&&r.push(s),r}function Wt(e,t,n,o){return"curly"===e?o?`M0,0 C${.6*n},0 ${.4*n},${t/2} ${n},${t/2} C${.4*n},${t/2} ${.6*n},${t} 0,${t}`:`M0,0 C0,${.6*n} ${t/2},${.4*n} ${t/2},${n} C${t/2},${.4*n} ${t},${.6*n} ${t},0`:o?`M0,0 L${n},0 L${n},${t} L0,${t}`:`M0,0 L0,${n} L${t},${n} L${t},0`}function Gt(t,n,o,i){if(!t)return e.jsx("g",{className:"annotation-note"});const{label:r,title:s,orientation:a,align:l,wrap:c=120,noWrap:u}=t;if(!r&&!s)return e.jsx("g",{className:"annotation-note"});let d=a;d||(d=Math.abs(n)>Math.abs(o)?"leftRight":"topBottom");let h=l;h&&"dynamic"!==h||(h="topBottom"===d?0>n?"right":"left":0>o?"bottom":"top");let f="start";"topBottom"===d?"right"===h?f="end":"middle"===h&&(f="middle"):f=0>n?"end":"start";const g=16,p=s?u?[s]:zt(s,c):[],y=r?u?[r]:zt(r,c):[],m="leftRight"===d?"end"===f?-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:f,fontWeight:"bold",children:p.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:g,children:t},n))},"annotation-note-title")),v=p.length*g),y.length>0&&b.push(e.jsx("text",{className:"annotation-note-label",fill:x,textAnchor:f,y:v,children:y.map((t,n)=>e.jsx("tspan",{x:m,dy:0===n?0:g,children:t},n))},"annotation-note-label"));let w=null;if((s||r)&&(0!==n||0!==o))if("topBottom"===d){const t=Math.min(c,120);let n=0,o=t;"end"===f?(n=-t,o=0):"middle"===f&&(n=-t/2,o=t/2),w=e.jsx("line",{className:"note-line",x1:n,x2:o,y1:0,y2:0,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}else{const t=(p.length+y.length)*g+(y.length>0?g:0);let n=0,o=t;"bottom"===h?(n=-t,o=0):"middle"===h&&(n=-t/2,o=t/2),w=e.jsx("line",{className:"note-line",x1:0,x2:0,y1:n,y2:o,stroke:i||"var(--semiotic-text-secondary, currentColor)"})}const k=Math.max(0,p.length+y.length-1)*g;let A=0;return"topBottom"===d?A=0>o?-(k+2):18:"leftRight"===d&&(A="middle"===h?-(k+g+(y.length>0&&p.length>0?2:0))/2+8:"bottom"===h||0>o?-(k+2):18),e.jsxs("g",{className:"annotation-note",transform:`translate(${n},${o})`,children:[e.jsx("g",{className:"annotation-note-content",transform:0!==A?`translate(0,${A})`:void 0,children:b}),w]})}function Yt(t,n,o,i,r){var s;const a=[];switch(t){case"callout-circle":{const t=((null==n?void 0:n.radius)||0)+((null==n?void 0:n.radiusPadding)||0);t>0&&a.push(e.jsx("circle",{r:t,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-circle"));break}case"callout-rect":{const t=(null==n?void 0:n.width)||0,i=(null==n?void 0:n.height)||0;(t>0||i>0)&&a.push(e.jsx("rect",{width:t,height:i,fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"subject-rect"));break}case"callout-custom":(null==n?void 0:n.custom)&&a.push(...Array.isArray(n.custom)?n.custom:[n.custom]);break;case"xy-threshold":{const t=i||0,s=r||0;if(void 0!==(null==n?void 0:n.x)){const i=(n.x||0)-t;a.push(e.jsx("line",{x1:i,y1:(n.y1||0)-s,x2:i,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else if(void 0!==(null==n?void 0:n.y)){const i=(n.y||0)-s;a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:i,x2:(n.x2||0)-t,y2:i,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"))}else void 0!==(null==n?void 0:n.x1)||void 0!==(null==n?void 0:n.x2)?a.push(e.jsx("line",{x1:(n.x1||0)-t,y1:0,x2:(n.x2||0)-t,y2:0,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line")):void 0===(null==n?void 0:n.y1)&&void 0===(null==n?void 0:n.y2)||a.push(e.jsx("line",{x1:0,y1:(n.y1||0)-s,x2:0,y2:(n.y2||0)-s,stroke:o||"var(--semiotic-text-secondary, currentColor)",strokeDasharray:"5,5"},"threshold-line"));break}case"bracket":{const t=null!==(s=null==n?void 0:n.width)&&void 0!==s?s:null==n?void 0:n.height;void 0!==t&&a.push(e.jsx("path",{d:Wt((null==n?void 0:n.type)||"curly",t,(null==n?void 0:n.depth)||30,void 0===(null==n?void 0:n.width)),fill:"none",stroke:o||"var(--semiotic-text-secondary, currentColor)"},"bracket-path"));break}}return e.jsx("g",{className:"annotation-subject",children:a})}function qt(t,n,o,i,r,s){var a;const l=[];let c=0,u=0;if("callout-circle"!==r&&"label"!==r||!(null==s?void 0:s.radius)){if("callout-rect"===r&&s){const e=s.width||0,o=s.height||0;if(e>0||o>0){const i=e/2,r=o/2,s=t-i,a=n-r;if(0!==s||0!==a){const t=Math.abs(s),n=Math.abs(a),l=e/2,d=o/2,h=t*d>n*l?l/t:d/n;c=i+s*h,u=r+a*h}}}else if("bracket"===r&&s){const e=s.width,t=s.height,n=s.depth||30;void 0!==e?(c=e/2,u=n):void 0!==t&&(c=n,u=t/2)}}else{const e=(s.radius||0)+(s.radiusPadding||0);if(e>0&&(0!==t||0!==n)){const o=Math.atan2(n,t);c=Math.cos(o)*e,u=Math.sin(o)*e}}const d=Math.sqrt(Math.pow(t-c,2)+Math.pow(n-u,2));if(d>.5){const r=i||"var(--semiotic-text-secondary, currentColor)",s="curve"===(null==o?void 0:o.type);let h=Math.atan2(n-u,t-c);if(s){const i=(null!==(a=null==o?void 0:o.curve)&&void 0!==a?a:.25)*d,s=(c+t)/2+-(n-u)/d*i,f=(u+n)/2+(t-c)/d*i;l.push(e.jsx("path",{className:"connector-curve",d:`M${c},${u}Q${s},${f} ${t},${n}`,fill:"none",stroke:r},"connector-line")),h=Math.atan2(f-u,s-c)}else l.push(e.jsx("line",{x1:c,y1:u,x2:t,y2:n,stroke:r},"connector-line"));if("arrow"===(null==o?void 0:o.end)){const t=10,n=16/180*Math.PI;l.push(e.jsx("path",{d:`M${c},${u}L${c+t*Math.cos(h+n)},${u+t*Math.sin(h+n)}L${c+t*Math.cos(h-n)},${u+t*Math.sin(h-n)}Z`,fill:r,stroke:"none"},"connector-arrow"))}}return e.jsx("g",{className:"annotation-connector",children:l})}function Vt(t){var n,o;const{x:i=0,y:r=0,dx:s,dy:a,nx:l,ny:c,note:u,connector:d,subject:h,type:f,color:g,className:p,disable:y,opacity:m,strokeDasharray:v,events:b={},"data-testid":x}=t,w=Array.isArray(i)?null!==(n=i[0])&&void 0!==n?n:0:i,k=Array.isArray(r)?null!==(o=r[0])&&void 0!==o?o:0:r,A=new Set(Array.isArray(y)?y:[]);let j=s||0,S=a||0;null!=l&&(j=l-w),null!=c&&(S=c-k);const C="string"==typeof f?f:"label";if("bracket"===C&&h&&0===j&&0===S)if(void 0!==h.width){j=h.width/2;const e=h.depth||30;S=e+(0>e?-5:5)}else if(void 0!==h.height){const e=h.depth||30;j=e+(0>e?-5:5),S=h.height/2}return e.jsxs("g",Object.assign({className:("annotation "+(p||"")).trim(),transform:`translate(${w},${k})`,"data-testid":x},null!=m&&{opacity:m},v&&{strokeDasharray:v},b,{children:[!A.has("connector")&&qt(j,S,d,g,C,h),!A.has("subject")&&Yt(C,h,g,w,k),!A.has("note")&&Gt(u,j,S,g)]}))}function Xt(t){var n,o;const{noteData:i}=t,{screenCoordinates:r}=i,s="string"==typeof i.type?i.type:"label",a=i.eventListeners||i.events||{};if(i.coordinates&&r){const t=i.nx||r[0][0]+(null!==(n=i.dx)&&void 0!==n?n:0),a=i.ny||r[0][1]+(null!==(o=i.dy)&&void 0!==o?o:0),l=r.map((n,o)=>{const r=Object.assign({},i,{note:0===o?i.note:{label:""},x:n[0],y:n[1],nx:t,ny:a});return e.jsx(Vt,Object.assign({"data-testid":"semiotic-annotation"},r,{type:s}),"multi-annotation-"+o)});return e.jsx("g",{children:l})}const l=i.note||{title:"none",label:i.label},c=`${l.label}-${l.title}-${i.i}`;return e.jsx(Vt,Object.assign({"data-testid":"semiotic-annotation",events:a},i,{type:s}),c)}function Ut(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.x)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.time;return r?null!=e.x?r(e.x):t.xAccessor&&null!=e[t.xAccessor]?r(e[t.xAccessor]):null:null}function Kt(e,t){var n,o,i;const r=null!==(o=null===(n=t.scales)||void 0===n?void 0:n.y)&&void 0!==o?o:null===(i=t.scales)||void 0===i?void 0:i.value;return r?null!=e.y?r(e.y):t.yAccessor&&null!=e[t.yAccessor]?r(e[t.yAccessor]):null:null}function Qt(e){return null==e?null:e+""}function Zt(e,t,n){var o;return null===(o=t.stickyPositionCache)||void 0===o||o.set(e,n),n}function Jt(e,t,n){var o,i;const r=e.anchor||(null===(o=e.lifecycle)||void 0===o?void 0:o.anchor)||"fixed";if("latest"===r){if(null!=e.pointId&&n.pointNodes&&n.pointNodes.length>0)for(let o=n.pointNodes.length-1;o>=0;o--){const i=n.pointNodes[o];if(i.pointId===e.pointId)return Zt(t,n,{x:i.x,y:i.y})}const o=function(e){var t,n,o,i,r,s;const a=e.data;if(!a||0===a.length)return null;const l=a[a.length-1],c=null!==(n=null===(t=e.scales)||void 0===t?void 0:t.x)&&void 0!==n?n:null===(o=e.scales)||void 0===o?void 0:o.time,u=null!==(r=null===(i=e.scales)||void 0===i?void 0:i.y)&&void 0!==r?r:null===(s=e.scales)||void 0===s?void 0:s.value;if(!c||!u)return null;const d=l[e.xAccessor||"x"],h=l[e.yAccessor||"y"];return null==d||null==h?null:{x:c(d),y:u(h)}}(n);return o?Zt(t,n,o):null}if("semantic"===r){const o=function(e,t,n){var o,i;const r=function(e){var t,n;return Qt(null!==(n=null===(t=e.provenance)||void 0===t?void 0:t.stableId)&&void 0!==n?n:e.stableId)}(e);if(!r)return null;const s=null===(o=n.pointNodes)||void 0===o?void 0:o.find(e=>Qt(e.pointId)===r);if(s)return Zt(t,n,{x:s.x,y:s.y});const a=null===(i=n.data)||void 0===i?void 0:i.find(e=>function(e){var t,n,o;return Qt(null!==(n=null!==(t=e.stableId)&&void 0!==t?t:e.id)&&void 0!==n?n:null===(o=e.provenance)||void 0===o?void 0:o.stableId)}(e)===r);if(!a)return null;const l=Ut(a,n),c=Kt(a,n);return null==l||null==c?null:Zt(t,n,{x:l,y:c})}(e,t,n);if(o)return o}let s=null,a=null;if(null!=e.pointId&&n.pointNodes){const t=n.pointNodes.find(t=>t.pointId===e.pointId);t&&(s=t.x,a=t.y)}if(null!=s&&null!=a||(s=Ut(e,n),a=Kt(e,n)),null!=s&&null!=a)return Zt(t,n,{x:s,y:a});if("sticky"===r){const e=null===(i=n.stickyPositionCache)||void 0===i?void 0:i.get(t);if(e)return e}return null}function en(e,t,n,o=50){return!(-o>e||e>(n.width||0)+o||-o>t||t>(n.height||0)+o)}const tn={secondary:0,primary:3},nn=".annotation-deferred{opacity:0;pointer-events:none;transition:opacity .12s ease}.stream-xy-frame:hover .annotation-deferred,.stream-ordinal-frame:hover .annotation-deferred,.stream-network-frame:hover .annotation-deferred,.stream-geo-frame:hover .annotation-deferred,.stream-xy-frame:focus-within .annotation-deferred,.stream-ordinal-frame:focus-within .annotation-deferred,.stream-network-frame:focus-within .annotation-deferred,.stream-geo-frame:focus-within .annotation-deferred{opacity:1;pointer-events:auto}@media (prefers-reduced-motion:reduce){.annotation-deferred{transition:none}}";function on(e){return!0===(null==e?void 0:e._annotationDeferred)}function rn(e){return"blended"===(null==e?void 0:e.cohesion)||"layer"===(null==e?void 0:e.cohesion)?e.cohesion:null}function sn(e){var t;const n=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;return"number"==typeof n&&Number.isFinite(n)?Math.max(0,Math.min(1,n)):null}function an(e){return Math.max(.72,.95-.06*e)}function ln(t){const n=t.map((e,t)=>{return{p:e,i:t,emphasis:(n=e.annotation,"primary"===(null==n?void 0:n.emphasis)||"secondary"===(null==n?void 0:n.emphasis)?n.emphasis:null),confidence:sn(e.annotation),readingOrder:null,rank:1};var n}),o=n.some(e=>null!=e.emphasis||null!=e.confidence),i=t.some(e=>on(e.annotation)),r=t.some(e=>null!=rn(e.annotation)),s=t.some(e=>"layer"===rn(e.annotation));if(!o&&!i&&!r)return t.map(e=>e.node);const a=n.filter(e=>null==e.emphasis&&null!=e.confidence).slice().sort((e,t)=>{var n,o;return(null!==(n=t.confidence)&&void 0!==n?n:0)-(null!==(o=e.confidence)&&void 0!==o?o:0)||e.i-t.i});a.forEach((e,t)=>{e.readingOrder=t,e.rank=2-t/Math.max(1,a.length)});for(const e of n)e.emphasis&&(e.rank=tn[e.emphasis]);const l=n.sort((e,t)=>e.rank-t.rank||e.i-t.i).map(t=>{const{p:n,i:o,emphasis:i,readingOrder:r}=t,s=on(n.annotation);let a=n.node;if("primary"===i||"secondary"===i||null!=r){const t=null==i&&null!=r;a=e.jsx("g",Object.assign({className:t?"annotation-emphasis annotation-emphasis--inferred":"annotation-emphasis annotation-emphasis--"+i},"secondary"===i?{opacity:.6,fontSize:"0.88em"}:{},t?{opacity:an(r),"data-annotation-reading-order":r}:{},{children:n.node}),"annotation-emphasis-"+o)}const l=rn(n.annotation);return l&&(a=e.jsx("g",{className:"annotation-cohesion--"+l,children:a},"annotation-cohesion-"+o)),s&&(a=e.jsx("g",{className:"annotation-deferred","data-annotation-disclosure":"deferred",children:a},"annotation-deferred-"+o)),a});return i&&l.unshift(e.jsx("style",{children:nn},"annotation-disclosure-style")),s&&l.unshift(e.jsx("style",{children:".annotation-cohesion--layer text,.annotation-cohesion--layer tspan{fill:var(--semiotic-annotation-color,var(--semiotic-text-secondary,#666));font-style:italic}"},"annotation-cohesion-style")),l}const cn={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 un(e,t,n,o){const i=[];return e.forEach((e,r)=>{let s;if(n){const i=n(e,r,o);s=null!=i?i:t(e,r,o)}else s=t(e,r,o);s&&i.push({node:s,annotation:e})}),ln(i)}function dn(t){return function(t,n,o){var i,r,a,c,u,d,h,f,g,m,v,b,x,w,k,A,j,S,C,O,M,P,_,L,T,N,R,$,D,B,I,E,F,H,z,W,G,Y,q,V,X,U,K,Q,Z,J,ee,te,ne,oe,ie;switch(t.type){case"label":case"callout":case"callout-circle":case"callout-rect":{const s=Jt(t,n,o);if(!s)return null;const{x:l,y:c}=s;if(!en(l,c,o))return null;const u="callout"===t.type?"callout-circle":t.type,d="callout-circle"===u?{radius:null!==(i=t.radius)&&void 0!==i?i:12,radiusPadding:t.radiusPadding}:"callout-rect"===u?{width:t.width,height:t.height}:void 0;return e.jsx(Xt,{noteData:Object.assign(Object.assign({x:l,y:c,dx:null!==(r=t.dx)&&void 0!==r?r:30,dy:null!==(a=t.dy)&&void 0!==a?a:-30,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:u},d?{subject:d}:{}),{connector:t.connector||{end:"arrow"},color:t.color,disable:t.disable,opacity:t.opacity,strokeDasharray:t.strokeDasharray,className:t.className})},"ann-"+n)}case"x-threshold":{const i=Ut(null!=t.value?Object.assign(Object.assign({},t),{x:t.value}):t,o);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"top";let a;return a="bottom"===s?(o.height||0)-4:"center"===s?(o.height||0)/2:12,e.jsxs("g",{children:[e.jsx("line",{x1:i,y1:0,x2:i,y2:o.height||0,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:i+4,y:a,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"y-threshold":{const i=Kt(null!=t.value?Object.assign(Object.assign({},t),{y:t.value}):t,o);if(null==i)return null;const r=t.color||"#f97316",s=t.labelPosition||"right";let a,l;return"left"===s?(a=4,l="start"):"center"===s?(a=(o.width||0)/2,l="middle"):(a=(o.width||0)-4,l="end"),e.jsxs("g",{children:[e.jsx("line",{x1:0,y1:i,x2:o.width||0,y2:i,stroke:r,strokeWidth:t.strokeWidth||1.5,strokeDasharray:t.strokeDasharray||"6,3"}),t.label&&e.jsx("text",{x:a,y:i-4,textAnchor:l,fill:r,fontSize:12,fontWeight:"bold",children:t.label})]},"ann-"+n)}case"enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),o),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),o),r:1})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=l.packEnclose(i),s=t.padding||10;return e.jsxs("g",{children:[e.jsx("circle",{cx:r.x,cy:r.y,r:r.r+s,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:r.x,y:r.y-r.r-s-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"rect-enclose":{const i=(t.coordinates||[]).map(e=>({x:Ut(Object.assign(Object.assign({},e),{type:"point"}),o),y:Kt(Object.assign(Object.assign({},e),{type:"point"}),o)})).filter(e=>null!=e.x&&null!=e.y);if(2>i.length)return null;const r=t.padding||10,s=i.map(e=>e.x),a=i.map(e=>e.y),l=Math.min(...s)-r,c=Math.max(...s)+r,u=Math.min(...a)-r,d=Math.max(...a)+r;return e.jsxs("g",{children:[e.jsx("rect",{x:l,y:u,width:c-l,height:d-u,fill:t.fill||"none",fillOpacity:t.fillOpacity||.1,stroke:t.color||"var(--semiotic-text-secondary, #666)",strokeWidth:1.5,strokeDasharray:"4,2"}),t.label&&e.jsx("text",{x:(l+c)/2,y:u-4,textAnchor:"middle",fill:t.color||"var(--semiotic-text-secondary, #666)",fontSize:12,children:t.label})]},"ann-"+n)}case"highlight":{const i=o.data||[],r="function"==typeof t.filter?i.filter(t.filter):t.field&&null!=t.value?i.filter(e=>e[t.field]===t.value):[],s={stroke:t.color||"#f97316",strokeWidth:2,fill:"none"};return e.jsx("g",{children:r.map((n,i)=>{const r=Ut(n,o),a=Kt(n,o);if(null==r||null==a)return null;const l="function"==typeof t.r?t.r(n):t.r||6,c="function"==typeof t.style?t.style(n):t.style||s;return e.jsx("circle",Object.assign({cx:r,cy:a,r:l},c),"hl-"+i)})},"ann-"+n)}case"bracket":{const i=Ut(t,o),r=Kt(t,o);return e.jsx(Xt,{noteData:{x:null!=i?i:0,y:null!=r?r:0,dx:t.dx||0,dy:t.dy||0,note:{label:t.label,title:t.title,wrap:t.wrap||120},type:"bracket",subject:{type:t.bracketType||"curly",width:t.width,height:t.height,depth:t.depth||30},color:t.color}},"ann-"+n)}case"trend":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a="ordinal"===o.frameType,l="horizontal"===o.projection,p=a?r:null,v=a?s:null;let b;const x=[],w=new Map;if(a&&p&&v){for(const e of i){const t=e[p];if(null==t)continue;const n=t+"";w.has(n)||(w.set(n,x.length),x.push(n))}b=i.map(e=>{const t=e[p],n=e[v];if(null==t||null==n)return null;const o=w.get(t+"");return null!=o?[o,+n]:null}).filter(e=>null!==e)}else b=i.map(e=>[e[r],e[s]]).filter(e=>null!=e[0]&&null!=e[1]);if(2>b.length)return null;const k=null!==(u=null===(c=o.scales)||void 0===c?void 0:c.x)&&void 0!==u?u:null===(d=o.scales)||void 0===d?void 0:d.time,A=null!==(f=null===(h=o.scales)||void 0===h?void 0:h.y)&&void 0!==f?f:null===(g=o.scales)||void 0===g?void 0:g.value;if(!k||!A)return null;const j=e=>t=>{const n=Math.max(0,Math.floor(t)),o=Math.min(x.length-1,n+1),i=t-n,r=e(x[n]);return r+(e(x[o])-r)*i},S=k,C=A;let O;if(a)if(l){const e=j(C);O=(t,n)=>[S(n),e(t)]}else{const e=j(S);O=(t,n)=>[e(t),C(n)]}else O=(e,t)=>[S(e),C(t)];const M=t.method||"linear";let P;P="loess"===M?function(e,t=.3){const n=e.length;if(2>n)return e.slice();const o=e.slice().sort((e,t)=>e[0]-t[0]),i=o.map(e=>e[0]),r=o.map(e=>e[1]),s=Math.max(2,Math.ceil(t*n)),a=[];for(let e=0;n>e;e++){const t=i[e],o=i.map(e=>Math.abs(e-t)),l=o.slice().sort((e,t)=>e-t)[Math.min(s-1,n-1)]||1,c=[];for(let e=0;n>e;e++){const t=0===l?0:o[e]/l;c[e]=1>t?Math.pow(1-Math.pow(t,3),3):0}let u=0,d=0,h=0,f=0,g=0;for(let e=0;n>e;e++){const t=c[e];0!==t&&(u+=t,d+=t*i[e],h+=t*r[e],f+=t*i[e]*i[e],g+=t*i[e]*r[e])}if(0===u){a.push([t,r[e]]);continue}const p=u*f-d*d;if(1e-12>Math.abs(p))a.push([t,h/u]);else{const e=(u*g-d*h)/p;a.push([t,(h-e*d)/u+e*t])}}return a}(b,null!==(m=t.bandwidth)&&void 0!==m?m:.3):("polynomial"===M?y.default.polynomial(b,{order:t.order||2}):y.default.linear(b)).points;const _=P.map(([e,t])=>{const[n,o]=O(e,t);return`${n},${o}`}).join(" "),L=t.color||"#6366f1",T=P[P.length-1],[N,R]=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:N+4,y:R-4,fill:L,fontSize:11,children:t.label})]},"ann-"+n)}case"band":{const i=null!==(b=null===(v=o.scales)||void 0===v?void 0:v.y)&&void 0!==b?b:null===(x=o.scales)||void 0===x?void 0:x.value,r=null!==(w=null==i?void 0:i(t.y0))&&void 0!==w?w:0,s=null!==(k=null==i?void 0:i(t.y1))&&void 0!==k?k:o.height||0;return e.jsxs("g",{children:[e.jsx("rect",{x:0,y:Math.min(r,s),width:o.width||0,height:Math.abs(s-r),fill:t.fill||"var(--semiotic-primary, #6366f1)",fillOpacity:t.fillOpacity||.1}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(r,s)-4,textAnchor:"end",fill:t.color||"var(--semiotic-primary, #6366f1)",fontSize:11,children:t.label})]},"ann-"+n)}case"envelope":{const i=o.data||[];if(2>i.length)return null;const r=o.xAccessor||"x",a=null!==(j=null===(A=o.scales)||void 0===A?void 0:A.x)&&void 0!==j?j:null===(S=o.scales)||void 0===S?void 0:S.time,l=null!==(O=null===(C=o.scales)||void 0===C?void 0:C.y)&&void 0!==O?O:null===(M=o.scales)||void 0===M?void 0:M.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 f=cn[o.curve||"linear"]||s.curveLinear,g=s.area().x(e=>a(e[r])).y0(e=>l(e[u])).y1(e=>l(e[c])).curve(f)(h);if(!g)return null;const p=t.fill||"#6366f1";return e.jsxs("g",{children:[e.jsx("path",{d:g,fill:p,fillOpacity:null!==(P=t.fillOpacity)&&void 0!==P?P:.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-"+n)}case"anomaly-band":{const i=o.data||[];if(2>i.length)return null;const r=o.yAccessor||"y",s=null!==(L=null===(_=o.scales)||void 0===_?void 0:_.x)&&void 0!==L?L:null===(T=o.scales)||void 0===T?void 0:T.time,a=null!==(R=null===(N=o.scales)||void 0===N?void 0:N.y)&&void 0!==R?R:null===($=o.scales)||void 0===$?void 0:$.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!==(D=t.threshold)&&void 0!==D?D:2,f=c-h*d,g=!1!==t.showBand,p=t.fill||"#6366f1",y=null!==(B=t.fillOpacity)&&void 0!==B?B:.1,m=t.anomalyColor||"#ef4444",v=null!==(I=t.anomalyRadius)&&void 0!==I?I:6,b=a(c+h*d),x=a(f),w=i.filter(e=>{const t=e[r];return null!=t&&Math.abs(t-c)>h*d});return e.jsxs("g",{children:[g&&e.jsx("rect",{x:0,y:Math.min(b,x),width:o.width||0,height:Math.abs(x-b),fill:p,fillOpacity:y}),w.map((t,n)=>{const i=Ut(t,o),r=Kt(t,o);return null==i||null==r?null:e.jsx("circle",{cx:i,cy:r,r:v,fill:m,fillOpacity:.7,stroke:m,strokeWidth:1.5},"anomaly-"+n)}),t.label&&e.jsx("text",{x:(o.width||0)-4,y:Math.min(b,x)-4,textAnchor:"end",fill:p,fontSize:11,children:t.label})]},"ann-"+n)}case"forecast":{const i=o.data||[];if(3>i.length)return null;const r=o.xAccessor||"x",s=o.yAccessor||"y",a=null!==(F=null===(E=o.scales)||void 0===E?void 0:E.x)&&void 0!==F?F:null===(H=o.scales)||void 0===H?void 0:H.time,l=null!==(W=null===(z=o.scales)||void 0===z?void 0:z.y)&&void 0!==W?W:null===(G=o.scales)||void 0===G?void 0:G.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,n,o)=>e+n*Math.pow(t,o),0)}else{const e=c.length;let t=0,n=0,o=0,i=0;for(const[e,r]of c)t+=e,n+=r,o+=e*e,i+=e*r;const r=e*o-t*t;if(1e-12>Math.abs(r))return null;const s=(e*i-t*n)/r,a=(n-s*t)/e;u=e=>a+s*e}const d=c.length,h=c.map(([e,t])=>t-u(e)).reduce((e,t)=>e+t*t,0),f=Math.sqrt(h/Math.max(d-2,1)),g=c.reduce((e,t)=>e+t[0],0)/d,p=c.reduce((e,t)=>e+Math.pow(t[0]-g,2),0),m=null!==(Y=t.confidence)&&void 0!==Y?Y:.95,v=.99>m?.95>m?.9>m?1:1.645:1.96:2.576,b=null!==(q=t.steps)&&void 0!==q?q:5,x=c[d-1][0],w=(x-c[0][0])/Math.max(d-1,1),k=[];for(let e=1;b>=e;e++)k.push(x+e*w);const A=[];for(const e of k){const t=u(e),n=f*Math.sqrt(1+1/d+(p>0?Math.pow(e-g,2)/p:0))*v;A.push({x:e,yCenter:t,yUpper:t+n,yLower:t-n})}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!==(V=t.fillOpacity)&&void 0!==V?V:.15,stroke:"none"}),e.jsx("polyline",{points:`${C} ${S}`,fill:"none",stroke:O,strokeWidth:null!==(X=t.strokeWidth)&&void 0!==X?X:2,strokeDasharray:null!==(U=t.strokeDasharray)&&void 0!==U?U:"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-"+n)}case"widget":{let i=null,r=null;if(null!=t.px&&null!=t.py)i=t.px,r=t.py;else{const e=Jt(t,n,o);if(!e)return null;i=e.x,r=e.y}if(null==i||null==r)return null;if(!en(i,r,o))return null;const s=null!==(K=t.dx)&&void 0!==K?K:0,a=null!==(Q=t.dy)&&void 0!==Q?Q:0,l=null!==(Z=t.width)&&void 0!==Z?Z:32,c=null!==(J=t.height)&&void 0!==J?J:32,u=null!==(ee=t.content)&&void 0!==ee?ee:e.jsx("span",{style:{fontSize:18,cursor:"default"},title:t.label||"Info",children:"ℹ️"});return e.jsx("foreignObject",{x:i+s-l/2,y:r+a-c/2,width:l,height:c,style:{overflow:"visible",pointerEvents:"auto"},children:e.jsx("div",{style:{width:l,height:c,display:"flex",alignItems:"center",justifyContent:"center"},children:u})},"ann-"+n)}case"text":{const i=Jt(t,n,o);if(!i)return null;const{x:r,y:s}=i,a=r+(t.dx||0),l=s+(t.dy||0),c=t.color||"var(--semiotic-text, #333)",u=e.jsx("text",{x:a,y:l,fill:c,fontSize:t.fontSize||11,opacity:t.opacity,strokeDasharray:t.strokeDasharray,dominantBaseline:"middle",style:{fontFamily:"inherit"},children:t.label});return!0!==t._redundantConnector?p.cloneElement(u,{key:"ann-text-"+n}):e.jsxs("g",{opacity:t.opacity,strokeDasharray:t.strokeDasharray,children:[e.jsx("line",{x1:r,y1:s,x2:a,y2:l,stroke:c,strokeWidth:1,strokeOpacity:.5,style:{pointerEvents:"none"}}),p.cloneElement(u,{opacity:void 0,strokeDasharray:void 0})]},"ann-text-"+n)}case"category-highlight":{const i=t.category;if(null==i)return null;const r=e=>"function"==typeof e&&"function"==typeof e.bandwidth,s=null===(te=o.scales)||void 0===te?void 0:te.o,a=null===(ne=o.scales)||void 0===ne?void 0:ne.x,l=null===(oe=o.scales)||void 0===oe?void 0:oe.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)",f=null!==(ie=t.opacity)&&void 0!==ie?ie:.15,g=t.label;return e.jsxs("g",(o.projection?"vertical"===o.projection:c===a)?{children:[e.jsx("rect",{x:u,y:0,width:d,height:o.height||0,fill:h,fillOpacity:f}),g&&e.jsx("text",{x:u+d/2,y:12,textAnchor:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]}:{children:[e.jsx("rect",{x:0,y:u,width:o.width||0,height:d,fill:h,fillOpacity:f}),g&&e.jsx("text",{x:12,y:u+d/2,dominantBaseline:"middle",fill:h,fontSize:12,fontWeight:"bold",children:g})]},"ann-"+n)}default:return null}}}const hn=new Set(["label","callout","callout-circle","callout-rect","text","widget"]),fn=new Set(["label","callout","callout-circle","callout-rect"]);function gn(e){return"string"==typeof(null==e?void 0:e.type)?e.type:""}function pn(e){return!!e&&"object"==typeof e&&hn.has(gn(e))}function yn(e){return fn.has(gn(e))&&!function(e){return Array.isArray(null==e?void 0:e.disable)&&e.disable.includes("connector")}(e)}function mn(e){return"primary"===(null==e?void 0:e.emphasis)||!0===(null==e?void 0:e.defensive)}function vn(e,t,n={}){return"number"==typeof n.maxAnnotations&&Number.isFinite(n.maxAnnotations)?Math.max(0,Math.floor(n.maxAnnotations)):e>0&&t>0?Math.max(1,Math.round(e*t/(n.areaPerAnnotation&&n.areaPerAnnotation>0?n.areaPerAnnotation:2e4))):1/0}function bn(e){var t,n;let o;const i=null==e?void 0:e.emphasis;o="primary"===i?100:"secondary"===i?10:50;const r=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;switch("number"==typeof r&&Number.isFinite(r)&&(o+=15*function(e){return Math.max(0,Math.min(1,e))}(r)),null===(n=null==e?void 0:e.lifecycle)||void 0===n?void 0:n.freshness){case"fresh":o+=8;break;case"aging":o+=4;break;case"stale":o+=1;break;case"expired":o-=200}return o}const xn=32,wn=6,kn=4,An=8,jn=72;const Sn={ai:"AI",agent:"agent",watcher:"watcher",system:"system",import:"imported",computed:"computed",user:"you"};function Cn(e){return pn(e)}function On(e,t){if(!e)return[];const n=Math.max(1,Math.floor(t/7)),o=e.split(/\s+/).filter(Boolean),i=[];let r="";for(const e of o)r&&r.length+e.length+1>n?(i.push(r),r=e):r=r?`${r} ${e}`:e;return r&&i.push(r),i}function Mn(e,t,n,o,i){const r=e+n,s=t+o;return Math.abs(n)>Math.abs(o)?{x:0>n?r-i.width-4:r+4,y:0>o?s-i.height:s,width:i.width,height:i.height}:{x:0>n?r-i.width:r,y:0>o?s-i.height-4:s+4,width:i.width,height:i.height}}function Pn(e,t){return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}function _n(e,t){return Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y))}function Ln(e,t,n,o,i,r,s,a){const l=Pn(e,s);let c=.4*Math.hypot(t.dx,t.dy)+80*function(e,t,n,o){const i=Math.max(0,o-e.x),r=Math.max(0,o-e.y);return(i+Math.max(0,e.x+e.width-(t-o)))*e.height+(r+Math.max(0,e.y+e.height-(n-o)))*e.width}(l,i,r,a);for(const e of n)c+=12*_n(l,e);for(const e of o)c+=4*_n(l,e);return c}function Tn(e){var t;const{annotations:n,context:o,defaultOffset:i=xn,notePadding:r=wn,markPadding:s=kn,edgePadding:a=An,preserveManualOffsets:l=!0,routeLongConnectors:c=!0,connectorThreshold:u=jn,density:d,progressiveDisclosure:h=!1,redundantCues:f=!1,responsive:g,cohesion:p,audience:y}=e,m=o.width||0,v=o.height||0;if(0===n.length||0>=m||0>=v)return n.slice();const b=[],x=function(e,t){return(e.pointNodes||[]).map(e=>{const n=Math.max(1,e.r||1)+t;return{x:e.x-n,y:e.y-n,width:2*n,height:2*n}})}(o,s);let w=!1;const k=n.map((e,t)=>{if(!Cn(e))return e;const n=function(e,t,n){var o,i;if("widget"===e.type&&"number"==typeof e.px&&"number"==typeof e.py)return{x:e.px,y:e.py};const r=null!==(o=e.pointId)&&void 0!==o?o:e.nodeId;if(null!=r&&n.pointNodes){const e=n.pointNodes.find(e=>e.pointId===r);if(e)return{x:e.x,y:e.y}}const s=e.coordinates,a=null===(i=n.scales)||void 0===i?void 0:i.geoProjection;if(Array.isArray(s)&&s.length>=2&&a){const e=s[0],t=s[1];if("number"==typeof e&&"number"==typeof t){const n=a([e,t]);if(n&&"number"==typeof n[0]&&"number"==typeof n[1])return{x:n[0],y:n[1]}}}return n.scales||"number"!=typeof e.x||"number"!=typeof e.y?Jt(e,t,n):{x:e.x,y:e.y}}(e,t,o);if(!n)return e;const s=function(e){if("widget"===e.type)return{width:"number"==typeof e.width?e.width:32,height:"number"==typeof e.height?e.height:32};const t="number"==typeof e.wrap?e.wrap:120,n=[...On("string"==typeof e.title?e.title:void 0,t),...On("string"==typeof e.label?e.label:void 0,t)],o=n.reduce((e,t)=>Math.max(e,t.length),0);return{width:Math.max(24,Math.min(t,7*o)+10),height:Math.max(18,16*n.length+6)}}(e);if(l&&("number"==typeof(d=e).dx||"number"==typeof d.dy)){const t=function(e){return"text"===e.type||"widget"===e.type?{dx:0,dy:0}:{dx:30,dy:-30}}(e);return b.push(Pn(Mn(n.x,n.y,"number"==typeof e.dx?e.dx:t.dx,"number"==typeof e.dy?e.dy:t.dy,s),r)),e}var d;let h=null,f=1/0;for(const e of function(e){const t=1.6*e;return[{dx:e,dy:-e},{dx:-e,dy:-e},{dx:e,dy:e},{dx:-e,dy:e},{dx:e,dy:0},{dx:-e,dy:0},{dx:0,dy:-e},{dx:0,dy:e},{dx:t,dy:-t},{dx:-t,dy:-t},{dx:t,dy:t},{dx:-t,dy:t}]}(i)){const t=Ln(Mn(n.x,n.y,e.dx,e.dy,s),e,b,x,m,v,r,a);f>t&&(h=e,f=t)}if(!h)return e;const g=Pn(Mn(n.x,n.y,h.dx,h.dy,s),r);b.push(g);const p=Math.hypot(h.dx,h.dy),y=c&&p>=u&&"text"!==e.type&&"widget"!==e.type?Object.assign(Object.assign({},e.connector||{end:"arrow"}),{type:"curve"}):e.connector;return w=!0,Object.assign(Object.assign(Object.assign({},e),{dx:h.dx,dy:h.dy}),y?{connector:y}:{})}),A=w?k:n.slice();let j=A;if(f){let e=!1;const t=A.map(t=>{const n=function(e){return"text"!==e.type||"string"!=typeof e.color||8>Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0)?e:Object.assign(Object.assign({},e),{_redundantConnector:!0})}(t);return n!==t&&(e=!0),n});j=e?t:A}{let e=!1;const t=j.map(t=>{if(!0!==(null==t?void 0:t.defensive))return t;const n=function(e){var t;const n=null==e?void 0:e.provenance;if(!n||"object"!=typeof n)return e;const o="string"==typeof n.source?null!==(t=Sn[n.source])&&void 0!==t?t:n.source:null,i="number"==typeof n.confidence&&Number.isFinite(n.confidence)?Math.round(100*Math.max(0,Math.min(1,n.confidence)))+"%":null;if(!o&&!i)return e;if(null!=e.label&&"string"!=typeof e.label)return e;const r=[o,i].filter(Boolean).join(" · "),s="string"==typeof e.label?e.label:"";return s.includes(`(${r})`)?e:Object.assign(Object.assign({},e),{label:s?`${s} (${r})`:`(${r})`})}(t);return n!==t&&(e=!0),n});j=e?t:j}const S=new Set;if(d){const e="object"==typeof d?d:{},n=function(e){if(!e)return 1;const t=function(e){const t=null==e?void 0:e.familiarity;if(!t)return 3;const n=Object.values(t).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0===n.length?3:n.reduce((e,t)=>e+t,0)/n.length}(e);return t>2?4>t?1:.6:1.5}(y),o=1===n?e:Object.assign(Object.assign({},e),{maxAnnotations:Math.max(0,Math.round((null!==(t=e.maxAnnotations)&&void 0!==t?t:vn(m,v,e))*n))}),{deferred:i}=function(e){var t;const{annotations:n,width:o,height:i}=e,r=Math.max(0,null!==(t=e.minVisible)&&void 0!==t?t:1),s=vn(o,i,e),a=n.map((e,t)=>{return{annotation:e,index:t,note:(n=e,pn(n))};var n}),l=a.filter(e=>e.note);if(0===l.length||s>=l.length)return{visible:n.slice(),deferred:[],budget:s};const c=l.filter(e=>mn(e.annotation)),u=l.filter(e=>!mn(e.annotation)).sort((e,t)=>bn(t.annotation)-bn(e.annotation)||e.index-t.index),d=Math.min(u.length,Math.max(Math.max(0,s-c.length),Math.max(0,r-c.length))),h=new Set([...c.map(e=>e.index),...u.slice(0,d).map(e=>e.index)]),f=[],g=[];for(const{annotation:e,index:t,note:n}of a)!n||h.has(t)?f.push(e):g.push(e);return{visible:f,deferred:g,budget:s}}(Object.assign({annotations:j,width:m,height:v},o));for(const e of i)S.add(e)}if(g&&("object"==typeof g&&"number"==typeof g.minWidth?g.minWidth:480)>=m)for(const e of j)Cn(e)&&"secondary"===e.emphasis&&S.add(e);if(S.size>0)for(const e of j)!0===(null==e?void 0:e.defensive)&&S.delete(e);let C;return C=0===S.size?j:h?j.map(e=>S.has(e)?Object.assign(Object.assign({},e),{_annotationDeferred:!0}):e):j.filter(e=>!S.has(e)),p?function(e,t){let n=!1;const o=e.map(e=>Cn(e)?"blended"===e.cohesion||"layer"===e.cohesion?e:(n=!0,Object.assign(Object.assign({},e),{cohesion:t})):e);return n?o:e}(C,p):C}let Nn={positions:new Map};const Rn=new Set;function $n(){for(const e of Rn)e()}function Dn(e,t){const n=Nn.positions.get(e);if(null==n?void 0:n.locked)return;if(!n||n.sourceId!==t)return;const o=new Map(Nn.positions);o.delete(e),Nn={positions:o},$n()}function Bn(e,t){const n=Nn.positions.get(e);if(!(null==n?void 0:n.locked))return;if(t&&n.sourceId!==t)return;const o=new Map(Nn.positions);o.delete(e),Nn={positions:o},$n()}function In(){return Nn}function En(e){return Rn.add(e),()=>Rn.delete(e)}const Fn={positions:new Map};function Hn(){return()=>{}}function zn(){return Fn}function Wn(e,t,n){return"exact"===n?function(e,t){const n=e.domain(),o=n[0],i=n[n.length-1],r=o instanceof Date,s=o instanceof Date?o.getTime():o,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 n=e===t-1?a:s+e*l;c[e]=r?new Date(n):n}return c}(e,t):e.ticks(t)}function Gn(e,t,n){if("edges"===e){if(t)return"start";if(n)return"end"}return"middle"}function Yn(e,t,n){if("edges"===e){if(t)return"hanging";if(n)return"auto"}return"middle"}function qn(e){if(0===e.length)return{min:null,max:null};let t=1/0,n=-1/0;for(const o of e)t>o.pixel&&(t=o.pixel),o.pixel>n&&(n=o.pixel);return{min:t,max:n}}function Vn(e){if(e)return"dashed"===e?"6,4":"dotted"===e?"2,4":e}function Xn(e,t,n){if("left"===e||"right"===e){const o="left"===e?n:0,i="left"===e?-1:1,r=Math.ceil(t/8);let s="M0,"+o;for(let e=0;r>e;e++){const n=8*(e+1);s+=`L${Math.min(8*e+4,t)},${o+4*i}`,s+=`L${Math.min(n,t)},${o}`}return s}{const o="bottom"===e?0:t,i="bottom"===e?1:-1,r=Math.ceil(n/8);let s=`M${o},0`;for(let e=0;r>e;e++){const t=8*(e+1);s+=`L${o+4*i},${Math.min(8*e+4,n)}`,s+=`L${o},${Math.min(t,n)}`}return s}}function Un(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,axes:u,showGrid:d,xFormat:h,yFormat:f,axisExtent:g}=n,p=t.useMemo(()=>{var e,t;if(!l)return[];const n=null==u?void 0:u.find(e=>"bottom"===e.orient),i=(null==n?void 0:n.tickFormat)||h||Kn,r=Math.max(2,Math.floor(o/70)),s=null!==(e=null==n?void 0:n.ticks)&&void 0!==e?e:5,a=null!==(t=null==n?void 0:n.tickValues)&&void 0!==t?t:Wn(l.x,"exact"===g?Math.max(2,s):Math.min(s,r),g),c=a.map(e=>e.valueOf()),d=a.map((e,t)=>({value:e,pixel:l.x(e),label:i(e,t,c)})),f=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 Qn(d,Math.max(55,f+8))},[l,u,h,o,g]),y=t.useMemo(()=>{var e,t;if(!l)return[];const n=null==u?void 0:u.find(e=>"left"===e.orient),o=(null==n?void 0:n.tickFormat)||f||Kn,r=Math.max(2,Math.floor(i/30)),s=null!==(e=null==n?void 0:n.ticks)&&void 0!==e?e:5;return Qn((null!==(t=null==n?void 0:n.tickValues)&&void 0!==t?t:Wn(l.y,"exact"===g?Math.max(2,s):Math.min(s,r),g)).map(e=>({value:e,pixel:l.y(e),label:o(e)})),22)},[l,u,f,i,g]),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),w=v&&(!b||!1!==b.baseline),k=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,n;const r=Vn(null===(t=null==u?void 0:u.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),s=Vn(null===(n=null==u?void 0:u.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[p.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:i,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:r},"xgrid-"+n)),y.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:o,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:s},"ygrid-"+n))]})})(),w&&!A&&e.jsx("line",{x1:0,y1:i,x2:o,y2:i,stroke:S,strokeWidth:1}),A&&e.jsx("path",{d:Xn("bottom",o,i),fill:"none",stroke:S,strokeWidth:1}),k&&!j&&e.jsx("line",{x1:0,y1:0,x2:0,y2:i,stroke:S,strokeWidth:1}),j&&e.jsx("path",{d:Xn("left",o,i),fill:"none",stroke:S,strokeWidth:1})]})})}function Kn(e,t,n){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:"number"==typeof e?Math.round(100*e)/100+"":e+""}function Qn(e,t){if(2>=e.length)return e;const n=[e[0]];for(let o=1;e.length-1>o;o++)t>Math.abs(e[o].pixel-n[n.length-1].pixel)||n.push(e[o]);const o=e[e.length-1];return t>Math.abs(o.pixel-n[n.length-1].pixel)?n[n.length-1]=o:n.push(o),n}function Zn(n){var o,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,axes:h,xLabel:f,yLabel:g,yLabelRight:p,xFormat:y,yFormat:m,axisExtent:v,showGrid:b,title:x,legend:w,legendHoverBehavior:k,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S,legendPosition:C="right",legendLayout:O,foregroundGraphics:M,marginalGraphics:P,xValues:_,yValues:L,annotations:T,autoPlaceAnnotations:N,svgAnnotationRules:R,xAccessor:$,yAccessor:D,annotationData:B,pointNodes:I,curve:E,underlayRendered:F,canvasObscuresUnderlay:H=!0,linkedCrosshairName:z,linkedCrosshairSourceId:W,children:G}=n,Y=t.useMemo(()=>{var e,t;if(!d||!u)return[];const n=null==h?void 0:h.find(e=>"bottom"===e.orient),o=(null==n?void 0:n.tickFormat)||y||Kn,i=Math.max(2,Math.floor(r/70)),s=null!==(e=null==n?void 0:n.ticks)&&void 0!==e?e:5,a=null!==(t=null==n?void 0:n.tickValues)&&void 0!==t?t:Wn(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:o(e,t,l)})),f=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),g=(null==n?void 0:n.autoRotate)?Math.max(20,Math.min(f+8,55)):Math.max(55,f+8);let p=Qn(c,g);if(p.length>1&&(p=p.filter((e,t)=>0===t||e.label+""!=p[t-1].label+"")),(null==n?void 0:n.includeMax)&&p.length>0&&"exact"!==v&&!(null==n?void 0:n.tickValues)){const e=u.x.domain()[1],t=u.x(e),n=p[p.length-1].pixel;if(Math.abs(t-n)>1){const i=o(e,p.length,l);g>t-n&&p.length>1&&(p=p.slice(0,-1)),p.push({value:e,pixel:t,label:i})}}return p},[d,u,h,y,r,v]),q=t.useMemo(()=>{var e,t;if(!d||!u)return[];const n=null==h?void 0:h.find(e=>"left"===e.orient),o=(null==n?void 0:n.tickFormat)||m||Kn,i=Math.max(2,Math.floor(s/30)),r=null!==(e=null==n?void 0:n.ticks)&&void 0!==e?e:5;let a=Qn((null!==(t=null==n?void 0:n.tickValues)&&void 0!==t?t:Wn(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22);if(a.length>1&&(a=a.filter((e,t)=>0===t||e.label+""!=a[t-1].label+"")),(null==n?void 0:n.includeMax)&&a.length>0&&"exact"!==v&&!(null==n?void 0:n.tickValues)){const e=u.y.domain()[1],t=u.y(e),n=a[a.length-1].pixel;if(Math.abs(t-n)>1){const i=o(e);22>Math.abs(t-n)&&a.length>1&&(a=a.slice(0,-1)),a.push({value:e,pixel:t,label:i})}}return a},[d,u,h,m,s,v]),V=t.useMemo(()=>{var e,t;if(!d||!u)return[];const n=null==h?void 0:h.find(e=>"right"===e.orient);if(!n)return[];const o=n.tickFormat||m||Kn,i=Math.max(2,Math.floor(s/30)),r=null!==(e=n.ticks)&&void 0!==e?e:5;return Qn((null!==(t=n.tickValues)&&void 0!==t?t:Wn(u.y,"exact"===v?Math.max(2,r):Math.min(r,i),v)).map(e=>({value:e,pixel:u.y(e),label:o(e)})),22)},[d,u,h,m,s,v]),X=t.useRef(new Map),U=t.useRef(null!==(o=null==T?void 0:T.length)&&void 0!==o?o:0),K=null!==(i=null==T?void 0:T.length)&&void 0!==i?i:0;U.current!==K&&(U.current=K,X.current=new Map);const Q=t.useMemo(()=>{if(!T||0===T.length)return null;const e=dn(),t={scales:u?{x:u.x,y:u.y,time:u.x,value:u.y}:null,timeAxis:"x",xAccessor:$,yAccessor:D,width:r,height:s,data:B,frameType:"xy",pointNodes:I,curve:E,stickyPositionCache:X.current};return un(N?Tn(Object.assign({annotations:T,context:t},"object"==typeof N?N:{})):T,e,R,t)},[T,N,R,r,s,$,D,B,u,I,E]),Z=function(e){var n;const o=t.useSyncExternalStore(e?En:Hn,e?In:zn,e?In:zn);return e&&null!==(n=o.positions.get(e))&&void 0!==n?n:null}(z);return t.useEffect(()=>{if(!(null==Z?void 0:Z.locked)||!z)return;const e=e=>{"Escape"===e.key&&Bn(z)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[null==Z?void 0:Z.locked,z]),d||x||w||M||P||Q&&Q.length>0||b||G||Z?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&&(!F||H)&&(()=>{var t,n;const o=Vn(null===(t=null==h?void 0:h.find(e=>"bottom"===e.orient))||void 0===t?void 0:t.gridStyle),i=Vn(null===(n=null==h?void 0:h.find(e=>"left"===e.orient))||void 0===n?void 0:n.gridStyle);return e.jsxs("g",{className:"stream-grid",children:[Y.map((t,n)=>e.jsx("line",{x1:t.pixel,y1:0,x2:t.pixel,y2:s,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:o},"xgrid-"+n)),q.map((t,n)=>e.jsx("line",{x1:0,y1:t.pixel,x2:r,y2:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1,strokeDasharray:i},"ygrid-"+n))]})})(),d&&u&&(()=>{const t=null==h?void 0:h.find(e=>"left"===e.orient),n=null==h?void 0:h.find(e=>"bottom"===e.orient),o=!t||!1!==t.baseline,i=!n||!1!==n.baseline,a=(null==t?void 0:t.jaggedBase)||!1,l=(null==n?void 0:n.jaggedBase)||!1,u=null==n?void 0:n.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==n?void 0:n.autoRotate)&&Y.length>1&&(()=>{const e=r/Math.max(Y.length-1,1);return Y.reduce((e,t)=>Math.max(e,"string"==typeof t.label?6.5*t.label.length:60),0)+8>e})(),x={fontSize:"var(--semiotic-tick-font-size, 12px)"},w={fontSize:"calc(var(--semiotic-tick-font-size, 12px) + 1px)"},k={fontSize:"var(--semiotic-axis-label-font-size, 12px)"},A=null==n?void 0:n.tickAnchor,j=null==t?void 0:t.tickAnchor,S=qn(Y),C=qn(q);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:[(!F||H)&&i&&!l&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:y,strokeWidth:1}),(!F||H)&&l&&e.jsx("path",{d:Xn("bottom",r,s),fill:"none",stroke:y,strokeWidth:1}),Y.map((t,n)=>{const o=!!u&&("function"==typeof u?u(t.value,n):Ue(t.value,n>0?Y[n-1].value:void 0));return e.jsxs("g",{transform:`translate(${t.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:y,strokeWidth:1}),"string"==typeof t.label||"number"==typeof t.label?e.jsx("text",{y:b?10:18,textAnchor:b?"end":Gn(A,t.pixel===S.min,t.pixel===S.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w: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-"+n)}),f&&e.jsx("text",{x:r/2,y:s+40,textAnchor:"middle",fill:v,className:"semiotic-axis-label",style:Object.assign({userSelect:"none"},k),children:f})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[(!F||H)&&o&&!a&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:y,strokeWidth:1}),(!F||H)&&a&&e.jsx("path",{d:Xn("left",r,s),fill:"none",stroke:y,strokeWidth:1}),q.map((t,n)=>{const o=!!d&&("function"==typeof d?d(t.value,n):Ue(t.value,n>0?q[n-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:Yn(j,t.pixel===C.min,t.pixel===C.max),fontWeight:o?600:400,fill:m,className:"semiotic-axis-tick",style:Object.assign({userSelect:"none"},o?w: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-"+n)}),(()=>{const n=(null==t?void 0:t.label)||g;return n?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"},k),children:n}):null})()]}),(()=>{const t=null==h?void 0:h.find(e=>"right"===e.orient);if(!t||0===V.length)return null;const n=!1!==t.baseline,o=t.landmarkTicks,i=t.label||p,a=t.tickAnchor,l=qn(V);return e.jsxs("g",{className:"semiotic-axis semiotic-axis-right","data-orient":"right",children:[n&&e.jsx("line",{x1:r,y1:0,x2:r,y2:s,stroke:y,strokeWidth:1}),V.map((t,n)=>{const i=!!o&&("function"==typeof o?o(t.value,n):Ue(t.value,n>0?V[n-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:Yn(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?w: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-"+n)}),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"},k),children:i})]})})()]})})(),Q,P&&u&&_&&L&&e.jsxs(e.Fragment,{children:[P.top&&e.jsx("g",{transform:"translate(0, 0)",children:e.jsx(Ht,{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(Ht,{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(Ht,{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(Ht,{orient:"right",config:Ft(P.right),values:L,scale:u.y,size:c.right,length:s})})]}),M,Z&&Z.sourceId!==W&&(null==u?void 0:u.x)&&(()=>{const t=u.x(Z.xValue);if(null==t||0>t||t>r)return null;const n=Z.locked;return e.jsx("line",{x1:t,y1:0,x2:t,y2:s,stroke:n?"white":"var(--semiotic-text-secondary, rgba(0,0,0,0.25))",strokeWidth:n?1.5:1,strokeDasharray:n?"6,3":"4,4",pointerEvents:"none"})})(),G]}),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}),Et({legend:w,totalWidth:a,totalHeight:l,margin:c,legendPosition:C,title:x,legendLayout:O,legendHoverBehavior:k,legendClickBehavior:A,legendHighlightedCategory:j,legendIsolatedCategories:S})]}):null}function Jn(e){var t,n,o,i;return(null!==(t=e.tl)&&void 0!==t?t:0)>0||(null!==(n=e.tr)&&void 0!==n?n:0)>0||(null!==(o=e.br)&&void 0!==o?o:0)>0||(null!==(i=e.bl)&&void 0!==i?i:0)>0}function eo(e){const t=e.cornerRadii;if(!t)return{tl:0,tr:0,br:0,bl:0};const n=Math.min(e.w,e.h)/2,o=e=>Math.max(0,Math.min(null!=e?e:0,n));return{tl:o(t.tl),tr:o(t.tr),br:o(t.br),bl:o(t.bl)}}const to=(e,t)=>({x:e*Math.cos(t),y:e*Math.sin(t)});function no(e){var t,n;const{innerRadius:o,outerRadius:i,startAngle:r,endAngle:s}=e,a=0>=o;if(0>=(null!==(t=e.cornerRadius)&&void 0!==t?t:0)||!e.roundStart&&!e.roundEnd){if(a){const e=to(i,r),t=to(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=to(i,r),t=to(i,s),n=to(o,s),l=to(o,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${n.x},${n.y} A${o},${o} 0 ${c} 0 ${l.x},${l.y} Z`}const l=Math.max(0,Math.min(null!==(n=e.cornerRadius)&&void 0!==n?n:0,(i-o)/2));if(0===l)return no(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,o+l))),d=s-r,h=e.roundStart&&e.roundEnd?d/2:d,f=!!e.roundStart&&h>c,g=!!e.roundEnd&&h>c;if(!f&&!g)return no(Object.assign(Object.assign({},e),{cornerRadius:0,roundStart:!1,roundEnd:!1}));const p=r+(f?c:0),y=s-(g?c:0),m=r+(f?u:0),v=s-(g?u:0),b=to(i,p),x=to(i,y),w=(i-l)*Math.cos(c),k=to(w,r),A=to(w,s),j=a?null:to(o,v),S=a?null:to(o,m),C=a?0:(o+l)*Math.cos(u),O=a?null:to(C,r),M=a?null:to(C,s),P=y-p>Math.PI?1:0,_=a?0:v-m>Math.PI?1:0;let L="";if(f)L+=`M${k.x},${k.y}`,L+=` A${l},${l} 0 0 1 ${b.x},${b.y}`;else{const e=to(i,r);L+=`M${e.x},${e.y}`}if(g)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=to(i,s);L+=` A${i},${i} 0 ${P} 1 ${e.x},${e.y}`}if(a)L+=" L0,0";else{if(g)L+=` L${M.x},${M.y}`,L+=` A${l},${l} 0 0 1 ${j.x},${j.y}`;else{const e=to(o,s);L+=` L${e.x},${e.y}`}if(f)L+=` A${o},${o} 0 ${_} 0 ${S.x},${S.y}`,L+=` A${l},${l} 0 0 1 ${O.x},${O.y}`;else{const e=to(o,r);L+=` A${o},${o} 0 ${_} 0 ${e.x},${e.y}`}}return L+=" Z",L}function oo(e){const t=no({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,cornerRadius:e.cornerRadius,roundStart:e.roundStart,roundEnd:e.roundEnd}),n=[],o=e.colors;if(o.length>0){const t=(e.endAngle-e.startAngle)/o.length;for(let i=0;o.length>i;i++)n.push({d:no({innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle+i*t,endAngle:e.endAngle}),color:o[i]})}return{clipPath:t,slices:n}}const io={innerRadius:0,outerRadius:0,startAngle:0,endAngle:0};function ro(e,t="#4e79a7"){return e&&"string"==typeof e?e:t}function so(e){const t=e.replace(/[^A-Za-z0-9_-]/g,"_");return!t||/^\d/.test(t)?"s_"+t:t}const ao="undefined"==typeof window||"undefined"==typeof document,lo="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function co(){const[e,n]=t.useState(!1);return lo(()=>{n(!0)},[]),e}const uo=()=>()=>{},ho=()=>!1,fo=()=>!0;function go(){const e=t.useSyncExternalStore(uo,ho,fo);return t.useRef(e).current}function po(e){const{hydrated:n,wasHydratingFromSSR:o,storeRef:i,dirtyRef:r,renderFnRef:s,cleanup:a}=e;lo(()=>{var e,t;n&&o&&(null===(t=null===(e=i.current)||void 0===e?void 0:e.cancelIntroAnimation)||void 0===t||t.call(e)),r.current=!0,s.current()},[n,o]);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 yo(e){const n=t.useRef(e);return function(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return vo(e,t);if(!bo(e)||!bo(t))return!1;const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;const n=e[o],i=t[o];if(!Object.is(n,i))if(Array.isArray(n)&&Array.isArray(i)){if(!vo(n,i))return!1}else{if(!bo(n)||!bo(i))return!1;if(!mo(n,i))return!1}}return!0}(n.current,e)||(n.current=e),n.current}function mo(e,t){const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n){if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Object.is(e[o],t[o]))return!1}return!0}function vo(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function bo(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 xo=p.createContext(null);function wo({children:t}){const[n,o]=p.useState(!1),i=p.useMemo(()=>({visible:n,setVisible:o}),[n]);return e.jsx(xo.Provider,{value:i,children:t})}function ko(){return p.useContext(xo)}const Ao={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0};function jo(e,t){if(!e||0===e.length)return t+", empty";const n={};for(const t of e){if(null===(null==t?void 0:t.datum))continue;const e=t.type+"";n[e]=(n[e]||0)+1}if(0===Object.keys(n).length)return t+", empty";const o=[],i={point:"points",line:"lines",area:"areas",rect:"bars",heatcell:"cells",circle:"nodes",candlestick:"candlesticks",wedge:"wedges",arc:"arcs",geoarea:"regions"},r=["point","line","area","rect","heatcell","circle","candlestick","wedge","arc","geoarea"],s=Object.keys(n).sort((e,t)=>{const n=r.indexOf(e),o=r.indexOf(t);return(-1===n?999:n)-(-1===o?999:o)});for(const e of s)o.push(`${n[e]} ${i[e]||e}`);return`${t}, ${o.join(", ")}`}function So(e,t,n){const o=[];return e>0&&o.push(e+" nodes"),t>0&&o.push(t+" edges"),0===o.length?n+", empty":`${n}, ${o.join(", ")}`}const Co=e=>{if(null==e)return"";const t=Math.round(100*e)/100;return Number.isNaN(t)?"":t+""};function Oo(e){const t={};if(null==e||"object"!=typeof e)return t;for(const[n,o]of Object.entries(e))n.startsWith("_")||null!=o&&""!==o&&("number"==typeof o?Number.isFinite(o)&&(t[n]=o):"string"==typeof o?t[n]=o:"boolean"==typeof o?t[n]=o+"":o instanceof Date&&(t[n]=o.toISOString().slice(0,10)));return t}const Mo="semiotic-accessible-data-table",Po=Mo+" semiotic-accessible-data-table-hidden",_o=Mo+" semiotic-accessible-data-table-visible",Lo=_o+" semiotic-accessible-data-table-network",To={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"},No={marginBottom:8,paddingRight:28,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #666))",fontSize:12,letterSpacing:"0.01em"},Ro={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)"},$o={width:"100%",borderCollapse:"collapse",fontSize:12,marginTop:4,fontVariantNumeric:"tabular-nums"},Do={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))"},Bo={padding:"4px 10px",borderBottom:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))"},Io={textAlign:"left",fontSize:11,color:"var(--semiotic-data-table-muted-text, var(--semiotic-text-secondary, #999))",marginBottom:4,fontStyle:"italic"},Eo={marginTop:8,padding:"4px 10px",fontSize:12,cursor:"pointer",border:"1px solid var(--semiotic-data-table-border, var(--semiotic-border, #e0e0e0))",borderRadius:"var(--semiotic-border-radius, 4px)",background:"var(--semiotic-data-table-bg, var(--semiotic-surface, var(--semiotic-bg, #fff)))",color:"var(--semiotic-data-table-text, var(--semiotic-text, #333))",fontFamily:"inherit"};function Fo({scene:t,chartType:n,tableId:o,chartTitle:i}){var r;const[s,a]=p.useState(!1),[l,c]=p.useState(5),u=ko(),d=null!==(r=null==u?void 0:u.visible)&&void 0!==r&&r,h=s||d,f=p.useRef(null),g=i?"Data summary for "+i:o?`Data summary for ${n} ${o}`:"Data summary for "+n;p.useEffect(()=>{h||c(5)},[h]);const y=p.useCallback(e=>{e.target===e.currentTarget&&(s||d||a(!0))},[s,d]),m=p.useCallback(e=>{var t;d||(null===(t=f.current)||void 0===t?void 0:t.contains(e.relatedTarget))||a(!1)},[d]);if(!t||0===t.length)return o?e.jsx("span",{id:o,tabIndex:-1,style:Ao}):null;if(!h)return e.jsx("div",{id:o,className:Po,tabIndex:-1,onFocus:y,style:Ao,role:"region","aria-label":g,children:e.jsxs("button",{type:"button",onClick:()=>a(!0),children:["View data summary (",t.length," elements)"]})});const v=function(e){var t,n,o,i,r,s,a,l,c,u,d,h,f,g,p,y,m;const v=[];if(!Array.isArray(e))return v;const b=e.some(e=>e&&("line"===e.type||"area"===e.type));for(const x of e)if(x&&"object"==typeof x&&null!==x.datum)try{switch(x.type){case"point":if(b)break;v.push({label:"Point",values:Oo(x.datum)});break;case"line":case"area":{const e=Array.isArray(x.datum)?x.datum:[],t="line"===x.type?"Line point":"Area point";for(const n of e)v.push({label:t,values:Oo(n)});break}case"rect":{const e=null!=x.datum&&"object"==typeof x.datum?x.datum:{},r=null!==(n=null!==(t=e.category)&&void 0!==t?t:x.group)&&void 0!==n?n:"",s=null!==(i=null!==(o=e.value)&&void 0!==o?o:e.__aggregateValue)&&void 0!==i?i:e.total;v.push({label:"Bar",values:{category:r,value:null!=s?s:""}});break}case"heatcell":{const e=Oo(x.datum);null==e.value&&"number"==typeof x.value&&Number.isFinite(x.value)&&(e.value=x.value),v.push({label:"Cell",values:e});break}case"wedge":v.push({label:"Wedge",values:{category:null!==(l=null!==(s=null===(r=x.datum)||void 0===r?void 0:r.category)&&void 0!==s?s:null===(a=x.datum)||void 0===a?void 0:a.label)&&void 0!==l?l:"",value:null!==(u=null===(c=x.datum)||void 0===c?void 0:c.value)&&void 0!==u?u:""}});break;case"circle":v.push({label:"Node",values:Oo(x.datum)});break;case"arc":v.push({label:"Arc",values:Oo(x.datum)});break;case"candlestick":v.push({label:"Candlestick",values:Oo(x.datum)});break;case"geoarea":v.push({label:"Region",values:{name:null!==(p=null!==(f=null===(h=null===(d=x.datum)||void 0===d?void 0:d.properties)||void 0===h?void 0:h.name)&&void 0!==f?f:null===(g=x.datum)||void 0===g?void 0:g.name)&&void 0!==p?p:"",value:null!==(m=null===(y=x.datum)||void 0===y?void 0:y.value)&&void 0!==m?m:""}})}}catch(e){}return v}(t),b=function(e){if(!e||0===e.length)return[];const t=new Set;for(const n of e)if(n&&n.values)for(const e of Object.keys(n.values))t.add(e);const n=[];for(const o of t){const t=[],i=new Set;for(const n of e){if(!n||!n.values)continue;const e=n.values[o];null!=e&&""!==e&&("number"==typeof e&&!Number.isNaN(e)&&Number.isFinite(e)?t.push(e):"number"==typeof e||"object"!=typeof e&&"function"!=typeof e&&i.add(e+""))}if(t.length>0){let e=t[0],i=t[0],r=0;for(const n of t)e>n&&(e=n),n>i&&(i=n),r+=n;n.push({name:o,count:t.length,numeric:!0,min:e,max:i,mean:r/t.length})}else if(i.size>0){const e=Array.from(i);n.push({name:o,count:e.length,numeric:!1,uniqueValues:e.slice(0,5)})}}return n}(v),x=function(e,t){const n=[e+" data points."];for(const e of t)if(e.numeric)n.push(`${e.name}: ${Co(e.min)} to ${Co(e.max)}, mean ${Co(e.mean)}.`);else{const t=e.uniqueValues,o=t.length>3?`${t.slice(0,3).join(", ")}… (${e.count} unique)`:t.join(", ");n.push(`${e.name}: ${o}.`)}return n.join(" ")}(v.length,b),w=Math.min(l,v.length),k=v.slice(0,w),A=v.length-w,j=new Set;for(const e of k)for(const t of Object.keys(e.values))j.add(t);const S=Array.from(j);return e.jsxs("div",{ref:f,id:o,className:_o,tabIndex:-1,onBlur:m,style:To,role:"region","aria-label":g,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{d&&u&&u.setVisible(!1),a(!1)},"aria-label":"Close data summary",style:Ro,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:No,children:x}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Sample data for "+n,style:$o,children:[e.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:Io,children:A>0?`First ${w} of ${v.length} data points`:`All ${v.length} data points`}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Do,children:"type"}),S.map(t=>e.jsx("th",{style:Do,children:t},t))]})}),e.jsx("tbody",{children:k.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:Bo,children:t.label}),S.map(n=>{return e.jsx("td",{style:Bo,children:(o=t.values[n],null==o||""===o?"—":"number"==typeof o?Number.isNaN(o)?"—":Co(o):"boolean"==typeof o?o?"true":"false":"object"==typeof o?"—":o+"")},n);var o})]},n))})]}),A>0&&e.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>c(e=>e+25),style:Eo,children:["Show ",Math.min(25,A)," more"," ",1===A?"row":"rows"," (",A," remaining)"]})]})}function Ho({nodes:t,edges:n,chartType:o,tableId:i,chartTitle:r}){var s,a,l,c,u,d,h,f,g,y,m,v,b,x;const[w,k]=p.useState(!1),[A,j]=p.useState(5),S=ko(),C=null!==(s=null==S?void 0:S.visible)&&void 0!==s&&s,O=w||C,M=r?"Data summary for "+r:i?`Data summary for ${o} ${i}`:"Data summary for "+o,P=p.useRef(null);p.useEffect(()=>{O||j(5)},[O]);const _=p.useCallback(e=>{e.target===e.currentTarget&&(w||C||k(!0))},[w,C]),L=p.useCallback(e=>{var t;C||(null===(t=P.current)||void 0===t?void 0:t.contains(e.relatedTarget))||k(!1)},[C]);if(!t||0===t.length)return i?e.jsx("span",{id:i,tabIndex:-1,style:Ao}):null;if(!O)return e.jsx("div",{id:i,className:Po,tabIndex:-1,onFocus:_,style:Ao,role:"region","aria-label":M,children:e.jsxs("button",{type:"button",onClick:()=>k(!0),children:["View data summary (",t.length," nodes, ",n.length," edges)"]})});const T=Array.isArray(t)?t:[],N=Array.isArray(n)?n:[],R=new Map,$=new Map,D=new Map,B=new Map;for(const e of N){if(!e||"object"!=typeof e)continue;const t=null!==(a=e.datum)&&void 0!==a?a:e,n="object"==typeof t.source?null===(l=t.source)||void 0===l?void 0:l.id:t.source,o="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!=n&&""!==n){const e=n+"";$.set(e,(null!==(u=$.get(e))&&void 0!==u?u:0)+1),B.set(e,(null!==(d=B.get(e))&&void 0!==d?d:0)+i)}if(null!=o&&""!==o){const e=o+"";R.set(e,(null!==(h=R.get(e))&&void 0!==h?h:0)+1),D.set(e,(null!==(f=D.get(e))&&void 0!==f?f:0)+i)}}const I=[];for(let e=0;T.length>e;e++){const t=T[e];if(!t||"object"!=typeof t)continue;const n=null!==(y=null===(g=t.datum)||void 0===g?void 0:g.id)&&void 0!==y?y:t.id,o=null!=n?n+"":"node-"+e,i=null!==(m=R.get(o))&&void 0!==m?m:0,r=null!==(v=$.get(o))&&void 0!==v?v:0,s=null!==(b=D.get(o))&&void 0!==b?b:0,a=null!==(x=B.get(o))&&void 0!==x?x:0;I.push({id:o,degree:i+r,inDeg:i,outDeg:r,wDegree:s+a,wInDeg:s,wOutDeg:a})}I.sort((e,t)=>t.degree-e.degree);let E=0,F=0;if(I.length>0){let e=0;for(const t of I)e+=t.degree,t.degree>F&&(F=t.degree);E=e/I.length}const H=N.some(e=>{var t;const n=null!==(t=null==e?void 0:e.datum)&&void 0!==t?t:e;return"number"==typeof(null==n?void 0:n.value)&&Number.isFinite(n.value)}),z=[`${I.length} nodes, ${N.length} edges.`];I.length>0&&z.push(`Mean degree: ${Co(E)}, max degree: ${F}.`);const W=Math.min(A,I.length),G=I.slice(0,W),Y=I.length-W;return e.jsxs("div",{ref:P,id:i,className:Lo,tabIndex:-1,onBlur:L,style:To,role:"region","aria-label":M,children:[e.jsx("button",{type:"button",className:"semiotic-accessible-data-table-close",onClick:()=>{C&&S&&S.setVisible(!1),k(!1)},"aria-label":"Close data summary",style:Ro,children:"×"}),e.jsx("div",{className:"semiotic-accessible-data-table-summary",role:"note",style:No,children:z.join(" ")}),e.jsxs("table",{className:"semiotic-accessible-data-table-table",role:"table","aria-label":"Node degree summary for "+o,style:$o,children:[e.jsx("caption",{className:"semiotic-accessible-data-table-caption",style:Io,children:Y>0?`Top ${W} of ${I.length} nodes by degree`:`All ${I.length} nodes by degree`}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:Do,children:"id"}),e.jsx("th",{style:Do,children:"degree"}),e.jsx("th",{style:Do,children:"in"}),e.jsx("th",{style:Do,children:"out"}),H&&e.jsx("th",{style:Do,children:"w. degree"}),H&&e.jsx("th",{style:Do,children:"w. in"}),H&&e.jsx("th",{style:Do,children:"w. out"})]})}),e.jsx("tbody",{children:G.map((t,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:Bo,children:t.id}),e.jsx("td",{style:Bo,children:t.degree}),e.jsx("td",{style:Bo,children:t.inDeg}),e.jsx("td",{style:Bo,children:t.outDeg}),H&&e.jsx("td",{style:Bo,children:Co(t.wDegree)}),H&&e.jsx("td",{style:Bo,children:Co(t.wInDeg)}),H&&e.jsx("td",{style:Bo,children:Co(t.wOutDeg)})]},n))})]}),Y>0&&e.jsxs("button",{type:"button",className:"semiotic-accessible-data-table-show-more",onClick:()=>j(e=>e+25),style:Eo,children:["Show ",Math.min(25,Y)," more"," ",1===Y?"node":"nodes"," (",Y," remaining)"]})]})}function zo({summary:t}){return t?e.jsx("div",{role:"note",style:Ao,children:t}):null}function Wo({tableId:t}){return e.jsx("a",{href:"#"+t,style:Ao,onClick:e=>{e.preventDefault();const n=document.getElementById(t);n&&requestAnimationFrame(()=>n.focus())},onFocus:e=>{Object.assign(e.currentTarget.style,{position:"absolute",width:"auto",height:"auto",overflow:"visible",clip:"auto",whiteSpace:"normal",padding:"4px 8px",background:"var(--semiotic-bg, #fff)",color:"var(--semiotic-text, #000)",border:"2px solid var(--semiotic-focus, #005fcc)",borderRadius:"4px",zIndex:"10",fontSize:"12px",top:"4px",left:"4px"})},onBlur:e=>{const t=e.currentTarget;t.removeAttribute("style"),Object.assign(t.style,Ao)},children:"Skip to data table"})}function Go({hoverPoint:t}){let n="";if(t){const e=t.data||t;n="object"==typeof e?"Data point: "+Object.entries(e).filter(([,e])=>"object"!=typeof e&&"function"!=typeof e).map(([e,t])=>`${e}: ${t}`).join(", "):"Data point: "+e}return e.jsx("div",{"aria-live":"polite","aria-atomic":"true",style:Ao,children:n})}const Yo="var(--semiotic-focus, #005fcc)";function qo({active:t,hoverPoint:n,margin:o,size:i,shape:r="circle",width:s,height:a}){if(!t||!n)return null;const l=n.x+o.left,c=n.y+o.top;let u;if("rect"===r&&null!=s&&null!=a){const t=Math.max(s,4),n=Math.max(a,4);u=e.jsx("rect",{x:l-t/2-3,y:c-n/2-3,width:t+6,height:n+6,rx:3,fill:"none",stroke:Yo,strokeWidth:2,strokeDasharray:"4,2"})}else u=e.jsx("circle","wedge"===r?{cx:l,cy:c,r:12,fill:"none",stroke:Yo,strokeWidth:2.5,strokeDasharray:"6,3"}:{cx:l,cy:c,r:8,fill:"none",stroke:Yo,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 Vo(e){return Array.isArray(e)?e[0]:e}function Xo(e,t,n,o){return Object.assign({data:Vo(e),x:t,y:n,__semioticHoverData:!0},o)}const Uo={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 Ko(e,t){return"function"==typeof t?t(e):e[t]}function Qo(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 Zo(t={}){const{fields:n,title:o,format:i,style:r={},className:s=""}=t;return t=>{if(!t||"object"!=typeof t)return null;let a;const l=[];if(o){const e=Ko(t,o);a=Qo(e,i)}if(n&&n.length>0)n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=Ko(t,o);l.push({label:n,value:Qo(s,r)})});else if(!o){const e=["value","y","name","id","label"];for(const n of e)if(void 0!==t[n]){a=Qo(t[n],i);break}if(!a){const e=Object.keys(t).filter(e=>!e.startsWith("_"));e.length>0&&(a=Qo(t[e[0]],i))}}const c=Object.assign(Object.assign({},Uo),r);return e.jsxs("div",{className:("semiotic-tooltip "+s).trim(),style:c,children:[a&&e.jsx("div",{style:{fontWeight:l.length>0?"bold":"normal"},children:a}),l.map((t,n)=>e.jsxs("div",{style:{marginTop:0===n&&a?"4px":0},children:[t.label&&e.jsxs("span",{children:[t.label,": "]}),t.value]},n))]})}}function Jo(){return t=>{var n,o,i,r,s,a,l;const c=t.allSeries;if(!c||0===c.length){const r=null!==(o=null===(n=t.data)||void 0===n?void 0:n.value)&&void 0!==o?o:null===(i=t.data)||void 0===i?void 0:i.y;return e.jsx("div",{className:"semiotic-tooltip",style:Uo,children:e.jsx("div",{children:Qo(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:Uo,children:[null!=u&&e.jsx("div",{style:{fontWeight:600,marginBottom:4,fontSize:"0.9em",borderBottom:"1px solid var(--semiotic-border, #eee)",paddingBottom:4},children:Qo(u)}),c.map((t,n)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"1px 0"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t.color,flexShrink:0}}),e.jsx("span",{style:{flex:1,fontSize:"0.85em"},children:t.group}),e.jsx("span",{style:{fontWeight:500,fontSize:"0.85em"},children:Qo(t.value)})]},n))]})}}function ei(t){if(!0!==t){if("function"==typeof t){const n=t;return t=>{var o;const i=Vo(!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!==(o=t.data)&&void 0!==o?o:{}:t),r=n(i);return null==r?null:e.jsx("div",{className:"semiotic-tooltip",style:Uo,children:r})}}return!1!==t&&void 0!==t&&("object"==typeof t&&null!==t&&("fields"in t||"title"in t)?Zo(t):Zo())}}function ti({x:t,y:n,containerWidth:o,containerHeight:i,margin:r,children:s,className:a="stream-frame-tooltip",zIndex:l=1}){const c=Number.isFinite(t)&&Number.isFinite(n),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,o,i]);let f;f=d?`translate(${d.width+12>o-t?"calc(-100% - 12px)":"12px"}, ${d.height+12>i-n?"calc(-100% - 4px)":"4px"})`:`translate(${t>.7*o?"calc(-100% - 12px)":"12px"}, ${.3*i>n?"4px":"calc(-100% - 4px)"})`;const g=function(e){if(!p.isValidElement(e))return!1;const t=e.type;if("string"!=typeof t&&t&&!0===t.ownsChrome)return!0;const n=e.props;if("string"==typeof n.className&&n.className.trim().length>0)return!0;const o=n.style;if(o&&"object"==typeof o){if(null!=o.background&&""!==o.background)return!0;if(null!=o.backgroundColor&&""!==o.backgroundColor)return!0}return!1}(s),y=g?null:Uo;return c?e.jsx("div",{ref:u,className:g?a:(a+" semiotic-tooltip").trim(),style:Object.assign(Object.assign({},y||{}),{position:"absolute",left:r.left+t,top:r.top+n,transform:f,pointerEvents:"none",zIndex:l,width:"max-content"}),children:s}):null}function ni(e,t){if("function"==typeof e.addEventListener)return e.addEventListener("change",t),()=>e.removeEventListener("change",t);const n=e;return n.addListener(t),()=>n.removeListener(t)}function oi(){const[e,n]=t.useState(()=>!("undefined"==typeof window||!window.matchMedia)&&window.matchMedia("(prefers-reduced-motion: reduce)").matches);return t.useEffect(()=>{if("undefined"==typeof window||!window.matchMedia)return;const e=window.matchMedia("(prefers-reduced-motion: reduce)");return n(e.matches),ni(e,e=>n(e.matches))},[]),e}function ii(e,n,o){const i=t.useRef(null),[r,s]=t.useState(null);return t.useEffect(()=>{if(!n&&!o)return;const e=i.current;if(!e)return;const t=new ResizeObserver(e=>{for(const t of e){const{width:e,height:n}=t.contentRect;s(t=>t&&t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[n,o]),[i,[n&&r?r.w:e[0],o&&r?r.h:e[1]]]}const ri="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function si(e,t,n){return"function"==typeof e?e({size:t,margin:n}):e}function ai(e){const n=oi(),o=t.useRef(n);o.current=n;const[i,r]=ii(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=si(e.foregroundGraphics,r,s),u=si(e.backgroundGraphics,r,s),d=N(e=>e.theme),{transition:h,introEnabled:f}=function(e,t){var n,o;if(!1===e)return{transition:void 0,introEnabled:!1};const i="undefined"!=typeof window&&(null===(n=window.matchMedia)||void 0===n?void 0:n.call(window,"(prefers-reduced-motion: reduce)").matches);return{transition:e?!0===e?{duration:300}:{duration:null!==(o=e.duration)&&void 0!==o?o:300,easing:"linear"===e.easing?"linear":"ease-out"}:t,introEnabled:!(i||!e||!0!==e&&!1===e.intro)}}(e.animate,e.transitionProp),g="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(()=>{}),w=t.useRef(null),k=t.useRef(0),A=t.useCallback(()=>{k.current=0;const e=w.current;w.current=null,e&&b.current(e)},[]),j=t.useCallback(e=>{w.current={clientX:e.clientX,clientY:e.clientY},0===k.current&&(k.current=requestAnimationFrame(A))},[A]),S=t.useCallback(()=>{w.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0),x.current()},[]);t.useEffect(()=>()=>{w.current=null,0!==k.current&&(cancelAnimationFrame(k.current),k.current=0)},[]);const C=e.themeDirtyRef;return ri(()=>{C&&(et++,C.current=!0,v())},[d,v,C]),{reducedMotion:n,reducedMotionRef:o,responsiveRef:i,size:r,margin:s,adjustedWidth:a,adjustedHeight:l,resolvedForeground:c,resolvedBackground:u,currentTheme:d,transition:h,introEnabled:f,tableId:g,rafRef:y,renderFnRef:m,scheduleRender:v,hoverHandlerRef:b,hoverLeaveRef:x,onPointerMove:j,onPointerLeave:S}}function li(e,t,n,o){const i=e.getContext("2d");if(!i)return null;const r=t[0]*o,s=t[1]*o,a=t[0]+"px",l=t[1]+"px";return e.style.width!==a&&(e.style.width=a),e.style.height!==l&&(e.style.height=l),e.width===r&&e.height===s||(e.width=r,e.height=s),i.setTransform(o,0,0,o,0,0),i.translate(n.left,n.top),i}function ci(){return"undefined"!=typeof window&&window.devicePixelRatio||1}function ui(e,t,n){let o=n;for(const n of t)"lesser"===n.thresholdType?n.value>e&&(o=n.color):e>n.value&&(o=n.color);return o}function di(e,t,n,o,i,r){if(2>t.length)return;const s=[0];for(let e=1;t.length>e;e++){const n=t[e][0]-t[e-1][0],o=t[e][1]-t[e-1][1];s.push(s[e-1]+Math.sqrt(n*n+o*o))}const a=s[s.length-1];if(0===a)return;const l=Math.min(.2*a,40);e.strokeStyle=n,e.lineWidth=o,e.lineCap=r;for(let n=0;t.length-1>n;n++){const o=(s[n]+s[n+1])/2;let r=i;l>o&&(r*=o/l),l>a-o&&(r*=(a-o)/l),e.globalAlpha=Math.max(0,r),e.beginPath(),e.moveTo(t[n][0],t[n][1]),e.lineTo(t[n+1][0],t[n+1][1]),e.stroke()}}const hi=(e,t,n,o)=>{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,o.width*c,o.height),e.clip());const u=l.style.stroke||"#007bff",d=rt(e,u)||u,h=l.style.strokeWidth||2,f=l.colorThresholds,g=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;di(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=f&&f.length>0&&g&&g.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 w=null,k=null,A=null,j=null,S=!1;function C(t,n,o){e.beginPath(),e.strokeStyle=t,e.moveTo(n,o),S=!0}function O(){S&&(e.stroke(),S=!1)}for(let M=0;l.path.length>M;M++){const[P,_]=l.path[M],L=g[M],T=ui(L,f,d);if(null!==w&&null!==j&&null!==A){if(T===j)e.lineTo(P,_);else{const N=[];for(const R of f){const $=R.value;(A>$||$>L)&&($>A||L>$)||A===$||L===$||N.push({t:($-A)/(L-A)})}N.sort((e,t)=>e.t-t.t);for(const D of N){const B=w+(P-w)*D.t,I=k+(_-k)*D.t,E=ui(A+(L-A)*Math.min(D.t+1e-4,1),f,d);e.lineTo(B,I),O(),C(E,B,I)}e.lineTo(P,_)}w=P,k=_,A=L,j=T}else C(T,P,_),w=P,k=_,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[H,z]=l.path[0];e.moveTo(H,z);for(let W=1;l.path.length>W;W++)e.lineTo(l.path[W][0],l.path[W][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 V=1;l.path.length>V;V++)e.lineTo(l.path[V][0],l.path[V][1])}const G=l.path[0][0];e.lineTo(l.path[l.path.length-1][0],o.height),e.lineTo(G,o.height),e.closePath(),e.fill()}void 0!==c&&1>c&&e.restore(),e.globalAlpha=1,e.setLineDash([]),e.lineCap="butt"}};function fi(e){return!(!e._pulseIntensity||0>=e._pulseIntensity)}function gi(e,t,n=.3){fi(t)&&(e.globalAlpha=t._pulseIntensity*n,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fillRect(t.x,t.y,t.w,t.h))}function pi(e,t,n=.6){var o,i,r,s,a;if(!fi(t))return;const l=null!==(o=t._pulseGlowRadius)&&void 0!==o?o:4,c=t.r+l*t._pulseIntensity,u=null!==(r=null!==(i=t.cx)&&void 0!==i?i:t.x)&&void 0!==r?r:0,d=null!==(a=null!==(s=t.cy)&&void 0!==s?s:t.y)&&void 0!==a?a:0;e.beginPath(),e.arc(u,d,c,0,2*Math.PI),e.strokeStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.lineWidth=2*t._pulseIntensity,e.globalAlpha=t._pulseIntensity*n,e.stroke()}function yi(e,t,n,o=.35){fi(t)&&(e.globalAlpha=t._pulseIntensity*o,e.fillStyle=t._pulseColor||"rgba(255,255,255,0.6)",e.fill())}function mi(e,t){const n=at(t.curve);if(!n||2>t.topPath.length||2>t.bottomPath.length){e.beginPath(),e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1]);for(let n=t.bottomPath.length-1;n>=0;n--)e.lineTo(t.bottomPath[n][0],t.bottomPath[n][1]);e.closePath()}else{const o=s.area().x(e=>e[0]).y0((e,n)=>t.bottomPath[n][1]).y1(e=>e[1]).curve(n).context(e);e.beginPath(),o(t.topPath)}}const vi=(e,t,n,o)=>{var i,r,a;const l=t.filter(e=>"area"===e.type);for(const t of l){if(2>t.topPath.length)continue;let n=!1;t.clipRect&&(e.save(),e.beginPath(),e.rect(t.clipRect.x,t.clipRect.y,t.clipRect.width,t.clipRect.height),e.clip(),n=!0);const l=t._introClipFraction;void 0!==l&&1>l&&(e.save(),e.beginPath(),e.rect(0,0,o.width*l,o.height),e.clip());const c=lt(e,t.style.fill,"#4e79a7"),u=t._decayOpacities;if(u&&u.length===t.topPath.length){const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:.7;e.fillStyle=c;for(let o=0;t.topPath.length-1>o;o++)e.globalAlpha=.5*(u[o]+u[o+1])*n,e.beginPath(),e.moveTo(t.topPath[o][0],t.topPath[o][1]),e.lineTo(t.topPath[o+1][0],t.topPath[o+1][1]),e.lineTo(t.bottomPath[o+1][0],t.bottomPath[o+1][1]),e.lineTo(t.bottomPath[o][0],t.bottomPath[o][1]),e.closePath(),e.fill();if(t.style.stroke&&"none"!==t.style.stroke){e.strokeStyle=rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);for(let n=0;t.topPath.length-1>n;n++)e.globalAlpha=.5*(u[n]+u[n+1]),e.beginPath(),e.moveTo(t.topPath[n][0],t.topPath[n][1]),e.lineTo(t.topPath[n+1][0],t.topPath[n+1][1]),e.stroke()}e.globalAlpha=1;continue}const d=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(mi(e,t),t.fillGradient&&("colorStops"in t.fillGradient&&t.fillGradient.colorStops.length>=2||"topOpacity"in t.fillGradient)&&t.fillGradient){let n=1/0;for(const e of t.topPath)n>e[1]&&(n=e[1]);let o=-1/0;for(const e of t.bottomPath)e[1]>o&&(o=e[1]);const i=ct(e,t.fillGradient,"string"==typeof c?c:"#4e79a7",0,n,0,o);e.fillStyle=i||c,e.globalAlpha=d}else{const n=null!==(a=t.style.fillOpacity)&&void 0!==a?a:.7;e.globalAlpha=n*d,e.fillStyle=c}if(e.fill(),t._pulseIntensity&&t._pulseIntensity>0&&(mi(e,t),yi(e,t)),t.style.stroke&&"none"!==t.style.stroke){e.globalAlpha=d;const n=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=n||rt(e,t.style.stroke)||t.style.stroke,e.lineWidth=t.style.strokeWidth||2,e.setLineDash([]);const o=at(t.curve);if(e.beginPath(),o)s.line().x(e=>e[0]).y(e=>e[1]).curve(o).context(e)(t.topPath);else{e.moveTo(t.topPath[0][0],t.topPath[0][1]);for(let n=1;t.topPath.length>n;n++)e.lineTo(t.topPath[n][0],t.topPath[n][1])}e.stroke()}void 0!==l&&1>l&&e.restore(),n&&e.restore(),e.globalAlpha=1}},bi=(e,t,n,o)=>{var i;const r=t.filter(e=>"point"===e.type);if(0!==r.length){e.save();try{for(const t of r){e.beginPath(),e.arc(t.x,t.y,t.r,0,2*Math.PI);const n=null!==(i=t.style.opacity)&&void 0!==i?i:t.style.fillOpacity;null!=n&&(e.globalAlpha=n),e.fillStyle=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()),pi(e,t),e.globalAlpha=1}}finally{e.restore()}}};function xi(e,t){const{x:n,y:o,w:i,h:r}=t,{tl:s,tr:a,br:l,bl:c}=eo(t);e.beginPath(),e.moveTo(n+s,o),e.lineTo(n+i-a,o),a>0&&e.arcTo(n+i,o,n+i,o+a,a),e.lineTo(n+i,o+r-l),l>0&&e.arcTo(n+i,o+r,n+i-l,o+r,l),e.lineTo(n+c,o+r),c>0&&e.arcTo(n,o+r,n,o+r-c,c),e.lineTo(n,o+s),s>0&&e.arcTo(n,o,n+s,o,s),e.closePath()}function wi(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 ki=(e,t,n,o)=>{const i=t.filter(e=>"rect"===e.type);for(const t of i){if(null!=t.style.opacity&&(e.globalAlpha=t.style.opacity),t.style.icon)Ai(e,t);else if(t.cornerRadii&&Jn(t.cornerRadii)){const n=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),o=wi(t),i=t.fillGradient&&"string"==typeof n?ct(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=i||n,xi(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 n=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),o=wi(t),i=t.fillGradient&&"string"==typeof n?ct(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=i||n;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 n=lt(e,t.style.fill,rt(e,"var(--semiotic-primary, #007bff)")),o=wi(t),i=t.fillGradient&&"string"==typeof n?ct(e,t.fillGradient,n,o.x0,o.y0,o.x1,o.y1):null;e.fillStyle=i||n,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))}gi(e,t),e.globalAlpha=1}};function Ai(e,t){const n=t.style.icon,o=t.style.iconPadding||2,i=Math.min(t.w,t.h)-o;if(0>=i)return;const r=t.h>t.w;if(e.save(),e.beginPath(),e.rect(t.x,t.y,t.w,t.h),e.clip(),r){const r=i+o,s=t.x+(t.w-i)/2;for(let o=t.y+t.h-i;o>=t.y-i;o-=r)e.drawImage(n,s,o,i,i)}else{const r=i+o,s=t.y+(t.h-i)/2;for(let o=t.x;t.x+t.w>o;o+=r)e.drawImage(n,o,s,i,i)}e.restore()}function ji(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>128?"#000":"#fff"}function Si(e){return Number.isInteger(e)?e+"":100>Math.abs(e)?1>Math.abs(e)?e.toPrecision(3):e.toFixed(1):e.toFixed(0)}const Ci=(e,t,n,o)=>{const i=t.filter(e=>"heatcell"===e.type);e.save();try{for(const t of i){const n=t.style;if(null!=(null==n?void 0:n.opacity)&&(e.globalAlpha=n.opacity),e.fillStyle=t.fill,e.fillRect(t.x,t.y,t.w,t.h),e.strokeStyle=rt(e,"var(--semiotic-surface, #fff)"),e.lineWidth=1,e.strokeRect(t.x,t.y,t.w,t.h),gi(e,t),e.globalAlpha=1,t.showValues&&null!=t.value){if(20>t.w||20>t.h)continue;const n=t.valueFormat?t.valueFormat(t.value):Si(t.value),o=Math.max(10,Math.min(16,.3*Math.min(t.w,t.h))),i=t.x+t.w/2,r=t.y+t.h/2;e.fillStyle=ji(t.fill),e.font=o+"px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(n,i,r)}}}finally{e.restore()}},Oi=(e,t,n,o)=>{var i,r,s;for(const n of t){if("candlestick"!==n.type)continue;const t=n;e.save();const a=(null!==(i=t._decayOpacity)&&void 0!==i?i:1)*(null!==(s=null===(r=t.style)||void 0===r?void 0:r.opacity)&&void 0!==s?s:1);1!==a&&(e.globalAlpha=a);const l=rt(e,t.wickColor)||t.wickColor,c=60>o.height,u=c?Math.max(t.wickWidth,2):t.wickWidth,d=()=>{e.beginPath(),e.moveTo(t.x,t.highY),e.lineTo(t.x,t.lowY),e.strokeStyle=l,e.lineWidth=u,e.stroke()};if(c||d(),t.isRange){const n=Math.max(2,Math.min(t.bodyWidth/2,.12*o.height));e.fillStyle=l,e.beginPath(),e.arc(t.x,t.highY,n,0,2*Math.PI),e.fill(),e.beginPath(),e.arc(t.x,t.lowY,n,0,2*Math.PI),e.fill()}else if(t.bodyWidth>0){const n=Math.min(t.openY,t.closeY),o=Math.abs(t.openY-t.closeY),i=t.isUp?t.upColor:t.downColor,r=rt(e,i)||i;e.fillStyle=r,e.fillRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1)),e.strokeStyle=r,e.lineWidth=1,e.strokeRect(t.x-t.bodyWidth/2,n,t.bodyWidth,Math.max(o,1))}c&&d(),e.restore()}};function Mi(e,t){if(!t)return[];const n=new Set,o=[];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+"";n.has(r)||(n.add(r),o.push(r))}return o}function Pi(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0}function _i(e,t,n,o){return"string"==typeof e?{key:e,fn:null}:"function"==typeof e?{key:n,fn:e}:"string"==typeof t?{key:t,fn:null}:"function"==typeof t?{key:o,fn:t}:{key:void 0,fn:null}}function Li(e,t,n){return o=>{if(!o||!n||!e.fn&&!t.fn)return o;let i=!1;const r=o.map(n=>{const o=e.fn&&e.key&&!(e.key in n),r=t.fn&&t.key&&!(t.key in n);if(!o&&!r)return n;i=!0;const s=Object.assign({},n);return o&&(s[e.key]=e.fn(n)),r&&(s[t.key]=t.fn(n)),s});return i?r:o}}const Ti=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Ni(e){const t=e[1]-e[0],n=3156e7;return 864e5>t?e=>{const t=new Date(e);return`${(t.getUTCHours()+"").padStart(2,"0")}:${(t.getUTCMinutes()+"").padStart(2,"0")}`}:n>t?e=>{const t=new Date(e);return`${Ti[t.getUTCMonth()]} ${t.getUTCDate()}`}:5*n>t?e=>{const t=new Date(e);return`${Ti[t.getUTCMonth()]} ${t.getUTCFullYear()}`}:e=>new Date(e).getUTCFullYear()+""}const Ri={line:[vi,hi,bi],area:[vi,bi],stackedarea:[vi,bi],scatter:[bi],bubble:[bi],heatmap:[Ci],bar:[ki],swarm:[bi],waterfall:[(e,t,n,o)=>{var i;ki(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 o=r[t],i=r[t+1],s=o.datum,a=i.datum;if(null==(null==s?void 0:s.cumEnd)||null==(null==a?void 0:a.baseline))continue;const l=n.y(s.cumEnd),c=o.x+o.w,u=i.x;e.beginPath(),e.moveTo(c,l),e.lineTo(u,l),e.stroke()}e.restore()}}],candlestick:[Oi],mixed:[vi,hi,bi],custom:[vi,ki,Ci,hi,bi,Oi]},$i={top:20,right:20,bottom:30,left:40},Di={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 Bi(e,t){const n=e.trim();if(/^#[0-9a-f]{3}$/i.test(n)){const e=n[1],o=n[2],i=n[3];return`#${e}${e}${o}${o}${i}${i}${t}`}if(/^#[0-9a-f]{6}$/i.test(n))return`${n}${t}`;const o=n.match(/^rgb\s*\(\s*([^)]+?)\s*\)$/i);return o?`rgba(${o[1]}, ${(parseInt(t,16)/255).toFixed(3)})`:n}const 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 Ei({hover:t}){var n,o,i;const r=e=>null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+"",s=null!==(n=t.data)&&void 0!==n?n:{},a=null!==(o=s.y)&&void 0!==o?o: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)})]})}Ei.ownsChrome=!0;const Fi=t.forwardRef(function(n,o){var i,r,s,a,l,c,u,d,h,f,g,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:N,normalize:R,baseline:$,stackOrder:D,binSize:B,valueAccessor:I,arrowOfTime:E="right",windowMode:F="sliding",windowSize:H=200,timeAccessor:z,xExtent:W,yExtent:G,extentPadding:Y=.1,scalePadding:q,sizeRange:V,size:X=[500,300],responsiveWidth:U,responsiveHeight:K,margin:Q,className:Z,background:J,lineStyle:ee,pointStyle:te,areaStyle:ne,barStyle:oe,waterfallStyle:ie,swarmStyle:re,barColors:se,colorScheme:ae,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:he,lineGradient:fe,areaGroups:ge,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,showAxes:xe=!0,axes:we,xLabel:ke,yLabel:Ae,yLabelRight:je,xFormat:Se,yFormat:Ce,axisExtent:Oe,tickFormatTime:Me,tickFormatValue:Pe,hoverAnnotation:_e,tooltipContent:Le,customHoverBehavior:Te,customClickBehavior:Ne,enableHover:Re,hoverRadius:$e=30,tooltipMode:Be,annotations:Ie,autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,showGrid:He,legend:ze,legendHoverBehavior:We,legendClickBehavior:qe,legendHighlightedCategory:Ve,legendIsolatedCategories:Xe,legendPosition:Ue,legendLayout:Ke,legendCategoryAccessor:Qe,onCategoriesChange:Ze,backgroundGraphics:Je,foregroundGraphics:et,canvasPreRenderers:tt,svgPreRenderers:nt,title:ot,categoryAccessor:it,brush:st,onBrush:at,decay:lt,pulse:ct,transition:ut,animate:dt,staleness:pt,heatmapAggregation:yt,heatmapXBins:mt,heatmapYBins:vt,showValues:bt,heatmapValueFormat:xt,marginalGraphics:wt,pointIdAccessor:Ct,xScaleType:Ot,yScaleType:_t,accessibleTable:Lt=!0,description:Tt,summary:Nt,linkedCrosshairName:Rt,linkedCrosshairSourceId:$t,customLayout:Dt,layoutConfig:Bt}=n,It=t.useId().replace(/:/g,""),Et=t.useRef(!1),Ft=ai({sizeProp:X,responsiveWidth:U,responsiveHeight:K,userMargin:Q,marginDefault:$i,animate:dt,transitionProp:ut,themeDirtyRef:Et}),Ht=co(),zt=go(),{reducedMotionRef:Wt,responsiveRef:Gt,size:Yt,currentTheme:qt,transition:Vt,introEnabled:Xt,tableId:Ut,rafRef:Kt,renderFnRef:Qt,scheduleRender:Zt}=Ft;let Jt=Ft.margin;if(wt){const e=60,t=Object.assign({},Ft.margin);wt.top&&e>t.top&&(t.top=e),wt.bottom&&e>t.bottom&&(t.bottom=e),wt.left&&e>t.left&&(t.left=e),wt.right&&e>t.right&&(t.right=e),Jt=t}const en="function"==typeof et?et({size:Yt,margin:Jt}):et,tn="function"==typeof Je?Je({size:Yt,margin:Jt}):Je,nn=Yt[0]-Jt.left-Jt.right,on=Yt[1]-Jt.top-Jt.bottom,rn=t.useMemo(()=>v(A),[A]),sn=null!=_e?_e:Re,an=t.useRef(null),ln=t.useRef(null),[cn,un]=t.useState(0),[dn,hn]=t.useState(null),fn=t.useRef(null),gn=t.useRef(null),[pn,yn]=t.useState(null),mn=t.useRef(Di.primary),vn=t.useRef([]),bn=t.useRef(Qe),xn=t.useRef(Ze);bn.current=Qe,xn.current=Ze;const[wn,kn]=t.useState(!1),[An,jn]=t.useState([]),[Sn,Cn]=t.useState([]),On="streaming"===x||["bar","swarm","waterfall"].includes(b),Mn=t.useMemo(()=>{var e,t,n;return{chartType:b,runtimeMode:On?"streaming":"bounded",windowSize:H,windowMode:F,arrowOfTime:On?E:"right",extentPadding:Y,scalePadding:q,axisExtent:Oe,xAccessor:O,yAccessor:M,timeAccessor:On?z:void 0,valueAccessor:I,colorAccessor:P,sizeAccessor:_,groupAccessor:L||(T?"_lineGroup":void 0),categoryAccessor:it,lineDataAccessor:T,xScaleType:Ot,yScaleType:_t,xExtent:W,yExtent:G,sizeRange:V,binSize:B,normalize:R,baseline:$,stackOrder:D,boundsAccessor:le,boundsStyle:ce,y0Accessor:ue,band:de,gradientFill:!0===he?{topOpacity:.8,bottomOpacity:.05}:!1===he?void 0:he,areaGroups:ge?new Set(ge):void 0,lineGradient:fe,openAccessor:pe,highAccessor:ye,lowAccessor:me,closeAccessor:ve,candlestickStyle:be,lineStyle:ee,pointStyle:te,areaStyle:ne,swarmStyle:re,waterfallStyle:ie,colorScheme:ae,barColors:se,barStyle:oe,annotations:Ie,decay:lt,pulse:ct,transition:Vt,introAnimation:Xt,staleness:pt,heatmapAggregation:yt,heatmapXBins:mt,heatmapYBins:vt,showValues:bt,heatmapValueFormat:xt,pointIdAccessor:Ct,curve:N,themeCategorical:null===(e=null==qt?void 0:qt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(qt),themeSequential:null===(t=null==qt?void 0:qt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(n=null==qt?void 0:qt.colors)||void 0===n?void 0:n.diverging,customLayout:Dt,layoutConfig:Bt,layoutMargin:Jt}},[b,H,F,E,Y,q,Oe,O,M,z,I,Ot,_t,P,_,L,it,T,W,G,V,B,R,$,D,le,ce,ue,de,he,fe,ge,pe,ye,me,ve,be,ee,te,ne,re,ie,oe,ae,se,Ie,lt,ct,null==Vt?void 0:Vt.duration,null==Vt?void 0:Vt.easing,Xt,pt,yt,mt,vt,bt,xt,On,Ct,N,qt,Dt,Bt,Jt]),Pn=yo(Mn),_n=t.useRef(null);_n.current||(_n.current=new Ge(Pn));const Ln=t.useCallback(()=>{var e,t;const n=bn.current,o=xn.current;if(!o||!n)return;const i=Mi(null!==(t=null===(e=_n.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],n);Pi(i,vn.current)||(vn.current=i,o(i))},[]);t.useEffect(()=>{var e;null===(e=_n.current)||void 0===e||e.updateConfig(Pn),Et.current=!0,Zt()},[Pn,Zt]);const Tn=t.useRef(null);Tn.current||(Tn.current=new k(e=>{const t=_n.current;t&&t.ingest(e)&&(Et.current=!0,Zt())},{chunkThreshold:j,chunkSize:C})),t.useEffect(()=>{var e;null===(e=Tn.current)||void 0===e||e.updateChunkOptions({chunkThreshold:j,chunkSize:C})},[j,C]);const Nn=t.useCallback(e=>{var t;null===(t=Tn.current)||void 0===t||t.push(e)},[]),Rn=t.useCallback(e=>{var t;null===(t=Tn.current)||void 0===t||t.pushMany(e)},[]),$n=t.useCallback(()=>{var e,t;null===(e=Tn.current)||void 0===e||e.clear(),null===(t=_n.current)||void 0===t||t.clear(),Et.current=!0,Zt()},[Zt]);t.useImperativeHandle(o,()=>({push:Nn,pushMany:Rn,remove:e=>{var t,n,o;null===(t=Tn.current)||void 0===t||t.flush();const i=null!==(o=null===(n=_n.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];return i.length>0&&(fn.current&&i.some(e=>{var t;return e===(null===(t=fn.current)||void 0===t?void 0:t.data)})&&(fn.current=null,yn(null)),Et.current=!0,Zt()),i},update:(e,t)=>{var n,o,i;null===(n=Tn.current)||void 0===n||n.flush();const r=null!==(i=null===(o=_n.current)||void 0===o?void 0:o.update(e,t))&&void 0!==i?i:[];return r.length>0&&(Et.current=!0,Zt()),r},clear:$n,getData:()=>{var e,t,n;return null===(e=Tn.current)||void 0===e||e.flush(),null!==(n=null===(t=_n.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=_n.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null},getExtents:()=>{var e,t;return null!==(t=null===(e=_n.current)||void 0===e?void 0:e.getExtents())&&void 0!==t?t:null}}),[Nn,Rn,$n,Zt]),t.useEffect(()=>{var e,t;if(A){if(T&&rn.length>0&&"object"==typeof rn[0]&&null!==rn[0]){const t="string"==typeof T?T:"coordinates";if(Array.isArray(rn[0][t])){const n=[];for(const e of rn){const o=e[t];if(Array.isArray(o)){const t=e.label||e.id||e.key;if(null!=t)for(const e of o)n.push(Object.assign(Object.assign({},e),{_lineGroup:t}));else for(const e of o)n.push(e)}}return void(null===(e=Tn.current)||void 0===e||e.setBoundedData(n))}}null===(t=Tn.current)||void 0===t||t.setBoundedData(rn)}},[A,rn,T]);const{hoverHandlerRef:Dn,hoverLeaveRef:Bn,onPointerMove:In,onPointerLeave:En}=Ft;Dn.current=e=>{var t,n,o,i;if(!sn)return;const r=an.current;if(!r)return;const s=r.getBoundingClientRect(),a=e.clientX-s.left-Jt.left,l=e.clientY-s.top-Jt.top;if(0>a||a>nn||0>l||l>on)return void(fn.current&&(fn.current=null,gn.current=null,yn(null),Te&&(Te(null),Et.current=!0),Zt()));const c=_n.current;if(!c||0===c.scene.length)return;const u=ft(c.scene,a,l,$e,c.quadtree,c.maxPointRadius),d="multi"===Be,h=()=>{fn.current&&(fn.current=null,gn.current=null,yn(null),Te&&Te(null),Zt())};if(!u&&!d)return void h();const f=d||!u?a:u.x,g=d||!u?l:u.y,p=(null==u?void 0:u.datum)?De(u.datum,c.resolvedRibbons):{},y=null===(n=null===(t=c.scales)||void 0===t?void 0:t.x)||void 0===n?void 0:n.invert,m="function"==typeof y?y(f):void 0;let v=Xo(p,f,g,null!=m?{xValue:m,xPx:f}:void 0);if(d&&c.scene.length>0&&c.scales){const e=function(e,t,n=30){const o=[];for(const i of e)if("line"===i.type){const e=i;if(2>e.path.length)continue;const r=gt(ht(e.path,e.curve),t,n);if(null===r)continue;const s=kt(e.path,t);o.push({node:i,datum:Array.isArray(e.datum)&&e.datum[s]?e.datum[s]:e.datum,x:e.path[s][0],y:r,group:e.group,color:e.style.stroke})}else if("area"===i.type){const e=i;if(!1===e.interactive)continue;if(2>e.topPath.length)continue;const r=ht(e.topPath,e.curve),s=ht(e.bottomPath,e.curve),a=gt(r,t,n);if(null===a)continue;const l=gt(s,t,n),c=kt(e.topPath,t);o.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 o}(c.scene,f,Math.max($e,nn));if(e.length>0){const t=c.scales.y.invert,n=mn.current,o=y?y(f):f;if(u)v.xValue=o,v.xPx=f;else{const e={xValue:o};"string"==typeof O&&(e[O]=o),v=Xo(e,f,g,{xValue:o,xPx:f})}v.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,c.resolvedRibbons)}})}}u||(null===(o=v.allSeries)||void 0===o?void 0:o.length)?(fn.current=v,gn.current=null!==(i=null==u?void 0:u.node)&&void 0!==i?i:null,yn(v),Te&&(Te(v),Et.current=!0),Zt()):h()},Bn.current=()=>{fn.current&&(fn.current=null,gn.current=null,yn(null),Te&&(Te(null),Et.current=!0),Zt())};const Fn=t.useRef(()=>{});Fn.current=e=>{var t,n;if(!Ne)return;const o=an.current;if(!o)return;const i=o.getBoundingClientRect(),r=e.clientX-i.left-Jt.left,s=e.clientY-i.top-Jt.top;if(0>r||r>nn||0>s||s>on)return void Ne(null);const a=_n.current;if(!a||0===a.scene.length)return void Ne(null);const l=ft(a.scene,r,s,$e,a.quadtree,a.maxPointRadius);if(!l)return void Ne(null);const c=l.datum||{},u=null===(n=null===(t=a.scales)||void 0===t?void 0:t.x)||void 0===n?void 0:n.invert,d="function"==typeof u?u(l.x):void 0;Ne(Xo(c,l.x,l.y,null!=d?{xValue:d,xPx:l.x}:void 0))};const Hn=t.useCallback(e=>Fn.current(e),[]),zn=t.useRef(-1),Wn=t.useRef(null),Gn=t.useRef(null),Yn=t.useCallback(e=>{const t=_n.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(Gn.current&&Gn.current.version===n)o=Gn.current.graph;else{const e=function(e){var t,n,o;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,n=Array.isArray(e.datum)?e.datum:[],o=null!==(t=e.group)&&void 0!==t?t:"_default";for(let t=0;e.path.length>t&&n.length>t;t++)i.push({x:e.path[t][0],y:e.path[t][1],datum:n[t],shape:"circle",group:o});break}case"area":{const e=r,t=Array.isArray(e.datum)?e.datum:[],o=null!==(n=e.group)&&void 0!==n?n:"_default";for(let n=0;e.topPath.length>n&&t.length>n;n++)i.push({x:e.topPath[n][0],y:e.topPath[n][1],datum:t[n],shape:"circle",group:o});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!==(o=r.group)&&void 0!==o?o:"_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;o=At(e),Gn.current={version:n,graph:o}}const i=zn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),zn.current=0;const n=o.flat[0];Wn.current={shape:n.shape,w:n.w,h:n.h};const i=Mt(Object.assign(Object.assign({},n),{datum:De(n.datum,t.resolvedRibbons)}));return fn.current=i,yn(i),Te&&Te(i),void Zt()}const r=jt(o,i),s=St(e.key,r,o);if(null===s)return;if(e.preventDefault(),0>s)return zn.current=-1,Wn.current=null,fn.current=null,gn.current=null,yn(null),Te&&Te(null),void Zt();zn.current=s;const a=o.flat[s];Wn.current={shape:a.shape,w:a.w,h:a.h};const l=Mt(Object.assign(Object.assign({},a),{datum:De(a.datum,t.resolvedRibbons)}));fn.current=l,yn(l),Te&&Te(l),Zt()},[Te,Zt]),qn=t.useCallback(e=>{zn.current=-1,Wn.current=null,In(e)},[In]);Qt.current=()=>{var e,t;Kt.current=0;const n=an.current,o=ln.current;if(!n||!o)return;const i=_n.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=Et.current||s;l&&!a&&(i.computeScene({width:nn,height:on}),Ln());const c=ci(),u=function(e){if(!e)return Di;const t=getComputedStyle(e),n=t.getPropertyValue("--semiotic-border").trim(),o=t.getPropertyValue("--semiotic-text-secondary").trim(),i=t.getPropertyValue("--semiotic-bg").trim(),r=t.getPropertyValue("--semiotic-primary").trim(),s=o||t.getPropertyValue("--text-secondary").trim(),a=t.getPropertyValue("--text-primary").trim(),l=n||t.getPropertyValue("--surface-3").trim(),c=i||t.getPropertyValue("--surface-0").trim();return s||a||n||r?{axisStroke:l||Di.axisStroke,tickText:s||Di.tickText,crosshair:s?Bi(s,"66"):Di.crosshair,hoverFill:c?Bi(c,"4D"):Di.hoverFill,hoverStroke:s?Bi(s,"99"):Di.hoverStroke,pointRing:c||Di.pointRing,primary:r||Di.primary}:Di}(n);mn.current=u.primary;const d=null!==(e=null==pt?void 0:pt.threshold)&&void 0!==e?e:5e3,h=pt&&i.lastIngestTime>0&&r-i.lastIngestTime>d;if(l){const e=li(n,Yt,Jt,c);if(e){if(e.clearRect(-Jt.left,-Jt.top,Yt[0],Yt[1]),h&&(e.globalAlpha=null!==(t=null==pt?void 0:pt.dimOpacity)&&void 0!==t?t:.5),"transparent"!==J&&!Je){const t=getComputedStyle(n).getPropertyValue("--semiotic-bg").trim(),o=J||(t&&"transparent"!==t?t:null),i=o?rt(e,o):null;i&&(e.fillStyle=i,e.fillRect(-Jt.left,-Jt.top,Yt[0],Yt[1]))}if(e.save(),"function"==typeof e.rect&&(e.beginPath(),e.rect(0,0,nn,on),e.clip()),tt&&i.scales)for(const t of tt)e.save(),t(e,i.scene,i.scales,{width:nn,height:on}),e.restore();const o=Dt?Ri.custom:Ri[b];if(o&&i.scales)for(const t of o)t(e,i.scene,i.scales,{width:nn,height:on});e.restore(),h&&(e.globalAlpha=1)}}{const e=li(o,Yt,Jt,c);if(e&&(e.clearRect(-Jt.left,-Jt.top,Yt[0],Yt[1]),sn&&fn.current&&i.scales&&function(e,t,n,o,i,r,s){var a;if(!1===i.crosshair)return;const l=t.allSeries,c=l&&l.length>0,u=null!==(a=t.xPx)&&void 0!==a?a:t.x;e.save();const d="object"==typeof i.crosshair?i.crosshair:{};if(e.strokeStyle=d.stroke||s.crosshair,e.lineWidth=d.strokeWidth||1,e.setLineDash(d.strokeDasharray?d.strokeDasharray.split(/[\s,]+/).map(Number):[4,4]),e.beginPath(),e.moveTo(c?u:t.x,0),e.lineTo(c?u:t.x,o),e.stroke(),c||(e.beginPath(),e.moveTo(0,t.y),e.lineTo(n,t.y),e.stroke()),e.restore(),c){e.lineWidth=2,e.strokeStyle=s.pointRing;for(const t of l)null!=t.valuePx&&(e.beginPath(),e.arc(u,t.valuePx,4,0,2*Math.PI),e.fillStyle=t.color||s.primary,e.fill(),e.stroke())}else{const n=i.pointColor||function(e){if(!e)return null;if("heatcell"===e.type)return e.fill||null;if("candlestick"===e.type)return e.isUp?e.upColor:e.downColor;const{style:t}=e;if(!t)return null;const n="string"==typeof t.fill?t.fill:null;return"line"===e.type||"area"===e.type?t.stroke||n||null:n||t.stroke||null}(r)||s.primary;e.beginPath(),e.arc(t.x,t.y,4,0,2*Math.PI),e.fillStyle=n,e.fill(),e.strokeStyle=s.pointRing,e.lineWidth=2,e.stroke()}}(e,fn.current,nn,on,"object"==typeof sn?sn:{},gn.current,u),gn.current&&Array.isArray(_e))){const t=_e.find(e=>e&&"object"==typeof e&&"highlight"===e.type);t&&function(e,t,n,o,i){var r;if(!n)return;const s="group"in n?n.group:void 0;if(void 0!==s)for(const n of t){if("line"!==n.type)continue;if(n.group!==s)continue;if(2>n.path.length)continue;const t="function"==typeof o.style?n.datum?o.style(n.datum):{}:o.style||{};e.save(),e.beginPath(),e.moveTo(n.path[0][0],n.path[0][1]);for(let t=1;n.path.length>t;t++)e.lineTo(n.path[t][0],n.path[t][1]);e.strokeStyle=t.stroke||n.style.stroke||i.primary,e.lineWidth=t.strokeWidth||(n.style.strokeWidth||2)+2,e.globalAlpha=null!==(r=t.opacity)&&void 0!==r?r:1,e.stroke(),e.restore()}}(e,i.scene,gn.current,t,u)}}l&&n&&n.setAttribute("aria-label",jo(i.scene,b+" chart"));const f=Et.current;if(Et.current=!1,f&&i.scales){const e=e=>"object"==typeof e&&null!==e&&"function"==typeof e.valueOf?e.valueOf():e;if((!dn||e(dn.x.domain()[0])!==e(i.scales.x.domain()[0])||e(dn.x.domain()[1])!==e(i.scales.x.domain()[1])||e(dn.y.domain()[0])!==e(i.scales.y.domain()[0])||e(dn.y.domain()[1])!==e(i.scales.y.domain()[1])||dn.x.range()[0]!==i.scales.x.range()[0]||dn.x.range()[1]!==i.scales.x.range()[1]||dn.y.range()[0]!==i.scales.y.range()[0]||dn.y.range()[1]!==i.scales.y.range()[1])&&hn(i.scales),wt){const e=i.getData(),t="function"==typeof O?O:e=>e[O||"x"],n="function"==typeof M?M:e=>e[M||"y"];jn(e.map(e=>t(e)).filter(e=>"number"==typeof e&&isFinite(e))),Cn(e.map(e=>n(e)).filter(e=>"number"==typeof e&&isFinite(e)))}}f&&Ie&&Ie.length>0&&un(e=>e+1),(null==pt?void 0:pt.showBadge)&&kn(!!h),(a||null!=i.activeTransition||i.hasActivePulses)&&(Kt.current=requestAnimationFrame(()=>Qt.current()))},po({hydrated:Ht,wasHydratingFromSSR:zt,storeRef:_n,dirtyRef:Et,renderFnRef:Qt,cleanup:()=>{var e;return null===(e=Tn.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{Et.current=!0,Zt()},[b,nn,on,xe,J,ee,tt,Zt]),Pt(pt,_n,Et,Zt,wn,kn);const Vn=t.useMemo(()=>{if(Se||Me)return;const e=_n.current;return(null==e?void 0:e.xIsDate)&&dn?Ni(dn.x.domain()):void 0},[Se,Me,dn]),Xn=Se||Me||Vn,Kn=sn&&pn?Le?Le(pn):e.jsx(Ei,{hover:pn}):null,Qn=Kn?e.jsx(ti,{x:pn.x,y:pn.y,containerWidth:nn,containerHeight:on,margin:Jt,className:"stream-frame-tooltip",children:Kn}):null,Jn=Wn.current,eo=e.jsx(qo,{active:zn.current>=0,hoverPoint:pn,margin:Jt,size:Yt,shape:null==Jn?void 0:Jn.shape,width:null==Jn?void 0:Jn.w,height:null==Jn?void 0:Jn.h}),to=_i(O,z,"__semiotic_resolvedX","__semiotic_resolvedTime"),no=_i(M,I,"__semiotic_resolvedY","__semiotic_resolvedValue"),oo=to.key,io=no.key,so=Li(to,no,Ie&&Ie.length>0||!1);if(ao||!Ht&&zt){const t=_n.current;t&&A&&(t.ingest({inserts:rn,bounded:!0}),t.computeScene({width:nn,height:on}));const n=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],o=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,a=Xn||(()=>{if((null==t?void 0:t.xIsDate)&&o)return Ni(o.x.domain())})();return e.jsxs("div",{ref:Gt,className:"stream-xy-frame"+(Z?" "+Z:""),role:"img","aria-label":Tt||("string"==typeof ot?ot:"XY chart"),style:{position:"relative",width:U?"100%":Yt[0],height:K?"100%":Yt[1]},children:[e.jsx(zo,{summary:Nt}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:Yt[0],height:Yt[1],style:{position:"absolute",left:0,top:0},children:[e.jsx("g",{transform:`translate(${Jt.left},${Jt.top})`,children:tn}),e.jsxs("g",{transform:`translate(${Jt.left},${Jt.top})`,children:[J&&e.jsx("rect",{x:0,y:0,width:nn,height:on,fill:J}),nt&&o&&nt.map((t,i)=>e.jsx(p.Fragment,{children:t(n,o,{width:nn,height:on})},"svgpre-"+i)),n.map((t,n)=>function(t,n,o){var i,r,s,a,l;switch(t.type){case"line":{const o=t;if(0===o.path.length)return null;const i="M"+o.path.map(([e,t])=>`${e},${t}`).join("L");return e.jsx("path",{d:i,fill:"none",stroke:o.style.stroke||"#4e79a7",strokeWidth:o.style.strokeWidth||2,strokeDasharray:o.style.strokeDasharray,opacity:o.style.opacity},"line-"+n)}case"area":{const 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=`${o?o+"-":""}area-clip-${n}`;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:ro(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-"+n)}return e.jsx("path",{d:c,fill:ro(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-"+n)}case"point":{const o=t;return e.jsx("circle",{cx:o.x,cy:o.y,r:o.r,fill:ro(o.style.fill),opacity:null!==(l=o.style.opacity)&&void 0!==l?l:.8,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"point-"+n)}case"rect":{const o=t;return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:ro(o.style.fill),opacity:o.style.opacity,stroke:o.style.stroke,strokeWidth:o.style.strokeWidth},"rect-"+n)}case"heatcell":{const o=t;if(o.showValues&&null!=o.value&&o.w>=20&&o.h>=20){const t=o.valueFormat?o.valueFormat(o.value):Number.isInteger(o.value)?o.value+"":100>Math.abs(o.value)?1>Math.abs(o.value)?o.value.toPrecision(3):o.value.toFixed(1):o.value.toFixed(0),[i,r,s]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(o.fill),a=.299*i+.587*r+.114*s>128?"#000":"#fff",l=Math.max(10,Math.min(16,.3*Math.min(o.w,o.h)));return e.jsxs("g",{children:[e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill}),e.jsx("text",{x:o.x+o.w/2,y:o.y+o.h/2,textAnchor:"middle",dominantBaseline:"middle",fill:a,fontSize:l+"px",children:t})]},"heatcell-"+n)}return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:o.fill},"heatcell-"+n)}case"candlestick":{const o=t,i=Math.min(o.openY,o.closeY),r=Math.max(Math.abs(o.openY-o.closeY),1),s=o.isUp?o.upColor:o.downColor;return e.jsxs("g",{children:[e.jsx("line",{x1:o.x,y1:o.highY,x2:o.x,y2:o.lowY,stroke:o.wickColor,strokeWidth:o.wickWidth}),e.jsx("rect",{x:o.x-o.bodyWidth/2,y:i,width:o.bodyWidth,height:r,fill:s,stroke:s,strokeWidth:1})]},"candle-"+n)}default:return null}}(t,n,It)).filter(Boolean)]})]}),e.jsx(Zn,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:Jt,scales:o,showAxes:xe,axes:we,xLabel:ke,yLabel:Ae,yLabelRight:je,xFormat:a,yFormat:Ce||Pe,axisExtent:Oe,showGrid:He,title:ot,legend:ze,legendHoverBehavior:We,legendClickBehavior:qe,legendHighlightedCategory:Ve,legendIsolatedCategories:Xe,legendPosition:Ue,legendLayout:Ke,foregroundGraphics:Ye(en,null===(s=_n.current)||void 0===s?void 0:s.customLayoutOverlays),marginalGraphics:wt,xValues:[],yValues:[],annotations:Ie,autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,annotationFrame:0,xAccessor:oo,yAccessor:io,annotationData:so(null==t?void 0:t.getData()),pointNodes:null==t?void 0:t.scene.filter(e=>"point"===e.type),curve:"string"==typeof N?N:void 0,linkedCrosshairName:Rt,linkedCrosshairSourceId:$t})]})}return e.jsxs("div",{ref:Gt,className:"stream-xy-frame"+(Z?" "+Z:""),role:"group","aria-label":Tt||("string"==typeof ot?ot:"XY chart"),tabIndex:0,style:{position:"relative",width:U?"100%":Yt[0],height:K?"100%":Yt[1],overflow:"visible"},onKeyDown:Yn,children:[Lt&&e.jsx(Wo,{tableId:Ut}),Lt&&e.jsx(Fo,{scene:null!==(l=null===(a=_n.current)||void 0===a?void 0:a.scene)&&void 0!==l?l:[],chartType:b+" chart",tableId:Ut,chartTitle:"string"==typeof ot?ot:void 0}),e.jsx(zo,{summary:Nt}),e.jsx(Go,{hoverPoint:pn}),e.jsxs("div",{role:"img","aria-label":Tt||("string"==typeof ot?ot:"XY chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:sn?qn:void 0,onMouseLeave:sn?En:void 0,onClick:Ne?Hn:void 0,children:[tn&&e.jsx("svg",{style:{position:"absolute",left:0,top:0,width:Yt[0],height:Yt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${Jt.left},${Jt.top})`,children:tn})}),e.jsx(Un,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:Jt,scales:dn,showAxes:xe,axes:we,showGrid:He,xFormat:Xn,yFormat:Ce||Pe,axisExtent:Oe}),e.jsx("canvas",{ref:an,"aria-label":jo(null!==(u=null===(c=_n.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:ln,style:{position:"absolute",left:0,top:0,pointerEvents:"none"}}),e.jsx(Zn,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:Jt,scales:dn,showAxes:xe,axes:we,xLabel:ke,yLabel:Ae,yLabelRight:je,xFormat:Xn,yFormat:Ce||Pe,axisExtent:Oe,showGrid:He,title:ot,legend:ze,legendHoverBehavior:We,legendClickBehavior:qe,legendHighlightedCategory:Ve,legendIsolatedCategories:Xe,legendPosition:Ue,legendLayout:Ke,foregroundGraphics:Ye(en,null===(d=_n.current)||void 0===d?void 0:d.customLayoutOverlays),marginalGraphics:wt,xValues:An,yValues:Sn,annotations:Ie,autoPlaceAnnotations:Ee,svgAnnotationRules:Fe,annotationFrame:cn,xAccessor:oo,yAccessor:io,annotationData:so(null===(h=_n.current)||void 0===h?void 0:h.getData()),pointNodes:null===(f=_n.current)||void 0===f?void 0:f.scene.filter(e=>"point"===e.type),curve:"string"==typeof N?N:void 0,underlayRendered:!0,canvasObscuresUnderlay:"transparent"!==J&&!Je,linkedCrosshairName:Rt,linkedCrosshairSourceId:$t}),(st||at)&&e.jsx(w,{width:nn,height:on,totalWidth:Yt[0],totalHeight:Yt[1],margin:Jt,dimension:null!==(g=null==st?void 0:st.dimension)&&void 0!==g?g:"xy",scales:dn,onBrush:null!=at?at:()=>{},binSize:B,snap:null==st?void 0:st.snap,binBoundaries:null!==(y=null==st?void 0:st.binBoundaries)&&void 0!==y?y:"bar"===b?null===(m=_n.current)||void 0===m?void 0:m.getBinBoundaries():void 0,snapDuring:null==st?void 0:st.snapDuring,streaming:"streaming"===x}),(null==pt?void 0:pt.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===pt.badgePosition?{top:4,left:4}:"bottom-left"===pt.badgePosition?{bottom:4,left:4}:"bottom-right"===pt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:wn?"#dc3545":"#28a745",color:"white"}),children:wn?"STALE":"LIVE"}),eo,Qn]})]})});Fi.displayName="StreamXYFrame";const Hi=t.createContext(null);function zi({colors:n,categories:o,colorScheme:i="category10",children:r}){const s=t.useMemo(()=>{if(n)return n;if(o){const e=Array.isArray(i)?i:ye[i]||me,t={};for(let n=0;o.length>n;n++)t[o[n]]=e[n%e.length];return t}return{}},[n,o,i]);return e.jsx(Hi.Provider,{value:s,children:r})}function Wi(){return t.useContext(Hi)}function Gi(e){const t=[];for(const[n,o]of Object.entries(e.fields))if("point"===o.type)t.push(e=>o.values.has(e[n]));else{const[e,i]=o.range;t.push(t=>{const o=t[n];return o>=e&&i>=o})}return e=>t.every(t=>t(e))}function Yi(e,t){const n=[];for(const[o,i]of e.clauses)"crossfilter"===e.resolution&&o===t||n.push(Gi(i));return 0===n.length?()=>!0:"intersect"===e.resolution?e=>n.every(t=>t(e)):e=>n.some(t=>t(e))}function qi(e,t){let n=e.get(t);return n||(n={name:t,resolution:"union",clauses:new Map},e.set(t,n)),n}zi.displayName="CategoryColorProvider";const[Vi,Xi]=A(e=>({selections:new Map,setClause(t,n){e(e=>{const o=new Map(e.selections),i=qi(o,t),r=new Map(i.clauses);return r.set(n.clientId,n),o.set(t,Object.assign(Object.assign({},i),{clauses:r})),{selections:o}})},clearClause(t,n){e(e=>{const o=e.selections.get(t);if(!o)return{};const i=new Map(e.selections),r=new Map(o.clauses);return r.delete(n),i.set(t,Object.assign(Object.assign({},o),{clauses:r})),{selections:i}})},setResolution(t,n){e(e=>{const o=new Map(e.selections),i=qi(o,t);return o.set(t,Object.assign(Object.assign({},i),{resolution:n})),{selections:o}})},clearSelection(t){e(e=>{const n=new Map(e.selections),o=n.get(t);return o&&n.set(t,Object.assign(Object.assign({},o),{clauses:new Map})),{selections:n}})}})),[Ui,Ki]=A(e=>({observations:[],maxObservations:100,version:0,pushObservation(t){e(e=>{const n=e.observations;return n.push(t),n.length>e.maxObservations&&n.shift(),{version:e.version+1}})},clearObservations(){e(()=>({observations:[],version:0}))}}));function Qi(e){const n=t.useId(),o=e.clientId||n,{name:i}=e,r=Xi(e=>e.selections.get(i)),s=Xi(e=>e.setClause),a=Xi(e=>e.clearClause),l=t.useMemo(()=>!!r&&r.clauses.size>0,[r]);return{predicate:t.useMemo(()=>r&&0!==r.clauses.size?Yi(r,o):()=>!0,[r,o]),isActive:l,selectPoints:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"point",values:new Set(o)};s(i,{clientId:o,type:"point",fields:t})},[o,i,s]),selectInterval:t.useCallback(e=>{const t={};for(const[n,o]of Object.entries(e))t[n]={type:"interval",range:o};s(i,{clientId:o,type:"interval",fields:t})},[o,i,s]),clear:t.useCallback(()=>{a(i,o)},[a,i,o]),clientId:o}}function Zi(e){const n=e.name||"hover",{fields:o}=e,{predicate:i,isActive:r,selectPoints:s,clear:a}=Qi({name:n});return{onHover:t.useCallback(e=>{if(!e)return void a();const t={};for(const n of o){const o=e[n];void 0!==o&&(t[n]=[o])}Object.keys(t).length>0&&s(t)},[o,s,a,n]),predicate:i,isActive:r}}function Ji(e){return 2===e.length&&"number"==typeof e[0]&&"number"==typeof e[1]}function er(e){const{name:n,xField:o,yField:i}=e,{predicate:r,isActive:s,selectInterval:a,clear:l}=Qi({name:n}),c=o&&i?"xyBrush":o?"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)?(o&&(t[o]=[Math.min(e[0][0],e[1][0]),Math.max(e[0][0],e[1][0])]),i&&(t[i]=[Math.min(e[0][1],e[1][1]),Math.max(e[0][1],e[1][1])])):"xBrush"===c&&Ji(e)?o&&(t[o]=[Math.min(...e),Math.max(...e)]):"yBrush"===c&&Ji(e)&&i&&(t[i]=[Math.min(...e),Math.max(...e)]),Object.keys(t).length>0&&a(t)},[c,o,i,a,l]);return{brushInteraction:t.useMemo(()=>({brush:c,during:u,end:u}),[c,u]),predicate:r,isActive:s,clear:l}}function tr(e={}){const{limit:n=50,types:o,chartId:i}=e,r=Ki(e=>e.version),s=Ki(e=>e.observations),a=Ki(e=>e.clearObservations),l=t.useMemo(()=>{let e=s;if(o&&o.length>0){const t=new Set(o);e=e.filter(e=>t.has(e.type))}return i&&(e=e.filter(e=>e.chartId===i)),e.length>n&&(e=e.slice(e.length-n)),e},[s,o,i,n,r]);return{observations:l,latest:l.length>0?l[l.length-1]:null,clear:a}}const nr=t.createContext(!1),or=t.createContext(null),ir="undefined"==typeof window?t.useEffect:t.useLayoutEffect;function rr(e){const t=new Set,n=[];for(const o of e)t.has(o)||(t.add(o),n.push(o));return n}function sr(e,t){if(e.length!==t.length)return!1;for(let n=0;e.length>n;n++)if(e[n]!==t[n])return!1;return!0}function ar(e){const n=t.useContext(or),o=t.useId(),i=rr(e),r=t.useRef([]);sr(r.current,i)||(r.current=i);const s=r.current;ir(()=>{if(n)return()=>n.unregisterCategories(o)},[n,o]),ir(()=>{n&&n.registerCategories(o,s)},[n,o,s])}function lr({selections:e}){const n=Xi(e=>e.setResolution);return t.useEffect(()=>{for(const[t,o]of Object.entries(e))o.resolution&&n(t,o.resolution)},[e,n]),null}function cr({categoryColors:n,interaction:o,selectionName:i,field:r}){const s=Object.entries(n),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=Zi({name:i,fields:[r]}),u=Qi({name:i,clientId:"__linked-legend-isolate__"}),[d,h]=t.useState(new Set),[f,g]=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"===o&&(d.size>0?p.current({[r]:Array.from(d)}):y.current())},[o,d,r]);const m=t.useCallback(e=>{"highlight"===o&&(e?(g(e.label),c.onHover({[r]:e.label})):(g(null),c.onHover(null)))},[o,r,c]),v=t.useCallback(e=>{"isolate"===o&&h(t=>{const n=new Set(t);return n.has(e.label)?n.delete(e.label):n.add(e.label),n.size===a.length?new Set:n})},[o,a.length]),[b,[x]]=ii([0,0],!0,!1),w=t.useMemo(()=>function(e,t){if(!t||0===e.length)return 1;let n=0,o=1;for(const i of e){const e=26+7*i.length;n>0&&n+e>t&&(o++,n=0),n+=e}return o}(s.map(([e])=>e),x),[s,x]);return 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*w+8),style:{display:"block",overflow:"visible"},children:e.jsx(Dt,{legendGroups:l,title:!1,orientation:"horizontal",width:x,height:20,customHoverBehavior:"highlight"===o?m:void 0,customClickBehavior:"isolate"===o?v:void 0,highlightedCategory:f,isolatedCategories:d})})})}function ur({children:n,selections:o,showLegend:i,legendPosition:r="top",legendInteraction:s="none",legendSelectionName:a="legend",legendField:l="category"}){const c=Wi(),[u,d]=t.useState({}),h=t.useRef({}),f=t.useMemo(()=>({registerCategories:(e,t)=>{const n=rr(t);d(t=>{var o;return sr(null!==(o=t[e])&&void 0!==o?o:[],n)?t:Object.assign(Object.assign({},t),{[e]:n})})},unregisterCategories:e=>{d(t=>{if(!(e in t))return t;const n=Object.assign({},t);return delete n[e],n})}}),[]),g=t.useMemo(()=>{const e=[];for(const t of Object.values(u))for(const n of t)e.push(n);return rr(e)},[u]),p=t.useMemo(()=>{var e;const t=null!=c?c:{},n=h.current;let o=Object.keys(t).length+Object.keys(n).length;for(const e of g)t[e]||n[e]||(n[e]=me[o%me.length],o++);const i=Object.assign({},t);for(const o of g)i[o]=null!==(e=t[o])&&void 0!==e?e:n[o];return i},[c,g]),y=void 0===i||i,m=y&&Object.keys(p).length>0;return e.jsx(Vi,{children:e.jsxs(Ui,{children:[o&&e.jsx(lr,{selections:o}),e.jsx(or.Provider,{value:f,children:e.jsx(zi,{colors:p,children:e.jsxs(nr.Provider,{value:m,children:[y&&"top"===r&&e.jsx(cr,{categoryColors:p,interaction:s,selectionName:a,field:l}),n,y&&"bottom"===r&&e.jsx(cr,{categoryColors:p,interaction:s,selectionName:a,field:l})]})})})]})})}function dr({data:e,colorBy:t,colorScale:n,getColor:o,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?o(s,t,n):n?n(i):ve[r%ve.length];return{label:i+"",color:a}});return{legendGroups:[{styleFn:e=>{const t=e.color||"#333",n={fill:t,stroke:t};return void 0!==i&&(n.stroke=i),void 0!==r&&(n.strokeWidth=r),n},type:"fill",items:a,label:""}]}}function hr(e){return e?"string"==typeof e?{name:e}:e:null}function fr(e,t,n){return t?(o,...i)=>{var r;const s=Object.assign({},e(o,...i));if(t.isActive)if(t.predicate(o))(null==n?void 0:n.selectedStyle)&&Object.assign(s,n.selectedStyle);else{const e=null!==(r=null==n?void 0:n.unselectedOpacity)&&void 0!==r?r:.5;s.opacity=e,s.fillOpacity=e,s.strokeOpacity=e,(null==n?void 0:n.unselectedStyle)&&Object.assign(s,n.unselectedStyle)}return s}:e}const gr={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:12},tooltip:{background:"#fff5ee",text:"#4a3728",borderRadius:"8px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"10px"},"pastels-dark":{mode:"dark",colors:{primary:"#c9a0dc",secondary:"#a899c0",categorical:["#f0a0c0","#88d4ab","#b0a0e8","#f0c888"],sequential:"purples",background:"#1a1525",surface:"#251e35",text:"#e8ddf0",textSecondary:"#a899c0",grid:"#3d3455",border:"#3d3455",focus:"#c9a0dc",annotation:"#c9a0dc",success:"#88d4ab",danger:"#f0a0c0",warning:"#f0c888",error:"#e87690",info:"#9cb8e0"},typography:{fontFamily:"Inter, system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#251e35",text:"#e8ddf0",borderRadius:"8px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"10px"},"bi-tool":{mode:"light",colors:{primary:"#2563eb",secondary:"#6b7280",categorical:["#2563eb","#0d9488","#ea580c","#6b7280"],sequential:"blues",background:"#f5f6f8",surface:"#ffffff",text:"#2c3e50",textSecondary:"#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:12},tooltip:{background:"#ffffff",text:"#2c3e50",borderRadius:"6px",shadow:"0 2px 8px rgba(0, 0, 0, 0.12)"},borderRadius:"8px"},"bi-tool-dark":{mode:"dark",colors:{primary:"#3b82f6",secondary:"#9ca3af",categorical:["#3b82f6","#14b8a6","#f97316","#9ca3af"],sequential:"blues",background:"#111827",surface:"#1f2937",text:"#f3f4f6",textSecondary:"#9ca3af",grid:"#374151",border:"#374151",focus:"#3b82f6",annotation:"#3b82f6",success:"#34d399",danger:"#f87171",warning:"#fbbf24",error:"#ef4444",info:"#60a5fa"},typography:{fontFamily:"'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f2937",text:"#f3f4f6",borderRadius:"6px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"8px"},italian:{mode:"light",colors:{primary:"#cc0000",secondary:"#666666",categorical:["#cc0000","#333333","#c8a415","#4682b4"],sequential:"reds",background:"#fafafa",surface:"#ffffff",text:"#1a1a1a",textSecondary:"#666666",grid:"#e0e0e0",border:"#e0e0e0",focus:"#cc0000",annotation:"#cc0000",success:"#556b2f",danger:"#cc0000",warning:"#c8a415",error:"#8b0000",info:"#4682b4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#1a1a1a",borderRadius:"2px",shadow:"0 2px 4px rgba(0, 0, 0, 0.15)"},borderRadius:"2px"},"italian-dark":{mode:"dark",colors:{primary:"#ff3333",secondary:"#aaaaaa",categorical:["#ff3333","#aaaaaa","#d4a843","#6aa4d4"],sequential:"reds",background:"#0a0a0a",surface:"#1a1a1a",text:"#f5f5f5",textSecondary:"#aaaaaa",grid:"#333333",border:"#333333",focus:"#ff3333",annotation:"#ff3333",success:"#7a8b5a",danger:"#ff3333",warning:"#d4a843",error:"#cc0000",info:"#6aa4d4"},typography:{fontFamily:"'Helvetica Neue', Helvetica, Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1a1a1a",text:"#f5f5f5",borderRadius:"2px",shadow:"0 2px 8px rgba(0, 0, 0, 0.5)"},borderRadius:"2px"},tufte:{mode:"light",colors:{primary:"#8b0000",secondary:"#555555",categorical:["#8b4513","#556b2f","#4a5568","#800020"],sequential:"oranges",background:"#fffff8",surface:"#fffff8",text:"#111111",textSecondary:"#555555",grid:"#e0ddd0",border:"#e0ddd0",focus:"#8b0000",annotation:"#8b0000",success:"#556b2f",danger:"#8b0000",warning:"#b88700",error:"#6b0000",info:"#4a5568"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#fffff8",text:"#111111",borderRadius:"2px",shadow:"0 1px 3px rgba(0, 0, 0, 0.1)"},borderRadius:"0px"},"tufte-dark":{mode:"dark",colors:{primary:"#c05050",secondary:"#a09880",categorical:["#c08050","#7a8b5a","#8090a0","#a05060"],sequential:"oranges",background:"#1c1b18",surface:"#262520",text:"#e8e4d8",textSecondary:"#a09880",grid:"#3d3c35",border:"#3d3c35",focus:"#c05050",annotation:"#c05050",success:"#7a8b5a",danger:"#c05050",warning:"#c8a060",error:"#a04040",info:"#8090a0"},typography:{fontFamily:"Georgia, 'Times New Roman', serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262520",text:"#e8e4d8",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.4)"},borderRadius:"0px"},journalist:{mode:"light",colors:{primary:"#e45050",secondary:"#666666",categorical:["#3a86c8","#e45050","#d4a843","#888888"],sequential:"blues",background:"#ffffff",surface:"#f8f8f8",text:"#222222",textSecondary:"#666666",grid:"#d4d4d4",border:"#d4d4d4",focus:"#e45050",annotation:"#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:12,tickFontFamily:"'Courier New', Courier, monospace",legendSize:11},tooltip:{background:"#f8f8f8",text:"#222222",borderRadius:"4px",shadow:"0 2px 6px rgba(0, 0, 0, 0.12)"},borderRadius:"4px"},"journalist-dark":{mode:"dark",colors:{primary:"#ff6b6b",secondary:"#a0a0a0",categorical:["#5a9fd8","#ff6b6b","#e0c060","#aaaaaa"],sequential:"blues",background:"#141414",surface:"#1e1e1e",text:"#ededed",textSecondary:"#a0a0a0",grid:"#383838",border:"#383838",focus:"#ff6b6b",annotation:"#ff6b6b",success:"#6fba78",danger:"#ff6b6b",warning:"#e0c060",error:"#d04040",info:"#5a9fd8"},typography:{fontFamily:"'Franklin Gothic Medium', 'Libre Franklin', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1e1e1e",text:"#ededed",borderRadius:"4px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"4px"},playful:{mode:"light",colors:{primary:"#8b5cf6",secondary:"#7c5a9e",categorical:["#8b5cf6","#ec4899","#06b6d4","#84cc16"],sequential:"viridis",background:"#fdf8ff",surface:"#ffffff",text:"#2d1b4e",textSecondary:"#7c5a9e",grid:"#e8d0f8",border:"#e8d0f8",focus:"#8b5cf6",annotation:"#8b5cf6",success:"#10d870",danger:"#ff4b6e",warning:"#ffaa33",error:"#e11d48",info:"#06b6d4"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#2d1b4e",borderRadius:"12px",shadow:"0 4px 12px rgba(139, 92, 246, 0.15)"},borderRadius:"12px"},"playful-dark":{mode:"dark",colors:{primary:"#a78bfa",secondary:"#b8a0d8",categorical:["#a78bfa","#f472b6","#22d3ee","#a3e635"],sequential:"viridis",background:"#150a28",surface:"#1f1138",text:"#f0e8ff",textSecondary:"#b8a0d8",grid:"#3a2560",border:"#3a2560",focus:"#a78bfa",annotation:"#a78bfa",success:"#4ade80",danger:"#fb7185",warning:"#fbbf24",error:"#f43f5e",info:"#22d3ee"},typography:{fontFamily:"'Nunito', 'Poppins', system-ui, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#1f1138",text:"#f0e8ff",borderRadius:"12px",shadow:"0 4px 12px rgba(0, 0, 0, 0.4)"},borderRadius:"12px"},carbon:{mode:"light",colors:{primary:"#0f62fe",secondary:"#525252",categorical:["#6929c4","#1192e8","#005d5d","#9f1853"],sequential:"blues",diverging:"RdBu",background:"#ffffff",surface:"#ffffff",text:"#161616",textSecondary:"#525252",grid:"#e0e0e0",border:"#e0e0e0",focus:"#0f62fe",annotation:"#0f62fe",success:"#24a148",danger:"#da1e28",warning:"#f1c21b",error:"#a2191f",info:"#0043ce"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#ffffff",text:"#161616",borderRadius:"2px",shadow:"0 2px 6px rgba(0, 0, 0, 0.2)"},borderRadius:"0px"},"carbon-dark":{mode:"dark",colors:{primary:"#4589ff",secondary:"#a8a8a8",categorical:["#a56eff","#33b1ff","#08bdba","#ff7eb6"],sequential:"blues",diverging:"RdBu",background:"#161616",surface:"#262626",text:"#f4f4f4",textSecondary:"#a8a8a8",grid:"#393939",border:"#393939",focus:"#4589ff",annotation:"#4589ff",success:"#42be65",danger:"#fa4d56",warning:"#f1c21b",error:"#da1e28",info:"#4589ff"},typography:{fontFamily:"'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif",titleSize:16,labelSize:12,tickSize:12},tooltip:{background:"#262626",text:"#f4f4f4",borderRadius:"2px",shadow:"0 4px 12px rgba(0, 0, 0, 0.5)"},borderRadius:"0px"}};function pr(e){return gr[e]}const yr=p.createContext(void 0),mr="undefined"==typeof window?p.useEffect:p.useLayoutEffect;function vr(e){if("string"!=typeof e)return e;if("light"===e||"dark"===e||"high-contrast"===e)return e;return pr(e)||(void 0!==console&&console.warn(`[ThemeProvider] Unknown theme preset "${e}". Falling back to light theme.`),"light")}function br({theme:e}){const t=N(e=>e.setTheme),n=N(e=>e.theme),o=p.useRef(n);o.current=n;const i=p.useRef(null);p.useEffect(()=>{if(void 0!==e)return;if("undefined"==typeof window||!window.matchMedia)return;const n=window.matchMedia("(forced-colors: active)");return n.matches&&(i.current=o.current===_?M:o.current,t("high-contrast")),ni(n,e=>{var n,r;e.matches?(i.current=o.current===_?null!==(n=i.current)&&void 0!==n?n:M:o.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 mr(()=>{r.current?void 0!==e&&t(vr(e)):r.current=!0},[e,t]),null}function xr({children:t}){var n,o,i,r,s;const a=N(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===(n=a.tooltip)||void 0===n?void 0:n.background)?{"--semiotic-tooltip-bg":a.tooltip.background}:{}),(null===(o=a.tooltip)||void 0===o?void 0:o.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(yr),u={};return c&&(u["data-semiotic-theme"]=c),e.jsx("div",Object.assign({style:l},u,{children:t}))}function wr(){return N(e=>e.theme)}const kr="#007bff";function Ar(e,t,n){var o;const i=null!==(o=e.xValue)&&void 0!==o?o:null==t?void 0:t[n];if(null==i)return null;const r=Number(i);return Number.isFinite(r)?r:null}function jr(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 Sr(){var e;const t=wr(),n=null===(e=null==t?void 0:t.colors)||void 0===e?void 0:e.categorical;return n&&n.length>0?n:void 0}function Cr(e,t,n,o,i){if(e)return e;let r;if(Array.isArray(n))r=n;else if(t&&t.length>0)r=t;else if("string"==typeof n){const e=ye[n];Array.isArray(e)&&(r=e)}return r&&0!==r.length?null!=o?(i.has(o)||i.set(o,i.size),r[i.get(o)%r.length]):r[0]:kr}function Or(e,n,o){const i=Wi(),r=Sr();return t.useMemo(()=>{var t;if(!n)return;const s=null!==(t=null!=o?o:r&&r.length>0?r:void 0)&&void 0!==t?t:"category10";if(0!==e.length){if("function"==typeof n){const t=Array.from(new Set(e.map(e=>n(e)+"")));if(i&&Object.keys(i).length>0){const e=ke(t.map(e=>({_cat:e})),"_cat",s);return t=>i[t]||e(t)}return ke(t.map(e=>({_cat:e})),"_cat",s)}if(i&&Object.keys(i).length>0){const t=ke(e,n,s);return e=>i[e]||t(e)}return ke(e,n,s)}if(i&&Object.keys(i).length>0){const e=ke([{_:"a"}],"_",s);return t=>i[t]||e(t)}},[e,n,o,i,r])}function Mr(e,n,o){return t.useMemo(()=>{if(!n||"auto"===n||"function"==typeof n)return e;const t=[...e],i=function(e){return"function"==typeof e?e:t=>t[e]}(o);return t.sort("asc"===n?(e,t)=>i(e)-i(t):(e,t)=>i(t)-i(e))},[e,n,o])}function Pr({selection:e,linkedHover:n,fallbackFields:o=[],unwrapData:i=!1,onObservation:r,chartType:s,chartId:a,onClick:l,hoverHighlight:c,colorByField:u}){const d=t.useId(),h=function(e,t){return e?!0===e?{name:"hover",fields:t||[]}:"string"==typeof e?{name:e,fields:t||[]}:{name:e.name||"hover",fields:e.fields||t||[],mode:e.mode,xField:e.xField,seriesField:e.seriesField}:null}(n,o),f="series"===(null==h?void 0:h.mode)?[h.seriesField||u||o[0]].filter(e=>!!e):(null==h?void 0:h.fields)||o||[],g=Qi({name:(null==e?void 0:e.name)||"__unused__"}),p=Zi({name:(null==h?void 0:h.name)||"hover",fields:f}),y=Ki(e=>e.pushObservation),m=e?{isActive:g.isActive,predicate:g.predicate}:null,[v,b]=t.useState(null),x=u||o[0],w=t.useMemo(()=>{if(!c||null==v||!x)return null;const e=v,t=x;return{isActive:!0,predicate:n=>{var o;return("string"==typeof n[t]?n[t]:(null!==(o=n[t])&&void 0!==o?o:"")+"")===e}}},[c,v,x]),k=t.useCallback(e=>{var t,o;if(n)if(e){let t=e.data||e.datum||e;if(Array.isArray(t)&&(t=t[0]),"x-position"===(null==h?void 0:h.mode)&&h.xField){const n=Ar(e,t,h.xField);null!=n&&function(e,t,n){const o=Nn.positions.get(e);(null==o?void 0:o.locked)||o&&o.xValue===t&&o.sourceId===n||(Nn={positions:new Map(Nn.positions).set(e,{xValue:t,sourceId:n})},$n())}(h.name||"hover",n,d)}"x-position"!==(null==h?void 0:h.mode)&&p.onHover(t)}else"x-position"===(null==h?void 0:h.mode)&&Dn(h.name||"hover",d),"x-position"!==(null==h?void 0:h.mode)&&p.onHover(null);if(c&&x)if(e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=null==t?void 0:t[x];b(null!=n?n+"":null)}else b(null);if(r||y){const n={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const i=jr(e),s=Object.assign(Object.assign({},n),{type:"hover",datum:i||{},x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(o=e.y)&&void 0!==o?o:0});r&&r(s),y&&y(s)}else{const e=Object.assign(Object.assign({},n),{type:"hover-end"});r&&r(e),y&&y(e)}}},[n,p,h,d,r,s,a,y,c,x]),A=t.useCallback(e=>{var t,n,o,i;if("x-position"===(null==h?void 0:h.mode)&&h.xField&&e){let t=e.data||e.datum||e;Array.isArray(t)&&(t=t[0]);const n=Ar(e,t,h.xField);null!=n&&function(e,t,n){const o=Nn.positions.get(e);if(null==o?void 0:o.locked){const t=new Map(Nn.positions);return t.delete(e),Nn={positions:t},$n(),!1}Nn={positions:new Map(Nn.positions).set(e,{xValue:t,sourceId:n,locked:!0})},$n()}(h.name||"hover",n,d)}if(e&&l){let o=e.data||e.datum||e;Array.isArray(o)&&(o=o[0]),l(o,{x:null!==(t=e.x)&&void 0!==t?t:0,y:null!==(n=e.y)&&void 0!==n?n:0})}if(r||y){const t={timestamp:Date.now(),chartType:s||"unknown",chartId:a};if(e){const n=jr(e),s=Object.assign(Object.assign({},t),{type:"click",datum:n||{},x:null!==(o=e.x)&&void 0!==o?o:0,y:null!==(i=e.y)&&void 0!==i?i:0});r&&r(s),y&&y(s)}else{const e=Object.assign(Object.assign({},t),{type:"click-end"});r&&r(e),y&&y(e)}}},[l,r,y,s,a,h,d]);return t.useEffect(()=>{if("x-position"!==(null==h?void 0:h.mode))return;const e=h.name||"hover";return()=>{Bn(e,d),Dn(e,d)}},[null==h?void 0:h.mode,null==h?void 0:h.name,d]),{activeSelectionHook:m,hoverSelectionHook:w,customHoverBehavior:k,customClickBehavior:A,crosshairSourceId:d}}function _r(e,t){const n="object"==typeof e&&null!==e?e:void 0;if("x-position"===(null==n?void 0:n.mode))return{linkedCrosshairName:n.name||"hover",linkedCrosshairSourceId:t}}function Lr({data:e,colorBy:n,colorScale:o,showLegend:i,legendPosition:r="right",userMargin:s,defaults:a={top:50,bottom:60,left:70,right:40},categories:l}){const c=t.useContext(nr),u=null!==t.useContext(or),d=void 0!==i?i:!c&&!!n,h=!!n&&(d||u),f=t.useMemo(()=>{if(!h)return[];if(void 0!==l)return l;const t=new Set;for(const o of e){const e="function"==typeof n?n(o):o[n];null!=e&&t.add(e+"")}return Array.from(t)},[l,n,e,h]);ar(u&&n?f:[]);const g=t.useMemo(()=>{if(!d||!n)return;const t=dr({data:e,colorBy:n,colorScale:o,getColor:we,categories:f});return 0!==t.legendGroups.reduce((e,t)=>e+t.items.length,0)?t:void 0},[d,n,e,o,f]),p=t.useMemo(()=>{const e="number"==typeof s?{top:s,bottom:s,left:s,right:s}:null!=s?s:{},t=t=>{const n=e[t];return"number"==typeof n?n:a[t]},n={top:t("top"),right:t("right"),bottom:t("bottom"),left:t("left")},o=t=>"number"==typeof e[t];return g&&("right"===r&&!o("right")&&110>n.right?n.right=110:"left"===r&&!o("left")&&110>n.left?n.left=110:"top"===r&&!o("top")&&50>n.top?n.top=50:"bottom"===r&&!o("bottom")&&80>n.bottom&&(n.bottom=80)),n},[a,s,g,r]);return{legend:g,margin:p,legendPosition:r}}function Tr(e,n,o){const[i,r]=t.useState(null),[s,a]=t.useState(new Set),l=t.useCallback(t=>{"highlight"===e&&r(t?t.label:null)},[e]),c=t.useCallback(t=>{"isolate"===e&&a(e=>{const n=new Set(e);return n.has(t.label)?n.delete(t.label):n.add(t.label),n.size===o.length?new Set:n})},[e,o.length]),u=t.useMemo(()=>{if(!e||"none"===e||!n)return null;const t="string"==typeof n?n:null;return"highlight"===e&&null!=i?{isActive:!0,predicate:e=>(t?e[t]:"function"==typeof n?n(e):null)===i}:"isolate"===e&&s.size>0?{isActive:!0,predicate:e=>{const o=t?e[t]:"function"==typeof n?n(e):null;return s.has(o)}}:null},[e,n,i,s]);return{highlightedCategory:"highlight"===e?i:null,isolatedCategories:"isolate"===e?s:new Set,onLegendHover:l,onLegendClick:c,legendSelectionHook:u}}const Nr={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 Rr(e,t,n){var o,i,r,s,a,l,c;const u=Nr[e||"primary"],d="context"===e||"sparkline"===e;return{width:null!==(o=t.width)&&void 0!==o?o:e&&"primary"!==e||!(null==n?void 0:n.width)?u.width:n.width,height:null!==(i=t.height)&&void 0!==i?i:e&&"primary"!==e||!(null==n?void 0:n.height)?u.height:n.height,showAxes:null!==(r=t.showAxes)&&void 0!==r?r:u.showAxes,showGrid:null!==(s=t.showGrid)&&void 0!==s?s:u.showGrid,enableHover:null!==(a=t.enableHover)&&void 0!==a?a:!!t.linkedHover||u.enableHover,showLegend:null!==(l=t.showLegend)&&void 0!==l?l:u.showLegend,showLabels:null!==(c=t.showLabels)&&void 0!==c?c:u.showLabels,title:d?void 0:t.title,description:t.description,summary:t.summary,accessibleTable:t.accessibleTable,xLabel:d?void 0:t.xLabel,yLabel:d?void 0:t.yLabel,categoryLabel:d?void 0:t.categoryLabel,valueLabel:d?void 0:t.valueLabel,marginDefaults:$r(u.marginDefaults,t.showCategoryTicks,t.orientation),compactMode:d}}function $r(e,t,n){if(!1!==t)return e;const o=Object.assign({},e);return"horizontal"===n?o.left=Math.min(o.left,15):o.bottom=Math.min(o.bottom,15),o}function Dr(e){return"string"==typeof e?e:"value"}function Br(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 Br(e);try{const n=t(e);return null==n?Br(e):n}catch(t){return Br(e)}}function Er(e,t){return"function"==typeof t?t(e):e[t]}function Fr(e,t){if(!e)return[];const n=[];return(Array.isArray(e)?e:[e]).forEach((e,o)=>{const i="string"==typeof(null==e?void 0:e.y1Accessor)?e.y1Accessor:"high";n.push({label:"string"==typeof(null==e?void 0:e.y0Accessor)?e.y0Accessor:"low",accessor:e=>{var t,n,i,r;return null!==(i=null===(n=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[o])||void 0===n?void 0:n.y0)&&void 0!==i?i:0===o?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y0:void 0},format:t}),n.push({label:i,accessor:e=>{var t,n,i,r;return null!==(i=null===(n=null===(t=null==e?void 0:e.bands)||void 0===t?void 0:t[o])||void 0===n?void 0:n.y1)&&void 0!==i?i:0===o?null===(r=null==e?void 0:e.band)||void 0===r?void 0:r.y1:void 0},format:t})}),n}function Hr(t){const n=t.find(e=>"title"===e.role),o=t.filter(e=>"title"!==e.role);return t=>{const i=t.data;if(!i)return null;const r=n?Ir(Er(i,n.accessor),n.format):null;return e.jsxs("div",{className:"semiotic-tooltip",style:Uo,children:[null!=r&&e.jsx("div",{style:{fontWeight:"bold",marginBottom:o.length>0?4:0},children:r}),o.map((t,n)=>{const o=Ir(Er(i,t.accessor),t.format);return e.jsxs("div",{style:n>0?{marginTop:2}:void 0,children:[e.jsxs("span",{style:{opacity:.7},children:[t.label,": "]}),e.jsx("span",{children:o})]},n)})]})}}function zr({categoryAccessor:t,valueAccessor:n,groupAccessor:o,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=Er(c,t),d=Er(c,n),h=o?Er(c,o):void 0;return e.jsxs("div",{className:"semiotic-tooltip",style:Uo,children:[e.jsx("div",{style:{fontWeight:"bold"},children:Br(u)}),e.jsx("div",{style:{marginTop:4},children:Ir(d,s)}),null!=h&&e.jsxs("div",{style:{marginTop:2,opacity:.8},children:[i||Dr(o),": ",Br(h)]})]})}}function Wr({componentName:t,message:n,diagnosticHint:o,width:i,height:r}){return e.jsx("div",{role:"alert",style:{width:i,height:Math.max(r,120),display:"flex",alignItems:"center",justifyContent:"center",border:"1px dashed rgba(128, 128, 128, 0.4)",borderRadius:8,background:"rgba(128, 128, 128, 0.04)",padding:24,boxSizing:"border-box"},children:e.jsxs("div",{style:{textAlign:"center",maxWidth:400},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"rgba(128, 128, 128, 0.7)",marginBottom:6,fontFamily:"monospace"},children:t}),e.jsx("div",{style:{fontSize:14,color:"rgba(128, 128, 128, 0.9)",lineHeight:1.5},children:n}),o&&e.jsx("div",{"data-testid":"semiotic-diagnostic-hint",style:{marginTop:10,padding:"8px 12px",background:"rgba(128, 128, 128, 0.06)",borderRadius:4,fontSize:12,color:"rgba(128, 128, 128, 0.8)",fontFamily:"monospace",textAlign:"left",whiteSpace:"pre-wrap",lineHeight:1.6},children:o})]})})}class Gr extends p.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){var n,o;null===(o=(n=this.props).onError)||void 0===o||o.call(n,e,t)}render(){if(this.state.error){const{fallback:t}=this.props,n=this.state.error;return"function"==typeof t?t(n):void 0!==t?t:e.jsx(Wr,{componentName:"ChartErrorBoundary",message:n.message||"An unexpected error occurred while rendering this chart.",width:600,height:400})}return this.props.children}}var Yr;const qr="undefined"!=typeof process&&"production"!==(null===(Yr=process.env)||void 0===Yr?void 0:Yr.NODE_ENV);function Vr({componentName:t,width:n,height:o,children:i}){return e.jsx(Gr,{fallback:i=>e.jsx(Wr,{componentName:t,message:i.message,width:n,height:o}),children:i})}const Xr={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"},Ur={background:"var(--semiotic-border, #e0e0e0)",borderRadius:2};function Kr(t,n,o,i){return!1===i||null==t||Array.isArray(t)&&t.length>0?null:Array.isArray(t)?e.jsx("div",{style:Object.assign(Object.assign({},Xr),{width:n,height:o}),children:i||"No data available"}):null}function Qr(t,n,o,i){if(!t)return null;if(!1===i)return null;if(null!=i)return e.jsx("div",{style:{width:n,height:o,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box"},children:i});const r=Math.min(5,Math.floor(o/40)),s=Math.max(8,Math.floor(o/(3*r))),a=Math.max(6,Math.floor(o/(2.5*r))),l=Math.floor((o-(r*(s+a)-a))/2);return e.jsx("div",{style:{width:n,height:o,position:"relative",overflow:"hidden",border:"1px solid var(--semiotic-border, #e0e0e0)",borderRadius:4,boxSizing:"border-box"},children:Array.from({length:r},(t,o)=>e.jsx("div",{className:"semiotic-loading-bar",style:Object.assign(Object.assign({},Ur),{position:"absolute",top:l+o*(s+a),left:Math.floor(.1*n),width:30+(37*o+13)%50+"%",height:s,opacity:.5+o%2*.2})},o))})}function Zr(e,t,n,o){if(!qr)return;if(!t||0===t.length)return;if("string"!=typeof o)return;const i=t[0];if(!i||"object"!=typeof i)return;if(o in i)return;const r=Object.keys(i).join(", ");console.warn(`[semiotic] ${e}: ${n} "${o}" not found in data. Available keys: ${r}`)}function Jr(e,t){const n=e.length,o=t.length,i=Array(o+1);for(let e=0;o>=e;e++)i[e]=e;for(let r=1;n>=r;r++){let n=i[0];i[0]=r;for(let s=1;o>=s;s++){const o=i[s];i[s]=e[r-1]===t[s-1]?n:1+Math.min(n,i[s],i[s-1]),n=o}}return i[o]}function es(e,t,n=3){let o,i=n+1;for(const n of t){const t=Jr(e.toLowerCase(),n.toLowerCase());i>t&&(i=t,o=n)}return i>n?void 0:o}function ts(e){return e.length>3?[e[0],e[Math.floor(e.length/2)],e[e.length-1]]:e}function ns(e,t){var n;if(0===t.length)return null;const o=e.toLowerCase();return t.find(e=>e.toLowerCase().includes(o)||o.includes(e.toLowerCase()))||(null!==(n=es(e,t,3))&&void 0!==n?n:null)}function os({componentName:e,data:t,accessors:n,requiredProps:o}){if(o)for(const[t,n]of Object.entries(o))if(null==n)return`${e}: ${t} is required. Provide a field name or function.`;if(null==t)return null;if(!Array.isArray(t)||0===t.length)return e+": No data provided. Pass a non-empty array to the data prop.";if(!Array.isArray(t)&&"object"==typeof t)return e+": data should be an array, but received an object. If this is hierarchical data, use TreeDiagram, Treemap, or CirclePack instead.";if(n){const o=ts(t).find(e=>e&&"object"==typeof e);if(o){const t=Object.keys(o);for(const[i,r]of Object.entries(n))if(r&&"string"==typeof r&&!(r in o)){const n=ns(r,t),o=n?` Try ${i}="${n}".`:"";return`${e}: ${i} "${r}" not found in data. Available fields: ${t.join(", ")}.${o}`}}}return null}function is({componentName:e,data:t,dataLabel:n="data"}){return null==t?`${e}: No ${n} provided. Pass a hierarchical object with children: { name: "root", children: [...] }.`:Array.isArray(t)?`${e}: ${n} should be a single root object, not an array. Expected: { name: "root", children: [...] }. If you have flat data, use LineChart, BarChart, or Scatterplot instead.`:null}function rs({componentName:e,nodes:t,edges:n,nodesRequired:o=!1,edgesRequired:i=!0,accessors:r}){if(null==t&&null==n)return null;if(i&&(!n||!Array.isArray(n)||0===n.length))return e+': No edges provided. Pass a non-empty array: edges={[{ source: "A", target: "B", value: 10 }, ...]}.';if(o&&(!t||!Array.isArray(t)||0===t.length))return e+': No nodes provided. Pass a non-empty array: nodes={[{ id: "A" }, { id: "B" }, ...]}.';if(r&&t&&t.length>0){const n=ts(t).find(e=>e&&"object"==typeof e);if(n){const t=Object.keys(n);for(const[o,i]of Object.entries(r))if(i&&"string"==typeof i&&!(i in n)){const n=ns(i,t),r=n?` Try ${o}="${n}".`:"";return`${e}: ${o} "${i}" not found in node data. Available fields: ${t.join(", ")}.${r}`}}}return null}function ss(e){const n=N(e=>e.theme.colors.selectionOpacity);return t.useMemo(()=>{var t,o;if(void 0!==e||void 0!==n)return Object.assign(Object.assign({name:null!==(t=null==e?void 0:e.name)&&void 0!==t?t:""},e),{unselectedOpacity:null!==(o=null==e?void 0:e.unselectedOpacity)&&void 0!==o?o:n})},[e,n])}function as(e){const{data:n,rawData:o,colorBy:i,colorScheme:r,legendInteraction:s,legendPosition:a,selection:l,linkedHover:c,fallbackFields:u,unwrapData:d=!1,onObservation:h,chartType:f,chartId:g,showLegend:p,userMargin:y,marginDefaults:m,onClick:b,hoverHighlight:x,loading:w,loadingContent:k,emptyContent:A,width:j,height:S}=e,C=void 0===o,O=t.useMemo(()=>v(n),[n]),[M,P]=t.useState([]),_=t.useCallback(e=>{P(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[]),L="string"==typeof e.colorBy?e.colorBy:void 0,{activeSelectionHook:T,hoverSelectionHook:N,customHoverBehavior:R,customClickBehavior:$,crosshairSourceId:D}=Pr({selection:l,linkedHover:c,fallbackFields:u,unwrapData:d,onObservation:h,chartType:f,chartId:g,onClick:b,hoverHighlight:x,colorByField:L}),B=_r(c,D),I=Or(O,i,r),E=t.useMemo(()=>{if(!i)return[];const e=new Set;for(const t of O){const n="function"==typeof i?i(t):t[i];null!=n&&e.add(n+"")}return Array.from(e)},[O,i]),F=t.useMemo(()=>C&&M.length>0?M:E,[C,M,E]),H=Tr(s,i,F),z=t.useMemo(()=>N||(H.legendSelectionHook?H.legendSelectionHook:T),[N,H.legendSelectionHook,T]),W=ss(l),G=Sr(),Y=Wi(),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",n=ke(F.map(e=>({[t]:e})),t,e);return e=>(null==Y?void 0:Y[e])||n(e)||"#999"},[I,i,F,r,G,Y]),{legend:V,margin:X,legendPosition:U}=Lr({data:O,colorBy:i,colorScale:q,showLegend:p,legendPosition:a,userMargin:y,defaults:m,categories:F}),K=t.useMemo(()=>{const e={};return V&&(e.legend=V,e.legendPosition=U),s&&"none"!==s&&(e.legendHoverBehavior=H.onLegendHover,e.legendClickBehavior=H.onLegendClick,e.legendHighlightedCategory=H.highlightedCategory,e.legendIsolatedCategories=H.isolatedCategories),C&&i&&(e.legendCategoryAccessor=i,e.onCategoriesChange=_),e},[V,U,s,H.onLegendHover,H.onLegendClick,H.highlightedCategory,H.isolatedCategories,C,i,_]),Q=Array.isArray(o)?v(o):o,Z=Qr(w,j,S,k),J=Z?null:Kr(Q,j,S,A);return{data:O,colorScale:I,allCategories:F,legendState:H,effectiveSelectionHook:z,activeSelectionHook:T,customHoverBehavior:R,customClickBehavior:$,legend:V,margin:X,legendPosition:U,earlyReturn:Z||J||null,legendBehaviorProps:K,crosshairProps:B,resolvedSelection:W}}function ls(e,t){if(!function(e){return void 0!==e.stroke||void 0!==e.strokeWidth||void 0!==e.opacity}(t))return null!=e?e:()=>({});const n={};return void 0!==t.stroke&&(n.stroke=t.stroke),void 0!==t.strokeWidth&&(n.strokeWidth=t.strokeWidth),void 0!==t.opacity&&(n.opacity=t.opacity),e?(...t)=>{const o=e(...t)||{};return Object.assign(Object.assign({},o),n)}:(...e)=>Object.assign({},n)}function cs(e){const{lineWidth:n=2,colorBy:o,colorScale:i,color:r,resolveStroke:s,fillArea:a,areaOpacity:l=.3,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:f}=e,g=t.useMemo(()=>(e,t)=>{const c={strokeWidth:n},u=!0===a||Array.isArray(a)&&null!=t&&a.includes(t);let d;return s?d=s(e,t):o?i&&(d=we(e,o,i)):d=r||kr,void 0!==d&&(c.stroke=d,u&&(c.fill=d,c.fillOpacity=l)),c},[n,o,i,r,s,a,l]),p=t.useMemo(()=>ls(g,{stroke:c,strokeWidth:u,opacity:d}),[g,c,u,d]);return t.useMemo(()=>fr(p,null!=h?h:null,f),[p,h,f])}function us(e,n){const{variant:o,frameRef:i,overrides:r,deps:s}=n;t.useImperativeHandle(e,()=>{const e=function(e,t){if("xy"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.remove(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,i;return null!==(i=null===(o=e.current)||void 0===o?void 0:o.update(t,n))&&void 0!==i?i:[]},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getScales())&&void 0!==n?n:null}}}if("network"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o,i,r,s;const a=Array.isArray(t)?t:[t],l=null!==(i=null===(o=null===(n=e.current)||void 0===n?void 0:n.getTopology())||void 0===o?void 0:o.nodes)&&void 0!==i?i:[],c=[];for(const t of a){const n=l.find(e=>e.id===t);n&&c.push(Object.assign(Object.assign({},null!==(r=n.data)&&void 0!==r?r:{}),{id:t})),null===(s=e.current)||void 0===s||s.removeNode(t)}return c},update:(t,n)=>(Array.isArray(t)?t:[t]).flatMap(t=>{var o;const i=null===(o=e.current)||void 0===o?void 0:o.updateNode(t,n);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,n,o,i;return null!==(i=null===(o=null===(n=null===(t=e.current)||void 0===t?void 0:t.getTopology())||void 0===n?void 0:n.nodes)||void 0===o?void 0:o.map(e=>e.data))&&void 0!==i?i:[]}}}if("geo-points"===e){const e=t;return{push:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.push(t)},pushMany:t=>{var n;return null===(n=e.current)||void 0===n?void 0:n.pushMany(t)},remove:t=>{var n,o;return null!==(o=null===(n=e.current)||void 0===n?void 0:n.removePoint(t))&&void 0!==o?o:[]},update:(t,n)=>{var o,i,r;const s=null!==(i=null===(o=e.current)||void 0===o?void 0:o.removePoint(t))&&void 0!==i?i:[];for(const t of s)null===(r=e.current)||void 0===r||r.push(n(t));return s},clear:()=>{var t;return null===(t=e.current)||void 0===t?void 0:t.clear()},getData:()=>{var t,n;return null!==(n=null===(t=e.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]}}}const n=t;return{push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushLine(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushManyLines(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.removeLine(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,i,r;const s=null!==(i=null===(o=n.current)||void 0===o?void 0:o.removeLine(e))&&void 0!==i?i:[];for(const e of s)null===(r=n.current)||void 0===r||r.pushLine(t(e));return s},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getLines())&&void 0!==t?t:[]}}}(o,i);return Object.assign(Object.assign({},e),r)},null!=s?s:[])}function ds(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&0>t.indexOf(o)&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(e);o.length>i;i++)0>t.indexOf(o[i])&&Object.prototype.propertyIsEnumerable.call(e,o[i])&&(n[o[i]]=e[o[i]])}return n}function hs(e,t,n,o){return new(n||(n=Promise))(function(i,r){function s(e){try{l(o.next(e))}catch(e){r(e)}}function a(e){try{l(o.throw(e))}catch(e){r(e)}}function l(e){e.done?i(e.value):function(e){return e instanceof n?e:new n(function(t){t(e)})}(e.value).then(s,a)}l((o=o.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const fs="__forecastSegment";let gs=null;function ps(){return hs(this,void 0,void 0,function*(){return gs||(gs=yield Promise.resolve().then(function(){return gy})),gs})}const ys="__semiotic_resolvedX",ms="__semiotic_resolvedY";function vs(e){const{data:n,xAccessor:o,yAccessor:i,forecast:r,anomaly:s,groupBy:a}=e,l="string"==typeof o?o:ys,c="string"==typeof i?i:ms,u=t.useMemo(()=>{if(!r&&!s)return n;const e="function"==typeof o,t="function"==typeof i;return e||t?n.map(n=>{const r=Object.assign({},n);return e&&(r[ys]=o(n)),t&&(r[ms]=i(n)),r}):n},[n,r,s,o,i]),[d,h]=t.useState(null),[f,g]=t.useState([]),p=t.useRef(r),y=t.useRef(s);return t.useEffect(()=>{if(!r&&!s)return void((p.current||y.current)&&(h(null),g([]),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),g([])),r){const t=a&&"string"==typeof a&&"object"==typeof r?Object.assign(Object.assign({},r),{_groupBy:a}):r;(function(...e){return hs(this,void 0,void 0,function*(){return(yield ps()).buildForecast(...e)})})(u,l,c,t,s).then(t=>{e||(h(t),g(t.annotations))}).catch(()=>{e||(h(null),g([]))})}else s&&function(...e){return hs(this,void 0,void 0,function*(){return(yield ps()).buildAnomalyAnnotations(...e)})}(s).then(t=>{e||(h(null),g(t))}).catch(()=>{e||g([])});return()=>{e=!0}},[u,r,s,l,c,a]),{effectiveData:d?d.processedData:n,statisticalAnnotations:f,hasForecast:!!d,xAccessorKey:l,yAccessorKey:c}}const bs=t.forwardRef(function(n,o){var i,r;const s=t.useRef(null);us(o,{variant:"xy",frameRef:s});const a=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,axisExtent:f,xAccessor:g="x",yAccessor:p="y",lineBy:y,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:x,curve:w="linear",showPoints:k=!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:N,forecast:R,band:$,xExtent:D,yExtent:B,frameProps:I={},selection:E,linkedHover:F,onObservation:H,onClick:z,hoverHighlight:W,hoverRadius:G,chartId:Y,loading:q,loadingContent:V,emptyContent:X,legendInteraction:U,legendPosition:K,xScaleType:Q,yScaleType:Z,color:J,stroke:ee,strokeWidth:te,opacity:ne}=n,{width:oe,height:ie,enableHover:re,showGrid:se,showLegend:ae,title:le,description:ce,summary:ue,accessibleTable:de,xLabel:he,yLabel:fe}=a,ge=t.useMemo(()=>v(l),[l]);Zr("LineChart",ge,"xAccessor",g),Zr("LineChart",ge,"yAccessor",p);const{effectiveData:pe,statisticalAnnotations:ye}=vs({data:ge,xAccessor:g,yAccessor:p,forecast:R,anomaly:N,groupBy:y}),me="__compoundGroup",ve=!(!R||!y),be=ve?me:R?fs:y,xe=t.useMemo(()=>{if(!ve)return pe;const e="function"==typeof y?y:e=>e[y];return pe.map(t=>{const n=Object.assign({},t);return n[me]=`${e(t)}__${t[fs]||"observed"}`,n})},[pe,ve,y]),ke=ve?xe:pe,Ae=b||y,je=t.useMemo(()=>{if(!R)return;const e=R.upperBounds,t=R.lowerBounds;if(!e&&!t)return;const n="function"==typeof e?e:"string"==typeof e?t=>t[e]:null,o="function"==typeof t?t:"string"==typeof t?e=>e[t]:null;let i=1/0,r=-1/0;const s=pe;for(const e of s){const t="function"==typeof p?p(e):+e[p];if(isFinite(t)&&(i>t&&(i=t),t>r&&(r=t)),n){const t=n(e);null!=t&&isFinite(t)&&(t>r&&(r=t),i>t&&(i=t))}if(o){const t=o(e);null!=t&&isFinite(t)&&(i>t&&(i=t),t>r&&(r=t))}}return isFinite(i)&&isFinite(r)?[i,r]:void 0},[R,pe,p]),Se=t.useCallback(e=>{const t="function"==typeof g?g(e):e[g],n="function"==typeof p?p(e):e[p];return null==t||null==n||Number.isNaN(t)||Number.isNaN(n)},[g,p]),Ce=void 0!==(null===(i=ke[0])||void 0===i?void 0:i[m]),Oe=t.useMemo(()=>{if(Ce)return ke;if(be){const e=ke.reduce((e,t)=>{const n="function"==typeof be?be(t):t[be];if(!e[n]){const o={[m]:[]};"string"==typeof be&&(o[be]=n),ve&&(o[fs]=t[fs],"string"==typeof y&&(o[y]=t[y])),e[n]=o}return e[n][m].push(t),e},{});return Object.values(e)}return[{[m]:ke}]},[ke,be,m,Ce]),{gapProcessedLineData:Me,hasGaps:Pe}=t.useMemo(()=>{if("interpolate"===T){let e=!1;const t=[];for(const n of Oe){const o=(n[m]||[]).filter(t=>!Se(t)||(e=!0,!1));o.length>0&&t.push(Object.assign(Object.assign({},n),{[m]:o}))}return{gapProcessedLineData:t,hasGaps:e}}if("break"===T){let e=!1;const t=[];for(const n of Oe){const o=n[m]||[];let i=[],r=0;const s=be&&"string"==typeof be?n[be]:void 0;for(const a of o)if(Se(a))e=!0,i.length>0&&(t.push(Object.assign(Object.assign({},n),{[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({},n),{[m]:i}))}return{gapProcessedLineData:t,hasGaps:e}}if("zero"===T){let e=!1;const t="string"==typeof p?p:"y",n=[];for(const o of Oe){const i=o[m]||[],r=[];for(const n of i)Se(n)?(e=!0,r.push(Object.assign(Object.assign({},n),{[t]:0}))):r.push(n);n.push(Object.assign(Object.assign({},o),{[m]:r}))}return{gapProcessedLineData:n,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,Ne=t.useMemo(()=>{var e;if(!L||!Ae)return[];const t="function"==typeof Ae?Ae:e=>e[Ae],n=new Set;for(const o of Me){const i=o[m]||[];if(0===i.length)continue;const r=null!==(e=t("end"===Le?i[i.length-1]:i[0]))&&void 0!==e?e:t(o);if(null==r)continue;const s=r+"";""!==s&&n.add(s)}return Array.from(n)},[L,Ae,Me,m,Le]),Re=t.useMemo(()=>{if(!L)return a.marginDefaults;const e=Ne.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,Ne,Te,Le,a.marginDefaults]),$e=as({data:pe,rawData:l,colorBy:Ae,colorScheme:x,legendInteraction:U,legendPosition:K,selection:E,linkedHover:F,fallbackFields:Ae?["string"==typeof Ae?Ae:""]:[],unwrapData:!1,onObservation:H,onClick:z,hoverHighlight:W,chartType:"LineChart",chartId:Y,showLegend:(!L||void 0!==ae)&&ae,userMargin:c,marginDefaults:Re,loading:q,loadingContent:V,emptyContent:X,width:oe,height:ie}),De=$e.colorScale,Be=$e.customHoverBehavior,Ie=$e.customClickBehavior,Ee=$e.crosshairProps,Fe=cs({lineWidth:C,colorBy:Ae,colorScale:De,color:J,fillArea:j,areaOpacity:S,stroke:ee,strokeWidth:te,opacity:ne,effectiveSelectionHook:$e.effectiveSelectionHook,resolvedSelection:$e.resolvedSelection}),[He,ze]=t.useState(null);t.useEffect(()=>{if(!R)return void ze(null);let e=!1;return function(...e){return hs(this,void 0,void 0,function*(){return(yield ps()).createSegmentLineStyle(...e)})}(Fe,R).then(t=>{e||ze(()=>t)}).catch(()=>{e||ze(null)}),()=>{e=!0}},[Fe,R]);const We=He||Fe,Ge=t.useMemo(()=>{if(k)return e=>{const t={r:A,fillOpacity:1};return Ae?De&&(t.fill=we(e.parentLine||e,Ae,De)):t.fill=J||kr,t}},[k,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 g?g:e=>e[g],n="function"==typeof p?p:e=>e[p],o="function"==typeof Ae?Ae:e=>e[Ae],i=new Map;for(const t of Me){const n=t[m]||[];if(0===n.length)continue;const r="end"===Le?n[n.length-1]:n[0],s=null!==(e=o(r))&&void 0!==e?e:o(t);if(null==s)continue;const a=s+"";""===a||i.has(a)||i.set(a,r)}const r=Array.from(i.entries()).map(([e,o])=>({type:"text",label:e,["string"==typeof g?g:"x"]:t(o),["string"==typeof p?p:"y"]:n(o),dx:"end"===Le?6:-6,dy:0,color:De?De(e):kr,fontSize:Te}));r.sort((e,t)=>{const n="string"==typeof p?p:"y";return e[n]-t[n]});for(let e=1;r.length>e;e++){const t="string"==typeof p?p:"y",n=r[e-1],o=r[e];Te+2>Math.abs(o[t]+o.dy-(n[t]+n.dy))&&(o.dy+=Te+2)}return r},[L,Ae,De,Me,m,g,p,Le,Te]),Ve=$e.margin,Xe=y||b,Ue=t.useMemo(()=>Hr([{label:he||Dr(g),accessor:g,role:"x",format:d},{label:fe||Dr(p),accessor:p,role:"y",format:h},...Xe?[{label:Dr(Xe),accessor:Xe,role:"group"}]:[],...Fr($,h)]),[g,p,he,fe,Xe,d,h,$]),Ke=os({componentName:"LineChart",data:Ce?(null===(r=pe[0])||void 0===r?void 0:r[m])||[]:l,accessors:{xAccessor:g,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}):ke,[Me,m,Ce,be,ke,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(Object.assign({chartType:Ye},Array.isArray(j)&&{areaGroups:j}),O&&{lineGradient:O}),null!=G&&{hoverRadius:G}),null!=l&&{data:Qe}),{xAccessor:g,yAccessor:p,xScaleType:Q,yScaleType:Z}),D&&{xExtent:D}),!B||null==B[0]&&null==B[1]?je?{yExtent:je}:{}:{yExtent:B}),{groupAccessor:"break"===T&&Pe?"_gapSegment":be||void 0}),$&&{band:$}),{curve:w,lineStyle:We}),k&&{pointStyle:Ge}),{size:[oe,ie],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Ve,showAxes:a.showAxes,xLabel:he,yLabel:fe,xFormat:d,yFormat:h}),void 0!==f&&{axisExtent:f}),void 0!==n.autoPlaceAnnotations&&{autoPlaceAnnotations:n.autoPlaceAnnotations}),{enableHover:re,showGrid:se}),$e.legendBehaviorProps),le&&{title:le}),ce&&{description:ce}),ue&&{summary:ue}),void 0!==de&&{accessibleTable:de}),u&&{className:u}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===M?()=>null:"multi"===M?Jo():ei(M)||Ue}),"multi"===M&&{tooltipMode:"multi"}),(F||H||z||W)&&{customHoverBehavior:Be}),(H||z||F)&&{customClickBehavior:Ie}),P&&{pointIdAccessor:P}),((null==_?void 0:_.length)||ye.length||qe.length)&&{annotations:[..._||[],...ye,...qe]}),Ee),I);return $e.earlyReturn?$e.earlyReturn:Ke?e.jsx(Wr,{componentName:"LineChart",message:Ke,width:oe,height:ie}):e.jsx(Vr,{componentName:"LineChart",width:oe,height:ie,children:e.jsx(Fi,Object.assign({ref:s},Ze))})});function xs(e){const{title:t,description:n,summary:o,accessibleTable:i,className:r,animate:s,axisExtent:a,autoPlaceAnnotations:l}=e,c={};return t&&(c.title=t),n&&(c.description=n),o&&(c.summary=o),void 0!==i&&(c.accessibleTable=i),r&&(c.className=r),null!=s&&(c.animate=s),void 0!==a&&(c.axisExtent=a),void 0!==l&&(c.autoPlaceAnnotations=l),c}function ws(e){const{linkedHover:t,onObservation:n,onClick:o,hoverHighlight:i,customHoverBehavior:r,customClickBehavior:s,linkedHoverInClickPredicate:a=!0}=e,l={};return(t||n||o||i)&&(l.customHoverBehavior=r),(a?n||o||t:n||o)&&(l.customClickBehavior=s),l}function ks(e){const{tooltip:t,defaultTooltipContent:n}=e;return{tooltipContent:!1===t?()=>null:ei(t)||n}}function As(e){var n;const{safeData:o,data:i,areaBy:r,lineDataAccessor:s,colorBy:a,colorScale:l,color:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:f,resolvedSelection:g,areaOpacity:p,showLine:y,lineWidth:m,showPoints:v,pointRadius:b,xAccessor:x,yAccessor:w,xLabel:k,yLabel:A,xFormat:j,yFormat:S,groupField:C}=e,O=void 0!==(null===(n=o[0])||void 0===n?void 0:n[s]),M=t.useMemo(()=>{if(null==i)return[];if(!O&&!r)return o;let e;if(O)e=o;else{const t=r,n=o.reduce((e,n)=>{const o="function"==typeof t?t(n):n[t];if(!e[o]){const n={[s]:[]};"string"==typeof t&&(n[t]=o),e[o]=n}return e[o][s].push(n),e},{});e=Object.values(n)}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,o,r,s,O]),P=t.useMemo(()=>e=>{const t={};if(a){if(l){const n=we(e,a,l);t.fill=n,y?(t.stroke=n,t.strokeWidth=m):t.stroke="none"}}else{const e=c||kr;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(()=>ls(P,{stroke:u,strokeWidth:d,opacity:h}),[P,u,d,h]);return{flattenedData:M,lineStyle:t.useMemo(()=>fr(_,null!=f?f:null,g),[_,f,g]),pointStyle:t.useMemo(()=>{if(v)return e=>{const t={r:b,fillOpacity:1};return a?l&&(t.fill=we(e.parentLine||e,a,l)):t.fill=c||kr,t}},[v,b,a,l,c]),defaultTooltipContent:t.useMemo(()=>Hr([{label:k||Dr(x),accessor:x,role:"x",format:j},{label:A||Dr(w),accessor:w,role:"y",format:S},...C?[{label:Dr(C),accessor:C,role:"group"}]:[],...Fr(e.band,S)]),[x,w,k,A,C,j,S,e.band])}}function js(e,t){if(null==t)return e;const n=e.trim(),o=n.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(o){const e=o[1],n=3===e.length?e.split("").map(e=>e+e).join(""):e;return`rgba(${parseInt(n.slice(0,2),16)}, ${parseInt(n.slice(2,4),16)}, ${parseInt(n.slice(4,6),16)}, ${t})`}if(n.startsWith("rgba(")){const e=n.lastIndexOf(","),o=n.lastIndexOf(")");if(-1!==e&&o>e)return`${n.slice(0,e+1)} ${t})`}return n.startsWith("rgb(")?n.replace(/^rgb\(/,"rgba(").replace(/\)$/,`, ${t})`):e}bs.displayName="LineChart";const Ss=t.forwardRef(function(n,o){const i=t.useRef(null);us(o,{variant:"xy",frameRef:i});const r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:f,y0Accessor:g,gradientFill:p=!1,semanticGradient:y,lineDataAccessor:m="coordinates",colorBy:b,colorScheme:x,curve:w="monotoneX",areaOpacity:k=.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:N,yExtent:R,frameProps:$={},selection:D,linkedHover:B,onObservation:I,onClick:E,hoverHighlight:F,chartId:H,loading:z,loadingContent:W,emptyContent:G,legendInteraction:Y,legendPosition:q,color:V,stroke:X,strokeWidth:U,opacity:K}=n,{width:Q,height:Z,enableHover:J,showGrid:ee,showLegend:te,title:ne,description:oe,summary:ie,accessibleTable:re,xLabel:se,yLabel:ae}=r,le=t.useMemo(()=>v(s),[s]),ce=b||f,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:js(e.color,e.opacity)})).sort((e,t)=>e.offset-t.offset))}:p;var e},[y,p]);Zr("AreaChart",le,"xAccessor",d),Zr("AreaChart",le,"yAccessor",h);const de=as({data:le,rawData:s,colorBy:ce,colorScheme:x,legendInteraction:Y,legendPosition:q,selection:D,linkedHover:B,fallbackFields:ce?["string"==typeof ce?ce:""]:[],unwrapData:!1,onObservation:I,onClick:E,hoverHighlight:F,chartType:"AreaChart",chartId:H,showLegend:te,userMargin:a,marginDefaults:r.marginDefaults,loading:z,loadingContent:W,emptyContent:G,width:Q,height:Z}),{effectiveData:he,statisticalAnnotations:fe}=vs({data:le,xAccessor:d,yAccessor:h,forecast:_,anomaly:L,groupBy:f}),{flattenedData:ge,lineStyle:pe,pointStyle:ye,defaultTooltipContent:me}=As({safeData:he,data:s,areaBy:f,lineDataAccessor:m,colorBy:ce,colorScale:de.colorScale,color:V,stroke:X,strokeWidth:U,opacity:K,effectiveSelectionHook:de.effectiveSelectionHook,resolvedSelection:de.resolvedSelection,areaOpacity:k,showLine:j,lineWidth:S,showPoints:C,pointRadius:O,xAccessor:d,yAccessor:h,xLabel:se,yLabel:ae,xFormat:c,yFormat:u,groupField:f||b,band:T}),ve=os({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:ge}),{xAccessor:d,yAccessor:h,groupAccessor:f||void 0}),g&&{y0Accessor:g}),T&&{band:T}),ue&&{gradientFill:ue}),A&&{lineGradient:A}),{curve:w,lineStyle:pe}),C&&ye&&{pointStyle:ye}),{size:[Q,Z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:de.margin,showAxes:r.showAxes,xLabel:se,yLabel:ae,xFormat:c,yFormat:u,enableHover:J}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:ee}),de.legendBehaviorProps),xs({title:ne,description:oe,summary:ie,accessibleTable:re,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),"multi"===M?{tooltipContent:Jo(),tooltipMode:"multi"}:ks({tooltip:M,defaultTooltipContent:me})),ws({linkedHover:B,onObservation:I,onClick:E,hoverHighlight:F,customHoverBehavior:de.customHoverBehavior,customClickBehavior:de.customClickBehavior})),(P&&P.length>0||fe.length>0)&&{annotations:[...P||[],...fe]}),N&&{xExtent:N}),R&&{yExtent:R}),de.crosshairProps),$);return de.earlyReturn?de.earlyReturn:ve?e.jsx(Wr,{componentName:"AreaChart",message:ve,width:Q,height:Z}):e.jsx(Vr,{componentName:"AreaChart",width:Q,height:Z,children:e.jsx(Fi,Object.assign({ref:i},be))})});function Cs(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}Ss.displayName="AreaChart";const Os=t.forwardRef(function(n,o){const i=t.useRef(null),r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",seriesAAccessor:h="a",seriesBAccessor:f="b",seriesALabel:g="A",seriesBLabel:p="B",seriesAColor:y="var(--semiotic-danger, #dc2626)",seriesBColor:m="var(--semiotic-info, #2563eb)",showLines:b=!0,lineWidth:x=1.5,showPoints:w=!1,pointRadius:k=3,curve:A="linear",areaOpacity:j=.6,gradientFill:S,tooltip:C,annotations:O,xExtent:M,yExtent:P,frameProps:_={},selection:L,linkedHover:T,onObservation:N,onClick:R,hoverHighlight:$,chartId:D,loading:B,loadingContent:I,emptyContent:E,legendInteraction:F,legendPosition:H,pointIdAccessor:z,windowSize:W}=n,{width:G,height:Y,enableHover:q,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,xLabel:J,yLabel:ee}=r,te=t.useMemo(()=>"function"==typeof d?e=>Cs(d(e)):e=>Cs(e[d]),[d]),ne=t.useMemo(()=>"function"==typeof h?e=>Cs(h(e)):e=>Cs(e[h]),[h]),oe=t.useMemo(()=>"function"==typeof f?e=>Cs(f(e)):e=>Cs(e[f]),[f]),[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,n,o){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),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),f=(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],g=t(r),p=n(r),y=o(r);if(!Number.isFinite(g)||!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 n=p-l.a-(y-l.b);if(0!==n){const o=Math.max(0,Math.min(1,(l.b-l.a)/n));e=l.x+o*(g-l.x),t=l.a+o*(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++)f(c[e],a)}else for(const e of c)f(e,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else{a=m;for(const e of c)f(e,a);c=[],h({__x:g,__y:y>p?y:p,__y0:y>p?p:y,__diffSegment:d(a),__diffWinner:a,__valA:p,__valB:y,__sourceDatum:r}),l={x:g,a:p,b:y,w:m}}else c.push({x:g,y:p,datum:r})}for(const e of c)f(e,null!=a?a:"A");return r}(le,te,ne,oe),[le,te,ne,oe]),ue=t.useMemo(()=>b?function(e,t,n,o){if(!e.length)return[];const i=e.filter(e=>Number.isFinite(t(e))).sort((e,n)=>t(e)-t(n)),r=[];for(const e of i){const i=t(e),s=n(e),a=o(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,ne,oe):[],[b,le,te,ne,oe]),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(o,()=>{const e=e=>{const t=W&&e.length>W?e.slice(e.length-W):e;se.current=t,re(t)},t=z?"function"==typeof z?z:e=>e[z]:null;return{push:t=>e([...se.current,t]),pushMany:t=>e([...se.current,...t]),remove:n=>{if(!t)return[];const o=Array.isArray(n)?n:[n],i=[],r=[];for(const e of se.current)o.includes(t(e))?i.push(e):r.push(e);return e(r),i},update:(n,o)=>{if(!t)return[];const i=Array.isArray(n)?n:[n],r=[],s=se.current.map(e=>{if(i.includes(t(e))){const t=o(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,W]);const fe=as({data:le,rawData:s,colorBy:"__diffWinner",colorScheme:[y,m],legendInteraction:F,legendPosition:H,selection:L,linkedHover:T,fallbackFields:["__diffWinner"],unwrapData:!1,onObservation:N,onClick:R,hoverHighlight:$,chartType:"DifferenceChart",chartId:D,showLegend:X,userMargin:a,marginDefaults:r.marginDefaults,loading:B,loadingContent:I,emptyContent:E,width:G,height:Y}),ge=t.useMemo(()=>{if(!1!==X)return{legendGroups:[{label:"",type:"fill",styleFn:e=>({fill:e.color||"currentColor"}),items:[{label:g,color:y},{label:p,color:m}]}]}},[X,g,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:k}),[y,m,k]),ve=t.useCallback(t=>{var n;const o=t.data,i=t.allSeries,r=null!==(n=t.xValue)&&void 0!==n?n:null==o?void 0:o.__x;let s=null==o?void 0:o.__valA,a=null==o?void 0:o.__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=ne(e)),null==a&&(a=oe(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:Uo,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:[g,": ",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,ne,oe,c,y,m,g,p]),be="multi"===C,xe=t.useMemo(()=>!1===C?()=>null:be?ve:ei(C)||ve,[C,be,ve]);if(fe.earlyReturn)return fe.earlyReturn;const we=Object.assign(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},w&&{pointStyle:me}),{size:[G,Y],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:fe.margin,showAxes:r.showAxes,xLabel:J,yLabel:ee,xFormat:c,yFormat:u,enableHover:q,showGrid:V}),S&&{gradientFill:!0===S?{topOpacity:.85,bottomOpacity:.15}:S}),ge&&{legend:ge,legendPosition:fe.legendPosition}),xs({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),{tooltipContent:xe}),be&&{tooltipMode:"multi"}),ws({linkedHover:T,onObservation:N,onClick:R,hoverHighlight:$,customHoverBehavior:fe.customHoverBehavior,customClickBehavior:fe.customClickBehavior})),O&&O.length>0&&{annotations:O}),M&&{xExtent:M}),P&&{yExtent:P}),fe.crosshairProps),_);return e.jsx(Vr,{componentName:"DifferenceChart",width:G,height:Y,children:e.jsx(Fi,Object.assign({ref:i},we))})});"function"==typeof Os&&(Os.displayName="DifferenceChart");const Ms=t.forwardRef(function(n,o){const i=t.useRef(null),r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",areaBy:f,lineDataAccessor:g="coordinates",colorBy:p,colorScheme:y,curve:m="monotoneX",areaOpacity:b=.7,showLine:x=!0,lineWidth:w=2,showPoints:k=!1,pointRadius:A=3,normalize:j=!1,baseline:S="zero",stackOrder:C,tooltip:O,annotations:M,xExtent:P,yExtent:_,frameProps:L={},selection:T,linkedHover:N,onObservation:R,onClick:$,hoverHighlight:D,chartId:B,loading:I,loadingContent:E,emptyContent:F,legendInteraction:H,legendPosition:z,color:W,stroke:G,strokeWidth:Y,opacity:q}=n,{width:V,height:X,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,xLabel:ne,yLabel:oe}=r,ie=t.useMemo(()=>v(s),[s]),re=p||f;us(o,{variant:"xy",frameRef:i});const se=as({data:ie,rawData:s,colorBy:re,colorScheme:y,legendInteraction:H,legendPosition:z,selection:T,linkedHover:N,fallbackFields:re?["string"==typeof re?re:""]:[],unwrapData:!1,onObservation:R,onClick:$,hoverHighlight:D,chartType:"StackedAreaChart",chartId:B,showLegend:Q,userMargin:a,marginDefaults:r.marginDefaults,loading:I,loadingContent:E,emptyContent:F,width:V,height:X}),{flattenedData:ae,lineStyle:le,pointStyle:ce,defaultTooltipContent:ue}=As({safeData:ie,data:s,areaBy:f,lineDataAccessor:g,colorBy:re,colorScale:se.colorScale,color:W,stroke:G,strokeWidth:Y,opacity:q,effectiveSelectionHook:se.effectiveSelectionHook,resolvedSelection:se.resolvedSelection,areaOpacity:b,showLine:x,lineWidth:w,showPoints:k,pointRadius:A,xAccessor:d,yAccessor:h,xLabel:ne,yLabel:oe,xFormat:c,yFormat:u,groupField:f||p}),de=os({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:f||void 0,curve:m,normalize:j,baseline:j?"zero":S,stackOrder:C,lineStyle:le}),k&&ce&&{pointStyle:ce}),{size:[V,X],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:se.margin,showAxes:r.showAxes,xLabel:ne,yLabel:oe,xFormat:c,yFormat:u,enableHover:U}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:K}),se.legendBehaviorProps),xs({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),"multi"===O?{tooltipContent:Jo(),tooltipMode:"multi"}:ks({tooltip:O,defaultTooltipContent:ue})),ws({linkedHover:N,onObservation:R,onClick:$,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(Wr,{componentName:"StackedAreaChart",message:de,width:V,height:X}):e.jsx(Vr,{componentName:"StackedAreaChart",width:V,height:X,children:e.jsx(Fi,Object.assign({ref:i},he))})});function Ps(e){const{colorBy:n,colorScale:o,color:i,pointRadius:r=5,radiusFn:s,fillOpacity:a=1,fallbackFill:l,baseStyleExtras:c,stroke:u,strokeWidth:d,opacity:h,effectiveSelectionHook:f,resolvedSelection:g,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(n){if(o){const t=p?p(e):e;u.fill=we(t,n,o)}}else u.fill=l?l(e):i||kr;return void 0===u.r&&(u.r=s?s(e):r),u},[n,o,i,r,s,a,l,c,p]),m=t.useMemo(()=>ls(y,{stroke:u,strokeWidth:d,opacity:h}),[y,u,d,h]);return t.useMemo(()=>fr(m,null!=f?f:null,g),[m,f,g])}function _s(e){const{accessor:n,data:o,isPushMode:i}=e,r=t.useRef(null),[s,a]=t.useState(0),l=t.useCallback(e=>{if(!i||!n)return;let t=!1;for(const o of e){const e="function"==typeof n?n(o):o[n];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,n]),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(!n||0===o.length)return;const t="function"==typeof n?n:e=>e[n];let s=1/0,a=-1/0;for(const e of o){const n=t(e);if(null==n)continue;const o="number"==typeof n?n:Number(n);Number.isFinite(o)&&(s>o&&(s=o),o>a&&(a=o))}return Number.isFinite(s)&&Number.isFinite(a)?[s,a]:void 0},[o,n,i,s]);return{domain:u,trackPushed:l,reset:c}}function Ls(e){var t;if(!e)return;const n="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=n.method)&&void 0!==t?t:"linear"},null!=n.bandwidth&&{bandwidth:n.bandwidth}),null!=n.order&&{order:n.order}),null!=n.color&&{color:n.color}),null!=n.strokeWidth&&{strokeWidth:n.strokeWidth}),null!=n.strokeDasharray&&{strokeDasharray:n.strokeDasharray}),null!=n.label&&{label:n.label})}Ms.displayName="StackedAreaChart";const Ts=t.forwardRef(function(n,o){const i=t.useRef(null),r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xScaleType:f,yScaleType:g,colorBy:y,colorScheme:m,sizeBy:b,sizeRange:x=[3,15],pointRadius:w=5,pointOpacity:k=.8,tooltip:A,marginalGraphics:j,pointIdAccessor:S,annotations:C,regression:O,forecast:M,anomaly:P,xExtent:_,yExtent:L,frameProps:T={},selection:N,linkedHover:R,linkedBrush:$,onObservation:D,onClick:B,hoverHighlight:I,chartId:E,loading:F,loadingContent:H,emptyContent:z,legendInteraction:W,legendPosition:G,color:Y,stroke:q,strokeWidth:V,opacity:X}=n,{width:U,height:K,enableHover:Q,showGrid:Z,showLegend:J,title:ee,description:te,summary:ne,accessibleTable:oe,xLabel:ie,yLabel:re}=r,se=t.useMemo(()=>v(s),[s]),ae=void 0===s,{domain:le,trackPushed:ce,reset:ue}=_s({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]);us(o,{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 fe=as({data:se,rawData:s,colorBy:y,colorScheme:m,legendInteraction:W,legendPosition:G,selection:N,linkedHover:R,fallbackFields:y?["string"==typeof y?y:""]:[],unwrapData:!1,onObservation:D,onClick:B,hoverHighlight:I,chartType:"Scatterplot",chartId:E,showLegend:J,userMargin:a,marginDefaults:r.marginDefaults,loading:F,loadingContent:H,emptyContent:z,width:U,height:K}),ge=hr($),pe=er({name:(null==ge?void 0:ge.name)||"__unused_brush__",xField:(null==ge?void 0:ge.xField)||("string"==typeof d?d:void 0),yField:(null==ge?void 0:ge.yField)||("string"==typeof h?h:void 0)}),ye=ge?"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)},[]);Zr("Scatterplot",se,"xAccessor",d),Zr("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]),we=Ps({colorBy:y,colorScale:fe.colorScale,color:Y,pointRadius:w,fillOpacity:k,radiusFn:xe,stroke:q,strokeWidth:V,opacity:X,effectiveSelectionHook:fe.effectiveSelectionHook,resolvedSelection:fe.resolvedSelection}),ke=t.useMemo(()=>Hr([{label:ie||Dr(d),accessor:d,role:"x",format:c},{label:re||Dr(h),accessor:h,role:"y",format:u},...y?[{label:Dr(y),accessor:y,role:"color"}]:[],...b?[{label:Dr(b),accessor:b,role:"size"}]:[]]),[d,h,ie,re,y,b,c,u]),{effectiveData:je,statisticalAnnotations:Se}=vs({data:se,xAccessor:d,yAccessor:h,forecast:M,anomaly:P}),Ce=t.useMemo(()=>{const e=Ls(O);return e||0!==Se.length?[...e?[e]:[],...C||[],...Se]:C},[O,C,Se]);if(fe.earlyReturn)return fe.earlyReturn;const Oe=os({componentName:"Scatterplot",data:s,accessors:{xAccessor:d,yAccessor:h}});if(Oe)return e.jsx(Wr,{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:f,yScaleType:g,colorAccessor:y||void 0,sizeAccessor:b||void 0,sizeRange:x,pointStyle:we,colorScheme:m,size:[U,K],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:fe.margin,showAxes:r.showAxes,xLabel:ie,yLabel:re,xFormat:c,yFormat:u,enableHover:Q,showGrid:Z}),fe.legendBehaviorProps),xs({title:ee,description:te,summary:ne,accessibleTable:oe,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:A,defaultTooltipContent:ke})),ws({linkedHover:R,onObservation:D,onClick:B,hoverHighlight:I,customHoverBehavior:fe.customHoverBehavior,customClickBehavior:fe.customClickBehavior})),j&&{marginalGraphics:j}),S&&{pointIdAccessor:S}),Ce&&Ce.length>0&&{annotations:Ce}),_&&{xExtent:_}),L&&{yExtent:L}),ge&&{brush:{dimension:ye},onBrush:ve}),fe.crosshairProps),T);return e.jsx(Vr,{componentName:"Scatterplot",width:U,height:K,children:e.jsx(Fi,Object.assign({ref:i},Me))})});function Ns(e,t){return oe(1===t?.5:e/(t-1))}Ts.displayName="Scatterplot";const Rs=t.forwardRef(function(n,o){var i,r;const s=t.useRef(null);us(o,{variant:"xy",frameRef:s});const a=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:u,xFormat:d,yFormat:h,xAccessor:f="x",yAccessor:g="y",orderAccessor:p,orderLabel:y,pointRadius:m=4,tooltip:v,pointIdAccessor:b,annotations:x,regression:w,forecast:k,anomaly:A,xExtent:j,yExtent:S,frameProps:C={},selection:O,linkedHover:M,onObservation:P,onClick:_,hoverHighlight:L,chartId:T,loading:N,loadingContent:R,emptyContent:$,legendInteraction:D,stroke:B,strokeWidth:I,opacity:E}=n,{width:F,height:H,enableHover:z,showGrid:W,title:G,description:Y,summary:q,accessibleTable:V,xLabel:X,yLabel:U}=a,K=l||[],{safeData:Q,orderMap:Z}=t.useMemo(()=>{const e="function"==typeof f?f:e=>e[f],t="function"==typeof g?g:e=>e[g];let n=K;if(p&&K.length>0){const e="function"==typeof p?p:e=>e[p];n=[...K].sort((t,n)=>{const o=e(t),i=e(n);return(o instanceof Date?o.getTime():+o)-(i instanceof Date?i.getTime():+i)})}const o=new WeakMap;let i=0;for(const o of n){const n=e(o),r=t(o);null!=n&&null!=r&&isFinite(n)&&isFinite(r)&&i++}let r=0;for(const s of n){const n=e(s),a=t(s);null!=n&&null!=a&&isFinite(n)&&isFinite(a)&&o.set(s,{idx:r++,total:i})}return{safeData:n,orderMap:o}},[K,p,f,g]);Zr("ConnectedScatterplot",Q,"xAccessor",f),Zr("ConnectedScatterplot",Q,"yAccessor",g);const J=as({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:N,loadingContent:R,emptyContent:$,width:F,height:H}),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 n,o,i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return;const a=null===(n=J.effectiveSelectionHook)||void 0===n?void 0:n.isActive,l=null===(o=J.effectiveSelectionHook)||void 0===o?void 0:o.predicate,c=100>s.length,u=s.length;e.lineCap="round";for(let t=0;u-1>t;t++){const n=s[t],o=s[t+1],d=Ns(t,u),h=!a||!l||l(null!==(i=n.datum)&&void 0!==i?i:n)||l(null!==(r=o.datum)&&void 0!==r?r:o),f=a?h?1:ee:1;c&&(e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(o.x,o.y),e.strokeStyle="white",e.lineWidth=m+2,e.globalAlpha=.5*f,e.stroke()),e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(o.x,o.y),e.strokeStyle=d,e.lineWidth=m,e.globalAlpha=f,e.stroke()}e.globalAlpha=1},[m,J.effectiveSelectionHook,ee]),ne=t.useMemo(()=>[te],[te]),oe=t.useMemo(()=>(t,n,o)=>{var i,r;const s=t.filter(e=>"point"===e.type);if(2>s.length)return null;const a=s.length,l=100>a,c=[];for(let t=0;a-1>t;t++){const n=s[t],o=s[t+1],u=Ns(t,a),d="number"==typeof(null===(i=n.style)||void 0===i?void 0:i.opacity)?n.style.opacity:1,h="number"==typeof(null===(r=o.style)||void 0===r?void 0:r.opacity)?o.style.opacity:1,f=Math.min(d,h);l&&c.push(e.jsx("line",{x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:"white",strokeWidth:m+2,strokeLinecap:"round",opacity:.5*f},"halo-"+t)),c.push(e.jsx("line",{x1:n.x,y1:n.y,x2:o.x,y2:o.y,stroke:u,strokeWidth:m,strokeLinecap:"round",opacity:f},"seg-"+t))}return e.jsx(e.Fragment,{children:c})},[m]),ie=t.useMemo(()=>[oe],[oe]),re=t.useMemo(()=>e=>{var t,n;const o=Z.get(e),i=null!==(t=null==o?void 0:o.idx)&&void 0!==t?t:0,r=null!==(n=null==o?void 0:o.total)&&void 0!==n?n:1;return{fill:r>0?Ns(i,r):"#6366f1",stroke:"white",strokeWidth:1,r:m,fillOpacity:1}},[m,Z]),se=Ps({colorScale:void 0,baseStyleExtras:re,stroke:B,strokeWidth:I,opacity:E,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection}),ae=y||("string"==typeof p?p:"Order"),le=t.useMemo(()=>Hr([{label:X||Dr(f),accessor:f,role:"x",format:d},{label:U||Dr(g),accessor:g,role:"y",format:h},...p?[{label:ae,accessor:p,role:"group"}]:[]]),[f,g,X,U,p,ae,d,h]),ce=os({componentName:"ConnectedScatterplot",data:l,accessors:{xAccessor:f,yAccessor:g}}),{effectiveData:ue,statisticalAnnotations:de}=vs({data:Q,xAccessor:f,yAccessor:g,forecast:k,anomaly:A});if(J.earlyReturn)return J.earlyReturn;const he=Ls(w),fe=he||de.length>0?[...he?[he]:[],...x||[],...de]:x,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({chartType:"scatter"},null!=l&&{data:ue}),{xAccessor:f,yAccessor:g,pointStyle:se,size:[F,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:J.margin,showAxes:a.showAxes,xLabel:X,yLabel:U,xFormat:d,yFormat:h,enableHover:z,showGrid:W}),xs({title:G,description:Y,summary:q,accessibleTable:V,className:u,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:v,defaultTooltipContent:le})),ws({linkedHover:M,onObservation:P,onClick:_,hoverHighlight:L,customHoverBehavior:J.customHoverBehavior,customClickBehavior:J.customClickBehavior})),b&&{pointIdAccessor:b}),{canvasPreRenderers:ne,svgPreRenderers:ie}),fe&&fe.length>0&&{annotations:fe}),j&&{xExtent:j}),S&&{yExtent:S}),J.crosshairProps),C);return ce?e.jsx(Wr,{componentName:"ConnectedScatterplot",message:ce,width:F,height:H}):e.jsx(Vr,{componentName:"ConnectedScatterplot",width:F,height:H,children:e.jsx(Fi,Object.assign({ref:s},ge))})});Rs.displayName="ConnectedScatterplot";const $s=t.forwardRef(function(n,o){const i=t.useRef(null),r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",sizeBy:f,sizeRange:g=[5,40],colorBy:p,colorScheme:y,bubbleOpacity:m=.6,bubbleStrokeWidth:b=1,bubbleStrokeColor:x="white",tooltip:w,marginalGraphics:k,pointIdAccessor:A,annotations:j,regression:S,xExtent:C,yExtent:O,frameProps:M={},selection:P,linkedHover:_,linkedBrush:L,onObservation:T,onClick:N,hoverHighlight:R,chartId:$,loading:D,loadingContent:B,emptyContent:I,legendInteraction:E,legendPosition:F,color:H,stroke:z,strokeWidth:W,opacity:G}=n,{width:Y,height:q,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,ne=t.useMemo(()=>v(s),[s]),oe=void 0===s,ie=as({data:ne,rawData:s,colorBy:p,colorScheme:y,legendInteraction:E,legendPosition:F,selection:P,linkedHover:_,fallbackFields:p?["string"==typeof p?p:""]:[],unwrapData:!1,onObservation:T,onClick:N,hoverHighlight:R,chartType:"BubbleChart",chartId:$,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:B,emptyContent:I,width:Y,height:q}),{domain:re,trackPushed:se,reset:ae}=_s({accessor:f,data:ne,isPushMode:oe}),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]);us(o,{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=hr(L);er({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]),fe=t.useCallback(e=>Ae(e,f,g,he),[f,g,he]),ge=Ps({colorBy:p,colorScale:ie.colorScale,color:H,fillOpacity:m,radiusFn:fe,baseStyleExtras:de,stroke:z,strokeWidth:W,opacity:G,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection}),pe=t.useMemo(()=>Hr([{label:ee||Dr(d),accessor:d,role:"x",format:c},{label:te||Dr(h),accessor:h,role:"y",format:u},{label:Dr(f),accessor:f,role:"size"},...p?[{label:Dr(p),accessor:p,role:"color"}]:[]]),[d,h,ee,te,f,p,c,u]);if(ie.earlyReturn)return ie.earlyReturn;const ye=os({componentName:"BubbleChart",data:s,accessors:{xAccessor:d,yAccessor:h},requiredProps:{sizeBy:f}});if(ye)return e.jsx(Wr,{componentName:"BubbleChart",message:ye,width:Y,height:q});const me=Ls(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:ne}),{xAccessor:d,yAccessor:h,colorAccessor:p||void 0,sizeAccessor:f,sizeRange:g,pointStyle:ge,colorScheme:y,size:[Y,q],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ie.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:V,showGrid:X}),ie.legendBehaviorProps),xs({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:w,defaultTooltipContent:pe})),ws({linkedHover:_,onObservation:T,onClick:N,hoverHighlight:R,customHoverBehavior:ie.customHoverBehavior,customClickBehavior:ie.customClickBehavior})),k&&{marginalGraphics:k}),A&&{pointIdAccessor:A}),ve&&ve.length>0&&{annotations:ve}),C&&{xExtent:C}),O&&{yExtent:O}),ie.crosshairProps),M);return e.jsx(Vr,{componentName:"BubbleChart",width:Y,height:q,children:e.jsx(Fi,Object.assign({ref:i},be))})});$s.displayName="BubbleChart";const Ds=t.forwardRef(function(n,o){var r;const s=t.useRef(null);us(o,{variant:"xy",frameRef:s});const a=Rr(n.mode,{width:n.width,height:n.height,showGrid:void 0,enableHover:n.enableHover,showLegend:void 0,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:l,margin:c,className:u,xAccessor:d="x",yAccessor:h="y",valueAccessor:f="value",xFormat:g,yFormat:p,colorScheme:y,customColorScale:m,showValues:b=!1,valueFormat:x,tooltip:w,annotations:k,xExtent:A,yExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:N,emptyContent:R,showLegend:$,legendPosition:D,legendInteraction:B}=n,{width:I,height:E,enableHover:F,title:H,description:z,summary:W,accessibleTable:G,xLabel:Y,yLabel:q}=a,V=Qr(T,I,E,N),X=V?null:Kr(l,I,E,R),U=t.useMemo(()=>v(l),[l]),K=function(){var e;const t=wr();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!=$&&$,de=null!=D?D:"right",{margin:he}=Lr({data:U,colorBy:ue?"value":void 0,colorScale:void 0,showLegend:ue,legendPosition:de,userMargin:c,defaults:a.marginDefaults}),{customHoverBehavior:fe,customClickBehavior:ge,crosshairSourceId:pe}=Pr({selection:C,linkedHover:O,fallbackFields:[],onObservation:M,onClick:P,chartType:"Heatmap",chartId:L,hoverHighlight:_,colorByField:void 0});ss(C);const ye=_r(O,pe);Tr(B,void 0,[]);const me=t.useMemo(()=>"function"==typeof f?e=>f(e):e=>e[f],[f]),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:oe,oranges:ee,purples:te,greys:ne,plasma:ie,inferno:re,magma:se,cividis:ae,turbo:le}[ce]||Q).domain(ve),[ce,m,ve]),xe=t.useMemo(()=>Hr([{label:Y||Dr(d),accessor:d,role:"x",format:g},{label:q||Dr(h),accessor:h,role:"y",format:p},{label:Dr(f),accessor:f,role:"value",format:x}]),[d,h,Y,q,f,g,p,x]),we=os({componentName:"Heatmap",data:l,accessors:{xAccessor:d,yAccessor:h,valueAccessor:f}}),ke=t.useMemo(()=>{if(ue)return{gradient:{colorFn:e=>be(e),domain:ve,label:"string"==typeof f?f:"value",format:x}}},[ue,be,ve,f,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:f,colorScheme:"custom"!==ce?ce:void 0,showValues:b,heatmapValueFormat:x,size:[I,E],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:he,showAxes:a.showAxes,xLabel:Y,yLabel:q,xFormat:g,yFormat:p,enableHover:F}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),ke&&{legend:ke,legendPosition:de}),xs({title:H,description:z,summary:W,accessibleTable:G,className:u,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:w,defaultTooltipContent:xe})),ws({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:fe,customClickBehavior:ge})),k&&k.length>0&&{annotations:k}),A&&{xExtent:A}),j&&{yExtent:j}),ye),S);return V||X||(we?e.jsx(Wr,{componentName:"Heatmap",message:we,width:I,height:E}):e.jsx(Vr,{componentName:"Heatmap",width:I,height:E,children:e.jsx(Fi,Object.assign({ref:s},Ae))}))});Ds.displayName="Heatmap";const Bs="__splomIdx",Is={top:4,bottom:4,left:4,right:4};function Es({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=n.select(a.current).select(".brush-g"),t=o.brush().extent([[0,0],[l,c]]).on("brush end",e=>{var t;const n=null===(t=i.current)||void 0===t?void 0:t.getScales();if(!n)return;if(!e.selection)return void s(null);const[[o,r],[a,l]]=e.selection,c=[[n.x.invert(o),n.y.invert(r)],[n.x.invert(a),n.y.invert(l)]];s(c)});return e.call(t),e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.15).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[l,c,i,s]),e.jsx("svg",{ref:a,width:r,height:r,style:{position:"absolute",top:0,left:0},children:e.jsx("g",{className:"brush-g",transform:`translate(${Is.left},${Is.top})`})})}function Fs({data:n,xField:o,yField:i,cellSize:r,pointRadius:s,pointOpacity:a,colorBy:l,colorScale:c,brushSelectionName:u,hoverSelectionName:d,unselectedOpacity:h,mode:f,onPointHover:g}){const p=t.useRef(null),y=Qi({name:u,clientId:`splom-${o}-${i}`}),m=er({name:u,xField:o,yField:i}),v=Qi({name:d,clientId:"splom-hover-source"}),b=v.selectPoints,x=t.useCallback(e=>{e?m.brushInteraction.during(e):m.brushInteraction.end(null)},[m.brushInteraction]),w=t.useCallback(e=>{if(!e)return void(null==g||g(null));const t=e.data,n=null==t?void 0:t[Bs];void 0!==n&&(b({[Bs]:[n]}),null==g||g(t,e.x+Is.left,e.y+Is.top))},[b,g]),k=t.useCallback(e=>{const t={opacity:a,r:s};return t.fill=l?we(e,l,c):kr,"hover"===f?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,f,y.isActive,y.predicate,v.isActive,v.predicate,h]);return e.jsxs("div",{style:{position:"relative",width:r,height:r},children:[e.jsx(Fi,{ref:p,chartType:"scatter",data:n,size:[r,r],xAccessor:o,yAccessor:i,pointStyle:k,margin:Is,showAxes:!1,enableHover:"hover"===f,customHoverBehavior:"hover"===f?w:void 0,tooltipContent:"hover"===f?()=>null:void 0}),"brush"===f&&e.jsx(Es,{frameRef:p,cellSize:r,xField:o,yField:i,onBrush:x})]})}function Hs({data:n,field:o,label:i,cellSize:r,bins:s,colorBy:a,colorScale:l,brushSelectionName:c,hoverSelectionName:u,mode:d}){const h=Qi({name:c,clientId:"splom-diag-"+o}),f=Qi({name:u,clientId:`splom-diag-${o}-hover`}),g="hover"===d?f:h,p=g.isActive,y=g.predicate,m=t.useMemo(()=>{const e=n.map(e=>e[o]).filter(e=>null!=e&&!isNaN(e));if(0===e.length)return{bars:[],selectedBars:[],categoryBars:[],selectedCategoryBars:[],max:0,categories:[]};const t=Math.min(...e),i=(Math.max(...e)-t)/s||1,l="string"==typeof a?a:null,c=l?[...new Set(n.map(e=>e[l]).filter(e=>null!=e).map(String))]:[],u=new Map(c.map((e,t)=>[e,t])),d=Array(s).fill(0),h=Array(s).fill(0),f=Array.from({length:s},()=>Array(c.length).fill(0)),g=Array.from({length:s},()=>Array(c.length).fill(0));for(const e of n){const n=e[o];if(null==n||isNaN(n))continue;const r=Math.min(Math.floor((n-t)/i),s-1);if(d[r]++,p&&!y(e)||h[r]++,l){const t=u.get(e[l]+"");void 0!==t&&(f[r][t]++,p&&!y(e)||g[r][t]++)}}const m=Math.max(...d,1),v=f.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:n,category:c[o]};return n+=i,a})}),b=g.map((e,t)=>{let n=0;return e.map((e,o)=>{const i=e/m*(r-24),a={x:t/s*r,w:r/s-1,h:i,y0:n,category:c[o]};return n+=i,a})});return{bars:d.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/m*(r-24),count:e})),selectedBars:h.map((e,t)=>({x:t/s*r,w:r/s-1,h:e/m*(r-24),count:e})),categoryBars:v,selectedCategoryBars:b,max:m,categories:c}},[n,o,s,r,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,n)=>t.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):kr,opacity:p?.3:.6},`bg-${n}-${o}`))):m.bars.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:kr,opacity:p?.3:.6},"bg-"+n)),p&&(m.categories.length>0?m.selectedCategoryBars.map((t,n)=>t.map((t,o)=>e.jsx("rect",{x:t.x,y:r-t.y0-t.h,width:Math.max(t.w,1),height:t.h,fill:l?l(t.category):kr,opacity:.7},`sel-${n}-${o}`))):m.selectedBars.map((t,n)=>e.jsx("rect",{x:t.x,y:r-t.h,width:Math.max(t.w,1),height:t.h,fill:kr,opacity:.7},"sel-"+n)))]})}function zs({label:t,cellSize:n}){return e.jsx("svg",{width:n,height:n,children:e.jsx("text",{x:n/2,y:n/2,textAnchor:"middle",dominantBaseline:"middle",fontSize:12,fontWeight:"bold",fill:"#333",children:t})})}function Ws(n){const{data:o,fields:i,fieldLabels:r={},colorBy:s,colorScheme:a,cellSize:l=150,cellGap:c=4,pointRadius:u=2,pointOpacity:d=.5,diagonal:h="histogram",histogramBins:f=20,brushMode:g="crossfilter",hoverMode:y=!0,unselectedOpacity:m=.1,showGrid:v=!1,tooltip:b,showLegend:x,idAccessor:w,className:k,onObservation:A,chartId:j}=n,S="splom",C="splom-hover",O=y?"hover":g?"brush":"hover",M=Xi(e=>e.clearSelection),[P,_]=t.useState(null),L=t.useCallback(()=>{M(C),_(null)},[M,C]),T=t.useMemo(()=>(o||[]).map((e,t)=>void 0!==e[Bs]?e:Object.assign(Object.assign({},e),{[Bs]:t})),[o]),N=Or(T,s,a),R=void 0!==x?x:!!s,$=t.useMemo(()=>{if(!R||!s)return null;const e="string"==typeof s?s:null;return e?[...new Set(T.map(t=>t[e]))].map(e=>({label:e+"",color:N?N(e+""):kr})):null},[R,s,T,N]),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:k,style:{position:"relative"},children:[$&&e.jsx("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:$.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,n)=>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((o,i)=>n===i?"label"===h?e.jsx(zs,{label:r[t]||t,cellSize:l},"diag-"+t):e.jsx(Hs,{data:T,field:t,label:r[t]||t,cellSize:l,bins:f,colorBy:s,colorScale:N,brushSelectionName:S,hoverSelectionName:C,unselectedOpacity:m,mode:O},"diag-"+t):e.jsx(Fs,{data:T,xField:o,yField:t,fieldLabels:r,cellSize:l,pointRadius:u,pointOpacity:d,colorBy:s,colorScale:N,brushSelectionName:S,hoverSelectionName:C,unselectedOpacity:m,showGrid:v,tooltip:b,mode:O,onPointHover:"hover"===O?(e,r,s)=>{e?(_({datum:e,xField:o,yField:t,colIndex:i,rowIndex:n,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}-${o}`))]},"row-"+t)),e.jsx("div",{})," ",i.map(t=>e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:"bold",color:"#333"},children:r[t]||t},"col-label-"+t))]}),P&&"hover"===O&&(()=>{const t=P.datum,n=r[P.xField]||P.xField,o=r[P.yField]||P.yField,i=s?"function"==typeof s?s(t):t[s]:null,a=w?"function"==typeof w?w(t):t[w]:"Row "+t[Bs];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:[n,": ",null!=t[P.xField]?Number(t[P.xField]).toFixed(1):"–"]}),e.jsxs("div",{children:[o,": ",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 Gs(t){const{brushMode:n="crossfilter",hoverMode:o=!0}=t,i={};return!o&&n&&(i.splom={resolution:n}),o&&(i["splom-hover"]={resolution:"union"}),e.jsx(ur,{selections:i,children:e.jsx(Ws,Object.assign({},t))})}function Ys({width:i,height:r,margin:s,scales:a,brushDirection:l,extent:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),f=t.useRef(!1),g=i+s.left+s.right,p=r+s.top+s.bottom;return t.useEffect(()=>{if(!d.current||!a)return;const e=n.select(d.current).select(".brush-group"),t="x"===l?o.brushX().extent([[0,0],[i,r]]):o.brushY().extent([[0,0],[i,r]]);return t.on("brush end",e=>{if(f.current)return;if(!e.sourceEvent)return;const t=e.selection;if(!t)return void u(null);const n=("x"===l?a.x:a.y).invert;if(!n)return;const o=[n(t[0]),n(t[1])];u(o)}),e.call(t),h.current=t,e.select(".selection").attr("fill","steelblue").attr("fill-opacity",.2).attr("stroke","steelblue").attr("stroke-width",1),()=>{t.on("brush end",null)}},[a,i,r,l,u]),t.useEffect(()=>{if(!h.current||!a||!d.current)return;const e=n.select(d.current).select(".brush-group"),t="x"===l?a.x:a.y;if(f.current=!0,c){const n=[t(c[0]),t(c[1])];e.call(h.current.move,n)}else e.call(h.current.move,null);f.current=!1},[c,a,l]),e.jsx("svg",{ref:d,width:g,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 qs(n){var o,i;const{data:r,width:s=600,height:a=400,margin:l,className:c,title:u,description:d,summary:h,xLabel:f,yLabel:g,xFormat:p,yFormat:y,xAccessor:m="x",yAccessor:b="y",lineBy:x,lineDataAccessor:w="coordinates",colorBy:k,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:N,tooltip:R,minimap:$={},renderBefore:D=!1,onBrush:B,brushExtent:I,yExtent:E,frameProps:F={},loading:H,loadingContent:z,emptyContent:W}=n,G=Qr(H,s,a,z),Y=G?null:Kr(r,s,a,W),q=t.useMemo(()=>v(r),[r]),[V,X]=t.useState(null),U=null!=I?I:V,K=t.useCallback(e=>{I||X(e),null==B||B(e)},[I,B]),Q=t.useRef(null),[Z,J]=t.useState(null);t.useEffect(()=>{let e=0,t=!1;const n=()=>{var o,i;if(t)return;const r=null===(i=null===(o=Q.current)||void 0===o?void 0:o.getScales)||void 0===i?void 0:i.call(o);r?J(r):e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>{t=!0,e&&cancelAnimationFrame(e)}},[r]);const ee=void 0!==(null===(o=q[0])||void 0===o?void 0:o[w]),te=t.useMemo(()=>{if(ee)return q;if(x){const e=q.reduce((e,t)=>{const n="function"==typeof x?x(t):t[x];if(!e[n]){const t={[w]:[]};"string"==typeof x&&(t[x]=n),e[n]=t}return e[n][w].push(t),e},{});return Object.values(e)}return[{[w]:q}]},[q,x,w,ee]),ne=t.useMemo(()=>ee||x?te.flatMap(e=>{const t=e[w]||[];return x&&"string"==typeof x?t.map(t=>Object.assign(Object.assign({},t),{[x]:e[x]})):t}):q,[te,w,ee,x,q]),oe=Or(q,k,A),ie=cs({lineWidth:S,colorBy:k,colorScale:oe,fillArea:C,areaOpacity:O}),re=t.useMemo(()=>{if($.lineStyle)return $.lineStyle},[$.lineStyle]),se=cs({lineWidth:1,colorBy:k,colorScale:oe}),ae=null!=re?re:se,le=t.useMemo(()=>{if(M)return e=>{const t={r:P,fillOpacity:1};return t.fill=k?we(e.parentLine||e,k,oe):kr,t}},[M,P,k,oe]),{legend:ce,margin:ue,legendPosition:de}=Lr({data:te,colorBy:k,colorScale:oe,showLegend:T,legendPosition:N,userMargin:l}),he=$.height||60,fe=t.useMemo(()=>{var e,t,n,o,i,r,s,a;return{top:null!==(t=null===(e=$.margin)||void 0===e?void 0:e.top)&&void 0!==t?t:0,bottom:null!==(o=null===(n=$.margin)||void 0===n?void 0:n.bottom)&&void 0!==o?o:20,left:null!==(r=null===(i=$.margin)||void 0===i?void 0:i.left)&&void 0!==r?r:ue.left,right:null!==(a=null===(s=$.margin)||void 0===s?void 0:s.right)&&void 0!==a?a:ue.right}},[$.margin,ue]),ge=$.brushDirection||"x",pe=t.useMemo(()=>Hr([{label:f||Dr(m),accessor:m,role:"x",format:p},{label:g||Dr(b),accessor:b,role:"y",format:y}]),[m,b,f,g,p,y]),ye=os({componentName:"MinimapChart",data:r,accessors:{xAccessor:m,yAccessor:b}});if(ye)return e.jsx(Wr,{componentName:"MinimapChart",message:ye,width:s,height:a});const me=C?"area":"line",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({chartType:me,data:ne,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ie},M&&{pointStyle:le}),{size:[s,a],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ue,showAxes:!0,xLabel:f,yLabel:g,xFormat:p,yFormat:y,enableHover:_,showGrid:L}),ce&&{legend:ce,legendPosition:de}),u&&{title:u}),d&&{description:d}),h&&{summary:h}),{tooltipContent:!1===R?()=>null:ei(R)||pe}),U&&{xExtent:U}),E&&{yExtent:E}),void 0!==n.axisExtent&&{axisExtent:n.axisExtent}),void 0!==n.autoPlaceAnnotations&&{autoPlaceAnnotations:n.autoPlaceAnnotations}),F),be=Object.assign({chartType:me,data:ne,xAccessor:m,yAccessor:b,groupAccessor:x||void 0,curve:j,lineStyle:ae,size:[s,he+fe.top+fe.bottom],margin:fe,showAxes:null!==(i=$.showAxes)&&void 0!==i&&i,background:$.background,enableHover:!1},E&&{yExtent:E}),xe=e.jsxs("div",{style:{position:"relative",width:s,overflow:"hidden"},children:[e.jsx(Fi,Object.assign({ref:Q},be)),e.jsx(Ys,{width:s-fe.left-fe.right,height:he,margin:fe,scales:Z,brushDirection:ge,extent:U,onBrush:K})]},"minimap"),ke=e.jsx("div",{style:{overflow:"hidden"},children:e.jsx(Fi,Object.assign({},ve))},"main");return G||Y||e.jsx(Vr,{componentName:"MinimapChart",width:s,height:a,children:e.jsxs("div",{className:"minimap-chart"+(c?" "+c:""),children:[D?xe:ke,D?ke:xe]})})}Gs.displayName="ScatterplotMatrix",qs.displayName="MinimapChart";const Vs={label:"Low / High",color:"#E9C46A",opacity:.08},Xs={label:"High / High",color:"#2A9D8F",opacity:.08},Us={label:"Low / Low",color:"#E76F51",opacity:.08},Ks={label:"High / Low",color:"#86BBD8",opacity:.08};function Qs(e,t){var n,o,i;return{label:null!==(n=null==t?void 0:t.label)&&void 0!==n?n:e.label,color:null!==(o=null==t?void 0:t.color)&&void 0!==o?o:e.color,opacity:null!==(i=null==t?void 0:t.opacity)&&void 0!==i?i:e.opacity}}const Zs=t.forwardRef(function(n,o){const i=t.useRef(null);us(o,{variant:"xy",frameRef:i});const r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",yAccessor:h="y",xCenter:f,yCenter:g,quadrants:p,centerlineStyle:y={},showQuadrantLabels:m=!0,quadrantLabelSize:b=12,colorBy:x,colorScheme:w,sizeBy:k,sizeRange:A=[3,15],pointRadius:j=5,pointOpacity:S=.8,tooltip:C,pointIdAccessor:O,annotations:M,frameProps:P={},selection:_,linkedHover:L,onObservation:T,onClick:N,hoverHighlight:R,chartId:$,loading:D,loadingContent:B,emptyContent:I,legendInteraction:E,legendPosition:F,color:H,stroke:z,strokeWidth:W,opacity:G}=n,{width:Y,height:q,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,xLabel:ee,yLabel:te}=r,ne=t.useMemo(()=>({topLeft:Qs(Vs,null==p?void 0:p.topLeft),topRight:Qs(Xs,null==p?void 0:p.topRight),bottomLeft:Qs(Us,null==p?void 0:p.bottomLeft),bottomRight:Qs(Ks,null==p?void 0:p.bottomRight)}),[p]),oe=t.useMemo(()=>v(s),[s]),ie=as({data:oe,rawData:s,colorBy:x,colorScheme:w,legendInteraction:E,legendPosition:F,selection:_,linkedHover:L,fallbackFields:"string"==typeof x?[x]:[],unwrapData:!1,onObservation:T,onClick:N,hoverHighlight:R,chartType:"QuadrantChart",chartId:$,showLegend:U,userMargin:a,marginDefaults:r.marginDefaults,loading:D,loadingContent:B,emptyContent:I,width:Y,height:q});Zr("QuadrantChart",oe,"xAccessor",d),Zr("QuadrantChart",oe,"yAccessor",h);const re=t.useMemo(()=>{if(!oe.length)return;const e="function"==typeof d?d:e=>+e[d],t="function"==typeof h?h:e=>+e[h];let n=1/0,o=-1/0,i=1/0,r=-1/0;for(const s of oe){const a=e(s),l=t(s);isFinite(a)&&(n>a&&(n=a),a>o&&(o=a)),isFinite(l)&&(i>l&&(i=l),l>r&&(r=l))}if(null!=f&&isFinite(f)&&(n>f&&(n=f),f>o&&(o=f)),null!=g&&isFinite(g)&&(i>g&&(i=g),g>r&&(r=g)),n===1/0)return;const s=.1*(o-n)||1,a=.1*(r-i)||1;return{xExtent:[n-s,o+s],yExtent:[i-a,r+a]}},[oe,d,h,f,g]),se=t.useMemo(()=>{if(!k||0===oe.length)return;const e=oe.map(e=>"function"==typeof k?k(e):e[k]).filter(e=>"number"==typeof e&&Number.isFinite(e));return 0!==e.length?[Math.min(...e),Math.max(...e)]:void 0},[oe,k]),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),n=le(e),o=null!=f?t>=f:void 0,i=null!=g?n>=g:void 0;return void 0===i||void 0===o?H||kr:i&&o?ne.topRight.color:i&&!o?ne.topLeft.color:!i&&o?ne.bottomRight.color:ne.bottomLeft.color},[ae,le,f,g,ne,H]),ue=t.useMemo(()=>k?e=>Ae(e,k,A,se):void 0,[k,A,se]),de=Ps({colorBy:x,colorScale:ie.colorScale,color:H,pointRadius:j,fillOpacity:S,radiusFn:ue,fallbackFill:ce,stroke:z,strokeWidth:W,opacity:G,effectiveSelectionHook:ie.effectiveSelectionHook,resolvedSelection:ie.resolvedSelection}),he=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 k&&e.add(k);const t=oe[0];for(const n of Object.keys(t))if(!n.startsWith("_")&&!e.has(n)&&"string"==typeof t[n])return n},[oe,d,h,x,k]),fe=t.useMemo(()=>Hr([...he?[{label:he,accessor:he,role:"title"}]:[],{label:ee||Dr(d),accessor:d,role:"x",format:c},{label:te||Dr(h),accessor:h,role:"y",format:u},...x?[{label:Dr(x),accessor:x,role:"color"}]:[],...k?[{label:Dr(k),accessor:k,role:"size"}]:[]]),[he,d,h,ee,te,x,k,c,u]),ge=os({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,n,o,i)=>{var r;if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return;const s=i.width,a=i.height,l=null!=f?o.x(f):s/2,c=null!=g?o.y(g):a/2;if(null!=f&&!isFinite(l))return;if(null!=g&&!isFinite(c))return;const u=Math.max(0,Math.min(s,l)),d=Math.max(0,Math.min(a,c)),h=[{config:ne.topLeft,x:0,y:0,w:u,h:d},{config:ne.topRight,x:u,y:0,w:s-u,h:d},{config:ne.bottomLeft,x:0,y:d,w:u,h:a-d},{config:ne.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([])}]},[f,g,ne,y]),ye=t.useMemo(()=>m?[...pe,(e,t,n,o)=>{if(!(null==n?void 0:n.x)||!(null==n?void 0:n.y))return;const i=o.width,r=o.height,s=null!=f?n.x(f):i/2,a=null!=g?n.y(g):r/2;(null==f||isFinite(s))&&(null==g||isFinite(a))&&(e.font=`600 ${b}px sans-serif`,e.globalAlpha=.5,e.fillStyle=ne.topLeft.color,e.textAlign="left",e.textBaseline="top",e.fillText(ne.topLeft.label,8,8),e.fillStyle=ne.topRight.color,e.textAlign="right",e.textBaseline="top",e.fillText(ne.topRight.label,i-8,8),e.fillStyle=ne.bottomLeft.color,e.textAlign="left",e.textBaseline="bottom",e.fillText(ne.bottomLeft.label,8,r-8),e.fillStyle=ne.bottomRight.color,e.textAlign="right",e.textBaseline="bottom",e.fillText(ne.bottomRight.label,i-8,r-8),e.globalAlpha=1)}]:pe,[pe,m,b,ne,f,g]),me=t.useMemo(()=>{const e=P.canvasPreRenderers||[];return[...ye,...e]},[ye,P.canvasPreRenderers]),ve=t.useMemo(()=>{var t;const n={stroke:y.stroke||"#999",strokeWidth:null!==(t=y.strokeWidth)&&void 0!==t?t:1,dashArray:y.strokeDasharray?Array.isArray(y.strokeDasharray)?y.strokeDasharray.join(","):y.strokeDasharray:void 0};return[(t,o,i)=>{if(!(null==o?void 0:o.x)||!(null==o?void 0:o.y))return null;const r=i.width,s=i.height,a=null!=f?o.x(f):r/2,l=null!=g?o.y(g):s/2;if(null!=f&&!isFinite(a))return null;if(null!=g&&!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:ne.topLeft,x:0,y:0,w:c,h:u},{config:ne.topRight,x:c,y:0,w:r-c,h:u},{config:ne.bottomLeft,x:0,y:u,w:c,h:s-u},{config:ne.bottomRight,x:c,y:u,w:r-c,h:s-u}].map((t,n)=>{var o;return t.w>0&&t.h>0?e.jsx("rect",{x:t.x,y:t.y,width:t.w,height:t.h,fill:t.config.color,opacity:null!==(o=t.config.opacity)&&void 0!==o?o:.08},"qf-"+n):null}),e.jsx("line",{x1:c,y1:0,x2:c,y2:s,stroke:n.stroke,strokeWidth:n.strokeWidth,strokeDasharray:n.dashArray}),e.jsx("line",{x1:0,y1:u,x2:r,y2:u,stroke:n.stroke,strokeWidth:n.strokeWidth,strokeDasharray:n.dashArray}),m&&e.jsxs(e.Fragment,{children:[e.jsx("text",{x:8,y:8+b,fill:ne.topLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:ne.topLeft.label}),e.jsx("text",{x:r-8,y:8+b,fill:ne.topRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:ne.topRight.label}),e.jsx("text",{x:8,y:s-8,fill:ne.bottomLeft.color,fontWeight:600,fontSize:b,opacity:.5,children:ne.bottomLeft.label}),e.jsx("text",{x:r-8,y:s-8,fill:ne.bottomRight.color,fontWeight:600,fontSize:b,opacity:.5,textAnchor:"end",children:ne.bottomRight.label})]})]})}]},[f,g,ne,y,m,b]);if(ie.earlyReturn)return ie.earlyReturn;const 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(Object.assign({chartType:"scatter"},null!=s&&{data:oe}),{xAccessor:d,yAccessor:h,colorAccessor:x||void 0,sizeAccessor:k||void 0,sizeRange:A,pointStyle:de,colorScheme:w,size:[Y,q],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ie.margin,showAxes:r.showAxes,xLabel:ee,yLabel:te,xFormat:c,yFormat:u,enableHover:V,showGrid:X}),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!=n.animate&&{animate:n.animate}),void 0!==n.axisExtent&&{axisExtent:n.axisExtent}),void 0!==n.autoPlaceAnnotations&&{autoPlaceAnnotations:n.autoPlaceAnnotations}),{tooltipContent:!1===C?()=>null:!0===C||void 0===C?fe:ei(C)||fe}),(L||T||N||R)&&{customHoverBehavior:ie.customHoverBehavior}),(T||N||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 ge?e.jsx(Wr,{componentName:"QuadrantChart",message:ge,width:Y,height:q}):e.jsx(Vr,{componentName:"QuadrantChart",width:Y,height:q,children:e.jsx(Fi,Object.assign({ref:i},be))})});Zs.displayName="QuadrantChart";const Js="__ma_unitized",ea="__ma_series";function ta(e,t){const n=t[1]-t[0];return 0===n?.5:(e-t[0])/n}function na(e,t){return t[0]+e*(t[1]-t[0])}const oa=t.forwardRef(function(n,o){var i;const r=t.useRef(null),s=t.useRef([]),a=t.useRef(n.series);a.current=n.series,t.useImperativeHandle(o,()=>{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 n=e(),o=t;for(let e=0;n.length>e&&2>e;e++){const t=n[e],i=t.extent||s.current[e];if(!i)continue;const a=("function"==typeof t.yAccessor?t.yAccessor:e=>e[t.yAccessor])(o);null!=a&&isFinite(a)&&r.current.push(Object.assign(Object.assign({},o),{[Js]:ta(a,i),[ea]:t.label||"Series "+(e+1)}))}},pushMany:t=>{if(!r.current)return;const n=e(),o=[];for(const e of t)for(let t=0;n.length>t&&2>t;t++){const i=n[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)&&o.push(Object.assign(Object.assign({},e),{[Js]:ta(a,r),[ea]:i.label||"Series "+(t+1)}))}r.current.pushMany(o)},remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=r.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=r.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}},[]);const l=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,xLabel:n.xLabel,accessibleTable:n.accessibleTable},{width:800,height:400}),{data:c,margin:u,className:d,xFormat:h,xAccessor:f="x",series:g,colorScheme:y,curve:m="monotoneX",lineWidth:b=2,tooltip:x,annotations:w,frameProps:k={},selection:A,linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,chartId:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:N,stroke:R,strokeWidth:$,opacity:D}=n,{width:B,height:I,enableHover:E,showGrid:F,showLegend:H=!0,title:z,description:W,summary:G,accessibleTable:Y,xLabel:q}=l,V=t.useMemo(()=>v(c),[c]),X=t.useMemo(()=>v(g),[g]),U=X,K=2===X.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 ${X.length}. Rendering as a standard multi-line chart.`);const Q=Qr(P,B,I,_),Z=Q?null:Kr(c,B,I,L),J=Sr(),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,n)=>t.color||e[n%e.length])},[U,y,J]),te=t.useMemo(()=>X.map((e,t)=>e.label||"Series "+(t+1)),[X]),{unitizedData:ne,extents:oe}=t.useMemo(()=>{if(0===V.length){const e=X.map(e=>e.extent||null).filter(Boolean);return e.length===X.length&&(s.current=e),{unitizedData:[],extents:e.length===X.length?e:[]}}const e=X.map(e=>e.extent||function(e,t){let n=1/0,o=-1/0;const i="function"==typeof t?t:e=>e[t];for(const t of e){const e=i(t);null!=e&&isFinite(e)&&(n>e&&(n=e),e>o&&(o=e))}if(!isFinite(n)||!isFinite(o))return[0,1];if(n===o){const e=0===n?1:.1*Math.abs(n);return[n-e,o+e]}return[n,o]}(V,e.yAccessor));if(s.current=e,!K){const t=[];for(const e of V)for(let n=0;X.length>n;n++){const o=X[n],i=("function"==typeof o.yAccessor?o.yAccessor:e=>e[o.yAccessor])(e);null!=i&&t.push(Object.assign(Object.assign({},e),{[Js]:i,[ea]:te[n]}))}return{unitizedData:t,extents:e}}const t=[];for(const n of V)for(let o=0;2>o;o++){const i=X[o],r=("function"==typeof i.yAccessor?i.yAccessor:e=>e[i.yAccessor])(n);null!=r&&t.push(Object.assign(Object.assign({},n),{[Js]:ta(r,e[o]),[ea]:te[o]}))}return{unitizedData:t,extents:e}},[V,X,K,te]),ie=t.useMemo(()=>{if(K&&oe.length>=2)return[{orient:"left",label:te[0],tickFormat:X[0].format||(e=>{const t=na(e,oe[0]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"right",label:te[1],tickFormat:X[1].format||(e=>{const t=na(e,oe[1]);return Number.isInteger(t)?t+"":t.toFixed(1)})},{orient:"bottom"}]},[K,oe,X,te]),re=as({data:t.useMemo(()=>ne.length>0?ne:te.map(e=>({[ea]:e})),[ne,te]),rawData:c,colorBy:ea,colorScheme:ee,legendInteraction:T,legendPosition:N,selection:A,linkedHover:j,fallbackFields:[ea],unwrapData:!1,onObservation:S,onClick:C,hoverHighlight:O,chartType:"MultiAxisLineChart",chartId:M,showLegend:H,userMargin:u,marginDefaults:K?Object.assign(Object.assign({},l.marginDefaults),{left:70,right:70}):l.marginDefaults,loading:P,loadingContent:_,emptyContent:L,width:B,height:I}),se=t.useMemo(()=>{const e=new Map;return te.forEach((t,n)=>e.set(t,ee[n])),e},[te,ee]),ae=cs({lineWidth:b,resolveStroke:t.useCallback(e=>se.get(e[ea])||ee[0],[se,ee]),stroke:R,strokeWidth:$,opacity:D,effectiveSelectionHook:re.effectiveSelectionHook,resolvedSelection:re.resolvedSelection}),le=t.useMemo(()=>{if(!1===x)return()=>null;return ei(x)||(e=>{var t;const n=e.data||e,o=n[ea],i=te.indexOf(o),r=n[Js],s=K&&i>=0&&oe[i]?na(r,oe[i]):r,a=i>=0&&(null===(t=X[i])||void 0===t?void 0:t.format)?X[i].format:e=>Number.isInteger(e)?e+"":e.toFixed(2),l="function"==typeof f?f(n):n[f];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"}},o),p.createElement("div",null,`${"string"==typeof f?f:"x"}: ${l}`),p.createElement("div",null,`${o}: ${a(s)}`))})},[x,te,ee,oe,K,X,f]);if(re.earlyReturn)return re.earlyReturn;const ce=os({componentName:"MultiAxisLineChart",data:c,accessors:{xAccessor:f}}),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(Object.assign({chartType:"line"},null!=c&&{data:ne}),{xAccessor:f,yAccessor:Js,groupAccessor:ea,lineStyle:ae,colorScheme:ee,size:[B,I],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:re.margin,showAxes:l.showAxes}),ie&&{axes:ie}),{xLabel:q}),K?{}:{yLabel:te[0]}),{xFormat:h}),K&&ue&&{yExtent:ue}),{enableHover:E}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),{showGrid:F,curve:m}),re.legendBehaviorProps),z&&{title:z}),W&&{description:W}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),d&&{className:d}),null!=n.animate&&{animate:n.animate}),void 0!==n.axisExtent&&{axisExtent:n.axisExtent}),void 0!==n.autoPlaceAnnotations&&{autoPlaceAnnotations:n.autoPlaceAnnotations}),{tooltipContent:le}),w&&{annotations:w}),(j||S||C||O)&&{customHoverBehavior:re.customHoverBehavior}),(S||C||j)&&{customClickBehavior:re.customClickBehavior}),re.crosshairProps),k);return Q||Z||(ce?e.jsx(Wr,{componentName:"MultiAxisLineChart",message:ce,width:B,height:I}):e.jsx(Vr,{componentName:"MultiAxisLineChart",width:B,height:I,children:e.jsx(Fi,Object.assign({ref:r},de))}))});oa.displayName="MultiAxisLineChart";const ia=t.forwardRef(function(n,o){const i=t.useRef(null);us(o,{variant:"xy",frameRef:i});const r=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,title:n.title,xLabel:n.xLabel,yLabel:n.yLabel,description:n.description,summary:n.summary,accessibleTable:n.accessibleTable}),{data:s,margin:a,className:l,xFormat:c,yFormat:u,xAccessor:d="x",highAccessor:h="high",lowAccessor:f="low",openAccessor:g,closeAccessor:p,candlestickStyle:y,tooltip:m,annotations:b,xExtent:x,yExtent:w,frameProps:k={},selection:A,linkedHover:j,onObservation:S,onClick:C,chartId:O,loading:M,loadingContent:P,emptyContent:_}=n,{width:L,height:T,enableHover:N,showGrid:R,title:$,description:D,summary:B,accessibleTable:I,xLabel:E,yLabel:F}=r,H=Qr(M,L,T,P),z=H?null:Kr(s,L,T,_),W=t.useMemo(()=>v(s),[s]),G=null==g||null==p;Zr("CandlestickChart",W,"xAccessor",d),Zr("CandlestickChart",W,"highAccessor",h),Zr("CandlestickChart",W,"lowAccessor",f),G||(Zr("CandlestickChart",W,"openAccessor",g),Zr("CandlestickChart",W,"closeAccessor",p));const{customHoverBehavior:Y,customClickBehavior:q,crosshairSourceId:V}=Pr({selection:A,linkedHover:j,onObservation:S,onClick:C,chartType:"CandlestickChart",chartId:O}),X=_r(j,V),U=t.useMemo(()=>{const e=r.marginDefaults,t="sparkline"===n.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,n.mode]),K=t.useMemo(()=>{const e=[{label:E||Dr(d),accessor:d,role:"x",format:c}];return G?(e.push({label:"High",accessor:h,role:"y",format:u}),e.push({label:"Low",accessor:f,format:u})):(e.push({label:"Open",accessor:g,format:u}),e.push({label:"High",accessor:h,format:u}),e.push({label:"Low",accessor:f,format:u}),e.push({label:"Close",accessor:p,format:u})),Hr(e)},[d,E,c,u,h,f,g,p,G]),Q=os({componentName:"CandlestickChart",data:s,accessors:Object.assign({xAccessor:d,highAccessor:h,lowAccessor:f},!G&&{openAccessor:g,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:W}),{xAccessor:d,yAccessor:h,highAccessor:h,lowAccessor:f}),!G&&{openAccessor:g,closeAccessor:p}),y&&{candlestickStyle:y}),{scalePadding:Z,extentPadding:J,size:[L,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:U,showAxes:r.showAxes,xLabel:E,yLabel:F,xFormat:c,yFormat:u,enableHover:N,showGrid:R}),n.pointIdAccessor&&{pointIdAccessor:n.pointIdAccessor}),xs({title:$,description:D,summary:B,accessibleTable:I,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:K})),ws({linkedHover:j,onObservation:S,onClick:C,customHoverBehavior:Y,customClickBehavior:q})),b&&b.length>0&&{annotations:b}),x&&{xExtent:x}),w&&{yExtent:w}),X),k);return H||z||(Q?e.jsx(Wr,{componentName:"CandlestickChart",message:Q,width:L,height:T}):e.jsx(Vr,{componentName:"CandlestickChart",width:L,height:T,children:e.jsx(Fi,Object.assign({ref:i},ee))}))});function ra(e,t){var n;const{columns:o,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(o),f=h.some(e=>{const t=e.pieceData[0];return t&&("number"==typeof t._pct||"number"==typeof t._pctStart||null!=t._roundedEnds)}),g=d&&!f&&h.length>1&&(null!==(n=i.cornerRadius)&&void 0!==n?n:0)>0;for(let e=0;h.length>e;e++){const t=h[e],n=t.pieceData[0],o="number"==typeof(null==n?void 0:n._pctStart)?n._pctStart:t.pctStart,d=c+o*u,f=c+(o+("number"==typeof(null==n?void 0:n._pct)?n._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:f},i.cornerRadius&&{cornerRadius:i.cornerRadius}),{style:p,datum:(null==n?void 0:n._nonInteractive)?null:t.pieceData,category:t.name});(null==n?void 0:n._roundedEnds)?v.roundedEnds=n._roundedEnds:g&&(v.roundedEnds={start:y,end:m}),(null==n?void 0:n._gradientBand)&&(v._gradientBand=n._gradientBand),s.push(v)}return s}function sa(e){var t,n,o;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!==(n=a.quantile(e,.5))&&void 0!==n?n:(r+s)/2,q3:null!==(o=a.quantile(e,.75))&&void 0!==o?o:s,max:s,mean:e.reduce((e,t)=>e+t,0)/i}}function aa(e,t,n){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:n}function la(e){return 0===e.length?()=>"#4e79a7":t=>{var n;let o=0;for(let e=0;t.length>e;e++)o=31*o+t.charCodeAt(e)|0;return null!==(n=e[Math.abs(o)%e.length])&&void 0!==n?n:"#4e79a7"}}ia.displayName="CandlestickChart";const ca={bar:function(e,t){var n,o,i;const{scales:r,columns:s,config:a,getR:l,getStack:c,resolvePieceStyle:u}=e,{r:d,projection:h}=r,f=[],g="vertical"===h,p="horizontal"===h,y=a.normalize,m=[];if(c){const e=new Set;for(const t of Object.values(s))for(const n of t.pieceData){const t=c(n);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 n of e.pieceData){const e=c?c(n):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const o=t.get(e);o.total+=l(n),o.pieces.push(n)}let n=0;if(y)for(const e of t.values())n+=Math.abs(e.total);let o=0,i=0;for(const r of m){const s=t.get(r);if(!s)continue;let a=s.total;y&&n>0&&(a/=n);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(g){const t=d(0>a?i:o+a),n=0>a?d(i+a)-d(i):d(o)-d(o+a);f.push(H(e.x,t,e.width,Math.abs(n),l,h,r)),0>a?i+=a:o+=a}else if(p){const t=d(0>a?i+a:o),n=0>a?d(i)-d(i+a):d(o+a)-d(o);f.push(H(t,e.x,Math.abs(n),e.width,l,h,r)),0>a?i+=a:o+=a}}}const v="vertical"===h,b=a.roundedTop&&a.roundedTop>0?Math.max(0,a.roundedTop):0;for(const e of f){if("rect"!==e.type)continue;const t=null!==(o=null===(n=e.datum)||void 0===n?void 0:n.__aggregateValue)&&void 0!==o?o: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 f){if("rect"!==t.type)continue;const n=(null===(i=t.datum)||void 0===i?void 0:i.category)||"";e.has(n)||e.set(n,[]),e.get(n).push(t)}for(const t of e.values()){if(0===t.length)continue;const e=t.filter(e=>{var t,n;return(null!==(n=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==n?n:0)>=0}),n=t.filter(e=>{var t,n;return 0>(null!==(n=null===(t=e.datum)||void 0===t?void 0:t.__aggregateValue)&&void 0!==n?n: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),n.length>0&&(n.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 f},clusterbar:function(e,t){const{scales:n,columns:o,config:i,getR:r,getGroup:s,resolvePieceStyle:a}=e,{r:l,projection:c}=n,u=[],d="vertical"===c,h=[],f=new Set;for(const e of Object.values(o))for(const t of e.pieceData){const e=s?s(t):"_default";f.has(e)||(f.add(e),h.push(e))}const g=h.length||1;for(const e of Object.values(o)){const t=e.width/g,n=.2*t,o=t-n,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),f=a(i,h[s]);if(d){const r=e.x+s*t+n/2,a=l(0),d=l(c);u.push(H(r,Math.min(a,d),o,Math.abs(a-d),f,i,h[s]))}else{const r=e.x+s*t+n/2,a=l(0),d=l(c);u.push(H(Math.min(a,d),r,Math.abs(d-a),o,f,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 n,o;const{scales:i,columns:r,getR:s,multiScales:a,resolvePieceStyle:l}=e,{r:c,projection:u}=i,d=[],h="vertical"===u,f="radial"===u,g=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!==(n=t.__rIndex)&&void 0!==n?n:0,r=null!==(o=t.__rValue)&&void 0!==o?o:s(t),u=g&&a[i]||c,m=l(t,e.name),v=m.r||5;let b,x;if(f){const t=y+(e.pctStart+e.pct/2)*p,n=u(r);b=Math.cos(t)*n,x=Math.sin(t)*n}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:n,columns:o,getR:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="vertical"===a;for(const e of Object.values(o)){const t=e.width/2;for(let n=0;e.pieceData.length>n;n++){const o=e.pieceData[n],a=i(o),u=r(o,e.name),d=u.r||4,h=(7919*n%100/100-.5)*t*.8,f=c?e.middle+h:s(a),g=c?s(a):e.middle+h;l.push({type:"point",x:f,y:g,r:d,style:u,datum:o})}}return l},pie:ra,donut:ra,boxplot:function(e,t){var n,o,i,r,s,l;const{scales:c,columns:u,config:d,getR:h,resolveSummaryStyle:f}=e,{r:g,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!==(n=a.quantile(c,.25))&&void 0!==n?n:u,b=null!==(o=a.quantile(c,.5))&&void 0!==o?o:(u+d)/2,x=null!==(i=a.quantile(c,.75))&&void 0!==i?i:d,w=x-p,k=p-1.5*w,A=x+1.5*w,j=null!==(r=c.find(e=>e>=k))&&void 0!==r?r:u,S=null!==(s=[...c].reverse().find(e=>A>=e))&&void 0!==s?s:d,C=f(t.pieceData[0],t.name),O=[];if(v)for(const e of t.pieceData){const n=h(e);if(k>n||n>A){const o=m?t.middle:g(n),i=m?g(n):t.middle;O.push({px:o,py:i,value:n,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:g(j),q1Pos:g(p),medianPos:g(b),q3Pos:g(x),maxPos:g(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 n,o,i;const{scales:r,columns:s,config:l,getR:c,resolveSummaryStyle:u}=e,{r:d,projection:h}=r,f=[],g="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(g){b=`M ${e.middle} ${d(r)}`;for(let t=0;p>t;t++){const n=d(r+(t+.5)*l);b+=` L ${e.middle+h[t]/m*v} ${n}`}b+=` L ${e.middle} ${d(s)}`;for(let t=p-1;t>=0;t--){const n=d(r+(t+.5)*l);b+=` L ${e.middle-h[t]/m*v} ${n}`}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 w;if(y&&t.length>=4){const l=null!==(n=a.quantile(t,.25))&&void 0!==n?n:r,c=null!==(o=a.quantile(t,.5))&&void 0!==o?o:(r+s)/2,u=null!==(i=a.quantile(t,.75))&&void 0!==i?i:s;w={q1Pos:d(l),medianPos:d(c),q3Pos:d(u),centerPos:e.middle,isVertical:g}}const k=g?{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};f.push({type:"violin",pathString:b,translateX:0,translateY:0,bounds:k,iqrLine:w,stats:sa(t),style:x,datum:e.pieceData,category:e.name})}return f},histogram:function(e,t){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l}=o,c=[],u=r.bins||25,d=r.normalize,h=null===(n=l.domain)||void 0===n?void 0:n.call(l),f=h?+h[0]:void 0,g=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 n=null!=f&&isFinite(f)?f:Math.min(...t),o=null!=g&&isFinite(g)?g:Math.max(...t),i=(o-n)/u||1,r=Array(u).fill(0);for(const e of t)n>e||e>o||r[Math.min(Math.floor((e-n)/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 o=(d?r[t]/h:r[t]/p)*e.width*.9,s=l(n+t*i),a=l(n+(t+1)*i);c.push(H(Math.min(s,a),e.x+e.width-o,Math.abs(a-s),o,y,{bin:t,count:r[t],range:[n+t*i,n+(t+1)*i],category:e.name},e.name))}}return c},ridgeline:function(e,t){var n;const{scales:o,columns:i,config:r,getR:s,resolveSummaryStyle:a}=e,{r:l,projection:c}=o,u=[],d=r.bins||20,h="horizontal"===c,f=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 o=t[0],i=t[t.length-1],r=(i-o)/d||1,c=Array(d).fill(0);for(const e of t)o>e||e>i||c[Math.min(Math.floor((e-o)/r),d-1)]++;const g=Math.max(...c,1),p=a(e.pieceData[0],e.name),y=e.width*f;let m="";if(h){const t=e.x+e.width;m=`M ${l(o)} ${t}`;for(let e=0;d>e;e++)m+=` L ${l(o+(e+.5)*r)} ${t-c[e]/g*y}`;m+=` L ${l(i)} ${t} Z`}else{const t=e.x;m=`M ${t} ${l(o)}`;for(let e=0;d>e;e++){const n=l(o+(e+.5)*r);m+=` L ${t+c[e]/g*y} ${n}`}m+=` L ${t} ${l(i)} Z`}const v=h?{x:Math.min(l(o),l(i)),y:e.x,width:Math.abs(l(i)-l(o)),height:e.width}:{x:e.x,y:Math.min(l(i),l(o)),width:e.width,height:Math.abs(l(i)-l(o))};u.push({type:"violin",pathString:m,translateX:0,translateY:0,bounds:v,stats:sa(t),style:Object.assign(Object.assign({},p),{fillOpacity:null!==(n=p.fillOpacity)&&void 0!==n?n:.5}),datum:e.pieceData,category:e.name})}return u},timeline:function(e,t){const{scales:n,columns:o,getRawRange:i,resolvePieceStyle:r}=e,{r:s,projection:a}=n,l=[],c="horizontal"===a;for(const e of Object.values(o))for(const t of e.pieceData){const n=i(t);if(!n)continue;const[o,a]=n,u=r(t,e.name);if(c){const n=s(Math.min(o,a)),i=s(Math.max(o,a));l.push(H(n,e.x,i-n,e.width,u,t,e.name))}else{const n=s(Math.max(o,a)),i=s(Math.min(o,a));l.push(H(e.x,n,e.width,i-n,u,t,e.name))}}return l},funnel:function(e,t){var n,o,r,s,a,l,c,u;const{columns:d,getR:h,getStack:f,resolvePieceStyle:g}=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=f?f(t):"_default";x.has(e)||(x.add(e),b.push(e))}const w=b.length>1&&"_default"!==b[0],k=[];let A=0;for(const e of v){const t=new Map;let n=0;for(const o of e.pieceData){const e=f?f(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=h(o);i.total+=r,i.pieces.push(o),n+=r}k.push({col:e,groups:t,stepTotal:n}),w||n>A&&(A=n)}if(w)for(const e of k){let t=0,n=0;for(let o=0;b.length>o;o++){const i=e.groups.get(b[o]);i&&(o%2==0?t+=i.total:n+=i.total)}const o=Math.max(t,n);o>A&&(A=o)}if(0===A)return p;const j=new Map;for(const e of b){const t=k[0].groups.get(e);j.set(e,null!==(n=null==t?void 0:t.total)&&void 0!==n?n:0)}const S=k[0].stepTotal,C=w?.95*y:.9*t.width,O=i.scaleLinear().domain([0,A]).range([0,C]),M=null!==(o=e.config.connectorOpacity)&&void 0!==o?o:.3;let P=new Map;for(let t=0;k.length>t;t++){const n=k[t],o=n.col,i=0===t,d=o.width,h=.55*d,f=o.x+(d-h)/2,v=new Map;if(w){let e=0;for(const t of b){const o=n.groups.get(t);o&&(e+=O(o.total))}let t=y,r=y;for(let s=0;b.length>s;s++){const l=b[s],c=n.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 w=g(c.pieces[0],l),k=null!==(a=j.get(l))&&void 0!==a?a:c.total,A=k>0?c.total/k*100:0,S=Object.assign(Object.assign({},c.pieces[0]),{__funnelValue:c.total,__funnelPercent:A,__funnelStep:o.name,__funnelIsFirstStep:i,__aggregateValue:c.total,__pieceCount:c.pieces.length,category:l});m&&(0===s&&(S.__funnelStepLabel=o.name,S.__funnelStepLabelX=y,S.__funnelStepLabelY=f,S.__funnelRowWidth=e),S.__funnelValueLabelX=x+u/2,S.__funnelValueLabelY=f,S.__funnelBarW=u),p.push(H(x,f,u,h,w,S,l)),v.set(l,{x:x,y:f,w:u,h:h})}}else{const e=n.stepTotal,t=O(e),a=y-t/2,l=b[0],c="_default"!==l,u=null!==(s=null===(r=n.groups.get(l))||void 0===r?void 0:r.pieces[0])&&void 0!==s?s:o.pieceData[0],d=c?l:o.name,x=g(u,d),w=S>0?e/S*100:0,k=Object.assign(Object.assign({},u),{__funnelValue:e,__funnelPercent:w,__funnelStep:o.name,__funnelIsFirstStep:i,category:c?l:o.name});m&&(k.__funnelStepLabel=o.name,k.__funnelStepLabelX=y,k.__funnelStepLabelY=f,k.__funnelRowWidth=t,k.__funnelValueLabelX=y,k.__funnelValueLabelY=f,k.__funnelBarW=t),p.push(H(a,f,t,h,x,k,d)),v.set(l,{x:a,y:f,w:t,h:h})}if(t>0&&P.size>0){const t=w?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=n.groups.get(i);return g(e?e.pieces[0]:o.pieceData[0],"_default"===i?o.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=n.groups.get(i))||void 0===c?void 0:c.pieces[0])&&void 0!==u?u:o.pieceData[0],category:"_default"===i?o.name:i};p.push(a)}}P=v}return p},"bar-funnel":function(e,t){var n,o,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 f=[],g=new Set;for(const e of h)for(const t of e.pieceData){const e=l?l(t):"_default";g.has(e)||(g.add(e),f.push(e))}const p=f.length>1&&"_default"!==f[0],y=[];for(const e of h){const t=new Map;let n=0;for(const o of e.pieceData){const e=l?l(o):"_default";t.has(e)||t.set(e,{total:0,pieces:[]});const i=t.get(e),r=a(o);i.total+=r,i.pieces.push(o),n+=r}y.push({col:e,groups:t,stepTotal:n})}const m=new Map;for(const e of f){const t=null===(n=y[0])||void 0===n?void 0:n.groups.get(e);m.set(e,null!==(o=null==t?void 0:t.total)&&void 0!==o?o:0)}const v=u.r,b=p?f.length:1,x=p?.15:0;for(let e=0;y.length>e;e++){const t=y[e],n=t.col,o=0===e,s=e>0?y[e-1]:null,a=n.width/b,l=a*x,u=a-l;for(let e=0;f.length>e;e++){const h=f[e],g=t.groups.get(h);if(!g)continue;const y=g.total,b=null!==(i=m.get(h))&&void 0!==i?i:y,x=b>0?y/b*100:0,w=null==s?void 0:s.groups.get(h),k=null!==(r=null==w?void 0:w.total)&&void 0!==r?r:y,A=o?0:Math.max(0,k-y),j=n.x+e*a+l/2,S=v(y),C=v(0)-S,O=c(g.pieces[0],p?h:n.name),M=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:y,__barFunnelPercent:x,__barFunnelIsFirstStep:o,__barFunnelIsDropoff:!1,__barFunnelStep:n.name,__barFunnelDropoffValue:A,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name,__barFunnelLabelX:j+u/2,__barFunnelLabelY:v(y+A)});if(d.push(H(j,S,u,C,O,M,p?h:n.name)),A>0){const e=v(y+A),t=S-e,o=Object.assign({},O),i=Object.assign(Object.assign({},g.pieces[0]),{__barFunnelValue:A,__barFunnelPercent:b>0?A/b*100:0,__barFunnelIsFirstStep:!1,__barFunnelIsDropoff:!0,__barFunnelStep:n.name,__barFunnelCategory:"_default"===h?void 0:h,category:p?h:n.name});d.push(H(j,e,u,t,o,i,p?h:n.name))}}}return d},swimlane:function(e,t){var n;const{scales:o,columns:i,getR:r,getStack:s,resolvePieceStyle:a}=e,{r:l,projection:c}=o,u=[],d="horizontal"===c,h=e.config.gradientFill,f=d?"left":"bottom",g=e.config.trackFill;if(g){const e="string"==typeof g?g:g.color,t="string"==typeof g?1:null!==(n=g.opacity)&&void 0!==n?n:1,[o,r]=l.range(),s=Math.min(o,r),a=Math.abs(r-o);for(const n of Object.values(i)){const o={fill:e,opacity:t},i=d?H(s,n.x,a,n.width,o,null,"__track__"):H(n.x,s,n.width,a,o,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 n=u.length;for(const n of e.pieceData){const o=Math.abs(r(n));if(0===o)continue;const i=s?s(n):e.name,c=a(n,i);let g;if(d){const r=l(t),s=l(t+o);g=H(r,e.x,s-r,e.width,c,n,i)}else{const r=l(t+o),s=l(t);g=H(e.x,r,e.width,s-r,c,n,i)}h&&(g.fillGradient=h,g.roundedEdge=f),u.push(g),t+=o}if(p>0&&u.length>n){const e=u.slice(n),t=e[0],o=e[e.length-1];1===e.length?t.cornerRadii={tl:p,tr:p,br:p,bl:p}:d?(t.cornerRadii={tl:p,bl:p},o.cornerRadii={tr:p,br:p}):(t.cornerRadii={bl:p,br:p},o.cornerRadii={tl:p,tr:p})}}return u}};class ua{constructor(e){this.rExtent=new $,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 R(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 $)):(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 R(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 n=e.totalSize||e.inserts.length;n>this.buffer.capacity&&(this.buffer.resize(n),this.timestampBuffer&&n>this.timestampBuffer.capacity&&this.timestampBuffer.resize(n));for(const n of e.inserts)this.buffer.push(n),this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n)}else{this._hasStreamingData=!0;for(const n of e.inserts){const e=this.buffer.push(n);this.timestampBuffer&&this.timestampBuffer.push(t),this.categories.add(this.getO(n)),this.pushValueExtent(n),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 n="function"==typeof t?t(e):e[t];return Array.isArray(n)&&n.length>=2?[+n[0],+n[1]]:null}computeScene(e){const{config:t,buffer:n}=this;if(0===n.size)return this.scales=null,this.scene=[],this.columns={},void this.version++;this.rExtent.dirty&&this.rExtent.recalculate(n,this.getR);const o=n.toArray(),r=t.projection||"vertical",s=t.oExtent||this.resolveCategories(o),a=this.computeValueDomain(o,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 n=Math.min(e.width,e.height)/2,o=t.innerRadius||0;h=i.scaleLinear().domain(a).range([o,n])}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((o,r)=>{var s;const a=this.rExtents[r];a.dirty&&a.recalculate(n,o);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,f=h>0?h*d:1;return c-=f,u+=f,c>0&&(c=0),l?i.scaleLinear().domain([c,u]).range([0,e.width]):i.scaleLinear().domain([c,u]).range([e.height,0])}):[];let f=o;this.rAccessors.length>1&&(f=o.flatMap(e=>this.rAccessors.map((t,n)=>Object.assign(Object.assign({},e),{__rIndex:n,__rValue:t(e),__rName:this.resolveRAccessorName(n)})))),this.columns=this.buildColumns(f,s,d,r,e),this.config.transition&&this.scene.length>0&&this.snapshotPositions(),this.scene=this.buildSceneNodes(f,e),this.rebuildPointQuadtree(),this.config.decay&&this.applyDecay(this.scene,o),this.config.pulse&&this.applyPulse(this.scene,o),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,n=Array.isArray(t)?t[e]:t;return"string"==typeof n?n:"value"+e}resolveCategories(e){const t=this.config.oSort,n="streaming"===this.config.runtimeMode||this._hasStreamingData,o="auto"===t?void 0:t;let i=null;if(n){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(n&&void 0===o){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===o)return r;if("function"==typeof o)return r.sort(o);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"===o?(e,t)=>(s.get(e)||0)-(s.get(t)||0):(e,t)=>(s.get(t)||0)-(s.get(e)||0))}computeValueDomain(e,t){var n,o,i,r,s;const a=this.config.chartType,l=null!==(n=this.config.extentPadding)&&void 0!==n?n:.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,n=new Map;for(const o of e){const e=this.getO(o),i=this.getR(o);0>i?n.set(e,(n.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 n.values())c>e&&(c=e)}else if("bar"===a){const t=new Map;for(const n of e){const e=this.getO(n),o=this.getR(n);t.set(e,(t.get(e)||0)+o)}for(const e of t.values())e>u&&(u=e),c>e&&(c=e)}else if("swimlane"===a){const t=new Map;for(const n of e){const e=this.getO(n),o=Math.abs(this.getR(n));t.set(e,(t.get(e)||0)+o)}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===(o=this.config.rExtent)||void 0===o?void 0:o[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,n,o,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"===o)for(const t of e)l+=Math.abs(this.getR(t));const c=this.config.dynamicColumnWidth;let u=null;if(c&&"radial"!==o){u=new Map;let e=0;for(const n of t){const t=a.get(n)||[];let o;o="string"==typeof c?t.reduce((e,t)=>e+(Number(t[c])||0),0):c(t),u.set(n,o),e+=o}const r=("horizontal"===o?i.height:i.width)-n.padding()*n.step()*t.length;if(e>0)for(const[t,n]of u)u.set(t,n/e*r)}let d=0,h=0;for(const e of t){const t=a.get(e)||[],o=t.reduce((e,t)=>e+Math.abs(this.getR(t)),0),i=l>0?o/l:0;let c,f;u?(c=h,f=u.get(e)||n.bandwidth(),h+=f+n.padding()*n.step()):(c=null!==(r=n(e))&&void 0!==r?r:0,f=n.bandwidth()),s[e]={name:e,x:c,y:0,width:f,middle:c+f/2,padding:n.padding()*n.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 n,o;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!==(n=r.overlays)&&void 0!==n?n:null,null!==(o=r.nodes)&&void 0!==o?o:[]}this.customLayoutOverlays=null;const i=this.getSceneContext(),r=ca[this.config.chartType];let s=r?r(i,t):[];if(this.getConnector&&this.scales){const e=function(e,t){var n,o;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 n=s(t);if(!n)continue;let o,i;"point"===e.type?(o=e.x,i=e.y):(o=e.x+e.w/2,i=e.y+("vertical"===c?0:e.h/2)),u.has(n)||u.set(n,[]),u.get(n).push({x:o,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===(n=e.config.themeSemantic)||void 0===n?void 0:n.border)||(null===(o=e.config.themeSemantic)||void 0===o?void 0:o.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 n,o,i;const r=this.config,s=null!==(n=r.layoutMargin)&&void 0!==n?n:{top:0,right:0,bottom:0,left:0},a=aa(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!==(o=r.themeSemantic)&&void 0!==o?o:{},categorical:[...a]},resolveColor:la(a),config:null!==(i=r.layoutConfig)&&void 0!==i?i:{}}}resolvePieceStyle(e,t){if("function"==typeof this.config.pieceStyle){const n=this.config.pieceStyle(e,t);return n&&!n.fill&&t?Object.assign(Object.assign({},n),{fill:this.getColorFromScheme(t)}):n}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 n=Array.isArray(this.config.colorScheme)?this.config.colorScheme:this.config.themeCategorical||ve,o=n[this._colorSchemeIndex%n.length];return this._colorSchemeIndex++,this._colorSchemeMap.set(e,o),o}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 n=this.config.decay;return n&&t>1?je(n,e,t):1}getDatumIndexMap(e){if(this._datumIndexCache&&this._datumIndexCache.version===this._dataVersion)return this._datumIndexCache.map;const t=new Map;for(let n=0;e.length>n;n++)t.set(e[n],n);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,n="function"==typeof t,o=n?null:t||"category",i=new Map;for(let r=0;e.length>r;r++){const s=e[r],a=n?t(s):s[o];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 n of this.scene)"point"===n.type&&(e++,n.r>t&&(t=n.r));if(this._maxPointRadius=t,ua.QUADTREE_THRESHOLD>=e)return void(this._pointQuadtree=null);const n=Array(e);let o=0;for(const e of this.scene)"point"===e.type&&(n[o++]=e);this._pointQuadtree=r.quadtree().x(e=>e.x).y(e=>e.y).addAll(n)}get pointQuadtree(){return this._pointQuadtree}get maxPointRadius(){return this._maxPointRadius}applyDecay(e,t){var n,o;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!==(o=null===(n=t.style)||void 0===n?void 0:n.opacity)&&void 0!==o?o:1;t.style=Object.assign(Object.assign({},t.style),{opacity:a*s})}}applyPulse(e,t){var n,o,i;if(!this.config.pulse||!this.timestampBuffer)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=null!==(n=this.config.pulse.duration)&&void 0!==n?n:500,a=null!==(o=this.config.pulse.color)&&void 0!==o?o:"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 n of e){if("connector"===n.type||"violin"===n.type||"boxplot"===n.type)continue;if("wedge"===n.type){const e=n.category;if(!e)continue;u||(u=this.getCategoryIndexMap(t));const o=u.get(e);if(!o)continue;let i=0;for(let e=0;o.length>e;e++){const t=this.timestampBuffer.get(o[e]);if(null==t)continue;const n=r-t;if(s>n){const e=1-n/s;e>i&&(i=e)}}i>0&&(n._pulseIntensity=i,n._pulseColor=a);continue}const e=c.get(n.datum);if(null==e)continue;const o=this.timestampBuffer.get(e);if(null==o)continue;const i=r-o;s>i&&(n._pulseIntensity=1-i/s,n._pulseColor=a,n._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(),n=null!==(e=this.config.pulse.duration)&&void 0!==e?e:500,o=this.timestampBuffer.peek();return null!=o&&n>t-o}synthesizeIntroPositions(){var e,t,n,o,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===(n=this.scales)||void 0===n?void 0:n.projection);let l;for(let e=0;this.scene.length>e;e++){const t=this.scene[e],n=this.getNodeKey(t,r);n&&("rect"===t.type?this.prevPositionMap.set(n,a?{x:t.x,y:s,w:t.w,h:0,opacity:null!==(o=t.style.opacity)&&void 0!==o?o: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(n,{x:t.x,y:t.y,r:0,opacity:0}):"wedge"===t.type&&(void 0===l&&(l=t.startAngle),this.prevPositionMap.set(n,{x:t.cx,y:t.cy,startAngle:l,endAngle:l,innerRadius:t.innerRadius,outerRadius:t.outerRadius,opacity:0})))}}getNodeKey(e,t){var n,o,i;if("point"===e.type){const n=`p:${e.datum?this.getO(e.datum):""}:${e.datum?this.getR(e.datum):0}`,o=t.get(n)||0;return t.set(n,o+1),`${n}:${o}`}return"rect"===e.type?`r:${e.group||""}:${null!==(o=null===(n=e.datum)||void 0===n?void 0:n.category)&&void 0!==o?o:""}`:"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 n=0;this.scene.length>n;n++){const o=this.scene[n],i=this.getNodeKey(o,t);i&&("point"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,r:o.r,opacity:o.style.opacity}):"rect"===o.type?this.prevPositionMap.set(i,{x:o.x,y:o.y,w:o.w,h:o.h,opacity:o.style.opacity}):"wedge"===o.type&&this.prevPositionMap.set(i,{x:o.cx,y:o.cy,startAngle:o.startAngle,endAngle:o.endAngle,innerRadius:o.innerRadius,outerRadius:o.outerRadius,opacity:null!==(e=o.style.opacity)&&void 0!==e?e:1}))}}startTransition(){var e,t,n,o,i,r,s,a,l,c,u,d,h,f,g,p,y,m,v,b,x;if(!this.config.transition||0===this.prevPositionMap.size)return;const w=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 k=!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),k=!0)):(c._targetOpacity=null!==(n=c.style.opacity)&&void 0!==n?n:1,c._targetR=c.r,c.r=0,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),k=!0);else if("rect"===c.type)d?(A.add(u),c._targetOpacity=null!==(o=c.style.opacity)&&void 0!==o?o: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,k=!0)):(c._targetOpacity=null!==(s=c.style.opacity)&&void 0!==s?s:1,c.style=Object.assign(Object.assign({},c.style),{opacity:0}),k=!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,k=!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}),k=!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!==(f=t.opacity)&&void 0!==f?f:1,fill:"#999"},datum:null,_targetOpacity:0,_transitionKey:e});else if(e.startsWith("w:")){const n=((null!==(g=t.startAngle)&&void 0!==g?g:0)+(null!==(p=t.endAngle)&&void 0!==p?p:0))/2,o={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:n,_targetEndAngle:n,_targetOpacity:0,_transitionKey:e};this.exitNodes.push(o)}k=!0}this.exitNodes.length>0&&(this.scene=[...this.scene,...this.exitNodes]),k&&(this.activeTransition={startTime:Pe(),duration:w})}advanceTransition(e){var t,n,o,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 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)}const o=this.prevPositionMap.get(t);void 0!==e._targetX&&o&&(e.x=Me(o.x,e._targetX,s),e.y=Me(o.y,e._targetY,s)),void 0!==e._targetR&&void 0!==(null==o?void 0:o.r)&&(e.r=Me(o.r,e._targetR,s))}else if("rect"===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)}if(void 0===e._targetX)continue;const n=this.prevPositionMap.get(t);if(!n)continue;e.x=Me(n.x,e._targetX,s),e.y=Me(n.y,e._targetY,s),void 0!==n.w&&(e.w=Me(n.w,e._targetW,s),e.h=Me(n.h,e._targetH,s))}else if("wedge"===e.type){if(void 0!==e._targetOpacity){const n=this.prevPositionMap.get(t),o=n?null!==(i=n.opacity)&&void 0!==i?i:1:0;e.style=Object.assign(Object.assign({},e.style),{opacity:Me(o,e._targetOpacity,s)})}if(void 0!==e._targetStartAngle&&void 0!==e._targetEndAngle){const n=this.prevPositionMap.get(t);n&&void 0!==n.startAngle&&(e.startAngle=Me(n.startAngle,e._targetStartAngle,s),e.endAngle=Me(n.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]),n=this.getDataId,o=e=>t.has(n(e));if(this.timestampBuffer&&this.timestampBuffer.size>0){const e=this.timestampBuffer.toArray(),t=new Set;this.buffer.forEach((e,n)=>{o(e)&&t.add(n)}),this.timestampBuffer.clear();for(let n=0;e.length>n;n++)t.has(n)||this.timestampBuffer.push(e[n])}const i=this.buffer.remove(o);if(0===i.length)return i;for(const e of i)this.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 n=new Set(Array.isArray(e)?e:[e]),o=this.getDataId,i=new Set;this.buffer.forEach((e,t)=>{n.has(o(e))&&i.add(t)});const r=this.buffer.update(e=>n.has(o(e)),t);if(0===r.length)return r;for(const e of r)this.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&&!W(e.colorAccessor,t.colorAccessor))&&(this._colorSchemeMap=null,this._colorSchemeIndex=0),("categoryAccessor"in e&&!W(e.categoryAccessor,t.categoryAccessor)||"oAccessor"in e&&!W(e.oAccessor,t.oAccessor))&&(this._categoryIndexCache=null),Object.assign(this.config,e),("categoryAccessor"in e||"oAccessor"in e)&&(W(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 n=e.valueAccessor||e.rAccessor,o=t.valueAccessor||t.rAccessor,i=Array.isArray(n)?n:[n],r=Array.isArray(o)?o:[o];if(i.length!==r.length||i.some((e,t)=>!W(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 $)):(this.getR=G(e,"value"),this.rAccessors=[this.getR],this.rExtents=[this.rExtent])}}"stackBy"in e&&!W(e.stackBy,t.stackBy)&&(this.getStack=null!=this.config.stackBy?q(this.config.stackBy):void 0),"groupBy"in e&&!W(e.groupBy,t.groupBy)&&(this.getGroup=null!=this.config.groupBy?q(this.config.groupBy):void 0),"colorAccessor"in e&&!W(e.colorAccessor,t.colorAccessor)&&(this.getColor=null!=this.config.colorAccessor?q(this.config.colorAccessor):void 0),"connectorAccessor"in e&&!W(e.connectorAccessor,t.connectorAccessor)&&(this.getConnector=null!=this.config.connectorAccessor?q(this.config.connectorAccessor):void 0)}}function da(e,t,n){const o=qe(t,n,e);return o.hit?{datum:e.datum,x:o.cx,y:e.y,distance:0,category:e.group}:null}function ha(e,t,n,o=30){const i=t-e.x,r=n-e.y,s=Math.sqrt(i*i+r*r);return s>Ve(e.r,o)?null:{datum:e.datum,x:e.x,y:e.y,distance:s}}function fa(e,t,n){const o=t-e.cx,i=n-e.cy,r=Math.sqrt(o*o+i*i);if(e.innerRadius>r||r>e.outerRadius)return null;const s=Ke(Math.atan2(i,o)),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 ga(e,t,n){const o=e.columnWidth/2;if("vertical"===e.projection){if(!(e.x-o>t||t>e.x+o||Math.min(e.minPos,e.maxPos)>n||n>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-o,r=e.y+o;if(!(Math.min(e.minPos,e.maxPos)>t||t>Math.max(e.minPos,e.maxPos)||i>n||n>r))return{datum:e.datum,x:e.medianPos,y:e.y,distance:0,category:e.category,stats:e.stats}}return null}function pa(e,t,n){if(!e.bounds)return null;const{x:o,y:i,width:r,height:s}=e.bounds;return o>t||t>o+r||i>n||n>i+s?null:{datum:e.datum,x:o+r/2,y:i+s/2,distance:0,category:e.category,stats:e.stats}}function ya(n){const{width:o,height:i,totalWidth:r,totalHeight:s,margin:a,scales:l,showAxes:c,showGrid:u,rFormat:d}=n,{rTickValues:h,axisExtent:f}=n,g="radial"===(null==l?void 0:l.projection),p="horizontal"===(null==l?void 0:l.projection),y=t.useMemo(()=>!l||g?[]:(h||Wn(l.r,5,f)).map(e=>({value:e,pixel:l.r(e),label:(d||ma)(e)})),[l,d,g,h,f]),m=u&&l&&!g,v=c&&l&&!g;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,n)=>e.jsx("line",{x1:p?t.pixel:0,y1:p?0:t.pixel,x2:p?t.pixel:o,y2:p?i:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+n))}),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:o,y2:i,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})]}:{children:[e.jsx("line",{x1:0,y1:i,x2:o,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 ma(e){return Math.round(100*e)/100+""}function va(n){var o,i;const{width:r,height:s,totalWidth:a,totalHeight:l,margin:c,scales:u,showAxes:d,showCategoryTicks:h,oLabel:f,rLabel:g,oFormat:p,rFormat:y,showGrid:m,title:v,legend:b,legendHoverBehavior:x,legendClickBehavior:w,legendHighlightedCategory:k,legendIsolatedCategories:A,legendPosition:j="right",legendLayout:S,foregroundGraphics:C,annotations:O,autoPlaceAnnotations:M,svgAnnotationRules:P,xAccessor:_,yAccessor:L,annotationData:T,underlayRendered:N,children:R}=n,$="radial"===(null==u?void 0:u.projection),D="horizontal"===(null==u?void 0:u.projection),B=!1!==h,I=t.useMemo(()=>d&&B&&u&&!$?u.o.domain().map((e,t)=>{var n;return{value:e,pixel:(null!==(n=u.o(e))&&void 0!==n?n:0)+u.o.bandwidth()/2,label:p?p(e,t):e}}):[],[d,B,u,p,$]),E=n.rTickValues,F=n.tickLabelEdgeAlign,H=n.axisExtent,z=t.useMemo(()=>d&&u&&!$?(E||Wn(u.r,5,H)).map(e=>({value:e,pixel:u.r(e),label:(y||ma)(e)})):[],[d,u,y,$,E,H]),W=t.useRef(new Map),G=t.useRef(null!==(o=null==O?void 0:O.length)&&void 0!==o?o:0),Y=null!==(i=null==O?void 0:O.length)&&void 0!==i?i:0;G.current!==Y&&(G.current=Y,W.current=new Map);const q=t.useMemo(()=>{if(!O||0===O.length)return null;const e=dn(),t="horizontal"===(null==u?void 0:u.projection),n=(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,o={scales:u?{x:t?u.r:n||u.r,y:t&&n||u.r,time:u.r,value:u.r,o:u.o}:null,timeAxis:"x",xAccessor:_,yAccessor:L,width:r,height:s,data:T,frameType:"ordinal",projection:t?"horizontal":"vertical",stickyPositionCache:W.current};return un(M?Tn(Object.assign({annotations:O,context:o},"object"==typeof M?M:{})):O,e,P,o)},[O,M,P,r,s,u,_,L,T]);return d||v||b||C||q&&q.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&&!$&&!N&&e.jsx("g",{className:"ordinal-grid",children:z.map((t,n)=>e.jsx("line",{x1:D?t.pixel:0,y1:D?0:t.pixel,x2:D?t.pixel:r,y2:D?s:t.pixel,stroke:"var(--semiotic-grid, #e0e0e0)",strokeWidth:1},"grid-"+n))}),d&&u&&!$&&(()=>{const t={fontSize:"var(--semiotic-tick-font-size, 12px)"},n={fontSize:"var(--semiotic-axis-label-font-size, 12px)"};return e.jsx("g",{className:"ordinal-axes",children:e.jsxs(e.Fragment,D?{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!N&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),I.map((n,o)=>e.jsxs("g",{transform:`translate(0,${n.pixel})`,children:[e.jsx("line",{x2:-5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.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:n.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:n.label})})]},"cat-"+o)),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"},n),children:f})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!N&&e.jsx("line",{x1:0,y1:s,x2:r,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),!N&&(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})(),z.map((n,o)=>{const i=F?0===o?"start":o===z.length-1?"end":"middle":"middle";return e.jsxs("g",{transform:`translate(${n.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:n.label})]},"val-"+o)}),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"},n),children:g})]})]}:{children:[e.jsxs("g",{className:"semiotic-axis semiotic-axis-bottom","data-orient":"bottom",children:[!N&&(()=>{const t=(null==u?void 0:u.r)?u.r(0):s,n=0>t||t>s?s:t;return e.jsx("line",{x1:0,y1:n,x2:r,y2:n,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1})})(),I.map((n,o)=>e.jsxs("g",{transform:`translate(${n.pixel},${s})`,children:[e.jsx("line",{y2:5,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),"string"==typeof n.label||"number"==typeof n.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:n.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:n.label})})]},"cat-"+o)),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"},n),children:f})]}),e.jsxs("g",{className:"semiotic-axis semiotic-axis-left","data-orient":"left",children:[!N&&e.jsx("line",{x1:0,y1:0,x2:0,y2:s,stroke:"var(--semiotic-border, #ccc)",strokeWidth:1}),z.map((n,o)=>e.jsxs("g",{transform:`translate(0,${n.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:n.label})]},"val-"+o)),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"},n),children:g})]})]})})})(),q,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}),Et({legend:b,totalWidth:a,totalHeight:l,margin:c,legendPosition:j,title:v,legendLayout:S,legendHoverBehavior:x,legendClickBehavior:w,legendHighlightedCategory:k,legendIsolatedCategories:A})]}):null}function ba({width:i,height:r,totalWidth:s,totalHeight:a,margin:l,scales:c,onBrush:u}){const d=t.useRef(null),h=t.useRef(null),f=t.useRef(u);f.current=u;const g=t.useRef(c);g.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=n.select(d.current).select(".brush-g"),t=m?o.brushX():o.brushY();return t.extent([[0,0],[i,r]]),t.on("brush end",e=>{if(p.current)return;const t=g.current;if(!t)return;if(!e.selection)return y.current=null,void f.current(null);const[n,o]=e.selection;let i;i=v.current?[t.r.invert(n),t.r.invert(o)]:[t.r.invert(o),t.r.invert(n)];const r={r:i};y.current=r,f.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=n.select(d.current).select(".brush-g"),o=c.r(e.r[0]),i=c.r(e.r[1]);m?(p.current=!0,t.call(h.current.move,[o,i]),p.current=!1):(p.current=!0,t.call(h.current.move,[i,o]),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 xa(e,t){var n,o,i,r;const s=t._gradientBand.colors;if(0===s.length)return;const{clipPath:a,slices:l}=oo({innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle,endAngle:t.endAngle,cornerRadius:t.cornerRadius,roundStart:null===(o=null===(n=t.roundedEnds)||void 0===n?void 0:n.start)||void 0===o||o,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 wa(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 ka(e,t){const n={innerRadius:t.innerRadius,outerRadius:t.outerRadius,startAngle:t.startAngle+Math.PI/2,endAngle:t.endAngle+Math.PI/2},o=s.arc().cornerRadius(t.cornerRadius)(n);if(!o)return;e.save(),e.translate(t.cx,t.cy);const i=new Path2D(o);e.fill(i),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(i),e.restore()}ua.QUADTREE_THRESHOLD=500;const Aa=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"wedge"===e.type);for(const t of s){const n=null!==(i=t.style.fillOpacity)&&void 0!==i?i:1,o=null!==(r=t.style.opacity)&&void 0!==r?r:1;if(e.globalAlpha=n*o,t._gradientBand&&t._gradientBand.colors.length>0)xa(e,t),t._pulseIntensity&&t._pulseIntensity>0&&(wa(e,t),yi(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 n=no({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 o=new Path2D(n);e.fill(o),t.style.stroke&&"none"!==t.style.stroke&&e.stroke(o),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),ka(e,t)):(wa(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&&(wa(e,t),yi(e,t)),e.globalAlpha=1}}},ja=(e,t,n,o)=>{var i,r;const s=t.filter(e=>"boxplot"===e.type);for(const t of s){const n=t.columnWidth/2,o="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,f=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(),o?(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(),o?(e.moveTo(t.x-.4*n,t.minPos),e.lineTo(t.x+.4*n,t.minPos),e.moveTo(t.x-.4*n,t.maxPos),e.lineTo(t.x+.4*n,t.maxPos)):(e.moveTo(t.minPos,t.y-.4*n),e.lineTo(t.minPos,t.y+.4*n),e.moveTo(t.maxPos,t.y-.4*n),e.lineTo(t.maxPos,t.y+.4*n)),e.stroke(),e.globalAlpha=f,e.fillStyle=c,o){const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(t.x-n,o,t.columnWidth,i),e.globalAlpha=1,e.strokeRect(t.x-n,o,t.columnWidth,i)}else{const o=Math.min(t.q1Pos,t.q3Pos),i=Math.abs(t.q3Pos-t.q1Pos);e.fillRect(o,t.y-n,i,t.columnWidth),e.globalAlpha=1,e.strokeRect(o,t.y-n,i,t.columnWidth)}e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),o?(e.moveTo(t.x-n,t.medianPos),e.lineTo(t.x+n,t.medianPos)):(e.moveTo(t.medianPos,t.y-n),e.lineTo(t.medianPos,t.y+n)),e.stroke(),e.restore()}},Sa=(e,t,n,o)=>{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 n=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(n),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(n)),t.iqrLine){e.strokeStyle="#333",e.lineWidth=2,e.globalAlpha=.8;const n=t.iqrLine.centerPos,o=!1!==t.iqrLine.isVertical;e.beginPath(),o?(e.moveTo(n,t.iqrLine.q1Pos),e.lineTo(n,t.iqrLine.q3Pos)):(e.moveTo(t.iqrLine.q1Pos,n),e.lineTo(t.iqrLine.q3Pos,n)),e.stroke(),e.beginPath(),o?e.arc(n,t.iqrLine.medianPos,3,0,2*Math.PI):e.arc(t.iqrLine.medianPos,n,3,0,2*Math.PI),e.fillStyle="#fff",e.fill(),e.strokeStyle="#333",e.lineWidth=1,e.stroke(),e.globalAlpha=1}e.restore()}},Ca=(e,t,n,o)=>{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 n=t[0].style;if(n.fill&&"none"!==n.fill){e.beginPath(),e.moveTo(t[0].x1,t[0].y1);for(const n of t)e.lineTo(n.x2,n.y2);e.closePath(),e.globalAlpha=null!==(r=null!==(i=n.fillOpacity)&&void 0!==i?i:n.opacity)&&void 0!==r?r:.3,e.fillStyle=n.fill,e.fill(),e.globalAlpha=1}for(const n of t)e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.strokeStyle=rt(e,n.style.stroke)||("string"==typeof n.style.fill?rt(e,n.style.fill):n.style.fill)||rt(e,"var(--semiotic-border, #999)"),e.lineWidth=n.style.strokeWidth||1,e.globalAlpha=null!==(s=n.style.opacity)&&void 0!==s?s:.5,e.stroke(),e.globalAlpha=1}},Oa=(e,t,n,o)=>{var i,r,s,a;const l=t.filter(e=>"trapezoid"===e.type);for(const t of l){const n=t.points;if(n.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(n[0][0],n[0][1]);for(let t=1;n.length>t;t++)e.lineTo(n[t][0],n[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 Ma(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 Pa(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}let _a=null;const La=new Map;function Ta(e,t){const n=`${e}@${"undefined"!=typeof window&&window.devicePixelRatio||1}`,o=La.get(n);if(void 0!==o)return o;const i=function(e={},t){const{background:n="transparent",stroke:o="#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):(_a||(_a=document.createElement("canvas")),_a.width=e,_a.height=e,_a)}(a)}catch(e){return null}const c=l.getContext("2d");if(!c)return null;n&&"transparent"!==n?(c.fillStyle=n,c.fillRect(0,0,a,a)):c.clearRect(0,0,a,a),c.strokeStyle=o,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 La.set(n,i),i}function Na(e,t,n,o,i,r){e.moveTo(t+r,n),e.lineTo(t+o-r,n),e.quadraticCurveTo(t+o,n,t+o,n+r),e.lineTo(t+o,n+i-r),e.quadraticCurveTo(t+o,n+i,t+o-r,n+i),e.lineTo(t+r,n+i),e.quadraticCurveTo(t,n+i,t,n+i-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()}function Ra(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 $a(e){return.05>Math.abs(e-Math.round(e))?Math.round(e)+"%":e.toFixed(1)+"%"}const Da=e=>[Ca,...e],Ba={bar:Da([ki]),clusterbar:Da([ki]),point:Da([bi]),swarm:Da([bi]),pie:[Aa],donut:[Aa],boxplot:Da([ja,bi]),violin:Da([Sa]),histogram:Da([ki]),ridgeline:Da([Sa]),timeline:Da([ki]),funnel:[ki,Oa,(e,t,n,o)=>{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,n;return null!=(null===(t=e.datum)||void 0===t?void 0:t.__funnelStepLabel)||null!=(null===(n=e.datum)||void 0===n?void 0:n.__funnelValueLabelX)})){e.textBaseline="top",e.lineJoin="round",e.textAlign="center",e.font="bold 14px sans-serif";for(const t of l){const n=t.datum;if(!n)continue;if(!n.__funnelStepLabel)continue;const o=n.__funnelStepLabel;if(e.measureText(o).width+16>(null!==(r=null!==(i=n.__funnelRowWidth)&&void 0!==i?i:n.__funnelBarW)&&void 0!==r?r:0))continue;const s=n.__funnelStepLabelX,a=n.__funnelStepLabelY+3;e.strokeStyle="rgba(0,0,0,0.6)",e.lineWidth=3,e.strokeText(o,s,a),e.fillStyle="#fff",e.fillText(o,s,a)}e.font="bold 13px sans-serif";for(const t of l){const n=t.datum;if(!n)continue;if(null==n.__funnelValueLabelX)continue;const o=null!==(s=n.__funnelBarW)&&void 0!==s?s:0;if(60>o)continue;const i=n.__funnelValue;if(null==i||0===i)continue;const r=n.__funnelPercent,l=!0===n.__funnelIsFirstStep;let c;if(c=l?Ma(i):null!=r?`${Ma(i)} (${Pa(r)})`:Ma(i),e.measureText(c).width+16>o){if(l||null==r)continue;if(c=Ma(i),e.measureText(c).width+16>o)continue}const u=n.__funnelValueLabelX,d=(null!==(a=n.__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":[ki,(e,t,n,o)=>{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 n=("string"==typeof t.style.fill?t.style.fill:null)||rt(e,"var(--semiotic-border, #999)"),o=Ta(n,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),o?e.fillStyle=o:(e.fillStyle=n,e.globalAlpha=.4*(null!==(r=t.style.opacity)&&void 0!==r?r:1)),e.fill(),e.globalAlpha=1}},(e,t,n,o)=>{const i=t.filter(e=>{var t,n;return"rect"===e.type&&!0!==(null===(t=e.datum)||void 0===t?void 0:t.__barFunnelIsDropoff)&&null!=(null===(n=e.datum)||void 0===n?void 0:n.__barFunnelLabelX)});if(0===i.length)return;const r=function(e,t){const[n,o,i]=st(e,t);return(.2126*n+.7152*o+.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 n=t.datum;if(!n)continue;const o=n.__barFunnelValue;if(null==o)continue;if(25>t.w)continue;const i=n.__barFunnelPercent,r=!(!0===n.__barFunnelIsFirstStep)&&null!=i,u=r?$a(i):"",d=Ra(o);e.font="bold 13px sans-serif";const h=r?e.measureText(u).width:0;e.font="11px sans-serif";const f=e.measureText(d).width,g=Math.max(h,f)+12,p=r?32:17,y=n.__barFunnelLabelX,m=y-g/2,v=n.__barFunnelLabelY-p-4;e.save(),e.shadowColor="rgba(0,0,0,0.15)",e.shadowBlur=4,e.shadowOffsetY=1,e.fillStyle=s,e.beginPath(),Na(e,m,v,g,p,4),e.fill(),e.restore(),e.strokeStyle=a,e.lineWidth=.5,e.beginPath(),Na(e,m,v,g,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:Da([ki]),custom:Da([ki,bi,Aa,ja,Sa,Oa])},Ia={top:50,right:40,bottom:60,left:70},Ea={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 Fa({hover:t}){var n,o,i,r,s,a;const l=t.data||{},c=t.stats,u=t.category;if(Array.isArray(l)){const t=u||(null===(n=l[0])||void 0===n?void 0:n.category)||"";if(c)return e.jsxs("div",{className:"semiotic-tooltip",style:Ea,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 o=l.length;return e.jsxs("div",{className:"semiotic-tooltip",style:Ea,children:[t&&e.jsx("div",{style:{fontWeight:"bold"},children:t+""}),e.jsxs("div",{children:[o," items"]})]})}if(null!=l.bin&&null!=l.count){const t=l.range||[];return e.jsxs("div",{className:"semiotic-tooltip",style:Ea,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,f=t.__chartType;if("swarm"===f||"point"===f){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:Ea,children:t.map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof n?n.toLocaleString():n+""]},t))})}const g=(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!==(o=l.__aggregateValue)&&void 0!==o?o: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(!g&&""===p){const t=Object.entries(l).filter(([e])=>!e.startsWith("_")&&"data"!==e);return e.jsx("div",{className:"semiotic-tooltip",style:Ea,children:t.map(([t,n])=>e.jsxs("div",{children:[e.jsxs("span",{style:{opacity:.7},children:[t,":"]})," ","number"==typeof n?n.toLocaleString():n+""]},t))})}return e.jsxs("div",{className:"semiotic-tooltip",style:Ea,children:[g&&e.jsx("div",{style:{fontWeight:"bold"},children:g+""}),""!==p&&e.jsx("div",{children:"number"==typeof p?p.toLocaleString():p+""})]})}Fa.ownsChrome=!0;const Ha=t.forwardRef(function(n,o){var i,r,a,l,c,u,d,h,f,g,y;const{chartType:m,runtimeMode:b,data:x,oAccessor:w="category",rAccessor:A="value",colorAccessor:j,stackBy:C,groupBy:O,multiAxis:M,timeAccessor:P,valueAccessor:_,categoryAccessor:L,projection:T="vertical",size:N=[600,400],responsiveWidth:R,responsiveHeight:$,margin:D,barPadding:B,roundedTop:I,gradientFill:E,trackFill:F,baselinePadding:H,innerRadius:z,cornerRadius:W,normalize:G,startAngle:Y,sweepAngle:q,dynamicColumnWidth:V,bins:X,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:ne,rExtent:oe,oExtent:ie,extentPadding:re=.05,oSort:se,windowMode:ae="sliding",windowSize:le=200,pieceStyle:ce,summaryStyle:ue,colorScheme:de,barColors:he,showAxes:fe=!0,showCategoryTicks:ge,categoryLabel:pe,valueLabel:ye,categoryFormat:me,valueFormat:ve,oLabel:be,rLabel:xe,oFormat:we,rFormat:ke,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,enableHover:Ce=!0,hoverAnnotation:Oe,tooltipContent:Me,customHoverBehavior:Pe,annotations:_e,autoPlaceAnnotations:Le,svgAnnotationRules:Te,showGrid:Ne=!1,legend:Re,legendHoverBehavior:$e,legendClickBehavior:De,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,legendPosition:Ee,legendLayout:Fe,legendCategoryAccessor:He,onCategoriesChange:ze,backgroundGraphics:We,foregroundGraphics:Ge,title:qe,className:Ve,background:Xe,centerContent:Ue,decay:Ke,pulse:Ze,transition:Je,animate:et,staleness:tt,brush:nt,onBrush:ot,accessibleTable:it=!0,description:st,summary:at,customLayout:lt,layoutConfig:ct}=n,ut=t.useRef(!0),dt=ai({sizeProp:N,responsiveWidth:R,responsiveHeight:$,userMargin:D,marginDefault:Ia,foregroundGraphics:Ge,backgroundGraphics:We,animate:et,transitionProp:Je,themeDirtyRef:ut}),{reducedMotionRef:ht,responsiveRef:ft,size:gt,margin:pt,adjustedWidth:yt,adjustedHeight:mt,resolvedForeground:vt,resolvedBackground:bt,currentTheme:xt,transition:wt,introEnabled:kt,tableId:Ct,rafRef:Ot,renderFnRef:_t,scheduleRender:Lt}=dt,Tt=co(),Nt=go(),Rt=t.useMemo(()=>v(x),[x]),$t=null!=pe?pe:be,Dt=null!=ye?ye:xe,Bt=null!=me?me:we,It=null!=ve?ve:ke,Et=t.useRef(null),Ft=t.useRef(null),Ht=t.useRef([]),zt=t.useRef(He),Wt=t.useRef(ze);zt.current=He,Wt.current=ze;const[Gt,Yt]=t.useState(null),[qt,Vt]=t.useState(null),[Xt,Ut]=t.useState(0),[Kt,Qt]=t.useState(!1),[Zt,Jt]=t.useState(null),en=t.useCallback(()=>{var e,t;Jt(null!==(t=null===(e=sn.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]),tn=Ce||Oe,nn="streaming"===b,on=t.useMemo(()=>{var e,t,n;return{chartType:m,runtimeMode:nn?"streaming":"bounded",windowSize:le,windowMode:ae,extentPadding:re,projection:T,oAccessor:nn?void 0:w,rAccessor:nn?void 0:A,colorAccessor:j,stackBy:C,groupBy:O,multiAxis:M,timeAccessor:nn?P:void 0,valueAccessor:nn?_||("string"==typeof A||"function"==typeof A?A:void 0):void 0,categoryAccessor:nn?L||w:void 0,rExtent:oe,oExtent:ie,axisExtent:Se,barPadding:B,roundedTop:I,gradientFill:E,trackFill:F,baselinePadding:H,innerRadius:z,cornerRadius:W,normalize:G,startAngle:Y,sweepAngle:q,dynamicColumnWidth:V,bins:X,showOutliers:U,showIQR:K,amplitude:Q,connectorOpacity:Z,showLabels:J,connectorAccessor:ee,connectorStyle:te,dataIdAccessor:ne,oSort:se,pieceStyle:ce,summaryStyle:ue,colorScheme:de,themeCategorical:null===(e=null==xt?void 0:xt.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(xt),themeSequential:null===(t=null==xt?void 0:xt.colors)||void 0===t?void 0:t.sequential,themeDiverging:null===(n=null==xt?void 0:xt.colors)||void 0===n?void 0:n.diverging,barColors:he,decay:Ke,pulse:Ze,transition:wt,introAnimation:kt,staleness:tt,customLayout:lt,layoutConfig:ct,layoutMargin:pt}},[m,le,ae,re,T,w,A,j,C,O,M,P,_,L,oe,ie,Se,B,I,E,F,H,z,W,G,Y,q,V,X,U,K,Q,Z,J,ee,te,ne,se,ce,ue,de,he,Ke,Ze,null==wt?void 0:wt.duration,null==wt?void 0:wt.easing,kt,tt,nn,xt,lt,ct,pt]),rn=yo(on),sn=t.useRef(null);sn.current||(sn.current=new ua(rn));const an=t.useCallback(()=>{var e,t;const n=zt.current,o=Wt.current;if(!o||!n)return;const i=Mi(null!==(t=null===(e=sn.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[],n);Pi(i,Ht.current)||(Ht.current=i,o(i))},[]);t.useEffect(()=>{var e;null===(e=sn.current)||void 0===e||e.updateConfig(rn),ut.current=!0,Lt()},[rn,Lt]);const ln=t.useRef(null);ln.current||(ln.current=new k(e=>{const t=sn.current;t&&t.ingest(e)&&(ut.current=!0,Lt())}));const cn=t.useCallback(e=>{var t;null===(t=ln.current)||void 0===t||t.push(e)},[]),un=t.useCallback(e=>{var t;null===(t=ln.current)||void 0===t||t.pushMany(e)},[]),dn=t.useCallback(()=>{var e,t;null===(e=ln.current)||void 0===e||e.clear(),null===(t=sn.current)||void 0===t||t.clear(),ut.current=!0,Lt()},[Lt]),hn=t.useCallback(e=>{var t,n;null===(t=ln.current)||void 0===t||t.clearLastData(),null===(n=ln.current)||void 0===n||n.setReplacementData(e)},[]);t.useImperativeHandle(o,()=>({push:cn,pushMany:un,replace:hn,remove:e=>{var t,n,o,i;null===(t=ln.current)||void 0===t||t.flush();const r=null!==(o=null===(n=sn.current)||void 0===n?void 0:n.remove(e))&&void 0!==o?o:[];if(r.length>0){const e=null===(i=Ft.current)||void 0===i?void 0:i.data;!!Ft.current&&r.some(Array.isArray(e)?t=>e.includes(t):t=>t===e)&&(Ft.current=null,Yt(null)),ut.current=!0,Lt()}return r},update:(e,t)=>{var n,o,i;null===(n=ln.current)||void 0===n||n.flush();const r=null!==(i=null===(o=sn.current)||void 0===o?void 0:o.update(e,t))&&void 0!==i?i:[];return r.length>0&&(ut.current=!0,Lt()),r},clear:dn,getData:()=>{var e,t,n;return null===(e=ln.current)||void 0===e||e.flush(),null!==(n=null===(t=sn.current)||void 0===t?void 0:t.getData())&&void 0!==n?n:[]},getScales:()=>{var e,t;return null!==(t=null===(e=sn.current)||void 0===e?void 0:e.scales)&&void 0!==t?t:null}}),[cn,un,hn,dn,Lt]),t.useEffect(()=>{var e;x&&(null===(e=ln.current)||void 0===e||e.setBoundedData(Rt))},[x,Rt]);const{hoverHandlerRef:fn,hoverLeaveRef:gn,onPointerMove:pn,onPointerLeave:yn}=dt;fn.current=e=>{if(!tn)return;const t=Et.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-pt.left,i=e.clientY-n.top-pt.top;if(0>o||o>yt||0>i||i>mt)return void(Ft.current&&(Ft.current=null,Yt(null),Pe&&Pe(null),Lt()));const r=sn.current;if(!r||0===r.scene.length)return;const s="radial"===T,a=function(e,t,n,o=30,i,r=0){let s=null;if(i){const e=Qe(i,t,n,o,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=da(r,t,n);break;case"point":if(i)break;e=ha(r,t,n,o);break;case"wedge":if(null===r.datum)break;e=fa(r,t,n);break;case"boxplot":e=ga(r,t,n);break;case"violin":e=pa(r,t,n)}e&&o>e.distance&&(s&&e.distance>=s.distance||(s=e))}return s}(r.scene,s?o-yt/2:o,s?i-mt/2:i,30,r.pointQuadtree,r.maxPointRadius);if(!a)return void(Ft.current&&(Ft.current=null,Yt(null),Pe&&Pe(null),Lt()));const l=Xo(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 w?w:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m}));Ft.current=l,Yt(l),Pe&&(Pe(l),ut.current=!0),Lt()},gn.current=()=>{Ft.current&&(Ft.current=null,Yt(null),Pe&&(Pe(null),ut.current=!0),Lt())};const mn=t.useRef(-1),vn=t.useRef(null),bn=t.useRef(null),xn=t.useCallback(e=>{const t=sn.current;if(!t||0===t.scene.length)return;const n=t.version;let o;if(bn.current&&bn.current.version===n)o=bn.current.graph;else{const e=function(e){var t,n,o;const i=[];for(const r of e)if("rect"===r.type&&null!=r.x){if(null==r.datum)continue;const e=null!==(n=null===(t=r.datum)||void 0===t?void 0:t.category)&&void 0!==n?n:"";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!==(o=r.group)&&void 0!==o?o: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;o=At(e),bn.current={version:n,graph:o}}const i=mn.current;if(0>i){if("Escape"===e.key)return;if(!["ArrowRight","ArrowLeft","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(e.key))return;e.preventDefault(),mn.current=0;const t=o.flat[0];vn.current={shape:t.shape,w:t.w,h:t.h};const n=Object.assign(Object.assign({},Mt(t)),{__oAccessor:"string"==typeof w?w:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});return Ft.current=n,Yt(n),Pe&&Pe(n),void Lt()}const r=jt(o,i),s=St(e.key,r,o);if(null===s)return;if(e.preventDefault(),0>s)return mn.current=-1,vn.current=null,Ft.current=null,Yt(null),Pe&&Pe(null),void Lt();mn.current=s;const a=o.flat[s];vn.current={shape:a.shape,w:a.w,h:a.h};const l=Object.assign(Object.assign({},Mt(a)),{__oAccessor:"string"==typeof w?w:void 0,__rAccessor:"string"==typeof A?A:void 0,__chartType:m});Ft.current=l,Yt(l),Pe&&Pe(l),Lt()},[Pe,Lt]),wn=t.useCallback(e=>{mn.current=-1,vn.current=null,pn(e)},[pn]);_t.current=()=>{var e,t;Ot.current=0;const n=Et.current;if(!n)return;const o=n.getContext("2d");if(!o)return;const i=sn.current;if(!i)return;const r="undefined"!=typeof performance?performance.now():Date.now(),s=i.advanceTransition(ht.current?r+1e6:r),a=!ht.current&&s,l=ut.current;l&&!s&&(i.computeScene({width:yt,height:mt}),an(),en(),ut.current=!1),(l||a)&&n.setAttribute("aria-label",jo(i.scene,m+" chart"));const c=ci(),u=gt[0]*c,d=gt[1]*c;n.width===u&&n.height===d||(n.width=u,n.height=d,n.style.width=gt[0]+"px",n.style.height=gt[1]+"px"),o.setTransform(c,0,0,c,0,0),o.clearRect(0,0,gt[0],gt[1]);const h=null!==(e=null==tt?void 0:tt.threshold)&&void 0!==e?e:5e3,f=tt&&i.lastIngestTime>0&&r-i.lastIngestTime>h;if(f&&(o.globalAlpha=null!==(t=null==tt?void 0:tt.dimOpacity)&&void 0!==t?t:.5),"transparent"!==Xe&&!We){const e=n?getComputedStyle(n).getPropertyValue("--semiotic-bg").trim():"",t=Xe||(e&&"transparent"!==e?e:null),i=t?rt(o,t):null;i&&(o.fillStyle=i,o.fillRect(0,0,gt[0],gt[1]))}const g="radial"===T;o.save(),o.beginPath(),o.rect(pt.left,pt.top,yt,mt),o.clip(),g?(o.save(),o.translate(pt.left+yt/2,pt.top+mt/2)):o.translate(pt.left,pt.top);const p=lt?Ba.custom:Ba[m]||[],y={width:yt,height:mt};for(const e of p)e(o,i.scene,i.scales,y);g&&o.restore(),o.restore(),f&&(o.globalAlpha=1),l&&i.scales&&(Vt(i.scales),Ut(e=>e+1)),(null==tt?void 0:tt.showBadge)&&Qt(!!f),(a||null!=i.activeTransition||i.hasActivePulses)&&(Ot.current=requestAnimationFrame(()=>_t.current()))},po({hydrated:Tt,wasHydratingFromSSR:Nt,storeRef:sn,dirtyRef:ut,renderFnRef:_t,cleanup:()=>{var e;return null===(e=ln.current)||void 0===e?void 0:e.clear()}}),t.useEffect(()=>{ut.current=!0,Lt()},[m,yt,mt,fe,Xe,Lt]),Pt(tt,sn,ut,Lt,Kt,Qt);const kn=tn&&Gt?Me?Me(Gt):e.jsx(Fa,{hover:Gt}):null,An="radial"===T,jn=kn?e.jsx(ti,{x:Gt?An?Gt.x+yt/2:Gt.x:0,y:Gt?An?Gt.y+mt/2:Gt.y:0,containerWidth:yt,containerHeight:mt,margin:pt,className:"stream-ordinal-tooltip",children:kn}):null,Sn=_i(w,void 0,"__semiotic_resolvedO",""),Cn=_i(A,void 0,"__semiotic_resolvedR",""),On=Sn.key,Mn=Cn.key,Pn=Li(Sn,Cn,_e&&_e.length>0||!1);if(ao||!Tt&&Nt){const t=sn.current;t&&x&&(t.ingest({inserts:Rt,bounded:!0}),t.computeScene({width:yt,height:mt}));const n=null!==(i=null==t?void 0:t.scene)&&void 0!==i?i:[],o=null!==(r=null==t?void 0:t.scales)&&void 0!==r?r:null,l="radial"===T,c=l?pt.left+yt/2:pt.left,u=l?pt.top+mt/2:pt.top;return e.jsxs("div",{ref:ft,className:"stream-ordinal-frame"+(Ve?" "+Ve:""),role:"img","aria-label":st||("string"==typeof qe?qe:"Ordinal chart"),style:{position:"relative",width:R?"100%":gt[0],height:$?"100%":gt[1]},children:[e.jsx(zo,{summary:at}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:gt[0],height:gt[1],style:{position:"absolute",left:0,top:0},children:[bt&&e.jsx("g",{transform:`translate(${pt.left},${pt.top})`,children:bt}),e.jsxs("g",{transform:`translate(${c},${u})`,children:[Xe&&e.jsx("rect",{x:0,y:0,width:yt,height:mt,fill:Xe}),n.map((t,n)=>function(t,n,o){var i,r,a,l,c,u,d,h,f;const g=("category"in t?t.category:void 0)||("group"in t?t.group:void 0)||"",y=e=>`ord-${t.type}-${g}-${n}-${e}`,m=`ord-${t.type}-${g}-${n}`;switch(t.type){case"rect":{const n=t,o=so(m)+"-grad",i=function(t,n){const o=t.fillGradient;if(!o)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 o){const t=o.colorStops.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:Math.max(0,Math.min(1,e.offset)),color:e.color}));if(2>t.length)return null;for(let n=0;t.length>n;n++)l.push(e.jsx("stop",{offset:t[n].offset,stopColor:t[n].color},n))}else{const n=ro(t.style.fill);l.push(e.jsx("stop",{offset:0,stopColor:n,stopOpacity:o.topOpacity},"0")),l.push(e.jsx("stop",{offset:1,stopColor:n,stopOpacity:o.bottomOpacity},"1"))}return e.jsx("linearGradient",{id:n,gradientUnits:"userSpaceOnUse",x1:i,y1:r,x2:s,y2:a,children:l})}(n,o),r=i?`url(#${o})`:ro(n.style.fill);if(n.cornerRadii&&Jn(n.cornerRadii)){const t=function(e){const{x:t,y:n,w:o,h:i}=e,{tl:r,tr:s,br:a,bl:l}=eo(e);let c=`M${t+r},${n}`;return c+=` L${t+o-s},${n}`,s>0&&(c+=` A${s},${s} 0 0 1 ${t+o},${n+s}`),c+=` L${t+o},${n+i-a}`,a>0&&(c+=` A${a},${a} 0 0 1 ${t+o-a},${n+i}`),c+=` L${t+l},${n+i}`,l>0&&(c+=` A${l},${l} 0 0 1 ${t},${n+i-l}`),c+=` L${t},${n+r}`,r>0&&(c+=` A${r},${r} 0 0 1 ${t+r},${n}`),c+=" Z",c}(n);return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:t,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},m)}if(n.roundedTop&&n.roundedTop>0){const t=Math.min(n.roundedTop,n.w/2,n.h/2),{x:o,y:s,w:a,h:l}=n;let c;switch(n.roundedEdge){case"right":c=`M${o},${s} L${o+a-t},${s} A${t},${t} 0 0 1 ${o+a},${s+t} L${o+a},${s+l-t} A${t},${t} 0 0 1 ${o+a-t},${s+l} L${o},${s+l} Z`;break;case"left":c=`M${o+a},${s} L${o+t},${s} A${t},${t} 0 0 0 ${o},${s+t} L${o},${s+l-t} A${t},${t} 0 0 0 ${o+t},${s+l} L${o+a},${s+l} Z`;break;case"bottom":c=`M${o},${s} L${o+a},${s} L${o+a},${s+l-t} A${t},${t} 0 0 1 ${o+a-t},${s+l} L${o+t},${s+l} A${t},${t} 0 0 1 ${o},${s+l-t} Z`;break;default:c=`M${o},${s+l} L${o},${s+t} A${t},${t} 0 0 1 ${o+t},${s} L${o+a-t},${s} A${t},${t} 0 0 1 ${o+a},${s+t} L${o+a},${s+l} Z`}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("path",{d:c,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},m)}return e.jsxs(p.Fragment,{children:[i&&e.jsx("defs",{children:i}),e.jsx("rect",{x:n.x,y:n.y,width:n.w,height:n.h,fill:r,opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth})]},m)}case"point":{const n=t;return e.jsx("circle",{cx:n.x,cy:n.y,r:n.r,fill:ro(n.style.fill),opacity:null!==(i=n.style.opacity)&&void 0!==i?i:.8,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},m)}case"wedge":{const i=t;if(i._gradientBand&&i._gradientBand.colors.length>0){const t=so(`${o?o+"-":""}gauge-grad-${i.category||m}-${n}`),{clipPath:s,slices:u}=oo({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,n)=>e.jsx("path",{d:t.d,fill:ro(t.color)},n))}),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=no({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(io)||""}return e.jsx("path",{d:u,transform:`translate(${i.cx},${i.cy})`,fill:ro(i.style.fill),stroke:i.style.stroke,strokeWidth:i.style.strokeWidth,opacity:i.style.opacity},m)}case"boxplot":{const n=t,o=n.columnWidth/2;return e.jsxs("g","vertical"===n.projection?{children:[e.jsx("line",{x1:n.x,y1:n.minPos,x2:n.x,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:n.x-o,y:Math.min(n.q1Pos,n.q3Pos),width:n.columnWidth,height:Math.abs(n.q3Pos-n.q1Pos),fill:ro(n.style.fill),fillOpacity:null!==(u=n.style.fillOpacity)&&void 0!==u?u:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:n.x-o,y1:n.medianPos,x2:n.x+o,y2:n.medianPos,stroke:n.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:n.x-.5*o,y1:n.minPos,x2:n.x+.5*o,y2:n.minPos,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:n.x-.5*o,y1:n.maxPos,x2:n.x+.5*o,y2:n.maxPos,stroke:n.style.stroke||"#333",strokeWidth:1})]}:{children:[e.jsx("line",{x1:n.minPos,y1:n.y,x2:n.maxPos,y2:n.y,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("rect",{x:Math.min(n.q1Pos,n.q3Pos),y:n.y-o,width:Math.abs(n.q3Pos-n.q1Pos),height:n.columnWidth,fill:ro(n.style.fill),fillOpacity:null!==(d=n.style.fillOpacity)&&void 0!==d?d:.6,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:n.medianPos,y1:n.y-o,x2:n.medianPos,y2:n.y+o,stroke:n.style.stroke||"#333",strokeWidth:2}),e.jsx("line",{x1:n.minPos,y1:n.y-.5*o,x2:n.minPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1}),e.jsx("line",{x1:n.maxPos,y1:n.y-.5*o,x2:n.maxPos,y2:n.y+.5*o,stroke:n.style.stroke||"#333",strokeWidth:1})]},m)}case"violin":{const n=t,o=[e.jsx("path",{d:n.pathString,transform:n.translateX||n.translateY?`translate(${n.translateX},${n.translateY})`:void 0,fill:ro(n.style.fill),fillOpacity:null!==(h=n.style.fillOpacity)&&void 0!==h?h:.6,stroke:n.style.stroke||"#333",strokeWidth:n.style.strokeWidth||1},y("path"))];if(n.iqrLine&&n.bounds){const t=n.bounds,i=t.x+t.width/2,r=t.y+t.height/2;t.height>t.width?o.push(e.jsx("line",{x1:i,y1:n.iqrLine.q1Pos,x2:i,y2:n.iqrLine.q3Pos,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),e.jsx("circle",{cx:i,cy:n.iqrLine.medianPos,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med"))):o.push(e.jsx("line",{x1:n.iqrLine.q1Pos,y1:r,x2:n.iqrLine.q3Pos,y2:r,stroke:n.style.stroke||"#333",strokeWidth:2},y("iqr")),e.jsx("circle",{cx:n.iqrLine.medianPos,cy:r,r:3,fill:"white",stroke:n.style.stroke||"#333",strokeWidth:1},y("med")))}return e.jsx("g",{children:o},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!==(f=t.style.opacity)&&void 0!==f?f:.5},m);case"trapezoid":{const n=t,o=n.points.map(e=>`${e[0]},${e[1]}`).join(" ");return e.jsx("polygon",{points:o,fill:ro(n.style.fill,"#999"),opacity:n.style.opacity,stroke:n.style.stroke,strokeWidth:n.style.strokeWidth},m)}default:return null}}(t,n,Ct)).filter(Boolean)]})]}),e.jsx(va,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:o,showAxes:fe,showCategoryTicks:ge,oLabel:$t,rLabel:Dt,oFormat:Bt,rFormat:It,rTickValues:Ae,tickLabelEdgeAlign:je,axisExtent:Se,showGrid:Ne,title:qe,legend:Re,legendHoverBehavior:$e,legendClickBehavior:De,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,legendPosition:Ee,legendLayout:Fe,foregroundGraphics:Ye(vt,null===(a=sn.current)||void 0===a?void 0:a.customLayoutOverlays),annotations:_e,autoPlaceAnnotations:Le,svgAnnotationRules:Te,annotationFrame:0,xAccessor:On,yAccessor:Mn,annotationData:Pn(null==t?void 0:t.getData())}),Ue&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:pt.left+yt/2,top:pt.top+mt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Ue})]})}return e.jsxs("div",{ref:ft,className:"stream-ordinal-frame"+(Ve?" "+Ve:""),role:"group","aria-label":st||("string"==typeof qe?qe:"Ordinal chart"),tabIndex:0,style:{position:"relative",width:R?"100%":gt[0],height:$?"100%":gt[1],overflow:"visible"},onKeyDown:xn,children:[it&&e.jsx(Wo,{tableId:Ct}),it&&e.jsx(Fo,{scene:null!==(c=null===(l=sn.current)||void 0===l?void 0:l.scene)&&void 0!==c?c:[],chartType:m+" chart",tableId:Ct,chartTitle:"string"==typeof qe?qe:void 0}),e.jsx(zo,{summary:at}),e.jsx(Go,{hoverPoint:Gt}),e.jsxs("div",{role:"img","aria-label":st||("string"==typeof qe?qe:"Ordinal chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:tn?wn:void 0,onMouseLeave:tn?yn:void 0,children:[bt&&e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:gt[0],height:gt[1],pointerEvents:"none"},children:e.jsx("g",{transform:`translate(${pt.left},${pt.top})`,children:bt})}),e.jsx(ya,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:qt,showAxes:fe,showGrid:Ne,rFormat:It,rTickValues:Ae,axisExtent:Se}),e.jsx("canvas",{ref:Et,"aria-label":jo(null!==(d=null===(u=sn.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(va,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:qt,showAxes:fe,showCategoryTicks:ge,oLabel:$t,rLabel:Dt,oFormat:Bt,rFormat:It,rTickValues:Ae,axisExtent:Se,showGrid:Ne,title:qe,legend:Re,legendHoverBehavior:$e,legendClickBehavior:De,legendHighlightedCategory:Be,legendIsolatedCategories:Ie,legendPosition:Ee,legendLayout:Fe,foregroundGraphics:Ye(vt,Zt),annotations:_e,autoPlaceAnnotations:Le,svgAnnotationRules:Te,annotationFrame:Xt,xAccessor:On,yAccessor:Mn,annotationData:Pn(null===(h=sn.current)||void 0===h?void 0:h.getData()),underlayRendered:!0}),(nt||ot)&&"radial"!==T&&e.jsx(ba,{width:yt,height:mt,totalWidth:gt[0],totalHeight:gt[1],margin:pt,scales:qt,onBrush:ot||(()=>{})}),Ue&&"radial"===T&&e.jsx("div",{style:{position:"absolute",left:pt.left+yt/2,top:pt.top+mt/2,transform:"translate(-50%, -50%)",pointerEvents:"none",textAlign:"center"},children:Ue}),(null==tt?void 0:tt.showBadge)&&e.jsx("div",{className:"stream-staleness-badge",style:Object.assign(Object.assign({position:"absolute"},"top-left"===tt.badgePosition?{top:4,left:4}:"bottom-left"===tt.badgePosition?{bottom:4,left:4}:"bottom-right"===tt.badgePosition?{bottom:4,right:4}:{top:4,right:4}),{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:600,pointerEvents:"none",background:Kt?"#dc3545":"#28a745",color:"white"}),children:Kt?"STALE":"LIVE"}),e.jsx(qo,{active:mn.current>=0,hoverPoint:Gt,margin:pt,size:gt,shape:null===(f=vn.current)||void 0===f?void 0:f.shape,width:null===(g=vn.current)||void 0===g?void 0:g.w,height:null===(y=vn.current)||void 0===y?void 0:y.h}),jn]})]})});function za({ref:e,frameRef:n,setup:o}){return t.useImperativeHandle(e,()=>({push:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=n.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,o;return null!==(o=null===(t=n.current)||void 0===t?void 0:t.remove(e))&&void 0!==o?o:[]},update:(e,t)=>{var o,i;return null!==(i=null===(o=n.current)||void 0===o?void 0:o.update(e,t))&&void 0!==i?i:[]},clear:()=>{var e;return null===(e=n.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=n.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[n]),{effectiveLegendProps:o.legendBehaviorProps,effectiveMargin:o.margin}}function Wa(e){const{colorBy:n,colorScale:o,color:i,themeCategorical:r,colorScheme:s,categoryIndexMap:a,userPieceStyle:l,stroke:c,strokeWidth:u,opacity:d,effectiveSelectionHook:h,resolvedSelection:f,cycleByCategory:g=!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(n){if(!o)return c;c.fill=we(e,n,o)}else c.fill=Cr(i,r,s,g?t:void 0,a);return y&&void 0===c.stroke&&void 0!==c.fill&&(c.stroke=c.fill),c},[n,o,i,r,s,a,g,p,y]),v=t.useMemo(()=>ls(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(()=>fr(v,null!=h?h:null,f),[v,h,f])}Ha.displayName="StreamOrdinalFrame";const Ga=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:f,colorScheme:g,sort:p=!1,barPadding:y=40,roundedTop:m,gradientFill:b=!1,baselinePadding:x=!1,tooltip:w,annotations:k,regression:A,valueExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:N,emptyContent:R,legendInteraction:$,legendPosition:D,color:B,stroke:I,strokeWidth:E,opacity:F,showCategoryTicks:H,categoryFormat:z,dataIdAccessor:W}=n,{width:G,height:Y,enableHover:q,showGrid:V,showLegend:X,title:U,description:K,summary:Q,accessibleTable:Z,categoryLabel:J,valueLabel:ee}=i,te=t.useMemo(()=>v(s),[s]),ne=as({data:te,rawData:s,colorBy:f,colorScheme:g,legendInteraction:$,legendPosition:D,selection:C,linkedHover:O,fallbackFields:f?["string"==typeof f?f:""]:[],unwrapData:!0,onObservation:M,onClick:P,hoverHighlight:_,chartType:"BarChart",chartId:L,showLegend:X,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:N,emptyContent:R,width:G,height:Y}),{effectiveLegendProps:oe,effectiveMargin:ie}=za({ref:o,frameRef:r,setup:ne});Zr("BarChart",te,"categoryAccessor",c),Zr("BarChart",te,"valueAccessor",u);const re=Mr(te,p,u),se=Sr(),ae=t.useMemo(()=>new Map,[te]),le=Wa({colorBy:f,colorScale:ne.colorScale,color:B,themeCategorical:se,colorScheme:g,categoryIndexMap:ae,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:E,opacity:F,effectiveSelectionHook:ne.effectiveSelectionHook,resolvedSelection:ne.resolvedSelection}),ce=t.useMemo(()=>zr({categoryAccessor:c,valueAccessor:u,groupAccessor:f&&f!==c?f:void 0,groupLabel:"string"==typeof f?f:"group",valueFormat:h}),[c,u,f,h]);if(ne.earlyReturn)return ne.earlyReturn;const ue=os({componentName:"BarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(Wr,{componentName:"BarChart",message:ue,width:G,height:Y});const de=Ls(A),he=de?[de,...k||[]]:k,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(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:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ie,barPadding:y}),null!=m&&{roundedTop:m}),b&&{gradientFill:!0===b?{topOpacity:.8,bottomOpacity:.05}:b}),W&&{dataIdAccessor:W}),{baselinePadding:x,enableHover:q,showAxes:i.showAxes,oLabel:J,rLabel:ee,rFormat:h}),z&&{oFormat:z}),{showGrid:V,showCategoryTicks:H,oSort:p}),oe),xs({title:U,description:K,summary:Q,accessibleTable:Z,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:w,defaultTooltipContent:ce})),ws({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:ne.customHoverBehavior,customClickBehavior:ne.customClickBehavior})),he&&he.length>0&&{annotations:he}),j&&{rExtent:j}),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"BarChart",width:G,height:Y,children:e.jsx(Ha,Object.assign({ref:r},fe))})});Ga.displayName="BarChart";const Ya=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",stackBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:f,colorBy:g,colorScheme:p,normalize:y=!1,sort:m=!1,barPadding:b=40,roundedTop:x,baselinePadding:w=!1,tooltip:k,annotations:A,valueExtent:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:N,emptyContent:R,legendInteraction:$,legendPosition:D,color:B,stroke:I,strokeWidth:E,opacity:F,categoryFormat:H}=n,{width:z,height:W,enableHover:G,showGrid:Y,showLegend:q,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=g||u,te=as({data:J,rawData:s,colorBy:ee,colorScheme:p,legendInteraction:$,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:N,emptyContent:R,width:z,height:W}),ne=Sr(),oe=t.useMemo(()=>new Map,[J]),ie=Wa({colorBy:ee,colorScale:te.colorScale,color:B,themeCategorical:ne,colorScheme:p,categoryIndexMap:oe,userPieceStyle:null==S?void 0:S.pieceStyle,stroke:I,strokeWidth:E,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection}),re=t.useMemo(()=>zr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:f}),[u,c,d,f]),se=os({componentName:"StackedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{stackBy:u}}),{effectiveLegendProps:ae,effectiveMargin:le}=za({ref:o,frameRef:r,setup:te});if(te.earlyReturn)return te.earlyReturn;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(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,W],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:le,barPadding:b}),null!=x&&{roundedTop:x}),{baselinePadding:w,enableHover:G}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:f}),H&&{oFormat:H}),{showGrid:Y}),ae),xs({title:V,description:X,summary:U,accessibleTable:K,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:k,defaultTooltipContent:re})),ws({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(Wr,{componentName:"StackedBarChart",message:se,width:z,height:W}):e.jsx(Vr,{componentName:"StackedBarChart",width:z,height:W,children:e.jsx(Ha,Object.assign({ref:r},ce))})});Ya.displayName="StackedBarChart";const qa=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",groupBy:u,valueAccessor:d="value",orientation:h="vertical",valueFormat:f,colorBy:g,colorScheme:p,sort:y=!1,barPadding:m=60,roundedTop:b,baselinePadding:x=!1,tooltip:w,annotations:k,valueExtent:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:N,legendInteraction:R,legendPosition:$,color:D,stroke:B,strokeWidth:I,opacity:E,categoryFormat:F}=n,{width:H,height:z,enableHover:W,showGrid:G,showLegend:Y,title:q,description:V,summary:X,accessibleTable:U,categoryLabel:K,valueLabel:Q}=i,Z=t.useMemo(()=>v(s),[s]),J=g||u,ee=as({data:Z,rawData:s,colorBy:J,colorScheme:p,legendInteraction:R,legendPosition:$,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:N,width:H,height:z}),te=Sr(),ne=t.useMemo(()=>new Map,[Z]),oe=Wa({colorBy:J,colorScale:ee.colorScale,color:D,themeCategorical:te,colorScheme:p,categoryIndexMap:ne,userPieceStyle:j.pieceStyle,stroke:B,strokeWidth:I,opacity:E,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection}),ie=t.useMemo(()=>zr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:f}),[u,c,d,f]),re=os({componentName:"GroupedBarChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d},requiredProps:{groupBy:u}}),{effectiveLegendProps:se,effectiveMargin:ae}=za({ref:o,frameRef:r,setup:ee});if(ee.earlyReturn)return ee.earlyReturn;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:"clusterbar"},null!=s&&{data:Z}),{oAccessor:c,rAccessor:d,groupBy:u,oSort:y,projection:"horizontal"===h?"horizontal":"vertical",pieceStyle:oe,size:[H,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ae,barPadding:m}),null!=b&&{roundedTop:b}),{baselinePadding:x,enableHover:W}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:K,rLabel:Q,rFormat:f}),F&&{oFormat:F}),{showGrid:G}),se),xs({title:q,description:V,summary:X,accessibleTable:U,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:w,defaultTooltipContent:ie})),ws({linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,customHoverBehavior:ee.customHoverBehavior,customClickBehavior:ee.customClickBehavior})),k&&k.length>0&&{annotations:k}),A&&{rExtent:A}),Object.fromEntries(Object.entries(j).filter(([e])=>"pieceStyle"!==e)));return re?e.jsx(Wr,{componentName:"GroupedBarChart",message:re,width:H,height:z}):e.jsx(Vr,{componentName:"GroupedBarChart",width:H,height:z,children:e.jsx(Ha,Object.assign({ref:r},le))})});function Va({brushProp:e,onBrushProp:n,linkedBrush:o,valueAccessor:i}){const r=hr("string"==typeof o?o:o?{name:o.name,xField:o.rField}:void 0),s=er({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==n||n(e)},[n,r]),c=!!(e||o||n);return{hasBrush:c,handleBrush:l,brushStreamProps:c?{brush:{dimension:"r"},onBrush:l}:{}}}qa.displayName="GroupedBarChart";const Xa=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:f,colorScheme:g,sizeBy:p,sizeRange:y=[3,8],pointRadius:m=4,pointOpacity:b=.7,categoryPadding:x=20,tooltip:w,annotations:k,valueExtent:A,brush:j,onBrush:S,linkedBrush:C,frameProps:O={},selection:M,linkedHover:P,onObservation:_,onClick:L,hoverHighlight:T,chartId:N,loading:R,loadingContent:$,emptyContent:D,legendInteraction:B,legendPosition:I,color:E,stroke:F,strokeWidth:H,opacity:z,showCategoryTicks:W,categoryFormat:G}=n,{width:Y,height:q,enableHover:V,showGrid:X,showLegend:U,title:K,description:Q,summary:Z,accessibleTable:J,categoryLabel:ee,valueLabel:te}=i,ne=t.useMemo(()=>v(s),[s]),oe=as({data:ne,rawData:s,colorBy:f,colorScheme:g,legendInteraction:B,legendPosition:I,selection:M,linkedHover:P,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:_,onClick:L,hoverHighlight:T,chartType:"SwarmPlot",chartId:N,showLegend:U,userMargin:a,marginDefaults:i.marginDefaults,loading:R,loadingContent:$,emptyContent:D,width:Y,height:q}),ie=Va({brushProp:j,onBrushProp:S,linkedBrush:C,valueAccessor:u}),re=t.useMemo(()=>{if(!p)return;const e=ne.map(e=>"function"==typeof p?p(e):e[p]);return[Math.min(...e),Math.max(...e)]},[ne,p]),se=Sr(),ae=t.useMemo(()=>new Map,[ne]),le=Wa({colorBy:f,colorScale:oe.colorScale,color:E,themeCategorical:se,colorScheme:g,categoryIndexMap:ae,userPieceStyle:null==O?void 0:O.pieceStyle,stroke:F,strokeWidth:H,opacity:z,effectiveSelectionHook:oe.effectiveSelectionHook,resolvedSelection:oe.resolvedSelection,baseStyleExtras:e=>({fillOpacity:b,r:p?Ae(e,p,y,re):m})}),ce=t.useMemo(()=>zr({categoryAccessor:c,valueAccessor:u,groupAccessor:f||void 0,valueFormat:h}),[c,u,f,h]);if(oe.earlyReturn)return oe.earlyReturn;const ue=os({componentName:"SwarmPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ue)return e.jsx(Wr,{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:ne}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",pieceStyle:le,size:[Y,q],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:oe.margin,barPadding:x,enableHover:V}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:ee,rLabel:te,rFormat:h}),G&&{oFormat:G}),{showGrid:X,showCategoryTicks:W}),oe.legendBehaviorProps),xs({title:K,description:Q,summary:Z,accessibleTable:J,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:w,defaultTooltipContent:ce})),ws({linkedHover:P,onObservation:_,onClick:L,hoverHighlight:T,customHoverBehavior:oe.customHoverBehavior,customClickBehavior:oe.customClickBehavior})),k&&k.length>0&&{annotations:k}),A&&{rExtent:A}),ie.brushStreamProps),Object.fromEntries(Object.entries(O).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"SwarmPlot",width:Y,height:q,children:e.jsx(Ha,Object.assign({ref:r},de))})});function Ua(t){return n=>{var o;const i=n.category||n.data&&(null===(o=n.data[0])||void 0===o?void 0:o.category)||"",r=n.stats||(n.data||n).stats;if(r&&null!=r.median)return e.jsxs("div",{className:"semiotic-tooltip",style:Uo,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 o=t.valueAccessor,r=(Array.isArray(n.data)?n.data:[]).map(e=>Number("function"==typeof o?o(e):e[o])).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:Uo,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:Uo,children:e.jsx("div",{style:{fontWeight:"bold"},children:i+""})})}}Xa.displayName="SwarmPlot";const Ka=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",valueFormat:h,colorBy:f,colorScheme:g,showOutliers:p=!0,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,frameProps:w={},selection:k,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:C,chartId:O,loading:M,loadingContent:P,emptyContent:_,legendInteraction:L,legendPosition:T,color:N,stroke:R,strokeWidth:$,opacity:D,showCategoryTicks:B,categoryFormat:I}=n,{width:E,height:F,enableHover:H,showGrid:z,showLegend:W,title:G,description:Y,summary:q,accessibleTable:V,categoryLabel:X,valueLabel:U}=i,K=t.useMemo(()=>v(s),[s]),Q=as({data:K,rawData:s,colorBy:f,colorScheme:g,legendInteraction:L,legendPosition:T,selection:k,linkedHover:A,fallbackFields:f?["string"==typeof f?f:""]:["string"==typeof c?c:""],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:C,chartType:"BoxPlot",chartId:O,showLegend:W,userMargin:a,marginDefaults:i.marginDefaults,loading:M,loadingContent:P,emptyContent:_,width:E,height:F}),Z=Sr(),J=t.useMemo(()=>new Map,[K]),ee=Wa({colorBy:f,colorScale:Q.colorScale,color:N,themeCategorical:Z,colorScheme:g,categoryIndexMap:J,userPieceStyle:void 0,stroke:R,strokeWidth:$,opacity:D,effectiveSelectionHook:Q.effectiveSelectionHook,resolvedSelection:Q.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),te=t.useMemo(()=>Ua(),[]);if(Q.earlyReturn)return Q.earlyReturn;const ne=os({componentName:"BoxPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ne)return e.jsx(Wr,{componentName:"BoxPlot",message:ne,width:E,height:F});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"boxplot"},null!=s&&{data:K}),{oAccessor:c,rAccessor:u,projection:"horizontal"===d?"horizontal":"vertical",summaryStyle:ee,showOutliers:p,size:[E,F],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Q.margin,barPadding:y,enableHover:H}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:X,rLabel:U,rFormat:h}),I&&{oFormat:I}),{showGrid:z,showCategoryTicks:B}),Q.legendBehaviorProps),xs({title:G,description:Y,summary:q,accessibleTable:V,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:te})),ws({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(w).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"BoxPlot",width:E,height:F,children:e.jsx(Ha,Object.assign({ref:r},oe))})});Ka.displayName="BoxPlot";const Qa=e=>{const t=null==e?void 0:e.category;return null==t?"All":t+""},Za=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:"horizontal"}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c=Qa,valueAccessor:u="value",bins:d=25,relative:h=!1,valueFormat:f,colorBy:g,colorScheme:p,categoryPadding:y=20,tooltip:m,annotations:b,valueExtent:x,brush:w,onBrush:k,linkedBrush:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:N,legendInteraction:R,legendPosition:$,color:D,stroke:B,strokeWidth:I,opacity:E,showCategoryTicks:F,categoryFormat:H}=n,{width:z,height:W,enableHover:G,showGrid:Y,showLegend:q,title:V,description:X,summary:U,accessibleTable:K,categoryLabel:Q,valueLabel:Z}=i,J=t.useMemo(()=>v(s),[s]),ee=as({data:J,rawData:s,colorBy:g,colorScheme:p,legendInteraction:R,legendPosition:$,selection:S,linkedHover:C,fallbackFields:g?["string"==typeof g?g:""]:["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:N,width:z,height:W}),te=Va({brushProp:w,onBrushProp:k,linkedBrush:A,valueAccessor:u}),ne=t.useMemo(()=>{if(0===J.length)return;const e="function"==typeof u?u:e=>e[u];let t=1/0,n=-1/0;for(const o of J){const i=e(o);null!=i&&isFinite(i)&&(t>i&&(t=i),i>n&&(n=i))}return t>n?void 0:[t,n]},[J,u]),oe=Sr(),ie=t.useMemo(()=>new Map,[J]),re=Wa({colorBy:g,colorScale:ee.colorScale,color:D,themeCategorical:oe,colorScheme:p,categoryIndexMap:ie,userPieceStyle:void 0,stroke:B,strokeWidth:I,opacity:E,effectiveSelectionHook:ee.effectiveSelectionHook,resolvedSelection:ee.resolvedSelection,baseStyleExtras:{fillOpacity:.8},linkStrokeToFill:!0}),se=t.useMemo(()=>t=>{const n=t.data||t,o=n.category||t.category||"",i=n.count,r=n.range;return e.jsxs("div",{className:"semiotic-tooltip",style:Uo,children:[o&&e.jsx("div",{style:{fontWeight:"bold"},children:o+""}),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)]})]})},[]);if(ee.earlyReturn)return ee.earlyReturn;const ae=os({componentName:"Histogram",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(Wr,{componentName:"Histogram",message:ae,width:z,height:W});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}:ne&&{rExtent:ne}),{size:[z,W],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ee.margin,barPadding:y,enableHover:G}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Q,rLabel:Z,rFormat:f}),H&&{oFormat:H}),{showGrid:Y,showCategoryTicks:F}),ee.legendBehaviorProps),xs({title:V,description:X,summary:U,accessibleTable:K,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:se})),ws({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(Vr,{componentName:"Histogram",width:z,height:W,children:e.jsx(Ha,Object.assign({ref:r},le))})});Za.displayName="Histogram";const Ja=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="vertical",bins:h=25,showIQR:f=!0,valueFormat:g,colorBy:p,colorScheme:y,categoryPadding:m=20,tooltip:b,annotations:x,valueExtent:w,brush:k,onBrush:A,linkedBrush:j,frameProps:S={},selection:C,linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,chartId:L,loading:T,loadingContent:N,emptyContent:R,legendInteraction:$,legendPosition:D,color:B,stroke:I,strokeWidth:E,opacity:F,showCategoryTicks:H,categoryFormat:z}=n,{width:W,height:G,enableHover:Y,showGrid:q,showLegend:V,title:X,description:U,summary:K,accessibleTable:Q,categoryLabel:Z,valueLabel:J}=i,ee=t.useMemo(()=>v(s),[s]),te=as({data:ee,rawData:s,colorBy:p,colorScheme:y,legendInteraction:$,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:V,userMargin:a,marginDefaults:i.marginDefaults,loading:T,loadingContent:N,emptyContent:R,width:W,height:G}),ne=Va({brushProp:k,onBrushProp:A,linkedBrush:j,valueAccessor:u}),oe=Sr(),ie=t.useMemo(()=>new Map,[ee]),re=Wa({colorBy:p,colorScale:te.colorScale,color:B,themeCategorical:oe,colorScheme:y,categoryIndexMap:ie,userPieceStyle:void 0,stroke:I,strokeWidth:E,opacity:F,effectiveSelectionHook:te.effectiveSelectionHook,resolvedSelection:te.resolvedSelection,baseStyleExtras:{fillOpacity:.6},linkStrokeToFill:!0}),se=t.useMemo(()=>Ua({valueAccessor:u}),[u]);if(te.earlyReturn)return te.earlyReturn;const ae=os({componentName:"ViolinPlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(ae)return e.jsx(Wr,{componentName:"ViolinPlot",message:ae,width:W,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:f,size:[W,G],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:te.margin,barPadding:m,enableHover:Y}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:Z,rLabel:J,rFormat:g}),z&&{oFormat:z}),{showGrid:q,showCategoryTicks:H}),te.legendBehaviorProps),xs({title:X,description:U,summary:K,accessibleTable:Q,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:b,defaultTooltipContent:se})),ws({linkedHover:O,onObservation:M,onClick:P,hoverHighlight:_,customHoverBehavior:te.customHoverBehavior,customClickBehavior:te.customClickBehavior})),x&&x.length>0&&{annotations:x}),w&&{rExtent:w}),ne.brushStreamProps),Object.fromEntries(Object.entries(S).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"ViolinPlot",width:W,height:G,children:e.jsx(Ha,Object.assign({ref:r},le))})});Ja.displayName="ViolinPlot";const el=t.forwardRef(function(n,o){var i;const r=Rr(n.mode,{width:n.width,height:n.height,showGrid:null===(i=n.showGrid)||void 0===i||i,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),s=t.useRef(null);us(o,{variant:"xy",frameRef:s});const{data:a,margin:l,className:c,categoryAccessor:u="category",valueAccessor:d="value",orientation:h="horizontal",valueFormat:f,colorBy:g,colorScheme:p,sort:y="auto",dotRadius:m=5,categoryPadding:b=10,tooltip:x,annotations:w,regression:k,valueExtent:A,frameProps:j={},selection:S,linkedHover:C,onObservation:O,onClick:M,hoverHighlight:P,chartId:_,loading:L,loadingContent:T,emptyContent:N,legendInteraction:R,legendPosition:$,color:D,stroke:B,strokeWidth:I,opacity:E,categoryFormat:F}=n,{width:H,height:z,enableHover:W,showGrid:G,showLegend:Y,title:q,description:V,summary:X,accessibleTable:U,categoryLabel:K,valueLabel:Q}=r,Z=t.useMemo(()=>v(a),[a]),J=as({data:Z,rawData:a,colorBy:g,colorScheme:p,legendInteraction:R,legendPosition:$,selection:S,linkedHover:C,fallbackFields:g?["string"==typeof g?g:""]:["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:N,width:H,height:z}),ee=Mr(Z,y,d),te=Sr(),ne=t.useMemo(()=>new Map,[Z]),oe=Wa({colorBy:g,colorScale:J.colorScale,color:D,themeCategorical:te,colorScheme:p,categoryIndexMap:ne,userPieceStyle:null==j?void 0:j.pieceStyle,stroke:B,strokeWidth:I,opacity:E,effectiveSelectionHook:J.effectiveSelectionHook,resolvedSelection:J.resolvedSelection,baseStyleExtras:{r:m,fillOpacity:.8}}),ie=t.useMemo(()=>zr({categoryAccessor:u,valueAccessor:d,valueFormat:f}),[u,d,f]);if(J.earlyReturn)return J.earlyReturn;const re=os({componentName:"DotPlot",data:a,accessors:{categoryAccessor:u,valueAccessor:d}});if(re)return e.jsx(Wr,{componentName:"DotPlot",message:re,width:H,height:z});const se=Ls(k),ae=se?[se,...w||[]]:w,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:oe,size:[H,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:J.margin,barPadding:b,enableHover:W}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:r.showAxes,oLabel:K,rLabel:Q,rFormat:f}),F&&{oFormat:F}),{showGrid:G,oSort:y}),J.legendBehaviorProps),xs({title:q,description:V,summary:X,accessibleTable:U,className:c,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:x,defaultTooltipContent:ie})),ws({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(Vr,{componentName:"DotPlot",width:H,height:z,children:e.jsx(Ha,Object.assign({ref:s},le))})});el.displayName="DotPlot";const tl=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,categoryAccessor:c="category",valueAccessor:u="value",orientation:d="horizontal",bins:h=20,amplitude:f=1.5,valueFormat:g,colorBy:p,colorScheme:y,categoryPadding:m=5,tooltip:b,annotations:x,valueExtent:w,frameProps:k={},selection:A,linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,chartId:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:N,color:R,stroke:$,strokeWidth:D,opacity:B,showCategoryTicks:I,categoryFormat:E}=n,{width:F,height:H,enableHover:z,showGrid:W,showLegend:G,title:Y,description:q,summary:V,accessibleTable:X,categoryLabel:U,valueLabel:K}=i,Q=t.useMemo(()=>v(s),[s]),Z=as({data:Q,rawData:s,colorBy:p,colorScheme:y,legendInteraction:T,legendPosition:N,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:H}),J=Sr(),ee=t.useMemo(()=>new Map,[Q]),te=Wa({colorBy:p,colorScale:Z.colorScale,color:R,themeCategorical:J,colorScheme:y,categoryIndexMap:ee,userPieceStyle:void 0,stroke:$,strokeWidth:D,opacity:B,effectiveSelectionHook:Z.effectiveSelectionHook,resolvedSelection:Z.resolvedSelection,baseStyleExtras:{fillOpacity:.5},linkStrokeToFill:!0}),ne=t.useMemo(()=>Ua(),[]);if(Z.earlyReturn)return Z.earlyReturn;const oe=os({componentName:"RidgelinePlot",data:s,accessors:{categoryAccessor:c,valueAccessor:u}});if(oe)return e.jsx(Wr,{componentName:"RidgelinePlot",message:oe,width:F,height:H});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,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:Z.margin,barPadding:m,enableHover:z}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:U,rLabel:K,rFormat:g}),E&&{oFormat:E}),{showGrid:W,showCategoryTicks:I,oSort:!1,amplitude:f}),Z.legendBehaviorProps),xs({title:Y,description:q,summary:V,accessibleTable:X,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:b,defaultTooltipContent:ne})),ws({linkedHover:j,onObservation:S,onClick:C,hoverHighlight:O,customHoverBehavior:Z.customHoverBehavior,customClickBehavior:Z.customClickBehavior})),x&&x.length>0&&{annotations:x}),w&&{rExtent:w}),Object.fromEntries(Object.entries(k).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"RidgelinePlot",width:F,height:H,children:e.jsx(Ha,Object.assign({ref:r},ie))})});tl.displayName="RidgelinePlot";const nl=t.forwardRef(function(n,o){var i,r;const s=Rr(n.mode,{width:null!==(i=n.width)&&void 0!==i?i:400,height:null!==(r=n.height)&&void 0!==r?r:400,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,showCategoryTicks:n.showCategoryTicks}),a=t.useRef(null),{data:l,margin:c,className:u,categoryAccessor:d="category",valueAccessor:h="value",colorBy:f,colorScheme:g,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:N,strokeWidth:R,opacity:$}=n,{width:D,height:B,enableHover:I,showLegend:E,title:F,description:H,summary:z,accessibleTable:W}=s,G=t.useMemo(()=>v(l),[l]),Y=f||d,q=as({data:G,rawData:l,colorBy:Y,colorScheme:g,legendInteraction:_,legendPosition:L,selection:w,linkedHover:k,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"PieChart",chartId:C,showLegend:E,userMargin:c,marginDefaults:s.marginDefaults,loading:O,loadingContent:M,emptyContent:P,width:D,height:B}),V=Sr(),X=t.useMemo(()=>new Map,[G]),U=Wa({colorBy:Y,colorScale:q.colorScale,color:T,themeCategorical:V,colorScheme:g,categoryIndexMap:X,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:N,strokeWidth:R,opacity:$,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),K=t.useMemo(()=>zr({categoryAccessor:d,valueAccessor:h,groupAccessor:f&&f!==d?f:void 0,groupLabel:"string"==typeof f?f:"group",pieData:!0}),[d,h,f]),Q=os({componentName:"PieChart",data:l,accessors:{categoryAccessor:d,valueAccessor:h}}),{effectiveLegendProps:Z,effectiveMargin:J}=za({ref:o,frameRef:a,setup:q});if(q.earlyReturn)return q.earlyReturn;const ee=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"pie"},null!=l&&{data:G}),{oAccessor:d,rAccessor:h,projection:"radial",pieceStyle:U,startAngle:p}),null!=y&&{cornerRadius:y}),{size:[D,B],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:J,enableHover:I}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:!1}),Z),xs({title:F,description:H,summary:z,accessibleTable:W,className:u,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:K})),ws({linkedHover:k,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(Wr,{componentName:"PieChart",message:Q,width:D,height:B}):e.jsx(Vr,{componentName:"PieChart",width:D,height:B,children:e.jsx(Ha,Object.assign({ref:a},ee))})});nl.displayName="PieChart";const ol=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,linkedHover:n.linkedHover,showCategoryTicks:n.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:f,colorScheme:g,startAngle:p=0,cornerRadius:y,tooltip:m,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:N,strokeWidth:R,opacity:$}=n,{width:D,height:B,enableHover:I,showLegend:E,title:F,description:H,summary:z,accessibleTable:W}=i,G=t.useMemo(()=>v(s),[s]),Y=f||c,q=as({data:G,rawData:s,colorBy:Y,colorScheme:g,legendInteraction:_,legendPosition:L,selection:w,linkedHover:k,fallbackFields:Y?["string"==typeof Y?Y:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"DonutChart",chartId:C,showLegend:E,userMargin:a,marginDefaults:i.marginDefaults,loading:O,loadingContent:M,emptyContent:P,width:D,height:B}),V=null!=d?d:Math.max(2,.15*Math.min(D,B)),X=Sr(),U=t.useMemo(()=>new Map,[G]),K=Wa({colorBy:Y,colorScale:q.colorScale,color:T,themeCategorical:X,colorScheme:g,categoryIndexMap:U,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:N,strokeWidth:R,opacity:$,effectiveSelectionHook:q.effectiveSelectionHook,resolvedSelection:q.resolvedSelection,cycleByCategory:!0}),Q=t.useMemo(()=>zr({categoryAccessor:c,valueAccessor:u,groupAccessor:f&&f!==c?f:void 0,groupLabel:"string"==typeof f?f:"group",pieData:!0}),[c,u,f]),Z=os({componentName:"DonutChart",data:s,accessors:{categoryAccessor:c,valueAccessor:u}}),{effectiveLegendProps:J,effectiveMargin:ee}=za({ref:o,frameRef:r,setup:q});if(q.earlyReturn)return q.earlyReturn;const te=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:"donut"},null!=s&&{data:G}),{oAccessor:c,rAccessor:u,projection:"radial",pieceStyle:K,innerRadius:V,startAngle:p}),null!=y&&{cornerRadius:y}),{centerContent:h,size:[D,B],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ee,enableHover:I}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:!1}),J),xs({title:F,description:H,summary:z,accessibleTable:W,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:Q})),ws({linkedHover:k,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(Wr,{componentName:"DonutChart",message:Z,width:D,height:B}):e.jsx(Vr,{componentName:"DonutChart",width:D,height:B,children:e.jsx(Ha,Object.assign({ref:r},te))})});function il(e=240){const t=360-e,n=180+t/2,o=n*Math.PI/180;return{sweepRad:e*Math.PI/180,gapDeg:t,startAngleDeg:n,startAngleRad:o,offsetRad:-Math.PI/2+o}}function rl(e){return Math.max(0,Math.min(1,e))}function sl(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 n=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i);if(n){const e=[Number(n[1]),Number(n[2]),Number(n[3])];if(e.every(Number.isFinite))return e}return null}function al(e,t,n){const o=e=>Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0");return`#${o(e)}${o(t)}${o(n)}`}function ll(e,t){const n=e.filter(e=>Number.isFinite(e.offset)).map(e=>({offset:rl(e.offset),color:e.color})).sort((e,t)=>e.offset-t.offset);if(0===n.length)return"#999999";if(1===n.length)return n[0].color;const o=rl(t);if(n[0].offset>=o)return n[0].color;if(o>=n[n.length-1].offset)return n[n.length-1].color;for(let e=0;n.length-1>e;e++){const t=n[e],i=n[e+1];if(t.offset>o||o>i.offset)continue;const r=i.offset-t.offset,s=r>0?(o-t.offset)/r:0,a=sl(t.color),l=sl(i.color);if(!a||!l)return.5>s?t.color:i.color;const[c,u,d]=a,[h,f,g]=l;return al(c+(h-c)*s,u+(f-u)*s,d+(g-d)*s)}return n[n.length-1].color}function cl(e,t,n){return`${e}-${t}`}ol.displayName="DonutChart";const ul=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLegend:!1,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:300,height:250}),r=t.useRef(null),s="context"===n.mode,{compactMode:a}=i,{value:l,min:c=0,max:u=100,thresholds:d,gradientFill:h,color:f,backgroundColor:g="var(--semiotic-grid, #e0e0e0)",arcWidth:p=.3,cornerRadius:y,showNeedle:m=!0,needleColor:v="var(--semiotic-text, #333)",centerContent:b,valueFormat:x,showScaleLabels:w=!a,sweep:k=240,fillZones:A=!0,tooltip:j,annotations:S,frameProps:C={},className:O,stroke:M,strokeWidth:P,opacity:_}=n,{width:L,height:T,title:N,description:R,summary:$,accessibleTable:D}=i,B=h&&"object"==typeof h?h:void 0,I=Math.max(c,Math.min(u,l)),E=u-c||1,F=(I-c)/E,{gaugeData:H,pieceStyle:z,gaugeAnnotations:W}=t.useMemo(()=>function(e){const{min:t,max:n,value:o,thresholds:i,fillColor:r,backgroundColor:s,fillZones:a,showScaleLabels:l,gradientFill:c,gradientSteps:u=240}=e,d=n-t||1,h=(Math.max(t,Math.min(n,o))-t)/d;let f=i&&i.length>0?[...i].sort((e,t)=>e.value-t.value):[{value:n,color:r||"#007bff"}];f=f.map(e=>Object.assign(Object.assign({},e),{value:Math.max(t,Math.min(n,e.value))})),n>f[f.length-1].value&&f.push({value:n,color:f[f.length-1].color});const g=!!c&&c.colorStops.length>=2,p=[],y=new Map,m=[];if(g){const e=a?h:1,t=cl("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)),n=Math.max(1,Math.min(t,Math.round(e*t))),o=[];for(let t=0;n>t;t++)o.push(ll(c.colorStops,e*(t+.5)/n));const i=cl("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:o}}),y.set(i,{fill:o[0]||s})}}else{let e=t;for(let n=0;f.length>n;n++){const o=f[n],i=(o.value-e)/d,r=(e-t)/d,l=(o.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=cl("fill",n);p.push({category:e,value:c,_zone:o.label||"Zone "+(n+1),_isFill:!0}),y.set(e,{fill:o.color})}if(u>0){const e=cl("bg",n);p.push({category:e,value:u,_zone:o.label||"Zone "+(n+1),_isFill:!1}),y.set(e,{fill:s,opacity:.4})}e=o.value}}if(l&&i&&i.length>0)for(const e of i)e.value>t&&n>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:f,backgroundColor:g,fillZones:A,showScaleLabels:w,gradientFill:B}),[l,c,u,d,f,g,w,A,B]),G=t.useMemo(()=>ls(z,{stroke:M,strokeWidth:P,opacity:_}),[z,M,P,_]),{sweepRad:Y,startAngleDeg:q}=il(k),V=function(e=240){const{sweepRad:t,offsetRad:n}=il(e),o=[[Math.cos(n),Math.sin(n)],[Math.cos(n+t),Math.sin(n+t)],[0,0]];for(let e=0;2*Math.PI>e;e+=Math.PI/2)((e-n)%(2*Math.PI)+2*Math.PI)%(2*Math.PI)>t+.001||o.push([Math.cos(e),Math.sin(e)]);const i=o.map(e=>e[0]),r=o.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),X=Math.min(10,Math.max(1,Math.min(L,T)/12)),U=V.cx,K=V.cy,Q=Math.max(4,Math.min((L-2*X)/V.width,(T-2*X)/V.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),ne=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}),w&&e.jsxs("div",{style:{fontSize:11,color:"var(--semiotic-text-secondary, #666)"},children:[c," – ",u]})]})},[b,I,c,u,x,w,Q,a]),oe=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,n,o)=>{if("gauge-needle"===t.type){const i=(o.width||L)/2,r=(o.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-"+n)}if("gauge-label"===t.type){const i=-Math.PI/2+q*Math.PI/180+(t.value-c)/E*Y,r=(o.width||L)/2,s=(o.height||T)/2,a=Z-1,l=Q+1,u=Math.cos(i)*a,d=Math.sin(i)*a,h=Math.cos(i)*l,f=Math.sin(i)*l,g=Q+10,p=Math.cos(i)*g,y=Math.sin(i)*g,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:f,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-"+n)}return"gauge-value"===t.type?e.jsx("text",{x:(o.width||L)/2,y:(o.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-"+n):null},[L,T,c,E,q,Y,Z,Q]),se=t.useMemo(()=>{const e=[...W,...S||[]];return ie&&e.push(ie),oe&&e.push(oe),e},[W,S,ie,oe]),ae=t.useMemo(()=>t=>{var n;const o=(null===(n=null==t?void 0:t.data)||void 0===n?void 0:n[0])||(null==t?void 0:t.data)||t,i=null==o?void 0:o._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==o?void 0:o._zone)||""}),e.jsx("div",{style:{fontSize:"0.85em",color:"var(--semiotic-text-secondary, #666)"},children:i?"Current: "+Math.round(I):"Remaining"})]})},[I]);if(0===H.length)return e.jsx(Wr,{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:H,oAccessor:"category",rAccessor:"value",oSort:!1,projection:"radial",pieceStyle:G,innerRadius:Z,startAngle:q,sweepAngle:k},null!=y&&{cornerRadius:y}),{centerContent:ne,size:[L,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.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:ei(j)||ae,svgAnnotationRules:re}),se.length>0&&{annotations:se}),N&&{title:N}),R&&{description:R}),$&&{summary:$}),void 0!==D&&{accessibleTable:D}),O&&{className:O}),null!=n.animate&&{animate:n.animate}),C);return e.jsx(Vr,{componentName:"GaugeChart",width:L,height:T,children:e.jsx(Ha,Object.assign({ref:r},le))})});ul.displayName="GaugeChart";const dl=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:!1,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,showCategoryTicks:!1}),r=t.useRef(null);us(o,{variant:"xy",frameRef:r});const{data:s,margin:a,className:l,stepAccessor:c="step",valueAccessor:u="value",categoryAccessor:d,colorBy:h,colorScheme:f,orientation:g="horizontal",connectorOpacity:p=.3,showLabels:y=!0,tooltip:m,annotations:b,frameProps:x={},selection:w,linkedHover:k,onObservation:A,onClick:j,hoverHighlight:S,chartId:C,loading:O,loadingContent:M,emptyContent:P,legendInteraction:_,legendPosition:L,color:T,stroke:N,strokeWidth:R,opacity:$,categoryFormat:D}=n,B="vertical"===g,{width:I,height:E,enableHover:F,showLegend:H,title:z,description:W,summary:G,accessibleTable:Y}=i,q=B?{top:z?60:40,right:20,bottom:60,left:60}:{top:z?40:10,right:10,bottom:10,left:10},V=t.useMemo(()=>v(s),[s]),X=h||d,U=!X,K=as({data:V,rawData:s,colorBy:X,colorScheme:f,legendInteraction:_,legendPosition:L,selection:w,linkedHover:k,fallbackFields:X?["string"==typeof X?X:""]:[],unwrapData:!0,onObservation:A,onClick:j,hoverHighlight:S,chartType:"FunnelChart",chartId:C,showLegend:H,userMargin:a,marginDefaults:q,loading:O,loadingContent:M,emptyContent:P,width:I,height:E});Zr("FunnelChart",V,"stepAccessor",c),Zr("FunnelChart",V,"valueAccessor",u);const Q=Sr(),Z=t.useMemo(()=>new Map,[V]),J=t.useMemo(()=>{if(U)return T||((null==Q?void 0:Q[0])?Q[0]:Array.isArray(f)&&f[0]?f[0]:"#4e79a7")},[U,T,Q,f]),ee=Wa({colorBy:J?void 0:X,colorScale:K.colorScale,color:null!=J?J:T,themeCategorical:Q,colorScheme:f,categoryIndexMap:Z,userPieceStyle:null==x?void 0:x.pieceStyle,stroke:N,strokeWidth:R,opacity:$,effectiveSelectionHook:K.effectiveSelectionHook,resolvedSelection:K.resolvedSelection}),te=t.useMemo(()=>t=>{var n,o,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!==(o=null!==(n=null==l?void 0:l.__funnelValue)&&void 0!==n?n:null==l?void 0:l.__barFunnelValue)&&void 0!==o?o: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,f=null==l?void 0:l.__barFunnelIsDropoff,g=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:Uo,children:[c&&e.jsx("div",{style:{fontWeight:"bold"},children:c+""}),g&&g!==c&&e.jsx("div",{style:{marginTop:2,opacity:.8},children:g+""}),f&&e.jsx("div",{style:{marginTop:2,fontStyle:"italic",opacity:.7},children:"Dropoff"}),e.jsxs("div",{style:{marginTop:4},children:[u+"",p]})]})},[]);if(K.earlyReturn)return K.earlyReturn;const ne=os({componentName:"FunnelChart",data:s,accessors:{stepAccessor:c,valueAccessor:u}});if(ne)return e.jsx(Wr,{componentName:"FunnelChart",message:ne,width:I,height:E});const oe=Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({chartType:B?"bar-funnel":"funnel"},null!=s&&{data:V}),{oAccessor:c,rAccessor:u}),d&&{stackBy:d}),{projection:B?"vertical":"horizontal",barPadding:B?40:0,pieceStyle:ee,size:[I,E],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K.margin,enableHover:F}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:B,showCategoryTicks:B}),D&&{oFormat:D}),{showGrid:B}),!B&&{connectorOpacity:p}),{showLabels:y}),K.legendBehaviorProps),z&&{title:z}),W&&{description:W}),G&&{summary:G}),void 0!==Y&&{accessibleTable:Y}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),{tooltipContent:!1===m?()=>null:!0===m||null==m?te:ei(m)||te}),(k||A||j||S)&&{customHoverBehavior:K.customHoverBehavior}),(A||j||k)&&{customClickBehavior:K.customClickBehavior}),b&&b.length>0&&{annotations:b}),Object.fromEntries(Object.entries(x).filter(([e])=>"pieceStyle"!==e)));return e.jsx(Vr,{componentName:"FunnelChart",width:I,height:E,children:e.jsx(Ha,Object.assign({ref:r},oe))})});dl.displayName="FunnelChart";const hl={RdBu:ce,PiYG:ue,PRGn:de,BrBG:he,RdYlBu:fe,RdYlGn:ge,Spectral:pe},fl="__likert_neutral_neg",gl="__likert_neutral_pos";function pl(e,t){if("function"==typeof e)return e;const n=e||t;return e=>e[n]}function yl(e,t,n,o,i,r){const s=new Map,a=new Set(t);for(const l of e){const e=n(l);s.has(e)||s.set(e,new Map);const c=s.get(e);if(o){const e=o(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 n=e-1;if(0>n||n>=t.length)continue;const i=t[n];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,n]of s){let o=0;for(const e of t)o+=n.get(e)||0;if(0!==o)for(let i=0;t.length>i;i++){const r=t[i],s=n.get(r)||0;l.push({__likertCategory:e,__likertLevel:r,__likertLevelLabel:r,__likertCount:s,__likertPct:s/o*100,__likertLevelIndex:i})}}return l}function ml(e,t){const n=t.length,o=n%2!=0,i=Math.floor(n/2),r=[];for(const t of e){const e=t.__likertLevelIndex;if(o&&e===i){const e=t.__likertPct/2;r.push(Object.assign(Object.assign({},t),{__likertLevel:fl,__likertPct:-e})),r.push(Object.assign(Object.assign({},t),{__likertLevel:gl,__likertPct:e}))}else r.push(i>e?Object.assign(Object.assign({},t),{__likertPct:-t.__likertPct}):t)}return r}function vl(e,t){const n=t.length,o=n%2!=0,i=Math.floor(n/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 n of e)n.__likertLevel===fl?r=n:n.__likertLevel===gl?a=n:t.set(n.__likertLevelIndex,n);o&&r&&s.push(r);for(let e=i-1;e>=0;e--){const n=t.get(e);n&&s.push(n)}o&&a&&s.push(a);for(let e=o?i+1:i;n>e;e++){const n=t.get(e);n&&s.push(n)}}return s}const bl=["Very Low","Low","Neutral","High","Very High"],xl=new Map,wl=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="question",valueAccessor:u,levelAccessor:d,countAccessor:h="count",levels:f=bl,orientation:g="horizontal",colorScheme:y,barPadding:m=20,tooltip:v,annotations:b,valueExtent:x,frameProps:w={},selection:k,linkedHover:A,onObservation:j,onClick:S,hoverHighlight:C,chartId:O,valueFormat:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,legendPosition:N,categoryFormat:R,stroke:$,strokeWidth:D,opacity:B}=n,{width:I,height:E,enableHover:F,showGrid:H,showLegend:z,title:W,description:G,summary:Y,accessibleTable:q,categoryLabel:V,valueLabel:X}=i,U="horizontal"===g,K=void 0===s,Q=!d,Z=function(){var e;const t=wr();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>=f.length?y:function(e,t){if(0>=e)return[];if(t){const n=hl[t];if(n){if(1===e)return[n(.5)];const t=[];for(let o=0;e>o;o++)t.push(n(o/(e-1)));return t}}const n=["#da1e28","#ff8389","#ffb3b8"],o=["#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(n[Math.min(Math.floor(e*n.length/s),n.length-1)]);r&&a.push(i);for(let e=0;s>e;e++)a.push(o[Math.min(Math.floor(e*o.length/s),o.length-1)]);return a}(f.length,Z),[y,f.length,Z]),ee=t.useMemo(()=>{const e=new Map;for(let t=0;f.length>t;t++)e.set(f[t],J[t]||"#888");return e},[f,J]),{processedData:te,reAggregate:ne,accumulatorRef:oe}=function({data:e,levels:n,categoryAccessor:o,valueAccessor:i,levelAccessor:r,countAccessor:s,isDiverging:a,frameRef:l}){const c=!r,u=t.useMemo(()=>pl(o,"question"),[o]),d=t.useMemo(()=>c?pl(i,"score"):null,[c,i]),h=t.useMemo(()=>c?null:pl(r,"level"),[c,r]),f=t.useMemo(()=>c?null:pl(s,"count"),[c,s]),g=e||[],p=t.useRef([]),y=t.useMemo(()=>{if(0===g.length)return[];let e=yl(g,n,u,d,h,f);return a&&(e=ml(e,n),e=vl(e,n)),e},[g,n,u,d,h,f,a]),m=t.useCallback(e=>{var t;let o=yl(e,n,u,d,h,f);a&&(o=ml(o,n),o=vl(o,n)),null===(t=l.current)||void 0===t||t.replace(o)},[n,u,d,h,f,a,l]);return{processedData:y,reAggregate:m,accumulatorRef:p}}({data:s,levels:f,categoryAccessor:c,valueAccessor:u,levelAccessor:d,countAccessor:h,isDiverging:U,frameRef:r}),ie="__likertLevelLabel",re=function({isPushMode:e,colorBy:n,colorScheme:o,showLegend:i,legendPosition:r="right"}){const s=t.useRef(new Set),a=t.useRef([]),[l,c]=t.useState(0),u=Wi(),d=Sr(),h=t.useCallback(e=>{const t=e[n];return null!=t?t+"":null},[n]),f=t.useCallback(t=>{if(!e||!n)return;let o=!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),o=!0)}o&&c(e=>e+1)},[e,n,h]),g=t.useCallback(t=>{if(!e||!n)return;const o=Array.from(new Set(t.map(String))),i=a.current;i.length===o.length&&i.every((e,t)=>e===o[t])||(s.current=new Set(o),a.current=o,c(e=>e+1))},[e,n]),p=t.useCallback(e=>t=>{f([t]),e(t)},[f]),y=t.useCallback(e=>t=>{f(t),e(t)},[f]),m=t.useCallback(()=>{s.current=new Set,a.current=[],c(e=>e+1)},[]);ar(e&&n?a.current:[]);const v=t.useMemo(()=>{if(!e||!n||!1===i)return;const t=a.current;if(0===t.length)return;const r=Array.isArray(o)&&o.length>0||"string"==typeof o&&o.length>0?o:d&&d.length>0?d:ve,s=n,l=t.map(e=>({[s]:e})),c=ke(l,s,r);return dr({data:l,colorBy:s,colorScale:e=>(null==u?void 0:u[e])||c(e)||"#999",getColor:we})},[e,n,i,o,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&&n?{legendCategoryAccessor:n,onCategoriesChange:g}:{},streamingLegend:v,streamingMarginAdjust:b}}({isPushMode:K,colorBy:ie,colorScheme:J,showLegend:z,legendPosition:N}),se=t.useCallback(re.wrapPush(e=>{oe.current.push(e),ne(oe.current)}),[re.wrapPush,ne,oe]),ae=t.useCallback(re.wrapPushMany(e=>{oe.current.push(...e),ne(oe.current)}),[re.wrapPushMany,ne,oe]);t.useImperativeHandle(o,()=>({push:se,pushMany:ae,remove:e=>{var t,n;return null!==(n=null===(t=r.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=r.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;oe.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,oe]);const le=as({data:te,rawData:s,colorBy:ie,colorScheme:J,legendInteraction:T,legendPosition:N,selection:k,linkedHover:A,fallbackFields:["__likertLevelLabel"],unwrapData:!0,onObservation:j,onClick:S,hoverHighlight:C,chartType:"LikertChart",chartId:O,showLegend:z,userMargin:a,marginDefaults:i.marginDefaults,loading:P,loadingContent:_,emptyContent:L,width:I,height:E}),ce=t.useMemo(()=>{const e=f.length;return e%2!=0&&ee.get(f[Math.floor(e/2)])||"#888"},[f,ee]),ue=Wa({colorBy:void 0,colorScale:void 0,color:void 0,themeCategorical:void 0,colorScheme:void 0,categoryIndexMap:xl,userPieceStyle:null==w?void 0:w.pieceStyle,stroke:$,strokeWidth:D,opacity:B,effectiveSelectionHook:le.effectiveSelectionHook,resolvedSelection:le.resolvedSelection,baseStyleExtras:e=>{var t,n;const o=e.__likertLevelLabel||(null===(t=e.data)||void 0===t?void 0:t.__likertLevelLabel),i=e.__likertLevel||(null===(n=e.data)||void 0===n?void 0:n.__likertLevel);if(i===fl||i===gl)return{fill:ce};const r=o||i;return r&&ee.has(r)?{fill:ee.get(r)}:{fill:"#888"}}}),de=t.useMemo(()=>{const e=f.length;return e%2!=0?f[Math.floor(e/2)]:""},[f]),he=t.useMemo(()=>e=>{const t=e.data||e,n=t.__likertLevel||"Unknown",o=n===fl||n===gl?de:n,i=t.__likertCategory||"",r=Math.abs(t.__likertPct||0),s=n===fl||n===gl?2*r:r,a=t.__likertCount||0;return p.createElement("div",{className:"semiotic-tooltip",style:Uo},p.createElement("div",{style:{fontWeight:"bold"}},i),p.createElement("div",{style:{marginTop:4}},`${o}: ${s.toFixed(1)}% (n=${a})`))},[de]),fe=t.useMemo(()=>{if(!f||2>f.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)),os({componentName:"LikertChart",data:s,accessors:e,requiredProps:{levels:f}})},[s,c,u,d,h,f,Q]),ge=t.useMemo(()=>[{styleFn:e=>({fill:ee.get(e.label)||"#888"}),items:f.map(e=>({label:e})),label:""}],[f,ee]),pe=t.useMemo(()=>!1!==z?Object.assign(Object.assign({},le.legendBehaviorProps),{legend:{legendGroups:ge},legendPosition:N||le.legendPosition||"bottom"}):le.legendBehaviorProps,[le.legendBehaviorProps,le.legendPosition,N,z,ge]),ye=t.useMemo(()=>{const e=Object.assign({},le.margin);if(K&&!1!==z){const t=N||"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,n]of Object.entries(re.streamingMarginAdjust))n>e[t]&&(e[t]=n);return U&&100>e.left&&(e.left=100),e},[le.margin,re.streamingMarginAdjust,U,K,z,N]),me=t.useMemo(()=>M||(U?e=>Math.abs(Number(e)).toFixed(0)+"%":e=>Number(e).toFixed(0)+"%"),[U,M]);if(le.earlyReturn)return le.earlyReturn;const 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:"bar"},null!=s&&{data:te}),{oAccessor:"__likertCategory",rAccessor:"__likertPct",stackBy:"__likertLevel",normalize:!1,projection:U?"horizontal":"vertical",pieceStyle:ue,size:[I,E],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:ye,barPadding:m,enableHover:F}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:V,rLabel:X||(U?void 0:"Percentage"),rFormat:me}),R&&{oFormat:R}),{showGrid:H}),pe),W&&{title:W}),G&&{description:G}),Y&&{summary:Y}),void 0!==q&&{accessibleTable:q}),l&&{className:l}),null!=n.animate&&{animate:n.animate}),void 0!==n.axisExtent&&{axisExtent:n.axisExtent}),void 0!==n.autoPlaceAnnotations&&{autoPlaceAnnotations:n.autoPlaceAnnotations}),{tooltipContent:!1===v?()=>null:!0===v?he:ei(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(w).filter(([e])=>"pieceStyle"!==e)));return fe?e.jsx(Wr,{componentName:"LikertChart",message:fe,width:I,height:E}):e.jsx(Vr,{componentName:"LikertChart",width:I,height:E,children:e.jsx(Ha,Object.assign({ref:r},be))})});wl.displayName="LikertChart";const kl=t.forwardRef(function(n,o){const i=Rr(n.mode,{width:n.width,height:n.height,showGrid:n.showGrid,enableHover:n.enableHover,showLegend:n.showLegend,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,categoryLabel:n.categoryLabel,valueLabel:n.valueLabel,showCategoryTicks:n.showCategoryTicks,orientation:n.orientation}),r=t.useRef(null),{data:s,margin:a,className:l,categoryAccessor:c="category",subcategoryAccessor:u,valueAccessor:d="value",orientation:h="horizontal",valueFormat:f,colorBy:g,colorScheme:p,barPadding:y,tooltip:m,annotations:b,brush:x,onBrush:w,linkedBrush:k,frameProps:A={},selection:j,linkedHover:S,onObservation:C,onClick:O,hoverHighlight:M,chartId:P,loading:_,loadingContent:L,emptyContent:T,legendInteraction:N,legendPosition:R,color:$,stroke:D,strokeWidth:B,opacity:I,categoryFormat:E,rTickValues:F,tickLabelEdgeAlign:H,showCategoryTicks:z,gradientFill:W,trackFill:G,roundedTop:Y,valueExtent:q}=n,{width:V,height:X,enableHover:U,showGrid:K,showLegend:Q,title:Z,description:J,summary:ee,accessibleTable:te,categoryLabel:ne,valueLabel:oe}=i,ie=t.useMemo(()=>v(s),[s]),re=g||u,se=t.useMemo(()=>{if(null!=y)return y;if("sparkline"!==n.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?X:V)-2*t)/(t-1))):1},[y,n.mode,ie,c,h,V,X]),ae=as({data:ie,rawData:s,colorBy:re,colorScheme:p,legendInteraction:N,legendPosition:R,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:V,height:X}),le=Va({brushProp:x,onBrushProp:w,linkedBrush:k,valueAccessor:d}),ce=Sr(),ue=t.useMemo(()=>new Map,[ie]),de=Wa({colorBy:re,colorScale:ae.colorScale,color:$,themeCategorical:ce,colorScheme:p,categoryIndexMap:ue,userPieceStyle:null==A?void 0:A.pieceStyle,stroke:D,strokeWidth:B,opacity:I,effectiveSelectionHook:ae.effectiveSelectionHook,resolvedSelection:ae.resolvedSelection,cycleByCategory:!0}),he=t.useMemo(()=>zr({categoryAccessor:u,valueAccessor:d,groupAccessor:c,valueFormat:f}),[u,c,d,f]),fe=os({componentName:"SwimlaneChart",data:s,accessors:{categoryAccessor:c,valueAccessor:d,subcategoryAccessor:u},requiredProps:{subcategoryAccessor:u}}),{effectiveLegendProps:ge,effectiveMargin:pe}=za({ref:o,frameRef:r,setup:ae});if(ae.earlyReturn)return ae.earlyReturn;const 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:[V,X],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:pe,barPadding:se,enableHover:U}),n.dataIdAccessor&&{dataIdAccessor:n.dataIdAccessor}),{showAxes:i.showAxes,oLabel:!1===z?void 0:ne,rLabel:oe,rFormat:f}),F&&{rTickValues:F}),null!=H&&{tickLabelEdgeAlign:H}),E&&{oFormat:E}),void 0!==z&&{showCategoryTicks:z}),{showGrid:K}),ge),xs({title:Z,description:J,summary:ee,accessibleTable:te,className:l,animate:n.animate,axisExtent:n.axisExtent,autoPlaceAnnotations:n.autoPlaceAnnotations})),ks({tooltip:m,defaultTooltipContent:he})),ws({linkedHover:S,onObservation:C,onClick:O,hoverHighlight:M,customHoverBehavior:ae.customHoverBehavior,customClickBehavior:ae.customClickBehavior})),b&&b.length>0&&{annotations:b}),W&&{gradientFill:!0===W?{topOpacity:.8,bottomOpacity:.05}:W}),null!=G&&{trackFill:G}),null!=Y&&{roundedTop:Y}),q&&{rExtent:q}),le.brushStreamProps),Object.fromEntries(Object.entries(A).filter(([e])=>"pieceStyle"!==e)));return fe?e.jsx(Wr,{componentName:"SwimlaneChart",message:fe,width:V,height:X}):e.jsx(Vr,{componentName:"SwimlaneChart",width:V,height:X,children:e.jsx(Ha,Object.assign({ref:r},ye))})});kl.displayName="SwimlaneChart";const Al={weightChange:.1,newEdge:.5,newNode:1,threshold:3,transitionDuration:500},jl={radius:3,opacity:.7,speedMultiplier:1,maxPerEdge:50,spawnRate:.1};class Sl{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 n=this.particles[t];return n.active=!0,n.t=0,n.offset=Math.random()-.5,n.edgeIndex=e,n.x=0,n.y=0,n}step(e,t,n,o){var i;for(let r=0;this.capacity>r;r++){const s=this.particles[r];if(!s.active)continue;const a=n[s.edgeIndex];if(!a||!a.bezier){s.active=!1,this._freeIndices.push(r);continue}const l=o&&null!==(i=o[s.edgeIndex])&&void 0!==i?i:1;s.t+=e*t*l*(a.bezier.circular?.3:1),1>s.t?Cl(a.bezier,s.t,s.offset,s):(s.active=!1,this._freeIndices.push(r))}}countForEdge(e){let t=0;for(let n=0;this.capacity>n;n++)this.particles[n].active&&this.particles[n].edgeIndex===e&&t++;return t}clear(){for(let e=0;this.capacity>e;e++)this.particles[e].active=!1;this._freeIndices.length=0;for(let e=this.capacity-1;e>=0;e--)this._freeIndices.push(e)}resize(e){if(this.capacity>=e)return;const t=this.particles;this.particles=Array(e);for(let n=0;e>n;n++)t.length>n?this.particles[n]=t[n]:(this.particles[n]={t:0,offset:0,edgeIndex:0,active:!1,x:0,y:0},this._freeIndices.push(n));this.capacity=e}}function Cl(e,t,n,o){if(e.circular&&e.segments)return void function(e,t,n,o,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];Ol(c,u,d,h,l,i);const f=h.x-c.x,g=h.y-c.y,p=Math.sqrt(f*f+g*g);if(p>.001){const e=f/p;i.x+=-g/p*n*o*2,i.y+=e*n*o*2}}(e.segments,t,n,e.halfWidth,o);if(!e.points)return o.x=0,void(o.y=0);const[i,r,s,a]=e.points;Ol(i,r,s,a,t,o);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;o.x+=-c/u*n*e.halfWidth*2,o.y+=t*n*e.halfWidth*2}}function Ol(e,t,n,o,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*n.x+u*o.x,r.y=l*e.y+3*a*i*t.y+3*s*c*n.y+u*o.y}function Ml(e,t){var n=e.get(t);if(!n)throw Error("missing: "+t);return n}function Pl(e,t){var n,o=[],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,o,d=!1;for(i.push(e),r[e]=!0,t=0;a[e].length>t;t++)(o=a[e][t])===n?(u(n,i),d=!0):r[o]||(d=c(o));if(d)l(e);else for(t=0;a[e].length>t;t++){var h=s[o=a[e][t]];h||(s[o]=h={}),h[o]=!0}return i.pop(),d}function u(e,t){var n=[].concat(t).concat(e);o.push(n)}function d(t){!function(t){for(var n=0;e.length>n;n++)n>=t&&e[n]||(e[n]=[]),e[n]=e[n].filter(function(e){return e>=t})}(t);for(var n,o=function(e){for(var t=e.length,n=Array(t),o=Array(t),i=Array(t),r=Array(t),s=Array(t),a=Array(t),l=0;t>l;++l)n[l]=-1,o[l]=0,i[l]=!1,r[l]=0,s[l]=-1,a[l]=[];var c,u=0,d=[],h=[];function f(t){var l=[t],c=[t];for(n[t]=o[t]=u,i[t]=!0,u+=1;c.length>0;){var f=e[t=c[c.length-1]];if(f.length>r[t]){for(var g=r[t];f.length>g;++g){var p=f[g];if(0>n[p]){n[p]=o[p]=u,i[p]=!0,u+=1,l.push(p),c.push(p);break}i[p]&&(o[t]=0|Math.min(o[t],o[p])),0>s[p]||a[t].push(s[p])}r[t]=g}else{if(o[t]===n[t]){var y=[],m=[],v=0;for(g=l.length-1;g>=0;--g){var b=l[g];if(i[b]=!1,y.push(b),m.push(a[b]),v+=a[b].length,s[b]=d.length,b===t){l.length=g;break}}d.push(y);var x=Array(v);for(g=0;m.length>g;g++)for(var w=0;m[g].length>w;w++)x[--v]=m[g][w];h.push(x)}c.pop()}}}for(l=0;t>l;++l)0>n[l]&&f(l);for(l=0;h.length>l;l++){var g=h[l];if(0!==g.length){g.sort(function(e,t){return e-t}),c=[g[0]];for(var p=1;g.length>p;p++)g[p]!==g[p-1]&&c.push(g[p]);h[l]=c}}return{components:d,adjacencyList:h}}(e),i=o.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],n=s);var l=i[n];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}}n=0;for(var h=e.length;h>n;){var f=d(n);if(n=f.leastVertex,a=f.adjList){for(var g=0;a.length>g;g++)for(var p=0;a[g].length>p;p++){var y=a[g][p];r[+y]=!1,s[y]={}}c(n),n+=1}else n=h}return o}function _l(e){return e.y0-e.y1>0?"up":"down"}function Ll(e,t){return t(e.source)==t(e.target)}function Tl(e){var t=0;e.source.sourceLinks.forEach(function(e){t=e.circular?t+1:t});var n=0;return e.target.targetLinks.forEach(function(e){n=e.circular?n+1:n}),1>=t&&1>=n}function Nl(e){return e.target.x0-e.source.x1}function Rl(e,t){var n=Dl(e),o=Nl(t)/Math.tan(n);return"up"==_l(e)?e.y1-o:e.y1+o}function $l(e,t){var n=Dl(e),o=Nl(t)/Math.tan(n);return"up"==_l(e)?e.y1+o:e.y1-o}function Dl(e){var t=Math.abs(e.y1-e.y0);return Math.atan(Math.abs(e.target.x0-e.source.x1)/t)}function Bl(e,t){return t(e)}function Il(e){return Fl(e.source)}function El(e){return Fl(e.target)}function Fl(e){return(e.y0+e.y1)/2}function Hl(e){return e.virtual?0:e.value}function zl(e,t){var n=0;e.sourceLinks.forEach(function(e){n=e.circular&&!Ll(e,t)?n+1:n});var o=0;return e.targetLinks.forEach(function(e){o=e.circular&&!Ll(e,t)?o+1:o}),n+o}function Wl(e){return e.target.depth}function Gl(e,t){return e.sourceLinks.length?e.depth:t-1}function Yl(e,t){return e.y0-t.y0}function ql(e,t){return t.y0-e.y0}function Vl(e,t){return e.y1-t.y1}function Xl(e,t){return t.y1-e.y1}function Ul(e,t){return Ql(e.source,t.source)||e.index-t.index}function Kl(e,t){return Ql(e.target,t.target)||e.index-t.index}function Ql(e,t){return e.partOfCycle===t.partOfCycle?e.y0-t.y0:"top"===e.circularLinkType||"bottom"===t.circularLinkType?-1:1}function Zl(e,t){return Jl(e)==Jl(t)?"bottom"==e.circularLinkType?ql(e,t):Yl(e,t):Jl(t)-Jl(e)}function Jl(e){return e.target.column-e.source.column}function ec(e,t){return tc(e)==tc(t)}function tc(e){return e.y0-e.y1>0?"up":"down"}function nc(e,t,n,o,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}),oc(r.links.filter(function(e){return"top"==e.circularLinkType}),t,n),oc(r.links.filter(function(e){return"bottom"==e.circularLinkType}),t,n),r.links.forEach(function(e){if(e.circular){if(e.circularPathData.arcRadius=e._circularWidth+o,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,Ll(e,t)&&Tl(e))e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2,e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2,e.circularPathData.leftLargeArcRadius=o+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?ql:Yl);var u=0;c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.rightSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.rightLargeArcRadius=o+e._circularWidth/2+i*n+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?Xl:Vl),u=0,c.forEach(function(t,i){t.circularLinkID==e.circularLinkID&&(e.circularPathData.leftSmallArcRadius=o+e._circularWidth/2+u,e.circularPathData.leftLargeArcRadius=o+e._circularWidth/2+i*n+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,n=e.y0,o=e.target.x0,i=e.y1,r=(t+o)/2;return"M"+t+","+n+"C"+r+","+n+" "+r+","+i+" "+o+","+i}(e)}),r}function oc(e,t,n){e.sort(Zl);var o=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(Ll(e,t)&&Tl(e))e.circularPathData.verticalBuffer=r+e._circularWidth/2;else{for(var s=0;o.length>s;s++){var a=o[s];if(a!==e&&a.circularPathData&&void 0!==a.circularPathData.verticalBuffer&&ic(e,a)){var l=a.circularPathData.verticalBuffer+(a._circularWidth||a.width)/2+n;r=l>r?l:r}}e.circularPathData.verticalBuffer=r+e._circularWidth/2}}),e}function ic(e,t){return e.source.column>=t.target.column&&t.source.column>=e.target.column}function rc(e){return function(){return e}}function sc(e){return e.index}function ac(e){return e.nodes}function lc(e){return e.links}function cc(e,t,n){var o=a.groups(e.nodes,function(e){return e.column}).sort(function(e,t){return e[0]-t[0]}).map(function(e){return e[1]});o.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 n,o,i,r=(o=0,i=0,(n=e).targetLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Fl(e.source)*t,o+=t}}),n.sourceLinks.forEach(function(e){if(!e.circular){var t=e.value||1;i+=Fl(e.target)*t,o+=t}}),o>0?i/o:NaN);a.set(e,{bc:r,idx:t})}),i.sort(function(e,t){var n=a.get(e),o=a.get(t),i=n.bc,r=o.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)?n.idx-o.idx:1:-1:i-r})}else i.sort(function(e,t){return e.circularLinkType==t.circularLinkType?zl(t,n)-zl(e,n):"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==o.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==zl(t,n)?(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 uc(e,t,n,o,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,n),d();function u(t,n){var o=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&&zl(i,n)>0){var c=a.mean(i.sourceLinks,El),u=a.mean(i.targetLinks,Il),d=c&&u?(c+u)/2:c||u;if(d){var h=(d-Fl(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==o-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 f=a.mean(i.sourceLinks,El),g=a.mean(i.targetLinks,Il),p=((f&&g?(f+g)/2:f||g)-Fl(i))*t;i.y0+=p,i.y1+=p}})})}function d(){s.forEach(function(n){var r,s,a,l=e.y0,c=n.length;for(n.sort(t||Ql),a=0;c>a;++a)(s=l-(r=n[a]).y0)>0&&(r.y0+=s,r.y1+=s),l=r.y1+o;if((s=l-o-e.y1)>0)for(l=r.y0-=s,r.y1-=s,a=c-2;a>=0;--a)(s=(r=n[a]).y1+i-l)>0&&(r.y0-=s,r.y1-=s),l=r.y0})}}function dc(e){e.nodes.forEach(function(e){e.sourceLinks.sort(Kl),e.targetLinks.sort(Ul)}),e.nodes.forEach(function(e){var t=e.y0,n=t,o=e.y1,i=o;e.sourceLinks.forEach(function(e){e.circular?(e.y0=o-e.width/2,o-=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=n+e.width/2,n+=e.width)})})}function hc(){var e=0,t=0,n=1,o=1,i=24,r=8,s=null,l=sc,c=Gl,u=void 0,d=32,h=2,f=ac,g=lc;function p(){var p={nodes:f.apply(null,arguments),links:g.apply(null,arguments)};return function(f){f.x0=e,f.y0=t,f.x1=n,f.y1=o,f.py=0,function(e,t){e.nodes.forEach(function(e,t){e.index=t,e.sourceLinks=[],e.targetLinks=[]});var n=function(e,t){var n=new Map;return a.group(e,t).forEach(function(e,t){n.set(t,e[0])}),n}(e.nodes,t);e.links.forEach(function(e,t){e.index=t;var o=e.source,i=e.target;"object"!=typeof o&&(o=e.source=Ml(n,o)),"object"!=typeof i&&(i=e.target=Ml(n,i)),o.sourceLinks.push(e),i.targetLinks.push(e)})}(f,l),function(e,t){var n=0;if(null==t){for(var o=[],i=0;e.links.length>i;i++){var r=e.links[i],s=r.source.index,a=r.target.index;o[s]||(o[s]=[]),o[a]||(o[a]=[]),-1===o[s].indexOf(a)&&o[s].push(a)}var l=Pl(o);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,o=e.source.index;t===o||c[o]&&c[o][t]?(e.circular=!0,e.circularLinkID=n++):e.circular=!1})}else e.links.forEach(function(e){t(e.source)<t(e.target)?e.circular=!1:(e.circular=!0,e.circularLinkID=n++)})}(f,u),function(e,t){var n=0,o=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:o>n?"top":"bottom","top"==i.circularLinkType?n++:o++,e.nodes.forEach(function(e){Bl(e,t)!=Bl(i.source,t)&&Bl(e,t)!=Bl(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),Ll(e,t)&&(e.circularLinkType=e.source.circularLinkType))})}(f,l),function(e){e.nodes.forEach(function(e){e.partOfCycle=!1,e.value=Math.max(a.sum(e.sourceLinks,Hl),a.sum(e.targetLinks,Hl)),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)})})}(f),function(e,t,n){var o,i,r;if(null!=t){e.nodes.sort(function(e,n){return t(e)<t(n)?-1:1});var s=0,a=t(e.nodes[0]);e.nodes.forEach(function(e){s=t(e)==a?s:s+1,a=t(e)==a?a:t(e),e.column=s})}for(o=e.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.forEach(function(e){e.depth=r,e.sourceLinks.forEach(function(e){0>i.indexOf(e.target)&&!e.circular&&i.push(e.target)})});for(o=e.nodes,i=[],r=0;o.length;++r,o=i,i=[])o.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?n(e,r):e.column})}(f,u,c);var g=r;if(null!==s){var p=a.groups(f.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&&(g=Math.max(1,(o-t)*s/(y-1)))}(function(e,t,n){var o=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(o,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-n)/r),t.x1=t.x0+n}:function(t){t.x0=e.x0,t.x1=t.x0+n})})(f,g,i),cc(f,u,l),uc(f,u,l,g,g,d),dc(f),nc(f,l,h,10,8),cc(f,u,l),uc(f,u,l,g,g,d),dc(f),nc(f,l,h,10,8),function(e,t){let n=e;n.nodes.forEach(function(e){e.y+(e.y1-e.y0)>n.y1&&(e.y=e.y-(e.y+(e.y1-e.y0)-n.y1));var o=n.links.filter(function(n){return Bl(n.source,t)==Bl(e,t)}),i=o.length;i>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.target.column==t.target.column)return e.y1-t.y1;if(!ec(e,t))return e.y1-t.y1;if(e.target.column>t.target.column){var n=Rl(t,e);return e.y1-n}if(t.target.column>e.target.column)return Rl(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;o.forEach(function(e){e.y0=r+e.width/2,r+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;t.y0=e.y1-s-t.width/2}})})}(f,l),function(e,t){let n=e;n.nodes.forEach(function(e){var o=n.links.filter(function(n){return Bl(n.target,t)==Bl(e,t)}),i=o.length;i>1&&o.sort(function(e,t){if(!e.circular&&!t.circular){if(e.source.column==t.source.column)return e.y0-t.y0;if(!ec(e,t))return e.y0-t.y0;if(e.source.column>t.source.column){var n=$l(t,e);return e.y0-n}if(t.source.column>e.source.column)return $l(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;o.forEach(function(e){e.y1=r+e.width/2,r+=e.width}),o.forEach(function(t,n){if("bottom"==t.circularLinkType){for(var r=n+1,s=0;i>r;r++)s+=o[r].width;t.y1=e.y1-s-t.width/2}})})}(f,l),function(e){var t=e.nodes,n=e.links,o=!1,i=!1;if(n.forEach(function(e){"top"==e.circularLinkType?o=!0:"bottom"==e.circularLinkType&&(i=!0)}),0==o||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)}),n.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,n=c(e.y0)-e.y0;e.y0=c(e.y0),e.y1=e.y0+t,e.sourceLinks.forEach(function(e){e.y0=e.y0+n}),e.targetLinks.forEach(function(e){e.y1=e.y1+n})})}}(f),nc(f,l,h,10,8)}(p),p}return p.update=function(e){return dc(e),nc(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?(f="function"==typeof e?e:rc(e),p):f},p.links=function(e){return arguments.length?(g="function"==typeof e?e:rc(e),p):g},p.nodeId=function(e){return arguments.length?(l="function"==typeof e?e:rc(e),p):l},p.nodeAlign=function(e){return arguments.length?(c="function"==typeof e?e:rc(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],n=+i[1][0],o=+i[1][1],p):[[e,t],[n,o]]},p.size=function(i){return arguments.length?(e=t=0,n=+i[0],o=+i[1],p):[n-e,o-t]},p}function fc(e){const{sx:t,sTop:n,sBot:o,tx:i,tTop:r,tBot:s,cp1X:a,cp2X:l}=e,c=(n+o)/2,u=(r+s)/2;return{pathD:[`M${t},${n}`,`C${a},${n} ${l},${r} ${i},${r}`,`L${i},${s}`,`C${l},${s} ${a},${o} ${t},${o}`,"Z"].join(" "),bezier:{circular:!1,points:[{x:t,y:c},{x:a,y:c},{x:l,y:u},{x:i,y:u}],halfWidth:(o-n)/2}}}const gc=e=>{let t,n,o,i,r,s,a,l,c;if("down"===e.direction)return t=e.y0-e.sankeyWidth/2,n=e.y1-e.sankeyWidth/2,o=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} ${n},${c} ${n},${s}L${o},${s}C${o},${c} ${i},${l} ${i},${r}Z`;const d=e.sankeyWidth/2,h=u.interpolateNumber(e.source.x1,e.target.x0),{pathD:f}=fc({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 f};function pc(e){var t;const n=e.sankeyWidth/2,o=(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,o=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},${o-n}L${t+a},${o-n}L${t+a},${o+n}L${t},${o+n}ZM${r},${s-n}L${r-l},${s-n}L${r-l},${s+n}L${r},${s+n}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,f=Math.max(4,Math.min(o,15));return`M${r},${s-h*n}L${c},${s-h*n}L${c+o},${s-h*n+h*f}L${c+o},${d+h*o-h*f}L${c+o-f},${d+h*o}L${u-o+f},${d+h*o}L${u-o},${d+h*o-h*f}L${u-o},${l-h*n+h*f}L${u-o+f},${l-h*n}L${a},${l-h*n}L${a},${l+h*n}L${u+o},${l+h*n}L${u+o},${d-h*o}L${c-o},${d-h*o}L${c-o},${s+h*n}L${r},${s+h*n}Z`}const yc=new Set,mc=new WeakMap;function vc(e,t){if("production"===process.env.NODE_ENV)return e;if(!e||!e.data||"object"!=typeof e.data)return e;let n=mc.get(e);if(n){const e=n.get(t);if(e)return e}else n=new Map,mc.set(e,n);const o=new Proxy(e,{get(e,n,o){if("string"==typeof n&&!(n in e)&&e.data&&n in e.data){const e=`${t}:${n}`;yc.has(e)||(yc.add(e),console.warn(`[Semiotic] "${t}" callback accessed "${n}" on the wrapper object, but it only exists on ".data". Use d.data.${n} (or d.data?.${n}) instead. Frame callbacks receive RealtimeNode/RealtimeEdge wrappers, not your raw data.`))}return Reflect.get(e,n,o)}});return n.set(t,o),o}const bc={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(Wl))-1:0},justify:Gl};function xc(e){return"string"==typeof e?e:e.id}const wc={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var i,r,s,a,l,c,u;if(0===e.length)return;const d="vertical"===n.orientation?"down":"right",h=n.nodeAlign||"justify",f=null!==(i=n.nodeWidth)&&void 0!==i?i:15,g=null!==(r=n.nodePaddingRatio)&&void 0!==r?r:.05,p=null!==(s=n.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],[o[1],o[0]]]:[[0,0],[o[0],o[1]]];const b=hc().extent(v).links(m).nodes(y).nodeAlign(bc[h]||Gl).nodeId(e=>e.id).nodeWidth(f).iterations(p);b.nodePaddingRatio&&b.nodePaddingRatio(g),b();{let e=1/0,t=-1/0,n=1/0,i=-1/0;for(const o of y)e>o.x0&&(e=o.x0),o.x1>t&&(t=o.x1),n>o.y0&&(n=o.y0),o.y1>i&&(i=o.y1);for(const o of m){if(!o.circular||!o.circularPathData)continue;const r=o.circularPathData,s=(null!==(l=null!==(a=o._circularWidth)&&void 0!==a?a:o.width)&&void 0!==l?l:0)/2;e>r.leftFullExtent-s&&(e=r.leftFullExtent-s),r.rightFullExtent+s>t&&(t=r.rightFullExtent+s),n>r.verticalFullExtent-s&&(n=r.verticalFullExtent-s),r.verticalFullExtent+s>i&&(i=r.verticalFullExtent+s)}const r=t-e,s=i-n,u=o[0],d=o[1];if(r>0&&s>0&&(0>e||0>n||t>u||i>d)){const t=Math.min(u/r,d/s),o=-e*t+(u-r*t)/2,i=-n*t+(d-s*t)/2;for(const e of y)e.x0=e.x0*t+o,e.x1=e.x1*t+o,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 n=e.circularPathData;n.sourceX=n.sourceX*t+o,n.targetX=n.targetX*t+o,n.sourceY=n.sourceY*t+i,n.targetY=n.targetY*t+i,n.rightFullExtent=n.rightFullExtent*t+o,n.leftFullExtent=n.leftFullExtent*t+o,n.verticalFullExtent=n.verticalFullExtent*t+i,n.rightInnerExtent=n.rightInnerExtent*t+o,n.leftInnerExtent=n.leftInnerExtent*t+o,n.verticalRightInnerExtent=n.verticalRightInnerExtent*t+i,n.verticalLeftInnerExtent=n.verticalLeftInnerExtent*t+i,n.rightSmallArcRadius*=t,n.rightLargeArcRadius*=t,n.leftSmallArcRadius*=t,n.leftLargeArcRadius*=t,n.sourceWidth*=t,n.rightNodeBuffer*=t,n.leftNodeBuffer*=t,n.arcRadius*=t}}}const 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 w=new Map;for(const e of t)w.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=xc(e.source),n=xc(e.target),o=w.get(e._edgeKey?e._edgeKey:`${t}\0${n}`);if(o){o.y0=e.y0,o.y1=e.y1,o.sankeyWidth=null!==(u=e.width)&&void 0!==u?u:0,o.circular=!!e.circular,o.circularPathData=e.circularPathData,o._circularWidth=e._circularWidth,o._circularStub=e._circularStub,o.path=e.path,o.circularLinkType=e.circularLinkType,o.direction=d;const i=x.get(t),r=x.get(n);i&&(o.source=i),r&&(o.target=r)}}},buildScene(e,t,n,o){var i,r,s,a,l,c;const u="vertical"===n.orientation?"down":"right",d=n.nodeStyle,h=n.edgeStyle,f=null!==(i=n.edgeOpacity)&&void 0!==i?i:.5,g=n.edgeColorBy||"source",p=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.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,n=t.y1-t.y0;if(0>=e||0>=n)continue;const o=d?d(vc(t,"nodeStyle")):{},i={fill:o.fill||y.get(t.id)||"#4d430c",stroke:o.stroke,strokeWidth:o.strokeWidth,opacity:o.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:n,h:e,style:i,datum:t,id:t.id,label:t.id}:{type:"rect",x:t.x0,y:t.y0,w:e,h:n,style:i,datum:t,id:t.id,label:t.id})}const w=[...t].sort((e,t)=>(t.sankeyWidth||0)-(e.sankeyWidth||0));for(const e of w){if(!e.sankeyWidth||0>=e.sankeyWidth)continue;const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let i=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";i="function"==typeof g?g(e)||i:"target"===g?x.get(o.id)||y.get(o.id)||i:x.get(t.id)||y.get(t.id)||i;const u=h?h(vc(e,"edgeStyle")):{};if(e._circularStub&&e.circular&&e.circularPathData){const t=e.circularPathData,n=e.sankeyWidth/2,o=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-n}L${t.sourceX+o},${t.sourceY-n}L${t.sourceX+o},${t.sourceY+n}L${t.sourceX},${t.sourceY+n}Z`,style:{fill:s,fillOpacity:null!==(a=u.fillOpacity)&&void 0!==a?a:f,stroke:"none",opacity:u.opacity},datum:e,_gradient:{direction:"right",from:1,to:0,x0:t.sourceX,x1:t.sourceX+o}}),v.push({type:"bezier",pathD:`M${t.targetX},${t.targetY-n}L${t.targetX-r},${t.targetY-n}L${t.targetX-r},${t.targetY+n}L${t.targetX},${t.targetY+n}Z`,style:{fill:s,fillOpacity:null!==(l=u.fillOpacity)&&void 0!==l?l:f,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?pc(e):gc(e),!d)continue;const p={fill:u.fill||i,fillOpacity:null!==(c=u.fillOpacity)&&void 0!==c?c:f,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!==n.showLabels){const t=(k=n.nodeLabel)?"function"==typeof k?k:e=>e[k]||e.id:null;for(const n of e){const e=n.x1-n.x0,i=n.y1-n.y0;if(0>=e||0>=i)continue;const r=t?t(n):n.id;if(!r)continue;let s,a,l;"down"===u?(s=n.y0+(n.y1-n.y0)/2,a=n.x1+14,l="start"):(o[0]/2>n.x0+e/2?(s=n.x0-6,l="end"):(s=n.x1+6,l="start"),a=n.y0+i/2),b.push({x:s,y:a,text:r+"",anchor:"down"===u?"middle":l,baseline:"middle",fontSize:11})}}var k;return{sceneNodes:m,sceneEdges:v,labels:b}}},kc={supportsStreaming:!0,hierarchical:!1,computeLayout(e,t,n,o){var i,r;if(0===e.length)return;const s=null!==(i=n.forceStrength)&&void 0!==i?i:.1,a=o[0]/2,l=o[1]/2,c=n.__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),n=null==c?void 0:c.get(t.id);e?u++:n?(t.x=n.x,t.y=n.y,u++):h.push(t)}const f=u>0&&.3>=(e.length>0?h.length/e.length:1);if(f){const n=new Map;for(const t of e)n.set(t.id,t);for(const e of h){const o=Ac(e.id,t,n);if(o.length>0){let t=0,n=0;for(const e of o)t+=e.x,n+=e.y;const i=jc(e.id),r=i%360*(Math.PI/180),s=10+i%20;e.x=t/o.length+s*Math.cos(r),e.y=n/o.length+s*Math.sin(r)}else{const t=jc(e.id),n=t%360*(Math.PI/180),o=15+t%30;e.x=a+o*Math.cos(n),e.y=l+o*Math.sin(n)}}}else{const t=2.399963229728653;for(let n=0;e.length>n;n++){const o=e[n];if(null==o.x||null==o.y||0===o.x&&0===o.y){const e=10*Math.sqrt(n+.5),i=n*t;o.x=a+e*Math.cos(i),o.y=l+e*Math.sin(i)}}}const g=null!==(r=n.iterations)&&void 0!==r?r:Math.max(50,Math.min(300,Math.floor(300-2*(e.length-30)))),p=0===n.iterations?0:f?40:g,y=Sc(n.nodeSize,n.nodeSizeRange,e),m=e=>y(e);if(p>0){const n=d.forceLink().strength(e=>{const t=e.weight;return Math.min(2.5,t?t*s:s)}).id(e=>e.id),o=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(o.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}));n.links(e),o.force("link",n)}f?o.alpha(.3):.1>o.alpha()&&o.alpha(1),o.stop();for(let e=0;p>e;++e)o.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(o[0]-e,t.x)),t.y=Math.max(e,Math.min(o[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,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.edgeStyle,f=Sc(n.nodeSize,n.nodeSizeRange,e),g=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:K,p=new Map;e.forEach((e,t)=>{p.set(e.id,g[t%g.length])});const y=[],m=[],v=[];for(const t of e){if(null==t.x||null==t.y)continue;const e=f(vc(t,"nodeSize")),o=d?d(vc(t,"nodeStyle")):{},a={fill:o.fill||p.get(t.id)||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#007bff",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:2,opacity:o.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),o="object"==typeof e.target?e.target:b.get(e.target);if(!t||!o)continue;if(null==t.x||null==t.y)continue;if(null==o.x||null==o.y)continue;const i=h?h(vc(e,"edgeStyle")):{},r={stroke:i.stroke||(null===(a=n.themeSemantic)||void 0===a?void 0:a.border)||(null===(l=n.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:o.x,y2:o.y,style:r,datum:e})}if(!1!==n.showLabels){const t=(x=n.nodeLabel)?"function"==typeof x?x:e=>e[x]||e.id:null;for(const n of e){if(null==n.x||null==n.y)continue;const e=t?t(n):n.id;if(!e)continue;const o=f(vc(n,"nodeSize"));v.push({x:n.x,y:n.y-o-4,text:e+"",anchor:"middle",baseline:"auto",fontSize:11})}}var x;return{sceneNodes:y,sceneEdges:m,labels:v}}};function Ac(e,t,n){const o=[];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=n.get(s);!e||0===e.x&&0===e.y||o.push({x:e.x,y:e.y})}}return o}function jc(e){let t=0;for(let n=0;e.length>n;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)}function Sc(e,t,n){var o,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=n.map(t=>{var n;return null===(n=t.data)||void 0===n?void 0:n[e]}).filter(e=>null!=e&&"number"==typeof e);if(0===l.length)return()=>s[0];const c=null!==(o=a.min(l))&&void 0!==o?o: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 n;const o=null===(n=t.data)||void 0===n?void 0:n[e];return null==o||"number"!=typeof o?s[0]:d(o)}}const Cc=K,Oc={supportsStreaming:!1,hierarchical:!1,computeLayout(e,t,n,o){if(0===e.length)return;const{padAngle:i=.01,groupWidth:r=20,sortGroups:a}=n,l=Math.min(o[0],o[1])/2,c=l-r,u=o[0]/2,d=o[1]/2,f=(g=n.valueAccessor)?"function"==typeof g?g:e=>{var t;return null!==(t=e[g])&&void 0!==t?t:1}:e=>{var t;return null!==(t=e.value)&&void 0!==t?t:1};var g;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,n=p.get("string"==typeof e.source?e.source:e.source.id),o=p.get(t);if(void 0===n||void 0===o)continue;const i=f(e);m[n][o]=i}const v=h.chord().padAngle(i);a&&v.sortGroups(a);const b=v(m),x=b.groups,w=s.arc().innerRadius(c).outerRadius(l);for(const t of x){const n=e[t.index],o=w.centroid({innerRadius:c,outerRadius:l,startAngle:t.startAngle,endAngle:t.endAngle});n.x=o[0]+u,n.y=o[1]+d,n.__arcData={startAngle:t.startAngle,endAngle:t.endAngle}}const k=new Map;for(const t of e)k.set(t.id,t);for(const e of t){const t="string"==typeof e.target?e.target:e.target.id,n=k.get("string"==typeof e.source?e.source:e.source.id),o=k.get(t);n&&(e.source=n),o&&(e.target=o)}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 n=e[t.source.index].id,o=e[t.target.index].id,i=A.get(`${n}\0${o}`)||A.get(`${o}\0${n}`);i&&(i.__chordData=t)}},buildScene(e,t,n,o){var i,r,s,a;const{groupWidth:l=20,edgeOpacity:c=.5}=n,u=Math.min(o[0],o[1])/2,d=u-l,f=o[0]/2,g=o[1]/2,p=n.nodeStyle,y=n.edgeStyle,m=n.edgeColorBy||"source",v=Array.isArray(n.colorScheme)?n.colorScheme:n.themeCategorical&&n.themeCategorical.length>0?n.themeCategorical:Cc,b=new Map;e.forEach((e,t)=>{b.set(e.id,v[t%v.length])});const x=h.ribbon().radius(d),w=[],k=[],A=[];for(let t=0;e.length>t;t++){const n=e[t],o=n.__arcData;if(!o)continue;let r;r=p?p(vc(n,"nodeStyle")).fill||b.get(n.id)||v[t%v.length]:b.get(n.id)||v[t%v.length];const s=p?p(vc(n,"nodeStyle")):{},a={fill:r,stroke:s.stroke||"black",strokeWidth:null!==(i=s.strokeWidth)&&void 0!==i?i:1,opacity:s.opacity};w.push({type:"arc",cx:f,cy:g,innerR:d,outerR:u,startAngle:o.startAngle-Math.PI/2,endAngle:o.endAngle-Math.PI/2,style:a,datum:n,id:n.id,label:n.id})}for(const e of t){const t=e.__chordData;if(!t)continue;const o=x(t);if(!o)continue;const i=Mc(o,f,g);let l=(null===(r=n.themeSemantic)||void 0===r?void 0:r.border)||(null===(s=n.themeSemantic)||void 0===s?void 0:s.secondary)||"#999";if(y)l=y(vc(e,"edgeStyle")).fill||l;else{const t="object"==typeof e.source?e.source:null,n="object"==typeof e.target?e.target:null;"target"===m&&n?l=b.get(n.id)||l:t&&(l=b.get(t.id)||l)}const u=y?y(vc(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};k.push({type:"ribbon",pathD:i,style:d,datum:e})}if(!1!==n.showLabels){const t=(j=n.nodeLabel)?"function"==typeof j?j:e=>e[j]||e.id:null,o=u+12;for(const n of e){const e=n.__arcData;if(!e)continue;const i=t?t(n):n.id;if(!i)continue;const r=(e.startAngle+e.endAngle)/2,s=r-Math.PI/2;A.push({x:f+Math.cos(s)*o,y:g+Math.sin(s)*o,text:i+"",anchor:r>Math.PI?"end":"start",baseline:"middle",fontSize:11})}}var j;return{sceneNodes:w,sceneEdges:k,labels:A}}};function Mc(e,t,n){const o=e.match(/[a-zA-Z]|[-+]?\d*\.?\d+(?:[eE][-+]?\d+)?/g);if(!o)return e;const i=[];let r=0;for(;o.length>r;){const e=o[r];if("M"===e||"L"===e)for(i.push(e),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(Number(o[r])+t+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("C"===e)for(i.push(e),r++;o.length>r&&!isNaN(Number(o[r]));)for(let e=0;3>e&&o.length>r&&!isNaN(Number(o[r]));e++)i.push(Number(o[r])+t+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("Q"===e)for(i.push(e),r++;o.length>r&&!isNaN(Number(o[r]));)for(let e=0;2>e&&o.length>r&&!isNaN(Number(o[r]));e++)i.push(Number(o[r])+t+""),r++,o.length>r&&!isNaN(Number(o[r]))&&(i.push(Number(o[r])+n+""),r++);else if("A"===e)for(i.push(e),r++;o.length>r&&!isNaN(Number(o[r]));)i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&i.push(o[r++]),o.length>r&&(i.push(Number(o[r])+t+""),r++),o.length>r&&(i.push(Number(o[r])+n+""),r++);else"Z"===e||"z"===e?(i.push(e),r++):(i.push(o[r]),r++)}return i.join(" ")}const Pc=["#e8d5b7","#b8d4e3","#d4e3b8","#e3c4d4","#d4d4e3","#e3d4b8","#b8e3d4","#e3b8b8"];function _c(e){const[t,n,o]=function(e){if(e.startsWith("#")){let t=e.slice(1);if(3===t.length&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),6===t.length)return[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const t=e.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);return t?[+t[1],+t[2],+t[3]]:[128,128,128]}(e);return.299*t+.587*n+.114*o>150?"#222":"#fff"}function Lc(e,t,n){const o=t.nodeIDAccessor;return"function"==typeof o?o(e.data)+"":"string"==typeof o&&void 0!==e.data[o]?e.data[o]+"":void 0!==e.data.name?e.data.name+"":void 0!==e.data.id?e.data.id+"":"node-"+n}function Tc(e){return e?"function"==typeof e?e:t=>{var n;return(null===(n=t.data)||void 0===n?void 0:n[e])||t[e]||t.id}:null}function Nc(e){return Array.isArray(e.colorScheme)?e.colorScheme:e.themeCategorical&&e.themeCategorical.length>0?e.themeCategorical:Pc}function Rc(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 $c(e,t,n,o,i){if("horizontal"===i){const i=(e+n)/2;return`M ${e},${t} C ${i},${t} ${i},${o} ${n},${o}`}if("radial"===i){const i=(e+n)/2;return`M ${e},${t} Q ${i},${t} ${i},${(t+o)/2} T ${n},${o}`}{const i=(t+o)/2;return`M ${e},${t} C ${e},${i} ${n},${i} ${n},${o}`}}const Dc={supportsStreaming:!1,hierarchical:!0,computeLayout(e,t,n,o){var i;const r=n.__hierarchyRoot;if(!r)return;const s=n.chartType,a=function(e){if(e)return"function"==typeof e?e:t=>t[e]}(n.childrenAccessor),c=n.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 n,o;return(null!==(n=t.value)&&void 0!==n?n:0)-(null!==(o=e.value)&&void 0!==o?o:0)});const[h,f]=o;switch(s){case"tree":!function(e,t,n,o){const i=t.treeOrientation||"vertical",r=l.tree();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(e)}(d,n,h,f);break;case"cluster":!function(e,t,n,o){const i=t.treeOrientation||"vertical",r=l.cluster();r.size("horizontal"===i?[o,n]:"radial"===i?[2*Math.PI,Math.min(n,o)/2*.8]:[n,o]),r(e)}(d,n,h,f);break;case"treemap":!function(e,t,n,o){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([n,o]).tile(l.treemapBinary).padding(s);a>0&&c.paddingTop(a),c(e)}(d,n,h,f);break;case"circlepack":!function(e,t,n,o){var i;const r=null!==(i=t.padding)&&void 0!==i?i:4;l.pack().size([n,o]).padding(r)(e)}(d,n,h,f);break;case"partition":!function(e,t,n,o){var i;l.partition().size([n,o]).padding(null!==(i=t.padding)&&void 0!==i?i:1)(e)}(d,n,h,f)}const g=d.descendants();e.length=0,t.length=0;const p=new Map;for(let t=0;g.length>t;t++){const o=g[t],r={id:Lc(o,n,t),x:0,y:0,x0:0,x1:0,y0:0,y1:0,width:0,height:0,value:null!==(i=o.value)&&void 0!==i?i:0,depth:o.depth,data:o.data,createdByFrame:!0};"tree"===s||"cluster"===s?Bc(r,o,n):"treemap"===s||"partition"===s?Ic(r,o):"circlepack"===s&&Ec(r,o),r.__hierarchyNode=o,e.push(r),p.set(o,r)}if("tree"===s||"cluster"===s)for(const e of g)if(e.parent){const n=p.get(e.parent),o=p.get(e);n&&o&&t.push({source:n,target:o,value:1,y0:0,y1:0,sankeyWidth:0,data:{depth:e.depth}})}},buildScene(e,t,n,o){const i=n.nodeStyle||(()=>({})),r=n.edgeStyle||(()=>({}));switch(n.chartType){case"tree":case"cluster":return function(e,t,n,o,i,r){var s,a,l,c,u,d,h,f;const g=[],p=[],y=[],m=n.treeOrientation||"vertical",v="radial"===m,b=o[0]/2,x=o[1]/2,w="number"==typeof(k=n.nodeSize)?k:5;var k;for(const t of e){let e=t.x,o=t.y;v&&(e+=b,o+=x);const r=i(vc(t,"nodeStyle"));let l=r.fill||Rc(n);if(n.colorByDepth&&void 0!==t.depth){const e=Nc(n);l=e[t.depth%e.length]}const c={fill:l,stroke:r.stroke||(null===(s=n.themeSemantic)||void 0===s?void 0:s.surface)||"#fff",strokeWidth:null!==(a=r.strokeWidth)&&void 0!==a?a:1,opacity:r.opacity};g.push({type:"circle",cx:e,cy:o,r:w,style:c,datum:t,id:t.id,label:t.id,depth:t.depth})}const A=null!==(l=n.edgeOpacity)&&void 0!==l?l:.5;for(const e of t){const t="object"==typeof e.source?e.source:null,o="object"==typeof e.target?e.target:null;if(!t||!o)continue;let i=t.x,s=t.y,a=o.x,l=o.y;v&&(i+=b,s+=x,a+=b,l+=x);const f=$c(i,s,a,l,m),g=r(vc(e,"edgeStyle")),y={fill:"none",stroke:g.stroke||(null===(c=n.themeSemantic)||void 0===c?void 0:c.border)||(null===(u=n.themeSemantic)||void 0===u?void 0:u.secondary)||"#999",strokeWidth:null!==(d=g.strokeWidth)&&void 0!==d?d:1.5,opacity:null!==(h=g.opacity)&&void 0!==h?h:A};p.push({type:"curved",pathD:f,style:y,datum:e})}if(!1!==n.showLabels){const t=Tc(n.nodeLabel);for(const n of e){const e=t?t(n):n.id;if(!e)continue;let o,i,r,s=n.x,a=n.y;if(v&&(s+=b,a+=x),v){const e=s-b,t=a-x,n=Math.sqrt(e*e+t*t);n>0?(o=s+e/n*10,i=a+t/n*10,r=0>e?"end":"start"):(o=s,i=a-12,r="middle")}else"horizontal"===m?((null===(f=n.data)||void 0===f?void 0:f.children)&&0!==n.data.children.length?(o=s-w-6,r="end"):(o=s+w+6,r="start"),i=a):(o=s,i=a+w+14,r="middle");y.push({x:o,y:i,text:e+"",anchor:r,baseline:"middle",fontSize:11})}}return{sceneNodes:g,sceneEdges:p,labels:y}}(e,t,n,o,i,r);case"treemap":case"partition":return function(e,t,n,o){var i,r,s,a,l;const c=[],u=[];for(const n of e){const e=n.x1-n.x0,s=n.y1-n.y0;if(0>=e||0>=s)continue;const a=o(vc(n,"nodeStyle"));let l=a.fill||Rc(t);if(t.colorByDepth&&void 0!==n.depth){const e=Nc(t);l=e[n.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:n.x0,y:n.y0,w:e,h:s,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Tc(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 f=n?n(c):c.id;if(!f)continue;if((h?30:40)>e||(h?16:14)>d)continue;let g=o(vc(c,"nodeStyle")).fill||Rc(t);if(t.colorByDepth&&void 0!==c.depth){const e=Nc(t);g=e[c.depth%e.length]}const p="string"==typeof g?_c(g):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:f+"",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:f+"",anchor:"start",baseline:"auto",fontSize:11,fontWeight:600,fill:p})}}return{sceneNodes:c,sceneEdges:[],labels:u}}(e,n,0,i);case"circlepack":return function(e,t,n,o){var i,r,s,a,l,c,u,d,h,f;const g=[],p=[];for(const n of e){const e=null!==(i=n.__radius)&&void 0!==i?i:5;if(0>=e)continue;const l=o(vc(n,"nodeStyle"));let c=l.fill||Rc(t);if(t.colorByDepth&&void 0!==n.depth){const e=Nc(t);c=e[n.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};g.push({type:"circle",cx:n.x,cy:n.y,r:e,style:u,datum:n,id:n.id,label:n.id,depth:n.depth})}if(!1!==t.showLabels){const n=Tc(t.nodeLabel);for(const i of e){const e=null!==(l=i.__radius)&&void 0!==l?l:5,r=n?n(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=o(vc(i,"nodeStyle")).fill||Rc(t);if(t.colorByDepth&&void 0!==i.depth){const e=Nc(t);a=e[i.depth%e.length]}if(s){const n="string"==typeof a?_c(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:n})}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===(f=t.themeSemantic)||void 0===f?void 0:f.surface)||"#fff",strokeWidth:3,paintOrder:"stroke"})}}return{sceneNodes:g,sceneEdges:[],labels:p}}(e,n,0,i);default:return{sceneNodes:[],sceneEdges:[],labels:[]}}}};function Bc(e,t,n){const o=n.treeOrientation||"vertical";if("radial"===o){const n=t.x,o=t.y;e.x=o*Math.cos(n-Math.PI/2),e.y=o*Math.sin(n-Math.PI/2)}else"horizontal"===o?(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 Ec(e,t){var n;const o=null!==(n=t.r)&&void 0!==n?n:0;e.x=t.x,e.y=t.y,e.x0=t.x-o,e.x1=t.x+o,e.y0=t.y-o,e.y1=t.y+o,e.width=2*o,e.height=2*o,e.__radius=o}function Fc(e){let t=e.__orbitState;return t||(t={metaMap:new Map,startTime:"undefined"!=typeof performance?performance.now():Date.now()},e.__orbitState=t),t}const Hc={supportsStreaming:!1,hierarchical:!0,supportsAnimation:!0,computeLayout(e,t,n,o){const i=n.__hierarchyRoot;i&&function(e,t,n,o,i){var r,a;const l=function(e){if("function"==typeof e)return e;const t=e||"children";return e=>e[t]||null}(n.childrenAccessor),c=function(e){if("function"==typeof e)return e;const t=e||"name";return e=>{var n;return(null!==(n=e[t])&&void 0!==n?n:"")+""}}(n.nodeIDAccessor),u=function(e){if(Array.isArray(e))return e;switch(e){case"solar":return[1];case"atomic":return[2,8];default:return[9999]}}(n.orbitMode),d=null!==(r=n.orbitSize)&&void 0!==r?r:2.95,h=null!==(a=n.orbitEccentricity)&&void 0!==a?a:1,f="number"==typeof d?()=>d:d,g="number"==typeof h?()=>h:h,p=Fc(n);p.metaMap.clear(),o.length=0,i.length=0;const y=new Map;function m(e){var t;const n=null!==(t=y.get(e))&&void 0!==t?t:0;return y.set(e,n+1),0===n?e:`${e}__${n}`}const v=t[0]/2,b=t[1]/2,x=Math.min(t[0],t[1])/2*.85,w=m(c(e));o.push({id:w,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(w,{ring:x,angle:0,depth:0,parentId:null,eccentricity:1}),function e(t,n,r,a,d,h,y){const v=l(t);if(!(null==v?void 0:v.length))return;const b=v.length;let x=0,w=0,k=0;for(;b>w;)w+=u[Math.min(k,u.length-1)],k++,x++;let A=0;for(let b=0;x>b;b++){const w=u[Math.min(b,u.length-1)],k=v.slice(A,A+w);if(!k.length)break;const j=(b+1)/x,S={id:n,depth:h,data:t,parentId:n},C=y?d/f(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(k),P=g(S);for(let t=0;k.length>t;t++){const s=(M[t].startAngle+M[t].endAngle)/2,l=k[t],u=m(c(l)),d=r+C*Math.sin(s),f=a+C*Math.cos(s)*P;o.push({id:u,x:d,y:f,x0:d,x1:d,y0:f,y1:f,width:0,height:0,value:0,depth:h,data:l}),p.metaMap.set(u,{ring:C,angle:s,depth:h,parentId:n,eccentricity:P}),i.push({source:n,target:u,value:1,y0:0,y1:0,sankeyWidth:0,data:{source:n,target:u}}),e(l,u,d,f,C,h+1,!0)}A+=w}}(e,w,v,b,x,1,!1)}(i,o,n,e,t)},buildScene(e,t,n,o){var i,r,s,a,l,c,u;const d=n.nodeStyle,h=n.nodeSize,f="number"==typeof h?()=>h:"function"==typeof h?h:()=>6,g=[],p=[],y=[];if(!1!==n.orbitShowRings){const t=Fc(n),o=new Map;for(const t of e)o.set(t.id,t);const i=new Map;for(const[,e]of t.metaMap){if(!e.parentId)continue;const t=o.get(e.parentId);if(!t)continue;const n=`${e.parentId}:${e.ring}`;i.has(n)||i.set(n,{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:n,ecc:o}]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+n*Math.sin(a),y1:t+n*Math.cos(a)*o,x2:e+n*Math.sin(l),y2:t+n*Math.cos(l)*o,style:s,datum:null})}}for(const t of e){if(null==t.x||null==t.y)continue;const e=f(vc(t,"nodeSize")),o=d?d(vc(t,"nodeStyle")):{},c={fill:o.fill||(null===(i=n.themeSemantic)||void 0===i?void 0:i.primary)||"#6366f1",stroke:o.stroke||(null===(r=n.themeSemantic)||void 0===r?void 0:r.surface)||"#fff",strokeWidth:null!==(s=o.strokeWidth)&&void 0!==s?s:1,opacity:null!==(a=o.opacity)&&void 0!==a?a:0===(null!==(l=t.depth)&&void 0!==l?l:0)?1:.85};g.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),n="object"==typeof e.target?e.target:m.get(e.target);t&&n&&(null!=t.x&&null!=n.x&&p.push({type:"line",x1:t.x,y1:t.y,x2:n.x,y2:n.y,style:{stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1},datum:e}))}if(n.showLabels){const t=n.nodeLabel;for(const n of e){const e=f(vc(n,"nodeSize"));if(4>=e)continue;const o="function"==typeof t?t(n):t&&null!==(u=null===(c=n.data)||void 0===c?void 0:c[t])&&void 0!==u?u:n.id;y.push({x:n.x,y:n.y+e+12,text:o+"",anchor:"middle",fontSize:10,fill:"currentColor"})}}return{sceneNodes:g,sceneEdges:p,labels:y}},tick:(e,t,n,o,i)=>!1!==n.orbitAnimated&&(function(e,t){var n,o;const i=Fc(t),r=null!==(n=t.orbitSpeed)&&void 0!==n?n:.25,s=null!==(o=t.orbitRevolution)&&void 0!==o?o: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 n=null!==(t=e.depth)&&void 0!==t?t:0;return(n%2==0?1:-1)/(n+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 n=c.get(e.parentId);if(!n)continue;const o=e.angle+a*l*s({id:t.id,depth:e.depth,data:t.data,parentId:e.parentId});t.x=n.x+e.ring*Math.sin(o),t.y=n.y+e.ring*Math.cos(o)*e.eccentricity,t.x0=t.x,t.x1=t.x,t.y0=t.y,t.y1=t.y}}(e,n),!0)},zc={sankey:wc,force:kc,chord:Oc,tree:Dc,cluster:Dc,treemap:Dc,circlepack:Dc,partition:Dc,orbit:Hc};function Wc(e){return zc[e]}class Gc{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({},Al),e.tensionConfig),e.showParticles&&("sankey"===e.chartType||e.customNetworkLayout)&&(this.particlePool=new Sl(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({},Al),e.tensionConfig),!e.showParticles||"sankey"!==e.chartType&&!e.customNetworkLayout||this.particlePool||(this.particlePool=new Sl(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,n){const{nodeIDAccessor:o="id",sourceAccessor:i="source",targetAccessor:r="target",valueAccessor:s="value"}=this.config,a="function"==typeof o?o:e=>e[o],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({},Yc(e)),{data:t}))}for(let e=0;t.length>e;e++){const n=t[e],o=l(n)+"",i=c(n)+"",r=u(n),s=null==r?NaN:Number(r),a=Number.isFinite(s)?s:1;this.nodes.has(o)||this.nodes.set(o,Object.assign(Object.assign({},Yc(o)),{data:n})),this.nodes.has(i)||this.nodes.set(i,Object.assign(Object.assign({},Yc(i)),{data:n}));const d=`${o}\0${i}\0${e}`,h={source:o,target:i,value:a,y0:0,y1:0,sankeyWidth:0,data:n,_edgeKey:d};n&&"object"==typeof n&&qc(n.bezier)&&(h.bezier=n.bezier),this.edges.set(d,h)}this.runLayout(n)}edgeKey(e,t){return`${e}\0${t}`}ingestEdge(e){const{source:t,target:n,value:o}=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,Yc(t)),this.nodeTimestamps.set(t,s),this.tension+=this.tensionConfig.newNode,r=!0),this.nodes.has(n)||(this.nodes.set(n,Yc(n)),this.nodeTimestamps.set(n,s),this.tension+=this.tensionConfig.newNode,r=!0);const a=this.edgeKey(t,n),l=this.edges.get(a);let c=!1;return l?(l.value+=o,this.edgeTimestamps.set(a,s),this.tension+=this.tensionConfig.weightChange,c=!0):(this.edges.set(a,{source:t,target:n,value:o,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,n,o,i,r,s,a,l;if(this.config.customNetworkLayout)return this.recordTopologyDiff(),void this.layoutVersion++;const c=Wc(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!==(n=a._prevX0)&&void 0!==n?n:0),c=(null!==(o=a._prevY1)&&void 0!==o?o: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,n]of this._lastPositionSnapshot)e.has(t)||e.set(t,n);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],n=t._edgeKey||`${"string"==typeof t.source?t.source:t.source.id}\0${"string"==typeof t.target?t.target:t.target.id}\0${e}`;t._edgeKey=n,this.edges.set(n,t)}const e=this._boundedPrevSnapshot;if(e&&e.size>0)for(const t of this.nodes.values()){const n=e.get(t.id);n&&(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1)}this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null,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 f=u.some(e=>void 0!==e._prevX0&&(0!==e._prevX0||0!==e._prevX1||0!==e._prevY0||0!==e._prevY1)),g=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&&g>0){const t=e[0]/2,n=e[1]/2;for(const e of this.nodes.values())e._prevX0=t,e._prevX1=t,e._prevY0=n,e._prevY1=n;for(const e of this.edges.values())e._prevY0=n,e._prevY1=n,e._prevSankeyWidth=0,e._introFromZero=!0;this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g}}else f&&g>0&&(this.restorePreviousPositions(),this.transition={startTime:performance.now(),duration:g});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,n,o,i,r,s;const a=Array.from(this.nodes.values()),l=Array.from(this.edges.values());if(this.config.customNetworkLayout){const c=aa(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:la(c),config:null!==(n=this.config.layoutConfig)&&void 0!==n?n:{}};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!==(o=d.sceneNodes)&&void 0!==o?o:[],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=Wc(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=Wc(this.config.chartType);return!!(null==e?void 0:e.supportsAnimation)&&!1!==this.config.orbitAnimated}tickAnimation(e,t){const n=Wc(this.config.chartType);if(!(null==n?void 0:n.tick))return!1;const o=Array.from(this.nodes.values()),i=Array.from(this.edges.values());return n.tick(o,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),n=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,n),e.x1=Me(e._prevX1,e._targetX1,n),e.y0=Me(e._prevY0,e._targetY0,n),e.y1=Me(e._prevY1,e._targetY1,n));for(const e of this.edges.values())void 0!==e._targetY0&&void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&(e._prevSankeyWidth>0||e._introFromZero)&&(e.y0=Me(e._prevY0,e._targetY0,n),e.y1=Me(e._prevY1,e._targetY1,n),e.sankeyWidth=Me(e._prevSankeyWidth,e._targetSankeyWidth,n));return this.rebuildAllBeziers(),1>t||(this.snapToTargets(),this.transition=null,!1)}prepareForRelayout(){const e=this._boundedPrevSnapshot;for(const t of this.nodes.values()){const n=null==e?void 0:e.get(t.id);n&&0===t.x0&&0===t.x1&&0===t.y0&&0===t.y1?(t._prevX0=n.x0,t._prevX1=n.x1,t._prevY0=n.y0,t._prevY1=n.y1):(t._prevX0=t.x0,t._prevX1=t.x1,t._prevY0=t.y0,t._prevY1=t.y1)}const t=this._boundedEdgeSnapshot;for(const e of this.edges.values()){if(t&&0===e.sankeyWidth){const n=t.get(`${"string"==typeof e.source?e.source:e.source.id}\0${"string"==typeof e.target?e.target:e.target.id}`);if(n){e._prevY0=n.y0,e._prevY1=n.y1,e._prevSankeyWidth=n.sankeyWidth;continue}}e._prevY0=e.y0,e._prevY1=e.y1,e._prevSankeyWidth=e.sankeyWidth}this.nodes.size>0&&(this._boundedPrevSnapshot=null,this._boundedEdgeSnapshot=null)}finalizeLayout(){const e="vertical"===this.config.orientation?"down":"right";for(const e of this.nodes.values())if(0!==e.x0||0!==e.x1||0!==e.y0||0!==e.y1)e.width=e.x1-e.x0,e.height=e.y1-e.y0,e.x=e.x0+e.width/2,e.y=e.y0+e.height/2;else{const t=5;e.x0=e.x-t,e.x1=e.x+t,e.y0=e.y-t,e.y1=e.y+t,e.width=2*t,e.height=2*t}for(const t of this.edges.values())t.direction=e,this.updateEdgeBezier(t);this.tension=0}saveTargetPositions(){for(const e of this.nodes.values())e._targetX0=e.x0,e._targetX1=e.x1,e._targetY0=e.y0,e._targetY1=e.y1;for(const e of this.edges.values())e._targetY0=e.y0,e._targetY1=e.y1,e._targetSankeyWidth=e.sankeyWidth}restorePreviousPositions(){for(const e of this.nodes.values())void 0===e._prevX0||0===e._prevX0&&0===e._prevX1||(e.x0=e._prevX0,e.x1=e._prevX1,e.y0=e._prevY0,e.y1=e._prevY1);for(const e of this.edges.values())void 0!==e._prevY0&&void 0!==e._prevSankeyWidth&&e._prevSankeyWidth>0&&(e.y0=e._prevY0,e.y1=e._prevY1,e.sankeyWidth=e._prevSankeyWidth);this.rebuildAllBeziers()}snapToTargets(){for(const e of this.nodes.values())void 0!==e._targetX0&&(e.x0=e._targetX0,e.x1=e._targetX1,e.y0=e._targetY0,e.y1=e._targetY1);for(const e of this.edges.values())void 0!==e._targetY0&&(e.y0=e._targetY0,e.y1=e._targetY1,e.sankeyWidth=e._targetSankeyWidth),e._introFromZero=void 0;this.rebuildAllBeziers()}updateEdgeBezier(e){const t="string"==typeof e.source?this.nodes.get(e.source):e.source,n="string"==typeof e.target?this.nodes.get(e.target):e.target;t&&n&&(e.bezier=e.circular&&e.circularPathData?this.buildCircularBezier(e):this.buildStandardBezier(e,t,n))}buildStandardBezier(e,t,n){const o=(e.sankeyWidth||1)/2;if("down"===e.direction){const i=t.x1,r=n.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:o}}const i=t.x1,r=n.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:o}}buildCircularBezier(e){const t=(e._circularWidth||e.sankeyWidth||1)/2,n=e.circularPathData;if(!n)throw Error("buildCircularBezier requires circularPathData");if(e._circularStub){const e=Math.max(15,Math.min(40,.33*(n.rightFullExtent-n.sourceX))),o=Math.max(15,Math.min(40,.33*(n.targetX-n.leftFullExtent)));return{circular:!0,segments:[[{x:n.sourceX,y:n.sourceY},{x:n.sourceX+.33*e,y:n.sourceY},{x:n.sourceX+.66*e,y:n.sourceY},{x:n.sourceX+e,y:n.sourceY}],[{x:n.targetX-o,y:n.targetY},{x:n.targetX-.66*o,y:n.targetY},{x:n.targetX-.33*o,y:n.targetY},{x:n.targetX,y:n.targetY}]],halfWidth:t}}let o;o="down"===e.direction?[{x:n.sourceY,y:n.sourceX},{x:n.sourceY,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.rightFullExtent},{x:n.verticalFullExtent,y:n.leftFullExtent},{x:n.targetY,y:n.leftFullExtent},{x:n.targetY,y:n.targetX}]:[{x:n.sourceX,y:n.sourceY},{x:n.rightFullExtent,y:n.sourceY},{x:n.rightFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.verticalFullExtent},{x:n.leftFullExtent,y:n.targetY},{x:n.targetX,y:n.targetY}];const i=[];for(let e=0;o.length-1>e;e++){const t=o[e],n=o[e+1],r=n.x-t.x,s=n.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},n])}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,n,o,i,r;const s=this.config.pulse;if(!s)return;const a=null!==(t=s.duration)&&void 0!==t?t:500,l=null!==(n=s.color)&&void 0!==n?n:"rgba(255,255,255,0.6)",c=null!==(o=s.glowRadius)&&void 0!==o?o:4;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const o=this.nodeTimestamps.get(n);if(!o)continue;const i=e-o;a>i&&(t._pulseIntensity=1-i/a,t._pulseColor=l,t._pulseGlowRadius=c)}for(const t of this.sceneEdges){const n=t.datum;if(!n)continue;const o="object"==typeof n.source?null===(i=n.source)||void 0===i?void 0:i.id:n.source,s="object"==typeof n.target?null===(r=n.target)||void 0===r?void 0:r.id:n.target;if(!o||!s)continue;const c=this.edgeTimestamps.get(`${o}\0${s}`);if(!c)continue;const u=e-c;a>u&&(t._pulseIntensity=1-u/a,t._pulseColor=l)}}applyDecay(){var e,t;const n=this.config.decay;if(!n)return;const o=this.nodeTimestamps.size;if(1>=o)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(n,a,o),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 n=e-this.lastTopologyChangeTime;if(n>=2e3)return;const o=1-n/2e3;for(const e of this.sceneNodes){const n=e.id;n&&this.addedNodes.has(n)&&(e._pulseIntensity=Math.max(null!==(t=e._pulseIntensity)&&void 0!==t?t:0,o),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,n;const o=this.config.thresholds;if(!o)return;const i=null!==(t=o.warningColor)&&void 0!==t?t:"#f59e0b",r=null!==(n=o.criticalColor)&&void 0!==n?n:"#ef4444",s=!1!==o.pulse;for(const t of this.sceneNodes){const n=t.id;if(!n)continue;const a=this.nodes.get(n);if(!a)continue;const l=o.metric(a);let c=null;void 0===o.critical||o.critical>l?void 0===o.warning||o.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 n=e.metric(t);if(void 0!==e.warning&&n>=e.warning||void 0!==e.critical&&n>=e.critical)return!0}return!1}get hasActivePulses(){var e;const t=this.config.pulse;if(!t||0===this.lastIngestTime)return!1;const n="undefined"!=typeof performance?performance.now():Date.now();return(null!==(e=t.duration)&&void 0!==e?e:500)>n-this.lastIngestTime}getLayoutData(){return{nodes:Array.from(this.nodes.values()),edges:Array.from(this.edges.values())}}updateNode(e,t){var n;const o=this.nodes.get(e);if(!o)return null;const i=o.data?Object.assign({},o.data):{};return o.data=t(null!==(n=o.data)&&void 0!==n?n:{}),this.layoutVersion++,i}updateEdge(e,t,n){var o;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=n(null!==(o=i.data)&&void 0!==o?o:{});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,n]of this.edges)("string"==typeof n.source?n.source:n.source.id)!==e&&("string"==typeof n.target?n.target:n.target.id)!==e||(this.edges.delete(t),this.edgeTimestamps.delete(t));return this.layoutVersion++,!0}removeEdge(e,t){const n=[];if(void 0===t){const t=this.config.edgeIdAccessor;if(!t)throw Error("removeEdge(edgeId) requires edgeIdAccessor to be configured. Use removeEdge(sourceId, targetId) instead.");const o="function"==typeof t?t:e=>null==e?void 0:e[t];for(const[t,i]of this.edges)i.data&&o(i.data)===e&&n.push(t)}else for(const[o,i]of this.edges)("string"==typeof i.source?i.source:i.source.id)===e&&("string"==typeof i.target?i.target:i.target.id)===t&&n.push(o);for(const e of n)this.edges.delete(e),this.edgeTimestamps.delete(e);return n.length>0&&this.layoutVersion++,n.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 Yc(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 qc(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(!Vc(e))return!1;return!0}return Vc(t.points)}function Vc(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 Xc(e,t,n,o,i=30){let r=null,s=i,a=1/0;for(const t of e){const e=Uc(t,n,o,i);if(e)if("rect"===t.type){const n=t.w*t.h;a>n&&(r=e,a=n)}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=eu(e,n,o);t&&s>t.distance&&(r=t,s=t.distance)}return r}function Uc(e,t,n,o=30){switch(e.type){case"circle":return function(e,t,n,o=30){const i=t-e.cx,r=n-e.cy,s=Math.sqrt(i*i+r*r);return s>Ve(e.r,o)?null:{type:"node",datum:e.datum,x:e.cx,y:e.cy,distance:s}}(e,t,n,o);case"rect":return function(e,t,n){const o=qe(t,n,e);return o.hit?{type:"node",datum:e.datum,x:o.cx,y:o.cy,distance:0}:null}(e,t,n);case"arc":return function(e,t,n){const o=t-e.cx,i=n-e.cy,r=Math.sqrt(o*o+i*i);if(e.innerR-2>r||r>e.outerR+2)return null;const s=Ke(Math.atan2(i,o)),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,n=(e.innerR+e.outerR)/2;return{type:"node",datum:e.datum,x:e.cx+n*Math.cos(t),y:e.cy+n*Math.sin(t),distance:0}}return null}(e,t,n);default:return null}}let Kc=null,Qc=null;function Zc(){return Qc||(Kc=document.createElement("canvas"),Kc.width=1,Kc.height=1,Qc=Kc.getContext("2d")),Qc}function Jc(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 eu(e,t,n){switch(e.type){case"bezier":return function(e,t,n){if(!e.pathD)return null;const o=Jc(e),i=Zc();if(!o||!i)return null;try{if(i.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(o,t,n);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);case"line":return function(e,t,n){const o=e.x2-e.x1,i=e.y2-e.y1,r=o*o+i*i;if(0===r)return null;let s=((t-e.x1)*o+(n-e.y1)*i)/r;s=Math.max(0,Math.min(1,s));const a=e.x1+s*o,l=e.y1+s*i,c=Math.sqrt(Math.pow(t-a,2)+Math.pow(n-l,2));return c>5?null:{type:"edge",datum:e.datum,x:a,y:l,distance:c}}(e,t,n);case"ribbon":case"curved":return function(e,t,n){if(!e.pathD)return null;const o=Jc(e),i=Zc();if(!o||!i)return null;try{if(i.isPointInPath(o,t,n))return{type:"edge",datum:e.datum,x:t,y:n,distance:0};const r=i.lineWidth;i.lineWidth=10;const s=i.isPointInStroke(o,t,n);if(i.lineWidth=r,s)return{type:"edge",datum:e.datum,x:t,y:n,distance:4}}catch(e){}return null}(e,t,n);default:return null}}function tu(t){const{width:n,height:o,totalWidth:i,totalHeight:r,margin:s,labels:a,title:l,legend:c,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f,legendPosition:g="right",legendLayout:y,foregroundGraphics:m,sceneNodes:v,annotations:b,autoPlaceAnnotations:x,svgAnnotationRules:w}=t,k=p.useMemo(()=>{const e=(v||[]).flatMap(e=>{const t=function(e){var t,n,o,i;const r=null!==(t=e.cx)&&void 0!==t?t:null!=e.x&&null!=e.w?e.x+e.w/2:e.x,s=null!==(n=e.cy)&&void 0!==n?n:null!=e.y&&null!=e.h?e.y+e.h/2:e.y;return"number"!=typeof r||"number"!=typeof s?null:{x:r,y:s,r:"number"==typeof e.r?Math.max(1,e.r):"number"==typeof e.outerR?Math.max(1,e.outerR):Math.max(1,null!==(o=e.w)&&void 0!==o?o:0,null!==(i=e.h)&&void 0!==i?i:0)/2}}(e),n=function(e){var t,n,o,i,r,s,a,l;const c=null!==(s=null!==(o=null!==(t=e.id)&&void 0!==t?t:null===(n=e.datum)||void 0===n?void 0:n.id)&&void 0!==o?o:null===(r=null===(i=e.datum)||void 0===i?void 0:i.data)||void 0===r?void 0:r.id)&&void 0!==s?s:null===(l=null===(a=e.datum)||void 0===a?void 0:a.data)||void 0===l?void 0:l.name;return null==c?void 0:c+""}(e);return t?[Object.assign({pointId:n},t)]:[]});return{scales:null,width:n,height:o,frameType:"network",pointNodes:e,sceneNodes:v}},[o,v,n]),A=p.useMemo(()=>b&&x?Tn(Object.assign({annotations:b,context:k},"object"==typeof x?x:{})):b,[b,x,k]),j=A?ln(A.reduce((t,n,o)=>{if("widget"===n.type||!w)return t;const i=w(n,o,k);return i&&t.push({node:e.jsx(p.Fragment,{children:i},"annotation-"+o),annotation:n}),t},[])):null,S=!0===(null==A?void 0:A.some(e=>"widget"===e.type&&!0===e._annotationDeferred));return e.jsxs(e.Fragment,{children:[S&&e.jsx("style",{children:nn},"annotation-widget-disclosure-style"),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,n)=>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-"+n)),j,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,Et({legend:c,totalWidth:i,totalHeight:r,margin:s,legendPosition:g,title:l,legendLayout:y,legendHoverBehavior:u,legendClickBehavior:d,legendHighlightedCategory:h,legendIsolatedCategories:f})]}),null==A?void 0:A.filter(e=>"widget"===e.type&&e.nodeId&&v).map((t,n)=>{var o,i,r,a,l,c,u,d,h;const f=!0===t._annotationDeferred,g=v.find(e=>{var n,o,i,r,s;return e.id===t.nodeId||(null===(n=e.datum)||void 0===n?void 0:n.id)===t.nodeId||(null===(i=null===(o=e.datum)||void 0===o?void 0:o.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 p=s.left+(null!==(o=g.cx)&&void 0!==o?o:null!=g.x&&null!=g.w?g.x+g.w/2:null!==(i=g.x)&&void 0!==i?i:0),y=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),m=null!==(l=t.dx)&&void 0!==l?l:0,b=null!==(c=t.dy)&&void 0!==c?c:-16,x=null!==(u=t.width)&&void 0!==u?u:32,w=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",{className:f?"annotation-deferred":void 0,"data-annotation-disclosure":f?"deferred":void 0,style:{position:"absolute",left:p+m-x/2,top:y+b-w/2,width:x,height:w,display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:k},"widget-"+n)})]})}function nu(e){return e._cachedPath2D&&e._cachedPath2DSource===e.pathD||(e._cachedPath2D=new Path2D(e.pathD),e._cachedPath2DSource=e.pathD),e._cachedPath2D}function ou(e,t){var n,o,i,r,s,a;if(!t.pathD)return;e.save();const l=nu(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!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.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 iu(e,t){var n,o;e.save();const i=t.style.stroke||"#999";e.strokeStyle=rt(e,i)||i,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n: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!==(o=t.style.strokeWidth)&&void 0!==o?o: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 ru(e,t){var n,o,i,r;if(!t.pathD)return;e.save();const s=nu(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!==(o=null!==(n=t.style.fillOpacity)&&void 0!==n?n:t.style.opacity)&&void 0!==o?o:.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 su(e,t){var n,o;if(!t.pathD)return;e.save();const i=nu(t),r=t.style.stroke||"#999";e.strokeStyle=rt(e,r)||r,e.lineWidth=null!==(n=t.style.strokeWidth)&&void 0!==n?n: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!==(o=t.style.fillOpacity)&&void 0!==o?o:.1,e.fill(i)),e.restore()}tu.displayName="NetworkSVGOverlay";const au={top:20,right:80,bottom:20,left:80},lu={top:40,right:40,bottom:40,left:40},cu=new Set(["chord","force","circlepack","orbit"]),uu=[800,600],du={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 hu({data:t}){var n,o,i,r,s,a;if("edge"===t.nodeOrEdge){const n=t.data;return n?e.jsxs("div",{className:"semiotic-tooltip",style:du,children:[e.jsxs("div",{style:{fontWeight:600},children:["object"==typeof n.source?n.source.id:n.source," → ","object"==typeof n.target?n.target.id:n.target]}),null!=n.value&&e.jsxs("div",{style:{marginTop:4,opacity:.8},children:["Value:"," ","number"==typeof n.value?n.value.toLocaleString():n.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!==(o=null===(n=s.data)||void 0===n?void 0:n.name)&&void 0!==o?o: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:du,children:[e.jsx("div",{children:t.map((t,n)=>e.jsxs("span",{children:[n>0&&e.jsx("span",{style:{margin:"0 3px",opacity:.5},children:" → "}),n===a?e.jsx("strong",{children:t}):e.jsx("span",{style:{opacity:.7},children:t})]},n))}),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:du,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()})`]})]})}hu.ownsChrome=!0;const fu=t.forwardRef(function(n,o){var i,r,a,l,c,u,d,h,f,g,p,y,m,b,x,w,k,A;const{chartType:j,nodes:C,edges:O,data:M,initialEdges:P,nodeIDAccessor:_="id",sourceAccessor:L="source",targetAccessor:T="target",valueAccessor:N="value",edgeIdAccessor:R,childrenAccessor:$,hierarchySum:D,orientation:B="horizontal",nodeAlign:I="justify",nodePaddingRatio:E=.05,nodeWidth:F=15,iterations:H=300,forceStrength:z=.1,padAngle:W=.01,groupWidth:G=20,sortGroups:Y,edgeSort:q,treeOrientation:V="vertical",edgeType:X="curve",padding:U,paddingTop:K,tensionConfig:Q,showParticles:Z=!1,particleStyle:J,nodeStyle:ee,edgeStyle:te,colorBy:ne,colorScheme:oe="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=uu,responsiveWidth:fe,responsiveHeight:ge,margin:pe,className:ye,background:ve,enableHover:be=!0,tooltipContent:xe,customHoverBehavior:we,customClickBehavior:ke,onObservation:Ae,chartId:je,onTopologyChange:Se,annotations:Ce,autoPlaceAnnotations:Oe,svgAnnotationRules:Me,legend:Pe,legendPosition:_e,legendLayout:Le,legendHoverBehavior:Te,legendClickBehavior:Ne,legendHighlightedCategory:Re,legendIsolatedCategories:$e,title:De,foregroundGraphics:Be,backgroundGraphics:Ie,decay:Ee,pulse:Fe,transition:He,animate:ze,staleness:We,thresholds:Ge,accessibleTable:qe=!0,description:Ve,summary:Xe,orbitMode:Ue,orbitSize:Ke,orbitSpeed:Qe,orbitRevolution:Ze,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:nt,customNetworkLayout:ot,layoutConfig:it}=n,st=cu.has(j)?lu:au,at=t.useRef(!0),lt=ai({sizeProp:he,responsiveWidth:fe,responsiveHeight:ge,userMargin:pe,marginDefault:st,foregroundGraphics:Be,backgroundGraphics:Ie,animate:ze,transitionProp:He,themeDirtyRef:at}),{reducedMotionRef:ct,responsiveRef:ut,size:dt,margin:ht,adjustedWidth:ft,adjustedHeight:gt,resolvedForeground:pt,resolvedBackground:yt,transition:mt,introEnabled:vt,tableId:bt,rafRef:xt,renderFnRef:wt,scheduleRender:kt,currentTheme:Ct}=lt,Mt=co(),_t=go(),Lt=t.useMemo(()=>v(C),[C]),Tt=t.useMemo(()=>Array.isArray(O)?v(O):O,[O]),Nt=t.useMemo(()=>Object.assign(Object.assign({},Al),Q),[Q]),Rt=t.useMemo(()=>Object.assign(Object.assign({},jl),J),[J]),$t=t.useMemo(()=>{var e;return{chartType:j,nodeIDAccessor:_,sourceAccessor:L,targetAccessor:T,valueAccessor:N,edgeIdAccessor:R,childrenAccessor:$,hierarchySum:D,orientation:B,nodeAlign:I,nodePaddingRatio:E,nodeWidth:F,iterations:H,forceStrength:z,padAngle:W,groupWidth:G,sortGroups:Y,edgeSort:q,treeOrientation:V,edgeType:X,padding:U,paddingTop:K,tensionConfig:Nt,showParticles:Z,particleStyle:Rt,nodeStyle:ee,edgeStyle:te,nodeLabel:ce,showLabels:ue,labelMode:de,colorBy:ne,colorScheme:oe,themeCategorical:null===(e=null==Ct?void 0:Ct.colors)||void 0===e?void 0:e.categorical,themeSemantic:S(Ct),edgeColorBy:ie,edgeOpacity:re,colorByDepth:se,nodeSize:ae,nodeSizeRange:le,decay:Ee,pulse:Fe,transition:mt,introAnimation:vt,staleness:We,thresholds:Ge,orbitMode:Ue,orbitSize:Ke,orbitSpeed:Qe,orbitRevolution:Ze,orbitRevolutionStyle:Je,orbitEccentricity:et,orbitShowRings:tt,orbitAnimated:nt,customNetworkLayout:ot,layoutConfig:it}},[j,_,L,T,N,$,D,B,I,E,F,H,z,W,G,Y,q,V,X,U,K,Nt,Z,Rt,ee,te,ce,ue,de,ne,oe,ie,re,se,ae,le,Ee,Fe,null==mt?void 0:mt.duration,null==mt?void 0:mt.easing,vt,We,Ge,Ue,Ke,Qe,Ze,Je,et,tt,nt,Ct,ot,it]),Dt=yo($t),Bt=yo({chartType:j,nodeIDAccessor:_,sourceAccessor:L,targetAccessor:T,valueAccessor:N,childrenAccessor:$,hierarchySum:D,orientation:B,nodeAlign:I,nodePaddingRatio:E,nodeWidth:F,iterations:H,forceStrength:z,padAngle:W,groupWidth:G,sortGroups:Y,edgeSort:q,treeOrientation:V,edgeType:X,padding:U,paddingTop:K,tensionConfig:Nt,orbitMode:Ue,orbitSize:Ke,orbitEccentricity:et,customNetworkLayout:ot,layoutConfig:it}),It=t.useRef(null),Et=t.useRef(0),Ft=t.useRef(0),Ht=t.useRef(!1),zt=t.useRef(null);zt.current||(zt.current=new Gc(Dt));const[Wt,Gt]=t.useState(null),[Yt,qt]=t.useState(0),[Vt,Xt]=t.useState(0),[Ut,Kt]=t.useState(!1),[Qt,Zt]=t.useState(null),Jt=t.useRef(null),en=t.useRef(new Map),tn=t.useRef(0),nn=t.useCallback(e=>{if("function"==typeof ne)return ne(e)+"";if("string"==typeof ne&&e.data){const t=e.data[ne];if(void 0!==t){if(!en.current.has(t+"")){const e=Array.isArray(oe)?oe:me;en.current.set(t+"",e[tn.current++%e.length])}return en.current.get(t+"")}}if(en.current.has(e.id))return en.current.get(e.id);const t=Array.isArray(oe)?oe:me,n=ne?t[tn.current++%t.length]:t[0];return en.current.set(e.id,n),n},[ne,oe]),on=(null===(i=null==Ct?void 0:Ct.colors)||void 0===i?void 0:i.border)||(null===(r=null==Ct?void 0:Ct.colors)||void 0===r?void 0:r.secondary)||(null===(a=null==Ct?void 0:Ct.colors)||void 0===a?void 0:a.primary)||"#999",rn=t.useCallback(e=>{var t,n;return e?"object"==typeof e?e:null!==(n=null===(t=zt.current)||void 0===t?void 0:t.nodes.get(e))&&void 0!==n?n:null:null},[]),sn=t.useCallback(e=>{if("function"==typeof ie)return ie(e);const t=rn(e.source),n=rn(e.target);return"target"===ie&&n?nn(n):t?nn(t):on},[ie,nn,on,rn]),an=t.useCallback(e=>{if("function"==typeof Rt.color){const t=rn(e.source);return t?Rt.color(e,t):on}if(!(null==J?void 0:J.colorBy))return sn(e);const t=Rt.colorBy,n=rn(e.source),o=rn(e.target);return"target"===t&&o?nn(o):n?nn(n):on},[null==J?void 0:J.colorBy,Rt.color,Rt.colorBy,nn,sn,on,rn]),ln=("sankey"===j||!!ot)&&Z||!!Fe||null!==(c=null===(l=zt.current)||void 0===l?void 0:l.isAnimating)&&void 0!==c&&c;t.useEffect(()=>{var e;null===(e=zt.current)||void 0===e||e.updateConfig(Dt),at.current=!0,kt()},[Dt,kt]);const cn=t.useCallback(()=>{var e,t;Zt(null!==(t=null===(e=zt.current)||void 0===e?void 0:e.customLayoutOverlays)&&void 0!==t?t:null)},[]);t.useEffect(()=>{var e;const t=zt.current;if(t){t.buildScene([ft,gt]),cn();for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&en.current.set(n.id,n.style.fill);at.current=!0,kt()}},[Ct,ft,gt,kt,cn]);const un=t.useCallback(()=>{var e;const t=zt.current;if(!t)return;t.runLayout([ft,gt]),t.buildScene([ft,gt]),cn(),at.current=!0;for(const n of t.sceneNodes)n.id&&"string"==typeof(null===(e=n.style)||void 0===e?void 0:e.fill)&&en.current.set(n.id,n.style.fill);const n=Array.isArray(oe)?oe:me,o=Array.from(t.nodes.values());for(let e=0;o.length>e;e++){const t=o[e];en.current.has(t.id)||en.current.set(t.id,n[e%n.length])}if(tn.current=o.length,qt(t.layoutVersion),Se){const{nodes:e,edges:n}=t.getLayoutData();Se(e,n)}},[ft,gt,Se,oe,cn]),dn=t.useCallback(e=>{if(null==e||"object"!=typeof e)return;const t=zt.current;t&&(t.ingestEdge(e)&&un(),kt())},[un,kt]),hn=t.useCallback(e=>{const t=zt.current;if(!t)return;let n=!1;for(const o of e)null!=o&&"object"==typeof o&&t.ingestEdge(o)&&(n=!0);n&&un(),kt()},[un,kt]),fn=t.useCallback(()=>{var e;null===(e=zt.current)||void 0===e||e.clear(),en.current.clear(),tn.current=0,qt(0),Gt(null),Jt.current=null,at.current=!0,kt()},[kt]),gn=t.useCallback(()=>{const e=zt.current;e&&(e.tension+=999,un(),kt())},[un,kt]);t.useImperativeHandle(o,()=>({push:dn,pushMany:hn,removeNode:e=>{var t,n,o;const i=null!==(n=null===(t=zt.current)||void 0===t?void 0:t.removeNode(e))&&void 0!==n&&n;if(i){const t=(null===(o=Jt.current)||void 0===o?void 0:o.data)?"function"==typeof _?_(Jt.current.data):Jt.current.data[_]:void 0;Jt.current&&"node"===Jt.current.nodeOrEdge&&t===e&&(Jt.current=null,Gt(null)),en.current.delete(e),un(),at.current=!0,kt()}return i},removeEdge:(e,t)=>{var n,o;const i=null!==(o=null===(n=zt.current)||void 0===n?void 0:n.removeEdge(e,t))&&void 0!==o&&o;if(i){if(Jt.current&&"edge"===Jt.current.nodeOrEdge){const n=Jt.current.data;let o;o=void 0!==t?("object"==typeof(null==n?void 0:n.source)?n.source.id:null==n?void 0:n.source)===e&&("object"==typeof(null==n?void 0:n.target)?n.target.id:null==n?void 0:n.target)===t:!R||!n||("function"==typeof R?R:e=>null==e?void 0:e[R])(n)===e,o&&(Jt.current=null,Gt(null))}un(),at.current=!0,kt()}return i},updateNode:(e,t)=>{var n,o;const i=null!==(o=null===(n=zt.current)||void 0===n?void 0:n.updateNode(e,t))&&void 0!==o?o:null;return i&&(at.current=!0,kt()),i},updateEdge:(e,t,n)=>{var o,i;const r=null!==(i=null===(o=zt.current)||void 0===o?void 0:o.updateEdge(e,t,n))&&void 0!==i?i:[];return r.length>0&&(un(),at.current=!0,kt()),r},clear:fn,getTopology:()=>{var e,t;return null!==(t=null===(e=zt.current)||void 0===e?void 0:e.getLayoutData())&&void 0!==t?t:{nodes:[],edges:[]}},getTopologyDiff:()=>{const e=zt.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:gn,getTension:()=>{var e,t;return null!==(t=null===(e=zt.current)||void 0===e?void 0:e.tension)&&void 0!==t?t:0}}),[dn,hn,fn,gn,un,kt]);const pn=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),yn=pn?M||(Array.isArray(O)?void 0:O):void 0;t.useEffect(()=>{var e;const t=zt.current;if(t)if(pn&&yn)t.ingestHierarchy(yn,[ft,gt]),t.buildScene([ft,gt]),cn(),at.current=!0,kt();else{const n=Lt,o=Array.isArray(Tt)?Tt:[];if(0===n.length&&0===o.length)return;t.ingestBounded(n,o,[ft,gt]),t.buildScene([ft,gt]),cn();for(const n of t.sceneNodes)n.id&&(null===(e=n.style)||void 0===e?void 0:e.fill)&&en.current.set(n.id,n.style.fill+"");const i=Array.isArray(oe)?oe:me,r=Array.from(t.nodes.values());for(let e=0;r.length>e;e++){const t=r[e];en.current.has(t.id)||en.current.set(t.id,i[e%i.length])}tn.current=r.length,at.current=!0,kt()}},[Lt,Tt,M,yn,pn,ft,gt,Bt,kt,oe,cn]),t.useEffect(()=>{P&&P.length>0&&hn(P)},[]);const mn=t.useCallback(e=>{if(we&&we(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})}},[we,Ae,je]),vn=t.useCallback(e=>{if(ke&&ke(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})}},[ke,Ae,je]),{hoverHandlerRef:bn,hoverLeaveRef:xn,onPointerMove:wn,onPointerLeave:kn}=lt;bn.current=e=>{if(!be)return;const t=It.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-ht.left,i=e.clientY-n.top-ht.top;if(0>o||o>ft||0>i||i>gt)return void(Jt.current&&(Jt.current=null,Gt(null),mn&&(mn(null),at.current=!0),kt()));const r=zt.current;if(!r)return;const s=Xc(r.sceneNodes,r.sceneEdges,o,i);if(!s)return void(Jt.current&&(Jt.current=null,Gt(null),mn&&(mn(null),at.current=!0),kt()));const a=Xo(s.datum||{},s.x,s.y,{nodeOrEdge:s.type});Jt.current=a,Gt(a),mn&&(mn(a),at.current=!0),kt()},xn.current=()=>{Jt.current&&(Jt.current=null,Gt(null),mn&&(mn(null),at.current=!0),kt())};const An=t.useRef(()=>{});An.current=e=>{if(!ke&&!Ae)return;const t=It.current;if(!t)return;const n=t.getBoundingClientRect(),o=e.clientX-n.left-ht.left,i=e.clientY-n.top-ht.top;if(0>o||o>ft||0>i||i>gt)return;const r=zt.current;if(!r)return;const s=Xc(r.sceneNodes,r.sceneEdges,o,i);vn(s?Xo(s.datum||{},s.x,s.y,{nodeOrEdge:s.type}):null)};const jn=t.useCallback(e=>An.current(e),[]),Sn=t.useRef(-1),Cn=t.useRef(null),On=t.useRef(-1),Mn=t.useCallback(e=>{var t;const n=zt.current;if(!n)return;const o=function(e){var t,n,o,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!==(n=null===(t=l.datum)||void 0===t?void 0:t.id)&&void 0!==n?n:"_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===(o=l.datum)||void 0===o?void 0:o.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}(n.sceneNodes);if(0===o.length)return;const i=At(o),r=Sn.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(),Sn.current=0,On.current=-1;const t=i.flat[0];Cn.current={shape:t.shape,w:t.w,h:t.h};const n=Xo(t.datum||{},t.x,t.y,{nodeOrEdge:"node"});return Jt.current=n,Gt(n),mn&&(mn(n),at.current=!0),void kt()}const s=jt(i,r),a=function(e,t,n,o,i){var r,s,a;const l=n.flat[t.flatIndex];if(!l)return St(e,t,n);const c=null===(r=l.datum)||void 0===r?void 0:r.id;switch(e){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":{const o=null!==(s=function(e,t,n){let o=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(n){case"right":c=a>0&&Math.abs(a)>=Math.abs(l);break;case"left":c=0>a&&Math.abs(a)>=Math.abs(l);break;case"down":c=l>0&&Math.abs(l)>=Math.abs(a);break;case"up":c=0>l&&Math.abs(l)>=Math.abs(a)}if(!c)continue;const u=a*a+l*l;i>u&&(i=u,o=r)}return o}(n,l,"ArrowRight"===e?"right":"ArrowLeft"===e?"left":"ArrowDown"===e?"down":"up"))&&void 0!==s?s:t.flatIndex;return o!==t.flatIndex&&(i.current=-1),o}case"Enter":{if(null==c)return t.flatIndex;const e=function(e,t){var n;const o=e+"",i=[];for(const e of t){const t=null!==(n=e.datum)&&void 0!==n?n:e,r=Ot(t.source),s=Ot(t.target),a=null!=r,l=null!=s;a&&r+""===o&&l?i.push(s+""):l&&s+""===o&&a&&i.push(r+"")}return i}(c,o);if(0===e.length)return t.flatIndex;const r=null!==(a=n.idToIdx.get(e[(i.current+1)%e.length]))&&void 0!==a?a:-1;return 0>r?t.flatIndex:(i.current=-1,r)}default:{const o=St(e,t,n);return null!==o&&o!==t.flatIndex&&(i.current=-1),o}}}(e.key,s,i,null!==(t=n.sceneEdges)&&void 0!==t?t:[],On);if(null===a)return;if(e.preventDefault(),0>a)return Sn.current=-1,Cn.current=null,On.current=-1,Jt.current=null,Gt(null),mn&&(mn(null),at.current=!0),void kt();Sn.current=a;const l=i.flat[a];Cn.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"};Jt.current=c,Gt(c),mn&&(mn(c),at.current=!0),kt()},[mn,kt]),Pn=t.useCallback(e=>{Sn.current=-1,Cn.current=null,wn(e)},[wn]);wt.current=()=>{var e,t,n,o,i,r,s;xt.current=0;const a=It.current;if(!a)return;const l=a.getContext("2d");if(!l)return;const c=zt.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(ct.current?u+1e6:u),f=!ct.current&&h,g=!ct.current&&c.tickAnimation([ft,gt],d);(h||at.current||g)&&c.buildScene([ft,gt]);const p=ci();if(!li(a,dt,ht,p))return;if(l.clearRect(-ht.left,-ht.top,dt[0],dt[1]),ve){const e=rt(l,ve);e&&(l.fillStyle=e,l.fillRect(0,0,ft,gt))}Ee&&c.applyDecay(),Fe&&c.applyPulse(u),Ge&&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 n of t)switch(n.type){case"bezier":ou(e,n);break;case"line":iu(e,n);break;case"ribbon":ru(e,n);break;case"curved":su(e,n)}}(l,c.sceneEdges),function(e,t){var n,o,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!==(n=t.style.opacity)&&void 0!==n?n: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!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.strokeRect(t.x,t.y,t.w,t.h)),gi(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,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!==(n=t.style.opacity)&&void 0!==n?n: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!==(o=t.style.strokeWidth)&&void 0!==o?o:1,e.globalAlpha=null!==(i=t.style.opacity)&&void 0!==i?i:1,e.stroke()),pi(e,t),e.restore())}}(l,c.sceneNodes),function(e,t){var n,o,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!==(n=t.style.opacity)&&void 0!==n?n: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!==(o=t.style.strokeWidth)&&void 0!==o?o: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,n,o){var i,r;const s=null!==(i=o.spawnRate)&&void 0!==i?i:jl.spawnRate,a=null!==(r=o.maxPerEdge)&&void 0!==r?r:jl.maxPerEdge;for(let o=0;t.length>o;o++){const i=t[o];if(!i.bezier)continue;if(e.countForEdge(o)>=a)continue;const r=i.value*s*n*(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(o)<a;t++)e.spawn(o)}}(c.particlePool,e,d,Rt);const t=.5*(null!==(n=Rt.speedMultiplier)&&void 0!==n?n:1);let o;if(Rt.proportionalSpeed){const t=e.reduce((e,t)=>Math.max(e,t.value||1),1);o=e.map(e=>.3+(e.value||1)/t*1.7)}c.particlePool.step(d,t,e,o),function(e,t,n,o,i){var r,s;const a=null!==(r=o.radius)&&void 0!==r?r:jl.radius,l=null!==(s=o.opacity)&&void 0!==s?s:jl.opacity;e.globalAlpha=l;for(let r=0;t.particles.length>r;r++){const s=t.particles[r];if(!s.active)continue;const l=n[s.edgeIndex];if(!l)continue;let c;c="string"==typeof o.color&&"inherit"!==o.color?o.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,an)}}m&&(l.globalAlpha=1);const v=at.current;if(at.current=!1,v||f||g){const e=It.current;e&&e.setAttribute("aria-label",So(null!==(i=null===(o=c.sceneNodes)||void 0===o?void 0:o.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||f||g||Ht.current;b&&u-Ft.current>=33?(Xt(e=>e+1),Ft.current=u,Ht.current=!1):Ht.current=!!b,(ln||f||null!=c.transition||g||c.hasActivePulses||c.hasActiveThresholds||c.hasActiveTopologyDiff||Ht.current)&&(xt.current=requestAnimationFrame(()=>wt.current()))},po({hydrated:Mt,wasHydratingFromSSR:_t,storeRef:zt,dirtyRef:at,renderFnRef:wt}),t.useEffect(()=>{at.current=!0,kt()},[j,ft,gt,ve,kt]),Pt(We,zt,at,kt,Ut,Kt);const _n=be&&Wt?e.jsx(ti,{x:Wt.x,y:Wt.y,containerWidth:ft,containerHeight:gt,margin:ht,className:"stream-network-tooltip",zIndex:2,children:xe?xe(Wt):e.jsx(hu,{data:Wt})}):null;if(ao||!Mt&&_t){const t=zt.current;if(t){const e=["tree","cluster","treemap","circlepack","partition","orbit"].includes(j),n=e?M||(Array.isArray(O)?void 0:O):void 0;if(e&&n)t.ingestHierarchy(n,[ft,gt]),t.buildScene([ft,gt]);else{const e=Lt,n=Array.isArray(Tt)?Tt:[];(e.length>0||n.length>0)&&(t.ingestBounded(e,n,[ft,gt]),t.buildScene([ft,gt]))}}const n=null!==(u=null==t?void 0:t.sceneNodes)&&void 0!==u?u:[],o=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:ut,className:"stream-network-frame"+(ye?" "+ye:""),role:"img","aria-label":Ve||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:fe?"100%":dt[0],height:ge?"100%":dt[1]},children:[e.jsx(zo,{summary:Xe}),e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:dt[0],height:dt[1],style:{position:"absolute",left:0,top:0},children:[yt&&e.jsx("g",{transform:`translate(${ht.left},${ht.top})`,children:yt}),e.jsxs("g",{transform:`translate(${ht.left},${ht.top})`,children:[ve&&e.jsx("rect",{x:0,y:0,width:ft,height:gt,fill:ve}),o.map((t,n)=>function(t,n){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-"+n);case"bezier":{const o=t;return e.jsx("path",{d:o.pathD,fill:ro(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"ribbon":{const o=t;return e.jsx("path",{d:o.pathD,fill:ro(o.style.fill,"#999"),fillOpacity:o.style.fillOpacity,stroke:o.style.stroke||"none",strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-edge-"+n)}case"curved":{const o=t;return e.jsx("path",{d:o.pathD,fill:ro(o.style.fill,"none"),stroke:o.style.stroke||"#999",strokeWidth:o.style.strokeWidth||1,opacity:o.style.opacity},"net-edge-"+n)}default:return null}}(t,n)).filter(Boolean),n.map((t,n)=>function(t,n){switch(t.type){case"circle":{const o=t;return e.jsx("circle",{cx:o.cx,cy:o.cy,r:o.r,fill:ro(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-circle-"+n)}case"rect":{const o=t;return e.jsx("rect",{x:o.x,y:o.y,width:o.w,height:o.h,fill:ro(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-rect-"+n)}case"arc":{const o=t,i=s.arc().innerRadius(o.innerR).outerRadius(o.outerR).startAngle(o.startAngle+Math.PI/2).endAngle(o.endAngle+Math.PI/2)(io)||"";return e.jsx("path",{d:i,transform:`translate(${o.cx},${o.cy})`,fill:ro(o.style.fill),stroke:o.style.stroke,strokeWidth:o.style.strokeWidth,opacity:o.style.opacity},"net-arc-"+n)}default:return null}}(t,n)).filter(Boolean),i.map((t,n)=>function(t,n){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-"+n)}(t,n)).filter(Boolean)]})]}),e.jsx(tu,{width:ft,height:gt,totalWidth:dt[0],totalHeight:dt[1],margin:ht,labels:i,sceneNodes:n,title:De,legend:Pe,legendPosition:_e,legendLayout:Le,legendHoverBehavior:Te,legendClickBehavior:Ne,legendHighlightedCategory:Re,legendIsolatedCategories:$e,foregroundGraphics:Ye(pt,null===(f=zt.current)||void 0===f?void 0:f.customLayoutOverlays),annotations:Ce,autoPlaceAnnotations:Oe,svgAnnotationRules:Me,annotationFrame:0})]})}const Ln=zt.current;return e.jsxs("div",{ref:ut,className:"stream-network-frame"+(ye?" "+ye:""),role:"group","aria-label":Ve||("string"==typeof De?De:"Network chart"),tabIndex:0,style:{position:"relative",width:fe?"100%":dt[0],height:ge?"100%":dt[1],overflow:"visible"},onKeyDown:Mn,children:[qe&&e.jsx(Wo,{tableId:bt}),qe&&e.jsx(Ho,{nodes:null!==(g=null==Ln?void 0:Ln.sceneNodes)&&void 0!==g?g:[],edges:null!==(p=null==Ln?void 0:Ln.sceneEdges)&&void 0!==p?p:[],chartType:"Network chart",tableId:bt,chartTitle:"string"==typeof De?De:void 0}),e.jsx(zo,{summary:Xe}),e.jsx(Go,{hoverPoint:Wt}),e.jsxs("div",{role:"img","aria-label":Ve||("string"==typeof De?De:"Network chart"),style:{position:"relative",width:"100%",height:"100%"},onMouseMove:be?Pn:void 0,onMouseLeave:be?kn:void 0,onClick:ke||Ae?jn:void 0,children:[yt&&e.jsx("svg",{overflow:"visible",style:{position:"absolute",top:0,left:0,width:dt[0],height:dt[1],pointerEvents:"none",overflow:"visible"},children:e.jsx("g",{transform:`translate(${ht.left},${ht.top})`,children:yt})}),e.jsx("canvas",{ref:It,"aria-label":So(null!==(m=null===(y=null==Ln?void 0:Ln.sceneNodes)||void 0===y?void 0:y.length)&&void 0!==m?m:0,null!==(x=null===(b=null==Ln?void 0:Ln.sceneEdges)||void 0===b?void 0:b.length)&&void 0!==x?x:0,"Network chart"),style:{position:"absolute",top:0,left:0}}),e.jsx(tu,{width:ft,height:gt,totalWidth:dt[0],totalHeight:dt[1],margin:ht,labels:(null==Ln?void 0:Ln.labels)||[],sceneNodes:null==Ln?void 0:Ln.sceneNodes,title:De,legend:Pe,legendPosition:_e,legendLayout:Le,legendHoverBehavior:Te,legendClickBehavior:Ne,legendHighlightedCategory:Re,legendIsolatedCategories:$e,foregroundGraphics:Ye(pt,Qt),annotations:Ce,autoPlaceAnnotations:Oe,svgAnnotationRules:Me,annotationFrame:Vt}),e.jsx(qo,{active:Sn.current>=0,hoverPoint:Wt,margin:ht,size:dt,shape:null===(w=Cn.current)||void 0===w?void 0:w.shape,width:null===(k=Cn.current)||void 0===k?void 0:k.w,height:null===(A=Cn.current)||void 0===A?void 0:A.h}),_n,(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:Ut?"#dc3545":"#28a745",color:"white",fontSize:10,fontWeight:700,padding:"2px 6px",borderRadius:3,letterSpacing:"0.05em",zIndex:3,pointerEvents:"none"}),children:Ut?"STALE":"LIVE"})]})]})});function gu(e,t){if(!e)return[];const n=[],o=e=>{n.push(e);const i="function"==typeof t?t(e):e[t];i&&Array.isArray(i)&&i.forEach(o)};return o(e),n}function pu(e,t,n,o){if(e&&e.length>0)return e;const i=new Set;return t.forEach(e=>{const t="function"==typeof n?n(e):e[n],r="function"==typeof o?o(e):e[o];i.add(t),i.add(r)}),Array.from(i).map(e=>({id:e}))}function yu(e){return"function"==typeof e?e:t=>t[e]||1}function mu({edgeColorBy:e,colorBy:t,colorScale:n,nodeStyleFn:o,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=we(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else if("target"===e){const e="object"==typeof s.target?s.target:null;t&&e?a.fill=we(e.data||e,t,n):e&&(a.fill=o(e,e.index).fill)}else"gradient"===e&&(a.fill="#999",a.fillOpacity=.7*i);return a}}function vu(e){const{nodes:n,edges:o,inferNodes:i=!0,sourceAccessor:r="source",targetAccessor:s="target",colorBy:a,colorScheme:l,showLegend:c,legendPosition:u,legendInteraction:d,selection:h,linkedHover:f,onObservation:g,onClick:p,chartType:y,chartId:m,marginDefaults:b,userMargin:x,width:w,height:k,loading:A,loadingContent:j,emptyContent:S,emptyDataKey:C="edges"}=e,O=t.useMemo(()=>v(o),[o]),M=t.useMemo(()=>v(n),[n]),P=Qr(A,w,k,j),_=P?null:Kr("nodes"===C?void 0===n?void 0:M:void 0===o?void 0:O,w,k,S),L=t.useMemo(()=>i?pu(M,O,r,s):M,[i,M,O,r,s]),T=Or(L,a,l),N=Sr(),R=t.useMemo(()=>{if(Array.isArray(l))return l;if(N&&N.length>0)return N;if("string"==typeof l){const e=ye[l];if(Array.isArray(e)&&e.length>0)return e}return me},[l,N]),$=t.useMemo(()=>{if(!a)return[];const e=new Set;for(const t of L){const n="function"==typeof a?a(t):t[a];null!=n&&e.add(n+"")}return Array.from(e)},[L,a]),D=Tr(d,a,$),{legend:B,margin:I,legendPosition:E}=Lr({data:L,colorBy:a,colorScale:T,showLegend:c,legendPosition:u,userMargin:x,defaults:b,categories:$}),F=Pr({selection:h,linkedHover:f,fallbackFields:a?["string"==typeof a?a:""]:[],unwrapData:!0,onObservation:g,onClick:p,chartType:y,chartId:m}),{customHoverBehavior:H,customClickBehavior:z,activeSelectionHook:W,hoverSelectionHook:G,crosshairSourceId:Y}=F;return{safeNodes:L,safeEdges:O,colorScale:T,effectivePalette:R,themeCategorical:N,allCategories:$,legendState:D,legend:B,margin:I,legendPosition:E,customHoverBehavior:H,customClickBehavior:z,activeSelectionHook:W,hoverSelectionHook:G,crosshairSourceId:Y,loadingEl:P,emptyEl:_}}fu.displayName="StreamNetworkFrame";const bu=t.forwardRef(function(n,o){var i;const r=t.useRef(null);us(o,{variant:"network",frameRef:r});const s=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLegend:n.showLegend,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{nodes:a,edges:l,margin:c,className:u,nodeIdAccessor:d,nodeIDAccessor:h,sourceAccessor:f="source",targetAccessor:g="target",nodeLabel:p,colorBy:y,colorScheme:m,nodeSize:v=8,nodeSizeRange:b=[5,20],edgeWidth:x=1,edgeColor:w="#999",edgeOpacity:k=.6,iterations:A=300,forceStrength:j=.1,tooltip:S,frameProps:C={},onObservation:O,onClick:M,chartId:P,selection:_,linkedHover:L,loading:T,loadingContent:N,emptyContent:R,legendInteraction:$,legendPosition:D,stroke:B,strokeWidth:I,opacity:E}=n,F=null!==(i=null!=d?d:h)&&void 0!==i?i:"id",{width:H,height:z,enableHover:W,showLegend:G,showLabels:Y=!1,title:q,description:V,summary:X,accessibleTable:U}=s,K=vu({nodes:a,edges:l,inferNodes:!1,sourceAccessor:f,targetAccessor:g,colorBy:y,colorScheme:m,showLegend:G,legendPosition:D,legendInteraction:$,selection:_,linkedHover:L,onObservation:O,onClick:M,chartType:"ForceDirectedGraph",chartId:P,marginDefaults:s.marginDefaults,userMargin:c,width:H,height:z,loading:T,loadingContent:N,emptyContent:R,emptyDataKey:"nodes"}),Q=t.useMemo(()=>new Map,[]),Z=t.useMemo(()=>e=>{const t={};return t.fill=y?we(e.data||e,y,K.colorScale):Cr(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(()=>ls(Z,{stroke:B,strokeWidth:I,opacity:E}),[Z,B,I,E]),ee=t.useMemo(()=>e=>({stroke:w,strokeWidth:"number"==typeof x?x:"function"==typeof x?x(e):e[x]||1,opacity:k}),[x,w,k]),te=t.useMemo(()=>ls(ee,{stroke:B,strokeWidth:I,opacity:E}),[ee,B,I,E]),ne=t.useMemo(()=>{if(Y&&p)return"function"==typeof p?p:e=>{var t,n,o;return null!==(o=null!==(n=null===(t=e.data)||void 0===t?void 0:t[p])&&void 0!==n?n:e[p])&&void 0!==o?o:e.id}},[Y,p]),oe=rs({componentName:"ForceDirectedGraph",nodes:a,edges:l,nodesRequired:!0,edgesRequired:!0,accessors:{nodeIDAccessor:F}});return oe?e.jsx(Wr,{componentName:"ForceDirectedGraph",message:oe,width:H,height:z}):K.loadingEl?K.loadingEl:K.emptyEl?K.emptyEl:e.jsx(Vr,{componentName:"ForceDirectedGraph",width:H,height:z,children:e.jsx(fu,Object.assign({ref:r,chartType:"force"},null!=a&&{nodes:K.safeNodes},null!=l&&{edges:K.safeEdges},{size:[H,z],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:K.margin,nodeIDAccessor:F,sourceAccessor:f,targetAccessor:g,iterations:A,forceStrength:j,nodeStyle:J,edgeStyle:te,colorBy:y,colorScheme:K.effectivePalette,nodeSize:v,nodeSizeRange:b,nodeLabel:ne,showLabels:Y,enableHover:W,tooltipContent:!1===S?()=>null:ei(S)||void 0,customHoverBehavior:L||O||M?K.customHoverBehavior:void 0,customClickBehavior:O||M?K.customClickBehavior:void 0,legend:K.legend,legendPosition:K.legendPosition},$&&"none"!==$&&{legendHoverBehavior:K.legendState.onLegendHover,legendClickBehavior:K.legendState.onLegendClick,legendHighlightedCategory:K.legendState.highlightedCategory,legendIsolatedCategories:K.legendState.isolatedCategories},{className:u,title:q,description:V,summary:X,accessibleTable:U},null!=n.animate&&{animate:n.animate},C))})});bu.displayName="ForceDirectedGraph";const xu=t.forwardRef(function(n,o){const i=t.useRef(null);us(o,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const r=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:600,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:p,edgeColorBy:y="source",padAngle:m=.01,groupWidth:v=20,sortGroups:b,nodeLabel:x,edgeOpacity:w=.5,tooltip:k,frameProps:A={},onObservation:j,onClick:S,chartId:C,selection:O,linkedHover:M,loading:P,loadingContent:_,emptyContent:L,legendInteraction:T,stroke:N,strokeWidth:R,opacity:$}=n,{width:D,height:B,enableHover:I,showLabels:E=!0,title:F,description:H,summary:z,accessibleTable:W}=r,G=vu({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,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:B,loading:P,loadingContent:_,emptyContent:L}),Y=t.useMemo(()=>new Map,[]),q=G.safeNodes.length>0,V=t.useMemo(()=>{if(q)return(e,t)=>{var n,o;const i={stroke:"black",strokeWidth:1};if(g)i.fill=we(e.data||e,g,G.colorScale);else{const r=Array.isArray(p)?p:ye[p]||me,s=Array.isArray(r)?r:me,a=null!==(o=null!==(n=e.index)&&void 0!==n?n:t)&&void 0!==o?o:0;i.fill=s[a%s.length]}return i}},[q,g,G.colorScale,p]),X=t.useMemo(()=>V?ls(V,{stroke:N,strokeWidth:R,opacity:$}):void 0,[V,N,R,$]),U=t.useMemo(()=>{if(q)return mu({edgeColorBy:y,colorBy:g,colorScale:G.colorScale,nodeStyleFn:X||(e=>({fill:Cr(void 0,G.themeCategorical,p,void 0,Y)})),edgeOpacity:w,baseStyle:{stroke:"black",strokeWidth:.5,strokeOpacity:w}})},[q,y,g,G.colorScale,X,w,G.themeCategorical,p,Y]),K=t.useMemo(()=>U?ls(U,{stroke:N,strokeWidth:R,opacity:$}):void 0,[U,N,R,$]),Q=t.useMemo(()=>{if(!E)return;const e=x||f;return"function"==typeof e?e:t=>{var n,o,i;return null!==(i=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==i?i:t.id}},[E,x,f]),Z=rs({componentName:"ChordDiagram",edges:a,edgesRequired:!0});return Z?e.jsx(Wr,{componentName:"ChordDiagram",message:Z,width:D,height:B}):G.loadingEl?G.loadingEl:G.emptyEl?G.emptyEl:e.jsx(Vr,{componentName:"ChordDiagram",width:D,height:B,children:e.jsx(fu,Object.assign({ref:i,chartType:"chord"},G.safeNodes.length>0&&{nodes:G.safeNodes},null!=a&&{edges:G.safeEdges},{size:[D,B],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:G.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,padAngle:m,groupWidth:v,sortGroups:b,nodeStyle:X,edgeStyle:K,colorBy:g,colorScheme:G.effectivePalette,edgeColorBy:y,edgeOpacity:w,nodeLabel:Q,showLabels:E,enableHover:I,tooltipContent:!1===k?()=>null:ei(k)||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:H,summary:z,accessibleTable:W},null!=n.animate&&{animate:n.animate},A))})});xu.displayName="ChordDiagram";const wu=t.forwardRef(function(n,o){const i=t.useRef(null);us(o,{variant:"network",frameRef:i,overrides:{getData:()=>{var e,t,n,o;return null!==(o=null===(n=null===(t=null===(e=i.current)||void 0===e?void 0:e.getTopology())||void 0===t?void 0:t.edges)||void 0===n?void 0:n.map(e=>e.data))&&void 0!==o?o:[]}}});const r=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary},{width:800,height:600}),{nodes:s,edges:a,margin:l,className:c,sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",nodeIdAccessor:f="id",colorBy:g,colorScheme:p,edgeColorBy:y="source",orientation:m="horizontal",nodeAlign:v="justify",nodePaddingRatio:b=.05,nodeWidth:x=15,nodeLabel:w,edgeOpacity:k=.5,edgeSort:A,tooltip:j,frameProps:S={},onObservation:C,onClick:O,chartId:M,selection:P,linkedHover:_,loading:L,loadingContent:T,emptyContent:N,showLegend:R,legendPosition:$,legendInteraction:D,stroke:B,strokeWidth:I,opacity:E}=n,{width:F,height:H,enableHover:z,showLabels:W=!0,title:G,description:Y,summary:q,accessibleTable:V}=r,X=vu({nodes:s,edges:a,inferNodes:!0,sourceAccessor:u,targetAccessor:d,colorBy:g,colorScheme:p,showLegend:R,legendPosition:$,legendInteraction:D,selection:P,linkedHover:_,onObservation:C,onClick:O,chartType:"SankeyDiagram",chartId:M,marginDefaults:r.marginDefaults,userMargin:l,width:F,height:H,loading:L,loadingContent:T,emptyContent:N}),U=t.useMemo(()=>new Map,[]),K=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?we(e.data||e,g,X.colorScale):Cr(void 0,X.themeCategorical,p,void 0,U),t},[g,X.colorScale,X.themeCategorical,p,U]),Q=t.useMemo(()=>ls(K,{stroke:B,strokeWidth:I,opacity:E}),[K,B,I,E]),Z=t.useMemo(()=>mu({edgeColorBy:y,colorBy:g,colorScale:X.colorScale,nodeStyleFn:Q,edgeOpacity:k,baseStyle:{stroke:"none",strokeWidth:0}}),[y,g,X.colorScale,Q,k]),J=t.useMemo(()=>ls(Z,{stroke:B,strokeWidth:I,opacity:E}),[Z,B,I,E]),ee=t.useMemo(()=>{if(!W)return;const e=w||f;return"function"==typeof e?e:t=>{var n,o,i;return null!==(i=null!==(o=null===(n=t.data)||void 0===n?void 0:n[e])&&void 0!==o?o:t[e])&&void 0!==i?i:t.id}},[W,w,f]),te=rs({componentName:"SankeyDiagram",edges:a,edgesRequired:!0});return te?e.jsx(Wr,{componentName:"SankeyDiagram",message:te,width:F,height:H}):X.loadingEl?X.loadingEl:X.emptyEl?X.emptyEl:e.jsx(Vr,{componentName:"SankeyDiagram",width:F,height:H,children:e.jsx(fu,Object.assign({ref:i,chartType:"sankey"},X.safeNodes.length>0&&{nodes:X.safeNodes},null!=a&&{edges:X.safeEdges},{size:[F,H],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:X.margin,nodeIDAccessor:f,sourceAccessor:u,targetAccessor:d,valueAccessor:h,orientation:m,nodeAlign:v,nodePaddingRatio:b,nodeWidth:x,nodeStyle:Q,edgeStyle:J,colorBy:g,colorScheme:X.effectivePalette,edgeColorBy:y,edgeOpacity:k,edgeSort:A,nodeLabel:ee,showLabels:W,enableHover:z,tooltipContent:!1===j?()=>null:ei(j)||void 0,customHoverBehavior:_||C||O?X.customHoverBehavior:void 0,customClickBehavior:C||O?X.customClickBehavior:void 0,legend:X.legend,legendPosition:X.legendPosition},D&&"none"!==D&&{legendHoverBehavior:X.legendState.onLegendHover,legendClickBehavior:X.legendState.onLegendClick,legendHighlightedCategory:X.legendState.highlightedCategory,legendIsolatedCategories:X.legendState.isolatedCategories},{className:c,title:G,description:Y,summary:q,accessibleTable:V},null!=n.animate&&{animate:n.animate},S))})});function ku(e,t,n){const o=t.incoming[e.id],i=t.outgoing[e.id],r=[];for(const e of o)r.push({time:e.endTime,delta:+e.value,edge:e,kind:"in",side:n.get(e.id).targetSide});for(const e of i)r.push({time:e.startTime,delta:-e.value,edge:e,kind:"out",side:n.get(e.id).sourceSide});const s={create:0,in:1,"transfer-out":2,"transfer-in":3,out:4},a=()=>{r.sort((e,t)=>{var n,o;return e.time-t.time||(null!==(n=s[e.kind])&&void 0!==n?n:99)-(null!==(o=s[t.kind])&&void 0!==o?o: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 f=e=>{const t=h.get(e);return null!=t?(t+e)/2:null!=u?u:e};a();const g=[];let p=0,y=0;for(const e of r)if("out"===e.kind){const t=Math.abs(e.delta);let n=t-("top"===e.side?p:y);if(n>0){const t="top"===e.side?"bot":"top",o=Math.min(n,"top"===t?p:y);if(o>0){const i=f(e.time);g.push({time:i,delta:-o,kind:"transfer-out",side:t}),g.push({time:i,delta:+o,kind:"transfer-in",side:e.side}),"top"===t?p-=o:y-=o,"top"===e.side?p+=o:y+=o,n-=o}n>0&&null!==u&&(g.push({time:u,delta:+n,kind:"create",side:e.side}),"top"===e.side?p+=n:y+=n)}"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(...g),a();let m=0,v=0,b=0,x=0,w=0;const k=[],A=new Map;for(const e of r){if(k.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>w&&(w=v),k.push({t:e.time,topMass:m,botMass:v})}const j=[];let S=0;for(;k.length>S;){let e=S;for(;k.length>e+1&&k[e+1].t===k[S].t;)e++;j.push(k[S]);for(let t=S+1;e>=t;t++){const e=j[j.length-1];k[t].topMass===e.topMass&&k[t].botMass===e.botMass||j.push(k[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 o)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 n=j[0],o=Math.min(null!=c?c:1/0,null!=O?O:1/0);Number.isFinite(o)&&n.t>o&&n.topMass+n.botMass>0&&j.unshift({t:o,topMass:n.topMass,botMass:n.botMass})}return{samples:j,peak:b,topPeak:x,botPeak:w,localAttachments:A}}function Au(e,t){return t?Math.max(t[0],Math.min(t[1],e)):e}function ju(e,t){return e.map(e=>({t:Au(e.t,t),topMass:e.topMass,botMass:e.botMass}))}function Su(e,t,n){const o=e.value*n;if("out"===e.kind){const i=e.sideMassBefore*n;if("top"===e.side){const e=t-i;return[e,e+o]}const r=t+i;return[r-o,r]}const i=e.sideMassAfter*n;if("top"===e.side){const e=t-i;return[e,e+o]}const r=t+i;return[r-o,r]}function Cu(e,t){let n=0;for(let o=0;t.length>o;o++)for(let i=o+1;t.length>i;i++){const r=t[o],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]&&n++)}return n}function Ou(e,t){let n=0;for(const o of t)n+=Math.abs(e[o.source]-e[o.target])*(o.value||1);return n}function Mu(e,t){return 1e3*Cu(e,t)+Ou(e,t)}function Pu(e,t){return{slots:e.map(e=>({peak:Object.assign({},e.peak),occupants:e.occupants.slice()})),map:Object.assign({},t)}}function _u(e,t,n){e.length>8||n.length>40?(function(e,t,n,o=6){const i=e.length;if(1>=i)return;let r=Pu(e,t),s=Mu(t,n);for(let a=0;o>a;a++){const o=Array(i).fill(0),a=Array(i).fill(0);for(const e of n){const n=t[e.source],i=t[e.target];o[n]+=i*(e.value||1),a[n]+=e.value||1,o[i]+=n*(e.value||1),a[i]+=e.value||1}const l=Array.from({length:i},(e,t)=>t).sort((e,t)=>(a[e]>0?o[e]/a[e]:e)-(a[t]>0?o[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=Mu(t,n);if(s>d)s=d,r=Pu(e,t);else if(d===s)break}!function(e,t,n){e.length=0;for(const t of n.slots)e.push(t);for(const e of Object.keys(t))delete t[e];for(const e of Object.keys(n.map))t[e]=n.map[e]}(e,t,r)}(e,t,n,6),function(e,t,n,o=6){const i=e.length;if(1>=i)return;let r=Mu(t,n);for(let s=0;o>s;s++){let o=!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=Mu(t,n);if(r>a)r=a,o=!0;else{const n=e[s];e[s]=e[s+1],e[s+1]=n;for(const e of Object.keys(t))t[e]===s?t[e]=s+1:t[e]===s+1&&(t[e]=s)}}if(!o)break}}(e,t,n,6)):function(e,t,n){const o=e.length;if(1>=o)return;const i=Object.assign({},t),r=Object.keys(i),s=Array.from({length:o},(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=Mu(l,n);u>e&&(u=e,c=s.slice())},h=(e,t)=>{const n=s[e],o=s[t];s[e]=o,s[t]=n,a[n]=t,a[o]=e};d();const f=Array(o).fill(0);let g=0;for(;o>g;)g>f[g]?(h(g%2==0?0:f[g],g),d(),f[g]++,g=0):(f[g]=0,g++);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,n)}function Lu(e,t,n,o,i){var r,s,a,l,c,u,d,h;const{plotH:f,padding:g,valueScale:p,packing:y,laneOrder:m,lifetimeMode:v="full"}=i,b={},x={};for(const t of e)b[t.id]=n[t.id].topPeak||0,x[t.id]=n[t.id].botPeak||0;const w="half"===v,k={};for(const t of e){const e=Array.isArray(t.xExtent)?t.xExtent[0]:null,n=Array.isArray(t.xExtent)?t.xExtent[1]:null;let i=null!=e&&Number.isFinite(e)?e:1/0,r=null!=n&&Number.isFinite(n)?n:-1/0;for(const e of o.outgoing[t.id]){i>e.startTime&&(i=e.startTime),null!=e.systemInTime&&Number.isFinite(e.systemInTime)&&i>e.systemInTime&&(i=e.systemInTime);const t=w?(e.startTime+e.endTime)/2:e.endTime;t>r&&(r=t)}for(const e of o.incoming[t.id]){const t=w?(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)}k[t.id]={start:Number.isFinite(i)?i:null,end:Number.isFinite(r)?r:null}}const A={},j=[];if("reuse"===y){const n=new Map;for(const t of e)n.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=o.outgoing[e])&&void 0!==a?a:[]){const o=(null!==(l=n.get(e))&&void 0!==l?l:0)+1;o>(null!==(c=n.get(t.target))&&void 0!==c?c:0)&&n.set(t.target,o),i.set(t.target,i.get(t.target)-1),0===i.get(t.target)&&d.push(t.target)}}const h=[...e].filter(e=>null!==k[e.id].start).sort((e,t)=>{var o,i;const r=null!==(o=n.get(e.id))&&void 0!==o?o:0,s=null!==(i=n.get(t.id))&&void 0!==i?i:0;return r!==s?r-s:k[e.id].start-k[t.id].start}),f=e.filter(e=>null===k[e.id].start);for(const e of[...h,...f]){const t=k[e.id];let n=-1;for(let e=0;j.length>e;e++){const o=j[e].occupants[j[e].occupants.length-1];if(null===t.start||void 0===o||t.start>=o.end){n=e;break}}-1===n&&(j.push({occupants:[],peak:{topPeak:0,botPeak:0}}),n=j.length-1),j[n].occupants.push({id:e.id,end:null!==(u=null==t?void 0:t.end)&&void 0!==u?u:-1/0}),j[n].peak.topPeak=Math.max(j[n].peak.topPeak,b[e.id]),j[n].peak.botPeak=Math.max(j[n].peak.botPeak,x[e.id]),A[e.id]=n}}else e.forEach((e,t)=>{var n,o;j.push({occupants:[{id:e.id,end:null!==(o=null===(n=k[e.id])||void 0===n?void 0:n.end)&&void 0!==o?o:-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=Cu(A,t),O=Ou(A,t)},_=()=>{C=Cu(A,t),M=Ou(A,t)};"crossing-min"===m?(P(),_u(j,A,t),_()):"inside-out"===m?(P(),function(e,t){const n=e.length;if(1>=n)return;const o=e=>e.peak.topPeak+e.peak.botPeak,i=e.map((e,t)=>({slot:e,idx:t})).sort((e,t)=>o(t.slot)-o(e.slot)),r=Array(n),s=Math.floor((n-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&&n>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(),_u(j,A,t),function(e,t,n){const o=e.length;if(1>=o)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((o-1)/2);let s=Mu(t,n);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;o>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=Mu(t,n);if(d>s){const n=e[l];e.splice(l,1),e.splice(i,0,n);const r=new Map;for(let e=0;o>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 o of e.occupants){const e=n[o.id];if(e)for(const n of e.samples){const e=t.get(n.t)||{top:0,bot:0};t.set(n.t,{top:Math.max(e.top,n.topMass),bot:Math.max(e.bot,n.botMass)})}}return[...t.entries()].sort((e,t)=>e[0]-t[0])}),T=(e,t)=>{let n={top:0,bot:0};for(const[o,i]of e){if(o>t)break;n=i}return n},N=[];for(let e=0;j.length-1>e;e++){const t=L[e],n=L[e+1],o=new Set([...t.map(e=>e[0]),...n.map(e=>e[0])]);let i=0;for(const e of o){const o=T(t,e),r=T(n,e);o.bot+r.top>i&&(i=o.bot+r.top)}N.push(i)}const R=[];let $=g+(null!==(h=null===(d=j[0])||void 0===d?void 0:d.peak.topPeak)&&void 0!==h?h:0)*p;j.length>0&&R.push($);for(let e=1;j.length>e;e++)$+=N[e-1]*p+g,R.push($);if(j.length>0&&($+=j[j.length-1].peak.botPeak*p+g),$>f){const e=f/$;for(let t=0;R.length>t;t++)R[t]*=e}const D=0===j.length?0:j[0].peak.topPeak+N.reduce((e,t)=>e+t,0)+j[j.length-1].peak.botPeak,B={};for(const t of e)B[t.id]=R[A[t.id]];return{effectiveSlotsHeight:D,centerlines:B,laneLifetime:k,slots:j,slotByNode:A,slotCenter:R,crossingsBefore:S,crossingsAfter:C,lengthBefore:O,lengthAfter:M}}wu.displayName="SankeyDiagram";const Tu=e=>{var t,n;const{bands:o=[],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 o)if(e.gradientStubs)for(let t=0;e.gradientStubs.length>t;t++){const n=e.gradientStubs[t];s.push({type:"bezier",pathD:n.pathD,interactive:!1,style:{fill:e.fill,fillOpacity:.86,stroke:"none"},_gradient:{x0:n.x0,x1:n.x1,from:n.from,to:n.to},datum:{__kind:"band",data:e.rawDatum,id:`${e.id}__stub${t}`}})}for(const e of o)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!==(n=e.strokeWidth)&&void 0!==n?n:.5}),datum:{__kind:"band",data:e.rawDatum,id:e.id}});const a=r?o.map(e=>({x:e.labelX,y:e.labelY,text:e.labelText,anchor:"end",baseline:"middle",fontSize:11,fontWeight:600})):[];return{sceneNodes:o.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 Nu(e){return"object"==typeof e&&null!==e&&"__kind"in e&&("band"===e.__kind||"ribbon"===e.__kind)}function Ru(e){return null==e?NaN:e instanceof Date?e.getTime():"number"==typeof e?e:new Date(e).getTime()}function $u(e,t){return"function"==typeof e?e(t):t[e]}const Du=t.forwardRef(function(n,o){const{nodes:r,edges:s,domain:a,axisTicks:l=[],nodeIdAccessor:c="id",sourceAccessor:u="source",targetAccessor:d="target",valueAccessor:h="value",startTimeAccessor:f="startTime",endTimeAccessor:g="endTime",systemInTimeAccessor:p,systemOutTimeAccessor:y,xExtentAccessor:m="xExtent",edgeIdAccessor:b="id",colorBy:x,colorScheme:w,showLegend:k,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:N=400,margin:R,title:$,description:D,summary:B,accessibleTable:I,responsiveWidth:E,responsiveHeight:F,loading:H,loadingContent:z,emptyContent:W,edgeOpacity:G=.35,timeFormat:Y,valueFormat:q,tooltip:V,enableHover:X=!0,onObservation:U,onClick:K,showParticles:Q=!1,particleStyle:Z,chartId:J,frameProps:ee={}}=n,[te,ne]=t.useState([]),[oe,ie]=t.useState([]),re=t.useRef(te),se=t.useRef(oe);re.current=te,se.current=oe;const ae=t.useCallback(e=>{re.current=e,ne(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=oe;if(0===e.length&&0===t.length)return pu([],ue,u,d);const n=new Set,o=[];for(const t of e){const e=$u(c,t)+"";n.has(e)||(n.add(e),o.push(t))}for(const e of t){const t=$u(c,e)+"";n.has(t)||(n.add(t),o.push(e))}const i=pu([],ue,u,d);for(const e of i)n.has(e.id)||(n.add(e.id),o.push(e));return o},[r,oe,ue,c,u,d]),he=t.useRef(null),fe=t.useCallback((e,t)=>{const n=$u(b,e);return null!=n?n+"":`${$u(u,e)}-${$u(d,e)}-${t}`},[b,u,d]),ge=t.useCallback(e=>{if(null==e)return!1;const t=e;return null!=$u(u,t)&&null!=$u(d,t)},[u,d]);us(o,{variant:"network",frameRef:he,overrides:{push(e){if(ge(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=[],n=[];for(const o of e)ge(o)?t.push(o):n.push(o);t.length>0&&(ce?console.warn("ProcessSankey.pushMany: edges ignored — `edges` prop is controlled."):ae([...re.current,...t])),n.length>0&&le([...se.current,...n])},remove(e){const t=new Set(Array.isArray(e)?e:[e]),n=[];if(!ce){const e=re.current,o=[];for(let i=0;e.length>i;i++){const r=e[i];t.has(fe(r,i))?n.push(r):o.push(r)}o.length!==e.length&&ae(o)}const o=se.current,i=[];for(const e of o){const o=$u(c,e)+"";t.has(o)?n.push(e):i.push(e)}return i.length!==o.length&&le(i),n},update(e,t){const n=new Set(Array.isArray(e)?e:[e]),o=[];if(!ce){let e=!1;const i=re.current.map((i,r)=>n.has(fe(i,r))?(o.push(i),e=!0,t(i)):i);e&&ae(i)}let i=!1;const r=se.current.map(e=>{const r=$u(c,e)+"";return n.has(r)?(o.push(e),i=!0,t(e)):e});return i&&le(r),o},clear(){var e;ce||ae([]),le([]),null===(e=he.current)||void 0===e||e.clear()},getData:()=>null!=ue?ue:[],getScales:()=>null},deps:[ce,ge,fe,c,ue,ae,le]});const pe=fe,ye=t.useCallback(e=>$u(c,e)+"",[c]),{nodes:me,edges:ve,domain:be,rawNodeById:xe,rawEdgeById:ke}=t.useMemo(()=>{const e=(null!=de?de:[]).map(e=>{const t={id:ye(e),__raw:e},n=m?$u(m,e):null;if(Array.isArray(n)&&2===n.length){const e=Ru(n[0]),o=Ru(n[1]);Number.isFinite(e)&&Number.isFinite(o)&&(t.xExtent=[e,o])}return t}),t=(null!=ue?ue:[]).map((e,t)=>{const n={id:pe(e,t),source:$u(u,e)+"",target:$u(d,e)+"",value:Number($u(h,e)),startTime:Ru($u(f,e)),endTime:Ru($u(g,e)),__raw:e};if(p){const t=Ru($u(p,e));Number.isFinite(t)&&(n.systemInTime=t)}if(y){const t=Ru($u(y,e));Number.isFinite(t)&&(n.systemOutTime=t)}return n}),n=[Ru(a[0]),Ru(a[1])],o=new Map;for(const t of e)null!=t.__raw&&o.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:n,rawNodeById:o,rawEdgeById:i}},[de,ue,a,ye,pe,m,u,d,h,f,g,p,y]),Ae=vu({nodes:de,edges:ue,inferNodes:!1,sourceAccessor:u,targetAccessor:d,colorBy:x,colorScheme:w,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:R,width:T,height:N,loading:H,loadingContent:z,emptyContent:W}),je=(null!=k?k:!!x)&&!!x,Se=t.useCallback(e=>null!=R&&("number"==typeof R||null!=R[e]),[R]),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=N-Ce.top-Ce.bottom,Pe=t.useMemo(()=>function(e,t,n){const o=[],i=new Set(e.map(e=>e.id)),r=Array.isArray(n)&&2===n.length,s=r&&Number.isFinite(n[0])&&Number.isFinite(n[1]);r&&s&&s&&n[1]>=n[0]||o.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]||o.push({kind:"invalid-node-time",id:t.id}));for(const e of t)i.has(e.source)||o.push({kind:"missing-node",id:e.id,endpoint:"source",nodeId:e.source}),i.has(e.target)||o.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||o.push({kind:"invalid-value",id:e.id}),e.endTime>e.startTime||o.push({kind:"backward-edge",id:e.id,source:e.source,target:e.target})):o.push({kind:"invalid-edge-time",id:e.id});return o}(me,ve,be),[me,ve,be]),_e=t.useMemo(()=>Pe.length>0?null:function(e,t,n){var o;const{plotH:i,pairing:r="temporal",packing:s="reuse",laneOrder:a="crossing-min",lifetimeMode:l="half"}=n,c=function(e,t){const n={},o={};for(const t of e)n[t.id]=[],o[t.id]=[];for(const e of t)o[e.source]&&o[e.source].push(e),n[e.target]&&n[e.target].push(e);return{incoming:n,outgoing:o}}(e,t),u=function(e,t,n,o="value"){const i="temporal"===o?(e,t)=>e.endTime-t.endTime:(e,t)=>t.value-e.value,r="temporal"===o?(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 n=new Map;for(const o of e){const e=o[t];n.has(e)||n.set(e,{partner:e,edges:[],total:0,earliestStart:1/0,latestEnd:-1/0});const i=n.get(e);i.edges.push(o),i.total+=o.value,i.earliestStart=Math.min(i.earliestStart,o.startTime),i.latestEnd=Math.max(i.latestEnd,o.endTime)}const s=[...n.values()];s.sort("temporal"===o?(e,n)=>"target"===t?e.earliestStart-n.earliestStart:e.latestEnd-n.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=n.outgoing[t.id],o=n.incoming[t.id];if(0===o.length)a(e,"target").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).sourceSide=n});else if(0===e.length)a(o,"source").forEach((e,t)=>{const n=t%2==0?"top":"bot";for(const t of e.edges)s.get(t.id).targetSide=n});else{const t=a(o,"source"),n=a(e,"target"),i=Math.max(t.length,n.length);for(let e=0;i>e;e++){const o=e%2==0?"top":"bot";if(t[e])for(const n of t[e].edges)s.get(n.id).targetSide=o;if(n[e])for(const t of n[e].edges)s.get(t.id).sourceSide=o}}}return s}(e,t,c,r);let d={};for(const t of e)d[t.id]=ku(t,c,u);const h=Lu(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),f=new Set;for(const e of t){const t=h.slotByNode[e.source],n=h.slotByNode[e.target];if(void 0===t||void 0===n)continue;const o=u.get(e.id);t!==n?t>n?(o.sourceSide="top",o.targetSide="bot"):(o.sourceSide="bot",o.targetSide="top"):(f.add(e.id),o.sourceSide="bot",o.targetSide="bot")}for(const t of e){const e=c.outgoing[t.id],n=c.incoming[t.id],o=new Set(e.map(e=>u.get(e.id).sourceSide)),i=new Set(n.map(e=>u.get(e.id).targetSide));if(1===o.size&&n.length>0){const e=[...o][0];for(const t of n)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 n of e)h.slotByNode[n.source]===h.slotByNode[n.target]&&(u.get(n.id).sourceSide=t)}}for(const t of e){const e=c.incoming[t.id],n=c.outgoing[t.id];if(0===e.length||0===n.length)continue;const o=()=>{const t={inTop:0,inBot:0,outTop:0,outBot:0};for(const n of e)"top"===u.get(n.id).targetSide?t.inTop+=n.value:t.inBot+=n.value;for(const e of n)"top"===u.get(e.id).sourceSide?t.outTop+=e.value:t.outBot+=e.value;return t},i=(e,t)=>{const i=o(),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=n.filter(t=>!f.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=n.length+1;for(;r-- >0&&(i("top","bot")||i("bot","top")););}d={};for(const t of e)d[t.id]=ku(t,c,u);const g=Lu(e,t,d,c,{plotH:i,padding:12,valueScale:1,packing:s,laneOrder:a,lifetimeMode:l}),p=null!==(o=g.effectiveSlotsHeight)&&void 0!==o?o:g.slots.reduce((e,t)=>e+t.peak.topPeak+t.peak.botPeak,0),y=Math.min(12,.35*i/Math.max(g.slots.length+1,1)),m=p>0?Math.max(0,(i-y*(g.slots.length+1))/p):1,v=Lu(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 we(t,x,Ae.colorScale)}return Ae.effectivePalette[t%Ae.effectivePalette.length]||"#475569"},[x,de,xe,Ae.colorScale,Ae.effectivePalette]),Ne=t.useMemo(()=>{const e=new Map;return me.forEach((t,n)=>e.set(t.id,n)),e},[me]),Re=t.useMemo(()=>{if(!_e)return{bands:[],ribbons:[]};const{centerlines:e,nodeData:t,valueScale:n}=_e,o=[],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,n,o,i){if(0===e.length)return null;const r=ju(e,i),s=e=>t-r[e].topMass*n,a=e=>t+r[e].botMass*n;let l=`M${o(r[0].t)},${s(0)}`;for(let e=1;r.length>e;e++)l+=` L${o(r[e].t)},${s(e)}`;l+=` L${o(r[r.length-1].t)},${a(r.length-1)}`;for(let e=r.length-2;e>=0;e--)l+=` L${o(r[e].t)},${a(e)}`;return l+" Z"}(a.samples,e[i.id],n,Le,be);if(!l)return;const c=ju(a.samples,be),u=c.find(e=>e.topMass+e.botMass>0)||c[0],d=e[i.id]+(u.botMass-u.topMass)*n/2,h=Te(i.id,r),f=null!==(s=xe.get(i.id))&&void 0!==s?s:i,g=function(e,t,n,o,i){const r=n.nodeData[e];if(!r||0===r.samples.length)return[];const s=n.valueScale,a=n.centerlines[e],l=ju(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=o(c.t),h=o(u.t),f=e=>o(Au(e,i)),g=[],p=(e,t,n,o)=>`M${e},${t} L${n},${t} L${n},${o} L${e},${o} Z`;for(const n of t){if(n.source===e&&null!=n.systemInTime&&Number.isFinite(n.systemInTime)){const e=r.localAttachments.get(n.id);if(e&&"out"===e.kind&&n.startTime>n.systemInTime){const t=f(n.systemInTime),o=f(n.startTime),i=t-20,r=Math.max(d,i);if(o>r){const[n,l]=Su(e,a,s);g.push({pathD:p(r,n,o,l),x0:i,x1:t,from:0,to:1})}}}if(n.target===e&&null!=n.systemOutTime&&Number.isFinite(n.systemOutTime)){const e=r.localAttachments.get(n.id);if(e&&"in"===e.kind&&n.systemOutTime>n.endTime){const t=f(n.systemOutTime),o=f(n.endTime),i=t+20,r=Math.min(h,i);if(r>o){const[n,l]=Su(e,a,s);g.push({pathD:p(o,n,r,l),x0:t,x1:i,from:1,to:0})}}}}return g}(i.id,ve,_e,Le,be);o.push(Object.assign(Object.assign({id:i.id,pathD:l,fill:h,stroke:h,strokeWidth:.5},g.length>0&&{gradientStubs:g}),{rawDatum:f,labelX:Le(u.t)-4,labelY:d,labelText:i.id}))}),ve.forEach(o=>{var r,s,a,l;const c=null===(r=t[o.source])||void 0===r?void 0:r.localAttachments.get(o.id),u=null===(s=t[o.target])||void 0===s?void 0:s.localAttachments.get(o.id);if(!c||!u)return;const d=null!==(a=Ne.get(o.source))&&void 0!==a?a:0,h=Te(o.source,d),f=function(e,t,n,o,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(n.time)),h=e.value*l,f=n.value*l,g=e.sideMassBefore*l,p=n.sideMassAfter*l;let y,m,v,b;"top"===e.side?(y=t-g,m=y+h):(m=t+g,y=m-h),"top"===n.side?(v=o-p,b=v+f):(b=o+p,v=b-f);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[o.source],u,e[o.target],n,Le,O,be),{pathD:g,bezier:p}=fc(f),y=null!==(l=ke.get(o.id))&&void 0!==l?l:o;i.push({id:o.id,pathD:g,fill:h,opacity:G,rawDatum:y,bezier:p})}),{bands:o,ribbons:i}},[_e,me,ve,Le,be,Te,xe,ke,O,G,Ne]),$e=t.useMemo(()=>({bands:Re.bands,ribbons:Re.ribbons,showLabels:L}),[Re,L]),De=t.useMemo(()=>{if(!je||!x)return;const e=new Map;(null!=de?de:[]).forEach((t,n)=>{const o=$u(x,t),i=null==o?"":o+"";i&&!e.has(i)&&e.set(i,{label:i,color:Te(ye(t),n)})});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]),Be=t.useMemo(()=>!1!==V&&X?void 0===V||!0===V?null:ei(V)||null:null,[V,X]),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]),Ee=t.useCallback(e=>q?q(e):e+"",[q]),Fe=t.useCallback(t=>{if(!t||!t.data)return null;const n=t.data;if(!Nu(n))return null;const o=n.data;if(Be)return Be(o);if("band"===n.__kind){const t=n.id,o=_e?function(e){if(!e)return[];const t=new Set,n=[];for(const o of e.samples){const e=o.topMass+o.botMass,i=`${o.t}:${e}`;t.has(i)||(t.add(i),n.push({t:o.t,total:e}))}return n}(_e.nodeData[t]):[],i=5,r=o.length>i?o.length:null,s=function(e,t=5){if(t>=e.length)return e.slice();const n=[...e].sort((e,t)=>e.total-t.total),o=n.length-1,i=[Object.assign(Object.assign({},n[0]),{mark:"min"}),Object.assign(Object.assign({},n[Math.floor(.25*o)]),{mark:"q25"}),Object.assign(Object.assign({},n[Math.floor(.5*o)]),{mark:"median"}),Object.assign(Object.assign({},n[Math.floor(.75*o)]),{mark:"q75"}),Object.assign(Object.assign({},n[o]),{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)}(o,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,n)=>e.jsxs("tr",{children:[e.jsx("td",{style:{paddingRight:8},children:Ie(t.t)}),e.jsx("td",{style:{textAlign:"right"},children:Ee(t.total)}),null!=r&&e.jsx("td",{style:{textAlign:"right",paddingLeft:8,opacity:.55},children:t.mark})]},n))})]}),null!=r&&e.jsxs("div",{style:{marginTop:4,fontSize:10,opacity:.55},children:["showing ",s.length," of ",r," samples"]})]})}const i=o,r=$u(u,i),s=$u(d,i),a=$u(h,i),l=$u(f,i),c=$u(g,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:Ee(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(Ru(l))})]}),null!=c&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{opacity:.6},children:"end"}),e.jsx("span",{style:{textAlign:"right"},children:Ie(Ru(c))})]})]})]})},[_e,Be,Ie,Ee,u,d,h,f,g]),He=t.useMemo(()=>{if(!_e)return null;const{centerlines:t,laneLifetime:n,nodeData:o,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=n[e.id];if(!t||null===t.start||null===t.end)continue;const o=Le(t.start),i=Le(t.end);(null===d||d>o)&&(d=o),(null===h||i>h)&&(h=i)}const f=e=>Math.max(0,Math.min(Oe,e)),g=f(null!=d?d:0),p=Math.max(g,f(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,n)=>{const o=Le(Ru(t.date));return g-.5>o||o>p+.5?null:e.jsx("line",{x1:o,y1:0,x2:o,y2:Me,stroke:"#94a3b8",strokeOpacity:.15,strokeDasharray:"2 4"},"grid-"+n)}),P&&me.map((r,s)=>{const a=n[r.id];if(!a||null===a.start)return null;const l=o[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),f=Te(r.id,s);return e.jsxs("g",{children:[e.jsx("line",{x1:d,y1:u,x2:h,y2:u,stroke:f,strokeOpacity:.35,strokeWidth:1,strokeDasharray:"3 3"}),e.jsx("line",{x1:d,y1:u-4,x2:d,y2:u+4,stroke:f,strokeOpacity:.5}),e.jsx("line",{x1:h,y1:u-4,x2:h,y2:u+4,stroke:f,strokeOpacity:.5})]},"lane-"+r.id)}),e.jsx("line",{x1:g,y1:Me+4,x2:p,y2:Me+4,stroke:"#94a3b8"}),l.map((t,n)=>{const o=Ru(t.date),i=Le(o);if(g-.5>i||i>p+.5)return null;const r=null!=t.label?t.label:Y?Y(new Date(o)):"";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})]},n)})]})},[_e,l,Le,Oe,Me,P,me,Te,_,Y]),ze=t.useMemo(()=>(null!=de?de:[]).map(e=>({id:ye(e),data:e})),[de,ye]),We=t.useMemo(()=>{const e=new Map;for(const t of Re.ribbons)t.bezier&&e.set(t.id,t.bezier);return e},[Re]),Ge=t.useMemo(()=>(null!=ue?ue:[]).map((e,t)=>{const n=pe(e,t),o=Number($u(h,e));return{id:n,source:$u(u,e)+"",target:$u(d,e)+"",value:Number.isFinite(o)?o:0,bezier:We.get(n),data:e}}),[ue,pe,u,d,h,We]),Ye=Ae.loadingEl,qe=Ae.emptyEl;return Pe.length>0?e.jsxs("svg",{width:T,height:N,role:"img","aria-label":null!=$?$:"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,n)=>{return e.jsx("text",{x:20,y:56+18*n,fontSize:12,fill:"#64748b",children:"• "+(o=t,"invalid-node-time"===o.kind?`node ${o.id} has an invalid xExtent (must be [start, end] with start <= end)`:"invalid-edge-time"===o.kind?`edge ${o.id} has an invalid startTime or endTime`:"invalid-domain"===o.kind?"time domain must be a 2-tuple of finite times [start, end] with start <= end":"invalid-value"===o.kind?`edge ${o.id} must have a positive finite value`:"missing-node"===o.kind?`edge ${o.id} references missing ${o.endpoint} node "${o.nodeId}"`:"backward-edge"===o.kind?`edge ${o.id} (${o.source}->${o.target}) ends before it starts`:o.kind)},n);var o})]}):Ye||qe||e.jsx(fu,Object.assign({ref:he,chartType:"force",nodes:ze,edges:Ge,customNetworkLayout:Tu,layoutConfig:$e,size:[T,N],responsiveWidth:E,responsiveHeight:F,margin:Ce,title:$,description:null!=D?D:"Temporal process flow with lifetime-bounded node lanes, mass bands, and value-scaled ribbons.",summary:B,accessibleTable:I,enableHover:X,tooltipContent:!1===V?()=>null:Fe,backgroundGraphics:He,showParticles:Q,particleStyle:Z,legend:De,legendPosition:A,onObservation:U,customClickBehavior:K?e=>{if(!e||!e.data)return;const t=e.data;Nu(t)&&K(t.data,{x:e.x,y:e.y})}:void 0,chartId:J,colorScheme:Array.isArray(w)?w:void 0},ee))});function Bu(n){const o=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.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:f,colorByDepth:g=!1,edgeStyle:p="curve",nodeLabel:y,nodeSize:m=5,tooltip:v,frameProps:b={},onObservation:x,onClick:w,chartId:k,selection:A,linkedHover:j,loading:S,loadingContent:C,legendInteraction:O,stroke:M,strokeWidth:P,opacity:_}=n,{width:L,height:T,enableHover:N,showLabels:R=!0,title:$,description:D,summary:B,accessibleTable:I}=o,E=vu({nodes:t.useMemo(()=>gu(null!=i?i:null,c),[i,c]),edges:void 0,inferNodes:!1,colorBy:g?void 0:h,colorScheme:f,showLegend:!1,legendInteraction:O,selection:A,linkedHover:j,onObservation:x,onClick:w,chartType:"TreeDiagram",chartId:k,marginDefaults:o.marginDefaults,userMargin:r,width:L,height:T,loading:S,loadingContent:C}),F=t.useMemo(()=>new Map,[]),H=t.useMemo(()=>e=>{const t={stroke:"black",strokeWidth:1};return t.fill=g?be[(e.depth||0)%be.length]:h?we(e.data||e,h,E.colorScale):Cr(void 0,E.themeCategorical,f,void 0,F),t},[h,g,E.colorScale,E.themeCategorical,f,F]),z=t.useMemo(()=>ls(H,{stroke:M,strokeWidth:P,opacity:_}),[H,M,P,_]),W=t.useMemo(()=>()=>({stroke:"#999",strokeWidth:1,fill:"none"}),[]),G=t.useMemo(()=>ls(W,{stroke:M,strokeWidth:P,opacity:_}),[W,M,P,_]),Y=t.useMemo(()=>{if("treemap"===a||"circlepack"===a||"partition"===a)return yu(u)},[a,u]),q=is({componentName:"TreeDiagram",data:i});return q?e.jsx(Wr,{componentName:"TreeDiagram",message:q,width:L,height:T}):E.loadingEl?E.loadingEl:e.jsx(Vr,{componentName:"TreeDiagram",width:L,height:T,children:e.jsx(fu,Object.assign({chartType:a},null!=i&&{data:i},{size:[L,T],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:E.margin,nodeIDAccessor:d,childrenAccessor:c,hierarchySum:Y,treeOrientation:l,edgeType:p,nodeStyle:z,edgeStyle:G,colorBy:h,colorScheme:E.effectivePalette,colorByDepth:g,nodeSize:m,nodeLabel:R?y||d:void 0,showLabels:R,enableHover:N,tooltipContent:!1===v?()=>null:ei(v)||void 0,customHoverBehavior:j||x||w?E.customHoverBehavior:void 0,customClickBehavior:x||w?E.customClickBehavior:void 0},O&&"none"!==O&&{legendHoverBehavior:E.legendState.onLegendHover,legendClickBehavior:E.legendState.onLegendClick,legendHighlightedCategory:E.legendState.highlightedCategory,legendIsolatedCategories:E.legendState.isolatedCategories},{className:s,title:$,description:D,summary:B,accessibleTable:I},null!=n.animate&&{animate:n.animate},b))})}function Iu(n){const o=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.summary,linkedHover:n.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:f="leaf",nodeLabel:g,padding:p=4,paddingTop:y,nodeStyle:m,tooltip:v,frameProps:b={},selection:x,linkedHover:w,onObservation:k,onClick:A,chartId:j,loading:S,loadingContent:C,legendInteraction:O,stroke:M,strokeWidth:P,opacity:_}=n,{nodeStyle:L}=b,T=ds(b,["nodeStyle"]),{width:N,height:R,enableHover:$,showLabels:D=!0,title:B,description:I,summary:E,accessibleTable:F}=o,H=vu({nodes:t.useMemo(()=>gu(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:w,onObservation:k,onClick:A,chartType:"Treemap",chartId:j,marginDefaults:o.marginDefaults,userMargin:r,width:N,height:R,loading:S,loadingContent:C}),z=ss(x),W=H.customHoverBehavior,G=t.useCallback(e=>{if(!e)return W(null);const t=e.data||e;W({data:(null==t?void 0:t.data)||t})},[W]),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?we(e.data||e,u,H.colorScale):Cr(void 0,H.themeCategorical,d,void 0,Y),t},[u,h,H.colorScale,H.themeCategorical,d,Y]),V=t.useMemo(()=>m||L?e=>{var t,n;return Object.assign(Object.assign(Object.assign({},q(e)),L&&null!==(t=L(e))&&void 0!==t?t:{}),m&&null!==(n=m(e))&&void 0!==n?n:{})}:q,[q,m,L]),X=t.useMemo(()=>ls(V,{stroke:M,strokeWidth:P,opacity:_}),[V,M,P,_]),U=t.useMemo(()=>H.activeSelectionHook?e=>{var t;const n=Object.assign({},X(e));if(H.activeSelectionHook.isActive)if(H.activeSelectionHook.predicate(e.data||e))(null==z?void 0:z.selectedStyle)&&Object.assign(n,z.selectedStyle);else{const e=null!==(t=null==z?void 0:z.unselectedOpacity)&&void 0!==t?t:.5;n.opacity=e,n.fillOpacity=e,n.strokeOpacity=e,(null==z?void 0:z.unselectedStyle)&&Object.assign(n,z.unselectedStyle)}return n}:X,[X,H.activeSelectionHook,z]),K=t.useMemo(()=>yu(l),[l]),Q=void 0!==y?y:!D||"parent"!==f&&"all"!==f?void 0:18,Z=is({componentName:"Treemap",data:i});return Z?e.jsx(Wr,{componentName:"Treemap",message:Z,width:N,height:R}):H.loadingEl?H.loadingEl:e.jsx(Vr,{componentName:"Treemap",width:N,height:R,children:e.jsx(fu,Object.assign({chartType:"treemap"},null!=i&&{data:i},{size:[N,R],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:H.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:K,padding:p,paddingTop:Q,nodeStyle:U,colorBy:u,colorScheme:H.effectivePalette,colorByDepth:h,nodeLabel:D?g||c:void 0,showLabels:D,labelMode:f,enableHover:$,tooltipContent:!1===v?()=>null:ei(v)||void 0},(w||k||A)&&{customHoverBehavior:G},(k||A)&&{customClickBehavior:H.customClickBehavior},O&&"none"!==O&&{legendHoverBehavior:H.legendState.onLegendHover,legendClickBehavior:H.legendState.onLegendClick,legendHighlightedCategory:H.legendState.highlightedCategory,legendIsolatedCategories:H.legendState.isolatedCategories},{className:s,title:B,description:I,summary:E,accessibleTable:F},null!=n.animate&&{animate:n.animate},T))})}function Eu(n){const o=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.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:f,circleOpacity:g=.7,padding:p=4,tooltip:y,frameProps:m={},onObservation:v,onClick:b,chartId:x,selection:w,linkedHover:k,loading:A,loadingContent:j,legendInteraction:S,stroke:C,strokeWidth:O,opacity:M}=n,{width:P,height:_,enableHover:L,showLabels:T=!0,title:N,description:R,summary:$,accessibleTable:D}=o,B=vu({nodes:t.useMemo(()=>gu(null!=i?i:null,a),[i,a]),edges:void 0,inferNodes:!1,colorBy:h?void 0:u,colorScheme:d,showLegend:!1,legendInteraction:S,selection:w,linkedHover:k,onObservation:v,onClick:b,chartType:"CirclePack",chartId:x,marginDefaults:o.marginDefaults,userMargin:r,width:P,height:_,loading:A,loadingContent:j}),I=t.useMemo(()=>new Map,[]),E=t.useMemo(()=>e=>{const t={stroke:"currentColor",strokeWidth:1,strokeOpacity:.3,fillOpacity:g};return t.fill=h?be[(e.depth||0)%be.length]:u?we(e.data||e,u,B.colorScale):Cr(void 0,B.themeCategorical,d,void 0,I),t},[u,h,B.colorScale,g,B.themeCategorical,d,I]),F=t.useMemo(()=>ls(E,{stroke:C,strokeWidth:O,opacity:M}),[E,C,O,M]),H=t.useMemo(()=>yu(l),[l]),z=is({componentName:"CirclePack",data:i});return z?e.jsx(Wr,{componentName:"CirclePack",message:z,width:P,height:_}):B.loadingEl?B.loadingEl:e.jsx(Vr,{componentName:"CirclePack",width:P,height:_,children:e.jsx(fu,Object.assign({chartType:"circlepack"},null!=i&&{data:i},{size:[P,_],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:B.margin,nodeIDAccessor:c,childrenAccessor:a,hierarchySum:H,padding:p,nodeStyle:F,colorBy:u,colorScheme:B.effectivePalette,colorByDepth:h,nodeLabel:T?f||c:void 0,showLabels:T,enableHover:L,tooltipContent:!1===y?()=>null:ei(y)||void 0,customHoverBehavior:k||v||b?B.customHoverBehavior:void 0,customClickBehavior:v||b?B.customClickBehavior:void 0},S&&"none"!==S&&{legendHoverBehavior:B.legendState.onLegendHover,legendClickBehavior:B.legendState.onLegendClick,legendHighlightedCategory:B.legendState.highlightedCategory,legendIsolatedCategories:B.legendState.isolatedCategories},{className:s,title:N,description:R,summary:$,accessibleTable:D},null!=n.animate&&{animate:n.animate},m))})}Du.displayName="ProcessSankey",Bu.displayName="TreeDiagram",Iu.displayName="Treemap",Eu.displayName="CirclePack";const Fu=be;function Hu(n){const o=Rr(n.mode,{width:n.width,height:n.height,enableHover:n.enableHover,showLabels:n.showLabels,title:n.title,description:n.description,accessibleTable:n.accessibleTable,summary:n.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:f=2.95,speed:g=.25,revolution:p,revolutionStyle:y,eccentricity:m=1,showRings:v=!0,nodeRadius:b=6,showLabels:x=!1,animated:w=!0,tooltip:k,foregroundGraphics:A,annotations:j,frameProps:S={},onObservation:C,onClick:O,chartId:M,selection:P,linkedHover:_,loading:L,loadingContent:T,stroke:N,strokeWidth:R,opacity:$}=n,{width:D,height:B,enableHover:I,title:E,description:F,summary:H,accessibleTable:z}=o,W=vu({nodes:t.useMemo(()=>gu(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:B,loading:L,loadingContent:T}),G=t.useMemo(()=>new Map,[]),{colorScale:Y,customClickBehavior:q,customHoverBehavior:V,themeCategorical:X}=W,U=t.useMemo(()=>{if(Array.isArray(u))return u;const e=ye[u];return Array.isArray(e)?e:me},[u]),K=t.useMemo(()=>e=>{var t;const n={stroke:"#fff",strokeWidth:1},o=0===(null!==(t=e.depth)&&void 0!==t?t:0);return n.fill=d?o?U[0]:Fu[(e.depth||0)%Fu.length]:c?we(e.data||e,c,Y):Cr(void 0,X,u,void 0,G),n.opacity=o?1:.85,n},[c,d,Y,U,X,u,G]),Q=t.useMemo(()=>ls(K,{stroke:N,strokeWidth:R,opacity:$}),[K,N,R,$]),Z=t.useMemo(()=>()=>({stroke:"rgba(128,128,128,0.35)",strokeWidth:.5,opacity:1}),[]),J=t.useMemo(()=>{if(V)return e=>{V(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[V]),ee=t.useMemo(()=>{if(q)return e=>{q(e&&e.data&&void 0!==e.data.data?Object.assign(Object.assign({},e),{data:e.data.data}):e)}},[q]),te=is({componentName:"OrbitDiagram",data:i});return te?e.jsx(Wr,{componentName:"OrbitDiagram",message:te,width:D,height:B}):W.loadingEl?W.loadingEl:e.jsx(Vr,{componentName:"OrbitDiagram",width:D,height:B,children:e.jsx(fu,Object.assign({chartType:"orbit"},null!=i&&{data:i},{size:[D,B],responsiveWidth:n.responsiveWidth,responsiveHeight:n.responsiveHeight,margin:W.margin,nodeIDAccessor:l,childrenAccessor:a,nodeStyle:Q,edgeStyle:Z,colorBy:c,colorScheme:W.effectivePalette,colorByDepth:d,nodeSize:b,nodeLabel:x?l:void 0,showLabels:x,enableHover:!w&&I,tooltipContent:w?void 0:!1===k?()=>null:ei(k)||void 0,customHoverBehavior:_||C||O?J:void 0,customClickBehavior:C||O?ee:void 0,foregroundGraphics:A,annotations:j,className:s,title:E,description:F,summary:H,orbitMode:h,orbitSize:f,orbitSpeed:g,orbitRevolution:p,orbitRevolutionStyle:y,orbitEccentricity:m,orbitShowRings:v,orbitAnimated:w,accessibleTable:z},null!=n.animate&&{animate:n.animate},S))})}Hu.displayName="OrbitDiagram";const zu={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"},Wu={opacity:.7,marginRight:4};function Gu(e,t,n){if(null!=e)return"function"==typeof t?t(e):e["string"==typeof t?t:n]}function Yu(e){return null==e?"":"number"==typeof e?Number.isInteger(e)?e+"":e.toFixed(2):e instanceof Date?e.toLocaleString():e+""}function qu(t={}){const{timeAccessor:n,valueAccessor:o,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=Gu(a,n,"time"),c=Gu(a,o,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:zu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:Wu,children:[i,":"]}),Yu(l)]}),e.jsxs("div",{children:[e.jsxs("span",{style:Wu,children:[r,":"]}),Yu(c)]})]})}}function Vu(e,t){var n;return null!=e?e:Math.max(null!==(n=null==t?void 0:t.length)&&void 0!==n?n:0,200)}const Xu=t.forwardRef(function(n,o){var i,r,s,a,l;const c=Rr(n.mode,{width:null!==(r=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==r?r:n.width,height:null!==(a=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,stroke:k="#007bff",strokeWidth:A=2,strokeDasharray:j,opacity:S,background:C,tooltipContent:O,tooltip:M,onHover:P,annotations:_,autoPlaceAnnotations:L,svgAnnotationRules:T,tickFormatTime:N,tickFormatValue:R,decay:$,pulse:D,staleness:B,transition:I,linkedHover:E,selection:F,onObservation:H,chartId:z,loading:W,loadingContent:G,emptyContent:Y,emphasis:q,legendPosition:V}=n,X=c.showAxes,U=c.enableHover,K=null!=d?d:c.marginDefaults,Q=null!=u?u:[c.width,c.height],Z=null!==(l=null!=O?O:M)&&void 0!==l?l:qu({timeAccessor:m,valueAccessor:v}),J=t.useRef(null),{customHoverBehavior:ee}=Pr({selection:F,linkedHover:E,unwrapData:!0,onObservation:H,chartType:"RealtimeLineChart",chartId:z}),te=t.useCallback(e=>{P&&P(e),ee(e)},[P,ee]);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=J.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=J.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=J.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=J.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=J.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ne=Qr(W,Q[0],Q[1],G),oe=ne?null:Kr(y,Q[0],Q[1],Y),ie={stroke:k,strokeWidth:A,strokeDasharray:j};null!=S&&(ie.opacity=S);const re=Vu(p,y);return ne||oe||e.jsx(Fi,{ref:J,chartType:"line",runtimeMode:"streaming",size:Q,margin:K,className:q?`${h||""} semiotic-emphasis-${q}`.trim():h,arrowOfTime:f,windowMode:g,windowSize:re,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:w,lineStyle:ie,showAxes:X,background:C,hoverAnnotation:U,tooltipContent:Z,customHoverBehavior:te,annotations:_,autoPlaceAnnotations:L,svgAnnotationRules:T,tickFormatTime:N,tickFormatValue:R,decay:$,pulse:D,staleness:B,transition:I,pointIdAccessor:n.pointIdAccessor,legendPosition:V})});function Uu(e,t,n){const o="function"==typeof t?t(e):e[null!=t?t:n];if(null==o)return null;if(o instanceof Date)return o.getTime();if("string"==typeof o&&""===o.trim())return null;const i=Number(o);return Number.isFinite(i)?i:null}Xu.displayName="RealtimeLineChart";const Ku=t.forwardRef(function(n,o){var i,r,s,a,l;const c=Rr(n.mode,{width:null!==(r=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==r?r:n.width,height:null!==(a=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==a?a:n.height,showAxes:n.showAxes,enableHover:null!=n.enableHover?!!n.enableHover:void 0,linkedHover:n.linkedHover}),{binSize:u,size:d,margin:h,className:f,arrowOfTime:g="right",windowMode:p="sliding",windowSize:y,data:m,timeAccessor:v,valueAccessor:b,direction:x="up",timeExtent:w,valueExtent:k,extentPadding:A,categoryAccessor:j,colors:S,fill:C,stroke:O,strokeWidth:M,opacity:P,gap:_,background:L,tooltipContent:T,tooltip:N,onHover:R,annotations:$,autoPlaceAnnotations:D,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:E,linkedHover:F,selection:H,decay:z,pulse:W,staleness:G,transition:Y,onObservation:q,chartId:V,loading:X,loadingContent:U,emptyContent:K,emphasis:Q,legendPosition:Z,brush:J,onBrush:ee,linkedBrush:te}=n,ne=c.showAxes,oe=c.enableHover,ie=null!=h?h:c.marginDefaults,re=null!=d?d:[c.width,c.height],se=null!==(l=null!=T?T:N)&&void 0!==l?l:function(t={}){const{timeAccessor:n,valueAccessor:o}=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=Gu(r,n,"time"),i=Gu(r,o,"value");return e.jsxs("div",{className:"semiotic-tooltip",style:zu,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"x:"}),Yu(t)]}),e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"y:"}),Yu(i)]})]})}return e.jsxs("div",{className:"semiotic-tooltip",style:zu,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"range:"}),Yu(r.binStart),"–",Yu(r.binEnd)]}),null!=r.total&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"count:"}),Yu(r.total)]}),null!=r.category&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"category:"}),Yu(r.category)]})]})}}({timeAccessor:v,valueAccessor:b}),ae=t.useRef(null),{customHoverBehavior:le}=Pr({selection:H,linkedHover:F,unwrapData:!0,onObservation:q,chartType:"RealtimeHistogram",chartId:V}),ce=t.useCallback(e=>{R&&R(e),le(e)},[R,le]),ue=!0===J?{dimension:"x",snap:"bin"}:"x"===J?{dimension:"x"}:"object"==typeof J?J:void 0,de=hr(te),he=er(Object.assign({name:(null==de?void 0:de.name)||"__unused_hist_brush__",xField:(null==de?void 0:de.xField)||("string"==typeof v?v:"time")},(null==de?void 0:de.yField)?{yField:de.yField}:{})),fe=t.useRef(he.brushInteraction);fe.current=he.brushInteraction;const ge=t.useCallback(e=>{if(ee&&ee(e),q&&q(e?{type:"brush",extent:e,timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:V}:{type:"brush-end",timestamp:Date.now(),chartType:"RealtimeHistogram",chartId:V}),de){const t=fe.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)}},[ee,q,V,de]);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=ae.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=ae.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=ae.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=ae.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=ae.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=ae.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=ae.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const pe=Qr(X,re[0],re[1],U),ye=pe?null:Kr(m,re[0],re[1],K),me={};null!=C&&(me.fill=C),null!=O&&(me.stroke=O),null!=M&&(me.strokeWidth=M),null!=P&&(me.opacity=P),null!=_&&(me.gap=_);const ve=Q?`${f||""} semiotic-emphasis-${Q}`.trim():f,be=Vu(y,m),xe=t.useMemo(()=>"down"!==x?k:function({data:e,valueAccessor:t,timeAccessor:n,binSize:o,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=Uu(i,n,"time"),r=Uu(i,t,"value");if(null==e||null==r)continue;const l=Math.floor(e/o)*o;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:k,extentPadding:A}),[x,m,b,v,u,k,A]);return pe||ye||e.jsx(Fi,{ref:ae,chartType:"bar",runtimeMode:"streaming",size:re,margin:ie,className:ve,arrowOfTime:g,windowMode:p,windowSize:be,data:m,timeAccessor:v,valueAccessor:b,xExtent:w,yExtent:xe,extentPadding:A,binSize:u,categoryAccessor:j,barColors:S,barStyle:me,showAxes:ne,background:L,hoverAnnotation:oe,tooltipContent:se,customHoverBehavior:ce,annotations:$,autoPlaceAnnotations:D,svgAnnotationRules:B,tickFormatTime:I,tickFormatValue:E,decay:z,pulse:W,staleness:G,transition:Y,pointIdAccessor:n.pointIdAccessor,legendPosition:Z,brush:ue||(te?{dimension:"x"}:void 0),onBrush:ue||te?ge:void 0})});function Qu(t){return e.jsx(Ku,Object.assign({},t,{windowMode:"growing"}))}Ku.displayName="RealtimeHistogram",Qu.displayName="TemporalHistogram";const Zu=t.forwardRef(function(n,o){var i,r,s,a,l;const c=Rr(n.mode,{width:null!==(r=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==r?r:n.width,height:null!==(a=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,categoryAccessor:k,colors:A,radius:j,fill:S,opacity:C,stroke:O,strokeWidth:M,background:P,tooltipContent:_,tooltip:L,onHover:T,annotations:N,autoPlaceAnnotations:R,svgAnnotationRules:$,tickFormatTime:D,tickFormatValue:B,linkedHover:I,selection:E,onObservation:F,chartId:H,loading:z,loadingContent:W,emptyContent:G,emphasis:Y,legendPosition:q}=n,V=c.showAxes,X=c.enableHover,U=null!=d?d:c.marginDefaults,K=null!=u?u:[c.width,c.height],Q=null!==(l=null!=_?_:L)&&void 0!==l?l:qu({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=Pr({selection:E,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeSwarmChart",chartId:H}),ee=t.useCallback(e=>{T&&T(e),J(e)},[T,J]);t.useImperativeHandle(o,()=>({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,n;return null!==(n=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=Z.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=Qr(z,K[0],K[1],W),ne=te?null:Kr(y,K[0],K[1],G),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 ie=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,re=Vu(p,y);return te||ne||e.jsx(Fi,{ref:Z,chartType:"swarm",runtimeMode:"streaming",size:K,margin:U,className:ie,arrowOfTime:f,windowMode:g,windowSize:re,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:w,categoryAccessor:k,barColors:A,swarmStyle:oe,showAxes:V,background:P,hoverAnnotation:X,tooltipContent:Q,customHoverBehavior:ee,annotations:N,autoPlaceAnnotations:R,svgAnnotationRules:$,tickFormatTime:D,tickFormatValue:B,legendPosition:q,pointIdAccessor:n.pointIdAccessor})});Zu.displayName="RealtimeSwarmChart";const Ju=t.forwardRef(function(n,o){var i,r,s,a,l;const c=Rr(n.mode,{width:null!==(r=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==r?r:n.width,height:null!==(a=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,timeExtent:b,valueExtent:x,extentPadding:w,positiveColor:k,negativeColor:A,connectorStroke:j,connectorWidth:S,gap:C,stroke:O,strokeWidth:M,opacity:P,background:_,tooltipContent:L,tooltip:T,onHover:N,annotations:R,autoPlaceAnnotations:$,svgAnnotationRules:D,tickFormatTime:B,tickFormatValue:I,linkedHover:E,selection:F,onObservation:H,chartId:z,loading:W,loadingContent:G,emptyContent:Y,emphasis:q,legendPosition:V}=n,X=c.showAxes,U=c.enableHover,K=null!=d?d:c.marginDefaults,Q=null!=u?u:[c.width,c.height],Z=null!==(l=null!=L?L:T)&&void 0!==l?l:function(t={}){const{timeAccessor:n,valueAccessor:o}=t;return t=>{var i,r;const s=null!==(i=null==t?void 0:t.data)&&void 0!==i?i:null,a=Gu(s,n,"time"),l=null!==(r=null==s?void 0:s.delta)&&void 0!==r?r:Gu(s,o,"value"),c=null==s?void 0:s.cumEnd,u="number"==typeof l?0>l?Yu(l):"+"+Yu(l):Yu(l);return e.jsxs("div",{className:"semiotic-tooltip",style:zu,children:[e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"x:"}),Yu(a)]}),e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"Δ:"}),u]}),null!=c&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"total:"}),Yu(c)]})]})}}({timeAccessor:m,valueAccessor:v}),J=t.useRef(null),{customHoverBehavior:ee}=Pr({selection:F,linkedHover:E,unwrapData:!0,onObservation:H,chartType:"RealtimeWaterfallChart",chartId:z}),te=t.useCallback(e=>{N&&N(e),ee(e)},[N,ee]);t.useImperativeHandle(o,()=>({push:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.push(e)},pushMany:e=>{var t;return null===(t=J.current)||void 0===t?void 0:t.pushMany(e)},remove:e=>{var t,n;return null!==(n=null===(t=J.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=J.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},clear:()=>{var e;return null===(e=J.current)||void 0===e?void 0:e.clear()},getData:()=>{var e,t;return null!==(t=null===(e=J.current)||void 0===e?void 0:e.getData())&&void 0!==t?t:[]},getScales:()=>{var e,t;return null!==(t=null===(e=J.current)||void 0===e?void 0:e.getScales())&&void 0!==t?t:null}}),[]);const ne=Qr(W,Q[0],Q[1],G),oe=ne?null:Kr(y,Q[0],Q[1],Y),ie={};null!=k&&(ie.positiveColor=k),null!=A&&(ie.negativeColor=A),null!=j&&(ie.connectorStroke=j),null!=S&&(ie.connectorWidth=S),null!=C&&(ie.gap=C),null!=O&&(ie.stroke=O),null!=M&&(ie.strokeWidth=M),null!=P&&(ie.opacity=P);const re=q?`${h||""} semiotic-emphasis-${q}`.trim():h,se=Vu(p,y);return ne||oe||e.jsx(Fi,{ref:J,chartType:"waterfall",runtimeMode:"streaming",size:Q,margin:K,className:re,arrowOfTime:f,windowMode:g,windowSize:se,data:y,timeAccessor:m,valueAccessor:v,xExtent:b,yExtent:x,extentPadding:w,waterfallStyle:ie,showAxes:X,background:_,hoverAnnotation:U,tooltipContent:Z,customHoverBehavior:te,annotations:R,autoPlaceAnnotations:$,svgAnnotationRules:D,tickFormatTime:B,tickFormatValue:I,legendPosition:V,pointIdAccessor:n.pointIdAccessor})});Ju.displayName="RealtimeWaterfallChart";const ed=t.forwardRef(function(n,o){var i,r,s,a,l;const c=Rr(n.mode,{width:null!==(r=null===(i=n.size)||void 0===i?void 0:i[0])&&void 0!==r?r:n.width,height:null!==(a=null===(s=n.size)||void 0===s?void 0:s[1])&&void 0!==a?a:n.height,enableHover:null!=n.enableHover?!!n.enableHover:void 0}),{size:u,margin:d,className:h,arrowOfTime:f="right",windowMode:g="sliding",windowSize:p,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,timeExtent:x,valueExtent:w,extentPadding:k,heatmapXBins:A=20,heatmapYBins:j=20,aggregation:S="count",background:C,tooltipContent:O,tooltip:M,onHover:P,annotations:_,autoPlaceAnnotations:L,svgAnnotationRules:T,tickFormatTime:N,tickFormatValue:R,decay:$,pulse:D,staleness:B,linkedHover:I,selection:E,onObservation:F,chartId:H,loading:z,loadingContent:W,emptyContent:G,emphasis:Y,legendPosition:q}=n,V=c.showAxes,X=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:function(t={}){const{timeAccessor:n,valueAccessor:o,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:Gu(u,n,"time"),h=null!==(l=null==u?void 0:u.yCenter)&&void 0!==l?l:Gu(u,o,"value"),f=null==u?void 0:u.count,g=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:zu,children:[e.jsxs("div",{children:[e.jsxs("span",{style:Wu,children:[i,":"]}),Yu(d)]}),e.jsxs("div",{children:[e.jsxs("span",{style:Wu,children:[r,":"]}),Yu(h)]}),null!=f&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"count:"}),Yu(f)]}),"sum"===y&&null!=g&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"sum:"}),Yu(g)]}),"mean"===y&&null!=p&&e.jsxs("div",{children:[e.jsx("span",{style:Wu,children:"mean:"}),Yu(p)]})]})}}({timeAccessor:m,valueAccessor:v}),Z=t.useRef(null),{customHoverBehavior:J}=Pr({selection:E,linkedHover:I,unwrapData:!0,onObservation:F,chartType:"RealtimeHeatmap",chartId:H}),ee=t.useCallback(e=>{P&&P(e),J(e)},[P,J]);t.useImperativeHandle(o,()=>({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,n;return null!==(n=null===(t=Z.current)||void 0===t?void 0:t.remove(e))&&void 0!==n?n:[]},update:(e,t)=>{var n,o;return null!==(o=null===(n=Z.current)||void 0===n?void 0:n.update(e,t))&&void 0!==o?o:[]},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=Qr(z,K[0],K[1],W),ne=te?null:Kr(y,K[0],K[1],G),oe=Y?`${h||""} semiotic-emphasis-${Y}`.trim():h,ie=Vu(p,y);return te||ne||e.jsx(Fi,{ref:Z,chartType:"heatmap",runtimeMode:"streaming",size:K,margin:U,className:oe,arrowOfTime:f,windowMode:g,windowSize:ie,data:y,timeAccessor:m,valueAccessor:v,categoryAccessor:b,xExtent:x,yExtent:w,extentPadding:k,heatmapXBins:A,heatmapYBins:j,heatmapAggregation:S,showAxes:V,background:C,hoverAnnotation:X,tooltipContent:Q,customHoverBehavior:ee,annotations:_,autoPlaceAnnotations:L,svgAnnotationRules:T,tickFormatTime:N,tickFormatValue:R,decay:$,pulse:D,staleness:B,legendPosition:q,pointIdAccessor:n.pointIdAccessor})});function td(e,t={}){var n,o,i,r,s,a,l;if("function"==typeof e)return e;const c=null!==(n=t.locale)&&void 0!==n?n:"en-US",u=null!==(o=t.currency)&&void 0!==o?o:"USD";if("currency"===e){const e=null!==(i=t.precision)&&void 0!==i?i:2,n=new Intl.NumberFormat(c,{style:"currency",currency:u,maximumFractionDigits:e,minimumFractionDigits:e});return e=>n.format(e)}if("percent"===e){const e=null!==(r=t.precision)&&void 0!==r?r:1,n=new Intl.NumberFormat(c,{style:"percent",maximumFractionDigits:e,minimumFractionDigits:0});return e=>n.format(e)}if("compact"===e){const e=null!==(s=t.precision)&&void 0!==s?s:1,n=new Intl.NumberFormat(c,{notation:"compact",maximumFractionDigits:e,minimumFractionDigits:0});return e=>n.format(e)}if("duration"===e)return e=>function(e){if(!Number.isFinite(e))return e+"";const t=0>e?"-":"",n=Math.abs(e);if(1e3>n)return`${t}${Math.round(n)}ms`;const o=n/1e3;if(60>o)return`${t}${i=o,Math.round(100*i)/100+""}s`;var i;const r=o/60;if(60>r){const e=Math.floor(r),n=Math.round(o-60*e);return 0===n?`${t}${e}m`:`${t}${e}m ${n}s`}const s=r/60;if(24>s){const e=Math.floor(s),n=Math.round(r-60*e);return 0===n?`${t}${e}h`:`${t}${e}h ${n}m`}const a=Math.floor(s/24),l=Math.round(s-24*a);return 0===l?`${t}${a}d`:`${t}${a}d ${l}h`}(e);const d=null!==(a=t.precision)&&void 0!==a?a:0,h=new Intl.NumberFormat(c,{notation:null!==(l=t.notation)&&void 0!==l?l:"standard",maximumFractionDigits:d,minimumFractionDigits:0});return e=>h.format(e)}function nd(e,t,n){return`${null!=t?t:""}${e}${null!=n?n:""}`}ed.displayName="RealtimeHeatmap";const od={tile:{width:280,height:184,align:"start",labelSize:13,captionSize:11,valueSize:40,deltaSize:13,padding:{top:14,right:16,bottom:14,left:16},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:44},presentation:{width:540,height:320,align:"center",labelSize:18,captionSize:14,valueSize:96,deltaSize:18,padding:{top:32,right:32,bottom:32,left:32},background:"var(--semiotic-surface, transparent)",border:!0,showHeader:!0,showDelta:!0,showTrend:!0,showChart:!0,chartSize:80},inline:{width:void 0,height:void 0,align:"inherit",labelSize:0,captionSize:0,valueSize:0,deltaSize:0,padding:{top:0,right:0,bottom:0,left:0},background:"transparent",border:!1,showHeader:!1,showDelta:!0,showTrend:!1,showChart:!1,chartSize:0},thumbnail:{width:96,height:56,align:"center",labelSize:0,captionSize:0,valueSize:22,deltaSize:0,padding:{top:4,right:6,bottom:4,left:6},background:"transparent",border:!1,showHeader:!1,showDelta:!1,showTrend:!1,showChart:!1,chartSize:0}};function id(e,t,n){return void 0===e?n:"function"==typeof e?e(t):e}function rd(e){return"positive"===e?"var(--semiotic-success, currentColor)":"negative"===e?"var(--semiotic-danger, currentColor)":"var(--semiotic-text-secondary, currentColor)"}function sd(e){return"positive"===e?"▲":"negative"===e?"▼":"■"}const ad=t.forwardRef((n,o)=>{var i,r,s,a;const{value:l,label:c,caption:u,format:d,locale:h,currency:f,precision:g,prefix:p,suffix:y,unit:m,comparison:v,target:b,delta:x,deltaFormat:w,showDeltaPercent:k,direction:A,sentiment:j,thresholds:S,windowSize:C=60,mode:O="tile",align:M,width:P,height:_,padding:L,emphasis:T,color:N,background:R,borderColor:$,borderRadius:D,className:B,style:I,animate:E,stalenessThreshold:F,staleLabel:H,headerSlot:z,valueSlot:W,deltaSlot:G,trendSlot:Y,chartSlot:q,chartSize:V,footerSlot:X,onClick:U,onObservation:K,chartId:Q,description:Z,summary:J,loading:ee,loadingContent:te,emptyContent:ne}=n,oe=null!==(i=od[O])&&void 0!==i?i:od.tile,ie=null!=M?M:oe.align,re=null!=P?P:oe.width,se=null!=_?_:oe.height,ae=oi(),[le,ce]=t.useState([]),[ue,de]=t.useState(null),[he,fe]=t.useState(null),[ge,pe]=t.useState(null),ye=t.useRef([]),me=t.useRef(null),ve=t.useRef(l);t.useEffect(()=>{ve.current=l},[l]);const be=t.useRef(C);t.useEffect(()=>{be.current=C},[C]);const xe=t.useCallback(e=>{const t="number"==typeof e?{value:e,time:Date.now()}:Object.assign({time:Date.now()},e),n="number"==typeof t.time?t.time:t.time instanceof Date?t.time.getTime():Date.now();return Object.assign(Object.assign({},t),{time:n})},[]),we=t.useCallback(e=>{if(0===e.length)return;const t=be.current,n=e.map(xe);let o=ye.current.concat(n);o.length>t&&(o=o.slice(o.length-t)),ye.current=o;const i=n[n.length-1];me.current=i.value,ce(o),de(i.value);for(let e=n.length-1;e>=0;e--){const t=n[e].comparison;if(null!=t){fe(t);break}}pe(i.time)},[xe]),ke=t.useCallback(e=>we([e]),[we]);t.useImperativeHandle(o,()=>({push:e=>ke(e),pushMany:e=>we(e),clear:()=>{ye.current=[],me.current=null,ce([]),de(null),fe(null),pe(null)},getValue:()=>{var e;return null!==(e=me.current)&&void 0!==e?e:Number.isFinite(ve.current)?ve.current:null},getData:()=>ye.current.slice()}),[ke,we]);const Ae=null!=ue?ue:l,je=null==Ae||"number"!=typeof Ae||!Number.isFinite(Ae),Se=t.useMemo(()=>td(null!=d?d:"number",{locale:h,currency:f,precision:g}),[d,h,f,g]),Ce=t.useMemo(()=>{var e;return td(null!==(e=null!=w?w:d)&&void 0!==e?e:"number",{locale:h,currency:f,precision:null==w&&null==d?0:g})},[w,d,h,f,g]),Oe=null!=E&&E,Me=t.useRef(("object"==typeof Oe&&!1===Oe.intro||!Oe)&&Number.isFinite(l)?l:0),Pe=function(e,n,o){const[i,r]=t.useState(e),s=t.useRef(null),a=t.useRef(e),l=t.useRef(0),c=t.useRef(e);return t.useEffect(()=>{if(!Number.isFinite(e))return void r(e);if(!n||o)return void r(e);const t="object"==typeof n&&n.duration?n.duration:300,u="object"==typeof n&&"linear"===n.easing?"linear":"ease-out";a.current=i,c.current=e,l.current="undefined"!=typeof performance?performance.now():Date.now();const d="linear"===u?e=>e:e=>1-Math.pow(1-e,3),h=e=>{const n=Math.min(1,(e-l.current)/t),o=d(n);r(a.current+(c.current-a.current)*o),1>n?s.current=requestAnimationFrame(h):(s.current=null,r(c.current))};return s.current=requestAnimationFrame(h),()=>{null!=s.current&&cancelAnimationFrame(s.current),s.current=null}},[e,n,o]),i}(Number.isFinite(Ae)?Ae:Me.current,Oe,ae),_e=Oe?Pe:Number.isFinite(Ae)?Ae:0,Le=t.useMemo(()=>function(e,t){if(!t||0===t.length)return null;if(!Number.isFinite(e))return null;const n=t.filter(e=>Number.isFinite(e.at)||e.at===-1/0).slice().sort((e,t)=>e.at-t.at);let o=null;for(const t of n){if(t.at>e)break;o=t}return o}(Number.isFinite(Ae)?Ae:NaN,S),[Ae,S]),Te=Le?Le.level:"neutral",Ne=null!=N?N:function(e,t){return t||("neutral"===e?"var(--semiotic-text, currentColor)":`var(--semiotic-${e}, currentColor)`)}(Te,null==Le?void 0:Le.color),Re=null!==(r=null!=he?he:null==v?void 0:v.value)&&void 0!==r?r:null,$e=null!=x?x:null!=Re&&Number.isFinite(Ae)?Ae-Re:null,De=function(e,t,n){if(n&&"auto"!==n)return n;if(null==e||0===e||!Number.isFinite(e))return"neutral";const o=null!=t?t:"higher-is-better";return"neutral"===o?"neutral":("higher-is-better"===o?e>0:0>e)?"positive":"negative"}($e,null!==(a=null!==(s=null==v?void 0:v.direction)&&void 0!==s?s:null==b?void 0:b.direction)&&void 0!==a?a:A,j),Be=null!=$e&&Number.isFinite($e)?function(e,t){return Number.isFinite(e)?0===e?t(0):`${e>0?"+":"−"}${t(Math.abs(e))}`:""}($e,Ce):null,Ie=null!=Re&&Number.isFinite(Ae)&&(null==k||k)?function(e,t,n="en-US",o=1){if(!Number.isFinite(e)||!Number.isFinite(t))return null;if(0===e)return null;const i=(t-e)/Math.abs(e);return new Intl.NumberFormat(n,{style:"percent",maximumFractionDigits:o,minimumFractionDigits:0,signDisplay:"exceptZero"}).format(i)}(Re,Ae,h):null,Ee=t.useMemo(()=>{if(!b||!Number.isFinite(Ae)||!b.value)return null;const e=Ae/b.value;return new Intl.NumberFormat(null!=h?h:"en-US",{style:"percent",maximumFractionDigits:0}).format(e)},[b,Ae,h]),Fe=t.useMemo(()=>{var e,t;return td(null!==(t=null!==(e=null==b?void 0:b.format)&&void 0!==e?e:d)&&void 0!==t?t:"number",{locale:h,currency:f,precision:g})},[null==b?void 0:b.format,d,h,f,g]),He=t.useMemo(()=>{var e,t;return td(null!==(t=null!==(e=null==v?void 0:v.format)&&void 0!==e?e:d)&&void 0!==t?t:"number",{locale:h,currency:f,precision:g})},[null==v?void 0:v.format,d,h,f,g]),ze=function(e,n){const[o,i]=t.useState(!1);return t.useEffect(()=>{if(!n||null==e)return void i(!1);const t=()=>{const t=Date.now()-e;i(t>=n)};t();const o=setInterval(t,Math.max(250,Math.floor(n/4)));return()=>clearInterval(o)},[e,n]),o}(ge,F),We=Number.isFinite(_e)?nd(Se(_e),p,y):"",Ge={value:je?null:Ae,formattedValue:We,level:Te,color:Ne,delta:$e,deltaFormatted:Be,deltaPercent:Ie,sentiment:De,isStale:ze,pushBuffer:le},Ye=null!=Z?Z:function(e){var t;const n=[];if(e.label&&n.push(e.label+":"),n.push(e.unit?`${e.formattedValue} ${e.unit}`:e.formattedValue),e.deltaFormatted){const t=e.delta;n.push(`${null!=t&&Number.isFinite(t)&&0!==t?t>0?"up":"down":"change"} ${e.deltaFormatted}${e.deltaPercent?` (${e.deltaPercent})`:""}${e.comparisonLabel?" from "+e.comparisonLabel:""}`)}return e.targetPercent&&e.targetLabel&&n.push(`${e.targetPercent} of ${e.targetLabel}`),e.stale&&n.push(null!==(t=e.staleLabel)&&void 0!==t?t:"stale"),n.join(", ")}({label:c,formattedValue:Number.isFinite(Ae)?nd(Se(Ae),p,y):"",unit:m,comparisonLabel:null==v?void 0:v.label,delta:$e,deltaFormatted:Be,deltaPercent:Ie,targetLabel:null==b?void 0:b.label,targetPercent:Ee,stale:ze,staleLabel:H}),qe="number"==typeof L?{top:L,right:L,bottom:L,left:L}:Object.assign(Object.assign({},oe.padding),null!=L?L:{}),Ve="end"===ie?"flex-end":"center"===ie?"center":"start"===ie?"flex-start":"inherit",Xe=Object.assign({position:"relative",boxSizing:"border-box",width:re,height:se,padding:`${qe.top}px ${qe.right}px ${qe.bottom}px ${qe.left}px`,background:null!=R?R:oe.background,border:oe.border?"1px solid "+(null!=$?$:"var(--semiotic-border, #e2e2e2)"):void 0,borderRadius:"number"==typeof D?D+"px":null!=D?D:"var(--semiotic-border-radius, 8px)",display:"inline"===O?"inline-flex":"flex",flexDirection:"column",alignItems:"inherit"===Ve?void 0:Ve,textAlign:ie,fontFamily:"var(--semiotic-font-family, system-ui, sans-serif)",color:"var(--semiotic-text, #111)",opacity:ze?.55:1,transition:"opacity 240ms ease-out",gridColumn:"primary"===T?"span 2":void 0,cursor:U?"pointer":void 0},I),Ue=t.useCallback(e=>{const t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top,i={value:je?NaN:Ae,level:Te,delta:$e};U&&U(i,{x:n,y:o}),K&&K({type:"click",datum:i,x:n,y:o,chartType:"BigNumber",chartId:Q,timestamp:Date.now()})},[U,K,Q,je,Ae,Te,$e]),Ke="inline"===O?"span":"div",Qe=["semiotic-bignumber","semiotic-bignumber--mode-"+O,"semiotic-bignumber--level-"+Te,"semiotic-bignumber--sentiment-"+De,ze?"semiotic-bignumber--stale":null,B].filter(Boolean).join(" "),Ze="positive"===De?"up":"negative"===De?"down":"flat";if(ee){const t="number"==typeof re?re:280,n="number"==typeof se?se:160;return e.jsx(Ke,{role:"status","aria-live":"polite","aria-busy":"true",className:Qe+" semiotic-bignumber--loading",style:Object.assign(Object.assign({},Xe),{opacity:1}),children:null!=te?te:e.jsx(cd,{width:t,height:n,mode:O})})}return je?!1===ne?null:e.jsx(Ke,{role:"status","aria-label":c?c+": no value":"no value",className:Qe+" semiotic-bignumber--empty",style:Object.assign(Object.assign({},Xe),{color:"var(--semiotic-text-secondary, #999)",fontSize:13,alignItems:"center",justifyContent:"center"}),children:null!=ne?ne:"—"}):e.jsx(Vr,{componentName:"BigNumber",width:"number"==typeof re?re:280,height:"number"==typeof se?se:160,children:e.jsxs(Ke,{role:"group","aria-label":Ye,"data-chart":"BigNumber","data-mode":O,"data-level":Te,"data-stale":ze?"true":void 0,"data-sentiment":De,className:Qe,style:Xe,onClick:U||K?Ue:void 0,children:[oe.showHeader&&(c||u||z)?e.jsx("div",{className:"semiotic-bignumber__header",style:{display:"flex",flexDirection:"column",gap:2,marginBottom:6,paddingRight:oe.showChart&&null!=q?(null!=V?V:oe.chartSize)+8:0},children:id(z,Ge,e.jsxs(e.Fragment,{children:[c?e.jsx("span",{className:"semiotic-bignumber__label",style:{fontSize:oe.labelSize,color:"var(--semiotic-text-secondary, #6b7280)",fontWeight:500,letterSpacing:.2},children:c}):null,u?e.jsx("span",{className:"semiotic-bignumber__caption",style:{fontSize:oe.captionSize,color:"var(--semiotic-text-secondary, #9ca3af)"},children:u}):null]}))}):null,id(W,Ge,e.jsxs(Ke,{className:"semiotic-bignumber__value semiotic-bignumber__value--"+Te,style:{display:"inline"===O?"inline-flex":"flex",alignItems:"baseline",gap:6,fontVariantNumeric:"tabular-nums",fontWeight:600,color:Ne,fontSize:oe.valueSize||void 0,lineHeight:1.05},children:[e.jsx("span",{className:"semiotic-bignumber__value-text",children:We}),m?e.jsx("span",{className:"semiotic-bignumber__unit",style:{fontSize:oe.valueSize?Math.max(11,Math.round(.32*oe.valueSize)):"0.75em",color:"var(--semiotic-text-secondary, #9ca3af)",fontWeight:500},children:m}):null]})),oe.showDelta&&(Be||b||v)?e.jsx(Ke,{className:"semiotic-bignumber__delta semiotic-bignumber__delta--"+Ze,style:{display:"inline"===O?"inline-flex":"flex",flexWrap:"wrap",gap:8,alignItems:"baseline",marginTop:"inline"===O?0:6,fontSize:oe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #6b7280)"},children:id(G,Ge,e.jsxs(e.Fragment,{children:[Be?e.jsxs("span",{className:"semiotic-bignumber__delta-row semiotic-bignumber__delta-row--"+Ze,style:{display:"inline-flex",alignItems:"center",gap:4,color:rd(De),fontWeight:600},children:[e.jsx("span",{"aria-hidden":"true",className:"semiotic-bignumber__arrow semiotic-bignumber__arrow--"+Ze,children:sd(De)}),e.jsx("span",{className:"semiotic-bignumber__delta-amount",children:Be}),Ie?e.jsxs("span",{className:"semiotic-bignumber__delta-percent",style:{fontWeight:500},children:["(",Ie,")"]}):null]}):null,(null==v?void 0:v.label)?e.jsx("span",{className:"semiotic-bignumber__comparison-label",children:v.label}):null,b?e.jsxs("span",{className:"semiotic-bignumber__target",style:{display:"inline-flex",alignItems:"baseline",gap:4},children:[Be||(null==v?void 0:v.label)?e.jsx("span",{"aria-hidden":"true",className:"semiotic-bignumber__separator",children:"·"}):null,e.jsx("span",{className:"semiotic-bignumber__target-percent",style:{fontWeight:500,color:"var(--semiotic-text, #111)"},children:Ee}),e.jsxs("span",{className:"semiotic-bignumber__target-value",children:["of ",Fe(b.value),b.label?" "+b.label:""]})]}):null]}))}):null,oe.showChart&&null!=q?e.jsx("div",{className:"semiotic-bignumber__chart",style:{position:"absolute",top:qe.top,right:qe.right,width:null!=V?V:oe.chartSize,height:null!=V?V:oe.chartSize,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:e.jsx("div",{style:{pointerEvents:"auto",lineHeight:0},children:id(q,Ge,null)})}):null,oe.showTrend&&null!=Y?e.jsx("div",{className:"semiotic-bignumber__trend",style:{position:"absolute",left:qe.left,right:qe.right,bottom:qe.bottom+(null!=X?28:0)},children:id(Y,Ge,null)}):null,null!=X?e.jsx(Ke,{className:"semiotic-bignumber__footer",style:{position:"absolute",left:qe.left,right:qe.right,bottom:qe.bottom,fontSize:oe.deltaSize||void 0,color:"var(--semiotic-text-secondary, #9ca3af)"},children:id(X,Ge,null)}):null,J?e.jsx("span",{style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0},children:J}):null,e.jsx("span",{"aria-hidden":"true",style:{display:"none"},children:null!=Re?He(Re):null})]})})});ad.displayName="BigNumber";const ld=ad;function cd(t){const n=Math.floor(.45*t.width),o=Math.floor(.6*t.width),i=(t,n)=>e.jsx("div",{style:{width:t,height:n,background:"var(--semiotic-border, #e0e0e0)",borderRadius:4,opacity:.55}});return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,justifyContent:"center",width:"100%",height:"100%"},children:["thumbnail"!==t.mode&&"inline"!==t.mode?i(n,10):null,i(o,"presentation"===t.mode?48:28),"tile"===t.mode||"presentation"===t.mode?i(Math.floor(.35*t.width),8):null]})}const[ud]=A(e=>({tooltip:null,changeTooltip(t){e(()=>({tooltip:t}))}}));function dd(e,t){return hs(this,void 0,void 0,function*(){const{format:n="png",filename:o="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"),hd(s,a),"svg"===n){const e=(new XMLSerializer).serializeToString(a);fd(new Blob([e],{type:"image/svg+xml;charset=utf-8"}),o+".svg")}else{const t=l.width*i,n=l.height*i,s=document.createElement("canvas");s.width=t,s.height=n;const c=s.getContext("2d");c.fillStyle=r,c.fillRect(0,0,t,n),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"}),f=URL.createObjectURL(h),g=new Image;g.width=l.width,g.height=l.height,yield new Promise((e,t)=>{g.onload=()=>{c.drawImage(g,0,0),s.toBlob(n=>{n?(fd(n,o+".png"),e()):t(Error("Failed to create PNG blob"))},"image/png"),URL.revokeObjectURL(f)},g.onerror=()=>{URL.revokeObjectURL(f),t(Error("Failed to load SVG image"))},g.src=f})}})}function hd(e,t){var n;const o=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 o=r.getPropertyValue(e);o&&"none"!==o&&""!==o&&(null===(n=t.style)||void 0===n||n.setProperty(e,o))}for(let e=0;Math.min(o.length,i.length)>e;e++)hd(o[e],i[e])}function fd(e,t){const n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)}const gd={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"},autoPlaceAnnotations:{type:["boolean","object"]},axisExtent:{type:"string",enum:["nice","exact"]},frameProps:{type:"object"},onClick:{type:"function"}},pd={xLabel:{type:"string"},yLabel:{type:"string"},xFormat:{type:"function"},yFormat:{type:"function"}},yd={categoryLabel:{type:"string"},valueLabel:{type:"string"},valueFormat:{type:"function"},categoryFormat:{type:"function"}},md=["linear","monotoneX","monotoneY","step","stepAfter","stepBefore","basis","cardinal","catmullRom"],vd=["vertical","horizontal"],bd={LineChart:{required:["data"],dataShape:"array",dataAccessors:["xAccessor","yAccessor"],props:Object.assign(Object.assign(Object.assign({},gd),pd),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},lineBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:md},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({},gd),pd),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:md},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({},gd),pd),{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:md},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({},gd),pd),{data:{type:"array"},xAccessor:{type:["string","function"]},yAccessor:{type:["string","function"]},areaBy:{type:["string","function"]},lineDataAccessor:{type:"string"},curve:{type:"string",enum:md},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({},gd),pd),{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({},gd),pd),{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({},gd),pd),{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({},gd),pd),{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({},gd),pd),{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({},gd),pd),{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({},gd),pd),{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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},stackBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),yd),{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:vd},barPadding:{type:"number"}})},GroupedBarChart:{required:["data","groupBy"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},groupBy:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},showOutliers:{type:"boolean"},outlierRadius:{type:"number"},categoryPadding:{type:"number"}})},Histogram:{required:["data"],dataShape:"array",dataAccessors:["categoryAccessor","valueAccessor"],props:Object.assign(Object.assign(Object.assign({},gd),yd),{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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),yd),{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({},gd),yd),{data:{type:"array"},categoryAccessor:{type:["string","function"]},valueAccessor:{type:["string","function"]},orientation:{type:"string",enum:vd},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({},gd),{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({},gd),{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({},gd),{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({},gd),yd),{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({},gd),yd),{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({},gd),{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({},gd),{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:vd},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({},gd),{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({},gd),{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({},gd),{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({},gd),{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({},gd),{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({},gd),{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"},autoPlaceAnnotations:{type:["boolean","object"]},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"},autoPlaceAnnotations:{type:["boolean","object"]},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"},autoPlaceAnnotations:{type:["boolean","object"]},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"},autoPlaceAnnotations:{type:["boolean","object"]},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"},autoPlaceAnnotations:{type:["boolean","object"]},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"},autoPlaceAnnotations:{type:["boolean","object"]},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({},gd),{data:{type:"array"},fields:{type:"array"}})},MinimapChart:{required:["data"],dataShape:"array",dataAccessors:[],props:Object.assign(Object.assign({},gd),{data:{type:"array"}})},ChoroplethMap:{required:["areas"],dataShape:"array",dataAccessors:["valueAccessor"],props:Object.assign(Object.assign({},gd),{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({},gd),{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({},gd),{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({},gd),{points:{type:"array"},center:{type:"array"},costAccessor:{type:["string","function"]}})},BigNumber:{required:[],dataShape:"none",dataAccessors:[],props:{width:{type:["number","string"]},height:{type:["number","string"]},className:{type:"string"},onClick:{type:"function"},value:{type:"number"},label:{type:"string"},caption:{type:"string"},format:{type:["string","function"],enum:["number","currency","percent","compact","duration"]},locale:{type:"string"},currency:{type:"string"},precision:{type:"number"},prefix:{type:"string"},suffix:{type:"string"},unit:{type:"string"},comparison:{type:"object"},target:{type:"object"},delta:{type:"number"},deltaFormat:{type:["string","function"],enum:["number","currency","percent","compact","duration"]},showDeltaPercent:{type:"boolean"},direction:{type:"string",enum:["higher-is-better","lower-is-better","neutral"]},sentiment:{type:"string",enum:["auto","positive","negative","neutral"]},thresholds:{type:"array"},chartSlot:{type:["string","number","array","object","function"]},chartSize:{type:"number"},windowSize:{type:"number"},mode:{type:"string",enum:["tile","presentation","inline","thumbnail"]},align:{type:"string",enum:["start","center","end"]},padding:{type:["number","object"]},emphasis:{type:"string",enum:["primary","secondary"]},color:{type:"string"},background:{type:"string"},borderColor:{type:"string"},borderRadius:{type:["number","string"]},animate:{type:["boolean","object"]},stalenessThreshold:{type:"number"},staleLabel:{type:"string"},headerSlot:{type:["string","number","array","object","function"]},valueSlot:{type:["string","number","array","object","function"]},deltaSlot:{type:["string","number","array","object","function"]},trendSlot:{type:["string","number","array","object","function"]},footerSlot:{type:["string","number","array","object","function"]},onObservation:{type:"function"}}}};function xd(e,t){return(Array.isArray(t)?t:[t]).includes(Array.isArray(e)?"array":typeof e)}function wd(e,t){const n=[],o=bd[e];if(!o)return{valid:!1,errors:[`Unknown component "${e}". Valid components: ${Object.keys(bd).join(", ")}`]};for(const i of o.required)null==t[i]&&n.push(`"${i}" is required for ${e}.`);for(const[e,i]of Object.entries(t)){if(null==i)continue;const t=o.props[e];if(t){if(!xd(i,t.type)){const o=Array.isArray(t.type)?t.type.join(" | "):t.type;n.push(`"${e}" should be ${o}, got ${Array.isArray(i)?"array":typeof i}.`);continue}t.enum&&"string"==typeof i&&!t.enum.includes(i)&&n.push(`"${e}" value "${i}" is not valid. Expected one of: ${t.enum.join(", ")}.`)}}const i=Object.keys(o.props),r=new Set(i);for(const o of Object.keys(t))if(void 0!==t[o]&&!r.has(o)){const t=es(o,i),r=t?`Unknown prop "${o}" for ${e}. Did you mean "${t}"?`:`Unknown prop "${o}" for ${e}. Valid props: ${i.join(", ")}.`;n.push(r)}if("array"===o.dataShape){const i=t.data,r={};for(const e of o.dataAccessors){const n=t[e];"string"==typeof n&&(r[e]=n)}const s=os({componentName:e,data:i,accessors:Object.keys(r).length>0?r:void 0});s&&n.push(s)}else if("object"===o.dataShape){const o=is({componentName:e,data:t.data});o&&n.push(o)}else if("network"===o.dataShape){const i=rs({componentName:e,nodes:t.nodes,edges:t.edges,nodesRequired:o.required.includes("nodes"),edgesRequired:o.required.includes("edges")});i&&n.push(i)}return{valid:0===n.length,errors:n}}const kd=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"]),Ad=new Set(["data","nodes","edges"]),jd="function"==typeof structuredClone?structuredClone:e=>JSON.parse(JSON.stringify(e));function Sd(e){return hs(this,arguments,void 0,function*(e,t="json"){const n="jsx"===t?Cd(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(n)})}function Cd(e){const{component:t,props:n}=e,o=["<"+t];for(const[e,t]of Object.entries(n))if("string"==typeof t)o.push(` ${e}="${t}"`);else if("boolean"==typeof t&&!0===t)o.push(" "+e);else if("boolean"==typeof t&&!1===t)o.push(` ${e}={false}`);else if("number"==typeof t)o.push(` ${e}={${t}}`);else{const n=JSON.stringify(t);o.push(80>n.length?` ${e}={${n}}`:` ${e}={${JSON.stringify(t,null,2)}}`)}return o.push("/>"),o.join("\n")}const Od=new Set(["LineChart","AreaChart","StackedAreaChart","DifferenceChart","Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","MultiAxisLineChart","MinimapChart"]),Md=new Set(["BarChart","StackedBarChart","GroupedBarChart","DotPlot"]),Pd=new Set(["PieChart","DonutChart","FunnelChart"]),_d=new Set(["Histogram","BoxPlot","ViolinPlot","RidgelinePlot","SwarmPlot"]);function Ld(e,t){var n,o;return Md.has(e)||Pd.has(e)||"SwimlaneChart"===e||"GaugeChart"===e?{measure:t.valueAccessor,measureFallback:"value",dimension:null!==(n=t.categoryAccessor)&&void 0!==n?n:t.stepAccessor,dimensionFallback:"category"}:{measure:null!==(o=t.yAccessor)&&void 0!==o?o:t.valueAccessor,measureFallback:"y",dimension:t.xAccessor,dimensionFallback:"x"}}function Td(e){for(const t of["lineBy","areaBy","stackBy","groupBy","colorBy"]){const n=e[t];if("string"==typeof n&&n)return n}}function Nd(e,t){return null==e?"—":e instanceof Date?e.toISOString().slice(0,10):"number"==typeof e?t(e):e+""}const Rd={fresh:1,aging:1.5,stale:3};function $d(e,t,n={}){var o,i,r;if(!Number.isFinite(t)||0>=t)return"fresh";if(Number.isNaN(e))return"fresh";if(e===1/0)return"expired";if(0>e)return"fresh";const s=null!==(o=n.fresh)&&void 0!==o?o:Rd.fresh,a=null!==(i=n.aging)&&void 0!==i?i:Rd.aging,l=null!==(r=n.stale)&&void 0!==r?r:Rd.stale;return t*s>e?"fresh":t*a>e?"aging":t*l>e?"stale":"expired"}function Dd(){return(new Date).toISOString()}function Bd(e){if(null==e)return null;if("number"==typeof e)return e;if(e instanceof Date)return e.getTime();const t=Date.parse(e);return Number.isFinite(t)?t:null}function Id(e){const t=Bd(null==e?void 0:e.now);if(null!=t)return t;const n=null==e?void 0:e.dataExtent;if(n)if(Array.isArray(n)){const e=Bd(n[n.length-1]);if(null!=e)return e}else if("max"in n){const e=Bd(n.max);if(null!=e)return e}return Date.now()}function Ed(e,t,n={}){var o,i,r;const s=null===(o=null==e?void 0:e.lifecycle)||void 0===o?void 0:o.freshness,a=Bd(null===(i=null==e?void 0:e.provenance)||void 0===i?void 0:i.createdAt),l=function(e){if(null==e)return null;if("number"==typeof e)return e;const t=function(e){const t=/^P(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/.exec(e);return t?1e3*(3600*(24*parseInt(t[1]||"0",10)+parseInt(t[2]||"0",10))+60*parseInt(t[3]||"0",10)+parseInt(t[4]||"0",10)):0}(e);return t>0?t:null}(null===(r=null==e?void 0:e.lifecycle)||void 0===r?void 0:r.ttlHint);return null==a||null==l?null!=s?s:"fresh":$d(t-a,l,n)}const Fd={fresh:null,aging:.55,stale:.35,expired:.2},Hd={fresh:null,aging:null,stale:"4 4",expired:"2 4"};function zd(e,t,n){return e&&n in e?e[n]:t[n]}const Wd={proposed:.7,accepted:null,disputed:.7,retracted:.25},Gd={proposed:"3 3",accepted:null,disputed:"2 3",retracted:"2 4"},Yd={proposed:" (proposed)",accepted:"",disputed:" (?)",retracted:""};function qd(e,t,n){return e&&n in e?e[n]:t[n]}function Vd(e,t={}){var n,o;const i=!0===t.showRetractedAnnotations,r=!0===t.showSupersededAnnotations,s=new Set;for(const t of e){const e=null===(n=null==t?void 0:t.lifecycle)||void 0===n?void 0:n.supersedes;e&&"retracted"!==(null===(o=null==t?void 0:t.lifecycle)||void 0===o?void 0:o.status)&&s.add(e)}return e.filter(e=>{var t,n;if("retracted"===(null===(t=null==e?void 0:e.lifecycle)||void 0===t?void 0:t.status)&&!i)return!1;const o=null===(n=null==e?void 0:e.provenance)||void 0===n?void 0:n.stableId;return!(o&&s.has(o)&&!r)})}const Xd={LineChart:"line chart",AreaChart:"area chart",StackedAreaChart:"stacked area chart",DifferenceChart:"difference chart",Scatterplot:"scatter plot",BubbleChart:"bubble chart",ConnectedScatterplot:"connected scatter plot",QuadrantChart:"quadrant chart",MultiAxisLineChart:"dual-axis line chart",CandlestickChart:"candlestick chart",Heatmap:"heatmap",MinimapChart:"line chart",BarChart:"bar chart",StackedBarChart:"stacked bar chart",GroupedBarChart:"grouped bar chart",DotPlot:"dot plot",Histogram:"histogram",BoxPlot:"box plot",ViolinPlot:"violin plot",RidgelinePlot:"ridgeline plot",SwarmPlot:"swarm plot",PieChart:"pie chart",DonutChart:"donut chart",FunnelChart:"funnel chart",GaugeChart:"gauge",LikertChart:"Likert chart",SwimlaneChart:"swimlane chart",ForceDirectedGraph:"network graph",SankeyDiagram:"Sankey diagram",ProcessSankey:"temporal Sankey diagram",ChordDiagram:"chord diagram",TreeDiagram:"tree diagram",Treemap:"treemap",CirclePack:"circle-packing chart",OrbitDiagram:"orbit diagram",ChoroplethMap:"choropleth map",ProportionalSymbolMap:"proportional-symbol map",FlowMap:"flow map",DistanceCartogram:"distance cartogram",BigNumber:"single value"},Ud=new Set(["ForceDirectedGraph","SankeyDiagram","ProcessSankey","ChordDiagram"]);function Kd(e){return Xd[e]||e.replace(/([a-z])([A-Z])/g,"$1 $2").toLowerCase()+" chart"}const Qd=new Set(["Scatterplot","BubbleChart","ConnectedScatterplot","QuadrantChart","ScatterplotMatrix"]),Zd={"outlier-detection":"alerting","change-detection":"alerting",trend:"tracking","composition-over-time":"apportioning","compare-series":"comparing","compare-categories":"comparing",rank:"ranking","part-to-whole":"apportioning",distribution:"characterizing",correlation:"relating",flow:"tracing",hierarchy:"nesting",geo:"locating"},Jd={"time-series":"tracking",categorical:"comparing",distribution:"characterizing",relationship:"relating",flow:"tracing",network:"tracing",hierarchy:"nesting",geo:"locating",realtime:"tracking",value:"presenting",custom:"presenting"},eh=["trend","compare-series","compare-categories","rank","part-to-whole","distribution","correlation","flow","hierarchy","geo","composition-over-time","change-detection","outlier-detection"],th={alerting:"alerting",tracking:"trend",comparing:"comparison",ranking:"ranking",apportioning:"composition",characterizing:"distribution",relating:"correlation",tracing:"flow",nesting:"hierarchy",locating:"locator",presenting:"single-value"};function nh(e,t){var n;const o=function(e){if(e){if("fits"in e||"buildProps"in e){const t=e,n={};for(const[e,o]of Object.entries(t.intentScores))"number"==typeof o&&Number.isFinite(o)&&(n[e]=o);return{family:t.family,intentScores:Object.keys(n).length?n:void 0}}return e}}(t);if(null==o?void 0:o.act)return o.act;if(null==o?void 0:o.intentScores){const e=function(e){let t,n=0;for(const[o,i]of Object.entries(e))if("number"==typeof i&&i>0)if(i>n)t=o,n=i;else if(i===n&&void 0!==t){const e=eh.indexOf(o),n=eh.indexOf(t);-1===e||-1!==n&&e>=n||(t=o)}return t}(o.intentScores);if(e&&Zd[e]&&(null!==(n=o.intentScores[e])&&void 0!==n?n:0)>=3)return Zd[e]}return(null==o?void 0:o.family)?Jd[o.family]:function(e){return Pd.has(e)||"StackedAreaChart"===e?"apportioning":Qd.has(e)?"relating":Md.has(e)?"comparing":_d.has(e)?"characterizing":Od.has(e)?"tracking":Ud.has(e)?"tracing":"BigNumber"===e?"presenting":void 0}(e)}function oh(e="en"){let t,n;try{t=new Intl.NumberFormat(e,{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat(e,{maximumFractionDigits:2})}catch(e){t=new Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}),n=new Intl.NumberFormat("en",{maximumFractionDigits:2})}return e=>Number.isFinite(e)?1e4>Math.abs(e)?n.format(e):t.format(e):e+""}const ih={"y-threshold":"a threshold line","x-threshold":"a threshold line",band:"a highlighted band",label:"a label",callout:"a callout","callout-circle":"a callout","callout-rect":"a callout",text:"a text note",bracket:"a bracket",enclose:"an enclosure","rect-enclose":"an enclosure",highlight:"a highlight",widget:"a widget",trend:"a trend line",envelope:"an envelope","anomaly-band":"an anomaly band",forecast:"a forecast","category-highlight":"a category highlight"};function rh(e){const t=ih["string"==typeof e.type?e.type:"annotation"]||"an annotation",n=function(e){var t,n;const o=e.provenance&&"object"==typeof e.provenance?e.provenance:null,i=null!==(n=null!==(t=null==o?void 0:o.authorKind)&&void 0!==t?t:null==o?void 0:o.source)&&void 0!==n?n:null==o?void 0:o.basis;return"watcher"===i?"a watcher-flagged ":"agent"===i||"ai"===i||"llm-inference"===i?"an AI-suggested ":""}(e),o=n?n+t.replace(/^an? /,""):t,i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:void 0;return i?`${o} labeled "${i}"`:o}function sh(e,t,n={}){var o,i;const r=void 0!==n.levels,s=new Set(null!==(o=n.levels)&&void 0!==o?o:["l1","l2","l3"]);!r&&n.capability&&s.add("l4");const a=oh(null!==(i=n.locale)&&void 0!==i?i:"en"),l=Kd(e),c=Array.isArray(t.data)?t.data:null,u=Td(t),{measure:d,measureFallback:h,dimension:f,dimensionFallback:g}=Ld(e,t),p="string"==typeof d&&d?d:h,y="string"==typeof f&&f?f:g,m={};if(s.has("l1"))if(Od.has(e)||Md.has(e))m.l1=`A ${l} of ${p} by ${y}`+(u?`, split by ${u}.`:".");else if(Pd.has(e))m.l1=`A ${l} showing ${p} across ${y} categories.`;else if(_d.has(e))m.l1=`A ${l} of the distribution of ${p}`+(u?` by ${u}.`:".");else if(Ud.has(e)){const e=Array.isArray(t.nodes)?t.nodes.length:void 0,n=Array.isArray(t.edges)?t.edges.length:void 0,o=[null!=e?`${e} ${lh(e,"node")}`:null,null!=n?`${n} ${lh(n,"edge")}`:null].filter(Boolean);m.l1=`A ${l}${o.length?" with "+o.join(" and "):""}.`}else if("BigNumber"===e){const e="string"==typeof t.label?t.label:p;m.l1=`A single value${e?" for "+e:""}.`}else m.l1=`A ${l}.`;const v=Od.has(e)||Md.has(e)||Pd.has(e)||_d.has(e);let b=null;if((s.has("l2")||s.has("l3")||s.has("l4"))&&v&&c&&c.length>0&&(b=function(e,t,n,o){let i=0,r=0,s=1/0,a=-1/0,l=null,c=null,u=0,d=0,h=null,f=null,g=NaN,p=NaN;for(const n of e){const e=t(n);Number.isFinite(e)&&(0===i&&(g=e,h=n),p=e,f=n,s>e&&(s=e,l=n,u=i),e>a&&(a=e,c=n,d=i),i++,r+=e)}return 0===i?null:{count:i,min:s,max:a,mean:r/i,minLabel:Nd(null!=l?n(l):null,o),maxLabel:Nd(null!=c?n(c):null,o),first:g,last:p,firstLabel:Nd(null!=h?n(h):null,o),lastLabel:Nd(null!=f?n(f):null,o),minIndex:u,maxIndex:d}}(c,G(d,h),Y(f,g),a)),s.has("l2")&&v&&(c&&0!==c.length?b&&(m.l2=Pd.has(e)?`${b.count} segments totaling ${a(function(e){return e.mean*e.count}(b))}. Largest is ${b.maxLabel} at ${a(b.max)}; smallest is ${b.minLabel} at ${a(b.min)}.`:`${p} ranges from ${a(b.min)} (${b.minLabel}) to ${a(b.max)} (${b.maxLabel}), with a mean of ${a(b.mean)} across ${b.count} points.`):m.l2="No data is loaded yet."),s.has("l3")&&b&&Od.has(e)?m.l3=function(e,t,n){const{first:o,last:i,min:r,max:s,maxLabel:a,minLabel:l,firstLabel:c,lastLabel:u,minIndex:d,maxIndex:h,count:f}=e,g=s-r,p=i-o;if(0===g)return`${ah(t)} is constant at ${n(o)} across the series.`;if(.04>g/(Math.abs(e.mean)||1))return`${ah(t)} ends roughly where it started (${n(o)} at ${c} to ${n(i)} at ${u}), ranging between ${n(r)} and ${n(s)}.`;const y=h>0&&f-1>h,m=d>0&&f-1>d,v=(s-Math.max(o,i))/g,b=(Math.min(o,i)-r)/g;return y&&v>.15?`Overall ${t} climbs to a peak of ${n(s)} (${a}), then falls to ${n(i)} (${u}).`:m&&b>.15?`Overall ${t} drops to a low of ${n(r)} (${l}), then recovers to ${n(i)} (${u}).`:.05>Math.abs(p)/g?`${ah(t)} ends roughly where it started (${n(o)} at ${c} to ${n(i)} at ${u}), ranging between ${n(r)} and ${n(s)}.`:p>0?h===f-1?`Overall ${t} rises from ${n(o)} (${c}) to a peak of ${n(i)} (${u}).`:`Overall ${t} rises from ${n(o)} (${c}) to ${n(i)} (${u}), after peaking at ${n(s)} (${a}).`:d===f-1?`Overall ${t} falls from ${n(o)} (${c}) to a low of ${n(i)} (${u}).`:`Overall ${t} falls from ${n(o)} (${c}) to ${n(i)} (${u}), after dipping to ${n(r)} (${l}).`}(b,p,a):s.has("l3")&&b&&Md.has(e)&&(m.l3=`The highest ${y} is ${b.maxLabel} and the lowest is ${b.minLabel}.`),s.has("l4")){const o=nh(e,n.capability);o&&(m.l4=function(e,t,n,o,i,r,s,a){const l=th[e],c=/^[aeiou]/i.test(l)?"an":"a";let u,d;switch(e){case"locating":u="This is a map",d="read values by location";break;case"presenting":u="This is a single-value display",d=`read ${"string"==typeof n.label&&n.label?n.label:i} as the headline number`;break;case"tracing":u=`This is ${c} ${l} chart`,d="follow the movement between states";break;case"nesting":u=`This is ${c} ${l} chart`,d="read it for nested structure and how children sum into their parents";break;case"relating":u=`This is ${c} ${l} chart`,d=`read it for whether ${r} and ${i} move together`;break;default:u=`This is ${c} ${l} chart`,d=function(e,t,n,o,i,r){if(!t)switch(e){case"alerting":return"watch for points that break from the rest";case"tracking":return"read it for the overall direction of "+n;case"comparing":return`compare ${n} across ${o}`;case"ranking":return"read it top to bottom by "+n;case"apportioning":return`read each ${o}'s share of the whole`;case"characterizing":return"read it for the spread and shape of "+n;default:return"read the highlighted features"}switch(e){case"alerting":return function(e,t,n){if(Md.has(n)||Pd.has(n))return`${e.maxLabel} stands out at ${t(e.max)} — check it first`;const{first:o,last:i,min:r,max:s,minLabel:a,maxLabel:l,lastLabel:c,minIndex:u,maxIndex:d,count:h}=e,f=s-r;if(f>0){const e=d>0&&h-1>d,n=u>0&&h-1>u,g=(s-Math.max(o,i))/f,p=(Math.min(o,i)-r)/f;if(e&&g>.15)return`the peak of ${t(s)} at ${l} is the point to investigate`;if(n&&p>.15)return`the dip to ${t(r)} at ${a} is the point to investigate`;if(i>=s)return`the climb to ${t(i)} at ${c} warrants a closer look`;if(r>=i)return`the drop to ${t(i)} at ${c} warrants a closer look`}return`the extremes — ${l} (${t(s)}) and ${a} (${t(r)}) — are the points to check`}(t,i,r);case"tracking":return`read it for the trajectory of ${n}, which ${function(e){const t=e.max-e.min,n=e.last-e.first;return 0===t||.05>Math.abs(n)/t?"holds roughly steady":n>0?"rises":"falls"}(t)} from ${i(t.first)} (${t.firstLabel}) to ${i(t.last)} (${t.lastLabel})`;case"comparing":return`compare ${n} across ${o}; ${t.maxLabel} leads at ${i(t.max)}`;case"ranking":return`read it top to bottom by ${n}; ${t.maxLabel} ranks highest at ${i(t.max)}`;case"apportioning":{const e=t.mean*t.count,n=e>0?Math.round(t.max/e*100):null;return`read each ${o}'s share of the ${i(e)} total; ${t.maxLabel} is the largest at ${i(t.max)}${null!=n?` (${n}%)`:""}`}case"characterizing":return`read it for the spread of ${n}, from ${i(t.min)} to ${i(t.max)}`;default:return"read the highlighted features"}}(e,o,i,r,s,t)}return`${u}; ${d}.${function(e,t){var n;if(!t)return"";const o=null===(n=t.familiarity)||void 0===n?void 0:n[e];return"number"!=typeof o||o>2?"":` This ${Kd(e)} may be unfamiliar${t.name?` to ${t.name.toLowerCase()} readers`:""} — lean on this description.`}(t,a)}`}(o,e,t,b,p,y,a,n.audience))}const x=["l1","l2","l3","l4"].filter(e=>s.has(e)&&m[e]).map(e=>m[e]).join(" "),w=function(e){const t=Array.isArray(e.annotations)?e.annotations:null;if(!t||0===t.length)return;const n=Vd(t.filter(e=>!!e&&"object"==typeof e));if(0===n.length)return;const o=n.map(rh),i=o.slice(0,5),r=o.length-i.length,s=function(e){var t;return e.length>1?2===e.length?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`:null!==(t=e[0])&&void 0!==t?t:""}(i)+(r>0?`, and ${r} more`:""),a=n.length;return`The author has marked ${1===a?"one feature":a+" features"} on this chart: ${s}.`}(t);return Object.assign({text:w?`${w} ${x}`.trim():x,levels:m},w?{annotations:w}:{})}function ah(e){return e.length?e[0].toUpperCase()+e.slice(1):e}function lh(e,t){return 1===e?t:t+"s"}function ch(e,t,n={}){var o,i,r;const s=null!==(o=n.locale)&&void 0!==o?o:"en",a=Math.max(1,null!==(i=n.maxLeaves)&&void 0!==i?i:200),l=oh(s),c={id:"root",role:"chart",label:sh(e,t,{locale:s}).text||"Chart.",level:1,children:[]},u=function(e,t){const n=Array.isArray(e.annotations)?e.annotations:null;if(!n)return null;const o=Vd(n.filter(e=>!!e&&"object"==typeof e));if(0===o.length)return null;let i=0;const r=o.slice(0,t).map(e=>{var t;const n=null===(t=e.lifecycle)||void 0===t?void 0:t.status,o=n&&"accepted"!==n?` (${n})`:"";return{id:"annotation-"+i++,role:"annotation",level:3,label:`${r=rh(e),r?r.charAt(0).toUpperCase()+r.slice(1):r}${o}.`,datum:e};var r});o.length>t&&r.push({id:"annotation-"+i++,role:"annotation",level:3,label:`…and ${o.length-t} more annotations.`});const s=o.length;return{id:"annotations",role:"annotation",level:2,label:`Annotations: ${1===s?"one marked feature":s+" marked features"}.`,children:r}}(t,a),d=Array.isArray(t.data)?t.data:null,h=Od.has(e)||Md.has(e)||Pd.has(e)||_d.has(e);if(!d||0===d.length||!h)return u&&(c.children=[u]),c;const{measure:f,measureFallback:g,dimension:p,dimensionFallback:y}=Ld(e,t),m=G(f,g),v=Y(p,y),b="string"==typeof f&&f?f:g,x="string"==typeof p&&p?p:y,w=Td(t);let k=0;const A=e=>`${e}-${k++}`,j=(e,t)=>{const n=e.slice(0,a).map(e=>((e,t)=>{const n=m(e),o=Nd(v(e),l);return{id:A("datum"),role:"datum",level:t,label:`${o}: ${Number.isFinite(n)?l(n):"—"}`,value:Number.isFinite(n)?n:void 0,datum:e}})(e,t));return e.length>a&&n.push({id:A("more"),role:"datum",level:t,label:`…and ${e.length-a} more points`}),n},S=[];if(Od.has(e)||Md.has(e)){let t=1/0,n=-1/0,o=1/0,i=-1/0;const r=[];let s=!0;for(const e of d){const a=m(e);Number.isFinite(a)&&(t>a&&(t=a),a>n&&(n=a));const l=v(e);r.push(l),"number"==typeof l&&Number.isFinite(l)?(o>l&&(o=l),l>i&&(i=l)):s=!1}const a=new Set,c=[];for(const e of r){const t=e+"";a.has(t)||(a.add(t),c.push(e))}const u=s?`${l(o)} to ${l(i)}`:`${Nd(c[0],l)} to ${Nd(c[c.length-1],l)} (${Md.has(e)?c.length+" categories":d.length+" points"})`;S.push({id:A("axis"),role:"axis",level:2,label:`${Md.has(e)?"Category axis":"X axis"}: ${x}, ${u}.`}),t>n||S.push({id:A("axis"),role:"axis",level:2,label:`Value axis: ${b}, ${l(t)} to ${l(n)}.`})}if(w){const n=Y(w,w),o=new Map;for(const e of d){const t=(null!==(r=n(e))&&void 0!==r?r:"—")+"",i=o.get(t);i?i.push(e):o.set(t,[e])}const i=[];for(const[n,r]of o){const o=sh(e,Object.assign(Object.assign({},t),{data:r}),{levels:["l2","l3"],locale:s}).text;i.push({id:A("series"),role:"series",level:2,label:`Series ${n}: ${o}`,children:j(r,3)})}c.children=[...S,...i]}else c.children=[...S,...j(d,2)];return u&&c.children.push(u),c}function uh(e,t){const n=[],o=e=>{if(n.push(e),e.children&&e.children.length>0&&t.has(e.id))for(const t of e.children)o(t)};return o(e),n}let dh=null;const hh=new Set,fh=new Set,gh=1e3;function ph(e,t,n){const o=null!=e?e:t;if(!Number.isFinite(o)||0>=o)throw new RangeError(`${n} must be a positive number, got ${o+""}`);return Math.floor(o)}function yh(e,t){void 0!==console&&console.warn(`[conversationArc] ${e} failed:`,t)}function mh(e,t){try{const n=t();n&&"function"==typeof n.then&&Promise.resolve(n).catch(t=>yh(e,t))}catch(t){yh(e,t)}}function vh(e){if(e)return e;try{const e=globalThis.localStorage;return null!=e?e:null}catch(e){return null}}function bh(e,t){if(!e)return[];try{return function(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch(e){return yh("localStorage load",e),[]}}(e.getItem(t))}catch(e){return yh("localStorage read",e),[]}}const xh=Object.freeze([]);let wh=xh,kh=!1;function Ah(){return kh?(wh=dh?Object.freeze(dh.buffer.slice()):xh,kh=!1,wh):wh}function jh(){kh=!0}const Sh=new Set;function Ch(){for(const e of Sh)try{e()}catch(e){void 0!==console&&console.warn("[conversationArc] change subscriber threw:",e)}}function Oh(e){return Sh.add(e),()=>{Sh.delete(e)}}function Mh(e,t={}){var n,o,i,r,s,a,l;const c=Array.isArray(e)?e.slice():[],u=ph(t.capacity,Math.max(null!==(n=null==dh?void 0:dh.capacity)&&void 0!==n?n:gh,c.length,1),"loadConversationArc: capacity"),d=null!==(s=null!==(r=null!==(o=t.sessionId)&&void 0!==o?o:null===(i=c[0])||void 0===i?void 0:i.sessionId)&&void 0!==r?r:null==dh?void 0:dh.sessionId)&&void 0!==s?s:Ph();for(dh?(dh.enabled=null!==(l=t.enabled)&&void 0!==l&&l,dh.sessionId=d,dh.capacity=u):dh={enabled:null!==(a=t.enabled)&&void 0!==a&&a,sessionId:d,capacity:u,buffer:[]},t.append||(dh.buffer=[]),dh.buffer.push(...c);dh.buffer.length>dh.capacity;)dh.buffer.shift();return jh(),Ch(),Ah()}function Ph(){return`arc-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function _h(){return dh}function Lh(e={}){var t,n;const o=null!==(t=e.capacity)&&void 0!==t?t:1e3;if(!Number.isFinite(o)||0>=o)throw new RangeError("enableConversationArc: capacity must be a positive number, got "+o);if(dh){if(dh.enabled=!0,e.sessionId&&(dh.sessionId=e.sessionId),null!=e.capacity){for(dh.capacity=o;dh.buffer.length>dh.capacity;)dh.buffer.shift();jh()}}else dh={enabled:!0,sessionId:null!==(n=e.sessionId)&&void 0!==n?n:Ph(),capacity:o,buffer:[]},jh();return Ch(),Rh}function Th(){dh&&(dh.enabled=!1,Ch())}function Nh(){return Rh}const Rh={get enabled(){var e;return null!==(e=null==dh?void 0:dh.enabled)&&void 0!==e&&e},get sessionId(){var e;return null!==(e=null==dh?void 0:dh.sessionId)&&void 0!==e?e:null},get capacity(){var e;return null!==(e=null==dh?void 0:dh.capacity)&&void 0!==e?e:0},record(e){var t,n;const o=_h();if(!o||!o.enabled)return null;const i=Object.assign(Object.assign({},e),{timestamp:null!==(t=e.timestamp)&&void 0!==t?t:Date.now(),sessionId:null!==(n=e.sessionId)&&void 0!==n?n:o.sessionId});for(o.buffer.push(i);o.buffer.length>o.capacity;)o.buffer.shift();jh(),Ch();for(const e of hh)try{e(i)}catch(e){void 0!==console&&console.warn("[conversationArc] subscriber threw:",e)}return function(e){for(const t of fh)t.record&&mh("sink record",()=>{var n;return null===(n=t.record)||void 0===n?void 0:n.call(t,e)})}(i),i},flush(){const e=_h();if(!e)return[];const t=e.buffer.slice();return e.buffer=[],jh(),Ch(),function(e){for(const t of fh)t.flush&&mh("sink flush",()=>{var n;return null===(n=t.flush)||void 0===n?void 0:n.call(t,e)})}(t),t},getEvents:()=>Ah(),subscribe:e=>(hh.add(e),()=>{hh.delete(e)}),clear(){const e=_h();e&&(e.buffer=[],jh(),Ch()),function(){for(const e of fh)e.clear&&mh("sink clear",()=>{var t;return null===(t=e.clear)||void 0===t?void 0:t.call(e)})}()},reset(){if(hh.clear(),fh.clear(),wh=xh,kh=!1,!dh)return Ch(),void Sh.clear();dh.buffer=[],dh.enabled=!1,dh=null,Ch(),Sh.clear()}},$h={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Dh({tree:t,label:n,visible:o=!1,className:i,onActiveChange:r,activeId:s,chartId:a}){const[l,c]=p.useState(()=>new Set([t.id])),[u,d]=p.useState(t.id),h=void 0!==s,f=h?s:u,g=p.useRef(null),y=p.useRef(new Map),m=p.useMemo(()=>function(e){const t=new Map,n=e=>{var o;for(const i of null!==(o=e.children)&&void 0!==o?o:[])t.set(i.id,e),n(i)};return n(e),t}(t),[t]),v=p.useMemo(()=>uh(t,l),[t,l]);p.useEffect(()=>{h||v.some(e=>e.id===u)||d(t.id)},[v,u,t.id,h]),p.useEffect(()=>{const e=[];let t=m.get(f);for(;t;)e.push(t.id),t=m.get(t.id);e.length>0&&c(t=>{if(e.every(e=>t.has(e)))return t;const n=new Set(t);for(const t of e)n.add(t);return n})},[f,m]),p.useEffect(()=>{var e,t;(null===(e=g.current)||void 0===e?void 0:e.contains(document.activeElement))&&(null===(t=y.current.get(f))||void 0===t||t.focus())},[f]);const b=p.useCallback((e,t,n)=>{const o=Nh();o.enabled&&o.record("focus"===t?{type:"nav-node-focused",chartId:a,nodeId:e.id,role:e.role,level:e.level,label:e.label.length>200?e.label.slice(0,200):e.label}:{type:"nav-branch-expanded",chartId:a,nodeId:e.id,role:e.role,level:e.level,expanded:!!n})},[a]),x=p.useCallback(e=>{e.id!==f&&(h||d(e.id),null==r||r(e),b(e,"focus"))},[r,h,b,f]),w=e=>{c(t=>new Set(t).add(e.id)),b(e,"toggle",!0)},k=e=>{c(t=>{const n=new Set(t);return n.delete(e.id),n}),b(e,"toggle",!1)},A=(t,n,i)=>{const r=!!t.children&&t.children.length>0,s=l.has(t.id);return e.jsxs("li",{role:"treeitem","aria-label":t.label,"aria-level":t.level,"aria-posinset":n,"aria-setsize":i,"aria-expanded":r?s:void 0,"aria-selected":t.id===f,tabIndex:t.id===f?0:-1,ref:e=>{y.current.set(t.id,e)},onClick:e=>{e.stopPropagation(),x(t),r&&(s?k:w)(t)},style:o?{listStyle:"none",padding:"2px 6px",paddingLeft:6+16*(t.level-1),cursor:r?"pointer":"default",fontSize:13,background:t.id===f?"var(--semiotic-surface, #f0f4f8)":"transparent",outline:"none"}:void 0,children:[e.jsxs("span",{className:"semiotic-nav-tree-label semiotic-nav-tree-"+t.role,children:[o&&r?s?"▾ ":"▸ ":"",t.label]}),r&&s&&e.jsx("ul",{role:"group",style:o?{margin:0,padding:0}:void 0,children:t.children.map((e,n)=>A(e,n+1,t.children.length))})]},t.id)};return e.jsx("div",{ref:g,className:"semiotic-nav-tree"+(i?" "+i:""),style:o?void 0:$h,onKeyDown:e=>{const t=v.findIndex(e=>e.id===f);if(-1===t)return;const n=v[t],o=!!n.children&&n.children.length>0,i=l.has(n.id);let r=!0;switch(e.key){case"ArrowDown":x(v[Math.min(t+1,v.length-1)]);break;case"ArrowUp":x(v[Math.max(t-1,0)]);break;case"Home":x(v[0]);break;case"End":x(v[v.length-1]);break;case"ArrowRight":o&&!i?w(n):o&&i?x(n.children[0]):r=!1;break;case"ArrowLeft":if(o&&i)k(n);else{const e=m.get(n.id);e?x(e):r=!1}break;case"Enter":case" ":o?(i?k:w)(n):r=!1;break;default:r=!1}r&&(e.preventDefault(),e.stopPropagation())},children:e.jsx("ul",{role:"tree","aria-label":n||"Chart navigation",style:o?{margin:0,padding:0}:void 0,children:A(t,1,1)})})}const Bh={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0,0,0,0)",whiteSpace:"nowrap",border:0,padding:0,margin:-1};function Ih(){const t=function(){const e=p.useContext(xo);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:Wh,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 Eh={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 Fh({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 Hh({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 zh=p.forwardRef(function({title:t,subtitle:n,children:o,width:i="100%",height:r=400,actions:s,chartConfig:a,describe:l,navigable:c,controls:u,loading:d=!1,error:h,errorBoundary:f=!1,status:g,detailsPanel:y,className:m,style:v},b){var x;const w=p.useRef(null),k=p.useRef(null),[A,j]=p.useState(!1),S=!1!==(null==s?void 0:s.export)&&void 0!==(null==s?void 0:s.export),C=!1!==(null==s?void 0:s.fullscreen)&&void 0!==(null==s?void 0:s.fullscreen),O=!1!==(null==s?void 0:s.copyConfig)&&void 0!==(null==s?void 0:s.copyConfig)&&a,M=!0===(null==s?void 0:s.dataSummary),P=p.useMemo(()=>{if(!l||!(null==a?void 0:a.component)||!(null==a?void 0:a.props))return"";const e="object"==typeof l?l.levels:void 0;try{return sh(a.component,a.props,e?{levels:e}:{}).text}catch(e){return""}},[l,a]),_="object"==typeof l&&!0===l.visible,L=p.useMemo(()=>{if(!c||!(null==a?void 0:a.component)||!(null==a?void 0:a.props))return null;const e="object"==typeof c?c.maxLeaves:void 0;try{return ch(a.component,a.props,e?{maxLeaves:e}:{})}catch(e){return null}},[c,a]),T="object"==typeof c&&!0===c.visible,N=p.useMemo(()=>"object"==typeof(null==s?void 0:s.export)?s.export:{},[null==s?void 0:s.export]),R="object"==typeof(null==s?void 0:s.copyConfig)?s.copyConfig.format:"json",$=p.useCallback(e=>hs(this,void 0,void 0,function*(){k.current&&(yield dd(k.current,Object.assign(Object.assign({},N),e)))}),[N]),D=p.useCallback(()=>{w.current&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):w.current.requestFullscreen().catch(()=>{}))},[]),B=p.useCallback(e=>hs(this,void 0,void 0,function*(){var t,n;a&&(yield Sd(Object.assign(Object.assign({},a),{version:null!==(t=a.version)&&void 0!==t?t:"1",createdAt:null!==(n=a.createdAt)&&void 0!==n?n:(new Date).toISOString()}),e||R||"json"))}),[a,R]);p.useEffect(()=>{const e=()=>{j(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]),p.useImperativeHandle(b,()=>({export:$,toggleFullscreen:D,copyConfig:B,element:w.current}),[$,D,B]);const I=t||n||u||S||C||O||M||g,E=d?e.jsx(Fh,{height:r}):h?e.jsx(Hh,{error:h}):f?e.jsx(Gr,{children:o}):o;return F=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:w,className:"semiotic-chart-container"+(m?" "+m:""),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"},A?{display:"flex",flexDirection:"column",width:"100%",height:"100%"}:{}),v),children:[I&&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}),n&&e.jsx("div",{className:"semiotic-chart-subtitle",style:{fontSize:12,color:"var(--semiotic-text-secondary, #666)",marginTop:t?2:0},children:n})]}),e.jsxs("div",{className:"semiotic-chart-toolbar",style:{display:"flex",alignItems:"center",gap:4},children:[u,S&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>$(),title:"Export chart","aria-label":"Export chart",style:Wh,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"})]})}),M&&e.jsx(Ih,{}),C&&e.jsx("button",{className:"semiotic-chart-action",onClick:D,title:A?"Exit fullscreen":"Fullscreen","aria-label":A?"Exit fullscreen":"Enter fullscreen",style:Wh,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,A?{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"})]})})}),O&&e.jsx("button",{className:"semiotic-chart-action",onClick:()=>B(),title:"Copy config","aria-label":"Copy chart configuration",style:Wh,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"})]})}),g&&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:Eh[g].bg,color:Eh[g].color,lineHeight:"18px"},children:g})]})]}),P&&e.jsx("div",{className:"semiotic-chart-description",role:"note",style:_?{padding:"8px 16px",fontSize:12,lineHeight:1.5,color:"var(--semiotic-text-secondary, #666)",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)"}:Bh,children:P}),L&&e.jsx("div",{className:"semiotic-chart-nav",style:T?{padding:"8px 8px",borderBottom:"1px solid var(--semiotic-border, #e0e0e0)",maxHeight:240,overflow:"auto"}:void 0,children:e.jsx(Dh,{tree:L,label:"string"==typeof t&&t?t+" — navigable structure":"Chart navigable structure",visible:T,chartId:"string"==typeof(null===(x=null==a?void 0:a.props)||void 0===x?void 0:x.chartId)?a.props.chartId:void 0})}),e.jsxs("div",{className:"semiotic-chart-body",ref:k,style:Object.assign({position:"relative",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},A?{flex:1}:{height:r}),children:[E,y]})]})]}),M?e.jsx(wo,{children:F}):F;var F}),Wh={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 Gh({children:t,columns:n="auto",minCellWidth:o=300,gap:i=16,className:r,style:s}){const a="number"==typeof n?n:void 0;return e.jsx("div",{className:"semiotic-chart-grid"+(r?" "+r:""),style:Object.assign({display:"grid",gridTemplateColumns:"auto"===n?`repeat(auto-fill, minmax(${o}px, 1fr))`:`repeat(${n}, 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 Yh({children:t,context:n,position:o="right",contextSize:i=250,gap:r=12,className:s,style:a}){const l="left"===o||"right"===o,c="left"===o||"top"===o,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:n})]})}Gh.displayName="ChartGrid",Yh.displayName="ContextLayout";function qh({children:n,position:o="right",size:i=300,trigger:r="click",chartId:s,observation:a,dismissOnEmpty:l=!0,showClose:c=!0,onToggle:u,className:d,style:h}){const[f,g]=t.useState(null),[p,y]=t.useState(null),[m,v]=t.useState(!1),[b,x]=t.useState(!1),w=t.useRef(null),k=t.useRef(void 0),A="click"===r?["click","click-end"]:["hover","hover-end"],{latest:j}=tr({types:A,chartId:s,limit:1}),S=void 0!==a?a:j,C=t.useCallback(()=>{x(!0),v(!1),clearTimeout(k.current),k.current=setTimeout(()=>{x(!1),g(null),y(null)},200)},[]);if(t.useEffect(()=>{if(S)if("click"===S.type||"hover"===S.type){const e=S;g(e.datum),y(e),v(e=>(e||(x(!0),clearTimeout(k.current),k.current=setTimeout(()=>x(!1),200)),!0))}else!l||"click-end"!==S.type&&"hover-end"!==S.type||C()},[l,C,S]),t.useEffect(()=>{null==u||u(m)},[m,u]),t.useEffect(()=>()=>clearTimeout(k.current),[]),!f&&!b)return null;const O=f&&p?n(f,p):null;if(null===O&&!b)return null;const M=function(e,t,n,o){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:o?"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:n?"translateX(0)":`translateX(${t}px)`,opacity:n?1:0}:"bottom"===e?{bottom:0,left:0,width:"100%",height:t,borderTopWidth:1,padding:"12px 16px",transform:n?"translateY(0)":`translateY(${t}px)`,opacity:n?1:0}:{top:"50%",left:"50%",transform:n?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0.95)",opacity:n?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)"})}(o,i,m,b);return e.jsxs("div",{ref:w,className:`semiotic-details-panel semiotic-details-${o}${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:Vh,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 Vh={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};qh.displayName="DetailsPanel";const Xh=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),Uh=new Set(["ForceDirectedGraph","SankeyDiagram","ChordDiagram"]),Kh=new Set(["BarChart","StackedBarChart","GroupedBarChart","AreaChart","StackedAreaChart"]),Qh=new Set(["LineChart","AreaChart","StackedAreaChart"]),Zh=new Set(["BarChart","StackedBarChart","GroupedBarChart","FunnelChart"]);function Jh(e){const t=e.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);if(!t)return null;const[n,o,i]=[parseInt(t[1],16)/255,parseInt(t[2],16)/255,parseInt(t[3],16)/255],r=e=>e>.03928?Math.pow((e+.055)/1.055,2.4):e/12.92;return.2126*r(n)+.7152*r(o)+.0722*r(i)}function ef(e,t){const n=Jh(e),o=Jh(t);return null===n||null===o?null:(Math.max(n,o)+.05)/(Math.min(n,o)+.05)}const tf=["xAccessor","yAccessor","timeAccessor","valueAccessor","categoryAccessor","colorBy","sizeBy","lineBy","areaBy","stackBy","groupBy","orderAccessor","y0Accessor","sourceAccessor","targetAccessor","nodeIDAccessor","childrenAccessor","costAccessor"],nf=new Set(["TreeDiagram","Treemap","CirclePack","OrbitDiagram"]),of=new Set(["PieChart","DonutChart","FunnelChart"]),rf=new Set(["BigNumber"]),sf=new Set(["LineChart","AreaChart","DifferenceChart","StackedAreaChart","Scatterplot","ConnectedScatterplot","BubbleChart","QuadrantChart","MultiAxisLineChart","CandlestickChart","Heatmap","MinimapChart"]),af=new Set(["OrbitDiagram"]),lf=new Set(["RealtimeLineChart","RealtimeHistogram","RealtimeSwarmChart","RealtimeWaterfallChart","RealtimeHeatmap","ProcessSankey"]),cf=new Set(["MultiAxisLineChart"]),uf=new Set(["ChoroplethMap","ProportionalSymbolMap","FlowMap","DistanceCartogram"]),df={Scatterplot:"pointRadius",BubbleChart:"pointRadius",ConnectedScatterplot:"pointRadius",QuadrantChart:"pointRadius",SwarmPlot:"pointRadius",DotPlot:"dotRadius"},hf=new Set(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#f0e442","#000000"]);function ff(e){return"string"==typeof e&&e.trim().length>0}function gf(e){return"primary"===(null==e?void 0:e.emphasis)||"secondary"===(null==e?void 0:e.emphasis)||null!=function(e){var t;const n=null===(t=null==e?void 0:e.provenance)||void 0===t?void 0:t.confidence;return"number"==typeof n&&Number.isFinite(n)?n:null}(e)}function pf(e){const t=e.toLowerCase().replace(/[^a-z]/g,"");if(!t)return 0;if(3>=t.length)return 1;const n=t.replace(/(?:[^laeiouy]es|ed|[^laeiouy]e)$/,"").replace(/^y/,"").match(/[aeiouy]{1,2}/g);return n?n.length:1}function yf(e,t,n={}){const o=[],i=!!bd[e],r=!0===n.inChartContainer,s=!0===n.describe,a=!0===n.navigable,l=rf.has(e),c=nf.has(e),u=!1!==t.accessibleTable&&!l,d=ff(t.title),h=ff(t.description),f=ff(t.summary),g=d||h||f,p=function(e){return!1!==e.tooltip||null!=e.onClick||null!=e.brush||null!=e.onBrush||null!=e.selection||null!=e.linkedHover||null!=e.linkedBrush}(t),y=Array.isArray(t.annotations)?t.annotations.filter(e=>!!e&&"object"==typeof e):[],m=i?"pass":"manual",v=i?"":` (unrecognized component "${e}" — verify manually that the built-in applies)`;if(o.push(function(e){const t={id:"perceivable.low-contrast",principle:"perceivable",heuristic:"Low contrast",critical:!0},n=e.colorScheme,o="string"==typeof e.background?e.background:null;if(o&&!o.startsWith("#"))return Object.assign(Object.assign({},t),{status:"manual",message:`Background "${o}" isn't a hex literal (theme/CSS variable) — contrast can't be verified statically.`,fix:'Pass a hex `background` (e.g. "#ffffff"/"#000000"), or verify contrast manually once the theme resolves.'});const i=null!=o?o:"#ffffff";if(!Array.isArray(n))return Object.assign(Object.assign({},t),{status:"manual",message:"Mark colors come from the theme/CSS variables — contrast can't be verified statically.",fix:"Confirm geometries/large text have ≥ 3:1 and regular text ≥ 4.5:1 contrast against the background."});const r=[];let s=0;for(const e of n){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ef(e,i);null!=t&&(s++,3>t&&r.push(`${e} (${t.toFixed(1)}:1)`))}return Object.assign(Object.assign({},t),0===s?{status:"manual",message:"colorScheme has no parseable hex colors to check.",fix:"Verify contrast manually for non-hex colors."}:r.length>0?{status:"fail",message:`${r.length} color(s) fall below 3:1 contrast vs ${i}: ${r.join(", ")}.`,fix:"Darken (light background) or lighten (dark background) those colors, or use COLOR_BLIND_SAFE_CATEGORICAL."}:{status:"pass",message:`All ${s} checked colorScheme color(s) meet ≥ 3:1 contrast vs ${i}.`})}(t)),o.push(Object.assign({id:"perceivable.content-only-visual",principle:"perceivable",heuristic:"Content is only visual",critical:!0},l?{status:"pass",message:"BigNumber renders its value as real text with an ARIA label — available without vision."}:u?{status:"pass",message:"A screen-reader data table + live region expose the data non-visually (accessibleTable is on)."}:h&&f?{status:"manual",message:"accessibleTable is off; a description + summary are present. Verify they convey everything the chart shows.",fix:"Re-enable accessibleTable, or confirm via screen reader that the text alternative is complete."}:{status:"fail",message:"accessibleTable is disabled and there's no full text alternative — the data is only available visually.",fix:"Remove accessibleTable={false}, or provide a complete description/summary plus a data table."})),o.push({id:"perceivable.small-text",principle:"perceivable",heuristic:"Small text size",critical:!0,status:"pass",message:"Semiotic's default tick and axis-label fonts are 12px, meeting Chartability's 9pt/12px floor.",fix:"If a theme or override lowers --semiotic-tick-font-size below 12px, raise it back for low-vision audiences."}),o.push(Object.assign({id:"perceivable.seizure-risk",principle:"perceivable",heuristic:"Visual presents seizure risk",critical:!0},null!=t.pulse||af.has(e)?{status:"manual",message:"Pulse/continuous animation is in use. Confirm nothing flashes more than 3×/sec, especially saturated red.",fix:"Avoid red flashes and rapid (>3 Hz) flicker; reduced-motion is auto-honored, but verify the default presentation."}:{status:"manual",message:"No flashing detected statically. Confirm no element flashes more than 3×/sec.",fix:"Manual check — most static charts pass trivially."})),null!=t.colorBy){o.push(Object.assign({id:"perceivable.color-alone",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1},!0===t.directLabel||!0===t.showLabels?{status:"pass",message:"Categories are encoded by color (colorBy) and also directly labeled, so color isn't the only channel."}:{status:"warn",message:"Categories are encoded by color (colorBy) with no redundant channel — Semiotic does not yet ship texture/pattern fills.",fix:"Add direct labels (directLabel on LineChart/AreaChart, showLabels on network/hierarchy), keep categories ≤ ~7, and use a CVD-safe palette."}));const e=Array.isArray(t.colorScheme)?t.colorScheme:null,n=e?e.filter(e=>"string"==typeof e&&e.startsWith("#")).map(e=>e.toLowerCase()):[],i=n.length>0&&n.every(e=>hf.has(e));o.push(Object.assign({id:"perceivable.cvd-safe",principle:"perceivable",heuristic:"Not CVD-friendly",critical:!1},i?{status:"pass",message:"colorScheme uses Semiotic's Wong colorblind-safe palette."}:{status:"manual",message:"Color encodes meaning; statically we can't confirm the palette is colorblind-safe.",fix:'Use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic", or test your scheme with Viz Palette / Chroma.'})),o.push({id:"flexible.textures-adjustable",principle:"flexible",heuristic:"Contrast and textures cannot be adjusted",critical:!1,status:"warn",message:"There's no per-category texture/pattern channel to toggle as an alternative to color.",fix:"Until texture fills land, ensure the encoding survives color removal: direct labels + a CVD-safe palette. Contrast itself is themeable via CSS variables."})}{const e=y.filter(pn);if(e.length>0){const n=t.autoPlaceAnnotations,i="object"==typeof n&&null!==n&&!0===n.redundantCues,r=e.filter(e=>{if("string"!=typeof e.color)return!1;const t=gn(e),n=i&&"text"===t;return!(yn(e)||n)});o.push(Object.assign({id:"perceivable.annotation-association",principle:"perceivable",heuristic:"Color is used alone to communicate meaning",critical:!1},0===r.length?{status:"pass",message:"No annotation relies on color alone to indicate its target — wherever color is used, a connector, enclosure, or reference-line cue is present too."}:{status:"warn",message:`${r.length} of ${e.length} annotation(s) carry a color but no connector, enclosure, or reference-line cue, so a color-blind or non-visual reader can't tie them to their target (the correspondence problem).`,fix:"Add a connector (the label/callout default), place the note adjacent to its target, enclose the target, or enable autoPlaceAnnotations: { redundantCues: true } to give colored text notes a leader line — don't rely on color matching alone."}))}}o.push(Object.assign({id:"operable.single-input-modality",principle:"operable",heuristic:"Interaction modality only has one input type",critical:!0},i?{status:"pass",message:"Built-in keyboard navigation (arrows/Home/End/PageUp-Down/Enter) mirrors mouse hover."}:{status:"manual",message:`Can't confirm keyboard support for "${e}".`,fix:"Verify Tab + arrow-key operation."}));{const e=[];null==t.brush&&null==t.onBrush||e.push("brushing"),!0===t.zoomable&&e.push("zoom/pan"),"isolate"!==t.legendInteraction&&"highlight"!==t.legendInteraction||e.push("legend filtering"),e.length>0&&o.push({id:"operable.complex-action-alternatives",principle:"operable",heuristic:"Complex actions have no alternatives",critical:!1,status:"warn",message:`Mouse-driven ${e.join(", ")} ${e.length>1?"have":"has"} no built-in keyboard/standard-UI equivalent.`,fix:"Pair the complex interaction with a standard control (range inputs for a brush, buttons for zoom, a checkbox list for legend filtering) operable by keyboard and screen reader."})}{const n=df[e];if(n&&p){const e=t[n];"number"==typeof e&&e>0&&24>2*e&&o.push({id:"operable.target-size",principle:"operable",heuristic:"Target pointer interaction size is too small",critical:!1,status:"warn",message:`${n}=${e} gives a ~${2*e}px hit target, below the 24×24px minimum for pointer interaction.`,fix:"Increase the radius, or rely on the chart's hoverRadius / keyboard navigation as the alternative for precise selection."})}}o.push({id:"operable.tab-stops",principle:"operable",heuristic:"Inappropriate tab stops",critical:!1,status:m,message:`The chart takes a single tab stop and navigates data with arrow keys${v} — the recommended pattern for dense charts (no per-datum tab stops to wade through).`}),o.push(Object.assign({id:"operable.interaction-cues",principle:"operable",heuristic:"No interaction cues or instructions",critical:!0},p?f||h?{status:"manual",message:"Chart is interactive and has descriptive text. Confirm that text explains how to interact (keyboard + pointer).",fix:'State the interaction model in summary, e.g. "Use arrow keys to move between points."'}:{status:"warn",message:"Chart is interactive but nothing explains how to use it.",fix:"Describe the interaction in a summary or nearby text (keyboard navigation, what hover/click reveals)."}:{status:"not-applicable",message:"No interactive behavior detected."})),o.push({id:"operable.controls-override-at",principle:"operable",heuristic:"Controls override AT controls",critical:!0,status:m,message:`Keyboard handlers fire only while the chart has focus, so they don't hijack page/app screen-reader shortcuts${v}.`}),o.push({id:"operable.focus-indicator",principle:"operable",heuristic:"Keyboard focus indicator missing, obscured, or low contrast",critical:!1,status:m,message:`A shape-adaptive focus ring (var(--semiotic-focus)) marks the focused element${v}.`,fix:i?"Ensure --semiotic-focus keeps ≥ 3:1 contrast against your background.":void 0}),o.push(Object.assign({id:"understandable.title-summary-caption",principle:"understandable",heuristic:"No title, summary, or caption",critical:!0},g?{status:"pass",message:`Provided: ${[d&&"title",h&&"description",f&&"summary"].filter(Boolean).join(", ")}.`}:r?{status:"manual",message:"No title/description/summary on the chart. If the wrapping ChartContainer supplies a title/subtitle, this is covered at that layer — verify it does.",fix:"Give the ChartContainer a title (and optionally enable describe), or set title/description/summary on the chart."}:{status:"fail",message:"No title, description, or summary — the screen reader falls back to a generic label.",fix:"Add title/description/summary on the chart, or wrap it in a ChartContainer (the opt-in layer for title/caption/description chrome)."})),o.push(Object.assign({id:"understandable.explain-purpose",principle:"understandable",heuristic:"No explanation for purpose or for how to read",critical:!0},h||f?{status:"pass",message:"A description/summary is available to explain purpose and how to read the chart."}:s?{status:"manual",message:"ChartContainer's describe option explains how to read the chart (type, stats, trend). Confirm the domain purpose — why this chart exists — is also conveyed (title/subtitle).",fix:"Give the ChartContainer a title/subtitle stating the purpose; describe() covers the how-to-read half."}:d?{status:"warn",message:"Only a title is set — a label, not an explanation of purpose or how to read the chart.",fix:"Add a summary, or enable ChartContainer's describe option for an auto-generated how-to-read description."}:{status:"fail",message:"Nothing explains the chart's purpose or how to read it.",fix:"Add a summary/description, or wrap in a ChartContainer with a title and the describe option (the opt-in full-accessibility layer)."}));{const e=[t.description,t.summary].filter(ff).join(". "),n=e?function(e){const t=e.split(/[.!?]+/).map(e=>e.trim()).filter(Boolean),n=e.trim().split(/\s+/).filter(Boolean);if(0===n.length||0===t.length)return null;let o=0;for(const e of n)o+=pf(e);return n.length/t.length*.39+o/n.length*11.8-15.59}(e):null;o.push(Object.assign({id:"understandable.reading-level",principle:"understandable",heuristic:"Reading level inappropriate",critical:!0},null==n?{status:"not-applicable",message:"No description/summary text to grade."}:n>9?{status:"warn",message:`Description/summary reads at ~grade ${n.toFixed(0)}; Chartability targets grade 9 or lower.`,fix:"Shorten sentences and prefer common words."}:{status:"pass",message:`Description/summary reads at ~grade ${Math.max(0,Math.round(n))} (≤ 9).`}))}if(sf.has(e)){const e=ff(t.xLabel),n=ff(t.yLabel);o.push(Object.assign({id:"understandable.axis-labels",principle:"understandable",heuristic:"Axis labels are unclear or missing",critical:!1},e&&n?{status:"pass",message:"Both axes are labeled (xLabel, yLabel)."}:{status:"warn",message:`Missing axis label: ${[!e&&"xLabel",!n&&"yLabel"].filter(Boolean).join(", ")}. Ticks alone may not name the variable.`,fix:"Set xLabel and yLabel to name each axis's variable and units."}))}if(cf.has(e)&&o.push({id:"understandable.information-complexity",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1,status:"warn",message:"Dual-axis chart: two y-scales are hard to read accurately and notoriously easy to misinterpret (the crossover point is arbitrary).",fix:"Confirm the second axis is necessary; consider two aligned charts (small multiples) or indexing both series to a common baseline. Label each axis and its series unambiguously."}),y.length>1){const e=y.filter(gf).length;o.push(Object.assign({id:"understandable.annotation-hierarchy",principle:"understandable",heuristic:"Information complexity is inappropriate",critical:!1},e===y.length?{status:"pass",message:`All ${y.length} annotation(s) declare hierarchy through emphasis or provenance confidence, so the renderer can resolve reading order and visual priority.`}:0===e?{status:"warn",message:y.length+" annotations are present with no emphasis or provenance confidence; readers may not know which note is primary.",fix:'Mark the main annotation with emphasis="primary", set supporting notes to emphasis="secondary", or provide provenance.confidence so Semiotic can infer order.'}:{status:"warn",message:`${y.length-e} of ${y.length} annotation(s) have no emphasis or provenance confidence; readers may not know which note is primary among the unordered notes.`,fix:"Set emphasis on each annotation (primary/secondary), or provide provenance.confidence on all annotations so Semiotic can infer order."}))}(null!=t.forecast||null!=t.anomaly||null!=t.band||null!=t.regression)&&o.push({id:"understandable.uncertainty",principle:"understandable",heuristic:"Statistical uncertainty isn't clearly communicated",critical:!1,status:"manual",message:"The chart shows a forecast/regression/band/anomaly overlay. Confirm the uncertainty it represents is explained in text, not just drawn.",fix:"State the confidence interval / method in the summary, and label the band so it isn't mistaken for data."}),null!=t.animate&&!1!==t.animate&&o.push({id:"understandable.changes-followable",principle:"understandable",heuristic:"Changes are not easy to follow",critical:!1,status:m,message:`Transitions animate with object constancy and data changes are mirrored to the live region${v}.`,fix:i?"Keep transition durations in the 250ms–2s range so changes are followable but not slow.":void 0}),o.push({id:"robust.conforms-to-standards",principle:"robust",heuristic:"Does not conform to standards",critical:!1,status:"manual",message:"WCAG 2.1 / Section 508 conformance can't be settled from config alone.",fix:"Run an automated checker (axe) on the rendered output and test with real assistive tech."}),o.push({id:"robust.semantically-valid",principle:"robust",heuristic:"Semantically invalid",critical:!1,status:"manual",message:"Whether interactive elements expose correct roles/names is a render-time, screen-reader question.",fix:"Verify with a screen reader that buttons read as buttons, the chart as an image/group, etc."}),o.push({id:"robust.fragile-technology-support",principle:"robust",heuristic:"Fragile technology support",critical:!1,status:m,message:`Charts render on canvas with an SVG overlay and render to SVG in SSR, so access isn't tied to one rendering path${v}.`,fix:i?"Still test across NVDA+Firefox, JAWS+Chrome, and VoiceOver+Safari — AT support varies.":void 0}),o.push(Object.assign({id:"compromising.table",principle:"compromising",heuristic:"No table",critical:!0},l?{status:"not-applicable",message:"Single-value display — a table isn't meaningful."}:u?{status:"pass",message:"A human-readable data table is provided (accessibleTable)."}:{status:"fail",message:"accessibleTable is disabled — no human-readable table of the underlying data.",fix:"Remove accessibleTable={false} (unless title/summary/annotations already convey all the data)."})),l||o.push(Object.assign({id:"compromising.table-static",principle:"compromising",heuristic:"Table/data is static",critical:!1},r?{status:"manual",message:"Rendered in a ChartContainer. If a data-download action is enabled, the data is exportable.",fix:"Enable the ChartContainer data-download action so users can save the underlying data (keep it opt-in)."}:{status:"warn",message:"The data table is read-only — not downloadable, sortable, or filterable.",fix:"Wrap the chart in a ChartContainer and enable its data-download action (opt-in, so deployments can withhold it where export isn't allowed)."})),o.push({id:"compromising.shareable-state",principle:"compromising",heuristic:"State is not easy to share and reproduce",critical:!1,status:i?"pass":"manual",message:`Chart state serializes via toConfig/toURL/copyConfig${i?"":v}.`,fix:i?"Expose it to users via the ChartContainer copyConfig action or a shareable URL.":void 0}),o.push(Object.assign({id:"compromising.navigable-structure",principle:"compromising",heuristic:"Information cannot be navigated according to narrative or structure",critical:!1},a?{status:"pass",message:"ChartContainer's navigable option mounts a structured tree (chart → axes/series → data points) that screen readers can traverse."}:c?{status:"warn",message:"Hierarchical chart: built-in keyboard navigation is largely flat — it doesn't descend the tree structure.",fix:"Enable ChartContainer's navigable option for a structured navigation tree, or lean on the data table and a summary that conveys the hierarchy."}:{status:m,message:`Keyboard navigation steps through points and switches series/groups${v}.`,fix:i?"For deeper structure (axis → series → datum), enable ChartContainer's navigable option.":void 0}));{const n=Array.isArray(t.data)?t.data:null,i=Array.isArray(t.nodes)?t.nodes:null,r={id:"assistive.data-density",principle:"assistive",heuristic:"Data density is inappropriate",critical:!0};let s;s=of.has(e)&&n&&n.length>7?Object.assign(Object.assign({},r),{status:"warn",message:n.length+" slices in a part-to-whole chart. Chartability suggests ≤ 5 categories; many thin slices are hard to perceive and to describe.",fix:'Group small slices into an "Other" category, or switch to a ranked bar chart.'}):Object.assign(Object.assign({},r),i&&i.length>200?{status:"warn",message:i.length+" nodes. A network this size is hard to navigate non-visually node by node.",fix:"Provide a summary of structure (clusters, hubs, components) and consider filtering or aggregating the graph."}:n&&n.length>5e3?{status:"warn",message:n.length+" data points. Canvas renders this fine, but the non-visual table/navigation become unwieldy.",fix:"Aggregate or bin for the accessible representation, or expose summary statistics rather than every row."}:n?{status:"pass",message:n.length+" data points — a reasonable density for non-visual consumption."}:i?{status:"pass",message:i.length+" nodes — a reasonable density for non-visual consumption."}:{status:"manual",message:"Data not provided inline (push mode); verify density at runtime."}),o.push(s)}{const e=Array.isArray(t.data)?t.data:null,n=["valueFormat","yFormat","xFormat","tickFormat","format"].some(e=>"function"==typeof t[e]||"string"==typeof t[e]);let i=!1;if(e&&!n)for(const t of e.slice(0,50))if(t&&"object"==typeof t){for(const e of Object.values(t))if("number"==typeof e&&Number.isFinite(e)&&Math.abs(e)>=1e5){i=!0;break}if(i)break}i&&o.push({id:"assistive.human-readable-numbers",principle:"assistive",heuristic:"Data in text is not human-readable",critical:!1,status:"warn",message:'Data includes large numbers (≥ 100,000) and no value/tick formatter — screen readers will read every digit (e.g. "six hundred fifty thousand…").',fix:'Pass valueFormat / yFormat (e.g. a compact formatter so 6,500,000 reads as "6.5M"); the formatter flows to ticks, tooltips, and the data table.'})}o.push(Object.assign({id:"assistive.features-described",principle:"assistive",heuristic:"Visually apparent features and relationships are not described",critical:!1},s?{status:"pass",message:"ChartContainer's describe option auto-generates an L1–L3 description (chart type, statistics, and trend) via describeChart()."}:f?{status:"manual",message:"A summary is present. Confirm it describes trends, extrema, clusters, and outliers — not just what the chart is.",fix:"Cover the L2/L3 content blind readers value most: direction of trend, peak/trough, notable outliers."}:{status:"warn",message:"No text describes the visually apparent trends, extrema, or outliers.",fix:"Enable ChartContainer's describe option (auto-generates via describeChart()), or write a summary covering the key trend and notable points."})),o.push(Object.assign({id:"assistive.skippable-navigation",principle:"assistive",heuristic:"Navigation and interaction is tedious",critical:!0},l?{status:"not-applicable",message:"Single value — nothing to skip."}:u?{status:"pass",message:'A "Skip to data table" link lets screen-reader users bypass point-by-point navigation.'}:{status:"warn",message:"accessibleTable is off, removing the skip-to-table affordance.",fix:"Keep accessibleTable enabled so users can skip past dense point navigation."})),o.push({id:"flexible.user-style-respected",principle:"flexible",heuristic:"User style change not respected",critical:!0,status:m,message:`Styling flows through CSS custom properties and honors forced-colors mode, so user/user-agent style changes cascade in${v}.`,fix:i?"Avoid hardcoding colors via frameProps style fns that bypass theme variables.":void 0}),o.push(Object.assign({id:"flexible.reduced-motion",principle:"flexible",heuristic:"Long animations cannot be controlled",critical:!1},af.has(e)||lf.has(e)?{status:"warn",message:e+" animates continuously. prefers-reduced-motion is auto-honored, but there's no in-chart pause/stop control for users who don't set that preference.",fix:"Offer a pause/stop control for looping/streaming motion (Chartability requires it for animation > 2s)."}:{status:m,message:`prefers-reduced-motion is auto-detected; transitions fast-forward and looping animation stops${v}.`}));{const n=!0===t.responsiveWidth||!0===t.responsiveHeight,i=uf.has(e)&&!0===t.zoomable;o.push(Object.assign({id:"flexible.zoom-reflow",principle:"flexible",heuristic:"Zoom and reflow are not supported",critical:!1},n?{status:"pass",message:`Chart reflows to its container (${[!0===t.responsiveWidth&&"responsiveWidth",!0===t.responsiveHeight&&"responsiveHeight"].filter(Boolean).join(", ")}), so page zoom doesn't clip it.`}:i?{status:"pass",message:"Geo chart is zoomable/pannable."}:{status:"manual",message:"Fixed width/height — verify the chart survives browser zoom and reflow without clipping or loss of function.",fix:"Use responsiveWidth/responsiveHeight so the chart reflows to its container."}))}const b=o.filter(e=>"not-applicable"!==e.status).filter(e=>e.critical),x={criticalsPassed:b.filter(e=>"pass"===e.status).length,criticalsEvaluated:b.length,fails:o.filter(e=>"fail"===e.status).length,warnings:o.filter(e=>"warn"===e.status).length,manual:o.filter(e=>"manual"===e.status).length,passes:o.filter(e=>"pass"===e.status).length};return{component:e,ok:!b.some(e=>"fail"===e.status),summary:x,findings:o,reference:"Chartability (POUR-CAF) — https://chartability.github.io/POUR-CAF/. Not a pass/fail cert; pair with manual screen-reader testing (NVDA+Firefox, JAWS+Chrome, VoiceOver+Safari)."}}const mf={pass:"✓",fail:"✗",warn:"⚠",manual:"○","not-applicable":"·"},vf=["perceivable","operable","understandable","robust","compromising","assistive","flexible"];function bf(e){return"nominal"===e||"ordinal"===e}function xf(e){return"quantitative"===e||"temporal"===e}const wf={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"},kf={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"},Af={sum:"sum",mean:"mean",average:"mean",count:"count",min:"min",max:"max",median:"mean"};function jf(e,t,n,o,i){var r,s;(null==e?void 0:e.field)&&(n.xAccessor=o?"value":e.field),(null==t?void 0:t.field)&&(n.yAccessor=i?"value":t.field),(null===(r=null==e?void 0:e.axis)||void 0===r?void 0:r.title)&&(n.xLabel=e.axis.title),(null===(s=null==t?void 0:t.axis)||void 0===s?void 0:s.title)&&(n.yLabel=t.axis.title)}function Sf(e,t,n){const o={component:e,props:t,version:"1",createdAt:(new Date).toISOString()};if(n.length>0){o.warnings=n;for(const e of n)console.warn("[semiotic/fromVegaLite] "+e)}return o}const Cf=/^\d{4}[-/]\d{2}/,Of=/^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;function Mf(e){return"number"==typeof e?Number.isFinite(e)?"numeric":"unknown":e instanceof Date?"date":"string"==typeof e?Cf.test(e)&&!Number.isNaN(Date.parse(e))?"date":Of.test(e)&&Number.isFinite(Number(e))?"numeric":"categorical":"boolean"==typeof e?"categorical":"unknown"}function Pf(e){let t=1/0,n=-1/0;for(let o=0;e.length>o;o++){const i=e[o];t>i&&(t=i),i>n&&(n=i)}return{min:t,max:n}}function _f(e){const t=e.length;if(0===t)return NaN;const n=t>>1;return t%2==0?(e[n-1]+e[n])/2:e[n]}function Lf(e,t={}){var n,o;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 n=e[t];if(n&&"object"==typeof n)for(const e of Object.keys(n))a.add(e)}const c={};for(const t of a){const r=[];for(let o=0;e.length>o;o++){const i=null===(n=e[o])||void 0===n?void 0:n[t];null!=i&&r.push(i)}if(0===r.length){c[t]={type:"unknown"};continue}const s=Mf(r[0]);if("numeric"===s){const e=[];for(let t=0;r.length>t;t++){const n=Number(r[t]);Number.isFinite(n)&&e.push(n)}if(0===e.length){c[t]={type:"unknown"};continue}const{min:n,max:o}=Pf(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:n,max:o,mean:i/e.length,median:_f(s)}}else if("date"===s){const e=[];for(let t=0;r.length>t;t++){const n=r[t],o=n instanceof Date?n.getTime():Date.parse(n);Number.isFinite(o)&&e.push(o)}if(0===e.length){c[t]={type:"unknown"};continue}const{min:n,max:o}=Pf(e);c[t]={type:"date",min:new Date(n).toISOString(),max:new Date(o).toISOString()}}else if("categorical"===s){const e=new Map;for(let t=0;r.length>t;t++){const n=r[t]+"";e.set(n,(null!==(o=e.get(n))&&void 0!==o?o:0)+1)}const n=[...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:n,distinctValues:e.size>i?void 0:n.map(e=>e.value)}}else c[t]={type:"unknown"}}return{rowCount:e.length,fields:c,sample:e.slice(0,r)}}const Tf=/^(x|index|rank|order|step|sequence|year|quarter|qtr|fiscal|month|week|day|date|time|timestamp)$/i,Nf=/^(y|value|amount|total|count|revenue|sales|price|score|rate|population|measure)$/i,Rf=/(size|magnitude|volume|weight|count|amount)/i,$f=/^(category|label|name|type|group|region|segment|kind|class)$/i,Df=/^(series|group|type|category|segment|cohort|product)$/i,Bf=new Set(["numeric"]),If=new Set(["numeric","date"]),Ef=new Set(["numeric"]),Ff=new Set(["date"]),Hf=new Set(["categorical","boolean"]);function zf(e){return"numeric"===e.type?"numeric":"date"===e.type?"date":"categorical"===e.type?"categorical":"unknown"}function Wf(e,t){return t.test(e)?.2:0}function Gf(e,t){var n;let o=null;for(let i=0;e.length>i;i++){const r=null===(n=e[i])||void 0===n?void 0:n[t];if(null==r)continue;const s=r instanceof Date?r.getTime():Number(r);if(!Number.isFinite(s))return!1;if(null!==o&&o>s)return!1;o=s}return null!==o}function Yf(e,t,n,o,i={}){const r=[];for(const[s,a]of Object.entries(e)){const e=zf(a);if(!n.has(e))continue;let l,c=.5;c+=Wf(s,o),"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=Gf(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 qf(e,t){var n;const o=new Set;for(let i=0;e.length>i;i++){const r=null===(n=e[i])||void 0===n?void 0:n[t];null!=r&&o.add(r+"")}return o.size}const Vf=/^(source|from|origin|stage|currentstage|sourcestage|fromstage)$/i,Xf=/^(target|to|destination|nextstage|next|targetstage|tostage|destinationstage|status)$/i,Uf=/^(starttime|startedat|enteredat|startdate|start|timestamp|date|time)$/i,Kf=/^(endtime|endedat|exitedat|completedat|finishtime|enddate|end)$/i,Qf=/^(value|weight|amount|count|magnitude|volume)$/i;function Zf(e,t){return e.find(e=>t.test(e))}function Jf(e,t={}){var n,o,i,r,s,a,l;const c=Lf(null!=e?e:[]),u=Array.isArray(e)?e:[],d=function(e){var t;if(e&&"object"==typeof e&&!Array.isArray(e)){const n=e;if("FeatureCollection"===n.type&&Array.isArray(n.features))return{hasHierarchy:!1,hasNetwork:!1,hasGeo:!0,geo:{features:n.features,points:Array.isArray(n.points)?n.points:void 0,flows:Array.isArray(n.flows)?n.flows:void 0}};if(Array.isArray(n.children))return{hasHierarchy:!0,hasNetwork:!1,hasGeo:!1,hierarchy:n};if(Array.isArray(n.nodes)&&(Array.isArray(n.edges)||Array.isArray(n.links))){const e=null!==(t=n.edges)&&void 0!==t?t:n.links;return{hasHierarchy:!1,hasNetwork:!0,hasGeo:!1,network:{nodes:n.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,n;if(3>e.length)return null;const o=e[0];if(!o||"object"!=typeof o)return null;const i=Object.keys(o),r=Zf(i,Vf),s=Zf(i,Xf);if(!r||!s||r===s)return null;const a=Zf(i,Uf),l=Zf(i,Kf),c=Zf(i,Qf),u=[];for(const t of e){if(!t)continue;const e=t[r],n=t[s];if(null==e||null==n)continue;const o=(e+"").trim(),i=(n+"").trim();o&&i&&o!==i&&u.push(t)}if(3>u.length)return null;const d=new Map,h=new Map,f=new Map;for(const e of u){const n=(e[r]+"").trim(),o=(e[s]+"").trim();d.has(n)||d.set(n,{id:n,label:n}),d.has(o)||d.set(o,{id:o,label:o});const i=`${n}->${o}`,u=c?Number(e[c]):1,g=Number.isFinite(u)?u:1;h.set(i,(null!==(t=h.get(i))&&void 0!==t?t:0)+g),f.has(i)||f.set(i,Object.assign(Object.assign({source:n,target:o},a?{startTime:e[a]}:{}),l?{endTime:e[l]}:{}))}const g=[];for(const[e,t]of f)g.push(Object.assign(Object.assign({},t),{value:null!==(n=h.get(e))&&void 0!==n?n:1}));return{nodes:Array.from(d.values()),edges:g}}(u);e&&(d.hasNetwork=!0,d.network=e)}const h=Yf(c.fields,u,If,Tf,{computeMonotonic:!0}),f=Yf(c.fields,u,Ef,Nf),g=Yf(c.fields,u,Bf,Rf),p=Yf(c.fields,u,Hf,$f),y=Yf(c.fields,u,Hf,Df),m=Yf(c.fields,u,Ff,/(date|time|timestamp)/i,{computeMonotonic:!0}),v=null===(n=m[0])||void 0===n?void 0:n.field;let b=v,x=v?"time":"none";if(!b){const e=h.find(e=>Tf.test(e.field)&&"numeric"===e.kind);e&&(b=e.field,x="named")}const w=null===(o=f.find(e=>e.field!==b))||void 0===o?void 0:o.field;if(!b&&w){const e=Object.entries(c.fields).filter(([e,t])=>"numeric"===t.type).map(([e])=>e);2>e.length||(b=e.find(e=>e!==w),b&&(x="scatter"))}const k=null===(i=g.find(e=>e.field!==b&&e.field!==w))||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?qf(u,S):void 0,M=C?qf(u,C):void 0,P=b?qf(u,b):void 0,_=!!b&&function(e,t){var n;const o=new Set;for(let i=0;e.length>i;i++){const r=null===(n=e[i])||void 0===n?void 0:n[t];if(null==r)continue;const s=r+"";if(o.has(s))return!0;o.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:f,size:g,category:p,series:y,time:m},primary:{x:b,y:w,size:k,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 eg={rows:{tiny:3,small:25,medium:250,large:5e3},cardinality:{low:7,medium:25},fields:{narrow:3,typical:10}},tg=["tiny","small","medium","large","huge"];function ng(e){var t,n,o;return{rows:Object.assign(Object.assign({},eg.rows),null!==(t=null==e?void 0:e.rows)&&void 0!==t?t:{}),cardinality:Object.assign(Object.assign({},eg.cardinality),null!==(n=null==e?void 0:e.cardinality)&&void 0!==n?n:{}),fields:Object.assign(Object.assign({},eg.fields),null!==(o=null==e?void 0:e.fields)&&void 0!==o?o:{})}}function og(e,t){if(!Number.isFinite(e)||0>e)return"tiny";const n=ng(null==t?void 0:t.thresholds).rows;return e>n.tiny?e>n.small?e>n.medium?e>n.large?"huge":"large":"medium":"small":"tiny"}function ig(e,t){if(!Number.isFinite(e)||0>e)return"low";const n=ng(null==t?void 0:t.thresholds).cardinality;return e>n.low?e>n.medium?"high":"medium":"low"}function rg(e,t){if(!Number.isFinite(e)||0>e)return"narrow";const n=ng(null==t?void 0:t.thresholds).fields;return e>n.narrow?e>n.typical?"wide":"typical":"narrow"}function sg(e,t){return tg.indexOf(e)-tg.indexOf(t)}function ag(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=ng(null==n?void 0:n.thresholds).rows;switch(e){case"tiny":return Math.max(1,Math.floor(t.tiny/2));case"small":return Math.floor((t.tiny+t.small)/2);case"medium":return Math.floor((t.small+t.medium)/2);case"large":return Math.floor((t.medium+t.large)/2);case"huge":return Math.floor(2*t.large)}}return t}function lg(e,t,n){if("number"==typeof e&&Number.isFinite(e))return e;if(void 0!==e){const t=ng(null==n?void 0:n.thresholds).cardinality;switch(e){case"low":return Math.max(1,Math.floor(t.low/2));case"medium":return Math.floor((t.low+t.medium)/2);case"high":return Math.floor(2*t.medium)}}return t}function cg(e,t){var n,o,i,r;const s=null!==(n=e.rowCount)&&void 0!==n?n:0,a=null==t?void 0:t.rows,l=ag(a,s,t),c=og(l,t),u=Object.keys(null!==(o=e.fields)&&void 0!==o?o:{}).length,d=null==t?void 0:t.fields,h="number"==typeof d?d:"string"==typeof d?function(e,t){const n=ng(null==t?void 0:t.thresholds).fields;switch(e){case"narrow":return Math.max(1,Math.floor(n.narrow/2));case"typical":return Math.floor((n.narrow+n.typical)/2);case"wide":return Math.floor(2*n.typical)}}(d,t):u,f=rg(h,t),g=e.primary.category,p=g?null===(i=null==t?void 0:t.cardinality)||void 0===i?void 0:i[g]:void 0,y=lg(null!=p?p:null==t?void 0:t.typicalCardinality,e.categoryCount,t);return{rows:l,rowBand:c,fields:h,fieldBand:f,typicalCardinality:y,cardinalityBand:void 0!==y?ig(y,t):void 0,growth:null!==(r=null==t?void 0:t.growth)&&void 0!==r?r:"static",rowsSource:void 0!==a?"declared":"measured"}}const ug=2.5;function dg(e,t,n,o,i){var r,s,a;const l=[],c=[];let u=0,d=!1;if(e.scaleFit){const i=e.scaleFit(t,n,o);if(i&&(u+=Math.max(-2.5,Math.min(ug,null!==(r=i.delta)&&void 0!==r?r:0)),i.reason&&l.push(i.reason),i.caveats))for(const e of i.caveats)c.push(e)}const h=null===(s=null==o?void 0:o.charts)||void 0===s?void 0:s[e.component];if(h&&(h.minBand&&0>sg(n.rowBand,h.minBand)||h.maxBand&&sg(n.rowBand,h.maxBand)>0?d=!0:"number"==typeof h.bias?(u+=Math.max(-3,Math.min(3,h.bias)),h.reason&&l.push(`${(null==o?void 0:o.name)?o.name+": ":""}${h.reason}`)):h.reason&&l.push(`${(null==o?void 0:o.name)?o.name+": ":""}${h.reason}`)),i&&e.qualityFit){const n=e.qualityFit(t,i);if(n&&(u+=Math.max(-1,Math.min(1,null!==(a=n.delta)&&void 0!==a?a:0)),n.reason&&l.push(n.reason),n.caveats))for(const e of n.caveats)c.push(e)}else if(i){const e=t.primary.y;if(e){const t=function(e,t){if(void 0===e)return;if("number"==typeof e)return e;const n=e[t];return"number"==typeof n?n:void 0}(i.completeness,e);void 0!==t&&.85>t&&c.push(`${e} is only ${Math.round(100*t)}% complete — expect gaps`)}}return{delta:u,reasons:l,caveats:c,excluded:d}}function hg(e){return(t,n)=>{let o=0;const i=[];let r;if(e.rows){const[t,s]=e.rows.sweetSpot;t>n.rows||n.rows>s?t>n.rows?(o-=Math.min(ug,.8*(0===t?1:(t-n.rows)/t)),void 0===e.rows.caveatBelow||n.rows>e.rows.caveatBelow||i.push(`only ${n.rows} rows — chart may feel sparse`)):(o-=Math.min(ug,.4*(0===s?1:(n.rows-s)/s)),void 0===e.rows.caveatAbove||e.rows.caveatAbove>n.rows||i.push(n.rows+" rows is past this chart's comfortable density")):(o+=.6,r=n.rows+" rows is in the sweet spot for this chart")}if(e.cardinality&&void 0!==n.typicalCardinality){const t=n.typicalCardinality,[r,s]=e.cardinality.sweetSpot;r>t||t>s?t>s&&(o-=Math.min(ug,.5*(0===s?1:(t-s)/s)),void 0===e.cardinality.caveatAbove||e.cardinality.caveatAbove>t||i.push(t+" distinct categories may overwhelm this chart")):o+=.4}return 0!==o||0!==i.length||r?{delta:o,reason:r,caveats:i}:null}}const fg={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 n=null===(t=e.candidates.x.find(t=>t.field===e.primary.x))||void 0===t?void 0:t.kind;return n&&"numeric"!==n&&"date"!==n?`x field "${e.primary.x}" is ${n}, 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 n;const o={data:e.data,xAccessor:e.primary.x,yAccessor:e.primary.y};return e.seriesCount&&e.seriesCount>=2&&e.primary.series&&(o.lineBy=e.primary.series,o.colorBy=e.primary.series),e.hasTimeAxis&&e.primary.x===e.primary.time&&(o.xScaleType="time"),Object.assign(Object.assign({},o),null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})},scaleFit:hg({rows:{sweetSpot:[25,2e3],caveatBelow:4,caveatAbove:1e4}})},gg={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 n,o;let i=e.data;if(e.seriesCount&&e.seriesCount>=2&&e.primary.series){const t=e.primary.series,o=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[o]);r.set(e,(null!==(n=r.get(e))&&void 0!==n?n: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!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})},scaleFit:hg({rows:{sweetSpot:[6,200],caveatAbove:2e3}})},pg={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 n;const o={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&&(o.xScaleType="time"),Object.assign(Object.assign({},o),null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})},scaleFit:hg({rows:{sweetSpot:[30,1500],caveatBelow:12,caveatAbove:1e4}})},yg={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 n=null===(t=e.candidates.x.find(t=>t.field===e.primary.x))||void 0===t?void 0:t.kind;return"date"===n?null:n&&"numeric"!==n?`x field "${e.primary.x}" is ${n}, Scatterplot needs numeric`:null},intentScores:{correlation:e=>{const t="time"===e.xProvenance||"named"===e.xProvenance?e.primary.x:e.primary.time,n=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&n.length>=2||e.primary.size?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 n;const o={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?(o.xAccessor=r[0],o.yAccessor=r[1]):(o.xAccessor=e.primary.x,o.yAccessor=e.primary.y,e.primary.size&&(o.sizeBy=e.primary.size)),e.primary.series&&e.seriesCount&&6>=e.seriesCount&&(o.colorBy=e.primary.series),Object.assign(Object.assign({},o),null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})},scaleFit:hg({rows:{sweetSpot:[50,5e3],caveatBelow:20,caveatAbove:1e4}})},mg={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,n=t?e.candidates.y.filter(e=>e.field!==t).map(e=>e.field):[];return t&&n.length>=2?5:4},"change-detection":3},caveats:()=>["readers can confuse path direction without explicit start/end markers"],buildProps:e=>{var t,n;const o={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?(o.xAccessor=r[0],o.yAccessor=r[1],o.orderAccessor=i):(o.xAccessor=e.primary.x,o.yAccessor=e.primary.y,o.orderAccessor=null!==(t=e.primary.time)&&void 0!==t?t:e.primary.x),e.primary.series&&6>=(null!==(n=e.seriesCount)&&void 0!==n?n:0)&&(o.colorBy=e.primary.series),o}},vg={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:5,"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}:{})},scaleFit:hg({rows:{sweetSpot:[10,500],caveatAbove:1500}})},bg={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 n=e.primary.x,o=e.primary.y,i=e.fields[n],r=e.fields[o],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:n,yAccessor:o},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({},Vs),topRight:Object.assign({},Xs),bottomLeft:Object.assign({},Us),bottomRight:Object.assign({},Ks)}})}},xg={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,n])=>"numeric"===n.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,n])=>"numeric"===n.type&&t!==e.primary.x).slice(0,2).map(([e])=>({yAccessor:e,label:e}));return{data:e.data,xAccessor:e.primary.x,series:t}}},wg={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"}:{})},kg={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,n,o;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 n of e.data){const e=n[s];if(!a(e))continue;const o=e+"",i=Number(n[r]);l.set(o,(null!==(t=l.get(o))&&void 0!==t?t:0)+(Number.isFinite(i)?i:0))}const c=[...l.entries()].sort((e,t)=>t[1]-e[1]),u=null===(n=c[0])||void 0===n?void 0:n[0],d=null===(o=c[1])||void 0===o?void 0:o[0],h=e=>e instanceof Date?e.getTime():e,f=new Map;for(const t of e.data){const e=t[s];if(!a(e))continue;const n=e+"";if(n!==u&&n!==d)continue;const o=t[i],l=t[r],c=h(o);let g=f.get(c);g||(g={[i]:o},f.set(c,g)),n===u?g.a=l:n===d&&(g.b=l)}return{data:Array.from(f.values()).filter(e=>null!=e.a&&null!=e.b),xAccessor:i,seriesAAccessor:"a",seriesBAccessor:"b",seriesALabel:u,seriesBLabel:d}}},Ag={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())),n=t.has("high"),o=t.has("low");return n&&o?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),n=e=>t.find(t=>t.toLowerCase()===e);return{data:e.data,xAccessor:e.primary.x,highAccessor:n("high"),lowAccessor:n("low"),openAccessor:n("open"),closeAccessor:n("close")}}},jg={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 n=e.candidates.category.length;return n>=2||n>=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 n=[];return(null!==(t=e.uniqueXCount)&&void 0!==t?t:0)>30&&n.push("many x values — cells will be narrow"),n},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 n,o,i,r;const s=e.candidates.category.map(e=>e.field),a=null!==(n=e.primary.time)&&void 0!==n?n:s[0],l=null!==(i=null!==(o=s.find(e=>e!==a))&&void 0!==o?o: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:{})},scaleFit:hg({rows:{sweetSpot:[100,1e4],caveatBelow:25,caveatAbove:5e4}})},Sg={component:"BarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:5,accuracy:5,precision:4},fits:e=>{var t,n;return e.primary.category?e.primary.y?1>(null!==(t=e.categoryCount)&&void 0!==t?t:0)?"needs at least 1 category":(null!==(n=e.categoryCount)&&void 0!==n?n: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 n;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})},scaleFit:hg({cardinality:{sweetSpot:[3,15],caveatAbove:25},rows:{sweetSpot:[3,200]}})},Cg={component:"GroupedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:5,precision:4},fits:e=>{var t,n,o;return e.primary.category?e.primary.y?e.primary.series?2>(null!==(t=e.seriesCount)&&void 0!==t?t:0)?"needs 2+ groups":(null!==(n=e.seriesCount)&&void 0!==n?n:0)>6?e.seriesCount+" groups is too many for grouped bars":(null!==(o=e.categoryCount)&&void 0!==o?o: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})},Og={component:"StackedBarChart",family:"categorical",importPath:"semiotic/ordinal",rubric:{familiarity:4,accuracy:4,precision:3},fits:e=>{var t,n;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!==(n=e.seriesCount)&&void 0!==n?n: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 n;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,stackBy:e.primary.series,colorBy:e.primary.series},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})}},Mg={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}),scaleFit:hg({cardinality:{sweetSpot:[10,30],caveatAbove:40},rows:{sweetSpot:[5,300]}})},Pg={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 n=null!==(t=e.categoryCount)&&void 0!==t?t:0;return 2>n?"needs 2+ categories":n>8?n+" 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 n;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})},scaleFit:hg({cardinality:{sweetSpot:[2,5],caveatAbove:6}})},_g={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 n=null!==(t=e.categoryCount)&&void 0!==t?t:0;return 2>n?"needs 2+ categories":n>8?n+" 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})},Lg=/(stage|step|funnel|status|outcome|phase)/i,Tg={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=>Lg.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=>Lg.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}:{})}},Ng={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,"part-to-whole":e=>1===e.rowCount?5:1},caveats:()=>["gauges only show a single value; consider a stat card or bar instead for comparison"],buildProps:e=>{const t=e.primary.y,n=e.data[0],o=n?Number(n[t]):0,i=e.fields[t],r="numeric"===(null==i?void 0:i.type)?i.max:100;return{value:Number.isFinite(o)?o:0,min:0,max:r}},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.6,reason:"designed for single-value displays"}:null},Rg=/(rating|score|likert|satisfaction|nps|agree|sentiment|level)/i,$g={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=>Rg.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=>Rg.test(e));return{data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y,levelAccessor:t,levels:["Very Low","Low","Neutral","High","Very High"]}}},Dg={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})},Bg={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,n=e.candidates.y.find(e=>e.field===t);return void 0!==(null==n?void 0:n.distinctCount)&&6>n.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 n;return Object.assign({data:e.data,valueAccessor:e.primary.y},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})}},Ig={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})},Eg={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}:{})},Fg={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 n;return Object.assign({data:e.data,categoryAccessor:e.primary.category,valueAccessor:e.primary.y},null!==(n=null==t?void 0:t.props)&&void 0!==n?n:{})}},Hg={component:"RidgelinePlot",family:"distribution",importPath:"semiotic/ordinal",rubric:{familiarity:2,accuracy:3,precision:3},fits:e=>{var t,n;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!==(n=e.categoryCount)&&void 0!==n?n: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})},zg={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,n;return(null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes.length)&&void 0!==n?n:0)>500?["large graphs become hairballs — consider filtering or aggregating"]:[]},buildProps:e=>{var t,n,o,i;return{nodes:null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==n?n:[],edges:null!==(i=null===(o=e.network)||void 0===o?void 0:o.edges)&&void 0!==i?i:[],nodeIdAccessor:"id",sourceAccessor:"source",targetAccessor:"target"}},scaleFit:e=>{var t,n;const o=null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes.length)&&void 0!==n?n:0;return 5>o?{delta:-.4,caveats:[`only ${o} nodes — force layout is overkill for this size`]}:o>100?o>300?{delta:-.8,caveats:[o+" nodes — expect a hairball; filter or aggregate before rendering"]}:{delta:0}:{delta:.5,reason:o+" nodes is in the readable range for force layout"}}},Wg={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,n,o,i;return{nodes:null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==n?n:[],edges:null!==(i=null===(o=e.network)||void 0===o?void 0:o.edges)&&void 0!==i?i:[],sourceAccessor:"source",targetAccessor:"target",valueAccessor:"value",nodeIdAccessor:"id"}}},Gg={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,n,o,i;return{nodes:null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==n?n:[],edges:null!==(i=null===(o=e.network)||void 0===o?void 0:o.edges)&&void 0!==i?i:[],valueAccessor:"value"}}},Yg={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,n,o,i,r;const s={nodes:null!==(n=null===(t=e.network)||void 0===t?void 0:t.nodes)&&void 0!==n?n:[],edges:null!==(i=null===(o=e.network)||void 0===o?void 0:o.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}},qg={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 n,o;return Object.assign({data:null!==(n=e.hierarchy)&&void 0!==n?n:{name:"root",children:[]}},null!==(o=null==t?void 0:t.props)&&void 0!==o?o:{})}};function Vg(e){if(!e||"object"!=typeof e)return 0;const t=e.children;return Array.isArray(t)&&t.length>0?t.reduce((e,t)=>e+Vg(t),0):1}const Xg={component:"Treemap",family:"hierarchy",importPath:"semiotic/network",rubric:{familiarity:4,accuracy:3,precision:3},fits:e=>e.hasHierarchy&&e.hierarchy?4>e.rowCount?"declared scale is too small to render a hierarchy meaningfully":null:"needs a hierarchical root with values",intentScores:{hierarchy:4,"part-to-whole":e=>e.hasHierarchy?5: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"}},scaleFit:(e,t)=>{const n=Vg(e.hierarchy);let o=0;const i=[];let r;return 5>n?(o-=.5,i.push(`only ${n} leaves — treemap needs more cells to show structure`)):n>100?n>500&&(o-=.7,i.push(n+" leaves — most tiles will be sub-pixel; prefer aggregation or zoomable treatment")):(o+=.4,r=n+" leaves is in the legible band for treemap"),"huge"===t.rowBand&&(o-=.5,i.push("at huge declared scale a stacked or matrix view aggregates better than hierarchical browsing")),{delta:o,reason:r,caveats:i}}},Ug={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"}}},Kg={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"}}},Qg={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,n,o;return{areas:null!==(n=null===(t=e.geo)||void 0===t?void 0:t.features)&&void 0!==n?n:[],valueAccessor:null!==(o=e.primary.y)&&void 0!==o?o:"value"}}},Zg={component:"ProportionalSymbolMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:3,accuracy:3,precision:3},fits:e=>{var t,n,o;return e.hasGeo&&e.geo?(null!==(n=null===(t=e.geo.points)||void 0===t?void 0:t.length)&&void 0!==n?n:0)>0||0!==(null!==(o=e.geo.features.length)&&void 0!==o?o: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,n,o,i,r;return{points:null!==(n=null===(t=e.geo)||void 0===t?void 0:t.points)&&void 0!==n?n:[],areas:null!==(i=null===(o=e.geo)||void 0===o?void 0:o.features)&&void 0!==i?i:void 0,xAccessor:"lon",yAccessor:"lat",sizeBy:null!==(r=e.primary.size)&&void 0!==r?r:"value"}}},Jg={component:"FlowMap",family:"geo",importPath:"semiotic/geo",rubric:{familiarity:2,accuracy:3,precision:2},fits:e=>{var t,n;return e.hasGeo&&e.geo?(null===(t=e.geo.flows)||void 0===t?void 0:t.length)?(null===(n=e.geo.points)||void 0===n?void 0:n.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,n,o,i;return{flows:null!==(n=null===(t=e.geo)||void 0===t?void 0:t.flows)&&void 0!==n?n:[],nodes:null!==(i=null===(o=e.geo)||void 0===o?void 0:o.points)&&void 0!==i?i:[],valueAccessor:"value"}}},ep={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,n;return{points:null!==(n=null===(t=e.geo)||void 0===t?void 0:t.points)&&void 0!==n?n:[],costAccessor:"cost"}}},tp={component:"BigNumber",family:"value",importPath:"semiotic/value",rubric:{familiarity:5,accuracy:5,precision:5},fits:e=>e.primary.y||e.primary.size||0!==e.candidates.y.length?e.rowCount>50?"BigNumber shows a single focal value — pass scalar data, or use a chart family for >50 rows":null:"needs a numeric value to display",intentScores:{trend:e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:3:0,"compare-categories":1,rank:1,"part-to-whole":e=>1===e.rowCount?5:1,"change-detection":e=>e.hasTimeAxis||"named"===e.xProvenance||e.monotonicX?e.rowCount>8?1:4:0},caveats:e=>{const t=[];return e.rowCount>1&&t.push("BigNumber renders the latest row's value as the focal number; earlier rows feed an optional sparkline"),t},buildProps:e=>{var t,n,o;const i=null!==(n=null!==(t=e.primary.y)&&void 0!==t?t:e.primary.size)&&void 0!==n?n:null===(o=e.candidates.y[0])||void 0===o?void 0:o.field;if(!i)return{value:0};const r=e.data,s=r.length>0?r[r.length-1]:null,a=s?Number(s[i]):0,l={value:Number.isFinite(a)?a:0,label:i};if(r.length>=2){const e=Number(r[r.length-2][i]);Number.isFinite(e)&&(l.comparison={value:e,label:"vs previous"})}return l},scaleFit:(e,t)=>"tiny"===t.rowBand?{delta:.8,reason:"single-value displays beat charts when there is one number to show"}:"small"===t.rowBand?{delta:.2,reason:"the latest value with a trend spark is often more legible than a chart at small scale"}:null},np=[fg,gg,pg,yg,mg,vg,bg,xg,wg,kg,Ag,jg,Sg,Cg,Og,Mg,Pg,_g,Tg,Ng,$g,Dg,Bg,Ig,Eg,Fg,Hg,zg,Wg,Gg,Yg,qg,Xg,Ug,Kg,Qg,Zg,Jg,ep,tp],op=new Map;function ip(){if(0===op.size)return np;const e=new Map;for(const t of np)e.set(t.component,t);for(const[t,n]of op)e.set(t,n);return Array.from(e.values())}function rp(e){return ip().find(t=>t.component===e)}const sp=new Set(["perceivable.content-only-visual","perceivable.color-alone","assistive.data-density","assistive.human-readable-numbers","assistive.skippable-navigation","compromising.table","compromising.navigable-structure"]),ap={"screen-reader":"a screen reader",sonified:"sonification",agent:"an AI reader"};function lp(e,t){if("visual"===t)return{delta:0,caveats:[]};let n=0;const o=[],i=[];for(const t of e.findings){if(!sp.has(t.id))continue;let e=0;"fail"===t.status?e=t.critical?1.2:.8:"warn"===t.status&&(e=.4),e>0&&(n-=e,o.push(t.heuristic.charAt(0).toLowerCase()+t.heuristic.slice(1)),i.push(t.message))}return 0===o.length?{delta:0,caveats:[]}:{delta:Math.max(-3,n),reason:`Harder to receive via ${ap[t]}: ${o.slice(0,3).join("; ")}`,caveats:i}}function cp(e,t,n,o,i){var r,s,a;if(!o)return{score:e,rubric:t};const l=null===(r=o.familiarity)||void 0===r?void 0:r[n],c=null!=l?l:t.familiarity,u=null===(s=o.targets)||void 0===s?void 0:s[n];let d,h,f=0;if(void 0!==l&&(f+=.5*(l-3)),u){const e=Math.max(1,Math.min(3,null!==(a=u.weight)&&void 0!==a?a:1));f+=1*("increase"===u.direction?1:-1)*e,d=u.reason?`${o.name?o.name+": ":""}${u.reason}`:`${o.name?o.name+" ":""}target: ${u.direction} ${n}`}const g=o.receptionModality;return i&&g&&"visual"!==g&&(f+=i.delta,h=i.reason),{score:e+f,rubric:Object.assign(Object.assign({},t),{familiarity:c}),appliedReason:d,receivabilityReason:h}}function up(e,t,n){var o,i;return n&&null!==(i=null===(o=n.familiarity)||void 0===o?void 0:o[e])&&void 0!==i?i:t}function dp(e){return e&&2===e.exposureLevel?4:3}function hp(e,t){if(void 0===e)return 0;const n="function"==typeof e?e(t):e;return Number.isFinite(n)?Math.max(0,Math.min(5,n)):0}function fp(e,t){var n;if(!(null==t?void 0:t.intentDeltas))return e;const o=Object.assign({},e);for(const[e,i]of Object.entries(t.intentDeltas)){const t=null!==(n=o[e])&&void 0!==n?n:0;o[e]=Math.max(0,Math.min(5,t+i))}return o}function gp(e,t){var n,o,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!==(n=t.rubricDeltas.familiarity)&&void 0!==n?n:0),accuracy:e.accuracy+(null!==(o=t.rubricDeltas.accuracy)&&void 0!==o?o:0),precision:e.precision+(null!==(i=t.rubricDeltas.precision)&&void 0!==i?i:0)}):e}function pp(e,t,n,o){var i;const r=[],s=o.map(e=>{var t;return{intent:e,score:null!==(t=n[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 yp(e,t){var n;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 o=0;for(const i of t)o+=null!==(n=e[i])&&void 0!==n?n:0;return o/t.length}function mp(e,t={}){var n,o,i,r,s,a,l;const c=null!==(n=t.profile)&&void 0!==n?n:Jf(null!=e?e:[],{rawInput:t.rawInput,seriesField:t.seriesField}),u=null!==(o=t.capabilities)&&void 0!==o?o:ip(),d=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],h=!1!==t.includeVariants,f=null!==(i=t.minScore)&&void 0!==i?i:0,g=null!==(r=t.maxResults)&&void 0!==r?r:10,p=t.allow?new Set(t.allow):null,y=t.deny?new Set(t.deny):null,m=null===(s=t.audience)||void 0===s?void 0:s.receptionModality,v=void 0!==m&&"visual"!==m,b=cg(c,t.scale),x=void 0!==t.scale&&b.rows!==c.rowCount?Object.assign(Object.assign({},c),{rowCount:b.rows}):c,w=[];for(const e of u){if(p&&!p.has(e.component))continue;if(y&&y.has(e.component))continue;if(null!==e.fits(x))continue;const n={};for(const[t,o]of Object.entries(e.intentScores))n[t]=hp(o,x);const o=e.caveats?Array.from(e.caveats(x)):[],i=h&&e.variants&&e.variants.length>0?e.variants:[void 0];for(const r of i){const i=fp(n,r),s=yp(i,d),u=gp(e.rubric,r),h=e.buildProps(c,r);let g;v&&(g=lp(yf(e.component,h),m));const p=cp(s,u,e.component,t.audience,g),y=dg(e,x,b,t.scale,t.quality);if(y.excluded)continue;const k=p.score+y.delta;if(f>k)continue;const A=pp(0,x,i,d);p.appliedReason&&A.push(p.appliedReason),p.receivabilityReason&&A.push(p.receivabilityReason);for(const e of y.reasons)A.push(e);const j=[...o,...null!==(a=null==r?void 0:r.caveats)&&void 0!==a?a:[],...y.caveats,...null!==(l=null==g?void 0:g.caveats.slice(0,3))&&void 0!==l?l:[]];w.push({component:e.component,family:e.family,importPath:e.importPath,variant:r,score:k,intentScores:i,rubric:p.rubric,reasons:A,caveats:j,props:h,scaleRange:{band:b.rowBand,cardinalityBand:b.cardinalityBand,rows:b.rows,rowsSource:b.rowsSource}})}}return w.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),w.slice(0,g)}function vp(e,t={}){var n,o;const i=null!==(n=t.profile)&&void 0!==n?n:Jf(null!=e?e:[],{rawInput:t.rawInput,seriesField:t.seriesField}),r=null!==(o=t.capabilities)&&void 0!==o?o:ip(),s=t.allow?new Set(t.allow):null,a=t.deny?new Set(t.deny):null,l=cg(i,t.scale),c=void 0!==t.scale&&l.rows!==i.rowCount?Object.assign(Object.assign({},i),{rowCount:l.rows}):i,u=[];for(const e of r){if(s&&!s.has(e.component))continue;if(a&&a.has(e.component))continue;const t=e.fits(c);null!==t&&u.push({component:e.component,family:e.family,importPath:e.importPath,reason:t})}return{fitting:mp(e,Object.assign(Object.assign({},t),{profile:i})),rejected:u,profile:i}}function bp(e,t){return null==e?e:e.length>t?e.slice(0,t-1)+"…":e}const xp=["hover","hover-end","click","click-end","selection","selection-end","brush-end"];function wp(e){var t;if("datum"===e.role&&e.datum)return e.datum;for(const n of null!==(t=e.children)&&void 0!==t?t:[]){const e=wp(n);if(e)return e}return null}function kp(e,t){return e?t.map(t=>e[t]+"").join(""):""}const Ap=[{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 jp(e,t={}){var n,o,i,r,s,a,l,c,u,d,h,f;const g=t.audience;if(!g)return[];const p=null!==(n=t.profile)&&void 0!==n?n:Jf(null!=e?e:[],{rawInput:t.rawInput}),y=dp(g),m=null!==(o=t.scoreTolerance)&&void 0!==o?o:1.5,v=null!==(i=t.maxResults)&&void 0!==i?i:5,b=ip(),x=new Map;for(const e of b)x.set(e.component,up(e.component,e.rubric.familiarity,g));const w=mp(e,{profile:p,intent:t.intent,maxResults:30,includeVariants:!0,minScore:1,allow:t.allow,deny:t.deny}),k=w.filter(e=>{var t;return(null!==(t=x.get(e.component))&&void 0!==t?t:e.rubric.familiarity)>=4}),A=k[0],j=[];for(const e of w)(null!==(r=x.get(e.component))&&void 0!==r?r:e.rubric.familiarity)>y||("increase"===(null===(a=null===(s=g.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 n=`${e.component}/${null!==(c=null===(l=e.variant)||void 0===l?void 0:l.key)&&void 0!==c?c:"base"}`;if(S.has(n))continue;S.add(n);const o=null!==(u=x.get(e.component))&&void 0!==u?u:e.rubric.familiarity,i=null===(d=g.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!==(f=g.name)&&void 0!==f?f:"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:o}),C.length>=v)break}return C}const Sp={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},Cp={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},Op={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},Mp={executive:Sp,analyst:Cp,"data-scientist":Op},Pp={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,n,o;const i=null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,r=null===(n=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind))||void 0===n?void 0:n.name,s=null===(o=e.fields.find(e=>"category"===e.role||"categorical"===e.kind&&"series"!==e.role))||void 0===o?void 0:o.name;return Object.assign({timeAccessor:i,valueAccessor:r},s?{categoryAccessor:s}:{})}},_p=[{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,n;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(n=e.fields.find(e=>"y"===e.role||"value"===e.role||"numeric"===e.kind))||void 0===n?void 0:n.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,n;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===n?void 0:n.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,n,o;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===n?void 0:n.name,categoryAccessor:null===(o=e.fields.find(e=>"category"===e.role||"categorical"===e.kind))||void 0===o?void 0:o.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,n;return{timeAccessor:null===(t=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===t?void 0:t.name,valueAccessor:null===(n=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===n?void 0:n.name}}},Pp,{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,n;const o=null===(t=e.fields.find(e=>"value"===e.role||"numeric"===e.kind))||void 0===t?void 0:t.name;return{timeAccessor:null===(n=e.fields.find(e=>"x"===e.role||"date"===e.kind))||void 0===n?void 0:n.name,valueAccessor:o}}}],Lp=new Map;function Tp(){if(0===Lp.size)return _p;const e=new Map;for(const t of _p)e.set(t.component,t);for(const[t,n]of Lp)e.set(t,n);return Array.from(e.values())}function Np(e,t){if(void 0===e)return 0;const n="function"==typeof e?e(t):e;return Number.isFinite(n)?Math.max(0,Math.min(5,n)):0}function Rp(e,t){var n;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 o=0;for(const i of t)o+=null!==(n=e[i])&&void 0!==n?n:0;return o/t.length}function $p(e,t,n){const o=[],i=n.map(e=>{var n;return{intent:e,score:null!==(n=t[e])&&void 0!==n?n:0}}).filter(e=>e.score>=3).sort((e,t)=>t.score-e.score).slice(0,2);for(const{intent:e,score:t}of i)o.push(`Strong fit for ${e} (${t}/5)`);return e.throughput&&o.push(`tuned for ${e.throughput} throughput`),o}const Dp=["x","y","size","category","series","time"];function Bp(e,t){const n=e.fields[t];return n?"numeric"===n.type?"numeric":"categorical"===n.type?"categorical":"date"===n.type?"date":"unknown":"unknown"}function Ip(e){const t=new Set;for(const n of ip())null===n.fits(e)&&t.add(n.component);return t}const Ep=(()=>{const e=Array.from({length:12},(e,t)=>t+1);return["EU","NA","APAC"].flatMap((t,n)=>e.map(e=>({month:e,revenue:800+e*(200+40*n)+150*Math.sin(e),region:t})))})(),Fp=Array.from({length:12},(e,t)=>({month:t+1,revenue:1e3+150*t+100*Math.sin(t/2)})),Hp=[{product:"Widget",units:480},{product:"Gadget",units:620},{product:"Sprocket",units:290},{product:"Whatsit",units:740},{product:"Doohickey",units:410}],zp=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]})),Wp=Array.from({length:80},(e,t)=>{const n=Math.max(0,40*Math.random());return{student_id:"s"+(t+1),hours:n,grade:Math.min(100,1.8*n+30+20*(Math.random()-.5))}}),Gp=Array.from({length:50},(e,t)=>({observation:50+12*Math.sin(t/4)+6*Math.random()})),Yp=[{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}],qp=[{name:"monthly revenue with regions, intent=trend",shape:"12 months × 3 regions, numeric month, numeric revenue",data:Ep,intent:"trend",expected:["LineChart","AreaChart","MinimapChart"]},{name:"monthly revenue with regions, intent=compare-series",shape:"12 months × 3 regions",data:Ep,intent:"compare-series",expected:["LineChart","GroupedBarChart"]},{name:"monthly revenue with regions, intent=composition-over-time",shape:"12 months × 3 regions, additive",data:Ep,intent:"composition-over-time",expected:["StackedAreaChart","StackedBarChart"]},{name:"monthly revenue single series, intent=trend",shape:"12 months, no series",data:Fp,intent:"trend",expected:["LineChart","AreaChart"]},{name:"product sales, intent=rank",shape:"5 products, single numeric measure",data:Hp,intent:"rank",expected:["BarChart","DotPlot"]},{name:"product sales, intent=part-to-whole",shape:"5 products, single numeric measure",data:Hp,intent:"part-to-whole",expected:["PieChart","DonutChart","BarChart"]},{name:"satisfaction scores, intent=distribution",shape:"150 numeric observations across 3 cohorts",data:zp,intent:"distribution",expected:["Histogram","BoxPlot","ViolinPlot"]},{name:"satisfaction scores, intent=compare-categories",shape:"150 obs × 3 cohorts",data:zp,intent:"compare-categories",expected:["BoxPlot","ViolinPlot","SwarmPlot"]},{name:"hours vs grade, intent=correlation",shape:"80 students, hours + grade",data:Wp,intent:"correlation",expected:["Scatterplot"]},{name:"hours vs grade, intent=outlier-detection",shape:"80 students",data:Wp,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:Yp,intent:"compare-series",expected:["GroupedBarChart","StackedBarChart"]},{name:"sales by region and product, intent=part-to-whole",shape:"12 rows = 4 products × 3 regions",data:Yp,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 n=100+1.2*t+8*Math.sin(t/4),o=n+4*(Math.random()-.5),i=n+4*(Math.random()-.5);return{day:t+1,open:o,high:Math.max(o,i)+3*Math.random(),low:Math.min(o,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:Gp,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"]}],Vp=e=>Oh(e),Xp=()=>Nh().enabled,Up=()=>!1,Kp=[{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"}],Qp=new Map(Kp.map(e=>[e.id,e])),Zp=new Set(Kp.map(e=>e.id)),Jp=new Set;function ey(e,t,n){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):t}function ty(e,t){return void 0===e?0:ey("function"==typeof e?e(t):e,0,5)}function ny(e){return e?Array.isArray(e)?[...e]:[e]:[]}function oy(e,t,n){var o;const i={};for(const[n,o]of Object.entries(e.intentScores))i[n]=ty(o,t);if(n)for(const[e,t]of Object.entries(n))i[e]=ey((null!==(o=i[e])&&void 0!==o?o:0)+t,0,5);return i}function iy(e,t){if(t.length>0)return t.reduce((t,n)=>{var o;return t+(null!==(o=e[n])&&void 0!==o?o:0)},0)/t.length;const n=Object.values(e).filter(e=>"number"==typeof e&&e>0);return n.length?n.reduce((e,t)=>e+t,0)/n.length:0}function ry(e,t){var n;return{id:`${e.component}:${t.key}`,baseComponent:e.component,label:t.label,intentDeltas:t.intentDeltas,rubricDeltas:t.rubricDeltas,buildProps:n=>e.buildProps(n,t),rationale:null!==(n=t.description)&&void 0!==n?n:`Registered ${e.component} variant: ${t.label}.`,source:"manual",variantKey:t.key,tags:t.tags}}function sy(e,t,n){return e.some(e=>{var o;return(null===(o=e.props)||void 0===o?void 0:o[t])===n})}const ay=new Set(["BarChart","GroupedBarChart","StackedBarChart","DotPlot"]);const ly={total:0,byType:{},componentsSeen:[],audiencesSeen:[],startedAt:null,lastAt:null,durationMs:0};function cy(e){var t;if(0===e.length)return ly;const n={},o=new Set,i=[];let r;for(const s of e){n[s.type]=(null!==(t=n[s.type])&&void 0!==t?t:0)+1,s.arcId&&(r=s.arcId);const e="component"in s&&"string"==typeof s.component?s.component:void 0;if(e&&o.add(e),"from"in s&&"string"==typeof s.from&&o.add(s.from),"to"in s&&"string"==typeof s.to&&o.add(s.to),"components"in s&&Array.isArray(s.components))for(const e of s.components)"string"==typeof e&&o.add(e);"audience-set"===s.type&&"string"==typeof s.audience&&i.push(s.audience)}const s=e[0].timestamp,a=e[e.length-1].timestamp;return{total:e.length,byType:n,componentsSeen:Array.from(o),audiencesSeen:i,latestArcId:r,startedAt:s,lastAt:a,durationMs:Math.max(0,a-s)}}function uy(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)*(1-t)),i=Math.round(parseInt(n[2],16)*(1-t)),r=Math.round(parseInt(n[3],16)*(1-t));return`#${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}function dy(e,t=.5){const n=/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);if(!n)return e;const o=Math.round(parseInt(n[1],16)+(255-parseInt(n[1],16))*t),i=Math.round(parseInt(n[2],16)+(255-parseInt(n[2],16))*t),r=Math.round(parseInt(n[3],16)+(255-parseInt(n[3],16))*t);return`#${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}${r.toString(16).padStart(2,"0")}`}const hy="__forecastSegment";function fy(e,t){return"function"==typeof t?t(e):!!e[t]}const gy=Object.freeze({__proto__:null,SEGMENT_FIELD:hy,buildAnomalyAnnotations:function(e){var t,n,o;return[{type:"anomaly-band",threshold:null!==(t=e.threshold)&&void 0!==t?t:2,showBand:!1!==e.showBand,fill:e.bandColor||"#6366f1",fillOpacity:null!==(n=e.bandOpacity)&&void 0!==n?n:.1,anomalyColor:e.anomalyColor||"#ef4444",anomalyRadius:null!==(o=e.anomalyRadius)&&void 0!==o?o:6,label:e.label}]},buildForecast:function(e,t,n,o,i){return(r=o).isTraining||r.isForecast||r.isAnomaly||r.upperBounds||r.lowerBounds?function(e,t,n,o,i){var r,s,a,l;const{isTraining:c,isForecast:u,isAnomaly:d,upperBounds:h,lowerBounds:f,color:g="#6366f1",bandOpacity:p=.15,anomalyColor:y="#ef4444",anomalyRadius:m=6,label:v}=o,b=e.map(e=>{let t="observed";return u&&fy(e,u)?t="forecast":c&&fy(e,c)&&(t="training"),Object.assign(Object.assign({},e),{[hy]:t})}),x=o._groupBy,w=[];if(x){const e=new Map;for(const t of b){const n=null!==(r=t[x])&&void 0!==r?r:"__default";e.has(n)||e.set(n,[]),e.get(n).push(t)}const t=[];for(const[,n]of e)for(let e=0;n.length-1>e;e++)n[e][hy]!==n[e+1][hy]&&(t.push(Object.assign(Object.assign({},n[e+1]),{[hy]:n[e][hy]})),t.push(Object.assign(Object.assign({},n[e]),{[hy]:n[e+1][hy]})));w.push(...b,...t)}else for(let e=0;b.length>e;e++)w.push(b[e]),b.length-1>e&&b[e][hy]!==b[e+1][hy]&&(w.push(Object.assign(Object.assign({},b[e+1]),{[hy]:b[e][hy]})),w.push(Object.assign(Object.assign({},b[e]),{[hy]:b[e+1][hy]})));if(o.trainUnderline){const e=[];for(const t of w)"training"===t[hy]&&e.push(Object.assign(Object.assign({},t),{[hy]:"training-base"}));w.unshift(...e)}const k=[];if(h&&f){const e="string"==typeof h?h:"__envUpper",t="string"==typeof f?f:"__envLower";if("function"==typeof h||"function"==typeof f)for(const n of w)"function"==typeof h&&(n[e]=h(n)),"function"==typeof f&&(n[t]=f(n));k.push({type:"envelope",upperAccessor:e,lowerAccessor:t,fill:g,fillOpacity:p,label:v})}if(d){const e=o.anomalyStyle,t={type:"highlight",filter:e=>fy(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}),k.push(t)}return i&&k.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:w,annotations:k}}(e,0,0,o,i):function(e,t,n,o,i){var r,s,a;const{trainEnd:l,steps:c=10,confidence:u=.95,color:d="#6366f1",bandOpacity:h=.15,label:f}=o;if(null==l)return{processedData:e,annotations:[]};const g=[],p=[];for(const n of e)n[t]>l?p.push(Object.assign(Object.assign({},n),{[hy]:"observed"})):g.push(Object.assign(Object.assign({},n),{[hy]:"training"}));const y=g.map(e=>[e[t],e[n]]).filter(e=>null!=e[0]&&null!=e[1]&&isFinite(e[0])&&isFinite(e[1])).sort((e,t)=>e[0]-t[0]),m=[],v=[];if(y.length>=3){const o=y.length;let i=0,r=0,s=0,a=0;for(const[e,t]of y)i+=e,r+=t,s+=e*e,a+=e*t;const l=o*s-i*i;if(Math.abs(l)>1e-12){const s=(o*a-i*r)/l,g=(r-s*i)/o,p=e=>g+s*e,b=y.map(([e,t])=>t-p(e)).reduce((e,t)=>e+t*t,0),x=Math.sqrt(b/Math.max(o-2,1)),w=y.reduce((e,t)=>e+t[0],0)/o,k=y.reduce((e,t)=>e+Math.pow(t[0]-w,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[o-1][0]-y[0][0])/(o-1):1;for(let e=1;c>=e;e++){const i=S+e*C,r=p(i),s=x*Math.sqrt(1+1/o+(k>0?Math.pow(i-w,2)/k:0))*A;v.push({[t]:i,[n]:r,[hy]:"forecast",__forecastUpper:r+s,__forecastLower:r-s})}m.push({type:"envelope",upperAccessor:"__forecastUpper",lowerAccessor:"__forecastLower",fill:d,fillOpacity:h,label:f})}}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(...g),g.length>0&&p.length>0&&b.push(Object.assign(Object.assign({},g[g.length-1]),{[hy]:"observed"})),b.push(...p),v.length>0){const e=p.length>0?p[p.length-1]:g[g.length-1];e&&b.push(Object.assign(Object.assign({},e),{[hy]:"forecast"})),b.push(...v)}return{processedData:b,annotations:m}}(e,t,n,o,i);var r},createSegmentLineStyle:function(e,t){var n,o;const i=null!==(n=t.trainDasharray)&&void 0!==n?n:"8,4",r=null!==(o=t.forecastDasharray)&&void 0!==o?o:"4,4",s=t.color||"#6366f1",a=t.trainOpacity,l=t.forecastOpacity,c=t.trainStroke,u=t.trainLinecap,d=t.trainUnderline;return t=>{const n=e(t),o=t[hy];if("training"===o){let e=n.stroke;return"darken"===c?e=uy(n.stroke||"#666",.5):c&&(e=c),Object.assign(Object.assign(Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:i}),u&&{strokeLinecap:u}),null!=a&&{strokeOpacity:a})}if("training-base"===o){let e=n.stroke||"#666";return"lighten"===d&&(e=dy(e,.4)),Object.assign(Object.assign({},n),{stroke:e,strokeDasharray:void 0})}return"forecast"===o?Object.assign(Object.assign(Object.assign({},n),{stroke:s,strokeDasharray:r}),null!=l&&{strokeOpacity:l}):n}},darkenColor:uy,lightenColor:dy});exports.AccessibleNavTree=Dh,exports.AreaChart=Ss,exports.AreaChartCapability=gg,exports.BUILT_IN_AUDIENCES=Mp,exports.BUILT_IN_INTENT_IDS=Zp,exports.BarChart=Ga,exports.BarChartCapability=Sg,exports.BigNumber=ld,exports.BoxPlot=Ka,exports.BoxPlotCapability=Ig,exports.BubbleChart=$s,exports.BubbleChartCapability=vg,exports.CANONICAL_FIXTURES=qp,exports.CandlestickChart=ia,exports.CandlestickChartCapability=Ag,exports.CategoryColorProvider=zi,exports.ChartContainer=zh,exports.ChartGrid=Gh,exports.ChordDiagram=xu,exports.ChordDiagramCapability=Gg,exports.ChoroplethMapCapability=Qg,exports.CirclePack=Eu,exports.CirclePackCapability=Ug,exports.ConnectedScatterplot=Rs,exports.ConnectedScatterplotCapability=mg,exports.ContextLayout=Yh,exports.DEFAULT_LIFECYCLE_THRESHOLDS=Rd,exports.DEFAULT_SCALE_THRESHOLDS=eg,exports.DetailsPanel=qh,exports.DifferenceChart=Os,exports.DifferenceChartCapability=kg,exports.DistanceCartogramCapability=ep,exports.DonutChart=ol,exports.DonutChartCapability=_g,exports.DotPlot=el,exports.DotPlotCapability=Mg,exports.FlowMapCapability=Jg,exports.ForceDirectedGraph=bu,exports.ForceDirectedGraphCapability=zg,exports.FunnelChart=dl,exports.FunnelChartCapability=Tg,exports.GaugeChart=ul,exports.GaugeChartCapability=Ng,exports.GroupedBarChart=qa,exports.GroupedBarChartCapability=Cg,exports.Heatmap=Ds,exports.HeatmapCapability=jg,exports.Histogram=Za,exports.HistogramCapability=Bg,exports.LikertChart=wl,exports.LikertChartCapability=$g,exports.LineChart=bs,exports.LineChartCapability=fg,exports.LinkedCharts=ur,exports.MinimapChart=qs,exports.MinimapChartCapability=wg,exports.MultiAxisLineChart=oa,exports.MultiAxisLineChartCapability=xg,exports.MultiLineTooltip=function(t={}){const{fields:n=[],title:o,format:i,style:r={},className:s="",showLabels:a=!0,separator:l=": "}=t;return t=>{if(!t||"object"!=typeof t)return null;const c=[];if(o){const e=Ko(t,o);c.push({value:Qo(e,i)})}n&&Array.isArray(n)&&n.length>0?n.forEach(e=>{let n,o,r;"string"==typeof e?(n=e,o=e,r=i):(n=e.label,o=e.accessor||e.key||"",r=e.format||i);const s=Qo(Ko(t,o),r);c.push({label:a?n:void 0,value:s})}):Object.keys(t).filter(e=>!e.startsWith("_")&&"data"!==e).forEach(e=>{c.push({label:a?e:void 0,value:Qo(t[e],i)})});const u=Object.assign(Object.assign({},Uo),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,n)=>e.jsxs("div",{style:{marginBottom:c.length-1>n?"4px":0},children:[t.label&&e.jsxs("strong",{children:[t.label,l]}),t.value]},n))}):null}},exports.OrbitDiagram=Hu,exports.OrbitDiagramCapability=Kg,exports.PieChart=nl,exports.PieChartCapability=Pg,exports.ProcessSankey=Du,exports.ProcessSankeyCapability=Yg,exports.ProportionalSymbolMapCapability=Zg,exports.QuadrantChart=Zs,exports.QuadrantChartCapability=bg,exports.RealtimeHeatmap=ed,exports.RealtimeHistogram=Ku,exports.RealtimeLineChart=Xu,exports.RealtimeSwarmChart=Zu,exports.RealtimeWaterfallChart=Ju,exports.RidgelinePlot=tl,exports.RidgelinePlotCapability=Hg,exports.SankeyDiagram=wu,exports.SankeyDiagramCapability=Wg,exports.Scatterplot=Ts,exports.ScatterplotCapability=yg,exports.ScatterplotMatrix=Gs,exports.StackedAreaChart=Ms,exports.StackedAreaChartCapability=pg,exports.StackedBarChart=Ya,exports.StackedBarChartCapability=Og,exports.SwarmPlot=Xa,exports.SwarmPlotCapability=Eg,exports.SwimlaneChart=kl,exports.SwimlaneChartCapability=Dg,exports.TemporalHistogram=Qu,exports.ThemeProvider=function({theme:t,children:n}){const o="string"==typeof t&&pr(t)?t:void 0,i=p.useMemo(()=>function(e){return void 0!==e?L(M,vr(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(yr.Provider,{value:o,children:[e.jsx(br,{theme:t}),e.jsx(xr,{children:n})]})})},exports.TooltipProvider=ud,exports.TreeDiagram=Bu,exports.TreeDiagramCapability=qg,exports.Treemap=Iu,exports.TreemapCapability=Xg,exports.ViolinPlot=Ja,exports.ViolinPlotCapability=Fg,exports.accessibilityCaveats=function(e,{onlyCritical:t=!1}={}){const n=[];for(const o of e.findings)"fail"!==o.status&&"warn"!==o.status||t&&!o.critical||n.push(o.message);return n},exports.analystPersona=Cp,exports.annotationFreshnessFor=Ed,exports.applyAnnotationLifecycle=function(e,t={}){var n,o;const i=Id(t),r=!0===t.showExpiredAnnotations,s=[];for(const a of e){const e=Ed(a,i,t.thresholds);if("expired"===e&&!r)continue;const l=zd(t.opacity,Fd,e),c=zd(t.strokeDasharray,Hd,e),u=null===(n=t.labelSuffix)||void 0===n?void 0:n[e],d=Object.assign(Object.assign({},a),{lifecycle:Object.assign(Object.assign({},a.lifecycle),{freshness:e})});null!=l&&null==d.opacity&&(d.opacity=l),null!=c&&null==d.strokeDasharray&&(d.strokeDasharray=c),u&&"string"==typeof d.label&&(d.label=d.label+u);const h=null===(o=a.lifecycle)||void 0===o?void 0:o.anchor;h&&null==d.anchor&&(d.anchor=h),s.push(d)}return s},exports.applyAnnotationStatus=function(e,t={}){var n,o,i;const r=[];for(const s of Vd(e,t)){const e=null===(n=null==s?void 0:s.lifecycle)||void 0===n?void 0:n.status;if(!e){r.push(s);continue}const a=qd(t.opacity,Wd,e),l=qd(t.strokeDasharray,Gd,e),c=null!==(i=null===(o=t.labelSuffix)||void 0===o?void 0:o[e])&&void 0!==i?i:Yd[e],u=Object.assign({},s);null!=a&&(u.opacity=("number"==typeof u.opacity?u.opacity:1)*a),null!=l&&null==u.strokeDasharray&&(u.strokeDasharray=l),c&&"string"==typeof u.label&&(u.label=u.label+c),r.push(u)}return r},exports.applyAudienceBias=cp,exports.applyScaleBias=dg,exports.auditAccessibility=yf,exports.bandFromAge=$d,exports.buildNavigationTree=ch,exports.buildReaderGrounding=function(e,t,n={}){var o;const{capability:i,audience:r,locale:s}=n,a=null!==(o=n.levels)&&void 0!==o?o:["l1","l2","l3"],l=!1!==n.includeStructure,c=nh(e,i),u=sh(e,t,{levels:c?[...a,"l4"]:a,locale:s,capability:i,audience:r}),d=u.levels,{l4:h}=d,f=ds(d,["l4"]),g=["l1","l2","l3"].map(e=>u.levels[e]).filter(Boolean).join(" "),p=Object.assign({levels:f,text:u.annotations?`${u.annotations} ${g}`.trim():g},u.annotations?{annotations:u.annotations}:{});let y;if(c&&h){const e=(m=i)?"fits"in m||"buildProps"in m?{family:m.family}:{family:m.family,intentScores:m.intentScores}:{};y={act:c,sentence:h,family:e.family,intentScores:e.intentScores}}var m;const v=l?ch(e,t,{maxLeaves:n.maxLeaves,locale:s}):void 0,b=[p.text,null==y?void 0:y.sentence].filter(Boolean).join(" ");return{component:e,description:p,intent:y,structure:v,text:b}},exports.classifyCardinalityBand=ig,exports.classifyFieldBand=rg,exports.classifyRowBand=og,exports.clearVariantDiscovery=function(){Jp.clear()},exports.communicativeActForIntent=function(e){return Zd[e]},exports.compareBands=sg,exports.computeAnnotationFreshness=function(e,t={}){const n=Id(t);return e.map(e=>{const o=Ed(e,n,t.thresholds);return Object.assign(Object.assign({},e),{lifecycle:Object.assign(Object.assign({},e.lifecycle),{freshness:o})})})},exports.computeEffectiveScale=cg,exports.configToJSX=Cd,exports.copyConfig=Sd,exports.countNodes=function e(t){let n=1;if(t.children)for(const o of t.children)n+=e(o);return n},exports.createIndexedDBConversationArcSink=function(e={}){var t,n;const o=null!==(t=e.dbName)&&void 0!==t?t:"semiotic-conversation-arc",i=null!==(n=e.storeName)&&void 0!==n?n:"events",r=ph(e.maxEvents,gh,"createIndexedDBConversationArcSink: maxEvents");let s=null;const a=()=>(null!=s||(s=function(e,t,n){const o=function(e){var t;if(e)return e;try{return null!==(t=globalThis.indexedDB)&&void 0!==t?t:null}catch(e){return null}}(n);return o?new Promise(n=>{let i;try{i=o.open(e,1)}catch(e){return yh("IndexedDB open",e),void n(null)}i.onupgradeneeded=()=>{const e=i.result;e.objectStoreNames.contains(t)||e.createObjectStore(t,{keyPath:"id",autoIncrement:!0})},i.onsuccess=()=>n(i.result),i.onerror=()=>{yh("IndexedDB open",i.error),n(null)},i.onblocked=()=>{yh("IndexedDB open",Error("upgrade blocked")),n(null)}}):Promise.resolve(null)}(o,i,e.indexedDB)),s);return{record(e){return hs(this,void 0,void 0,function*(){const t=yield a();t&&(yield new Promise(n=>{try{const o=t.transaction(i,"readwrite");o.objectStore(i).add({event:e}),o.oncomplete=()=>n(),o.onerror=()=>{yh("IndexedDB record",o.error),n()}}catch(e){yh("IndexedDB record",e),n()}}),yield function(e,t,n){return e?new Promise(o=>{try{const i=e.transaction(t,"readwrite"),r=i.objectStore(t),s=r.getAll();s.onsuccess=()=>{const e=Array.isArray(s.result)?s.result:[],t=e.length-n;if(t>0)for(const n of e.slice(0,t))null!=n.id&&r.delete(n.id)},s.onerror=()=>yh("IndexedDB trim",s.error),i.oncomplete=()=>o(),i.onerror=()=>{yh("IndexedDB trim",i.error),o()}}catch(e){yh("IndexedDB trim",e),o()}}):Promise.resolve()}(t,i,r))})},clear(){return hs(this,void 0,void 0,function*(){const e=yield a();e&&(yield new Promise(t=>{try{const n=e.transaction(i,"readwrite");n.objectStore(i).clear(),n.oncomplete=()=>t(),n.onerror=()=>{yh("IndexedDB clear",n.error),t()}}catch(e){yh("IndexedDB clear",e),t()}}))})},load(){return hs(this,void 0,void 0,function*(){return function(e,t){return e?new Promise(n=>{try{const o=e.transaction(t,"readonly").objectStore(t).getAll();o.onsuccess=()=>{n((Array.isArray(o.result)?o.result:[]).map(e=>e.event).filter(Boolean))},o.onerror=()=>{yh("IndexedDB load",o.error),n([])}}catch(e){yh("IndexedDB load",e),n([])}}):Promise.resolve([])}(yield a(),i)})}}},exports.createLocalStorageConversationArcSink=function(e={}){var t;const n=null!==(t=e.key)&&void 0!==t?t:"semiotic:conversation-arc",o=ph(e.maxEvents,gh,"createLocalStorageConversationArcSink: maxEvents");return{record(t){const i=vh(e.storage),r=bh(i,n);r.push(t),function(e,t,n,o){if(e)try{e.setItem(t,JSON.stringify(n.slice(-o)))}catch(e){yh("localStorage write",e)}}(i,n,r,o)},clear(){const t=vh(e.storage);if(t)try{t.removeItem(n)}catch(e){yh("localStorage clear",e)}},load:()=>bh(vh(e.storage),n)}},exports.createWebhookConversationArcSink=function(e){var t;if(!e.url)throw new TypeError("createWebhookConversationArcSink: url is required");const n=null!==(t=e.method)&&void 0!==t?t:"POST";return{record(t){var o;const i=null!==(o=e.fetch)&&void 0!==o?o:globalThis.fetch;if(!i)return;const r=e.mapEvent?e.mapEvent(t):t;return i(e.url,{method:n,headers:Object.assign({"Content-Type":"application/json"},e.headers),body:JSON.stringify(r)}).then(()=>{})}}},exports.currentTimestamp=Dd,exports.dataScientistPersona=Op,exports.describeChart=sh,exports.deserializeSelections=function(e){const t=new Map;for(const[n,o]of Object.entries(e)){const e=new Map;for(const t of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:new Set(o.values)}:{type:"interval",range:o.range};e.set(t.clientId,{clientId:t.clientId,type:t.type,fields:n})}t.set(n,{name:o.name,resolution:o.resolution,clauses:e})}return t},exports.diagnoseConfig=function(e,t){const n=[],o=wd(e,t);for(const e of o.errors)n.push({severity:"error",code:"VALIDATION",message:e,fix:""});return bd[e]?(function(e,t,n){const o=bd[e];if(o){if("array"===o.dataShape){const e=t.data;e&&Array.isArray(e)&&0===e.length&&n.push({severity:"error",code:"EMPTY_DATA",message:"data is an empty array — chart will render blank.",fix:"Provide at least one data point: data={[{ x: 1, y: 2 }]}."})}"network"===o.dataShape&&t.edges&&Array.isArray(t.edges)&&0===t.edges.length&&n.push({severity:"error",code:"EMPTY_EDGES",message:"edges is an empty array — network chart will render blank.",fix:'Provide at least one edge: edges={[{ source: "A", target: "B" }]}.'})}}(e,t,n),function(e,t,n){const o=t.width,i=t.height;if(void 0===o||"number"==typeof o&&o>0||n.push({severity:"error",code:"BAD_WIDTH",message:`width=${JSON.stringify(o)} — chart needs a positive number.`,fix:"Set width={600} or use responsiveWidth={true}."}),void 0===i||"number"==typeof i&&i>0||n.push({severity:"error",code:"BAD_HEIGHT",message:`height=${JSON.stringify(i)} — chart needs a positive number.`,fix:"Set height={400} or use responsiveHeight={true}."}),t.size&&Array.isArray(t.size)){const[e,o]=t.size;(null!=e&&0>=e||null!=o&&0>=o)&&n.push({severity:"error",code:"BAD_SIZE",message:`size=[${e}, ${o}] — both dimensions must be positive.`,fix:"Set size={[600, 400]}."})}}(0,t,n),function(e,t,n){const o=bd[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=Object.keys(r);for(const e of o.dataAccessors){const o=t[e];"string"==typeof o&&(o in r||n.push({severity:"error",code:"ACCESSOR_MISSING",message:`${e}="${o}" not found in data. Available fields: ${s.join(", ")}.`,fix:`Change ${e} to one of: ${s.map(e=>`"${e}"`).join(", ")}.`}))}}(e,t,n),function(e,t,n){Xh.has(e)&&Array.isArray(t.data)&&n.push({severity:"error",code:"HIERARCHY_FLAT_ARRAY",message:e+" expects hierarchical data but received a flat array.",fix:'Pass a root object: data={{ name: "root", children: [...] }}. For flat data, use BarChart or LineChart.'})}(e,t,n),function(e,t,n){Uh.has(e)&&(t.edges||t.data||n.push({severity:"error",code:"NETWORK_NO_EDGES",message:e+" requires an edges prop.",fix:'Provide edges={[{ source: "A", target: "B", value: 10 }]}.'}))}(e,t,n),function(e,t,n){const o=bd[e];if(!o||"array"!==o.dataShape)return;const i=t.data;if(!i||!Array.isArray(i)||0===i.length)return;const r=i[0];if(!r||"object"!=typeof r)return;const s=t.xAccessor;"string"==typeof s&&r[s]instanceof Date&&!t.xFormat&&n.push({severity:"warning",code:"DATE_NO_FORMAT",message:`xAccessor "${s}" contains Date objects but no xFormat is provided. Axis ticks may display "[object Object]".`,fix:"Add xFormat={d => d.toLocaleDateString()} or use timestamps (d.getTime()) instead of Date objects."})}(e,t,n),function(e,t,n){t.linkedHover&&!t.selection&&n.push({severity:"warning",code:"LINKED_HOVER_NO_SELECTION",message:"linkedHover is set but selection is not — this chart emits hover events but won't highlight from others.",fix:`Add selection={{ name: "${"object"==typeof t.linkedHover&&t.linkedHover.name||"hl"}" }} to receive cross-highlights.`})}(0,t,n),function(e,t,n){var o;if(!Kh.has(e))return;const i=t.rExtent||t.yExtent;i&&Array.isArray(i)&&i.length>=1&&null!=i[0]&&0!==i[0]&&n.push({severity:"warning",code:"NON_ZERO_BASELINE",message:`${e} has a non-zero baseline (${i[0]}). Bar and area charts should start at zero to avoid exaggerating differences.`,fix:`Remove the custom extent minimum or set it to 0: rExtent={[0, ${null!==(o=i[1])&&void 0!==o?o:"auto"}]}. For trend-focused charts, use LineChart instead.`})}(e,t,n),function(e,t,n){if(!Qh.has(e))return;if(t.gapStrategy)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=t.yAccessor||"y";"string"==typeof i&&o.some(e=>{const t=e[i];return null==t||Number.isNaN(t)})&&n.push({severity:"warning",code:"DATA_GAPS",message:`Data contains null/undefined/NaN values in "${i}". Default behavior breaks the line at gaps.`,fix:'Set gapStrategy="break" (default), "interpolate", or "zero" to control gap handling.'})}(e,t,n),function(e,t,n){var o,i;const r=null!==(o=t.width)&&void 0!==o?o:600,s=null!==(i=t.height)&&void 0!==i?i:400,a=t.margin;if(!a||"object"!=typeof a)return;const l=(a.left||0)+(a.right||0),c=(a.top||0)+(a.bottom||0);r>l||n.push({severity:"error",code:"MARGIN_OVERFLOW_H",message:`Horizontal margins (${l}px) >= width (${r}px) — no drawing area left.`,fix:"Reduce margin.left/right or increase width."}),s>c||n.push({severity:"error",code:"MARGIN_OVERFLOW_V",message:`Vertical margins (${c}px) >= height (${s}px) — no drawing area left.`,fix:"Reduce margin.top/bottom or increase height."})}(0,t,n),function(e,t,n){var o;const i=bd[e];if(!i||"array"!==i.dataShape)return;const r=t.data;if(!r||!Array.isArray(r)||0===r.length)return;const s=[];t.xAccessor&&"string"==typeof t.xAccessor&&s.push({prop:"xAccessor",name:t.xAccessor}),t.yAccessor&&"string"==typeof t.yAccessor&&s.push({prop:"yAccessor",name:t.yAccessor}),t.valueAccessor&&"string"==typeof t.valueAccessor&&s.push({prop:"valueAccessor",name:t.valueAccessor});const a=Math.min(r.length,5);for(const e of s){let t=!0;for(let n=0;a>n;n++){const i=null===(o=r[n])||void 0===o?void 0:o[e.name];if("number"==typeof i&&Number.isFinite(i)){t=!1;break}}t&&n.push({severity:"error",code:"DEGENERATE_EXTENT",message:`${e.prop}="${e.name}" produces NaN or non-finite values for all sampled data points — chart extents will be invalid.`,fix:`Ensure data[].${e.name} contains finite numbers, or use a function accessor to transform values.`})}}(e,t,n),function(e,t,n){if(!Zh.has(e))return;const o=t.barPadding;"number"==typeof o&&10>o&&n.push({severity:"warning",code:"BAR_PADDING_INVISIBLE",message:`barPadding=${o} is very small — bars may appear to have no spacing between them.`,fix:"Increase barPadding to at least 10 for visible gaps, e.g. barPadding={12}."})}(e,t,n),function(e,t,n){if("bottom"!==t.legendPosition)return;const o=t.margin;if(!o||"object"!=typeof o)return;const i=o.bottom;"number"==typeof i&&70>i&&n.push({severity:"warning",code:"BOTTOM_MARGIN_WITH_LEGEND",message:`legendPosition="bottom" with margin.bottom=${i}px — legend may overlap axis labels.`,fix:"Increase margin.bottom to at least 70, e.g. margin={{ ...margin, bottom: 80 }}."})}(0,t,n),function(e,t,n){var o;if(!t.showLegend)return;if("right"!==(null!==(o=t.legendPosition)&&void 0!==o?o:"right"))return;const i=t.margin;if(!i||"object"!=typeof i)return;const r=i.right;"number"==typeof r&&100>r&&n.push({severity:"warning",code:"LEGEND_MARGIN_TIGHT",message:`showLegend is true with legendPosition="right" but margin.right=${r}px — legend may be clipped or overlap the chart.`,fix:"Increase margin.right to at least 100, e.g. margin={{ ...margin, right: 120 }}."})}(0,t,n),function(e,t,n){if("Heatmap"!==e)return;const o=t.data;if(!o||!Array.isArray(o)||0===o.length)return;const i=o[0];if(i&&"object"==typeof i)for(const e of["xAccessor","yAccessor"]){const o=t[e];if("string"!=typeof o)continue;const r=i[o];"string"==typeof r&&n.push({severity:"warning",code:"HEATMAP_STRING_ACCESSOR",message:`${e}="${o}" resolves to string values (e.g. "${r}"). Heatmap will use categorical axis handling which may produce unexpected cell layout.`,fix:"If you intend categorical axes this is fine. Otherwise, convert values to numbers before passing data."})}}(e,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o))return;const i="string"==typeof t.background?t.background:"#ffffff";if(!i.startsWith("#"))return;const r=[];for(const e of o){if("string"!=typeof e||!e.startsWith("#"))continue;const t=ef(e,i);null!==t&&3>t&&r.push(`${e} (${t.toFixed(1)}:1)`)}r.length>0&&n.push({severity:"warning",code:"LOW_COLOR_CONTRAST",message:`${r.length} color(s) in colorScheme have < 3:1 contrast against background "${i}": ${r.join(", ")}. Data marks may be hard to see.`,fix:'Use darker colors on light backgrounds or lighter colors on dark backgrounds. Import COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for an accessible preset.'})}(0,t,n),function(e,t,n){const o=t.colorScheme;if(!o||!Array.isArray(o)||2>o.length)return;const i=o.filter(e=>"string"==typeof e&&e.startsWith("#"));if(2>i.length)return;const r=[];for(let e=0;i.length-1>e;e++){const t=ef(i[e],i[e+1]);null!==t&&1.5>t&&r.push(`${i[e]} / ${i[e+1]} (${t.toFixed(1)}:1)`)}r.length>0&&n.push({severity:"warning",code:"LOW_ADJACENT_CONTRAST",message:`${r.length} adjacent color pair(s) in colorScheme have very similar luminance: ${r.join("; ")}. Categories may be hard to distinguish.`,fix:'Alternate light and dark colors in the scheme, or use COLOR_BLIND_SAFE_CATEGORICAL from "semiotic" for a pre-tested palette.'})}(0,t,n),function(e,t,n){const o="string"==typeof t.title&&t.title.trim().length>0,i="string"==typeof t.description&&t.description.trim().length>0,r="string"==typeof t.summary&&t.summary.trim().length>0;o||i||r||n.push({severity:"warning",code:"MISSING_DESCRIPTION",message:'No title, description, or summary provided. Screen readers will use a generic label like "XY chart".',fix:'Add a title="..." prop for a brief label, or description="..." for a detailed aria-label, or summary="..." for a screen-reader-only note describing the chart\'s purpose.'})}(0,t,n),function(e,t,n){const o=[];for(const e of tf)"function"==typeof t[e]&&o.push(e);o.length>0&&n.push({severity:"warning",code:"FUNCTION_ACCESSOR",message:`Function accessor${o.length>1?"s":""} detected: ${o.join(", ")}. If defined inline (e.g. \`xAccessor={d => d.value}\`), every parent re-render creates a new reference which may trigger unnecessary scene rebuilds.`,fix:'Use string accessors when possible (e.g. xAccessor="value"), or memoize with useCallback / define outside the component.'})}(0,t,n),function(e,t,n){const o=Array.isArray(t.annotations)?t.annotations:null;if(o)for(const e of o){if(!e||"object"!=typeof e)continue;const t=gn(e);if(!pn(e)||"widget"===t)continue;const o=Math.hypot("number"==typeof e.dx?e.dx:0,"number"==typeof e.dy?e.dy:0),i="string"==typeof e.label?e.label:"string"==typeof e.title?e.title:t,r=yn(e);!r&&o>120?n.push({severity:"warning",code:"ANNOTATION_FAR_NO_CONNECTOR",message:`Annotation "${i}" sits ~${Math.round(o)}px from its anchor with no connector — a reader can't tell what it refers to.`,fix:'Add a connector (connector: { end: "arrow" }, the label/callout default) or place the note adjacent to its target (smaller dx/dy).'}):r&&o>250&&n.push({severity:"warning",code:"ANNOTATION_LONG_CONNECTOR",message:`Annotation "${i}" uses a very long connector (~${Math.round(o)}px); prefer placing the note adjacent to its target when space allows.`,fix:"Reduce dx/dy so the note sits near its target, or keep the long connector only if proximity is genuinely infeasible."})}}(0,t,n),function(e,t,n){const o=Array.isArray(t.annotations)?t.annotations:null;if(!o)return;const i=o.filter(pn).length;if(0===i)return;const r="number"==typeof t.width?t.width:600,s="number"==typeof t.height?t.height:400,a=vn(r,s);Number.isFinite(a)&&i>a&&n.push({severity:"warning",code:"ANNOTATION_DENSITY",message:`${i} note annotations on a ${r}×${s} chart exceed the ~${a} notes the plot area carries comfortably — the chart may read as cluttered.`,fix:'Mark the essential notes emphasis: "primary" and let density management shed the rest (autoPlaceAnnotations: { density: true }), enable progressive disclosure to reveal secondary notes on hover, or give the chart more room.'})}(0,t,n),{ok:n.every(e=>"warning"===e.severity),diagnoses:n}):{ok:0===n.length,diagnoses:n}},exports.diffProfile=function(e,t){const n=new Set(Object.keys(e.fields)),o=new Set(Object.keys(t.fields)),i=[],r=[];for(const e of o)n.has(e)||i.push(e);for(const e of n)o.has(e)||r.push(e);i.sort(),r.sort();const s=[];for(const i of o){if(!n.has(i))continue;const o=Bp(e,i),r=Bp(t,i);o!==r&&s.push({field:i,from:o,to:r})}s.sort((e,t)=>e.field.localeCompare(t.field));const a=[];for(const n of Dp){const o=e.primary[n],i=t.primary[n];o!==i&&a.push({role:n,from:o,to:i})}const l=Ip(e),c=Ip(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.disableConversationArc=Th,exports.effectiveFamiliarity=up,exports.enableConversationArc=Lh,exports.evaluateVariantProposal=(e,t,n,o={})=>{var i,r,s,a,l;const c=rp(e.baseComponent);if(!c)return{proposalId:e.id,fit:0,novelty:1,risk:1,reasons:[`No capability registered for proposed component "${e.baseComponent}".`]};const u=c.fits(t);if(null!==u)return{proposalId:e.id,fit:0,novelty:"manual"===e.source?.2:.7,risk:1,reasons:["Rejected: "+u]};const d=ny(o.intent),h=oy(c,t,e.intentDeltas),f=iy(h,d),g=function(e,t){var n,o,i,r;return t?(r={familiarity:e.familiarity+(null!==(n=t.familiarity)&&void 0!==n?n:0),accuracy:e.accuracy+(null!==(o=t.accuracy)&&void 0!==o?o:0),precision:e.precision+(null!==(i=t.precision)&&void 0!==i?i:0)},{familiarity:Math.round(ey(r.familiarity,1,5)),accuracy:Math.round(ey(r.accuracy,1,5)),precision:Math.round(ey(r.precision,1,5))}):e}(c.rubric,e.rubricDeltas);let p;const y=null==n?void 0:n.receptionModality;if(y&&"visual"!==y){const o=e.variantKey?null===(i=c.variants)||void 0===i?void 0:i.find(t=>t.key===e.variantKey):void 0,r=e.buildProps?e.buildProps(t,n):c.buildProps(t,o);p=lp(yf(e.baseComponent,r),y)}const m=cp(f,g,e.baseComponent,n,p),v=ey(m.score,0,5);let b="manual"===e.source?.15:"heuristic"===e.source?.45:.75;o.baselineComponent&&o.baselineComponent!==e.baseComponent&&(b+=.2),e.variantKey||(b+=.05),b=ey(b,0,1);let x="manual"===e.source?.1:"heuristic"===e.source?.25:.45;0>(null!==(s=null===(r=e.rubricDeltas)||void 0===r?void 0:r.accuracy)&&void 0!==s?s:0)&&(x+=.15),0>(null!==(l=null===(a=e.rubricDeltas)||void 0===a?void 0:a.precision)&&void 0!==l?l:0)&&(x+=.1),g.accuracy>3||(x+=.1),3>v&&(x+=.2),x=ey(x,0,1);const w=[];if(e.rationale&&w.push(e.rationale),d.length>0){const e=d.map(e=>{var t;return`${e}: ${(null!==(t=h[e])&&void 0!==t?t:0).toFixed(1)}/5`}).join(", ");w.push(`Intent fit — ${e}.`)}else w.push(`Mean non-zero intent fit ${f.toFixed(1)}/5.`);return"manual"!==e.source&&w.push(e.source+" proposal; verify against domain context."),m.appliedReason&&w.push(m.appliedReason),m.receivabilityReason&&w.push(m.receivabilityReason),e.rubricDeltas&&Object.values(e.rubricDeltas).some(e=>0>(null!=e?e:0))&&w.push("Rubric tradeoff: improves one reading mode while reducing precision or accuracy."),{proposalId:e.id,fit:v,novelty:b,risk:x,reasons:w}},exports.executivePersona=Sp,exports.explainCapabilityFit=vp,exports.exportChart=dd,exports.filterAnnotationsByStatus=Vd,exports.flattenVisible=uh,exports.formatAccessibilityAudit=function(e){const t=[],n=e.summary,o=e.ok?`${n.criticalsPassed}/${n.criticalsEvaluated} critical heuristics pass`:`${n.fails} blocking failure(s) — ${n.criticalsPassed}/${n.criticalsEvaluated} critical heuristics pass`;t.push(`${e.ok?"✓":"✗"} ${e.component}: accessibility audit (Chartability POUR-CAF)`),t.push(` ${o} · ${n.warnings} warning(s) · ${n.manual} to verify manually`);for(const n of vf){const o=e.findings.filter(e=>e.principle===n&&"not-applicable"!==e.status);if(0!==o.length){t.push(""),t.push(" "+n.toUpperCase());for(const e of o)t.push(` ${mf[e.status]} ${e.id}${e.critical?" [critical]":""}: ${e.message}`),!e.fix||"fail"!==e.status&&"warn"!==e.status&&"manual"!==e.status||t.push(" → "+e.fix)}}return t.push(""),t.push(" Ref: "+e.reference),t.join("\n")},exports.fromConfig=function(e){if(!e.component||!e.props)throw Error("Invalid chart config: missing component or props");if(!bd[e.component])throw Error(`Unknown component "${e.component}". This config may require a newer version of semiotic.`);return{componentName:e.component,props:jd(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 n=t.replace(/-/g,"+").replace(/_/g,"/"),o=decodeURIComponent(escape(atob(n)));return JSON.parse(o)},exports.fromVegaLite=function(e){var t,n,o,i,r,s,a,l,c,u,d,h;const f=[],{type:g,markProps:p}=function(e){if("string"==typeof e)return{type:e,markProps:{}};const{type:t}=e;return{type:t,markProps:ds(e,["type"])}}(e.mark),y=e.encoding||{},m=y.x,v=y.y,b=y.color,x=y.size,w=y.theta,k=y.opacity;let A;(null===(t=e.data)||void 0===t?void 0:t.values)?A=e.data.values:(null===(n=e.data)||void 0===n?void 0:n.url)&&f.push("data.url is not supported — only inline data.values can be translated. Provide data manually."),e.transform&&e.transform.length>0&&f.push("Vega-Lite transforms are not supported. Pre-transform your data before passing to fromVegaLite()."),e.layer&&f.push('Layered specs ("layer") are not supported. Only single-mark specs can be translated.'),(e.hconcat||e.vconcat||e.concat)&&f.push('Concatenated views ("hconcat"/"vconcat"/"concat") are not supported. Translate each sub-spec individually.'),(e.facet||y.facet||y.row||y.column)&&f.push("Faceted views are not supported. Use Semiotic's LinkedCharts or render multiple charts manually."),e.repeat&&f.push('Repeated views ("repeat") are not supported. Translate each field combination individually.'),(e.params||e.selection)&&f.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===(o=b.scale)||void 0===o?void 0:o.scheme)){const e=wf[b.scale.scheme];e&&(j.colorScheme=e)}void 0!==(null==k?void 0:k.value)&&(j.pointOpacity=k.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,n=Af[e.aggregate];if(n&&(null==t?void 0:t.field)&&e.field)A=function(e,t){const{groupBy:n,value:o,agg:i="sum"}=t,r=new Map;for(const t of e){const e=t[n]+"";r.has(e)||r.set(e,[]),r.get(e).push(Number(t[o]))}const s=[];for(const[e,t]of r){let o;switch(i){case"count":o=t.length;break;case"mean":o=t.reduce((e,t)=>e+t,0)/t.length;break;case"min":o=Math.min(...t);break;case"max":o=Math.max(...t);break;default:o=t.reduce((e,t)=>e+t,0)}s.push({[n]:e,value:o})}return s}(A,{groupBy:t.field,value:e.field,agg:n});else if(("count"===n||"count"===e.aggregate)&&(null==t?void 0:t.field)&&A){const e=new Map;for(const n of A){const o=n[t.field]+"";e.set(o,(e.get(o)||0)+1)}A=Array.from(e,([e,n])=>({[t.field]:e,value:n}))}}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),n="object"==typeof t?t.maxbins:void 0;return n&&(j.bins=n),Sf(e,j,f)}let M;switch(g){case"bar":M=function(e,t,n,o,i,r,s){var a,l,c,u,d,h;let f;return(null==n?void 0:n.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)?(f="StackedBarChart",o.stackBy=n.field):f="BarChart",bf(null==e?void 0:e.type)&&xf(null==t?void 0:t.type)?(o.categoryAccessor=e.field,o.valueAccessor=s?"value":t.field,(null===(a=null==e?void 0:e.axis)||void 0===a?void 0:a.title)&&(o.categoryLabel=e.axis.title),(null===(l=null==t?void 0:t.axis)||void 0===l?void 0:l.title)&&(o.valueLabel=t.axis.title)):xf(null==e?void 0:e.type)&&bf(null==t?void 0:t.type)?(o.categoryAccessor=t.field,o.valueAccessor=r?"value":e.field,o.orientation="horizontal",(null===(c=null==t?void 0:t.axis)||void 0===c?void 0:c.title)&&(o.categoryLabel=t.axis.title),(null===(u=null==e?void 0:e.axis)||void 0===u?void 0:u.title)&&(o.valueLabel=e.axis.title)):((null==e?void 0:e.field)&&(o.categoryAccessor=e.field),(null==t?void 0:t.field)&&(o.valueAccessor=s?"value":t.field),(null===(d=null==e?void 0:e.axis)||void 0===d?void 0:d.title)&&(o.categoryLabel=e.axis.title),(null===(h=null==t?void 0:t.axis)||void 0===h?void 0:h.title)&&(o.valueLabel=t.axis.title)),i&&(o.data=i),f}(m,v,b,j,A,C,O);break;case"line":if(M="LineChart",jf(m,v,j,C,O),(null==b?void 0:b.field)&&(j.lineBy=b.field),p.interpolate){const e=kf[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",jf(m,v,j,C,O),p.interpolate){const e=kf[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",jf(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==w?void 0:w.field)?j.valueAccessor=w.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==w?void 0:w.field)&&(j.categoryAccessor=m.field),A&&(j.data=A);break;case"tick":M="DotPlot",bf(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)):bf(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:f.push(`Unsupported mark type "${g}". Defaulting to Scatterplot.`),M="Scatterplot",jf(m,v,j,C,O),A&&(j.data=A)}return Sf(M,j,f)},exports.getCapabilities=ip,exports.getCapability=rp,exports.getConversationArcStore=Nh,exports.getIntent=function(e){return Qp.get(e)},exports.getRegisteredVariantDiscovery=function(){return Array.from(Jp)},exports.getStreamCapabilities=Tp,exports.inferIntent=function(e){var t;if("string"!=typeof e||0===e.trim().length)return null;const n=new Map;for(const o of Ap)for(const i of o.patterns)if(i.test(e)){const e=null!==(t=n.get(o.intent))&&void 0!==t?t:0;n.set(o.intent,Math.min(5,0===e?o.weight:e+.5));break}if(0===n.size)return null;const o=Array.from(n.entries()).map(([e,t])=>({intent:e,confidence:t})).sort((e,t)=>t.confidence-e.confidence),[i,...r]=o;return{intent:i.intent,confidence:i.confidence,alternates:r}},exports.listIntents=function(){return Array.from(Qp.values())},exports.loadConversationArc=Mh,exports.profileData=Jf,exports.proposeVariant=(e,t,n)=>function(e,t,n){var o;const i=new Map,r=e=>{for(const t of e)t&&t.id&&t.baseComponent&&(i.has(t.id)||i.set(t.id,t))};r(function(e,t,n){var o,i,r;const s=n.profile,a=null!==(i=null!==(o=n.existingVariants)&&void 0!==o?o:t.variants)&&void 0!==i?i:[],l=ny(n.intent),c=[];for(const e of a)c.push(ry(t,e));const u=l.includes("rank")||l.includes("compare-categories");!ay.has(e)||"categorical"!==t.family||sy(a,"orientation","horizontal")||!u&&6>(null!==(r=s.categoryCount)&&void 0!==r?r:0)||c.push({id:e+":heuristic-horizontal",baseComponent:e,label:"Horizontal ranked view",intentDeltas:{rank:1,"compare-categories":.5},rubricDeltas:{precision:1},buildProps:e=>Object.assign(Object.assign({},t.buildProps(e)),{orientation:"horizontal",sort:"desc"}),rationale:"Horizontal orientation improves label legibility and rank scanning for categorical comparisons.",source:"heuristic",tags:["horizontal","ranked"]});const d=sy(a,"normalize",!0)||sy(a,"type","percent")||a.some(e=>/normal|percent/i.test(`${e.key} ${e.label}`));if(/Stacked/.test(e)&&!d&&(l.includes("part-to-whole")||l.includes("composition-over-time"))&&c.push({id:e+":heuristic-normalized",baseComponent:e,label:"Normalized composition",intentDeltas:{"part-to-whole":1,"compare-categories":-.5},rubricDeltas:{precision:-1},buildProps:e=>Object.assign(Object.assign({},t.buildProps(e)),{normalize:!0}),rationale:"Normalization emphasizes proportional composition when absolute magnitude is secondary.",source:"heuristic",tags:["normalized","part-to-whole"]}),l.length>0){const t=ip().filter(t=>t.component!==e).filter(e=>null===e.fits(s)).map(e=>{const t=oy(e,s);return{candidate:e,fit:iy(t,l),scores:t}}).filter(e=>e.fit>=4).sort((e,t)=>t.fit!==e.fit?t.fit-e.fit:t.candidate.rubric.accuracy!==e.candidate.rubric.accuracy?t.candidate.rubric.accuracy-e.candidate.rubric.accuracy:t.candidate.rubric.familiarity-e.candidate.rubric.familiarity).slice(0,3);for(const{candidate:e,fit:n}of t)c.push({id:`${e.component}:heuristic-${l.join("-")}`,baseComponent:e.component,label:e.component+" alternative",buildProps:t=>e.buildProps(t),rationale:`${e.component} is a strong ${l.join(" + ")} alternative (${n.toFixed(1)}/5) for this data shape.`,source:"heuristic",tags:["cross-family",e.family]})}return c}(e,t,n));for(const i of Jp){let s=[];try{s=null!==(o=i(e,t,n))&&void 0!==o?o:[]}catch(e){void 0!==console&&console.warn("[variantDiscovery] proposer threw:",e);continue}r(s)}return Array.from(i.values())}(e,t,n),exports.receivabilityBias=lp,exports.recordAnnotationStatusChange=function(e,t){return Rh.record({type:"annotation-status-changed",toStatus:e,annotationId:null==t?void 0:t.annotationId,fromStatus:null==t?void 0:t.fromStatus,chartId:null==t?void 0:t.chartId,arcId:null==t?void 0:t.arcId,meta:null==t?void 0:t.meta})},exports.recordAudienceChange=function(e,t,n){return Rh.record(Object.assign({type:"audience-set",audience:e,previous:null!=t?t:void 0},n))},exports.registerChartCapability=function(e){op.set(e.component,e)},exports.registerConversationArcSink=function(e){if(!e||"object"!=typeof e)throw new TypeError("registerConversationArcSink: sink must be an object");return fh.add(e),()=>{fh.delete(e)}},exports.registerIntent=function(e){Qp.set(e.id,e)},exports.registerStreamChartCapability=function(e){Lp.set(e.component,e)},exports.registerVariantDiscovery=function(e){return Jp.add(e),()=>{Jp.delete(e)}},exports.repairChartConfig=function(e,t,n={}){var o,i;const r=null!==(o=n.profile)&&void 0!==o?o:Jf(null!=t?t:[],{rawInput:n.rawInput}),s=rp(e),a=null!==(i=n.maxAlternatives)&&void 0!==i?i:3;if(!s)return{status:"unknown",component:e,alternatives:mp(t,{profile:r,intent:n.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:mp(t,{profile:r,intent:n.intent,maxResults:a,deny:[e],includeVariants:!1}),profile:r}},exports.replayConversationArc=function(e,t={}){return Mh(e,t)},exports.resolveCardinalityToNumber=lg,exports.resolveCommunicativeAct=nh,exports.resolveRowsToNumber=ag,exports.runQualityScorecard=function(e,t=ip()){var n,o,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,f=new Map,g=new Map,p=[];for(const s of e){let e,a;try{e=Jf(s.data,{rawInput:s.rawInput}),a=vp(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!==(n=d.get(e.component))&&void 0!==n?n:0)+e.score),h.set(e.component,(null!==(o=h.get(e.component))&&void 0!==o?o:0)+1),e.caveats.length>0&&f.set(e.component,(null!==(i=f.get(e.component))&&void 0!==i?i:0)+1),e.variant&&g.set(e.component,(null!==(r=g.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=f.get(e.component))&&void 0!==l?l:0)/t,e.variantUtilization=0===t?0:(null!==(c=g.get(e.component))&&void 0!==c?c:0)/t}const y=Array.from(u.values()).sort((e,t)=>{const n=e.expertAgreementCount-t.expertAgreementCount;return 0!==n?n: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(f.values()).reduce((e,t)=>e+t,0),w=Array.from(g.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:w/b}}},exports.scaleHints=hg,exports.scoreChart=function(e,t,n={}){var o,i,r;const s=ip().find(t=>t.component===e);if(!s)return{reason:`No capability registered for "${e}"`};const a=null!==(o=n.profile)&&void 0!==o?o:Jf(null!=t?t:[]),l=s.fits(a);if(null!==l)return{reason:l};const c=n.variantKey?null===(i=s.variants)||void 0===i?void 0:i.find(e=>e.key===n.variantKey):void 0,u=n.intent?Array.isArray(n.intent)?n.intent:[n.intent]:[],d={};for(const[e,t]of Object.entries(s.intentScores))d[e]=hp(t,a);const h=fp(d,c),f=yp(h,u),g=gp(s.rubric,c),p=pp(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:f,intentScores:h,rubric:g,reasons:p,caveats:y,props:s.buildProps(a,c)}},exports.serializeSelections=function(e){const t={};for(const[n,o]of e){const e=[];for(const[,t]of o.clauses){const n={};for(const[e,o]of Object.entries(t.fields))n[e]="point"===o.type?{type:"point",values:Array.from(o.values)}:{type:"interval",range:o.range};e.push({clientId:t.clientId,type:t.type,fields:n})}t[n]={name:o.name,resolution:o.resolution,clauses:e}}return t},exports.stretchFamiliarityCeiling=dp,exports.subscribeToConversationArcChange=Oh,exports.suggestCharts=mp,exports.suggestChartsGrouped=function(e,t={}){var n,o,i,r,s,a,l,c,u;const d=null!==(n=t.profile)&&void 0!==n?n:Jf(null!=e?e:[],{rawInput:t.rawInput,seriesField:t.seriesField}),h=cg(d,t.scale),f=null!==(i=null!==(o=t.maxPerBand)&&void 0!==o?o:t.maxResults)&&void 0!==i?i:5,g=["tiny","small","medium","large","huge"],p={};for(const n of g){const o=Object.assign(Object.assign({},null!==(r=t.scale)&&void 0!==r?r:{}),{rows:n});p[n]=mp(e,Object.assign(Object.assign({},t),{profile:d,scale:o,maxResults:f}))}return{tiny:null!==(s=p.tiny)&&void 0!==s?s:[],small:null!==(a=p.small)&&void 0!==a?a:[],medium:null!==(l=p.medium)&&void 0!==l?l:[],large:null!==(c=p.large)&&void 0!==c?c:[],huge:null!==(u=p.huge)&&void 0!==u?u:[],effective:h}},exports.suggestDashboard=function(e,t={}){var n,o,i,r,s,a,l,c,u,d,h;const f=null!==(n=t.profile)&&void 0!==n?n:Jf(null!=e?e:[],{rawInput:t.rawInput}),g=null!==(o=t.maxPanels)&&void 0!==o?o: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))}(f),m=[],v=[],b=[],x=new Set,w=new Set;for(const n of y){if(m.length>=g){b.push(n);continue}const o=mp(e,{profile:f,intent:n,allow:t.allow,deny:t.deny,maxResults:20,includeVariants:!0,minScore:1.5,audience:t.audience});let i;for(const e of o){const t=`${e.component}/${null!==(s=null===(r=e.variant)||void 0===r?void 0:r.key)&&void 0!==s?s:"base"}`;if(!(w.has(t)||p&&x.has(e.family))){i=e;break}}if(!i&&p)for(const e of o){const t=`${e.component}/${null!==(l=null===(a=e.variant)||void 0===a?void 0:a.key)&&void 0!==l?l:"base"}`;if(!w.has(t)){i=e;break}}i?(m.push({intent:n,suggestion:i}),v.push(n),x.add(i.family),w.add(`${i.component}/${null!==(u=null===(c=i.variant)||void 0===c?void 0:c.key)&&void 0!==u?u:"base"}`)):b.push(n)}return{panels:m,intentsCovered:v,intentsMissing:b,stretchPanels:t.audience&&(null!==(d=t.audience.exposureLevel)&&void 0!==d?d:1)>0?jp(e,{profile:f,audience:t.audience,deny:Array.from(w).map(e=>e.split("/")[0]),maxResults:null!==(h=t.maxStretchPanels)&&void 0!==h?h:Math.min(3,g)}):[],profile:f}},exports.suggestStreamCharts=function(e,t={}){var n,o,i;const r=null!==(n=t.capabilities)&&void 0!==n?n:Tp(),s=t.intent?Array.isArray(t.intent)?t.intent:[t.intent]:[],a=null!==(o=t.minScore)&&void 0!==o?o: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 n={};for(const[o,i]of Object.entries(t.intentScores))n[o]=Np(i,e);const o=Rp(n,s);if(a>o)continue;const i=Object.assign({},t.rubric),r=t.caveats?Array.from(t.caveats(e)):[],l=$p(e,n,s),h=t.buildProps(e);d.push({component:t.component,family:"realtime",importPath:t.importPath,score:o,intentScores:n,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=jp,exports.summarizeArc=cy,exports.summarizeData=Lf,exports.toConfig=function(e,t,n){if(!bd[e])throw Error(`Unknown component "${e}". Known components: ${Object.keys(bd).join(", ")}`);const o=!1!==(null==n?void 0:n.includeData),i={};for(const[e,n]of Object.entries(t))null!=n&&(kd.has(e)||!o&&Ad.has(e)||"function"!=typeof n&&((null==n?void 0:n.$$typeof)||(i[e]=jd(n))));return Object.assign({component:e,props:i,version:"1",createdAt:(new Date).toISOString()},(null==n?void 0:n.selections)?{selections:n.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){op.delete(e)},exports.unregisterStreamChartCapability=function(e){Lp.delete(e)},exports.useBrushSelection=er,exports.useCategoryColors=Wi,exports.useChartFocus=function(e={}){const{chartId:n,types:o=xp}=e,{latest:i}=tr({chartId:n,types:o,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:n,onQuery:o,initialAnnotations:i,componentName:r,props:s,includeProfile:a,includeSuggestions:l,suggestionsIntent:c,suggestionsMax:u,focus:d}=e,[h,f]=t.useState([]),[g,p]=t.useState([]),[y,m]=t.useState(!1),[v,b]=t.useState(null),x=t.useMemo(()=>Lf(null!=n?n:[]),[n]),w=a||l,k=t.useMemo(()=>w?Jf(null!=n?n:[]):void 0,[w,n]),A=t.useMemo(()=>l&&k?mp(n,{profile:k,intent:c,maxResults:null!=u?u:5}):void 0,[l,k,n,c,u]),j=t.useRef(o);j.current=o;const S=t.useRef(r);S.current=r;const C=t.useRef(s);C.current=s;const O=t.useRef(n);O.current=n;const M=t.useRef(x);M.current=x;const P=t.useRef(k);P.current=k;const _=t.useRef(A);_.current=A;const L=t.useRef(d);L.current=d;const T=t.useCallback(e=>hs(this,void 0,void 0,function*(){var t,n,o;const i=e.trim();if(!i)return;m(!0),b(null),f(e=>[...e,{role:"user",text:i}]);const r="undefined"!=typeof performance?performance.now():Date.now();Nh().record({type:"interrogation-asked",component:S.current,query:bp(i,500)});try{const e=yield j.current(i,{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!==(n=L.current)&&void 0!==n?n:void 0});f(t=>[...t,{role:"assistant",text:e.answer}]),e.annotations&&p(e.annotations);const s="undefined"!=typeof performance?performance.now():Date.now();Nh().record({type:"interrogation-answered",component:S.current,answer:bp(e.answer,2e3),annotationCount:null===(o=e.annotations)||void 0===o?void 0:o.length,latencyMs:Math.max(0,Math.round(s-r))})}catch(e){b(e instanceof Error?e:Error(e+"")),f(e=>[...e,{role:"assistant",text:"Sorry, I couldn't process that query."}]);const t="undefined"!=typeof performance?performance.now():Date.now();Nh().record({type:"interrogation-answered",component:S.current,error:!0,latencyMs:Math.max(0,Math.round(t-r))})}finally{m(!1)}}),[]),N=t.useCallback(({text:e,annotations:t})=>{const n=e.trim();n&&(f(e=>[...e,{role:"assistant",text:n}]),t&&t.length>0&&p(e=>[...e,...t]))},[]),R=t.useCallback(()=>{f([]),p([]),b(null)},[]);return{ask:T,announce:N,history:h,summary:x,annotations:t.useMemo(()=>{const e=null!=i?i:[];return 0===e.length?g:0===g.length?e:[...e,...g]},[i,g]),loading:y,error:v,reset:R}},exports.useChartObserver=tr,exports.useChartSuggestions=function(e,n={}){const{intent:o,allow:i,deny:r,maxResults:s,includeVariants:a,minScore:l,rawInput:c,seriesField:u,capabilities:d,audience:h,profile:f}=n,g=t.useMemo(()=>null!=f?f:Jf(null!=e?e:[],{rawInput:c,seriesField:u}),[f,e,c,u]),p=t.useMemo(()=>mp(e,{intent:o,allow:i,deny:r,maxResults:s,includeVariants:a,minScore:l,capabilities:d,audience:h,profile:g}),[e,o,i,r,s,a,l,d,h,g]),y=t.useSyncExternalStore(Vp,Xp,Up),m=t.useRef(null);return t.useEffect(()=>{var e,t,n,i;if(0===p.length)return void(m.current=null);if(!y)return void(m.current=null);const r=Nh(),s=null!==(e=null==h?void 0:h.name)&&void 0!==e?e:h?"custom":void 0,a=`${null!=o?o:""}|${null!=s?s:""}|${p.map(e=>e.component).join(",")}`;if(a===m.current)return;const l=r.getEvents();for(let e=l.length-1;e>=0;e--){const o=l[e];if("suggestion-shown"===o.type){if(`${Array.isArray(o.intent)?o.intent.join(","):null!==(t=o.intent)&&void 0!==t?t:""}|${null!==(n=o.audience)&&void 0!==n?n:""}|${o.components.join(",")}`===a)return void(m.current=a);break}}m.current=a,r.record({type:"suggestion-shown",intent:o,components:p.map(e=>e.component),topScore:null===(i=p[0])||void 0===i?void 0:i.score,audience:s})},[p,o,h,y]),{suggestions:p,profile:g}},exports.useConversationArc=function(e={}){const{enableOnMount:n=!0,disableOnUnmount:o=!1,capacity:i,sessionId:r}=e;t.useEffect(()=>(n&&Lh({capacity:i,sessionId:r}),()=>{o&&Th()}),[n,o,i,r]);const s=t.useCallback(e=>Oh(e),[]),a=t.useCallback(()=>Nh().getEvents(),[]),l=t.useSyncExternalStore(s,a,a),[c,u]=t.useState(()=>Nh().enabled),[d,h]=t.useState(()=>Nh().sessionId);t.useEffect(()=>(u(Nh().enabled),h(Nh().sessionId),Oh(()=>{const e=Nh();u(e.enabled),h(e.sessionId)})),[]);const f=t.useMemo(()=>cy(l),[l]),g=t.useCallback(e=>Nh().record(e),[]),p=t.useCallback(()=>Nh().clear(),[]);return{history:l,summary:f,enabled:c,sessionId:d,record:g,clear:p}},exports.useFilteredData=function(e,n,o){const i=Xi(e=>e.selections.get(n));return t.useMemo(()=>{if(!i||0===i.clauses.size)return e;const t=Yi(i,o);return e.filter(t)},[e,i,o])},exports.useLinkedHover=Zi,exports.useNavigationSync=function(e){var n;const{tree:o,chartId:i,observe:r=["hover","click"]}=e,s=null!==(n=e.selectionName)&&void 0!==n?n:"__semiotic-nav-sync"+(i?":"+i:""),a=t.useMemo(()=>{if(e.matchFields)return e.matchFields;const t=wp(o);return t?Object.keys(t).filter(e=>{return!e.startsWith("_")&&(null==(n=t[e])||"string"==typeof n||"number"==typeof n||"boolean"==typeof n);var n}):[]},[e.matchFields,o]),l=t.useMemo(()=>{const e=new Map,t=n=>{var o;if("datum"===n.role&&n.datum){const t=kp(n.datum,a);e.has(t)||e.set(t,n.id)}for(const e of null!==(o=n.children)&&void 0!==o?o:[])t(e)};return t(o),e},[o,a]),{selectPoints:c,clear:u}=Qi({name:s}),{latest:d}=tr({chartId:i,types:[...r,"hover-end"],limit:1}),[h,f]=t.useState(o.id);t.useEffect(()=>{f(o.id),u()},[o,u]);const g=t.useCallback(e=>{if(f(e.id),"datum"===e.role&&e.datum&&a.length>0){const t={};for(const n of a)t[n]=[e.datum[n]];c(t)}else u()},[a,c,u]),p=e.annotations,y=t.useMemo(()=>{const e=new Set;if(0===a.length||!p)return e;for(const t of p){const n=l.get(kp(t,a));n&&e.add(n)}return e},[p,l,a]),m=t.useCallback(e=>{const t="number"==typeof e?null==p?void 0:p[e]:e;if(!t||0===a.length)return!1;const n=l.get(kp(t,a));if(!n)return!1;f(n);const o={};for(const e of a)o[e]=[t[e]];return c(o),!0},[p,l,a,c]),v=t.useRef(null);return t.useEffect(()=>{if(!d||d===v.current)return;if(v.current=d,"hover-end"===d.type)return;const e=d.datum;if(!e||0===a.length)return;const t=l.get(kp(e,a));t&&t!==h&&f(t)},[d,l,a,h]),{activeId:h,onActiveChange:g,selection:{name:s},annotatedIds:y,focusAnnotation:m}},exports.useSelection=Qi,exports.useTheme=wr,exports.validateProps=wd,exports.withCurrentProvenance=function(e,t={}){var n,o;const i=e.provenance;return Object.assign(Object.assign({},e),{provenance:Object.assign(Object.assign(Object.assign({},i),t),{createdAt:null!==(o=null!==(n=t.createdAt)&&void 0!==n?n:null==i?void 0:i.createdAt)&&void 0!==o?o:Dd()})})},exports.withProvenance=function(e,t){const n=Object.assign({},e);return t.provenance&&(n.provenance=t.provenance),t.lifecycle&&(n.lifecycle=t.lifecycle),n};
|