@mt-gloss/ui 0.1.141 → 0.1.143

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,933 @@
1
+ import { jsxs as u, jsx as e, Fragment as K } from "react/jsx-runtime";
2
+ import { useId as me, useMemo as B, useState as ge, useRef as $, useCallback as C, useEffect as pe } from "react";
3
+ import { formatTrend as xe, isStatusModeEnabled as ye, pickMetricTier as be, getValueFontSize as Y, formatValue as q, getDateRangeForPreset as ve, formatDateRangeSmart as ke, ROLLING_OPTIONS as we, PERIOD_OPTIONS as Se } from "@mt-gloss/utils";
4
+ import { B as D, a as N, b as Ce } from "./BaseText-Dxbk1JJa.js";
5
+ import { Box as E, Chip as X, Popper as Ie, Paper as ze, MenuList as Me, MenuItem as Re, ListItemText as Le, IconButton as Te, Tooltip as De, Divider as Ne } from "@mui/material";
6
+ import $e from "@mui/icons-material/ExpandMore";
7
+ import Be from "@mui/icons-material/Star";
8
+ import We from "@mui/icons-material/StarBorder";
9
+ import Oe from "@mui/icons-material/Check";
10
+ const Q = {
11
+ up: { color: "#10b981", bg: "rgba(16,185,129,0.07)" },
12
+ down: { color: "#ef4444", bg: "rgba(239,68,68,0.07)" },
13
+ flat: { color: "#6b7280", bg: "rgba(107,114,128,0.07)" }
14
+ }, Z = {
15
+ up: "▲",
16
+ down: "▼",
17
+ flat: "▶"
18
+ }, j = function({ value: n, direction: t }) {
19
+ if (n == null) return null;
20
+ const { text: a, direction: f } = xe(n), s = t || f, { color: r, bg: l } = Q[s] || Q.flat, o = Z[s] || Z.flat;
21
+ return /* @__PURE__ */ u(
22
+ "span",
23
+ {
24
+ style: {
25
+ display: "inline-flex",
26
+ alignItems: "center",
27
+ gap: 2,
28
+ padding: "2px 6px",
29
+ borderRadius: 4,
30
+ fontSize: 11,
31
+ fontWeight: 600,
32
+ lineHeight: 1,
33
+ color: r,
34
+ backgroundColor: l,
35
+ whiteSpace: "nowrap"
36
+ },
37
+ children: [
38
+ /* @__PURE__ */ e("span", { style: { fontSize: 8, lineHeight: 1 }, children: o }),
39
+ a
40
+ ]
41
+ }
42
+ );
43
+ };
44
+ j.displayName = "TrendIndicator";
45
+ const H = ({ data: i, color: n, isStale: t }) => {
46
+ const f = "sparkbg-" + me().replace(/:/g, ""), s = n || "#4f46e5", r = B(() => {
47
+ if (!i || i.length < 2) return null;
48
+ const l = 300, o = 55, c = 2, d = Math.min(...i), m = Math.max(...i) - d || 1, p = i.map((y, S) => ({
49
+ x: S / (i.length - 1) * l,
50
+ y: c + (1 - (y - d) / m) * (o - c * 2)
51
+ })).map((y, S) => `${S === 0 ? "M" : "L"}${y.x},${y.y}`).join(" "), w = `${p} L${l},${o} L0,${o}Z`;
52
+ return { line: p, area: w, w: l, h: o };
53
+ }, [i]);
54
+ return r ? /* @__PURE__ */ u(
55
+ "svg",
56
+ {
57
+ height: 55,
58
+ viewBox: `0 0 ${r.w} ${r.h}`,
59
+ preserveAspectRatio: "none",
60
+ style: {
61
+ position: "absolute",
62
+ // quick-260418-k7k-fix-4: "bleed" means REACH the card edges — NOT
63
+ // extend past them. CardShell's FRONT BaseBox has `inset: 0` inside
64
+ // CardShell root, so its padding-box (= containing block for abs
65
+ // descendants) is the FULL card size. width:100% + left:0 + right:0
66
+ // + bottom:0 lands the SVG exactly inside the card border. Earlier
67
+ // fix-3 added `calc(100% + 24px)` to overshoot each side by 12px,
68
+ // which user rejected ("Why on earth would I want the sparklines
69
+ // to go beyond the edge of the cards?"). StackedGroupCard hoists
70
+ // SparklineBg to Fragment-root so its containing block matches the
71
+ // 1×1 MetricCard path (FRONT BaseBox padding-box = full card).
72
+ bottom: 0,
73
+ left: 0,
74
+ right: 0,
75
+ width: "100%",
76
+ zIndex: 1,
77
+ display: "block",
78
+ pointerEvents: "none",
79
+ transform: t ? "scaleY(0.05)" : "scaleY(1)",
80
+ transformOrigin: "bottom",
81
+ transition: t ? "transform 400ms ease-out" : "transform 500ms ease-in-out"
82
+ },
83
+ children: [
84
+ /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ u("linearGradient", { id: f, x1: "0", y1: "0", x2: "0", y2: "1", children: [
85
+ /* @__PURE__ */ e("stop", { offset: "0%", stopColor: s, stopOpacity: "0.09" }),
86
+ /* @__PURE__ */ e("stop", { offset: "100%", stopColor: s, stopOpacity: "0.01" })
87
+ ] }) }),
88
+ /* @__PURE__ */ e("path", { d: r.area, fill: `url(#${f})` }),
89
+ /* @__PURE__ */ e(
90
+ "path",
91
+ {
92
+ d: r.line,
93
+ fill: "none",
94
+ stroke: s,
95
+ strokeOpacity: "0.22",
96
+ strokeWidth: "1.5",
97
+ strokeLinecap: "round",
98
+ strokeLinejoin: "round"
99
+ }
100
+ )
101
+ ]
102
+ }
103
+ ) : null;
104
+ };
105
+ H.displayName = "SparklineBg";
106
+ const ee = ({ data: i, color: n, isStale: t }) => {
107
+ const a = n || "#4f46e5", f = B(() => {
108
+ if (!i || i.length < 1) return null;
109
+ const s = 300, r = 50, l = r * 0.82, o = i.length, c = s / (o * 4), d = c * 3, m = Math.max(...i) || 1;
110
+ return i.map((x, p) => {
111
+ const w = x / m, y = Math.max(w * l, 2);
112
+ return {
113
+ x: p * (d + c),
114
+ y: r - y,
115
+ width: d,
116
+ height: y,
117
+ isLast: p === o - 1
118
+ };
119
+ });
120
+ }, [i]);
121
+ return f ? /* @__PURE__ */ e(
122
+ "svg",
123
+ {
124
+ width: "100%",
125
+ height: 50,
126
+ viewBox: "0 0 300 50",
127
+ preserveAspectRatio: "none",
128
+ style: {
129
+ position: "absolute",
130
+ bottom: 0,
131
+ left: 0,
132
+ right: 0,
133
+ zIndex: 1,
134
+ display: "block",
135
+ pointerEvents: "none",
136
+ transform: t ? "scaleY(0.05)" : "scaleY(1)",
137
+ transformOrigin: "bottom",
138
+ transition: t ? "transform 400ms ease-out" : "transform 500ms ease-in-out"
139
+ },
140
+ children: f.map((s, r) => /* @__PURE__ */ e(
141
+ "rect",
142
+ {
143
+ x: s.x,
144
+ y: s.y,
145
+ width: s.width,
146
+ height: s.height,
147
+ fill: a,
148
+ fillOpacity: s.isLast ? 0.14 : 0.06,
149
+ rx: "2.5"
150
+ },
151
+ r
152
+ ))
153
+ }
154
+ ) : null;
155
+ };
156
+ ee.displayName = "BarsBg";
157
+ const te = ({ value: i = 0, max: n = 100, color: t = "#4f46e5", colSpan: a = 1, isStale: f }) => {
158
+ const s = a >= 2 ? 40 : 34, r = 3.5, l = (s - r) / 2, o = 2 * Math.PI * l, c = f ? 0 : Math.min(Math.max(i / (n || 1), 0), 1), d = o * (1 - c);
159
+ return /* @__PURE__ */ u(
160
+ "svg",
161
+ {
162
+ width: s,
163
+ height: s,
164
+ viewBox: `0 0 ${s} ${s}`,
165
+ style: { flexShrink: 0, marginRight: 8, display: "block" },
166
+ children: [
167
+ /* @__PURE__ */ e(
168
+ "circle",
169
+ {
170
+ cx: s / 2,
171
+ cy: s / 2,
172
+ r: l,
173
+ fill: "none",
174
+ stroke: t,
175
+ strokeOpacity: "0.06",
176
+ strokeWidth: r
177
+ }
178
+ ),
179
+ /* @__PURE__ */ e(
180
+ "circle",
181
+ {
182
+ cx: s / 2,
183
+ cy: s / 2,
184
+ r: l,
185
+ fill: "none",
186
+ stroke: t,
187
+ strokeWidth: r,
188
+ strokeDasharray: o,
189
+ strokeDashoffset: d,
190
+ strokeLinecap: "round",
191
+ transform: `rotate(-90 ${s / 2} ${s / 2})`,
192
+ style: { transition: "stroke-dashoffset 0.4s ease" }
193
+ }
194
+ )
195
+ ]
196
+ }
197
+ );
198
+ };
199
+ te.displayName = "DonutChart";
200
+ const re = ({ value: i = 0, max: n = 100, trendValue: t = 0, color: a = "#6b7280", colSpan: f = 1, isStale: s }) => {
201
+ const r = f >= 2 ? 44 : 36, l = 3.5, o = (r - l) / 2, c = 2 * Math.PI * o, d = s ? 0 : Math.min(Math.max(i / (n || 1), 0), 1), h = c * (1 - d), m = f >= 2 ? 11 : 9, x = `${Math.round(Math.abs(t))}%`;
202
+ return /* @__PURE__ */ u(
203
+ "div",
204
+ {
205
+ style: {
206
+ position: "relative",
207
+ display: "inline-flex",
208
+ alignItems: "center",
209
+ justifyContent: "center",
210
+ width: r,
211
+ height: r,
212
+ flexShrink: 0,
213
+ marginRight: 8
214
+ },
215
+ children: [
216
+ /* @__PURE__ */ u(
217
+ "svg",
218
+ {
219
+ width: r,
220
+ height: r,
221
+ viewBox: `0 0 ${r} ${r}`,
222
+ style: { display: "block" },
223
+ children: [
224
+ /* @__PURE__ */ e(
225
+ "circle",
226
+ {
227
+ cx: r / 2,
228
+ cy: r / 2,
229
+ r: o,
230
+ fill: "none",
231
+ stroke: a,
232
+ strokeOpacity: "0.06",
233
+ strokeWidth: l
234
+ }
235
+ ),
236
+ /* @__PURE__ */ e(
237
+ "circle",
238
+ {
239
+ cx: r / 2,
240
+ cy: r / 2,
241
+ r: o,
242
+ fill: "none",
243
+ stroke: a,
244
+ strokeWidth: l,
245
+ strokeDasharray: c,
246
+ strokeDashoffset: h,
247
+ strokeLinecap: "round",
248
+ transform: `rotate(-90 ${r / 2} ${r / 2})`,
249
+ style: { transition: "stroke-dashoffset 0.4s ease" }
250
+ }
251
+ )
252
+ ]
253
+ }
254
+ ),
255
+ /* @__PURE__ */ e(
256
+ "div",
257
+ {
258
+ style: {
259
+ position: "absolute",
260
+ inset: 0,
261
+ display: "flex",
262
+ alignItems: "center",
263
+ justifyContent: "center",
264
+ fontSize: m,
265
+ fontWeight: 700,
266
+ color: a,
267
+ lineHeight: 1,
268
+ pointerEvents: "none"
269
+ },
270
+ children: x
271
+ }
272
+ )
273
+ ]
274
+ }
275
+ );
276
+ };
277
+ re.displayName = "ObjectArrow";
278
+ const _e = { slot3: 200, slot5: 380 };
279
+ function Ee(i, n) {
280
+ const t = _e, a = 150, [f, s] = ge(1), r = $(null), l = $(null), o = C(() => {
281
+ const d = r.current;
282
+ if (d == null) return;
283
+ const h = d < t.slot3 ? 1 : d < t.slot5 ? 3 : 5;
284
+ s((m) => m === h ? m : h), r.current = null, l.current && (clearTimeout(l.current), l.current = null);
285
+ }, [t.slot3, t.slot5]);
286
+ pe(() => {
287
+ const d = i.current;
288
+ if (!d || typeof ResizeObserver > "u") return;
289
+ const h = new ResizeObserver((m) => {
290
+ const x = m[0]?.contentRect.width ?? 0;
291
+ r.current = x, l.current && clearTimeout(l.current), l.current = setTimeout(o, a);
292
+ });
293
+ return h.observe(d), () => {
294
+ h.disconnect(), l.current && clearTimeout(l.current);
295
+ };
296
+ }, [i, o, a]);
297
+ const c = C(() => {
298
+ o();
299
+ }, [o]);
300
+ return { capacity: f, onPointerUp: c };
301
+ }
302
+ function ie(i) {
303
+ const { onStatusSlotClick: n } = i, t = $(null), a = ye(), { capacity: f, onPointerUp: s } = Ee(t), r = i.maxSlots ?? f, l = i.statuses.slice(0, r);
304
+ if (!a) {
305
+ const o = i.statuses[0];
306
+ return /* @__PURE__ */ u(
307
+ D,
308
+ {
309
+ definition: { display: "flex", direction: "column" },
310
+ className: "gloss-status-card gloss-status-card--flag-off",
311
+ children: [
312
+ /* @__PURE__ */ e(N, { className: "gloss-metric-card__label", children: i.label }),
313
+ o != null ? /* @__PURE__ */ e(N, { children: String(o.value) }) : null
314
+ ]
315
+ }
316
+ );
317
+ }
318
+ return /* @__PURE__ */ u(
319
+ "div",
320
+ {
321
+ ref: t,
322
+ className: "gloss-status-card",
323
+ "data-status-mode": "on",
324
+ "data-status-capacity": r,
325
+ onPointerUp: s,
326
+ children: [
327
+ /* @__PURE__ */ e(N, { className: "gloss-metric-card__label", children: i.label }),
328
+ /* @__PURE__ */ e("div", { className: "gloss-status-slots", "data-status-slot-count": l.length, children: l.map((o, c) => {
329
+ const d = i.sparklinePerStatus?.[o.id], h = o.id === i.activeStatusId;
330
+ return /* @__PURE__ */ u(
331
+ "div",
332
+ {
333
+ className: `gloss-status-slots__slot${h ? " gloss-status-slots__slot--active" : ""}`,
334
+ "data-status-slot-id": o.id,
335
+ "data-status-slot-index": c,
336
+ onClick: n ? (m) => n(o.id, m.currentTarget) : void 0,
337
+ style: n ? { cursor: "pointer" } : void 0,
338
+ children: [
339
+ /* @__PURE__ */ e("span", { className: "gloss-metric-card__label", children: o.label }),
340
+ /* @__PURE__ */ e("span", { children: String(o.value) }),
341
+ d != null && d.length > 0 ? /* @__PURE__ */ e(H, { data: [...d], color: o.accentColor }) : null
342
+ ]
343
+ },
344
+ o.id
345
+ );
346
+ }) })
347
+ ]
348
+ }
349
+ );
350
+ }
351
+ ie.displayName = "StatusModeCard";
352
+ function je(i, n) {
353
+ if (!n) return;
354
+ if (i == null) return n.fallback;
355
+ const { operator: t, threshold: a, result: f, fallback: s } = n;
356
+ return (t === "lt" ? i < a : t === "gt" ? i > a : t === "eq" ? Math.abs(i - a) < 1e-9 : t === "gte" ? i >= a : t === "lte" ? i <= a : !1) ? f : s;
357
+ }
358
+ function J(i, n) {
359
+ const t = i.replace("#", "");
360
+ if (!/^[0-9a-fA-F]{6}$/.test(t))
361
+ return `rgba(0,0,0,${n})`;
362
+ const a = parseInt(t.substring(0, 2), 16), f = parseInt(t.substring(2, 4), 16), s = parseInt(t.substring(4, 6), 16);
363
+ return `rgba(${a},${f},${s},${n})`;
364
+ }
365
+ const _ = {
366
+ up: "var(--color-positive)",
367
+ down: "var(--color-negative)",
368
+ flat: "var(--color-text-secondary)"
369
+ }, Ae = {
370
+ positive: "#10b981",
371
+ // Used with hexToRgba() for tinted overlays -- must stay hex
372
+ negative: "#ef4444",
373
+ // Used with hexToRgba() for tinted overlays -- must stay hex
374
+ warning: "#f59e0b",
375
+ // Used with hexToRgba() for tinted overlays -- must stay hex
376
+ neutral: "#6b7280"
377
+ // Used with hexToRgba() for tinted overlays -- must stay hex
378
+ }, He = () => /* @__PURE__ */ u(
379
+ "svg",
380
+ {
381
+ "aria-label": "Warning threshold breached",
382
+ role: "img",
383
+ width: "14",
384
+ height: "14",
385
+ viewBox: "0 0 14 14",
386
+ fill: "none",
387
+ xmlns: "http://www.w3.org/2000/svg",
388
+ children: [
389
+ /* @__PURE__ */ e(
390
+ "path",
391
+ {
392
+ d: "M7 1.5L13 12.5H1L7 1.5Z",
393
+ fill: "currentColor",
394
+ fillOpacity: "0.15",
395
+ stroke: "currentColor",
396
+ strokeWidth: "1.2",
397
+ strokeLinejoin: "round"
398
+ }
399
+ ),
400
+ /* @__PURE__ */ e("line", { x1: "7", y1: "5.5", x2: "7", y2: "8.5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }),
401
+ /* @__PURE__ */ e("circle", { cx: "7", cy: "10.5", r: "0.7", fill: "currentColor" })
402
+ ]
403
+ }
404
+ ), Fe = () => /* @__PURE__ */ u(
405
+ "svg",
406
+ {
407
+ "aria-label": "Critical threshold breached",
408
+ role: "img",
409
+ width: "14",
410
+ height: "14",
411
+ viewBox: "0 0 14 14",
412
+ fill: "none",
413
+ xmlns: "http://www.w3.org/2000/svg",
414
+ children: [
415
+ /* @__PURE__ */ e("circle", { cx: "7", cy: "7", r: "6", fill: "currentColor", fillOpacity: "0.15", stroke: "currentColor", strokeWidth: "1.2" }),
416
+ /* @__PURE__ */ e("line", { x1: "7", y1: "4", x2: "7", y2: "8", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }),
417
+ /* @__PURE__ */ e("circle", { cx: "7", cy: "10", r: "0.7", fill: "currentColor" })
418
+ ]
419
+ }
420
+ ), Pe = function(n) {
421
+ const {
422
+ variant: t = "standard",
423
+ label: a,
424
+ labelAdornment: f,
425
+ value: s,
426
+ valueFormat: r,
427
+ trend: l,
428
+ subtitle: o,
429
+ colSpan: c = 1,
430
+ isStale: d,
431
+ thresholdBreach: h = "none"
432
+ } = n, m = t === "sparkline" || t === "bars" || t === "donut" ? n.accentColor ?? "#4f46e5" : "#4f46e5", x = t === "highlight" ? n.highlightColor : void 0, p = t === "sparkline" ? n.sparklineData : void 0, w = t === "bars" ? n.barData : void 0, y = t === "donut" ? n.donutValue : 0, S = t === "donut" ? n.donutMax ?? 100 : 100, L = t === "object-arrow" ? n.objectArrowValue : 0, W = t === "object-arrow" ? n.objectArrowMax : 100, O = t === "arrow" ? n.arrowDirection : void 0, I = t === "versus" ? n.versusData : void 0, z = t === "segmented" ? n.segments : void 0, b = (t === "highlight" && n.tintCondition ? je(
433
+ typeof n.value == "number" ? n.value : null,
434
+ n.tintCondition
435
+ ) : void 0) ?? x, k = (b ? Ae[b] : void 0) || b, { formatted: T, tier: ne, length: oe } = B(
436
+ () => t === "status-mode" ? { formatted: "", tier: 0, length: 0 } : be(s, {
437
+ prefix: r?.prefix || "",
438
+ suffix: r?.suffix || "",
439
+ abbreviated: r?.abbreviated
440
+ }, c),
441
+ [t, s, r?.prefix, r?.suffix, r?.abbreviated, c]
442
+ );
443
+ if (n.variant === "status-mode")
444
+ return /* @__PURE__ */ e(ie, { ...n });
445
+ const R = { display: T, full: T, length: oe }, se = Y(R.length, c), le = l?.direction && _[l.direction] || _.flat, F = d ? "gloss-metric-data-stale" : "gloss-metric-data-fresh", P = {
446
+ fontWeight: 700,
447
+ letterSpacing: "-0.03em",
448
+ color: t === "highlight" ? k : "rgba(0,0,0,0.87)",
449
+ fontSize: se,
450
+ lineHeight: 1.1,
451
+ whiteSpace: "nowrap",
452
+ overflow: "hidden"
453
+ }, V = {
454
+ fontSize: 10.5,
455
+ color: "rgba(0,0,0,0.35)",
456
+ overflow: "hidden",
457
+ textOverflow: "ellipsis",
458
+ whiteSpace: "nowrap",
459
+ flex: 1,
460
+ minWidth: 0
461
+ }, G = t === "sparkline" || t === "bars", ae = G && o ? {
462
+ ...V,
463
+ backgroundColor: "rgba(255,255,255,0.78)",
464
+ backdropFilter: "blur(4px)",
465
+ WebkitBackdropFilter: "blur(4px)",
466
+ padding: "1px 6px",
467
+ borderRadius: 4,
468
+ color: "rgba(0,0,0,0.5)",
469
+ flex: "none",
470
+ minWidth: void 0
471
+ } : V, ce = () => {
472
+ const v = O === "down" ? "▼" : "▲";
473
+ return /* @__PURE__ */ e(
474
+ "div",
475
+ {
476
+ style: {
477
+ width: 22,
478
+ height: 22,
479
+ borderRadius: 5,
480
+ backgroundColor: `${m}14`,
481
+ // ~8% opacity
482
+ display: "flex",
483
+ alignItems: "center",
484
+ justifyContent: "center",
485
+ flexShrink: 0,
486
+ marginRight: 6
487
+ },
488
+ children: /* @__PURE__ */ e("span", { style: { fontSize: 10, color: m, lineHeight: 1 }, children: v })
489
+ }
490
+ );
491
+ }, de = () => {
492
+ if (!I) return null;
493
+ const v = q(I.current, {
494
+ prefix: r?.prefix || "",
495
+ suffix: r?.suffix || "",
496
+ abbreviated: r?.abbreviated
497
+ }), M = q(I.prior, {
498
+ prefix: r?.prefix || "",
499
+ suffix: r?.suffix || "",
500
+ abbreviated: r?.abbreviated
501
+ }), U = Y(v.length, c), he = Math.max(U - 4, 14);
502
+ return /* @__PURE__ */ u("div", { style: { display: "flex", alignItems: "center", gap: 12, flex: 1 }, children: [
503
+ /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column" }, children: [
504
+ /* @__PURE__ */ e(
505
+ "span",
506
+ {
507
+ style: {
508
+ fontWeight: 700,
509
+ fontSize: U,
510
+ letterSpacing: "-0.03em",
511
+ color: "rgba(0,0,0,0.87)",
512
+ lineHeight: 1.1
513
+ },
514
+ title: v.full,
515
+ children: v.display
516
+ }
517
+ ),
518
+ /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "rgba(0,0,0,0.35)", marginTop: 2 }, children: I.currentLabel })
519
+ ] }),
520
+ /* @__PURE__ */ e(
521
+ Ce,
522
+ {
523
+ definition: { orientation: "vertical", color: "rgba(0,0,0,0.08)" },
524
+ style: { flexShrink: 0 }
525
+ }
526
+ ),
527
+ /* @__PURE__ */ u("div", { style: { display: "flex", flexDirection: "column" }, children: [
528
+ /* @__PURE__ */ e(
529
+ "span",
530
+ {
531
+ style: {
532
+ fontWeight: 700,
533
+ fontSize: he,
534
+ letterSpacing: "-0.03em",
535
+ color: "rgba(0,0,0,0.5)",
536
+ lineHeight: 1.1
537
+ },
538
+ title: M.full,
539
+ children: M.display
540
+ }
541
+ ),
542
+ /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "rgba(0,0,0,0.35)", marginTop: 2 }, children: I.priorLabel })
543
+ ] })
544
+ ] });
545
+ }, fe = () => !z || z.length === 0 ? null : /* @__PURE__ */ u("div", { style: { zIndex: 2, position: "relative" }, children: [
546
+ /* @__PURE__ */ e(
547
+ "div",
548
+ {
549
+ style: {
550
+ height: 5,
551
+ borderRadius: 3,
552
+ display: "flex",
553
+ gap: 1,
554
+ overflow: "hidden"
555
+ },
556
+ children: z.map((v, M) => /* @__PURE__ */ e(
557
+ "div",
558
+ {
559
+ style: {
560
+ flex: v.value,
561
+ backgroundColor: v.color,
562
+ minWidth: 2
563
+ }
564
+ },
565
+ M
566
+ ))
567
+ }
568
+ ),
569
+ /* @__PURE__ */ e(
570
+ "div",
571
+ {
572
+ style: {
573
+ display: "flex",
574
+ gap: 8,
575
+ flexWrap: "wrap",
576
+ marginTop: 4
577
+ },
578
+ children: z.map((v, M) => /* @__PURE__ */ u(
579
+ "div",
580
+ {
581
+ style: {
582
+ display: "flex",
583
+ alignItems: "center",
584
+ gap: 3
585
+ },
586
+ children: [
587
+ /* @__PURE__ */ e(
588
+ "div",
589
+ {
590
+ style: {
591
+ width: 6,
592
+ height: 6,
593
+ borderRadius: "50%",
594
+ backgroundColor: v.color,
595
+ flexShrink: 0
596
+ }
597
+ }
598
+ ),
599
+ /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "rgba(0,0,0,0.5)" }, children: v.label })
600
+ ]
601
+ },
602
+ M
603
+ ))
604
+ }
605
+ )
606
+ ] }), ue = [
607
+ "gloss-threshold-overlay",
608
+ h === "warn" ? "gloss-threshold-warn" : "",
609
+ h === "critical" ? "gloss-threshold-critical" : "",
610
+ h === "critical" ? "gloss-threshold-pulse" : ""
611
+ ].filter(Boolean).join(" ");
612
+ return /* @__PURE__ */ u(K, { children: [
613
+ h !== "none" && /* @__PURE__ */ e("div", { className: ue }),
614
+ h === "warn" && /* @__PURE__ */ e("span", { className: "gloss-threshold-icon gloss-threshold-icon--warn", children: /* @__PURE__ */ e(He, {}) }),
615
+ h === "critical" && /* @__PURE__ */ e("span", { className: "gloss-threshold-icon gloss-threshold-icon--critical", children: /* @__PURE__ */ e(Fe, {}) }),
616
+ t === "highlight" && k && /* @__PURE__ */ e(
617
+ "div",
618
+ {
619
+ style: {
620
+ position: "absolute",
621
+ inset: 0,
622
+ borderRadius: 10,
623
+ backgroundColor: J(k, 0.06),
624
+ border: `1px solid ${J(k, 0.15)}`,
625
+ zIndex: 0,
626
+ pointerEvents: "none"
627
+ }
628
+ }
629
+ ),
630
+ t === "sparkline" && /* @__PURE__ */ e(H, { data: p, color: m, isStale: d }),
631
+ t === "bars" && /* @__PURE__ */ e(ee, { data: w, color: m, isStale: d }),
632
+ /* @__PURE__ */ u(
633
+ D,
634
+ {
635
+ className: "gloss-metric-card__zone-a",
636
+ "data-tier": ne,
637
+ style: { height: 28, flexShrink: 0, zIndex: 2, position: "relative", display: "flex", alignItems: "center" },
638
+ children: [
639
+ /* @__PURE__ */ e(N, { className: "gloss-metric-card__label", children: a }),
640
+ f
641
+ ]
642
+ }
643
+ ),
644
+ /* @__PURE__ */ u(
645
+ D,
646
+ {
647
+ definition: { display: "flex", align: "center" },
648
+ className: `gloss-metric-card__zone-b ${F}`,
649
+ style: { flex: 1, zIndex: 2, position: "relative", minHeight: 0 },
650
+ children: [
651
+ t === "donut" && /* @__PURE__ */ e(te, { value: y, max: S, color: m, colSpan: c, isStale: d }),
652
+ t === "object-arrow" && /* @__PURE__ */ e(
653
+ re,
654
+ {
655
+ value: L,
656
+ max: W,
657
+ trendValue: l?.value,
658
+ color: le,
659
+ colSpan: c,
660
+ isStale: d
661
+ }
662
+ ),
663
+ t === "arrow" && ce(),
664
+ t !== "versus" && t !== "segmented" && /* @__PURE__ */ e("span", { style: P, title: R.full, children: R.display }),
665
+ t === "versus" && de(),
666
+ t === "segmented" && /* @__PURE__ */ e("span", { style: P, title: R.full, children: R.display })
667
+ ]
668
+ }
669
+ ),
670
+ /* @__PURE__ */ u(
671
+ D,
672
+ {
673
+ definition: { display: "flex", justify: "between", align: "center" },
674
+ className: `gloss-metric-card__zone-c ${F}`,
675
+ style: { minHeight: 18, flexShrink: 0, zIndex: 2, position: "relative" },
676
+ children: [
677
+ /* @__PURE__ */ e("span", { style: ae, children: o }),
678
+ G && l?.value != null ? /* @__PURE__ */ e("span", { style: {
679
+ backgroundColor: "rgba(255,255,255,0.78)",
680
+ backdropFilter: "blur(4px)",
681
+ WebkitBackdropFilter: "blur(4px)",
682
+ borderRadius: 4,
683
+ display: "inline-flex",
684
+ flexShrink: 0
685
+ }, children: /* @__PURE__ */ e(j, { value: l?.value, direction: l?.direction }) }) : /* @__PURE__ */ e(j, { value: l?.value, direction: l?.direction })
686
+ ]
687
+ }
688
+ ),
689
+ t === "segmented" && fe()
690
+ ] });
691
+ };
692
+ Pe.displayName = "MetricCard";
693
+ const A = ({
694
+ groupId: i,
695
+ options: n,
696
+ selectedId: t,
697
+ defaultId: a,
698
+ onSelect: f,
699
+ pinnedId: s,
700
+ onPin: r,
701
+ isOpen: l = !1,
702
+ onOpenChange: o,
703
+ disableHover: c = !1
704
+ }) => {
705
+ const d = $(null), h = l, m = n.find((g) => g.id === t), x = !!m, p = m || n.find((g) => g.id === s) || n.find((g) => g.id === a) || n[0], w = B(() => {
706
+ if (!p || !["7d", "30d", "60d", "90d", "mtd", "qtd", "ytd", "lytd"].includes(p.id))
707
+ return "";
708
+ const { start: b, end: k } = ve(p.id);
709
+ return ke(b, k, /* @__PURE__ */ new Date());
710
+ }, [p]), y = C(() => {
711
+ c || o && o(i, !0);
712
+ }, [i, o, c]), S = C(() => {
713
+ c || o && o(i, !1);
714
+ }, [i, o, c]), L = C(() => {
715
+ o && o(i, !1);
716
+ }, [i, o]), W = C(() => {
717
+ o && o(i, !h);
718
+ }, [i, h, o]), O = C((g) => {
719
+ f(g), L();
720
+ }, [f, L]), I = C((g, b) => {
721
+ g.stopPropagation(), r && r(b);
722
+ }, [r]), z = /* @__PURE__ */ u(
723
+ E,
724
+ {
725
+ ref: d,
726
+ onMouseEnter: y,
727
+ onMouseLeave: S,
728
+ sx: { position: "relative", display: "inline-flex" },
729
+ children: [
730
+ /* @__PURE__ */ e(
731
+ X,
732
+ {
733
+ label: p?.label,
734
+ onClick: W,
735
+ deleteIcon: /* @__PURE__ */ e(
736
+ $e,
737
+ {
738
+ sx: {
739
+ transform: h ? "rotate(180deg)" : "none",
740
+ transition: "transform 200ms"
741
+ }
742
+ }
743
+ ),
744
+ onDelete: () => {
745
+ },
746
+ variant: "outlined",
747
+ color: x ? "primary" : "default",
748
+ size: "small",
749
+ sx: {
750
+ cursor: "pointer",
751
+ fontWeight: x ? 600 : 400,
752
+ "& .MuiChip-deleteIcon": {
753
+ fontSize: "16px",
754
+ marginLeft: "-4px",
755
+ marginRight: "4px",
756
+ color: x ? "primary.main" : "action.active"
757
+ },
758
+ "&:hover": {
759
+ borderColor: "primary.main"
760
+ }
761
+ }
762
+ }
763
+ ),
764
+ /* @__PURE__ */ e(
765
+ Ie,
766
+ {
767
+ open: h,
768
+ anchorEl: d.current,
769
+ placement: "bottom-start",
770
+ disablePortal: !0,
771
+ sx: { zIndex: 1300 },
772
+ children: /* @__PURE__ */ e(
773
+ ze,
774
+ {
775
+ elevation: 8,
776
+ onMouseEnter: y,
777
+ onMouseLeave: S,
778
+ sx: {
779
+ minWidth: 120,
780
+ mt: 0.5,
781
+ py: 0.5
782
+ },
783
+ children: /* @__PURE__ */ e(Me, { dense: !0, children: n.map((g) => {
784
+ const b = t === g.id, k = s === g.id;
785
+ return /* @__PURE__ */ u(
786
+ Re,
787
+ {
788
+ onClick: () => O(g.id),
789
+ selected: b,
790
+ sx: {
791
+ display: "flex",
792
+ alignItems: "center",
793
+ justifyContent: "space-between",
794
+ gap: 1,
795
+ py: 0.75,
796
+ minHeight: 36
797
+ },
798
+ children: [
799
+ /* @__PURE__ */ u(E, { sx: { display: "flex", alignItems: "center", gap: 1 }, children: [
800
+ b && /* @__PURE__ */ e(Oe, { fontSize: "small", color: "primary", sx: { fontSize: 14 } }),
801
+ /* @__PURE__ */ e(
802
+ Le,
803
+ {
804
+ primary: g.label,
805
+ primaryTypographyProps: {
806
+ fontSize: 13,
807
+ fontWeight: b ? 600 : 400,
808
+ sx: { ml: b ? 0 : 2.5 }
809
+ }
810
+ }
811
+ )
812
+ ] }),
813
+ /* @__PURE__ */ e(
814
+ Te,
815
+ {
816
+ size: "small",
817
+ onClick: (T) => I(T, g.id),
818
+ sx: {
819
+ p: 0.25,
820
+ opacity: k ? 1 : 0,
821
+ transition: "opacity 200ms",
822
+ ".MuiMenuItem-root:hover &": {
823
+ opacity: 1
824
+ }
825
+ },
826
+ title: k ? "Unpin as default" : "Set as default",
827
+ children: k ? /* @__PURE__ */ e(Be, { fontSize: "small", color: "warning", sx: { fontSize: 14 } }) : /* @__PURE__ */ e(We, { fontSize: "small", sx: { fontSize: 14 } })
828
+ }
829
+ )
830
+ ]
831
+ },
832
+ g.id
833
+ );
834
+ }) })
835
+ }
836
+ )
837
+ }
838
+ )
839
+ ]
840
+ }
841
+ );
842
+ return w ? /* @__PURE__ */ e(
843
+ De,
844
+ {
845
+ title: w,
846
+ placement: "top-start",
847
+ slotProps: {
848
+ popper: {
849
+ modifiers: [{ name: "offset", options: { offset: [0, -9] } }]
850
+ }
851
+ },
852
+ children: z
853
+ }
854
+ ) : z;
855
+ };
856
+ A.displayName = "ExpandableChip";
857
+ function Ve({
858
+ selectedPreset: i,
859
+ onSelect: n,
860
+ pinnedPreset: t = "30d",
861
+ onPin: a,
862
+ openGroup: f,
863
+ onOpenChange: s,
864
+ disableHover: r = !1,
865
+ showCalendarEntry: l = !0,
866
+ calendarEntry: o
867
+ }) {
868
+ const c = i === "today";
869
+ return /* @__PURE__ */ u(E, { className: "hybrid-date-picker__quick-bar", children: [
870
+ /* @__PURE__ */ e(
871
+ X,
872
+ {
873
+ label: "Today",
874
+ size: "small",
875
+ variant: c ? "filled" : "outlined",
876
+ color: c ? "primary" : "default",
877
+ onClick: () => n("today"),
878
+ sx: {
879
+ fontWeight: c ? 600 : 400,
880
+ cursor: "pointer"
881
+ }
882
+ }
883
+ ),
884
+ /* @__PURE__ */ e(
885
+ A,
886
+ {
887
+ groupId: "rolling",
888
+ options: we,
889
+ selectedId: i,
890
+ defaultId: t,
891
+ onSelect: n,
892
+ pinnedId: t,
893
+ onPin: a,
894
+ isOpen: f === "rolling",
895
+ onOpenChange: s,
896
+ disableHover: r
897
+ }
898
+ ),
899
+ /* @__PURE__ */ e(
900
+ A,
901
+ {
902
+ groupId: "period",
903
+ options: Se,
904
+ selectedId: i,
905
+ defaultId: t,
906
+ onSelect: n,
907
+ pinnedId: t,
908
+ onPin: a,
909
+ isOpen: f === "period",
910
+ onOpenChange: s,
911
+ disableHover: r
912
+ }
913
+ ),
914
+ l && /* @__PURE__ */ u(K, { children: [
915
+ /* @__PURE__ */ e(Ne, { orientation: "vertical", flexItem: !0, sx: { mx: 0.5 } }),
916
+ o
917
+ ] })
918
+ ] });
919
+ }
920
+ Ve.displayName = "TimeframeQuickBar";
921
+ export {
922
+ ee as B,
923
+ te as D,
924
+ A as E,
925
+ Pe as M,
926
+ re as O,
927
+ ie as S,
928
+ j as T,
929
+ H as a,
930
+ Ve as b,
931
+ je as e,
932
+ Ee as u
933
+ };