@canplot/react 0.1.8 → 0.1.10

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