@canplot/react 0.1.11 → 0.1.13

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,15 +1,15 @@
1
1
  import { jsxs as lt, jsx as _, Fragment as _t } from "react/jsx-runtime";
2
- import Z, { createContext as vt, useContext as J, useRef as L, useLayoutEffect as N, useEffect as wt, version as Rt, forwardRef as At, useMemo as Q, useState as V, useId as Ut } from "react";
2
+ import Z, { createContext as vt, useContext as J, useRef as U, useLayoutEffect as N, useEffect as wt, version as Rt, forwardRef as At, useMemo as Q, useState as V, useId as Ut } from "react";
3
3
  import { createStore as bt, useStore as St } from "zustand";
4
4
  const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e) => s + (e ?? 0), 0), ue = (t, s) => {
5
5
  let e = 0;
6
6
  for (let o = 0; o < t.length; o++)
7
7
  Math.abs(t[o] - s) < Math.abs(t[e] - s) && (e = o);
8
8
  return e;
9
- }, Lt = (t, s, e, o) => {
10
- const { min: n, max: i, origin: a } = I(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = (a === "x" ? r.width : r.height) / (i - n);
9
+ }, Dt = (t, s, e, o) => {
10
+ const { min: n, max: c, origin: a } = L(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = (a === "x" ? r.width : r.height) / (c - n);
11
11
  return s / d;
12
- }, I = (t, s) => {
12
+ }, L = (t, s) => {
13
13
  const e = t.scales.find((o) => o.id === s);
14
14
  if (!e)
15
15
  throw new Error(`Scale ${s} not found`);
@@ -18,11 +18,11 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
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
20
  }, ut = (t, s, e, o) => {
21
- const n = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: i, max: a, origin: r } = I(t, e), d = (r === "x" ? n.width : n.height) / (a - i);
21
+ const n = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, { min: c, max: a, origin: r } = L(t, e), d = (r === "x" ? n.width : n.height) / (a - c);
22
22
  return s * d;
23
23
  }, H = (t, s, e, o) => {
24
- const { min: n, origin: i } = I(t, e), a = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, r = ut(t, s - n, e, o);
25
- return i === "x" ? j(
24
+ const { min: n, origin: c } = L(t, e), a = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, r = ut(t, s - n, e, o);
25
+ return c === "x" ? j(
26
26
  a.x + r,
27
27
  a.x - 10 * a.width,
28
28
  a.x + 11 * a.width
@@ -32,21 +32,21 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
32
32
  a.y + 11 * a.height
33
33
  );
34
34
  }, de = (t, s, e) => {
35
- const { min: o, max: n } = I(t, e);
35
+ const { min: o, max: n } = L(t, e);
36
36
  return j(s, o, n);
37
- }, O = (t, s, e) => {
37
+ }, Y = (t, s, e) => {
38
38
  const o = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
39
39
  return j(s, o.x, o.x + o.width);
40
- }, $ = (t, s, e) => {
40
+ }, O = (t, s, e) => {
41
41
  const o = e === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS;
42
42
  return j(s, o.y, o.y + o.height);
43
43
  }, rt = (t, s, e) => {
44
- const { min: o, max: n } = I(t, e);
44
+ const { min: o, max: n } = L(t, e);
45
45
  return s >= o && s <= n;
46
46
  }, D = (t, s, e, o) => {
47
- const { min: n, max: i, origin: a } = I(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = a === "x" ? (s - r.x) / r.width : (r.height - s + r.y) / r.height;
48
- return n + d * (i - n);
49
- }, Dt = (t) => {
47
+ const { min: n, max: c, origin: a } = L(t, e), r = o === "canvas" ? t.chartAreaCanvasPX : t.chartAreaCSS, d = a === "x" ? (s - r.x) / r.width : (r.height - s + r.y) / r.height;
48
+ return n + d * (c - n);
49
+ }, Lt = (t) => {
50
50
  const { ctx: s, scales: e } = t;
51
51
  for (const o of e) {
52
52
  if (!o.axis) continue;
@@ -61,12 +61,12 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
61
61
  if (o.axis.position === "bottom")
62
62
  s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x + n.width, n.y), s.stroke();
63
63
  else if (o.axis.position === "top") {
64
- const i = n.y + n.height;
65
- s.beginPath(), s.moveTo(n.x, i), s.lineTo(n.x + n.width, i), s.stroke();
64
+ const c = n.y + n.height;
65
+ s.beginPath(), s.moveTo(n.x, c), s.lineTo(n.x + n.width, c), s.stroke();
66
66
  }
67
67
  } else if (o.axis.position === "left") {
68
- const i = n.x + n.width;
69
- s.beginPath(), s.moveTo(i, n.y), s.lineTo(i, n.y + n.height), s.stroke();
68
+ const c = n.x + n.width;
69
+ s.beginPath(), s.moveTo(c, n.y), s.lineTo(c, n.y + n.height), s.stroke();
70
70
  } else o.axis.position === "right" && (s.beginPath(), s.moveTo(n.x, n.y), s.lineTo(n.x, n.y + n.height), s.stroke());
71
71
  s.restore();
72
72
  }
@@ -80,31 +80,31 @@ const j = (t, s, e) => Math.min(Math.max(t, s), e), le = (t) => t.reduce((s, e)
80
80
  _frame: null,
81
81
  getFrame: e,
82
82
  getCtx: () => e().ctx,
83
- clampXPosToChartArea: (o, n) => O(e(), o, n ?? "canvas"),
84
- clampYPosToChartArea: (o, n) => $(e(), o, n ?? "canvas"),
85
- valToPos: (o, n, i) => H(e(), o, n, i ?? "canvas"),
86
- valToPxDistance: (o, n, i) => ut(
83
+ clampXPosToChartArea: (o, n) => Y(e(), o, n ?? "canvas"),
84
+ clampYPosToChartArea: (o, n) => O(e(), o, n ?? "canvas"),
85
+ valToPos: (o, n, c) => H(e(), o, n, c ?? "canvas"),
86
+ valToPxDistance: (o, n, c) => ut(
87
87
  e(),
88
88
  o,
89
89
  n,
90
- i ?? "canvas"
90
+ c ?? "canvas"
91
91
  ),
92
92
  valFits: (o, n) => rt(e(), o, n),
93
- getScale: (o) => I(e(), o)
93
+ getScale: (o) => L(e(), o)
94
94
  };
95
95
  }), Xt = () => bt((t) => ({
96
96
  notify: () => {
97
97
  t((s) => ({ version: s.version + 1 }));
98
98
  },
99
99
  version: 0
100
- })), dt = vt(null), Ct = vt(null), Y = (t, s) => {
100
+ })), dt = vt(null), Ct = vt(null), z = (t, s) => {
101
101
  const e = J(dt), o = J(Ct);
102
102
  if (!e || !o)
103
103
  throw new Error("useFrame must be used within a CanPlot component");
104
- const n = L(t);
104
+ const n = U(t);
105
105
  n.current = t, N(() => {
106
- n.current(e.getState()), e.subscribe((i) => {
107
- i._frame && n.current(i);
106
+ n.current(e.getState()), e.subscribe((c) => {
107
+ c._frame && n.current(c);
108
108
  });
109
109
  }, [e]), wt(() => {
110
110
  o.getState().notify();
@@ -127,8 +127,8 @@ function Ft(t) {
127
127
  return (s) => {
128
128
  const e = [];
129
129
  for (const o of t) {
130
- const n = at(o, s), i = typeof n == "function";
131
- e.push(i ? n : () => at(o, null));
130
+ const n = at(o, s), c = typeof n == "function";
131
+ e.push(c ? n : () => at(o, null));
132
132
  }
133
133
  return () => {
134
134
  for (const o of e) o();
@@ -142,19 +142,19 @@ function at(t, s) {
142
142
  }
143
143
  var zt = parseInt(Rt.split(".")[0], 10) >= 19 ? Ft : Kt;
144
144
  const he = At(({ configuration: t, children: s, style: e, className: o }, n) => {
145
- const i = L(null), a = L(null), r = Ot(a), d = Q(It, []), u = Q(Xt, []);
145
+ const c = U(null), a = U(null), r = Ot(a), d = Q(It, []), u = Q(Xt, []);
146
146
  N(() => {
147
147
  d.setState({
148
- _frame: $t(t, r, i.current)
148
+ _frame: Bt(t, r, c.current)
149
149
  });
150
- }, [t, r, i, d]), N(() => d.subscribe((p) => {
151
- p._frame && Bt(p._frame);
150
+ }, [t, r, c, d]), N(() => d.subscribe((p) => {
151
+ p._frame && $t(p._frame);
152
152
  }), [d]), N(() => {
153
153
  let p = !1;
154
154
  return u.subscribe(() => {
155
155
  p || (p = !0, window.requestAnimationFrame(() => {
156
- p = !1, d.setState((f) => ({
157
- _frame: f._frame ? { ...f._frame } : null
156
+ p = !1, d.setState((m) => ({
157
+ _frame: m._frame ? { ...m._frame } : null
158
158
  }));
159
159
  }));
160
160
  });
@@ -175,7 +175,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
175
175
  /* @__PURE__ */ _(
176
176
  "canvas",
177
177
  {
178
- ref: i,
178
+ ref: c,
179
179
  width: r.width * l,
180
180
  height: r.height * l,
181
181
  style: {
@@ -202,8 +202,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
202
202
  width: 0,
203
203
  height: 0
204
204
  }), [o] = V(() => new ResizeObserver((n) => {
205
- for (const i of n) {
206
- const a = Math.round(i.contentRect.width), r = Math.round(i.contentRect.height);
205
+ for (const c of n) {
206
+ const a = Math.round(c.contentRect.width), r = Math.round(c.contentRect.height);
207
207
  e(
208
208
  (d) => d.width !== a || d.height !== r ? { ...d, width: a, height: r } : d
209
209
  );
@@ -211,57 +211,57 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
211
211
  }));
212
212
  return N(() => {
213
213
  if (!t.current) return;
214
- const n = t.current.clientWidth, i = t.current.clientHeight;
214
+ const n = t.current.clientWidth, c = t.current.clientHeight;
215
215
  return e(
216
- (a) => a.width !== n || a.height !== i ? { ...a, width: n, height: i } : a
216
+ (a) => a.width !== n || a.height !== c ? { ...a, width: n, height: c } : a
217
217
  ), o.observe(t.current, { box: "border-box" }), () => o.disconnect();
218
218
  }, [o, t]), s;
219
- }, $t = (t, s, e) => {
219
+ }, Bt = (t, s, e) => {
220
220
  const o = e?.getContext("2d");
221
221
  if (!o) return null;
222
222
  const n = window.devicePixelRatio || 1;
223
223
  if (s.width === 0 || s.height === 0)
224
224
  return null;
225
- const i = {
225
+ const c = {
226
226
  x: t.padding.left,
227
227
  y: t.padding.top,
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 m of t.scales)
232
- m.axis && (m.origin === "x" ? (m.axis.position === "bottom" || m.axis.position === "top") && (i.height = Math.max(
231
+ for (const f of t.scales)
232
+ f.axis && (f.origin === "x" ? (f.axis.position === "bottom" || f.axis.position === "top") && (c.height = Math.max(
233
233
  0,
234
- i.height - m.axis.size
235
- ), m.axis.position === "top" && (i.y += m.axis.size)) : (m.axis.position === "left" || m.axis.position === "right") && (i.width = Math.max(0, i.width - m.axis.size), m.axis.position === "left" && (i.x += m.axis.size)));
234
+ c.height - f.axis.size
235
+ ), f.axis.position === "top" && (c.y += f.axis.size)) : (f.axis.position === "left" || f.axis.position === "right") && (c.width = Math.max(0, c.width - f.axis.size), f.axis.position === "left" && (c.x += f.axis.size)));
236
236
  const a = {
237
- x: i.x * n,
238
- y: i.y * n,
239
- width: i.width * n,
240
- height: i.height * n
237
+ x: c.x * n,
238
+ y: c.y * n,
239
+ width: c.width * n,
240
+ height: c.height * n
241
241
  }, r = [];
242
242
  let d = t.padding.left * n, u = o.canvas.width - t.padding.right * n, l = o.canvas.height - t.padding.bottom * n, p = t.padding.top * n;
243
- for (const m of t.scales) {
244
- if (!m.axis) {
245
- r.push({ ...m, axis: null });
243
+ for (const f of t.scales) {
244
+ if (!f.axis) {
245
+ r.push({ ...f, axis: null });
246
246
  continue;
247
247
  }
248
- let c;
249
- if (m.origin === "x")
250
- switch (m.axis.position) {
248
+ let i;
249
+ if (f.origin === "x")
250
+ switch (f.axis.position) {
251
251
  case "bottom":
252
- l -= m.axis.size * n, c = {
253
- x: i.x,
252
+ l -= f.axis.size * n, i = {
253
+ x: c.x,
254
254
  y: l / n,
255
- width: i.width,
256
- height: m.axis.size
255
+ width: c.width,
256
+ height: f.axis.size
257
257
  };
258
258
  break;
259
259
  case "top":
260
- p += m.axis.size * n, c = {
261
- x: i.x,
262
- y: p / n - m.axis.size,
263
- width: i.width,
264
- height: m.axis.size
260
+ p += f.axis.size * n, i = {
261
+ x: c.x,
262
+ y: p / n - f.axis.size,
263
+ width: c.width,
264
+ height: f.axis.size
265
265
  };
266
266
  break;
267
267
  case "left":
@@ -269,21 +269,21 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
269
269
  throw new Error("Invalid axis position for x origin");
270
270
  }
271
271
  else
272
- switch (m.axis.position) {
272
+ switch (f.axis.position) {
273
273
  case "left":
274
- d += m.axis.size * n, c = {
275
- x: d / n - m.axis.size,
276
- y: i.y,
277
- width: m.axis.size,
278
- height: i.height
274
+ d += f.axis.size * n, i = {
275
+ x: d / n - f.axis.size,
276
+ y: c.y,
277
+ width: f.axis.size,
278
+ height: c.height
279
279
  };
280
280
  break;
281
281
  case "right":
282
- u -= m.axis.size * n, c = {
282
+ u -= f.axis.size * n, i = {
283
283
  x: u / n,
284
- y: i.y,
285
- width: m.axis.size,
286
- height: i.height
284
+ y: c.y,
285
+ width: f.axis.size,
286
+ height: c.height
287
287
  };
288
288
  break;
289
289
  case "top":
@@ -291,16 +291,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
291
291
  throw new Error("Invalid axis position for y origin");
292
292
  }
293
293
  const h = {
294
- x: c.x * n,
295
- y: c.y * n,
296
- width: c.width * n,
297
- height: c.height * n
294
+ x: i.x * n,
295
+ y: i.y * n,
296
+ width: i.width * n,
297
+ height: i.height * n
298
298
  };
299
299
  r.push({
300
- ...m,
300
+ ...f,
301
301
  axis: {
302
- ...m.axis,
303
- cssRect: c,
302
+ ...f.axis,
303
+ cssRect: i,
304
304
  canvasRect: h
305
305
  }
306
306
  });
@@ -310,24 +310,24 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
310
310
  dpr: n,
311
311
  padding: t.padding,
312
312
  scales: r,
313
- chartAreaCSS: i,
313
+ chartAreaCSS: c,
314
314
  chartAreaCanvasPX: a
315
315
  };
316
- }, Bt = (t) => {
317
- t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Dt(t);
318
- }, fe = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (Y(
319
- ({ getCtx: n, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: r }) => {
316
+ }, $t = (t) => {
317
+ t.ctx.clearRect(0, 0, t.ctx.canvas.width, t.ctx.canvas.height), Lt(t);
318
+ }, fe = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (z(
319
+ ({ getCtx: n, clampXPosToChartArea: c, clampYPosToChartArea: a, valToPos: r }) => {
320
320
  const d = n();
321
321
  d.save(), d.beginPath(), R(d, o);
322
322
  for (const u of t) {
323
- const l = i(r(u.x, s)), p = a(r(u.y, e));
323
+ const l = c(r(u.x, s)), p = a(r(u.y, e));
324
324
  d.lineTo(l, p);
325
325
  }
326
326
  d.stroke(), d.restore();
327
327
  },
328
328
  [t, s, e, o]
329
- ), null), me = ({ data: t, xScaleId: s, yScaleId: e, radius: o = 5, style: n }) => (Y(({ getCtx: i, valToPos: a, valFits: r }) => {
330
- const d = i();
329
+ ), null), me = ({ data: t, xScaleId: s, yScaleId: e, radius: o = 5, style: n }) => (z(({ getCtx: c, valToPos: a, valFits: r }) => {
330
+ const d = c();
331
331
  d.save(), d.beginPath(), R(d, n);
332
332
  for (const u of t) {
333
333
  if (!r(u.x, s) || !r(u.y, e))
@@ -342,9 +342,9 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
342
342
  yScaleId: e,
343
343
  style: o,
344
344
  barWidth: n,
345
- xPositionOffset: i,
345
+ xPositionOffset: c,
346
346
  radius: a
347
- }) => (Y(
347
+ }) => (z(
348
348
  ({
349
349
  getCtx: r,
350
350
  valToPxDistance: d,
@@ -353,28 +353,28 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
353
353
  clampYPosToChartArea: p
354
354
  }) => {
355
355
  if (t.length === 0) return;
356
- const f = r();
357
- f.save(), R(f, o);
358
- const m = d(n, s);
359
- f.beginPath();
360
- for (const c of t) {
361
- const y = u(c.x, s) - m / 2 + i * m, x = p(u(0, e)), w = p(u(c.y, e)), g = x - w, v = l(y), T = l(y + m) - v;
362
- a ? f.roundRect(
356
+ const m = r();
357
+ m.save(), R(m, o);
358
+ const f = d(n, s);
359
+ m.beginPath();
360
+ for (const i of t) {
361
+ const y = u(i.x, s) - f / 2 + c * f, x = p(u(0, e)), w = p(u(i.y, e)), g = x - w, v = l(y), T = l(y + f) - v;
362
+ a ? m.roundRect(
363
363
  v,
364
364
  w,
365
365
  T,
366
366
  g,
367
367
  a
368
- ) : f.rect(v, w, T, g);
368
+ ) : m.rect(v, w, T, g);
369
369
  }
370
- f.closePath(), f.fill(), o?.strokeStyle && f.stroke(), f.restore();
370
+ m.closePath(), m.fill(), o?.strokeStyle && m.stroke(), m.restore();
371
371
  },
372
- [t, s, e, o, n, i, a]
373
- ), null), ye = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (Y(({ getCtx: n, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: r }) => {
372
+ [t, s, e, o, n, c, a]
373
+ ), null), ye = ({ data: t, xScaleId: s, yScaleId: e, style: o }) => (z(({ getCtx: n, clampXPosToChartArea: c, clampYPosToChartArea: a, valToPos: r }) => {
374
374
  const d = [];
375
375
  for (const l of t) {
376
- const p = i(r(l.x, s)), f = a(r(l.y[0], e)), m = a(r(l.y[1], e));
377
- d.push({ x: p, y: f }), d.unshift({ x: p, y: m });
376
+ const p = c(r(l.x, s)), m = a(r(l.y[0], e)), f = a(r(l.y[1], e));
377
+ d.push({ x: p, y: m }), d.unshift({ x: p, y: f });
378
378
  }
379
379
  const u = n();
380
380
  if (d.length > 0) {
@@ -383,24 +383,24 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
383
383
  u.lineTo(l.x, l.y);
384
384
  u.closePath(), u.fill(), u.restore();
385
385
  }
386
- }, [t, s, e, o]), null), xe = ({ data: t, stroked: s, xScaleId: e, yScaleId: o, style: n }) => (Y(
387
- ({ getCtx: i, clampXPosToChartArea: a, clampYPosToChartArea: r, valToPos: d }) => {
388
- const u = [], l = i();
389
- for (const c of t) {
390
- const h = a(d(c.x, e)), y = r(d(c.y, o));
386
+ }, [t, s, e, o]), null), xe = ({ data: t, stroked: s, xScaleId: e, yScaleId: o, style: n }) => (z(
387
+ ({ getCtx: c, clampXPosToChartArea: a, clampYPosToChartArea: r, valToPos: d }) => {
388
+ const u = [], l = c();
389
+ for (const i of t) {
390
+ const h = a(d(i.x, e)), y = r(d(i.y, o));
391
391
  u.push({ x: h, y });
392
392
  }
393
- const p = u.at(0), f = u.at(-1);
394
- if (!p || !f)
393
+ const p = u.at(0), m = u.at(-1);
394
+ if (!p || !m)
395
395
  return;
396
- const m = r(d(0, o));
397
- l.save(), l.beginPath(), R(l, n), l.moveTo(p.x, m);
398
- for (const c of u)
399
- l.lineTo(c.x, c.y);
400
- if (l.lineTo(f.x, m), l.closePath(), l.fill(), s) {
396
+ const f = r(d(0, o));
397
+ l.save(), l.beginPath(), R(l, n), l.moveTo(p.x, f);
398
+ for (const i of u)
399
+ l.lineTo(i.x, i.y);
400
+ if (l.lineTo(m.x, f), l.closePath(), l.fill(), s) {
401
401
  l.beginPath(), l.moveTo(p.x, p.y);
402
- for (const c of u)
403
- l.lineTo(c.x, c.y);
402
+ for (const i of u)
403
+ l.lineTo(i.x, i.y);
404
404
  l.stroke();
405
405
  }
406
406
  l.restore();
@@ -411,7 +411,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
411
411
  clampXPosToChartArea: e,
412
412
  clampYPosToChartArea: o,
413
413
  getScale: n,
414
- valToPos: i,
414
+ valToPos: c,
415
415
  valFits: a
416
416
  }) => {
417
417
  const r = {};
@@ -420,13 +420,13 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
420
420
  switch (u.exceeding) {
421
421
  case "discard": {
422
422
  if (a(u.value, u.scaleId)) {
423
- const l = i(u.value, u.scaleId, s);
423
+ const l = c(u.value, u.scaleId, s);
424
424
  r[d] = l;
425
425
  }
426
426
  break;
427
427
  }
428
428
  case "clamp": {
429
- const l = i(u.value, u.scaleId, s);
429
+ const l = c(u.value, u.scaleId, s);
430
430
  r[d] = n(u.scaleId)?.origin === "x" ? e(l, s) : o(l, s);
431
431
  break;
432
432
  }
@@ -434,21 +434,21 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
434
434
  }
435
435
  return r;
436
436
  }
437
- ), ve = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: i }) => (Y(
437
+ ), ve = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: c }) => (z(
438
438
  ({ getCtx: a, valToPos: r, getScale: d, getFrame: u }) => {
439
439
  const l = a(), p = d(t);
440
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, c = window.devicePixelRatio || 1, h = m, y = (n ?? 6) * c, x = f.position === "top" ? m - y : m + y, w = (o ?? 12) * c;
441
+ const m = p.axis, f = m.position === "top" ? m.canvasRect.y + m.canvasRect.height : m.canvasRect.y, i = window.devicePixelRatio || 1, h = f, y = (n ?? 6) * i, x = m.position === "top" ? f - y : f + y, w = (o ?? 12) * i;
442
442
  l.save(), l.fontKerning = "auto", R(l, {
443
443
  ...s
444
444
  }), l.beginPath();
445
- const g = Array.isArray(i) ? i : i({ ...p, axis: f }, u());
445
+ const g = Array.isArray(c) ? c : c({ ...p, axis: m }, u());
446
446
  for (const { value: v } of g) {
447
447
  const T = r(v, t, "canvas");
448
448
  l.moveTo(T, h), l.lineTo(T, x);
449
449
  }
450
450
  l.stroke(), l.restore(), l.save(), R(l, {
451
- textBaseline: f.position === "top" ? "bottom" : "top",
451
+ textBaseline: m.position === "top" ? "bottom" : "top",
452
452
  textAlign: "center",
453
453
  ...s,
454
454
  ...e
@@ -457,24 +457,24 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
457
457
  const b = r(v, t, "canvas"), C = T.split(`
458
458
  `);
459
459
  for (let k = 0; k < C.length; k++)
460
- l.fillText(C[k], b, x + c * 2 + k * w);
460
+ l.fillText(C[k], b, x + i * 2 + k * w);
461
461
  }
462
462
  l.restore();
463
463
  },
464
- [i, t, s, e]
465
- ), null), we = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: i }) => (Y(
464
+ [c, t, s, e]
465
+ ), null), we = ({ scaleId: t, tickStyle: s, labelStyle: e, labelGap: o, tickSize: n, ticks: c }) => (z(
466
466
  ({ getCtx: a, valToPos: r, getScale: d, getFrame: u }) => {
467
467
  const l = a(), p = d(t);
468
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, c = m, h = n ?? 6, y = f.position === "left" ? m - h : m + h, x = o ?? 12, w = Array.isArray(i) ? i : i({ ...p, axis: f }, u());
469
+ const m = p.axis, f = m.position === "left" ? m.canvasRect.x + m.canvasRect.width : m.canvasRect.x, i = f, h = n ?? 6, y = m.position === "left" ? f - h : f + h, x = o ?? 12, w = Array.isArray(c) ? c : c({ ...p, axis: m }, u());
470
470
  l.save(), l.fontKerning = "auto", R(l, { ...s }), l.beginPath();
471
471
  for (const { value: g } of w) {
472
472
  const v = r(g, t, "canvas");
473
- l.moveTo(c, v), l.lineTo(y, v);
473
+ l.moveTo(i, v), l.lineTo(y, v);
474
474
  }
475
475
  l.stroke(), l.restore(), l.save(), R(l, {
476
476
  textBaseline: "middle",
477
- textAlign: f.position === "left" ? "right" : "left",
477
+ textAlign: m.position === "left" ? "right" : "left",
478
478
  ...s,
479
479
  ...e
480
480
  });
@@ -486,7 +486,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
486
486
  }
487
487
  l.restore();
488
488
  },
489
- [i, t, s, e]
489
+ [c, t, s, e]
490
490
  ), null), E = () => {
491
491
  const t = [];
492
492
  return {
@@ -524,8 +524,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
524
524
  const o = Z.useRef(e);
525
525
  o.current = e, Z.useEffect(() => S[t].addEventListener(
526
526
  s,
527
- (i, a) => {
528
- o.current(a, i);
527
+ (c, a) => {
528
+ o.current(a, c);
529
529
  }
530
530
  ), [s, t, o]);
531
531
  }, ft = Z.createContext(""), mt = (t, s) => {
@@ -533,18 +533,18 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
533
533
  return M(t, e, s);
534
534
  }, Nt = (t, s, e, o, n) => {
535
535
  if (!s) return;
536
- const i = o ?? e.scales.find((p) => p.origin === "x")?.id, a = n ?? e.scales.find((p) => p.origin === "y")?.id;
537
- if (!i || !a)
536
+ const c = o ?? e.scales.find((p) => p.origin === "x")?.id, a = n ?? e.scales.find((p) => p.origin === "y")?.id;
537
+ if (!c || !a)
538
538
  return;
539
539
  const r = t.clientX - s.left, d = {
540
- scaleId: i,
541
- value: D(e, r, i, "css")
540
+ scaleId: c,
541
+ value: D(e, r, c, "css")
542
542
  }, u = t.clientY - s.top, l = {
543
543
  scaleId: a,
544
544
  value: D(e, u, a, "css")
545
545
  };
546
546
  return { pointerSyncPosition: { x: d, y: l }, cssX: r, cssY: u };
547
- }, z = (t, s) => {
547
+ }, F = (t, s) => {
548
548
  const e = t.x ? H(
549
549
  s,
550
550
  t.x.value,
@@ -561,8 +561,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
561
561
  cssY: o,
562
562
  scaled: Object.fromEntries(
563
563
  s.scales.map((n) => {
564
- const i = n.origin === "y" ? o : e;
565
- return [n.id, D(s, i, n.id, "css")];
564
+ const c = n.origin === "y" ? o : e;
565
+ return [n.id, D(s, c, n.id, "css")];
566
566
  })
567
567
  )
568
568
  };
@@ -577,7 +577,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
577
577
  s.to,
578
578
  s.scaleId,
579
579
  "css"
580
- ), i = e.scales.flatMap(
580
+ ), c = e.scales.flatMap(
581
581
  (a) => {
582
582
  if (a.origin !== t)
583
583
  return [];
@@ -594,7 +594,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
594
594
  return {
595
595
  fromCSS: o,
596
596
  toCSS: n,
597
- scaled: i
597
+ scaled: c
598
598
  };
599
599
  }, be = ({
600
600
  id: t,
@@ -602,33 +602,33 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
602
602
  onDblClick: e,
603
603
  onMouseMove: o,
604
604
  onMouseDown: n,
605
- onMouseUp: i,
605
+ onMouseUp: c,
606
606
  onDocumentMouseUp: a,
607
607
  onSpanSelect: r,
608
608
  onContextMenu: d,
609
609
  className: u,
610
610
  style: l,
611
611
  sync: p,
612
- children: f
612
+ children: m
613
613
  }) => {
614
- const m = Ut(), c = t || m;
615
- return M("dblclick", c, (h) => {
614
+ const f = Ut(), i = t || f;
615
+ return M("dblclick", i, (h) => {
616
616
  e?.(h);
617
- }), M("click", c, (h) => {
617
+ }), M("click", i, (h) => {
618
618
  s?.(h);
619
- }), M("move", c, (h) => {
619
+ }), M("move", i, (h) => {
620
620
  o?.(h);
621
- }), M("mousedown", c, (h) => {
621
+ }), M("mousedown", i, (h) => {
622
622
  n?.(h);
623
- }), M("mouseup", c, (h) => {
624
- i?.(h);
625
- }), M("documentmouseup", c, (h) => {
623
+ }), M("mouseup", i, (h) => {
624
+ c?.(h);
625
+ }), M("documentmouseup", i, (h) => {
626
626
  a?.(h);
627
- }), M("spanselect", c, (h) => {
627
+ }), M("spanselect", i, (h) => {
628
628
  r?.(h);
629
- }), M("contextmenu", c, (h) => {
629
+ }), M("contextmenu", i, (h) => {
630
630
  d?.(h);
631
- }), /* @__PURE__ */ lt(ft.Provider, { value: c, children: [
631
+ }), /* @__PURE__ */ lt(ft.Provider, { value: i, children: [
632
632
  /* @__PURE__ */ _(
633
633
  Vt,
634
634
  {
@@ -637,25 +637,25 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
637
637
  sync: p
638
638
  }
639
639
  ),
640
- f
640
+ m
641
641
  ] });
642
642
  }, Vt = ({ className: t, style: s, sync: e }) => {
643
- const o = L(null), n = ht(), i = L(n);
644
- i.current = n;
645
- const a = J(ft), r = e?.key || a, d = L(null), u = L(null), l = L(null), p = () => {
646
- const c = o.current?.parentElement;
647
- if (c) {
648
- if (c.dataset.canplotroot === void 0)
643
+ const o = U(null), n = ht(), c = U(n);
644
+ c.current = n;
645
+ const a = J(ft), r = e?.key || a, d = U(null), u = U(null), l = U(null), p = () => {
646
+ const i = o.current?.parentElement;
647
+ if (i) {
648
+ if (i.dataset.canplotroot === void 0)
649
649
  throw new Error(
650
650
  "ChartAreaInteractions must be used within a CanPlot component"
651
651
  );
652
- return c.getBoundingClientRect();
652
+ return i.getBoundingClientRect();
653
653
  }
654
- }, f = (c, h) => {
654
+ }, m = (i, h) => {
655
655
  const y = Nt(
656
- c,
656
+ i,
657
657
  p(),
658
- i.current,
658
+ c.current,
659
659
  e?.xViaScaleId,
660
660
  e?.yViaScaleId
661
661
  );
@@ -663,21 +663,21 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
663
663
  y.pointerSyncPosition,
664
664
  { cssX: y.cssX, cssY: y.cssY },
665
665
  {
666
- ctrlKey: c.ctrlKey,
667
- altKey: c.altKey,
668
- shiftKey: c.shiftKey,
669
- metaKey: c.metaKey
666
+ ctrlKey: i.ctrlKey,
667
+ altKey: i.altKey,
668
+ shiftKey: i.shiftKey,
669
+ metaKey: i.metaKey
670
670
  }
671
671
  );
672
- }, m = L(f);
673
- return m.current = f, wt(() => {
674
- const c = (g) => {
672
+ }, f = U(m);
673
+ return f.current = m, wt(() => {
674
+ const i = (g) => {
675
675
  const v = u.current;
676
676
  v && S.sync_spanselect.dispatchEvent(r, {
677
677
  ...v,
678
678
  completed: !0
679
679
  }), S.documentmouseup.dispatchEvent(r, {
680
- frame: i.current,
680
+ frame: c.current,
681
681
  keys: {
682
682
  ctrlKey: g.ctrlKey,
683
683
  altKey: g.altKey,
@@ -710,49 +710,49 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
710
710
  );
711
711
  }
712
712
  }, y = (g) => {
713
- m.current(
713
+ f.current(
714
714
  g,
715
715
  (v, { cssX: T, cssY: b }, C) => {
716
716
  const k = d.current;
717
717
  if (!k || !v.x || !v.y) return;
718
- const A = i.current, P = k.xRangeCss.start, B = T, F = k.yRangeCss.start, st = b, nt = I(A, v.x.scaleId), ot = I(A, v.y.scaleId);
718
+ const A = c.current, P = k.xRangeCss.start, B = T, K = k.yRangeCss.start, st = b, nt = L(A, v.x.scaleId), ot = L(A, v.y.scaleId);
719
719
  d.current = {
720
720
  xRangeCss: { start: P, end: B },
721
- yRangeCss: { start: F, end: st }
721
+ yRangeCss: { start: K, end: st }
722
722
  };
723
- let U = "below_threshold";
724
- const it = Math.abs(F - st), ct = Math.abs(P - B);
725
- it < 10 && ct < 10 ? U = "below_threshold" : it > 30 && ct > 30 ? U = "box" : it > ct ? U = "y" : U = "x";
726
- const Mt = U === "x" || U === "box" ? {
723
+ let $ = "below_threshold";
724
+ const ct = Math.abs(K - st), it = Math.abs(P - B);
725
+ ct < 10 && it < 10 ? $ = "below_threshold" : ct > 30 && it > 30 ? $ = "box" : ct > it ? $ = "y" : $ = "x";
726
+ const Mt = {
727
727
  scaleId: nt.id,
728
728
  from: D(
729
729
  A,
730
- O(i.current, P, "css"),
730
+ Y(c.current, P, "css"),
731
731
  nt.id,
732
732
  "css"
733
733
  ),
734
734
  to: D(
735
735
  A,
736
- O(i.current, B, "css"),
736
+ Y(c.current, B, "css"),
737
737
  nt.id,
738
738
  "css"
739
739
  )
740
- } : void 0, Pt = U === "y" || U === "box" ? {
740
+ }, Pt = {
741
741
  scaleId: ot.id,
742
742
  from: D(
743
743
  A,
744
- $(i.current, F, "css"),
744
+ O(c.current, K, "css"),
745
745
  ot.id,
746
746
  "css"
747
747
  ),
748
748
  to: D(
749
749
  A,
750
- $(i.current, st, "css"),
750
+ O(c.current, st, "css"),
751
751
  ot.id,
752
752
  "css"
753
753
  )
754
- } : void 0, yt = {
755
- mode: U,
754
+ }, yt = {
755
+ mode: $,
756
756
  xRange: Mt,
757
757
  yRange: Pt,
758
758
  completed: !1,
@@ -765,7 +765,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
765
765
  }
766
766
  );
767
767
  }, x = (g) => {
768
- m.current(g, (v, T, b) => {
768
+ f.current(g, (v, T, b) => {
769
769
  if (Object.values(b).some((k) => k)) {
770
770
  g.preventDefault();
771
771
  const k = Math.abs(g.deltaY) > Math.abs(g.deltaX) ? g.deltaY : g.deltaX;
@@ -779,96 +779,96 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
779
779
  }
780
780
  });
781
781
  };
782
- document.addEventListener("mouseup", c), document.addEventListener("keydown", h), document.addEventListener("keyup", h), document.addEventListener("mousemove", y);
782
+ document.addEventListener("mouseup", i), document.addEventListener("keydown", h), document.addEventListener("keyup", h), document.addEventListener("mousemove", y);
783
783
  const w = o.current;
784
784
  return w?.addEventListener("wheel", x, {
785
785
  passive: !1
786
786
  }), () => {
787
- document.removeEventListener("mouseup", c), document.removeEventListener("keydown", h), document.removeEventListener("keyup", h), document.removeEventListener("mousemove", y), w?.removeEventListener("wheel", x);
787
+ document.removeEventListener("mouseup", i), document.removeEventListener("keydown", h), document.removeEventListener("keyup", h), document.removeEventListener("mousemove", y), w?.removeEventListener("wheel", x);
788
788
  };
789
- }, [i, r, m]), M("sync_dblclick", r, (c) => {
790
- const h = z(
791
- c.positions,
792
- i.current
789
+ }, [c, r, f]), M("sync_dblclick", r, (i) => {
790
+ const h = F(
791
+ i.positions,
792
+ c.current
793
793
  );
794
794
  h && S.dblclick.dispatchEvent(a, {
795
- frame: i.current,
795
+ frame: c.current,
796
796
  pointer: h,
797
- keys: c.keys
797
+ keys: i.keys
798
798
  });
799
- }), M("sync_click", r, (c) => {
800
- const h = z(
801
- c.positions,
802
- i.current
799
+ }), M("sync_click", r, (i) => {
800
+ const h = F(
801
+ i.positions,
802
+ c.current
803
803
  );
804
804
  h && S.click.dispatchEvent(a, {
805
- frame: i.current,
805
+ frame: c.current,
806
806
  pointer: h,
807
- keys: c.keys
807
+ keys: i.keys
808
808
  });
809
- }), M("sync_contextmenu", r, (c) => {
810
- const h = z(
811
- c.positions,
812
- i.current
809
+ }), M("sync_contextmenu", r, (i) => {
810
+ const h = F(
811
+ i.positions,
812
+ c.current
813
813
  );
814
814
  h && S.contextmenu.dispatchEvent(a, {
815
- frame: i.current,
815
+ frame: c.current,
816
816
  pointer: h,
817
- keys: c.keys
817
+ keys: i.keys
818
818
  });
819
- }), M("sync_move", r, (c) => {
820
- const h = c.positions ? z(
821
- c.positions,
822
- i.current
819
+ }), M("sync_move", r, (i) => {
820
+ const h = i.positions ? F(
821
+ i.positions,
822
+ c.current
823
823
  ) : null;
824
- l.current = c, S.move.dispatchEvent(a, {
825
- frame: i.current,
824
+ l.current = i, S.move.dispatchEvent(a, {
825
+ frame: c.current,
826
826
  pointer: h ?? null,
827
- keys: c.keys
827
+ keys: i.keys
828
828
  });
829
- }), M("sync_mousedown", r, (c) => {
830
- const h = z(
831
- c.positions,
832
- i.current
829
+ }), M("sync_mousedown", r, (i) => {
830
+ const h = F(
831
+ i.positions,
832
+ c.current
833
833
  );
834
834
  h && S.mousedown.dispatchEvent(a, {
835
- frame: i.current,
835
+ frame: c.current,
836
836
  pointer: h,
837
- keys: c.keys
837
+ keys: i.keys
838
838
  });
839
- }), M("sync_mouseup", r, (c) => {
840
- const h = z(
841
- c.positions,
842
- i.current
839
+ }), M("sync_mouseup", r, (i) => {
840
+ const h = F(
841
+ i.positions,
842
+ c.current
843
843
  );
844
844
  h && S.mouseup.dispatchEvent(a, {
845
- frame: i.current,
845
+ frame: c.current,
846
846
  pointer: h,
847
- keys: c.keys
847
+ keys: i.keys
848
848
  });
849
849
  }), M(
850
850
  "sync_pressandwheel",
851
851
  r,
852
- (c) => {
853
- const h = z(
854
- c.positions,
855
- i.current
852
+ (i) => {
853
+ const h = F(
854
+ i.positions,
855
+ c.current
856
856
  );
857
857
  h && S.pressandwheel.dispatchEvent(a, {
858
- frame: i.current,
858
+ frame: c.current,
859
859
  pointer: h,
860
- keys: c.keys,
861
- deltaX: c.deltaX,
862
- deltaY: c.deltaY,
863
- deltaAbs: c.deltaAbs
860
+ keys: i.keys,
861
+ deltaX: i.deltaX,
862
+ deltaY: i.deltaY,
863
+ deltaAbs: i.deltaAbs
864
864
  });
865
865
  }
866
- ), M("sync_spanselect", r, (c) => {
867
- const h = c.xRange && xt("x", c.xRange, i.current), y = c.yRange && xt("y", c.yRange, i.current), x = h?.scaled, w = y?.scaled;
868
- c.completed && (d.current = null), S.spanselect.dispatchEvent(a, {
869
- mode: c.mode,
870
- frame: i.current,
871
- completed: c.completed,
866
+ ), M("sync_spanselect", r, (i) => {
867
+ const h = i.xRange && xt("x", i.xRange, c.current), y = i.yRange && xt("y", i.yRange, c.current), x = h?.scaled, w = y?.scaled;
868
+ i.completed && (d.current = null), S.spanselect.dispatchEvent(a, {
869
+ mode: i.mode,
870
+ frame: c.current,
871
+ completed: i.completed,
872
872
  x: {
873
873
  css: h && {
874
874
  from: h.fromCSS,
@@ -883,7 +883,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
883
883
  },
884
884
  scaled: w ?? []
885
885
  },
886
- keys: c.keys
886
+ keys: i.keys
887
887
  });
888
888
  }), /* @__PURE__ */ _(
889
889
  "div",
@@ -900,35 +900,35 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
900
900
  zIndex: 25,
901
901
  ...s
902
902
  },
903
- onDragStart: (c) => {
904
- c.preventDefault();
903
+ onDragStart: (i) => {
904
+ i.preventDefault();
905
905
  },
906
- onClick: (c) => {
907
- f(c, (h, y, x) => {
906
+ onClick: (i) => {
907
+ m(i, (h, y, x) => {
908
908
  S.sync_click.dispatchEvent(r, {
909
909
  positions: h,
910
910
  keys: x
911
911
  });
912
912
  });
913
913
  },
914
- onMouseLeave: (c) => {
915
- f(c, (h, y, x) => {
914
+ onMouseLeave: (i) => {
915
+ m(i, (h, y, x) => {
916
916
  S.sync_move.dispatchEvent(r, {
917
917
  positions: null,
918
918
  keys: x
919
919
  });
920
920
  });
921
921
  },
922
- onMouseMove: (c) => {
923
- f(c, (h, y, x) => {
922
+ onMouseMove: (i) => {
923
+ m(i, (h, y, x) => {
924
924
  S.sync_move.dispatchEvent(r, {
925
925
  positions: h,
926
926
  keys: x
927
927
  });
928
928
  });
929
929
  },
930
- onMouseDown: (c) => {
931
- f(c, (h, { cssX: y, cssY: x }, w) => {
930
+ onMouseDown: (i) => {
931
+ m(i, (h, { cssX: y, cssY: x }, w) => {
932
932
  S.sync_mousedown.dispatchEvent(r, {
933
933
  positions: h,
934
934
  keys: w
@@ -938,8 +938,8 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
938
938
  };
939
939
  });
940
940
  },
941
- onMouseUp: (c) => {
942
- f(c, (h, y, x) => {
941
+ onMouseUp: (i) => {
942
+ m(i, (h, y, x) => {
943
943
  S.sync_mouseup.dispatchEvent(r, {
944
944
  positions: h,
945
945
  keys: x
@@ -960,16 +960,16 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
960
960
  }
961
961
  });
962
962
  },
963
- onContextMenu: (c) => {
964
- c.preventDefault(), f(c, (h, y, x) => {
963
+ onContextMenu: (i) => {
964
+ i.preventDefault(), m(i, (h, y, x) => {
965
965
  S.sync_contextmenu.dispatchEvent(r, {
966
966
  positions: h,
967
967
  keys: x
968
968
  });
969
969
  });
970
970
  },
971
- onDoubleClick: (c) => {
972
- f(c, (h, y, x) => {
971
+ onDoubleClick: (i) => {
972
+ m(i, (h, y, x) => {
973
973
  S.sync_dblclick.dispatchEvent(r, {
974
974
  positions: h,
975
975
  keys: x
@@ -983,7 +983,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
983
983
  mt("move", (a) => {
984
984
  n(a);
985
985
  });
986
- const i = Q(() => {
986
+ const c = Q(() => {
987
987
  if (!o)
988
988
  return null;
989
989
  const { frame: a, pointer: r } = o, d = r?.scaled[e];
@@ -992,21 +992,21 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
992
992
  const u = [];
993
993
  let l = d;
994
994
  for (const p of t) {
995
- let f = null, m = 1 / 0;
995
+ let m = null, f = 1 / 0;
996
996
  for (const [h, y] of p.points.entries()) {
997
997
  if (!rt(a, y.x, e) || !rt(a, y.y, p.yScaleId))
998
998
  continue;
999
999
  const x = Math.abs(y.x - d);
1000
- x < m && (m = x, f = h);
1000
+ x < f && (f = x, m = h);
1001
1001
  }
1002
- const c = p.points[f ?? -1];
1003
- if (!c || ut(a, m, e, "css") > 30) {
1002
+ const i = p.points[m ?? -1];
1003
+ if (!i || ut(a, f, e, "css") > 30) {
1004
1004
  u.push({ seriesId: p.seriesId, y: null });
1005
1005
  continue;
1006
1006
  }
1007
- l = c.x, u.push({
1007
+ l = i.x, u.push({
1008
1008
  seriesId: p.seriesId,
1009
- y: c.y
1009
+ y: i.y
1010
1010
  });
1011
1011
  }
1012
1012
  return {
@@ -1015,14 +1015,14 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
1015
1015
  points: u
1016
1016
  };
1017
1017
  }, [t, o, e]);
1018
- return s(i);
1018
+ return s(c);
1019
1019
  }, Ce = ({ makeXStyle: t, makeXClassName: s, makeYStyle: e, makeYClassName: o }) => {
1020
- const [n, i] = V(null);
1020
+ const [n, c] = V(null);
1021
1021
  if (mt("move", (l) => {
1022
- i(l);
1022
+ c(l);
1023
1023
  }), !n)
1024
1024
  return null;
1025
- const { frame: a, pointer: r } = n, d = O(a, r?.cssX ?? 0, "css"), u = $(a, r?.cssY ?? 0, "css");
1025
+ const { frame: a, pointer: r } = n, d = Y(a, r?.cssX ?? 0, "css"), u = O(a, r?.cssY ?? 0, "css");
1026
1026
  return /* @__PURE__ */ lt(_t, { children: [
1027
1027
  /* @__PURE__ */ _(
1028
1028
  "div",
@@ -1066,30 +1066,30 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
1066
1066
  ] });
1067
1067
  }, Te = ({ makeClassName: t, makeStyle: s }) => {
1068
1068
  const [e, o] = V(null);
1069
- mt("spanselect", (i) => {
1070
- o(i.mode === "below_threshold" || i.completed ? null : i);
1069
+ mt("spanselect", (c) => {
1070
+ o(c.mode === "below_threshold" || c.completed ? null : c);
1071
1071
  });
1072
1072
  const n = Q(() => {
1073
1073
  if (!e || e.mode === "below_threshold")
1074
1074
  return null;
1075
- const i = O(
1075
+ const c = Y(
1076
1076
  e.frame,
1077
1077
  e.x.css?.from ?? -1 / 0,
1078
1078
  "css"
1079
- ), a = O(
1079
+ ), a = Y(
1080
1080
  e.frame,
1081
1081
  e.x.css?.to ?? 1 / 0,
1082
1082
  "css"
1083
- ), r = $(
1083
+ ), r = O(
1084
1084
  e.frame,
1085
1085
  e.y.css?.from ?? -1 / 0,
1086
1086
  "css"
1087
- ), d = $(
1087
+ ), d = O(
1088
1088
  e.frame,
1089
1089
  e.y.css?.to ?? 1 / 0,
1090
1090
  "css"
1091
- ), u = Math.min(i, a), l = Math.min(r, d), p = Math.abs(a - i), f = Math.abs(d - r);
1092
- return { leftPx: u, topPx: l, widthPx: p, heightPx: f };
1091
+ ), u = Math.min(c, a), l = Math.min(r, d), p = Math.abs(a - c), m = Math.abs(d - r);
1092
+ return { leftPx: u, topPx: l, widthPx: p, heightPx: m };
1093
1093
  }, [e]);
1094
1094
  return /* @__PURE__ */ _(
1095
1095
  "div",
@@ -1108,7 +1108,7 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
1108
1108
  }
1109
1109
  );
1110
1110
  }, ke = ({ style: t, children: s, scaleId: e, ...o }) => {
1111
- const n = ht((i) => i.getScale(e)?.axis);
1111
+ const n = ht((c) => c.getScale(e)?.axis);
1112
1112
  return n ? /* @__PURE__ */ _(
1113
1113
  "div",
1114
1114
  {
@@ -1127,18 +1127,23 @@ const he = At(({ configuration: t, children: s, style: e, className: o }, n) =>
1127
1127
  ) : null;
1128
1128
  }, Tt = 60, jt = 30, kt = "UTC", Ht = "en-GB", Ee = ({
1129
1129
  space: t,
1130
- formatter: s
1131
- } = {}) => (e, o) => {
1132
- const { min: n, max: i } = e, a = [], r = window.devicePixelRatio || 1, d = (t ?? (e.origin === "x" ? Tt : jt)) * r, u = Lt(
1133
- o,
1134
- d,
1135
- e.id,
1130
+ formatter: s,
1131
+ acceptableIncrements: e
1132
+ } = {}) => (o, n) => {
1133
+ const { min: c, max: a } = o, r = [], d = window.devicePixelRatio || 1, u = (t ?? (o.origin === "x" ? Tt : jt)) * d, l = Dt(
1134
+ n,
1135
+ u,
1136
+ o.id,
1136
1137
  "canvas"
1137
- ), l = W.find((f) => f > u) ?? 1;
1138
- let p = n % l < Number.EPSILON ? n : n + l - n % l;
1139
- for (; p <= i; )
1140
- a.push(p), p += l;
1141
- return (s ?? Wt)(a);
1138
+ ), p = e ?? W, m = p.find((i) => i > l) ?? p.at(-1) ?? 1;
1139
+ let f = c;
1140
+ if (Math.abs(f % m) > Number.EPSILON) {
1141
+ const i = (m - f % m) % m;
1142
+ f += i;
1143
+ }
1144
+ for (; f <= a && r.length < 1e3; )
1145
+ r.push(f), f += m;
1146
+ return (s ?? Wt)(r);
1142
1147
  }, Wt = (t) => {
1143
1148
  const s = Math.max(0, Math.ceil(-Math.log10(t[1] - t[0])));
1144
1149
  return t.map((e) => ({ value: e, label: e.toFixed(s) }));
@@ -1233,7 +1238,7 @@ const qt = 1, Et = 1e3 * qt, pt = 60 * Et, tt = 60 * pt, et = 24 * tt, Gt = 30 *
1233
1238
  }, gt = (t, s) => {
1234
1239
  const e = new Date(t);
1235
1240
  return e.setUTCMonth(e.getUTCMonth() + s), e.getTime();
1236
- }, K = (t, s) => {
1241
+ }, X = (t, s) => {
1237
1242
  const [e, o] = s;
1238
1243
  switch (o) {
1239
1244
  case "milliseconds":
@@ -1258,32 +1263,32 @@ function G(t, s) {
1258
1263
  }
1259
1264
  const oe = (t, s, e = "UTC") => {
1260
1265
  const [o, n] = s;
1261
- let i = new Date(t);
1266
+ let c = new Date(t);
1262
1267
  const a = () => {
1263
- i.setUTCHours(-G(i, e), 0, 0, 0);
1268
+ c.setUTCHours(-G(c, e), 0, 0, 0);
1264
1269
  };
1265
1270
  switch (n) {
1266
1271
  case "milliseconds":
1267
- i.setUTCMilliseconds(
1268
- Math.ceil(i.getUTCMilliseconds() / o) * o
1272
+ c.setUTCMilliseconds(
1273
+ Math.ceil(c.getUTCMilliseconds() / o) * o
1269
1274
  );
1270
1275
  break;
1271
1276
  case "seconds":
1272
- i.setUTCSeconds(
1273
- Math.ceil(i.getUTCSeconds() / o) * o,
1277
+ c.setUTCSeconds(
1278
+ Math.ceil(c.getUTCSeconds() / o) * o,
1274
1279
  0
1275
1280
  );
1276
1281
  break;
1277
1282
  case "minutes":
1278
- i.setUTCMinutes(
1279
- Math.ceil(i.getTime() % tt / pt / o) * o,
1283
+ c.setUTCMinutes(
1284
+ Math.ceil(c.getTime() % tt / pt / o) * o,
1280
1285
  0,
1281
1286
  0
1282
1287
  );
1283
1288
  break;
1284
1289
  case "hours":
1285
- i.setUTCHours(
1286
- Math.ceil(i.getTime() % et / tt / o) * o,
1290
+ c.setUTCHours(
1291
+ Math.ceil(c.getTime() % et / tt / o) * o,
1287
1292
  0,
1288
1293
  0,
1289
1294
  0
@@ -1292,36 +1297,36 @@ const oe = (t, s, e = "UTC") => {
1292
1297
  case "days":
1293
1298
  case "months":
1294
1299
  case "years":
1295
- n === "months" ? i.setUTCDate(1) : n === "years" && i.setUTCMonth(0, 1), a(), i.getTime() < t && (i = new Date(K(i, [1, n])));
1300
+ n === "months" ? c.setUTCDate(1) : n === "years" && c.setUTCMonth(0, 1), a(), c.getTime() < t && (c = new Date(X(c, [1, n])));
1296
1301
  break;
1297
1302
  }
1298
- return i.getTime();
1303
+ return c.getTime();
1299
1304
  }, Me = ({
1300
1305
  timeZone: t = kt,
1301
1306
  space: s = Tt,
1302
1307
  formatter: e,
1303
1308
  locale: o,
1304
1309
  showTimezone: n
1305
- } = {}) => (i, a) => {
1306
- const { min: r, max: d } = i, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - r) / u, [f, m] = Jt.find(
1310
+ } = {}) => (c, a) => {
1311
+ const { min: r, max: d } = c, u = Math.floor(a.chartAreaCanvasPX.width / s) + 1, p = (d - r) / u, [m, f] = Jt.find(
1307
1312
  (w) => q(w) >= p
1308
- ) ?? [1, "milliseconds"], c = oe(r, [f, m], t), h = G(c, t), y = [c];
1313
+ ) ?? [1, "milliseconds"], i = oe(r, [m, f], t), h = G(i, t), y = [i];
1309
1314
  let x;
1310
1315
  for (; ; ) {
1311
- switch (m) {
1316
+ switch (f) {
1312
1317
  case "milliseconds":
1313
1318
  case "seconds":
1314
1319
  case "minutes":
1315
1320
  case "hours": {
1316
- x = K(c, [y.length * f, m]);
1321
+ x = X(i, [y.length * m, f]);
1317
1322
  break;
1318
1323
  }
1319
1324
  case "days": {
1320
- const w = K(c, [
1321
- y.length * f,
1322
- m
1325
+ const w = X(i, [
1326
+ y.length * m,
1327
+ f
1323
1328
  ]);
1324
- x = K(w, [
1329
+ x = X(w, [
1325
1330
  h - G(w, t),
1326
1331
  "hours"
1327
1332
  ]);
@@ -1329,14 +1334,14 @@ const oe = (t, s, e = "UTC") => {
1329
1334
  }
1330
1335
  case "months":
1331
1336
  case "years": {
1332
- const w = K(
1333
- K(K(c, [h, "hours"]), [
1334
- y.length * f,
1335
- m
1337
+ const w = X(
1338
+ X(X(i, [h, "hours"]), [
1339
+ y.length * m,
1340
+ f
1336
1341
  ]),
1337
1342
  [-h, "hours"]
1338
1343
  );
1339
- x = K(w, [
1344
+ x = X(w, [
1340
1345
  h - G(w, t),
1341
1346
  "hours"
1342
1347
  ]);
@@ -1347,12 +1352,12 @@ const oe = (t, s, e = "UTC") => {
1347
1352
  break;
1348
1353
  y.push(x);
1349
1354
  }
1350
- return (e ?? ie({
1355
+ return (e ?? ce({
1351
1356
  locale: o,
1352
1357
  showTimezone: n,
1353
1358
  timeZone: t
1354
1359
  }))(y);
1355
- }, X = (t, s, e) => t.find((o) => o.type === e)?.value !== s.find((o) => o.type === e)?.value, ie = ({
1360
+ }, I = (t, s, e) => t.find((o) => o.type === e)?.value !== s.find((o) => o.type === e)?.value, ce = ({
1356
1361
  timeZone: t = kt,
1357
1362
  locale: s = Ht,
1358
1363
  showTimezone: e = !0
@@ -1370,15 +1375,15 @@ const oe = (t, s, e = "UTC") => {
1370
1375
  timeZone: t
1371
1376
  });
1372
1377
  return (n) => {
1373
- const i = n[1] - n[0], a = i < q([1, "days"]), r = i < q([1, "minutes"]), d = i < q([1, "seconds"]);
1378
+ const c = n[1] - n[0], a = c < q([1, "days"]), r = c < q([1, "minutes"]), d = c < q([1, "seconds"]);
1374
1379
  return n.map((u) => ({ value: u, label: o.formatToParts(new Date(u)) })).map((u, l, p) => {
1375
- const f = p[l - 1], m = l === 0 || X(u.label, f.label, "year"), c = l === 0 || X(u.label, f.label, "day"), h = l === 0 || X(u.label, f.label, "month"), y = l === 0 || X(u.label, f.label, "hour"), x = l === 0 || X(u.label, f.label, "timeZoneName"), w = l === 0 || X(u.label, f.label, "minute"), g = l === 0 || X(u.label, f.label, "second"), v = l === 0 || X(u.label, f.label, "fractionalSecond"), T = [];
1380
+ const m = p[l - 1], f = l === 0 || I(u.label, m.label, "year"), i = l === 0 || I(u.label, m.label, "day"), h = l === 0 || I(u.label, m.label, "month"), y = l === 0 || I(u.label, m.label, "hour"), x = l === 0 || I(u.label, m.label, "timeZoneName"), w = l === 0 || I(u.label, m.label, "minute"), g = l === 0 || I(u.label, m.label, "second"), v = l === 0 || I(u.label, m.label, "fractionalSecond"), T = [];
1376
1381
  if (a && (y || w || x || g || v)) {
1377
1382
  const b = 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;
1378
1383
  let A = "";
1379
1384
  if (r) {
1380
- const P = u.label.find((F) => F.type === "second")?.value, B = u.label.find(
1381
- (F) => F.type === "fractionalSecond"
1385
+ const P = u.label.find((K) => K.type === "second")?.value, B = u.label.find(
1386
+ (K) => K.type === "fractionalSecond"
1382
1387
  )?.value;
1383
1388
  A = `:${P}` + (d ? `.${B}` : "");
1384
1389
  }
@@ -1386,12 +1391,12 @@ const oe = (t, s, e = "UTC") => {
1386
1391
  `${b}:${C}${A}` + (e && x ? ` ${k}` : "")
1387
1392
  );
1388
1393
  }
1389
- return (c || h) && T.push(
1394
+ return (i || h) && T.push(
1390
1395
  [
1391
1396
  u.label.find((b) => b.type === "month")?.value,
1392
- c && u.label.find((b) => b.type === "day")?.value
1397
+ i && u.label.find((b) => b.type === "day")?.value
1393
1398
  ].filter(Boolean).join(" ")
1394
- ), m && T.push(u.label.find((b) => b.type === "year")?.value), {
1399
+ ), f && T.push(u.label.find((b) => b.type === "year")?.value), {
1395
1400
  value: u.value,
1396
1401
  label: T.filter((b) => b).join(`
1397
1402
  `)
@@ -1416,18 +1421,18 @@ export {
1416
1421
  R as applyStyles,
1417
1422
  j as clamp,
1418
1423
  de as clampUnfit,
1419
- O as clampXPosToChartArea,
1420
- $ as clampYPosToChartArea,
1424
+ Y as clampXPosToChartArea,
1425
+ O as clampYPosToChartArea,
1421
1426
  Wt as defaultNumericalTicksFormatter,
1422
1427
  ue as findClosestIndex,
1423
- I as getScale,
1428
+ L as getScale,
1424
1429
  Ee as makeLinearTicks,
1425
- ie as makeTimeTickFormat,
1430
+ ce as makeTimeTickFormat,
1426
1431
  Me as makeTimeTicks,
1427
1432
  D as posToVal,
1428
- Lt as pxToValDistance,
1433
+ Dt as pxToValDistance,
1429
1434
  le as sum,
1430
- Y as useDrawEffect,
1435
+ z as useDrawEffect,
1431
1436
  ht as useFrameState,
1432
1437
  mt as useInteractionsEvent,
1433
1438
  ge as useXPositioned,