@meetreeve/ui 0.21.0 → 0.23.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,913 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/charts/index.ts
22
+ var charts_exports = {};
23
+ __export(charts_exports, {
24
+ AreaChart: () => AreaChart,
25
+ BAR_CATEGORY_GAP: () => BAR_CATEGORY_GAP,
26
+ BAR_STANDARD: () => BAR_STANDARD,
27
+ BarChart: () => BarChart,
28
+ CHART_SERIES_COUNT: () => CHART_SERIES_COUNT,
29
+ ChartCard: () => ChartCard,
30
+ ChartContainer: () => ChartContainer,
31
+ ChartSkeleton: () => ChartSkeleton,
32
+ ChartTooltip: () => ChartTooltip,
33
+ ChartTooltipContent: () => ChartTooltipContent,
34
+ DASHBOARD_GRID_CSS: () => DASHBOARD_GRID_CSS,
35
+ DASHBOARD_TIERS: () => DASHBOARD_TIERS,
36
+ DashboardGrid: () => DashboardGrid,
37
+ DonutChart: () => DonutChart,
38
+ KpiCard: () => KpiCard,
39
+ LineChart: () => LineChart,
40
+ RadialChart: () => RadialChart,
41
+ Sparkline: () => Sparkline,
42
+ barValueLabel: () => barValueLabel,
43
+ chartColor: () => chartColor,
44
+ chartConfig: () => chartConfig,
45
+ chartPalette: () => chartPalette,
46
+ chartTokens: () => chartTokens,
47
+ dashboardSpan: () => dashboardSpan,
48
+ deltaTone: () => deltaTone,
49
+ useChart: () => useChart,
50
+ usePrefersReducedMotion: () => usePrefersReducedMotion,
51
+ withAlpha: () => withAlpha
52
+ });
53
+ module.exports = __toCommonJS(charts_exports);
54
+
55
+ // src/charts/theme.ts
56
+ var CHART_SERIES_COUNT = 8;
57
+ function chartColor(index) {
58
+ return `var(--chart-${index % CHART_SERIES_COUNT + 1})`;
59
+ }
60
+ var chartPalette = Array.from({ length: CHART_SERIES_COUNT }, (_, i) => chartColor(i));
61
+ var chartTokens = {
62
+ positive: "var(--chart-positive)",
63
+ negative: "var(--chart-negative)",
64
+ // Fall back to the shadcn tokens every host has, so grid and ticks still
65
+ // render when a host defines only the series colours.
66
+ grid: "var(--chart-grid, var(--border))",
67
+ muted: "var(--chart-muted, var(--muted-foreground))",
68
+ foreground: "var(--foreground)",
69
+ card: "var(--card)"
70
+ };
71
+ function withAlpha(color, percent) {
72
+ return `color-mix(in srgb, ${color} ${percent}%, transparent)`;
73
+ }
74
+ var chartConfig = {
75
+ tooltip: {
76
+ background: chartTokens.card,
77
+ border: withAlpha(chartColor(0), 20),
78
+ text: chartTokens.foreground,
79
+ label: chartTokens.muted
80
+ },
81
+ grid: { stroke: chartTokens.grid },
82
+ axis: { stroke: chartTokens.grid, tick: chartTokens.muted, fontSize: 11 }
83
+ };
84
+
85
+ // src/charts/chart.tsx
86
+ var import_react2 = require("react");
87
+ var import_recharts = require("recharts");
88
+
89
+ // src/lib/cn.ts
90
+ function cn(...inputs) {
91
+ const out = [];
92
+ for (const input of inputs) {
93
+ if (!input) continue;
94
+ if (typeof input === "string" || typeof input === "number") {
95
+ out.push(String(input));
96
+ } else if (Array.isArray(input)) {
97
+ const nested = cn(...input);
98
+ if (nested) out.push(nested);
99
+ } else if (typeof input === "object") {
100
+ for (const [key, value] of Object.entries(input)) {
101
+ if (value) out.push(key);
102
+ }
103
+ }
104
+ }
105
+ return out.join(" ");
106
+ }
107
+
108
+ // src/lib/use-media-query.ts
109
+ var import_react = require("react");
110
+ function useMediaQuery(query) {
111
+ const subscribe = (0, import_react.useCallback)(
112
+ (onChange) => {
113
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
114
+ return () => {
115
+ };
116
+ }
117
+ const mql = window.matchMedia(query);
118
+ mql.addEventListener("change", onChange);
119
+ return () => mql.removeEventListener("change", onChange);
120
+ },
121
+ [query]
122
+ );
123
+ const getSnapshot = () => typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(query).matches : false;
124
+ return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, () => false);
125
+ }
126
+
127
+ // src/charts/chart.tsx
128
+ var import_jsx_runtime = require("react/jsx-runtime");
129
+ var ChartContext = (0, import_react2.createContext)(null);
130
+ function useChart() {
131
+ const ctx = (0, import_react2.useContext)(ChartContext);
132
+ if (!ctx) throw new Error("useChart must be used within a <ChartContainer />");
133
+ return ctx;
134
+ }
135
+ function usePrefersReducedMotion() {
136
+ return useMediaQuery("(prefers-reduced-motion: reduce)");
137
+ }
138
+ function ChartContainer({ config = {}, height = 300, loading = false, className, children }) {
139
+ const chartId = `chart-${(0, import_react2.useId)().replace(/:/g, "")}`;
140
+ const vars = Object.fromEntries(
141
+ Object.entries(config).filter(([, c]) => c.color).map(([key, c]) => [`--color-${key}`, c.color])
142
+ );
143
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { "data-slot": "chart", "data-chart": chartId, className: cn("w-full", className), style: { ...vars, height }, children: loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartSkeleton, { height }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_recharts.ResponsiveContainer, { width: "100%", height, children }) }) });
144
+ }
145
+ function ChartSkeleton({ height = 300 }) {
146
+ const reduced = usePrefersReducedMotion();
147
+ const bars = [0.45, 0.7, 0.55, 0.85, 0.6, 0.75, 0.5];
148
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
149
+ "div",
150
+ {
151
+ role: "status",
152
+ "aria-label": "Loading chart",
153
+ "data-testid": "chart-skeleton",
154
+ className: cn("flex w-full items-end gap-2", !reduced && "animate-pulse"),
155
+ style: { height },
156
+ children: bars.map((h, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex-1 rounded-t-md", style: { height: `${h * 100}%`, background: "var(--muted)" } }, i))
157
+ }
158
+ );
159
+ }
160
+ function ChartTooltipContent({ active, payload, label, formatter }) {
161
+ if (!active || !payload?.length) return null;
162
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
163
+ "div",
164
+ {
165
+ className: "rounded-lg px-3 py-2 text-xs shadow-xl",
166
+ style: { background: chartConfig.tooltip.background, border: `1px solid ${chartConfig.tooltip.border}` },
167
+ children: [
168
+ label != null && label !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mb-1 font-medium", style: { color: chartConfig.tooltip.label }, children: label }),
169
+ payload.map((entry, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "flex items-center gap-2", style: { color: chartConfig.tooltip.text }, children: [
170
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "inline-block h-2 w-2 rounded-full", style: { backgroundColor: entry.color } }),
171
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: chartConfig.tooltip.label }, children: [
172
+ entry.name,
173
+ ":"
174
+ ] }),
175
+ " ",
176
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-medium", children: formatter ? formatter(entry.value, entry.name) : entry.value.toLocaleString() })
177
+ ] }, i))
178
+ ]
179
+ }
180
+ );
181
+ }
182
+ var ChartTooltip = import_recharts.Tooltip;
183
+
184
+ // src/charts/area-chart.tsx
185
+ var import_react3 = require("react");
186
+ var import_recharts2 = require("recharts");
187
+
188
+ // src/charts/patterns.tsx
189
+ var import_jsx_runtime2 = require("react/jsx-runtime");
190
+ function fillId(chartId, dataKey, variant) {
191
+ return `${chartId}-${variant}-${dataKey.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
192
+ }
193
+ function AreaFill({ id, variant, color }) {
194
+ switch (variant) {
195
+ case "gradient":
196
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
197
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 0.3 }),
198
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0 })
199
+ ] });
200
+ case "solid":
201
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("linearGradient", { id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
202
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "0%", stopColor: color, stopOpacity: 0.15 }),
203
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("stop", { offset: "100%", stopColor: color, stopOpacity: 0.15 })
204
+ ] });
205
+ case "dotted":
206
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pattern", { id, width: "6", height: "6", patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "3", cy: "3", r: "1", fill: color, fillOpacity: 0.45 }) });
207
+ case "hatched":
208
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("pattern", { id, width: "8", height: "8", patternUnits: "userSpaceOnUse", patternTransform: "rotate(20)", children: [
209
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { width: "8", height: "8", fill: color, fillOpacity: 0.06 }),
210
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { width: "4", height: "8", fill: color, fillOpacity: 0.22 })
211
+ ] });
212
+ case "lines":
213
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pattern", { id, width: "5", height: "5", patternUnits: "userSpaceOnUse", patternTransform: "rotate(45)", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "0", y1: "0", x2: "0", y2: "5", stroke: color, strokeOpacity: 0.35, strokeWidth: 1 }) });
214
+ }
215
+ }
216
+ function GlowFilter({ id }) {
217
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("filter", { id, filterUnits: "userSpaceOnUse", x: "0", y: "0", width: "100%", height: "100%", children: [
218
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("feGaussianBlur", { stdDeviation: "4", result: "blur" }),
219
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("feMerge", { children: [
220
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("feMergeNode", { in: "blur" }),
221
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("feMergeNode", { in: "SourceGraphic" })
222
+ ] })
223
+ ] });
224
+ }
225
+
226
+ // src/charts/area-chart.tsx
227
+ var import_jsx_runtime3 = require("react/jsx-runtime");
228
+ function AreaChart({
229
+ data,
230
+ xKey,
231
+ series,
232
+ height = 300,
233
+ showGrid = false,
234
+ showLegend = false,
235
+ showYAxis = true,
236
+ tooltipFormatter,
237
+ yTickFormatter,
238
+ variant = "gradient",
239
+ curve = "monotone",
240
+ stack = "none",
241
+ loading = false
242
+ }) {
243
+ const chartId = `area-${(0, import_react3.useId)().replace(/:/g, "")}`;
244
+ const animate = !usePrefersReducedMotion();
245
+ const colorOf = (s, i) => s.color ?? chartColor(i);
246
+ const variantOf = (s) => s.variant ?? variant;
247
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
248
+ import_recharts2.AreaChart,
249
+ {
250
+ data,
251
+ margin: { top: 8, right: 8, left: showYAxis ? -12 : 8, bottom: 0 },
252
+ stackOffset: stack === "expanded" ? "expand" : void 0,
253
+ children: [
254
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("defs", { children: series.map((s, i) => {
255
+ const v = variantOf(s);
256
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AreaFill, { id: fillId(chartId, s.dataKey, v), variant: v, color: colorOf(s, i) }, s.dataKey);
257
+ }) }),
258
+ showGrid && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.CartesianGrid, { strokeDasharray: "3 3", stroke: chartConfig.grid.stroke }),
259
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
260
+ import_recharts2.XAxis,
261
+ {
262
+ dataKey: xKey,
263
+ stroke: chartConfig.axis.stroke,
264
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
265
+ tickLine: false,
266
+ axisLine: false
267
+ }
268
+ ),
269
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
270
+ import_recharts2.YAxis,
271
+ {
272
+ hide: !showYAxis,
273
+ stroke: chartConfig.axis.stroke,
274
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
275
+ tickFormatter: yTickFormatter,
276
+ tickLine: false,
277
+ axisLine: false
278
+ }
279
+ ),
280
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
281
+ import_recharts2.Tooltip,
282
+ {
283
+ content: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ChartTooltipContent, { formatter: tooltipFormatter }),
284
+ cursor: { stroke: withAlpha(chartColor(0), 20) }
285
+ }
286
+ ),
287
+ showLegend && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_recharts2.Legend, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } }),
288
+ series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
289
+ import_recharts2.Area,
290
+ {
291
+ type: curve,
292
+ dataKey: s.dataKey,
293
+ name: s.name,
294
+ stackId: s.stackId ?? (stack === "none" ? void 0 : "stack"),
295
+ stroke: colorOf(s, i),
296
+ strokeWidth: 2,
297
+ fill: `url(#${fillId(chartId, s.dataKey, variantOf(s))})`,
298
+ dot: false,
299
+ activeDot: { r: 4, fill: colorOf(s, i), stroke: "var(--background)", strokeWidth: 2 },
300
+ isAnimationActive: animate
301
+ },
302
+ s.dataKey
303
+ ))
304
+ ]
305
+ }
306
+ ) });
307
+ }
308
+
309
+ // src/charts/line-chart.tsx
310
+ var import_react4 = require("react");
311
+ var import_recharts3 = require("recharts");
312
+ var import_jsx_runtime4 = require("react/jsx-runtime");
313
+ function LineChart({
314
+ data,
315
+ xKey,
316
+ series,
317
+ height = 300,
318
+ showGrid = false,
319
+ showLegend = false,
320
+ showYAxis = true,
321
+ tooltipFormatter,
322
+ yTickFormatter,
323
+ curve = "monotone",
324
+ loading = false
325
+ }) {
326
+ const chartId = `line-${(0, import_react4.useId)().replace(/:/g, "")}`;
327
+ const animate = !usePrefersReducedMotion();
328
+ const glowId = (s) => `${chartId}-glow-${s.dataKey.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
329
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_recharts3.LineChart, { data, margin: { top: 8, right: 8, left: showYAxis ? -12 : 8, bottom: 0 }, children: [
330
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("defs", { children: series.filter((s) => s.glow).map((s) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(GlowFilter, { id: glowId(s) }, s.dataKey)) }),
331
+ showGrid && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.CartesianGrid, { strokeDasharray: "3 3", stroke: chartConfig.grid.stroke, vertical: false }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
333
+ import_recharts3.XAxis,
334
+ {
335
+ dataKey: xKey,
336
+ stroke: chartConfig.axis.stroke,
337
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
338
+ tickLine: false,
339
+ axisLine: false
340
+ }
341
+ ),
342
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
343
+ import_recharts3.YAxis,
344
+ {
345
+ hide: !showYAxis,
346
+ stroke: chartConfig.axis.stroke,
347
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
348
+ tickFormatter: yTickFormatter,
349
+ tickLine: false,
350
+ axisLine: false
351
+ }
352
+ ),
353
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
354
+ import_recharts3.Tooltip,
355
+ {
356
+ content: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ChartTooltipContent, { formatter: tooltipFormatter }),
357
+ cursor: { stroke: withAlpha(chartColor(0), 20) }
358
+ }
359
+ ),
360
+ showLegend && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_recharts3.Legend, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } }),
361
+ series.map((s, i) => {
362
+ const color = s.color ?? chartColor(i);
363
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
364
+ import_recharts3.Line,
365
+ {
366
+ type: curve,
367
+ dataKey: s.dataKey,
368
+ name: s.name,
369
+ stroke: color,
370
+ strokeWidth: 2,
371
+ strokeDasharray: s.dashed ? "5 4" : void 0,
372
+ filter: s.glow ? `url(#${glowId(s)})` : void 0,
373
+ dot: s.dots ? { r: 3, fill: color, strokeWidth: 0 } : false,
374
+ activeDot: { r: 4, fill: color, stroke: "var(--background)", strokeWidth: 2 },
375
+ isAnimationActive: animate
376
+ },
377
+ s.dataKey
378
+ );
379
+ })
380
+ ] }) });
381
+ }
382
+
383
+ // src/charts/bar-chart.tsx
384
+ var import_recharts4 = require("recharts");
385
+ var import_jsx_runtime5 = require("react/jsx-runtime");
386
+ var BAR_CATEGORY_GAP = "8.33%";
387
+ var BAR_LABEL_FONT_SIZE = chartConfig.axis.fontSize;
388
+ var BAR_STANDARD = {
389
+ barCategoryGap: BAR_CATEGORY_GAP
390
+ };
391
+ var BAR_LABEL_STYLE = {
392
+ fill: chartTokens.foreground,
393
+ fontSize: BAR_LABEL_FONT_SIZE,
394
+ fontWeight: 500
395
+ };
396
+ function barValueLabel(format = (v) => v.toLocaleString(), {
397
+ slack = 0.2,
398
+ orientation = "vertical"
399
+ } = {}) {
400
+ function BarValueLabel({ value, offset = 6, viewBox }) {
401
+ const n = typeof value === "number" ? value : Number(value);
402
+ if (value == null || value === "" || !Number.isFinite(n) || !viewBox || !("width" in viewBox)) return null;
403
+ const { x = 0, y = 0, width = 0, height = 0 } = viewBox;
404
+ const text = format(n);
405
+ if (orientation === "horizontal") {
406
+ if (Math.abs(height) < BAR_LABEL_FONT_SIZE) return null;
407
+ const negative = width < 0;
408
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
409
+ "text",
410
+ {
411
+ x: x + width + (negative ? -offset : offset),
412
+ y: y + height / 2,
413
+ dominantBaseline: "central",
414
+ textAnchor: negative ? "end" : "start",
415
+ ...BAR_LABEL_STYLE,
416
+ children: text
417
+ }
418
+ );
419
+ }
420
+ const barWidth = Math.abs(width);
421
+ const room = barWidth + (typeof slack === "function" ? slack(barWidth) : barWidth * slack);
422
+ if (text.length * BAR_LABEL_FONT_SIZE * 0.6 > room) return null;
423
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("text", { x: x + width / 2, y: Math.min(y, y + height) - offset, textAnchor: "middle", ...BAR_LABEL_STYLE, children: text });
424
+ }
425
+ return BarValueLabel;
426
+ }
427
+ var GROUPED_BAR_GAP = 4;
428
+ function BarChart({
429
+ data,
430
+ xKey,
431
+ series,
432
+ height = 300,
433
+ showGrid = false,
434
+ showLegend = false,
435
+ tooltipFormatter,
436
+ labelFormatter,
437
+ showValueLabels = true,
438
+ showYAxis = false,
439
+ loading = false
440
+ }) {
441
+ const animate = !usePrefersReducedMotion();
442
+ const grouped = series.length > 1;
443
+ const formatLabel = labelFormatter ?? tooltipFormatter ?? ((v) => v.toLocaleString());
444
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
445
+ import_recharts4.BarChart,
446
+ {
447
+ data,
448
+ barCategoryGap: BAR_CATEGORY_GAP,
449
+ barGap: GROUPED_BAR_GAP,
450
+ margin: {
451
+ top: showValueLabels ? 22 : 8,
452
+ right: 8,
453
+ left: showYAxis ? -12 : 8,
454
+ bottom: 0
455
+ },
456
+ children: [
457
+ showGrid && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.CartesianGrid, { strokeDasharray: "3 3", stroke: chartConfig.grid.stroke, vertical: false }),
458
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
459
+ import_recharts4.XAxis,
460
+ {
461
+ dataKey: xKey,
462
+ stroke: chartConfig.axis.stroke,
463
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
464
+ tickLine: false,
465
+ axisLine: false
466
+ }
467
+ ),
468
+ showYAxis ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
469
+ import_recharts4.YAxis,
470
+ {
471
+ stroke: chartConfig.axis.stroke,
472
+ tick: { fill: chartConfig.axis.tick, fontSize: chartConfig.axis.fontSize },
473
+ tickLine: false,
474
+ axisLine: false
475
+ }
476
+ ) : (
477
+ // Hidden scale: without visible ticks there is no reason to round the
478
+ // top up to a "nice" number, so the tallest bar reaches the label row.
479
+ // An all-zero series still gets a [0, 1] scale, keeping its "0" labels
480
+ // on the baseline instead of floating mid-chart; an all-negative series
481
+ // tops out at 0 so its bars span the full height below the baseline
482
+ // (DEV-16977).
483
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.YAxis, { hide: true, domain: [(min) => Math.min(0, min), (max) => max < 0 ? 0 : max || 1] })
484
+ ),
485
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
486
+ import_recharts4.Tooltip,
487
+ {
488
+ content: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChartTooltipContent, { formatter: tooltipFormatter }),
489
+ cursor: { fill: withAlpha(chartColor(0), 6) }
490
+ }
491
+ ),
492
+ showLegend && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.Legend, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } }),
493
+ series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
494
+ import_recharts4.Bar,
495
+ {
496
+ dataKey: s.dataKey,
497
+ name: s.name,
498
+ fill: s.color ?? chartColor(i),
499
+ radius: s.radius ?? 4,
500
+ isAnimationActive: animate,
501
+ children: showValueLabels && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
502
+ import_recharts4.LabelList,
503
+ {
504
+ dataKey: s.dataKey,
505
+ position: "top",
506
+ content: barValueLabel((v) => formatLabel(v, s.name), {
507
+ slack: grouped ? () => GROUPED_BAR_GAP : 0.2
508
+ })
509
+ }
510
+ )
511
+ },
512
+ s.dataKey
513
+ ))
514
+ ]
515
+ }
516
+ ) });
517
+ }
518
+
519
+ // src/charts/donut-chart.tsx
520
+ var import_recharts5 = require("recharts");
521
+ var import_jsx_runtime6 = require("react/jsx-runtime");
522
+ function DonutChart({
523
+ data,
524
+ height = 300,
525
+ innerRadius = 60,
526
+ outerRadius = 90,
527
+ showLegend = true,
528
+ tooltipFormatter,
529
+ centerLabel,
530
+ centerValue,
531
+ loading = false
532
+ }) {
533
+ const animate = !usePrefersReducedMotion();
534
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_recharts5.PieChart, { children: [
535
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_recharts5.Tooltip, { content: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ChartTooltipContent, { formatter: tooltipFormatter }) }),
536
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
537
+ import_recharts5.Pie,
538
+ {
539
+ data,
540
+ cx: "50%",
541
+ cy: "50%",
542
+ innerRadius,
543
+ outerRadius,
544
+ paddingAngle: 2,
545
+ dataKey: "value",
546
+ nameKey: "name",
547
+ stroke: "none",
548
+ isAnimationActive: animate,
549
+ children: [
550
+ data.map((entry, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_recharts5.Cell, { fill: entry.fill ?? chartColor(i) }, i)),
551
+ (centerLabel || centerValue) && // Anchored to the pie's own centre: a bottom legend shifts the pie
552
+ // up, so the SVG's 50% would sit below the hole. Recharts 3 hands a
553
+ // Pie's Label the plot box (legend space already removed), and the
554
+ // pie's cx/cy="50%" are relative to that same box.
555
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
556
+ import_recharts5.Label,
557
+ {
558
+ position: "center",
559
+ content: ({ viewBox }) => {
560
+ const { x = 0, y = 0, width = 0, height: height2 = 0 } = viewBox ?? {};
561
+ const cx = x + width / 2;
562
+ const cy = y + height2 / 2;
563
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("text", { x: cx, y: cy, textAnchor: "middle", dominantBaseline: "middle", "data-testid": "donut-center", children: [
564
+ centerValue && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("tspan", { x: cx, dy: centerLabel ? -8 : 0, fill: chartTokens.foreground, fontSize: 20, fontWeight: 600, children: centerValue }),
565
+ centerLabel && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("tspan", { x: cx, dy: centerValue ? 22 : 0, fill: chartTokens.muted, fontSize: 11, children: centerLabel })
566
+ ] });
567
+ }
568
+ }
569
+ )
570
+ ]
571
+ }
572
+ ),
573
+ showLegend && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_recharts5.Legend, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } })
574
+ ] }) });
575
+ }
576
+
577
+ // src/charts/radial-chart.tsx
578
+ var import_recharts6 = require("recharts");
579
+ var import_jsx_runtime7 = require("react/jsx-runtime");
580
+ function RadialChart({ data, max = 100, height = 220, centerValue, centerLabel, loading = false }) {
581
+ const animate = !usePrefersReducedMotion();
582
+ const rows = data.map((d, i) => ({ ...d, fill: d.fill ?? chartColor(i) }));
583
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_recharts6.RadialBarChart, { data: rows, innerRadius: "55%", outerRadius: "100%", startAngle: 90, endAngle: -270, barSize: 10, children: [
584
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_recharts6.PolarAngleAxis, { type: "number", domain: [0, max], tick: false, axisLine: false }),
585
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_recharts6.RadialBar, { dataKey: "value", background: { fill: "var(--muted)" }, cornerRadius: 6, isAnimationActive: animate }),
586
+ (centerLabel || centerValue) && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("text", { x: "50%", y: "50%", textAnchor: "middle", dominantBaseline: "middle", children: [
587
+ centerValue && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tspan", { x: "50%", dy: "-6", fill: chartTokens.foreground, fontSize: 20, fontWeight: 600, children: centerValue }),
588
+ centerLabel && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("tspan", { x: "50%", dy: centerValue ? "20" : "0", fill: chartTokens.muted, fontSize: 11, children: centerLabel })
589
+ ] })
590
+ ] }) });
591
+ }
592
+
593
+ // src/charts/sparkline.tsx
594
+ var import_react5 = require("react");
595
+ var import_recharts7 = require("recharts");
596
+ var import_jsx_runtime8 = require("react/jsx-runtime");
597
+ function Sparkline({ values, color = chartColor(0), height = 32, filled = true }) {
598
+ const chartId = `spark-${(0, import_react5.useId)().replace(/:/g, "")}`;
599
+ const data = values.filter(Number.isFinite).map((v, i) => ({ i, v }));
600
+ if (data.length < 2) return null;
601
+ const id = fillId(chartId, "v", "gradient");
602
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "aria-hidden": "true", "data-testid": "sparkline", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ChartContainer, { height, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_recharts7.AreaChart, { data, margin: { top: 2, right: 0, left: 0, bottom: 2 }, children: [
603
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AreaFill, { id, variant: "gradient", color }) }),
604
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_recharts7.YAxis, { hide: true, domain: ["dataMin", "dataMax"] }),
605
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
606
+ import_recharts7.Area,
607
+ {
608
+ type: "monotone",
609
+ dataKey: "v",
610
+ stroke: color,
611
+ strokeWidth: 1.5,
612
+ fill: filled ? `url(#${id})` : "none",
613
+ dot: false,
614
+ isAnimationActive: false
615
+ }
616
+ )
617
+ ] }) }) });
618
+ }
619
+
620
+ // src/charts/kpi-card.tsx
621
+ var import_lucide_react = require("lucide-react");
622
+
623
+ // src/info-tip.tsx
624
+ var import_popover = require("@base-ui/react/popover");
625
+
626
+ // src/tokens.ts
627
+ var MIN_SIZES = {
628
+ /** WCAG 2.5.5 minimum interactive target, px. Applies to BOTH width and height. */
629
+ touchTarget: 44,
630
+ /** Floor width for the always-inline search field on mobile, px. */
631
+ searchInput: 200,
632
+ /** Generic minimum width/height for a secondary control (button, select), px. */
633
+ control: 44,
634
+ /** Max width of the brand wordmark before it truncates, px. */
635
+ // DEV-5340: scaled with the wordmark's text-sm→text-base bump (180 × 16/14
636
+ // ≈ 206) so the truncation point keeps the same character budget.
637
+ wordmarkMaxWidth: 205
638
+ };
639
+ var TOUCH_TARGET_STYLE = {
640
+ minWidth: MIN_SIZES.touchTarget,
641
+ minHeight: MIN_SIZES.touchTarget
642
+ };
643
+
644
+ // src/info-tip.tsx
645
+ var import_jsx_runtime9 = require("react/jsx-runtime");
646
+ function InfoTip({ children, label = "More information", side = "top", align = "center", className }) {
647
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_popover.Popover.Root, { children: [
648
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
649
+ import_popover.Popover.Trigger,
650
+ {
651
+ openOnHover: true,
652
+ delay: 150,
653
+ closeDelay: 100,
654
+ "aria-label": label,
655
+ style: TOUCH_TARGET_STYLE,
656
+ className: cn(
657
+ "group -my-3.5 inline-flex shrink-0 cursor-help items-center justify-center rounded-full align-middle text-muted-foreground outline-none transition-colors hover:text-foreground data-[popup-open]:text-foreground",
658
+ className
659
+ ),
660
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
661
+ "span",
662
+ {
663
+ "aria-hidden": "true",
664
+ className: "inline-flex size-4 items-center justify-center rounded-full border border-current text-[0.625rem] font-semibold leading-none group-focus-visible:ring-2 group-focus-visible:ring-ring/50",
665
+ children: "?"
666
+ }
667
+ )
668
+ }
669
+ ),
670
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover.Popover.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover.Popover.Positioner, { side, align, sideOffset: 8, collisionPadding: 16, className: "z-50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
671
+ import_popover.Popover.Popup,
672
+ {
673
+ "aria-label": label,
674
+ className: "max-w-[min(20rem,calc(100vw-2rem))] origin-[var(--transform-origin)] rounded-md border border-border bg-popover px-3 py-2 text-left text-xs font-normal leading-relaxed text-popover-foreground shadow-md outline-none transition-[opacity,transform] duration-150 ease-out data-[ending-style]:scale-95 data-[ending-style]:opacity-0 data-[starting-style]:scale-95 data-[starting-style]:opacity-0 motion-reduce:transition-none",
675
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_popover.Popover.Description, { children })
676
+ }
677
+ ) }) })
678
+ ] });
679
+ }
680
+
681
+ // src/charts/kpi-card.tsx
682
+ var import_jsx_runtime10 = require("react/jsx-runtime");
683
+ function deltaTone(delta, polarity = "up-is-good") {
684
+ if (delta == null || !Number.isFinite(delta) || delta === 0 || polarity === "neutral") return "neutral";
685
+ const up = delta > 0;
686
+ return up === (polarity === "up-is-good") ? "positive" : "negative";
687
+ }
688
+ var TONE_COLOR = {
689
+ positive: chartTokens.positive,
690
+ negative: chartTokens.negative,
691
+ neutral: chartTokens.muted
692
+ };
693
+ var defaultDeltaFormat = (d) => `${d > 0 ? "+" : d < 0 ? "\u2212" : ""}${Math.abs(d * 100).toLocaleString("en-US", { maximumFractionDigits: 1 })}%`;
694
+ function KpiCard({
695
+ label,
696
+ value,
697
+ delta,
698
+ deltaLabel,
699
+ deltaFormatter = defaultDeltaFormat,
700
+ polarity = "up-is-good",
701
+ trend,
702
+ info,
703
+ loading = false,
704
+ state = "ok",
705
+ message,
706
+ action,
707
+ className
708
+ }) {
709
+ const tone = deltaTone(delta, polarity);
710
+ const toneColor = TONE_COLOR[tone];
711
+ const Arrow = !delta ? import_lucide_react.Minus : delta > 0 ? import_lucide_react.ArrowUpRight : import_lucide_react.ArrowDownRight;
712
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
713
+ "div",
714
+ {
715
+ "data-slot": "kpi-card",
716
+ "data-state": loading ? "loading" : state,
717
+ className: cn("flex h-full min-w-0 flex-col gap-1 rounded-xl border bg-card p-4 text-card-foreground", className),
718
+ children: [
719
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex min-w-0 items-center gap-1 text-xs font-medium text-muted-foreground", children: [
720
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "truncate", children: label }),
721
+ info && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoTip, { label: "About this metric", children: info })
722
+ ] }),
723
+ loading ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { "aria-label": "Loading", role: "status", className: "flex flex-col gap-2 pt-1", children: [
724
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-7 w-24 animate-pulse rounded-md", style: { background: "var(--muted)" } }),
725
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "h-4 w-16 animate-pulse rounded-md", style: { background: "var(--muted)" } })
726
+ ] }) : state !== "ok" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-1 flex-col items-start gap-2 pt-1", children: [
727
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-sm text-muted-foreground", children: message ?? (state === "setup" ? "Not connected yet." : "No data yet.") }),
728
+ state === "setup" && action
729
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
730
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "truncate text-2xl font-semibold tabular-nums tracking-tight", children: value }),
731
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex min-w-0 items-center gap-2 text-xs", children: [
732
+ delta != null && Number.isFinite(delta) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
733
+ "span",
734
+ {
735
+ "data-testid": "kpi-delta",
736
+ "data-tone": tone,
737
+ className: "inline-flex items-center gap-0.5 rounded-full px-1.5 py-0.5 font-medium tabular-nums",
738
+ style: { color: toneColor, background: withAlpha(toneColor, 12) },
739
+ children: [
740
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Arrow, { "aria-hidden": "true", className: "h-3 w-3" }),
741
+ deltaFormatter(delta)
742
+ ]
743
+ }
744
+ ),
745
+ deltaLabel && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "truncate text-muted-foreground", children: deltaLabel })
746
+ ] }),
747
+ trend && trend.length > 1 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "mt-auto pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Sparkline, { values: trend, color: tone === "neutral" ? chartColor(0) : toneColor }) })
748
+ ] })
749
+ ]
750
+ }
751
+ );
752
+ }
753
+
754
+ // src/charts/chart-card.tsx
755
+ var import_jsx_runtime11 = require("react/jsx-runtime");
756
+ var RANGE_LABEL = { "7d": "7d", "30d": "30d", "90d": "90d", custom: "Custom" };
757
+ var DEFAULT_MESSAGE = {
758
+ empty: "No data for this period.",
759
+ setup: "Connect a source to see this chart.",
760
+ error: "This chart couldn\u2019t load. Try again shortly."
761
+ };
762
+ function ChartCard({
763
+ title,
764
+ subtitle,
765
+ info,
766
+ action,
767
+ range,
768
+ legend,
769
+ state = "ok",
770
+ message,
771
+ setupAction,
772
+ height = 240,
773
+ className,
774
+ children
775
+ }) {
776
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
777
+ "section",
778
+ {
779
+ "data-slot": "chart-card",
780
+ "data-state": state,
781
+ className: cn("flex h-full min-w-0 flex-col gap-3 rounded-xl border bg-card p-4 text-card-foreground", className),
782
+ children: [
783
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("header", { className: "flex min-w-0 flex-wrap items-start justify-between gap-2", children: [
784
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "min-w-0", children: [
785
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("h3", { className: "flex items-center gap-1 text-sm font-semibold", children: [
786
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "truncate", children: title }),
787
+ info && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(InfoTip, { label: "About this chart", children: info })
788
+ ] }),
789
+ subtitle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "truncate text-xs text-muted-foreground", children: subtitle })
790
+ ] }),
791
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "flex items-center gap-2", children: [
792
+ range && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { role: "group", "aria-label": "Date range", className: "inline-flex rounded-lg border p-0.5 text-xs", children: (range.options ?? ["7d", "30d", "90d"]).map((r) => (
793
+ // 44px hit area (the package floor) with a vertical negative
794
+ // margin, so the pill stays compact in the header — same trick
795
+ // as InfoTip.
796
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
797
+ "button",
798
+ {
799
+ type: "button",
800
+ "aria-pressed": range.value === r,
801
+ onClick: () => range.onChange(r),
802
+ className: "inline-flex items-center justify-center",
803
+ style: { ...TOUCH_TARGET_STYLE, marginBlock: -10 },
804
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
805
+ "span",
806
+ {
807
+ className: cn(
808
+ "rounded-md px-2 py-1 font-medium tabular-nums",
809
+ range.value === r ? "bg-muted text-foreground" : "text-muted-foreground"
810
+ ),
811
+ children: RANGE_LABEL[r]
812
+ }
813
+ )
814
+ },
815
+ r
816
+ )
817
+ )) }),
818
+ action
819
+ ] })
820
+ ] }),
821
+ state === "loading" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ChartSkeleton, { height }) : state === "ok" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
822
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "min-w-0", children }),
823
+ legend && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "text-xs text-muted-foreground", children: legend })
824
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
825
+ "div",
826
+ {
827
+ role: state === "error" ? "alert" : void 0,
828
+ className: "flex flex-col items-center justify-center gap-2 rounded-lg border border-dashed p-6 text-center",
829
+ style: { minHeight: Math.min(height, 160) },
830
+ children: [
831
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-sm text-muted-foreground", children: message ?? DEFAULT_MESSAGE[state] }),
832
+ state === "setup" && setupAction
833
+ ]
834
+ }
835
+ )
836
+ ]
837
+ }
838
+ );
839
+ }
840
+
841
+ // src/charts/dashboard-grid.tsx
842
+ var import_jsx_runtime12 = require("react/jsx-runtime");
843
+ var DASHBOARD_TIERS = [
844
+ // Docked desktop pane and up: 4 KPIs per row.
845
+ { minWidth: 880, columns: 12, span: { sm: 3, md: 6, lg: 8, wide: 9, full: 12 } },
846
+ // Tablet: 3 KPIs per row, charts half or full.
847
+ { minWidth: 600, columns: 12, span: { sm: 4, md: 6, lg: 12, wide: 12, full: 12 } },
848
+ // Narrow pane and phones: 2 KPIs per row, every chart full width.
849
+ { minWidth: 320, columns: 6, span: { sm: 3, md: 6, lg: 6, wide: 6, full: 6 } },
850
+ { minWidth: 0, columns: 1, span: { sm: 1, md: 1, lg: 1, wide: 1, full: 1 } }
851
+ ];
852
+ function tierFor(width) {
853
+ return DASHBOARD_TIERS.find((t) => width >= t.minWidth) ?? DASHBOARD_TIERS[DASHBOARD_TIERS.length - 1];
854
+ }
855
+ function dashboardSpan(width, size) {
856
+ const tier = tierFor(width);
857
+ const span = tier.span[size];
858
+ return { columns: tier.columns, span, perRow: Math.floor(tier.columns / span) };
859
+ }
860
+ var SIZES = ["sm", "md", "lg", "wide", "full"];
861
+ function tierRules(t) {
862
+ return [
863
+ `.mf-dash__grid{grid-template-columns:repeat(${t.columns},minmax(0,1fr))}`,
864
+ ...SIZES.map((s) => `.mf-dash__item[data-size=${s}]{grid-column:span ${t.span[s]}/span ${t.span[s]}}`)
865
+ ].join("");
866
+ }
867
+ var DASHBOARD_GRID_CSS = [
868
+ ".mf-dash{container:mf-dash/inline-size}",
869
+ ".mf-dash__grid{display:grid;gap:var(--mf-dash-gap,12px);grid-auto-flow:row dense}",
870
+ ".mf-dash__item{min-width:0}",
871
+ ...[...DASHBOARD_TIERS].reverse().map((t) => t.minWidth === 0 ? tierRules(t) : `@container mf-dash (min-width:${t.minWidth}px){${tierRules(t)}}`)
872
+ ].join("\n");
873
+ function DashboardGridRoot({ className, children }) {
874
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { "data-slot": "dashboard-grid", className: cn("mf-dash", className), children: [
875
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("style", { children: DASHBOARD_GRID_CSS }),
876
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "mf-dash__grid", children })
877
+ ] });
878
+ }
879
+ function DashboardGridItem({ size = "sm", className, children }) {
880
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { "data-size": size, className: cn("mf-dash__item", className), children });
881
+ }
882
+ var DashboardGrid = Object.assign(DashboardGridRoot, { Item: DashboardGridItem });
883
+ // Annotate the CommonJS export names for ESM import in node:
884
+ 0 && (module.exports = {
885
+ AreaChart,
886
+ BAR_CATEGORY_GAP,
887
+ BAR_STANDARD,
888
+ BarChart,
889
+ CHART_SERIES_COUNT,
890
+ ChartCard,
891
+ ChartContainer,
892
+ ChartSkeleton,
893
+ ChartTooltip,
894
+ ChartTooltipContent,
895
+ DASHBOARD_GRID_CSS,
896
+ DASHBOARD_TIERS,
897
+ DashboardGrid,
898
+ DonutChart,
899
+ KpiCard,
900
+ LineChart,
901
+ RadialChart,
902
+ Sparkline,
903
+ barValueLabel,
904
+ chartColor,
905
+ chartConfig,
906
+ chartPalette,
907
+ chartTokens,
908
+ dashboardSpan,
909
+ deltaTone,
910
+ useChart,
911
+ usePrefersReducedMotion,
912
+ withAlpha
913
+ });