@elevasis/ui 1.20.1 → 1.22.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 (66) hide show
  1. package/dist/charts/index.js +3 -2
  2. package/dist/chunk-3KMDHCAR.js +52 -0
  3. package/dist/{chunk-4SY4EQSK.js → chunk-5266RV46.js} +3 -3
  4. package/dist/{chunk-UMFPUM7Q.js → chunk-7TLPKXC2.js} +12 -12
  5. package/dist/{chunk-OFAXUZPZ.js → chunk-AJPFSMEH.js} +528 -336
  6. package/dist/chunk-AWT255UH.js +255 -0
  7. package/dist/{chunk-EMN755L5.js → chunk-CTF6FS2M.js} +10 -216
  8. package/dist/{chunk-C7AD6N23.js → chunk-DLI3F5IV.js} +364 -364
  9. package/dist/{chunk-AQ5MQDSS.js → chunk-EDAYKRPJ.js} +404 -2
  10. package/dist/{chunk-XOTN3X3Z.js → chunk-FATKFO7X.js} +3 -54
  11. package/dist/{chunk-JZEXFQ6N.js → chunk-HOYZWSNV.js} +91 -80
  12. package/dist/{chunk-AWMZCYKH.js → chunk-IAZT3VO6.js} +158 -82
  13. package/dist/{chunk-ERVB3QJQ.js → chunk-N5SDJP44.js} +1 -1
  14. package/dist/{chunk-3DIU726S.js → chunk-NVSKJG3L.js} +25 -4
  15. package/dist/{chunk-VLTVZXP6.js → chunk-QZS5FOIR.js} +2 -2
  16. package/dist/chunk-ROSMICXG.js +668 -0
  17. package/dist/{chunk-JIABC3AE.js → chunk-WAEKXBP3.js} +516 -266
  18. package/dist/{chunk-COTI2QPO.js → chunk-ZHJGTOXP.js} +4 -3
  19. package/dist/components/chat/index.d.ts +202 -0
  20. package/dist/components/chat/index.js +2 -0
  21. package/dist/components/index.css +0 -3
  22. package/dist/components/index.d.ts +37 -37
  23. package/dist/components/index.js +2652 -2902
  24. package/dist/features/auth/index.css +0 -3
  25. package/dist/features/dashboard/index.css +0 -3
  26. package/dist/features/dashboard/index.js +9 -9
  27. package/dist/features/monitoring/index.css +0 -3
  28. package/dist/features/monitoring/index.js +10 -10
  29. package/dist/features/operations/index.css +0 -3
  30. package/dist/features/operations/index.d.ts +245 -10
  31. package/dist/features/operations/index.js +1115 -170
  32. package/dist/features/settings/index.css +0 -3
  33. package/dist/features/settings/index.js +9 -9
  34. package/dist/hooks/index.css +68 -3
  35. package/dist/hooks/index.d.ts +1165 -4
  36. package/dist/hooks/index.js +5 -6
  37. package/dist/hooks/published.css +68 -3
  38. package/dist/hooks/published.d.ts +1165 -4
  39. package/dist/hooks/published.js +4 -5
  40. package/dist/index.css +68 -3
  41. package/dist/index.d.ts +1166 -5
  42. package/dist/index.js +6 -7
  43. package/dist/layout/index.d.ts +4 -4
  44. package/dist/layout/index.js +3 -4
  45. package/dist/provider/index.css +0 -3
  46. package/dist/provider/index.d.ts +1 -1
  47. package/dist/provider/index.js +3 -4
  48. package/dist/provider/published.d.ts +1 -1
  49. package/dist/theme/index.d.ts +1 -1
  50. package/dist/theme/index.js +3 -3
  51. package/dist/types/index.d.ts +1 -1
  52. package/package.json +7 -2
  53. package/dist/chunk-JFRG2JJE.js +0 -47
  54. package/dist/chunk-R3R367QY.js +0 -14
  55. package/dist/theme/presets/__tests__/getPreset.test.d.ts +0 -2
  56. package/dist/theme/presets/__tests__/getPreset.test.d.ts.map +0 -1
  57. package/dist/theme/presets/__tests__/getPreset.test.js +0 -92
  58. package/dist/theme/presets/cyber-volt.d.ts +0 -12
  59. package/dist/theme/presets/cyber-volt.d.ts.map +0 -1
  60. package/dist/theme/presets/cyber-volt.js +0 -70
  61. package/dist/theme/presets/regal.d.ts +0 -8
  62. package/dist/theme/presets/regal.d.ts.map +0 -1
  63. package/dist/theme/presets/regal.js +0 -69
  64. package/dist/theme/presets/rose-gold.d.ts +0 -12
  65. package/dist/theme/presets/rose-gold.d.ts.map +0 -1
  66. package/dist/theme/presets/rose-gold.js +0 -76
@@ -0,0 +1,668 @@
1
+ import { StyledMarkdown } from './chunk-3KMDHCAR.js';
2
+ import { Stack, Textarea, Group, Text, Tooltip, ActionIcon, Paper, Box, Collapse, Title, Badge, Progress, Alert, Center, Loader } from '@mantine/core';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import { memo, useState, useCallback, useMemo, useRef, useEffect } from 'react';
5
+ import { IconSend, IconCheck, IconCopy, IconChevronDown, IconAlertCircle, IconAlertTriangle } from '@tabler/icons-react';
6
+ import { useClipboard } from '@mantine/hooks';
7
+ import JSONPrettyRaw from 'react-json-pretty';
8
+
9
+ function ChatSidebar({ isOpen, title = "Details", children, width = 320, zIndex = 10 }) {
10
+ return /* @__PURE__ */ jsxs(
11
+ Paper,
12
+ {
13
+ withBorder: isOpen,
14
+ style: {
15
+ position: "absolute",
16
+ top: 0,
17
+ right: 0,
18
+ bottom: 0,
19
+ width: `${width}px`,
20
+ transform: isOpen ? "translateX(0)" : "translateX(100%)",
21
+ opacity: isOpen ? 1 : 0,
22
+ transition: "transform var(--duration-normal) var(--easing), opacity var(--duration-normal) var(--easing)",
23
+ background: "var(--glass-background)",
24
+ zIndex,
25
+ display: "flex",
26
+ flexDirection: "column",
27
+ margin: 8
28
+ },
29
+ children: [
30
+ /* @__PURE__ */ jsx(Group, { justify: "space-between", p: "sm", style: { borderBottom: "1px solid var(--color-border)" }, children: /* @__PURE__ */ jsx(Text, { fw: 600, size: "sm", style: { fontFamily: "var(--mantine-font-family-headings)" }, children: title }) }),
31
+ children
32
+ ]
33
+ }
34
+ );
35
+ }
36
+ function ChatHeader({
37
+ title,
38
+ status,
39
+ contextUsage,
40
+ sidebarIcon,
41
+ onToggleSidebar,
42
+ isSidebarOpen = false,
43
+ sidebarTooltip
44
+ }) {
45
+ const percentage = contextUsage ? Math.round(contextUsage.used / contextUsage.total * 100) : 0;
46
+ const progressColor = percentage > 90 ? "red" : percentage > 75 ? "orange" : "blue";
47
+ return /* @__PURE__ */ jsxs(Group, { justify: "space-between", align: "center", children: [
48
+ /* @__PURE__ */ jsxs(Group, { gap: "sm", children: [
49
+ /* @__PURE__ */ jsx(Title, { order: 3, children: title }),
50
+ status && /* @__PURE__ */ jsx(Badge, { size: "sm", variant: "light", color: status.color, children: status.label })
51
+ ] }),
52
+ /* @__PURE__ */ jsxs(Group, { children: [
53
+ contextUsage && /* @__PURE__ */ jsx(
54
+ Tooltip,
55
+ {
56
+ label: `${contextUsage.used.toLocaleString()} / ${contextUsage.total.toLocaleString()} tokens used`,
57
+ position: "bottom",
58
+ children: /* @__PURE__ */ jsx("div", { style: { width: "180px" }, children: /* @__PURE__ */ jsxs(Stack, { gap: 4, children: [
59
+ /* @__PURE__ */ jsxs(Group, { justify: "space-between", children: [
60
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", children: "Context" }),
61
+ /* @__PURE__ */ jsxs(Text, { size: "xs", fw: 600, c: progressColor, children: [
62
+ percentage,
63
+ "%"
64
+ ] })
65
+ ] }),
66
+ /* @__PURE__ */ jsx(Progress, { value: percentage, color: progressColor, size: "sm" })
67
+ ] }) })
68
+ }
69
+ ),
70
+ sidebarIcon && onToggleSidebar && /* @__PURE__ */ jsx(Tooltip, { label: sidebarTooltip || (isSidebarOpen ? "Close sidebar" : "Open sidebar"), position: "left", children: /* @__PURE__ */ jsx(
71
+ ActionIcon,
72
+ {
73
+ variant: "subtle",
74
+ size: "lg",
75
+ onClick: onToggleSidebar,
76
+ style: {
77
+ transform: isSidebarOpen ? "rotate(180deg)" : "rotate(0deg)",
78
+ transition: "transform var(--duration-normal) var(--easing)",
79
+ color: "var(--color-text-subtle)",
80
+ marginRight: 4
81
+ },
82
+ children: sidebarIcon
83
+ }
84
+ ) })
85
+ ] })
86
+ ] });
87
+ }
88
+ var ChatInputArea = memo(function ChatInputArea2({
89
+ input,
90
+ onInputChange,
91
+ onSend,
92
+ isDisabled = false,
93
+ isProcessing = false,
94
+ isConnected = true,
95
+ placeholder = "Message the agent..."
96
+ }) {
97
+ const [focused, setFocused] = useState(false);
98
+ const handleKeyDown = useCallback(
99
+ (e) => {
100
+ if (e.key === "Enter" && !e.shiftKey) {
101
+ e.preventDefault();
102
+ onSend();
103
+ }
104
+ },
105
+ [onSend]
106
+ );
107
+ const canSend = isConnected && !isDisabled && !isProcessing && input.trim();
108
+ return /* @__PURE__ */ jsx(Stack, { gap: 4, pt: 6, children: /* @__PURE__ */ jsxs(
109
+ "div",
110
+ {
111
+ style: {
112
+ display: "flex",
113
+ gap: "10px",
114
+ alignItems: "flex-end",
115
+ background: "var(--color-surface)",
116
+ border: focused ? "1px solid color-mix(in srgb, var(--color-primary) 50%, var(--color-border))" : "1px solid var(--color-border)",
117
+ borderRadius: "14px",
118
+ padding: "6px 6px 6px 16px",
119
+ transition: "border-color 180ms, box-shadow 180ms",
120
+ boxShadow: focused ? "0 0 0 1px color-mix(in srgb, var(--color-primary) 15%, transparent), 0 0 12px color-mix(in srgb, var(--color-primary) 10%, transparent), inset 0 0 8px color-mix(in srgb, var(--color-primary) 4%, transparent)" : "var(--standard-box-shadow)"
121
+ },
122
+ children: [
123
+ /* @__PURE__ */ jsx(
124
+ Textarea,
125
+ {
126
+ placeholder,
127
+ value: input,
128
+ onChange: (e) => onInputChange(e.currentTarget.value),
129
+ onKeyDown: handleKeyDown,
130
+ onFocus: () => setFocused(true),
131
+ onBlur: () => setFocused(false),
132
+ autosize: true,
133
+ minRows: 1,
134
+ maxRows: 6,
135
+ style: { flex: 1 },
136
+ disabled: !isConnected || isProcessing || isDisabled,
137
+ styles: {
138
+ input: {
139
+ border: "none",
140
+ background: "transparent",
141
+ fontSize: "14px",
142
+ padding: "6px 0",
143
+ color: "var(--color-text)",
144
+ "&:focus": {
145
+ outline: "none"
146
+ },
147
+ "&::placeholder": {
148
+ color: "var(--color-text-subtle)",
149
+ fontWeight: 400,
150
+ opacity: 0.6
151
+ }
152
+ }
153
+ }
154
+ }
155
+ ),
156
+ /* @__PURE__ */ jsx(
157
+ "button",
158
+ {
159
+ onClick: onSend,
160
+ disabled: !canSend,
161
+ "aria-label": "Send message",
162
+ style: {
163
+ display: "flex",
164
+ alignItems: "center",
165
+ justifyContent: "center",
166
+ width: 36,
167
+ height: 36,
168
+ flexShrink: 0,
169
+ border: "none",
170
+ borderRadius: "10px",
171
+ cursor: canSend ? "pointer" : "default",
172
+ background: canSend ? "linear-gradient(135deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 80%, black))" : "var(--color-surface-hover)",
173
+ boxShadow: canSend ? "0 2px 8px color-mix(in srgb, var(--color-primary) 35%, transparent), inset 0 1px 0 rgba(255,255,255,0.1)" : "none",
174
+ transition: "all 180ms",
175
+ transform: canSend ? "scale(1)" : "scale(0.92)",
176
+ opacity: canSend ? 1 : 0.35
177
+ },
178
+ children: /* @__PURE__ */ jsx(IconSend, { size: 16, color: "white", style: { marginLeft: -1 } })
179
+ }
180
+ )
181
+ ]
182
+ }
183
+ ) });
184
+ });
185
+ var JSONPretty = JSONPrettyRaw;
186
+ var jsonTheme = {
187
+ main: "line-height:1.3;color:var(--color-text);background:transparent;overflow:auto;",
188
+ error: "line-height:1.3;color:var(--color-error);background:transparent;overflow:auto;",
189
+ key: "color:var(--color-text-dimmed);",
190
+ string: "color:var(--color-success);",
191
+ value: "color:var(--color-warning);",
192
+ boolean: "color:var(--color-text-dimmed);"
193
+ };
194
+ var ENTRANCE_DURATION = "0.35s";
195
+ var ENTRANCE_EASING = "cubic-bezier(0.16, 1, 0.3, 1)";
196
+ var slideFromLeft = {
197
+ animation: `assistantSlideIn ${ENTRANCE_DURATION} ${ENTRANCE_EASING} both`
198
+ };
199
+ var slideFromRight = {
200
+ animation: `assistantSlideInRight ${ENTRANCE_DURATION} ${ENTRANCE_EASING} both`
201
+ };
202
+ var keyframesInjected = false;
203
+ function ensureKeyframes() {
204
+ if (keyframesInjected || typeof document === "undefined") return;
205
+ keyframesInjected = true;
206
+ const style = document.createElement("style");
207
+ style.textContent = `
208
+ @keyframes assistantSlideIn {
209
+ from { opacity: 0; transform: translateX(-12px); }
210
+ to { opacity: 1; transform: translateX(0); }
211
+ }
212
+ @keyframes assistantSlideInRight {
213
+ from { opacity: 0; transform: translateX(12px); }
214
+ to { opacity: 1; transform: translateX(0); }
215
+ }
216
+ `;
217
+ document.head.appendChild(style);
218
+ }
219
+ var monoMeta = {
220
+ fontFamily: "var(--mantine-font-family-monospace)",
221
+ fontSize: "0.65rem",
222
+ letterSpacing: "0.06em"
223
+ };
224
+ function AgentActivityBubble({
225
+ icon,
226
+ title,
227
+ color,
228
+ collapsible = false,
229
+ expanded = false,
230
+ onToggle,
231
+ children
232
+ }) {
233
+ return /* @__PURE__ */ jsx(Box, { style: { alignSelf: "flex-start", width: "100%", maxWidth: "75%", ...slideFromLeft }, children: /* @__PURE__ */ jsxs(
234
+ Paper,
235
+ {
236
+ p: "xs",
237
+ withBorder: false,
238
+ style: {
239
+ backgroundColor: "var(--color-surface)",
240
+ border: "none",
241
+ boxShadow: "var(--standard-box-shadow)"
242
+ },
243
+ children: [
244
+ /* @__PURE__ */ jsxs(
245
+ Group,
246
+ {
247
+ gap: "xs",
248
+ onClick: collapsible ? onToggle : void 0,
249
+ style: {
250
+ cursor: collapsible ? "pointer" : "default",
251
+ userSelect: collapsible ? "none" : "auto"
252
+ },
253
+ children: [
254
+ /* @__PURE__ */ jsxs(Text, { size: "sm", c: color, ff: "monospace", style: { letterSpacing: "0.04em" }, children: [
255
+ icon,
256
+ " ",
257
+ title
258
+ ] }),
259
+ collapsible && /* @__PURE__ */ jsx(
260
+ IconChevronDown,
261
+ {
262
+ size: 14,
263
+ style: {
264
+ transform: expanded ? "rotate(180deg)" : "none",
265
+ transition: "transform var(--duration-fast)"
266
+ }
267
+ }
268
+ )
269
+ ]
270
+ }
271
+ ),
272
+ collapsible ? /* @__PURE__ */ jsx(Collapse, { in: expanded, children: /* @__PURE__ */ jsx(Box, { mt: "xs", p: "xs", children }) }) : /* @__PURE__ */ jsx(Box, { mt: "xs", p: "xs", children })
273
+ ]
274
+ }
275
+ ) });
276
+ }
277
+ var MessageBubble = memo(function MessageBubble2({ message }) {
278
+ ensureKeyframes();
279
+ const [expanded, setExpanded] = useState(false);
280
+ switch (message.messageType) {
281
+ case "user_message":
282
+ case "assistant_message":
283
+ return /* @__PURE__ */ jsx(TextMessage, { message });
284
+ case "agent:started":
285
+ case "agent:completed":
286
+ return null;
287
+ // Don't render system lifecycle messages
288
+ case "agent:reasoning": {
289
+ const event = message.metadata;
290
+ return /* @__PURE__ */ jsx(
291
+ ReasoningMessage,
292
+ {
293
+ iteration: event.iteration,
294
+ reasoning: event.reasoning,
295
+ expanded,
296
+ onToggle: () => setExpanded(!expanded)
297
+ }
298
+ );
299
+ }
300
+ case "agent:tool_call": {
301
+ const event = message.metadata;
302
+ return /* @__PURE__ */ jsx(
303
+ ToolCallMessage,
304
+ {
305
+ toolName: event.toolName,
306
+ args: event.args,
307
+ expanded,
308
+ onToggle: () => setExpanded(!expanded)
309
+ }
310
+ );
311
+ }
312
+ case "agent:tool_result": {
313
+ const event = message.metadata;
314
+ return /* @__PURE__ */ jsx(
315
+ ToolResultMessage,
316
+ {
317
+ success: event.success,
318
+ result: event.result,
319
+ error: event.error,
320
+ expanded,
321
+ onToggle: () => setExpanded(!expanded)
322
+ }
323
+ );
324
+ }
325
+ case "agent:error": {
326
+ const event = message.metadata;
327
+ return /* @__PURE__ */ jsx(ErrorMessage, { error: event.error, expanded, onToggle: () => setExpanded(!expanded) });
328
+ }
329
+ default:
330
+ return null;
331
+ }
332
+ });
333
+ function TextMessage({ message }) {
334
+ const isUser = message.role === "user";
335
+ const clipboard = useClipboard({ timeout: 2e3 });
336
+ return /* @__PURE__ */ jsxs(
337
+ Stack,
338
+ {
339
+ gap: 4,
340
+ style: {
341
+ alignSelf: isUser ? "flex-end" : "flex-start",
342
+ maxWidth: "75%",
343
+ ...isUser ? slideFromRight : slideFromLeft
344
+ },
345
+ children: [
346
+ /* @__PURE__ */ jsxs(Group, { gap: 6, justify: isUser ? "flex-end" : "flex-start", children: [
347
+ /* @__PURE__ */ jsx(
348
+ Text,
349
+ {
350
+ size: "xs",
351
+ fw: 600,
352
+ c: isUser ? "var(--color-primary)" : "var(--color-text-subtle)",
353
+ tt: "uppercase",
354
+ style: { ...monoMeta, fontWeight: 600 },
355
+ children: isUser ? "USER" : "AGENT"
356
+ }
357
+ ),
358
+ /* @__PURE__ */ jsx(Text, { size: "xs", c: "dimmed", style: monoMeta, children: message.createdAt.toLocaleTimeString() }),
359
+ /* @__PURE__ */ jsx(Tooltip, { label: clipboard.copied ? "Copied!" : "Copy message", position: "top", children: /* @__PURE__ */ jsx(
360
+ ActionIcon,
361
+ {
362
+ size: "xs",
363
+ variant: "subtle",
364
+ color: "gray",
365
+ onClick: () => clipboard.copy(message.text),
366
+ style: { opacity: 0.5, transition: "opacity var(--duration-fast)" },
367
+ onMouseEnter: (e) => e.currentTarget.style.opacity = "1",
368
+ onMouseLeave: (e) => e.currentTarget.style.opacity = "0.5",
369
+ children: clipboard.copied ? /* @__PURE__ */ jsx(IconCheck, { size: 12 }) : /* @__PURE__ */ jsx(IconCopy, { size: 12 })
370
+ }
371
+ ) })
372
+ ] }),
373
+ /* @__PURE__ */ jsx(
374
+ Paper,
375
+ {
376
+ p: "xs",
377
+ c: isUser ? "var(--color-primary-contrast)" : "var(--color-text)",
378
+ style: {
379
+ backgroundColor: isUser ? "var(--color-primary)" : "var(--color-surface)",
380
+ borderLeft: isUser ? "none" : "2px solid color-mix(in srgb, var(--color-primary) 30%, transparent)",
381
+ border: isUser ? "none" : void 0,
382
+ boxShadow: isUser ? "0 2px 8px color-mix(in srgb, var(--color-primary) 30%, transparent)" : "var(--standard-box-shadow)"
383
+ },
384
+ children: isUser ? /* @__PURE__ */ jsx(Text, { size: "sm", style: { lineHeight: 1.55 }, children: message.text }) : /* @__PURE__ */ jsx(
385
+ StyledMarkdown,
386
+ {
387
+ components: {
388
+ p: ({ children }) => /* @__PURE__ */ jsx(Text, { size: "sm", style: { lineHeight: 1.55, margin: "0.25rem 0" }, component: "p", children })
389
+ },
390
+ children: message.text
391
+ }
392
+ )
393
+ }
394
+ )
395
+ ]
396
+ }
397
+ );
398
+ }
399
+ function ReasoningMessage({
400
+ iteration,
401
+ reasoning,
402
+ expanded,
403
+ onToggle
404
+ }) {
405
+ return /* @__PURE__ */ jsx(
406
+ AgentActivityBubble,
407
+ {
408
+ icon: "\u{1F4AD}",
409
+ title: `Reasoning (Iteration ${iteration})`,
410
+ color: "var(--color-primary)",
411
+ collapsible: true,
412
+ expanded,
413
+ onToggle,
414
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text)", style: { whiteSpace: "pre-wrap", lineHeight: 1.6 }, children: reasoning })
415
+ }
416
+ );
417
+ }
418
+ function ToolCallMessage({
419
+ toolName,
420
+ args,
421
+ expanded,
422
+ onToggle
423
+ }) {
424
+ return /* @__PURE__ */ jsx(
425
+ AgentActivityBubble,
426
+ {
427
+ icon: "\u{1F527}",
428
+ title: `Tool: ${toolName}`,
429
+ color: "var(--mantine-color-cyan-6)",
430
+ collapsible: true,
431
+ expanded,
432
+ onToggle,
433
+ children: /* @__PURE__ */ jsx(
434
+ "div",
435
+ {
436
+ style: {
437
+ fontSize: "0.75rem",
438
+ fontFamily: "var(--mantine-font-family-monospace)",
439
+ padding: "0.5rem",
440
+ overflow: "auto",
441
+ background: "var(--color-background)",
442
+ borderRadius: "var(--mantine-radius-sm)"
443
+ },
444
+ children: /* @__PURE__ */ jsx(JSONPretty, { data: args, theme: jsonTheme })
445
+ }
446
+ )
447
+ }
448
+ );
449
+ }
450
+ function ToolResultMessage({
451
+ success,
452
+ result,
453
+ error,
454
+ expanded,
455
+ onToggle
456
+ }) {
457
+ const color = success ? "green" : "orange";
458
+ const icon = success ? "\u2705" : "\u26A0\uFE0F";
459
+ return /* @__PURE__ */ jsx(
460
+ AgentActivityBubble,
461
+ {
462
+ icon,
463
+ title: "Tool Result",
464
+ color: `var(--mantine-color-${color}-6)`,
465
+ collapsible: true,
466
+ expanded,
467
+ onToggle,
468
+ children: success ? /* @__PURE__ */ jsx(
469
+ "div",
470
+ {
471
+ style: {
472
+ fontSize: "0.75rem",
473
+ fontFamily: "var(--mantine-font-family-monospace)",
474
+ padding: "0.5rem",
475
+ overflow: "auto",
476
+ background: "var(--color-background)",
477
+ borderRadius: "var(--mantine-radius-sm)"
478
+ },
479
+ children: /* @__PURE__ */ jsx(JSONPretty, { data: result, theme: jsonTheme })
480
+ }
481
+ ) : /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text)", style: { whiteSpace: "pre-wrap", lineHeight: 1.6 }, children: error })
482
+ }
483
+ );
484
+ }
485
+ function ErrorMessage({ error, expanded, onToggle }) {
486
+ return /* @__PURE__ */ jsx(
487
+ AgentActivityBubble,
488
+ {
489
+ icon: "\u274C",
490
+ title: "Agent Error",
491
+ color: "var(--color-error)",
492
+ collapsible: true,
493
+ expanded,
494
+ onToggle,
495
+ children: /* @__PURE__ */ jsx(Text, { size: "sm", c: "var(--color-text)", style: { whiteSpace: "pre-wrap", lineHeight: 1.6 }, children: error })
496
+ }
497
+ );
498
+ }
499
+ var TEXT = "PROCESSING...";
500
+ var STREAK_DURATION = 1.8;
501
+ var BRIGHT_WIDTH = 3;
502
+ function ProcessingIndicator() {
503
+ const letters = useMemo(
504
+ () => TEXT.split("").map((char, i) => ({
505
+ char,
506
+ delay: i / TEXT.length * STREAK_DURATION
507
+ })),
508
+ []
509
+ );
510
+ return /* @__PURE__ */ jsxs(
511
+ "div",
512
+ {
513
+ style: {
514
+ fontFamily: "monospace",
515
+ fontSize: "var(--mantine-font-size-xs)",
516
+ letterSpacing: "0.06em",
517
+ paddingLeft: "var(--mantine-spacing-xs)",
518
+ paddingRight: "var(--mantine-spacing-xs)",
519
+ display: "inline-flex"
520
+ },
521
+ children: [
522
+ /* @__PURE__ */ jsx("style", { children: `
523
+ @keyframes processing-streak {
524
+ 0%, 100% {
525
+ color: color-mix(in srgb, var(--color-primary) 40%, transparent);
526
+ text-shadow: none;
527
+ }
528
+ ${Math.round(BRIGHT_WIDTH / TEXT.length * 50)}% {
529
+ color: color-mix(in srgb, var(--color-primary) 100%, white);
530
+ text-shadow: 0 0 8px color-mix(in srgb, var(--color-primary) 60%, transparent);
531
+ }
532
+ }
533
+ ` }),
534
+ letters.map((letter, i) => /* @__PURE__ */ jsx(
535
+ "span",
536
+ {
537
+ style: {
538
+ color: "color-mix(in srgb, var(--color-primary) 40%, transparent)",
539
+ animation: `processing-streak ${STREAK_DURATION}s ease-in-out ${letter.delay}s infinite`
540
+ },
541
+ children: letter.char
542
+ },
543
+ i
544
+ ))
545
+ ]
546
+ }
547
+ );
548
+ }
549
+ function MessageAreaContent({
550
+ isConnected,
551
+ isProcessing,
552
+ error,
553
+ messages,
554
+ emptyStateText,
555
+ emptyStateSubtext,
556
+ scrollRef
557
+ }) {
558
+ if (!isConnected) {
559
+ return /* @__PURE__ */ jsx(Center, { style: { flex: 1, width: "100%", marginTop: "auto", marginBottom: "auto" }, children: error ? /* @__PURE__ */ jsxs(Stack, { align: "center", gap: "xs", children: [
560
+ /* @__PURE__ */ jsx(IconAlertTriangle, { size: 40, color: "var(--mantine-color-red-6)" }),
561
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "red", children: error })
562
+ ] }) : /* @__PURE__ */ jsx(Loader, { size: "lg" }) });
563
+ }
564
+ if (messages.length === 0) {
565
+ return /* @__PURE__ */ jsx(Center, { style: { flex: 1, width: "100%", marginTop: "auto", marginBottom: "auto" }, children: /* @__PURE__ */ jsxs(Stack, { align: "center", children: [
566
+ /* @__PURE__ */ jsx(Text, { c: "dimmed", children: emptyStateText }),
567
+ /* @__PURE__ */ jsx(Text, { size: "sm", c: "dimmed", children: emptyStateSubtext })
568
+ ] }) });
569
+ }
570
+ return /* @__PURE__ */ jsxs(Stack, { pb: 4, pr: "sm", style: { marginTop: "auto" }, children: [
571
+ messages.map((msg) => /* @__PURE__ */ jsx(MessageBubble, { message: msg }, msg.id)),
572
+ isProcessing && /* @__PURE__ */ jsx(ProcessingIndicator, {}),
573
+ /* @__PURE__ */ jsx("div", { ref: scrollRef })
574
+ ] });
575
+ }
576
+ function ChatInterface({
577
+ messages,
578
+ input,
579
+ onInputChange,
580
+ onSendMessage,
581
+ isProcessing = false,
582
+ isConnected = true,
583
+ error,
584
+ onClearError,
585
+ emptyStateText = "No messages yet",
586
+ emptyStateSubtext = "Send a message to start the conversation",
587
+ placeholder = "Message the agent..."
588
+ }) {
589
+ const scrollRef = useRef(null);
590
+ const scrollContainerRef = useRef(null);
591
+ useEffect(() => {
592
+ if (scrollContainerRef.current) {
593
+ scrollContainerRef.current.scrollTop = scrollContainerRef.current.scrollHeight;
594
+ }
595
+ }, [messages.length, isConnected, isProcessing]);
596
+ return /* @__PURE__ */ jsxs(Stack, { gap: 0, style: { height: "100%", overflow: "hidden" }, children: [
597
+ /* @__PURE__ */ jsx(ScrollableContainer, { containerRef: scrollContainerRef, children: /* @__PURE__ */ jsx(
598
+ MessageAreaContent,
599
+ {
600
+ isConnected,
601
+ isProcessing,
602
+ error,
603
+ messages,
604
+ emptyStateText,
605
+ emptyStateSubtext,
606
+ scrollRef
607
+ }
608
+ ) }),
609
+ isConnected && error && onClearError && /* @__PURE__ */ jsx(
610
+ Alert,
611
+ {
612
+ icon: /* @__PURE__ */ jsx(IconAlertCircle, { size: 16 }),
613
+ color: "red",
614
+ variant: "light",
615
+ withCloseButton: true,
616
+ onClose: onClearError,
617
+ radius: 0,
618
+ style: { flexShrink: 0 },
619
+ children: error
620
+ }
621
+ ),
622
+ /* @__PURE__ */ jsx(
623
+ ChatInputArea,
624
+ {
625
+ input,
626
+ onInputChange,
627
+ onSend: onSendMessage,
628
+ isProcessing,
629
+ isConnected,
630
+ placeholder
631
+ }
632
+ )
633
+ ] });
634
+ }
635
+ function ScrollableContainer({
636
+ children,
637
+ containerRef
638
+ }) {
639
+ return /* @__PURE__ */ jsx(
640
+ "div",
641
+ {
642
+ ref: containerRef,
643
+ style: {
644
+ flex: 1,
645
+ display: "flex",
646
+ flexDirection: "column",
647
+ overflowY: "auto",
648
+ overflowX: "hidden",
649
+ scrollBehavior: "smooth",
650
+ backgroundColor: "var(--color-background)",
651
+ backgroundImage: [
652
+ "linear-gradient(color-mix(in srgb, var(--color-primary) 5%, transparent) 1px, transparent 1px)",
653
+ "linear-gradient(90deg, color-mix(in srgb, var(--color-primary) 5%, transparent) 1px, transparent 1px)",
654
+ "radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--color-primary) 5%, transparent) 0%, transparent 70%)"
655
+ ].join(", "),
656
+ backgroundSize: "40px 40px, 40px 40px, 100% 100%",
657
+ borderRadius: "var(--mantine-radius-sm)",
658
+ padding: "8px",
659
+ // Custom scrollbar styling
660
+ scrollbarWidth: "thin",
661
+ scrollbarColor: "color-mix(in srgb, var(--color-text-subtle) 50%, var(--color-border)) transparent"
662
+ },
663
+ children
664
+ }
665
+ );
666
+ }
667
+
668
+ export { ChatHeader, ChatInputArea, ChatInterface, ChatSidebar, MessageBubble, ProcessingIndicator };