@object-ui/plugin-chatbot 17.3.0 → 17.6.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.
package/dist/index.js CHANGED
@@ -1,46 +1,46 @@
1
1
  import * as e from "react";
2
2
  import { Children as t, Fragment as n, createContext as r, isValidElement as i, memo as a, useCallback as o, useContext as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
- import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as ee, DropdownMenuContent as P, DropdownMenuItem as F, DropdownMenuTrigger as I, Empty as te, EmptyDescription as ne, EmptyHeader as L, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger as oe, Input as z, Label as B, ScrollArea as V, ScrollBar as H, Select as se, SelectContent as ce, SelectItem as le, SelectTrigger as ue, SelectValue as de, Separator as fe, Sheet as pe, SheetContent as me, SheetDescription as he, SheetHeader as ge, SheetTitle as _e, Skeleton as ve, Table as ye, TableBody as be, TableCell as U, TableHead as W, TableHeader as xe, TableRow as Se, Tabs as Ce, TabsList as we, TabsTrigger as Te, Textarea as Ee, Tooltip as De, TooltipContent as Oe, TooltipProvider as ke, TooltipTrigger as Ae, cn as G } from "@object-ui/components";
4
- import { AlertCircle as je, ArrowDownIcon as Me, ArrowRight as Ne, BookIcon as Pe, Bot as Fe, BrainIcon as Ie, Check as Le, CheckCircle2 as K, CheckCircleIcon as q, CheckIcon as Re, ChevronDownIcon as ze, ChevronLeftIcon as Be, ChevronRightIcon as Ve, CircleIcon as He, ClipboardList as Ue, Clock as We, Clock3 as Ge, ClockIcon as Ke, Copy as qe, CopyIcon as Je, CornerDownLeft as Ye, CornerDownLeftIcon as J, Eye as Xe, GitCompareArrows as Ze, HelpCircle as Qe, Hourglass as $e, ImageIcon as et, Inbox as tt, Loader2 as nt, Loader2Icon as rt, Maximize2 as it, MicIcon as at, Minimize2 as ot, PaperclipIcon as st, PlusIcon as ct, RefreshCw as lt, Rocket as ut, Send as dt, ShieldCheck as ft, Sparkles as pt, SquareIcon as mt, Table2 as ht, TriangleAlert as gt, WifiOff as _t, WrenchIcon as vt, X as yt, XCircle as Y, XCircleIcon as bt, XIcon as xt } from "lucide-react";
3
+ import { Alert as f, AlertDescription as p, Avatar as m, AvatarFallback as h, AvatarImage as g, Badge as _, Button as v, Card as y, CardContent as b, CardDescription as x, CardHeader as S, CardTitle as C, Collapsible as w, CollapsibleContent as T, CollapsibleTrigger as E, Command as D, CommandEmpty as O, CommandGroup as k, CommandInput as A, CommandItem as j, CommandList as M, CommandSeparator as N, DropdownMenu as ee, DropdownMenuContent as P, DropdownMenuItem as F, DropdownMenuTrigger as I, Empty as te, EmptyDescription as ne, EmptyHeader as L, EmptyMedia as re, EmptyTitle as ie, HoverCard as R, HoverCardContent as ae, HoverCardTrigger as oe, Input as z, Label as B, ScrollArea as se, ScrollBar as V, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Separator as pe, Sheet as me, SheetContent as he, SheetDescription as ge, SheetHeader as _e, SheetTitle as ve, Skeleton as ye, Table as be, TableBody as xe, TableCell as H, TableHead as U, TableHeader as Se, TableRow as Ce, Tabs as we, TabsList as Te, TabsTrigger as Ee, Textarea as De, Tooltip as Oe, TooltipContent as ke, TooltipProvider as Ae, TooltipTrigger as je, cn as W } from "@object-ui/components";
4
+ import { AlertCircle as Me, ArrowDownIcon as Ne, ArrowRight as Pe, BookIcon as Fe, Bot as Ie, BrainIcon as Le, Check as Re, CheckCircle2 as G, CheckCircleIcon as ze, CheckIcon as Be, ChevronDownIcon as Ve, ChevronLeftIcon as He, ChevronRightIcon as Ue, CircleIcon as K, ClipboardList as We, Clock as Ge, Clock3 as Ke, ClockIcon as qe, Copy as Je, CopyIcon as Ye, CornerDownLeft as Xe, CornerDownLeftIcon as Ze, Eye as Qe, GitCompareArrows as $e, HelpCircle as et, Hourglass as tt, ImageIcon as nt, Inbox as rt, Loader2 as it, Loader2Icon as at, Maximize2 as ot, MicIcon as st, Minimize2 as q, PaperclipIcon as ct, PlusIcon as lt, RefreshCw as ut, Rocket as dt, Send as ft, ShieldCheck as pt, Sparkles as mt, SquareIcon as ht, Table2 as gt, TriangleAlert as _t, WifiOff as vt, WrenchIcon as yt, X as bt, XCircle as J, XCircleIcon as xt, XIcon as Y } from "lucide-react";
5
5
  import { Fragment as X, jsx as Z, jsxs as Q } from "react/jsx-runtime";
6
6
  import { useChat as St } from "@ai-sdk/react";
7
7
  import { DefaultChatTransport as Ct } from "ai";
8
8
  import * as wt from "react-dom";
9
- import { SchemaRenderer as Tt, useObjectTranslation as $ } from "@object-ui/react";
10
- import { useObjectTranslation as Et, useSafeTranslate as Dt } from "@object-ui/i18n";
11
- import { StickToBottom as Ot, useStickToBottomContext as kt } from "use-stick-to-bottom";
12
- import { cva as At } from "class-variance-authority";
13
- import { Slot as jt } from "@radix-ui/react-slot";
14
- import { Streamdown as Mt } from "streamdown";
15
- import { nanoid as Nt } from "nanoid";
16
- import { codeToHtml as Pt } from "shiki";
17
- import { useControllableState as Ft } from "@radix-ui/react-use-controllable-state";
18
- import { motion as It } from "motion/react";
19
- import { ComponentRegistry as Lt } from "@object-ui/core";
9
+ import { SchemaRenderer as Tt, useObjectTranslation as Et } from "@object-ui/react";
10
+ import { useObjectTranslation as Dt, useSafeTranslate as Ot } from "@object-ui/i18n";
11
+ import { StickToBottom as kt, useStickToBottomContext as At } from "use-stick-to-bottom";
12
+ import { cva as jt } from "class-variance-authority";
13
+ import { Slot as Mt } from "@radix-ui/react-slot";
14
+ import { Streamdown as Nt } from "streamdown";
15
+ import { nanoid as Pt } from "nanoid";
16
+ import { codeToHtml as Ft } from "shiki";
17
+ import { useControllableState as It } from "@radix-ui/react-use-controllable-state";
18
+ import { motion as Lt } from "motion/react";
19
+ import { ComponentRegistry as Rt, toDomProps as zt } from "@object-ui/core";
20
20
  //#region \0rolldown/runtime.js
21
- var Rt = Object.defineProperty, zt = (e, t) => {
21
+ var Bt = Object.defineProperty, Vt = (e, t) => {
22
22
  let n = {};
23
- for (var r in e) Rt(n, r, {
23
+ for (var r in e) Bt(n, r, {
24
24
  get: e[r],
25
25
  enumerable: !0
26
26
  });
27
- return t || Rt(n, Symbol.toStringTag, { value: "Module" }), n;
27
+ return t || Bt(n, Symbol.toStringTag, { value: "Module" }), n;
28
28
  };
29
29
  //#endregion
30
30
  //#region src/utils.ts
31
- function Bt(e = "msg") {
31
+ function Ht(e = "msg") {
32
32
  return typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `${e}-${Date.now()}-${Math.random().toString(36).slice(2)}`;
33
33
  }
34
34
  //#endregion
35
35
  //#region src/mapMessages.ts
36
- function Vt(e, t) {
36
+ function Ut(e, t) {
37
37
  return typeof e.content == "string" ? e.content : t.filter((e) => e.type === "text").map((e) => e.text ?? "").join("");
38
38
  }
39
- function Ht(e) {
39
+ function Wt(e) {
40
40
  let t = e.filter((e) => e.type === "reasoning" || e.type === "reasoning-delta").map((e) => e.text ?? "").join("\n").trim();
41
41
  return t.length > 0 ? t : void 0;
42
42
  }
43
- function Ut(e) {
43
+ function $(e) {
44
44
  let t = (e) => {
45
45
  if (e && typeof e == "object") return e;
46
46
  if (typeof e != "string") return;
@@ -53,18 +53,18 @@ function Ut(e) {
53
53
  }
54
54
  }, n = [e];
55
55
  e && typeof e == "object" && "value" in e && n.push(e.value);
56
- let r;
56
+ let r, i;
57
57
  for (let e of n) {
58
58
  let n = t(e);
59
59
  if (n) {
60
60
  if (typeof n.status == "string") return n;
61
- r ??= n;
61
+ n.type === "text" && "value" in n ? i ??= n : r ??= n;
62
62
  }
63
63
  }
64
- return r;
64
+ return r ?? i;
65
65
  }
66
- function Wt(e) {
67
- let t = Ut(e);
66
+ function Gt(e) {
67
+ let t = $(e);
68
68
  if (!t) return;
69
69
  let n = t.pendingActionId;
70
70
  if (t.status === "pending_approval" && typeof n == "string" && n.length > 0) return {
@@ -72,11 +72,11 @@ function Wt(e) {
72
72
  raw: t
73
73
  };
74
74
  }
75
- function Gt(e) {
75
+ function Kt(e) {
76
76
  return Array.isArray(e) ? e.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
77
77
  }
78
- function Kt(e) {
79
- let t = Ut(e);
78
+ function qt(e) {
79
+ let t = $(e);
80
80
  if (!t || t.status !== "blueprint_proposed") return;
81
81
  let n = t.blueprint, r = n && typeof n == "object" ? n : {}, i = (Array.isArray(r.objects) ? r.objects : []).flatMap((e) => {
82
82
  let t = e;
@@ -92,7 +92,7 @@ function Kt(e) {
92
92
  views: a(o.views, Array.isArray(r.views) ? r.views.length : 0),
93
93
  dashboards: a(o.dashboards, Array.isArray(r.dashboards) ? r.dashboards.length : 0),
94
94
  seedData: a(o.seedData, Array.isArray(r.seedData) ? r.seedData.length : 0)
95
- }, c = Gt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
95
+ }, c = Kt(t.questions), l = t.questionChoices, u = Array.isArray(l) ? l.flatMap((e) => {
96
96
  let t = e;
97
97
  if (typeof t?.text != "string" || !t.text) return [];
98
98
  let n = Array.isArray(t.options) ? t.options.filter((e) => typeof e == "string" && e.trim().length > 0) : [];
@@ -105,14 +105,14 @@ function Kt(e) {
105
105
  ...d ? { summary: d } : {},
106
106
  objects: i,
107
107
  counts: s,
108
- questions: c.length ? c : Gt(r.questions),
108
+ questions: c.length ? c : Kt(r.questions),
109
109
  ...u.length ? { questionChoices: u } : {},
110
- assumptions: Gt(r.assumptions),
110
+ assumptions: Kt(r.assumptions),
111
111
  ...typeof f == "string" && f ? { targetApp: f } : {}
112
112
  };
113
113
  }
114
- function qt(e) {
115
- let t = Ut(e);
114
+ function Jt(e) {
115
+ let t = $(e);
116
116
  if (!t || t.status !== "build_handoff") return;
117
117
  let n = typeof t.prompt == "string" ? t.prompt.trim() : "";
118
118
  if (!n) return;
@@ -122,8 +122,8 @@ function qt(e) {
122
122
  ...i ? { packageId: i } : {}
123
123
  };
124
124
  }
125
- function Jt(e) {
126
- let t = Ut(e);
125
+ function Yt(e) {
126
+ let t = $(e);
127
127
  if (!t || t.status !== "changes_proposed") return;
128
128
  let n = (e) => typeof e == "string" && e ? e : void 0, r = t.changes, i = (Array.isArray(r) ? r : []).flatMap((e) => {
129
129
  let t = e;
@@ -141,8 +141,57 @@ function Jt(e) {
141
141
  changes: i
142
142
  };
143
143
  }
144
- function Yt(e) {
145
- let t = Ut(e);
144
+ function Xt(e, t) {
145
+ if (!e || !e.startsWith("replay_")) return;
146
+ let n = $(t);
147
+ if (!n) return;
148
+ if (n.status === "published") return { kind: "published" };
149
+ let r = n.error;
150
+ if (typeof r == "string" && r.trim() && n.status === void 0) return {
151
+ kind: "failed",
152
+ dispatchError: !0,
153
+ error: r.trim().split("\n")[0]
154
+ };
155
+ if (n.status !== "drafted") return;
156
+ let i = n.packageId, a = typeof i == "string" && i ? { packageId: i } : {};
157
+ if (n.publishFailed === !0) {
158
+ let e = n.publishError, t = typeof e == "string" && e.trim() ? e.trim().split("\n")[0] : void 0, r = n.publishOutcome;
159
+ return {
160
+ kind: "failed",
161
+ ...typeof r == "string" && r ? { outcome: r } : {},
162
+ ...t ? { error: t } : {},
163
+ ...a
164
+ };
165
+ }
166
+ return {
167
+ kind: "drafted",
168
+ ...a
169
+ };
170
+ }
171
+ function Zt(e) {
172
+ let t = $(e);
173
+ if (!t) return;
174
+ if (t.status === "published") return { kind: "published" };
175
+ if (t.status !== "drafted") return;
176
+ let n = t.packageId, r = typeof n == "string" && n ? { packageId: n } : {};
177
+ return t.publishFailed === !0 ? {
178
+ kind: "failed",
179
+ ...r
180
+ } : {
181
+ kind: "drafted",
182
+ ...r
183
+ };
184
+ }
185
+ function Qt(e) {
186
+ let t = $(e);
187
+ if (!t || t.status !== "drafted" && t.status !== "published") return;
188
+ let n = t.packageId;
189
+ if (typeof n != "string" || !n) return;
190
+ let r = t.drafted;
191
+ return Array.isArray(r) && r.some((e) => e && typeof e == "object" && e.type === "app") ? n : void 0;
192
+ }
193
+ function $t(e) {
194
+ let t = $(e);
146
195
  if (!t || t.status !== "drafted") return;
147
196
  let n = [];
148
197
  if (Array.isArray(t.drafted)) {
@@ -182,39 +231,40 @@ function Yt(e) {
182
231
  ...s.length ? { issues: s } : {}
183
232
  };
184
233
  }
185
- function Xt(e) {
234
+ function en(e) {
186
235
  return e.replace(/[._-]+/g, " ").replace(/\s+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
187
236
  }
188
- function Zt(e) {
237
+ function tn(e) {
189
238
  if (!e || !Array.isArray(e.items) || e.items.length === 0) return;
190
239
  let t = e.items.find((e) => e.type === "app");
191
240
  if (t) return {
192
241
  phase: "done",
193
- appLabel: Xt(t.name),
242
+ appLabel: en(t.name),
194
243
  items: e.items,
195
244
  done: e.items.length,
196
245
  total: e.items.length
197
246
  };
198
247
  }
199
- function Qt(e, t = {}) {
248
+ function nn(e, t = {}) {
200
249
  return e.filter((e) => e.type === "dynamic-tool" || typeof e.type == "string" && e.type.startsWith("tool-")).map((e) => {
201
- let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.output ?? e.result, i = Wt(r), a = Yt(r), o = Kt(r), s = Jt(r), c = qt(r), l = e.state, u = (l === "input-available" || l === "input-streaming") && (r !== void 0 || !t.liveTail) ? "output-available" : l, d = i && u !== "output-error" ? "approval-requested" : u;
250
+ let n = e.type === "dynamic-tool" ? e.toolName ?? "tool" : typeof e.type == "string" ? e.type.replace(/^tool-/, "") : "tool", r = e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`, i = e.output ?? e.result, a = Gt(i), o = Xt(r, i), s = o ? void 0 : $t(i), c = qt(i), l = Yt(i), u = Jt(i), d = e.state, f = (d === "input-available" || d === "input-streaming") && (i !== void 0 || !t.liveTail) ? "output-available" : d, p = a && f !== "output-error" ? "approval-requested" : f;
202
251
  return {
203
- toolCallId: e.toolCallId ?? e.id ?? `${e.type ?? "tool"}-${Math.random().toString(36).slice(2, 8)}`,
252
+ toolCallId: r,
204
253
  toolName: n,
205
254
  args: e.input ?? e.args,
206
- result: r,
255
+ result: i,
207
256
  errorText: e.errorText,
208
- state: d,
209
- pendingActionId: i?.pendingActionId,
210
- draftReview: a,
211
- proposedPlan: o,
212
- proposedChanges: s,
213
- builderHandoff: c
257
+ state: p,
258
+ pendingActionId: a?.pendingActionId,
259
+ draftReview: s,
260
+ proposedPlan: c,
261
+ proposedChanges: l,
262
+ builderHandoff: u,
263
+ replayOutcome: o
214
264
  };
215
265
  });
216
266
  }
217
- function $t(e) {
267
+ function rn(e) {
218
268
  let t = e.filter((e) => e.type === "source-url" || e.type === "source").map((e) => ({
219
269
  id: e.id,
220
270
  title: e.title,
@@ -222,7 +272,7 @@ function $t(e) {
222
272
  })).filter((e) => !!e.url);
223
273
  return t.length > 0 ? t : void 0;
224
274
  }
225
- function en(e) {
275
+ function an(e) {
226
276
  let t = e.filter((e) => e.type === "data-build-progress").pop()?.data;
227
277
  if (!t || typeof t != "object") return;
228
278
  let n = t, r = Array.isArray(n.items) ? n.items.filter((e) => typeof e?.type == "string" && typeof e?.name == "string").map((e) => ({
@@ -238,7 +288,7 @@ function en(e) {
238
288
  ...typeof n.seq == "number" ? { seq: n.seq } : {}
239
289
  };
240
290
  }
241
- function tn(e) {
291
+ function on(e) {
242
292
  let t = e.filter((e) => e.type === "data-blueprint-progress").pop()?.data;
243
293
  if (!t || typeof t != "object") return;
244
294
  let n = t, r = Array.isArray(n.objects) ? n.objects.filter((e) => typeof e?.name == "string").map((e) => ({
@@ -260,7 +310,7 @@ function tn(e) {
260
310
  ...typeof n.seq == "number" ? { seq: n.seq } : {}
261
311
  };
262
312
  }
263
- function nn(e) {
313
+ function sn(e) {
264
314
  let t = [];
265
315
  for (let n of e) {
266
316
  if (n.type !== "data-chart") continue;
@@ -280,35 +330,70 @@ function nn(e) {
280
330
  }
281
331
  return t.length > 0 ? t : void 0;
282
332
  }
283
- function rn(e, t = {}) {
284
- let n = Array.isArray(e.parts) ? e.parts : [], r = Qt(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = en(n) ?? a.map((e) => Zt(e.draftReview)).find((e) => !!e);
333
+ function cn(e, t = {}) {
334
+ let n = Array.isArray(e.parts) ? e.parts : [], r = nn(n, { liveTail: t.streaming }), i = Array.isArray(e.toolInvocations) ? e.toolInvocations : [], a = r.length > 0 ? r : i, o = an(n) ?? a.map((e) => tn(e.draftReview)).find((e) => !!e);
285
335
  return {
286
336
  id: e.id ?? `msg-${Math.random().toString(36).slice(2, 8)}`,
287
337
  role: e.role ?? "assistant",
288
- content: Vt(e, n),
289
- reasoning: Ht(n),
338
+ content: Ut(e, n),
339
+ reasoning: Wt(n),
290
340
  toolInvocations: a,
291
- sources: $t(n),
341
+ sources: rn(n),
292
342
  buildProgress: o,
293
- blueprintProgress: tn(n),
294
- charts: nn(n),
343
+ blueprintProgress: on(n),
344
+ charts: sn(n),
295
345
  streaming: t.streaming
296
346
  };
297
347
  }
298
- function an(e, t = {}) {
348
+ function ln(e, t = {}) {
299
349
  if (!Array.isArray(e) || e.length === 0) return [];
300
350
  let n = e.length - 1;
301
- return e.map((e, r) => rn(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
351
+ return e.map((e, r) => cn(e, { streaming: !!t.isStreaming && r === n && e.role === "assistant" }));
352
+ }
353
+ //#endregion
354
+ //#region src/chatMessageAdapter.ts
355
+ function un(e) {
356
+ return typeof e == "string" ? e : e instanceof Date ? e.toISOString() : void 0;
357
+ }
358
+ function dn(e) {
359
+ return e === "tool" ? "assistant" : e;
360
+ }
361
+ function fn(e) {
362
+ switch (e) {
363
+ case "partial-call": return "input-streaming";
364
+ case "call": return "input-available";
365
+ case "result": return "output-available";
366
+ default: return e;
367
+ }
368
+ }
369
+ function pn(e) {
370
+ let { state: t, ...n } = e;
371
+ return {
372
+ ...n,
373
+ state: fn(t)
374
+ };
375
+ }
376
+ function mn(e) {
377
+ let { role: t, timestamp: n, toolInvocations: r, ...i } = e;
378
+ return {
379
+ ...i,
380
+ role: dn(t),
381
+ timestamp: un(n),
382
+ toolInvocations: r?.map(pn)
383
+ };
384
+ }
385
+ function hn(e) {
386
+ return (e ?? []).map(mn);
302
387
  }
303
388
  //#endregion
304
389
  //#region src/useObjectChat.ts
305
- var on = "objectui:ai-usage-refresh";
306
- function sn() {
390
+ var gn = "objectui:ai-usage-refresh";
391
+ function _n() {
307
392
  if (!(typeof window > "u" || typeof window.dispatchEvent != "function")) try {
308
- window.dispatchEvent(new CustomEvent(on));
393
+ window.dispatchEvent(new CustomEvent(gn));
309
394
  } catch {}
310
395
  }
311
- async function cn(e, t) {
396
+ async function vn(e, t) {
312
397
  let n;
313
398
  try {
314
399
  n = await fetch(e, t);
@@ -326,7 +411,7 @@ async function cn(e, t) {
326
411
  }
327
412
  return n;
328
413
  }
329
- function ln(e) {
414
+ function yn(e) {
330
415
  let t = [...e.messages].reverse().find((e) => e.role === "user");
331
416
  return { body: {
332
417
  ...e.body ?? {},
@@ -337,7 +422,7 @@ function ln(e) {
337
422
  ...t ? { turnId: t.id } : {}
338
423
  } };
339
424
  }
340
- function un(e, t) {
425
+ function bn(e, t) {
341
426
  let n = e.context ?? {};
342
427
  return {
343
428
  ...e,
@@ -347,25 +432,33 @@ function un(e, t) {
347
432
  }
348
433
  };
349
434
  }
350
- function dn(e) {
435
+ var xn = /* @__PURE__ */ new Set();
436
+ function Sn() {
437
+ xn.has("maxToolRoundtrips") || (xn.add("maxToolRoundtrips"), console.warn("[@object-ui/plugin-chatbot] `maxToolRoundtrips` is deprecated and has no effect: the installed chat runtime exposes no client-side round-trip cap (`useChat` dropped the numeric knob, and the surviving `stopWhen` / `stepCountIs` step cap is server-side only). Cap tool-calling loops on the agent instead — `planning.maxIterations`. This key is inert and is slated for removal in a future major (objectui#5605)."));
438
+ }
439
+ function Cn(e) {
351
440
  return (e ?? []).map((e, t) => ({
352
441
  id: e.id || `msg-${t}`,
353
442
  role: e.role || "user",
354
443
  content: e.content || "",
355
- timestamp: typeof e.timestamp == "string" ? e.timestamp : e.timestamp instanceof Date ? e.timestamp.toISOString() : void 0,
444
+ timestamp: un(e.timestamp),
356
445
  metadata: e.metadata,
357
446
  streaming: e.streaming,
358
447
  toolInvocations: e.toolInvocations
359
448
  }));
360
449
  }
361
- function fn(e = {}) {
362
- let { api: t, initialMessages: n, conversationId: r, parentConversationId: i, systemPrompt: a, model: s, streamingEnabled: f = !0, headers: p, body: m, maxToolRoundtrips: h = 5, onError: g, showTimestamp: _, autoResponse: v, autoResponseText: y, autoResponseDelay: b = 1e3, onSend: x } = e, S = u(t ? "api" : "local").current === "api", C = l(() => (n ?? []).map((e, t) => {
450
+ function wn(e = {}) {
451
+ let { api: t, initialMessages: n, conversationId: r, parentConversationId: i, systemPrompt: a, model: s, streamingEnabled: f = !0, headers: p, body: m, maxToolRoundtrips: h, onError: g, showTimestamp: _, autoResponse: v, autoResponseText: y, autoResponseDelay: b = 1e3, onSend: x } = e;
452
+ c(() => {
453
+ h !== void 0 && Sn();
454
+ }, [h]);
455
+ let S = u(t ? "api" : "local").current === "api", C = l(() => (n ?? []).map((e, t) => {
363
456
  if (Array.isArray(e.parts) && e.parts.length > 0) return {
364
457
  id: e.id || `msg-${t}`,
365
458
  role: e.role || "user",
366
459
  parts: e.parts
367
460
  };
368
- let n = dn([e])[0], r = [];
461
+ let n = Cn([e])[0], r = [];
369
462
  n.content && r.push({
370
463
  type: "text",
371
464
  text: n.content
@@ -397,100 +490,108 @@ function fn(e = {}) {
397
490
  let e = E.current;
398
491
  E.current = i, i && !e && (T.current = i);
399
492
  }, [i]);
400
- let D = l(() => {
493
+ let D = u(m);
494
+ D.current = m;
495
+ let O = u(p);
496
+ O.current = p;
497
+ let k = l(() => {
401
498
  if (S) return new Ct({
402
499
  api: t,
403
- fetch: cn,
404
- headers: { ...p },
500
+ fetch: vn,
405
501
  body: {
406
- ...m,
407
502
  ...r ? { conversationId: r } : {},
408
503
  ...s ? { model: s } : {},
409
504
  ...a ? { systemPrompt: a } : {},
410
505
  ...f === void 0 ? {} : { stream: f }
411
506
  },
412
- prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i }) => {
413
- let a = ln({
507
+ prepareSendMessagesRequest: ({ id: e, body: t, messages: n, trigger: r, messageId: i, headers: a }) => {
508
+ let o = yn({
414
509
  id: e,
415
- body: t,
510
+ body: {
511
+ ...D.current,
512
+ ...t
513
+ },
416
514
  messages: n,
417
515
  trigger: r,
418
516
  messageId: i
419
517
  });
420
- return w.current && (a.body.model = w.current), T.current &&= (a.body = un(a.body, T.current), void 0), a;
518
+ w.current && (o.body.model = w.current), T.current &&= (o.body = bn(o.body, T.current), void 0);
519
+ let s = new Headers(O.current ?? {});
520
+ return new Headers(a ?? {}).forEach((e, t) => s.set(t, e)), {
521
+ ...o,
522
+ headers: s
523
+ };
421
524
  }
422
525
  });
423
526
  }, [
424
527
  S,
425
528
  t,
426
- p,
427
- m,
428
529
  s,
429
530
  a,
430
531
  f,
431
532
  r
432
- ]), O = u(null), k = St({
433
- transport: D,
533
+ ]), A = u(null), j = St({
534
+ transport: k,
434
535
  messages: S && C.length > 0 ? C : void 0,
435
536
  onError: S ? (e) => {
436
537
  if (e.notSent) {
437
- let e = O.current, t = e?.messages;
438
- e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)), sn();
538
+ let e = A.current, t = e?.messages;
539
+ e?.setMessages && t && t.length > 0 && t[t.length - 1]?.role === "user" && e.setMessages(t.slice(0, -1)), _n();
439
540
  }
440
541
  g?.(e);
441
542
  } : void 0
442
543
  });
443
- O.current = k;
444
- let A = u(void 0), j = k?.status;
544
+ A.current = j;
545
+ let M = u(void 0), N = j?.status;
445
546
  c(() => {
446
- let e = A.current;
447
- A.current = j, (e === "streaming" || e === "submitted") && j === "ready" && sn();
448
- }, [j]);
449
- let [M, N] = d(() => dn(n)), [ee, P] = d(!1), [F, I] = d(""), [te, ne] = d(""), L = u(null);
547
+ let e = M.current;
548
+ M.current = N, (e === "streaming" || e === "submitted") && N === "ready" && _n();
549
+ }, [N]);
550
+ let [ee, P] = d(() => Cn(n)), [F, I] = d(!1), [te, ne] = d(""), [L, re] = d(""), ie = u(null);
450
551
  c(() => () => {
451
- L.current &&= (clearTimeout(L.current), null);
552
+ ie.current &&= (clearTimeout(ie.current), null);
452
553
  }, []);
453
- let { messages: re, status: ie, error: R, sendMessage: ae, regenerate: oe, stop: z, setMessages: B } = k, V = ie === "submitted" || ie === "streaming", H = an(re, { isStreaming: V }).map((e, t) => ({
554
+ let { messages: R, status: ae, error: oe, sendMessage: z, regenerate: B, stop: se, setMessages: V } = j, ce = ae === "submitted" || ae === "streaming", le = ln(R, { isStreaming: ce }).map((e, t) => ({
454
555
  ...e,
455
- metadata: re[t]?.metadata
456
- })), se = o((e) => {
556
+ metadata: R[t]?.metadata
557
+ })), ue = o((e) => {
457
558
  let t = e.trim();
458
559
  if (!t) return;
459
- let n = [...H, {
460
- id: Bt("msg"),
560
+ let n = [...le, {
561
+ id: Ht("msg"),
461
562
  role: "user",
462
563
  content: t
463
564
  }];
464
- ae({ text: t }), ne(""), x?.(t, n);
565
+ z({ text: t }), re(""), x?.(t, n);
465
566
  }, [
466
- ae,
567
+ z,
467
568
  x,
468
- H
469
- ]), ce = o(() => {
470
- B([]);
471
- }, [B]), le = o((e) => {
472
- ne(e.target.value);
473
- }, []), ue = o(() => {
474
- L.current &&= (clearTimeout(L.current), null), P(!1);
475
- }, []), de = o((e) => {
569
+ le
570
+ ]), de = o(() => {
571
+ V([]);
572
+ }, [V]), fe = o((e) => {
573
+ re(e.target.value);
574
+ }, []), pe = o(() => {
575
+ ie.current &&= (clearTimeout(ie.current), null), I(!1);
576
+ }, []), me = o((e) => {
476
577
  if (!e.trim()) return;
477
578
  let t = {
478
- id: Bt("msg"),
579
+ id: Ht("msg"),
479
580
  role: "user",
480
581
  content: e.trim(),
481
582
  timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
482
583
  };
483
- N((n) => {
584
+ P((n) => {
484
585
  let r = [...n, t];
485
586
  return x?.(e.trim(), r), r;
486
- }), I(""), v && (P(!0), L.current = setTimeout(() => {
587
+ }), ne(""), v && (I(!0), ie.current = setTimeout(() => {
487
588
  let e = {
488
- id: Bt("msg"),
589
+ id: Ht("msg"),
489
590
  role: "assistant",
490
591
  content: y || "Thank you for your message!",
491
592
  timestamp: _ ? (/* @__PURE__ */ new Date()).toLocaleTimeString() : void 0
492
593
  };
493
- N((t) => [...t, e]), P(!1);
594
+ P((t) => [...t, e]), I(!1);
494
595
  }, b));
495
596
  }, [
496
597
  _,
@@ -498,65 +599,65 @@ function fn(e = {}) {
498
599
  y,
499
600
  b,
500
601
  x
501
- ]), fe = o(() => {}, []), pe = o(() => {
502
- ue(), N([]);
503
- }, [ue]), me = o((e) => {
504
- I(e.target.value);
602
+ ]), he = o(() => {}, []), ge = o(() => {
603
+ pe(), P([]);
604
+ }, [pe]), _e = o((e) => {
605
+ ne(e.target.value);
505
606
  }, []);
506
607
  return S ? {
507
- messages: H,
508
- isLoading: V,
509
- error: R,
510
- sendMessage: se,
511
- stop: z,
512
- reload: oe,
513
- clear: ce,
514
- setMessages: B,
608
+ messages: le,
609
+ isLoading: ce,
610
+ error: oe,
611
+ sendMessage: ue,
612
+ stop: se,
613
+ reload: B,
614
+ clear: de,
615
+ setMessages: V,
515
616
  isApiMode: !0,
516
- input: te,
517
- setInput: ne,
518
- handleInputChange: le
617
+ input: L,
618
+ setInput: re,
619
+ handleInputChange: fe
519
620
  } : {
520
- messages: M,
521
- isLoading: ee,
621
+ messages: ee,
622
+ isLoading: F,
522
623
  error: void 0,
523
- sendMessage: de,
524
- stop: ue,
525
- reload: fe,
526
- clear: pe,
624
+ sendMessage: me,
625
+ stop: pe,
626
+ reload: he,
627
+ clear: ge,
527
628
  isApiMode: !1,
528
- input: F,
529
- setInput: I,
530
- handleInputChange: me
629
+ input: te,
630
+ setInput: ne,
631
+ handleInputChange: _e
531
632
  };
532
633
  }
533
634
  //#endregion
534
635
  //#region src/agentAliases.ts
535
- var pn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
536
- function mn(e) {
537
- return pn.find((t) => t.includes(e)) ?? [e];
636
+ var Tn = [["build", "metadata_assistant"], ["ask", "data_chat"]];
637
+ function En(e) {
638
+ return Tn.find((t) => t.includes(e)) ?? [e];
538
639
  }
539
- function hn(e) {
540
- return mn(e)[0];
640
+ function Dn(e) {
641
+ return En(e)[0];
541
642
  }
542
- function gn(e, t) {
643
+ function On(e, t) {
543
644
  if (e) {
544
645
  if (t.includes(e)) return e;
545
- for (let n of mn(e)) if (t.includes(n)) return n;
646
+ for (let n of En(e)) if (t.includes(n)) return n;
546
647
  }
547
648
  }
548
- function _n(e) {
549
- return e != null && pn.some((t) => t.includes(e));
649
+ function kn(e) {
650
+ return e != null && Tn.some((t) => t.includes(e));
550
651
  }
551
- function vn(e) {
552
- return e != null && hn(e) === "build";
652
+ function An(e) {
653
+ return e != null && Dn(e) === "build";
553
654
  }
554
- function yn(e) {
555
- return e != null && hn(e) === "ask";
655
+ function jn(e) {
656
+ return e != null && Dn(e) === "ask";
556
657
  }
557
658
  //#endregion
558
659
  //#region src/useAgents.ts
559
- function bn(e) {
660
+ function Mn(e) {
560
661
  if (!(!e || typeof e != "object")) return {
561
662
  authoring: e.authoring === !0,
562
663
  canvas: e.canvas === !0,
@@ -564,45 +665,45 @@ function bn(e) {
564
665
  resume: e.resume === !0
565
666
  };
566
667
  }
567
- function xn(e, t, n) {
668
+ function Nn(e, t, n) {
568
669
  if (!t) return !1;
569
670
  let r = e.find((e) => e.name === t);
570
- return r?.capabilities ? r.capabilities[n] : vn(t);
671
+ return r?.capabilities ? r.capabilities[n] : An(t);
571
672
  }
572
- var Sn = "ask";
573
- function Cn(e, t) {
673
+ var Pn = "ask";
674
+ function Fn(e, t) {
574
675
  if (e.length === 0) return;
575
676
  let n = e.map((e) => e.name);
576
677
  if (t) {
577
- let e = gn(t, n);
678
+ let e = On(t, n);
578
679
  if (e) return e;
579
680
  }
580
- return gn("ask", n) || e[0].name;
681
+ return On("ask", n) || e[0].name;
581
682
  }
582
- function wn(e) {
683
+ function In(e) {
583
684
  let t = e && typeof e == "object" && !Array.isArray(e) && typeof e.success == "boolean" ? e.data : e;
584
685
  if (Array.isArray(t)) return t;
585
686
  let n = t?.agents;
586
687
  return Array.isArray(n) ? n : [];
587
688
  }
588
- function Tn(e) {
689
+ function Ln(e) {
589
690
  return e.filter((e) => typeof e?.name == "string" && e.name.length > 0).map((e) => ({
590
691
  name: e.name,
591
692
  label: e.label || e.name,
592
693
  description: e.description,
593
694
  role: e.role,
594
695
  active: e.active !== !1,
595
- capabilities: bn(e.capabilities)
696
+ capabilities: Mn(e.capabilities)
596
697
  }));
597
698
  }
598
- var En = 3e4, Dn = /* @__PURE__ */ new Map(), On = /* @__PURE__ */ new Map();
599
- function kn(e, t, n) {
600
- if (n) Dn.delete(e);
699
+ var Rn = 3e4, zn = /* @__PURE__ */ new Map(), Bn = /* @__PURE__ */ new Map();
700
+ function Vn(e, t, n) {
701
+ if (n) zn.delete(e);
601
702
  else {
602
- let t = Dn.get(e);
603
- if (t && Date.now() - t.timestamp < En) return Promise.resolve(t.data);
703
+ let t = zn.get(e);
704
+ if (t && Date.now() - t.timestamp < Rn) return Promise.resolve(t.data);
604
705
  }
605
- let r = On.get(e);
706
+ let r = Bn.get(e);
606
707
  if (r && !n) return r;
607
708
  let i = `${e.replace(/\/$/, "")}/agents`, a = fetch(i, {
608
709
  method: "GET",
@@ -613,21 +714,21 @@ function kn(e, t, n) {
613
714
  credentials: "include"
614
715
  }).then(async (e) => {
615
716
  if (!e.ok) throw Error(`Failed to load agents (${e.status})`);
616
- return Tn(wn(await e.json()));
617
- }).then((t) => (Dn.set(e, {
717
+ return Ln(In(await e.json()));
718
+ }).then((t) => (zn.set(e, {
618
719
  data: t,
619
720
  timestamp: Date.now()
620
721
  }), t)).finally(() => {
621
- On.delete(e);
722
+ Bn.delete(e);
622
723
  });
623
- return On.set(e, a), a;
724
+ return Bn.set(e, a), a;
624
725
  }
625
- function An(e = {}) {
726
+ function Hn(e = {}) {
626
727
  let { apiBase: t, headers: n, enabled: r = !0, fallback: i = [] } = e, [a, s] = d(i), [l, f] = d(!1), [p, m] = d(void 0), [h, g] = d(0), _ = u(n);
627
728
  return _.current = n, c(() => {
628
729
  if (!r || !t) return;
629
730
  let e = !1;
630
- return f(!0), m(void 0), kn(t, _.current, h > 0).then((t) => {
731
+ return f(!0), m(void 0), Vn(t, _.current, h > 0).then((t) => {
631
732
  e || s(t.length > 0 ? t : i);
632
733
  }).catch((t) => {
633
734
  e || (m(t), s(i));
@@ -649,13 +750,13 @@ function An(e = {}) {
649
750
  }
650
751
  //#endregion
651
752
  //#region src/useAiModels.ts
652
- function jn(e) {
753
+ function Un(e) {
653
754
  return e.filter((e) => typeof e?.id == "string" && e.id.length > 0).map((e) => ({
654
755
  id: e.id,
655
756
  label: e.label || e.id
656
757
  }));
657
758
  }
658
- function Mn(e = {}) {
759
+ function Wn(e = {}) {
659
760
  let { apiBase: t, headers: n, enabled: r = !0 } = e, [i, a] = d([]), [s, l] = d(void 0), [f, p] = d(!1), [m, h] = d(void 0), [g, _] = d(0), v = u(n);
660
761
  return v.current = n, c(() => {
661
762
  if (!r || !t) return;
@@ -675,7 +776,7 @@ function Mn(e = {}) {
675
776
  if (!t.ok) throw Error(`Failed to load AI models (${t.status})`);
676
777
  let r = await t.json();
677
778
  if (n) return;
678
- let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = jn(c);
779
+ let c = Array.isArray(r) ? r : r?.models ?? [], u = Array.isArray(r) ? void 0 : r?.defaultModel, d = Un(c);
679
780
  a(d), l(u ?? c.find((e) => e?.default)?.id ?? c[0]?.id), p(!1), d.length === 0 && o < 5 && !n && (o += 1, setTimeout(() => {
680
781
  s();
681
782
  }, 1200));
@@ -704,8 +805,8 @@ function Mn(e = {}) {
704
805
  }
705
806
  //#endregion
706
807
  //#region src/FloatingChatbotProvider.tsx
707
- var Nn = e.createContext(null);
708
- function Pn({ defaultOpen: t = !1, children: n }) {
808
+ var Gn = e.createContext(null);
809
+ function Kn({ defaultOpen: t = !1, children: n }) {
709
810
  let [r, i] = e.useState(t), [a, o] = e.useState(!1), s = e.useMemo(() => ({
710
811
  isOpen: r,
711
812
  isFullscreen: a,
@@ -716,26 +817,26 @@ function Pn({ defaultOpen: t = !1, children: n }) {
716
817
  toggle: () => i((e) => !e),
717
818
  toggleFullscreen: () => o((e) => !e)
718
819
  }), [r, a]);
719
- return /* @__PURE__ */ Z(Nn.Provider, {
820
+ return /* @__PURE__ */ Z(Gn.Provider, {
720
821
  value: s,
721
822
  children: n
722
823
  });
723
824
  }
724
- function Fn() {
725
- let t = e.useContext(Nn);
825
+ function qn() {
826
+ let t = e.useContext(Gn);
726
827
  if (!t) throw Error("useFloatingChatbot must be used within a <FloatingChatbotProvider>");
727
828
  return t;
728
829
  }
729
830
  //#endregion
730
831
  //#region src/FloatingChatbotTrigger.tsx
731
- function In() {
732
- let { t: e } = $();
832
+ function Jn() {
833
+ let { t: e } = Et();
733
834
  return (t, n) => {
734
835
  let r = e(`common.${t}`);
735
836
  return !r || r === `common.${t}` ? n : r;
736
837
  };
737
838
  }
738
- var Ln = {
839
+ var Yn = {
739
840
  32: "size-8",
740
841
  36: "size-9",
741
842
  40: "size-10",
@@ -748,26 +849,26 @@ var Ln = {
748
849
  72: "size-[72px]",
749
850
  80: "size-20"
750
851
  };
751
- function Rn(e, t) {
852
+ function Xn(e, t) {
752
853
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
753
854
  }
754
- function zn(e) {
755
- return Ln[e] ?? Ln[Rn(e, Object.keys(Ln).map(Number))];
855
+ function Zn(e) {
856
+ return Yn[e] ?? Yn[Xn(e, Object.keys(Yn).map(Number))];
756
857
  }
757
- function Bn({ position: e = "bottom-right", size: t = 56, className: n }) {
758
- let { isOpen: r, toggle: i } = Fn(), a = In();
858
+ function Qn({ position: e = "bottom-right", size: t = 56, className: n }) {
859
+ let { isOpen: r, toggle: i } = qn(), a = Jn();
759
860
  return /* @__PURE__ */ Z(v, {
760
861
  onClick: i,
761
- className: G("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", zn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
862
+ className: W("fixed z-50 rounded-full shadow-lg transition-transform hover:scale-105", Zn(t), r && "hidden", e === "bottom-right" ? "right-6 bottom-20 sm:bottom-6" : "left-6 bottom-20 sm:bottom-6", n),
762
863
  size: "icon",
763
864
  "aria-label": r ? a("closeChat", "Close chat") : a("openChat", "Open chat"),
764
865
  "data-testid": "floating-chatbot-trigger",
765
- children: Z(r ? yt : Fe, { className: "h-6 w-6" })
866
+ children: Z(r ? bt : Ie, { className: "h-6 w-6" })
766
867
  });
767
868
  }
768
869
  //#endregion
769
870
  //#region src/FloatingChatbotPanel.tsx
770
- var Vn = {
871
+ var $n = {
771
872
  300: "sm:w-[300px]",
772
873
  320: "sm:w-[320px]",
773
874
  340: "sm:w-[340px]",
@@ -786,7 +887,7 @@ var Vn = {
786
887
  640: "sm:w-[640px]",
787
888
  720: "sm:w-[720px]",
788
889
  800: "sm:w-[800px]"
789
- }, Hn = {
890
+ }, er = {
790
891
  360: "h-[min(360px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[360px]",
791
892
  400: "h-[min(400px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[400px]",
792
893
  420: "h-[min(420px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[420px]",
@@ -800,19 +901,19 @@ var Vn = {
800
901
  720: "h-[min(720px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[720px]",
801
902
  800: "h-[min(800px,calc(100svh_-_6rem_-_env(safe-area-inset-bottom)))] sm:h-[800px]"
802
903
  };
803
- function Un(e, t) {
904
+ function tr(e, t) {
804
905
  return t.reduce((t, n) => Math.abs(n - e) < Math.abs(t - e) ? n : t);
805
906
  }
806
- function Wn(e) {
807
- return Vn[e] ?? Vn[Un(e, Object.keys(Vn).map(Number))];
907
+ function nr(e) {
908
+ return $n[e] ?? $n[tr(e, Object.keys($n).map(Number))];
808
909
  }
809
- function Gn(e) {
810
- return Hn[e] ?? Hn[Un(e, Object.keys(Hn).map(Number))];
910
+ function rr(e) {
911
+ return er[e] ?? er[tr(e, Object.keys(er).map(Number))];
811
912
  }
812
- function Kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
813
- let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = Fn();
913
+ function ir({ title: e = "Chat", position: t = "bottom-right", width: n = 400, height: r = 520, children: i, className: a, headerExtra: o, headerActions: s }) {
914
+ let { isOpen: c, isFullscreen: l, close: u, toggleFullscreen: d } = qn();
814
915
  return c ? /* @__PURE__ */ Q("div", {
815
- className: G("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? G("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Wn(n), Gn(r)) : G("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", Wn(n), Gn(r)), a),
916
+ className: W("fixed z-50 flex flex-col overflow-hidden border bg-background shadow-xl transition-all", l ? "inset-0 h-svh w-screen rounded-none" : t === "bottom-right" ? W("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:left-auto sm:right-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", nr(n), rr(r)) : W("left-3 right-3 bottom-[calc(4rem_+_env(safe-area-inset-bottom))] rounded-lg", "sm:right-auto sm:left-6 sm:bottom-20 sm:max-h-[calc(100vh_-_100px)]", nr(n), rr(r)), a),
816
917
  role: "dialog",
817
918
  "aria-label": e,
818
919
  "data-testid": "floating-chatbot-panel",
@@ -839,7 +940,7 @@ function Kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
839
940
  onClick: d,
840
941
  "aria-label": l ? "Exit fullscreen" : "Fullscreen",
841
942
  "data-testid": "floating-chatbot-fullscreen",
842
- children: Z(l ? ot : it, { className: "h-4 w-4" })
943
+ children: Z(l ? q : ot, { className: "h-4 w-4" })
843
944
  }),
844
945
  /* @__PURE__ */ Z(v, {
845
946
  variant: "ghost",
@@ -848,7 +949,7 @@ function Kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
848
949
  onClick: u,
849
950
  "aria-label": "Close chat",
850
951
  "data-testid": "floating-chatbot-close",
851
- children: /* @__PURE__ */ Z(yt, { className: "h-4 w-4" })
952
+ children: /* @__PURE__ */ Z(bt, { className: "h-4 w-4" })
852
953
  })
853
954
  ]
854
955
  })
@@ -861,7 +962,7 @@ function Kn({ title: e = "Chat", position: t = "bottom-right", width: n = 400, h
861
962
  }
862
963
  //#endregion
863
964
  //#region src/tool-display.ts
864
- var qn = {
965
+ var ar = {
865
966
  ai: "AI",
866
967
  api: "API",
867
968
  crm: "CRM",
@@ -873,17 +974,17 @@ var qn = {
873
974
  url: "URL",
874
975
  utc: "UTC"
875
976
  };
876
- function Jn(e) {
977
+ function or(e) {
877
978
  if (!e) return "";
878
979
  let t = String(e).trim();
879
980
  if (!t) return "";
880
981
  let n = t.replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(/\s+/).filter(Boolean);
881
982
  return n.length === 0 ? t : n.map((e, t) => {
882
983
  let n = e.toLowerCase();
883
- return qn[n] ? qn[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
984
+ return ar[n] ? ar[n] : t === 0 ? n.charAt(0).toUpperCase() + n.slice(1) : n;
884
985
  }).join(" ");
885
986
  }
886
- function Yn(e) {
987
+ function sr(e) {
887
988
  if (e == null) return e;
888
989
  let t = e;
889
990
  for (let e = 0; e < 2; e++) {
@@ -901,7 +1002,7 @@ function Yn(e) {
901
1002
  }
902
1003
  return t;
903
1004
  }
904
- function Xn(e) {
1005
+ function cr(e) {
905
1006
  let t = (e instanceof Error ? e.message : String(e ?? "")).replace(/\s+/g, " ").trim();
906
1007
  if (!t) return { summary: "Something went wrong. Please try again." };
907
1008
  let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, ""), r = n.match(/^Invalid error response format:\s*(.+)$/i)?.[1]?.trim() ?? n, i = r.match(/^([^:]{8,80}):\s+(.+)$/)?.[1]?.trim() ?? r.match(/^([^.;!?]+[.;!?])\s/)?.[1]?.trim() ?? (r.length > 140 ? `${r.slice(0, 137).trimEnd()}…` : r);
@@ -910,12 +1011,18 @@ function Xn(e) {
910
1011
  details: n.length > i.length ? n : void 0
911
1012
  };
912
1013
  }
913
- var Zn = /* @__PURE__ */ new Set([
1014
+ var lr = /* @__PURE__ */ new Set([
914
1015
  "ai_design_quota_exhausted",
915
1016
  "ai_data_chat_trial_exhausted",
916
1017
  "ai_allowance_exhausted"
917
1018
  ]);
918
- function Qn(e) {
1019
+ function ur(e) {
1020
+ return typeof e == "string" && lr.has(e) ? e : void 0;
1021
+ }
1022
+ function dr(e) {
1023
+ return typeof e == "string" && e.trim() ? e : void 0;
1024
+ }
1025
+ function fr(e) {
919
1026
  let t = e instanceof Error ? e.message : String(e ?? "");
920
1027
  if (!t) return null;
921
1028
  let n = t.replace(/^Failed after \d+ attempts?\.\s*Last error:\s*/i, "").replace(/^Invalid error response format:\s*/i, "").trim(), r = n.indexOf("{"), i = n.lastIndexOf("}");
@@ -926,39 +1033,41 @@ function Qn(e) {
926
1033
  } catch {
927
1034
  return null;
928
1035
  }
929
- return !a || typeof a.error != "string" || !Zn.has(a.error) ? null : {
930
- code: a.error,
931
- message: typeof a.message == "string" ? a.message : "",
932
- messageEn: typeof a.messageEn == "string" ? a.messageEn : void 0,
1036
+ if (!a || typeof a != "object") return null;
1037
+ let o = a.error && typeof a.error == "object" ? a.error : void 0, s = ur(a.error), c = ur(o?.code) ?? s ?? ur(a.code);
1038
+ return c ? {
1039
+ code: c,
1040
+ message: dr(o?.message) ?? dr(a.message) ?? (s ? void 0 : dr(a.error)) ?? "",
1041
+ messageEn: dr(a.messageEn),
933
1042
  upgrade: a.upgrade === !0,
934
1043
  topUp: a.topUp === !0
935
- };
1044
+ } : null;
936
1045
  }
937
- function $n(e) {
1046
+ function pr(e) {
938
1047
  return !!(e && typeof e == "object" && e.notSent === !0);
939
1048
  }
940
- function er(e) {
1049
+ function mr(e) {
941
1050
  let t = e && typeof e == "object" ? e.status : void 0;
942
1051
  return typeof t == "number" ? t : void 0;
943
1052
  }
944
- function tr(e) {
945
- if (er(e) === 429) return !0;
1053
+ function hr(e) {
1054
+ if (mr(e) === 429) return !0;
946
1055
  let t = e instanceof Error ? e.message : typeof e == "string" ? e : "";
947
1056
  return /\b429\b|too many requests|rate[\s_-]?limit/i.test(t);
948
1057
  }
949
1058
  //#endregion
950
1059
  //#region src/elements/conversation.tsx
951
- var nr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
952
- className: G("relative flex-1 overflow-y-hidden", e),
1060
+ var gr = ({ className: e, ...t }) => /* @__PURE__ */ Z(kt, {
1061
+ className: W("relative flex-1 overflow-y-hidden", e),
953
1062
  initial: "smooth",
954
1063
  resize: "smooth",
955
1064
  role: "log",
956
1065
  ...t
957
- }), rr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot.Content, {
958
- className: G("flex flex-col gap-8 p-4", e),
1066
+ }), _r = ({ className: e, ...t }) => /* @__PURE__ */ Z(kt.Content, {
1067
+ className: W("flex flex-col gap-8 p-4", e),
959
1068
  ...t
960
- }), ir = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Z("div", {
961
- className: G("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
1069
+ }), vr = ({ className: e, title: t = "No messages yet", description: n = "Start a conversation to see messages here", icon: r, children: i, ...a }) => /* @__PURE__ */ Z("div", {
1070
+ className: W("flex size-full flex-col items-center justify-center gap-3 p-8 text-center", e),
962
1071
  ...a,
963
1072
  children: i ?? /* @__PURE__ */ Q(X, { children: [r && /* @__PURE__ */ Z("div", {
964
1073
  className: "text-muted-foreground",
@@ -973,55 +1082,55 @@ var nr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Ot, {
973
1082
  children: n
974
1083
  })]
975
1084
  })] })
976
- }), ar = ({ className: e, ...t }) => {
977
- let { isAtBottom: n, scrollToBottom: r } = kt(), i = o(() => {
1085
+ }), yr = ({ className: e, ...t }) => {
1086
+ let { isAtBottom: n, scrollToBottom: r } = At(), i = o(() => {
978
1087
  r();
979
1088
  }, [r]);
980
1089
  return !n && /* @__PURE__ */ Z(v, {
981
- className: G("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
1090
+ className: W("absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full", e),
982
1091
  onClick: i,
983
1092
  size: "icon",
984
1093
  type: "button",
985
1094
  variant: "outline",
986
1095
  ...t,
987
- children: /* @__PURE__ */ Z(Me, { className: "size-4" })
1096
+ children: /* @__PURE__ */ Z(Ne, { className: "size-4" })
988
1097
  });
989
- }, or = At("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
1098
+ }, br = jt("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
990
1099
  variants: { orientation: {
991
1100
  horizontal: "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none",
992
1101
  vertical: "flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none"
993
1102
  } },
994
1103
  defaultVariants: { orientation: "horizontal" }
995
1104
  });
996
- function sr({ className: e, orientation: t, ...n }) {
1105
+ function xr({ className: e, orientation: t, ...n }) {
997
1106
  return /* @__PURE__ */ Z("div", {
998
1107
  role: "group",
999
1108
  "data-slot": "button-group",
1000
1109
  "data-orientation": t,
1001
- className: G(or({ orientation: t }), e),
1110
+ className: W(br({ orientation: t }), e),
1002
1111
  ...n
1003
1112
  });
1004
1113
  }
1005
- function cr({ className: e, asChild: t = !1, ...n }) {
1006
- return /* @__PURE__ */ Z(t ? jt : "div", {
1007
- className: G("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
1114
+ function Sr({ className: e, asChild: t = !1, ...n }) {
1115
+ return /* @__PURE__ */ Z(t ? Mt : "div", {
1116
+ className: W("flex items-center gap-2 rounded-md border bg-muted px-4 text-sm font-medium shadow-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4", e),
1008
1117
  ...n
1009
1118
  });
1010
1119
  }
1011
1120
  //#endregion
1012
1121
  //#region src/elements/message.tsx
1013
- var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1014
- className: G("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
1122
+ var Cr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1123
+ className: W("group flex w-full max-w-[95%] flex-col gap-2", t === "user" ? "is-user ml-auto justify-end" : "is-assistant", e),
1015
1124
  ...n
1016
- }), ur = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Z("div", {
1017
- className: G("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
1125
+ }), wr = ({ children: e, className: t, ...n }) => /* @__PURE__ */ Z("div", {
1126
+ className: W("is-user:dark flex w-fit max-w-full min-w-0 flex-col gap-2 overflow-hidden text-sm", "group-[.is-user]:ml-auto group-[.is-user]:rounded-lg group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground", "group-[.is-assistant]:text-foreground", t),
1018
1127
  ...n,
1019
1128
  children: e
1020
- }), dr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
1021
- className: G("flex items-center gap-1", e),
1129
+ }), Tr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
1130
+ className: W("flex items-center gap-1", e),
1022
1131
  ...n,
1023
1132
  children: t
1024
- }), fr = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
1133
+ }), Er = ({ tooltip: e, children: t, label: n, variant: r = "ghost", size: i = "icon", ...a }) => {
1025
1134
  let o = /* @__PURE__ */ Q(v, {
1026
1135
  size: i,
1027
1136
  type: "button",
@@ -1032,15 +1141,15 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1032
1141
  children: n || e
1033
1142
  })]
1034
1143
  });
1035
- return e ? /* @__PURE__ */ Z(ke, { children: /* @__PURE__ */ Q(De, { children: [/* @__PURE__ */ Z(Ae, {
1144
+ return e ? /* @__PURE__ */ Z(Ae, { children: /* @__PURE__ */ Q(Oe, { children: [/* @__PURE__ */ Z(je, {
1036
1145
  asChild: !0,
1037
1146
  children: o
1038
- }), /* @__PURE__ */ Z(Oe, { children: /* @__PURE__ */ Z("p", { children: e }) })] }) }) : o;
1039
- }, pr = r(null), mr = () => {
1040
- let e = s(pr);
1147
+ }), /* @__PURE__ */ Z(ke, { children: /* @__PURE__ */ Z("p", { children: e }) })] }) }) : o;
1148
+ }, Dr = r(null), Or = () => {
1149
+ let e = s(Dr);
1041
1150
  if (!e) throw Error("MessageBranch components must be used within MessageBranch");
1042
1151
  return e;
1043
- }, hr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
1152
+ }, kr = ({ defaultBranch: e = 0, onBranchChange: t, className: n, ...r }) => {
1044
1153
  let [i, a] = d(e), [o, s] = d([]), c = (e) => {
1045
1154
  a(e), t?.(e);
1046
1155
  }, l = {
@@ -1057,15 +1166,15 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1057
1166
  branches: o,
1058
1167
  setBranches: s
1059
1168
  };
1060
- return /* @__PURE__ */ Z(pr.Provider, {
1169
+ return /* @__PURE__ */ Z(Dr.Provider, {
1061
1170
  value: l,
1062
1171
  children: /* @__PURE__ */ Z("div", {
1063
- className: G("grid w-full gap-2 [&>div]:pb-0", n),
1172
+ className: W("grid w-full gap-2 [&>div]:pb-0", n),
1064
1173
  ...r
1065
1174
  })
1066
1175
  });
1067
- }, gr = ({ children: e, ...t }) => {
1068
- let { currentBranch: n, setBranches: r, branches: i } = mr(), a = Array.isArray(e) ? e : [e];
1176
+ }, Ar = ({ children: e, ...t }) => {
1177
+ let { currentBranch: n, setBranches: r, branches: i } = Or(), a = Array.isArray(e) ? e : [e];
1069
1178
  return c(() => {
1070
1179
  i.length !== a.length && r(a);
1071
1180
  }, [
@@ -1073,19 +1182,19 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1073
1182
  i,
1074
1183
  r
1075
1184
  ]), a.map((e, r) => /* @__PURE__ */ Z("div", {
1076
- className: G("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
1185
+ className: W("grid gap-2 overflow-hidden [&>div]:pb-0", r === n ? "block" : "hidden"),
1077
1186
  ...t,
1078
1187
  children: e
1079
1188
  }, e.key));
1080
- }, _r = ({ className: e, from: t, ...n }) => {
1081
- let { totalBranches: r } = mr();
1082
- return r <= 1 ? null : /* @__PURE__ */ Z(sr, {
1189
+ }, jr = ({ className: e, from: t, ...n }) => {
1190
+ let { totalBranches: r } = Or();
1191
+ return r <= 1 ? null : /* @__PURE__ */ Z(xr, {
1083
1192
  className: "[&>*:not(:first-child)]:rounded-l-md [&>*:not(:last-child)]:rounded-r-md",
1084
1193
  orientation: "horizontal",
1085
1194
  ...n
1086
1195
  });
1087
- }, vr = ({ children: e, ...t }) => {
1088
- let { goToPrevious: n, totalBranches: r } = mr();
1196
+ }, Mr = ({ children: e, ...t }) => {
1197
+ let { goToPrevious: n, totalBranches: r } = Or();
1089
1198
  return /* @__PURE__ */ Z(v, {
1090
1199
  "aria-label": "Previous branch",
1091
1200
  disabled: r <= 1,
@@ -1094,10 +1203,10 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1094
1203
  type: "button",
1095
1204
  variant: "ghost",
1096
1205
  ...t,
1097
- children: e ?? /* @__PURE__ */ Z(Be, { size: 14 })
1206
+ children: e ?? /* @__PURE__ */ Z(He, { size: 14 })
1098
1207
  });
1099
- }, yr = ({ children: e, className: t, ...n }) => {
1100
- let { goToNext: r, totalBranches: i } = mr();
1208
+ }, Nr = ({ children: e, className: t, ...n }) => {
1209
+ let { goToNext: r, totalBranches: i } = Or();
1101
1210
  return /* @__PURE__ */ Z(v, {
1102
1211
  "aria-label": "Next branch",
1103
1212
  disabled: i <= 1,
@@ -1106,12 +1215,12 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1106
1215
  type: "button",
1107
1216
  variant: "ghost",
1108
1217
  ...n,
1109
- children: e ?? /* @__PURE__ */ Z(Ve, { size: 14 })
1218
+ children: e ?? /* @__PURE__ */ Z(Ue, { size: 14 })
1110
1219
  });
1111
- }, br = ({ className: e, ...t }) => {
1112
- let { currentBranch: n, totalBranches: r } = mr();
1113
- return /* @__PURE__ */ Q(cr, {
1114
- className: G("border-none bg-transparent text-muted-foreground shadow-none", e),
1220
+ }, Pr = ({ className: e, ...t }) => {
1221
+ let { currentBranch: n, totalBranches: r } = Or();
1222
+ return /* @__PURE__ */ Q(Sr, {
1223
+ className: W("border-none bg-transparent text-muted-foreground shadow-none", e),
1115
1224
  ...t,
1116
1225
  children: [
1117
1226
  n + 1,
@@ -1119,15 +1228,15 @@ var lr = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Z("div", {
1119
1228
  r
1120
1229
  ]
1121
1230
  });
1122
- }, xr = a(({ className: e, ...t }) => /* @__PURE__ */ Z(Mt, {
1123
- className: G("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
1231
+ }, Fr = a(({ className: e, ...t }) => /* @__PURE__ */ Z(Nt, {
1232
+ className: W("size-full [&>*:first-child]:mt-0 [&>*:last-child]:mb-0", e),
1124
1233
  ...t
1125
1234
  }), (e, t) => e.children === t.children);
1126
- xr.displayName = "MessageResponse";
1127
- function Sr({ data: e, className: t, onRemove: n, ...r }) {
1235
+ Fr.displayName = "MessageResponse";
1236
+ function Ir({ data: e, className: t, onRemove: n, ...r }) {
1128
1237
  let i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1129
1238
  return /* @__PURE__ */ Z("div", {
1130
- className: G("group relative size-24 overflow-hidden rounded-lg", t),
1239
+ className: W("group relative size-24 overflow-hidden rounded-lg", t),
1131
1240
  ...r,
1132
1241
  children: a ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("img", {
1133
1242
  alt: i || "attachment",
@@ -1143,17 +1252,17 @@ function Sr({ data: e, className: t, onRemove: n, ...r }) {
1143
1252
  },
1144
1253
  type: "button",
1145
1254
  variant: "ghost",
1146
- children: [/* @__PURE__ */ Z(xt, {}), /* @__PURE__ */ Z("span", {
1255
+ children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
1147
1256
  className: "sr-only",
1148
1257
  children: "Remove"
1149
1258
  })]
1150
- })] }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(De, { children: [/* @__PURE__ */ Z(Ae, {
1259
+ })] }) : /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(Oe, { children: [/* @__PURE__ */ Z(je, {
1151
1260
  asChild: !0,
1152
1261
  children: /* @__PURE__ */ Z("div", {
1153
1262
  className: "flex size-full shrink-0 items-center justify-center rounded-lg bg-muted text-muted-foreground",
1154
- children: /* @__PURE__ */ Z(st, { className: "size-4" })
1263
+ children: /* @__PURE__ */ Z(ct, { className: "size-4" })
1155
1264
  })
1156
- }), /* @__PURE__ */ Z(Oe, { children: /* @__PURE__ */ Z("p", { children: o }) })] }), n && /* @__PURE__ */ Q(v, {
1265
+ }), /* @__PURE__ */ Z(ke, { children: /* @__PURE__ */ Z("p", { children: o }) })] }), n && /* @__PURE__ */ Q(v, {
1157
1266
  "aria-label": "Remove attachment",
1158
1267
  className: "size-6 shrink-0 rounded-full p-0 opacity-0 transition-opacity hover:bg-accent group-hover:opacity-100 [&>svg]:size-3",
1159
1268
  onClick: (e) => {
@@ -1161,36 +1270,36 @@ function Sr({ data: e, className: t, onRemove: n, ...r }) {
1161
1270
  },
1162
1271
  type: "button",
1163
1272
  variant: "ghost",
1164
- children: [/* @__PURE__ */ Z(xt, {}), /* @__PURE__ */ Z("span", {
1273
+ children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
1165
1274
  className: "sr-only",
1166
1275
  children: "Remove"
1167
1276
  })]
1168
1277
  })] })
1169
1278
  });
1170
1279
  }
1171
- function Cr({ children: e, className: t, ...n }) {
1280
+ function Lr({ children: e, className: t, ...n }) {
1172
1281
  return e ? /* @__PURE__ */ Z("div", {
1173
- className: G("ml-auto flex w-fit flex-wrap items-start gap-2", t),
1282
+ className: W("ml-auto flex w-fit flex-wrap items-start gap-2", t),
1174
1283
  ...n,
1175
1284
  children: e
1176
1285
  }) : null;
1177
1286
  }
1178
- var wr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
1179
- className: G("mt-4 flex w-full items-center justify-between gap-4", e),
1287
+ var Rr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z("div", {
1288
+ className: W("mt-4 flex w-full items-center justify-between gap-4", e),
1180
1289
  ...n,
1181
1290
  children: t
1182
1291
  });
1183
1292
  //#endregion
1184
1293
  //#region src/elements/ui/input-group.tsx
1185
- function Tr({ className: e, ...t }) {
1294
+ function zr({ className: e, ...t }) {
1186
1295
  return /* @__PURE__ */ Z("div", {
1187
1296
  "data-slot": "input-group",
1188
1297
  role: "group",
1189
- className: G("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
1298
+ className: W("group/input-group relative flex w-full items-center rounded-md border border-input shadow-xs transition-[color,box-shadow] outline-none dark:bg-input/30", "h-9 min-w-0 has-[>textarea]:h-auto", "has-[>[data-align=inline-start]]:[&>input]:pl-2", "has-[>[data-align=inline-end]]:[&>input]:pr-2", "has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>[data-align=block-start]]:[&>input]:pb-3", "has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3", "has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50", "has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-destructive/20 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40", e),
1190
1299
  ...t
1191
1300
  });
1192
1301
  }
1193
- var Er = At("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1302
+ var Br = jt("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4", {
1194
1303
  variants: { align: {
1195
1304
  "inline-start": "order-first pl-3 has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]",
1196
1305
  "inline-end": "order-last pr-3 has-[>button]:mr-[-0.45rem] has-[>kbd]:mr-[-0.35rem]",
@@ -1199,19 +1308,19 @@ var Er = At("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 te
1199
1308
  } },
1200
1309
  defaultVariants: { align: "inline-start" }
1201
1310
  });
1202
- function Dr({ className: e, align: t = "inline-start", ...n }) {
1311
+ function Vr({ className: e, align: t = "inline-start", ...n }) {
1203
1312
  return /* @__PURE__ */ Z("div", {
1204
1313
  role: "group",
1205
1314
  "data-slot": "input-group-addon",
1206
1315
  "data-align": t,
1207
- className: G(Er({ align: t }), e),
1316
+ className: W(Br({ align: t }), e),
1208
1317
  onClick: (e) => {
1209
1318
  e.target.closest("button") || e.currentTarget.parentElement?.querySelector("input")?.focus();
1210
1319
  },
1211
1320
  ...n
1212
1321
  });
1213
1322
  }
1214
- var Or = At("flex items-center gap-2 text-sm shadow-none", {
1323
+ var Hr = jt("flex items-center gap-2 text-sm shadow-none", {
1215
1324
  variants: { size: {
1216
1325
  xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-'])]:size-3.5",
1217
1326
  sm: "h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5",
@@ -1220,38 +1329,38 @@ var Or = At("flex items-center gap-2 text-sm shadow-none", {
1220
1329
  } },
1221
1330
  defaultVariants: { size: "xs" }
1222
1331
  });
1223
- function kr({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1332
+ function Ur({ className: e, type: t = "button", variant: n = "ghost", size: r = "xs", ...i }) {
1224
1333
  return /* @__PURE__ */ Z(v, {
1225
1334
  type: t,
1226
1335
  "data-size": r,
1227
1336
  variant: n,
1228
- className: G(Or({ size: r }), e),
1337
+ className: W(Hr({ size: r }), e),
1229
1338
  ...i
1230
1339
  });
1231
1340
  }
1232
- function Ar({ className: e, ...t }) {
1233
- return /* @__PURE__ */ Z(Ee, {
1341
+ function Wr({ className: e, ...t }) {
1342
+ return /* @__PURE__ */ Z(De, {
1234
1343
  "data-slot": "input-group-control",
1235
- className: G("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
1344
+ className: W("flex-1 resize-none rounded-none border-0 bg-transparent py-3 shadow-none focus-visible:ring-0 dark:bg-transparent", e),
1236
1345
  ...t
1237
1346
  });
1238
1347
  }
1239
1348
  //#endregion
1240
1349
  //#region src/elements/prompt-input.tsx
1241
- var jr = r(null), Mr = r(null), Nr = () => {
1242
- let e = s(jr);
1350
+ var Gr = r(null), Kr = r(null), qr = () => {
1351
+ let e = s(Gr);
1243
1352
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use usePromptInputController().");
1244
1353
  return e;
1245
- }, Pr = () => s(jr), Fr = () => {
1246
- let e = s(Mr);
1354
+ }, Jr = () => s(Gr), Yr = () => {
1355
+ let e = s(Kr);
1247
1356
  if (!e) throw Error("Wrap your component inside <PromptInputProvider> to use useProviderAttachments().");
1248
1357
  return e;
1249
- }, Ir = () => s(Mr);
1250
- function Lr({ initialInput: e = "", children: t }) {
1358
+ }, Xr = () => s(Kr);
1359
+ function Zr({ initialInput: e = "", children: t }) {
1251
1360
  let [n, r] = d(e), i = o(() => r(""), []), [a, s] = d([]), f = u(null), p = u(() => {}), m = o((e) => {
1252
1361
  let t = Array.from(e);
1253
1362
  t.length !== 0 && s((e) => e.concat(t.map((e) => ({
1254
- id: Nt(),
1363
+ id: Pt(),
1255
1364
  type: "file",
1256
1365
  url: URL.createObjectURL(e),
1257
1366
  mediaType: e.type,
@@ -1303,25 +1412,25 @@ function Lr({ initialInput: e = "", children: t }) {
1303
1412
  y,
1304
1413
  b
1305
1414
  ]);
1306
- return /* @__PURE__ */ Z(jr.Provider, {
1415
+ return /* @__PURE__ */ Z(Gr.Provider, {
1307
1416
  value: x,
1308
- children: /* @__PURE__ */ Z(Mr.Provider, {
1417
+ children: /* @__PURE__ */ Z(Kr.Provider, {
1309
1418
  value: y,
1310
1419
  children: t
1311
1420
  })
1312
1421
  });
1313
1422
  }
1314
- var Rr = r(null), zr = () => {
1315
- let e = Ir(), t = s(Rr), n = e ?? t;
1423
+ var Qr = r(null), $r = () => {
1424
+ let e = Xr(), t = s(Qr), n = e ?? t;
1316
1425
  if (!n) throw Error("usePromptInputAttachments must be used within a PromptInput or PromptInputProvider");
1317
1426
  return n;
1318
1427
  };
1319
- function Br({ data: e, className: t, ...n }) {
1320
- let r = zr(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1321
- return /* @__PURE__ */ Q(si, { children: [/* @__PURE__ */ Z(oe, {
1428
+ function ei({ data: e, className: t, ...n }) {
1429
+ let r = $r(), i = e.filename || "", a = (e.mediaType?.startsWith("image/") && e.url ? "image" : "file") == "image", o = i || (a ? "Image" : "Attachment");
1430
+ return /* @__PURE__ */ Q(xi, { children: [/* @__PURE__ */ Z(oe, {
1322
1431
  asChild: !0,
1323
1432
  children: /* @__PURE__ */ Q("div", {
1324
- className: G("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
1433
+ className: W("group relative flex h-8 cursor-pointer select-none items-center gap-1.5 rounded-md border border-border px-1.5 font-medium text-sm transition-all hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50", t),
1325
1434
  ...n,
1326
1435
  children: [/* @__PURE__ */ Q("div", {
1327
1436
  className: "relative size-5 shrink-0",
@@ -1335,7 +1444,7 @@ function Br({ data: e, className: t, ...n }) {
1335
1444
  width: 20
1336
1445
  }) : /* @__PURE__ */ Z("div", {
1337
1446
  className: "flex size-5 items-center justify-center text-muted-foreground",
1338
- children: /* @__PURE__ */ Z(st, { className: "size-3" })
1447
+ children: /* @__PURE__ */ Z(ct, { className: "size-3" })
1339
1448
  })
1340
1449
  }), /* @__PURE__ */ Q(v, {
1341
1450
  "aria-label": "Remove attachment",
@@ -1345,7 +1454,7 @@ function Br({ data: e, className: t, ...n }) {
1345
1454
  },
1346
1455
  type: "button",
1347
1456
  variant: "ghost",
1348
- children: [/* @__PURE__ */ Z(xt, {}), /* @__PURE__ */ Z("span", {
1457
+ children: [/* @__PURE__ */ Z(Y, {}), /* @__PURE__ */ Z("span", {
1349
1458
  className: "sr-only",
1350
1459
  children: "Remove"
1351
1460
  })]
@@ -1355,7 +1464,7 @@ function Br({ data: e, className: t, ...n }) {
1355
1464
  children: o
1356
1465
  })]
1357
1466
  }, e.id)
1358
- }), /* @__PURE__ */ Z(li, {
1467
+ }), /* @__PURE__ */ Z(Ci, {
1359
1468
  className: "w-auto p-2",
1360
1469
  children: /* @__PURE__ */ Q("div", {
1361
1470
  className: "w-auto space-y-3",
@@ -1384,29 +1493,29 @@ function Br({ data: e, className: t, ...n }) {
1384
1493
  })
1385
1494
  })] });
1386
1495
  }
1387
- function Vr({ children: e, className: t, ...r }) {
1388
- let i = zr();
1496
+ function ti({ children: e, className: t, ...r }) {
1497
+ let i = $r();
1389
1498
  return i.files.length ? /* @__PURE__ */ Z("div", {
1390
- className: G("flex flex-wrap items-center gap-2 p-3 w-full", t),
1499
+ className: W("flex flex-wrap items-center gap-2 p-3 w-full", t),
1391
1500
  ...r,
1392
1501
  children: i.files.map((t) => /* @__PURE__ */ Z(n, { children: e(t) }, t.id))
1393
1502
  }) : null;
1394
1503
  }
1395
- var Hr = ({ label: e = "Add photos or files", ...t }) => {
1396
- let n = zr();
1504
+ var ni = ({ label: e = "Add photos or files", ...t }) => {
1505
+ let n = $r();
1397
1506
  return /* @__PURE__ */ Q(F, {
1398
1507
  ...t,
1399
1508
  onSelect: (e) => {
1400
1509
  e.preventDefault(), n.openFileDialog();
1401
1510
  },
1402
1511
  children: [
1403
- /* @__PURE__ */ Z(et, { className: "mr-2 size-4" }),
1512
+ /* @__PURE__ */ Z(nt, { className: "mr-2 size-4" }),
1404
1513
  " ",
1405
1514
  e
1406
1515
  ]
1407
1516
  });
1408
- }, Ur = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
1409
- let _ = Pr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1517
+ }, ri = ({ className: e, accept: t, multiple: n, fileInputLabel: r = "Upload files", globalDrop: i, syncHiddenInput: a, maxFiles: s, maxFileSize: f, onError: p, onSubmit: m, children: h, ...g }) => {
1518
+ let _ = Jr(), v = !!_, y = u(null), b = u(null), [x, S] = d([]), C = v ? _.attachments.files : x, w = u(C);
1410
1519
  w.current = C;
1411
1520
  let T = o(() => {
1412
1521
  y.current?.click();
@@ -1441,7 +1550,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1441
1550
  });
1442
1551
  let i = [];
1443
1552
  for (let e of n) i.push({
1444
- id: Nt(),
1553
+ id: Pt(),
1445
1554
  type: "file",
1446
1555
  url: URL.createObjectURL(e),
1447
1556
  mediaType: e.type,
@@ -1528,7 +1637,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1528
1637
  title: r,
1529
1638
  type: "file"
1530
1639
  }), /* @__PURE__ */ Z("form", {
1531
- className: G("w-full", e),
1640
+ className: W("w-full", e),
1532
1641
  onSubmit: (e) => {
1533
1642
  e.preventDefault();
1534
1643
  let t = e.currentTarget, n = v ? _.textInput.value : new FormData(t).get("message") || "";
@@ -1555,20 +1664,20 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1555
1664
  },
1556
1665
  ref: b,
1557
1666
  ...g,
1558
- children: /* @__PURE__ */ Z(Tr, {
1667
+ children: /* @__PURE__ */ Z(zr, {
1559
1668
  className: "overflow-hidden",
1560
1669
  children: h
1561
1670
  })
1562
1671
  })] });
1563
- return v ? I : /* @__PURE__ */ Z(Rr.Provider, {
1672
+ return v ? I : /* @__PURE__ */ Z(Qr.Provider, {
1564
1673
  value: F,
1565
1674
  children: I
1566
1675
  });
1567
- }, Wr = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1568
- className: G("contents", e),
1676
+ }, ii = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1677
+ className: W("contents", e),
1569
1678
  ...t
1570
- }), Gr = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1571
- let i = Pr(), a = zr(), [o, s] = d(!1), c = (e) => {
1679
+ }), ai = ({ onChange: e, className: t, placeholder: n = "What would you like to know?", ...r }) => {
1680
+ let i = Jr(), a = $r(), [o, s] = d(!1), c = (e) => {
1572
1681
  if (e.key === "Enter") {
1573
1682
  if (o || e.nativeEvent.isComposing || e.shiftKey) return;
1574
1683
  e.preventDefault();
@@ -1596,8 +1705,8 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1596
1705
  i.textInput.setInput(t.currentTarget.value), e?.(t);
1597
1706
  }
1598
1707
  } : { onChange: e };
1599
- return /* @__PURE__ */ Z(Ar, {
1600
- className: G("field-sizing-content max-h-48 min-h-16", t),
1708
+ return /* @__PURE__ */ Z(Wr, {
1709
+ className: W("field-sizing-content max-h-48 min-h-16", t),
1601
1710
  name: "message",
1602
1711
  onCompositionEnd: () => s(!1),
1603
1712
  onCompositionStart: () => s(!0),
@@ -1607,52 +1716,52 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1607
1716
  ...r,
1608
1717
  ...u
1609
1718
  });
1610
- }, Kr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Dr, {
1719
+ }, oi = ({ className: e, ...t }) => /* @__PURE__ */ Z(Vr, {
1611
1720
  align: "block-end",
1612
- className: G("order-first flex-wrap gap-1", e),
1721
+ className: W("order-first flex-wrap gap-1", e),
1613
1722
  ...t
1614
- }), qr = ({ className: e, ...t }) => /* @__PURE__ */ Z(Dr, {
1723
+ }), si = ({ className: e, ...t }) => /* @__PURE__ */ Z(Vr, {
1615
1724
  align: "block-end",
1616
- className: G("justify-between gap-1", e),
1725
+ className: W("justify-between gap-1", e),
1617
1726
  ...t
1618
- }), Jr = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1619
- className: G("flex items-center gap-1", e),
1727
+ }), ci = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1728
+ className: W("flex items-center gap-1", e),
1620
1729
  ...t
1621
- }), Yr = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1730
+ }), li = ({ variant: e = "ghost", className: n, size: r, ...i }) => {
1622
1731
  let a = r ?? (t.count(i.children) > 1 ? "sm" : "icon-sm");
1623
- return /* @__PURE__ */ Z(kr, {
1624
- className: G(n),
1732
+ return /* @__PURE__ */ Z(Ur, {
1733
+ className: W(n),
1625
1734
  size: a,
1626
1735
  type: "button",
1627
1736
  variant: e,
1628
1737
  ...i
1629
1738
  });
1630
- }, Xr = (e) => /* @__PURE__ */ Z(ee, { ...e }), Zr = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(I, {
1739
+ }, ui = (e) => /* @__PURE__ */ Z(ee, { ...e }), di = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(I, {
1631
1740
  asChild: !0,
1632
- children: /* @__PURE__ */ Z(Yr, {
1741
+ children: /* @__PURE__ */ Z(li, {
1633
1742
  className: e,
1634
1743
  ...n,
1635
- children: t ?? /* @__PURE__ */ Z(ct, { className: "size-4" })
1744
+ children: t ?? /* @__PURE__ */ Z(lt, { className: "size-4" })
1636
1745
  })
1637
- }), Qr = ({ className: e, ...t }) => /* @__PURE__ */ Z(P, {
1746
+ }), fi = ({ className: e, ...t }) => /* @__PURE__ */ Z(P, {
1638
1747
  align: "start",
1639
- className: G(e),
1748
+ className: W(e),
1640
1749
  ...t
1641
- }), $r = ({ className: e, ...t }) => /* @__PURE__ */ Z(F, {
1642
- className: G(e),
1750
+ }), pi = ({ className: e, ...t }) => /* @__PURE__ */ Z(F, {
1751
+ className: W(e),
1643
1752
  ...t
1644
- }), ei = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1645
- let o = /* @__PURE__ */ Z(J, { className: "size-4" });
1646
- return r === "submitted" ? o = /* @__PURE__ */ Z(rt, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Z(mt, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Z(xt, { className: "size-4" })), /* @__PURE__ */ Z(kr, {
1753
+ }), mi = ({ className: e, variant: t = "default", size: n = "icon-sm", status: r, children: i, ...a }) => {
1754
+ let o = /* @__PURE__ */ Z(Ze, { className: "size-4" });
1755
+ return r === "submitted" ? o = /* @__PURE__ */ Z(at, { className: "size-4 animate-spin" }) : r === "streaming" ? o = /* @__PURE__ */ Z(ht, { className: "size-4" }) : r === "error" && (o = /* @__PURE__ */ Z(Y, { className: "size-4" })), /* @__PURE__ */ Z(Ur, {
1647
1756
  "aria-label": "Submit",
1648
- className: G(e),
1757
+ className: W(e),
1649
1758
  size: n,
1650
1759
  type: "submit",
1651
1760
  variant: t,
1652
1761
  ...a,
1653
1762
  children: i ?? o
1654
1763
  });
1655
- }, ti = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1764
+ }, hi = ({ className: e, textareaRef: t, onTranscriptionChange: n, ...r }) => {
1656
1765
  let [i, a] = d(!1), [s, l] = d(null), f = u(null);
1657
1766
  c(() => {
1658
1767
  if (typeof window < "u" && ("SpeechRecognition" in window || "webkitSpeechRecognition" in window)) {
@@ -1682,80 +1791,80 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1682
1791
  let p = o(() => {
1683
1792
  s && (i ? s.stop() : s.start());
1684
1793
  }, [s, i]);
1685
- return /* @__PURE__ */ Z(Yr, {
1686
- className: G("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1794
+ return /* @__PURE__ */ Z(li, {
1795
+ className: W("relative transition-all duration-200", i && "animate-pulse bg-accent text-accent-foreground", e),
1687
1796
  disabled: !s,
1688
1797
  onClick: p,
1689
1798
  ...r,
1690
- children: /* @__PURE__ */ Z(at, { className: "size-4" })
1799
+ children: /* @__PURE__ */ Z(st, { className: "size-4" })
1691
1800
  });
1692
- }, ni = (e) => /* @__PURE__ */ Z(se, { ...e }), ri = ({ className: e, ...t }) => /* @__PURE__ */ Z(ue, {
1693
- className: G("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
1801
+ }, gi = (e) => /* @__PURE__ */ Z(ce, { ...e }), _i = ({ className: e, ...t }) => /* @__PURE__ */ Z(de, {
1802
+ className: W("border-none bg-transparent font-medium text-muted-foreground shadow-none transition-colors", "hover:bg-accent hover:text-foreground aria-expanded:bg-accent aria-expanded:text-foreground", e),
1694
1803
  ...t
1695
- }), ii = ({ className: e, ...t }) => /* @__PURE__ */ Z(ce, {
1696
- className: G(e),
1804
+ }), vi = ({ className: e, ...t }) => /* @__PURE__ */ Z(le, {
1805
+ className: W(e),
1697
1806
  ...t
1698
- }), ai = ({ className: e, ...t }) => /* @__PURE__ */ Z(le, {
1699
- className: G(e),
1807
+ }), yi = ({ className: e, ...t }) => /* @__PURE__ */ Z(ue, {
1808
+ className: W(e),
1700
1809
  ...t
1701
- }), oi = ({ className: e, ...t }) => /* @__PURE__ */ Z(de, {
1702
- className: G(e),
1810
+ }), bi = ({ className: e, ...t }) => /* @__PURE__ */ Z(fe, {
1811
+ className: W(e),
1703
1812
  ...t
1704
- }), si = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Z(R, {
1813
+ }), xi = ({ openDelay: e = 0, closeDelay: t = 0, ...n }) => /* @__PURE__ */ Z(R, {
1705
1814
  closeDelay: t,
1706
1815
  openDelay: e,
1707
1816
  ...n
1708
- }), ci = (e) => /* @__PURE__ */ Z(oe, { ...e }), li = ({ align: e = "start", ...t }) => /* @__PURE__ */ Z(ae, {
1817
+ }), Si = (e) => /* @__PURE__ */ Z(oe, { ...e }), Ci = ({ align: e = "start", ...t }) => /* @__PURE__ */ Z(ae, {
1709
1818
  align: e,
1710
1819
  ...t
1711
- }), ui = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1712
- className: G(e),
1820
+ }), wi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1821
+ className: W(e),
1713
1822
  ...t
1714
- }), di = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1715
- className: G(e),
1823
+ }), Ti = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1824
+ className: W(e),
1716
1825
  ...t
1717
- }), fi = ({ className: e, ...t }) => /* @__PURE__ */ Z("h3", {
1718
- className: G("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1826
+ }), Ei = ({ className: e, ...t }) => /* @__PURE__ */ Z("h3", {
1827
+ className: W("mb-2 px-3 font-medium text-muted-foreground text-xs", e),
1719
1828
  ...t
1720
- }), pi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1721
- className: G("space-y-1", e),
1829
+ }), Di = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1830
+ className: W("space-y-1", e),
1722
1831
  ...t
1723
- }), mi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1724
- className: G("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1832
+ }), Oi = ({ className: e, ...t }) => /* @__PURE__ */ Z("div", {
1833
+ className: W("flex items-center gap-2 px-3 py-2 text-xs hover:bg-accent", e),
1725
1834
  ...t
1726
- }), hi = ({ className: e, ...t }) => /* @__PURE__ */ Z(D, {
1727
- className: G(e),
1835
+ }), ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(D, {
1836
+ className: W(e),
1728
1837
  ...t
1729
- }), gi = ({ className: e, ...t }) => /* @__PURE__ */ Z(A, {
1730
- className: G(e),
1838
+ }), Ai = ({ className: e, ...t }) => /* @__PURE__ */ Z(A, {
1839
+ className: W(e),
1731
1840
  ...t
1732
- }), _i = ({ className: e, ...t }) => /* @__PURE__ */ Z(M, {
1733
- className: G(e),
1841
+ }), ji = ({ className: e, ...t }) => /* @__PURE__ */ Z(M, {
1842
+ className: W(e),
1734
1843
  ...t
1735
- }), vi = ({ className: e, ...t }) => /* @__PURE__ */ Z(O, {
1736
- className: G(e),
1844
+ }), Mi = ({ className: e, ...t }) => /* @__PURE__ */ Z(O, {
1845
+ className: W(e),
1737
1846
  ...t
1738
- }), yi = ({ className: e, ...t }) => /* @__PURE__ */ Z(k, {
1739
- className: G(e),
1847
+ }), Ni = ({ className: e, ...t }) => /* @__PURE__ */ Z(k, {
1848
+ className: W(e),
1740
1849
  ...t
1741
- }), bi = ({ className: e, ...t }) => /* @__PURE__ */ Z(j, {
1742
- className: G(e),
1850
+ }), Pi = ({ className: e, ...t }) => /* @__PURE__ */ Z(j, {
1851
+ className: W(e),
1743
1852
  ...t
1744
- }), xi = ({ className: e, ...t }) => /* @__PURE__ */ Z(N, {
1745
- className: G(e),
1853
+ }), Fi = ({ className: e, ...t }) => /* @__PURE__ */ Z(N, {
1854
+ className: W(e),
1746
1855
  ...t
1747
- }), Si = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(V, {
1856
+ }), Ii = ({ className: e, children: t, ...n }) => /* @__PURE__ */ Q(se, {
1748
1857
  className: "w-full overflow-x-auto whitespace-nowrap",
1749
1858
  ...n,
1750
1859
  children: [/* @__PURE__ */ Z("div", {
1751
- className: G("flex w-max flex-nowrap items-center gap-2", e),
1860
+ className: W("flex w-max flex-nowrap items-center gap-2", e),
1752
1861
  children: t
1753
- }), /* @__PURE__ */ Z(H, {
1862
+ }), /* @__PURE__ */ Z(V, {
1754
1863
  className: "hidden",
1755
1864
  orientation: "horizontal"
1756
1865
  })]
1757
- }), Ci = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Z(v, {
1758
- className: G("cursor-pointer rounded-full px-4", n),
1866
+ }), Li = ({ suggestion: e, onClick: t, className: n, variant: r = "outline", size: i = "sm", children: a, ...o }) => /* @__PURE__ */ Z(v, {
1867
+ className: W("cursor-pointer rounded-full px-4", n),
1759
1868
  onClick: () => {
1760
1869
  t?.(e);
1761
1870
  },
@@ -1764,7 +1873,7 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1764
1873
  variant: r,
1765
1874
  ...o,
1766
1875
  children: a || e
1767
- }), wi = r({ code: "" }), Ti = {
1876
+ }), Ri = r({ code: "" }), zi = {
1768
1877
  name: "line-numbers",
1769
1878
  line(e, t) {
1770
1879
  e.children.unshift({
@@ -1785,21 +1894,21 @@ var Hr = ({ label: e = "Add photos or files", ...t }) => {
1785
1894
  });
1786
1895
  }
1787
1896
  };
1788
- async function Ei(e, t, n = !1) {
1789
- let r = n ? [Ti] : [];
1790
- return await Promise.all([Pt(e, {
1897
+ async function Bi(e, t, n = !1) {
1898
+ let r = n ? [zi] : [];
1899
+ return await Promise.all([Ft(e, {
1791
1900
  lang: t,
1792
1901
  theme: "one-light",
1793
1902
  transformers: r
1794
- }), Pt(e, {
1903
+ }), Ft(e, {
1795
1904
  lang: t,
1796
1905
  theme: "one-dark-pro",
1797
1906
  transformers: r
1798
1907
  })]);
1799
1908
  }
1800
- var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1909
+ var Vi = ({ code: e, language: t, showLineNumbers: n = !1, className: r, children: i, ...a }) => {
1801
1910
  let [o, s] = d(""), [l, f] = d(""), p = u(!1);
1802
- return c(() => (Ei(e, t, n).then(([e, t]) => {
1911
+ return c(() => (Bi(e, t, n).then(([e, t]) => {
1803
1912
  p.current ||= (s(e), f(t), !0);
1804
1913
  }), () => {
1805
1914
  p.current = !1;
@@ -1807,10 +1916,10 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1807
1916
  e,
1808
1917
  t,
1809
1918
  n
1810
- ]), /* @__PURE__ */ Z(wi.Provider, {
1919
+ ]), /* @__PURE__ */ Z(Ri.Provider, {
1811
1920
  value: { code: e },
1812
1921
  children: /* @__PURE__ */ Z("div", {
1813
- className: G("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
1922
+ className: W("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", r),
1814
1923
  ...a,
1815
1924
  children: /* @__PURE__ */ Q("div", {
1816
1925
  className: "relative",
@@ -1831,8 +1940,8 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1831
1940
  })
1832
1941
  })
1833
1942
  });
1834
- }, Oi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1835
- let [o, c] = d(!1), { code: l } = s(wi), u = async () => {
1943
+ }, Hi = ({ onCopy: e, onError: t, timeout: n = 2e3, children: r, className: i, ...a }) => {
1944
+ let [o, c] = d(!1), { code: l } = s(Ri), u = async () => {
1836
1945
  if (typeof window > "u" || !navigator?.clipboard?.writeText) {
1837
1946
  t?.(/* @__PURE__ */ Error("Clipboard API not available"));
1838
1947
  return;
@@ -1842,29 +1951,29 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1842
1951
  } catch (e) {
1843
1952
  t?.(e);
1844
1953
  }
1845
- }, f = o ? Re : Je;
1954
+ }, f = o ? Be : Ye;
1846
1955
  return /* @__PURE__ */ Z(v, {
1847
- className: G("shrink-0", i),
1956
+ className: W("shrink-0", i),
1848
1957
  onClick: u,
1849
1958
  size: "icon",
1850
1959
  variant: "ghost",
1851
1960
  ...a,
1852
1961
  children: r ?? /* @__PURE__ */ Z(f, { size: 14 })
1853
1962
  });
1854
- }, ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
1855
- className: G("not-prose mb-4 w-full rounded-md border", e),
1963
+ }, Ui = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
1964
+ className: W("not-prose mb-4 w-full rounded-md border", e),
1856
1965
  ...t
1857
- }), Ai = (e) => /* @__PURE__ */ Q(_, {
1966
+ }), Wi = (e) => /* @__PURE__ */ Q(_, {
1858
1967
  className: "gap-1.5 rounded-full text-xs",
1859
1968
  variant: "secondary",
1860
1969
  children: [{
1861
- "input-streaming": /* @__PURE__ */ Z(He, { className: "size-4" }),
1862
- "input-available": /* @__PURE__ */ Z(Ke, { className: "size-4 animate-pulse" }),
1863
- "approval-requested": /* @__PURE__ */ Z(Ke, { className: "size-4 text-yellow-600" }),
1864
- "approval-responded": /* @__PURE__ */ Z(q, { className: "size-4 text-blue-600" }),
1865
- "output-available": /* @__PURE__ */ Z(q, { className: "size-4 text-green-600" }),
1866
- "output-error": /* @__PURE__ */ Z(bt, { className: "size-4 text-red-600" }),
1867
- "output-denied": /* @__PURE__ */ Z(bt, { className: "size-4 text-orange-600" })
1970
+ "input-streaming": /* @__PURE__ */ Z(K, { className: "size-4" }),
1971
+ "input-available": /* @__PURE__ */ Z(qe, { className: "size-4 animate-pulse" }),
1972
+ "approval-requested": /* @__PURE__ */ Z(qe, { className: "size-4 text-yellow-600" }),
1973
+ "approval-responded": /* @__PURE__ */ Z(ze, { className: "size-4 text-blue-600" }),
1974
+ "output-available": /* @__PURE__ */ Z(ze, { className: "size-4 text-green-600" }),
1975
+ "output-error": /* @__PURE__ */ Z(xt, { className: "size-4 text-red-600" }),
1976
+ "output-denied": /* @__PURE__ */ Z(xt, { className: "size-4 text-orange-600" })
1868
1977
  }[e], {
1869
1978
  "input-streaming": "Pending",
1870
1979
  "input-available": "Running",
@@ -1874,61 +1983,61 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1874
1983
  "output-error": "Error",
1875
1984
  "output-denied": "Denied"
1876
1985
  }[e]]
1877
- }), ji = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ Q(E, {
1878
- className: G("flex w-full items-center justify-between gap-4 p-3", e),
1986
+ }), Gi = ({ className: e, title: t, type: n, state: r, ...i }) => /* @__PURE__ */ Q(E, {
1987
+ className: W("flex w-full items-center justify-between gap-4 p-3", e),
1879
1988
  ...i,
1880
1989
  children: [/* @__PURE__ */ Q("div", {
1881
1990
  className: "flex items-center gap-2",
1882
1991
  children: [
1883
- /* @__PURE__ */ Z(vt, { className: "size-4 text-muted-foreground" }),
1992
+ /* @__PURE__ */ Z(yt, { className: "size-4 text-muted-foreground" }),
1884
1993
  /* @__PURE__ */ Z("span", {
1885
1994
  className: "font-medium text-sm",
1886
1995
  children: t ?? n.split("-").slice(1).join("-")
1887
1996
  }),
1888
- Ai(r)
1997
+ Wi(r)
1889
1998
  ]
1890
- }), /* @__PURE__ */ Z(ze, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
1891
- }), Mi = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
1892
- className: G("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1999
+ }), /* @__PURE__ */ Z(Ve, { className: "size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180" })]
2000
+ }), Ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
2001
+ className: W("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
1893
2002
  ...t
1894
- }), Ni = ({ className: e, input: t, ...n }) => /* @__PURE__ */ Q("div", {
1895
- className: G("space-y-2 overflow-hidden p-4", e),
2003
+ }), qi = ({ className: e, input: t, ...n }) => /* @__PURE__ */ Q("div", {
2004
+ className: W("space-y-2 overflow-hidden p-4", e),
1896
2005
  ...n,
1897
2006
  children: [/* @__PURE__ */ Z("h4", {
1898
2007
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1899
2008
  children: "Parameters"
1900
2009
  }), /* @__PURE__ */ Z("div", {
1901
2010
  className: "rounded-md bg-muted/50",
1902
- children: /* @__PURE__ */ Z(Di, {
2011
+ children: /* @__PURE__ */ Z(Vi, {
1903
2012
  code: JSON.stringify(t, null, 2),
1904
2013
  language: "json"
1905
2014
  })
1906
2015
  })]
1907
- }), Pi = ({ className: e, output: t, errorText: n, ...r }) => {
2016
+ }), Ji = ({ className: e, output: t, errorText: n, ...r }) => {
1908
2017
  if (!(t || n)) return null;
1909
2018
  let a = /* @__PURE__ */ Z("div", { children: t });
1910
- return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(Di, {
2019
+ return typeof t == "object" && !i(t) ? a = /* @__PURE__ */ Z(Vi, {
1911
2020
  code: JSON.stringify(t, null, 2),
1912
2021
  language: "json"
1913
- }) : typeof t == "string" && (a = /* @__PURE__ */ Z(Di, {
2022
+ }) : typeof t == "string" && (a = /* @__PURE__ */ Z(Vi, {
1914
2023
  code: t,
1915
2024
  language: "json"
1916
2025
  })), /* @__PURE__ */ Q("div", {
1917
- className: G("space-y-2 p-4", e),
2026
+ className: W("space-y-2 p-4", e),
1918
2027
  ...r,
1919
2028
  children: [/* @__PURE__ */ Z("h4", {
1920
2029
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
1921
2030
  children: n ? "Error" : "Result"
1922
2031
  }), /* @__PURE__ */ Q("div", {
1923
- className: G("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
2032
+ className: W("overflow-x-auto rounded-md text-xs [&_table]:w-full", n ? "bg-destructive/10 text-destructive" : "bg-muted/50 text-foreground"),
1924
2033
  children: [n && /* @__PURE__ */ Z("div", { children: n }), a]
1925
2034
  })]
1926
2035
  });
1927
- }, Fi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
1928
- let a = l(() => It.create(t), [t]), o = l(() => (e?.length ?? 0) * i, [e, i]);
2036
+ }, Yi = a(({ children: e, as: t = "p", className: n, duration: r = 2, spread: i = 2 }) => {
2037
+ let a = l(() => Lt.create(t), [t]), o = l(() => (e?.length ?? 0) * i, [e, i]);
1929
2038
  return /* @__PURE__ */ Z(a, {
1930
2039
  animate: { backgroundPosition: "0% center" },
1931
- className: G("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
2040
+ className: W("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent", "[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]", n),
1932
2041
  initial: { backgroundPosition: "100% center" },
1933
2042
  style: {
1934
2043
  "--spread": `${o}px`,
@@ -1941,21 +2050,21 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1941
2050
  },
1942
2051
  children: e
1943
2052
  });
1944
- }), Ii = r(null), Li = () => {
1945
- let e = s(Ii);
2053
+ }), Xi = r(null), Zi = () => {
2054
+ let e = s(Xi);
1946
2055
  if (!e) throw Error("Reasoning components must be used within Reasoning");
1947
2056
  return e;
1948
- }, Ri = 1e3, zi = 1e3, Bi = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
1949
- let [l, u] = Ft({
2057
+ }, Qi = 1e3, $i = 1e3, ea = a(({ className: e, isStreaming: t = !1, open: n, defaultOpen: r = !0, onOpenChange: i, duration: a, children: o, ...s }) => {
2058
+ let [l, u] = It({
1950
2059
  prop: n,
1951
2060
  defaultProp: r,
1952
2061
  onChange: i
1953
- }), [f, p] = Ft({
2062
+ }), [f, p] = It({
1954
2063
  prop: a,
1955
2064
  defaultProp: void 0
1956
2065
  }), [m, h] = d(!1), [g, _] = d(null);
1957
2066
  return c(() => {
1958
- t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / zi)), _(null));
2067
+ t ? g === null && _(Date.now()) : g !== null && (p(Math.ceil((Date.now() - g) / $i)), _(null));
1959
2068
  }, [
1960
2069
  t,
1961
2070
  g,
@@ -1964,7 +2073,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1964
2073
  if (r && !t && l && !m) {
1965
2074
  let e = setTimeout(() => {
1966
2075
  u(!1), h(!0);
1967
- }, Ri);
2076
+ }, Qi);
1968
2077
  return () => clearTimeout(e);
1969
2078
  }
1970
2079
  }, [
@@ -1973,7 +2082,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1973
2082
  r,
1974
2083
  u,
1975
2084
  m
1976
- ]), /* @__PURE__ */ Z(Ii.Provider, {
2085
+ ]), /* @__PURE__ */ Z(Xi.Provider, {
1977
2086
  value: {
1978
2087
  isStreaming: t,
1979
2088
  isOpen: l,
@@ -1981,7 +2090,7 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1981
2090
  duration: f
1982
2091
  },
1983
2092
  children: /* @__PURE__ */ Z(w, {
1984
- className: G("not-prose mb-4", e),
2093
+ className: W("not-prose mb-4", e),
1985
2094
  onOpenChange: (e) => {
1986
2095
  u(e);
1987
2096
  },
@@ -1990,37 +2099,37 @@ var Di = ({ code: e, language: t, showLineNumbers: n = !1, className: r, childre
1990
2099
  children: o
1991
2100
  })
1992
2101
  });
1993
- }), Vi = (e, t) => e || t === 0 ? /* @__PURE__ */ Z(Fi, {
2102
+ }), ta = (e, t) => e || t === 0 ? /* @__PURE__ */ Z(Yi, {
1994
2103
  duration: 1,
1995
2104
  children: "Thinking..."
1996
2105
  }) : t === void 0 ? /* @__PURE__ */ Z("p", { children: "Thought for a few seconds" }) : /* @__PURE__ */ Q("p", { children: [
1997
2106
  "Thought for ",
1998
2107
  t,
1999
2108
  " seconds"
2000
- ] }), Hi = a(({ className: e, children: t, getThinkingMessage: n = Vi, ...r }) => {
2001
- let { isStreaming: i, isOpen: a, duration: o } = Li();
2109
+ ] }), na = a(({ className: e, children: t, getThinkingMessage: n = ta, ...r }) => {
2110
+ let { isStreaming: i, isOpen: a, duration: o } = Zi();
2002
2111
  return /* @__PURE__ */ Z(E, {
2003
- className: G("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
2112
+ className: W("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground", e),
2004
2113
  ...r,
2005
2114
  children: t ?? /* @__PURE__ */ Q(X, { children: [
2006
- /* @__PURE__ */ Z(Ie, { className: "size-4" }),
2115
+ /* @__PURE__ */ Z(Le, { className: "size-4" }),
2007
2116
  n(i, o),
2008
- /* @__PURE__ */ Z(ze, { className: G("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
2117
+ /* @__PURE__ */ Z(Ve, { className: W("size-4 transition-transform", a ? "rotate-180" : "rotate-0") })
2009
2118
  ] })
2010
2119
  });
2011
- }), Ui = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(T, {
2012
- className: G("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
2120
+ }), ra = a(({ className: e, children: t, ...n }) => /* @__PURE__ */ Z(T, {
2121
+ className: W("mt-4 text-sm", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-muted-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
2013
2122
  ...n,
2014
- children: /* @__PURE__ */ Z(Mt, { children: t })
2123
+ children: /* @__PURE__ */ Z(Nt, { children: t })
2015
2124
  }));
2016
- Bi.displayName = "Reasoning", Hi.displayName = "ReasoningTrigger", Ui.displayName = "ReasoningContent";
2125
+ ea.displayName = "Reasoning", na.displayName = "ReasoningTrigger", ra.displayName = "ReasoningContent";
2017
2126
  //#endregion
2018
2127
  //#region src/elements/sources.tsx
2019
- var Wi = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
2020
- className: G("not-prose mb-4 text-primary text-xs", e),
2128
+ var ia = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
2129
+ className: W("not-prose mb-4 text-primary text-xs", e),
2021
2130
  ...t
2022
- }), Gi = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Z(E, {
2023
- className: G("flex items-center gap-2", e),
2131
+ }), aa = ({ className: e, count: t, children: n, ...r }) => /* @__PURE__ */ Z(E, {
2132
+ className: W("flex items-center gap-2", e),
2024
2133
  ...r,
2025
2134
  children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q("p", {
2026
2135
  className: "font-medium",
@@ -2029,24 +2138,24 @@ var Wi = ({ className: e, ...t }) => /* @__PURE__ */ Z(w, {
2029
2138
  t,
2030
2139
  " sources"
2031
2140
  ]
2032
- }), /* @__PURE__ */ Z(ze, { className: "h-4 w-4" })] })
2033
- }), Ki = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
2034
- className: G("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
2141
+ }), /* @__PURE__ */ Z(Ve, { className: "h-4 w-4" })] })
2142
+ }), oa = ({ className: e, ...t }) => /* @__PURE__ */ Z(T, {
2143
+ className: W("mt-3 flex w-fit flex-col gap-2", "data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 outline-none data-[state=closed]:animate-out data-[state=open]:animate-in", e),
2035
2144
  ...t
2036
- }), qi = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Z("a", {
2145
+ }), sa = ({ href: e, title: t, children: n, ...r }) => /* @__PURE__ */ Z("a", {
2037
2146
  className: "flex items-center gap-2",
2038
2147
  href: e,
2039
2148
  rel: "noreferrer",
2040
2149
  target: "_blank",
2041
2150
  ...r,
2042
- children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(Pe, { className: "h-4 w-4" }), /* @__PURE__ */ Z("span", {
2151
+ children: n ?? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z(Fe, { className: "h-4 w-4" }), /* @__PURE__ */ Z("span", {
2043
2152
  className: "block font-medium",
2044
2153
  children: t
2045
2154
  })] })
2046
2155
  });
2047
2156
  //#endregion
2048
2157
  //#region src/ChatbotEnhanced.tsx
2049
- function Ji(e) {
2158
+ function ca(e) {
2050
2159
  let t = e ?? {}, n = t.data && typeof t.data == "object" ? t.data : t, r = n.seedApplied, i = n.probes;
2051
2160
  if (!r && !i) return;
2052
2161
  let a = {};
@@ -2060,10 +2169,10 @@ function Ji(e) {
2060
2169
  message: String(e.message)
2061
2170
  }))), a;
2062
2171
  }
2063
- function Yi(e) {
2172
+ function la(e) {
2064
2173
  return e === "user" ? "user" : "assistant";
2065
2174
  }
2066
- function Xi(e) {
2175
+ function ua(e) {
2067
2176
  let t = e.trim();
2068
2177
  if (t.length < 2 || !(t.startsWith("{") || t.startsWith("[")) || !(t.endsWith("}") || t.endsWith("]"))) return !1;
2069
2178
  try {
@@ -2072,15 +2181,15 @@ function Xi(e) {
2072
2181
  return !1;
2073
2182
  }
2074
2183
  }
2075
- function Zi(e) {
2076
- let t = Ut(e)?.status;
2184
+ function da(e) {
2185
+ let t = $(e)?.status;
2077
2186
  return t === "changes_proposed" || t === "blueprint_proposed" || t === "awaiting_confirmation";
2078
2187
  }
2079
- function Qi(e) {
2188
+ function fa(e) {
2080
2189
  let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
2081
- return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? Zi(e.result) ? "awaiting" : "completed" : "running";
2190
+ return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? da(e.result) ? "awaiting" : "completed" : "running";
2082
2191
  }
2083
- var $i = {
2192
+ var pa = {
2084
2193
  create_object: "Create object",
2085
2194
  add_field: "Add field",
2086
2195
  modify_field: "Modify field",
@@ -2090,20 +2199,20 @@ var $i = {
2090
2199
  create_seed: "Generate sample data",
2091
2200
  create_package: "Create app package"
2092
2201
  };
2093
- function ea(e, t = $i) {
2202
+ function ma(e, t = pa) {
2094
2203
  return [
2095
- t[e.verb] ?? $i[e.verb] ?? e.verb,
2204
+ t[e.verb] ?? pa[e.verb] ?? e.verb,
2096
2205
  `${e.field ? `${e.object ? `${e.object}.` : ""}${e.field}` : e.object ?? e.name ?? ""}${e.type ? ` (${e.type})` : ""}`,
2097
2206
  e.details
2098
2207
  ].filter(Boolean).join(" ");
2099
2208
  }
2100
- function ta(e) {
2209
+ function ha(e) {
2101
2210
  return e.toolName === "propose_blueprint";
2102
2211
  }
2103
- function na(e) {
2104
- return ta(e) && Qi(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
2212
+ function ga(e) {
2213
+ return ha(e) && fa(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
2105
2214
  }
2106
- var ra = [
2215
+ var _a = [
2107
2216
  "待补",
2108
2217
  "后续",
2109
2218
  "将在",
@@ -2129,25 +2238,25 @@ var ra = [
2129
2238
  "coming soon",
2130
2239
  "tbd"
2131
2240
  ];
2132
- function ia(e) {
2241
+ function va(e) {
2133
2242
  let t = [], n = [];
2134
2243
  for (let r of e) {
2135
2244
  if (typeof r != "string") continue;
2136
2245
  let e = r.trim();
2137
2246
  if (!e) continue;
2138
2247
  let i = e.toLowerCase();
2139
- ra.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
2248
+ _a.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
2140
2249
  }
2141
2250
  return {
2142
2251
  designNotes: t,
2143
2252
  deferred: n
2144
2253
  };
2145
2254
  }
2146
- function aa(e) {
2147
- let t = Qi(e);
2148
- return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || na(e);
2255
+ function ya(e) {
2256
+ let t = fa(e);
2257
+ return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || ga(e);
2149
2258
  }
2150
- function oa(e) {
2259
+ function ba(e) {
2151
2260
  switch (e) {
2152
2261
  case "failed": return 4;
2153
2262
  case "awaiting": return 3;
@@ -2155,20 +2264,20 @@ function oa(e) {
2155
2264
  case "completed": return 1;
2156
2265
  }
2157
2266
  }
2158
- function sa(e) {
2267
+ function xa(e) {
2159
2268
  return /^\((?:called [^)]*|tool call|no content)\)$/.test(e.trim());
2160
2269
  }
2161
- function ca(e) {
2270
+ function Sa(e) {
2162
2271
  let t = /* @__PURE__ */ new Map();
2163
2272
  for (let n of e) {
2164
- let e = Qi(n), r = `${n.toolName}:${e}`, i = t.get(r);
2273
+ let e = fa(n), r = `${n.toolName}:${e}`, i = t.get(r);
2165
2274
  if (i) {
2166
2275
  i.count += 1, i.errorText = i.errorText ?? n.errorText;
2167
2276
  continue;
2168
2277
  }
2169
2278
  t.set(r, {
2170
2279
  key: r,
2171
- title: Jn(n.toolName) || n.toolName,
2280
+ title: or(n.toolName) || n.toolName,
2172
2281
  rawName: n.toolName,
2173
2282
  count: 1,
2174
2283
  state: e,
@@ -2176,11 +2285,11 @@ function ca(e) {
2176
2285
  });
2177
2286
  }
2178
2287
  return Array.from(t.values()).sort((e, t) => {
2179
- let n = oa(t.state) - oa(e.state);
2288
+ let n = ba(t.state) - ba(e.state);
2180
2289
  return n === 0 ? e.title.localeCompare(t.title) : n;
2181
2290
  });
2182
2291
  }
2183
- function la({ health: e }) {
2292
+ function Ca({ health: e }) {
2184
2293
  if (!e) return null;
2185
2294
  let t = e.issues ?? [], n = t.filter((e) => e.severity === "error"), r = t.filter((e) => e.severity !== "error"), i = e.checked, a = !!i && i.seeds + i.views + i.widgets > 0, o = [];
2186
2295
  if (typeof e.seededRows == "number" && e.seededRows > 0 && !e.seedError && o.push(`${e.seededRows} sample row${e.seededRows === 1 ? "" : "s"} live`), a && n.length === 0) {
@@ -2193,25 +2302,25 @@ function la({ health: e }) {
2193
2302
  children: [
2194
2303
  o.length > 0 ? /* @__PURE__ */ Q("div", {
2195
2304
  className: "flex items-center gap-1.5 text-xs text-emerald-700",
2196
- children: [/* @__PURE__ */ Z(K, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: o.join(" · ") })]
2305
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: o.join(" · ") })]
2197
2306
  }) : null,
2198
2307
  e.seedError ? /* @__PURE__ */ Q("div", {
2199
2308
  className: "flex items-start gap-1.5 text-xs text-red-600",
2200
- children: [/* @__PURE__ */ Z(Y, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.seedError })]
2309
+ children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.seedError })]
2201
2310
  }) : null,
2202
2311
  n.map((e, t) => /* @__PURE__ */ Q("div", {
2203
2312
  className: "flex items-start gap-1.5 text-xs text-red-600",
2204
- children: [/* @__PURE__ */ Z(Y, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2313
+ children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2205
2314
  }, `e${t}`)),
2206
2315
  r.map((e, t) => /* @__PURE__ */ Q("div", {
2207
2316
  className: "flex items-start gap-1.5 text-xs text-amber-600",
2208
- children: [/* @__PURE__ */ Z(je, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2317
+ children: [/* @__PURE__ */ Z(Me, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2209
2318
  }, `w${t}`))
2210
2319
  ]
2211
2320
  });
2212
2321
  }
2213
- var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt,.csv,.tsv,.xlsx,.xlsm", maxFileSize: w = 10485760, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: ee = "Approve", toolDenyLabel: P = "Deny", toolDenyReason: F = "User denied the operation", toolDecisions: I, onReviewDraft: te, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: L, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onDesignBuiltApp: R, designBuiltAppLabel: ae = "Design in Studio", getArtifactAction: oe, onPreviewDraftApp: z, previewDraftLabel: B = "Preview", onDraftArtifacts: V, onBuildMaterialized: H, publishDraftsLabel: se = "Publish", publishedLabel: ce = "Published", verifiedLabel: le = "Verified", nextStepsLabel: ue = "What's next", planTitleLabel: de = "Proposed plan", builderHandoffTitleLabel: fe = "Build this in the Builder", builderHandoffOpenLabel: pe = "Open in Builder →", builderHandoffSupersededTitle: me = "A newer request is available", onOpenBuilder: he, planExtendLabel: ge = "Adding to existing app", planQuestionsLabel: _e = "Confirm before building", planAssumptionsLabel: ve = "Assumptions", planDeferredLabel: ye = "Not yet built", planApproveHintLabel: be = "Reply to approve or adjust this plan.", planApproveLabel: U = "Build it", planAdjustLabel: W = "Adjust", planBuiltLabel: xe = "Built", planBuildingLabel: Se = "Building…", planReadyLabel: Ce = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: we = "Looks good — build it as proposed.", planApproveDefaultsMessage: Te = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: Ee = (e, t) => `For "${e}", go with: ${t}.`, changesTitleLabel: De = "Confirm changes", changesConfirmedLabel: Oe = "Confirmed", changesConfirmLabel: ke = "Confirm", changesConfirmHintLabel: Ae = "Reply to confirm or adjust this change.", changesConfirmMessage: Me = "Confirm — apply the change you just proposed.", changeVerbLabels: Ne = $i, fetchPendingDraftCount: Pe, autoPublishDrafts: Ie = !1, processVisibility: q = "summary", surface: Re = "card", ...ze }, Be) => {
2214
- let Ve = d ? "streaming" : "ready", He = Re === "plain", [We, Ge] = e.useState(null), Ke = e.useRef(""), Je = e.useRef(null), J = e.useMemo(() => ({
2322
+ var wa = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, onClear: a, onStop: o, onReload: s, onUpgrade: c, disabled: l = !1, readOnly: u = !1, isLoading: d = !1, error: f, showTimestamp: p = !1, showAvatars: m = !1, userAvatarUrl: h, userAvatarFallback: g = "You", assistantAvatarUrl: _, assistantAvatarFallback: v = "AI", hideClearBar: y = !1, maxHeight: b = "500px", enableMarkdown: x = !0, enableFileUpload: S = !1, acceptedFileTypes: C = "image/*,.pdf,.doc,.docx,.txt,.csv,.tsv,.xlsx,.xlsm", maxFileSize: w = 10485760, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: ee = "Approve", toolDenyLabel: P = "Deny", toolDenyReason: F = "User denied the operation", toolDecisions: I, onReviewDraft: te, toolReviewLabel: ne = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: L, onOpenBuiltApp: re, openBuiltAppLabel: ie = "Open app", onDesignBuiltApp: R, designBuiltAppLabel: ae = "Design in Studio", getArtifactAction: oe, onPreviewDraftApp: z, previewDraftLabel: B = "Preview", onDraftArtifacts: se, onBuildMaterialized: V, publishDraftsLabel: ce = "Publish", publishedLabel: le = "Published", verifiedLabel: ue = "Verified", nextStepsLabel: de = "What's next", planTitleLabel: fe = "Proposed plan", builderHandoffTitleLabel: pe = "Build this in the Builder", builderHandoffOpenLabel: me = "Open in Builder →", builderHandoffSupersededTitle: he = "A newer request is available", onOpenBuilder: ge, planExtendLabel: _e = "Adding to existing app", planQuestionsLabel: ve = "Confirm before building", planAssumptionsLabel: ye = "Assumptions", planDeferredLabel: be = "Not yet built", planApproveHintLabel: xe = "Reply to approve or adjust this plan.", planApproveLabel: H = "Build it", planAdjustLabel: U = "Adjust", planBuiltLabel: Se = "Built", planBuildingLabel: Ce = "Building…", planReadyLabel: we = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: Te = "Looks good — build it as proposed.", planApproveDefaultsMessage: Ee = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: De = (e, t) => `For "${e}", go with: ${t}.`, changesTitleLabel: Oe = "Confirm changes", changesConfirmedLabel: ke = "Confirmed", changesConfirmLabel: Ae = "Confirm", changesConfirmHintLabel: je = "Reply to confirm or adjust this change.", changesConfirmMessage: Ne = "Confirm — apply the change you just proposed.", changeVerbLabels: Pe = pa, changesApplyingLabel: Fe = "Applying…", changesAppliedLabel: Le = "Applied", changesDraftedLabel: ze = "Saved as draft", changesFailedLabel: Be = "Not applied", surfaceContextLabel: Ve, fetchPendingDraftCount: He, autoPublishDrafts: Ue = !1, processVisibility: K = "summary", surface: Ge = "card", ...qe }, Ye) => {
2323
+ let Ze = d ? "streaming" : "ready", nt = Ge === "plain", [rt, at] = e.useState(null), ot = e.useRef(""), st = e.useRef(null), q = e.useMemo(() => ({
2215
2324
  emptyTitle: E?.emptyTitle ?? "Start a conversation",
2216
2325
  emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
2217
2326
  clear: E?.clear ?? "Clear",
@@ -2237,55 +2346,55 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2237
2346
  connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
2238
2347
  connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
2239
2348
  designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
2240
- designingPlanHints: E?.designingPlanHints ?? ya
2241
- }), [E]), [et, tt] = e.useState(() => /* @__PURE__ */ new Set()), [rt, it] = e.useState(() => /* @__PURE__ */ new Map()), [at, ot] = e.useState(() => /* @__PURE__ */ new Map()), st = e.useRef(/* @__PURE__ */ new Set()), ct = e.useCallback(async (e) => {
2242
- if (Pe) try {
2243
- let t = await Pe(e);
2244
- ot((n) => {
2349
+ designingPlanHints: E?.designingPlanHints ?? Na
2350
+ }), [E]), [ct, lt] = e.useState(() => /* @__PURE__ */ new Set()), [ft, ht] = e.useState(() => /* @__PURE__ */ new Map()), [vt, yt] = e.useState(() => /* @__PURE__ */ new Map()), bt = e.useRef(/* @__PURE__ */ new Set()), xt = e.useCallback(async (e) => {
2351
+ if (He) try {
2352
+ let t = await He(e);
2353
+ yt((n) => {
2245
2354
  if (n.get(e) === t) return n;
2246
2355
  let r = new Map(n);
2247
2356
  return r.set(e, t), r;
2248
2357
  });
2249
2358
  } catch {}
2250
- }, [Pe]);
2359
+ }, [He]);
2251
2360
  e.useEffect(() => {
2252
- if (!Pe || d) return;
2361
+ if (!He || d) return;
2253
2362
  let e = /* @__PURE__ */ new Set();
2254
2363
  for (let t of n) for (let n of t.toolInvocations ?? []) {
2255
2364
  let t = n.draftReview?.packageId, r = n.toolCallId;
2256
- t && r && !st.current.has(r) && (st.current.add(r), e.add(t));
2365
+ t && r && !bt.current.has(r) && (bt.current.add(r), e.add(t));
2257
2366
  }
2258
- for (let t of e) ct(t);
2367
+ for (let t of e) xt(t);
2259
2368
  }, [
2260
2369
  n,
2261
2370
  d,
2262
- Pe,
2263
- ct
2371
+ He,
2372
+ xt
2264
2373
  ]);
2265
- let dt = e.useCallback(async (e) => {
2374
+ let Y = e.useCallback(async (e) => {
2266
2375
  if (!L) return;
2267
2376
  let t = [];
2268
2377
  for (let r of n) for (let n of r.toolInvocations ?? []) n.draftReview?.packageId === e && n.toolCallId && t.push(n.toolCallId);
2269
2378
  let r = await L(e), i = r && typeof r == "object" ? r : void 0;
2270
2379
  if ((i ? i.ok !== !1 : r !== !1) && t.length > 0) {
2271
- tt((e) => {
2380
+ lt((e) => {
2272
2381
  let n = new Set(e);
2273
2382
  for (let e of t) n.add(e);
2274
2383
  return n;
2275
2384
  });
2276
2385
  let e = i?.health;
2277
- e && it((n) => {
2386
+ e && ht((n) => {
2278
2387
  let r = new Map(n);
2279
2388
  for (let n of t) r.set(n, e);
2280
2389
  return r;
2281
2390
  });
2282
2391
  }
2283
- ct(e);
2392
+ xt(e);
2284
2393
  }, [
2285
2394
  L,
2286
2395
  n,
2287
- ct
2288
- ]), mt = e.useRef(/* @__PURE__ */ new Set()), _t = e.useRef(!1);
2396
+ xt
2397
+ ]), St = e.useRef(/* @__PURE__ */ new Set()), Ct = e.useRef(!1);
2289
2398
  e.useEffect(() => {
2290
2399
  let e = [];
2291
2400
  for (let t of n) for (let n of t.toolInvocations ?? []) {
@@ -2295,27 +2404,27 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2295
2404
  packageId: t.packageId
2296
2405
  });
2297
2406
  }
2298
- if (!_t.current) {
2299
- _t.current = !0;
2300
- for (let t of e) mt.current.add(t.key);
2407
+ if (!Ct.current) {
2408
+ Ct.current = !0;
2409
+ for (let t of e) St.current.add(t.key);
2301
2410
  return;
2302
2411
  }
2303
- if (!Ie || !L || d) return;
2304
- let t = e.filter((e) => !mt.current.has(e.key));
2412
+ if (!Ue || !L || d) return;
2413
+ let t = e.filter((e) => !St.current.has(e.key));
2305
2414
  if (t.length !== 0) {
2306
- for (let e of t) mt.current.add(e.key);
2307
- for (let e of [...new Set(t.map((e) => e.packageId))]) dt(e);
2415
+ for (let e of t) St.current.add(e.key);
2416
+ for (let e of [...new Set(t.map((e) => e.packageId))]) Y(e);
2308
2417
  }
2309
2418
  }, [
2310
2419
  n,
2311
2420
  d,
2312
- Ie,
2421
+ Ue,
2313
2422
  L,
2314
- dt
2423
+ Y
2315
2424
  ]);
2316
- let vt = e.useRef(/* @__PURE__ */ new Set());
2425
+ let wt = e.useRef(/* @__PURE__ */ new Set());
2317
2426
  e.useEffect(() => {
2318
- if (!V) return;
2427
+ if (!se) return;
2319
2428
  let e = /* @__PURE__ */ new Map(), t;
2320
2429
  for (let r of n) {
2321
2430
  for (let t of r.buildProgress?.items ?? []) t?.type && t?.name && e.set(`${t.type}:${t.name}`, t);
@@ -2325,69 +2434,82 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2325
2434
  r?.packageId && r.items?.some((e) => e.type === "app") && (t = r.packageId);
2326
2435
  }
2327
2436
  }
2328
- let r = vt.current, i = !1;
2437
+ let r = wt.current, i = !1;
2329
2438
  for (let t of e.keys()) r.has(t) || (r.add(t), i = !0);
2330
- i && V([...e.values()], t);
2331
- }, [n, V]);
2332
- let yt = e.useRef(/* @__PURE__ */ new Set());
2439
+ i && se([...e.values()], t);
2440
+ }, [n, se]);
2441
+ let Et = e.useRef(/* @__PURE__ */ new Set());
2333
2442
  e.useEffect(() => {
2334
- if (H) for (let e of n) for (let t of e.toolInvocations ?? []) {
2443
+ if (V) for (let e of n) for (let t of e.toolInvocations ?? []) {
2335
2444
  let e = t.draftReview;
2336
2445
  if (!e?.materialized || !t.toolCallId) continue;
2337
2446
  let n = e.items.find((e) => e.type === "app");
2338
- !n || yt.current.has(t.toolCallId) || (yt.current.add(t.toolCallId), H(n.name));
2447
+ !n || Et.current.has(t.toolCallId) || (Et.current.add(t.toolCallId), V(n.name));
2339
2448
  }
2340
- }, [n, H]);
2341
- let bt = e.useCallback((e) => {
2449
+ }, [n, V]);
2450
+ let Dt = e.useCallback((e) => {
2342
2451
  let t = !!e.text?.trim(), n = e.files?.map((e) => e.file).filter(Boolean), r = !!(n && n.length > 0);
2343
2452
  if (!(t || r)) return;
2344
2453
  let a = e.text?.trim() ?? "";
2345
- Ke.current = a, Je.current = null, $.current = null, i?.(a, n);
2346
- }, [i]), xt = e.useCallback((e) => {
2347
- $.current = null, i?.(e);
2348
- }, [i]), St = e.useRef(null), [Ct, wt] = e.useState(() => /* @__PURE__ */ new Set()), $ = e.useRef(null), Et = e.useCallback((e, t) => {
2349
- t && ($.current = t, wt((e) => {
2454
+ ot.current = a, st.current = null, Mt.current = null, i?.(a, n);
2455
+ }, [i]), Ot = e.useCallback((e) => {
2456
+ Mt.current = null, i?.(e);
2457
+ }, [i]), kt = e.useRef(null), [At, jt] = e.useState(() => /* @__PURE__ */ new Set()), Mt = e.useRef(null), Nt = e.useCallback((e, t) => {
2458
+ t && (Mt.current = t, jt((e) => {
2350
2459
  let n = new Set(e);
2351
2460
  return n.add(t), n;
2352
- })), i?.(e ? Te : we);
2461
+ })), i?.(e ? Ee : Te);
2353
2462
  }, [
2354
2463
  i,
2355
- we,
2356
- Te
2357
- ]), Dt = e.useCallback(() => {
2358
- let e = St.current?.querySelector("textarea");
2464
+ Te,
2465
+ Ee
2466
+ ]), [Pt, Ft] = e.useState(() => /* @__PURE__ */ new Set()), It = e.useRef(null), Lt = e.useCallback((e) => {
2467
+ e && (It.current = e, Ft((t) => {
2468
+ let n = new Set(t);
2469
+ return n.add(e), n;
2470
+ })), i?.(Ne);
2471
+ }, [i, Ne]), Rt = e.useCallback(() => {
2472
+ let e = kt.current?.querySelector("textarea");
2359
2473
  e && (e.focus(), e.scrollIntoView({ block: "nearest" }));
2360
2474
  }, []);
2361
2475
  e.useEffect(() => {
2362
- if (!f || !$n(f) || Je.current === f) return;
2363
- if (Je.current = f, $.current) {
2364
- let e = $.current;
2365
- $.current = null, wt((t) => {
2476
+ if (!f || !pr(f) || st.current === f) return;
2477
+ if (st.current = f, Mt.current) {
2478
+ let e = Mt.current;
2479
+ Mt.current = null, jt((t) => {
2366
2480
  if (!t.has(e)) return t;
2367
2481
  let n = new Set(t);
2368
2482
  return n.delete(e), n;
2369
2483
  });
2370
2484
  }
2371
- let e = Ke.current;
2485
+ if (It.current) {
2486
+ let e = It.current;
2487
+ It.current = null, Ft((t) => {
2488
+ if (!t.has(e)) return t;
2489
+ let n = new Set(t);
2490
+ return n.delete(e), n;
2491
+ });
2492
+ }
2493
+ let e = ot.current;
2372
2494
  if (!e) return;
2373
- let t = St.current?.querySelector("textarea");
2495
+ let t = kt.current?.querySelector("textarea");
2374
2496
  t && t.value.trim() === "" && (t.value = e, t.dispatchEvent(new Event("input", { bubbles: !0 })), t.focus());
2375
2497
  }, [f]);
2376
- let Ot = e.useCallback((e) => {
2377
- navigator.clipboard?.writeText(e.content), Ge(e.id), window.setTimeout(() => Ge((t) => t === e.id ? null : t), 1500);
2378
- }, []), kt = e.useMemo(() => {
2498
+ let zt = e.useCallback((e) => {
2499
+ navigator.clipboard?.writeText(e.content), at(e.id), window.setTimeout(() => at((t) => t === e.id ? null : t), 1500);
2500
+ }, []), Bt = e.useMemo(() => {
2379
2501
  let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
2380
- for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || na(n)) && n.toolCallId && t.push({
2502
+ for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || ga(n)) && n.toolCallId && t.push({
2381
2503
  id: n.toolCallId,
2382
2504
  order: i
2383
2505
  }), n.toolName === "apply_blueprint" && (r = i), i += 1;
2384
2506
  for (let n of t) n.order < r && e.add(n.id);
2385
2507
  return e;
2386
- }, [n]), At = e.useMemo(() => {
2508
+ }, [n]), Vt = e.useMemo(() => {
2387
2509
  let e;
2388
2510
  for (let t of n) for (let n of t.toolInvocations ?? []) n.builderHandoff && n.toolCallId && (e = n.toolCallId);
2389
2511
  return e;
2390
- }, [n]), jt = e.useMemo(() => {
2512
+ }, [n]), Ht = e.useMemo(() => {
2391
2513
  let e = /* @__PURE__ */ new Set(), t = [], r = /* @__PURE__ */ new Map(), i = 0;
2392
2514
  for (let e of n) for (let n of e.toolInvocations ?? []) n.proposedChanges && n.toolCallId ? t.push({
2393
2515
  id: n.toolCallId,
@@ -2399,8 +2521,27 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2399
2521
  t !== void 0 && t > n.order && e.add(n.id);
2400
2522
  }
2401
2523
  return e;
2402
- }, [n]), Mt = (e) => {
2403
- let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = Jn(e.toolName), c = Yn(e.result), l = q === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = q === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : at.get(d), p = f === void 0 ? et.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && Zi(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ Q("span", {
2524
+ }, [n]), Ut = e.useMemo(() => {
2525
+ let e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), r = [], i = 0;
2526
+ for (let a of n) for (let n of a.toolInvocations ?? []) {
2527
+ if (n.proposedChanges && n.toolCallId) r.push({
2528
+ id: n.toolCallId,
2529
+ toolName: n.toolName ?? "",
2530
+ order: i
2531
+ }), t.delete(n.toolCallId);
2532
+ else if (n.toolCallId?.startsWith("replay_")) {
2533
+ let a;
2534
+ for (let e of r) e.order < i && e.toolName === (n.toolName ?? "") && (a = e);
2535
+ a && (n.replayOutcome ? (e.set(a.id, n.replayOutcome), n.replayOutcome.dispatchError ? t.set(a.id, i) : t.delete(a.id)) : n.result === void 0 && !n.errorText && e.set(a.id, { kind: "applying" }));
2536
+ } else if (n.result !== void 0 && t.size > 0) {
2537
+ let r = Zt(n.result);
2538
+ if (r) for (let [n, a] of t) i > a && e.set(n, r);
2539
+ }
2540
+ i += 1;
2541
+ }
2542
+ return e;
2543
+ }, [n]), Wt = (e) => {
2544
+ let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = I?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = or(e.toolName), c = sr(e.result), l = K === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = K === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : vt.get(d), p = f === void 0 ? ct.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && da(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ Q("span", {
2404
2545
  className: "inline-flex min-w-0 items-center gap-2",
2405
2546
  children: [
2406
2547
  /* @__PURE__ */ Z("span", { children: s || e.toolName }),
@@ -2408,22 +2549,22 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2408
2549
  className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
2409
2550
  children: e.toolName
2410
2551
  }) : null,
2411
- m ? ta(e) ? /* @__PURE__ */ Z(Sa, {
2412
- label: J.designingPlanLabel,
2413
- hints: J.designingPlanHints,
2414
- offlineLabel: J.connectionOfflineLabel
2415
- }) : /* @__PURE__ */ Z(Ca, { offlineLabel: J.connectionOfflineLabel }) : null
2552
+ m ? ha(e) ? /* @__PURE__ */ Z(Ia, {
2553
+ label: q.designingPlanLabel,
2554
+ hints: q.designingPlanHints,
2555
+ offlineLabel: q.connectionOfflineLabel
2556
+ }) : /* @__PURE__ */ Z(La, { offlineLabel: q.connectionOfflineLabel }) : null
2416
2557
  ]
2417
2558
  });
2418
- return /* @__PURE__ */ Q(ki, {
2419
- defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || na(e),
2420
- children: [/* @__PURE__ */ Z(ji, {
2559
+ return /* @__PURE__ */ Q(Ui, {
2560
+ defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || !!e.builderHandoff || ga(e),
2561
+ children: [/* @__PURE__ */ Z(Gi, {
2421
2562
  type: n,
2422
2563
  state: h,
2423
2564
  title: g
2424
- }), /* @__PURE__ */ Q(Mi, { children: [
2425
- u && e.args !== void 0 ? /* @__PURE__ */ Z(Ni, { input: e.args }) : null,
2426
- o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(Na, {
2565
+ }), /* @__PURE__ */ Q(Ki, { children: [
2566
+ u && e.args !== void 0 ? /* @__PURE__ */ Z(qi, { input: e.args }) : null,
2567
+ o ? null : u || t === "output-error" ? /* @__PURE__ */ Z(qa, {
2427
2568
  output: c,
2428
2569
  errorText: e.errorText
2429
2570
  }) : null,
@@ -2455,18 +2596,18 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2455
2596
  L && e.draftReview.packageId ? p ? /* @__PURE__ */ Q("span", {
2456
2597
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700",
2457
2598
  children: [
2458
- /* @__PURE__ */ Z(K, { className: "size-3.5" }),
2459
- ce,
2599
+ /* @__PURE__ */ Z(G, { className: "size-3.5" }),
2600
+ le,
2460
2601
  e.draftReview.failedCount ? ` · ${e.draftReview.failedCount} need${e.draftReview.failedCount === 1 ? "s" : ""} attention` : ""
2461
2602
  ]
2462
2603
  }) : /* @__PURE__ */ Q("button", {
2463
2604
  type: "button",
2464
- onClick: () => void dt(e.draftReview.packageId),
2605
+ onClick: () => void Y(e.draftReview.packageId),
2465
2606
  className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2466
2607
  "data-testid": "draft-publish",
2467
2608
  children: [
2468
- /* @__PURE__ */ Z(ut, { className: "size-3.5" }),
2469
- se,
2609
+ /* @__PURE__ */ Z(dt, { className: "size-3.5" }),
2610
+ ce,
2470
2611
  typeof f == "number" && f > 0 ? ` (${f})` : ""
2471
2612
  ]
2472
2613
  }) : null,
@@ -2474,7 +2615,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2474
2615
  type: "button",
2475
2616
  onClick: () => te(e.draftReview.items),
2476
2617
  className: L && e.draftReview.packageId ? "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted" : "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2477
- children: [/* @__PURE__ */ Z(Ze, { className: "size-3.5" }), ne(e.draftReview.items.length)]
2618
+ children: [/* @__PURE__ */ Z($e, { className: "size-3.5" }), ne(e.draftReview.items.length)]
2478
2619
  }) : null,
2479
2620
  z && !p ? (() => {
2480
2621
  let t = e.draftReview.items.find((e) => e.type === "app");
@@ -2486,17 +2627,17 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2486
2627
  }),
2487
2628
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
2488
2629
  "data-testid": "draft-preview-app",
2489
- children: [/* @__PURE__ */ Z(Xe, { className: "size-3.5" }), B]
2630
+ children: [/* @__PURE__ */ Z(Qe, { className: "size-3.5" }), B]
2490
2631
  }) : null;
2491
2632
  })() : null,
2492
2633
  e.draftReview.verification ? e.draftReview.verification.errors > 0 ? /* @__PURE__ */ Q("span", {
2493
2634
  className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-2.5 text-xs font-medium text-amber-700",
2494
2635
  "data-testid": "draft-verification-chip",
2495
- children: [/* @__PURE__ */ Z(gt, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
2636
+ children: [/* @__PURE__ */ Z(_t, { className: "size-3.5" }), `${e.draftReview.verification.errors} issue${e.draftReview.verification.errors === 1 ? "" : "s"}`]
2496
2637
  }) : /* @__PURE__ */ Q("span", {
2497
2638
  className: "inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-2.5 text-xs font-medium text-emerald-700",
2498
2639
  "data-testid": "draft-verification-chip",
2499
- children: [/* @__PURE__ */ Z(ft, { className: "size-3.5" }), le]
2640
+ children: [/* @__PURE__ */ Z(pt, { className: "size-3.5" }), ue]
2500
2641
  }) : null,
2501
2642
  e.draftReview.summary ? /* @__PURE__ */ Z("span", {
2502
2643
  className: "min-w-0 flex-1 truncate text-xs text-muted-foreground",
@@ -2509,19 +2650,19 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2509
2650
  "data-testid": "draft-issues",
2510
2651
  children: [e.draftReview.issues.filter((e) => e.severity === "error").map((e, t) => /* @__PURE__ */ Q("div", {
2511
2652
  className: "flex items-start gap-1.5 text-xs text-red-600",
2512
- children: [/* @__PURE__ */ Z(Y, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
2653
+ children: [/* @__PURE__ */ Z(J, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.fix ? `${e.message} — ${e.fix}` : e.message })]
2513
2654
  }, `e${t}`)), e.draftReview.issues.filter((e) => e.severity !== "error").map((e, t) => /* @__PURE__ */ Q("div", {
2514
2655
  className: "flex items-start gap-1.5 text-xs text-amber-600",
2515
- children: [/* @__PURE__ */ Z(je, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2656
+ children: [/* @__PURE__ */ Z(Me, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Z("span", { children: e.message })]
2516
2657
  }, `w${t}`))]
2517
2658
  }) : null,
2518
- et.has(e.toolCallId) ? /* @__PURE__ */ Z(la, { health: rt.get(e.toolCallId) }) : null,
2659
+ ct.has(e.toolCallId) ? /* @__PURE__ */ Z(Ca, { health: ft.get(e.toolCallId) }) : null,
2519
2660
  e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ Q("div", {
2520
2661
  className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
2521
2662
  "data-testid": "draft-next-steps",
2522
2663
  children: [/* @__PURE__ */ Z("span", {
2523
2664
  className: "text-xs font-medium text-foreground/80",
2524
- children: ue
2665
+ children: de
2525
2666
  }), e.draftReview.nextSteps.map((e, t) => /* @__PURE__ */ Q("div", {
2526
2667
  className: "flex items-start gap-1.5 text-xs text-muted-foreground",
2527
2668
  children: [/* @__PURE__ */ Z("span", {
@@ -2537,22 +2678,22 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2537
2678
  children: [
2538
2679
  /* @__PURE__ */ Q("span", {
2539
2680
  className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2540
- children: [/* @__PURE__ */ Z(pt, { className: "size-3.5" }), fe]
2681
+ children: [/* @__PURE__ */ Z(mt, { className: "size-3.5" }), pe]
2541
2682
  }),
2542
2683
  /* @__PURE__ */ Z("p", {
2543
2684
  className: "text-xs text-muted-foreground",
2544
2685
  children: e.builderHandoff.prompt
2545
2686
  }),
2546
2687
  (() => {
2547
- let t = !!At && e.toolCallId !== At;
2688
+ let t = !!Vt && e.toolCallId !== Vt;
2548
2689
  return /* @__PURE__ */ Z("button", {
2549
2690
  type: "button",
2550
- onClick: () => he?.(e.builderHandoff),
2551
- disabled: !he || t,
2691
+ onClick: () => ge?.(e.builderHandoff),
2692
+ disabled: !ge || t,
2552
2693
  "data-testid": t ? "builder-handoff-superseded" : "builder-handoff-open",
2553
- title: t ? me : void 0,
2694
+ title: t ? he : void 0,
2554
2695
  className: "inline-flex w-fit items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50",
2555
- children: pe
2696
+ children: me
2556
2697
  });
2557
2698
  })()
2558
2699
  ]
@@ -2563,14 +2704,14 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2563
2704
  children: [
2564
2705
  /* @__PURE__ */ Q("span", {
2565
2706
  className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2566
- children: [/* @__PURE__ */ Z(Ue, { className: "size-3.5" }), de]
2707
+ children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), fe]
2567
2708
  }),
2568
2709
  e.proposedPlan.targetApp ? /* @__PURE__ */ Q("span", {
2569
2710
  className: "inline-flex w-fit items-center gap-1 rounded-md border border-blue-200 bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700 dark:border-blue-900/50 dark:bg-blue-950/30 dark:text-blue-300",
2570
2711
  "data-testid": "proposed-plan-extend",
2571
2712
  children: [
2572
2713
  "+ ",
2573
- ge,
2714
+ _e,
2574
2715
  " \"",
2575
2716
  e.proposedPlan.targetApp,
2576
2717
  "\""
@@ -2586,7 +2727,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2586
2727
  className: "inline-flex items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80",
2587
2728
  title: e.name,
2588
2729
  children: [
2589
- /* @__PURE__ */ Z(ht, { className: "size-3 text-foreground/40" }),
2730
+ /* @__PURE__ */ Z(gt, { className: "size-3 text-foreground/40" }),
2590
2731
  e.label || e.name,
2591
2732
  e.fieldCount > 0 ? /* @__PURE__ */ Q("span", {
2592
2733
  className: "text-foreground/40",
@@ -2603,13 +2744,13 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2603
2744
  }) : null;
2604
2745
  })(),
2605
2746
  (() => {
2606
- let { designNotes: t, deferred: n } = ia(e.proposedPlan.assumptions);
2747
+ let { designNotes: t, deferred: n } = va(e.proposedPlan.assumptions);
2607
2748
  return /* @__PURE__ */ Q(X, { children: [t.length > 0 ? /* @__PURE__ */ Q("div", {
2608
2749
  className: "flex flex-col gap-0.5",
2609
2750
  "data-testid": "proposed-plan-assumptions",
2610
2751
  children: [/* @__PURE__ */ Z("span", {
2611
2752
  className: "text-[11px] font-medium text-foreground/70",
2612
- children: ve
2753
+ children: ye
2613
2754
  }), t.map((e, t) => /* @__PURE__ */ Q("div", {
2614
2755
  className: "flex items-start gap-1.5 text-[11px] text-muted-foreground",
2615
2756
  children: [/* @__PURE__ */ Z("span", {
@@ -2622,7 +2763,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2622
2763
  "data-testid": "proposed-plan-deferred",
2623
2764
  children: [/* @__PURE__ */ Q("span", {
2624
2765
  className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
2625
- children: [/* @__PURE__ */ Z($e, { className: "size-3.5" }), ye]
2766
+ children: [/* @__PURE__ */ Z(tt, { className: "size-3.5" }), be]
2626
2767
  }), n.map((e, t) => /* @__PURE__ */ Q("div", {
2627
2768
  className: "flex items-start gap-1.5 text-[11px] text-amber-900/90 dark:text-amber-200/90",
2628
2769
  children: [/* @__PURE__ */ Z("span", {
@@ -2637,7 +2778,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2637
2778
  "data-testid": "proposed-plan-questions",
2638
2779
  children: [/* @__PURE__ */ Q("span", {
2639
2780
  className: "inline-flex items-center gap-1.5 text-[11px] font-medium text-amber-800 dark:text-amber-300",
2640
- children: [/* @__PURE__ */ Z(Qe, { className: "size-3.5" }), _e]
2781
+ children: [/* @__PURE__ */ Z(et, { className: "size-3.5" }), ve]
2641
2782
  }), e.proposedPlan.questions.map((t, n) => {
2642
2783
  let r = e.proposedPlan.questionChoices?.find((e) => e.text === t);
2643
2784
  return /* @__PURE__ */ Q("div", {
@@ -2653,7 +2794,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2653
2794
  "data-testid": "proposed-plan-choice",
2654
2795
  children: r.options.map((e, n) => /* @__PURE__ */ Z("button", {
2655
2796
  type: "button",
2656
- onClick: () => i(Ee(t, e)),
2797
+ onClick: () => i(De(t, e)),
2657
2798
  className: "inline-flex h-6 items-center rounded-full border border-amber-300 bg-background px-2 text-[11px] font-medium text-amber-900 hover:bg-amber-100 dark:border-amber-800 dark:text-amber-200 dark:hover:bg-amber-900/40",
2658
2799
  children: e
2659
2800
  }, n))
@@ -2661,91 +2802,91 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2661
2802
  }, n);
2662
2803
  })]
2663
2804
  }) : null,
2664
- i ? kt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2805
+ i ? Bt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2665
2806
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2666
2807
  "data-testid": "proposed-plan-actions",
2667
2808
  children: /* @__PURE__ */ Q("span", {
2668
2809
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2669
2810
  "data-testid": "proposed-plan-built",
2670
- children: [/* @__PURE__ */ Z(K, { className: "size-3.5" }), xe]
2811
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Se]
2671
2812
  })
2672
- }) : Ct.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2813
+ }) : At.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2673
2814
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2674
2815
  "data-testid": "proposed-plan-actions",
2675
2816
  children: /* @__PURE__ */ Q("span", {
2676
2817
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-muted-foreground",
2677
2818
  "data-testid": "proposed-plan-building",
2678
- children: [/* @__PURE__ */ Z(nt, { className: "size-3.5 animate-spin" }), Se]
2819
+ children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Ce]
2679
2820
  })
2680
2821
  }) : /* @__PURE__ */ Q("div", {
2681
2822
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2682
2823
  "data-testid": "proposed-plan-actions",
2683
2824
  children: [/* @__PURE__ */ Q("button", {
2684
2825
  type: "button",
2685
- onClick: () => Et(e.proposedPlan.questions.length > 0, e.toolCallId),
2826
+ onClick: () => Nt(e.proposedPlan.questions.length > 0, e.toolCallId),
2686
2827
  className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2687
2828
  "data-testid": "proposed-plan-approve",
2688
- children: [/* @__PURE__ */ Z(ut, { className: "size-3.5" }), U]
2829
+ children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), H]
2689
2830
  }), /* @__PURE__ */ Z("button", {
2690
2831
  type: "button",
2691
- onClick: Dt,
2832
+ onClick: Rt,
2692
2833
  className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2693
2834
  "data-testid": "proposed-plan-adjust",
2694
- children: W
2835
+ children: U
2695
2836
  })]
2696
2837
  }) : /* @__PURE__ */ Z("span", {
2697
2838
  className: "text-[11px] italic text-muted-foreground/80",
2698
- children: be
2839
+ children: xe
2699
2840
  })
2700
2841
  ]
2701
2842
  }) : null,
2702
- na(e) ? /* @__PURE__ */ Q("div", {
2843
+ ga(e) ? /* @__PURE__ */ Q("div", {
2703
2844
  className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
2704
2845
  "data-testid": "proposed-plan-fallback",
2705
2846
  children: [
2706
2847
  /* @__PURE__ */ Q("span", {
2707
2848
  className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2708
- children: [/* @__PURE__ */ Z(Ue, { className: "size-3.5" }), de]
2849
+ children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), fe]
2709
2850
  }),
2710
2851
  /* @__PURE__ */ Z("p", {
2711
2852
  className: "text-xs text-muted-foreground",
2712
- children: Ce
2853
+ children: we
2713
2854
  }),
2714
- i ? kt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2855
+ i ? Bt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2715
2856
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2716
2857
  "data-testid": "proposed-plan-actions",
2717
2858
  children: /* @__PURE__ */ Q("span", {
2718
2859
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2719
2860
  "data-testid": "proposed-plan-built",
2720
- children: [/* @__PURE__ */ Z(K, { className: "size-3.5" }), xe]
2861
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Se]
2721
2862
  })
2722
- }) : Ct.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2863
+ }) : At.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2723
2864
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2724
2865
  "data-testid": "proposed-plan-actions",
2725
2866
  children: /* @__PURE__ */ Q("span", {
2726
2867
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-muted-foreground",
2727
2868
  "data-testid": "proposed-plan-building",
2728
- children: [/* @__PURE__ */ Z(nt, { className: "size-3.5 animate-spin" }), Se]
2869
+ children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Ce]
2729
2870
  })
2730
2871
  }) : /* @__PURE__ */ Q("div", {
2731
2872
  className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2732
2873
  "data-testid": "proposed-plan-actions",
2733
2874
  children: [/* @__PURE__ */ Q("button", {
2734
2875
  type: "button",
2735
- onClick: () => Et(!1, e.toolCallId),
2876
+ onClick: () => Nt(!1, e.toolCallId),
2736
2877
  className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2737
2878
  "data-testid": "proposed-plan-approve",
2738
- children: [/* @__PURE__ */ Z(ut, { className: "size-3.5" }), U]
2879
+ children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), H]
2739
2880
  }), /* @__PURE__ */ Z("button", {
2740
2881
  type: "button",
2741
- onClick: Dt,
2882
+ onClick: Rt,
2742
2883
  className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2743
2884
  "data-testid": "proposed-plan-adjust",
2744
- children: W
2885
+ children: U
2745
2886
  })]
2746
2887
  }) : /* @__PURE__ */ Z("span", {
2747
2888
  className: "text-[11px] italic text-muted-foreground/80",
2748
- children: be
2889
+ children: xe
2749
2890
  })
2750
2891
  ]
2751
2892
  }) : null,
@@ -2755,7 +2896,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2755
2896
  children: [
2756
2897
  /* @__PURE__ */ Q("span", {
2757
2898
  className: "inline-flex items-center gap-1.5 text-xs font-medium text-foreground/80",
2758
- children: [/* @__PURE__ */ Z(Ue, { className: "size-3.5" }), De]
2899
+ children: [/* @__PURE__ */ Z(We, { className: "size-3.5" }), Oe]
2759
2900
  }),
2760
2901
  e.proposedChanges.summary ? /* @__PURE__ */ Z("p", {
2761
2902
  className: "text-xs text-muted-foreground",
@@ -2765,66 +2906,111 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2765
2906
  className: "flex flex-col gap-1",
2766
2907
  children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ Q("div", {
2767
2908
  className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
2768
- children: [/* @__PURE__ */ Z(ht, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Z("span", { children: ea(e, Ne) })]
2909
+ children: [/* @__PURE__ */ Z(gt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Z("span", { children: ma(e, Pe) })]
2769
2910
  }, t))
2770
2911
  }),
2771
- i ? jt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2772
- className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2773
- "data-testid": "proposed-changes-actions",
2774
- children: /* @__PURE__ */ Q("span", {
2775
- className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2776
- "data-testid": "proposed-changes-confirmed",
2777
- children: [/* @__PURE__ */ Z(K, { className: "size-3.5" }), Oe]
2778
- })
2779
- }) : /* @__PURE__ */ Q("div", {
2780
- className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2781
- "data-testid": "proposed-changes-actions",
2782
- children: [/* @__PURE__ */ Q("button", {
2783
- type: "button",
2784
- onClick: () => i(Me),
2785
- className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2786
- "data-testid": "proposed-changes-confirm",
2787
- children: [/* @__PURE__ */ Z(K, { className: "size-3.5" }), ke]
2788
- }), /* @__PURE__ */ Z("button", {
2789
- type: "button",
2790
- onClick: Dt,
2791
- className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2792
- "data-testid": "proposed-changes-adjust",
2793
- children: W
2794
- })]
2795
- }) : /* @__PURE__ */ Z("span", {
2796
- className: "text-[11px] italic text-muted-foreground/80",
2797
- children: Ae
2798
- })
2912
+ (() => {
2913
+ let t = Ut.get(e.toolCallId);
2914
+ return t?.kind === "published" ? /* @__PURE__ */ Z("div", {
2915
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2916
+ "data-testid": "proposed-changes-actions",
2917
+ children: /* @__PURE__ */ Q("span", {
2918
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2919
+ "data-testid": "proposed-changes-applied",
2920
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Le]
2921
+ })
2922
+ }) : t?.kind === "failed" ? /* @__PURE__ */ Q("div", {
2923
+ className: "flex flex-col gap-1 pt-0.5",
2924
+ "data-testid": "proposed-changes-actions",
2925
+ children: [/* @__PURE__ */ Q("span", {
2926
+ className: "inline-flex h-7 w-fit items-center gap-1.5 rounded-md border border-red-200 bg-red-50 px-3 text-xs font-medium text-red-700 dark:border-red-900/50 dark:bg-red-950/30 dark:text-red-300",
2927
+ "data-testid": "proposed-changes-failed",
2928
+ children: [/* @__PURE__ */ Z(J, { className: "size-3.5" }), Be]
2929
+ }), t.error ? /* @__PURE__ */ Z("span", {
2930
+ className: "text-[11px] text-red-700/80 dark:text-red-300/80",
2931
+ "data-testid": "proposed-changes-failed-reason",
2932
+ children: t.error
2933
+ }) : null]
2934
+ }) : t?.kind === "drafted" ? /* @__PURE__ */ Q("div", {
2935
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2936
+ "data-testid": "proposed-changes-actions",
2937
+ children: [/* @__PURE__ */ Q("span", {
2938
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-amber-200 bg-amber-50 px-3 text-xs font-medium text-amber-800 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-300",
2939
+ "data-testid": "proposed-changes-drafted",
2940
+ children: [/* @__PURE__ */ Z(Ke, { className: "size-3.5" }), ze]
2941
+ }), L && t.packageId ? /* @__PURE__ */ Q("button", {
2942
+ type: "button",
2943
+ onClick: () => void Y(t.packageId),
2944
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2945
+ "data-testid": "proposed-changes-publish",
2946
+ children: [/* @__PURE__ */ Z(dt, { className: "size-3.5" }), ce]
2947
+ }) : null]
2948
+ }) : t?.kind === "applying" || Pt.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2949
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2950
+ "data-testid": "proposed-changes-actions",
2951
+ children: /* @__PURE__ */ Q("span", {
2952
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border bg-muted/40 px-3 text-xs font-medium text-foreground/70",
2953
+ "data-testid": "proposed-changes-applying",
2954
+ children: [/* @__PURE__ */ Z(it, { className: "size-3.5 animate-spin" }), Fe]
2955
+ })
2956
+ }) : i ? Ht.has(e.toolCallId) ? /* @__PURE__ */ Z("div", {
2957
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2958
+ "data-testid": "proposed-changes-actions",
2959
+ children: /* @__PURE__ */ Q("span", {
2960
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md border border-emerald-200 bg-emerald-50 px-3 text-xs font-medium text-emerald-700 dark:border-emerald-900/50 dark:bg-emerald-950/30 dark:text-emerald-300",
2961
+ "data-testid": "proposed-changes-confirmed",
2962
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), ke]
2963
+ })
2964
+ }) : /* @__PURE__ */ Q("div", {
2965
+ className: "flex flex-wrap items-center gap-1.5 pt-0.5",
2966
+ "data-testid": "proposed-changes-actions",
2967
+ children: [/* @__PURE__ */ Q("button", {
2968
+ type: "button",
2969
+ onClick: () => Lt(e.toolCallId),
2970
+ className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
2971
+ "data-testid": "proposed-changes-confirm",
2972
+ children: [/* @__PURE__ */ Z(G, { className: "size-3.5" }), Ae]
2973
+ }), /* @__PURE__ */ Z("button", {
2974
+ type: "button",
2975
+ onClick: Rt,
2976
+ className: "inline-flex h-7 items-center rounded-md border bg-background px-3 text-xs font-medium hover:bg-accent",
2977
+ "data-testid": "proposed-changes-adjust",
2978
+ children: U
2979
+ })]
2980
+ }) : /* @__PURE__ */ Z("span", {
2981
+ className: "text-[11px] italic text-muted-foreground/80",
2982
+ children: je
2983
+ });
2984
+ })()
2799
2985
  ]
2800
2986
  }) : null
2801
2987
  ] })]
2802
2988
  }, e.toolCallId);
2803
2989
  };
2804
2990
  return /* @__PURE__ */ Q("div", {
2805
- ref: Be,
2806
- className: G(He ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
2991
+ ref: Ye,
2992
+ className: W(nt ? "flex min-h-0 flex-col overflow-hidden bg-background" : "flex min-h-0 flex-col overflow-hidden rounded-lg border bg-background", t),
2807
2993
  style: { maxHeight: b },
2808
- ...ze,
2994
+ ...qe,
2809
2995
  children: [
2810
2996
  a && !y && n.length > 0 && /* @__PURE__ */ Z("div", {
2811
- className: G("flex items-center justify-end px-4 py-2", He ? "bg-background" : "border-b bg-muted/30"),
2997
+ className: W("flex items-center justify-end px-4 py-2", nt ? "bg-background" : "border-b bg-muted/30"),
2812
2998
  children: /* @__PURE__ */ Z("button", {
2813
2999
  type: "button",
2814
3000
  onClick: a,
2815
3001
  className: "text-xs text-muted-foreground hover:text-foreground transition-colors",
2816
- children: J.clear
3002
+ children: q.clear
2817
3003
  })
2818
3004
  }),
2819
3005
  A ? /* @__PURE__ */ Z("div", {
2820
- className: G("shrink-0", !He && "border-b bg-background/50"),
3006
+ className: W("shrink-0", !nt && "border-b bg-background/50"),
2821
3007
  children: A
2822
3008
  }) : null,
2823
- /* @__PURE__ */ Q(nr, {
3009
+ /* @__PURE__ */ Q(gr, {
2824
3010
  className: "flex-1 min-h-0",
2825
- children: [/* @__PURE__ */ Q(rr, {
2826
- className: G("space-y-4", He ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
2827
- children: [n.length === 0 ? /* @__PURE__ */ Q(ir, {
3011
+ children: [/* @__PURE__ */ Q(_r, {
3012
+ className: W("space-y-4", nt ? "mx-auto w-full max-w-2xl px-4 py-8 sm:px-0" : "px-4 py-3"),
3013
+ children: [n.length === 0 ? /* @__PURE__ */ Q(vr, {
2828
3014
  className: "gap-3 px-0 py-8",
2829
3015
  children: [
2830
3016
  /* @__PURE__ */ Z("div", {
@@ -2833,49 +3019,49 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2833
3019
  src: _,
2834
3020
  alt: "",
2835
3021
  className: "size-full rounded-md object-cover"
2836
- }) : /* @__PURE__ */ Z(Fe, { className: "size-4" })
3022
+ }) : /* @__PURE__ */ Z(Ie, { className: "size-4" })
2837
3023
  }),
2838
3024
  /* @__PURE__ */ Q("div", {
2839
3025
  className: "w-full max-w-full space-y-1",
2840
3026
  children: [/* @__PURE__ */ Z("h3", {
2841
3027
  className: "text-sm font-medium text-foreground/90 break-words",
2842
- children: J.emptyTitle
3028
+ children: q.emptyTitle
2843
3029
  }), /* @__PURE__ */ Z("p", {
2844
3030
  className: "text-sm text-muted-foreground break-words",
2845
- children: J.emptyDescription
3031
+ children: q.emptyDescription
2846
3032
  })]
2847
3033
  }),
2848
3034
  T && T.length > 0 ? /* @__PURE__ */ Z("div", {
2849
3035
  className: "flex w-full max-w-full flex-wrap justify-center gap-2",
2850
- children: T.map((e) => /* @__PURE__ */ Z(Ci, {
3036
+ children: T.map((e) => /* @__PURE__ */ Z(Li, {
2851
3037
  className: "h-auto min-h-8 min-w-0 max-w-full whitespace-normal break-words rounded-full border-border/60 bg-background/80 px-3 py-1 text-left text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
2852
3038
  suggestion: e,
2853
- onClick: xt
3039
+ onClick: Ot
2854
3040
  }, e))
2855
3041
  }) : null
2856
3042
  ]
2857
3043
  }) : n.map((e) => {
2858
- let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && q === "summary" ? n.filter((e) => !aa(e) && !(o && e.toolName === "propose_blueprint")) : [], l = !t && q === "debug" ? n : !t && q !== "debug" ? n.filter(aa) : [], u = !t && e.content.trim().length > 0 && !sa(e.content), d = q === "debug" && !!r, f = !t && !!e.streaming && !u && c.length === 0 && l.length === 0 && !d && !a && !o;
2859
- return /* @__PURE__ */ Z(lr, {
2860
- from: Yi(e.role),
3044
+ let t = e.role === "user", n = e.toolInvocations ?? [], r = e.reasoning?.trim(), i = e.sources ?? [], a = t ? void 0 : e.buildProgress, o = !t && !n.some((e) => !!e.proposedPlan) ? e.blueprintProgress : void 0, c = !t && K === "summary" ? n.filter((e) => !ya(e) && !(o && e.toolName === "propose_blueprint")) : [], l = !t && K === "debug" ? n : !t && K !== "debug" ? n.filter(ya) : [], u = !t && e.content.trim().length > 0 && !xa(e.content), d = K === "debug" && !!r, f = !t && !!e.streaming && !u && c.length === 0 && l.length === 0 && !d && !a && !o;
3045
+ return /* @__PURE__ */ Z(Cr, {
3046
+ from: la(e.role),
2861
3047
  children: /* @__PURE__ */ Q("div", {
2862
- className: G("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
2863
- children: [m ? /* @__PURE__ */ Z(da, {
3048
+ className: W("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
3049
+ children: [m ? /* @__PURE__ */ Z(Ta, {
2864
3050
  isUser: t,
2865
3051
  url: t ? h : _,
2866
3052
  fallback: t ? g : v
2867
3053
  }) : null, /* @__PURE__ */ Q("div", {
2868
- className: G("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
2869
- children: [/* @__PURE__ */ Q(ur, { children: [
2870
- o ? /* @__PURE__ */ Z(Ea, {
3054
+ className: W("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
3055
+ children: [/* @__PURE__ */ Q(wr, { children: [
3056
+ o ? /* @__PURE__ */ Z(Ba, {
2871
3057
  progress: o,
2872
- designingLabel: J.designingPlanLabel,
2873
- extendLabel: ge,
2874
- waitingLabel: J.connectionWaiting,
2875
- stalledLabel: J.connectionStalledLabel,
2876
- offlineLabel: J.connectionOfflineLabel
3058
+ designingLabel: q.designingPlanLabel,
3059
+ extendLabel: _e,
3060
+ waitingLabel: q.connectionWaiting,
3061
+ stalledLabel: q.connectionStalledLabel,
3062
+ offlineLabel: q.connectionOfflineLabel
2877
3063
  }) : null,
2878
- a ? /* @__PURE__ */ Z(Da, {
3064
+ a ? /* @__PURE__ */ Z(Va, {
2879
3065
  progress: a,
2880
3066
  appSegment: e.toolInvocations?.map((e) => e.draftReview).find((e) => e?.packageId && e.items?.some((e) => e.type === "app"))?.packageId,
2881
3067
  onOpenBuiltApp: re,
@@ -2885,27 +3071,27 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2885
3071
  getArtifactAction: oe,
2886
3072
  onPreviewDraftApp: z,
2887
3073
  previewDraftLabel: B,
2888
- waitingLabel: J.connectionWaiting,
2889
- stalledLabel: J.connectionStalledLabel,
2890
- offlineLabel: J.connectionOfflineLabel
3074
+ waitingLabel: q.connectionWaiting,
3075
+ stalledLabel: q.connectionStalledLabel,
3076
+ offlineLabel: q.connectionOfflineLabel
2891
3077
  }) : null,
2892
- !t && q === "debug" && r ? /* @__PURE__ */ Q(Bi, {
3078
+ !t && K === "debug" && r ? /* @__PURE__ */ Q(ea, {
2893
3079
  isStreaming: !!e.streaming && !e.content,
2894
3080
  className: "mb-2",
2895
- children: [/* @__PURE__ */ Z(Hi, {}), /* @__PURE__ */ Z(Ui, { children: r })]
3081
+ children: [/* @__PURE__ */ Z(na, {}), /* @__PURE__ */ Z(ra, { children: r })]
2896
3082
  }) : null,
2897
- !t && q === "summary" && c.length > 0 ? /* @__PURE__ */ Z(Oa, {
2898
- groups: ca(c),
2899
- labels: J
3083
+ !t && K === "summary" && c.length > 0 ? /* @__PURE__ */ Z(Ha, {
3084
+ groups: Sa(c),
3085
+ labels: q
2900
3086
  }) : null,
2901
- !t && l.length > 0 ? l.map(Mt) : null,
3087
+ !t && l.length > 0 ? l.map(Wt) : null,
2902
3088
  t ? e.content ? /* @__PURE__ */ Z("div", {
2903
3089
  className: "whitespace-pre-wrap break-words",
2904
3090
  children: e.content
2905
- }) : null : f ? /* @__PURE__ */ Z(pa, {}) : u ? /* @__PURE__ */ Z(xr, { children: e.content }) : !e.streaming && sa(e.content) ? /* @__PURE__ */ Z("span", {
3091
+ }) : null : f ? /* @__PURE__ */ Z(Da, {}) : u ? /* @__PURE__ */ Z(Fr, { children: e.content }) : !e.streaming && xa(e.content) ? /* @__PURE__ */ Z("span", {
2906
3092
  className: "text-xs italic text-muted-foreground/70",
2907
3093
  title: e.content,
2908
- children: J.agentActivity
3094
+ children: q.agentActivity
2909
3095
  }) : null,
2910
3096
  e.streaming && u ? /* @__PURE__ */ Z("span", {
2911
3097
  "aria-hidden": !0,
@@ -2930,7 +3116,7 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2930
3116
  } })]
2931
3117
  }, t))
2932
3118
  }) : null,
2933
- !t && i.length > 0 ? /* @__PURE__ */ Q(Wi, { children: [/* @__PURE__ */ Z(Gi, { count: i.length }), /* @__PURE__ */ Z(Ki, { children: i.map((e, t) => /* @__PURE__ */ Z(qi, {
3119
+ !t && i.length > 0 ? /* @__PURE__ */ Q(ia, { children: [/* @__PURE__ */ Z(aa, { count: i.length }), /* @__PURE__ */ Z(oa, { children: i.map((e, t) => /* @__PURE__ */ Z(sa, {
2934
3120
  href: e.url,
2935
3121
  title: e.title ?? e.url
2936
3122
  }, e.id ?? e.url ?? t)) })] }) : null,
@@ -2938,133 +3124,144 @@ var ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
2938
3124
  className: "text-[10px] opacity-70 mt-1",
2939
3125
  children: e.timestamp
2940
3126
  }) : null
2941
- ] }), !t && !f ? /* @__PURE__ */ Q(dr, {
3127
+ ] }), !t && !f ? /* @__PURE__ */ Q(Tr, {
2942
3128
  className: "opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100",
2943
3129
  children: [
2944
- /* @__PURE__ */ Z(fr, {
2945
- label: We === e.id ? J.copied : J.copy,
2946
- tooltip: We === e.id ? J.copied : J.copy,
2947
- onClick: () => Ot(e),
2948
- children: We === e.id ? /* @__PURE__ */ Z(Le, { className: "size-3.5" }) : /* @__PURE__ */ Z(qe, { className: "size-3.5" })
3130
+ /* @__PURE__ */ Z(Er, {
3131
+ label: rt === e.id ? q.copied : q.copy,
3132
+ tooltip: rt === e.id ? q.copied : q.copy,
3133
+ onClick: () => zt(e),
3134
+ children: rt === e.id ? /* @__PURE__ */ Z(Re, { className: "size-3.5" }) : /* @__PURE__ */ Z(Je, { className: "size-3.5" })
2949
3135
  }),
2950
- s ? /* @__PURE__ */ Z(fr, {
2951
- label: J.regenerate,
2952
- tooltip: J.regenerate,
3136
+ s ? /* @__PURE__ */ Z(Er, {
3137
+ label: q.regenerate,
3138
+ tooltip: q.regenerate,
2953
3139
  onClick: s,
2954
- children: /* @__PURE__ */ Z(lt, { className: "size-3.5" })
3140
+ children: /* @__PURE__ */ Z(ut, { className: "size-3.5" })
2955
3141
  }) : null,
2956
- q === "debug" && e.traceId ? /* @__PURE__ */ Z("a", {
3142
+ K === "debug" && e.traceId ? /* @__PURE__ */ Z("a", {
2957
3143
  href: `#trace/${e.traceId}`,
2958
3144
  "data-trace-id": e.traceId,
2959
3145
  className: "text-[10px] text-muted-foreground hover:text-foreground ml-1 underline",
2960
- title: J.viewTrace,
2961
- children: J.trace
3146
+ title: q.viewTrace,
3147
+ children: q.trace
2962
3148
  }) : null
2963
3149
  ]
2964
3150
  }) : null]
2965
3151
  })]
2966
3152
  })
2967
3153
  }, e.id);
2968
- }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(fa, {
3154
+ }), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Z(Ea, {
2969
3155
  showAvatar: m,
2970
3156
  assistantAvatarUrl: _,
2971
3157
  assistantAvatarFallback: v,
2972
- waitingLabel: J.connectionWaiting,
2973
- stalledLabel: J.connectionStalledLabel,
2974
- offlineLabel: J.connectionOfflineLabel
3158
+ waitingLabel: q.connectionWaiting,
3159
+ stalledLabel: q.connectionStalledLabel,
3160
+ offlineLabel: q.connectionOfflineLabel
2975
3161
  }) : null]
2976
- }), /* @__PURE__ */ Z(ar, {})]
3162
+ }), /* @__PURE__ */ Z(yr, {})]
2977
3163
  }),
2978
- f ? $n(f) && !Qn(f) ? /* @__PURE__ */ Z(ja, {
3164
+ f ? pr(f) && !fr(f) ? /* @__PURE__ */ Z(Ga, {
2979
3165
  error: f,
2980
- rateLimitedLabel: J.sendFailedRateLimited,
2981
- genericLabel: J.sendFailedGeneric
2982
- }) : /* @__PURE__ */ Z(Ma, {
3166
+ rateLimitedLabel: q.sendFailedRateLimited,
3167
+ genericLabel: q.sendFailedGeneric
3168
+ }) : /* @__PURE__ */ Z(Ka, {
2983
3169
  error: f,
2984
3170
  onReload: s,
2985
3171
  onUpgrade: c
2986
3172
  }) : null,
2987
3173
  u ? null : /* @__PURE__ */ Q("div", {
2988
- ref: St,
2989
- className: G("relative", He && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
2990
- children: [j ? /* @__PURE__ */ Z("div", {
2991
- className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
2992
- children: j
2993
- }) : null, /* @__PURE__ */ Q(Ur, {
2994
- accept: C,
2995
- fileInputLabel: J.uploadFiles,
2996
- maxFileSize: w,
2997
- onSubmit: bt,
2998
- onError: (e) => {
2999
- console.warn("[plugin-chatbot] prompt-input error", e);
3000
- },
3001
- children: [
3002
- S ? /* @__PURE__ */ Z(Wr, { children: /* @__PURE__ */ Z(Vr, { children: (e) => /* @__PURE__ */ Z(Br, { data: e }) }) }) : null,
3003
- /* @__PURE__ */ Z(Gr, {
3004
- placeholder: r,
3005
- disabled: l || Ve === "streaming",
3006
- onChange: M ? (e) => M(e.currentTarget.value) : void 0
3007
- }),
3008
- /* @__PURE__ */ Q(qr, { children: [/* @__PURE__ */ Q(Jr, { children: [
3009
- S ? /* @__PURE__ */ Q(Xr, { children: [/* @__PURE__ */ Z(Zr, {}), /* @__PURE__ */ Z(Qr, { children: /* @__PURE__ */ Z(Hr, {}) })] }) : null,
3010
- D && D.length > 1 ? /* @__PURE__ */ Z("select", {
3011
- "aria-label": J.model,
3012
- value: O ?? D[0].id,
3013
- onChange: (e) => k?.(e.target.value),
3014
- className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
3015
- children: D.map((e) => /* @__PURE__ */ Q("option", {
3016
- value: e.id,
3017
- children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
3018
- }, e.id))
3019
- }) : null,
3020
- /* @__PURE__ */ Q("span", {
3021
- className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
3022
- "aria-hidden": "true",
3023
- children: [/* @__PURE__ */ Z(Ye, { className: "h-3 w-3" }), /* @__PURE__ */ Z("span", {
3024
- className: "opacity-70",
3025
- children: J.sendHint
3026
- })]
3027
- })
3028
- ] }), /* @__PURE__ */ Z(ei, {
3029
- "aria-label": Ve === "streaming" ? J.stopResponse : J.submit,
3030
- status: Ve,
3031
- disabled: l,
3032
- onClick: Ve === "streaming" ? o : void 0,
3033
- type: Ve === "streaming" ? "button" : "submit"
3034
- })] })
3035
- ]
3036
- })]
3174
+ ref: kt,
3175
+ className: W("relative", nt && "mx-auto w-full max-w-2xl px-4 pb-4 sm:px-0"),
3176
+ children: [
3177
+ Ve ? /* @__PURE__ */ Z("div", {
3178
+ className: "mb-1 flex",
3179
+ "data-testid": "surface-context-chip",
3180
+ children: /* @__PURE__ */ Z("span", {
3181
+ className: "inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-[11px] text-muted-foreground",
3182
+ children: Ve
3183
+ })
3184
+ }) : null,
3185
+ j ? /* @__PURE__ */ Z("div", {
3186
+ className: "absolute bottom-full left-0 right-0 z-10 px-3 pb-1",
3187
+ children: j
3188
+ }) : null,
3189
+ /* @__PURE__ */ Q(ri, {
3190
+ accept: C,
3191
+ fileInputLabel: q.uploadFiles,
3192
+ maxFileSize: w,
3193
+ onSubmit: Dt,
3194
+ onError: (e) => {
3195
+ console.warn("[plugin-chatbot] prompt-input error", e);
3196
+ },
3197
+ children: [
3198
+ S ? /* @__PURE__ */ Z(ii, { children: /* @__PURE__ */ Z(ti, { children: (e) => /* @__PURE__ */ Z(ei, { data: e }) }) }) : null,
3199
+ /* @__PURE__ */ Z(ai, {
3200
+ placeholder: r,
3201
+ disabled: l || Ze === "streaming",
3202
+ onChange: M ? (e) => M(e.currentTarget.value) : void 0
3203
+ }),
3204
+ /* @__PURE__ */ Q(si, { children: [/* @__PURE__ */ Q(ci, { children: [
3205
+ S ? /* @__PURE__ */ Q(ui, { children: [/* @__PURE__ */ Z(di, {}), /* @__PURE__ */ Z(fi, { children: /* @__PURE__ */ Z(ni, {}) })] }) : null,
3206
+ D && D.length > 1 ? /* @__PURE__ */ Z("select", {
3207
+ "aria-label": q.model,
3208
+ value: O ?? D[0].id,
3209
+ onChange: (e) => k?.(e.target.value),
3210
+ className: "h-7 rounded-md border bg-background px-2 text-xs text-muted-foreground hover:text-foreground focus:outline-none focus:ring-1 focus:ring-ring",
3211
+ children: D.map((e) => /* @__PURE__ */ Q("option", {
3212
+ value: e.id,
3213
+ children: [e.label ?? e.id, e.provider ? ` · ${e.provider}` : ""]
3214
+ }, e.id))
3215
+ }) : null,
3216
+ /* @__PURE__ */ Q("span", {
3217
+ className: "hidden items-center gap-1 text-[10px] text-muted-foreground sm:inline-flex",
3218
+ "aria-hidden": "true",
3219
+ children: [/* @__PURE__ */ Z(Xe, { className: "h-3 w-3" }), /* @__PURE__ */ Z("span", {
3220
+ className: "opacity-70",
3221
+ children: q.sendHint
3222
+ })]
3223
+ })
3224
+ ] }), /* @__PURE__ */ Z(mi, {
3225
+ "aria-label": Ze === "streaming" ? q.stopResponse : q.submit,
3226
+ status: Ze,
3227
+ disabled: l,
3228
+ onClick: Ze === "streaming" ? o : void 0,
3229
+ type: Ze === "streaming" ? "button" : "submit"
3230
+ })] })
3231
+ ]
3232
+ })
3233
+ ]
3037
3234
  })
3038
3235
  ]
3039
3236
  });
3040
3237
  });
3041
- ua.displayName = "ChatbotEnhanced";
3042
- function da({ isUser: e, url: t, fallback: n }) {
3238
+ wa.displayName = "ChatbotEnhanced";
3239
+ function Ta({ isUser: e, url: t, fallback: n }) {
3043
3240
  return /* @__PURE__ */ Z("div", {
3044
- className: G("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
3241
+ className: W("mt-0.5 flex size-7 shrink-0 items-center justify-center overflow-hidden rounded-full text-[11px] font-medium", e ? "bg-secondary text-secondary-foreground" : "bg-primary/10 text-primary"),
3045
3242
  "aria-hidden": "true",
3046
3243
  children: t ? /* @__PURE__ */ Z("img", {
3047
3244
  src: t,
3048
3245
  alt: "",
3049
3246
  className: "size-full object-cover"
3050
- }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Z(Fe, { className: "size-4" })
3247
+ }) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Z(Ie, { className: "size-4" })
3051
3248
  });
3052
3249
  }
3053
- function fa({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
3054
- return /* @__PURE__ */ Z(lr, {
3250
+ function Ea({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
3251
+ return /* @__PURE__ */ Z(Cr, {
3055
3252
  from: "assistant",
3056
3253
  "aria-live": "polite",
3057
3254
  children: /* @__PURE__ */ Q("div", {
3058
- className: G("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
3059
- children: [e ? /* @__PURE__ */ Z(da, {
3255
+ className: W("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
3256
+ children: [e ? /* @__PURE__ */ Z(Ta, {
3060
3257
  isUser: !1,
3061
3258
  url: t,
3062
3259
  fallback: n
3063
- }) : null, /* @__PURE__ */ Z(ur, {
3260
+ }) : null, /* @__PURE__ */ Z(wr, {
3064
3261
  className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
3065
3262
  children: /* @__PURE__ */ Q("span", {
3066
3263
  className: "inline-flex items-center gap-2",
3067
- children: [/* @__PURE__ */ Z(pa, {}), /* @__PURE__ */ Z(va, {
3264
+ children: [/* @__PURE__ */ Z(Da, {}), /* @__PURE__ */ Z(Ma, {
3068
3265
  active: !0,
3069
3266
  pending: !0,
3070
3267
  activityKey: 0,
@@ -3077,7 +3274,7 @@ function fa({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
3077
3274
  })
3078
3275
  });
3079
3276
  }
3080
- function pa() {
3277
+ function Da() {
3081
3278
  return /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Z("span", {
3082
3279
  className: "sr-only",
3083
3280
  children: "Assistant is responding"
@@ -3091,12 +3288,12 @@ function pa() {
3091
3288
  ]
3092
3289
  })] });
3093
3290
  }
3094
- function ma(e) {
3291
+ function Oa(e) {
3095
3292
  let t = Math.floor(e / 60), n = e % 60;
3096
3293
  return `${t}:${String(n).padStart(2, "0")}`;
3097
3294
  }
3098
- var ha = 6;
3099
- function ga(t, n) {
3295
+ var ka = 6;
3296
+ function Aa(t, n) {
3100
3297
  let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
3101
3298
  elapsed: 0,
3102
3299
  quiet: 0
@@ -3125,10 +3322,10 @@ function ga(t, n) {
3125
3322
  }, [t]), {
3126
3323
  elapsedSeconds: a.elapsed,
3127
3324
  quietSeconds: a.quiet,
3128
- live: a.quiet < ha
3325
+ live: a.quiet < ka
3129
3326
  };
3130
3327
  }
3131
- function _a() {
3328
+ function ja() {
3132
3329
  let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
3133
3330
  return e.useEffect(() => {
3134
3331
  if (typeof window > "u") return;
@@ -3138,22 +3335,22 @@ function _a() {
3138
3335
  };
3139
3336
  }, []), t;
3140
3337
  }
3141
- function va({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3142
- let { elapsedSeconds: o, quietSeconds: s, live: c } = ga(e, t), l = _a() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = ma(o);
3338
+ function Ma({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3339
+ let { elapsedSeconds: o, quietSeconds: s, live: c } = Aa(e, t), l = ja() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = Oa(o);
3143
3340
  return /* @__PURE__ */ Q("span", {
3144
- className: G("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
3341
+ className: W("inline-flex items-center gap-1.5 text-xs tabular-nums", l === "offline" ? "text-red-600 font-medium" : l === "stalled" ? "text-amber-600 font-medium" : "font-normal text-muted-foreground"),
3145
3342
  "aria-live": "polite",
3146
3343
  "data-liveness-tier": l,
3147
3344
  title: l === "offline" ? `${a} · ${u} elapsed` : l === "receiving" ? `Receiving from server · ${u} elapsed` : l === "stalled" ? `${i} (${s}s with no response) · ${u} elapsed` : `${r} · ${u} elapsed`,
3148
3345
  children: [
3149
- l === "offline" ? /* @__PURE__ */ Z(_t, {
3346
+ l === "offline" ? /* @__PURE__ */ Z(vt, {
3150
3347
  className: "size-3 shrink-0",
3151
3348
  "aria-hidden": !0
3152
3349
  }) : /* @__PURE__ */ Z("span", {
3153
3350
  "aria-hidden": !0,
3154
- className: G("size-1.5 shrink-0 rounded-full", l === "receiving" ? "bg-emerald-500 animate-pulse" : l === "stalled" ? "bg-amber-500" : "bg-muted-foreground/50 animate-pulse")
3351
+ className: W("size-1.5 shrink-0 rounded-full", l === "receiving" ? "bg-emerald-500 animate-pulse" : l === "stalled" ? "bg-amber-500" : "bg-muted-foreground/50 animate-pulse")
3155
3352
  }),
3156
- /* @__PURE__ */ Z(Ge, {
3353
+ /* @__PURE__ */ Z(Ke, {
3157
3354
  className: "size-3 shrink-0",
3158
3355
  "aria-hidden": !0
3159
3356
  }),
@@ -3162,7 +3359,7 @@ function va({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
3162
3359
  ]
3163
3360
  });
3164
3361
  }
3165
- var ya = [
3362
+ var Na = [
3166
3363
  "Mapping out the data you’ll track…",
3167
3364
  "Shaping objects and their fields…",
3168
3365
  "Connecting related records…",
@@ -3173,27 +3370,27 @@ var ya = [
3173
3370
  "Sketching a dashboard to track it…",
3174
3371
  "Double-checking the structure hangs together…",
3175
3372
  "Pulling the plan together…"
3176
- ], ba = 3500;
3177
- function xa(e, t, n = ba) {
3373
+ ], Pa = 3500;
3374
+ function Fa(e, t, n = Pa) {
3178
3375
  if (t <= 0) return -1;
3179
3376
  if (t === 1) return 0;
3180
- let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ba));
3377
+ let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : Pa));
3181
3378
  return Math.min(r, t - 1);
3182
3379
  }
3183
- function Sa({ label: t, hints: n, offlineLabel: r }) {
3380
+ function Ia({ label: t, hints: n, offlineLabel: r }) {
3184
3381
  let [i, a] = e.useState(0);
3185
3382
  e.useEffect(() => {
3186
3383
  if (n.length <= 1) return;
3187
- let e = Date.now(), t = setInterval(() => a(Date.now() - e), ba);
3384
+ let e = Date.now(), t = setInterval(() => a(Date.now() - e), Pa);
3188
3385
  return () => clearInterval(t);
3189
3386
  }, [n.length]);
3190
- let o = xa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
3387
+ let o = Fa(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
3191
3388
  return /* @__PURE__ */ Q("span", {
3192
3389
  className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
3193
3390
  "data-testid": "build-proposal-progress",
3194
3391
  "aria-live": "polite",
3195
3392
  children: [
3196
- /* @__PURE__ */ Z(pt, {
3393
+ /* @__PURE__ */ Z(mt, {
3197
3394
  className: "size-3 shrink-0 animate-pulse text-primary",
3198
3395
  "aria-hidden": !0
3199
3396
  }),
@@ -3209,45 +3406,45 @@ function Sa({ label: t, hints: n, offlineLabel: r }) {
3209
3406
  className: "hidden shrink-0 items-center gap-0.5 sm:inline-flex",
3210
3407
  "data-testid": "build-proposal-progress-dots",
3211
3408
  "aria-hidden": !0,
3212
- children: n.map((e, t) => /* @__PURE__ */ Z("span", { className: G("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
3409
+ children: n.map((e, t) => /* @__PURE__ */ Z("span", { className: W("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
3213
3410
  }) : null,
3214
- /* @__PURE__ */ Z(Ca, { offlineLabel: r })
3411
+ /* @__PURE__ */ Z(La, { offlineLabel: r })
3215
3412
  ]
3216
3413
  });
3217
3414
  }
3218
- function Ca({ offlineLabel: t }) {
3219
- let [n, r] = e.useState(0), i = _a();
3415
+ function La({ offlineLabel: t }) {
3416
+ let [n, r] = e.useState(0), i = ja();
3220
3417
  return e.useEffect(() => {
3221
3418
  let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
3222
3419
  return () => clearInterval(t);
3223
3420
  }, []), /* @__PURE__ */ Q("span", {
3224
- className: G("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
3421
+ className: W("inline-flex items-center gap-1 text-xs tabular-nums", i ? "text-red-600 font-medium" : "text-muted-foreground"),
3225
3422
  "aria-live": "polite",
3226
3423
  "data-tool-running-timer": !0,
3227
3424
  children: [
3228
- Z(i ? _t : Ge, {
3425
+ Z(i ? vt : Ke, {
3229
3426
  className: "size-3 shrink-0",
3230
3427
  "aria-hidden": !0
3231
3428
  }),
3232
- /* @__PURE__ */ Z("span", { children: ma(n) }),
3429
+ /* @__PURE__ */ Z("span", { children: Oa(n) }),
3233
3430
  i ? /* @__PURE__ */ Q("span", { children: ["· ", t] }) : null
3234
3431
  ]
3235
3432
  });
3236
3433
  }
3237
- var wa = [
3434
+ var Ra = [
3238
3435
  "object",
3239
3436
  "view",
3240
3437
  "dashboard",
3241
3438
  "app",
3242
3439
  "seed"
3243
- ], Ta = {
3440
+ ], za = {
3244
3441
  object: "Objects",
3245
3442
  view: "Views",
3246
3443
  dashboard: "Dashboards",
3247
3444
  app: "App",
3248
3445
  seed: "Sample data"
3249
3446
  };
3250
- function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3447
+ function Ba({ progress: e, designingLabel: t = "Designing your app…", extendLabel: n = "Adding to existing app", waitingLabel: r = "Waiting for server…", stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
3251
3448
  let { phase: o, summary: s, appLabel: c, targetApp: l, objects: u, counts: d, seq: f } = e, p = o === "done", m = f ?? `${o}:${u.length}`, h = p && (s || c) || t, g = [];
3252
3449
  return d?.objects && g.push(`${d.objects} object${d.objects === 1 ? "" : "s"}`), d?.views && g.push(`${d.views} view${d.views === 1 ? "" : "s"}`), d?.dashboards && g.push(`${d.dashboards} dashboard${d.dashboards === 1 ? "" : "s"}`), /* @__PURE__ */ Q("div", {
3253
3450
  className: "rounded-lg border bg-muted/30 p-3 text-sm",
@@ -3256,7 +3453,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
3256
3453
  /* @__PURE__ */ Q("div", {
3257
3454
  className: "mb-2 flex items-center gap-2 font-medium",
3258
3455
  children: [
3259
- p ? /* @__PURE__ */ Z(K, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(nt, { className: "size-4 shrink-0 animate-spin text-primary" }),
3456
+ p ? /* @__PURE__ */ Z(G, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(it, { className: "size-4 shrink-0 animate-spin text-primary" }),
3260
3457
  /* @__PURE__ */ Z("span", {
3261
3458
  className: "min-w-0 truncate",
3262
3459
  children: h
@@ -3274,7 +3471,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
3274
3471
  }) : null,
3275
3472
  p ? null : /* @__PURE__ */ Z("span", {
3276
3473
  className: "ml-auto shrink-0",
3277
- children: /* @__PURE__ */ Z(va, {
3474
+ children: /* @__PURE__ */ Z(Ma, {
3278
3475
  active: !0,
3279
3476
  activityKey: m,
3280
3477
  waitingLabel: r,
@@ -3295,7 +3492,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
3295
3492
  className: "inline-flex animate-in fade-in items-center gap-1 rounded-md border bg-background px-1.5 py-0.5 text-[11px] text-foreground/80 duration-500",
3296
3493
  title: e.name,
3297
3494
  children: [
3298
- /* @__PURE__ */ Z(ht, { className: "size-3 text-foreground/40" }),
3495
+ /* @__PURE__ */ Z(gt, { className: "size-3 text-foreground/40" }),
3299
3496
  e.label || e.name,
3300
3497
  e.fields ? /* @__PURE__ */ Q("span", {
3301
3498
  className: "text-foreground/40",
@@ -3311,7 +3508,7 @@ function Ea({ progress: e, designingLabel: t = "Designing your app…", extendLa
3311
3508
  ]
3312
3509
  });
3313
3510
  }
3314
- function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel: i = "Open app", onDesignBuiltApp: a, designBuiltAppLabel: o = "Design in Studio", getArtifactAction: s, onPreviewDraftApp: c, previewDraftLabel: l = "Preview", waitingLabel: u = "Waiting for server…", stalledLabel: d = "Still working…", offlineLabel: f = "Connection lost — reconnecting…" }) {
3511
+ function Va({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel: i = "Open app", onDesignBuiltApp: a, designBuiltAppLabel: o = "Design in Studio", getArtifactAction: s, onPreviewDraftApp: c, previewDraftLabel: l = "Preview", waitingLabel: u = "Waiting for server…", stalledLabel: d = "Still working…", offlineLabel: f = "Connection lost — reconnecting…" }) {
3315
3512
  let { phase: p, appLabel: m, items: h, done: g, total: _, seq: v } = t, y = p === "done", b = v ?? `${p}:${g}:${h.length}`, x = h.find((e) => e.type === "app"), S = _ > 0 ? Math.min(100, Math.round(g / _ * 100)) : y ? 100 : 6, C = /* @__PURE__ */ new Map();
3316
3513
  for (let e of h) {
3317
3514
  let t = C.get(e.type) ?? [];
@@ -3320,7 +3517,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3320
3517
  display: e.name.replace(/_sample$/, "")
3321
3518
  }), C.set(e.type, t);
3322
3519
  }
3323
- let w = [...wa.filter((e) => C.has(e)), ...[...C.keys()].filter((e) => !wa.includes(e))];
3520
+ let w = [...Ra.filter((e) => C.has(e)), ...[...C.keys()].filter((e) => !Ra.includes(e))];
3324
3521
  return /* @__PURE__ */ Q("div", {
3325
3522
  className: "rounded-lg border bg-muted/30 p-3 text-sm",
3326
3523
  "data-testid": "build-progress",
@@ -3328,7 +3525,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3328
3525
  /* @__PURE__ */ Q("div", {
3329
3526
  className: "mb-2 flex items-center gap-2 font-medium",
3330
3527
  children: [
3331
- y ? /* @__PURE__ */ Z(K, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(nt, { className: "size-4 shrink-0 animate-spin text-primary" }),
3528
+ y ? /* @__PURE__ */ Z(G, { className: "size-4 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(it, { className: "size-4 shrink-0 animate-spin text-primary" }),
3332
3529
  /* @__PURE__ */ Z("span", { children: y ? `Built ${m ?? "your app"}` : `Building ${m ?? "your app"}…` }),
3333
3530
  !y && p === "data" ? /* @__PURE__ */ Z("span", {
3334
3531
  className: "text-xs font-normal text-muted-foreground",
@@ -3336,7 +3533,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3336
3533
  }) : null,
3337
3534
  y ? null : /* @__PURE__ */ Z("span", {
3338
3535
  className: "ml-auto",
3339
- children: /* @__PURE__ */ Z(va, {
3536
+ children: /* @__PURE__ */ Z(Ma, {
3340
3537
  active: !0,
3341
3538
  activityKey: b,
3342
3539
  waitingLabel: u,
@@ -3349,7 +3546,7 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3349
3546
  /* @__PURE__ */ Z("div", {
3350
3547
  className: "mb-2 h-1.5 w-full overflow-hidden rounded-full bg-muted",
3351
3548
  children: /* @__PURE__ */ Z("div", {
3352
- className: G("h-full rounded-full transition-all duration-500", y ? "bg-emerald-500" : "bg-primary"),
3549
+ className: W("h-full rounded-full transition-all duration-500", y ? "bg-emerald-500" : "bg-primary"),
3353
3550
  style: { width: `${S}%` }
3354
3551
  })
3355
3552
  }),
@@ -3359,12 +3556,12 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3359
3556
  let r = C.get(t);
3360
3557
  return /* @__PURE__ */ Q("li", {
3361
3558
  className: "flex items-start gap-2",
3362
- children: [/* @__PURE__ */ Z(K, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ Q("span", {
3559
+ children: [/* @__PURE__ */ Z(G, { className: "mt-0.5 size-3.5 shrink-0 text-emerald-600" }), /* @__PURE__ */ Q("span", {
3363
3560
  className: "min-w-0 text-muted-foreground",
3364
3561
  children: [
3365
3562
  /* @__PURE__ */ Z("span", {
3366
3563
  className: "font-medium text-foreground",
3367
- children: Ta[t] ?? t
3564
+ children: za[t] ?? t
3368
3565
  }),
3369
3566
  " ",
3370
3567
  r.slice(0, 6).map((r, i) => {
@@ -3394,28 +3591,28 @@ function Da({ progress: t, appSegment: n, onOpenBuiltApp: r, openBuiltAppLabel:
3394
3591
  onClick: () => a(x.name, n),
3395
3592
  className: "inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground hover:bg-primary/90",
3396
3593
  "data-testid": "build-progress-design-app",
3397
- children: [o, /* @__PURE__ */ Z(Ne, { className: "size-3.5" })]
3594
+ children: [o, /* @__PURE__ */ Z(Pe, { className: "size-3.5" })]
3398
3595
  }) : null,
3399
3596
  r ? /* @__PURE__ */ Q("button", {
3400
3597
  type: "button",
3401
3598
  onClick: () => r(x.name),
3402
- className: G("inline-flex h-7 items-center gap-1.5 rounded-md px-3 text-xs font-medium", a ? "border hover:bg-muted" : "bg-primary text-primary-foreground hover:bg-primary/90"),
3599
+ className: W("inline-flex h-7 items-center gap-1.5 rounded-md px-3 text-xs font-medium", a ? "border hover:bg-muted" : "bg-primary text-primary-foreground hover:bg-primary/90"),
3403
3600
  "data-testid": "build-progress-open-app",
3404
- children: [i, /* @__PURE__ */ Z(Ne, { className: "size-3.5" })]
3601
+ children: [i, /* @__PURE__ */ Z(Pe, { className: "size-3.5" })]
3405
3602
  }) : null,
3406
3603
  c ? /* @__PURE__ */ Q("button", {
3407
3604
  type: "button",
3408
3605
  onClick: () => c(x.name),
3409
3606
  className: "inline-flex h-7 items-center gap-1.5 rounded-md border px-3 text-xs font-medium hover:bg-muted",
3410
3607
  "data-testid": "build-progress-preview-app",
3411
- children: [/* @__PURE__ */ Z(Xe, { className: "size-3.5" }), l]
3608
+ children: [/* @__PURE__ */ Z(Qe, { className: "size-3.5" }), l]
3412
3609
  }) : null
3413
3610
  ]
3414
3611
  }) : null
3415
3612
  ]
3416
3613
  });
3417
3614
  }
3418
- function Oa({ groups: e, labels: t }) {
3615
+ function Ha({ groups: e, labels: t }) {
3419
3616
  return e.length === 0 ? null : /* @__PURE__ */ Z("div", {
3420
3617
  className: "not-prose mb-2 border-l border-border/70 pl-3",
3421
3618
  children: /* @__PURE__ */ Z("div", {
@@ -3425,7 +3622,7 @@ function Oa({ groups: e, labels: t }) {
3425
3622
  children: [/* @__PURE__ */ Q("div", {
3426
3623
  className: "flex min-w-0 items-center gap-2",
3427
3624
  children: [
3428
- /* @__PURE__ */ Z(ka, { state: e.state }),
3625
+ /* @__PURE__ */ Z(Ua, { state: e.state }),
3429
3626
  /* @__PURE__ */ Z("span", {
3430
3627
  className: "truncate font-medium text-foreground",
3431
3628
  children: e.title
@@ -3435,22 +3632,22 @@ function Oa({ groups: e, labels: t }) {
3435
3632
  children: ["x", e.count]
3436
3633
  }) : null
3437
3634
  ]
3438
- }), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(Sa, {
3635
+ }), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Z(Ia, {
3439
3636
  label: t.designingPlanLabel,
3440
3637
  hints: t.designingPlanHints,
3441
3638
  offlineLabel: t.connectionOfflineLabel
3442
- }) : /* @__PURE__ */ Z(Ca, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Z("span", {
3443
- className: G("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
3444
- children: Aa(e.state, t)
3639
+ }) : /* @__PURE__ */ Z(La, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Z("span", {
3640
+ className: W("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
3641
+ children: Wa(e.state, t)
3445
3642
  })]
3446
3643
  }, e.key))
3447
3644
  })
3448
3645
  });
3449
3646
  }
3450
- function ka({ state: e }) {
3451
- return e === "failed" ? /* @__PURE__ */ Z(Y, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Z(K, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(Ge, { className: "size-3.5 shrink-0 text-muted-foreground" });
3647
+ function Ua({ state: e }) {
3648
+ return e === "failed" ? /* @__PURE__ */ Z(J, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Z(G, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Z(Ke, { className: "size-3.5 shrink-0 text-muted-foreground" });
3452
3649
  }
3453
- function Aa(e, t) {
3650
+ function Wa(e, t) {
3454
3651
  switch (e) {
3455
3652
  case "failed": return t.toolFailed;
3456
3653
  case "awaiting": return t.toolAwaitingApproval;
@@ -3458,8 +3655,8 @@ function Aa(e, t) {
3458
3655
  case "completed": return t.toolCompleted;
3459
3656
  }
3460
3657
  }
3461
- function ja({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3462
- let i = e.useMemo(() => tr(t) ? n : r, [
3658
+ function Ga({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3659
+ let i = e.useMemo(() => hr(t) ? n : r, [
3463
3660
  t,
3464
3661
  n,
3465
3662
  r
@@ -3472,7 +3669,7 @@ function ja({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3472
3669
  className: "rounded-md border border-amber-300/40 bg-amber-50/60 px-3 py-2 text-foreground dark:bg-amber-950/20",
3473
3670
  children: /* @__PURE__ */ Q("div", {
3474
3671
  className: "flex items-start gap-2",
3475
- children: [/* @__PURE__ */ Z(gt, { className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600" }), /* @__PURE__ */ Z("div", {
3672
+ children: [/* @__PURE__ */ Z(_t, { className: "mt-0.5 h-4 w-4 shrink-0 text-amber-600" }), /* @__PURE__ */ Z("div", {
3476
3673
  className: "min-w-0 flex-1 break-words leading-snug",
3477
3674
  children: i
3478
3675
  })]
@@ -3480,8 +3677,8 @@ function ja({ error: t, rateLimitedLabel: n, genericLabel: r }) {
3480
3677
  })
3481
3678
  });
3482
3679
  }
3483
- function Ma({ error: t, onReload: n, onUpgrade: r }) {
3484
- let { language: i } = Et(), a = Dt(), o = e.useMemo(() => Qn(t), [t]), { summary: s, details: c } = e.useMemo(() => Xn(t), [t]), [l, u] = e.useState(!1);
3680
+ function Ka({ error: t, onReload: n, onUpgrade: r }) {
3681
+ let { language: i } = Dt(), a = Ot(), o = e.useMemo(() => fr(t), [t]), { summary: s, details: c } = e.useMemo(() => cr(t), [t]), [l, u] = e.useState(!1);
3485
3682
  if (o) {
3486
3683
  let e = (i.toLowerCase().startsWith("zh") ? o.message : o.messageEn ?? o.message) || a("chatbotQuota.fallbackMessage", "You have reached your AI quota."), t = o.topUp ? a("chatbotQuota.buyCredits", "Buy a credit pack") : a("chatbotQuota.upgradePlan", "Upgrade plan"), n = a("chatbotQuota.title", "Upgrade needed");
3487
3684
  return /* @__PURE__ */ Z("div", {
@@ -3518,7 +3715,7 @@ function Ma({ error: t, onReload: n, onUpgrade: r }) {
3518
3715
  children: [/* @__PURE__ */ Q("div", {
3519
3716
  className: "flex items-start gap-2",
3520
3717
  children: [
3521
- /* @__PURE__ */ Z(je, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
3718
+ /* @__PURE__ */ Z(Me, { className: "mt-0.5 h-4 w-4 shrink-0 text-destructive" }),
3522
3719
  /* @__PURE__ */ Q("div", {
3523
3720
  className: "min-w-0 flex-1",
3524
3721
  children: [/* @__PURE__ */ Z("div", {
@@ -3541,7 +3738,7 @@ function Ma({ error: t, onReload: n, onUpgrade: r }) {
3541
3738
  type: "button",
3542
3739
  onClick: n,
3543
3740
  className: "inline-flex h-7 items-center rounded-md border border-destructive/30 bg-background px-2 text-xs font-medium text-destructive hover:bg-destructive/10",
3544
- children: [/* @__PURE__ */ Z(lt, { className: "mr-1 h-3 w-3" }), a("chatbotError.retry", "Retry")]
3741
+ children: [/* @__PURE__ */ Z(ut, { className: "mr-1 h-3 w-3" }), a("chatbotError.retry", "Retry")]
3545
3742
  }) : null]
3546
3743
  })
3547
3744
  ]
@@ -3552,27 +3749,27 @@ function Ma({ error: t, onReload: n, onUpgrade: r }) {
3552
3749
  })
3553
3750
  });
3554
3751
  }
3555
- function Na({ output: e, errorText: t }) {
3556
- return t ? /* @__PURE__ */ Z(Pi, {
3752
+ function qa({ output: e, errorText: t }) {
3753
+ return t ? /* @__PURE__ */ Z(Ji, {
3557
3754
  output: void 0,
3558
3755
  errorText: t
3559
- }) : e == null || e === "" ? null : typeof e == "string" && !Xi(e) ? /* @__PURE__ */ Q("div", {
3756
+ }) : e == null || e === "" ? null : typeof e == "string" && !ua(e) ? /* @__PURE__ */ Q("div", {
3560
3757
  className: "space-y-2 p-4",
3561
3758
  children: [/* @__PURE__ */ Z("h4", {
3562
3759
  className: "font-medium text-muted-foreground text-xs uppercase tracking-wide",
3563
3760
  children: "Result"
3564
3761
  }), /* @__PURE__ */ Z("div", {
3565
3762
  className: "overflow-x-auto rounded-md bg-muted/40 px-3 py-2 text-sm text-foreground",
3566
- children: /* @__PURE__ */ Z(xr, { children: e })
3763
+ children: /* @__PURE__ */ Z(Fr, { children: e })
3567
3764
  })]
3568
- }) : /* @__PURE__ */ Z(Pi, {
3765
+ }) : /* @__PURE__ */ Z(Ji, {
3569
3766
  output: e,
3570
3767
  errorText: void 0
3571
3768
  });
3572
3769
  }
3573
3770
  //#endregion
3574
3771
  //#region src/FloatingChatbot.tsx
3575
- function Pa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3772
+ function Ja({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3576
3773
  let { position: a = "bottom-right", defaultOpen: o = !1, panelWidth: s = 400, panelHeight: c = 520, title: l = "Chat", triggerSize: u = 56 } = t ?? {}, [d, f] = e.useState(null);
3577
3774
  e.useEffect(() => {
3578
3775
  let e = document.getElementById("floating-chatbot-portal");
@@ -3580,19 +3777,19 @@ function Pa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3580
3777
  e && e.parentNode && !e.hasChildNodes() && e.parentNode.removeChild(e);
3581
3778
  };
3582
3779
  }, []);
3583
- let p = /* @__PURE__ */ Q(Pn, {
3780
+ let p = /* @__PURE__ */ Q(Kn, {
3584
3781
  defaultOpen: o,
3585
- children: [/* @__PURE__ */ Z(Bn, {
3782
+ children: [/* @__PURE__ */ Z(Qn, {
3586
3783
  position: a,
3587
3784
  size: u
3588
- }), /* @__PURE__ */ Z(Kn, {
3785
+ }), /* @__PURE__ */ Z(ir, {
3589
3786
  title: l,
3590
3787
  position: a,
3591
3788
  width: s,
3592
3789
  height: c,
3593
3790
  headerExtra: n,
3594
3791
  headerActions: r,
3595
- children: /* @__PURE__ */ Z(ua, {
3792
+ children: /* @__PURE__ */ Z(wa, {
3596
3793
  ...i,
3597
3794
  maxHeight: "100%",
3598
3795
  className: "h-full border-0 rounded-none"
@@ -3601,8 +3798,8 @@ function Pa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
3601
3798
  });
3602
3799
  return d ? wt.createPortal(p, d) : p;
3603
3800
  }
3604
- Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3605
- let { messages: r, isLoading: i, sendMessage: a } = fn({
3801
+ Rt.register("chatbot", ({ schema: e, className: t, disabled: n, ...r }) => {
3802
+ let { messages: i, isLoading: a, sendMessage: o } = wn({
3606
3803
  api: e.api,
3607
3804
  initialMessages: e.messages,
3608
3805
  conversationId: e.conversationId,
@@ -3618,22 +3815,22 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3618
3815
  autoResponseText: e.autoResponseText,
3619
3816
  autoResponseDelay: e.autoResponseDelay,
3620
3817
  onSend: e.onSend
3621
- });
3622
- return /* @__PURE__ */ Z(to, {
3623
- messages: r,
3818
+ }), s = (e) => {
3819
+ o(e);
3820
+ }, c = l(() => hn(i), [i]);
3821
+ return /* @__PURE__ */ Z(go, {
3822
+ ...zt(r),
3823
+ messages: c,
3624
3824
  placeholder: e.placeholder,
3625
- onSendMessage: (e) => {
3626
- a(e);
3627
- },
3628
- disabled: e.disabled || i,
3825
+ onSendMessage: s,
3826
+ disabled: n || a,
3629
3827
  showTimestamp: e.showTimestamp,
3630
3828
  userAvatarUrl: e.userAvatarUrl,
3631
3829
  userAvatarFallback: e.userAvatarFallback,
3632
3830
  assistantAvatarUrl: e.assistantAvatarUrl,
3633
3831
  assistantAvatarFallback: e.assistantAvatarFallback,
3634
3832
  maxHeight: e.maxHeight,
3635
- className: t,
3636
- ...n
3833
+ className: t
3637
3834
  });
3638
3835
  }, {
3639
3836
  namespace: "plugin-chatbot",
@@ -3767,8 +3964,8 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3767
3964
  autoResponseDelay: 1e3,
3768
3965
  className: "w-full max-w-2xl"
3769
3966
  }
3770
- }), Lt.register("chatbot-enhanced", ({ schema: e, className: t, ...n }) => {
3771
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = fn({
3967
+ }), Rt.register("chatbot-enhanced", ({ schema: e, className: t, disabled: n, ...r }) => {
3968
+ let { messages: i, isLoading: a, error: o, sendMessage: s, stop: c, reload: u, clear: d, isApiMode: f } = wn({
3772
3969
  api: e.api,
3773
3970
  initialMessages: e.messages,
3774
3971
  conversationId: e.conversationId,
@@ -3784,21 +3981,22 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3784
3981
  autoResponseText: e.autoResponseText,
3785
3982
  autoResponseDelay: e.autoResponseDelay,
3786
3983
  onSend: e.onSend
3787
- });
3788
- return /* @__PURE__ */ Z(ua, {
3789
- messages: r,
3984
+ }), p = (e, t) => {
3985
+ s(e, t);
3986
+ }, m = () => {
3987
+ d(), e.onClear?.();
3988
+ }, h = l(() => hn(i), [i]);
3989
+ return /* @__PURE__ */ Z(wa, {
3990
+ ...zt(r),
3991
+ messages: h,
3790
3992
  placeholder: e.placeholder,
3791
- onSendMessage: (e, t) => {
3792
- o(e, t);
3793
- },
3794
- onClear: () => {
3795
- l(), e.onClear?.();
3796
- },
3797
- onStop: u && i ? s : void 0,
3798
- onReload: u ? c : void 0,
3799
- disabled: e.disabled,
3800
- isLoading: i,
3801
- error: a,
3993
+ onSendMessage: p,
3994
+ onClear: m,
3995
+ onStop: f && a ? c : void 0,
3996
+ onReload: f ? u : void 0,
3997
+ disabled: n,
3998
+ isLoading: a,
3999
+ error: o,
3802
4000
  showTimestamp: e.showTimestamp,
3803
4001
  userAvatarUrl: e.userAvatarUrl,
3804
4002
  userAvatarFallback: e.userAvatarFallback,
@@ -3808,8 +4006,7 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3808
4006
  enableMarkdown: e.enableMarkdown ?? !0,
3809
4007
  enableFileUpload: e.enableFileUpload ?? !1,
3810
4008
  processVisibility: e.processVisibility,
3811
- className: t,
3812
- ...n
4009
+ className: t
3813
4010
  });
3814
4011
  }, {
3815
4012
  namespace: "plugin-chatbot",
@@ -3954,8 +4151,8 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3954
4151
  autoResponseDelay: 1e3,
3955
4152
  className: "w-full max-w-2xl"
3956
4153
  }
3957
- }), Lt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
3958
- let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: l, isApiMode: u } = fn({
4154
+ }), Rt.register("chatbot-floating", ({ schema: e, className: t, ...n }) => {
4155
+ let { messages: r, isLoading: i, error: a, sendMessage: o, stop: s, reload: c, clear: u, isApiMode: d } = wn({
3959
4156
  api: e.api,
3960
4157
  initialMessages: e.messages,
3961
4158
  conversationId: e.conversationId,
@@ -3971,19 +4168,19 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
3971
4168
  autoResponseText: e.autoResponseText,
3972
4169
  autoResponseDelay: e.autoResponseDelay,
3973
4170
  onSend: e.onSend
3974
- });
3975
- return /* @__PURE__ */ Z(Pa, {
4171
+ }), f = (e, t) => {
4172
+ o(e, t);
4173
+ }, p = () => {
4174
+ u(), e.onClear?.();
4175
+ }, m = l(() => hn(r), [r]);
4176
+ return /* @__PURE__ */ Z(Ja, {
3976
4177
  floatingConfig: e.floatingConfig,
3977
- messages: r,
4178
+ messages: m,
3978
4179
  placeholder: e.placeholder,
3979
- onSendMessage: (e, t) => {
3980
- o(e, t);
3981
- },
3982
- onClear: () => {
3983
- l(), e.onClear?.();
3984
- },
3985
- onStop: u && i ? s : void 0,
3986
- onReload: u ? c : void 0,
4180
+ onSendMessage: f,
4181
+ onClear: p,
4182
+ onStop: d && i ? s : void 0,
4183
+ onReload: d ? c : void 0,
3987
4184
  disabled: e.disabled,
3988
4185
  isLoading: i,
3989
4186
  error: a,
@@ -4144,7 +4341,7 @@ Lt.register("chatbot", ({ schema: e, className: t, ...n }) => {
4144
4341
  });
4145
4342
  //#endregion
4146
4343
  //#region src/elements/loader.tsx
4147
- var Fa = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
4344
+ var Ya = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
4148
4345
  height: e,
4149
4346
  strokeLinejoin: "round",
4150
4347
  style: { color: "currentcolor" },
@@ -4225,97 +4422,97 @@ var Fa = ({ size: e = 16 }) => /* @__PURE__ */ Q("svg", {
4225
4422
  })
4226
4423
  }) })
4227
4424
  ]
4228
- }), Ia = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Z("div", {
4229
- className: G("inline-flex animate-spin items-center justify-center", e),
4425
+ }), Xa = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Z("div", {
4426
+ className: W("inline-flex animate-spin items-center justify-center", e),
4230
4427
  ...n,
4231
- children: /* @__PURE__ */ Z(Fa, { size: t })
4232
- }), La = /* @__PURE__ */ zt({
4233
- CodeBlock: () => Di,
4234
- CodeBlockCopyButton: () => Oi,
4235
- Conversation: () => nr,
4236
- ConversationContent: () => rr,
4237
- ConversationEmptyState: () => ir,
4238
- ConversationScrollButton: () => ar,
4239
- Loader: () => Ia,
4240
- Message: () => lr,
4241
- MessageAction: () => fr,
4242
- MessageActions: () => dr,
4243
- MessageAttachment: () => Sr,
4244
- MessageAttachments: () => Cr,
4245
- MessageBranch: () => hr,
4246
- MessageBranchContent: () => gr,
4247
- MessageBranchNext: () => yr,
4248
- MessageBranchPage: () => br,
4249
- MessageBranchPrevious: () => vr,
4250
- MessageBranchSelector: () => _r,
4251
- MessageContent: () => ur,
4252
- MessageResponse: () => xr,
4253
- MessageToolbar: () => wr,
4254
- PromptInput: () => Ur,
4255
- PromptInputActionAddAttachments: () => Hr,
4256
- PromptInputActionMenu: () => Xr,
4257
- PromptInputActionMenuContent: () => Qr,
4258
- PromptInputActionMenuItem: () => $r,
4259
- PromptInputActionMenuTrigger: () => Zr,
4260
- PromptInputAttachment: () => Br,
4261
- PromptInputAttachments: () => Vr,
4262
- PromptInputBody: () => Wr,
4263
- PromptInputButton: () => Yr,
4264
- PromptInputCommand: () => hi,
4265
- PromptInputCommandEmpty: () => vi,
4266
- PromptInputCommandGroup: () => yi,
4267
- PromptInputCommandInput: () => gi,
4268
- PromptInputCommandItem: () => bi,
4269
- PromptInputCommandList: () => _i,
4270
- PromptInputCommandSeparator: () => xi,
4271
- PromptInputFooter: () => qr,
4272
- PromptInputHeader: () => Kr,
4273
- PromptInputHoverCard: () => si,
4274
- PromptInputHoverCardContent: () => li,
4275
- PromptInputHoverCardTrigger: () => ci,
4276
- PromptInputProvider: () => Lr,
4277
- PromptInputSelect: () => ni,
4278
- PromptInputSelectContent: () => ii,
4279
- PromptInputSelectItem: () => ai,
4280
- PromptInputSelectTrigger: () => ri,
4281
- PromptInputSelectValue: () => oi,
4282
- PromptInputSpeechButton: () => ti,
4283
- PromptInputSubmit: () => ei,
4284
- PromptInputTab: () => di,
4285
- PromptInputTabBody: () => pi,
4286
- PromptInputTabItem: () => mi,
4287
- PromptInputTabLabel: () => fi,
4288
- PromptInputTabsList: () => ui,
4289
- PromptInputTextarea: () => Gr,
4290
- PromptInputTools: () => Jr,
4291
- Reasoning: () => Bi,
4292
- ReasoningContent: () => Ui,
4293
- ReasoningTrigger: () => Hi,
4294
- Shimmer: () => Fi,
4295
- Source: () => qi,
4296
- Sources: () => Wi,
4297
- SourcesContent: () => Ki,
4298
- SourcesTrigger: () => Gi,
4299
- Suggestion: () => Ci,
4300
- Suggestions: () => Si,
4301
- Tool: () => ki,
4302
- ToolContent: () => Mi,
4303
- ToolHeader: () => ji,
4304
- ToolInput: () => Ni,
4305
- ToolOutput: () => Pi,
4306
- highlightCode: () => Ei,
4307
- usePromptInputAttachments: () => zr,
4308
- usePromptInputController: () => Nr,
4309
- useProviderAttachments: () => Fr,
4310
- useReasoning: () => Li
4311
- }), Ra = "/api/v1/ai";
4312
- function za(e, t, n) {
4428
+ children: /* @__PURE__ */ Z(Ya, { size: t })
4429
+ }), Za = /* @__PURE__ */ Vt({
4430
+ CodeBlock: () => Vi,
4431
+ CodeBlockCopyButton: () => Hi,
4432
+ Conversation: () => gr,
4433
+ ConversationContent: () => _r,
4434
+ ConversationEmptyState: () => vr,
4435
+ ConversationScrollButton: () => yr,
4436
+ Loader: () => Xa,
4437
+ Message: () => Cr,
4438
+ MessageAction: () => Er,
4439
+ MessageActions: () => Tr,
4440
+ MessageAttachment: () => Ir,
4441
+ MessageAttachments: () => Lr,
4442
+ MessageBranch: () => kr,
4443
+ MessageBranchContent: () => Ar,
4444
+ MessageBranchNext: () => Nr,
4445
+ MessageBranchPage: () => Pr,
4446
+ MessageBranchPrevious: () => Mr,
4447
+ MessageBranchSelector: () => jr,
4448
+ MessageContent: () => wr,
4449
+ MessageResponse: () => Fr,
4450
+ MessageToolbar: () => Rr,
4451
+ PromptInput: () => ri,
4452
+ PromptInputActionAddAttachments: () => ni,
4453
+ PromptInputActionMenu: () => ui,
4454
+ PromptInputActionMenuContent: () => fi,
4455
+ PromptInputActionMenuItem: () => pi,
4456
+ PromptInputActionMenuTrigger: () => di,
4457
+ PromptInputAttachment: () => ei,
4458
+ PromptInputAttachments: () => ti,
4459
+ PromptInputBody: () => ii,
4460
+ PromptInputButton: () => li,
4461
+ PromptInputCommand: () => ki,
4462
+ PromptInputCommandEmpty: () => Mi,
4463
+ PromptInputCommandGroup: () => Ni,
4464
+ PromptInputCommandInput: () => Ai,
4465
+ PromptInputCommandItem: () => Pi,
4466
+ PromptInputCommandList: () => ji,
4467
+ PromptInputCommandSeparator: () => Fi,
4468
+ PromptInputFooter: () => si,
4469
+ PromptInputHeader: () => oi,
4470
+ PromptInputHoverCard: () => xi,
4471
+ PromptInputHoverCardContent: () => Ci,
4472
+ PromptInputHoverCardTrigger: () => Si,
4473
+ PromptInputProvider: () => Zr,
4474
+ PromptInputSelect: () => gi,
4475
+ PromptInputSelectContent: () => vi,
4476
+ PromptInputSelectItem: () => yi,
4477
+ PromptInputSelectTrigger: () => _i,
4478
+ PromptInputSelectValue: () => bi,
4479
+ PromptInputSpeechButton: () => hi,
4480
+ PromptInputSubmit: () => mi,
4481
+ PromptInputTab: () => Ti,
4482
+ PromptInputTabBody: () => Di,
4483
+ PromptInputTabItem: () => Oi,
4484
+ PromptInputTabLabel: () => Ei,
4485
+ PromptInputTabsList: () => wi,
4486
+ PromptInputTextarea: () => ai,
4487
+ PromptInputTools: () => ci,
4488
+ Reasoning: () => ea,
4489
+ ReasoningContent: () => ra,
4490
+ ReasoningTrigger: () => na,
4491
+ Shimmer: () => Yi,
4492
+ Source: () => sa,
4493
+ Sources: () => ia,
4494
+ SourcesContent: () => oa,
4495
+ SourcesTrigger: () => aa,
4496
+ Suggestion: () => Li,
4497
+ Suggestions: () => Ii,
4498
+ Tool: () => Ui,
4499
+ ToolContent: () => Ki,
4500
+ ToolHeader: () => Gi,
4501
+ ToolInput: () => qi,
4502
+ ToolOutput: () => Ji,
4503
+ highlightCode: () => Bi,
4504
+ usePromptInputAttachments: () => $r,
4505
+ usePromptInputController: () => qr,
4506
+ useProviderAttachments: () => Yr,
4507
+ useReasoning: () => Zi
4508
+ }), Qa = "/api/v1/ai";
4509
+ function $a(e, t, n) {
4313
4510
  let r = e.replace(/\/$/, ""), i = new URLSearchParams();
4314
4511
  if (n) for (let [e, t] of Object.entries(n)) t != null && t !== "" && i.set(e, String(t));
4315
4512
  let a = i.toString();
4316
4513
  return `${r}${t}${a ? `?${a}` : ""}`;
4317
4514
  }
4318
- async function Ba(e, t, n) {
4515
+ async function eo(e, t, n) {
4319
4516
  let r = await fetch(e, {
4320
4517
  credentials: "include",
4321
4518
  ...t,
@@ -4335,8 +4532,8 @@ async function Ba(e, t, n) {
4335
4532
  }
4336
4533
  return i;
4337
4534
  }
4338
- function Va(t = {}) {
4339
- let { apiBase: n = Ra, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
4535
+ function to(t = {}) {
4536
+ let { apiBase: n = Qa, status: r = "pending", conversationId: i, limit: a, headers: o, pollInterval: s = 5e3, enabled: c = !0 } = t, [l, u] = e.useState([]), [d, f] = e.useState(0), [p, m] = e.useState(!1), [h, g] = e.useState(void 0), _ = e.useRef({
4340
4537
  apiBase: n,
4341
4538
  status: r,
4342
4539
  conversationId: i,
@@ -4354,7 +4551,7 @@ function Va(t = {}) {
4354
4551
  let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
4355
4552
  m(!0), g(void 0);
4356
4553
  try {
4357
- let a = await Ba(za(e, "/pending-actions", {
4554
+ let a = await eo($a(e, "/pending-actions", {
4358
4555
  status: t && t !== "all" ? t : void 0,
4359
4556
  conversationId: n,
4360
4557
  limit: r
@@ -4366,9 +4563,9 @@ function Va(t = {}) {
4366
4563
  m(!1);
4367
4564
  }
4368
4565
  }, []), y = e.useCallback(async (e) => {
4369
- let { apiBase: t, headers: n } = _.current, r = za(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
4566
+ let { apiBase: t, headers: n } = _.current, r = $a(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
4370
4567
  try {
4371
- return await Ba(r, {
4568
+ return await eo(r, {
4372
4569
  method: "POST",
4373
4570
  body: "{}"
4374
4571
  }, n);
@@ -4376,9 +4573,9 @@ function Va(t = {}) {
4376
4573
  v();
4377
4574
  }
4378
4575
  }, [v]), b = e.useCallback(async (e, t) => {
4379
- let { apiBase: n, headers: r } = _.current, i = za(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
4576
+ let { apiBase: n, headers: r } = _.current, i = $a(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
4380
4577
  try {
4381
- return await Ba(i, {
4578
+ return await eo(i, {
4382
4579
  method: "POST",
4383
4580
  body: JSON.stringify(t ? { reason: t } : {})
4384
4581
  }, r);
@@ -4412,7 +4609,7 @@ function Va(t = {}) {
4412
4609
  }
4413
4610
  //#endregion
4414
4611
  //#region src/AiPendingActionsInbox.tsx
4415
- var Ha = {
4612
+ var no = {
4416
4613
  pending: {
4417
4614
  variant: "secondary",
4418
4615
  label: "Pending"
@@ -4434,8 +4631,8 @@ var Ha = {
4434
4631
  label: "Rejected"
4435
4632
  }
4436
4633
  };
4437
- function Ua({ status: e }) {
4438
- let t = Ha[e] ?? {
4634
+ function ro({ status: e }) {
4635
+ let t = no[e] ?? {
4439
4636
  variant: "outline",
4440
4637
  label: e
4441
4638
  };
@@ -4444,7 +4641,7 @@ function Ua({ status: e }) {
4444
4641
  children: t.label
4445
4642
  });
4446
4643
  }
4447
- function Wa(e) {
4644
+ function io(e) {
4448
4645
  if (!e) return "—";
4449
4646
  let t = Date.parse(e);
4450
4647
  if (Number.isNaN(t)) return e;
@@ -4462,7 +4659,7 @@ function Wa(e) {
4462
4659
  return e;
4463
4660
  }
4464
4661
  }
4465
- function Ga(e) {
4662
+ function ao(e) {
4466
4663
  if (!e) return null;
4467
4664
  try {
4468
4665
  return JSON.parse(e);
@@ -4470,7 +4667,7 @@ function Ga(e) {
4470
4667
  return e;
4471
4668
  }
4472
4669
  }
4473
- function Ka({ value: e, max: t = 320 }) {
4670
+ function oo({ value: e, max: t = 320 }) {
4474
4671
  let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
4475
4672
  return n == null || n === "" ? /* @__PURE__ */ Z("span", {
4476
4673
  className: "text-muted-foreground text-xs",
@@ -4481,20 +4678,20 @@ function Ka({ value: e, max: t = 320 }) {
4481
4678
  children: n
4482
4679
  });
4483
4680
  }
4484
- function qa(e) {
4681
+ function so(e) {
4485
4682
  switch (e) {
4486
4683
  case "pending": return "pending";
4487
4684
  case "all": return "all";
4488
4685
  case "decided": return "all";
4489
4686
  }
4490
4687
  }
4491
- function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
4492
- let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: P, reject: F } = Va({
4688
+ function co({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i, variant: a = "card", title: o = "AI Approvals", description: s = "Actions an AI agent proposed that need a human review before execution.", className: c }) {
4689
+ let [l, u] = e.useState("pending"), [d, m] = e.useState(null), [h, g] = e.useState(null), [_, w] = e.useState(""), [T, E] = e.useState(null), [D, O] = e.useState(null), [k, A] = e.useState(null), { items: j, isLoading: M, error: N, refresh: ee, approve: P, reject: F } = to({
4493
4690
  apiBase: t,
4494
4691
  headers: n,
4495
4692
  pollInterval: r,
4496
4693
  conversationId: i,
4497
- status: qa(l)
4694
+ status: so(l)
4498
4695
  }), I = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), R = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ae = e.useCallback(async (e) => {
4499
4696
  E(e), O(null);
4500
4697
  try {
@@ -4541,19 +4738,19 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4541
4738
  children: [
4542
4739
  /* @__PURE__ */ Q("div", {
4543
4740
  className: "flex items-center justify-between gap-2",
4544
- children: [/* @__PURE__ */ Z(Ce, {
4741
+ children: [/* @__PURE__ */ Z(we, {
4545
4742
  value: l,
4546
4743
  onValueChange: (e) => u(e),
4547
- children: /* @__PURE__ */ Q(we, { children: [
4548
- /* @__PURE__ */ Z(Te, {
4744
+ children: /* @__PURE__ */ Q(Te, { children: [
4745
+ /* @__PURE__ */ Z(Ee, {
4549
4746
  value: "pending",
4550
4747
  children: "Pending"
4551
4748
  }),
4552
- /* @__PURE__ */ Z(Te, {
4749
+ /* @__PURE__ */ Z(Ee, {
4553
4750
  value: "decided",
4554
4751
  children: "Decided"
4555
4752
  }),
4556
- /* @__PURE__ */ Z(Te, {
4753
+ /* @__PURE__ */ Z(Ee, {
4557
4754
  value: "all",
4558
4755
  children: "All"
4559
4756
  })
@@ -4564,20 +4761,20 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4564
4761
  onClick: () => void ee(),
4565
4762
  disabled: M,
4566
4763
  "data-testid": "ai-inbox-refresh",
4567
- children: [/* @__PURE__ */ Z(lt, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
4764
+ children: [/* @__PURE__ */ Z(ut, { className: `h-3.5 w-3.5 mr-1.5 ${M ? "animate-spin" : ""}` }), "Refresh"]
4568
4765
  })]
4569
4766
  }),
4570
4767
  N ? /* @__PURE__ */ Q(f, {
4571
4768
  variant: "destructive",
4572
- children: [/* @__PURE__ */ Z(je, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: N.message })]
4769
+ children: [/* @__PURE__ */ Z(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: N.message })]
4573
4770
  }) : null,
4574
4771
  D ? /* @__PURE__ */ Q(f, {
4575
4772
  variant: "destructive",
4576
- children: [/* @__PURE__ */ Z(je, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: D })]
4773
+ children: [/* @__PURE__ */ Z(Me, { className: "h-4 w-4" }), /* @__PURE__ */ Z(p, { children: D })]
4577
4774
  }) : null,
4578
4775
  k && !D ? /* @__PURE__ */ Q(f, {
4579
4776
  variant: k.ok ? "default" : "destructive",
4580
- children: [k.ok ? /* @__PURE__ */ Z(K, { className: "h-4 w-4" }) : /* @__PURE__ */ Z(Y, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: [
4777
+ children: [k.ok ? /* @__PURE__ */ Z(G, { className: "h-4 w-4" }) : /* @__PURE__ */ Z(J, { className: "h-4 w-4" }), /* @__PURE__ */ Q(p, { children: [
4581
4778
  k.kind === "approve" ? "Approve" : "Reject",
4582
4779
  " for",
4583
4780
  " ",
@@ -4593,69 +4790,69 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4593
4790
  M && I.length === 0 ? /* @__PURE__ */ Q("div", {
4594
4791
  className: "space-y-2",
4595
4792
  children: [
4596
- /* @__PURE__ */ Z(ve, { className: "h-10 w-full" }),
4597
- /* @__PURE__ */ Z(ve, { className: "h-10 w-full" }),
4598
- /* @__PURE__ */ Z(ve, { className: "h-10 w-full" })
4793
+ /* @__PURE__ */ Z(ye, { className: "h-10 w-full" }),
4794
+ /* @__PURE__ */ Z(ye, { className: "h-10 w-full" }),
4795
+ /* @__PURE__ */ Z(ye, { className: "h-10 w-full" })
4599
4796
  ]
4600
4797
  }) : I.length === 0 ? /* @__PURE__ */ Z(te, { children: /* @__PURE__ */ Q(L, { children: [
4601
- /* @__PURE__ */ Z(re, { children: /* @__PURE__ */ Z(tt, { className: "h-8 w-8 text-muted-foreground" }) }),
4798
+ /* @__PURE__ */ Z(re, { children: /* @__PURE__ */ Z(rt, { className: "h-8 w-8 text-muted-foreground" }) }),
4602
4799
  /* @__PURE__ */ Z(ie, { children: "No actions waiting" }),
4603
4800
  /* @__PURE__ */ Z(ne, { children: "When the AI proposes a sensitive action it will appear here for review." })
4604
4801
  ] }) }) : /* @__PURE__ */ Z("div", {
4605
4802
  className: "rounded-md border",
4606
- children: /* @__PURE__ */ Q(ye, { children: [/* @__PURE__ */ Z(xe, { children: /* @__PURE__ */ Q(Se, { children: [
4607
- /* @__PURE__ */ Z(W, {
4803
+ children: /* @__PURE__ */ Q(be, { children: [/* @__PURE__ */ Z(Se, { children: /* @__PURE__ */ Q(Ce, { children: [
4804
+ /* @__PURE__ */ Z(U, {
4608
4805
  className: "w-[140px]",
4609
4806
  children: "Tool"
4610
4807
  }),
4611
- /* @__PURE__ */ Z(W, {
4808
+ /* @__PURE__ */ Z(U, {
4612
4809
  className: "w-[140px]",
4613
4810
  children: "Action"
4614
4811
  }),
4615
- /* @__PURE__ */ Z(W, {
4812
+ /* @__PURE__ */ Z(U, {
4616
4813
  className: "w-[120px]",
4617
4814
  children: "Object"
4618
4815
  }),
4619
- /* @__PURE__ */ Z(W, {
4816
+ /* @__PURE__ */ Z(U, {
4620
4817
  className: "w-[110px]",
4621
4818
  children: "Status"
4622
4819
  }),
4623
- /* @__PURE__ */ Z(W, {
4820
+ /* @__PURE__ */ Z(U, {
4624
4821
  className: "w-[110px]",
4625
4822
  children: "Proposed"
4626
4823
  }),
4627
- /* @__PURE__ */ Z(W, {
4824
+ /* @__PURE__ */ Z(U, {
4628
4825
  className: "w-[260px] text-right",
4629
4826
  children: "Decision"
4630
4827
  })
4631
- ] }) }), /* @__PURE__ */ Z(be, { children: I.map((e) => {
4828
+ ] }) }), /* @__PURE__ */ Z(xe, { children: I.map((e) => {
4632
4829
  let t = e.status === "pending", n = T === e.id;
4633
- return /* @__PURE__ */ Q(Se, { children: [
4634
- /* @__PURE__ */ Z(U, {
4830
+ return /* @__PURE__ */ Q(Ce, { children: [
4831
+ /* @__PURE__ */ Z(H, {
4635
4832
  className: "font-mono text-xs",
4636
4833
  children: e.tool_name
4637
4834
  }),
4638
- /* @__PURE__ */ Z(U, {
4835
+ /* @__PURE__ */ Z(H, {
4639
4836
  className: "text-sm",
4640
4837
  children: e.action_name
4641
4838
  }),
4642
- /* @__PURE__ */ Z(U, {
4839
+ /* @__PURE__ */ Z(H, {
4643
4840
  className: "text-sm",
4644
4841
  children: e.object_name
4645
4842
  }),
4646
- /* @__PURE__ */ Z(U, { children: /* @__PURE__ */ Z(Ua, { status: e.status }) }),
4647
- /* @__PURE__ */ Z(U, {
4843
+ /* @__PURE__ */ Z(H, { children: /* @__PURE__ */ Z(ro, { status: e.status }) }),
4844
+ /* @__PURE__ */ Z(H, {
4648
4845
  className: "text-xs text-muted-foreground",
4649
4846
  children: /* @__PURE__ */ Q("span", {
4650
4847
  className: "inline-flex items-center gap-1",
4651
4848
  children: [
4652
- /* @__PURE__ */ Z(We, { className: "h-3 w-3" }),
4849
+ /* @__PURE__ */ Z(Ge, { className: "h-3 w-3" }),
4653
4850
  " ",
4654
- Wa(e.proposed_at)
4851
+ io(e.proposed_at)
4655
4852
  ]
4656
4853
  })
4657
4854
  }),
4658
- /* @__PURE__ */ Z(U, {
4855
+ /* @__PURE__ */ Z(H, {
4659
4856
  className: "text-right",
4660
4857
  children: /* @__PURE__ */ Q("div", {
4661
4858
  className: "inline-flex gap-1.5",
@@ -4664,14 +4861,14 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4664
4861
  variant: "ghost",
4665
4862
  onClick: () => m(e.id),
4666
4863
  "data-testid": `ai-inbox-view-${e.id}`,
4667
- children: [/* @__PURE__ */ Z(Xe, { className: "h-3.5 w-3.5 mr-1" }), " View"]
4864
+ children: [/* @__PURE__ */ Z(Qe, { className: "h-3.5 w-3.5 mr-1" }), " View"]
4668
4865
  }), t ? /* @__PURE__ */ Q(X, { children: [/* @__PURE__ */ Q(v, {
4669
4866
  size: "sm",
4670
4867
  variant: "default",
4671
4868
  disabled: n,
4672
4869
  onClick: () => void ae(e.id),
4673
4870
  "data-testid": `ai-inbox-approve-${e.id}`,
4674
- children: [/* @__PURE__ */ Z(K, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
4871
+ children: [/* @__PURE__ */ Z(G, { className: "h-3.5 w-3.5 mr-1" }), n ? "Working…" : "Approve"]
4675
4872
  }), /* @__PURE__ */ Q(v, {
4676
4873
  size: "sm",
4677
4874
  variant: "destructive",
@@ -4680,7 +4877,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4680
4877
  g(e.id), w("");
4681
4878
  },
4682
4879
  "data-testid": `ai-inbox-reject-${e.id}`,
4683
- children: [/* @__PURE__ */ Z(Y, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4880
+ children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4684
4881
  })] }) : null]
4685
4882
  })
4686
4883
  })
@@ -4697,7 +4894,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4697
4894
  children: [/* @__PURE__ */ Q(C, {
4698
4895
  className: "flex items-center gap-2",
4699
4896
  children: [
4700
- /* @__PURE__ */ Z(Fe, { className: "h-4 w-4" }),
4897
+ /* @__PURE__ */ Z(Ie, { className: "h-4 w-4" }),
4701
4898
  " ",
4702
4899
  o
4703
4900
  ]
@@ -4707,17 +4904,17 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4707
4904
  className: c,
4708
4905
  children: z
4709
4906
  }),
4710
- /* @__PURE__ */ Z(pe, {
4907
+ /* @__PURE__ */ Z(me, {
4711
4908
  open: !!d,
4712
4909
  onOpenChange: (e) => {
4713
4910
  e || m(null);
4714
4911
  },
4715
- children: /* @__PURE__ */ Q(me, {
4912
+ children: /* @__PURE__ */ Q(he, {
4716
4913
  className: "sm:max-w-[560px] overflow-y-auto",
4717
- children: [/* @__PURE__ */ Q(ge, { children: [/* @__PURE__ */ Q(_e, {
4914
+ children: [/* @__PURE__ */ Q(_e, { children: [/* @__PURE__ */ Q(ve, {
4718
4915
  className: "flex items-center gap-2",
4719
- children: [/* @__PURE__ */ Z(Fe, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
4720
- }), /* @__PURE__ */ Z(he, { children: R ? /* @__PURE__ */ Q(X, { children: [
4916
+ children: [/* @__PURE__ */ Z(Ie, { className: "h-4 w-4" }), R ? R.action_name : "Pending action"]
4917
+ }), /* @__PURE__ */ Z(ge, { children: R ? /* @__PURE__ */ Q(X, { children: [
4721
4918
  "Tool ",
4722
4919
  /* @__PURE__ */ Z("code", {
4723
4920
  className: "text-xs",
@@ -4740,14 +4937,14 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4740
4937
  children: "Status"
4741
4938
  }), /* @__PURE__ */ Z("div", {
4742
4939
  className: "mt-1",
4743
- children: /* @__PURE__ */ Z(Ua, { status: R.status })
4940
+ children: /* @__PURE__ */ Z(ro, { status: R.status })
4744
4941
  })] }),
4745
4942
  /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4746
4943
  className: "text-xs text-muted-foreground",
4747
4944
  children: "Proposed"
4748
4945
  }), /* @__PURE__ */ Z("div", {
4749
4946
  className: "mt-1 text-xs",
4750
- children: Wa(R.proposed_at)
4947
+ children: io(R.proposed_at)
4751
4948
  })] }),
4752
4949
  /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4753
4950
  className: "text-xs text-muted-foreground",
@@ -4775,27 +4972,27 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4775
4972
  }) : null
4776
4973
  ]
4777
4974
  }),
4778
- /* @__PURE__ */ Z(fe, {}),
4975
+ /* @__PURE__ */ Z(pe, {}),
4779
4976
  /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4780
4977
  className: "text-xs",
4781
4978
  children: "Tool input"
4782
4979
  }), /* @__PURE__ */ Z("div", {
4783
4980
  className: "mt-1.5",
4784
- children: /* @__PURE__ */ Z(Ka, { value: Ga(R.tool_input) })
4981
+ children: /* @__PURE__ */ Z(oo, { value: ao(R.tool_input) })
4785
4982
  })] }),
4786
4983
  R.result ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4787
4984
  className: "text-xs",
4788
4985
  children: "Result"
4789
4986
  }), /* @__PURE__ */ Z("div", {
4790
4987
  className: "mt-1.5",
4791
- children: /* @__PURE__ */ Z(Ka, { value: Ga(R.result) })
4988
+ children: /* @__PURE__ */ Z(oo, { value: ao(R.result) })
4792
4989
  })] }) : null,
4793
4990
  R.error ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4794
4991
  className: "text-xs text-destructive",
4795
4992
  children: "Error"
4796
4993
  }), /* @__PURE__ */ Z("div", {
4797
4994
  className: "mt-1.5",
4798
- children: /* @__PURE__ */ Z(Ka, { value: R.error })
4995
+ children: /* @__PURE__ */ Z(oo, { value: R.error })
4799
4996
  })] }) : null,
4800
4997
  R.rejection_reason ? /* @__PURE__ */ Q("div", { children: [/* @__PURE__ */ Z(B, {
4801
4998
  className: "text-xs",
@@ -4810,7 +5007,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4810
5007
  size: "sm",
4811
5008
  onClick: () => void ae(R.id),
4812
5009
  disabled: T === R.id,
4813
- children: [/* @__PURE__ */ Z(K, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
5010
+ children: [/* @__PURE__ */ Z(G, { className: "h-3.5 w-3.5 mr-1" }), "Approve & Execute"]
4814
5011
  }), /* @__PURE__ */ Q(v, {
4815
5012
  size: "sm",
4816
5013
  variant: "destructive",
@@ -4818,24 +5015,24 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4818
5015
  g(R.id), w("");
4819
5016
  },
4820
5017
  disabled: T === R.id,
4821
- children: [/* @__PURE__ */ Z(Y, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
5018
+ children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4822
5019
  })]
4823
5020
  }) : null
4824
5021
  ]
4825
5022
  }) : null]
4826
5023
  })
4827
5024
  }),
4828
- /* @__PURE__ */ Z(pe, {
5025
+ /* @__PURE__ */ Z(me, {
4829
5026
  open: !!h,
4830
5027
  onOpenChange: (e) => {
4831
5028
  e || (g(null), w(""));
4832
5029
  },
4833
- children: /* @__PURE__ */ Q(me, {
5030
+ children: /* @__PURE__ */ Q(he, {
4834
5031
  side: "bottom",
4835
5032
  className: "max-h-[40vh]",
4836
- children: [/* @__PURE__ */ Q(ge, { children: [/* @__PURE__ */ Z(_e, { children: "Reject this action?" }), /* @__PURE__ */ Z(he, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ Q("div", {
5033
+ children: [/* @__PURE__ */ Q(_e, { children: [/* @__PURE__ */ Z(ve, { children: "Reject this action?" }), /* @__PURE__ */ Z(ge, { children: "The reason is shown back to the AI so it can adjust its next response." })] }), /* @__PURE__ */ Q("div", {
4837
5034
  className: "px-4 mt-3 space-y-3",
4838
- children: [/* @__PURE__ */ Z(Ee, {
5035
+ children: [/* @__PURE__ */ Z(De, {
4839
5036
  value: _,
4840
5037
  onChange: (e) => w(e.target.value),
4841
5038
  placeholder: "Optional reason (e.g. 'Wrong record id — please confirm with the user first.')",
@@ -4856,7 +5053,7 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4856
5053
  onClick: () => h && void oe(h, _),
4857
5054
  disabled: !h || T === h,
4858
5055
  "data-testid": "ai-inbox-reject-confirm",
4859
- children: [/* @__PURE__ */ Z(Y, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
5056
+ children: [/* @__PURE__ */ Z(J, { className: "h-3.5 w-3.5 mr-1" }), "Reject"]
4860
5057
  })]
4861
5058
  })]
4862
5059
  })]
@@ -4866,14 +5063,14 @@ function Ja({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
4866
5063
  }
4867
5064
  //#endregion
4868
5065
  //#region src/useHitlInChat.ts
4869
- function Ya(e) {
5066
+ function lo(e) {
4870
5067
  return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
4871
5068
  }
4872
- function Xa(e, t) {
5069
+ function uo(e, t) {
4873
5070
  let n = { ...e ?? {} };
4874
5071
  return t && (n["Content-Type"] = "application/json"), n;
4875
5072
  }
4876
- async function Za(e) {
5073
+ async function fo(e) {
4877
5074
  let t = await e.text();
4878
5075
  if (!t) return null;
4879
5076
  try {
@@ -4882,8 +5079,8 @@ async function Za(e) {
4882
5079
  return { raw: t };
4883
5080
  }
4884
5081
  }
4885
- function Qa(t) {
4886
- let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = Ya(r), c = e.useMemo(() => {
5082
+ function po(t) {
5083
+ let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = lo(r), c = e.useMemo(() => {
4887
5084
  let e = /* @__PURE__ */ new Map();
4888
5085
  for (let t of n) {
4889
5086
  let n = t.toolInvocations ?? [];
@@ -4926,9 +5123,9 @@ function Qa(t) {
4926
5123
  let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
4927
5124
  method: "POST",
4928
5125
  credentials: "include",
4929
- headers: Xa(i, !0),
5126
+ headers: uo(i, !0),
4930
5127
  body: c
4931
- }), f = await Za(d) ?? {};
5128
+ }), f = await fo(d) ?? {};
4932
5129
  if (!d.ok) {
4933
5130
  let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
4934
5131
  m(e, {
@@ -4961,7 +5158,7 @@ function Qa(t) {
4961
5158
  message: `Status: ${p}`
4962
5159
  }), h = !0;
4963
5160
  if (a?.(e, f), h && o) {
4964
- let r = $a({
5161
+ let r = mo({
4965
5162
  approved: t,
4966
5163
  status: p,
4967
5164
  toolName: u,
@@ -4997,24 +5194,24 @@ function Qa(t) {
4997
5194
  isDeciding: f
4998
5195
  };
4999
5196
  }
5000
- function $a(e) {
5197
+ function mo(e) {
5001
5198
  let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
5002
5199
  if (t && n === "executed") {
5003
5200
  let e = a.result;
5004
- return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : eo(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
5201
+ return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : ho(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
5005
5202
  }
5006
5203
  if (!t && n === "rejected") return `${s} The operator rejected the \`${r}\` call.${o && o.trim().length > 0 ? ` Reason: ${o}.` : ""} Acknowledge the rejection and ask whether to try a different approach.`;
5007
5204
  if (n === "failed") {
5008
5205
  let e = a.error;
5009
- return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : eo(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
5206
+ return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : ho(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
5010
5207
  }
5011
5208
  }
5012
- function eo(e, t) {
5209
+ function ho(e, t) {
5013
5210
  return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
5014
5211
  }
5015
5212
  //#endregion
5016
5213
  //#region src/index.tsx
5017
- var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
5214
+ var go = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type your message...", onSendMessage: i, disabled: a = !1, showTimestamp: o = !1, userAvatarUrl: s, userAvatarFallback: c = "You", assistantAvatarUrl: l, assistantAvatarFallback: u = "AI", maxHeight: d = "500px", ...f }, p) => {
5018
5215
  let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
5019
5216
  e.useEffect(() => {
5020
5217
  if (g.current) {
@@ -5029,10 +5226,10 @@ var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
5029
5226
  };
5030
5227
  return /* @__PURE__ */ Q("div", {
5031
5228
  ref: p,
5032
- className: G("flex flex-col border rounded-lg bg-background overflow-hidden", t),
5229
+ className: W("flex flex-col border rounded-lg bg-background overflow-hidden", t),
5033
5230
  style: { maxHeight: d },
5034
5231
  ...f,
5035
- children: [/* @__PURE__ */ Z(V, {
5232
+ children: [/* @__PURE__ */ Z(se, {
5036
5233
  ref: g,
5037
5234
  className: "flex-1 p-4",
5038
5235
  children: /* @__PURE__ */ Z("div", {
@@ -5040,7 +5237,7 @@ var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
5040
5237
  children: n.length === 0 ? /* @__PURE__ */ Z("div", {
5041
5238
  className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
5042
5239
  children: "No messages yet. Start a conversation!"
5043
- }) : n.map((e) => /* @__PURE__ */ Z(no, {
5240
+ }) : n.map((e) => /* @__PURE__ */ Z(_o, {
5044
5241
  message: e,
5045
5242
  showTimestamp: o,
5046
5243
  userAvatarUrl: s,
@@ -5065,14 +5262,14 @@ var to = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
5065
5262
  onClick: y,
5066
5263
  disabled: a || !m.trim(),
5067
5264
  size: "icon",
5068
- children: /* @__PURE__ */ Z(dt, { className: "h-4 w-4" })
5265
+ children: /* @__PURE__ */ Z(ft, { className: "h-4 w-4" })
5069
5266
  })]
5070
5267
  })
5071
5268
  })]
5072
5269
  });
5073
5270
  });
5074
- to.displayName = "Chatbot";
5075
- var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
5271
+ go.displayName = "Chatbot";
5272
+ var _o = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
5076
5273
  let o = e.role === "user";
5077
5274
  if (e.role === "system") return /* @__PURE__ */ Z("div", {
5078
5275
  className: "flex justify-center",
@@ -5083,7 +5280,7 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
5083
5280
  });
5084
5281
  let s = o ? e.avatar || n : e.avatar || i, c = o ? e.avatarFallback || r : e.avatarFallback || a;
5085
5282
  return /* @__PURE__ */ Q("div", {
5086
- className: G("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
5283
+ className: W("flex gap-3", o ? "flex-row-reverse" : "flex-row"),
5087
5284
  children: [/* @__PURE__ */ Q(m, {
5088
5285
  className: "h-8 w-8",
5089
5286
  children: [/* @__PURE__ */ Z(g, { src: s }), /* @__PURE__ */ Z(h, {
@@ -5091,9 +5288,9 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
5091
5288
  children: c
5092
5289
  })]
5093
5290
  }), /* @__PURE__ */ Q("div", {
5094
- className: G("flex flex-col gap-1", o ? "items-end" : "items-start"),
5291
+ className: W("flex flex-col gap-1", o ? "items-end" : "items-start"),
5095
5292
  children: [/* @__PURE__ */ Z("div", {
5096
- className: G("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
5293
+ className: W("rounded-lg px-4 py-2 max-w-[70%] break-words", o ? "bg-primary text-primary-foreground" : "bg-muted"),
5097
5294
  children: /* @__PURE__ */ Z("p", {
5098
5295
  className: "text-sm whitespace-pre-wrap",
5099
5296
  children: e.content
@@ -5104,9 +5301,9 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
5104
5301
  })]
5105
5302
  })]
5106
5303
  });
5107
- }, ro = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ Q("div", {
5304
+ }, vo = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ Q("div", {
5108
5305
  ref: i,
5109
- className: G("flex gap-3", e),
5306
+ className: W("flex gap-3", e),
5110
5307
  ...r,
5111
5308
  children: [/* @__PURE__ */ Q(m, {
5112
5309
  className: "h-8 w-8",
@@ -5126,6 +5323,6 @@ var no = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
5126
5323
  })
5127
5324
  })]
5128
5325
  }));
5129
- ro.displayName = "TypingIndicator";
5326
+ vo.displayName = "TypingIndicator";
5130
5327
  //#endregion
5131
- export { pn as AGENT_ALIAS_GROUPS, La as AIElements, on as AI_USAGE_REFRESH_EVENT, Ja as AiPendingActionsInbox, to as Chatbot, ua as ChatbotEnhanced, Pa as FloatingChatbot, Kn as FloatingChatbotPanel, Pn as FloatingChatbotProvider, Bn as FloatingChatbotTrigger, Sn as PLATFORM_DEFAULT_AGENT, ro as TypingIndicator, mn as agentAliasGroup, xn as agentHasCapability, hn as agentRouteName, Zt as buildProgressFromDraftReview, qt as detectBuilderHandoff, Yt as detectDraftResult, Jt as detectProposedChanges, Kt as detectProposedPlan, sn as emitAiUsageRefresh, Jn as humanizeToolName, yn as isAskAgent, vn as isBuildAgent, _n as isBuiltinAgentName, Ji as publishHealthFromResponse, gn as resolveAgentParam, Cn as resolveDefaultAgentName, Xn as summarizeChatError, rn as uiMessageToChatMessage, an as uiMessagesToChatMessages, Yn as unwrapToolResult, An as useAgents, Mn as useAiModels, Fn as useFloatingChatbot, Qa as useHitlInChat, fn as useObjectChat, Va as usePendingActions };
5328
+ export { Tn as AGENT_ALIAS_GROUPS, Za as AIElements, gn as AI_USAGE_REFRESH_EVENT, co as AiPendingActionsInbox, go as Chatbot, wa as ChatbotEnhanced, Ja as FloatingChatbot, ir as FloatingChatbotPanel, Kn as FloatingChatbotProvider, Qn as FloatingChatbotTrigger, Pn as PLATFORM_DEFAULT_AGENT, vo as TypingIndicator, En as agentAliasGroup, Nn as agentHasCapability, Dn as agentRouteName, mn as authoredToRuntimeMessage, tn as buildProgressFromDraftReview, Zt as detectAuthoringVerdict, Jt as detectBuilderHandoff, Qt as detectBuiltAppPackage, $t as detectDraftResult, Yt as detectProposedChanges, qt as detectProposedPlan, Xt as detectReplayOutcome, _n as emitAiUsageRefresh, or as humanizeToolName, jn as isAskAgent, An as isBuildAgent, kn as isBuiltinAgentName, ca as publishHealthFromResponse, On as resolveAgentParam, Fn as resolveDefaultAgentName, cr as summarizeChatError, hn as toRuntimeMessages, dn as toRuntimeRole, un as toRuntimeTimestamp, pn as toRuntimeToolInvocation, fn as toRuntimeToolState, cn as uiMessageToChatMessage, ln as uiMessagesToChatMessages, sr as unwrapToolResult, Hn as useAgents, Wn as useAiModels, qn as useFloatingChatbot, po as useHitlInChat, wn as useObjectChat, to as usePendingActions };