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