@umriss-ui/charts 0.6.0 → 0.7.0

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/charts.js CHANGED
@@ -1,24 +1,24 @@
1
1
  import "./charts.css";
2
- var Ue = Object.defineProperty;
3
- var Xe = (s, t, e) => t in s ? Ue(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
4
- var x = (s, t, e) => Xe(s, typeof t != "symbol" ? t + "" : t, e);
5
- import { jsxs as z, jsx as I, Fragment as Et } from "react/jsx-runtime";
6
- import { useRef as q, useEffect as D, createContext as Ze, useContext as je, useSyncExternalStore as $t, useCallback as Je, useMemo as P, useState as Ee, useId as Qe } from "react";
7
- function tn() {
2
+ var fn = Object.defineProperty;
3
+ var mn = (s, t, e) => t in s ? fn(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
4
+ var x = (s, t, e) => mn(s, typeof t != "symbol" ? t + "" : t, e);
5
+ import { jsxs as O, jsx as k, Fragment as xt } from "react/jsx-runtime";
6
+ import { useRef as G, useEffect as D, createContext as pn, useContext as gn, useSyncExternalStore as wt, useId as Ve, useState as fe, useLayoutEffect as yn, useCallback as xn, Fragment as bn, useMemo as $ } from "react";
7
+ function vn() {
8
8
  var t;
9
9
  const s = import.meta;
10
10
  return typeof ((t = s.env) == null ? void 0 : t.DEV) == "boolean" ? s.env.DEV : typeof process < "u" && (process != null && process.env) ? process.env.NODE_ENV !== "production" : !1;
11
11
  }
12
- const yt = tn();
13
- function pt(s, t) {
14
- if (yt && !s)
12
+ const bt = vn();
13
+ function gt(s, t) {
14
+ if (bt && !s)
15
15
  throw new Error(`@umriss-ui/charts: ${t}`);
16
16
  }
17
- const oe = /* @__PURE__ */ new Set();
18
- function tt(s, t) {
19
- !yt || oe.has(s) || (oe.add(s), console.warn(`@umriss-ui/charts: ${t}`));
17
+ const ye = /* @__PURE__ */ new Set();
18
+ function nt(s, t) {
19
+ !bt || ye.has(s) || (ye.add(s), console.warn(`@umriss-ui/charts: ${t}`));
20
20
  }
21
- const R = {
21
+ const H = {
22
22
  colorAxis: "rgba(23, 23, 23, 0.17)",
23
23
  colorGrid: "rgba(23, 23, 23, 0.06)",
24
24
  colorText: "#71717a",
@@ -28,82 +28,110 @@ const R = {
28
28
  colorOk: "#217a4b",
29
29
  font: "system-ui, sans-serif",
30
30
  fontMono: "ui-monospace, monospace",
31
- series: ["#2563eb", "#db2777", "#059669", "#d97706", "#7c3aed", "#0891b2"]
32
- }, re = /* @__PURE__ */ new WeakMap();
33
- let Zt = 0;
34
- const jt = /* @__PURE__ */ new Set();
35
- let Wt = null;
36
- function Vt(s, t, e) {
31
+ series: ["#2563eb", "#db2777", "#059669", "#d97706", "#7c3aed", "#0891b2"],
32
+ forced: !1
33
+ }, Ye = "(forced-colors: active)";
34
+ function kn() {
35
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(Ye).matches;
36
+ }
37
+ const xe = /* @__PURE__ */ new WeakMap();
38
+ let se = 0;
39
+ const oe = /* @__PURE__ */ new Set();
40
+ let Kt = null;
41
+ function yt(s, t, e) {
37
42
  const n = s.getPropertyValue(t).trim();
38
43
  return n === "" ? e : n;
39
44
  }
40
- function Le(s, t) {
41
- const e = s.ownerDocument.createElement("span");
42
- e.setAttribute("aria-hidden", "true"), e.style.position = "absolute", e.style.visibility = "hidden", s.appendChild(e);
45
+ function me(s, t, e = !1) {
46
+ const n = s.ownerDocument.createElement("span");
47
+ n.setAttribute("aria-hidden", "true"), n.style.position = "absolute", n.style.visibility = "hidden", e && n.style.setProperty("forced-color-adjust", "none"), s.appendChild(n);
43
48
  try {
44
- return t((n) => {
45
- e.style.color = "", e.style.color = n;
46
- const i = getComputedStyle(e).color;
47
- return i === "" || i.startsWith("var(") ? n : i;
49
+ return t((i) => {
50
+ n.style.color = "", n.style.color = i;
51
+ const o = getComputedStyle(n).color;
52
+ return o === "" || o.startsWith("var(") ? i : o;
48
53
  });
49
54
  } finally {
50
- e.remove();
55
+ n.remove();
51
56
  }
52
57
  }
53
- function en(s) {
58
+ function wn(s, t) {
59
+ return me(
60
+ s,
61
+ (e) => {
62
+ const n = e("CanvasText"), i = e("Highlight");
63
+ return {
64
+ colorAxis: n,
65
+ colorGrid: e("GrayText"),
66
+ colorText: n,
67
+ colorBg: e("Canvas"),
68
+ colorWarning: i,
69
+ colorAlarm: i,
70
+ colorOk: n,
71
+ font: yt(t, "--uc-font", H.font),
72
+ fontMono: yt(t, "--uc-font-mono", H.fontMono),
73
+ series: H.series.map(() => n),
74
+ forced: !0
75
+ };
76
+ },
77
+ !0
78
+ );
79
+ }
80
+ function Nn(s) {
54
81
  const t = getComputedStyle(s);
55
- return Le(s, (e) => {
82
+ return kn() ? wn(s, t) : me(s, (e) => {
56
83
  const n = (o, r) => {
57
- const l = Vt(t, o, r);
84
+ const l = yt(t, o, r);
58
85
  if (l === r) return r;
59
86
  const a = e(`var(${o})`);
60
87
  return a === `var(${o})` ? l : a;
61
88
  }, i = [];
62
89
  for (let o = 1; o <= 6; o++)
63
- i.push(n(`--uc-series-${o}`, R.series[o - 1] ?? "#2563eb"));
90
+ i.push(n(`--uc-series-${o}`, H.series[o - 1] ?? "#2563eb"));
64
91
  return {
65
- colorAxis: n("--uc-color-axis", R.colorAxis),
66
- colorGrid: n("--uc-color-grid", R.colorGrid),
67
- colorText: n("--uc-color-text", R.colorText),
68
- colorBg: n("--uc-color-bg", R.colorBg),
69
- colorWarning: n("--uc-color-warning", R.colorWarning),
70
- colorAlarm: n("--uc-color-alarm", R.colorAlarm),
71
- colorOk: n("--uc-color-ok", R.colorOk),
72
- font: Vt(t, "--uc-font", R.font),
73
- fontMono: Vt(t, "--uc-font-mono", R.fontMono),
74
- series: i
92
+ colorAxis: n("--uc-color-axis", H.colorAxis),
93
+ colorGrid: n("--uc-color-grid", H.colorGrid),
94
+ colorText: n("--uc-color-text", H.colorText),
95
+ colorBg: n("--uc-color-bg", H.colorBg),
96
+ colorWarning: n("--uc-color-warning", H.colorWarning),
97
+ colorAlarm: n("--uc-color-alarm", H.colorAlarm),
98
+ colorOk: n("--uc-color-ok", H.colorOk),
99
+ font: yt(t, "--uc-font", H.font),
100
+ fontMono: yt(t, "--uc-font-mono", H.fontMono),
101
+ series: i,
102
+ forced: !1
75
103
  };
76
104
  });
77
105
  }
78
- function Fe() {
79
- var s, t;
80
- Wt === null && (typeof MutationObserver > "u" || typeof document > "u" || (Wt = new MutationObserver(() => le()), Wt.observe(document.documentElement, { attributes: !0 }), typeof window < "u" && typeof window.matchMedia == "function" && ((t = (s = window.matchMedia("(prefers-color-scheme: dark)")).addEventListener) == null || t.call(s, "change", () => le()))));
106
+ function Ge() {
107
+ var s, t, e, n;
108
+ Kt === null && (typeof MutationObserver > "u" || typeof document > "u" || (Kt = new MutationObserver(() => qt()), Kt.observe(document.documentElement, { attributes: !0 }), typeof window < "u" && typeof window.matchMedia == "function" && ((t = (s = window.matchMedia("(prefers-color-scheme: dark)")).addEventListener) == null || t.call(s, "change", () => qt()), (n = (e = window.matchMedia(Ye)).addEventListener) == null || n.call(e, "change", () => qt()))));
81
109
  }
82
- function nn(s, t) {
83
- return Fe(), Le(s, (e) => {
110
+ function In(s, t) {
111
+ return Ge(), me(s, (e) => {
84
112
  const n = {};
85
113
  for (const i of Object.keys(t)) n[i] = e(t[i]);
86
114
  return n;
87
115
  });
88
116
  }
89
- function sn(s) {
90
- Fe();
91
- const t = re.get(s);
92
- if (t !== void 0 && t.generation === Zt) return t.theme;
93
- const e = en(s);
94
- return re.set(s, { generation: Zt, theme: e }), e;
117
+ function An(s) {
118
+ Ge();
119
+ const t = xe.get(s);
120
+ if (t !== void 0 && t.generation === se) return t.theme;
121
+ const e = Nn(s);
122
+ return xe.set(s, { generation: se, theme: e }), e;
95
123
  }
96
- function le() {
97
- Zt++;
98
- for (const s of jt) s();
124
+ function qt() {
125
+ se++;
126
+ for (const s of oe) s();
99
127
  }
100
- function on(s) {
101
- return jt.add(s), () => {
102
- jt.delete(s);
128
+ function Tn(s) {
129
+ return oe.add(s), () => {
130
+ oe.delete(s);
103
131
  };
104
132
  }
105
- const rn = { width: 0, height: 0 };
106
- class ln {
133
+ const Mn = { width: 0, height: 0 };
134
+ class Sn {
107
135
  constructor(t) {
108
136
  x(this, "span", null);
109
137
  x(this, "root");
@@ -121,7 +149,7 @@ class ln {
121
149
  const n = `${e}|${t}`, i = this.cache.get(n);
122
150
  if (i !== void 0) return i;
123
151
  const o = this.ensure();
124
- if (o === null) return rn;
152
+ if (o === null) return Mn;
125
153
  o.className = `uc-measure ${e}`, o.textContent = t;
126
154
  const r = o.getBoundingClientRect(), l = { width: r.width, height: r.height };
127
155
  return this.cache.set(n, l), l;
@@ -134,15 +162,15 @@ class ln {
134
162
  (t = this.span) == null || t.remove(), this.span = null, this.cache.clear();
135
163
  }
136
164
  }
137
- function Lt(s) {
165
+ function Ht(s) {
138
166
  return Object.is(s, -0) ? 0 : s;
139
167
  }
140
- function ot(s, t) {
168
+ function lt(s, t) {
141
169
  if (!Number.isFinite(s) || s <= 0) return 1;
142
170
  const e = Math.max(1, Math.floor(t)), n = s / e, i = Math.pow(10, Math.floor(Math.log10(n))), o = n / i, r = 1e-9;
143
171
  return (o <= 1 + r ? 1 : o <= 2 + r ? 2 : o <= 5 + r ? 5 : 10) * i;
144
172
  }
145
- function Rt(s) {
173
+ function Yt(s) {
146
174
  const t = Math.abs(s);
147
175
  if (!Number.isFinite(t) || t === 0) return 0;
148
176
  const e = Math.floor(Math.log10(t));
@@ -152,52 +180,52 @@ function Rt(s) {
152
180
  n++;
153
181
  return n;
154
182
  }
155
- function Ft(s, t) {
156
- return t <= 0 || !Number.isFinite(s) || Math.abs(s) >= 1e21 ? Lt(s) : Lt(Number(s.toFixed(Math.min(20, t))));
183
+ function Rt(s, t) {
184
+ return t <= 0 || !Number.isFinite(s) || Math.abs(s) >= 1e21 ? Ht(s) : Ht(Number(s.toFixed(Math.min(20, t))));
157
185
  }
158
- function an(s, t, e) {
186
+ function Ln(s, t, e) {
159
187
  if (!Number.isFinite(s) || !Number.isFinite(t)) return [0, 1];
160
188
  if (s === t) return [s - 1, t + 1];
161
- const n = ot(t - s, e), i = Rt(n);
189
+ const n = lt(t - s, e), i = Yt(n);
162
190
  return [
163
- Ft(Math.floor(s / n) * n, i),
164
- Ft(Math.ceil(t / n) * n, i)
191
+ Rt(Math.floor(s / n) * n, i),
192
+ Rt(Math.ceil(t / n) * n, i)
165
193
  ];
166
194
  }
167
- function _t(s, t) {
195
+ function Ut(s, t) {
168
196
  return !Number.isFinite(s) || !Number.isFinite(t) ? [0, 1] : s === t ? [s - 1, t + 1] : [s, t];
169
197
  }
170
- function Pe(s, t, e) {
198
+ function Ke(s, t, e) {
171
199
  if (!Number.isFinite(s) || !Number.isFinite(t)) return [];
172
- if (s === t) return [Lt(s)];
173
- const [n, i] = s < t ? [s, t] : [t, s], o = ot(i - n, e), r = Rt(o), l = o * 1e-9, a = Math.ceil((n - l) / o), c = Math.floor((i + l) / o);
200
+ if (s === t) return [Ht(s)];
201
+ const [n, i] = s < t ? [s, t] : [t, s], o = lt(i - n, e), r = Yt(o), l = o * 1e-9, a = Math.ceil((n - l) / o), c = Math.floor((i + l) / o);
174
202
  if (!Number.isFinite(a) || !Number.isFinite(c)) return [];
175
203
  const h = [];
176
204
  for (let f = a; f <= c; f++)
177
- h.push(Ft(f * o, r));
205
+ h.push(Rt(f * o, r));
178
206
  return h;
179
207
  }
180
- function un(s, t, e, n) {
208
+ function En(s, t, e, n) {
181
209
  const i = n.length, o = n[0], r = n[i - 1];
182
210
  if (i < 2 || o === void 0 || r === void 0 || !Number.isFinite(s) || !Number.isFinite(t))
183
211
  return null;
184
- const [l, a] = s === t ? [s - 1, t + 1] : [s, t], c = (r - o) / (i - 1), h = (o - e[0]) / c, f = (e[1] - r) / c, m = i - 1 + h + f, p = (d) => Lt(Number(d.toPrecision(12)));
185
- let u = ot((a - l) / m, 1);
186
- for (let d = 0; d < 64; d++) {
187
- const y = u * 1e-9, g = Math.floor((l + h * u + y) / u) * u, b = g - h * u;
188
- if (b + m * u >= a - y) {
189
- const k = Rt(u);
212
+ const [l, a] = s === t ? [s - 1, t + 1] : [s, t], c = (r - o) / (i - 1), h = (o - e[0]) / c, f = (e[1] - r) / c, m = i - 1 + h + f, p = (g) => Ht(Number(g.toPrecision(12)));
213
+ let u = lt((a - l) / m, 1);
214
+ for (let g = 0; g < 64; g++) {
215
+ const d = u * 1e-9, y = Math.floor((l + h * u + d) / u) * u, b = y - h * u;
216
+ if (b + m * u >= a - d) {
217
+ const v = Yt(u);
190
218
  return {
191
219
  domain: [p(b), p(b + m * u)],
192
- ticks: Array.from({ length: i }, (T, O) => Ft(g + O * u, k)),
220
+ ticks: Array.from({ length: i }, (w, L) => Rt(y + L * u, v)),
193
221
  step: u
194
222
  };
195
223
  }
196
- u = ot(u * 1.5, 1);
224
+ u = lt(u * 1.5, 1);
197
225
  }
198
226
  return null;
199
227
  }
200
- class ae {
228
+ class be {
201
229
  constructor(t, e) {
202
230
  x(this, "domain");
203
231
  x(this, "range");
@@ -215,36 +243,36 @@ class ae {
215
243
  return this.m === 0 ? this.domain[0] : (t - this.b) / this.m;
216
244
  }
217
245
  ticks(t) {
218
- return Pe(this.domain[0], this.domain[1], t);
246
+ return Ke(this.domain[0], this.domain[1], t);
219
247
  }
220
248
  }
221
- let vt = null;
222
- function De() {
223
- if (vt !== null) return vt;
249
+ let Mt = null;
250
+ function qe() {
251
+ if (Mt !== null) return Mt;
224
252
  const s = typeof navigator > "u" ? void 0 : navigator.language;
225
- return vt = typeof s == "string" && s !== "" ? s : "en-US", vt;
253
+ return Mt = typeof s == "string" && s !== "" ? s : "en-US", Mt;
226
254
  }
227
- const Pt = /* @__PURE__ */ new Map();
228
- function cn(s) {
229
- const t = De(), e = `${t}|${s}`;
230
- let n = Pt.get(e);
255
+ const Wt = /* @__PURE__ */ new Map();
256
+ function Fn(s) {
257
+ const t = qe(), e = `${t}|${s}`;
258
+ let n = Wt.get(e);
231
259
  return n === void 0 && (n = new Intl.NumberFormat(t, {
232
260
  minimumFractionDigits: s,
233
261
  maximumFractionDigits: s,
234
262
  useGrouping: !0
235
- }), Pt.set(e, n)), n;
263
+ }), Wt.set(e, n)), n;
236
264
  }
237
- function Ce(s, t) {
238
- return cn(Math.min(6, Rt(t))).format(s);
265
+ function Ue(s, t) {
266
+ return Fn(Math.min(6, Yt(t))).format(s);
239
267
  }
240
- function kt(s) {
268
+ function St(s) {
241
269
  if (!Number.isFinite(s)) return "–";
242
- const t = De(), e = `${t}|value`;
243
- let n = Pt.get(e);
244
- return n === void 0 && (n = new Intl.NumberFormat(t, { maximumFractionDigits: 3, useGrouping: !0 }), Pt.set(e, n)), n.format(s);
270
+ const t = qe(), e = `${t}|value`;
271
+ let n = Wt.get(e);
272
+ return n === void 0 && (n = new Intl.NumberFormat(t, { maximumFractionDigits: 3, useGrouping: !0 }), Wt.set(e, n)), n.format(s);
245
273
  }
246
- const it = 1e3, B = 60 * it, st = 60 * B, K = 24 * st;
247
- function hn(s) {
274
+ const ot = 1e3, V = 60 * ot, rt = 60 * V, K = 24 * rt;
275
+ function Dn(s) {
248
276
  const t = s.filter((o) => Number.isFinite(o.from) && Number.isFinite(o.to) && o.to > o.from).sort((o, r) => o.from - r.from), e = [];
249
277
  for (const o of t) {
250
278
  const r = e[e.length - 1];
@@ -256,15 +284,15 @@ function hn(s) {
256
284
  n.push(i), i += o.to - o.from;
257
285
  return { intervals: e, offsets: n, total: i };
258
286
  }
259
- const ue = /* @__PURE__ */ new WeakMap();
260
- function J(s) {
287
+ const ve = /* @__PURE__ */ new WeakMap();
288
+ function tt(s) {
261
289
  if (!Array.isArray(s)) return s;
262
- const t = s, e = ue.get(t);
290
+ const t = s, e = ve.get(t);
263
291
  if (e !== void 0) return e;
264
- const n = hn(t);
265
- return ue.set(t, n), n;
292
+ const n = Dn(t);
293
+ return ve.set(t, n), n;
266
294
  }
267
- function dn(s, t) {
295
+ function Pn(s, t) {
268
296
  const e = s.intervals;
269
297
  let n = 0, i = e.length - 1, o = -1;
270
298
  for (; n <= i; ) {
@@ -273,14 +301,14 @@ function dn(s, t) {
273
301
  }
274
302
  return o < 0 ? -1 : t <= e[o].to ? o : -1;
275
303
  }
276
- function lt(s, t) {
277
- const e = J(t);
304
+ function ut(s, t) {
305
+ const e = tt(t);
278
306
  if (e.intervals.length === 0) return s;
279
- const n = dn(e, s);
307
+ const n = Pn(e, s);
280
308
  return n < 0 ? Number.NaN : e.offsets[n] + (s - e.intervals[n].from);
281
309
  }
282
- function at(s, t) {
283
- const e = J(t), n = e.intervals;
310
+ function ht(s, t) {
311
+ const e = tt(t), n = e.intervals;
284
312
  if (n.length === 0) return s;
285
313
  if (!(s >= 0) || s > e.total) return Number.NaN;
286
314
  if (s === e.total)
@@ -292,15 +320,15 @@ function at(s, t) {
292
320
  }
293
321
  return n[r].from + (s - e.offsets[r]);
294
322
  }
295
- function Bi(s, t, e, n) {
296
- const i = J(s);
323
+ function ws(s, t, e, n) {
324
+ const i = tt(s);
297
325
  for (let o = 0; o < e; o++)
298
- n[o] = lt(t[o], i);
326
+ n[o] = ut(t[o], i);
299
327
  }
300
- function fn(s, t) {
301
- const e = J(t);
328
+ function Cn(s, t) {
329
+ const e = tt(t);
302
330
  if (e.intervals.length === 0) return s;
303
- const n = lt(s, e);
331
+ const n = ut(s, e);
304
332
  if (!Number.isNaN(n)) return n;
305
333
  if (!Number.isFinite(s)) return Number.NaN;
306
334
  for (let i = 0; i < e.intervals.length; i++) {
@@ -309,12 +337,12 @@ function fn(s, t) {
309
337
  }
310
338
  return e.total;
311
339
  }
312
- function mn(s, t) {
313
- const e = J(t);
314
- return e.intervals.length === 0 ? !1 : Number.isNaN(lt(s, e));
340
+ function $n(s, t) {
341
+ const e = tt(t);
342
+ return e.intervals.length === 0 ? !1 : Number.isNaN(ut(s, e));
315
343
  }
316
- function pn(s) {
317
- const t = J(s), e = [];
344
+ function On(s) {
345
+ const t = tt(s), e = [];
318
346
  for (let n = 1; n < t.intervals.length; n++)
319
347
  e.push({
320
348
  from: t.intervals[n - 1].to,
@@ -323,83 +351,83 @@ function pn(s) {
323
351
  });
324
352
  return e;
325
353
  }
326
- function yn(s, t, e) {
327
- return pn(s).map((n) => n.operatingTime).filter((n) => n >= t && n <= e);
328
- }
329
- const ce = [
330
- it,
331
- 2 * it,
332
- 5 * it,
333
- 10 * it,
334
- 15 * it,
335
- 30 * it,
336
- B,
337
- 2 * B,
338
- 5 * B,
339
- 10 * B,
340
- 15 * B,
341
- 30 * B,
342
- st,
343
- 2 * st,
344
- 3 * st,
345
- 6 * st,
346
- 12 * st,
354
+ function Hn(s, t, e) {
355
+ return On(s).map((n) => n.operatingTime).filter((n) => n >= t && n <= e);
356
+ }
357
+ const ke = [
358
+ ot,
359
+ 2 * ot,
360
+ 5 * ot,
361
+ 10 * ot,
362
+ 15 * ot,
363
+ 30 * ot,
364
+ V,
365
+ 2 * V,
366
+ 5 * V,
367
+ 10 * V,
368
+ 15 * V,
369
+ 30 * V,
370
+ rt,
371
+ 2 * rt,
372
+ 3 * rt,
373
+ 6 * rt,
374
+ 12 * rt,
347
375
  K,
348
376
  2 * K,
349
377
  7 * K,
350
378
  14 * K,
351
379
  28 * K
352
380
  ];
353
- function xn(s, t) {
354
- const e = ce[0];
381
+ function Rn(s, t) {
382
+ const e = ke[0];
355
383
  if (!Number.isFinite(s) || s <= 0) return e;
356
384
  const n = s / Math.max(1, Math.floor(t));
357
- for (const i of ce) if (i >= n) return i;
358
- return K * ot(n / K, 1);
385
+ for (const i of ke) if (i >= n) return i;
386
+ return K * lt(n / K, 1);
359
387
  }
360
- function Ki(s) {
361
- return new Date(s).getTimezoneOffset() * B;
388
+ function Ns(s) {
389
+ return new Date(s).getTimezoneOffset() * V;
362
390
  }
363
- function gn(s, t, e, n, i = 0) {
364
- const o = J(s), r = [];
391
+ function Wn(s, t, e, n, i = 0) {
392
+ const o = tt(s), r = [];
365
393
  if (!Number.isFinite(t) || !Number.isFinite(e) || !(n > 0)) return r;
366
394
  const l = Math.ceil((t - i) / n), a = Math.floor((e - i) / n);
367
395
  if (!Number.isFinite(l) || !Number.isFinite(a)) return r;
368
396
  let c = Number.NaN;
369
397
  for (let h = l; h <= a; h++) {
370
- const f = i + h * n, m = lt(f, o);
398
+ const f = i + h * n, m = ut(f, o);
371
399
  Number.isNaN(m) || m === c || (r.push({ wallClock: f, operatingTime: m }), c = m);
372
400
  }
373
401
  return r;
374
402
  }
375
- function Gi(s, t, e, n, i = 0) {
376
- const o = J(s);
403
+ function Is(s, t, e, n, i = 0) {
404
+ const o = tt(s);
377
405
  if (o.intervals.length === 0 || !(e > t)) return [];
378
- const r = Math.max(0, Math.min(o.total, t)), l = Math.max(0, Math.min(o.total, e)), a = xn(e - t, n);
379
- return gn(
406
+ const r = Math.max(0, Math.min(o.total, t)), l = Math.max(0, Math.min(o.total, e)), a = Rn(e - t, n);
407
+ return Wn(
380
408
  o,
381
- at(r, o),
382
- at(l, o),
409
+ ht(r, o),
410
+ ht(l, o),
383
411
  a,
384
412
  i
385
413
  ).map((h) => h.operatingTime).filter((h) => h >= t && h <= e);
386
414
  }
387
- const he = 365 * K, bn = [
388
- ...[1, 2, 5, 10, 15, 30].map((s) => ({ unit: "minute", n: s, ms: s * B })),
389
- ...[1, 2, 3, 6, 12].map((s) => ({ unit: "hour", n: s, ms: s * st })),
415
+ const we = 365 * K, zn = [
416
+ ...[1, 2, 5, 10, 15, 30].map((s) => ({ unit: "minute", n: s, ms: s * V })),
417
+ ...[1, 2, 3, 6, 12].map((s) => ({ unit: "hour", n: s, ms: s * rt })),
390
418
  ...[1, 2, 7, 14].map((s) => ({ unit: "day", n: s, ms: s * K })),
391
419
  ...[1, 2, 3, 6].map((s) => ({ unit: "month", n: s, ms: s * 30 * K }))
392
420
  ];
393
- function vn(s, t) {
421
+ function Bn(s, t) {
394
422
  const e = s / Math.max(1, Math.floor(t));
395
- for (const i of bn) if (i.ms >= e) return i;
396
- const n = Math.max(1, ot(e / he, 1));
397
- return { unit: "year", n, ms: n * he };
398
- }
399
- const Dt = { year: 0, month: 1, day: 2, hour: 3, minute: 4 };
400
- function Jt(s, t) {
401
- const e = new Date(s), n = [e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes()], i = Dt[t.unit];
402
- for (let r = i + 1; r < n.length; r++) n[r] = r === Dt.day ? 1 : 0;
423
+ for (const i of zn) if (i.ms >= e) return i;
424
+ const n = Math.max(1, lt(e / we, 1));
425
+ return { unit: "year", n, ms: n * we };
426
+ }
427
+ const zt = { year: 0, month: 1, day: 2, hour: 3, minute: 4 };
428
+ function re(s, t) {
429
+ const e = new Date(s), n = [e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes()], i = zt[t.unit];
430
+ for (let r = i + 1; r < n.length; r++) n[r] = r === zt.day ? 1 : 0;
403
431
  const o = n[i];
404
432
  if (t.unit === "day") {
405
433
  const r = Math.round(Date.UTC(n[0], n[1], o) / K);
@@ -408,209 +436,265 @@ function Jt(s, t) {
408
436
  n[i] = Math.floor(o / t.n) * t.n;
409
437
  return n;
410
438
  }
411
- function At(s, t, e) {
439
+ function Dt(s, t, e) {
412
440
  const n = s.slice();
413
- return n[Dt[t.unit]] = n[Dt[t.unit]] + e * t.n, new Date(n[0], n[1], n[2], n[3], n[4]).getTime();
441
+ return n[zt[t.unit]] = n[zt[t.unit]] + e * t.n, new Date(n[0], n[1], n[2], n[3], n[4]).getTime();
414
442
  }
415
- function de(s, t, e) {
443
+ function Ne(s, t, e) {
416
444
  const n = [];
417
445
  if (!Number.isFinite(s) || !Number.isFinite(t)) return n;
418
- const i = Jt(s, e);
446
+ const i = re(s, e);
419
447
  for (let o = 0; o < 1e3; o++) {
420
- const r = At(i, e, o);
448
+ const r = Dt(i, e, o);
421
449
  if (r > t) break;
422
450
  r >= s && !(r <= n[n.length - 1]) && n.push(r);
423
451
  }
424
452
  return n;
425
453
  }
426
- function kn(s, t, e) {
427
- const n = Jt(t, e), i = At(n, e, 0);
428
- return [At(Jt(s, e), e, 0), i < t ? At(n, e, 1) : i];
454
+ function _n(s, t, e) {
455
+ const n = re(t, e), i = Dt(n, e, 0);
456
+ return [Dt(re(s, e), e, 0), i < t ? Dt(n, e, 1) : i];
429
457
  }
430
- const Oe = new Intl.DateTimeFormat("en-GB", { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }), wn = new Intl.DateTimeFormat("en-GB", {
458
+ const Xe = new Intl.DateTimeFormat("en-GB", { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }), Vn = new Intl.DateTimeFormat("en-GB", {
431
459
  hour: "2-digit",
432
460
  minute: "2-digit",
433
461
  second: "2-digit",
434
462
  hourCycle: "h23"
435
- }), $e = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short" }), Nn = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric" }), In = new Intl.DateTimeFormat("en-GB", { month: "short", year: "numeric" }), An = new Intl.DateTimeFormat("en-GB", { year: "numeric" });
436
- function Qt(s, t = !1) {
437
- return Number.isFinite(s) ? `${$e.format(s)} ${(t ? wn : Oe).format(s)}` : "";
463
+ }), Ze = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short" }), Yn = new Intl.DateTimeFormat("en-GB", { day: "numeric", month: "short", year: "numeric" }), Gn = new Intl.DateTimeFormat("en-GB", { month: "short", year: "numeric" }), Kn = new Intl.DateTimeFormat("en-GB", { year: "numeric" });
464
+ function le(s, t = !1) {
465
+ return Number.isFinite(s) ? `${Ze.format(s)} ${(t ? Vn : Xe).format(s)}` : "";
438
466
  }
439
- function Tn(s, t) {
467
+ function qn(s, t) {
440
468
  return s.map((e, n) => {
441
469
  const i = n === 0 ? void 0 : new Date(s[n - 1]), o = new Date(e);
442
470
  switch (t.unit) {
443
471
  case "minute":
444
472
  case "hour":
445
- return i === void 0 || i.toDateString() !== o.toDateString() ? Qt(e) : Oe.format(e);
473
+ return i === void 0 || i.toDateString() !== o.toDateString() ? le(e) : Xe.format(e);
446
474
  case "day":
447
- return i === void 0 || i.getFullYear() !== o.getFullYear() ? Nn.format(e) : $e.format(e);
475
+ return i === void 0 || i.getFullYear() !== o.getFullYear() ? Yn.format(e) : Ze.format(e);
448
476
  case "month":
449
- return In.format(e);
477
+ return Gn.format(e);
450
478
  default:
451
- return An.format(e);
479
+ return Kn.format(e);
452
480
  }
453
481
  });
454
482
  }
455
- const te = 5, ee = 4, zt = 8, fe = 4, Mn = 8, rt = "uc-tick-label", wt = "uc-axis-title", Re = {
483
+ const ae = 5, ce = 4, Xt = 8, Ie = 4, Un = 8, ct = "uc-tick-label", Lt = "uc-axis-title", je = {
456
484
  width: 0,
457
485
  height: 0,
458
486
  plot: { x: 0, y: 0, width: 0, height: 0 },
459
487
  axes: []
460
488
  };
461
- function me(s, t, e) {
489
+ function Ae(s, t, e) {
462
490
  const n = Math.ceil(t), i = e.get(s);
463
- return i === void 0 || n > i || i - n >= Mn ? (e.set(s, n), n) : i;
491
+ return i === void 0 || n > i || i - n >= Un ? (e.set(s, n), n) : i;
464
492
  }
465
- function Ht(s) {
493
+ function Gt(s) {
466
494
  return s.calendar !== void 0 && s.calendar.length > 0 ? s.calendar : void 0;
467
495
  }
468
- function He(s) {
469
- return s[1] - s[0] >= B;
496
+ function Je(s) {
497
+ return s[1] - s[0] >= V;
470
498
  }
471
- function Ct(s, t) {
472
- return vn(s[1] - s[0], t);
499
+ function Bt(s, t) {
500
+ return Bn(s[1] - s[0], t);
473
501
  }
474
- function Yt(s, t) {
502
+ function Zt(s, t) {
475
503
  const e = s.domainMode;
476
504
  if (Array.isArray(e)) {
477
505
  const o = e;
478
506
  return o[0] === o[1] ? [o[0] - 1, o[1] + 1] : o;
479
507
  }
480
508
  const [n, i] = s.extent;
481
- return Ht(s) !== void 0 || e === "data" ? _t(n, i) : s.time === !0 ? He([n, i]) ? kn(n, i, Ct([n, i], t)) : _t(n, i) : an(n, i, t);
509
+ return Gt(s) !== void 0 || e === "data" ? Ut(n, i) : s.time === !0 ? Je([n, i]) ? _n(n, i, Bt([n, i], t)) : Ut(n, i) : Ln(n, i, t);
482
510
  }
483
- function pe(s, t, e) {
484
- const n = Ht(s);
511
+ function Te(s, t, e) {
512
+ const n = Gt(s);
485
513
  if (s.tickValues !== void 0)
486
- return (n !== void 0 ? s.tickValues.map((o) => lt(o, n)) : s.tickValues).filter((o) => o >= t[0] && o <= t[1]);
514
+ return (n !== void 0 ? s.tickValues.map((o) => ut(o, n)) : s.tickValues).filter((o) => o >= t[0] && o <= t[1]);
487
515
  if (n !== void 0) {
488
- const i = J(n), o = (l) => at(Math.min(Math.max(l, 0), i.total), i), r = [];
489
- for (const l of de(o(t[0]), o(t[1]), Ct(t, e))) {
490
- const a = lt(l, i);
516
+ const i = tt(n), o = (l) => ht(Math.min(Math.max(l, 0), i.total), i), r = [];
517
+ for (const l of Ne(o(t[0]), o(t[1]), Bt(t, e))) {
518
+ const a = ut(l, i);
491
519
  Number.isNaN(a) || a === r[r.length - 1] || a >= t[0] && a <= t[1] && r.push(a);
492
520
  }
493
521
  return r;
494
522
  }
495
- return s.time === !0 ? He(t) ? de(t[0], t[1], Ct(t, e)) : [] : Pe(t[0], t[1], e);
523
+ return s.time === !0 ? Je(t) ? Ne(t[0], t[1], Bt(t, e)) : [] : Ke(t[0], t[1], e);
496
524
  }
497
- function ye(s, t, e) {
498
- const n = s.tickFormat, i = Ht(s);
525
+ function Me(s, t, e) {
526
+ const n = s.tickFormat, i = Gt(s);
499
527
  if (i !== void 0)
500
- return n !== void 0 ? (r) => n(at(r, i)) : (r, l) => Qt(at(r, i), l);
528
+ return n !== void 0 ? (r) => n(ht(r, i)) : (r, l) => le(ht(r, i), l);
501
529
  if (n !== void 0) return (r) => n(r);
502
- if (s.time === !0) return Qt;
503
- const o = ot(Math.abs(t[1] - t[0]), e);
504
- return (r) => Ce(r, o);
530
+ if (s.time === !0) return le;
531
+ const o = lt(Math.abs(t[1] - t[0]), e);
532
+ return (r) => Ue(r, o);
505
533
  }
506
- function xe(s, t, e, n, i) {
507
- const o = Ht(s);
534
+ function Se(s, t, e, n, i) {
535
+ const o = Gt(s);
508
536
  if (s.tickFormat !== void 0 || s.time !== !0 && o === void 0) return n.map(i);
509
- const r = o === void 0 ? n : n.map((l) => at(l, o));
510
- return Tn(r, Ct(t, e));
537
+ const r = o === void 0 ? n : n.map((l) => ht(l, o));
538
+ return qn(r, Bt(t, e));
511
539
  }
512
- function We(s, t, e) {
540
+ function Qe(s, t, e) {
513
541
  return Math.min(Math.max(s, 0), Math.max(0, e - t));
514
542
  }
515
- function Sn(s) {
516
- const { width: t, height: e, padding: n, axes: i, measure: o, hysteresis: r } = s, l = i.filter((w) => w.position === "left"), a = i.filter((w) => w.position === "right"), c = i.filter((w) => w.position === "top"), h = i.filter((w) => w.position === "bottom"), f = Math.ceil(o("0", rt).height) || 14, m = /* @__PURE__ */ new Map();
517
- for (const w of [...c, ...h]) {
518
- const L = w.label === void 0 || w.label === "" ? 0 : Math.ceil(o(w.label, wt).height) + fe;
519
- m.set(w.key, me(w.key, te + ee + f + L, r));
520
- }
521
- const p = (w, L) => {
522
- let v = 0;
523
- for (let F = 0; F < w.length; F++) {
524
- const V = w[F];
525
- V !== void 0 && (v += L.get(V.key) ?? 0, F > 0 && (v += zt));
526
- }
527
- return v;
528
- }, u = n.top + p(c, m), d = e - n.bottom - p(h, m), y = Math.max(0, d - u), g = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), k = i.find((w) => w.orientation === "y");
529
- for (const w of [...l, ...a].sort((L, v) => L === k ? -1 : v === k ? 1 : 0)) {
530
- const L = w.tickCount ?? Math.max(2, Math.round(y / 50)), v = k === void 0 ? void 0 : g.get(k.key), [F, V] = Array.isArray(w.domainMode) ? Yt(w, L) : w.extent, N = w.alignTicks === !0 && w !== k && v !== void 0 ? un(F, V, v.domain, v.values) : null, C = (N == null ? void 0 : N.domain) ?? Yt(w, L), H = (N == null ? void 0 : N.ticks) ?? pe(w, C, L), G = N === null ? ye(w, C, L) : w.tickFormat ?? ((W) => Ce(W, N.step)), Y = xe(w, C, L, H, G), X = Y.map((W) => o(W, rt).width);
531
- let $ = 0;
532
- for (const W of X) W > $ && ($ = W);
533
- for (const W of w.limitLabels ?? []) $ = Math.max($, o(W, rt).width + 4);
534
- const Z = w.label === void 0 || w.label === "" ? 0 : Math.ceil(o(w.label, wt).height) + fe;
535
- g.set(w.key, { axis: w, domain: C, values: H, labels: Y, widths: X, format: G }), b.set(
536
- w.key,
537
- me(w.key, te + ee + $ + Z, r)
543
+ function Xn(s) {
544
+ const { width: t, height: e, padding: n, axes: i, measure: o, hysteresis: r } = s, l = i.filter((I) => I.position === "left"), a = i.filter((I) => I.position === "right"), c = i.filter((I) => I.position === "top"), h = i.filter((I) => I.position === "bottom"), f = Math.ceil(o("0", ct).height) || 14, m = /* @__PURE__ */ new Map();
545
+ for (const I of [...c, ...h]) {
546
+ const P = I.label === void 0 || I.label === "" ? 0 : Math.ceil(o(I.label, Lt).height) + Ie;
547
+ m.set(I.key, Ae(I.key, ae + ce + f + P, r));
548
+ }
549
+ const p = (I, P) => {
550
+ let N = 0;
551
+ for (let F = 0; F < I.length; F++) {
552
+ const B = I[F];
553
+ B !== void 0 && (N += P.get(B.key) ?? 0, F > 0 && (N += Xt));
554
+ }
555
+ return N;
556
+ }, u = n.top + p(c, m), g = e - n.bottom - p(h, m), d = Math.max(0, g - u), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), v = i.find((I) => I.orientation === "y");
557
+ for (const I of [...l, ...a].sort((P, N) => P === v ? -1 : N === v ? 1 : 0)) {
558
+ const P = I.tickCount ?? Math.max(2, Math.round(d / 50)), N = v === void 0 ? void 0 : y.get(v.key), [F, B] = Array.isArray(I.domainMode) ? Zt(I, P) : I.extent, E = I.alignTicks === !0 && I !== v && N !== void 0 ? En(F, B, N.domain, N.values) : null, M = (E == null ? void 0 : E.domain) ?? Zt(I, P), C = (E == null ? void 0 : E.ticks) ?? Te(I, M, P), q = E === null ? Me(I, M, P) : I.tickFormat ?? ((W) => Ue(W, E.step)), Y = Se(I, M, P, C, q), Z = Y.map((W) => o(W, ct).width);
559
+ let R = 0;
560
+ for (const W of Z) W > R && (R = W);
561
+ for (const W of I.limitLabels ?? []) R = Math.max(R, o(W, ct).width + 4);
562
+ const j = I.label === void 0 || I.label === "" ? 0 : Math.ceil(o(I.label, Lt).height) + Ie;
563
+ y.set(I.key, { axis: I, domain: M, values: C, labels: Y, widths: Z, format: q }), b.set(
564
+ I.key,
565
+ Ae(I.key, ae + ce + R + j, r)
538
566
  );
539
567
  }
540
- const T = n.left + p(l, b), O = t - n.right - p(a, b), A = Math.max(0, O - T), E = { x: T, y: u, width: A, height: y }, S = (w, L, v, F) => {
541
- switch (w.position) {
568
+ const w = n.left + p(l, b), L = t - n.right - p(a, b), A = Math.max(0, L - w), z = { x: w, y: u, width: A, height: d }, T = (I, P, N, F) => {
569
+ switch (I.position) {
542
570
  case "left":
543
- return { x: T - v - F, y: u, width: F, height: y };
571
+ return { x: w - N - F, y: u, width: F, height: d };
544
572
  case "right":
545
- return { x: O + v, y: u, width: F, height: y };
573
+ return { x: L + N, y: u, width: F, height: d };
546
574
  case "top":
547
- return { x: T, y: u - v - F, width: A, height: F };
575
+ return { x: w, y: u - N - F, width: A, height: F };
548
576
  default:
549
- return { x: T, y: d + v, width: A, height: F };
550
- }
551
- }, M = [], _ = (w) => {
552
- let L = 0;
553
- w.forEach((v, F) => {
554
- const V = b.get(v.key) ?? 0, N = g.get(v.key), C = S(v, F, L, V);
555
- L += V + zt;
556
- const H = (N == null ? void 0 : N.domain) ?? [0, 1], G = (N == null ? void 0 : N.format) ?? (($) => String($)), Y = new ae(H, [u + y, u]), X = ((N == null ? void 0 : N.values) ?? []).map(($, Z) => ({
557
- value: $,
558
- label: (N == null ? void 0 : N.labels[Z]) ?? "",
559
- px: Y.toPx($),
577
+ return { x: w, y: g + N, width: A, height: F };
578
+ }
579
+ }, S = [], _ = (I) => {
580
+ let P = 0;
581
+ I.forEach((N, F) => {
582
+ const B = b.get(N.key) ?? 0, E = y.get(N.key), M = T(N, F, P, B);
583
+ P += B + Xt;
584
+ const C = (E == null ? void 0 : E.domain) ?? [0, 1], q = (E == null ? void 0 : E.format) ?? ((R) => String(R)), Y = new be(C, [u + d, u]), Z = ((E == null ? void 0 : E.values) ?? []).map((R, j) => ({
585
+ value: R,
586
+ label: (E == null ? void 0 : E.labels[j]) ?? "",
587
+ px: Y.toPx(R),
560
588
  labelLeft: 0,
561
- labelWidth: (N == null ? void 0 : N.widths[Z]) ?? 0
589
+ labelWidth: (E == null ? void 0 : E.widths[j]) ?? 0
562
590
  }));
563
- M.push({
564
- key: v.key,
565
- id: v.id,
591
+ S.push({
592
+ key: N.key,
593
+ id: N.id,
566
594
  orientation: "y",
567
- position: v.position,
568
- label: v.label,
569
- grid: v.grid,
570
- band: C,
571
- size: V,
595
+ position: N.position,
596
+ label: N.label,
597
+ grid: N.grid,
598
+ band: M,
599
+ size: B,
572
600
  stack: F,
573
- domain: H,
601
+ domain: C,
574
602
  scale: Y,
575
- ticks: X,
576
- format: G,
577
- titleSize: v.label === void 0 || v.label === "" ? 0 : Math.ceil(o(v.label, wt).height),
603
+ ticks: Z,
604
+ format: q,
605
+ titleSize: N.label === void 0 || N.label === "" ? 0 : Math.ceil(o(N.label, Lt).height),
578
606
  breaks: []
579
607
  });
580
608
  });
581
609
  };
582
610
  _(l), _(a);
583
- const U = (w) => {
584
- let L = 0;
585
- w.forEach((v, F) => {
586
- const V = m.get(v.key) ?? 0, N = S(v, F, L, V);
587
- L += V + zt;
588
- const C = v.tickCount ?? Math.max(2, Math.round(A / 80)), H = Yt(v, C), G = pe(v, H, C), Y = ye(v, H, C), X = xe(v, H, C, G, Y), $ = new ae(H, [T, T + A]), Z = G.map((W, Q) => {
589
- const et = X[Q] ?? "", nt = o(et, rt).width, dt = $.toPx(W), qe = We(dt - nt / 2, nt, t);
590
- return { value: W, label: et, px: dt, labelLeft: qe, labelWidth: nt };
611
+ const X = (I) => {
612
+ let P = 0;
613
+ I.forEach((N, F) => {
614
+ const B = m.get(N.key) ?? 0, E = T(N, F, P, B);
615
+ P += B + Xt;
616
+ const M = N.tickCount ?? Math.max(2, Math.round(A / 80)), C = Zt(N, M), q = Te(N, C, M), Y = Me(N, C, M), Z = Se(N, C, M, q, Y), R = new be(C, [w, w + A]), j = q.map((W, At) => {
617
+ const J = Z[At] ?? "", et = o(J, ct).width, at = R.toPx(W), Tt = Qe(at - et / 2, et, t);
618
+ return { value: W, label: J, px: at, labelLeft: Tt, labelWidth: et };
591
619
  });
592
- M.push({
593
- key: v.key,
594
- id: v.id,
620
+ S.push({
621
+ key: N.key,
622
+ id: N.id,
595
623
  orientation: "x",
596
- position: v.position,
597
- label: v.label,
598
- grid: v.grid,
599
- band: N,
600
- size: V,
624
+ position: N.position,
625
+ label: N.label,
626
+ grid: N.grid,
627
+ band: E,
628
+ size: B,
601
629
  stack: F,
602
- domain: H,
603
- scale: $,
604
- ticks: Z,
630
+ domain: C,
631
+ scale: R,
632
+ ticks: j,
605
633
  format: Y,
606
- titleSize: v.label === void 0 || v.label === "" ? 0 : Math.ceil(o(v.label, wt).height),
607
- breaks: v.calendar === void 0 || v.calendar.length === 0 ? [] : yn(v.calendar, H[0], H[1]).map((W) => $.toPx(W))
634
+ titleSize: N.label === void 0 || N.label === "" ? 0 : Math.ceil(o(N.label, Lt).height),
635
+ breaks: N.calendar === void 0 || N.calendar.length === 0 ? [] : Hn(N.calendar, C[0], C[1]).map((W) => R.toPx(W))
608
636
  });
609
637
  });
610
638
  };
611
- return U(c), U(h), { width: t, height: e, plot: E, axes: M };
639
+ return X(c), X(h), { width: t, height: e, plot: z, axes: S };
640
+ }
641
+ const Le = [[], [7, 4], [1, 4], [7, 3, 1, 3], [14, 4], [7, 3, 1, 3, 1, 3]], Zn = ["circle", "square", "triangle", "diamond", "triangleDown", "plus"], ue = ["none", "rising", "falling", "horizontal", "vertical", "crossed"];
642
+ function jn(s) {
643
+ const t = tn(s, Le.length);
644
+ return { dash: Le[t], marker: Zn[t], hatch: ue[t] };
645
+ }
646
+ function Pt(s) {
647
+ return ue[tn(s, ue.length)];
648
+ }
649
+ function Jn(s) {
650
+ const t = /* @__PURE__ */ new Map();
651
+ for (const e of s) for (const { label: n } of e) t.has(n) || t.set(n, Pt(t.size));
652
+ return t;
653
+ }
654
+ function tn(s, t) {
655
+ return (s % t + t) % t;
656
+ }
657
+ function en(s, t, e) {
658
+ const n = [];
659
+ if (t === "none" || !(e > 0) || !(s.width > 0) || !(s.height > 0)) return n;
660
+ const { x: i, y: o, width: r, height: l } = s, a = (c) => Math.ceil(c / e) * e;
661
+ if (t === "rising" || t === "crossed")
662
+ for (let c = a(i + o); c <= i + r + o + l; c += e) n.push(c - o - l, o + l, c - o, o);
663
+ if (t === "falling" || t === "crossed")
664
+ for (let c = a(i - o - l); c <= i + r - o; c += e) n.push(c + o, o, c + o + l, o + l);
665
+ if (t === "horizontal")
666
+ for (let c = a(o); c <= o + l; c += e) n.push(i, c, i + r, c);
667
+ if (t === "vertical")
668
+ for (let c = a(i); c <= i + r; c += e) n.push(c, o, c, o + l);
669
+ return n;
670
+ }
671
+ function pe(s, t, e, n, i) {
672
+ const o = (r) => {
673
+ r.forEach(([l, a], c) => c === 0 ? s.moveTo(e + l * i, n + a * i) : s.lineTo(e + l * i, n + a * i)), s.closePath();
674
+ };
675
+ switch (t) {
676
+ case "circle":
677
+ s.moveTo(e + i, n), s.arc(e, n, i, 0, Math.PI * 2);
678
+ return;
679
+ case "square":
680
+ o([[-0.89, -0.89], [0.89, -0.89], [0.89, 0.89], [-0.89, 0.89]]);
681
+ return;
682
+ case "triangle":
683
+ o([[0, -1.35], [1.17, 0.68], [-1.17, 0.68]]);
684
+ return;
685
+ case "triangleDown":
686
+ o([[0, 1.35], [1.17, -0.68], [-1.17, -0.68]]);
687
+ return;
688
+ case "diamond":
689
+ o([[0, -1.25], [1.25, 0], [0, 1.25], [-1.25, 0]]);
690
+ return;
691
+ case "plus": {
692
+ o([[-0.42, -1.2], [0.42, -1.2], [0.42, -0.42], [1.2, -0.42], [1.2, 0.42], [0.42, 0.42], [0.42, 1.2], [-0.42, 1.2], [-0.42, 0.42], [-1.2, 0.42], [-1.2, -0.42], [-0.42, -0.42]]);
693
+ return;
694
+ }
695
+ }
612
696
  }
613
- function ge(s, t, e) {
697
+ function Ee(s, t, e) {
614
698
  if (t <= 0 || !(e >= s[0])) return -1;
615
699
  let n = 0, i = t - 1;
616
700
  if (s[i] <= e) return i;
@@ -620,14 +704,14 @@ function ge(s, t, e) {
620
704
  }
621
705
  return n;
622
706
  }
623
- function Ve(s, t, e, n) {
707
+ function nn(s, t, e, n) {
624
708
  return e + 1 < t ? s[e + 1] : n;
625
709
  }
626
- function En(s, t, e, n, i) {
710
+ function Qn(s, t, e, n, i) {
627
711
  const o = s[t - 1], r = e > o ? e : n > 0 ? o + n : i;
628
712
  return Math.min(r, i);
629
713
  }
630
- function Ln(s, t) {
714
+ function ti(s, t) {
631
715
  const e = [];
632
716
  for (let n = 1; n < t; n++) {
633
717
  const i = s[n] - s[n - 1];
@@ -635,10 +719,10 @@ function Ln(s, t) {
635
719
  }
636
720
  return e.length === 0 ? 0 : (e.sort((n, i) => n - i), e[e.length - 1 >> 1]);
637
721
  }
638
- function xt(s) {
722
+ function vt(s) {
639
723
  return Math.round(s) + 0.5;
640
724
  }
641
- function Fn(s, t) {
725
+ function ei(s, t) {
642
726
  const { plot: e, axes: n, theme: i } = t, o = e.x, r = e.x + e.width, l = e.y, a = e.y + e.height;
643
727
  s.lineWidth = 1;
644
728
  for (const c of n)
@@ -650,182 +734,197 @@ function Fn(s, t) {
650
734
  for (const p of c.ticks)
651
735
  if ((c.orientation === "y" && p.value === 0) === f)
652
736
  if (m = !0, c.orientation === "y") {
653
- const d = xt(p.px);
654
- s.moveTo(o, d), s.lineTo(r, d);
737
+ const g = vt(p.px);
738
+ s.moveTo(o, g), s.lineTo(r, g);
655
739
  } else {
656
- const d = xt(p.px);
657
- s.moveTo(d, l), s.lineTo(d, a);
740
+ const g = vt(p.px);
741
+ s.moveTo(g, l), s.lineTo(g, a);
658
742
  }
659
743
  m && (s.strokeStyle = f ? i.colorAxis : i.colorGrid, s.stroke());
660
744
  }
661
745
  }
662
- const Pn = 60;
663
- function Dn(s, t, e) {
746
+ const ni = 6;
747
+ function Nt(s, t, e, n, i) {
748
+ if (n === "none") return;
749
+ const o = en(e, n, ni), r = new Path2D();
750
+ for (let l = 0; l < o.length; l += 4)
751
+ r.moveTo(o[l], o[l + 1]), r.lineTo(o[l + 2], o[l + 3]);
752
+ s.save(), s.clip(t), s.strokeStyle = i, s.lineWidth = 1, s.setLineDash([]), s.stroke(r), s.restore();
753
+ }
754
+ const ii = 60;
755
+ function si(s, t, e) {
664
756
  return (e === 0 || Number.isNaN(s[e - 1])) && (e === t - 1 || Number.isNaN(s[e + 1]));
665
757
  }
666
- function Cn(s, t) {
758
+ function oi(s, t) {
667
759
  const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.step === !0, h = new Path2D();
668
760
  let f = !1, m = 0;
669
761
  for (let p = 0; p < e; p++) {
670
- const u = a[p], d = l[p] * n + i;
762
+ const u = a[p], g = l[p] * n + i;
671
763
  if (Number.isNaN(u)) {
672
- c && f && h.lineTo(d, m), f = !1;
764
+ c && f && h.lineTo(g, m), f = !1;
673
765
  continue;
674
766
  }
675
- const y = u * o + r;
676
- f ? (c && h.lineTo(d, m), h.lineTo(d, y)) : (h.moveTo(d, y), f = !0), m = y;
767
+ const d = u * o + r;
768
+ f ? (c && h.lineTo(g, m), h.lineTo(g, d)) : (h.moveTo(g, d), f = !0), m = d;
677
769
  }
678
770
  if (s.strokeStyle = t.color, s.lineWidth = t.strokeWidth, t.dash !== void 0 && t.dash.length > 0 ? s.setLineDash(t.dash) : s.setLineDash([]), s.stroke(h), s.setLineDash([]), t.markers !== "never") {
679
- const p = t.markers === "always" || e <= Pn, u = t.strokeWidth + 1.5, d = new Path2D();
771
+ const p = t.markers === "always" || e <= ii, u = t.strokeWidth + 1.5, g = t.marker ?? "circle", d = new Path2D();
680
772
  for (let y = 0; y < e; y++) {
681
- const g = a[y];
682
- if (Number.isNaN(g) || !p && !Dn(a, e, y)) continue;
683
- const b = l[y] * n + i, k = g * o + r;
684
- d.moveTo(b + u, k), d.arc(b, k, u, 0, Math.PI * 2);
773
+ const b = a[y];
774
+ if (Number.isNaN(b) || !p && !si(a, e, y)) continue;
775
+ const v = l[y] * n + i, w = b * o + r;
776
+ pe(d, g, v, w, u);
685
777
  }
686
778
  s.fillStyle = t.color, s.fill(d);
687
779
  }
688
780
  }
689
- function On(s, t) {
690
- const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.y0, h = t.baseline * o + r, f = new Path2D(), m = new Path2D(), p = new Path2D();
691
- let u = 0;
692
- for (; u < e; ) {
693
- for (; u < e && (Number.isNaN(a[u]) || c !== null && Number.isNaN(c[u])); )
694
- u++;
695
- if (u >= e) break;
696
- const d = u;
697
- for (; u < e && !Number.isNaN(a[u]) && (c === null || !Number.isNaN(c[u])); )
698
- u++;
699
- const y = u - 1;
700
- if (d === y) {
701
- const g = l[d] * n + i;
702
- p.moveTo(g, c === null ? h : c[d] * o + r), p.lineTo(g, a[d] * o + r);
781
+ function ri(s, t, e, n) {
782
+ const i = t.length, o = t.xScale.m, r = t.xScale.b, l = t.yScale.m, a = t.yScale.b, c = t.x, h = t.y, f = t.y0, m = t.baseline * l + a, p = new Path2D(), u = new Path2D(), g = new Path2D();
783
+ let d = 0;
784
+ for (; d < i; ) {
785
+ for (; d < i && (Number.isNaN(h[d]) || f !== null && Number.isNaN(f[d])); )
786
+ d++;
787
+ if (d >= i) break;
788
+ const y = d;
789
+ for (; d < i && !Number.isNaN(h[d]) && (f === null || !Number.isNaN(f[d])); )
790
+ d++;
791
+ const b = d - 1;
792
+ if (y === b) {
793
+ const v = c[y] * o + r;
794
+ g.moveTo(v, f === null ? m : f[y] * l + a), g.lineTo(v, h[y] * l + a);
703
795
  continue;
704
796
  }
705
- for (let g = d; g <= y; g++) {
706
- const b = l[g] * n + i, k = a[g] * o + r;
707
- g === d ? (f.moveTo(b, k), m.moveTo(b, k)) : (f.lineTo(b, k), m.lineTo(b, k));
797
+ for (let v = y; v <= b; v++) {
798
+ const w = c[v] * o + r, L = h[v] * l + a;
799
+ v === y ? (p.moveTo(w, L), u.moveTo(w, L)) : (p.lineTo(w, L), u.lineTo(w, L));
708
800
  }
709
- if (c === null)
710
- f.lineTo(l[y] * n + i, h), f.lineTo(l[d] * n + i, h);
801
+ if (f === null)
802
+ p.lineTo(c[b] * o + r, m), p.lineTo(c[y] * o + r, m);
711
803
  else
712
- for (let g = y; g >= d; g--)
713
- f.lineTo(l[g] * n + i, c[g] * o + r);
714
- f.closePath();
804
+ for (let v = b; v >= y; v--)
805
+ p.lineTo(c[v] * o + r, f[v] * l + a);
806
+ p.closePath();
715
807
  }
716
- s.globalAlpha = t.alpha * t.fillOpacity, s.fillStyle = t.color, s.fill(f), s.globalAlpha = t.alpha, s.strokeStyle = t.color, t.strokeWidth > 0 && (s.setLineDash(t.dash ?? []), s.lineWidth = t.strokeWidth, s.stroke(m)), s.setLineDash([]), s.lineWidth = Math.max(1, t.strokeWidth), s.stroke(p);
808
+ s.globalAlpha = t.alpha * t.fillOpacity, s.fillStyle = t.color, s.fill(p), s.globalAlpha = t.alpha, Nt(s, p, e, t.hatch ?? "none", t.color), t.edges === !0 && (s.setLineDash([]), s.strokeStyle = n, s.lineWidth = t.strokeWidth + 2, s.stroke(u)), s.strokeStyle = t.color, t.strokeWidth > 0 && (s.setLineDash(t.dash ?? []), s.lineWidth = t.strokeWidth, s.stroke(u)), s.setLineDash([]), s.lineWidth = Math.max(1, t.strokeWidth), s.stroke(g);
717
809
  }
718
- function $n(s, t) {
719
- const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.baseline * o + r, h = t.offset * n, f = t.width * n, m = new Path2D();
720
- for (let p = 0; p < e; p++) {
721
- const u = a[p];
722
- if (Number.isNaN(u)) continue;
723
- const d = l[p] * n + i + h, y = u * o + r;
724
- m.rect(d, y, f, c - y);
810
+ function li(s, t, e, n) {
811
+ const i = t.length, o = t.xScale.m, r = t.xScale.b, l = t.yScale.m, a = t.yScale.b, c = t.x, h = t.y, f = t.y0, m = t.baseline * l + a, p = t.offset * o, u = t.width * o, g = new Path2D(), d = t.edges === !0 && f !== null ? new Path2D() : null;
812
+ for (let y = 0; y < i; y++) {
813
+ const b = h[y];
814
+ if (Number.isNaN(b)) continue;
815
+ const v = c[y] * o + r + p, w = b * l + a, L = f === null ? m : f[y] * l + a;
816
+ g.rect(v, w, u, L - w), d !== null && (f == null ? void 0 : f[y]) !== 0 && (d.moveTo(v, L), d.lineTo(v + u, L));
725
817
  }
726
- s.fillStyle = t.color, s.fill(m);
818
+ s.fillStyle = t.color, s.fill(g), Nt(s, g, e, t.hatch ?? "none", n), d !== null && (s.strokeStyle = n, s.lineWidth = 1, s.setLineDash([]), s.stroke(d));
727
819
  }
728
- function Rn(s, t) {
729
- const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.radius, h = new Path2D();
730
- for (let f = 0; f < e; f++) {
731
- const m = a[f];
732
- if (Number.isNaN(m)) continue;
733
- const p = l[f] * n + i, u = m * o + r;
734
- h.moveTo(p + c, u), h.arc(p, u, c, 0, Math.PI * 2);
735
- }
736
- s.fillStyle = t.color, s.fill(h);
737
- }
738
- function Hn(s, t) {
739
- const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.x, r = t.y, l = t.laneTop, a = t.laneBottom - t.laneTop, c = t.colors.length;
740
- if (c === 0 || a <= 0) return;
741
- const h = [];
742
- for (let m = 0; m < c; m++) h.push(new Path2D());
743
- let f = !1;
820
+ function ai(s, t) {
821
+ const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.radius, h = t.marker ?? "circle", f = new Path2D();
744
822
  for (let m = 0; m < e; m++) {
745
- const p = r[m];
823
+ const p = a[m];
746
824
  if (Number.isNaN(p)) continue;
747
- const u = p | 0, d = h[u];
748
- if (d === void 0) continue;
749
- const y = o[m], g = Ve(o, e, m, t.lastEnd);
750
- g > y && (d.rect(y * n + i, l, (g - y) * n, a), f = !0);
751
- }
752
- if (f)
753
- for (let m = 0; m < c; m++)
754
- s.fillStyle = t.colors[m], s.fill(h[m]);
755
- }
756
- function Wn(s, t) {
757
- const e = t.length, n = t.xScale.m, i = t.xScale.b, o = t.yScale.m, r = t.yScale.b, l = t.x, a = t.y, c = t.buckets, h = t.colors.length;
758
- if (h === 0) return;
759
- const f = t.width * n, m = Math.abs(t.height * o), p = [];
760
- for (let u = 0; u < h; u++) p.push(new Path2D());
761
- for (let u = 0; u < e; u++) {
762
- const d = c[u];
763
- if (d < 0) continue;
764
- const y = p[d];
765
- if (y === void 0) continue;
766
- const g = l[u] * n + i - f / 2, b = a[u] * o + r - m / 2;
767
- y.rect(g, b, f, m);
768
- }
769
- for (let u = 0; u < h; u++)
770
- s.fillStyle = t.colors[u], s.fill(p[u]);
771
- }
772
- function be(s, t, e) {
825
+ const u = l[m] * n + i, g = p * o + r;
826
+ pe(f, h, u, g, c);
827
+ }
828
+ s.fillStyle = t.color, s.fill(f);
829
+ }
830
+ function ci(s, t, e, n) {
831
+ var u;
832
+ const i = t.length, o = t.xScale.m, r = t.xScale.b, l = t.x, a = t.y, c = t.laneTop, h = t.laneBottom - t.laneTop, f = t.colors.length;
833
+ if (f === 0 || h <= 0) return;
834
+ const m = [];
835
+ for (let g = 0; g < f; g++) m.push(new Path2D());
836
+ let p = !1;
837
+ for (let g = 0; g < i; g++) {
838
+ const d = a[g];
839
+ if (Number.isNaN(d)) continue;
840
+ const y = d | 0, b = m[y];
841
+ if (b === void 0) continue;
842
+ const v = l[g], w = nn(l, i, g, t.lastEnd);
843
+ w > v && (b.rect(v * o + r, c, (w - v) * o, h), p = !0);
844
+ }
845
+ if (p)
846
+ for (let g = 0; g < f; g++)
847
+ s.fillStyle = t.colors[g], s.fill(m[g]), Nt(s, m[g], e, ((u = t.hatches) == null ? void 0 : u[g]) ?? "none", n);
848
+ }
849
+ function ui(s, t, e, n) {
850
+ var d;
851
+ const i = t.length, o = t.xScale.m, r = t.xScale.b, l = t.yScale.m, a = t.yScale.b, c = t.x, h = t.y, f = t.buckets, m = t.colors.length;
852
+ if (m === 0) return;
853
+ const p = t.width * o, u = Math.abs(t.height * l), g = [];
854
+ for (let y = 0; y < m; y++) g.push(new Path2D());
855
+ for (let y = 0; y < i; y++) {
856
+ const b = f[y];
857
+ if (b < 0) continue;
858
+ const v = g[b];
859
+ if (v === void 0) continue;
860
+ const w = c[y] * o + r - p / 2, L = h[y] * l + a - u / 2;
861
+ v.rect(w, L, p, u);
862
+ }
863
+ for (let y = 0; y < m; y++)
864
+ s.fillStyle = t.colors[y], s.fill(g[y]), Nt(s, g[y], e, ((d = t.hatches) == null ? void 0 : d[y]) ?? "none", n);
865
+ }
866
+ function Fe(s, t, e) {
773
867
  for (const n of e) {
774
868
  if (n.band) {
775
869
  const i = Math.min(n.fromPx, n.toPx), o = Math.max(n.fromPx, n.toPx);
776
- s.fillStyle = n.color, s.save(), s.globalAlpha = 0.12, n.orientation === "y" ? s.fillRect(t.x, i, t.width, o - i) : s.fillRect(i, t.y, o - i, t.height), s.restore();
870
+ if (s.fillStyle = n.color, s.save(), s.globalAlpha = 0.12, n.hatch !== !0) {
871
+ n.orientation === "y" ? s.fillRect(t.x, i, t.width, o - i) : s.fillRect(i, t.y, o - i, t.height), s.restore();
872
+ continue;
873
+ }
874
+ const r = new Path2D();
875
+ n.orientation === "y" ? r.rect(t.x, i, t.width, o - i) : r.rect(i, t.y, o - i, t.height), s.fill(r), s.globalAlpha = 0.5, Nt(s, r, t, "rising", n.color), s.restore();
777
876
  continue;
778
877
  }
779
878
  if (s.beginPath(), n.orientation === "y") {
780
- const i = xt(n.fromPx);
879
+ const i = vt(n.fromPx);
781
880
  s.moveTo(t.x, i), s.lineTo(t.x + t.width, i);
782
881
  } else {
783
- const i = xt(n.fromPx);
882
+ const i = vt(n.fromPx);
784
883
  s.moveTo(i, t.y), s.lineTo(i, t.y + t.height);
785
884
  }
786
885
  s.strokeStyle = n.color, s.lineWidth = 1, s.setLineDash(n.dash), s.stroke(), s.setLineDash([]);
787
886
  }
788
887
  }
789
- function Vn(s, t) {
888
+ function hi(s, t) {
790
889
  const { width: e, height: n, plot: i, series: o } = t;
791
890
  if (s.clearRect(0, 0, e, n), !(i.width <= 0 || i.height <= 0)) {
792
- Fn(s, t), s.save(), s.beginPath(), s.rect(i.x, i.y, i.width, i.height), s.clip(), s.lineJoin = "round", s.lineCap = "round", s.globalAlpha = 1, be(s, i, t.limitBands);
891
+ ei(s, t), s.save(), s.beginPath(), s.rect(i.x, i.y, i.width, i.height), s.clip(), s.lineJoin = "round", s.lineCap = "round", s.globalAlpha = 1, Fe(s, i, t.limitBands);
793
892
  for (const r of o)
794
893
  if (r.length !== 0)
795
894
  switch (s.globalAlpha = r.alpha, r.kind) {
796
895
  case "line":
797
- Cn(s, r);
896
+ oi(s, r);
798
897
  break;
799
898
  case "area":
800
- On(s, r);
899
+ ri(s, r, i, t.theme.colorBg);
801
900
  break;
802
901
  case "bar":
803
- $n(s, r);
902
+ li(s, r, i, t.theme.colorBg);
804
903
  break;
805
904
  case "scatter":
806
- Rn(s, r);
905
+ ai(s, r);
807
906
  break;
808
907
  case "state":
809
- Hn(s, r);
908
+ ci(s, r, i, t.theme.colorBg);
810
909
  break;
811
910
  case "matrix":
812
- Wn(s, r);
911
+ ui(s, r, i, t.theme.colorBg);
813
912
  break;
814
913
  }
815
- s.globalAlpha = 1, be(s, i, t.limitLines), s.restore();
914
+ s.globalAlpha = 1, Fe(s, i, t.limitLines), s.restore();
816
915
  }
817
916
  }
818
- function _n(s, t) {
917
+ function di(s, t) {
819
918
  const { width: e, height: n, plot: i, theme: o, hover: r } = t;
820
919
  s.clearRect(0, 0, e, n);
821
920
  const l = (r == null ? void 0 : r.hit.xPx) ?? t.syncPx;
822
921
  if (l === null || i.width <= 0 || i.height <= 0) return;
823
- const a = xt(l);
922
+ const a = vt(l);
824
923
  a >= i.x && a <= i.x + i.width && (s.beginPath(), s.moveTo(a, i.y), s.lineTo(a, i.y + i.height), s.lineWidth = 1, s.strokeStyle = o.colorAxis, s.setLineDash([]), s.stroke());
825
924
  for (const c of (r == null ? void 0 : r.marker) ?? [])
826
925
  c.x < i.x || c.x > i.x + i.width || c.y < i.y || c.y > i.y + i.height || (s.beginPath(), s.arc(c.x, c.y, 5.5, 0, Math.PI * 2), s.fillStyle = o.colorBg, s.fill(), s.beginPath(), s.arc(c.x, c.y, 3.5, 0, Math.PI * 2), s.fillStyle = c.color, s.fill());
827
926
  }
828
- function ne(s, t, e) {
927
+ function he(s, t, e) {
829
928
  if (t <= 0) return -1;
830
929
  if (t === 1) return 0;
831
930
  let n = 0, i = t - 1;
@@ -838,7 +937,7 @@ function ne(s, t, e) {
838
937
  const o = e - s[n];
839
938
  return s[i] - e < o ? i : n;
840
939
  }
841
- function ut(s, t, e) {
940
+ function it(s, t, e) {
842
941
  let n = 0, i = t;
843
942
  for (; n < i; ) {
844
943
  const o = n + i >> 1;
@@ -846,8 +945,8 @@ function ut(s, t, e) {
846
945
  }
847
946
  return n;
848
947
  }
849
- function zn(s, t, e, n, i, o, r) {
850
- const l = ne(s, e, n);
948
+ function fi(s, t, e, n, i, o, r) {
949
+ const l = he(s, e, n);
851
950
  if (l < 0) return -1;
852
951
  const a = o.toPx(n), c = r.toPx(i);
853
952
  let h = -1, f = Number.POSITIVE_INFINITY;
@@ -856,51 +955,59 @@ function zn(s, t, e, n, i, o, r) {
856
955
  if (p * p > f) break;
857
956
  const u = t[m];
858
957
  if (Number.isNaN(u)) continue;
859
- const d = r.toPx(u) - c, y = p * p + d * d;
860
- y < f && (f = y, h = m);
958
+ const g = r.toPx(u) - c, d = p * p + g * g;
959
+ d < f && (f = d, h = m);
861
960
  }
862
961
  for (let m = l + 1; m < e; m++) {
863
962
  const p = o.toPx(s[m]) - a;
864
963
  if (p * p > f) break;
865
964
  const u = t[m];
866
965
  if (Number.isNaN(u)) continue;
867
- const d = r.toPx(u) - c, y = p * p + d * d;
868
- y < f && (f = y, h = m);
966
+ const g = r.toPx(u) - c, d = p * p + g * g;
967
+ d < f && (f = d, h = m);
869
968
  }
870
969
  return h;
871
970
  }
872
- const _e = {
971
+ const sn = {
873
972
  roleDescription: "chart",
874
973
  empty: "No data",
875
974
  seriesList: (s) => `${s.length === 1 ? "1 series" : `${s.length} series`}: ${s.join(", ")}.`,
876
975
  visibleRange: (s, t) => `From ${s} to ${t}.`,
877
976
  seriesExtent: (s, t, e) => `${s} from ${t} to ${e}.`,
878
977
  readout: (s, t) => [`${s}.`, ...t.map((e) => `${e.name} ${e.value}${e.x === "" ? "" : ` at ${e.x}`}.`)].join(" "),
978
+ stackTotal: "Total",
979
+ percent: (s) => `${s}%`,
879
980
  walkHelp: "Left and right arrows move through the values, up and down change the series, Home and End go to the first and the last, Escape clears.",
880
- zoomHelp: "Plus and minus zoom, Shift with left or right pans, 0 shows everything."
881
- }, bt = (s, t) => !Number.isNaN(s.y[t]) && (s.w === null || Number.isFinite(s.w[t])) && (s.changesOnly !== !0 || t === 0 || s.y[t] !== s.y[t - 1]);
882
- function Tt(s, t, e) {
981
+ zoomHelp: "Plus and minus zoom, Shift with left or right pans, 0 shows everything.",
982
+ showData: "Show data",
983
+ hideData: "Hide data",
984
+ positionColumn: "Position",
985
+ rowColumn: "Row",
986
+ tableCaption: (s, t) => `Values from ${s} to ${t}.`,
987
+ downsampled: (s) => `Downsampled from ${s.toLocaleString("en-GB")} readings: the first, lowest, highest and last value of each stretch.`
988
+ }, It = (s, t) => !Number.isNaN(s.y[t]) && (s.w === null || Number.isFinite(s.w[t])) && (s.changesOnly !== !0 || t === 0 || s.y[t] !== s.y[t - 1]);
989
+ function Ct(s, t, e) {
883
990
  let n = Number.POSITIVE_INFINITY;
884
991
  for (const i of s)
885
- for (let o = ut(i.x, i.length, t); o < i.length; o++) {
992
+ for (let o = it(i.x, i.length, t); o < i.length; o++) {
886
993
  const r = i.x[o];
887
994
  if (r >= n) break;
888
- if (!(e && r === t || !bt(i, o))) {
995
+ if (!(e && r === t || !It(i, o))) {
889
996
  n = r;
890
997
  break;
891
998
  }
892
999
  }
893
1000
  return n;
894
1001
  }
895
- function Mt(s, t, e) {
1002
+ function $t(s, t, e) {
896
1003
  let n = Number.NEGATIVE_INFINITY;
897
1004
  for (const i of s) {
898
- let o = ut(i.x, i.length, t) - 1;
1005
+ let o = it(i.x, i.length, t) - 1;
899
1006
  if (!e) for (; o + 1 < i.length && i.x[o + 1] === t; ) o++;
900
1007
  for (; o >= 0; o--) {
901
1008
  const r = i.x[o];
902
1009
  if (r <= n) break;
903
- if (bt(i, o)) {
1010
+ if (It(i, o)) {
904
1011
  n = r;
905
1012
  break;
906
1013
  }
@@ -908,10 +1015,10 @@ function Mt(s, t, e) {
908
1015
  }
909
1016
  return n;
910
1017
  }
911
- const St = (s, [t, e]) => s >= t && s <= e;
912
- function Bt(s, t, e, n) {
913
- const i = Tt(s, n[0], !1), o = Mt(s, n[1], !1);
914
- if (!St(i, n) || !St(o, n)) return null;
1018
+ const Ot = (s, [t, e]) => s >= t && s <= e;
1019
+ function jt(s, t, e, n) {
1020
+ const i = Ct(s, n[0], !1), o = $t(s, n[1], !1);
1021
+ if (!Ot(i, n) || !Ot(o, n)) return null;
915
1022
  if (t === null) return e === "previous" || e === "last" || e === "pagePrevious" ? o : i;
916
1023
  const r = (n[1] - n[0]) / 10;
917
1024
  let l;
@@ -921,28 +1028,28 @@ function Bt(s, t, e, n) {
921
1028
  case "last":
922
1029
  return o;
923
1030
  case "next":
924
- l = Tt(s, t, !0);
1031
+ l = Ct(s, t, !0);
925
1032
  break;
926
1033
  case "previous":
927
- l = Mt(s, t, !0);
1034
+ l = $t(s, t, !0);
928
1035
  break;
929
1036
  case "pageNext":
930
- l = Math.min(Tt(s, t + r, !1), o);
1037
+ l = Math.min(Ct(s, t + r, !1), o);
931
1038
  break;
932
1039
  case "pagePrevious":
933
- l = Math.max(Mt(s, t - r, !1), i);
1040
+ l = Math.max($t(s, t - r, !1), i);
934
1041
  break;
935
1042
  }
936
- return St(l, n) ? l : t;
1043
+ return Ot(l, n) ? l : t;
937
1044
  }
938
- function ve(s, t, e) {
939
- const n = Math.min(Math.max(t, e[0]), e[1]), i = Tt(s, n, !1), o = Mt(s, n, !1), r = [i, o].filter((l) => St(l, e));
1045
+ function De(s, t, e) {
1046
+ const n = Math.min(Math.max(t, e[0]), e[1]), i = Ct(s, n, !1), o = $t(s, n, !1), r = [i, o].filter((l) => Ot(l, e));
940
1047
  return r.length === 0 ? null : r.reduce((l, a) => Math.abs(a - t) < Math.abs(l - t) ? a : l);
941
1048
  }
942
- function ke(s, t, e) {
1049
+ function Pe(s, t, e) {
943
1050
  let n = null;
944
1051
  for (let i = 0; i < s.length; i++) {
945
- if (!bt(s, i)) continue;
1052
+ if (!It(s, i)) continue;
946
1053
  const o = s.x[i], r = s.y[i];
947
1054
  let l, a;
948
1055
  switch (e) {
@@ -963,22 +1070,22 @@ function ke(s, t, e) {
963
1070
  }
964
1071
  return n ?? t;
965
1072
  }
966
- function Yn(s, t, e) {
1073
+ function mi(s, t, e) {
967
1074
  let n = t;
968
1075
  for (let i = 0; i < s.length; i++) {
969
- if (s.y[i] !== t.y || !bt(s, i)) continue;
1076
+ if (s.y[i] !== t.y || !It(s, i)) continue;
970
1077
  const o = s.x[i];
971
1078
  (e === "start" ? o < n.x : o > n.x) && (n = { x: o, y: t.y });
972
1079
  }
973
1080
  return n;
974
1081
  }
975
- function Bn(s, t) {
1082
+ function pi(s, t) {
976
1083
  for (let e = 0; e < s.length; e++)
977
- if (s.x[e] === t.x && s.y[e] === t.y && bt(s, e)) return !0;
1084
+ if (s.x[e] === t.x && s.y[e] === t.y && It(s, e)) return !0;
978
1085
  return !1;
979
1086
  }
980
- function Kn(s, t, e, n, i, o) {
981
- const { x: r, y: l, y0: a, length: c } = s, h = Math.max(0, ut(r, c, t) - 1), f = Math.min(c - 1, ut(r, c, e));
1087
+ function on(s, t, e, n, i, o) {
1088
+ const { x: r, y: l, y0: a, length: c } = s, h = Math.max(0, it(r, c, t) - 1), f = Math.min(c - 1, it(r, c, e));
982
1089
  if (f < h) return { x: r.subarray(0, 0), y: l.subarray(0, 0), y0: null, length: 0 };
983
1090
  if (f - h + 1 <= 2 * o)
984
1091
  return {
@@ -990,32 +1097,116 @@ function Kn(s, t, e, n, i, o) {
990
1097
  const m = [], p = new Array(6);
991
1098
  let u = h;
992
1099
  for (; u <= f; ) {
993
- const y = Math.floor(r[u] * n + i);
994
- let g = -1, b = -1, k = -1, T = -1, O = -1, A = -1;
995
- for (; u <= f && Math.floor(r[u] * n + i) === y; u++) {
996
- const S = l[u];
997
- if (Number.isNaN(S) || a !== null && Number.isNaN(a[u])) {
998
- O < 0 && (O = u), A < 0 && (A = u);
1100
+ const d = Math.floor(r[u] * n + i);
1101
+ let y = -1, b = -1, v = -1, w = -1, L = -1, A = -1;
1102
+ for (; u <= f && Math.floor(r[u] * n + i) === d; u++) {
1103
+ const T = l[u];
1104
+ if (Number.isNaN(T) || a !== null && Number.isNaN(a[u])) {
1105
+ L < 0 && (L = u), A < 0 && (A = u);
999
1106
  continue;
1000
1107
  }
1001
- A = -1, g < 0 && (g = u), b = u, (k < 0 || S < l[k]) && (k = u), (T < 0 || S > l[T]) && (T = u);
1108
+ A = -1, y < 0 && (y = u), b = u, (v < 0 || T < l[v]) && (v = u), (w < 0 || T > l[w]) && (w = u);
1002
1109
  }
1003
- p[0] = g, p[1] = k, p[2] = T, p[3] = b, p[4] = O, p[5] = A, p.sort((S, M) => S - M);
1004
- let E = -1;
1005
- for (const S of p)
1006
- S < 0 || S === E || (m.push(S), E = S);
1110
+ p[0] = y, p[1] = v, p[2] = w, p[3] = b, p[4] = L, p[5] = A, p.sort((T, S) => T - S);
1111
+ let z = -1;
1112
+ for (const T of p)
1113
+ T < 0 || T === z || (m.push(T), z = T);
1007
1114
  }
1008
- const d = {
1115
+ const g = {
1009
1116
  x: new Float64Array(m.length),
1010
1117
  y: new Float64Array(m.length),
1011
1118
  y0: a === null ? null : new Float64Array(m.length),
1012
1119
  length: m.length
1013
1120
  };
1014
- return m.forEach((y, g) => {
1015
- d.x[g] = r[y], d.y[g] = l[y], d.y0 !== null && (d.y0[g] = a[y]);
1016
- }), d;
1121
+ return m.forEach((d, y) => {
1122
+ g.x[y] = r[d], g.y[y] = l[d], g.y0 !== null && (g.y0[y] = a[d]);
1123
+ }), g;
1124
+ }
1125
+ const gi = 500;
1126
+ function yi(s, t, e, n = gi) {
1127
+ const i = s.map((c) => bi(c, t, e)), o = Jt(i, !1).count;
1128
+ if (o <= n || !(e > t)) return { ...Jt(i, !0), courses: i, readings: o, thinned: !1 };
1129
+ const r = Math.max(1, Math.floor(n / 6 / Math.max(1, s.length))), l = (r - 1) / (e - t), a = i.map(
1130
+ (c, h) => {
1131
+ var f;
1132
+ return ((f = s[h]) == null ? void 0 : f.changesOnly) === !0 ? xi(c) : on(c, t, e, l, -t * l, r);
1133
+ }
1134
+ );
1135
+ return { ...Jt(a, !0), courses: a, readings: o, thinned: !0 };
1136
+ }
1137
+ function xi(s) {
1138
+ const t = [];
1139
+ for (let e = 0; e < s.length; e++) (e === 0 || !Object.is(s.y[e], s.y[e - 1])) && t.push(e);
1140
+ return {
1141
+ x: Float64Array.from(t, (e) => s.x[e]),
1142
+ y: Float64Array.from(t, (e) => s.y[e]),
1143
+ y0: null,
1144
+ length: t.length
1145
+ };
1146
+ }
1147
+ function bi(s, t, e) {
1148
+ const n = it(s.x, s.length, t);
1149
+ let i = it(s.x, s.length, e);
1150
+ for (; i < s.length && s.x[i] <= e; ) i++;
1151
+ return {
1152
+ x: s.x.subarray(n, i),
1153
+ y: s.y.subarray(n, i),
1154
+ y0: s.y0 === null ? null : s.y0.subarray(n, i),
1155
+ length: Math.max(0, i - n)
1156
+ };
1157
+ }
1158
+ function Jt(s, t) {
1159
+ const e = s.map(() => 0), n = [], i = [];
1160
+ let o = 0;
1161
+ for (; ; ) {
1162
+ let r = Number.POSITIVE_INFINITY;
1163
+ for (let a = 0; a < s.length; a++) {
1164
+ const c = s[a], h = e[a];
1165
+ h < c.length && c.x[h] < r && (r = c.x[h]);
1166
+ }
1167
+ if (r === Number.POSITIVE_INFINITY) break;
1168
+ const l = t ? s.map(() => -1) : null;
1169
+ for (let a = 0; a < s.length; a++) {
1170
+ const c = s[a], h = e[a];
1171
+ h < c.length && c.x[h] === r && (l !== null && (l[a] = h), e[a] = h + 1);
1172
+ }
1173
+ o++, l !== null && (n.push(r), i.push(l));
1174
+ }
1175
+ return { x: n, at: i, count: o };
1176
+ }
1177
+ function vi(s, t = !1) {
1178
+ const e = /* @__PURE__ */ new Map();
1179
+ for (const n of s)
1180
+ for (let i = 0; i < n.length; i++) {
1181
+ const o = n.y[i];
1182
+ if (Number.isNaN(o)) continue;
1183
+ const r = n.x[i], l = e.get(r);
1184
+ l === void 0 ? e.set(r, { net: o, abs: Math.abs(o), up: 0, down: 0 }) : (l.net += o, l.abs += Math.abs(o));
1185
+ }
1186
+ return s.map((n) => {
1187
+ const i = {
1188
+ top: new Float64Array(n.length),
1189
+ bottom: new Float64Array(n.length),
1190
+ value: new Float64Array(n.length),
1191
+ total: new Float64Array(n.length)
1192
+ };
1193
+ for (let o = 0; o < n.length; o++) {
1194
+ const r = n.y[o], l = e.get(n.x[o]);
1195
+ if (i.total[o] = l === void 0 ? Number.NaN : l.net, Number.isNaN(r) || l === void 0) {
1196
+ i.top[o] = Number.NaN, i.bottom[o] = Number.NaN, i.value[o] = Number.NaN;
1197
+ continue;
1198
+ }
1199
+ i.value[o] = Qt(r, l.abs, t);
1200
+ const a = r >= 0 ? l.up : l.down, c = a + r;
1201
+ r >= 0 ? l.up = c : l.down = c, i.bottom[o] = Qt(a, l.abs, t), i.top[o] = Qt(c, l.abs, t);
1202
+ }
1203
+ return i;
1204
+ });
1205
+ }
1206
+ function Qt(s, t, e) {
1207
+ return e ? t === 0 ? 0 : s / t * 100 : s;
1017
1208
  }
1018
- function we(s, t) {
1209
+ function Ce(s, t) {
1019
1210
  if (t < 2) return 0;
1020
1211
  const e = s.slice(0, t).sort();
1021
1212
  let n = Number.POSITIVE_INFINITY;
@@ -1025,10 +1216,10 @@ function we(s, t) {
1025
1216
  }
1026
1217
  return Number.isFinite(n) ? n : 0;
1027
1218
  }
1028
- function Nt(s, t) {
1219
+ function Et(s, t) {
1029
1220
  return s > 0 ? s : t;
1030
1221
  }
1031
- function Gn(s, t, e, n, i, o, r) {
1222
+ function ki(s, t, e, n, i, o, r) {
1032
1223
  const l = o / 2, a = r / 2;
1033
1224
  for (let c = 0; c < e; c++) {
1034
1225
  const h = n - s[c];
@@ -1039,24 +1230,24 @@ function Gn(s, t, e, n, i, o, r) {
1039
1230
  }
1040
1231
  return -1;
1041
1232
  }
1042
- const qn = {
1233
+ const wi = {
1043
1234
  ok: 0,
1044
1235
  unknown: 1,
1045
1236
  warning: 2,
1046
1237
  alarm: 3
1047
1238
  };
1048
- function qi(s) {
1049
- return qn[s];
1239
+ function As(s) {
1240
+ return wi[s];
1050
1241
  }
1051
- const Ne = { warning: 2, alarm: 3 };
1052
- function Un(s, t = {}) {
1242
+ const $e = { warning: 2, alarm: 3 };
1243
+ function Ni(s, t = {}) {
1053
1244
  if (s == null || !Number.isFinite(s))
1054
1245
  return { verdict: "unknown" };
1055
1246
  const e = t.target, n = e !== void 0 && Number.isFinite(e) ? s - e : void 0;
1056
1247
  let i, o = 0;
1057
1248
  for (const l of t.limits ?? []) {
1058
1249
  const a = l.side === "upper" ? s - l.value : l.value - s;
1059
- a > 0 && (i === void 0 || Ne[l.severity] > Ne[i.severity] || l.severity === i.severity && a > o) && (i = l, o = a);
1250
+ a > 0 && (i === void 0 || $e[l.severity] > $e[i.severity] || l.severity === i.severity && a > o) && (i = l, o = a);
1060
1251
  }
1061
1252
  if (i === void 0)
1062
1253
  return n === void 0 ? { verdict: "ok" } : { verdict: "ok", deviation: n };
@@ -1067,35 +1258,35 @@ function Un(s, t = {}) {
1067
1258
  };
1068
1259
  return n === void 0 ? r : { ...r, deviation: n };
1069
1260
  }
1070
- function Kt(s) {
1261
+ function te(s) {
1071
1262
  return s == null || !Number.isFinite(s) ? Number.NaN : s;
1072
1263
  }
1073
- function Xn(s, t, e, n, i) {
1264
+ function Ii(s, t, e, n, i) {
1074
1265
  const o = s.length, r = new Float64Array(o), l = new Float64Array(o), a = typeof n == "function" ? n : null, c = a === null ? null : new Float64Array(o), h = (i == null ? void 0 : i.value) ?? null, f = h === null ? null : new Float64Array(o), m = (i == null ? void 0 : i.xMap) ?? null, p = (i == null ? void 0 : i.xGap) ?? null;
1075
- let u = Number.POSITIVE_INFINITY, d = Number.NEGATIVE_INFINITY, y = Number.POSITIVE_INFINITY, g = Number.NEGATIVE_INFINITY;
1076
- typeof n == "number" && o > 0 && (y = n, g = n);
1266
+ let u = Number.POSITIVE_INFINITY, g = Number.NEGATIVE_INFINITY, d = Number.POSITIVE_INFINITY, y = Number.NEGATIVE_INFINITY;
1267
+ typeof n == "number" && o > 0 && (d = n, y = n);
1077
1268
  for (let b = 0; b < o; b++) {
1078
- const k = s[b], T = t(k, b), O = !Number.isFinite(T), A = O ? b > 0 ? r[b - 1] : Number.NEGATIVE_INFINITY : m === null ? T : m(T);
1269
+ const v = s[b], w = t(v, b), L = !Number.isFinite(w), A = L ? b > 0 ? r[b - 1] : Number.NEGATIVE_INFINITY : m === null ? w : m(w);
1079
1270
  r[b] = A;
1080
- const E = O || p !== null && p(T);
1081
- E || (A < u && (u = A), A > d && (d = A));
1082
- const S = E ? Number.NaN : Kt(e(k, b));
1083
- if (l[b] = S, S < y && (y = S), S > g && (g = S), h !== null && (f[b] = E ? Number.NaN : Kt(h(k, b))), a !== null) {
1084
- const M = E ? Number.NaN : Kt(a(k, b));
1085
- c[b] = M, M < y && (y = M), M > g && (g = M);
1271
+ const z = L || p !== null && p(w);
1272
+ z || (A < u && (u = A), A > g && (g = A));
1273
+ const T = z ? Number.NaN : te(e(v, b));
1274
+ if (l[b] = T, T < d && (d = T), T > y && (y = T), h !== null && (f[b] = z ? Number.NaN : te(h(v, b))), a !== null) {
1275
+ const S = z ? Number.NaN : te(a(v, b));
1276
+ c[b] = S, S < d && (d = S), S > y && (y = S);
1086
1277
  }
1087
1278
  }
1088
- return { series: { x: r, y: l, y0: c, w: f, length: o }, extent: { xMin: u, xMax: d, yMin: y, yMax: g } };
1279
+ return { series: { x: r, y: l, y0: c, w: f, length: o }, extent: { xMin: u, xMax: g, yMin: d, yMax: y } };
1089
1280
  }
1090
- function Zn(s, t) {
1281
+ function Ai(s, t) {
1091
1282
  for (let e = 1; e < t; e++)
1092
1283
  if (s[e] < s[e - 1]) return e;
1093
1284
  return -1;
1094
1285
  }
1095
- function jn(s, t, e) {
1286
+ function Oe(s, t, e) {
1096
1287
  const { x: n, y: i, y0: o, length: r } = s;
1097
1288
  let l = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY;
1098
- for (let c = ut(n, r, t); c < r && n[c] <= e; c++) {
1289
+ for (let c = it(n, r, t); c < r && n[c] <= e; c++) {
1099
1290
  const h = i[c];
1100
1291
  if (h < l && (l = h), h > a && (a = h), o !== null) {
1101
1292
  const f = o[c];
@@ -1104,7 +1295,7 @@ function jn(s, t, e) {
1104
1295
  }
1105
1296
  return [l, a];
1106
1297
  }
1107
- function Jn(s, t, e, n) {
1298
+ function Ti(s, t, e, n) {
1108
1299
  let i = Number.POSITIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
1109
1300
  for (const r of e) {
1110
1301
  const l = r.extent;
@@ -1117,7 +1308,7 @@ function Jn(s, t, e, n) {
1117
1308
  Number.isFinite(r) && (r < i && (i = r), r > o && (o = r));
1118
1309
  return !Number.isFinite(i) || !Number.isFinite(o) ? [0, 1] : [i, o];
1119
1310
  }
1120
- function Qn(s, t) {
1311
+ function Mi(s, t) {
1121
1312
  let e = Number.POSITIVE_INFINITY;
1122
1313
  for (let n = 1; n < t; n++) {
1123
1314
  const i = s[n] - s[n - 1];
@@ -1125,14 +1316,14 @@ function Qn(s, t) {
1125
1316
  }
1126
1317
  return Number.isFinite(e) ? e : 0;
1127
1318
  }
1128
- function ti(s, t) {
1319
+ function Si(s, t) {
1129
1320
  return s > 0 ? s : t;
1130
1321
  }
1131
- function ei(s, t, e, n) {
1322
+ function Li(s, t, e, n) {
1132
1323
  const i = s * t, o = i / n;
1133
1324
  return { offset: -i / 2 + e * o, width: o };
1134
1325
  }
1135
- function ni(s) {
1326
+ function Ei(s) {
1136
1327
  const t = /* @__PURE__ */ new Map();
1137
1328
  for (const n of s) {
1138
1329
  if (n.kind !== "bar") continue;
@@ -1142,44 +1333,49 @@ function ni(s) {
1142
1333
  const e = /* @__PURE__ */ new Map();
1143
1334
  for (const n of t.values()) {
1144
1335
  let i = Number.POSITIVE_INFINITY;
1145
- for (const l of n)
1146
- l.step > 0 && l.step < i && (i = l.step);
1147
- const o = Number.isFinite(i) ? i : 0, r = n[0].fraction;
1148
- n.forEach((l, a) => {
1149
- e.set(l.order, {
1150
- index: a,
1151
- size: n.length,
1336
+ for (const a of n)
1337
+ a.step > 0 && a.step < i && (i = a.step);
1338
+ const o = Number.isFinite(i) ? i : 0, r = n[0].fraction, l = /* @__PURE__ */ new Map();
1339
+ for (const a of n) {
1340
+ const c = a.stack ?? a.order;
1341
+ l.has(c) || l.set(c, l.size);
1342
+ }
1343
+ for (const a of n)
1344
+ e.set(a.order, {
1345
+ index: l.get(a.stack ?? a.order),
1346
+ size: l.size,
1152
1347
  step: o,
1153
1348
  fraction: r
1154
1349
  });
1155
- });
1156
1350
  }
1157
1351
  return e;
1158
1352
  }
1159
- const Ie = {
1353
+ const He = {
1160
1354
  version: 0,
1161
- layout: Re,
1355
+ layout: je,
1162
1356
  legend: null,
1163
1357
  series: [],
1164
1358
  limits: [],
1165
1359
  // Unknown before the first frame: saying "No data" there would flash.
1166
- empty: !1
1167
- }, Ae = {
1360
+ empty: !1,
1361
+ dataTable: null
1362
+ }, Re = {
1168
1363
  version: 0,
1169
1364
  hover: null,
1170
1365
  tooltip: null,
1171
1366
  xLabel: "",
1172
- rows: []
1173
- }, ii = 4, Te = 12;
1174
- let Gt = 0;
1367
+ rows: [],
1368
+ totals: []
1369
+ }, Fi = 4, We = 12;
1370
+ let ee = 0;
1175
1371
  const ft = /* @__PURE__ */ new Map();
1176
- function j(s, t) {
1372
+ function Q(s, t) {
1177
1373
  if (s === t) return !0;
1178
1374
  if (typeof s != "function" || typeof t != "function") return !1;
1179
1375
  const e = String(s);
1180
1376
  return e.includes("[native code]") ? !1 : e === String(t);
1181
1377
  }
1182
- function si(s, t) {
1378
+ function Di(s, t) {
1183
1379
  var e, n, i, o;
1184
1380
  if (s === t) return !0;
1185
1381
  if (s === void 0 || t === void 0 || s.length !== t.length) return !1;
@@ -1187,34 +1383,43 @@ function si(s, t) {
1187
1383
  if (((e = s[r]) == null ? void 0 : e.from) !== ((n = t[r]) == null ? void 0 : n.from) || ((i = s[r]) == null ? void 0 : i.to) !== ((o = t[r]) == null ? void 0 : o.to)) return !1;
1188
1384
  return !0;
1189
1385
  }
1190
- function It(s) {
1386
+ function mt(s) {
1191
1387
  return s.kind !== "state" && s.kind !== "matrix";
1192
1388
  }
1193
- function oi(s) {
1389
+ function Pi(s) {
1194
1390
  const t = s.entry.materialized;
1195
1391
  if (t === null) return !1;
1196
- const e = t.x[s.index], n = (i) => i > 0 && i < B;
1392
+ const e = t.x[s.index], n = (i) => i > 0 && i < V;
1197
1393
  return s.index > 0 && n(e - t.x[s.index - 1]) || s.index + 1 < t.length && n(t.x[s.index + 1] - e);
1198
1394
  }
1199
- function gt(s, t) {
1395
+ function kt(s, t) {
1200
1396
  if (s === t) return !0;
1201
1397
  if (s === void 0 || t === void 0 || s.length !== t.length) return !1;
1202
1398
  for (let e = 0; e < s.length; e++) if (s[e] !== t[e]) return !1;
1203
1399
  return !0;
1204
1400
  }
1205
- function ri(s, t) {
1206
- return s.kind === t.kind && j(s.accessor, t.accessor) && s.data === t.data && j(Ot(s), Ot(t)) && j(ie(s), ie(t));
1401
+ function Ci(s, t) {
1402
+ return s.kind === t.kind && U(s) === U(t) && _t(s) === _t(t) && Q(s.accessor, t.accessor) && s.data === t.data && Q(Vt(s), Vt(t)) && Q(de(s), de(t));
1403
+ }
1404
+ function U(s) {
1405
+ if (!(s.kind !== "bar" && s.kind !== "area" || s.stack === void 0))
1406
+ return `${s.xAxisId}
1407
+ ${s.yAxisId}
1408
+ ${s.stack}`;
1207
1409
  }
1208
- function ie(s) {
1410
+ function _t(s) {
1411
+ return (s.kind === "bar" || s.kind === "area") && s.stack !== void 0 && s.normalize === !0;
1412
+ }
1413
+ function de(s) {
1209
1414
  return s.kind === "matrix" ? s.value : void 0;
1210
1415
  }
1211
- function Ot(s) {
1416
+ function Vt(s) {
1212
1417
  switch (s.kind) {
1213
1418
  case "line":
1214
1419
  case "scatter":
1215
1420
  return;
1216
1421
  case "area":
1217
- return s.baseline ?? 0;
1422
+ return s.stack === void 0 ? s.baseline ?? 0 : 0;
1218
1423
  case "bar":
1219
1424
  return 0;
1220
1425
  case "state":
@@ -1222,16 +1427,16 @@ function Ot(s) {
1222
1427
  return;
1223
1428
  }
1224
1429
  }
1225
- function li(s, t) {
1430
+ function $i(s, t) {
1226
1431
  if (s.kind !== t.kind) return !1;
1227
1432
  switch (t.kind) {
1228
1433
  case "line": {
1229
1434
  const e = s;
1230
- return e.strokeWidth === t.strokeWidth && e.markers === t.markers && e.step === t.step && gt(e.dash, t.dash);
1435
+ return e.strokeWidth === t.strokeWidth && e.markers === t.markers && e.step === t.step && kt(e.dash, t.dash);
1231
1436
  }
1232
1437
  case "area": {
1233
1438
  const e = s;
1234
- return j(e.baseline, t.baseline) && e.fillOpacity === t.fillOpacity && e.strokeWidth === t.strokeWidth && gt(e.dash, t.dash);
1439
+ return Q(e.baseline, t.baseline) && e.fillOpacity === t.fillOpacity && e.strokeWidth === t.strokeWidth && kt(e.dash, t.dash);
1235
1440
  }
1236
1441
  case "bar":
1237
1442
  return s.barWidth === t.barWidth;
@@ -1239,13 +1444,13 @@ function li(s, t) {
1239
1444
  return s.radius === t.radius;
1240
1445
  case "state": {
1241
1446
  const e = s;
1242
- return e.laneFrom === t.laneFrom && e.laneTo === t.laneTo && ai(e.states, t.states);
1447
+ return e.laneFrom === t.laneFrom && e.laneTo === t.laneTo && Oi(e.states, t.states);
1243
1448
  }
1244
1449
  case "matrix":
1245
- return ui(s.coloring, t.coloring);
1450
+ return Hi(s.coloring, t.coloring);
1246
1451
  }
1247
1452
  }
1248
- function ai(s, t) {
1453
+ function Oi(s, t) {
1249
1454
  var e, n, i, o;
1250
1455
  if (s === t) return !0;
1251
1456
  if (s.length !== t.length) return !1;
@@ -1253,17 +1458,17 @@ function ai(s, t) {
1253
1458
  if (((e = s[r]) == null ? void 0 : e.label) !== ((n = t[r]) == null ? void 0 : n.label) || ((i = s[r]) == null ? void 0 : i.color) !== ((o = t[r]) == null ? void 0 : o.color)) return !1;
1254
1459
  return !0;
1255
1460
  }
1256
- function ui(s, t) {
1257
- return s === t ? !0 : s.kind !== t.kind ? !1 : s.kind === "assessment" && t.kind === "assessment" ? s.limits === t.limits : s.kind === "gradient" && t.kind === "gradient" ? gt(s.stops, t.stops) && gt(s.range, t.range) : !1;
1461
+ function Hi(s, t) {
1462
+ return s === t ? !0 : s.kind !== t.kind ? !1 : s.kind === "assessment" && t.kind === "assessment" ? s.limits === t.limits : s.kind === "gradient" && t.kind === "gradient" ? kt(s.stops, t.stops) && kt(s.range, t.range) : !1;
1258
1463
  }
1259
- function qt(s, t) {
1464
+ function Ft(s, t) {
1260
1465
  return s.kind === "assessment" ? [t.colorOk, t.colorWarning, t.colorAlarm] : s.stops;
1261
1466
  }
1262
- function ci(s) {
1467
+ function Ri(s) {
1263
1468
  const t = 100 / Math.max(1, s.length);
1264
1469
  return `linear-gradient(to right, ${s.map((n, i) => `${n} ${i * t}% ${(i + 1) * t}%`).join(", ")})`;
1265
1470
  }
1266
- function hi(s, t, e) {
1471
+ function Wi(s, t, e) {
1267
1472
  let n = e == null ? void 0 : e[0], i = e == null ? void 0 : e[1];
1268
1473
  if (n === void 0 || i === void 0) {
1269
1474
  n = Number.POSITIVE_INFINITY, i = Number.NEGATIVE_INFINITY;
@@ -1274,46 +1479,49 @@ function hi(s, t, e) {
1274
1479
  }
1275
1480
  return [n, i];
1276
1481
  }
1277
- function di(s, t, e, n, i) {
1482
+ function zi(s, t, e, n, i) {
1278
1483
  if (t.kind === "assessment") {
1279
- const a = Un(s, t.limits);
1484
+ const a = Ni(s, t.limits);
1280
1485
  return a.verdict === "alarm" ? 2 : a.verdict === "warning" ? 1 : a.verdict === "ok" ? 0 : -1;
1281
1486
  }
1282
1487
  if (!Number.isFinite(s)) return -1;
1283
1488
  const o = i - n, r = o > 0 ? (s - n) / o : 0.5, l = Math.floor(r * e);
1284
1489
  return l < 0 ? 0 : l >= e ? e - 1 : l;
1285
1490
  }
1286
- function Me(s, t, e) {
1491
+ function ze(s, t, e) {
1287
1492
  const n = s.length, i = new Int32Array(n), o = s.w;
1288
1493
  if (o === null || e === 0)
1289
1494
  return i.fill(-1), i;
1290
- const [r, l] = t.kind === "gradient" ? hi(o, n, t.range) : [0, 0];
1291
- for (let a = 0; a < n; a++) i[a] = di(o[a], t, e, r, l);
1495
+ const [r, l] = t.kind === "gradient" ? Wi(o, n, t.range) : [0, 0];
1496
+ for (let a = 0; a < n; a++) i[a] = zi(o[a], t, e, r, l);
1292
1497
  return i;
1293
1498
  }
1294
- function fi(s, t) {
1499
+ function Bi(s, t) {
1295
1500
  return s === t ? !0 : Array.isArray(s) && Array.isArray(t) ? s[0] === t[0] && s[1] === t[1] : !1;
1296
1501
  }
1297
- const mi = 150, pi = 100, yi = {
1502
+ const _i = 150, Vi = 100, Yi = {
1298
1503
  ArrowRight: "next",
1299
1504
  ArrowLeft: "previous",
1300
1505
  Home: "first",
1301
1506
  End: "last",
1302
1507
  PageDown: "pageNext",
1303
1508
  PageUp: "pagePrevious"
1304
- }, xi = {
1509
+ }, Gi = {
1305
1510
  ArrowLeft: "left",
1306
1511
  ArrowRight: "right",
1307
1512
  ArrowUp: "up",
1308
1513
  ArrowDown: "down"
1309
- }, Se = 1.25;
1310
- class ze {
1514
+ }, Be = 1.25;
1515
+ class rn {
1311
1516
  constructor() {
1312
1517
  /* ---------- Registration ---------- */
1313
1518
  x(this, "series", /* @__PURE__ */ new Map());
1314
1519
  x(this, "axes", /* @__PURE__ */ new Map());
1315
1520
  x(this, "legend", null);
1316
1521
  x(this, "tooltip", null);
1522
+ x(this, "dataTable", null);
1523
+ /** `Chart encoding` (charts-alternatives C3). */
1524
+ x(this, "encoding", "color");
1317
1525
  x(this, "limits", /* @__PURE__ */ new Map());
1318
1526
  /* ---------- Data and layout inputs ---------- */
1319
1527
  x(this, "data", []);
@@ -1331,7 +1539,7 @@ class ze {
1331
1539
  x(this, "summaryEl", null);
1332
1540
  x(this, "readoutTimer", null);
1333
1541
  x(this, "summaryTimer", null);
1334
- x(this, "wording", _e);
1542
+ x(this, "wording", sn);
1335
1543
  x(this, "measurer", null);
1336
1544
  /* ---------- Size and DPR ---------- */
1337
1545
  x(this, "cssWidth", 0);
@@ -1357,12 +1565,13 @@ class ze {
1357
1565
  `var(--…)` or a `light-dark(…)` and keeps the previous fillStyle. */
1358
1566
  x(this, "painted", /* @__PURE__ */ new Map());
1359
1567
  /* ---------- Layout and interaction ---------- */
1360
- x(this, "layout", Re);
1568
+ x(this, "layout", je);
1361
1569
  x(this, "hysteresis", /* @__PURE__ */ new Map());
1362
1570
  x(this, "hover", null);
1363
1571
  x(this, "hoverKey", "");
1364
1572
  x(this, "hoverXLabel", "");
1365
1573
  x(this, "hoverRows", []);
1574
+ x(this, "hoverTotals", []);
1366
1575
  /** The orders of the series in the current hit, beside its rows. */
1367
1576
  x(this, "hoverOrders", []);
1368
1577
  x(this, "highlight", null);
@@ -1378,8 +1587,8 @@ class ze {
1378
1587
  /** The highlight is the keyboard's, and goes with its Active point. */
1379
1588
  x(this, "keyHighlight", !1);
1380
1589
  /* ---------- Snapshots for the HTML layer ---------- */
1381
- x(this, "layoutSnapshot", Ie);
1382
- x(this, "hoverSnapshot", Ae);
1590
+ x(this, "layoutSnapshot", He);
1591
+ x(this, "hoverSnapshot", Re);
1383
1592
  x(this, "layoutSubscribers", /* @__PURE__ */ new Set());
1384
1593
  x(this, "hoverSubscribers", /* @__PURE__ */ new Set());
1385
1594
  /* ---------- Instrumentation (R-5.1) ---------- */
@@ -1395,6 +1604,7 @@ class ze {
1395
1604
  (t = this.measurer) == null || t.clear(), this.hysteresis.clear(), this.markLayoutDirty();
1396
1605
  });
1397
1606
  x(this, "themeRoot", null);
1607
+ x(this, "percent", (t) => this.wording.percent(St(t)));
1398
1608
  /* ---------- Cursor sync (charts-long-series 04) ----------
1399
1609
 
1400
1610
  Only the x position travels, in domain units: each chart draws its own
@@ -1422,12 +1632,12 @@ class ze {
1422
1632
  this.layoutSubscribers.delete(t);
1423
1633
  }));
1424
1634
  x(this, "getLayoutSnapshot", () => this.layoutSnapshot);
1425
- x(this, "getLayoutServerSnapshot", () => Ie);
1635
+ x(this, "getLayoutServerSnapshot", () => He);
1426
1636
  x(this, "subscribeHover", (t) => (this.hoverSubscribers.add(t), () => {
1427
1637
  this.hoverSubscribers.delete(t);
1428
1638
  }));
1429
1639
  x(this, "getHoverSnapshot", () => this.hoverSnapshot);
1430
- x(this, "getHoverServerSnapshot", () => Ae);
1640
+ x(this, "getHoverServerSnapshot", () => Re);
1431
1641
  }
1432
1642
  setOnPerf(t) {
1433
1643
  this.onPerf = t;
@@ -1453,42 +1663,44 @@ class ze {
1453
1663
  return !1;
1454
1664
  }
1455
1665
  registerSeries(t) {
1456
- const e = Gt++;
1666
+ const e = ee++;
1457
1667
  return this.series.set(e, {
1458
1668
  order: e,
1459
1669
  config: t,
1460
- slot: It(t) ? this.slotFor(t.name) : -1,
1670
+ slot: mt(t) ? this.slotFor(t.name) : -1,
1461
1671
  lastSlot: null,
1462
1672
  materialized: null,
1463
1673
  extent: null,
1464
1674
  step: null,
1465
1675
  cellHeight: null,
1466
- buckets: null
1676
+ buckets: null,
1677
+ own: null,
1678
+ stacked: null
1467
1679
  }), this.materialsDirty = !0, this.markLayoutDirty(), e;
1468
1680
  }
1469
1681
  updateSeries(t, e) {
1470
1682
  const n = this.series.get(t);
1471
1683
  if (n === void 0) return;
1472
- const i = n.config, o = ri(i, e), r = o && i.xAxisId === e.xAxisId && i.yAxisId === e.yAxisId && i.name === e.name && j(i.format, e.format) && i.color === e.color && i.tone === e.tone && i.hidden === e.hidden && li(i, e);
1473
- if (n.slot < 0 && It(e))
1684
+ const i = n.config, o = Ci(i, e), r = o && i.xAxisId === e.xAxisId && i.yAxisId === e.yAxisId && i.name === e.name && Q(i.format, e.format) && i.color === e.color && i.tone === e.tone && i.hidden === e.hidden && $i(i, e);
1685
+ if (n.slot < 0 && mt(e))
1474
1686
  n.slot = this.slotFor(e.name);
1475
1687
  else if (i.name !== e.name && e.name !== void 0 && n.slot >= 0) {
1476
1688
  const l = this.slotsByName.get(e.name);
1477
1689
  l === void 0 ? this.slotsByName.set(e.name, n.slot) : this.slotTaken(l, n) || (n.slot = l);
1478
1690
  }
1479
- n.config = e, !r && (n.buckets = null, o || (n.materialized = null, n.extent = null, n.step = null, n.cellHeight = null, n.buckets = null, this.materialsDirty = !0), this.markLayoutDirty());
1691
+ n.config = e, !r && (n.buckets = null, i.hidden !== e.hidden && U(e) !== void 0 && (this.materialsDirty = !0), o || (n.materialized = null, n.extent = null, n.step = null, n.cellHeight = null, n.buckets = null, this.materialsDirty = !0), this.markLayoutDirty());
1480
1692
  }
1481
1693
  unregisterSeries(t) {
1482
1694
  this.series.delete(t) && (this.materialsDirty = !0, this.markLayoutDirty());
1483
1695
  }
1484
1696
  registerAxis(t) {
1485
- const e = Gt++;
1697
+ const e = ee++;
1486
1698
  return this.axes.set(e, { order: e, config: t }), this.materialsDirty = !0, this.markLayoutDirty(), e;
1487
1699
  }
1488
1700
  updateAxis(t, e) {
1489
1701
  const n = this.axes.get(t);
1490
1702
  if (n === void 0) return;
1491
- const i = n.config, o = j(i.accessor, e.accessor) && si(i.calendar, e.calendar), r = o && i.id === e.id && i.orientation === e.orientation && i.position === e.position && i.label === e.label && i.tickCount === e.tickCount && i.grid === e.grid && i.time === e.time && i.alignTicks === e.alignTicks && gt(i.ticks, e.ticks) && fi(i.domain, e.domain) && i.onDomainChange === void 0 == (e.onDomainChange === void 0) && j(i.tickFormat, e.tickFormat);
1703
+ const i = n.config, o = Q(i.accessor, e.accessor) && Di(i.calendar, e.calendar), r = o && i.id === e.id && i.orientation === e.orientation && i.position === e.position && i.label === e.label && i.tickCount === e.tickCount && i.grid === e.grid && i.time === e.time && i.alignTicks === e.alignTicks && kt(i.ticks, e.ticks) && Bi(i.domain, e.domain) && i.onDomainChange === void 0 == (e.onDomainChange === void 0) && Q(i.tickFormat, e.tickFormat);
1492
1704
  if (n.config = e, !r) {
1493
1705
  if (!o || i.id !== e.id) {
1494
1706
  for (const l of this.series.values())
@@ -1505,7 +1717,7 @@ class ze {
1505
1717
  anything in this library. They are therefore not series: no accessor, no
1506
1718
  data, no legend entry, no hit. */
1507
1719
  registerLimit(t) {
1508
- const e = Gt++;
1720
+ const e = ee++;
1509
1721
  return this.limits.set(e, { order: e, config: t }), this.markLayoutDirty(), e;
1510
1722
  }
1511
1723
  updateLimit(t, e) {
@@ -1534,7 +1746,7 @@ class ze {
1534
1746
  }
1535
1747
  updateTooltip(t) {
1536
1748
  const e = this.tooltip;
1537
- if (e !== null && e.mode === t.mode && j(e.render, t.render)) {
1749
+ if (e !== null && e.mode === t.mode && Q(e.render, t.render)) {
1538
1750
  this.tooltip = t;
1539
1751
  return;
1540
1752
  }
@@ -1543,6 +1755,45 @@ class ze {
1543
1755
  unregisterTooltip() {
1544
1756
  this.tooltip = null, this.hover = null, this.hoverKey = "", this.markOverlayDirty(), this.pushHoverSnapshot();
1545
1757
  }
1758
+ /* The data table (charts-alternatives 01) registers like the legend: one per
1759
+ chart. Whether it is open is the scene's, because two elements show it -
1760
+ the key in the legend and the panel. Opening it changes no pixel of the
1761
+ plot, so it only pushes the snapshot. */
1762
+ registerDataTable(t) {
1763
+ this.dataTable = { id: t, open: !1 }, this.pushLayoutSnapshot();
1764
+ }
1765
+ unregisterDataTable() {
1766
+ this.dataTable = null, this.pushLayoutSnapshot();
1767
+ }
1768
+ toggleDataTable() {
1769
+ this.dataTable !== null && (this.dataTable = { ...this.dataTable, open: !this.dataTable.open }, this.pushLayoutSnapshot());
1770
+ }
1771
+ setEncoding(t) {
1772
+ t !== this.encoding && (this.encoding = t, this.markLayoutDirty());
1773
+ }
1774
+ /** Is every series drawn with its marks as well as its colour? Under forced
1775
+ colours always: every series is drawn in the one text colour then (C4). */
1776
+ marked() {
1777
+ var t;
1778
+ return this.encoding === "marks" || ((t = this.theme) == null ? void 0 : t.forced) === !0;
1779
+ }
1780
+ /** A series' marks by its palette place - the same place its colour comes
1781
+ from; null without encoding by marks, and for the kinds that take no
1782
+ place (a band and a cell are hatched by state and by step instead). */
1783
+ marksOf(t) {
1784
+ return this.marked() && mt(t.config) ? jn(this.paletteSlot(t)) : null;
1785
+ }
1786
+ /** Each state's hatch by its name, across every band of the chart - so the
1787
+ legend and each band agree (charts-alternatives 04). */
1788
+ stateHatches() {
1789
+ const t = [];
1790
+ for (const { config: e } of this.seriesInOrder()) e.kind === "state" && t.push(e.states);
1791
+ return Jn(t);
1792
+ }
1793
+ /** The words the HTML layer writes - the data table's key among them. */
1794
+ getWording() {
1795
+ return this.wording;
1796
+ }
1546
1797
  /** Series in registration order - the drawing order. The palette follows it
1547
1798
  only on the first mount; after that it follows the name. */
1548
1799
  seriesInOrder() {
@@ -1567,31 +1818,31 @@ class ze {
1567
1818
  /* ================= Checks (R-4.12, R-4.13) ================= */
1568
1819
  /** Called from the Chart after the child effects; DEV only. */
1569
1820
  validate() {
1570
- if (!yt) return;
1821
+ if (!bt) return;
1571
1822
  const t = /* @__PURE__ */ new Set();
1572
1823
  for (const { config: o } of this.axesInOrder()) {
1573
1824
  const r = `${o.orientation}:${o.id}`, l = o.orientation === "x" ? "XAxis" : "YAxis";
1574
- pt(
1825
+ gt(
1575
1826
  !t.has(r),
1576
1827
  `Two <${l}> with the same id "${o.id}". A second ${l} needs an own id (R-4.12).`
1577
1828
  ), t.add(r);
1578
1829
  }
1579
1830
  const e = /* @__PURE__ */ new Set();
1580
1831
  for (const { config: o } of this.series.values())
1581
- pt(
1832
+ gt(
1582
1833
  t.has(`x:${o.xAxisId}`),
1583
1834
  `Series "${o.name ?? "?"}" refers to the unknown x axis "${o.xAxisId}" (R-4.12).`
1584
- ), pt(
1835
+ ), gt(
1585
1836
  t.has(`y:${o.yAxisId}`),
1586
1837
  `Series "${o.name ?? "?"}" refers to the unknown y axis "${o.yAxisId}" (R-4.12).`
1587
1838
  ), e.add(`x:${o.xAxisId}`), e.add(`y:${o.yAxisId}`);
1588
1839
  for (const { config: o } of this.limits.values())
1589
- pt(
1840
+ gt(
1590
1841
  t.has(`${o.orientation}:${this.limitAxisId(o)}`),
1591
1842
  `A limit refers to the unknown ${o.orientation} axis "${this.limitAxisId(o)}" (R-4.12).`
1592
1843
  );
1593
1844
  for (const o of t)
1594
- !e.has(o) && this.series.size > 0 && tt(
1845
+ !e.has(o) && this.series.size > 0 && nt(
1595
1846
  `axis-without-series-${o}`,
1596
1847
  `Axis "${o}" has no bound series; it is drawn with the domain [0, 1] (R-4.13).`
1597
1848
  );
@@ -1599,14 +1850,14 @@ class ze {
1599
1850
  for (const { config: o } of this.seriesInOrder()) {
1600
1851
  if (o.kind !== "bar") continue;
1601
1852
  const r = n.get(o.xAxisId);
1602
- r === void 0 ? n.set(o.xAxisId, o.barWidth) : r !== o.barWidth && tt(
1853
+ r === void 0 ? n.set(o.xAxisId, o.barWidth) : r !== o.barWidth && nt(
1603
1854
  `bar-width-${o.xAxisId}`,
1604
1855
  `Bars on the x axis "${o.xAxisId}" give different barWidth. A group shares one width fraction; that of the first (${r}) applies (ADR-0002).`
1605
1856
  );
1606
1857
  }
1607
1858
  let i = 0;
1608
1859
  for (const o of this.axesInOrder()) o.config.grid === !0 && i++;
1609
- i > 1 && tt(
1860
+ i > 1 && nt(
1610
1861
  "multiple-grids",
1611
1862
  "More than one axis draws grid. Unaligned grids compete visually; `alignTicks` puts a further y axis' ticks on the first one's grid instead (R-4.15)."
1612
1863
  );
@@ -1634,19 +1885,19 @@ class ze {
1634
1885
  }
1635
1886
  const i = n.config, o = i.data ?? this.data, r = this.findAxisConfig("x", i.xAxisId);
1636
1887
  if (r === null) continue;
1637
- const l = Xn(
1888
+ const l = Ii(
1638
1889
  o,
1639
1890
  r.accessor,
1640
1891
  i.accessor,
1641
- Ot(i),
1892
+ Vt(i),
1642
1893
  {
1643
- value: ie(i),
1894
+ value: de(i),
1644
1895
  xMap: this.mapFor(r),
1645
1896
  xGap: this.gapFor(r)
1646
1897
  }
1647
1898
  );
1648
- if (n.materialized = l.series, e += l.series.length, i.kind === "bar") {
1649
- const a = Qn(l.series.x, l.series.length);
1899
+ if (n.materialized = l.series, n.own = U(i) === void 0 ? null : l.series.y, n.stacked = null, e += l.series.length, i.kind === "bar") {
1900
+ const a = Mi(l.series.x, l.series.length);
1650
1901
  n.step = a;
1651
1902
  const c = a / 2;
1652
1903
  n.extent = {
@@ -1655,7 +1906,7 @@ class ze {
1655
1906
  xMax: l.extent.xMax + c
1656
1907
  };
1657
1908
  } else if (i.kind === "matrix") {
1658
- const a = we(l.series.x, l.series.length), c = we(l.series.y, l.series.length);
1909
+ const a = Ce(l.series.x, l.series.length), c = Ce(l.series.y, l.series.length);
1659
1910
  n.step = a, n.cellHeight = c, n.extent = {
1660
1911
  xMin: l.extent.xMin - a / 2,
1661
1912
  xMax: l.extent.xMax + a / 2,
@@ -1663,7 +1914,7 @@ class ze {
1663
1914
  yMax: l.extent.yMax + c / 2
1664
1915
  };
1665
1916
  } else if (i.kind === "state") {
1666
- const a = Ln(l.series.x, l.series.length);
1917
+ const a = ti(l.series.x, l.series.length);
1667
1918
  n.step = a, n.extent = {
1668
1919
  ...l.extent,
1669
1920
  xMax: l.extent.xMax + a,
@@ -1672,23 +1923,50 @@ class ze {
1672
1923
  };
1673
1924
  } else
1674
1925
  n.step = null, n.extent = l.extent;
1675
- if (yt && i.kind !== "matrix") {
1676
- const a = Zn(l.series.x, l.series.length);
1926
+ if (bt && i.kind !== "matrix") {
1927
+ const a = Ai(l.series.x, l.series.length);
1677
1928
  if (a >= 0) {
1678
1929
  const c = i.name ?? "?";
1679
- tt(
1930
+ nt(
1680
1931
  `x-unsorted-${c}`,
1681
1932
  `Series "${c}": x values are not sorted ascending (index ${a}). Binary search and path building assume sortedness; there is no automatic sorting (R-2.6).`
1682
1933
  );
1683
1934
  }
1684
1935
  }
1685
1936
  }
1686
- this.materialsDirty = !1, this.perf.materializeMs = (typeof performance > "u" ? 0 : performance.now()) - t, this.perf.points = e;
1937
+ this.stackAll(), this.materialsDirty = !1, this.perf.materializeMs = (typeof performance > "u" ? 0 : performance.now()) - t, this.perf.points = e;
1938
+ }
1939
+ /** Sums every stack anew from its members' own values (charts-stacking K2),
1940
+ once per materialisation: a member that changes moves every one above
1941
+ it. The stack is summed before anything is drawn, so an area's
1942
+ downsampling thins the stacked edges - each member keeps its own
1943
+ extremes per pixel column, and inside one column the edge of a member
1944
+ and the foot of the one above may part by a stroke's width. */
1945
+ stackAll() {
1946
+ const t = /* @__PURE__ */ new Map();
1947
+ for (const e of this.seriesInOrder()) {
1948
+ const n = U(e.config);
1949
+ if (n === void 0 || e.config.hidden === !0 || e.materialized === null || e.own === null) continue;
1950
+ const i = t.get(n);
1951
+ i === void 0 ? t.set(n, [e]) : i.push(e);
1952
+ }
1953
+ for (const e of t.values()) {
1954
+ const n = U(e[0].config), i = [...this.series.values()].some((r) => U(r.config) === n && _t(r.config)), o = vi(
1955
+ e.map((r) => ({ ...r.materialized, y: r.own })),
1956
+ i
1957
+ );
1958
+ e.forEach((r, l) => {
1959
+ const a = o[l], c = { ...r.materialized, y: a.top, y0: a.bottom };
1960
+ r.materialized = c, r.stacked = { value: a.value, total: a.total, normalize: i };
1961
+ const [h, f] = Oe(c, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
1962
+ r.extent !== null && (r.extent = { ...r.extent, yMin: h, yMax: f });
1963
+ });
1964
+ }
1687
1965
  }
1688
1966
  /* ================= DOM binding, DPR, resize ================= */
1689
1967
  bind(t, e, n, i) {
1690
1968
  var r;
1691
- this.container = t, this.themeRoot = i, this.seriesCanvas = e, this.overlayCanvas = n, this.seriesCtx = e.getContext("2d"), this.overlayCtx = n.getContext("2d"), this.measurer = new ln(i), this.dpr = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, this.rebindDprWatch(), this.unsubscribeTheme = on(() => {
1969
+ this.container = t, this.themeRoot = i, this.seriesCanvas = e, this.overlayCanvas = n, this.seriesCtx = e.getContext("2d"), this.overlayCtx = n.getContext("2d"), this.measurer = new Sn(i), this.dpr = typeof devicePixelRatio == "number" ? devicePixelRatio : 1, this.rebindDprWatch(), this.unsubscribeTheme = Tn(() => {
1692
1970
  var l;
1693
1971
  this.theme = null, this.painted.clear(), (l = this.measurer) == null || l.clear(), this.hysteresis.clear(), this.markLayoutDirty();
1694
1972
  });
@@ -1702,7 +1980,7 @@ class ze {
1702
1980
  this.readoutEl = t, this.summaryEl = e, this.scheduleSummary();
1703
1981
  }
1704
1982
  setWording(t) {
1705
- t !== this.wording && (this.wording = t, this.scheduleSummary());
1983
+ t !== this.wording && (this.wording = t, this.markLayoutDirty());
1706
1984
  }
1707
1985
  unbind() {
1708
1986
  var t, e, n, i, o;
@@ -1745,7 +2023,7 @@ class ze {
1745
2023
  }));
1746
2024
  }
1747
2025
  frame() {
1748
- if (this.applyPendingSize(), this.theme === null && this.themeRoot !== null && (this.theme = sn(this.themeRoot)), this.cssWidth <= 0 || this.cssHeight <= 0) {
2026
+ if (this.applyPendingSize(), this.theme === null && this.themeRoot !== null && (this.theme = An(this.themeRoot)), this.cssWidth <= 0 || this.cssHeight <= 0) {
1749
2027
  this.layoutDirty && this.pushLayoutSnapshot();
1750
2028
  return;
1751
2029
  }
@@ -1785,7 +2063,7 @@ class ze {
1785
2063
  // A hidden series has no say: the axis fits what is shown.
1786
2064
  extent: r.config.hidden === !0 ? null : n ? this.visibleExtentOf(r) : r.extent
1787
2065
  }));
1788
- return Jn(t, e, i, this.limitValues(t, e));
2066
+ return Ti(t, e, i, this.limitValues(t, e));
1789
2067
  }
1790
2068
  /** The extent of what a fixed x domain shows. A domain that is not fixed
1791
2069
  shows every point - "nice" and "data" both contain the data -, and a band
@@ -1796,8 +2074,8 @@ class ze {
1796
2074
  if (!Array.isArray(e) || t.materialized === null || n === "state" || n === "matrix")
1797
2075
  return t.extent;
1798
2076
  const [i, o] = e;
1799
- let [r, l] = jn(t.materialized, i, o);
1800
- const a = Ot(t.config);
2077
+ let [r, l] = Oe(t.materialized, i, o);
2078
+ const a = Vt(t.config);
1801
2079
  return typeof a == "number" && r <= l && (r = Math.min(r, a), l = Math.max(l, a)), { xMin: i, xMax: o, yMin: r, yMax: l };
1802
2080
  }
1803
2081
  /** The values of the limits that are to pull this axis along. */
@@ -1821,12 +2099,12 @@ class ze {
1821
2099
  mapFor(t) {
1822
2100
  const e = t.calendar;
1823
2101
  if (!(e === void 0 || e.length === 0))
1824
- return (n) => fn(n, e);
2102
+ return (n) => Cn(n, e);
1825
2103
  }
1826
2104
  gapFor(t) {
1827
2105
  const e = t.calendar;
1828
2106
  if (!(e === void 0 || e.length === 0))
1829
- return (n) => mn(n, e);
2107
+ return (n) => $n(n, e);
1830
2108
  }
1831
2109
  extentFor(t) {
1832
2110
  return this.axisExtent(t.orientation, t.id);
@@ -1847,7 +2125,7 @@ class ze {
1847
2125
  extent: this.extentFor(r),
1848
2126
  domainMode: r.domain,
1849
2127
  tickCount: r.tickCount,
1850
- tickFormat: r.tickFormat,
2128
+ tickFormat: r.orientation === "y" ? this.yTickFormat(r.id) : r.tickFormat,
1851
2129
  tickValues: r.ticks,
1852
2130
  time: r.time,
1853
2131
  calendar: r.calendar,
@@ -1855,7 +2133,7 @@ class ze {
1855
2133
  limitLabels: r.orientation === "y" ? this.limitsInOrder().map((l) => l.config).filter((l) => l.orientation === "y" && this.limitAxisId(l) === r.id && l.label !== void 0 && l.label !== "").map((l) => l.label) : void 0
1856
2134
  });
1857
2135
  }
1858
- this.layout = Sn({
2136
+ this.layout = Xn({
1859
2137
  width: this.cssWidth,
1860
2138
  height: this.cssHeight,
1861
2139
  padding: this.padding,
@@ -1872,22 +2150,24 @@ class ze {
1872
2150
  /* ================= Series colours and legend entries ================= */
1873
2151
  /** A caller's CSS colour as the canvas can draw it (finding 15). */
1874
2152
  paint(t) {
2153
+ var i;
1875
2154
  const e = this.themeRoot;
1876
2155
  if (e === null) return t;
2156
+ if (((i = this.theme) == null ? void 0 : i.forced) === !0) return this.theme.colorText;
1877
2157
  let n = this.painted.get(t);
1878
- return n === void 0 && (n = nn(e, { color: t }).color, this.painted.set(t, n)), n;
2158
+ return n === void 0 && (n = In(e, { color: t }).color, this.painted.set(t, n)), n;
1879
2159
  }
1880
2160
  colorFor(t) {
1881
2161
  var i;
1882
2162
  if (t.config.color !== void 0) return this.paint(t.config.color);
1883
- if (!It(t.config)) return "";
2163
+ if (!mt(t.config)) return "";
1884
2164
  const e = t.config.tone;
1885
2165
  if (e !== void 0) {
1886
- const o = this.theme ?? R;
2166
+ const o = this.theme ?? H;
1887
2167
  return e === "alarm" ? o.colorAlarm : e === "warning" ? o.colorWarning : o.colorOk;
1888
2168
  }
1889
- const n = ((i = this.theme) == null ? void 0 : i.series) ?? R.series;
1890
- return n[this.paletteSlot(t) % Math.max(1, n.length)] ?? R.series[0] ?? "#2563eb";
2169
+ const n = ((i = this.theme) == null ? void 0 : i.series) ?? H.series;
2170
+ return n[this.paletteSlot(t) % Math.max(1, n.length)] ?? H.series[0] ?? "#2563eb";
1891
2171
  }
1892
2172
  /** Named: the place of the name. Nameless: the position among the series that
1893
2173
  take a palette place, as before - and a warning as soon as that shifts
@@ -1896,49 +2176,75 @@ class ze {
1896
2176
  if (t.config.name !== void 0) return t.slot;
1897
2177
  let e = 0;
1898
2178
  for (const n of this.series.values())
1899
- n.order < t.order && It(n.config) && e++;
1900
- return t.lastSlot !== null && t.lastSlot !== e && tt(
2179
+ n.order < t.order && mt(n.config) && e++;
2180
+ return t.lastSlot !== null && t.lastSlot !== e && nt(
1901
2181
  "series-without-name-colour",
1902
2182
  "a series without a name has changed its colour, because a series before it went away - with `name` it keeps it."
1903
2183
  ), t.lastSlot = e, e;
1904
2184
  }
1905
2185
  nameFor(t, e) {
1906
- return t.config.name !== void 0 ? t.config.name : (tt(
2186
+ return t.config.name !== void 0 ? t.config.name : (nt(
1907
2187
  "series-without-name",
1908
2188
  `a series without a name is called "Series ${e + 1}" in the legend and the tooltip - the name belongs in \`name\`.`
1909
2189
  ), `Series ${e + 1}`);
1910
2190
  }
1911
2191
  legendItems() {
1912
- const t = [], e = /* @__PURE__ */ new Map();
1913
- return this.seriesInOrder().forEach((n, i) => {
1914
- const o = n.config;
1915
- if (o.kind === "state") {
1916
- o.states.forEach((r, l) => {
1917
- const a = `${r.label}\0${r.color}`, c = e.get(a);
1918
- if (c !== void 0) {
1919
- c.seriesIds.includes(n.order) || c.seriesIds.push(n.order), c.hidden && (c.hidden = o.hidden === !0);
2192
+ const t = [], e = /* @__PURE__ */ new Map(), n = this.theme ?? H, i = this.marked() ? this.stateHatches() : null;
2193
+ return this.seriesInOrder().forEach((o, r) => {
2194
+ const l = o.config;
2195
+ if (l.kind === "state") {
2196
+ l.states.forEach((a, c) => {
2197
+ const h = `${a.label}\0${a.color}`, f = e.get(h);
2198
+ if (f !== void 0) {
2199
+ f.seriesIds.includes(o.order) || f.seriesIds.push(o.order), f.hidden && (f.hidden = l.hidden === !0);
1920
2200
  return;
1921
2201
  }
1922
- const h = {
1923
- id: `${n.order}:${l}`,
1924
- name: r.label,
1925
- hidden: o.hidden === !0,
1926
- color: r.color,
1927
- seriesIds: [n.order]
2202
+ const m = {
2203
+ id: `${o.order}:${c}`,
2204
+ name: a.label,
2205
+ hidden: l.hidden === !0,
2206
+ color: a.color,
2207
+ seriesIds: [o.order],
2208
+ mark: i === null ? null : { dash: null, marker: null, swatches: [{ color: this.paint(a.color), hatch: i.get(a.label) ?? "none" }], ground: n.colorBg }
1928
2209
  };
1929
- e.set(a, h), t.push(h);
2210
+ e.set(h, m), t.push(m);
1930
2211
  });
1931
2212
  return;
1932
2213
  }
1933
2214
  t.push({
1934
- id: String(n.order),
1935
- name: this.nameFor(n, i),
1936
- hidden: o.hidden === !0,
1937
- color: o.kind === "matrix" ? ci(qt(o.coloring, this.theme ?? R)) : this.colorFor(n),
1938
- seriesIds: [n.order]
2215
+ id: String(o.order),
2216
+ name: this.nameFor(o, r),
2217
+ hidden: l.hidden === !0,
2218
+ color: l.kind === "matrix" ? Ri(Ft(l.coloring, n)) : this.colorFor(o),
2219
+ seriesIds: [o.order],
2220
+ mark: this.legendMark(o, n)
1939
2221
  });
1940
2222
  }), t;
1941
2223
  }
2224
+ /** What a series' chip shows under encoding by marks. */
2225
+ legendMark(t, e) {
2226
+ if (!this.marked()) return null;
2227
+ const n = t.config;
2228
+ if (n.kind === "matrix")
2229
+ return { dash: null, marker: null, swatches: Ft(n.coloring, e).map((r, l) => ({ color: this.paint(r), hatch: Pt(l) })), ground: e.colorBg };
2230
+ const i = this.marksOf(t);
2231
+ if (i === null) return null;
2232
+ switch (n.kind) {
2233
+ case "line":
2234
+ return { dash: n.dash ?? i.dash, marker: i.marker, swatches: null, ground: e.colorBg };
2235
+ case "area":
2236
+ return {
2237
+ dash: n.dash ?? i.dash,
2238
+ marker: null,
2239
+ swatches: [{ color: this.colorFor(t), hatch: i.hatch, opacity: n.fillOpacity }],
2240
+ ground: e.colorBg
2241
+ };
2242
+ case "scatter":
2243
+ return { dash: null, marker: i.marker, swatches: null, ground: e.colorBg };
2244
+ default:
2245
+ return { dash: null, marker: null, swatches: [{ color: this.colorFor(t), hatch: i.hatch }], ground: e.colorBg };
2246
+ }
2247
+ }
1942
2248
  /* ---------- Limits, ready in pixels ---------- */
1943
2249
  limitColor(t, e) {
1944
2250
  return t.color !== void 0 ? this.paint(t.color) : t.role === "control" ? e.colorAxis : t.role === "zone" ? e.colorGrid : t.severity === "alarm" ? e.colorAlarm : e.colorWarning;
@@ -1956,7 +2262,7 @@ class ze {
1956
2262
  }
1957
2263
  }
1958
2264
  limitItems(t) {
1959
- const e = this.theme ?? R, n = [];
2265
+ const e = this.theme ?? H, n = [];
1960
2266
  for (const { config: i } of this.limitsInOrder()) {
1961
2267
  if (i.kind === "band" !== t) continue;
1962
2268
  const o = this.findAxis(i.orientation, this.limitAxisId(i));
@@ -1969,7 +2275,8 @@ class ze {
1969
2275
  toPx: o.scale.toPx(this.limitAt(i, i.to)),
1970
2276
  color: r,
1971
2277
  band: !0,
1972
- dash: l
2278
+ dash: l,
2279
+ hatch: this.marked()
1973
2280
  });
1974
2281
  else {
1975
2282
  const a = o.scale.toPx(this.limitAt(i, i.value));
@@ -1993,12 +2300,12 @@ class ze {
1993
2300
  if (i.label === void 0 || i.label === "") continue;
1994
2301
  const o = this.findAxis(i.orientation, this.limitAxisId(i));
1995
2302
  if (o === null) continue;
1996
- const r = i.kind === "line" ? this.limitAt(i, i.value) : (this.limitAt(i, i.from) + this.limitAt(i, i.to)) / 2, l = o.scale.toPx(r), a = (((e = this.measurer) == null ? void 0 : e.measure(i.label, rt).width) ?? 0) + 4;
2303
+ const r = i.kind === "line" ? this.limitAt(i, i.value) : (this.limitAt(i, i.from) + this.limitAt(i, i.to)) / 2, l = o.scale.toPx(r), a = (((e = this.measurer) == null ? void 0 : e.measure(i.label, ct).width) ?? 0) + 4;
1997
2304
  t.push({
1998
2305
  id: n,
1999
2306
  axisKey: o.key,
2000
2307
  px: l,
2001
- labelLeft: We(l, a, this.cssWidth),
2308
+ labelLeft: Qe(l, a, this.cssWidth),
2002
2309
  label: i.label,
2003
2310
  severity: i.severity,
2004
2311
  role: i.role
@@ -2008,101 +2315,113 @@ class ze {
2008
2315
  }
2009
2316
  /* ================= Drawing ================= */
2010
2317
  drawItems() {
2011
- const t = [], e = this.seriesInOrder().filter((r) => r.config.hidden !== !0), n = this.highlight, i = n !== null && e.some((r) => n.includes(r.order)) ? n : null, o = ni(
2012
- e.map((r) => ({
2013
- order: r.order,
2014
- kind: r.config.kind,
2015
- xAxisId: r.config.xAxisId,
2016
- step: r.step ?? 0,
2017
- fraction: r.config.kind === "bar" ? r.config.barWidth : 0
2318
+ const t = [];
2319
+ let e;
2320
+ const n = this.seriesInOrder().filter((l) => l.config.hidden !== !0), i = this.highlight, o = i !== null && n.some((l) => i.includes(l.order)) ? i : null, r = Ei(
2321
+ n.map((l) => ({
2322
+ order: l.order,
2323
+ kind: l.config.kind,
2324
+ xAxisId: l.config.xAxisId,
2325
+ step: l.step ?? 0,
2326
+ fraction: l.config.kind === "bar" ? l.config.barWidth : 0,
2327
+ stack: U(l.config)
2018
2328
  }))
2019
2329
  );
2020
- return e.forEach((r) => {
2021
- const l = r.materialized;
2022
- if (l === null) return;
2023
- const a = this.findAxis("x", r.config.xAxisId), c = this.findAxis("y", r.config.yAxisId);
2024
- if (a === null || c === null) return;
2025
- const h = i !== null && !i.includes(r.order), f = {
2026
- x: l.x,
2027
- y: l.y,
2028
- length: l.length,
2029
- xScale: a.scale,
2030
- yScale: c.scale,
2031
- color: this.colorFor(r),
2032
- alpha: h ? 0.25 : 1
2033
- }, m = r.config, p = m.kind === "line" || m.kind === "area" ? Kn(l, a.scale.domain[0], a.scale.domain[1], a.scale.m, a.scale.b, this.layout.plot.width) : l;
2034
- switch (f.x = p.x, f.y = p.y, f.length = p.length, m.kind) {
2330
+ return n.forEach((l) => {
2331
+ const a = l.materialized;
2332
+ if (a === null) return;
2333
+ const c = this.findAxis("x", l.config.xAxisId), h = this.findAxis("y", l.config.yAxisId);
2334
+ if (c === null || h === null) return;
2335
+ const f = o !== null && !o.includes(l.order), m = this.marksOf(l), p = {
2336
+ x: a.x,
2337
+ y: a.y,
2338
+ length: a.length,
2339
+ xScale: c.scale,
2340
+ yScale: h.scale,
2341
+ color: this.colorFor(l),
2342
+ alpha: f ? 0.25 : 1
2343
+ }, u = l.config, g = u.kind === "line" || u.kind === "area" ? on(a, c.scale.domain[0], c.scale.domain[1], c.scale.m, c.scale.b, this.layout.plot.width) : a;
2344
+ switch (p.x = g.x, p.y = g.y, p.length = g.length, u.kind) {
2035
2345
  case "line":
2036
2346
  t.push({
2037
- ...f,
2347
+ ...p,
2038
2348
  kind: "line",
2039
- strokeWidth: m.strokeWidth,
2040
- dash: m.dash,
2041
- markers: m.markers,
2042
- step: m.step
2349
+ strokeWidth: u.strokeWidth,
2350
+ // A dash of the caller's own wins over the one its place gives.
2351
+ dash: u.dash ?? (m == null ? void 0 : m.dash),
2352
+ markers: u.markers,
2353
+ step: u.step,
2354
+ marker: m == null ? void 0 : m.marker
2043
2355
  });
2044
2356
  break;
2045
2357
  case "area":
2046
2358
  t.push({
2047
- ...f,
2359
+ ...p,
2048
2360
  kind: "area",
2049
- y0: p.y0,
2361
+ y0: g.y0,
2050
2362
  baseline: 0,
2051
- fillOpacity: m.fillOpacity,
2052
- strokeWidth: m.strokeWidth,
2053
- dash: m.dash
2363
+ fillOpacity: u.fillOpacity,
2364
+ strokeWidth: u.strokeWidth,
2365
+ dash: u.dash ?? (m == null ? void 0 : m.dash),
2366
+ hatch: m == null ? void 0 : m.hatch,
2367
+ edges: l.stacked !== null
2054
2368
  });
2055
2369
  break;
2056
2370
  case "bar": {
2057
- const u = o.get(r.order) ?? {
2371
+ const d = r.get(l.order) ?? {
2058
2372
  index: 0,
2059
2373
  size: 1,
2060
- step: r.step ?? 0,
2061
- fraction: m.barWidth
2062
- }, d = a.scale.domain, y = ei(
2063
- ti(u.step, d[1] - d[0]),
2064
- u.fraction,
2065
- u.index,
2066
- u.size
2374
+ step: l.step ?? 0,
2375
+ fraction: u.barWidth
2376
+ }, y = c.scale.domain, b = Li(
2377
+ Si(d.step, y[1] - y[0]),
2378
+ d.fraction,
2379
+ d.index,
2380
+ d.size
2067
2381
  );
2068
2382
  t.push({
2069
- ...f,
2383
+ ...p,
2070
2384
  kind: "bar",
2385
+ y0: a.y0,
2071
2386
  baseline: 0,
2072
- offset: y.offset,
2073
- width: y.width
2387
+ offset: b.offset,
2388
+ width: b.width,
2389
+ hatch: m == null ? void 0 : m.hatch,
2390
+ edges: l.stacked !== null
2074
2391
  });
2075
2392
  break;
2076
2393
  }
2077
2394
  case "scatter":
2078
- t.push({ ...f, kind: "scatter", radius: m.radius });
2395
+ t.push({ ...p, kind: "scatter", radius: u.radius, marker: m == null ? void 0 : m.marker });
2079
2396
  break;
2080
2397
  case "state": {
2081
- const u = this.lanePx(m, c);
2398
+ const d = this.lanePx(u, h);
2082
2399
  t.push({
2083
- ...f,
2400
+ ...p,
2084
2401
  kind: "state",
2085
- colors: m.states.map((d) => this.paint(d.color)),
2086
- laneTop: u.top,
2087
- laneBottom: u.bottom,
2088
- lastEnd: this.lastEnd(r, l, a)
2402
+ colors: u.states.map((y) => this.paint(y.color)),
2403
+ laneTop: d.top,
2404
+ laneBottom: d.bottom,
2405
+ lastEnd: this.lastEnd(l, a, c),
2406
+ hatches: this.marked() ? u.states.map((y) => (e ?? (e = this.stateHatches())).get(y.label) ?? "none") : null
2089
2407
  });
2090
2408
  break;
2091
2409
  }
2092
2410
  case "matrix": {
2093
- const u = qt(m.coloring, this.theme ?? R).map((d) => this.paint(d));
2411
+ const d = Ft(u.coloring, this.theme ?? H).map((y) => this.paint(y));
2094
2412
  t.push({
2095
- ...f,
2413
+ ...p,
2096
2414
  kind: "matrix",
2097
- buckets: r.buckets ?? (r.buckets = Me(l, m.coloring, u.length)),
2098
- colors: u,
2099
- width: Nt(
2100
- r.step ?? 0,
2101
- a.scale.domain[1] - a.scale.domain[0]
2102
- ),
2103
- height: Nt(
2104
- r.cellHeight ?? 0,
2415
+ buckets: l.buckets ?? (l.buckets = ze(a, u.coloring, d.length)),
2416
+ colors: d,
2417
+ hatches: this.marked() ? d.map((y, b) => Pt(b)) : null,
2418
+ width: Et(
2419
+ l.step ?? 0,
2105
2420
  c.scale.domain[1] - c.scale.domain[0]
2421
+ ),
2422
+ height: Et(
2423
+ l.cellHeight ?? 0,
2424
+ h.scale.domain[1] - h.scale.domain[0]
2106
2425
  )
2107
2426
  });
2108
2427
  break;
@@ -2121,7 +2440,7 @@ class ze {
2121
2440
  const l = r.x[r.length - 1];
2122
2441
  l > i && (i = l);
2123
2442
  }
2124
- return En(e.x, e.length, i, t.step ?? 0, n.scale.domain[1]);
2443
+ return Qn(e.x, e.length, i, t.step ?? 0, n.scale.domain[1]);
2125
2444
  }
2126
2445
  /** Lane of a state series in pixels. Without a value the whole domain of its y
2127
2446
  axis: a single series fills its band, a stack gets a domain with one unit per
@@ -2135,7 +2454,7 @@ class ze {
2135
2454
  const t = this.seriesCtx, e = this.theme;
2136
2455
  if (!t || !e) return;
2137
2456
  const n = typeof performance > "u" ? 0 : performance.now();
2138
- Vn(t, {
2457
+ hi(t, {
2139
2458
  width: this.cssWidth,
2140
2459
  height: this.cssHeight,
2141
2460
  plot: this.layout.plot,
@@ -2148,7 +2467,7 @@ class ze {
2148
2467
  }
2149
2468
  drawOverlayLayer() {
2150
2469
  const t = this.overlayCtx, e = this.theme;
2151
- !t || !e || (_n(t, {
2470
+ !t || !e || (di(t, {
2152
2471
  width: this.cssWidth,
2153
2472
  height: this.cssHeight,
2154
2473
  plot: this.layout.plot,
@@ -2191,7 +2510,7 @@ class ze {
2191
2510
  const o = this.findAxis("x", n.primary.entry.config.xAxisId);
2192
2511
  if (o !== null && this.share({ axisId: o.id, value: o.scale.fromPx(n.state.hit.xPx) }), i !== this.hoverKey) {
2193
2512
  const r = n.primary.entry.config.xAxisId;
2194
- this.hoverKey = i, this.hoverXLabel = this.xLabel(r, n.primary.xValue, oi(n.primary)), this.hoverRows = n.chosen.map((l) => this.tooltipRow(l, r)), this.hoverOrders = n.chosen.map((l) => l.entry.order), this.pushHoverSnapshot();
2513
+ this.hoverKey = i, this.hoverXLabel = this.xLabel(r, n.primary.xValue, Pi(n.primary)), this.hoverRows = n.chosen.map((l) => this.tooltipRow(l, r)), this.hoverOrders = n.chosen.map((l) => l.entry.order), this.hoverTotals = this.totalsOf(n.chosen), this.pushHoverSnapshot();
2195
2514
  }
2196
2515
  return !0;
2197
2516
  }
@@ -2206,23 +2525,24 @@ class ze {
2206
2525
  hitTest(t, e) {
2207
2526
  var p;
2208
2527
  const n = ((p = this.tooltip) == null ? void 0 : p.mode) ?? "x", i = [];
2209
- if (this.seriesInOrder().forEach((u, d) => {
2210
- const y = u.materialized;
2211
- if (y === null || y.length === 0 || u.config.hidden === !0) return;
2212
- const g = u.config, b = this.findAxis("x", g.xAxisId), k = this.findAxis("y", g.yAxisId);
2213
- if (b === null || k === null) return;
2214
- const T = b.scale.fromPx(t), O = k.scale.fromPx(e), A = this.hitIn(u, y, b, k, e, T, O, n);
2528
+ if (this.seriesInOrder().forEach((u, g) => {
2529
+ const d = u.materialized;
2530
+ if (d === null || d.length === 0 || u.config.hidden === !0) return;
2531
+ const y = u.config, b = this.findAxis("x", y.xAxisId), v = this.findAxis("y", y.yAxisId);
2532
+ if (b === null || v === null) return;
2533
+ const w = b.scale.fromPx(t), L = v.scale.fromPx(e), A = this.hitIn(u, d, b, v, e, w, L, n);
2215
2534
  A !== null && i.push({
2216
2535
  entry: u,
2217
2536
  index: A.index,
2218
2537
  color: A.color ?? this.colorFor(u),
2219
- name: this.nameFor(u, d),
2538
+ name: this.nameFor(u, g),
2220
2539
  px: A.px,
2221
2540
  py: A.py,
2222
2541
  xValue: A.xValue,
2223
2542
  yValue: A.yValue,
2224
2543
  marked: A.marked,
2225
2544
  areal: A.areal,
2545
+ covers: A.covers === !0,
2226
2546
  value: A.value,
2227
2547
  segment: A.segment
2228
2548
  });
@@ -2231,11 +2551,12 @@ class ze {
2231
2551
  let l = r[0];
2232
2552
  if (n === "nearest") {
2233
2553
  let u = Number.POSITIVE_INFINITY;
2234
- for (const d of o) {
2235
- const y = d.px - t, g = d.py - e, b = y * y + g * g;
2236
- b < u && (u = b, l = d);
2554
+ const g = o.filter((d) => d.covers);
2555
+ for (const d of g.length > 0 ? g : o) {
2556
+ const y = d.px - t, b = d.py - e, v = y * y + b * b;
2557
+ (v < u || v === u && d.covers) && (u = v, l = d);
2237
2558
  }
2238
- if (u > Te * Te) {
2559
+ if (g.length === 0 && u > We * We) {
2239
2560
  for (const d of i)
2240
2561
  if (d.areal) {
2241
2562
  l = d;
@@ -2244,16 +2565,16 @@ class ze {
2244
2565
  }
2245
2566
  } else {
2246
2567
  let u = Number.POSITIVE_INFINITY;
2247
- for (const d of r) {
2248
- const y = Math.abs(d.px - t);
2249
- y < u && (u = y, l = d);
2568
+ for (const g of r) {
2569
+ const d = Math.abs(g.px - t);
2570
+ d < u && (u = d, l = g);
2250
2571
  }
2251
2572
  }
2252
2573
  const a = n === "nearest" ? [l] : i.filter(
2253
2574
  // An area is always included: it covers the pointer, otherwise it
2254
2575
  // would not have reported a hit at all. Only points have to share the
2255
2576
  // x position.
2256
- (u) => u.areal || Math.abs(u.px - l.px) <= ii
2577
+ (u) => u.areal || Math.abs(u.px - l.px) <= Fi
2257
2578
  ), c = a.map((u) => ({
2258
2579
  seriesName: u.name,
2259
2580
  color: u.color,
@@ -2320,7 +2641,7 @@ class ze {
2320
2641
  const e = this.emphasised();
2321
2642
  if (e === null) return !1;
2322
2643
  if (e.config.kind === "matrix") return this.cellKey(t.key, e);
2323
- const n = t.shiftKey ? void 0 : yi[t.key];
2644
+ const n = t.shiftKey ? void 0 : Yi[t.key];
2324
2645
  return n !== void 0 ? (this.walk(n), !0) : !t.shiftKey && (t.key === "ArrowDown" || t.key === "ArrowUp") ? (this.changeSeries(t.key === "ArrowDown" ? 1 : -1), !0) : !1;
2325
2646
  }
2326
2647
  /** Zoom and pan by key (Q6), only where the caller controls the domain:
@@ -2329,8 +2650,8 @@ class ze {
2329
2650
  var i;
2330
2651
  if (!this.hasZoom()) return !1;
2331
2652
  const e = this.layout.plot, n = ((i = this.hover) == null ? void 0 : i.hit.xPx) ?? e.x + e.width / 2;
2332
- if (t.key === "+" || t.key === "=") this.zoomAt(n, 1 / Se);
2333
- else if (t.key === "-" || t.key === "_") this.zoomAt(n, Se);
2653
+ if (t.key === "+" || t.key === "=") this.zoomAt(n, 1 / Be);
2654
+ else if (t.key === "-" || t.key === "_") this.zoomAt(n, Be);
2334
2655
  else if (t.key === "0") this.doubleClick();
2335
2656
  else if (t.shiftKey && (t.key === "ArrowLeft" || t.key === "ArrowRight"))
2336
2657
  this.panBy((t.key === "ArrowLeft" ? 1 : -1) * e.width / 10);
@@ -2351,7 +2672,7 @@ class ze {
2351
2672
  }
2352
2673
  const n = e === null ? null : this.findAxis("x", e.config.xAxisId);
2353
2674
  if (e === null || n === null) return;
2354
- const i = this.activeBy === null ? null : this.walkFrom(), o = Bt(this.walked(e), i, t, n.scale.domain);
2675
+ const i = this.activeBy === null ? null : this.walkFrom(), o = jt(this.walked(e), i, t, n.scale.domain);
2355
2676
  o !== null && this.showPosition(e, o);
2356
2677
  }
2357
2678
  changeSeries(t) {
@@ -2361,7 +2682,7 @@ class ze {
2361
2682
  this.emphasis = i.order, this.setHighlight([i.order]), this.keyHighlight = !0;
2362
2683
  const o = this.walkFrom(), r = this.findAxis("x", i.config.xAxisId);
2363
2684
  if (r === null) return;
2364
- const l = o === null ? Bt(this.walked(i), null, "last", r.scale.domain) : ve(this.walked(i), o, r.scale.domain);
2685
+ const l = o === null ? jt(this.walked(i), null, "last", r.scale.domain) : De(this.walked(i), o, r.scale.domain);
2365
2686
  if (l !== null)
2366
2687
  if (this.keyCell = null, i.config.kind === "matrix") {
2367
2688
  const a = this.columnStart(i, l);
@@ -2374,21 +2695,21 @@ class ze {
2374
2695
  cellKey(t, e) {
2375
2696
  const n = e.materialized, i = this.keyCell ?? this.lastCell(e);
2376
2697
  if (i === null) return !1;
2377
- const o = xi[t];
2698
+ const o = Gi[t];
2378
2699
  let r;
2379
- if (o !== void 0) r = ke(n, i, o);
2380
- else if (t === "Home" || t === "End") r = Yn(n, i, t === "Home" ? "start" : "end");
2700
+ if (o !== void 0) r = Pe(n, i, o);
2701
+ else if (t === "Home" || t === "End") r = mi(n, i, t === "Home" ? "start" : "end");
2381
2702
  else return !1;
2382
2703
  return r === i && (o === "up" || o === "down") && this.walkable().length > 1 ? (this.changeSeries(o === "down" ? 1 : -1), !0) : (this.showCell(e, r), !0);
2383
2704
  }
2384
2705
  /** Where a matrix' walk starts: the newest column, its lowest row. */
2385
2706
  lastCell(t) {
2386
- const e = t.materialized, n = this.findAxis("x", t.config.xAxisId), i = n === null ? null : Bt([e], null, "last", n.scale.domain);
2707
+ const e = t.materialized, n = this.findAxis("x", t.config.xAxisId), i = n === null ? null : jt([e], null, "last", n.scale.domain);
2387
2708
  return i === null ? null : this.columnStart(t, i);
2388
2709
  }
2389
2710
  /** The lowest cell with a value in a matrix' column. */
2390
2711
  columnStart(t, e) {
2391
- const n = { x: e, y: Number.NEGATIVE_INFINITY }, i = ke(t.materialized, n, "up");
2712
+ const n = { x: e, y: Number.NEGATIVE_INFINITY }, i = Pe(t.materialized, n, "up");
2392
2713
  return i === n ? null : i;
2393
2714
  }
2394
2715
  showCell(t, e, n = !0) {
@@ -2405,7 +2726,7 @@ class ze {
2405
2726
  const a = this.lanePx(t.config, o);
2406
2727
  l = (a.top + a.bottom) / 2;
2407
2728
  } else {
2408
- const a = r.y[ne(r.x, r.length, e)];
2729
+ const a = r.y[he(r.x, r.length, e)];
2409
2730
  l = Number.isNaN(a) ? this.layout.plot.y + this.layout.plot.height / 2 : o.scale.toPx(a);
2410
2731
  }
2411
2732
  this.moveKey(e, i.scale.toPx(e), l, n);
@@ -2421,24 +2742,38 @@ class ze {
2421
2742
  this.readoutTimer = null;
2422
2743
  const t = this.readoutEl;
2423
2744
  t !== null && this.activeBy === "keyboard" && (t.textContent = this.readoutText());
2424
- }, mi));
2745
+ }, _i));
2425
2746
  }
2426
2747
  readoutText() {
2427
- var i;
2748
+ var o;
2428
2749
  const t = this.hover;
2429
2750
  if (t === null) return "";
2430
- const e = t.hit.points.map((o, r) => {
2431
- const l = this.hoverRows[r];
2432
- return { order: this.hoverOrders[r], name: o.seriesName, value: (l == null ? void 0 : l.value) ?? "", x: (l == null ? void 0 : l.x) ?? "" };
2433
- }), n = (i = this.emphasised()) == null ? void 0 : i.order;
2434
- return e.sort((o, r) => +(r.order === n) - +(o.order === n)), this.wording.readout(this.hoverXLabel, e);
2751
+ const e = t.hit.points.map((r, l) => {
2752
+ const a = this.hoverRows[l];
2753
+ return { order: this.hoverOrders[l], name: r.seriesName, value: (a == null ? void 0 : a.value) ?? "", x: (a == null ? void 0 : a.x) ?? "" };
2754
+ }), n = (o = this.emphasised()) == null ? void 0 : o.order;
2755
+ e.sort((r, l) => +(l.order === n) - +(r.order === n));
2756
+ const i = this.hoverTotals.map((r) => ({ name: r.name, value: r.value, x: "" }));
2757
+ return this.wording.readout(this.hoverXLabel, [...e, ...i]);
2758
+ }
2759
+ /** The totals of the stacks in a hit (K4), each after its stack's last
2760
+ member. A normalised stack's total is no share: it is written in the
2761
+ series' own `format`, as its readings would be. */
2762
+ totalsOf(t) {
2763
+ const e = [];
2764
+ return t.forEach((n, i) => {
2765
+ const o = U(n.entry.config), r = n.entry.stacked;
2766
+ if (o === void 0 || r === null || t.some((c, h) => h > i && U(c.entry.config) === o)) return;
2767
+ const l = r.total[n.index], a = r.normalize ? (n.entry.config.format ?? St)(l) : this.formatY(n.entry, l);
2768
+ e.push({ after: i, name: this.wording.stackTotal, value: a });
2769
+ }), e;
2435
2770
  }
2436
2771
  /** The summary is rebuilt after a layout, but not on every one: a zoom lays
2437
2772
  out every frame, and the summary reads every visible point. */
2438
2773
  scheduleSummary() {
2439
2774
  this.summaryEl !== null && (this.summaryTimer !== null && clearTimeout(this.summaryTimer), this.summaryTimer = setTimeout(() => {
2440
2775
  this.summaryTimer = null, this.summaryEl !== null && (this.summaryEl.textContent = this.summaryText());
2441
- }, pi));
2776
+ }, Vi));
2442
2777
  }
2443
2778
  /** Kind of content, series by name, the visible stretch, each series' range
2444
2779
  in it and the keys (R10). A band has no range - its values are states. */
@@ -2462,37 +2797,138 @@ class ze {
2462
2797
  /** The lowest and highest value of a series inside its x axis' domain; a
2463
2798
  cell's value, every other kind's y. */
2464
2799
  visibleRange(t) {
2800
+ var c;
2465
2801
  const e = t.materialized, n = this.findAxis("x", t.config.xAxisId);
2466
2802
  if (e === null || n === null) return null;
2467
- const [i, o] = n.scale.domain, r = e.w ?? e.y;
2803
+ const [i, o] = n.scale.domain, r = e.w ?? ((c = t.stacked) == null ? void 0 : c.value) ?? e.y;
2468
2804
  let l = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY;
2469
- for (let c = ut(e.x, e.length, i); c < e.length && e.x[c] <= o; c++) {
2470
- const h = r[c];
2471
- !Number.isFinite(h) || Number.isNaN(e.y[c]) || (h < l && (l = h), h > a && (a = h));
2805
+ for (let h = it(e.x, e.length, i); h < e.length && e.x[h] <= o; h++) {
2806
+ const f = r[h];
2807
+ !Number.isFinite(f) || Number.isNaN(e.y[h]) || (f < l && (l = f), f > a && (a = f));
2472
2808
  }
2473
2809
  return l <= a ? [l, a] : null;
2474
2810
  }
2475
2811
  /** A value as the tooltip writes it: the series' format, else its y axis'
2476
2812
  (a cell's value has no y axis format). */
2477
2813
  formatY(t, e) {
2478
- var o;
2814
+ var o, r, l;
2479
2815
  const n = t.config;
2480
- if (n.format !== void 0) return n.format(e);
2481
- if (n.kind === "matrix") return kt(e);
2482
- const i = (o = this.findAxisConfig("y", n.yAxisId)) == null ? void 0 : o.tickFormat;
2483
- return i === void 0 ? kt(e) : i(e);
2816
+ if (n.format !== void 0 && ((o = t.stacked) == null ? void 0 : o.normalize) !== !0) return n.format(e);
2817
+ if (n.kind === "matrix") return St(e);
2818
+ const i = ((r = t.stacked) == null ? void 0 : r.normalize) === !0 ? this.yTickFormat(n.yAxisId) : (l = this.findAxisConfig("y", n.yAxisId)) == null ? void 0 : l.tickFormat;
2819
+ return i === void 0 ? St(e) : i(e);
2820
+ }
2821
+ /** A y axis' `tickFormat`; without one, an axis that carries a normalised
2822
+ stack reads in percent (K5). */
2823
+ yTickFormat(t) {
2824
+ var n;
2825
+ const e = (n = this.findAxisConfig("y", t)) == null ? void 0 : n.tickFormat;
2826
+ if (e !== void 0) return e;
2827
+ for (const i of this.series.values())
2828
+ if (i.config.yAxisId === t && _t(i.config)) return this.percent;
2829
+ }
2830
+ /* ---------- The data table (charts-alternatives 01) ---------- */
2831
+ /** What the data table lists: one table per x axis for the series on it, one
2832
+ per matrix - a matrix has two positions per value, and shares no rows.
2833
+ Only the visible domain, and above the limit its downsampled course
2834
+ (table.ts). Called by the open table, once per layout. */
2835
+ dataTableGroups() {
2836
+ const t = this.seriesInOrder(), e = [], n = /* @__PURE__ */ new Map();
2837
+ for (const i of this.walkable()) {
2838
+ const o = i.config.kind === "matrix" ? void 0 : n.get(i.config.xAxisId);
2839
+ if (o !== void 0) o.push(i);
2840
+ else {
2841
+ const r = [i];
2842
+ e.push(r), i.config.kind !== "matrix" && n.set(i.config.xAxisId, r);
2843
+ }
2844
+ }
2845
+ return e.flatMap((i) => {
2846
+ const o = i[0];
2847
+ return o.config.kind === "matrix" ? this.matrixTable(o, t) ?? [] : this.courseTable(i, t) ?? [];
2848
+ });
2849
+ }
2850
+ /** The series of one x axis, merged on their x. */
2851
+ courseTable(t, e) {
2852
+ var f;
2853
+ const n = this.wording, i = t[0].config.xAxisId, o = this.findAxis("x", i);
2854
+ if (o === null) return null;
2855
+ const [r, l] = o.scale.domain, a = yi(
2856
+ t.map((m) => {
2857
+ const p = m.materialized;
2858
+ return m.stacked !== null ? { ...p, y: m.stacked.value, y0: null } : m.config.kind === "state" ? { ...p, changesOnly: !0 } : p;
2859
+ }),
2860
+ r,
2861
+ l
2862
+ );
2863
+ let c = !1;
2864
+ for (let m = 1; m < a.x.length && !c; m++) {
2865
+ const p = a.x[m] - a.x[m - 1];
2866
+ c = p > 0 && p < V;
2867
+ }
2868
+ const h = n.tableCaption(this.xLabel(i, r), this.xLabel(i, l));
2869
+ return {
2870
+ key: `x:${i}`,
2871
+ caption: a.thinned ? `${h} ${n.downsampled(a.readings)}` : h,
2872
+ columns: [
2873
+ ((f = this.findAxisConfig("x", i)) == null ? void 0 : f.label) ?? n.positionColumn,
2874
+ ...t.map((m) => this.nameFor(m, e.indexOf(m)))
2875
+ ],
2876
+ rows: a.x.map((m, p) => [
2877
+ this.xLabel(i, m, c),
2878
+ ...t.map((u, g) => {
2879
+ var d;
2880
+ return this.cellText(u, a.courses[g], ((d = a.at[p]) == null ? void 0 : d[g]) ?? -1);
2881
+ })
2882
+ ])
2883
+ };
2884
+ }
2885
+ /** One cell: empty where the series has no reading there or a gap; a
2886
+ state's name; a corridor's two edges; every other value as the tooltip
2887
+ writes it. */
2888
+ cellText(t, e, n) {
2889
+ var l, a;
2890
+ if (n < 0) return "";
2891
+ const i = e.y[n];
2892
+ if (Number.isNaN(i)) return "";
2893
+ const o = t.config;
2894
+ if (o.kind === "state") return ((l = o.states[i | 0]) == null ? void 0 : l.label) ?? "";
2895
+ const r = (a = e.y0) == null ? void 0 : a[n];
2896
+ return r !== void 0 && !Number.isNaN(r) ? `${this.formatY(t, r)} – ${this.formatY(t, i)}` : this.formatY(t, i);
2897
+ }
2898
+ /** A matrix' table: its cells inside the visible x domain, by column and
2899
+ row, with their value. */
2900
+ matrixTable(t, e) {
2901
+ var h, f;
2902
+ const n = t.materialized, i = this.findAxis("x", t.config.xAxisId), o = this.findAxis("y", t.config.yAxisId);
2903
+ if (n === null || n.w === null || i === null || o === null) return null;
2904
+ const [r, l] = i.scale.domain, a = [];
2905
+ for (let m = 0; m < n.length; m++) {
2906
+ const p = n.x[m], u = n.w[m];
2907
+ p < r || p > l || !Number.isFinite(u) || a.push([this.xLabel(i.id, p), o.format(n.y[m]), this.formatY(t, u)]);
2908
+ }
2909
+ const c = this.wording;
2910
+ return {
2911
+ key: `m:${t.order}`,
2912
+ caption: c.tableCaption(i.format(r), i.format(l)),
2913
+ columns: [
2914
+ ((h = this.findAxisConfig("x", t.config.xAxisId)) == null ? void 0 : h.label) ?? c.positionColumn,
2915
+ ((f = this.findAxisConfig("y", t.config.yAxisId)) == null ? void 0 : f.label) ?? c.rowColumn,
2916
+ this.nameFor(t, e.indexOf(t))
2917
+ ],
2918
+ rows: a
2919
+ };
2484
2920
  }
2485
2921
  /** After a layout - new data, a new domain -, the keyboard's point goes to
2486
2922
  the nearest position still visible (Q6), or goes away. */
2487
2923
  reapplyKey() {
2488
- const t = this.emphasised(), e = t === null ? null : this.findAxis("x", t.config.xAxisId), n = t === null || e === null || this.keyX === null ? null : ve(this.walked(t), this.keyX, e.scale.domain);
2924
+ const t = this.emphasised(), e = t === null ? null : this.findAxis("x", t.config.xAxisId), n = t === null || e === null || this.keyX === null ? null : De(this.walked(t), this.keyX, e.scale.domain);
2489
2925
  if (t === null || n === null) {
2490
2926
  this.clearActive();
2491
2927
  return;
2492
2928
  }
2493
2929
  if (t.config.kind !== "matrix") this.showPosition(t, n, !1);
2494
2930
  else {
2495
- const i = this.keyCell, o = t.materialized, r = i !== null && Bn(o, { x: n, y: i.y }) ? { x: n, y: i.y } : this.columnStart(t, n);
2931
+ const i = this.keyCell, o = t.materialized, r = i !== null && pi(o, { x: n, y: i.y }) ? { x: n, y: i.y } : this.columnStart(t, n);
2496
2932
  r !== null && this.showCell(t, r, !1);
2497
2933
  }
2498
2934
  }
@@ -2616,16 +3052,21 @@ class ze {
2616
3052
  written in its format. A series' own `format` comes before either. */
2617
3053
  tooltipRow(t, e) {
2618
3054
  var l, a;
2619
- const n = t.entry.config, i = (l = t.segment) == null ? void 0 : l.label;
2620
- let o;
2621
- if (i !== void 0 && i !== "") o = i;
2622
- else if (t.value !== void 0) o = (n.format ?? kt)(t.value);
2623
- else {
2624
- const c = n.format ?? ((a = this.findAxisConfig("y", n.yAxisId)) == null ? void 0 : a.tickFormat);
2625
- o = c === void 0 ? kt(t.yValue) : c(t.yValue);
2626
- }
2627
- const r = n.xAxisId === e ? "" : this.xLabel(n.xAxisId, t.xValue);
2628
- return { value: o, x: r };
3055
+ const n = t.entry.config, i = (l = t.segment) == null ? void 0 : l.label, o = i !== void 0 && i !== "" ? i : this.formatY(t.entry, t.value ?? t.yValue), r = n.xAxisId === e ? "" : this.xLabel(n.xAxisId, t.xValue);
3056
+ return { value: o, x: r, chip: ((a = this.theme) == null ? void 0 : a.forced) === !0 ? this.tooltipChip(t, this.theme) : null };
3057
+ }
3058
+ /** A hit's chip drawn as its legend entry is: a band's state and a cell's
3059
+ step by their hatch, every other series by its marks. */
3060
+ tooltipChip(t, e) {
3061
+ var r, l;
3062
+ const n = t.entry.config, i = (a) => ({
3063
+ color: e.colorText,
3064
+ mark: { dash: null, marker: null, swatches: [{ color: e.colorText, hatch: a }], ground: e.colorBg }
3065
+ });
3066
+ if (n.kind === "state") return i(this.stateHatches().get(((r = t.segment) == null ? void 0 : r.label) ?? "") ?? "none");
3067
+ if (n.kind === "matrix") return i(Pt(((l = t.entry.buckets) == null ? void 0 : l[t.index]) ?? 0));
3068
+ const o = this.legendMark(t.entry, e);
3069
+ return o === null ? null : { color: this.colorFor(t.entry), mark: o };
2629
3070
  }
2630
3071
  /** The hit of one series - one different question per kind.
2631
3072
 
@@ -2636,69 +3077,70 @@ class ze {
2636
3077
  hitIn(t, e, n, i, o, r, l, a) {
2637
3078
  const c = t.config, h = e.length;
2638
3079
  if (c.kind === "state") {
2639
- const u = this.lanePx(c, i);
2640
- if (o < u.top || o > u.bottom) return null;
2641
- const d = ge(e.x, h, r);
3080
+ const g = this.lanePx(c, i);
3081
+ if (o < g.top || o > g.bottom) return null;
3082
+ const d = Ee(e.x, h, r);
2642
3083
  if (d < 0) return null;
2643
3084
  const y = e.y[d];
2644
3085
  if (Number.isNaN(y)) return null;
2645
- const g = e.x[d], b = Ve(e.x, h, d, this.lastEnd(t, e, n));
2646
- if (d === h - 1 && !(r < b)) return null;
2647
- const k = c.states[y | 0];
3086
+ const b = e.x[d], v = nn(e.x, h, d, this.lastEnd(t, e, n));
3087
+ if (d === h - 1 && !(r < v)) return null;
3088
+ const w = c.states[y | 0];
2648
3089
  return {
2649
3090
  index: d,
2650
- px: n.scale.toPx(g),
2651
- py: (u.top + u.bottom) / 2,
2652
- xValue: g,
3091
+ px: n.scale.toPx(b),
3092
+ py: (g.top + g.bottom) / 2,
3093
+ xValue: b,
2653
3094
  yValue: y,
2654
3095
  marked: !1,
2655
3096
  areal: !0,
2656
- color: k == null ? void 0 : k.color,
2657
- segment: { from: g, to: b, label: (k == null ? void 0 : k.label) ?? "" }
3097
+ color: w == null ? void 0 : w.color,
3098
+ segment: { from: b, to: v, label: (w == null ? void 0 : w.label) ?? "" }
2658
3099
  };
2659
3100
  }
2660
3101
  if (c.kind === "matrix") {
2661
- const u = Gn(
3102
+ const g = ki(
2662
3103
  e.x,
2663
3104
  e.y,
2664
3105
  h,
2665
3106
  r,
2666
3107
  l,
2667
- Nt(t.step ?? 0, n.scale.domain[1] - n.scale.domain[0]),
2668
- Nt(t.cellHeight ?? 0, i.scale.domain[1] - i.scale.domain[0])
3108
+ Et(t.step ?? 0, n.scale.domain[1] - n.scale.domain[0]),
3109
+ Et(t.cellHeight ?? 0, i.scale.domain[1] - i.scale.domain[0])
2669
3110
  );
2670
- if (u < 0) return null;
2671
- const d = e.w, y = d === null ? Number.NaN : d[u];
3111
+ if (g < 0) return null;
3112
+ const d = e.w, y = d === null ? Number.NaN : d[g];
2672
3113
  if (!Number.isFinite(y)) return null;
2673
- const g = e.x[u], b = e.y[u], k = qt(c.coloring, this.theme ?? R);
2674
- return t.buckets ?? (t.buckets = Me(e, c.coloring, k.length)), {
2675
- index: u,
2676
- px: n.scale.toPx(g),
2677
- py: i.scale.toPx(b),
2678
- color: k[t.buckets[u]],
2679
- xValue: g,
3114
+ const b = e.x[g], v = e.y[g], w = Ft(c.coloring, this.theme ?? H);
3115
+ return t.buckets ?? (t.buckets = ze(e, c.coloring, w.length)), {
3116
+ index: g,
3117
+ px: n.scale.toPx(b),
3118
+ py: i.scale.toPx(v),
3119
+ color: w[t.buckets[g]],
3120
+ xValue: b,
2680
3121
  // yValue stays the position on the y axis; the value that carries the
2681
3122
  // colour stands in a field of its own. Colour alone can transport no
2682
3123
  // number - which is why the tooltip has to carry it.
2683
- yValue: b,
3124
+ yValue: v,
2684
3125
  value: y,
2685
3126
  marked: !1,
2686
3127
  areal: !0
2687
3128
  };
2688
3129
  }
2689
- const f = c.kind === "scatter" && a === "nearest" ? zn(e.x, e.y, h, r, l, n.scale, i.scale) : c.kind === "line" && c.step === !0 ? ge(e.x, h, r) : ne(e.x, h, r);
3130
+ const f = c.kind === "scatter" && a === "nearest" ? fi(e.x, e.y, h, r, l, n.scale, i.scale) : c.kind === "line" && c.step === !0 ? Ee(e.x, h, r) : he(e.x, h, r);
2690
3131
  if (f < 0) return null;
2691
3132
  const m = e.y[f];
2692
3133
  if (Number.isNaN(m)) return null;
2693
- const p = e.x[f];
3134
+ const p = e.x[f], u = t.stacked === null || e.y0 === null ? Number.NaN : e.y0[f];
2694
3135
  return {
2695
3136
  index: f,
2696
3137
  px: n.scale.toPx(p),
2697
3138
  py: i.scale.toPx(m),
2698
3139
  xValue: p,
2699
- yValue: m,
3140
+ yValue: t.stacked === null ? m : t.stacked.value[f],
2700
3141
  marked: !0,
2701
- areal: !1
3142
+ areal: !1,
3143
+ covers: l >= Math.min(u, m) && l <= Math.max(u, m)
2702
3144
  };
2703
3145
  }
2704
3146
  /** R-4.9: 12 px to the right of the crosshair, flipping at the right edge,
@@ -2738,7 +3180,8 @@ class ze {
2738
3180
  legend: this.legend,
2739
3181
  series: this.legendItems(),
2740
3182
  limits: this.limitLabels(),
2741
- empty: !this.showsAPoint()
3183
+ empty: !this.showsAPoint(),
3184
+ dataTable: this.dataTable
2742
3185
  };
2743
3186
  for (const t of this.layoutSubscribers) t();
2744
3187
  }
@@ -2748,25 +3191,26 @@ class ze {
2748
3191
  hover: this.hover,
2749
3192
  tooltip: this.tooltip,
2750
3193
  xLabel: this.hoverXLabel,
2751
- rows: this.hoverRows
3194
+ rows: this.hoverRows,
3195
+ totals: this.hoverTotals
2752
3196
  };
2753
3197
  for (const t of this.hoverSubscribers) t();
2754
3198
  }
2755
3199
  }
2756
3200
  /** Class name of the measuring span for tick labels - keeps the CSS and the
2757
3201
  layout in step. */
2758
- x(ze, "classTick", rt);
2759
- const Ye = Ze(null);
2760
- function ct(s) {
2761
- const t = je(Ye);
2762
- if (t === null && yt)
3202
+ x(rn, "classTick", ct);
3203
+ const ln = pn(null);
3204
+ function st(s) {
3205
+ const t = gn(ln);
3206
+ if (t === null && bt)
2763
3207
  throw new Error(
2764
3208
  `@umriss-ui/charts: <${s}> must be used inside a <Chart>.`
2765
3209
  );
2766
3210
  return t;
2767
3211
  }
2768
- function ht(s, t) {
2769
- const e = ct(s), n = q(null);
3212
+ function dt(s, t) {
3213
+ const e = st(s), n = G(null);
2770
3214
  D(() => {
2771
3215
  if (e !== null)
2772
3216
  return n.current = e.registerSeries(t), () => {
@@ -2776,8 +3220,8 @@ function ht(s, t) {
2776
3220
  e !== null && n.current !== null && e.updateSeries(n.current, t);
2777
3221
  });
2778
3222
  }
2779
- function Be(s, t) {
2780
- const e = ct(s), n = q(null);
3223
+ function an(s, t) {
3224
+ const e = st(s), n = G(null);
2781
3225
  D(() => {
2782
3226
  if (e !== null)
2783
3227
  return n.current = e.registerAxis(t), () => {
@@ -2787,8 +3231,8 @@ function Be(s, t) {
2787
3231
  e !== null && n.current !== null && e.updateAxis(n.current, t);
2788
3232
  });
2789
3233
  }
2790
- function Ke(s, t) {
2791
- const e = ct(s), n = q(null);
3234
+ function cn(s, t) {
3235
+ const e = st(s), n = G(null);
2792
3236
  D(() => {
2793
3237
  if (e !== null)
2794
3238
  return n.current = e.registerLimit(t), () => {
@@ -2798,8 +3242,8 @@ function Ke(s, t) {
2798
3242
  e !== null && n.current !== null && e.updateLimit(n.current, t);
2799
3243
  });
2800
3244
  }
2801
- function gi(s, t) {
2802
- const e = ct(s);
3245
+ function Ki(s, t) {
3246
+ const e = st(s);
2803
3247
  D(() => {
2804
3248
  if (e !== null)
2805
3249
  return e.registerLegend(t), () => e.unregisterLegend();
@@ -2807,8 +3251,15 @@ function gi(s, t) {
2807
3251
  e == null || e.updateLegend(t);
2808
3252
  });
2809
3253
  }
2810
- function bi(s, t) {
2811
- const e = ct(s);
3254
+ function qi(s, t) {
3255
+ const e = st(s);
3256
+ D(() => {
3257
+ if (e !== null)
3258
+ return e.registerDataTable(t), () => e.unregisterDataTable();
3259
+ }, [e, t]);
3260
+ }
3261
+ function Ui(s, t) {
3262
+ const e = st(s);
2812
3263
  D(() => {
2813
3264
  if (e !== null)
2814
3265
  return e.registerTooltip(t), () => e.unregisterTooltip();
@@ -2816,27 +3267,27 @@ function bi(s, t) {
2816
3267
  e == null || e.updateTooltip(t);
2817
3268
  });
2818
3269
  }
2819
- function vi(s, t) {
3270
+ function Xi(s, t) {
2820
3271
  const { band: e, position: n, orientation: i } = s, o = {
2821
3272
  left: `${e.x}px`,
2822
3273
  top: `${e.y}px`,
2823
3274
  width: `${e.width}px`,
2824
3275
  height: `${e.height}px`
2825
- }, r = te + ee;
2826
- return /* @__PURE__ */ z(
3276
+ }, r = ae + ce;
3277
+ return /* @__PURE__ */ O(
2827
3278
  "div",
2828
3279
  {
2829
3280
  className: `uc-axis uc-axis-${i} uc-axis-${n}`,
2830
3281
  style: o,
2831
3282
  "data-axis": s.id,
2832
3283
  children: [
2833
- /* @__PURE__ */ I("span", { className: "uc-axis-line" }),
3284
+ /* @__PURE__ */ k("span", { className: "uc-axis-line" }),
2834
3285
  s.ticks.map((l) => {
2835
3286
  if (i === "y") {
2836
3287
  const c = Math.round(l.px - e.y);
2837
- return /* @__PURE__ */ z("span", { className: "uc-tick", style: { top: `${c}px` }, children: [
2838
- /* @__PURE__ */ I("span", { className: "uc-tick-mark" }),
2839
- /* @__PURE__ */ I(
3288
+ return /* @__PURE__ */ O("span", { className: "uc-tick", style: { top: `${c}px` }, children: [
3289
+ /* @__PURE__ */ k("span", { className: "uc-tick-mark" }),
3290
+ /* @__PURE__ */ k(
2840
3291
  "span",
2841
3292
  {
2842
3293
  className: "uc-tick-label",
@@ -2847,9 +3298,9 @@ function vi(s, t) {
2847
3298
  ] }, l.value);
2848
3299
  }
2849
3300
  const a = Math.round(l.px - e.x);
2850
- return /* @__PURE__ */ z("span", { className: "uc-tick", style: { left: `${a}px` }, children: [
2851
- /* @__PURE__ */ I("span", { className: "uc-tick-mark" }),
2852
- /* @__PURE__ */ I(
3301
+ return /* @__PURE__ */ O("span", { className: "uc-tick", style: { left: `${a}px` }, children: [
3302
+ /* @__PURE__ */ k("span", { className: "uc-tick-mark" }),
3303
+ /* @__PURE__ */ k(
2853
3304
  "span",
2854
3305
  {
2855
3306
  className: "uc-tick-label",
@@ -2862,7 +3313,7 @@ function vi(s, t) {
2862
3313
  )
2863
3314
  ] }, l.value);
2864
3315
  }),
2865
- s.breaks.map((l, a) => /* @__PURE__ */ I(
3316
+ s.breaks.map((l, a) => /* @__PURE__ */ k(
2866
3317
  "span",
2867
3318
  {
2868
3319
  className: "uc-break",
@@ -2872,7 +3323,7 @@ function vi(s, t) {
2872
3323
  `break-${a}`
2873
3324
  )),
2874
3325
  t.map(
2875
- (l) => i === "y" ? /* @__PURE__ */ I(
3326
+ (l) => i === "y" ? /* @__PURE__ */ k(
2876
3327
  "span",
2877
3328
  {
2878
3329
  className: "uc-limit-label",
@@ -2882,7 +3333,7 @@ function vi(s, t) {
2882
3333
  children: l.label
2883
3334
  },
2884
3335
  `limit-${l.id}`
2885
- ) : /* @__PURE__ */ I(
3336
+ ) : /* @__PURE__ */ k(
2886
3337
  "span",
2887
3338
  {
2888
3339
  className: "uc-limit-label",
@@ -2897,22 +3348,22 @@ function vi(s, t) {
2897
3348
  `limit-${l.id}`
2898
3349
  )
2899
3350
  ),
2900
- s.label !== void 0 && s.label !== "" && /* @__PURE__ */ I("span", { className: "uc-axis-title", children: s.label })
3351
+ s.label !== void 0 && s.label !== "" && /* @__PURE__ */ k("span", { className: "uc-axis-title", children: s.label })
2901
3352
  ]
2902
3353
  },
2903
3354
  s.key
2904
3355
  );
2905
3356
  }
2906
- function ki({ scene: s, empty: t }) {
2907
- const e = $t(
3357
+ function Zi({ scene: s, empty: t }) {
3358
+ const e = wt(
2908
3359
  s.subscribeLayout,
2909
3360
  s.getLayoutSnapshot,
2910
3361
  s.getLayoutServerSnapshot
2911
3362
  ), { layout: n } = e;
2912
3363
  if (n.plot.width <= 0 || n.plot.height <= 0) return null;
2913
3364
  const { plot: i } = n;
2914
- return /* @__PURE__ */ z("div", { className: "uc-axes", children: [
2915
- e.empty && /* @__PURE__ */ I(
3365
+ return /* @__PURE__ */ O("div", { className: "uc-axes", children: [
3366
+ e.empty && /* @__PURE__ */ k(
2916
3367
  "div",
2917
3368
  {
2918
3369
  className: "uc-empty",
@@ -2921,19 +3372,175 @@ function ki({ scene: s, empty: t }) {
2921
3372
  }
2922
3373
  ),
2923
3374
  n.axes.map(
2924
- (o) => vi(
3375
+ (o) => Xi(
2925
3376
  o,
2926
3377
  e.limits.filter((r) => r.axisKey === o.key)
2927
3378
  )
2928
3379
  )
2929
3380
  ] });
2930
3381
  }
2931
- function wi({ scene: s }) {
2932
- const t = $t(
3382
+ function un({ scene: s, state: t }) {
3383
+ const e = s.getWording();
3384
+ return /* @__PURE__ */ k(
3385
+ "button",
3386
+ {
3387
+ type: "button",
3388
+ className: "uc-legend-item uc-data-key",
3389
+ "aria-expanded": t.open,
3390
+ "aria-controls": t.open ? t.id : void 0,
3391
+ onClick: () => s.toggleDataTable(),
3392
+ children: t.open ? e.hideData : e.showData
3393
+ }
3394
+ );
3395
+ }
3396
+ function ji({ scene: s }) {
3397
+ const t = Ve();
3398
+ qi("DataTable", t);
3399
+ const e = wt(s.subscribeLayout, s.getLayoutSnapshot, s.getLayoutServerSnapshot), n = e.dataTable, i = (n == null ? void 0 : n.open) === !0, o = i ? s.dataTableGroups() : [], r = G(null), [l, a] = fe(null);
3400
+ if (yn(() => {
3401
+ var m, p;
3402
+ const h = (p = (m = r.current) == null ? void 0 : m.parentElement) == null ? void 0 : p.querySelector(":scope > .uc-plot");
3403
+ if (h == null) return;
3404
+ const f = { top: h.offsetTop, height: h.offsetHeight };
3405
+ a((u) => u !== null && u.top === f.top && u.height === f.height ? u : f);
3406
+ }, [e, i]), n === null) return null;
3407
+ const c = l === null ? void 0 : { top: l.top, height: l.height };
3408
+ return /* @__PURE__ */ O(xt, { children: [
3409
+ e.legend === null && /* @__PURE__ */ k("div", { className: "uc-legend uc-legend-top", children: /* @__PURE__ */ k(un, { scene: s, state: n }) }),
3410
+ i && // A tab stop of its own: the panel scrolls, and a keyboard has to be
3411
+ // able to scroll it.
3412
+ /* @__PURE__ */ k("div", { ref: r, id: n.id, className: "uc-data-panel", style: c, tabIndex: 0, children: o.map((h) => /* @__PURE__ */ O("table", { className: "uc-data-table", children: [
3413
+ /* @__PURE__ */ k("caption", { children: h.caption }),
3414
+ /* @__PURE__ */ k("thead", { children: /* @__PURE__ */ k("tr", { children: h.columns.map((f, m) => /* @__PURE__ */ k("th", { scope: "col", children: f }, m)) }) }),
3415
+ /* @__PURE__ */ k("tbody", { children: h.rows.map((f, m) => /* @__PURE__ */ O("tr", { children: [
3416
+ /* @__PURE__ */ k("th", { scope: "row", children: f[0] }),
3417
+ f.slice(1).map((p, u) => /* @__PURE__ */ k("td", { children: p }, u))
3418
+ ] }, m)) })
3419
+ ] }, h.key)) })
3420
+ ] });
3421
+ }
3422
+ function Ts() {
3423
+ const s = st("DataTable");
3424
+ return s === null ? null : /* @__PURE__ */ k(ji, { scene: s });
3425
+ }
3426
+ function Ji({
3427
+ scene: s,
3428
+ placement: t,
3429
+ onToggle: e
3430
+ }) {
3431
+ Ki("Legend", { placement: t });
3432
+ const n = wt(
3433
+ s.subscribeLayout,
3434
+ s.getLayoutSnapshot,
3435
+ s.getLayoutServerSnapshot
3436
+ ), i = n.dataTable;
3437
+ return n.series.length === 0 && i === null ? null : /* @__PURE__ */ O("div", { className: `uc-legend uc-legend-${t}`, children: [
3438
+ n.series.map((o) => {
3439
+ const r = {
3440
+ className: "uc-legend-item",
3441
+ "data-hidden": o.hidden ? "" : void 0,
3442
+ onPointerEnter: () => s.setHighlight(o.seriesIds),
3443
+ onPointerLeave: () => s.setHighlight(null)
3444
+ }, l = /* @__PURE__ */ O(xt, { children: [
3445
+ o.mark === null ? /* @__PURE__ */ k("span", { className: "uc-legend-chip", style: { background: o.color } }) : /* @__PURE__ */ k(hn, { color: o.color, mark: o.mark }),
3446
+ o.name
3447
+ ] });
3448
+ return e === void 0 ? /* @__PURE__ */ k("span", { ...r, children: l }, o.id) : /* @__PURE__ */ k(
3449
+ "button",
3450
+ {
3451
+ type: "button",
3452
+ "aria-pressed": !o.hidden,
3453
+ onClick: () => e(o.name),
3454
+ ...r,
3455
+ children: l
3456
+ },
3457
+ o.id
3458
+ );
3459
+ }),
3460
+ i !== null && /* @__PURE__ */ k(un, { scene: s, state: i })
3461
+ ] });
3462
+ }
3463
+ const Qi = 3;
3464
+ function hn({ color: s, mark: t }) {
3465
+ var n;
3466
+ const e = t.dash !== null ? (n = t.swatches) == null ? void 0 : n[0] : void 0;
3467
+ if (e !== void 0)
3468
+ return /* @__PURE__ */ O("svg", { className: "uc-legend-mark", width: 18, height: 10, viewBox: "0 0 18 10", "aria-hidden": "true", children: [
3469
+ /* @__PURE__ */ k("rect", { y: 3, width: 18, height: 7, fill: e.color, fillOpacity: e.opacity }),
3470
+ /* @__PURE__ */ k("path", { d: _e({ x: 0, y: 3, width: 18, height: 7 }, e.hatch), stroke: e.color, strokeWidth: 1 }),
3471
+ /* @__PURE__ */ k(
3472
+ "line",
3473
+ {
3474
+ x1: 1,
3475
+ y1: 3,
3476
+ x2: 17,
3477
+ y2: 3,
3478
+ stroke: s,
3479
+ strokeWidth: 1.5,
3480
+ strokeLinecap: "round",
3481
+ strokeDasharray: t.dash !== null && t.dash.length > 0 ? t.dash.join(" ") : void 0
3482
+ }
3483
+ )
3484
+ ] });
3485
+ if (t.swatches !== null) {
3486
+ const i = t.swatches.length === 1 ? 10 : 8, o = i * t.swatches.length;
3487
+ return /* @__PURE__ */ k("svg", { className: "uc-legend-mark", width: o, height: 10, viewBox: `0 0 ${o} 10`, "aria-hidden": "true", children: t.swatches.map((r, l) => (
3488
+ // A nested svg clips its hatch to its own swatch.
3489
+ /* @__PURE__ */ O("svg", { x: l * i, y: 0, width: i, height: 10, children: [
3490
+ /* @__PURE__ */ k("rect", { width: i, height: 10, fill: r.color }),
3491
+ /* @__PURE__ */ k("path", { d: _e({ x: 0, y: 0, width: i, height: 10 }, r.hatch), stroke: t.ground, strokeWidth: 1 })
3492
+ ] }, l)
3493
+ )) });
3494
+ }
3495
+ return /* @__PURE__ */ O("svg", { className: "uc-legend-mark", width: 18, height: 10, viewBox: "0 0 18 10", "aria-hidden": "true", children: [
3496
+ t.dash !== null && /* @__PURE__ */ k(
3497
+ "line",
3498
+ {
3499
+ x1: 1,
3500
+ y1: 5,
3501
+ x2: 17,
3502
+ y2: 5,
3503
+ stroke: s,
3504
+ strokeWidth: 1.5,
3505
+ strokeLinecap: "round",
3506
+ strokeDasharray: t.dash.length > 0 ? t.dash.join(" ") : void 0
3507
+ }
3508
+ ),
3509
+ t.marker !== null && /* @__PURE__ */ k("path", { d: ts(t.marker, 9, 5, 3), fill: s })
3510
+ ] });
3511
+ }
3512
+ function _e(s, t) {
3513
+ const e = en(s, t, Qi);
3514
+ let n = "";
3515
+ for (let i = 0; i < e.length; i += 4) n += `M${e[i]} ${e[i + 1]}L${e[i + 2]} ${e[i + 3]}`;
3516
+ return n;
3517
+ }
3518
+ function ts(s, t, e, n) {
3519
+ let i = "";
3520
+ return pe(
3521
+ {
3522
+ moveTo: (o, r) => i += `M${o} ${r}`,
3523
+ lineTo: (o, r) => i += `L${o} ${r}`,
3524
+ // Only ever a whole circle: two half arcs, as SVG has no full one.
3525
+ arc: (o, r, l) => i += `M${o - l} ${r}A${l} ${l} 0 1 0 ${o + l} ${r}A${l} ${l} 0 1 0 ${o - l} ${r}`,
3526
+ closePath: () => i += "Z"
3527
+ },
3528
+ s,
3529
+ t,
3530
+ e,
3531
+ n
3532
+ ), i;
3533
+ }
3534
+ function Ms({ placement: s = "top", onToggle: t }) {
3535
+ const e = st("Legend");
3536
+ return e === null ? null : /* @__PURE__ */ k(Ji, { scene: e, placement: s, onToggle: t });
3537
+ }
3538
+ function es({ scene: s }) {
3539
+ const t = wt(
2933
3540
  s.subscribeHover,
2934
3541
  s.getHoverSnapshot,
2935
3542
  s.getHoverServerSnapshot
2936
- ), e = Je(
3543
+ ), e = xn(
2937
3544
  (i) => {
2938
3545
  s.bindTooltip(i);
2939
3546
  },
@@ -2943,22 +3550,28 @@ function wi({ scene: s }) {
2943
3550
  s.markOverlayDirty();
2944
3551
  }, [s, t.version]), t.tooltip === null) return null;
2945
3552
  const n = t.hover;
2946
- return /* @__PURE__ */ I("div", { className: "uc-tooltip", ref: e, role: "presentation", children: n === null ? null : t.tooltip.render !== void 0 ? t.tooltip.render(n.hit) : /* @__PURE__ */ z(Et, { children: [
2947
- /* @__PURE__ */ I("div", { className: "uc-tooltip-head", children: t.xLabel }),
2948
- /* @__PURE__ */ I("div", { className: "uc-tooltip-list", children: n.hit.points.map((i, o) => {
3553
+ return /* @__PURE__ */ k("div", { className: "uc-tooltip", ref: e, role: "presentation", children: n === null ? null : t.tooltip.render !== void 0 ? t.tooltip.render(n.hit) : /* @__PURE__ */ O(xt, { children: [
3554
+ /* @__PURE__ */ k("div", { className: "uc-tooltip-head", children: t.xLabel }),
3555
+ /* @__PURE__ */ k("div", { className: "uc-tooltip-list", children: n.hit.points.map((i, o) => {
2949
3556
  const r = t.rows[o];
2950
- return /* @__PURE__ */ z("div", { className: "uc-tooltip-row", children: [
2951
- /* @__PURE__ */ I("span", { className: "uc-tooltip-chip", style: { background: i.color } }),
2952
- /* @__PURE__ */ z("span", { className: "uc-tooltip-name", children: [
2953
- i.seriesName,
2954
- r !== void 0 && r.x !== "" ? /* @__PURE__ */ I("span", { className: "uc-tooltip-x", children: r.x }) : null
3557
+ return /* @__PURE__ */ O(bn, { children: [
3558
+ /* @__PURE__ */ O("div", { className: "uc-tooltip-row", children: [
3559
+ (r == null ? void 0 : r.chip) != null ? /* @__PURE__ */ k(hn, { color: r.chip.color, mark: r.chip.mark }) : /* @__PURE__ */ k("span", { className: "uc-tooltip-chip", style: { background: i.color } }),
3560
+ /* @__PURE__ */ O("span", { className: "uc-tooltip-name", children: [
3561
+ i.seriesName,
3562
+ r !== void 0 && r.x !== "" ? /* @__PURE__ */ k("span", { className: "uc-tooltip-x", children: r.x }) : null
3563
+ ] }),
3564
+ /* @__PURE__ */ k("span", { className: "uc-tooltip-value", children: r == null ? void 0 : r.value })
2955
3565
  ] }),
2956
- /* @__PURE__ */ I("span", { className: "uc-tooltip-value", children: r == null ? void 0 : r.value })
3566
+ t.totals.filter((l) => l.after === o).map((l) => /* @__PURE__ */ O("div", { className: "uc-tooltip-row", children: [
3567
+ /* @__PURE__ */ k("span", { className: "uc-tooltip-name uc-tooltip-total", children: l.name }),
3568
+ /* @__PURE__ */ k("span", { className: "uc-tooltip-value", children: l.value })
3569
+ ] }, "total"))
2957
3570
  ] }, `${i.seriesName}-${i.index}`);
2958
3571
  }) })
2959
3572
  ] }) });
2960
3573
  }
2961
- function Ui(s) {
3574
+ function Ss(s) {
2962
3575
  const {
2963
3576
  data: t,
2964
3577
  width: e = "100%",
@@ -2971,120 +3584,123 @@ function Ui(s) {
2971
3584
  syncId: c,
2972
3585
  empty: h,
2973
3586
  wording: f,
2974
- children: m
2975
- } = s, p = P(() => ({ ..._e, ...f }), [f]), u = h ?? p.empty, [d] = Ee(() => new ze()), y = q(null), g = q(null), b = q(null), k = q(null), T = q(null), O = q(null), A = Qe(), E = typeof i == "number" ? void 0 : i, S = typeof i == "number" ? i : void 0, M = S ?? (E == null ? void 0 : E.top), _ = S ?? (E == null ? void 0 : E.right), U = S ?? (E == null ? void 0 : E.bottom), w = S ?? (E == null ? void 0 : E.left), L = P(
3587
+ encoding: m = "color",
3588
+ children: p
3589
+ } = s, u = $(() => ({ ...sn, ...f }), [f]), g = h ?? u.empty, [d] = fe(() => new rn()), y = G(null), b = G(null), v = G(null), w = G(null), L = G(null), A = G(null), z = Ve(), T = typeof i == "number" ? void 0 : i, S = typeof i == "number" ? i : void 0, _ = S ?? (T == null ? void 0 : T.top), X = S ?? (T == null ? void 0 : T.right), I = S ?? (T == null ? void 0 : T.bottom), P = S ?? (T == null ? void 0 : T.left), N = $(
2976
3590
  () => ({
2977
- top: M ?? 8,
2978
- right: _ ?? 8,
2979
- bottom: U ?? 8,
2980
- left: w ?? 8
3591
+ top: _ ?? 8,
3592
+ right: X ?? 8,
3593
+ bottom: I ?? 8,
3594
+ left: P ?? 8
2981
3595
  }),
2982
- [M, _, U, w]
3596
+ [_, X, I, P]
2983
3597
  );
2984
- o === void 0 && tt(
3598
+ o === void 0 && nt(
2985
3599
  "chart-arialabel",
2986
3600
  "Chart without ariaLabel - please set a meaningful description (R-7.6)."
2987
3601
  ), D(() => {
2988
- const N = y.current, C = g.current, H = b.current, G = k.current;
2989
- if (!N || !C || !H || !G) return;
2990
- d.bind(C, H, G, N), d.bindA11y(T.current, O.current);
2991
- const Y = C.getBoundingClientRect();
2992
- d.requestResize(Y.width, Y.height);
2993
- const X = new ResizeObserver((Q) => {
2994
- var dt;
2995
- const et = Q[Q.length - 1];
3602
+ const M = y.current, C = b.current, q = v.current, Y = w.current;
3603
+ if (!M || !C || !q || !Y) return;
3604
+ d.bind(C, q, Y, M), d.bindA11y(L.current, A.current);
3605
+ const Z = C.getBoundingClientRect();
3606
+ d.requestResize(Z.width, Z.height);
3607
+ const R = new ResizeObserver((J) => {
3608
+ var Tt;
3609
+ const et = J[J.length - 1];
2996
3610
  if (et === void 0) return;
2997
- const nt = (dt = et.contentBoxSize) == null ? void 0 : dt[0];
2998
- nt !== void 0 ? d.requestResize(nt.inlineSize, nt.blockSize) : d.requestResize(et.contentRect.width, et.contentRect.height);
3611
+ const at = (Tt = et.contentBoxSize) == null ? void 0 : Tt[0];
3612
+ at !== void 0 ? d.requestResize(at.inlineSize, at.blockSize) : d.requestResize(et.contentRect.width, et.contentRect.height);
2999
3613
  });
3000
- X.observe(C);
3001
- const $ = () => d.pointerLeave();
3002
- window.addEventListener("blur", $);
3003
- const Z = (Q) => {
3004
- C.contains(Q.target) || d.pointerLeave();
3614
+ R.observe(C);
3615
+ const j = () => d.pointerLeave();
3616
+ window.addEventListener("blur", j);
3617
+ const W = (J) => {
3618
+ C.contains(J.target) || d.pointerLeave();
3005
3619
  };
3006
- document.addEventListener("pointerdown", Z);
3007
- const W = (Q) => d.wheel(Q);
3008
- return C.addEventListener("wheel", W, { passive: !1 }), () => {
3009
- C.removeEventListener("wheel", W), window.removeEventListener("blur", $), document.removeEventListener("pointerdown", Z), X.disconnect(), d.unbind();
3620
+ document.addEventListener("pointerdown", W);
3621
+ const At = (J) => d.wheel(J);
3622
+ return C.addEventListener("wheel", At, { passive: !1 }), () => {
3623
+ C.removeEventListener("wheel", At), window.removeEventListener("blur", j), document.removeEventListener("pointerdown", W), R.disconnect(), d.unbind();
3010
3624
  };
3011
3625
  }, [d]), D(() => {
3012
3626
  d.setData(t);
3013
3627
  }, [d, t]), D(() => {
3014
- d.setPadding(L);
3015
- }, [d, L]), D(() => {
3016
- d.setWording(p);
3017
- }, [d, p]), D(() => {
3628
+ d.setPadding(N);
3629
+ }, [d, N]), D(() => {
3630
+ d.setWording(u);
3631
+ }, [d, u]), D(() => {
3632
+ d.setEncoding(m);
3633
+ }, [d, m]), D(() => {
3018
3634
  d.setOnPerf(a ?? null);
3019
3635
  }, [d, a]), D(() => (d.setSyncId(c ?? null), () => d.setSyncId(null)), [d, c]), D(() => {
3020
3636
  d.validate();
3021
3637
  });
3022
- const v = $t(
3638
+ const F = wt(
3023
3639
  d.subscribeHover,
3024
3640
  () => d.getHoverSnapshot().tooltip !== null,
3025
3641
  () => !1
3026
- ), F = {
3642
+ ), B = {
3027
3643
  width: e === "100%" ? "100%" : `${e}px`,
3028
3644
  height: `${n}px`,
3029
3645
  ...l
3030
- }, V = (N) => {
3031
- d.drag(N.nativeEvent), d.pointerMove(N.nativeEvent.offsetX, N.nativeEvent.offsetY);
3646
+ }, E = (M) => {
3647
+ d.drag(M.nativeEvent), d.pointerMove(M.nativeEvent.offsetX, M.nativeEvent.offsetY);
3032
3648
  };
3033
- return /* @__PURE__ */ I(Ye.Provider, { value: d, children: /* @__PURE__ */ z(
3649
+ return /* @__PURE__ */ k(ln.Provider, { value: d, children: /* @__PURE__ */ O(
3034
3650
  "div",
3035
3651
  {
3036
3652
  ref: y,
3037
3653
  className: r ? `uc-root ${r}` : "uc-root",
3038
- style: F,
3654
+ style: B,
3039
3655
  children: [
3040
- /* @__PURE__ */ z(
3656
+ /* @__PURE__ */ O(
3041
3657
  "div",
3042
3658
  {
3043
- ref: g,
3659
+ ref: b,
3044
3660
  className: "uc-plot",
3045
- role: v ? "application" : "img",
3046
- "aria-roledescription": v ? p.roleDescription : void 0,
3661
+ role: F ? "application" : "img",
3662
+ "aria-roledescription": F ? u.roleDescription : void 0,
3047
3663
  "aria-label": o,
3048
- "aria-describedby": A,
3049
- tabIndex: v ? 0 : void 0,
3050
- onKeyDown: (N) => {
3051
- d.key(N.nativeEvent) && N.preventDefault();
3664
+ "aria-describedby": z,
3665
+ tabIndex: F ? 0 : void 0,
3666
+ onKeyDown: (M) => {
3667
+ d.key(M.nativeEvent) && M.preventDefault();
3052
3668
  },
3053
- onFocus: (N) => d.focus(Ni(N.currentTarget)),
3669
+ onFocus: (M) => d.focus(ns(M.currentTarget)),
3054
3670
  onBlur: () => d.blur(),
3055
- onPointerMove: V,
3056
- onPointerDown: (N) => {
3057
- d.pointerDown(N.nativeEvent), V(N);
3671
+ onPointerMove: E,
3672
+ onPointerDown: (M) => {
3673
+ d.pointerDown(M.nativeEvent), E(M);
3058
3674
  },
3059
- onPointerUp: (N) => d.pointerUp(N.nativeEvent),
3060
- onPointerCancel: (N) => d.pointerUp(N.nativeEvent),
3675
+ onPointerUp: (M) => d.pointerUp(M.nativeEvent),
3676
+ onPointerCancel: (M) => d.pointerUp(M.nativeEvent),
3061
3677
  onDoubleClick: () => d.doubleClick(),
3062
- onPointerLeave: (N) => {
3063
- N.pointerType !== "touch" && d.pointerLeave();
3678
+ onPointerLeave: (M) => {
3679
+ M.pointerType !== "touch" && d.pointerLeave();
3064
3680
  },
3065
3681
  children: [
3066
- /* @__PURE__ */ I("canvas", { ref: b, className: "uc-layer-series", "aria-hidden": "true" }),
3067
- /* @__PURE__ */ I("canvas", { ref: k, className: "uc-layer-overlay", "aria-hidden": "true" }),
3068
- /* @__PURE__ */ I(ki, { scene: d, empty: u }),
3069
- /* @__PURE__ */ I(wi, { scene: d })
3682
+ /* @__PURE__ */ k("canvas", { ref: v, className: "uc-layer-series", "aria-hidden": "true" }),
3683
+ /* @__PURE__ */ k("canvas", { ref: w, className: "uc-layer-overlay", "aria-hidden": "true" }),
3684
+ /* @__PURE__ */ k(Zi, { scene: d, empty: g }),
3685
+ /* @__PURE__ */ k(es, { scene: d })
3070
3686
  ]
3071
3687
  }
3072
3688
  ),
3073
- /* @__PURE__ */ I("div", { ref: T, className: "uc-sr", "aria-live": "polite" }),
3074
- /* @__PURE__ */ I("div", { ref: O, id: A, className: "uc-sr" }),
3075
- m
3689
+ /* @__PURE__ */ k("div", { ref: L, className: "uc-sr", "aria-live": "polite" }),
3690
+ /* @__PURE__ */ k("div", { ref: A, id: z, className: "uc-sr" }),
3691
+ p
3076
3692
  ]
3077
3693
  }
3078
3694
  ) });
3079
3695
  }
3080
- function Ni(s) {
3696
+ function ns(s) {
3081
3697
  try {
3082
3698
  return s.matches(":focus-visible");
3083
3699
  } catch {
3084
3700
  return !0;
3085
3701
  }
3086
3702
  }
3087
- function Xi(s) {
3703
+ function Ls(s) {
3088
3704
  const {
3089
3705
  accessor: t,
3090
3706
  baseline: e,
@@ -3096,10 +3712,12 @@ function Xi(s) {
3096
3712
  format: a,
3097
3713
  color: c,
3098
3714
  tone: h,
3099
- fillOpacity: f = 0.18,
3100
- strokeWidth: m = 1.5,
3101
- dash: p
3102
- } = s, u = P(
3715
+ stack: f,
3716
+ normalize: m,
3717
+ fillOpacity: p = 0.18,
3718
+ strokeWidth: u = 1.5,
3719
+ dash: g
3720
+ } = s, d = $(
3103
3721
  () => ({
3104
3722
  kind: "area",
3105
3723
  accessor: t,
@@ -3112,15 +3730,17 @@ function Xi(s) {
3112
3730
  format: a,
3113
3731
  color: c,
3114
3732
  tone: h,
3115
- fillOpacity: f,
3116
- strokeWidth: m,
3117
- dash: p
3733
+ stack: f,
3734
+ normalize: m,
3735
+ fillOpacity: p,
3736
+ strokeWidth: u,
3737
+ dash: g
3118
3738
  }),
3119
- [t, e, n, i, o, r, l, a, c, h, f, m, p]
3739
+ [t, e, n, i, o, r, l, a, c, h, f, m, p, u, g]
3120
3740
  );
3121
- return ht("Area", u), null;
3741
+ return dt("Area", d), null;
3122
3742
  }
3123
- function Zi(s) {
3743
+ function Es(s) {
3124
3744
  const {
3125
3745
  accessor: t,
3126
3746
  xAxisId: e = "x",
@@ -3131,8 +3751,10 @@ function Zi(s) {
3131
3751
  format: l,
3132
3752
  color: a,
3133
3753
  tone: c,
3134
- barWidth: h = 0.8
3135
- } = s, f = P(
3754
+ stack: h,
3755
+ normalize: f,
3756
+ barWidth: m = 0.8
3757
+ } = s, p = $(
3136
3758
  () => ({
3137
3759
  kind: "bar",
3138
3760
  accessor: t,
@@ -3144,13 +3766,15 @@ function Zi(s) {
3144
3766
  format: l,
3145
3767
  color: a,
3146
3768
  tone: c,
3147
- barWidth: h
3769
+ stack: h,
3770
+ normalize: f,
3771
+ barWidth: m
3148
3772
  }),
3149
- [t, e, n, i, o, r, l, a, c, h]
3773
+ [t, e, n, i, o, r, l, a, c, h, f, m]
3150
3774
  );
3151
- return ht("Bar", f), null;
3775
+ return dt("Bar", p), null;
3152
3776
  }
3153
- function Ii(s) {
3777
+ function is(s) {
3154
3778
  const {
3155
3779
  accessor: t,
3156
3780
  xAxisId: e = "x",
@@ -3165,7 +3789,7 @@ function Ii(s) {
3165
3789
  dash: f,
3166
3790
  markers: m = "auto",
3167
3791
  step: p
3168
- } = s, u = P(
3792
+ } = s, u = $(
3169
3793
  () => ({
3170
3794
  kind: "line",
3171
3795
  accessor: t,
@@ -3184,9 +3808,9 @@ function Ii(s) {
3184
3808
  }),
3185
3809
  [t, e, n, i, o, r, l, a, c, h, f, m, p]
3186
3810
  );
3187
- return ht("Line", u), null;
3811
+ return dt("Line", u), null;
3188
3812
  }
3189
- function Ai(s) {
3813
+ function ss(s) {
3190
3814
  const {
3191
3815
  accessor: t,
3192
3816
  xAxisId: e = "x",
@@ -3198,7 +3822,7 @@ function Ai(s) {
3198
3822
  color: a,
3199
3823
  tone: c,
3200
3824
  radius: h = 3
3201
- } = s, f = P(
3825
+ } = s, f = $(
3202
3826
  () => ({
3203
3827
  kind: "scatter",
3204
3828
  accessor: t,
@@ -3214,9 +3838,9 @@ function Ai(s) {
3214
3838
  }),
3215
3839
  [t, e, n, i, o, r, l, a, c, h]
3216
3840
  );
3217
- return ht("Scatter", f), null;
3841
+ return dt("Scatter", f), null;
3218
3842
  }
3219
- function ji(s) {
3843
+ function Fs(s) {
3220
3844
  const {
3221
3845
  accessor: t,
3222
3846
  states: e,
@@ -3227,7 +3851,7 @@ function ji(s) {
3227
3851
  hidden: l,
3228
3852
  laneFrom: a,
3229
3853
  laneTo: c
3230
- } = s, h = P(
3854
+ } = s, h = $(
3231
3855
  () => ({
3232
3856
  kind: "state",
3233
3857
  accessor: t,
@@ -3242,9 +3866,9 @@ function ji(s) {
3242
3866
  }),
3243
3867
  [t, e, n, i, o, r, l, a, c]
3244
3868
  );
3245
- return ht("StateBand", h), null;
3869
+ return dt("StateBand", h), null;
3246
3870
  }
3247
- const Ti = [
3871
+ const os = [
3248
3872
  "#eef2ff",
3249
3873
  "#c7d2fe",
3250
3874
  "#a5b4fc",
@@ -3253,7 +3877,7 @@ const Ti = [
3253
3877
  "#4f46e5",
3254
3878
  "#4338ca"
3255
3879
  ];
3256
- function Ji(s) {
3880
+ function Ds(s) {
3257
3881
  const {
3258
3882
  accessor: t,
3259
3883
  value: e,
@@ -3264,10 +3888,10 @@ function Ji(s) {
3264
3888
  name: l,
3265
3889
  hidden: a,
3266
3890
  format: c
3267
- } = s, h = P(
3268
- () => n ?? { kind: "gradient", stops: Ti },
3891
+ } = s, h = $(
3892
+ () => n ?? { kind: "gradient", stops: os },
3269
3893
  [n]
3270
- ), f = P(
3894
+ ), f = $(
3271
3895
  () => ({
3272
3896
  kind: "matrix",
3273
3897
  accessor: t,
@@ -3282,9 +3906,9 @@ function Ji(s) {
3282
3906
  }),
3283
3907
  [t, e, h, i, o, r, l, a, c]
3284
3908
  );
3285
- return ht("Matrix", f), null;
3909
+ return dt("Matrix", f), null;
3286
3910
  }
3287
- function mt(s) {
3911
+ function pt(s) {
3288
3912
  const {
3289
3913
  value: t,
3290
3914
  orientation: e = "y",
@@ -3294,7 +3918,7 @@ function mt(s) {
3294
3918
  color: r,
3295
3919
  inExtent: l = !0,
3296
3920
  role: a = "specification"
3297
- } = s, c = P(
3921
+ } = s, c = $(
3298
3922
  () => ({
3299
3923
  kind: "line",
3300
3924
  value: t,
@@ -3308,9 +3932,9 @@ function mt(s) {
3308
3932
  }),
3309
3933
  [t, n, e, i, a, o, r, l]
3310
3934
  );
3311
- return Ke("LimitLine", c), null;
3935
+ return cn("LimitLine", c), null;
3312
3936
  }
3313
- function Qi(s) {
3937
+ function Ps(s) {
3314
3938
  const {
3315
3939
  from: t,
3316
3940
  to: e,
@@ -3321,7 +3945,7 @@ function Qi(s) {
3321
3945
  color: l,
3322
3946
  inExtent: a = !0,
3323
3947
  role: c = "specification"
3324
- } = s, h = P(
3948
+ } = s, h = $(
3325
3949
  () => ({
3326
3950
  kind: "band",
3327
3951
  from: t,
@@ -3336,10 +3960,10 @@ function Qi(s) {
3336
3960
  }),
3337
3961
  [t, e, i, n, o, c, r, l, a]
3338
3962
  );
3339
- return Ke("LimitBand", h), null;
3963
+ return cn("LimitBand", h), null;
3340
3964
  }
3341
- const Mi = 1.128;
3342
- function Ut(s, t) {
3965
+ const rs = 1.128;
3966
+ function ne(s, t) {
3343
3967
  return {
3344
3968
  center: s,
3345
3969
  sigma: t,
@@ -3347,12 +3971,12 @@ function Ut(s, t) {
3347
3971
  lower: s - 3 * t
3348
3972
  };
3349
3973
  }
3350
- function ts(s, t) {
3974
+ function Cs(s, t) {
3351
3975
  return (t - s) / 3;
3352
3976
  }
3353
- function Si(s, t) {
3977
+ function ls(s, t) {
3354
3978
  if (t.kind === "given")
3355
- return Ut(t.center, t.sigma);
3979
+ return ne(t.center, t.sigma);
3356
3980
  const e = Math.max(0, Math.trunc(t.from)), n = Math.min(s.length, Math.trunc(t.to));
3357
3981
  let i = 0, o = 0, r = 0, l = 0, a = Number.NaN;
3358
3982
  for (let h = e; h < n; h++) {
@@ -3363,21 +3987,21 @@ function Si(s, t) {
3363
3987
  }
3364
3988
  i += f, o++, Number.isFinite(a) && (r += Math.abs(f - a), l++), a = f;
3365
3989
  }
3366
- if (o === 0) return Ut(Number.NaN, Number.NaN);
3367
- const c = l === 0 ? 0 : r / l / Mi;
3368
- return Ut(i / o, c);
3990
+ if (o === 0) return ne(Number.NaN, Number.NaN);
3991
+ const c = l === 0 ? 0 : r / l / rs;
3992
+ return ne(i / o, c);
3369
3993
  }
3370
- function Ei(s, t = [1, 2]) {
3994
+ function as(s, t = [1, 2]) {
3371
3995
  return t.map((e) => ({
3372
3996
  k: e,
3373
3997
  upper: s.center + e * s.sigma,
3374
3998
  lower: s.center - e * s.sigma
3375
3999
  }));
3376
4000
  }
3377
- function Li(s, t) {
4001
+ function cs(s, t) {
3378
4002
  return Number.isFinite(s) ? s > t ? 1 : s < t ? -1 : 0 : 0;
3379
4003
  }
3380
- function Ge(s, t) {
4004
+ function dn(s, t) {
3381
4005
  const e = [];
3382
4006
  if (t < 1) return e;
3383
4007
  let n = 0;
@@ -3391,7 +4015,7 @@ function Ge(s, t) {
3391
4015
  }
3392
4016
  return e;
3393
4017
  }
3394
- const se = {
4018
+ const ge = {
3395
4019
  outlier: !0,
3396
4020
  run: !0,
3397
4021
  trend: !0,
@@ -3399,7 +4023,7 @@ const se = {
3399
4023
  runLength: 9,
3400
4024
  trendLength: 6
3401
4025
  };
3402
- function Fi(s, t) {
4026
+ function us(s, t) {
3403
4027
  const e = [];
3404
4028
  if (!(t.sigma > 0)) return e;
3405
4029
  for (let n = 0; n < s.length; n++) {
@@ -3408,24 +4032,24 @@ function Fi(s, t) {
3408
4032
  }
3409
4033
  return e;
3410
4034
  }
3411
- function Pi(s, t, e = se.runLength) {
3412
- return Ge(
3413
- s.map((n) => Li(n, t.center)),
4035
+ function hs(s, t, e = ge.runLength) {
4036
+ return dn(
4037
+ s.map((n) => cs(n, t.center)),
3414
4038
  e
3415
4039
  );
3416
4040
  }
3417
- function Di(s, t = se.trendLength) {
4041
+ function ds(s, t = ge.trendLength) {
3418
4042
  const e = [];
3419
4043
  for (let i = 1; i < s.length; i++) {
3420
4044
  const o = s[i - 1], r = s[i];
3421
4045
  e.push(Number.isFinite(o) && Number.isFinite(r) ? Math.sign(r - o) : 0);
3422
4046
  }
3423
4047
  const n = [];
3424
- for (const i of Ge(e, Math.max(1, t - 1)))
4048
+ for (const i of dn(e, Math.max(1, t - 1)))
3425
4049
  n[n.length - 1] !== i && n.push(i), n.push(i + 1);
3426
4050
  return n;
3427
4051
  }
3428
- function Ci(s, t) {
4052
+ function fs(s, t) {
3429
4053
  if (!(t.sigma > 0)) return [];
3430
4054
  const e = t.center + 2 * t.sigma, n = t.center - 2 * t.sigma, i = /* @__PURE__ */ new Set();
3431
4055
  for (let o = 0; o + 2 < s.length; o++)
@@ -3436,30 +4060,30 @@ function Ci(s, t) {
3436
4060
  if (r.length >= 2) for (const l of r) i.add(l);
3437
4061
  return [...i].sort((o, r) => o - r);
3438
4062
  }
3439
- function Oi(s, t, e = {}) {
3440
- const n = { ...se, ...e };
3441
- t.sigma > 0 || tt(
4063
+ function ms(s, t, e = {}) {
4064
+ const n = { ...ge, ...e };
4065
+ t.sigma > 0 || nt(
3442
4066
  "control-sigma-zero",
3443
4067
  `control limits with sigma ${t.sigma} span no band - a constant reference window, or a given sigma not above 0. Rules 1 and 4 find nothing there; take a window with spread, or a positive given sigma.`
3444
4068
  );
3445
4069
  const i = [], o = (r, l) => {
3446
4070
  l.length > 0 && i.push({ rule: r, indices: l });
3447
4071
  };
3448
- return n.outlier && o("outlier", Fi(s, t)), n.run && o("run", Pi(s, t, n.runLength)), n.trend && o("trend", Di(s, n.trendLength)), n.twoOfThree && o("twoOfThree", Ci(s, t)), i;
4072
+ return n.outlier && o("outlier", us(s, t)), n.run && o("run", hs(s, t, n.runLength)), n.trend && o("trend", ds(s, n.trendLength)), n.twoOfThree && o("twoOfThree", fs(s, t)), i;
3449
4073
  }
3450
- function $i(s) {
4074
+ function ps(s) {
3451
4075
  const t = /* @__PURE__ */ new Set();
3452
4076
  for (const e of s) for (const n of e.indices) t.add(n);
3453
4077
  return [...t].sort((e, n) => e - n);
3454
4078
  }
3455
- function Xt(s, t) {
3456
- const [e, n] = Ee({ value: s });
4079
+ function ie(s, t) {
4080
+ const [e, n] = fe({ value: s });
3457
4081
  return e.value === s || t(e.value, s) ? e.value : (n({ value: s }), s);
3458
4082
  }
3459
- function Ri(s, t) {
4083
+ function gs(s, t) {
3460
4084
  return s.kind === "given" && t.kind === "given" ? s.center === t.center && s.sigma === t.sigma : s.kind === "referenceWindow" && t.kind === "referenceWindow" ? s.from === t.from && s.to === t.to : !1;
3461
4085
  }
3462
- function Hi(s, t) {
4086
+ function ys(s, t) {
3463
4087
  if (s.length !== t.length) return !1;
3464
4088
  for (let e = 0; e < s.length; e++) {
3465
4089
  const n = s[e], i = t[e];
@@ -3468,7 +4092,7 @@ function Hi(s, t) {
3468
4092
  }
3469
4093
  return !0;
3470
4094
  }
3471
- function es(s) {
4095
+ function $s(s) {
3472
4096
  const {
3473
4097
  data: t,
3474
4098
  xAxisId: e = "x",
@@ -3483,64 +4107,64 @@ function es(s) {
3483
4107
  labelLower: f,
3484
4108
  violationName: m,
3485
4109
  onViolations: p
3486
- } = s, u = Xt(s.accessor, j), d = Xt(s.origin, Ri), y = P(() => {
3487
- const M = [];
4110
+ } = s, u = ie(s.accessor, Q), g = ie(s.origin, gs), d = $(() => {
4111
+ const S = [];
3488
4112
  for (let _ = 0; _ < t.length; _++) {
3489
- const U = u(t[_], _);
3490
- M.push(U ?? Number.NaN);
3491
- }
3492
- return M;
3493
- }, [t, u]), g = P(() => Si(y, d), [y, d]), b = Xt(
3494
- P(() => Oi(y, g, a ?? {}), [y, g, a]),
3495
- Hi
3496
- ), k = P(() => new Set($i(b)), [b]), T = q(p);
4113
+ const X = u(t[_], _);
4114
+ S.push(X ?? Number.NaN);
4115
+ }
4116
+ return S;
4117
+ }, [t, u]), y = $(() => ls(d, g), [d, g]), b = ie(
4118
+ $(() => ms(d, y, a ?? {}), [d, y, a]),
4119
+ ys
4120
+ ), v = $(() => new Set(ps(b)), [b]), w = G(p);
3497
4121
  D(() => {
3498
- T.current = p;
4122
+ w.current = p;
3499
4123
  }, [p]), D(() => {
3500
- var M;
3501
- (M = T.current) == null || M.call(T, b);
4124
+ var S;
4125
+ (S = w.current) == null || S.call(w, b);
3502
4126
  }, [b]);
3503
- const O = P(
3504
- () => (M, _) => k.has(_) ? u(M, _) : null,
3505
- [k, u]
3506
- ), A = P(
3507
- () => k.size === 0 ? t : t.slice(),
3508
- [t, k]
3509
- ), E = P(
3510
- () => c ? Ei(g, [1, 2]) : [],
3511
- [c, g]
3512
- ), S = Number.isFinite(g.center);
3513
- return /* @__PURE__ */ z(Et, { children: [
3514
- /* @__PURE__ */ I(Ii, { accessor: u, data: t, xAxisId: e, yAxisId: n, name: i, format: o, color: r, tone: l }),
3515
- S && /* @__PURE__ */ z(Et, { children: [
3516
- E.map((M) => /* @__PURE__ */ I(
3517
- mt,
4127
+ const L = $(
4128
+ () => (S, _) => v.has(_) ? u(S, _) : null,
4129
+ [v, u]
4130
+ ), A = $(
4131
+ () => v.size === 0 ? t : t.slice(),
4132
+ [t, v]
4133
+ ), z = $(
4134
+ () => c ? as(y, [1, 2]) : [],
4135
+ [c, y]
4136
+ ), T = Number.isFinite(y.center);
4137
+ return /* @__PURE__ */ O(xt, { children: [
4138
+ /* @__PURE__ */ k(is, { accessor: u, data: t, xAxisId: e, yAxisId: n, name: i, format: o, color: r, tone: l }),
4139
+ T && /* @__PURE__ */ O(xt, { children: [
4140
+ z.map((S) => /* @__PURE__ */ k(
4141
+ pt,
3518
4142
  {
3519
- value: M.upper,
4143
+ value: S.upper,
3520
4144
  axisId: n,
3521
4145
  role: "zone",
3522
4146
  inExtent: !1
3523
4147
  },
3524
- `zone-${M.k}-upper`
4148
+ `zone-${S.k}-upper`
3525
4149
  )),
3526
- E.map((M) => /* @__PURE__ */ I(
3527
- mt,
4150
+ z.map((S) => /* @__PURE__ */ k(
4151
+ pt,
3528
4152
  {
3529
- value: M.lower,
4153
+ value: S.lower,
3530
4154
  axisId: n,
3531
4155
  role: "zone",
3532
4156
  inExtent: !1
3533
4157
  },
3534
- `zone-${M.k}-lower`
4158
+ `zone-${S.k}-lower`
3535
4159
  )),
3536
- /* @__PURE__ */ I(mt, { value: g.center, axisId: n, role: "control" }),
3537
- /* @__PURE__ */ I(mt, { value: g.upper, axisId: n, role: "control", label: h }),
3538
- /* @__PURE__ */ I(mt, { value: g.lower, axisId: n, role: "control", label: f })
4160
+ /* @__PURE__ */ k(pt, { value: y.center, axisId: n, role: "control" }),
4161
+ /* @__PURE__ */ k(pt, { value: y.upper, axisId: n, role: "control", label: h }),
4162
+ /* @__PURE__ */ k(pt, { value: y.lower, axisId: n, role: "control", label: f })
3539
4163
  ] }),
3540
- /* @__PURE__ */ I(
3541
- Ai,
4164
+ /* @__PURE__ */ k(
4165
+ ss,
3542
4166
  {
3543
- accessor: O,
4167
+ accessor: L,
3544
4168
  data: A,
3545
4169
  xAxisId: e,
3546
4170
  yAxisId: n,
@@ -3552,7 +4176,7 @@ function es(s) {
3552
4176
  )
3553
4177
  ] });
3554
4178
  }
3555
- function ns(s) {
4179
+ function Os(s) {
3556
4180
  const {
3557
4181
  id: t = "x",
3558
4182
  position: e = "bottom",
@@ -3566,7 +4190,7 @@ function ns(s) {
3566
4190
  time: h,
3567
4191
  calendar: f,
3568
4192
  onDomainChange: m
3569
- } = s, p = P(
4193
+ } = s, p = $(
3570
4194
  () => ({
3571
4195
  id: t,
3572
4196
  orientation: "x",
@@ -3584,9 +4208,9 @@ function ns(s) {
3584
4208
  }),
3585
4209
  [t, e, n, i, o, r, l, a, c, h, f, m]
3586
4210
  );
3587
- return Be("XAxis", p), null;
4211
+ return an("XAxis", p), null;
3588
4212
  }
3589
- function is(s) {
4213
+ function Hs(s) {
3590
4214
  const {
3591
4215
  id: t = "y",
3592
4216
  position: e = "left",
@@ -3598,7 +4222,7 @@ function is(s) {
3598
4222
  grid: a,
3599
4223
  ticks: c,
3600
4224
  alignTicks: h
3601
- } = s, f = P(
4225
+ } = s, f = $(
3602
4226
  () => ({
3603
4227
  id: t,
3604
4228
  orientation: "y",
@@ -3614,60 +4238,22 @@ function is(s) {
3614
4238
  }),
3615
4239
  [t, e, n, i, o, r, l, a, c, h]
3616
4240
  );
3617
- return Be("YAxis", f), null;
3618
- }
3619
- function Wi({
3620
- scene: s,
3621
- placement: t,
3622
- onToggle: e
3623
- }) {
3624
- gi("Legend", { placement: t });
3625
- const n = $t(
3626
- s.subscribeLayout,
3627
- s.getLayoutSnapshot,
3628
- s.getLayoutServerSnapshot
3629
- );
3630
- return n.series.length === 0 ? null : /* @__PURE__ */ I("div", { className: `uc-legend uc-legend-${t}`, children: n.series.map((i) => {
3631
- const o = {
3632
- className: "uc-legend-item",
3633
- "data-hidden": i.hidden ? "" : void 0,
3634
- onPointerEnter: () => s.setHighlight(i.seriesIds),
3635
- onPointerLeave: () => s.setHighlight(null)
3636
- }, r = /* @__PURE__ */ z(Et, { children: [
3637
- /* @__PURE__ */ I("span", { className: "uc-legend-chip", style: { background: i.color } }),
3638
- i.name
3639
- ] });
3640
- return e === void 0 ? /* @__PURE__ */ I("span", { ...o, children: r }, i.id) : /* @__PURE__ */ I(
3641
- "button",
3642
- {
3643
- type: "button",
3644
- "aria-pressed": !i.hidden,
3645
- onClick: () => e(i.name),
3646
- ...o,
3647
- children: r
3648
- },
3649
- i.id
3650
- );
3651
- }) });
3652
- }
3653
- function ss({ placement: s = "top", onToggle: t }) {
3654
- const e = ct("Legend");
3655
- return e === null ? null : /* @__PURE__ */ I(Wi, { scene: e, placement: s, onToggle: t });
4241
+ return an("YAxis", f), null;
3656
4242
  }
3657
- function os(s) {
3658
- const { mode: t = "x", render: e } = s, n = P(
4243
+ function Rs(s) {
4244
+ const { mode: t = "x", render: e } = s, n = $(
3659
4245
  () => ({ mode: t, render: e }),
3660
4246
  [t, e]
3661
4247
  );
3662
- return bi("Tooltip", n), null;
4248
+ return Ui("Tooltip", n), null;
3663
4249
  }
3664
- const Vi = {
4250
+ const xs = {
3665
4251
  cutoff: 0.8,
3666
4252
  collectRank: Number.POSITIVE_INFINITY
3667
4253
  };
3668
- function rs(s, t = {}) {
3669
- const e = { ...Vi, ...t };
3670
- pt(
4254
+ function Ws(s, t = {}) {
4255
+ const e = { ...xs, ...t };
4256
+ gt(
3671
4257
  !Number.isFinite(e.collectRank) || e.remainderName !== void 0,
3672
4258
  "pareto: a collect rank needs `remainderName` - the package brings no name for the remainder."
3673
4259
  );
@@ -3688,54 +4274,55 @@ function rs(s, t = {}) {
3688
4274
  return { entries: c, total: a, cutoffIndex: m };
3689
4275
  }
3690
4276
  export {
3691
- Xi as Area,
3692
- Zi as Bar,
3693
- Ui as Chart,
3694
- es as ControlChart,
4277
+ Ls as Area,
4278
+ Es as Bar,
4279
+ Ss as Chart,
4280
+ $s as ControlChart,
3695
4281
  K as DAY,
3696
- _e as DEFAULT_CHARTS_WORDING,
3697
- Ti as DEFAULT_GRADIENT,
3698
- st as HOUR,
3699
- ss as Legend,
3700
- Qi as LimitBand,
3701
- mt as LimitLine,
3702
- Ii as Line,
3703
- ae as LinearScale,
3704
- B as MINUTE,
3705
- Ji as Matrix,
3706
- it as SECOND,
3707
- Ai as Scatter,
3708
- ji as StateBand,
3709
- os as Tooltip,
3710
- ns as XAxis,
3711
- is as YAxis,
3712
- Un as assess,
3713
- yn as breaks,
3714
- J as calendarFrom,
3715
- Si as controlLimits,
3716
- se as defaultRules,
3717
- le as invalidateTheme,
3718
- Ki as localOffset,
3719
- Bi as mapSeries,
3720
- hn as operatingCalendar,
3721
- Gi as operatingTicks,
3722
- gn as operatingTimeTicks,
3723
- rs as pareto,
3724
- Vi as paretoDefaults,
3725
- pn as removedIntervals,
3726
- nn as resolveColours,
3727
- Fi as ruleOutlier,
3728
- Pi as ruleRun,
3729
- Di as ruleTrend,
3730
- Ci as ruleTwoOfThree,
3731
- ts as sigmaFromLimit,
3732
- on as subscribeTheme,
3733
- xn as timeStep,
3734
- lt as toOperatingTime,
3735
- fn as toOperatingTimeClamped,
3736
- at as toWallClock,
3737
- qi as verdictWeight,
3738
- $i as violatedIndices,
3739
- Oi as violations,
3740
- Ei as zones
4282
+ sn as DEFAULT_CHARTS_WORDING,
4283
+ os as DEFAULT_GRADIENT,
4284
+ Ts as DataTable,
4285
+ rt as HOUR,
4286
+ Ms as Legend,
4287
+ Ps as LimitBand,
4288
+ pt as LimitLine,
4289
+ is as Line,
4290
+ be as LinearScale,
4291
+ V as MINUTE,
4292
+ Ds as Matrix,
4293
+ ot as SECOND,
4294
+ ss as Scatter,
4295
+ Fs as StateBand,
4296
+ Rs as Tooltip,
4297
+ Os as XAxis,
4298
+ Hs as YAxis,
4299
+ Ni as assess,
4300
+ Hn as breaks,
4301
+ tt as calendarFrom,
4302
+ ls as controlLimits,
4303
+ ge as defaultRules,
4304
+ qt as invalidateTheme,
4305
+ Ns as localOffset,
4306
+ ws as mapSeries,
4307
+ Dn as operatingCalendar,
4308
+ Is as operatingTicks,
4309
+ Wn as operatingTimeTicks,
4310
+ Ws as pareto,
4311
+ xs as paretoDefaults,
4312
+ On as removedIntervals,
4313
+ In as resolveColours,
4314
+ us as ruleOutlier,
4315
+ hs as ruleRun,
4316
+ ds as ruleTrend,
4317
+ fs as ruleTwoOfThree,
4318
+ Cs as sigmaFromLimit,
4319
+ Tn as subscribeTheme,
4320
+ Rn as timeStep,
4321
+ ut as toOperatingTime,
4322
+ Cn as toOperatingTimeClamped,
4323
+ ht as toWallClock,
4324
+ As as verdictWeight,
4325
+ ps as violatedIndices,
4326
+ ms as violations,
4327
+ as as zones
3741
4328
  };