uplot-plus 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +33 -10
  2. package/dist/index.cjs +1 -1
  3. package/dist/index.js +2169 -1775
  4. package/dist/src/annotations.d.ts.map +1 -0
  5. package/dist/src/axes/layout.d.ts.map +1 -0
  6. package/dist/src/axes/ticks.d.ts.map +1 -0
  7. package/dist/src/colors.d.ts.map +1 -0
  8. package/dist/src/components/Axis.d.ts.map +1 -0
  9. package/dist/src/components/Band.d.ts.map +1 -0
  10. package/dist/{components → src/components}/Chart.d.ts +1 -1
  11. package/dist/src/components/Chart.d.ts.map +1 -0
  12. package/dist/src/components/FloatingLegend.d.ts +31 -0
  13. package/dist/src/components/FloatingLegend.d.ts.map +1 -0
  14. package/dist/src/components/HoverLabel.d.ts +15 -0
  15. package/dist/src/components/HoverLabel.d.ts.map +1 -0
  16. package/dist/src/components/Legend.d.ts.map +1 -0
  17. package/dist/src/components/Scale.d.ts.map +1 -0
  18. package/dist/{components → src/components}/Series.d.ts +4 -1
  19. package/dist/src/components/Series.d.ts.map +1 -0
  20. package/dist/{components → src/components}/Sparkline.d.ts +3 -3
  21. package/dist/src/components/Sparkline.d.ts.map +1 -0
  22. package/dist/src/components/Timeline.d.ts.map +1 -0
  23. package/dist/{components → src/components}/Tooltip.d.ts +1 -1
  24. package/dist/src/components/Tooltip.d.ts.map +1 -0
  25. package/dist/{components → src/components}/ZoomRanger.d.ts +3 -3
  26. package/dist/src/components/ZoomRanger.d.ts.map +1 -0
  27. package/dist/src/components/annotations/AnnotationLabel.d.ts.map +1 -0
  28. package/dist/src/components/annotations/HLine.d.ts.map +1 -0
  29. package/dist/src/components/annotations/Region.d.ts.map +1 -0
  30. package/dist/src/components/annotations/VLine.d.ts.map +1 -0
  31. package/dist/src/components/annotations/index.d.ts.map +1 -0
  32. package/dist/src/components/overlay/SeriesPanel.d.ts +27 -0
  33. package/dist/src/components/overlay/SeriesPanel.d.ts.map +1 -0
  34. package/dist/src/core/BlockMinMax.d.ts.map +1 -0
  35. package/dist/{core → src/core}/CursorManager.d.ts +7 -0
  36. package/dist/src/core/CursorManager.d.ts.map +1 -0
  37. package/dist/{core → src/core}/DataStore.d.ts +3 -1
  38. package/dist/src/core/DataStore.d.ts.map +1 -0
  39. package/dist/src/core/RenderScheduler.d.ts.map +1 -0
  40. package/dist/src/core/Scale.d.ts.map +1 -0
  41. package/dist/src/core/ScaleManager.d.ts.map +1 -0
  42. package/dist/src/core/normalizeData.d.ts +12 -0
  43. package/dist/src/core/normalizeData.d.ts.map +1 -0
  44. package/dist/{formatters.d.ts → src/formatters.d.ts} +8 -0
  45. package/dist/src/formatters.d.ts.map +1 -0
  46. package/dist/src/hooks/useChart.d.ts.map +1 -0
  47. package/dist/{hooks → src/hooks}/useChartStore.d.ts +9 -0
  48. package/dist/src/hooks/useChartStore.d.ts.map +1 -0
  49. package/dist/src/hooks/useDrawHook.d.ts.map +1 -0
  50. package/dist/src/hooks/useInteraction.d.ts.map +1 -0
  51. package/dist/{hooks → src/hooks}/useStreamingData.d.ts +2 -2
  52. package/dist/src/hooks/useStreamingData.d.ts.map +1 -0
  53. package/dist/{index.d.ts → src/index.d.ts} +7 -3
  54. package/dist/src/index.d.ts.map +1 -0
  55. package/dist/src/math/align.d.ts.map +1 -0
  56. package/dist/src/math/increments.d.ts.map +1 -0
  57. package/dist/src/math/stack.d.ts.map +1 -0
  58. package/dist/src/math/utils.d.ts.map +1 -0
  59. package/dist/src/paths/bars.d.ts +21 -0
  60. package/dist/src/paths/bars.d.ts.map +1 -0
  61. package/dist/src/paths/candlestick.d.ts.map +1 -0
  62. package/dist/src/paths/catmullRom.d.ts.map +1 -0
  63. package/dist/src/paths/linear.d.ts.map +1 -0
  64. package/dist/src/paths/monotoneCubic.d.ts.map +1 -0
  65. package/dist/src/paths/points.d.ts.map +1 -0
  66. package/dist/src/paths/spline.d.ts.map +1 -0
  67. package/dist/src/paths/stepped.d.ts.map +1 -0
  68. package/dist/src/paths/types.d.ts.map +1 -0
  69. package/dist/src/paths/utils.d.ts.map +1 -0
  70. package/dist/{rendering → src/rendering}/CanvasRenderer.d.ts +7 -2
  71. package/dist/src/rendering/CanvasRenderer.d.ts.map +1 -0
  72. package/dist/src/rendering/drawAxes.d.ts.map +1 -0
  73. package/dist/src/rendering/drawBands.d.ts.map +1 -0
  74. package/dist/{rendering → src/rendering}/drawCursor.d.ts +1 -1
  75. package/dist/src/rendering/drawCursor.d.ts.map +1 -0
  76. package/dist/src/rendering/drawPoints.d.ts.map +1 -0
  77. package/dist/src/rendering/drawSelect.d.ts.map +1 -0
  78. package/dist/src/rendering/drawSeries.d.ts.map +1 -0
  79. package/dist/src/sync/SyncGroup.d.ts.map +1 -0
  80. package/dist/src/sync/useSyncGroup.d.ts.map +1 -0
  81. package/dist/src/time/fmtDate.d.ts.map +1 -0
  82. package/dist/src/time/timeIncrs.d.ts.map +1 -0
  83. package/dist/src/time/timeSplits.d.ts.map +1 -0
  84. package/dist/src/time/timeVals.d.ts.map +1 -0
  85. package/dist/src/types/axes.d.ts.map +1 -0
  86. package/dist/src/types/bands.d.ts.map +1 -0
  87. package/dist/{types → src/types}/chart.d.ts +7 -3
  88. package/dist/src/types/chart.d.ts.map +1 -0
  89. package/dist/src/types/common.d.ts.map +1 -0
  90. package/dist/src/types/cursor.d.ts.map +1 -0
  91. package/dist/{types → src/types}/data.d.ts +21 -1
  92. package/dist/src/types/data.d.ts.map +1 -0
  93. package/dist/src/types/events.d.ts.map +1 -0
  94. package/dist/src/types/hooks.d.ts.map +1 -0
  95. package/dist/{types → src/types}/index.d.ts +1 -1
  96. package/dist/src/types/index.d.ts.map +1 -0
  97. package/dist/src/types/legend.d.ts.map +1 -0
  98. package/dist/{types → src/types}/scales.d.ts +6 -0
  99. package/dist/src/types/scales.d.ts.map +1 -0
  100. package/dist/{types → src/types}/series.d.ts +2 -0
  101. package/dist/src/types/series.d.ts.map +1 -0
  102. package/dist/src/types/timeline.d.ts.map +1 -0
  103. package/dist/src/types/tooltip.d.ts.map +1 -0
  104. package/dist/src/utils/shallowEqual.d.ts.map +1 -0
  105. package/package.json +2 -2
  106. package/dist/annotations.d.ts.map +0 -1
  107. package/dist/axes/layout.d.ts.map +0 -1
  108. package/dist/axes/ticks.d.ts.map +0 -1
  109. package/dist/colors.d.ts.map +0 -1
  110. package/dist/components/Axis.d.ts.map +0 -1
  111. package/dist/components/Band.d.ts.map +0 -1
  112. package/dist/components/Chart.d.ts.map +0 -1
  113. package/dist/components/Legend.d.ts.map +0 -1
  114. package/dist/components/Scale.d.ts.map +0 -1
  115. package/dist/components/Series.d.ts.map +0 -1
  116. package/dist/components/Sparkline.d.ts.map +0 -1
  117. package/dist/components/Timeline.d.ts.map +0 -1
  118. package/dist/components/Tooltip.d.ts.map +0 -1
  119. package/dist/components/ZoomRanger.d.ts.map +0 -1
  120. package/dist/components/annotations/AnnotationLabel.d.ts.map +0 -1
  121. package/dist/components/annotations/HLine.d.ts.map +0 -1
  122. package/dist/components/annotations/Region.d.ts.map +0 -1
  123. package/dist/components/annotations/VLine.d.ts.map +0 -1
  124. package/dist/components/annotations/index.d.ts.map +0 -1
  125. package/dist/core/BlockMinMax.d.ts.map +0 -1
  126. package/dist/core/CursorManager.d.ts.map +0 -1
  127. package/dist/core/DataStore.d.ts.map +0 -1
  128. package/dist/core/RenderScheduler.d.ts.map +0 -1
  129. package/dist/core/Scale.d.ts.map +0 -1
  130. package/dist/core/ScaleManager.d.ts.map +0 -1
  131. package/dist/formatters.d.ts.map +0 -1
  132. package/dist/hooks/useChart.d.ts.map +0 -1
  133. package/dist/hooks/useChartStore.d.ts.map +0 -1
  134. package/dist/hooks/useDrawHook.d.ts.map +0 -1
  135. package/dist/hooks/useInteraction.d.ts.map +0 -1
  136. package/dist/hooks/useStreamingData.d.ts.map +0 -1
  137. package/dist/index.d.ts.map +0 -1
  138. package/dist/math/align.d.ts.map +0 -1
  139. package/dist/math/increments.d.ts.map +0 -1
  140. package/dist/math/stack.d.ts.map +0 -1
  141. package/dist/math/utils.d.ts.map +0 -1
  142. package/dist/paths/bars.d.ts +0 -9
  143. package/dist/paths/bars.d.ts.map +0 -1
  144. package/dist/paths/candlestick.d.ts.map +0 -1
  145. package/dist/paths/catmullRom.d.ts.map +0 -1
  146. package/dist/paths/linear.d.ts.map +0 -1
  147. package/dist/paths/monotoneCubic.d.ts.map +0 -1
  148. package/dist/paths/points.d.ts.map +0 -1
  149. package/dist/paths/spline.d.ts.map +0 -1
  150. package/dist/paths/stepped.d.ts.map +0 -1
  151. package/dist/paths/types.d.ts.map +0 -1
  152. package/dist/paths/utils.d.ts.map +0 -1
  153. package/dist/rendering/CanvasRenderer.d.ts.map +0 -1
  154. package/dist/rendering/drawAxes.d.ts.map +0 -1
  155. package/dist/rendering/drawBands.d.ts.map +0 -1
  156. package/dist/rendering/drawCursor.d.ts.map +0 -1
  157. package/dist/rendering/drawPoints.d.ts.map +0 -1
  158. package/dist/rendering/drawSelect.d.ts.map +0 -1
  159. package/dist/rendering/drawSeries.d.ts.map +0 -1
  160. package/dist/sync/SyncGroup.d.ts.map +0 -1
  161. package/dist/sync/useSyncGroup.d.ts.map +0 -1
  162. package/dist/time/fmtDate.d.ts.map +0 -1
  163. package/dist/time/timeIncrs.d.ts.map +0 -1
  164. package/dist/time/timeSplits.d.ts.map +0 -1
  165. package/dist/time/timeVals.d.ts.map +0 -1
  166. package/dist/types/axes.d.ts.map +0 -1
  167. package/dist/types/bands.d.ts.map +0 -1
  168. package/dist/types/chart.d.ts.map +0 -1
  169. package/dist/types/common.d.ts.map +0 -1
  170. package/dist/types/cursor.d.ts.map +0 -1
  171. package/dist/types/data.d.ts.map +0 -1
  172. package/dist/types/events.d.ts.map +0 -1
  173. package/dist/types/hooks.d.ts.map +0 -1
  174. package/dist/types/index.d.ts.map +0 -1
  175. package/dist/types/legend.d.ts.map +0 -1
  176. package/dist/types/scales.d.ts.map +0 -1
  177. package/dist/types/series.d.ts.map +0 -1
  178. package/dist/types/timeline.d.ts.map +0 -1
  179. package/dist/types/tooltip.d.ts.map +0 -1
  180. package/dist/utils/shallowEqual.d.ts.map +0 -1
  181. /package/dist/{annotations.d.ts → src/annotations.d.ts} +0 -0
  182. /package/dist/{axes → src/axes}/layout.d.ts +0 -0
  183. /package/dist/{axes → src/axes}/ticks.d.ts +0 -0
  184. /package/dist/{colors.d.ts → src/colors.d.ts} +0 -0
  185. /package/dist/{components → src/components}/Axis.d.ts +0 -0
  186. /package/dist/{components → src/components}/Band.d.ts +0 -0
  187. /package/dist/{components → src/components}/Legend.d.ts +0 -0
  188. /package/dist/{components → src/components}/Scale.d.ts +0 -0
  189. /package/dist/{components → src/components}/Timeline.d.ts +0 -0
  190. /package/dist/{components → src/components}/annotations/AnnotationLabel.d.ts +0 -0
  191. /package/dist/{components → src/components}/annotations/HLine.d.ts +0 -0
  192. /package/dist/{components → src/components}/annotations/Region.d.ts +0 -0
  193. /package/dist/{components → src/components}/annotations/VLine.d.ts +0 -0
  194. /package/dist/{components → src/components}/annotations/index.d.ts +0 -0
  195. /package/dist/{core → src/core}/BlockMinMax.d.ts +0 -0
  196. /package/dist/{core → src/core}/RenderScheduler.d.ts +0 -0
  197. /package/dist/{core → src/core}/Scale.d.ts +0 -0
  198. /package/dist/{core → src/core}/ScaleManager.d.ts +0 -0
  199. /package/dist/{hooks → src/hooks}/useChart.d.ts +0 -0
  200. /package/dist/{hooks → src/hooks}/useDrawHook.d.ts +0 -0
  201. /package/dist/{hooks → src/hooks}/useInteraction.d.ts +0 -0
  202. /package/dist/{math → src/math}/align.d.ts +0 -0
  203. /package/dist/{math → src/math}/increments.d.ts +0 -0
  204. /package/dist/{math → src/math}/stack.d.ts +0 -0
  205. /package/dist/{math → src/math}/utils.d.ts +0 -0
  206. /package/dist/{paths → src/paths}/candlestick.d.ts +0 -0
  207. /package/dist/{paths → src/paths}/catmullRom.d.ts +0 -0
  208. /package/dist/{paths → src/paths}/linear.d.ts +0 -0
  209. /package/dist/{paths → src/paths}/monotoneCubic.d.ts +0 -0
  210. /package/dist/{paths → src/paths}/points.d.ts +0 -0
  211. /package/dist/{paths → src/paths}/spline.d.ts +0 -0
  212. /package/dist/{paths → src/paths}/stepped.d.ts +0 -0
  213. /package/dist/{paths → src/paths}/types.d.ts +0 -0
  214. /package/dist/{paths → src/paths}/utils.d.ts +0 -0
  215. /package/dist/{rendering → src/rendering}/drawAxes.d.ts +0 -0
  216. /package/dist/{rendering → src/rendering}/drawBands.d.ts +0 -0
  217. /package/dist/{rendering → src/rendering}/drawPoints.d.ts +0 -0
  218. /package/dist/{rendering → src/rendering}/drawSelect.d.ts +0 -0
  219. /package/dist/{rendering → src/rendering}/drawSeries.d.ts +0 -0
  220. /package/dist/{sync → src/sync}/SyncGroup.d.ts +0 -0
  221. /package/dist/{sync → src/sync}/useSyncGroup.d.ts +0 -0
  222. /package/dist/{time → src/time}/fmtDate.d.ts +0 -0
  223. /package/dist/{time → src/time}/timeIncrs.d.ts +0 -0
  224. /package/dist/{time → src/time}/timeSplits.d.ts +0 -0
  225. /package/dist/{time → src/time}/timeVals.d.ts +0 -0
  226. /package/dist/{types → src/types}/axes.d.ts +0 -0
  227. /package/dist/{types → src/types}/bands.d.ts +0 -0
  228. /package/dist/{types → src/types}/common.d.ts +0 -0
  229. /package/dist/{types → src/types}/cursor.d.ts +0 -0
  230. /package/dist/{types → src/types}/events.d.ts +0 -0
  231. /package/dist/{types → src/types}/hooks.d.ts +0 -0
  232. /package/dist/{types → src/types}/legend.d.ts +0 -0
  233. /package/dist/{types → src/types}/timeline.d.ts +0 -0
  234. /package/dist/{types → src/types}/tooltip.d.ts +0 -0
  235. /package/dist/{utils → src/utils}/shallowEqual.d.ts +0 -0
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/uPlot-Plus/)**
5
+ **[Live Demo (99 examples)](https://yeonsoo-p.github.io/uPlot-Plus/)**
6
6
 
7
7
  ## Features
8
8
 
@@ -13,7 +13,7 @@ High-performance React charting library ripped off from uPlot. Might perform occ
13
13
  - **7 path builders** — linear, stepped, bars, monotone cubic, Catmull-Rom, points, candlestick
14
14
  - **Interactive** — wheel/touch zoom, drag-to-zoom, cursor snapping, series focus
15
15
  - **Cursor sync** — linked crosshairs and tooltips across multiple charts
16
- - **Compact bundle** — ~111KB (~30KB gzip), React 18+ peer dependency
16
+ - **Compact bundle** — ~128KB (~36KB gzip), React 18+ peer dependency
17
17
  - **Dual output** — ES module + CommonJS
18
18
 
19
19
  ## Installation
@@ -30,6 +30,24 @@ npm install react react-dom
30
30
 
31
31
  ## Quick Start
32
32
 
33
+ Scales, axes, and colors are auto-injected when omitted — the simplest chart is just data + series:
34
+
35
+ ```tsx
36
+ import { Chart, Series } from 'uplot-plus';
37
+
38
+ const data = { x: [1, 2, 3, 4, 5], y: [10, 25, 13, 30, 18] };
39
+
40
+ function App() {
41
+ return (
42
+ <Chart width={800} height={400} data={data}>
43
+ <Series group={0} index={0} label="Revenue" />
44
+ </Chart>
45
+ );
46
+ }
47
+ ```
48
+
49
+ For full control, declare scales, axes, and series explicitly:
50
+
33
51
  ```tsx
34
52
  import { Chart, Scale, Series, Axis } from 'uplot-plus';
35
53
 
@@ -68,6 +86,8 @@ function App() {
68
86
  | `<Band>` | Fills a region between two series |
69
87
  | `<Legend>` | Interactive legend with live cursor values, click-to-toggle |
70
88
  | `<Tooltip>` | Floating tooltip at cursor position, auto-flips at edges |
89
+ | `<FloatingLegend>` | Draggable or cursor-following legend panel with idle opacity fade |
90
+ | `<HoverLabel>` | Shows nearest series info after a hover delay |
71
91
  | `<ZoomRanger>` | Overview mini-chart with draggable selection for zoom control |
72
92
  | `<Timeline>` | Horizontal lanes of colored event spans |
73
93
  | `<Sparkline>` | Compact inline chart for tables and dashboards (no axes, no interaction) |
@@ -81,13 +101,14 @@ function App() {
81
101
 
82
102
  ## Data Model
83
103
 
84
- Data is organized as groups, each with its own x-values:
104
+ Three input forms use whichever fits your data:
85
105
 
86
106
  ```ts
87
- import type { ChartData, XGroup } from 'uplot-plus';
107
+ // Simplest: single series
108
+ const data = { x: [1, 2, 3, 4, 5], y: [10, 20, 30, 40, 50] };
88
109
 
89
- // Single x-axis (most common)
90
- const data: ChartData = [
110
+ // Multiple series sharing one x-axis
111
+ const data = [
91
112
  {
92
113
  x: [1, 2, 3, 4, 5],
93
114
  series: [
@@ -98,7 +119,7 @@ const data: ChartData = [
98
119
  ];
99
120
 
100
121
  // Multi x-axis — two groups with independent x-ranges
101
- const multiData: ChartData = [
122
+ const multiData = [
102
123
  { x: [0, 1, 2, 3], series: [[10, 20, 15, 25]] },
103
124
  { x: [0, 0.5, 1.5, 2.5, 3], series: [[8, 18, 22, 12, 30]] },
104
125
  ];
@@ -114,7 +135,9 @@ Null values in series arrays create gaps in the chart. Use `spanGaps` on `<Serie
114
135
  |---------|--------|----------|
115
136
  | `linear()` | `linear` | Line/area charts (default). Pixel-level decimation for large datasets |
116
137
  | `stepped()` | `stepped` | Step charts — step-after, step-before, or mid-step |
117
- | `bars()` | `bars` | Bar/column charts with configurable width, gaps, grouped bars |
138
+ | `bars()` | `bars` | Bar/column charts with configurable width and gaps |
139
+ | `groupedBars()` | `groupedBars` | Side-by-side grouped bar charts |
140
+ | `stackedBars()` | `stackedBars` | Stacked bar charts |
118
141
  | `monotoneCubic()` | `monotoneCubic` | Smooth curves that preserve monotonicity (no overshoot) |
119
142
  | `catmullRom()` | `catmullRom` | Centripetal Catmull-Rom splines |
120
143
  | `points()` | `points` | Scatter plots — points only, no connecting lines |
@@ -270,7 +293,7 @@ import { drawHLine, drawVLine, drawLabel, drawRegion } from 'uplot-plus';
270
293
 
271
294
  | Category | Functions |
272
295
  | ---------- | ----------- |
273
- | Axis formatters | `fmtCompact`, `fmtSuffix`, `fmtHourMin`, `fmtMonthName`, `fmtDateStr`, `fmtLabels` |
296
+ | Axis formatters | `fmtCompact`, `fmtSuffix`, `fmtPrefix`, `fmtWrap`, `fmtHourMin`, `fmtMonthName`, `fmtDateStr`, `fmtLabels` |
274
297
  | Color helpers | `fadeGradient`, `withAlpha`, `palette` |
275
298
  | Data transforms | `stackGroup`, `alignData` |
276
299
  | Scale math | `valToPos`, `posToVal` |
@@ -280,7 +303,7 @@ import { drawHLine, drawVLine, drawLabel, drawRegion } from 'uplot-plus';
280
303
  ## Development
281
304
 
282
305
  ```sh
283
- npm run dev # Start demo dev server (85+ examples)
306
+ npm run dev # Start demo dev server (99 examples)
284
307
  npm run build # Build library (ES + CJS to dist/)
285
308
  npm run typecheck # TypeScript strict check
286
309
  npm run lint # ESLint
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const G=require("react/jsx-runtime"),F=require("react");var Y=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(Y||{}),_=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(_||{}),K=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(K||{}),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 de(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,De=q.PI,he=q.abs,se=q.floor,B=q.round,ye=q.ceil,Ue=q.min,be=q.max,pe=q.pow,Ne=q.sign,J=q.log10,xe=q.log2,It=(e,t=1)=>q.sinh(e)*t,Ge=(e,t=1)=>q.asinh(e/t),O=1/0,at=Number.isInteger;function ze(e,t){return e[t]??0}function re(e,t,n=0,s=t.length-1){let o;const i=s<=2147483647;for(;s-n>1;)o=i?n+s>>1:se((n+s)/2),ze(t,o)<e?n=o:s=o;return e-ze(t,n)<=ze(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 u=e[r]??O,c=e[r]??-O;if(r>-1)if(s===me.Ascending)u=e[r]??O,c=e[a]??-O;else if(s===me.Descending)u=e[a]??O,c=e[r]??-O;else for(let h=r;h<=a;h++){const f=e[h];f!=null&&l(f)&&(f<u?u=f:f>c&&(c=f))}return[u,c]}function ae(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 ae(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(se(ke(e/t))*t):se(e/t)*t}function gt(e,t,n,s){const o=[],i=s.map(Pt);for(let l=t;l<n;l++){const r=he(l);for(let a=0;a<s.length;a++){const u=s[a]??0,c=i[a]??0,h=+`${u}e${l}`,f=(l>=0?0:r)+(l>=c?0:c),d=h;o.push(d),we.set(d,f)}}return o}const Rt=new Intl.NumberFormat,pt=e=>Rt.format(e),Dt=.1,oe={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,u=i.hard??-O,c=l.hard??O,h=i.soft??O,f=l.soft??-O,d=i.mode,v=l.mode;let b=t-e;const L=J(b),g=be(he(e),he(t)),w=J(g),P=he(w-L);(b<1e-24||P>10)&&(b=0,(e===0||t===0)&&(b=1e-24));const R=b||g||1e3,T=J(R),S=pe(10,se(T)),C=R*(b===0?e===0?.1:1:r),x=ae(dt(e-C,S/10),24),I=e>=h&&(d===1||d===3&&x<=h||d===2&&x>=h)?h:O,D=be(u,x<I&&e>=I?I:Ue(I,x)),m=R*(b===0?t===0?.1:1:a),p=ae(_e(t+m,S/10),24),M=t<=f&&(v===1||v===3&&p>=f||v===2&&p<=f)?f:-O,k=Ue(c,p>M&&t<=M?M:be(M,p));return D===k&&D===0?[-1,1]:[D,k]}function Ft(e,t,n,s){n===2&&(s=!0);const o=Ne(e),i=Ne(t);e===t&&(o===-1?(e*=n,t/=n):(e/=n,t*=n));const l=n===10?J:xe,r=o===1?se:ye,a=i===1?ye:se,u=l(he(e)),c=l(he(t)),h=r(u),f=a(c);let d=pe(n,h),v=pe(n,f);return n===10&&(h<0&&(d=ae(d,-h)),f<0&&(v=ae(v,-f))),s?(e=d*o,t=v*i):(e=dt(e,pe(n,se(u)),!1),t=_e(t,pe(n,se(c)),!1)),[e,t]}function Oe(e){return(J((e^e>>31)-(e>>31))|0)+1}function Ht(e,t,n,s,o){const i=be(Oe(e),Oe(t)),l=t-e;let r=be(0,re(o/s*l,n)-1);do{const a=n[r]??0,u=s*a/l;if(u>=o*.9&&i+(a<5?we.get(a)??0:0)<=17)return[a,u]}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??U.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?_.Horizontal:_.Vertical),dir:e.dir??K.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_min:null,_max:null}}function ie(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=Ge(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=Ge(t,e.asinh):e._max=t;return e._max}function Gt(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?(Ge(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=Gt(e,t);let i;return t.ori===_.Horizontal?i=t.dir===K.Forward?o:1-o:i=t.dir===K.Forward?1-o:o,s+i*n}function ne(e,t,n,s){if(n===0)return t.min??0;let o=(e-s)/n;return t.ori===_.Horizontal?t.dir===K.Backward&&(o=1-o):t.dir!==K.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,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,ie(o))}autoRangeX(t){var s,o,i,l,r,a;const n=new Map;for(const[u,c]of this.groupXScales){const h=this.scales.get(c);if(!h||!h.auto)continue;const f=t[u];if(!f||f.x.length===0)continue;const d=f.x[0],v=f.x[f.x.length-1];if(d==null||v==null)continue;const b=n.get(c);b?(b.dataMin=Math.min(b.dataMin,d),b.dataMax=Math.max(b.dataMax,v)):n.set(c,{dataMin:d,dataMax:v})}for(const[u,{dataMin:c,dataMax:h}]of n){const f=this.scales.get(u);if(f){if(f.range){const[d,v]=Me(c,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=v}else c===h?[f.min,f.max]=Me(c,h,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(f.min=c,f.max=h);ie(f)}}}autoRange(t,n,s){var r,a,u,c,h,f,d,v,b,L,g,w;const o=new Map;for(const[P,R]of this.groupXScales){const T=this.scales.get(R);if(!T||!T.auto)continue;const S=t[P];if(!S||S.x.length===0)continue;const C=S.x[0],x=S.x[S.x.length-1];if(C==null||x==null)continue;const I=o.get(R);I?(I.dataMin=Math.min(I.dataMin,C),I.dataMax=Math.max(I.dataMax,x)):o.set(R,{dataMin:C,dataMax:x})}for(const[P,{dataMin:R,dataMax:T}]of o){const S=this.scales.get(P);if(S){if(S.range){const[C,x]=Me(R,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:((u=S.range.min)==null?void 0:u.mode)??0},max:{pad:((c=S.range.max)==null?void 0:c.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=C,S.max=x}else R===T?[S.min,S.max]=Me(R,T,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}}):(S.min=R,S.max=T);ie(S)}}const i=new Map,l=new Map;for(const{group:P,index:R,yScale:T}of n){const S=t[P];if(!S)continue;const C=S.series[R];if(!C||C.length===0)continue;const x=s.windows.get(P),I=x?x[0]:0,D=x?x[1]:C.length-1,m=this.scales.get(T),p=(m==null?void 0:m.distr)===U.Log,[M,k]=s.getCachedMinMax(P,R,I,D,0,p),y=i.get(T),A=l.get(T);i.set(T,y!=null?Math.min(y,M):M),l.set(T,A!=null?Math.max(A,k):k)}for(const[P,R]of i){const T=this.scales.get(P);if(!T||!T.auto)continue;const S=l.get(P)??-O;if(R===O)continue;let C,x;if(T.distr===U.Log)[C,x]=Ft(R,S,T.log,!1);else{const I=T.range??{min:oe,max:oe};[C,x]=Me(R,S,{min:{pad:((d=I.min)==null?void 0:d.pad)??oe.pad,soft:((v=I.min)==null?void 0:v.soft)??oe.soft,mode:((b=I.min)==null?void 0:b.mode)??oe.mode},max:{pad:((L=I.max)==null?void 0:L.pad)??oe.pad,soft:((g=I.max)==null?void 0:g.soft)??oe.soft,mode:((w=I.max)==null?void 0:w.mode)??oe.mode}})}T.min=C,T.max=x,ie(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 u=1/0,c=-1/0;for(let h=r;h<a;h++){const f=t[h];f!=null&&(f<u&&(u=f),f>c&&(c=f))}o[l*2]=u,o[l*2+1]=c}}rangeMinMax(t,n){const{data:s,blockSize:o,blocks:i}=this;let l=1/0,r=-1/0;const a=Math.floor(t/o),u=Math.floor(n/o);if(a===u){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 c=(a+1)*o-1;for(let f=t;f<=c;f++){const d=s[f];d!=null&&(d<l&&(l=d),d>r&&(r=d))}for(let f=a+1;f<u;f++){const d=i[f*2]??1/0,v=i[f*2+1]??-1/0;d<l&&(l=d),v>r&&(r=v)}const h=u*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,u=-1/0;for(let c=l;c<r;c++){const h=n[c];h!=null&&(h<a&&(a=h),h>u&&(u=h))}o[t*2]=a,o[t*2+1]=u}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,u;if(!i||!l||l.min==null||l.max==null)a=0,u=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const c=i.x;if(c.length===0)a=0,u=0;else{a=re(l.min,c),u=re(l.max,c);const h=c[a],f=c[u];a>0&&h!=null&&h>l.min&&a--,u<c.length-1&&f!=null&&f<l.max&&u++}}(!r||r[0]!==a||r[1]!==u)&&(n=!0,(s=this.minMaxCache.get(o))==null||s.clear()),this.windows.set(o,[a,u])}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 u=this.data[t];if(!u)return[1/0,-1/0];const c=u.series[n];if(!c||c.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=At(c,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 u=s[r];if(u)for(let h=0;h<u.length;h++)a.push(u[h]??null);const c=this.blockTrees.get(`${t}:${r}`);c&&(c.setData(a),c.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 u=1/0,c=-1,h=-1,f=-1;const d=new Map;for(const v of i){if(v.show===!1)continue;let b=d.get(v.group);b==null&&(b=[],d.set(v.group,b)),b.push(v)}for(let v=0;v<o.length;v++){const b=o[v];if(b==null)continue;const L=b.x;if(L.length===0)continue;const g=a(v);if(g==null)continue;const w=l(g);if(w==null||w.min==null||w.max==null)continue;const[P,R]=r(v),T=s.width,S=s.left,C=ne(t+S,w,T,S),x=re(C,L,P,R),I=[x];x>P&&I.push(x-1),x<R&&I.push(x+1);const D=new Map;for(const m of I){const p=L[m];if(p==null)continue;const M=V(p,w,T,S);for(const k of d.get(v)??[]){const y=b.series[k.index];if(y==null)continue;const A=y[m];if(A==null)continue;let z=D.get(k.yScale);if(z==null&&!D.has(k.yScale)&&(z=l(k.yScale),D.set(k.yScale,z)),z==null||z.min==null||z.max==null)continue;const H=s.height,E=s.top,$=V(A,z,H,E),W=t+S-M,j=n+E-$,X=W*W+j*j;if(X<u&&(u=X,c=v,h=k.index,f=m,X===0))break}if(u===0)break}}this.state.activeGroup=c,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),u=re(t,o.x,r,a),c=o.x[u];if(c==null)return;const h=V(c,l,n.plotBox.width,n.plotBox.left);this.state.left=h-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=u;let f=0,d=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 L=b[u];if(L==null)continue;const g=n.scaleManager.getScale(v.yScale);if(!(g==null||g.min==null||g.max==null)){d=V(L,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,f=v.index;break}}this.state.top=d,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===K.Forward?n:s,u=o===K.Forward?s:n,c=o;for(let h=a;o===K.Forward?h<=u:h>=u;h+=c)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 $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,u=t===_.Horizontal?s:n,c=t===_.Horizontal?i:o;for(const[h,f]of e)h>r&&(t===_.Horizontal?l.rect(r,u,h-r,c):l.rect(u,r,c,h-r)),r=f;return r<a&&(t===_.Horizontal?l.rect(r,u,a-r,c):l.rect(u,r,c,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),Kt=xt(Le);function vt(){return(e,t,n,s,o,i,l,r,a,u,c,h,f)=>{const d=(f==null?void 0:f.spanGaps)??!1;if([a,u]=(s.distr===U.Log?ht:Ae)(t,a,u),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=C=>h(V(C,n,o,l)),L=C=>h(V(C,s,i,r));let g,w;n.ori===_.Horizontal?(g=Pe,w=Yt):(g=Le,w=Kt);const P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;if(u-a>=o*4){const C=A=>ne(A,n,o,l);let x=null,I=0,D=0,m=0,p=b(e[c===K.Forward?a:u]);const M=b(e[a]),k=b(e[u]);let y=C(c===K.Forward?M+1:k-1);for(let A=c===K.Forward?a:u;A>=a&&A<=u;A+=c){const z=e[A],E=(c===K.Forward?z<y:z>y)?p:b(z),$=t[A];E===p?$!=null?(m=$,x==null?(g(R,E,L(m)),D=x=I=m):m<x?x=m:m>I&&(I=m)):$===null&&!d&&(T=!0):(x!=null&&w(R,p,L(x),L(I),L(D),L(m)),$!=null?(m=$,g(R,E,L(m)),x=I=D=m):(x=null,I=0,$===null&&!d&&(T=!0)),p=E,y=C(p+c))}x!=null&&(x!==I?w(R,p,L(x),L(I),L(D),L(m)):g(R,p,L(m)))}else for(let C=c===K.Forward?a:u;C>=a&&C<=u;C+=c){const x=t[C];x===null&&!d?T=!0:x!=null&&g(R,b(e[C]),L(x))}{const C=P.fill=new Path2D(R),x=(f==null?void 0:f.fillTo)??s.min??0,I=L(x);let D=l,m=l+o;c===K.Backward&&([m,D]=[D,m]),g(C,m,I),g(C,D,I)}if(T){const C=Ve(e,t,a,u,c,b);P.gaps=C,P.clip=$e(C,n.ori,l,r,o,i)}return P}}const qe=new WeakMap;function Ze(e,t,n){return typeof t=="string"?t:Ut(e,t,n)}function Ut(e,t,n){const s=qe.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 qe.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=Ze(e,t.fill,l),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=Ze(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,u=r%2/2;a===1&&u>0&&e.translate(u,u),e.stroke(n.stroke)}e.restore()}const Ot=vt(),Je=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 u=this.lruMap.get(this.lruKey(t,n,r));u!=null&&u!==this.lruTail&&(this.lruUnlink(u),this.lruAppend(u))}return a}setCachedPaths(t,n,s,o,i){if(this.pathCacheSize>=Je){const c=Je>>2;let h=this.lruHead;for(let f=0;f<c&&h!=null;f++){const d=h.next,v=this.pathCache.get(h.group);if(v!=null){const b=v.get(h.index);b!=null&&(b.delete(h.key),this.pathCacheSize--,b.size===0&&v.delete(h.index),v.size===0&&this.pathCache.delete(h.group))}this.lruMap.delete(this.lruKey(h.group,h.index,h.key)),h=d}this.lruHead=h,h!=null?h.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),u=this.lruKey(t,n,a);if(!r.has(a)){this.pathCacheSize++;const c={group:t,index:n,key:a,prev:null,next:null};this.lruAppend(c),this.lruMap.set(u,c)}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 u=this.getCachedPaths(i,l,r,a);if(u==null){const c=t.config.paths??Ot,h=t.xScale.dir,f=b=>B(b),d=t.config.fillTo,v=typeof d=="function"?d(t.yScale.min??0,t.yScale.max??0):d;u=c(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,r,a,h,f,{fillTo:v,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,l,r,a,u)}Nt(o,t.config,u,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),ce=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:ae(_e(e,n),l);for(let a=r;a<=t;a=ae(a+n,l))i.push(Object.is(a,-0)?0:a);return i}function Qe(e){return e.map(t=>pt(t))}function en(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=se((n===10?J:xe)(e));let l=pe(n,i);n===10&&(l=ce[re(l,ce)]??l);let r=l,a=l*n;n===10&&(a=ce[re(a,ce)]??a);let u=0;do{if(r>=e&&s.push(r),r=r+l,n===10&&!we.has(r)){const c=we.get(l)??0;r=ae(r,c)}r>=a*(1-1e-10)&&(l=r,a=l*n,n===10&&(a=ce[re(a,ce)]??a))}while(r<=t&&++u<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 he(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=de(e.side)===_.Vertical,i=e.space??(o?30:nn(t,n)),l=e.incrs??ce;return Ht(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(de(e.side)===_.Vertical&&t!=null){let u=0;for(const h of t)h.length>u&&(u=h.length);const c=u*7;return Math.max(50,s+o+c+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,ue=3600,le=86400,fe=2592e3,Ce=31536e3,an=[1,5,10,15,30,ge,5*ge,10*ge,15*ge,30*ge,ue,2*ue,3*ue,4*ue,6*ue,12*ue,le,2*le,3*le,7*le,14*le,fe,2*fe,3*fe,6*fe,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>=fe){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/fe));if(i<e&&(l.setUTCMonth(l.getUTCMonth()+1),i=l.getTime()/1e3),r>1){const a=l.getUTCMonth(),u=Math.ceil((a+1)/r)*r;l.setUTCMonth(u-1),i=l.getTime()/1e3}for(;i<=t;)o.push(i),l.setUTCMonth(l.getUTCMonth()+r),i=l.getTime()/1e3;return o}if(n>=le){const l=new Date(e*1e3);l.setUTCHours(0,0,0,0),i=l.getTime()/1e3,i<e&&(i+=le)}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 et=new Map;function un(e,t){const n=JSON.stringify(e)+(t??"");let s=et.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),et.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>=fe?s=mn:t>=le?s=gn:t>=ue?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,u=s/a;if(u>=o)return[r,u]}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 u=r.side,h=de(u)===_.Horizontal?n:s,{min:f,max:d}=a;let v,b;if(a.time){const g=r.space??80;[v,b]=xn(f,d,an,h,g)}else[v,b]=sn(r,f,d,h);if(l._incr=v,l._space=b,b===0)continue;if(r.splits)l._splits=r.splits(f,d,v,b);else if(a.time)l._splits=cn(f,d,v);else if(a.distr===U.Log)l._splits=en(f,d,a.log);else{const g=a.distr===U.Ordinal;l._splits=Qt(f,d,v,b,g)}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 g=tn(l._splits,a.log),w=Qe(l._splits);l._values=w.map((P,R)=>g[R]?P:"")}else l._values=Qe(l._splits);l._rotate=u===Y.Bottom?r.rotate??0:0;const L=l._size;l._size=ye(ln(r,l._values)),L!==l._size&&(i=!1)}return i}function tt(e,t,n,s=0){let o=e,i=t-s,l=0,r=s;for(const a of n){if(!a._show)continue;const u=a.config.side,c=de(u)===_.Vertical,h=a.config.label!=null?a.config.labelSize??20:0,f=a._size+h;f>0&&(c?(o-=f,u===Y.Left&&(l+=f)):(i-=f,u===Y.Top&&(r+=f)))}return{left:l,top:r,width:Math.max(o,0),height:Math.max(i,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 Y.Top:return n-=a,n+a;case Y.Right:{const u=s;return s+=a,u}case Y.Bottom:{const u=o;return o+=a,u}case Y.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 u=r.config.labelSize??20;r._lpos=l(a,u)}}}function Sn(e,t,n,s,o=0){for(const a of n)a._size=0;let i=!1,l=0,r={left:0,top:0,width:e,height:t};for(;!i;){l++;const a=Mn(n,s,r.width,r.height);i=l===vn||a,i||(r=tt(e,t,n,o))}return r=tt(e,t,n,o),bn(n,r),r}const nt="top",st="bottom",yn="left",kn="right";function Fe(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,u,c){const h=r%2/2;e.save(),e.translate(h,h),e.strokeStyle=a,e.lineWidth=r,u.length>0&&e.setLineDash(u),e.beginPath();let f=0,d=0,v=0,b=0;const L=i+(o===Y.Top||o===Y.Left?-l:l);s===_.Horizontal?(d=i,b=L):(f=i,v=L);for(let g=0;g<t.length;g++)n[g]!=null&&(s===_.Horizontal?f=v=t[g]??0:d=b=t[g]??0,e.moveTo(f,d),e.lineTo(v,b));e.stroke(),e.restore()}function Cn(e,t,n,s,o,i){const l=B(s.left*o),r=B(s.top*o),a=B(s.width*o),u=B(s.height*o);for(const c of t){if(!c._show)continue;const h=c.config,f=h.side,d=de(f),v=n(h.scale);if(!v||v.min==null||v.max==null)continue;const b=h.stroke??"#000",L=f===Y.Top||f===Y.Left?-1:1,g=c._splits,w=c._values;if(!g||!w||c._space===0)continue;const P=d===_.Horizontal?s.width:s.height,R=d===_.Horizontal?s.left:s.top,T=g.map(D=>B(V(D,v,P,R)*o)),S=w.map(D=>D===""?null:D),C=h.grid;if((C==null?void 0:C.show)!==!1){const D=(C==null?void 0:C.stroke)??"rgba(0,0,0,0.12)",m=B(((C==null?void 0:C.width)??2)*o),p=((C==null?void 0:C.dash)??[]).map(y=>y*o),M=d===_.Horizontal?r:l,k=d===_.Horizontal?u:a;ot(e,T,S,d,2,M,k,m,D,p)}const x=h.ticks;if((x==null?void 0:x.show)!==!1){const D=(x==null?void 0:x.stroke)??b,m=B(((x==null?void 0:x.width)??1)*o),p=B(((x==null?void 0:x.size)??10)*o),M=((x==null?void 0:x.dash)??[]).map(y=>y*o),k=B(c._pos*o);ot(e,T,S,d,f,k,p,m,D,M)}{const D=(x==null?void 0:x.show)!==!1?((x==null?void 0:x.size)??10)*o:0,m=B((h.gap??5)*o),p=B(c._pos*o),M=(D+m)*L,k=p+M,y=Fe(h.font??"12px system-ui, sans-serif",o),A=d===_.Horizontal?"center":f===Y.Left?kn:yn,z=d===_.Horizontal?f===Y.Bottom?nt:st:"middle";e.font=y,e.fillStyle=b,e.textAlign=A,e.textBaseline=z;const H=c._rotate*-De/180;if(H!==0){const E=Math.cos(H),$=Math.sin(H);for(let W=0;W<w.length;W++){const j=w[W];if(j==null||j==="")continue;const X=T[W]??0;e.setTransform(E,$,-$,E,X,k),e.fillText(j,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let E=0;E<w.length;E++){const $=w[E];if($==null||$==="")continue;const W=T[E]??0,j=d===_.Horizontal?W:k,X=d===_.Horizontal?k:W;e.fillText($,j,X)}}if(h.label!=null){const D=Fe(h.labelFont??"bold 12px system-ui, sans-serif",o);e.font=D,e.fillStyle=b,e.textAlign="center",e.textBaseline=f===Y.Bottom?nt:st;const m=B((c._lpos+(h.labelGap??0)*L)*o);d===_.Vertical?(e.save(),e.translate(m,B(r+u/2)),e.rotate((f===Y.Left?-De:De)/2),e.fillText(h.label,0,0),e.restore()):e.fillText(h.label,B(l+a/2),m)}const I=h.border;if((I==null?void 0:I.show)!==!1&&I!=null){const D=I.stroke??b,m=B((I.width??1)*o),p=(I.dash??[]).map(k=>k*o),M=B(c._pos*o);e.strokeStyle=D,e.lineWidth=m,p.length>0&&e.setLineDash(p),e.beginPath(),d===_.Horizontal?(e.moveTo(l,M),e.lineTo(l+a,M)):(e.moveTo(M,r),e.lineTo(M,r+u)),e.stroke(),p.length>0&&e.setLineDash([])}}if(i!=null){const c=Fe("bold 14px system-ui, sans-serif",o);e.font=c,e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(i,B(l+a/2),B(4*o))}}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 P;if(t.left<0||t.top<0)return;const u={...Tn,...a},c=s,h=B(n.left*c),f=B(n.top*c),d=B(n.width*c),v=B(n.height*c),b=B(u.width*c),L=b%2/2,g=B((n.left+t.left)*c)+L,w=B((n.top+t.top)*c)+L;if(e.save(),e.strokeStyle=u.stroke,e.lineWidth=b,e.setLineDash(u.dash.map(R=>R*c)),u.showX&&(e.beginPath(),e.moveTo(g,f),e.lineTo(g,f+v),e.stroke()),u.showY&&(e.beginPath(),e.moveTo(h,w),e.lineTo(h+d,w),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const R=t.activeGroup,T=t.activeSeriesIdx,S=t.activeDataIdx,C=o[R];if(C!=null&&T>=0&&T<C.series.length&&S<C.x.length){const x=C.x[S],I=C.series[T],D=I!=null?I[S]:null;if(x!=null&&D!=null){let m=u.stroke,p=!0;for(const M of i)if(M.group===R&&M.index===T){const k=M.stroke;m=(typeof k=="string"?k:void 0)??u.stroke,p=((P=M.cursor)==null?void 0:P.show)!==!1;break}if(p){const M=r(R),k=M!=null?l(M):void 0,y=In(i,R,T),A=y!=null?l(y):void 0;if(k!=null&&A!=null&&k.min!=null&&k.max!=null&&A.min!=null&&A.max!=null){const z=B(V(x,k,n.width,n.left)*c),H=B(V(D,A,n.height,n.top)*c),E=u.pointRadius*c,$=B(2*c);e.beginPath(),e.arc(z,H,E,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=m,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),u=B(t.width*l),c=B(t.height*l);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,u,c),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=B(i.width*l),e.strokeRect(r,a,u,c)),e.restore()}function Pn(e,t,n,s,o,i,l,r,a,u,c,h){const f=c/2*l,d=Math.max(1,B(c*.2))*l,v=(u==null?void 0:u.stroke)??h,b=(u==null?void 0:u.fill)??"#fff";e.save(),e.strokeStyle=v,e.fillStyle=b,e.lineWidth=d,(u==null?void 0:u.dash)!=null&&e.setLineDash(u.dash.map(L=>L*l));for(let L=r;L<=a;L++){const g=n[L];if(g==null)continue;const w=t[L];if(w==null)continue;const P=B(V(w,s,i.width,i.left)*l),R=B(V(g,o,i.height,i.top)*l);e.beginPath(),e.arc(P,R,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 u=d=>V(d,s,i.width,i.left)*l,c=d=>V(d,o,i.height,i.top)*l,h=new Path2D;let f=!1;for(let d=r;d<=a;d++){const v=t[d],b=e[d];if(v==null||b==null)continue;const L=u(b),g=c(v);f?h.lineTo(L,g):(h.moveTo(L,g),f=!0)}if(!f)return null;for(let d=a;d>=r;d--){const v=n[d],b=e[d];v==null||b==null||h.lineTo(u(b),c(v))}return h.closePath(),h}function Dn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function He(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,title:void 0,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:u}=e;if(a==null||i===0||l===0)return;const c=a.getContext("2d");if(c==null)return;s.setContext(c,r);const f=(u.dirty&~(Z.Cursor|Z.Select))===0,d=g=>t.getScale(g);if(f&&s.restoreSnapshot(c)){if(lt(c,e.cursorManager.state,e.plotBox,r,n.data,o,d,g=>t.getGroupXScaleKey(g)),it(c,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){c.save(),c.scale(r,r);const g=He(c,e.plotBox,r,d);for(const w of e.cursorDrawHooks)try{w(g,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}for(const g of e.listeners)g();return}t.autoRangeX(n.data),n.updateWindows(g=>{const w=t.getGroupXScaleKey(g);return w!=null?t.getScale(w):void 0});const v=o.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(t.autoRange(n.data,v,n),Fn(e),e.axisStates.length>0){const g=e.title!=null?20:0;e.plotBox=Sn(i,l,e.axisStates,d,g)}else e.plotBox={left:10,top:10,width:i-20,height:l-20};c.clearRect(0,0,i*r,l*r),e.axisStates.length>0&&Cn(c,e.axisStates,d,e.plotBox,r,e.title);const b=[];for(const g of o){const w=t.getGroupXScaleKey(g.group),P=w!=null?t.getScale(w):void 0,R=t.getScale(g.yScale);P==null||R==null||b.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:P,yScale:R,window:n.getWindow(g.group)})}c.save(),c.scale(r,r),c.beginPath(),c.rect(e.plotBox.left,e.plotBox.top,e.plotBox.width,e.plotBox.height),c.clip();for(let g=0;g<b.length;g++){const w=b[g];w!=null&&(e.focusedSeries!=null&&g!==e.focusedSeries?(c.globalAlpha=e.focusAlpha,s.drawSeries(w,e.plotBox,1),c.globalAlpha=1):s.drawSeries(w,e.plotBox,1))}const L=new Map;for(const g of o)L.set(`${g.group}-${g.index}`,g);for(const g of e.bandConfigs){const w=t.getGroupXScaleKey(g.group),P=w!=null?t.getScale(w):void 0,R=L.get(`${g.group}-${g.series[0]}`),T=L.get(`${g.group}-${g.series[1]}`);if(P==null||R==null||T==null)continue;const S=t.getScale(R.yScale);if(S==null)continue;const[C,x]=n.getWindow(g.group),I=g.series[0],D=g.series[1];let m=s.getCachedBandPath(g.group,I,D,C,x);m==null&&(m=Rn(n.getXValues(g.group),n.getYValues(g.group,I),n.getYValues(g.group,D),P,S,e.plotBox,r,C,x)??void 0,m!=null&&s.setCachedBandPath(g.group,I,D,C,x,m)),m!=null&&Dn(c,g,m)}for(const g of b){const w=g.config;if(w.show===!1)continue;const P=w.points,R=w.width??1,T=(P==null?void 0:P.size)??3+R*2,S=(P==null?void 0:P.space)??T*2,[C,x]=g.window;Ln(P==null?void 0:P.show,w.group,w.index,C,x,e.plotBox.width,S)&&Pn(c,g.dataX,g.dataY,g.xScale,g.yScale,e.plotBox,r,C,x,P,T,(typeof w.stroke=="string"?w.stroke:null)??"#000")}if(c.restore(),e.drawHooks.size>0){c.save(),c.beginPath(),c.rect(e.plotBox.left*r,e.plotBox.top*r,e.plotBox.width*r,e.plotBox.height*r),c.clip(),c.scale(r,r);const g=He(c,e.plotBox,r,d);for(const w of e.drawHooks)try{w(g)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(c,i*r,l*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,o,d,g=>n.getWindow(g),g=>t.getGroupXScaleKey(g))),lt(c,e.cursorManager.state,e.plotBox,r,n.data,o,d,g=>t.getGroupXScaleKey(g)),it(c,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){c.save(),c.scale(r,r);const g=He(c,e.plotBox,r,d);for(const w of e.cursorDrawHooks)try{w(g,e.cursorManager.state)}catch(P){console.warn("[uPlot+] draw hook error:",P)}c.restore()}for(const g of e.listeners)g();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const g of t.getAllScales()){if(g.min==null||g.max==null)continue;const w=e._prevScaleRanges.get(g.id);if(w==null||w.min!==g.min||w.max!==g.max)try{e.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(P){console.warn("[uPlot+] event callback error:",P)}}e._prevScaleRanges.clear();for(const g of t.getAllScales())g.min!=null&&g.max!=null&&e._prevScaleRanges.set(g.id,{min:g.min,max:g.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 Hn(){const e=F.useRef(null);return e.current===null&&(e.current=zn()),e.current}const bt=F.createContext(null);function ee(){const e=F.useContext(bt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function En(e,t){F.useEffect(()=>{if(t!=null)return Gn(e,t)},[e,t])}function Gn(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 p=t.getBoundingClientRect(),M=e.plotBox,k=m.clientX-p.left-M.left,y=m.clientY-p.top-M.top;return{cx:k,cy:y}}function a(m,p){const M=e.plotBox;return m>=0&&m<=M.width&&p>=0&&p<=M.height}function u(m,p){const M=t.getBoundingClientRect(),k=m-M.left,y=p-M.top,A=e.plotBox;for(const z of e.axisStates){const H=z.config,E=H.side;if(z._size<=0)continue;const W=y>=A.top&&y<=A.top+A.height,j=k>=A.left&&k<=A.left+A.width;if(E===Y.Left&&k<A.left&&W||E===Y.Right&&k>A.left+A.width&&W||E===Y.Top&&y<A.top&&j||E===Y.Bottom&&y>A.top+A.height&&j){const N=de(E);return{scaleId:H.scale,ori:N}}}return null}function c(m,p,M){const k=e.cursorManager.state;let y=null;if(k.activeGroup>=0&&k.activeDataIdx>=0){const A=e.dataStore.data[k.activeGroup];if(A!=null){const z=A.x[k.activeDataIdx],H=A.series[k.activeSeriesIdx],E=H!=null?H[k.activeDataIdx]:void 0;if(z!=null&&E!=null){const $=e.plotBox,W=e.scaleManager.getGroupXScaleKey(k.activeGroup),j=W!=null?e.scaleManager.getScale(W):void 0,X=e.seriesConfigs.find(Ke=>Ke.group===k.activeGroup&&Ke.index===k.activeSeriesIdx),N=X!=null?e.scaleManager.getScale(X.yScale):void 0;let te=p,Re=M;(j==null?void 0:j.min)!=null&&j.max!=null&&(te=V(z,j,$.width,$.left)-$.left),(N==null?void 0:N.min)!=null&&N.max!=null&&(Re=V(E,N,$.height,$.top)-$.top);const Xe=p-te,Ye=M-Re;y={group:k.activeGroup,seriesIdx:k.activeSeriesIdx,dataIdx:k.activeDataIdx,xVal:z,yVal:E,pxX:te,pxY:Re,dist:Math.sqrt(Xe*Xe+Ye*Ye)}}}}return{plotX:p,plotY:M,point:y,srcEvent:m}}function h(m){const p=e.plotBox,M=m.left/p.width,k=(m.left+m.width)/p.width,y={};for(const A of e.scaleManager.getAllScales()){if(A.ori!==_.Horizontal||A.min==null||A.max==null)continue;const z=ne(p.left+M*p.width,A,p.width,p.left),H=ne(p.left+k*p.width,A,p.width,p.left);y[A.id]={min:Math.min(z,H),max:Math.max(z,H)}}return{left:M,right:k,ranges:y}}function f(){const m=e.eventCallbacks.onScaleChange;if(m!=null)for(const p of e.scaleManager.getAllScales()){if(p.min==null||p.max==null)continue;const M=e._prevScaleRanges.get(p.id);(M==null||M.min!==p.min||M.max!==p.max)&&m(p.id,p.min,p.max)}}function d(m,p){if(i!=null){const A=t.getBoundingClientRect(),z=m.clientY-A.top,H=e.plotBox,E=(z-i.startY)/H.height,$=i.startMax-i.startMin,W=e.scaleManager.getScale(i.scaleId);W!=null&&(W.min=i.startMin+E*$,W.max=i.startMax+E*$,W.auto=!1,ie(W),e.renderer.clearCache(),e.scheduleRedraw());return}const M=r(m);if(M==null)return;const{cx:k,cy:y}=M;if(!a(k,y)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(k,y,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 z=e.seriesConfigs.findIndex(H=>H.group===A.activeGroup&&H.index===A.activeSeriesIdx);z>=0&&e.focusedSeries!==z&&(e.focusedSeries=z,e.scheduleRedraw())}}if(p!=null&&e.eventCallbacks.onCursorMove!=null&&a(k,y))try{e.eventCallbacks.onCursorMove(c(p,k,y))}catch(A){console.warn("[uPlot+] event callback error:",A)}if(n!=null){const A=n.x,z=e.plotBox,H=Math.max(0,Math.min(k,z.width));s.show=!0,s.left=Math.min(A,H),s.top=0,s.width=Math.abs(H-A),s.height=z.height,e.selectState=s}n!=null?e.scheduler.mark(Z.Cursor|Z.Select):e.scheduleCursorRedraw()}function v(m){d(m,m)}function b(m){if(m.button!==0)return;const p=u(m.clientX,m.clientY);if(p!=null&&p.ori===_.Vertical){const k=e.scaleManager.getScale(p.scaleId);if(k!=null&&k.min!=null&&k.max!=null){const y=t.getBoundingClientRect();i={scaleId:p.scaleId,startY:m.clientY-y.top,startMin:k.min,startMax:k.max},m.preventDefault();return}}const M=r(m);M!=null&&a(M.cx,M.cy)&&(n={x:M.cx,y:M.cy},l=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function L(m){if(i!=null){f(),i=null;return}if(n!=null){if(s.width>5){l=!0;let p=!0;if(e.eventCallbacks.onSelect!=null){const M=h(s);let k;try{k=e.eventCallbacks.onSelect(M)}catch(y){console.warn("[uPlot+] event callback error:",y)}k===!1&&(p=!1)}p&&(C(s),f())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function g(m){L()}function w(m){if(l){l=!1;return}const p=e.eventCallbacks.onClick;if(p==null)return;const M=r(m);if(M!=null&&a(M.cx,M.cy))try{p(c(m,M.cx,M.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}}function P(m){const p=e.eventCallbacks.onContextMenu;if(p==null)return;const M=r(m);if(M!=null&&a(M.cx,M.cy)){m.preventDefault();try{p(c(m,M.cx,M.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}}}function R(m){var p,M;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{(M=(p=e.eventCallbacks).onCursorLeave)==null||M.call(p)}catch(k){console.warn("[uPlot+] event callback error:",k)}}function T(m){if(e.eventCallbacks.onDblClick!=null){const p=r(m);if(p!=null&&a(p.cx,p.cy)){let M;try{M=e.eventCallbacks.onDblClick(c(m,p.cx,p.cy))}catch(k){console.warn("[uPlot+] event callback error:",k)}if(M===!1)return}}for(const p of e.scaleConfigs)e.scaleManager.addScale(p);e.renderer.clearCache(),e.scheduleRedraw()}function S(m){const p=e.wheelZoom;if(!p)return;let M=!1,k=!1;if(p===!0||p==="x")M=!0;else if(p==="y")k=!0;else if(p==="xy")M=!0,k=!0;else if(typeof p=="object"){if(p.x){const H=typeof p.x=="object"?p.x.key:void 0;M=H==null||m[`${H}Key`]}if(p.y){const H=typeof p.y=="object"?p.y.key:void 0;k=H==null||m[`${H}Key`]}}if(!M&&!k)return;const y=r(m);if(y==null||!a(y.cx,y.cy))return;m.preventDefault();const A=Math.max(.1,Math.min(10,1-m.deltaY*.001)),z=e.plotBox;for(const H of e.scaleManager.getAllScales()){if(H.min==null||H.max==null)continue;const E=H.ori===_.Horizontal;if(E&&!M||!E&&!k)continue;const $=E?z.width:z.height,W=E?z.left:z.top,j=E?y.cx+z.left:y.cy+z.top,X=ne(j,H,$,W),N=X-(X-H.min)*A,te=X+(H.max-X)*A;H.min=Math.min(N,te),H.max=Math.max(N,te),H.auto=!1,ie(H)}e.renderer.clearCache(),e.scheduleRedraw(),f()}function C(m){const p=e.plotBox,M=m.left/p.width,k=(m.left+m.width)/p.width;for(const y of e.scaleManager.getAllScales()){if(y.ori!==_.Horizontal||y.min==null||y.max==null)continue;const A=ne(p.left+M*p.width,y,p.width,p.left),z=ne(p.left+k*p.width,y,p.width,p.left);y.min=Math.min(A,z),y.max=Math.max(A,z),y.auto=!1,ie(y)}e.renderer.clearCache()}function x(m){if(m.touches.length===2){const k=m.touches[0],y=m.touches[1],A=y.clientX-k.clientX,z=y.clientY-k.clientY;o={dist:Math.sqrt(A*A+z*z),midX:(k.clientX+y.clientX)/2,midY:(k.clientY+y.clientY)/2},n=null;return}const p=m.touches[0];if(p==null)return;const M=r(p);M!=null&&a(M.cx,M.cy)&&(n={x:M.cx,y:M.cy},l=!1)}function I(m){if(m.touches.length===2&&o!=null){m.preventDefault();const M=m.touches[0],k=m.touches[1],y=k.clientX-M.clientX,A=k.clientY-M.clientY,z=Math.sqrt(y*y+A*A),H=z/o.dist,E=t.getBoundingClientRect(),$=e.plotBox,W=o.midX-E.left-$.left;for(const j of e.scaleManager.getAllScales()){if(j.ori!==_.Horizontal||j.min==null||j.max==null)continue;const X=ne(W+$.left,j,$.width,$.left),N=X-(X-j.min)/H,te=X+(j.max-X)/H;j.min=Math.min(N,te),j.max=Math.max(N,te),j.auto=!1,ie(j)}o.dist=z,e.renderer.clearCache(),e.scheduleRedraw(),f();return}const p=m.touches[0];p!=null&&(d(p,m),n!=null&&m.preventDefault())}function D(m){if(o!=null){o=null;return}m.changedTouches[0]!=null&&L()}return t.addEventListener("mousemove",v),t.addEventListener("mousedown",b),t.addEventListener("mouseup",g),t.addEventListener("click",w),t.addEventListener("contextmenu",P),t.addEventListener("mouseleave",R),t.addEventListener("dblclick",T),t.addEventListener("wheel",S,{passive:!1}),t.addEventListener("touchstart",x,{passive:!0}),t.addEventListener("touchmove",I,{passive:!1}),t.addEventListener("touchend",D),()=>{t.removeEventListener("mousemove",v),t.removeEventListener("mousedown",b),t.removeEventListener("mouseup",g),t.removeEventListener("click",w),t.removeEventListener("contextmenu",P),t.removeEventListener("mouseleave",R),t.removeEventListener("dblclick",T),t.removeEventListener("wheel",S),t.removeEventListener("touchstart",x),t.removeEventListener("touchmove",I),t.removeEventListener("touchend",D)}}const Ee=new Map;function _n(e){let t=Ee.get(e);return t==null&&(t=new Vn(e),Ee.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&&Ee.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){F.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 Be({width:e,height:t,data:n,children:s,className:o,pxRatio:i,title:l,onDraw:r,onCursorDraw:a,syncKey:u,cursor:c,onClick:h,onContextMenu:f,onDblClick:d,onCursorMove:v,onCursorLeave:b,onScaleChange:L,onSelect:g}){var k;const w=Hn(),[P,R]=F.useState(null),T=i??(typeof window<"u"&&window.devicePixelRatio||1),S=c==null?void 0:c.wheelZoom,C=typeof S=="object"?JSON.stringify(S):S,x=((k=c==null?void 0:c.focus)==null?void 0:k.alpha)??((c==null?void 0:c.focus)!=null?.15:1);F.useEffect(()=>{w.wheelZoom=S,w.focusAlpha=x},[w,C,x]),w.title=l,w.eventCallbacks.onClick=h,w.eventCallbacks.onContextMenu=f,w.eventCallbacks.onDblClick=d,w.eventCallbacks.onCursorMove=v,w.eventCallbacks.onCursorLeave=b,w.eventCallbacks.onScaleChange=L,w.eventCallbacks.onSelect=g,En(w,P),$n(w,u);const I=F.useCallback(y=>{w.canvas=y,y&&w.scheduleRedraw()},[w]),D=F.useCallback(y=>{R(y)},[]);F.useEffect(()=>{w.pxRatio=T,w.setSize(e,t)},[w,e,t,T]),F.useEffect(()=>()=>{w.canvas=null,w.scheduler.cancel(),w.focusedSeries=null},[w]),F.useEffect(()=>{if(P==null||typeof ResizeObserver>"u")return;const y=new ResizeObserver(A=>{const z=A[0];if(z==null)return;const{width:H,height:E}=z.contentRect;H>0&&E>0&&(H!==w.width||E!==w.height)&&w.setSize(Math.round(H),Math.round(E))});return y.observe(P),()=>{y.disconnect()}},[w,P]);const m=F.useRef(n);F.useEffect(()=>{if(n===m.current&&w.dataStore.data.length>0)return;m.current=n,w.dataStore.setData(n),w.renderer.clearCache();const y="x";w.scaleManager.getScale(y)||w.registerScale({id:y,auto:!0});for(let A=0;A<n.length;A++)w.scaleManager.setGroupXScale(A,y);w.scheduleRedraw()},[w,n]);const p=F.useRef(r);p.current=r,F.useEffect(()=>{const y=A=>{var z;(z=p.current)==null||z.call(p,A)};return w.drawHooks.add(y),()=>{w.drawHooks.delete(y)}},[w]);const M=F.useRef(a);return M.current=a,F.useEffect(()=>{const y=(A,z)=>{var H;(H=M.current)==null||H.call(M,A,z)};return w.cursorDrawHooks.add(y),()=>{w.cursorDrawHooks.delete(y)}},[w]),G.jsx(bt.Provider,{value:w,children:G.jsxs("div",{className:o,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[G.jsx("div",{ref:D,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:G.jsx("canvas",{ref:I,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 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(rt(r)&&rt(a)){if(!Bn(r,a))return!1}else return!1}return!0}function Te(e){const t=ee(),n=F.useRef(e);n.current=e,F.useEffect(()=>{const o=n.current;return t.registerScale({...o}),t.scheduleRedraw(),()=>{t.unregisterScale(o.id),t.scheduleRedraw()}},[t,e.id]);const s=F.useRef(null);return F.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.renderer.clearCache(),t.scheduleRedraw())}),null}function je(e){const t=ee(),n=F.useRef(e);n.current=e,F.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=F.useRef(null);return F.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 Wn(e){return{...e,side:e.side??(e.scale==="x"?Y.Bottom:Y.Left),show:e.show??!0}}function Ie(e){const t=ee(),n=Wn(e),s=F.useRef(n);s.current=n,F.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=F.useRef(null);return F.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 jn({series:e,group:t,fill:n,dir:s}){const o=ee(),i=F.useRef(null),l=e[0],r=e[1];return F.useEffect(()=>{const a={series:[l,r],group:t,fill:n,dir:s};return i.current!=null&&(o.bandConfigs=o.bandConfigs.filter(u=>u!==i.current)),i.current=a,o.bandConfigs.push(a),o.scheduleRedraw(),()=>{o.bandConfigs=o.bandConfigs.filter(u=>u!==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},Kn={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},Un=F.memo(function({group:t,index:n,label:s,color:o,isHidden:i,valueStr:l,store:r}){const a=F.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);return G.jsxs("span",{onClick:a,style:{...Kn,opacity:i?.4:1},children:[G.jsx("span",{style:{...Xn,backgroundColor:o}}),G.jsx("span",{children:s}),l&&G.jsx("span",{style:Yn,children:l})]})});function Nn({show:e=!0,position:t="bottom",className:n}){const s=ee(),o=F.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=F.useCallback(c=>s.subscribe(c),[s]),l=F.useCallback(()=>{const{activeGroup:c,activeDataIdx:h}=s.cursorManager.state,f=s.seriesConfigs.length,{revision:d}=s,v=o.current;if(v.activeGroup===c&&v.activeDataIdx===h&&v.seriesCount===f&&v.revision===d)return v;const b={activeGroup:c,activeDataIdx:h,seriesCount:f,revision:d};return o.current=b,b},[s]),r=F.useSyncExternalStore(i,l);if(!e)return null;const{activeGroup:a,activeDataIdx:u}=r;return G.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(c=>{const h=typeof c.stroke=="string"?c.stroke:"#000";let f="";if(u>=0&&a>=0){const v=s.dataStore.getYValues(c.group,c.index)[u];v!=null&&(f=typeof v=="number"?v.toPrecision(4):String(v))}return G.jsx(Un,{group:c.group,index:c.index,label:c.label??`Series ${c.index}`,color:h,isHidden:c.show===!1,valueStr:f,store:s},`${c.group}:${c.index}`)})})}function On({show:e=!0,className:t,children:n,offset:s={}}){var M,k;const o=ee(),i=F.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),l=F.useRef(null),r=F.useCallback(y=>o.subscribe(y),[o]),a=F.useCallback(()=>{const y=o.cursorManager.state,{revision:A}=o,z=i.current;if(z.left===y.left&&z.top===y.top&&z.activeGroup===y.activeGroup&&z.activeDataIdx===y.activeDataIdx&&z.revision===A)return z;const H={left:y.left,top:y.top,activeGroup:y.activeGroup,activeDataIdx:y.activeDataIdx,revision:A};return i.current=H,H},[o]),u=F.useSyncExternalStore(r,a);if(!e||u.activeDataIdx<0||u.activeGroup<0||u.left<0)return null;const{activeGroup:c,activeDataIdx:h}=u,f=o.plotBox,d=o.dataStore.data[c],v=d!=null?d.x[h]??null:null,b=v!=null?parseFloat(v.toPrecision(6)).toString():"",L=[];for(const y of o.seriesConfigs){if(y.show===!1)continue;const A=o.dataStore.getYValues(y.group,y.index),z=y.group===c?A[h]:null;L.push({label:y.label??`Series ${y.index}`,value:z,color:typeof y.stroke=="string"?y.stroke:"#000",group:y.group,index:y.index})}const g={x:v,xLabel:b,items:L,left:u.left+f.left,top:u.top+f.top},w=s.x??12,P=s.y??-12,R=((M=l.current)==null?void 0:M.offsetWidth)??0,T=((k=l.current)==null?void 0:k.offsetHeight)??0,S=u.left+f.left,C=u.top+f.top,x=f.left+f.width,I=f.top+f.height,D=Math.max(f.left,Math.min(S+w,x-R)),m=Math.max(f.top,Math.min(C+P,I-T)),p={position:"absolute",left:D,top:m,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100};return n?G.jsx("div",{ref:l,className:t,style:p,children:n(g)}):G.jsxs("div",{ref:l,className:t,style:{...p,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:[G.jsx("div",{style:{fontWeight:600,marginBottom:2},children:b}),L.map(y=>G.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[G.jsx("span",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:y.color,display:"inline-block"}}),G.jsxs("span",{children:[y.label,":"]}),G.jsx("span",{style:{fontWeight:600},children:y.value!=null?y.value.toPrecision(4):"—"})]},`${y.group}:${y.index}`))]})}function qn({width:e,height:t,data:n,onRangeChange:s,initialRange:o,className:i,colors:l,grips:r=!1}){const a=F.useRef(null),[u,c]=F.useState(()=>{if(o!=null&&n.length>0){const T=n[0];if(T!=null&&T.x.length>1){const S=T.x[0],x=T.x[T.x.length-1]-S;if(x>0)return[Math.max(0,(o[0]-S)/x),Math.min(1,(o[1]-S)/x)]}}return[.25,.75]}),h=F.useRef(null);F.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],x=T.x[T.x.length-1]-S,I=S+u[0]*x,D=S+u[1]*x,m=h.current,p=Math.max(1e-10,Math.abs(D-I)*1e-12);m!=null&&Math.abs(m[0]-I)<p&&Math.abs(m[1]-D)<p||(h.current=[I,D],s(I,D))},[u,n,s]);const f=F.useRef(null),d=F.useCallback(T=>{const S=a.current;if(S==null)return 0;const C=S.getBoundingClientRect();return Math.max(0,Math.min(1,(T-C.left)/C.width))},[]),v=F.useCallback(T=>{const S=a.current;if(S==null)return;const C=d(T.clientX),x=S.getBoundingClientRect().width,I=x>0?8/x:0;let D;if(Math.abs(C-u[0])<I)D="left";else if(Math.abs(C-u[1])<I)D="right";else if(C>=u[0]&&C<=u[1])D="move";else{const m=u[1]-u[0],p=m/2,M=Math.max(0,Math.min(1-m,C-p));c([M,M+m]),D="move"}f.current={mode:D,startX:T.clientX,startFrac:[...u]},S.setPointerCapture(T.pointerId),T.preventDefault()},[u,d]),b=F.useCallback(T=>{const S=f.current;if(S==null)return;const C=d(T.clientX),x=d(S.startX),I=C-x;if(S.mode==="move"){const D=S.startFrac[1]-S.startFrac[0];let m=S.startFrac[0]+I;m=Math.max(0,Math.min(1-D,m)),c([m,m+D])}else if(S.mode==="left"){const D=Math.max(0,Math.min(S.startFrac[1]-.01,S.startFrac[0]+I));c([D,S.startFrac[1]])}else{const D=Math.min(1,Math.max(S.startFrac[0]+.01,S.startFrac[1]+I));c([S.startFrac[0],D])}},[d]),L=F.useCallback(T=>{f.current=null;const S=a.current;S!=null&&S.releasePointerCapture(T.pointerId)},[]),g=`${u[0]*100}%`,w=`${(u[1]-u[0])*100}%`,P=n[0],R=P!=null?P.series.length:0;return G.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[G.jsxs(Be,{width:e,height:t,data:n,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),Array.from({length:R},(T,S)=>G.jsx(je,{group:0,index:S,yScale:"y",stroke:l!=null&&l[S]!=null?l[S]:`hsl(${S*137}, 60%, 50%)`,width:1},S))]}),G.jsxs("div",{ref:a,onPointerDown:v,onPointerMove:b,onPointerUp:L,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[G.jsx("div",{style:{position:"absolute",top:0,left:0,width:g,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:`${u[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),G.jsx("div",{style:{position:"absolute",top:0,left:g,width:w,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&&G.jsxs(G.Fragment,{children:[G.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"}}),G.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=F.useRef(e);n.current=e,F.useEffect(()=>{const s=o=>n.current(o);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Zn(e){const t=ee(),n=F.useRef(e);n.current=e,F.useEffect(()=>{const s=(o,i)=>n.current(o,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function Jn({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 u=(t+n)*r,c=t*r,h=l.top*r;for(let f=0;f<e.length;f++){const d=e[f];if(d==null)continue;const v=h+f*u;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(d.label,(l.left-6)*r,v+c/2);for(const b of d.segments){const L=V(b.start,a,l.width,l.left)*r,w=V(b.end,a,l.width,l.left)*r-L;w<=0||(i.fillStyle=b.color??"#4dabf7",i.fillRect(L,v,w,c),b.label!=null&&w>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(b.label,L+w/2,v+c/2,w-4*r)))}}i.restore()}),null}function Qn({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:o,lineWidth:i=1,paths:l,fillTo:r,className:a}){return G.jsx("div",{style:{pointerEvents:"none"},className:a,children:G.jsxs(Be,{width:t,height:n,data:e,children:[G.jsx(Te,{id:"x"}),G.jsx(Te,{id:"y"}),G.jsx(Ie,{scale:"x",show:!1}),G.jsx(Ie,{scale:"y",show:!1}),G.jsx(je,{group:0,index:0,yScale:"y",stroke:s,fill:o,width:i,paths:l,fillTo:r})]})})}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 es(e,t,n,s,o,i,l={}){const{ctx:r,plotBox:a}=e,u=V(s,t,a.width,a.left),c=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,u,c-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 ts(e){const t=F.useRef(e);return F.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 ns(e){const t=F.useRef(e);return F.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 ss(e){const t=F.useRef(e);return F.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 os(e){const t=F.useRef(e);return F.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]=F.useState(e),[r,a]=F.useState(!1),[u,c]=F.useState(0),h=F.useRef(0),f=F.useRef(0),d=F.useRef(0),v=F.useRef(new Map),b=F.useRef(0),L=F.useRef(n);L.current=n;const g=F.useCallback((T,S,...C)=>{let x=v.current.get(T);x==null&&(x={x:[],series:C.map(()=>[])},v.current.set(T,x)),x.x.push(...S);for(let I=0;I<C.length;I++){let D=x.series[I];D==null&&(D=[],x.series[I]=D),D.push(...C[I]??[])}b.current===0&&(b.current=requestAnimationFrame(()=>{b.current=0;const I=v.current;v.current=new Map;const D=L.current;l(m=>{const p=m.slice();for(const[M,{x:k,series:y}]of I){const A=p[M];if(A==null)continue;const z=A.x,H=Math.max(0,z.length+k.length-D),E=H>0?z.slice(H).concat(k):z.concat(k),$=A.series.map((W,j)=>{const X=W,N=y[j]??[];return H>0?X.slice(H).concat(N):X.concat(N)});p[M]={x:E,series:$}}return p})}))},[]),w=F.useCallback((T,...S)=>{g(0,T,...S)},[g]),P=F.useCallback(()=>{a(!0)},[]),R=F.useCallback(()=>{a(!1)},[]);return F.useEffect(()=>{if(!r){h.current!==0&&(cancelAnimationFrame(h.current),h.current=0);return}d.current=performance.now(),f.current=0;const T=S=>{f.current++;const C=S-d.current;C>=1e3&&(c(Math.round(f.current*1e3/C)),f.current=0,d.current=S),h.current=requestAnimationFrame(T)};return h.current=requestAnimationFrame(T),()=>{h.current!==0&&(cancelAnimationFrame(h.current),h.current=0)}},[r]),F.useEffect(()=>()=>{b.current!==0&&cancelAnimationFrame(b.current)},[]),F.useEffect(()=>{o&&a(!0)},[o]),{data:i,push:w,pushGroup:g,start:P,stop:R,running:r,fps:u}}function is(e){return(t,n,s,o,i,l,r,a,u,c,h,f,d)=>{const v=(d==null?void 0:d.align)??e??1,b=(d==null?void 0:d.spanGaps)??!1;if([u,c]=Ae(n,u,c),u===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const L=I=>f(V(I,s,i,r)),g=I=>f(V(I,o,l,a)),w=s.ori===_.Horizontal?Pe:Le,P={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},R=P.stroke;let T=!1;const S=h===K.Forward?u:c;let C=g(n[S]),x=L(t[S]);w(R,x,C);for(let I=S;I>=u&&I<=c;I+=h){const D=n[I];if(D==null){D===null&&!b&&(T=!0);continue}const m=L(t[I]),p=g(D);if(v===1)w(R,m,C);else if(v===-1)w(R,x,p);else{const M=f((x+m)/2);w(R,M,C),w(R,M,p)}w(R,m,p),C=p,x=m}{const I=P.fill=new Path2D(R),D=(d==null?void 0:d.fillTo)??o.min??0,m=g(D);let p=r,M=r+i;h===K.Backward&&([M,p]=[p,M]),w(I,M,m),w(I,p,m)}if(T){const I=Ve(t,n,u,c,h,L);P.gaps=I,P.clip=$e(I,s.ori,r,a,i,l)}return P}}function rs(){return(e,t,n,s,o,i,l,r,a,u,c,h,f)=>{const d=(f==null?void 0:f.barWidth)??.6,v=(f==null?void 0:f.barGap)??0,b=(f==null?void 0:f.barRadius)??0,L=(f==null?void 0:f.barGroupIdx)??0,g=(f==null?void 0:f.barGroupCount)??1,w=M=>h(V(M,n,o,l)),P=M=>h(V(M,s,i,r));let R=o;if(u>a){let M=1/0,k=-1;for(let y=a;y<=u;y++)if(t[y]!=null){if(k>=0){const A=e[y],z=e[k],H=Math.abs(w(A)-w(z));H<M&&(M=H)}k=y}M<1/0&&(R=M)}const T=R*(1-d),S=Math.max(0,T+v),C=Math.max(1,h(R-S)),x=g>1?Math.max(1,h(C/Math.max(1,g))):C,I=(f==null?void 0:f.fillTo)??s.min??0,D=P(I),m=new Path2D,p=n.ori===_.Horizontal;for(let M=c===K.Forward?a:u;M>=a&&M<=u;M+=c){const k=t[M];if(k==null)continue;const y=w(e[M]),A=P(k),z=g>1?(L-(g-1)/2)*x:0,H=h(y-x/2+z),E=Math.min(A,D),W=Math.max(A,D)-E;if(W!==0)if(b>0){const j=Math.min(b*x,W/2);as(m,p,H,E,x,W,j,k<I)}else p?m.rect(H,E,x,W):m.rect(E,H,W,x)}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 Ct(e){return(t,n,s,o,i,l,r,a,u,c,h,f,d)=>{const v=(d==null?void 0:d.spanGaps)??!1;if([u,c]=Ae(n,u,c),u===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const b=x=>f(V(x,s,i,r)),L=x=>f(V(x,o,l,a)),g=s.ori===_.Horizontal?Pe:Le,w=[],P=[];let R=!1;for(let x=h===K.Forward?u:c;x>=u&&x<=c;x+=h){const I=n[x];I!=null?(w.push(b(t[x])),P.push(L(I))):I===null&&!v&&(R=!0)}const T=s.ori===_.Horizontal,S=e(w,P,T,f),C={stroke:S??new Path2D,fill:null,clip:null,band:null,gaps:null};if(S!=null){const x=C.fill=new Path2D(S),I=(d==null?void 0:d.fillTo)??o.min??0,D=L(I);let m=r,p=r+i;h===K.Backward&&([p,m]=[m,p]),g(x,p,D),g(x,m,D)}if(R){const x=Ve(t,n,u,c,h,b);C.gaps=x,C.clip=$e(x,s.ori,r,a,i,l)}return C}}function cs(){return Ct(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),u=new Array(o-1),c=new Array(o-1),h=new Array(o-1);for(let f=0;f<o-1;f++)c[f]=(t[f+1]??0)-(t[f]??0),h[f]=(e[f+1]??0)-(e[f]??0),u[f]=h[f]!==0?(c[f]??0)/(h[f]??1):0;a[0]=u[0]??0;for(let f=1;f<o-1;f++){const d=u[f]??0,v=u[f-1]??0;if(d===0||v===0||v>0!=d>0)a[f]=0;else{const b=h[f]??1,L=h[f-1]??1;a[f]=3*(L+b)/((2*b+L)/v+(b+2*L)/d),isFinite(a[f]??0)||(a[f]=0)}}a[o-1]=u[o-2]??0;for(let f=0;f<o-1;f++){const d=h[f]??1,v=e[f]??0,b=t[f]??0,L=e[f+1]??0,g=t[f+1]??0,w=a[f]??0,P=a[f+1]??0,R=v+d/3,T=b+w*d/3,S=L-d/3,C=g-P*d/3;n?i.bezierCurveTo(R,T,S,C,L,g):i.bezierCurveTo(T,R,C,S,g,L)}return i};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=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),u=s(t[1]??0);return n?i.lineTo(a,u):i.lineTo(u,a),i}for(let a=0;a<o-1;a++){const u=a===0?0:a-1,c=e[u]??0,h=t[u]??0,f=e[a]??0,d=t[a]??0,v=e[a+1]??0,b=t[a+1]??0,L=a+2<o?e[a+2]??0:v,g=a+2<o?t[a+2]??0:b,w=Math.hypot(c-f,h-d),P=Math.hypot(f-v,d-b),R=Math.hypot(v-L,b-g),T=Math.sqrt(R),S=R,C=Math.sqrt(P),x=P,I=Math.sqrt(w),D=w,m=2*D+3*I*C+x,p=2*S+3*T*C+x,M=3*I*(I+C),k=3*T*(T+C);let y,A,z,H;if(M>0){const E=1/M;y=(-x*c+m*f+D*v)*E,A=(-x*h+m*d+D*b)*E}else y=f,A=d;if(k>0){const E=1/k;z=(S*f+p*v-x*L)*E,H=(S*d+p*b-x*g)*E}else z=v,H=b;n?i.bezierCurveTo(y,A,z,H,v,b):i.bezierCurveTo(A,y,H,z,b,v)}return i};function ds(e=4){return(t,n,s,o,i,l,r,a,u,c,h,f,d)=>{const v=P=>f(V(P,s,i,r)),b=P=>f(V(P,o,l,a)),L=e/2,g=new Path2D,w=s.ori===_.Horizontal;for(let P=h===K.Forward?u:c;P>=u&&P<=c;P+=h){const R=n[P];if(R==null)continue;const T=v(t[P]),S=b(R);w?(g.moveTo(T+L,S),g.arc(T,S,L,0,Math.PI*2)):(g.moveTo(S+L,T),g.arc(S,T,L,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:u,yScale:c,upColor:h="#26a69a",downColor:f="#ef5350",bodyWidth:d=.6,wickWidth:v=1}=e;if(u.min==null||u.max==null||c.min==null||c.max==null)return;const b=o.length;if(b===0)return;const g=Math.max(2,n.width/b*d)*s/2;t.save();for(let w=0;w<b;w++){const P=o[w],R=i[w],T=l[w],S=r[w],C=a[w];if(P==null||R==null||T==null||S==null||C==null)continue;const x=V(P,u,n.width,n.left)*s,I=V(R,c,n.height,n.top)*s,D=V(T,c,n.height,n.top)*s,m=V(S,c,n.height,n.top)*s,p=V(C,c,n.height,n.top)*s,k=C>=R?h:f;t.strokeStyle=k,t.lineWidth=v*s,t.beginPath(),t.moveTo(x,D),t.lineTo(x,m),t.stroke();const y=Math.min(I,p),A=Math.abs(p-I);t.fillStyle=k,t.fillRect(x-g,y,g*2,Math.max(A,1*s))}t.restore()}}function ps(e,t,n=0){const s=t??e.series.map((u,c)=>c),o=e.x.length,i=[],l=new Float64Array(o);for(let u=0;u<s.length;u++){const c=s[u];if(c==null)continue;const h=e.series[c];if(h==null)continue;const f=new Array(o);for(let d=0;d<o;d++){const v=h[d];v!=null?(l[d]=l[d]+v,f[d]=l[d]):f[d]=null}i.push(f)}const r=[];for(let u=0;u<e.series.length;u++){const c=s.indexOf(u),h=c>=0?i[c]:void 0;h!=null?r.push(h):r.push(e.series[u]??[])}const a=[];for(let u=s.length-1;u>0;u--){const c=s[u],h=s[u-1];c!=null&&h!=null&&a.push({group:n,series:[c,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 u=i[a];if(u==null)continue;const c=s.get(u);c!=null&&(r[c]=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?Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):Q(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Ms(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 bs(e){const{tz:t,...n}=e??{};return s=>s.map(o=>Q(o,n,t))}function Ss(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 ys(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 ks(e,t){const n=Tt(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=jn;exports.Chart=Be;exports.Direction=K;exports.Distribution=U;exports.HLine=ts;exports.Legend=Nn;exports.Orientation=_;exports.Region=ss;exports.Scale=Te;exports.Series=je;exports.Side=Y;exports.SortOrder=me;exports.Sparkline=Qn;exports.Timeline=Jn;exports.Tooltip=On;exports.VLine=ns;exports.ZoomRanger=qn;exports.alignData=ms;exports.bars=rs;exports.catmullRom=fs;exports.drawCandlesticks=gs;exports.drawHLine=St;exports.drawLabel=es;exports.drawRegion=kt;exports.drawVLine=yt;exports.fadeGradient=ys;exports.fmtCompact=ws;exports.fmtDateStr=bs;exports.fmtHourMin=vs;exports.fmtLabels=Ss;exports.fmtMonthName=Ms;exports.fmtSuffix=xs;exports.linear=vt;exports.monotoneCubic=cs;exports.palette=Cs;exports.points=ds;exports.posToVal=ne;exports.sideOrientation=de;exports.stackGroup=ps;exports.stepped=is;exports.useChart=ee;exports.useCursorDrawHook=Zn;exports.useDrawHook=ve;exports.useStreamingData=ls;exports.valToPos=V;exports.withAlpha=ks;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("react/jsx-runtime"),A=require("react");var Y=(e=>(e[e.Top=0]="Top",e[e.Right=1]="Right",e[e.Bottom=2]="Bottom",e[e.Left=3]="Left",e))(Y||{}),B=(e=>(e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e))(B||{}),K=(e=>(e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward",e))(K||{}),N=(e=>(e[e.Linear=1]="Linear",e[e.Ordinal=2]="Ordinal",e[e.Log=3]="Log",e[e.Asinh=4]="Asinh",e))(N||{}),xe=(e=>(e[e.Ascending=1]="Ascending",e[e.Descending=-1]="Descending",e[e.Unsorted=0]="Unsorted",e))(xe||{});function ge(e){return e%2}var te=(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))(te||{});const Z=Math,ze=Z.PI,de=Z.abs,oe=Z.floor,X=Z.round,Ce=Z.ceil,Ge=Z.min,be=Z.max,we=Z.pow,Ze=Z.sign,ne=Z.log10,Se=Z.log2,Vt=(e,t=1)=>Z.sinh(e)*t,We=(e,t=1)=>Z.asinh(e/t),O=1/0,wt=Number.isInteger;function Fe(e,t){return e[t]??0}function re(e,t,n=0,s=t.length-1){let l;const i=s<=2147483647;for(;s-n>1;)l=i?n+s>>1:oe((n+s)/2),Fe(t,l)<e?n=l:s=l;return e-Fe(t,n)<=Fe(t,s)-e?n:s}const xt=e=>e!=null,bt=e=>e!=null&&e>0;function vt(e){return(t,n,s)=>{let l=-1,i=-1;for(let o=n;o<=s;o++)if(e(t[o])){l=o;break}for(let o=s;o>=n;o--)if(e(t[o])){i=o;break}return[l,i]}}const Pe=vt(xt),St=vt(bt);function jt(e,t,n,s=xe.Unsorted,l=!1){const i=l?St:Pe,o=l?bt:xt,[r,a]=i(e,t,n);let f=e[r]??O,u=e[r]??-O;if(r>-1)if(s===xe.Ascending)f=e[r]??O,u=e[a]??-O;else if(s===xe.Descending)f=e[a]??O,u=e[r]??-O;else for(let d=r;d<=a;d++){const c=e[d];c!=null&&o(c)&&(c<f?f=c:c>u&&(u=c))}return[f,u]}function ae(e,t=0){if(wt(e))return e;const n=10**t,s=e*n*(1+Number.EPSILON);return X(s)/n}const ve=new Map;function Bt(e){return(String(e).split(".")[1]??"").length}const Xt=/\.\d*?(?=9{6,}|0{6,})/gm;function ke(e){if(wt(e)||ve.has(e))return e;const t=`${e}`,n=t.match(Xt);if(n==null)return e;const s=n[0].length-1;if(t.indexOf("e-")!==-1){const l=t.split("e"),i=l[0]??"0",o=l[1]??"0";return+`${ke(+i)}e${o}`}return ae(e,s)}function Ve(e,t,n=!0){return n?ke(Ce(ke(e/t))*t):Ce(e/t)*t}function Mt(e,t,n=!0){return n?ke(oe(ke(e/t))*t):oe(e/t)*t}function yt(e,t,n,s){const l=[],i=s.map(Bt);for(let o=t;o<n;o++){const r=de(o);for(let a=0;a<s.length;a++){const f=s[a]??0,u=i[a]??0,d=+`${f}e${o}`,c=(o>=0?0:r)+(o>=u?0:u),h=d;l.push(h),ve.set(h,c)}}return l}function q(e,t,n){return Ge(be(e,t),n)}const Yt=new Intl.NumberFormat,Ct=e=>Yt.format(e);function Je(e,t,n){for(;t<=n;){if(e[t]!=null)return!0;t++}return!1}const Kt=.1,le={mode:3,pad:Kt,soft:null},ye={pad:0,soft:null,mode:0},Ut={min:ye,max:ye};function _e(e,t,n,s){let l;typeof n=="number"?(ye.pad=n,ye.soft=null,ye.mode=0,l=Ut):l=n;const i=l.min,o=l.max,r=i.pad,a=o.pad,f=i.hard??-O,u=o.hard??O,d=i.soft??O,c=o.soft??-O,h=i.mode,m=o.mode;let v=t-e;const C=ne(v),g=be(de(e),de(t)),y=ne(g),L=de(y-C);(v<1e-24||L>10)&&(v=0,(e===0||t===0)&&(v=1e-24));const T=v||g||1e3,E=ne(T),D=we(10,oe(E)),S=T*(v===0?e===0?.1:1:r),M=ae(Mt(e-S,D/10),24),P=h===1||h===3&&M<=d||h===2&&M>=d,R=e>=d&&P?d:O,p=be(f,M<R&&e>=R?R:Ge(R,M)),w=T*(v===0?t===0?.1:1:a),x=ae(Ve(t+w,D/10),24),b=m===1||m===3&&x>=c||m===2&&x<=c,k=t<=c&&b?c:-O,I=Ge(u,x>k&&t<=k?k:be(k,x));return p===I&&p===0?[-1,1]:[p,I]}function Nt(e,t,n,s){n===2&&(s=!0);const l=Ze(e),i=Ze(t);e===t&&(l===-1?(e*=n,t/=n):(e/=n,t*=n));const o=n===10?ne:Se,r=l===1?oe:Ce,a=i===1?Ce:oe,f=o(de(e)),u=o(de(t)),d=r(f),c=a(u);let h=we(n,d),m=we(n,c);return n===10&&(d<0&&(h=ae(h,-d)),c<0&&(m=ae(m,-c))),s?(e=h*l,t=m*i):(e=Mt(e,we(n,oe(f)),!1),t=Ve(t,we(n,oe(u)),!1)),[e,t]}function Qe(e){return(ne((e^e>>31)-(e>>31))|0)+1}function Ot(e,t,n,s,l){const i=be(Qe(e),Qe(t)),o=t-e;let r=be(0,re(l/s*o,n)-1);do{const a=n[r]??0,f=s*a/o;if(f>=l*.9&&i+(a<5?ve.get(a)??0:0)<=17)return[a,f]}while(++r<n.length);return[0,0]}function qt(e){return{id:e.id,min:e.min??null,max:e.max??null,distr:e.distr??N.Linear,log:e.log??10,asinh:e.asinh??1,ori:e.ori??(e.id==="x"?B.Horizontal:B.Vertical),dir:e.dir??K.Forward,time:e.time??!1,auto:e.auto??!0,range:e.range??null,_discrete:!1,_cfgMin:e.min??null,_cfgMax:e.max??null,_min:null,_max:null}}function fe(e){e._min=null,e._max=null}function kt(e){if(e._min!=null)return e._min;const{min:t,distr:n}=e;if(t==null)return 0;if(n===N.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": min value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._min=(e.log===10?ne:Se)(s)}else n===N.Asinh?e._min=We(t,e.asinh):e._min=t;return e._min}function Tt(e){if(e._max!=null)return e._max;const{max:t,distr:n}=e;if(t==null)return 0;if(n===N.Log){t<=0&&console.warn(`[uPlot+] Log scale "${e.id}": max value ${t} <= 0, clamping to 1e-10`);const s=t>0?t:1e-10;e._max=(e.log===10?ne:Se)(s)}else n===N.Asinh?e._max=We(t,e.asinh):e._max=t;return e._max}function Zt(e,t){if(t.min==null||t.max==null)return 0;const n=kt(t),l=Tt(t)-n;if(l===0)return 0;const{distr:i}=t;if(i===N.Log){const o=t.log===10?ne:Se,r=e>0?e:1e-10;return(o(r)-n)/l}return i===N.Asinh?(We(e,t.asinh)-n)/l:(e-n)/l}function Jt(e,t){if(t.min==null||t.max==null)return 0;const n=kt(t),s=Tt(t);if(s===n)return t.min;const{distr:l}=t;return l===N.Log?Math.pow(t.log,n+e*(s-n)):l===N.Asinh?Vt(n+e*(s-n),t.asinh):n+e*(s-n)}function j(e,t,n,s){const l=Zt(e,t);let i;return t.ori===B.Horizontal?i=t.dir===K.Forward?l:1-l:i=t.dir===K.Forward?1-l:l,s+i*n}function se(e,t,n,s){if(n===0)return t.min??0;let l=(e-s)/n;return t.ori===B.Horizontal?t.dir===K.Backward&&(l=1-l):t.dir!==K.Backward&&(l=1-l),Jt(l,t)}class Qt{constructor(){this.scales=new Map,this.groupXScales=new Map}addScale(t){this.scales.set(t.id,qt(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 l=this.scales.get(t);l&&(l.min=n,l.max=s,fe(l))}autoRangeX(t){var s,l,i,o,r,a;const n=new Map;for(const[f,u]of this.groupXScales){const d=this.scales.get(u);if(!d||!d.auto)continue;const c=t[f];if(!c||c.x.length===0)continue;const h=c.x[0],m=c.x[c.x.length-1];if(h==null||m==null)continue;const v=n.get(u);v?(v.dataMin=Math.min(v.dataMin,h),v.dataMax=Math.max(v.dataMax,m),v.groups.push(f)):n.set(u,{dataMin:h,dataMax:m,groups:[f]})}for(const[f,{dataMin:u,dataMax:d,groups:c}]of n){const h=this.scales.get(f);if(!h)continue;let m=!0,v=O;for(const C of c){const g=t[C];if(g){for(let y=0;y<g.x.length;y++)if(Number.isInteger(g.x[y])||(m=!1),y>0){const L=g.x[y]-g.x[y-1];L>0&&L<v&&(v=L)}}}if(h._discrete=m,h.range){const[C,g]=_e(u,d,{min:{pad:((s=h.range.min)==null?void 0:s.pad)??0,soft:((l=h.range.min)==null?void 0:l.soft)??null,mode:((i=h.range.min)==null?void 0:i.mode)??0},max:{pad:((o=h.range.max)==null?void 0:o.pad)??0,soft:((r=h.range.max)==null?void 0:r.soft)??null,mode:((a=h.range.max)==null?void 0:a.mode)??0}});h.min=C,h.max=g}else if(u===d)[h.min,h.max]=_e(u,d,{min:{pad:.1,soft:null,mode:0},max:{pad:.1,soft:null,mode:0}});else if(v<O){const C=v/2;h.min=u-C,h.max=d+C}else h.min=u,h.max=d;h._cfgMin!=null&&(h.min=h._cfgMin),h._cfgMax!=null&&(h.max=h._cfgMax),fe(h)}}autoRange(t,n,s){var o,r,a,f,u,d;const l=new Map,i=new Map;for(const{group:c,index:h,yScale:m}of n){const v=t[c];if(!v)continue;const C=v.series[h];if(!C||C.length===0)continue;const g=s.windows.get(c),y=g?g[0]:0,L=g?g[1]:C.length-1,T=this.scales.get(m),E=(T==null?void 0:T.distr)===N.Log,[D,S]=s.getCachedMinMax(c,h,y,L,0,E),M=l.get(m),P=i.get(m);l.set(m,M!=null?Math.min(M,D):D),i.set(m,P!=null?Math.max(P,S):S)}for(const[c,h]of l){const m=this.scales.get(c);if(!m||!m.auto)continue;const v=i.get(c)??-O;if(h===O)continue;let C,g;if(m.distr===N.Log)[C,g]=Nt(h,v,m.log,!1);else{const y=m.range??{min:le,max:le};[C,g]=_e(h,v,{min:{pad:((o=y.min)==null?void 0:o.pad)??le.pad,soft:((r=y.min)==null?void 0:r.soft)??le.soft,mode:((a=y.min)==null?void 0:a.mode)??le.mode},max:{pad:((f=y.max)==null?void 0:f.pad)??le.pad,soft:((u=y.max)==null?void 0:u.soft)??le.soft,mode:((d=y.max)==null?void 0:d.mode)??le.mode}})}m._cfgMin!=null&&(C=m._cfgMin),m._cfgMax!=null&&(g=m._cfgMax),m.min=C,m.max=g,fe(m)}}}const en=1024;class tn{constructor(t,n=en){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:l,len:i}=this;for(let o=0;o<s;o++){const r=o*n,a=Math.min(r+n,i);let f=1/0,u=-1/0;for(let d=r;d<a;d++){const c=t[d];c!=null&&(c<f&&(f=c),c>u&&(u=c))}l[o*2]=f,l[o*2+1]=u}}rangeMinMax(t,n){const{data:s,blockSize:l,blocks:i}=this;let o=1/0,r=-1/0;const a=Math.floor(t/l),f=Math.floor(n/l);if(a===f){for(let c=t;c<=n;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}return[o,r]}const u=(a+1)*l-1;for(let c=t;c<=u;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}for(let c=a+1;c<f;c++){const h=i[c*2]??1/0,m=i[c*2+1]??-1/0;h<o&&(o=h),m>r&&(r=m)}const d=f*l;for(let c=d;c<=n;c++){const h=s[c];h!=null&&(h<o&&(o=h),h>r&&(r=h))}return[o,r]}updateBlock(t){const{data:n,blockSize:s,blocks:l,len:i}=this;if(t>=this.nBlocks)return;const o=t*s,r=Math.min(o+s,i);let a=1/0,f=-1/0;for(let u=o;u<r;u++){const d=n[u];d!=null&&(d<a&&(a=d),d>f&&(f=d))}l[t*2]=a,l[t*2+1]=f}grow(t){const n=this.nBlocks;if(this.len=t,this.nBlocks=Math.ceil(t/this.blockSize),this.nBlocks>n){const l=new Float64Array(this.nBlocks*2);l.set(this.blocks),this.blocks=l}const s=Math.max(0,n-1);for(let l=s;l<this.nBlocks;l++)this.updateBlock(l)}setData(t){this.data=t}}class nn{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 l=this.blockTrees.get(s);if(l)return l;const i=this.data[t];if(!i)return;const o=i.series[n];if(!(!o||o.length===0))return l=new tn(o),this.blockTrees.set(s,l),l}updateWindows(t){var s;let n=!1;for(let l=0;l<this.data.length;l++){const i=this.data[l],o=t(l),r=this.windows.get(l);let a,f;if(!i||!o||o.min==null||o.max==null)a=0,f=Math.max(0,((i==null?void 0:i.x.length)??1)-1);else{const u=i.x;if(u.length===0)a=0,f=0;else{a=re(o.min,u),f=re(o.max,u);const d=u[a],c=u[f];a>0&&d!=null&&d>o.min&&a--,f<u.length-1&&c!=null&&c<o.max&&f++}}(!r||r[0]!==a||r[1]!==f)&&(n=!0,(s=this.minMaxCache.get(l))==null||s.clear()),this.windows.set(l,[a,f])}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,l,i,o){let r=this.minMaxCache.get(t);const a=`${n}:${s}:${l}`;if(r){const h=r.get(a);if(h!=null)return h}else r=new Map,this.minMaxCache.set(t,r);const f=this.data[t];if(!f)return[1/0,-1/0];const u=f.series[n];if(!u||u.length===0)return[1/0,-1/0];let d;const c=!o&&i===xe.Unsorted?this.getOrBuildTree(t,n):void 0;return c?d=c.rangeMinMax(s,l):d=jt(u,s,l,i,o),r.set(a,d),d}getBlockTree(t,n){return this.getOrBuildTree(t,n)}appendData(t,n,s){var o;const l=this.data[t];if(!l)return;let i;Array.isArray(l.x)?i=l.x:(i=Array.from(l.x),l.x=i);for(let r=0;r<n.length;r++){const a=n[r];a!=null&&i.push(a)}for(let r=0;r<l.series.length;r++){let a=l.series[r];if(!a)continue;Array.isArray(a)||(a=Array.from(a),l.series[r]=a);const f=s[r];if(f){const d=a;for(let c=0;c<f.length;c++)d.push(f[c]??null)}const u=this.blockTrees.get(`${t}:${r}`);u&&(u.setData(a),u.grow(a.length))}(o=this.minMaxCache.get(t))==null||o.clear()}static toTypedX(t){for(const n of t)Array.isArray(n.x)&&(n.x=Float64Array.from(n.x));return t}}class sn{constructor(){this.state={left:-10,top:-10,activeGroup:-1,activeSeriesIdx:-1,activeDataIdx:-1},this._groupedConfigs=new Map,this._groupedConfigsSource=null}getGroupedConfigs(t){if(this._groupedConfigsSource!==t){this._groupedConfigsSource=t,this._groupedConfigs.clear();for(const n of t){if(n.show===!1)continue;let s=this._groupedConfigs.get(n.group);s==null&&(s=[],this._groupedConfigs.set(n.group,s)),s.push(n)}}return this._groupedConfigs}invalidateGroupedConfigs(){this._groupedConfigsSource=null}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,l,i,o,r,a){this.state.left=t,this.state.top=n;let f=1/0,u=-1,d=-1,c=-1;const h=this.getGroupedConfigs(i);for(let m=0;m<l.length;m++){const v=l[m];if(v==null)continue;const C=v.x;if(C.length===0)continue;const g=a(m);if(g==null)continue;const y=o(g);if(y==null||y.min==null||y.max==null)continue;const[L,T]=r(m),E=s.width,D=s.left,S=se(t+D,y,E,D),M=re(S,C,L,T),P=[M];M>L&&P.push(M-1),M<T&&P.push(M+1);const R=new Map;for(const p of P){const w=C[p];if(w==null)continue;const x=j(w,y,E,D);for(const b of h.get(m)??[]){const k=v.series[b.index];if(k==null)continue;const I=k[p];if(I==null)continue;let z=R.get(b.yScale);if(z==null&&!R.has(b.yScale)&&(z=o(b.yScale),R.set(b.yScale,z)),z==null||z.min==null||z.max==null)continue;const _=s.height,F=s.top,H=j(I,z,_,F),G=t+D-x,$=n+F-H,V=G*G+$*$;if(V<f&&(f=V,u=m,d=b.index,c=p,V===0))break}if(f===0)break}}this.state.activeGroup=u,this.state.activeSeriesIdx=d,this.state.activeDataIdx=c}syncToValue(t,n){const s=n.dataStore.data;if(s.length===0)return;const l=s[0];if(l==null)return;const i=n.scaleManager.getGroupXScaleKey(0);if(i==null)return;const o=n.scaleManager.getScale(i);if(o==null||o.min==null||o.max==null)return;const[r,a]=n.dataStore.getWindow(0),f=re(t,l.x,r,a),u=l.x[f];if(u==null)return;const d=j(u,o,n.plotBox.width,n.plotBox.left);this.state.left=d-n.plotBox.left,this.state.activeGroup=0,this.state.activeDataIdx=f;let c=0,h=n.plotBox.height/2;for(const m of n.seriesConfigs){if(m.group!==0||m.show===!1)continue;const v=l.series[m.index];if(v==null)continue;const C=v[f];if(C==null)continue;const g=n.scaleManager.getScale(m.yScale);if(!(g==null||g.min==null||g.max==null)){h=j(C,g,n.plotBox.height,n.plotBox.top)-n.plotBox.top,c=m.index;break}}this.state.top=h,this.state.activeSeriesIdx=c}}class on{constructor(){this.flags=te.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=te.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=te.None}}function Re(e,t,n){e.lineTo(t,n)}function De(e,t,n){e.lineTo(n,t)}function je(e,t,n,s,l,i){const o=[];let r=-1;const a=l===K.Forward?n:s,f=l===K.Forward?s:n,u=l;for(let d=a;l===K.Forward?d<=f:d>=f;d+=u)if(t[d]===null||t[d]===void 0){if(r===-1){const c=q(d-l,n,s);r=i(e[c])}}else r!==-1&&(o.push([r,i(e[d])]),r=-1);return r!==-1&&o.push([r,i(e[s])]),o}function Be(e,t,n,s,l,i){const o=new Path2D;let r=t===B.Horizontal?n:s;const a=t===B.Horizontal?n+l:s+i,f=t===B.Horizontal?s:n,u=t===B.Horizontal?i:l;for(const[d,c]of e)d>r&&(t===B.Horizontal?o.rect(r,f,d-r,u):o.rect(f,r,u,d-r)),r=c;return r<a&&(t===B.Horizontal?o.rect(r,f,a-r,u):o.rect(f,r,u,a-r)),o}function It(e){return(t,n,s,l,i,o)=>{s!==l&&(i!==s&&o!==s&&e(t,n,s),i!==l&&o!==l&&e(t,n,l),e(t,n,o))}}const ln=It(Re),rn=It(De);function At(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.spanGaps)??!1;if([a,f]=(s.distr===N.Log?St:Pe)(t,a,f),a===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=S=>d(j(S,n,l,o)),C=S=>d(j(S,s,i,r));let g,y;n.ori===B.Horizontal?(g=Re,y=ln):(g=De,y=rn);const L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=L.stroke;let E=!1;if(f-a>=l*4){const S=I=>se(I,n,l,o);let M=null,P=0,R=0,p=0,w=v(e[u===K.Forward?a:f]);const x=v(e[a]),b=v(e[f]);let k=S(u===K.Forward?x+1:b-1);for(let I=u===K.Forward?a:f;I>=a&&I<=f;I+=u){const z=e[I],F=(u===K.Forward?z<k:z>k)?w:v(z),H=t[I];F===w?H!=null?(p=H,M==null?(g(T,F,C(p)),R=M=P=p):p<M?M=p:p>P&&(P=p)):H===null&&!h&&(E=!0):(M!=null&&y(T,w,C(M),C(P),C(R),C(p)),H!=null?(p=H,g(T,F,C(p)),M=P=R=p):(M=null,P=0,H===null&&!h&&(E=!0)),w=F,k=S(w+u))}M!=null&&(M!==P?y(T,w,C(M),C(P),C(R),C(p)):g(T,w,C(p)))}else for(let S=u===K.Forward?a:f;S>=a&&S<=f;S+=u){const M=t[S];M===null&&!h?E=!0:M!=null&&g(T,v(e[S]),C(M))}{const S=L.fill=new Path2D(T),M=(c==null?void 0:c.fillTo)??s.min??0,P=C(M);let R=o,p=o+l;u===K.Backward&&([p,R]=[R,p]),g(S,p,P),g(S,R,P)}if(E){const S=je(e,t,a,f,u,v);L.gaps=S,L.clip=Be(S,n.ori,o,r,l,i)}return L}}const et=new WeakMap;function tt(e,t,n){return typeof t=="string"?t:an(e,t,n)}function an(e,t,n){const s=et.get(t);if(s!=null&&s.left===n.left&&s.top===n.top&&s.width===n.width&&s.height===n.height)return s.grad;const l=e.createLinearGradient(0,n.top,0,n.top+n.height);for(const[i,o]of t.stops)l.addColorStop(i,o);return et.set(t,{grad:l,left:n.left,top:n.top,width:n.width,height:n.height}),l}function cn(e,t,n,s,l){if(t.show===!1)return;const i=t.alpha??1;e.save(),i<1&&(e.globalAlpha=i),n.clip&&e.clip(n.clip);const o=l??{left:0,top:0,width:e.canvas.width/s,height:e.canvas.height/s};if(t.fill&&n.fill&&(e.fillStyle=tt(e,t.fill,o),e.fill(n.fill)),t.stroke){const r=(t.width??1)*s;e.strokeStyle=tt(e,t.stroke,o),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,f=r%2/2;a===1&&f>0&&e.translate(f,f),e.stroke(n.stroke)}e.restore()}const un=At(),nt=64;class fn{constructor(){this.ctx=null,this.pxRatio=1,this.pathCache=new Map,this.pathCacheSize=0,this.bandCache=new Map,this.scaleStamp="",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 l=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(l,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}checkScaleStamp(t){let n="";const s=new Set;for(const l of t)for(const i of[l.xScale,l.yScale])s.has(i.id)||(s.add(i.id),n+=`${i.id}:${i.min}:${i.max};`);n!==this.scaleStamp&&(this.scaleStamp!==""&&this.clearCache(),this.scaleStamp=n)}windowKey(t,n){return`${t}:${n}`}getCachedPaths(t,n,s,l){const i=this.pathCache.get(t);if(i==null)return;const o=i.get(n);if(o==null)return;const r=this.windowKey(s,l);let a=o.get(r);if(a==null)for(const[f,u]of o){const d=f.indexOf(":"),c=+f.slice(0,d),h=+f.slice(d+1);if(c<=s&&h>=l){a=u;const m=this.lruMap.get(this.lruKey(t,n,f));m!=null&&m!==this.lruTail&&(this.lruUnlink(m),this.lruAppend(m));break}}else{const f=this.lruMap.get(this.lruKey(t,n,r));f!=null&&f!==this.lruTail&&(this.lruUnlink(f),this.lruAppend(f))}return a}setCachedPaths(t,n,s,l,i){if(this.pathCacheSize>=nt){const u=nt>>2;let d=this.lruHead;for(let c=0;c<u&&d!=null;c++){const h=d.next,m=this.pathCache.get(d.group);if(m!=null){const v=m.get(d.index);v!=null&&(v.delete(d.key),this.pathCacheSize--,v.size===0&&m.delete(d.index),m.size===0&&this.pathCache.delete(d.group))}this.lruMap.delete(this.lruKey(d.group,d.index,d.key)),d=h}this.lruHead=d,d!=null?d.prev=null:this.lruTail=null}let o=this.pathCache.get(t);o==null&&(o=new Map,this.pathCache.set(t,o));let r=o.get(n);r==null&&(r=new Map,o.set(n,r));const a=this.windowKey(s,l),f=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(f,u)}r.set(a,i)}invalidateSeries(t,n){const s=this.pathCache.get(t);if(s==null)return;const l=s.get(n);if(l!=null){this.pathCacheSize-=l.size;for(const i of l.keys()){const o=this.lruKey(t,n,i),r=this.lruMap.get(o);r!=null&&(this.lruUnlink(r),this.lruMap.delete(o))}s.delete(n)}}clearGroupCache(t){const n=this.pathCache.get(t);if(n!=null){for(const[s,l]of n.entries()){this.pathCacheSize-=l.size;for(const i of l.keys()){const o=this.lruKey(t,s,i),r=this.lruMap.get(o);r!=null&&(this.lruUnlink(r),this.lruMap.delete(o))}}this.pathCache.delete(t)}for(const s of this.bandCache.keys())s.startsWith(`${t}:`)&&this.bandCache.delete(s);this.invalidateSnapshot()}clearCache(){this.pathCache.clear(),this.pathCacheSize=0,this.lruHead=null,this.lruTail=null,this.lruMap.clear(),this.bandCache.clear(),this.invalidateSnapshot()}bandKey(t,n,s,l,i){return`${t}:${n}:${s}:${l}:${i}`}getCachedBandPath(t,n,s,l,i){return this.bandCache.get(this.bandKey(t,n,s,l,i))}setCachedBandPath(t,n,s,l,i,o){this.bandCache.set(this.bandKey(t,n,s,l,i),o)}drawSeries(t,n,s){const l=this.ctx;if(l==null||t.config.show===!1)return;const i=t.config.group,o=t.config.index,[r,a]=t.window;let f=this.getCachedPaths(i,o,r,a);if(f==null){const u=t.config.paths??un,d=t.xScale.dir,c=T=>X(T),h=a-r,m=Math.max(1,Math.ceil(h*.1)),v=t.dataX.length,C=Math.max(0,r-m),g=Math.min(v-1,a+m),y=t.config.fillTo,L=typeof y=="function"?y(t.yScale.min??0,t.yScale.max??0):y;f=u(t.dataX,t.dataY,t.xScale,t.yScale,n.width,n.height,n.left,n.top,C,g,d,c,{fillTo:L,spanGaps:t.config.spanGaps}),this.setCachedPaths(i,o,C,g,f)}cn(l,t.config,f,s,n)}draw(t,n,s,l){const i=this.ctx;if(i==null)return;const o=this.pxRatio;i.clearRect(0,0,t*o,n*o),i.save(),i.scale(o,o),i.beginPath(),i.rect(s.left,s.top,s.width,s.height),i.clip();for(const r of l)this.drawSeries(r,s,1);i.restore(),this.resetPropertyCache()}}const Lt=[1,2,2.5,5],hn=yt(10,-32,0,Lt),dn=yt(10,0,32,Lt),ce=hn.concat(dn);function gn(e,t,n,s,l){if(n<=0||t<e)return[];const i=[],o=ve.get(n)??0,r=l?Math.ceil(e/n)*n:ae(Ve(e,n),o);for(let a=r;a<=t;a=ae(a+n,o))i.push(Object.is(a,-0)?0:a);return i}function st(e){return e.map(t=>Ct(t))}function pn(e,t,n){if(e<=0||t<=0||e>=t)return[];const s=[],i=oe((n===10?ne:Se)(e));let o=we(n,i);n===10&&(o=ce[re(o,ce)]??o);let r=o,a=o*n;n===10&&(a=ce[re(a,ce)]??a);let f=0;do{if(r>=e&&s.push(r),r=r+o,n===10&&!ve.has(r)){const u=ve.get(o)??0;r=ae(r,u)}r>=a*(1-1e-10)&&(o=r,a=o*n,n===10&&(a=ce[re(a,ce)]??a))}while(r<=t&&++f<1e4);return s}function mn(e,t){const n=t===10?ne:Se;return e.map(s=>{if(s===0)return!0;if(s<0)return!1;const l=n(s);return de(l-Math.round(l))<1e-10})}const wn=7,xn=50,bn=16;function vn(e,t){const s=Ct(Math.max(Math.abs(e),Math.abs(t))).length*wn;return Math.max(xn,s+bn)}function Sn(e,t,n,s){if(s<=0)return[0,0];const l=ge(e.side)===B.Vertical,i=e.space??(l?30:vn(t,n)),o=e.incrs??ce;return Ot(t,n,o,s,i)}const Mn=50;function yn(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,l=e.gap??5,i=12;if(ge(e.side)===B.Vertical&&t!=null){let f=0;for(const d of t)d.length>f&&(f=d.length);const u=f*7;return Math.max(50,s+l+u+4)}return Math.max(50,s+l+i+3)}function Cn(e){return{config:e,_show:e.show!==!1,_size:e.size??Mn,_pos:0,_lpos:0,_splits:null,_values:null,_incr:0,_space:0,_rotate:0}}const me=60,ue=3600,ie=86400,kn=604800,he=2592e3,Te=31536e3,Tn=[1,5,10,15,30,me,5*me,10*me,15*me,30*me,ue,2*ue,3*ue,4*ue,6*ue,12*ue,ie,2*ie,3*ie,7*ie,14*ie,he,2*he,3*he,6*he,Te];function In(e,t,n,s){const l=[];if(n<=0||e>=t)return l;let i;if(n>=Te){const o=new Date(e*1e3);for(o.setUTCMonth(0,1),o.setUTCHours(0,0,0,0),i=o.getTime()/1e3,i<e&&(o.setUTCFullYear(o.getUTCFullYear()+1),i=o.getTime()/1e3);i<=t;)l.push(i),o.setUTCFullYear(o.getUTCFullYear()+Math.round(n/Te)),i=o.getTime()/1e3;return l}if(n>=he){const o=new Date(e*1e3);o.setUTCDate(1),o.setUTCHours(0,0,0,0),i=o.getTime()/1e3;const r=Math.max(1,Math.round(n/he));if(i<e&&(o.setUTCMonth(o.getUTCMonth()+1),i=o.getTime()/1e3),r>1){const a=o.getUTCMonth(),f=Math.ceil((a+1)/r)*r;o.setUTCMonth(f-1),i=o.getTime()/1e3}for(;i<=t;)l.push(i),o.setUTCMonth(o.getUTCMonth()+r),i=o.getTime()/1e3;return l}if(n>=ie){const o=new Date(e*1e3);o.setUTCHours(0,0,0,0),i=o.getTime()/1e3,i<e&&(i+=ie)}else i=Math.ceil(e/n)*n;for(let o=0;;o++){const r=i+o*n;if(r>t)break;l.push(r)}return l}const ot=new Map;function An(e,t){const n=JSON.stringify(e)+(t??"");let s=ot.get(n);return s==null&&(s=new Intl.DateTimeFormat(void 0,{...e,timeZone:t}),ot.set(n,s)),s}function ee(e,t,n){const s=new Date(e*1e3);return An(t,n).format(s)}function Ln(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function Pn(e,t){return ee(e,{year:"numeric",month:"2-digit",day:"2-digit"},t)}function Rn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1},t)}function Dn(e,t){return ee(e,{hour:"2-digit",minute:"2-digit",hour12:!1},t)}function zn(e,t){return ee(e,{month:"short",day:"numeric"},t)}function Fn(e,t){return ee(e,{year:"numeric"},t)}function _n(e,t){return ee(e,{year:"numeric",month:"short"},t)}function En(e,t,n){let s;return t>=Te?s=Fn:t>=he?s=_n:t>=kn?s=Pn:t>=ie?s=zn:t>=ue?s=Dn:t>=me?s=Rn:s=Ln,e.map(l=>s(l,n))}function Hn(e,t,n,s,l){const i=t-e;if(i<=0||s<=0)return[0,0];for(const r of n){const a=i/r,f=s/a;if(f>=l)return[r,f]}const o=n[n.length-1]??Te;return[o,s/(i/o)]}const Gn=3;function $n(e,t,n,s,l){let i=!0;for(const o of e){const r=o.config;if(r.show===!1)continue;const a=t(r.scale);if(!a||a.min==null||a.max==null){o._show&&(i=!1,o._show=!1);continue}else o._show||(i=!1,o._show=!0);const f=r.side,d=ge(f)===B.Horizontal?n:s,{min:c,max:h}=a;let m,v;if(a.time){const g=r.space??80;[m,v]=Hn(c,h,Tn,d,g)}else[m,v]=Sn(r,c,h,d);if(a._discrete&&m>0&&m<1&&(m=1),o._incr=m,o._space=v,v===0)continue;if(r.splits)o._splits=r.splits(c,h,m,v);else if(a.time)o._splits=In(c,h,m);else if(a.distr===N.Log)o._splits=pn(c,h,a.log);else{const g=a.distr===N.Ordinal||a._discrete;o._splits=gn(c,h,m,v,g)}if(r.values)o._values=r.values(o._splits,v,m);else if(a.time)o._values=En(o._splits,m);else if(a.distr===N.Log){const g=mn(o._splits,a.log),y=st(o._splits);o._values=y.map((L,T)=>g[T]?L:"")}else o._values=st(o._splits);o._rotate=f===Y.Bottom?r.rotate??0:0;const C=o._size;o._size=Ce(yn(r,o._values)),C!==o._size&&(i=!1)}return i}function lt(e,t,n,s=0){let l=e,i=t-s,o=0,r=s;for(const f of n){if(!f._show)continue;const u=f.config.side,d=ge(u)===B.Vertical,c=f.config.label!=null?f.config.labelSize??20:0,h=f._size+c;h>0&&(d?(l-=h,u===Y.Left&&(o+=h)):(i-=h,u===Y.Top&&(r+=h)))}return!n.some(f=>f._show&&f.config.side===Y.Top)&&r<=s&&(r+=8,i-=8),{left:o,top:r,width:Math.max(l,0),height:Math.max(i,0)}}function Wn(e,t){let n=t.top,s=t.left+t.width,l=t.top+t.height,i=t.left;function o(r,a){switch(r){case Y.Top:return n-=a,n+a;case Y.Right:{const f=s;return s+=a,f}case Y.Bottom:{const f=l;return l+=a,f}case Y.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=o(a,r._size),r.config.label!=null){const f=r.config.labelSize??20;r._lpos=o(a,f)}}}function Vn(e,t,n,s,l=0){for(const a of n)a._size=0;let i=!1,o=0,r={left:0,top:0,width:e,height:t};for(;!i;){o++;const a=$n(n,s,r.width,r.height);i=o===Gn||a,i||(r=lt(e,t,n,l))}return r=lt(e,t,n,l),Wn(n,r),r}const it="top",rt="bottom",jn="left",Bn="right";function Ee(e,t){return t===1?e:e.replace(/(\d+(?:\.\d+)?)px/,(n,s)=>`${Math.round(Number(s)*t)}px`)}function at(e,t,n,s,l,i,o,r,a,f,u){const d=r%2/2;e.save(),e.translate(d,d),e.strokeStyle=a,e.lineWidth=r,f.length>0&&e.setLineDash(f),e.beginPath();let c=0,h=0,m=0,v=0;const C=i+(l===Y.Top||l===Y.Left?-o:o);s===B.Horizontal?(h=i,v=C):(c=i,m=C);for(let g=0;g<t.length;g++)n[g]!=null&&(s===B.Horizontal?c=m=t[g]??0:h=v=t[g]??0,e.moveTo(c,h),e.lineTo(m,v));e.stroke(),e.restore()}function Xn(e,t,n,s,l,i){const o=X(s.left*l),r=X(s.top*l),a=X(s.width*l),f=X(s.height*l);for(const u of t){if(!u._show)continue;const d=u.config,c=d.side,h=ge(c),m=n(d.scale);if(!m||m.min==null||m.max==null)continue;const v=d.stroke??"#000",C=c===Y.Top||c===Y.Left?-1:1,g=u._splits,y=u._values;if(!g||!y||u._space===0)continue;const L=h===B.Horizontal?s.width:s.height,T=h===B.Horizontal?s.left:s.top,E=g.map(R=>X(j(R,m,L,T)*l)),D=y.map(R=>R===""?null:R),S=d.grid;if((S==null?void 0:S.show)!==!1){const R=(S==null?void 0:S.stroke)??"rgba(0,0,0,0.12)",p=X(((S==null?void 0:S.width)??2)*l),w=((S==null?void 0:S.dash)??[]).map(k=>k*l),x=h===B.Horizontal?r:o,b=h===B.Horizontal?f:a;at(e,E,D,h,2,x,b,p,R,w)}const M=d.ticks;if((M==null?void 0:M.show)!==!1){const R=(M==null?void 0:M.stroke)??v,p=X(((M==null?void 0:M.width)??1)*l),w=X(((M==null?void 0:M.size)??10)*l),x=((M==null?void 0:M.dash)??[]).map(k=>k*l),b=X(u._pos*l);at(e,E,D,h,c,b,w,p,R,x)}{const R=(M==null?void 0:M.show)!==!1?((M==null?void 0:M.size)??10)*l:0,p=X((d.gap??5)*l),w=X(u._pos*l),x=(R+p)*C,b=w+x,k=Ee(d.font??"12px system-ui, sans-serif",l),I=h===B.Horizontal?"center":c===Y.Left?Bn:jn,z=h===B.Horizontal?c===Y.Bottom?it:rt:"middle";e.font=k,e.fillStyle=v,e.textAlign=I,e.textBaseline=z;const _=u._rotate*-ze/180;if(_!==0){const F=Math.cos(_),H=Math.sin(_);for(let G=0;G<y.length;G++){const $=y[G];if($==null||$==="")continue;const V=E[G]??0;e.setTransform(F,H,-H,F,V,b),e.fillText($,0,0)}e.setTransform(1,0,0,1,0,0)}else for(let F=0;F<y.length;F++){const H=y[F];if(H==null||H==="")continue;const G=E[F]??0,$=h===B.Horizontal?G:b,V=h===B.Horizontal?b:G;e.fillText(H,$,V)}}if(d.label!=null){const R=Ee(d.labelFont??"bold 12px system-ui, sans-serif",l);e.font=R,e.fillStyle=v,e.textAlign="center",e.textBaseline=c===Y.Bottom?it:rt;const p=X((u._lpos+(d.labelGap??0)*C)*l);h===B.Vertical?(e.save(),e.translate(p,X(r+f/2)),e.rotate((c===Y.Left?-ze:ze)/2),e.fillText(d.label,0,0),e.restore()):e.fillText(d.label,X(o+a/2),p)}const P=d.border;if((P==null?void 0:P.show)!==!1&&P!=null){const R=P.stroke??v,p=X((P.width??1)*l),w=(P.dash??[]).map(b=>b*l),x=X(u._pos*l);e.strokeStyle=R,e.lineWidth=p,w.length>0&&e.setLineDash(w),e.beginPath(),h===B.Horizontal?(e.moveTo(o,x),e.lineTo(o+a,x)):(e.moveTo(x,r),e.lineTo(x,r+f)),e.stroke(),w.length>0&&e.setLineDash([])}}if(i!=null){const u=Ee("bold 14px system-ui, sans-serif",l);e.font=u,e.fillStyle="#000",e.textAlign="center",e.textBaseline="top",e.fillText(i,X(o+a/2),X(4*l))}}const Yn={stroke:"#607D8B",width:1,dash:[5,3],pointRadius:4,showX:!0,showY:!0};function ct(e,t,n,s,l,i,o,r,a,f){var T,E;if(t.left<0||t.top<0)return;const u={...Yn,...a},d=s,c=X(n.left*d),h=X(n.top*d),m=X(n.width*d),v=X(n.height*d),C=X(u.width*d),g=C%2/2,y=X((n.left+t.left)*d)+g,L=X((n.top+t.top)*d)+g;if(e.save(),e.strokeStyle=u.stroke,e.lineWidth=C,e.setLineDash(u.dash.map(D=>D*d)),u.showX&&(e.beginPath(),e.moveTo(y,h),e.lineTo(y,h+v),e.stroke()),u.showY&&(e.beginPath(),e.moveTo(c,L),e.lineTo(c+m,L),e.stroke()),e.setLineDash([]),t.activeGroup>=0&&t.activeDataIdx>=0){const D=t.activeGroup,S=t.activeSeriesIdx,M=t.activeDataIdx,P=l[D];if(P!=null&&S>=0&&S<P.series.length&&M<P.x.length){const R=P.x[M],p=P.series[S],w=p!=null?p[M]:null;if(R!=null&&w!=null){let x=u.stroke,b=!0;const k=f==null?void 0:f.get(`${D}:${S}`);if(k!=null){const I=k.stroke;x=(typeof I=="string"?I:void 0)??u.stroke,b=((T=k.cursor)==null?void 0:T.show)!==!1}if(b){const I=r(D),z=I!=null?o(I):void 0,_=((E=f==null?void 0:f.get(`${D}:${S}`))==null?void 0:E.yScale)??Kn(i,D,S),F=_!=null?o(_):void 0;if(z!=null&&F!=null&&z.min!=null&&z.max!=null&&F.min!=null&&F.max!=null){const H=X(j(R,z,n.width,n.left)*d),G=X(j(w,F,n.height,n.top)*d),$=u.pointRadius*d,V=X(2*d);e.beginPath(),e.arc(H,G,$,0,Math.PI*2),e.fillStyle="#fff",e.fill(),e.strokeStyle=x,e.lineWidth=V,e.stroke()}}}}}e.restore()}function Kn(e,t,n){for(const s of e)if(s.group===t&&s.index===n)return s.yScale}const Un={fill:"rgba(0,0,0,0.07)",stroke:"rgba(0,0,0,0.15)",width:1};function ut(e,t,n,s,l){if(!t.show||t.width<=0)return;const i={...Un,...l},o=s,r=X((n.left+t.left)*o),a=X((n.top+t.top)*o),f=X(t.width*o),u=X(t.height*o);e.save(),e.fillStyle=i.fill,e.fillRect(r,a,f,u),i.width>0&&(e.strokeStyle=i.stroke,e.lineWidth=X(i.width*o),e.strokeRect(r,a,f,u)),e.restore()}function Nn(e,t,n,s,l,i,o,r,a,f,u,d){const c=u/2*o,h=Math.max(1,X(u*.2))*o,m=(f==null?void 0:f.stroke)??d,v=(f==null?void 0:f.fill)??"#fff";e.save(),e.strokeStyle=m,e.fillStyle=v,e.lineWidth=h,(f==null?void 0:f.dash)!=null&&e.setLineDash(f.dash.map(C=>C*o));for(let C=r;C<=a;C++){const g=n[C];if(g==null)continue;const y=t[C];if(y==null)continue;const L=X(j(y,s,i.width,i.left)*o),T=X(j(g,l,i.height,i.top)*o);e.beginPath(),e.arc(L,T,c,0,Math.PI*2),e.fill(),e.stroke()}e.restore()}function On(e,t,n,s,l,i,o){if(typeof e=="function")return e(t,n,s,l,i);if(e===!0)return!0;if(e===!1)return!1;const r=l-s;return r>0&&r<=i/o}function qn(e,t,n,s,l,i,o,r,a){if(r>a||r<0||!Je(t,r,a)&&!Je(n,r,a))return null;const f=h=>j(h,s,i.width,i.left)*o,u=h=>j(h,l,i.height,i.top)*o,d=new Path2D;let c=!1;for(let h=r;h<=a;h++){const m=t[h],v=e[h];if(m==null||v==null)continue;const C=f(v),g=u(m);c?d.lineTo(C,g):(d.moveTo(C,g),c=!0)}if(!c)return null;for(let h=a;h>=r;h--){const m=n[h],v=e[h];m==null||v==null||d.lineTo(f(v),u(m))}return d.closePath(),d}function Zn(e,t,n){e.save(),e.fillStyle=t.fill??"rgba(0, 120, 255, 0.1)",e.fill(n),e.restore()}function Jn(e){const t=e.dataStore.data;if(t.length===0)return;if(!e.scaleManager.getScale("x")){const o={id:"x",auto:!0};e.scaleConfigs.push(o),e.scaleManager.addScale(o)}for(let o=0;o<t.length;o++)e.scaleManager.getGroupXScaleKey(o)||e.scaleManager.setGroupXScale(o,"x");const n=new Set(e.scaleConfigs.map(o=>o.id)),s=new Set;for(const o of e.seriesConfigs)s.add(o.yScale);s.size===0&&!n.has("y")&&s.add("y");for(const o of s)if(!n.has(o)){const r={id:o,auto:!0};e.scaleConfigs.push(r),e.scaleManager.addScale(r),n.add(o)}e.axisConfigs.some(o=>o.scale==="x")||e.axisConfigs.push({scale:"x",side:Y.Bottom,show:!0,label:e.xlabel??"X Axis"});const i=new Set(e.axisConfigs.map(o=>o.scale));for(const o of s)i.has(o)||(e.axisConfigs.push({scale:o,side:Y.Left,show:!0,label:e.ylabel??"Y Axis"}),i.add(o))}function He(e,t,n,s){return{ctx:e,plotBox:t,pxRatio:n,getScale:s,valToX:(o,r="x")=>{const a=s(r);return a==null||a.min==null||a.max==null?null:j(o,a,t.width,t.left)},valToY:(o,r)=>{const a=s(r);return a==null||a.min==null||a.max==null?null:j(o,a,t.height,t.top)}}}function ft(e){e.seriesConfigMap.clear();for(const t of e.seriesConfigs)e.seriesConfigMap.set(`${t.group}:${t.index}`,t)}function Qn(){const e={scaleManager:new Qt,dataStore:new nn,renderer:new fn,cursorManager:new sn,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,cursorListeners:new Set,scheduler:new on,drawHooks:new Set,cursorDrawHooks:new Set,focusedSeries:null,focusAlpha:.15,wheelZoom:!1,title:void 0,xlabel:void 0,ylabel:void 0,revision:0,eventCallbacks:{},_prevScaleRanges:new Map,seriesConfigMap: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),ft(e)},unregisterSeries(t,n){e.seriesConfigs=e.seriesConfigs.filter(s=>!(s.group===t&&s.index===n)),ft(e)},toggleSeries(t,n){const s=e.seriesConfigMap.get(`${t}:${n}`);s!=null&&(s.show=s.show===!1,e.revision++,e.cursorManager.invalidateGroupedConfigs(),e.renderer.invalidateSeries(t,n),e.renderer.invalidateSnapshot(),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(te.Full)},scheduleCursorRedraw(){e.scheduler.mark(te.Cursor)},subscribe(t){return e.listeners.add(t),()=>{e.listeners.delete(t)}},subscribeCursor(t){return e.cursorListeners.add(t),()=>{e.cursorListeners.delete(t)}},redraw(){const{scaleManager:t,dataStore:n,renderer:s,seriesConfigs:l,width:i,height:o,pxRatio:r,canvas:a,scheduler:f}=e;if(a==null||i===0||o===0)return;const u=a.getContext("2d");if(u==null)return;s.setContext(u,r);const c=(f.dirty&~(te.Cursor|te.Select))===0,h=g=>t.getScale(g);if(c&&s.restoreSnapshot(u)){if(ct(u,e.cursorManager.state,e.plotBox,r,n.data,l,h,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),ut(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const g=He(u,e.plotBox,r,h);for(const y of e.cursorDrawHooks)try{y(g,e.cursorManager.state)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}for(const g of e.cursorListeners)g();return}Jn(e),t.autoRangeX(n.data),n.updateWindows(g=>{const y=t.getGroupXScaleKey(g);return y!=null?t.getScale(y):void 0});const m=l.map(g=>({group:g.group,index:g.index,yScale:g.yScale}));if(t.autoRange(n.data,m,n),es(e),e.axisStates.length>0){const g=e.title!=null?20:0;e.plotBox=Vn(i,o,e.axisStates,h,g)}else e.plotBox={left:10,top:10,width:i-20,height:o-20};u.clearRect(0,0,i*r,o*r),e.axisStates.length>0&&Xn(u,e.axisStates,h,e.plotBox,r,e.title);const v=[];for(const g of l){const y=t.getGroupXScaleKey(g.group),L=y!=null?t.getScale(y):void 0,T=t.getScale(g.yScale);L==null||T==null||v.push({config:g,dataX:n.getXValues(g.group),dataY:n.getYValues(g.group,g.index),xScale:L,yScale:T,window:n.getWindow(g.group)})}s.checkScaleStamp(v),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 g=0;g<v.length;g++){const y=v[g];y!=null&&(e.focusedSeries!=null&&g!==e.focusedSeries?(u.globalAlpha=e.focusAlpha,s.drawSeries(y,e.plotBox,1),u.globalAlpha=1):s.drawSeries(y,e.plotBox,1))}const C=new Map;for(const g of l)C.set(`${g.group}-${g.index}`,g);for(const g of e.bandConfigs){const y=t.getGroupXScaleKey(g.group),L=y!=null?t.getScale(y):void 0,T=C.get(`${g.group}-${g.series[0]}`),E=C.get(`${g.group}-${g.series[1]}`);if(L==null||T==null||E==null)continue;const D=t.getScale(T.yScale);if(D==null)continue;const[S,M]=n.getWindow(g.group),P=g.series[0],R=g.series[1];let p=s.getCachedBandPath(g.group,P,R,S,M);p==null&&(p=qn(n.getXValues(g.group),n.getYValues(g.group,P),n.getYValues(g.group,R),L,D,e.plotBox,r,S,M)??void 0,p!=null&&s.setCachedBandPath(g.group,P,R,S,M,p)),p!=null&&Zn(u,g,p)}for(const g of v){const y=g.config;if(y.show===!1)continue;const L=y.points,T=y.width??1,E=(L==null?void 0:L.size)??3+T*2,D=(L==null?void 0:L.space)??E*2,[S,M]=g.window;On(L==null?void 0:L.show,y.group,y.index,S,M,e.plotBox.width,D)&&Nn(u,g.dataX,g.dataY,g.xScale,g.yScale,e.plotBox,r,S,M,L,E,(typeof y.stroke=="string"?y.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 g=He(u,e.plotBox,r,h);for(const y of e.drawHooks)try{y(g)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}if(e.cursorManager.state.left>=0&&(s.saveSnapshot(u,i*r,o*r),e.cursorManager.update(e.cursorManager.state.left,e.cursorManager.state.top,e.plotBox,n.data,l,h,g=>n.getWindow(g),g=>t.getGroupXScaleKey(g))),ct(u,e.cursorManager.state,e.plotBox,r,n.data,l,h,g=>t.getGroupXScaleKey(g),void 0,e.seriesConfigMap),ut(u,e.selectState,e.plotBox,r),e.cursorDrawHooks.size>0){u.save(),u.scale(r,r);const g=He(u,e.plotBox,r,h);for(const y of e.cursorDrawHooks)try{y(g,e.cursorManager.state)}catch(L){console.warn("[uPlot+] draw hook error:",L)}u.restore()}for(const g of e.listeners)g();for(const g of e.cursorListeners)g();if(e._prevScaleRanges.size>0&&e.eventCallbacks.onScaleChange!=null)for(const g of t.getAllScales()){if(g.min==null||g.max==null)continue;const y=e._prevScaleRanges.get(g.id);if(y==null||y.min!==g.min||y.max!==g.max)try{e.eventCallbacks.onScaleChange(g.id,g.min,g.max)}catch(L){console.warn("[uPlot+] event callback error:",L)}}e._prevScaleRanges.clear();for(const g of t.getAllScales())g.min!=null&&g.max!=null&&e._prevScaleRanges.set(g.id,{min:g.min,max:g.max})}};return e.scheduler.onRedraw(()=>e.redraw()),e}function es(e){const{axisConfigs:t,axisStates:n}=e,s=new Map;for(const l of n)s.set(`${l.config.scale}:${l.config.side}`,l);e.axisStates=t.map(l=>{const i=`${l.scale}:${l.side}`,o=s.get(i);return o!=null?(o.config=l,o):Cn(l)})}function ts(){const e=A.useRef(null);return e.current===null&&(e.current=Qn()),e.current}const Pt=A.createContext(null);function Q(){const e=A.useContext(Pt);if(!e)throw new Error("useChart must be used within a <Chart> component");return e}function ns(e,t){A.useEffect(()=>{if(t!=null)return ss(e,t)},[e,t])}function ss(e,t){let n=null;const s={show:!1,left:0,top:0,width:0,height:0};let l=null,i=null,o=!1;function r(p){const w=t.getBoundingClientRect(),x=e.plotBox,b=p.clientX-w.left-x.left,k=p.clientY-w.top-x.top;return{cx:b,cy:k}}function a(p,w){const x=e.plotBox;return p>=0&&p<=x.width&&w>=0&&w<=x.height}function f(p,w){const x=t.getBoundingClientRect(),b=p-x.left,k=w-x.top,I=e.plotBox;for(const z of e.axisStates){const _=z.config,F=_.side;if(z._size<=0)continue;const G=k>=I.top&&k<=I.top+I.height,$=b>=I.left&&b<=I.left+I.width;if(F===Y.Left&&b<I.left&&G||F===Y.Right&&b>I.left+I.width&&G||F===Y.Top&&k<I.top&&$||F===Y.Bottom&&k>I.top+I.height&&$){const U=ge(F);return{scaleId:_.scale,ori:U}}}return null}function u(p,w,x){const b=e.cursorManager.state;let k=null;if(b.activeGroup>=0&&b.activeDataIdx>=0){const I=e.dataStore.data[b.activeGroup];if(I!=null){const z=I.x[b.activeDataIdx],_=I.series[b.activeSeriesIdx],F=_!=null?_[b.activeDataIdx]:void 0;if(z!=null&&F!=null){const H=e.plotBox,G=e.scaleManager.getGroupXScaleKey(b.activeGroup),$=G!=null?e.scaleManager.getScale(G):void 0,V=e.seriesConfigMap.get(`${b.activeGroup}:${b.activeSeriesIdx}`),U=V!=null?e.scaleManager.getScale(V.yScale):void 0;let J=w,pe=x;($==null?void 0:$.min)!=null&&$.max!=null&&(J=j(z,$,H.width,H.left)-H.left),(U==null?void 0:U.min)!=null&&U.max!=null&&(pe=j(F,U,H.height,H.top)-H.top);const Oe=w-J,qe=x-pe;k={group:b.activeGroup,seriesIdx:b.activeSeriesIdx,dataIdx:b.activeDataIdx,xVal:z,yVal:F,pxX:J,pxY:pe,dist:Math.sqrt(Oe*Oe+qe*qe)}}}}return{plotX:w,plotY:x,point:k,srcEvent:p}}function d(p){const w=e.plotBox,x=p.left/w.width,b=(p.left+p.width)/w.width,k={};for(const I of e.scaleManager.getAllScales()){if(I.ori!==B.Horizontal||I.min==null||I.max==null)continue;const z=se(w.left+x*w.width,I,w.width,w.left),_=se(w.left+b*w.width,I,w.width,w.left);k[I.id]={min:Math.min(z,_),max:Math.max(z,_)}}return{left:x,right:b,ranges:k}}function c(){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 h(p,w){if(i!=null){const I=t.getBoundingClientRect(),z=p.clientY-I.top,_=e.plotBox,F=(z-i.startY)/_.height,H=i.startMax-i.startMin,G=e.scaleManager.getScale(i.scaleId);G!=null&&(G.min=i.startMin+F*H,G.max=i.startMax+F*H,G.auto=!1,fe(G),e.renderer.clearCache(),e.scheduleRedraw());return}const x=r(p);if(x==null)return;const{cx:b,cy:k}=x;if(!a(b,k)&&n==null){e.cursorManager.hide(),e.focusedSeries!=null&&e.setFocus(null),e.scheduleCursorRedraw();return}if(e.cursorManager.update(b,k,e.plotBox,e.dataStore.data,e.seriesConfigs,I=>e.scaleManager.getScale(I),I=>e.dataStore.getWindow(I),I=>e.scaleManager.getGroupXScaleKey(I)),e.focusAlpha<1){const I=e.cursorManager.state;if(I.activeGroup>=0&&I.activeSeriesIdx>=0){const z=e.seriesConfigs.findIndex(_=>_.group===I.activeGroup&&_.index===I.activeSeriesIdx);z>=0&&e.focusedSeries!==z&&(e.focusedSeries=z,e.scheduleRedraw())}}if(w!=null&&e.eventCallbacks.onCursorMove!=null&&a(b,k))try{e.eventCallbacks.onCursorMove(u(w,b,k))}catch(I){console.warn("[uPlot+] event callback error:",I)}if(n!=null){const I=n.x,z=e.plotBox,_=q(b,0,z.width);s.show=!0,s.left=Math.min(I,_),s.top=0,s.width=Math.abs(_-I),s.height=z.height,e.selectState=s}n!=null?e.scheduler.mark(te.Cursor|te.Select):e.scheduleCursorRedraw()}function m(p){h(p,p)}function v(p){if(p.button!==0)return;const w=f(p.clientX,p.clientY);if(w!=null&&w.ori===B.Vertical){const b=e.scaleManager.getScale(w.scaleId);if(b!=null&&b.min!=null&&b.max!=null){const k=t.getBoundingClientRect();i={scaleId:w.scaleId,startY:p.clientY-k.top,startMin:b.min,startMax:b.max},p.preventDefault();return}}const x=r(p);x!=null&&a(x.cx,x.cy)&&(n={x:x.cx,y:x.cy},o=!1,s.show=!1,s.left=0,s.width=0,e.selectState=s)}function C(p){if(i!=null){c(),i=null;return}if(n!=null){if(s.width>5){o=!0;let w=!0;if(e.eventCallbacks.onSelect!=null){const x=d(s);let b;try{b=e.eventCallbacks.onSelect(x)}catch(k){console.warn("[uPlot+] event callback error:",k)}b===!1&&(w=!1)}w&&(S(s),c())}n=null,s.show=!1,s.left=0,s.width=0,e.selectState=s,e.scheduleRedraw()}}function g(p){C()}function y(p){if(o){o=!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(b){console.warn("[uPlot+] event callback error:",b)}}function L(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(b){console.warn("[uPlot+] event callback error:",b)}}}function T(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(b){console.warn("[uPlot+] event callback error:",b)}}function E(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(b){console.warn("[uPlot+] event callback error:",b)}if(x===!1)return}}for(const w of e.scaleConfigs)e.scaleManager.addScale(w);e.renderer.clearCache(),e.scheduleRedraw()}function D(p){const w=e.wheelZoom;if(!w)return;let x=!1,b=!1;if(w===!0||w==="x")x=!0;else if(w==="y")b=!0;else if(w==="xy")x=!0,b=!0;else if(typeof w=="object"){if(w.x){const _=typeof w.x=="object"?w.x.key:void 0;x=_==null||p[`${_}Key`]}if(w.y){const _=typeof w.y=="object"?w.y.key:void 0;b=_==null||p[`${_}Key`]}}if(!x&&!b)return;const k=r(p);if(k==null||!a(k.cx,k.cy))return;p.preventDefault();const I=q(1-p.deltaY*.001,.1,10),z=e.plotBox;for(const _ of e.scaleManager.getAllScales()){if(_.min==null||_.max==null)continue;const F=_.ori===B.Horizontal;if(F&&!x||!F&&!b)continue;const H=F?z.width:z.height,G=F?z.left:z.top,$=F?k.cx+z.left:k.cy+z.top,V=se($,_,H,G),U=V-(V-_.min)*I,J=V+(_.max-V)*I;_.min=Math.min(U,J),_.max=Math.max(U,J),_.auto=!1,fe(_)}e.scheduleRedraw(),c()}function S(p){const w=e.plotBox,x=p.left/w.width,b=(p.left+p.width)/w.width;for(const k of e.scaleManager.getAllScales()){if(k.ori!==B.Horizontal||k.min==null||k.max==null)continue;const I=se(w.left+x*w.width,k,w.width,w.left),z=se(w.left+b*w.width,k,w.width,w.left);k.min=Math.min(I,z),k.max=Math.max(I,z),k.auto=!1,fe(k)}}function M(p){if(p.touches.length===2){const b=p.touches[0],k=p.touches[1],I=k.clientX-b.clientX,z=k.clientY-b.clientY;l={dist:Math.sqrt(I*I+z*z),midX:(b.clientX+k.clientX)/2,midY:(b.clientY+k.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},o=!1)}function P(p){if(p.touches.length===2&&l!=null){p.preventDefault();const x=p.touches[0],b=p.touches[1],k=b.clientX-x.clientX,I=b.clientY-x.clientY,z=Math.sqrt(k*k+I*I),_=z/l.dist,F=t.getBoundingClientRect(),H=e.plotBox,G=l.midX-F.left-H.left;for(const $ of e.scaleManager.getAllScales()){if($.ori!==B.Horizontal||$.min==null||$.max==null)continue;const V=se(G+H.left,$,H.width,H.left),U=V-(V-$.min)/_,J=V+($.max-V)/_;$.min=Math.min(U,J),$.max=Math.max(U,J),$.auto=!1,fe($)}l.dist=z,e.renderer.clearCache(),e.scheduleRedraw(),c();return}const w=p.touches[0];w!=null&&(h(w,p),n!=null&&p.preventDefault())}function R(p){if(l!=null){l=null;return}p.changedTouches[0]!=null&&C()}return t.addEventListener("mousemove",m),t.addEventListener("mousedown",v),t.addEventListener("mouseup",g),t.addEventListener("click",y),t.addEventListener("contextmenu",L),t.addEventListener("mouseleave",T),t.addEventListener("dblclick",E),t.addEventListener("wheel",D,{passive:!1}),t.addEventListener("touchstart",M,{passive:!0}),t.addEventListener("touchmove",P,{passive:!1}),t.addEventListener("touchend",R),()=>{t.removeEventListener("mousemove",m),t.removeEventListener("mousedown",v),t.removeEventListener("mouseup",g),t.removeEventListener("click",y),t.removeEventListener("contextmenu",L),t.removeEventListener("mouseleave",T),t.removeEventListener("dblclick",E),t.removeEventListener("wheel",D),t.removeEventListener("touchstart",M),t.removeEventListener("touchmove",P),t.removeEventListener("touchend",R)}}const $e=new Map;function os(e){let t=$e.get(e);return t==null&&(t=new ls(e),$e.set(e,t)),t}class ls{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:l}=n;if(s<0||l<0){for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.hide(),r.scheduleCursorRedraw());this.publishing=!1;return}const o=t.dataStore.getXValues(s)[l];if(o==null){this.publishing=!1;return}for(const r of this.members)r!==t&&(this.syncedStores.add(r),r.cursorManager.syncToValue(o,r),r.scheduleCursorRedraw());this.publishing=!1}}function is(e,t){A.useEffect(()=>{if(t==null)return;const n=os(t);n.join(e);let s=-1,l=-1;const i=e.subscribe(()=>{const{activeGroup:o,activeDataIdx:r}=e.cursorManager.state;o===s&&r===l||(s=o,l=r,n.pub(e))});return()=>{i(),n.leave(e)}},[e,t])}function Rt(e){return e instanceof Float64Array?e:new Float64Array(e)}function Dt(e){return e instanceof Float64Array||e.some(t=>t==null)?e:new Float64Array(e)}function ht(e){return{x:Rt(e.x),series:[Dt(e.y)]}}function rs(e){return{x:Rt(e.x),series:e.series.map(Dt)}}function Xe(e){if(!Array.isArray(e))return[ht(e)];if(e.length===0)return[];const t=e[0];return t==null?[]:"series"in t?e.map(rs):e.map(ht)}function Ye({width:e,height:t,data:n,children:s,className:l,pxRatio:i,title:o,xlabel:r,ylabel:a,onDraw:f,onCursorDraw:u,syncKey:d,cursor:c,onClick:h,onContextMenu:m,onDblClick:v,onCursorMove:C,onCursorLeave:g,onScaleChange:y,onSelect:L}){var _;const T=ts(),[E,D]=A.useState(null),S=i??(typeof window<"u"&&window.devicePixelRatio||1),M=c==null?void 0:c.wheelZoom,P=typeof M=="object"?JSON.stringify(M):M,R=((_=c==null?void 0:c.focus)==null?void 0:_.alpha)??((c==null?void 0:c.focus)!=null?.15:1);A.useEffect(()=>{T.wheelZoom=M,T.focusAlpha=R},[T,P,R]),A.useEffect(()=>{T.title=o,T.xlabel=r,T.ylabel=a},[T,o,r,a]);const p=A.useRef(T.eventCallbacks);p.current=T.eventCallbacks,A.useEffect(()=>{const F=p.current;F.onClick=h,F.onContextMenu=m,F.onDblClick=v,F.onCursorMove=C,F.onCursorLeave=g,F.onScaleChange=y,F.onSelect=L}),ns(T,E),is(T,d);const w=A.useCallback(F=>{T.canvas=F,F&&T.scheduleRedraw()},[T]),x=A.useCallback(F=>{D(F)},[]);A.useEffect(()=>{T.pxRatio=S,T.setSize(e,t)},[T,e,t,S]),A.useEffect(()=>()=>{T.canvas=null,T.scheduler.cancel(),T.focusedSeries=null},[T]),A.useEffect(()=>{if(E==null||typeof ResizeObserver>"u")return;const F=new ResizeObserver(H=>{const G=H[0];if(G==null)return;const{width:$,height:V}=G.contentRect;$>0&&V>0&&($!==T.width||V!==T.height)&&T.setSize(Math.round($),Math.round(V))});return F.observe(E),()=>{F.disconnect()}},[T,E]);const b=A.useMemo(()=>Xe(n),[n]),k=A.useRef(n);A.useEffect(()=>{n===k.current&&T.dataStore.data.length>0||(k.current=n,T.dataStore.setData(b),T.renderer.clearCache(),T.scheduleRedraw())},[T,n,b]);const I=A.useRef(f);I.current=f,A.useEffect(()=>{const F=H=>{var G;(G=I.current)==null||G.call(I,H)};return T.drawHooks.add(F),()=>{T.drawHooks.delete(F)}},[T]);const z=A.useRef(u);return z.current=u,A.useEffect(()=>{const F=(H,G)=>{var $;($=z.current)==null||$.call(z,H,G)};return T.cursorDrawHooks.add(F),()=>{T.cursorDrawHooks.delete(F)}},[T]),W.jsx(Pt.Provider,{value:T,children:W.jsxs("div",{className:l,style:{position:"relative",display:"flex",flexDirection:"column",width:`${e}px`},children:[W.jsx("div",{ref:x,style:{position:"relative",width:`${e}px`,height:`${t}px`,cursor:"crosshair",order:0},children:W.jsx("canvas",{ref:w,style:{position:"absolute",left:0,top:0}})}),s]})})}function dt(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function as(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;for(const l of s)if(e[l]!==t[l])return!1;return!0}function Ke(e,t){if(e===null)return!1;const n=e,s=t,l=Object.keys(n),i=Object.keys(s);if(l.length!==i.length)return!1;for(const o of i){const r=n[o],a=s[o];if(r!==a)if(dt(r)&&dt(a)){if(!as(r,a))return!1}else return!1}return!0}function Ie(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const l=n.current;return t.registerScale({...l}),t.scheduleRedraw(),()=>{t.unregisterScale(l.id),t.scheduleRedraw()}},[t,e.id]);const s=A.useRef(null);return A.useEffect(()=>{Ke(s.current,e)||(s.current=e,t.scaleConfigs=t.scaleConfigs.map(l=>l.id===e.id?{...e}:l),t.scaleManager.addScale({...e}),t.renderer.clearCache(),t.scheduleRedraw())}),null}const gt=["#e74c3c","#3498db","#2ecc71","#f39c12","#9b59b6","#1abc9c","#e67e22","#34495e","#16a085","#c0392b","#2980b9","#27ae60","#f1c40f","#8e44ad","#d35400"];function pt(e,t){return{...e,yScale:e.yScale??"y",show:e.show??!0,stroke:e.stroke??gt[t%gt.length]}}function Ue(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const l=n.current;return t.registerSeries(pt(l,t.seriesConfigs.length)),t.renderer.clearGroupCache(l.group),t.scheduleRedraw(),()=>{t.unregisterSeries(l.group,l.index),t.renderer.clearGroupCache(l.group),t.scheduleRedraw()}},[t,e.group,e.index]);const s=A.useRef(null);return A.useEffect(()=>{if(!Ke(s.current,e)){s.current=e,t.seriesConfigs=t.seriesConfigs.map((l,i)=>l.group===e.group&&l.index===e.index?pt(e,i):l),t.seriesConfigMap.clear();for(const l of t.seriesConfigs)t.seriesConfigMap.set(`${l.group}:${l.index}`,l);t.renderer.invalidateSeries(e.group,e.index),t.scheduleRedraw()}}),null}function cs(e){return{...e,side:e.side??(e.scale==="x"?Y.Bottom:Y.Left),show:e.show??!0}}function Ae(e){const t=Q(),n=cs(e),s=A.useRef(n);s.current=n,A.useEffect(()=>{const i=s.current;return t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===i.scale&&o.side===i.side)),t.axisConfigs.push(i),t.scheduleRedraw(),()=>{t.axisConfigs=t.axisConfigs.filter(o=>!(o.scale===i.scale&&o.side===i.side)),t.scheduleRedraw()}},[t,n.scale,n.side]);const l=A.useRef(null);return A.useEffect(()=>{Ke(l.current,e)||(l.current=e,t.axisConfigs=t.axisConfigs.map(i=>i.scale===n.scale&&i.side===n.side?n:i),t.scheduleRedraw())}),null}function us({series:e,group:t,fill:n,dir:s}){const l=Q(),i=A.useRef(null),o=e[0],r=e[1];return A.useEffect(()=>{const a={series:[o,r],group:t,fill:n,dir:s};return i.current!=null&&(l.bandConfigs=l.bandConfigs.filter(f=>f!==i.current)),i.current=a,l.bandConfigs.push(a),l.scheduleRedraw(),()=>{l.bandConfigs=l.bandConfigs.filter(f=>f!==i.current),i.current=null,l.scheduleRedraw()}},[l,o,r,t,n,s]),null}const fs={width:12,height:3,borderRadius:1,display:"inline-block"},hs={fontWeight:600},zt={display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",cursor:"pointer",fontSize:12,fontFamily:"sans-serif"},ds={...zt,opacity:1},gs={...zt,opacity:.4},mt=new Map,ps=A.memo(function({group:t,index:n,label:s,color:l,isHidden:i,valueStr:o,store:r}){const a=A.useCallback(()=>{r.toggleSeries(t,n)},[r,t,n]);let f=mt.get(l);return f==null&&(f={...fs,backgroundColor:l},mt.set(l,f)),W.jsxs("span",{onClick:a,style:i?gs:ds,children:[W.jsx("span",{style:f}),W.jsx("span",{children:s}),o&&W.jsx("span",{style:hs,children:o})]})});function ms({show:e=!0,position:t="bottom",className:n}){const s=Q(),l=A.useRef({activeGroup:-1,activeDataIdx:-1,seriesCount:0,revision:-1}),i=A.useCallback(u=>s.subscribeCursor(u),[s]),o=A.useCallback(()=>{const{activeGroup:u,activeDataIdx:d}=s.cursorManager.state,c=s.seriesConfigs.length,{revision:h}=s,m=l.current;if(m.activeGroup===u&&m.activeDataIdx===d&&m.seriesCount===c&&m.revision===h)return m;const v={activeGroup:u,activeDataIdx:d,seriesCount:c,revision:h};return l.current=v,v},[s]),r=A.useSyncExternalStore(i,o);if(!e)return null;const{activeGroup:a,activeDataIdx:f}=r;return W.jsx("div",{className:n,style:{display:"flex",flexWrap:"wrap",justifyContent:"center",order:t==="top"?-1:1,padding:"4px 0"},children:s.seriesConfigs.map(u=>{if(u.legend===!1)return null;const d=typeof u.stroke=="string"?u.stroke:"#000";let c="";if(f>=0&&a>=0&&u.group===a){const m=s.dataStore.getYValues(u.group,u.index)[f];m!=null&&(c=typeof m=="number"?m.toPrecision(4):String(m))}return W.jsx(ps,{group:u.group,index:u.index,label:u.label??`Series ${u.index}`,color:d,isHidden:u.show===!1,valueStr:c,store:s},`${u.group}:${u.index}`)})})}const ws={position:"absolute",zIndex:50,background:"rgba(255,255,255,0.92)",border:"1px solid #ccc",borderRadius:4,padding:"4px 6px",fontSize:12,fontFamily:"sans-serif",userSelect:"none",boxShadow:"0 1px 4px rgba(0,0,0,0.12)",whiteSpace:"nowrap"},xs={width:12,height:3,borderRadius:1,display:"inline-block",flexShrink:0},bs={fontWeight:600},vs={display:"flex",alignItems:"center",gap:4,padding:"1px 4px"},Ne=A.memo(function({label:t,color:n,value:s,isHidden:l,onClick:i}){return W.jsxs("div",{onClick:i,style:{...vs,opacity:l?.4:1,cursor:i?"pointer":"default"},children:[W.jsx("span",{style:{...xs,backgroundColor:n}}),W.jsx("span",{children:t}),s&&W.jsx("span",{style:bs,children:s})]})}),Le=A.forwardRef(function({left:t,top:n,children:s,className:l,style:i,onMouseDown:o,onMouseEnter:r,onMouseLeave:a},f){return W.jsx("div",{ref:f,className:l,onMouseDown:o,onMouseEnter:r,onMouseLeave:a,style:{...ws,left:t,top:n,...i},children:s})});function Ss(e,t,n,s,l){if(l<0||s<0)return"";const o=e.dataStore.getYValues(t,n)[l];return o==null?"":typeof o=="number"?o.toPrecision(4):String(o)}function Ms({show:e=!0,className:t,children:n,offset:s={}}){var w,x;const l=Q(),i=A.useRef({left:-10,top:-10,activeGroup:-1,activeDataIdx:-1,revision:-1}),o=A.useRef(null),r=A.useCallback(b=>l.subscribeCursor(b),[l]),a=A.useCallback(()=>{const b=l.cursorManager.state,{revision:k}=l,I=i.current;if(I.left===b.left&&I.top===b.top&&I.activeGroup===b.activeGroup&&I.activeDataIdx===b.activeDataIdx&&I.revision===k)return I;const z={left:b.left,top:b.top,activeGroup:b.activeGroup,activeDataIdx:b.activeDataIdx,revision:k};return i.current=z,z},[l]),f=A.useSyncExternalStore(r,a);if(!e||f.activeDataIdx<0||f.activeGroup<0||f.left<0)return null;const{activeGroup:u,activeDataIdx:d}=f,c=l.plotBox,h=l.dataStore.data[u],m=h!=null?h.x[d]??null:null,v=m!=null?parseFloat(m.toPrecision(6)).toString():"",C=[];for(const b of l.seriesConfigs){if(b.show===!1||b.legend===!1)continue;const k=l.dataStore.getYValues(b.group,b.index),I=b.group===u?k[d]:null;C.push({label:b.label??`Series ${b.index}`,value:I,color:typeof b.stroke=="string"?b.stroke:"#000",group:b.group,index:b.index})}const g={x:m,xLabel:v,items:C,left:f.left+c.left,top:f.top+c.top},y=s.x??12,L=s.y??-12,T=((w=o.current)==null?void 0:w.offsetWidth)??0,E=((x=o.current)==null?void 0:x.offsetHeight)??0,D=f.left+c.left,S=f.top+c.top,M=c.left+c.width,P=c.top+c.height,R=q(D+y,c.left,M-T),p=q(S+L,c.top,P-E);return n?W.jsx("div",{ref:o,className:t,style:{position:"absolute",left:R,top:p,whiteSpace:"nowrap",pointerEvents:"none",zIndex:100},children:n(g)}):W.jsxs(Le,{ref:o,left:R,top:p,className:t,style:{pointerEvents:"none",zIndex:100},children:[W.jsx("div",{style:{fontWeight:600,marginBottom:2,padding:"0 4px"},children:v}),C.map(b=>W.jsx(Ne,{label:b.label,color:b.color,value:b.value!=null?b.value.toPrecision(4):"—"},`${b.group}:${b.index}`))]})}function ys({width:e,height:t,data:n,onRangeChange:s,initialRange:l,className:i,colors:o,grips:r=!1}){const a=A.useRef(null),f=A.useMemo(()=>Xe(n),[n]),[u,d]=A.useState(()=>{if(l!=null&&f.length>0){const D=f[0];if(D!=null&&D.x.length>1){const S=D.x[0],P=D.x[D.x.length-1]-S;if(P>0)return[Math.max(0,(l[0]-S)/P),Math.min(1,(l[1]-S)/P)]}}return[.25,.75]}),c=A.useRef(null);A.useEffect(()=>{if(s==null||f.length===0)return;const D=f[0];if(D==null||D.x.length<2)return;const S=D.x[0],P=D.x[D.x.length-1]-S,R=S+u[0]*P,p=S+u[1]*P,w=c.current,x=Math.max(1e-10,Math.abs(p-R)*1e-12);w!=null&&Math.abs(w[0]-R)<x&&Math.abs(w[1]-p)<x||(c.current=[R,p],s(R,p))},[u,f,s]);const h=A.useRef(null),m=A.useCallback(D=>{const S=a.current;if(S==null)return 0;const M=S.getBoundingClientRect();return q((D-M.left)/M.width,0,1)},[]),v=A.useCallback(D=>{const S=a.current;if(S==null)return;const M=m(D.clientX),P=S.getBoundingClientRect().width,R=P>0?8/P:0;let p;if(Math.abs(M-u[0])<R)p="left";else if(Math.abs(M-u[1])<R)p="right";else if(M>=u[0]&&M<=u[1])p="move";else{const w=u[1]-u[0],x=w/2,b=q(M-x,0,1-w);d([b,b+w]),p="move"}h.current={mode:p,startX:D.clientX,startFrac:[...u]},S.setPointerCapture(D.pointerId),D.preventDefault()},[u,m]),C=A.useCallback(D=>{const S=h.current;if(S==null)return;const M=m(D.clientX),P=m(S.startX),R=M-P;if(S.mode==="move"){const p=S.startFrac[1]-S.startFrac[0],w=q(S.startFrac[0]+R,0,1-p);d([w,w+p])}else if(S.mode==="left"){const p=q(S.startFrac[0]+R,0,S.startFrac[1]-.01);d([p,S.startFrac[1]])}else{const p=q(S.startFrac[1]+R,S.startFrac[0]+.01,1);d([S.startFrac[0],p])}},[m]),g=A.useCallback(D=>{h.current=null;const S=a.current;S!=null&&S.releasePointerCapture(D.pointerId)},[]),y=`${u[0]*100}%`,L=`${(u[1]-u[0])*100}%`,T=f[0],E=T!=null?T.series.length:0;return W.jsxs("div",{className:i,style:{position:"relative",width:e,height:t},children:[W.jsxs(Ye,{width:e,height:t,data:n,children:[W.jsx(Ie,{id:"x"}),W.jsx(Ie,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),Array.from({length:E},(D,S)=>W.jsx(Ue,{group:0,index:S,yScale:"y",stroke:o!=null&&o[S]!=null?o[S]:`hsl(${S*137}, 60%, 50%)`,width:1},S))]}),W.jsxs("div",{ref:a,onPointerDown:v,onPointerMove:C,onPointerUp:g,style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",cursor:"default",touchAction:"none"},children:[W.jsx("div",{style:{position:"absolute",top:0,left:0,width:y,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:`${u[1]*100}%`,right:0,height:"100%",background:"rgba(0,0,0,0.3)",pointerEvents:"none"}}),W.jsx("div",{style:{position:"absolute",top:0,left:y,width:L,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&&W.jsxs(W.Fragment,{children:[W.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"}}),W.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 Me(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=l=>n.current(l);return t.drawHooks.add(s),()=>{t.drawHooks.delete(s)}},[t])}function Cs(e){const t=Q(),n=A.useRef(e);n.current=e,A.useEffect(()=>{const s=(l,i)=>n.current(l,i);return t.cursorDrawHooks.add(s),()=>{t.cursorDrawHooks.delete(s)}},[t])}function ks({lanes:e,laneHeight:t=24,gap:n=2,scaleId:s="x"}){const l=Q();return Me(({ctx:i,plotBox:o,pxRatio:r})=>{const a=l.scaleManager.getScale(s);if(a==null||a.min==null||a.max==null)return;i.save(),i.beginPath(),i.rect(o.left*r,o.top*r,o.width*r,o.height*r),i.clip();const f=(t+n)*r,u=t*r,d=o.top*r;for(let c=0;c<e.length;c++){const h=e[c];if(h==null)continue;const m=d+c*f;i.fillStyle="#666",i.font=`${11*r}px sans-serif`,i.textAlign="right",i.textBaseline="middle",i.fillText(h.label,(o.left-6)*r,m+u/2);for(const v of h.segments){const C=j(v.start,a,o.width,o.left)*r,y=j(v.end,a,o.width,o.left)*r-C;y<=0||(i.fillStyle=v.color??"#4dabf7",i.fillRect(C,m,y,u),v.label!=null&&y>20*r&&(i.fillStyle="#fff",i.font=`${10*r}px sans-serif`,i.textAlign="center",i.textBaseline="middle",i.fillText(v.label,C+y/2,m+u/2,y-4*r)))}}i.restore()}),null}function Ts({data:e,width:t=150,height:n=30,stroke:s="#03a9f4",fill:l,lineWidth:i=1,paths:o,fillTo:r,className:a}){return W.jsx("div",{style:{pointerEvents:"none"},className:a,children:W.jsxs(Ye,{width:t,height:n,data:e,children:[W.jsx(Ie,{id:"x"}),W.jsx(Ie,{id:"y"}),W.jsx(Ae,{scale:"x",show:!1}),W.jsx(Ae,{scale:"y",show:!1}),W.jsx(Ue,{group:0,index:0,yScale:"y",stroke:s,fill:l,width:i,paths:o,fillTo:r})]})})}function Is(e,t){if(e!=null&&typeof e=="object")return e;const n=8;switch(e){case"top-left":return{x:t.left+n,y:t.top+n};case"bottom-left":return{x:t.left+n,y:t.top+t.height-60};case"bottom-right":return{x:t.left+t.width-140,y:t.top+t.height-60};case"top-right":default:return{x:t.left+t.width-140,y:t.top+n}}}function As({mode:e="draggable",position:t="top-right",offset:n={x:12,y:-12},idleOpacity:s=.3,show:l=!0,className:i}){var p,w;const o=Q(),r=A.useRef(null),[a,f]=A.useState(null),[u,d]=A.useState(!1),c=A.useRef(!1),h=A.useRef(!1),m=A.useRef({dx:0,dy:0}),v=A.useRef(!1),C=A.useRef(null),g=A.useCallback(x=>o.subscribeCursor(x),[o]),y=A.useCallback(()=>{const{activeGroup:x,activeDataIdx:b,left:k,top:I}=o.cursorManager.state,z=o.seriesConfigs.length,{revision:_}=o,{left:F,top:H,width:G,height:$}=o.plotBox,V=r.current;if(V!=null&&V.activeGroup===x&&V.activeDataIdx===b&&V.cursorLeft===k&&V.cursorTop===I&&V.seriesCount===z&&V.revision===_&&V.plotLeft===F&&V.plotTop===H&&V.plotWidth===G&&V.plotHeight===$)return V;const U={activeGroup:x,activeDataIdx:b,cursorLeft:k,cursorTop:I,seriesCount:z,revision:_,plotLeft:F,plotTop:H,plotWidth:G,plotHeight:$};return r.current=U,U},[o]),L=A.useSyncExternalStore(g,y);e==="draggable"&&!v.current&&L.plotWidth>0&&(v.current=!0,a==null&&f(Is(t,o.plotBox)));const T=A.useCallback((x,b)=>{h.current||o.toggleSeries(x,b)},[o]),E=A.useCallback(x=>{if(e!=="draggable")return;x.stopPropagation(),x.preventDefault(),c.current=!0,h.current=!1;const b=x.currentTarget.getBoundingClientRect();m.current={dx:x.clientX-b.left,dy:x.clientY-b.top}},[e]);if(A.useEffect(()=>{if(!l||e!=="draggable")return;const x=k=>{var _;if(!c.current)return;h.current=!0;const I=(_=o.canvas)==null?void 0:_.parentElement;if(!I)return;const z=I.getBoundingClientRect();f({x:k.clientX-z.left-m.current.dx,y:k.clientY-z.top-m.current.dy})},b=()=>{c.current=!1};return window.addEventListener("mousemove",x),window.addEventListener("mouseup",b),()=>{window.removeEventListener("mousemove",x),window.removeEventListener("mouseup",b)}},[o,l,e]),!l)return null;const{activeGroup:D,activeDataIdx:S,cursorLeft:M,cursorTop:P}=L,R=o.seriesConfigs.filter(x=>x.legend!==!1).map(x=>{const b=typeof x.stroke=="string"?x.stroke:"#000",k=Ss(o,x.group,x.index,D,S),I=e==="draggable";return W.jsx(Ne,{label:x.label??`Series ${x.index}`,color:b,value:k,isHidden:x.show===!1,onClick:I?()=>T(x.group,x.index):void 0},`${x.group}:${x.index}`)});if(e==="cursor"){if(M<0)return null;const x=((p=C.current)==null?void 0:p.offsetWidth)??0,b=((w=C.current)==null?void 0:w.offsetHeight)??0,k=L.plotLeft+L.plotWidth,I=L.plotTop+L.plotHeight,z=q(M+L.plotLeft+n.x,L.plotLeft,k-x),_=q(P+L.plotTop+n.y,L.plotTop,I-b);return W.jsx(Le,{ref:C,left:z,top:_,className:i,style:{pointerEvents:"none"},children:R})}return a==null?null:W.jsx(Le,{ref:C,left:a.x,top:a.y,className:i,onMouseDown:E,onMouseEnter:()=>d(!0),onMouseLeave:()=>{d(!1),h.current=!1},style:{pointerEvents:"auto",cursor:c.current?"grabbing":"grab",opacity:u||c.current?1:s,transition:"opacity 0.2s ease"},children:R})}function Ls({delay:e=1e3,show:t=!0,className:n}){var E,D;const s=Q(),l=A.useRef(null),[i,o]=A.useState(!1),r=A.useRef(-1),a=A.useRef(0),f=A.useRef(null),u=A.useCallback(S=>s.subscribe(S),[s]),d=A.useCallback(()=>{const{left:S,top:M,activeSeriesIdx:P,activeGroup:R}=s.cursorManager.state,{left:p,top:w,width:x,height:b}=s.plotBox,k=l.current;if(k!=null&&k.cursorLeft===S&&k.cursorTop===M&&k.activeSeriesIdx===P&&k.activeGroup===R&&k.plotLeft===p&&k.plotTop===w&&k.plotWidth===x&&k.plotHeight===b)return k;const I={cursorLeft:S,cursorTop:M,activeSeriesIdx:P,activeGroup:R,plotLeft:p,plotTop:w,plotWidth:x,plotHeight:b};return l.current=I,I},[s]),c=A.useSyncExternalStore(u,d);if(A.useEffect(()=>{const S=c.activeSeriesIdx;S!==r.current&&(r.current=S,o(!1),window.clearTimeout(a.current),S>=0&&(a.current=window.setTimeout(()=>o(!0),e)))},[c.activeSeriesIdx,e]),A.useEffect(()=>()=>{window.clearTimeout(a.current)},[]),!t||!i||c.cursorLeft<0)return null;const h=s.seriesConfigs.find(S=>S.group===c.activeGroup&&S.index===c.activeSeriesIdx);if(!(h!=null&&h.label)||h.legend===!1)return null;const m=typeof h.stroke=="string"?h.stroke:"#000",v=((E=f.current)==null?void 0:E.offsetWidth)??80,C=((D=f.current)==null?void 0:D.offsetHeight)??24,g=c.cursorLeft+c.plotLeft,y=c.cursorTop+c.plotTop,L=q(g-v/2,c.plotLeft,c.plotLeft+c.plotWidth-v),T=q(y-C-12,c.plotTop,c.plotTop+c.plotHeight-C);return W.jsx(Le,{ref:f,left:L,top:T,className:n,style:{pointerEvents:"none"},children:W.jsx(Ne,{label:h.label,color:m})})}function Ft(e,t,n,s={}){const{ctx:l,plotBox:i}=e,o=j(n,t,i.height,i.top);l.beginPath(),l.moveTo(i.left,o),l.lineTo(i.left+i.width,o),l.strokeStyle=s.stroke??"red",l.lineWidth=s.width??1,s.dash&&l.setLineDash(s.dash),l.stroke(),s.dash&&l.setLineDash([])}function _t(e,t,n,s={}){const{ctx:l,plotBox:i}=e,o=j(n,t,i.width,i.left);l.beginPath(),l.moveTo(o,i.top),l.lineTo(o,i.top+i.height),l.strokeStyle=s.stroke??"red",l.lineWidth=s.width??1,s.dash&&l.setLineDash(s.dash),l.stroke(),s.dash&&l.setLineDash([])}function Ps(e,t,n,s,l,i,o={}){const{ctx:r,plotBox:a}=e,f=j(s,t,a.width,a.left),u=j(l,n,a.height,a.top);r.font=o.font??"12px sans-serif",r.fillStyle=o.fill??"#000",r.textBaseline="bottom",r.fillText(i,f,u-4)}function Et(e,t,n,s,l={}){const{ctx:i,plotBox:o}=e,r=j(s,t,o.height,o.top),a=j(n,t,o.height,o.top);i.fillStyle=l.fill??"rgba(255,0,0,0.1)",i.fillRect(o.left,Math.min(r,a),o.width,Math.abs(a-r)),l.stroke&&(i.strokeStyle=l.stroke,i.lineWidth=l.width??1,l.dash&&i.setLineDash(l.dash),i.strokeRect(o.left,Math.min(r,a),o.width,Math.abs(a-r)),l.dash&&i.setLineDash([]))}function Rs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=s.yScale??"y",i=n.getScale(l);if(i!=null&&(Ft(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const o=n.valToY(s.value,l);if(o==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,o-4)}}),null}function Ds(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=s.xScale??"x",i=n.getScale(l);if(i!=null&&(_t(n,i,s.value,{stroke:s.stroke,width:s.width,dash:s.dash}),s.label!=null)){const o=n.valToX(s.value,l);if(o==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,o,a.top-4)}}),null}function zs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=n.getScale(s.yScale??"y");l!=null&&Et(n,l,s.yMin,s.yMax,{fill:s.fill,stroke:s.stroke,width:s.strokeWidth,dash:s.dash})}),null}function Fs(e){const t=A.useRef(e);return A.useLayoutEffect(()=>{t.current=e}),Me(n=>{const s=t.current,l=n.valToX(s.x,s.xScale??"x"),i=n.valToY(s.y,s.yScale??"y");if(l==null||i==null)return;const{ctx:o}=n;o.font=s.font??"12px sans-serif",o.fillStyle=s.fill??"#000",o.textAlign=s.align??"left",o.textBaseline=s.baseline??"bottom",o.fillText(s.text,l,i-4)}),null}function _s(e,t){const{window:n,batchSize:s=1}=t,l=t.autoStart??!0,[i,o]=A.useState(()=>Xe(e)),[r,a]=A.useState(!1),[f,u]=A.useState(0),d=A.useRef(0),c=A.useRef(0),h=A.useRef(0),m=A.useRef(new Map),v=A.useRef(0),C=A.useRef(n);C.current=n;const g=A.useRef(s);g.current=s;const y=A.useCallback((D,S,...M)=>{let P=m.current.get(D);P==null&&(P={x:[],series:M.map(()=>[])},m.current.set(D,P)),P.x.push(...S);for(let p=0;p<M.length;p++){let w=P.series[p];w==null&&(w=[],P.series[p]=w),w.push(...M[p]??[])}const R=P.x.length;v.current===0&&R>=g.current&&(v.current=requestAnimationFrame(()=>{v.current=0;const p=m.current;m.current=new Map;const w=C.current;o(x=>{const b=x.slice();for(const[k,{x:I,series:z}]of p){const _=b[k];if(_==null)continue;const F=_.x,H=Math.max(0,F.length+I.length-w),G=H>0?F.slice(H).concat(I):F.concat(I),$=_.series.map((V,U)=>{const J=V,pe=z[U]??[];return H>0?J.slice(H).concat(pe):J.concat(pe)});b[k]={x:G,series:$}}return b})}))},[]),L=A.useCallback((D,...S)=>{y(0,D,...S)},[y]),T=A.useCallback(()=>{a(!0)},[]),E=A.useCallback(()=>{a(!1)},[]);return A.useEffect(()=>{if(!r){d.current!==0&&(cancelAnimationFrame(d.current),d.current=0);return}h.current=performance.now(),c.current=0;const D=S=>{c.current++;const M=S-h.current;M>=1e3&&(u(Math.round(c.current*1e3/M)),c.current=0,h.current=S),d.current=requestAnimationFrame(D)};return d.current=requestAnimationFrame(D),()=>{d.current!==0&&(cancelAnimationFrame(d.current),d.current=0)}},[r]),A.useEffect(()=>()=>{v.current!==0&&cancelAnimationFrame(v.current)},[]),A.useEffect(()=>{l&&a(!0)},[l]),{data:i,push:L,pushGroup:y,start:T,stop:E,running:r,fps:f}}function Es(e){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=(h==null?void 0:h.align)??e??1,v=(h==null?void 0:h.spanGaps)??!1;if([f,u]=Pe(n,f,u),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const C=P=>c(j(P,s,i,r)),g=P=>c(j(P,l,o,a)),y=s.ori===B.Horizontal?Re:De,L={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null},T=L.stroke;let E=!1;const D=d===K.Forward?f:u;let S=g(n[D]),M=C(t[D]);y(T,M,S);for(let P=D;P>=f&&P<=u;P+=d){const R=n[P];if(R==null){R===null&&!v&&(E=!0);continue}const p=C(t[P]),w=g(R);if(m===1)y(T,p,S);else if(m===-1)y(T,M,w);else{const x=c((M+p)/2);y(T,x,S),y(T,x,w)}y(T,p,w),S=w,M=p}{const P=L.fill=new Path2D(T),R=(h==null?void 0:h.fillTo)??l.min??0,p=g(R);let w=r,x=r+i;d===K.Backward&&([x,w]=[w,x]),y(P,x,p),y(P,w,p)}if(E){const P=je(t,n,f,u,d,C);L.gaps=P,L.clip=Be(P,s.ori,r,a,i,o)}return L}}function Ht(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.barWidth)??.6,m=(c==null?void 0:c.barGap)??0,v=(c==null?void 0:c.barRadius)??0,C=(c==null?void 0:c.barGroupIdx)??0,g=(c==null?void 0:c.barGroupCount)??1,y=x=>d(j(x,n,l,o)),L=x=>d(j(x,s,i,r));let T=l;if(f>a){let x=1/0,b=-1;for(let k=a;k<=f;k++)if(t[k]!=null){if(b>=0){const I=e[k],z=e[b],_=Math.abs(y(I)-y(z));_<x&&(x=_)}b=k}x<1/0&&(T=x)}const E=T*(1-h),D=Math.max(0,E+m),S=Math.max(1,d(T-D)),M=g>1?Math.max(1,d(S/Math.max(1,g))):S,P=(c==null?void 0:c.fillTo)??s.min??0,R=L(P),p=new Path2D,w=n.ori===B.Horizontal;for(let x=u===K.Forward?a:f;x>=a&&x<=f;x+=u){const b=t[x];if(b==null)continue;const k=y(e[x]),I=L(b),z=g>1?(C-(g-1)/2)*M:0,_=d(k-M/2+z),F=Math.min(I,R),G=Math.max(I,R)-F;if(G!==0)if(v>0){const $=Math.min(v*M,G/2);Gt(p,w,_,F,M,G,$,b<P)}else w?p.rect(_,F,M,G):p.rect(F,_,G,M)}return{stroke:p,fill:p,clip:null,band:null,gaps:null}}}function Hs(e,t){const n=Ht();return(s,l,i,o,r,a,f,u,d,c,h,m,v)=>{const C={...v,barGroupIdx:e,barGroupCount:t};return n(s,l,i,o,r,a,f,u,d,c,h,m,C)}}function Gs(){return(e,t,n,s,l,i,o,r,a,f,u,d,c)=>{const h=(c==null?void 0:c.barWidth)??.8,m=(c==null?void 0:c.barGap)??0,v=(c==null?void 0:c.barRadius)??0,C=R=>d(j(R,n,l,o)),g=R=>d(j(R,s,i,r));let y=l;if(f>a){let R=1/0,p=-1;for(let w=a;w<=f;w++)if(t[w]!=null){if(p>=0){const x=e[w],b=e[p],k=Math.abs(C(x)-C(b));k<R&&(R=k)}p=w}R<1/0&&(y=R)}const L=y*(1-h),T=Math.max(0,L+m),E=Math.max(1,d(y-T)),D=(c==null?void 0:c.fillTo)??s.min??0,S=g(D),M=new Path2D,P=n.ori===B.Horizontal;for(let R=u===K.Forward?a:f;R>=a&&R<=f;R+=u){const p=t[R];if(p==null)continue;const w=C(e[R]),x=g(p),b=d(w-E/2),k=Math.min(x,S),z=Math.max(x,S)-k;if(z!==0)if(v>0){const _=Math.min(v*E,z/2);Gt(M,P,b,k,E,z,_,p<D)}else P?M.rect(b,k,E,z):M.rect(k,b,z,E)}return{stroke:M,fill:M,clip:null,band:null,gaps:null}}}function Gt(e,t,n,s,l,i,o,r){o=Math.min(o,l/2,i/2),t?r?(e.moveTo(n,s),e.lineTo(n+l,s),e.lineTo(n+l,s+i-o),e.arc(n+l-o,s+i-o,o,0,Math.PI/2),e.lineTo(n+o,s+i),e.arc(n+o,s+i-o,o,Math.PI/2,Math.PI),e.closePath()):(e.moveTo(n,s+i),e.lineTo(n,s+o),e.arc(n+o,s+o,o,Math.PI,Math.PI*1.5),e.lineTo(n+l-o,s),e.arc(n+l-o,s+o,o,Math.PI*1.5,0),e.lineTo(n+l,s+i),e.closePath()):r?(e.moveTo(s,n),e.lineTo(s,n+l),e.lineTo(s+i-o,n+l),e.arc(s+i-o,n+l-o,o,Math.PI/2,0,!0),e.lineTo(s+i,n+o),e.arc(s+i-o,n+o,o,0,-Math.PI/2,!0),e.closePath()):(e.moveTo(s+i,n),e.lineTo(s+o,n),e.arc(s+o,n+o,o,-Math.PI/2,Math.PI,!0),e.lineTo(s,n+l-o),e.arc(s+o,n+l-o,o,Math.PI,Math.PI/2,!0),e.lineTo(s+i,n+l),e.closePath())}function $t(e){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=(h==null?void 0:h.spanGaps)??!1;if([f,u]=Pe(n,f,u),f===-1)return{stroke:new Path2D,fill:null,clip:null,band:null,gaps:null};const v=M=>c(j(M,s,i,r)),C=M=>c(j(M,l,o,a)),g=s.ori===B.Horizontal?Re:De,y=[],L=[];let T=!1;for(let M=d===K.Forward?f:u;M>=f&&M<=u;M+=d){const P=n[M];P!=null?(y.push(v(t[M])),L.push(C(P))):P===null&&!m&&(T=!0)}const E=s.ori===B.Horizontal,D=e(y,L,E,c),S={stroke:D??new Path2D,fill:null,clip:null,band:null,gaps:null};if(D!=null){const M=S.fill=new Path2D(D),P=(h==null?void 0:h.fillTo)??l.min??0,R=C(P);let p=r,w=r+i;d===K.Backward&&([w,p]=[p,w]),g(M,w,R),g(M,p,R)}if(T){const M=je(t,n,f,u,d,v);S.gaps=M,S.clip=Be(M,s.ori,r,a,i,o)}return S}}function $s(){return $t(Ws)}const Ws=(e,t,n,s)=>{const l=e.length;if(l<2)return null;const i=new Path2D,o=e[0]??0,r=t[0]??0;if(n?i.moveTo(o,r):i.moveTo(r,o),l===2){const c=e[1]??0,h=t[1]??0;return n?i.lineTo(c,h):i.lineTo(h,c),i}const a=new Array(l),f=new Array(l-1),u=new Array(l-1),d=new Array(l-1);for(let c=0;c<l-1;c++)u[c]=(t[c+1]??0)-(t[c]??0),d[c]=(e[c+1]??0)-(e[c]??0),f[c]=d[c]!==0?(u[c]??0)/(d[c]??1):0;a[0]=f[0]??0;for(let c=1;c<l-1;c++){const h=f[c]??0,m=f[c-1]??0;if(h===0||m===0||m>0!=h>0)a[c]=0;else{const v=d[c]??1,C=d[c-1]??1;a[c]=3*(C+v)/((2*v+C)/m+(v+2*C)/h),isFinite(a[c]??0)||(a[c]=0)}}a[l-1]=f[l-2]??0;for(let c=0;c<l-1;c++){const h=d[c]??1,m=e[c]??0,v=t[c]??0,C=e[c+1]??0,g=t[c+1]??0,y=a[c]??0,L=a[c+1]??0,T=m+h/3,E=v+y*h/3,D=C-h/3,S=g-L*h/3;n?i.bezierCurveTo(T,E,D,S,C,g):i.bezierCurveTo(E,T,S,D,g,C)}return i};function Vs(){return $t(js)}const js=(e,t,n,s)=>{const l=e.length;if(l<2)return null;const i=new Path2D,o=s(e[0]??0),r=s(t[0]??0);if(n?i.moveTo(o,r):i.moveTo(r,o),l===2){const a=s(e[1]??0),f=s(t[1]??0);return n?i.lineTo(a,f):i.lineTo(f,a),i}for(let a=0;a<l-1;a++){const f=a===0?0:a-1,u=e[f]??0,d=t[f]??0,c=e[a]??0,h=t[a]??0,m=e[a+1]??0,v=t[a+1]??0,C=a+2<l?e[a+2]??0:m,g=a+2<l?t[a+2]??0:v,y=Math.hypot(u-c,d-h),L=Math.hypot(c-m,h-v),T=Math.hypot(m-C,v-g),E=Math.sqrt(T),D=T,S=Math.sqrt(L),M=L,P=Math.sqrt(y),R=y,p=2*R+3*P*S+M,w=2*D+3*E*S+M,x=3*P*(P+S),b=3*E*(E+S);let k,I,z,_;if(x>0){const F=1/x;k=(-M*u+p*c+R*m)*F,I=(-M*d+p*h+R*v)*F}else k=c,I=h;if(b>0){const F=1/b;z=(D*c+w*m-M*C)*F,_=(D*h+w*v-M*g)*F}else z=m,_=v;n?i.bezierCurveTo(k,I,z,_,m,v):i.bezierCurveTo(I,k,_,z,v,m)}return i};function Bs(e=4){return(t,n,s,l,i,o,r,a,f,u,d,c,h)=>{const m=L=>c(j(L,s,i,r)),v=L=>c(j(L,l,o,a)),C=e/2,g=new Path2D,y=s.ori===B.Horizontal;for(let L=d===K.Forward?f:u;L>=f&&L<=u;L+=d){const T=n[L];if(T==null)continue;const E=m(t[L]),D=v(T);y?(g.moveTo(E+C,D),g.arc(E,D,C,0,Math.PI*2)):(g.moveTo(D+C,E),g.arc(D,E,C,0,Math.PI*2))}return{stroke:g,fill:g,clip:null,band:null,gaps:null}}}function Xs(e){return({ctx:t,plotBox:n,pxRatio:s})=>{const{xValues:l,open:i,high:o,low:r,close:a,xScale:f,yScale:u,upColor:d="#26a69a",downColor:c="#ef5350",bodyWidth:h=.6,wickWidth:m=1}=e;if(f.min==null||f.max==null||u.min==null||u.max==null)return;const v=l.length;if(v===0)return;const g=Math.max(2,n.width/v*h)*s/2;t.save();for(let y=0;y<v;y++){const L=l[y],T=i[y],E=o[y],D=r[y],S=a[y];if(L==null||T==null||E==null||D==null||S==null)continue;const M=j(L,f,n.width,n.left)*s,P=j(T,u,n.height,n.top)*s,R=j(E,u,n.height,n.top)*s,p=j(D,u,n.height,n.top)*s,w=j(S,u,n.height,n.top)*s,b=S>=T?d:c;t.strokeStyle=b,t.lineWidth=m*s,t.beginPath(),t.moveTo(M,R),t.lineTo(M,p),t.stroke();const k=Math.min(P,w),I=Math.abs(w-P);t.fillStyle=b,t.fillRect(M-g,k,g*2,Math.max(I,1*s))}t.restore()}}function Ys(e,t,n=0){const s=t??e.series.map((u,d)=>d),l=e.x.length,i=[],o=new Float64Array(l);for(let u=0;u<s.length;u++){const d=s[u];if(d==null)continue;const c=e.series[d];if(c==null)continue;const h=new Array(l);for(let m=0;m<l;m++){const v=c[m];v!=null?(o[m]=o[m]+v,h[m]=o[m]):h[m]=null}i.push(h)}const r=new Map;for(let u=0;u<s.length;u++){const d=s[u];d!=null&&r.set(d,u)}const a=[];for(let u=0;u<e.series.length;u++){const d=r.get(u)??-1,c=d>=0?i[d]:void 0;c!=null?a.push(c):a.push(e.series[u]??[])}const f=[];for(let u=s.length-1;u>0;u--){const d=s[u],c=s[u-1];d!=null&&c!=null&&f.push({group:n,series:[d,c]})}return{group:{x:e.x,series:a},bands:f}}function Ks(e){const t=new Set;for(const[i]of e)for(let o=0;o<i.length;o++){const r=i[o];r!=null&&t.add(r)}const n=Float64Array.from([...t].sort((i,o)=>i-o)),s=new Map;for(let i=0;i<n.length;i++){const o=n[i];o!=null&&s.set(o,i)}const l=[];for(const[i,o]of e){const r=new Array(n.length).fill(null);for(let a=0;a<i.length;a++){const f=i[a];if(f==null)continue;const u=s.get(f);u!=null&&(r[u]=o[a]??null)}l.push(r)}return[{x:n,series:l}]}function Us(e){const t=(e==null?void 0:e.decimals)??1;return n=>n.map(s=>{const l=Math.abs(s);return l>=1e9?(s/1e9).toFixed(t)+"B":l>=1e6?(s/1e6).toFixed(t)+"M":l>=1e3?(s/1e3).toFixed(t)+"K":s.toFixed(l>=1?0:t)})}function Ns(e,t=0){return n=>n.map(s=>s.toFixed(t)+e)}function Os(e,t=0){return n=>n.map(s=>e+s.toFixed(t))}function qs(e,t,n=0){return s=>s.map(l=>e+l.toFixed(n)+t)}function Zs(e){const t=(e==null?void 0:e.utc)??!1;return n=>n.map(s=>t?ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1},"UTC"):ee(s,{hour:"2-digit",minute:"2-digit",hour12:!1}))}function Js(e){const t=e!=null&&e.utc?"UTC":void 0,n=(e==null?void 0:e.format)??"short";return s=>s.map(l=>ee(l,{month:n},t))}function Qs(e){const{tz:t,...n}=e??{};return s=>s.map(l=>ee(l,n,t))}function eo(e,t=0){return n=>n.map(s=>{const l=Math.round(s)-t;return e[l]??String(s)})}function Wt(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 to(e,t=.8,n=0){const s=Wt(e);if(s==null)return{type:"linear",stops:[[0,e],[1,e]]};const[l,i,o]=s;return{type:"linear",stops:[[0,`rgba(${l},${i},${o},${t})`],[1,`rgba(${l},${i},${o},${n})`]]}}function no(e,t){const n=Wt(e);if(n==null)return e;const[s,l,i]=n;return`rgba(${s},${l},${i},${t})`}function so(e,t=65,n=50){const s=[];for(let i=0;i<e;i++){const o=i*137.508%360;s.push(`hsl(${o.toFixed(1)},${t}%,${n}%)`)}return s}exports.AnnotationLabel=Fs;exports.Axis=Ae;exports.Band=us;exports.Chart=Ye;exports.Direction=K;exports.Distribution=N;exports.FloatingLegend=As;exports.HLine=Rs;exports.HoverLabel=Ls;exports.Legend=ms;exports.Orientation=B;exports.Region=zs;exports.Scale=Ie;exports.Series=Ue;exports.Side=Y;exports.SortOrder=xe;exports.Sparkline=Ts;exports.Timeline=ks;exports.Tooltip=Ms;exports.VLine=Ds;exports.ZoomRanger=ys;exports.alignData=Ks;exports.bars=Ht;exports.catmullRom=Vs;exports.drawCandlesticks=Xs;exports.drawHLine=Ft;exports.drawLabel=Ps;exports.drawRegion=Et;exports.drawVLine=_t;exports.fadeGradient=to;exports.fmtCompact=Us;exports.fmtDateStr=Qs;exports.fmtHourMin=Zs;exports.fmtLabels=eo;exports.fmtMonthName=Js;exports.fmtPrefix=Os;exports.fmtSuffix=Ns;exports.fmtWrap=qs;exports.groupedBars=Hs;exports.linear=At;exports.monotoneCubic=$s;exports.palette=so;exports.points=Bs;exports.posToVal=se;exports.sideOrientation=ge;exports.stackGroup=Ys;exports.stackedBars=Gs;exports.stepped=Es;exports.useChart=Q;exports.useCursorDrawHook=Cs;exports.useDrawHook=Me;exports.useStreamingData=_s;exports.valToPos=j;exports.withAlpha=no;