@elevasis/ui 1.3.7 → 1.5.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 (56) hide show
  1. package/dist/{CoreAuthKitInner-3J4RVQO6.js → CoreAuthKitInner-Y6LQYIPX.js} +1 -0
  2. package/dist/api/index.js +1 -0
  3. package/dist/auth/context.js +1 -0
  4. package/dist/auth/index.js +1 -0
  5. package/dist/charts/index.d.ts +96 -0
  6. package/dist/charts/index.js +384 -0
  7. package/dist/chunk-54S7KNJV.js +112 -0
  8. package/dist/{chunk-6IX5JZEH.js → chunk-G4TAF3T6.js} +166 -1
  9. package/dist/{chunk-Y2I5JJ3N.js → chunk-K3YVC5RW.js} +2 -2
  10. package/dist/chunk-KB5NKPTN.js +1455 -0
  11. package/dist/chunk-MLKGABMK.js +7 -0
  12. package/dist/{chunk-GIFAF5ZS.js → chunk-MS45MNFM.js} +6 -1
  13. package/dist/chunk-R56VC63S.js +129 -0
  14. package/dist/chunk-TYV5NJV2.js +1 -0
  15. package/dist/{chunk-JQLT6HBI.js → chunk-YJFTZUJJ.js} +22 -2
  16. package/dist/components/index.css +486 -0
  17. package/dist/components/index.d.ts +2047 -1
  18. package/dist/components/index.js +3350 -0
  19. package/dist/components/navigation/index.js +1 -0
  20. package/dist/execution/index.d.ts +15 -3
  21. package/dist/execution/index.js +2 -1
  22. package/dist/graph/index.js +2 -1
  23. package/dist/hooks/index.d.ts +270 -0
  24. package/dist/hooks/index.js +3 -2
  25. package/dist/hooks/published.d.ts +546 -2
  26. package/dist/hooks/published.js +3 -2
  27. package/dist/index.css +62 -0
  28. package/dist/index.d.ts +351 -4
  29. package/dist/index.js +12 -1038
  30. package/dist/initialization/index.d.ts +270 -0
  31. package/dist/initialization/index.js +1 -0
  32. package/dist/layout/index.css +44 -0
  33. package/dist/layout/index.d.ts +330 -0
  34. package/dist/layout/index.js +1440 -0
  35. package/dist/organization/index.js +1 -0
  36. package/dist/profile/index.d.ts +270 -0
  37. package/dist/profile/index.js +1 -0
  38. package/dist/provider/index.css +61 -0
  39. package/dist/provider/index.d.ts +54 -2
  40. package/dist/provider/index.js +5 -3
  41. package/dist/provider/published.d.ts +6 -0
  42. package/dist/provider/published.js +3 -2
  43. package/dist/router/context.js +1 -0
  44. package/dist/router/index.js +1 -0
  45. package/dist/sse/index.js +1 -1
  46. package/dist/supabase/index.d.ts +525 -0
  47. package/dist/supabase/index.js +1 -0
  48. package/dist/theme/index.d.ts +107 -0
  49. package/dist/theme/index.js +3 -0
  50. package/dist/typeform/index.js +1 -0
  51. package/dist/typeform/schemas.js +1 -0
  52. package/dist/types/index.d.ts +3664 -354
  53. package/dist/utils/index.js +1 -0
  54. package/package.json +64 -3
  55. package/dist/chunk-XXDDMASA.js +0 -170
  56. /package/dist/{chunk-BUZONXAW.js → chunk-ARQRKA6J.js} +0 -0
@@ -1 +1,3351 @@
1
+ export { ElevasisLoader, NavigationButton } from '../chunk-R56VC63S.js';
2
+ import '../chunk-TYV5NJV2.js';
3
+ import { useMarkAsRead, useMarkAllAsRead, useNotificationCount, useNotifications, useSubmitAction, useDeleteTask } from '../chunk-G4TAF3T6.js';
4
+ import '../chunk-JGJSZ3UE.js';
5
+ import '../chunk-LHQTTUL2.js';
6
+ import { Graph_default, Graph_exports, useDirectedChainHighlighting, useNodeSelection, useFitViewTrigger, useGraphHighlighting, calculateGraphHeight, GRAPH_CONSTANTS } from '../chunk-MS45MNFM.js';
7
+ export { Graph_exports as graphStyles } from '../chunk-MS45MNFM.js';
8
+ import { STATUS_COLORS, getStatusIcon, formatDuration, getStatusColors, AGENT_CONSTANTS, shouldAnimateEdge, ResourceStatusColors, TIMELINE_CONSTANTS, calculateBarPosition, CONTAINER_CONSTANTS, useExecutionPath, useUnifiedWorkflowLayout, WORKFLOW_CONSTANTS, useReactFlowAgent } from '../chunk-YJFTZUJJ.js';
9
+ export { CONTAINER_CONSTANTS, SHARED_VIZ_CONSTANTS } from '../chunk-YJFTZUJJ.js';
10
+ import '../chunk-TIRMFDM4.js';
11
+ import { getResourceIcon } from '../chunk-LFYO3MDC.js';
12
+ import { getErrorInfo, getErrorTitle, formatErrorMessage } from '../chunk-4VGWQ5AN.js';
13
+ import '../chunk-2JBWPFHF.js';
14
+ import '../chunk-FWZJH3TL.js';
15
+ import '../chunk-NEK6JKPW.js';
16
+ import '../chunk-L2CM2CUA.js';
17
+ import '../chunk-KA7LO7U5.js';
18
+ import '../chunk-DD3CCMCZ.js';
19
+ import { useAuthContext } from '../chunk-7PLEQFHO.js';
20
+ import { useRouterContext } from '../chunk-Q7DJKLEN.js';
21
+ import '../chunk-MLKGABMK.js';
22
+ import { Paper, Stack, Text, Group, Badge, Box, useComputedColorScheme, Center, Title, Button, Loader, Collapse, ScrollArea, Card, Skeleton, Select, Alert, Code, ThemeIcon, Grid, Modal, Space, TextInput, Table, Textarea, Radio, Checkbox, NumberInput, Tooltip, UnstyledButton, Divider, Popover, Indicator, ActionIcon, SegmentedControl, Menu, Accordion, SimpleGrid } from '@mantine/core';
23
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
24
+ import { IconPlayerPlay, IconPlayerStop, IconArrowsSplit, IconSquare, IconBrain, IconFileText, IconMail, IconSend, IconClock, IconArrowUp, IconMessageCircle, IconRocket, IconEye, IconEdit, IconAlertTriangle, IconRefresh, IconX, IconCheck, IconMinus, IconTrendingUp, IconTrendingDown, IconChevronUp, IconChevronDown, IconAlertCircle, IconInfoCircle, IconChevronRight, IconSelector, IconTrash, IconCircle, IconCircleFilled, IconBell, IconFocus2, IconRobot, IconGitBranch, IconDotsVertical, IconExternalLink, IconTool, IconSettings, IconCpu, IconClockHour4, IconVersions, IconNetwork, IconSitemap, IconFileOff, IconCircleX, IconCircleCheck } from '@tabler/icons-react';
25
+ import { memo, useMemo, useState, cloneElement, useEffect, useCallback, Fragment as Fragment$1 } from 'react';
26
+ import Markdown from 'react-markdown';
27
+ import { Prism } from 'react-syntax-highlighter';
28
+ import { oneDark } from 'react-syntax-highlighter/dist/esm/styles/prism';
29
+ import { AreaChart } from '@mantine/charts';
30
+ import { useDisclosure } from '@mantine/hooks';
31
+ import { formatDistanceToNow } from 'date-fns';
32
+ import { Position, Handle, getSmoothStepPath, BaseEdge as BaseEdge$1, EdgeLabelRenderer, Panel, useReactFlow, Controls, ReactFlowProvider, ReactFlow } from '@xyflow/react';
33
+ import '@xyflow/react/dist/style.css';
34
+ import { useForm } from '@mantine/form';
35
+ import dagre from '@dagrejs/dagre';
36
+ import { notifications } from '@mantine/notifications';
1
37
 
38
+ function EmptyState({ icon: Icon, title, description, action, py = "xl" }) {
39
+ return /* @__PURE__ */ jsx(Center, { py, children: /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "xs", children: [
40
+ /* @__PURE__ */ jsx(Icon, { size: 48, style: { opacity: 0.5 } }),
41
+ /* @__PURE__ */ jsx(Title, { order: 4, children: title }),
42
+ description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ta: "center", children: description }),
43
+ action && /* @__PURE__ */ jsx(Button, { variant: "light", onClick: action.onClick, leftSection: action.icon, mt: "sm", children: action.label })
44
+ ] }) });
45
+ }
46
+ function TabCountBadge({ count, isLoading }) {
47
+ return /* @__PURE__ */ jsx(Box, { miw: 20, h: 20, style: { display: "flex", alignItems: "center", justifyContent: "center" }, children: isLoading ? /* @__PURE__ */ jsx(Loader, { size: 12 }) : /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", circle: count < 10, children: count }) });
48
+ }
49
+ function TrendIndicator({ current, previous, inverse }) {
50
+ const change = previous === 0 ? 0 : (current - previous) / previous * 100;
51
+ const isPositive = inverse ? change < 0 : change > 0;
52
+ const isFlat = Math.abs(change) < 0.1;
53
+ const color = isFlat ? "gray" : isPositive ? "green" : "red";
54
+ const Icon = isFlat ? IconMinus : change > 0 ? IconTrendingUp : IconTrendingDown;
55
+ return /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
56
+ /* @__PURE__ */ jsx(Icon, { size: 12 }),
57
+ /* @__PURE__ */ jsx(Badge, { size: "sm", color, variant: "light", children: isFlat ? "No change" : `${isPositive ? "+" : ""}${Math.abs(change).toFixed(1)}%` })
58
+ ] });
59
+ }
60
+ function CollapsibleSection({
61
+ title,
62
+ count,
63
+ countLabel,
64
+ children,
65
+ emptyMessage,
66
+ defaultExpanded = true,
67
+ maxHeight = 300
68
+ }) {
69
+ const [expanded, setExpanded] = useState(defaultExpanded);
70
+ const isEmpty = count === 0;
71
+ return /* @__PURE__ */ jsxs(
72
+ "div",
73
+ {
74
+ style: {
75
+ borderRadius: "8px",
76
+ padding: "8px",
77
+ border: "1px solid var(--color-border)",
78
+ boxShadow: "var(--standard-box-shadow)"
79
+ },
80
+ children: [
81
+ /* @__PURE__ */ jsxs(
82
+ Group,
83
+ {
84
+ gap: "xs",
85
+ mb: expanded ? "xs" : 0,
86
+ justify: "space-between",
87
+ align: "center",
88
+ style: { cursor: "pointer" },
89
+ onClick: () => setExpanded(!expanded),
90
+ children: [
91
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", style: { flex: 1 }, children: [
92
+ typeof title === "string" ? /* @__PURE__ */ jsx(
93
+ Text,
94
+ {
95
+ fw: 600,
96
+ size: "sm",
97
+ c: "var(--color-text)",
98
+ style: { fontFamily: "var(--elevasis-font-family-subtitle)" },
99
+ children: title
100
+ }
101
+ ) : title,
102
+ count !== void 0 && countLabel && /* @__PURE__ */ jsxs(Badge, { size: "sm", variant: "light", color: "gray", children: [
103
+ count,
104
+ " ",
105
+ count === 1 ? countLabel.replace(/s$/, "") : countLabel
106
+ ] })
107
+ ] }),
108
+ expanded ? /* @__PURE__ */ jsx(IconChevronUp, { size: 16 }) : /* @__PURE__ */ jsx(IconChevronDown, { size: 16 })
109
+ ]
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(Collapse, { in: expanded, children: isEmpty && emptyMessage ? /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: emptyMessage }) : /* @__PURE__ */ jsx(ScrollArea, { h: maxHeight, type: "scroll", offsetScrollbars: true, children }) })
113
+ ]
114
+ }
115
+ );
116
+ }
117
+ var PageTitleCaption = ({ title, caption, rightSection }) => {
118
+ const renderCaption = () => {
119
+ if (!caption) return null;
120
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Text, { c: "dimmed", style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: caption }) });
121
+ };
122
+ const titleContent = /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [
123
+ /* @__PURE__ */ jsx(Title, { order: 1, children: title }),
124
+ /* @__PURE__ */ jsx(Space, { h: "4" }),
125
+ renderCaption()
126
+ ] });
127
+ if (!rightSection) {
128
+ return titleContent;
129
+ }
130
+ return /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "end", children: [
131
+ titleContent,
132
+ rightSection
133
+ ] });
134
+ };
135
+ function StatsCardSkeleton({ chartHeight = 120, withChart = true, statCount = 3 }) {
136
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
137
+ /* @__PURE__ */ jsx(Skeleton, { height: 24, width: 150, mb: "md" }),
138
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "xl", children: [
139
+ /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 100 }),
140
+ statCount >= 2 && /* @__PURE__ */ jsx(Skeleton, { height: 60, width: 100 }),
141
+ /* @__PURE__ */ jsx(Skeleton, { height: 40, circle: true })
142
+ ] }),
143
+ withChart && /* @__PURE__ */ jsx(Skeleton, { height: chartHeight })
144
+ ] });
145
+ }
146
+ function ListSkeleton({ rows = 3, rowHeight = 50 }) {
147
+ return /* @__PURE__ */ jsx(Stack, { gap: "xs", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { height: rowHeight }, i)) });
148
+ }
149
+ function DetailCardSkeleton({ rows = 3 }) {
150
+ return /* @__PURE__ */ jsxs(Card, { withBorder: true, children: [
151
+ /* @__PURE__ */ jsx(Skeleton, { height: 24, width: 150, mb: "md" }),
152
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "lg", children: [
153
+ /* @__PURE__ */ jsx(Skeleton, { height: 80, width: 100 }),
154
+ /* @__PURE__ */ jsx(Skeleton, { height: 80, width: 100 }),
155
+ /* @__PURE__ */ jsx(Skeleton, { height: 40, circle: true })
156
+ ] }),
157
+ /* @__PURE__ */ jsx(Stack, { gap: "xs", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsx(Skeleton, { height: 60 }, i)) })
158
+ ] });
159
+ }
160
+ function CustomSelector({
161
+ value,
162
+ onChange,
163
+ data,
164
+ leftSection,
165
+ placeholder,
166
+ w,
167
+ withCheckIcon = false,
168
+ disabled
169
+ }) {
170
+ return /* @__PURE__ */ jsx(
171
+ Select,
172
+ {
173
+ value,
174
+ onChange,
175
+ data,
176
+ leftSection,
177
+ placeholder,
178
+ w,
179
+ size: "xs",
180
+ variant: "unstyled",
181
+ withCheckIcon,
182
+ disabled,
183
+ styles: {
184
+ wrapper: {
185
+ border: "1px solid var(--color-border)",
186
+ borderRadius: "var(--mantine-radius-default)",
187
+ backgroundColor: "var(--color-surface)",
188
+ transition: "border-color 150ms ease, background-color 150ms ease",
189
+ "&:hover": {
190
+ borderColor: "var(--color-border-hover, var(--mantine-color-dark-3))"
191
+ }
192
+ },
193
+ input: {
194
+ fontSize: "var(--mantine-font-size-xs)",
195
+ fontWeight: 500,
196
+ height: "30px",
197
+ minHeight: "30px",
198
+ paddingLeft: leftSection ? "30px" : void 0,
199
+ borderRadius: "var(--mantine-radius-default)",
200
+ cursor: "pointer"
201
+ },
202
+ section: {
203
+ color: "var(--color-text-subtle)"
204
+ },
205
+ dropdown: {
206
+ border: "1px solid var(--color-border)",
207
+ backgroundColor: "var(--color-surface)",
208
+ boxShadow: "var(--card-shadow)"
209
+ },
210
+ option: {
211
+ fontSize: "var(--mantine-font-size-xs)"
212
+ }
213
+ }
214
+ }
215
+ );
216
+ }
217
+ function APIErrorAlert({
218
+ error,
219
+ title,
220
+ showRequestId = true,
221
+ icon = /* @__PURE__ */ jsx(IconAlertCircle, {}),
222
+ color = "red"
223
+ }) {
224
+ const { message, code, requestId, retryAfter } = getErrorInfo(error);
225
+ const alertTitle = title || getErrorTitle(code);
226
+ return /* @__PURE__ */ jsxs(Alert, { icon, title: alertTitle, color, variant: "light", children: [
227
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: message }),
228
+ retryAfter && /* @__PURE__ */ jsxs(Text, { size: "sm", mt: "xs", children: [
229
+ "Please wait ",
230
+ retryAfter,
231
+ " seconds before retrying."
232
+ ] }),
233
+ showRequestId && requestId && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", mt: "xs", children: [
234
+ "Request ID: ",
235
+ /* @__PURE__ */ jsx(Code, { children: requestId })
236
+ ] })
237
+ ] });
238
+ }
239
+
240
+ // src/components/display/StatCard.module.css
241
+ var StatCard_default = {};
242
+ function StatCard(props) {
243
+ if (props.variant === "hero") {
244
+ return /* @__PURE__ */ jsx(HeroStatCard, { ...props });
245
+ }
246
+ const { label, value, icon: IconComponent, color } = props;
247
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
248
+ /* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color, children: /* @__PURE__ */ jsx(IconComponent, { size: 18 }) }),
249
+ /* @__PURE__ */ jsxs("div", { children: [
250
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: label }),
251
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 600, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: value })
252
+ ] })
253
+ ] }) });
254
+ }
255
+ function HeroStatCard({
256
+ icon: IconComponent,
257
+ value,
258
+ label,
259
+ valueColor,
260
+ isLoading,
261
+ size = "sm",
262
+ children
263
+ }) {
264
+ const sm = size === "sm";
265
+ const iconSize = sm ? 36 : 46;
266
+ if (isLoading) {
267
+ return /* @__PURE__ */ jsx(Paper, { p: sm ? "md" : "lg", className: StatCard_default.heroCard, children: /* @__PURE__ */ jsxs(Group, { gap: sm ? "sm" : "md", wrap: "nowrap", children: [
268
+ /* @__PURE__ */ jsx(Skeleton, { circle: true, height: iconSize }),
269
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
270
+ /* @__PURE__ */ jsx(Skeleton, { height: sm ? 24 : 32, width: 60 }),
271
+ /* @__PURE__ */ jsx(Skeleton, { height: 12, width: 80 })
272
+ ] })
273
+ ] }) });
274
+ }
275
+ return /* @__PURE__ */ jsx(Paper, { p: sm ? "md" : "lg", className: StatCard_default.heroCard, children: /* @__PURE__ */ jsxs(Group, { gap: sm ? "sm" : "md", wrap: "nowrap", children: [
276
+ /* @__PURE__ */ jsx("div", { className: sm ? StatCard_default.iconRingSm : StatCard_default.iconRing, children: /* @__PURE__ */ jsx(IconComponent, { size: sm ? 18 : 22 }) }),
277
+ /* @__PURE__ */ jsxs(Stack, { gap: 2, style: { flex: children ? 1 : void 0 }, children: [
278
+ /* @__PURE__ */ jsx(
279
+ "span",
280
+ {
281
+ className: sm ? StatCard_default.heroValueSm : StatCard_default.heroValue,
282
+ style: valueColor ? { color: valueColor } : void 0,
283
+ children: value
284
+ }
285
+ ),
286
+ children ? /* @__PURE__ */ jsxs(Group, { gap: "sm", wrap: "nowrap", style: { flex: 1 }, children: [
287
+ /* @__PURE__ */ jsx("span", { className: sm ? StatCard_default.heroLabelSm : StatCard_default.heroLabel, children: label }),
288
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 }, children })
289
+ ] }) : /* @__PURE__ */ jsx("span", { className: sm ? StatCard_default.heroLabelSm : StatCard_default.heroLabel, children: label })
290
+ ] })
291
+ ] }) });
292
+ }
293
+ function StatCardSkeleton() {
294
+ return /* @__PURE__ */ jsx(Card, { withBorder: true, children: /* @__PURE__ */ jsx(Skeleton, { height: 60 }) });
295
+ }
296
+ var customCodeTheme = Object.fromEntries(
297
+ Object.entries(oneDark).map(([key, value]) => [
298
+ key,
299
+ typeof value === "object" && value !== null ? { ...value, background: "none", backgroundColor: "none" } : value
300
+ ])
301
+ );
302
+ var defaultComponents = {
303
+ h1: ({ children }) => /* @__PURE__ */ jsx(Title, { order: 3, c: "var(--color-primary)", mb: "xs", mt: "md", children }),
304
+ h2: ({ children }) => /* @__PURE__ */ jsx(Title, { order: 4, c: "var(--color-primary)", mb: "xs", mt: "sm", children }),
305
+ ul: ({ children }) => /* @__PURE__ */ jsx("ul", { style: { margin: "0.5rem 0", paddingLeft: "1.5rem" }, children }),
306
+ ol: ({ children }) => /* @__PURE__ */ jsx("ol", { style: { margin: "0.5rem 0", paddingLeft: "1.5rem" }, children }),
307
+ li: ({ children }) => /* @__PURE__ */ jsx("li", { style: { marginBottom: "0.25rem", fontSize: "var(--mantine-font-size-sm)" }, children }),
308
+ code: ({ className, children, ...props }) => {
309
+ const match = /language-(\w+)/.exec(className || "");
310
+ const codeString = String(children).replace(/\n$/, "");
311
+ if (match) {
312
+ return /* @__PURE__ */ jsx(
313
+ Prism,
314
+ {
315
+ style: customCodeTheme,
316
+ language: match[1],
317
+ PreTag: "div",
318
+ customStyle: {
319
+ margin: "0.5rem 0",
320
+ borderRadius: "var(--mantine-radius-default)",
321
+ fontSize: "0.8rem"
322
+ },
323
+ children: codeString
324
+ }
325
+ );
326
+ }
327
+ return /* @__PURE__ */ jsx(Code, { ...props, children });
328
+ },
329
+ pre: ({ children }) => /* @__PURE__ */ jsx(Fragment, { children }),
330
+ blockquote: ({ children }) => /* @__PURE__ */ jsx(Box, { pl: "sm", my: "xs", style: { borderLeft: "2px solid var(--color-border)" }, children }),
331
+ p: ({ children }) => /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children }),
332
+ strong: ({ children }) => /* @__PURE__ */ jsx(Text, { component: "span", fw: 700, children }),
333
+ em: ({ children }) => /* @__PURE__ */ jsx(Text, { component: "span", fs: "italic", children })
334
+ };
335
+ function StyledMarkdown({ children, components, className, style }) {
336
+ const mergedComponents = components ? { ...defaultComponents, ...components } : defaultComponents;
337
+ return /* @__PURE__ */ jsx("div", { className, style, children: /* @__PURE__ */ jsx(Markdown, { components: mergedComponents, children }) });
338
+ }
339
+ var jsonTheme = Object.fromEntries(
340
+ Object.entries(oneDark).map(([key, value]) => [
341
+ key,
342
+ typeof value === "object" && value !== null ? { ...value, background: "none", backgroundColor: "none" } : value
343
+ ])
344
+ );
345
+ function JsonViewer({ data, maxHeight, fontSize = "0.8rem" }) {
346
+ const jsonString = typeof data === "string" ? data : JSON.stringify(data, null, 2);
347
+ return /* @__PURE__ */ jsx(
348
+ Prism,
349
+ {
350
+ language: "json",
351
+ style: jsonTheme,
352
+ customStyle: {
353
+ margin: 0,
354
+ fontSize,
355
+ maxHeight,
356
+ overflow: maxHeight ? "auto" : void 0,
357
+ overflowX: "auto"
358
+ },
359
+ children: jsonString
360
+ }
361
+ );
362
+ }
363
+ var subtleMarkdownComponents = {
364
+ p: ({ children }) => /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, c: "var(--color-text-subtle)", style: { whiteSpace: "pre-wrap" }, children })
365
+ };
366
+ var subtleMarkdownWrapperStyle = {
367
+ display: "flex",
368
+ flexDirection: "column",
369
+ gap: 8
370
+ };
371
+ function ContextViewer({ data }) {
372
+ return /* @__PURE__ */ jsx(ContextNode, { data, depth: 0 });
373
+ }
374
+ function ContextNode({ data, depth }) {
375
+ if (data === null || data === void 0) {
376
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No context provided" });
377
+ }
378
+ if (typeof data === "string") {
379
+ return /* @__PURE__ */ jsx(StyledMarkdown, { components: subtleMarkdownComponents, style: subtleMarkdownWrapperStyle, children: data });
380
+ }
381
+ if (typeof data === "number" || typeof data === "boolean") {
382
+ return /* @__PURE__ */ jsx(Text, { size: "sm", children: String(data) });
383
+ }
384
+ if (Array.isArray(data)) {
385
+ return /* @__PURE__ */ jsx(ArrayView, { items: data, depth });
386
+ }
387
+ if (typeof data === "object") {
388
+ return /* @__PURE__ */ jsx(ObjectView, { data, depth });
389
+ }
390
+ return /* @__PURE__ */ jsx(Text, { size: "sm", children: String(data) });
391
+ }
392
+ function formatLabel(key) {
393
+ return key.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[_-]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
394
+ }
395
+ function hasMarkdown(value) {
396
+ return /(\*\*.+\*\*|^#{1,6}\s|^\s*[-*]\s|\[.+\]\(.+\)|^\|.+\|$|^>\s|```)/.test(value);
397
+ }
398
+ function NestedSection({ title, children }) {
399
+ const [expanded, setExpanded] = useState(true);
400
+ return /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
401
+ /* @__PURE__ */ jsxs(Group, { gap: 4, style: { cursor: "pointer", userSelect: "none" }, onClick: () => setExpanded((v) => !v), children: [
402
+ /* @__PURE__ */ jsx(
403
+ IconChevronRight,
404
+ {
405
+ size: 14,
406
+ color: "var(--color-primary)",
407
+ style: {
408
+ transition: "transform 150ms ease",
409
+ transform: expanded ? "rotate(90deg)" : "rotate(0deg)",
410
+ flexShrink: 0
411
+ }
412
+ }
413
+ ),
414
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: title })
415
+ ] }),
416
+ expanded && /* @__PURE__ */ jsx(Box, { pl: "sm", style: { borderLeft: "2px solid var(--color-border)" }, children })
417
+ ] });
418
+ }
419
+ function PrimitiveValue({ value }) {
420
+ if (value === null || value === void 0) {
421
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "\u2014" });
422
+ }
423
+ if (typeof value === "boolean") {
424
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children: value ? "Yes" : "No" });
425
+ }
426
+ if (typeof value === "number") {
427
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, children: value.toLocaleString() });
428
+ }
429
+ const str = String(value);
430
+ if (hasMarkdown(str)) {
431
+ return /* @__PURE__ */ jsx(StyledMarkdown, { components: subtleMarkdownComponents, children: str });
432
+ }
433
+ return /* @__PURE__ */ jsx(Text, { size: "sm", m: 0, c: "var(--color-text-subtle)", style: { whiteSpace: "pre-wrap" }, children: str });
434
+ }
435
+ function ArrayView({ items, depth }) {
436
+ if (items.length === 0) {
437
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Empty list" });
438
+ }
439
+ const allPrimitive = items.every((item) => typeof item !== "object" || item === null);
440
+ if (allPrimitive) {
441
+ return /* @__PURE__ */ jsx(Stack, { gap: 2, children: items.map((item, i) => /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "flex-start", children: [
442
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { userSelect: "none" }, children: "\u2022" }),
443
+ /* @__PURE__ */ jsx(PrimitiveValue, { value: item })
444
+ ] }, i)) });
445
+ }
446
+ return /* @__PURE__ */ jsx(Stack, { gap: "sm", children: items.map((item, i) => /* @__PURE__ */ jsx(Paper, { p: "sm", style: { border: "1px solid var(--color-border)" }, children: /* @__PURE__ */ jsx(ContextNode, { data: item, depth: depth + 1 }) }, i)) });
447
+ }
448
+ function ObjectView({ data, depth }) {
449
+ const entries = Object.entries(data);
450
+ if (entries.length === 0) {
451
+ return /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Empty" });
452
+ }
453
+ const simpleEntries = [];
454
+ const complexEntries = [];
455
+ for (const [key, value] of entries) {
456
+ if (value === null || value === void 0 || typeof value === "boolean" || typeof value === "number") {
457
+ simpleEntries.push([key, value]);
458
+ } else if (typeof value === "string") {
459
+ if (hasMarkdown(value) || value.length > 120) {
460
+ complexEntries.push([key, value]);
461
+ } else {
462
+ simpleEntries.push([key, value]);
463
+ }
464
+ } else {
465
+ complexEntries.push([key, value]);
466
+ }
467
+ }
468
+ return /* @__PURE__ */ jsxs(Stack, { gap: 10, children: [
469
+ simpleEntries.length > 0 && /* @__PURE__ */ jsx(Stack, { gap: 6, children: simpleEntries.map(([key, value]) => /* @__PURE__ */ jsxs(Group, { gap: "sm", align: "flex-start", wrap: "nowrap", children: [
470
+ /* @__PURE__ */ jsx(
471
+ Text,
472
+ {
473
+ size: "sm",
474
+ style: { minWidth: 140, flexShrink: 0, fontFamily: "var(--mantine-font-family-headings)" },
475
+ children: formatLabel(key)
476
+ }
477
+ ),
478
+ /* @__PURE__ */ jsx(PrimitiveValue, { value })
479
+ ] }, key)) }),
480
+ complexEntries.map(([key, value]) => /* @__PURE__ */ jsx(NestedSection, { title: formatLabel(key), children: /* @__PURE__ */ jsx(ContextNode, { data: value, depth: depth + 1 }) }, key))
481
+ ] });
482
+ }
483
+ var TIME_RANGE_OPTIONS = [
484
+ { value: "1h", label: "Last 1 hour" },
485
+ { value: "24h", label: "Last 24 hours" },
486
+ { value: "7d", label: "Last 7 days" },
487
+ { value: "30d", label: "Last 30 days" }
488
+ ];
489
+ function TimeRangeSelector({ value, onChange, width = 180 }) {
490
+ return /* @__PURE__ */ jsx(
491
+ CustomSelector,
492
+ {
493
+ value,
494
+ onChange: (newValue) => newValue && onChange(newValue),
495
+ data: TIME_RANGE_OPTIONS,
496
+ leftSection: /* @__PURE__ */ jsx(IconClock, { size: 16, color: "var(--color-text-subtle)" }),
497
+ w: width,
498
+ withCheckIcon: true
499
+ }
500
+ );
501
+ }
502
+ function PageNotFound() {
503
+ const { currentPath, navigate } = useRouterContext();
504
+ const { user, isLoading } = useAuthContext();
505
+ const isAuthPage = currentPath === "/login" || currentPath === "/auth-redirect";
506
+ const shouldShowSidebar = user && !isLoading && !isAuthPage;
507
+ const height = shouldShowSidebar ? "100%" : "100vh";
508
+ return /* @__PURE__ */ jsx(Center, { h: height, bg: "var(--color-background)", children: /* @__PURE__ */ jsxs(Stack, { align: "center", justify: "center", children: [
509
+ /* @__PURE__ */ jsx(IconInfoCircle, { size: 60, color: "var(--color-text-subtle)" }),
510
+ /* @__PURE__ */ jsx(Title, { order: 1, children: "Page Not Found" }),
511
+ /* @__PURE__ */ jsx(Text, { c: "dimmed", size: "lg", children: "The page you are looking for does not exist." }),
512
+ /* @__PURE__ */ jsx(Group, { justify: "center", children: /* @__PURE__ */ jsx(Button, { size: "md", onClick: () => navigate("/"), children: "Go Home" }) })
513
+ ] }) });
514
+ }
515
+ function ResourceCard({
516
+ resource,
517
+ onClick,
518
+ layout = "stack",
519
+ rightSection,
520
+ topSection,
521
+ lastRunLabel,
522
+ style,
523
+ ...rest
524
+ }) {
525
+ const Icon = getResourceIcon(resource.type);
526
+ if (!Icon) {
527
+ return /* @__PURE__ */ jsx(Card, { shadow: "sm", withBorder: true, children: /* @__PURE__ */ jsxs(Text, { children: [
528
+ "Invalid resource type: ",
529
+ resource.type
530
+ ] }) });
531
+ }
532
+ const cardStyle = {
533
+ cursor: "pointer",
534
+ ...layout === "grid" || layout === "card" ? { transition: "box-shadow var(--duration-fast) var(--easing)" } : {},
535
+ ...style
536
+ };
537
+ const iconSize = layout === "grid" ? 28 : 20;
538
+ const details = /* @__PURE__ */ jsxs(Group, { gap: "sm", wrap: "nowrap", children: [
539
+ /* @__PURE__ */ jsx(Icon, { size: iconSize, color: "var(--color-primary)" }),
540
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, style: { flex: 1, minWidth: 0 }, children: [
541
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", align: "center", children: [
542
+ /* @__PURE__ */ jsx(
543
+ Text,
544
+ {
545
+ fw: 600,
546
+ size: "sm",
547
+ style: { fontFamily: "var(--elevasis-font-family-subtitle)" },
548
+ ...layout === "stack" ? { lineClamp: 1 } : { truncate: true },
549
+ children: resource.name
550
+ }
551
+ ),
552
+ /* @__PURE__ */ jsx(Badge, { variant: "light", size: layout === "grid" ? "xs" : "sm", children: resource.type })
553
+ ] }),
554
+ resource.description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", ...layout === "stack" ? { lineClamp: 1 } : { truncate: true }, children: resource.description }),
555
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
556
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "outline", size: "xs", children: [
557
+ "v",
558
+ resource.version
559
+ ] }),
560
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "outline", size: layout === "grid" ? "xs" : "sm", children: resource.status.toUpperCase() })
561
+ ] }),
562
+ lastRunLabel && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: lastRunLabel }),
563
+ /* @__PURE__ */ jsx(Text, { size: layout === "grid" ? "sm" : "xs", c: "dimmed", ff: "monospace", children: resource.resourceId })
564
+ ] })
565
+ ] });
566
+ if (layout === "card") {
567
+ return /* @__PURE__ */ jsx(
568
+ Card,
569
+ {
570
+ withBorder: true,
571
+ padding: 0,
572
+ style: cardStyle,
573
+ onClick: () => onClick(resource),
574
+ "data-resource-id": rest["data-resource-id"],
575
+ children: /* @__PURE__ */ jsxs(Stack, { gap: 8, p: "sm", pb: "xs", children: [
576
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", justify: "space-between", children: [
577
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", style: { minWidth: 0 }, children: [
578
+ /* @__PURE__ */ jsx(Icon, { size: 20, color: "var(--color-primary)", style: { flexShrink: 0 } }),
579
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "md", style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, truncate: true, children: resource.name })
580
+ ] }),
581
+ /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", style: { flexShrink: 0 }, children: [
582
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "light", size: "sm", children: [
583
+ "v",
584
+ resource.version
585
+ ] }),
586
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "light", size: "sm", children: resource.status.toUpperCase() })
587
+ ] })
588
+ ] }),
589
+ resource.description && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", truncate: true, children: resource.description }),
590
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", justify: "space-between", wrap: "nowrap", children: [
591
+ rightSection || /* @__PURE__ */ jsx("span", {}),
592
+ lastRunLabel && /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: lastRunLabel })
593
+ ] }),
594
+ topSection
595
+ ] })
596
+ }
597
+ );
598
+ }
599
+ if (layout === "row") {
600
+ const [hovered, setHovered] = useState(false);
601
+ return /* @__PURE__ */ jsx(
602
+ Card,
603
+ {
604
+ padding: 0,
605
+ style: {
606
+ cursor: "pointer",
607
+ border: "1px solid var(--color-border)",
608
+ transition: "background 150ms ease",
609
+ background: hovered ? "var(--active-background)" : "var(--glass-background)",
610
+ ...style
611
+ },
612
+ onClick: () => onClick(resource),
613
+ onMouseEnter: () => setHovered(true),
614
+ onMouseLeave: () => setHovered(false),
615
+ "data-resource-id": rest["data-resource-id"],
616
+ children: /* @__PURE__ */ jsxs(
617
+ "div",
618
+ {
619
+ style: {
620
+ display: "grid",
621
+ gridTemplateColumns: "18px 200px 120px 1fr 180px 140px 14px",
622
+ alignItems: "center",
623
+ gap: "var(--mantine-spacing-sm)"
624
+ },
625
+ children: [
626
+ /* @__PURE__ */ jsx(Icon, { size: 18, color: "var(--color-primary)" }),
627
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "md", truncate: true, style: { fontFamily: "var(--elevasis-font-family-subtitle)" }, children: resource.name }),
628
+ /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
629
+ resource.version && /* @__PURE__ */ jsxs(Badge, { variant: "light", size: "sm", children: [
630
+ "v",
631
+ resource.version
632
+ ] }),
633
+ /* @__PURE__ */ jsx(Badge, { color: ResourceStatusColors[resource.status], variant: "light", size: "sm", children: resource.status.toUpperCase() })
634
+ ] }),
635
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", truncate: true, style: { minWidth: 0 }, children: resource.description || "" }),
636
+ /* @__PURE__ */ jsx("div", { style: { whiteSpace: "nowrap" }, children: rightSection }),
637
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap", textAlign: "right" }, children: lastRunLabel || "" }),
638
+ /* @__PURE__ */ jsx(
639
+ IconChevronRight,
640
+ {
641
+ size: 14,
642
+ style: {
643
+ opacity: hovered ? 0.7 : 0,
644
+ transition: "opacity 150ms ease"
645
+ }
646
+ }
647
+ )
648
+ ]
649
+ }
650
+ )
651
+ }
652
+ );
653
+ }
654
+ if (layout === "grid") {
655
+ return /* @__PURE__ */ jsx(
656
+ Card,
657
+ {
658
+ withBorder: true,
659
+ padding: "sm",
660
+ style: cardStyle,
661
+ onClick: () => onClick(resource),
662
+ "data-resource-id": rest["data-resource-id"],
663
+ children: /* @__PURE__ */ jsxs(Grid, { gutter: "sm", align: "center", children: [
664
+ /* @__PURE__ */ jsx(Grid.Col, { span: 8, children: details }),
665
+ rightSection && /* @__PURE__ */ jsx(Grid.Col, { span: 4, children: /* @__PURE__ */ jsx(Group, { justify: "flex-end", gap: "md", wrap: "nowrap", children: rightSection }) })
666
+ ] })
667
+ }
668
+ );
669
+ }
670
+ return /* @__PURE__ */ jsx(
671
+ Card,
672
+ {
673
+ shadow: "sm",
674
+ withBorder: true,
675
+ style: cardStyle,
676
+ onClick: () => onClick(resource),
677
+ "data-resource-id": rest["data-resource-id"],
678
+ children: /* @__PURE__ */ jsx(Stack, { children: details })
679
+ }
680
+ );
681
+ }
682
+
683
+ // src/components/display/ResourceCardAdapters.ts
684
+ function catalogItemToResourceDefinition(item) {
685
+ return {
686
+ resourceId: item.resourceId,
687
+ name: item.resourceName,
688
+ description: item.description || "",
689
+ version: item.version,
690
+ type: item.resourceType,
691
+ status: item.status
692
+ };
693
+ }
694
+ function CardHeader({ icon, title, subtitle, rightSection }) {
695
+ return /* @__PURE__ */ jsxs(Group, { justify: "space-between", mb: "md", children: [
696
+ subtitle ? /* @__PURE__ */ jsxs("div", { children: [
697
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
698
+ icon,
699
+ /* @__PURE__ */ jsx(Title, { order: 3, children: title })
700
+ ] }),
701
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", mt: 2, children: subtitle })
702
+ ] }) : /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
703
+ icon,
704
+ /* @__PURE__ */ jsx(Title, { order: 3, children: title })
705
+ ] }),
706
+ rightSection
707
+ ] });
708
+ }
709
+ var CustomModal = ({ children, opened, onClose, loading, style, size }) => {
710
+ const canClose = loading === true ? false : true;
711
+ return /* @__PURE__ */ jsx(
712
+ Modal,
713
+ {
714
+ opened,
715
+ onClose,
716
+ padding: "xs",
717
+ withCloseButton: false,
718
+ closeOnClickOutside: canClose,
719
+ closeOnEscape: canClose,
720
+ centered: true,
721
+ style,
722
+ size,
723
+ children
724
+ }
725
+ );
726
+ };
727
+ var ConfirmationModal = ({
728
+ opened,
729
+ onClose,
730
+ loading,
731
+ icon,
732
+ confirmationHandler,
733
+ style,
734
+ title,
735
+ text,
736
+ buttonText,
737
+ buttonColor,
738
+ centerText
739
+ }) => {
740
+ const styledIcon = cloneElement(icon, {
741
+ size: 55,
742
+ strokeWidth: 1.5
743
+ });
744
+ return /* @__PURE__ */ jsxs(CustomModal, { opened, onClose, loading, style, children: [
745
+ /* @__PURE__ */ jsx(Center, { children: styledIcon }),
746
+ /* @__PURE__ */ jsx(Space, { h: 16 }),
747
+ /* @__PURE__ */ jsx(Center, { style: { textAlign: "center" }, children: /* @__PURE__ */ jsx(Text, { size: "lg", c: "var(--color-text)", children: title }) }),
748
+ /* @__PURE__ */ jsx(Space, { h: 16 }),
749
+ text && /* @__PURE__ */ jsxs(Fragment, { children: [
750
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text-dimmed)", style: { textAlign: centerText ? "center" : "left" }, children: text }),
751
+ /* @__PURE__ */ jsx(Space, { h: 16 })
752
+ ] }),
753
+ /* @__PURE__ */ jsx(Button, { color: buttonColor || "blue", fullWidth: true, onClick: confirmationHandler, loading, children: buttonText || "Confirm" })
754
+ ] });
755
+ };
756
+ var ConfirmationInputModal = ({
757
+ opened,
758
+ onClose,
759
+ loading,
760
+ icon,
761
+ confirmationHandler,
762
+ style,
763
+ title,
764
+ text,
765
+ buttonText,
766
+ buttonColor,
767
+ inputValue,
768
+ onInputChange,
769
+ expectedValue,
770
+ placeholder
771
+ }) => {
772
+ const styledIcon = cloneElement(icon, {
773
+ size: 55,
774
+ strokeWidth: 1.5
775
+ });
776
+ return /* @__PURE__ */ jsxs(CustomModal, { opened, onClose, loading, style, children: [
777
+ /* @__PURE__ */ jsx(Center, { children: styledIcon }),
778
+ /* @__PURE__ */ jsx(Space, { h: 16 }),
779
+ /* @__PURE__ */ jsx(Center, { children: /* @__PURE__ */ jsx(Title, { order: 3, children: title }) }),
780
+ /* @__PURE__ */ jsx(Space, { h: 16 }),
781
+ text && /* @__PURE__ */ jsxs(Fragment, { children: [
782
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text-dimmed)", children: text }),
783
+ /* @__PURE__ */ jsx(Space, { h: 8 })
784
+ ] }),
785
+ /* @__PURE__ */ jsx(
786
+ TextInput,
787
+ {
788
+ placeholder: placeholder || "Enter confirmation text",
789
+ value: inputValue,
790
+ onChange: (event) => onInputChange(event.currentTarget.value)
791
+ }
792
+ ),
793
+ /* @__PURE__ */ jsx(Space, { h: 16 }),
794
+ /* @__PURE__ */ jsx(
795
+ Button,
796
+ {
797
+ color: buttonColor || "blue",
798
+ fullWidth: true,
799
+ onClick: confirmationHandler,
800
+ loading,
801
+ disabled: inputValue !== expectedValue,
802
+ children: buttonText || "Confirm"
803
+ }
804
+ )
805
+ ] });
806
+ };
807
+ function SortableHeader({ column, children, sort, onToggle, style, w }) {
808
+ const isActive = sort.column === column;
809
+ return /* @__PURE__ */ jsx(Table.Th, { style: { ...style, cursor: "pointer", userSelect: "none" }, w, onClick: () => onToggle(column), children: /* @__PURE__ */ jsxs(Group, { gap: 4, wrap: "nowrap", children: [
810
+ children,
811
+ isActive ? sort.direction === "asc" ? /* @__PURE__ */ jsx(IconChevronUp, { size: 14 }) : /* @__PURE__ */ jsx(IconChevronDown, { size: 14 }) : /* @__PURE__ */ jsx(IconSelector, { size: 14, style: { opacity: 0.3 } })
812
+ ] }) });
813
+ }
814
+ function FilterBar({ children, actions }) {
815
+ return /* @__PURE__ */ jsx(Paper, { children: /* @__PURE__ */ jsxs(Group, { gap: "md", wrap: "wrap", justify: "space-between", children: [
816
+ /* @__PURE__ */ jsx(Group, { gap: "md", wrap: "wrap", children }),
817
+ /* @__PURE__ */ jsx(Group, { gap: "md", children: actions })
818
+ ] }) });
819
+ }
820
+ function TableSelectionToolbar({ selectedCount, onDelete, isDeleting }) {
821
+ if (selectedCount === 0) return null;
822
+ return /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
823
+ /* @__PURE__ */ jsxs(Text, { size: "sm", fw: 600, c: "blue", children: [
824
+ selectedCount,
825
+ " selected"
826
+ ] }),
827
+ onDelete && /* @__PURE__ */ jsx(
828
+ Button,
829
+ {
830
+ size: "sm",
831
+ color: "red",
832
+ variant: "light",
833
+ leftSection: /* @__PURE__ */ jsx(IconTrash, { size: 16 }),
834
+ loading: isDeleting,
835
+ onClick: onDelete,
836
+ children: "Delete"
837
+ }
838
+ )
839
+ ] });
840
+ }
841
+ function FormFieldRenderer({ field, form, richTextRenderer }) {
842
+ const commonProps = {
843
+ label: field.label,
844
+ description: field.description,
845
+ placeholder: field.placeholder,
846
+ required: field.required,
847
+ ...form.getInputProps(field.name)
848
+ };
849
+ switch (field.type) {
850
+ case "text":
851
+ return /* @__PURE__ */ jsx(TextInput, { ...commonProps });
852
+ case "textarea":
853
+ return /* @__PURE__ */ jsx(Textarea, { ...commonProps, minRows: 3, autosize: true });
854
+ case "number":
855
+ return /* @__PURE__ */ jsx(NumberInput, { ...commonProps, min: field.min, max: field.max });
856
+ case "select":
857
+ return /* @__PURE__ */ jsx(
858
+ Select,
859
+ {
860
+ ...commonProps,
861
+ data: field.options?.map((opt) => ({
862
+ label: opt.label,
863
+ value: String(opt.value)
864
+ })) || []
865
+ }
866
+ );
867
+ case "checkbox":
868
+ return /* @__PURE__ */ jsx(Checkbox, { ...commonProps, ...form.getInputProps(field.name, { type: "checkbox" }) });
869
+ case "radio":
870
+ return /* @__PURE__ */ jsx(Radio.Group, { ...commonProps, children: /* @__PURE__ */ jsx(Stack, { gap: "xs", children: field.options?.map((opt) => /* @__PURE__ */ jsx(Radio, { value: String(opt.value), label: opt.label }, opt.value)) }) });
871
+ case "richtext": {
872
+ const inputProps = form.getInputProps(field.name);
873
+ if (richTextRenderer) {
874
+ return richTextRenderer({
875
+ content: inputProps.value || "",
876
+ onChange: (content) => form.setFieldValue(field.name, content),
877
+ placeholder: field.placeholder
878
+ });
879
+ }
880
+ return /* @__PURE__ */ jsx(Textarea, { ...commonProps, minRows: 5, autosize: true });
881
+ }
882
+ default:
883
+ return /* @__PURE__ */ jsx(TextInput, { ...commonProps });
884
+ }
885
+ }
886
+ function formatStartTime(timestamp) {
887
+ return new Date(timestamp).toLocaleString("en-US", {
888
+ month: "short",
889
+ day: "numeric",
890
+ hour: "numeric",
891
+ minute: "2-digit"
892
+ });
893
+ }
894
+ function getStatusConfig(status) {
895
+ switch (status) {
896
+ case "running":
897
+ return {
898
+ icon: /* @__PURE__ */ jsx(IconCircle, { size: 14, color: "var(--color-primary)" }),
899
+ label: "Running",
900
+ color: "blue"
901
+ };
902
+ case "completed":
903
+ return {
904
+ icon: /* @__PURE__ */ jsx(IconCircleCheck, { size: 14, color: "var(--color-success)" }),
905
+ label: "Completed",
906
+ color: "green"
907
+ };
908
+ case "failed":
909
+ return {
910
+ icon: /* @__PURE__ */ jsx(IconCircleX, { size: 14, color: "var(--color-error)" }),
911
+ label: "Failed",
912
+ color: "red"
913
+ };
914
+ case "warning":
915
+ return {
916
+ icon: /* @__PURE__ */ jsx(IconAlertTriangle, { size: 14, color: "var(--color-warning)" }),
917
+ label: "Warning",
918
+ color: "yellow"
919
+ };
920
+ case "pending":
921
+ default:
922
+ return {
923
+ icon: /* @__PURE__ */ jsx(IconCircle, { size: 14, color: "var(--mantine-color-gray-6)" }),
924
+ label: "Pending",
925
+ color: "gray"
926
+ };
927
+ }
928
+ }
929
+ function LoadingState() {
930
+ return /* @__PURE__ */ jsx(Center, { py: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "md" }) });
931
+ }
932
+ function EmptyState2() {
933
+ return /* @__PURE__ */ jsx(Center, { py: "xl", children: /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "xs", children: [
934
+ /* @__PURE__ */ jsx(IconFileOff, { size: 48, color: "var(--color-text-subtle)" }),
935
+ /* @__PURE__ */ jsx(Text, { size: "lg", fw: 500, c: "dimmed", children: "No executions found" }),
936
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Executions will appear here when workflows or agents are run" })
937
+ ] }) });
938
+ }
939
+ function ExecutionLogsTable({ executions, isLoading, onRowClick }) {
940
+ const handleRowClick = (execution) => {
941
+ onRowClick?.({
942
+ resourceType: execution.resourceType,
943
+ resourceId: execution.resourceId,
944
+ executionId: execution.id
945
+ });
946
+ };
947
+ return /* @__PURE__ */ jsxs(Table, { highlightOnHover: true, children: [
948
+ /* @__PURE__ */ jsx(Table.Thead, { children: /* @__PURE__ */ jsxs(Table.Tr, { children: [
949
+ /* @__PURE__ */ jsx(Table.Th, { children: "Resource" }),
950
+ /* @__PURE__ */ jsx(Table.Th, { children: "Status" }),
951
+ /* @__PURE__ */ jsx(Table.Th, { children: "Started" }),
952
+ /* @__PURE__ */ jsx(Table.Th, { ta: "right", children: "Duration" }),
953
+ /* @__PURE__ */ jsx(Table.Th, { ta: "center", children: "Env" }),
954
+ /* @__PURE__ */ jsx(Table.Th, { ta: "center", children: "Version" })
955
+ ] }) }),
956
+ /* @__PURE__ */ jsx(Table.Tbody, { children: isLoading ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: 6, children: /* @__PURE__ */ jsx(LoadingState, {}) }) }) : executions.length === 0 ? /* @__PURE__ */ jsx(Table.Tr, { children: /* @__PURE__ */ jsx(Table.Td, { colSpan: 6, children: /* @__PURE__ */ jsx(EmptyState2, {}) }) }) : executions.map((execution) => {
957
+ const statusConfig = getStatusConfig(execution.status);
958
+ return /* @__PURE__ */ jsxs(
959
+ Table.Tr,
960
+ {
961
+ style: { cursor: onRowClick ? "pointer" : void 0 },
962
+ onClick: () => handleRowClick(execution),
963
+ children: [
964
+ /* @__PURE__ */ jsx(Table.Td, { style: { maxWidth: 200 }, children: /* @__PURE__ */ jsx(Text, { size: "sm", lineClamp: 1, title: execution.resourceName, children: execution.resourceName }) }),
965
+ /* @__PURE__ */ jsx(Table.Td, { children: /* @__PURE__ */ jsx(Badge, { color: statusConfig.color, variant: "light", size: "sm", leftSection: statusConfig.icon, children: statusConfig.label }) }),
966
+ /* @__PURE__ */ jsx(Table.Td, { style: { whiteSpace: "nowrap" }, children: /* @__PURE__ */ jsx(Text, { size: "sm", children: formatStartTime(execution.startTime) }) }),
967
+ /* @__PURE__ */ jsx(Table.Td, { ta: "right", children: /* @__PURE__ */ jsx(Text, { size: "sm", c: execution.status === "running" ? "dimmed" : void 0, children: formatDuration(execution.duration) }) }),
968
+ /* @__PURE__ */ jsx(Table.Td, { ta: "center", children: /* @__PURE__ */ jsx(Badge, { color: execution.resourceStatus === "prod" ? "green" : "gray", variant: "light", size: "sm", children: execution.resourceStatus.toUpperCase() }) }),
969
+ /* @__PURE__ */ jsx(Table.Td, { ta: "center", children: /* @__PURE__ */ jsx(
970
+ Tooltip,
971
+ {
972
+ label: `Resource: ${execution.resourceVersion ?? "-"}
973
+ API: ${execution.apiVersion ?? "-"}
974
+ SDK: ${execution.sdkVersion ?? "-"}`,
975
+ multiline: true,
976
+ position: "left",
977
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", c: "dimmed", style: { cursor: "help" }, children: execution.resourceVersion ?? "-" })
978
+ }
979
+ ) })
980
+ ]
981
+ },
982
+ execution.id
983
+ );
984
+ }) })
985
+ ] });
986
+ }
987
+ function getHealthColor(successRate, hasExecutions = true) {
988
+ if (!hasExecutions) return "var(--mantine-color-gray-6)";
989
+ if (successRate >= 95) return "var(--color-success)";
990
+ if (successRate >= 80) return "var(--color-warning)";
991
+ return "var(--color-error)";
992
+ }
993
+ function ResourceHealthChart({
994
+ healthData,
995
+ hasExecutions = true,
996
+ width = 300,
997
+ height = 60
998
+ }) {
999
+ if (!healthData || healthData.trendData.length === 0) {
1000
+ return /* @__PURE__ */ jsx(Box, { w: width, h: height, style: { display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "No activity" }) });
1001
+ }
1002
+ const chartData = healthData.trendData.map((d) => ({
1003
+ time: d.time,
1004
+ rate: d.rate
1005
+ }));
1006
+ const chartColor = getHealthColor(healthData.summary.successRate, hasExecutions);
1007
+ return /* @__PURE__ */ jsx(Box, { w: width, h: height, children: /* @__PURE__ */ jsx(
1008
+ AreaChart,
1009
+ {
1010
+ h: height,
1011
+ data: chartData,
1012
+ dataKey: "time",
1013
+ series: [{ name: "rate", color: chartColor }],
1014
+ curveType: "monotone",
1015
+ withDots: false,
1016
+ withTooltip: false,
1017
+ withXAxis: false,
1018
+ withYAxis: false,
1019
+ fillOpacity: 0.2,
1020
+ gridAxis: "none"
1021
+ }
1022
+ ) });
1023
+ }
1024
+ var categoryColors = {
1025
+ info: "blue",
1026
+ queue: "cyan",
1027
+ alert: "yellow",
1028
+ error: "red",
1029
+ system: "gray"
1030
+ };
1031
+ function NotificationItem({ notification, onClose, onNavigate }) {
1032
+ const markAsRead = useMarkAsRead();
1033
+ const handleClick = async () => {
1034
+ if (!notification.read) {
1035
+ await markAsRead.mutateAsync(notification.id);
1036
+ }
1037
+ if (notification.actionUrl) {
1038
+ onNavigate?.(notification.actionUrl);
1039
+ }
1040
+ onClose?.();
1041
+ };
1042
+ const categoryColor = categoryColors[notification.category] || "gray";
1043
+ return /* @__PURE__ */ jsx(
1044
+ UnstyledButton,
1045
+ {
1046
+ onClick: handleClick,
1047
+ style: {
1048
+ width: "100%",
1049
+ padding: "12px",
1050
+ backgroundColor: "transparent",
1051
+ transition: "background-color var(--duration-fast) var(--easing)"
1052
+ },
1053
+ styles: {
1054
+ root: {
1055
+ "&:hover": {
1056
+ backgroundColor: "var(--color-surface-hover)"
1057
+ }
1058
+ }
1059
+ },
1060
+ children: /* @__PURE__ */ jsxs(Group, { gap: "sm", align: "flex-start", wrap: "nowrap", children: [
1061
+ /* @__PURE__ */ jsx(Box, { mt: 4, children: notification.read ? /* @__PURE__ */ jsx(IconCircle, { size: 12, color: "var(--mantine-color-gray-5)" }) : /* @__PURE__ */ jsx(IconCircleFilled, { size: 12, color: `var(--mantine-color-${categoryColor}-6)` }) }),
1062
+ /* @__PURE__ */ jsxs(Stack, { gap: 4, style: { flex: 1 }, children: [
1063
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: notification.read ? 400 : 600, children: notification.title }),
1064
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: notification.message }),
1065
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDistanceToNow(new Date(notification.createdAt), { addSuffix: true }) })
1066
+ ] })
1067
+ ] })
1068
+ }
1069
+ );
1070
+ }
1071
+ function NotificationList({ notifications: notifications2, isLoading, onClose, onNavigate }) {
1072
+ if (isLoading) {
1073
+ return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
1074
+ }
1075
+ if (notifications2.length === 0) {
1076
+ return /* @__PURE__ */ jsx(Center, { p: "xl", children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "No notifications" }) });
1077
+ }
1078
+ return /* @__PURE__ */ jsx(Stack, { gap: 0, children: notifications2.map((notification) => /* @__PURE__ */ jsx(NotificationItem, { notification, onClose, onNavigate }, notification.id)) });
1079
+ }
1080
+ function NotificationPanel({ notifications: notifications2, isLoading, onClose, onNavigate }) {
1081
+ const markAllAsRead = useMarkAllAsRead();
1082
+ const hasUnread = notifications2.some((n) => !n.read);
1083
+ const handleMarkAllAsRead = async () => {
1084
+ await markAllAsRead.mutateAsync();
1085
+ };
1086
+ return /* @__PURE__ */ jsxs(Box, { children: [
1087
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", p: "md", pb: "sm", children: [
1088
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Notifications" }),
1089
+ hasUnread && /* @__PURE__ */ jsx(Button, { variant: "subtle", size: "xs", onClick: handleMarkAllAsRead, loading: markAllAsRead.isPending, children: "Mark all as read" })
1090
+ ] }),
1091
+ /* @__PURE__ */ jsx(Divider, {}),
1092
+ /* @__PURE__ */ jsx(ScrollArea, { h: 400, type: "auto", children: /* @__PURE__ */ jsx(
1093
+ NotificationList,
1094
+ {
1095
+ notifications: notifications2,
1096
+ isLoading,
1097
+ onClose,
1098
+ onNavigate
1099
+ }
1100
+ ) })
1101
+ ] });
1102
+ }
1103
+ function NotificationBell({ unreadCount, onNavigate }) {
1104
+ const [opened, { toggle, close }] = useDisclosure(false);
1105
+ const { data: apiCount = 0 } = useNotificationCount();
1106
+ const { data, isLoading } = useNotifications({ limit: 20 });
1107
+ const notifications2 = data?.notifications ?? [];
1108
+ const count = unreadCount ?? apiCount;
1109
+ return /* @__PURE__ */ jsxs(Popover, { opened, onChange: toggle, position: "bottom-end", width: 400, children: [
1110
+ /* @__PURE__ */ jsx(Tooltip, { label: "Notifications", disabled: opened, children: /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(Indicator, { label: count > 99 ? "99+" : count, disabled: count === 0, size: 16, offset: 4, children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", size: "lg", onClick: toggle, children: /* @__PURE__ */ jsx(IconBell, { size: 20, color: "var(--color-text-subtle)" }) }) }) }) }),
1111
+ /* @__PURE__ */ jsx(Popover.Dropdown, { p: 0, children: /* @__PURE__ */ jsx(
1112
+ NotificationPanel,
1113
+ {
1114
+ notifications: notifications2,
1115
+ isLoading,
1116
+ onClose: close,
1117
+ onNavigate
1118
+ }
1119
+ ) })
1120
+ ] });
1121
+ }
1122
+ function ExecutionStatusBadge({
1123
+ status,
1124
+ size = "sm",
1125
+ variant = "light",
1126
+ showLoader = true
1127
+ }) {
1128
+ const statusColors = STATUS_COLORS[status];
1129
+ const isRunning = status === "running" && showLoader;
1130
+ return /* @__PURE__ */ jsx(
1131
+ Badge,
1132
+ {
1133
+ color: statusColors.badge,
1134
+ size,
1135
+ variant,
1136
+ leftSection: isRunning ? /* @__PURE__ */ jsx(Loader, { size: 10, color: statusColors.badge }) : void 0,
1137
+ children: status.charAt(0).toUpperCase() + status.slice(1)
1138
+ }
1139
+ );
1140
+ }
1141
+ function getRateColor(rate) {
1142
+ if (rate >= 95) return "var(--color-success)";
1143
+ if (rate >= 80) return "var(--color-warning)";
1144
+ return "var(--color-error)";
1145
+ }
1146
+ function getMantineRateColor(rate) {
1147
+ if (rate >= 95) return "green";
1148
+ if (rate >= 80) return "yellow";
1149
+ return "red";
1150
+ }
1151
+ function ExecutionStats({
1152
+ totalExecutions,
1153
+ successCount,
1154
+ failureCount,
1155
+ warningCount,
1156
+ successRate,
1157
+ align = "flex-end",
1158
+ compact = false
1159
+ }) {
1160
+ if (totalExecutions === 0 && !compact) {
1161
+ return null;
1162
+ }
1163
+ if (compact && totalExecutions === 0) {
1164
+ return /* @__PURE__ */ jsxs(Group, { gap: 10, wrap: "nowrap", style: { width: "100%" }, children: [
1165
+ /* @__PURE__ */ jsx(Text, { size: "md", fw: 700, ff: "monospace", c: "dimmed", style: { minWidth: 42 }, children: "\u2014" }),
1166
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: "No recent executions" })
1167
+ ] });
1168
+ }
1169
+ if (compact) {
1170
+ return /* @__PURE__ */ jsxs(Group, { gap: 10, wrap: "nowrap", style: { width: "100%" }, children: [
1171
+ /* @__PURE__ */ jsxs(Group, { gap: 8, wrap: "nowrap", children: [
1172
+ /* @__PURE__ */ jsxs(Text, { size: "md", fw: 700, ff: "monospace", style: { color: getRateColor(successRate), minWidth: 42 }, children: [
1173
+ successRate,
1174
+ "%"
1175
+ ] }),
1176
+ /* @__PURE__ */ jsxs(Group, { gap: 5, wrap: "nowrap", children: [
1177
+ /* @__PURE__ */ jsx("div", { style: { width: 7, height: 7, borderRadius: "50%", background: "var(--color-success)" } }),
1178
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, c: "green", children: successCount })
1179
+ ] }),
1180
+ failureCount > 0 && /* @__PURE__ */ jsxs(Group, { gap: 5, wrap: "nowrap", children: [
1181
+ /* @__PURE__ */ jsx("div", { style: { width: 7, height: 7, borderRadius: "50%", background: "var(--color-error)" } }),
1182
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, c: "red", children: failureCount })
1183
+ ] })
1184
+ ] }),
1185
+ /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", style: { whiteSpace: "nowrap" }, children: [
1186
+ totalExecutions,
1187
+ " ",
1188
+ totalExecutions === 1 ? "run" : "runs"
1189
+ ] })
1190
+ ] });
1191
+ }
1192
+ return /* @__PURE__ */ jsxs(Stack, { gap: 2, align, style: { whiteSpace: "nowrap" }, children: [
1193
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "blue", children: [
1194
+ totalExecutions,
1195
+ " ",
1196
+ totalExecutions === 1 ? "execution" : "executions"
1197
+ ] }),
1198
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "green", children: [
1199
+ successCount,
1200
+ " success"
1201
+ ] }),
1202
+ warningCount != null && warningCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "yellow", children: [
1203
+ warningCount,
1204
+ " warning"
1205
+ ] }),
1206
+ failureCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "red", children: [
1207
+ failureCount,
1208
+ " failed"
1209
+ ] }),
1210
+ /* @__PURE__ */ jsxs(Text, { size: "xs", fw: 600, c: getMantineRateColor(successRate), children: [
1211
+ successRate,
1212
+ "% Success Rate"
1213
+ ] })
1214
+ ] });
1215
+ }
1216
+ function TimelineAxis({ totalDuration }) {
1217
+ const markers = [
1218
+ { position: 0, time: 0 },
1219
+ { position: 25, time: totalDuration * 0.25 },
1220
+ { position: 50, time: totalDuration * 0.5 },
1221
+ { position: 75, time: totalDuration * 0.75 },
1222
+ { position: 100, time: totalDuration }
1223
+ ];
1224
+ return /* @__PURE__ */ jsx(
1225
+ Box,
1226
+ {
1227
+ style: {
1228
+ position: "relative",
1229
+ height: 20
1230
+ },
1231
+ children: markers.map((marker, idx) => /* @__PURE__ */ jsx(
1232
+ Box,
1233
+ {
1234
+ style: {
1235
+ position: "absolute",
1236
+ left: `${marker.position}%`,
1237
+ transform: marker.position === 100 ? "translateX(-100%)" : marker.position === 0 ? "none" : "translateX(-50%)",
1238
+ top: 4
1239
+ },
1240
+ children: /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(marker.time) })
1241
+ },
1242
+ idx
1243
+ ))
1244
+ }
1245
+ );
1246
+ }
1247
+ function TimelineContainer({ executionStart, executionEnd, children }) {
1248
+ const totalDuration = executionEnd - executionStart;
1249
+ return /* @__PURE__ */ jsxs(
1250
+ Box,
1251
+ {
1252
+ style: {
1253
+ borderBottom: "1px solid var(--color-border)",
1254
+ borderRadius: "var(--mantine-radius-default)",
1255
+ backgroundColor: "var(--color-background)",
1256
+ padding: "var(--mantine-spacing-xs)"
1257
+ },
1258
+ children: [
1259
+ /* @__PURE__ */ jsx(
1260
+ Box,
1261
+ {
1262
+ style: {
1263
+ position: "relative"
1264
+ },
1265
+ children: /* @__PURE__ */ jsx(Box, { style: { position: "relative", zIndex: 1 }, children })
1266
+ }
1267
+ ),
1268
+ /* @__PURE__ */ jsx(Box, { style: { paddingLeft: TIMELINE_CONSTANTS.LABEL_WIDTH + 12, paddingRight: 16 }, children: /* @__PURE__ */ jsx(TimelineAxis, { totalDuration }) })
1269
+ ]
1270
+ }
1271
+ );
1272
+ }
1273
+ function TimelineBar({
1274
+ startTime,
1275
+ endTime,
1276
+ executionStart,
1277
+ executionEnd,
1278
+ status,
1279
+ label,
1280
+ onClick,
1281
+ isSelected = false,
1282
+ hasSelection = false
1283
+ }) {
1284
+ const colors = getStatusColors(status);
1285
+ const { left, width } = calculateBarPosition(startTime, endTime, executionStart, executionEnd);
1286
+ const opacity = hasSelection && !isSelected ? 0.5 : 1;
1287
+ return /* @__PURE__ */ jsx(
1288
+ Box,
1289
+ {
1290
+ style: {
1291
+ position: "absolute",
1292
+ left: `${left}%`,
1293
+ width: `${width}%`,
1294
+ top: 4,
1295
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT / 2,
1296
+ backgroundColor: colors.color,
1297
+ opacity,
1298
+ borderRadius: 4,
1299
+ cursor: onClick ? "pointer" : "default",
1300
+ display: "flex",
1301
+ alignItems: "center",
1302
+ justifyContent: "center",
1303
+ overflow: "hidden"
1304
+ },
1305
+ onClick,
1306
+ children: label && /* @__PURE__ */ jsx(Text, { size: "xs", c: "white", style: { whiteSpace: "nowrap" }, children: label })
1307
+ }
1308
+ );
1309
+ }
1310
+ function TimelineRow({
1311
+ label,
1312
+ bars,
1313
+ executionStart,
1314
+ executionEnd,
1315
+ indent = 0,
1316
+ selectedNodeId
1317
+ }) {
1318
+ const labelMatch = label.match(/^(.+?)\s*\((.+?)\)$/);
1319
+ const labelName = labelMatch ? labelMatch[1] : label;
1320
+ const labelDuration = labelMatch ? labelMatch[2] : null;
1321
+ const statusColor = bars.length > 0 ? getStatusColors(bars[0].status).color : "var(--color-text-dimmed)";
1322
+ const hasSelection = selectedNodeId !== null && selectedNodeId !== void 0;
1323
+ return /* @__PURE__ */ jsxs(
1324
+ Box,
1325
+ {
1326
+ style: {
1327
+ display: "flex",
1328
+ gap: 0,
1329
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT
1330
+ // paddingLeft: indent * TIMELINE_CONSTANTS.INDENT_SIZE
1331
+ },
1332
+ children: [
1333
+ /* @__PURE__ */ jsxs(
1334
+ Box,
1335
+ {
1336
+ style: {
1337
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT,
1338
+ width: TIMELINE_CONSTANTS.LABEL_WIDTH,
1339
+ flexShrink: 0,
1340
+ display: "flex",
1341
+ alignItems: "center",
1342
+ gap: 6,
1343
+ paddingRight: 12,
1344
+ paddingLeft: 8 + indent * TIMELINE_CONSTANTS.INDENT_SIZE,
1345
+ // Indent only the label, not the timeline bars
1346
+ overflow: "hidden"
1347
+ },
1348
+ children: [
1349
+ /* @__PURE__ */ jsx(
1350
+ Box,
1351
+ {
1352
+ style: {
1353
+ width: 6,
1354
+ height: 6,
1355
+ borderRadius: "50%",
1356
+ backgroundColor: statusColor,
1357
+ flexShrink: 0
1358
+ }
1359
+ }
1360
+ ),
1361
+ /* @__PURE__ */ jsx(Text, { size: "sm", truncate: true, style: { flexShrink: 1, minWidth: 0 }, children: labelName }),
1362
+ labelDuration && /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", ff: "monospace", style: { flexShrink: 0 }, children: [
1363
+ "(",
1364
+ labelDuration,
1365
+ ")"
1366
+ ] })
1367
+ ]
1368
+ }
1369
+ ),
1370
+ /* @__PURE__ */ jsx(
1371
+ Box,
1372
+ {
1373
+ style: {
1374
+ position: "relative",
1375
+ flex: 1,
1376
+ height: TIMELINE_CONSTANTS.BAR_HEIGHT,
1377
+ marginLeft: 12,
1378
+ marginRight: 16
1379
+ // Right margin to match grid padding
1380
+ },
1381
+ children: bars.map((bar, idx) => {
1382
+ const isSelected = bar.nodeId !== void 0 && bar.nodeId === selectedNodeId;
1383
+ return /* @__PURE__ */ jsx(
1384
+ TimelineBar,
1385
+ {
1386
+ ...bar,
1387
+ executionStart,
1388
+ executionEnd,
1389
+ isSelected,
1390
+ hasSelection
1391
+ },
1392
+ idx
1393
+ );
1394
+ })
1395
+ }
1396
+ )
1397
+ ]
1398
+ }
1399
+ );
1400
+ }
1401
+ var VisualizerContainer = ({ children, handleContainerClick, height }) => {
1402
+ const containerHeight = height ?? CONTAINER_CONSTANTS.CONTAINER_HEIGHT;
1403
+ return /* @__PURE__ */ jsx(
1404
+ Box,
1405
+ {
1406
+ bg: "var(--color-background)",
1407
+ onClick: handleContainerClick,
1408
+ style: {
1409
+ borderBottom: "1px solid var(--color-border)",
1410
+ borderRadius: "var(--mantine-radius-default)"
1411
+ },
1412
+ children: /* @__PURE__ */ jsx(
1413
+ "div",
1414
+ {
1415
+ style: {
1416
+ width: "100%",
1417
+ height: `${containerHeight}px`,
1418
+ overflow: "hidden"
1419
+ },
1420
+ children
1421
+ }
1422
+ )
1423
+ }
1424
+ );
1425
+ };
1426
+ var EmptyVisualizer = ({ message = "Select an execution to view timeline" }) => {
1427
+ return /* @__PURE__ */ jsx(
1428
+ Box,
1429
+ {
1430
+ h: CONTAINER_CONSTANTS.CONTAINER_HEIGHT,
1431
+ bg: "var(--color-background)",
1432
+ style: {
1433
+ borderBottom: "1px solid var(--color-border)",
1434
+ borderRadius: "var(--mantine-radius-default)",
1435
+ display: "flex",
1436
+ alignItems: "center",
1437
+ justifyContent: "center"
1438
+ },
1439
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: message })
1440
+ }
1441
+ );
1442
+ };
1443
+ var DOMAIN_COLORS = {
1444
+ primary: "var(--color-primary)",
1445
+ agent: "#8b5cf6",
1446
+ workflow: "#3b82f6",
1447
+ trigger: "#f97316",
1448
+ integration: "#14b8a6",
1449
+ approval: "#f59e0b"
1450
+ };
1451
+ function fill(color, isDark) {
1452
+ return isDark ? `color-mix(in srgb, ${color} 80%, black)` : `color-mix(in srgb, ${color} 60%, white)`;
1453
+ }
1454
+ function glow(color) {
1455
+ return `color-mix(in srgb, ${color} 40%, transparent)`;
1456
+ }
1457
+ function useGraphTheme() {
1458
+ const isDark = useComputedColorScheme("dark") === "dark";
1459
+ return useMemo(
1460
+ () => ({
1461
+ primary: fill(DOMAIN_COLORS.primary, isDark),
1462
+ primaryGlow: glow(DOMAIN_COLORS.primary),
1463
+ agent: fill(DOMAIN_COLORS.agent, isDark),
1464
+ workflow: fill(DOMAIN_COLORS.workflow, isDark),
1465
+ trigger: fill(DOMAIN_COLORS.trigger, isDark),
1466
+ integration: fill(DOMAIN_COLORS.integration, isDark),
1467
+ approval: fill(DOMAIN_COLORS.approval, isDark),
1468
+ agentGlow: glow(DOMAIN_COLORS.agent),
1469
+ workflowGlow: glow(DOMAIN_COLORS.workflow),
1470
+ triggerGlow: glow(DOMAIN_COLORS.trigger),
1471
+ integrationGlow: glow(DOMAIN_COLORS.integration),
1472
+ approvalGlow: glow(DOMAIN_COLORS.approval),
1473
+ edgeTriggers: fill(DOMAIN_COLORS.workflow, isDark),
1474
+ edgeUses: fill(DOMAIN_COLORS.integration, isDark),
1475
+ edgeApproval: fill(DOMAIN_COLORS.approval, isDark),
1476
+ edgeTriggersGlow: glow(DOMAIN_COLORS.workflow),
1477
+ edgeUsesGlow: glow(DOMAIN_COLORS.integration),
1478
+ edgeApprovalGlow: glow(DOMAIN_COLORS.approval)
1479
+ }),
1480
+ [isDark]
1481
+ );
1482
+ }
1483
+ function getGraphBackgroundStyles(isDark) {
1484
+ const pct = isDark ? 5 : 3;
1485
+ const glowPct = isDark ? 8 : 5;
1486
+ const mix = (percent) => `color-mix(in srgb, var(--color-primary) ${percent}%, transparent)`;
1487
+ return {
1488
+ backgroundImage: `
1489
+ linear-gradient(${mix(pct)} 1px, transparent 1px),
1490
+ linear-gradient(90deg, ${mix(pct)} 1px, transparent 1px),
1491
+ radial-gradient(ellipse at 50% 50%, ${mix(glowPct)} 0%, transparent 70%)
1492
+ `,
1493
+ backgroundColor: "var(--color-background)",
1494
+ backgroundSize: "40px 40px, 40px 40px, 100% 100%"
1495
+ };
1496
+ }
1497
+ function useGraphBackgroundStyles() {
1498
+ const isDark = useComputedColorScheme("dark") === "dark";
1499
+ return useMemo(() => getGraphBackgroundStyles(isDark), [isDark]);
1500
+ }
1501
+ function GraphContainer({ children, height = 600 }) {
1502
+ const backgroundStyles = useGraphBackgroundStyles();
1503
+ return /* @__PURE__ */ jsx(
1504
+ Box,
1505
+ {
1506
+ style: {
1507
+ width: "100%",
1508
+ height,
1509
+ border: "1px solid var(--color-border)",
1510
+ borderRadius: "var(--mantine-radius-md)",
1511
+ overflow: "hidden",
1512
+ position: "relative",
1513
+ ...backgroundStyles
1514
+ },
1515
+ children
1516
+ }
1517
+ );
1518
+ }
1519
+ function GraphBackground() {
1520
+ return null;
1521
+ }
1522
+ function LegendDot({ color }) {
1523
+ return /* @__PURE__ */ jsx(
1524
+ Box,
1525
+ {
1526
+ style: {
1527
+ width: 10,
1528
+ height: 10,
1529
+ borderRadius: "50%",
1530
+ backgroundColor: `var(--mantine-color-${color}-5)`
1531
+ }
1532
+ }
1533
+ );
1534
+ }
1535
+ function LegendLine({ color }) {
1536
+ return /* @__PURE__ */ jsx(
1537
+ Box,
1538
+ {
1539
+ style: {
1540
+ width: 20,
1541
+ height: 3,
1542
+ borderRadius: 2,
1543
+ background: `linear-gradient(90deg, var(--mantine-color-${color}-5), var(--mantine-color-${color}-6))`
1544
+ }
1545
+ }
1546
+ );
1547
+ }
1548
+ function GraphLegend({ title = "Legend", items, position = "bottom-right" }) {
1549
+ const margins = {
1550
+ marginBottom: position.includes("bottom") ? 12 : void 0,
1551
+ marginTop: position.includes("top") ? 12 : void 0,
1552
+ marginRight: position.includes("right") ? 60 : 12,
1553
+ marginLeft: position.includes("left") ? 12 : void 0
1554
+ };
1555
+ return /* @__PURE__ */ jsx(Panel, { position, style: margins, children: /* @__PURE__ */ jsx(
1556
+ Card,
1557
+ {
1558
+ p: "xs",
1559
+ className: void 0,
1560
+ style: {
1561
+ backgroundColor: "var(--glass-background)"
1562
+ },
1563
+ children: /* @__PURE__ */ jsxs(Group, { children: [
1564
+ /* @__PURE__ */ jsx(
1565
+ Text,
1566
+ {
1567
+ size: "xs",
1568
+ fw: 600,
1569
+ style: {
1570
+ letterSpacing: "0.5px",
1571
+ textTransform: "uppercase",
1572
+ fontFamily: "var(--mantine-font-family-headings)"
1573
+ },
1574
+ children: title
1575
+ }
1576
+ ),
1577
+ items.map((item) => /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1578
+ item.type === "line" ? /* @__PURE__ */ jsx(LegendLine, { color: item.color }) : /* @__PURE__ */ jsx(LegendDot, { color: item.color }),
1579
+ /* @__PURE__ */ jsx(Text, { size: "xs", children: item.label })
1580
+ ] }, item.label))
1581
+ ] })
1582
+ }
1583
+ ) });
1584
+ }
1585
+ function GraphFitViewButton({ padding = 0.2, variant = "reactflow", duration = 300 }) {
1586
+ const { fitView } = useReactFlow();
1587
+ const handleFitView = () => {
1588
+ fitView({ padding, duration });
1589
+ };
1590
+ if (variant === "mantine") {
1591
+ return /* @__PURE__ */ jsx(
1592
+ ActionIcon,
1593
+ {
1594
+ onClick: handleFitView,
1595
+ variant: "default",
1596
+ size: "lg",
1597
+ title: "Fit view",
1598
+ style: {
1599
+ position: "absolute",
1600
+ bottom: 12,
1601
+ right: 12,
1602
+ zIndex: 5,
1603
+ background: "var(--color-surface)",
1604
+ border: "1px solid var(--color-border)"
1605
+ },
1606
+ children: /* @__PURE__ */ jsx(IconFocus2, { size: 18 })
1607
+ }
1608
+ );
1609
+ }
1610
+ return /* @__PURE__ */ jsx(Controls, { position: "bottom-right", showZoom: false, showFitView: false, showInteractive: false, children: /* @__PURE__ */ jsx(
1611
+ "button",
1612
+ {
1613
+ className: "react-flow__controls-button react-flow__controls-fitview",
1614
+ onClick: handleFitView,
1615
+ title: "Fit view",
1616
+ children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { d: "M8 3H5C3.89 3 3 3.89 3 5V8H5V5H8V3M19 3H16V5H19V8H21V5C21 3.89 20.11 3 19 3M19 19H16V21H19C20.11 21 21 20.11 21 19V16H19V19M5 19H8V21H5C3.89 21 3 20.11 3 19V16H5V19Z" }) })
1617
+ }
1618
+ ) });
1619
+ }
1620
+ function GraphFitViewHandler({
1621
+ trigger,
1622
+ padding = 0.15,
1623
+ duration = 300,
1624
+ delay = 250
1625
+ }) {
1626
+ const { fitView } = useReactFlow();
1627
+ useEffect(() => {
1628
+ if (trigger && trigger > 0) {
1629
+ const timeout = setTimeout(() => {
1630
+ fitView({ padding, duration });
1631
+ }, delay);
1632
+ return () => clearTimeout(timeout);
1633
+ }
1634
+ return void 0;
1635
+ }, [trigger, fitView, padding, duration, delay]);
1636
+ return null;
1637
+ }
1638
+ var colorClassMap = {
1639
+ violet: void 0,
1640
+ blue: void 0,
1641
+ orange: void 0,
1642
+ teal: void 0,
1643
+ gray: void 0,
1644
+ yellow: void 0
1645
+ };
1646
+ var BaseNode = memo(function BaseNode2({
1647
+ children,
1648
+ color,
1649
+ selected = false,
1650
+ highlighted = false,
1651
+ width = 220,
1652
+ className = "",
1653
+ handleDirection = "horizontal",
1654
+ showSourceHandle = true,
1655
+ showTargetHandle = true
1656
+ }) {
1657
+ const typeClass = colorClassMap[color] || void 0;
1658
+ const highlightClass = highlighted ? void 0 : "";
1659
+ const targetPosition = handleDirection === "horizontal" ? Position.Left : Position.Top;
1660
+ const sourcePosition = handleDirection === "horizontal" ? Position.Right : Position.Bottom;
1661
+ return /* @__PURE__ */ jsxs("div", { className: `${ void 0} ${typeClass} ${highlightClass} ${className}`, children: [
1662
+ showTargetHandle && /* @__PURE__ */ jsx(Handle, { type: "target", position: targetPosition, style: { opacity: 0, pointerEvents: "none" } }),
1663
+ showSourceHandle && /* @__PURE__ */ jsx(Handle, { type: "source", position: sourcePosition, style: { opacity: 0, pointerEvents: "none" } }),
1664
+ /* @__PURE__ */ jsx(
1665
+ Paper,
1666
+ {
1667
+ p: "sm",
1668
+ className: `${ void 0} ${selected ? void 0 : ""}`,
1669
+ style: {
1670
+ width,
1671
+ border: `1px solid ${selected ? `var(--mantine-color-${color}-5)` : "var(--color-border)"}`,
1672
+ backgroundColor: "var(--color-surface)",
1673
+ cursor: "pointer",
1674
+ boxShadow: selected ? `0 0 15px var(--mantine-color-${color}-5), 0 4px 12px rgba(0,0,0,0.1)` : "0 2px 8px rgba(0,0,0,0.08)"
1675
+ },
1676
+ children
1677
+ }
1678
+ )
1679
+ ] });
1680
+ });
1681
+ var BaseEdge = memo(function BaseEdge2({
1682
+ id,
1683
+ sourceX,
1684
+ sourceY,
1685
+ targetX,
1686
+ targetY,
1687
+ sourcePosition,
1688
+ targetPosition,
1689
+ color,
1690
+ glowColor,
1691
+ label,
1692
+ selected,
1693
+ animated = true,
1694
+ dimmed = false,
1695
+ edgeIndex = 0,
1696
+ totalEdges = 1
1697
+ }) {
1698
+ const edgeSpacing = 10;
1699
+ const baseOffset = 15;
1700
+ const offsetAmount = totalEdges > 1 ? (edgeIndex - (totalEdges - 1) / 2) * edgeSpacing : 0;
1701
+ const [edgePath, labelX, labelY] = getSmoothStepPath({
1702
+ sourceX,
1703
+ sourceY: sourceY + offsetAmount,
1704
+ sourcePosition,
1705
+ targetX,
1706
+ targetY: targetY + offsetAmount,
1707
+ targetPosition,
1708
+ borderRadius: 8,
1709
+ offset: baseOffset + Math.abs(offsetAmount)
1710
+ // Stagger the turn points horizontally
1711
+ });
1712
+ const edgeOpacity = dimmed ? 0.25 : 1;
1713
+ return /* @__PURE__ */ jsxs("g", { style: { opacity: edgeOpacity }, children: [
1714
+ /* @__PURE__ */ jsx(
1715
+ "path",
1716
+ {
1717
+ d: edgePath,
1718
+ fill: "none",
1719
+ stroke: color,
1720
+ strokeWidth: selected ? 8 : 6,
1721
+ strokeOpacity: 0.2,
1722
+ style: { filter: "blur(4px)" }
1723
+ }
1724
+ ),
1725
+ animated && !dimmed && /* @__PURE__ */ jsx(
1726
+ "path",
1727
+ {
1728
+ d: edgePath,
1729
+ fill: "none",
1730
+ stroke: color,
1731
+ strokeWidth: selected ? 4 : 3,
1732
+ strokeOpacity: 0.3,
1733
+ strokeDasharray: "12 6",
1734
+ className: Graph_default.edgeAnimated,
1735
+ style: { filter: `drop-shadow(0 0 3px ${glowColor})` }
1736
+ }
1737
+ ),
1738
+ /* @__PURE__ */ jsx(
1739
+ BaseEdge$1,
1740
+ {
1741
+ id,
1742
+ path: edgePath,
1743
+ style: {
1744
+ stroke: color,
1745
+ strokeWidth: selected ? 3 : 2,
1746
+ filter: dimmed ? "none" : selected ? `drop-shadow(0 0 6px ${glowColor})` : `drop-shadow(0 0 2px ${glowColor})`
1747
+ }
1748
+ }
1749
+ ),
1750
+ animated && !dimmed && /* @__PURE__ */ jsx(
1751
+ "path",
1752
+ {
1753
+ d: edgePath,
1754
+ fill: "none",
1755
+ stroke: "white",
1756
+ strokeWidth: 2,
1757
+ strokeOpacity: 0.6,
1758
+ strokeDasharray: "4 20",
1759
+ className: Graph_default.edgeAnimated,
1760
+ style: { filter: "drop-shadow(0 0 2px white)" }
1761
+ }
1762
+ ),
1763
+ label && /* @__PURE__ */ jsx(EdgeLabelRenderer, { children: /* @__PURE__ */ jsx(
1764
+ "div",
1765
+ {
1766
+ className: `${Graph_default.edgeLabel} ${dimmed ? Graph_default.edgeLabelDimmed : ""}`,
1767
+ style: {
1768
+ position: "absolute",
1769
+ transform: `translate(-50%, -50%) translate(${labelX}px, ${labelY}px)`,
1770
+ pointerEvents: "all",
1771
+ fontSize: 10,
1772
+ fontWeight: 600,
1773
+ textTransform: "uppercase",
1774
+ letterSpacing: "0.5px",
1775
+ padding: "3px 8px",
1776
+ borderRadius: 6,
1777
+ background: `linear-gradient(135deg, ${color}, ${color}dd)`,
1778
+ color: "var(--color-text)",
1779
+ boxShadow: "0 2px 8px rgba(0,0,0,0.2)",
1780
+ opacity: dimmed ? 0.25 : 1
1781
+ },
1782
+ children: label
1783
+ }
1784
+ ) })
1785
+ ] });
1786
+ });
1787
+ var UnifiedWorkflowNode = memo(function UnifiedWorkflowNode2({ data }) {
1788
+ const selected = data.isSelected ?? false;
1789
+ const primaryColor = data.isEntryPoint ? "teal" : data.isEndNode ? "violet" : data.isConditional ? "orange" : "blue";
1790
+ const statusColors = data.executionStatus ? STATUS_COLORS[data.executionStatus] : void 0;
1791
+ const showExecutionStatus = data.isExecuted && data.executionStatus;
1792
+ return /* @__PURE__ */ jsx(
1793
+ BaseNode,
1794
+ {
1795
+ color: primaryColor,
1796
+ selected,
1797
+ highlighted: Boolean(data.highlighted),
1798
+ width: 220,
1799
+ className: data.isDimmed ? "dimmed-node" : "",
1800
+ showSourceHandle: !data.isEndNode,
1801
+ children: /* @__PURE__ */ jsx("div", { style: { opacity: data.isDimmed ? 0.3 : 1 }, children: /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
1802
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, lineClamp: 1, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: data.name }),
1803
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
1804
+ data.isEntryPoint && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "teal", leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 10 }), children: "Entry" }),
1805
+ data.isEndNode && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "violet", leftSection: /* @__PURE__ */ jsx(IconPlayerStop, { size: 10 }), children: "End" }),
1806
+ data.isConditional && /* @__PURE__ */ jsxs(Badge, { size: "xs", variant: "light", color: "orange", leftSection: /* @__PURE__ */ jsx(IconArrowsSplit, { size: 10 }), children: [
1807
+ data.routeCount,
1808
+ " routes"
1809
+ ] }),
1810
+ !data.isEntryPoint && !data.isEndNode && !data.isConditional && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", leftSection: /* @__PURE__ */ jsx(IconSquare, { size: 10 }), children: "Step" }),
1811
+ /* @__PURE__ */ jsx(Text, { size: "xs", ff: "monospace", c: "dimmed", truncate: true, children: data.id })
1812
+ ] }),
1813
+ !data.isDimmed && data.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: data.description }),
1814
+ showExecutionStatus && statusColors && /* @__PURE__ */ jsx(Box, { mt: 4, children: /* @__PURE__ */ jsxs(Group, { gap: 8, align: "center", children: [
1815
+ /* @__PURE__ */ jsx(Box, { children: getStatusIcon({
1816
+ status: data.executionStatus,
1817
+ colors: { icon: statusColors.color },
1818
+ iconSize: 16,
1819
+ spinDuration: "1s"
1820
+ }) }),
1821
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: statusColors.badge, children: data.executionStatus }),
1822
+ data.duration !== void 0 && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(data.duration) })
1823
+ ] }) })
1824
+ ] }) })
1825
+ }
1826
+ );
1827
+ });
1828
+ var UnifiedWorkflowEdge = memo(function UnifiedWorkflowEdge2({
1829
+ id,
1830
+ sourceX,
1831
+ sourceY,
1832
+ targetX,
1833
+ targetY,
1834
+ selected,
1835
+ data
1836
+ }) {
1837
+ const colors = useGraphTheme();
1838
+ const edgeType = data?.edgeType || "linear";
1839
+ const isDimmed = data?.isDimmed ?? false;
1840
+ const isAnimated = data?.isAnimated ?? false;
1841
+ let edgeColor;
1842
+ let glowColor;
1843
+ let label;
1844
+ switch (edgeType) {
1845
+ case "conditional":
1846
+ edgeColor = colors.trigger;
1847
+ glowColor = colors.triggerGlow;
1848
+ label = data?.label || "route";
1849
+ break;
1850
+ case "default":
1851
+ edgeColor = colors.integration;
1852
+ glowColor = colors.integrationGlow;
1853
+ label = data?.label || "default";
1854
+ break;
1855
+ case "linear":
1856
+ default:
1857
+ edgeColor = colors.workflow;
1858
+ glowColor = colors.workflowGlow;
1859
+ label = void 0;
1860
+ break;
1861
+ }
1862
+ return /* @__PURE__ */ jsx(
1863
+ BaseEdge,
1864
+ {
1865
+ id,
1866
+ sourceX,
1867
+ sourceY,
1868
+ targetX,
1869
+ targetY,
1870
+ sourcePosition: Position.Right,
1871
+ targetPosition: Position.Left,
1872
+ color: edgeColor,
1873
+ glowColor,
1874
+ label,
1875
+ selected,
1876
+ animated: isAnimated,
1877
+ dimmed: isDimmed
1878
+ }
1879
+ );
1880
+ });
1881
+ var nodeTypes = {
1882
+ unifiedWorkflowNode: UnifiedWorkflowNode
1883
+ };
1884
+ var edgeTypes = {
1885
+ unifiedWorkflowEdge: UnifiedWorkflowEdge
1886
+ };
1887
+ var NODE_LEGEND_ITEMS = [
1888
+ { color: "teal", label: "Entry" },
1889
+ { color: "blue", label: "Step" },
1890
+ { color: "orange", label: "Conditional" },
1891
+ { color: "violet", label: "End" }
1892
+ ];
1893
+ var EDGE_LEGEND_ITEMS = [
1894
+ { color: "blue", label: "Next", type: "line" },
1895
+ { color: "orange", label: "Route", type: "line" },
1896
+ { color: "teal", label: "Default", type: "line" }
1897
+ ];
1898
+ function UnifiedWorkflowGraph({
1899
+ resourceDefinition,
1900
+ executionLogs,
1901
+ selectedStepId,
1902
+ onStepSelect,
1903
+ fitViewTrigger: externalFitViewTrigger
1904
+ }) {
1905
+ const hasExecutionData = executionLogs && executionLogs.length > 0;
1906
+ const [mode, setMode] = useState(hasExecutionData ? "execution" : "definition");
1907
+ useEffect(() => {
1908
+ setMode(hasExecutionData ? "execution" : "definition");
1909
+ }, [hasExecutionData]);
1910
+ const isDefinitionMode = mode === "definition";
1911
+ const executionPath = useExecutionPath(
1912
+ isDefinitionMode ? void 0 : executionLogs,
1913
+ isDefinitionMode ? void 0 : resourceDefinition
1914
+ );
1915
+ const workflowInput = useMemo(
1916
+ () => resourceDefinition ? { entryPoint: resourceDefinition.entryPoint, steps: resourceDefinition.steps } : void 0,
1917
+ [resourceDefinition]
1918
+ );
1919
+ const {
1920
+ nodes: layoutNodes,
1921
+ edges: layoutEdges,
1922
+ graphHeight
1923
+ } = useUnifiedWorkflowLayout(workflowInput, executionPath, isDefinitionMode ? null : selectedStepId, mode);
1924
+ const {
1925
+ nodes: highlightedNodes,
1926
+ edges: highlightedEdges,
1927
+ handleNodeMouseEnter,
1928
+ handleNodeMouseLeave
1929
+ } = useDirectedChainHighlighting(layoutNodes, layoutEdges);
1930
+ const nodes = isDefinitionMode ? highlightedNodes : layoutNodes;
1931
+ const edges = isDefinitionMode ? highlightedEdges : layoutEdges;
1932
+ const [internalFitViewTrigger, setInternalFitViewTrigger] = useState(0);
1933
+ const executedStepsCount = executionPath?.executedSteps.size ?? 0;
1934
+ const nodesCount = nodes.length;
1935
+ useEffect(() => {
1936
+ if (nodesCount > 0) {
1937
+ setInternalFitViewTrigger((prev) => prev + 1);
1938
+ }
1939
+ }, [nodesCount, executedStepsCount]);
1940
+ const fitViewTrigger = (externalFitViewTrigger ?? 0) + internalFitViewTrigger;
1941
+ const { handleNodeClick, handlePaneClick, handleContainerClick } = useNodeSelection(
1942
+ selectedStepId || null,
1943
+ onStepSelect || (() => {
1944
+ })
1945
+ );
1946
+ if (!resourceDefinition || !resourceDefinition.steps.length) {
1947
+ return /* @__PURE__ */ jsx(EmptyVisualizer, {});
1948
+ }
1949
+ return /* @__PURE__ */ jsx(
1950
+ VisualizerContainer,
1951
+ {
1952
+ handleContainerClick: isDefinitionMode ? void 0 : handleContainerClick,
1953
+ height: graphHeight,
1954
+ children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsxs(
1955
+ ReactFlow,
1956
+ {
1957
+ nodes,
1958
+ edges,
1959
+ nodeTypes,
1960
+ edgeTypes,
1961
+ onNodeClick: isDefinitionMode ? void 0 : handleNodeClick,
1962
+ onPaneClick: isDefinitionMode ? void 0 : handlePaneClick,
1963
+ onNodeMouseEnter: isDefinitionMode ? handleNodeMouseEnter : void 0,
1964
+ onNodeMouseLeave: isDefinitionMode ? handleNodeMouseLeave : void 0,
1965
+ fitView: true,
1966
+ fitViewOptions: {
1967
+ padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING
1968
+ },
1969
+ proOptions: { hideAttribution: true },
1970
+ minZoom: WORKFLOW_CONSTANTS.MIN_ZOOM,
1971
+ maxZoom: WORKFLOW_CONSTANTS.MAX_ZOOM,
1972
+ defaultViewport: { x: 0, y: 0, zoom: 1 },
1973
+ nodesDraggable: false,
1974
+ nodesConnectable: false,
1975
+ elementsSelectable: !isDefinitionMode,
1976
+ selectNodesOnDrag: false,
1977
+ zoomOnScroll: true,
1978
+ panOnDrag: true,
1979
+ className: Graph_exports.graphContainer,
1980
+ children: [
1981
+ /* @__PURE__ */ jsx(GraphBackground, {}),
1982
+ /* @__PURE__ */ jsx(Panel, { position: "top-right", style: { marginTop: 12, marginRight: 12 }, children: /* @__PURE__ */ jsx(
1983
+ SegmentedControl,
1984
+ {
1985
+ size: "xs",
1986
+ value: mode,
1987
+ onChange: (value) => setMode(value),
1988
+ data: [
1989
+ { label: "Definition", value: "definition" },
1990
+ { label: "Execution", value: "execution" }
1991
+ ],
1992
+ styles: {
1993
+ root: {
1994
+ backgroundColor: "var(--color-surface)",
1995
+ border: "1px solid var(--color-border)"
1996
+ }
1997
+ }
1998
+ }
1999
+ ) }),
2000
+ /* @__PURE__ */ jsx(GraphLegend, { title: "Legend", items: NODE_LEGEND_ITEMS, position: "bottom-right" }),
2001
+ /* @__PURE__ */ jsx(GraphLegend, { title: "Flow", items: EDGE_LEGEND_ITEMS, position: "bottom-left" }),
2002
+ /* @__PURE__ */ jsx(GraphFitViewButton, { padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING, variant: "mantine" }),
2003
+ /* @__PURE__ */ jsx(GraphFitViewHandler, { trigger: fitViewTrigger, padding: WORKFLOW_CONSTANTS.FIT_VIEW_PADDING })
2004
+ ]
2005
+ }
2006
+ ) })
2007
+ }
2008
+ );
2009
+ }
2010
+ function WorkflowExecutionTimeline({ timelineData, selectedStepId }) {
2011
+ const { steps } = timelineData;
2012
+ const executionStart = steps[0]?.startTime || 0;
2013
+ const executionEnd = steps[steps.length - 1]?.endTime || executionStart;
2014
+ return /* @__PURE__ */ jsx(TimelineContainer, { executionStart, executionEnd, children: steps.map(
2015
+ (step) => step.startTime && step.endTime && /* @__PURE__ */ jsx(
2016
+ TimelineRow,
2017
+ {
2018
+ label: step.stepName,
2019
+ bars: [
2020
+ {
2021
+ startTime: step.startTime,
2022
+ endTime: step.endTime,
2023
+ status: step.status,
2024
+ nodeId: step.stepId
2025
+ }
2026
+ ],
2027
+ executionStart,
2028
+ executionEnd,
2029
+ selectedNodeId: selectedStepId
2030
+ },
2031
+ step.stepId
2032
+ )
2033
+ ) });
2034
+ }
2035
+ var statusColorMap = {
2036
+ running: "blue",
2037
+ completed: "teal",
2038
+ failed: "orange",
2039
+ pending: "violet",
2040
+ warning: "yellow"
2041
+ };
2042
+ var AgentIterationNode = memo(function AgentIterationNode2({ data, selected }) {
2043
+ const { nodeType, label, iterationNumber, status, reasoningCount, actionCount, duration, isLive } = data;
2044
+ const colors = getStatusColors(status);
2045
+ const nodeColor = statusColorMap[status];
2046
+ return /* @__PURE__ */ jsxs(BaseNode, { color: nodeColor, selected, width: AGENT_CONSTANTS.NODE_WIDTH, children: [
2047
+ /* @__PURE__ */ jsxs(Box, { style: { display: "flex", flexDirection: "column", alignItems: "center" }, children: [
2048
+ /* @__PURE__ */ jsx(
2049
+ Box,
2050
+ {
2051
+ style: {
2052
+ width: AGENT_CONSTANTS.CIRCLE_SIZE,
2053
+ height: AGENT_CONSTANTS.CIRCLE_SIZE,
2054
+ borderRadius: "50%",
2055
+ backgroundColor: "var(--color-surface)",
2056
+ border: `2px solid ${colors.color}`,
2057
+ display: "flex",
2058
+ alignItems: "center",
2059
+ justifyContent: "center"
2060
+ },
2061
+ children: getStatusIcon({
2062
+ status,
2063
+ colors: { icon: colors.color },
2064
+ iconSize: AGENT_CONSTANTS.STATUS_ICON_SIZE,
2065
+ spinDuration: "1s"
2066
+ })
2067
+ }
2068
+ ),
2069
+ /* @__PURE__ */ jsx(
2070
+ Text,
2071
+ {
2072
+ size: "sm",
2073
+ fw: status === "running" ? 500 : 400,
2074
+ ta: "center",
2075
+ mt: 4,
2076
+ style: { maxWidth: 150, fontFamily: "var(--mantine-font-family-headings)" },
2077
+ children: nodeType === "iteration" ? `Iteration ${iterationNumber}` : label
2078
+ }
2079
+ ),
2080
+ /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: colors.badge, mt: 4, children: status.toUpperCase() }),
2081
+ /* @__PURE__ */ jsxs(Stack, { gap: 2, mt: 2, align: "center", children: [
2082
+ nodeType === "iteration" && reasoningCount !== void 0 && reasoningCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
2083
+ reasoningCount,
2084
+ " reasoning"
2085
+ ] }),
2086
+ nodeType === "iteration" && actionCount !== void 0 && actionCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
2087
+ actionCount,
2088
+ " ",
2089
+ actionCount === 1 ? "action" : "actions"
2090
+ ] }),
2091
+ duration !== void 0 && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDuration(duration) })
2092
+ ] })
2093
+ ] }),
2094
+ isLive && /* @__PURE__ */ jsx(
2095
+ Badge,
2096
+ {
2097
+ size: "xs",
2098
+ variant: "filled",
2099
+ style: {
2100
+ position: "absolute",
2101
+ top: 4,
2102
+ right: 4
2103
+ },
2104
+ children: /* @__PURE__ */ jsx("span", { className: Graph_exports.livePulse, children: "LIVE" })
2105
+ }
2106
+ )
2107
+ ] });
2108
+ });
2109
+ var statusEdgeColors = {
2110
+ running: {
2111
+ color: "var(--mantine-color-blue-5)",
2112
+ glow: "rgba(59, 130, 246, 0.5)"
2113
+ },
2114
+ completed: {
2115
+ color: "var(--mantine-color-teal-5)",
2116
+ glow: "rgba(20, 184, 166, 0.5)"
2117
+ },
2118
+ failed: {
2119
+ color: "var(--mantine-color-orange-5)",
2120
+ glow: "rgba(249, 115, 22, 0.5)"
2121
+ },
2122
+ pending: {
2123
+ color: "var(--mantine-color-gray-5)",
2124
+ glow: "rgba(156, 163, 175, 0.3)"
2125
+ },
2126
+ warning: {
2127
+ color: "var(--mantine-color-yellow-5)",
2128
+ glow: "rgba(234, 179, 8, 0.5)"
2129
+ }
2130
+ };
2131
+ var AgentIterationEdge = memo(function AgentIterationEdge2({
2132
+ id,
2133
+ sourceX,
2134
+ sourceY,
2135
+ targetX,
2136
+ targetY,
2137
+ data,
2138
+ selected
2139
+ }) {
2140
+ const edgeData = data;
2141
+ const sourceStatus = edgeData?.sourceStatus || "pending";
2142
+ const targetStatus = edgeData?.targetStatus || "pending";
2143
+ const edgeColors = statusEdgeColors[sourceStatus];
2144
+ const isAnimated = shouldAnimateEdge(sourceStatus, targetStatus);
2145
+ return /* @__PURE__ */ jsx(
2146
+ BaseEdge,
2147
+ {
2148
+ id,
2149
+ sourceX,
2150
+ sourceY,
2151
+ targetX,
2152
+ targetY,
2153
+ sourcePosition: Position.Right,
2154
+ targetPosition: Position.Left,
2155
+ color: edgeColors.color,
2156
+ glowColor: edgeColors.glow,
2157
+ animated: isAnimated,
2158
+ selected
2159
+ }
2160
+ );
2161
+ });
2162
+ var nodeTypes2 = {
2163
+ agentIteration: AgentIterationNode
2164
+ };
2165
+ var edgeTypes2 = {
2166
+ agentIteration: AgentIterationEdge
2167
+ };
2168
+ function AgentExecutionVisualizer({
2169
+ resourceDefinition,
2170
+ iterationData,
2171
+ selectedExecutionId,
2172
+ liveExecutions,
2173
+ selectedIterationId,
2174
+ onIterationSelect
2175
+ }) {
2176
+ const { nodes, edges } = useReactFlowAgent(
2177
+ iterationData,
2178
+ resourceDefinition,
2179
+ selectedIterationId,
2180
+ liveExecutions,
2181
+ selectedExecutionId
2182
+ );
2183
+ const fitViewTrigger = useFitViewTrigger(iterationData, nodes);
2184
+ const handleIterationSelect = useCallback(
2185
+ (id) => {
2186
+ onIterationSelect(id);
2187
+ },
2188
+ [onIterationSelect]
2189
+ );
2190
+ const { handlePaneClick, handleContainerClick } = useNodeSelection(selectedIterationId, handleIterationSelect);
2191
+ const handleNodeClick = useCallback(
2192
+ (_event, node2) => {
2193
+ if (node2.id === "initialization" || node2.id === "completion") {
2194
+ handleIterationSelect(selectedIterationId === node2.id ? null : node2.id);
2195
+ return;
2196
+ }
2197
+ const iterationNumber = Number.parseInt(node2.id.replace("iteration-", ""), 10);
2198
+ if (!Number.isNaN(iterationNumber)) {
2199
+ handleIterationSelect(iterationNumber === selectedIterationId ? null : iterationNumber);
2200
+ }
2201
+ },
2202
+ [selectedIterationId, handleIterationSelect]
2203
+ );
2204
+ if (!iterationData || nodes.length === 0) {
2205
+ return /* @__PURE__ */ jsx(EmptyVisualizer, {});
2206
+ }
2207
+ return /* @__PURE__ */ jsx(VisualizerContainer, { handleContainerClick, children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsxs(
2208
+ ReactFlow,
2209
+ {
2210
+ nodes,
2211
+ edges,
2212
+ nodeTypes: nodeTypes2,
2213
+ edgeTypes: edgeTypes2,
2214
+ onNodeClick: handleNodeClick,
2215
+ onPaneClick: handlePaneClick,
2216
+ fitView: true,
2217
+ fitViewOptions: {
2218
+ padding: AGENT_CONSTANTS.FIT_VIEW_PADDING
2219
+ },
2220
+ proOptions: { hideAttribution: true },
2221
+ minZoom: AGENT_CONSTANTS.MIN_ZOOM,
2222
+ maxZoom: AGENT_CONSTANTS.MAX_ZOOM,
2223
+ nodesDraggable: false,
2224
+ nodesConnectable: false,
2225
+ elementsSelectable: true,
2226
+ selectNodesOnDrag: false,
2227
+ zoomOnScroll: false,
2228
+ panOnDrag: false,
2229
+ className: Graph_exports.graphContainer,
2230
+ children: [
2231
+ /* @__PURE__ */ jsx(GraphBackground, {}),
2232
+ /* @__PURE__ */ jsx(GraphFitViewButton, { padding: AGENT_CONSTANTS.FIT_VIEW_PADDING, variant: "mantine", duration: 300 }),
2233
+ /* @__PURE__ */ jsx(GraphFitViewHandler, { trigger: fitViewTrigger, padding: AGENT_CONSTANTS.FIT_VIEW_PADDING })
2234
+ ]
2235
+ }
2236
+ ) }) });
2237
+ }
2238
+ function AgentExecutionTimeline({ iterationData, selectedIterationId }) {
2239
+ const { initialization, iterations, completion } = iterationData;
2240
+ const executionStart = initialization.startTime;
2241
+ const executionEnd = completion.endTime;
2242
+ return /* @__PURE__ */ jsxs(TimelineContainer, { executionStart, executionEnd, children: [
2243
+ initialization.startTime && initialization.endTime && /* @__PURE__ */ jsx(
2244
+ TimelineRow,
2245
+ {
2246
+ label: `Initialization (${formatDuration(initialization.duration || 0)})`,
2247
+ bars: [
2248
+ {
2249
+ startTime: initialization.startTime,
2250
+ endTime: initialization.endTime,
2251
+ status: initialization.status,
2252
+ nodeId: "initialization"
2253
+ }
2254
+ ],
2255
+ executionStart,
2256
+ executionEnd,
2257
+ selectedNodeId: selectedIterationId
2258
+ }
2259
+ ),
2260
+ iterations.map((iteration) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
2261
+ iteration.startTime && iteration.endTime && /* @__PURE__ */ jsx(
2262
+ TimelineRow,
2263
+ {
2264
+ label: `Iteration ${iteration.iterationNumber} (${formatDuration(iteration.duration || 0)})`,
2265
+ bars: [
2266
+ {
2267
+ startTime: iteration.startTime,
2268
+ endTime: iteration.endTime,
2269
+ status: iteration.status,
2270
+ nodeId: iteration.iterationNumber
2271
+ }
2272
+ ],
2273
+ executionStart,
2274
+ executionEnd,
2275
+ selectedNodeId: selectedIterationId
2276
+ }
2277
+ ),
2278
+ iteration.subActivities.map((activity, activityIndex) => /* @__PURE__ */ jsx(
2279
+ TimelineRow,
2280
+ {
2281
+ label: `${activity.type} (${formatDuration(activity.duration)})`,
2282
+ bars: [
2283
+ {
2284
+ startTime: activity.startTime,
2285
+ endTime: activity.endTime,
2286
+ status: "completed",
2287
+ nodeId: iteration.iterationNumber
2288
+ }
2289
+ ],
2290
+ executionStart,
2291
+ executionEnd,
2292
+ indent: 1,
2293
+ selectedNodeId: selectedIterationId
2294
+ },
2295
+ `${iteration.iterationNumber}-${activity.type}-${activity.startTime}-${activityIndex}`
2296
+ ))
2297
+ ] }, iteration.iterationNumber)),
2298
+ completion.startTime && completion.endTime && /* @__PURE__ */ jsx(
2299
+ TimelineRow,
2300
+ {
2301
+ label: `Completion (${formatDuration(completion.duration || 0)})`,
2302
+ bars: [
2303
+ {
2304
+ startTime: completion.startTime,
2305
+ endTime: completion.endTime,
2306
+ status: completion.status,
2307
+ nodeId: "completion"
2308
+ }
2309
+ ],
2310
+ executionStart,
2311
+ executionEnd,
2312
+ selectedNodeId: selectedIterationId
2313
+ }
2314
+ )
2315
+ ] });
2316
+ }
2317
+ var iconMap = {
2318
+ IconCheck,
2319
+ IconX,
2320
+ IconRefresh,
2321
+ IconAlertTriangle: IconAlertTriangle,
2322
+ IconEdit,
2323
+ IconEye,
2324
+ IconRocket,
2325
+ IconMessageCircle,
2326
+ IconArrowUp,
2327
+ IconClock: IconClock,
2328
+ IconFileText,
2329
+ IconSend,
2330
+ IconMail
2331
+ };
2332
+ function getIcon(iconName) {
2333
+ if (!iconName) return null;
2334
+ const icon = iconMap[iconName];
2335
+ if (!icon && process.env.NODE_ENV !== "production") {
2336
+ console.warn(`[iconMap] Unknown icon "${iconName}". Allowed: ${Object.keys(iconMap).join(", ")}`);
2337
+ }
2338
+ return icon || null;
2339
+ }
2340
+ function resolveDefaultValue(context, path) {
2341
+ if (!context || typeof context !== "object") return void 0;
2342
+ return path.split(".").reduce((obj, key) => {
2343
+ if (obj && typeof obj === "object" && key in obj) {
2344
+ return obj[key];
2345
+ }
2346
+ return void 0;
2347
+ }, context);
2348
+ }
2349
+ function ActionModal({
2350
+ action,
2351
+ task,
2352
+ opened,
2353
+ onClose,
2354
+ onSubmit,
2355
+ richTextRenderer,
2356
+ error,
2357
+ isPending
2358
+ }) {
2359
+ const getInitialValuesFromContext = () => {
2360
+ if (!action.form?.fields) return {};
2361
+ return action.form.fields.reduce(
2362
+ (acc, field) => {
2363
+ if (field.defaultValueFromContext && task?.context) {
2364
+ const value = resolveDefaultValue(task.context, field.defaultValueFromContext);
2365
+ if (value !== void 0) {
2366
+ acc[field.name] = value;
2367
+ }
2368
+ }
2369
+ return acc;
2370
+ },
2371
+ {}
2372
+ );
2373
+ };
2374
+ const form = useForm({
2375
+ initialValues: {
2376
+ ...getInitialValuesFromContext(),
2377
+ ...action.payloadTemplate || {},
2378
+ notes: ""
2379
+ }
2380
+ });
2381
+ const handleSubmit = form.onSubmit((values) => {
2382
+ const { notes, ...payload } = values;
2383
+ onSubmit(payload, notes || void 0);
2384
+ });
2385
+ const Icon = getIcon(action.icon);
2386
+ const errorMessage = error ? (() => {
2387
+ const { message, fields, requestId } = getErrorInfo(error);
2388
+ return formatErrorMessage(message, requestId, fields);
2389
+ })() : null;
2390
+ if (!action.form) {
2391
+ return null;
2392
+ }
2393
+ return /* @__PURE__ */ jsx(CustomModal, { opened, onClose, size: "xl", children: /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxs(Stack, { children: [
2394
+ /* @__PURE__ */ jsx(Title, { order: 3, children: action.form.title || action.label }),
2395
+ action.form.description && /* @__PURE__ */ jsx(Text, { c: "dimmed", children: action.form.description }),
2396
+ action.form.fields.map((field) => /* @__PURE__ */ jsx(FormFieldRenderer, { field, form, richTextRenderer }, field.name)),
2397
+ /* @__PURE__ */ jsx(
2398
+ Textarea,
2399
+ {
2400
+ label: "Notes (optional)",
2401
+ placeholder: "Add any notes or reasoning...",
2402
+ ...form.getInputProps("notes")
2403
+ }
2404
+ ),
2405
+ errorMessage && /* @__PURE__ */ jsx(Alert, { color: "red", variant: "light", icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }), title: "Submission failed", children: /* @__PURE__ */ jsx(Text, { size: "sm", style: { whiteSpace: "pre-line" }, children: errorMessage }) }),
2406
+ /* @__PURE__ */ jsxs(Group, { mt: "md", justify: "space-between", children: [
2407
+ /* @__PURE__ */ jsx(Button, { variant: "light", onClick: onClose, children: "Cancel" }),
2408
+ /* @__PURE__ */ jsx(
2409
+ Button,
2410
+ {
2411
+ type: "submit",
2412
+ color: action.color || "blue",
2413
+ leftSection: Icon ? /* @__PURE__ */ jsx(Icon, { size: 16 }) : null,
2414
+ loading: isPending,
2415
+ children: action.label
2416
+ }
2417
+ )
2418
+ ] })
2419
+ ] }) }) });
2420
+ }
2421
+ function TaskCard({ task, onViewExecution, richTextRenderer }) {
2422
+ const [isExpanded, setIsExpanded] = useState(false);
2423
+ const { mutate: submitAction, isPending } = useSubmitAction();
2424
+ const { mutate: deleteTask, isPending: isDeleting } = useDeleteTask();
2425
+ const [actionModalOpened, setActionModalOpened] = useState(false);
2426
+ const [selectedAction, setSelectedAction] = useState(null);
2427
+ const [confirmAction, setConfirmAction] = useState(null);
2428
+ const [deleteConfirmOpened, setDeleteConfirmOpened] = useState(false);
2429
+ const handleActionClick = (action) => {
2430
+ if (action.requiresConfirmation) {
2431
+ setConfirmAction(action);
2432
+ } else if (action.form) {
2433
+ setSelectedAction(action);
2434
+ setActionModalOpened(true);
2435
+ } else {
2436
+ submitAction({
2437
+ taskId: task.id,
2438
+ actionId: action.id
2439
+ });
2440
+ }
2441
+ };
2442
+ const handleConfirm = () => {
2443
+ if (!confirmAction) return;
2444
+ if (confirmAction.form) {
2445
+ setSelectedAction(confirmAction);
2446
+ setActionModalOpened(true);
2447
+ } else {
2448
+ submitAction({
2449
+ taskId: task.id,
2450
+ actionId: confirmAction.id
2451
+ });
2452
+ }
2453
+ setConfirmAction(null);
2454
+ };
2455
+ const getPriorityColor = (priority) => {
2456
+ if (priority >= 8) return "red";
2457
+ if (priority >= 5) return "yellow";
2458
+ return "gray";
2459
+ };
2460
+ const getStatusColor = (status) => {
2461
+ switch (status) {
2462
+ case "pending":
2463
+ return "blue";
2464
+ case "processing":
2465
+ return "blue";
2466
+ case "completed":
2467
+ return "green";
2468
+ case "failed":
2469
+ return "red";
2470
+ case "expired":
2471
+ return "orange";
2472
+ default:
2473
+ return "gray";
2474
+ }
2475
+ };
2476
+ const handleRetry = () => {
2477
+ if (task.selectedAction) {
2478
+ submitAction({
2479
+ taskId: task.id,
2480
+ actionId: task.selectedAction,
2481
+ payload: task.actionPayload
2482
+ });
2483
+ }
2484
+ };
2485
+ const formatDate = (date) => {
2486
+ const now = /* @__PURE__ */ new Date();
2487
+ const diffMs = now.getTime() - date.getTime();
2488
+ const diffMins = Math.floor(diffMs / 6e4);
2489
+ const diffHours = Math.floor(diffMins / 60);
2490
+ const diffDays = Math.floor(diffHours / 24);
2491
+ if (diffMins < 60) return `${diffMins}m ago`;
2492
+ if (diffHours < 24) return `${diffHours}h ago`;
2493
+ return `${diffDays}d ago`;
2494
+ };
2495
+ return /* @__PURE__ */ jsx(
2496
+ Card,
2497
+ {
2498
+ withBorder: true,
2499
+ style: { transition: "box-shadow var(--duration-fast) var(--easing)" },
2500
+ onMouseEnter: (e) => {
2501
+ e.currentTarget.style.boxShadow = "var(--standard-box-shadow)";
2502
+ },
2503
+ onMouseLeave: (e) => {
2504
+ e.currentTarget.style.boxShadow = "";
2505
+ },
2506
+ children: /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
2507
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", wrap: "nowrap", children: [
2508
+ /* @__PURE__ */ jsxs(Group, { gap: "sm", style: { flex: 1 }, children: [
2509
+ /* @__PURE__ */ jsx(ThemeIcon, { size: "lg", variant: "light", color: task.originResourceType === "agent" ? "blue" : "grape", children: task.originResourceType === "agent" ? /* @__PURE__ */ jsx(IconRobot, { size: 20 }) : /* @__PURE__ */ jsx(IconGitBranch, { size: 20 }) }),
2510
+ /* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
2511
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", mb: 4, children: [
2512
+ /* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: task.description || "Task approval required" }),
2513
+ /* @__PURE__ */ jsxs(Badge, { size: "xs", variant: "light", color: getPriorityColor(task.priority), radius: "sm", children: [
2514
+ "P",
2515
+ task.priority
2516
+ ] })
2517
+ ] }),
2518
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
2519
+ /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
2520
+ task.originResourceType === "agent" ? "Agent" : "Workflow",
2521
+ ": ",
2522
+ task.originResourceId
2523
+ ] }),
2524
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "\u2022" }),
2525
+ /* @__PURE__ */ jsxs(Group, { gap: 4, children: [
2526
+ /* @__PURE__ */ jsx(IconClock, { size: 12 }),
2527
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: formatDate(task.createdAt) })
2528
+ ] })
2529
+ ] })
2530
+ ] })
2531
+ ] }),
2532
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
2533
+ /* @__PURE__ */ jsx(
2534
+ Badge,
2535
+ {
2536
+ size: "sm",
2537
+ variant: "light",
2538
+ color: getStatusColor(task.status),
2539
+ radius: "sm",
2540
+ leftSection: task.status === "processing" ? /* @__PURE__ */ jsx(Loader, { size: 6 }) : void 0,
2541
+ children: task.status.charAt(0).toUpperCase() + task.status.slice(1)
2542
+ }
2543
+ ),
2544
+ task.status === "failed" && /* @__PURE__ */ jsx(Button, { variant: "light", color: "red", size: "xs", loading: isPending, onClick: handleRetry, children: "Retry" }),
2545
+ /* @__PURE__ */ jsxs(Menu, { shadow: "md", position: "bottom-end", offset: 8, children: [
2546
+ /* @__PURE__ */ jsx(Menu.Target, { children: /* @__PURE__ */ jsx(ActionIcon, { variant: "subtle", color: "gray", size: "sm", children: /* @__PURE__ */ jsx(IconDotsVertical, { size: 16 }) }) }),
2547
+ /* @__PURE__ */ jsx(Menu.Dropdown, { children: /* @__PURE__ */ jsx(
2548
+ Menu.Item,
2549
+ {
2550
+ leftSection: /* @__PURE__ */ jsx(IconTrash, { size: 14 }),
2551
+ disabled: task.status === "processing",
2552
+ onClick: () => setDeleteConfirmOpened(true),
2553
+ children: "Delete"
2554
+ }
2555
+ ) })
2556
+ ] })
2557
+ ] })
2558
+ ] }),
2559
+ /* @__PURE__ */ jsx(Accordion, { value: isExpanded ? "details" : null, onChange: (value) => setIsExpanded(!!value), children: /* @__PURE__ */ jsxs(Accordion.Item, { value: "details", children: [
2560
+ /* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, children: "View Context" }) }),
2561
+ /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsx(ContextViewer, { data: task.context }) })
2562
+ ] }) }),
2563
+ task.status === "pending" && /* @__PURE__ */ jsx(Group, { gap: "xs", children: task.actions.map((action) => {
2564
+ const Icon = getIcon(action.icon);
2565
+ const variant = "light";
2566
+ return /* @__PURE__ */ jsx(
2567
+ Button,
2568
+ {
2569
+ variant,
2570
+ color: action.color || (action.type === "danger" ? "red" : "blue"),
2571
+ leftSection: Icon ? /* @__PURE__ */ jsx(Icon, { size: 16 }) : null,
2572
+ loading: isPending,
2573
+ onClick: () => handleActionClick(action),
2574
+ title: action.description,
2575
+ size: "xs",
2576
+ radius: "xs",
2577
+ children: action.label
2578
+ },
2579
+ action.id
2580
+ );
2581
+ }) }),
2582
+ task.selectedAction && /* @__PURE__ */ jsx(Accordion, { children: /* @__PURE__ */ jsxs(Accordion.Item, { value: "submitted", children: [
2583
+ /* @__PURE__ */ jsx(Accordion.Control, { children: /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
2584
+ /* @__PURE__ */ jsx(ThemeIcon, { size: "sm", variant: "light", color: "green", radius: "xl", children: /* @__PURE__ */ jsx(IconCheck, { size: 12 }) }),
2585
+ /* @__PURE__ */ jsxs(Text, { size: "sm", fw: 500, children: [
2586
+ "Submitted: ",
2587
+ task.actions.find((a) => a.id === task.selectedAction)?.label || task.selectedAction
2588
+ ] }),
2589
+ task.targetExecutionId && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "cyan", leftSection: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 10 }), children: "Executed" })
2590
+ ] }) }),
2591
+ /* @__PURE__ */ jsx(Accordion.Panel, { children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2592
+ task.actionPayload !== void 0 && task.actionPayload !== null && /* @__PURE__ */ jsx(JsonViewer, { data: task.actionPayload, maxHeight: 200 }),
2593
+ task.completedAt && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
2594
+ "Completed ",
2595
+ formatDate(task.completedAt),
2596
+ task.completedBy ? ` by ${task.completedBy}` : ""
2597
+ ] }),
2598
+ task.targetExecutionId && /* @__PURE__ */ jsx(
2599
+ Button,
2600
+ {
2601
+ variant: "light",
2602
+ size: "xs",
2603
+ leftSection: /* @__PURE__ */ jsx(IconExternalLink, { size: 14 }),
2604
+ onClick: () => {
2605
+ onViewExecution?.({
2606
+ resourceType: task.originResourceType,
2607
+ resourceId: task.originResourceId,
2608
+ executionId: task.targetExecutionId
2609
+ });
2610
+ },
2611
+ children: "View Execution"
2612
+ }
2613
+ )
2614
+ ] }) })
2615
+ ] }) }),
2616
+ /* @__PURE__ */ jsx(CustomModal, { opened: !!confirmAction, onClose: () => setConfirmAction(null), size: "sm", children: /* @__PURE__ */ jsxs(Stack, { children: [
2617
+ /* @__PURE__ */ jsx(Text, { fw: 600, children: "Confirm Action" }),
2618
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: confirmAction?.confirmationMessage || `Are you sure you want to ${confirmAction?.label.toLowerCase()}?` }),
2619
+ /* @__PURE__ */ jsxs(Group, { justify: "flex-end", children: [
2620
+ /* @__PURE__ */ jsx(Button, { variant: "default", onClick: () => setConfirmAction(null), children: "Cancel" }),
2621
+ /* @__PURE__ */ jsx(Button, { onClick: handleConfirm, children: confirmAction?.label })
2622
+ ] })
2623
+ ] }) }),
2624
+ selectedAction && /* @__PURE__ */ jsx(
2625
+ ActionModal,
2626
+ {
2627
+ action: selectedAction,
2628
+ task,
2629
+ opened: actionModalOpened,
2630
+ onClose: () => setActionModalOpened(false),
2631
+ onSubmit: (payload, notes) => {
2632
+ submitAction({
2633
+ taskId: task.id,
2634
+ actionId: selectedAction.id,
2635
+ payload,
2636
+ notes
2637
+ });
2638
+ setActionModalOpened(false);
2639
+ },
2640
+ richTextRenderer
2641
+ }
2642
+ ),
2643
+ /* @__PURE__ */ jsx(CustomModal, { opened: deleteConfirmOpened, onClose: () => setDeleteConfirmOpened(false), size: "sm", children: /* @__PURE__ */ jsxs(Stack, { children: [
2644
+ /* @__PURE__ */ jsx(Text, { fw: 600, children: "Delete Task" }),
2645
+ /* @__PURE__ */ jsx(Text, { size: "sm", children: "Are you sure you want to delete this task? This action cannot be undone." }),
2646
+ /* @__PURE__ */ jsxs(Group, { justify: "flex-end", children: [
2647
+ /* @__PURE__ */ jsx(Button, { variant: "default", onClick: () => setDeleteConfirmOpened(false), children: "Cancel" }),
2648
+ /* @__PURE__ */ jsx(
2649
+ Button,
2650
+ {
2651
+ color: "red",
2652
+ loading: isDeleting,
2653
+ onClick: () => {
2654
+ deleteTask(task.id);
2655
+ setDeleteConfirmOpened(false);
2656
+ },
2657
+ children: "Delete"
2658
+ }
2659
+ )
2660
+ ] })
2661
+ ] }) })
2662
+ ] })
2663
+ }
2664
+ );
2665
+ }
2666
+ function ContentSections({ context, sections, titles }) {
2667
+ const sectionKeys = sections || Object.keys(context).filter((key) => key !== "contentDisplay" && typeof context[key] === "string");
2668
+ const formatTitle = (key) => key.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
2669
+ return /* @__PURE__ */ jsx(Stack, { gap: "lg", children: sectionKeys.map((key) => {
2670
+ const content = context[key];
2671
+ if (typeof content !== "string") return null;
2672
+ const title = titles?.[key] || formatTitle(key);
2673
+ return /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2674
+ /* @__PURE__ */ jsx(Title, { order: 4, children: title }),
2675
+ /* @__PURE__ */ jsx(StyledMarkdown, { children: content })
2676
+ ] }, key);
2677
+ }) });
2678
+ }
2679
+ function CollapsibleJsonSection({ title, data, defaultExpanded = false }) {
2680
+ const [isExpanded, setIsExpanded] = useState(defaultExpanded);
2681
+ const [isHovered, setIsHovered] = useState(false);
2682
+ return /* @__PURE__ */ jsxs(
2683
+ "div",
2684
+ {
2685
+ style: {
2686
+ borderRadius: "var(--mantine-radius-default)",
2687
+ backgroundColor: isHovered ? "var(--color-surface-hover, rgba(0,0,0,0.02))" : "transparent",
2688
+ transition: "background-color var(--duration-fast) var(--easing)"
2689
+ },
2690
+ children: [
2691
+ /* @__PURE__ */ jsxs(
2692
+ Group,
2693
+ {
2694
+ gap: 4,
2695
+ onClick: () => setIsExpanded(!isExpanded),
2696
+ onMouseEnter: () => setIsHovered(true),
2697
+ onMouseLeave: () => setIsHovered(false),
2698
+ style: {
2699
+ cursor: "pointer",
2700
+ padding: "0.375rem 0.5rem",
2701
+ userSelect: "none"
2702
+ },
2703
+ wrap: "nowrap",
2704
+ children: [
2705
+ /* @__PURE__ */ jsx(
2706
+ ActionIcon,
2707
+ {
2708
+ variant: "transparent",
2709
+ size: "xs",
2710
+ style: {
2711
+ transition: "transform var(--duration-fast) var(--easing)",
2712
+ transform: isExpanded ? "rotate(90deg)" : "rotate(0deg)"
2713
+ },
2714
+ children: /* @__PURE__ */ jsx(IconChevronRight, { size: 14 })
2715
+ }
2716
+ ),
2717
+ title
2718
+ ]
2719
+ }
2720
+ ),
2721
+ /* @__PURE__ */ jsx(Collapse, { in: isExpanded, children: /* @__PURE__ */ jsx(JsonViewer, { data }) })
2722
+ ]
2723
+ }
2724
+ );
2725
+ }
2726
+ function ContractDisplay({ contract, defaultExpanded = false }) {
2727
+ return /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2728
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Contract" }),
2729
+ /* @__PURE__ */ jsx(
2730
+ CollapsibleJsonSection,
2731
+ {
2732
+ title: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Input Schema" }),
2733
+ data: contract.inputSchema,
2734
+ defaultExpanded
2735
+ }
2736
+ ),
2737
+ contract.outputSchema != null && /* @__PURE__ */ jsx(
2738
+ CollapsibleJsonSection,
2739
+ {
2740
+ title: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: "Output Schema" }),
2741
+ data: contract.outputSchema,
2742
+ defaultExpanded
2743
+ }
2744
+ )
2745
+ ] });
2746
+ }
2747
+ function ConfigCard({ icon, title, badge, items, color = "blue" }) {
2748
+ const visibleItems = items.filter((item) => item.value !== void 0 && item.value !== null);
2749
+ if (visibleItems.length === 0) return null;
2750
+ return /* @__PURE__ */ jsx(Card, { padding: "sm", withBorder: true, children: /* @__PURE__ */ jsxs(Stack, { gap: "xs", children: [
2751
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
2752
+ /* @__PURE__ */ jsx(ThemeIcon, { size: "sm", variant: "light", color, radius: "sm", children: icon }),
2753
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { flex: 1, fontFamily: "var(--elevasis-font-family-subtitle)" }, children: title }),
2754
+ badge && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color, children: badge })
2755
+ ] }),
2756
+ /* @__PURE__ */ jsx(Stack, { gap: 4, children: visibleItems.map((item, index) => /* @__PURE__ */ jsxs(Group, { gap: 6, wrap: "nowrap", children: [
2757
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", style: { minWidth: "fit-content" }, children: item.label }),
2758
+ typeof item.value === "string" || typeof item.value === "number" ? /* @__PURE__ */ jsx(Text, { size: "xs", ff: item.mono ? "monospace" : void 0, truncate: true, style: { flex: 1 }, children: item.value }) : item.value
2759
+ ] }, index)) })
2760
+ ] }) });
2761
+ }
2762
+ function ToolsListDisplay({ tools, compact = false, maxVisible = 0 }) {
2763
+ if (tools.length === 0) {
2764
+ return /* @__PURE__ */ jsxs("div", { children: [
2765
+ !compact && /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, mb: "xs", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Tools" }),
2766
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No tools configured" })
2767
+ ] });
2768
+ }
2769
+ const normalizedTools = tools.map((tool) => typeof tool === "string" ? { name: tool } : tool);
2770
+ const visibleTools = maxVisible > 0 ? normalizedTools.slice(0, maxVisible) : normalizedTools;
2771
+ const hiddenCount = maxVisible > 0 ? Math.max(0, normalizedTools.length - maxVisible) : 0;
2772
+ return /* @__PURE__ */ jsxs("div", { children: [
2773
+ !compact && /* @__PURE__ */ jsxs(Group, { gap: "xs", mb: "xs", children: [
2774
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Tools" }),
2775
+ /* @__PURE__ */ jsx(Badge, { variant: "light", size: "xs", children: tools.length })
2776
+ ] }),
2777
+ /* @__PURE__ */ jsx(SimpleGrid, { cols: 2, spacing: "xs", children: visibleTools.map((tool, index) => /* @__PURE__ */ jsxs(Card, { withBorder: true, p: "sm", children: [
2778
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", mb: tool.description ? "xs" : 0, children: [
2779
+ /* @__PURE__ */ jsx(IconTool, { size: 16, style: { color: "var(--color-text-subtle)", flexShrink: 0 } }),
2780
+ /* @__PURE__ */ jsx(Text, { size: "sm", ff: "monospace", fw: 500, children: tool.name })
2781
+ ] }),
2782
+ tool.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: tool.description })
2783
+ ] }, `${tool.name}-${index}`)) }),
2784
+ hiddenCount > 0 && /* @__PURE__ */ jsxs(Text, { size: "sm", c: "dimmed", fs: "italic", mt: "xs", children: [
2785
+ "+",
2786
+ hiddenCount,
2787
+ " more tools"
2788
+ ] })
2789
+ ] });
2790
+ }
2791
+ var NODE_WIDTH = 200;
2792
+ var NODE_HEIGHT = 100;
2793
+ var RANK_SEP = 80;
2794
+ var NODE_SEP = 30;
2795
+ function useNewKnowledgeMapLayout(knowledgeMap, agentName) {
2796
+ return useMemo(() => {
2797
+ if (!knowledgeMap || knowledgeMap.nodes.length === 0) {
2798
+ return { nodes: [], edges: [] };
2799
+ }
2800
+ const agentNodeId = "__agent__";
2801
+ const edges = knowledgeMap.nodes.map((node2) => ({
2802
+ id: `edge-${agentNodeId}-${node2.id}`,
2803
+ source: agentNodeId,
2804
+ target: node2.id,
2805
+ type: "knowledgeMap",
2806
+ data: {}
2807
+ }));
2808
+ const dagreGraph = new dagre.graphlib.Graph();
2809
+ dagreGraph.setDefaultEdgeLabel(() => ({}));
2810
+ dagreGraph.setGraph({
2811
+ rankdir: "TB",
2812
+ ranksep: RANK_SEP,
2813
+ nodesep: NODE_SEP,
2814
+ marginx: 40,
2815
+ marginy: 40
2816
+ });
2817
+ dagreGraph.setNode(agentNodeId, { width: NODE_WIDTH, height: NODE_HEIGHT });
2818
+ knowledgeMap.nodes.forEach((node2) => {
2819
+ dagreGraph.setNode(node2.id, { width: NODE_WIDTH, height: NODE_HEIGHT });
2820
+ });
2821
+ edges.forEach((edge) => {
2822
+ dagreGraph.setEdge(edge.source, edge.target);
2823
+ });
2824
+ dagre.layout(dagreGraph);
2825
+ const agentDagreNode = dagreGraph.node(agentNodeId);
2826
+ const agentNode = {
2827
+ id: agentNodeId,
2828
+ type: "knowledgeMap",
2829
+ position: {
2830
+ x: agentDagreNode.x - NODE_WIDTH / 2,
2831
+ y: agentDagreNode.y - NODE_HEIGHT / 2
2832
+ },
2833
+ data: {
2834
+ id: agentNodeId,
2835
+ name: agentName,
2836
+ description: "Agent with lazy-loading knowledge",
2837
+ loaded: true,
2838
+ hasPrompt: false,
2839
+ isAgentNode: true
2840
+ }
2841
+ };
2842
+ const knowledgeNodes = knowledgeMap.nodes.map((node2) => {
2843
+ const dagreNode = dagreGraph.node(node2.id);
2844
+ return {
2845
+ id: node2.id,
2846
+ type: "knowledgeMap",
2847
+ position: {
2848
+ x: dagreNode.x - NODE_WIDTH / 2,
2849
+ y: dagreNode.y - NODE_HEIGHT / 2
2850
+ },
2851
+ data: {
2852
+ id: node2.id,
2853
+ name: node2.id,
2854
+ description: node2.description,
2855
+ loaded: node2.loaded,
2856
+ hasPrompt: node2.hasPrompt,
2857
+ isAgentNode: false
2858
+ }
2859
+ };
2860
+ });
2861
+ return { nodes: [agentNode, ...knowledgeNodes], edges };
2862
+ }, [knowledgeMap, agentName]);
2863
+ }
2864
+ var NewKnowledgeMapNode = memo(function NewKnowledgeMapNode2({ data, selected }) {
2865
+ const nodeColor = data.isAgentNode ? "violet" : data.loaded ? "teal" : "blue";
2866
+ return /* @__PURE__ */ jsx(BaseNode, { color: nodeColor, selected, width: 200, handleDirection: "vertical", children: /* @__PURE__ */ jsxs(Stack, { gap: 6, children: [
2867
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", wrap: "nowrap", children: [
2868
+ data.isAgentNode ? /* @__PURE__ */ jsx(IconBrain, { size: 16, style: { flexShrink: 0 } }) : data.loaded ? /* @__PURE__ */ jsx(IconBrain, { size: 16, style: { flexShrink: 0 } }) : /* @__PURE__ */ jsx(IconBrain, { size: 16, style: { flexShrink: 0, opacity: 0.4 } }),
2869
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 500, truncate: true, style: { flex: 1, fontFamily: "var(--mantine-font-family-headings)" }, children: data.name })
2870
+ ] }),
2871
+ data.description && /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", lineClamp: 2, children: data.description }),
2872
+ /* @__PURE__ */ jsx(Group, { gap: 4, children: data.isAgentNode ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: "Root" }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2873
+ /* @__PURE__ */ jsx(
2874
+ Badge,
2875
+ {
2876
+ size: "xs",
2877
+ variant: "light",
2878
+ color: data.loaded ? "teal" : "gray",
2879
+ leftSection: /* @__PURE__ */ jsx(IconBrain, { size: 10 }),
2880
+ children: data.loaded ? "Loaded" : "Available"
2881
+ }
2882
+ ),
2883
+ data.hasPrompt && /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "orange", leftSection: /* @__PURE__ */ jsx(IconFileText, { size: 10 }), children: "Prompt" })
2884
+ ] }) })
2885
+ ] }) });
2886
+ });
2887
+ var NewKnowledgeMapEdge = memo(function NewKnowledgeMapEdge2({
2888
+ id,
2889
+ sourceX,
2890
+ sourceY,
2891
+ targetX,
2892
+ targetY,
2893
+ sourcePosition,
2894
+ targetPosition,
2895
+ selected,
2896
+ data
2897
+ }) {
2898
+ const colors = useGraphTheme();
2899
+ return /* @__PURE__ */ jsx(
2900
+ BaseEdge,
2901
+ {
2902
+ id,
2903
+ sourceX,
2904
+ sourceY,
2905
+ targetX,
2906
+ targetY,
2907
+ sourcePosition,
2908
+ targetPosition,
2909
+ color: colors.primary,
2910
+ glowColor: colors.primaryGlow,
2911
+ animated: false,
2912
+ selected,
2913
+ dimmed: data?.dimmed
2914
+ }
2915
+ );
2916
+ });
2917
+ var nodeTypes3 = {
2918
+ knowledgeMap: NewKnowledgeMapNode
2919
+ };
2920
+ var edgeTypes3 = {
2921
+ knowledgeMap: NewKnowledgeMapEdge
2922
+ };
2923
+ function NewKnowledgeMapGraphInner({ knowledgeMap, agentName, compact, fitViewTrigger }) {
2924
+ const { nodes: layoutNodes, edges: layoutEdges } = useNewKnowledgeMapLayout(knowledgeMap, agentName);
2925
+ const { nodes, edges, handleNodeMouseEnter, handleNodeMouseLeave } = useGraphHighlighting(layoutNodes, layoutEdges);
2926
+ if (!knowledgeMap || knowledgeMap.nodes.length === 0) {
2927
+ return /* @__PURE__ */ jsxs("div", { children: [
2928
+ !compact && /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, mb: "xs", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Knowledge Map" }),
2929
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "No knowledge nodes configured" })
2930
+ ] });
2931
+ }
2932
+ const containerHeight = calculateGraphHeight({
2933
+ itemCount: knowledgeMap.nodeCount,
2934
+ minHeight: 250,
2935
+ maxHeight: 450,
2936
+ heightPerItem: 60
2937
+ });
2938
+ return /* @__PURE__ */ jsxs("div", { children: [
2939
+ !compact && /* @__PURE__ */ jsxs(Group, { gap: "xs", mb: "xs", children: [
2940
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Knowledge Map" }),
2941
+ /* @__PURE__ */ jsxs(Badge, { variant: "light", size: "xs", children: [
2942
+ knowledgeMap.nodeCount,
2943
+ " ",
2944
+ knowledgeMap.nodeCount === 1 ? "node" : "nodes"
2945
+ ] })
2946
+ ] }),
2947
+ /* @__PURE__ */ jsx(
2948
+ Box,
2949
+ {
2950
+ className: Graph_default.graphContainer,
2951
+ style: {
2952
+ width: "100%",
2953
+ height: containerHeight,
2954
+ border: "1px solid var(--color-border)",
2955
+ borderRadius: "var(--mantine-radius-md)",
2956
+ overflow: "hidden"
2957
+ },
2958
+ children: /* @__PURE__ */ jsxs(
2959
+ ReactFlow,
2960
+ {
2961
+ nodes,
2962
+ edges,
2963
+ nodeTypes: nodeTypes3,
2964
+ edgeTypes: edgeTypes3,
2965
+ onNodeMouseEnter: handleNodeMouseEnter,
2966
+ onNodeMouseLeave: handleNodeMouseLeave,
2967
+ fitView: true,
2968
+ fitViewOptions: { padding: 0.15 },
2969
+ proOptions: { hideAttribution: true },
2970
+ minZoom: GRAPH_CONSTANTS.MIN_ZOOM,
2971
+ maxZoom: GRAPH_CONSTANTS.MAX_ZOOM,
2972
+ nodesDraggable: false,
2973
+ nodesConnectable: false,
2974
+ elementsSelectable: true,
2975
+ selectNodesOnDrag: false,
2976
+ panOnDrag: true,
2977
+ zoomOnScroll: true,
2978
+ zoomOnPinch: true,
2979
+ panOnScroll: false,
2980
+ children: [
2981
+ /* @__PURE__ */ jsx(GraphBackground, {}),
2982
+ /* @__PURE__ */ jsx(GraphFitViewButton, { padding: 0.15, variant: "mantine", duration: 300 }),
2983
+ /* @__PURE__ */ jsx(GraphFitViewHandler, { trigger: fitViewTrigger })
2984
+ ]
2985
+ }
2986
+ )
2987
+ }
2988
+ )
2989
+ ] });
2990
+ }
2991
+ function NewKnowledgeMapGraph(props) {
2992
+ return /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(NewKnowledgeMapGraphInner, { ...props }) });
2993
+ }
2994
+ function DefinitionSectionHeader({ expanded, onToggle, icon, title, count }) {
2995
+ return /* @__PURE__ */ jsxs(Group, { gap: 4, onClick: onToggle, style: { cursor: "pointer", userSelect: "none" }, wrap: "nowrap", children: [
2996
+ /* @__PURE__ */ jsx(
2997
+ ActionIcon,
2998
+ {
2999
+ variant: "transparent",
3000
+ size: "xs",
3001
+ style: {
3002
+ transition: "transform var(--duration-fast) var(--easing)",
3003
+ transform: expanded ? "rotate(90deg)" : "rotate(0deg)"
3004
+ },
3005
+ children: /* @__PURE__ */ jsx(IconChevronRight, { size: 14 })
3006
+ }
3007
+ ),
3008
+ icon,
3009
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: title }),
3010
+ count && /* @__PURE__ */ jsxs(Text, { size: "xs", c: "dimmed", children: [
3011
+ "(",
3012
+ count,
3013
+ ")"
3014
+ ] })
3015
+ ] });
3016
+ }
3017
+ function AgentDefinitionDisplay({ agent, defaultExpanded = false }) {
3018
+ const [systemPromptExpanded, setSystemPromptExpanded] = useState(defaultExpanded);
3019
+ const [configExpanded, setConfigExpanded] = useState(defaultExpanded);
3020
+ const [knowledgeMapExpanded, setKnowledgeMapExpanded] = useState(defaultExpanded);
3021
+ const [knowledgeMapFitTrigger, setKnowledgeMapFitTrigger] = useState(0);
3022
+ const [toolsExpanded, setToolsExpanded] = useState(defaultExpanded);
3023
+ const [memoryPrefsExpanded, setMemoryPrefsExpanded] = useState(defaultExpanded);
3024
+ const hasConstraints = agent.config.constraints && Object.keys(agent.config.constraints).length > 0;
3025
+ const hasMemoryPreferences = !!agent.config.memoryPreferences;
3026
+ return /* @__PURE__ */ jsxs(Stack, { children: [
3027
+ /* @__PURE__ */ jsxs("div", { children: [
3028
+ /* @__PURE__ */ jsx(
3029
+ DefinitionSectionHeader,
3030
+ {
3031
+ expanded: configExpanded,
3032
+ onToggle: () => setConfigExpanded(!configExpanded),
3033
+ icon: /* @__PURE__ */ jsx(IconSettings, { size: 16, color: "var(--color-text-subtle)" }),
3034
+ title: "Configuration"
3035
+ }
3036
+ ),
3037
+ /* @__PURE__ */ jsxs(Collapse, { in: configExpanded, children: [
3038
+ /* @__PURE__ */ jsxs(SimpleGrid, { cols: 2, spacing: "sm", mt: "xs", pl: "xl", children: [
3039
+ /* @__PURE__ */ jsx(
3040
+ ConfigCard,
3041
+ {
3042
+ icon: /* @__PURE__ */ jsx(IconCpu, { size: 14 }),
3043
+ title: "Model",
3044
+ badge: agent.modelConfig.provider,
3045
+ items: [
3046
+ {
3047
+ label: "Model",
3048
+ value: /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: agent.modelConfig.model })
3049
+ },
3050
+ { label: "Temperature", value: agent.modelConfig.temperature, mono: true },
3051
+ { label: "Max Tokens", value: agent.modelConfig.maxOutputTokens?.toLocaleString(), mono: true },
3052
+ { label: "Top P", value: agent.modelConfig.topP, mono: true },
3053
+ {
3054
+ label: "Reasoning",
3055
+ value: agent.modelConfig.modelOptions && "reasoning_effort" in agent.modelConfig.modelOptions ? String(agent.modelConfig.modelOptions.reasoning_effort) : void 0,
3056
+ mono: true
3057
+ },
3058
+ {
3059
+ label: "Verbosity",
3060
+ value: agent.modelConfig.modelOptions && "verbosity" in agent.modelConfig.modelOptions ? String(agent.modelConfig.modelOptions.verbosity) : void 0,
3061
+ mono: true
3062
+ }
3063
+ ]
3064
+ }
3065
+ ),
3066
+ hasConstraints && /* @__PURE__ */ jsx(
3067
+ ConfigCard,
3068
+ {
3069
+ icon: /* @__PURE__ */ jsx(IconClockHour4, { size: 14 }),
3070
+ title: "Constraints",
3071
+ color: "orange",
3072
+ items: [
3073
+ { label: "Max Iterations", value: agent.config.constraints?.maxIterations, mono: true },
3074
+ {
3075
+ label: "Timeout",
3076
+ value: agent.config.constraints?.timeout ? `${(agent.config.constraints.timeout / 1e3).toFixed(0)}s` : void 0,
3077
+ mono: true
3078
+ },
3079
+ { label: "Max Memory Keys", value: agent.config.constraints?.maxSessionMemoryKeys, mono: true },
3080
+ {
3081
+ label: "Max Memory Tokens",
3082
+ value: agent.config.constraints?.maxMemoryTokens?.toLocaleString(),
3083
+ mono: true
3084
+ }
3085
+ ]
3086
+ }
3087
+ ),
3088
+ /* @__PURE__ */ jsx(
3089
+ ConfigCard,
3090
+ {
3091
+ icon: /* @__PURE__ */ jsx(IconVersions, { size: 14 }),
3092
+ title: "Version",
3093
+ color: "grape",
3094
+ items: [
3095
+ {
3096
+ label: "Version",
3097
+ value: /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: agent.config.version })
3098
+ }
3099
+ ]
3100
+ }
3101
+ ),
3102
+ /* @__PURE__ */ jsx(
3103
+ ConfigCard,
3104
+ {
3105
+ icon: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }),
3106
+ title: "Execution Interface",
3107
+ color: "teal",
3108
+ items: [
3109
+ {
3110
+ label: "Has Interface",
3111
+ value: agent.interface ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "green", children: "Yes" }) : /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: "No" })
3112
+ }
3113
+ ]
3114
+ }
3115
+ )
3116
+ ] }),
3117
+ /* @__PURE__ */ jsx("div", { style: { paddingLeft: "var(--mantine-spacing-xl)", marginTop: "var(--mantine-spacing-sm)" }, children: /* @__PURE__ */ jsx(ContractDisplay, { contract: agent.contract, defaultExpanded }) })
3118
+ ] })
3119
+ ] }),
3120
+ /* @__PURE__ */ jsx(Divider, {}),
3121
+ /* @__PURE__ */ jsxs("div", { children: [
3122
+ /* @__PURE__ */ jsx(
3123
+ DefinitionSectionHeader,
3124
+ {
3125
+ expanded: systemPromptExpanded,
3126
+ onToggle: () => setSystemPromptExpanded(!systemPromptExpanded),
3127
+ icon: /* @__PURE__ */ jsx(IconBrain, { size: 16, color: "var(--color-text-subtle)" }),
3128
+ title: "System Prompt"
3129
+ }
3130
+ ),
3131
+ /* @__PURE__ */ jsx(Collapse, { in: systemPromptExpanded, children: /* @__PURE__ */ jsx(Paper, { p: "sm", mt: "xs", children: /* @__PURE__ */ jsx(StyledMarkdown, { children: agent.config.systemPrompt }) }) })
3132
+ ] }),
3133
+ agent.knowledgeMap && agent.knowledgeMap.nodeCount > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
3134
+ /* @__PURE__ */ jsx(Divider, {}),
3135
+ /* @__PURE__ */ jsxs("div", { children: [
3136
+ /* @__PURE__ */ jsx(
3137
+ DefinitionSectionHeader,
3138
+ {
3139
+ expanded: knowledgeMapExpanded,
3140
+ onToggle: () => {
3141
+ const willExpand = !knowledgeMapExpanded;
3142
+ setKnowledgeMapExpanded(willExpand);
3143
+ if (willExpand) {
3144
+ setKnowledgeMapFitTrigger((prev) => prev + 1);
3145
+ }
3146
+ },
3147
+ icon: /* @__PURE__ */ jsx(IconNetwork, { size: 16, color: "var(--color-text-subtle)" }),
3148
+ title: "Knowledge Map",
3149
+ count: `${agent.knowledgeMap.nodeCount} ${agent.knowledgeMap.nodeCount === 1 ? "node" : "nodes"}`
3150
+ }
3151
+ ),
3152
+ /* @__PURE__ */ jsx(Collapse, { in: knowledgeMapExpanded, children: /* @__PURE__ */ jsx("div", { style: { marginTop: "var(--mantine-spacing-xs)" }, children: /* @__PURE__ */ jsx(
3153
+ NewKnowledgeMapGraph,
3154
+ {
3155
+ knowledgeMap: agent.knowledgeMap,
3156
+ agentName: agent.config.name,
3157
+ compact: true,
3158
+ fitViewTrigger: knowledgeMapFitTrigger
3159
+ }
3160
+ ) }) })
3161
+ ] })
3162
+ ] }),
3163
+ /* @__PURE__ */ jsx(Divider, {}),
3164
+ /* @__PURE__ */ jsxs("div", { children: [
3165
+ /* @__PURE__ */ jsx(
3166
+ DefinitionSectionHeader,
3167
+ {
3168
+ expanded: toolsExpanded,
3169
+ onToggle: () => setToolsExpanded(!toolsExpanded),
3170
+ icon: /* @__PURE__ */ jsx(IconTool, { size: 16, color: "var(--color-text-subtle)" }),
3171
+ title: "Tools",
3172
+ count: String(agent.tools.length)
3173
+ }
3174
+ ),
3175
+ /* @__PURE__ */ jsx(Collapse, { in: toolsExpanded, children: /* @__PURE__ */ jsx("div", { style: { marginTop: "var(--mantine-spacing-xs)" }, children: /* @__PURE__ */ jsx(ToolsListDisplay, { tools: agent.tools, compact: true }) }) })
3176
+ ] }),
3177
+ hasMemoryPreferences && /* @__PURE__ */ jsxs(Fragment, { children: [
3178
+ /* @__PURE__ */ jsx(Divider, {}),
3179
+ /* @__PURE__ */ jsxs("div", { children: [
3180
+ /* @__PURE__ */ jsx(
3181
+ DefinitionSectionHeader,
3182
+ {
3183
+ expanded: memoryPrefsExpanded,
3184
+ onToggle: () => setMemoryPrefsExpanded(!memoryPrefsExpanded),
3185
+ title: "Memory Preferences"
3186
+ }
3187
+ ),
3188
+ /* @__PURE__ */ jsx(Collapse, { in: memoryPrefsExpanded, children: /* @__PURE__ */ jsx(
3189
+ Paper,
3190
+ {
3191
+ p: "sm",
3192
+ mt: "xs",
3193
+ style: {
3194
+ backgroundColor: "var(--color-background)",
3195
+ border: "1px solid var(--color-border)"
3196
+ },
3197
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", style: { whiteSpace: "pre-wrap" }, children: agent.config.memoryPreferences })
3198
+ }
3199
+ ) })
3200
+ ] })
3201
+ ] })
3202
+ ] });
3203
+ }
3204
+ function WorkflowDefinitionDisplay({ workflow, defaultExpanded = false }) {
3205
+ const [configExpanded, setConfigExpanded] = useState(defaultExpanded);
3206
+ return /* @__PURE__ */ jsx(Stack, { children: /* @__PURE__ */ jsxs("div", { children: [
3207
+ /* @__PURE__ */ jsxs(
3208
+ Group,
3209
+ {
3210
+ gap: 4,
3211
+ onClick: () => setConfigExpanded(!configExpanded),
3212
+ style: { cursor: "pointer", userSelect: "none" },
3213
+ wrap: "nowrap",
3214
+ children: [
3215
+ /* @__PURE__ */ jsx(
3216
+ ActionIcon,
3217
+ {
3218
+ variant: "transparent",
3219
+ size: "xs",
3220
+ style: {
3221
+ transition: "transform var(--duration-fast) var(--easing)",
3222
+ transform: configExpanded ? "rotate(90deg)" : "rotate(0deg)"
3223
+ },
3224
+ children: /* @__PURE__ */ jsx(IconChevronRight, { size: 14 })
3225
+ }
3226
+ ),
3227
+ /* @__PURE__ */ jsx(IconSettings, { size: 16, color: "var(--color-text-subtle)" }),
3228
+ /* @__PURE__ */ jsx(Text, { size: "sm", fw: 600, style: { fontFamily: "var(--mantine-font-family-headings)" }, children: "Configuration" })
3229
+ ]
3230
+ }
3231
+ ),
3232
+ /* @__PURE__ */ jsxs(Collapse, { in: configExpanded, children: [
3233
+ /* @__PURE__ */ jsxs(SimpleGrid, { cols: 2, spacing: "sm", mt: "xs", pl: "xl", children: [
3234
+ /* @__PURE__ */ jsx(
3235
+ ConfigCard,
3236
+ {
3237
+ icon: /* @__PURE__ */ jsx(IconVersions, { size: 14 }),
3238
+ title: "Version",
3239
+ color: "grape",
3240
+ items: [
3241
+ {
3242
+ label: "Version",
3243
+ value: /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", children: workflow.config.version })
3244
+ }
3245
+ ]
3246
+ }
3247
+ ),
3248
+ /* @__PURE__ */ jsx(
3249
+ ConfigCard,
3250
+ {
3251
+ icon: /* @__PURE__ */ jsx(IconPlayerPlay, { size: 14 }),
3252
+ title: "Execution Interface",
3253
+ color: "teal",
3254
+ items: [
3255
+ {
3256
+ label: "Has Interface",
3257
+ value: workflow.interface ? /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "green", children: "Yes" }) : /* @__PURE__ */ jsx(Badge, { size: "xs", variant: "light", color: "gray", children: "No" })
3258
+ }
3259
+ ]
3260
+ }
3261
+ )
3262
+ ] }),
3263
+ /* @__PURE__ */ jsx("div", { style: { paddingLeft: "var(--mantine-spacing-xl)", marginTop: "var(--mantine-spacing-sm)" }, children: /* @__PURE__ */ jsx(ContractDisplay, { contract: workflow.contract, defaultExpanded }) })
3264
+ ] })
3265
+ ] }) });
3266
+ }
3267
+ function isAgentDefinition(structure) {
3268
+ return structure.config.type === "agent" && "modelConfig" in structure;
3269
+ }
3270
+ function isWorkflowDefinition(structure) {
3271
+ return structure.config.type === "workflow" && "steps" in structure;
3272
+ }
3273
+ function ResourceDefinitionSection({
3274
+ resourceDefinition,
3275
+ defaultExpanded = false
3276
+ }) {
3277
+ const isAgent = isAgentDefinition(resourceDefinition);
3278
+ const isWorkflow = isWorkflowDefinition(resourceDefinition);
3279
+ if (isAgent) {
3280
+ return /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "sm", children: /* @__PURE__ */ jsxs(Stack, { children: [
3281
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3282
+ /* @__PURE__ */ jsx(IconBrain, { size: 20 }),
3283
+ /* @__PURE__ */ jsx(Title, { order: 3, children: "Agent Definition" })
3284
+ ] }),
3285
+ /* @__PURE__ */ jsx(Space, { h: 0 }),
3286
+ /* @__PURE__ */ jsx(AgentDefinitionDisplay, { agent: resourceDefinition, defaultExpanded })
3287
+ ] }) });
3288
+ }
3289
+ if (isWorkflow) {
3290
+ return /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "sm", children: /* @__PURE__ */ jsxs(Stack, { children: [
3291
+ /* @__PURE__ */ jsxs(Group, { gap: "xs", children: [
3292
+ /* @__PURE__ */ jsx(IconSitemap, { size: 20 }),
3293
+ /* @__PURE__ */ jsx(Title, { order: 3, children: "Workflow Definition" })
3294
+ ] }),
3295
+ /* @__PURE__ */ jsx(Space, { h: 0 }),
3296
+ /* @__PURE__ */ jsx(WorkflowDefinitionDisplay, { workflow: resourceDefinition, defaultExpanded })
3297
+ ] }) });
3298
+ }
3299
+ return /* @__PURE__ */ jsx(Paper, { withBorder: true, p: "sm", children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", fs: "italic", children: "Unknown resource type" }) });
3300
+ }
3301
+ var showInfoNotification = (message) => {
3302
+ notifications.show({
3303
+ title: "Info",
3304
+ message,
3305
+ autoClose: 5e3,
3306
+ color: "blue",
3307
+ position: "top-right"
3308
+ });
3309
+ };
3310
+ var showSuccessNotification = (message) => {
3311
+ notifications.show({
3312
+ title: "Action Successful",
3313
+ message,
3314
+ autoClose: 5e3,
3315
+ color: "green",
3316
+ position: "top-right"
3317
+ });
3318
+ };
3319
+ var showErrorNotification = (error) => {
3320
+ if (error instanceof Error) {
3321
+ error = error.message;
3322
+ }
3323
+ notifications.show({
3324
+ title: "Action Failed",
3325
+ message: error,
3326
+ autoClose: 5e3,
3327
+ color: "red",
3328
+ position: "top-right"
3329
+ });
3330
+ };
3331
+ var showWarningNotification = (message) => {
3332
+ notifications.show({
3333
+ title: "Warning",
3334
+ message,
3335
+ autoClose: 5e3,
3336
+ color: "orange",
3337
+ position: "top-right"
3338
+ });
3339
+ };
3340
+ var showApiErrorNotification = (error) => {
3341
+ const { message, code, requestId, fields, retryAfter } = getErrorInfo(error);
3342
+ notifications.show({
3343
+ title: getErrorTitle(code),
3344
+ message: formatErrorMessage(message, requestId, fields, retryAfter),
3345
+ autoClose: retryAfter ? retryAfter * 1e3 : 5e3,
3346
+ color: "red",
3347
+ position: "top-right"
3348
+ });
3349
+ };
3350
+
3351
+ export { APIErrorAlert, ActionModal, AgentDefinitionDisplay, AgentExecutionTimeline, AgentExecutionVisualizer, AgentIterationEdge, AgentIterationNode, BaseEdge, BaseNode, CardHeader, CollapsibleJsonSection, CollapsibleSection, ConfigCard, ConfirmationInputModal, ConfirmationModal, ContentSections, ContextViewer, ContractDisplay, CustomModal, CustomSelector, DetailCardSkeleton, EmptyState, EmptyVisualizer, ExecutionLogsTable, ExecutionStats, ExecutionStatusBadge, FilterBar, FormFieldRenderer, GraphBackground, GraphContainer, GraphFitViewButton, GraphFitViewHandler, GraphLegend, JsonViewer, ListSkeleton, NewKnowledgeMapEdge, NewKnowledgeMapGraph, NewKnowledgeMapNode, NotificationBell, NotificationItem, NotificationList, NotificationPanel, PageNotFound, PageTitleCaption, ResourceCard, ResourceDefinitionSection, ResourceHealthChart, SortableHeader, StatCard, StatCardSkeleton, StatsCardSkeleton, StyledMarkdown, TabCountBadge, TableSelectionToolbar, TaskCard, TimeRangeSelector, TimelineAxis, TimelineBar, TimelineContainer, TimelineRow, ToolsListDisplay, TrendIndicator, UnifiedWorkflowEdge, UnifiedWorkflowGraph, UnifiedWorkflowNode, VisualizerContainer, WorkflowDefinitionDisplay, WorkflowExecutionTimeline, catalogItemToResourceDefinition, getGraphBackgroundStyles, getHealthColor, getIcon, iconMap, showApiErrorNotification, showErrorNotification, showInfoNotification, showSuccessNotification, showWarningNotification, useGraphBackgroundStyles, useGraphTheme, useNewKnowledgeMapLayout };