@elevasis/ui 2.40.1 → 2.41.1

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.
Files changed (92) hide show
  1. package/dist/api/index.js +4 -6
  2. package/dist/app/index.css +384 -0
  3. package/dist/app/index.d.ts +108 -0
  4. package/dist/app/index.js +17 -27
  5. package/dist/auth/index.css +659 -0
  6. package/dist/auth/index.js +19 -6
  7. package/dist/charts/index.css +533 -0
  8. package/dist/charts/index.js +18 -15
  9. package/dist/{chunk-RXH4D6TY.js → chunk-5M4HSHQ5.js} +631 -2
  10. package/dist/{chunk-TE4P6OSJ.js → chunk-7FJI76OH.js} +1 -1
  11. package/dist/chunk-GMXGDO3I.js +244 -0
  12. package/dist/{chunk-CXY7FMUM.js → chunk-GUKY77FJ.js} +50 -4
  13. package/dist/{chunk-5JYKCULK.js → chunk-NZ2F5RQ4.js} +44 -2
  14. package/dist/{chunk-WF7CONXF.js → chunk-OJJK27GC.js} +658 -6
  15. package/dist/{chunk-RX6RSKWC.js → chunk-QDXTIQT4.js} +29255 -18312
  16. package/dist/{chunk-73EWE2EW.js → chunk-V5HWC5EW.js} +1 -1
  17. package/dist/components/chat/index.js +1 -2
  18. package/dist/components/index.css +149 -149
  19. package/dist/components/index.js +13 -37
  20. package/dist/components/navigation/index.css +659 -0
  21. package/dist/components/navigation/index.js +25 -4
  22. package/dist/features/auth/index.js +14 -38
  23. package/dist/features/clients/index.css +149 -149
  24. package/dist/features/clients/index.js +13 -37
  25. package/dist/features/crm/index.js +13 -37
  26. package/dist/features/dashboard/index.js +13 -37
  27. package/dist/features/delivery/index.js +13 -37
  28. package/dist/features/knowledge/index.css +659 -0
  29. package/dist/features/knowledge/index.js +25 -248
  30. package/dist/features/lead-gen/index.d.ts +81 -0
  31. package/dist/features/lead-gen/index.js +13 -37
  32. package/dist/features/monitoring/index.js +13 -37
  33. package/dist/features/monitoring/requests/index.d.ts +69 -7
  34. package/dist/features/monitoring/requests/index.js +32 -41
  35. package/dist/features/operations/index.d.ts +79 -0
  36. package/dist/features/operations/index.js +13 -37
  37. package/dist/features/seo/index.js +1 -4
  38. package/dist/features/settings/index.js +13 -37
  39. package/dist/hooks/access/index.css +659 -0
  40. package/dist/hooks/access/index.js +19 -5
  41. package/dist/hooks/delivery/index.js +13 -37
  42. package/dist/hooks/index.d.ts +18 -6
  43. package/dist/hooks/index.js +13 -37
  44. package/dist/hooks/published.d.ts +18 -6
  45. package/dist/hooks/published.js +13 -37
  46. package/dist/index.d.ts +151 -7
  47. package/dist/index.js +14 -38
  48. package/dist/initialization/index.js +1 -1
  49. package/dist/knowledge/index.css +659 -0
  50. package/dist/knowledge/index.d.ts +81 -0
  51. package/dist/knowledge/index.js +25 -15
  52. package/dist/layout/index.css +659 -0
  53. package/dist/layout/index.d.ts +18 -2
  54. package/dist/layout/index.js +24 -7
  55. package/dist/organization/index.js +13 -37
  56. package/dist/provider/index.css +384 -0
  57. package/dist/provider/index.d.ts +120 -1
  58. package/dist/provider/index.js +18 -22
  59. package/dist/provider/published.css +533 -0
  60. package/dist/provider/published.d.ts +121 -2
  61. package/dist/provider/published.js +18 -17
  62. package/dist/test-utils/index.js +4 -6
  63. package/dist/theme/index.js +2 -5
  64. package/dist/theme/presets/index.js +1 -2
  65. package/dist/utils/index.js +1 -3
  66. package/package.json +3 -3
  67. package/dist/chunk-3KMDHCAR.js +0 -52
  68. package/dist/chunk-4DRI3G36.js +0 -1016
  69. package/dist/chunk-5EYJ2GIN.js +0 -122
  70. package/dist/chunk-66U7JOWV.js +0 -425
  71. package/dist/chunk-6D4LCJ52.js +0 -10
  72. package/dist/chunk-6EV47QQW.js +0 -340
  73. package/dist/chunk-6ROXVZ3L.js +0 -9
  74. package/dist/chunk-7MTWRSUZ.js +0 -357
  75. package/dist/chunk-7PHY5ONQ.js +0 -85
  76. package/dist/chunk-B2DZLPDL.js +0 -39
  77. package/dist/chunk-CLDCYJQT.js +0 -1
  78. package/dist/chunk-CTJBPF3Z.js +0 -734
  79. package/dist/chunk-DT3QYZVU.js +0 -23
  80. package/dist/chunk-IIMU5YAJ.js +0 -53
  81. package/dist/chunk-IUQAP4IO.js +0 -2131
  82. package/dist/chunk-J3FLIZY4.js +0 -423
  83. package/dist/chunk-K7GKKETO.js +0 -3157
  84. package/dist/chunk-L7GXUSCV.js +0 -215
  85. package/dist/chunk-LJDYY3XB.js +0 -133
  86. package/dist/chunk-NYBEU5TE.js +0 -118
  87. package/dist/chunk-RH5VWWSC.js +0 -624
  88. package/dist/chunk-SJNIOGVX.js +0 -112
  89. package/dist/chunk-TYRUKGGD.js +0 -46
  90. package/dist/chunk-WLOQ4IBG.js +0 -654
  91. package/dist/chunk-X4WBGKJQ.js +0 -138
  92. package/dist/chunk-X7D6SUKR.js +0 -1234
@@ -1,1016 +0,0 @@
1
- import { CenteredErrorState, TrendIndicator, EmptyState, StatCard } from './chunk-CTJBPF3Z.js';
2
- import { CardHeader } from './chunk-S3XR4II4.js';
3
- import { getTimeRangeLabel, getTimeRangeDates, formatBucketTime } from './chunk-RXH4D6TY.js';
4
- import { useElevasisServices } from './chunk-2FTX4WO2.js';
5
- import { useRef, useState, useLayoutEffect, useEffect, useMemo, useCallback } from 'react';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
7
- import { useComputedColorScheme, Group, Text, Box, Stack, Center, Loader, Paper, Button, NumberFormatter, Badge, Space, Tooltip as Tooltip$1, SimpleGrid, Alert, SegmentedControl } from '@mantine/core';
8
- import { ResponsiveContainer, AreaChart, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine as ReferenceLine$1, Area, PieChart, Pie, Cell } from 'recharts';
9
- import { IconActivity, IconDownload, IconChartLine, IconInfoCircle, IconApps, IconPlayerPlay, IconChartBar, IconAlertTriangle, IconRocket, IconAlertCircle } from '@tabler/icons-react';
10
- import { useQuery } from '@tanstack/react-query';
11
-
12
- function ChartFrame({ h, debounceMs = 150, children }) {
13
- const ref = useRef(null);
14
- const [width, setWidth] = useState(0);
15
- useLayoutEffect(() => {
16
- const el = ref.current;
17
- if (!el) return;
18
- const w = el.getBoundingClientRect().width;
19
- if (w > 0) setWidth(w);
20
- }, []);
21
- useEffect(() => {
22
- const el = ref.current;
23
- if (!el) return;
24
- let timeout;
25
- const ro = new ResizeObserver((entries) => {
26
- if (timeout !== void 0) window.clearTimeout(timeout);
27
- const nextWidth = entries[0]?.contentRect.width ?? 0;
28
- timeout = window.setTimeout(() => {
29
- if (nextWidth > 0) setWidth(nextWidth);
30
- }, debounceMs);
31
- });
32
- ro.observe(el);
33
- return () => {
34
- ro.disconnect();
35
- if (timeout !== void 0) window.clearTimeout(timeout);
36
- };
37
- }, [debounceMs]);
38
- return /* @__PURE__ */ jsx("div", { ref, style: { width: "100%", height: h, position: "relative" }, children: width > 0 && /* @__PURE__ */ jsx("div", { style: { width, height: h }, children }) });
39
- }
40
- var THEME_DERIVED = {
41
- grid: "var(--color-border)",
42
- gridLine: "var(--color-border)",
43
- tickText: "var(--mantine-color-dimmed)",
44
- tooltipBg: "var(--glass-background)",
45
- tooltipBorder: "var(--color-border)",
46
- tooltipText: "var(--mantine-color-dimmed)",
47
- dotStroke: "var(--mantine-color-body)"
48
- };
49
- var DARK = {
50
- cyan: "#00e5ff",
51
- cyanDim: "#00b8d4",
52
- blue: "#448aff",
53
- green: "#00ff88",
54
- greenDim: "#00c853",
55
- red: "#ff1744",
56
- redDim: "#d50000",
57
- yellow: "#ffab00",
58
- magenta: "#ff4081",
59
- ...THEME_DERIVED,
60
- cardGlow: "0 0 30px rgba(0, 229, 255, 0.06)"
61
- };
62
- var LIGHT = {
63
- cyan: "#0091ea",
64
- cyanDim: "#0277bd",
65
- blue: "#4d8af0",
66
- green: "#00a854",
67
- greenDim: "#00873e",
68
- red: "#d32f2f",
69
- redDim: "#b71c1c",
70
- yellow: "#f9a825",
71
- magenta: "#c51162",
72
- ...THEME_DERIVED,
73
- cardGlow: "0 0 20px rgba(0, 145, 234, 0.06)"
74
- };
75
- function useCyberColors() {
76
- const scheme = useComputedColorScheme("dark");
77
- return useMemo(() => scheme === "dark" ? DARK : LIGHT, [scheme]);
78
- }
79
- function getSeriesColor(key, colors) {
80
- switch (key) {
81
- case "Success Rate":
82
- return colors.cyan;
83
- case "Executions":
84
- return colors.blue;
85
- case "Success Count":
86
- return colors.green;
87
- case "Error Count":
88
- return colors.red;
89
- default:
90
- return colors.cyan;
91
- }
92
- }
93
- var ReferenceLine = ReferenceLine$1;
94
- function CyberDefs({ colors, isLight }) {
95
- const gradMul = isLight ? 0.5 : 1;
96
- const gradients = [
97
- { id: "gradCyan", color: colors.cyan, opacity: 0.35 * gradMul },
98
- { id: "gradBlue", color: colors.blue, opacity: 0.3 * gradMul },
99
- { id: "gradGreen", color: colors.green, opacity: 0.3 * gradMul },
100
- { id: "gradRed", color: colors.red, opacity: 0.3 * gradMul },
101
- { id: "gradYellow", color: colors.yellow, opacity: 0.3 * gradMul }
102
- ];
103
- const glowMul = isLight ? 0.25 : 1;
104
- const filters = [
105
- { id: "glowCyan", std: 3 * glowMul },
106
- { id: "glowBlue", std: 3 * glowMul },
107
- { id: "glowGreen", std: 2.5 * glowMul },
108
- { id: "glowRed", std: 2.5 * glowMul },
109
- { id: "glowYellow", std: 2.5 * glowMul }
110
- ];
111
- return /* @__PURE__ */ jsxs("defs", { children: [
112
- gradients.map((g) => /* @__PURE__ */ jsxs("linearGradient", { id: g.id, x1: "0", y1: "0", x2: "0", y2: "1", children: [
113
- /* @__PURE__ */ jsx("stop", { offset: "0%", stopColor: g.color, stopOpacity: g.opacity }),
114
- /* @__PURE__ */ jsx("stop", { offset: "60%", stopColor: g.color, stopOpacity: g.opacity * 0.2 }),
115
- /* @__PURE__ */ jsx("stop", { offset: "100%", stopColor: g.color, stopOpacity: 0 })
116
- ] }, g.id)),
117
- filters.map((f) => /* @__PURE__ */ jsxs("filter", { id: f.id, x: "-20%", y: "-20%", width: "140%", height: "140%", children: [
118
- /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: f.std, result: "blur" }),
119
- /* @__PURE__ */ jsxs("feMerge", { children: [
120
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
121
- /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
122
- ] })
123
- ] }, f.id)),
124
- /* @__PURE__ */ jsxs("filter", { id: "dotGlow", x: "-50%", y: "-50%", width: "200%", height: "200%", children: [
125
- /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "4", result: "blur" }),
126
- /* @__PURE__ */ jsxs("feMerge", { children: [
127
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
128
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
129
- /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
130
- ] })
131
- ] }),
132
- /* @__PURE__ */ jsxs("filter", { id: "pulseGlow", x: "-30%", y: "-30%", width: "160%", height: "160%", children: [
133
- /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "5", result: "blur" }),
134
- /* @__PURE__ */ jsxs("feMerge", { children: [
135
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
136
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
137
- /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
138
- ] })
139
- ] })
140
- ] });
141
- }
142
- function PulseDefs({ series, colors, isLight }) {
143
- return /* @__PURE__ */ jsx("defs", { children: series.map((s, i) => {
144
- const color = colors[s.color ?? "cyan"];
145
- const dur = "6s";
146
- const delay = "0s";
147
- const keyTimes = "0;0.3;1";
148
- const keySplines = "0.33 0 0.67 1;0 0 1 1";
149
- const animateProps = {
150
- dur,
151
- keyTimes,
152
- keySplines,
153
- repeatCount: "indefinite",
154
- calcMode: "spline",
155
- begin: delay
156
- };
157
- return /* @__PURE__ */ jsxs("linearGradient", { id: `pulse-${i}`, x1: "0", y1: "0", x2: "1", y2: "0", children: [
158
- /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: color, stopOpacity: 0, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "-0.15;1.0;1.0", ...animateProps }) }),
159
- /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: isLight ? "white" : color, stopOpacity: isLight ? 0.6 : 0.9, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "-0.075;1.075;1.075", ...animateProps }) }),
160
- /* @__PURE__ */ jsx("stop", { offset: "0", stopColor: color, stopOpacity: 0, children: /* @__PURE__ */ jsx("animate", { attributeName: "offset", values: "0;1.15;1.15", ...animateProps }) })
161
- ] }, i);
162
- }) });
163
- }
164
- function CyberActiveDot({
165
- cx,
166
- cy,
167
- color,
168
- dotStroke
169
- }) {
170
- if (cx == null || cy == null) return null;
171
- return /* @__PURE__ */ jsxs("g", { filter: "url(#dotGlow)", children: [
172
- /* @__PURE__ */ jsxs("circle", { cx, cy, r: 6, fill: "none", stroke: color, strokeWidth: 2, opacity: 0.5, children: [
173
- /* @__PURE__ */ jsx("animate", { attributeName: "r", from: "4", to: "10", dur: "1.2s", repeatCount: "indefinite" }),
174
- /* @__PURE__ */ jsx("animate", { attributeName: "opacity", from: "0.6", to: "0", dur: "1.2s", repeatCount: "indefinite" })
175
- ] }),
176
- /* @__PURE__ */ jsx("circle", { cx, cy, r: 4, fill: color, stroke: dotStroke, strokeWidth: 2 })
177
- ] });
178
- }
179
- function CyberTooltipContent({
180
- active,
181
- payload,
182
- label,
183
- colors,
184
- labelFormatter,
185
- valueFormatter
186
- }) {
187
- if (!active || !payload?.length) return null;
188
- const filtered = payload.filter((entry) => !entry.name?.startsWith("_pulse_"));
189
- if (!filtered.length) return null;
190
- const displayLabel = label && labelFormatter ? labelFormatter(label) : label;
191
- return /* @__PURE__ */ jsxs(
192
- "div",
193
- {
194
- style: {
195
- background: colors.tooltipBg,
196
- border: `1px solid ${colors.tooltipBorder}`,
197
- borderRadius: 8,
198
- padding: "10px 14px",
199
- backdropFilter: "var(--glass-blur)",
200
- WebkitBackdropFilter: "var(--glass-blur)",
201
- boxShadow: "var(--standard-box-shadow)",
202
- fontFamily: "var(--mantine-font-family-monospace, monospace)",
203
- minWidth: 160
204
- },
205
- children: [
206
- /* @__PURE__ */ jsx(
207
- "div",
208
- {
209
- style: {
210
- fontSize: 11,
211
- color: colors.tickText,
212
- marginBottom: 8,
213
- letterSpacing: "0.05em",
214
- textTransform: "uppercase",
215
- borderBottom: `1px solid ${colors.tooltipBorder}`,
216
- paddingBottom: 6
217
- },
218
- children: displayLabel
219
- }
220
- ),
221
- filtered.map((entry) => {
222
- const color = entry.color || getSeriesColor(entry.dataKey, colors);
223
- return /* @__PURE__ */ jsxs(
224
- "div",
225
- {
226
- style: {
227
- display: "flex",
228
- justifyContent: "space-between",
229
- alignItems: "center",
230
- gap: 16,
231
- padding: "3px 0",
232
- fontSize: 12
233
- },
234
- children: [
235
- /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
236
- /* @__PURE__ */ jsx(
237
- "div",
238
- {
239
- style: {
240
- width: 8,
241
- height: 8,
242
- borderRadius: "50%",
243
- backgroundColor: color,
244
- boxShadow: `0 0 6px ${color}`
245
- }
246
- }
247
- ),
248
- /* @__PURE__ */ jsx("span", { style: { color: colors.tooltipText }, children: entry.name ?? entry.dataKey })
249
- ] }),
250
- /* @__PURE__ */ jsx("span", { style: { color, fontWeight: 600, fontVariantNumeric: "tabular-nums" }, children: entry.value != null && valueFormatter ? valueFormatter(entry.value) : String(entry.value) })
251
- ]
252
- },
253
- entry.dataKey
254
- );
255
- })
256
- ]
257
- }
258
- );
259
- }
260
- function CyberLegendItem({ color, label }) {
261
- return /* @__PURE__ */ jsxs(Group, { gap: 8, children: [
262
- /* @__PURE__ */ jsx(
263
- "div",
264
- {
265
- style: {
266
- width: 10,
267
- height: 10,
268
- borderRadius: "50%",
269
- backgroundColor: color,
270
- boxShadow: `0 0 8px ${color}, 0 0 16px ${color}40`
271
- }
272
- }
273
- ),
274
- /* @__PURE__ */ jsx(Text, { size: "xs", style: { color: "var(--color-text-subtle)", letterSpacing: "0.03em" }, children: label })
275
- ] });
276
- }
277
- var COLOR_MAP = {
278
- cyan: { gradient: "url(#gradCyan)", filter: "url(#glowCyan)", key: "cyan" },
279
- blue: { gradient: "url(#gradBlue)", filter: "url(#glowBlue)", key: "blue" },
280
- green: { gradient: "url(#gradGreen)", filter: "url(#glowGreen)", key: "green" },
281
- red: { gradient: "url(#gradRed)", filter: "url(#glowRed)", key: "red" },
282
- yellow: { gradient: "url(#gradYellow)", filter: "url(#glowYellow)", key: "yellow" }
283
- };
284
- function CyberAreaChart({
285
- data,
286
- series,
287
- xDataKey = "time",
288
- height = 300,
289
- yAxisLabel,
290
- yDomain,
291
- yTickFormatter,
292
- showGrid = true,
293
- showZeroBaseline = true,
294
- baselineColor,
295
- lineOnly = false,
296
- margin = { top: 8, right: 20, left: 0, bottom: 0 },
297
- xTickFormatter,
298
- tooltipFormatter
299
- }) {
300
- const isLight = useComputedColorScheme("dark") === "light";
301
- const colors = useCyberColors();
302
- const [ready, setReady] = useState(false);
303
- useEffect(() => {
304
- const frame = requestAnimationFrame(() => setReady(true));
305
- return () => cancelAnimationFrame(frame);
306
- }, []);
307
- const allZero = useMemo(() => {
308
- if (!showZeroBaseline || !data.length) return false;
309
- return data.every((row) => series.every((s) => row[s.dataKey] === 0));
310
- }, [data, series, showZeroBaseline]);
311
- if (!ready || !data.length) return /* @__PURE__ */ jsx(Box, { style: { height } });
312
- const gridProps = {
313
- stroke: colors.gridLine,
314
- strokeDasharray: "3 6",
315
- strokeOpacity: 1
316
- };
317
- const xAxisConfig = {
318
- stroke: "none",
319
- tick: {
320
- fill: colors.tickText,
321
- fontSize: 11,
322
- fontFamily: "var(--mantine-font-family-monospace, monospace)"
323
- },
324
- tickLine: false,
325
- axisLine: { stroke: colors.grid, strokeWidth: 1 }
326
- };
327
- const yTickStyle = {
328
- fill: colors.tickText,
329
- fontSize: 11,
330
- fontFamily: "var(--mantine-font-family-monospace, monospace)"
331
- };
332
- return /* @__PURE__ */ jsx(Box, { style: { width: "100%", height }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(AreaChart, { data, margin, children: [
333
- /* @__PURE__ */ jsx(CyberDefs, { colors, isLight }),
334
- /* @__PURE__ */ jsx(PulseDefs, { series, colors, isLight }),
335
- showGrid && /* @__PURE__ */ jsx(CartesianGrid, { ...gridProps }),
336
- /* @__PURE__ */ jsx(XAxis, { dataKey: xDataKey, ...xAxisConfig, tickFormatter: xTickFormatter }),
337
- /* @__PURE__ */ jsx(
338
- YAxis,
339
- {
340
- domain: yDomain ?? [0, (max) => Math.max(max, 1)],
341
- stroke: "none",
342
- tick: yTickStyle,
343
- tickFormatter: yTickFormatter,
344
- tickLine: false,
345
- axisLine: { stroke: colors.grid, strokeWidth: 1 },
346
- label: yAxisLabel ? {
347
- value: yAxisLabel,
348
- angle: -90,
349
- position: "insideLeft",
350
- offset: 0,
351
- style: { fill: colors.tickText, fontSize: 11 }
352
- } : void 0
353
- }
354
- ),
355
- /* @__PURE__ */ jsx(
356
- Tooltip,
357
- {
358
- content: /* @__PURE__ */ jsx(CyberTooltipContent, { colors, labelFormatter: xTickFormatter, valueFormatter: tooltipFormatter }),
359
- cursor: { stroke: colors.cyan, strokeOpacity: 0.2 }
360
- }
361
- ),
362
- allZero && (() => {
363
- const bColor = colors[baselineColor ?? series[0]?.color ?? "cyan"];
364
- const glow = isLight ? `drop-shadow(0 0 2px ${bColor})` : `drop-shadow(0 0 4px ${bColor}) drop-shadow(0 0 8px ${bColor})`;
365
- return /* @__PURE__ */ jsx(ReferenceLine, { y: 0, stroke: bColor, strokeWidth: isLight ? 1.5 : 2, style: { filter: glow } });
366
- })(),
367
- series.map((s) => {
368
- const cm = COLOR_MAP[s.color ?? "cyan"];
369
- const strokeColor = colors[cm.key];
370
- return /* @__PURE__ */ jsx(
371
- Area,
372
- {
373
- type: "monotone",
374
- dataKey: s.dataKey,
375
- name: s.name ?? s.dataKey,
376
- stroke: strokeColor,
377
- strokeWidth: lineOnly ? 3 : 2,
378
- fill: lineOnly ? "transparent" : cm.gradient,
379
- filter: cm.filter,
380
- dot: false,
381
- activeDot: /* @__PURE__ */ jsx(CyberActiveDot, { color: strokeColor, dotStroke: colors.dotStroke }),
382
- animationBegin: 100,
383
- animationDuration: s.animationDuration ?? 1200,
384
- animationEasing: "ease-out"
385
- },
386
- s.dataKey
387
- );
388
- }),
389
- !isLight && series.map((s, i) => /* @__PURE__ */ jsx(
390
- Area,
391
- {
392
- type: "monotone",
393
- dataKey: s.dataKey,
394
- name: `_pulse_${s.dataKey}`,
395
- stroke: `url(#pulse-${i})`,
396
- strokeWidth: 3,
397
- fill: "none",
398
- filter: "url(#pulseGlow)",
399
- dot: false,
400
- activeDot: false,
401
- tooltipType: "none",
402
- isAnimationActive: false,
403
- style: { pointerEvents: "none" }
404
- },
405
- `pulse-${s.dataKey}`
406
- ))
407
- ] }) }) });
408
- }
409
- function CyberDonutTooltip({
410
- active,
411
- payload,
412
- colors
413
- }) {
414
- if (!active || !payload?.length) return null;
415
- const entry = payload[0];
416
- if (!entry) return null;
417
- const color = entry.payload?.color ?? colors.cyan;
418
- return /* @__PURE__ */ jsxs(
419
- "div",
420
- {
421
- style: {
422
- background: colors.tooltipBg,
423
- border: `1px solid ${colors.tooltipBorder}`,
424
- borderRadius: 8,
425
- padding: "8px 12px",
426
- backdropFilter: "var(--glass-blur)",
427
- WebkitBackdropFilter: "var(--glass-blur)",
428
- boxShadow: "var(--standard-box-shadow)",
429
- fontFamily: "var(--mantine-font-family-monospace, monospace)",
430
- display: "flex",
431
- alignItems: "center",
432
- gap: 10
433
- },
434
- children: [
435
- /* @__PURE__ */ jsx(
436
- "div",
437
- {
438
- style: {
439
- width: 8,
440
- height: 8,
441
- borderRadius: "50%",
442
- backgroundColor: color,
443
- boxShadow: `0 0 6px ${color}`
444
- }
445
- }
446
- ),
447
- /* @__PURE__ */ jsx("span", { style: { color: colors.tooltipText, fontSize: 12 }, children: entry.name }),
448
- /* @__PURE__ */ jsx("span", { style: { color, fontWeight: 600, fontSize: 12, fontVariantNumeric: "tabular-nums" }, children: entry.value })
449
- ]
450
- }
451
- );
452
- }
453
- function CyberDonut({
454
- title,
455
- segments,
456
- centerValue,
457
- centerLabel,
458
- centerValueColor = "var(--mantine-color-text)",
459
- glowId,
460
- colors,
461
- size = 120,
462
- innerRadius = 36,
463
- outerRadius = 52,
464
- isLoading,
465
- showLegend = true
466
- }) {
467
- const filtered = segments.filter((s) => s.value > 0);
468
- const isEmpty = filtered.length === 0;
469
- const pieData = isEmpty ? [{ name: "Empty", value: 1, color: "var(--color-border)" }] : filtered;
470
- return /* @__PURE__ */ jsxs(Stack, { gap: 6, align: "center", children: [
471
- title && /* @__PURE__ */ jsx(
472
- Text,
473
- {
474
- size: "xs",
475
- fw: 600,
476
- style: { color: "var(--color-text)", letterSpacing: "0.03em", textTransform: "uppercase" },
477
- children: title
478
- }
479
- ),
480
- /* @__PURE__ */ jsxs(Box, { style: { width: size, height: size, position: "relative" }, children: [
481
- /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(PieChart, { children: [
482
- !isEmpty && /* @__PURE__ */ jsx("defs", { children: filtered.map((_, i) => /* @__PURE__ */ jsxs("filter", { id: `${glowId}-${i}`, x: "-20%", y: "-20%", width: "140%", height: "140%", children: [
483
- /* @__PURE__ */ jsx("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "2", result: "blur" }),
484
- /* @__PURE__ */ jsxs("feMerge", { children: [
485
- /* @__PURE__ */ jsx("feMergeNode", { in: "blur" }),
486
- /* @__PURE__ */ jsx("feMergeNode", { in: "SourceGraphic" })
487
- ] })
488
- ] }, i)) }),
489
- /* @__PURE__ */ jsx(
490
- Pie,
491
- {
492
- data: pieData,
493
- cx: "50%",
494
- cy: "50%",
495
- innerRadius,
496
- outerRadius,
497
- paddingAngle: isEmpty ? 0 : 3,
498
- dataKey: "value",
499
- stroke: "none",
500
- animationBegin: 100,
501
- animationDuration: 1e3,
502
- animationEasing: "ease-out",
503
- isAnimationActive: !isEmpty,
504
- children: pieData.map((entry, i) => /* @__PURE__ */ jsx(
505
- Cell,
506
- {
507
- fill: entry.color,
508
- style: {
509
- filter: isEmpty ? void 0 : `url(#${glowId}-${i})`,
510
- fillOpacity: isEmpty ? 0.3 : 0.9
511
- }
512
- },
513
- entry.name
514
- ))
515
- }
516
- ),
517
- !isEmpty && /* @__PURE__ */ jsx(Tooltip, { content: /* @__PURE__ */ jsx(CyberDonutTooltip, { colors }) })
518
- ] }) }),
519
- /* @__PURE__ */ jsxs(
520
- "div",
521
- {
522
- style: {
523
- position: "absolute",
524
- top: "50%",
525
- left: "50%",
526
- transform: "translate(-50%, -50%)",
527
- textAlign: "center",
528
- pointerEvents: "none"
529
- },
530
- children: [
531
- /* @__PURE__ */ jsx(
532
- "div",
533
- {
534
- style: {
535
- fontSize: 18,
536
- fontWeight: 700,
537
- fontFamily: "var(--mantine-font-family-monospace, monospace)",
538
- color: centerValueColor,
539
- lineHeight: 1
540
- },
541
- children: isLoading ? "-" : centerValue
542
- }
543
- ),
544
- /* @__PURE__ */ jsx(
545
- "div",
546
- {
547
- style: {
548
- fontSize: 8,
549
- color: "var(--mantine-color-dimmed)",
550
- letterSpacing: "0.05em",
551
- textTransform: "uppercase",
552
- marginTop: 2
553
- },
554
- children: centerLabel
555
- }
556
- )
557
- ]
558
- }
559
- )
560
- ] }),
561
- showLegend && /* @__PURE__ */ jsx(Stack, { gap: 4, style: { width: "100%" }, children: segments.map((seg) => /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", px: "xs", children: [
562
- /* @__PURE__ */ jsx(CyberLegendItem, { color: seg.color, label: seg.name }),
563
- /* @__PURE__ */ jsx(
564
- Text,
565
- {
566
- size: "xs",
567
- fw: 600,
568
- style: {
569
- fontFamily: "var(--mantine-font-family-monospace, monospace)",
570
- fontVariantNumeric: "tabular-nums"
571
- },
572
- children: isLoading ? "-" : seg.value
573
- }
574
- )
575
- ] }, seg.name)) })
576
- ] });
577
- }
578
- var GRANULARITY_MAP = {
579
- "1h": "hour",
580
- "24h": "hour",
581
- "7d": "day",
582
- "30d": "day"
583
- };
584
- var BUCKET_CONFIG = {
585
- "1h": { size: 5 * 60 * 1e3, count: 12 },
586
- "24h": { size: 60 * 60 * 1e3, count: 24 },
587
- "7d": { size: 24 * 60 * 60 * 1e3, count: 7 },
588
- "30d": { size: 24 * 60 * 60 * 1e3, count: 30 }
589
- };
590
- function groupTimestampsByTime(timestamps, timeRange) {
591
- const { size: bucketSize, count: bucketCount } = BUCKET_CONFIG[timeRange];
592
- const granularity = GRANULARITY_MAP[timeRange];
593
- const now = /* @__PURE__ */ new Date();
594
- const flooredNow = new Date(now.getTime() - now.getTime() % bucketSize);
595
- const buckets = /* @__PURE__ */ new Map();
596
- for (let i = bucketCount - 1; i >= 0; i--) {
597
- const bucketTime = new Date(flooredNow.getTime() - i * bucketSize);
598
- const label = formatBucketTime(bucketTime.toISOString(), granularity);
599
- buckets.set(label, 0);
600
- }
601
- timestamps.forEach((occurredAt) => {
602
- const timeDiff = flooredNow.getTime() - occurredAt.getTime();
603
- const bucketIndex = Math.floor(timeDiff / bucketSize);
604
- if (bucketIndex >= 0 && bucketIndex < bucketCount) {
605
- const bucketTime = new Date(flooredNow.getTime() - bucketIndex * bucketSize);
606
- const label = formatBucketTime(bucketTime.toISOString(), granularity);
607
- buckets.set(label, (buckets.get(label) || 0) + 1);
608
- }
609
- });
610
- return Array.from(buckets.entries()).map(([time, count]) => ({
611
- time,
612
- "Activity Count": count
613
- }));
614
- }
615
- function ActivityTrendChart({ timestamps, total, isLoading, timeRange }) {
616
- const chartData = useMemo(() => {
617
- return groupTimestampsByTime(timestamps, timeRange);
618
- }, [timestamps, timeRange]);
619
- if (isLoading) {
620
- return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) });
621
- }
622
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
623
- /* @__PURE__ */ jsx(
624
- CardHeader,
625
- {
626
- icon: /* @__PURE__ */ jsx(IconActivity, { size: 18 }),
627
- title: "Activity Trend",
628
- subtitle: `${total} activities in ${getTimeRangeLabel(timeRange)}`
629
- }
630
- ),
631
- /* @__PURE__ */ jsx(
632
- CyberAreaChart,
633
- {
634
- data: chartData,
635
- series: [{ dataKey: "Activity Count", color: "blue" }],
636
- height: 200,
637
- yAxisLabel: "Count",
638
- yDomain: [0, "auto"]
639
- }
640
- )
641
- ] });
642
- }
643
- function formatDollar(value) {
644
- return `$${value.toFixed(2)}`;
645
- }
646
- function CostTrendChart({ data, summaryData, isLoading, error }) {
647
- const todayCost = summaryData?.current.totalCostUsd ?? 0;
648
- const previousCost = summaryData?.previous.totalCostUsd ?? 0;
649
- const mtdCost = summaryData?.mtd.totalCostUsd ?? 0;
650
- const projectedMonthlyCost = summaryData?.projection.monthlyCostUsd ?? 0;
651
- const confidence = summaryData?.projection.confidence ?? "low";
652
- const budget = 1500;
653
- const budgetStatus = projectedMonthlyCost <= budget ? "green" : projectedMonthlyCost <= budget * 1.1 ? "yellow" : "red";
654
- const budgetLabel = projectedMonthlyCost <= budget ? "On Budget" : projectedMonthlyCost <= budget * 1.1 ? "Warning" : "Over Budget";
655
- const chartData = data?.trendData.map((point) => {
656
- const date = new Date(point.time);
657
- const timeLabel = data.granularity === "hour" ? date.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }) : date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
658
- return {
659
- time: timeLabel,
660
- "Total Cost": point.totalCostUsd
661
- };
662
- }) ?? [];
663
- const handleExport = () => {
664
- if (!data) return;
665
- const csvContent = [
666
- ["Time", "Total Cost ($)", "Executions", "Avg Cost/Execution ($)"],
667
- ...data.trendData.map((d) => [
668
- d.time,
669
- d.totalCostUsd.toFixed(4),
670
- d.executionCount,
671
- d.avgCostPerExecution.toFixed(4)
672
- ])
673
- ].map((row) => row.join(",")).join("\n");
674
- const blob = new Blob([csvContent], { type: "text/csv" });
675
- const url = URL.createObjectURL(blob);
676
- const link = document.createElement("a");
677
- link.href = url;
678
- link.download = `cost-trends-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
679
- link.click();
680
- URL.revokeObjectURL(url);
681
- };
682
- if (error) {
683
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load cost trends" }) });
684
- }
685
- if (isLoading) {
686
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
687
- }
688
- const granularityLabel = data?.granularity === "hour" ? "Hourly" : "Daily";
689
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
690
- /* @__PURE__ */ jsx(
691
- CardHeader,
692
- {
693
- icon: /* @__PURE__ */ jsx(IconChartLine, { size: 18 }),
694
- title: `Cost Trend (${granularityLabel})`,
695
- rightSection: /* @__PURE__ */ jsx(Button, { variant: "subtle", size: "xs", leftSection: /* @__PURE__ */ jsx(IconDownload, { size: 14 }), onClick: handleExport, children: "Export CSV" })
696
- }
697
- ),
698
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", mb: "md", children: [
699
- /* @__PURE__ */ jsxs(Group, { gap: "lg", children: [
700
- /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
701
- /* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: todayCost, decimalScale: 2 }) }),
702
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "period" }),
703
- /* @__PURE__ */ jsx(TrendIndicator, { current: todayCost, previous: previousCost, inverse: true })
704
- ] }),
705
- /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
706
- /* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: mtdCost, thousandSeparator: true, decimalScale: 2 }) }),
707
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "MTD" })
708
- ] })
709
- ] }),
710
- /* @__PURE__ */ jsx(Badge, { size: "md", variant: "dot", color: budgetStatus, children: budgetLabel })
711
- ] }),
712
- chartData.length > 0 ? /* @__PURE__ */ jsx(
713
- CyberAreaChart,
714
- {
715
- data: chartData,
716
- series: [{ dataKey: "Total Cost", color: "blue", name: "Total Cost" }],
717
- height: 200,
718
- yDomain: [0, (max) => Math.max(max * 1.1, 0.01)],
719
- yTickFormatter: formatDollar,
720
- tooltipFormatter: formatDollar,
721
- baselineColor: "blue"
722
- }
723
- ) : /* @__PURE__ */ jsx(EmptyState, { icon: IconChartLine, title: "No cost data available for this time period" }),
724
- /* @__PURE__ */ jsx(Space, { h: "lg" }),
725
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
726
- /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
727
- /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
728
- "Projected monthly:",
729
- " ",
730
- /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: projectedMonthlyCost, thousandSeparator: true, decimalScale: 2 })
731
- ] }),
732
- /* @__PURE__ */ jsx(Tooltip$1, { label: `Projection confidence: ${confidence}`, children: /* @__PURE__ */ jsx(IconInfoCircle, { size: 12, color: "var(--color-text-subtle)" }) })
733
- ] }),
734
- /* @__PURE__ */ jsxs(
735
- Text,
736
- {
737
- size: "xs",
738
- fw: 600,
739
- c: projectedMonthlyCost > budget ? "red" : "dimmed",
740
- style: { fontFamily: "var(--mantine-font-family-headings)" },
741
- children: [
742
- "Budget: ",
743
- /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: budget, thousandSeparator: true, decimalScale: 2 })
744
- ]
745
- }
746
- )
747
- ] })
748
- ] });
749
- }
750
- var EM_DASH = "\u2014";
751
- function getSuccessRateColor(rate) {
752
- if (rate >= 95) return "var(--mantine-color-teal-6)";
753
- if (rate >= 80) return "var(--mantine-color-yellow-6)";
754
- return "var(--mantine-color-red-6)";
755
- }
756
- function getErrorCountColor(count) {
757
- if (count === 0) return "var(--mantine-color-teal-6)";
758
- if (count <= 5) return "var(--mantine-color-yellow-6)";
759
- return "var(--mantine-color-red-6)";
760
- }
761
- function HeroStatsRow({
762
- resourcesData,
763
- resourcesLoading,
764
- dashboardData,
765
- dashboardLoading,
766
- unresolvedErrorCount,
767
- errorsLoading
768
- }) {
769
- const health = dashboardData?.executionHealth;
770
- const resourceCount = resourcesData?.total ?? null;
771
- const totalExecutions = health?.totalExecutions ?? null;
772
- const successRate = totalExecutions ? health?.successRate ?? null : null;
773
- return /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 2, sm: 5 }, children: [
774
- /* @__PURE__ */ jsx(
775
- StatCard,
776
- {
777
- variant: "hero",
778
- icon: IconApps,
779
- value: resourceCount ?? EM_DASH,
780
- label: "Resources",
781
- isLoading: resourcesLoading
782
- }
783
- ),
784
- /* @__PURE__ */ jsx(
785
- StatCard,
786
- {
787
- variant: "hero",
788
- icon: IconPlayerPlay,
789
- value: totalExecutions ?? EM_DASH,
790
- label: "Executions",
791
- isLoading: dashboardLoading
792
- }
793
- ),
794
- /* @__PURE__ */ jsx(
795
- StatCard,
796
- {
797
- variant: "hero",
798
- icon: IconChartBar,
799
- value: successRate != null ? `${Math.round(successRate)}%` : EM_DASH,
800
- label: "Success Rate",
801
- valueColor: successRate != null ? getSuccessRateColor(successRate) : void 0,
802
- isLoading: dashboardLoading
803
- }
804
- ),
805
- /* @__PURE__ */ jsx(
806
- StatCard,
807
- {
808
- variant: "hero",
809
- icon: IconAlertTriangle,
810
- value: errorsLoading ? EM_DASH : unresolvedErrorCount ?? EM_DASH,
811
- label: "Errors",
812
- valueColor: unresolvedErrorCount != null ? getErrorCountColor(unresolvedErrorCount) : void 0
813
- }
814
- ),
815
- /* @__PURE__ */ jsx(
816
- StatCard,
817
- {
818
- variant: "hero",
819
- icon: IconRocket,
820
- value: dashboardData?.activeDeploymentVersion ?? EM_DASH,
821
- label: "Deployment",
822
- isLoading: dashboardLoading
823
- }
824
- )
825
- ] });
826
- }
827
-
828
- // src/hooks/observability/queryKeys.ts
829
- var observabilityKeys = {
830
- all: ["observability"],
831
- // Error analysis
832
- errorAnalysis: (organizationId, timeRange) => [...observabilityKeys.all, "error-analysis", organizationId, timeRange],
833
- // Error details list
834
- errorDetails: (organizationId, filters) => [...observabilityKeys.all, "error-details", organizationId, filters],
835
- // Single execution error detail
836
- errorDetail: (organizationId, executionId) => [...observabilityKeys.all, "error-detail", organizationId, executionId],
837
- // Error trends time-series
838
- errorTrends: (organizationId, startDate, endDate, granularity) => [...observabilityKeys.all, "error-trends", organizationId, startDate, endDate, granularity],
839
- // Error distribution breakdown
840
- errorDistribution: (organizationId, startDate, endDate, groupBy) => [...observabilityKeys.all, "error-distribution", organizationId, startDate, endDate, groupBy],
841
- // Top failing resources
842
- topFailingResources: (organizationId, startDate, endDate, limit) => [...observabilityKeys.all, "top-failing-resources", organizationId, startDate, endDate, limit],
843
- // Cost trends time-series
844
- costTrends: (organizationId, timeRange, granularity) => [...observabilityKeys.all, "cost-trends", organizationId, timeRange, granularity],
845
- // Cost by model breakdown
846
- costByModel: (organizationId, timeRange) => [...observabilityKeys.all, "cost-by-model", organizationId, timeRange],
847
- // Cost breakdown per resource/model
848
- costBreakdown: (organizationId, timeRange) => [...observabilityKeys.all, "cost-breakdown", organizationId, timeRange],
849
- // Composite dashboard metrics
850
- dashboardMetrics: (organizationId, timeRange) => [...observabilityKeys.all, "dashboard-metrics", organizationId, timeRange],
851
- // Business impact / automation ROI
852
- businessImpact: (organizationId, timeRange) => [...observabilityKeys.all, "business-impact", organizationId, timeRange],
853
- // Resources health batch
854
- resourcesHealth: (organizationId, resources, startDate, endDate, granularity) => [...observabilityKeys.all, "resources-health", organizationId, resources, startDate, endDate, granularity],
855
- // System-scoped health from direct/descendant resource descriptors
856
- systemHealth: (organizationId, systemPath, timeRange, includeDescendants, descendantMode, resourceSet, startDate, endDate, directResources, descendantResources) => [
857
- ...observabilityKeys.all,
858
- "system-health",
859
- organizationId,
860
- systemPath,
861
- timeRange,
862
- includeDescendants,
863
- descendantMode,
864
- resourceSet,
865
- startDate,
866
- endDate,
867
- directResources,
868
- descendantResources
869
- ],
870
- // Unresolved errors dashboard teaser
871
- unresolvedErrors: (organizationId, startDate, endDate) => [...observabilityKeys.all, "unresolved-errors", organizationId, startDate, endDate],
872
- // Recent executions grouped by resource (dashboard widget)
873
- recentExecutionsByResource: (organizationId, timeRange, limit) => [...observabilityKeys.all, "recent-executions-by-resource", organizationId, timeRange, limit]
874
- };
875
-
876
- // src/hooks/observability/useErrorTrends.ts
877
- function useErrorTrends({ startDate, endDate, granularity }) {
878
- const { apiRequest, isReady, workOSOrganizationId } = useElevasisServices();
879
- return useQuery({
880
- queryKey: observabilityKeys.errorTrends(workOSOrganizationId, startDate, endDate, granularity),
881
- queryFn: async () => {
882
- const params = new URLSearchParams({ startDate, endDate, granularity });
883
- return apiRequest(`/observability/error-analytics/trends?${params.toString()}`);
884
- },
885
- enabled: isReady,
886
- refetchInterval: 6e4,
887
- staleTime: 3e4
888
- });
889
- }
890
- function getGranularityFromTimeRange(timeRange) {
891
- return ["1h", "24h"].includes(timeRange) ? "hour" : "day";
892
- }
893
- function formatPeakPeriod(peakPeriod, granularity) {
894
- if (!peakPeriod) return "N/A";
895
- const date = new Date(peakPeriod);
896
- if (granularity === "hour") {
897
- return date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", hour12: true });
898
- } else {
899
- return date.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
900
- }
901
- }
902
- function CombinedTrendChart({
903
- healthData,
904
- errorData: _errorData,
905
- isLoading,
906
- error,
907
- timeRange,
908
- navigationAction,
909
- compact = false
910
- }) {
911
- const [activeTab, setActiveTab] = useState("success");
912
- const colors = useCyberColors();
913
- const { startDate: start, endDate: end } = useMemo(() => getTimeRangeDates(timeRange), [timeRange]);
914
- const granularity = getGranularityFromTimeRange(timeRange);
915
- const { data: errorTrends } = useErrorTrends({
916
- startDate: start,
917
- endDate: end,
918
- granularity
919
- });
920
- const xTickFormatter = useCallback((value) => formatBucketTime(value, granularity), [granularity]);
921
- if (error) {
922
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load trend data" }) });
923
- }
924
- if (isLoading) {
925
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
926
- }
927
- const errorTrendsMap = new Map(errorTrends?.map((trend) => [trend.time, trend.errorCount]) || []);
928
- const successErrorData = healthData?.trendData.length ? healthData.trendData.map((d) => {
929
- const errorCount = errorTrendsMap.get(d.time) || 0;
930
- return {
931
- time: d.time,
932
- "Success Count": d.successCount,
933
- "Error Count": errorCount
934
- };
935
- }) : [];
936
- const throughputData = healthData?.trendData.length ? healthData.trendData.map((d) => ({
937
- time: d.time,
938
- Executions: d.executionCount
939
- })) : [];
940
- const totalExecutions = healthData?.totalExecutions ?? 0;
941
- const peakPeriod = healthData?.peakPeriod ?? "";
942
- const dataGranularity = healthData?.granularity ?? granularity;
943
- if (!successErrorData.length) {
944
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { h: 300, children: /* @__PURE__ */ jsx(Alert, { icon: /* @__PURE__ */ jsx(IconAlertCircle, {}), color: "gray", variant: "light", children: "No trend data available for the selected time range" }) }) });
945
- }
946
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
947
- /* @__PURE__ */ jsx(
948
- CardHeader,
949
- {
950
- icon: /* @__PURE__ */ jsx(IconChartLine, { size: 18 }),
951
- title: "Execution Trends",
952
- subtitle: `${getTimeRangeLabel(timeRange)} - ${dataGranularity === "hour" ? "Hourly" : "Daily"} data`,
953
- rightSection: /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
954
- /* @__PURE__ */ jsx(
955
- SegmentedControl,
956
- {
957
- value: activeTab ?? "success",
958
- onChange: setActiveTab,
959
- size: "xs",
960
- data: [
961
- { label: "Success & Errors", value: "success" },
962
- { label: "Throughput", value: "throughput" }
963
- ]
964
- }
965
- ),
966
- navigationAction
967
- ] })
968
- }
969
- ),
970
- activeTab === "success" && /* @__PURE__ */ jsxs(Box, { style: { height: compact ? 180 : 280 }, children: [
971
- /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
972
- /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.green, label: "Success Count" }),
973
- /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.red, label: "Error Count" })
974
- ] }),
975
- /* @__PURE__ */ jsx(
976
- CyberAreaChart,
977
- {
978
- data: successErrorData,
979
- series: [
980
- { dataKey: "Error Count", color: "red" },
981
- { dataKey: "Success Count", color: "green", animationDuration: 1400 }
982
- ],
983
- height: compact ? 150 : 250,
984
- yAxisLabel: "Count",
985
- baselineColor: "green",
986
- xTickFormatter
987
- }
988
- )
989
- ] }),
990
- activeTab === "throughput" && /* @__PURE__ */ jsxs(Box, { style: { height: compact ? 180 : 280 }, children: [
991
- /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
992
- /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
993
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: totalExecutions.toLocaleString() }),
994
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "executions" })
995
- ] }),
996
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "|" }),
997
- /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
998
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "peak" }),
999
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: formatPeakPeriod(peakPeriod, dataGranularity) })
1000
- ] }),
1001
- /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "dot", color: "green", children: "Normal" })
1002
- ] }),
1003
- /* @__PURE__ */ jsx(
1004
- CyberAreaChart,
1005
- {
1006
- data: throughputData,
1007
- series: [{ dataKey: "Executions", color: "blue" }],
1008
- height: compact ? 150 : 250,
1009
- xTickFormatter
1010
- }
1011
- )
1012
- ] })
1013
- ] });
1014
- }
1015
-
1016
- export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart, CyberAreaChart, CyberDonut, CyberDonutTooltip, CyberLegendItem, HeroStatsRow, getSeriesColor, observabilityKeys, useCyberColors, useErrorTrends };