uplot-plus 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -62
- package/dist/components/annotations/HLine.d.ts.map +1 -1
- package/dist/core/CursorManager.d.ts.map +1 -1
- package/dist/hooks/useChartStore.d.ts.map +1 -1
- package/dist/hooks/useDrawHook.d.ts +12 -0
- package/dist/hooks/useDrawHook.d.ts.map +1 -1
- package/dist/hooks/useInteraction.d.ts.map +1 -1
- package/dist/hooks/useStreamingData.d.ts +14 -1
- package/dist/hooks/useStreamingData.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1246 -1164
- package/dist/rendering/CanvasRenderer.d.ts +12 -1
- package/dist/rendering/CanvasRenderer.d.ts.map +1 -1
- package/dist/rendering/drawAxes.d.ts.map +1 -1
- package/dist/rendering/drawBands.d.ts +7 -3
- package/dist/rendering/drawBands.d.ts.map +1 -1
- package/dist/rendering/drawSeries.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
High-performance React charting library ripped off from uPlot. Might perform occasionally better than original uPlot in React context (or worse). Definitely easier to use in React context.
|
|
4
4
|
|
|
5
|
-
**[Live Demo (85+ examples)](https://yeonsoo-p.github.io/
|
|
5
|
+
**[Live Demo (85+ examples)](https://yeonsoo-p.github.io/uPlot-Plus/)**
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
@@ -232,67 +232,18 @@ Sliding-window data management for real-time charts:
|
|
|
232
232
|
```tsx
|
|
233
233
|
import { useStreamingData } from 'uplot-plus';
|
|
234
234
|
|
|
235
|
-
const { data, push, start, stop, fps } = useStreamingData(initialData, {
|
|
235
|
+
const { data, push, pushGroup, start, stop, fps } = useStreamingData(initialData, {
|
|
236
236
|
window: 1000, // keep last 1000 points
|
|
237
237
|
batchSize: 10, // push 10 points per tick
|
|
238
238
|
});
|
|
239
239
|
|
|
240
|
-
//
|
|
240
|
+
// Push into group 0 (default):
|
|
241
241
|
push([newX], [newY1], [newY2]);
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
## Axis Value Formatters
|
|
245
242
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
```tsx
|
|
249
|
-
import { fmtCompact, fmtSuffix, fmtHourMin, fmtMonthName, fmtLabels } from 'uplot-plus';
|
|
250
|
-
|
|
251
|
-
<Axis scale="y" values={fmtCompact()} /> // 1.2K, 3.5M
|
|
252
|
-
<Axis scale="y" values={fmtSuffix('%')} /> // 42%
|
|
253
|
-
<Axis scale="y" values={fmtSuffix('°C', 1)} /> // 23.5°C
|
|
254
|
-
<Axis scale="x" values={fmtHourMin({ utc: true })} /> // 14:30
|
|
255
|
-
<Axis scale="x" values={fmtMonthName()} /> // Jan, Feb, ...
|
|
256
|
-
<Axis scale="x" values={fmtLabels(['Q1','Q2','Q3','Q4'])} />
|
|
243
|
+
// Push into a specific group (for multi-x-axis charts):
|
|
244
|
+
pushGroup(1, [newX], [newY1]);
|
|
257
245
|
```
|
|
258
246
|
|
|
259
|
-
## Color Utilities
|
|
260
|
-
|
|
261
|
-
```tsx
|
|
262
|
-
import { fadeGradient, withAlpha, palette } from 'uplot-plus';
|
|
263
|
-
|
|
264
|
-
// Gradient that fades from color to transparent (for area fills)
|
|
265
|
-
<Series fill={fadeGradient('#3498db')} />
|
|
266
|
-
<Series fill={fadeGradient('#e74c3c', 1.0, 0.2)} />
|
|
267
|
-
|
|
268
|
-
// Match fill to stroke with lower opacity
|
|
269
|
-
<Series stroke="#2980b9" fill={withAlpha('#2980b9', 0.1)} />
|
|
270
|
-
|
|
271
|
-
// Generate N distinct colors
|
|
272
|
-
const colors = palette(5); // 5 visually distinct HSL colors
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
## Data Utilities
|
|
276
|
-
|
|
277
|
-
### `stackGroup`
|
|
278
|
-
|
|
279
|
-
Computes stacked series values and generates band configs:
|
|
280
|
-
|
|
281
|
-
```tsx
|
|
282
|
-
import { stackGroup, Band } from 'uplot-plus';
|
|
283
|
-
|
|
284
|
-
const raw = { x: [1, 2, 3], series: [[10, 20, 30], [5, 10, 15]] };
|
|
285
|
-
const { group, bands } = stackGroup(raw);
|
|
286
|
-
|
|
287
|
-
<Chart data={[group]}>
|
|
288
|
-
{bands.map((b, i) => <Band key={i} {...b} />)}
|
|
289
|
-
</Chart>
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### `alignData`
|
|
293
|
-
|
|
294
|
-
Aligns data across multiple x-axes for multi-group charts.
|
|
295
|
-
|
|
296
247
|
## Annotations
|
|
297
248
|
|
|
298
249
|
Declarative annotation components — place inside `<Chart>`:
|
|
@@ -315,16 +266,16 @@ Imperative helpers are available for advanced draw hooks that need programmatic
|
|
|
315
266
|
import { drawHLine, drawVLine, drawLabel, drawRegion } from 'uplot-plus';
|
|
316
267
|
```
|
|
317
268
|
|
|
318
|
-
##
|
|
269
|
+
## Utilities
|
|
319
270
|
|
|
320
|
-
|
|
271
|
+
| Category | Functions |
|
|
272
|
+
| ---------- | ----------- |
|
|
273
|
+
| Axis formatters | `fmtCompact`, `fmtSuffix`, `fmtHourMin`, `fmtMonthName`, `fmtDateStr`, `fmtLabels` |
|
|
274
|
+
| Color helpers | `fadeGradient`, `withAlpha`, `palette` |
|
|
275
|
+
| Data transforms | `stackGroup`, `alignData` |
|
|
276
|
+
| Scale math | `valToPos`, `posToVal` |
|
|
321
277
|
|
|
322
|
-
|
|
323
|
-
import { valToPos, posToVal } from 'uplot-plus';
|
|
324
|
-
|
|
325
|
-
const px = valToPos(dataValue, scale, dimension, offset);
|
|
326
|
-
const val = posToVal(pixelPos, scale, dimension, offset);
|
|
327
|
-
```
|
|
278
|
+
> Full API, signatures, and examples: [docs/UTILITIES.md](docs/UTILITIES.md)
|
|
328
279
|
|
|
329
280
|
## Development
|
|
330
281
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HLine.d.ts","sourceRoot":"","sources":["../../../src/components/annotations/HLine.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HLine.d.ts","sourceRoot":"","sources":["../../../src/components/annotations/HLine.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CA6B7C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CursorManager.d.ts","sourceRoot":"","sources":["../../src/core/CursorManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACxE,YAAY,EAAE;QAAE,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;KAAE,CAAC;IAClH,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,KAAK,EAAE,WAAW,CAMhB;IAEF,wCAAwC;IACxC,IAAI,IAAI,IAAI;IAQZ;;;;;;;;;OASG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,EACb,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,YAAY,EAAE,EAC7B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,EAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EACjD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC1D,IAAI;
|
|
1
|
+
{"version":3,"file":"CursorManager.d.ts","sourceRoot":"","sources":["../../src/core/CursorManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIpD,4EAA4E;AAC5E,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,CAAC;IACxE,YAAY,EAAE;QAAE,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAA;KAAE,CAAC;IAClH,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,aAAa;IACxB,KAAK,EAAE,WAAW,CAMhB;IAEF,wCAAwC;IACxC,IAAI,IAAI,IAAI;IAQZ;;;;;;;;;OASG;IACH,MAAM,CACJ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,EACb,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,YAAY,EAAE,EAC7B,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,EAChD,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,EACjD,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GAC1D,IAAI;IAyGP;;;OAGG;IACH,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI;CA6CnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChartStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useChartStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAA6B,MAAM,6BAA6B,CAAC;AAQxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAe,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAsBtD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAEzB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAG7B,WAAW,EAAE,WAAW,CAAC;IAGzB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAC;IAG1B,UAAU,EAAE,SAAS,EAAE,CAAC;IAGxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IAGd,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAGjC,SAAS,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAG3B,SAAS,EAAE,eAAe,CAAC;IAG3B,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7B,eAAe,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAGzC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IAGnB,QAAQ,EAAE,MAAM,CAAC;IAGjB,cAAc,EAAE,cAAc,CAAC;IAG/B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAG5D,aAAa,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,cAAc,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,
|
|
1
|
+
{"version":3,"file":"useChartStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useChartStore.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAA6B,MAAM,6BAA6B,CAAC;AAQxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,OAAO,KAAK,EAAe,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAsBtD;;;;GAIG;AACH,MAAM,WAAW,UAAU;IAEzB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,QAAQ,EAAE,cAAc,CAAC;IACzB,aAAa,EAAE,aAAa,CAAC;IAG7B,WAAW,EAAE,WAAW,CAAC;IAGzB,YAAY,EAAE,WAAW,EAAE,CAAC;IAC5B,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,WAAW,EAAE,UAAU,EAAE,CAAC;IAG1B,UAAU,EAAE,SAAS,EAAE,CAAC;IAGxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,IAAI,CAAC;IAGd,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAGjC,SAAS,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAG3B,SAAS,EAAE,eAAe,CAAC;IAG3B,SAAS,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;IAC7B,eAAe,EAAE,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAGzC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,uDAAuD;IACvD,UAAU,EAAE,MAAM,CAAC;IACnB,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IAGnB,QAAQ,EAAE,MAAM,CAAC;IAGjB,cAAc,EAAE,cAAc,CAAC;IAG/B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAG5D,aAAa,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAC;IAC1C,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,cAAc,EAAE,CAAC,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;IAC5C,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAC1C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAkX7C;AAwBD;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAM1C"}
|
|
@@ -9,6 +9,18 @@ export declare function useDrawHook(fn: DrawCallback): void;
|
|
|
9
9
|
* Register a draw callback that fires on the cursor overlay
|
|
10
10
|
* (redrawn every frame, including cursor-only fast path).
|
|
11
11
|
* Uses a ref wrapper so the callback can be an inline function.
|
|
12
|
+
*
|
|
13
|
+
* **Performance note:** This callback fires on *every* cursor move frame
|
|
14
|
+
* (60-120 Hz). Keep the callback cheap. If your drawing is expensive,
|
|
15
|
+
* cache previous cursor state and skip redundant work:
|
|
16
|
+
* ```ts
|
|
17
|
+
* const lastIdx = useRef(-1);
|
|
18
|
+
* useCursorDrawHook((dc, cursor) => {
|
|
19
|
+
* if (cursor.activeDataIdx === lastIdx.current) return;
|
|
20
|
+
* lastIdx.current = cursor.activeDataIdx;
|
|
21
|
+
* // expensive drawing here
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
12
24
|
*/
|
|
13
25
|
export declare function useCursorDrawHook(fn: CursorDrawCallback): void;
|
|
14
26
|
//# sourceMappingURL=useDrawHook.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrawHook.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrawHook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGvE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAYlD;AAED
|
|
1
|
+
{"version":3,"file":"useDrawHook.d.ts","sourceRoot":"","sources":["../../src/hooks/useDrawHook.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGvE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAYlD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,GAAG,IAAI,CAY9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInteraction.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteraction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAWlD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,cAAc,GAAG,IAAI,GACjC,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"useInteraction.d.ts","sourceRoot":"","sources":["../../src/hooks/useInteraction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAWlD;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,UAAU,EACjB,WAAW,EAAE,cAAc,GAAG,IAAI,GACjC,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,WAAW,GAAG,MAAM,IAAI,CAqjB/E"}
|
|
@@ -11,11 +11,21 @@ export interface StreamingResult {
|
|
|
11
11
|
/** Current chart data (pass to <Chart data={...}>) */
|
|
12
12
|
data: ChartData;
|
|
13
13
|
/**
|
|
14
|
-
* Push new data points. Oldest points beyond the window are dropped.
|
|
14
|
+
* Push new data points into group 0. Oldest points beyond the window are dropped.
|
|
15
|
+
* Multiple calls within the same animation frame are batched into a single React update.
|
|
15
16
|
* @param x - new x values
|
|
16
17
|
* @param ySeries - one array of new y values per series
|
|
17
18
|
*/
|
|
18
19
|
push: (x: number[], ...ySeries: number[][]) => void;
|
|
20
|
+
/**
|
|
21
|
+
* Push new data points into a specific group. Oldest points beyond the window are dropped.
|
|
22
|
+
* Other groups are preserved unchanged.
|
|
23
|
+
* Multiple calls within the same animation frame are batched into a single React update.
|
|
24
|
+
* @param group - target group index
|
|
25
|
+
* @param x - new x values
|
|
26
|
+
* @param ySeries - one array of new y values per series
|
|
27
|
+
*/
|
|
28
|
+
pushGroup: (group: number, x: number[], ...ySeries: number[][]) => void;
|
|
19
29
|
/** Start the rAF loop (calls the onTick callback each frame) */
|
|
20
30
|
start: () => void;
|
|
21
31
|
/** Stop the rAF loop */
|
|
@@ -30,6 +40,9 @@ export interface StreamingResult {
|
|
|
30
40
|
*
|
|
31
41
|
* Manages a requestAnimationFrame loop and FPS counter.
|
|
32
42
|
* Call `push()` from your own tick callback, or use it standalone.
|
|
43
|
+
*
|
|
44
|
+
* Multiple push() calls within the same animation frame are batched
|
|
45
|
+
* into a single React state update, avoiding redundant re-renders.
|
|
33
46
|
*/
|
|
34
47
|
export declare function useStreamingData(initialData: ChartData, options: StreamingOptions): StreamingResult;
|
|
35
48
|
//# sourceMappingURL=useStreamingData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStreamingData.d.ts","sourceRoot":"","sources":["../../src/hooks/useStreamingData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,IAAI,EAAE,SAAS,CAAC;IAChB
|
|
1
|
+
{"version":3,"file":"useStreamingData.d.ts","sourceRoot":"","sources":["../../src/hooks/useStreamingData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,sDAAsD;IACtD,IAAI,EAAE,SAAS,CAAC;IAChB;;;;;OAKG;IACH,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,IAAI,CAAC;IACpD;;;;;;;OAOG;IACH,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,KAAK,IAAI,CAAC;IACxE,gEAAgE;IAChE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,wBAAwB;IACxB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,sCAAsC;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;CACb;AAOD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,SAAS,EACtB,OAAO,EAAE,gBAAgB,GACxB,eAAe,CAyIjB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("react/jsx-runtime"),z=require("react");var $=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))($||{}),H=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(H||{}),Y=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(Y||{}),O=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(O||{}),me=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(me||{});function he(e){return e%2}var q=(e=>(e[e.None=0]="None",e[e.Scales=1]="Scales",e[e.Axes=2]="Axes",e[e.Paths=4]="Paths",e[e.Cursor=8]="Cursor",e[e.Select=16]="Select",e[e.Size=32]="Size",e[e.Full=63]="Full",e))(q||{});const N=Math,ze=N.PI,fe=N.abs,te=N.floor,B=N.round,ye=N.ceil,Oe=N.min,Me=N.max,pe=N.pow,Ue=N.sign,Z=N.log10,xe=N.log2,Tt=(e,t=1)=>N.sinh(e)*t,Ge=(e,t=1)=>N.asinh(e/t),U=1/0,rt=Number.isInteger;function Fe(e,t){return e[t]??0}function ie(e,t,n=0,s=t.length-1){let o;const i=s<=2147483647;for(;s-n>1;)o=i?n+s>>1:te((n+s)/2),Fe(t,o)<e?n=o:s=o;return e-Fe(t,n)<=Fe(t,s)-e?n:s}const at=e=>e!=null,ct=e=>e!=null&&e>0;function ut(e){return(t,n,s)=>{let o=-1,i=-1;for(let l=n;l<=s;l++)if(e(t[l])){o=l;break}for(let l=s;l>=n;l--)if(e(t[l])){i=l;break}return[o,i]}}const Ae=ut(at),ft=ut(ct);function It(e,t,n,s=me.Unsorted,o=!1){const i=o?ft:Ae,l=o?ct:at,[r,a]=i(e,t,n);let c=e[r]??U,u=e[r]??-U;if(r>-1)if(s===me.Ascending)c=e[r]??U,u=e[a]??-U;else if(s===me.Descending)c=e[a]??U,u=e[r]??-U;else for(let h=r;h<=a;h++){const f=e[h];f!=null&&l(f)&&(f<c?c=f:f>u&&(u=f))}return[c,u]}function re(e,t=0){if(rt(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return B(s)/n}const we=new Map;function At(e){return(String(e).split(".")[1]??"").length}const Pt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(rt(e)||we.has(e))return e;const t=`${e}`,n=t.match(Pt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const o=t.split("e"),i=o[0]??"0",l=o[1]??"0";return+`${ke(+i)}e${l}`}return re(e,s)}function He(e,t,n=!0){return n?ke(ye(ke(e/t))*t):ye(e/t)*t}function ht(e,t,n=!0){return n?ke(te(ke(e/t))*t):te(e/t)*t}function dt(e,t,n,s){const o=[],i=s.map(At);for(let l=t;l<n;l++){const r=fe(l);for(let a=0;a<s.length;a++){const c=s[a]??0,u=i[a]??0,h=+`${c}e${l}`,f=(l>=0?0:r)+(l>=u?0:u),d=h;o.push(d),we.set(d,f)}}return o}const Lt=new Intl.NumberFormat,gt=e=>Lt.format(e),Rt=.1,se={mode:3,pad:Rt,soft:null},be={pad:0,soft:null,mode:0},Dt={min:be,max:be};function Se(e,t,n,s){let o;typeof n=="number"?(be.pad=n,be.soft=null,be.mode=0,o=Dt):o=n;const i=o.min,l=o.max,r=i.pad,a=l.pad,c=i.hard??-U,u=l.hard??U,h=i.soft??U,f=l.soft??-U,d=i.mode,y=l.mode;let M=t-e;const p=Z(M),g=Me(fe(e),fe(t)),I=Z(g),L=fe(I-p);(M<1e-24||L>10)&&(M=0,(e===0||t===0)&&(M=1e-24));const P=M||g||1e3,T=Z(P),S=pe(10,te(T)),w=P*(M===0?e===0?.1:1:r),b=re(ht(e-w,S/10),24),k=e>=h&&(d===1||d===3&&b<=h||d===2&&b>=h)?h:U,D=Me(c,b<k&&e>=k?k:Oe(k,b)),m=P*(M===0?t===0?.1:1:a),x=re(He(t+m,S/10),24),v=t<=f&&(y===1||y===3&&x>=f||y===2&&x<=f)?f:-U,C=Oe(u,x>v&&t<=v?v:Me(v,x));return D===C&&D===0?[0,100]:[D,C]}function zt(e,t,n,s){n===2&&(s=!0);const o=Ue(e),i=Ue(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?Z:xe,r=o===1?te:ye,a=i===1?ye:te,c=l(fe(e)),u=l(fe(t)),h=r(c),f=a(u);let d=pe(n,h),y=pe(n,f);return n===10&&(h<0&&(d=re(d,-h)),f<0&&(y=re(y,-f))),s?(e=d*o,t=y*i):(e=ht(e,pe(n,te(c)),!1),t=He(t,pe(n,te(u)),!1)),[e,t]}function Ne(e){return(Z((e^e>>31)-(e>>31))|0)+1}function Ft(e,t,n,s,o){const i=Me(Ne(e),Ne(t)),l=t-e;let r=Me(0,ie(o/s*l,n)-1);do{const a=n[r]??0,c=s*a/l;if(c>=o*.9&&i+(a<5?we.get(a)??0:0)<=17)return[a,c]}while(++r<n.length);return[0,0]}function Et(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??O.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?H.Horizontal:H.Vertical),dir:e.dir??Y.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_min:null,_max:null}}function le(e){e._min=null,e._max=null}function pt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===O.Log){const s=t>0?t:1e-10;e._min=(e.log===10?Z:xe)(s)}else n===O.Asinh?e._min=Ge(t,e.asinh):e._min=t;return e._min}function mt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===O.Log){const s=t>0?t:1e-10;e._max=(e.log===10?Z:xe)(s)}else n===O.Asinh?e._max=Ge(t,e.asinh):e._max=t;return e._max}function _t(e,t){if(t.min==null||t.max==null)return 0;const n=pt(t),o=mt(t)-n;if(o===0)return 0;const{distr:i}=t;if(i===O.Log){const l=t.log===10?Z:xe,r=e>0?e:1e-10;return(l(r)-n)/o}return i===O.Asinh?(Ge(e,t.asinh)-n)/o:(e-n)/o}function Gt(e,t){if(t.min==null||t.max==null)return 0;const n=pt(t),s=mt(t);if(s===n)return t.min;const{distr:o}=t;return o===O.Log?Math.pow(t.log,n+e*(s-n)):o===O.Asinh?Tt(n+e*(s-n),t.asinh):n+e*(s-n)}function V(e,t,n,s){const o=_t(e,t);let i;return t.ori===H.Horizontal?i=t.dir===Y.Forward?o:1-o:i=t.dir===Y.Forward?1-o:o,s+i*n}function ee(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===H.Horizontal?t.dir===Y.Backward&&(o=1-o):t.dir!==Y.Backward&&(o=1-o),Gt(o,t)}class Ht{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,Et(t))}removeScale(t){this.scales.delete(t)}getScale(t){return this.scales.get(t)}getAllScales(){return this.scales.values()}setGroupXScale(t,n){this.groupXScales.set(t,n)}getGroupXScaleKey(t){return this.groupXScales.get(t)}setRange(t,n,s){const o=this.scales.get(t);o&&(o.min=n,o.max=s,le(o))}autoRangeX(t){var s,o,i,l,r,a;const n=new Map;for(const[c,u]of this.groupXScales){const h=this.scales.get(u);if(!h||!h.auto)continue;const f=t[c];if(!f||f.x.length===0)continue;const d=f.x[0],y=f.x[f.x.length-1];if(d==null||y==null)continue;const M=n.get(u);M?(M.dataMin=Math.min(M.dataMin,d),M.dataMax=Math.max(M.dataMax,y)):n.set(u,{dataMin:d,dataMax:y})}for(const[c,{dataMin:u,dataMax:h}]of n){const f=this.scales.get(c);if(f){if(f.range){const[d,y]=Se(u,h,{min:{pad:((s=f.range.min)==null?void 0:s.pad)??0,soft:((o=f.range.min)==null?void 0:o.soft)??null,mode:((i=f.range.min)==null?void 0:i.mode)??0},max:{pad:((l=f.range.max)==null?void 0:l.pad)??0,soft:((r=f.range.max)==null?void 0:r.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=d,f.max=y}else u===h?[f.min,f.max]=Se(u,h,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(f.min=u,f.max=h);le(f)}}}autoRange(t,n,s){var r,a,c,u,h,f,d,y,M,p,g,I;const o=new Map;for(const[L,P]of this.groupXScales){const T=this.scales.get(P);if(!T||!T.auto)continue;const S=t[L];if(!S||S.x.length===0)continue;const w=S.x[0],b=S.x[S.x.length-1];if(w==null||b==null)continue;const k=o.get(P);k?(k.dataMin=Math.min(k.dataMin,w),k.dataMax=Math.max(k.dataMax,b)):o.set(P,{dataMin:w,dataMax:b})}for(const[L,{dataMin:P,dataMax:T}]of o){const S=this.scales.get(L);if(S){if(S.range){const[w,b]=Se(P,T,{min:{pad:((r=S.range.min)==null?void 0:r.pad)??0,soft:((a=S.range.min)==null?void 0:a.soft)??null,mode:((c=S.range.min)==null?void 0:c.mode)??0},max:{pad:((u=S.range.max)==null?void 0:u.pad)??0,soft:((h=S.range.max)==null?void 0:h.soft)??null,mode:((f=S.range.max)==null?void 0:f.mode)??0}});S.min=w,S.max=b}else P===T?[S.min,S.max]=Se(P,T,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(S.min=P,S.max=T);le(S)}}const i=new Map,l=new Map;for(const{group:L,index:P,yScale:T}of n){const S=t[L];if(!S)continue;const w=S.series[P];if(!w||w.length===0)continue;const b=s.windows.get(L),k=b?b[0]:0,D=b?b[1]:w.length-1,m=this.scales.get(T),x=(m==null?void 0:m.distr)===O.Log,[v,C]=s.getCachedMinMax(L,P,k,D,0,x),R=i.get(T),A=l.get(T);i.set(T,R!=null?Math.min(R,v):v),l.set(T,A!=null?Math.max(A,C):C)}for(const[L,P]of i){const T=this.scales.get(L);if(!T||!T.auto)continue;const S=l.get(L)??-U;if(P===U)continue;let w,b;if(T.distr===O.Log)[w,b]=zt(P,S,T.log,!1);else{const k=T.range??{min:se,max:se};[w,b]=Se(P,S,{min:{pad:((d=k.min)==null?void 0:d.pad)??se.pad,soft:((y=k.min)==null?void 0:y.soft)??se.soft,mode:((M=k.min)==null?void 0:M.mode)??se.mode},max:{pad:((p=k.max)==null?void 0:p.pad)??se.pad,soft:((g=k.max)==null?void 0:g.soft)??se.soft,mode:((I=k.max)==null?void 0:I.mode)??se.mode}})}T.min=w,T.max=b,le(T)}}}const Vt=1024;class Bt{constructor(t,n=Vt){this.data=t,this.len=t.length,this.blockSize=n,this.nBlocks=Math.ceil(t.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:t,blockSize:n,nBlocks:s,blocks:o,len:i}=this;for(let l=0;l<s;l++){const r=l*n,a=Math.min(r+n,i);let c=1/0,u=-1/0;for(let h=r;h<a;h++){const f=t[h];f!=null&&(f<c&&(c=f),f>u&&(u=f))}o[l*2]=c,o[l*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:i}=this;let l=1/0,r=-1/0;const a=Math.floor(t/o),c=Math.floor(n/o);if(a===c){for(let f=t;f<=n;f++){const d=s[f];d!=null&&(d<l&&(l=d),d>r&&(r=d))}return[l,r]}const u=(a+1)*o-1;for(let f=t;f<=u;f++){const d=s[f];d!=null&&(d<l&&(l=d),d>r&&(r=d))}for(let f=a+1;f<c;f++){const d=i[f*2]??1/0,y=i[f*2+1]??-1/0;d<l&&(l=d),y>r&&(r=y)}const h=c*o;for(let f=h;f<=n;f++){const d=s[f];d!=null&&(d<l&&(l=d),d>r&&(r=d))}return[l,r]}updateBlock(t){const{data:n,blockSize:s,blocks:o,len:i}=this;if(t>=this.nBlocks)return;const l=t*s,r=Math.min(l+s,i);let a=1/0,c=-1/0;for(let u=l;u<r;u++){const h=n[u];h!=null&&(h<a&&(a=h),h>c&&(c=h))}o[t*2]=a,o[t*2+1]=c}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const o=new Float64Array(this.nBlocks*2);o.set(this.blocks),this.blocks=o}const s=Math.max(0,n-1);for(let o=s;o<this.nBlocks;o++)this.updateBlock(o)}setData(t){this.data=t}}class Wt{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(t){this.data=t,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(t,n){const s=`${t}:${n}`;let o=this.blockTrees.get(s);if(o)return o;const i=this.data[t];if(!i)return;const l=i.series[n];if(!(!l||l.length===0))return o=new Bt(l),this.blockTrees.set(s,o),o}updateWindows(t){var s;let n=!1;for(let o=0;o<this.data.length;o++){const i=this.data[o],l=t(o),r=this.windows.get(o);let a,c;if(!i||!l||l.min==null||l.max==null)a=0,c=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,c=0;else{a=ie(l.min,u),c=ie(l.max,u);const h=u[a],f=u[c];a>0&&h!=null&&h>l.min&&a--,c<u.length-1&&f!=null&&f<l.max&&c++}}(!r||r[0]!==a||r[1]!==c)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,c])}return n}getWindow(t){var n;return this.windows.get(t)??[0,(((n=this.data[t])==null?void 0:n.x.length)||1)-1]}getXValues(t){var n;return((n=this.data[t])==null?void 0:n.x)??[]}getYValues(t,n){var s;return((s=this.data[t])==null?void 0:s.series[n])??[]}getCachedMinMax(t,n,s,o,i,l){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${o}`;if(r){const d=r.get(a);if(d!=null)return d}else r=new Map,this.minMaxCache.set(t,r);const c=this.data[t];if(!c)return[1/0,-1/0];const u=c.series[n];if(!u||u.length===0)return[1/0,-1/0];let h;const f=!l&&i===me.Unsorted?this.getOrBuildTree(t,n):void 0;return f?h=f.rangeMinMax(s,o):h=It(u,s,o,i,l),r.set(a,h),h}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var l;const o=this.data[t];if(!o)return;const i=o.x;if(Array.isArray(i)){for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<o.series.length;r++){const a=o.series[r];if(!a||!Array.isArray(a))continue;const c=s[r];if(c)for(let h=0;h<c.length;h++)a.push(c[h]??null);const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(l=this.minMaxCache.get(t))==null||l.clear()}}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class jt{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1}}hide(){this.state.left=-10,this.state.top=-10,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,o,i,l,r,a){this.state.left=t,this.state.top=n;let c=1/0,u=-1,h=-1,f=-1;for(let d=0;d<o.length;d++){const y=o[d];if(y==null)continue;const M=y.x;if(M.length===0)continue;const p=a(d);if(p==null)continue;const g=l(p);if(g==null||g.min==null||g.max==null)continue;const[I,L]=r(d),P=s.width,T=s.left,S=ee(t+T,g,P,T),w=ie(S,M,I,L),b=[w];w>I&&b.push(w-1),w<L&&b.push(w+1);const k=new Map;for(const D of b){const m=M[D];if(m==null)continue;const x=V(m,g,P,T);for(const v of i){if(v.group!==d||v.show===!1)continue;const C=y.series[v.index];if(C==null)continue;const R=C[D];if(R==null)continue;let A=k.get(v.yScale);if(A==null&&!k.has(v.yScale)&&(A=l(v.yScale),k.set(v.yScale,A)),A==null||A.min==null||A.max==null)continue;const F=s.height,E=s.top,G=V(R,A,F,E),W=t+T-x,X=n+E-G,j=W*W+X*X;if(j<c&&(c=j,u=d,h=v.index,f=D,j===0))break}if(c===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=h,this.state.activeDataIdx=f}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const o=s[0];if(o==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const l=n.scaleManager.getScale(i);if(l==null||l.min==null||l.max==null)return;const[r,a]=n.dataStore.getWindow(0),c=ie(t,o.x,r,a),u=o.x[c];if(u==null)return;const h=V(u,l,n.plotBox.width,n.plotBox.left);this.state.left=h-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=c;let f=0,d=n.plotBox.height/2;for(const y of n.seriesConfigs){if(y.group!==0||y.show===!1)continue;const M=o.series[y.index];if(M==null)continue;const p=M[c];if(p==null)continue;const g=n.scaleManager.getScale(y.yScale);if(!(g==null||g.min==null||g.max==null)){d=V(p,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,f=y.index;break}}this.state.top=d,this.state.activeSeriesIdx=f}}class Xt{constructor(){this.flags=q.None,this.frameId=null,this.callback=null}mark(t){this.flags|=t,this.scheduleFrame()}has(t){return(this.flags&t)!==0}get dirty(){return this.flags}clear(){this.flags=q.None}onRedraw(t){this.callback=t}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const t=this.callback;t!=null&&t(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=q.None}}function Pe(e,t,n){e.lineTo(t,n)}function Le(e,t,n){e.lineTo(n,t)}function Ve(e,t,n,s,o,i){const l=[];let r=-1;const a=o===Y.Forward?n:s,c=o===Y.Forward?s:n,u=o;for(let h=a;o===Y.Forward?h<=c:h>=c;h+=u)if(t[h]===null||t[h]===void 0){if(r===-1){const f=Math.max(n,Math.min(h-o,s));r=i(e[f])}}else r!==-1&&(l.push([r,i(e[h])]),r=-1);return r!==-1&&l.push([r,i(e[s])]),l}function Be(e,t,n,s,o,i){const l=new Path2D;let r=t===H.Horizontal?n:s;const a=t===H.Horizontal?n+o:s+i,c=t===H.Horizontal?s:n,u=t===H.Horizontal?i:o;for(const[h,f]of e)h>r&&(t===H.Horizontal?l.rect(r,c,h-r,u):l.rect(c,r,u,h-r)),r=f;return r<a&&(t===H.Horizontal?l.rect(r,c,a-r,u):l.rect(c,r,u,a-r)),l}function wt(e){return(t,n,s,o,i,l)=>{s!==o&&(i!==s&&l!==s&&e(t,n,s),i!==o&&l!==o&&e(t,n,o),e(t,n,l))}}const $t=wt(Pe),Yt=wt(Le);function xt(){return(e,t,n,s,o,i,l,r,a,c,u,h,f)=>{const d=(f==null?void 0:f.spanGaps)??!1;if([a,c]=(s.distr===O.Log?ft:Ae)(t,a,c),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=w=>h(V(w,n,o,l)),p=w=>h(V(w,s,i,r));let g,I;n.ori===H.Horizontal?(g=Pe,I=$t):(g=Le,I=Yt);const L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},P=L.stroke;let T=!1;if(c-a>=o*4){const w=A=>ee(A,n,o,l);let b=null,k=0,D=0,m=0,x=M(e[u===Y.Forward?a:c]);const v=M(e[a]),C=M(e[c]);let R=w(u===Y.Forward?v+1:C-1);for(let A=u===Y.Forward?a:c;A>=a&&A<=c;A+=u){const F=e[A],G=(u===Y.Forward?F<R:F>R)?x:M(F),W=t[A];G===x?W!=null?(m=W,b==null?(g(P,G,p(m)),D=b=k=m):m<b?b=m:m>k&&(k=m)):W===null&&!d&&(T=!0):(b!=null&&I(P,x,p(b),p(k),p(D),p(m)),W!=null?(m=W,g(P,G,p(m)),b=k=D=m):(b=null,k=0,W===null&&!d&&(T=!0)),x=G,R=w(x+u))}b!=null&&(b!==k?I(P,x,p(b),p(k),p(D),p(m)):g(P,x,p(m)))}else for(let w=u===Y.Forward?a:c;w>=a&&w<=c;w+=u){const b=t[w];b===null&&!d?T=!0:b!=null&&g(P,M(e[w]),p(b))}{const w=L.fill=new Path2D(P),b=(f==null?void 0:f.fillTo)??s.min??0,k=p(b);let D=l,m=l+o;u===Y.Backward&&([m,D]=[D,m]),g(w,m,k),g(w,D,k)}if(T){const w=Ve(e,t,a,c,u,M);L.gaps=w,L.clip=Be(w,n.ori,l,r,o,i)}return L}}function Ke(e,t,n){return typeof t=="string"?t:Ot(e,t,n)}function Ot(e,t,n){const s=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[o,i]of t.stops)s.addColorStop(o,i);return s}function Ut(e,t,n,s,o){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const l=o??{top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=Ke(e,t.fill,l),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=Ke(e,t.stroke,l),e.lineWidth=r,e.lineJoin=t.join??"round",e.lineCap=t.cap??"butt",t.dash&&e.setLineDash(t.dash.map(h=>h*s));const a=t.pxAlign??1,c=r%2/2;a===1&&c>0&&e.translate(c,c),e.stroke(n.stroke)}e.restore()}const Nt=xt(),qe=64;class Kt{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.lruOrder=[],this.snapshotCanvas=null,this.snapshotValid=!1,this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setContext(t,n){this.ctx=t,this.pxRatio=n,this.resetPropertyCache()}resetPropertyCache(){this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setFillStyle(t,n){n!==this.cachedFillStyle&&(t.fillStyle=n,this.cachedFillStyle=n)}setStrokeStyle(t,n){n!==this.cachedStrokeStyle&&(t.strokeStyle=n,this.cachedStrokeStyle=n)}setLineWidth(t,n){n!==this.cachedLineWidth&&(t.lineWidth=n,this.cachedLineWidth=n)}setFont(t,n){n!==this.cachedFont&&(t.font=n,this.cachedFont=n)}setTextAlign(t,n){n!==this.cachedTextAlign&&(t.textAlign=n,this.cachedTextAlign=n)}setTextBaseline(t,n){n!==this.cachedTextBaseline&&(t.textBaseline=n,this.cachedTextBaseline=n)}setGlobalAlpha(t,n){n!==this.cachedGlobalAlpha&&(t.globalAlpha=n,this.cachedGlobalAlpha=n)}saveSnapshot(t,n,s){const o=t.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==s)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,s):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=s);const i=this.snapshotCanvas.getContext("2d");i!=null&&typeof i.drawImage=="function"&&(i.clearRect(0,0,n,s),i.drawImage(o,0,0),this.snapshotValid=!0)}restoreSnapshot(t){return!this.snapshotValid||this.snapshotCanvas==null||typeof t.drawImage!="function"?!1:(t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,o){const i=this.pathCache.get(t);if(i==null)return;const l=i.get(n);if(l==null)return;const r=this.windowKey(s,o),a=l.get(r);if(a!=null){const c=this.lruOrder.findIndex(u=>u.group===t&&u.index===n&&u.key===r);if(c>=0){const u=this.lruOrder.splice(c,1)[0];u!=null&&this.lruOrder.push(u)}}return a}setCachedPaths(t,n,s,o,i){if(this.pathCacheSize>=qe){const c=qe>>2,u=this.lruOrder.splice(0,c);for(const h of u){const f=this.pathCache.get(h.group);if(f==null)continue;const d=f.get(h.index);d!=null&&(d.delete(h.key),this.pathCacheSize--,d.size===0&&f.delete(h.index),f.size===0&&this.pathCache.delete(h.group))}}let l=this.pathCache.get(t);l==null&&(l=new Map,this.pathCache.set(t,l));let r=l.get(n);r==null&&(r=new Map,l.set(n,r));const a=this.windowKey(s,o);r.has(a)||(this.pathCacheSize++,this.lruOrder.push({group:t,index:n,key:a})),r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const o=s.get(n);o!=null&&(this.pathCacheSize-=o.size,s.delete(n),this.lruOrder=this.lruOrder.filter(i=>!(i.group===t&&i.index===n)))}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const s of n.values())this.pathCacheSize-=s.size;this.pathCache.delete(t),this.lruOrder=this.lruOrder.filter(s=>s.group!==t)}this.snapshotValid=!1}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruOrder.length=0,this.snapshotValid=!1}drawSeries(t,n,s){const o=this.ctx;if(o==null||t.config.show===!1)return;const i=t.config.group,l=t.config.index,[r,a]=t.window;let c=this.getCachedPaths(i,l,r,a);if(c==null){const u=t.config.paths??Nt,h=t.xScale.dir,f=M=>B(M),d=t.config.fillTo,y=typeof d=="function"?d(t.yScale.min??0,t.yScale.max??0):d;c=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,r,a,h,f,{fillTo:y,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,l,r,a,c)}Ut(o,t.config,c,s,n)}draw(t,n,s,o){const i=this.ctx;if(i==null)return;const l=this.pxRatio;i.clearRect(0,0,t*l,n*l),i.save(),i.scale(l,l),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of o)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const vt=[1,2,2.5,5],qt=dt(10,-32,0,vt),Zt=dt(10,0,32,vt),ae=qt.concat(Zt);function Jt(e,t,n,s,o){if(n<=0||t<e)return[];const i=[],l=we.get(n)??0,r=o?e:re(He(e,n),l);for(let a=r;a<=t;a=re(a+n,l))i.push(Object.is(a,-0)?0:a);return i}function Ze(e){return e.map(t=>gt(t))}function Qt(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=te((n===10?Z:xe)(e));let l=pe(n,i);n===10&&(l=ae[ie(l,ae)]??l);let r=l,a=l*n;n===10&&(a=ae[ie(a,ae)]??a);let c=0;do{if(r>=e&&s.push(r),r=r+l,n===10&&!we.has(r)){const u=we.get(l)??0;r=re(r,u)}r>=a*(1-1e-10)&&(l=r,a=l*n,n===10&&(a=ae[ie(a,ae)]??a))}while(r<=t&&++c<1e4);return s}function en(e,t){const n=t===10?Z:xe;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const o=n(s);return fe(o-Math.round(o))<1e-10})}function tn(e,t){const s=gt(Math.max(Math.abs(e),Math.abs(t))).length*7;return Math.max(50,s+16)}function nn(e,t,n,s){if(s<=0)return[0,0];const o=he(e.side)===H.Vertical,i=e.space??(o?30:tn(t,n)),l=e.incrs??ae;return Ft(t,n,l,s,i)}const sn=50;function on(e,t,n){var r,a;if(e.size!=null)return e.size;const s=((r=e.ticks)==null?void 0:r.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,o=e.gap??5,i=12;if(he(e.side)===H.Vertical&&t!=null){let c=0;for(const h of t)h.length>c&&(c=h.length);const u=c*7;return Math.max(50,s+o+u+4)}return Math.max(50,s+o+i+3)}function ln(e){return{config:e,_show:e.show!==!1,_size:e.size??sn,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const ge=60,ce=3600,oe=86400,ue=2592e3,Ce=31536e3,rn=[1,5,10,15,30,ge,5*ge,10*ge,15*ge,30*ge,ce,2*ce,3*ce,4*ce,6*ce,12*ce,oe,2*oe,3*oe,7*oe,14*oe,ue,2*ue,3*ue,6*ue,Ce];function an(e,t,n,s){const o=[];if(n<=0||e>=t)return o;let i;if(n>=Ce){const l=new Date(e*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(l.setUTCFullYear(l.getUTCFullYear()+1),i=l.getTime()/1e3);i<=t;)o.push(i),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ce)),i=l.getTime()/1e3;return o}if(n>=ue){const l=new Date(e*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3;const r=Math.max(1,Math.round(n/ue));if(i<e&&(l.setUTCMonth(l.getUTCMonth()+1),i=l.getTime()/1e3),r>1){const a=l.getUTCMonth(),c=Math.ceil((a+1)/r)*r;l.setUTCMonth(c-1),i=l.getTime()/1e3}for(;i<=t;)o.push(i),l.setUTCMonth(l.getUTCMonth()+r),i=l.getTime()/1e3;return o}if(n>=oe){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(i+=oe)}else i=Math.ceil(e/n)*n;for(let l=0;;l++){const r=i+l*n;if(r>t)break;o.push(r)}return o}const Je=new Map;function cn(e,t){const n=JSON.stringify(e)+(t??"");let s=Je.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),Je.set(n,s)),s}function J(e,t,n){const s=new Date(e*1e3);return cn(t,n).format(s)}function un(e,t){return J(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function fn(e,t){return J(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function hn(e,t){return J(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function dn(e,t){return J(e,{month:"short",day:"numeric"},t)}function gn(e,t){return J(e,{year:"numeric"},t)}function pn(e,t){return J(e,{year:"numeric",month:"short"},t)}function mn(e,t,n){let s;return t>=Ce?s=gn:t>=ue?s=pn:t>=oe?s=dn:t>=ce?s=hn:t>=ge?s=fn:s=un,e.map(o=>s(o,n))}function wn(e,t,n,s,o){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,c=s/a;if(c>=o)return[r,c]}const l=n[n.length-1]??Ce;return[l,s/(i/l)]}const xn=3;function vn(e,t,n,s,o){let i=!0;for(const l of e){const r=l.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){l._show&&(i=!1,l._show=!1);continue}else l._show||(i=!1,l._show=!0);const c=r.side,h=he(c)===H.Horizontal?n:s,{min:f,max:d}=a;let y,M;if(a.time){const g=r.space??80;[y,M]=wn(f,d,rn,h,g)}else[y,M]=nn(r,f,d,h);if(l._incr=y,l._space=M,M===0)continue;if(r.splits)l._splits=r.splits(f,d,y,M);else if(a.time)l._splits=an(f,d,y);else if(a.distr===O.Log)l._splits=Qt(f,d,a.log);else{const g=a.distr===O.Ordinal;l._splits=Jt(f,d,y,M,g)}if(r.values)l._values=r.values(l._splits,M,y);else if(a.time)l._values=mn(l._splits,y);else if(a.distr===O.Log){const g=en(l._splits,a.log),I=Ze(l._splits);l._values=I.map((L,P)=>g[P]?L:"")}else l._values=Ze(l._splits);l._rotate=c===$.Bottom?r.rotate??0:0;const p=l._size;l._size=ye(on(r,l._values)),p!==l._size&&(i=!1)}return i}function Qe(e,t,n){let s=e,o=t,i=0,l=0;for(const r of n){if(!r._show)continue;const a=r.config.side,c=he(a)===H.Vertical,u=r.config.label!=null?r.config.labelSize??20:0,h=r._size+u;h>0&&(c?(s-=h,a===$.Left&&(i+=h)):(o-=h,a===$.Top&&(l+=h)))}return{left:i,top:l,width:Math.max(s,0),height:Math.max(o,0)}}function Sn(e,t){let n=t.top,s=t.left+t.width,o=t.top+t.height,i=t.left;function l(r,a){switch(r){case $.Top:return n-=a,n+a;case $.Right:{const c=s;return s+=a,c}case $.Bottom:{const c=o;return o+=a,c}case $.Left:return i-=a,i+a;default:return 0}}for(const r of e){if(!r._show)continue;const a=r.config.side;if(r._pos=l(a,r._size),r.config.label!=null){const c=r.config.labelSize??20;r._lpos=l(a,c)}}}function Mn(e,t,n,s){for(const r of n)r._size=0;let o=!1,i=0,l={left:0,top:0,width:e,height:t};for(;!o;){i++;const r=vn(n,s,l.width,l.height);o=i===xn||r,o||(l=Qe(e,t,n))}return l=Qe(e,t,n),Sn(n,l),l}const et="top",tt="bottom",bn="left",yn="right";function nt(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function st(e,t,n,s,o,i,l,r,a,c,u){const h=r%2/2;e.save(),e.translate(h,h),e.strokeStyle=a,e.lineWidth=r,c.length>0&&e.setLineDash(c),e.beginPath();let f=0,d=0,y=0,M=0;const p=i+(o===$.Top||o===$.Left?-l:l);s===H.Horizontal?(d=i,M=p):(f=i,y=p);for(let g=0;g<t.length;g++)n[g]!=null&&(s===H.Horizontal?f=y=t[g]??0:d=M=t[g]??0,e.moveTo(f,d),e.lineTo(y,M));e.stroke(),e.restore()}function kn(e,t,n,s,o){const i=B(s.left*o),l=B(s.top*o),r=B(s.width*o),a=B(s.height*o);for(const c of t){if(!c._show)continue;const u=c.config,h=u.side,f=he(h),d=n(u.scale);if(!d||d.min==null||d.max==null)continue;const y=u.stroke??"#000",M=h===$.Top||h===$.Left?-1:1,p=c._splits,g=c._values;if(!p||!g||c._space===0)continue;const I=f===H.Horizontal?s.width:s.height,L=f===H.Horizontal?s.left:s.top,P=p.map(k=>B(V(k,d,I,L)*o)),T=g.map(k=>k===""?null:k),S=u.grid;if((S==null?void 0:S.show)!==!1){const k=(S==null?void 0:S.stroke)??"rgba(0,0,0,0.12)",D=B(((S==null?void 0:S.width)??2)*o),m=((S==null?void 0:S.dash)??[]).map(C=>C*o),x=f===H.Horizontal?l:i,v=f===H.Horizontal?a:r;st(e,P,T,f,2,x,v,D,k,m)}const w=u.ticks;if((w==null?void 0:w.show)!==!1){const k=(w==null?void 0:w.stroke)??y,D=B(((w==null?void 0:w.width)??1)*o),m=B(((w==null?void 0:w.size)??10)*o),x=((w==null?void 0:w.dash)??[]).map(C=>C*o),v=B(c._pos*o);st(e,P,T,f,h,v,m,D,k,x)}{const k=(w==null?void 0:w.show)!==!1?((w==null?void 0:w.size)??10)*o:0,D=B((u.gap??5)*o),m=B(c._pos*o),x=(k+D)*M,v=m+x,C=nt(u.font??"12px system-ui, sans-serif",o),R=f===H.Horizontal?"center":h===$.Left?yn:bn,A=f===H.Horizontal?h===$.Bottom?et:tt:"middle";e.font=C,e.fillStyle=y,e.textAlign=R,e.textBaseline=A;const F=c._rotate*-ze/180;for(let E=0;E<g.length;E++){const G=g[E];if(G==null||G==="")continue;const W=P[E]??0;if(F!==0)e.save(),e.translate(W,v),e.rotate(F),e.fillText(G,0,0),e.restore();else{const X=f===H.Horizontal?W:v,j=f===H.Horizontal?v:W;e.fillText(G,X,j)}}}if(u.label!=null){const k=nt(u.labelFont??"bold 12px system-ui, sans-serif",o);e.font=k,e.fillStyle=y,e.textAlign="center",e.textBaseline=h===$.Bottom?et:tt;const D=B((c._lpos+(u.labelGap??0)*M)*o);f===H.Vertical?(e.save(),e.translate(D,B(l+a/2)),e.rotate((h===$.Left?-ze:ze)/2),e.fillText(u.label,0,0),e.restore()):e.fillText(u.label,B(i+r/2),D)}const b=u.border;if((b==null?void 0:b.show)!==!1&&b!=null){const k=b.stroke??y,D=B((b.width??1)*o),m=(b.dash??[]).map(v=>v*o),x=B(c._pos*o);e.strokeStyle=k,e.lineWidth=D,m.length>0&&e.setLineDash(m),e.beginPath(),f===H.Horizontal?(e.moveTo(i,x),e.lineTo(i+r,x)):(e.moveTo(x,l),e.lineTo(x,l+a)),e.stroke(),m.length>0&&e.setLineDash([])}}}const Cn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function ot(e,t,n,s,o,i,l,r,a){var L;if(t.left<0||t.top<0)return;const c={...Cn,...a},u=s,h=B(n.left*u),f=B(n.top*u),d=B(n.width*u),y=B(n.height*u),M=B(c.width*u),p=M%2/2,g=B((n.left+t.left)*u)+p,I=B((n.top+t.top)*u)+p;if(e.save(),e.strokeStyle=c.stroke,e.lineWidth=M,e.setLineDash(c.dash.map(P=>P*u)),c.showX&&(e.beginPath(),e.moveTo(g,f),e.lineTo(g,f+y),e.stroke()),c.showY&&(e.beginPath(),e.moveTo(h,I),e.lineTo(h+d,I),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const P=t.activeGroup,T=t.activeSeriesIdx,S=t.activeDataIdx,w=o[P];if(w!=null&&T>=0&&T<w.series.length&&S<w.x.length){const b=w.x[S],k=w.series[T],D=k!=null?k[S]:null;if(b!=null&&D!=null){let m=c.stroke,x=!0;for(const v of i)if(v.group===P&&v.index===T){const C=v.stroke;m=(typeof C=="string"?C:void 0)??c.stroke,x=((L=v.cursor)==null?void 0:L.show)!==!1;break}if(x){const v=r(P),C=v!=null?l(v):void 0,R=Tn(i,P,T),A=R!=null?l(R):void 0;if(C!=null&&A!=null&&C.min!=null&&C.max!=null&&A.min!=null&&A.max!=null){const F=B(V(b,C,n.width,n.left)*u),E=B(V(D,A,n.height,n.top)*u),G=c.pointRadius*u,W=B(2*u);e.beginPath(),e.arc(F,E,G,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=m,e.lineWidth=W,e.stroke()}}}}}e.restore()}function Tn(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const In={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function lt(e,t,n,s,o){if(!t.show||t.width<=0)return;const i={...In,...o},l=s,r=B((n.left+t.left)*l),a=B((n.top+t.top)*l),c=B(t.width*l),u=B(t.height*l);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,c,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=B(i.width*l),e.strokeRect(r,a,c,u)),e.restore()}function An(e,t,n,s,o,i,l,r,a,c,u,h){const f=u/2*l,d=Math.max(1,B(u*.2))*l,y=(c==null?void 0:c.stroke)??h,M=(c==null?void 0:c.fill)??"#fff";e.save(),e.strokeStyle=y,e.fillStyle=M,e.lineWidth=d,(c==null?void 0:c.dash)!=null&&e.setLineDash(c.dash.map(p=>p*l));for(let p=r;p<=a;p++){const g=n[p];if(g==null)continue;const I=t[p];if(I==null)continue;const L=B(V(I,s,i.width,i.left)*l),P=B(V(g,o,i.height,i.top)*l);e.beginPath(),e.arc(L,P,f,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function Pn(e,t,n,s,o,i,l){if(typeof e=="function")return e(t,n,s,o,i);if(e===!0)return!0;if(e===!1)return!1;const r=o-s;return r>0&&r<=i/l}function Ln(e,t,n,s,o,i,l,r,a,c,u){if(c>u||c<0)return;const h=t.fill??"rgba(0, 120, 255, 0.1)",f=M=>V(M,i,r.width,r.left)*a,d=M=>V(M,l,r.height,r.top)*a;e.save(),e.fillStyle=h,e.beginPath();let y=!1;for(let M=c;M<=u;M++){const p=s[M],g=n[M];if(p==null||g==null)continue;const I=f(g),L=d(p);y?e.lineTo(I,L):(e.moveTo(I,L),y=!0)}if(!y){e.restore();return}for(let M=u;M>=c;M--){const p=o[M],g=n[M];p==null||g==null||e.lineTo(f(g),d(p))}e.closePath(),e.fill(),e.restore()}function Ee(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(l,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.width,t.left)},valToY:(l,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.height,t.top)}}}function Rn(){const e={scaleManager:new Ht,dataStore:new Wt,renderer:new Kt,cursorManager:new jt,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,scheduler:new Xt,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,registerScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t.id),e.scaleConfigs.push(t),e.scaleManager.addScale(t)},unregisterScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t),e.scaleManager.removeScale(t)},registerSeries(t){e.seriesConfigs=e.seriesConfigs.filter(n=>!(n.group===t.group&&n.index===t.index)),e.seriesConfigs.push(t)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n))},toggleSeries(t,n){const s=e.seriesConfigs.find(o=>o.group===t&&o.index===n);s!=null&&(s.show=s.show===!1,e.revision++,e.renderer.invalidateSeries(t,n),e.scheduleRedraw())},setFocus(t){e.focusedSeries=t,e.scheduleRedraw()},setSize(t,n){e.width=t,e.height=n,e.canvas&&(e.canvas.width=t*e.pxRatio,e.canvas.height=n*e.pxRatio,e.canvas.style.width=`${t}px`,e.canvas.style.height=`${n}px`),e.renderer.clearCache(),e.scheduleRedraw()},scheduleRedraw(){e.scheduler.mark(q.Full)},scheduleCursorRedraw(){e.scheduler.mark(q.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:o,width:i,height:l,pxRatio:r,canvas:a,scheduler:c}=e;if(a==null||i===0||l===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const f=(c.dirty&~(q.Cursor|q.Select))===0,d=p=>t.getScale(p);if(f&&s.restoreSnapshot(u)){if(ot(u,e.cursorManager.state,e.plotBox,r,n.data,o,d,p=>t.getGroupXScaleKey(p)),lt(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const p=Ee(u,e.plotBox,r,d);for(const g of e.cursorDrawHooks)try{g(p,e.cursorManager.state)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}for(const p of e.listeners)p();return}t.autoRangeX(n.data),n.updateWindows(p=>{const g=t.getGroupXScaleKey(p);return g!=null?t.getScale(g):void 0});const y=o.map(p=>({group:p.group,index:p.index,yScale:p.yScale}));t.autoRange(n.data,y,n),Dn(e),e.axisStates.length>0?e.plotBox=Mn(i,l,e.axisStates,d):e.plotBox={left:10,top:10,width:i-20,height:l-20},u.clearRect(0,0,i*r,l*r),e.axisStates.length>0&&kn(u,e.axisStates,d,e.plotBox,r);const M=[];for(const p of o){const g=t.getGroupXScaleKey(p.group),I=g!=null?t.getScale(g):void 0,L=t.getScale(p.yScale);I==null||L==null||M.push({config:p,dataX:n.getXValues(p.group),dataY:n.getYValues(p.group,p.index),xScale:I,yScale:L,window:n.getWindow(p.group)})}u.save(),u.scale(r,r),u.beginPath(),u.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),u.clip();for(let p=0;p<M.length;p++){const g=M[p];g!=null&&(e.focusedSeries!=null&&p!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(g,e.plotBox,1),u.globalAlpha=1):s.drawSeries(g,e.plotBox,1))}for(const p of e.bandConfigs){const g=t.getGroupXScaleKey(p.group),I=g!=null?t.getScale(g):void 0,L=o.find(b=>b.group===p.group&&b.index===p.series[0]),P=o.find(b=>b.group===p.group&&b.index===p.series[1]);if(I==null||L==null||P==null)continue;const T=t.getScale(L.yScale);if(T==null)continue;const[S,w]=n.getWindow(p.group);Ln(u,p,n.getXValues(p.group),n.getYValues(p.group,p.series[0]),n.getYValues(p.group,p.series[1]),I,T,e.plotBox,r,S,w)}for(const p of M){const g=p.config;if(g.show===!1)continue;const I=g.points,L=g.width??1,P=(I==null?void 0:I.size)??3+L*2,T=(I==null?void 0:I.space)??P*2,[S,w]=p.window;Pn(I==null?void 0:I.show,g.group,g.index,S,w,e.plotBox.width,T)&&An(u,p.dataX,p.dataY,p.xScale,p.yScale,e.plotBox,r,S,w,I,P,(typeof g.stroke=="string"?g.stroke:null)??"#000")}if(u.restore(),e.drawHooks.size>0){u.save(),u.beginPath(),u.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),u.clip(),u.scale(r,r);const p=Ee(u,e.plotBox,r,d);for(const g of e.drawHooks)try{g(p)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,l*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,d,p=>n.getWindow(p),p=>t.getGroupXScaleKey(p))),ot(u,e.cursorManager.state,e.plotBox,r,n.data,o,d,p=>t.getGroupXScaleKey(p)),lt(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const p=Ee(u,e.plotBox,r,d);for(const g of e.cursorDrawHooks)try{g(p,e.cursorManager.state)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}for(const p of e.listeners)p();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const p of t.getAllScales()){if(p.min==null||p.max==null)continue;const g=e._prevScaleRanges.get(p.id);if(g==null||g.min!==p.min||g.max!==p.max)try{e.eventCallbacks.onScaleChange(p.id,p.min,p.max)}catch(I){console.warn("[uPlot+] event callback error:",I)}}e._prevScaleRanges.clear();for(const p of t.getAllScales())p.min!=null&&p.max!=null&&e._prevScaleRanges.set(p.id,{min:p.min,max:p.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function Dn(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const o of n)s.set(`${o.config.scale}:${o.config.side}`,o);e.axisStates=t.map(o=>{const i=`${o.scale}:${o.side}`,l=s.get(i);return l!=null?(l.config=o,l):ln(o)})}function zn(){const e=z.useRef(null);return e.current===null&&(e.current=Rn()),e.current}const St=z.createContext(null);function Q(){const e=z.useContext(St);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function Fn(e,t){z.useEffect(()=>{if(t!=null)return En(e,t)},[e,t])}function En(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let o=null,i=null,l=!1;function r(m){const x=t.getBoundingClientRect(),v=e.plotBox,C=m.clientX-x.left-v.left,R=m.clientY-x.top-v.top;return{cx:C,cy:R}}function a(m,x){const v=e.plotBox;return m>=0&&m<=v.width&&x>=0&&x<=v.height}function c(m,x){const v=t.getBoundingClientRect(),C=m-v.left,R=x-v.top,A=e.plotBox;for(const F of e.axisStates){const E=F.config,G=E.side;if(F._size<=0)continue;const X=R>=A.top&&R<=A.top+A.height,j=C>=A.left&&C<=A.left+A.width;if(G===$.Left&&C<A.left&&X||G===$.Right&&C>A.left+A.width&&X||G===$.Top&&R<A.top&&j||G===$.Bottom&&R>A.top+A.height&&j){const K=he(G);return{scaleId:E.scale,ori:K}}}return null}function u(m,x,v){const C=e.cursorManager.state;let R=null;if(C.activeGroup>=0&&C.activeDataIdx>=0){const A=e.dataStore.data[C.activeGroup];if(A!=null){const F=A.x[C.activeDataIdx],E=A.series[C.activeSeriesIdx],G=E!=null?E[C.activeDataIdx]:void 0;if(F!=null&&G!=null){const W=e.plotBox,X=e.scaleManager.getGroupXScaleKey(C.activeGroup),j=X!=null?e.scaleManager.getScale(X):void 0,ne=e.seriesConfigs.find(Ye=>Ye.group===C.activeGroup&&Ye.index===C.activeSeriesIdx),K=ne!=null?e.scaleManager.getScale(ne.yScale):void 0;let de=x,De=v;(j==null?void 0:j.min)!=null&&j.max!=null&&(de=V(F,j,W.width,W.left)-W.left),(K==null?void 0:K.min)!=null&&K.max!=null&&(De=V(G,K,W.height,W.top)-W.top);const Xe=x-de,$e=v-De;R={group:C.activeGroup,seriesIdx:C.activeSeriesIdx,dataIdx:C.activeDataIdx,xVal:F,yVal:G,pxX:de,pxY:De,dist:Math.sqrt(Xe*Xe+$e*$e)}}}}return{plotX:x,plotY:v,point:R,srcEvent:m}}function h(m){const x=e.plotBox,v=m.left/x.width,C=(m.left+m.width)/x.width,R={};for(const A of e.scaleManager.getAllScales()){if(A.ori!==H.Horizontal||A.min==null||A.max==null)continue;const F=ee(x.left+v*x.width,A,x.width,x.left),E=ee(x.left+C*x.width,A,x.width,x.left);R[A.id]={min:Math.min(F,E),max:Math.max(F,E)}}return{left:v,right:C,ranges:R}}function f(){const m=e.eventCallbacks.onScaleChange;if(m!=null)for(const x of e.scaleManager.getAllScales()){if(x.min==null||x.max==null)continue;const v=e._prevScaleRanges.get(x.id);(v==null||v.min!==x.min||v.max!==x.max)&&m(x.id,x.min,x.max)}}function d(m,x){if(i!=null){const A=t.getBoundingClientRect(),F=m.clientY-A.top,E=e.plotBox,G=(F-i.startY)/E.height,W=i.startMax-i.startMin,X=e.scaleManager.getScale(i.scaleId);X!=null&&(X.min=i.startMin+G*W,X.max=i.startMax+G*W,X.auto=!1,le(X),e.renderer.clearCache(),e.scheduleRedraw());return}const v=r(m);if(v==null)return;const{cx:C,cy:R}=v;if(!a(C,R)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(C,R,e.plotBox,e.dataStore.data,e.seriesConfigs,A=>e.scaleManager.getScale(A),A=>e.dataStore.getWindow(A),A=>e.scaleManager.getGroupXScaleKey(A)),e.focusAlpha<1){const A=e.cursorManager.state;if(A.activeGroup>=0&&A.activeSeriesIdx>=0){const F=e.seriesConfigs.findIndex(E=>E.group===A.activeGroup&&E.index===A.activeSeriesIdx);F>=0&&e.focusedSeries!==F&&(e.focusedSeries=F,e.renderer.clearCache(),e.scheduleRedraw())}}if(x!=null&&e.eventCallbacks.onCursorMove!=null&&a(C,R))try{e.eventCallbacks.onCursorMove(u(x,C,R))}catch(A){console.warn("[uPlot+] event callback error:",A)}if(n!=null){const A=n.x,F=e.plotBox,E=Math.max(0,Math.min(C,F.width));s.show=!0,s.left=Math.min(A,E),s.top=0,s.width=Math.abs(E-A),s.height=F.height,e.selectState=s}n!=null?e.scheduler.mark(q.Cursor|q.Select):e.scheduleCursorRedraw()}function y(m){d(m,m)}function M(m){if(m.button!==0)return;const x=c(m.clientX,m.clientY);if(x!=null&&x.ori===H.Vertical){const C=e.scaleManager.getScale(x.scaleId);if(C!=null&&C.min!=null&&C.max!=null){const R=t.getBoundingClientRect();i={scaleId:x.scaleId,startY:m.clientY-R.top,startMin:C.min,startMax:C.max},m.preventDefault();return}}const v=r(m);v!=null&&a(v.cx,v.cy)&&(n={x:v.cx,y:v.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function p(m){if(i!=null){f(),i=null;return}if(n!=null){if(s.width>5){l=!0;let x=!0;if(e.eventCallbacks.onSelect!=null){const v=h(s);let C;try{C=e.eventCallbacks.onSelect(v)}catch(R){console.warn("[uPlot+] event callback error:",R)}C===!1&&(x=!1)}x&&(w(s),f())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function g(m){p()}function I(m){if(l){l=!1;return}const x=e.eventCallbacks.onClick;if(x==null)return;const v=r(m);if(v!=null&&a(v.cx,v.cy))try{x(u(m,v.cx,v.cy))}catch(C){console.warn("[uPlot+] event callback error:",C)}}function L(m){const x=e.eventCallbacks.onContextMenu;if(x==null)return;const v=r(m);if(v!=null&&a(v.cx,v.cy)){m.preventDefault();try{x(u(m,v.cx,v.cy))}catch(C){console.warn("[uPlot+] event callback error:",C)}}}function P(m){var x,v;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),i!=null&&(i=null),e.scheduleCursorRedraw();try{(v=(x=e.eventCallbacks).onCursorLeave)==null||v.call(x)}catch(C){console.warn("[uPlot+] event callback error:",C)}}function T(m){if(e.eventCallbacks.onDblClick!=null){const x=r(m);if(x!=null&&a(x.cx,x.cy)){let v;try{v=e.eventCallbacks.onDblClick(u(m,x.cx,x.cy))}catch(C){console.warn("[uPlot+] event callback error:",C)}if(v===!1)return}}for(const x of e.scaleConfigs)e.scaleManager.addScale(x);e.renderer.clearCache(),e.scheduleRedraw()}function S(m){if(!e.wheelZoom)return;const x=r(m);if(x==null||!a(x.cx,x.cy))return;m.preventDefault();const v=Math.max(.1,Math.min(10,1-m.deltaY*.001)),C=e.plotBox;for(const R of e.scaleManager.getAllScales()){if(R.ori!==H.Horizontal||R.min==null||R.max==null)continue;const A=ee(x.cx+C.left,R,C.width,C.left),F=A-(A-R.min)*v,E=A+(R.max-A)*v;R.min=Math.min(F,E),R.max=Math.max(F,E),R.auto=!1,le(R)}e.renderer.clearCache(),e.scheduleRedraw(),f()}function w(m){const x=e.plotBox,v=m.left/x.width,C=(m.left+m.width)/x.width;for(const R of e.scaleManager.getAllScales()){if(R.ori!==H.Horizontal||R.min==null||R.max==null)continue;const A=ee(x.left+v*x.width,R,x.width,x.left),F=ee(x.left+C*x.width,R,x.width,x.left);R.min=Math.min(A,F),R.max=Math.max(A,F),R.auto=!1,le(R)}e.renderer.clearCache()}function b(m){if(m.touches.length===2){const C=m.touches[0],R=m.touches[1],A=R.clientX-C.clientX,F=R.clientY-C.clientY;o={dist:Math.sqrt(A*A+F*F),midX:(C.clientX+R.clientX)/2,midY:(C.clientY+R.clientY)/2},n=null;return}const x=m.touches[0];if(x==null)return;const v=r(x);v!=null&&a(v.cx,v.cy)&&(n={x:v.cx,y:v.cy},l=!1)}function k(m){if(m.touches.length===2&&o!=null){m.preventDefault();const v=m.touches[0],C=m.touches[1],R=C.clientX-v.clientX,A=C.clientY-v.clientY,F=Math.sqrt(R*R+A*A),E=F/o.dist,G=t.getBoundingClientRect(),W=e.plotBox,X=o.midX-G.left-W.left;for(const j of e.scaleManager.getAllScales()){if(j.ori!==H.Horizontal||j.min==null||j.max==null)continue;const ne=ee(X+W.left,j,W.width,W.left),K=ne-(ne-j.min)/E,de=ne+(j.max-ne)/E;j.min=Math.min(K,de),j.max=Math.max(K,de),j.auto=!1,le(j)}o.dist=F,e.renderer.clearCache(),e.scheduleRedraw(),f();return}const x=m.touches[0];x!=null&&(d(x,m),n!=null&&m.preventDefault())}function D(m){if(o!=null){o=null;return}m.changedTouches[0]!=null&&p()}return t.addEventListener("mousemove",y),t.addEventListener("mousedown",M),t.addEventListener("mouseup",g),t.addEventListener("click",I),t.addEventListener("contextmenu",L),t.addEventListener("mouseleave",P),t.addEventListener("dblclick",T),t.addEventListener("wheel",S,{passive:!1}),t.addEventListener("touchstart",b,{passive:!0}),t.addEventListener("touchmove",k,{passive:!1}),t.addEventListener("touchend",D),()=>{t.removeEventListener("mousemove",y),t.removeEventListener("mousedown",M),t.removeEventListener("mouseup",g),t.removeEventListener("click",I),t.removeEventListener("contextmenu",L),t.removeEventListener("mouseleave",P),t.removeEventListener("dblclick",T),t.removeEventListener("wheel",S),t.removeEventListener("touchstart",b),t.removeEventListener("touchmove",k),t.removeEventListener("touchend",D)}}const _e=new Map;function _n(e){let t=_e.get(e);return t==null&&(t=new Gn(e),_e.set(e,t)),t}class Gn{constructor(t){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=t}join(t){this.members.add(t)}leave(t){this.members.delete(t),this.members.size===0&&_e.delete(this.key)}pub(t){if(this.publishing)return;if(this.syncedStores.has(t)){this.syncedStores.delete(t);return}this.publishing=!0;const n=t.cursorManager.state,{activeGroup:s,activeDataIdx:o}=n;if(s<0||o<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const l=t.dataStore.getXValues(s)[o];if(l==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(l,r),r.scheduleCursorRedraw());this.publishing=!1}}function Hn(e,t){z.useEffect(()=>{if(t==null)return;const n=_n(t);n.join(e);let s=-1,o=-1;const i=e.subscribe(()=>{const{activeGroup:l,activeDataIdx:r}=e.cursorManager.state;l===s&&r===o||(s=l,o=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function Re({width:e,height:t,data:n,children:s,className:o,pxRatio:i,onDraw:l,onCursorDraw:r,syncKey:a,cursor:c,onClick:u,onContextMenu:h,onDblClick:f,onCursorMove:d,onCursorLeave:y,onScaleChange:M,onSelect:p}){var x;const g=zn(),[I,L]=z.useState(null),P=i??(typeof window<"u"&&window.devicePixelRatio||1),T=(c==null?void 0:c.wheelZoom)??!1,S=((x=c==null?void 0:c.focus)==null?void 0:x.alpha)??((c==null?void 0:c.focus)!=null?.15:1);z.useEffect(()=>{g.wheelZoom=T,g.focusAlpha=S},[g,T,S]),g.eventCallbacks.onClick=u,g.eventCallbacks.onContextMenu=h,g.eventCallbacks.onDblClick=f,g.eventCallbacks.onCursorMove=d,g.eventCallbacks.onCursorLeave=y,g.eventCallbacks.onScaleChange=M,g.eventCallbacks.onSelect=p,Fn(g,I),Hn(g,a);const w=z.useCallback(v=>{g.canvas=v,v&&g.scheduleRedraw()},[g]),b=z.useCallback(v=>{L(v)},[]);z.useEffect(()=>{g.pxRatio=P,g.setSize(e,t)},[g,e,t,P]),z.useEffect(()=>()=>{g.canvas=null,g.scheduler.cancel(),g.focusedSeries=null},[g]),z.useEffect(()=>{if(I==null||typeof ResizeObserver>"u")return;const v=new ResizeObserver(C=>{const R=C[0];if(R==null)return;const{width:A,height:F}=R.contentRect;A>0&&F>0&&(A!==g.width||F!==g.height)&&g.setSize(Math.round(A),Math.round(F))});return v.observe(I),()=>{v.disconnect()}},[g,I]);const k=z.useRef(n);z.useEffect(()=>{if(n===k.current&&g.dataStore.data.length>0)return;k.current=n,g.dataStore.setData(n),g.renderer.clearCache();const v="x";g.scaleManager.getScale(v)||g.registerScale({id:v,auto:!0});for(let C=0;C<n.length;C++)g.scaleManager.setGroupXScale(C,v);g.scheduleRedraw()},[g,n]);const D=z.useRef(l);D.current=l,z.useEffect(()=>{const v=C=>{var R;(R=D.current)==null||R.call(D,C)};return g.drawHooks.add(v),()=>{g.drawHooks.delete(v)}},[g]);const m=z.useRef(r);return m.current=r,z.useEffect(()=>{const v=(C,R)=>{var A;(A=m.current)==null||A.call(m,C,R)};return g.cursorDrawHooks.add(v),()=>{g.cursorDrawHooks.delete(v)}},[g]),_.jsx(St.Provider,{value:g,children:_.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[_.jsx("div",{ref:b,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:_.jsx("canvas",{ref:w,style:{position:"absolute",left:0,top:0}})}),s]})})}function it(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Vn(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of s)if(e[o]!==t[o])return!1;return!0}function We(e,t){if(e===null)return!1;const n=e,s=t,o=Object.keys(n),i=Object.keys(s);if(o.length!==i.length)return!1;for(const l of i){const r=n[l],a=s[l];if(r!==a)if(it(r)&&it(a)){if(!Vn(r,a))return!1}else return!1}return!0}function Te(e){const t=Q(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=z.useRef(null);return z.useEffect(()=>{We(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(o=>o.id===e.id?{...e}:o),t.scaleManager.addScale({...e}),t.scheduleRedraw())}),null}function je(e){const t=Q(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerSeries({...o,show:o.show??!0}),t.renderer.clearCache(),t.scheduleRedraw(),()=>{t.unregisterSeries(o.group,o.index),t.renderer.clearCache(),t.scheduleRedraw()}},[t,e.group,e.index]);const s=z.useRef(null);return z.useEffect(()=>{We(s.current,e)||(s.current=e,t.seriesConfigs=t.seriesConfigs.map(o=>o.group===e.group&&o.index===e.index?{...e,show:e.show??!0}:o),t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw())}),null}function Bn(e){return{...e,side:e.side??(e.scale==="x"?$.Bottom:$.Left),show:e.show??!0}}function Ie(e){const t=Q(),n=Bn(e),s=z.useRef(n);s.current=n,z.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const o=z.useRef(null);return z.useEffect(()=>{We(o.current,e)||(o.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function Wn({series:e,group:t,fill:n,dir:s}){const o=Q(),i=z.useRef(null),l=e[0],r=e[1];return z.useEffect(()=>{const a={series:[l,r],group:t,fill:n,dir:s};return i.current!=null&&(o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current)),i.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current),i.current=null,o.scheduleRedraw()}},[o,l,r,t,n,s]),null}const jn={width:12,height:3,borderRadius:1,display:"inline-block"},Xn={fontWeight:600},$n={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Yn=z.memo(function({group:t,index:n,label:s,color:o,isHidden:i,valueStr:l,store:r}){const a=z.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);return _.jsxs("span",{onClick:a,style:{...$n,opacity:i?.4:1},children:[_.jsx("span",{style:{...jn,backgroundColor:o}}),_.jsx("span",{children:s}),l&&_.jsx("span",{style:Xn,children:l})]})});function On({show:e=!0,position:t="bottom",className:n}){const s=Q(),o=z.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=z.useCallback(u=>s.subscribe(u),[s]),l=z.useCallback(()=>{const{activeGroup:u,activeDataIdx:h}=s.cursorManager.state,f=s.seriesConfigs.length,{revision:d}=s,y=o.current;if(y.activeGroup===u&&y.activeDataIdx===h&&y.seriesCount===f&&y.revision===d)return y;const M={activeGroup:u,activeDataIdx:h,seriesCount:f,revision:d};return o.current=M,M},[s]),r=z.useSyncExternalStore(i,l);if(!e)return null;const{activeGroup:a,activeDataIdx:c}=r;return _.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{const h=typeof u.stroke=="string"?u.stroke:"#000";let f="";if(c>=0&&a>=0){const y=s.dataStore.getYValues(u.group,u.index)[c];y!=null&&(f=typeof y=="number"?y.toPrecision(4):String(y))}return _.jsx(Yn,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:h,isHidden:u.show===!1,valueStr:f,store:s},`${u.group}:${u.index}`)})})}const Un=160;function Nn({show:e=!0,className:t,children:n,offset:s={}}){const o=Q(),i=z.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=z.useCallback(w=>o.subscribe(w),[o]),r=z.useCallback(()=>{const w=o.cursorManager.state,{revision:b}=o,k=i.current;if(k.left===w.left&&k.top===w.top&&k.activeGroup===w.activeGroup&&k.activeDataIdx===w.activeDataIdx&&k.revision===b)return k;const D={left:w.left,top:w.top,activeGroup:w.activeGroup,activeDataIdx:w.activeDataIdx,revision:b};return i.current=D,D},[o]),a=z.useSyncExternalStore(l,r);if(!e||a.activeDataIdx<0||a.activeGroup<0||a.left<0)return null;const{activeGroup:c,activeDataIdx:u}=a,h=o.plotBox,f=o.dataStore.data[c],d=f!=null?f.x[u]??null:null,y=d!=null?parseFloat(d.toPrecision(6)).toString():"",M=[];for(const w of o.seriesConfigs){if(w.show===!1)continue;const b=o.dataStore.getYValues(w.group,w.index),k=w.group===c?b[u]:null;M.push({label:w.label??`Series ${w.index}`,value:k,color:typeof w.stroke=="string"?w.stroke:"#000",group:w.group,index:w.index})}const p={x:d,xLabel:y,items:M,left:a.left+h.left,top:a.top+h.top},g=s.x??12,I=s.y??-12,L=a.left+h.left+g+Un>h.left+h.width,P=a.top+h.top+I<h.top,T=L?p.left-g:p.left+g,S=P?p.top+Math.abs(I):p.top+I;return n?_.jsx("div",{className:t,style:{position:"absolute",left:T,top:S,transform:L?"translateX(-100%)":void 0,pointerEvents:"none",zIndex:100},children:n(p)}):_.jsxs("div",{className:t,style:{position:"absolute",left:T,top:S,transform:L?"translateX(-100%)":void 0,pointerEvents:"none",zIndex:100,background:"rgba(0,0,0,0.85)",color:"#fff",padding:"6px 10px",borderRadius:4,fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",lineHeight:1.5},children:[_.jsx("div",{style:{fontWeight:600,marginBottom:2},children:y}),M.map(w=>_.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[_.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:w.color,display:"inline-block"}}),_.jsxs("span",{children:[w.label,":"]}),_.jsx("span",{style:{fontWeight:600},children:w.value!=null?w.value.toPrecision(4):"—"})]},`${w.group}:${w.index}`))]})}function Kn({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:i,colors:l,grips:r=!1}){const a=z.useRef(null),[c,u]=z.useState(()=>{if(o!=null&&n.length>0){const T=n[0];if(T!=null&&T.x.length>1){const S=T.x[0],b=T.x[T.x.length-1]-S;if(b>0)return[Math.max(0,(o[0]-S)/b),Math.min(1,(o[1]-S)/b)]}}return[.25,.75]}),h=z.useRef(null);z.useEffect(()=>{if(s==null||n.length===0)return;const T=n[0];if(T==null||T.x.length<2)return;const S=T.x[0],b=T.x[T.x.length-1]-S,k=S+c[0]*b,D=S+c[1]*b,m=h.current,x=Math.max(1e-10,Math.abs(D-k)*1e-12);m!=null&&Math.abs(m[0]-k)<x&&Math.abs(m[1]-D)<x||(h.current=[k,D],s(k,D))},[c,n,s]);const f=z.useRef(null),d=z.useCallback(T=>{const S=a.current;if(S==null)return 0;const w=S.getBoundingClientRect();return Math.max(0,Math.min(1,(T-w.left)/w.width))},[]),y=z.useCallback(T=>{const S=a.current;if(S==null)return;const w=d(T.clientX),b=S.getBoundingClientRect().width,k=b>0?8/b:0;let D;if(Math.abs(w-c[0])<k)D="left";else if(Math.abs(w-c[1])<k)D="right";else if(w>=c[0]&&w<=c[1])D="move";else{const m=c[1]-c[0],x=m/2,v=Math.max(0,Math.min(1-m,w-x));u([v,v+m]),D="move"}f.current={mode:D,startX:T.clientX,startFrac:[...c]},S.setPointerCapture(T.pointerId),T.preventDefault()},[c,d]),M=z.useCallback(T=>{const S=f.current;if(S==null)return;const w=d(T.clientX),b=d(S.startX),k=w-b;if(S.mode==="move"){const D=S.startFrac[1]-S.startFrac[0];let m=S.startFrac[0]+k;m=Math.max(0,Math.min(1-D,m)),u([m,m+D])}else if(S.mode==="left"){const D=Math.max(0,Math.min(S.startFrac[1]-.01,S.startFrac[0]+k));u([D,S.startFrac[1]])}else{const D=Math.min(1,Math.max(S.startFrac[0]+.01,S.startFrac[1]+k));u([S.startFrac[0],D])}},[d]),p=z.useCallback(T=>{f.current=null;const S=a.current;S!=null&&S.releasePointerCapture(T.pointerId)},[]),g=`${c[0]*100}%`,I=`${(c[1]-c[0])*100}%`,L=n[0],P=L!=null?L.series.length:0;return _.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[_.jsxs(Re,{width:e,height:t,data:n,children:[_.jsx(Te,{id:"x"}),_.jsx(Te,{id:"y"}),_.jsx(Ie,{scale:"x",show:!1}),_.jsx(Ie,{scale:"y",show:!1}),Array.from({length:P},(T,S)=>_.jsx(je,{group:0,index:S,yScale:"y",stroke:l!=null&&l[S]!=null?l[S]:`hsl(${S*137}, 60%, 50%)`,width:1},S))]}),_.jsxs("div",{ref:a,onPointerDown:y,onPointerMove:M,onPointerUp:p,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[_.jsx("div",{style:{position:"absolute",top:0,left:0,width:g,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),_.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),_.jsx("div",{style:{position:"absolute",top:0,left:g,width:I,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:r&&_.jsxs(_.Fragment,{children:[_.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),_.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function ve(e){const t=Q(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function qn(e){const t=Q(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=(o,i)=>n.current(o,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Zn({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const o=Q();return ve(({ctx:i,plotBox:l,pxRatio:r})=>{const a=o.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(l.left*r,l.top*r,l.width*r,l.height*r),i.clip();const c=(t+n)*r,u=t*r,h=l.top*r;for(let f=0;f<e.length;f++){const d=e[f];if(d==null)continue;const y=h+f*c;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(d.label,(l.left-6)*r,y+u/2);for(const M of d.segments){const p=V(M.start,a,l.width,l.left)*r,I=V(M.end,a,l.width,l.left)*r-p;I<=0||(i.fillStyle=M.color??"#4dabf7",i.fillRect(p,y,I,u),M.label!=null&&I>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(M.label,p+I/2,y+u/2,I-4*r)))}}i.restore()}),null}function Jn({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:i=1,paths:l,fillTo:r,className:a}){return _.jsx("div",{style:{pointerEvents:"none"},className:a,children:_.jsxs(Re,{width:t,height:n,data:e,children:[_.jsx(Te,{id:"x"}),_.jsx(Te,{id:"y"}),_.jsx(Ie,{scale:"x",show:!1}),_.jsx(Ie,{scale:"y",show:!1}),_.jsx(je,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:i,paths:l,fillTo:r})]})})}function Qn({minWidth:e=100,minHeight:t=100,aspectRatio:n,initialHeight:s=300,...o}){const i=z.useRef(null),[l,r]=z.useState(null),a=z.useCallback(c=>{const u=Math.max(c.width,e);let h;return n!=null?h=Math.max(u/n,t):h=Math.max(c.height||s,t),{width:Math.round(u),height:Math.round(h)}},[e,t,n,s]);return z.useEffect(()=>{const c=i.current;if(c==null)return;const u=c.getBoundingClientRect();if(r(a({width:u.width,height:u.height})),typeof ResizeObserver>"u")return;const h=new ResizeObserver(f=>{const d=f[0];if(d==null)return;const{width:y,height:M}=d.contentRect;r(a({width:y,height:M}))});return h.observe(c),()=>h.disconnect()},[a]),_.jsx("div",{ref:i,style:{width:"100%",height:n!=null?"auto":"100%"},children:l!=null&&_.jsx(Re,{...o,width:l.width,height:l.height})})}function Mt(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.height,i.top);o.beginPath(),o.moveTo(i.left,l),o.lineTo(i.left+i.width,l),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function bt(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.width,i.left);o.beginPath(),o.moveTo(l,i.top),o.lineTo(l,i.top+i.height),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function es(e,t,n,s,o,i,l={}){const{ctx:r,plotBox:a}=e,c=V(s,t,a.width,a.left),u=V(o,n,a.height,a.top);r.font=l.font??"12px sans-serif",r.fillStyle=l.fill??"#000",r.textBaseline="bottom",r.fillText(i,c,u-4)}function yt(e,t,n,s,o={}){const{ctx:i,plotBox:l}=e,r=V(s,t,l.height,l.top),a=V(n,t,l.height,l.top);i.fillStyle=o.fill??"rgba(255,0,0,0.1)",i.fillRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.stroke&&(i.strokeStyle=o.stroke,i.lineWidth=o.width??1,o.dash&&i.setLineDash(o.dash),i.strokeRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.dash&&i.setLineDash([]))}function ts(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.yScale??"y",i=n.getScale(o);if(i!=null&&(Mt(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToY(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(s.label,a.left+4,l-4)}}),null}function ns(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.xScale??"x",i=n.getScale(o);if(i!=null&&(bt(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToX(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(s.label,l,a.top-4)}}),null}function ss(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.getScale(s.yScale??"y");o!=null&&yt(n,o,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function os(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(o==null||i==null)return;const{ctx:l}=n;l.font=s.font??"12px sans-serif",l.fillStyle=s.fill??"#000",l.textAlign=s.align??"left",l.textBaseline=s.baseline??"bottom",l.fillText(s.text,o,i-4)}),null}function ls(e,t){const{window:n,batchSize:s=1}=t,o=t.autoStart??!0,[i,l]=z.useState(e),[r,a]=z.useState(!1),[c,u]=z.useState(0),h=z.useRef(0),f=z.useRef(0),d=z.useRef(0),y=z.useCallback((g,...I)=>{l(L=>{const P=L[0];if(P==null)return L;const T=P.x,S=Math.max(0,T.length+g.length-n),w=S>0?T.slice(S).concat(g):T.concat(g),b=P.series.map((k,D)=>{const m=k,x=I[D]??[];return S>0?m.slice(S).concat(x):m.concat(x)});return[{x:w,series:b}]})},[n]),M=z.useCallback(()=>{a(!0)},[]),p=z.useCallback(()=>{a(!1)},[]);return z.useEffect(()=>{if(!r){h.current!==0&&(cancelAnimationFrame(h.current),h.current=0);return}d.current=performance.now(),f.current=0;const g=I=>{f.current++;const L=I-d.current;L>=1e3&&(u(Math.round(f.current*1e3/L)),f.current=0,d.current=I),h.current=requestAnimationFrame(g)};return h.current=requestAnimationFrame(g),()=>{h.current!==0&&(cancelAnimationFrame(h.current),h.current=0)}},[r]),z.useEffect(()=>{o&&a(!0)},[o]),{data:i,push:y,start:M,stop:p,running:r,fps:c}}function is(e){return(t,n,s,o,i,l,r,a,c,u,h,f,d)=>{const y=(d==null?void 0:d.align)??e??1,M=(d==null?void 0:d.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const p=k=>f(V(k,s,i,r)),g=k=>f(V(k,o,l,a)),I=s.ori===H.Horizontal?Pe:Le,L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},P=L.stroke;let T=!1;const S=h===Y.Forward?c:u;let w=g(n[S]),b=p(t[S]);I(P,b,w);for(let k=S;k>=c&&k<=u;k+=h){const D=n[k];if(D==null){D===null&&!M&&(T=!0);continue}const m=p(t[k]),x=g(D);if(y===1)I(P,m,w);else if(y===-1)I(P,b,x);else{const v=f((b+m)/2);I(P,v,w),I(P,v,x)}I(P,m,x),w=x,b=m}{const k=L.fill=new Path2D(P),D=(d==null?void 0:d.fillTo)??o.min??0,m=g(D);let x=r,v=r+i;h===Y.Backward&&([v,x]=[x,v]),I(k,v,m),I(k,x,m)}if(T){const k=Ve(t,n,c,u,h,p);L.gaps=k,L.clip=Be(k,s.ori,r,a,i,l)}return L}}function rs(){return(e,t,n,s,o,i,l,r,a,c,u,h,f)=>{const d=(f==null?void 0:f.barWidth)??.6,y=(f==null?void 0:f.barGap)??0,M=(f==null?void 0:f.barRadius)??0,p=(f==null?void 0:f.barGroupIdx)??0,g=(f==null?void 0:f.barGroupCount)??1,I=v=>h(V(v,n,o,l)),L=v=>h(V(v,s,i,r));let P=o;if(c>a){let v=1/0,C=-1;for(let R=a;R<=c;R++)if(t[R]!=null){if(C>=0){const A=e[R],F=e[C],E=Math.abs(I(A)-I(F));E<v&&(v=E)}C=R}v<1/0&&(P=v)}const T=P*(1-d),S=Math.max(0,T+y),w=Math.max(1,h(P-S)),b=g>1?Math.max(1,h(w/Math.max(1,g))):w,k=(f==null?void 0:f.fillTo)??s.min??0,D=L(k),m=new Path2D,x=n.ori===H.Horizontal;for(let v=u===Y.Forward?a:c;v>=a&&v<=c;v+=u){const C=t[v];if(C==null)continue;const R=I(e[v]),A=L(C),F=g>1?(p-(g-1)/2)*b:0,E=h(R-b/2+F),G=Math.min(A,D),X=Math.max(A,D)-G;if(X!==0)if(M>0){const j=Math.min(M*b,X/2);as(m,x,E,G,b,X,j,C<k)}else x?m.rect(E,G,b,X):m.rect(G,E,X,b)}return{stroke:m,fill:m,clip:null,band:null,gaps:null}}}function as(e,t,n,s,o,i,l,r){l=Math.min(l,o/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+o,s),e.lineTo(n+o,s+i-l),e.arc(n+o-l,s+i-l,l,0,Math.PI/2),e.lineTo(n+l,s+i),e.arc(n+l,s+i-l,l,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+l),e.arc(n+l,s+l,l,Math.PI,Math.PI*1.5),e.lineTo(n+o-l,s),e.arc(n+o-l,s+l,l,Math.PI*1.5,0),e.lineTo(n+o,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+o),e.lineTo(s+i-l,n+o),e.arc(s+i-l,n+o-l,l,Math.PI/2,0,!0),e.lineTo(s+i,n+l),e.arc(s+i-l,n+l,l,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+l,n),e.arc(s+l,n+l,l,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+o-l),e.arc(s+l,n+o-l,l,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+o),e.closePath())}function kt(e){return(t,n,s,o,i,l,r,a,c,u,h,f,d)=>{const y=(d==null?void 0:d.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const M=b=>f(V(b,s,i,r)),p=b=>f(V(b,o,l,a)),g=s.ori===H.Horizontal?Pe:Le,I=[],L=[];let P=!1;for(let b=h===Y.Forward?c:u;b>=c&&b<=u;b+=h){const k=n[b];k!=null?(I.push(M(t[b])),L.push(p(k))):k===null&&!y&&(P=!0)}const T=s.ori===H.Horizontal,S=e(I,L,T,f),w={stroke:S??new Path2D,fill:null,clip:null,band:null,gaps:null};if(S!=null){const b=w.fill=new Path2D(S),k=(d==null?void 0:d.fillTo)??o.min??0,D=p(k);let m=r,x=r+i;h===Y.Backward&&([x,m]=[m,x]),g(b,x,D),g(b,m,D)}if(P){const b=Ve(t,n,c,u,h,M);w.gaps=b,w.clip=Be(b,s.ori,r,a,i,l)}return w}}function cs(){return kt(us)}const us=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=e[0]??0,r=t[0]??0;if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const f=e[1]??0,d=t[1]??0;return n?i.lineTo(f,d):i.lineTo(d,f),i}const a=new Array(o),c=new Array(o-1),u=new Array(o-1),h=new Array(o-1);for(let f=0;f<o-1;f++)u[f]=(t[f+1]??0)-(t[f]??0),h[f]=(e[f+1]??0)-(e[f]??0),c[f]=h[f]!==0?(u[f]??0)/(h[f]??1):0;a[0]=c[0]??0;for(let f=1;f<o-1;f++){const d=c[f]??0,y=c[f-1]??0;if(d===0||y===0||y>0!=d>0)a[f]=0;else{const M=h[f]??1,p=h[f-1]??1;a[f]=3*(p+M)/((2*M+p)/y+(M+2*p)/d),isFinite(a[f]??0)||(a[f]=0)}}a[o-1]=c[o-2]??0;for(let f=0;f<o-1;f++){const d=h[f]??1,y=e[f]??0,M=t[f]??0,p=e[f+1]??0,g=t[f+1]??0,I=a[f]??0,L=a[f+1]??0,P=y+d/3,T=M+I*d/3,S=p-d/3,w=g-L*d/3;n?i.bezierCurveTo(P,T,S,w,p,g):i.bezierCurveTo(T,P,w,S,g,p)}return i};function fs(){return kt(hs)}const hs=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const a=s(e[1]??0),c=s(t[1]??0);return n?i.lineTo(a,c):i.lineTo(c,a),i}for(let a=0;a<o-1;a++){const c=a===0?0:a-1,u=e[c]??0,h=t[c]??0,f=e[a]??0,d=t[a]??0,y=e[a+1]??0,M=t[a+1]??0,p=a+2<o?e[a+2]??0:y,g=a+2<o?t[a+2]??0:M,I=Math.hypot(u-f,h-d),L=Math.hypot(f-y,d-M),P=Math.hypot(y-p,M-g),T=Math.sqrt(P),S=P,w=Math.sqrt(L),b=L,k=Math.sqrt(I),D=I,m=2*D+3*k*w+b,x=2*S+3*T*w+b,v=3*k*(k+w),C=3*T*(T+w);let R,A,F,E;if(v>0){const G=1/v;R=(-b*u+m*f+D*y)*G,A=(-b*h+m*d+D*M)*G}else R=f,A=d;if(C>0){const G=1/C;F=(S*f+x*y-b*p)*G,E=(S*d+x*M-b*g)*G}else F=y,E=M;n?i.bezierCurveTo(R,A,F,E,y,M):i.bezierCurveTo(A,R,E,F,M,y)}return i};function ds(e=4){return(t,n,s,o,i,l,r,a,c,u,h,f,d)=>{const y=L=>f(V(L,s,i,r)),M=L=>f(V(L,o,l,a)),p=e/2,g=new Path2D,I=s.ori===H.Horizontal;for(let L=h===Y.Forward?c:u;L>=c&&L<=u;L+=h){const P=n[L];if(P==null)continue;const T=y(t[L]),S=M(P);I?(g.moveTo(T+p,S),g.arc(T,S,p,0,Math.PI*2)):(g.moveTo(S+p,T),g.arc(S,T,p,0,Math.PI*2))}return{stroke:g,fill:g,clip:null,band:null,gaps:null}}}function gs(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:o,open:i,high:l,low:r,close:a,xScale:c,yScale:u,upColor:h="#26a69a",downColor:f="#ef5350",bodyWidth:d=.6,wickWidth:y=1}=e;if(c.min==null||c.max==null||u.min==null||u.max==null)return;const M=o.length;if(M===0)return;const g=Math.max(2,n.width/M*d)*s/2;t.save();for(let I=0;I<M;I++){const L=o[I],P=i[I],T=l[I],S=r[I],w=a[I];if(L==null||P==null||T==null||S==null||w==null)continue;const b=V(L,c,n.width,n.left)*s,k=V(P,u,n.height,n.top)*s,D=V(T,u,n.height,n.top)*s,m=V(S,u,n.height,n.top)*s,x=V(w,u,n.height,n.top)*s,C=w>=P?h:f;t.strokeStyle=C,t.lineWidth=y*s,t.beginPath(),t.moveTo(b,D),t.lineTo(b,m),t.stroke();const R=Math.min(k,x),A=Math.abs(x-k);t.fillStyle=C,t.fillRect(b-g,R,g*2,Math.max(A,1*s))}t.restore()}}function ps(e,t,n=0){const s=t??e.series.map((c,u)=>u),o=e.x.length,i=[],l=new Float64Array(o);for(let c=0;c<s.length;c++){const u=s[c];if(u==null)continue;const h=e.series[u];if(h==null)continue;const f=new Array(o);for(let d=0;d<o;d++){const y=h[d];y!=null?(l[d]=l[d]+y,f[d]=l[d]):f[d]=null}i.push(f)}const r=[];for(let c=0;c<e.series.length;c++){const u=s.indexOf(c),h=u>=0?i[u]:void 0;h!=null?r.push(h):r.push(e.series[c]??[])}const a=[];for(let c=s.length-1;c>0;c--){const u=s[c],h=s[c-1];u!=null&&h!=null&&a.push({group:n,series:[u,h]})}return{group:{x:e.x,series:r},bands:a}}function ms(e){const t=new Set;for(const[i]of e)for(let l=0;l<i.length;l++){const r=i[l];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,l)=>i-l)),s=new Map;for(let i=0;i<n.length;i++){const l=n[i];l!=null&&s.set(l,i)}const o=[];for(const[i,l]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const c=i[a];if(c==null)continue;const u=s.get(c);u!=null&&(r[u]=l[a]??null)}o.push(r)}return[{x:n,series:o}]}function ws(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const o=Math.abs(s);return o>=1e9?(s/1e9).toFixed(t)+"B":o>=1e6?(s/1e6).toFixed(t)+"M":o>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(o>=1?0:t)})}function xs(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function vs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?J(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):J(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ss(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(o=>J(o,{month:n},t))}function Ms(e){const{tz:t,...n}=e??{};return s=>s.map(o=>J(o,n,t))}function bs(e,t=0){return n=>n.map(s=>{const o=Math.round(s)-t;return e[o]??String(s)})}function Ct(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e);return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null}function ys(e,t=.8,n=0){const s=Ct(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[o,i,l]=s;return{type:"linear",stops:[[0,`rgba(${o},${i},${l},${t})`],[1,`rgba(${o},${i},${l},${n})`]]}}function ks(e,t){const n=Ct(e);if(n==null)return e;const[s,o,i]=n;return`rgba(${s},${o},${i},${t})`}function Cs(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const l=i*137.508%360;s.push(`hsl(${l.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=os;exports.Axis=Ie;exports.Band=Wn;exports.Chart=Re;exports.Direction=Y;exports.Distribution=O;exports.HLine=ts;exports.Legend=On;exports.Orientation=H;exports.Region=ss;exports.ResponsiveChart=Qn;exports.Scale=Te;exports.Series=je;exports.Side=$;exports.SortOrder=me;exports.Sparkline=Jn;exports.Timeline=Zn;exports.Tooltip=Nn;exports.VLine=ns;exports.ZoomRanger=Kn;exports.alignData=ms;exports.bars=rs;exports.catmullRom=fs;exports.drawCandlesticks=gs;exports.drawHLine=Mt;exports.drawLabel=es;exports.drawRegion=yt;exports.drawVLine=bt;exports.fadeGradient=ys;exports.fmtCompact=ws;exports.fmtDateStr=Ms;exports.fmtHourMin=vs;exports.fmtLabels=bs;exports.fmtMonthName=Ss;exports.fmtSuffix=xs;exports.linear=xt;exports.monotoneCubic=cs;exports.palette=Cs;exports.points=ds;exports.posToVal=ee;exports.sideOrientation=he;exports.stackGroup=ps;exports.stepped=is;exports.useChart=Q;exports.useCursorDrawHook=qn;exports.useDrawHook=ve;exports.useStreamingData=ls;exports.valToPos=V;exports.withAlpha=ks;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("react/jsx-runtime"),z=require("react");var X=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(X||{}),_=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(_||{}),Y=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(Y||{}),U=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(U||{}),me=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(me||{});function he(e){return e%2}var Z=(e=>(e[e.None=0]="None",e[e.Scales=1]="Scales",e[e.Axes=2]="Axes",e[e.Paths=4]="Paths",e[e.Cursor=8]="Cursor",e[e.Select=16]="Select",e[e.Size=32]="Size",e[e.Full=63]="Full",e))(Z||{});const q=Math,ze=q.PI,fe=q.abs,ne=q.floor,B=q.round,ye=q.ceil,Ue=q.min,be=q.max,pe=q.pow,Ke=q.sign,J=q.log10,xe=q.log2,It=(e,t=1)=>q.sinh(e)*t,He=(e,t=1)=>q.asinh(e/t),N=1/0,at=Number.isInteger;function Fe(e,t){return e[t]??0}function ie(e,t,n=0,s=t.length-1){let o;const i=s<=2147483647;for(;s-n>1;)o=i?n+s>>1:ne((n+s)/2),Fe(t,o)<e?n=o:s=o;return e-Fe(t,n)<=Fe(t,s)-e?n:s}const ct=e=>e!=null,ut=e=>e!=null&&e>0;function ft(e){return(t,n,s)=>{let o=-1,i=-1;for(let l=n;l<=s;l++)if(e(t[l])){o=l;break}for(let l=s;l>=n;l--)if(e(t[l])){i=l;break}return[o,i]}}const Ae=ft(ct),ht=ft(ut);function At(e,t,n,s=me.Unsorted,o=!1){const i=o?ht:Ae,l=o?ut:ct,[r,a]=i(e,t,n);let c=e[r]??N,u=e[r]??-N;if(r>-1)if(s===me.Ascending)c=e[r]??N,u=e[a]??-N;else if(s===me.Descending)c=e[a]??N,u=e[r]??-N;else for(let d=r;d<=a;d++){const f=e[d];f!=null&&l(f)&&(f<c?c=f:f>u&&(u=f))}return[c,u]}function re(e,t=0){if(at(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return B(s)/n}const we=new Map;function Pt(e){return(String(e).split(".")[1]??"").length}const Lt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(at(e)||we.has(e))return e;const t=`${e}`,n=t.match(Lt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const o=t.split("e"),i=o[0]??"0",l=o[1]??"0";return+`${ke(+i)}e${l}`}return re(e,s)}function _e(e,t,n=!0){return n?ke(ye(ke(e/t))*t):ye(e/t)*t}function dt(e,t,n=!0){return n?ke(ne(ke(e/t))*t):ne(e/t)*t}function gt(e,t,n,s){const o=[],i=s.map(Pt);for(let l=t;l<n;l++){const r=fe(l);for(let a=0;a<s.length;a++){const c=s[a]??0,u=i[a]??0,d=+`${c}e${l}`,f=(l>=0?0:r)+(l>=u?0:u),g=d;o.push(g),we.set(g,f)}}return o}const Rt=new Intl.NumberFormat,pt=e=>Rt.format(e),Dt=.1,se={mode:3,pad:Dt,soft:null},Se={pad:0,soft:null,mode:0},zt={min:Se,max:Se};function Me(e,t,n,s){let o;typeof n=="number"?(Se.pad=n,Se.soft=null,Se.mode=0,o=zt):o=n;const i=o.min,l=o.max,r=i.pad,a=l.pad,c=i.hard??-N,u=l.hard??N,d=i.soft??N,f=l.soft??-N,g=i.mode,v=l.mode;let b=t-e;const P=J(b),h=be(fe(e),fe(t)),C=J(h),I=fe(C-P);(b<1e-24||I>10)&&(b=0,(e===0||t===0)&&(b=1e-24));const L=b||h||1e3,T=J(L),M=pe(10,ne(T)),m=L*(b===0?e===0?.1:1:r),S=re(dt(e-m,M/10),24),y=e>=d&&(g===1||g===3&&S<=d||g===2&&S>=d)?d:N,R=be(c,S<y&&e>=y?y:Ue(y,S)),p=L*(b===0?t===0?.1:1:a),w=re(_e(t+p,M/10),24),x=t<=f&&(v===1||v===3&&w>=f||v===2&&w<=f)?f:-N,k=Ue(u,w>x&&t<=x?x:be(x,w));return R===k&&R===0?[0,100]:[R,k]}function Ft(e,t,n,s){n===2&&(s=!0);const o=Ke(e),i=Ke(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?J:xe,r=o===1?ne:ye,a=i===1?ye:ne,c=l(fe(e)),u=l(fe(t)),d=r(c),f=a(u);let g=pe(n,d),v=pe(n,f);return n===10&&(d<0&&(g=re(g,-d)),f<0&&(v=re(v,-f))),s?(e=g*o,t=v*i):(e=dt(e,pe(n,ne(c)),!1),t=_e(t,pe(n,ne(u)),!1)),[e,t]}function Ne(e){return(J((e^e>>31)-(e>>31))|0)+1}function Et(e,t,n,s,o){const i=be(Ne(e),Ne(t)),l=t-e;let r=be(0,ie(o/s*l,n)-1);do{const a=n[r]??0,c=s*a/l;if(c>=o*.9&&i+(a<5?we.get(a)??0:0)<=17)return[a,c]}while(++r<n.length);return[0,0]}function Gt(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??U.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?_.Horizontal:_.Vertical),dir:e.dir??Y.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_min:null,_max:null}}function le(e){e._min=null,e._max=null}function mt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._min=(e.log===10?J:xe)(s)}else n===U.Asinh?e._min=He(t,e.asinh):e._min=t;return e._min}function wt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===U.Log){const s=t>0?t:1e-10;e._max=(e.log===10?J:xe)(s)}else n===U.Asinh?e._max=He(t,e.asinh):e._max=t;return e._max}function Ht(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),o=wt(t)-n;if(o===0)return 0;const{distr:i}=t;if(i===U.Log){const l=t.log===10?J:xe,r=e>0?e:1e-10;return(l(r)-n)/o}return i===U.Asinh?(He(e,t.asinh)-n)/o:(e-n)/o}function _t(e,t){if(t.min==null||t.max==null)return 0;const n=mt(t),s=wt(t);if(s===n)return t.min;const{distr:o}=t;return o===U.Log?Math.pow(t.log,n+e*(s-n)):o===U.Asinh?It(n+e*(s-n),t.asinh):n+e*(s-n)}function V(e,t,n,s){const o=Ht(e,t);let i;return t.ori===_.Horizontal?i=t.dir===Y.Forward?o:1-o:i=t.dir===Y.Forward?1-o:o,s+i*n}function te(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===_.Horizontal?t.dir===Y.Backward&&(o=1-o):t.dir!==Y.Backward&&(o=1-o),_t(o,t)}class Vt{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,Gt(t))}removeScale(t){this.scales.delete(t)}getScale(t){return this.scales.get(t)}getAllScales(){return this.scales.values()}setGroupXScale(t,n){this.groupXScales.set(t,n)}getGroupXScaleKey(t){return this.groupXScales.get(t)}setRange(t,n,s){const o=this.scales.get(t);o&&(o.min=n,o.max=s,le(o))}autoRangeX(t){var s,o,i,l,r,a;const n=new Map;for(const[c,u]of this.groupXScales){const d=this.scales.get(u);if(!d||!d.auto)continue;const f=t[c];if(!f||f.x.length===0)continue;const g=f.x[0],v=f.x[f.x.length-1];if(g==null||v==null)continue;const b=n.get(u);b?(b.dataMin=Math.min(b.dataMin,g),b.dataMax=Math.max(b.dataMax,v)):n.set(u,{dataMin:g,dataMax:v})}for(const[c,{dataMin:u,dataMax:d}]of n){const f=this.scales.get(c);if(f){if(f.range){const[g,v]=Me(u,d,{min:{pad:((s=f.range.min)==null?void 0:s.pad)??0,soft:((o=f.range.min)==null?void 0:o.soft)??null,mode:((i=f.range.min)==null?void 0:i.mode)??0},max:{pad:((l=f.range.max)==null?void 0:l.pad)??0,soft:((r=f.range.max)==null?void 0:r.soft)??null,mode:((a=f.range.max)==null?void 0:a.mode)??0}});f.min=g,f.max=v}else u===d?[f.min,f.max]=Me(u,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(f.min=u,f.max=d);le(f)}}}autoRange(t,n,s){var r,a,c,u,d,f,g,v,b,P,h,C;const o=new Map;for(const[I,L]of this.groupXScales){const T=this.scales.get(L);if(!T||!T.auto)continue;const M=t[I];if(!M||M.x.length===0)continue;const m=M.x[0],S=M.x[M.x.length-1];if(m==null||S==null)continue;const y=o.get(L);y?(y.dataMin=Math.min(y.dataMin,m),y.dataMax=Math.max(y.dataMax,S)):o.set(L,{dataMin:m,dataMax:S})}for(const[I,{dataMin:L,dataMax:T}]of o){const M=this.scales.get(I);if(M){if(M.range){const[m,S]=Me(L,T,{min:{pad:((r=M.range.min)==null?void 0:r.pad)??0,soft:((a=M.range.min)==null?void 0:a.soft)??null,mode:((c=M.range.min)==null?void 0:c.mode)??0},max:{pad:((u=M.range.max)==null?void 0:u.pad)??0,soft:((d=M.range.max)==null?void 0:d.soft)??null,mode:((f=M.range.max)==null?void 0:f.mode)??0}});M.min=m,M.max=S}else L===T?[M.min,M.max]=Me(L,T,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(M.min=L,M.max=T);le(M)}}const i=new Map,l=new Map;for(const{group:I,index:L,yScale:T}of n){const M=t[I];if(!M)continue;const m=M.series[L];if(!m||m.length===0)continue;const S=s.windows.get(I),y=S?S[0]:0,R=S?S[1]:m.length-1,p=this.scales.get(T),w=(p==null?void 0:p.distr)===U.Log,[x,k]=s.getCachedMinMax(I,L,y,R,0,w),D=i.get(T),A=l.get(T);i.set(T,D!=null?Math.min(D,x):x),l.set(T,A!=null?Math.max(A,k):k)}for(const[I,L]of i){const T=this.scales.get(I);if(!T||!T.auto)continue;const M=l.get(I)??-N;if(L===N)continue;let m,S;if(T.distr===U.Log)[m,S]=Ft(L,M,T.log,!1);else{const y=T.range??{min:se,max:se};[m,S]=Me(L,M,{min:{pad:((g=y.min)==null?void 0:g.pad)??se.pad,soft:((v=y.min)==null?void 0:v.soft)??se.soft,mode:((b=y.min)==null?void 0:b.mode)??se.mode},max:{pad:((P=y.max)==null?void 0:P.pad)??se.pad,soft:((h=y.max)==null?void 0:h.soft)??se.soft,mode:((C=y.max)==null?void 0:C.mode)??se.mode}})}T.min=m,T.max=S,le(T)}}}const $t=1024;class Bt{constructor(t,n=$t){this.data=t,this.len=t.length,this.blockSize=n,this.nBlocks=Math.ceil(t.length/n),this.blocks=new Float64Array(this.nBlocks*2),this.buildAll()}buildAll(){const{data:t,blockSize:n,nBlocks:s,blocks:o,len:i}=this;for(let l=0;l<s;l++){const r=l*n,a=Math.min(r+n,i);let c=1/0,u=-1/0;for(let d=r;d<a;d++){const f=t[d];f!=null&&(f<c&&(c=f),f>u&&(u=f))}o[l*2]=c,o[l*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:i}=this;let l=1/0,r=-1/0;const a=Math.floor(t/o),c=Math.floor(n/o);if(a===c){for(let f=t;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}const u=(a+1)*o-1;for(let f=t;f<=u;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}for(let f=a+1;f<c;f++){const g=i[f*2]??1/0,v=i[f*2+1]??-1/0;g<l&&(l=g),v>r&&(r=v)}const d=c*o;for(let f=d;f<=n;f++){const g=s[f];g!=null&&(g<l&&(l=g),g>r&&(r=g))}return[l,r]}updateBlock(t){const{data:n,blockSize:s,blocks:o,len:i}=this;if(t>=this.nBlocks)return;const l=t*s,r=Math.min(l+s,i);let a=1/0,c=-1/0;for(let u=l;u<r;u++){const d=n[u];d!=null&&(d<a&&(a=d),d>c&&(c=d))}o[t*2]=a,o[t*2+1]=c}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const o=new Float64Array(this.nBlocks*2);o.set(this.blocks),this.blocks=o}const s=Math.max(0,n-1);for(let o=s;o<this.nBlocks;o++)this.updateBlock(o)}setData(t){this.data=t}}class Wt{constructor(){this.data=[],this.windows=new Map,this.minMaxCache=new Map,this.blockTrees=new Map}setData(t){this.data=t,this.windows.clear();for(const n of this.minMaxCache.values())n.clear();this.minMaxCache.clear(),this.blockTrees.clear()}getOrBuildTree(t,n){const s=`${t}:${n}`;let o=this.blockTrees.get(s);if(o)return o;const i=this.data[t];if(!i)return;const l=i.series[n];if(!(!l||l.length===0))return o=new Bt(l),this.blockTrees.set(s,o),o}updateWindows(t){var s;let n=!1;for(let o=0;o<this.data.length;o++){const i=this.data[o],l=t(o),r=this.windows.get(o);let a,c;if(!i||!l||l.min==null||l.max==null)a=0,c=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,c=0;else{a=ie(l.min,u),c=ie(l.max,u);const d=u[a],f=u[c];a>0&&d!=null&&d>l.min&&a--,c<u.length-1&&f!=null&&f<l.max&&c++}}(!r||r[0]!==a||r[1]!==c)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,c])}return n}getWindow(t){var n;return this.windows.get(t)??[0,(((n=this.data[t])==null?void 0:n.x.length)||1)-1]}getXValues(t){var n;return((n=this.data[t])==null?void 0:n.x)??[]}getYValues(t,n){var s;return((s=this.data[t])==null?void 0:s.series[n])??[]}getCachedMinMax(t,n,s,o,i,l){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${o}`;if(r){const g=r.get(a);if(g!=null)return g}else r=new Map,this.minMaxCache.set(t,r);const c=this.data[t];if(!c)return[1/0,-1/0];const u=c.series[n];if(!u||u.length===0)return[1/0,-1/0];let d;const f=!l&&i===me.Unsorted?this.getOrBuildTree(t,n):void 0;return f?d=f.rangeMinMax(s,o):d=At(u,s,o,i,l),r.set(a,d),d}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var l;const o=this.data[t];if(!o)return;const i=o.x;if(Array.isArray(i)){for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<o.series.length;r++){const a=o.series[r];if(!a||!Array.isArray(a))continue;const c=s[r];if(c)for(let d=0;d<c.length;d++)a.push(c[d]??null);const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(l=this.minMaxCache.get(t))==null||l.clear()}}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class jt{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1}}hide(){this.state.left=-10,this.state.top=-10,this.state.activeGroup=-1,this.state.activeSeriesIdx=-1,this.state.activeDataIdx=-1}update(t,n,s,o,i,l,r,a){this.state.left=t,this.state.top=n;let c=1/0,u=-1,d=-1,f=-1;const g=new Map;for(const v of i){if(v.show===!1)continue;let b=g.get(v.group);b==null&&(b=[],g.set(v.group,b)),b.push(v)}for(let v=0;v<o.length;v++){const b=o[v];if(b==null)continue;const P=b.x;if(P.length===0)continue;const h=a(v);if(h==null)continue;const C=l(h);if(C==null||C.min==null||C.max==null)continue;const[I,L]=r(v),T=s.width,M=s.left,m=te(t+M,C,T,M),S=ie(m,P,I,L),y=[S];S>I&&y.push(S-1),S<L&&y.push(S+1);const R=new Map;for(const p of y){const w=P[p];if(w==null)continue;const x=V(w,C,T,M);for(const k of g.get(v)??[]){const D=b.series[k.index];if(D==null)continue;const A=D[p];if(A==null)continue;let F=R.get(k.yScale);if(F==null&&!R.has(k.yScale)&&(F=l(k.yScale),R.set(k.yScale,F)),F==null||F.min==null||F.max==null)continue;const E=s.height,G=s.top,$=V(A,F,E,G),W=t+M-x,j=n+G-$,K=W*W+j*j;if(K<c&&(c=K,u=v,d=k.index,f=p,K===0))break}if(c===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=d,this.state.activeDataIdx=f}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const o=s[0];if(o==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const l=n.scaleManager.getScale(i);if(l==null||l.min==null||l.max==null)return;const[r,a]=n.dataStore.getWindow(0),c=ie(t,o.x,r,a),u=o.x[c];if(u==null)return;const d=V(u,l,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=c;let f=0,g=n.plotBox.height/2;for(const v of n.seriesConfigs){if(v.group!==0||v.show===!1)continue;const b=o.series[v.index];if(b==null)continue;const P=b[c];if(P==null)continue;const h=n.scaleManager.getScale(v.yScale);if(!(h==null||h.min==null||h.max==null)){g=V(P,h,n.plotBox.height,n.plotBox.top)-n.plotBox.top,f=v.index;break}}this.state.top=g,this.state.activeSeriesIdx=f}}class Xt{constructor(){this.flags=Z.None,this.frameId=null,this.callback=null}mark(t){this.flags|=t,this.scheduleFrame()}has(t){return(this.flags&t)!==0}get dirty(){return this.flags}clear(){this.flags=Z.None}onRedraw(t){this.callback=t}scheduleFrame(){this.frameId==null&&(this.frameId=requestAnimationFrame(()=>{this.frameId=null;const t=this.callback;t!=null&&t(),this.clear()}))}cancel(){this.frameId!=null&&(cancelAnimationFrame(this.frameId),this.frameId=null)}dispose(){this.cancel(),this.callback=null,this.flags=Z.None}}function Pe(e,t,n){e.lineTo(t,n)}function Le(e,t,n){e.lineTo(n,t)}function Ve(e,t,n,s,o,i){const l=[];let r=-1;const a=o===Y.Forward?n:s,c=o===Y.Forward?s:n,u=o;for(let d=a;o===Y.Forward?d<=c:d>=c;d+=u)if(t[d]===null||t[d]===void 0){if(r===-1){const f=Math.max(n,Math.min(d-o,s));r=i(e[f])}}else r!==-1&&(l.push([r,i(e[d])]),r=-1);return r!==-1&&l.push([r,i(e[s])]),l}function $e(e,t,n,s,o,i){const l=new Path2D;let r=t===_.Horizontal?n:s;const a=t===_.Horizontal?n+o:s+i,c=t===_.Horizontal?s:n,u=t===_.Horizontal?i:o;for(const[d,f]of e)d>r&&(t===_.Horizontal?l.rect(r,c,d-r,u):l.rect(c,r,u,d-r)),r=f;return r<a&&(t===_.Horizontal?l.rect(r,c,a-r,u):l.rect(c,r,u,a-r)),l}function xt(e){return(t,n,s,o,i,l)=>{s!==o&&(i!==s&&l!==s&&e(t,n,s),i!==o&&l!==o&&e(t,n,o),e(t,n,l))}}const Yt=xt(Pe),Ut=xt(Le);function vt(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.spanGaps)??!1;if([a,c]=(s.distr===U.Log?ht:Ae)(t,a,c),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=m=>d(V(m,n,o,l)),P=m=>d(V(m,s,i,r));let h,C;n.ori===_.Horizontal?(h=Pe,C=Yt):(h=Le,C=Ut);const I={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},L=I.stroke;let T=!1;if(c-a>=o*4){const m=A=>te(A,n,o,l);let S=null,y=0,R=0,p=0,w=b(e[u===Y.Forward?a:c]);const x=b(e[a]),k=b(e[c]);let D=m(u===Y.Forward?x+1:k-1);for(let A=u===Y.Forward?a:c;A>=a&&A<=c;A+=u){const F=e[A],G=(u===Y.Forward?F<D:F>D)?w:b(F),$=t[A];G===w?$!=null?(p=$,S==null?(h(L,G,P(p)),R=S=y=p):p<S?S=p:p>y&&(y=p)):$===null&&!g&&(T=!0):(S!=null&&C(L,w,P(S),P(y),P(R),P(p)),$!=null?(p=$,h(L,G,P(p)),S=y=R=p):(S=null,y=0,$===null&&!g&&(T=!0)),w=G,D=m(w+u))}S!=null&&(S!==y?C(L,w,P(S),P(y),P(R),P(p)):h(L,w,P(p)))}else for(let m=u===Y.Forward?a:c;m>=a&&m<=c;m+=u){const S=t[m];S===null&&!g?T=!0:S!=null&&h(L,b(e[m]),P(S))}{const m=I.fill=new Path2D(L),S=(f==null?void 0:f.fillTo)??s.min??0,y=P(S);let R=l,p=l+o;u===Y.Backward&&([p,R]=[R,p]),h(m,p,y),h(m,R,y)}if(T){const m=Ve(e,t,a,c,u,b);I.gaps=m,I.clip=$e(m,n.ori,l,r,o,i)}return I}}const Oe=new WeakMap;function qe(e,t,n){return typeof t=="string"?t:Kt(e,t,n)}function Kt(e,t,n){const s=Oe.get(t);if(s!=null&&s.top===n.top&&s.height===n.height)return s.grad;const o=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[i,l]of t.stops)o.addColorStop(i,l);return Oe.set(t,{grad:o,top:n.top,height:n.height}),o}function Nt(e,t,n,s,o){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const l=o??{top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=qe(e,t.fill,l),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=qe(e,t.stroke,l),e.lineWidth=r,e.lineJoin=t.join??"round",e.lineCap=t.cap??"butt",t.dash&&e.setLineDash(t.dash.map(d=>d*s));const a=t.pxAlign??1,c=r%2/2;a===1&&c>0&&e.translate(c,c),e.stroke(n.stroke)}e.restore()}const Ot=vt(),Ze=64;class qt{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.bandCache=new Map,this.lruHead=null,this.lruTail=null,this.lruMap=new Map,this.snapshotCanvas=null,this.snapshotValid=!1,this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}lruKey(t,n,s){return`${t}:${n}:${s}`}lruUnlink(t){t.prev!=null?t.prev.next=t.next:this.lruHead=t.next,t.next!=null?t.next.prev=t.prev:this.lruTail=t.prev,t.prev=null,t.next=null}lruAppend(t){t.prev=this.lruTail,t.next=null,this.lruTail!=null?this.lruTail.next=t:this.lruHead=t,this.lruTail=t}setContext(t,n){this.ctx=t,this.pxRatio=n,this.resetPropertyCache()}resetPropertyCache(){this.cachedFillStyle="",this.cachedStrokeStyle="",this.cachedLineWidth=-1,this.cachedFont="",this.cachedTextAlign="",this.cachedTextBaseline="",this.cachedGlobalAlpha=-1}setFillStyle(t,n){n!==this.cachedFillStyle&&(t.fillStyle=n,this.cachedFillStyle=n)}setStrokeStyle(t,n){n!==this.cachedStrokeStyle&&(t.strokeStyle=n,this.cachedStrokeStyle=n)}setLineWidth(t,n){n!==this.cachedLineWidth&&(t.lineWidth=n,this.cachedLineWidth=n)}setFont(t,n){n!==this.cachedFont&&(t.font=n,this.cachedFont=n)}setTextAlign(t,n){n!==this.cachedTextAlign&&(t.textAlign=n,this.cachedTextAlign=n)}setTextBaseline(t,n){n!==this.cachedTextBaseline&&(t.textBaseline=n,this.cachedTextBaseline=n)}setGlobalAlpha(t,n){n!==this.cachedGlobalAlpha&&(t.globalAlpha=n,this.cachedGlobalAlpha=n)}saveSnapshot(t,n,s){const o=t.canvas;(this.snapshotCanvas==null||this.snapshotCanvas.width!==n||this.snapshotCanvas.height!==s)&&(this.snapshotCanvas=typeof OffscreenCanvas<"u"?new OffscreenCanvas(n,s):document.createElement("canvas"),this.snapshotCanvas.width=n,this.snapshotCanvas.height=s);const i=this.snapshotCanvas.getContext("2d");i!=null&&typeof i.drawImage=="function"&&(i.clearRect(0,0,n,s),i.drawImage(o,0,0),this.snapshotValid=!0)}restoreSnapshot(t){return!this.snapshotValid||this.snapshotCanvas==null||typeof t.drawImage!="function"?!1:(t.clearRect(0,0,t.canvas.width,t.canvas.height),t.drawImage(this.snapshotCanvas,0,0),!0)}invalidateSnapshot(){this.snapshotValid=!1}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,o){const i=this.pathCache.get(t);if(i==null)return;const l=i.get(n);if(l==null)return;const r=this.windowKey(s,o),a=l.get(r);if(a!=null){const c=this.lruMap.get(this.lruKey(t,n,r));c!=null&&c!==this.lruTail&&(this.lruUnlink(c),this.lruAppend(c))}return a}setCachedPaths(t,n,s,o,i){if(this.pathCacheSize>=Ze){const u=Ze>>2;let d=this.lruHead;for(let f=0;f<u&&d!=null;f++){const g=d.next,v=this.pathCache.get(d.group);if(v!=null){const b=v.get(d.index);b!=null&&(b.delete(d.key),this.pathCacheSize--,b.size===0&&v.delete(d.index),v.size===0&&this.pathCache.delete(d.group))}this.lruMap.delete(this.lruKey(d.group,d.index,d.key)),d=g}this.lruHead=d,d!=null?d.prev=null:this.lruTail=null}let l=this.pathCache.get(t);l==null&&(l=new Map,this.pathCache.set(t,l));let r=l.get(n);r==null&&(r=new Map,l.set(n,r));const a=this.windowKey(s,o),c=this.lruKey(t,n,a);if(!r.has(a)){this.pathCacheSize++;const u={group:t,index:n,key:a,prev:null,next:null};this.lruAppend(u),this.lruMap.set(c,u)}r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const o=s.get(n);if(o!=null){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,n,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}s.delete(n)}}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const[s,o]of n.entries()){this.pathCacheSize-=o.size;for(const i of o.keys()){const l=this.lruKey(t,s,i),r=this.lruMap.get(l);r!=null&&(this.lruUnlink(r),this.lruMap.delete(l))}}this.pathCache.delete(t)}for(const s of this.bandCache.keys())s.startsWith(`${t}:`)&&this.bandCache.delete(s);this.snapshotValid=!1}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruHead=null,this.lruTail=null,this.lruMap.clear(),this.bandCache.clear(),this.snapshotValid=!1}bandKey(t,n,s,o,i){return`${t}:${n}:${s}:${o}:${i}`}getCachedBandPath(t,n,s,o,i){return this.bandCache.get(this.bandKey(t,n,s,o,i))}setCachedBandPath(t,n,s,o,i,l){this.bandCache.set(this.bandKey(t,n,s,o,i),l)}drawSeries(t,n,s){const o=this.ctx;if(o==null||t.config.show===!1)return;const i=t.config.group,l=t.config.index,[r,a]=t.window;let c=this.getCachedPaths(i,l,r,a);if(c==null){const u=t.config.paths??Ot,d=t.xScale.dir,f=b=>B(b),g=t.config.fillTo,v=typeof g=="function"?g(t.yScale.min??0,t.yScale.max??0):g;c=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,r,a,d,f,{fillTo:v,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,l,r,a,c)}Nt(o,t.config,c,s,n)}draw(t,n,s,o){const i=this.ctx;if(i==null)return;const l=this.pxRatio;i.clearRect(0,0,t*l,n*l),i.save(),i.scale(l,l),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of o)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const Mt=[1,2,2.5,5],Zt=gt(10,-32,0,Mt),Jt=gt(10,0,32,Mt),ae=Zt.concat(Jt);function Qt(e,t,n,s,o){if(n<=0||t<e)return[];const i=[],l=we.get(n)??0,r=o?e:re(_e(e,n),l);for(let a=r;a<=t;a=re(a+n,l))i.push(Object.is(a,-0)?0:a);return i}function Je(e){return e.map(t=>pt(t))}function en(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=ne((n===10?J:xe)(e));let l=pe(n,i);n===10&&(l=ae[ie(l,ae)]??l);let r=l,a=l*n;n===10&&(a=ae[ie(a,ae)]??a);let c=0;do{if(r>=e&&s.push(r),r=r+l,n===10&&!we.has(r)){const u=we.get(l)??0;r=re(r,u)}r>=a*(1-1e-10)&&(l=r,a=l*n,n===10&&(a=ae[ie(a,ae)]??a))}while(r<=t&&++c<1e4);return s}function tn(e,t){const n=t===10?J:xe;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const o=n(s);return fe(o-Math.round(o))<1e-10})}function nn(e,t){const s=pt(Math.max(Math.abs(e),Math.abs(t))).length*7;return Math.max(50,s+16)}function sn(e,t,n,s){if(s<=0)return[0,0];const o=he(e.side)===_.Vertical,i=e.space??(o?30:nn(t,n)),l=e.incrs??ae;return Et(t,n,l,s,i)}const on=50;function ln(e,t,n){var r,a;if(e.size!=null)return e.size;const s=((r=e.ticks)==null?void 0:r.show)!==!1?((a=e.ticks)==null?void 0:a.size)??10:0,o=e.gap??5,i=12;if(he(e.side)===_.Vertical&&t!=null){let c=0;for(const d of t)d.length>c&&(c=d.length);const u=c*7;return Math.max(50,s+o+u+4)}return Math.max(50,s+o+i+3)}function rn(e){return{config:e,_show:e.show!==!1,_size:e.size??on,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const ge=60,ce=3600,oe=86400,ue=2592e3,Ce=31536e3,an=[1,5,10,15,30,ge,5*ge,10*ge,15*ge,30*ge,ce,2*ce,3*ce,4*ce,6*ce,12*ce,oe,2*oe,3*oe,7*oe,14*oe,ue,2*ue,3*ue,6*ue,Ce];function cn(e,t,n,s){const o=[];if(n<=0||e>=t)return o;let i;if(n>=Ce){const l=new Date(e*1e3);for(l.setUTCMonth(0,1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(l.setUTCFullYear(l.getUTCFullYear()+1),i=l.getTime()/1e3);i<=t;)o.push(i),l.setUTCFullYear(l.getUTCFullYear()+Math.round(n/Ce)),i=l.getTime()/1e3;return o}if(n>=ue){const l=new Date(e*1e3);l.setUTCDate(1),l.setUTCHours(0,0,0,0),i=l.getTime()/1e3;const r=Math.max(1,Math.round(n/ue));if(i<e&&(l.setUTCMonth(l.getUTCMonth()+1),i=l.getTime()/1e3),r>1){const a=l.getUTCMonth(),c=Math.ceil((a+1)/r)*r;l.setUTCMonth(c-1),i=l.getTime()/1e3}for(;i<=t;)o.push(i),l.setUTCMonth(l.getUTCMonth()+r),i=l.getTime()/1e3;return o}if(n>=oe){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(i+=oe)}else i=Math.ceil(e/n)*n;for(let l=0;;l++){const r=i+l*n;if(r>t)break;o.push(r)}return o}const Qe=new Map;function un(e,t){const n=JSON.stringify(e)+(t??"");let s=Qe.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),Qe.set(n,s)),s}function Q(e,t,n){const s=new Date(e*1e3);return un(t,n).format(s)}function fn(e,t){return Q(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function hn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function dn(e,t){return Q(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function gn(e,t){return Q(e,{month:"short",day:"numeric"},t)}function pn(e,t){return Q(e,{year:"numeric"},t)}function mn(e,t){return Q(e,{year:"numeric",month:"short"},t)}function wn(e,t,n){let s;return t>=Ce?s=pn:t>=ue?s=mn:t>=oe?s=gn:t>=ce?s=dn:t>=ge?s=hn:s=fn,e.map(o=>s(o,n))}function xn(e,t,n,s,o){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,c=s/a;if(c>=o)return[r,c]}const l=n[n.length-1]??Ce;return[l,s/(i/l)]}const vn=3;function Mn(e,t,n,s,o){let i=!0;for(const l of e){const r=l.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){l._show&&(i=!1,l._show=!1);continue}else l._show||(i=!1,l._show=!0);const c=r.side,d=he(c)===_.Horizontal?n:s,{min:f,max:g}=a;let v,b;if(a.time){const h=r.space??80;[v,b]=xn(f,g,an,d,h)}else[v,b]=sn(r,f,g,d);if(l._incr=v,l._space=b,b===0)continue;if(r.splits)l._splits=r.splits(f,g,v,b);else if(a.time)l._splits=cn(f,g,v);else if(a.distr===U.Log)l._splits=en(f,g,a.log);else{const h=a.distr===U.Ordinal;l._splits=Qt(f,g,v,b,h)}if(r.values)l._values=r.values(l._splits,b,v);else if(a.time)l._values=wn(l._splits,v);else if(a.distr===U.Log){const h=tn(l._splits,a.log),C=Je(l._splits);l._values=C.map((I,L)=>h[L]?I:"")}else l._values=Je(l._splits);l._rotate=c===X.Bottom?r.rotate??0:0;const P=l._size;l._size=ye(ln(r,l._values)),P!==l._size&&(i=!1)}return i}function et(e,t,n){let s=e,o=t,i=0,l=0;for(const r of n){if(!r._show)continue;const a=r.config.side,c=he(a)===_.Vertical,u=r.config.label!=null?r.config.labelSize??20:0,d=r._size+u;d>0&&(c?(s-=d,a===X.Left&&(i+=d)):(o-=d,a===X.Top&&(l+=d)))}return{left:i,top:l,width:Math.max(s,0),height:Math.max(o,0)}}function bn(e,t){let n=t.top,s=t.left+t.width,o=t.top+t.height,i=t.left;function l(r,a){switch(r){case X.Top:return n-=a,n+a;case X.Right:{const c=s;return s+=a,c}case X.Bottom:{const c=o;return o+=a,c}case X.Left:return i-=a,i+a;default:return 0}}for(const r of e){if(!r._show)continue;const a=r.config.side;if(r._pos=l(a,r._size),r.config.label!=null){const c=r.config.labelSize??20;r._lpos=l(a,c)}}}function Sn(e,t,n,s){for(const r of n)r._size=0;let o=!1,i=0,l={left:0,top:0,width:e,height:t};for(;!o;){i++;const r=Mn(n,s,l.width,l.height);o=i===vn||r,o||(l=et(e,t,n))}return l=et(e,t,n),bn(n,l),l}const tt="top",nt="bottom",yn="left",kn="right";function st(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function ot(e,t,n,s,o,i,l,r,a,c,u){const d=r%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=r,c.length>0&&e.setLineDash(c),e.beginPath();let f=0,g=0,v=0,b=0;const P=i+(o===X.Top||o===X.Left?-l:l);s===_.Horizontal?(g=i,b=P):(f=i,v=P);for(let h=0;h<t.length;h++)n[h]!=null&&(s===_.Horizontal?f=v=t[h]??0:g=b=t[h]??0,e.moveTo(f,g),e.lineTo(v,b));e.stroke(),e.restore()}function Cn(e,t,n,s,o){const i=B(s.left*o),l=B(s.top*o),r=B(s.width*o),a=B(s.height*o);for(const c of t){if(!c._show)continue;const u=c.config,d=u.side,f=he(d),g=n(u.scale);if(!g||g.min==null||g.max==null)continue;const v=u.stroke??"#000",b=d===X.Top||d===X.Left?-1:1,P=c._splits,h=c._values;if(!P||!h||c._space===0)continue;const C=f===_.Horizontal?s.width:s.height,I=f===_.Horizontal?s.left:s.top,L=P.map(y=>B(V(y,g,C,I)*o)),T=h.map(y=>y===""?null:y),M=u.grid;if((M==null?void 0:M.show)!==!1){const y=(M==null?void 0:M.stroke)??"rgba(0,0,0,0.12)",R=B(((M==null?void 0:M.width)??2)*o),p=((M==null?void 0:M.dash)??[]).map(k=>k*o),w=f===_.Horizontal?l:i,x=f===_.Horizontal?a:r;ot(e,L,T,f,2,w,x,R,y,p)}const m=u.ticks;if((m==null?void 0:m.show)!==!1){const y=(m==null?void 0:m.stroke)??v,R=B(((m==null?void 0:m.width)??1)*o),p=B(((m==null?void 0:m.size)??10)*o),w=((m==null?void 0:m.dash)??[]).map(k=>k*o),x=B(c._pos*o);ot(e,L,T,f,d,x,p,R,y,w)}{const y=(m==null?void 0:m.show)!==!1?((m==null?void 0:m.size)??10)*o:0,R=B((u.gap??5)*o),p=B(c._pos*o),w=(y+R)*b,x=p+w,k=st(u.font??"12px system-ui, sans-serif",o),D=f===_.Horizontal?"center":d===X.Left?kn:yn,A=f===_.Horizontal?d===X.Bottom?tt:nt:"middle";e.font=k,e.fillStyle=v,e.textAlign=D,e.textBaseline=A;const F=c._rotate*-ze/180;if(F!==0){const E=Math.cos(F),G=Math.sin(F);for(let $=0;$<h.length;$++){const W=h[$];if(W==null||W==="")continue;const j=L[$]??0;e.setTransform(E,G,-G,E,j,x),e.fillText(W,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let E=0;E<h.length;E++){const G=h[E];if(G==null||G==="")continue;const $=L[E]??0,W=f===_.Horizontal?$:x,j=f===_.Horizontal?x:$;e.fillText(G,W,j)}}if(u.label!=null){const y=st(u.labelFont??"bold 12px system-ui, sans-serif",o);e.font=y,e.fillStyle=v,e.textAlign="center",e.textBaseline=d===X.Bottom?tt:nt;const R=B((c._lpos+(u.labelGap??0)*b)*o);f===_.Vertical?(e.save(),e.translate(R,B(l+a/2)),e.rotate((d===X.Left?-ze:ze)/2),e.fillText(u.label,0,0),e.restore()):e.fillText(u.label,B(i+r/2),R)}const S=u.border;if((S==null?void 0:S.show)!==!1&&S!=null){const y=S.stroke??v,R=B((S.width??1)*o),p=(S.dash??[]).map(x=>x*o),w=B(c._pos*o);e.strokeStyle=y,e.lineWidth=R,p.length>0&&e.setLineDash(p),e.beginPath(),f===_.Horizontal?(e.moveTo(i,w),e.lineTo(i+r,w)):(e.moveTo(w,l),e.lineTo(w,l+a)),e.stroke(),p.length>0&&e.setLineDash([])}}}const Tn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function lt(e,t,n,s,o,i,l,r,a){var I;if(t.left<0||t.top<0)return;const c={...Tn,...a},u=s,d=B(n.left*u),f=B(n.top*u),g=B(n.width*u),v=B(n.height*u),b=B(c.width*u),P=b%2/2,h=B((n.left+t.left)*u)+P,C=B((n.top+t.top)*u)+P;if(e.save(),e.strokeStyle=c.stroke,e.lineWidth=b,e.setLineDash(c.dash.map(L=>L*u)),c.showX&&(e.beginPath(),e.moveTo(h,f),e.lineTo(h,f+v),e.stroke()),c.showY&&(e.beginPath(),e.moveTo(d,C),e.lineTo(d+g,C),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const L=t.activeGroup,T=t.activeSeriesIdx,M=t.activeDataIdx,m=o[L];if(m!=null&&T>=0&&T<m.series.length&&M<m.x.length){const S=m.x[M],y=m.series[T],R=y!=null?y[M]:null;if(S!=null&&R!=null){let p=c.stroke,w=!0;for(const x of i)if(x.group===L&&x.index===T){const k=x.stroke;p=(typeof k=="string"?k:void 0)??c.stroke,w=((I=x.cursor)==null?void 0:I.show)!==!1;break}if(w){const x=r(L),k=x!=null?l(x):void 0,D=In(i,L,T),A=D!=null?l(D):void 0;if(k!=null&&A!=null&&k.min!=null&&k.max!=null&&A.min!=null&&A.max!=null){const F=B(V(S,k,n.width,n.left)*u),E=B(V(R,A,n.height,n.top)*u),G=c.pointRadius*u,$=B(2*u);e.beginPath(),e.arc(F,E,G,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=p,e.lineWidth=$,e.stroke()}}}}}e.restore()}function In(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const An={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function it(e,t,n,s,o){if(!t.show||t.width<=0)return;const i={...An,...o},l=s,r=B((n.left+t.left)*l),a=B((n.top+t.top)*l),c=B(t.width*l),u=B(t.height*l);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,c,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=B(i.width*l),e.strokeRect(r,a,c,u)),e.restore()}function Pn(e,t,n,s,o,i,l,r,a,c,u,d){const f=u/2*l,g=Math.max(1,B(u*.2))*l,v=(c==null?void 0:c.stroke)??d,b=(c==null?void 0:c.fill)??"#fff";e.save(),e.strokeStyle=v,e.fillStyle=b,e.lineWidth=g,(c==null?void 0:c.dash)!=null&&e.setLineDash(c.dash.map(P=>P*l));for(let P=r;P<=a;P++){const h=n[P];if(h==null)continue;const C=t[P];if(C==null)continue;const I=B(V(C,s,i.width,i.left)*l),L=B(V(h,o,i.height,i.top)*l);e.beginPath(),e.arc(I,L,f,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function Ln(e,t,n,s,o,i,l){if(typeof e=="function")return e(t,n,s,o,i);if(e===!0)return!0;if(e===!1)return!1;const r=o-s;return r>0&&r<=i/l}function Rn(e,t,n,s,o,i,l,r,a){if(r>a||r<0)return null;const c=g=>V(g,s,i.width,i.left)*l,u=g=>V(g,o,i.height,i.top)*l,d=new Path2D;let f=!1;for(let g=r;g<=a;g++){const v=t[g],b=e[g];if(v==null||b==null)continue;const P=c(b),h=u(v);f?d.lineTo(P,h):(d.moveTo(P,h),f=!0)}if(!f)return null;for(let g=a;g>=r;g--){const v=n[g],b=e[g];v==null||b==null||d.lineTo(c(b),u(v))}return d.closePath(),d}function Dn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function Ee(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(l,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.width,t.left)},valToY:(l,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:V(l,a,t.height,t.top)}}}function zn(){const e={scaleManager:new Vt,dataStore:new Wt,renderer:new qt,cursorManager:new jt,selectState:{show:!1,left:0,top:0,width:0,height:0},scaleConfigs:[],seriesConfigs:[],axisConfigs:[],bandConfigs:[],axisStates:[],width:0,height:0,pxRatio:typeof window<"u"&&window.devicePixelRatio||1,plotBox:{left:0,top:0,width:0,height:0},canvas:null,listeners:new Set,scheduler:new Xt,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,registerScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t.id),e.scaleConfigs.push(t),e.scaleManager.addScale(t)},unregisterScale(t){e.scaleConfigs=e.scaleConfigs.filter(n=>n.id!==t),e.scaleManager.removeScale(t)},registerSeries(t){e.seriesConfigs=e.seriesConfigs.filter(n=>!(n.group===t.group&&n.index===t.index)),e.seriesConfigs.push(t)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n))},toggleSeries(t,n){const s=e.seriesConfigs.find(o=>o.group===t&&o.index===n);s!=null&&(s.show=s.show===!1,e.revision++,e.renderer.invalidateSeries(t,n),e.scheduleRedraw())},setFocus(t){e.focusedSeries=t,e.scheduleRedraw()},setSize(t,n){e.width=t,e.height=n,e.canvas&&(e.canvas.width=t*e.pxRatio,e.canvas.height=n*e.pxRatio,e.canvas.style.width=`${t}px`,e.canvas.style.height=`${n}px`),e.renderer.clearCache(),e.scheduleRedraw()},scheduleRedraw(){e.scheduler.mark(Z.Full)},scheduleCursorRedraw(){e.scheduler.mark(Z.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:o,width:i,height:l,pxRatio:r,canvas:a,scheduler:c}=e;if(a==null||i===0||l===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const f=(c.dirty&~(Z.Cursor|Z.Select))===0,g=h=>t.getScale(h);if(f&&s.restoreSnapshot(u)){if(lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Ee(u,e.plotBox,r,g);for(const C of e.cursorDrawHooks)try{C(h,e.cursorManager.state)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}for(const h of e.listeners)h();return}t.autoRangeX(n.data),n.updateWindows(h=>{const C=t.getGroupXScaleKey(h);return C!=null?t.getScale(C):void 0});const v=o.map(h=>({group:h.group,index:h.index,yScale:h.yScale}));t.autoRange(n.data,v,n),Fn(e),e.axisStates.length>0?e.plotBox=Sn(i,l,e.axisStates,g):e.plotBox={left:10,top:10,width:i-20,height:l-20},u.clearRect(0,0,i*r,l*r),e.axisStates.length>0&&Cn(u,e.axisStates,g,e.plotBox,r);const b=[];for(const h of o){const C=t.getGroupXScaleKey(h.group),I=C!=null?t.getScale(C):void 0,L=t.getScale(h.yScale);I==null||L==null||b.push({config:h,dataX:n.getXValues(h.group),dataY:n.getYValues(h.group,h.index),xScale:I,yScale:L,window:n.getWindow(h.group)})}u.save(),u.scale(r,r),u.beginPath(),u.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),u.clip();for(let h=0;h<b.length;h++){const C=b[h];C!=null&&(e.focusedSeries!=null&&h!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(C,e.plotBox,1),u.globalAlpha=1):s.drawSeries(C,e.plotBox,1))}const P=new Map;for(const h of o)P.set(`${h.group}-${h.index}`,h);for(const h of e.bandConfigs){const C=t.getGroupXScaleKey(h.group),I=C!=null?t.getScale(C):void 0,L=P.get(`${h.group}-${h.series[0]}`),T=P.get(`${h.group}-${h.series[1]}`);if(I==null||L==null||T==null)continue;const M=t.getScale(L.yScale);if(M==null)continue;const[m,S]=n.getWindow(h.group),y=h.series[0],R=h.series[1];let p=s.getCachedBandPath(h.group,y,R,m,S);p==null&&(p=Rn(n.getXValues(h.group),n.getYValues(h.group,y),n.getYValues(h.group,R),I,M,e.plotBox,r,m,S)??void 0,p!=null&&s.setCachedBandPath(h.group,y,R,m,S,p)),p!=null&&Dn(u,h,p)}for(const h of b){const C=h.config;if(C.show===!1)continue;const I=C.points,L=C.width??1,T=(I==null?void 0:I.size)??3+L*2,M=(I==null?void 0:I.space)??T*2,[m,S]=h.window;Ln(I==null?void 0:I.show,C.group,C.index,m,S,e.plotBox.width,M)&&Pn(u,h.dataX,h.dataY,h.xScale,h.yScale,e.plotBox,r,m,S,I,T,(typeof C.stroke=="string"?C.stroke:null)??"#000")}if(u.restore(),e.drawHooks.size>0){u.save(),u.beginPath(),u.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),u.clip(),u.scale(r,r);const h=Ee(u,e.plotBox,r,g);for(const C of e.drawHooks)try{C(h)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,l*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,g,h=>n.getWindow(h),h=>t.getGroupXScaleKey(h))),lt(u,e.cursorManager.state,e.plotBox,r,n.data,o,g,h=>t.getGroupXScaleKey(h)),it(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const h=Ee(u,e.plotBox,r,g);for(const C of e.cursorDrawHooks)try{C(h,e.cursorManager.state)}catch(I){console.warn("[uPlot+] draw hook error:",I)}u.restore()}for(const h of e.listeners)h();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const h of t.getAllScales()){if(h.min==null||h.max==null)continue;const C=e._prevScaleRanges.get(h.id);if(C==null||C.min!==h.min||C.max!==h.max)try{e.eventCallbacks.onScaleChange(h.id,h.min,h.max)}catch(I){console.warn("[uPlot+] event callback error:",I)}}e._prevScaleRanges.clear();for(const h of t.getAllScales())h.min!=null&&h.max!=null&&e._prevScaleRanges.set(h.id,{min:h.min,max:h.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function Fn(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const o of n)s.set(`${o.config.scale}:${o.config.side}`,o);e.axisStates=t.map(o=>{const i=`${o.scale}:${o.side}`,l=s.get(i);return l!=null?(l.config=o,l):rn(o)})}function En(){const e=z.useRef(null);return e.current===null&&(e.current=zn()),e.current}const bt=z.createContext(null);function ee(){const e=z.useContext(bt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function Gn(e,t){z.useEffect(()=>{if(t!=null)return Hn(e,t)},[e,t])}function Hn(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let o=null,i=null,l=!1;function r(p){const w=t.getBoundingClientRect(),x=e.plotBox,k=p.clientX-w.left-x.left,D=p.clientY-w.top-x.top;return{cx:k,cy:D}}function a(p,w){const x=e.plotBox;return p>=0&&p<=x.width&&w>=0&&w<=x.height}function c(p,w){const x=t.getBoundingClientRect(),k=p-x.left,D=w-x.top,A=e.plotBox;for(const F of e.axisStates){const E=F.config,G=E.side;if(F._size<=0)continue;const W=D>=A.top&&D<=A.top+A.height,j=k>=A.left&&k<=A.left+A.width;if(G===X.Left&&k<A.left&&W||G===X.Right&&k>A.left+A.width&&W||G===X.Top&&D<A.top&&j||G===X.Bottom&&D>A.top+A.height&&j){const O=he(G);return{scaleId:E.scale,ori:O}}}return null}function u(p,w,x){const k=e.cursorManager.state;let D=null;if(k.activeGroup>=0&&k.activeDataIdx>=0){const A=e.dataStore.data[k.activeGroup];if(A!=null){const F=A.x[k.activeDataIdx],E=A.series[k.activeSeriesIdx],G=E!=null?E[k.activeDataIdx]:void 0;if(F!=null&&G!=null){const $=e.plotBox,W=e.scaleManager.getGroupXScaleKey(k.activeGroup),j=W!=null?e.scaleManager.getScale(W):void 0,K=e.seriesConfigs.find(Ye=>Ye.group===k.activeGroup&&Ye.index===k.activeSeriesIdx),O=K!=null?e.scaleManager.getScale(K.yScale):void 0;let de=w,De=x;(j==null?void 0:j.min)!=null&&j.max!=null&&(de=V(F,j,$.width,$.left)-$.left),(O==null?void 0:O.min)!=null&&O.max!=null&&(De=V(G,O,$.height,$.top)-$.top);const je=w-de,Xe=x-De;D={group:k.activeGroup,seriesIdx:k.activeSeriesIdx,dataIdx:k.activeDataIdx,xVal:F,yVal:G,pxX:de,pxY:De,dist:Math.sqrt(je*je+Xe*Xe)}}}}return{plotX:w,plotY:x,point:D,srcEvent:p}}function d(p){const w=e.plotBox,x=p.left/w.width,k=(p.left+p.width)/w.width,D={};for(const A of e.scaleManager.getAllScales()){if(A.ori!==_.Horizontal||A.min==null||A.max==null)continue;const F=te(w.left+x*w.width,A,w.width,w.left),E=te(w.left+k*w.width,A,w.width,w.left);D[A.id]={min:Math.min(F,E),max:Math.max(F,E)}}return{left:x,right:k,ranges:D}}function f(){const p=e.eventCallbacks.onScaleChange;if(p!=null)for(const w of e.scaleManager.getAllScales()){if(w.min==null||w.max==null)continue;const x=e._prevScaleRanges.get(w.id);(x==null||x.min!==w.min||x.max!==w.max)&&p(w.id,w.min,w.max)}}function g(p,w){if(i!=null){const A=t.getBoundingClientRect(),F=p.clientY-A.top,E=e.plotBox,G=(F-i.startY)/E.height,$=i.startMax-i.startMin,W=e.scaleManager.getScale(i.scaleId);W!=null&&(W.min=i.startMin+G*$,W.max=i.startMax+G*$,W.auto=!1,le(W),e.renderer.clearCache(),e.scheduleRedraw());return}const x=r(p);if(x==null)return;const{cx:k,cy:D}=x;if(!a(k,D)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(k,D,e.plotBox,e.dataStore.data,e.seriesConfigs,A=>e.scaleManager.getScale(A),A=>e.dataStore.getWindow(A),A=>e.scaleManager.getGroupXScaleKey(A)),e.focusAlpha<1){const A=e.cursorManager.state;if(A.activeGroup>=0&&A.activeSeriesIdx>=0){const F=e.seriesConfigs.findIndex(E=>E.group===A.activeGroup&&E.index===A.activeSeriesIdx);F>=0&&e.focusedSeries!==F&&(e.focusedSeries=F,e.scheduleRedraw())}}if(w!=null&&e.eventCallbacks.onCursorMove!=null&&a(k,D))try{e.eventCallbacks.onCursorMove(u(w,k,D))}catch(A){console.warn("[uPlot+] event callback error:",A)}if(n!=null){const A=n.x,F=e.plotBox,E=Math.max(0,Math.min(k,F.width));s.show=!0,s.left=Math.min(A,E),s.top=0,s.width=Math.abs(E-A),s.height=F.height,e.selectState=s}n!=null?e.scheduler.mark(Z.Cursor|Z.Select):e.scheduleCursorRedraw()}function v(p){g(p,p)}function b(p){if(p.button!==0)return;const w=c(p.clientX,p.clientY);if(w!=null&&w.ori===_.Vertical){const k=e.scaleManager.getScale(w.scaleId);if(k!=null&&k.min!=null&&k.max!=null){const D=t.getBoundingClientRect();i={scaleId:w.scaleId,startY:p.clientY-D.top,startMin:k.min,startMax:k.max},p.preventDefault();return}}const x=r(p);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function P(p){if(i!=null){f(),i=null;return}if(n!=null){if(s.width>5){l=!0;let w=!0;if(e.eventCallbacks.onSelect!=null){const x=d(s);let k;try{k=e.eventCallbacks.onSelect(x)}catch(D){console.warn("[uPlot+] event callback error:",D)}k===!1&&(w=!1)}w&&(m(s),f())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function h(p){P()}function C(p){if(l){l=!1;return}const w=e.eventCallbacks.onClick;if(w==null)return;const x=r(p);if(x!=null&&a(x.cx,x.cy))try{w(u(p,x.cx,x.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}}function I(p){const w=e.eventCallbacks.onContextMenu;if(w==null)return;const x=r(p);if(x!=null&&a(x.cx,x.cy)){p.preventDefault();try{w(u(p,x.cx,x.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}}}function L(p){var w,x;e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),n!=null&&(n=null,s.show=!1,s.width=0,e.selectState=s),i!=null&&(i=null),e.scheduleCursorRedraw();try{(x=(w=e.eventCallbacks).onCursorLeave)==null||x.call(w)}catch(k){console.warn("[uPlot+] event callback error:",k)}}function T(p){if(e.eventCallbacks.onDblClick!=null){const w=r(p);if(w!=null&&a(w.cx,w.cy)){let x;try{x=e.eventCallbacks.onDblClick(u(p,w.cx,w.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}if(x===!1)return}}for(const w of e.scaleConfigs)e.scaleManager.addScale(w);e.renderer.clearCache(),e.scheduleRedraw()}function M(p){if(!e.wheelZoom)return;const w=r(p);if(w==null||!a(w.cx,w.cy))return;p.preventDefault();const x=Math.max(.1,Math.min(10,1-p.deltaY*.001)),k=e.plotBox;for(const D of e.scaleManager.getAllScales()){if(D.ori!==_.Horizontal||D.min==null||D.max==null)continue;const A=te(w.cx+k.left,D,k.width,k.left),F=A-(A-D.min)*x,E=A+(D.max-A)*x;D.min=Math.min(F,E),D.max=Math.max(F,E),D.auto=!1,le(D)}e.renderer.clearCache(),e.scheduleRedraw(),f()}function m(p){const w=e.plotBox,x=p.left/w.width,k=(p.left+p.width)/w.width;for(const D of e.scaleManager.getAllScales()){if(D.ori!==_.Horizontal||D.min==null||D.max==null)continue;const A=te(w.left+x*w.width,D,w.width,w.left),F=te(w.left+k*w.width,D,w.width,w.left);D.min=Math.min(A,F),D.max=Math.max(A,F),D.auto=!1,le(D)}e.renderer.clearCache()}function S(p){if(p.touches.length===2){const k=p.touches[0],D=p.touches[1],A=D.clientX-k.clientX,F=D.clientY-k.clientY;o={dist:Math.sqrt(A*A+F*F),midX:(k.clientX+D.clientX)/2,midY:(k.clientY+D.clientY)/2},n=null;return}const w=p.touches[0];if(w==null)return;const x=r(w);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},l=!1)}function y(p){if(p.touches.length===2&&o!=null){p.preventDefault();const x=p.touches[0],k=p.touches[1],D=k.clientX-x.clientX,A=k.clientY-x.clientY,F=Math.sqrt(D*D+A*A),E=F/o.dist,G=t.getBoundingClientRect(),$=e.plotBox,W=o.midX-G.left-$.left;for(const j of e.scaleManager.getAllScales()){if(j.ori!==_.Horizontal||j.min==null||j.max==null)continue;const K=te(W+$.left,j,$.width,$.left),O=K-(K-j.min)/E,de=K+(j.max-K)/E;j.min=Math.min(O,de),j.max=Math.max(O,de),j.auto=!1,le(j)}o.dist=F,e.renderer.clearCache(),e.scheduleRedraw(),f();return}const w=p.touches[0];w!=null&&(g(w,p),n!=null&&p.preventDefault())}function R(p){if(o!=null){o=null;return}p.changedTouches[0]!=null&&P()}return t.addEventListener("mousemove",v),t.addEventListener("mousedown",b),t.addEventListener("mouseup",h),t.addEventListener("click",C),t.addEventListener("contextmenu",I),t.addEventListener("mouseleave",L),t.addEventListener("dblclick",T),t.addEventListener("wheel",M,{passive:!1}),t.addEventListener("touchstart",S,{passive:!0}),t.addEventListener("touchmove",y,{passive:!1}),t.addEventListener("touchend",R),()=>{t.removeEventListener("mousemove",v),t.removeEventListener("mousedown",b),t.removeEventListener("mouseup",h),t.removeEventListener("click",C),t.removeEventListener("contextmenu",I),t.removeEventListener("mouseleave",L),t.removeEventListener("dblclick",T),t.removeEventListener("wheel",M),t.removeEventListener("touchstart",S),t.removeEventListener("touchmove",y),t.removeEventListener("touchend",R)}}const Ge=new Map;function _n(e){let t=Ge.get(e);return t==null&&(t=new Vn(e),Ge.set(e,t)),t}class Vn{constructor(t){this.members=new Set,this.publishing=!1,this.syncedStores=new WeakSet,this.key=t}join(t){this.members.add(t)}leave(t){this.members.delete(t),this.members.size===0&&Ge.delete(this.key)}pub(t){if(this.publishing)return;if(this.syncedStores.has(t)){this.syncedStores.delete(t);return}this.publishing=!0;const n=t.cursorManager.state,{activeGroup:s,activeDataIdx:o}=n;if(s<0||o<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const l=t.dataStore.getXValues(s)[o];if(l==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(l,r),r.scheduleCursorRedraw());this.publishing=!1}}function $n(e,t){z.useEffect(()=>{if(t==null)return;const n=_n(t);n.join(e);let s=-1,o=-1;const i=e.subscribe(()=>{const{activeGroup:l,activeDataIdx:r}=e.cursorManager.state;l===s&&r===o||(s=l,o=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function Re({width:e,height:t,data:n,children:s,className:o,pxRatio:i,onDraw:l,onCursorDraw:r,syncKey:a,cursor:c,onClick:u,onContextMenu:d,onDblClick:f,onCursorMove:g,onCursorLeave:v,onScaleChange:b,onSelect:P}){var w;const h=En(),[C,I]=z.useState(null),L=i??(typeof window<"u"&&window.devicePixelRatio||1),T=(c==null?void 0:c.wheelZoom)??!1,M=((w=c==null?void 0:c.focus)==null?void 0:w.alpha)??((c==null?void 0:c.focus)!=null?.15:1);z.useEffect(()=>{h.wheelZoom=T,h.focusAlpha=M},[h,T,M]),h.eventCallbacks.onClick=u,h.eventCallbacks.onContextMenu=d,h.eventCallbacks.onDblClick=f,h.eventCallbacks.onCursorMove=g,h.eventCallbacks.onCursorLeave=v,h.eventCallbacks.onScaleChange=b,h.eventCallbacks.onSelect=P,Gn(h,C),$n(h,a);const m=z.useCallback(x=>{h.canvas=x,x&&h.scheduleRedraw()},[h]),S=z.useCallback(x=>{I(x)},[]);z.useEffect(()=>{h.pxRatio=L,h.setSize(e,t)},[h,e,t,L]),z.useEffect(()=>()=>{h.canvas=null,h.scheduler.cancel(),h.focusedSeries=null},[h]),z.useEffect(()=>{if(C==null||typeof ResizeObserver>"u")return;const x=new ResizeObserver(k=>{const D=k[0];if(D==null)return;const{width:A,height:F}=D.contentRect;A>0&&F>0&&(A!==h.width||F!==h.height)&&h.setSize(Math.round(A),Math.round(F))});return x.observe(C),()=>{x.disconnect()}},[h,C]);const y=z.useRef(n);z.useEffect(()=>{if(n===y.current&&h.dataStore.data.length>0)return;y.current=n,h.dataStore.setData(n),h.renderer.clearCache();const x="x";h.scaleManager.getScale(x)||h.registerScale({id:x,auto:!0});for(let k=0;k<n.length;k++)h.scaleManager.setGroupXScale(k,x);h.scheduleRedraw()},[h,n]);const R=z.useRef(l);R.current=l,z.useEffect(()=>{const x=k=>{var D;(D=R.current)==null||D.call(R,k)};return h.drawHooks.add(x),()=>{h.drawHooks.delete(x)}},[h]);const p=z.useRef(r);return p.current=r,z.useEffect(()=>{const x=(k,D)=>{var A;(A=p.current)==null||A.call(p,k,D)};return h.cursorDrawHooks.add(x),()=>{h.cursorDrawHooks.delete(x)}},[h]),H.jsx(bt.Provider,{value:h,children:H.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[H.jsx("div",{ref:S,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:H.jsx("canvas",{ref:m,style:{position:"absolute",left:0,top:0}})}),s]})})}function rt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Bn(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const o of s)if(e[o]!==t[o])return!1;return!0}function Be(e,t){if(e===null)return!1;const n=e,s=t,o=Object.keys(n),i=Object.keys(s);if(o.length!==i.length)return!1;for(const l of i){const r=n[l],a=s[l];if(r!==a)if(rt(r)&&rt(a)){if(!Bn(r,a))return!1}else return!1}return!0}function Te(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(o=>o.id===e.id?{...e}:o),t.scaleManager.addScale({...e}),t.scheduleRedraw())}),null}function We(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const o=n.current;return t.registerSeries({...o,show:o.show??!0}),t.renderer.clearCache(),t.scheduleRedraw(),()=>{t.unregisterSeries(o.group,o.index),t.renderer.clearCache(),t.scheduleRedraw()}},[t,e.group,e.index]);const s=z.useRef(null);return z.useEffect(()=>{Be(s.current,e)||(s.current=e,t.seriesConfigs=t.seriesConfigs.map(o=>o.group===e.group&&o.index===e.index?{...e,show:e.show??!0}:o),t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw())}),null}function Wn(e){return{...e,side:e.side??(e.scale==="x"?X.Bottom:X.Left),show:e.show??!0}}function Ie(e){const t=ee(),n=Wn(e),s=z.useRef(n);s.current=n,z.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(l=>!(l.scale===i.scale&&l.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const o=z.useRef(null);return z.useEffect(()=>{Be(o.current,e)||(o.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function jn({series:e,group:t,fill:n,dir:s}){const o=ee(),i=z.useRef(null),l=e[0],r=e[1];return z.useEffect(()=>{const a={series:[l,r],group:t,fill:n,dir:s};return i.current!=null&&(o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current)),i.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(c=>c!==i.current),i.current=null,o.scheduleRedraw()}},[o,l,r,t,n,s]),null}const Xn={width:12,height:3,borderRadius:1,display:"inline-block"},Yn={fontWeight:600},Un={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Kn=z.memo(function({group:t,index:n,label:s,color:o,isHidden:i,valueStr:l,store:r}){const a=z.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);return H.jsxs("span",{onClick:a,style:{...Un,opacity:i?.4:1},children:[H.jsx("span",{style:{...Xn,backgroundColor:o}}),H.jsx("span",{children:s}),l&&H.jsx("span",{style:Yn,children:l})]})});function Nn({show:e=!0,position:t="bottom",className:n}){const s=ee(),o=z.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=z.useCallback(u=>s.subscribe(u),[s]),l=z.useCallback(()=>{const{activeGroup:u,activeDataIdx:d}=s.cursorManager.state,f=s.seriesConfigs.length,{revision:g}=s,v=o.current;if(v.activeGroup===u&&v.activeDataIdx===d&&v.seriesCount===f&&v.revision===g)return v;const b={activeGroup:u,activeDataIdx:d,seriesCount:f,revision:g};return o.current=b,b},[s]),r=z.useSyncExternalStore(i,l);if(!e)return null;const{activeGroup:a,activeDataIdx:c}=r;return H.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{const d=typeof u.stroke=="string"?u.stroke:"#000";let f="";if(c>=0&&a>=0){const v=s.dataStore.getYValues(u.group,u.index)[c];v!=null&&(f=typeof v=="number"?v.toPrecision(4):String(v))}return H.jsx(Kn,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:d,isHidden:u.show===!1,valueStr:f,store:s},`${u.group}:${u.index}`)})})}const On=160;function qn({show:e=!0,className:t,children:n,offset:s={}}){const o=ee(),i=z.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=z.useCallback(m=>o.subscribe(m),[o]),r=z.useCallback(()=>{const m=o.cursorManager.state,{revision:S}=o,y=i.current;if(y.left===m.left&&y.top===m.top&&y.activeGroup===m.activeGroup&&y.activeDataIdx===m.activeDataIdx&&y.revision===S)return y;const R={left:m.left,top:m.top,activeGroup:m.activeGroup,activeDataIdx:m.activeDataIdx,revision:S};return i.current=R,R},[o]),a=z.useSyncExternalStore(l,r);if(!e||a.activeDataIdx<0||a.activeGroup<0||a.left<0)return null;const{activeGroup:c,activeDataIdx:u}=a,d=o.plotBox,f=o.dataStore.data[c],g=f!=null?f.x[u]??null:null,v=g!=null?parseFloat(g.toPrecision(6)).toString():"",b=[];for(const m of o.seriesConfigs){if(m.show===!1)continue;const S=o.dataStore.getYValues(m.group,m.index),y=m.group===c?S[u]:null;b.push({label:m.label??`Series ${m.index}`,value:y,color:typeof m.stroke=="string"?m.stroke:"#000",group:m.group,index:m.index})}const P={x:g,xLabel:v,items:b,left:a.left+d.left,top:a.top+d.top},h=s.x??12,C=s.y??-12,I=a.left+d.left+h+On>d.left+d.width,L=a.top+d.top+C<d.top,T=I?P.left-h:P.left+h,M=L?P.top+Math.abs(C):P.top+C;return n?H.jsx("div",{className:t,style:{position:"absolute",left:T,top:M,transform:I?"translateX(-100%)":void 0,pointerEvents:"none",zIndex:100},children:n(P)}):H.jsxs("div",{className:t,style:{position:"absolute",left:T,top:M,transform:I?"translateX(-100%)":void 0,pointerEvents:"none",zIndex:100,background:"rgba(0,0,0,0.85)",color:"#fff",padding:"6px 10px",borderRadius:4,fontSize:12,fontFamily:"sans-serif",whiteSpace:"nowrap",lineHeight:1.5},children:[H.jsx("div",{style:{fontWeight:600,marginBottom:2},children:v}),b.map(m=>H.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[H.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:m.color,display:"inline-block"}}),H.jsxs("span",{children:[m.label,":"]}),H.jsx("span",{style:{fontWeight:600},children:m.value!=null?m.value.toPrecision(4):"—"})]},`${m.group}:${m.index}`))]})}function Zn({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:i,colors:l,grips:r=!1}){const a=z.useRef(null),[c,u]=z.useState(()=>{if(o!=null&&n.length>0){const T=n[0];if(T!=null&&T.x.length>1){const M=T.x[0],S=T.x[T.x.length-1]-M;if(S>0)return[Math.max(0,(o[0]-M)/S),Math.min(1,(o[1]-M)/S)]}}return[.25,.75]}),d=z.useRef(null);z.useEffect(()=>{if(s==null||n.length===0)return;const T=n[0];if(T==null||T.x.length<2)return;const M=T.x[0],S=T.x[T.x.length-1]-M,y=M+c[0]*S,R=M+c[1]*S,p=d.current,w=Math.max(1e-10,Math.abs(R-y)*1e-12);p!=null&&Math.abs(p[0]-y)<w&&Math.abs(p[1]-R)<w||(d.current=[y,R],s(y,R))},[c,n,s]);const f=z.useRef(null),g=z.useCallback(T=>{const M=a.current;if(M==null)return 0;const m=M.getBoundingClientRect();return Math.max(0,Math.min(1,(T-m.left)/m.width))},[]),v=z.useCallback(T=>{const M=a.current;if(M==null)return;const m=g(T.clientX),S=M.getBoundingClientRect().width,y=S>0?8/S:0;let R;if(Math.abs(m-c[0])<y)R="left";else if(Math.abs(m-c[1])<y)R="right";else if(m>=c[0]&&m<=c[1])R="move";else{const p=c[1]-c[0],w=p/2,x=Math.max(0,Math.min(1-p,m-w));u([x,x+p]),R="move"}f.current={mode:R,startX:T.clientX,startFrac:[...c]},M.setPointerCapture(T.pointerId),T.preventDefault()},[c,g]),b=z.useCallback(T=>{const M=f.current;if(M==null)return;const m=g(T.clientX),S=g(M.startX),y=m-S;if(M.mode==="move"){const R=M.startFrac[1]-M.startFrac[0];let p=M.startFrac[0]+y;p=Math.max(0,Math.min(1-R,p)),u([p,p+R])}else if(M.mode==="left"){const R=Math.max(0,Math.min(M.startFrac[1]-.01,M.startFrac[0]+y));u([R,M.startFrac[1]])}else{const R=Math.min(1,Math.max(M.startFrac[0]+.01,M.startFrac[1]+y));u([M.startFrac[0],R])}},[g]),P=z.useCallback(T=>{f.current=null;const M=a.current;M!=null&&M.releasePointerCapture(T.pointerId)},[]),h=`${c[0]*100}%`,C=`${(c[1]-c[0])*100}%`,I=n[0],L=I!=null?I.series.length:0;return H.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[H.jsxs(Re,{width:e,height:t,data:n,children:[H.jsx(Te,{id:"x"}),H.jsx(Te,{id:"y"}),H.jsx(Ie,{scale:"x",show:!1}),H.jsx(Ie,{scale:"y",show:!1}),Array.from({length:L},(T,M)=>H.jsx(We,{group:0,index:M,yScale:"y",stroke:l!=null&&l[M]!=null?l[M]:`hsl(${M*137}, 60%, 50%)`,width:1},M))]}),H.jsxs("div",{ref:a,onPointerDown:v,onPointerMove:b,onPointerUp:P,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[H.jsx("div",{style:{position:"absolute",top:0,left:0,width:h,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),H.jsx("div",{style:{position:"absolute",top:0,left:`${c[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),H.jsx("div",{style:{position:"absolute",top:0,left:h,width:C,height:"100%",borderLeft:"2px solid rgba(0,100,255,0.8)",borderRight:"2px solid rgba(0,100,255,0.8)",boxSizing:"border-box",cursor:"grab",pointerEvents:"none"},children:r&&H.jsxs(H.Fragment,{children:[H.jsx("div",{style:{position:"absolute",left:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}}),H.jsx("div",{style:{position:"absolute",right:-5,top:"50%",transform:"translateY(-50%)",width:8,height:24,borderRadius:3,background:"rgba(0,100,255,0.8)",cursor:"ew-resize",pointerEvents:"auto"}})]})})]})]})}function ve(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Jn(e){const t=ee(),n=z.useRef(e);n.current=e,z.useEffect(()=>{const s=(o,i)=>n.current(o,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Qn({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const o=ee();return ve(({ctx:i,plotBox:l,pxRatio:r})=>{const a=o.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(l.left*r,l.top*r,l.width*r,l.height*r),i.clip();const c=(t+n)*r,u=t*r,d=l.top*r;for(let f=0;f<e.length;f++){const g=e[f];if(g==null)continue;const v=d+f*c;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(g.label,(l.left-6)*r,v+u/2);for(const b of g.segments){const P=V(b.start,a,l.width,l.left)*r,C=V(b.end,a,l.width,l.left)*r-P;C<=0||(i.fillStyle=b.color??"#4dabf7",i.fillRect(P,v,C,u),b.label!=null&&C>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(b.label,P+C/2,v+u/2,C-4*r)))}}i.restore()}),null}function es({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:i=1,paths:l,fillTo:r,className:a}){return H.jsx("div",{style:{pointerEvents:"none"},className:a,children:H.jsxs(Re,{width:t,height:n,data:e,children:[H.jsx(Te,{id:"x"}),H.jsx(Te,{id:"y"}),H.jsx(Ie,{scale:"x",show:!1}),H.jsx(Ie,{scale:"y",show:!1}),H.jsx(We,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:i,paths:l,fillTo:r})]})})}function ts({minWidth:e=100,minHeight:t=100,aspectRatio:n,initialHeight:s=300,...o}){const i=z.useRef(null),[l,r]=z.useState(null),a=z.useCallback(c=>{const u=Math.max(c.width,e);let d;return n!=null?d=Math.max(u/n,t):d=Math.max(c.height||s,t),{width:Math.round(u),height:Math.round(d)}},[e,t,n,s]);return z.useEffect(()=>{const c=i.current;if(c==null)return;const u=c.getBoundingClientRect();if(r(a({width:u.width,height:u.height})),typeof ResizeObserver>"u")return;const d=new ResizeObserver(f=>{const g=f[0];if(g==null)return;const{width:v,height:b}=g.contentRect;r(a({width:v,height:b}))});return d.observe(c),()=>d.disconnect()},[a]),H.jsx("div",{ref:i,style:{width:"100%",height:n!=null?"auto":"100%"},children:l!=null&&H.jsx(Re,{...o,width:l.width,height:l.height})})}function St(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.height,i.top);o.beginPath(),o.moveTo(i.left,l),o.lineTo(i.left+i.width,l),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function yt(e,t,n,s={}){const{ctx:o,plotBox:i}=e,l=V(n,t,i.width,i.left);o.beginPath(),o.moveTo(l,i.top),o.lineTo(l,i.top+i.height),o.strokeStyle=s.stroke??"red",o.lineWidth=s.width??1,s.dash&&o.setLineDash(s.dash),o.stroke(),s.dash&&o.setLineDash([])}function ns(e,t,n,s,o,i,l={}){const{ctx:r,plotBox:a}=e,c=V(s,t,a.width,a.left),u=V(o,n,a.height,a.top);r.font=l.font??"12px sans-serif",r.fillStyle=l.fill??"#000",r.textBaseline="bottom",r.fillText(i,c,u-4)}function kt(e,t,n,s,o={}){const{ctx:i,plotBox:l}=e,r=V(s,t,l.height,l.top),a=V(n,t,l.height,l.top);i.fillStyle=o.fill??"rgba(255,0,0,0.1)",i.fillRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.stroke&&(i.strokeStyle=o.stroke,i.lineWidth=o.width??1,o.dash&&i.setLineDash(o.dash),i.strokeRect(l.left,Math.min(r,a),l.width,Math.abs(a-r)),o.dash&&i.setLineDash([]))}function ss(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.yScale??"y",i=n.getScale(o);if(i!=null&&(St(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToY(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="left",r.textBaseline="bottom",r.fillText(s.label,a.left+4,l-4)}}),null}function os(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=s.xScale??"x",i=n.getScale(o);if(i!=null&&(yt(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const l=n.valToX(s.value,o);if(l==null)return;const{ctx:r,plotBox:a}=n;r.font=s.labelFont??"11px sans-serif",r.fillStyle=s.stroke??"red",r.textAlign="center",r.textBaseline="bottom",r.fillText(s.label,l,a.top-4)}}),null}function ls(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.getScale(s.yScale??"y");o!=null&&kt(n,o,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function is(e){const t=z.useRef(e);return z.useLayoutEffect(()=>{t.current=e}),ve(n=>{const s=t.current,o=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(o==null||i==null)return;const{ctx:l}=n;l.font=s.font??"12px sans-serif",l.fillStyle=s.fill??"#000",l.textAlign=s.align??"left",l.textBaseline=s.baseline??"bottom",l.fillText(s.text,o,i-4)}),null}function rs(e,t){const{window:n,batchSize:s=1}=t,o=t.autoStart??!0,[i,l]=z.useState(e),[r,a]=z.useState(!1),[c,u]=z.useState(0),d=z.useRef(0),f=z.useRef(0),g=z.useRef(0),v=z.useRef(new Map),b=z.useRef(0),P=z.useRef(n);P.current=n;const h=z.useCallback((T,M,...m)=>{let S=v.current.get(T);S==null&&(S={x:[],series:m.map(()=>[])},v.current.set(T,S)),S.x.push(...M);for(let y=0;y<m.length;y++){let R=S.series[y];R==null&&(R=[],S.series[y]=R),R.push(...m[y]??[])}b.current===0&&(b.current=requestAnimationFrame(()=>{b.current=0;const y=v.current;v.current=new Map;const R=P.current;l(p=>{const w=p.slice();for(const[x,{x:k,series:D}]of y){const A=w[x];if(A==null)continue;const F=A.x,E=Math.max(0,F.length+k.length-R),G=E>0?F.slice(E).concat(k):F.concat(k),$=A.series.map((W,j)=>{const K=W,O=D[j]??[];return E>0?K.slice(E).concat(O):K.concat(O)});w[x]={x:G,series:$}}return w})}))},[]),C=z.useCallback((T,...M)=>{h(0,T,...M)},[h]),I=z.useCallback(()=>{a(!0)},[]),L=z.useCallback(()=>{a(!1)},[]);return z.useEffect(()=>{if(!r){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}g.current=performance.now(),f.current=0;const T=M=>{f.current++;const m=M-g.current;m>=1e3&&(u(Math.round(f.current*1e3/m)),f.current=0,g.current=M),d.current=requestAnimationFrame(T)};return d.current=requestAnimationFrame(T),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[r]),z.useEffect(()=>()=>{b.current!==0&&cancelAnimationFrame(b.current)},[]),z.useEffect(()=>{o&&a(!0)},[o]),{data:i,push:C,pushGroup:h,start:I,stop:L,running:r,fps:c}}function as(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const v=(g==null?void 0:g.align)??e??1,b=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const P=y=>f(V(y,s,i,r)),h=y=>f(V(y,o,l,a)),C=s.ori===_.Horizontal?Pe:Le,I={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},L=I.stroke;let T=!1;const M=d===Y.Forward?c:u;let m=h(n[M]),S=P(t[M]);C(L,S,m);for(let y=M;y>=c&&y<=u;y+=d){const R=n[y];if(R==null){R===null&&!b&&(T=!0);continue}const p=P(t[y]),w=h(R);if(v===1)C(L,p,m);else if(v===-1)C(L,S,w);else{const x=f((S+p)/2);C(L,x,m),C(L,x,w)}C(L,p,w),m=w,S=p}{const y=I.fill=new Path2D(L),R=(g==null?void 0:g.fillTo)??o.min??0,p=h(R);let w=r,x=r+i;d===Y.Backward&&([x,w]=[w,x]),C(y,x,p),C(y,w,p)}if(T){const y=Ve(t,n,c,u,d,P);I.gaps=y,I.clip=$e(y,s.ori,r,a,i,l)}return I}}function cs(){return(e,t,n,s,o,i,l,r,a,c,u,d,f)=>{const g=(f==null?void 0:f.barWidth)??.6,v=(f==null?void 0:f.barGap)??0,b=(f==null?void 0:f.barRadius)??0,P=(f==null?void 0:f.barGroupIdx)??0,h=(f==null?void 0:f.barGroupCount)??1,C=x=>d(V(x,n,o,l)),I=x=>d(V(x,s,i,r));let L=o;if(c>a){let x=1/0,k=-1;for(let D=a;D<=c;D++)if(t[D]!=null){if(k>=0){const A=e[D],F=e[k],E=Math.abs(C(A)-C(F));E<x&&(x=E)}k=D}x<1/0&&(L=x)}const T=L*(1-g),M=Math.max(0,T+v),m=Math.max(1,d(L-M)),S=h>1?Math.max(1,d(m/Math.max(1,h))):m,y=(f==null?void 0:f.fillTo)??s.min??0,R=I(y),p=new Path2D,w=n.ori===_.Horizontal;for(let x=u===Y.Forward?a:c;x>=a&&x<=c;x+=u){const k=t[x];if(k==null)continue;const D=C(e[x]),A=I(k),F=h>1?(P-(h-1)/2)*S:0,E=d(D-S/2+F),G=Math.min(A,R),W=Math.max(A,R)-G;if(W!==0)if(b>0){const j=Math.min(b*S,W/2);us(p,w,E,G,S,W,j,k<y)}else w?p.rect(E,G,S,W):p.rect(G,E,W,S)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}}}function us(e,t,n,s,o,i,l,r){l=Math.min(l,o/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+o,s),e.lineTo(n+o,s+i-l),e.arc(n+o-l,s+i-l,l,0,Math.PI/2),e.lineTo(n+l,s+i),e.arc(n+l,s+i-l,l,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+l),e.arc(n+l,s+l,l,Math.PI,Math.PI*1.5),e.lineTo(n+o-l,s),e.arc(n+o-l,s+l,l,Math.PI*1.5,0),e.lineTo(n+o,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+o),e.lineTo(s+i-l,n+o),e.arc(s+i-l,n+o-l,l,Math.PI/2,0,!0),e.lineTo(s+i,n+l),e.arc(s+i-l,n+l,l,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+l,n),e.arc(s+l,n+l,l,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+o-l),e.arc(s+l,n+o-l,l,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+o),e.closePath())}function Ct(e){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const v=(g==null?void 0:g.spanGaps)??!1;if([c,u]=Ae(n,c,u),c===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=S=>f(V(S,s,i,r)),P=S=>f(V(S,o,l,a)),h=s.ori===_.Horizontal?Pe:Le,C=[],I=[];let L=!1;for(let S=d===Y.Forward?c:u;S>=c&&S<=u;S+=d){const y=n[S];y!=null?(C.push(b(t[S])),I.push(P(y))):y===null&&!v&&(L=!0)}const T=s.ori===_.Horizontal,M=e(C,I,T,f),m={stroke:M??new Path2D,fill:null,clip:null,band:null,gaps:null};if(M!=null){const S=m.fill=new Path2D(M),y=(g==null?void 0:g.fillTo)??o.min??0,R=P(y);let p=r,w=r+i;d===Y.Backward&&([w,p]=[p,w]),h(S,w,R),h(S,p,R)}if(L){const S=Ve(t,n,c,u,d,b);m.gaps=S,m.clip=$e(S,s.ori,r,a,i,l)}return m}}function fs(){return Ct(hs)}const hs=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=e[0]??0,r=t[0]??0;if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const f=e[1]??0,g=t[1]??0;return n?i.lineTo(f,g):i.lineTo(g,f),i}const a=new Array(o),c=new Array(o-1),u=new Array(o-1),d=new Array(o-1);for(let f=0;f<o-1;f++)u[f]=(t[f+1]??0)-(t[f]??0),d[f]=(e[f+1]??0)-(e[f]??0),c[f]=d[f]!==0?(u[f]??0)/(d[f]??1):0;a[0]=c[0]??0;for(let f=1;f<o-1;f++){const g=c[f]??0,v=c[f-1]??0;if(g===0||v===0||v>0!=g>0)a[f]=0;else{const b=d[f]??1,P=d[f-1]??1;a[f]=3*(P+b)/((2*b+P)/v+(b+2*P)/g),isFinite(a[f]??0)||(a[f]=0)}}a[o-1]=c[o-2]??0;for(let f=0;f<o-1;f++){const g=d[f]??1,v=e[f]??0,b=t[f]??0,P=e[f+1]??0,h=t[f+1]??0,C=a[f]??0,I=a[f+1]??0,L=v+g/3,T=b+C*g/3,M=P-g/3,m=h-I*g/3;n?i.bezierCurveTo(L,T,M,m,P,h):i.bezierCurveTo(T,L,m,M,h,P)}return i};function ds(){return Ct(gs)}const gs=(e,t,n,s)=>{const o=e.length;if(o<2)return null;const i=new Path2D,l=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(l,r):i.moveTo(r,l),o===2){const a=s(e[1]??0),c=s(t[1]??0);return n?i.lineTo(a,c):i.lineTo(c,a),i}for(let a=0;a<o-1;a++){const c=a===0?0:a-1,u=e[c]??0,d=t[c]??0,f=e[a]??0,g=t[a]??0,v=e[a+1]??0,b=t[a+1]??0,P=a+2<o?e[a+2]??0:v,h=a+2<o?t[a+2]??0:b,C=Math.hypot(u-f,d-g),I=Math.hypot(f-v,g-b),L=Math.hypot(v-P,b-h),T=Math.sqrt(L),M=L,m=Math.sqrt(I),S=I,y=Math.sqrt(C),R=C,p=2*R+3*y*m+S,w=2*M+3*T*m+S,x=3*y*(y+m),k=3*T*(T+m);let D,A,F,E;if(x>0){const G=1/x;D=(-S*u+p*f+R*v)*G,A=(-S*d+p*g+R*b)*G}else D=f,A=g;if(k>0){const G=1/k;F=(M*f+w*v-S*P)*G,E=(M*g+w*b-S*h)*G}else F=v,E=b;n?i.bezierCurveTo(D,A,F,E,v,b):i.bezierCurveTo(A,D,E,F,b,v)}return i};function ps(e=4){return(t,n,s,o,i,l,r,a,c,u,d,f,g)=>{const v=I=>f(V(I,s,i,r)),b=I=>f(V(I,o,l,a)),P=e/2,h=new Path2D,C=s.ori===_.Horizontal;for(let I=d===Y.Forward?c:u;I>=c&&I<=u;I+=d){const L=n[I];if(L==null)continue;const T=v(t[I]),M=b(L);C?(h.moveTo(T+P,M),h.arc(T,M,P,0,Math.PI*2)):(h.moveTo(M+P,T),h.arc(M,T,P,0,Math.PI*2))}return{stroke:h,fill:h,clip:null,band:null,gaps:null}}}function ms(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:o,open:i,high:l,low:r,close:a,xScale:c,yScale:u,upColor:d="#26a69a",downColor:f="#ef5350",bodyWidth:g=.6,wickWidth:v=1}=e;if(c.min==null||c.max==null||u.min==null||u.max==null)return;const b=o.length;if(b===0)return;const h=Math.max(2,n.width/b*g)*s/2;t.save();for(let C=0;C<b;C++){const I=o[C],L=i[C],T=l[C],M=r[C],m=a[C];if(I==null||L==null||T==null||M==null||m==null)continue;const S=V(I,c,n.width,n.left)*s,y=V(L,u,n.height,n.top)*s,R=V(T,u,n.height,n.top)*s,p=V(M,u,n.height,n.top)*s,w=V(m,u,n.height,n.top)*s,k=m>=L?d:f;t.strokeStyle=k,t.lineWidth=v*s,t.beginPath(),t.moveTo(S,R),t.lineTo(S,p),t.stroke();const D=Math.min(y,w),A=Math.abs(w-y);t.fillStyle=k,t.fillRect(S-h,D,h*2,Math.max(A,1*s))}t.restore()}}function ws(e,t,n=0){const s=t??e.series.map((c,u)=>u),o=e.x.length,i=[],l=new Float64Array(o);for(let c=0;c<s.length;c++){const u=s[c];if(u==null)continue;const d=e.series[u];if(d==null)continue;const f=new Array(o);for(let g=0;g<o;g++){const v=d[g];v!=null?(l[g]=l[g]+v,f[g]=l[g]):f[g]=null}i.push(f)}const r=[];for(let c=0;c<e.series.length;c++){const u=s.indexOf(c),d=u>=0?i[u]:void 0;d!=null?r.push(d):r.push(e.series[c]??[])}const a=[];for(let c=s.length-1;c>0;c--){const u=s[c],d=s[c-1];u!=null&&d!=null&&a.push({group:n,series:[u,d]})}return{group:{x:e.x,series:r},bands:a}}function xs(e){const t=new Set;for(const[i]of e)for(let l=0;l<i.length;l++){const r=i[l];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,l)=>i-l)),s=new Map;for(let i=0;i<n.length;i++){const l=n[i];l!=null&&s.set(l,i)}const o=[];for(const[i,l]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const c=i[a];if(c==null)continue;const u=s.get(c);u!=null&&(r[u]=l[a]??null)}o.push(r)}return[{x:n,series:o}]}function vs(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const o=Math.abs(s);return o>=1e9?(s/1e9).toFixed(t)+"B":o>=1e6?(s/1e6).toFixed(t)+"M":o>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(o>=1?0:t)})}function Ms(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function bs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ss(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(o=>Q(o,{month:n},t))}function ys(e){const{tz:t,...n}=e??{};return s=>s.map(o=>Q(o,n,t))}function ks(e,t=0){return n=>n.map(s=>{const o=Math.round(s)-t;return e[o]??String(s)})}function Tt(e){const t=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})/i.exec(e);if(t)return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)];const n=/^#([0-9a-f])([0-9a-f])([0-9a-f])/i.exec(e);if(n)return[parseInt(n[1]+n[1],16),parseInt(n[2]+n[2],16),parseInt(n[3]+n[3],16)];const s=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/i.exec(e);return s?[Number(s[1]),Number(s[2]),Number(s[3])]:null}function Cs(e,t=.8,n=0){const s=Tt(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[o,i,l]=s;return{type:"linear",stops:[[0,`rgba(${o},${i},${l},${t})`],[1,`rgba(${o},${i},${l},${n})`]]}}function Ts(e,t){const n=Tt(e);if(n==null)return e;const[s,o,i]=n;return`rgba(${s},${o},${i},${t})`}function Is(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const l=i*137.508%360;s.push(`hsl(${l.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=is;exports.Axis=Ie;exports.Band=jn;exports.Chart=Re;exports.Direction=Y;exports.Distribution=U;exports.HLine=ss;exports.Legend=Nn;exports.Orientation=_;exports.Region=ls;exports.ResponsiveChart=ts;exports.Scale=Te;exports.Series=We;exports.Side=X;exports.SortOrder=me;exports.Sparkline=es;exports.Timeline=Qn;exports.Tooltip=qn;exports.VLine=os;exports.ZoomRanger=Zn;exports.alignData=xs;exports.bars=cs;exports.catmullRom=ds;exports.drawCandlesticks=ms;exports.drawHLine=St;exports.drawLabel=ns;exports.drawRegion=kt;exports.drawVLine=yt;exports.fadeGradient=Cs;exports.fmtCompact=vs;exports.fmtDateStr=ys;exports.fmtHourMin=bs;exports.fmtLabels=ks;exports.fmtMonthName=Ss;exports.fmtSuffix=Ms;exports.linear=vt;exports.monotoneCubic=fs;exports.palette=Is;exports.points=ps;exports.posToVal=te;exports.sideOrientation=he;exports.stackGroup=ws;exports.stepped=as;exports.useChart=ee;exports.useCursorDrawHook=Jn;exports.useDrawHook=ve;exports.useStreamingData=rs;exports.valToPos=V;exports.withAlpha=Ts;
|