@elevasis/ui 2.31.0 → 2.33.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.
Files changed (169) hide show
  1. package/dist/{CoreAuthKitInner-KSEGSB67.js → CoreAuthKitInner-QC62UHTZ.js} +1 -1
  2. package/dist/api/index.js +3 -3
  3. package/dist/app/index.css +38 -0
  4. package/dist/app/index.d.ts +69 -9
  5. package/dist/app/index.js +7 -6
  6. package/dist/auth/context.js +1 -1
  7. package/dist/auth/index.js +1 -1
  8. package/dist/charts/index.js +5 -6
  9. package/dist/{chunk-JKSUN5GN.js → chunk-2GMF5IRF.js} +81 -746
  10. package/dist/{chunk-XQHZBA65.js → chunk-2RJMVWFJ.js} +1 -6
  11. package/dist/{chunk-CW3UNAF2.js → chunk-4DYOXEH6.js} +410 -5
  12. package/dist/{chunk-HQGF4ATG.js → chunk-52NLZN6Z.js} +118 -141
  13. package/dist/chunk-AHCKOU2M.js +13 -0
  14. package/dist/chunk-CLDCYJQT.js +1 -0
  15. package/dist/chunk-DWXDNT7P.js +145 -0
  16. package/dist/chunk-E4T2N7P7.js +124 -0
  17. package/dist/{chunk-HYNYEBHM.js → chunk-E7C4XEWH.js} +3 -3
  18. package/dist/{chunk-L3BVJWML.js → chunk-EPTHX4VZ.js} +1 -1
  19. package/dist/{chunk-QDEETKYT.js → chunk-FFPHJBJC.js} +9 -9
  20. package/dist/chunk-GNRMB6DC.js +5126 -0
  21. package/dist/{chunk-DZTG5IAC.js → chunk-I2KLQ2HA.js} +1 -7
  22. package/dist/{chunk-Q6OYNEGR.js → chunk-IUKFNASA.js} +5 -6
  23. package/dist/{chunk-QHEWXU7I.js → chunk-JFL3GRD4.js} +1 -1
  24. package/dist/{chunk-T3IPHEYJ.js → chunk-JHT5JIJ3.js} +4410 -566
  25. package/dist/{chunk-L2NVFLXU.js → chunk-MHLZ4F4N.js} +4 -4
  26. package/dist/{chunk-XQQEKWTL.js → chunk-N55DVMAG.js} +6 -2
  27. package/dist/{chunk-TOIXUWR6.js → chunk-ND5TDV2J.js} +1 -1
  28. package/dist/{chunk-5LJAEZMA.js → chunk-NOIRGGW2.js} +5 -6
  29. package/dist/{chunk-7KC4P3AU.js → chunk-QNOVUCSV.js} +2 -12
  30. package/dist/{chunk-3BAPR3KA.js → chunk-RQA2EVN3.js} +5 -15
  31. package/dist/{chunk-ND42LPY4.js → chunk-TKF5S4XP.js} +6 -6
  32. package/dist/{chunk-DWK2QIAK.js → chunk-TYRUKGGD.js} +1 -1
  33. package/dist/{chunk-Y4FWCG7Y.js → chunk-UVFOURXR.js} +8 -7
  34. package/dist/chunk-UW7IV2Y3.js +447 -0
  35. package/dist/{chunk-P55BJZZW.js → chunk-V6SZ4ECN.js} +20 -5
  36. package/dist/{chunk-6YT4IKJ7.js → chunk-VNAZTCHA.js} +15 -0
  37. package/dist/chunk-XG57WXOL.js +85 -0
  38. package/dist/{chunk-SHQXMW4F.js → chunk-XOFSMJLF.js} +46 -28
  39. package/dist/{chunk-7HMCB26R.js → chunk-XZGSCABI.js} +1 -1
  40. package/dist/chunk-YAQ25UNM.js +2126 -0
  41. package/dist/chunk-ZGTDKH3P.js +467 -0
  42. package/dist/components/chat/index.js +1 -1
  43. package/dist/components/index.css +38 -0
  44. package/dist/components/index.d.ts +262 -51
  45. package/dist/components/index.js +37 -39
  46. package/dist/components/navigation/index.css +38 -0
  47. package/dist/components/navigation/index.js +5 -3
  48. package/dist/execution/index.d.ts +11 -2
  49. package/dist/execution/index.js +1 -1
  50. package/dist/features/auth/index.css +38 -0
  51. package/dist/features/auth/index.d.ts +91 -14
  52. package/dist/features/auth/index.js +42 -10
  53. package/dist/features/clients/index.css +38 -0
  54. package/dist/features/clients/index.d.ts +1 -1
  55. package/dist/features/clients/index.js +17 -15
  56. package/dist/features/crm/index.css +38 -0
  57. package/dist/features/crm/index.d.ts +80 -18
  58. package/dist/features/crm/index.js +17 -15
  59. package/dist/features/dashboard/index.css +38 -0
  60. package/dist/features/dashboard/index.d.ts +174 -25
  61. package/dist/features/dashboard/index.js +17 -16
  62. package/dist/features/delivery/index.css +38 -0
  63. package/dist/features/delivery/index.d.ts +80 -18
  64. package/dist/features/delivery/index.js +16 -15
  65. package/dist/features/knowledge/index.css +38 -0
  66. package/dist/features/knowledge/index.d.ts +20 -18
  67. package/dist/features/knowledge/index.js +114 -609
  68. package/dist/features/lead-gen/index.css +38 -0
  69. package/dist/features/lead-gen/index.d.ts +45 -43
  70. package/dist/features/lead-gen/index.js +17 -16
  71. package/dist/features/monitoring/index.css +38 -0
  72. package/dist/features/monitoring/index.d.ts +20 -18
  73. package/dist/features/monitoring/index.js +18 -17
  74. package/dist/features/monitoring/requests/index.css +38 -0
  75. package/dist/features/monitoring/requests/index.d.ts +23 -21
  76. package/dist/features/monitoring/requests/index.js +16 -14
  77. package/dist/features/operations/index.css +38 -0
  78. package/dist/features/operations/index.d.ts +1299 -66
  79. package/dist/features/operations/index.js +22 -24
  80. package/dist/features/seo/index.d.ts +20 -18
  81. package/dist/features/seo/index.js +2 -2
  82. package/dist/features/settings/index.css +38 -0
  83. package/dist/features/settings/index.d.ts +80 -18
  84. package/dist/features/settings/index.js +17 -15
  85. package/dist/graph/index.js +1 -1
  86. package/dist/hooks/delivery/index.css +38 -0
  87. package/dist/hooks/delivery/index.d.ts +60 -0
  88. package/dist/hooks/delivery/index.js +3 -3
  89. package/dist/hooks/index.css +38 -0
  90. package/dist/hooks/index.d.ts +492 -89
  91. package/dist/hooks/index.js +15 -13
  92. package/dist/hooks/operations/command-view/utils/transformCommandViewData.d.ts +332 -33
  93. package/dist/hooks/operations/command-view/utils/transformCommandViewData.js +1 -1
  94. package/dist/hooks/published.css +38 -0
  95. package/dist/hooks/published.d.ts +492 -89
  96. package/dist/hooks/published.js +15 -13
  97. package/dist/index.css +38 -0
  98. package/dist/index.d.ts +1353 -1349
  99. package/dist/index.js +16 -14
  100. package/dist/initialization/index.d.ts +60 -0
  101. package/dist/initialization/index.js +1 -1
  102. package/dist/knowledge/index.d.ts +1217 -1292
  103. package/dist/knowledge/index.js +6538 -2198
  104. package/dist/knowledge-search-index-P7PR626V.js +1514 -0
  105. package/dist/layout/index.js +3 -4
  106. package/dist/organization/index.css +38 -0
  107. package/dist/organization/index.js +1 -1
  108. package/dist/profile/index.d.ts +60 -0
  109. package/dist/profile/index.js +1 -1
  110. package/dist/provider/ElevasisServiceContext.js +1 -1
  111. package/dist/provider/index.css +38 -0
  112. package/dist/provider/index.d.ts +1068 -1246
  113. package/dist/provider/index.js +12 -10
  114. package/dist/provider/published.css +38 -0
  115. package/dist/provider/published.d.ts +1065 -1243
  116. package/dist/provider/published.js +9 -7
  117. package/dist/router/context.js +1 -1
  118. package/dist/router/index.js +1 -1
  119. package/dist/sse/index.js +1 -1
  120. package/dist/supabase/index.d.ts +117 -0
  121. package/dist/supabase/index.js +1 -1
  122. package/dist/test-utils/index.d.ts +16 -9
  123. package/dist/test-utils/index.js +40 -33
  124. package/dist/test-utils/setup-integration.js +1 -1
  125. package/dist/test-utils/setup.js +1 -1
  126. package/dist/theme/index.js +3 -3
  127. package/dist/theme/presets/index.js +1 -1
  128. package/dist/typeform/index.js +1 -1
  129. package/dist/typeform/schemas.js +1 -1
  130. package/dist/types/index.d.ts +394 -35
  131. package/dist/utils/index.d.ts +174 -25
  132. package/dist/utils/index.js +2 -2
  133. package/dist/vite/index.js +1 -1
  134. package/dist/vite-plugin-knowledge/index.js +1 -1
  135. package/dist/zustand/index.js +1 -1
  136. package/package.json +10 -9
  137. package/src/README.md +29 -29
  138. package/src/api/README.md +18 -18
  139. package/src/app/README.md +24 -24
  140. package/src/auth/README.md +18 -18
  141. package/src/components/README.md +24 -24
  142. package/src/execution/README.md +16 -16
  143. package/src/features/README.md +28 -28
  144. package/src/graph/README.md +16 -16
  145. package/src/hooks/README.md +23 -23
  146. package/src/initialization/README.md +19 -19
  147. package/src/knowledge/README.md +31 -31
  148. package/src/organization/README.md +18 -18
  149. package/src/profile/README.md +19 -19
  150. package/src/provider/README.md +32 -32
  151. package/src/router/README.md +18 -18
  152. package/src/sse/README.md +13 -13
  153. package/src/test-utils/README.md +7 -7
  154. package/src/theme/README.md +23 -23
  155. package/src/theme/presets/README.md +19 -19
  156. package/src/types/README.md +16 -16
  157. package/src/utils/README.md +18 -18
  158. package/src/zustand/README.md +18 -18
  159. package/dist/chunk-542WPQU2.js +0 -413
  160. package/dist/chunk-6IXOKUBC.js +0 -347
  161. package/dist/chunk-CQZ3DNQY.js +0 -740
  162. package/dist/chunk-ECNNI3NT.js +0 -6
  163. package/dist/chunk-GRDLB6LM.js +0 -160
  164. package/dist/chunk-JDNEWB5F.js +0 -10
  165. package/dist/chunk-MVFCLZSK.js +0 -4337
  166. package/dist/chunk-O2QOPJI5.js +0 -2235
  167. package/dist/chunk-OAVTMITG.js +0 -13
  168. package/dist/chunk-TVRQ6AQI.js +0 -476
  169. package/dist/chunk-WF227UBV.js +0 -48
@@ -1,413 +0,0 @@
1
- import { CyberAreaChart, useCyberColors, CyberLegendItem } from './chunk-CW3UNAF2.js';
2
- import { useErrorTrends } from './chunk-6YT4IKJ7.js';
3
- import { CardHeader, CenteredErrorState, TrendIndicator, EmptyState, StatCard } from './chunk-L3BVJWML.js';
4
- import { getTimeRangeLabel, getTimeRangeDates, formatBucketTime } from './chunk-XQHZBA65.js';
5
- import { useRef, useState, useLayoutEffect, useEffect, useMemo, useCallback } from 'react';
6
- import { jsx, jsxs } from 'react/jsx-runtime';
7
- import { Center, Loader, Paper, Button, Group, Text, NumberFormatter, Badge, Space, Tooltip, SimpleGrid, Alert, SegmentedControl, Box } from '@mantine/core';
8
- import { IconActivity, IconDownload, IconChartLine, IconInfoCircle, IconApps, IconPlayerPlay, IconChartBar, IconAlertTriangle, IconRocket, IconAlertCircle } from '@tabler/icons-react';
9
-
10
- function ChartFrame({ h, debounceMs = 150, children }) {
11
- const ref = useRef(null);
12
- const [width, setWidth] = useState(0);
13
- useLayoutEffect(() => {
14
- const el = ref.current;
15
- if (!el) return;
16
- const w = el.getBoundingClientRect().width;
17
- if (w > 0) setWidth(w);
18
- }, []);
19
- useEffect(() => {
20
- const el = ref.current;
21
- if (!el) return;
22
- let timeout;
23
- const ro = new ResizeObserver((entries) => {
24
- if (timeout !== void 0) window.clearTimeout(timeout);
25
- const nextWidth = entries[0]?.contentRect.width ?? 0;
26
- timeout = window.setTimeout(() => {
27
- if (nextWidth > 0) setWidth(nextWidth);
28
- }, debounceMs);
29
- });
30
- ro.observe(el);
31
- return () => {
32
- ro.disconnect();
33
- if (timeout !== void 0) window.clearTimeout(timeout);
34
- };
35
- }, [debounceMs]);
36
- return /* @__PURE__ */ jsx("div", { ref, style: { width: "100%", height: h, position: "relative" }, children: width > 0 && /* @__PURE__ */ jsx("div", { style: { width, height: h }, children }) });
37
- }
38
- var GRANULARITY_MAP = {
39
- "1h": "hour",
40
- "24h": "hour",
41
- "7d": "day",
42
- "30d": "day"
43
- };
44
- var BUCKET_CONFIG = {
45
- "1h": { size: 5 * 60 * 1e3, count: 12 },
46
- "24h": { size: 60 * 60 * 1e3, count: 24 },
47
- "7d": { size: 24 * 60 * 60 * 1e3, count: 7 },
48
- "30d": { size: 24 * 60 * 60 * 1e3, count: 30 }
49
- };
50
- function groupTimestampsByTime(timestamps, timeRange) {
51
- const { size: bucketSize, count: bucketCount } = BUCKET_CONFIG[timeRange];
52
- const granularity = GRANULARITY_MAP[timeRange];
53
- const now = /* @__PURE__ */ new Date();
54
- const flooredNow = new Date(now.getTime() - now.getTime() % bucketSize);
55
- const buckets = /* @__PURE__ */ new Map();
56
- for (let i = bucketCount - 1; i >= 0; i--) {
57
- const bucketTime = new Date(flooredNow.getTime() - i * bucketSize);
58
- const label = formatBucketTime(bucketTime.toISOString(), granularity);
59
- buckets.set(label, 0);
60
- }
61
- timestamps.forEach((occurredAt) => {
62
- const timeDiff = flooredNow.getTime() - occurredAt.getTime();
63
- const bucketIndex = Math.floor(timeDiff / bucketSize);
64
- if (bucketIndex >= 0 && bucketIndex < bucketCount) {
65
- const bucketTime = new Date(flooredNow.getTime() - bucketIndex * bucketSize);
66
- const label = formatBucketTime(bucketTime.toISOString(), granularity);
67
- buckets.set(label, (buckets.get(label) || 0) + 1);
68
- }
69
- });
70
- return Array.from(buckets.entries()).map(([time, count]) => ({
71
- time,
72
- "Activity Count": count
73
- }));
74
- }
75
- function ActivityTrendChart({ timestamps, total, isLoading, timeRange }) {
76
- const chartData = useMemo(() => {
77
- return groupTimestampsByTime(timestamps, timeRange);
78
- }, [timestamps, timeRange]);
79
- if (isLoading) {
80
- return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) });
81
- }
82
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
83
- /* @__PURE__ */ jsx(
84
- CardHeader,
85
- {
86
- icon: /* @__PURE__ */ jsx(IconActivity, { size: 18 }),
87
- title: "Activity Trend",
88
- subtitle: `${total} activities in ${getTimeRangeLabel(timeRange)}`
89
- }
90
- ),
91
- /* @__PURE__ */ jsx(
92
- CyberAreaChart,
93
- {
94
- data: chartData,
95
- series: [{ dataKey: "Activity Count", color: "blue" }],
96
- height: 200,
97
- yAxisLabel: "Count",
98
- yDomain: [0, "auto"]
99
- }
100
- )
101
- ] });
102
- }
103
- function formatDollar(value) {
104
- return `$${value.toFixed(2)}`;
105
- }
106
- function CostTrendChart({ data, summaryData, isLoading, error }) {
107
- const todayCost = summaryData?.current.totalCostUsd ?? 0;
108
- const previousCost = summaryData?.previous.totalCostUsd ?? 0;
109
- const mtdCost = summaryData?.mtd.totalCostUsd ?? 0;
110
- const projectedMonthlyCost = summaryData?.projection.monthlyCostUsd ?? 0;
111
- const confidence = summaryData?.projection.confidence ?? "low";
112
- const budget = 1500;
113
- const budgetStatus = projectedMonthlyCost <= budget ? "green" : projectedMonthlyCost <= budget * 1.1 ? "yellow" : "red";
114
- const budgetLabel = projectedMonthlyCost <= budget ? "On Budget" : projectedMonthlyCost <= budget * 1.1 ? "Warning" : "Over Budget";
115
- const chartData = data?.trendData.map((point) => {
116
- const date = new Date(point.time);
117
- const timeLabel = data.granularity === "hour" ? date.toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit" }) : date.toLocaleDateString("en-US", { month: "short", day: "numeric" });
118
- return {
119
- time: timeLabel,
120
- "Total Cost": point.totalCostUsd
121
- };
122
- }) ?? [];
123
- const handleExport = () => {
124
- if (!data) return;
125
- const csvContent = [
126
- ["Time", "Total Cost ($)", "Executions", "Avg Cost/Execution ($)"],
127
- ...data.trendData.map((d) => [
128
- d.time,
129
- d.totalCostUsd.toFixed(4),
130
- d.executionCount,
131
- d.avgCostPerExecution.toFixed(4)
132
- ])
133
- ].map((row) => row.join(",")).join("\n");
134
- const blob = new Blob([csvContent], { type: "text/csv" });
135
- const url = URL.createObjectURL(blob);
136
- const link = document.createElement("a");
137
- link.href = url;
138
- link.download = `cost-trends-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
139
- link.click();
140
- URL.revokeObjectURL(url);
141
- };
142
- if (error) {
143
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load cost trends" }) });
144
- }
145
- if (isLoading) {
146
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
147
- }
148
- const granularityLabel = data?.granularity === "hour" ? "Hourly" : "Daily";
149
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
150
- /* @__PURE__ */ jsx(
151
- CardHeader,
152
- {
153
- icon: /* @__PURE__ */ jsx(IconChartLine, { size: 18 }),
154
- title: `Cost Trend (${granularityLabel})`,
155
- rightSection: /* @__PURE__ */ jsx(Button, { variant: "subtle", size: "xs", leftSection: /* @__PURE__ */ jsx(IconDownload, { size: 14 }), onClick: handleExport, children: "Export CSV" })
156
- }
157
- ),
158
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", mb: "md", children: [
159
- /* @__PURE__ */ jsxs(Group, { gap: "lg", children: [
160
- /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
161
- /* @__PURE__ */ jsx(Text, { size: "xl", fw: 700, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: todayCost, decimalScale: 2 }) }),
162
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "period" }),
163
- /* @__PURE__ */ jsx(TrendIndicator, { current: todayCost, previous: previousCost, inverse: true })
164
- ] }),
165
- /* @__PURE__ */ jsxs(Group, { gap: 6, align: "baseline", children: [
166
- /* @__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 }) }),
167
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "MTD" })
168
- ] })
169
- ] }),
170
- /* @__PURE__ */ jsx(Badge, { size: "md", variant: "dot", color: budgetStatus, children: budgetLabel })
171
- ] }),
172
- chartData.length > 0 ? /* @__PURE__ */ jsx(
173
- CyberAreaChart,
174
- {
175
- data: chartData,
176
- series: [{ dataKey: "Total Cost", color: "blue", name: "Total Cost" }],
177
- height: 200,
178
- yDomain: [0, (max) => Math.max(max * 1.1, 0.01)],
179
- yTickFormatter: formatDollar,
180
- tooltipFormatter: formatDollar,
181
- baselineColor: "blue"
182
- }
183
- ) : /* @__PURE__ */ jsx(EmptyState, { icon: IconChartLine, title: "No cost data available for this time period" }),
184
- /* @__PURE__ */ jsx(Space, { h: "lg" }),
185
- /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
186
- /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
187
- /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
188
- "Projected monthly:",
189
- " ",
190
- /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: projectedMonthlyCost, thousandSeparator: true, decimalScale: 2 })
191
- ] }),
192
- /* @__PURE__ */ jsx(Tooltip, { label: `Projection confidence: ${confidence}`, children: /* @__PURE__ */ jsx(IconInfoCircle, { size: 12, color: "var(--color-text-subtle)" }) })
193
- ] }),
194
- /* @__PURE__ */ jsxs(
195
- Text,
196
- {
197
- size: "xs",
198
- fw: 600,
199
- c: projectedMonthlyCost > budget ? "red" : "dimmed",
200
- style: { fontFamily: "var(--mantine-font-family-headings)" },
201
- children: [
202
- "Budget: ",
203
- /* @__PURE__ */ jsx(NumberFormatter, { prefix: "$", value: budget, thousandSeparator: true, decimalScale: 2 })
204
- ]
205
- }
206
- )
207
- ] })
208
- ] });
209
- }
210
- var EM_DASH = "\u2014";
211
- function getSuccessRateColor(rate) {
212
- if (rate >= 95) return "var(--mantine-color-teal-6)";
213
- if (rate >= 80) return "var(--mantine-color-yellow-6)";
214
- return "var(--mantine-color-red-6)";
215
- }
216
- function getErrorCountColor(count) {
217
- if (count === 0) return "var(--mantine-color-teal-6)";
218
- if (count <= 5) return "var(--mantine-color-yellow-6)";
219
- return "var(--mantine-color-red-6)";
220
- }
221
- function HeroStatsRow({
222
- resourcesData,
223
- resourcesLoading,
224
- dashboardData,
225
- dashboardLoading,
226
- unresolvedErrorCount,
227
- errorsLoading
228
- }) {
229
- const health = dashboardData?.executionHealth;
230
- const resourceCount = resourcesData?.total ?? null;
231
- const totalExecutions = health?.totalExecutions ?? null;
232
- const successRate = totalExecutions ? health?.successRate ?? null : null;
233
- return /* @__PURE__ */ jsxs(SimpleGrid, { cols: { base: 2, sm: 5 }, children: [
234
- /* @__PURE__ */ jsx(
235
- StatCard,
236
- {
237
- variant: "hero",
238
- icon: IconApps,
239
- value: resourceCount ?? EM_DASH,
240
- label: "Resources",
241
- isLoading: resourcesLoading
242
- }
243
- ),
244
- /* @__PURE__ */ jsx(
245
- StatCard,
246
- {
247
- variant: "hero",
248
- icon: IconPlayerPlay,
249
- value: totalExecutions ?? EM_DASH,
250
- label: "Executions",
251
- isLoading: dashboardLoading
252
- }
253
- ),
254
- /* @__PURE__ */ jsx(
255
- StatCard,
256
- {
257
- variant: "hero",
258
- icon: IconChartBar,
259
- value: successRate != null ? `${Math.round(successRate)}%` : EM_DASH,
260
- label: "Success Rate",
261
- valueColor: successRate != null ? getSuccessRateColor(successRate) : void 0,
262
- isLoading: dashboardLoading
263
- }
264
- ),
265
- /* @__PURE__ */ jsx(
266
- StatCard,
267
- {
268
- variant: "hero",
269
- icon: IconAlertTriangle,
270
- value: errorsLoading ? EM_DASH : unresolvedErrorCount ?? EM_DASH,
271
- label: "Errors",
272
- valueColor: unresolvedErrorCount != null ? getErrorCountColor(unresolvedErrorCount) : void 0
273
- }
274
- ),
275
- /* @__PURE__ */ jsx(
276
- StatCard,
277
- {
278
- variant: "hero",
279
- icon: IconRocket,
280
- value: dashboardData?.activeDeploymentVersion ?? EM_DASH,
281
- label: "Deployment",
282
- isLoading: dashboardLoading
283
- }
284
- )
285
- ] });
286
- }
287
- function getGranularityFromTimeRange(timeRange) {
288
- return ["1h", "24h"].includes(timeRange) ? "hour" : "day";
289
- }
290
- function formatPeakPeriod(peakPeriod, granularity) {
291
- if (!peakPeriod) return "N/A";
292
- const date = new Date(peakPeriod);
293
- if (granularity === "hour") {
294
- return date.toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", hour12: true });
295
- } else {
296
- return date.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
297
- }
298
- }
299
- function CombinedTrendChart({
300
- healthData,
301
- errorData: _errorData,
302
- isLoading,
303
- error,
304
- timeRange,
305
- navigationAction,
306
- compact = false
307
- }) {
308
- const [activeTab, setActiveTab] = useState("success");
309
- const colors = useCyberColors();
310
- const { startDate: start, endDate: end } = useMemo(() => getTimeRangeDates(timeRange), [timeRange]);
311
- const granularity = getGranularityFromTimeRange(timeRange);
312
- const { data: errorTrends } = useErrorTrends({
313
- startDate: start,
314
- endDate: end,
315
- granularity
316
- });
317
- const xTickFormatter = useCallback((value) => formatBucketTime(value, granularity), [granularity]);
318
- if (error) {
319
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(CenteredErrorState, { error, title: "Failed to load trend data" }) });
320
- }
321
- if (isLoading) {
322
- return /* @__PURE__ */ jsx(Paper, { withBorder: true, children: /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, {}) }) });
323
- }
324
- const errorTrendsMap = new Map(errorTrends?.map((trend) => [trend.time, trend.errorCount]) || []);
325
- const successErrorData = healthData?.trendData.length ? healthData.trendData.map((d) => {
326
- const errorCount = errorTrendsMap.get(d.time) || 0;
327
- return {
328
- time: d.time,
329
- "Success Count": d.successCount,
330
- "Error Count": errorCount
331
- };
332
- }) : [];
333
- const throughputData = healthData?.trendData.length ? healthData.trendData.map((d) => ({
334
- time: d.time,
335
- Executions: d.executionCount
336
- })) : [];
337
- const totalExecutions = healthData?.totalExecutions ?? 0;
338
- const peakPeriod = healthData?.peakPeriod ?? "";
339
- const dataGranularity = healthData?.granularity ?? granularity;
340
- if (!successErrorData.length) {
341
- 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" }) }) });
342
- }
343
- return /* @__PURE__ */ jsxs(Paper, { withBorder: true, children: [
344
- /* @__PURE__ */ jsx(
345
- CardHeader,
346
- {
347
- icon: /* @__PURE__ */ jsx(IconChartLine, { size: 18 }),
348
- title: "Execution Trends",
349
- subtitle: `${getTimeRangeLabel(timeRange)} - ${dataGranularity === "hour" ? "Hourly" : "Daily"} data`,
350
- rightSection: /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
351
- /* @__PURE__ */ jsx(
352
- SegmentedControl,
353
- {
354
- value: activeTab ?? "success",
355
- onChange: setActiveTab,
356
- size: "xs",
357
- data: [
358
- { label: "Success & Errors", value: "success" },
359
- { label: "Throughput", value: "throughput" }
360
- ]
361
- }
362
- ),
363
- navigationAction
364
- ] })
365
- }
366
- ),
367
- activeTab === "success" && /* @__PURE__ */ jsxs(Box, { style: { height: compact ? 180 : 280 }, children: [
368
- /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
369
- /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.green, label: "Success Count" }),
370
- /* @__PURE__ */ jsx(CyberLegendItem, { color: colors.red, label: "Error Count" })
371
- ] }),
372
- /* @__PURE__ */ jsx(
373
- CyberAreaChart,
374
- {
375
- data: successErrorData,
376
- series: [
377
- { dataKey: "Error Count", color: "red" },
378
- { dataKey: "Success Count", color: "green", animationDuration: 1400 }
379
- ],
380
- height: compact ? 150 : 250,
381
- yAxisLabel: "Count",
382
- baselineColor: "green",
383
- xTickFormatter
384
- }
385
- )
386
- ] }),
387
- activeTab === "throughput" && /* @__PURE__ */ jsxs(Box, { style: { height: compact ? 180 : 280 }, children: [
388
- /* @__PURE__ */ jsxs(Group, { gap: "lg", justify: "center", mb: "xs", h: 24, align: "center", children: [
389
- /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
390
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: totalExecutions.toLocaleString() }),
391
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "executions" })
392
- ] }),
393
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "|" }),
394
- /* @__PURE__ */ jsxs(Group, { gap: 6, children: [
395
- /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "peak" }),
396
- /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { color: colors.blue, fontVariantNumeric: "tabular-nums" }, children: formatPeakPeriod(peakPeriod, dataGranularity) })
397
- ] }),
398
- /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "dot", color: "green", children: "Normal" })
399
- ] }),
400
- /* @__PURE__ */ jsx(
401
- CyberAreaChart,
402
- {
403
- data: throughputData,
404
- series: [{ dataKey: "Executions", color: "blue" }],
405
- height: compact ? 150 : 250,
406
- xTickFormatter
407
- }
408
- )
409
- ] })
410
- ] });
411
- }
412
-
413
- export { ActivityTrendChart, ChartFrame, CombinedTrendChart, CostTrendChart, HeroStatsRow };