@photon-ai/pho-ui 4.9.0 → 4.10.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.
@@ -0,0 +1,1365 @@
1
+ "use client";
2
+ import { t as ie } from "./cn-ChIgwEl3.js";
3
+ import { FADE_ENTRANCE as Nt, SPAN_SCALE as Ae, SPRING_ENTRANCE as he } from "../motion.js";
4
+ import { t as fe } from "./skeleton-DwjSl4vC.js";
5
+ import { Children as Dt, Fragment as St, isValidElement as Ft, useCallback as Ut, useContext as P, useEffect as At, useId as Ve, useLayoutEffect as Lt, useMemo as U, useRef as Ge, useState as It } from "react";
6
+ import { Fragment as Yt, jsx as h, jsxs as _ } from "react/jsx-runtime";
7
+ import { useAnimate as Kt, useReducedMotion as Ht } from "motion/react";
8
+ import { AreaSeries as Wt, Axis as qe, BarGroup as $t, BarSeries as Rt, BarStack as Et, DataContext as G, DataProvider as Pt, Grid as Bt, LineSeries as zt, TooltipContext as Ot, TooltipProvider as jt, XYChart as Xt, buildChartTheme as Vt } from "@visx/xychart";
9
+ function Ze(e) {
10
+ this._context = e;
11
+ }
12
+ Ze.prototype = {
13
+ areaStart: function() {
14
+ this._line = 0;
15
+ },
16
+ areaEnd: function() {
17
+ this._line = NaN;
18
+ },
19
+ lineStart: function() {
20
+ this._point = 0;
21
+ },
22
+ lineEnd: function() {
23
+ (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
24
+ },
25
+ point: function(e, t) {
26
+ switch (e = +e, t = +t, this._point) {
27
+ case 0:
28
+ this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
29
+ break;
30
+ case 1:
31
+ this._point = 2;
32
+ default:
33
+ this._context.lineTo(e, t);
34
+ }
35
+ }
36
+ };
37
+ function Gt(e) {
38
+ return new Ze(e);
39
+ }
40
+ function Le(e) {
41
+ return e < 0 ? -1 : 1;
42
+ }
43
+ function Ie(e, t, n) {
44
+ var o = e._x1 - e._x0, r = t - e._x1, i = (e._y1 - e._y0) / (o || r < 0 && -0), a = (n - e._y1) / (r || o < 0 && -0), s = (i * r + a * o) / (o + r);
45
+ return (Le(i) + Le(a)) * Math.min(Math.abs(i), Math.abs(a), 0.5 * Math.abs(s)) || 0;
46
+ }
47
+ function Ye(e, t) {
48
+ var n = e._x1 - e._x0;
49
+ return n ? (3 * (e._y1 - e._y0) / n - t) / 2 : t;
50
+ }
51
+ function de(e, t, n) {
52
+ var o = e._x0, r = e._y0, i = e._x1, a = e._y1, s = (i - o) / 3;
53
+ e._context.bezierCurveTo(o + s, r + s * t, i - s, a - s * n, i, a);
54
+ }
55
+ function oe(e) {
56
+ this._context = e;
57
+ }
58
+ oe.prototype = {
59
+ areaStart: function() {
60
+ this._line = 0;
61
+ },
62
+ areaEnd: function() {
63
+ this._line = NaN;
64
+ },
65
+ lineStart: function() {
66
+ this._x0 = this._x1 = this._y0 = this._y1 = this._t0 = NaN, this._point = 0;
67
+ },
68
+ lineEnd: function() {
69
+ switch (this._point) {
70
+ case 2:
71
+ this._context.lineTo(this._x1, this._y1);
72
+ break;
73
+ case 3:
74
+ de(this, this._t0, Ye(this, this._t0));
75
+ }
76
+ (this._line || this._line !== 0 && this._point === 1) && this._context.closePath(), this._line = 1 - this._line;
77
+ },
78
+ point: function(e, t) {
79
+ var n = NaN;
80
+ if (e = +e, t = +t, !(e === this._x1 && t === this._y1)) {
81
+ switch (this._point) {
82
+ case 0:
83
+ this._point = 1, this._line ? this._context.lineTo(e, t) : this._context.moveTo(e, t);
84
+ break;
85
+ case 1:
86
+ this._point = 2;
87
+ break;
88
+ case 2:
89
+ this._point = 3, de(this, Ye(this, n = Ie(this, e, t)), n);
90
+ break;
91
+ default:
92
+ de(this, this._t0, n = Ie(this, e, t));
93
+ }
94
+ this._x0 = this._x1, this._x1 = e, this._y0 = this._y1, this._y1 = t, this._t0 = n;
95
+ }
96
+ }
97
+ };
98
+ function qt(e) {
99
+ this._context = new Je(e);
100
+ }
101
+ (qt.prototype = Object.create(oe.prototype)).point = function(e, t) {
102
+ oe.prototype.point.call(this, t, e);
103
+ };
104
+ function Je(e) {
105
+ this._context = e;
106
+ }
107
+ Je.prototype = {
108
+ moveTo: function(e, t) {
109
+ this._context.moveTo(t, e);
110
+ },
111
+ closePath: function() {
112
+ this._context.closePath();
113
+ },
114
+ lineTo: function(e, t) {
115
+ this._context.lineTo(t, e);
116
+ },
117
+ bezierCurveTo: function(e, t, n, o, r, i) {
118
+ this._context.bezierCurveTo(t, e, o, n, i, r);
119
+ }
120
+ };
121
+ function Zt(e) {
122
+ return new oe(e);
123
+ }
124
+ var Ke = [
125
+ "chart-1",
126
+ "chart-2",
127
+ "chart-3",
128
+ "chart-4",
129
+ "chart-5",
130
+ "chart-6"
131
+ ];
132
+ function Jt(e, t) {
133
+ const n = e ?? Ke[t % Ke.length];
134
+ return `var(--color-pho-${n.startsWith("chart-") ? n : `chart-${n}`})`;
135
+ }
136
+ function He(e, t = !1) {
137
+ const n = new Intl.NumberFormat(e, t ? {
138
+ notation: "compact",
139
+ maximumFractionDigits: 1
140
+ } : { maximumFractionDigits: 2 });
141
+ return (o) => n.format(o);
142
+ }
143
+ function D(e, t) {
144
+ const n = e[t];
145
+ return typeof n == "number" && Number.isFinite(n) ? n : null;
146
+ }
147
+ function Qt(e) {
148
+ return e.length <= 1 ? e[0] ?? "" : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
149
+ }
150
+ function en({ data: e, series: t, valueFormat: n, timeFormat: o }) {
151
+ if (e.length === 0) return "No data to show.";
152
+ const r = e[0], i = e[e.length - 1], a = e.length > 1 ? `${o(new Date(r.x))} to ${o(new Date(i.x))}` : o(new Date(r.x)), s = [`${Qt(t.map((c) => c.label))}, ${a}.`];
153
+ for (const c of t) {
154
+ let l = 0, u = 1 / 0, f = -1 / 0, g = null, p = 0;
155
+ for (const Y of e) {
156
+ const k = D(Y, c.key);
157
+ k != null && (p++, l += k, k < u && (u = k), k > f && (f = k, g = new Date(Y.x)));
158
+ }
159
+ if (p === 0) {
160
+ s.push(`${c.label}: no values.`);
161
+ continue;
162
+ }
163
+ const w = g ? `, peak ${n(f)} at ${o(g)}` : "";
164
+ s.push(c.kind === "bar" ? `${c.label}: ${n(l)} in total${w}.` : `${c.label}: from ${n(u)} to ${n(f)}${w}.`);
165
+ }
166
+ return s.join(" ");
167
+ }
168
+ function Qe({ color: e, kind: t = "rect", dashed: n }) {
169
+ return t === "line" ? /* @__PURE__ */ h("svg", {
170
+ "aria-hidden": !0,
171
+ width: "14",
172
+ height: "6",
173
+ className: "shrink-0",
174
+ children: /* @__PURE__ */ h("line", {
175
+ x1: "1",
176
+ x2: "13",
177
+ y1: "3",
178
+ y2: "3",
179
+ stroke: e,
180
+ strokeWidth: "2",
181
+ strokeLinecap: "round",
182
+ strokeDasharray: n ? "3 3" : void 0
183
+ })
184
+ }) : /* @__PURE__ */ h("span", {
185
+ "aria-hidden": !0,
186
+ className: "inline-block size-2 shrink-0 rounded-[2px]",
187
+ style: { background: e }
188
+ });
189
+ }
190
+ function tn({ items: e, className: t, ...n }) {
191
+ return /* @__PURE__ */ h("ul", {
192
+ className: ie("text-pho-secondary flex flex-wrap gap-x-4 gap-y-1 text-xs", t),
193
+ ...n,
194
+ children: e.map((o) => /* @__PURE__ */ _("li", {
195
+ className: "flex items-center gap-1.5",
196
+ children: [/* @__PURE__ */ h(Qe, {
197
+ color: o.color,
198
+ kind: o.kind,
199
+ dashed: o.dashed
200
+ }), o.label]
201
+ }, o.label))
202
+ });
203
+ }
204
+ function me(e, t) {
205
+ return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
206
+ }
207
+ function nn(e, t) {
208
+ return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
209
+ }
210
+ function rn(e) {
211
+ let t, n, o;
212
+ e.length !== 2 ? (t = me, n = (s, c) => me(e(s), c), o = (s, c) => e(s) - c) : (t = e === me || e === nn ? e : on, n = e, o = e);
213
+ function r(s, c, l = 0, u = s.length) {
214
+ if (l < u) {
215
+ if (t(c, c) !== 0) return u;
216
+ do {
217
+ const f = l + u >>> 1;
218
+ n(s[f], c) < 0 ? l = f + 1 : u = f;
219
+ } while (l < u);
220
+ }
221
+ return l;
222
+ }
223
+ function i(s, c, l = 0, u = s.length) {
224
+ if (l < u) {
225
+ if (t(c, c) !== 0) return u;
226
+ do {
227
+ const f = l + u >>> 1;
228
+ n(s[f], c) <= 0 ? l = f + 1 : u = f;
229
+ } while (l < u);
230
+ }
231
+ return l;
232
+ }
233
+ function a(s, c, l = 0, u = s.length) {
234
+ const f = r(s, c, l, u - 1);
235
+ return f > l && o(s[f - 1], c) > -o(s[f], c) ? f - 1 : f;
236
+ }
237
+ return {
238
+ left: r,
239
+ center: a,
240
+ right: i
241
+ };
242
+ }
243
+ function on() {
244
+ return 0;
245
+ }
246
+ var an = Math.sqrt(50), sn = Math.sqrt(10), ln = Math.sqrt(2);
247
+ function ae(e, t, n) {
248
+ const o = (t - e) / Math.max(0, n), r = Math.floor(Math.log10(o)), i = o / Math.pow(10, r), a = i >= an ? 10 : i >= sn ? 5 : i >= ln ? 2 : 1;
249
+ let s, c, l;
250
+ return r < 0 ? (l = Math.pow(10, -r) / a, s = Math.round(e * l), c = Math.round(t * l), s / l < e && ++s, c / l > t && --c, l = -l) : (l = Math.pow(10, r) * a, s = Math.round(e / l), c = Math.round(t / l), s * l < e && ++s, c * l > t && --c), c < s && 0.5 <= n && n < 2 ? ae(e, t, n * 2) : [
251
+ s,
252
+ c,
253
+ l
254
+ ];
255
+ }
256
+ function cn(e, t, n) {
257
+ if (t = +t, e = +e, n = +n, !(n > 0)) return [];
258
+ if (e === t) return [e];
259
+ const o = t < e, [r, i, a] = o ? ae(t, e, n) : ae(e, t, n);
260
+ if (!(i >= r)) return [];
261
+ const s = i - r + 1, c = new Array(s);
262
+ if (o)
263
+ if (a < 0) for (let l = 0; l < s; ++l) c[l] = (i - l) / -a;
264
+ else for (let l = 0; l < s; ++l) c[l] = (i - l) * a;
265
+ else if (a < 0) for (let l = 0; l < s; ++l) c[l] = (r + l) / -a;
266
+ else for (let l = 0; l < s; ++l) c[l] = (r + l) * a;
267
+ return c;
268
+ }
269
+ function We(e, t, n) {
270
+ return t = +t, e = +e, n = +n, ae(e, t, n)[2];
271
+ }
272
+ function se(e, t, n) {
273
+ t = +t, e = +e, n = +n;
274
+ const o = t < e, r = o ? We(t, e, n) : We(e, t, n);
275
+ return (o ? -1 : 1) * (r < 0 ? 1 / -r : r);
276
+ }
277
+ var ge = /* @__PURE__ */ new Date(), pe = /* @__PURE__ */ new Date();
278
+ function b(e, t, n, o) {
279
+ function r(i) {
280
+ return e(i = arguments.length === 0 ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date(+i)), i;
281
+ }
282
+ return r.floor = (i) => (e(i = /* @__PURE__ */ new Date(+i)), i), r.ceil = (i) => (e(i = /* @__PURE__ */ new Date(i - 1)), t(i, 1), e(i), i), r.round = (i) => {
283
+ const a = r(i), s = r.ceil(i);
284
+ return i - a < s - i ? a : s;
285
+ }, r.offset = (i, a) => (t(i = /* @__PURE__ */ new Date(+i), a == null ? 1 : Math.floor(a)), i), r.range = (i, a, s) => {
286
+ const c = [];
287
+ if (i = r.ceil(i), s = s == null ? 1 : Math.floor(s), !(i < a) || !(s > 0)) return c;
288
+ let l;
289
+ do
290
+ c.push(l = /* @__PURE__ */ new Date(+i)), t(i, s), e(i);
291
+ while (l < i && i < a);
292
+ return c;
293
+ }, r.filter = (i) => b((a) => {
294
+ if (a >= a) for (; e(a), !i(a); ) a.setTime(a - 1);
295
+ }, (a, s) => {
296
+ if (a >= a)
297
+ if (s < 0) for (; ++s <= 0; ) for (; t(a, -1), !i(a); ) ;
298
+ else for (; --s >= 0; ) for (; t(a, 1), !i(a); ) ;
299
+ }), n && (r.count = (i, a) => (ge.setTime(+i), pe.setTime(+a), e(ge), e(pe), Math.floor(n(ge, pe))), r.every = (i) => (i = Math.floor(i), !isFinite(i) || !(i > 0) ? null : i > 1 ? r.filter(o ? (a) => o(a) % i === 0 : (a) => r.count(0, a) % i === 0) : r)), r;
300
+ }
301
+ var le = b(() => {
302
+ }, (e, t) => {
303
+ e.setTime(+e + t);
304
+ }, (e, t) => t - e);
305
+ le.every = (e) => (e = Math.floor(e), !isFinite(e) || !(e > 0) ? null : e > 1 ? b((t) => {
306
+ t.setTime(Math.floor(t / e) * e);
307
+ }, (t, n) => {
308
+ t.setTime(+t + n * e);
309
+ }, (t, n) => (n - t) / e) : le);
310
+ var gr = le.range, A = 1e3, C = A * 60, L = C * 60, I = L * 24, xe = I * 7, $e = I * 30, ve = I * 365, Z = b((e) => {
311
+ e.setTime(e - e.getMilliseconds());
312
+ }, (e, t) => {
313
+ e.setTime(+e + t * A);
314
+ }, (e, t) => (t - e) / A, (e) => e.getUTCSeconds()), pr = Z.range, et = b((e) => {
315
+ e.setTime(e - e.getMilliseconds() - e.getSeconds() * A);
316
+ }, (e, t) => {
317
+ e.setTime(+e + t * C);
318
+ }, (e, t) => (t - e) / C, (e) => e.getMinutes()), vr = et.range, tt = b((e) => {
319
+ e.setUTCSeconds(0, 0);
320
+ }, (e, t) => {
321
+ e.setTime(+e + t * C);
322
+ }, (e, t) => (t - e) / C, (e) => e.getUTCMinutes()), yr = tt.range, nt = b((e) => {
323
+ e.setTime(e - e.getMilliseconds() - e.getSeconds() * A - e.getMinutes() * C);
324
+ }, (e, t) => {
325
+ e.setTime(+e + t * L);
326
+ }, (e, t) => (t - e) / L, (e) => e.getHours()), br = nt.range, rt = b((e) => {
327
+ e.setUTCMinutes(0, 0, 0);
328
+ }, (e, t) => {
329
+ e.setTime(+e + t * L);
330
+ }, (e, t) => (t - e) / L, (e) => e.getUTCHours()), Tr = rt.range, V = b((e) => e.setHours(0, 0, 0, 0), (e, t) => e.setDate(e.getDate() + t), (e, t) => (t - e - (t.getTimezoneOffset() - e.getTimezoneOffset()) * C) / I, (e) => e.getDate() - 1), xr = V.range, un = b((e) => {
331
+ e.setUTCHours(0, 0, 0, 0);
332
+ }, (e, t) => {
333
+ e.setUTCDate(e.getUTCDate() + t);
334
+ }, (e, t) => (t - e) / I, (e) => e.getUTCDate() - 1), Mr = un.range, it = b((e) => {
335
+ e.setUTCHours(0, 0, 0, 0);
336
+ }, (e, t) => {
337
+ e.setUTCDate(e.getUTCDate() + t);
338
+ }, (e, t) => (t - e) / I, (e) => Math.floor(e / I)), _r = it.range;
339
+ function B(e) {
340
+ return b((t) => {
341
+ t.setDate(t.getDate() - (t.getDay() + 7 - e) % 7), t.setHours(0, 0, 0, 0);
342
+ }, (t, n) => {
343
+ t.setDate(t.getDate() + n * 7);
344
+ }, (t, n) => (n - t - (n.getTimezoneOffset() - t.getTimezoneOffset()) * C) / xe);
345
+ }
346
+ var ot = B(0), hn = B(1), fn = B(2), dn = B(3), mn = B(4), gn = B(5), pn = B(6), wr = ot.range, kr = hn.range, Cr = fn.range, Nr = dn.range, Dr = mn.range, Sr = gn.range, Fr = pn.range;
347
+ function z(e) {
348
+ return b((t) => {
349
+ t.setUTCDate(t.getUTCDate() - (t.getUTCDay() + 7 - e) % 7), t.setUTCHours(0, 0, 0, 0);
350
+ }, (t, n) => {
351
+ t.setUTCDate(t.getUTCDate() + n * 7);
352
+ }, (t, n) => (n - t) / xe);
353
+ }
354
+ var at = z(0), vn = z(1), yn = z(2), bn = z(3), Tn = z(4), xn = z(5), Mn = z(6), Ur = at.range, Ar = vn.range, Lr = yn.range, Ir = bn.range, Yr = Tn.range, Kr = xn.range, Hr = Mn.range, st = b((e) => {
355
+ e.setDate(1), e.setHours(0, 0, 0, 0);
356
+ }, (e, t) => {
357
+ e.setMonth(e.getMonth() + t);
358
+ }, (e, t) => t.getMonth() - e.getMonth() + (t.getFullYear() - e.getFullYear()) * 12, (e) => e.getMonth()), Wr = st.range, lt = b((e) => {
359
+ e.setUTCDate(1), e.setUTCHours(0, 0, 0, 0);
360
+ }, (e, t) => {
361
+ e.setUTCMonth(e.getUTCMonth() + t);
362
+ }, (e, t) => t.getUTCMonth() - e.getUTCMonth() + (t.getUTCFullYear() - e.getUTCFullYear()) * 12, (e) => e.getUTCMonth()), $r = lt.range, ce = b((e) => {
363
+ e.setMonth(0, 1), e.setHours(0, 0, 0, 0);
364
+ }, (e, t) => {
365
+ e.setFullYear(e.getFullYear() + t);
366
+ }, (e, t) => t.getFullYear() - e.getFullYear(), (e) => e.getFullYear());
367
+ ce.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : b((t) => {
368
+ t.setFullYear(Math.floor(t.getFullYear() / e) * e), t.setMonth(0, 1), t.setHours(0, 0, 0, 0);
369
+ }, (t, n) => {
370
+ t.setFullYear(t.getFullYear() + n * e);
371
+ });
372
+ var Rr = ce.range, Me = b((e) => {
373
+ e.setUTCMonth(0, 1), e.setUTCHours(0, 0, 0, 0);
374
+ }, (e, t) => {
375
+ e.setUTCFullYear(e.getUTCFullYear() + t);
376
+ }, (e, t) => t.getUTCFullYear() - e.getUTCFullYear(), (e) => e.getUTCFullYear());
377
+ Me.every = (e) => !isFinite(e = Math.floor(e)) || !(e > 0) ? null : b((t) => {
378
+ t.setUTCFullYear(Math.floor(t.getUTCFullYear() / e) * e), t.setUTCMonth(0, 1), t.setUTCHours(0, 0, 0, 0);
379
+ }, (t, n) => {
380
+ t.setUTCFullYear(t.getUTCFullYear() + n * e);
381
+ });
382
+ var Er = Me.range;
383
+ function ct(e, t, n, o, r, i) {
384
+ const a = [
385
+ [
386
+ Z,
387
+ 1,
388
+ A
389
+ ],
390
+ [
391
+ Z,
392
+ 5,
393
+ 5 * A
394
+ ],
395
+ [
396
+ Z,
397
+ 15,
398
+ 15 * A
399
+ ],
400
+ [
401
+ Z,
402
+ 30,
403
+ 30 * A
404
+ ],
405
+ [
406
+ i,
407
+ 1,
408
+ C
409
+ ],
410
+ [
411
+ i,
412
+ 5,
413
+ 5 * C
414
+ ],
415
+ [
416
+ i,
417
+ 15,
418
+ 15 * C
419
+ ],
420
+ [
421
+ i,
422
+ 30,
423
+ 30 * C
424
+ ],
425
+ [
426
+ r,
427
+ 1,
428
+ L
429
+ ],
430
+ [
431
+ r,
432
+ 3,
433
+ 3 * L
434
+ ],
435
+ [
436
+ r,
437
+ 6,
438
+ 6 * L
439
+ ],
440
+ [
441
+ r,
442
+ 12,
443
+ 12 * L
444
+ ],
445
+ [
446
+ o,
447
+ 1,
448
+ I
449
+ ],
450
+ [
451
+ o,
452
+ 2,
453
+ 2 * I
454
+ ],
455
+ [
456
+ n,
457
+ 1,
458
+ xe
459
+ ],
460
+ [
461
+ t,
462
+ 1,
463
+ $e
464
+ ],
465
+ [
466
+ t,
467
+ 3,
468
+ 3 * $e
469
+ ],
470
+ [
471
+ e,
472
+ 1,
473
+ ve
474
+ ]
475
+ ];
476
+ function s(l, u, f) {
477
+ const g = u < l;
478
+ g && ([l, u] = [u, l]);
479
+ const p = f && typeof f.range == "function" ? f : c(l, u, f), w = p ? p.range(l, +u + 1) : [];
480
+ return g ? w.reverse() : w;
481
+ }
482
+ function c(l, u, f) {
483
+ const g = Math.abs(u - l) / f, p = rn(([, , k]) => k).right(a, g);
484
+ if (p === a.length) return e.every(se(l / ve, u / ve, f));
485
+ if (p === 0) return le.every(Math.max(se(l, u, f), 1));
486
+ const [w, Y] = a[g / a[p - 1][2] < a[p][2] / g ? p - 1 : p];
487
+ return w.every(Y);
488
+ }
489
+ return [s, c];
490
+ }
491
+ var [Pr, Br] = ct(Me, lt, at, it, rt, tt), [_n, zr] = ct(ce, st, ot, V, nt, et);
492
+ function E(e) {
493
+ return typeof e == "number" ? e : e.getTime();
494
+ }
495
+ function wn(e, t, n) {
496
+ if (!Number.isFinite(e) || !Number.isFinite(t)) return {
497
+ domain: [0, 1],
498
+ ticks: [0, 1],
499
+ count: 1
500
+ };
501
+ e > t && ([e, t] = [t, e]);
502
+ const o = n?.integer ?? (Number.isInteger(e) && Number.isInteger(t));
503
+ if (e === t) {
504
+ if (t === 0) return o ? {
505
+ domain: [0, 1],
506
+ ticks: [0, 1],
507
+ count: 1
508
+ } : {
509
+ domain: [0, 1],
510
+ ticks: [
511
+ 0,
512
+ 0.5,
513
+ 1
514
+ ],
515
+ count: 2
516
+ };
517
+ t > 0 ? e = 0 : t = 0;
518
+ }
519
+ for (let r = 4; r >= 2; r--) {
520
+ const i = o ? kn(e, t, r) : se(e, t, r), a = Math.floor(e / i) * i, s = Math.ceil(t / i) * i, c = o ? Cn(a, s, i) : cn(a, s, r);
521
+ if (c.length <= 5 || r === 2) return {
522
+ domain: [a, s],
523
+ ticks: c,
524
+ count: o ? Math.max(1, c.length - 1) : r
525
+ };
526
+ }
527
+ return {
528
+ domain: [e, t],
529
+ ticks: [e, t],
530
+ count: 1
531
+ };
532
+ }
533
+ function kn(e, t, n) {
534
+ const o = se(e, t, n);
535
+ if (o <= 1) return 1;
536
+ if (Number.isInteger(o)) return o;
537
+ const r = 10 ** Math.floor(Math.log10(o)), i = o / r;
538
+ return (i <= 1 ? 1 : i <= 2 ? 2 : i <= 5 ? 5 : 10) * r;
539
+ }
540
+ function Cn(e, t, n) {
541
+ const o = [];
542
+ for (let r = e; r <= t + n / 2; r += n) o.push(r);
543
+ return o;
544
+ }
545
+ function Nn(e) {
546
+ if (e.length < 2) return 0;
547
+ const t = [];
548
+ for (let n = 1; n < e.length; n++) t.push(e[n] - e[n - 1]);
549
+ return t.sort((n, o) => n - o), t[Math.floor(t.length / 2)];
550
+ }
551
+ var Dn = 864e5;
552
+ function Sn(e, t, n) {
553
+ if (t <= e || n <= 0) return [new Date(e)];
554
+ const o = Math.max(2, Math.floor(n / 96)), r = _n(new Date(e), new Date(t), o);
555
+ if (r.length > 2 && r.every((i) => Fn(i))) {
556
+ const i = r.slice(1).map((s, c) => V.count(r[c], s)), a = Math.max(...i);
557
+ if (a > 1 && i.some((s) => s !== a)) return V.range(r[0], new Date(t + 1), a);
558
+ }
559
+ return r;
560
+ }
561
+ function Fn(e) {
562
+ return V(e).getTime() === e.getTime();
563
+ }
564
+ function Un(e) {
565
+ const t = new Intl.DateTimeFormat(e, {
566
+ hour: "numeric",
567
+ minute: "2-digit"
568
+ }), n = new Intl.DateTimeFormat(e, {
569
+ month: "short",
570
+ day: "numeric"
571
+ }), o = new Intl.DateTimeFormat(e, {
572
+ month: "short",
573
+ year: "numeric"
574
+ });
575
+ return (r) => V(r).getTime() < r.getTime() ? t.format(r) : ce(r).getTime() < r.getTime() ? n.format(r) : o.format(r);
576
+ }
577
+ function An(e, t) {
578
+ const n = new Intl.DateTimeFormat(e, t >= Dn ? {
579
+ month: "short",
580
+ day: "numeric"
581
+ } : {
582
+ month: "short",
583
+ day: "numeric",
584
+ hour: "numeric",
585
+ minute: "2-digit"
586
+ });
587
+ return (o) => n.format(o);
588
+ }
589
+ function Ln(e) {
590
+ return e.length * 6.5 + 16;
591
+ }
592
+ function In(e, t, n) {
593
+ if (e.length < 2) return [...e];
594
+ const o = Math.max(...e.map((a) => Ln(t(a)))), r = Math.max(1, Math.floor(n / o)), i = Math.ceil(e.length / r);
595
+ return i <= 1 ? [...e] : e.filter((a, s) => s % i === 0);
596
+ }
597
+ function ut(e, t) {
598
+ if (e.length === 0) return -1;
599
+ let n = 0, o = e.length - 1;
600
+ for (; n < o; ) {
601
+ const r = n + o >> 1;
602
+ e[r] < t ? n = r + 1 : o = r;
603
+ }
604
+ return n > 0 && t - e[n - 1] < e[n] - t ? n - 1 : n;
605
+ }
606
+ var ye = 8, be = 8, Re = 22;
607
+ function Yn(e, t, n) {
608
+ const o = n.reduce((a, s) => Math.max(a, s.length), 0), r = Math.ceil(o * 6.5) + 10, i = t - Re;
609
+ return {
610
+ width: e,
611
+ height: t,
612
+ left: r,
613
+ top: ye,
614
+ right: e - be,
615
+ bottom: i,
616
+ innerWidth: Math.max(0, e - r - be),
617
+ innerHeight: Math.max(0, i - ye),
618
+ margin: {
619
+ top: ye,
620
+ right: be,
621
+ bottom: Re,
622
+ left: r
623
+ }
624
+ };
625
+ }
626
+ var Kn = { "--pho-chart-surface": "var(--pho-surface, var(--background-color-pho-primary))" };
627
+ function Hn({ label: e, description: t, height: n, containerRef: o, legend: r, loading: i, empty: a, showEmpty: s, placeholder: c, className: l, children: u, ...f }) {
628
+ const g = Ve();
629
+ return /* @__PURE__ */ _("div", {
630
+ "data-chart": "",
631
+ className: ie("flex w-full min-w-0 flex-col gap-3", l),
632
+ ...f,
633
+ children: [/* @__PURE__ */ _("div", {
634
+ ref: o,
635
+ "aria-busy": i || void 0,
636
+ className: ie("relative w-full transition-opacity duration-150 ease-out", i && "opacity-50"),
637
+ style: { height: n },
638
+ children: [
639
+ /* @__PURE__ */ h("div", {
640
+ role: "img",
641
+ "aria-label": e,
642
+ "aria-describedby": g,
643
+ className: "animate-pho-chart-in relative size-full select-none [&_.visx-bar-stack_.visx-bar]:stroke-(--pho-chart-surface) [&_.visx-bar-stack_.visx-bar]:stroke-2 [&_svg]:block [&_svg]:overflow-visible",
644
+ style: Kn,
645
+ children: u
646
+ }),
647
+ /* @__PURE__ */ h("p", {
648
+ id: g,
649
+ className: "sr-only",
650
+ children: t
651
+ }),
652
+ c,
653
+ s && /* @__PURE__ */ h("div", {
654
+ className: "text-pho-description absolute inset-0 flex items-center justify-center text-xs",
655
+ children: a
656
+ })
657
+ ]
658
+ }), r]
659
+ });
660
+ }
661
+ var Wn = [
662
+ 0.42,
663
+ 0.58,
664
+ 0.5,
665
+ 0.7,
666
+ 0.62,
667
+ 0.8,
668
+ 0.66,
669
+ 0.9,
670
+ 0.72,
671
+ 0.56,
672
+ 0.76,
673
+ 0.64
674
+ ], re = [
675
+ 0,
676
+ 1 / 3,
677
+ 2 / 3,
678
+ 1
679
+ ], $n = 5;
680
+ function Rn({ layout: e }) {
681
+ const { margin: t } = e;
682
+ return /* @__PURE__ */ _("div", {
683
+ "aria-hidden": !0,
684
+ "data-chart-skeleton": "",
685
+ className: "absolute inset-0 grid",
686
+ style: {
687
+ gridTemplateColumns: `${t.left}px 1fr ${t.right}px`,
688
+ gridTemplateRows: `${t.top}px 1fr ${t.bottom}px`
689
+ },
690
+ children: [
691
+ /* @__PURE__ */ h("div", {
692
+ className: "relative col-start-1 row-start-2",
693
+ children: re.map((n) => /* @__PURE__ */ h(fe, {
694
+ "data-bone": "y",
695
+ className: "absolute right-2 h-2.5 w-4 -translate-y-1/2",
696
+ style: { top: `${n * 100}%` }
697
+ }, n))
698
+ }),
699
+ /* @__PURE__ */ _("div", {
700
+ className: "relative col-start-2 row-start-2",
701
+ children: [re.map((n, o) => /* @__PURE__ */ h("div", {
702
+ "data-bone": o === re.length - 1 ? "baseline" : "grid",
703
+ className: ie("absolute inset-x-0 border-t", o === re.length - 1 ? "border-pho-chart-crosshair" : "border-pho-chart-grid"),
704
+ style: { top: `${n * 100}%` }
705
+ }, n)), /* @__PURE__ */ h("div", {
706
+ className: "absolute inset-0 flex items-end justify-between gap-2",
707
+ children: Wn.map((n, o) => /* @__PURE__ */ h(fe, {
708
+ "data-bone": "bar",
709
+ className: "w-full max-w-6 rounded-t-[4px] rounded-b-none",
710
+ style: { height: `${n * 100}%` }
711
+ }, o))
712
+ })]
713
+ }),
714
+ /* @__PURE__ */ h("div", {
715
+ className: "col-start-2 row-start-3 flex items-center justify-between px-1",
716
+ children: Array.from({ length: $n }, (n, o) => /* @__PURE__ */ h(fe, {
717
+ "data-bone": "x",
718
+ className: "h-2.5 w-8"
719
+ }, o))
720
+ })
721
+ ]
722
+ });
723
+ }
724
+ var Ee = {
725
+ fontFamily: "inherit",
726
+ fontSize: 11,
727
+ fontWeight: 400,
728
+ letterSpacing: 0,
729
+ fill: "var(--text-color-pho-description)",
730
+ style: { fontVariantNumeric: "tabular-nums" }
731
+ };
732
+ function En(e) {
733
+ return Vt({
734
+ backgroundColor: "var(--pho-surface, var(--background-color-pho-primary))",
735
+ colors: [...e],
736
+ gridColor: "var(--color-pho-chart-grid)",
737
+ gridColorDark: "var(--color-pho-chart-crosshair)",
738
+ tickLength: 4,
739
+ svgLabelSmall: Ee,
740
+ svgLabelBig: Ee,
741
+ htmlLabel: {
742
+ fontFamily: "inherit",
743
+ fontSize: 11,
744
+ fontWeight: 400,
745
+ letterSpacing: 0,
746
+ color: "var(--text-color-pho-description)"
747
+ }
748
+ });
749
+ }
750
+ function Pn({ x: e, width: t, top: n, heading: o, rows: r, breakdown: i, breakdownTitle: a, valueFormat: s, empty: c }) {
751
+ const l = e > t / 2;
752
+ return /* @__PURE__ */ _("div", {
753
+ "aria-hidden": !0,
754
+ "data-chart-tooltip": "",
755
+ className: "bg-pho-primary shadow-pho-lg ring-pho-secondary rounded-base pointer-events-none absolute z-10 max-w-72 min-w-40 px-3 py-2 text-xs ring-1 ring-inset",
756
+ style: l ? {
757
+ right: t - e + 12,
758
+ top: n
759
+ } : {
760
+ left: e + 12,
761
+ top: n
762
+ },
763
+ children: [
764
+ /* @__PURE__ */ h("div", {
765
+ className: "text-pho-primary font-medium",
766
+ children: o
767
+ }),
768
+ r.length === 0 && c != null && /* @__PURE__ */ h("div", {
769
+ className: "text-pho-description mt-1",
770
+ children: c
771
+ }),
772
+ /* @__PURE__ */ h("ul", {
773
+ className: "mt-1 flex flex-col gap-0.5",
774
+ children: r.map((u) => /* @__PURE__ */ _("li", {
775
+ className: "flex items-center justify-between gap-4",
776
+ children: [/* @__PURE__ */ _("span", {
777
+ className: "text-pho-secondary flex min-w-0 items-center gap-1.5",
778
+ children: [/* @__PURE__ */ h(Qe, {
779
+ color: u.color,
780
+ kind: u.kind,
781
+ dashed: u.dashed
782
+ }), /* @__PURE__ */ h("span", {
783
+ className: "truncate",
784
+ children: u.label
785
+ })]
786
+ }), /* @__PURE__ */ h("span", {
787
+ className: "text-pho-primary font-medium tabular-nums",
788
+ children: u.value
789
+ })]
790
+ }, u.label))
791
+ }),
792
+ i != null && i.length > 0 && /* @__PURE__ */ _("div", {
793
+ className: "border-pho-secondary mt-2 border-t pt-2",
794
+ children: [a != null && /* @__PURE__ */ h("div", {
795
+ className: "text-pho-description mb-1",
796
+ children: a
797
+ }), /* @__PURE__ */ h("ul", {
798
+ className: "flex flex-col gap-0.5",
799
+ children: i.map((u) => /* @__PURE__ */ _("li", {
800
+ className: "flex items-center justify-between gap-4",
801
+ children: [/* @__PURE__ */ h("span", {
802
+ className: "text-pho-secondary truncate",
803
+ children: u.label
804
+ }), /* @__PURE__ */ h("span", {
805
+ className: "text-pho-primary tabular-nums",
806
+ children: s(u.value)
807
+ })]
808
+ }, u.label))
809
+ })]
810
+ })
811
+ ]
812
+ });
813
+ }
814
+ var ht = typeof window > "u" ? At : Lt;
815
+ function Bn(e) {
816
+ const t = Ge(null), [n, o] = It(0);
817
+ return ht(() => {
818
+ if (e != null) return;
819
+ const r = t.current;
820
+ if (r == null || (o(r.getBoundingClientRect().width), typeof ResizeObserver > "u")) return;
821
+ const i = new ResizeObserver((a) => {
822
+ const s = a[0]?.contentRect.width;
823
+ s != null && o(s);
824
+ });
825
+ return i.observe(r), () => i.disconnect();
826
+ }, [e]), [t, e ?? n];
827
+ }
828
+ var zn = 24, On = 4, Pe = 2, jn = 4, Xn = "var(--pho-chart-surface)", Vn = "var(--background-color-pho-ghost-hover)", ft = "var(--color-pho-chart-crosshair)";
829
+ function _e(e) {
830
+ return null;
831
+ }
832
+ _e.displayName = "Chart.Bar";
833
+ _e.chartPart = "bar";
834
+ function we(e) {
835
+ return null;
836
+ }
837
+ we.displayName = "Chart.Line";
838
+ we.chartPart = "line";
839
+ function Gn(e) {
840
+ return e?.chartPart;
841
+ }
842
+ function dt(e, t = []) {
843
+ return Dt.forEach(e, (n) => {
844
+ if (!Ft(n)) return;
845
+ const o = Gn(n.type);
846
+ if (n.type === St) dt(n.props.children, t);
847
+ else if (o === "bar") {
848
+ const r = n.props;
849
+ t.push({
850
+ kind: "bar",
851
+ dataKey: r.dataKey,
852
+ label: r.label,
853
+ color: r.color,
854
+ curve: "linear"
855
+ });
856
+ } else if (o === "line") {
857
+ const r = n.props;
858
+ t.push({
859
+ kind: "line",
860
+ dataKey: r.dataKey,
861
+ label: r.label,
862
+ color: r.color,
863
+ dashed: r.dashed,
864
+ curve: r.curve ?? "linear",
865
+ area: r.area,
866
+ gaps: r.gaps ?? "break"
867
+ });
868
+ }
869
+ }), t;
870
+ }
871
+ var Te = (e) => E(e.x), Be = /* @__PURE__ */ new Map();
872
+ function qn(e) {
873
+ let t = Be.get(e);
874
+ return t == null && (t = (n) => D(n, e) ?? 0, Be.set(e, t)), t;
875
+ }
876
+ var ze = /* @__PURE__ */ new Map();
877
+ function Oe(e) {
878
+ let t = ze.get(e);
879
+ return t == null && (t = (n) => D(n, e) ?? NaN, ze.set(e, t)), t;
880
+ }
881
+ var je = /* @__PURE__ */ new Map();
882
+ function Zn(e, t) {
883
+ const n = `${e} ${t}`;
884
+ let o = je.get(n);
885
+ return o == null && (o = (r) => D(r, e) ? t : "transparent", je.set(n, o)), o;
886
+ }
887
+ function J(e) {
888
+ const t = e, n = typeof t.bandwidth == "function" ? t.bandwidth() / 2 : 0;
889
+ return (o) => {
890
+ const r = t(o);
891
+ return typeof r == "number" && Number.isFinite(r) ? r + n : void 0;
892
+ };
893
+ }
894
+ function mt(e) {
895
+ const t = e;
896
+ return (n) => {
897
+ const o = t(Number(n));
898
+ return typeof o == "number" && Number.isFinite(o) ? o : void 0;
899
+ };
900
+ }
901
+ function Jn(e) {
902
+ const t = e;
903
+ return typeof t.step == "function" ? t.step() : 0;
904
+ }
905
+ function Qn(e, t, n, o) {
906
+ const r = t > 0 ? e / t : 0, i = r >= 6 ? 2 : r >= 3 ? 1 : 0, a = Math.max(1, Math.min(zn, r - i)), s = Math.min(2, i), c = o ? a + s : n > 1 ? a + 2 * s : a, l = Math.min(r, c), u = r > 0 ? 1 - l / r : 0, f = n > 1 && l > s ? Math.min(0.5, s * n / (l - s)) : 0;
907
+ return {
908
+ paddingInner: u,
909
+ paddingOuter: u / 2,
910
+ groupPadding: f
911
+ };
912
+ }
913
+ function Xe({ children: e }) {
914
+ const { dataRegistry: t } = P(G);
915
+ return t?.entries().some((n) => n.data.length > 0) ?? !1 ? /* @__PURE__ */ h(Yt, { children: e }) : null;
916
+ }
917
+ function ke(e, t, n) {
918
+ const o = P(Ot);
919
+ if (!o?.tooltipOpen) return null;
920
+ if (n) {
921
+ const i = o.tooltipLeft;
922
+ if (i == null || t == null || e.length === 0) return null;
923
+ const a = J(t), s = [];
924
+ for (const c of e) {
925
+ const l = a(E(c.x));
926
+ if (l == null) return null;
927
+ s.push(l);
928
+ }
929
+ return ut(s, i);
930
+ }
931
+ const r = o.tooltipData?.nearestDatum?.index;
932
+ return r != null && r >= 0 && r < e.length ? r : null;
933
+ }
934
+ function er({ values: e, format: t, layout: n }) {
935
+ const { xScale: o } = P(G), r = Ut((i) => {
936
+ const a = i, s = J(o)(a) ?? n.left, c = t(a).length * 6.5 / 2;
937
+ return { textAnchor: s - c < n.left ? "start" : s + c > n.right ? "end" : "middle" };
938
+ }, [
939
+ o,
940
+ t,
941
+ n.left,
942
+ n.right
943
+ ]);
944
+ return /* @__PURE__ */ h(qe, {
945
+ orientation: "bottom",
946
+ tickValues: [...e],
947
+ tickFormat: (i) => t(i),
948
+ hideAxisLine: !0,
949
+ hideTicks: !0,
950
+ tickLabelProps: r
951
+ });
952
+ }
953
+ function tr({ data: e, layout: t, hasConnectedLines: n }) {
954
+ const { xScale: o } = P(G), r = ke(e, o, n);
955
+ if (r == null || o == null) return null;
956
+ const i = J(o)(E(e[r].x)), a = Jn(o);
957
+ return i == null ? null : /* @__PURE__ */ h("rect", {
958
+ "data-hover-wash": "",
959
+ x: i - a / 2,
960
+ y: t.top,
961
+ width: a,
962
+ height: t.innerHeight,
963
+ fill: Vn
964
+ });
965
+ }
966
+ function nr({ layout: e }) {
967
+ const { yScale: t } = P(G), n = t ? mt(t)(0) : void 0;
968
+ return n == null ? null : /* @__PURE__ */ h("line", {
969
+ "data-zero": "",
970
+ x1: e.left,
971
+ x2: e.right,
972
+ y1: n,
973
+ y2: n,
974
+ stroke: ft
975
+ });
976
+ }
977
+ function rr({ data: e, layout: t, lines: n, crosshair: o, hasConnectedLines: r }) {
978
+ const { xScale: i, yScale: a } = P(G), s = ke(e, i, r);
979
+ if (s == null || i == null || a == null) return null;
980
+ const c = e[s], l = J(i)(E(c.x));
981
+ if (l == null) return null;
982
+ const u = mt(a);
983
+ return /* @__PURE__ */ _("g", {
984
+ "data-hover": "",
985
+ children: [o && /* @__PURE__ */ h("line", {
986
+ x1: l,
987
+ x2: l,
988
+ y1: t.top,
989
+ y2: t.bottom,
990
+ stroke: ft
991
+ }), n.length > 0 && /* @__PURE__ */ h("g", {
992
+ "data-points": "",
993
+ children: n.map((f) => {
994
+ const g = D(c, f.dataKey), p = g == null ? void 0 : u(g);
995
+ return p == null ? null : /* @__PURE__ */ h("circle", {
996
+ cx: l,
997
+ cy: p,
998
+ r: jn,
999
+ fill: f.color,
1000
+ stroke: Xn,
1001
+ strokeWidth: 2
1002
+ }, f.dataKey);
1003
+ })
1004
+ })]
1005
+ });
1006
+ }
1007
+ function ir({ data: e, range: t, layout: n, children: o }) {
1008
+ const r = Ht(), [i, a] = Kt(), s = Ve(), c = Ge(null);
1009
+ ht(() => {
1010
+ const u = i.current, f = c.current;
1011
+ if (c.current = t, e.length === 0 || r || u == null) return;
1012
+ const g = { opacity: Nt }, p = f == null ? a(u, {
1013
+ scaleY: [0, 1],
1014
+ scaleX: 1,
1015
+ x: 0,
1016
+ opacity: [0, 1],
1017
+ originY: 1
1018
+ }, {
1019
+ scaleY: he,
1020
+ ...g
1021
+ }) : f === 0 || t === f ? a(u, {
1022
+ x: [-12, 0],
1023
+ scaleX: 1,
1024
+ scaleY: 1,
1025
+ opacity: [0, 1]
1026
+ }, {
1027
+ x: he,
1028
+ ...g
1029
+ }) : a(u, {
1030
+ scaleX: [t > f ? Ae : 1 / Ae, 1],
1031
+ scaleY: 1,
1032
+ x: 0,
1033
+ opacity: [0, 1],
1034
+ originX: 0.5
1035
+ }, {
1036
+ scaleX: he,
1037
+ ...g
1038
+ });
1039
+ return () => p.stop();
1040
+ }, [
1041
+ e,
1042
+ t,
1043
+ r
1044
+ ]);
1045
+ const l = 4;
1046
+ return /* @__PURE__ */ _("g", {
1047
+ clipPath: `url(#${s})`,
1048
+ children: [/* @__PURE__ */ h("defs", { children: /* @__PURE__ */ h("clipPath", {
1049
+ id: s,
1050
+ children: /* @__PURE__ */ h("rect", {
1051
+ x: n.left - l,
1052
+ y: n.top - l,
1053
+ width: n.innerWidth + 8,
1054
+ height: n.innerHeight + 8
1055
+ })
1056
+ }) }), /* @__PURE__ */ h("g", {
1057
+ ref: i,
1058
+ "data-marks": "",
1059
+ children: o
1060
+ })]
1061
+ });
1062
+ }
1063
+ function or({ data: e, layout: t, parts: n, colors: o, width: r, headingFormat: i, valueFormat: a, breakdownTitle: s, emptyBucket: c, hasConnectedLines: l }) {
1064
+ const { xScale: u } = P(G), f = ke(e, u, l);
1065
+ if (f == null || u == null) return null;
1066
+ const g = e[f], p = J(u)(E(g.x));
1067
+ return p == null ? null : /* @__PURE__ */ h(Pn, {
1068
+ x: p,
1069
+ width: r,
1070
+ top: t.top,
1071
+ heading: i(new Date(g.x)),
1072
+ rows: n.flatMap((w, Y) => {
1073
+ const k = D(g, w.dataKey);
1074
+ return k == null ? [] : [{
1075
+ label: w.label,
1076
+ value: a(k),
1077
+ color: o[Y],
1078
+ kind: w.kind === "bar" ? "rect" : "line",
1079
+ dashed: w.dashed
1080
+ }];
1081
+ }),
1082
+ breakdown: g.breakdown,
1083
+ breakdownTitle: s,
1084
+ valueFormat: a,
1085
+ empty: c
1086
+ });
1087
+ }
1088
+ var ar = {
1089
+ dx: "-0.35em",
1090
+ dy: "0.35em",
1091
+ width: void 0
1092
+ };
1093
+ function Ce({ data: e, children: t, label: n, description: o, height: r = 200, width: i, valueFormat: a, timeFormat: s, locale: c, legend: l, baseline: u = "zero", stacked: f = !1, breakdownTitle: g, loading: p, empty: w = "Nothing here yet.", emptyBucket: Y, className: k, ...gt }) {
1094
+ const [pt, O] = Bn(i), S = U(() => dt(t), [t]), d = U(() => {
1095
+ const m = e.map((v) => E(v.x)), T = Nn(m), x = a ?? He(c, !0), y = a ?? He(c), $ = s ?? An(c, T), ee = S.map((v, N) => Jt(v.color, N)), F = S.filter((v) => v.kind === "bar"), Fe = S.map((v, N) => ({
1096
+ ...v,
1097
+ color: ee[N]
1098
+ })).filter((v) => v.kind === "line");
1099
+ let R = 1 / 0, X = -1 / 0;
1100
+ const te = (v) => {
1101
+ v < R && (R = v), v > X && (X = v);
1102
+ };
1103
+ if (f && F.length > 1) for (const v of e) {
1104
+ let N = 0, W = 0;
1105
+ for (const Ct of F) {
1106
+ const ne = D(v, Ct.dataKey);
1107
+ ne != null && (ne > 0 ? N += ne : W += ne);
1108
+ }
1109
+ te(N), te(W);
1110
+ }
1111
+ else for (const v of F) for (const N of e) {
1112
+ const W = D(N, v.dataKey);
1113
+ W != null && te(W);
1114
+ }
1115
+ for (const v of Fe) for (const N of e) {
1116
+ const W = D(N, v.dataKey);
1117
+ W != null && te(W);
1118
+ }
1119
+ R === 1 / 0 && (R = 0, X = 0), (u === "zero" || F.length > 0) && (R = Math.min(0, R), X = Math.max(0, X));
1120
+ const Ue = wn(R, X);
1121
+ return {
1122
+ times: m,
1123
+ span: T,
1124
+ colors: ee,
1125
+ bars: F,
1126
+ lines: Fe,
1127
+ hasBars: F.length > 0,
1128
+ axisFormat: x,
1129
+ fullFormat: y,
1130
+ headingFormat: $,
1131
+ y: Ue,
1132
+ yLabels: Ue.ticks.map(x),
1133
+ described: o ?? en({
1134
+ data: e,
1135
+ series: S.map((v) => ({
1136
+ key: v.dataKey,
1137
+ label: v.label,
1138
+ kind: v.kind
1139
+ })),
1140
+ valueFormat: y,
1141
+ timeFormat: $
1142
+ })
1143
+ };
1144
+ }, [
1145
+ e,
1146
+ S,
1147
+ f,
1148
+ u,
1149
+ a,
1150
+ s,
1151
+ c,
1152
+ o
1153
+ ]), K = e.length, H = d.times[0] ?? 0, j = d.times[K - 1] ?? 0, vt = K > 0 ? j - H + d.span : 0, M = U(() => Yn(O, r, d.yLabels), [
1154
+ O,
1155
+ r,
1156
+ d.yLabels
1157
+ ]), q = U(() => Qn(M.innerWidth, K, d.bars.length, f), [
1158
+ M.innerWidth,
1159
+ K,
1160
+ d.bars.length,
1161
+ f
1162
+ ]), yt = U(() => d.hasBars ? {
1163
+ type: "band",
1164
+ domain: d.times,
1165
+ paddingInner: q.paddingInner,
1166
+ paddingOuter: q.paddingOuter
1167
+ } : {
1168
+ type: "time",
1169
+ domain: j > H ? [H, j] : [H - 1, H + 1]
1170
+ }, [
1171
+ d.hasBars,
1172
+ d.times,
1173
+ q.paddingInner,
1174
+ q.paddingOuter,
1175
+ H,
1176
+ j
1177
+ ]), bt = U(() => ({
1178
+ type: "linear",
1179
+ domain: d.y.domain,
1180
+ zero: !1,
1181
+ nice: !1
1182
+ }), [d.y.domain]), Tt = U(() => En(d.colors), [d.colors]), Ne = U(() => {
1183
+ const m = Un(c);
1184
+ if (K === 0 || M.innerWidth <= 0) return {
1185
+ values: [],
1186
+ format: () => ""
1187
+ };
1188
+ const T = In(Sn(H, j, M.innerWidth), m, M.innerWidth);
1189
+ if (!d.hasBars) return {
1190
+ values: T,
1191
+ format: (y) => m(new Date(y))
1192
+ };
1193
+ const x = /* @__PURE__ */ new Map();
1194
+ for (const y of T) {
1195
+ const $ = d.times[ut(d.times, y.getTime())];
1196
+ x.has($) || x.set($, m(y));
1197
+ }
1198
+ return {
1199
+ values: [...x.keys()],
1200
+ format: (y) => x.get(E(y)) ?? m(new Date(y))
1201
+ };
1202
+ }, [
1203
+ K,
1204
+ H,
1205
+ j,
1206
+ M.innerWidth,
1207
+ c,
1208
+ d.hasBars,
1209
+ d.times
1210
+ ]), xt = l ?? S.length > 1, De = K === 0 && !p, Mt = K === 0 && p === !0, _t = d.y.domain[0] >= 0 || d.y.domain[1] <= 0, Q = e, Se = U(() => {
1211
+ const m = /* @__PURE__ */ new Map();
1212
+ for (const T of d.lines) T.gaps === "connect" && m.set(T.dataKey, Q.filter((x) => D(x, T.dataKey) != null));
1213
+ return m;
1214
+ }, [d.lines, Q]), ue = Se.size > 0, wt = (() => {
1215
+ const { bars: m } = d;
1216
+ if (m.length === 0) return null;
1217
+ const T = m.length - 1, x = m.map((y, $) => {
1218
+ const ee = d.colors[S.indexOf(y)], F = !f || $ === T;
1219
+ return /* @__PURE__ */ h(Rt, {
1220
+ dataKey: y.dataKey,
1221
+ data: Q,
1222
+ xAccessor: Te,
1223
+ yAccessor: qn(y.dataKey),
1224
+ colorAccessor: Zn(y.dataKey, ee),
1225
+ radius: F ? On : void 0,
1226
+ radiusTop: F,
1227
+ "data-series": y.dataKey
1228
+ }, y.dataKey);
1229
+ });
1230
+ return m.length === 1 ? x : f ? /* @__PURE__ */ h(Et, { children: x }) : /* @__PURE__ */ h($t, {
1231
+ padding: q.groupPadding,
1232
+ children: x
1233
+ });
1234
+ })(), kt = d.lines.map((m) => {
1235
+ const T = m.curve === "monotone" ? Zt : Gt, x = m.dashed ? "4 4" : void 0, y = Se.get(m.dataKey) ?? Q;
1236
+ return m.area ? /* @__PURE__ */ h(Wt, {
1237
+ dataKey: m.dataKey,
1238
+ data: y,
1239
+ xAccessor: Te,
1240
+ yAccessor: Oe(m.dataKey),
1241
+ curve: T,
1242
+ fill: m.color,
1243
+ fillOpacity: 0.1,
1244
+ lineProps: {
1245
+ stroke: m.color,
1246
+ strokeWidth: Pe,
1247
+ strokeLinejoin: "round",
1248
+ strokeDasharray: x
1249
+ },
1250
+ "data-series": m.dataKey
1251
+ }, m.dataKey) : /* @__PURE__ */ h(zt, {
1252
+ dataKey: m.dataKey,
1253
+ data: y,
1254
+ xAccessor: Te,
1255
+ yAccessor: Oe(m.dataKey),
1256
+ curve: T,
1257
+ stroke: m.color,
1258
+ strokeWidth: Pe,
1259
+ strokeLinejoin: "round",
1260
+ strokeDasharray: x,
1261
+ "data-series": m.dataKey
1262
+ }, m.dataKey);
1263
+ });
1264
+ return /* @__PURE__ */ h(Hn, {
1265
+ label: n,
1266
+ description: d.described,
1267
+ height: r,
1268
+ containerRef: pt,
1269
+ loading: p,
1270
+ empty: w,
1271
+ showEmpty: De,
1272
+ placeholder: Mt ? /* @__PURE__ */ h(Rn, { layout: M }) : null,
1273
+ className: k,
1274
+ legend: xt ? /* @__PURE__ */ h(tn, { items: S.map((m, T) => ({
1275
+ label: m.label,
1276
+ color: d.colors[T],
1277
+ kind: m.kind === "bar" ? "rect" : "line",
1278
+ dashed: m.dashed
1279
+ })) }) : null,
1280
+ ...gt,
1281
+ children: O > 0 && !De && /* @__PURE__ */ h(Pt, {
1282
+ xScale: yt,
1283
+ yScale: bt,
1284
+ theme: Tt,
1285
+ initialDimensions: {
1286
+ width: O,
1287
+ height: r,
1288
+ margin: M.margin
1289
+ },
1290
+ children: /* @__PURE__ */ _(jt, {
1291
+ hideTooltipDebounceMs: 0,
1292
+ children: [/* @__PURE__ */ _(Xt, {
1293
+ width: O,
1294
+ height: r,
1295
+ margin: M.margin,
1296
+ accessibilityLabel: n,
1297
+ children: [
1298
+ /* @__PURE__ */ h(Xe, { children: /* @__PURE__ */ h(Bt, {
1299
+ rows: !0,
1300
+ columns: !1,
1301
+ numTicks: d.y.count
1302
+ }) }),
1303
+ /* @__PURE__ */ h(qe, {
1304
+ orientation: "left",
1305
+ tickValues: d.y.ticks,
1306
+ tickFormat: (m) => d.axisFormat(Number(m)),
1307
+ hideAxisLine: !0,
1308
+ hideTicks: !0,
1309
+ tickLabelProps: ar
1310
+ }),
1311
+ /* @__PURE__ */ h(er, {
1312
+ values: Ne.values,
1313
+ format: Ne.format,
1314
+ layout: M
1315
+ }),
1316
+ d.hasBars && /* @__PURE__ */ h(tr, {
1317
+ data: e,
1318
+ layout: M,
1319
+ hasConnectedLines: ue
1320
+ }),
1321
+ /* @__PURE__ */ _(ir, {
1322
+ data: e,
1323
+ range: vt,
1324
+ layout: M,
1325
+ children: [wt, kt]
1326
+ }),
1327
+ d.hasBars && _t && /* @__PURE__ */ h(Xe, { children: /* @__PURE__ */ h(nr, { layout: M }) }),
1328
+ /* @__PURE__ */ h(rr, {
1329
+ data: e,
1330
+ layout: M,
1331
+ lines: d.lines,
1332
+ crosshair: !d.hasBars,
1333
+ hasConnectedLines: ue
1334
+ })
1335
+ ]
1336
+ }), /* @__PURE__ */ h(or, {
1337
+ data: e,
1338
+ layout: M,
1339
+ parts: S,
1340
+ colors: d.colors,
1341
+ width: O,
1342
+ headingFormat: d.headingFormat,
1343
+ valueFormat: d.fullFormat,
1344
+ breakdownTitle: g,
1345
+ emptyBucket: Y,
1346
+ hasConnectedLines: ue
1347
+ })]
1348
+ })
1349
+ })
1350
+ });
1351
+ }
1352
+ Ce.displayName = "Chart";
1353
+ Ce.Bar = _e;
1354
+ Ce.Line = we;
1355
+ export {
1356
+ Qe as a,
1357
+ tn as i,
1358
+ _e as n,
1359
+ Ke as o,
1360
+ we as r,
1361
+ Jt as s,
1362
+ Ce as t
1363
+ };
1364
+
1365
+ //# sourceMappingURL=chart-BrIXaMue.js.map