@canplot/react 0.1.23 → 0.1.25

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