@canplot/react 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canplot.mjs CHANGED
@@ -1,27 +1,27 @@
1
1
  import { jsxs as ht, jsx as A, Fragment as It } from "react/jsx-runtime";
2
- import Q, { createContext as Ct, useContext as tt, useRef as D, useLayoutEffect as z, useEffect as Mt, version as Ut, forwardRef as Xt, useMemo as et, useState as V, useId as Kt } from "react";
2
+ import Q, { createContext as Ct, useContext as tt, useRef as _, useLayoutEffect as z, useEffect as Mt, version as Ut, forwardRef as Xt, useMemo as et, useState as V, useId as Kt } from "react";
3
3
  import { createStore as Et, useStore as Pt } from "zustand";
4
- const j = (t, n, e) => Math.min(Math.max(t, n), e), fe = (t) => t.reduce((n, e) => n + (e ?? 0), 0), me = (t, n) => {
5
- let e = 0;
6
- for (let s = 0; s < t.length; s++)
7
- Math.abs(t[s] - n) < Math.abs(t[e] - n) && (e = s);
8
- return e;
9
- }, Ot = (t, n, e, s) => {
10
- const { min: o, max: i, origin: r } = I(t, e), d = s === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = (r === "x" ? d.width : d.height) / (i - o);
11
- return n / l;
12
- }, I = (t, n) => {
13
- const e = t.scales.find((s) => s.id === n);
14
- if (!e)
15
- throw new Error(`Scale ${n} not found`);
16
- return e;
17
- }, _ = (t, n) => {
18
- const e = window.devicePixelRatio || 1;
19
- t.lineCap = n?.lineCap ?? "butt", t.lineDashOffset = e * (n?.lineDashOffset ?? 0), t.lineJoin = n?.lineJoin ?? "miter", t.lineWidth = e * (n?.lineWidth ?? 1), t.miterLimit = e * (n?.miterLimit ?? 10), t.strokeStyle = n?.strokeStyle ?? "black", t.fillStyle = n?.fillStyle ?? t.strokeStyle, t.font = n?.font ?? `${10 * e}px sans-serif`, t.textAlign = n?.textAlign ?? "start", t.direction = n?.direction ?? "inherit", t.textBaseline = n?.textBaseline ?? "alphabetic", t.fontKerning = n?.fontKerning ?? "auto";
20
- }, ft = (t, n, e, s) => {
21
- const o = s === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: i, max: r, origin: d } = I(t, e), l = (d === "x" ? o.width : o.height) / (r - i);
22
- return n * l;
23
- }, H = (t, n, e, s) => {
24
- const { min: o, origin: i } = I(t, e), r = s === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = ft(t, n - o, e, s);
4
+ const j = (n, e, t) => Math.min(Math.max(n, e), t), fe = (n) => n.reduce((e, t) => e + (t ?? 0), 0), me = (n, e) => {
5
+ let t = 0;
6
+ for (let s = 0; s < n.length; s++)
7
+ Math.abs(n[s] - e) < Math.abs(n[t] - e) && (t = s);
8
+ return t;
9
+ }, Ot = (n, e, t, s) => {
10
+ const { min: o, max: i, origin: r } = I(n, t), d = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, h = (r === "x" ? d.width : d.height) / (i - o);
11
+ return e / h;
12
+ }, I = (n, e) => {
13
+ const t = n.scales.find((s) => s.id === e);
14
+ if (!t)
15
+ throw new Error(`Scale ${e} not found`);
16
+ return t;
17
+ }, D = (n, e) => {
18
+ const t = window.devicePixelRatio || 1;
19
+ n.lineCap = e?.lineCap ?? "butt", n.lineDashOffset = t * (e?.lineDashOffset ?? 0), n.lineJoin = e?.lineJoin ?? "miter", n.lineWidth = t * (e?.lineWidth ?? 1), n.miterLimit = t * (e?.miterLimit ?? 10), n.strokeStyle = e?.strokeStyle ?? "black", n.fillStyle = e?.fillStyle ?? n.strokeStyle, n.font = e?.font ?? `${10 * t}px sans-serif`, n.textAlign = e?.textAlign ?? "start", n.direction = e?.direction ?? "inherit", n.textBaseline = e?.textBaseline ?? "alphabetic", n.fontKerning = e?.fontKerning ?? "auto";
20
+ }, ft = (n, e, t, s) => {
21
+ const o = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, { min: i, max: r, origin: d } = I(n, t), h = (d === "x" ? o.width : o.height) / (r - i);
22
+ return e * h;
23
+ }, H = (n, e, t, s) => {
24
+ const { min: o, origin: i } = I(n, t), r = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, d = ft(n, e - o, t, s);
25
25
  return i === "x" ? j(
26
26
  r.x + d,
27
27
  r.x - 10 * r.width,
@@ -31,26 +31,26 @@ const j = (t, n, e) => Math.min(Math.max(t, n), e), fe = (t) => t.reduce((n, e)
31
31
  r.y - 10 * r.height,
32
32
  r.y + 11 * r.height
33
33
  );
34
- }, pe = (t, n, e) => {
35
- const { min: s, max: o } = I(t, e);
36
- return j(n, s, o);
37
- }, Y = (t, n, e) => {
38
- const s = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
39
- return j(n, s.x, s.x + s.width);
40
- }, B = (t, n, e) => {
41
- const s = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
42
- return j(n, s.y, s.y + s.height);
43
- }, lt = (t, n, e) => {
44
- const { min: s, max: o } = I(t, e);
45
- return n >= s && n <= o;
46
- }, L = (t, n, e, s) => {
47
- const { min: o, max: i, origin: r } = I(t, e), d = s === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, l = r === "x" ? (n - d.x) / d.width : (d.height - n + d.y) / d.height;
48
- return o + l * (i - o);
49
- }, Ft = (t) => {
50
- const { ctx: n, scales: e } = t;
51
- for (const s of e) {
34
+ }, pe = (n, e, t) => {
35
+ const { min: s, max: o } = I(n, t);
36
+ return j(e, s, o);
37
+ }, Y = (n, e, t) => {
38
+ const s = t === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS;
39
+ return j(e, s.x, s.x + s.width);
40
+ }, B = (n, e, t) => {
41
+ const s = t === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS;
42
+ return j(e, s.y, s.y + s.height);
43
+ }, lt = (n, e, t) => {
44
+ const { min: s, max: o } = I(n, t);
45
+ return e >= s && e <= o;
46
+ }, L = (n, e, t, s) => {
47
+ const { min: o, max: i, origin: r } = I(n, t), d = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, h = r === "x" ? (e - d.x) / d.width : (d.height - e + d.y) / d.height;
48
+ return o + h * (i - o);
49
+ }, Ft = (n) => {
50
+ const { ctx: e, scales: t } = n;
51
+ for (const s of t) {
52
52
  if (!s.axis) continue;
53
- n.save(), _(n, {
53
+ e.save(), D(e, {
54
54
  strokeStyle: "black",
55
55
  fillStyle: "black",
56
56
  lineWidth: 1,
@@ -59,131 +59,131 @@ const j = (t, n, e) => Math.min(Math.max(t, n), e), fe = (t) => t.reduce((n, e)
59
59
  const o = s.axis.canvasRect;
60
60
  if (s.origin === "x") {
61
61
  if (s.axis.position === "bottom")
62
- n.beginPath(), n.moveTo(o.x, o.y), n.lineTo(o.x + o.width, o.y), n.stroke();
62
+ e.beginPath(), e.moveTo(o.x, o.y), e.lineTo(o.x + o.width, o.y), e.stroke();
63
63
  else if (s.axis.position === "top") {
64
64
  const i = o.y + o.height;
65
- n.beginPath(), n.moveTo(o.x, i), n.lineTo(o.x + o.width, i), n.stroke();
65
+ e.beginPath(), e.moveTo(o.x, i), e.lineTo(o.x + o.width, i), e.stroke();
66
66
  }
67
67
  } else if (s.axis.position === "left") {
68
68
  const i = o.x + o.width;
69
- n.beginPath(), n.moveTo(i, o.y), n.lineTo(i, o.y + o.height), n.stroke();
70
- } else s.axis.position === "right" && (n.beginPath(), n.moveTo(o.x, o.y), n.lineTo(o.x, o.y + o.height), n.stroke());
71
- n.restore();
69
+ e.beginPath(), e.moveTo(i, o.y), e.lineTo(i, o.y + o.height), e.stroke();
70
+ } else s.axis.position === "right" && (e.beginPath(), e.moveTo(o.x, o.y), e.lineTo(o.x, o.y + o.height), e.stroke());
71
+ e.restore();
72
72
  }
73
73
  }, ut = {
74
74
  TOP: 300,
75
75
  MIDDLE: 200,
76
76
  BOTTOM: 200,
77
77
  BACKGROUND: 100
78
- }, zt = () => Et((t, n) => {
79
- const e = () => {
80
- const s = n()._frame;
78
+ }, zt = () => Et((n, e) => {
79
+ const t = () => {
80
+ const s = e()._frame;
81
81
  if (!s) throw new Error("No frame set in frame store");
82
82
  return s;
83
83
  };
84
84
  return {
85
85
  _frame: null,
86
- getFrame: e,
87
- getCtx: () => e().ctx,
88
- clampXPosToChartArea: (s, o) => Y(e(), s, o ?? "canvas"),
89
- clampYPosToChartArea: (s, o) => B(e(), s, o ?? "canvas"),
90
- valToPos: (s, o, i) => H(e(), s, o, i ?? "canvas"),
86
+ getFrame: t,
87
+ getCtx: () => t().ctx,
88
+ clampXPosToChartArea: (s, o) => Y(t(), s, o ?? "canvas"),
89
+ clampYPosToChartArea: (s, o) => B(t(), s, o ?? "canvas"),
90
+ valToPos: (s, o, i) => H(t(), s, o, i ?? "canvas"),
91
91
  valToPxDistance: (s, o, i) => ft(
92
- e(),
92
+ t(),
93
93
  s,
94
94
  o,
95
95
  i ?? "canvas"
96
96
  ),
97
- valFits: (s, o) => lt(e(), s, o),
98
- getScale: (s) => I(e(), s),
97
+ valFits: (s, o) => lt(t(), s, o),
98
+ getScale: (s) => I(t(), s),
99
99
  _listeners: [],
100
- _subscribe: (s, o) => (n()._listeners.push([o, s]), n()._listeners.sort((i, r) => i[0] - r[0]), () => {
101
- const i = n()._listeners.findIndex(([, r]) => r === s);
102
- i !== -1 && n()._listeners.splice(i, 1);
100
+ _subscribe: (s, o) => (e()._listeners.push([o, s]), e()._listeners.sort((i, r) => i[0] - r[0]), () => {
101
+ const i = e()._listeners.findIndex(([, r]) => r === s);
102
+ i !== -1 && e()._listeners.splice(i, 1);
103
103
  }),
104
104
  _notifyListeners: (s) => {
105
- for (const [, o] of n()._listeners)
105
+ for (const [, o] of e()._listeners)
106
106
  o(s);
107
107
  }
108
108
  };
109
- }), Yt = () => Et((t) => ({
109
+ }), Yt = () => Et((n) => ({
110
110
  notify: () => {
111
- t((n) => ({ version: n.version + 1 }));
111
+ n((e) => ({ version: e.version + 1 }));
112
112
  },
113
113
  version: 0
114
- })), mt = Ct(null), kt = Ct(null), F = (t, n, e) => {
114
+ })), mt = Ct(null), kt = Ct(null), F = (n, e, t) => {
115
115
  const s = tt(mt), o = tt(kt);
116
116
  if (!s || !o)
117
117
  throw new Error("useFrame must be used within a CanPlot component");
118
- const i = D(n);
119
- i.current = n, z(() => (Promise.resolve().then(() => {
118
+ const i = _(e);
119
+ i.current = e, z(() => (Promise.resolve().then(() => {
120
120
  i.current(s.getState());
121
121
  }), s.getState()._subscribe(
122
122
  (r) => {
123
123
  r._frame && i.current(r);
124
124
  },
125
- typeof t == "number" ? t : ut[t]
126
- )), [s, t]), Mt(() => {
125
+ typeof n == "number" ? n : ut[n]
126
+ )), [s, n]), Mt(() => {
127
127
  o.getState().notify();
128
- }, [o, ...e]);
129
- }, pt = (t) => {
130
- const n = tt(mt);
131
- if (!n)
128
+ }, [o, ...t]);
129
+ }, pt = (n) => {
130
+ const e = tt(mt);
131
+ if (!e)
132
132
  throw new Error("useFrame must be used within a CanPlot component");
133
133
  return Pt(
134
- n,
135
- t ?? ((e) => e.getFrame())
134
+ e,
135
+ n ?? ((t) => t.getFrame())
136
136
  );
137
137
  };
138
- function Bt(t) {
139
- return (n) => {
140
- for (const e of t) dt(e, n);
138
+ function Bt(n) {
139
+ return (e) => {
140
+ for (const t of n) dt(t, e);
141
141
  };
142
142
  }
143
- function Nt(t) {
144
- return (n) => {
145
- const e = [];
146
- for (const s of t) {
147
- const o = dt(s, n), i = typeof o == "function";
148
- e.push(i ? o : () => dt(s, null));
143
+ function Nt(n) {
144
+ return (e) => {
145
+ const t = [];
146
+ for (const s of n) {
147
+ const o = dt(s, e), i = typeof o == "function";
148
+ t.push(i ? o : () => dt(s, null));
149
149
  }
150
150
  return () => {
151
- for (const s of e) s();
151
+ for (const s of t) s();
152
152
  };
153
153
  };
154
154
  }
155
- function dt(t, n) {
156
- if (typeof t == "function")
157
- return t(n);
158
- t && (t.current = n);
155
+ function dt(n, e) {
156
+ if (typeof n == "function")
157
+ return n(e);
158
+ n && (n.current = e);
159
159
  }
160
160
  var $t = parseInt(Ut.split(".")[0], 10) >= 19 ? Nt : Bt;
161
- const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) => {
162
- const i = D(null), r = D(null), d = jt(r), l = et(zt, []), c = et(Yt, []);
161
+ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) => {
162
+ const i = _(null), r = _(null), d = jt(r), h = et(zt, []), u = et(Yt, []);
163
163
  z(() => {
164
- l.setState({
165
- _frame: Ht(t, d, i.current)
164
+ h.setState({
165
+ _frame: Ht(n, d, i.current)
166
166
  });
167
- const m = l.getState();
168
- m._notifyListeners(m);
169
- }, [t, d, i, l]), z(() => l.getState()._subscribe((m) => {
170
- const h = m._frame?.ctx;
171
- h && h.clearRect(0, 0, h.canvas.width, h.canvas.height);
172
- }, ut.BACKGROUND), [l]), z(() => l.getState()._subscribe((m) => {
173
- m._frame && Ft(m._frame);
174
- }, ut.BOTTOM), [l]), z(() => {
175
- let m = !1;
176
- return c.subscribe(() => {
177
- m || (m = !0, window.requestAnimationFrame(() => {
178
- m = !1, l.setState((f) => ({
179
- _frame: f._frame ? { ...f._frame } : null
167
+ const c = h.getState();
168
+ c._notifyListeners(c);
169
+ }, [n, d, i, h]), z(() => h.getState()._subscribe((c) => {
170
+ const f = c._frame?.ctx;
171
+ f && f.clearRect(0, 0, f.canvas.width, f.canvas.height);
172
+ }, ut.BACKGROUND), [h]), z(() => h.getState()._subscribe((c) => {
173
+ c._frame && Ft(c._frame);
174
+ }, ut.BOTTOM), [h]), z(() => {
175
+ let c = !1;
176
+ return u.subscribe(() => {
177
+ c || (c = !0, window.requestAnimationFrame(() => {
178
+ c = !1, h.setState((a) => ({
179
+ _frame: a._frame ? { ...a._frame } : null
180
180
  }));
181
- const h = l.getState();
182
- h._notifyListeners(h);
181
+ const f = h.getState();
182
+ f._notifyListeners(f);
183
183
  }));
184
184
  });
185
- }, [c, l]);
186
- const a = window.devicePixelRatio || 1;
185
+ }, [u, h]);
186
+ const m = window.devicePixelRatio || 1;
187
187
  return /* @__PURE__ */ ht(
188
188
  "div",
189
189
  {
@@ -192,7 +192,7 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
192
192
  style: {
193
193
  position: "relative",
194
194
  overflow: "hidden",
195
- ...e
195
+ ...t
196
196
  },
197
197
  "data-canplotroot": !0,
198
198
  children: [
@@ -200,8 +200,8 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
200
200
  "canvas",
201
201
  {
202
202
  ref: i,
203
- width: d.width * a,
204
- height: d.height * a,
203
+ width: d.width * m,
204
+ height: d.height * m,
205
205
  style: {
206
206
  inset: 0,
207
207
  position: "absolute",
@@ -213,79 +213,79 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
213
213
  /* @__PURE__ */ A(
214
214
  Vt,
215
215
  {
216
- frameStore: l,
217
- updateRequestStore: c,
218
- children: n
216
+ frameStore: h,
217
+ updateRequestStore: u,
218
+ children: e
219
219
  }
220
220
  )
221
221
  ]
222
222
  }
223
223
  );
224
- }), Vt = ({ frameStore: t, updateRequestStore: n, children: e }) => Pt(t, (o) => !!o._frame) ? /* @__PURE__ */ A(kt.Provider, { value: n, children: /* @__PURE__ */ A(mt.Provider, { value: t, children: e }) }) : null, jt = (t) => {
225
- const [n, e] = V({
224
+ }), Vt = ({ frameStore: n, updateRequestStore: e, children: t }) => Pt(n, (o) => !!o._frame) ? /* @__PURE__ */ A(kt.Provider, { value: e, children: /* @__PURE__ */ A(mt.Provider, { value: n, children: t }) }) : null, jt = (n) => {
225
+ const [e, t] = V({
226
226
  width: 0,
227
227
  height: 0
228
228
  }), [s] = V(() => new ResizeObserver((o) => {
229
229
  for (const i of o) {
230
230
  const r = Math.round(i.contentRect.width), d = Math.round(i.contentRect.height);
231
- e(
232
- (l) => l.width !== r || l.height !== d ? { ...l, width: r, height: d } : l
231
+ t(
232
+ (h) => h.width !== r || h.height !== d ? { ...h, width: r, height: d } : h
233
233
  );
234
234
  }
235
235
  }));
236
236
  return z(() => {
237
- if (!t.current) return;
238
- const o = t.current.clientWidth, i = t.current.clientHeight;
239
- return e(
237
+ if (!n.current) return;
238
+ const o = n.current.clientWidth, i = n.current.clientHeight;
239
+ return t(
240
240
  (r) => r.width !== o || r.height !== i ? { ...r, width: o, height: i } : r
241
- ), s.observe(t.current, { box: "border-box" }), () => s.disconnect();
242
- }, [s, t]), n;
243
- }, Ht = (t, n, e) => {
244
- const s = e?.getContext("2d");
241
+ ), s.observe(n.current, { box: "border-box" }), () => s.disconnect();
242
+ }, [s, n]), e;
243
+ }, Ht = (n, e, t) => {
244
+ const s = t?.getContext("2d");
245
245
  if (!s) return null;
246
246
  const o = window.devicePixelRatio || 1;
247
- if (n.width === 0 || n.height === 0)
247
+ if (e.width === 0 || e.height === 0)
248
248
  return null;
249
249
  const i = {
250
- x: t.padding.left,
251
- y: t.padding.top,
252
- width: n.width - t.padding.left - t.padding.right,
253
- height: n.height - t.padding.top - t.padding.bottom
250
+ x: n.padding.left,
251
+ y: n.padding.top,
252
+ width: e.width - n.padding.left - n.padding.right,
253
+ height: e.height - n.padding.top - n.padding.bottom
254
254
  };
255
- for (const f of t.scales)
256
- f.axis && (f.origin === "x" ? (f.axis.position === "bottom" || f.axis.position === "top") && (i.height = Math.max(
255
+ for (const a of n.scales)
256
+ a.axis && (a.origin === "x" ? (a.axis.position === "bottom" || a.axis.position === "top") && (i.height = Math.max(
257
257
  0,
258
- i.height - f.axis.size
259
- ), f.axis.position === "top" && (i.y += f.axis.size)) : (f.axis.position === "left" || f.axis.position === "right") && (i.width = Math.max(0, i.width - f.axis.size), f.axis.position === "left" && (i.x += f.axis.size)));
258
+ i.height - a.axis.size
259
+ ), a.axis.position === "top" && (i.y += a.axis.size)) : (a.axis.position === "left" || a.axis.position === "right") && (i.width = Math.max(0, i.width - a.axis.size), a.axis.position === "left" && (i.x += a.axis.size)));
260
260
  const r = {
261
261
  x: i.x * o,
262
262
  y: i.y * o,
263
263
  width: i.width * o,
264
264
  height: i.height * o
265
265
  }, d = [];
266
- let l = t.padding.left * o, c = s.canvas.width - t.padding.right * o, a = s.canvas.height - t.padding.bottom * o, m = t.padding.top * o;
267
- for (const f of t.scales) {
268
- if (!f.axis) {
269
- d.push({ ...f, axis: null });
266
+ let h = n.padding.left * o, u = s.canvas.width - n.padding.right * o, m = s.canvas.height - n.padding.bottom * o, c = n.padding.top * o;
267
+ for (const a of n.scales) {
268
+ if (!a.axis) {
269
+ d.push({ ...a, axis: null });
270
270
  continue;
271
271
  }
272
- let u;
273
- if (f.origin === "x")
274
- switch (f.axis.position) {
272
+ let l;
273
+ if (a.origin === "x")
274
+ switch (a.axis.position) {
275
275
  case "bottom":
276
- a -= f.axis.size * o, u = {
276
+ m -= a.axis.size * o, l = {
277
277
  x: i.x,
278
- y: a / o,
278
+ y: m / o,
279
279
  width: i.width,
280
- height: f.axis.size
280
+ height: a.axis.size
281
281
  };
282
282
  break;
283
283
  case "top":
284
- m += f.axis.size * o, u = {
284
+ c += a.axis.size * o, l = {
285
285
  x: i.x,
286
- y: m / o - f.axis.size,
286
+ y: c / o - a.axis.size,
287
287
  width: i.width,
288
- height: f.axis.size
288
+ height: a.axis.size
289
289
  };
290
290
  break;
291
291
  case "left":
@@ -293,20 +293,20 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
293
293
  throw new Error("Invalid axis position for x origin");
294
294
  }
295
295
  else
296
- switch (f.axis.position) {
296
+ switch (a.axis.position) {
297
297
  case "left":
298
- l += f.axis.size * o, u = {
299
- x: l / o - f.axis.size,
298
+ h += a.axis.size * o, l = {
299
+ x: h / o - a.axis.size,
300
300
  y: i.y,
301
- width: f.axis.size,
301
+ width: a.axis.size,
302
302
  height: i.height
303
303
  };
304
304
  break;
305
305
  case "right":
306
- c -= f.axis.size * o, u = {
307
- x: c / o,
306
+ u -= a.axis.size * o, l = {
307
+ x: u / o,
308
308
  y: i.y,
309
- width: f.axis.size,
309
+ width: a.axis.size,
310
310
  height: i.height
311
311
  };
312
312
  break;
@@ -315,16 +315,16 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
315
315
  throw new Error("Invalid axis position for y origin");
316
316
  }
317
317
  const p = {
318
- x: u.x * o,
319
- y: u.y * o,
320
- width: u.width * o,
321
- height: u.height * o
318
+ x: l.x * o,
319
+ y: l.y * o,
320
+ width: l.width * o,
321
+ height: l.height * o
322
322
  };
323
323
  d.push({
324
- ...f,
324
+ ...a,
325
325
  axis: {
326
- ...f.axis,
327
- cssRect: u,
326
+ ...a.axis,
327
+ cssRect: l,
328
328
  canvasRect: p
329
329
  }
330
330
  });
@@ -332,212 +332,215 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
332
332
  return {
333
333
  ctx: s,
334
334
  dpr: o,
335
- padding: t.padding,
335
+ padding: n.padding,
336
336
  scales: d,
337
337
  chartAreaCSS: i,
338
338
  chartAreaCanvasPX: r
339
339
  };
340
- }, ye = ({ data: t, xScaleId: n, yScaleId: e, style: s }) => (F(
341
- "MIDDLE",
342
- ({ getCtx: o, clampXPosToChartArea: i, clampYPosToChartArea: r, valToPos: d }) => {
343
- const l = o();
344
- l.save(), l.beginPath(), _(l, s);
345
- for (const c of t) {
346
- const a = i(d(c.x, n)), m = r(d(c.y, e));
347
- l.lineTo(a, m);
340
+ }, ye = ({ layer: n = "MIDDLE", data: e, xScaleId: t, yScaleId: s, style: o }) => (F(
341
+ n,
342
+ ({ getCtx: i, clampXPosToChartArea: r, clampYPosToChartArea: d, valToPos: h }) => {
343
+ const u = i();
344
+ u.save(), u.beginPath(), D(u, o);
345
+ for (const m of e) {
346
+ const c = r(h(m.x, t)), f = d(h(m.y, s));
347
+ u.lineTo(c, f);
348
348
  }
349
- l.stroke(), l.restore();
349
+ u.stroke(), u.restore();
350
350
  },
351
- [t, n, e, s]
352
- ), null), ve = ({ data: t, xScaleId: n, yScaleId: e, radius: s = 5, style: o }) => (F(
353
- "MIDDLE",
354
- ({ getCtx: i, valToPos: r, valFits: d }) => {
355
- const l = i();
356
- l.save(), l.beginPath(), _(l, o);
357
- for (const c of t) {
358
- if (!d(c.x, n) || !d(c.y, e))
351
+ [e, t, s, o]
352
+ ), null), ve = ({ layer: n = "MIDDLE", data: e, xScaleId: t, yScaleId: s, radius: o = 5, style: i, globalAlpha: r }) => (F(
353
+ n,
354
+ ({ getCtx: d, valToPos: h, valFits: u }) => {
355
+ const m = d();
356
+ m.save(), m.beginPath();
357
+ const c = new Path2D();
358
+ D(m, i), r !== void 0 && (m.globalAlpha = r);
359
+ for (const f of e) {
360
+ if (!u(f.x, t) || !u(f.y, s))
359
361
  continue;
360
- const a = r(c.x, n), m = r(c.y, e);
361
- l.moveTo(a + s, m), l.arc(a, m, s, 0, Math.PI * 2);
362
+ const a = h(f.x, t), l = h(f.y, s);
363
+ c.moveTo(a + o, l), c.arc(a, l, o, 0, Math.PI * 2);
362
364
  }
363
- l.stroke(), l.fill(), l.restore();
365
+ m.fill(c), m.stroke(c), m.restore();
364
366
  },
365
- [t, n, e, s, o]
367
+ [e, t, s, o, i, r]
366
368
  ), null), ge = ({
367
- data: t,
368
- xScaleId: n,
369
- yScaleId: e,
369
+ data: n,
370
+ xScaleId: e,
371
+ yScaleId: t,
370
372
  style: s,
371
373
  barWidth: o,
372
374
  xPositionOffset: i,
373
- radius: r
375
+ radius: r,
376
+ layer: d = "MIDDLE"
374
377
  }) => (F(
375
- "MIDDLE",
378
+ d,
376
379
  ({
377
- getCtx: d,
378
- valToPxDistance: l,
379
- valToPos: c,
380
- clampXPosToChartArea: a,
381
- clampYPosToChartArea: m
380
+ getCtx: h,
381
+ valToPxDistance: u,
382
+ valToPos: m,
383
+ clampXPosToChartArea: c,
384
+ clampYPosToChartArea: f
382
385
  }) => {
383
- if (t.length === 0) return;
384
- const h = d();
385
- h.save(), _(h, s);
386
- const f = l(o, n);
387
- h.beginPath();
388
- for (const u of t) {
389
- const x = c(u.x, n) - f / 2 + i * f, v = m(c(0, e)), g = m(c(u.y, e)), y = v - g, b = a(x), S = a(x + f) - b;
390
- r ? h.roundRect(
391
- b,
392
- g,
386
+ if (n.length === 0) return;
387
+ const a = h();
388
+ a.save(), D(a, s);
389
+ const l = u(o, e);
390
+ a.beginPath();
391
+ for (const p of n) {
392
+ const x = m(p.x, e) - l / 2 + i * l, g = f(m(0, t)), y = f(m(p.y, t)), w = g - y, S = c(x), b = c(x + l) - S;
393
+ r ? a.roundRect(
393
394
  S,
394
395
  y,
396
+ b,
397
+ w,
395
398
  r
396
- ) : h.rect(b, g, S, y);
399
+ ) : a.rect(S, y, b, w);
397
400
  }
398
- h.closePath(), h.fill(), s?.strokeStyle && h.stroke(), h.restore();
401
+ a.closePath(), a.fill(), s?.strokeStyle && a.stroke(), a.restore();
399
402
  },
400
- [t, n, e, s, o, i, r]
401
- ), null), be = ({ data: t, xScaleId: n, yScaleId: e, style: s }) => (F(
402
- "MIDDLE",
403
- ({ getCtx: o, clampXPosToChartArea: i, clampYPosToChartArea: r, valToPos: d }) => {
404
- const l = [];
405
- for (const a of t) {
406
- const m = i(d(a.x, n)), h = r(d(a.y[0], e)), f = r(d(a.y[1], e));
407
- l.push({ x: m, y: h }), l.unshift({ x: m, y: f });
403
+ [n, e, t, s, o, i, r]
404
+ ), null), we = ({ layer: n = "MIDDLE", data: e, xScaleId: t, yScaleId: s, style: o }) => (F(
405
+ n,
406
+ ({ getCtx: i, clampXPosToChartArea: r, clampYPosToChartArea: d, valToPos: h }) => {
407
+ const u = [];
408
+ for (const c of e) {
409
+ const f = r(h(c.x, t)), a = d(h(c.y[0], s)), l = d(h(c.y[1], s));
410
+ u.push({ x: f, y: a }), u.unshift({ x: f, y: l });
408
411
  }
409
- const c = o();
410
- if (l.length > 0) {
411
- c.save(), c.beginPath(), _(c, s), c.moveTo(l[0].x, l[0].y);
412
- for (const a of l)
413
- c.lineTo(a.x, a.y);
414
- c.closePath(), c.fill(), c.restore();
412
+ const m = i();
413
+ if (u.length > 0) {
414
+ m.save(), m.beginPath(), D(m, o), m.moveTo(u[0].x, u[0].y);
415
+ for (const c of u)
416
+ m.lineTo(c.x, c.y);
417
+ m.closePath(), m.fill(), m.restore();
415
418
  }
416
419
  },
417
- [t, n, e, s]
418
- ), null), we = ({ data: t, stroked: n, xScaleId: e, yScaleId: s, style: o }) => (F(
419
- "MIDDLE",
420
- ({ getCtx: i, clampXPosToChartArea: r, clampYPosToChartArea: d, valToPos: l }) => {
421
- const c = [], a = i();
422
- for (const u of t) {
423
- const p = r(l(u.x, e)), x = d(l(u.y, s));
424
- c.push({ x: p, y: x });
420
+ [e, t, s, o]
421
+ ), null), be = ({ layer: n = "MIDDLE", data: e, stroked: t, xScaleId: s, yScaleId: o, style: i }) => (F(
422
+ n,
423
+ ({ getCtx: r, clampXPosToChartArea: d, clampYPosToChartArea: h, valToPos: u }) => {
424
+ const m = [], c = r();
425
+ for (const p of e) {
426
+ const v = d(u(p.x, s)), x = h(u(p.y, o));
427
+ m.push({ x: v, y: x });
425
428
  }
426
- const m = c.at(0), h = c.at(-1);
427
- if (!m || !h)
429
+ const f = m.at(0), a = m.at(-1);
430
+ if (!f || !a)
428
431
  return;
429
- const f = d(l(0, s));
430
- a.save(), a.beginPath(), _(a, o), a.moveTo(m.x, f);
431
- for (const u of c)
432
- a.lineTo(u.x, u.y);
433
- if (a.lineTo(h.x, f), a.closePath(), a.fill(), n) {
434
- a.beginPath(), a.moveTo(m.x, m.y);
435
- for (const u of c)
436
- a.lineTo(u.x, u.y);
437
- a.stroke();
432
+ const l = h(u(0, o));
433
+ c.save(), c.beginPath(), D(c, i), c.moveTo(f.x, l);
434
+ for (const p of m)
435
+ c.lineTo(p.x, p.y);
436
+ if (c.lineTo(a.x, l), c.closePath(), c.fill(), t) {
437
+ c.beginPath(), c.moveTo(f.x, f.y);
438
+ for (const p of m)
439
+ c.lineTo(p.x, p.y);
440
+ c.stroke();
438
441
  }
439
- a.restore();
442
+ c.restore();
440
443
  },
441
- [t, n, e, s, o]
442
- ), null), Se = (t, n) => pt(
444
+ [e, t, s, o, i]
445
+ ), null), Se = (n, e) => pt(
443
446
  ({
444
- clampXPosToChartArea: e,
447
+ clampXPosToChartArea: t,
445
448
  clampYPosToChartArea: s,
446
449
  getScale: o,
447
450
  valToPos: i,
448
451
  valFits: r
449
452
  }) => {
450
453
  const d = {};
451
- for (const l in t) {
452
- const c = t[l];
453
- switch (c.exceeding) {
454
+ for (const h in n) {
455
+ const u = n[h];
456
+ switch (u.exceeding) {
454
457
  case "discard": {
455
- if (r(c.value, c.scaleId)) {
456
- const a = i(c.value, c.scaleId, n);
457
- d[l] = a;
458
+ if (r(u.value, u.scaleId)) {
459
+ const m = i(u.value, u.scaleId, e);
460
+ d[h] = m;
458
461
  }
459
462
  break;
460
463
  }
461
464
  case "clamp": {
462
- const a = i(c.value, c.scaleId, n);
463
- d[l] = o(c.scaleId)?.origin === "x" ? e(a, n) : s(a, n);
465
+ const m = i(u.value, u.scaleId, e);
466
+ d[h] = o(u.scaleId)?.origin === "x" ? t(m, e) : s(m, e);
464
467
  break;
465
468
  }
466
469
  }
467
470
  }
468
471
  return d;
469
472
  }
470
- ), Te = ({ scaleId: t, tickStyle: n, labelStyle: e, labelGap: s, tickSize: o, ticks: i }) => (F(
471
- "BOTTOM",
472
- ({ getCtx: r, valToPos: d, getScale: l, getFrame: c }) => {
473
- const a = r(), m = l(t);
474
- if (!m || !m.axis || m.origin !== "x") return;
475
- const h = m.axis, f = h.position === "top" ? h.canvasRect.y + h.canvasRect.height : h.canvasRect.y, u = window.devicePixelRatio || 1, p = f, x = (o ?? 6) * u, v = h.position === "top" ? f - x : f + x, g = (s ?? 12) * u;
476
- a.save(), a.fontKerning = "auto", _(a, {
477
- ...n
478
- }), a.beginPath();
479
- const y = Array.isArray(i) ? i : i({ ...m, axis: h }, c());
480
- for (const { value: b } of y) {
481
- const S = d(b, t, "canvas");
482
- a.moveTo(S, p), a.lineTo(S, v);
473
+ ), Te = ({ layer: n = "BOTTOM", scaleId: e, tickStyle: t, labelStyle: s, labelGap: o, tickSize: i, ticks: r }) => (F(
474
+ n,
475
+ ({ getCtx: d, valToPos: h, getScale: u, getFrame: m }) => {
476
+ const c = d(), f = u(e);
477
+ if (!f || !f.axis || f.origin !== "x") return;
478
+ const a = f.axis, l = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, p = window.devicePixelRatio || 1, v = l, x = (i ?? 6) * p, g = a.position === "top" ? l - x : l + x, y = (o ?? 12) * p;
479
+ c.save(), c.fontKerning = "auto", D(c, {
480
+ ...t
481
+ }), c.beginPath();
482
+ const w = Array.isArray(r) ? r : r({ ...f, axis: a }, m());
483
+ for (const { value: S } of w) {
484
+ const b = h(S, e, "canvas");
485
+ c.moveTo(b, v), c.lineTo(b, g);
483
486
  }
484
- a.stroke(), a.restore(), a.save(), _(a, {
485
- textBaseline: h.position === "top" ? "bottom" : "top",
487
+ c.stroke(), c.restore(), c.save(), D(c, {
488
+ textBaseline: a.position === "top" ? "bottom" : "top",
486
489
  textAlign: "center",
487
- ...n,
488
- ...e
490
+ ...t,
491
+ ...s
489
492
  });
490
- for (const { value: b, label: S } of y) {
491
- const T = d(b, t, "canvas"), w = S.split(`
493
+ for (const { value: S, label: b } of w) {
494
+ const T = h(S, e, "canvas"), C = b.split(`
492
495
  `);
493
- for (let M = 0; M < w.length; M++)
494
- a.fillText(w[M], T, v + u * 2 + M * g);
496
+ for (let M = 0; M < C.length; M++)
497
+ c.fillText(C[M], T, g + p * 2 + M * y);
495
498
  }
496
- a.restore();
499
+ c.restore();
497
500
  },
498
- [i, t, n, e]
499
- ), null), Ce = ({ scaleId: t, tickStyle: n, labelStyle: e, labelGap: s, tickSize: o, ticks: i }) => (F(
500
- "BOTTOM",
501
- ({ getCtx: r, valToPos: d, getScale: l, getFrame: c }) => {
502
- const a = r(), m = l(t);
503
- if (!m || !m.axis || m.origin !== "y") return;
504
- const h = m.axis, f = h.position === "left" ? h.canvasRect.x + h.canvasRect.width : h.canvasRect.x, u = f, p = o ?? 6, x = h.position === "left" ? f - p : f + p, v = s ?? 12, g = Array.isArray(i) ? i : i({ ...m, axis: h }, c());
505
- a.save(), a.fontKerning = "auto", _(a, { ...n }), a.beginPath();
506
- for (const { value: y } of g) {
507
- const b = d(y, t, "canvas");
508
- a.moveTo(u, b), a.lineTo(x, b);
501
+ [r, e, t, s]
502
+ ), null), Ce = ({ layer: n = "BOTTOM", scaleId: e, tickStyle: t, labelStyle: s, labelGap: o, tickSize: i, ticks: r }) => (F(
503
+ n,
504
+ ({ getCtx: d, valToPos: h, getScale: u, getFrame: m }) => {
505
+ const c = d(), f = u(e);
506
+ if (!f || !f.axis || f.origin !== "y") return;
507
+ const a = f.axis, l = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, p = l, v = i ?? 6, x = a.position === "left" ? l - v : l + v, g = o ?? 12, y = Array.isArray(r) ? r : r({ ...f, axis: a }, m());
508
+ c.save(), c.fontKerning = "auto", D(c, { ...t }), c.beginPath();
509
+ for (const { value: w } of y) {
510
+ const S = h(w, e, "canvas");
511
+ c.moveTo(p, S), c.lineTo(x, S);
509
512
  }
510
- a.stroke(), a.restore(), a.save(), _(a, {
513
+ c.stroke(), c.restore(), c.save(), D(c, {
511
514
  textBaseline: "middle",
512
- textAlign: h.position === "left" ? "right" : "left",
513
- ...n,
514
- ...e
515
+ textAlign: a.position === "left" ? "right" : "left",
516
+ ...t,
517
+ ...s
515
518
  });
516
- for (const { value: y, label: b } of g) {
517
- const S = d(y, t, "canvas"), T = b.split(`
519
+ for (const { value: w, label: S } of y) {
520
+ const b = h(w, e, "canvas"), T = S.split(`
518
521
  `);
519
- for (let w = 0; w < T.length; w++)
520
- a.fillText(` ${T[w]} `, x, S + w * v);
522
+ for (let C = 0; C < T.length; C++)
523
+ c.fillText(` ${T[C]} `, x, b + C * g);
521
524
  }
522
- a.restore();
525
+ c.restore();
523
526
  },
524
- [i, t, n, e]
527
+ [r, e, t, s]
525
528
  ), null), k = () => {
526
- const t = [];
529
+ const n = [];
527
530
  return {
528
- addEventListener: (n, e) => (t.push({
529
- syncKey: n,
530
- callback: e
531
+ addEventListener: (e, t) => (n.push({
532
+ syncKey: e,
533
+ callback: t
531
534
  }), () => {
532
- const s = t.findIndex((o) => o.callback === e);
533
- s !== -1 && t.splice(s, 1);
535
+ const s = n.findIndex((o) => o.callback === t);
536
+ s !== -1 && n.splice(s, 1);
534
537
  }),
535
- dispatchEvent: (n, e) => {
536
- for (const s of t)
537
- s.syncKey === n && s.callback(n, e);
538
+ dispatchEvent: (e, t) => {
539
+ for (const s of n)
540
+ s.syncKey === e && s.callback(e, t);
538
541
  }
539
542
  };
540
- }, C = {
543
+ }, E = {
541
544
  dblclick: k(),
542
545
  click: k(),
543
546
  contextmenu: k(),
@@ -548,63 +551,63 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
548
551
  documentmouseup: k(),
549
552
  pressandwheel: k(),
550
553
  sync_move: k()
551
- }, R = (t, n, e) => {
552
- const s = Q.useRef(e);
553
- s.current = e, Q.useEffect(() => C[t].addEventListener(
554
- n,
554
+ }, R = (n, e, t) => {
555
+ const s = Q.useRef(t);
556
+ s.current = t, Q.useEffect(() => E[n].addEventListener(
557
+ e,
555
558
  (i, r) => {
556
559
  s.current(r, i);
557
560
  }
558
- ), [n, t, s]);
559
- }, xt = Q.createContext(""), yt = (t, n) => {
560
- const e = Q.useContext(xt);
561
- return R(t, e, n);
562
- }, Wt = (t, n, e, s, o) => {
563
- if (!n) return;
564
- const i = s ?? e.scales.find((m) => m.origin === "x")?.id, r = o ?? e.scales.find((m) => m.origin === "y")?.id;
561
+ ), [e, n, s]);
562
+ }, xt = Q.createContext(""), yt = (n, e) => {
563
+ const t = Q.useContext(xt);
564
+ return R(n, t, e);
565
+ }, Wt = (n, e, t, s, o) => {
566
+ if (!e) return;
567
+ const i = s ?? t.scales.find((c) => c.origin === "x")?.id, r = o ?? t.scales.find((c) => c.origin === "y")?.id;
565
568
  if (!i || !r)
566
569
  return;
567
- const d = t.clientX - n.left, l = {
570
+ const d = n.clientX - e.left, h = {
568
571
  scaleId: i,
569
- value: L(e, d, i, "css")
570
- }, c = t.clientY - n.top, a = {
572
+ value: L(t, d, i, "css")
573
+ }, u = n.clientY - e.top, m = {
571
574
  scaleId: r,
572
- value: L(e, c, r, "css")
575
+ value: L(t, u, r, "css")
573
576
  };
574
- return { pointerSyncPosition: { x: l, y: a }, cssX: d, cssY: c };
575
- }, O = (t, n) => {
576
- const { x: e, y: s } = t, o = e && n.scales.some((r) => r.id === e.scaleId) ? H(n, e.value, e.scaleId, "css") : null, i = s && n.scales.some((r) => r.id === s.scaleId) ? H(n, s.value, s.scaleId, "css") : null;
577
+ return { pointerSyncPosition: { x: h, y: m }, cssX: d, cssY: u };
578
+ }, O = (n, e) => {
579
+ const { x: t, y: s } = n, o = t && e.scales.some((r) => r.id === t.scaleId) ? H(e, t.value, t.scaleId, "css") : null, i = s && e.scales.some((r) => r.id === s.scaleId) ? H(e, s.value, s.scaleId, "css") : null;
577
580
  return {
578
581
  cssX: o,
579
582
  cssY: i,
580
583
  scaled: Object.fromEntries(
581
- n.scales.flatMap((r) => {
584
+ e.scales.flatMap((r) => {
582
585
  const d = r.origin === "y" ? i : o;
583
- return d === null ? [] : [[r.id, L(n, d, r.id, "css")]];
586
+ return d === null ? [] : [[r.id, L(e, d, r.id, "css")]];
584
587
  })
585
588
  )
586
589
  };
587
- }, St = (t, n, e) => {
590
+ }, St = (n, e, t) => {
588
591
  const s = H(
589
- e,
590
- n.from,
591
- n.scaleId,
592
+ t,
593
+ e.from,
594
+ e.scaleId,
592
595
  "css"
593
596
  ), o = H(
594
- e,
595
- n.to,
596
- n.scaleId,
597
+ t,
598
+ e.to,
599
+ e.scaleId,
597
600
  "css"
598
- ), i = e.scales.flatMap(
601
+ ), i = t.scales.flatMap(
599
602
  (r) => {
600
- if (r.origin !== t)
603
+ if (r.origin !== n)
601
604
  return [];
602
- const d = L(e, s, r.id, "css"), l = L(e, o, r.id, "css");
605
+ const d = L(t, s, r.id, "css"), h = L(t, o, r.id, "css");
603
606
  return [
604
607
  {
605
608
  scaleId: r.id,
606
609
  from: d,
607
- to: l
610
+ to: h
608
611
  }
609
612
  ];
610
613
  }
@@ -615,86 +618,86 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
615
618
  scaled: i
616
619
  };
617
620
  }, Me = ({
618
- id: t,
619
- onClick: n,
620
- onDblClick: e,
621
+ id: n,
622
+ onClick: e,
623
+ onDblClick: t,
621
624
  onMouseMove: s,
622
625
  onMouseDown: o,
623
626
  onMouseUp: i,
624
627
  onDocumentMouseUp: r,
625
628
  onSpanSelect: d,
626
- onContextMenu: l,
627
- className: c,
628
- style: a,
629
- sync: m,
630
- children: h
629
+ onContextMenu: h,
630
+ className: u,
631
+ style: m,
632
+ sync: c,
633
+ children: f
631
634
  }) => {
632
- const f = Kt(), u = t || f;
633
- return R("dblclick", u, (p) => {
635
+ const a = Kt(), l = n || a;
636
+ return R("dblclick", l, (p) => {
637
+ t?.(p);
638
+ }), R("click", l, (p) => {
634
639
  e?.(p);
635
- }), R("click", u, (p) => {
636
- n?.(p);
637
- }), R("move", u, (p) => {
640
+ }), R("move", l, (p) => {
638
641
  s?.(p);
639
- }), R("mousedown", u, (p) => {
642
+ }), R("mousedown", l, (p) => {
640
643
  o?.(p);
641
- }), R("mouseup", u, (p) => {
644
+ }), R("mouseup", l, (p) => {
642
645
  i?.(p);
643
- }), R("documentmouseup", u, (p) => {
646
+ }), R("documentmouseup", l, (p) => {
644
647
  r?.(p);
645
- }), R("spanselect", u, (p) => {
648
+ }), R("spanselect", l, (p) => {
646
649
  d?.(p);
647
- }), R("contextmenu", u, (p) => {
648
- l?.(p);
649
- }), /* @__PURE__ */ ht(xt.Provider, { value: u, children: [
650
+ }), R("contextmenu", l, (p) => {
651
+ h?.(p);
652
+ }), /* @__PURE__ */ ht(xt.Provider, { value: l, children: [
650
653
  /* @__PURE__ */ A(
651
654
  qt,
652
655
  {
653
- className: c,
654
- style: a,
655
- sync: m
656
+ className: u,
657
+ style: m,
658
+ sync: c
656
659
  }
657
660
  ),
658
- h
661
+ f
659
662
  ] });
660
- }, qt = ({ className: t, style: n, sync: e }) => {
661
- const s = D(null), o = pt(), i = D(o);
663
+ }, qt = ({ className: n, style: e, sync: t }) => {
664
+ const s = _(null), o = pt(), i = _(o);
662
665
  i.current = o;
663
- const r = tt(xt), d = e?.key || r, l = D(null), c = D(null), a = D(null), m = () => {
664
- const u = s.current?.parentElement;
665
- if (u) {
666
- if (u.dataset.canplotroot === void 0)
666
+ const r = tt(xt), d = t?.key || r, h = _(null), u = _(null), m = _(null), c = () => {
667
+ const l = s.current?.parentElement;
668
+ if (l) {
669
+ if (l.dataset.canplotroot === void 0)
667
670
  throw new Error(
668
671
  "ChartAreaInteractions must be used within a CanPlot component"
669
672
  );
670
- return u.getBoundingClientRect();
673
+ return l.getBoundingClientRect();
671
674
  }
672
- }, h = (u, p) => {
673
- const x = Wt(
674
- u,
675
- m(),
675
+ }, f = (l, p) => {
676
+ const v = Wt(
677
+ l,
678
+ c(),
676
679
  i.current,
677
- e?.xViaScaleId,
678
- e?.yViaScaleId
680
+ t?.xViaScaleId,
681
+ t?.yViaScaleId
679
682
  );
680
- x && p(
681
- x.pointerSyncPosition,
682
- { cssX: x.cssX, cssY: x.cssY },
683
+ v && p(
684
+ v.pointerSyncPosition,
685
+ { cssX: v.cssX, cssY: v.cssY },
683
686
  {
684
- ctrlKey: u.ctrlKey,
685
- altKey: u.altKey,
686
- shiftKey: u.shiftKey,
687
- metaKey: u.metaKey
687
+ ctrlKey: l.ctrlKey,
688
+ altKey: l.altKey,
689
+ shiftKey: l.shiftKey,
690
+ metaKey: l.metaKey
688
691
  }
689
692
  );
690
- }, f = D(h);
691
- return f.current = h, Mt(() => {
692
- const u = (y) => {
693
- const b = c.current;
694
- b && C.spanselect.dispatchEvent(r, {
695
- ...b,
693
+ }, a = _(f);
694
+ return a.current = f, Mt(() => {
695
+ const l = (y) => {
696
+ const w = u.current;
697
+ w && E.spanselect.dispatchEvent(r, {
698
+ ...w,
696
699
  completed: !0
697
- }), C.documentmouseup.dispatchEvent(r, {
700
+ }), E.documentmouseup.dispatchEvent(r, {
698
701
  frame: i.current,
699
702
  keys: {
700
703
  ctrlKey: y.ctrlKey,
@@ -704,34 +707,34 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
704
707
  }
705
708
  });
706
709
  }, p = (y) => {
707
- const b = {
710
+ const w = {
708
711
  ctrlKey: y.ctrlKey,
709
712
  altKey: y.altKey,
710
713
  shiftKey: y.shiftKey,
711
714
  metaKey: y.metaKey
712
- }, S = a.current;
713
- if (S && Object.entries(b).some(
714
- ([w, M]) => S.keys[w] !== M
715
+ }, S = m.current;
716
+ if (S && Object.entries(w).some(
717
+ ([T, C]) => S.keys[T] !== C
715
718
  )) {
716
- const w = { ...S, keys: b };
717
- a.current = w, C.sync_move.dispatchEvent(d, w);
719
+ const T = { ...S, keys: w };
720
+ m.current = T, E.sync_move.dispatchEvent(d, T);
718
721
  }
719
- const T = c.current;
720
- if (T && Object.entries(b).some(
721
- ([w, M]) => T.keys[w] !== M
722
+ const b = u.current;
723
+ if (b && Object.entries(w).some(
724
+ ([T, C]) => b.keys[T] !== C
722
725
  )) {
723
726
  y.stopPropagation(), y.preventDefault();
724
- const w = { ...T, keys: b };
725
- c.current = w, C.spanselect.dispatchEvent(r, w);
727
+ const T = { ...b, keys: w };
728
+ u.current = T, E.spanselect.dispatchEvent(r, T);
726
729
  }
727
- }, x = (y) => {
728
- f.current(
730
+ }, v = (y) => {
731
+ a.current(
729
732
  y,
730
- (b, { cssX: S, cssY: T }, w) => {
731
- const M = l.current;
732
- if (!M || !b.x || !b.y) return;
733
- const E = i.current, P = M.xRangeCss.start, N = S, K = M.yRangeCss.start, ot = T, it = I(E, b.x.scaleId), rt = I(E, b.y.scaleId);
734
- l.current = {
733
+ (w, { cssX: S, cssY: b }, T) => {
734
+ const C = h.current;
735
+ if (!C || !w.x || !w.y) return;
736
+ const M = i.current, P = C.xRangeCss.start, N = S, K = C.yRangeCss.start, ot = b, it = I(M, w.x.scaleId), rt = I(M, w.y.scaleId);
737
+ h.current = {
735
738
  xRangeCss: { start: P, end: N },
736
739
  yRangeCss: { start: K, end: ot }
737
740
  };
@@ -741,32 +744,32 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
741
744
  const gt = {
742
745
  scaleId: it.id,
743
746
  from: L(
744
- E,
747
+ M,
745
748
  Y(i.current, P, "css"),
746
749
  it.id,
747
750
  "css"
748
751
  ),
749
752
  to: L(
750
- E,
753
+ M,
751
754
  Y(i.current, N, "css"),
752
755
  it.id,
753
756
  "css"
754
757
  )
755
- }, bt = {
758
+ }, wt = {
756
759
  scaleId: rt.id,
757
760
  from: L(
758
- E,
761
+ M,
759
762
  B(i.current, K, "css"),
760
763
  rt.id,
761
764
  "css"
762
765
  ),
763
766
  to: L(
764
- E,
767
+ M,
765
768
  B(i.current, ot, "css"),
766
769
  rt.id,
767
770
  "css"
768
771
  )
769
- }, W = gt && St("x", gt, i.current), q = bt && St("y", bt, i.current), Dt = W?.scaled, Lt = q?.scaled, wt = {
772
+ }, W = gt && St("x", gt, i.current), q = wt && St("y", wt, i.current), _t = W?.scaled, Lt = q?.scaled, bt = {
770
773
  mode: $,
771
774
  frame: i.current,
772
775
  completed: !1,
@@ -775,7 +778,7 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
775
778
  from: W.fromCSS,
776
779
  to: W.toCSS
777
780
  },
778
- scaled: Dt ?? []
781
+ scaled: _t ?? []
779
782
  },
780
783
  y: {
781
784
  css: q && {
@@ -784,58 +787,58 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
784
787
  },
785
788
  scaled: Lt ?? []
786
789
  },
787
- keys: w
790
+ keys: T
788
791
  };
789
- c.current = wt, C.spanselect.dispatchEvent(
792
+ u.current = bt, E.spanselect.dispatchEvent(
790
793
  r,
791
- wt
794
+ bt
792
795
  );
793
796
  }
794
797
  );
795
- }, v = (y) => {
796
- f.current(y, (b, S, T) => {
797
- const w = O(
798
- b,
798
+ }, x = (y) => {
799
+ a.current(y, (w, S, b) => {
800
+ const T = O(
801
+ w,
799
802
  i.current
800
803
  );
801
- if (!w) return;
802
- if (Object.values(T).some((E) => E)) {
804
+ if (!T) return;
805
+ if (Object.values(b).some((M) => M)) {
803
806
  y.preventDefault();
804
- const E = Math.abs(y.deltaY) > Math.abs(y.deltaX) ? y.deltaY : y.deltaX;
805
- C.pressandwheel.dispatchEvent(r, {
806
- pointer: w,
807
+ const M = Math.abs(y.deltaY) > Math.abs(y.deltaX) ? y.deltaY : y.deltaX;
808
+ E.pressandwheel.dispatchEvent(r, {
809
+ pointer: T,
807
810
  frame: i.current,
808
- keys: T,
811
+ keys: b,
809
812
  deltaX: y.deltaX,
810
813
  deltaY: y.deltaY,
811
- deltaAbs: E
814
+ deltaAbs: M
812
815
  });
813
816
  }
814
817
  });
815
818
  };
816
- document.addEventListener("mouseup", u), document.addEventListener("keydown", p), document.addEventListener("keyup", p), document.addEventListener("mousemove", x);
819
+ document.addEventListener("mouseup", l), document.addEventListener("keydown", p), document.addEventListener("keyup", p), document.addEventListener("mousemove", v);
817
820
  const g = s.current;
818
- return g?.addEventListener("wheel", v, {
821
+ return g?.addEventListener("wheel", x, {
819
822
  passive: !1
820
823
  }), () => {
821
- document.removeEventListener("mouseup", u), document.removeEventListener("keydown", p), document.removeEventListener("keyup", p), document.removeEventListener("mousemove", x), g?.removeEventListener("wheel", v);
824
+ document.removeEventListener("mouseup", l), document.removeEventListener("keydown", p), document.removeEventListener("keyup", p), document.removeEventListener("mousemove", v), g?.removeEventListener("wheel", x);
822
825
  };
823
- }, [i, r, d, f]), R("sync_move", d, (u) => {
824
- const p = u.positions ? O(
825
- u.positions,
826
+ }, [i, r, d, a]), R("sync_move", d, (l) => {
827
+ const p = l.positions ? O(
828
+ l.positions,
826
829
  i.current
827
830
  ) : null;
828
- a.current = u, C.move.dispatchEvent(r, {
831
+ m.current = l, E.move.dispatchEvent(r, {
829
832
  frame: i.current,
830
833
  pointer: p ?? null,
831
- keys: u.keys
834
+ keys: l.keys
832
835
  });
833
836
  }), /* @__PURE__ */ A(
834
837
  "div",
835
838
  {
836
839
  ref: s,
837
840
  id: "interactions",
838
- className: t,
841
+ className: n,
839
842
  style: {
840
843
  position: "absolute",
841
844
  left: o.chartAreaCSS.x,
@@ -843,113 +846,113 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
843
846
  width: o.chartAreaCSS.width,
844
847
  height: o.chartAreaCSS.height,
845
848
  zIndex: 25,
846
- ...n
849
+ ...e
847
850
  },
848
- onDragStart: (u) => {
849
- u.preventDefault();
851
+ onDragStart: (l) => {
852
+ l.preventDefault();
850
853
  },
851
- onClick: (u) => {
852
- h(u, (p, x, v) => {
854
+ onClick: (l) => {
855
+ f(l, (p, v, x) => {
853
856
  const g = O(
854
857
  p,
855
858
  i.current
856
859
  );
857
- g && C.click.dispatchEvent(r, {
860
+ g && E.click.dispatchEvent(r, {
858
861
  pointer: g,
859
862
  frame: i.current,
860
- keys: v
863
+ keys: x
861
864
  });
862
865
  });
863
866
  },
864
- onMouseLeave: (u) => {
865
- h(u, (p, x, v) => {
866
- C.sync_move.dispatchEvent(d, {
867
+ onMouseLeave: (l) => {
868
+ f(l, (p, v, x) => {
869
+ E.sync_move.dispatchEvent(d, {
867
870
  positions: null,
868
- keys: v
871
+ keys: x
869
872
  });
870
873
  });
871
874
  },
872
- onMouseMove: (u) => {
873
- h(u, (p, x, v) => {
874
- C.sync_move.dispatchEvent(d, {
875
+ onMouseMove: (l) => {
876
+ f(l, (p, v, x) => {
877
+ E.sync_move.dispatchEvent(d, {
875
878
  positions: p,
876
- keys: v
879
+ keys: x
877
880
  });
878
881
  });
879
882
  },
880
- onMouseDown: (u) => {
881
- h(u, (p, { cssX: x, cssY: v }, g) => {
883
+ onMouseDown: (l) => {
884
+ f(l, (p, { cssX: v, cssY: x }, g) => {
882
885
  const y = O(
883
886
  p,
884
887
  i.current
885
888
  );
886
- y && (C.mousedown.dispatchEvent(r, {
889
+ y && (E.mousedown.dispatchEvent(r, {
887
890
  pointer: y,
888
891
  frame: i.current,
889
892
  keys: g
890
- }), l.current = {
891
- xRangeCss: { start: x, end: x },
892
- yRangeCss: { start: v, end: v }
893
+ }), h.current = {
894
+ xRangeCss: { start: v, end: v },
895
+ yRangeCss: { start: x, end: x }
893
896
  });
894
897
  });
895
898
  },
896
- onMouseUp: (u) => {
897
- h(u, (p, x, v) => {
899
+ onMouseUp: (l) => {
900
+ f(l, (p, v, x) => {
898
901
  const g = O(
899
902
  p,
900
903
  i.current
901
904
  );
902
905
  if (!g) return;
903
- C.mouseup.dispatchEvent(r, {
906
+ E.mouseup.dispatchEvent(r, {
904
907
  frame: i.current,
905
908
  pointer: g,
906
- keys: v
909
+ keys: x
907
910
  });
908
- const y = c.current;
909
- c.current = null;
910
- const b = l.current;
911
- if (l.current = null, b && y) {
911
+ const y = u.current;
912
+ u.current = null;
913
+ const w = h.current;
914
+ if (h.current = null, w && y) {
912
915
  const S = {
913
916
  ...y,
914
- keys: v,
917
+ keys: x,
915
918
  completed: !0
916
919
  };
917
- c.current = null, C.spanselect.dispatchEvent(
920
+ u.current = null, E.spanselect.dispatchEvent(
918
921
  r,
919
922
  S
920
923
  );
921
924
  }
922
925
  });
923
926
  },
924
- onContextMenu: (u) => {
925
- u.preventDefault(), h(u, (p, x, v) => {
927
+ onContextMenu: (l) => {
928
+ l.preventDefault(), f(l, (p, v, x) => {
926
929
  const g = O(
927
930
  p,
928
931
  i.current
929
932
  );
930
- g && C.contextmenu.dispatchEvent(r, {
933
+ g && E.contextmenu.dispatchEvent(r, {
931
934
  frame: i.current,
932
935
  pointer: g,
933
- keys: v
936
+ keys: x
934
937
  });
935
938
  });
936
939
  },
937
- onDoubleClick: (u) => {
938
- h(u, (p, x, v) => {
940
+ onDoubleClick: (l) => {
941
+ f(l, (p, v, x) => {
939
942
  const g = O(
940
943
  p,
941
944
  i.current
942
945
  );
943
- g && C.dblclick.dispatchEvent(r, {
946
+ g && E.dblclick.dispatchEvent(r, {
944
947
  frame: i.current,
945
948
  pointer: g,
946
- keys: v
949
+ keys: x
947
950
  });
948
951
  });
949
952
  }
950
953
  }
951
954
  );
952
- }, Ee = ({ data: t, renderTooltip: n, xScaleId: e }) => {
955
+ }, Ee = ({ data: n, renderTooltip: e, xScaleId: t }) => {
953
956
  const [s, o] = V(null);
954
957
  yt("move", (r) => {
955
958
  o(r);
@@ -957,53 +960,53 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
957
960
  const i = et(() => {
958
961
  if (!s)
959
962
  return null;
960
- const { frame: r, pointer: d } = s, l = d?.scaled[e];
961
- if (l === void 0)
963
+ const { frame: r, pointer: d } = s, h = d?.scaled[t];
964
+ if (h === void 0)
962
965
  return null;
963
- const c = [];
964
- let a = l;
965
- for (const m of t) {
966
- let h = null, f = 1 / 0;
967
- for (const [p, x] of m.points.entries()) {
968
- if (!lt(r, x.x, e) || !lt(r, x.y, m.yScaleId))
966
+ const u = [];
967
+ let m = h;
968
+ for (const c of n) {
969
+ let f = null, a = 1 / 0;
970
+ for (const [p, v] of c.points.entries()) {
971
+ if (!lt(r, v.x, t) || !lt(r, v.y, c.yScaleId))
969
972
  continue;
970
- const v = Math.abs(x.x - l);
971
- v < f && (f = v, h = p);
973
+ const x = Math.abs(v.x - h);
974
+ x < a && (a = x, f = p);
972
975
  }
973
- const u = m.points[h ?? -1];
974
- if (!u || ft(r, f, e, "css") > 30) {
975
- c.push({ seriesId: m.seriesId, y: null });
976
+ const l = c.points[f ?? -1];
977
+ if (!l || ft(r, a, t, "css") > 30) {
978
+ u.push({ seriesId: c.seriesId, y: null });
976
979
  continue;
977
980
  }
978
- a = u.x, c.push({
979
- seriesId: m.seriesId,
980
- y: u.y
981
+ m = l.x, u.push({
982
+ seriesId: c.seriesId,
983
+ y: l.y
981
984
  });
982
985
  }
983
986
  return {
984
987
  frame: r,
985
- x: a,
986
- points: c
988
+ x: m,
989
+ points: u
987
990
  };
988
- }, [t, s, e]);
989
- return n(i);
990
- }, Pe = ({ makeXStyle: t, makeXClassName: n, makeYStyle: e, makeYClassName: s }) => {
991
+ }, [n, s, t]);
992
+ return e(i);
993
+ }, Pe = ({ makeXStyle: n, makeXClassName: e, makeYStyle: t, makeYClassName: s }) => {
991
994
  const [o, i] = V(null);
992
- if (yt("move", (h) => {
993
- i(h);
995
+ if (yt("move", (f) => {
996
+ i(f);
994
997
  }), !o)
995
998
  return null;
996
- const { frame: r, pointer: d } = o, l = d?.cssX ?? null, c = d?.cssY ?? null, a = l ? Y(r, l, "css") : 0, m = c ? B(r, c, "css") : 0;
999
+ const { frame: r, pointer: d } = o, h = d?.cssX ?? null, u = d?.cssY ?? null, m = h ? Y(r, h, "css") : 0, c = u ? B(r, u, "css") : 0;
997
1000
  return /* @__PURE__ */ ht(It, { children: [
998
1001
  /* @__PURE__ */ A(
999
1002
  "div",
1000
1003
  {
1001
1004
  "data-show": !!d,
1002
- className: n?.(o),
1005
+ className: e?.(o),
1003
1006
  style: {
1004
1007
  position: "absolute",
1005
1008
  left: 0,
1006
- visibility: l === null ? "hidden" : "visible",
1009
+ visibility: h === null ? "hidden" : "visible",
1007
1010
  top: r.chartAreaCSS.y,
1008
1011
  height: r.chartAreaCSS.height,
1009
1012
  borderColor: "red",
@@ -1011,8 +1014,8 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
1011
1014
  borderLeftStyle: "solid",
1012
1015
  pointerEvents: "none",
1013
1016
  opacity: d ? 1 : 0,
1014
- transform: `translateX(${a}px)`,
1015
- ...t?.(o)
1017
+ transform: `translateX(${m}px)`,
1018
+ ...n?.(o)
1016
1019
  }
1017
1020
  }
1018
1021
  ),
@@ -1023,7 +1026,7 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
1023
1026
  "data-show": !!d,
1024
1027
  style: {
1025
1028
  position: "absolute",
1026
- visibility: c === null ? "hidden" : "visible",
1029
+ visibility: u === null ? "hidden" : "visible",
1027
1030
  top: 0,
1028
1031
  height: 0,
1029
1032
  borderTop: "solid 1px red",
@@ -1031,43 +1034,43 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
1031
1034
  width: r.chartAreaCSS.width,
1032
1035
  pointerEvents: "none",
1033
1036
  opacity: d ? 1 : 0,
1034
- transform: `translateY(${m}px)`,
1035
- ...e?.(o)
1037
+ transform: `translateY(${c}px)`,
1038
+ ...t?.(o)
1036
1039
  }
1037
1040
  }
1038
1041
  )
1039
1042
  ] });
1040
- }, ke = ({ makeClassName: t, makeStyle: n }) => {
1041
- const [e, s] = V(null);
1043
+ }, ke = ({ makeClassName: n, makeStyle: e }) => {
1044
+ const [t, s] = V(null);
1042
1045
  yt("spanselect", (i) => {
1043
1046
  s(
1044
1047
  i.mode === "below_threshold" || i.completed ? null : i
1045
1048
  );
1046
1049
  });
1047
1050
  const o = et(() => {
1048
- if (!e || e.mode === "below_threshold")
1051
+ if (!t || t.mode === "below_threshold")
1049
1052
  return null;
1050
- const i = e.mode === "y" ? -1 / 0 : e.x.css?.from ?? -1 / 0, r = e.mode === "y" ? 1 / 0 : e.x.css?.to ?? 1 / 0, d = e.mode === "x" ? -1 / 0 : e.y.css?.from ?? -1 / 0, l = e.mode === "x" ? 1 / 0 : e.y.css?.to ?? 1 / 0, c = Y(e.frame, i, "css"), a = Y(e.frame, r, "css"), m = B(e.frame, d, "css"), h = B(e.frame, l, "css"), f = Math.min(c, a), u = Math.min(m, h), p = Math.abs(a - c), x = Math.abs(h - m);
1051
- return { leftPx: f, topPx: u, widthPx: p, heightPx: x };
1052
- }, [e]);
1053
+ const i = t.mode === "y" ? -1 / 0 : t.x.css?.from ?? -1 / 0, r = t.mode === "y" ? 1 / 0 : t.x.css?.to ?? 1 / 0, d = t.mode === "x" ? -1 / 0 : t.y.css?.from ?? -1 / 0, h = t.mode === "x" ? 1 / 0 : t.y.css?.to ?? 1 / 0, u = Y(t.frame, i, "css"), m = Y(t.frame, r, "css"), c = B(t.frame, d, "css"), f = B(t.frame, h, "css"), a = Math.min(u, m), l = Math.min(c, f), p = Math.abs(m - u), v = Math.abs(f - c);
1054
+ return { leftPx: a, topPx: l, widthPx: p, heightPx: v };
1055
+ }, [t]);
1053
1056
  return /* @__PURE__ */ A(
1054
1057
  "div",
1055
1058
  {
1056
- className: e ? t?.(e) : void 0,
1059
+ className: t ? n?.(t) : void 0,
1057
1060
  style: {
1058
1061
  position: "absolute",
1059
- visibility: e ? "visible" : "hidden",
1062
+ visibility: t ? "visible" : "hidden",
1060
1063
  left: `${o?.leftPx ?? 0}px`,
1061
1064
  top: `${o?.topPx ?? 0}px`,
1062
1065
  width: `${o?.widthPx ?? 0}px`,
1063
1066
  height: `${o?.heightPx ?? 0}px`,
1064
1067
  pointerEvents: "none",
1065
- ...e ? n?.(e) : void 0
1068
+ ...t ? e?.(t) : void 0
1066
1069
  }
1067
1070
  }
1068
1071
  );
1069
- }, Re = ({ style: t, children: n, scaleId: e, ...s }) => {
1070
- const o = pt((i) => i.getScale(e)?.axis);
1072
+ }, Re = ({ style: n, children: e, scaleId: t, ...s }) => {
1073
+ const o = pt((i) => i.getScale(t)?.axis);
1071
1074
  return o ? /* @__PURE__ */ A(
1072
1075
  "div",
1073
1076
  {
@@ -1078,38 +1081,38 @@ const xe = Xt(({ configuration: t, children: n, style: e, className: s }, o) =>
1078
1081
  top: o.cssRect.y,
1079
1082
  height: o.cssRect.height,
1080
1083
  width: o.cssRect.width,
1081
- ...t
1084
+ ...n
1082
1085
  },
1083
1086
  ...s,
1084
- children: n
1087
+ children: e
1085
1088
  }
1086
1089
  ) : null;
1087
1090
  }, Rt = 60, Gt = 30, At = "UTC", Zt = "en-GB", Ae = ({
1088
- space: t,
1089
- formatter: n,
1090
- acceptableIncrements: e
1091
+ space: n,
1092
+ formatter: e,
1093
+ acceptableIncrements: t
1091
1094
  } = {}) => (s, o) => {
1092
- const { min: i, max: r } = s, d = [], l = window.devicePixelRatio || 1, c = (t ?? (s.origin === "x" ? Rt : Gt)) * l, a = Ot(
1095
+ const { min: i, max: r } = s, d = [], h = window.devicePixelRatio || 1, u = (n ?? (s.origin === "x" ? Rt : Gt)) * h, m = Ot(
1093
1096
  o,
1094
- c,
1097
+ u,
1095
1098
  s.id,
1096
1099
  "canvas"
1097
- ), m = e ?? G, h = m.find((u) => u > a) ?? m.at(-1) ?? 1;
1098
- let f = i;
1099
- if (Math.abs(f % h) > Number.EPSILON) {
1100
- const u = (h - f % h) % h;
1101
- f += u;
1100
+ ), c = t ?? G, f = c.find((l) => l > m) ?? c.at(-1) ?? 1;
1101
+ let a = i;
1102
+ if (Math.abs(a % f) > Number.EPSILON) {
1103
+ const l = (f - a % f) % f;
1104
+ a += l;
1102
1105
  }
1103
- for (; f <= r && d.length < 1e3; )
1104
- d.push(f), f += h;
1105
- return (n ?? Jt)(d);
1106
- }, Jt = (t) => {
1107
- const n = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
1108
- return t.map((e) => ({ value: e, label: e.toFixed(n) }));
1106
+ for (; a <= r && d.length < 1e3; )
1107
+ d.push(a), a += f;
1108
+ return (e ?? Jt)(d);
1109
+ }, Jt = (n) => {
1110
+ const e = Math.max(0, Math.ceil(-Math.log10(n[1] - n[0])));
1111
+ return n.map((t) => ({ value: t, label: t.toFixed(e) }));
1109
1112
  }, G = [];
1110
- for (let t = -12; t <= 12; t++)
1111
- G.push(1 * 10 ** t), G.push(2 * 10 ** t), G.push(5 * 10 ** t);
1112
- const Qt = 1, _t = 1e3 * Qt, vt = 60 * _t, nt = 60 * vt, st = 24 * nt, te = 30 * st, ee = 365 * st, ne = [
1113
+ for (let n = -12; n <= 12; n++)
1114
+ G.push(1 * 10 ** n), G.push(2 * 10 ** n), G.push(5 * 10 ** n);
1115
+ const Qt = 1, Dt = 1e3 * Qt, vt = 60 * Dt, nt = 60 * vt, st = 24 * nt, te = 30 * st, ee = 365 * st, ne = [
1113
1116
  // second divisors
1114
1117
  [1, "milliseconds"],
1115
1118
  [2, "milliseconds"],
@@ -1161,70 +1164,70 @@ const Qt = 1, _t = 1e3 * Qt, vt = 60 * _t, nt = 60 * vt, st = 24 * nt, te = 30 *
1161
1164
  [25, "years"],
1162
1165
  [50, "years"],
1163
1166
  [100, "years"]
1164
- ], Z = (t) => {
1165
- const [n, e] = t;
1166
- switch (e) {
1167
+ ], Z = (n) => {
1168
+ const [e, t] = n;
1169
+ switch (t) {
1167
1170
  case "milliseconds":
1168
- return n;
1171
+ return e;
1169
1172
  case "seconds":
1170
- return n * _t;
1173
+ return e * Dt;
1171
1174
  case "minutes":
1172
- return n * vt;
1175
+ return e * vt;
1173
1176
  case "hours":
1174
- return n * nt;
1177
+ return e * nt;
1175
1178
  case "days":
1176
- return n * st;
1179
+ return e * st;
1177
1180
  case "months":
1178
- return n * te;
1181
+ return e * te;
1179
1182
  case "years":
1180
- return n * ee;
1183
+ return e * ee;
1181
1184
  }
1182
- }, se = (t, n) => {
1183
- const e = new Date(t);
1184
- return e.setUTCMilliseconds(e.getUTCMilliseconds() + n), e.getTime();
1185
- }, oe = (t, n) => {
1186
- const e = new Date(t);
1187
- return e.setUTCSeconds(e.getUTCSeconds() + n), e.getTime();
1188
- }, ie = (t, n) => {
1189
- const e = new Date(t);
1190
- return e.setUTCMinutes(e.getUTCMinutes() + n), e.getTime();
1191
- }, re = (t, n) => {
1192
- const e = new Date(t);
1193
- return e.setUTCHours(e.getUTCHours() + n), e.getTime();
1194
- }, ce = (t, n) => {
1195
- const e = new Date(t);
1196
- return e.setUTCDate(e.getUTCDate() + n), e.getTime();
1197
- }, Tt = (t, n) => {
1198
- const e = new Date(t);
1199
- return e.setUTCMonth(e.getUTCMonth() + n), e.getTime();
1200
- }, X = (t, n) => {
1201
- const [e, s] = n;
1185
+ }, se = (n, e) => {
1186
+ const t = new Date(n);
1187
+ return t.setUTCMilliseconds(t.getUTCMilliseconds() + e), t.getTime();
1188
+ }, oe = (n, e) => {
1189
+ const t = new Date(n);
1190
+ return t.setUTCSeconds(t.getUTCSeconds() + e), t.getTime();
1191
+ }, ie = (n, e) => {
1192
+ const t = new Date(n);
1193
+ return t.setUTCMinutes(t.getUTCMinutes() + e), t.getTime();
1194
+ }, re = (n, e) => {
1195
+ const t = new Date(n);
1196
+ return t.setUTCHours(t.getUTCHours() + e), t.getTime();
1197
+ }, ce = (n, e) => {
1198
+ const t = new Date(n);
1199
+ return t.setUTCDate(t.getUTCDate() + e), t.getTime();
1200
+ }, Tt = (n, e) => {
1201
+ const t = new Date(n);
1202
+ return t.setUTCMonth(t.getUTCMonth() + e), t.getTime();
1203
+ }, X = (n, e) => {
1204
+ const [t, s] = e;
1202
1205
  switch (s) {
1203
1206
  case "milliseconds":
1204
- return se(t, e);
1207
+ return se(n, t);
1205
1208
  case "seconds":
1206
- return oe(t, e);
1209
+ return oe(n, t);
1207
1210
  case "minutes":
1208
- return ie(t, e);
1211
+ return ie(n, t);
1209
1212
  case "hours":
1210
- return re(t, e);
1213
+ return re(n, t);
1211
1214
  case "days":
1212
- return ce(t, e);
1215
+ return ce(n, t);
1213
1216
  case "months":
1214
- return Tt(t, e);
1217
+ return Tt(n, t);
1215
1218
  case "years":
1216
- return Tt(t, e * 12);
1219
+ return Tt(n, t * 12);
1217
1220
  }
1218
1221
  };
1219
- function J(t, n) {
1220
- const e = new Date(t), s = new Date(e.toLocaleString("en-US", { timeZone: n })), o = new Date(e.toLocaleString("en-US", { timeZone: "UTC" }));
1222
+ function J(n, e) {
1223
+ const t = new Date(n), s = new Date(t.toLocaleString("en-US", { timeZone: e })), o = new Date(t.toLocaleString("en-US", { timeZone: "UTC" }));
1221
1224
  return (s.getTime() - o.getTime()) / (3600 * 1e3);
1222
1225
  }
1223
- const ae = (t, n, e = "UTC") => {
1224
- const [s, o] = n;
1225
- let i = new Date(t);
1226
+ const ae = (n, e, t = "UTC") => {
1227
+ const [s, o] = e;
1228
+ let i = new Date(n);
1226
1229
  const r = () => {
1227
- i.setUTCHours(-J(i, e), 0, 0, 0);
1230
+ i.setUTCHours(-J(i, t), 0, 0, 0);
1228
1231
  };
1229
1232
  switch (o) {
1230
1233
  case "milliseconds":
@@ -1256,37 +1259,37 @@ const ae = (t, n, e = "UTC") => {
1256
1259
  case "days":
1257
1260
  case "months":
1258
1261
  case "years":
1259
- o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < t && (i = new Date(X(i, [1, o])));
1262
+ o === "months" ? i.setUTCDate(1) : o === "years" && i.setUTCMonth(0, 1), r(), i.getTime() < n && (i = new Date(X(i, [1, o])));
1260
1263
  break;
1261
1264
  }
1262
1265
  return i.getTime();
1263
- }, _e = ({
1264
- timeZone: t = At,
1265
- space: n = Rt,
1266
- formatter: e,
1266
+ }, De = ({
1267
+ timeZone: n = At,
1268
+ space: e = Rt,
1269
+ formatter: t,
1267
1270
  locale: s,
1268
1271
  showTimezone: o
1269
1272
  } = {}) => (i, r) => {
1270
- const { min: d, max: l } = i, c = Math.floor(r.chartAreaCanvasPX.width / n) + 1, m = (l - d) / c, [h, f] = ne.find(
1271
- (g) => Z(g) >= m
1272
- ) ?? [1, "milliseconds"], u = ae(d, [h, f], t), p = J(u, t), x = [u];
1273
- let v;
1273
+ const { min: d, max: h } = i, u = Math.floor(r.chartAreaCanvasPX.width / e) + 1, c = (h - d) / u, [f, a] = ne.find(
1274
+ (g) => Z(g) >= c
1275
+ ) ?? [1, "milliseconds"], l = ae(d, [f, a], n), p = J(l, n), v = [l];
1276
+ let x;
1274
1277
  for (; ; ) {
1275
- switch (f) {
1278
+ switch (a) {
1276
1279
  case "milliseconds":
1277
1280
  case "seconds":
1278
1281
  case "minutes":
1279
1282
  case "hours": {
1280
- v = X(u, [x.length * h, f]);
1283
+ x = X(l, [v.length * f, a]);
1281
1284
  break;
1282
1285
  }
1283
1286
  case "days": {
1284
- const g = X(u, [
1285
- x.length * h,
1286
- f
1287
+ const g = X(l, [
1288
+ v.length * f,
1289
+ a
1287
1290
  ]);
1288
- v = X(g, [
1289
- p - J(g, t),
1291
+ x = X(g, [
1292
+ p - J(g, n),
1290
1293
  "hours"
1291
1294
  ]);
1292
1295
  break;
@@ -1294,34 +1297,34 @@ const ae = (t, n, e = "UTC") => {
1294
1297
  case "months":
1295
1298
  case "years": {
1296
1299
  const g = X(
1297
- X(X(u, [p, "hours"]), [
1298
- x.length * h,
1299
- f
1300
+ X(X(l, [p, "hours"]), [
1301
+ v.length * f,
1302
+ a
1300
1303
  ]),
1301
1304
  [-p, "hours"]
1302
1305
  );
1303
- v = X(g, [
1304
- p - J(g, t),
1306
+ x = X(g, [
1307
+ p - J(g, n),
1305
1308
  "hours"
1306
1309
  ]);
1307
1310
  break;
1308
1311
  }
1309
1312
  }
1310
- if (v > l)
1313
+ if (x > h)
1311
1314
  break;
1312
- x.push(v);
1315
+ v.push(x);
1313
1316
  }
1314
- return (e ?? le({
1317
+ return (t ?? le({
1315
1318
  locale: s,
1316
1319
  showTimezone: o,
1317
- timeZone: t
1318
- }))(x);
1319
- }, U = (t, n, e) => t.find((s) => s.type === e)?.value !== n.find((s) => s.type === e)?.value, le = ({
1320
- timeZone: t = At,
1321
- locale: n = Zt,
1322
- showTimezone: e = !0
1320
+ timeZone: n
1321
+ }))(v);
1322
+ }, U = (n, e, t) => n.find((s) => s.type === t)?.value !== e.find((s) => s.type === t)?.value, le = ({
1323
+ timeZone: n = At,
1324
+ locale: e = Zt,
1325
+ showTimezone: t = !0
1323
1326
  }) => {
1324
- const s = new Intl.DateTimeFormat(n, {
1327
+ const s = new Intl.DateTimeFormat(e, {
1325
1328
  year: "numeric",
1326
1329
  day: "numeric",
1327
1330
  month: "short",
@@ -1331,40 +1334,40 @@ const ae = (t, n, e = "UTC") => {
1331
1334
  second: "numeric",
1332
1335
  fractionalSecondDigits: 3,
1333
1336
  timeZoneName: "short",
1334
- timeZone: t
1337
+ timeZone: n
1335
1338
  });
1336
1339
  return (o) => {
1337
- const i = o[1] - o[0], r = i < Z([1, "days"]), d = i < Z([1, "minutes"]), l = i < Z([1, "seconds"]);
1338
- return o.map((c) => ({ value: c, label: s.formatToParts(new Date(c)) })).map((c, a, m) => {
1339
- const h = m[a - 1], f = a === 0 || U(c.label, h.label, "year"), u = a === 0 || U(c.label, h.label, "day"), p = a === 0 || U(c.label, h.label, "month"), x = a === 0 || U(c.label, h.label, "hour"), v = a === 0 || U(c.label, h.label, "timeZoneName"), g = a === 0 || U(c.label, h.label, "minute"), y = a === 0 || U(c.label, h.label, "second"), b = a === 0 || U(c.label, h.label, "fractionalSecond"), S = [];
1340
- if (r && (x || g || v || y || b)) {
1341
- const T = c.label.find((P) => P.type === "hour")?.value, w = c.label.find((P) => P.type === "minute")?.value, M = c.label.find((P) => P.type === "timeZoneName")?.value;
1342
- let E = "";
1340
+ const i = o[1] - o[0], r = i < Z([1, "days"]), d = i < Z([1, "minutes"]), h = i < Z([1, "seconds"]);
1341
+ return o.map((u) => ({ value: u, label: s.formatToParts(new Date(u)) })).map((u, m, c) => {
1342
+ const f = c[m - 1], a = m === 0 || U(u.label, f.label, "year"), l = m === 0 || U(u.label, f.label, "day"), p = m === 0 || U(u.label, f.label, "month"), v = m === 0 || U(u.label, f.label, "hour"), x = m === 0 || U(u.label, f.label, "timeZoneName"), g = m === 0 || U(u.label, f.label, "minute"), y = m === 0 || U(u.label, f.label, "second"), w = m === 0 || U(u.label, f.label, "fractionalSecond"), S = [];
1343
+ if (r && (v || g || x || y || w)) {
1344
+ const b = u.label.find((P) => P.type === "hour")?.value, T = u.label.find((P) => P.type === "minute")?.value, C = u.label.find((P) => P.type === "timeZoneName")?.value;
1345
+ let M = "";
1343
1346
  if (d) {
1344
- const P = c.label.find((K) => K.type === "second")?.value, N = c.label.find(
1347
+ const P = u.label.find((K) => K.type === "second")?.value, N = u.label.find(
1345
1348
  (K) => K.type === "fractionalSecond"
1346
1349
  )?.value;
1347
- E = `:${P}` + (l ? `.${N}` : "");
1350
+ M = `:${P}` + (h ? `.${N}` : "");
1348
1351
  }
1349
1352
  S.push(
1350
- `${T}:${w}${E}` + (e && v ? ` ${M}` : "")
1353
+ `${b}:${T}${M}` + (t && x ? ` ${C}` : "")
1351
1354
  );
1352
1355
  }
1353
- return (u || p) && S.push(
1356
+ return (l || p) && S.push(
1354
1357
  [
1355
- c.label.find((T) => T.type === "month")?.value,
1356
- u && c.label.find((T) => T.type === "day")?.value
1358
+ u.label.find((b) => b.type === "month")?.value,
1359
+ l && u.label.find((b) => b.type === "day")?.value
1357
1360
  ].filter(Boolean).join(" ")
1358
- ), f && S.push(c.label.find((T) => T.type === "year")?.value), {
1359
- value: c.value,
1360
- label: S.filter((T) => T).join(`
1361
+ ), a && S.push(u.label.find((b) => b.type === "year")?.value), {
1362
+ value: u.value,
1363
+ label: S.filter((b) => b).join(`
1361
1364
  `)
1362
1365
  };
1363
1366
  });
1364
1367
  };
1365
1368
  };
1366
1369
  export {
1367
- be as AreaPlot,
1370
+ we as AreaPlot,
1368
1371
  Re as AxisOverlay,
1369
1372
  ge as BarPlot,
1370
1373
  ut as CANPLOT_LAYER,
@@ -1374,11 +1377,11 @@ export {
1374
1377
  ye as LinePlot,
1375
1378
  ve as ScatterPlot,
1376
1379
  ke as SelectBox,
1377
- we as SparklinePlot,
1380
+ be as SparklinePlot,
1378
1381
  Ee as TooltipsX,
1379
1382
  Te as XTicks,
1380
1383
  Ce as YTicks,
1381
- _ as applyStyles,
1384
+ D as applyStyles,
1382
1385
  j as clamp,
1383
1386
  pe as clampUnfit,
1384
1387
  Y as clampXPosToChartArea,
@@ -1388,7 +1391,7 @@ export {
1388
1391
  I as getScale,
1389
1392
  Ae as makeLinearTicks,
1390
1393
  le as makeTimeTickFormat,
1391
- _e as makeTimeTicks,
1394
+ De as makeTimeTicks,
1392
1395
  L as posToVal,
1393
1396
  Ot as pxToValDistance,
1394
1397
  fe as sum,