@canplot/react 0.1.9 → 0.1.11

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