@canplot/react 0.1.22 → 0.1.23

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,13 +1,13 @@
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 Ct, jsx as k, 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);
9
+ }, Ft = (n, e, t, s) => {
10
+ const { min: o, max: i, origin: r } = I(n, t), l = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, h = (r === "x" ? l.width : l.height) / (i - o);
11
11
  return e / h;
12
12
  }, I = (n, e) => {
13
13
  const t = n.scales.find((s) => s.id === e);
@@ -18,20 +18,20 @@ const j = (n, e, t) => Math.min(Math.max(n, e), t), fe = (n) => n.reduce((e, t)
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
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);
21
+ const o = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, { min: i, max: r, origin: l } = I(n, t), h = (l === "x" ? o.width : o.height) / (r - i);
22
22
  return e * h;
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 = ft(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;
47
+ const { min: o, max: i, origin: r } = I(n, t), l = s === "canvas" ? n.chartAreaCanvasPX : n.chartAreaCSS, h = r === "x" ? (e - l.x) / l.width : (l.height - e + l.y) / l.height;
48
48
  return o + h * (i - o);
49
- }, Ft = (n) => {
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");
@@ -94,7 +94,7 @@ const j = (n, e, t) => Math.min(Math.max(n, e), t), fe = (n) => n.reduce((e, t)
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
+ })), mt = Mt(null), Rt = Mt(null), F = (n, e, t) => {
115
+ const s = tt(mt), 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
129
  }, pt = (n) => {
130
130
  const e = tt(mt);
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), h = et(Yt, []), u = et(Bt, []);
163
163
  z(() => {
164
164
  h.setState({
165
- _frame: Ht(n, d, i.current)
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 = h.getState();
168
+ a._notifyListeners(a);
169
+ }, [n, l, i, h]), z(() => h.getState()._subscribe((a) => {
170
+ const m = a._frame?.ctx;
171
+ m && m.clearRect(0, 0, m.canvas.width, m.canvas.height);
172
+ }, dt.BACKGROUND), [h]), z(() => h.getState()._subscribe((a) => {
173
+ a._frame && zt(a._frame);
174
+ }, dt.BOTTOM), [h]), 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, h.setState((c) => ({
179
+ _frame: c._frame ? { ...c._frame } : null
180
180
  }));
181
- const f = h.getState();
182
- f._notifyListeners(f);
181
+ const m = h.getState();
182
+ m._notifyListeners(m);
183
183
  }));
184
184
  });
185
185
  }, [u, h]);
186
- const m = window.devicePixelRatio || 1;
187
- return /* @__PURE__ */ ht(
186
+ const f = window.devicePixelRatio || 1;
187
+ return /* @__PURE__ */ Ct(
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",
@@ -196,22 +196,22 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
196
196
  },
197
197
  "data-canplotroot": !0,
198
198
  children: [
199
- /* @__PURE__ */ A(
199
+ /* @__PURE__ */ k(
200
200
  "canvas",
201
201
  {
202
202
  ref: i,
203
- width: d.width * m,
204
- height: d.height * m,
203
+ width: l.width * f,
204
+ height: l.height * f,
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
- /* @__PURE__ */ A(
214
- Vt,
213
+ /* @__PURE__ */ k(
214
+ jt,
215
215
  {
216
216
  frameStore: h,
217
217
  updateRequestStore: u,
@@ -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__ */ k(Rt.Provider, { value: e, children: /* @__PURE__ */ k(mt.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
+ (h) => h.width !== r || h.height !== l ? { ...h, width: r, height: l } : h
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 h = n.padding.left * o, u = s.canvas.width - n.padding.right * o, f = 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 p;
273
+ if (c.origin === "x")
274
+ switch (c.axis.position) {
275
275
  case "bottom":
276
- m -= a.axis.size * o, l = {
276
+ f -= c.axis.size * o, p = {
277
277
  x: i.x,
278
- y: m / o,
278
+ y: f / 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, p = {
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
+ h += c.axis.size * o, p = {
299
+ x: h / 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, p = {
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 d = {
318
+ x: p.x * o,
319
+ y: p.y * o,
320
+ width: p.width * o,
321
+ height: p.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: p,
328
+ canvasRect: d
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: h }) => {
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 f of e) {
346
+ const a = r(h(f.x, t)), m = l(h(f.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: h, valFits: u }) => {
355
+ const f = l();
356
+ f.save(), f.beginPath();
357
+ const a = new Path2D();
358
+ D(f, i), r !== void 0 && (f.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 = h(m.x, t), p = h(m.y, s);
363
+ a.moveTo(c + o, p), a.arc(c, p, o, 0, Math.PI * 2);
364
364
  }
365
- m.fill(c), m.stroke(c), m.restore();
365
+ f.fill(a), f.stroke(a), f.restore();
366
366
  },
367
367
  [e, t, s, o, i, r]
368
- ), null), ge = ({
368
+ ), null), be = ({
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
380
  getCtx: h,
381
381
  valToPxDistance: u,
382
- valToPos: m,
383
- clampXPosToChartArea: c,
384
- clampYPosToChartArea: f
382
+ valToPos: f,
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(
394
- S,
395
- y,
387
+ const c = h();
388
+ c.save(), D(c, s);
389
+ const p = u(o, e);
390
+ c.beginPath();
391
+ for (const d of n) {
392
+ const v = f(d.x, e) - p / 2 + i * p, g = m(f(0, t)), S = m(f(d.y, t)), y = g - S, b = a(v), w = a(v + p) - b;
393
+ r ? c.roundRect(
396
394
  b,
395
+ S,
397
396
  w,
397
+ y,
398
398
  r
399
- ) : a.rect(S, y, b, w);
399
+ ) : c.rect(b, S, w, 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
404
  ), null), we = ({ 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: h }) => {
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(h(a.x, t)), c = l(h(a.y[0], s)), p = l(h(a.y[1], s));
410
+ u.push({ x: m, y: c }), u.unshift({ x: m, y: p });
411
411
  }
412
- const m = i();
412
+ const f = 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
+ f.save(), f.beginPath(), D(f, o), f.moveTo(u[0].x, u[0].y);
415
+ for (const a of u)
416
+ f.lineTo(a.x, a.y);
417
+ f.closePath(), f.fill(), f.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: h, valToPos: u }) => {
424
+ const f = [], a = r();
425
+ for (const d of e) {
426
+ const x = l(u(d.x, s)), v = h(u(d.y, o));
427
+ f.push({ x, y: v });
428
428
  }
429
- const f = m.at(0), a = m.at(-1);
430
- if (!f || !a)
429
+ const m = f.at(0), c = f.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 p = h(u(0, o));
433
+ a.save(), a.beginPath(), D(a, i), a.moveTo(m.x, p);
434
+ for (const d of f)
435
+ a.lineTo(d.x, d.y);
436
+ if (a.lineTo(c.x, p), a.closePath(), a.fill(), t) {
437
+ a.beginPath(), a.moveTo(m.x, m.y);
438
+ for (const d of f)
439
+ a.lineTo(d.x, d.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) => pt(
446
446
  ({
447
447
  clampXPosToChartArea: t,
448
448
  clampYPosToChartArea: s,
@@ -450,82 +450,82 @@ 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 = {};
453
+ const l = {};
454
454
  for (const h in n) {
455
455
  const u = n[h];
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 f = i(u.value, u.scaleId, e);
460
+ l[h] = f;
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 f = i(u.value, u.scaleId, e);
466
+ l[h] = o(u.scaleId)?.origin === "x" ? t(f, e) : s(f, 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: h, getScale: u, getFrame: f }) => {
476
+ const a = l(), m = u(e);
477
+ if (!m || !m.axis || m.origin !== "x") return;
478
+ const c = m.axis, p = c.position === "top" ? c.canvasRect.y + c.canvasRect.height : c.canvasRect.y, d = window.devicePixelRatio || 1, x = p, v = (i ?? 6) * d, g = c.position === "top" ? p - v : p + v, S = (o ?? 12) * d;
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 }, f());
483
+ for (const { value: b } of y) {
484
+ const w = h(b, e, "canvas");
485
+ a.moveTo(w, x), a.lineTo(w, 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: b, label: w } of y) {
494
+ const P = h(b, e, "canvas"), T = w.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 + d * 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: h, getScale: u, getFrame: f }) => {
505
+ const a = l(), m = u(e);
506
+ if (!m || !m.axis || m.origin !== "y") return;
507
+ const c = m.axis, p = c.position === "left" ? c.canvasRect.x + c.canvasRect.width : c.canvasRect.x, d = p, x = i ?? 6, v = c.position === "left" ? p - x : p + x, g = o ?? 12, S = Array.isArray(r) ? r : r({ ...m, axis: c }, f());
508
+ a.save(), a.fontKerning = "auto", D(a, { ...t }), a.beginPath();
509
+ for (const { value: y } of S) {
510
+ const b = h(y, e, "canvas");
511
+ a.moveTo(d, b), a.lineTo(v, b);
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: b } of S) {
520
+ const w = h(y, e, "canvas"), P = b.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, w + T * g);
524
524
  }
525
- c.restore();
525
+ a.restore();
526
526
  },
527
527
  [r, e, t, s]
528
- ), null), k = () => {
528
+ ), null), R = () => {
529
529
  const n = [];
530
530
  return {
531
531
  addEventListener: (e, t) => (n.push({
@@ -541,17 +541,17 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
541
541
  }
542
542
  };
543
543
  }, E = {
544
- dblclick: k(),
545
- click: k(),
546
- contextmenu: k(),
547
- move: k(),
548
- mousedown: k(),
549
- mouseup: k(),
550
- spanselect: k(),
551
- documentmouseup: k(),
552
- pressandwheel: k(),
553
- sync_move: k()
554
- }, R = (n, e, t) => {
544
+ dblclick: R(),
545
+ click: R(),
546
+ contextmenu: R(),
547
+ move: R(),
548
+ mousedown: R(),
549
+ mouseup: R(),
550
+ spanselect: R(),
551
+ documentmouseup: R(),
552
+ pressandwheel: R(),
553
+ sync_move: R()
554
+ }, A = (n, e, t) => {
555
555
  const s = Q.useRef(t);
556
556
  s.current = t, Q.useEffect(() => E[n].addEventListener(
557
557
  e,
@@ -561,20 +561,20 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
561
561
  ), [e, n, s]);
562
562
  }, xt = Q.createContext(""), yt = (n, e) => {
563
563
  const t = Q.useContext(xt);
564
- return R(n, t, e);
565
- }, Wt = (n, e, t, s, o) => {
564
+ return A(n, t, e);
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, h = {
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, f = {
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: h, y: f }, 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,8 +582,8 @@ 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
  };
@@ -602,11 +602,11 @@ 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"), h = L(t, o, r.id, "css");
606
606
  return [
607
607
  {
608
608
  scaleId: r.id,
609
- from: d,
609
+ from: l,
610
610
  to: h
611
611
  }
612
612
  ];
@@ -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,80 +625,78 @@ 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,
628
+ onSpanSelect: l,
629
629
  onContextMenu: h,
630
630
  className: u,
631
- style: m,
632
- sync: c,
633
- children: f
631
+ style: f,
632
+ sync: a,
633
+ children: m
634
634
  }) => {
635
- const a = Kt(), l = n || a;
636
- return R("dblclick", l, (p) => {
637
- t?.(p);
638
- }), R("click", l, (p) => {
639
- e?.(p);
640
- }), R("move", l, (p) => {
641
- s?.(p);
642
- }), R("mousedown", l, (p) => {
643
- o?.(p);
644
- }), R("mouseup", l, (p) => {
645
- i?.(p);
646
- }), R("documentmouseup", l, (p) => {
647
- r?.(p);
648
- }), R("spanselect", l, (p) => {
649
- d?.(p);
650
- }), R("contextmenu", l, (p) => {
651
- h?.(p);
652
- }), /* @__PURE__ */ ht(xt.Provider, { value: l, children: [
653
- /* @__PURE__ */ A(
654
- qt,
655
- {
656
- className: u,
657
- style: m,
658
- sync: c
659
- }
660
- ),
661
- f
662
- ] });
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)
635
+ const c = Ot(), p = n || c;
636
+ return A("dblclick", p, (d) => {
637
+ t?.(d);
638
+ }), A("click", p, (d) => {
639
+ e?.(d);
640
+ }), A("move", p, (d) => {
641
+ s?.(d);
642
+ }), A("mousedown", p, (d) => {
643
+ o?.(d);
644
+ }), A("mouseup", p, (d) => {
645
+ i?.(d);
646
+ }), A("documentmouseup", p, (d) => {
647
+ r?.(d);
648
+ }), A("spanselect", p, (d) => {
649
+ l?.(d);
650
+ }), A("contextmenu", p, (d) => {
651
+ h?.(d);
652
+ }), /* @__PURE__ */ k(xt.Provider, { value: p, children: /* @__PURE__ */ k(
653
+ Gt,
654
+ {
655
+ className: u,
656
+ style: f,
657
+ sync: a,
658
+ children: m
659
+ }
660
+ ) });
661
+ }, Gt = ({ className: n, style: e, sync: t, children: s }) => {
662
+ const o = _(null), i = pt(), r = _(i);
663
+ r.current = i;
664
+ const l = tt(xt), h = t?.key || l, u = _(null), f = _(null), a = _(null), m = () => {
665
+ const d = o.current?.parentElement;
666
+ if (d) {
667
+ if (d.dataset.canplotroot === void 0)
670
668
  throw new Error(
671
669
  "ChartAreaInteractions must be used within a CanPlot component"
672
670
  );
673
- return l.getBoundingClientRect();
671
+ return d.getBoundingClientRect();
674
672
  }
675
- }, f = (l, p) => {
676
- const v = Wt(
677
- l,
678
- c(),
679
- i.current,
673
+ }, c = (d, x) => {
674
+ const v = qt(
675
+ d,
676
+ m(),
677
+ r.current,
680
678
  t?.xViaScaleId,
681
679
  t?.yViaScaleId
682
680
  );
683
- v && p(
681
+ v && x(
684
682
  v.pointerSyncPosition,
685
683
  { cssX: v.cssX, cssY: v.cssY },
686
684
  {
687
- ctrlKey: l.ctrlKey,
688
- altKey: l.altKey,
689
- shiftKey: l.shiftKey,
690
- metaKey: l.metaKey
685
+ ctrlKey: d.ctrlKey,
686
+ altKey: d.altKey,
687
+ shiftKey: d.shiftKey,
688
+ metaKey: d.metaKey
691
689
  }
692
690
  );
693
- }, a = _(f);
694
- return a.current = f, Mt(() => {
695
- const l = (y) => {
696
- const w = u.current;
697
- w && E.spanselect.dispatchEvent(r, {
698
- ...w,
691
+ }, p = _(c);
692
+ return p.current = c, Et(() => {
693
+ const d = (y) => {
694
+ const b = f.current;
695
+ b && E.spanselect.dispatchEvent(l, {
696
+ ...b,
699
697
  completed: !0
700
- }), E.documentmouseup.dispatchEvent(r, {
701
- frame: i.current,
698
+ }), E.documentmouseup.dispatchEvent(l, {
699
+ frame: r.current,
702
700
  keys: {
703
701
  ctrlKey: y.ctrlKey,
704
702
  altKey: y.altKey,
@@ -706,253 +704,254 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
706
704
  metaKey: y.metaKey
707
705
  }
708
706
  });
709
- }, p = (y) => {
710
- const w = {
707
+ }, x = (y) => {
708
+ const b = {
711
709
  ctrlKey: y.ctrlKey,
712
710
  altKey: y.altKey,
713
711
  shiftKey: y.shiftKey,
714
712
  metaKey: y.metaKey
715
- }, S = m.current;
716
- if (S && Object.entries(w).some(
717
- ([T, C]) => S.keys[T] !== C
713
+ }, w = a.current;
714
+ if (w && Object.entries(b).some(
715
+ ([T, M]) => w.keys[T] !== M
718
716
  )) {
719
- const T = { ...S, keys: w };
720
- m.current = T, E.sync_move.dispatchEvent(d, T);
717
+ const T = { ...w, keys: b };
718
+ a.current = T, E.sync_move.dispatchEvent(h, T);
721
719
  }
722
- const b = u.current;
723
- if (b && Object.entries(w).some(
724
- ([T, C]) => b.keys[T] !== C
720
+ const P = f.current;
721
+ if (P && Object.entries(b).some(
722
+ ([T, M]) => P.keys[T] !== M
725
723
  )) {
726
724
  y.stopPropagation(), y.preventDefault();
727
- const T = { ...b, keys: w };
728
- u.current = T, E.spanselect.dispatchEvent(r, T);
725
+ const T = { ...P, keys: b };
726
+ f.current = T, E.spanselect.dispatchEvent(l, T);
729
727
  }
730
728
  }, v = (y) => {
731
- a.current(
729
+ p.current(
732
730
  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 }
731
+ (b, { cssX: w, cssY: P }, T) => {
732
+ const M = u.current;
733
+ if (!M || !b.x || !b.y) return;
734
+ const C = r.current, N = M.xRangeCss.start, K = w, ot = M.yRangeCss.start, it = P, rt = I(C, b.x.scaleId), ct = I(C, b.y.scaleId);
735
+ u.current = {
736
+ xRangeCss: { start: N, end: K },
737
+ yRangeCss: { start: ot, end: it }
740
738
  };
741
739
  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";
740
+ const at = Math.abs(ot - it), lt = Math.abs(N - K);
741
+ at < 10 && lt < 10 ? $ = "below_threshold" : at > 30 && lt > 30 ? $ = "box" : at > lt ? $ = "y" : $ = "x";
744
742
  const gt = {
745
- scaleId: it.id,
743
+ scaleId: rt.id,
746
744
  from: L(
747
- M,
748
- Y(i.current, P, "css"),
749
- it.id,
745
+ C,
746
+ Y(r.current, N, "css"),
747
+ rt.id,
750
748
  "css"
751
749
  ),
752
750
  to: L(
753
- M,
754
- Y(i.current, N, "css"),
755
- it.id,
751
+ C,
752
+ Y(r.current, K, "css"),
753
+ rt.id,
756
754
  "css"
757
755
  )
758
- }, wt = {
759
- scaleId: rt.id,
756
+ }, bt = {
757
+ scaleId: ct.id,
760
758
  from: L(
761
- M,
762
- B(i.current, K, "css"),
763
- rt.id,
759
+ C,
760
+ B(r.current, ot, "css"),
761
+ ct.id,
764
762
  "css"
765
763
  ),
766
764
  to: L(
767
- M,
768
- B(i.current, ot, "css"),
769
- rt.id,
765
+ C,
766
+ B(r.current, it, "css"),
767
+ ct.id,
770
768
  "css"
771
769
  )
772
- }, W = gt && St("x", gt, i.current), q = wt && St("y", wt, i.current), _t = W?.scaled, Lt = q?.scaled, bt = {
770
+ }, W = gt && St("x", gt, r.current), q = bt && St("y", bt, r.current), Lt = W?.scaled, It = q?.scaled, wt = {
773
771
  mode: $,
774
- frame: i.current,
772
+ frame: r.current,
775
773
  completed: !1,
776
774
  x: {
777
775
  css: W && {
778
776
  from: W.fromCSS,
779
777
  to: W.toCSS
780
778
  },
781
- scaled: _t ?? []
779
+ scaled: Lt ?? []
782
780
  },
783
781
  y: {
784
782
  css: q && {
785
783
  from: q.fromCSS,
786
784
  to: q.toCSS
787
785
  },
788
- scaled: Lt ?? []
786
+ scaled: It ?? []
789
787
  },
790
788
  keys: T
791
789
  };
792
- u.current = bt, E.spanselect.dispatchEvent(
793
- r,
794
- bt
790
+ f.current = wt, E.spanselect.dispatchEvent(
791
+ l,
792
+ wt
795
793
  );
796
794
  }
797
795
  );
798
- }, x = (y) => {
799
- a.current(y, (w, S, b) => {
796
+ }, g = (y) => {
797
+ p.current(y, (b, w, P) => {
800
798
  const T = O(
801
- w,
802
- i.current
799
+ b,
800
+ r.current
803
801
  );
804
802
  if (!T) return;
805
- if (Object.values(b).some((M) => M)) {
803
+ if (Object.values(P).some((C) => C)) {
806
804
  y.preventDefault();
807
- const M = Math.abs(y.deltaY) > Math.abs(y.deltaX) ? y.deltaY : y.deltaX;
808
- E.pressandwheel.dispatchEvent(r, {
805
+ const C = Math.abs(y.deltaY) > Math.abs(y.deltaX) ? y.deltaY : y.deltaX;
806
+ E.pressandwheel.dispatchEvent(l, {
809
807
  pointer: T,
810
- frame: i.current,
811
- keys: b,
808
+ frame: r.current,
809
+ keys: P,
812
810
  deltaX: y.deltaX,
813
811
  deltaY: y.deltaY,
814
- deltaAbs: M
812
+ deltaAbs: C
815
813
  });
816
814
  }
817
815
  });
818
816
  };
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, {
817
+ document.addEventListener("mouseup", d), document.addEventListener("keydown", x), document.addEventListener("keyup", x), document.addEventListener("mousemove", v);
818
+ const S = o.current;
819
+ return S?.addEventListener("wheel", g, {
822
820
  passive: !1
823
821
  }), () => {
824
- document.removeEventListener("mouseup", l), document.removeEventListener("keydown", p), document.removeEventListener("keyup", p), document.removeEventListener("mousemove", v), g?.removeEventListener("wheel", x);
822
+ document.removeEventListener("mouseup", d), document.removeEventListener("keydown", x), document.removeEventListener("keyup", x), document.removeEventListener("mousemove", v), S?.removeEventListener("wheel", g);
825
823
  };
826
- }, [i, r, d, a]), R("sync_move", d, (l) => {
827
- const p = l.positions ? O(
828
- l.positions,
829
- i.current
824
+ }, [r, l, h, p]), A("sync_move", h, (d) => {
825
+ const x = d.positions ? O(
826
+ d.positions,
827
+ r.current
830
828
  ) : null;
831
- m.current = l, E.move.dispatchEvent(r, {
832
- frame: i.current,
833
- pointer: p ?? null,
834
- keys: l.keys
829
+ a.current = d, E.move.dispatchEvent(l, {
830
+ frame: r.current,
831
+ pointer: x ?? null,
832
+ keys: d.keys
835
833
  });
836
- }), /* @__PURE__ */ A(
834
+ }), /* @__PURE__ */ k(
837
835
  "div",
838
836
  {
839
- ref: s,
837
+ ref: o,
840
838
  id: "interactions",
841
839
  className: n,
842
840
  style: {
843
841
  position: "absolute",
844
- left: o.chartAreaCSS.x,
845
- top: o.chartAreaCSS.y,
846
- width: o.chartAreaCSS.width,
847
- height: o.chartAreaCSS.height,
842
+ left: i.chartAreaCSS.x,
843
+ top: i.chartAreaCSS.y,
844
+ width: i.chartAreaCSS.width,
845
+ height: i.chartAreaCSS.height,
848
846
  zIndex: 25,
849
847
  ...e
850
848
  },
851
- onDragStart: (l) => {
852
- l.preventDefault();
849
+ onDragStart: (d) => {
850
+ d.preventDefault();
853
851
  },
854
- onClick: (l) => {
855
- f(l, (p, v, x) => {
856
- const g = O(
857
- p,
858
- i.current
852
+ onClick: (d) => {
853
+ c(d, (x, v, g) => {
854
+ const S = O(
855
+ x,
856
+ r.current
859
857
  );
860
- g && E.click.dispatchEvent(r, {
861
- pointer: g,
862
- frame: i.current,
863
- keys: x
858
+ S && E.click.dispatchEvent(l, {
859
+ pointer: S,
860
+ frame: r.current,
861
+ keys: g
864
862
  });
865
863
  });
866
864
  },
867
- onMouseLeave: (l) => {
868
- f(l, (p, v, x) => {
869
- E.sync_move.dispatchEvent(d, {
865
+ onMouseLeave: (d) => {
866
+ c(d, (x, v, g) => {
867
+ E.sync_move.dispatchEvent(h, {
870
868
  positions: null,
871
- keys: x
869
+ keys: g
872
870
  });
873
871
  });
874
872
  },
875
- onMouseMove: (l) => {
876
- f(l, (p, v, x) => {
877
- E.sync_move.dispatchEvent(d, {
878
- positions: p,
879
- keys: x
873
+ onMouseMove: (d) => {
874
+ c(d, (x, v, g) => {
875
+ E.sync_move.dispatchEvent(h, {
876
+ positions: x,
877
+ keys: g
880
878
  });
881
879
  });
882
880
  },
883
- onMouseDown: (l) => {
884
- f(l, (p, { cssX: v, cssY: x }, g) => {
881
+ onMouseDown: (d) => {
882
+ c(d, (x, { cssX: v, cssY: g }, S) => {
885
883
  const y = O(
886
- p,
887
- i.current
884
+ x,
885
+ r.current
888
886
  );
889
- y && (E.mousedown.dispatchEvent(r, {
887
+ y && (E.mousedown.dispatchEvent(l, {
890
888
  pointer: y,
891
- frame: i.current,
892
- keys: g
893
- }), h.current = {
889
+ frame: r.current,
890
+ keys: S
891
+ }), u.current = {
894
892
  xRangeCss: { start: v, end: v },
895
- yRangeCss: { start: x, end: x }
893
+ yRangeCss: { start: g, end: g }
896
894
  });
897
895
  });
898
896
  },
899
- onMouseUp: (l) => {
900
- f(l, (p, v, x) => {
901
- const g = O(
902
- p,
903
- i.current
897
+ onMouseUp: (d) => {
898
+ c(d, (x, v, g) => {
899
+ const S = O(
900
+ x,
901
+ r.current
904
902
  );
905
- if (!g) return;
906
- E.mouseup.dispatchEvent(r, {
907
- frame: i.current,
908
- pointer: g,
909
- keys: x
903
+ if (!S) return;
904
+ E.mouseup.dispatchEvent(l, {
905
+ frame: r.current,
906
+ pointer: S,
907
+ keys: g
910
908
  });
911
- const y = u.current;
912
- u.current = null;
913
- const w = h.current;
914
- if (h.current = null, w && y) {
915
- const S = {
909
+ const y = f.current;
910
+ f.current = null;
911
+ const b = u.current;
912
+ if (u.current = null, b && y) {
913
+ const w = {
916
914
  ...y,
917
- keys: x,
915
+ keys: g,
918
916
  completed: !0
919
917
  };
920
- u.current = null, E.spanselect.dispatchEvent(
921
- r,
922
- S
918
+ f.current = null, E.spanselect.dispatchEvent(
919
+ l,
920
+ w
923
921
  );
924
922
  }
925
923
  });
926
924
  },
927
- onContextMenu: (l) => {
928
- l.preventDefault(), f(l, (p, v, x) => {
929
- const g = O(
930
- p,
931
- i.current
925
+ onContextMenu: (d) => {
926
+ d.preventDefault(), c(d, (x, v, g) => {
927
+ const S = O(
928
+ x,
929
+ r.current
932
930
  );
933
- g && E.contextmenu.dispatchEvent(r, {
934
- frame: i.current,
935
- pointer: g,
936
- keys: x
931
+ S && E.contextmenu.dispatchEvent(l, {
932
+ frame: r.current,
933
+ pointer: S,
934
+ keys: g
937
935
  });
938
936
  });
939
937
  },
940
- onDoubleClick: (l) => {
941
- f(l, (p, v, x) => {
942
- const g = O(
943
- p,
944
- i.current
938
+ onDoubleClick: (d) => {
939
+ c(d, (x, v, g) => {
940
+ const S = O(
941
+ x,
942
+ r.current
945
943
  );
946
- g && E.dblclick.dispatchEvent(r, {
947
- frame: i.current,
948
- pointer: g,
949
- keys: x
944
+ S && E.dblclick.dispatchEvent(l, {
945
+ frame: r.current,
946
+ pointer: S,
947
+ keys: g
950
948
  });
951
949
  });
952
- }
950
+ },
951
+ children: s
953
952
  }
954
953
  );
955
- }, Ee = ({ data: n, renderTooltip: e, xScaleId: t }) => {
954
+ }, Pe = ({ data: n, renderTooltip: e, xScaleId: t }) => {
956
955
  const [s, o] = V(null);
957
956
  yt("move", (r) => {
958
957
  o(r);
@@ -960,87 +959,87 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
960
959
  const i = et(() => {
961
960
  if (!s)
962
961
  return null;
963
- const { frame: r, pointer: d } = s, h = d?.scaled[t];
962
+ const { frame: r, pointer: l } = s, h = l?.scaled[t];
964
963
  if (h === void 0)
965
964
  return null;
966
965
  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))
966
+ let f = h;
967
+ for (const a of n) {
968
+ let m = null, c = 1 / 0;
969
+ for (const [d, x] of a.points.entries()) {
970
+ if (!ut(r, x.x, t) || !ut(r, x.y, a.yScaleId))
972
971
  continue;
973
- const x = Math.abs(v.x - h);
974
- x < a && (a = x, f = p);
972
+ const v = Math.abs(x.x - h);
973
+ v < c && (c = v, m = d);
975
974
  }
976
- const l = c.points[f ?? -1];
977
- if (!l || ft(r, a, t, "css") > 30) {
978
- u.push({ seriesId: c.seriesId, y: null });
975
+ const p = a.points[m ?? -1];
976
+ if (!p || ft(r, c, t, "css") > 30) {
977
+ u.push({ seriesId: a.seriesId, y: null });
979
978
  continue;
980
979
  }
981
- m = l.x, u.push({
982
- seriesId: c.seriesId,
983
- y: l.y
980
+ f = p.x, u.push({
981
+ seriesId: a.seriesId,
982
+ y: p.y
984
983
  });
985
984
  }
986
985
  return {
987
986
  frame: r,
988
- x: m,
987
+ x: f,
989
988
  points: u
990
989
  };
991
990
  }, [n, s, t]);
992
991
  return e(i);
993
- }, Pe = ({ makeXStyle: n, makeXClassName: e, makeYStyle: t, makeYClassName: s }) => {
992
+ }, ke = ({ makeXStyle: n, makeXClassName: e, makeYStyle: t, makeYClassName: s }) => {
994
993
  const [o, i] = V(null);
995
- if (yt("move", (f) => {
996
- i(f);
994
+ if (yt("move", (m) => {
995
+ i(m);
997
996
  }), !o)
998
997
  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: [
1001
- /* @__PURE__ */ A(
998
+ const { frame: r, pointer: l } = o, h = l?.cssX ?? null, u = l?.cssY ?? null, f = h ? Y(r, h, "css") - r.chartAreaCSS.x : 0, a = u ? B(r, u, "css") - r.chartAreaCSS.y : 0;
999
+ return /* @__PURE__ */ Ct(Ut, { children: [
1000
+ /* @__PURE__ */ k(
1002
1001
  "div",
1003
1002
  {
1004
- "data-show": !!d,
1003
+ "data-show": !!l,
1005
1004
  className: e?.(o),
1006
1005
  style: {
1007
1006
  position: "absolute",
1008
1007
  left: 0,
1009
1008
  visibility: h === null ? "hidden" : "visible",
1010
- top: r.chartAreaCSS.y,
1011
- height: r.chartAreaCSS.height,
1009
+ top: 0,
1010
+ bottom: 0,
1012
1011
  borderColor: "red",
1013
1012
  borderLeftWidth: "1px",
1014
1013
  borderLeftStyle: "solid",
1015
1014
  pointerEvents: "none",
1016
- opacity: d ? 1 : 0,
1017
- transform: `translateX(${m}px)`,
1015
+ opacity: l ? 1 : 0,
1016
+ transform: `translateX(${f}px)`,
1018
1017
  ...n?.(o)
1019
1018
  }
1020
1019
  }
1021
1020
  ),
1022
- /* @__PURE__ */ A(
1021
+ /* @__PURE__ */ k(
1023
1022
  "div",
1024
1023
  {
1025
1024
  className: s?.(o),
1026
- "data-show": !!d,
1025
+ "data-show": !!l,
1027
1026
  style: {
1028
1027
  position: "absolute",
1029
1028
  visibility: u === null ? "hidden" : "visible",
1030
1029
  top: 0,
1031
1030
  height: 0,
1032
1031
  borderTop: "solid 1px red",
1033
- left: r.chartAreaCSS.x,
1034
- width: r.chartAreaCSS.width,
1032
+ left: 0,
1033
+ right: 0,
1035
1034
  pointerEvents: "none",
1036
- opacity: d ? 1 : 0,
1037
- transform: `translateY(${c}px)`,
1035
+ opacity: l ? 1 : 0,
1036
+ transform: `translateY(${a}px)`,
1038
1037
  ...t?.(o)
1039
1038
  }
1040
1039
  }
1041
1040
  )
1042
1041
  ] });
1043
- }, ke = ({ makeClassName: n, makeStyle: e }) => {
1042
+ }, Re = ({ makeClassName: n, makeStyle: e }) => {
1044
1043
  const [t, s] = V(null);
1045
1044
  yt("spanselect", (i) => {
1046
1045
  s(
@@ -1050,10 +1049,10 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
1050
1049
  const o = et(() => {
1051
1050
  if (!t || t.mode === "below_threshold")
1052
1051
  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 };
1052
+ 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, h = t.mode === "x" ? 1 / 0 : t.y.css?.to ?? 1 / 0, u = Y(t.frame, i, "css"), f = Y(t.frame, r, "css"), a = B(t.frame, l, "css"), m = B(t.frame, h, "css"), c = Math.min(u, f) - t.frame.chartAreaCSS.x, p = Math.min(a, m) - t.frame.chartAreaCSS.y, d = Math.abs(f - u), x = Math.abs(m - a);
1053
+ return { leftPx: c, topPx: p, widthPx: d, heightPx: x };
1055
1054
  }, [t]);
1056
- return /* @__PURE__ */ A(
1055
+ return /* @__PURE__ */ k(
1057
1056
  "div",
1058
1057
  {
1059
1058
  className: t ? n?.(t) : void 0,
@@ -1069,9 +1068,9 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
1069
1068
  }
1070
1069
  }
1071
1070
  );
1072
- }, Re = ({ style: n, children: e, scaleId: t, ...s }) => {
1071
+ }, Ae = ({ style: n, children: e, scaleId: t, ...s }) => {
1073
1072
  const o = pt((i) => i.getScale(t)?.axis);
1074
- return o ? /* @__PURE__ */ A(
1073
+ return o ? /* @__PURE__ */ k(
1075
1074
  "div",
1076
1075
  {
1077
1076
  style: {
@@ -1087,32 +1086,32 @@ const xe = Xt(({ configuration: n, children: e, style: t, className: s }, o) =>
1087
1086
  children: e
1088
1087
  }
1089
1088
  ) : null;
1090
- }, Rt = 60, Gt = 30, At = "UTC", Zt = "en-GB", Ae = ({
1089
+ }, At = 60, Zt = 30, Dt = "UTC", Jt = "en-GB", De = ({
1091
1090
  space: n,
1092
1091
  formatter: e,
1093
1092
  acceptableIncrements: t
1094
1093
  } = {}) => (s, o) => {
1095
- const { min: i, max: r } = s, d = [], h = window.devicePixelRatio || 1, u = (n ?? (s.origin === "x" ? Rt : Gt)) * h, m = Ot(
1094
+ const { min: i, max: r } = s, l = [], h = window.devicePixelRatio || 1, u = (n ?? (s.origin === "x" ? At : Zt)) * h, f = Ft(
1096
1095
  o,
1097
1096
  u,
1098
1097
  s.id,
1099
1098
  "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;
1099
+ ), a = t ?? G, m = a.find((p) => p > f) ?? a.at(-1) ?? 1;
1100
+ let c = i;
1101
+ if (Math.abs(c % m) > Number.EPSILON) {
1102
+ const p = (m - c % m) % m;
1103
+ c += p;
1105
1104
  }
1106
- for (; a <= r && d.length < 1e3; )
1107
- d.push(a), a += f;
1108
- return (e ?? Jt)(d);
1109
- }, Jt = (n) => {
1105
+ for (; c <= r && l.length < 1e3; )
1106
+ l.push(c), c += m;
1107
+ return (e ?? Qt)(l);
1108
+ }, Qt = (n) => {
1110
1109
  const e = Math.max(0, Math.ceil(-Math.log10(n[1] - n[0])));
1111
1110
  return n.map((t) => ({ value: t, label: t.toFixed(e) }));
1112
1111
  }, G = [];
1113
1112
  for (let n = -12; n <= 12; n++)
1114
1113
  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 = [
1114
+ const te = 1, _t = 1e3 * te, vt = 60 * _t, nt = 60 * vt, st = 24 * nt, ee = 30 * st, ne = 365 * st, se = [
1116
1115
  // second divisors
1117
1116
  [1, "milliseconds"],
1118
1117
  [2, "milliseconds"],
@@ -1170,7 +1169,7 @@ const Qt = 1, Dt = 1e3 * Qt, vt = 60 * Dt, nt = 60 * vt, st = 24 * nt, te = 30 *
1170
1169
  case "milliseconds":
1171
1170
  return e;
1172
1171
  case "seconds":
1173
- return e * Dt;
1172
+ return e * _t;
1174
1173
  case "minutes":
1175
1174
  return e * vt;
1176
1175
  case "hours":
@@ -1178,23 +1177,23 @@ const Qt = 1, Dt = 1e3 * Qt, vt = 60 * Dt, nt = 60 * vt, st = 24 * nt, te = 30 *
1178
1177
  case "days":
1179
1178
  return e * st;
1180
1179
  case "months":
1181
- return e * te;
1182
- case "years":
1183
1180
  return e * ee;
1181
+ case "years":
1182
+ return e * ne;
1184
1183
  }
1185
- }, se = (n, e) => {
1184
+ }, oe = (n, e) => {
1186
1185
  const t = new Date(n);
1187
1186
  return t.setUTCMilliseconds(t.getUTCMilliseconds() + e), t.getTime();
1188
- }, oe = (n, e) => {
1187
+ }, ie = (n, e) => {
1189
1188
  const t = new Date(n);
1190
1189
  return t.setUTCSeconds(t.getUTCSeconds() + e), t.getTime();
1191
- }, ie = (n, e) => {
1190
+ }, re = (n, e) => {
1192
1191
  const t = new Date(n);
1193
1192
  return t.setUTCMinutes(t.getUTCMinutes() + e), t.getTime();
1194
- }, re = (n, e) => {
1193
+ }, ce = (n, e) => {
1195
1194
  const t = new Date(n);
1196
1195
  return t.setUTCHours(t.getUTCHours() + e), t.getTime();
1197
- }, ce = (n, e) => {
1196
+ }, ae = (n, e) => {
1198
1197
  const t = new Date(n);
1199
1198
  return t.setUTCDate(t.getUTCDate() + e), t.getTime();
1200
1199
  }, Tt = (n, e) => {
@@ -1204,15 +1203,15 @@ const Qt = 1, Dt = 1e3 * Qt, vt = 60 * Dt, nt = 60 * vt, st = 24 * nt, te = 30 *
1204
1203
  const [t, s] = e;
1205
1204
  switch (s) {
1206
1205
  case "milliseconds":
1207
- return se(n, t);
1208
- case "seconds":
1209
1206
  return oe(n, t);
1210
- case "minutes":
1207
+ case "seconds":
1211
1208
  return ie(n, t);
1212
- case "hours":
1209
+ case "minutes":
1213
1210
  return re(n, t);
1214
- case "days":
1211
+ case "hours":
1215
1212
  return ce(n, t);
1213
+ case "days":
1214
+ return ae(n, t);
1216
1215
  case "months":
1217
1216
  return Tt(n, t);
1218
1217
  case "years":
@@ -1223,7 +1222,7 @@ function J(n, e) {
1223
1222
  const t = new Date(n), s = new Date(t.toLocaleString("en-US", { timeZone: e })), o = new Date(t.toLocaleString("en-US", { timeZone: "UTC" }));
1224
1223
  return (s.getTime() - o.getTime()) / (3600 * 1e3);
1225
1224
  }
1226
- const ae = (n, e, t = "UTC") => {
1225
+ const le = (n, e, t = "UTC") => {
1227
1226
  const [s, o] = e;
1228
1227
  let i = new Date(n);
1229
1228
  const r = () => {
@@ -1263,33 +1262,33 @@ const ae = (n, e, t = "UTC") => {
1263
1262
  break;
1264
1263
  }
1265
1264
  return i.getTime();
1266
- }, De = ({
1267
- timeZone: n = At,
1268
- space: e = Rt,
1265
+ }, _e = ({
1266
+ timeZone: n = Dt,
1267
+ space: e = At,
1269
1268
  formatter: t,
1270
1269
  locale: s,
1271
1270
  showTimezone: o
1272
1271
  } = {}) => (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;
1272
+ const { min: l, max: h } = i, u = Math.floor(r.chartAreaCanvasPX.width / e) + 1, a = (h - l) / u, [m, c] = se.find(
1273
+ (g) => Z(g) >= a
1274
+ ) ?? [1, "milliseconds"], p = le(l, [m, c], n), d = J(p, n), x = [p];
1275
+ let v;
1277
1276
  for (; ; ) {
1278
- switch (a) {
1277
+ switch (c) {
1279
1278
  case "milliseconds":
1280
1279
  case "seconds":
1281
1280
  case "minutes":
1282
1281
  case "hours": {
1283
- x = X(l, [v.length * f, a]);
1282
+ v = X(p, [x.length * m, c]);
1284
1283
  break;
1285
1284
  }
1286
1285
  case "days": {
1287
- const g = X(l, [
1288
- v.length * f,
1289
- a
1286
+ const g = X(p, [
1287
+ x.length * m,
1288
+ c
1290
1289
  ]);
1291
- x = X(g, [
1292
- p - J(g, n),
1290
+ v = X(g, [
1291
+ d - J(g, n),
1293
1292
  "hours"
1294
1293
  ]);
1295
1294
  break;
@@ -1297,31 +1296,31 @@ const ae = (n, e, t = "UTC") => {
1297
1296
  case "months":
1298
1297
  case "years": {
1299
1298
  const g = X(
1300
- X(X(l, [p, "hours"]), [
1301
- v.length * f,
1302
- a
1299
+ X(X(p, [d, "hours"]), [
1300
+ x.length * m,
1301
+ c
1303
1302
  ]),
1304
- [-p, "hours"]
1303
+ [-d, "hours"]
1305
1304
  );
1306
- x = X(g, [
1307
- p - J(g, n),
1305
+ v = X(g, [
1306
+ d - J(g, n),
1308
1307
  "hours"
1309
1308
  ]);
1310
1309
  break;
1311
1310
  }
1312
1311
  }
1313
- if (x > h)
1312
+ if (v > h)
1314
1313
  break;
1315
- v.push(x);
1314
+ x.push(v);
1316
1315
  }
1317
- return (t ?? le({
1316
+ return (t ?? ue({
1318
1317
  locale: s,
1319
1318
  showTimezone: o,
1320
1319
  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,
1320
+ }))(x);
1321
+ }, U = (n, e, t) => n.find((s) => s.type === t)?.value !== e.find((s) => s.type === t)?.value, ue = ({
1322
+ timeZone: n = Dt,
1323
+ locale: e = Jt,
1325
1324
  showTimezone: t = !0
1326
1325
  }) => {
1327
1326
  const s = new Intl.DateTimeFormat(e, {
@@ -1337,30 +1336,30 @@ const ae = (n, e, t = "UTC") => {
1337
1336
  timeZone: n
1338
1337
  });
1339
1338
  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;
1339
+ const i = o[1] - o[0], r = i < Z([1, "days"]), l = i < Z([1, "minutes"]), h = i < Z([1, "seconds"]);
1340
+ return o.map((u) => ({ value: u, label: s.formatToParts(new Date(u)) })).map((u, f, a) => {
1341
+ const m = a[f - 1], c = f === 0 || U(u.label, m.label, "year"), p = f === 0 || U(u.label, m.label, "day"), d = f === 0 || U(u.label, m.label, "month"), x = f === 0 || U(u.label, m.label, "hour"), v = f === 0 || U(u.label, m.label, "timeZoneName"), g = f === 0 || U(u.label, m.label, "minute"), S = f === 0 || U(u.label, m.label, "second"), y = f === 0 || U(u.label, m.label, "fractionalSecond"), b = [];
1342
+ if (r && (x || g || v || S || y)) {
1343
+ const w = 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
1344
  let M = "";
1346
- if (d) {
1347
- const P = u.label.find((K) => K.type === "second")?.value, N = u.label.find(
1345
+ if (l) {
1346
+ const C = u.label.find((K) => K.type === "second")?.value, N = u.label.find(
1348
1347
  (K) => K.type === "fractionalSecond"
1349
1348
  )?.value;
1350
- M = `:${P}` + (h ? `.${N}` : "");
1349
+ M = `:${C}` + (h ? `.${N}` : "");
1351
1350
  }
1352
- S.push(
1353
- `${b}:${T}${M}` + (t && x ? ` ${C}` : "")
1351
+ b.push(
1352
+ `${w}:${P}${M}` + (t && v ? ` ${T}` : "")
1354
1353
  );
1355
1354
  }
1356
- return (l || p) && S.push(
1355
+ return (p || d) && b.push(
1357
1356
  [
1358
- u.label.find((b) => b.type === "month")?.value,
1359
- l && u.label.find((b) => b.type === "day")?.value
1357
+ u.label.find((w) => w.type === "month")?.value,
1358
+ p && u.label.find((w) => w.type === "day")?.value
1360
1359
  ].filter(Boolean).join(" ")
1361
- ), a && S.push(u.label.find((b) => b.type === "year")?.value), {
1360
+ ), c && b.push(u.label.find((w) => w.type === "year")?.value), {
1362
1361
  value: u.value,
1363
- label: S.filter((b) => b).join(`
1362
+ label: b.filter((w) => w).join(`
1364
1363
  `)
1365
1364
  };
1366
1365
  });
@@ -1368,38 +1367,38 @@ const ae = (n, e, t = "UTC") => {
1368
1367
  };
1369
1368
  export {
1370
1369
  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,
1370
+ Ae as AxisOverlay,
1371
+ be as BarPlot,
1372
+ dt as CANPLOT_LAYER,
1373
+ ye as CanPlot,
1374
+ Ee as ChartAreaInteractions,
1375
+ ke as Crosshair,
1376
+ ve as LinePlot,
1377
+ ge as ScatterPlot,
1378
+ Re as SelectBox,
1379
+ Se as SparklinePlot,
1380
+ Pe as TooltipsX,
1381
+ Ce as XTicks,
1382
+ Me as YTicks,
1384
1383
  D as applyStyles,
1385
1384
  j as clamp,
1386
- pe as clampUnfit,
1385
+ xe as clampUnfit,
1387
1386
  Y as clampXPosToChartArea,
1388
1387
  B as clampYPosToChartArea,
1389
- Jt as defaultNumericalTicksFormatter,
1390
- me as findClosestIndex,
1388
+ Qt as defaultNumericalTicksFormatter,
1389
+ pe as findClosestIndex,
1391
1390
  I as getScale,
1392
- Ae as makeLinearTicks,
1393
- le as makeTimeTickFormat,
1394
- De as makeTimeTicks,
1391
+ De as makeLinearTicks,
1392
+ ue as makeTimeTickFormat,
1393
+ _e as makeTimeTicks,
1395
1394
  L as posToVal,
1396
- Ot as pxToValDistance,
1397
- fe as sum,
1395
+ Ft as pxToValDistance,
1396
+ me as sum,
1398
1397
  F as useDrawEffect,
1399
1398
  pt as useFrameState,
1400
1399
  yt as useInteractionsEvent,
1401
- Se as useXPositioned,
1402
- lt as valFits,
1400
+ Te as useXPositioned,
1401
+ ut as valFits,
1403
1402
  H as valToPos,
1404
1403
  ft as valToPxDistance
1405
1404
  };