@cascivo/charts 0.2.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/index.js ADDED
@@ -0,0 +1,2090 @@
1
+ "use client";
2
+ import { useSignal as e, useSignalEffect as t, useSignals as n } from "@cascivo/core";
3
+ import { useId as r, useRef as i } from "react";
4
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
5
+ import { builtin as c, t as l } from "@cascivo/i18n";
6
+ //#region src/engine/scale.ts
7
+ function u(e, t) {
8
+ let [n, r] = e, [i, a] = t, o = r - n;
9
+ return {
10
+ domain: e,
11
+ range: t,
12
+ map: (e) => o === 0 ? i : i + (e - n) / o * (a - i),
13
+ invert: (e) => a - i === 0 ? n : n + (e - i) / (a - i) * o,
14
+ ticks: (e = 5) => d(n, r, e)
15
+ };
16
+ }
17
+ function d(e, t, n = 5) {
18
+ if (!Number.isFinite(e) || !Number.isFinite(t) || e === t) return [e];
19
+ e > t && ([e, t] = [t, e]);
20
+ let r = (t - e) / Math.max(1, n), i = 10 ** Math.floor(Math.log10(r)), a = [
21
+ 1,
22
+ 2,
23
+ 2.5,
24
+ 5,
25
+ 10
26
+ ], o = r / i, s = (a.find((e) => e >= o) ?? 10) * i, c = Math.ceil(e / s), l = Math.floor(t / s + 1e-9), u = [], d = Math.max(0, Math.ceil(-Math.log10(s)) + 2);
27
+ for (let e = c; e <= l; e++) u.push(parseFloat((e * s).toFixed(d)));
28
+ return u;
29
+ }
30
+ function f(e, t, n = .1) {
31
+ let [r, i] = t, a = e.length, o = (i - r) / Math.max(1, a + n * (a + 1)), s = o, c = o * n, l = new Map(e.map((e, t) => [e, t]));
32
+ return {
33
+ domain: e,
34
+ range: t,
35
+ bandwidth: s,
36
+ map: (e) => {
37
+ let t = l.get(e);
38
+ return t === void 0 ? void 0 : r + c + t * (o + c);
39
+ }
40
+ };
41
+ }
42
+ function p(e, t) {
43
+ let [n, r] = e, [i, a] = t, o = Math.sqrt(Math.max(0, n)), s = Math.sqrt(Math.max(0, r)) - o;
44
+ return (e) => s === 0 ? (i + a) / 2 : i + (Math.sqrt(Math.max(0, e)) - o) / s * (a - i);
45
+ }
46
+ //#endregion
47
+ //#region src/engine/scale-log.ts
48
+ function m(e, t) {
49
+ let [n, r] = e;
50
+ if (n <= 0 || r <= 0) throw Error(`logScale: domain must be strictly positive, got [${n}, ${r}]`);
51
+ let [i, a] = t, o = Math.log10(n), s = Math.log10(r), c = s - o;
52
+ return {
53
+ domain: e,
54
+ range: t,
55
+ map: (e) => c === 0 ? i : i + (Math.log10(e) - o) / c * (a - i),
56
+ invert: (e) => 10 ** (o + (e - i) / (a - i) * c),
57
+ ticks: () => {
58
+ let e = Math.ceil(o), t = Math.floor(s), i = [];
59
+ for (let n = e; n <= t; n++) i.push(10 ** n);
60
+ if (i.length < 3) {
61
+ let e = [];
62
+ for (let t = Math.floor(o); t <= Math.ceil(s); t++) for (let i of [2, 5]) {
63
+ let a = i * 10 ** t;
64
+ a > n && a < r && e.push(a);
65
+ }
66
+ i.push(...e), i.sort((e, t) => e - t);
67
+ }
68
+ return i.filter((e) => e >= n && e <= r);
69
+ }
70
+ };
71
+ }
72
+ //#endregion
73
+ //#region src/engine/scale-time.ts
74
+ var h = [
75
+ {
76
+ unit: "minute",
77
+ ms: 6e4
78
+ },
79
+ {
80
+ unit: "hour",
81
+ ms: 36e5
82
+ },
83
+ {
84
+ unit: "day",
85
+ ms: 864e5
86
+ },
87
+ {
88
+ unit: "week",
89
+ ms: 6048e5
90
+ },
91
+ {
92
+ unit: "month",
93
+ ms: 26298e5
94
+ },
95
+ {
96
+ unit: "quarter",
97
+ ms: 78894e5
98
+ },
99
+ {
100
+ unit: "year",
101
+ ms: 315576e5
102
+ }
103
+ ];
104
+ function g(e, t) {
105
+ let n = e.getUTCFullYear(), r = e.getUTCMonth();
106
+ if (t === "year") return new Date(Date.UTC(n, 0, 1));
107
+ if (t === "quarter") return new Date(Date.UTC(n, Math.floor(r / 3) * 3, 1));
108
+ if (t === "month") return new Date(Date.UTC(n, r, 1));
109
+ if (t === "week") {
110
+ let t = e.getUTCDate() - e.getUTCDay();
111
+ return new Date(Date.UTC(n, r, t));
112
+ }
113
+ return t === "day" ? new Date(Date.UTC(n, r, e.getUTCDate())) : t === "hour" ? new Date(Date.UTC(n, r, e.getUTCDate(), e.getUTCHours())) : new Date(Date.UTC(n, r, e.getUTCDate(), e.getUTCHours(), e.getUTCMinutes()));
114
+ }
115
+ function _(e, t, n = 1) {
116
+ let r = e.getUTCFullYear(), i = e.getUTCMonth();
117
+ if (t === "year") return new Date(Date.UTC(r + n, i, 1));
118
+ if (t === "quarter") return new Date(Date.UTC(r, i + 3 * n, 1));
119
+ if (t === "month") return new Date(Date.UTC(r, i + n, 1));
120
+ let a = {
121
+ week: 6048e5,
122
+ day: 864e5,
123
+ hour: 36e5,
124
+ minute: 6e4
125
+ }[t];
126
+ return new Date(e.getTime() + a * n);
127
+ }
128
+ function v(e, t) {
129
+ let [n, r] = e, [i, a] = t, o = r.getTime() - n.getTime();
130
+ function s(e) {
131
+ for (let t of h) if (o / t.ms <= e * 1.5) return t.unit;
132
+ return "year";
133
+ }
134
+ function c(e) {
135
+ return e === "minute" ? {
136
+ hour: "numeric",
137
+ minute: "2-digit"
138
+ } : e === "hour" ? { hour: "numeric" } : e === "day" || e === "week" ? {
139
+ month: "short",
140
+ day: "numeric"
141
+ } : e === "month" || e === "quarter" ? {
142
+ month: "short",
143
+ year: "numeric"
144
+ } : { year: "numeric" };
145
+ }
146
+ return {
147
+ domain: e,
148
+ range: t,
149
+ map: (e) => o === 0 ? i : i + (e.getTime() - n.getTime()) / o * (a - i),
150
+ invert: (e) => new Date(n.getTime() + (e - i) / (a - i) * o),
151
+ tickInterval: () => s(5),
152
+ tickFormat: () => c(s(5)),
153
+ ticks: (e = 5) => {
154
+ let t = s(e), i = g(n, t), a = [], o = i.getTime() >= n.getTime() ? i : _(i, t), c = 0;
155
+ for (; o.getTime() <= r.getTime() && c++ < 100;) a.push(o), o = _(o, t);
156
+ return a;
157
+ }
158
+ };
159
+ }
160
+ //#endregion
161
+ //#region src/engine/shape.ts
162
+ function y(e, t = "linear") {
163
+ return e.length === 0 ? "" : e.length === 1 || t === "linear" ? e.map(([e, t], n) => `${n === 0 ? "M" : "L"}${e},${t}`).join("") : b(e);
164
+ }
165
+ function b(e) {
166
+ let t = e.length, n = [], r = [], i = [];
167
+ for (let a = 0; a < t - 1; a++) n[a] = e[a + 1][0] - e[a][0], r[a] = e[a + 1][1] - e[a][1], i[a] = n[a] === 0 ? 0 : r[a] / n[a];
168
+ let a = [i[0] ?? 0];
169
+ for (let e = 1; e < t - 1; e++) {
170
+ let t = i[e - 1], n = i[e];
171
+ a[e] = t * n <= 0 ? 0 : 2 * t * n / (t + n);
172
+ }
173
+ a[t - 1] = i[t - 2] ?? 0;
174
+ let o = `M${e[0][0]},${e[0][1]}`;
175
+ for (let n = 0; n < t - 1; n++) {
176
+ let [t, r] = e[n], [i, s] = e[n + 1], c = (i - t) / 3;
177
+ o += `C${t + c},${r + c * a[n]} ${i - c},${s - c * a[n + 1]} ${i},${s}`;
178
+ }
179
+ return o;
180
+ }
181
+ function x(e, t, n = "linear") {
182
+ if (e.length === 0) return "";
183
+ let r = y(e, n), i = e[e.length - 1], a = e[0];
184
+ return `${r}L${i[0]},${t}L${a[0]},${t}Z`;
185
+ }
186
+ function S(e, t, n, r, i, a) {
187
+ let o = 2 * Math.PI;
188
+ if (Math.abs(a - i) >= o - 1e-9) {
189
+ let a = i + Math.PI;
190
+ return S(e, t, n, r, i, a) + S(e, t, n, r, a, i + o - 1e-9);
191
+ }
192
+ let s = (n, r) => [e + n * Math.sin(r), t - n * Math.cos(r)], c = +(a - i > Math.PI), [l, u] = s(n, i), [d, f] = s(n, a);
193
+ if (r <= 0) return `M${e},${t}L${l},${u}A${n},${n} 0 ${c} 1 ${d},${f}Z`;
194
+ let [p, m] = s(r, a), [h, g] = s(r, i);
195
+ return `M${l},${u}A${n},${n} 0 ${c} 1 ${d},${f}L${p},${m}A${r},${r} 0 ${c} 0 ${h},${g}Z`;
196
+ }
197
+ function C(e) {
198
+ let t = e[0]?.length ?? 0, n = Array.from({ length: t }, () => 0);
199
+ return e.map((e) => e.map((e, t) => {
200
+ let r = n[t];
201
+ return n[t] = r + e, [r, n[t]];
202
+ }));
203
+ }
204
+ //#endregion
205
+ //#region src/engine/nearest.ts
206
+ function w(e, t) {
207
+ if (e.length === 0) return -1;
208
+ if (e.length === 1) return 0;
209
+ let n = 0, r = e.length - 1;
210
+ for (; n < r;) {
211
+ let i = n + r >> 1;
212
+ e[i] < t ? n = i + 1 : r = i;
213
+ }
214
+ return n > 0 && Math.abs(e[n - 1] - t) < Math.abs(e[n] - t) ? n - 1 : n;
215
+ }
216
+ //#endregion
217
+ //#region src/engine/stats.ts
218
+ function T(e) {
219
+ let t = e.length, n = e[Math.floor(t * .25)] ?? 0;
220
+ return (e[Math.floor(t * .75)] ?? 0) - n;
221
+ }
222
+ function E(e, t) {
223
+ if (e.length === 0) return [];
224
+ let n = [...e].sort((e, t) => e - t), r = n.length, i = n[0] ?? 0, a = n[r - 1] ?? 0;
225
+ if (i === a) return [{
226
+ x0: i,
227
+ x1: i + 1,
228
+ count: r
229
+ }];
230
+ let o;
231
+ if (t !== void 0 && t > 0) o = t;
232
+ else {
233
+ let e = 2 * T(n) * r ** (-1 / 3);
234
+ o = Math.ceil(e > 0 ? (a - i) / e : Math.sqrt(r)), o = Math.max(1, Math.min(o, 200));
235
+ }
236
+ let s = (a - i) / o, c = Array.from({ length: o }, (e, t) => ({
237
+ x0: i + t * s,
238
+ x1: i + (t + 1) * s,
239
+ count: 0
240
+ }));
241
+ for (let t of e) {
242
+ let e = c[Math.min(Math.floor((t - i) / s), o - 1)];
243
+ e && e.count++;
244
+ }
245
+ return c;
246
+ }
247
+ function D(e) {
248
+ if (e.length === 0) return {
249
+ min: 0,
250
+ q1: 0,
251
+ median: 0,
252
+ q3: 0,
253
+ max: 0,
254
+ outliers: []
255
+ };
256
+ let t = [...e].sort((e, t) => e - t), n = t.length, r = (e) => {
257
+ let t = Math.floor(e.length / 2);
258
+ return e.length % 2 == 0 ? ((e[t - 1] ?? 0) + (e[t] ?? 0)) / 2 : e[t] ?? 0;
259
+ }, i = r(t.slice(0, Math.floor(n / 2))), a = r(t.slice(Math.ceil(n / 2))), o = r(t), s = a - i, c = i - 1.5 * s, l = a + 1.5 * s, u = t.filter((e) => e >= c && e <= l), d = t.filter((e) => e < c || e > l);
260
+ return {
261
+ min: u[0] ?? t[0] ?? 0,
262
+ q1: i,
263
+ median: o,
264
+ q3: a,
265
+ max: u[u.length - 1] ?? t[n - 1] ?? 0,
266
+ outliers: d
267
+ };
268
+ }
269
+ function O(e) {
270
+ if (e.length === 0) return [0, 1];
271
+ let t = e[0] ?? 0, n = e[0] ?? 0;
272
+ for (let r of e) r < t && (t = r), r > n && (n = r);
273
+ return [t, n];
274
+ }
275
+ //#endregion
276
+ //#region src/engine/treemap.ts
277
+ function k(e, t, n) {
278
+ let r = Math.max(...e), i = Math.min(...e);
279
+ return Math.max(t * t * r / (n * n), n * n / (t * t * i));
280
+ }
281
+ function A(e, t, n, r, i, a, o) {
282
+ let s = e.reduce((e, t) => e + t, 0), c = t, l = n;
283
+ for (let t = 0; t < e.length; t++) {
284
+ let n = e[t] ?? 0, u = a[t] ?? "";
285
+ if (r >= i) {
286
+ let e = (s > 0 ? n / s : 0) * r;
287
+ o.push({
288
+ id: u,
289
+ x: c,
290
+ y: l,
291
+ w: e,
292
+ h: i
293
+ }), c += e;
294
+ } else {
295
+ let e = (s > 0 ? n / s : 0) * i;
296
+ o.push({
297
+ id: u,
298
+ x: c,
299
+ y: l,
300
+ w: r,
301
+ h: e
302
+ }), l += e;
303
+ }
304
+ }
305
+ }
306
+ function j(e, t, n, r, i, a) {
307
+ if (e.length === 0 || r <= 0 || i <= 0) return;
308
+ let o = e.reduce((e, t) => e + t.value, 0);
309
+ if (o === 0) return;
310
+ let s = r * i, c = e.map((e) => e.value / o * s), l = e.map((e) => e.id), u = [], d = [], f = Math.min(r, i), p = 0, m = 0;
311
+ for (; m < c.length;) {
312
+ let o = c[m] ?? 0, h = l[m] ?? "", g = [...u, o], _ = p + o;
313
+ if (u.length === 0 || k(g, f, _) <= k(u, f, p)) u = g, d = [...d, h], p = _, m++;
314
+ else {
315
+ let o = p / s;
316
+ if (r >= i) {
317
+ let s = o * r;
318
+ A(u, t, n, s, i, d, a), j(e.slice(m), t + s, n, r - s, i, a);
319
+ } else {
320
+ let s = o * i;
321
+ A(u, t, n, r, s, d, a), j(e.slice(m), t, n + s, r, i - s, a);
322
+ }
323
+ return;
324
+ }
325
+ }
326
+ if (u.length > 0) {
327
+ let e = p / s;
328
+ r >= i ? A(u, t, n, e * r, i, d, a) : A(u, t, n, r, e * i, d, a);
329
+ }
330
+ }
331
+ function M(e, t, n) {
332
+ if (e.length === 0 || t <= 0 || n <= 0) return [];
333
+ let r = [...e].sort((e, t) => t.value - e.value), i = [];
334
+ return j(r, 0, 0, t, n, i), i;
335
+ }
336
+ //#endregion
337
+ //#region src/core/use-chart.ts
338
+ function N(n = 400, r = 300) {
339
+ let a = i(null), o = e(n), s = e(r);
340
+ return t(() => {
341
+ let e = a.current;
342
+ if (!e) return;
343
+ if (typeof ResizeObserver > "u") {
344
+ let t = e.getBoundingClientRect();
345
+ t.width > 0 && (o.value = t.width), t.height > 0 && (s.value = t.height);
346
+ return;
347
+ }
348
+ let t = new ResizeObserver((e) => {
349
+ for (let t of e) {
350
+ let { contentRect: e } = t;
351
+ e.width > 0 && (o.value = e.width), e.height > 0 && (s.value = e.height);
352
+ }
353
+ });
354
+ return t.observe(e), () => t.disconnect();
355
+ }), {
356
+ ref: a,
357
+ width: o,
358
+ height: s
359
+ };
360
+ }
361
+ var P = {
362
+ top: 8,
363
+ right: 8,
364
+ bottom: 24,
365
+ left: 36
366
+ }, F = {
367
+ top: 2,
368
+ right: 2,
369
+ bottom: 2,
370
+ left: 2
371
+ }, I = {
372
+ frame: "_frame_1aivh_2",
373
+ fallback: "_fallback_1aivh_7"
374
+ };
375
+ //#endregion
376
+ //#region src/core/data-point.ts
377
+ function L(e) {
378
+ return `${e.label}: ${e.value}`;
379
+ }
380
+ //#endregion
381
+ //#region src/core/chart-tooltip.tsx
382
+ function ee({ point: e, model: t }) {
383
+ let n = t.format ? t.format(e) : L(e);
384
+ return /* @__PURE__ */ o("div", {
385
+ role: "tooltip",
386
+ style: {
387
+ position: "absolute",
388
+ left: e.cx + 8,
389
+ top: Math.max(0, e.cy - 32),
390
+ pointerEvents: "none",
391
+ background: "var(--cascivo-surface-overlay, var(--cascivo-color-background))",
392
+ color: "var(--cascivo-text-primary, currentColor)",
393
+ border: "1px solid var(--cascivo-color-border)",
394
+ borderRadius: "var(--cascivo-radius-sm, 4px)",
395
+ padding: "0.25rem 0.5rem",
396
+ fontSize: "0.8125rem",
397
+ whiteSpace: "nowrap",
398
+ boxShadow: "var(--cascivo-shadow-sm, 0 1px 4px rgba(0,0,0,0.1))",
399
+ zIndex: 10
400
+ },
401
+ children: n
402
+ });
403
+ }
404
+ //#endregion
405
+ //#region src/core/nearest.ts
406
+ function te(e, t, n, r = "xy") {
407
+ if (e.length === 0) return -1;
408
+ let i = 0, a = Infinity;
409
+ for (let o = 0; o < e.length; o++) {
410
+ let s = e[o], c = r === "x" ? Math.abs(s.cx - t) : Math.hypot(s.cx - t, s.cy - n);
411
+ c < a && (a = c, i = o);
412
+ }
413
+ return i;
414
+ }
415
+ //#endregion
416
+ //#region src/core/chart-frame.tsx
417
+ function R({ title: c, description: l, width: u, height: d = 300, fallback: f, children: p, className: m, "data-state": h, plain: g, tooltip: _ }) {
418
+ n();
419
+ let v = r(), y = `${v}-desc`, b = `${v}-live`, { ref: x, width: S, height: C } = N(u ?? 400, d), w = e(null), T = i(null), E = u ?? S.value, D = d ?? C.value, O = typeof _ == "function" ? _({
420
+ width: E,
421
+ height: D
422
+ }) : _;
423
+ t(() => {
424
+ let e = w.value;
425
+ if (!O || !T.current) return;
426
+ let t = e === null ? void 0 : O.points[e];
427
+ T.current.textContent = t ? (O.format ?? L)(t) : "";
428
+ });
429
+ let k = {
430
+ position: "absolute",
431
+ inset: 0,
432
+ cursor: "crosshair",
433
+ background: "transparent"
434
+ }, A = O === void 0 ? void 0 : { position: "relative" };
435
+ return /* @__PURE__ */ s("div", {
436
+ ref: x,
437
+ className: [I.frame, m].filter(Boolean).join(" "),
438
+ style: A,
439
+ ...h !== void 0 && { "data-state": h },
440
+ ...g === !0 && { "data-plain": "" },
441
+ children: [
442
+ /* @__PURE__ */ s("svg", {
443
+ role: "img",
444
+ "aria-label": c,
445
+ "aria-describedby": l ? y : void 0,
446
+ width: E,
447
+ height: D,
448
+ viewBox: `0 0 ${E} ${D}`,
449
+ children: [l && /* @__PURE__ */ o("desc", {
450
+ id: y,
451
+ children: l
452
+ }), p({
453
+ width: E,
454
+ height: D
455
+ })]
456
+ }),
457
+ f && /* @__PURE__ */ o("div", {
458
+ className: I.fallback,
459
+ children: f
460
+ }),
461
+ O !== void 0 && /* @__PURE__ */ s(a, { children: [
462
+ /* @__PURE__ */ o("span", {
463
+ id: b,
464
+ ref: T,
465
+ "aria-live": "polite",
466
+ style: {
467
+ position: "absolute",
468
+ width: "1px",
469
+ height: "1px",
470
+ padding: 0,
471
+ margin: "-1px",
472
+ overflow: "hidden",
473
+ clip: "rect(0,0,0,0)",
474
+ whiteSpace: "nowrap",
475
+ border: 0
476
+ }
477
+ }),
478
+ w.value !== null && O.points[w.value] !== void 0 && (() => {
479
+ let e = O.points[w.value];
480
+ return /* @__PURE__ */ o("div", {
481
+ "aria-hidden": "true",
482
+ style: {
483
+ position: "absolute",
484
+ left: e.cx - 4,
485
+ top: e.cy - 4,
486
+ width: 8,
487
+ height: 8,
488
+ borderRadius: "50%",
489
+ border: "2px solid var(--cascivo-focus-ring, var(--cascivo-color-accent))",
490
+ background: "var(--cascivo-color-background, white)",
491
+ pointerEvents: "none",
492
+ zIndex: 10
493
+ }
494
+ });
495
+ })(),
496
+ w.value !== null && O.points[w.value] !== void 0 && /* @__PURE__ */ o(ee, {
497
+ point: O.points[w.value],
498
+ model: O
499
+ }),
500
+ /* @__PURE__ */ o("div", {
501
+ role: "application",
502
+ "aria-label": "Chart data — use arrow keys to navigate points",
503
+ tabIndex: 0,
504
+ style: k,
505
+ onPointerMove: (e) => {
506
+ if (!O.points.length) return;
507
+ let t = e.currentTarget.getBoundingClientRect(), n = e.clientX - t.left, r = e.clientY - t.top;
508
+ w.value = te(O.points, n, r, "xy");
509
+ },
510
+ onPointerLeave: () => {
511
+ w.value = null;
512
+ },
513
+ onKeyDown: (e) => {
514
+ if (!O.points.length) return;
515
+ let t = w.value;
516
+ e.key === "ArrowRight" || e.key === "ArrowDown" ? (e.preventDefault(), w.value = t === null ? 0 : Math.min(t + 1, O.points.length - 1)) : e.key === "ArrowLeft" || e.key === "ArrowUp" ? (e.preventDefault(), w.value = t === null ? O.points.length - 1 : Math.max(t - 1, 0)) : e.key === "Home" ? (e.preventDefault(), w.value = 0) : e.key === "End" ? (e.preventDefault(), w.value = O.points.length - 1) : e.key === "Escape" && (w.value = null);
517
+ },
518
+ onFocus: () => {
519
+ O.points.length > 0 && w.value === null && (w.value = 0);
520
+ },
521
+ onBlur: () => {
522
+ w.value = null;
523
+ }
524
+ })
525
+ ] })
526
+ ]
527
+ });
528
+ }
529
+ //#endregion
530
+ //#region src/chrome/axis.tsx
531
+ function ne(e) {
532
+ return "bandwidth" in e;
533
+ }
534
+ function re(e) {
535
+ return "tickInterval" in e;
536
+ }
537
+ function ie(e) {
538
+ return e instanceof Date ? e.toLocaleDateString() : typeof e == "number" ? e.toLocaleString() : String(e);
539
+ }
540
+ function z({ scale: e, orientation: t, length: n, format: r = ie, tickCount: i = 5, transform: a }) {
541
+ let c;
542
+ if (ne(e)) c = e.domain.map((t) => ({
543
+ position: (e.map(t) ?? 0) + e.bandwidth / 2,
544
+ label: r(t)
545
+ }));
546
+ else if (re(e)) c = e.ticks(i).map((t) => ({
547
+ position: e.map(t),
548
+ label: r(t)
549
+ }));
550
+ else {
551
+ let t = e;
552
+ c = t.ticks(i).map((e) => ({
553
+ position: t.map(e),
554
+ label: r(e)
555
+ }));
556
+ }
557
+ let l = t === "x";
558
+ return /* @__PURE__ */ s("g", {
559
+ transform: a,
560
+ "aria-hidden": "true",
561
+ children: [/* @__PURE__ */ o("line", {
562
+ x1: 0,
563
+ y1: 0,
564
+ x2: l ? n : 0,
565
+ y2: l ? 0 : n,
566
+ stroke: "var(--cascivo-chart-axis)",
567
+ strokeWidth: 1
568
+ }), c.map(({ position: e, label: t }, n) => /* @__PURE__ */ s("g", {
569
+ transform: l ? `translate(${e},0)` : `translate(0,${e})`,
570
+ children: [/* @__PURE__ */ o("line", {
571
+ x1: 0,
572
+ y1: 0,
573
+ x2: l ? 0 : -4,
574
+ y2: l ? 4 : 0,
575
+ stroke: "var(--cascivo-chart-axis)",
576
+ strokeWidth: 1
577
+ }), /* @__PURE__ */ o("text", {
578
+ x: l ? 0 : -8,
579
+ y: l ? 16 : 4,
580
+ textAnchor: l ? "middle" : "end",
581
+ fill: "var(--cascivo-chart-axis)",
582
+ fontSize: 11,
583
+ children: t
584
+ })]
585
+ }, n))]
586
+ });
587
+ }
588
+ //#endregion
589
+ //#region src/chrome/grid-lines.tsx
590
+ function B({ scale: e, orientation: t, length: n, tickCount: r = 5, transform: i }) {
591
+ let a = e.ticks(r), s = t === "x";
592
+ return /* @__PURE__ */ o("g", {
593
+ transform: i,
594
+ "aria-hidden": "true",
595
+ children: a.map((t) => {
596
+ let r = e.map(t);
597
+ return /* @__PURE__ */ o("line", {
598
+ x1: s ? r : 0,
599
+ y1: s ? 0 : r,
600
+ x2: s ? r : n,
601
+ y2: s ? n : r,
602
+ stroke: "var(--cascivo-chart-grid)",
603
+ strokeWidth: 1,
604
+ strokeDasharray: "2 4"
605
+ }, t);
606
+ })
607
+ });
608
+ }
609
+ var V = {
610
+ legend: "_legend_zczeh_2",
611
+ item: "_item_zczeh_9",
612
+ swatch: "_swatch_zczeh_27"
613
+ };
614
+ //#endregion
615
+ //#region src/chrome/legend.tsx
616
+ function H({ series: e, hidden: t }) {
617
+ return n(), /* @__PURE__ */ o("div", {
618
+ className: V.legend,
619
+ "aria-label": "Chart legend",
620
+ children: e.map((e, n) => {
621
+ let r = t.value.has(e.id);
622
+ return /* @__PURE__ */ s("button", {
623
+ type: "button",
624
+ className: V.item,
625
+ "data-state": r ? "off" : "on",
626
+ "aria-pressed": !r,
627
+ "aria-label": l(c.charts.legendToggle, { name: e.label }),
628
+ onClick: () => {
629
+ let n = new Set(t.value);
630
+ r ? n.delete(e.id) : n.add(e.id), t.value = n;
631
+ },
632
+ children: [/* @__PURE__ */ o("span", {
633
+ className: V.swatch,
634
+ style: { background: e.color || `var(--cascivo-chart-${n + 1})` },
635
+ "aria-hidden": "true"
636
+ }), e.label]
637
+ }, e.id);
638
+ })
639
+ });
640
+ }
641
+ //#endregion
642
+ //#region src/charts/line-chart/line-chart.tsx
643
+ var U = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
644
+ function ae({ series: t, x: r, y: i, title: c, description: l, curve: d = "monotone", width: f, height: p, xTicks: m = 5, yTicks: h = 5, legend: g, tooltip: _, formatTooltip: b, className: x, plain: S }) {
645
+ n();
646
+ let C = e(/* @__PURE__ */ new Set()), w = S ? F : P, T = p ?? (S ? 48 : 300), E = S ? !1 : g ?? t.length > 1, D = t.flatMap((e) => e.data.map((e) => r(e))), O = t.flatMap((e) => e.data.map((e) => i(e))), k = D.length > 0, A = k && D[0] instanceof Date;
647
+ return /* @__PURE__ */ s("div", {
648
+ style: {
649
+ display: "flex",
650
+ flexDirection: "column",
651
+ gap: "0.5rem"
652
+ },
653
+ children: [/* @__PURE__ */ o(R, {
654
+ title: c,
655
+ description: l,
656
+ width: f,
657
+ height: T,
658
+ fallback: /* @__PURE__ */ s("table", { children: [
659
+ /* @__PURE__ */ o("caption", { children: c }),
660
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "X" }), t.map((e) => /* @__PURE__ */ o("th", { children: e.label }, e.id))] }) }),
661
+ /* @__PURE__ */ o("tbody", { children: (t[0]?.data ?? []).map((e, n) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: String(t[0] ? r(t[0].data[n]) : "") }), t.map((e) => /* @__PURE__ */ o("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, n)) })
662
+ ] }),
663
+ className: x,
664
+ "data-state": k ? void 0 : "empty",
665
+ plain: S,
666
+ tooltip: _ !== !1 && k ? ({ width: e, height: n }) => {
667
+ if (_ === !1 || !k) return;
668
+ let a = e - w.left - w.right, o = n - w.top - w.bottom, s = Math.min(...A ? D.map((e) => e.getTime()) : D), c = Math.max(...A ? D.map((e) => e.getTime()) : D), l = Math.min(0, ...O), d = Math.max(...O), f = A ? v([new Date(s), new Date(c)], [0, a]) : u([s, c], [0, a]), p = u([l, d], [o, 0]), m = t.flatMap((e) => C.value.has(e.id) ? [] : e.data.map((t, n) => {
669
+ let a = r(t), o = f.map(a), s = p.map(i(t)), c = a instanceof Date ? a.toLocaleDateString() : String(a);
670
+ return {
671
+ id: `${e.id}-${n}`,
672
+ cx: w.left + o,
673
+ cy: w.top + s,
674
+ label: c,
675
+ value: i(t),
676
+ seriesId: e.id
677
+ };
678
+ }));
679
+ return b ? {
680
+ points: m,
681
+ format: (e) => {
682
+ let n = t.find((t) => t.id === e.seriesId), r = parseInt(e.id.split("-").pop() ?? "0", 10);
683
+ return n && n.data[r] !== void 0 ? b(n.data[r], n) : `${e.label}: ${e.value}`;
684
+ }
685
+ } : { points: m };
686
+ } : void 0,
687
+ children: ({ width: e, height: n }) => {
688
+ let c = e - w.left - w.right, l = n - w.top - w.bottom, f = Math.min(...A ? D.map((e) => e.getTime()) : D), p = Math.max(...A ? D.map((e) => e.getTime()) : D), g = Math.min(0, ...O), _ = Math.max(...O), b = A ? v([new Date(f), new Date(p)], [0, c]) : u([f, p], [0, c]), x = u([g, _], [l, 0]);
689
+ return /* @__PURE__ */ o("g", { children: /* @__PURE__ */ s("g", {
690
+ transform: `translate(${w.left},${w.top})`,
691
+ children: [
692
+ !S && /* @__PURE__ */ o(B, {
693
+ scale: x,
694
+ orientation: "y",
695
+ length: c,
696
+ tickCount: h
697
+ }),
698
+ t.map((e, t) => {
699
+ if (C.value.has(e.id)) return null;
700
+ let n = e.data.map((e) => {
701
+ let t = r(e);
702
+ return [b.map(t), x.map(i(e))];
703
+ }), a = e.color ?? U[t % U.length];
704
+ return /* @__PURE__ */ o("path", {
705
+ d: y(n, d),
706
+ fill: "none",
707
+ stroke: a,
708
+ strokeWidth: 2,
709
+ strokeLinecap: "round",
710
+ strokeLinejoin: "round",
711
+ "data-series": e.id
712
+ }, e.id);
713
+ }),
714
+ !S && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
715
+ scale: b,
716
+ orientation: "x",
717
+ length: c,
718
+ tickCount: m,
719
+ transform: `translate(0,${l})`
720
+ }), /* @__PURE__ */ o(z, {
721
+ scale: x,
722
+ orientation: "y",
723
+ length: l,
724
+ tickCount: h
725
+ })] })
726
+ ]
727
+ }) });
728
+ }
729
+ }), E && /* @__PURE__ */ o(H, {
730
+ series: t.map((e, t) => ({
731
+ id: e.id,
732
+ label: e.label,
733
+ color: e.color ?? U[t % U.length]
734
+ })),
735
+ hidden: C
736
+ })]
737
+ });
738
+ }
739
+ //#endregion
740
+ //#region src/charts/area-chart/area-chart.tsx
741
+ var W = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
742
+ function oe({ series: t, x: r, y: i, title: c, description: l, stacked: d = !1, curve: f = "monotone", width: p, height: m, xTicks: h = 5, yTicks: g = 5, legend: _, tooltip: v, className: b, plain: S }) {
743
+ n();
744
+ let w = e(/* @__PURE__ */ new Set()), T = S ? F : P, E = m ?? (S ? 48 : 300), D = S ? !1 : _ ?? t.length > 1, O = (t[0]?.data ?? []).map((e) => r(e)), k = t.flatMap((e) => e.data.map((e) => i(e))), A = O.length > 0, j = A ? Math.min(...O) : 0, M = A ? Math.max(...O) : 1, N = d ? 0 : Math.min(0, ...k), I = Math.max(...d ? (t[0]?.data ?? []).map((e, n) => t.reduce((e, t) => e + i(t.data[n]), 0)) : k);
745
+ return /* @__PURE__ */ s("div", {
746
+ style: {
747
+ display: "flex",
748
+ flexDirection: "column",
749
+ gap: "0.5rem"
750
+ },
751
+ children: [/* @__PURE__ */ o(R, {
752
+ title: c,
753
+ description: l,
754
+ width: p,
755
+ height: E,
756
+ fallback: /* @__PURE__ */ s("table", { children: [
757
+ /* @__PURE__ */ o("caption", { children: c }),
758
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "X" }), t.map((e) => /* @__PURE__ */ o("th", { children: e.label }, e.id))] }) }),
759
+ /* @__PURE__ */ o("tbody", { children: (t[0]?.data ?? []).map((e, n) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: t[0] ? String(r(t[0].data[n])) : "" }), t.map((e) => /* @__PURE__ */ o("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, n)) })
760
+ ] }),
761
+ className: b,
762
+ "data-state": A ? void 0 : "empty",
763
+ plain: S,
764
+ tooltip: v !== !1 && A ? ({ width: e, height: n }) => {
765
+ if (v === !1 || !A) return;
766
+ let a = e - T.left - T.right, o = n - T.top - T.bottom, s = u([j, M], [0, a]), c = u([N, I], [o, 0]);
767
+ return { points: t.flatMap((e) => w.value.has(e.id) ? [] : e.data.map((t, n) => ({
768
+ id: `${e.id}-${n}`,
769
+ cx: T.left + s.map(r(t)),
770
+ cy: T.top + c.map(i(t)),
771
+ label: String(r(t)),
772
+ value: i(t),
773
+ seriesId: e.id
774
+ }))) };
775
+ } : void 0,
776
+ children: ({ width: e, height: n }) => {
777
+ let c = e - T.left - T.right, l = n - T.top - T.bottom, p = u([j, M], [0, c]), m = u([N, I], [l, 0]), _ = [];
778
+ return d && (_ = C(t.map((e) => e.data.map((e) => i(e))))), /* @__PURE__ */ o("g", { children: /* @__PURE__ */ s("g", {
779
+ transform: `translate(${T.left},${T.top})`,
780
+ children: [
781
+ !S && /* @__PURE__ */ o(B, {
782
+ scale: m,
783
+ orientation: "y",
784
+ length: c,
785
+ tickCount: g
786
+ }),
787
+ t.map((e, t) => {
788
+ if (w.value.has(e.id)) return null;
789
+ let n = e.color ?? W[t % W.length], a, c;
790
+ if (d && _[t]) {
791
+ let i = _[t];
792
+ a = e.data.map((e, t) => [p.map(r(e)), m.map(i[t][1])]);
793
+ let l = e.data.map((e, t) => [p.map(r(e)), m.map(i[t][0])]);
794
+ c = m.map(0);
795
+ let u = y(a, f), d = l[l.length - 1], h = l[0], g = [...l].reverse().map(([e, t]) => `L${e},${t}`).join(""), v = `${u}L${d[0]},${d[1]}${g}L${h[0]},${h[1]}Z`;
796
+ return /* @__PURE__ */ s("g", {
797
+ "data-series": e.id,
798
+ children: [/* @__PURE__ */ o("path", {
799
+ d: v,
800
+ fill: n,
801
+ fillOpacity: .25,
802
+ stroke: "none"
803
+ }), /* @__PURE__ */ o("path", {
804
+ d: y(a, f),
805
+ fill: "none",
806
+ stroke: n,
807
+ strokeWidth: 2
808
+ })]
809
+ }, e.id);
810
+ } else return a = e.data.map((e) => [p.map(r(e)), m.map(i(e))]), c = m.map(0), /* @__PURE__ */ s("g", {
811
+ "data-series": e.id,
812
+ children: [/* @__PURE__ */ o("path", {
813
+ d: x(a, c, f),
814
+ fill: n,
815
+ fillOpacity: .25,
816
+ stroke: "none"
817
+ }), /* @__PURE__ */ o("path", {
818
+ d: y(a, f),
819
+ fill: "none",
820
+ stroke: n,
821
+ strokeWidth: 2
822
+ })]
823
+ }, e.id);
824
+ }),
825
+ !S && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
826
+ scale: p,
827
+ orientation: "x",
828
+ length: c,
829
+ tickCount: h,
830
+ transform: `translate(0,${l})`
831
+ }), /* @__PURE__ */ o(z, {
832
+ scale: m,
833
+ orientation: "y",
834
+ length: l,
835
+ tickCount: g
836
+ })] })
837
+ ]
838
+ }) });
839
+ }
840
+ }), D && /* @__PURE__ */ o(H, {
841
+ series: t.map((e, t) => ({
842
+ id: e.id,
843
+ label: e.label,
844
+ color: e.color ?? W[t % W.length]
845
+ })),
846
+ hidden: w
847
+ })]
848
+ });
849
+ }
850
+ //#endregion
851
+ //#region src/charts/bar-chart/bar-chart.tsx
852
+ var G = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
853
+ function se({ series: t, x: r, y: i, title: c, description: l, orientation: d = "vertical", mode: p = "grouped", width: m, height: h, xTicks: g = 5, yTicks: _ = 5, legend: v, tooltip: y, className: b, plain: x }) {
854
+ n();
855
+ let S = e(/* @__PURE__ */ new Set()), w = x ? F : P, T = h ?? (x ? 48 : 300), E = x ? !1 : v ?? t.length > 1, D = (t[0]?.data ?? []).map((e) => r(e)), O = t.flatMap((e) => e.data.map((e) => i(e))), k = D.length > 0, A = p === "stacked" ? 0 : Math.min(0, ...O), j = k ? Math.max(...D.map((e, n) => t.reduce((e, t) => e + i(t.data[n]), 0))) : 1, M = p === "stacked" ? j : Math.max(1, ...O);
856
+ return /* @__PURE__ */ s("div", {
857
+ style: {
858
+ display: "flex",
859
+ flexDirection: "column",
860
+ gap: "0.5rem"
861
+ },
862
+ children: [/* @__PURE__ */ o(R, {
863
+ title: c,
864
+ description: l,
865
+ width: m,
866
+ height: T,
867
+ fallback: /* @__PURE__ */ s("table", { children: [
868
+ /* @__PURE__ */ o("caption", { children: c }),
869
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "Category" }), t.map((e) => /* @__PURE__ */ o("th", { children: e.label }, e.id))] }) }),
870
+ /* @__PURE__ */ o("tbody", { children: D.map((e, n) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: e }), t.map((e) => /* @__PURE__ */ o("td", { children: e.data[n] == null ? "" : i(e.data[n]) }, e.id))] }, e)) })
871
+ ] }),
872
+ className: b,
873
+ "data-state": k ? void 0 : "empty",
874
+ plain: x,
875
+ tooltip: y && k ? ({ width: e, height: n }) => {
876
+ if (!y || !k) return;
877
+ let a = e - w.left - w.right, o = n - w.top - w.bottom, s = d === "vertical", c = f(D, s ? [0, a] : [0, o], .2), l = u([A, M], s ? [o, 0] : [0, a]), m = t.filter((e) => !S.value.has(e.id)), h = [];
878
+ return p === "stacked" && (h = C(t.map((e) => e.data.map((e) => i(e))))), { points: m.flatMap((e) => {
879
+ let n = t.indexOf(e), a = p === "grouped" ? c.bandwidth / m.length : c.bandwidth;
880
+ return e.data.map((t, o) => {
881
+ let u = c.map(r(t)) ?? 0, d, f;
882
+ if (p === "stacked" && h[n]) {
883
+ let e = h[n][o];
884
+ d = e[1], f = e[0];
885
+ } else d = i(t), f = A;
886
+ let g = m.indexOf(e), _ = u + (p === "grouped" ? g * a : 0) + a / 2, v = (Math.min(l.map(d), l.map(f)) + Math.max(l.map(d), l.map(f))) / 2;
887
+ return {
888
+ id: `${e.id}-${o}`,
889
+ cx: w.left + (s ? _ : v),
890
+ cy: w.top + (s ? v : _),
891
+ label: r(t),
892
+ value: i(t),
893
+ seriesId: e.id
894
+ };
895
+ });
896
+ }) };
897
+ } : void 0,
898
+ children: ({ width: e, height: n }) => {
899
+ let c = e - w.left - w.right, l = n - w.top - w.bottom, m = d === "vertical", h = f(D, m ? [0, c] : [0, l], .2), v = u([A, M], m ? [l, 0] : [0, c]), y = t.filter((e) => !S.value.has(e.id)), b = [];
900
+ return p === "stacked" && (b = C(t.map((e) => e.data.map((e) => i(e))))), /* @__PURE__ */ o("g", { children: /* @__PURE__ */ s("g", {
901
+ transform: `translate(${w.left},${w.top})`,
902
+ children: [
903
+ !x && m && /* @__PURE__ */ o(B, {
904
+ scale: v,
905
+ orientation: "y",
906
+ length: c,
907
+ tickCount: _
908
+ }),
909
+ !x && !m && /* @__PURE__ */ o(B, {
910
+ scale: v,
911
+ orientation: "x",
912
+ length: l,
913
+ tickCount: g
914
+ }),
915
+ y.map((e, n) => {
916
+ let a = e.color ?? G[t.indexOf(e) % G.length], s = t.indexOf(e), c = p === "grouped" ? h.bandwidth / y.length : h.bandwidth;
917
+ return e.data.map((t, l) => {
918
+ let u = h.map(r(t)) ?? 0, d, f;
919
+ if (p === "stacked" && b[s]) {
920
+ let e = b[s][l];
921
+ d = e[1], f = e[0];
922
+ } else d = i(t), f = A;
923
+ let g = u + (p === "grouped" ? n * c : 0), _ = Math.min(v.map(d), v.map(f)), y = Math.abs(v.map(d) - v.map(f));
924
+ return m ? /* @__PURE__ */ o("rect", {
925
+ x: g,
926
+ y: _,
927
+ width: c,
928
+ height: y,
929
+ fill: a,
930
+ rx: 2,
931
+ "data-series": e.id
932
+ }, `${e.id}-${l}`) : /* @__PURE__ */ o("rect", {
933
+ x: _,
934
+ y: g,
935
+ width: y,
936
+ height: c,
937
+ fill: a,
938
+ rx: 2,
939
+ "data-series": e.id
940
+ }, `${e.id}-${l}`);
941
+ });
942
+ }),
943
+ !x && m && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
944
+ scale: h,
945
+ orientation: "x",
946
+ length: c,
947
+ tickCount: g,
948
+ transform: `translate(0,${l})`
949
+ }), /* @__PURE__ */ o(z, {
950
+ scale: v,
951
+ orientation: "y",
952
+ length: l,
953
+ tickCount: _
954
+ })] }),
955
+ !x && !m && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
956
+ scale: v,
957
+ orientation: "x",
958
+ length: c,
959
+ tickCount: g,
960
+ transform: `translate(0,${l})`
961
+ }), /* @__PURE__ */ o(z, {
962
+ scale: h,
963
+ orientation: "y",
964
+ length: l,
965
+ tickCount: _
966
+ })] })
967
+ ]
968
+ }) });
969
+ }
970
+ }), E && /* @__PURE__ */ o(H, {
971
+ series: t.map((e, t) => ({
972
+ id: e.id,
973
+ label: e.label,
974
+ color: e.color ?? G[t % G.length]
975
+ })),
976
+ hidden: S
977
+ })]
978
+ });
979
+ }
980
+ //#endregion
981
+ //#region src/charts/pie-chart/pie-chart.tsx
982
+ var K = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
983
+ function ce({ data: t, title: r, description: i, donut: a = !1, width: c, height: l, legend: u, className: d, plain: f }) {
984
+ let p = l ?? (f ? 48 : 300), m = f ? !1 : u ?? !0;
985
+ n();
986
+ let h = e(/* @__PURE__ */ new Set()), g = t.length > 0;
987
+ return /* @__PURE__ */ s("div", {
988
+ style: {
989
+ display: "flex",
990
+ flexDirection: "column",
991
+ gap: "0.5rem"
992
+ },
993
+ children: [/* @__PURE__ */ o(R, {
994
+ title: r,
995
+ description: i,
996
+ width: c,
997
+ height: p,
998
+ fallback: /* @__PURE__ */ s("table", { children: [
999
+ /* @__PURE__ */ o("caption", { children: r }),
1000
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
1001
+ /* @__PURE__ */ o("th", { children: "Label" }),
1002
+ /* @__PURE__ */ o("th", { children: "Value" }),
1003
+ /* @__PURE__ */ o("th", { children: "Percent" })
1004
+ ] }) }),
1005
+ /* @__PURE__ */ o("tbody", { children: t.map((e) => {
1006
+ let n = t.reduce((e, t) => e + t.value, 0), r = n > 0 ? (e.value / n * 100).toFixed(1) : "0";
1007
+ return /* @__PURE__ */ s("tr", { children: [
1008
+ /* @__PURE__ */ o("td", { children: e.label }),
1009
+ /* @__PURE__ */ o("td", { children: e.value }),
1010
+ /* @__PURE__ */ s("td", { children: [r, "%"] })
1011
+ ] }, e.id);
1012
+ }) })
1013
+ ] }),
1014
+ className: d,
1015
+ "data-state": g ? void 0 : "empty",
1016
+ plain: f,
1017
+ tooltip: g ? ({ width: e, height: n }) => {
1018
+ if (!g) return;
1019
+ let r = e / 2, i = n / 2, a = Math.min(r, i) - 8, o = t.filter((e) => !h.value.has(e.id)), s = o.reduce((e, t) => e + t.value, 0), c = 0;
1020
+ return { points: o.map((e, t) => {
1021
+ let n = s > 0 ? e.value / s * 2 * Math.PI : 0, o = c + n, l = (c + o) / 2;
1022
+ return c = o, {
1023
+ id: e.id,
1024
+ cx: r + Math.sin(l) * a * .65,
1025
+ cy: i - Math.cos(l) * a * .65,
1026
+ label: e.label,
1027
+ value: e.value,
1028
+ seriesId: String(t)
1029
+ };
1030
+ }) };
1031
+ } : void 0,
1032
+ children: ({ width: e, height: n }) => {
1033
+ let r = e / 2, i = n / 2, s = Math.min(r, i) - 8, c = a ? s * .6 : 0, l = t.filter((e) => !h.value.has(e.id)), u = l.reduce((e, t) => e + t.value, 0), d = 0;
1034
+ return /* @__PURE__ */ o("g", { children: l.map((e, t) => {
1035
+ let n = u > 0 ? e.value / u * 2 * Math.PI : 0, a = d + n, l = e.color ?? K[t % K.length], f = S(r, i, s, c, d, a);
1036
+ return d = a, /* @__PURE__ */ o("path", {
1037
+ d: f,
1038
+ fill: l,
1039
+ stroke: "var(--cascivo-color-surface)",
1040
+ strokeWidth: 1,
1041
+ "data-series": e.id
1042
+ }, e.id);
1043
+ }) });
1044
+ }
1045
+ }), m && /* @__PURE__ */ o(H, {
1046
+ series: t.map((e, t) => ({
1047
+ id: e.id,
1048
+ label: e.label,
1049
+ color: e.color ?? K[t % K.length]
1050
+ })),
1051
+ hidden: h
1052
+ })]
1053
+ });
1054
+ }
1055
+ //#endregion
1056
+ //#region src/charts/scatter-chart/scatter-chart.tsx
1057
+ var q = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
1058
+ function le({ series: t, title: r, description: i, r: c = 4, width: l, height: d, xTicks: f = 5, yTicks: p = 5, legend: m, tooltip: h, className: g, plain: _ }) {
1059
+ n();
1060
+ let v = e(/* @__PURE__ */ new Set()), y = _ ? F : P, b = d ?? (_ ? 48 : 300), x = _ ? !1 : m ?? t.length > 1, S = t.flatMap((e) => e.data.map((e) => e.x)), C = t.flatMap((e) => e.data.map((e) => e.y)), w = S.length > 0, T = w ? Math.min(...S) : 0, E = w ? Math.max(...S) : 1, D = w ? Math.min(0, ...C) : 0, O = w ? Math.max(...C) : 1;
1061
+ return /* @__PURE__ */ s("div", {
1062
+ style: {
1063
+ display: "flex",
1064
+ flexDirection: "column",
1065
+ gap: "0.5rem"
1066
+ },
1067
+ children: [/* @__PURE__ */ o(R, {
1068
+ title: r,
1069
+ description: i,
1070
+ width: l,
1071
+ height: b,
1072
+ fallback: /* @__PURE__ */ s("table", { children: [
1073
+ /* @__PURE__ */ o("caption", { children: r }),
1074
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
1075
+ /* @__PURE__ */ o("th", { children: "Series" }),
1076
+ /* @__PURE__ */ o("th", { children: "X" }),
1077
+ /* @__PURE__ */ o("th", { children: "Y" })
1078
+ ] }) }),
1079
+ /* @__PURE__ */ o("tbody", { children: t.flatMap((e) => e.data.map((t, n) => /* @__PURE__ */ s("tr", { children: [
1080
+ /* @__PURE__ */ o("td", { children: e.label }),
1081
+ /* @__PURE__ */ o("td", { children: t.x }),
1082
+ /* @__PURE__ */ o("td", { children: t.y })
1083
+ ] }, `${e.id}-${n}`))) })
1084
+ ] }),
1085
+ className: g,
1086
+ "data-state": w ? void 0 : "empty",
1087
+ plain: _,
1088
+ tooltip: h !== !1 && w ? ({ width: e, height: n }) => {
1089
+ if (h === !1 || !w) return;
1090
+ let r = e - y.left - y.right, i = n - y.top - y.bottom, a = u([T, E], [0, r]), o = u([D, O], [i, 0]);
1091
+ return { points: t.flatMap((e) => v.value.has(e.id) ? [] : e.data.map((t, n) => ({
1092
+ id: `${e.id}-${n}`,
1093
+ cx: y.left + a.map(t.x),
1094
+ cy: y.top + o.map(t.y),
1095
+ label: `(${t.x}, ${t.y})`,
1096
+ value: t.y,
1097
+ seriesId: e.id
1098
+ }))) };
1099
+ } : void 0,
1100
+ children: ({ width: e, height: n }) => {
1101
+ let r = e - y.left - y.right, i = n - y.top - y.bottom, l = u([T, E], [0, r]), d = u([D, O], [i, 0]);
1102
+ return /* @__PURE__ */ o("g", { children: /* @__PURE__ */ s("g", {
1103
+ transform: `translate(${y.left},${y.top})`,
1104
+ children: [
1105
+ !_ && /* @__PURE__ */ o(B, {
1106
+ scale: d,
1107
+ orientation: "y",
1108
+ length: r,
1109
+ tickCount: p
1110
+ }),
1111
+ t.map((e, t) => {
1112
+ if (v.value.has(e.id)) return null;
1113
+ let n = e.color ?? q[t % q.length];
1114
+ return /* @__PURE__ */ o("g", {
1115
+ "data-series": e.id,
1116
+ children: e.data.map((e, t) => {
1117
+ let r = typeof c == "function" ? c(e) : e.r ?? c;
1118
+ return /* @__PURE__ */ o("circle", {
1119
+ cx: l.map(e.x),
1120
+ cy: d.map(e.y),
1121
+ r,
1122
+ fill: n,
1123
+ fillOpacity: .7,
1124
+ stroke: n,
1125
+ strokeWidth: 1
1126
+ }, t);
1127
+ })
1128
+ }, e.id);
1129
+ }),
1130
+ !_ && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
1131
+ scale: l,
1132
+ orientation: "x",
1133
+ length: r,
1134
+ tickCount: f,
1135
+ transform: `translate(0,${i})`
1136
+ }), /* @__PURE__ */ o(z, {
1137
+ scale: d,
1138
+ orientation: "y",
1139
+ length: i,
1140
+ tickCount: p
1141
+ })] })
1142
+ ]
1143
+ }) });
1144
+ }
1145
+ }), x && /* @__PURE__ */ o(H, {
1146
+ series: t.map((e, t) => ({
1147
+ id: e.id,
1148
+ label: e.label,
1149
+ color: e.color ?? q[t % q.length]
1150
+ })),
1151
+ hidden: v
1152
+ })]
1153
+ });
1154
+ }
1155
+ //#endregion
1156
+ //#region src/charts/sparkline/sparkline.tsx
1157
+ function J({ data: e, width: t = 120, height: n = 32, label: r, color: i = "var(--cascivo-chart-1)", endDot: c = !0 }) {
1158
+ return /* @__PURE__ */ o(R, {
1159
+ title: r,
1160
+ width: t,
1161
+ height: n,
1162
+ plain: !0,
1163
+ tooltip: e.length > 0 ? (() => {
1164
+ if (e.length === 0) return;
1165
+ let r = u([0, e.length - 1], [2, t - 2]), i = Math.min(...e), a = Math.max(...e), o = u([i === a ? i - 1 : i, a], [n - 2, 2]);
1166
+ return { points: e.map((e, t) => ({
1167
+ id: String(t),
1168
+ cx: r.map(t),
1169
+ cy: o.map(e),
1170
+ label: String(t),
1171
+ value: e
1172
+ })) };
1173
+ })() : void 0,
1174
+ children: () => {
1175
+ if (e.length === 0) return null;
1176
+ let r = u([0, e.length - 1], [2, t - 2]), l = Math.min(...e), d = Math.max(...e), f = u([l === d ? l - 1 : l, d], [n - 2, 2]), p = e.map((e, t) => [r.map(t), f.map(e)]), m = y(p, "monotone"), h = p[p.length - 1];
1177
+ return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("path", {
1178
+ d: m,
1179
+ fill: "none",
1180
+ stroke: i,
1181
+ strokeWidth: 1.5,
1182
+ strokeLinecap: "round",
1183
+ strokeLinejoin: "round"
1184
+ }), c && /* @__PURE__ */ o("circle", {
1185
+ cx: h[0],
1186
+ cy: h[1],
1187
+ r: 2.5,
1188
+ fill: i
1189
+ })] });
1190
+ }
1191
+ });
1192
+ }
1193
+ //#endregion
1194
+ //#region src/charts/meter/meter.tsx
1195
+ function ue(e, t, n, r) {
1196
+ if (!r) return "var(--cascivo-chart-1)";
1197
+ let { warning: i, critical: a } = r;
1198
+ return a != null && e >= a ? "var(--cascivo-color-destructive)" : i != null && e >= i ? "var(--cascivo-color-warning)" : "var(--cascivo-color-success)";
1199
+ }
1200
+ function de({ value: e, min: t = 0, max: n = 100, label: r, variant: i = "bar", thresholds: a, width: c = 200, height: l }) {
1201
+ let u = n > t ? (Math.min(n, Math.max(t, e)) - t) / (n - t) : 0, d = ue(e, t, n, a);
1202
+ if (i === "gauge") {
1203
+ let i = l ?? 100, a = c, f = a / 2, p = i * .9, m = Math.min(f, p) - 4, h = m * .65, g = Math.PI, _ = S(f, p, m, h, g, 2 * Math.PI), v = g + u * Math.PI, y = u > 0 ? S(f, p, m, h, g, v) : "";
1204
+ return /* @__PURE__ */ s("div", {
1205
+ "aria-label": r,
1206
+ role: "meter",
1207
+ "aria-valuenow": e,
1208
+ "aria-valuemin": t,
1209
+ "aria-valuemax": n,
1210
+ children: [/* @__PURE__ */ s("svg", {
1211
+ width: a,
1212
+ height: i,
1213
+ "aria-hidden": "true",
1214
+ children: [/* @__PURE__ */ o("path", {
1215
+ d: _,
1216
+ fill: "var(--cascivo-color-border)"
1217
+ }), y && /* @__PURE__ */ o("path", {
1218
+ d: y,
1219
+ fill: d
1220
+ })]
1221
+ }), /* @__PURE__ */ s("div", {
1222
+ style: {
1223
+ textAlign: "center",
1224
+ fontSize: "var(--cascivo-text-sm)",
1225
+ color: "var(--cascivo-color-foreground-muted)"
1226
+ },
1227
+ children: [
1228
+ r,
1229
+ ": ",
1230
+ e
1231
+ ]
1232
+ })]
1233
+ });
1234
+ }
1235
+ let f = l ?? 12, p = c;
1236
+ return /* @__PURE__ */ s("div", {
1237
+ "aria-label": r,
1238
+ role: "meter",
1239
+ "aria-valuenow": e,
1240
+ "aria-valuemin": t,
1241
+ "aria-valuemax": n,
1242
+ children: [/* @__PURE__ */ s("svg", {
1243
+ width: p,
1244
+ height: f,
1245
+ "aria-hidden": "true",
1246
+ style: { display: "block" },
1247
+ children: [/* @__PURE__ */ o("rect", {
1248
+ x: 0,
1249
+ y: 0,
1250
+ width: p,
1251
+ height: f,
1252
+ rx: f / 2,
1253
+ fill: "var(--cascivo-color-border)"
1254
+ }), /* @__PURE__ */ o("rect", {
1255
+ x: 0,
1256
+ y: 0,
1257
+ width: p,
1258
+ height: f,
1259
+ rx: f / 2,
1260
+ fill: d,
1261
+ style: {
1262
+ transformOrigin: "left center",
1263
+ transform: `scaleX(${u})`,
1264
+ transition: "transform 400ms ease"
1265
+ }
1266
+ })]
1267
+ }), /* @__PURE__ */ o("div", {
1268
+ style: {
1269
+ marginTop: "var(--cascivo-space-1)",
1270
+ fontSize: "var(--cascivo-text-xs)",
1271
+ color: "var(--cascivo-color-foreground-muted)"
1272
+ },
1273
+ children: r
1274
+ })]
1275
+ });
1276
+ }
1277
+ //#endregion
1278
+ //#region src/charts/kpi/kpi.tsx
1279
+ function Y(e) {
1280
+ return `${e >= 0 ? "+" : ""}${e.toLocaleString()}`;
1281
+ }
1282
+ function fe({ value: e, label: t, delta: n, deltaLabel: r, icon: i, sparkline: a, className: c }) {
1283
+ let l = n != null && n >= 0, u = n != null && n < 0;
1284
+ return /* @__PURE__ */ s("div", {
1285
+ className: c,
1286
+ style: {
1287
+ display: "flex",
1288
+ flexDirection: "column",
1289
+ gap: "var(--cascivo-space-2)",
1290
+ padding: "var(--cascivo-space-4)",
1291
+ borderRadius: "var(--cascivo-radius-surface)",
1292
+ border: "1px solid var(--cascivo-color-border)",
1293
+ background: "var(--cascivo-color-surface)"
1294
+ },
1295
+ children: [
1296
+ /* @__PURE__ */ s("div", {
1297
+ style: {
1298
+ display: "flex",
1299
+ alignItems: "center",
1300
+ justifyContent: "space-between"
1301
+ },
1302
+ children: [/* @__PURE__ */ o("span", {
1303
+ style: {
1304
+ fontSize: "var(--cascivo-text-sm)",
1305
+ color: "var(--cascivo-color-foreground-muted)"
1306
+ },
1307
+ children: t
1308
+ }), i && /* @__PURE__ */ o("span", {
1309
+ "aria-hidden": "true",
1310
+ children: i
1311
+ })]
1312
+ }),
1313
+ /* @__PURE__ */ s("div", {
1314
+ style: {
1315
+ display: "flex",
1316
+ alignItems: "flex-end",
1317
+ gap: "var(--cascivo-space-2)"
1318
+ },
1319
+ children: [/* @__PURE__ */ o("span", {
1320
+ style: {
1321
+ fontSize: "var(--cascivo-text-2xl)",
1322
+ fontWeight: 700,
1323
+ lineHeight: 1,
1324
+ color: "var(--cascivo-color-foreground)"
1325
+ },
1326
+ children: typeof e == "number" ? e.toLocaleString() : e
1327
+ }), n != null && /* @__PURE__ */ s("span", {
1328
+ style: {
1329
+ fontSize: "var(--cascivo-text-sm)",
1330
+ fontWeight: 500,
1331
+ color: l ? "var(--cascivo-color-success)" : u ? "var(--cascivo-color-destructive)" : "var(--cascivo-color-foreground-muted)"
1332
+ },
1333
+ "aria-label": `Trend: ${Y(n)}${r ? ` ${r}` : ""}`,
1334
+ children: [
1335
+ l ? "▲" : u ? "▼" : "–",
1336
+ " ",
1337
+ Y(n),
1338
+ r && ` ${r}`
1339
+ ]
1340
+ })]
1341
+ }),
1342
+ a && a.length > 0 && /* @__PURE__ */ o(J, {
1343
+ data: a,
1344
+ label: `${t} trend`,
1345
+ width: 120,
1346
+ height: 32
1347
+ })
1348
+ ]
1349
+ });
1350
+ }
1351
+ //#endregion
1352
+ //#region src/charts/histogram/histogram.tsx
1353
+ function pe({ data: e, bins: t, title: r, label: i, description: c, width: l, height: d, className: f, plain: p }) {
1354
+ n();
1355
+ let m = p ? F : P, h = d ?? (p ? 48 : 300), g = E(e, t), _ = g.reduce((e, t) => Math.max(e, t.count), 0);
1356
+ return /* @__PURE__ */ o(R, {
1357
+ title: r,
1358
+ description: c,
1359
+ width: l,
1360
+ height: h,
1361
+ fallback: /* @__PURE__ */ s("table", { children: [
1362
+ /* @__PURE__ */ o("caption", { children: r }),
1363
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "Range" }), /* @__PURE__ */ o("th", { children: "Count" })] }) }),
1364
+ /* @__PURE__ */ o("tbody", { children: g.map((e, t) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ s("td", { children: [
1365
+ e.x0.toFixed(2),
1366
+ " – ",
1367
+ e.x1.toFixed(2)
1368
+ ] }), /* @__PURE__ */ o("td", { children: e.count })] }, t)) })
1369
+ ] }),
1370
+ className: f,
1371
+ plain: p,
1372
+ tooltip: g.length > 0 ? ({ width: e, height: t }) => {
1373
+ if (g.length === 0) return;
1374
+ let n = e - m.left - m.right, r = t - m.top - m.bottom, i = u([g[0]?.x0 ?? 0, g[g.length - 1]?.x1 ?? 1], [0, n]), a = u([0, _ || 1], [r, 0]);
1375
+ return { points: g.map((e, t) => {
1376
+ let n = i.map(e.x0), r = Math.max(0, i.map(e.x1) - n - 1);
1377
+ return {
1378
+ id: `bin-${t}`,
1379
+ cx: m.left + n + r / 2,
1380
+ cy: m.top + a.map(e.count),
1381
+ label: `${e.x0.toFixed(2)}–${e.x1.toFixed(2)}`,
1382
+ value: e.count
1383
+ };
1384
+ }) };
1385
+ } : void 0,
1386
+ children: ({ width: e, height: t }) => {
1387
+ let n = {
1388
+ width: e - m.left - m.right,
1389
+ height: t - m.top - m.bottom
1390
+ };
1391
+ if (n.width <= 0 || g.length === 0) return null;
1392
+ let r = u([g[0]?.x0 ?? 0, g[g.length - 1]?.x1 ?? 1], [0, n.width]), i = u([0, _ || 1], [n.height, 0]);
1393
+ return /* @__PURE__ */ s("g", {
1394
+ transform: `translate(${m.left},${m.top})`,
1395
+ children: [
1396
+ !p && /* @__PURE__ */ o(B, {
1397
+ scale: i,
1398
+ orientation: "y",
1399
+ length: n.width
1400
+ }),
1401
+ g.map((e, t) => {
1402
+ let a = r.map(e.x0), s = Math.max(0, r.map(e.x1) - a - 1), c = i.map(e.count), l = n.height - c;
1403
+ return /* @__PURE__ */ o("rect", {
1404
+ x: a,
1405
+ y: c,
1406
+ width: s,
1407
+ height: Math.max(0, l),
1408
+ fill: "var(--cascivo-chart-1)",
1409
+ opacity: .85,
1410
+ "aria-label": `${e.x0.toFixed(1)}–${e.x1.toFixed(1)}: ${e.count}`
1411
+ }, t);
1412
+ }),
1413
+ !p && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
1414
+ scale: r,
1415
+ orientation: "x",
1416
+ length: n.width,
1417
+ transform: `translate(0,${n.height})`
1418
+ }), /* @__PURE__ */ o(z, {
1419
+ scale: i,
1420
+ orientation: "y",
1421
+ length: n.height
1422
+ })] })
1423
+ ]
1424
+ });
1425
+ }
1426
+ });
1427
+ }
1428
+ //#endregion
1429
+ //#region src/charts/boxplot/boxplot.tsx
1430
+ var X = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
1431
+ function me({ series: e, title: t, description: r, width: i, height: c, className: l, plain: d }) {
1432
+ n();
1433
+ let p = d ? F : P, m = c ?? (d ? 48 : 320), h = e.map((e) => ({
1434
+ ...e,
1435
+ stats: D(e.values)
1436
+ })), g = e.flatMap((e) => e.values), [_, v] = g.length > 0 ? O(g) : [0, 1];
1437
+ return /* @__PURE__ */ o(R, {
1438
+ title: t,
1439
+ description: r,
1440
+ width: i,
1441
+ height: m,
1442
+ fallback: /* @__PURE__ */ s("table", { children: [
1443
+ /* @__PURE__ */ o("caption", { children: t }),
1444
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
1445
+ /* @__PURE__ */ o("th", { children: "Series" }),
1446
+ /* @__PURE__ */ o("th", { children: "Min" }),
1447
+ /* @__PURE__ */ o("th", { children: "Q1" }),
1448
+ /* @__PURE__ */ o("th", { children: "Median" }),
1449
+ /* @__PURE__ */ o("th", { children: "Q3" }),
1450
+ /* @__PURE__ */ o("th", { children: "Max" })
1451
+ ] }) }),
1452
+ /* @__PURE__ */ o("tbody", { children: h.map((e) => /* @__PURE__ */ s("tr", { children: [
1453
+ /* @__PURE__ */ o("td", { children: e.label }),
1454
+ /* @__PURE__ */ o("td", { children: e.stats.min.toFixed(2) }),
1455
+ /* @__PURE__ */ o("td", { children: e.stats.q1.toFixed(2) }),
1456
+ /* @__PURE__ */ o("td", { children: e.stats.median.toFixed(2) }),
1457
+ /* @__PURE__ */ o("td", { children: e.stats.q3.toFixed(2) }),
1458
+ /* @__PURE__ */ o("td", { children: e.stats.max.toFixed(2) })
1459
+ ] }, e.id)) })
1460
+ ] }),
1461
+ className: l,
1462
+ plain: d,
1463
+ tooltip: h.length > 0 ? ({ width: e, height: t }) => {
1464
+ if (h.length === 0) return;
1465
+ let n = e - p.left - p.right, r = t - p.top - p.bottom;
1466
+ if (n <= 0) return;
1467
+ let i = f(h.map((e) => e.id), [0, n], .3), a = (v - _) * .05 || 1, o = u([_ - a, v + a], [r, 0]);
1468
+ return {
1469
+ points: h.map((e) => {
1470
+ let t = (i.map(e.id) ?? 0) + i.bandwidth / 2;
1471
+ return {
1472
+ id: e.id,
1473
+ cx: p.left + t,
1474
+ cy: p.top + o.map(e.stats.median),
1475
+ label: e.label,
1476
+ value: e.stats.median
1477
+ };
1478
+ }),
1479
+ format: (e) => {
1480
+ let t = h.find((t) => t.id === e.id);
1481
+ return t ? `${t.label}: min ${t.stats.min.toFixed(2)} / Q1 ${t.stats.q1.toFixed(2)} / med ${t.stats.median.toFixed(2)} / Q3 ${t.stats.q3.toFixed(2)} / max ${t.stats.max.toFixed(2)}` : `${e.label}: ${e.value}`;
1482
+ }
1483
+ };
1484
+ } : void 0,
1485
+ children: ({ width: e, height: t }) => {
1486
+ let n = {
1487
+ width: e - p.left - p.right,
1488
+ height: t - p.top - p.bottom
1489
+ };
1490
+ if (n.width <= 0 || h.length === 0) return null;
1491
+ let r = f(h.map((e) => e.id), [0, n.width], .3), i = (v - _) * .05 || 1, c = u([_ - i, v + i], [n.height, 0]);
1492
+ return /* @__PURE__ */ s("g", {
1493
+ transform: `translate(${p.left},${p.top})`,
1494
+ children: [h.map((e, t) => {
1495
+ let n = X[t % X.length] ?? "var(--cascivo-chart-1)", i = (r.map(e.id) ?? 0) + r.bandwidth / 2, a = r.bandwidth * .6, l = i - a / 2, u = c.map(e.stats.q1), d = c.map(e.stats.q3), f = c.map(e.stats.median), p = c.map(e.stats.min), m = c.map(e.stats.max);
1496
+ return /* @__PURE__ */ s("g", {
1497
+ "aria-label": `${e.label}: median ${e.stats.median.toFixed(2)}`,
1498
+ children: [
1499
+ /* @__PURE__ */ o("line", {
1500
+ x1: i,
1501
+ y1: d,
1502
+ x2: i,
1503
+ y2: m,
1504
+ stroke: n,
1505
+ strokeWidth: 1.5
1506
+ }),
1507
+ /* @__PURE__ */ o("line", {
1508
+ x1: i,
1509
+ y1: u,
1510
+ x2: i,
1511
+ y2: p,
1512
+ stroke: n,
1513
+ strokeWidth: 1.5
1514
+ }),
1515
+ /* @__PURE__ */ o("line", {
1516
+ x1: i - a / 4,
1517
+ y1: m,
1518
+ x2: i + a / 4,
1519
+ y2: m,
1520
+ stroke: n,
1521
+ strokeWidth: 1.5
1522
+ }),
1523
+ /* @__PURE__ */ o("line", {
1524
+ x1: i - a / 4,
1525
+ y1: p,
1526
+ x2: i + a / 4,
1527
+ y2: p,
1528
+ stroke: n,
1529
+ strokeWidth: 1.5
1530
+ }),
1531
+ /* @__PURE__ */ o("rect", {
1532
+ x: l,
1533
+ y: d,
1534
+ width: a,
1535
+ height: Math.max(0, u - d),
1536
+ fill: n,
1537
+ fillOpacity: .25,
1538
+ stroke: n,
1539
+ strokeWidth: 1.5
1540
+ }),
1541
+ /* @__PURE__ */ o("line", {
1542
+ x1: l,
1543
+ y1: f,
1544
+ x2: l + a,
1545
+ y2: f,
1546
+ stroke: n,
1547
+ strokeWidth: 2.5
1548
+ }),
1549
+ e.stats.outliers.map((e, t) => /* @__PURE__ */ o("circle", {
1550
+ cx: i,
1551
+ cy: c.map(e),
1552
+ r: 3,
1553
+ fill: "none",
1554
+ stroke: n,
1555
+ strokeWidth: 1.5,
1556
+ "aria-label": `Outlier: ${e.toFixed(2)}`
1557
+ }, t))
1558
+ ]
1559
+ }, e.id);
1560
+ }), !d && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
1561
+ scale: r,
1562
+ orientation: "x",
1563
+ length: n.width,
1564
+ transform: `translate(0,${n.height})`
1565
+ }), /* @__PURE__ */ o(z, {
1566
+ scale: c,
1567
+ orientation: "y",
1568
+ length: n.height
1569
+ })] })]
1570
+ });
1571
+ }
1572
+ });
1573
+ }
1574
+ //#endregion
1575
+ //#region src/charts/bubble-chart/bubble-chart.tsx
1576
+ var Z = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), he = 3, ge = 24;
1577
+ function _e({ series: t, title: r, description: i, width: c, height: l, tooltip: d, className: f, plain: m }) {
1578
+ n();
1579
+ let h = e(null), g = m ? F : P, _ = l ?? (m ? 48 : 320), v = t.flatMap((e) => e.data), [y, b] = v.length > 0 ? O(v.map((e) => e.x)) : [0, 1], [x, S] = v.length > 0 ? O(v.map((e) => e.y)) : [0, 1], [C, w] = v.length > 0 ? O(v.map((e) => e.size)) : [0, 1], T = p([C, w], [he, ge]), E = v.length > 0;
1580
+ return /* @__PURE__ */ o(R, {
1581
+ title: r,
1582
+ description: i,
1583
+ width: c,
1584
+ height: _,
1585
+ fallback: /* @__PURE__ */ s("table", { children: [
1586
+ /* @__PURE__ */ o("caption", { children: r }),
1587
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
1588
+ /* @__PURE__ */ o("th", { children: "Series" }),
1589
+ /* @__PURE__ */ o("th", { children: "X" }),
1590
+ /* @__PURE__ */ o("th", { children: "Y" }),
1591
+ /* @__PURE__ */ o("th", { children: "Size" })
1592
+ ] }) }),
1593
+ /* @__PURE__ */ o("tbody", { children: t.flatMap((e) => e.data.map((t, n) => /* @__PURE__ */ s("tr", { children: [
1594
+ /* @__PURE__ */ o("td", { children: e.name }),
1595
+ /* @__PURE__ */ o("td", { children: t.x }),
1596
+ /* @__PURE__ */ o("td", { children: t.y }),
1597
+ /* @__PURE__ */ o("td", { children: t.size })
1598
+ ] }, `${e.name}-${n}`))) })
1599
+ ] }),
1600
+ className: f,
1601
+ plain: m,
1602
+ tooltip: d !== !1 && E ? ({ width: e, height: n }) => {
1603
+ if (d === !1 || !E) return;
1604
+ let r = {
1605
+ width: e - g.left - g.right,
1606
+ height: n - g.top - g.bottom
1607
+ };
1608
+ if (r.width <= 0) return;
1609
+ let i = (b - y) * .05 || 1, a = (S - x) * .05 || 1, o = u([y - i, b + i], [0, r.width]), s = u([x - a, S + a], [r.height, 0]);
1610
+ return { points: t.flatMap((e, t) => e.data.map((n, r) => ({
1611
+ id: `${t}-${r}`,
1612
+ cx: g.left + o.map(n.x),
1613
+ cy: g.top + s.map(n.y),
1614
+ label: `${e.name} (${n.x}, ${n.y})`,
1615
+ value: n.y,
1616
+ seriesId: e.name
1617
+ }))) };
1618
+ } : void 0,
1619
+ children: ({ width: e, height: n }) => {
1620
+ let r = {
1621
+ width: e - g.left - g.right,
1622
+ height: n - g.top - g.bottom
1623
+ };
1624
+ if (r.width <= 0 || v.length === 0) return null;
1625
+ let i = (b - y) * .05 || 1, c = (S - x) * .05 || 1, l = u([y - i, b + i], [0, r.width]), d = u([x - c, S + c], [r.height, 0]);
1626
+ return /* @__PURE__ */ s("g", {
1627
+ transform: `translate(${g.left},${g.top})`,
1628
+ children: [
1629
+ !m && /* @__PURE__ */ o(B, {
1630
+ scale: d,
1631
+ orientation: "y",
1632
+ length: r.width
1633
+ }),
1634
+ t.map((e, t) => {
1635
+ let n = Z[t % Z.length] ?? "var(--cascivo-chart-1)";
1636
+ return /* @__PURE__ */ o("g", {
1637
+ opacity: h.value !== null && h.value !== e.name ? .2 : 1,
1638
+ onMouseEnter: () => {
1639
+ h.value = e.name;
1640
+ },
1641
+ onMouseLeave: () => {
1642
+ h.value = null;
1643
+ },
1644
+ children: e.data.map((t, r) => /* @__PURE__ */ o("circle", {
1645
+ cx: l.map(t.x),
1646
+ cy: d.map(t.y),
1647
+ r: T(t.size),
1648
+ fill: n,
1649
+ fillOpacity: .6,
1650
+ stroke: n,
1651
+ strokeWidth: 1,
1652
+ "aria-label": `${e.name}: x=${t.x}, y=${t.y}, size=${t.size}`
1653
+ }, r))
1654
+ }, e.name);
1655
+ }),
1656
+ !m && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
1657
+ scale: l,
1658
+ orientation: "x",
1659
+ length: r.width,
1660
+ transform: `translate(0,${r.height})`
1661
+ }), /* @__PURE__ */ o(z, {
1662
+ scale: d,
1663
+ orientation: "y",
1664
+ length: r.height
1665
+ })] })
1666
+ ]
1667
+ });
1668
+ }
1669
+ });
1670
+ }
1671
+ //#endregion
1672
+ //#region src/charts/combo-chart/combo-chart.tsx
1673
+ function ve({ bars: e, line: t, title: r, description: i, secondAxis: c = !1, width: l, height: d, tooltip: p, className: m, plain: h }) {
1674
+ n();
1675
+ let g = d ?? (h ? 48 : 320), _ = h ? F : {
1676
+ ...P,
1677
+ right: c ? 60 : P.right
1678
+ }, v = e.reduce((e, t) => Math.max(e, t.value), 0) || 1, b = t.length > 0 ? Math.min(...t.map((e) => e.y)) : 0, x = t.length > 0 ? Math.max(...t.map((e) => e.y)) : 1, S = e.length > 0;
1679
+ return /* @__PURE__ */ o(R, {
1680
+ title: r,
1681
+ description: i,
1682
+ width: l,
1683
+ height: g,
1684
+ fallback: /* @__PURE__ */ s("table", { children: [
1685
+ /* @__PURE__ */ o("caption", { children: r }),
1686
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "Label" }), /* @__PURE__ */ o("th", { children: "Bar value" })] }) }),
1687
+ /* @__PURE__ */ o("tbody", { children: e.map((e) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: e.label }), /* @__PURE__ */ o("td", { children: e.value })] }, e.label)) })
1688
+ ] }),
1689
+ className: m,
1690
+ plain: h,
1691
+ tooltip: p !== !1 && S ? ({ width: n, height: r }) => {
1692
+ if (p === !1 || !S) return;
1693
+ let i = {
1694
+ width: n - _.left - _.right,
1695
+ height: r - _.top - _.bottom
1696
+ };
1697
+ if (i.width <= 0) return;
1698
+ let a = f(e.map((e) => e.label), [0, i.width], .2), o = u([0, v], [i.height, 0]), s = c ? u([b, x || b + 1], [i.height, 0]) : o, l = e.map((e, t) => ({
1699
+ id: `bar-${t}`,
1700
+ cx: _.left + (a.map(e.label) ?? 0) + a.bandwidth / 2,
1701
+ cy: _.top + o.map(e.value),
1702
+ label: e.label,
1703
+ value: e.value,
1704
+ seriesId: "bars"
1705
+ })), d = t.map((n, r) => {
1706
+ let o = e[r] ? (a.map(e[r].label) ?? 0) + a.bandwidth / 2 : i.width * n.x / Math.max(1, t.length - 1);
1707
+ return {
1708
+ id: `line-${r}`,
1709
+ cx: _.left + o,
1710
+ cy: _.top + s.map(n.y),
1711
+ label: e[r]?.label ?? String(n.x),
1712
+ value: n.y,
1713
+ seriesId: "line"
1714
+ };
1715
+ });
1716
+ return { points: [...l, ...d] };
1717
+ } : void 0,
1718
+ children: ({ width: n, height: r }) => {
1719
+ let i = {
1720
+ width: n - _.left - _.right,
1721
+ height: r - _.top - _.bottom
1722
+ };
1723
+ if (i.width <= 0 || e.length === 0) return null;
1724
+ let l = f(e.map((e) => e.label), [0, i.width], .2), d = u([0, v], [i.height, 0]), p = c ? u([b, x || b + 1], [i.height, 0]) : d, m = t.map((n, r) => [e[r] ? (l.map(e[r].label) ?? 0) + l.bandwidth / 2 : i.width * n.x / Math.max(1, t.length - 1), p.map(n.y)]), g = m.length > 1 ? y(m, "monotone") : "";
1725
+ return /* @__PURE__ */ s("g", {
1726
+ transform: `translate(${_.left},${_.top})`,
1727
+ children: [
1728
+ !h && /* @__PURE__ */ o(B, {
1729
+ scale: d,
1730
+ orientation: "y",
1731
+ length: i.width
1732
+ }),
1733
+ e.map((e) => {
1734
+ let t = l.map(e.label) ?? 0, n = d.map(e.value);
1735
+ return /* @__PURE__ */ o("rect", {
1736
+ x: t,
1737
+ y: n,
1738
+ width: l.bandwidth,
1739
+ height: Math.max(0, i.height - n),
1740
+ fill: "var(--cascivo-chart-1)",
1741
+ opacity: .75,
1742
+ "aria-label": `${e.label}: ${e.value}`
1743
+ }, e.label);
1744
+ }),
1745
+ g && /* @__PURE__ */ o("path", {
1746
+ d: g,
1747
+ fill: "none",
1748
+ stroke: "var(--cascivo-chart-2)",
1749
+ strokeWidth: 2.5,
1750
+ strokeLinejoin: "round",
1751
+ strokeLinecap: "round"
1752
+ }),
1753
+ !h && /* @__PURE__ */ s(a, { children: [
1754
+ /* @__PURE__ */ o(z, {
1755
+ scale: l,
1756
+ orientation: "x",
1757
+ length: i.width,
1758
+ transform: `translate(0,${i.height})`
1759
+ }),
1760
+ /* @__PURE__ */ o(z, {
1761
+ scale: d,
1762
+ orientation: "y",
1763
+ length: i.height
1764
+ }),
1765
+ c && /* @__PURE__ */ o(z, {
1766
+ scale: p,
1767
+ orientation: "y",
1768
+ length: i.height,
1769
+ transform: `translate(${i.width},0)`
1770
+ })
1771
+ ] })
1772
+ ]
1773
+ });
1774
+ }
1775
+ });
1776
+ }
1777
+ //#endregion
1778
+ //#region src/charts/heatmap/heatmap.tsx
1779
+ function ye({ data: e, title: t, description: r, width: i, height: c, className: l, plain: u }) {
1780
+ n();
1781
+ let d = c ?? (u ? 48 : 320), p = u ? F : {
1782
+ top: 20,
1783
+ right: 20,
1784
+ bottom: 60,
1785
+ left: 60
1786
+ }, m = [...new Set(e.map((e) => e.x))], h = [...new Set(e.map((e) => e.y))], [g, _] = e.length > 0 ? O(e.map((e) => e.value)) : [0, 1], v = _ - g || 1, y = (e) => Math.max(0, Math.min(1, (e - g) / v));
1787
+ return /* @__PURE__ */ o(R, {
1788
+ title: t,
1789
+ description: r,
1790
+ width: i,
1791
+ height: d,
1792
+ fallback: /* @__PURE__ */ s("table", { children: [
1793
+ /* @__PURE__ */ o("caption", { children: t }),
1794
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [
1795
+ /* @__PURE__ */ o("th", { children: "X" }),
1796
+ /* @__PURE__ */ o("th", { children: "Y" }),
1797
+ /* @__PURE__ */ o("th", { children: "Value" })
1798
+ ] }) }),
1799
+ /* @__PURE__ */ o("tbody", { children: e.map((e, t) => /* @__PURE__ */ s("tr", { children: [
1800
+ /* @__PURE__ */ o("td", { children: e.x }),
1801
+ /* @__PURE__ */ o("td", { children: e.y }),
1802
+ /* @__PURE__ */ o("td", { children: e.value })
1803
+ ] }, t)) })
1804
+ ] }),
1805
+ className: l,
1806
+ plain: u,
1807
+ tooltip: e.length > 0 ? ({ width: t, height: n }) => {
1808
+ if (e.length === 0) return;
1809
+ let r = t - p.left - p.right, i = n - p.top - p.bottom;
1810
+ if (r <= 0) return;
1811
+ let a = f(m, [0, r], .05), o = f(h, [0, i], .05);
1812
+ return { points: e.map((e, t) => {
1813
+ let n = a.map(e.x) ?? 0, r = o.map(e.y) ?? 0;
1814
+ return {
1815
+ id: `cell-${t}`,
1816
+ cx: p.left + n + a.bandwidth / 2,
1817
+ cy: p.top + r + o.bandwidth / 2,
1818
+ label: `${e.x}×${e.y}`,
1819
+ value: e.value
1820
+ };
1821
+ }) };
1822
+ } : void 0,
1823
+ children: ({ width: t, height: n }) => {
1824
+ let r = {
1825
+ width: t - p.left - p.right,
1826
+ height: n - p.top - p.bottom
1827
+ };
1828
+ if (r.width <= 0 || e.length === 0) return null;
1829
+ let i = f(m, [0, r.width], .05), c = f(h, [0, r.height], .05);
1830
+ return /* @__PURE__ */ s("g", {
1831
+ transform: `translate(${p.left},${p.top})`,
1832
+ children: [e.map((e, t) => {
1833
+ let n = i.map(e.x) ?? 0, r = c.map(e.y) ?? 0, a = Math.round(y(e.value) * 100);
1834
+ return /* @__PURE__ */ o("rect", {
1835
+ x: n,
1836
+ y: r,
1837
+ width: i.bandwidth,
1838
+ height: c.bandwidth,
1839
+ fill: `color-mix(in oklab, var(--cascivo-chart-1) ${a}%, var(--cascivo-color-neutral-100))`,
1840
+ stroke: "var(--cascivo-surface-base)",
1841
+ strokeWidth: 1,
1842
+ "aria-label": `${e.x}, ${e.y}: ${e.value}`
1843
+ }, t);
1844
+ }), !u && /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(z, {
1845
+ scale: i,
1846
+ orientation: "x",
1847
+ length: r.width,
1848
+ transform: `translate(0,${r.height})`
1849
+ }), /* @__PURE__ */ o(z, {
1850
+ scale: c,
1851
+ orientation: "y",
1852
+ length: r.height
1853
+ })] })]
1854
+ });
1855
+ }
1856
+ });
1857
+ }
1858
+ //#endregion
1859
+ //#region src/charts/treemap/treemap.tsx
1860
+ var Q = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`);
1861
+ function be({ data: e, title: t, description: i, width: c, height: l, className: u, plain: d }) {
1862
+ n();
1863
+ let f = r();
1864
+ return /* @__PURE__ */ o(R, {
1865
+ title: t,
1866
+ description: i,
1867
+ width: c,
1868
+ height: l ?? (d ? 48 : 320),
1869
+ fallback: /* @__PURE__ */ s("table", { children: [
1870
+ /* @__PURE__ */ o("caption", { children: t }),
1871
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "Label" }), /* @__PURE__ */ o("th", { children: "Value" })] }) }),
1872
+ /* @__PURE__ */ o("tbody", { children: e.map((e) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: e.label }), /* @__PURE__ */ o("td", { children: e.value })] }, e.id)) })
1873
+ ] }),
1874
+ className: u,
1875
+ plain: d,
1876
+ tooltip: e.length > 0 ? ({ width: t, height: n }) => {
1877
+ if (e.length !== 0) return { points: M(e.map((e) => ({
1878
+ id: e.id,
1879
+ value: e.value
1880
+ })), t, n).map((t) => {
1881
+ let n = e.find((e) => e.id === t.id);
1882
+ return {
1883
+ id: t.id,
1884
+ cx: t.x + t.w / 2,
1885
+ cy: t.y + t.h / 2,
1886
+ label: n?.label ?? t.id,
1887
+ value: n?.value ?? 0
1888
+ };
1889
+ }) };
1890
+ } : void 0,
1891
+ children: ({ width: t, height: n }) => {
1892
+ if (e.length === 0) return null;
1893
+ let r = M(e.map((e) => ({
1894
+ id: e.id,
1895
+ value: e.value
1896
+ })), t, n), i = new Map(e.map((e) => [e.id, e.label]));
1897
+ return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("defs", { children: r.map((e) => /* @__PURE__ */ o("clipPath", {
1898
+ id: `${f}-${e.id}`,
1899
+ children: /* @__PURE__ */ o("rect", {
1900
+ x: e.x + 2,
1901
+ y: e.y + 2,
1902
+ width: Math.max(0, e.w - 4),
1903
+ height: Math.max(0, e.h - 4)
1904
+ })
1905
+ }, e.id)) }), r.map((t, n) => {
1906
+ let r = Q[n % Q.length] ?? "var(--cascivo-chart-1)", a = i.get(t.id) ?? t.id;
1907
+ return /* @__PURE__ */ s("g", {
1908
+ "aria-label": `${a}: ${e.find((e) => e.id === t.id)?.value}`,
1909
+ children: [/* @__PURE__ */ o("rect", {
1910
+ x: t.x,
1911
+ y: t.y,
1912
+ width: Math.max(0, t.w - 1),
1913
+ height: Math.max(0, t.h - 1),
1914
+ fill: r,
1915
+ fillOpacity: .8,
1916
+ stroke: "var(--cascivo-surface-base)",
1917
+ strokeWidth: 1
1918
+ }), !d && t.w > 30 && t.h > 18 && /* @__PURE__ */ o("text", {
1919
+ x: t.x + 4,
1920
+ y: t.y + 14,
1921
+ fontSize: Math.min(12, t.w / 5),
1922
+ fill: "currentColor",
1923
+ clipPath: `url(#${f}-${t.id})`,
1924
+ children: a
1925
+ })]
1926
+ }, t.id);
1927
+ })] });
1928
+ }
1929
+ });
1930
+ }
1931
+ //#endregion
1932
+ //#region src/charts/radar/radar.tsx
1933
+ var xe = Array.from({ length: 8 }, (e, t) => `var(--cascivo-chart-${t + 1})`), $ = 4;
1934
+ function Se(e, t, n, r, i) {
1935
+ let a = e.length;
1936
+ return e.map((e, o) => {
1937
+ let s = o / a * 2 * Math.PI - Math.PI / 2, c = e / t * i;
1938
+ return {
1939
+ x: n + Math.cos(s) * c,
1940
+ y: r + Math.sin(s) * c
1941
+ };
1942
+ });
1943
+ }
1944
+ function Ce({ axes: e, series: t, max: r, title: i, description: c, width: l, height: u, className: d, plain: f }) {
1945
+ let p = u ?? (f ? 48 : 320);
1946
+ n();
1947
+ let m = r ?? Math.max(1, ...t.flatMap((e) => e.values)), h = e.length;
1948
+ return /* @__PURE__ */ o(R, {
1949
+ title: i,
1950
+ description: c,
1951
+ width: l,
1952
+ height: p,
1953
+ fallback: /* @__PURE__ */ s("table", { children: [
1954
+ /* @__PURE__ */ o("caption", { children: i }),
1955
+ /* @__PURE__ */ o("thead", { children: /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("th", { children: "Series" }), e.map((e) => /* @__PURE__ */ o("th", { children: e }, e))] }) }),
1956
+ /* @__PURE__ */ o("tbody", { children: t.map((e) => /* @__PURE__ */ s("tr", { children: [/* @__PURE__ */ o("td", { children: e.label }), e.values.map((e, t) => /* @__PURE__ */ o("td", { children: e }, t))] }, e.id)) })
1957
+ ] }),
1958
+ className: d,
1959
+ plain: f,
1960
+ tooltip: t.length > 0 ? ({ width: n, height: r }) => {
1961
+ if (t.length === 0 || h === 0) return;
1962
+ let i = n / 2, a = r / 2, o = Math.min(i, a) * .72;
1963
+ return { points: t.flatMap((t) => t.values.map((n, r) => {
1964
+ let s = r / h * 2 * Math.PI - Math.PI / 2, c = n / m * o;
1965
+ return {
1966
+ id: `${t.id}-${r}`,
1967
+ cx: i + Math.cos(s) * c,
1968
+ cy: a + Math.sin(s) * c,
1969
+ label: e[r] ?? String(r),
1970
+ value: n,
1971
+ seriesId: t.id
1972
+ };
1973
+ })) };
1974
+ } : void 0,
1975
+ children: ({ width: n, height: r }) => {
1976
+ let i = n / 2, c = r / 2, l = Math.min(i, c) * .72, u = Array.from({ length: $ }, (e, t) => (t + 1) / $ * l), d = Array.from({ length: h }, (e, t) => {
1977
+ let n = t / h * 2 * Math.PI - Math.PI / 2;
1978
+ return {
1979
+ x: i + Math.cos(n) * l,
1980
+ y: c + Math.sin(n) * l
1981
+ };
1982
+ }), p = u.map((e) => Array.from({ length: h }, (t, n) => {
1983
+ let r = n / h * 2 * Math.PI - Math.PI / 2;
1984
+ return `${i + Math.cos(r) * e},${c + Math.sin(r) * e}`;
1985
+ }).join(" "));
1986
+ return /* @__PURE__ */ s(a, { children: [
1987
+ !f && p.map((e, t) => /* @__PURE__ */ o("polygon", {
1988
+ points: e,
1989
+ fill: "none",
1990
+ stroke: "var(--cascivo-border-subtle)",
1991
+ strokeWidth: 1
1992
+ }, t)),
1993
+ !f && d.map((e, t) => /* @__PURE__ */ o("line", {
1994
+ x1: i,
1995
+ y1: c,
1996
+ x2: e.x,
1997
+ y2: e.y,
1998
+ stroke: "var(--cascivo-border-subtle)",
1999
+ strokeWidth: 1
2000
+ }, t)),
2001
+ !f && d.map((t, n) => {
2002
+ let r = n / h * 2 * Math.PI - Math.PI / 2;
2003
+ return /* @__PURE__ */ o("text", {
2004
+ x: i + Math.cos(r) * (l + 18),
2005
+ y: c + Math.sin(r) * (l + 18),
2006
+ fontSize: 11,
2007
+ textAnchor: "middle",
2008
+ dominantBaseline: "middle",
2009
+ fill: "var(--cascivo-text-secondary)",
2010
+ children: e[n]
2011
+ }, n);
2012
+ }),
2013
+ t.map((e, t) => {
2014
+ let n = Se(e.values, m, i, c, l).map((e) => `${e.x},${e.y}`).join(" "), r = xe[t % xe.length] ?? "var(--cascivo-chart-1)";
2015
+ return /* @__PURE__ */ o("polygon", {
2016
+ points: n,
2017
+ fill: r,
2018
+ fillOpacity: .15,
2019
+ stroke: r,
2020
+ strokeWidth: 2,
2021
+ "aria-label": `${e.label}: ${e.values.join(", ")}`
2022
+ }, e.id);
2023
+ })
2024
+ ] });
2025
+ }
2026
+ });
2027
+ }
2028
+ //#endregion
2029
+ //#region src/charts/bullet/bullet.tsx
2030
+ var we = [
2031
+ "var(--cascivo-color-neutral-200)",
2032
+ "var(--cascivo-color-neutral-300)",
2033
+ "var(--cascivo-color-neutral-400)"
2034
+ ];
2035
+ function Te({ value: e, target: t, ranges: r, label: i, min: c = 0, max: l, width: d = 300, height: f = 40, className: p }) {
2036
+ n();
2037
+ let m = [...r].sort((e, t) => e - t), h = u([c, l ?? m[m.length - 1] ?? (Math.max(e, t) * 1.2 || 1)], [0, d]), g = f * .35, _ = (f - g) / 2, v = f * .7, y = (f - v) / 2;
2038
+ return /* @__PURE__ */ s("figure", {
2039
+ className: p,
2040
+ "aria-label": `${i}: value ${e}, target ${t}`,
2041
+ style: { margin: 0 },
2042
+ children: [/* @__PURE__ */ o(R, {
2043
+ title: `${i} bullet chart`,
2044
+ width: d,
2045
+ height: f,
2046
+ plain: !0,
2047
+ tooltip: { points: [{
2048
+ id: "measure",
2049
+ cx: h.map(e),
2050
+ cy: f / 2,
2051
+ label: i,
2052
+ value: e
2053
+ }] },
2054
+ children: () => /* @__PURE__ */ s(a, { children: [
2055
+ m.map((e, t) => {
2056
+ let n = t === 0 ? c : m[t - 1] ?? c, r = h.map(e) - h.map(n);
2057
+ return /* @__PURE__ */ o("rect", {
2058
+ x: h.map(n),
2059
+ y: 0,
2060
+ width: Math.max(0, r),
2061
+ height: f,
2062
+ fill: we[t % we.length] ?? "var(--cascivo-color-neutral-200)"
2063
+ }, t);
2064
+ }),
2065
+ /* @__PURE__ */ o("rect", {
2066
+ x: h.map(c),
2067
+ y: _,
2068
+ width: Math.max(0, h.map(e) - h.map(c)),
2069
+ height: g,
2070
+ fill: "var(--cascivo-chart-1)",
2071
+ "aria-label": `Value: ${e}`
2072
+ }),
2073
+ /* @__PURE__ */ o("line", {
2074
+ x1: h.map(t),
2075
+ y1: y,
2076
+ x2: h.map(t),
2077
+ y2: y + v,
2078
+ stroke: "var(--cascivo-text-primary)",
2079
+ strokeWidth: 2.5,
2080
+ "aria-label": `Target: ${t}`
2081
+ })
2082
+ ] })
2083
+ }), /* @__PURE__ */ o("figcaption", {
2084
+ style: { fontSize: 12 },
2085
+ children: i
2086
+ })]
2087
+ });
2088
+ }
2089
+ //#endregion
2090
+ export { oe as AreaChart, z as Axis, se as BarChart, me as Boxplot, _e as BubbleChart, Te as Bullet, R as ChartFrame, ve as ComboChart, P as DEFAULT_MARGINS, B as GridLines, ye as Heatmap, pe as Histogram, fe as Kpi, H as Legend, ae as LineChart, de as Meter, F as PLAIN_MARGINS, ce as PieChart, Ce as Radar, le as ScatterChart, J as Sparkline, be as Treemap, S as arcPath, x as areaPath, f as bandScale, E as binValues, D as boxStats, O as extent, y as linePath, u as linearScale, m as logScale, w as nearestIndex, d as niceTicks, p as sqrtScale, M as squarify, C as stackSeries, v as timeScale, N as useChartSize };