@canplot/react 0.5.3 → 0.5.5

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,9 +1,9 @@
1
1
  var Be = Object.defineProperty;
2
2
  var ze = (e, t, n) => t in e ? Be(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var F = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
3
+ var O = (e, t, n) => ze(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as pe, jsx as R, Fragment as Ne } from "react/jsx-runtime";
5
- import D, { version as $e, createContext as ye, forwardRef as je, useRef as k, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as Ve, useContext as q, useEffect as ke, useId as He } from "react";
6
- const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
5
+ import D, { version as $e, createContext as ye, forwardRef as je, useRef as A, useState as B, useMemo as Z, useLayoutEffect as $, useCallback as Ve, useContext as q, useEffect as Ae, useId as He } from "react";
6
+ const re = (e, t, n) => Math.min(Math.max(e, t), n), At = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Rt = (e, t) => {
7
7
  let n = 0;
8
8
  for (let s = 0; s < e.length; s++)
9
9
  Math.abs(e[s] - t) < Math.abs(e[n] - t) && (n = s);
@@ -63,19 +63,19 @@ const re = (e, t, n) => Math.min(Math.max(e, t), n), kt = (e) => e.reduce((t, n)
63
63
  return null;
64
64
  const r = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = o.origin === "x" ? (t - r.x) / r.width : (r.height - t + r.y) / r.height;
65
65
  return o.min + i * (o.max - o.min);
66
- }, O = (e, t) => {
66
+ }, F = (e, t) => {
67
67
  if (e === t) return !0;
68
68
  if (e == null || t == null || typeof e != typeof t || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
69
69
  if (Array.isArray(e) && Array.isArray(t)) {
70
70
  if (e.length !== t.length) return !1;
71
71
  for (let o = 0; o < e.length; o++)
72
- if (!O(e[o], t[o])) return !1;
72
+ if (!F(e[o], t[o])) return !1;
73
73
  return !0;
74
74
  }
75
75
  const n = Object.keys(e), s = Object.keys(t);
76
76
  if (n.length !== s.length) return !1;
77
77
  for (const o of n)
78
- if (!Object.prototype.hasOwnProperty.call(t, o) || !O(e[o], t[o])) return !1;
78
+ if (!Object.prototype.hasOwnProperty.call(t, o) || !F(e[o], t[o])) return !1;
79
79
  return !0;
80
80
  }, qe = (e) => {
81
81
  const { ctx: t, scales: n } = e;
@@ -149,13 +149,13 @@ const Re = ye({
149
149
  };
150
150
  class Le {
151
151
  constructor() {
152
- F(this, "_frame", null);
153
- F(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
154
- F(this, "clampYPosToChartArea", (t, n = "canvas") => H(this.frame, t, n));
155
- F(this, "valToPos", (t, n, s = "canvas") => G(this.frame, t, n, s));
156
- F(this, "valToPxDistance", (t, n, s = "canvas") => ge(this.frame, t, n, s));
157
- F(this, "valFits", (t, n) => fe(this.frame, t, n));
158
- F(this, "getScale", (t) => X(this.frame, t));
152
+ O(this, "_frame", null);
153
+ O(this, "clampXPosToChartArea", (t, n = "canvas") => V(this.frame, t, n));
154
+ O(this, "clampYPosToChartArea", (t, n = "canvas") => H(this.frame, t, n));
155
+ O(this, "valToPos", (t, n, s = "canvas") => G(this.frame, t, n, s));
156
+ O(this, "valToPxDistance", (t, n, s = "canvas") => ge(this.frame, t, n, s));
157
+ O(this, "valFits", (t, n) => fe(this.frame, t, n));
158
+ O(this, "getScale", (t) => X(this.frame, t));
159
159
  }
160
160
  _updateFrame(t) {
161
161
  this._frame = t;
@@ -169,8 +169,8 @@ class Le {
169
169
  return this.frame.ctx;
170
170
  }
171
171
  }
172
- const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) => {
173
- const r = k(null), i = k(null), c = tt(i), [l, u] = B(null), f = Z(
172
+ const Dt = je(({ configuration: e, children: t, style: n, ...s }, o) => {
173
+ const r = A(null), i = A(null), c = tt(i), [l, u] = B(null), f = Z(
174
174
  () => nt(e, c, l),
175
175
  [e, c, l]
176
176
  );
@@ -182,13 +182,13 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
182
182
  "div",
183
183
  {
184
184
  ref: Je([o, i]),
185
- className: s,
186
185
  style: {
187
186
  position: "relative",
188
187
  overflow: "hidden",
189
188
  ...n
190
189
  },
191
190
  "data-canplotroot": !0,
191
+ ...s,
192
192
  children: [
193
193
  /* @__PURE__ */ R(
194
194
  "canvas",
@@ -216,7 +216,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
216
216
  $(() => {
217
217
  e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
218
218
  }, [e, s]);
219
- const r = k(null);
219
+ const r = A(null);
220
220
  r.current = e, $(() => {
221
221
  n.subscribe(() => {
222
222
  r.current && qe(r.current);
@@ -326,7 +326,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
326
326
  case "bottom":
327
327
  throw new Error("Invalid axis position for y origin");
328
328
  }
329
- const h = {
329
+ const d = {
330
330
  x: p.x * s,
331
331
  y: p.y * s,
332
332
  width: p.width * s,
@@ -337,7 +337,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
337
337
  axis: {
338
338
  ...a.axis,
339
339
  cssRect: p,
340
- canvasRect: h
340
+ canvasRect: d
341
341
  }
342
342
  });
343
343
  }
@@ -355,9 +355,9 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
355
355
  throw new Error("useFrame must be used within a CanPlot component");
356
356
  const [i] = B(() => new Le());
357
357
  i._updateFrame(s);
358
- const c = k(i);
358
+ const c = A(i);
359
359
  c.current = i;
360
- const l = k(t);
360
+ const l = A(t);
361
361
  l.current = t, $(() => {
362
362
  const u = r.subscribe(
363
363
  () => {
@@ -370,7 +370,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
370
370
  };
371
371
  }, [r, e, i]), $(() => {
372
372
  o();
373
- }, [o, ...n]), ke(() => () => {
373
+ }, [o, ...n]), Ae(() => () => {
374
374
  o();
375
375
  }, [o]);
376
376
  }, Ue = () => {
@@ -392,7 +392,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
392
392
  r.stroke(), r.restore();
393
393
  },
394
394
  [t, n, s, o]
395
- ), null), It = D.memo(st, O), ot = ({
395
+ ), null), It = D.memo(st, F), ot = ({
396
396
  layer: e = "MIDDLE",
397
397
  data: t,
398
398
  xScaleId: n,
@@ -412,20 +412,20 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
412
412
  clampYPosToChartArea: p
413
413
  }) => {
414
414
  u.save(), u.beginPath();
415
- const h = new Path2D();
415
+ const d = new Path2D();
416
416
  U(u, c), l !== void 0 && (u.globalAlpha = l);
417
417
  for (const y of t) {
418
- let d, g;
418
+ let h, g;
419
419
  switch (o) {
420
420
  case "clip":
421
421
  if (!m(y.x, n))
422
422
  continue;
423
- d = f(y.x, n);
423
+ h = f(y.x, n);
424
424
  break;
425
425
  case "clamp": {
426
426
  if (f(y.x, n) === null)
427
427
  continue;
428
- d = a(f(y.x, n), "canvas");
428
+ h = a(f(y.x, n), "canvas");
429
429
  break;
430
430
  }
431
431
  }
@@ -439,12 +439,12 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
439
439
  g = p(f(y.y, s), "canvas");
440
440
  break;
441
441
  }
442
- d === null || g === null || (h.moveTo(d + i, g), h.arc(d, g, i, 0, Math.PI * 2));
442
+ h === null || g === null || (d.moveTo(h + i, g), d.arc(h, g, i, 0, Math.PI * 2));
443
443
  }
444
- u.fill(h), u.stroke(h), u.restore();
444
+ u.fill(d), u.stroke(d), u.restore();
445
445
  },
446
446
  [t, n, s, i, c, l]
447
- ), null), Lt = D.memo(ot, O), rt = ({
447
+ ), null), Lt = D.memo(ot, F), rt = ({
448
448
  data: e,
449
449
  xScaleId: t,
450
450
  yScaleId: n,
@@ -466,23 +466,23 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
466
466
  l.save(), U(l, s);
467
467
  const p = u(o, t) ?? 0;
468
468
  l.beginPath();
469
- for (const h of e) {
470
- const y = f(h.x, t);
469
+ for (const d of e) {
470
+ const y = f(d.x, t);
471
471
  if (y === null)
472
472
  continue;
473
- const d = y - p / 2 + r * p, g = a(
473
+ const h = y - p / 2 + r * p, g = a(
474
474
  f(0, n, "canvas"),
475
475
  "canvas"
476
476
  );
477
477
  if (g === null)
478
478
  continue;
479
479
  const w = a(
480
- f(h.y, n, "canvas"),
480
+ f(d.y, n, "canvas"),
481
481
  "canvas"
482
482
  );
483
483
  if (w === null)
484
484
  continue;
485
- const x = g - w, b = m(d, "canvas"), v = m(d + p, "canvas") - b;
485
+ const x = g - w, b = m(h, "canvas"), v = m(h + p, "canvas") - b;
486
486
  i ? l.roundRect(
487
487
  b,
488
488
  w,
@@ -494,7 +494,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
494
494
  l.closePath(), l.fill(), s?.strokeStyle && l.stroke(), l.restore();
495
495
  },
496
496
  [e, t, n, s, o, r, i]
497
- ), null), Ut = D.memo(rt, O), it = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
497
+ ), null), Ut = D.memo(rt, F), it = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
498
498
  e,
499
499
  ({ ctx: r, clampXPosToChartArea: i, clampYPosToChartArea: c, valToPos: l }) => {
500
500
  const u = [];
@@ -505,8 +505,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
505
505
  const p = c(l(m.y[0], s));
506
506
  if (p === null)
507
507
  continue;
508
- const h = c(l(m.y[1], s));
509
- h !== null && (u.push({ x: a, y: p }), u.unshift({ x: a, y: h }));
508
+ const d = c(l(m.y[1], s));
509
+ d !== null && (u.push({ x: a, y: p }), u.unshift({ x: a, y: d }));
510
510
  }
511
511
  const f = u[0];
512
512
  if (f) {
@@ -517,13 +517,13 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
517
517
  }
518
518
  },
519
519
  [t, n, s, o]
520
- ), null), _t = D.memo(it, O), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: r }) => (j(
520
+ ), null), _t = D.memo(it, F), ct = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: r }) => (j(
521
521
  e,
522
522
  ({ ctx: i, clampXPosToChartArea: c, clampYPosToChartArea: l, valToPos: u }) => {
523
523
  const f = [];
524
- for (const h of t) {
525
- const y = c(u(h.x, s)), d = l(u(h.y, o));
526
- y === null || d === null || f.push({ x: y, y: d });
524
+ for (const d of t) {
525
+ const y = c(u(d.x, s)), h = l(u(d.y, o));
526
+ y === null || h === null || f.push({ x: y, y: h });
527
527
  }
528
528
  const m = f.at(0), a = f.at(-1);
529
529
  if (!m || !a)
@@ -531,19 +531,19 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
531
531
  const p = l(u(0, o));
532
532
  if (p !== null) {
533
533
  i.save(), i.beginPath(), U(i, r), i.moveTo(m.x, p);
534
- for (const h of f)
535
- i.lineTo(h.x, h.y);
534
+ for (const d of f)
535
+ i.lineTo(d.x, d.y);
536
536
  if (i.lineTo(a.x, p), i.closePath(), i.fill(), n) {
537
537
  i.beginPath(), i.moveTo(m.x, m.y);
538
- for (const h of f)
539
- i.lineTo(h.x, h.y);
538
+ for (const d of f)
539
+ i.lineTo(d.x, d.y);
540
540
  i.stroke();
541
541
  }
542
542
  i.restore();
543
543
  }
544
544
  },
545
545
  [t, n, s, o, r]
546
- ), null), Xt = D.memo(ct, O), at = ({
546
+ ), null), Xt = D.memo(ct, F), at = ({
547
547
  layer: e = "BOTTOM",
548
548
  scaleId: t,
549
549
  tickStyle: n,
@@ -556,7 +556,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
556
556
  ({ ctx: c, valToPos: l, getScale: u, frame: f }) => {
557
557
  const m = u(t);
558
558
  if (!m || !m.axis || m.origin !== "x") return;
559
- const a = m.axis, p = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, h = window.devicePixelRatio || 1, y = p, d = (r ?? 6) * h, g = a.position === "top" ? p - d : p + d, w = (o ?? 12) * h;
559
+ const a = m.axis, p = a.position === "top" ? a.canvasRect.y + a.canvasRect.height : a.canvasRect.y, d = window.devicePixelRatio || 1, y = p, h = (r ?? 6) * d, g = a.position === "top" ? p - h : p + h, w = (o ?? 12) * d;
560
560
  c.save(), c.fontKerning = "auto", U(c, {
561
561
  ...n
562
562
  }), c.beginPath();
@@ -580,12 +580,12 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
580
580
  const C = v.split(`
581
581
  `);
582
582
  for (let E = 0; E < C.length; E++)
583
- c.fillText(C[E], T, g + h * 2 + E * w);
583
+ c.fillText(C[E], T, g + d * 2 + E * w);
584
584
  }
585
585
  c.restore();
586
586
  },
587
587
  [i, t, n, s]
588
- ), null), Ot = D.memo(at, O), lt = ({
588
+ ), null), Ft = D.memo(at, F), lt = ({
589
589
  layer: e = "BOTTOM",
590
590
  scaleId: t,
591
591
  tickStyle: n,
@@ -598,11 +598,11 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
598
598
  ({ ctx: c, valToPos: l, getScale: u, frame: f }) => {
599
599
  const m = u(t);
600
600
  if (!m || !m.axis || m.origin !== "y") return;
601
- const a = m.axis, p = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, h = p, y = r ?? 6, d = a.position === "left" ? p - y : p + y, g = o ?? 12, w = Array.isArray(i) ? i : i({ ...m, axis: a }, f);
601
+ const a = m.axis, p = a.position === "left" ? a.canvasRect.x + a.canvasRect.width : a.canvasRect.x, d = p, y = r ?? 6, h = a.position === "left" ? p - y : p + y, g = o ?? 12, w = Array.isArray(i) ? i : i({ ...m, axis: a }, f);
602
602
  c.save(), c.fontKerning = "auto", U(c, { ...n }), c.beginPath();
603
603
  for (const { value: x } of w) {
604
604
  const b = l(x, t, "canvas");
605
- b !== null && (c.moveTo(h, b), c.lineTo(d, b));
605
+ b !== null && (c.moveTo(d, b), c.lineTo(h, b));
606
606
  }
607
607
  c.stroke(), c.restore(), c.save(), U(c, {
608
608
  textBaseline: "middle",
@@ -619,12 +619,12 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
619
619
  const T = b.split(`
620
620
  `);
621
621
  for (let C = 0; C < T.length; C++)
622
- c.fillText(` ${T[C]} `, d, v + C * g);
622
+ c.fillText(` ${T[C]} `, h, v + C * g);
623
623
  }
624
624
  c.restore();
625
625
  },
626
626
  [i, t, n, s]
627
- ), null), Ft = D.memo(lt, O), _e = (e) => {
627
+ ), null), Ot = D.memo(lt, F), _e = (e) => {
628
628
  if (e)
629
629
  try {
630
630
  return e.replace(/(\d+)px/, (t, n) => `${parseInt(n) * window.devicePixelRatio || 1}px`);
@@ -739,24 +739,24 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
739
739
  innerChildren: a,
740
740
  children: p
741
741
  }) => {
742
- const h = He();
743
- return L("dblclick", h, (y) => {
742
+ const d = He();
743
+ return L("dblclick", d, (y) => {
744
744
  n?.(y);
745
- }), L("click", h, (y) => {
745
+ }), L("click", d, (y) => {
746
746
  t?.(y);
747
- }), L("move", h, (y) => {
747
+ }), L("move", d, (y) => {
748
748
  s?.(y);
749
- }), L("mousedown", h, (y) => {
749
+ }), L("mousedown", d, (y) => {
750
750
  o?.(y);
751
- }), L("mouseup", h, (y) => {
751
+ }), L("mouseup", d, (y) => {
752
752
  r?.(y);
753
- }), L("documentmouseup", h, (y) => {
753
+ }), L("documentmouseup", d, (y) => {
754
754
  i?.(y);
755
- }), L("spanselect", h, (y) => {
755
+ }), L("spanselect", d, (y) => {
756
756
  c?.(y);
757
- }), L("contextmenu", h, (y) => {
757
+ }), L("contextmenu", d, (y) => {
758
758
  l?.(y);
759
- }), /* @__PURE__ */ pe(we.Provider, { value: h, children: [
759
+ }), /* @__PURE__ */ pe(we.Provider, { value: d, children: [
760
760
  /* @__PURE__ */ R(
761
761
  ht,
762
762
  {
@@ -770,20 +770,20 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
770
770
  p
771
771
  ] });
772
772
  }, ht = ({ id: e, className: t, style: n, sync: s, children: o }) => {
773
- const r = k(null), i = Ue().frame, c = k(i);
773
+ const r = A(null), i = Ue().frame, c = A(i);
774
774
  c.current = i;
775
- const l = q(we), u = s?.key || l, f = k(null), m = k(null), a = k(null), p = () => {
776
- const d = r.current?.parentElement;
777
- if (d) {
778
- if (d.dataset.canplotroot === void 0)
775
+ const l = q(we), u = s?.key || l, f = A(null), m = A(null), a = A(null), p = () => {
776
+ const h = r.current?.parentElement;
777
+ if (h) {
778
+ if (h.dataset.canplotroot === void 0)
779
779
  throw new Error(
780
780
  "ChartAreaInteractions must be used within a CanPlot component"
781
781
  );
782
- return d.getBoundingClientRect();
782
+ return h.getBoundingClientRect();
783
783
  }
784
- }, h = (d, g) => {
784
+ }, d = (h, g) => {
785
785
  const w = ut(
786
- d,
786
+ h,
787
787
  p(),
788
788
  c.current,
789
789
  s?.xViaScaleId,
@@ -793,15 +793,15 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
793
793
  w.pointerSyncPosition,
794
794
  { cssX: w.cssX, cssY: w.cssY },
795
795
  {
796
- ctrlKey: d.ctrlKey,
797
- altKey: d.altKey,
798
- shiftKey: d.shiftKey,
799
- metaKey: d.metaKey
796
+ ctrlKey: h.ctrlKey,
797
+ altKey: h.altKey,
798
+ shiftKey: h.shiftKey,
799
+ metaKey: h.metaKey
800
800
  }
801
801
  );
802
- }, y = k(h);
803
- return y.current = h, ke(() => {
804
- const d = (v) => {
802
+ }, y = A(d);
803
+ return y.current = d, Ae(() => {
804
+ const h = (v) => {
805
805
  const T = m.current;
806
806
  T && M.spanselect.dispatchEvent(l, {
807
807
  ...T,
@@ -842,9 +842,9 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
842
842
  (T, { cssX: C, cssY: E }, S) => {
843
843
  const P = f.current;
844
844
  if (!P || !T.x || !T.y) return;
845
- const A = c.current, z = P.xRangeCss.start, ae = C, le = P.yRangeCss.start, ue = E, J = X(A, T.x.scaleId);
845
+ const k = c.current, z = P.xRangeCss.start, ae = C, le = P.yRangeCss.start, ue = E, J = X(k, T.x.scaleId);
846
846
  if (!J) return;
847
- const Q = X(A, T.y.scaleId);
847
+ const Q = X(k, T.y.scaleId);
848
848
  if (!Q) return;
849
849
  f.current = {
850
850
  xRangeCss: { start: z, end: ae },
@@ -854,28 +854,28 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
854
854
  const he = Math.abs(le - ue), de = Math.abs(z - ae);
855
855
  he < 10 && de < 10 ? W = "below_threshold" : he > 30 && de > 30 ? W = "box" : he > de ? W = "y" : W = "x";
856
856
  const Te = _(
857
- A,
857
+ k,
858
858
  V(c.current, z, "css"),
859
859
  J.id,
860
860
  "css"
861
861
  );
862
862
  if (Te === null) return;
863
863
  const Ce = _(
864
- A,
864
+ k,
865
865
  V(c.current, ae, "css"),
866
866
  J.id,
867
867
  "css"
868
868
  );
869
869
  if (Ce === null) return;
870
870
  const Se = _(
871
- A,
871
+ k,
872
872
  H(c.current, le, "css"),
873
873
  Q.id,
874
874
  "css"
875
875
  );
876
876
  if (Se === null) return;
877
877
  const Pe = _(
878
- A,
878
+ k,
879
879
  H(c.current, ue, "css"),
880
880
  Q.id,
881
881
  "css"
@@ -922,37 +922,37 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
922
922
  c.current
923
923
  );
924
924
  if (!S) return;
925
- if (Object.values(E).some((A) => A)) {
925
+ if (Object.values(E).some((k) => k)) {
926
926
  v.preventDefault();
927
- const A = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
927
+ const k = Math.abs(v.deltaY) > Math.abs(v.deltaX) ? v.deltaY : v.deltaX;
928
928
  M.pressandwheel.dispatchEvent(l, {
929
929
  pointer: S,
930
930
  frame: c.current,
931
931
  keys: E,
932
932
  deltaX: v.deltaX,
933
933
  deltaY: v.deltaY,
934
- deltaAbs: A
934
+ deltaAbs: k
935
935
  });
936
936
  }
937
937
  });
938
938
  };
939
- document.addEventListener("mouseup", d), document.addEventListener("keydown", g), document.addEventListener("keyup", g), document.addEventListener("mousemove", w);
939
+ document.addEventListener("mouseup", h), document.addEventListener("keydown", g), document.addEventListener("keyup", g), document.addEventListener("mousemove", w);
940
940
  const b = r.current;
941
941
  return b?.addEventListener("wheel", x, {
942
942
  passive: !1
943
943
  }), () => {
944
- document.removeEventListener("mouseup", d), document.removeEventListener("keydown", g), document.removeEventListener("keyup", g), document.removeEventListener("mousemove", w), b?.removeEventListener("wheel", x);
944
+ document.removeEventListener("mouseup", h), document.removeEventListener("keydown", g), document.removeEventListener("keyup", g), document.removeEventListener("mousemove", w), b?.removeEventListener("wheel", x);
945
945
  };
946
- }, [c, l, u, y]), L("sync_move", u, (d) => {
947
- const g = d.positions ? N(
948
- d.positions,
946
+ }, [c, l, u, y]), L("sync_move", u, (h) => {
947
+ const g = h.positions ? N(
948
+ h.positions,
949
949
  c.current
950
950
  ) : null;
951
- a.current = d, M.move.dispatchEvent(l, {
951
+ a.current = h, M.move.dispatchEvent(l, {
952
952
  frame: c.current,
953
953
  pointer: g ?? null,
954
- keys: d.keys,
955
- source: d.originInteractionsId === l ? "own" : "sync"
954
+ keys: h.keys,
955
+ source: h.originInteractionsId === l ? "own" : "sync"
956
956
  });
957
957
  }), /* @__PURE__ */ R(
958
958
  "div",
@@ -969,11 +969,11 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
969
969
  zIndex: 25,
970
970
  ...n
971
971
  },
972
- onDragStart: (d) => {
973
- d.preventDefault();
972
+ onDragStart: (h) => {
973
+ h.preventDefault();
974
974
  },
975
- onClick: (d) => {
976
- h(d, (g, w, x) => {
975
+ onClick: (h) => {
976
+ d(h, (g, w, x) => {
977
977
  const b = N(
978
978
  g,
979
979
  c.current
@@ -985,8 +985,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
985
985
  });
986
986
  });
987
987
  },
988
- onMouseLeave: (d) => {
989
- h(d, (g, w, x) => {
988
+ onMouseLeave: (h) => {
989
+ d(h, (g, w, x) => {
990
990
  M.sync_move.dispatchEvent(u, {
991
991
  positions: null,
992
992
  keys: x,
@@ -994,8 +994,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
994
994
  });
995
995
  });
996
996
  },
997
- onMouseMove: (d) => {
998
- h(d, (g, w, x) => {
997
+ onMouseMove: (h) => {
998
+ d(h, (g, w, x) => {
999
999
  M.sync_move.dispatchEvent(u, {
1000
1000
  positions: g,
1001
1001
  keys: x,
@@ -1003,8 +1003,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1003
1003
  });
1004
1004
  });
1005
1005
  },
1006
- onMouseDown: (d) => {
1007
- h(d, (g, { cssX: w, cssY: x }, b) => {
1006
+ onMouseDown: (h) => {
1007
+ d(h, (g, { cssX: w, cssY: x }, b) => {
1008
1008
  const v = N(
1009
1009
  g,
1010
1010
  c.current
@@ -1019,8 +1019,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1019
1019
  });
1020
1020
  });
1021
1021
  },
1022
- onMouseUp: (d) => {
1023
- h(d, (g, w, x) => {
1022
+ onMouseUp: (h) => {
1023
+ d(h, (g, w, x) => {
1024
1024
  const b = N(
1025
1025
  g,
1026
1026
  c.current
@@ -1047,8 +1047,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1047
1047
  }
1048
1048
  });
1049
1049
  },
1050
- onContextMenu: (d) => {
1051
- d.preventDefault(), h(d, (g, w, x) => {
1050
+ onContextMenu: (h) => {
1051
+ h.preventDefault(), d(h, (g, w, x) => {
1052
1052
  const b = N(
1053
1053
  g,
1054
1054
  c.current
@@ -1060,8 +1060,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1060
1060
  });
1061
1061
  });
1062
1062
  },
1063
- onDoubleClick: (d) => {
1064
- h(d, (g, w, x) => {
1063
+ onDoubleClick: (h) => {
1064
+ d(h, (g, w, x) => {
1065
1065
  const b = N(
1066
1066
  g,
1067
1067
  c.current
@@ -1090,15 +1090,15 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1090
1090
  const f = [];
1091
1091
  let m = l;
1092
1092
  for (const a of e) {
1093
- let p = null, h = 1 / 0;
1093
+ let p = null, d = 1 / 0;
1094
1094
  for (const [g, w] of a.points.entries()) {
1095
1095
  if (!fe(i, w.x, n) || !fe(i, w.y, a.yScaleId))
1096
1096
  continue;
1097
1097
  const x = Math.abs(w.x - l);
1098
- x < h && (h = x, p = g);
1098
+ x < d && (d = x, p = g);
1099
1099
  }
1100
- const y = a.points[p ?? -1], d = ge(i, h, n, "css");
1101
- if (!y || d === null || d > 30) {
1100
+ const y = a.points[p ?? -1], h = ge(i, d, n, "css");
1101
+ if (!y || h === null || h > 30) {
1102
1102
  f.push({ seriesId: a.seriesId, y: null });
1103
1103
  continue;
1104
1104
  }
@@ -1174,8 +1174,8 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1174
1174
  const o = Z(() => {
1175
1175
  if (!n || n.mode === "below_threshold")
1176
1176
  return null;
1177
- const r = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, i = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, l = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, u = V(n.frame, r, "css"), f = V(n.frame, i, "css"), m = H(n.frame, c, "css"), a = H(n.frame, l, "css"), p = Math.min(u, f), h = Math.min(m, a), y = Math.abs(f - u), d = Math.abs(a - m);
1178
- return { leftPx: p, topPx: h, widthPx: y, heightPx: d };
1177
+ const r = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, i = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, c = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, l = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, u = V(n.frame, r, "css"), f = V(n.frame, i, "css"), m = H(n.frame, c, "css"), a = H(n.frame, l, "css"), p = Math.min(u, f), d = Math.min(m, a), y = Math.abs(f - u), h = Math.abs(a - m);
1178
+ return { leftPx: p, topPx: d, widthPx: y, heightPx: h };
1179
1179
  }, [n]);
1180
1180
  return /* @__PURE__ */ R(
1181
1181
  "div",
@@ -1211,7 +1211,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1211
1211
  children: t
1212
1212
  }
1213
1213
  ) : null;
1214
- }, Xe = 60, dt = 30, Oe = "UTC", ft = "en-GB", $t = ({
1214
+ }, Xe = 60, dt = 30, Fe = "UTC", ft = "en-GB", $t = ({
1215
1215
  space: e,
1216
1216
  formatter: t,
1217
1217
  acceptableIncrements: n
@@ -1224,11 +1224,11 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1224
1224
  );
1225
1225
  if (f === null)
1226
1226
  return [];
1227
- const m = n ?? ne, a = m.find((h) => h > f) ?? m.at(-1) ?? 1;
1227
+ const m = n ?? ne, a = m.find((d) => d > f) ?? m.at(-1) ?? 1;
1228
1228
  let p = r;
1229
1229
  if (Math.abs(p % a) > Number.EPSILON) {
1230
- const h = (a - p % a) % a;
1231
- p += h;
1230
+ const d = (a - p % a) % a;
1231
+ p += d;
1232
1232
  }
1233
1233
  for (; p <= i && c.length < 1e3; )
1234
1234
  c.push(p), p += a;
@@ -1239,7 +1239,7 @@ const Dt = je(({ configuration: e, children: t, style: n, className: s }, o) =>
1239
1239
  }, ne = [];
1240
1240
  for (let e = -12; e <= 12; e++)
1241
1241
  ne.push(1 * 10 ** e), ne.push(2 * 10 ** e), ne.push(5 * 10 ** e);
1242
- const pt = 1, Fe = 1e3 * pt, be = 60 * Fe, ie = 60 * be, ce = 24 * ie, yt = 30 * ce, gt = 365 * ce, vt = [
1242
+ const pt = 1, Oe = 1e3 * pt, be = 60 * Oe, ie = 60 * be, ce = 24 * ie, yt = 30 * ce, gt = 365 * ce, vt = [
1243
1243
  // second divisors
1244
1244
  [1, "milliseconds"],
1245
1245
  [2, "milliseconds"],
@@ -1297,7 +1297,7 @@ const pt = 1, Fe = 1e3 * pt, be = 60 * Fe, ie = 60 * be, ce = 24 * ie, yt = 30 *
1297
1297
  case "milliseconds":
1298
1298
  return t;
1299
1299
  case "seconds":
1300
- return t * Fe;
1300
+ return t * Oe;
1301
1301
  case "minutes":
1302
1302
  return t * be;
1303
1303
  case "hours":
@@ -1324,7 +1324,7 @@ const pt = 1, Fe = 1e3 * pt, be = 60 * Fe, ie = 60 * be, ce = 24 * ie, yt = 30 *
1324
1324
  }, Ct = (e, t) => {
1325
1325
  const n = new Date(e);
1326
1326
  return n.setUTCDate(n.getUTCDate() + t), n.getTime();
1327
- }, Ae = (e, t) => {
1327
+ }, ke = (e, t) => {
1328
1328
  const n = new Date(e);
1329
1329
  return n.setUTCMonth(n.getUTCMonth() + t), n.getTime();
1330
1330
  }, Y = (e, t) => {
@@ -1341,9 +1341,9 @@ const pt = 1, Fe = 1e3 * pt, be = 60 * Fe, ie = 60 * be, ce = 24 * ie, yt = 30 *
1341
1341
  case "days":
1342
1342
  return Ct(e, n);
1343
1343
  case "months":
1344
- return Ae(e, n);
1344
+ return ke(e, n);
1345
1345
  case "years":
1346
- return Ae(e, n * 12);
1346
+ return ke(e, n * 12);
1347
1347
  }
1348
1348
  };
1349
1349
  function oe(e, t) {
@@ -1391,28 +1391,34 @@ const St = (e, t, n = "UTC") => {
1391
1391
  }
1392
1392
  return r.getTime();
1393
1393
  }, jt = ({
1394
- timeZone: e = Oe,
1394
+ timeZone: e = Fe,
1395
1395
  space: t = Xe,
1396
1396
  formatter: n,
1397
1397
  locale: s,
1398
1398
  showTimezone: o
1399
1399
  } = {}) => (r, i) => {
1400
- const { min: c, max: l } = r, u = Math.floor(i.chartAreaCanvasPX.width / t) + 1, m = (l - c) / u, [a, p] = vt.find(
1400
+ const { min: c, max: l } = r;
1401
+ if (!Number.isFinite(c) || !Number.isFinite(l))
1402
+ return [];
1403
+ const u = Math.floor(i.chartAreaCanvasPX.width / t) + 1, m = (l - c) / u, [a, p] = vt.find(
1401
1404
  (w) => se(w) >= m
1402
- ) ?? [1, "milliseconds"], h = St(c, [a, p], e), y = oe(h, e), d = [h];
1405
+ ) ?? [1, "milliseconds"];
1406
+ if (!a || !p)
1407
+ return [];
1408
+ const d = St(c, [a, p], e), y = oe(d, e), h = [d];
1403
1409
  let g;
1404
- for (; ; ) {
1410
+ for (; !(h.length > 1e3); ) {
1405
1411
  switch (p) {
1406
1412
  case "milliseconds":
1407
1413
  case "seconds":
1408
1414
  case "minutes":
1409
1415
  case "hours": {
1410
- g = Y(h, [d.length * a, p]);
1416
+ g = Y(d, [h.length * a, p]);
1411
1417
  break;
1412
1418
  }
1413
1419
  case "days": {
1414
- const w = Y(h, [
1415
- d.length * a,
1420
+ const w = Y(d, [
1421
+ h.length * a,
1416
1422
  p
1417
1423
  ]);
1418
1424
  g = Y(w, [
@@ -1424,8 +1430,8 @@ const St = (e, t, n = "UTC") => {
1424
1430
  case "months":
1425
1431
  case "years": {
1426
1432
  const w = Y(
1427
- Y(Y(h, [y, "hours"]), [
1428
- d.length * a,
1433
+ Y(Y(d, [y, "hours"]), [
1434
+ h.length * a,
1429
1435
  p
1430
1436
  ]),
1431
1437
  [-y, "hours"]
@@ -1439,15 +1445,15 @@ const St = (e, t, n = "UTC") => {
1439
1445
  }
1440
1446
  if (g > l)
1441
1447
  break;
1442
- d.push(g);
1448
+ h.push(g);
1443
1449
  }
1444
1450
  return (n ?? Pt({
1445
1451
  locale: s,
1446
1452
  showTimezone: o,
1447
1453
  timeZone: e
1448
- }))(d);
1454
+ }))(h);
1449
1455
  }, K = (e, t, n) => e.find((s) => s.type === n)?.value !== t.find((s) => s.type === n)?.value, Pt = ({
1450
- timeZone: e = Oe,
1456
+ timeZone: e = Fe,
1451
1457
  locale: t = ft,
1452
1458
  showTimezone: n = !0
1453
1459
  }) => {
@@ -1466,24 +1472,24 @@ const St = (e, t, n = "UTC") => {
1466
1472
  return (o) => {
1467
1473
  const r = o[1] - o[0], i = r < se([1, "days"]), c = r < se([1, "minutes"]), l = r < se([1, "seconds"]);
1468
1474
  return o.map((u) => ({ value: u, label: s.formatToParts(new Date(u)) })).map((u, f, m) => {
1469
- const a = m[f - 1], p = f === 0 || K(u.label, a.label, "year"), h = f === 0 || K(u.label, a.label, "day"), y = f === 0 || K(u.label, a.label, "month"), d = f === 0 || K(u.label, a.label, "hour"), g = f === 0 || K(u.label, a.label, "timeZoneName"), w = f === 0 || K(u.label, a.label, "minute"), x = f === 0 || K(u.label, a.label, "second"), b = f === 0 || K(u.label, a.label, "fractionalSecond"), v = [];
1470
- if (i && (d || w || g || x || b)) {
1475
+ const a = m[f - 1], p = f === 0 || K(u.label, a.label, "year"), d = f === 0 || K(u.label, a.label, "day"), y = f === 0 || K(u.label, a.label, "month"), h = f === 0 || K(u.label, a.label, "hour"), g = f === 0 || K(u.label, a.label, "timeZoneName"), w = f === 0 || K(u.label, a.label, "minute"), x = f === 0 || K(u.label, a.label, "second"), b = f === 0 || K(u.label, a.label, "fractionalSecond"), v = [];
1476
+ if (i && (h || w || g || x || b)) {
1471
1477
  const T = u.label.find((P) => P.type === "hour")?.value, C = u.label.find((P) => P.type === "minute")?.value, E = u.label.find((P) => P.type === "timeZoneName")?.value;
1472
1478
  let S = "";
1473
1479
  if (c) {
1474
- const P = u.label.find((z) => z.type === "second")?.value, A = u.label.find(
1480
+ const P = u.label.find((z) => z.type === "second")?.value, k = u.label.find(
1475
1481
  (z) => z.type === "fractionalSecond"
1476
1482
  )?.value;
1477
- S = `:${P}` + (l ? `.${A}` : "");
1483
+ S = `:${P}` + (l ? `.${k}` : "");
1478
1484
  }
1479
1485
  v.push(
1480
1486
  `${T}:${C}${S}` + (n && g ? ` ${E}` : "")
1481
1487
  );
1482
1488
  }
1483
- return (h || y) && v.push(
1489
+ return (d || y) && v.push(
1484
1490
  [
1485
1491
  u.label.find((T) => T.type === "month")?.value,
1486
- h && u.label.find((T) => T.type === "day")?.value
1492
+ d && u.label.find((T) => T.type === "day")?.value
1487
1493
  ].filter(Boolean).join(" ")
1488
1494
  ), p && v.push(u.label.find((T) => T.type === "year")?.value), {
1489
1495
  value: u.value,
@@ -1507,13 +1513,13 @@ export {
1507
1513
  zt as SelectBox,
1508
1514
  Xt as SparklinePlot,
1509
1515
  Yt as TooltipsX,
1510
- Ot as XTicks,
1511
- Ft as YTicks,
1516
+ Ft as XTicks,
1517
+ Ot as YTicks,
1512
1518
  U as applyStyles,
1513
1519
  re as clamp,
1514
1520
  V as clampXPosToChartArea,
1515
1521
  H as clampYPosToChartArea,
1516
- O as deepEqual,
1522
+ F as deepEqual,
1517
1523
  mt as defaultNumericalTicksFormatter,
1518
1524
  Rt as findClosestIndex,
1519
1525
  X as getScale,
@@ -1522,7 +1528,7 @@ export {
1522
1528
  jt as makeTimeTicks,
1523
1529
  _ as posToVal,
1524
1530
  We as pxToValDistance,
1525
- kt as sum,
1531
+ At as sum,
1526
1532
  j as useDrawEffect,
1527
1533
  Ue as useFrameState,
1528
1534
  xe as useInteractionsEvent,