@canplot/react 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canplot.mjs CHANGED
@@ -2,14 +2,14 @@ var Oe = Object.defineProperty;
2
2
  var Ke = (e, t, n) => t in e ? Oe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var K = (e, t, n) => Ke(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { jsxs as pe, jsx as R, Fragment as Fe } from "react/jsx-runtime";
5
- import D, { version as Ye, createContext as ye, forwardRef as ze, useRef as A, useState as z, useLayoutEffect as $, useMemo as oe, useCallback as Be, useContext as q, useId as Ne, useEffect as $e } from "react";
5
+ import D, { version as Ye, createContext as ye, forwardRef as Be, useRef as A, useState as B, useMemo as J, useLayoutEffect as $, useCallback as ze, useContext as q, useId as Ne, useEffect as $e } from "react";
6
6
  const G = (e, t, n) => Math.min(Math.max(e, t), n), Mt = (e) => e.reduce((t, n) => t + (n ?? 0), 0), Et = (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);
10
10
  return n;
11
11
  }, je = (e, t, n, s) => {
12
- const { min: o, max: r, origin: c } = X(e, n), i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, a = (c === "x" ? i.width : i.height) / (r - o);
12
+ const { min: o, max: c, origin: r } = X(e, n), i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, a = (r === "x" ? i.width : i.height) / (c - o);
13
13
  return t / a;
14
14
  }, X = (e, t) => {
15
15
  const n = e.scales.find((s) => s.id === t);
@@ -20,18 +20,18 @@ const G = (e, t, n) => Math.min(Math.max(e, t), n), Mt = (e) => e.reduce((t, n)
20
20
  const n = window.devicePixelRatio || 1;
21
21
  e.lineCap = t?.lineCap ?? "butt", e.lineDashOffset = n * (t?.lineDashOffset ?? 0), e.lineJoin = t?.lineJoin ?? "miter", e.lineWidth = n * (t?.lineWidth ?? 1), e.miterLimit = n * (t?.miterLimit ?? 10), e.strokeStyle = t?.strokeStyle ?? "black", e.fillStyle = t?.fillStyle ?? e.strokeStyle, e.font = t?.font ?? `${10 * n}px sans-serif`, e.textAlign = t?.textAlign ?? "start", e.direction = t?.direction ?? "inherit", e.textBaseline = t?.textBaseline ?? "alphabetic", e.fontKerning = t?.fontKerning ?? "auto";
22
22
  }, ge = (e, t, n, s) => {
23
- const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, { min: r, max: c, origin: i } = X(e, n), a = (i === "x" ? o.width : o.height) / (c - r);
23
+ const o = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, { min: c, max: r, origin: i } = X(e, n), a = (i === "x" ? o.width : o.height) / (r - c);
24
24
  return t * a;
25
25
  }, Z = (e, t, n, s) => {
26
- const { min: o, origin: r } = X(e, n), c = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = ge(e, t - o, n, s);
27
- return r === "x" ? G(
28
- c.x + i,
29
- c.x - 10 * c.width,
30
- c.x + 11 * c.width
26
+ const { min: o, origin: c } = X(e, n), r = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, i = ge(e, t - o, n, s);
27
+ return c === "x" ? G(
28
+ r.x + i,
29
+ r.x - 10 * r.width,
30
+ r.x + 11 * r.width
31
31
  ) : G(
32
- c.y + c.height - i,
33
- c.y - 10 * c.height,
34
- c.y + 11 * c.height
32
+ r.y + r.height - i,
33
+ r.y - 10 * r.height,
34
+ r.y + 11 * r.height
35
35
  );
36
36
  }, kt = (e, t, n) => {
37
37
  const { min: s, max: o } = X(e, n);
@@ -46,8 +46,8 @@ const G = (e, t, n) => Math.min(Math.max(e, t), n), Mt = (e) => e.reduce((t, n)
46
46
  const { min: s, max: o } = X(e, n);
47
47
  return t >= s && t <= o;
48
48
  }, _ = (e, t, n, s) => {
49
- const { min: o, max: r, origin: c } = X(e, n), i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, a = c === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
50
- return o + a * (r - o);
49
+ const { min: o, max: c, origin: r } = X(e, n), i = s === "canvas" ? e.chartAreaCanvasPX : e.chartAreaCSS, a = r === "x" ? (t - i.x) / i.width : (i.height - t + i.y) / i.height;
50
+ return o + a * (c - o);
51
51
  }, O = (e, t) => {
52
52
  if (e === t) return !0;
53
53
  if (e == null || t == null || typeof e != typeof t || typeof e != "object" || Array.isArray(e) !== Array.isArray(t)) return !1;
@@ -77,12 +77,12 @@ const G = (e, t, n) => Math.min(Math.max(e, t), n), Mt = (e) => e.reduce((t, n)
77
77
  if (s.axis.position === "bottom")
78
78
  t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x + o.width, o.y), t.stroke();
79
79
  else if (s.axis.position === "top") {
80
- const r = o.y + o.height;
81
- t.beginPath(), t.moveTo(o.x, r), t.lineTo(o.x + o.width, r), t.stroke();
80
+ const c = o.y + o.height;
81
+ t.beginPath(), t.moveTo(o.x, c), t.lineTo(o.x + o.width, c), t.stroke();
82
82
  }
83
83
  } else if (s.axis.position === "left") {
84
- const r = o.x + o.width;
85
- t.beginPath(), t.moveTo(r, o.y), t.lineTo(r, o.y + o.height), t.stroke();
84
+ const c = o.x + o.width;
85
+ t.beginPath(), t.moveTo(c, o.y), t.lineTo(c, o.y + o.height), t.stroke();
86
86
  } else s.axis.position === "right" && (t.beginPath(), t.moveTo(o.x, o.y), t.lineTo(o.x, o.y + o.height), t.stroke());
87
87
  t.restore();
88
88
  }
@@ -96,8 +96,8 @@ function We(e) {
96
96
  return (t) => {
97
97
  const n = [];
98
98
  for (const s of e) {
99
- const o = me(s, t), r = typeof o == "function";
100
- n.push(r ? o : () => me(s, null));
99
+ const o = me(s, t), c = typeof o == "function";
100
+ n.push(c ? o : () => me(s, null));
101
101
  }
102
102
  return () => {
103
103
  for (const s of n) s();
@@ -118,9 +118,9 @@ const Ee = ye({
118
118
  }
119
119
  }), Ge = () => {
120
120
  const e = [];
121
- return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((r, c) => r[0] - c[0]), () => {
122
- const r = e.findIndex(([, c]) => c === s);
123
- r !== -1 && e.splice(r, 1);
121
+ return { listeners: e, subscribe: (s, o) => (e.push([o, s]), e.sort((c, r) => c[0] - r[0]), () => {
122
+ const c = e.findIndex(([, r]) => r === s);
123
+ c !== -1 && e.splice(c, 1);
124
124
  }), notifyListeners: () => {
125
125
  for (const [, s] of e)
126
126
  s();
@@ -154,16 +154,19 @@ class Re {
154
154
  return this.frame.ctx;
155
155
  }
156
156
  }
157
- const At = ze(({ configuration: e, children: t, style: n, className: s }, o) => {
158
- const r = A(null), c = A(null), i = Je(c), [a, l] = z(() => null);
157
+ const At = Be(({ configuration: e, children: t, style: n, className: s }, o) => {
158
+ const c = A(null), r = A(null), i = Je(r), [a, u] = B(null), m = J(
159
+ () => Qe(e, i, a),
160
+ [e, i, a]
161
+ );
159
162
  $(() => {
160
- l(Qe(e, i, r.current));
161
- }, [e, i, r]);
162
- const m = window.devicePixelRatio || 1;
163
+ u(c.current?.getContext("2d") || null);
164
+ }, [c]);
165
+ const h = window.devicePixelRatio || 1;
163
166
  return /* @__PURE__ */ pe(
164
167
  "div",
165
168
  {
166
- ref: qe([o, c]),
169
+ ref: qe([o, r]),
167
170
  className: s,
168
171
  style: {
169
172
  position: "relative",
@@ -175,9 +178,9 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
175
178
  /* @__PURE__ */ R(
176
179
  "canvas",
177
180
  {
178
- ref: r,
179
- width: i.width * m,
180
- height: i.height * m,
181
+ ref: c,
182
+ width: i.width * h,
183
+ height: i.height * h,
181
184
  style: {
182
185
  inset: 0,
183
186
  position: "absolute",
@@ -186,7 +189,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
186
189
  }
187
190
  }
188
191
  ),
189
- a && /* @__PURE__ */ R(Ze, { frame: a, children: t })
192
+ m && /* @__PURE__ */ R(Ze, { frame: m, children: t })
190
193
  ]
191
194
  }
192
195
  );
@@ -194,14 +197,14 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
194
197
  frame: e,
195
198
  children: t
196
199
  }) => {
197
- const n = oe(Ge, []), [s, o] = z(0);
200
+ const n = J(Ge, []), [s, o] = B(0);
198
201
  $(() => {
199
202
  e?.ctx.clearRect(0, 0, e.ctx.canvas.width, e.ctx.canvas.height);
200
203
  }, [e, s]);
201
- const r = A(null);
202
- r.current = e, $(() => {
204
+ const c = A(null);
205
+ c.current = e, $(() => {
203
206
  n.subscribe(() => {
204
- r.current && Ve(r.current);
207
+ c.current && Ve(c.current);
205
208
  }, Ae.BOTTOM);
206
209
  }, [n]), $(() => {
207
210
  let i = null;
@@ -211,75 +214,75 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
211
214
  i && cancelAnimationFrame(i);
212
215
  };
213
216
  }, [s, e, n]);
214
- const c = Be(() => {
217
+ const r = ze(() => {
215
218
  o((i) => i + 1);
216
219
  }, [o]);
217
- return /* @__PURE__ */ R(Ee.Provider, { value: n, children: /* @__PURE__ */ R(ke.Provider, { value: c, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
220
+ return /* @__PURE__ */ R(Ee.Provider, { value: n, children: /* @__PURE__ */ R(ke.Provider, { value: r, children: /* @__PURE__ */ R(ve.Provider, { value: e, children: t }) }) });
218
221
  }, Je = (e) => {
219
- const [t, n] = z({
222
+ const [t, n] = B({
220
223
  width: 0,
221
224
  height: 0
222
- }), [s] = z(() => new ResizeObserver((o) => {
223
- for (const r of o) {
224
- const c = Math.round(r.contentRect.width), i = Math.round(r.contentRect.height);
225
+ }), [s] = B(() => new ResizeObserver((o) => {
226
+ for (const c of o) {
227
+ const r = Math.round(c.contentRect.width), i = Math.round(c.contentRect.height);
225
228
  n(
226
- (a) => a.width !== c || a.height !== i ? { ...a, width: c, height: i } : a
229
+ (a) => a.width !== r || a.height !== i ? { ...a, width: r, height: i } : a
227
230
  );
228
231
  }
229
232
  }));
230
233
  return $(() => {
231
234
  if (!e.current) return;
232
- const o = e.current.clientWidth, r = e.current.clientHeight;
235
+ const o = e.current.clientWidth, c = e.current.clientHeight;
233
236
  return n(
234
- (c) => c.width !== o || c.height !== r ? { ...c, width: o, height: r } : c
237
+ (r) => r.width !== o || r.height !== c ? { ...r, width: o, height: c } : r
235
238
  ), s.observe(e.current, { box: "border-box" }), () => s.disconnect();
236
239
  }, [s, e]), t;
237
240
  }, Qe = (e, t, n) => {
238
- const s = n?.getContext("2d");
239
- if (!s) return null;
240
- const o = window.devicePixelRatio || 1;
241
+ if (!n)
242
+ return null;
243
+ const s = window.devicePixelRatio || 1;
241
244
  if (t.width === 0 || t.height === 0)
242
245
  return null;
243
- const r = {
246
+ const o = {
244
247
  x: e.padding.left,
245
248
  y: e.padding.top,
246
249
  width: t.width - e.padding.left - e.padding.right,
247
250
  height: t.height - e.padding.top - e.padding.bottom
248
251
  };
249
- for (const u of e.scales)
250
- u.axis && (u.origin === "x" ? (u.axis.position === "bottom" || u.axis.position === "top") && (r.height = Math.max(
252
+ for (const l of e.scales)
253
+ l.axis && (l.origin === "x" ? (l.axis.position === "bottom" || l.axis.position === "top") && (o.height = Math.max(
251
254
  0,
252
- r.height - u.axis.size
253
- ), u.axis.position === "top" && (r.y += u.axis.size)) : (u.axis.position === "left" || u.axis.position === "right") && (r.width = Math.max(0, r.width - u.axis.size), u.axis.position === "left" && (r.x += u.axis.size)));
255
+ o.height - l.axis.size
256
+ ), l.axis.position === "top" && (o.y += l.axis.size)) : (l.axis.position === "left" || l.axis.position === "right") && (o.width = Math.max(0, o.width - l.axis.size), l.axis.position === "left" && (o.x += l.axis.size)));
254
257
  const c = {
255
- x: r.x * o,
256
- y: r.y * o,
257
- width: r.width * o,
258
- height: r.height * o
259
- }, i = [];
260
- let a = e.padding.left * o, l = s.canvas.width - e.padding.right * o, m = s.canvas.height - e.padding.bottom * o, d = e.padding.top * o;
261
- for (const u of e.scales) {
262
- if (!u.axis) {
263
- i.push({ ...u, axis: null });
258
+ x: o.x * s,
259
+ y: o.y * s,
260
+ width: o.width * s,
261
+ height: o.height * s
262
+ }, r = [];
263
+ let i = e.padding.left * s, a = t.width * s - e.padding.right * s, u = t.height * s - e.padding.bottom * s, m = e.padding.top * s;
264
+ for (const l of e.scales) {
265
+ if (!l.axis) {
266
+ r.push({ ...l, axis: null });
264
267
  continue;
265
268
  }
266
- let h;
267
- if (u.origin === "x")
268
- switch (u.axis.position) {
269
+ let p;
270
+ if (l.origin === "x")
271
+ switch (l.axis.position) {
269
272
  case "bottom":
270
- m -= u.axis.size * o, h = {
271
- x: r.x,
272
- y: m / o,
273
- width: r.width,
274
- height: u.axis.size
273
+ u -= l.axis.size * s, p = {
274
+ x: o.x,
275
+ y: u / s,
276
+ width: o.width,
277
+ height: l.axis.size
275
278
  };
276
279
  break;
277
280
  case "top":
278
- d += u.axis.size * o, h = {
279
- x: r.x,
280
- y: d / o - u.axis.size,
281
- width: r.width,
282
- height: u.axis.size
281
+ m += l.axis.size * s, p = {
282
+ x: o.x,
283
+ y: m / s - l.axis.size,
284
+ width: o.width,
285
+ height: l.axis.size
283
286
  };
284
287
  break;
285
288
  case "left":
@@ -287,84 +290,84 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
287
290
  throw new Error("Invalid axis position for x origin");
288
291
  }
289
292
  else
290
- switch (u.axis.position) {
293
+ switch (l.axis.position) {
291
294
  case "left":
292
- a += u.axis.size * o, h = {
293
- x: a / o - u.axis.size,
294
- y: r.y,
295
- width: u.axis.size,
296
- height: r.height
295
+ i += l.axis.size * s, p = {
296
+ x: i / s - l.axis.size,
297
+ y: o.y,
298
+ width: l.axis.size,
299
+ height: o.height
297
300
  };
298
301
  break;
299
302
  case "right":
300
- l -= u.axis.size * o, h = {
301
- x: l / o,
302
- y: r.y,
303
- width: u.axis.size,
304
- height: r.height
303
+ a -= l.axis.size * s, p = {
304
+ x: a / s,
305
+ y: o.y,
306
+ width: l.axis.size,
307
+ height: o.height
305
308
  };
306
309
  break;
307
310
  case "top":
308
311
  case "bottom":
309
312
  throw new Error("Invalid axis position for y origin");
310
313
  }
311
- const y = {
312
- x: h.x * o,
313
- y: h.y * o,
314
- width: h.width * o,
315
- height: h.height * o
314
+ const d = {
315
+ x: p.x * s,
316
+ y: p.y * s,
317
+ width: p.width * s,
318
+ height: p.height * s
316
319
  };
317
- i.push({
318
- ...u,
320
+ r.push({
321
+ ...l,
319
322
  axis: {
320
- ...u.axis,
321
- cssRect: h,
322
- canvasRect: y
323
+ ...l.axis,
324
+ cssRect: p,
325
+ canvasRect: d
323
326
  }
324
327
  });
325
328
  }
326
329
  return {
327
- ctx: s,
328
- dpr: o,
330
+ ctx: n,
331
+ dpr: s,
329
332
  padding: e.padding,
330
- scales: i,
331
- chartAreaCSS: r,
333
+ scales: r,
334
+ chartAreaCSS: o,
332
335
  chartAreaCanvasPX: c
333
336
  };
334
337
  }, j = (e, t, n) => {
335
- const s = q(ve), o = q(ke), r = q(Ee);
338
+ const s = q(ve), o = q(ke), c = q(Ee);
336
339
  if (!s || !o)
337
340
  throw new Error("useFrame must be used within a CanPlot component");
338
- const [c] = z(() => new Re());
339
- c._updateFrame(s);
340
- const i = A(c);
341
- i.current = c;
341
+ const [r] = B(() => new Re());
342
+ r._updateFrame(s);
343
+ const i = A(r);
344
+ i.current = r;
342
345
  const a = A(t);
343
- a.current = t, $(() => r.subscribe(
346
+ a.current = t, $(() => c.subscribe(
344
347
  () => {
345
- a.current(c);
348
+ a.current(r);
346
349
  },
347
350
  typeof e == "number" ? e : Ae[e]
348
- ), [r, e, c]), $(() => {
351
+ ), [c, e, r]), $(() => {
349
352
  o();
350
353
  }, [o, ...n]);
351
354
  }, De = () => {
352
355
  const e = q(ve);
353
356
  if (!e)
354
357
  throw new Error("useFrame must be used within a CanPlot component");
355
- return oe(() => {
358
+ return J(() => {
356
359
  const t = new Re();
357
360
  return t._updateFrame(e), t;
358
361
  }, [e]);
359
362
  }, et = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
360
363
  e,
361
- ({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: i, valToPos: a }) => {
362
- r.save(), r.beginPath(), U(r, o);
363
- for (const l of t) {
364
- const m = c(a(l.x, n)), d = i(a(l.y, s));
365
- r.lineTo(m, d);
364
+ ({ ctx: c, clampXPosToChartArea: r, clampYPosToChartArea: i, valToPos: a }) => {
365
+ c.save(), c.beginPath(), U(c, o);
366
+ for (const u of t) {
367
+ const m = r(a(u.x, n)), h = i(a(u.y, s));
368
+ c.lineTo(m, h);
366
369
  }
367
- r.stroke(), r.restore();
370
+ c.stroke(), c.restore();
368
371
  },
369
372
  [t, n, s, o]
370
373
  ), null), Rt = D.memo(et, O), tt = ({
@@ -373,141 +376,141 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
373
376
  xScaleId: n,
374
377
  yScaleId: s,
375
378
  xStrategy: o = "clip",
376
- yStrategy: r = "clip",
377
- radius: c = 5,
379
+ yStrategy: c = "clip",
380
+ radius: r = 5,
378
381
  style: i,
379
382
  globalAlpha: a
380
383
  }) => (j(
381
384
  e,
382
385
  ({
383
- ctx: l,
386
+ ctx: u,
384
387
  valToPos: m,
385
- valFits: d,
386
- clampXPosToChartArea: p,
387
- clampYPosToChartArea: u
388
+ valFits: h,
389
+ clampXPosToChartArea: l,
390
+ clampYPosToChartArea: p
388
391
  }) => {
389
- l.save(), l.beginPath();
390
- const h = new Path2D();
391
- U(l, i), a !== void 0 && (l.globalAlpha = a);
392
+ u.save(), u.beginPath();
393
+ const d = new Path2D();
394
+ U(u, i), a !== void 0 && (u.globalAlpha = a);
392
395
  for (const y of t) {
393
396
  let f, g;
394
397
  switch (o) {
395
398
  case "clip":
396
- if (!d(y.x, n))
399
+ if (!h(y.x, n))
397
400
  continue;
398
401
  f = m(y.x, n);
399
402
  break;
400
403
  case "clamp":
401
- f = p(m(y.x, n), "canvas");
404
+ f = l(m(y.x, n), "canvas");
402
405
  break;
403
406
  }
404
- switch (r) {
407
+ switch (c) {
405
408
  case "clip":
406
- if (!d(y.y, s))
409
+ if (!h(y.y, s))
407
410
  continue;
408
411
  g = m(y.y, s);
409
412
  break;
410
413
  case "clamp":
411
- g = u(m(y.y, s), "canvas");
414
+ g = p(m(y.y, s), "canvas");
412
415
  break;
413
416
  }
414
- h.moveTo(f + c, g), h.arc(f, g, c, 0, Math.PI * 2);
417
+ d.moveTo(f + r, g), d.arc(f, g, r, 0, Math.PI * 2);
415
418
  }
416
- l.fill(h), l.stroke(h), l.restore();
419
+ u.fill(d), u.stroke(d), u.restore();
417
420
  },
418
- [t, n, s, c, i, a]
421
+ [t, n, s, r, i, a]
419
422
  ), null), Dt = D.memo(tt, O), nt = ({
420
423
  data: e,
421
424
  xScaleId: t,
422
425
  yScaleId: n,
423
426
  style: s,
424
427
  barWidth: o,
425
- xPositionOffset: r,
426
- radius: c,
428
+ xPositionOffset: c,
429
+ radius: r,
427
430
  layer: i = "MIDDLE"
428
431
  }) => (j(
429
432
  i,
430
433
  ({
431
434
  ctx: a,
432
- valToPxDistance: l,
435
+ valToPxDistance: u,
433
436
  valToPos: m,
434
- clampXPosToChartArea: d,
435
- clampYPosToChartArea: p
437
+ clampXPosToChartArea: h,
438
+ clampYPosToChartArea: l
436
439
  }) => {
437
440
  if (e.length === 0) return;
438
441
  a.save(), U(a, s);
439
- const u = l(o, t);
442
+ const p = u(o, t);
440
443
  a.beginPath();
441
- for (const h of e) {
442
- const f = m(h.x, t) - u / 2 + r * u, g = p(m(0, n)), w = p(m(h.y, n)), T = g - w, x = d(f), v = d(f + u) - x;
443
- c ? a.roundRect(
444
+ for (const d of e) {
445
+ const f = m(d.x, t) - p / 2 + c * p, g = l(m(0, n)), w = l(m(d.y, n)), T = g - w, x = h(f), v = h(f + p) - x;
446
+ r ? a.roundRect(
444
447
  x,
445
448
  w,
446
449
  v,
447
450
  T,
448
- c
451
+ r
449
452
  ) : a.rect(x, w, v, T);
450
453
  }
451
454
  a.closePath(), a.fill(), s?.strokeStyle && a.stroke(), a.restore();
452
455
  },
453
- [e, t, n, s, o, r, c]
456
+ [e, t, n, s, o, c, r]
454
457
  ), null), It = D.memo(nt, O), st = ({ layer: e = "MIDDLE", data: t, xScaleId: n, yScaleId: s, style: o }) => (j(
455
458
  e,
456
- ({ ctx: r, clampXPosToChartArea: c, clampYPosToChartArea: i, valToPos: a }) => {
457
- const l = [];
458
- for (const d of t) {
459
- const p = c(a(d.x, n)), u = i(a(d.y[0], s)), h = i(a(d.y[1], s));
460
- l.push({ x: p, y: u }), l.unshift({ x: p, y: h });
459
+ ({ ctx: c, clampXPosToChartArea: r, clampYPosToChartArea: i, valToPos: a }) => {
460
+ const u = [];
461
+ for (const h of t) {
462
+ const l = r(a(h.x, n)), p = i(a(h.y[0], s)), d = i(a(h.y[1], s));
463
+ u.push({ x: l, y: p }), u.unshift({ x: l, y: d });
461
464
  }
462
- const m = l[0];
465
+ const m = u[0];
463
466
  if (m) {
464
- r.save(), r.beginPath(), U(r, o), r.moveTo(m.x, m.y);
465
- for (const d of l)
466
- r.lineTo(d.x, d.y);
467
- r.closePath(), r.fill(), r.restore();
467
+ c.save(), c.beginPath(), U(c, o), c.moveTo(m.x, m.y);
468
+ for (const h of u)
469
+ c.lineTo(h.x, h.y);
470
+ c.closePath(), c.fill(), c.restore();
468
471
  }
469
472
  },
470
473
  [t, n, s, o]
471
- ), null), Lt = D.memo(st, O), ot = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: r }) => (j(
474
+ ), null), Lt = D.memo(st, O), ot = ({ layer: e = "MIDDLE", data: t, stroked: n, xScaleId: s, yScaleId: o, style: c }) => (j(
472
475
  e,
473
- ({ ctx: c, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: l }) => {
476
+ ({ ctx: r, clampXPosToChartArea: i, clampYPosToChartArea: a, valToPos: u }) => {
474
477
  const m = [];
475
- for (const h of t) {
476
- const y = i(l(h.x, s)), f = a(l(h.y, o));
478
+ for (const d of t) {
479
+ const y = i(u(d.x, s)), f = a(u(d.y, o));
477
480
  m.push({ x: y, y: f });
478
481
  }
479
- const d = m.at(0), p = m.at(-1);
480
- if (!d || !p)
482
+ const h = m.at(0), l = m.at(-1);
483
+ if (!h || !l)
481
484
  return;
482
- const u = a(l(0, o));
483
- c.save(), c.beginPath(), U(c, r), c.moveTo(d.x, u);
484
- for (const h of m)
485
- c.lineTo(h.x, h.y);
486
- if (c.lineTo(p.x, u), c.closePath(), c.fill(), n) {
487
- c.beginPath(), c.moveTo(d.x, d.y);
488
- for (const h of m)
489
- c.lineTo(h.x, h.y);
490
- c.stroke();
485
+ const p = a(u(0, o));
486
+ r.save(), r.beginPath(), U(r, c), r.moveTo(h.x, p);
487
+ for (const d of m)
488
+ r.lineTo(d.x, d.y);
489
+ if (r.lineTo(l.x, p), r.closePath(), r.fill(), n) {
490
+ r.beginPath(), r.moveTo(h.x, h.y);
491
+ for (const d of m)
492
+ r.lineTo(d.x, d.y);
493
+ r.stroke();
491
494
  }
492
- c.restore();
495
+ r.restore();
493
496
  },
494
- [t, n, s, o, r]
495
- ), null), Ut = D.memo(ot, O), rt = ({ layer: e = "BOTTOM", scaleId: t, tickStyle: n, labelStyle: s, labelGap: o, tickSize: r, ticks: c }) => (j(
497
+ [t, n, s, o, c]
498
+ ), null), Ut = D.memo(ot, O), rt = ({ layer: e = "BOTTOM", scaleId: t, tickStyle: n, labelStyle: s, labelGap: o, tickSize: c, ticks: r }) => (j(
496
499
  e,
497
- ({ ctx: i, valToPos: a, getScale: l, frame: m }) => {
498
- const d = l(t);
499
- if (!d || !d.axis || d.origin !== "x") return;
500
- const p = d.axis, u = p.position === "top" ? p.canvasRect.y + p.canvasRect.height : p.canvasRect.y, h = window.devicePixelRatio || 1, y = u, f = (r ?? 6) * h, g = p.position === "top" ? u - f : u + f, w = (o ?? 12) * h;
500
+ ({ ctx: i, valToPos: a, getScale: u, frame: m }) => {
501
+ const h = u(t);
502
+ if (!h || !h.axis || h.origin !== "x") return;
503
+ const l = h.axis, p = l.position === "top" ? l.canvasRect.y + l.canvasRect.height : l.canvasRect.y, d = window.devicePixelRatio || 1, y = p, f = (c ?? 6) * d, g = l.position === "top" ? p - f : p + f, w = (o ?? 12) * d;
501
504
  i.save(), i.fontKerning = "auto", U(i, {
502
505
  ...n
503
506
  }), i.beginPath();
504
- const T = Array.isArray(c) ? c : c({ ...d, axis: p }, m);
507
+ const T = Array.isArray(r) ? r : r({ ...h, axis: l }, m);
505
508
  for (const { value: x } of T) {
506
509
  const v = a(x, t, "canvas");
507
510
  i.moveTo(v, y), i.lineTo(v, g);
508
511
  }
509
512
  i.stroke(), i.restore(), i.save(), U(i, {
510
- textBaseline: p.position === "top" ? "bottom" : "top",
513
+ textBaseline: l.position === "top" ? "bottom" : "top",
511
514
  textAlign: "center",
512
515
  ...n,
513
516
  ...s
@@ -516,25 +519,25 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
516
519
  const b = a(x, t, "canvas"), S = v.split(`
517
520
  `);
518
521
  for (let E = 0; E < S.length; E++)
519
- i.fillText(S[E], b, g + h * 2 + E * w);
522
+ i.fillText(S[E], b, g + d * 2 + E * w);
520
523
  }
521
524
  i.restore();
522
525
  },
523
- [c, t, n, s]
524
- ), null), _t = D.memo(rt, O), it = ({ layer: e = "BOTTOM", scaleId: t, tickStyle: n, labelStyle: s, labelGap: o, tickSize: r, ticks: c }) => (j(
526
+ [r, t, n, s]
527
+ ), null), _t = D.memo(rt, O), it = ({ layer: e = "BOTTOM", scaleId: t, tickStyle: n, labelStyle: s, labelGap: o, tickSize: c, ticks: r }) => (j(
525
528
  e,
526
- ({ ctx: i, valToPos: a, getScale: l, frame: m }) => {
527
- const d = l(t);
528
- if (!d || !d.axis || d.origin !== "y") return;
529
- const p = d.axis, u = p.position === "left" ? p.canvasRect.x + p.canvasRect.width : p.canvasRect.x, h = u, y = r ?? 6, f = p.position === "left" ? u - y : u + y, g = o ?? 12, w = Array.isArray(c) ? c : c({ ...d, axis: p }, m);
529
+ ({ ctx: i, valToPos: a, getScale: u, frame: m }) => {
530
+ const h = u(t);
531
+ if (!h || !h.axis || h.origin !== "y") return;
532
+ const l = h.axis, p = l.position === "left" ? l.canvasRect.x + l.canvasRect.width : l.canvasRect.x, d = p, y = c ?? 6, f = l.position === "left" ? p - y : p + y, g = o ?? 12, w = Array.isArray(r) ? r : r({ ...h, axis: l }, m);
530
533
  i.save(), i.fontKerning = "auto", U(i, { ...n }), i.beginPath();
531
534
  for (const { value: T } of w) {
532
535
  const x = a(T, t, "canvas");
533
- i.moveTo(h, x), i.lineTo(f, x);
536
+ i.moveTo(d, x), i.lineTo(f, x);
534
537
  }
535
538
  i.stroke(), i.restore(), i.save(), U(i, {
536
539
  textBaseline: "middle",
537
- textAlign: p.position === "left" ? "right" : "left",
540
+ textAlign: l.position === "left" ? "right" : "left",
538
541
  ...n,
539
542
  ...s
540
543
  });
@@ -546,7 +549,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
546
549
  }
547
550
  i.restore();
548
551
  },
549
- [c, t, n, s]
552
+ [r, t, n, s]
550
553
  ), null), Xt = D.memo(it, O), I = () => {
551
554
  const e = [];
552
555
  return {
@@ -577,8 +580,8 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
577
580
  const s = D.useRef(n);
578
581
  s.current = n, D.useEffect(() => M[e].addEventListener(
579
582
  t,
580
- (r, c) => {
581
- s.current(c, r);
583
+ (c, r) => {
584
+ s.current(r, c);
582
585
  }
583
586
  ), [t, e, s]);
584
587
  }, we = D.createContext(""), xe = (e, t) => {
@@ -586,23 +589,23 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
586
589
  return L(e, n, t);
587
590
  }, ct = (e, t, n, s, o) => {
588
591
  if (!t) return;
589
- const r = s ?? n.scales.find((d) => d.origin === "x")?.id, c = o ?? n.scales.find((d) => d.origin === "y")?.id, i = e.clientX - t.left, a = r ? {
590
- scaleId: r,
591
- value: _(n, i, r, "css")
592
- } : null, l = e.clientY - t.top, m = c ? {
592
+ const c = s ?? n.scales.find((h) => h.origin === "x")?.id, r = o ?? n.scales.find((h) => h.origin === "y")?.id, i = e.clientX - t.left, a = c ? {
593
593
  scaleId: c,
594
- value: _(n, l, c, "css")
594
+ value: _(n, i, c, "css")
595
+ } : null, u = e.clientY - t.top, m = r ? {
596
+ scaleId: r,
597
+ value: _(n, u, r, "css")
595
598
  } : null;
596
- return { pointerSyncPosition: { x: a, y: m }, cssX: i, cssY: l };
599
+ return { pointerSyncPosition: { x: a, y: m }, cssX: i, cssY: u };
597
600
  }, N = (e, t) => {
598
- const { x: n, y: s } = e, o = n && t.scales.some((c) => c.id === n.scaleId) ? Z(t, n.value, n.scaleId, "css") : null, r = s && t.scales.some((c) => c.id === s.scaleId) ? Z(t, s.value, s.scaleId, "css") : null;
601
+ const { x: n, y: s } = e, o = n && t.scales.some((r) => r.id === n.scaleId) ? Z(t, n.value, n.scaleId, "css") : null, c = s && t.scales.some((r) => r.id === s.scaleId) ? Z(t, s.value, s.scaleId, "css") : null;
599
602
  return {
600
603
  cssX: o,
601
- cssY: r,
604
+ cssY: c,
602
605
  scaled: Object.fromEntries(
603
- t.scales.flatMap((c) => {
604
- const i = c.origin === "y" ? r : o;
605
- return i === null ? [] : [[c.id, _(t, i, c.id, "css")]];
606
+ t.scales.flatMap((r) => {
607
+ const i = r.origin === "y" ? c : o;
608
+ return i === null ? [] : [[r.id, _(t, i, r.id, "css")]];
606
609
  })
607
610
  )
608
611
  };
@@ -617,14 +620,14 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
617
620
  t.to,
618
621
  t.scaleId,
619
622
  "css"
620
- ), r = n.scales.flatMap(
621
- (c) => {
622
- if (c.origin !== e)
623
+ ), c = n.scales.flatMap(
624
+ (r) => {
625
+ if (r.origin !== e)
623
626
  return [];
624
- const i = _(n, s, c.id, "css"), a = _(n, o, c.id, "css");
627
+ const i = _(n, s, r.id, "css"), a = _(n, o, r.id, "css");
625
628
  return [
626
629
  {
627
- scaleId: c.id,
630
+ scaleId: r.id,
628
631
  from: i,
629
632
  to: a
630
633
  }
@@ -634,7 +637,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
634
637
  return {
635
638
  fromCSS: s,
636
639
  toCSS: o,
637
- scaled: r
640
+ scaled: c
638
641
  };
639
642
  }, Ot = ({
640
643
  id: e,
@@ -642,51 +645,51 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
642
645
  onDblClick: n,
643
646
  onMouseMove: s,
644
647
  onMouseDown: o,
645
- onMouseUp: r,
646
- onDocumentMouseUp: c,
648
+ onMouseUp: c,
649
+ onDocumentMouseUp: r,
647
650
  onSpanSelect: i,
648
651
  onContextMenu: a,
649
- className: l,
652
+ className: u,
650
653
  style: m,
651
- sync: d,
652
- innerChildren: p,
653
- children: u
654
+ sync: h,
655
+ innerChildren: l,
656
+ children: p
654
657
  }) => {
655
- const h = Ne();
656
- return L("dblclick", h, (y) => {
658
+ const d = Ne();
659
+ return L("dblclick", d, (y) => {
657
660
  n?.(y);
658
- }), L("click", h, (y) => {
661
+ }), L("click", d, (y) => {
659
662
  t?.(y);
660
- }), L("move", h, (y) => {
663
+ }), L("move", d, (y) => {
661
664
  s?.(y);
662
- }), L("mousedown", h, (y) => {
665
+ }), L("mousedown", d, (y) => {
663
666
  o?.(y);
664
- }), L("mouseup", h, (y) => {
665
- r?.(y);
666
- }), L("documentmouseup", h, (y) => {
667
+ }), L("mouseup", d, (y) => {
667
668
  c?.(y);
668
- }), L("spanselect", h, (y) => {
669
+ }), L("documentmouseup", d, (y) => {
670
+ r?.(y);
671
+ }), L("spanselect", d, (y) => {
669
672
  i?.(y);
670
- }), L("contextmenu", h, (y) => {
673
+ }), L("contextmenu", d, (y) => {
671
674
  a?.(y);
672
- }), /* @__PURE__ */ pe(we.Provider, { value: h, children: [
675
+ }), /* @__PURE__ */ pe(we.Provider, { value: d, children: [
673
676
  /* @__PURE__ */ R(
674
677
  at,
675
678
  {
676
679
  id: e,
677
- className: l,
680
+ className: u,
678
681
  style: m,
679
- sync: d,
680
- children: p
682
+ sync: h,
683
+ children: l
681
684
  }
682
685
  ),
683
- u
686
+ p
684
687
  ] });
685
688
  }, at = ({ id: e, className: t, style: n, sync: s, children: o }) => {
686
- const r = A(null), c = De().frame, i = A(c);
687
- i.current = c;
688
- const a = q(we), l = s?.key || a, m = A(null), d = A(null), p = A(null), u = () => {
689
- const f = r.current?.parentElement;
689
+ const c = A(null), r = De().frame, i = A(r);
690
+ i.current = r;
691
+ const a = q(we), u = s?.key || a, m = A(null), h = A(null), l = A(null), p = () => {
692
+ const f = c.current?.parentElement;
690
693
  if (f) {
691
694
  if (f.dataset.canplotroot === void 0)
692
695
  throw new Error(
@@ -694,10 +697,10 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
694
697
  );
695
698
  return f.getBoundingClientRect();
696
699
  }
697
- }, h = (f, g) => {
700
+ }, d = (f, g) => {
698
701
  const w = ct(
699
702
  f,
700
- u(),
703
+ p(),
701
704
  i.current,
702
705
  s?.xViaScaleId,
703
706
  s?.yViaScaleId
@@ -712,10 +715,10 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
712
715
  metaKey: f.metaKey
713
716
  }
714
717
  );
715
- }, y = A(h);
716
- return y.current = h, $e(() => {
718
+ }, y = A(d);
719
+ return y.current = d, $e(() => {
717
720
  const f = (v) => {
718
- const b = d.current;
721
+ const b = h.current;
719
722
  b && M.spanselect.dispatchEvent(a, {
720
723
  ...b,
721
724
  completed: !0
@@ -734,20 +737,20 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
734
737
  altKey: v.altKey,
735
738
  shiftKey: v.shiftKey,
736
739
  metaKey: v.metaKey
737
- }, S = p.current;
740
+ }, S = l.current;
738
741
  if (S && Object.entries(b).some(
739
742
  ([C, P]) => S.keys[C] !== P
740
743
  )) {
741
744
  const C = { ...S, keys: b };
742
- p.current = C, M.sync_move.dispatchEvent(l, C);
745
+ l.current = C, M.sync_move.dispatchEvent(u, C);
743
746
  }
744
- const E = d.current;
747
+ const E = h.current;
745
748
  if (E && Object.entries(b).some(
746
749
  ([C, P]) => E.keys[C] !== P
747
750
  )) {
748
751
  v.stopPropagation(), v.preventDefault();
749
752
  const C = { ...E, keys: b };
750
- d.current = C, M.spanselect.dispatchEvent(a, C);
753
+ h.current = C, M.spanselect.dispatchEvent(a, C);
751
754
  }
752
755
  }, w = (v) => {
753
756
  y.current(
@@ -755,19 +758,19 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
755
758
  (b, { cssX: S, cssY: E }, C) => {
756
759
  const P = m.current;
757
760
  if (!P || !b.x || !b.y) return;
758
- const k = i.current, B = P.xRangeCss.start, ie = S, ce = P.yRangeCss.start, ae = E, le = X(k, b.x.scaleId), ue = X(k, b.y.scaleId);
761
+ const k = i.current, z = P.xRangeCss.start, ie = S, ce = P.yRangeCss.start, ae = E, le = X(k, b.x.scaleId), ue = X(k, b.y.scaleId);
759
762
  m.current = {
760
- xRangeCss: { start: B, end: ie },
763
+ xRangeCss: { start: z, end: ie },
761
764
  yRangeCss: { start: ce, end: ae }
762
765
  };
763
766
  let W = "below_threshold";
764
- const he = Math.abs(ce - ae), de = Math.abs(B - ie);
767
+ const he = Math.abs(ce - ae), de = Math.abs(z - ie);
765
768
  he < 10 && de < 10 ? W = "below_threshold" : he > 30 && de > 30 ? W = "box" : he > de ? W = "y" : W = "x";
766
769
  const Te = {
767
770
  scaleId: le.id,
768
771
  from: _(
769
772
  k,
770
- V(i.current, B, "css"),
773
+ V(i.current, z, "css"),
771
774
  le.id,
772
775
  "css"
773
776
  ),
@@ -791,27 +794,27 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
791
794
  ue.id,
792
795
  "css"
793
796
  )
794
- }, J = Te && Pe("x", Te, i.current), Q = Se && Pe("y", Se, i.current), _e = J?.scaled, Xe = Q?.scaled, Ce = {
797
+ }, Q = Te && Pe("x", Te, i.current), ee = Se && Pe("y", Se, i.current), _e = Q?.scaled, Xe = ee?.scaled, Ce = {
795
798
  mode: W,
796
799
  frame: i.current,
797
800
  completed: !1,
798
801
  x: {
799
- css: J && {
800
- from: J.fromCSS,
801
- to: J.toCSS
802
+ css: Q && {
803
+ from: Q.fromCSS,
804
+ to: Q.toCSS
802
805
  },
803
806
  scaled: _e ?? []
804
807
  },
805
808
  y: {
806
- css: Q && {
807
- from: Q.fromCSS,
808
- to: Q.toCSS
809
+ css: ee && {
810
+ from: ee.fromCSS,
811
+ to: ee.toCSS
809
812
  },
810
813
  scaled: Xe ?? []
811
814
  },
812
815
  keys: C
813
816
  };
814
- d.current = Ce, M.spanselect.dispatchEvent(
817
+ h.current = Ce, M.spanselect.dispatchEvent(
815
818
  a,
816
819
  Ce
817
820
  );
@@ -839,18 +842,18 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
839
842
  });
840
843
  };
841
844
  document.addEventListener("mouseup", f), document.addEventListener("keydown", g), document.addEventListener("keyup", g), document.addEventListener("mousemove", w);
842
- const x = r.current;
845
+ const x = c.current;
843
846
  return x?.addEventListener("wheel", T, {
844
847
  passive: !1
845
848
  }), () => {
846
849
  document.removeEventListener("mouseup", f), document.removeEventListener("keydown", g), document.removeEventListener("keyup", g), document.removeEventListener("mousemove", w), x?.removeEventListener("wheel", T);
847
850
  };
848
- }, [i, a, l, y]), L("sync_move", l, (f) => {
851
+ }, [i, a, u, y]), L("sync_move", u, (f) => {
849
852
  const g = f.positions ? N(
850
853
  f.positions,
851
854
  i.current
852
855
  ) : null;
853
- p.current = f, M.move.dispatchEvent(a, {
856
+ l.current = f, M.move.dispatchEvent(a, {
854
857
  frame: i.current,
855
858
  pointer: g ?? null,
856
859
  keys: f.keys,
@@ -859,15 +862,15 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
859
862
  }), /* @__PURE__ */ R(
860
863
  "div",
861
864
  {
862
- ref: r,
865
+ ref: c,
863
866
  id: e,
864
867
  className: t,
865
868
  style: {
866
869
  position: "absolute",
867
- left: c.chartAreaCSS.x,
868
- top: c.chartAreaCSS.y,
869
- width: c.chartAreaCSS.width,
870
- height: c.chartAreaCSS.height,
870
+ left: r.chartAreaCSS.x,
871
+ top: r.chartAreaCSS.y,
872
+ width: r.chartAreaCSS.width,
873
+ height: r.chartAreaCSS.height,
871
874
  zIndex: 25,
872
875
  ...n
873
876
  },
@@ -875,7 +878,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
875
878
  f.preventDefault();
876
879
  },
877
880
  onClick: (f) => {
878
- h(f, (g, w, T) => {
881
+ d(f, (g, w, T) => {
879
882
  const x = N(
880
883
  g,
881
884
  i.current
@@ -888,8 +891,8 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
888
891
  });
889
892
  },
890
893
  onMouseLeave: (f) => {
891
- h(f, (g, w, T) => {
892
- M.sync_move.dispatchEvent(l, {
894
+ d(f, (g, w, T) => {
895
+ M.sync_move.dispatchEvent(u, {
893
896
  positions: null,
894
897
  keys: T,
895
898
  originInteractionsId: a
@@ -897,8 +900,8 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
897
900
  });
898
901
  },
899
902
  onMouseMove: (f) => {
900
- h(f, (g, w, T) => {
901
- M.sync_move.dispatchEvent(l, {
903
+ d(f, (g, w, T) => {
904
+ M.sync_move.dispatchEvent(u, {
902
905
  positions: g,
903
906
  keys: T,
904
907
  originInteractionsId: a
@@ -906,7 +909,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
906
909
  });
907
910
  },
908
911
  onMouseDown: (f) => {
909
- h(f, (g, { cssX: w, cssY: T }, x) => {
912
+ d(f, (g, { cssX: w, cssY: T }, x) => {
910
913
  const v = N(
911
914
  g,
912
915
  i.current
@@ -922,7 +925,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
922
925
  });
923
926
  },
924
927
  onMouseUp: (f) => {
925
- h(f, (g, w, T) => {
928
+ d(f, (g, w, T) => {
926
929
  const x = N(
927
930
  g,
928
931
  i.current
@@ -933,8 +936,8 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
933
936
  pointer: x,
934
937
  keys: T
935
938
  });
936
- const v = d.current;
937
- d.current = null;
939
+ const v = h.current;
940
+ h.current = null;
938
941
  const b = m.current;
939
942
  if (m.current = null, b && v) {
940
943
  const S = {
@@ -942,7 +945,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
942
945
  keys: T,
943
946
  completed: !0
944
947
  };
945
- d.current = null, M.spanselect.dispatchEvent(
948
+ h.current = null, M.spanselect.dispatchEvent(
946
949
  a,
947
950
  S
948
951
  );
@@ -950,7 +953,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
950
953
  });
951
954
  },
952
955
  onContextMenu: (f) => {
953
- f.preventDefault(), h(f, (g, w, T) => {
956
+ f.preventDefault(), d(f, (g, w, T) => {
954
957
  const x = N(
955
958
  g,
956
959
  i.current
@@ -963,7 +966,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
963
966
  });
964
967
  },
965
968
  onDoubleClick: (f) => {
966
- h(f, (g, w, T) => {
969
+ d(f, (g, w, T) => {
967
970
  const x = N(
968
971
  g,
969
972
  i.current
@@ -979,50 +982,50 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
979
982
  }
980
983
  );
981
984
  }, Kt = ({ data: e, renderTooltip: t, xScaleId: n }) => {
982
- const [s, o] = z(null);
983
- xe("move", (c) => {
984
- o(c);
985
+ const [s, o] = B(null);
986
+ xe("move", (r) => {
987
+ o(r);
985
988
  });
986
- const r = oe(() => {
989
+ const c = J(() => {
987
990
  if (!s)
988
991
  return null;
989
- const { frame: c, pointer: i } = s, a = i?.scaled[n];
992
+ const { frame: r, pointer: i } = s, a = i?.scaled[n];
990
993
  if (a === void 0)
991
994
  return null;
992
- const l = [];
995
+ const u = [];
993
996
  let m = a;
994
- for (const d of e) {
995
- let p = null, u = 1 / 0;
996
- for (const [y, f] of d.points.entries()) {
997
- if (!fe(c, f.x, n) || !fe(c, f.y, d.yScaleId))
997
+ for (const h of e) {
998
+ let l = null, p = 1 / 0;
999
+ for (const [y, f] of h.points.entries()) {
1000
+ if (!fe(r, f.x, n) || !fe(r, f.y, h.yScaleId))
998
1001
  continue;
999
1002
  const g = Math.abs(f.x - a);
1000
- g < u && (u = g, p = y);
1003
+ g < p && (p = g, l = y);
1001
1004
  }
1002
- const h = d.points[p ?? -1];
1003
- if (!h || ge(c, u, n, "css") > 30) {
1004
- l.push({ seriesId: d.seriesId, y: null });
1005
+ const d = h.points[l ?? -1];
1006
+ if (!d || ge(r, p, n, "css") > 30) {
1007
+ u.push({ seriesId: h.seriesId, y: null });
1005
1008
  continue;
1006
1009
  }
1007
- m = h.x, l.push({
1008
- seriesId: d.seriesId,
1009
- y: h.y
1010
+ m = d.x, u.push({
1011
+ seriesId: h.seriesId,
1012
+ y: d.y
1010
1013
  });
1011
1014
  }
1012
1015
  return {
1013
- frame: c,
1016
+ frame: r,
1014
1017
  x: m,
1015
- points: l
1018
+ points: u
1016
1019
  };
1017
1020
  }, [e, s, n]);
1018
- return t(r);
1021
+ return t(c);
1019
1022
  }, Ft = ({ makeXStyle: e, makeXClassName: t, makeYStyle: n, makeYClassName: s }) => {
1020
- const [o, r] = z(null);
1021
- if (xe("move", (p) => {
1022
- r(p);
1023
+ const [o, c] = B(null);
1024
+ if (xe("move", (l) => {
1025
+ c(l);
1023
1026
  }), !o)
1024
1027
  return null;
1025
- const { frame: c, pointer: i } = o, a = i?.cssX ?? null, l = i?.cssY ?? null, m = a ? V(c, a, "css") : 0, d = l ? H(c, l, "css") : 0;
1028
+ const { frame: r, pointer: i } = o, a = i?.cssX ?? null, u = i?.cssY ?? null, m = a ? V(r, a, "css") : 0, h = u ? H(r, u, "css") : 0;
1026
1029
  return /* @__PURE__ */ pe(Fe, { children: [
1027
1030
  /* @__PURE__ */ R(
1028
1031
  "div",
@@ -1033,8 +1036,8 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
1033
1036
  position: "absolute",
1034
1037
  left: 0,
1035
1038
  visibility: a === null ? "hidden" : "visible",
1036
- top: c.chartAreaCSS.y,
1037
- height: c.chartAreaCSS.height,
1039
+ top: r.chartAreaCSS.y,
1040
+ height: r.chartAreaCSS.height,
1038
1041
  borderColor: "red",
1039
1042
  borderLeftWidth: "1px",
1040
1043
  borderLeftStyle: "solid",
@@ -1052,32 +1055,32 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
1052
1055
  "data-show": !!i,
1053
1056
  style: {
1054
1057
  position: "absolute",
1055
- visibility: l === null ? "hidden" : "visible",
1058
+ visibility: u === null ? "hidden" : "visible",
1056
1059
  top: 0,
1057
1060
  height: 0,
1058
1061
  borderTop: "solid 1px red",
1059
- left: c.chartAreaCSS.x,
1060
- width: c.chartAreaCSS.width,
1062
+ left: r.chartAreaCSS.x,
1063
+ width: r.chartAreaCSS.width,
1061
1064
  pointerEvents: "none",
1062
1065
  opacity: i ? 1 : 0,
1063
- transform: `translateY(${d}px)`,
1066
+ transform: `translateY(${h}px)`,
1064
1067
  ...n?.(o)
1065
1068
  }
1066
1069
  }
1067
1070
  )
1068
1071
  ] });
1069
1072
  }, Yt = ({ makeClassName: e, makeStyle: t }) => {
1070
- const [n, s] = z(null);
1071
- xe("spanselect", (r) => {
1073
+ const [n, s] = B(null);
1074
+ xe("spanselect", (c) => {
1072
1075
  s(
1073
- r.mode === "below_threshold" || r.completed ? null : r
1076
+ c.mode === "below_threshold" || c.completed ? null : c
1074
1077
  );
1075
1078
  });
1076
- const o = oe(() => {
1079
+ const o = J(() => {
1077
1080
  if (!n || n.mode === "below_threshold")
1078
1081
  return null;
1079
- const r = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, c = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, i = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, a = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, l = V(n.frame, r, "css"), m = V(n.frame, c, "css"), d = H(n.frame, i, "css"), p = H(n.frame, a, "css"), u = Math.min(l, m), h = Math.min(d, p), y = Math.abs(m - l), f = Math.abs(p - d);
1080
- return { leftPx: u, topPx: h, widthPx: y, heightPx: f };
1082
+ const c = n.mode === "y" ? -1 / 0 : n.x.css?.from ?? -1 / 0, r = n.mode === "y" ? 1 / 0 : n.x.css?.to ?? 1 / 0, i = n.mode === "x" ? -1 / 0 : n.y.css?.from ?? -1 / 0, a = n.mode === "x" ? 1 / 0 : n.y.css?.to ?? 1 / 0, u = V(n.frame, c, "css"), m = V(n.frame, r, "css"), h = H(n.frame, i, "css"), l = H(n.frame, a, "css"), p = Math.min(u, m), d = Math.min(h, l), y = Math.abs(m - u), f = Math.abs(l - h);
1083
+ return { leftPx: p, topPx: d, widthPx: y, heightPx: f };
1081
1084
  }, [n]);
1082
1085
  return /* @__PURE__ */ R(
1083
1086
  "div",
@@ -1095,7 +1098,7 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
1095
1098
  }
1096
1099
  }
1097
1100
  );
1098
- }, zt = ({ style: e, children: t, scaleId: n, ...s }) => {
1101
+ }, Bt = ({ style: e, children: t, scaleId: n, ...s }) => {
1099
1102
  const o = De().getScale(n)?.axis;
1100
1103
  return o ? /* @__PURE__ */ R(
1101
1104
  "div",
@@ -1113,32 +1116,32 @@ const At = ze(({ configuration: e, children: t, style: n, className: s }, o) =>
1113
1116
  children: t
1114
1117
  }
1115
1118
  ) : null;
1116
- }, Ie = 60, lt = 30, Le = "UTC", ut = "en-GB", Bt = ({
1119
+ }, Ie = 60, lt = 30, Le = "UTC", ut = "en-GB", zt = ({
1117
1120
  space: e,
1118
1121
  formatter: t,
1119
1122
  acceptableIncrements: n
1120
1123
  } = {}) => (s, o) => {
1121
- const { min: r, max: c } = s, i = [], a = window.devicePixelRatio || 1, l = (e ?? (s.origin === "x" ? Ie : lt)) * a, m = je(
1124
+ const { min: c, max: r } = s, i = [], a = window.devicePixelRatio || 1, u = (e ?? (s.origin === "x" ? Ie : lt)) * a, m = je(
1122
1125
  o,
1123
- l,
1126
+ u,
1124
1127
  s.id,
1125
1128
  "canvas"
1126
- ), d = n ?? ee, p = d.find((h) => h > m) ?? d.at(-1) ?? 1;
1127
- let u = r;
1128
- if (Math.abs(u % p) > Number.EPSILON) {
1129
- const h = (p - u % p) % p;
1130
- u += h;
1129
+ ), h = n ?? te, l = h.find((d) => d > m) ?? h.at(-1) ?? 1;
1130
+ let p = c;
1131
+ if (Math.abs(p % l) > Number.EPSILON) {
1132
+ const d = (l - p % l) % l;
1133
+ p += d;
1131
1134
  }
1132
- for (; u <= c && i.length < 1e3; )
1133
- i.push(u), u += p;
1135
+ for (; p <= r && i.length < 1e3; )
1136
+ i.push(p), p += l;
1134
1137
  return (t ?? ht)(i);
1135
1138
  }, ht = (e) => {
1136
1139
  const t = Math.max(0, Math.ceil(-Math.log10(e[1] - e[0])));
1137
1140
  return e.map((n) => ({ value: n, label: n.toFixed(t) }));
1138
- }, ee = [];
1141
+ }, te = [];
1139
1142
  for (let e = -12; e <= 12; e++)
1140
- ee.push(1 * 10 ** e), ee.push(2 * 10 ** e), ee.push(5 * 10 ** e);
1141
- const dt = 1, Ue = 1e3 * dt, be = 60 * Ue, se = 60 * be, re = 24 * se, ft = 30 * re, mt = 365 * re, pt = [
1143
+ te.push(1 * 10 ** e), te.push(2 * 10 ** e), te.push(5 * 10 ** e);
1144
+ const dt = 1, Ue = 1e3 * dt, be = 60 * Ue, oe = 60 * be, re = 24 * oe, ft = 30 * re, mt = 365 * re, pt = [
1142
1145
  // second divisors
1143
1146
  [1, "milliseconds"],
1144
1147
  [2, "milliseconds"],
@@ -1190,7 +1193,7 @@ const dt = 1, Ue = 1e3 * dt, be = 60 * Ue, se = 60 * be, re = 24 * se, ft = 30 *
1190
1193
  [25, "years"],
1191
1194
  [50, "years"],
1192
1195
  [100, "years"]
1193
- ], te = (e) => {
1196
+ ], ne = (e) => {
1194
1197
  const [t, n] = e;
1195
1198
  switch (n) {
1196
1199
  case "milliseconds":
@@ -1200,7 +1203,7 @@ const dt = 1, Ue = 1e3 * dt, be = 60 * Ue, se = 60 * be, re = 24 * se, ft = 30 *
1200
1203
  case "minutes":
1201
1204
  return t * be;
1202
1205
  case "hours":
1203
- return t * se;
1206
+ return t * oe;
1204
1207
  case "days":
1205
1208
  return t * re;
1206
1209
  case "months":
@@ -1245,38 +1248,38 @@ const dt = 1, Ue = 1e3 * dt, be = 60 * Ue, se = 60 * be, re = 24 * se, ft = 30 *
1245
1248
  return Me(e, n * 12);
1246
1249
  }
1247
1250
  };
1248
- function ne(e, t) {
1251
+ function se(e, t) {
1249
1252
  const n = new Date(e), s = new Date(n.toLocaleString("en-US", { timeZone: t })), o = new Date(n.toLocaleString("en-US", { timeZone: "UTC" }));
1250
1253
  return (s.getTime() - o.getTime()) / (3600 * 1e3);
1251
1254
  }
1252
1255
  const bt = (e, t, n = "UTC") => {
1253
1256
  const [s, o] = t;
1254
- let r = new Date(e);
1255
- const c = () => {
1256
- r.setUTCHours(-ne(r, n), 0, 0, 0);
1257
+ let c = new Date(e);
1258
+ const r = () => {
1259
+ c.setUTCHours(-se(c, n), 0, 0, 0);
1257
1260
  };
1258
1261
  switch (o) {
1259
1262
  case "milliseconds":
1260
- r.setUTCMilliseconds(
1261
- Math.ceil(r.getUTCMilliseconds() / s) * s
1263
+ c.setUTCMilliseconds(
1264
+ Math.ceil(c.getUTCMilliseconds() / s) * s
1262
1265
  );
1263
1266
  break;
1264
1267
  case "seconds":
1265
- r.setUTCSeconds(
1266
- Math.ceil(r.getUTCSeconds() / s) * s,
1268
+ c.setUTCSeconds(
1269
+ Math.ceil(c.getUTCSeconds() / s) * s,
1267
1270
  0
1268
1271
  );
1269
1272
  break;
1270
1273
  case "minutes":
1271
- r.setUTCMinutes(
1272
- Math.ceil(r.getTime() % se / be / s) * s,
1274
+ c.setUTCMinutes(
1275
+ Math.ceil(c.getTime() % oe / be / s) * s,
1273
1276
  0,
1274
1277
  0
1275
1278
  );
1276
1279
  break;
1277
1280
  case "hours":
1278
- r.setUTCHours(
1279
- Math.ceil(r.getTime() % re / se / s) * s,
1281
+ c.setUTCHours(
1282
+ Math.ceil(c.getTime() % re / oe / s) * s,
1280
1283
  0,
1281
1284
  0,
1282
1285
  0
@@ -1285,37 +1288,37 @@ const bt = (e, t, n = "UTC") => {
1285
1288
  case "days":
1286
1289
  case "months":
1287
1290
  case "years":
1288
- o === "months" ? r.setUTCDate(1) : o === "years" && r.setUTCMonth(0, 1), c(), r.getTime() < e && (r = new Date(Y(r, [1, o])));
1291
+ o === "months" ? c.setUTCDate(1) : o === "years" && c.setUTCMonth(0, 1), r(), c.getTime() < e && (c = new Date(Y(c, [1, o])));
1289
1292
  break;
1290
1293
  }
1291
- return r.getTime();
1294
+ return c.getTime();
1292
1295
  }, Nt = ({
1293
1296
  timeZone: e = Le,
1294
1297
  space: t = Ie,
1295
1298
  formatter: n,
1296
1299
  locale: s,
1297
1300
  showTimezone: o
1298
- } = {}) => (r, c) => {
1299
- const { min: i, max: a } = r, l = Math.floor(c.chartAreaCanvasPX.width / t) + 1, d = (a - i) / l, [p, u] = pt.find(
1300
- (w) => te(w) >= d
1301
- ) ?? [1, "milliseconds"], h = bt(i, [p, u], e), y = ne(h, e), f = [h];
1301
+ } = {}) => (c, r) => {
1302
+ const { min: i, max: a } = c, u = Math.floor(r.chartAreaCanvasPX.width / t) + 1, h = (a - i) / u, [l, p] = pt.find(
1303
+ (w) => ne(w) >= h
1304
+ ) ?? [1, "milliseconds"], d = bt(i, [l, p], e), y = se(d, e), f = [d];
1302
1305
  let g;
1303
1306
  for (; ; ) {
1304
- switch (u) {
1307
+ switch (p) {
1305
1308
  case "milliseconds":
1306
1309
  case "seconds":
1307
1310
  case "minutes":
1308
1311
  case "hours": {
1309
- g = Y(h, [f.length * p, u]);
1312
+ g = Y(d, [f.length * l, p]);
1310
1313
  break;
1311
1314
  }
1312
1315
  case "days": {
1313
- const w = Y(h, [
1314
- f.length * p,
1315
- u
1316
+ const w = Y(d, [
1317
+ f.length * l,
1318
+ p
1316
1319
  ]);
1317
1320
  g = Y(w, [
1318
- y - ne(w, e),
1321
+ y - se(w, e),
1319
1322
  "hours"
1320
1323
  ]);
1321
1324
  break;
@@ -1323,14 +1326,14 @@ const bt = (e, t, n = "UTC") => {
1323
1326
  case "months":
1324
1327
  case "years": {
1325
1328
  const w = Y(
1326
- Y(Y(h, [y, "hours"]), [
1327
- f.length * p,
1328
- u
1329
+ Y(Y(d, [y, "hours"]), [
1330
+ f.length * l,
1331
+ p
1329
1332
  ]),
1330
1333
  [-y, "hours"]
1331
1334
  );
1332
1335
  g = Y(w, [
1333
- y - ne(w, e),
1336
+ y - se(w, e),
1334
1337
  "hours"
1335
1338
  ]);
1336
1339
  break;
@@ -1363,15 +1366,15 @@ const bt = (e, t, n = "UTC") => {
1363
1366
  timeZone: e
1364
1367
  });
1365
1368
  return (o) => {
1366
- const r = o[1] - o[0], c = r < te([1, "days"]), i = r < te([1, "minutes"]), a = r < te([1, "seconds"]);
1367
- return o.map((l) => ({ value: l, label: s.formatToParts(new Date(l)) })).map((l, m, d) => {
1368
- const p = d[m - 1], u = m === 0 || F(l.label, p.label, "year"), h = m === 0 || F(l.label, p.label, "day"), y = m === 0 || F(l.label, p.label, "month"), f = m === 0 || F(l.label, p.label, "hour"), g = m === 0 || F(l.label, p.label, "timeZoneName"), w = m === 0 || F(l.label, p.label, "minute"), T = m === 0 || F(l.label, p.label, "second"), x = m === 0 || F(l.label, p.label, "fractionalSecond"), v = [];
1369
- if (c && (f || w || g || T || x)) {
1370
- const b = l.label.find((P) => P.type === "hour")?.value, S = l.label.find((P) => P.type === "minute")?.value, E = l.label.find((P) => P.type === "timeZoneName")?.value;
1369
+ const c = o[1] - o[0], r = c < ne([1, "days"]), i = c < ne([1, "minutes"]), a = c < ne([1, "seconds"]);
1370
+ return o.map((u) => ({ value: u, label: s.formatToParts(new Date(u)) })).map((u, m, h) => {
1371
+ const l = h[m - 1], p = m === 0 || F(u.label, l.label, "year"), d = m === 0 || F(u.label, l.label, "day"), y = m === 0 || F(u.label, l.label, "month"), f = m === 0 || F(u.label, l.label, "hour"), g = m === 0 || F(u.label, l.label, "timeZoneName"), w = m === 0 || F(u.label, l.label, "minute"), T = m === 0 || F(u.label, l.label, "second"), x = m === 0 || F(u.label, l.label, "fractionalSecond"), v = [];
1372
+ if (r && (f || w || g || T || x)) {
1373
+ const b = u.label.find((P) => P.type === "hour")?.value, S = u.label.find((P) => P.type === "minute")?.value, E = u.label.find((P) => P.type === "timeZoneName")?.value;
1371
1374
  let C = "";
1372
1375
  if (i) {
1373
- const P = l.label.find((B) => B.type === "second")?.value, k = l.label.find(
1374
- (B) => B.type === "fractionalSecond"
1376
+ const P = u.label.find((z) => z.type === "second")?.value, k = u.label.find(
1377
+ (z) => z.type === "fractionalSecond"
1375
1378
  )?.value;
1376
1379
  C = `:${P}` + (a ? `.${k}` : "");
1377
1380
  }
@@ -1379,13 +1382,13 @@ const bt = (e, t, n = "UTC") => {
1379
1382
  `${b}:${S}${C}` + (n && g ? ` ${E}` : "")
1380
1383
  );
1381
1384
  }
1382
- return (h || y) && v.push(
1385
+ return (d || y) && v.push(
1383
1386
  [
1384
- l.label.find((b) => b.type === "month")?.value,
1385
- h && l.label.find((b) => b.type === "day")?.value
1387
+ u.label.find((b) => b.type === "month")?.value,
1388
+ d && u.label.find((b) => b.type === "day")?.value
1386
1389
  ].filter(Boolean).join(" ")
1387
- ), u && v.push(l.label.find((b) => b.type === "year")?.value), {
1388
- value: l.value,
1390
+ ), p && v.push(u.label.find((b) => b.type === "year")?.value), {
1391
+ value: u.value,
1389
1392
  label: v.filter((b) => b).join(`
1390
1393
  `)
1391
1394
  };
@@ -1394,7 +1397,7 @@ const bt = (e, t, n = "UTC") => {
1394
1397
  };
1395
1398
  export {
1396
1399
  Lt as AreaPlot,
1397
- zt as AxisOverlay,
1400
+ Bt as AxisOverlay,
1398
1401
  It as BarPlot,
1399
1402
  Ae as CANPLOT_LAYER,
1400
1403
  At as CanPlot,
@@ -1417,7 +1420,7 @@ export {
1417
1420
  ht as defaultNumericalTicksFormatter,
1418
1421
  Et as findClosestIndex,
1419
1422
  X as getScale,
1420
- Bt as makeLinearTicks,
1423
+ zt as makeLinearTicks,
1421
1424
  Tt as makeTimeTickFormat,
1422
1425
  Nt as makeTimeTicks,
1423
1426
  _ as posToVal,