radiant-charts-core 0.2.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.
@@ -0,0 +1,431 @@
1
+ import React from 'react';
2
+
3
+ type TooltipTrigger = 'hover' | 'none';
4
+ type TooltipMode = 'shared' | 'item';
5
+ type TooltipPositionMode = 'follow-pointer' | 'snap-to-data' | 'fixed';
6
+ interface TooltipDatumEntry {
7
+ seriesIndex: number;
8
+ seriesId: string;
9
+ seriesType: string;
10
+ title: string;
11
+ color: string;
12
+ datum: Record<string, any>;
13
+ dataIndex: number;
14
+ xValue: any;
15
+ yValue: any;
16
+ }
17
+ interface TooltipState {
18
+ active: boolean;
19
+ /** Raw mouse position — viewport-relative (clientX/Y) */
20
+ pointerX: number;
21
+ pointerY: number;
22
+ /** Snapped data-point position — viewport-relative, used as portal anchor */
23
+ anchorX: number;
24
+ anchorY: number;
25
+ /** Chart-local coordinates (relative to container top-left) */
26
+ localX: number;
27
+ localY: number;
28
+ /** Active data entries */
29
+ entries: TooltipDatumEntry[];
30
+ /** Shared X-axis label (for shared mode) */
31
+ sharedLabel: string | null;
32
+ }
33
+ interface TooltipOptions {
34
+ enabled?: boolean;
35
+ trigger?: TooltipTrigger;
36
+ mode?: TooltipMode;
37
+ positionMode?: TooltipPositionMode;
38
+ delay?: {
39
+ show?: number;
40
+ hide?: number;
41
+ };
42
+ offset?: {
43
+ x?: number;
44
+ y?: number;
45
+ };
46
+ snap?: boolean;
47
+ shared?: boolean;
48
+ }
49
+
50
+ interface DataLabelOptions {
51
+ readonly enabled?: boolean;
52
+ /** 'top' | 'bottom' | 'left' | 'right' | 'inside' | 'center' | 'outside' */
53
+ readonly position?: string;
54
+ readonly fontSize?: number;
55
+ readonly fontFamily?: string;
56
+ readonly fill?: string;
57
+ readonly fontWeight?: string;
58
+ readonly rotation?: number;
59
+ }
60
+ interface AnimationOptions {
61
+ readonly enabled?: boolean;
62
+ readonly duration?: number;
63
+ readonly easing?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic' | 'bounce' | 'elastic' | 'back';
64
+ readonly type?: 'grow' | 'fade' | 'slide' | 'pop' | 'draw' | 'radial';
65
+ readonly delay?: number;
66
+ }
67
+ interface DropShadow {
68
+ readonly enabled?: boolean;
69
+ readonly color?: string;
70
+ readonly xOffset?: number;
71
+ readonly yOffset?: number;
72
+ readonly blur?: number;
73
+ }
74
+ type MarkerShape = 'circle' | 'square' | 'cross' | 'diamond' | 'triangle' | 'plus';
75
+ interface MarkerOptions {
76
+ readonly enabled?: boolean;
77
+ readonly shape?: MarkerShape;
78
+ readonly size?: number;
79
+ readonly fill?: string;
80
+ readonly stroke?: string;
81
+ readonly strokeWidth?: number;
82
+ }
83
+ interface RadiantChartOptions {
84
+ readonly data: readonly any[];
85
+ readonly animation?: AnimationOptions;
86
+ readonly title?: {
87
+ text: string;
88
+ fontSize?: number;
89
+ fill?: string;
90
+ };
91
+ readonly subtitle?: {
92
+ text: string;
93
+ fontSize?: number;
94
+ fill?: string;
95
+ };
96
+ readonly legend?: {
97
+ readonly enabled?: boolean;
98
+ readonly position?: 'top' | 'bottom' | 'left' | 'right';
99
+ readonly type?: 'discrete';
100
+ readonly listeners?: {
101
+ readonly legendItemClick?: (event: {
102
+ seriesId: string;
103
+ visible: boolean;
104
+ }) => void;
105
+ readonly legendItemDoubleClick?: (event: {
106
+ seriesId: string;
107
+ isolated: boolean;
108
+ }) => void;
109
+ };
110
+ };
111
+ /**
112
+ * Node-level pointer event callbacks. Triggered when the user interacts with
113
+ * an individual data point (bar / marker / sector / etc).
114
+ */
115
+ readonly listeners?: {
116
+ readonly nodeClick?: (event: {
117
+ seriesId: string;
118
+ datum: any;
119
+ xKey?: string;
120
+ yKey?: string;
121
+ type?: string;
122
+ }) => void;
123
+ readonly nodeDoubleClick?: (event: {
124
+ seriesId: string;
125
+ datum: any;
126
+ xKey?: string;
127
+ yKey?: string;
128
+ type?: string;
129
+ }) => void;
130
+ };
131
+ readonly showXAxis?: boolean;
132
+ readonly showYAxis?: boolean;
133
+ readonly showYAxisRight?: boolean;
134
+ readonly xAxisFontSize?: number;
135
+ readonly xAxisFontFamily?: string;
136
+ readonly xAxisRotation?: number;
137
+ readonly xAxisLabelAlignment?: 'start' | 'center' | 'end';
138
+ readonly yAxisFontSize?: number;
139
+ readonly yAxisFontFamily?: string;
140
+ readonly yAxisRotation?: number;
141
+ readonly yAxisLabelAlignment?: 'start' | 'center' | 'end';
142
+ readonly yAxisRightFontSize?: number;
143
+ readonly yAxisRightFontFamily?: string;
144
+ readonly yAxisRightRotation?: number;
145
+ readonly yAxisRightLabelAlignment?: 'start' | 'center' | 'end';
146
+ readonly series: readonly {
147
+ readonly type?: 'bar' | 'line' | 'pie' | 'donut' | 'area' | 'scatter';
148
+ readonly animation?: AnimationOptions;
149
+ readonly yAxisId?: 'left' | 'right';
150
+ readonly xAxisKey?: string;
151
+ readonly yAxisKey?: string;
152
+ readonly xKey?: string;
153
+ readonly yKey?: string;
154
+ readonly angleKey?: string;
155
+ readonly labelKey?: string;
156
+ readonly shadow?: DropShadow;
157
+ readonly connectMissingData?: boolean;
158
+ readonly sizeKey?: string;
159
+ readonly markerSize?: number;
160
+ readonly title?: string;
161
+ readonly fill?: string;
162
+ readonly stroke?: string;
163
+ readonly strokeWidth?: number;
164
+ readonly fills?: readonly string[];
165
+ readonly innerRadius?: number;
166
+ readonly outerRadius?: number;
167
+ readonly startAngle?: number;
168
+ readonly endAngle?: number;
169
+ readonly padAngle?: number;
170
+ readonly fillOpacity?: number;
171
+ readonly cornerRadius?: number;
172
+ readonly grouped?: boolean;
173
+ readonly stacked?: boolean;
174
+ readonly normalized?: boolean;
175
+ readonly direction?: 'vertical' | 'horizontal';
176
+ readonly interpolation?: 'linear' | 'step' | 'smooth';
177
+ /** @deprecated use interpolation:'step' */
178
+ readonly step?: boolean;
179
+ readonly marker?: MarkerOptions;
180
+ readonly jitter?: number;
181
+ readonly labels?: DataLabelOptions;
182
+ }[];
183
+ theme?: 'light' | 'dark' | 'system';
184
+ padding?: {
185
+ readonly top?: number;
186
+ readonly right?: number;
187
+ readonly bottom?: number;
188
+ readonly left?: number;
189
+ readonly inner?: number;
190
+ };
191
+ crosshair?: {
192
+ readonly x?: boolean;
193
+ readonly y?: boolean;
194
+ };
195
+ tooltip?: TooltipOptions;
196
+ toolbar?: {
197
+ readonly showExport?: boolean;
198
+ };
199
+ /**
200
+ * Callback triggered when keyboard navigation moves the internal focus index.
201
+ * Used for synchronizing the virtualized accessibility table.
202
+ */
203
+ readonly onFocusChange?: (index: number | null) => void;
204
+ }
205
+ interface RadiantChartHandle {
206
+ /**
207
+ * Exports the current chart as a PNG and triggers a browser download.
208
+ * @param filename Download filename. Defaults to 'chart.png'.
209
+ */
210
+ exportToPng(filename?: string): void;
211
+ }
212
+ interface RadiantChartProps {
213
+ options: RadiantChartOptions;
214
+ /**
215
+ * Explicit width for the chart container. Number = px, string = CSS value.
216
+ * Defaults to '100%'. For responsive sizing wrap with ResponsiveContainer.
217
+ */
218
+ width?: number | string;
219
+ /**
220
+ * Explicit height for the chart container. Number = px, string = CSS value.
221
+ * Defaults to '100%'. When using '100%' the parent must have a defined height,
222
+ * or wrap with ResponsiveContainer which handles this automatically.
223
+ */
224
+ height?: number | string;
225
+ className?: string;
226
+ style?: React.CSSProperties;
227
+ }
228
+ declare const RadiantChart: React.ForwardRefExoticComponent<RadiantChartProps & React.RefAttributes<RadiantChartHandle>>;
229
+
230
+ interface ResponsiveContainerProps {
231
+ /**
232
+ * Width of the container. Number = pixels, string = CSS value (e.g. '100%').
233
+ * Default: '100%'
234
+ */
235
+ width?: number | string;
236
+ /**
237
+ * Height of the container. Number = pixels, string = CSS value (e.g. '100%').
238
+ * When '100%' the container observes its parent and fills it.
239
+ * Default: 300
240
+ */
241
+ height?: number | string;
242
+ /** Minimum height in px applied as a CSS floor. Default: 100 */
243
+ minHeight?: number;
244
+ /** Minimum width in px applied as a CSS floor. Default: 0 */
245
+ minWidth?: number;
246
+ /**
247
+ * Aspect ratio (width ÷ height). When set, height is derived from the
248
+ * measured container width and this ratio. Overrides `height`.
249
+ */
250
+ aspect?: number;
251
+ /**
252
+ * Debounce resize callbacks by N ms to avoid excessive re-renders.
253
+ * Default: 0 (no debounce)
254
+ */
255
+ debounce?: number;
256
+ className?: string;
257
+ style?: React.CSSProperties;
258
+ children: React.ReactNode;
259
+ }
260
+ declare const ResponsiveContainer: React.FC<ResponsiveContainerProps>;
261
+
262
+ /**
263
+ * Radiant Charts — Declarative JSX API
264
+ *
265
+ * Provides a composable, JSX-first interface that React developers expect.
266
+ * Children register their configuration with the parent <Chart> via context;
267
+ * the parent assembles a standard RadiantChartOptions object and renders a
268
+ * single imperative RadiantChart under the hood.
269
+ *
270
+ * @example
271
+ * ```tsx
272
+ * import { Chart, Bar, Line, XAxis, YAxis, Title, Legend } from 'radiant-charts/Declarative';
273
+ *
274
+ * const data = [
275
+ * { month: 'Jan', sales: 120, target: 100 },
276
+ * { month: 'Feb', sales: 150, target: 130 },
277
+ * { month: 'Mar', sales: 135, target: 140 },
278
+ * ];
279
+ *
280
+ * export default function Revenue() {
281
+ * return (
282
+ * <Chart data={data} theme="dark" height={400}>
283
+ * <Title text="Monthly Revenue" />
284
+ * <Legend position="bottom" />
285
+ * <XAxis fontSize={11} rotation={-45} />
286
+ * <YAxis show={false} />
287
+ * <Bar xKey="month" yKey="sales" fill="#4e79a7" cornerRadius={4} />
288
+ * <Line xKey="month" yKey="target" stroke="#e15759" />
289
+ * </Chart>
290
+ * );
291
+ * }
292
+ * ```
293
+ */
294
+
295
+ interface ChartProps {
296
+ /** The data array shared by all series children. */
297
+ data: readonly any[];
298
+ /** Color theme. Accepts 'light', 'dark', or 'system'. */
299
+ theme?: 'light' | 'dark' | 'system';
300
+ /** Chart width. Number = px, string = CSS value. Default '100%'. */
301
+ width?: number | string;
302
+ /** Chart height. Number = px, string = CSS value. Default '100%'. */
303
+ height?: number | string;
304
+ /** Global animation options applied to all series. */
305
+ animation?: AnimationOptions;
306
+ /** Padding around the plot area. */
307
+ padding?: {
308
+ top?: number;
309
+ right?: number;
310
+ bottom?: number;
311
+ left?: number;
312
+ inner?: number;
313
+ };
314
+ /** Crosshair configuration. */
315
+ crosshair?: {
316
+ x?: boolean;
317
+ y?: boolean;
318
+ };
319
+ /** Tooltip configuration. */
320
+ tooltip?: TooltipOptions;
321
+ /** Show the export toolbar in the top-right corner. */
322
+ showExport?: boolean;
323
+ /** Additional class name applied to the container. */
324
+ className?: string;
325
+ /** Inline style applied to the container. */
326
+ style?: React.CSSProperties;
327
+ /** Access the imperative chart handle (e.g. exportToPng). */
328
+ chartRef?: React.Ref<RadiantChartHandle>;
329
+ /** Declarative series, axis, title, legend, and annotation children. */
330
+ children?: React.ReactNode;
331
+ }
332
+ declare const Chart: React.FC<ChartProps>;
333
+ /** Shared props accepted by every series component. */
334
+ interface CommonSeriesProps {
335
+ xKey?: string;
336
+ yKey?: string;
337
+ fill?: string;
338
+ stroke?: string;
339
+ strokeWidth?: number;
340
+ fillOpacity?: number;
341
+ cornerRadius?: number;
342
+ title?: string;
343
+ grouped?: boolean;
344
+ stacked?: boolean;
345
+ normalized?: boolean;
346
+ direction?: 'vertical' | 'horizontal';
347
+ interpolation?: 'linear' | 'step' | 'smooth';
348
+ marker?: {
349
+ enabled?: boolean;
350
+ size?: number;
351
+ fill?: string;
352
+ };
353
+ labels?: DataLabelOptions;
354
+ animation?: AnimationOptions;
355
+ yAxisId?: 'left' | 'right';
356
+ /** Any additional props are forwarded verbatim to the engine. */
357
+ [key: string]: any;
358
+ }
359
+ declare const Bar: React.FC<CommonSeriesProps>;
360
+ declare const Line: React.FC<CommonSeriesProps>;
361
+ declare const Area: React.FC<CommonSeriesProps>;
362
+ declare const Scatter: React.FC<CommonSeriesProps>;
363
+ declare const Pie: React.FC<CommonSeriesProps>;
364
+ declare const Donut: React.FC<CommonSeriesProps>;
365
+ interface AxisProps {
366
+ /** Show or hide this axis. Default: true. */
367
+ show?: boolean;
368
+ /** Font size for axis labels in px. */
369
+ fontSize?: number;
370
+ /** Font family for axis labels. */
371
+ fontFamily?: string;
372
+ /** Label rotation in degrees. */
373
+ rotation?: number;
374
+ /** Label alignment. */
375
+ labelAlignment?: 'start' | 'center' | 'end';
376
+ }
377
+ declare const XAxis: React.FC<AxisProps>;
378
+ declare const YAxis: React.FC<AxisProps>;
379
+ declare const YAxisRight: React.FC<AxisProps>;
380
+ interface TitleProps {
381
+ text: string;
382
+ fontSize?: number;
383
+ fill?: string;
384
+ }
385
+ declare const Title: React.FC<TitleProps>;
386
+ declare const Subtitle: React.FC<TitleProps>;
387
+ interface LegendProps {
388
+ /** Show or hide the legend. Default: true. */
389
+ enabled?: boolean;
390
+ /** Legend placement. */
391
+ position?: 'top' | 'bottom' | 'left' | 'right';
392
+ }
393
+ declare const Legend: React.FC<LegendProps>;
394
+ interface TooltipProps extends TooltipOptions {
395
+ }
396
+ /**
397
+ * Configure the tooltip system declaratively as a child of `<Chart>`.
398
+ * This is a config-only component — it renders nothing.
399
+ * Props are passed through to the chart's tooltip options.
400
+ *
401
+ * @example
402
+ * <Chart data={data}>
403
+ * <Tooltip
404
+ * mode="shared"
405
+ * snap
406
+ * sticky
407
+ * bulletShape="circle"
408
+ * bodyTemplate="Revenue: ${revenue}"
409
+ * footerTemplate="Source: ${source}"
410
+ * style={{ background: '#1a1a2e', borderRadius: 12 }}
411
+ * />
412
+ * <Bar xKey="month" yKey="sales" />
413
+ * </Chart>
414
+ */
415
+ declare const Tooltip: React.FC<TooltipProps>;
416
+
417
+ interface ChartTooltipContext {
418
+ active: boolean;
419
+ entries: TooltipDatumEntry[];
420
+ sharedLabel: string | null;
421
+ pointerX: number;
422
+ pointerY: number;
423
+ anchorX: number;
424
+ anchorY: number;
425
+ localX: number;
426
+ localY: number;
427
+ hide: () => void;
428
+ }
429
+ declare function useChartTooltip(): ChartTooltipContext;
430
+
431
+ export { type AnimationOptions, Area, type AxisProps, Bar, Chart, type ChartProps, type ChartTooltipContext, type DataLabelOptions, Donut, type DropShadow, Legend, type LegendProps, Line, type MarkerOptions, type MarkerShape, Pie, RadiantChart, type RadiantChartHandle, type RadiantChartOptions, ResponsiveContainer, Scatter, Subtitle, Title, type TitleProps, Tooltip, type TooltipDatumEntry, type TooltipMode, type TooltipOptions, type TooltipPositionMode, type TooltipProps, type TooltipState, type TooltipTrigger, XAxis, YAxis, YAxisRight, useChartTooltip };
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";var re=Object.create;var yt=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,he=Object.prototype.hasOwnProperty;var de=(h,t)=>{for(var e in t)yt(h,e,{get:t[e],enumerable:!0})},Ft=(h,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of oe(t))!he.call(h,s)&&s!==e&&yt(h,s,{get:()=>t[s],enumerable:!(i=ae(t,s))||i.enumerable});return h};var Lt=(h,t,e)=>(e=h!=null?re(le(h)):{},Ft(t||!h||!h.__esModule?yt(e,"default",{value:h,enumerable:!0}):e,h)),ce=h=>Ft(yt({},"__esModule",{value:!0}),h);var ve={};de(ve,{Area:()=>te,Bar:()=>Jt,Chart:()=>Vt,Donut:()=>se,Legend:()=>Xt,Line:()=>Zt,Pie:()=>ie,RadiantChart:()=>Tt,ResponsiveContainer:()=>jt,Scatter:()=>ee,Subtitle:()=>Et,Title:()=>zt,Tooltip:()=>Ct,XAxis:()=>Dt,YAxis:()=>Kt,YAxisRight:()=>It,useChartTooltip:()=>ne});module.exports=ce(ve);var M=Lt(require("react"));var $=class{constructor(){this.id=Math.random().toString(36).substr(2,9);this.x=0;this.y=0;this.visible=!0;this.opacity=1;this.translation={x:0,y:0};this.rotation=0;this.scaling={x:1,y:1};this.parent=null;this.children=[];this.pointerEvents=!0;this.clipRect=null;this.datum=null;this.seriesId="";this.shadow=null}add(t){t.parent&&t.parent.remove(t),t.parent=this,this.children.push(t)}remove(t){let e=this.children.indexOf(t);e!==-1&&(this.children.splice(e,1),t.parent=null)}clear(){this.children.forEach(t=>t.parent=null),this.children=[]}render(t){if(!this.visible||this.opacity===0)return;let e=this.translation.x!==0||this.translation.y!==0||this.rotation!==0||this.scaling.x!==1||this.scaling.y!==1,i=this.shadow!==null,s=this.opacity!==1||this.clipRect!==null||i;if(!e&&!s){this.renderShape(t);for(let n of this.children)n.render(t);return}t.save(),(this.translation.x!==0||this.translation.y!==0)&&t.translate(this.translation.x,this.translation.y),this.rotation!==0&&t.rotate(this.rotation),(this.scaling.x!==1||this.scaling.y!==1)&&t.scale(this.scaling.x,this.scaling.y),this.opacity!==1&&(t.globalAlpha*=this.opacity),this.clipRect&&(t.beginPath(),t.rect(this.clipRect.x,this.clipRect.y,this.clipRect.width,this.clipRect.height),t.clip()),this.shadow&&(t.shadowColor=this.shadow.color??"rgba(0,0,0,0.25)",t.shadowBlur=this.shadow.blur??4,t.shadowOffsetX=this.shadow.offsetX??0,t.shadowOffsetY=this.shadow.offsetY??2),this.renderShape(t),this.shadow&&(t.shadowColor="rgba(0,0,0,0)",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0);for(let n of this.children)n.render(t);t.restore()}pickNode(t,e){if(!this.visible||!this.pointerEvents)return null;let i=(t-this.translation.x)/this.scaling.x,s=(e-this.translation.y)/this.scaling.y;for(let n=this.children.length-1;n>=0;n--){let r=this.children[n].pickNode(i,s);if(r)return r}return this.isPointInNode(i,s)?this:null}};var K=class extends ${renderShape(t){}isPointInNode(t,e){return!1}getBBox(){if(this.children.length===0)return{x:0,y:0,width:0,height:0};let t=1/0,e=1/0,i=-1/0,s=-1/0;for(let n of this.children){let r=n.getBBox();t=Math.min(t,r.x+n.translation.x),e=Math.min(e,r.y+n.translation.y),i=Math.max(i,r.x+r.width+n.translation.x),s=Math.max(s,r.y+r.height+n.translation.y)}return{x:t,y:e,width:i-t,height:s-e}}},j=class extends ${constructor(){super(...arguments);this.width=0;this.height=0;this.fill="transparent";this.stroke="transparent";this.strokeWidth=1;this.cornerRadius=0;this.lineDash=[]}renderShape(e){if(!(this.width<=0||this.height<=0)){if(e.beginPath(),this.cornerRadius>0){let i=Math.min(this.cornerRadius,this.width/2,this.height/2);e.moveTo(this.x+i,this.y),e.arcTo(this.x+this.width,this.y,this.x+this.width,this.y+this.height,i),e.arcTo(this.x+this.width,this.y+this.height,this.x,this.y+this.height,i),e.arcTo(this.x,this.y+this.height,this.x,this.y,i),e.arcTo(this.x,this.y,this.x+this.width,this.y,i)}else e.rect(this.x,this.y,this.width,this.height);e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,this.lineDash.length>0&&e.setLineDash(this.lineDash),e.stroke(),this.lineDash.length>0&&e.setLineDash([]))}}isPointInNode(e,i){let s=Math.min(this.x,this.x+this.width),n=Math.max(this.x,this.x+this.width),r=Math.min(this.y,this.y+this.height),o=Math.max(this.y,this.y+this.height);return e>=s&&e<=n&&i>=r&&i<=o}getBBox(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},U=class extends ${constructor(){super(...arguments);this.x1=0;this.y1=0;this.x2=0;this.y2=0;this.stroke="black";this.strokeWidth=1}renderShape(e){e.save(),this.lineDash&&e.setLineDash(this.lineDash),e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.beginPath(),e.moveTo(this.x1,this.y1),e.lineTo(this.x2,this.y2),e.stroke(),e.restore()}isPointInNode(e,i){return!1}getBBox(){return{x:Math.min(this.x1,this.x2),y:Math.min(this.y1,this.y2),width:Math.abs(this.x2-this.x1),height:Math.abs(this.y2-this.y1)}}},ht=class extends ${constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.radius=5;this.fill="blue";this.stroke="transparent";this.strokeWidth=1}renderShape(e){e.beginPath(),e.arc(this.centerX,this.centerY,this.radius,0,Math.PI*2),e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY;return s*s+n*n<=this.radius*this.radius}getBBox(){return{x:this.centerX-this.radius,y:this.centerY-this.radius,width:this.radius*2,height:this.radius*2}}},at=class extends ${constructor(){super(...arguments);this.pathData=[];this.fill="transparent";this.stroke="transparent";this.strokeWidth=1;this.closed=!1;this.lineDashOffset=0}renderShape(e){if(this.pathData.length!==0){e.save(),this.lineDash&&(e.setLineDash(this.lineDash),e.lineDashOffset=this.lineDashOffset),e.beginPath();for(let i of this.pathData)i.command==="M"?e.moveTo(i.x,i.y):i.command==="L"?e.lineTo(i.x,i.y):i.command==="C"&&i.cp1x!==void 0&&i.cp2x!==void 0&&e.bezierCurveTo(i.cp1x,i.cp1y,i.cp2x,i.cp2y,i.x,i.y);this.closed&&e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke()),e.restore()}}isPointInNode(e,i){return!1}getBBox(){if(this.pathData.length===0)return{x:0,y:0,width:0,height:0};let e=1/0,i=1/0,s=-1/0,n=-1/0;for(let r of this.pathData)e=Math.min(e,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),n=Math.max(n,r.y),r.cp1x!==void 0&&(e=Math.min(e,r.cp1x,r.cp2x),i=Math.min(i,r.cp1y,r.cp2y),s=Math.max(s,r.cp1x,r.cp2x),n=Math.max(n,r.cp1y,r.cp2y));return{x:e,y:i,width:s-e,height:n-i}}},et=class extends ${constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.radius=5;this.fill="blue";this.stroke="transparent";this.strokeWidth=1;this.shape="circle"}renderShape(e){let i=this.centerX,s=this.centerY,n=this.radius;if(!(n<=0)){switch(e.beginPath(),this.shape){case"circle":e.arc(i,s,n,0,Math.PI*2),e.closePath();break;case"square":e.rect(i-n,s-n,n*2,n*2),e.closePath();break;case"diamond":e.moveTo(i,s-n),e.lineTo(i+n,s),e.lineTo(i,s+n),e.lineTo(i-n,s),e.closePath();break;case"triangle":e.moveTo(i,s-n),e.lineTo(i+n*.866,s+n*.5),e.lineTo(i-n*.866,s+n*.5),e.closePath();break;case"cross":{let r=n*.4;e.moveTo(i-n,s-n+r),e.lineTo(i-n+r,s-n),e.lineTo(i,s-r),e.lineTo(i+n-r,s-n),e.lineTo(i+n,s-n+r),e.lineTo(i+r,s),e.lineTo(i+n,s+n-r),e.lineTo(i+n-r,s+n),e.lineTo(i,s+r),e.lineTo(i-n+r,s+n),e.lineTo(i-n,s+n-r),e.lineTo(i-r,s),e.closePath();break}case"plus":{let r=n*.4;e.moveTo(i-r,s-n),e.lineTo(i+r,s-n),e.lineTo(i+r,s-r),e.lineTo(i+n,s-r),e.lineTo(i+n,s+r),e.lineTo(i+r,s+r),e.lineTo(i+r,s+n),e.lineTo(i-r,s+n),e.lineTo(i-r,s+r),e.lineTo(i-n,s+r),e.lineTo(i-n,s-r),e.lineTo(i-r,s-r),e.closePath();break}}this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY;return Math.abs(s)<=this.radius&&Math.abs(n)<=this.radius}getBBox(){return{x:this.centerX-this.radius,y:this.centerY-this.radius,width:this.radius*2,height:this.radius*2}}},bt=class extends ${constructor(){super(...arguments);this.centerX=0;this.centerY=0;this.innerRadius=0;this.outerRadius=0;this.startAngle=0;this.endAngle=0;this.fill="blue";this.stroke="transparent";this.strokeWidth=1}renderShape(e){e.beginPath(),e.arc(this.centerX,this.centerY,this.outerRadius,this.startAngle,this.endAngle),this.innerRadius>0?e.arc(this.centerX,this.centerY,this.innerRadius,this.endAngle,this.startAngle,!0):e.lineTo(this.centerX,this.centerY),e.closePath(),this.fill!=="transparent"&&(e.fillStyle=this.fill,e.fill()),this.stroke!=="transparent"&&this.strokeWidth>0&&(e.strokeStyle=this.stroke,e.lineWidth=this.strokeWidth,e.stroke())}isPointInNode(e,i){let s=e-this.centerX,n=i-this.centerY,r=Math.sqrt(s*s+n*n);if(r<this.innerRadius||r>this.outerRadius)return!1;let o=Math.atan2(n,s);o<0&&(o+=Math.PI*2);let l=this.startAngle%(Math.PI*2);l<0&&(l+=Math.PI*2);let y=this.endAngle%(Math.PI*2);return y<0&&(y+=Math.PI*2),l<y?o>=l&&o<=y:o>=l||o<=y}getBBox(){return{x:this.centerX-this.outerRadius,y:this.centerY-this.outerRadius,width:this.outerRadius*2,height:this.outerRadius*2}}},z=class extends ${constructor(){super(...arguments);this.text="";this.fontSize=12;this.fontFamily="sans-serif";this.fontWeight="normal";this.fill="black";this.textAlign="start";this.textBaseline="alphabetic"}renderShape(e){e.font=`${this.fontWeight} ${this.fontSize}px ${this.fontFamily}`,e.fillStyle=this.fill,e.textAlign=this.textAlign,e.textBaseline=this.textBaseline,this.shadowColor&&(e.shadowColor=this.shadowColor),this.shadowBlur!==void 0&&(e.shadowBlur=this.shadowBlur),this.maxWidth!==void 0&&this.maxWidth>0?e.fillText(this.text,this.x,this.y,this.maxWidth):e.fillText(this.text,this.x,this.y),this.shadowColor&&(e.shadowColor="transparent"),this.shadowBlur!==void 0&&(e.shadowBlur=0)}isPointInNode(e,i){return!1}getBBox(){return{x:this.x,y:this.y-this.fontSize,width:this.text.length*(this.fontSize*.55),height:this.fontSize}}};var xt=class{constructor(t){this.root=new K;this.width=0;this.height=0;this.pixelRatio=1;this._longPressTimer=null;this._longPressFired=!1;this.backgroundColor="";this.container=t,this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.top="0",this.canvas.style.left="0",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.display="block",this.canvas.style.zIndex="1",t.appendChild(this.canvas);let e=this.canvas.getContext("2d");if(!e)throw new Error("Could not get Canvas 2D context");this.ctx=e,this.resize(),this.setupEvents()}setupEvents(){this.canvas.addEventListener("mousemove",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onHover&&this.onHover(n,t)}),this.canvas.addEventListener("mouseleave",t=>{this.onHover&&this.onHover(null,t)}),this.canvas.addEventListener("click",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onClick&&this.onClick(n,t)}),this.canvas.addEventListener("dblclick",t=>{let e=this.canvas.getBoundingClientRect(),i=t.clientX-e.left,s=t.clientY-e.top,n=this.root.pickNode(i,s);this.onDblClick&&this.onDblClick(n,t)}),this.canvas.addEventListener("touchstart",t=>{if(t.touches.length!==1)return;let e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY});this.onHover&&this.onHover(r,o),this._longPressFired=!1,this._longPressTimer&&clearTimeout(this._longPressTimer),this._longPressTimer=setTimeout(()=>{this._longPressFired=!0;let l=new MouseEvent("click",{clientX:e.clientX,clientY:e.clientY});this.onLongPress&&this.onLongPress(r,l)},500)},{passive:!0}),this.canvas.addEventListener("touchend",t=>{if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),t.changedTouches.length!==1)return;if(this._longPressFired){this._longPressFired=!1;return}let e=t.changedTouches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("click",{clientX:e.clientX,clientY:e.clientY});this.onClick&&this.onClick(r,o)},{passive:!0}),this.canvas.addEventListener("touchmove",t=>{if(this._longPressTimer&&(clearTimeout(this._longPressTimer),this._longPressTimer=null),t.touches.length!==1)return;let e=t.touches[0],i=this.canvas.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.root.pickNode(s,n),o=new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY});this.onHover&&this.onHover(r,o)},{passive:!0})}resize(){let t=this.container.getBoundingClientRect();this.width=t.width,this.height=t.height,!(this.width===0||this.height===0)&&(this.pixelRatio=window.devicePixelRatio||1,this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.resetTransform(),this.ctx.scale(this.pixelRatio,this.pixelRatio),this.render())}render(){this.width===0||this.height===0||(this.ctx.clearRect(0,0,this.width,this.height),this.backgroundColor&&(this.ctx.fillStyle=this.backgroundColor,this.ctx.fillRect(0,0,this.width,this.height)),this.root.render(this.ctx))}getCanvas(){return this.canvas}getContext(){return this.ctx}destroy(){this._longPressTimer&&clearTimeout(this._longPressTimer),this.canvas.remove()}};var it=class{constructor(){this.domain=[0,1];this.range=[0,1]}convert(t){let[e,i]=this.domain,[s,n]=this.range;return i===e?s:s+(t-e)/(i-e)*(n-s)}invert(t){let[e,i]=this.domain,[s,n]=this.range;return n===s?e:e+(t-s)/(n-s)*(i-e)}ticks(t=5){let[e,i]=this.domain,s=(i-e)/t,n=Math.pow(10,Math.floor(Math.log10(s))),r=s/n,o;r<1.5?o=1:r<3?o=2:r<7?o=5:o=10;let l=o*n,y=Math.ceil(e/l)*l,u=Math.floor(i/l)*l,x=[];for(let c=y;c<=u;c+=l)x.push(c);return x}},st=class{constructor(){this.domain=[];this.range=[0,1];this.padding=.1}convert(t){let e=this.domain.indexOf(t);if(e===-1)return 0;let[i,s]=this.range,n=(s-i)/this.domain.length;return i+e*n+n*this.padding/2}invert(t){let[e,i]=this.range,s=(i-e)/this.domain.length,n=Math.floor((t-e)/s);return this.domain[n]||""}getBandwidth(){let[t,e]=this.range,i=(e-t)/this.domain.length;return Math.abs(i*(1-this.padding))}ticks(){return this.domain}};function V(h){return typeof h.getBandwidth=="function"?h.getBandwidth():0}function tt(h){if(h instanceof Date)return`${h.getMonth()+1}/${h.getDate()}/${String(h.getFullYear()).slice(-2)}`;if(typeof h!="number")return String(h);let t=Math.abs(h);if(t>1e11&&t<1e14){let e=new Date(h);if(!isNaN(e.getTime()))return`${e.getMonth()+1}/${e.getDate()}/${String(e.getFullYear()).slice(-2)}`}return t>=1e9?(h/1e9).toFixed(1).replace(/\.0$/,"")+"B":t>=1e6?(h/1e6).toFixed(1).replace(/\.0$/,"")+"M":t>=1e3?(h/1e3).toFixed(1).replace(/\.0$/,"")+"K":h%1!==0?t>0&&t<1?Number(h.toPrecision(3)).toString():h.toFixed(1):String(h)}var nt=class{constructor(t,e){this.group=new K;this.theme=null;this._measuredLabelMaxW=0;this._layoutMaxWidth=0;this.scale=t,this.options=e}setLayoutMaxWidth(t){this._layoutMaxWidth=t}getGroup(){return this.group}setTheme(t){this.theme=t}updateOptions(t){this.options={...this.options,...t}}getRequiredSpace(t){let{position:e,rotation:i=0}=this.options,s=this.options.fontFamily||this.theme?.fontFamily||"sans-serif",n=this.options.fontSize??10,r=this.options.tickLength??4,o=this.options.labelGap??2,l=this._tickCount,y=this._labelFormatter,u=this.scale.ticks?this.scale.ticks(l):[];t.font=`${n}px ${s}`;let x=i*Math.PI/180,c=Math.abs(Math.cos(x)),m=Math.abs(Math.sin(x));if(e==="bottom"||e==="top"){let b=n;if(i!==0)for(let p=0;p<u.length;p++){let S=u[p],w=y?y({value:S,index:p}):tt(S),g=t.measureText(w).width*m+n*c;g>b&&(b=g)}let k=r+o+b+4;return this.options.title&&(k+=18),{size:Math.ceil(k)}}let a=0;for(let b=0;b<u.length;b++){let k=u[b],p=y?y({value:k,index:b}):tt(k),S=t.measureText(p).width,w=i!==0?S*c+n*m:S;w>a&&(a=w)}this._measuredLabelMaxW=Math.ceil(a);let f=o+this._measuredLabelMaxW+8;return this.options.title&&(f+=22),u.length>0&&(f=Math.max(f,32)),{size:Math.ceil(f)}}update(t,e=0,i=!0,s=0,n=0){this.group.clear();let{position:r,rotation:o=0}=this.options,l=this.theme?.subtextColor??"#6b7280",y=this.theme?.gridColor??"rgba(107,114,128,0.12)",u=this.theme?.axisColor??"#d1d5db",x=this.options.fontFamily||this.theme?.fontFamily||"sans-serif",c=this.options.fontSize??10,m=this.options.tickLength??4,a=this.options.labelGap??2;if(r==="bottom"||r==="top"?this.scale.range=[s,t-s]:this.scale.range=[t-s,s],!i)return;if(r==="bottom"||r==="top"){let v=new U;v.x1=0,v.y1=0,v.x2=t,v.y2=0,v.stroke=u,v.strokeWidth=1,this.group.add(v)}let f=this._tickCount,b=this._labelFormatter,k=this._gridStyle,p=this.scale.ticks?this.scale.ticks(f):[],S=this.options.gridLines!==!1,{labelAlignment:w="center"}=this.options,d=this.scale.getBandwidth?.bind(this.scale),g=r==="bottom"||r==="top",C=r==="left"||r==="right",A=c*.5,R=g?-1/0:1/0;if(p.forEach((v,B)=>{let _=this.scale.convert(v);if(d){let Y=d(),[X,O]=this.scale.range,G=O>=X?1:-1;w==="center"?_+=G*Y/2:w==="end"&&(_+=G*Y)}let D=b?b({value:v,index:B}):tt(v);if(g&&o===0){let Y=c*.6*D.length;if(_-Y/2<R+A){if(r==="bottom"){let O=new U;O.x1=_,O.y1=0,O.x2=_,O.y2=m,O.stroke=u,O.strokeWidth=1,this.group.add(O)}return}R=_+Y/2}if(C){if(Math.abs(_-R)<c+2)return;R=_}let T=new z;T.text=D,T.fontSize=c,T.fill=l,T.fontFamily=x;let L=o*Math.PI/180;if(T.rotation=L,r==="bottom"){let Y=new U;Y.x1=_,Y.y1=0,Y.x2=_,Y.y2=m,Y.stroke=u,Y.strokeWidth=1,this.group.add(Y),T.translation={x:_,y:m+a},T.x=0,T.y=0,o===0?(T.textAlign="center",T.textBaseline="top"):(T.textAlign=o>0?"left":"right",T.textBaseline="middle"),this.group.add(T)}else if(r==="left"||r==="right"){let Y=r==="right",X=Y?1:-1;if(T.textAlign=Y?"left":"right",T.textBaseline="middle",T.maxWidth=this._layoutMaxWidth>0?this._layoutMaxWidth-a-8:void 0,T.translation={x:X*a,y:_},T.x=0,T.y=0,this.group.add(T),S&&e>0&&r==="left"){let O=new U;O.x1=n,O.y1=_,O.x2=e,O.y2=_;let G=k&&k.length>0?k[B%k.length]:void 0;O.stroke=G?.stroke??y,O.strokeWidth=1,O.lineDash=G?.lineDash?[...G.lineDash]:[4,6],this.group.add(O)}}}),this.options.title){let v=new z;v.text=this.options.title,v.fontSize=11,v.fill=l,v.fontFamily=x,r==="bottom"?(v.x=t/2,v.y=m+a+this._measuredLabelMaxW+12,v.textAlign="center"):r==="left"?(v.x=-(a+(this._layoutMaxWidth||this._measuredLabelMaxW)+14),v.y=t/2,v.rotation=-Math.PI/2,v.textAlign="center"):r==="right"&&(v.x=a+(this._layoutMaxWidth||this._measuredLabelMaxW)+14,v.y=t/2,v.rotation=Math.PI/2,v.textAlign="center"),this.group.add(v)}}};function ue(){return typeof window>"u"?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}var I=class I{constructor(t){this.startTime=0;this.requestId=null;this.loop=()=>{let t=performance.now(),e=Math.min((t-this.startTime)/this.duration,1);this.onUpdate(this.easing(e)),e<1?this.requestId=requestAnimationFrame(this.loop):(this.requestId=null,this.onComplete?.())};this.duration=t.duration??420,this.easing=t.easing??I.easeOutQuart,this.onUpdate=t.onUpdate,this.onComplete=t.onComplete}static getEasing(t){switch(t){case"linear":return I.linear;case"easeIn":return I.easeInQuad;case"easeOut":return I.easeOutQuad;case"easeInOut":return I.easeInOutQuad;case"easeInCubic":return I.easeInCubic;case"easeOutCubic":return I.easeOutCubic;case"easeInOutCubic":return I.easeInOutCubic;case"easeInQuart":return I.easeInQuart;case"easeOutQuart":return I.easeOutQuart;case"easeInOutQuart":return I.easeInOutQuart;case"bounce":return I.easeOutBounce;case"elastic":return I.easeOutElastic;case"back":return I.easeOutBack;default:return I.easeOutQuart}}start(){if(this.stop(),ue()){this.onUpdate(1),this.onComplete?.();return}this.startTime=performance.now(),this.loop()}stop(){this.requestId!==null&&(cancelAnimationFrame(this.requestId),this.requestId=null)}};I.linear=t=>t,I.easeInQuad=t=>t*t,I.easeOutQuad=t=>t*(2-t),I.easeInOutQuad=t=>t<.5?2*t*t:-1+(4-2*t)*t,I.easeInCubic=t=>t*t*t,I.easeOutCubic=t=>--t*t*t+1,I.easeInOutCubic=t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,I.easeInQuart=t=>t*t*t*t,I.easeOutQuart=t=>1- --t*t*t*t,I.easeInOutQuart=t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t,I.easeOutBack=t=>1+2.70158*Math.pow(t-1,3)+1.70158*Math.pow(t-1,2),I.easeOutBounce=t=>t<1/2.75?7.5625*t*t:t<2/2.75?7.5625*(t-=1.5/2.75)*t+.75:t<2.5/2.75?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,I.easeOutElastic=t=>{let e=2*Math.PI/3;return t===0?0:t===1?1:Math.pow(2,-10*t)*Math.sin((t*10-.75)*e)+1};var W=I;var Yt=class extends ${constructor(){super(...arguments);this.bars=[];this.fill="";this.stroke="transparent";this.cornerRadius=0}renderShape(e){if(this.bars.length!==0){e.fillStyle=this.fill,e.beginPath();for(let i of this.bars)if(this.cornerRadius>0&&i.width>8&&i.height>8){let s=Math.min(this.cornerRadius,i.width/2,i.height/2);e.moveTo(i.x+s,i.y),e.arcTo(i.x+i.width,i.y,i.x+i.width,i.y+i.height,s),e.arcTo(i.x+i.width,i.y+i.height,i.x,i.y+i.height,s),e.arcTo(i.x,i.y+i.height,i.x,i.y,s),e.arcTo(i.x,i.y,i.x+i.width,i.y,s)}else e.rect(i.x,i.y,i.width,i.height);e.fill(),this.stroke!=="transparent"&&(e.strokeStyle=this.stroke,e.stroke())}}isPointInNode(e,i){for(let s=this.bars.length-1;s>=0;s--){let n=this.bars[s];if(e>=n.x&&e<=n.x+n.width&&i>=n.y&&i<=n.y+n.height)return this.datum=n.datum,!0}return!1}getBBox(){return this.bars.length===0?{x:0,y:0,width:0,height:0}:{x:0,y:0,width:1e3,height:1e3}}},pt=class{constructor(t){this.group=new K;this.fill="#4e79a7";this.stroke="transparent";this.grouped=!1;this.stacked=!1;this.normalized=!1;this.direction="vertical";this.cornerRadius=3;this.batchNode=null;this.bars=[];this.xKey=t.xKey,this.yKey=t.yKey,this.grouped=t.grouped??!1,this.stacked=t.stacked??!1,this.normalized=t.normalized??!1,this.direction=t.direction??"vertical",this.cornerRadius=t.cornerRadius??3,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke)}getGroup(){return this.group}update(t,e,i,s,n=!0,r=0,o=1,l,y,u){u&&(this.xKey=u.xKey,this.yKey=u.yKey,u.fill&&(this.fill=u.fill),u.stroke&&(this.stroke=u.stroke),u.grouped!==void 0&&(this.grouped=u.grouped),u.stacked!==void 0&&(this.stacked=u.stacked),u.normalized!==void 0&&(this.normalized=u.normalized),u.direction!==void 0&&(this.direction=u.direction),u.cornerRadius!==void 0&&(this.cornerRadius=u.cornerRadius),u.labels&&(this.labelsOpts=u.labels),u.animation&&(this.animationOpts=u.animation),u.shadow!==void 0&&(this.shadowOpts=u.shadow));let x=this.bars.length===0,c=this.direction==="horizontal",m=this.animationOpts?.type||"grow",a=this.bars.length,f=t.length;if(f>1e3){this.group.clear(),this.bars=[],this.batchNode||(this.batchNode=new Yt),this.batchNode.fill=this.fill,this.batchNode.stroke=this.stroke,this.batchNode.cornerRadius=this.cornerRadius,this.batchNode.seriesId=this.yKey,this.batchNode.shadow=this.shadowOpts??null,this.group.add(this.batchNode);let p=[];if(t.forEach((S,w)=>{let d=S[this.yKey];this.normalized&&y&&y[w]&&(d=d/y[w]*100);let g=V(e);if(c){let C=e.convert(S[this.xKey]),A=g;this.grouped&&o>1&&(A=g/o,C+=r*A);let R=i.convert(this.stacked&&l?l[w]??0:0),v=i.convert((this.stacked&&l?l[w]??0:0)+d)-R;p.push({x:R,y:C,width:v,height:A,datum:S})}else{let C=e.convert(S[this.xKey]),A=g;this.grouped&&o>1&&(A=g/o,C+=r*A);let R=i.convert((this.stacked&&l?l[w]??0:0)+d),v=i.convert(this.stacked&&l?l[w]??0:0)-R;p.push({x:C,y:R,width:A,height:v,datum:S})}}),this.batchNode.bars=p,this.labelsOpts?.enabled){let S=Math.max(1,Math.ceil(f/100));for(let w=0;w<p.length;w+=S){let d=p[w],g=new j;g.x=d.x,g.y=d.y,g.width=d.width,g.height=d.height;let C=new z;this.group.add(C),this.placeLabel(C,g,d.datum[this.yKey])}}return}this.batchNode&&(this.group.remove(this.batchNode),this.batchNode=null);let k=[];if(t.forEach((p,S)=>{let w=p[this.yKey];this.normalized&&y&&y[S]&&(w=w/y[S]*100);let d=V(e),g,C,A,R;if(c){let v=e.convert(p[this.xKey]),B=d;if(this.grouped&&o>1&&(B=d/o,v+=r*B),C=v,R=B,this.stacked&&l){let _=l[S]??0;g=i.convert(_),A=i.convert(_+w)-g}else g=i.convert(0),A=i.convert(w)-g}else{let v=e.convert(p[this.xKey]),B=d;if(this.grouped&&o>1&&(B=d/o,v+=r*B),g=v,A=B,this.stacked&&l){let _=l[S]??0,D=this.normalized&&y?.[S]?_/y[S]*100:_;C=i.convert(D+w),R=i.convert(D)-C}else C=i.convert(w),R=i.convert(0)-C}k.push({datum:p,rawY:p[this.yKey],tx:g,ty:C,tw:A,th:R})}),f<a){for(let p=f;p<a;p++){let S=this.bars[p];this.group.remove(S.rect),S.label&&this.group.remove(S.label)}this.bars.length=f}for(let p=0;p<f;p++){let{datum:S,rawY:w,tx:d,ty:g,tw:C,th:A}=k[p],R,v,B,_,D,T,L=1,Y=1,X=1,O=1,G=1,rt=1;if(p<a){let N=this.bars[p];R=N.rect,v=N.label,B=R.x,_=R.y,D=R.width,T=R.height,L=R.opacity,X=R.scaling.x,G=R.scaling.y}else R=new j,this.group.add(R),B=d,_=g,D=C,T=A,m==="grow"?c?(B=0,D=0):(_=s.height,T=0):m==="fade"?L=0:m==="slide"?c?B=-50:_=s.height+50:m==="pop"&&(X=0,G=0),this.labelsOpts?.enabled&&(v=new z,this.group.add(v));R.fill=this.fill,R.stroke=this.stroke,R.cornerRadius=this.cornerRadius,R.datum=S,R.seriesId=this.yKey,R.opacity=L,R.scaling={x:X,y:G},R.shadow=this.shadowOpts??null;let J=d,Z=g;m==="pop"?(R.translation={x:d+C/2,y:g+A/2},J=-C/2,Z=-A/2,B=-C/2,_=-A/2):R.translation={x:0,y:0};let q={rect:R,label:v,rawY:w,targetY:Z,targetHeight:A,startY:_,startHeight:T,targetX:J,targetWidth:C,startX:B,startWidth:D,targetOpacity:Y,startOpacity:L,targetScaleX:O,startScaleX:X,targetScaleY:rt,startScaleY:G};p<a?this.bars[p]=q:this.bars.push(q)}if(n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let p=this.animationOpts?.duration??500,S=W.getEasing(this.animationOpts?.easing);this.animator=new W({duration:p,easing:S,onUpdate:w=>{this.bars.forEach(d=>{d.rect.y=d.startY+(d.targetY-d.startY)*w,d.rect.height=d.startHeight+(d.targetHeight-d.startHeight)*w,d.rect.x=d.startX+(d.targetX-d.startX)*w,d.rect.width=d.startWidth+(d.targetWidth-d.startWidth)*w,d.rect.opacity=d.startOpacity+(d.targetOpacity-d.startOpacity)*w,d.rect.scaling={x:d.startScaleX+(d.targetScaleX-d.startScaleX)*w,y:d.startScaleY+(d.targetScaleY-d.startScaleY)*w},d.label&&this.placeLabel(d.label,d.rect,d.rawY)})}}),this.animator.start()}else this.bars.forEach(p=>{p.rect.y=p.targetY,p.rect.height=p.targetHeight,p.rect.x=p.targetX,p.rect.width=p.targetWidth,p.rect.opacity=p.targetOpacity,p.rect.scaling={x:p.targetScaleX,y:p.targetScaleY},p.label&&this.placeLabel(p.label,p.rect,p.rawY)})}placeLabel(t,e,i){let s=this.labelsOpts?.position||"inside",n=this.direction==="horizontal",r=String(i);if(typeof i=="number"){let y=Math.abs(i);y>=1e9?r=(i/1e9).toFixed(1).replace(/\.0$/,"")+"B":y>=1e6?r=(i/1e6).toFixed(1).replace(/\.0$/,"")+"M":y>=1e3?r=(i/1e3).toFixed(1).replace(/\.0$/,"")+"K":r=i.toLocaleString()}t.text=r,t.fontSize=this.labelsOpts?.fontSize||10,t.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",t.fontWeight=this.labelsOpts?.fontWeight||"600",t.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,t.fill=this.labelsOpts?.fill||(s==="inside"||s==="center"?"#fff":"#6b7280"),t.textAlign="center",t.textBaseline="middle";let o=0,l=0;n?(l=e.y+e.height/2,s==="inside"?(o=e.x+e.width-12,t.textAlign="right"):s==="right"||s==="outside"?(o=e.x+e.width+6,t.textAlign="left",t.fill=this.labelsOpts?.fill||"#6b7280"):s==="center"?o=e.x+e.width/2:s==="left"&&(o=e.x+8,t.textAlign="left")):(o=e.x+e.width/2,s==="inside"?l=e.y+12:s==="top"||s==="outside"?(l=e.y-8,t.textBaseline="bottom",t.fill=this.labelsOpts?.fill||"#6b7280"):s==="center"?l=e.y+e.height/2:s==="bottom"&&(l=e.y+e.height-10)),t.translation={x:o,y:l},t.x=0,t.y=0,(s==="inside"||s==="center")&&(!n&&(e.width<14||e.height<14)&&(t.text=""),n&&(e.height<14||e.width<14)&&(t.text=""))}};function pe(h){if(h.length===0)return[];let t=[{command:"M",x:h[0].x,y:h[0].y}];for(let e=1;e<h.length;e++){let i=h[Math.max(e-2,0)],s=h[e-1],n=h[e],r=h[Math.min(e+1,h.length-1)];t.push({command:"C",cp1x:s.x+(n.x-i.x)/6,cp1y:s.y+(n.y-i.y)/6,cp2x:n.x-(r.x-s.x)/6,cp2y:n.y-(r.y-s.y)/6,x:n.x,y:n.y})}return t}var mt=class{constructor(t){this.group=new K;this.stroke="#4e79a7";this.strokeWidth=2;this.markerOpts={enabled:!0,size:6,fill:""};this.connectMissingData=!0;this.markerShape="circle";this.linePath=new at;this.xKey=t.xKey,this.yKey=t.yKey;let e=t.step?"step":"linear";this.interpolation=t.interpolation??e,t.stroke&&(this.stroke=t.stroke),t.strokeWidth&&(this.strokeWidth=t.strokeWidth),t.marker&&(this.markerOpts={...this.markerOpts,...t.marker}),this.markerOpts.fill=this.markerOpts.fill||this.stroke,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,this.connectMissingData=t.connectMissingData??!0,this.markerShape=t.markerShape??"circle"}getGroup(){return this.group}update(t,e,i,s,n=!0,r){if(r&&(this.xKey=r.xKey,this.yKey=r.yKey,r.stroke&&(this.stroke=r.stroke),r.strokeWidth!==void 0&&(this.strokeWidth=r.strokeWidth),r.interpolation&&(this.interpolation=r.interpolation),r.marker&&(this.markerOpts={...this.markerOpts,...r.marker}),r.labels&&(this.labelsOpts=r.labels),r.animation&&(this.animationOpts=r.animation),r.shadow!==void 0&&(this.shadowOpts=r.shadow),r.connectMissingData!==void 0&&(this.connectMissingData=r.connectMissingData),r.markerShape&&(this.markerShape=r.markerShape)),this.group.clear(),t.length===0)return;let o=t.map(x=>{let c=x[this.yKey],m=c==null||typeof c=="number"&&isNaN(c),a=V(e);return{x:e.convert(x[this.xKey])+a/2,y:i.convert(m?0:c),datum:x,missing:m}}),l=this.linePath;l.pathData=[],l.stroke=this.stroke,l.strokeWidth=this.strokeWidth,l.shadow=this.shadowOpts??null;let y=[];if(this.connectMissingData)y.push(o.filter(x=>!x.missing));else{let x=[];o.forEach(c=>{c.missing?x.length>0&&(y.push(x),x=[]):x.push(c)}),x.length>0&&y.push(x)}y.forEach(x=>{x.length!==0&&(this.interpolation==="smooth"?l.pathData.push(...pe(x)):this.interpolation==="step"?x.forEach((c,m)=>{if(m===0)l.pathData.push({command:"M",x:c.x,y:c.y});else{let a=l.pathData[l.pathData.length-1];l.pathData.push({command:"L",x:c.x,y:a.y}),l.pathData.push({command:"L",x:c.x,y:c.y})}}):x.forEach((c,m)=>l.pathData.push({command:m===0?"M":"L",x:c.x,y:c.y})))}),this.group.add(l);let u=new K;if(this.group.add(u),(this.markerOpts.enabled||this.labelsOpts?.enabled)&&o.forEach(x=>{if(!x.missing){if(this.markerOpts.enabled){let c=new et;c.centerX=x.x,c.centerY=x.y,c.radius=(this.markerOpts.size||6)/2,c.shape=this.markerShape,c.fill=this.markerOpts.fill||this.stroke,c.stroke="#fff",c.strokeWidth=1.5,c.shadow=this.shadowOpts??null,c.datum=x.datum,c.seriesId=this.yKey,u.add(c)}if(this.labelsOpts?.enabled){let c=new z;c.text=tt(x.datum[this.yKey]),c.fontSize=this.labelsOpts.fontSize||10,c.fontFamily=this.labelsOpts.fontFamily||"sans-serif",c.fontWeight=this.labelsOpts.fontWeight||"600",c.rotation=(this.labelsOpts.rotation||0)*Math.PI/180,c.fill=this.labelsOpts.fill||this.stroke;let m=this.labelsOpts.position||"top",a=(this.markerOpts.enabled?this.markerOpts.size||6:0)/2+5,f=x.x,b=x.y;m==="top"?(b=x.y-a,c.textAlign="center",c.textBaseline="bottom"):m==="bottom"?(b=x.y+a+2,c.textAlign="center",c.textBaseline="top"):m==="left"?(f=x.x-a-4,c.textAlign="right",c.textBaseline="middle"):m==="right"?(f=x.x+a+4,c.textAlign="left",c.textBaseline="middle"):(c.textAlign="center",c.textBaseline="middle",this.markerOpts.enabled&&(c.fill="#fff")),c.translation={x:f,y:b},c.x=0,c.y=0,u.add(c)}}}),n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let x=this.animationOpts?.type||"draw",c=this.animationOpts?.duration??800,m=W.getEasing(this.animationOpts?.easing);if(x==="draw"){let a=0;for(let f=1;f<o.length;f++)a+=Math.sqrt(Math.pow(o[f].x-o[f-1].x,2)+Math.pow(o[f].y-o[f-1].y,2));this.interpolation==="step"&&(a*=1.5),l.lineDash=[a,a],l.lineDashOffset=a,u.opacity=0,this.animator=new W({duration:c,easing:m,onUpdate:f=>{l.lineDashOffset=a*(1-f),f>.8&&(u.opacity=(f-.8)*5)},onComplete:()=>{l.lineDash=void 0,u.opacity=1}})}else this.group.opacity=0,this.animator=new W({duration:c,easing:m,onUpdate:a=>{this.group.opacity=a}});this.animator.start()}}};var Wt=Math.PI/180,dt=class{constructor(t){this.group=new K;this.innerRadius=0;this.fills=["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"];this.strokes=["#fff"];this.startAngleDeg=-90;this.endAngleDeg=270;this.padAngle=.008;this.slices=[];this.angleKey=t.angleKey,this.labelKey=t.labelKey,t.innerRadius!==void 0&&(this.innerRadius=t.innerRadius),t.outerRadius!==void 0&&(this.outerRadius=t.outerRadius),t.fills&&(this.fills=t.fills),t.strokes&&(this.strokes=t.strokes),t.startAngle!==void 0&&(this.startAngleDeg=t.startAngle),t.endAngle!==void 0&&(this.endAngleDeg=t.endAngle),t.padAngle!==void 0&&(this.padAngle=t.padAngle),this.labelsOpts=t.labels,this.animationOpts=t.animation}getGroup(){return this.group}update(t,e,i=!0,s){if(s&&(this.angleKey=s.angleKey,this.labelKey=s.labelKey,s.innerRadius!==void 0&&(this.innerRadius=s.innerRadius),s.outerRadius!==void 0&&(this.outerRadius=s.outerRadius),s.fills&&(this.fills=s.fills),s.strokes&&(this.strokes=s.strokes),s.startAngle!==void 0&&(this.startAngleDeg=s.startAngle),s.endAngle!==void 0&&(this.endAngleDeg=s.endAngle),s.padAngle!==void 0&&(this.padAngle=s.padAngle),s.labels&&(this.labelsOpts=s.labels),s.animation&&(this.animationOpts=s.animation)),this.group.clear(),!t||t.length===0)return;let n=t.reduce((a,f)=>a+(f[this.angleKey]||0),0);if(n===0)return;let r=e.x+e.width/2,o=e.y+e.height/2,l=this.labelsOpts?.enabled!==!1?.72:.88,y=this.outerRadius??Math.min(e.width,e.height)/2*l,u=this.innerRadius>0&&this.innerRadius<=1?this.innerRadius*y:this.innerRadius,x=this.startAngleDeg*Wt,c=(this.endAngleDeg-this.startAngleDeg)*Wt;this.slices=[];let m=x;if(t.forEach((a,f)=>{let k=(a[this.angleKey]||0)/n*c-this.padAngle,p=new bt;p.centerX=r,p.centerY=o,p.innerRadius=u,p.outerRadius=y,p.startAngle=m,p.endAngle=m+k,p.fill=this.fills[f%this.fills.length],p.stroke=this.strokes[f%this.strokes.length],p.strokeWidth=2,p.datum=a,p.seriesId=this.angleKey,this.group.add(p);let S;if(this.labelsOpts?.enabled!==!1){let w=m+k/2,d=this.labelsOpts?.position||"outside",g=d==="inside"||d==="center",C=g?u+(y-u)/2:y+18,A=r+Math.cos(w)*C,R=o+Math.sin(w)*C;S=new z,S.text=String(a[this.labelKey]??""),S.fontSize=this.labelsOpts?.fontSize||10,S.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",S.fontWeight=this.labelsOpts?.fontWeight||"normal",S.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,S.fill=this.labelsOpts?.fill||(g?"#fff":"#6b7280");let v=Math.cos(w);if(S.textAlign=g?"center":v>.05?"start":v<-.05?"end":"center",S.textBaseline="middle",S.translation={x:A,y:R},S.x=0,S.y=0,!g){let B=v>0?e.x+e.width-A-10:A-e.x-10;S.maxWidth=Math.max(40,Math.min(B,e.width/3))}g&&k<.1&&(S.text=""),this.group.add(S)}this.slices.push({arc:p,targetStart:m,targetEnd:m+k,label:S}),m+=k+this.padAngle}),i&&this.animationOpts?.enabled!==!1){this.animator?.stop();let a=this.animationOpts?.type||"grow",f=this.animationOpts?.duration??600,b=W.getEasing(this.animationOpts?.easing||(a==="grow"?"back":"easeOut"));a==="grow"?(this.slices.forEach(k=>{k.arc.outerRadius=0,k.label&&(k.label.opacity=0)}),this.animator=new W({duration:f,easing:b,onUpdate:k=>{this.slices.forEach(p=>{p.arc.outerRadius=y*k,p.label&&k>.8&&(p.label.opacity=(k-.8)*5)})}})):a==="radial"?(this.slices.forEach(k=>{k.arc.endAngle=k.arc.startAngle,k.label&&(k.label.opacity=0)}),this.animator=new W({duration:f,easing:b,onUpdate:k=>{this.slices.forEach(p=>{let S=p.targetEnd-p.targetStart;p.arc.endAngle=p.targetStart+S*k,p.label&&k>.8&&(p.label.opacity=(k-.8)*5)})}})):(this.group.opacity=0,this.animator=new W({duration:f,easing:b,onUpdate:k=>{this.group.opacity=k}})),this.animator.start()}}getLegendData(t,e){return e?e.map((i,s)=>({id:`${this.angleKey}-${s}`,label:String(i[this.labelKey]??`Item ${s+1}`),fill:this.fills[s%this.fills.length],markerType:"square"})):[]}};function me(h){if(h.length===0)return[];let t=[{command:"M",x:h[0].x,y:h[0].y}];for(let e=1;e<h.length;e++){let i=h[Math.max(e-2,0)],s=h[e-1],n=h[e],r=h[Math.min(e+1,h.length-1)];t.push({command:"C",cp1x:s.x+(n.x-i.x)/6,cp1y:s.y+(n.y-i.y)/6,cp2x:n.x-(r.x-s.x)/6,cp2y:n.y-(r.y-s.y)/6,x:n.x,y:n.y})}return t}var ft=class{constructor(t){this.group=new K;this.fill="#4e79a7";this.stroke="#4e79a7";this.strokeWidth=2;this.fillOpacity=.25;this.stacked=!1;this.normalized=!1;this.connectMissingData=!0;this.markerOpts={enabled:!1,size:6,fill:""};this.path=new at;this.markers=[];this.points=[];this.xKey=t.xKey,this.yKey=t.yKey,this.stacked=t.stacked??!1,this.normalized=t.normalized??!1,this.connectMissingData=t.connectMissingData??!0,this.interpolation=t.interpolation??"linear",t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke),t.strokeWidth!==void 0&&(this.strokeWidth=t.strokeWidth),t.fillOpacity!==void 0&&(this.fillOpacity=t.fillOpacity),t.marker&&(this.markerOpts={...this.markerOpts,...t.marker}),this.markerOpts.fill=this.markerOpts.fill||this.fill,this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow}getGroup(){return this.group}update(t,e,i,s,n=!0,r,o,l){o&&(this.xKey=o.xKey,this.yKey=o.yKey,o.fill&&(this.fill=o.fill),o.stroke&&(this.stroke=o.stroke),o.strokeWidth!==void 0&&(this.strokeWidth=o.strokeWidth),o.fillOpacity!==void 0&&(this.fillOpacity=o.fillOpacity),o.stacked!==void 0&&(this.stacked=o.stacked),o.normalized!==void 0&&(this.normalized=o.normalized),o.connectMissingData!==void 0&&(this.connectMissingData=o.connectMissingData),o.interpolation&&(this.interpolation=o.interpolation),o.marker&&(this.markerOpts={...this.markerOpts,...o.marker}),o.labels&&(this.labelsOpts=o.labels),o.animation&&(this.animationOpts=o.animation),o.shadow!==void 0&&(this.shadowOpts=o.shadow));let y=this.points.length===0;if(this.group.clear(),t.length===0)return;this.path=new at,this.path.fill=this.fill,this.path.stroke=this.stroke,this.path.strokeWidth=this.strokeWidth,this.path.opacity=this.fillOpacity,this.path.shadow=this.shadowOpts??null,this.group.add(this.path);let u=[];if(this.markers=[],t.forEach((x,c)=>{let m=e.convert(x[this.xKey])+V(e)/2,a=x[this.yKey],f=a==null||typeof a=="number"&&isNaN(a),b,k;if(this.stacked&&r){let d=r[c]??0,g=l?.[c]??0;if(this.normalized&&g>0){let C=d/g*100,A=(a??0)/g*100;k=i.convert(C),b=i.convert(C+A)}else k=i.convert(d),b=i.convert(d+(a??0))}else b=i.convert(a??0),k=i.convert(0);let p=y?i.convert(0):this.points[c]?.currentY??i.convert(0),S=y?i.convert(0):this.points[c]?.currentBottomY??i.convert(0),w;if(this.labelsOpts?.enabled&&(w=new z,this.group.add(w)),u.push({x:m,targetY:b,startY:p,currentY:p,targetBottomY:k,startBottomY:S,currentBottomY:S,label:w,datum:x,missing:f}),this.markerOpts.enabled){let d=new et;d.shape=this.markerOpts.shape||"circle",d.centerX=m,d.centerY=b,d.radius=(this.markerOpts.size||6)/2,d.fill=this.markerOpts.fill,this.markerOpts.stroke&&(d.stroke=this.markerOpts.stroke),this.markerOpts.strokeWidth!==void 0&&(d.strokeWidth=this.markerOpts.strokeWidth),d.shadow=this.shadowOpts??null,d.datum=x,d.seriesId=this.yKey,this.markers.push(d),this.group.add(d)}}),this.points=u,n&&this.animationOpts?.enabled!==!1){this.animator?.stop();let x=this.animationOpts?.type||"grow",c=this.animationOpts?.duration??500,m=W.getEasing(this.animationOpts?.easing);x==="fade"?(this.group.opacity=0,this.animator=new W({duration:c,easing:m,onUpdate:a=>{this.buildPath(1),this.group.opacity=a*this.fillOpacity,this.labelsOpts?.enabled&&this.renderLabels()}})):this.animator=new W({duration:c,easing:m,onUpdate:a=>{this.buildPath(a),this.labelsOpts?.enabled&&this.renderLabels()}}),this.animator.start()}else this.points.forEach((x,c)=>{x.label=u[c].label,x.targetY=u[c].targetY,x.targetBottomY=u[c].targetBottomY,x.startY=x.currentY,x.startBottomY=x.currentBottomY}),this.buildPath(1),this.labelsOpts?.enabled&&this.renderLabels()}renderLabels(){this.points.forEach(t=>{if(!t.label)return;let e=t.label;e.text=tt(t.datum[this.yKey]),e.fontSize=this.labelsOpts?.fontSize||10,e.fontFamily=this.labelsOpts?.fontFamily||"sans-serif",e.fontWeight=this.labelsOpts?.fontWeight||"600",e.rotation=(this.labelsOpts?.rotation||0)*Math.PI/180,e.fill=this.labelsOpts?.fill||this.stroke,e.textAlign="center",e.textBaseline="bottom",e.translation={x:t.x,y:t.currentY-8},e.x=0,e.y=0})}buildPath(t){this.points.forEach((s,n)=>{s.currentY=s.startY+(s.targetY-s.startY)*t,s.currentBottomY=s.startBottomY+(s.targetBottomY-s.startBottomY)*t,this.markers[n]&&(this.markers[n].centerY=s.currentY)});let e=[];if(this.connectMissingData)e.push(this.points);else{let s=[];this.points.forEach(n=>{n.missing?s.length>0&&(e.push(s),s=[]):s.push(n)}),s.length>0&&e.push(s)}let i=[];e.forEach(s=>{let n=s.map(l=>({x:l.x,y:l.currentY}));if(n.length===0)return;let r;this.interpolation==="smooth"?r=me(n):this.interpolation==="step"?(r=[],n.forEach((l,y)=>{if(y===0)r.push({command:"M",x:l.x,y:l.y});else{let u=r[r.length-1];r.push({command:"L",x:l.x,y:u.y}),r.push({command:"L",x:l.x,y:l.y})}})):r=n.map((l,y)=>({command:y===0?"M":"L",x:l.x,y:l.y}));let o=[];for(let l=s.length-1;l>=0;l--)o.push({command:"L",x:s[l].x,y:s[l].currentBottomY});o.push({command:"L",x:n[0].x,y:n[0].y}),i.push(...r,...o)}),this.path.pathData=i,this.path.closed=!0}};var gt=class{constructor(t){this.group=new K;this.fill="#4e79a7";this.stroke="#fff";this.strokeWidth=1;this.markerSize=8;this.markers=[];this.markerShape="circle";this.labelTexts=[];this.points=[];this.jitter=0;this.jitterOffsets=[];this.xKey=t.xKey,this.yKey=t.yKey,this.sizeKey=t.sizeKey,this.jitter=t.jitter??0,t.fill&&(this.fill=t.fill),t.stroke&&(this.stroke=t.stroke),t.strokeWidth!==void 0&&(this.strokeWidth=t.strokeWidth),t.marker?.size!==void 0&&(this.markerSize=t.marker.size),this.labelsOpts=t.labels,this.animationOpts=t.animation,this.shadowOpts=t.shadow,t.markerShape&&(this.markerShape=t.markerShape)}getGroup(){return this.group}update(t,e,i,s,n=!0,r){if(r&&(this.xKey=r.xKey,this.yKey=r.yKey,r.sizeKey!==void 0&&(this.sizeKey=r.sizeKey),r.fill&&(this.fill=r.fill),r.stroke&&(this.stroke=r.stroke),r.strokeWidth!==void 0&&(this.strokeWidth=r.strokeWidth),r.marker?.size!==void 0&&(this.markerSize=r.marker.size),r.jitter!==void 0&&(this.jitter=r.jitter),r.labels&&(this.labelsOpts=r.labels),r.animation&&(this.animationOpts=r.animation),r.shadow!==void 0&&(this.shadowOpts=r.shadow),r.markerShape&&(this.markerShape=r.markerShape)),this.animator&&this.animator.stop(),t.length===0){for(let m of this.markers)this.group.remove(m);for(let m of this.labelTexts)this.group.remove(m);this.markers=[],this.labelTexts=[],this.points=[];return}for(;this.jitterOffsets.length<t.length;)this.jitterOffsets.push((Math.random()-.5)*2);this.jitterOffsets.length>t.length&&(this.jitterOffsets.length=t.length);let o=m=>this.markerSize/2;if(this.sizeKey){let m=t.map(f=>f[this.sizeKey]||0),a=Math.max(...m);o=f=>f/(a||1)*this.markerSize}let l=this.animationOpts?.type||"pop",y=this.points.length===0,u=[];if(t.forEach((m,a)=>{let f=m[this.xKey],b=m[this.yKey],k=this.sizeKey?m[this.sizeKey]:0,p;if("getBandwidth"in e){let v=V(e),B=this.jitterOffsets[a]*(v*this.jitter/2);p=e.convert(f)+v/2+B}else p=e.convert(f);let S=i.convert(b),w=o(k),d,g,C,A,R;a<this.markers.length?(d=this.markers[a],g=d.centerX,C=d.centerY,A=d.radius,R=d.opacity,d.fill=this.fill,d.stroke=this.stroke,d.strokeWidth=this.strokeWidth,d.shape=this.markerShape,d.datum=m,d.seriesId=this.yKey,d.shadow=this.shadowOpts??null):(d=new et,d.fill=this.fill,d.stroke=this.stroke,d.strokeWidth=this.strokeWidth,d.shape=this.markerShape,d.datum=m,d.seriesId=this.yKey,d.shadow=this.shadowOpts??null,this.markers.push(d),this.group.add(d),y&&l==="grow"?(g=p,C=s.height,A=w,R=1):y&&l==="fade"?(g=p,C=S,A=w,R=0):y&&l==="slide"?(g=p,C=s.height+20,A=w,R=1):(g=p,C=S,A=0,R=0),d.centerX=g,d.centerY=C,d.radius=A,d.opacity=R),u.push({startX:g,targetX:p,startY:C,targetY:S,startRadius:A,targetRadius:w,startOpacity:R,targetOpacity:1})}),this.markers.length>t.length){for(let m=t.length;m<this.markers.length;m++)this.group.remove(this.markers[m]);this.markers.length=t.length}let x=this.labelsOpts?.enabled??!1;if(x){for(;this.labelTexts.length<t.length;){let m=new z;m.textAlign="center",m.textBaseline="bottom",m.x=0,m.y=0,this.labelTexts.push(m),this.group.add(m)}if(this.labelTexts.length>t.length){for(let m=t.length;m<this.labelTexts.length;m++)this.group.remove(this.labelTexts[m]);this.labelTexts.length=t.length}this.labelTexts.forEach((m,a)=>{let f=t[a][this.yKey];m.text=tt(f),m.fontSize=this.labelsOpts?.fontSize??10,m.fontFamily=this.labelsOpts?.fontFamily??"sans-serif",m.fontWeight=this.labelsOpts?.fontWeight??"600",m.rotation=(this.labelsOpts?.rotation??0)*Math.PI/180,m.fill=this.labelsOpts?.fill??this.fill})}else if(this.labelTexts.length>0){for(let m of this.labelTexts)this.group.remove(m);this.labelTexts=[]}this.points=u;let c=m=>{this.points.forEach((a,f)=>{let b=this.markers[f];if(!b)return;let k=a.startX+(a.targetX-a.startX)*m,p=a.startY+(a.targetY-a.startY)*m,S=a.startRadius+(a.targetRadius-a.startRadius)*m;b.centerX=k,b.centerY=p,b.radius=S,b.opacity=a.startOpacity+(a.targetOpacity-a.startOpacity)*m,x&&this.labelTexts[f]&&(this.labelTexts[f].translation={x:k,y:p-(S+5)})})};if(n&&this.animationOpts?.enabled!==!1){let m=this.animationOpts?.duration??600,a=W.getEasing(this.animationOpts?.easing??(l==="pop"?"back":"easeOut"));this.animator=new W({duration:m,easing:a,onUpdate:c}),this.animator.start()}else c(1)}};var _t={active:!1,pointerX:0,pointerY:0,anchorX:0,anchorY:0,localX:0,localY:0,entries:[],sharedLabel:null};var vt=class{constructor(){this._state={..._t};this._listeners=new Set;this._options={};this._showTimer=null;this._hideTimer=null;this._pendingActivation=null}getState(){return this._state}getOptions(){return this._options}setOptions(t){this._options=t}subscribe(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}activate(t,e,i,s,n){if(this._options.enabled===!1)return;this._clearHideTimer();let r=()=>{this._setState({active:!0,pointerX:e.x,pointerY:e.y,anchorX:i.x,anchorY:i.y,localX:s.x,localY:s.y,entries:t,sharedLabel:n})},o=this._options.delay?.show??0;o>0?(this._clearShowTimer(),this._pendingActivation=r,this._showTimer=setTimeout(()=>{this._pendingActivation?.(),this._pendingActivation=null,this._showTimer=null},o)):r()}deactivate(){this._clearShowTimer(),this._pendingActivation=null;let t=this._options.delay?.hide??0;t>0&&this._state.active?this._hideTimer=setTimeout(()=>{this._doDeactivate(),this._hideTimer=null},t):this._doDeactivate()}updatePointer(t,e){this._state.active&&this._setState({...this._state,pointerX:t,pointerY:e})}notifyResize(){this._state.active&&this._notify()}hide(){this._clearShowTimer(),this._clearHideTimer(),this._pendingActivation=null,this._doDeactivate(!0)}destroy(){this.hide(),this._listeners.clear()}_setState(t){this._state=t,this._notify()}_notify(){for(let t of this._listeners)t()}_doDeactivate(t=!1){!this._state.active&&!t||this._setState({..._t})}_clearShowTimer(){this._showTimer!==null&&(clearTimeout(this._showTimer),this._showTimer=null)}_clearHideTimer(){this._hideTimer!==null&&(clearTimeout(this._hideTimer),this._hideTimer=null)}};var Gt=["#4e79a7","#f28e2c","#e15759","#76b7b2","#59a14f","#edc948","#b07aa1","#ff9da7","#9c755f","#bab0ac"],Nt=["#80b1d3","#fdb462","#fb8072","#bebada","#b3de69","#fccde5","#8dd3c7","#ffffb3","#bc80bd","#ccebc5"],Pt={backgroundColor:"#ffffff",textColor:"#1a1a2e",subtextColor:"#6b7280",axisColor:"#d1d5db",gridColor:"rgba(107,114,128,0.12)",palette:Gt,palettes:{categorical:Gt},fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},Ht={backgroundColor:"#020617",textColor:"#e2e8f0",subtextColor:"#94a3b8",axisColor:"#334155",gridColor:"rgba(148,163,184,0.08)",palette:Nt,palettes:{categorical:Nt},fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'};function $t(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}var ct=class{constructor(){this.currentTheme=Pt}setTheme(t){t==="light"?this.currentTheme=Pt:t==="dark"?this.currentTheme=Ht:t==="system"?this.currentTheme=$t()?Ht:Pt:this.currentTheme=t}get theme(){return this.currentTheme}static resolveIsDark(t){return t==="dark"?!0:t==="system"?$t():!1}};var kt=class{constructor(){this.group=new K;this.items=[];this.hiddenSeries=[];this.pages=[];this.currentPage=0;this.ROW_H=24;this.NAV_H=22;this.MARKER=12;this.GAP=6;this.SPACING=20;this.CHAR_W=7.5;this.lastMaxWidth=0;this.lastMaxRows=2}getGroup(){return this.group}setHiddenSeries(t){this.hiddenSeries=t}getHiddenSeries(){return this.hiddenSeries}update(t,e,i,s,n="bottom"){this.items=t,this.theme=e,this.lastMaxWidth=i;let r=n==="left"||n==="right",o=.85,l=.25;this.lastMaxRows=Math.max(1,Math.floor(s*(r?o:l)/this.ROW_H)),this.pages=this._buildPages(t,i,this.lastMaxRows),this.currentPage=Math.min(this.currentPage,Math.max(0,this.pages.length-1)),this._renderCurrentPage()}paginate(t){this.currentPage=Math.max(0,Math.min(this.pages.length-1,this.currentPage+t)),this._renderCurrentPage()}getBBox(){return this.group.getBBox()}_buildPages(t,e,i){let s=[],n=[],r=0;for(let l of t){let y=this.MARKER+this.GAP+l.label.length*this.CHAR_W+this.SPACING;r+y>e&&n.length>0&&(s.push(n),n=[],r=0),n.push(l),r+=y}n.length>0&&s.push(n);let o=[];for(let l=0;l<s.length;l+=i)o.push(s.slice(l,l+i).flat());return o.length>0?o:[[]]}_renderCurrentPage(){if(this.group.clear(),!this.theme)return;let t=this.theme,e=this.pages[this.currentPage]??[],i=this.pages.length>1,s=0,n=0;for(let x of e){let c=x.label.length*this.CHAR_W,m=this.MARKER+this.GAP+c;s+m>this.lastMaxWidth&&s>0&&(s=0,n+=this.ROW_H);let a=new K;if(a.translation={x:s,y:n},a.seriesId=x.id,a.opacity=this.hiddenSeries.includes(x.id)?.4:1,a.pointerEvents=!0,x.markerType==="circle"){let b=new ht;b.centerX=this.MARKER/2,b.centerY=this.MARKER/2,b.radius=this.MARKER/2,b.fill=x.fill,a.add(b)}else if(x.markerType==="line"){let b=new U;b.x1=0,b.y1=this.MARKER/2,b.x2=this.MARKER,b.y2=this.MARKER/2,b.stroke=x.fill,b.strokeWidth=3,a.add(b)}else{let b=new j;b.width=this.MARKER,b.height=this.MARKER,b.fill=x.fill,b.cornerRadius=2,a.add(b)}let f=new z;f.text=x.label,f.x=this.MARKER+this.GAP,f.y=this.MARKER/2,f.fontSize=11,f.fontFamily=t.fontFamily,f.fill=t.textColor,f.textBaseline="middle",a.add(f),this.group.add(a),s+=m+this.SPACING}if(!i)return;let r=n+(e.length>0?this.ROW_H:0),o=t.subtextColor,l=this.NAV_H,y=28;this.currentPage>0&&this.group.add(this._makeNavButton("\u25C0","__legend_prev__",0,r,y,l,o,t,"start"));let u=new z;u.text=`${this.currentPage+1} / ${this.pages.length}`,u.x=this.lastMaxWidth/2,u.y=r+l/2,u.fontSize=10,u.fontFamily=t.fontFamily,u.fill=o,u.textAlign="center",u.textBaseline="middle",u.pointerEvents=!1,this.group.add(u),this.currentPage<this.pages.length-1&&this.group.add(this._makeNavButton("\u25B6","__legend_next__",this.lastMaxWidth-y,r,y,l,o,t,"end"))}_makeNavButton(t,e,i,s,n,r,o,l,y){let u=new K;u.translation={x:i,y:s},u.seriesId=e,u.pointerEvents=!0;let x=new j;x.x=0,x.y=0,x.width=n,x.height=r,x.fill="transparent",u.add(x);let c=new z;return c.text=t,c.x=y==="end"?n:0,c.y=r/2,c.fontSize=11,c.fontFamily=l.fontFamily,c.fill=o,c.textAlign=y,c.textBaseline="middle",u.add(c),u}};var St=class St{constructor(){this.group=new K;this.xLine=new U;this.yLine=new U;this.snapDot=new ht;this.bandHighlight=new j;this.enabledX=!1;this.enabledY=!1;this.seriesSnapDots=[];this.seriesSnapTargets=[];this.spikeXLabel=new z;this.spikeYLabel=new z;this.spikeXBg=new j;this.spikeYBg=new j;this._targetX=0;this._targetY=0;this._currentX=0;this._currentY=0;this._lerpActive=!1;this._reducedMotion=typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;this.group.visible=!1,this.xLine.strokeWidth=1,this.yLine.strokeWidth=1,this.snapDot.radius=5,this.snapDot.fill="transparent",this.snapDot.strokeWidth=2,this.bandHighlight.fill="rgba(128,128,128,0.06)",this.bandHighlight.visible=!1,this.spikeXLabel.fontSize=10,this.spikeXLabel.textAlign="center",this.spikeXLabel.textBaseline="top",this.spikeXLabel.visible=!1,this.spikeXBg.cornerRadius=3,this.spikeXBg.visible=!1,this.spikeYLabel.fontSize=10,this.spikeYLabel.textAlign="right",this.spikeYLabel.textBaseline="middle",this.spikeYLabel.visible=!1,this.spikeYBg.cornerRadius=3,this.spikeYBg.visible=!1,this.group.add(this.bandHighlight),this.group.add(this.xLine),this.group.add(this.yLine),this.group.add(this.snapDot),this.group.add(this.spikeXBg),this.group.add(this.spikeXLabel),this.group.add(this.spikeYBg),this.group.add(this.spikeYLabel)}getGroup(){return this.group}updateOptions(t){this.enabledX=t.x??!1,this.enabledY=t.y??!1}show(t,e,i,s,n,r,o){if(!this.enabledX&&!this.enabledY){this.group.visible=!1;return}this.group.visible=!0;let l=s.axisColor,y=t,u=e;if(this.snapDot.visible=!1,this.bandHighlight.visible=!1,n&&r&&o){let x=1/0,c=t,m=0;for(let a of r){let b=n.convert(a[o])+V(n)/2+i.x,k=Math.abs(b-t);k<x&&(x=k,c=b,m=n.convert(a[o]))}if(y=c,this.enabledX){this.bandHighlight.visible=!0,this.bandHighlight.x=m+i.x,this.bandHighlight.y=i.y,this.bandHighlight.width=V(n),this.bandHighlight.height=i.height;let a=s.backgroundColor.includes("2")||s.backgroundColor.includes("0");this.bandHighlight.fill=a?"rgba(255,255,255,0.05)":"rgba(0,0,0,0.04)"}this.enabledX&&(this.snapDot.visible=!0,this.snapDot.centerX=y,this.snapDot.centerY=e,this.snapDot.fill=s.backgroundColor,this.snapDot.stroke=l)}this._targetX=y,this._targetY=u,!this._lerpActive&&this._currentX===0&&this._currentY===0?(this._currentX=y,this._currentY=u):this._lerpActive=!0,this.enabledX?(this.xLine.visible=!0,this.xLine.x1=this._currentX,this.xLine.y1=i.y,this.xLine.x2=this._currentX,this.xLine.y2=i.y+i.height,this.xLine.stroke=l,this.xLine.lineDash=[4,4]):this.xLine.visible=!1,this.enabledY?(this.yLine.visible=!0,this.yLine.x1=i.x,this.yLine.y1=this._currentY,this.yLine.x2=i.x+i.width,this.yLine.y2=this._currentY,this.yLine.stroke=l,this.yLine.lineDash=[4,4]):this.yLine.visible=!1,this.spikeXLabel.visible=!1,this.spikeXBg.visible=!1,this.spikeYLabel.visible=!1,this.spikeYBg.visible=!1}showSpikeLabels(t,e,i,s,n,r){let o=r.backgroundColor.includes("2")||r.backgroundColor.includes("0");if(t&&this.enabledX){this.spikeXLabel.visible=!0,this.spikeXLabel.text=t,this.spikeXLabel.x=i,this.spikeXLabel.y=n.y+n.height+4,this.spikeXLabel.fill=o?"#e2e8f0":"#1e293b",this.spikeXLabel.fontFamily=r.fontFamily;let l=t.length*6+12;this.spikeXBg.visible=!0,this.spikeXBg.x=i-l/2,this.spikeXBg.y=n.y+n.height+2,this.spikeXBg.width=l,this.spikeXBg.height=18,this.spikeXBg.fill=o?"#1e293b":"#f1f5f9",this.spikeXBg.stroke=r.axisColor,this.spikeXBg.strokeWidth=1}if(e&&this.enabledY){this.spikeYLabel.visible=!0,this.spikeYLabel.text=e,this.spikeYLabel.x=n.x-4,this.spikeYLabel.y=s,this.spikeYLabel.fill=o?"#e2e8f0":"#1e293b",this.spikeYLabel.fontFamily=r.fontFamily;let l=e.length*6+12;this.spikeYBg.visible=!0,this.spikeYBg.x=n.x-l-4,this.spikeYBg.y=s-9,this.spikeYBg.width=l,this.spikeYBg.height=18,this.spikeYBg.fill=o?"#1e293b":"#f1f5f9",this.spikeYBg.stroke=r.axisColor,this.spikeYBg.strokeWidth=1}}tick(){if(!this.group.visible)return!1;let t=this.seriesSnapDots.some((n,r)=>Math.abs((this.seriesSnapTargets[r]??0)-n.radius)>.2);if(!this._lerpActive&&!t)return!1;if(this._reducedMotion){this._currentX=this._targetX,this._currentY=this._targetY,this._lerpActive=!1,this.enabledX&&(this.xLine.x1=this._currentX,this.xLine.x2=this._currentX),this.enabledY&&(this.yLine.y1=this._currentY,this.yLine.y2=this._currentY);for(let n=0;n<this.seriesSnapDots.length;n++){let r=this.seriesSnapDots[n],o=this.seriesSnapTargets[n]??0;r.radius=o,o===0&&(r.visible=!1)}return!0}let e=St.LERP_SPEED,i=this._targetX-this._currentX,s=this._targetY-this._currentY;Math.abs(i)<.5&&Math.abs(s)<.5?(this._currentX=this._targetX,this._currentY=this._targetY,this._lerpActive=!1):(this._currentX+=i*e,this._currentY+=s*e),this.enabledX&&(this.xLine.x1=this._currentX,this.xLine.x2=this._currentX),this.enabledY&&(this.yLine.y1=this._currentY,this.yLine.y2=this._currentY);for(let n=0;n<this.seriesSnapDots.length;n++){let r=this.seriesSnapDots[n],o=this.seriesSnapTargets[n]??0,l=o-r.radius;Math.abs(l)<.2?(r.radius=o,o===0&&(r.visible=!1)):r.radius+=l*.35}return!0}hideSeriesSnaps(){for(let t=0;t<this.seriesSnapDots.length;t++)this.seriesSnapTargets[t]=0}hide(){this.group.visible=!1,this.bandHighlight.visible=!1,this.hideSeriesSnaps(),this.spikeXLabel.visible=!1,this.spikeXBg.visible=!1,this.spikeYLabel.visible=!1,this.spikeYBg.visible=!1,this._lerpActive=!1,this._currentX=0,this._currentY=0}};St.LERP_SPEED=.25;var wt=St;var Qt=new Set(["pie"]),At=class{constructor(t,e){this.tooltipStore=new vt;this.themeManager=new ct;this.legend=new kt;this.crosshair=new wt;this.mediaQuery=null;this._onSystemThemeChange=()=>{if(this.options.theme!=="system")return;this.themeManager.setTheme("system");let t=this.themeManager.theme.backgroundColor;this.container.style.backgroundColor=t,this.scene.backgroundColor=t,this.processData(),this.performLayout(),this.render()};this.titleGroup=new K;this.subtitleGroup=new K;this.legendGroup=new K;this.seriesGroup=new K;this.axesGroup=new K;this.crosshairGroup=new K;this.emptyGroup=new K;this.categoryScale=new st;this.valueScale=new it;this.valueScaleRight=new it;this.series=[];this.seriesInstances=new Map;this.isCartesian=!0;this.seriesRect={x:0,y:0,width:0,height:0};this.initialized=!1;this.animRafId=null;this.hoveredSeriesId=null;this.hiddenSeries=[];this.minY=0;this.maxY=0;this.lastDataRef=null;this._kbIndex=-1;this.container=t,this.options=e,this.scene=new xt(t),this.tooltipStore.setOptions(e.tooltip??{}),this.container.setAttribute("tabindex","0"),this._onKeyDown=this._handleKeyboard.bind(this),this.container.addEventListener("keydown",this._onKeyDown),this._onPointerLeave=()=>{this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this.hoveredSeriesId=null,this.series.forEach(i=>{i.getGroup().opacity=1})},this.container.addEventListener("pointerleave",this._onPointerLeave),this.scene.root.add(this.titleGroup),this.scene.root.add(this.subtitleGroup),this.scene.root.add(this.axesGroup),this.scene.root.add(this.seriesGroup),this.scene.root.add(this.legendGroup),this.scene.root.add(this.crosshairGroup),this.scene.root.add(this.emptyGroup),this.legendGroup.add(this.legend.getGroup()),this.crosshairGroup.add(this.crosshair.getGroup()),this.legendProxy=document.createElement("div"),this.legendProxy.className="radiant-chart-legend",this.legendProxy.style.position="absolute",this.legendProxy.style.pointerEvents="none",this.legendProxy.style.display="none",this.container.appendChild(this.legendProxy),this.setupInteractivity(),this.startLoop(),this.resizeObserver=new ResizeObserver(i=>{for(let s of i)s.contentRect.width>0&&s.contentRect.height>0&&(this.scene.resize(),this.performLayout(),this.render(),this.initialized=!0,this.tooltipStore.notifyResize())}),this.resizeObserver.observe(t),this._syncMediaQueryListener(),this.update(e)}startLoop(){let t=()=>{this.crosshair.tick(),this.render(),this.animRafId=requestAnimationFrame(t)};this.animRafId=requestAnimationFrame(t)}stopLoop(){this.animRafId!==null&&(cancelAnimationFrame(this.animRafId),this.animRafId=null)}setupInteractivity(){this.scene.onHover=(t,e)=>{if(!this.initialized)return;if(t===null){this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this.hoveredSeriesId=null,this.series.forEach(u=>{u.getGroup().opacity=1});return}let i=this.container.getBoundingClientRect(),s=e.clientX-i.left,n=e.clientY-i.top,r=this.themeManager.theme,o=this.seriesRect,l=r.palette;if(this.isCartesian&&s>=o.x&&s<=o.x+o.width&&n>=o.y&&n<=o.y+o.height){let u=this.options.series[0]?.xKey;this.crosshair.show(s,n,o,r,u?this.categoryScale:void 0,u?this.options.data:void 0,u)}else this.crosshair.hide();this.options.tooltip?.enabled!==!1&&(this.isCartesian&&s>=o.x&&s<=o.x+o.width&&n>=o.y&&n<=o.y+o.height?this.tooltipStore.activate([],{x:e.clientX,y:e.clientY},{x:e.clientX,y:e.clientY},{x:s,y:n},null):t?.datum&&!this.isCartesian?this.tooltipStore.activate([],{x:e.clientX,y:e.clientY},{x:e.clientX,y:e.clientY},{x:s,y:n},null):(this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps()));let y=t?.seriesId??null;t?.datum&&y!==this.hoveredSeriesId?(this.hoveredSeriesId=y,this.series.forEach((u,x)=>{let c=this.options.series[x]?.yKey??this.options.series[x]?.angleKey??`s${x}`;u.getGroup().opacity=c===y||this.series.length===1?1:.15})):!t?.datum&&this.hoveredSeriesId!==null&&(this.hoveredSeriesId=null,this.series.forEach(u=>{u.getGroup().opacity=1}))},this.scene.onClick=(t,e)=>{if(!t)return;let i=t,s=null,n=!1;for(;i;){if(i.seriesId&&!s&&(s=i.seriesId),i===this.legendGroup||i===this.legend.getGroup()){n=!0;break}i=i.parent}if(!n&&t.datum&&this.options.listeners?.nodeClick){let o=this.options.series.find(l=>(l.yKey??l.angleKey??"")===s);this.options.listeners.nodeClick({seriesId:s??"",datum:t.datum,xKey:o?.xKey,yKey:o?.yKey,type:o?.type})}if(!n||!s)return;if(s==="__legend_prev__"||s==="__legend_next__"){this.legend.paginate(s==="__legend_next__"?1:-1),this.performLayout(),this.render();return}let r=this.hiddenSeries.indexOf(s);r>=0?this.hiddenSeries.splice(r,1):this.hiddenSeries.push(s),this.options.legend?.listeners?.legendItemClick?.({seriesId:s,visible:!this.hiddenSeries.includes(s)}),this.legend.setHiddenSeries([...this.hiddenSeries]),this.processData(),this.performLayout(),this.render()},this.scene.onDblClick=(t,e)=>{if(!t)return;let i=t,s=null,n=!1;for(;i;){if(i.seriesId&&!s&&(s=i.seriesId),i===this.legendGroup||i===this.legend.getGroup()){n=!0;break}i=i.parent}if(n){if(!s||s==="__legend_prev__"||s==="__legend_next__")return;let o=this.options.series.map((y,u)=>y.yKey??y.angleKey??`s${u}`).filter(y=>y!==s),l=o.every(y=>this.hiddenSeries.includes(y));l?this.hiddenSeries=[]:this.hiddenSeries=o,this.options.legend?.listeners?.legendItemDoubleClick?.({seriesId:s,isolated:!l}),this.legend.setHiddenSeries([...this.hiddenSeries]),this.processData(),this.performLayout(),this.render();return}if(t.datum&&this.options.listeners?.nodeDoubleClick){let r=this.options.series.find(o=>(o.yKey??o.angleKey??"")===s);this.options.listeners.nodeDoubleClick({seriesId:s??"",datum:t.datum,xKey:r?.xKey,yKey:r?.yKey,type:r?.type})}}}getTooltipStore(){return this.tooltipStore}_handleKeyboard(t){if(!this.initialized||!this.isCartesian)return;let e=this.options.data;if(!e?.length)return;let i=this.options.series[0]?.xKey;if(i)if(t.key==="ArrowRight"||t.key==="ArrowLeft"){t.preventDefault();let s=t.key==="ArrowRight"?1:-1;this._kbIndex=Math.max(0,Math.min(e.length-1,this._kbIndex+s));let n=this.seriesRect,r=this.themeManager.theme,o=r.palette;this.crosshair.show(n.x+n.width/2,n.y+n.height/2,n,r,this.categoryScale instanceof st?this.categoryScale:void 0,e,i),this.options.onFocusChange?.(this._kbIndex)}else t.key==="Escape"?(t.preventDefault(),this.tooltipStore.deactivate(),this.crosshair.hide(),this.crosshair.hideSeriesSnaps(),this._kbIndex=-1,this.options.onFocusChange?.(null)):t.key==="Home"?(t.preventDefault(),this._kbIndex=0,this._handleKeyboard(new KeyboardEvent("keydown",{key:"ArrowLeft"})),this._kbIndex=0):t.key==="End"&&(t.preventDefault(),this._kbIndex=e.length-1,this._handleKeyboard(new KeyboardEvent("keydown",{key:"ArrowRight"})),this._kbIndex=e.length-1)}update(t){let e=t.data!==this.lastDataRef;this.lastDataRef=t.data,this.options=t,t.theme&&this.themeManager.setTheme(t.theme);let i=this.themeManager.theme.backgroundColor;this.container.style.backgroundColor=i,this.scene.backgroundColor=i,this.container.style.transition="background-color 0.3s",this.crosshair.updateOptions(t.crosshair??{}),this.tooltipStore.setOptions(t.tooltip??{}),this._syncMediaQueryListener(),this.processData(),this.performLayout(e),this.render()}_syncMediaQueryListener(){if(typeof window>"u")return;let t=this.options.theme==="system";t&&!this.mediaQuery?(this.mediaQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.mediaQuery.addEventListener("change",this._onSystemThemeChange)):!t&&this.mediaQuery&&(this.mediaQuery.removeEventListener("change",this._onSystemThemeChange),this.mediaQuery=null)}processData(){let t=(this.options.series||[]).map(i=>{let s=(i.type||"").toLowerCase().replace(/[-_ ]/g,""),n=i.yAxisId;return!n&&s==="line"&&i.yKey&&/percent|cumulative|pareto/i.test(i.yKey)&&(n="right"),{...i,type:s,yAxisId:n}});this.options={...this.options,series:t};let{data:e}=this.options;if(this.emptyGroup.clear(),!e?.length||!t?.length){this.isCartesian=!1,this.initialized=!0,this.axesGroup.visible=!1,this.seriesGroup.clear(),this.legendGroup.visible=!1,this.legend.getGroup().visible=!1,this.series=[],this.seriesInstances.clear();return}if(this.isCartesian=t.every(i=>!Qt.has(i.type??"")),this.isCartesian){let i=new Set;this.minY=1/0,this.maxY=-1/0,t.some(a=>a.type==="scatter")?(this.categoryScale=new it,this.valueScale=new it):(this.categoryScale=new st,this.valueScale=new it);let n=t.filter(a=>a.type==="bar"&&(a.stacked||a.normalized)),r=t.filter(a=>a.type==="area"&&(a.stacked||a.normalized)),o=e.map(a=>n.reduce((f,b)=>f+(a[b.yKey]??0),0)),l=e.map(a=>r.reduce((f,b)=>f+(a[b.yKey]??0),0));n.length>0&&(t.some(a=>a.type==="bar"&&a.normalized)?this.maxY=100:e.forEach((a,f)=>{this.maxY=Math.max(this.maxY,o[f])})),r.length>0&&(t.some(a=>a.type==="area"&&a.normalized)?this.maxY=Math.max(this.maxY,100):e.forEach((a,f)=>{this.maxY=Math.max(this.maxY,l[f])}));let y=new Set,u=new Set;if(t.forEach(a=>{a.xKey&&y.add(a.xKey)}),t.forEach((a,f)=>{let b=a.yKey??a.angleKey??`s${f}`;!this.hiddenSeries.includes(b)&&a.yKey&&!a.stacked&&!a.normalized&&a.type!=="histogram"&&u.add(a.yKey)}),e.forEach(a=>{y.forEach(f=>{a[f]!==void 0&&i.add(a[f])}),u.forEach(f=>{let b=a[f];b>this.maxY&&(this.maxY=b),b<this.minY&&(this.minY=b)})}),this.categoryScale instanceof st)this.categoryScale.domain=Array.from(i);else{let a=Array.from(i).map(f=>typeof f=="number"?f:Number(new Date(f))).filter(f=>!isNaN(f));if(a.length>0){let f=Math.min(...a),b=Math.max(...a);this.categoryScale.domain=[f,b]}}if(this.valueScale instanceof st){let a=new Set;t.forEach(f=>{f.yKey&&e.forEach(b=>a.add(b[f.yKey]))}),this.valueScale.domain=Array.from(a)}else{let f=t.some(k=>k.type==="bar"||k.type==="area")?Math.min(0,this.minY):this.minY,b=this.maxY===-1/0?100:this.maxY;this.valueScale.domain=[f*(f<0?1.1:.98),b*1.05]}if(t.some(a=>a.yAxisId==="right")){let a=0,f=-1/0;t.forEach(b=>{b.yAxisId==="right"&&b.yKey&&e.forEach(k=>{let p=k[b.yKey];p>f&&(f=p),p<a&&(a=p)})}),this.valueScaleRight.domain=[a,(f===-1/0?100:f)*1.12]}let c=t.some(a=>a.type==="bar"&&a.direction==="horizontal"),m=this.themeManager.theme;this.axesGroup.clear(),c?(this.xAxis=new nt(this.valueScale,{position:"bottom",fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),this.yAxis=new nt(this.categoryScale,{position:"left",fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),this.yAxisRight=void 0):(this.xAxis=new nt(this.categoryScale,{position:"bottom",fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),this.yAxis=new nt(this.valueScale,{position:"left",fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),t.some(a=>a.yAxisId==="right")?this.yAxisRight=new nt(this.valueScaleRight,{position:"right",fontSize:this.options.yAxisRightFontSize??this.options.yAxisFontSize,fontFamily:this.options.yAxisRightFontFamily??this.options.yAxisFontFamily,rotation:this.options.yAxisRightRotation??this.options.yAxisRotation,labelAlignment:this.options.yAxisRightLabelAlignment??this.options.yAxisLabelAlignment}):this.yAxisRight=void 0),this.xAxis.setTheme(m),this.yAxis.setTheme(m),this.axesGroup.add(this.xAxis.getGroup()),this.axesGroup.add(this.yAxis.getGroup()),this.yAxisRight&&(this.yAxisRight.setTheme(m),this.axesGroup.add(this.yAxisRight.getGroup())),this.axesGroup.visible=!0}else this.axesGroup.visible=!1}createSeriesInstance(t,e){let i=this.themeManager.theme.palette,s=t.fill??i[e%i.length],n={...this.options.animation,...t.animation},r={...t,fill:s,stroke:t.stroke??s,animation:n};switch(t.type){case"bar":return new pt(r);case"line":return new mt(r);case"pie":return new dt({...t,fills:t.fills??i});case"donut":return new dt({...t,fills:t.fills??i,innerRadius:t.innerRadius??.6});case"area":return new ft(r);case"scatter":return new gt({...r,jitter:t.jitter});default:return null}}renderEmpty(){let{width:t,height:e}=this.container.getBoundingClientRect();if(!t||!e)return;let i=this.themeManager.theme,s=new z;s.text="\u2B1C",s.x=t/2,s.y=e/2-20,s.fontSize=26,s.fill=i.axisColor,s.textAlign="center",s.textBaseline="middle",this.emptyGroup.add(s);let n=new z;n.text="No data available",n.x=t/2,n.y=e/2+16,n.fontSize=13,n.fill=i.subtextColor,n.fontFamily=i.fontFamily,n.textAlign="center",n.textBaseline="middle",this.emptyGroup.add(n)}performLayout(t=!1){let{width:e,height:i}=this.container.getBoundingClientRect();if(!e||!i)return;this.axesGroup.opacity=1,this.seriesGroup.opacity=1;let s=this.options.padding??{top:4,right:4,bottom:0,left:4},n=s.top??4,r=i-(s.bottom??0),o=s.left??4,l=e-(s.right??4),y=s.inner??0,u=this.themeManager.theme;if(this.titleGroup.clear(),this.subtitleGroup.clear(),this.options.title){let A=new z;A.text=this.options.title.text,A.fontSize=this.options.title.fontSize??16,A.fontWeight="600",A.fill=u.textColor,A.fontFamily=u.fontFamily,A.x=e/2,A.y=n+A.fontSize,A.textAlign="center",this.titleGroup.add(A),n+=A.fontSize+8}if(this.options.subtitle){let A=new z;A.text=this.options.subtitle.text,A.fontSize=this.options.subtitle.fontSize??12,A.fill=u.subtextColor,A.fontFamily=u.fontFamily,A.x=e/2,A.y=n+A.fontSize,A.textAlign="center",this.subtitleGroup.add(A),n+=A.fontSize+6}let x=this.options.legend;if(x?.enabled!==!1&&this.options.series.length>1){let A=[],R=new Set(Qt);this.options.series.forEach((L,Y)=>{let X=null;for(let[O,G]of this.seriesInstances.entries())if(O.startsWith(`${L.type}-${Y}-`)){X=G;break}if(X||(X=this.createSeriesInstance(L,Y),X&&R.has(L.type)&&this.seriesInstances.set(`${L.type}-${Y}-null`,X)),X&&typeof X.getLegendData=="function"){let O=X.getLegendData(u,this.options.data);Array.isArray(O)&&O.length>0?A.push(...O):A.push({id:L.yKey??L.angleKey??`s${Y}`,label:L.title??L.yKey??L.angleKey??`Series ${Y+1}`,fill:L.fill??u.palette[Y%u.palette.length],markerType:L.type==="line"||L.type==="scatter"?"circle":"square"})}else A.push({id:L.yKey??L.angleKey??`s${Y}`,label:L.title??L.yKey??L.angleKey??`Series ${Y+1}`,fill:L.fill??u.palette[Y%u.palette.length],markerType:L.type==="line"||L.type==="scatter"?"circle":"square"})}),this.legend.setHiddenSeries([...this.hiddenSeries]);let v=x?.position??"bottom",_=v==="left"||v==="right"?Math.min(e*.3,200):e;this.legend.update(A,u,_,i,v),this.legendGroup.visible=!0,this.legendGroup.opacity=1;let D=this.legend.getGroup();D.visible=!0,D.opacity=1;let T=this.legend.getBBox();if(T.width>0&&T.height>0){let L=0,Y=0;v==="bottom"?(L=(e-T.width)/2-T.x,Y=r-T.height-T.y,r-=T.height+10):v==="top"?(L=(e-T.width)/2-T.x,Y=n-T.y,n+=T.height+10):v==="left"?(L=o-T.x,Y=(i-T.height)/2-T.y,o+=T.width+10):v==="right"&&(L=l-T.width-T.x,Y=(i-T.height)/2-T.y,l-=T.width+10),D.translation={x:L,y:Y},this.legendProxy&&(this.legendProxy.style.display="block",this.legendProxy.style.left=`${L+T.x}px`,this.legendProxy.style.top=`${Y+T.y}px`,this.legendProxy.style.width=`${T.width}px`,this.legendProxy.style.height=`${T.height}px`)}else v==="bottom"?(D.translation={x:0,y:r-24},r-=24):v==="top"&&(D.translation={x:0,y:n},n+=24),this.legendProxy&&(this.legendProxy.style.display="none")}else this.legendGroup.visible=!1,this.legendProxy&&(this.legendProxy.style.display="none");let m=this.options.showXAxis!==!1,a=this.options.showYAxis!==!1,f=this.options.showYAxisRight!==!1,b=this.scene.getContext(),k=0,p=0,S=0,w=0,d=12;if(this.isCartesian&&this.yAxis&&a){this.yAxis.setTheme(u),this.yAxis.updateOptions({fontSize:this.options.yAxisFontSize,fontFamily:this.options.yAxisFontFamily,rotation:this.options.yAxisRotation,labelAlignment:this.options.yAxisLabelAlignment}),k=this.yAxis.getRequiredSpace(b).size+d;let A=e*.4;k>A?(k=A,this.yAxis.setLayoutMaxWidth(k-d)):this.yAxis.setLayoutMaxWidth(0)}this.isCartesian&&this.yAxisRight&&f&&(this.yAxisRight.setTheme(u),this.yAxisRight.updateOptions({fontSize:this.options.yAxisRightFontSize??this.options.yAxisFontSize,fontFamily:this.options.yAxisRightFontFamily??this.options.yAxisFontFamily,rotation:this.options.yAxisRightRotation??this.options.yAxisRotation,labelAlignment:this.options.yAxisRightLabelAlignment??this.options.yAxisLabelAlignment}),p=this.yAxisRight.getRequiredSpace(b).size+d),this.isCartesian&&this.xAxis&&m&&(this.xAxis.setTheme(u),this.xAxis.updateOptions({fontSize:this.options.xAxisFontSize,fontFamily:this.options.xAxisFontFamily,rotation:this.options.xAxisRotation,labelAlignment:this.options.xAxisLabelAlignment}),S=this.xAxis.getRequiredSpace(b).size),this.seriesRect={x:o+k,y:n+w,width:l-o-k-p,height:r-n-S-w};let g=this.seriesRect,C={x:g.x+y,y:g.y+y,width:g.width-y*2,height:g.height-y*2};if(this.isCartesian&&this.xAxis&&this.yAxis){this.xAxis.setTheme(u),this.yAxis.setTheme(u),this.xAxis.getGroup().translation={x:g.x,y:g.y+g.height},this.xAxis.update(g.width,0,m,y),this.yAxis.getGroup().translation={x:g.x-d,y:g.y},this.yAxis.update(g.height,g.width+d,a,y,d),this.yAxisRight&&(this.yAxisRight.getGroup().translation={x:g.x+g.width+d,y:g.y},this.yAxisRight.update(g.height,g.width+d,f,y)),this.seriesGroup.translation={x:g.x,y:g.y},this.seriesGroup.clipRect={x:0,y:0,width:g.width,height:g.height},this.seriesGroup.clear();let A=[],R=this.options.data;this.options.series.forEach((v,B)=>{let _=v.yKey??v.angleKey??`s${B}`;if(this.hiddenSeries.includes(_))return;let D=v.type==="bar"&&v.direction==="horizontal",T=D?this.yAxis?.scale:this.xAxis?.scale,L=v.yAxisId==="right"&&this.yAxisRight?this.yAxisRight.scale:D?this.xAxis?.scale:this.yAxis?.scale,Y=v.type==="line"||v.type==="area",X=`${v.type}-${B}-null`,O=this.seriesInstances.get(X);if(O||(O=this.createSeriesInstance(v,B),O&&this.seriesInstances.set(X,O)),!O)return;A.push(O),this.seriesGroup.add(O.getGroup());let G={x:0,y:0,width:g.width,height:g.height},rt=Y&&R.length>1e3?{...v,marker:{...v.marker,enabled:!1}}:v;if(O instanceof pt){let J=this.options.series.filter(N=>N.type==="bar"),Z,q;if(v.stacked||v.normalized){let N=J.filter(E=>E.stacked||E.normalized),H=N.indexOf(v);Z=R.map(E=>N.slice(0,H).reduce((F,Mt)=>F+(E[Mt.yKey]??0),0)),q=R.map(E=>N.reduce((F,Mt)=>F+(E[Mt.yKey]??0),0))}O.update(R,T,L,G,!0,B,J.length,Z,q,v)}else if(O instanceof ft){let J,Z;if(v.stacked||v.normalized){let q=this.options.series.filter(H=>H.type==="area"&&(H.stacked||H.normalized)),N=q.indexOf(v);J=R.map(H=>q.slice(0,N).reduce((E,F)=>E+(H[F.yKey]??0),0)),Z=R.map(H=>q.reduce((E,F)=>E+(H[F.yKey]??0),0))}O.update(R,T,L,G,!0,J,rt,Z)}else(O instanceof mt||O instanceof gt)&&O.update(R,T,L,G,!0,rt)}),this.series=A}else{this.seriesGroup.translation={x:0,y:0},this.seriesGroup.clipRect={x:g.x-y,y:g.y-y,width:g.width+y*2,height:g.height+y*2},this.seriesGroup.clear();let A=[];this.options.series.forEach((R,v)=>{let B=R.yKey??R.angleKey??`s${v}`;if(this.hiddenSeries.includes(B))return;let _=`${R.type}-${v}-null`,D=this.seriesInstances.get(_);D||(D=this.createSeriesInstance(R,v),D&&this.seriesInstances.set(_,D)),D&&(A.push(D),this.seriesGroup.add(D.getGroup()),D instanceof dt&&D.update(this.options.data,g,t,R))}),this.series=A}}render(){this.scene.render()}exportToPng(t="chart.png"){let i=this.scene.getCanvas().toDataURL("image/png"),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s)}destroy(){this.stopLoop(),this.resizeObserver.disconnect(),this.mediaQuery&&(this.mediaQuery.removeEventListener("change",this._onSystemThemeChange),this.mediaQuery=null),this.container.removeEventListener("keydown",this._onKeyDown),this.container.removeEventListener("pointerleave",this._onPointerLeave),this.scene.destroy(),this.tooltipStore.destroy(),this.legendProxy&&(this.legendProxy.remove(),this.legendProxy=void 0)}};var Rt=require("react"),Bt=(0,Rt.createContext)(null);function qt(){let h=(0,Rt.useContext)(Bt);if(!h)throw new Error("useTooltipStore must be used within a RadiantChart or Chart component. Make sure your component is wrapped in a chart provider.");return h}var fe=["xKey","yKey","labelKey","angleKey","sizeKey"];function ge(h){let t=new Set;for(let e of h)for(let i of fe){let s=e[i];typeof s=="string"&&t.add(s)}return Array.from(t)}var ye=(0,M.forwardRef)(function({options:t,width:e="100%",height:i="100%",className:s,style:n},r){let o=(0,M.useRef)(null),l=(0,M.useRef)(null),y=(0,M.useRef)(null),[u,x]=(0,M.useState)(!1),[c,m]=(0,M.useState)(null);(0,M.useImperativeHandle)(r,()=>({exportToPng(w){l.current?.exportToPng(w)}}),[]);let a=(0,M.useMemo)(()=>({...t,series:t.series||[],data:t.data||[],onFocusChange:w=>m(w)}),[t]);(0,M.useLayoutEffect)(()=>(o.current&&!l.current&&(l.current=new At(o.current,{...a,onFocusChange:w=>m(w)}),y.current=l.current.getTooltipStore()),()=>{l.current?.destroy(),l.current=null}),[]),(0,M.useEffect)(()=>{if(u)return;if(typeof window>"u"){x(!0);return}let w=!1,d=window.requestAnimationFrame(()=>{w||x(!0)});return()=>{w=!0,window.cancelAnimationFrame(d)}},[u]),(0,M.useEffect)(()=>{l.current?.update(a)},[a,u]),(0,M.useEffect)(()=>{l.current?.update(a)},[t.theme]);let[f,b]=(0,M.useState)(()=>ct.resolveIsDark(t.theme));(0,M.useEffect)(()=>{if(t.theme!=="system"||typeof window>"u")return;let w=window.matchMedia("(prefers-color-scheme: dark)"),d=()=>b(w.matches);return b(w.matches),w.addEventListener("change",d),()=>w.removeEventListener("change",d)},[t.theme]);let k=t.theme==="system"?f:t.theme==="dark",p=(0,M.useMemo)(()=>ge(a.series),[a.series]),S=s||"";return M.default.createElement(Bt.Provider,{value:y.current},M.default.createElement("div",{ref:o,"data-radiant-chart":!0,className:S,style:{position:"relative",width:e,height:i,minHeight:typeof i=="number"?void 0:"100px",display:"block",overflow:"hidden",backgroundColor:k?"#020617":"#ffffff",...n}},!u&&M.default.createElement("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",gap:8,padding:"8px 10px 4px 4px",background:k?"#020617":"#ffffff"}},M.default.createElement("div",{style:{height:14,width:"35%",borderRadius:4,background:k?"#1e293b":"#f1f5f9",animation:"radiant-pulse 1.4s ease-in-out infinite"}}),M.default.createElement("div",{style:{flex:1,display:"flex",gap:6,alignItems:"flex-end",paddingTop:8}},[65,45,80,55,70,40,60].map((w,d)=>M.default.createElement("div",{key:d,style:{flex:1,height:`${w}%`,borderRadius:"3px 3px 0 0",background:k?"#1e293b":"#f1f5f9",animation:`radiant-pulse 1.4s ease-in-out ${d*.1}s infinite`}}))),M.default.createElement("div",{style:{height:8,borderRadius:4,background:k?"#1e293b":"#f1f5f9",animation:"radiant-pulse 1.4s ease-in-out infinite"}})),M.default.createElement("style",null,`
2
+ @keyframes radiant-pulse {
3
+ 0%, 100% { opacity: 1; }
4
+ 50% { opacity: 0.4; }
5
+ }
6
+ [data-radiant-chart] .radiant-toolbar { opacity: 0; transition: opacity 0.15s ease; }
7
+ [data-radiant-chart]:hover .radiant-toolbar { opacity: 1; }
8
+ `),t.toolbar?.showExport&&M.default.createElement("div",{className:"radiant-toolbar",style:{position:"absolute",top:8,right:8,zIndex:10,display:"flex",gap:4}},M.default.createElement("button",{type:"button",title:"Export as PNG","aria-label":"Export chart as PNG",onClick:()=>l.current?.exportToPng(t.title?.text?`${t.title.text.replace(/\s+/g,"-").toLowerCase()}.png`:"radiant-chart.png"),style:{display:"flex",alignItems:"center",justifyContent:"center",width:28,height:28,borderRadius:6,border:k?"1px solid rgba(255,255,255,0.12)":"1px solid rgba(0,0,0,0.10)",background:k?"rgba(15,23,42,0.85)":"rgba(255,255,255,0.90)",color:k?"#94a3b8":"#64748b",cursor:"pointer",backdropFilter:"blur(4px)",boxShadow:k?"0 1px 4px rgba(0,0,0,0.4)":"0 1px 4px rgba(0,0,0,0.10)",padding:0,transition:"background 0.15s, color 0.15s"},onMouseEnter:w=>{w.currentTarget.style.background=k?"rgba(30,41,59,0.95)":"rgba(241,245,249,0.98)",w.currentTarget.style.color=k?"#e2e8f0":"#0f172a"},onMouseLeave:w=>{w.currentTarget.style.background=k?"rgba(15,23,42,0.85)":"rgba(255,255,255,0.90)",w.currentTarget.style.color=k?"#94a3b8":"#64748b"}},M.default.createElement("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},M.default.createElement("path",{d:"M8 1v9M5 7l3 3 3-3",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),M.default.createElement("path",{d:"M2 12v1.5A1.5 1.5 0 003.5 15h9A1.5 1.5 0 0014 13.5V12",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})))),p.length>0&&a.data.length>0&&M.default.createElement("table",{className:"sr-only","aria-label":t.title?.text??"Chart data","aria-rowcount":a.data.length+1},M.default.createElement("thead",null,M.default.createElement("tr",{"aria-rowindex":1},p.map(w=>M.default.createElement("th",{key:w,scope:"col"},w)))),M.default.createElement("tbody",null,(()=>{let d=a.data.length,g=c===null?0:Math.max(0,c-Math.floor(10/2)),C=Math.min(d,g+10);return a.data.slice(g,C).map((A,R)=>{let v=g+R;return M.default.createElement("tr",{key:v,"aria-rowindex":v+2,"aria-selected":v===c},p.map(B=>M.default.createElement("td",{key:B},A[B]??"")))})})()))))}),Tt=ye;var Q=Lt(require("react")),be=({width:h="100%",height:t=300,minHeight:e=100,minWidth:i=0,aspect:s,debounce:n=0,className:r,style:o,children:l})=>{let y=(0,Q.useRef)(null),[u,x]=(0,Q.useState)(null),c=(0,Q.useRef)(null),m=(0,Q.useCallback)((b,k)=>{x({width:b,height:k})},[]),a=(0,Q.useCallback)(b=>{for(let k of b){let{width:p,height:S}=k.contentRect;p===0&&S===0||(n>0?(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>m(p,S),n)):m(p,S))}},[n,m]);(0,Q.useLayoutEffect)(()=>{let b=y.current;if(!b)return;let k=b.getBoundingClientRect();(k.width>0||k.height>0)&&m(k.width,k.height);let p=new ResizeObserver(a);return p.observe(b),()=>{p.disconnect(),c.current&&clearTimeout(c.current)}},[a,m]);let f=s&&u?Math.max(e,u.width/s):t;return Q.default.createElement("div",{ref:y,className:r,style:{position:"relative",width:h,height:f,minHeight:e,minWidth:i,overflow:"hidden",...o}},Q.default.createElement("div",{style:{position:"absolute",inset:0}},l))},jt=be;var P=Lt(require("react"));var Ut=(0,P.createContext)(null);function ot(){let h=(0,P.useContext)(Ut);if(!h)throw new Error("Radiant declarative components must be children of <Chart>.");return h}var xe=0;function lt(h){let t=(0,P.useRef)("");return t.current===""&&(t.current=`${h}-${xe++}`),t.current}var Vt=({data:h,theme:t,width:e,height:i,animation:s,padding:n,crosshair:r,tooltip:o,showExport:l,className:y,style:u,chartRef:x,children:c})=>{let m=(0,P.useRef)(new Map),a=(0,P.useRef)(new Map),f=(0,P.useRef)(new Map),b=(0,P.useRef)(new Map),[k,p]=(0,P.useState)(0),S=(0,P.useCallback)(()=>p(g=>g+1),[]),w=(0,P.useMemo)(()=>({registerSeries:(g,C)=>{m.current.set(g,C),S()},unregisterSeries:g=>{m.current.delete(g),S()},registerAxis:(g,C)=>{a.current.set(g,C),S()},unregisterAxis:g=>{a.current.delete(g),S()},registerTitle:(g,C)=>{f.current.set(g,C),S()},unregisterTitle:g=>{f.current.delete(g),S()},registerLegend:(g,C)=>{b.current.set(g,C),S()},unregisterLegend:g=>{b.current.delete(g),S()}}),[S]),d=(0,P.useMemo)(()=>{let g=[];m.current.forEach(E=>{g.push(E)}),g.length===0&&g.push({type:"bar",xKey:"x",yKey:"y"});let C,A,R,v,B,_,D,T,L,Y,X,O,G,rt,J;a.current.forEach(({axis:E,props:F})=>{E==="x"?(C=F.show??!0,v=F.fontSize,B=F.fontFamily,_=F.rotation,D=F.labelAlignment):E==="y"?(A=F.show??!0,T=F.fontSize,L=F.fontFamily,Y=F.rotation,X=F.labelAlignment):E==="y-right"&&(R=F.show??!0,O=F.fontSize,G=F.fontFamily,rt=F.rotation,J=F.labelAlignment)});let Z,q;f.current.forEach(E=>{E.kind==="title"?Z=E.props:q=E.props});let N;b.current.forEach(E=>{N={enabled:E.enabled??!0,position:E.position}});let H;return P.default.Children.forEach(c,E=>{P.default.isValidElement(E)&&E.type===Ct&&(H=E.props)}),{data:h,theme:t,animation:s,padding:n,crosshair:r,tooltip:H?{...o,...H}:o,toolbar:l?{showExport:!0}:void 0,title:Z,subtitle:q,legend:N,showXAxis:C,showYAxis:A,showYAxisRight:R,xAxisFontSize:v,xAxisFontFamily:B,xAxisRotation:_,xAxisLabelAlignment:D,yAxisFontSize:T,yAxisFontFamily:L,yAxisRotation:Y,yAxisLabelAlignment:X,yAxisRightFontSize:O,yAxisRightFontFamily:G,yAxisRightRotation:rt,yAxisRightLabelAlignment:J,series:g}},[h,t,s,n,r,o,l,c,k]);return P.default.createElement(Ut.Provider,{value:w},c,P.default.createElement(Tt,{ref:x,options:d,width:e,height:i,className:y,style:u}))};function ut(h,t){let e=i=>{let s=lt(h),n=ot(),r=(0,P.useMemo)(()=>({type:h,...i}),[JSON.stringify(i)]);return(0,P.useEffect)(()=>(n.registerSeries(s,r),()=>n.unregisterSeries(s)),[n,s,r]),null};return e.displayName=t,e}var Jt=ut("bar","Bar"),Zt=ut("line","Line"),te=ut("area","Area"),ee=ut("scatter","Scatter"),ie=ut("pie","Pie"),se=ut("donut","Donut"),Dt=h=>{let t=lt("x-axis"),e=ot(),i=(0,P.useMemo)(()=>({axis:"x",props:h}),[JSON.stringify(h)]);return(0,P.useEffect)(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};Dt.displayName="XAxis";var Kt=h=>{let t=lt("y-axis"),e=ot(),i=(0,P.useMemo)(()=>({axis:"y",props:h}),[JSON.stringify(h)]);return(0,P.useEffect)(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};Kt.displayName="YAxis";var It=h=>{let t=lt("y-axis-right"),e=ot(),i=(0,P.useMemo)(()=>({axis:"y-right",props:h}),[JSON.stringify(h)]);return(0,P.useEffect)(()=>(e.registerAxis(t,i),()=>e.unregisterAxis(t)),[e,t,i]),null};It.displayName="YAxisRight";var zt=h=>{let t=lt("title"),e=ot(),i=(0,P.useMemo)(()=>({kind:"title",props:h}),[JSON.stringify(h)]);return(0,P.useEffect)(()=>(e.registerTitle(t,i),()=>e.unregisterTitle(t)),[e,t,i]),null};zt.displayName="Title";var Et=h=>{let t=lt("subtitle"),e=ot(),i=(0,P.useMemo)(()=>({kind:"subtitle",props:h}),[JSON.stringify(h)]);return(0,P.useEffect)(()=>(e.registerTitle(t,i),()=>e.unregisterTitle(t)),[e,t,i]),null};Et.displayName="Subtitle";var Xt=h=>{let t=lt("legend"),e=ot(),i=(0,P.useMemo)(()=>({enabled:h.enabled,position:h.position}),[h.enabled,h.position]);return(0,P.useEffect)(()=>(e.registerLegend(t,i),()=>e.unregisterLegend(t)),[e,t,i]),null};Xt.displayName="Legend";var Ct=()=>null;Ct.displayName="Tooltip";var Ot=require("react");function ne(){let h=qt(),t=(0,Ot.useSyncExternalStore)(h.subscribe.bind(h),h.getState.bind(h),()=>h.getState()),e=(0,Ot.useCallback)(()=>h.hide(),[h]);return{active:t.active,entries:t.entries,sharedLabel:t.sharedLabel,pointerX:t.pointerX,pointerY:t.pointerY,anchorX:t.anchorX,anchorY:t.anchorY,localX:t.localX,localY:t.localY,hide:e}}0&&(module.exports={Area,Bar,Chart,Donut,Legend,Line,Pie,RadiantChart,ResponsiveContainer,Scatter,Subtitle,Title,Tooltip,XAxis,YAxis,YAxisRight,useChartTooltip});
9
+ //# sourceMappingURL=index.js.map