@canplot/react 0.1.22 → 0.1.24

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