@constructive-io/ui 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3182 @@
1
+ 'use client';
2
+ const require_rolldown_runtime = require('./rolldown-runtime-D_qnwXdH.cjs');
3
+ const require_utils = require('./utils-CzTQ3-VI.cjs');
4
+ const require_components_button = require('./components/button.cjs');
5
+ const require_components_badge = require('./components/badge.cjs');
6
+ const require_components_alert = require('./components/alert.cjs');
7
+ const require_components_tooltip = require('./components/tooltip.cjs');
8
+ const require_components_collapsible = require('./components/collapsible.cjs');
9
+ const require_components_avatar = require('./components/avatar.cjs');
10
+ let react = require("react");
11
+ react = require_rolldown_runtime.__toESM(react, 1);
12
+ let react_jsx_runtime = require("react/jsx-runtime");
13
+ let lucide_react = require("lucide-react");
14
+ let sugar_high = require("sugar-high");
15
+ let sugar_high_presets = require("sugar-high/presets");
16
+
17
+ //#region src/components/ai/text-shimmer.tsx
18
+ /**
19
+ * Sweeping-gradient status text for in-flight agent states.
20
+ * CSS-only animation so it does not re-render on a timer.
21
+ */
22
+ function TextShimmer({ className, active = true, children, ...props }) {
23
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
24
+ "data-slot": "text-shimmer",
25
+ "data-active": active ? "true" : "false",
26
+ className: require_utils.cn("inline-block font-medium", active ? [
27
+ "bg-[linear-gradient(90deg,var(--muted-foreground)_35%,var(--foreground)_50%,var(--muted-foreground)_65%)]",
28
+ "bg-size-[200%_100%] bg-clip-text text-transparent",
29
+ "animate-[ai-shimmer-text_1.4s_linear_infinite]",
30
+ "motion-reduce:animate-none motion-reduce:bg-none motion-reduce:text-muted-foreground"
31
+ ] : "text-muted-foreground", className),
32
+ ...props,
33
+ children
34
+ });
35
+ }
36
+
37
+ //#endregion
38
+ //#region src/components/ai/agent-loader.tsx
39
+ const REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
40
+ function subscribeToReducedMotion(onStoreChange) {
41
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return () => void 0;
42
+ const mediaQuery = window.matchMedia(REDUCED_MOTION_QUERY);
43
+ mediaQuery.addEventListener("change", onStoreChange);
44
+ return () => mediaQuery.removeEventListener("change", onStoreChange);
45
+ }
46
+ function getReducedMotionSnapshot() {
47
+ return typeof window === "undefined" || typeof window.matchMedia !== "function" ? true : window.matchMedia(REDUCED_MOTION_QUERY).matches;
48
+ }
49
+ /** Chevron wavefront across a 3×3 grid (Drive / Dots). */
50
+ const chevronDelays = Array.from({ length: 9 }, (_, i) => {
51
+ const r = Math.floor(i / 3);
52
+ return (i % 3 + Math.abs(r - 1)) * 90;
53
+ });
54
+ const ORBIT_ORDER = [
55
+ 0,
56
+ 1,
57
+ 2,
58
+ 5,
59
+ 8,
60
+ 7,
61
+ 6,
62
+ 3
63
+ ];
64
+ const orbitDelays = Array.from({ length: 9 }, (_, i) => {
65
+ const k = ORBIT_ORDER.indexOf(i);
66
+ return k === -1 ? null : k * 110;
67
+ });
68
+ const PIXEL_PATTERNS = {
69
+ drive: {
70
+ delays: chevronDelays,
71
+ durationMs: 650,
72
+ round: false
73
+ },
74
+ dots: {
75
+ delays: chevronDelays,
76
+ durationMs: 650,
77
+ round: true
78
+ },
79
+ orbit: {
80
+ delays: orbitDelays,
81
+ durationMs: 950,
82
+ round: false
83
+ }
84
+ };
85
+ function formatElapsed(totalSeconds) {
86
+ if (totalSeconds < 60) return `${totalSeconds.toFixed(1)}s`;
87
+ return `${Math.floor(totalSeconds / 60)}m ${(totalSeconds % 60).toFixed(1)}s`;
88
+ }
89
+ function useElapsedSeconds(enabled, controlledMs) {
90
+ const [ticks, setTicks] = react.useState(0);
91
+ react.useEffect(() => {
92
+ if (!enabled || controlledMs !== void 0) return;
93
+ const id = window.setInterval(() => setTicks((value) => value + 1), 100);
94
+ return () => window.clearInterval(id);
95
+ }, [enabled, controlledMs]);
96
+ if (controlledMs !== void 0) return controlledMs / 1e3;
97
+ return ticks / 10;
98
+ }
99
+ function PixelGrid({ variant, reducedMotion }) {
100
+ const { delays, durationMs, round } = PIXEL_PATTERNS[variant];
101
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
102
+ "aria-hidden": true,
103
+ className: "grid grid-cols-[repeat(3,4px)] gap-[1.5px]",
104
+ children: delays.map((delay, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
105
+ className: require_utils.cn("size-1 bg-foreground", round ? "rounded-full" : "rounded-[1px]"),
106
+ style: {
107
+ opacity: delay === null ? .07 : .15,
108
+ animation: reducedMotion || delay === null ? "none" : `ai-pixel-on ${durationMs}ms ease-in-out ${delay}ms infinite`
109
+ }
110
+ }, index))
111
+ });
112
+ }
113
+ function sizeClass(size) {
114
+ return {
115
+ sm: "size-4",
116
+ md: "size-5",
117
+ lg: "size-6"
118
+ }[size];
119
+ }
120
+ function CircularLoader({ size, className }) {
121
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
122
+ className: require_utils.cn("inline-block animate-spin rounded-full border-2 border-primary border-t-transparent motion-reduce:animate-none", sizeClass(size), className),
123
+ "aria-hidden": true
124
+ });
125
+ }
126
+ function DotsBounce({ size, className }) {
127
+ const dot = {
128
+ sm: "size-1.5",
129
+ md: "size-2",
130
+ lg: "size-2.5"
131
+ }[size];
132
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
133
+ className: require_utils.cn("inline-flex items-center gap-1", className),
134
+ "aria-hidden": true,
135
+ children: [
136
+ 0,
137
+ 1,
138
+ 2
139
+ ].map((i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
140
+ className: require_utils.cn("rounded-full bg-primary animate-[ai-bounce-dots_1.4s_ease-in-out_infinite] motion-reduce:animate-none", dot),
141
+ style: { animationDelay: `${i * 160}ms` }
142
+ }, i))
143
+ });
144
+ }
145
+ function TypingLoader({ size, className }) {
146
+ const dot = {
147
+ sm: "size-1",
148
+ md: "size-1.5",
149
+ lg: "size-2"
150
+ }[size];
151
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
152
+ className: require_utils.cn("inline-flex items-center gap-1", className),
153
+ "aria-hidden": true,
154
+ children: [
155
+ 0,
156
+ 1,
157
+ 2
158
+ ].map((i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
159
+ className: require_utils.cn("rounded-full bg-primary animate-[ai-typing_1s_infinite] motion-reduce:animate-none", dot),
160
+ style: { animationDelay: `${i * 250}ms` }
161
+ }, i))
162
+ });
163
+ }
164
+ function WaveLoader({ size, className }) {
165
+ const heights = {
166
+ sm: [
167
+ "6px",
168
+ "9px",
169
+ "12px",
170
+ "9px",
171
+ "6px"
172
+ ],
173
+ md: [
174
+ "8px",
175
+ "12px",
176
+ "16px",
177
+ "12px",
178
+ "8px"
179
+ ],
180
+ lg: [
181
+ "10px",
182
+ "15px",
183
+ "20px",
184
+ "15px",
185
+ "10px"
186
+ ]
187
+ }[size];
188
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
189
+ className: require_utils.cn("inline-flex items-center gap-0.5", sizeClass(size), className),
190
+ "aria-hidden": true,
191
+ children: heights.map((height, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
192
+ className: "w-0.5 rounded-full bg-primary animate-[ai-wave_1s_ease-in-out_infinite] motion-reduce:animate-none",
193
+ style: {
194
+ height,
195
+ animationDelay: `${i * 100}ms`
196
+ }
197
+ }, i))
198
+ });
199
+ }
200
+ function PulseDot({ size, className }) {
201
+ const dot = {
202
+ sm: "size-1",
203
+ md: "size-2",
204
+ lg: "size-3"
205
+ }[size];
206
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
207
+ className: require_utils.cn("inline-block rounded-full bg-primary animate-[ai-pulse-dot_1.2s_ease-in-out_infinite] motion-reduce:animate-none", dot, className),
208
+ "aria-hidden": true
209
+ });
210
+ }
211
+ /**
212
+ * Agent loading indicator. Pixel variants (drive / dots / orbit) match the
213
+ * Beautiful UI craft; simple variants cover common chat spinners.
214
+ */
215
+ function AgentLoader({ variant = "drive", label = "Working", showElapsed = true, elapsedMs, size = "md", className, text }) {
216
+ const reducedMotion = react.useSyncExternalStore(subscribeToReducedMotion, getReducedMotionSnapshot, () => true);
217
+ const isPixel = variant === "drive" || variant === "dots" || variant === "orbit";
218
+ const elapsed = useElapsedSeconds(isPixel && showElapsed, elapsedMs);
219
+ const statusText = text ?? label;
220
+ if (isPixel) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
221
+ "data-slot": "agent-loader",
222
+ "data-variant": variant,
223
+ role: "status",
224
+ "aria-live": "polite",
225
+ className: require_utils.cn("inline-flex w-fit items-center gap-2.5", className),
226
+ children: [
227
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PixelGrid, {
228
+ variant,
229
+ reducedMotion
230
+ }),
231
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
232
+ className: "text-[13px]",
233
+ children: statusText
234
+ }),
235
+ showElapsed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
236
+ className: "font-mono text-xs tabular-nums text-muted-foreground",
237
+ children: formatElapsed(elapsed)
238
+ }) : null,
239
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
240
+ className: "sr-only",
241
+ children: [statusText, showElapsed ? `, ${formatElapsed(elapsed)}` : ""]
242
+ })
243
+ ]
244
+ });
245
+ if (variant === "text-shimmer") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
246
+ "data-slot": "agent-loader",
247
+ role: "status",
248
+ className: require_utils.cn("inline-flex", className),
249
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
250
+ className: require_utils.cn(size === "sm" && "text-xs", size === "lg" && "text-base"),
251
+ children: statusText
252
+ })
253
+ });
254
+ if (variant === "loading-dots") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
255
+ "data-slot": "agent-loader",
256
+ role: "status",
257
+ className: require_utils.cn("inline-flex items-center gap-0.5 font-medium text-primary", className),
258
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
259
+ className: require_utils.cn(size === "sm" && "text-xs", size === "md" && "text-sm", size === "lg" && "text-base"),
260
+ children: statusText
261
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
262
+ "aria-hidden": true,
263
+ className: "inline-flex",
264
+ children: [
265
+ 0,
266
+ 1,
267
+ 2
268
+ ].map((i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
269
+ className: "animate-[ai-loading-dots_1.4s_infinite] motion-reduce:animate-none",
270
+ style: { animationDelay: `${(i + 1) * .2}s` },
271
+ children: "."
272
+ }, i))
273
+ })]
274
+ });
275
+ const indicator = variant === "circular" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CircularLoader, { size }) : variant === "bounce-dots" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DotsBounce, { size }) : variant === "typing" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TypingLoader, { size }) : variant === "wave" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WaveLoader, { size }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PulseDot, { size });
276
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
277
+ "data-slot": "agent-loader",
278
+ "data-variant": variant,
279
+ role: "status",
280
+ "aria-live": "polite",
281
+ className: require_utils.cn("inline-flex items-center gap-2", className),
282
+ children: [indicator, statusText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
283
+ className: "sr-only",
284
+ children: statusText
285
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
286
+ className: "sr-only",
287
+ children: "Loading"
288
+ })]
289
+ });
290
+ }
291
+ /** @deprecated Prefer AgentLoader — alias kept for prompt-kit familiarity. */
292
+ const Loader = AgentLoader;
293
+
294
+ //#endregion
295
+ //#region src/components/ai/prompt-input.tsx
296
+ const PromptInputContext = react.createContext(null);
297
+ function usePromptInput() {
298
+ const context = react.useContext(PromptInputContext);
299
+ if (!context) throw new Error("PromptInput compound parts must be used within <PromptInput>.");
300
+ return context;
301
+ }
302
+ /**
303
+ * Compound chat composer shell. Host owns submit/streaming; this owns layout,
304
+ * autosize context, and action slots.
305
+ */
306
+ function PromptInput({ className, isLoading = false, maxHeight = 240, value, onValueChange, onSubmit, children, disabled = false, shape = "default", onClick, ...props }) {
307
+ const [internalValue, setInternalValue] = react.useState(value ?? "");
308
+ const textareaRef = react.useRef(null);
309
+ react.useEffect(() => {
310
+ if (value !== void 0) setInternalValue(value);
311
+ }, [value]);
312
+ const handleChange = react.useCallback((next) => {
313
+ setInternalValue(next);
314
+ onValueChange?.(next);
315
+ }, [onValueChange]);
316
+ const handleClick = (event) => {
317
+ if (!disabled) textareaRef.current?.focus();
318
+ onClick?.(event);
319
+ };
320
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromptInputContext.Provider, {
321
+ value: {
322
+ isLoading,
323
+ value: value ?? internalValue,
324
+ setValue: onValueChange ?? handleChange,
325
+ maxHeight,
326
+ onSubmit,
327
+ disabled: disabled || isLoading,
328
+ textareaRef
329
+ },
330
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
331
+ "data-slot": "prompt-input",
332
+ "data-shape": shape,
333
+ "data-loading": isLoading ? "true" : "false",
334
+ onClick: handleClick,
335
+ className: require_utils.cn("cursor-text border border-input bg-background p-2 shadow-xs", "transition-shadow focus-within:border-primary/60 focus-within:ring-[3px] focus-within:ring-primary/35", shape === "pill" ? "rounded-3xl" : "rounded-xl", disabled && "cursor-not-allowed opacity-60", className),
336
+ ...props,
337
+ children
338
+ })
339
+ }) });
340
+ }
341
+ function PromptInputTextarea({ className, onKeyDown, disableAutosize = false, ...props }) {
342
+ const { value, setValue, maxHeight, onSubmit, disabled, textareaRef } = usePromptInput();
343
+ const adjustHeight = react.useCallback((element) => {
344
+ if (!element || disableAutosize) return;
345
+ element.style.height = "auto";
346
+ if (typeof maxHeight === "number") element.style.height = `${Math.min(element.scrollHeight, maxHeight)}px`;
347
+ else element.style.height = `min(${element.scrollHeight}px, ${maxHeight})`;
348
+ }, [disableAutosize, maxHeight]);
349
+ const setRefs = react.useCallback((element) => {
350
+ textareaRef.current = element;
351
+ adjustHeight(element);
352
+ }, [adjustHeight, textareaRef]);
353
+ react.useLayoutEffect(() => {
354
+ adjustHeight(textareaRef.current);
355
+ }, [
356
+ adjustHeight,
357
+ textareaRef,
358
+ value
359
+ ]);
360
+ const handleKeyDown = (event) => {
361
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
362
+ event.preventDefault();
363
+ onSubmit?.();
364
+ }
365
+ onKeyDown?.(event);
366
+ };
367
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("textarea", {
368
+ ref: setRefs,
369
+ "data-slot": "prompt-input-textarea",
370
+ value,
371
+ onChange: (event) => {
372
+ adjustHeight(event.target);
373
+ setValue(event.target.value);
374
+ },
375
+ onKeyDown: handleKeyDown,
376
+ disabled,
377
+ rows: 1,
378
+ className: require_utils.cn("min-h-11 w-full resize-none border-none bg-transparent px-2 py-1.5 text-sm outline-none", "placeholder:text-muted-foreground disabled:cursor-not-allowed", className),
379
+ ...props
380
+ });
381
+ }
382
+ function PromptInputActions({ className, ...props }) {
383
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
384
+ "data-slot": "prompt-input-actions",
385
+ className: require_utils.cn("flex items-center gap-1.5 px-1", className),
386
+ ...props
387
+ });
388
+ }
389
+ function PromptInputAction({ tooltip, children, className, side = "top", ...props }) {
390
+ const { disabled } = usePromptInput();
391
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_tooltip.Tooltip, {
392
+ ...props,
393
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipTrigger, {
394
+ asChild: true,
395
+ onClick: (event) => event.stopPropagation(),
396
+ disabled,
397
+ children
398
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipContent, {
399
+ side,
400
+ className,
401
+ children: tooltip
402
+ })]
403
+ });
404
+ }
405
+ function PromptInputBody({ className, ...props }) {
406
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
407
+ "data-slot": "prompt-input-body",
408
+ className: require_utils.cn("flex min-w-0 flex-col gap-1", className),
409
+ ...props
410
+ });
411
+ }
412
+
413
+ //#endregion
414
+ //#region src/components/ai/use-throttled-text.ts
415
+ /** Default stream throttle (~15fps) — bounds markdown re-parse cost. */
416
+ const STREAM_THROTTLE_MS = 66;
417
+ /**
418
+ * Throttle `text` updates while `streaming` is true; flush immediately when
419
+ * streaming ends so settled content is never delayed.
420
+ */
421
+ function useThrottledText(text, streaming, intervalMs = 66) {
422
+ const [throttled, setThrottled] = (0, react.useState)(text);
423
+ const latest = (0, react.useRef)(text);
424
+ latest.current = text;
425
+ const lastFlush = (0, react.useRef)(0);
426
+ const timer = (0, react.useRef)(null);
427
+ (0, react.useEffect)(() => {
428
+ if (!streaming) {
429
+ if (timer.current) {
430
+ clearTimeout(timer.current);
431
+ timer.current = null;
432
+ }
433
+ setThrottled((prev) => prev === text ? prev : text);
434
+ return;
435
+ }
436
+ const now = Date.now();
437
+ const elapsed = now - lastFlush.current;
438
+ if (elapsed >= intervalMs) {
439
+ lastFlush.current = now;
440
+ setThrottled(text);
441
+ } else if (timer.current == null) timer.current = setTimeout(() => {
442
+ timer.current = null;
443
+ lastFlush.current = Date.now();
444
+ setThrottled(latest.current);
445
+ }, intervalMs - elapsed);
446
+ }, [
447
+ text,
448
+ streaming,
449
+ intervalMs
450
+ ]);
451
+ (0, react.useEffect)(() => () => {
452
+ if (timer.current) clearTimeout(timer.current);
453
+ }, []);
454
+ return throttled;
455
+ }
456
+
457
+ //#endregion
458
+ //#region src/components/ai/markdown.tsx
459
+ function escapeHtml(value) {
460
+ return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
461
+ }
462
+ /**
463
+ * Lightweight markdown → HTML without hard deps.
464
+ * Handles paragraphs, bold, italic, inline code, fenced code, links, lists.
465
+ * Hosts that need full GFM can pass pre-rendered HTML via a future `html` prop
466
+ * or wrap with their own marked+DOMPurify pipeline.
467
+ */
468
+ function renderBasicMarkdown(source) {
469
+ const fences = [];
470
+ let text = source.replace(/```([\w-]*)\n?([\s\S]*?)```/g, (_match, lang, code) => {
471
+ const index = fences.length;
472
+ const language = lang ? ` data-language="${escapeHtml(lang)}"` : "";
473
+ fences.push(`<pre class="ai-md-pre" data-slot="markdown-pre"${language}><code>${escapeHtml(code.replace(/\n$/, ""))}</code></pre>`);
474
+ return `\u0000FENCE${index}\u0000`;
475
+ });
476
+ text = escapeHtml(text);
477
+ text = text.replace(/`([^`\n]+)`/g, "<code class=\"ai-md-code\">$1</code>");
478
+ text = text.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
479
+ text = text.replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, "<em>$1</em>");
480
+ text = text.replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g, "<a href=\"$2\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ai-md-link\">$1</a>");
481
+ const lines = text.split("\n");
482
+ const html = [];
483
+ let listOpen = null;
484
+ const closeList = () => {
485
+ if (listOpen) {
486
+ html.push(`</${listOpen}>`);
487
+ listOpen = null;
488
+ }
489
+ };
490
+ for (const line of lines) {
491
+ const unordered = line.match(/^[-*]\s+(.+)$/);
492
+ const ordered = line.match(/^\d+\.\s+(.+)$/);
493
+ const heading = line.match(/^(#{1,3})\s+(.+)$/);
494
+ if (unordered) {
495
+ if (listOpen !== "ul") {
496
+ closeList();
497
+ html.push("<ul class=\"ai-md-list\">");
498
+ listOpen = "ul";
499
+ }
500
+ html.push(`<li>${unordered[1]}</li>`);
501
+ continue;
502
+ }
503
+ if (ordered) {
504
+ if (listOpen !== "ol") {
505
+ closeList();
506
+ html.push("<ol class=\"ai-md-list\">");
507
+ listOpen = "ol";
508
+ }
509
+ html.push(`<li>${ordered[1]}</li>`);
510
+ continue;
511
+ }
512
+ closeList();
513
+ if (heading) {
514
+ const level = heading[1].length;
515
+ html.push(`<h${level} class="ai-md-h">${heading[2]}</h${level}>`);
516
+ continue;
517
+ }
518
+ if (line.trim() === "") {
519
+ html.push("");
520
+ continue;
521
+ }
522
+ if (line.includes("\0FENCE")) {
523
+ html.push(line.replace(/\u0000FENCE(\d+)\u0000/g, (_m, i) => fences[Number(i)] ?? ""));
524
+ continue;
525
+ }
526
+ html.push(`<p class="ai-md-p">${line}</p>`);
527
+ }
528
+ closeList();
529
+ return html.join("\n").replace(/\u0000FENCE(\d+)\u0000/g, (_m, i) => fences[Number(i)] ?? "");
530
+ }
531
+ /**
532
+ * Markdown renderer for assistant messages. Throttles while streaming.
533
+ * Uses a zero-dependency subset suitable for most agent replies; swap for a
534
+ * host-level marked pipeline when you need tables/footnotes.
535
+ */
536
+ function Markdown({ className, children, streaming = false, ...props }) {
537
+ const text = useThrottledText(children, streaming);
538
+ const html = react.useMemo(() => renderBasicMarkdown(text), [text]);
539
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
540
+ "data-slot": "markdown",
541
+ "data-streaming": streaming ? "true" : "false",
542
+ className: require_utils.cn("ai-markdown max-w-none space-y-3 break-words text-sm leading-relaxed text-foreground", "[&_.ai-md-p]:my-0", "[&_.ai-md-h]:font-semibold", "[&_h1.ai-md-h]:text-lg [&_h2.ai-md-h]:text-base [&_h3.ai-md-h]:text-sm", "[&_.ai-md-list]:my-1 [&_.ai-md-list]:list-disc [&_.ai-md-list]:space-y-1 [&_.ai-md-list]:pl-5", "[&_ol.ai-md-list]:list-decimal", "[&_.ai-md-code]:rounded-md [&_.ai-md-code]:bg-muted [&_.ai-md-code]:px-1 [&_.ai-md-code]:py-0.5 [&_.ai-md-code]:font-mono [&_.ai-md-code]:text-[0.85em]", "[&_.ai-md-pre]:overflow-x-auto [&_.ai-md-pre]:rounded-lg [&_.ai-md-pre]:border [&_.ai-md-pre]:border-border [&_.ai-md-pre]:bg-muted/50 [&_.ai-md-pre]:p-3 [&_.ai-md-pre]:font-mono [&_.ai-md-pre]:text-xs", "[&_.ai-md-link]:text-primary [&_.ai-md-link]:underline-offset-2 hover:[&_.ai-md-link]:underline", className),
543
+ dangerouslySetInnerHTML: { __html: html },
544
+ ...props
545
+ });
546
+ }
547
+
548
+ //#endregion
549
+ //#region src/components/ai/message.tsx
550
+ function Message({ className, from, ...props }) {
551
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
552
+ "data-slot": "message",
553
+ "data-from": from,
554
+ className: require_utils.cn("flex w-full gap-3", from === "user" && "justify-end [&_[data-slot=message-content]]:rounded-2xl [&_[data-slot=message-content]]:bg-secondary [&_[data-slot=message-content]]:px-3 [&_[data-slot=message-content]]:py-2", from === "assistant" && "justify-start", className),
555
+ ...props
556
+ });
557
+ }
558
+ function MessageAvatar({ src, alt = "", fallback, className, delay }) {
559
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_avatar.Avatar, {
560
+ className: require_utils.cn("size-8 shrink-0", className),
561
+ "data-slot": "message-avatar",
562
+ children: [src ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_avatar.AvatarImage, {
563
+ src,
564
+ alt
565
+ }) : null, fallback ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_avatar.AvatarFallback, {
566
+ delay,
567
+ children: fallback
568
+ }) : null]
569
+ });
570
+ }
571
+ function MessageContent({ className, markdown = false, streaming = false, children, ...props }) {
572
+ const contentClassName = require_utils.cn("min-w-0 max-w-[min(100%,42rem)] text-sm leading-relaxed text-foreground", className);
573
+ if (markdown && typeof children === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
574
+ "data-slot": "message-content",
575
+ streaming,
576
+ className: contentClassName,
577
+ ...props,
578
+ children
579
+ });
580
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
581
+ "data-slot": "message-content",
582
+ className: contentClassName,
583
+ ...props,
584
+ children
585
+ });
586
+ }
587
+ function MessageActions({ className, ...props }) {
588
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
589
+ "data-slot": "message-actions",
590
+ className: require_utils.cn("flex items-center gap-1 text-muted-foreground", className),
591
+ ...props
592
+ });
593
+ }
594
+ function MessageAction({ tooltip, children, className, side = "top", ...props }) {
595
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_tooltip.Tooltip, {
596
+ ...props,
597
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipTrigger, {
598
+ asChild: true,
599
+ children
600
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipContent, {
601
+ side,
602
+ className,
603
+ children: tooltip
604
+ })]
605
+ }) });
606
+ }
607
+
608
+ //#endregion
609
+ //#region src/components/ai/code-block.tsx
610
+ /** Default visible lines before the expand control appears. */
611
+ const DEFAULT_COLLAPSED_LINES = 12;
612
+ /** Approx. line box for text-xs + leading-relaxed (+ padding slack). */
613
+ const LINE_BOX_PX = 20;
614
+ /** Vertical padding inside the pre (p-3 = 12px × 2). */
615
+ const PRE_PAD_Y = 24;
616
+ /** Map common language labels to sugar-high presets (JS/TS/JSX is the default). */
617
+ function optionsForLanguage(language) {
618
+ if (!language) return void 0;
619
+ switch (language.toLowerCase().trim()) {
620
+ case "ts":
621
+ case "tsx":
622
+ case "typescript":
623
+ case "js":
624
+ case "jsx":
625
+ case "javascript":
626
+ case "mjs":
627
+ case "cjs": return;
628
+ case "py":
629
+ case "python": return sugar_high_presets.python;
630
+ case "rs":
631
+ case "rust": return sugar_high_presets.rust;
632
+ case "go":
633
+ case "golang": return sugar_high_presets.go;
634
+ case "java": return sugar_high_presets.java;
635
+ case "c":
636
+ case "h":
637
+ case "cpp":
638
+ case "c++":
639
+ case "cxx":
640
+ case "cc": return sugar_high_presets.c;
641
+ case "css":
642
+ case "scss":
643
+ case "less": return sugar_high_presets.css;
644
+ case "diff":
645
+ case "patch": return sugar_high_presets.diff;
646
+ default: return;
647
+ }
648
+ }
649
+ /**
650
+ * Agent code surface with lightweight sugar-high highlighting, elegant header,
651
+ * copy action, and collapse/expand for long sources.
652
+ */
653
+ function CodeBlock({ code, language, filename, showCopy = true, highlight: highlightEnabled = true, maxCollapsedLines = DEFAULT_COLLAPSED_LINES, maxExpandedHeight = "min(28rem, 70vh)", expanded: expandedProp, defaultExpanded = false, onExpandedChange, streamingLines = false, lineIntervalMs = 240, className, ...props }) {
654
+ const [copied, setCopied] = react.useState(false);
655
+ const [uncontrolledExpanded, setUncontrolledExpanded] = react.useState(defaultExpanded);
656
+ const expanded = expandedProp ?? uncontrolledExpanded;
657
+ const setExpanded = react.useCallback((next) => {
658
+ if (expandedProp === void 0) setUncontrolledExpanded(next);
659
+ onExpandedChange?.(next);
660
+ }, [expandedProp, onExpandedChange]);
661
+ const lines = react.useMemo(() => code.replace(/\n$/, "").split("\n"), [code]);
662
+ const lineCount = lines.length === 1 && lines[0] === "" ? 0 : lines.length;
663
+ const [visibleCount, setVisibleCount] = react.useState(streamingLines ? 0 : lines.length);
664
+ react.useEffect(() => {
665
+ if (!streamingLines) {
666
+ setVisibleCount(lines.length);
667
+ return;
668
+ }
669
+ setVisibleCount(0);
670
+ if (lines.length === 0) return;
671
+ const id = window.setInterval(() => {
672
+ setVisibleCount((count) => {
673
+ if (count >= lines.length) {
674
+ window.clearInterval(id);
675
+ return count;
676
+ }
677
+ return count + 1;
678
+ });
679
+ }, lineIntervalMs);
680
+ return () => window.clearInterval(id);
681
+ }, [
682
+ streamingLines,
683
+ lines,
684
+ lineIntervalMs,
685
+ code
686
+ ]);
687
+ const visible = streamingLines ? lines.slice(0, visibleCount).join("\n") : code;
688
+ const highlightedHtml = react.useMemo(() => {
689
+ if (!highlightEnabled || !visible) return null;
690
+ try {
691
+ return (0, sugar_high.highlight)(visible, optionsForLanguage(language));
692
+ } catch {
693
+ return null;
694
+ }
695
+ }, [
696
+ visible,
697
+ language,
698
+ highlightEnabled
699
+ ]);
700
+ const handleCopy = react.useCallback(async () => {
701
+ try {
702
+ await navigator.clipboard.writeText(code);
703
+ setCopied(true);
704
+ window.setTimeout(() => setCopied(false), 1500);
705
+ } catch {}
706
+ }, [code]);
707
+ const collapsible = maxCollapsedLines !== false && lineCount > maxCollapsedLines && !streamingLines;
708
+ const isCollapsed = collapsible && !expanded;
709
+ const hiddenLineCount = collapsible ? Math.max(0, lineCount - maxCollapsedLines) : 0;
710
+ const collapsedMaxHeight = maxCollapsedLines === false ? void 0 : PRE_PAD_Y + maxCollapsedLines * LINE_BOX_PX;
711
+ const hasHeader = Boolean(filename || language || showCopy);
712
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
713
+ "data-slot": "code-block",
714
+ "data-language": language || void 0,
715
+ "data-expanded": collapsible ? expanded : void 0,
716
+ className: require_utils.cn("overflow-hidden rounded-lg border border-border bg-muted/40 text-sm", "[--sh-class:oklch(0.48_0.12_250)] [--sh-identifier:var(--foreground)] [--sh-sign:var(--muted-foreground)]", "[--sh-property:oklch(0.48_0.11_230)] [--sh-entity:oklch(0.48_0.1_175)] [--sh-jsxliterals:oklch(0.5_0.14_290)]", "[--sh-string:oklch(0.48_0.1_160)] [--sh-keyword:oklch(0.52_0.16_25)] [--sh-comment:var(--muted-foreground)]", "[--sh-space:transparent] [--sh-break:transparent]", "dark:[--sh-class:oklch(0.78_0.1_250)] dark:[--sh-identifier:oklch(0.93_0_0)]", "dark:[--sh-sign:oklch(0.68_0.02_286)] dark:[--sh-property:oklch(0.78_0.1_230)]", "dark:[--sh-entity:oklch(0.78_0.1_175)] dark:[--sh-jsxliterals:oklch(0.8_0.12_290)]", "dark:[--sh-string:oklch(0.78_0.1_160)] dark:[--sh-keyword:oklch(0.78_0.14_25)]", "dark:[--sh-comment:oklch(0.62_0.02_286)]", className),
717
+ ...props,
718
+ children: [
719
+ hasHeader ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
720
+ "data-slot": "code-block-header",
721
+ className: "flex items-center gap-2 border-b border-border/70 bg-muted/50 px-2.5 py-1.5",
722
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
723
+ className: "flex min-w-0 flex-1 items-center gap-2",
724
+ children: [
725
+ filename ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
726
+ "data-slot": "code-block-filename",
727
+ className: "min-w-0 truncate font-mono text-[12px] text-foreground/80",
728
+ title: filename,
729
+ children: filename
730
+ }) : language ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
731
+ "data-slot": "code-block-language",
732
+ className: "min-w-0 truncate font-mono text-[12px] text-foreground/80",
733
+ children: language
734
+ }) : null,
735
+ filename && language ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
736
+ "data-slot": "code-block-language",
737
+ className: require_utils.cn("inline-flex shrink-0 items-center rounded-md px-1.5 py-0.5", "border border-border/60 bg-background/50", "font-sans text-[10px] font-medium tracking-wide text-muted-foreground uppercase"),
738
+ children: language
739
+ }) : null,
740
+ collapsible ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
741
+ "data-slot": "code-block-meta",
742
+ className: "hidden shrink-0 font-sans text-[11px] tabular-nums text-muted-foreground/70 sm:inline",
743
+ children: [lineCount, " lines"]
744
+ }) : null
745
+ ]
746
+ }), showCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
747
+ type: "button",
748
+ variant: "ghost",
749
+ size: "icon-xs",
750
+ className: "shrink-0 text-muted-foreground hover:text-foreground",
751
+ "aria-label": copied ? "Copied" : "Copy code",
752
+ onClick: handleCopy,
753
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3.5" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "size-3.5" })
754
+ }) : null]
755
+ }) : null,
756
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
757
+ "data-slot": "code-block-body",
758
+ className: "relative",
759
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
760
+ className: require_utils.cn("overflow-x-auto p-3 font-mono text-xs leading-relaxed text-foreground", "[&_.sh__line]:block", "transition-[max-height] duration-300 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none", isCollapsed && "overflow-y-hidden", !isCollapsed && maxExpandedHeight !== false && collapsible && "overflow-y-auto"),
761
+ style: isCollapsed ? { maxHeight: collapsedMaxHeight } : collapsible && maxExpandedHeight !== false ? { maxHeight: maxExpandedHeight } : void 0,
762
+ children: highlightedHtml ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { dangerouslySetInnerHTML: { __html: highlightedHtml } }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", { children: visible })
763
+ }), isCollapsed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
764
+ "aria-hidden": true,
765
+ "data-slot": "code-block-fade",
766
+ className: require_utils.cn("pointer-events-none absolute inset-x-0 bottom-0 h-16", "bg-linear-to-t from-muted/95 via-muted/55 to-transparent", "dark:from-muted/90 dark:via-muted/50")
767
+ }) : null]
768
+ }),
769
+ collapsible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
770
+ "data-slot": "code-block-footer",
771
+ className: "border-t border-border/70 bg-muted/40",
772
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
773
+ type: "button",
774
+ "data-slot": "code-block-expand",
775
+ "aria-expanded": expanded,
776
+ onClick: () => setExpanded(!expanded),
777
+ className: require_utils.cn("flex w-full items-center justify-center gap-1.5 px-3 py-2", "text-[12px] font-medium text-muted-foreground", "outline-none transition-colors duration-150", "hover:bg-muted/70 hover:text-foreground", "focus-visible:bg-muted/70 focus-visible:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset"),
778
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: expanded ? "Show less" : hiddenLineCount === 1 ? "Show 1 more line" : `Show ${hiddenLineCount} more lines` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
779
+ className: require_utils.cn("size-3.5 opacity-70 transition-transform duration-200 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none", expanded && "rotate-180"),
780
+ "aria-hidden": true
781
+ })]
782
+ })
783
+ }) : null
784
+ ]
785
+ });
786
+ }
787
+
788
+ //#endregion
789
+ //#region src/components/ai/response-stream.tsx
790
+ /**
791
+ * Progressive text reveal for demos and offline fixtures.
792
+ * Production streaming should feed tokens into Markdown/MessageContent instead.
793
+ */
794
+ function ResponseStream({ text, mode = "typewriter", speed = 2, className, markdown = false, onComplete }) {
795
+ const [cursor, setCursor] = react.useState(0);
796
+ const completeRef = react.useRef(onComplete);
797
+ completeRef.current = onComplete;
798
+ react.useEffect(() => {
799
+ setCursor(0);
800
+ }, [text]);
801
+ react.useEffect(() => {
802
+ if (cursor >= text.length) {
803
+ completeRef.current?.();
804
+ return;
805
+ }
806
+ const id = window.setTimeout(() => {
807
+ setCursor((value) => Math.min(text.length, value + Math.max(1, speed)));
808
+ }, mode === "fade" ? 16 : 18);
809
+ return () => window.clearTimeout(id);
810
+ }, [
811
+ cursor,
812
+ text,
813
+ speed,
814
+ mode
815
+ ]);
816
+ const visible = text.slice(0, cursor);
817
+ const streaming = cursor < text.length;
818
+ if (markdown) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
819
+ streaming,
820
+ className,
821
+ children: visible
822
+ });
823
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
824
+ "data-slot": "response-stream",
825
+ "data-streaming": streaming ? "true" : "false",
826
+ className: require_utils.cn("whitespace-pre-wrap text-sm leading-relaxed text-foreground", mode === "fade" && streaming && "animate-[fade-in_200ms_ease-out]", className),
827
+ children: [visible, streaming ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
828
+ "aria-hidden": true,
829
+ className: "ml-0.5 inline-block h-3.5 w-px translate-y-0.5 bg-foreground/70 animate-pulse motion-reduce:animate-none"
830
+ }) : null]
831
+ });
832
+ }
833
+
834
+ //#endregion
835
+ //#region src/components/ai/chat-container.tsx
836
+ const ChatContainerContext = react.createContext(null);
837
+ function useChatContainer() {
838
+ const context = react.useContext(ChatContainerContext);
839
+ if (!context) throw new Error("useChatContainer must be used within ChatContainer.");
840
+ return context;
841
+ }
842
+ /**
843
+ * Scroll region for chat transcripts with stick-to-bottom tracking.
844
+ * Pair with ScrollButton for jump-to-latest.
845
+ */
846
+ function ChatContainer({ className, children, bottomThreshold = 48, autoScroll = true, ...props }) {
847
+ const scrollRef = react.useRef(null);
848
+ const [isAtBottom, setIsAtBottom] = react.useState(true);
849
+ const isAtBottomRef = react.useRef(true);
850
+ const scrollToBottom = react.useCallback((behavior = "smooth") => {
851
+ const node = scrollRef.current;
852
+ if (!node) return;
853
+ node.scrollTo({
854
+ top: node.scrollHeight,
855
+ behavior
856
+ });
857
+ }, []);
858
+ const updatePinned = react.useCallback(() => {
859
+ const node = scrollRef.current;
860
+ if (!node) return;
861
+ const pinned = node.scrollHeight - node.scrollTop - node.clientHeight <= bottomThreshold;
862
+ isAtBottomRef.current = pinned;
863
+ setIsAtBottom(pinned);
864
+ }, [bottomThreshold]);
865
+ react.useEffect(() => {
866
+ const node = scrollRef.current;
867
+ if (!node) return;
868
+ updatePinned();
869
+ node.addEventListener("scroll", updatePinned, { passive: true });
870
+ const observer = new ResizeObserver(() => {
871
+ if (autoScroll && isAtBottomRef.current) node.scrollTop = node.scrollHeight;
872
+ updatePinned();
873
+ });
874
+ observer.observe(node);
875
+ if (node.firstElementChild) observer.observe(node.firstElementChild);
876
+ return () => {
877
+ node.removeEventListener("scroll", updatePinned);
878
+ observer.disconnect();
879
+ };
880
+ }, [autoScroll, updatePinned]);
881
+ react.useLayoutEffect(() => {
882
+ if (!autoScroll || !isAtBottomRef.current) return;
883
+ const node = scrollRef.current;
884
+ if (!node) return;
885
+ node.scrollTop = node.scrollHeight;
886
+ });
887
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChatContainerContext.Provider, {
888
+ value: {
889
+ scrollRef,
890
+ isAtBottom,
891
+ scrollToBottom
892
+ },
893
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
894
+ ref: scrollRef,
895
+ "data-slot": "chat-container",
896
+ "data-at-bottom": isAtBottom ? "true" : "false",
897
+ className: require_utils.cn("relative min-h-0 flex-1 overflow-y-auto overscroll-contain", className),
898
+ ...props,
899
+ children
900
+ })
901
+ });
902
+ }
903
+ function ChatContainerContent({ className, ...props }) {
904
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
905
+ "data-slot": "chat-container-content",
906
+ className: require_utils.cn("mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6", className),
907
+ ...props
908
+ });
909
+ }
910
+
911
+ //#endregion
912
+ //#region src/components/ai/scroll-button.tsx
913
+ /**
914
+ * Floating jump-to-latest control. Appears when the transcript is scrolled up.
915
+ * Must render inside ChatContainer (reads pin state via context).
916
+ *
917
+ * Visual: single soft ring + ambient shadow — not the outline Button chrome
918
+ * (which stacks border + inset pseudo and reads as a double border).
919
+ */
920
+ function ScrollButton({ className, visible, label = "Scroll to latest", onClick, type = "button", ...props }) {
921
+ const { isAtBottom, scrollToBottom } = useChatContainer();
922
+ if (!(visible ?? !isAtBottom)) return null;
923
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
924
+ type,
925
+ "aria-label": label,
926
+ "data-slot": "scroll-button",
927
+ className: require_utils.cn("absolute bottom-4 left-1/2 z-10 flex size-9 -translate-x-1/2 items-center justify-center", "rounded-full border border-border/80 bg-background/95 text-muted-foreground", "shadow-md shadow-black/10 backdrop-blur-md", "dark:border-border dark:bg-card/90 dark:shadow-black/40", "outline-none transition-[transform,background-color,color,box-shadow,border-color] duration-150 ease-out", "hover:border-border hover:bg-accent hover:text-foreground hover:shadow-lg", "focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background", "motion-safe:active:scale-[0.96]", "animate-[fade-in_150ms_ease-out] motion-reduce:animate-none", className),
928
+ onClick: (event) => {
929
+ scrollToBottom("smooth");
930
+ onClick?.(event);
931
+ },
932
+ ...props,
933
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowDown, {
934
+ className: "size-4 opacity-90",
935
+ "aria-hidden": true
936
+ })
937
+ });
938
+ }
939
+
940
+ //#endregion
941
+ //#region src/components/ai/system-message.tsx
942
+ /**
943
+ * Banner-style notice for app-injected transcript messages (errors, hints).
944
+ * Not an assistant reply — keep it visually distinct via Alert variants.
945
+ */
946
+ function SystemMessage({ className, title, variant = "info", children, ...props }) {
947
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_alert.Alert, {
948
+ "data-slot": "system-message",
949
+ variant,
950
+ className: require_utils.cn("text-left", className),
951
+ ...props,
952
+ children: [title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_alert.AlertTitle, { children: title }) : null, children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_alert.AlertDescription, { children }) : null]
953
+ });
954
+ }
955
+
956
+ //#endregion
957
+ //#region src/components/ai/format-duration.ts
958
+ /** Format elapsed ms for "Thought for …" / "Worked for …" labels. */
959
+ function formatDuration(ms) {
960
+ if (ms < 1e3) return `${Math.max(1, Math.round(ms))}ms`;
961
+ const seconds = ms / 1e3;
962
+ if (seconds < 10) return `${seconds.toFixed(1)}s`;
963
+ if (seconds < 60) return `${Math.round(seconds)}s`;
964
+ const minutes = Math.floor(seconds / 60);
965
+ const rem = Math.round(seconds % 60);
966
+ return rem === 0 ? `${minutes}m` : `${minutes}m ${rem}s`;
967
+ }
968
+
969
+ //#endregion
970
+ //#region src/components/ai/reasoning.tsx
971
+ /**
972
+ * Collapsible model reasoning / thinking block.
973
+ * Auto-opens while streaming; auto-collapses when settled unless the user toggled.
974
+ */
975
+ function Reasoning({ children, content, isStreaming = false, durationMs = null, open: openProp, onOpenChange, markdown = false, className, streamingLabel = "Thinking…", doneLabel = "Thought" }) {
976
+ const [internalOpen, setInternalOpen] = react.useState(isStreaming);
977
+ const userToggled = react.useRef(false);
978
+ const prevStreaming = react.useRef(isStreaming);
979
+ const controlled = openProp !== void 0;
980
+ const open = controlled ? openProp : internalOpen;
981
+ const setOpen = react.useCallback((next) => {
982
+ if (!controlled) setInternalOpen(next);
983
+ onOpenChange?.(next);
984
+ }, [controlled, onOpenChange]);
985
+ react.useEffect(() => {
986
+ const was = prevStreaming.current;
987
+ prevStreaming.current = isStreaming;
988
+ if (!was && isStreaming) {
989
+ userToggled.current = false;
990
+ if (!controlled) setInternalOpen(true);
991
+ onOpenChange?.(true);
992
+ } else if (was && !isStreaming && !userToggled.current) {
993
+ if (!controlled) setInternalOpen(false);
994
+ onOpenChange?.(false);
995
+ }
996
+ }, [
997
+ isStreaming,
998
+ controlled,
999
+ onOpenChange
1000
+ ]);
1001
+ const body = children ?? content ?? "";
1002
+ if ((typeof body === "string" ? body.trim().length === 0 : !body) && !isStreaming) return null;
1003
+ const duration = durationMs != null && durationMs > 0 ? formatDuration(durationMs) : null;
1004
+ const label = isStreaming ? streamingLabel : duration ? `Thought for ${duration}` : doneLabel;
1005
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1006
+ open,
1007
+ onOpenChange: (next) => {
1008
+ if (isStreaming) userToggled.current = true;
1009
+ setOpen(next);
1010
+ },
1011
+ className: require_utils.cn("w-full", className),
1012
+ "data-slot": "reasoning",
1013
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
1014
+ className: require_utils.cn("group flex w-fit max-w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-left text-[13px]", "text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),
1015
+ children: [
1016
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Brain, { className: "size-3.5 shrink-0 opacity-80" }),
1017
+ isStreaming ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
1018
+ className: "text-[13px] font-medium",
1019
+ children: label
1020
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1021
+ className: "font-medium",
1022
+ children: label
1023
+ }),
1024
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
1025
+ "data-slot": "collapsible-icon",
1026
+ className: "size-3.5 shrink-0 opacity-60 transition-transform duration-200"
1027
+ })
1028
+ ]
1029
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1030
+ innerClassName: "py-0",
1031
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1032
+ className: "my-1 ml-1.5 border-l border-border/70 py-1 pl-3",
1033
+ children: markdown && typeof body === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
1034
+ streaming: isStreaming,
1035
+ className: "text-[13px] text-muted-foreground",
1036
+ children: body
1037
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1038
+ className: "whitespace-pre-wrap text-[13px] leading-relaxed text-muted-foreground",
1039
+ children: body
1040
+ })
1041
+ })
1042
+ })]
1043
+ });
1044
+ }
1045
+ /** Compact “Thinking…” line with optional stop action (prompt-kit style). */
1046
+ function ThinkingBar({ className, text = "Thinking", onStop, stopLabel = "Answer now", onClick }) {
1047
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1048
+ "data-slot": "thinking-bar",
1049
+ className: require_utils.cn("flex w-full items-center justify-between gap-3", className),
1050
+ children: [onClick ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1051
+ type: "button",
1052
+ onClick,
1053
+ className: "flex items-center gap-1 text-sm transition-opacity duration-150 hover:opacity-80",
1054
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
1055
+ className: "font-medium",
1056
+ children: text
1057
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, { className: "size-4 -rotate-90 text-muted-foreground" })]
1058
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
1059
+ className: "cursor-default font-medium",
1060
+ children: text
1061
+ }), onStop ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1062
+ type: "button",
1063
+ onClick: onStop,
1064
+ className: "border-b border-dotted border-muted-foreground/50 text-sm text-muted-foreground transition-colors duration-150 hover:border-foreground hover:text-foreground",
1065
+ children: stopLabel
1066
+ }) : null]
1067
+ });
1068
+ }
1069
+
1070
+ //#endregion
1071
+ //#region src/components/ai/thinking-trace.tsx
1072
+ /**
1073
+ * Beautiful UI–style expandable agent trace with mode variants.
1074
+ * Production hosts pass rows + streaming; demos can drive visibleCount.
1075
+ */
1076
+ function ThinkingTrace({ mode = "steps", activeLabel, doneLabel, durationMs = null, isStreaming = false, rows, query, open: openProp, onOpenChange, className, visibleCount }) {
1077
+ const defaults = MODE_DEFAULTS[mode];
1078
+ const [internalOpen, setInternalOpen] = react.useState(isStreaming);
1079
+ const userToggled = react.useRef(false);
1080
+ const prevStreaming = react.useRef(isStreaming);
1081
+ const controlled = openProp !== void 0;
1082
+ const open = controlled ? openProp : internalOpen;
1083
+ react.useEffect(() => {
1084
+ const was = prevStreaming.current;
1085
+ prevStreaming.current = isStreaming;
1086
+ if (!was && isStreaming) {
1087
+ userToggled.current = false;
1088
+ if (!controlled) setInternalOpen(true);
1089
+ } else if (was && !isStreaming && !userToggled.current) {
1090
+ if (!controlled) setInternalOpen(false);
1091
+ }
1092
+ }, [isStreaming, controlled]);
1093
+ const setOpen = (next) => {
1094
+ if (isStreaming) userToggled.current = true;
1095
+ if (!controlled) setInternalOpen(next);
1096
+ onOpenChange?.(next);
1097
+ };
1098
+ const count = visibleCount ?? rows.length;
1099
+ const shown = rows.slice(0, Math.max(0, count));
1100
+ const duration = durationMs != null && durationMs > 0 ? formatDuration(durationMs) : null;
1101
+ const workingLabel = activeLabel ?? defaults.active;
1102
+ const settledLabel = doneLabel ?? (duration ? `${defaults.donePrefix} ${duration}` : defaults.done);
1103
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1104
+ "data-slot": "thinking-trace",
1105
+ "data-mode": mode,
1106
+ className: require_utils.cn("flex w-full flex-col", className),
1107
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1108
+ open,
1109
+ onOpenChange: setOpen,
1110
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
1111
+ className: require_utils.cn("group -mx-1.5 flex w-fit items-center gap-2 rounded-md px-1.5 py-1 text-left", "transition-colors duration-150 hover:bg-accent"),
1112
+ children: [
1113
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Sparkles, { className: require_utils.cn("size-3.5 shrink-0", isStreaming ? "text-muted-foreground" : "text-muted-foreground/70") }),
1114
+ isStreaming ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TextShimmer, {
1115
+ className: "text-[13px] font-medium whitespace-nowrap",
1116
+ children: workingLabel
1117
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1118
+ className: "text-[13px] font-medium whitespace-nowrap text-muted-foreground animate-[fade-in_350ms_ease-out_both] motion-reduce:animate-none",
1119
+ children: settledLabel
1120
+ }),
1121
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
1122
+ "data-slot": "collapsible-icon",
1123
+ className: "size-3.5 text-muted-foreground/60"
1124
+ })
1125
+ ]
1126
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1127
+ innerClassName: "py-0",
1128
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1129
+ className: "relative mt-1 ml-1.5 border-l border-border/70 pl-3",
1130
+ children: [mode === "search" && query ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1131
+ className: "mb-2 flex items-center gap-1.5 text-[12px] text-muted-foreground",
1132
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Globe, { className: "size-3 shrink-0" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1133
+ className: "truncate font-mono",
1134
+ children: query
1135
+ })]
1136
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
1137
+ className: "flex flex-col gap-1.5",
1138
+ children: shown.map((row, index) => {
1139
+ const settled = !isStreaming || index < shown.length - 1 || count >= rows.length;
1140
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
1141
+ className: "flex min-w-0 items-start gap-2 text-[13px] animate-[ai-fade-up_300ms_cubic-bezier(0.23,1,0.32,1)_both] motion-reduce:animate-none",
1142
+ style: { animationDelay: `${Math.min(index, 6) * 40}ms` },
1143
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1144
+ className: "mt-0.5 shrink-0",
1145
+ children: settled ? mode === "coding" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowIcon, {
1146
+ mono: row.mono,
1147
+ primary: row.primary
1148
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3 text-muted-foreground/70" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "size-3 animate-spin text-muted-foreground motion-reduce:animate-none" })
1149
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1150
+ className: "min-w-0 flex-1",
1151
+ children: [
1152
+ row.href ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1153
+ href: row.href,
1154
+ target: "_blank",
1155
+ rel: "noreferrer noopener",
1156
+ className: "font-medium text-foreground underline-offset-2 hover:underline",
1157
+ children: row.primary
1158
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1159
+ className: require_utils.cn("text-foreground", row.mono && "font-mono text-[12px]", mode === "reasoning" && "text-muted-foreground"),
1160
+ children: row.primary
1161
+ }),
1162
+ row.secondary ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1163
+ className: require_utils.cn("ml-1.5 text-muted-foreground", row.mono && "font-mono text-[12px]"),
1164
+ children: row.secondary
1165
+ }) : null,
1166
+ (row.add != null || row.del != null) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1167
+ className: "ml-1.5 font-mono text-[11px] tabular-nums",
1168
+ children: [row.add != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1169
+ className: "text-success",
1170
+ children: ["+", row.add]
1171
+ }) : null, row.del != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1172
+ className: "ml-1 text-destructive",
1173
+ children: ["-", row.del]
1174
+ }) : null]
1175
+ })
1176
+ ]
1177
+ })]
1178
+ }, `${row.primary}-${index}`);
1179
+ })
1180
+ })]
1181
+ })
1182
+ })]
1183
+ })
1184
+ });
1185
+ }
1186
+ function RowIcon({ mono, primary }) {
1187
+ const p = primary.toLowerCase();
1188
+ if (p.startsWith("run") || p.startsWith("bash")) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Terminal, { className: "size-3 text-muted-foreground" });
1189
+ if (p.startsWith("read") || p.startsWith("edit") || p.startsWith("write") || mono) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.FileCode2, { className: "size-3 text-muted-foreground" });
1190
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3 text-muted-foreground/70" });
1191
+ }
1192
+ const MODE_DEFAULTS = {
1193
+ steps: {
1194
+ active: "Thinking",
1195
+ done: "Thought",
1196
+ donePrefix: "Thought for"
1197
+ },
1198
+ reasoning: {
1199
+ active: "Thinking",
1200
+ done: "Thought",
1201
+ donePrefix: "Thought for"
1202
+ },
1203
+ search: {
1204
+ active: "Searching the web",
1205
+ done: "Searched the web",
1206
+ donePrefix: "Searched for"
1207
+ },
1208
+ coding: {
1209
+ active: "Running tools",
1210
+ done: "Ran tools",
1211
+ donePrefix: "Ran tools for"
1212
+ }
1213
+ };
1214
+
1215
+ //#endregion
1216
+ //#region src/components/ai/steps.tsx
1217
+ /**
1218
+ * Marker box (px). Icons are size-3.5 (14px); the box is slightly larger.
1219
+ * Odd rail keeps the 1px connector on an integer left: (RAIL - 1) / 2.
1220
+ */
1221
+ const RAIL = 15;
1222
+ /** Air between icon edge and the vertical segment (px). */
1223
+ const GAP = 6;
1224
+ const STATUS_LABEL = {
1225
+ pending: "Pending",
1226
+ running: "In progress",
1227
+ done: "Completed",
1228
+ error: "Failed"
1229
+ };
1230
+ /**
1231
+ * Quiet timeline with gapped segments (not a continuous spine through icons):
1232
+ *
1233
+ * ```
1234
+ * ✓
1235
+ * ↕ GAP
1236
+ * │ ≥ MIN_SEGMENT
1237
+ * ↕ GAP
1238
+ * ◌
1239
+ * ```
1240
+ *
1241
+ * Each step (except last) draws its own connector. The rail enforces a minimum
1242
+ * height so short title-only steps still show a readable segment.
1243
+ */
1244
+ function Steps({ children, className, open, onOpenChange, defaultOpen = true, title = "Steps" }) {
1245
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1246
+ open,
1247
+ defaultOpen,
1248
+ onOpenChange,
1249
+ className: require_utils.cn("w-full min-w-0", className),
1250
+ "data-slot": "steps",
1251
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
1252
+ className: require_utils.cn("group flex w-fit max-w-full items-center gap-1.5 rounded-md px-1.5 py-1 text-[13px]", "text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground"),
1253
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1254
+ className: "min-w-0 truncate font-medium",
1255
+ children: title
1256
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
1257
+ "data-slot": "collapsible-icon",
1258
+ className: "size-3.5 shrink-0 opacity-60"
1259
+ })]
1260
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1261
+ innerClassName: "py-1.5",
1262
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ol", {
1263
+ className: "flex min-w-0 flex-col",
1264
+ "data-slot": "steps-list",
1265
+ children
1266
+ })
1267
+ })]
1268
+ });
1269
+ }
1270
+ /**
1271
+ * Status as stroke icons only — no filled disks, no translucent glow.
1272
+ * Matches PlanTracker: Check / CircleDashed / Circle / X.
1273
+ */
1274
+ function StepMarker({ status }) {
1275
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1276
+ "data-slot": "step-marker",
1277
+ className: "relative z-10 flex shrink-0 items-center justify-center rounded-full bg-background",
1278
+ style: {
1279
+ width: RAIL,
1280
+ height: RAIL
1281
+ },
1282
+ "aria-hidden": true,
1283
+ children: status === "done" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {
1284
+ className: "size-3.5 text-success",
1285
+ strokeWidth: 2.5
1286
+ }) : status === "running" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CircleDashed, {
1287
+ className: "size-3.5 animate-spin text-primary motion-reduce:animate-none",
1288
+ strokeWidth: 2
1289
+ }) : status === "error" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
1290
+ className: "size-3.5 text-destructive",
1291
+ strokeWidth: 2.5
1292
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Circle, {
1293
+ className: "size-3.5 text-muted-foreground/40",
1294
+ strokeWidth: 1.75
1295
+ })
1296
+ });
1297
+ }
1298
+ function Step({ children, title, description, status = "pending", className }) {
1299
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
1300
+ "data-slot": "step",
1301
+ "data-status": status,
1302
+ "aria-current": status === "running" ? "step" : void 0,
1303
+ className: require_utils.cn("group/step relative flex min-w-0 items-stretch gap-2.5", className),
1304
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1305
+ "data-slot": "step-rail",
1306
+ className: "relative flex min-h-[39px] shrink-0 flex-col items-center group-last/step:min-h-[15px]",
1307
+ style: { width: RAIL },
1308
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StepMarker, { status }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1309
+ "aria-hidden": true,
1310
+ "data-slot": "step-connector",
1311
+ className: "pointer-events-none absolute w-px bg-border group-last/step:hidden",
1312
+ style: {
1313
+ left: (RAIL - 1) / 2,
1314
+ top: 21,
1315
+ bottom: GAP
1316
+ }
1317
+ })]
1318
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1319
+ className: require_utils.cn("min-w-0 flex-1 text-[13px]", "pb-3.5 group-last/step:pb-0"),
1320
+ children: [
1321
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1322
+ className: require_utils.cn("break-words font-medium", status === "running" && "text-foreground", status === "done" && "text-muted-foreground", status === "pending" && "text-muted-foreground/80", status === "error" && "text-destructive"),
1323
+ style: {
1324
+ minHeight: RAIL,
1325
+ lineHeight: `${RAIL}px`
1326
+ },
1327
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1328
+ className: "sr-only",
1329
+ children: [STATUS_LABEL[status], ": "]
1330
+ }), title]
1331
+ }),
1332
+ description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1333
+ className: "mt-1 break-words text-[12px] leading-snug text-muted-foreground",
1334
+ children: description
1335
+ }) : null,
1336
+ children ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1337
+ "data-slot": "step-body",
1338
+ className: require_utils.cn("mt-1.5 min-w-0 break-words text-[12px] leading-snug text-muted-foreground", "[&_pre]:mt-1.5 [&_pre]:max-w-full [&_pre]:overflow-x-auto [&_pre]:rounded-md [&_pre]:border [&_pre]:border-border [&_pre]:bg-muted/40 [&_pre]:p-2 [&_pre]:font-mono [&_pre]:text-[11px] [&_pre]:leading-relaxed", "[&_code]:rounded-sm [&_code]:bg-muted/50 [&_code]:px-1 [&_code]:py-px [&_code]:font-mono [&_code]:text-[11.5px]"),
1339
+ children
1340
+ }) : null
1341
+ ]
1342
+ })]
1343
+ });
1344
+ }
1345
+ /** Alias for prompt-kit chain-of-thought naming. */
1346
+ const ChainOfThought = Steps;
1347
+ const ChainOfThoughtStep = Step;
1348
+
1349
+ //#endregion
1350
+ //#region src/components/ai/types.ts
1351
+ function normalizeToolStatus(status) {
1352
+ switch (status) {
1353
+ case "input-streaming":
1354
+ case "pending": return "pending";
1355
+ case "input-available":
1356
+ case "running": return "running";
1357
+ case "output-available":
1358
+ case "success": return "success";
1359
+ case "output-error":
1360
+ case "error": return "error";
1361
+ case "aborted": return "aborted";
1362
+ default: return "pending";
1363
+ }
1364
+ }
1365
+
1366
+ //#endregion
1367
+ //#region src/components/ai/tool.tsx
1368
+ function formatValue(value) {
1369
+ if (value === null) return "null";
1370
+ if (value === void 0) return "undefined";
1371
+ if (typeof value === "string") return value;
1372
+ try {
1373
+ return JSON.stringify(value, null, 2);
1374
+ } catch {
1375
+ return String(value);
1376
+ }
1377
+ }
1378
+ function StatusIcon({ status }) {
1379
+ switch (status) {
1380
+ case "pending": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "size-3.5 animate-spin text-info motion-reduce:animate-none" });
1381
+ case "running": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Settings2, { className: "size-3.5 text-warning" });
1382
+ case "success": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CheckCircle2, { className: "size-3.5 text-success" });
1383
+ case "error": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CircleX, { className: "size-3.5 text-destructive" });
1384
+ case "aborted": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Wrench, { className: "size-3.5 text-muted-foreground" });
1385
+ }
1386
+ }
1387
+ function statusBadge(status) {
1388
+ return {
1389
+ pending: {
1390
+ label: "Queued",
1391
+ className: "bg-info/10 text-info border-info/20"
1392
+ },
1393
+ running: {
1394
+ label: "Running",
1395
+ className: "bg-warning/10 text-warning border-warning/25"
1396
+ },
1397
+ success: {
1398
+ label: "Done",
1399
+ className: "bg-success/10 text-success border-success/20"
1400
+ },
1401
+ error: {
1402
+ label: "Error",
1403
+ className: "bg-destructive/10 text-destructive border-destructive/20"
1404
+ },
1405
+ aborted: {
1406
+ label: "Stopped",
1407
+ className: "bg-muted text-muted-foreground border-border"
1408
+ }
1409
+ }[status];
1410
+ }
1411
+ /**
1412
+ * Tool call presentation in card, chip, or compact row density.
1413
+ */
1414
+ function Tool({ name, status: statusProp = "pending", summary, input, output, errorText, detail, diff, variant = "row", defaultOpen = false, open, onOpenChange, className, children }) {
1415
+ const status = normalizeToolStatus(statusProp);
1416
+ const diffs = diff ? Array.isArray(diff) ? diff : [diff] : [];
1417
+ const hasBody = Boolean(children) || Boolean(detail?.length) || input !== void 0 || output !== void 0 || Boolean(errorText) || diffs.length > 0;
1418
+ if (variant === "chip") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1419
+ "data-slot": "tool",
1420
+ "data-variant": "chip",
1421
+ "data-status": status,
1422
+ className: require_utils.cn("inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/80 bg-muted/40 px-2 py-1 text-[12px]", className),
1423
+ children: [
1424
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusIcon, { status }),
1425
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1426
+ className: "shrink-0 font-medium text-foreground",
1427
+ children: name
1428
+ }),
1429
+ summary ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1430
+ className: "min-w-0 truncate font-mono text-muted-foreground",
1431
+ children: summary
1432
+ }) : null
1433
+ ]
1434
+ });
1435
+ const trigger = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1436
+ className: require_utils.cn("flex min-w-0 max-w-full items-center gap-1.5 text-[13px] text-muted-foreground", variant === "card" && "w-full justify-between font-normal"),
1437
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1438
+ className: "flex min-w-0 items-center gap-1.5",
1439
+ children: [
1440
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusIcon, { status }),
1441
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1442
+ className: "shrink-0 font-medium text-foreground/90",
1443
+ children: name
1444
+ }),
1445
+ summary ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1446
+ className: require_utils.cn("min-w-0 truncate rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground"),
1447
+ children: summary
1448
+ }) : null,
1449
+ variant === "card" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1450
+ className: require_utils.cn("rounded-full border px-2 py-0.5 text-[11px] font-medium", statusBadge(status).className),
1451
+ children: statusBadge(status).label
1452
+ }) : null
1453
+ ]
1454
+ }), hasBody ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
1455
+ "data-slot": "collapsible-icon",
1456
+ className: "size-3.5 shrink-0 opacity-0 transition-[opacity,transform] duration-150 group-hover/tool:opacity-100 group-data-[panel-open]/collapsible:opacity-100"
1457
+ }) : null]
1458
+ });
1459
+ if (!hasBody) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1460
+ "data-slot": "tool",
1461
+ "data-variant": variant,
1462
+ "data-status": status,
1463
+ className: require_utils.cn("flex w-full items-center py-0.5 text-left", className),
1464
+ children: trigger
1465
+ });
1466
+ const body = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1467
+ className: "space-y-2 text-[12.5px]",
1468
+ children: [
1469
+ children,
1470
+ detail?.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1471
+ className: require_utils.cn("font-mono leading-relaxed text-muted-foreground", line.tone === "add" && "text-success"),
1472
+ children: line.text
1473
+ }, i)),
1474
+ input !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
1475
+ className: "mb-1 text-xs font-medium text-muted-foreground",
1476
+ children: "Input"
1477
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1478
+ className: "max-h-40 overflow-auto rounded-md border border-border bg-background p-2 font-mono text-[11.5px] leading-relaxed",
1479
+ children: formatValue(input)
1480
+ })] }) : null,
1481
+ output !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h4", {
1482
+ className: "mb-1 text-xs font-medium text-muted-foreground",
1483
+ children: "Output"
1484
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1485
+ className: "max-h-48 overflow-auto rounded-md border border-border bg-background p-2 font-mono text-[11.5px] leading-relaxed",
1486
+ children: formatValue(output)
1487
+ })] }) : null,
1488
+ errorText ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
1489
+ className: "rounded-md border border-destructive/30 bg-destructive/8 p-2 text-destructive",
1490
+ children: errorText
1491
+ }) : null,
1492
+ diffs.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1493
+ className: "flex flex-wrap gap-1.5 pt-0.5",
1494
+ children: diffs.map((d) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1495
+ className: "inline-flex items-center gap-1.5 rounded-md border border-border bg-muted/50 px-1.5 py-0.5 font-mono text-[11px]",
1496
+ children: [
1497
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1498
+ className: "text-foreground",
1499
+ children: d.file
1500
+ }),
1501
+ d.add != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1502
+ className: "text-success",
1503
+ children: ["+", d.add]
1504
+ }) : null,
1505
+ d.del != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1506
+ className: "text-destructive",
1507
+ children: ["-", d.del]
1508
+ }) : null
1509
+ ]
1510
+ }, d.file))
1511
+ }) : null
1512
+ ]
1513
+ });
1514
+ if (variant === "card") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1515
+ "data-slot": "tool",
1516
+ "data-variant": "card",
1517
+ "data-status": status,
1518
+ className: require_utils.cn("overflow-hidden rounded-lg border border-border", className),
1519
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1520
+ open,
1521
+ defaultOpen,
1522
+ onOpenChange,
1523
+ className: "group/tool group/collapsible",
1524
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleTrigger, {
1525
+ className: "w-full bg-background px-3 py-2 hover:bg-accent/40",
1526
+ children: trigger
1527
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1528
+ className: "border-t border-border",
1529
+ innerClassName: "px-3 py-2",
1530
+ children: body
1531
+ })]
1532
+ })
1533
+ });
1534
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1535
+ "data-slot": "tool",
1536
+ "data-variant": "row",
1537
+ "data-status": status,
1538
+ className: require_utils.cn("flex flex-col", className),
1539
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1540
+ open,
1541
+ defaultOpen,
1542
+ onOpenChange,
1543
+ className: "group/tool group/collapsible",
1544
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleTrigger, {
1545
+ className: require_utils.cn("group/row -mx-1 flex min-h-8 w-[calc(100%+0.5rem)] min-w-0 items-center gap-2 rounded-md px-1 py-1 text-left", "transition-colors duration-150 hover:bg-accent", "pointer-coarse:min-h-11"),
1546
+ children: trigger
1547
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1548
+ innerClassName: "py-1 pl-5",
1549
+ children: body
1550
+ })]
1551
+ })
1552
+ });
1553
+ }
1554
+ function ToolGroup({ label, children, defaultOpen = true, className }) {
1555
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1556
+ "data-slot": "tool-group",
1557
+ className: require_utils.cn("w-full max-w-md", className),
1558
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
1559
+ defaultOpen,
1560
+ className: "group/collapsible",
1561
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
1562
+ className: require_utils.cn("-mx-1.5 flex w-fit items-center gap-1.5 rounded-md px-1.5 py-1 text-[12.5px]", "text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground"),
1563
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
1564
+ "data-slot": "collapsible-icon",
1565
+ className: "size-3"
1566
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1567
+ className: "tabular-nums",
1568
+ children: label
1569
+ })]
1570
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
1571
+ innerClassName: "py-1",
1572
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1573
+ className: "mt-0.5 flex flex-col gap-1",
1574
+ children
1575
+ })
1576
+ })]
1577
+ })
1578
+ });
1579
+ }
1580
+
1581
+ //#endregion
1582
+ //#region src/components/ai/approval-card.tsx
1583
+ /**
1584
+ * Human-in-the-loop approval: simple confirm/skip or multi-question flow.
1585
+ */
1586
+ function ApprovalCard({ title, description, questions, confirmLabel = "Confirm", skipLabel = "Skip", destructive = false, preview, onConfirm, onSkip, onDismiss, className, defaultSent = false }) {
1587
+ const multi = Boolean(questions?.length);
1588
+ const [qi, setQi] = react.useState(0);
1589
+ const [answers, setAnswers] = react.useState({});
1590
+ const [sent, setSent] = react.useState(defaultSent);
1591
+ const question = multi ? questions[qi] : null;
1592
+ const selected = question ? answers[question.id] ?? [] : [];
1593
+ const last = multi ? qi === questions.length - 1 : true;
1594
+ const toggleOption = (optionId) => {
1595
+ if (!question) return;
1596
+ const type = question.type ?? "single";
1597
+ setAnswers((prev) => {
1598
+ const current = prev[question.id] ?? [];
1599
+ const next = type === "single" ? [optionId] : current.includes(optionId) ? current.filter((id) => id !== optionId) : [...current, optionId];
1600
+ return {
1601
+ ...prev,
1602
+ [question.id]: next
1603
+ };
1604
+ });
1605
+ if ((question.type ?? "single") === "single") window.setTimeout(() => {
1606
+ if (last) {
1607
+ setSent(true);
1608
+ onConfirm?.({ answers: {
1609
+ ...answers,
1610
+ [question.id]: [optionId]
1611
+ } });
1612
+ } else setQi((i) => i + 1);
1613
+ }, 280);
1614
+ };
1615
+ const submitMulti = () => {
1616
+ if (!question) return;
1617
+ if (last) {
1618
+ setSent(true);
1619
+ onConfirm?.({ answers });
1620
+ } else setQi((i) => i + 1);
1621
+ };
1622
+ if (sent) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1623
+ "data-slot": "approval-card",
1624
+ className: require_utils.cn("flex min-h-28 w-full max-w-sm flex-col items-center justify-center gap-2 rounded-xl border border-border bg-card p-4 shadow-xs", className),
1625
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1626
+ className: "flex size-6 items-center justify-center rounded-full bg-success text-white animate-[ai-fade-up_300ms_cubic-bezier(0.23,1,0.32,1)_both]",
1627
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {
1628
+ className: "size-3.5",
1629
+ strokeWidth: 3
1630
+ })
1631
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1632
+ className: "text-[13px] font-medium text-foreground",
1633
+ children: "Approved"
1634
+ })]
1635
+ });
1636
+ if (!multi) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1637
+ "data-slot": "approval-card",
1638
+ "data-destructive": destructive ? "true" : "false",
1639
+ className: require_utils.cn("w-full max-w-md overflow-hidden rounded-xl border bg-card shadow-xs", destructive ? "border-destructive/35" : "border-border", className),
1640
+ children: [
1641
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1642
+ className: "flex items-start justify-between gap-2 px-3 pt-3",
1643
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1644
+ className: "min-w-0 space-y-1",
1645
+ children: [title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1646
+ className: "text-[13px] font-medium text-pretty text-foreground",
1647
+ children: title
1648
+ }) : null, description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1649
+ className: "text-xs text-pretty text-muted-foreground",
1650
+ children: description
1651
+ }) : null]
1652
+ }), onDismiss ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1653
+ type: "button",
1654
+ variant: "ghost",
1655
+ size: "icon-xs",
1656
+ "aria-label": "Dismiss",
1657
+ onClick: onDismiss,
1658
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "size-3.5" })
1659
+ }) : null]
1660
+ }),
1661
+ preview ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1662
+ className: "px-3 pt-2",
1663
+ children: preview
1664
+ }) : null,
1665
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1666
+ className: "flex items-center justify-end gap-1.5 px-3 py-2.5",
1667
+ children: [onSkip ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1668
+ type: "button",
1669
+ variant: "ghost",
1670
+ size: "sm",
1671
+ onClick: onSkip,
1672
+ children: skipLabel
1673
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1674
+ type: "button",
1675
+ size: "sm",
1676
+ variant: destructive ? "destructive" : "default",
1677
+ onClick: () => {
1678
+ setSent(true);
1679
+ onConfirm?.({});
1680
+ },
1681
+ children: confirmLabel
1682
+ })]
1683
+ })
1684
+ ]
1685
+ });
1686
+ const progress = questions.map((_, i) => i <= qi);
1687
+ const canAdvance = selected.length > 0;
1688
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1689
+ "data-slot": "approval-card",
1690
+ className: require_utils.cn("w-full max-w-sm overflow-hidden rounded-xl border border-border bg-card shadow-xs", className),
1691
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1692
+ className: "p-3 animate-[ai-fade-up_300ms_cubic-bezier(0.23,1,0.32,1)_both] motion-reduce:animate-none",
1693
+ children: [
1694
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1695
+ className: "flex items-start justify-between gap-2",
1696
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1697
+ className: "text-[13px] font-medium text-pretty text-foreground",
1698
+ children: question.prompt
1699
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1700
+ className: "flex items-center gap-1",
1701
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1702
+ className: "flex items-center gap-0.5",
1703
+ "aria-hidden": true,
1704
+ children: progress.map((on, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: require_utils.cn("h-1 rounded-full transition-[width,background-color] duration-200", on ? "w-3 bg-primary" : "w-1.5 bg-border") }, i))
1705
+ }), onDismiss ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1706
+ type: "button",
1707
+ variant: "ghost",
1708
+ size: "icon-xs",
1709
+ "aria-label": "Dismiss",
1710
+ onClick: onDismiss,
1711
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "size-3.5" })
1712
+ }) : null]
1713
+ })]
1714
+ }),
1715
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1716
+ className: "mt-2 flex flex-col gap-0.5",
1717
+ children: question.options.map((option) => {
1718
+ const on = selected.includes(option.id);
1719
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1720
+ type: "button",
1721
+ "aria-pressed": on,
1722
+ onClick: () => toggleOption(option.id),
1723
+ className: require_utils.cn("-mx-1.5 flex min-h-10 items-start gap-2 rounded-md px-1.5 py-1.5 text-left text-[13px]", "transition-colors duration-150 hover:bg-accent", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", on && "bg-accent"),
1724
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1725
+ className: require_utils.cn("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border", on ? "border-primary bg-primary text-primary-foreground" : "border-border"),
1726
+ children: on ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {
1727
+ className: "size-2.5",
1728
+ strokeWidth: 3
1729
+ }) : null
1730
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1731
+ className: "min-w-0",
1732
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1733
+ className: "font-medium text-foreground",
1734
+ children: option.label
1735
+ }), option.description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1736
+ className: "mt-0.5 block text-xs text-muted-foreground",
1737
+ children: option.description
1738
+ }) : null]
1739
+ })]
1740
+ }, option.id);
1741
+ })
1742
+ }),
1743
+ (question.type === "multiple" || !last) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1744
+ className: "mt-2 flex justify-end",
1745
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1746
+ type: "button",
1747
+ size: "icon-sm",
1748
+ "aria-label": last ? confirmLabel : "Next",
1749
+ disabled: !canAdvance,
1750
+ onClick: submitMulti,
1751
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ArrowUp, { className: "size-4" })
1752
+ })
1753
+ })
1754
+ ]
1755
+ }, question.id)
1756
+ });
1757
+ }
1758
+
1759
+ //#endregion
1760
+ //#region src/components/ai/source.tsx
1761
+ function Source({ href, title, description, favicon, domain, className }) {
1762
+ const host = domain ?? (href ? safeHost(href) : void 0);
1763
+ const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1764
+ "data-slot": "source",
1765
+ className: require_utils.cn("inline-flex max-w-full items-center gap-1.5 rounded-full border border-border bg-muted/50 px-2 py-0.5 text-[12px]", "text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground", className),
1766
+ children: [
1767
+ favicon ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
1768
+ src: favicon,
1769
+ alt: "",
1770
+ className: "size-3.5 rounded-sm outline outline-1 outline-black/10 dark:outline-white/10"
1771
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.FileText, { className: "size-3 shrink-0 opacity-70" }),
1772
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1773
+ className: "min-w-0 truncate font-medium",
1774
+ children: host ?? title
1775
+ }),
1776
+ href ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ExternalLink, { className: "size-3 shrink-0 opacity-50" }) : null
1777
+ ]
1778
+ });
1779
+ const chip = href ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
1780
+ href,
1781
+ target: "_blank",
1782
+ rel: "noreferrer noopener",
1783
+ className: "inline-flex max-w-full",
1784
+ children: content
1785
+ }) : content;
1786
+ if (!description && title === host) return chip;
1787
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_tooltip.Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipTrigger, {
1788
+ asChild: true,
1789
+ children: chip
1790
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipContent, {
1791
+ side: "top",
1792
+ className: "max-w-xs",
1793
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1794
+ className: "space-y-0.5",
1795
+ children: [
1796
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1797
+ className: "font-medium",
1798
+ children: title
1799
+ }),
1800
+ description ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1801
+ className: "text-xs opacity-90",
1802
+ children: description
1803
+ }) : null,
1804
+ href ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1805
+ className: "truncate font-mono text-[10px] opacity-70",
1806
+ children: href
1807
+ }) : null
1808
+ ]
1809
+ })
1810
+ })] });
1811
+ }
1812
+ function Sources({ children, className, label }) {
1813
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1814
+ "data-slot": "sources",
1815
+ className: require_utils.cn("flex flex-col gap-1.5", className),
1816
+ children: [label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1817
+ className: "text-[11px] font-medium text-muted-foreground",
1818
+ children: label
1819
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1820
+ className: "flex flex-wrap gap-1.5",
1821
+ children
1822
+ })]
1823
+ });
1824
+ }
1825
+ function safeHost(url) {
1826
+ try {
1827
+ return new URL(url).hostname.replace(/^www\./, "");
1828
+ } catch {
1829
+ return;
1830
+ }
1831
+ }
1832
+
1833
+ //#endregion
1834
+ //#region src/components/ai/inline-diff.tsx
1835
+ /** Naive line diff for presentation (not a full Myers algorithm). */
1836
+ function lineDiff(before, after) {
1837
+ const a = before.split("\n");
1838
+ const b = after.split("\n");
1839
+ const aSet = new Set(a);
1840
+ const bSet = new Set(b);
1841
+ const lines = [];
1842
+ for (const line of a) if (!bSet.has(line)) lines.push({
1843
+ type: "del",
1844
+ text: line
1845
+ });
1846
+ for (const line of b) if (!aSet.has(line)) lines.push({
1847
+ type: "add",
1848
+ text: line
1849
+ });
1850
+ else if (!lines.some((l) => l.type === "context" && l.text === line)) {}
1851
+ if (lines.length === 0 && before !== after) return [...a.map((text) => ({
1852
+ type: "del",
1853
+ text
1854
+ })), ...b.map((text) => ({
1855
+ type: "add",
1856
+ text
1857
+ }))];
1858
+ const dels = a.filter((line) => !bSet.has(line)).map((text) => ({
1859
+ type: "del",
1860
+ text
1861
+ }));
1862
+ const adds = b.filter((line) => !aSet.has(line)).map((text) => ({
1863
+ type: "add",
1864
+ text
1865
+ }));
1866
+ const shared = b.filter((line) => aSet.has(line)).map((text) => ({
1867
+ type: "context",
1868
+ text
1869
+ }));
1870
+ if (shared.length > 6) return [...dels, ...adds];
1871
+ return [
1872
+ ...shared.slice(0, 2),
1873
+ ...dels,
1874
+ ...adds,
1875
+ ...shared.slice(2)
1876
+ ];
1877
+ }
1878
+ function InlineDiff({ source, className, maxLines = 40 }) {
1879
+ const lines = react.useMemo(() => lineDiff(source.before, source.after), [source.before, source.after]);
1880
+ const visible = lines.slice(0, maxLines);
1881
+ const hidden = lines.length - visible.length;
1882
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1883
+ "data-slot": "inline-diff",
1884
+ className: require_utils.cn("overflow-hidden rounded-lg border border-border bg-muted/30 font-mono text-[11.5px] leading-relaxed", className),
1885
+ children: [
1886
+ source.fileName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1887
+ className: "border-b border-border/80 bg-muted/50 px-2.5 py-1 text-xs text-muted-foreground",
1888
+ children: source.fileName
1889
+ }) : null,
1890
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("pre", {
1891
+ className: "overflow-x-auto p-0",
1892
+ children: visible.map((line, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1893
+ className: require_utils.cn("flex gap-2 px-2.5 py-0.5", line.type === "add" && "bg-success/10 text-success", line.type === "del" && "bg-destructive/10 text-destructive", line.type === "context" && "text-muted-foreground"),
1894
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1895
+ className: "w-3 shrink-0 select-none opacity-70",
1896
+ children: line.type === "add" ? "+" : line.type === "del" ? "-" : " "
1897
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1898
+ className: "min-w-0 whitespace-pre-wrap break-all",
1899
+ children: line.text || " "
1900
+ })]
1901
+ }, i))
1902
+ }),
1903
+ hidden > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1904
+ className: "border-t border-border/60 px-2.5 py-1 text-[11px] text-muted-foreground",
1905
+ children: [
1906
+ "+",
1907
+ hidden,
1908
+ " more lines"
1909
+ ]
1910
+ }) : null
1911
+ ]
1912
+ });
1913
+ }
1914
+
1915
+ //#endregion
1916
+ //#region src/components/ai/feedback-bar.tsx
1917
+ /**
1918
+ * Message action row: copy, regenerate, thumbs.
1919
+ */
1920
+ function FeedbackBar({ className, onCopy, onRegenerate, onFeedback, copyText, showCopy = true, showRegenerate = true, showFeedback = true }) {
1921
+ const [copied, setCopied] = react.useState(false);
1922
+ const [feedback, setFeedback] = react.useState(null);
1923
+ const handleCopy = async () => {
1924
+ try {
1925
+ if (copyText) await navigator.clipboard.writeText(copyText);
1926
+ await onCopy?.();
1927
+ setCopied(true);
1928
+ window.setTimeout(() => setCopied(false), 1500);
1929
+ } catch {}
1930
+ };
1931
+ const setFb = (value) => {
1932
+ const next = feedback === value ? null : value;
1933
+ setFeedback(next);
1934
+ onFeedback?.(next);
1935
+ };
1936
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1937
+ "data-slot": "feedback-bar",
1938
+ className: require_utils.cn("flex items-center gap-0.5 text-muted-foreground", className),
1939
+ children: [
1940
+ showCopy ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
1941
+ tip: copied ? "Copied" : "Copy",
1942
+ onClick: handleCopy,
1943
+ label: copied ? "Copied" : "Copy",
1944
+ children: copied ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3.5" }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Copy, { className: "size-3.5" })
1945
+ }) : null,
1946
+ showRegenerate && onRegenerate ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
1947
+ tip: "Regenerate",
1948
+ onClick: onRegenerate,
1949
+ label: "Regenerate",
1950
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RefreshCw, { className: "size-3.5" })
1951
+ }) : null,
1952
+ showFeedback ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
1953
+ tip: "Good response",
1954
+ onClick: () => setFb("up"),
1955
+ label: "Good response",
1956
+ active: feedback === "up",
1957
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsUp, { className: "size-3.5" })
1958
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Action, {
1959
+ tip: "Bad response",
1960
+ onClick: () => setFb("down"),
1961
+ label: "Bad response",
1962
+ active: feedback === "down",
1963
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ThumbsDown, { className: "size-3.5" })
1964
+ })] }) : null
1965
+ ]
1966
+ }) });
1967
+ }
1968
+ function Action({ tip, children, onClick, label, active }) {
1969
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_tooltip.Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipTrigger, {
1970
+ asChild: true,
1971
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
1972
+ type: "button",
1973
+ variant: "ghost",
1974
+ size: "icon-xs",
1975
+ "aria-label": label,
1976
+ "aria-pressed": active,
1977
+ onClick,
1978
+ className: require_utils.cn(active && "bg-accent text-foreground"),
1979
+ children
1980
+ })
1981
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipContent, {
1982
+ side: "bottom",
1983
+ children: tip
1984
+ })] });
1985
+ }
1986
+
1987
+ //#endregion
1988
+ //#region src/components/ai/prompt-suggestion.tsx
1989
+ function PromptSuggestion({ children, onClick, className }) {
1990
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1991
+ type: "button",
1992
+ "data-slot": "prompt-suggestion",
1993
+ onClick,
1994
+ className: require_utils.cn("inline-flex max-w-full items-center rounded-full border border-border bg-background px-3 py-1.5", "text-left text-[13px] text-foreground shadow-xs", "transition-[background-color,box-shadow,transform] duration-150 ease-out", "hover:bg-accent hover:shadow-sm", "motion-safe:active:scale-[0.98]", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", className),
1995
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1996
+ className: "min-w-0 truncate",
1997
+ children
1998
+ })
1999
+ });
2000
+ }
2001
+ function PromptSuggestions({ children, className, label = "Follow-ups" }) {
2002
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2003
+ "data-slot": "prompt-suggestions",
2004
+ className: require_utils.cn("flex flex-col gap-2", className),
2005
+ children: [label ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2006
+ className: "text-[12px] font-medium text-muted-foreground",
2007
+ children: label
2008
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2009
+ className: "flex flex-wrap gap-1.5",
2010
+ children
2011
+ })]
2012
+ });
2013
+ }
2014
+
2015
+ //#endregion
2016
+ //#region src/components/ai/streaming-text.tsx
2017
+ /**
2018
+ * Streamed answer with blur-resolve words, citation chips, actions, follow-ups.
2019
+ * For production, drive `streaming` + full `text` from the host; the interval
2020
+ * path is for demos when tokens arrive as a finished string.
2021
+ */
2022
+ function StreamingText({ text = "", tokens, sources = [], followUps = [], onFollowUp, streaming = true, wordIntervalMs = 48, showActions = true, onCopy, className }) {
2023
+ const words = react.useMemo(() => {
2024
+ if (tokens) return null;
2025
+ return text.split(/(\s+)/).filter(Boolean);
2026
+ }, [text, tokens]);
2027
+ const total = tokens?.length ?? words?.length ?? 0;
2028
+ const [visible, setVisible] = react.useState(streaming ? 0 : Number.MAX_SAFE_INTEGER);
2029
+ react.useEffect(() => {
2030
+ if (!streaming) {
2031
+ setVisible(Number.MAX_SAFE_INTEGER);
2032
+ return;
2033
+ }
2034
+ setVisible(0);
2035
+ if (total === 0) return;
2036
+ const id = window.setInterval(() => {
2037
+ setVisible((v) => {
2038
+ if (v >= total) {
2039
+ window.clearInterval(id);
2040
+ return v;
2041
+ }
2042
+ return v + 1;
2043
+ });
2044
+ }, wordIntervalMs);
2045
+ return () => window.clearInterval(id);
2046
+ }, [
2047
+ streaming,
2048
+ tokens,
2049
+ words,
2050
+ wordIntervalMs,
2051
+ text,
2052
+ total
2053
+ ]);
2054
+ const done = !streaming || visible >= total;
2055
+ /** Blur only the newest token while still revealing — not after the run settles. */
2056
+ const revealing = streaming && visible < total;
2057
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2058
+ "data-slot": "streaming-text",
2059
+ className: require_utils.cn("flex w-full flex-col gap-3", className),
2060
+ children: [
2061
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2062
+ className: "text-[13px] leading-relaxed text-pretty text-foreground",
2063
+ children: tokens ? tokens.slice(0, visible).map((tok, i) => {
2064
+ if (tok.type === "cite") {
2065
+ const src = sources.find((s) => s.id === tok.id);
2066
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("sup", {
2067
+ className: "mx-0.5",
2068
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Source, {
2069
+ title: src?.title ?? tok.id,
2070
+ href: src?.href,
2071
+ description: src?.description,
2072
+ className: "align-super text-[10px]"
2073
+ })
2074
+ }, i);
2075
+ }
2076
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2077
+ className: require_utils.cn("transition-[filter,opacity] duration-200 ease-out motion-reduce:transition-none", i === visible - 1 && revealing ? "opacity-90 blur-[2px] motion-reduce:blur-0" : "opacity-100 blur-0"),
2078
+ children: tok.text
2079
+ }, i);
2080
+ }) : words?.slice(0, visible).map((w, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2081
+ className: require_utils.cn("transition-[filter,opacity] duration-200 ease-out motion-reduce:transition-none", i === visible - 1 && revealing && !/^\s+$/.test(w) ? "opacity-90 blur-[2px] motion-reduce:blur-0" : "opacity-100 blur-0"),
2082
+ children: w
2083
+ }, i))
2084
+ }),
2085
+ sources.length > 0 && done ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Sources, {
2086
+ label: `${sources.length} sources`,
2087
+ children: sources.map((s) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Source, {
2088
+ title: s.title,
2089
+ href: s.href,
2090
+ description: s.description
2091
+ }, s.id))
2092
+ }) : null,
2093
+ showActions && done ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FeedbackBar, {
2094
+ copyText: text,
2095
+ onCopy,
2096
+ showRegenerate: false
2097
+ }) : null,
2098
+ followUps.length > 0 && done ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromptSuggestions, { children: followUps.map((f) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PromptSuggestion, {
2099
+ onClick: () => onFollowUp?.(f),
2100
+ children: f
2101
+ }, f)) }) : null
2102
+ ]
2103
+ });
2104
+ }
2105
+
2106
+ //#endregion
2107
+ //#region src/components/ai/diff-table.tsx
2108
+ /**
2109
+ * Table of proposed AI edits: removed rows tint destructive, added rows tint success.
2110
+ */
2111
+ function DiffTable({ title = "Proposed changes", columns, rows, addedRows = [], animate = false, className }) {
2112
+ const [stage, setStage] = react.useState(animate ? 0 : 2);
2113
+ react.useEffect(() => {
2114
+ if (!animate) {
2115
+ setStage(2);
2116
+ return;
2117
+ }
2118
+ setStage(0);
2119
+ const t1 = window.setTimeout(() => setStage(1), 500);
2120
+ const t2 = window.setTimeout(() => setStage(2), 1100);
2121
+ return () => {
2122
+ window.clearTimeout(t1);
2123
+ window.clearTimeout(t2);
2124
+ };
2125
+ }, [
2126
+ animate,
2127
+ rows,
2128
+ addedRows
2129
+ ]);
2130
+ const showRemovedTint = stage >= 1;
2131
+ const showAdded = stage >= 2 && addedRows.length > 0;
2132
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2133
+ "data-slot": "diff-table",
2134
+ className: require_utils.cn("w-full overflow-hidden rounded-xl border border-border bg-card shadow-xs", className),
2135
+ children: [title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2136
+ className: "flex items-center justify-between border-b border-border px-3 py-2",
2137
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2138
+ className: "text-[12.5px] font-medium text-foreground",
2139
+ children: title
2140
+ })
2141
+ }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2142
+ className: "overflow-x-auto",
2143
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
2144
+ className: "w-full border-collapse text-left text-[13px]",
2145
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
2146
+ className: "border-b border-border",
2147
+ children: columns.map((col) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
2148
+ scope: "col",
2149
+ className: require_utils.cn("px-3 py-2 text-[12px] font-medium text-muted-foreground", col.className),
2150
+ children: col.header
2151
+ }, col.id))
2152
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tbody", { children: [rows.map((row) => {
2153
+ const out = Boolean(row.removed && showRemovedTint);
2154
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
2155
+ "data-removed": out ? "true" : void 0,
2156
+ className: require_utils.cn("border-b border-border last:border-0", "transition-colors duration-200 ease-out motion-reduce:transition-none", out && "bg-destructive/8"),
2157
+ children: columns.map((col, colIndex) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2158
+ className: require_utils.cn("px-3 py-2 align-middle transition-colors duration-200 motion-reduce:transition-none", out && "text-destructive", out && colIndex > 0 && "line-through decoration-destructive/50", !out && colIndex === 0 && "font-medium text-foreground", !out && colIndex > 0 && "text-muted-foreground", col.className),
2159
+ children: col.cell(row)
2160
+ }, col.id))
2161
+ }, row.id);
2162
+ }), addedRows.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tr", {
2163
+ className: "border-0",
2164
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
2165
+ colSpan: columns.length,
2166
+ className: "p-0",
2167
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2168
+ className: require_utils.cn("grid transition-[grid-template-rows,opacity] duration-300 ease-out motion-reduce:transition-none", showAdded ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"),
2169
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2170
+ className: "overflow-hidden bg-success/8",
2171
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2172
+ className: "grid items-center border-t border-border",
2173
+ style: { gridTemplateColumns: `repeat(${columns.length}, minmax(0, 1fr))` },
2174
+ children: row.cells.map((cell, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2175
+ className: require_utils.cn("px-3 py-2 text-success", i === 0 && "font-medium"),
2176
+ children: cell
2177
+ }, i))
2178
+ })
2179
+ })
2180
+ })
2181
+ })
2182
+ }, row.id))] })]
2183
+ })
2184
+ })]
2185
+ });
2186
+ }
2187
+
2188
+ //#endregion
2189
+ //#region src/components/ai/plan-tracker.tsx
2190
+ /**
2191
+ * Live agent plan checklist, typically pinned above the composer.
2192
+ */
2193
+ function PlanTracker({ plan, streaming = false, className, flushBottom = true, defaultOpen = false, open, onOpenChange }) {
2194
+ if (!plan || plan.steps.length === 0) return null;
2195
+ const total = plan.steps.length;
2196
+ const done = plan.steps.filter((s) => s.status === "done").length;
2197
+ const complete = done === total;
2198
+ const activeIndex = plan.steps.findIndex((s) => s.status === "in_progress");
2199
+ const focusIndex = activeIndex >= 0 ? activeIndex : streaming ? plan.steps.findIndex((s) => s.status === "pending") : -1;
2200
+ const focusStep = focusIndex >= 0 ? plan.steps[focusIndex] : null;
2201
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2202
+ "data-slot": "plan-tracker",
2203
+ className: require_utils.cn("w-full", className),
2204
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.Collapsible, {
2205
+ open,
2206
+ defaultOpen,
2207
+ onOpenChange,
2208
+ className: "group/collapsible",
2209
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2210
+ className: require_utils.cn("border border-input bg-muted/40", flushBottom ? "rounded-t-xl border-b-0" : "rounded-xl"),
2211
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
2212
+ className: require_utils.cn("group flex w-full items-center gap-1.5 px-3 py-2 text-left text-[13px]", "text-muted-foreground transition-colors duration-150 hover:text-foreground"),
2213
+ children: [
2214
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ListChecks, { className: "size-3.5 shrink-0" }),
2215
+ complete ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2216
+ className: "min-w-0 flex-1 truncate font-medium",
2217
+ children: `${total}/${total} done`
2218
+ }) : focusStep ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2219
+ className: "min-w-0 flex-1 truncate font-medium",
2220
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2221
+ className: "mr-1.5 font-mono text-[12px] font-normal tabular-nums text-muted-foreground/60",
2222
+ children: [
2223
+ focusIndex + 1,
2224
+ "/",
2225
+ total
2226
+ ]
2227
+ }), focusStep.label]
2228
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2229
+ className: "min-w-0 flex-1 truncate font-medium",
2230
+ children: `${done}/${total} steps`
2231
+ }),
2232
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
2233
+ "data-slot": "collapsible-icon",
2234
+ className: "size-3.5 shrink-0 text-muted-foreground/60"
2235
+ })
2236
+ ]
2237
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
2238
+ innerClassName: "py-0",
2239
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2240
+ className: "max-h-48 overflow-y-auto px-2 pb-1",
2241
+ children: plan.steps.map((step, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PlanRow, { step }, `${step.label}-${i}`))
2242
+ })
2243
+ })]
2244
+ })
2245
+ })
2246
+ });
2247
+ }
2248
+ function PlanRow({ step }) {
2249
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2250
+ className: "flex items-center gap-2 rounded-md px-1.5 py-1 text-[13px]",
2251
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StepIcon, { status: step.status }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2252
+ className: require_utils.cn("min-w-0 flex-1 truncate", step.status === "done" ? "text-muted-foreground line-through" : "text-foreground"),
2253
+ children: step.label
2254
+ })]
2255
+ });
2256
+ }
2257
+ function StepIcon({ status }) {
2258
+ if (status === "done") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, { className: "size-3.5 shrink-0 text-success" });
2259
+ if (status === "in_progress") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.CircleDashed, { className: "size-3.5 shrink-0 text-foreground/70" });
2260
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Circle, { className: "size-3.5 shrink-0 text-muted-foreground/40" });
2261
+ }
2262
+
2263
+ //#endregion
2264
+ //#region src/components/ai/context-ring.tsx
2265
+ function formatCompact(n) {
2266
+ if (n >= 1e6) {
2267
+ const m = n / 1e6;
2268
+ return `${Number.isInteger(m) ? m : m.toFixed(m < 10 ? 2 : 1)}M`;
2269
+ }
2270
+ if (n >= 1e3) {
2271
+ const k = n / 1e3;
2272
+ return `${Number.isInteger(k) ? k : k.toFixed(k < 10 ? 1 : 0)}K`;
2273
+ }
2274
+ return String(n);
2275
+ }
2276
+ function meterTone(pct, recomputing, hasUsage) {
2277
+ if (!hasUsage) return "idle";
2278
+ if (recomputing) return "recomputing";
2279
+ if (pct >= 95) return "critical";
2280
+ if (pct >= 80) return "warn";
2281
+ return "ok";
2282
+ }
2283
+ function toneStroke(tone) {
2284
+ switch (tone) {
2285
+ case "critical": return "var(--destructive)";
2286
+ case "warn": return "var(--warning)";
2287
+ case "recomputing": return "var(--muted-foreground)";
2288
+ case "ok": return "var(--primary)";
2289
+ default: return "var(--border)";
2290
+ }
2291
+ }
2292
+ /**
2293
+ * Snap to fixed decimals so SVG attrs match across SSR and client.
2294
+ * Raw Math.cos/sin floats can differ by a ULP between Node and the browser,
2295
+ * which React reports as a hydration mismatch on line/circle coordinates.
2296
+ */
2297
+ function snap(n, digits = 3) {
2298
+ const f = 10 ** digits;
2299
+ return Math.round(n * f) / f;
2300
+ }
2301
+ /** Polar point; 0% is 12 o'clock, clockwise. */
2302
+ function polar(cx, cy, r, pct) {
2303
+ const rad = pct / 100 * Math.PI * 2 - Math.PI / 2;
2304
+ return {
2305
+ x: snap(cx + r * Math.cos(rad)),
2306
+ y: snap(cy + r * Math.sin(rad))
2307
+ };
2308
+ }
2309
+ /**
2310
+ * Compact context-window meter: linear segmented bar, bent into a ring.
2311
+ * Filled ticks glow; remaining ticks stay quiet.
2312
+ */
2313
+ function ContextRing({ usage, size = 24, stroke = 2, className }) {
2314
+ const uid = react.useId().replace(/:/g, "");
2315
+ const center = size / 2;
2316
+ const glowPad = snap(Math.max(4, size * .18));
2317
+ const recomputing = !!usage && usage.tokens === null;
2318
+ const pct = usage && usage.percent != null ? Math.max(0, Math.min(100, usage.percent)) : 0;
2319
+ const tone = meterTone(pct, recomputing, !!usage);
2320
+ const color = toneStroke(tone);
2321
+ const hit = Math.max(size, 32);
2322
+ const tickCount = size >= 36 ? 40 : size >= 28 ? 32 : 28;
2323
+ const barLen = snap(Math.max(3.2, size * .18));
2324
+ const barWidth = snap(Math.max(1.15, Math.min(1.75, stroke * .72)));
2325
+ const rOuter = snap(size / 2 - glowPad * .15);
2326
+ const rInner = snap(rOuter - barLen);
2327
+ const filledCount = usage ? Math.round(pct / 100 * tickCount) : 0;
2328
+ const blurStd = snap(Math.max(1.4, size * .06));
2329
+ const glowId = `ctx-bar-glow-${uid}`;
2330
+ let tooltip;
2331
+ if (!usage) tooltip = "No usage yet";
2332
+ else if (usage.tokens === null) tooltip = "Recomputing after compaction…";
2333
+ else tooltip = `${Math.round(usage.percent ?? 0)}% used · ${formatCompact(usage.tokens)} / ${formatCompact(usage.contextWindow)}`;
2334
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_tooltip.Tooltip, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipTrigger, {
2335
+ asChild: true,
2336
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2337
+ "data-slot": "context-ring",
2338
+ "data-tone": tone,
2339
+ "aria-label": tooltip,
2340
+ className: require_utils.cn("inline-flex items-center justify-center", className),
2341
+ style: {
2342
+ width: hit,
2343
+ height: hit
2344
+ },
2345
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
2346
+ width: size,
2347
+ height: size,
2348
+ viewBox: `${-glowPad} ${-glowPad} ${size + glowPad * 2} ${size + glowPad * 2}`,
2349
+ className: require_utils.cn(recomputing && "motion-safe:animate-pulse"),
2350
+ "aria-hidden": true,
2351
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("filter", {
2352
+ id: glowId,
2353
+ x: "-120%",
2354
+ y: "-120%",
2355
+ width: "340%",
2356
+ height: "340%",
2357
+ colorInterpolationFilters: "sRGB",
2358
+ children: [
2359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("feGaussianBlur", {
2360
+ stdDeviation: blurStd,
2361
+ result: "blur"
2362
+ }),
2363
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("feColorMatrix", {
2364
+ in: "blur",
2365
+ type: "matrix",
2366
+ values: "1 0 0 0 0\n 0 1 0 0 0\n 0 0 1 0 0\n 0 0 0 0.75 0",
2367
+ result: "glow"
2368
+ }),
2369
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("feMerge", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("feMergeNode", { in: "glow" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("feMergeNode", { in: "SourceGraphic" })] })
2370
+ ]
2371
+ }) }), Array.from({ length: tickCount }, (_, i) => {
2372
+ const t = (i + .5) / tickCount * 100;
2373
+ const filled = i < filledCount;
2374
+ const isFrontier = filled && i === filledCount - 1;
2375
+ const outer = polar(center, center, rOuter, t);
2376
+ const inner = polar(center, center, rInner, t);
2377
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
2378
+ x1: inner.x,
2379
+ y1: inner.y,
2380
+ x2: outer.x,
2381
+ y2: outer.y,
2382
+ stroke: filled ? color : "var(--border)",
2383
+ strokeWidth: barWidth,
2384
+ strokeLinecap: "round",
2385
+ opacity: filled ? recomputing ? .55 : isFrontier ? 1 : .92 : usage ? .38 : .28,
2386
+ filter: filled ? `url(#${glowId})` : void 0,
2387
+ className: "transition-[stroke,opacity] duration-200 ease-out"
2388
+ }, i);
2389
+ })]
2390
+ })
2391
+ })
2392
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_tooltip.TooltipContent, {
2393
+ side: "top",
2394
+ children: tooltip
2395
+ })] });
2396
+ }
2397
+
2398
+ //#endregion
2399
+ //#region src/components/ai/task-row.tsx
2400
+ function TaskRow({ label, meta, status, progress, details, onRetry, className, defaultOpen = false, index = 0 }) {
2401
+ const hasDetails = Boolean(details?.length);
2402
+ const header = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2403
+ className: "flex min-w-0 flex-1 items-center gap-2.5",
2404
+ children: [
2405
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2406
+ className: "relative flex size-6 shrink-0 items-center justify-center",
2407
+ children: status === "running" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
2408
+ width: "24",
2409
+ height: "24",
2410
+ className: "absolute inset-0 animate-spin motion-reduce:animate-none",
2411
+ style: { animationDuration: "1.1s" },
2412
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
2413
+ cx: "12",
2414
+ cy: "12",
2415
+ r: "10",
2416
+ fill: "none",
2417
+ stroke: "var(--border)",
2418
+ strokeWidth: "2"
2419
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
2420
+ cx: "12",
2421
+ cy: "12",
2422
+ r: "10",
2423
+ fill: "none",
2424
+ stroke: "var(--muted-foreground)",
2425
+ strokeWidth: "2",
2426
+ strokeLinecap: "round",
2427
+ strokeDasharray: `${2 * Math.PI * 10 * .28} ${2 * Math.PI * 10 * .72}`
2428
+ })]
2429
+ }), progress != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2430
+ className: "relative text-[10px] font-semibold tabular-nums text-foreground",
2431
+ children: Math.round(progress)
2432
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Loader2, { className: "relative size-3 animate-spin text-muted-foreground motion-reduce:animate-none" })] }) : status === "completed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2433
+ className: "flex size-5 items-center justify-center rounded-full bg-success text-white",
2434
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {
2435
+ className: "size-3",
2436
+ strokeWidth: 3
2437
+ })
2438
+ }) : status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2439
+ className: "flex size-5 items-center justify-center rounded-full bg-destructive text-white",
2440
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, {
2441
+ className: "size-3",
2442
+ strokeWidth: 3
2443
+ })
2444
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: "size-5 rounded-full border border-border" })
2445
+ }),
2446
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2447
+ className: "min-w-0 flex-1",
2448
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2449
+ className: "truncate text-[13px] font-medium text-foreground",
2450
+ children: label
2451
+ }), meta ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2452
+ className: "truncate text-[12px] text-muted-foreground",
2453
+ children: meta
2454
+ }) : null]
2455
+ }),
2456
+ status === "completed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2457
+ className: "inline-flex h-5 items-center rounded-full bg-success/10 px-2 text-[11.5px] font-medium text-success",
2458
+ children: "Completed"
2459
+ }) : status === "failed" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2460
+ className: "inline-flex items-center gap-1",
2461
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2462
+ className: "inline-flex h-5 items-center rounded-full bg-destructive/10 px-2 text-[11.5px] font-medium text-destructive",
2463
+ children: "Failed"
2464
+ }), onRetry ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
2465
+ type: "button",
2466
+ variant: "ghost",
2467
+ size: "icon-xs",
2468
+ "aria-label": "Retry",
2469
+ onClick: onRetry,
2470
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.RotateCcw, { className: "size-3" })
2471
+ }) : null]
2472
+ }) : null,
2473
+ hasDetails ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
2474
+ "data-slot": "collapsible-icon",
2475
+ className: "size-3.5 shrink-0 text-muted-foreground/60"
2476
+ }) : null
2477
+ ]
2478
+ });
2479
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2480
+ "data-slot": "task-row",
2481
+ "data-status": status,
2482
+ className: require_utils.cn("rounded-lg border border-border/80 bg-card px-2.5 py-2 shadow-xs", "animate-[ai-fade-up_300ms_cubic-bezier(0.23,1,0.32,1)_both] motion-reduce:animate-none", className),
2483
+ style: { animationDelay: `${index * 80}ms` },
2484
+ children: hasDetails ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
2485
+ defaultOpen,
2486
+ className: "group/collapsible",
2487
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleTrigger, {
2488
+ className: "w-full text-left",
2489
+ children: header
2490
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
2491
+ innerClassName: "py-1.5 pl-8",
2492
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2493
+ className: "space-y-1",
2494
+ children: details.map((d, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2495
+ className: "flex items-center justify-between gap-2 text-[12px]",
2496
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2497
+ className: "text-muted-foreground",
2498
+ children: d.label
2499
+ }), d.meta ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2500
+ className: "font-mono tabular-nums text-muted-foreground/80",
2501
+ children: d.meta
2502
+ }) : null]
2503
+ }, i))
2504
+ })
2505
+ })]
2506
+ }) : header
2507
+ });
2508
+ }
2509
+ function TaskList({ children, className }) {
2510
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2511
+ "data-slot": "task-list",
2512
+ className: require_utils.cn("flex flex-col gap-2", className),
2513
+ children
2514
+ });
2515
+ }
2516
+
2517
+ //#endregion
2518
+ //#region src/components/ai/context-card.tsx
2519
+ function ContextCard({ title, body, meta, sourceType, sourceName, className, index = 0 }) {
2520
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("article", {
2521
+ "data-slot": "context-card",
2522
+ className: require_utils.cn("rounded-xl border border-border bg-card p-3 shadow-xs", "animate-[ai-fade-up_300ms_cubic-bezier(0.23,1,0.32,1)_both] motion-reduce:animate-none", className),
2523
+ style: { animationDelay: `${index * 60}ms` },
2524
+ children: [
2525
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2526
+ className: "flex items-start justify-between gap-2",
2527
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
2528
+ className: "text-[13px] font-medium text-balance text-foreground",
2529
+ children: title
2530
+ }), meta ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2531
+ className: "shrink-0 text-[11px] tabular-nums text-muted-foreground",
2532
+ children: meta
2533
+ }) : null]
2534
+ }),
2535
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2536
+ className: "mt-1.5 text-[13px] text-pretty leading-relaxed text-muted-foreground",
2537
+ children: body
2538
+ }),
2539
+ (sourceType || sourceName) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2540
+ className: "mt-2.5 flex items-center gap-1.5 text-[12px] text-muted-foreground",
2541
+ children: [
2542
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.FileText, { className: "size-3 shrink-0 opacity-70" }),
2543
+ sourceType ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_badge.Badge, {
2544
+ variant: "secondary",
2545
+ className: "h-5 px-1.5 text-[10px] font-medium",
2546
+ children: sourceType
2547
+ }) : null,
2548
+ sourceName ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2549
+ className: "min-w-0 truncate",
2550
+ children: sourceName
2551
+ }) : null
2552
+ ]
2553
+ })
2554
+ ]
2555
+ });
2556
+ }
2557
+ function ContextCards({ children, className, label = "Chunks", count }) {
2558
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2559
+ "data-slot": "context-cards",
2560
+ className: require_utils.cn("flex flex-col gap-2", className),
2561
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2562
+ className: "flex items-center gap-2 text-[12px] text-muted-foreground",
2563
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2564
+ className: "font-medium",
2565
+ children: label
2566
+ }), count != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2567
+ className: "tabular-nums text-muted-foreground/70",
2568
+ children: count
2569
+ }) : null]
2570
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2571
+ className: "flex flex-col gap-2",
2572
+ children
2573
+ })]
2574
+ });
2575
+ }
2576
+
2577
+ //#endregion
2578
+ //#region src/components/ai/recommendation-card.tsx
2579
+ /**
2580
+ * Agent suggestion with confidence meter and optional alternatives drawer.
2581
+ */
2582
+ function RecommendationCard({ title = "Recommendation", body, confidence, confidenceLabel, alternatives = [], acceptLabel = "Accept", onAccept, className, selectedId: selectedProp, defaultSelectedId }) {
2583
+ const [internalId, setInternalId] = react.useState(defaultSelectedId ?? alternatives[0]?.id ?? "primary");
2584
+ const selectedId = selectedProp ?? internalId;
2585
+ const displayBody = alternatives.find((a) => a.id === selectedId)?.description ?? body;
2586
+ const pct = confidence != null ? Math.round(Math.max(0, Math.min(1, confidence)) * 100) : null;
2587
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2588
+ "data-slot": "recommendation-card",
2589
+ className: require_utils.cn("w-full max-w-md overflow-hidden rounded-xl border border-border bg-card shadow-xs", className),
2590
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2591
+ className: "space-y-3 p-3",
2592
+ children: [
2593
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2594
+ className: "text-[12px] font-medium text-muted-foreground",
2595
+ children: title
2596
+ }),
2597
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2598
+ className: "text-[13px] text-pretty leading-relaxed text-foreground",
2599
+ children: displayBody
2600
+ }),
2601
+ pct != null ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2602
+ className: "space-y-1",
2603
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2604
+ className: "flex items-center justify-between text-[11px] text-muted-foreground",
2605
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: confidenceLabel ?? "Confidence" }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2606
+ className: "tabular-nums font-medium text-foreground",
2607
+ children: [pct, "%"]
2608
+ })]
2609
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2610
+ className: "h-1.5 overflow-hidden rounded-full bg-muted",
2611
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2612
+ className: "h-full origin-left rounded-full bg-primary transition-transform duration-200 ease-out motion-reduce:transition-none",
2613
+ style: { transform: `scaleX(${pct / 100})` }
2614
+ })
2615
+ })]
2616
+ }) : null,
2617
+ alternatives.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.Collapsible, {
2618
+ className: "group/collapsible",
2619
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_collapsible.CollapsibleTrigger, {
2620
+ className: require_utils.cn("flex w-full items-center justify-between rounded-md border border-border/80 px-2.5 py-1.5 text-[12.5px]", "text-muted-foreground transition-colors duration-150 hover:bg-accent hover:text-foreground"),
2621
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "Other options" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.ChevronDown, {
2622
+ "data-slot": "collapsible-icon",
2623
+ className: "size-3.5"
2624
+ })]
2625
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_collapsible.CollapsibleContent, {
2626
+ innerClassName: "py-1.5",
2627
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2628
+ className: "flex flex-col gap-0.5",
2629
+ children: alternatives.map((opt) => {
2630
+ const on = opt.id === selectedId;
2631
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
2632
+ type: "button",
2633
+ "aria-pressed": on,
2634
+ onClick: () => {
2635
+ setInternalId(opt.id);
2636
+ },
2637
+ className: require_utils.cn("flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[13px]", "transition-colors duration-150 hover:bg-accent", on && "bg-accent"),
2638
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2639
+ className: require_utils.cn("mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border", on ? "border-primary bg-primary text-primary-foreground" : "border-border"),
2640
+ children: on ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Check, {
2641
+ className: "size-2.5",
2642
+ strokeWidth: 3
2643
+ }) : null
2644
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2645
+ className: "min-w-0 flex-1",
2646
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2647
+ className: "font-medium text-foreground",
2648
+ children: opt.label
2649
+ }), opt.badge ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2650
+ className: "ml-1.5 text-[11px] text-muted-foreground",
2651
+ children: opt.badge
2652
+ }) : null]
2653
+ })]
2654
+ }) }, opt.id);
2655
+ })
2656
+ })
2657
+ })]
2658
+ }) : null,
2659
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2660
+ className: "flex justify-end",
2661
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
2662
+ type: "button",
2663
+ size: "sm",
2664
+ onClick: () => onAccept?.(selectedId),
2665
+ children: acceptLabel
2666
+ })
2667
+ })
2668
+ ]
2669
+ })
2670
+ });
2671
+ }
2672
+
2673
+ //#endregion
2674
+ //#region src/components/ai/file-upload.tsx
2675
+ /**
2676
+ * Drag-and-drop / file picker for chat attachments.
2677
+ */
2678
+ function FileUpload({ files: filesProp, onFilesChange, multiple = true, accept, disabled, className, variant = "dropzone", children }) {
2679
+ const [internal, setInternal] = react.useState([]);
2680
+ const [dragging, setDragging] = react.useState(false);
2681
+ const inputRef = react.useRef(null);
2682
+ const files = filesProp ?? internal;
2683
+ const setFiles = (next) => {
2684
+ setInternal(next);
2685
+ onFilesChange?.(next);
2686
+ };
2687
+ const addFiles = (list) => {
2688
+ const incoming = Array.from(list);
2689
+ setFiles(multiple ? [...files, ...incoming] : incoming.slice(0, 1));
2690
+ };
2691
+ const removeAt = (index) => {
2692
+ setFiles(files.filter((_, i) => i !== index));
2693
+ };
2694
+ const onDrop = (event) => {
2695
+ event.preventDefault();
2696
+ setDragging(false);
2697
+ if (disabled || !event.dataTransfer.files?.length) return;
2698
+ addFiles(event.dataTransfer.files);
2699
+ };
2700
+ if (variant === "button") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2701
+ "data-slot": "file-upload",
2702
+ className: require_utils.cn("inline-flex", className),
2703
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2704
+ ref: inputRef,
2705
+ type: "file",
2706
+ className: "sr-only",
2707
+ multiple,
2708
+ accept,
2709
+ disabled,
2710
+ onChange: (e) => {
2711
+ if (e.target.files) addFiles(e.target.files);
2712
+ e.target.value = "";
2713
+ }
2714
+ }), children ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
2715
+ type: "button",
2716
+ variant: "ghost",
2717
+ size: "icon-sm",
2718
+ "aria-label": "Attach files",
2719
+ disabled,
2720
+ onClick: () => inputRef.current?.click(),
2721
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Paperclip, { className: "size-4" })
2722
+ })]
2723
+ });
2724
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2725
+ "data-slot": "file-upload",
2726
+ className: require_utils.cn("w-full space-y-2", className),
2727
+ children: [
2728
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
2729
+ ref: inputRef,
2730
+ type: "file",
2731
+ className: "sr-only",
2732
+ multiple,
2733
+ accept,
2734
+ disabled,
2735
+ onChange: (e) => {
2736
+ if (e.target.files) addFiles(e.target.files);
2737
+ e.target.value = "";
2738
+ }
2739
+ }),
2740
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2741
+ role: "button",
2742
+ tabIndex: disabled ? -1 : 0,
2743
+ onKeyDown: (e) => {
2744
+ if (e.key === "Enter" || e.key === " ") {
2745
+ e.preventDefault();
2746
+ inputRef.current?.click();
2747
+ }
2748
+ },
2749
+ onClick: () => !disabled && inputRef.current?.click(),
2750
+ onDragEnter: (e) => {
2751
+ e.preventDefault();
2752
+ setDragging(true);
2753
+ },
2754
+ onDragOver: (e) => e.preventDefault(),
2755
+ onDragLeave: () => setDragging(false),
2756
+ onDrop,
2757
+ className: require_utils.cn("flex cursor-pointer flex-col items-center justify-center gap-2 rounded-xl border border-dashed px-4 py-6 text-center", "transition-colors duration-150", dragging ? "border-primary bg-primary/5" : "border-border bg-muted/30 hover:bg-muted/50", disabled && "pointer-events-none opacity-60"),
2758
+ children: [
2759
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Upload, { className: "size-5 text-muted-foreground" }),
2760
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2761
+ className: "text-[13px] font-medium text-foreground",
2762
+ children: "Drop files or click to upload"
2763
+ }),
2764
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2765
+ className: "text-xs text-muted-foreground",
2766
+ children: multiple ? "Multiple files supported" : "Single file"
2767
+ })
2768
+ ]
2769
+ }),
2770
+ files.length > 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
2771
+ className: "flex flex-col gap-1",
2772
+ children: files.map((file, i) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
2773
+ className: "flex items-center gap-2 rounded-md border border-border bg-card px-2 py-1.5 text-[12.5px]",
2774
+ children: [
2775
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.Paperclip, { className: "size-3.5 shrink-0 text-muted-foreground" }),
2776
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2777
+ className: "min-w-0 flex-1 truncate font-medium",
2778
+ children: file.name
2779
+ }),
2780
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2781
+ className: "shrink-0 tabular-nums text-muted-foreground",
2782
+ children: formatBytes(file.size)
2783
+ }),
2784
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_button.Button, {
2785
+ type: "button",
2786
+ variant: "ghost",
2787
+ size: "icon-xs",
2788
+ "aria-label": `Remove ${file.name}`,
2789
+ onClick: () => removeAt(i),
2790
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(lucide_react.X, { className: "size-3.5" })
2791
+ })
2792
+ ]
2793
+ }, `${file.name}-${i}`))
2794
+ }) : null
2795
+ ]
2796
+ });
2797
+ }
2798
+ function formatBytes(n) {
2799
+ if (n < 1024) return `${n} B`;
2800
+ if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;
2801
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
2802
+ }
2803
+
2804
+ //#endregion
2805
+ //#region src/components/ai/image.tsx
2806
+ /**
2807
+ * Display AI-generated or user-uploaded images from base64 / bytes / URL.
2808
+ */
2809
+ function AiImage({ data, mimeType = "image/png", src, bytes, alt = "", className, ...props }) {
2810
+ const resolved = react.useMemo(() => {
2811
+ if (src) return src;
2812
+ if (data) {
2813
+ if (data.startsWith("data:")) return data;
2814
+ return `data:${mimeType};base64,${data}`;
2815
+ }
2816
+ if (bytes) {
2817
+ let binary = "";
2818
+ bytes.forEach((b) => {
2819
+ binary += String.fromCharCode(b);
2820
+ });
2821
+ return `data:${mimeType};base64,${btoa(binary)}`;
2822
+ }
2823
+ }, [
2824
+ src,
2825
+ data,
2826
+ bytes,
2827
+ mimeType
2828
+ ]);
2829
+ if (!resolved) return null;
2830
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
2831
+ "data-slot": "ai-image",
2832
+ src: resolved,
2833
+ alt,
2834
+ className: require_utils.cn("max-h-80 max-w-full rounded-lg object-contain", "outline outline-1 outline-black/10 dark:outline-white/10", className),
2835
+ ...props
2836
+ });
2837
+ }
2838
+
2839
+ //#endregion
2840
+ Object.defineProperty(exports, 'AgentLoader', {
2841
+ enumerable: true,
2842
+ get: function () {
2843
+ return AgentLoader;
2844
+ }
2845
+ });
2846
+ Object.defineProperty(exports, 'AiImage', {
2847
+ enumerable: true,
2848
+ get: function () {
2849
+ return AiImage;
2850
+ }
2851
+ });
2852
+ Object.defineProperty(exports, 'ApprovalCard', {
2853
+ enumerable: true,
2854
+ get: function () {
2855
+ return ApprovalCard;
2856
+ }
2857
+ });
2858
+ Object.defineProperty(exports, 'ChainOfThought', {
2859
+ enumerable: true,
2860
+ get: function () {
2861
+ return ChainOfThought;
2862
+ }
2863
+ });
2864
+ Object.defineProperty(exports, 'ChainOfThoughtStep', {
2865
+ enumerable: true,
2866
+ get: function () {
2867
+ return ChainOfThoughtStep;
2868
+ }
2869
+ });
2870
+ Object.defineProperty(exports, 'ChatContainer', {
2871
+ enumerable: true,
2872
+ get: function () {
2873
+ return ChatContainer;
2874
+ }
2875
+ });
2876
+ Object.defineProperty(exports, 'ChatContainerContent', {
2877
+ enumerable: true,
2878
+ get: function () {
2879
+ return ChatContainerContent;
2880
+ }
2881
+ });
2882
+ Object.defineProperty(exports, 'CodeBlock', {
2883
+ enumerable: true,
2884
+ get: function () {
2885
+ return CodeBlock;
2886
+ }
2887
+ });
2888
+ Object.defineProperty(exports, 'ContextCard', {
2889
+ enumerable: true,
2890
+ get: function () {
2891
+ return ContextCard;
2892
+ }
2893
+ });
2894
+ Object.defineProperty(exports, 'ContextCards', {
2895
+ enumerable: true,
2896
+ get: function () {
2897
+ return ContextCards;
2898
+ }
2899
+ });
2900
+ Object.defineProperty(exports, 'ContextRing', {
2901
+ enumerable: true,
2902
+ get: function () {
2903
+ return ContextRing;
2904
+ }
2905
+ });
2906
+ Object.defineProperty(exports, 'DiffTable', {
2907
+ enumerable: true,
2908
+ get: function () {
2909
+ return DiffTable;
2910
+ }
2911
+ });
2912
+ Object.defineProperty(exports, 'FeedbackBar', {
2913
+ enumerable: true,
2914
+ get: function () {
2915
+ return FeedbackBar;
2916
+ }
2917
+ });
2918
+ Object.defineProperty(exports, 'FileUpload', {
2919
+ enumerable: true,
2920
+ get: function () {
2921
+ return FileUpload;
2922
+ }
2923
+ });
2924
+ Object.defineProperty(exports, 'InlineDiff', {
2925
+ enumerable: true,
2926
+ get: function () {
2927
+ return InlineDiff;
2928
+ }
2929
+ });
2930
+ Object.defineProperty(exports, 'Loader', {
2931
+ enumerable: true,
2932
+ get: function () {
2933
+ return Loader;
2934
+ }
2935
+ });
2936
+ Object.defineProperty(exports, 'Markdown', {
2937
+ enumerable: true,
2938
+ get: function () {
2939
+ return Markdown;
2940
+ }
2941
+ });
2942
+ Object.defineProperty(exports, 'Message', {
2943
+ enumerable: true,
2944
+ get: function () {
2945
+ return Message;
2946
+ }
2947
+ });
2948
+ Object.defineProperty(exports, 'MessageAction', {
2949
+ enumerable: true,
2950
+ get: function () {
2951
+ return MessageAction;
2952
+ }
2953
+ });
2954
+ Object.defineProperty(exports, 'MessageActions', {
2955
+ enumerable: true,
2956
+ get: function () {
2957
+ return MessageActions;
2958
+ }
2959
+ });
2960
+ Object.defineProperty(exports, 'MessageAvatar', {
2961
+ enumerable: true,
2962
+ get: function () {
2963
+ return MessageAvatar;
2964
+ }
2965
+ });
2966
+ Object.defineProperty(exports, 'MessageContent', {
2967
+ enumerable: true,
2968
+ get: function () {
2969
+ return MessageContent;
2970
+ }
2971
+ });
2972
+ Object.defineProperty(exports, 'PlanTracker', {
2973
+ enumerable: true,
2974
+ get: function () {
2975
+ return PlanTracker;
2976
+ }
2977
+ });
2978
+ Object.defineProperty(exports, 'PromptInput', {
2979
+ enumerable: true,
2980
+ get: function () {
2981
+ return PromptInput;
2982
+ }
2983
+ });
2984
+ Object.defineProperty(exports, 'PromptInputAction', {
2985
+ enumerable: true,
2986
+ get: function () {
2987
+ return PromptInputAction;
2988
+ }
2989
+ });
2990
+ Object.defineProperty(exports, 'PromptInputActions', {
2991
+ enumerable: true,
2992
+ get: function () {
2993
+ return PromptInputActions;
2994
+ }
2995
+ });
2996
+ Object.defineProperty(exports, 'PromptInputBody', {
2997
+ enumerable: true,
2998
+ get: function () {
2999
+ return PromptInputBody;
3000
+ }
3001
+ });
3002
+ Object.defineProperty(exports, 'PromptInputTextarea', {
3003
+ enumerable: true,
3004
+ get: function () {
3005
+ return PromptInputTextarea;
3006
+ }
3007
+ });
3008
+ Object.defineProperty(exports, 'PromptSuggestion', {
3009
+ enumerable: true,
3010
+ get: function () {
3011
+ return PromptSuggestion;
3012
+ }
3013
+ });
3014
+ Object.defineProperty(exports, 'PromptSuggestions', {
3015
+ enumerable: true,
3016
+ get: function () {
3017
+ return PromptSuggestions;
3018
+ }
3019
+ });
3020
+ Object.defineProperty(exports, 'Reasoning', {
3021
+ enumerable: true,
3022
+ get: function () {
3023
+ return Reasoning;
3024
+ }
3025
+ });
3026
+ Object.defineProperty(exports, 'RecommendationCard', {
3027
+ enumerable: true,
3028
+ get: function () {
3029
+ return RecommendationCard;
3030
+ }
3031
+ });
3032
+ Object.defineProperty(exports, 'ResponseStream', {
3033
+ enumerable: true,
3034
+ get: function () {
3035
+ return ResponseStream;
3036
+ }
3037
+ });
3038
+ Object.defineProperty(exports, 'STREAM_THROTTLE_MS', {
3039
+ enumerable: true,
3040
+ get: function () {
3041
+ return STREAM_THROTTLE_MS;
3042
+ }
3043
+ });
3044
+ Object.defineProperty(exports, 'ScrollButton', {
3045
+ enumerable: true,
3046
+ get: function () {
3047
+ return ScrollButton;
3048
+ }
3049
+ });
3050
+ Object.defineProperty(exports, 'Source', {
3051
+ enumerable: true,
3052
+ get: function () {
3053
+ return Source;
3054
+ }
3055
+ });
3056
+ Object.defineProperty(exports, 'Sources', {
3057
+ enumerable: true,
3058
+ get: function () {
3059
+ return Sources;
3060
+ }
3061
+ });
3062
+ Object.defineProperty(exports, 'StatusIcon', {
3063
+ enumerable: true,
3064
+ get: function () {
3065
+ return StatusIcon;
3066
+ }
3067
+ });
3068
+ Object.defineProperty(exports, 'Step', {
3069
+ enumerable: true,
3070
+ get: function () {
3071
+ return Step;
3072
+ }
3073
+ });
3074
+ Object.defineProperty(exports, 'Steps', {
3075
+ enumerable: true,
3076
+ get: function () {
3077
+ return Steps;
3078
+ }
3079
+ });
3080
+ Object.defineProperty(exports, 'StreamingText', {
3081
+ enumerable: true,
3082
+ get: function () {
3083
+ return StreamingText;
3084
+ }
3085
+ });
3086
+ Object.defineProperty(exports, 'SystemMessage', {
3087
+ enumerable: true,
3088
+ get: function () {
3089
+ return SystemMessage;
3090
+ }
3091
+ });
3092
+ Object.defineProperty(exports, 'TaskList', {
3093
+ enumerable: true,
3094
+ get: function () {
3095
+ return TaskList;
3096
+ }
3097
+ });
3098
+ Object.defineProperty(exports, 'TaskRow', {
3099
+ enumerable: true,
3100
+ get: function () {
3101
+ return TaskRow;
3102
+ }
3103
+ });
3104
+ Object.defineProperty(exports, 'TextShimmer', {
3105
+ enumerable: true,
3106
+ get: function () {
3107
+ return TextShimmer;
3108
+ }
3109
+ });
3110
+ Object.defineProperty(exports, 'ThinkingBar', {
3111
+ enumerable: true,
3112
+ get: function () {
3113
+ return ThinkingBar;
3114
+ }
3115
+ });
3116
+ Object.defineProperty(exports, 'ThinkingTrace', {
3117
+ enumerable: true,
3118
+ get: function () {
3119
+ return ThinkingTrace;
3120
+ }
3121
+ });
3122
+ Object.defineProperty(exports, 'Tool', {
3123
+ enumerable: true,
3124
+ get: function () {
3125
+ return Tool;
3126
+ }
3127
+ });
3128
+ Object.defineProperty(exports, 'ToolGroup', {
3129
+ enumerable: true,
3130
+ get: function () {
3131
+ return ToolGroup;
3132
+ }
3133
+ });
3134
+ Object.defineProperty(exports, 'formatCompact', {
3135
+ enumerable: true,
3136
+ get: function () {
3137
+ return formatCompact;
3138
+ }
3139
+ });
3140
+ Object.defineProperty(exports, 'formatDuration', {
3141
+ enumerable: true,
3142
+ get: function () {
3143
+ return formatDuration;
3144
+ }
3145
+ });
3146
+ Object.defineProperty(exports, 'lineDiff', {
3147
+ enumerable: true,
3148
+ get: function () {
3149
+ return lineDiff;
3150
+ }
3151
+ });
3152
+ Object.defineProperty(exports, 'normalizeToolStatus', {
3153
+ enumerable: true,
3154
+ get: function () {
3155
+ return normalizeToolStatus;
3156
+ }
3157
+ });
3158
+ Object.defineProperty(exports, 'renderBasicMarkdown', {
3159
+ enumerable: true,
3160
+ get: function () {
3161
+ return renderBasicMarkdown;
3162
+ }
3163
+ });
3164
+ Object.defineProperty(exports, 'useChatContainer', {
3165
+ enumerable: true,
3166
+ get: function () {
3167
+ return useChatContainer;
3168
+ }
3169
+ });
3170
+ Object.defineProperty(exports, 'usePromptInput', {
3171
+ enumerable: true,
3172
+ get: function () {
3173
+ return usePromptInput;
3174
+ }
3175
+ });
3176
+ Object.defineProperty(exports, 'useThrottledText', {
3177
+ enumerable: true,
3178
+ get: function () {
3179
+ return useThrottledText;
3180
+ }
3181
+ });
3182
+ //# sourceMappingURL=ai-lAkichk8.cjs.map