@icanbwell/baileyai-chat-ui 1.0.18 → 1.0.20

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.
@@ -6,23 +6,23 @@ import * as h from "@radix-ui/react-dropdown-menu";
6
6
  import * as g from "@radix-ui/react-tooltip";
7
7
  import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
8
8
  //#region src/utils/pseudoToolCalls.ts
9
- var b = "search_tools|call_tool|function_calls|function_result", ee = RegExp(`<(${b})>([\\s\\S]*?)<\\/\\1>`, "g"), x = RegExp(`<(?:${b})>[\\s\\S]*$`), S = /<name>([\s\S]*?)<\/name>/, C = /<arguments>([\s\S]*?)<\/arguments>/, w = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, T = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
10
- function E(e) {
11
- let t = S.exec(e)?.[1]?.trim() || "unknown_tool", n = C.exec(e)?.[1]?.trim();
9
+ var b = "search_tools|call_tool|function_calls|function_result", x = RegExp(`<(${b})>([\\s\\S]*?)<\\/\\1>`, "g"), S = RegExp(`<(?:${b})>[\\s\\S]*$`), C = /<name>([\s\S]*?)<\/name>/, w = /<arguments>([\s\S]*?)<\/arguments>/, T = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, E = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
10
+ function D(e) {
11
+ let t = C.exec(e)?.[1]?.trim() || "unknown_tool", n = w.exec(e)?.[1]?.trim();
12
12
  return n ? {
13
13
  name: t,
14
14
  args: n
15
15
  } : { name: t };
16
16
  }
17
- function D(e) {
17
+ function O(e) {
18
18
  let t = [];
19
- w.lastIndex = 0;
19
+ T.lastIndex = 0;
20
20
  let n;
21
- for (; (n = w.exec(e)) !== null;) {
21
+ for (; (n = T.exec(e)) !== null;) {
22
22
  let [, e, r] = n, i = {};
23
- T.lastIndex = 0;
23
+ E.lastIndex = 0;
24
24
  let a;
25
- for (; (a = T.exec(r)) !== null;) i[a[1]] = a[2].trim();
25
+ for (; (a = E.exec(r)) !== null;) i[a[1]] = a[2].trim();
26
26
  let o = e.trim() || "unknown_tool";
27
27
  t.push(Object.keys(i).length > 0 ? {
28
28
  name: o,
@@ -31,14 +31,14 @@ function D(e) {
31
31
  }
32
32
  return t;
33
33
  }
34
- function O(e, t = {}) {
35
- let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(ee, (e, t, n) => (t === "call_tool" ? r.push(E(n)) : t === "search_tools" ? r.push({
34
+ function k(e, t = {}) {
35
+ let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(x, (e, t, n) => (t === "call_tool" ? r.push(D(n)) : t === "search_tools" ? r.push({
36
36
  name: "search_tools",
37
37
  args: n.trim()
38
- }) : t === "function_calls" ? r.push(...D(n)) : r.push({
38
+ }) : t === "function_calls" ? r.push(...O(n)) : r.push({
39
39
  name: "function_result",
40
40
  args: n.trim()
41
- }), "")), a = n ? i.replace(x, "") : i;
41
+ }), "")), a = n ? i.replace(S, "") : i;
42
42
  return r.length === 0 && a === i ? {
43
43
  cleanedText: i,
44
44
  matches: r
@@ -49,7 +49,7 @@ function O(e, t = {}) {
49
49
  }
50
50
  //#endregion
51
51
  //#region src/logic/sse.ts
52
- function k(e) {
52
+ function ee(e) {
53
53
  if (!e.startsWith("data: ")) return e;
54
54
  let t = "";
55
55
  for (let n of e.split("\n")) {
@@ -88,7 +88,7 @@ function A(e) {
88
88
  message: e
89
89
  });
90
90
  } else if (c?.type === "response.output_text.delta" && typeof c.delta == "string") {
91
- let e = k(c.delta);
91
+ let e = ee(c.delta);
92
92
  e && r.push({
93
93
  type: "response.output_text.delta",
94
94
  delta: e
@@ -171,12 +171,12 @@ function F() {
171
171
  }
172
172
  //#endregion
173
173
  //#region src/logic/useBaileyChat.ts
174
- var I = 200, oe = 100, L = 15e4, se = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ce = (e, t, n) => {
174
+ var I = 200, oe = 100, L = 15e4, R = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, se = (e, t, n) => {
175
175
  if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
176
176
  let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
177
177
  return i ? `${r} ${i.length > I ? `${i.slice(0, I)}…` : i}` : r;
178
178
  };
179
- function le(e, t, n) {
179
+ function ce(e, t, n) {
180
180
  if (e) try {
181
181
  return e.get(t) || void 0;
182
182
  } catch (e) {
@@ -184,82 +184,82 @@ function le(e, t, n) {
184
184
  return;
185
185
  }
186
186
  }
187
- function ue(e, t) {
187
+ function le(e, t) {
188
188
  t.signal.aborted || typeof e != "string" || (t.historyStatus = e);
189
189
  }
190
- function de(e, t, n, r) {
190
+ function ue(e, t, n, r) {
191
191
  try {
192
192
  e?.set(t, n);
193
193
  } catch (e) {
194
194
  r(e, "write");
195
195
  }
196
196
  }
197
- function R(e, t, n) {
197
+ function z(e, t, n) {
198
198
  try {
199
199
  e?.remove(t);
200
200
  } catch (e) {
201
201
  n(e, "remove");
202
202
  }
203
203
  }
204
- var z = (e, t) => t ? `${e}:${t}` : e;
205
- function fe(e) {
204
+ var B = (e, t) => t ? `${e}:${t}` : e;
205
+ function de(e) {
206
206
  let { seed: t, sub: n, storage: r, key: i, report: a } = e;
207
- if (!n) return t || le(r, i, a);
207
+ if (!n) return t || ce(r, i, a);
208
208
  if (t && re({
209
209
  conversationId: t,
210
210
  sub: n
211
211
  })) return t;
212
- let o = le(r, i, a);
212
+ let o = ce(r, i, a);
213
213
  if (o) {
214
214
  if (re({
215
215
  conversationId: o,
216
216
  sub: n
217
217
  })) return o;
218
- R(r, i, a);
218
+ z(r, i, a);
219
219
  }
220
220
  }
221
- var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i, firstUserMessagePrefix: o, onAssistantMessageComplete: c, idleTimeoutMs: l = L, client: p, conversationId: m, sub: h, storage: g, storageKey: _ = ie, sendFullTranscript: v = !1, onStorageError: y, onContextLoss: b }) => {
222
- let [ee, x] = f([]), [S, C] = f([]), [w, T] = f(null), [E, D] = f("idle"), [k, j] = f(null), M = h !== void 0 && h.trim() === "", N = M ? void 0 : h?.trim() || void 0, P = u(() => ae(), []), F = M ? null : g === void 0 ? P : g || null, I = d(y), le = d(b);
221
+ var V = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i, firstUserMessagePrefix: o, onAssistantMessageComplete: c, idleTimeoutMs: l = L, client: p, conversationId: m, sub: h, storage: g, storageKey: _ = ie, sendFullTranscript: v = !1, onStorageError: y, onContextLoss: b }) => {
222
+ let [x, S] = f([]), [C, w] = f([]), [T, E] = f(null), [D, O] = f("idle"), [ee, j] = f(null), M = h !== void 0 && h.trim() === "", N = M ? void 0 : h?.trim() || void 0, P = u(() => ae(), []), F = M ? null : g === void 0 ? P : g || null, I = d(y), ce = d(b);
223
223
  s(() => {
224
- I.current = y, le.current = b;
224
+ I.current = y, ce.current = b;
225
225
  }, [y, b]);
226
- let B = a((e, t) => {
226
+ let V = a((e, t) => {
227
227
  try {
228
228
  I.current?.(e, t);
229
229
  } catch {}
230
- }, []), V = (e) => fe({
230
+ }, []), H = (e) => de({
231
231
  seed: m,
232
232
  sub: N,
233
233
  storage: F,
234
- key: z(_, N),
234
+ key: B(_, N),
235
235
  report: e
236
- }), [H] = f(() => {
236
+ }), [U] = f(() => {
237
237
  let e = [];
238
238
  return {
239
- id: V((t, n) => void e.push({
239
+ id: H((t, n) => void e.push({
240
240
  error: t,
241
241
  operation: n
242
242
  })),
243
243
  errors: e
244
244
  };
245
- }), [pe, U] = f(H.id), [me, he] = f(H.errors.length > 0), W = a((e, t) => {
246
- he(!0), B(e, t);
247
- }, [B]);
245
+ }), [fe, W] = f(U.id), [pe, me] = f(U.errors.length > 0), G = a((e, t) => {
246
+ me(!0), V(e, t);
247
+ }, [V]);
248
248
  s(() => {
249
- H.errors.forEach(({ error: e, operation: t }) => B(e, t));
250
- }, [H, B]), s(() => {
251
- M && B(/* @__PURE__ */ Error("sub is blank"), "key");
252
- }, [M, B]);
253
- let G = d(pe), K = d({
249
+ U.errors.forEach(({ error: e, operation: t }) => V(e, t));
250
+ }, [U, V]), s(() => {
251
+ M && V(/* @__PURE__ */ Error("sub is blank"), "key");
252
+ }, [M, V]);
253
+ let K = d(fe), q = d({
254
254
  storage: F,
255
- key: z(_, N),
255
+ key: B(_, N),
256
256
  sub: N,
257
257
  sendFullTranscript: v
258
258
  });
259
259
  s(() => {
260
- K.current = {
260
+ q.current = {
261
261
  storage: F,
262
- key: z(_, N),
262
+ key: B(_, N),
263
263
  sub: N,
264
264
  sendFullTranscript: v
265
265
  };
@@ -269,40 +269,40 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
269
269
  N,
270
270
  v
271
271
  ]);
272
- let ge = g === !1 ? "off" : me || M ? "degraded" : "ok", [_e, ve] = f(!1), [ye, q] = f("idle"), [be, xe] = f(!1), J = d(0), Y = d(null), X = d(null), Se = d(!1), Z = a(() => {
273
- J.current += 1, Y.current?.abort(), Y.current = null, X.current = null, Se.current = !1, xe(!1), q("idle");
272
+ let he = g === !1 ? "off" : pe || M ? "degraded" : "ok", [ge, _e] = f(!1), [ve, J] = f("idle"), [ye, Y] = f(!1), X = d(0), be = d(null), xe = d(null), Se = d(!1), Z = a(() => {
273
+ X.current += 1, be.current?.abort(), be.current = null, xe.current = null, Se.current = !1, Y(!1), J("idle");
274
274
  }, []), Ce = d(p);
275
275
  s(() => {
276
276
  Ce.current = p;
277
- }, [p]), s(() => () => Y.current?.abort(), []);
277
+ }, [p]), s(() => () => be.current?.abort(), []);
278
278
  let we = d(null), Te = d(""), Ee = d(0), De = d([]);
279
279
  s(() => {
280
- De.current = ee;
281
- }, [ee]);
282
- let Q = d([]), Oe = d(/* @__PURE__ */ new Map()), ke = d(/* @__PURE__ */ new Map()), Ae = d(null), $ = a(() => {
280
+ De.current = x;
281
+ }, [x]);
282
+ let Q = d([]), Oe = d(/* @__PURE__ */ new Map()), ke = d(/* @__PURE__ */ new Map()), Ae = d(null), je = a(() => {
283
283
  Ae.current !== null && (clearTimeout(Ae.current), Ae.current = null);
284
- }, []), je = a((e) => {
285
- $(), Ae.current = setTimeout(() => {
284
+ }, []), Me = a((e) => {
285
+ je(), Ae.current = setTimeout(() => {
286
286
  e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
287
287
  }, l);
288
- }, [$, l]);
288
+ }, [je, l]);
289
289
  s(() => () => {
290
- we.current?.abort(), $();
291
- }, [$]);
292
- let Me = a(({ reportedId: e, source: t, turn: n }) => {
290
+ we.current?.abort(), je();
291
+ }, [je]);
292
+ let $ = a(({ reportedId: e, source: t, turn: n }) => {
293
293
  if (n.signal.aborted || typeof e != "string" || !e) return;
294
294
  if (t === "event") n.reportedId = e, n.reportedFromEvent = !0;
295
295
  else if (!n.reportedFromEvent) n.reportedId = e;
296
296
  else return;
297
- if (n.heldId || e === G.current) return;
298
- let { sub: r, storage: i, key: a } = K.current;
297
+ if (n.heldId || e === K.current) return;
298
+ let { sub: r, storage: i, key: a } = q.current;
299
299
  r && !re({
300
300
  conversationId: e,
301
301
  sub: r
302
- }) || (G.current = e, U(e), de(i, a, e, W));
303
- }, [W]), Ne = a((e, t, n, r) => {
302
+ }) || (K.current = e, W(e), ue(i, a, e, G));
303
+ }, [G]), Ne = a((e, t, n, r) => {
304
304
  let i = (e) => {
305
- n.push(e), C((t) => [...t, e]);
305
+ n.push(e), w((t) => [...t, e]);
306
306
  };
307
307
  if (t.type === "response.output_text.delta") {
308
308
  if (!t.delta) return !1;
@@ -311,8 +311,8 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
311
311
  emittedCount: 0
312
312
  };
313
313
  n.raw += t.delta;
314
- let { cleanedText: r, matches: a } = O(n.raw), o = r.trim(), s = a.slice(n.emittedCount);
315
- if (n.emittedCount = a.length, Oe.current.set(e, n), ke.current.set(e, o), x((t) => t.map((t) => t.id === e ? {
314
+ let { cleanedText: r, matches: a } = k(n.raw), o = r.trim(), s = a.slice(n.emittedCount);
315
+ if (n.emittedCount = a.length, Oe.current.set(e, n), ke.current.set(e, o), S((t) => t.map((t) => t.id === e ? {
316
316
  ...t,
317
317
  content: o
318
318
  } : t)), s.length > 0) {
@@ -329,7 +329,7 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
329
329
  }
330
330
  if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
331
331
  let n = t.item;
332
- if (n.type === "output_image") return n.image_url && x((t) => t.map((t) => t.id === e ? {
332
+ if (n.type === "output_image") return n.image_url && S((t) => t.map((t) => t.id === e ? {
333
333
  ...t,
334
334
  parts: [...t.parts ?? [], {
335
335
  type: "image",
@@ -384,26 +384,26 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
384
384
  turnSentAt: Ee.current
385
385
  }), !0;
386
386
  if (t.type === "response.output_text.done") return !1;
387
- if (t.type === "response.created") return Me({
387
+ if (t.type === "response.created") return $({
388
388
  reportedId: t.response?.conversation?.id,
389
389
  source: "event",
390
390
  turn: r
391
- }), ue(t.response?.conversation?.history_status, r), !1;
391
+ }), le(t.response?.conversation?.history_status, r), !1;
392
392
  if (t.type === "response.completed") {
393
- Me({
393
+ $({
394
394
  reportedId: t.response?.conversation?.id,
395
395
  source: "event",
396
396
  turn: r
397
- }), ue(t.response?.conversation?.history_status, r);
397
+ }), le(t.response?.conversation?.history_status, r);
398
398
  let n = typeof t.message_id == "string" && t.message_id ? t.message_id : void 0;
399
- n && x((t) => t.map((t) => t.id === e ? {
399
+ n && S((t) => t.map((t) => t.id === e ? {
400
400
  ...t,
401
401
  serverMessageId: n
402
402
  } : t));
403
403
  let i = Oe.current.get(e);
404
404
  if (i) {
405
- let { cleanedText: t } = O(i.raw, { hideOpenBlock: !1 }), n = t.trim();
406
- n !== ke.current.get(e) && (ke.current.set(e, n), x((t) => t.map((t) => t.id === e ? {
405
+ let { cleanedText: t } = k(i.raw, { hideOpenBlock: !1 }), n = t.trim();
406
+ n !== ke.current.get(e) && (ke.current.set(e, n), S((t) => t.map((t) => t.id === e ? {
407
407
  ...t,
408
408
  content: n
409
409
  } : t)));
@@ -426,7 +426,7 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
426
426
  turnSentAt: Ee.current
427
427
  }), !0;
428
428
  let { html: r, title: a, csp: o, permissions: s, prefersBorder: c, displayMode: l } = t;
429
- return x((t) => t.map((t) => t.id === e ? {
429
+ return S((t) => t.map((t) => t.id === e ? {
430
430
  ...t,
431
431
  parts: [...t.parts ?? [], {
432
432
  type: "mcp_app",
@@ -447,18 +447,18 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
447
447
  at: Date.now(),
448
448
  turnSentAt: Ee.current
449
449
  }), !0;
450
- }, [Me]), Pe = a(async (a) => {
451
- D("streaming"), j(null), ve(!1);
450
+ }, [$]), Pe = a(async (a) => {
451
+ O("streaming"), j(null), _e(!1);
452
452
  let s = Date.now();
453
453
  Ee.current = s;
454
- let l = se(), u = {
454
+ let l = R(), u = {
455
455
  id: l,
456
456
  role: "assistant",
457
457
  content: "",
458
458
  streaming: !0,
459
459
  createdAt: s
460
460
  };
461
- x((e) => [...e, u]), Q.current = [...a, u];
461
+ S((e) => [...e, u]), Q.current = [...a, u];
462
462
  let d = a.findIndex((e) => e.role === "user" && !e.hidden), f = a.map((e, t) => t === d && o ? {
463
463
  role: e.role,
464
464
  content: `${o}${e.content}`,
@@ -469,8 +469,8 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
469
469
  content: e.content,
470
470
  hidden: e.hidden,
471
471
  titleHint: e.titleHint
472
- }), { sendFullTranscript: p } = K.current, m = p ? void 0 : G.current, h = m ? f.slice(-1) : f;
473
- T({
472
+ }), { sendFullTranscript: p } = q.current, m = p ? void 0 : K.current, h = m ? f.slice(-1) : f;
473
+ E({
474
474
  model: t,
475
475
  systemPrompt: n,
476
476
  messages: h,
@@ -485,12 +485,12 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
485
485
  }
486
486
  });
487
487
  let g = new AbortController();
488
- we.current = g, je(g);
488
+ we.current = g, Me(g);
489
489
  let _ = {
490
490
  signal: g.signal,
491
491
  heldId: m
492
- }, v = "", y = null, b = !1, ee = !1, S = !1, w = [], E = (e, t) => {
493
- D("error"), j(e);
492
+ }, v = "", y = null, b = !1, x = !1, C = !1, T = [], D = (e, t) => {
493
+ O("error"), j(e);
494
494
  let n = {
495
495
  kind: "error",
496
496
  message: e,
@@ -498,8 +498,8 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
498
498
  turnSentAt: s,
499
499
  ...t
500
500
  };
501
- w.push(n), C((e) => [...e, n]);
502
- }, O = (e, t) => {
501
+ T.push(n), w((e) => [...e, n]);
502
+ }, k = (e, t) => {
503
503
  e.forEach((e) => {
504
504
  if (e.type === "error") {
505
505
  y = e.message;
@@ -509,35 +509,35 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
509
509
  at: Date.now(),
510
510
  turnSentAt: s
511
511
  };
512
- w.push(t), C((e) => [...e, t]);
512
+ T.push(t), w((e) => [...e, t]);
513
513
  return;
514
514
  }
515
- e.type === "response.output_text.delta" && e.delta && (S = !0), Ne(l, e, w, _) && (ee = !0);
516
- }), t && (b = !0, x((e) => e.map((e) => e.id === l ? {
515
+ e.type === "response.output_text.delta" && e.delta && (C = !0), Ne(l, e, T, _) && (x = !0);
516
+ }), t && (b = !0, S((e) => e.map((e) => e.id === l ? {
517
517
  ...e,
518
518
  streaming: !1
519
519
  } : e)));
520
520
  };
521
521
  try {
522
- let { status: a, text: o, errorMessage: u, interrupted: d } = await e.streamChat({
522
+ let { status: a, text: o, errorMessage: u, errorKind: d, interrupted: f } = await e.streamChat({
523
523
  model: t,
524
524
  instructions: n,
525
525
  input: h,
526
526
  tools: r,
527
527
  toolChoice: i,
528
528
  ...m ? { conversationId: m } : {},
529
- onConversationId: (e) => Me({
529
+ onConversationId: (e) => $({
530
530
  reportedId: e,
531
531
  source: "header",
532
532
  turn: _
533
533
  }),
534
534
  signal: g.signal,
535
535
  onChunk: (e) => {
536
- je(g), v += e;
536
+ Me(g), v += e;
537
537
  let { events: t, remainder: n, done: r } = A(v);
538
- v = n, O(t, r);
538
+ v = n, k(t, r);
539
539
  let i = Date.now();
540
- T((e) => e && e.sentAt === s ? {
540
+ E((e) => e && e.sentAt === s ? {
541
541
  ...e,
542
542
  streamStats: {
543
543
  chunkCount: e.streamStats.chunkCount + 1,
@@ -547,13 +547,13 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
547
547
  } : e);
548
548
  },
549
549
  onRequestId: (e) => {
550
- T((t) => t && t.sentAt === s ? {
550
+ E((t) => t && t.sentAt === s ? {
551
551
  ...t,
552
552
  requestId: e
553
553
  } : t);
554
554
  },
555
555
  onMessageId: (e) => {
556
- typeof e == "string" && e && x((t) => t.map((t) => t.id === l ? {
556
+ typeof e == "string" && e && S((t) => t.map((t) => t.id === l ? {
557
557
  ...t,
558
558
  serverMessageId: e
559
559
  } : t));
@@ -561,70 +561,74 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
561
561
  });
562
562
  if (v.trim()) {
563
563
  let { events: e, done: t } = A(`${v}\n\n`);
564
- v = "", O(e, t);
564
+ v = "", k(e, t);
565
565
  }
566
566
  if (y) {
567
- D("error"), j(y);
567
+ O("error"), j(y);
568
568
  return;
569
569
  }
570
- if (d && !b) {
571
- E("The connection was interrupted before the answer finished. Try again.");
570
+ if (d === "timeout" && !b) {
571
+ D(u || "The assistant took too long to respond. Please try again.", { source: "client-timeout" });
572
+ return;
573
+ }
574
+ if (f && !b) {
575
+ D("The connection was interrupted before the answer finished. Try again.");
572
576
  return;
573
577
  }
574
578
  if (a === void 0 || a >= 400) {
575
- E(ce(a, o, u), {
579
+ D(se(a, o, u), {
576
580
  httpStatus: a,
577
581
  rawBody: o || void 0
578
582
  });
579
583
  return;
580
584
  }
581
- let f = _.reportedId, p = f !== m, C = _.historyStatus === "failed" || _.historyStatus === "empty";
582
- if (m && !_.signal.aborted && (p || C)) {
583
- G.current = void 0, U(void 0), R(K.current.storage, K.current.key, W), Z(), ve(!0);
585
+ let p = _.reportedId, w = p !== m, ee = _.historyStatus === "failed" || _.historyStatus === "empty";
586
+ if (m && !_.signal.aborted && (w || ee)) {
587
+ K.current = void 0, W(void 0), z(q.current.storage, q.current.key, G), Z(), _e(!0);
584
588
  try {
585
- le.current?.({
589
+ ce.current?.({
586
590
  sentId: m,
587
- ...f ? { reportedId: f } : {},
588
- reason: p ? "id" : "history"
591
+ ...p ? { reportedId: p } : {},
592
+ reason: w ? "id" : "history"
589
593
  });
590
594
  } catch {}
591
595
  }
592
- if (!ee) {
593
- E("Bailey returned an empty response.");
596
+ if (!x) {
597
+ D("Bailey returned an empty response.");
594
598
  return;
595
599
  }
596
- if (!S) {
597
- E("Bailey ran some tools but didn't return an answer. Try asking again.");
600
+ if (!C) {
601
+ D("Bailey ran some tools but didn't return an answer. Try asking again.");
598
602
  return;
599
603
  }
600
- D("idle");
601
- let k = ke.current.get(l) ?? "";
602
- T((e) => e && e.sentAt === s ? {
604
+ O("idle");
605
+ let M = ke.current.get(l) ?? "";
606
+ E((e) => e && e.sentAt === s ? {
603
607
  ...e,
604
- response: { content: k }
608
+ response: { content: M }
605
609
  } : e), c && await c({
606
610
  id: l,
607
611
  role: "assistant",
608
- content: k,
612
+ content: M,
609
613
  streaming: !1
610
- }, w);
614
+ }, T);
611
615
  } catch (e) {
612
616
  let t = e;
613
617
  if (t?.name === "TimeoutError") {
614
- E(t.message, { source: "client-timeout" });
618
+ D(t.message, { source: "client-timeout" });
615
619
  return;
616
620
  }
617
621
  if (t?.name === "AbortError") {
618
- D("idle");
622
+ O("idle");
619
623
  return;
620
624
  }
621
- E(t?.message || "Bailey request failed.");
625
+ D(t?.message || "Bailey request failed.");
622
626
  } finally {
623
- $();
627
+ je();
624
628
  let e = ke.current.get(l) ?? "";
625
629
  Oe.current.delete(l), ke.current.delete(l);
626
- let t = w.some((e) => e.kind === "tool_start" || e.kind === "tool_end");
627
- x((e) => e.flatMap((e) => e.id === l ? e.content || t ? [{
630
+ let t = T.some((e) => e.kind === "tool_start" || e.kind === "tool_end");
631
+ S((e) => e.flatMap((e) => e.id === l ? e.content || t ? [{
628
632
  ...e,
629
633
  streaming: !1
630
634
  }] : [] : [e])), Q.current = Q.current.flatMap((t) => t.id === l ? e ? [{
@@ -642,31 +646,31 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
642
646
  o,
643
647
  c,
644
648
  Ne,
649
+ $,
645
650
  Me,
646
651
  je,
647
- $,
648
- W,
652
+ G,
649
653
  Z
650
654
  ]), Fe = a((e) => {
651
- De.current = e, x(e);
655
+ De.current = e, S(e);
652
656
  }, []), Ie = a((e) => {
653
657
  let t = e.trim();
654
658
  if (!t) return;
655
659
  Te.current = t;
656
660
  let n = {
657
- id: se(),
661
+ id: R(),
658
662
  role: "user",
659
663
  content: t,
660
664
  createdAt: Date.now()
661
665
  }, r = [...Q.current, n];
662
666
  Q.current = r, Fe([...De.current, n]), Pe(r);
663
667
  }, [Pe, Fe]), Le = a((e, t) => {
664
- if (E === "streaming") return;
668
+ if (D === "streaming") return;
665
669
  let n = e.trim();
666
670
  if (!n) return;
667
671
  Te.current = n;
668
672
  let r = t?.trim(), i = {
669
- id: se(),
673
+ id: R(),
670
674
  role: "user",
671
675
  content: n,
672
676
  createdAt: Date.now(),
@@ -674,10 +678,10 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
674
678
  ...r ? { titleHint: r } : {}
675
679
  }, a = [...Q.current, i];
676
680
  Q.current = a, Pe(a);
677
- }, [Pe, E]), Re = a(() => {
681
+ }, [Pe, D]), Re = a(() => {
678
682
  we.current?.abort();
679
683
  }, []), ze = a(() => {
680
- if (E === "streaming" || !Te.current) return;
684
+ if (D === "streaming" || !Te.current) return;
681
685
  let e = De.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
682
686
  Fe(n);
683
687
  let r = Q.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
@@ -685,20 +689,20 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
685
689
  }, [
686
690
  Pe,
687
691
  Fe,
688
- E
689
- ]), Be = a(() => C([]), []), Ve = a(() => {
690
- j(null), D((e) => e === "error" ? "idle" : e);
692
+ D
693
+ ]), Be = a(() => w([]), []), Ve = a(() => {
694
+ j(null), O((e) => e === "error" ? "idle" : e);
691
695
  }, []), He = a(() => {
692
- we.current?.abort(), Z(), ve(!1), Fe([]), Q.current = [], C([]), T(null), D("idle"), j(null), Te.current = "";
696
+ we.current?.abort(), Z(), _e(!1), Fe([]), Q.current = [], w([]), E(null), O("idle"), j(null), Te.current = "";
693
697
  }, [Z, Fe]), Ue = a(() => {
694
- He(), G.current = void 0, U(void 0), R(K.current.storage, K.current.key, W);
695
- }, [He, W]), We = d(N);
698
+ He(), K.current = void 0, W(void 0), z(q.current.storage, q.current.key, G);
699
+ }, [He, G]), We = d(N);
696
700
  s(() => {
697
701
  let e = We.current;
698
702
  if (e === N) return;
699
703
  We.current = N, e !== void 0 && He();
700
- let t = V(W);
701
- G.current = t, U(t);
704
+ let t = H(G);
705
+ K.current = t, W(t);
702
706
  }, [N]);
703
707
  let Ge = a((e) => {
704
708
  we.current?.abort();
@@ -706,24 +710,24 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
706
710
  ...e,
707
711
  streaming: !1
708
712
  }));
709
- Fe(t.filter((e) => !e.hidden)), Q.current = t, C([]), T(null), D("idle"), j(null), Te.current = "";
713
+ Fe(t.filter((e) => !e.hidden)), Q.current = t, w([]), E(null), O("idle"), j(null), Te.current = "";
710
714
  }, [Fe]), Ke = a((e) => {
711
715
  Z(), Ge(e);
712
716
  }, [Z, Ge]), qe = a((e) => {
713
- G.current = e, U(e), de(K.current.storage, K.current.key, e, W), ve(!1);
714
- }, [W]), Je = a((e) => {
717
+ K.current = e, W(e), ue(q.current.storage, q.current.key, e, G), _e(!1);
718
+ }, [G]), Je = a((e) => {
715
719
  let t = e.hasMoreBefore && e.nextBeforeAbsoluteIndex !== null;
716
- X.current = t ? e.nextBeforeAbsoluteIndex : null, xe(t);
720
+ xe.current = t ? e.nextBeforeAbsoluteIndex : null, Y(t);
717
721
  }, []);
718
722
  return {
719
- conversationId: pe,
720
- persistence: ge,
721
- contextLost: _e,
722
- messages: ee,
723
- traceEvents: S,
724
- lastRequest: w,
725
- status: E,
726
- error: k,
723
+ conversationId: fe,
724
+ persistence: he,
725
+ contextLost: ge,
726
+ messages: x,
727
+ traceEvents: C,
728
+ lastRequest: T,
729
+ status: D,
730
+ error: ee,
727
731
  send: Ie,
728
732
  sendHidden: Le,
729
733
  stop: Re,
@@ -733,25 +737,25 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
733
737
  newChat: Ue,
734
738
  loadMessages: Ke,
735
739
  loadConversation: a(async ({ conversationId: e }) => {
736
- let t = Ce.current, { sub: n } = K.current, r = !!e && (!n || re({
740
+ let t = Ce.current, { sub: n } = q.current, r = !!e && (!n || re({
737
741
  conversationId: e,
738
742
  sub: n
739
743
  }));
740
- if (!t || !r) throw q("error"), Error(t ? "invalid conversation id" : "no client");
744
+ if (!t || !r) throw J("error"), Error(t ? "invalid conversation id" : "no client");
741
745
  we.current?.abort(), Z();
742
- let i = J.current, a = new AbortController();
743
- Y.current = a, q("loading");
746
+ let i = X.current, a = new AbortController();
747
+ be.current = a, J("loading");
744
748
  try {
745
749
  let n = await t.getConversation({
746
750
  conversationId: e,
747
751
  limit: oe,
748
752
  signal: a.signal
749
753
  });
750
- if (i !== J.current) return;
751
- Ge(te({ messages: n.messages })), qe(e), Je(n), q("idle");
754
+ if (i !== X.current) return;
755
+ Ge(te({ messages: n.messages })), qe(e), Je(n), J("idle");
752
756
  } catch (e) {
753
- if (i !== J.current) return;
754
- throw q("error"), e;
757
+ if (i !== X.current) return;
758
+ throw J("error"), e;
755
759
  }
756
760
  }, [
757
761
  Je,
@@ -760,10 +764,10 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
760
764
  Ge
761
765
  ]),
762
766
  loadEarlier: a(async () => {
763
- let e = Ce.current, t = G.current, n = X.current;
767
+ let e = Ce.current, t = K.current, n = xe.current;
764
768
  if (!e || !t || n === null || Se.current) return;
765
- let r = J.current, i = new AbortController();
766
- Y.current = i, Se.current = !0, q("loading");
769
+ let r = X.current, i = new AbortController();
770
+ be.current = i, Se.current = !0, J("loading");
767
771
  try {
768
772
  let a = await e.getConversation({
769
773
  conversationId: t,
@@ -771,36 +775,36 @@ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
771
775
  beforeAbsoluteIndex: n,
772
776
  signal: i.signal
773
777
  });
774
- if (r !== J.current) return;
778
+ if (r !== X.current) return;
775
779
  let o = te({ messages: a.messages });
776
780
  Q.current = ne({
777
781
  current: Q.current,
778
782
  earlier: o
779
- }), x((e) => {
783
+ }), S((e) => {
780
784
  let t = ne({
781
785
  current: e,
782
786
  earlier: o
783
787
  });
784
788
  return De.current = t, t;
785
- }), Je(a), q("idle");
789
+ }), Je(a), J("idle");
786
790
  } catch (e) {
787
- if (r !== J.current) return;
788
- throw q("error"), e;
791
+ if (r !== X.current) return;
792
+ throw J("error"), e;
789
793
  } finally {
790
- r === J.current && (Se.current = !1);
794
+ r === X.current && (Se.current = !1);
791
795
  }
792
796
  }, [Je]),
793
- hasEarlier: be,
794
- historyStatus: ye
797
+ hasEarlier: ye,
798
+ historyStatus: ve
795
799
  };
796
- }, V = class extends Error {
800
+ }, H = class extends Error {
797
801
  status;
798
802
  kind;
799
803
  constructor(e) {
800
- super(e.message ?? H(e), e.cause === void 0 ? void 0 : { cause: e.cause }), this.name = "BaileyApiError", this.status = e.status, this.kind = e.kind;
804
+ super(e.message ?? U(e), e.cause === void 0 ? void 0 : { cause: e.cause }), this.name = "BaileyApiError", this.status = e.status, this.kind = e.kind;
801
805
  }
802
806
  };
803
- function H(e) {
807
+ function U(e) {
804
808
  switch (e.kind) {
805
809
  case "http": return `Bailey request failed (status ${e.status})`;
806
810
  case "timeout": return "Bailey request timed out";
@@ -809,16 +813,16 @@ function H(e) {
809
813
  default: return "Bailey request failed (network error)";
810
814
  }
811
815
  }
812
- var pe = class extends Error {
816
+ var fe = class extends Error {
813
817
  operation;
814
818
  constructor(e) {
815
819
  super(`Bailey cleanup failed (${e.operation})`), this.name = "BaileyCleanupError", this.operation = e.operation;
816
820
  }
817
- }, U = (e) => e instanceof V ? e : new V({
821
+ }, W = (e) => e instanceof H ? e : new H({
818
822
  status: 0,
819
823
  kind: "network"
820
824
  });
821
- function me(e) {
825
+ function pe(e) {
822
826
  let { pageSize: t, enabled: n = !0 } = e, [r, i] = f([]), [o, c] = f(n ? "loading" : "idle"), [l, u] = f(null), [p, m] = f(null), h = d(e.client), g = d([]);
823
827
  s(() => {
824
828
  h.current = e.client, g.current = r;
@@ -841,15 +845,15 @@ function me(e) {
841
845
  }), _.current = r.nextCursor, m(r.nextCursor), u(null), c("idle");
842
846
  } catch (e) {
843
847
  if (n.signal.aborted) return;
844
- u(U(e)), c("error");
848
+ u(W(e)), c("error");
845
849
  }
846
850
  }, [t]);
847
851
  s(() => {
848
852
  if (n) return y("replace"), () => v.current?.abort();
849
853
  }, [n, y]);
850
- let b = a(() => y("replace"), [y]), ee = a(async () => {
854
+ let b = a(() => y("replace"), [y]), x = a(async () => {
851
855
  _.current !== null && await y("append");
852
- }, [y]), x = a(async ({ conversationId: e }) => {
856
+ }, [y]), S = a(async ({ conversationId: e }) => {
853
857
  let t = g.current.findIndex((t) => t.conversationId === e), n = t === -1 ? void 0 : {
854
858
  row: g.current[t],
855
859
  index: t
@@ -873,44 +877,44 @@ function me(e) {
873
877
  error: l,
874
878
  hasMore: p !== null,
875
879
  refresh: b,
876
- loadMore: ee,
877
- remove: x
880
+ loadMore: x,
881
+ remove: S
878
882
  };
879
883
  }
880
884
  //#endregion
881
885
  //#region src/client/routes.ts
882
- function he(e) {
886
+ function me(e) {
883
887
  return e.replace(/\/+$/, "");
884
888
  }
885
- function W(e, t) {
889
+ function G(e, t) {
886
890
  let n = new URLSearchParams();
887
891
  for (let [e, r] of Object.entries(t)) r !== void 0 && n.set(e, String(r));
888
892
  let r = n.toString();
889
893
  return r ? `${e}?${r}` : e;
890
894
  }
891
- var G = {
895
+ var K = {
892
896
  responses(e) {
893
- return `${he(e)}/responses`;
897
+ return `${me(e)}/responses`;
894
898
  },
895
899
  conversations(e, t) {
896
- return W(`${he(e)}/conversations`, {
900
+ return G(`${me(e)}/conversations`, {
897
901
  limit: t.limit,
898
902
  cursor: t.cursor
899
903
  });
900
904
  },
901
905
  conversation(e, t, n) {
902
- return W(`${he(e)}/conversations/${encodeURIComponent(t)}`, {
906
+ return G(`${me(e)}/conversations/${encodeURIComponent(t)}`, {
903
907
  limit: n.limit,
904
908
  before_absolute_index: n.beforeAbsoluteIndex
905
909
  });
906
910
  },
907
911
  feedback(e, t, n) {
908
- return `${he(e)}/conversations/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/feedback`;
912
+ return `${me(e)}/conversations/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/feedback`;
909
913
  }
910
914
  };
911
915
  //#endregion
912
916
  //#region src/client/createBaileyClient.ts
913
- function K(e) {
917
+ function q(e) {
914
918
  return {
915
919
  status: void 0,
916
920
  text: "",
@@ -919,40 +923,51 @@ function K(e) {
919
923
  ...e ? { errorCause: e.cause } : {}
920
924
  };
921
925
  }
922
- var ge = 3e4, _e = 155e3, ve = "x-chat-id", ye = "header", q = "body", be = "x-request-id", xe = "x-conversation-id", J = "x-message-id", Y = (e) => e && typeof e == "object" ? e : {}, X = (e, t = "") => typeof e == "string" ? e : t, Se = (e, t = 0) => typeof e == "number" ? e : t;
923
- function Z(e) {
924
- let t = Y(e);
926
+ var he = "The assistant took too long to respond. Please try again.";
927
+ function ge(e) {
925
928
  return {
926
- conversationId: X(t.conversation_id),
929
+ status: e.status,
930
+ text: "",
931
+ errorMessage: he,
932
+ errorKind: "timeout",
933
+ errorCause: e.cause,
934
+ ...e.status === void 0 ? {} : { interrupted: !0 }
935
+ };
936
+ }
937
+ var _e = 3e4, ve = 155e3, J = "x-chat-id", ye = "header", Y = "body", X = "x-request-id", be = "x-conversation-id", xe = "x-message-id", Se = (e) => e && typeof e == "object" ? e : {}, Z = (e, t = "") => typeof e == "string" ? e : t, Ce = (e, t = 0) => typeof e == "number" ? e : t;
938
+ function we(e) {
939
+ let t = Se(e);
940
+ return {
941
+ conversationId: Z(t.conversation_id),
927
942
  title: typeof t.title == "string" ? t.title : null,
928
- status: X(t.status),
929
- messageCount: Se(t.message_count),
930
- createdAt: X(t.created_at),
931
- updatedAt: X(t.updated_at)
943
+ status: Z(t.status),
944
+ messageCount: Ce(t.message_count),
945
+ createdAt: Z(t.created_at),
946
+ updatedAt: Z(t.updated_at)
932
947
  };
933
948
  }
934
- function Ce(e) {
949
+ function Te(e) {
935
950
  if (!e || typeof e != "object") return null;
936
- let t = Y(e);
951
+ let t = Se(e);
937
952
  return {
938
- rating: X(t.rating),
953
+ rating: Z(t.rating),
939
954
  reasonCodes: Array.isArray(t.reason_codes) ? t.reason_codes.filter((e) => typeof e == "string") : [],
940
955
  comment: typeof t.comment == "string" ? t.comment : null,
941
956
  ...typeof t.updated_at == "string" ? { updatedAt: t.updated_at } : {}
942
957
  };
943
958
  }
944
- function we(e) {
945
- let t = Y(e);
959
+ function Ee(e) {
960
+ let t = Se(e);
946
961
  return {
947
- messageId: X(t.message_id),
948
- role: X(t.role),
949
- content: X(t.content),
962
+ messageId: Z(t.message_id),
963
+ role: Z(t.role),
964
+ content: Z(t.content),
950
965
  hidden: t.hidden === !0,
951
- createdAt: X(t.created_at),
952
- feedback: Ce(t.feedback)
966
+ createdAt: Z(t.created_at),
967
+ feedback: Te(t.feedback)
953
968
  };
954
969
  }
955
- function Te(e) {
970
+ function De(e) {
956
971
  let t = new AbortController(), n = !1, r = setTimeout(() => {
957
972
  n = !0, t.abort();
958
973
  }, e.timeoutMs), i = () => t.abort(e.caller?.reason);
@@ -964,30 +979,30 @@ function Te(e) {
964
979
  }
965
980
  };
966
981
  }
967
- function Ee(e) {
968
- return e.timedOut() ? new V({
982
+ function Q(e) {
983
+ return e.timedOut() ? new H({
969
984
  status: 0,
970
985
  kind: "timeout",
971
986
  cause: e.signal.reason
972
- }) : new V({
987
+ }) : new H({
973
988
  status: 0,
974
989
  kind: "aborted"
975
990
  });
976
991
  }
977
- function De(e) {
978
- let { baseUrl: t, getHeaders: n, onAuthError: r } = e, i = e.requestTimeoutMs ?? ge, a = e.idleTimeoutMs ?? _e, o = e.conversationVia ?? ye;
979
- if (o !== ye && o !== q) throw TypeError("createBaileyClient: conversationVia must be 'header' or 'body'");
992
+ function Oe(e) {
993
+ let { baseUrl: t, getHeaders: n, onAuthError: r } = e, i = e.requestTimeoutMs ?? _e, a = e.idleTimeoutMs ?? ve, o = e.conversationVia ?? ye;
994
+ if (o !== ye && o !== Y) throw TypeError("createBaileyClient: conversationVia must be 'header' or 'body'");
980
995
  let s = e.fetch ?? ((e, t) => globalThis.fetch(e, t));
981
996
  function c(t) {
982
997
  try {
983
- e.onCleanupError?.(new pe({ operation: t }));
998
+ e.onCleanupError?.(new fe({ operation: t }));
984
999
  } catch {}
985
1000
  }
986
1001
  function l(e) {
987
1002
  e.kind === "http" && (e.status === 401 || e.status === 403) && r?.(e);
988
1003
  }
989
1004
  async function u(e) {
990
- let t = Te({
1005
+ let t = De({
991
1006
  caller: e.signal,
992
1007
  timeoutMs: i
993
1008
  });
@@ -999,12 +1014,12 @@ function De(e) {
999
1014
  ...await n()
1000
1015
  };
1001
1016
  } catch {
1002
- throw new V({
1017
+ throw new H({
1003
1018
  status: 0,
1004
1019
  kind: "network"
1005
1020
  });
1006
1021
  }
1007
- if (t.signal.aborted) throw Ee(t);
1022
+ if (t.signal.aborted) throw Q(t);
1008
1023
  e.body !== void 0 && (r["Content-Type"] = "application/json");
1009
1024
  let i;
1010
1025
  try {
@@ -1015,18 +1030,18 @@ function De(e) {
1015
1030
  signal: t.signal
1016
1031
  });
1017
1032
  } catch (e) {
1018
- throw t.signal.aborted ? Ee(t) : new V({
1033
+ throw t.signal.aborted ? Q(t) : new H({
1019
1034
  status: 0,
1020
1035
  kind: "network",
1021
1036
  cause: e
1022
1037
  });
1023
1038
  }
1024
- if (!i.ok) throw i.body?.cancel().catch(() => c("cancel-response-body")), new V({
1039
+ if (!i.ok) throw i.body?.cancel().catch(() => c("cancel-response-body")), new H({
1025
1040
  status: i.status,
1026
1041
  kind: "http"
1027
1042
  });
1028
1043
  if (i.status === 204) {
1029
- if (e.requireJsonBody) throw new V({
1044
+ if (e.requireJsonBody) throw new H({
1030
1045
  status: 204,
1031
1046
  kind: "invalid-response"
1032
1047
  });
@@ -1034,22 +1049,22 @@ function De(e) {
1034
1049
  }
1035
1050
  try {
1036
1051
  let t = await i.json();
1037
- if (e.requireJsonBody && (typeof t != "object" || !t || Array.isArray(t))) throw new V({
1052
+ if (e.requireJsonBody && (typeof t != "object" || !t || Array.isArray(t))) throw new H({
1038
1053
  status: i.status,
1039
1054
  kind: "invalid-response"
1040
1055
  });
1041
1056
  return t;
1042
1057
  } catch (n) {
1043
- if (n instanceof V) throw n;
1044
- if (t.timedOut() || t.signal.aborted) throw Ee(t);
1045
- if (e.requireJsonBody) throw new V({
1058
+ if (n instanceof H) throw n;
1059
+ if (t.timedOut() || t.signal.aborted) throw Q(t);
1060
+ if (e.requireJsonBody) throw new H({
1046
1061
  status: i.status,
1047
1062
  kind: "invalid-response"
1048
1063
  });
1049
1064
  return;
1050
1065
  }
1051
1066
  } catch (e) {
1052
- throw e instanceof V && l(e), e;
1067
+ throw e instanceof H && l(e), e;
1053
1068
  } finally {
1054
1069
  t.dispose();
1055
1070
  }
@@ -1058,13 +1073,19 @@ function De(e) {
1058
1073
  streamChat: async (e) => {
1059
1074
  let r = new AbortController(), i = () => r.abort(e.signal.reason);
1060
1075
  e.signal.aborted ? i() : e.signal.addEventListener("abort", i, { once: !0 });
1061
- let u, d = () => {
1076
+ let u, d, f = () => {
1062
1077
  clearTimeout(u), u = setTimeout(() => {
1063
- r.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
1078
+ d = new DOMException(he, "TimeoutError"), r.abort(d);
1064
1079
  }, a);
1080
+ }, p = (t) => {
1081
+ if (d && !e.signal.aborted) return ge({
1082
+ cause: d,
1083
+ status: t
1084
+ });
1085
+ throw r.signal.reason;
1065
1086
  };
1066
1087
  try {
1067
- d();
1088
+ f();
1068
1089
  let i;
1069
1090
  try {
1070
1091
  i = {
@@ -1072,14 +1093,14 @@ function De(e) {
1072
1093
  ...await n()
1073
1094
  };
1074
1095
  } catch {
1075
- return K();
1096
+ return q();
1076
1097
  }
1077
- if (r.signal.aborted) throw r.signal.reason;
1078
- i["Content-Type"] = "application/json", e.conversationId && o === ye && (i[ve] = e.conversationId);
1098
+ if (r.signal.aborted) return p();
1099
+ i["Content-Type"] = "application/json", e.conversationId && o === ye && (i[J] = e.conversationId);
1079
1100
  let a = e.input[e.input.length - 1], u = {
1080
1101
  ...a?.hidden === !0 ? { hidden: !0 } : {},
1081
1102
  ...a?.titleHint ? { title_hint: a.titleHint } : {}
1082
- }, f = {
1103
+ }, d = {
1083
1104
  model: e.model,
1084
1105
  instructions: e.instructions,
1085
1106
  input: e.input.map(({ role: e, content: t }) => ({
@@ -1089,63 +1110,62 @@ function De(e) {
1089
1110
  stream: !0,
1090
1111
  ...Object.keys(u).length > 0 ? { metadata: u } : {}
1091
1112
  };
1092
- e.conversationId && o === q && (f.conversation = e.conversationId), e.tools.length > 0 && (f.tools = e.tools), e.toolChoice && (f.tool_choice = e.toolChoice);
1093
- let p;
1113
+ e.conversationId && o === Y && (d.conversation = e.conversationId), e.tools.length > 0 && (d.tools = e.tools), e.toolChoice && (d.tool_choice = e.toolChoice);
1114
+ let m;
1094
1115
  try {
1095
- p = await s(G.responses(t), {
1116
+ m = await s(K.responses(t), {
1096
1117
  method: "POST",
1097
1118
  headers: i,
1098
- body: JSON.stringify(f),
1119
+ body: JSON.stringify(d),
1099
1120
  signal: r.signal
1100
1121
  });
1101
1122
  } catch (e) {
1102
- if (r.signal.aborted) throw r.signal.reason;
1103
- return K({ cause: e });
1123
+ return r.signal.aborted ? p() : q({ cause: e });
1104
1124
  }
1105
- let m = p.headers.get(be);
1106
- m && e.onRequestId?.(m);
1107
- let h = p.headers.get(J);
1108
- if (h && e.onMessageId?.(h), !p.ok) {
1109
- l(new V({
1110
- status: p.status,
1125
+ let h = m.headers.get(X);
1126
+ h && e.onRequestId?.(h);
1127
+ let g = m.headers.get(xe);
1128
+ if (g && e.onMessageId?.(g), !m.ok) {
1129
+ l(new H({
1130
+ status: m.status,
1111
1131
  kind: "http"
1112
1132
  }));
1113
- let e = await p.text().catch(() => "");
1133
+ let e = await m.text().catch(() => "");
1114
1134
  return {
1115
- status: p.status,
1135
+ status: m.status,
1116
1136
  text: e
1117
1137
  };
1118
1138
  }
1119
- let g = p.headers.get(xe);
1120
- if (g && e.onConversationId?.(g), !p.body) return {
1121
- status: p.status,
1139
+ let _ = m.headers.get(be);
1140
+ if (_ && e.onConversationId?.(_), !m.body) return {
1141
+ status: m.status,
1122
1142
  text: ""
1123
1143
  };
1124
- let _ = p.body.getReader(), v = new TextDecoder(), y = () => void _.cancel(r.signal.reason).catch(() => c("cancel-stream-reader"));
1125
- r.signal.addEventListener("abort", y, { once: !0 });
1144
+ let v = m.body.getReader(), y = new TextDecoder(), b = () => void v.cancel(r.signal.reason).catch(() => c("cancel-stream-reader"));
1145
+ r.signal.addEventListener("abort", b, { once: !0 });
1126
1146
  try {
1127
1147
  for (;;) {
1128
- let { done: t, value: n } = await _.read();
1129
- if (r.signal.aborted) throw r.signal.reason;
1148
+ let { done: t, value: n } = await v.read();
1149
+ if (r.signal.aborted) return p(m.status);
1130
1150
  if (t) {
1131
- let t = v.decode();
1151
+ let t = y.decode();
1132
1152
  t && e.onChunk(t);
1133
1153
  break;
1134
1154
  }
1135
- d(), e.onChunk(v.decode(n, { stream: !0 }));
1155
+ f(), e.onChunk(y.decode(n, { stream: !0 }));
1136
1156
  }
1137
1157
  } catch {
1138
- if (r.signal.aborted) throw r.signal.reason;
1158
+ if (r.signal.aborted) return p(m.status);
1139
1159
  if (e.signal.aborted) throw e.signal.reason;
1140
1160
  return {
1141
- status: p.status,
1161
+ status: m.status,
1142
1162
  text: "",
1143
1163
  errorMessage: "Stream interrupted",
1144
1164
  interrupted: !0
1145
1165
  };
1146
1166
  }
1147
- return r.signal.removeEventListener("abort", y), {
1148
- status: p.status,
1167
+ return r.signal.removeEventListener("abort", b), {
1168
+ status: m.status,
1149
1169
  text: ""
1150
1170
  };
1151
1171
  } finally {
@@ -1153,31 +1173,31 @@ function De(e) {
1153
1173
  }
1154
1174
  },
1155
1175
  async listConversations(e = {}) {
1156
- let n = Y(await u({
1176
+ let n = Se(await u({
1157
1177
  method: "GET",
1158
- url: G.conversations(t, e),
1178
+ url: K.conversations(t, e),
1159
1179
  signal: e.signal,
1160
1180
  requireJsonBody: !0
1161
1181
  }));
1162
1182
  return {
1163
- conversations: Array.isArray(n.conversations) ? n.conversations.map(Z).filter((e) => e.conversationId !== "") : [],
1183
+ conversations: Array.isArray(n.conversations) ? n.conversations.map(we).filter((e) => e.conversationId !== "") : [],
1164
1184
  nextCursor: typeof n.next_cursor == "string" ? n.next_cursor : null
1165
1185
  };
1166
1186
  },
1167
1187
  async getConversation(e) {
1168
- let n = Y(await u({
1188
+ let n = Se(await u({
1169
1189
  method: "GET",
1170
- url: G.conversation(t, e.conversationId, e),
1190
+ url: K.conversation(t, e.conversationId, e),
1171
1191
  signal: e.signal,
1172
1192
  requireJsonBody: !0
1173
1193
  }));
1174
- if (!n.conversation || typeof n.conversation != "object") throw new V({
1194
+ if (!n.conversation || typeof n.conversation != "object") throw new H({
1175
1195
  status: 200,
1176
1196
  kind: "invalid-response"
1177
1197
  });
1178
1198
  return {
1179
- conversation: Z(n.conversation),
1180
- messages: Array.isArray(n.messages) ? n.messages.map(we) : [],
1199
+ conversation: we(n.conversation),
1200
+ messages: Array.isArray(n.messages) ? n.messages.map(Ee) : [],
1181
1201
  hasMoreBefore: n.has_more_before === !0,
1182
1202
  nextBeforeAbsoluteIndex: typeof n.next_before_absolute_index == "number" ? n.next_before_absolute_index : null
1183
1203
  };
@@ -1185,14 +1205,14 @@ function De(e) {
1185
1205
  async deleteConversation(e) {
1186
1206
  await u({
1187
1207
  method: "DELETE",
1188
- url: G.conversation(t, e.conversationId, {}),
1208
+ url: K.conversation(t, e.conversationId, {}),
1189
1209
  signal: e.signal
1190
1210
  });
1191
1211
  },
1192
1212
  async submitFeedback(e) {
1193
1213
  await u({
1194
1214
  method: "PUT",
1195
- url: G.feedback(t, e.conversationId, e.messageId),
1215
+ url: K.feedback(t, e.conversationId, e.messageId),
1196
1216
  body: {
1197
1217
  rating: e.rating,
1198
1218
  ...e.reasonCodes ? { reason_codes: e.reasonCodes } : {},
@@ -1204,7 +1224,7 @@ function De(e) {
1204
1224
  async clearFeedback(e) {
1205
1225
  await u({
1206
1226
  method: "DELETE",
1207
- url: G.feedback(t, e.conversationId, e.messageId),
1227
+ url: K.feedback(t, e.conversationId, e.messageId),
1208
1228
  signal: e.signal
1209
1229
  });
1210
1230
  }
@@ -1212,7 +1232,7 @@ function De(e) {
1212
1232
  }
1213
1233
  //#endregion
1214
1234
  //#region src/client/feedbackHandlers.ts
1215
- function Q(e) {
1235
+ function ke(e) {
1216
1236
  let { client: t, getConversationId: n } = e, r = () => {
1217
1237
  let e = n();
1218
1238
  if (!e) throw Error("no conversation id");
@@ -1240,15 +1260,15 @@ function Q(e) {
1240
1260
  }
1241
1261
  //#endregion
1242
1262
  //#region src/utils/prompt.ts
1243
- function Oe(...e) {
1263
+ function Ae(...e) {
1244
1264
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
1245
1265
  }
1246
1266
  //#endregion
1247
1267
  //#region src/utils/toolCalls.ts
1248
- var ke = "call_tool", Ae = "a tool";
1268
+ var je = "call_tool", Me = "a tool";
1249
1269
  function $(e, t) {
1250
1270
  let n = {
1251
- name: e === ke ? Ae : e,
1271
+ name: e === je ? Me : e,
1252
1272
  args: null,
1253
1273
  viaCallTool: !1
1254
1274
  };
@@ -1261,7 +1281,7 @@ function $(e, t) {
1261
1281
  }
1262
1282
  if (typeof r != "object" || !r) return n;
1263
1283
  let i = r;
1264
- if (e === ke) {
1284
+ if (e === je) {
1265
1285
  let e = typeof i.name == "string" ? i.name : void 0;
1266
1286
  if (!e) return n;
1267
1287
  let t = i.arguments;
@@ -1279,32 +1299,32 @@ function $(e, t) {
1279
1299
  }
1280
1300
  //#endregion
1281
1301
  //#region src/utils/table.ts
1282
- var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(Me).join(""), Ne = (e) => {
1302
+ var Ne = 5, Pe = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(Pe).join(""), Fe = (e) => {
1283
1303
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
1284
1304
  for (let t of e.children ?? []) {
1285
- let e = Ne(t);
1305
+ let e = Fe(t);
1286
1306
  if (e) return e;
1287
1307
  }
1288
- }, Pe = (e, t) => (e.children ?? []).find((e) => e.tagName === t), Fe = (e) => {
1289
- let t = Me(e), n = Ne(e);
1308
+ }, Ie = (e, t) => (e.children ?? []).find((e) => e.tagName === t), Le = (e) => {
1309
+ let t = Pe(e), n = Fe(e);
1290
1310
  return n ? {
1291
1311
  text: t,
1292
1312
  href: n
1293
1313
  } : { text: t };
1294
- }, Ie = (e) => (e.children ?? []).filter((e) => e.type === "element").map(Fe), Le = (e) => {
1314
+ }, Re = (e) => (e.children ?? []).filter((e) => e.type === "element").map(Le), ze = (e) => {
1295
1315
  if (e.tagName !== "table") return null;
1296
- let t = Pe(e, "thead"), n = t && Pe(t, "tr");
1316
+ let t = Ie(e, "thead"), n = t && Ie(t, "tr");
1297
1317
  return {
1298
- headers: n ? Ie(n).map((e) => e.text) : [],
1299
- rows: (Pe(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(Ie)
1318
+ headers: n ? Re(n).map((e) => e.text) : [],
1319
+ rows: (Ie(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(Re)
1300
1320
  };
1301
- }, Re = (e) => e.length > 5, ze = "When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {\"type\": \"bar\" | \"line\" | \"pie\" | \"doughnut\" | \"scatter\", \"title\"?: string, \"data\": {\"labels\": string[], \"datasets\": [{\"label\": string, \"data\": number[]}]}}. For \"scatter\" charts, omit \"labels\" and give each dataset \"data\" as an array of {\"x\": number, \"y\": number} points instead of a number array. \"pie\" and \"doughnut\" charts must have exactly one dataset. Do not include any other fields (no \"options\", no colors) — the app handles styling. Example:\n```chartjs\n{\"type\": \"line\", \"title\": \"BP readings\", \"data\": {\"labels\": [\"Jul 14\", \"Jul 21\", \"Jul 28\"], \"datasets\": [{\"label\": \"Systolic\", \"data\": [120, 118, 122]}]}}\n```", Be = [
1321
+ }, Be = (e) => e.length > 5, Ve = "When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {\"type\": \"bar\" | \"line\" | \"pie\" | \"doughnut\" | \"scatter\", \"title\"?: string, \"data\": {\"labels\": string[], \"datasets\": [{\"label\": string, \"data\": number[]}]}}. For \"scatter\" charts, omit \"labels\" and give each dataset \"data\" as an array of {\"x\": number, \"y\": number} points instead of a number array. \"pie\" and \"doughnut\" charts must have exactly one dataset. Do not include any other fields (no \"options\", no colors) — the app handles styling. Example:\n```chartjs\n{\"type\": \"line\", \"title\": \"BP readings\", \"data\": {\"labels\": [\"Jul 14\", \"Jul 21\", \"Jul 28\"], \"datasets\": [{\"label\": \"Systolic\", \"data\": [120, 118, 122]}]}}\n```", He = [
1302
1322
  "bar",
1303
1323
  "line",
1304
1324
  "pie",
1305
1325
  "doughnut",
1306
1326
  "scatter"
1307
- ], Ve = 8, He = 50, Ue = 8, We = 500, Ge = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", Ke = (e) => {
1327
+ ], Ue = 8, We = 50, Ge = 8, Ke = 500, qe = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", Je = (e) => {
1308
1328
  let t;
1309
1329
  try {
1310
1330
  t = JSON.parse(e);
@@ -1313,17 +1333,17 @@ var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).m
1313
1333
  }
1314
1334
  if (typeof t != "object" || !t) return null;
1315
1335
  let n = t;
1316
- if (typeof n.type != "string" || !Be.includes(n.type)) return null;
1336
+ if (typeof n.type != "string" || !He.includes(n.type)) return null;
1317
1337
  let r = n.type;
1318
1338
  if (n.title !== void 0 && typeof n.title != "string") return null;
1319
1339
  let i = n.title;
1320
1340
  if (typeof n.data != "object" || n.data === null) return null;
1321
1341
  let a = n.data;
1322
- if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > Ve || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
1342
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > Ue || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
1323
1343
  for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
1324
1344
  let o = a.datasets;
1325
1345
  if (r === "scatter") {
1326
- for (let e of o) if (e.data.length < 1 || e.data.length > We || !e.data.every(Ge)) return null;
1346
+ for (let e of o) if (e.data.length < 1 || e.data.length > Ke || !e.data.every(qe)) return null;
1327
1347
  return {
1328
1348
  type: r,
1329
1349
  title: i,
@@ -1331,7 +1351,7 @@ var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).m
1331
1351
  };
1332
1352
  }
1333
1353
  if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
1334
- let s = a.labels, c = r === "pie" || r === "doughnut" ? Ue : He;
1354
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? Ge : We;
1335
1355
  if (s.length < 1 || s.length > c) return null;
1336
1356
  for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
1337
1357
  return {
@@ -1342,7 +1362,7 @@ var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).m
1342
1362
  datasets: o
1343
1363
  }
1344
1364
  };
1345
- }, qe = {
1365
+ }, Ye = {
1346
1366
  tool_start: "Tool start",
1347
1367
  tool_end: "Tool end",
1348
1368
  pseudo_tool_call: "Narrated tool call",
@@ -1353,13 +1373,13 @@ var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).m
1353
1373
  error: "Error",
1354
1374
  raw: "Raw event"
1355
1375
  };
1356
- function Je(e) {
1376
+ function Xe(e) {
1357
1377
  return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : $(e.name, e.args);
1358
1378
  }
1359
- function Ye(e, t = Je(e)) {
1379
+ function Ze(e, t = Xe(e)) {
1360
1380
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
1361
1381
  }
1362
- function Xe(e, t = Je(e)) {
1382
+ function Qe(e, t = Xe(e)) {
1363
1383
  switch (e.kind) {
1364
1384
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
1365
1385
  case "tool_end": return `${t.viaCallTool ? `${t.name} (via call_tool)` : t.name}${e.runtimeSeconds === void 0 ? "" : ` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError ? " — failed" : ""}`;
@@ -1372,19 +1392,19 @@ function Xe(e, t = Je(e)) {
1372
1392
  case "raw": return `Unrecognized event: ${e.eventType}`;
1373
1393
  }
1374
1394
  }
1375
- function Ze(e, t = Je(e)) {
1395
+ function $e(e, t = Xe(e)) {
1376
1396
  return e.kind === "tool_start" || e.kind === "tool_end" ? t.args ? JSON.stringify(t.args, null, 2) : e.args ?? null : e.kind === "pseudo_tool_call" ? e.args ?? null : e.kind === "llm_call_start" ? JSON.stringify(e.request, null, 2) : null;
1377
1397
  }
1378
- function Qe(e) {
1398
+ function et(e) {
1379
1399
  return e.kind === "tool_end" ? e.output ?? null : e.kind === "llm_call_end" ? e.response ?? null : null;
1380
1400
  }
1381
- function $e(e) {
1401
+ function tt(e) {
1382
1402
  return e.kind === "tool_end" && e.structuredOutput ? JSON.stringify(e.structuredOutput, null, 2) : null;
1383
1403
  }
1384
- function et(e) {
1404
+ function nt(e) {
1385
1405
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
1386
1406
  }
1387
- function tt(e) {
1407
+ function rt(e) {
1388
1408
  switch (e.kind) {
1389
1409
  case "tool_start": return `Calling ${$(e.name, e.args).name}...`;
1390
1410
  case "tool_end": {
@@ -1400,11 +1420,11 @@ function tt(e) {
1400
1420
  case "raw": return `Unrecognized event: ${e.eventType}`;
1401
1421
  }
1402
1422
  }
1403
- function nt(e) {
1423
+ function it(e) {
1404
1424
  let t = new Date(e);
1405
1425
  return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
1406
1426
  }
1407
- function rt(e) {
1427
+ function at(e) {
1408
1428
  if (e <= 0) return "+0ms";
1409
1429
  if (e < 1e3) return `+${Math.round(e)}ms`;
1410
1430
  let t = e / 1e3;
@@ -1412,31 +1432,31 @@ function rt(e) {
1412
1432
  let n = Math.floor(t / 60), r = Math.round(t % 60);
1413
1433
  return `+${n}m${String(r).padStart(2, "0")}s`;
1414
1434
  }
1415
- function it(e) {
1435
+ function ot(e) {
1416
1436
  return e.map((t, n) => {
1417
- let r = Je(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
1437
+ let r = Xe(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
1418
1438
  return {
1419
1439
  key: `${t.at}-${n}`,
1420
1440
  kind: t.kind,
1421
- toolName: Ye(t, r),
1441
+ toolName: Ze(t, r),
1422
1442
  isToolStart: t.kind === "tool_start",
1423
1443
  failed: t.kind === "tool_end" && t.isError === !0,
1424
- time: nt(t.at),
1444
+ time: it(t.at),
1425
1445
  gapMs: t.at - i,
1426
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : qe[t.kind],
1427
- summary: Xe(t, r),
1428
- argsDetail: Ze(t, r),
1429
- outputDetail: Qe(t),
1430
- structuredOutputDetail: $e(t),
1431
- rawDetail: et(t)
1446
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : Ye[t.kind],
1447
+ summary: Qe(t, r),
1448
+ argsDetail: $e(t, r),
1449
+ outputDetail: et(t),
1450
+ structuredOutputDetail: tt(t),
1451
+ rawDetail: nt(t)
1432
1452
  };
1433
1453
  });
1434
1454
  }
1435
- function at(e) {
1455
+ function st(e) {
1436
1456
  let t = e.filter((e) => e.kind === "tool_end"), n = t.filter((e) => e.kind === "tool_end" && e.isError), r = e.filter((e) => e.kind === "llm_call_end"), i = e.filter((e) => e.kind === "error"), a = [];
1437
1457
  return r.length > 0 && a.push(`${r.length} LLM call${r.length === 1 ? "" : "s"}`), t.length > 0 && a.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), i.length > 0 && a.push(`${i.length} stream error${i.length === 1 ? "" : "s"}`), a.join(" · ");
1438
1458
  }
1439
- function ot(e) {
1459
+ function ct(e) {
1440
1460
  let t = [];
1441
1461
  for (let n of e) {
1442
1462
  let e = t[t.length - 1];
@@ -1455,17 +1475,17 @@ function ot(e) {
1455
1475
  }
1456
1476
  return t;
1457
1477
  }
1458
- function st(e) {
1478
+ function lt(e) {
1459
1479
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
1460
1480
  }
1461
- function ct(e, t) {
1481
+ function ut(e, t) {
1462
1482
  return t === void 0 ? [] : e.filter((e) => e.turnSentAt === t && (e.kind === "tool_end" || e.kind === "pseudo_tool_call" || e.kind === "progress")).map((e, t) => ({
1463
1483
  key: `${e.at}-${t}`,
1464
- text: tt(e),
1465
- toolName: Ye(e)
1484
+ text: rt(e),
1485
+ toolName: Ze(e)
1466
1486
  }));
1467
1487
  }
1468
- function lt(e, t) {
1488
+ function dt(e, t) {
1469
1489
  if (t === void 0) return [];
1470
1490
  let n = [];
1471
1491
  for (let r of e) if (r.turnSentAt === t) {
@@ -1494,45 +1514,45 @@ function lt(e, t) {
1494
1514
  }
1495
1515
  //#endregion
1496
1516
  //#region src/styles.css?inline
1497
- var ut = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#fff;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff;--color-bailey-page-bg:#eceef4;--color-bailey-heart:#16a34a}}@layer utilities;.bailey-chat-panel{box-sizing:border-box;background-color:var(--color-bailey-page-bg);height:100%;padding:calc(var(--spacing) * 3);font-family:var(--font-sans);flex-direction:column;display:flex;position:relative}.bailey-chat-panel-inner{width:100%;min-height:0;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;flex:1;margin-inline:auto;display:flex;overflow-y:auto}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 4);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-message{flex-direction:column;align-items:flex-end;max-width:75%;display:flex}.bailey-message-meta{margin-bottom:var(--spacing);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-message-meta-name{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-text)}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:100%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-tool-result-image{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);max-width:100%;height:auto;display:block}.bailey-mcp-app-frame{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:0;width:100%;height:480px;display:block}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);flex-wrap:wrap;display:flex}.bailey-empty-state{text-align:center;height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-suggestions{gap:calc(var(--spacing) * 3);padding:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-suggestions-title{padding-inline:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text)}.bailey-suggestion-card{cursor:pointer;appearance:none;justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-2xl);--tw-border-style:none;background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 3);text-align:left;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-style:none;display:flex}@media (hover:hover){.bailey-suggestion-card:hover{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.bailey-suggestion-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-text-secondary);flex-shrink:0}.bailey-privacy-note{border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 4);padding-top:calc(var(--spacing) * 3);padding-bottom:var(--spacing);text-align:center;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-privacy-note a{color:var(--color-bailey-text-secondary);text-decoration-line:underline}.bailey-tool-steps-live{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-activity-line{align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-activity-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-accent);flex-shrink:0}.bailey-step-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;flex-shrink:0}@media (prefers-reduced-motion:no-preference){.bailey-step-spinner{animation:var(--animate-spin)}}.bailey-tool-steps-summary{margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}.bailey-tool-steps-summary>summary{cursor:pointer;-webkit-user-select:none;user-select:none}.bailey-tool-steps-list{margin:0;margin-top:var(--spacing);gap:var(--spacing);flex-direction:column;padding:0;list-style-type:none;display:flex}.bailey-tool-step{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-tool-step-failed{color:var(--color-bailey-error)}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-error);background-color:#0000;border-style:none}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-area{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);min-width:0;padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;flex:1;display:flex}.bailey-input-row:focus-within{border-color:var(--color-bailey-accent)}.bailey-input{--tw-border-style:none;min-width:0;padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;background-color:#0000;border-style:none;outline-style:none;flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{cursor:pointer;appearance:none;background-color:#0000;border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}:is(.bailey-send-button,.bailey-stop-button):disabled{cursor:default;opacity:.4}.bailey-send-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-heart);border-style:none}@media (hover:hover){.bailey-send-button:hover{background-color:#16a34a1a}@supports (color:color-mix(in lab, red, red)){.bailey-send-button:hover{background-color:color-mix(in oklab, var(--color-bailey-heart) 10%, transparent)}}}.bailey-send-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-stop-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-copy-button{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-copy-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-copy-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-copy-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-tooltip-content{padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-menu-button{height:calc(var(--spacing) * 13);width:calc(var(--spacing) * 13);cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-menu-button:hover{background-color:var(--color-gray-50)}}.bailey-menu-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-menu-content{z-index:50;min-width:calc(var(--spacing) * 44);border-radius:var(--radius-2xl);background-color:var(--color-white);padding-block:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-black);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);font-family:var(--font-sans,\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif)}.bailey-menu-item{cursor:pointer;align-items:center;gap:calc(var(--spacing) * 3);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;outline-style:none;display:flex}.bailey-menu-item[data-highlighted]{background-color:var(--color-gray-100)}.bailey-menu-item-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-gray-600)}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-trace-toggle:hover{text-decoration-line:underline}}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}@media (hover:hover){.bailey-trace-copy-button:hover{text-decoration-line:none}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-feedback{align-items:center;gap:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);flex-wrap:wrap;display:flex}.bailey-message-actions>.bailey-feedback{display:contents}.bailey-feedback-thumbs{margin-left:var(--spacing);align-items:center;gap:calc(var(--spacing) * .5);border-left-style:var(--tw-border-style);border-left-width:1px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 2);display:flex}.bailey-feedback-thumb{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-feedback-thumb:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-feedback-thumb:hover{color:var(--color-bailey-text)}}.bailey-feedback-thumb:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-thumb:disabled{cursor:default;opacity:.5}.bailey-feedback-thumb[aria-pressed=true]{background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-thumb[aria-pressed=true]{color:var(--color-bailey-accent)}.bailey-feedback-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-feedback-status{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:inline-flex}.bailey-feedback-status:empty{display:none}.bailey-feedback-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);animation:var(--animate-spin);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;display:inline-block}.bailey-feedback-link{cursor:pointer;appearance:none;--tw-border-style:none;padding-inline:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-feedback-link:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-feedback-form{margin-top:calc(var(--spacing) * 2);box-sizing:border-box;border-radius:var(--radius-xl);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding:calc(var(--spacing) * 3);flex-basis:100%}.bailey-feedback-reasons{margin:0;margin-bottom:calc(var(--spacing) * 2);--tw-border-style:none;border-style:none;min-width:0;padding:0}.bailey-feedback-legend{margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text);padding:0;display:block}.bailey-feedback-chips{gap:calc(var(--spacing) * 1.5);flex-wrap:wrap;display:flex}.bailey-feedback-chip{cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text);border-radius:2147483647px}.bailey-feedback-chip:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-chip:disabled{cursor:default;opacity:.5}.bailey-feedback-chip[aria-pressed=true]{border-color:var(--color-bailey-accent);background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-chip[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-chip[aria-pressed=true]{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-feedback-textarea{box-sizing:border-box;min-height:calc(var(--spacing) * 18);resize:vertical;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding-inline:calc(var(--spacing) * 2.5);padding-block:calc(var(--spacing) * 2);font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);display:block}.bailey-feedback-textarea:disabled{opacity:.5}.bailey-feedback-meta{margin-top:calc(var(--spacing) * 1.5);justify-content:space-between;align-items:flex-start;gap:calc(var(--spacing) * 3);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-feedback-buttons{margin-top:calc(var(--spacing) * 2.5);justify-content:flex-end;gap:calc(var(--spacing) * 2);display:flex}.bailey-feedback-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-feedback-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-button:disabled{cursor:default;opacity:.5}.bailey-feedback-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-load-earlier{align-items:center;gap:var(--spacing);padding-bottom:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-load-earlier-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-load-earlier-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-load-earlier-button:disabled{cursor:default;opacity:.5}.bailey-load-earlier-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-history-drawer{z-index:10;background-color:var(--color-bailey-surface);font-family:var(--font-sans);color:var(--color-bailey-text);border-radius:14px;flex-direction:column;display:flex;position:absolute;inset:0;overflow:hidden;container-type:inline-size}.bailey-history-header{align-items:center;gap:calc(var(--spacing) * 2);border-bottom-style:var(--tw-border-style);border-bottom-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);display:flex}.bailey-history-heading{text-overflow:ellipsis;white-space:nowrap;--tw-font-weight:var(--font-weight-semibold);min-width:0;font-size:15px;font-weight:var(--font-weight-semibold);--tw-outline-style:none;outline-style:none;flex:1;margin:0;overflow:hidden}.bailey-history-icon-button{height:calc(var(--spacing) * 11);width:calc(var(--spacing) * 11);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;flex:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-icon-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-history-icon-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-history-icon-button:hover{color:var(--color-bailey-text)}}.bailey-history-icon-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-icon-button:disabled{cursor:default;opacity:.5}.bailey-history-icon{width:18px;height:18px}.bailey-history-icon-small{height:calc(var(--spacing) * 3.5);width:calc(var(--spacing) * 3.5);flex:none}.bailey-history-button{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;justify-content:center;align-items:center;gap:calc(var(--spacing) * 1.5);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 1.5);white-space:nowrap;color:var(--color-bailey-text);font-size:13px;display:inline-flex}.bailey-history-button:focus-visible{outline-style:var(--tw-outline-style);outline-offset:2px;outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-button:disabled{cursor:default;opacity:.5}.bailey-history-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-danger{border-color:var(--color-bailey-error);background-color:var(--color-bailey-error);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-small{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-history-body{padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);flex:1;overflow-y:auto}.bailey-history-list{margin:0;padding:0;list-style-type:none}.bailey-history-row{border-radius:10px;flex-wrap:wrap;align-items:center;display:flex;position:relative}.bailey-history-row+.bailey-history-row{margin-top:calc(var(--spacing) * .5)}.bailey-history-row:not(.bailey-history-row-active):hover{background-color:var(--color-gray-100)}.bailey-history-row-active{box-shadow:inset 3px 0 0 var(--color-bailey-accent,#4f46e5);background-color:#4f46e514}.bailey-history-select{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;gap:calc(var(--spacing) * .5);--tw-border-style:none;min-width:0;padding-block:calc(var(--spacing) * 2.5);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);text-align:left;color:var(--color-bailey-text);background-color:#0000;border-style:none;border-radius:10px;flex-direction:column;flex:1;font-family:inherit;display:flex}.bailey-history-select:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-select:disabled{cursor:default;opacity:.6}.bailey-history-row-title{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);overflow:hidden}.bailey-history-meta{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-history-meta>span+.bailey-history-count:before{content:\"·\";margin-right:.375rem}.bailey-history-current{--tw-font-weight:var(--font-weight-semibold);font-size:11px;font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-history-delete{margin-right:var(--spacing)}.bailey-history-row-confirming{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:var(--color-red-50)}.bailey-history-confirm{align-items:center;gap:calc(var(--spacing) * 2);min-width:0;padding-block:calc(var(--spacing) * 2);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);flex-wrap:wrap;flex:1;display:flex}.bailey-history-confirm-question{--tw-font-weight:var(--font-weight-semibold);min-width:7.5rem;font-size:13px;font-weight:var(--font-weight-semibold);flex:1}.bailey-history-confirm-title{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);flex-basis:100%;overflow:hidden}.bailey-history-row-failed{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:#fff7f7}.bailey-history-row-error{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-bottom:calc(var(--spacing) * 2.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;flex-basis:100%;display:flex}.bailey-history-state{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 6);padding-block:calc(var(--spacing) * 12);text-align:center;color:var(--color-bailey-text-secondary);flex-direction:column;font-size:13px;display:flex}.bailey-history-state strong{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-history-state-icon{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);color:var(--color-gray-400)}.bailey-history-state-error .bailey-history-state-icon{color:var(--color-bailey-error)}.bailey-history-more{padding-top:calc(var(--spacing) * 2.5);padding-bottom:calc(var(--spacing) * 1.5);justify-content:center;display:flex}.bailey-history-inline-error{justify-content:center;align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;display:flex}.bailey-history-status{min-height:calc(var(--spacing) * 9);align-items:center;gap:calc(var(--spacing) * 2);border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-history-skeleton{margin-inline:var(--spacing);margin-bottom:calc(var(--spacing) * 1.5);background:linear-gradient(90deg,#f1f1f4 25%,#e6e6ec 50%,#f1f1f4 75%) 0 0/200% 100%;border-radius:10px;height:52px;animation:1.3s infinite bailey-history-shimmer}.bailey-history-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent,#4f46e5);border-radius:2147483647px;animation:.8s linear infinite bailey-history-rotate;display:inline-block}@keyframes bailey-history-shimmer{to{background-position:-200% 0}}@keyframes bailey-history-rotate{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.bailey-history-skeleton,.bailey-history-spinner{animation:none}}@container (width<=340px){.bailey-history-new-chat{width:calc(var(--spacing) * 11);padding-inline:0}.bailey-history-new-chat-text,.bailey-history-count{display:none}}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}@keyframes spin{to{transform:rotate(360deg)}}", dt = r(void 0), ft = /:root\s*,\s*:host\s*\{/, pt = ".bailey-chat-panel{";
1498
- function mt(e) {
1499
- let t = e.match(new RegExp(ft, "g"))?.length ?? 0;
1517
+ var ft = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0;--tw-outline-style:solid}}}@layer theme{:root,:host{--font-sans:\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#fff;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff;--color-bailey-page-bg:#eceef4;--color-bailey-heart:#16a34a}}@layer utilities;.bailey-chat-panel{box-sizing:border-box;background-color:var(--color-bailey-page-bg);height:100%;padding:calc(var(--spacing) * 3);font-family:var(--font-sans);flex-direction:column;display:flex;position:relative}.bailey-chat-panel-inner{width:100%;min-height:0;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;flex:1;margin-inline:auto;display:flex;overflow-y:auto}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 4);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-message{flex-direction:column;align-items:flex-end;max-width:75%;display:flex}.bailey-message-meta{margin-bottom:var(--spacing);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-message-meta-name{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-text)}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:100%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-tool-result-image{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);max-width:100%;height:auto;display:block}.bailey-mcp-app-frame{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:0;width:100%;height:480px;display:block}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);flex-wrap:wrap;display:flex}.bailey-empty-state{text-align:center;height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-suggestions{gap:calc(var(--spacing) * 3);padding:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-suggestions-title{padding-inline:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text)}.bailey-suggestion-card{cursor:pointer;appearance:none;justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-2xl);--tw-border-style:none;background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 3);text-align:left;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-style:none;display:flex}@media (hover:hover){.bailey-suggestion-card:hover{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.bailey-suggestion-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-text-secondary);flex-shrink:0}.bailey-privacy-note{border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 4);padding-top:calc(var(--spacing) * 3);padding-bottom:var(--spacing);text-align:center;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-privacy-note a{color:var(--color-bailey-text-secondary);text-decoration-line:underline}.bailey-tool-steps-live{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-activity-line{align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-activity-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-accent);flex-shrink:0}.bailey-step-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;flex-shrink:0}@media (prefers-reduced-motion:no-preference){.bailey-step-spinner{animation:var(--animate-spin)}}.bailey-tool-steps-summary{margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary)}.bailey-tool-steps-summary>summary{cursor:pointer;-webkit-user-select:none;user-select:none}.bailey-tool-steps-list{margin:0;margin-top:var(--spacing);gap:var(--spacing);flex-direction:column;padding:0;list-style-type:none;display:flex}.bailey-tool-step{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-tool-step-failed{color:var(--color-bailey-error)}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-error);background-color:#0000;border-style:none}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-area{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);min-width:0;padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;flex:1;display:flex}.bailey-input-row:focus-within{border-color:var(--color-bailey-accent)}.bailey-input{--tw-border-style:none;min-width:0;padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;background-color:#0000;border-style:none;outline-style:none;flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{cursor:pointer;appearance:none;background-color:#0000;border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}:is(.bailey-send-button,.bailey-stop-button):disabled{cursor:default;opacity:.4}.bailey-send-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-heart);border-style:none}@media (hover:hover){.bailey-send-button:hover{background-color:#16a34a1a}@supports (color:color-mix(in lab, red, red)){.bailey-send-button:hover{background-color:color-mix(in oklab, var(--color-bailey-heart) 10%, transparent)}}}.bailey-send-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-stop-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-copy-button{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-copy-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-copy-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-copy-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-tooltip-content{padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-menu-button{height:calc(var(--spacing) * 13);width:calc(var(--spacing) * 13);cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-menu-button:hover{background-color:var(--color-gray-50)}}.bailey-menu-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-menu-content{z-index:50;min-width:calc(var(--spacing) * 44);border-radius:var(--radius-2xl);background-color:var(--color-white);padding-block:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-black);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);font-family:var(--font-sans,\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif)}.bailey-menu-item{cursor:pointer;align-items:center;gap:calc(var(--spacing) * 3);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;outline-style:none;display:flex}.bailey-menu-item[data-highlighted]{background-color:var(--color-gray-100)}.bailey-menu-item-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-gray-600)}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-trace-toggle:hover{text-decoration-line:underline}}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}@media (hover:hover){.bailey-trace-copy-button:hover{text-decoration-line:none}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-feedback{align-items:center;gap:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);flex-wrap:wrap;display:flex}.bailey-message-actions>.bailey-feedback{display:contents}.bailey-feedback-thumbs{margin-left:var(--spacing);align-items:center;gap:calc(var(--spacing) * .5);border-left-style:var(--tw-border-style);border-left-width:1px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 2);display:flex}.bailey-feedback-thumb{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-feedback-thumb:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-feedback-thumb:hover{color:var(--color-bailey-text)}}.bailey-feedback-thumb:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-thumb:disabled{cursor:default;opacity:.5}.bailey-feedback-thumb[aria-pressed=true]{background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-thumb[aria-pressed=true]{color:var(--color-bailey-accent)}.bailey-feedback-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-feedback-status{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:inline-flex}.bailey-feedback-status:empty{display:none}.bailey-feedback-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);animation:var(--animate-spin);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;display:inline-block}.bailey-feedback-link{cursor:pointer;appearance:none;--tw-border-style:none;padding-inline:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-feedback-link:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-feedback-form{margin-top:calc(var(--spacing) * 2);box-sizing:border-box;border-radius:var(--radius-xl);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding:calc(var(--spacing) * 3);flex-basis:100%}.bailey-feedback-reasons{margin:0;margin-bottom:calc(var(--spacing) * 2);--tw-border-style:none;border-style:none;min-width:0;padding:0}.bailey-feedback-legend{margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text);padding:0;display:block}.bailey-feedback-chips{gap:calc(var(--spacing) * 1.5);flex-wrap:wrap;display:flex}.bailey-feedback-chip{cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text);border-radius:2147483647px}.bailey-feedback-chip:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-chip:disabled{cursor:default;opacity:.5}.bailey-feedback-chip[aria-pressed=true]{border-color:var(--color-bailey-accent);background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-chip[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-chip[aria-pressed=true]{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-feedback-textarea{box-sizing:border-box;min-height:calc(var(--spacing) * 18);resize:vertical;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding-inline:calc(var(--spacing) * 2.5);padding-block:calc(var(--spacing) * 2);font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);display:block}.bailey-feedback-textarea:disabled{opacity:.5}.bailey-feedback-meta{margin-top:calc(var(--spacing) * 1.5);justify-content:space-between;align-items:flex-start;gap:calc(var(--spacing) * 3);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-feedback-buttons{margin-top:calc(var(--spacing) * 2.5);justify-content:flex-end;gap:calc(var(--spacing) * 2);display:flex}.bailey-feedback-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-feedback-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-button:disabled{cursor:default;opacity:.5}.bailey-feedback-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-load-earlier{align-items:center;gap:var(--spacing);padding-bottom:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-load-earlier-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-load-earlier-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-load-earlier-button:disabled{cursor:default;opacity:.5}.bailey-load-earlier-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-history-drawer{z-index:10;background-color:var(--color-bailey-surface);font-family:var(--font-sans);color:var(--color-bailey-text);border-radius:14px;flex-direction:column;display:flex;position:absolute;inset:0;overflow:hidden;container-type:inline-size}.bailey-history-header{align-items:center;gap:calc(var(--spacing) * 2);border-bottom-style:var(--tw-border-style);border-bottom-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);display:flex}.bailey-history-heading{text-overflow:ellipsis;white-space:nowrap;--tw-font-weight:var(--font-weight-semibold);min-width:0;font-size:15px;font-weight:var(--font-weight-semibold);--tw-outline-style:none;outline-style:none;flex:1;margin:0;overflow:hidden}.bailey-history-icon-button{height:calc(var(--spacing) * 11);width:calc(var(--spacing) * 11);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;flex:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-icon-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-history-icon-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-history-icon-button:hover{color:var(--color-bailey-text)}}.bailey-history-icon-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-icon-button:disabled{cursor:default;opacity:.5}.bailey-history-icon{width:18px;height:18px}.bailey-history-icon-small{height:calc(var(--spacing) * 3.5);width:calc(var(--spacing) * 3.5);flex:none}.bailey-history-button{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;justify-content:center;align-items:center;gap:calc(var(--spacing) * 1.5);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 1.5);white-space:nowrap;color:var(--color-bailey-text);font-size:13px;display:inline-flex}.bailey-history-button:focus-visible{outline-style:var(--tw-outline-style);outline-offset:2px;outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-button:disabled{cursor:default;opacity:.5}.bailey-history-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-danger{border-color:var(--color-bailey-error);background-color:var(--color-bailey-error);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-small{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-history-body{padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);flex:1;overflow-y:auto}.bailey-history-list{margin:0;padding:0;list-style-type:none}.bailey-history-row{border-radius:10px;flex-wrap:wrap;align-items:center;display:flex;position:relative}.bailey-history-row+.bailey-history-row{margin-top:calc(var(--spacing) * .5)}.bailey-history-row:not(.bailey-history-row-active):hover{background-color:var(--color-gray-100)}.bailey-history-row-active{box-shadow:inset 3px 0 0 var(--color-bailey-accent,#4f46e5);background-color:#4f46e514}.bailey-history-select{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;gap:calc(var(--spacing) * .5);--tw-border-style:none;min-width:0;padding-block:calc(var(--spacing) * 2.5);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);text-align:left;color:var(--color-bailey-text);background-color:#0000;border-style:none;border-radius:10px;flex-direction:column;flex:1;font-family:inherit;display:flex}.bailey-history-select:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-select:disabled{cursor:default;opacity:.6}.bailey-history-row-title{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);overflow:hidden}.bailey-history-meta{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-history-meta>span+.bailey-history-count:before{content:\"·\";margin-right:.375rem}.bailey-history-current{--tw-font-weight:var(--font-weight-semibold);font-size:11px;font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-history-delete{margin-right:var(--spacing)}.bailey-history-row-confirming{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:var(--color-red-50)}.bailey-history-confirm{align-items:center;gap:calc(var(--spacing) * 2);min-width:0;padding-block:calc(var(--spacing) * 2);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);flex-wrap:wrap;flex:1;display:flex}.bailey-history-confirm-question{--tw-font-weight:var(--font-weight-semibold);min-width:7.5rem;font-size:13px;font-weight:var(--font-weight-semibold);flex:1}.bailey-history-confirm-title{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);flex-basis:100%;overflow:hidden}.bailey-history-row-failed{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:#fff7f7}.bailey-history-row-error{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-bottom:calc(var(--spacing) * 2.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;flex-basis:100%;display:flex}.bailey-history-state{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 6);padding-block:calc(var(--spacing) * 12);text-align:center;color:var(--color-bailey-text-secondary);flex-direction:column;font-size:13px;display:flex}.bailey-history-state strong{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-history-state-icon{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);color:var(--color-gray-400)}.bailey-history-state-error .bailey-history-state-icon{color:var(--color-bailey-error)}.bailey-history-more{padding-top:calc(var(--spacing) * 2.5);padding-bottom:calc(var(--spacing) * 1.5);justify-content:center;display:flex}.bailey-history-inline-error{justify-content:center;align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;display:flex}.bailey-history-status{min-height:calc(var(--spacing) * 9);align-items:center;gap:calc(var(--spacing) * 2);border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3.5);padding-block:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-history-skeleton{margin-inline:var(--spacing);margin-bottom:calc(var(--spacing) * 1.5);background:linear-gradient(90deg,#f1f1f4 25%,#e6e6ec 50%,#f1f1f4 75%) 0 0/200% 100%;border-radius:10px;height:52px;animation:1.3s infinite bailey-history-shimmer}.bailey-history-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent,#4f46e5);border-radius:2147483647px;animation:.8s linear infinite bailey-history-rotate;display:inline-block}@keyframes bailey-history-shimmer{to{background-position:-200% 0}}@keyframes bailey-history-rotate{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.bailey-history-skeleton,.bailey-history-spinner{animation:none}}@container (width<=340px){.bailey-history-new-chat{width:calc(var(--spacing) * 11);padding-inline:0}.bailey-history-new-chat-text,.bailey-history-count{display:none}}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}@keyframes spin{to{transform:rotate(360deg)}}", pt = r(void 0), mt = /:root\s*,\s*:host\s*\{/, ht = ".bailey-chat-panel{";
1518
+ function gt(e) {
1519
+ let t = e.match(new RegExp(mt, "g"))?.length ?? 0;
1500
1520
  if (t !== 1) throw Error(`Expected exactly one ":root, :host {" rule in the compiled styles.css, found ${t}. Tailwind likely changed how @theme compiles — update this rewrite (and its sibling, scripts/scope-theme-vars.js) before shipping.`);
1501
- return e.replace(ft, pt);
1521
+ return e.replace(mt, ht);
1502
1522
  }
1503
- var ht = mt(ut), gt = "data-source", _t = "baileyai-chat-ui", vt = /* @__PURE__ */ new WeakMap();
1504
- function yt(e) {
1523
+ var _t = gt(ft), vt = "data-source", yt = "baileyai-chat-ui", bt = /* @__PURE__ */ new WeakMap();
1524
+ function xt(e) {
1505
1525
  let t = e.getRootNode();
1506
1526
  return t instanceof ShadowRoot ? t : document;
1507
1527
  }
1508
- function bt(e) {
1509
- let t = e instanceof ShadowRoot ? e : document.head, n = vt.get(e) ?? 0;
1510
- if (n === 0 && !t.querySelector(`style[${gt}="${_t}"]`)) {
1528
+ function St(e) {
1529
+ let t = e instanceof ShadowRoot ? e : document.head, n = bt.get(e) ?? 0;
1530
+ if (n === 0 && !t.querySelector(`style[${vt}="${yt}"]`)) {
1511
1531
  let e = document.createElement("style");
1512
- e.setAttribute(gt, _t), e.textContent = ht, t.appendChild(e);
1532
+ e.setAttribute(vt, yt), e.textContent = _t, t.appendChild(e);
1513
1533
  }
1514
- return vt.set(e, n + 1), () => {
1515
- let n = (vt.get(e) ?? 1) - 1;
1516
- n <= 0 ? (vt.delete(e), t.querySelector(`style[${gt}="${_t}"]`)?.remove()) : vt.set(e, n);
1534
+ return bt.set(e, n + 1), () => {
1535
+ let n = (bt.get(e) ?? 1) - 1;
1536
+ n <= 0 ? (bt.delete(e), t.querySelector(`style[${vt}="${yt}"]`)?.remove()) : bt.set(e, n);
1517
1537
  };
1518
1538
  }
1519
- function xt(e, t = !1) {
1539
+ function Ct(e, t = !1) {
1520
1540
  let [n, r] = f(null);
1521
1541
  return l(() => {
1522
1542
  if (t) return;
1523
1543
  let n = e.current;
1524
1544
  if (!n) return;
1525
- let i = yt(n);
1526
- return r(i), bt(i);
1545
+ let i = xt(n);
1546
+ return r(i), St(i);
1527
1547
  }, [t, e]), n;
1528
1548
  }
1529
- function St(e) {
1530
- let t = o(dt), n = t !== void 0, r = xt(e, n);
1549
+ function wt(e) {
1550
+ let t = o(pt), n = t !== void 0, r = Ct(e, n);
1531
1551
  return n ? t : r;
1532
1552
  }
1533
1553
  //#endregion
1534
1554
  //#region src/ui/markdown.tsx
1535
- function Ct({ renderTable: t, renderChart: n } = {}) {
1555
+ function Tt({ renderTable: t, renderChart: n } = {}) {
1536
1556
  return {
1537
1557
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ v(_, { children: n }) : /* @__PURE__ */ v("a", {
1538
1558
  href: t,
@@ -1541,8 +1561,8 @@ function Ct({ renderTable: t, renderChart: n } = {}) {
1541
1561
  children: n
1542
1562
  }),
1543
1563
  table: ({ node: n, children: r }) => {
1544
- let i = n && Le(n);
1545
- if (i && Re(i.rows) && t) {
1564
+ let i = n && ze(n);
1565
+ if (i && Be(i.rows) && t) {
1546
1566
  let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
1547
1567
  return /* @__PURE__ */ v(_, { children: t({
1548
1568
  headers: i.headers,
@@ -1554,7 +1574,7 @@ function Ct({ renderTable: t, renderChart: n } = {}) {
1554
1574
  pre: ({ children: e }) => {
1555
1575
  let t = (Array.isArray(e) ? e[0] : e)?.props;
1556
1576
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
1557
- let e = t?.children, r = Ke(Array.isArray(e) ? e.join("") : String(e ?? ""));
1577
+ let e = t?.children, r = Je(Array.isArray(e) ? e.join("") : String(e ?? ""));
1558
1578
  if (r) return /* @__PURE__ */ v(_, { children: n(r) });
1559
1579
  }
1560
1580
  return /* @__PURE__ */ v("pre", { children: e });
@@ -1563,7 +1583,7 @@ function Ct({ renderTable: t, renderChart: n } = {}) {
1563
1583
  }
1564
1584
  //#endregion
1565
1585
  //#region src/ui/icons.tsx
1566
- function wt({ className: e }) {
1586
+ function Et({ className: e }) {
1567
1587
  return /* @__PURE__ */ v("svg", {
1568
1588
  viewBox: "0 0 24 24",
1569
1589
  fill: "currentColor",
@@ -1572,7 +1592,7 @@ function wt({ className: e }) {
1572
1592
  children: /* @__PURE__ */ v("path", { d: "M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z" })
1573
1593
  });
1574
1594
  }
1575
- function Tt({ className: e }) {
1595
+ function Dt({ className: e }) {
1576
1596
  return /* @__PURE__ */ v("svg", {
1577
1597
  viewBox: "0 0 24 24",
1578
1598
  fill: "currentColor",
@@ -1587,7 +1607,7 @@ function Tt({ className: e }) {
1587
1607
  })
1588
1608
  });
1589
1609
  }
1590
- function Et({ className: e }) {
1610
+ function Ot({ className: e }) {
1591
1611
  return /* @__PURE__ */ y("svg", {
1592
1612
  viewBox: "0 0 24 24",
1593
1613
  fill: "none",
@@ -1600,7 +1620,7 @@ function Et({ className: e }) {
1600
1620
  children: [/* @__PURE__ */ v("path", { d: "M7 17 17 7" }), /* @__PURE__ */ v("path", { d: "M9 7h8v8" })]
1601
1621
  });
1602
1622
  }
1603
- function Dt({ className: e }) {
1623
+ function kt({ className: e }) {
1604
1624
  return /* @__PURE__ */ y("svg", {
1605
1625
  viewBox: "0 0 24 24",
1606
1626
  fill: "none",
@@ -1619,7 +1639,7 @@ function Dt({ className: e }) {
1619
1639
  }), /* @__PURE__ */ v("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
1620
1640
  });
1621
1641
  }
1622
- function Ot({ className: e }) {
1642
+ function At({ className: e }) {
1623
1643
  return /* @__PURE__ */ v("svg", {
1624
1644
  viewBox: "0 0 24 24",
1625
1645
  fill: "none",
@@ -1632,7 +1652,7 @@ function Ot({ className: e }) {
1632
1652
  children: /* @__PURE__ */ v("path", { d: "M5 12.5 9.5 17 19 7" })
1633
1653
  });
1634
1654
  }
1635
- function kt({ className: e }) {
1655
+ function jt({ className: e }) {
1636
1656
  return /* @__PURE__ */ v("svg", {
1637
1657
  viewBox: "0 0 24 24",
1638
1658
  fill: "none",
@@ -1645,7 +1665,7 @@ function kt({ className: e }) {
1645
1665
  children: /* @__PURE__ */ v("path", { d: "m22.7 13.5-2-2-2 2M21 12a9 9 0 1 1-1.245-4.57M12 7v5l3 2" })
1646
1666
  });
1647
1667
  }
1648
- function At({ className: e }) {
1668
+ function Mt({ className: e }) {
1649
1669
  return /* @__PURE__ */ y("svg", {
1650
1670
  viewBox: "0 0 24 24",
1651
1671
  fill: "none",
@@ -1662,7 +1682,7 @@ function At({ className: e }) {
1662
1682
  }), /* @__PURE__ */ v("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
1663
1683
  });
1664
1684
  }
1665
- function jt({ className: e }) {
1685
+ function Nt({ className: e }) {
1666
1686
  return /* @__PURE__ */ y("svg", {
1667
1687
  viewBox: "0 0 24 24",
1668
1688
  fill: "currentColor",
@@ -1687,7 +1707,7 @@ function jt({ className: e }) {
1687
1707
  ]
1688
1708
  });
1689
1709
  }
1690
- function Mt({ className: e }) {
1710
+ function Pt({ className: e }) {
1691
1711
  return /* @__PURE__ */ v("svg", {
1692
1712
  viewBox: "0 0 24 24",
1693
1713
  fill: "none",
@@ -1700,8 +1720,8 @@ function Mt({ className: e }) {
1700
1720
  children: /* @__PURE__ */ v("path", { d: "M12 5v14M5 12h14" })
1701
1721
  });
1702
1722
  }
1703
- var Nt = "M7 11v9H4v-9h3zm0 0 4-8c1.7 0 2.7 1.3 2.4 3L13 9h5.5a2 2 0 0 1 2 2.4l-1.3 6.8A2 2 0 0 1 17.2 20H7", Pt = "M17 13V4h3v9h-3zm0 0-4 8c-1.7 0-2.7-1.3-2.4-3L11 15H5.5a2 2 0 0 1-2-2.4l1.3-6.8A2 2 0 0 1 6.8 4H17";
1704
- function Ft({ className: e, filled: t = !1 }) {
1723
+ var Ft = "M7 11v9H4v-9h3zm0 0 4-8c1.7 0 2.7 1.3 2.4 3L13 9h5.5a2 2 0 0 1 2 2.4l-1.3 6.8A2 2 0 0 1 17.2 20H7", It = "M17 13V4h3v9h-3zm0 0-4 8c-1.7 0-2.7-1.3-2.4-3L11 15H5.5a2 2 0 0 1-2-2.4l1.3-6.8A2 2 0 0 1 6.8 4H17";
1724
+ function Lt({ className: e, filled: t = !1 }) {
1705
1725
  return /* @__PURE__ */ v("svg", {
1706
1726
  viewBox: "0 0 24 24",
1707
1727
  fill: t ? "currentColor" : "none",
@@ -1710,10 +1730,10 @@ function Ft({ className: e, filled: t = !1 }) {
1710
1730
  strokeLinejoin: "round",
1711
1731
  className: e,
1712
1732
  "aria-hidden": "true",
1713
- children: /* @__PURE__ */ v("path", { d: Nt })
1733
+ children: /* @__PURE__ */ v("path", { d: Ft })
1714
1734
  });
1715
1735
  }
1716
- function It({ className: e, filled: t = !1 }) {
1736
+ function Rt({ className: e, filled: t = !1 }) {
1717
1737
  return /* @__PURE__ */ v("svg", {
1718
1738
  viewBox: "0 0 24 24",
1719
1739
  fill: t ? "currentColor" : "none",
@@ -1722,10 +1742,10 @@ function It({ className: e, filled: t = !1 }) {
1722
1742
  strokeLinejoin: "round",
1723
1743
  className: e,
1724
1744
  "aria-hidden": "true",
1725
- children: /* @__PURE__ */ v("path", { d: Pt })
1745
+ children: /* @__PURE__ */ v("path", { d: It })
1726
1746
  });
1727
1747
  }
1728
- function Lt({ className: e }) {
1748
+ function zt({ className: e }) {
1729
1749
  return /* @__PURE__ */ v("svg", {
1730
1750
  viewBox: "0 0 24 24",
1731
1751
  fill: "none",
@@ -1738,7 +1758,7 @@ function Lt({ className: e }) {
1738
1758
  children: /* @__PURE__ */ v("path", { d: "M15 6l-6 6 6 6" })
1739
1759
  });
1740
1760
  }
1741
- function Rt({ className: e }) {
1761
+ function Bt({ className: e }) {
1742
1762
  return /* @__PURE__ */ v("svg", {
1743
1763
  viewBox: "0 0 24 24",
1744
1764
  fill: "none",
@@ -1751,7 +1771,7 @@ function Rt({ className: e }) {
1751
1771
  children: /* @__PURE__ */ v("path", { d: "M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3" })
1752
1772
  });
1753
1773
  }
1754
- function zt({ className: e }) {
1774
+ function Vt({ className: e }) {
1755
1775
  return /* @__PURE__ */ y("svg", {
1756
1776
  viewBox: "0 0 24 24",
1757
1777
  fill: "none",
@@ -1770,9 +1790,9 @@ function zt({ className: e }) {
1770
1790
  }
1771
1791
  //#endregion
1772
1792
  //#region src/ui/CopyMarkdownButton.tsx
1773
- var Bt = 1500;
1774
- function Vt({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
1775
- let [a, o] = f(!1), [c, l] = f(!1), u = d(null), p = d(null), m = St(p);
1793
+ var Ht = 1500;
1794
+ function Ut({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
1795
+ let [a, o] = f(!1), [c, l] = f(!1), u = d(null), p = d(null), m = wt(p);
1776
1796
  return s(() => () => {
1777
1797
  u.current !== null && clearTimeout(u.current);
1778
1798
  }, []), /* @__PURE__ */ v(g.Provider, {
@@ -1791,11 +1811,11 @@ function Vt({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
1791
1811
  } catch {
1792
1812
  return;
1793
1813
  }
1794
- o(!0), u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => o(!1), Bt);
1814
+ o(!0), u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => o(!1), Ht);
1795
1815
  },
1796
1816
  "aria-label": n,
1797
1817
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
1798
- children: v(a ? Ot : Dt, { className: "bailey-copy-icon" })
1818
+ children: v(a ? At : kt, { className: "bailey-copy-icon" })
1799
1819
  })
1800
1820
  }), /* @__PURE__ */ v(g.Portal, {
1801
1821
  container: m instanceof ShadowRoot ? m : void 0,
@@ -1810,20 +1830,20 @@ function Vt({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
1810
1830
  }
1811
1831
  //#endregion
1812
1832
  //#region src/ui/BaileyTracePanel.tsx
1813
- async function Ht(e) {
1833
+ async function Wt(e) {
1814
1834
  try {
1815
1835
  await navigator.clipboard.writeText(e);
1816
1836
  } catch {}
1817
1837
  }
1818
- function Ut({ text: e, label: t = "Copy" }) {
1838
+ function Gt({ text: e, label: t = "Copy" }) {
1819
1839
  return /* @__PURE__ */ v("button", {
1820
1840
  type: "button",
1821
- onClick: () => Ht(e),
1841
+ onClick: () => Wt(e),
1822
1842
  className: "bailey-trace-copy-button",
1823
1843
  children: t
1824
1844
  });
1825
1845
  }
1826
- function Wt(e) {
1846
+ function Kt(e) {
1827
1847
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
1828
1848
  switch (e.kind) {
1829
1849
  case "tool_start":
@@ -1834,7 +1854,7 @@ function Wt(e) {
1834
1854
  default: return "bailey-trace-chip bailey-trace-chip-default";
1835
1855
  }
1836
1856
  }
1837
- function Gt({ label: e, content: t, copyable: n }) {
1857
+ function qt({ label: e, content: t, copyable: n }) {
1838
1858
  return /* @__PURE__ */ y("details", {
1839
1859
  className: "bailey-trace-disclosure",
1840
1860
  children: [
@@ -1844,7 +1864,7 @@ function Gt({ label: e, content: t, copyable: n }) {
1844
1864
  }),
1845
1865
  n && /* @__PURE__ */ v("div", {
1846
1866
  className: "bailey-trace-disclosure-actions",
1847
- children: /* @__PURE__ */ v(Ut, { text: t })
1867
+ children: /* @__PURE__ */ v(Gt, { text: t })
1848
1868
  }),
1849
1869
  /* @__PURE__ */ v("pre", {
1850
1870
  className: "bailey-trace-disclosure-content",
@@ -1853,7 +1873,7 @@ function Gt({ label: e, content: t, copyable: n }) {
1853
1873
  ]
1854
1874
  });
1855
1875
  }
1856
- function Kt({ row: e }) {
1876
+ function Jt({ row: e }) {
1857
1877
  return /* @__PURE__ */ y("div", {
1858
1878
  className: "bailey-trace-row",
1859
1879
  children: [
@@ -1867,10 +1887,10 @@ function Kt({ row: e }) {
1867
1887
  /* @__PURE__ */ v("span", {
1868
1888
  className: "bailey-trace-row-gap",
1869
1889
  title: "Time since the previous event",
1870
- children: rt(e.gapMs)
1890
+ children: at(e.gapMs)
1871
1891
  }),
1872
1892
  /* @__PURE__ */ v("span", {
1873
- className: Wt(e),
1893
+ className: Kt(e),
1874
1894
  children: e.label
1875
1895
  }),
1876
1896
  /* @__PURE__ */ v("span", {
@@ -1879,32 +1899,32 @@ function Kt({ row: e }) {
1879
1899
  })
1880
1900
  ]
1881
1901
  }),
1882
- e.argsDetail && /* @__PURE__ */ v(Gt, {
1902
+ e.argsDetail && /* @__PURE__ */ v(qt, {
1883
1903
  label: e.kind === "llm_call_start" ? "request" : "args",
1884
1904
  content: e.argsDetail
1885
1905
  }),
1886
- e.outputDetail && /* @__PURE__ */ v(Gt, {
1906
+ e.outputDetail && /* @__PURE__ */ v(qt, {
1887
1907
  label: e.kind === "llm_call_end" ? "response" : "output",
1888
1908
  content: e.outputDetail
1889
1909
  }),
1890
- e.structuredOutputDetail && /* @__PURE__ */ v(Gt, {
1910
+ e.structuredOutputDetail && /* @__PURE__ */ v(qt, {
1891
1911
  label: "structured output",
1892
1912
  content: e.structuredOutputDetail
1893
1913
  }),
1894
- e.rawDetail && /* @__PURE__ */ v(Gt, {
1914
+ e.rawDetail && /* @__PURE__ */ v(qt, {
1895
1915
  label: "raw",
1896
1916
  content: e.rawDetail
1897
1917
  })
1898
1918
  ]
1899
1919
  });
1900
1920
  }
1901
- function qt(e, t) {
1921
+ function Yt(e, t) {
1902
1922
  if (e.chunkCount === 0) return "Streamed: no chunks received";
1903
1923
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
1904
1924
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
1905
1925
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
1906
1926
  }
1907
- function Jt({ request: e }) {
1927
+ function Xt({ request: e }) {
1908
1928
  let t = u(() => JSON.stringify({
1909
1929
  model: e.model,
1910
1930
  instructions: e.systemPrompt,
@@ -1928,24 +1948,24 @@ function Jt({ request: e }) {
1928
1948
  }),
1929
1949
  /* @__PURE__ */ v("span", {
1930
1950
  className: "bailey-trace-request-meta",
1931
- children: qt(e.streamStats, e.sentAt)
1951
+ children: Yt(e.streamStats, e.sentAt)
1932
1952
  }),
1933
- /* @__PURE__ */ v(Gt, {
1953
+ /* @__PURE__ */ v(qt, {
1934
1954
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
1935
1955
  content: e.systemPrompt,
1936
1956
  copyable: !0
1937
1957
  }),
1938
- /* @__PURE__ */ v(Gt, {
1958
+ /* @__PURE__ */ v(qt, {
1939
1959
  label: `Messages (${e.messages.length})`,
1940
1960
  content: JSON.stringify(e.messages, null, 2),
1941
1961
  copyable: !0
1942
1962
  }),
1943
- e.response && /* @__PURE__ */ v(Gt, {
1963
+ e.response && /* @__PURE__ */ v(qt, {
1944
1964
  label: `Response (${e.response.content.length.toLocaleString()} chars)`,
1945
1965
  content: e.response.content,
1946
1966
  copyable: !0
1947
1967
  }),
1948
- /* @__PURE__ */ v(Gt, {
1968
+ /* @__PURE__ */ v(qt, {
1949
1969
  label: "Full payload (JSON)",
1950
1970
  content: t,
1951
1971
  copyable: !0
@@ -1953,14 +1973,14 @@ function Jt({ request: e }) {
1953
1973
  ]
1954
1974
  });
1955
1975
  }
1956
- function Yt({ events: e, lastRequest: t, onClear: n }) {
1957
- let r = u(() => it(e), [e]), i = u(() => ot(r), [r]), a = u(() => JSON.stringify(e, null, 2), [e]);
1976
+ function Zt({ events: e, lastRequest: t, onClear: n }) {
1977
+ let r = u(() => ot(e), [e]), i = u(() => ct(r), [r]), a = u(() => JSON.stringify(e, null, 2), [e]);
1958
1978
  return /* @__PURE__ */ y("div", {
1959
1979
  className: "bailey-trace-body",
1960
1980
  children: [
1961
1981
  /* @__PURE__ */ y("div", {
1962
1982
  className: "bailey-trace-actions-row",
1963
- children: [e.length > 0 && /* @__PURE__ */ v(Ut, {
1983
+ children: [e.length > 0 && /* @__PURE__ */ v(Gt, {
1964
1984
  text: a,
1965
1985
  label: "Copy trace as JSON"
1966
1986
  }), /* @__PURE__ */ v("button", {
@@ -1970,15 +1990,15 @@ function Yt({ events: e, lastRequest: t, onClear: n }) {
1970
1990
  children: "Clear"
1971
1991
  })]
1972
1992
  }),
1973
- t && /* @__PURE__ */ v(Jt, { request: t }),
1993
+ t && /* @__PURE__ */ v(Xt, { request: t }),
1974
1994
  /* @__PURE__ */ v("div", {
1975
1995
  className: "bailey-trace-rows",
1976
1996
  children: i.map((e, t) => {
1977
- if (e.type === "single") return /* @__PURE__ */ v(Kt, { row: e.row }, e.row.key);
1997
+ if (e.type === "single") return /* @__PURE__ */ v(Jt, { row: e.row }, e.row.key);
1978
1998
  let n = e.rows.filter((e) => e.isToolStart).length;
1979
1999
  if (n <= 1) return /* @__PURE__ */ v("div", {
1980
2000
  className: "bailey-trace-rows",
1981
- children: e.rows.map((e) => /* @__PURE__ */ v(Kt, { row: e }, e.key))
2001
+ children: e.rows.map((e) => /* @__PURE__ */ v(Jt, { row: e }, e.key))
1982
2002
  }, `group-${t}`);
1983
2003
  let r = e.rows.filter((e) => e.failed).length;
1984
2004
  return /* @__PURE__ */ y("details", {
@@ -2000,7 +2020,7 @@ function Yt({ events: e, lastRequest: t, onClear: n }) {
2000
2020
  ]
2001
2021
  }), /* @__PURE__ */ v("div", {
2002
2022
  className: "bailey-trace-rows",
2003
- children: e.rows.map((e) => /* @__PURE__ */ v(Kt, { row: e }, e.key))
2023
+ children: e.rows.map((e) => /* @__PURE__ */ v(Jt, { row: e }, e.key))
2004
2024
  })]
2005
2025
  }, `group-${t}`);
2006
2026
  })
@@ -2008,8 +2028,8 @@ function Yt({ events: e, lastRequest: t, onClear: n }) {
2008
2028
  ]
2009
2029
  });
2010
2030
  }
2011
- function Xt({ events: e, lastRequest: t, onClear: n }) {
2012
- let [r, i] = f(!1), a = u(() => st(e), [e]), o = u(() => at(e), [e]);
2031
+ function Qt({ events: e, lastRequest: t, onClear: n }) {
2032
+ let [r, i] = f(!1), a = u(() => lt(e), [e]), o = u(() => st(e), [e]);
2013
2033
  return e.length === 0 && !t ? null : /* @__PURE__ */ y("div", {
2014
2034
  className: "bailey-trace-panel",
2015
2035
  children: [/* @__PURE__ */ y("div", {
@@ -2030,7 +2050,7 @@ function Xt({ events: e, lastRequest: t, onClear: n }) {
2030
2050
  className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
2031
2051
  children: o
2032
2052
  })]
2033
- }), r && /* @__PURE__ */ v(Yt, {
2053
+ }), r && /* @__PURE__ */ v(Zt, {
2034
2054
  events: e,
2035
2055
  lastRequest: t,
2036
2056
  onClear: n
@@ -2039,7 +2059,7 @@ function Xt({ events: e, lastRequest: t, onClear: n }) {
2039
2059
  }
2040
2060
  //#endregion
2041
2061
  //#region src/ui/ToolResultImage.tsx
2042
- function Zt({ src: e, alt: n, className: r }) {
2062
+ function $t({ src: e, alt: n, className: r }) {
2043
2063
  return t(e) ? /* @__PURE__ */ v("img", {
2044
2064
  src: e,
2045
2065
  alt: n ?? "",
@@ -2049,21 +2069,21 @@ function Zt({ src: e, alt: n, className: r }) {
2049
2069
  }
2050
2070
  //#endregion
2051
2071
  //#region src/utils/safeMcpAppResource.ts
2052
- var Qt = /^ui:\/\//, $t = 2097152, en = /* @__PURE__ */ new Set([
2072
+ var en = /^ui:\/\//, tn = 2097152, nn = /* @__PURE__ */ new Set([
2053
2073
  "connectDomains",
2054
2074
  "resourceDomains",
2055
2075
  "frameDomains",
2056
2076
  "baseUriDomains"
2057
- ]), tn = /* @__PURE__ */ new Set([
2077
+ ]), rn = /* @__PURE__ */ new Set([
2058
2078
  "camera",
2059
2079
  "microphone",
2060
2080
  "geolocation",
2061
2081
  "clipboardWrite"
2062
- ]), nn = (e, t) => e === void 0 ? !0 : typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.keys(e).every((e) => t.has(e)), rn = (e) => !(!Qt.test(e.resourceUri) || typeof e.html != "string" || e.html.length === 0 || e.html.length > $t || !nn(e.csp, en) || !nn(e.permissions, tn));
2082
+ ]), an = (e, t) => e === void 0 ? !0 : typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.keys(e).every((e) => t.has(e)), on = (e) => !(!en.test(e.resourceUri) || typeof e.html != "string" || e.html.length === 0 || e.html.length > tn || !an(e.csp, nn) || !an(e.permissions, rn));
2063
2083
  //#endregion
2064
2084
  //#region src/ui/McpAppFrame.tsx
2065
- function an({ html: e, title: t, resourceUri: n, csp: r, permissions: i, className: a }) {
2066
- return rn({
2085
+ function sn({ html: e, title: t, resourceUri: n, csp: r, permissions: i, className: a }) {
2086
+ return on({
2067
2087
  html: e,
2068
2088
  resourceUri: n,
2069
2089
  csp: r,
@@ -2078,14 +2098,14 @@ function an({ html: e, title: t, resourceUri: n, csp: r, permissions: i, classNa
2078
2098
  }
2079
2099
  //#endregion
2080
2100
  //#region src/ui/BaileyToolSteps.tsx
2081
- function on({ toolName: e, resolveActivityIcon: t }) {
2101
+ function cn({ toolName: e, resolveActivityIcon: t }) {
2082
2102
  let n = t?.(e);
2083
2103
  return n === 0 || n && n !== !0 ? /* @__PURE__ */ v("span", {
2084
2104
  className: "bailey-activity-icon",
2085
2105
  children: n
2086
2106
  }) : null;
2087
2107
  }
2088
- function sn({ steps: e, resolveActivityIcon: t }) {
2108
+ function ln({ steps: e, resolveActivityIcon: t }) {
2089
2109
  let n = e.filter((e) => e.status === "running");
2090
2110
  return n.length === 0 ? null : /* @__PURE__ */ v("div", {
2091
2111
  className: "bailey-tool-steps-live",
@@ -2094,7 +2114,7 @@ function sn({ steps: e, resolveActivityIcon: t }) {
2094
2114
  children: n.map((e) => /* @__PURE__ */ y("div", {
2095
2115
  className: "bailey-activity-line",
2096
2116
  children: [
2097
- /* @__PURE__ */ v(on, {
2117
+ /* @__PURE__ */ v(cn, {
2098
2118
  toolName: e.toolName,
2099
2119
  resolveActivityIcon: t
2100
2120
  }),
@@ -2107,7 +2127,7 @@ function sn({ steps: e, resolveActivityIcon: t }) {
2107
2127
  }, e.key))
2108
2128
  });
2109
2129
  }
2110
- function cn({ steps: e, labels: t, resolveActivityIcon: n }) {
2130
+ function un({ steps: e, labels: t, resolveActivityIcon: n }) {
2111
2131
  if (e.length === 0) return null;
2112
2132
  let r = e.filter((e) => e.status === "failed").length, i = e.length === 1 ? t.toolStepsSummaryOne : t.toolStepsSummaryMany.replace("{count}", String(e.length)), a = r > 0 ? `${i}${t.toolStepsFailedSuffix.replace("{failed}", String(r))}` : i;
2113
2133
  return /* @__PURE__ */ y("details", {
@@ -2117,7 +2137,7 @@ function cn({ steps: e, labels: t, resolveActivityIcon: n }) {
2117
2137
  children: e.map((e) => /* @__PURE__ */ y("li", {
2118
2138
  className: "bailey-tool-step",
2119
2139
  children: [
2120
- /* @__PURE__ */ v(on, {
2140
+ /* @__PURE__ */ v(cn, {
2121
2141
  toolName: e.toolName,
2122
2142
  resolveActivityIcon: n
2123
2143
  }),
@@ -2135,29 +2155,29 @@ function cn({ steps: e, labels: t, resolveActivityIcon: n }) {
2135
2155
  }
2136
2156
  //#endregion
2137
2157
  //#region src/utils/relativeTime.ts
2138
- var ln = /(Z|[+-]\d{2}:?\d{2})$/i, un = 60, dn = 3600, fn = 24 * dn, pn = 30 * fn * 1e3;
2139
- function mn(e) {
2140
- return e ? Date.parse(ln.test(e) ? e : `${e}Z`) : NaN;
2158
+ var dn = /(Z|[+-]\d{2}:?\d{2})$/i, fn = 60, pn = 3600, mn = 24 * pn, hn = 30 * mn * 1e3;
2159
+ function gn(e) {
2160
+ return e ? Date.parse(dn.test(e) ? e : `${e}Z`) : NaN;
2141
2161
  }
2142
- function hn(e) {
2143
- let t = mn(e.iso);
2162
+ function _n(e) {
2163
+ let t = gn(e.iso);
2144
2164
  if (Number.isNaN(t)) return "";
2145
2165
  let n = e.now ?? Date.now(), r = Math.max(0, n - t);
2146
2166
  if (typeof Intl > "u" || typeof Intl.RelativeTimeFormat != "function") return e.justNowText ?? "";
2147
- if (r >= pn) return new Intl.DateTimeFormat(e.locale, { dateStyle: "medium" }).format(t);
2167
+ if (r >= hn) return new Intl.DateTimeFormat(e.locale, { dateStyle: "medium" }).format(t);
2148
2168
  let i = r / 1e3, a = new Intl.RelativeTimeFormat(e.locale, { numeric: "auto" });
2149
- return i < un ? a.format(0, "second") : i < dn ? a.format(-Math.floor(i / un), "minute") : i < fn ? a.format(-Math.floor(i / dn), "hour") : a.format(-Math.floor(i / fn), "day");
2169
+ return i < fn ? a.format(0, "second") : i < pn ? a.format(-Math.floor(i / fn), "minute") : i < mn ? a.format(-Math.floor(i / pn), "hour") : a.format(-Math.floor(i / mn), "day");
2150
2170
  }
2151
2171
  //#endregion
2152
2172
  //#region src/ui/BaileyHistoryDrawer.tsx
2153
- function gn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o }) {
2154
- let s = me({
2173
+ function vn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o }) {
2174
+ let s = pe({
2155
2175
  client: e,
2156
2176
  pageSize: t
2157
2177
  }), { loadConversation: c, newChat: l } = n, u = a((e) => c ? c(e) : Promise.reject(/* @__PURE__ */ Error("no loadConversation")), [c]), d = a(() => {
2158
2178
  l(), o({ restoreFocusTo: "input" });
2159
2179
  }, [l, o]);
2160
- return /* @__PURE__ */ v(yn, {
2180
+ return /* @__PURE__ */ v(xn, {
2161
2181
  conversations: s,
2162
2182
  activeConversationId: n.conversationId,
2163
2183
  selectStatus: n.historyStatus,
@@ -2169,15 +2189,15 @@ function gn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o
2169
2189
  locale: i
2170
2190
  });
2171
2191
  }
2172
- var _n = (e, t) => Object.entries(t).reduce((e, [t, n]) => e.split(`{${t}}`).join(String(n)), e), vn = (e) => !e || e.kind !== "http" ? !1 : e.status === 401 || e.status === 403;
2173
- function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSelect: r, onActiveDeleted: i, onNewChat: a, onClose: o, labels: l, locale: u, now: p }) {
2174
- let { conversations: m, status: h, error: g, hasMore: b, refresh: ee, loadMore: x, remove: S } = e, C = c(), w = c(), T = d(null), E = d(null), D = d(null), O = d(/* @__PURE__ */ new Map()), k = d(/* @__PURE__ */ new Map()), A = d(null), j = d(null), [M, N] = f(null), [te, P] = f(null), [ne, re] = f(0), [ie, ae] = f(!1), [F, I] = f(!1), [oe, L] = f(!1), se = u ?? (typeof navigator < "u" ? navigator.language : void 0);
2192
+ var yn = (e, t) => Object.entries(t).reduce((e, [t, n]) => e.split(`{${t}}`).join(String(n)), e), bn = (e) => !e || e.kind !== "http" ? !1 : e.status === 401 || e.status === 403;
2193
+ function xn({ conversations: e, activeConversationId: t, selectStatus: n, onSelect: r, onActiveDeleted: i, onNewChat: a, onClose: o, labels: l, locale: u, now: p }) {
2194
+ let { conversations: m, status: h, error: g, hasMore: b, refresh: x, loadMore: S, remove: C } = e, w = c(), T = c(), E = d(null), D = d(null), O = d(null), k = d(/* @__PURE__ */ new Map()), ee = d(/* @__PURE__ */ new Map()), A = d(null), j = d(null), [M, N] = f(null), [te, P] = f(null), [ne, re] = f(0), [ie, ae] = f(!1), [F, I] = f(!1), [oe, L] = f(!1), R = u ?? (typeof navigator < "u" ? navigator.language : void 0);
2175
2195
  s(() => {
2176
- T.current?.focus();
2196
+ E.current?.focus();
2177
2197
  }, []), s(() => {
2178
2198
  let e = A.current;
2179
2199
  if (!e) return;
2180
- let t = e.kind === "select" ? O.current.get(e.id) : e.kind === "delete" ? k.current.get(e.id) : e.kind === "cancel" ? D.current : E.current;
2200
+ let t = e.kind === "select" ? k.current.get(e.id) : e.kind === "delete" ? ee.current.get(e.id) : e.kind === "cancel" ? O.current : D.current;
2181
2201
  t && (t.focus(), A.current = null);
2182
2202
  }), s(() => {
2183
2203
  let e = j.current;
@@ -2190,22 +2210,22 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2190
2210
  b,
2191
2211
  m
2192
2212
  ]);
2193
- let ce = () => {
2194
- j.current = m.length, x();
2195
- }, le = (e) => {
2213
+ let se = () => {
2214
+ j.current = m.length, S();
2215
+ }, ce = (e) => {
2196
2216
  A.current = {
2197
2217
  kind: "delete",
2198
2218
  id: e
2199
2219
  }, N(null);
2200
- }, ue = (e) => {
2220
+ }, le = (e) => {
2201
2221
  if (e.key === "Escape") {
2202
2222
  if (e.stopPropagation(), M) {
2203
- le(M);
2223
+ ce(M);
2204
2224
  return;
2205
2225
  }
2206
2226
  o({ restoreFocusTo: "menu" });
2207
2227
  }
2208
- }, de = async (e) => {
2228
+ }, ue = async (e) => {
2209
2229
  if (L(!1), e === t) {
2210
2230
  o({ restoreFocusTo: "input" });
2211
2231
  return;
@@ -2221,14 +2241,14 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2221
2241
  return;
2222
2242
  }
2223
2243
  I(!1), o({ restoreFocusTo: "input" });
2224
- }, R = async (e) => {
2244
+ }, z = async (e) => {
2225
2245
  let n = m.findIndex((t) => t.conversationId === e), r = m[n + 1] ?? m[n - 1];
2226
2246
  A.current = r ? {
2227
2247
  kind: "select",
2228
2248
  id: r.conversationId
2229
2249
  } : { kind: "newChat" }, N(null), P(null), ae(!1), re((e) => e + 1);
2230
2250
  try {
2231
- await S({ conversationId: e }), ae(!0), e === t && i?.();
2251
+ await C({ conversationId: e }), ae(!0), e === t && i?.();
2232
2252
  } catch {
2233
2253
  A.current = {
2234
2254
  kind: "delete",
@@ -2237,12 +2257,12 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2237
2257
  } finally {
2238
2258
  re((e) => e - 1);
2239
2259
  }
2240
- }, z = h === "loading" && m.length === 0, fe = h === "error" && m.length === 0, B = h === "error" && m.length > 0 && b, V = h === "loading" && m.length > 0, H = F || n === "loading", pe = z ? l.historyLoadingText : ne > 0 ? l.historyDeletingText : ie ? l.historyDeletedText : m.length > 0 ? _n(m.length === 1 ? l.historyCountTextOne : l.historyCountTextMany, { count: m.length }) : "", U = z || ne > 0;
2260
+ }, B = h === "loading" && m.length === 0, de = h === "error" && m.length === 0, V = h === "error" && m.length > 0 && b, H = h === "loading" && m.length > 0, U = F || n === "loading", fe = B ? l.historyLoadingText : ne > 0 ? l.historyDeletingText : ie ? l.historyDeletedText : m.length > 0 ? yn(m.length === 1 ? l.historyCountTextOne : l.historyCountTextMany, { count: m.length }) : "", W = B || ne > 0;
2241
2261
  return /* @__PURE__ */ y("section", {
2242
2262
  role: "region",
2243
- "aria-labelledby": C,
2263
+ "aria-labelledby": w,
2244
2264
  className: "bailey-history-drawer",
2245
- onKeyDown: ue,
2265
+ onKeyDown: le,
2246
2266
  children: [
2247
2267
  /* @__PURE__ */ y("div", {
2248
2268
  className: "bailey-history-header",
@@ -2252,23 +2272,23 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2252
2272
  className: "bailey-history-icon-button",
2253
2273
  "aria-label": l.historyBackAriaLabel,
2254
2274
  onClick: () => o({ restoreFocusTo: "menu" }),
2255
- children: /* @__PURE__ */ v(Lt, { className: "bailey-history-icon" })
2275
+ children: /* @__PURE__ */ v(zt, { className: "bailey-history-icon" })
2256
2276
  }),
2257
2277
  /* @__PURE__ */ v("h3", {
2258
- id: C,
2259
- ref: T,
2278
+ id: w,
2279
+ ref: E,
2260
2280
  tabIndex: -1,
2261
2281
  className: "bailey-history-heading",
2262
2282
  children: l.historyTitle
2263
2283
  }),
2264
2284
  /* @__PURE__ */ y("button", {
2265
- ref: E,
2285
+ ref: D,
2266
2286
  type: "button",
2267
2287
  className: "bailey-history-button bailey-history-new-chat",
2268
2288
  "aria-label": l.newChatButtonText,
2269
- disabled: z,
2289
+ disabled: B,
2270
2290
  onClick: a,
2271
- children: [/* @__PURE__ */ v(Mt, { className: "bailey-history-icon-small" }), /* @__PURE__ */ v("span", {
2291
+ children: [/* @__PURE__ */ v(Pt, { className: "bailey-history-icon-small" }), /* @__PURE__ */ v("span", {
2272
2292
  className: "bailey-history-new-chat-text",
2273
2293
  children: l.newChatButtonText
2274
2294
  })]
@@ -2277,9 +2297,9 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2277
2297
  }),
2278
2298
  /* @__PURE__ */ y("div", {
2279
2299
  className: "bailey-history-body",
2280
- "aria-busy": z || void 0,
2300
+ "aria-busy": B || void 0,
2281
2301
  children: [
2282
- z && /* @__PURE__ */ y("div", {
2302
+ B && /* @__PURE__ */ y("div", {
2283
2303
  "aria-hidden": "true",
2284
2304
  children: [
2285
2305
  /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" }),
@@ -2288,25 +2308,25 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2288
2308
  /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" })
2289
2309
  ]
2290
2310
  }),
2291
- fe && /* @__PURE__ */ y("div", {
2311
+ de && /* @__PURE__ */ y("div", {
2292
2312
  role: "alert",
2293
2313
  className: "bailey-history-state bailey-history-state-error",
2294
2314
  children: [
2295
- /* @__PURE__ */ v(zt, { className: "bailey-history-state-icon" }),
2296
- /* @__PURE__ */ v("strong", { children: vn(g) ? l.historySessionExpiredTitle : l.historyErrorTitle }),
2297
- /* @__PURE__ */ v("span", { children: vn(g) ? l.historySessionExpiredDescription : l.historyErrorDescription }),
2315
+ /* @__PURE__ */ v(Vt, { className: "bailey-history-state-icon" }),
2316
+ /* @__PURE__ */ v("strong", { children: bn(g) ? l.historySessionExpiredTitle : l.historyErrorTitle }),
2317
+ /* @__PURE__ */ v("span", { children: bn(g) ? l.historySessionExpiredDescription : l.historyErrorDescription }),
2298
2318
  /* @__PURE__ */ v("button", {
2299
2319
  type: "button",
2300
2320
  className: "bailey-history-button bailey-history-button-primary",
2301
- onClick: () => void ee(),
2321
+ onClick: () => void x(),
2302
2322
  children: l.retryButtonText
2303
2323
  })
2304
2324
  ]
2305
2325
  }),
2306
- !z && !fe && m.length === 0 && /* @__PURE__ */ y("div", {
2326
+ !B && !de && m.length === 0 && /* @__PURE__ */ y("div", {
2307
2327
  className: "bailey-history-state",
2308
2328
  children: [
2309
- /* @__PURE__ */ v(kt, { className: "bailey-history-state-icon" }),
2329
+ /* @__PURE__ */ v(jt, { className: "bailey-history-state-icon" }),
2310
2330
  /* @__PURE__ */ v("strong", { children: l.historyEmptyTitle }),
2311
2331
  /* @__PURE__ */ v("span", { children: l.historyEmptyDescription }),
2312
2332
  /* @__PURE__ */ v("button", {
@@ -2325,11 +2345,11 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2325
2345
  className: "bailey-history-row bailey-history-row-confirming",
2326
2346
  children: /* @__PURE__ */ y("div", {
2327
2347
  role: "group",
2328
- "aria-labelledby": w,
2348
+ "aria-labelledby": T,
2329
2349
  className: "bailey-history-confirm",
2330
2350
  children: [
2331
2351
  /* @__PURE__ */ v("span", {
2332
- id: w,
2352
+ id: T,
2333
2353
  className: "bailey-history-confirm-question",
2334
2354
  children: l.historyDeleteConfirmQuestion
2335
2355
  }),
@@ -2340,38 +2360,38 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2340
2360
  /* @__PURE__ */ v("button", {
2341
2361
  type: "button",
2342
2362
  className: "bailey-history-button bailey-history-button-danger",
2343
- onClick: () => void R(n),
2363
+ onClick: () => void z(n),
2344
2364
  children: l.historyDeleteConfirmText
2345
2365
  }),
2346
2366
  /* @__PURE__ */ v("button", {
2347
- ref: D,
2367
+ ref: O,
2348
2368
  type: "button",
2349
2369
  className: "bailey-history-button",
2350
- onClick: () => le(n),
2370
+ onClick: () => ce(n),
2351
2371
  children: l.historyDeleteCancelText
2352
2372
  })
2353
2373
  ]
2354
2374
  })
2355
2375
  }, n);
2356
- let a = hn({
2376
+ let a = _n({
2357
2377
  iso: e.updatedAt,
2358
- locale: se,
2378
+ locale: R,
2359
2379
  now: p?.(),
2360
2380
  justNowText: l.historyJustNowText
2361
- }), o = _n(e.messageCount === 1 ? l.historyMessageCountOne : l.historyMessageCountMany, { count: e.messageCount }), s = te === n;
2381
+ }), o = yn(e.messageCount === 1 ? l.historyMessageCountOne : l.historyMessageCountMany, { count: e.messageCount }), s = te === n;
2362
2382
  return /* @__PURE__ */ y("li", {
2363
2383
  className: `bailey-history-row${i ? " bailey-history-row-active" : ""}${s ? " bailey-history-row-failed" : ""}`,
2364
2384
  children: [
2365
2385
  /* @__PURE__ */ y("button", {
2366
2386
  type: "button",
2367
2387
  ref: (e) => {
2368
- e ? O.current.set(n, e) : O.current.delete(n);
2388
+ e ? k.current.set(n, e) : k.current.delete(n);
2369
2389
  },
2370
2390
  className: "bailey-history-select",
2371
2391
  "aria-current": i ? "true" : void 0,
2372
- "aria-disabled": H || void 0,
2392
+ "aria-disabled": U || void 0,
2373
2393
  onClick: () => {
2374
- H || de(n);
2394
+ U || ue(n);
2375
2395
  },
2376
2396
  children: [/* @__PURE__ */ v("span", {
2377
2397
  className: "bailey-history-row-title",
@@ -2397,25 +2417,25 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2397
2417
  /* @__PURE__ */ v("button", {
2398
2418
  type: "button",
2399
2419
  ref: (e) => {
2400
- e ? k.current.set(n, e) : k.current.delete(n);
2420
+ e ? ee.current.set(n, e) : ee.current.delete(n);
2401
2421
  },
2402
2422
  className: "bailey-history-icon-button bailey-history-delete",
2403
- "aria-label": _n(l.historyDeleteAriaLabel, { title: r }),
2423
+ "aria-label": yn(l.historyDeleteAriaLabel, { title: r }),
2404
2424
  onClick: () => {
2405
2425
  P(null), ae(!1), A.current = { kind: "cancel" }, N(n);
2406
2426
  },
2407
- children: /* @__PURE__ */ v(Rt, { className: "bailey-history-icon" })
2427
+ children: /* @__PURE__ */ v(Bt, { className: "bailey-history-icon" })
2408
2428
  }),
2409
2429
  s && /* @__PURE__ */ y("div", {
2410
2430
  role: "alert",
2411
2431
  className: "bailey-history-row-error",
2412
2432
  children: [
2413
- /* @__PURE__ */ v(zt, { className: "bailey-history-icon-small" }),
2433
+ /* @__PURE__ */ v(Vt, { className: "bailey-history-icon-small" }),
2414
2434
  /* @__PURE__ */ v("span", { children: l.historyDeleteFailedText }),
2415
2435
  /* @__PURE__ */ v("button", {
2416
2436
  type: "button",
2417
2437
  className: "bailey-history-button bailey-history-button-small",
2418
- onClick: () => void R(n),
2438
+ onClick: () => void z(n),
2419
2439
  children: l.historyDeleteRetryText
2420
2440
  }),
2421
2441
  /* @__PURE__ */ v("button", {
@@ -2437,24 +2457,24 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2437
2457
  }),
2438
2458
  b && m.length > 0 && /* @__PURE__ */ v("div", {
2439
2459
  className: "bailey-history-more",
2440
- children: B ? /* @__PURE__ */ y("div", {
2460
+ children: V ? /* @__PURE__ */ y("div", {
2441
2461
  role: "alert",
2442
2462
  className: "bailey-history-inline-error",
2443
2463
  children: [/* @__PURE__ */ v("span", { children: l.historyLoadMoreErrorText }), /* @__PURE__ */ v("button", {
2444
2464
  type: "button",
2445
2465
  className: "bailey-history-button",
2446
- onClick: ce,
2466
+ onClick: se,
2447
2467
  children: l.retryButtonText
2448
2468
  })]
2449
2469
  }) : /* @__PURE__ */ y("button", {
2450
2470
  type: "button",
2451
2471
  className: "bailey-history-button",
2452
- disabled: V,
2453
- onClick: ce,
2454
- children: [V && /* @__PURE__ */ v("span", {
2472
+ disabled: H,
2473
+ onClick: se,
2474
+ children: [H && /* @__PURE__ */ v("span", {
2455
2475
  className: "bailey-history-spinner",
2456
2476
  "aria-hidden": "true"
2457
- }), V ? l.historyLoadingMoreText : l.historyLoadMoreText]
2477
+ }), H ? l.historyLoadingMoreText : l.historyLoadMoreText]
2458
2478
  })
2459
2479
  })
2460
2480
  ]
@@ -2463,17 +2483,17 @@ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2463
2483
  role: "status",
2464
2484
  "aria-live": "polite",
2465
2485
  className: "bailey-history-status",
2466
- children: [U && /* @__PURE__ */ v("span", {
2486
+ children: [W && /* @__PURE__ */ v("span", {
2467
2487
  className: "bailey-history-spinner",
2468
2488
  "aria-hidden": "true"
2469
- }), pe]
2489
+ }), fe]
2470
2490
  })
2471
2491
  ]
2472
2492
  });
2473
2493
  }
2474
2494
  //#endregion
2475
2495
  //#region src/ui/historyLabels.ts
2476
- var bn = {
2496
+ var Sn = {
2477
2497
  newChatButtonText: "New chat",
2478
2498
  retryButtonText: "Retry",
2479
2499
  historyTitle: "Chat history",
@@ -2506,8 +2526,8 @@ var bn = {
2506
2526
  historyDeleteRetryText: "Try again",
2507
2527
  historyDeleteDismissText: "Dismiss",
2508
2528
  historyJustNowText: "just now"
2509
- }, xn = "How can bailey AI help you today?", Sn = "Reply to bailey AI", Cn = {
2510
- ...bn,
2529
+ }, Cn = "How can bailey AI help you today?", wn = "Reply to bailey AI", Tn = {
2530
+ ...Sn,
2511
2531
  newChatButtonText: "New chat",
2512
2532
  newChatAriaLabel: "new chat",
2513
2533
  historyAriaLabel: "conversation history",
@@ -2533,104 +2553,104 @@ var bn = {
2533
2553
  mcpAppDefaultTitle: "MCP App",
2534
2554
  loadEarlierButtonText: "Load earlier messages",
2535
2555
  loadEarlierErrorText: "Couldn't load earlier messages."
2536
- }, wn = [m], Tn = {
2537
- ...Ct(),
2556
+ }, En = [m], Dn = {
2557
+ ...Tt(),
2538
2558
  p: ({ children: e }) => /* @__PURE__ */ v(_, { children: e })
2539
- }, En = i(function({ content: e, components: t }) {
2559
+ }, On = i(function({ content: e, components: t }) {
2540
2560
  return /* @__PURE__ */ v("div", {
2541
2561
  className: "bailey-markdown-content",
2542
2562
  children: /* @__PURE__ */ v(p, {
2543
- remarkPlugins: wn,
2563
+ remarkPlugins: En,
2544
2564
  components: t,
2545
2565
  skipHtml: !0,
2546
2566
  children: e
2547
2567
  })
2548
2568
  });
2549
2569
  });
2550
- function Dn(e, t, n) {
2570
+ function kn(e, t, n) {
2551
2571
  if (e !== "streaming") return;
2552
2572
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
2553
2573
  return r[r.length - 1];
2554
2574
  }
2555
- function On(e) {
2556
- if (!(!e || e.kind === "tool_end")) return tt(e);
2575
+ function An(e) {
2576
+ if (!(!e || e.kind === "tool_end")) return rt(e);
2557
2577
  }
2558
- function kn(e) {
2578
+ function jn(e) {
2559
2579
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
2560
2580
  hour: "numeric",
2561
2581
  minute: "2-digit"
2562
2582
  });
2563
2583
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
2564
2584
  }
2565
- function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholder: i, suggestions: o, onHistoryClick: c, history: l, locale: m, privacyNote: _, resolveActivityIcon: b, className: ee, height: x, width: S, hideDeveloperDetails: C = !1, renderMessageActions: w, renderTable: T, renderChart: E, renderMcpApp: D, labels: O, formatMessageTime: k }) {
2585
+ function Mn({ chat: e, placeholder: t, replyPlaceholder: r = wn, emptyPlaceholder: i, suggestions: o, onHistoryClick: c, history: l, locale: m, privacyNote: _, resolveActivityIcon: b, className: x, height: S, width: C, hideDeveloperDetails: w = !1, renderMessageActions: T, renderTable: E, renderChart: D, renderMcpApp: O, labels: k, formatMessageTime: ee }) {
2566
2586
  let { messages: A, traceEvents: j, lastRequest: M, status: N, error: te, send: P, stop: ne, retryLast: re, clearTrace: ie, clearError: ae, newChat: F } = e, [I, oe] = f(""), L = {
2567
- ...Cn,
2568
- ...O
2569
- }, se = k ?? kn, ce = d(null), le = d(null), ue = d(null), de = d(null), [R, z] = f(!1), fe = d(null), B = d(!1), V = !!c || !!l, H = xt(ce), pe = d(null), U = d(null), me = d(!0), he = u(() => Ct({
2570
- renderTable: T,
2571
- renderChart: E
2572
- }), [T, E]), W = u(() => Dn(N, j, M), [
2587
+ ...Tn,
2588
+ ...k
2589
+ }, R = ee ?? jn, se = d(null), ce = d(null), le = d(null), ue = d(null), [z, B] = f(!1), de = d(null), V = d(!1), H = !!c || !!l, U = Ct(se), fe = d(null), W = d(null), pe = d(!0), me = u(() => Tt({
2590
+ renderTable: E,
2591
+ renderChart: D
2592
+ }), [E, D]), G = u(() => kn(N, j, M), [
2573
2593
  N,
2574
2594
  j,
2575
2595
  M
2576
- ]), G = On(W), K = W?.kind === "tool_end" ? W.at : void 0, ge = A[A.length - 1]?.content.length ?? 0, [_e, ve] = f(null), ye = _e;
2577
- K !== void 0 && _e?.at !== K && (ye = {
2578
- at: K,
2579
- length: ge
2580
- }, ve(ye));
2581
- let q = K !== void 0 && ye?.at === K && ge <= ye.length, be = G ?? (q ? L.thinkingHint : void 0), xe = A.length === 0, J = t ?? (xe ? i ?? xn : r);
2596
+ ]), K = An(G), q = G?.kind === "tool_end" ? G.at : void 0, he = A[A.length - 1]?.content.length ?? 0, [ge, _e] = f(null), ve = ge;
2597
+ q !== void 0 && ge?.at !== q && (ve = {
2598
+ at: q,
2599
+ length: he
2600
+ }, _e(ve));
2601
+ let J = q !== void 0 && ve?.at === q && he <= ve.length, ye = K ?? (J ? L.thinkingHint : void 0), Y = A.length === 0, X = t ?? (Y ? i ?? Cn : r);
2582
2602
  s(() => {
2583
- let e = U.current;
2603
+ let e = W.current;
2584
2604
  if (!e) return;
2585
2605
  let t = () => {
2586
2606
  let t = e.scrollHeight - e.scrollTop - e.clientHeight;
2587
- me.current = t < 60;
2607
+ pe.current = t < 60;
2588
2608
  };
2589
2609
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
2590
2610
  }, []), s(() => {
2591
- me.current && pe.current?.scrollIntoView({
2611
+ pe.current && fe.current?.scrollIntoView({
2592
2612
  behavior: N === "streaming" ? "auto" : "smooth",
2593
2613
  block: "nearest"
2594
2614
  });
2595
2615
  }, [A, N]);
2596
- let Y = (e) => {
2597
- me.current = !0, P(e);
2598
- }, X = d(null), Se = () => {
2599
- let t = U.current;
2600
- me.current = !1, X.current = t ? {
2616
+ let be = (e) => {
2617
+ pe.current = !0, P(e);
2618
+ }, xe = d(null), Se = () => {
2619
+ let t = W.current;
2620
+ pe.current = !1, xe.current = t ? {
2601
2621
  height: t.scrollHeight,
2602
2622
  top: t.scrollTop
2603
2623
  } : null, e.loadEarlier?.().catch(() => {
2604
- X.current = null;
2624
+ xe.current = null;
2605
2625
  });
2606
2626
  };
2607
2627
  s(() => {
2608
- let e = X.current, t = U.current;
2609
- !e || !t || t.scrollHeight === e.height || (t.scrollTop = e.top + (t.scrollHeight - e.height), X.current = null);
2628
+ let e = xe.current, t = W.current;
2629
+ !e || !t || t.scrollHeight === e.height || (t.scrollTop = e.top + (t.scrollHeight - e.height), xe.current = null);
2610
2630
  }, [A]), s(() => {
2611
- le.current?.toggleAttribute("inert", R);
2612
- }, [R]), s(() => {
2613
- R || !fe.current || ((fe.current === "input" ? ue.current : de.current)?.focus(), fe.current = null);
2614
- }, [R]);
2631
+ ce.current?.toggleAttribute("inert", z);
2632
+ }, [z]), s(() => {
2633
+ z || !de.current || ((de.current === "input" ? le.current : ue.current)?.focus(), de.current = null);
2634
+ }, [z]);
2615
2635
  let Z = a((e) => {
2616
- fe.current = e.restoreFocusTo, z(!1);
2636
+ de.current = e.restoreFocusTo, B(!1);
2617
2637
  }, []);
2618
- return /* @__PURE__ */ v(dt.Provider, {
2619
- value: H,
2638
+ return /* @__PURE__ */ v(pt.Provider, {
2639
+ value: U,
2620
2640
  children: /* @__PURE__ */ y("div", {
2621
- ref: ce,
2622
- className: `bailey-chat-panel${ee ? ` ${ee}` : ""}`,
2623
- style: x !== void 0 || S !== void 0 ? {
2624
- height: x,
2625
- width: S
2641
+ ref: se,
2642
+ className: `bailey-chat-panel${x ? ` ${x}` : ""}`,
2643
+ style: S !== void 0 || C !== void 0 ? {
2644
+ height: S,
2645
+ width: C
2626
2646
  } : void 0,
2627
2647
  children: [/* @__PURE__ */ y("div", {
2628
2648
  className: "bailey-chat-panel-inner",
2629
- ref: le,
2649
+ ref: ce,
2630
2650
  children: [
2631
2651
  /* @__PURE__ */ y("div", {
2632
2652
  className: "bailey-chat-transcript",
2633
- ref: U,
2653
+ ref: W,
2634
2654
  children: [
2635
2655
  e.hasEarlier && e.loadEarlier && /* @__PURE__ */ y("div", {
2636
2656
  className: "bailey-load-earlier",
@@ -2646,23 +2666,23 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2646
2666
  children: L.loadEarlierErrorText
2647
2667
  })]
2648
2668
  }),
2649
- xe && (o && o.length > 0 ? /* @__PURE__ */ y("div", {
2669
+ Y && (o && o.length > 0 ? /* @__PURE__ */ y("div", {
2650
2670
  className: "bailey-suggestions",
2651
2671
  children: [/* @__PURE__ */ v("div", {
2652
2672
  className: "bailey-suggestions-title",
2653
2673
  children: L.suggestionsTitle
2654
2674
  }), o.map((e, t) => /* @__PURE__ */ y("button", {
2655
2675
  type: "button",
2656
- onClick: () => Y(e.value ?? e.label),
2676
+ onClick: () => be(e.value ?? e.label),
2657
2677
  className: "bailey-suggestion-card",
2658
- children: [/* @__PURE__ */ v("span", { children: e.label }), /* @__PURE__ */ v(Et, { className: "bailey-suggestion-icon" })]
2678
+ children: [/* @__PURE__ */ v("span", { children: e.label }), /* @__PURE__ */ v(Ot, { className: "bailey-suggestion-icon" })]
2659
2679
  }, `${e.label}-${t}`))]
2660
2680
  }) : /* @__PURE__ */ v("div", {
2661
2681
  className: "bailey-empty-state",
2662
2682
  children: L.emptyStateMessage
2663
2683
  })),
2664
2684
  A.map((e, t) => {
2665
- let r = e.role === "assistant" && t === A.length - 1, i = N === "streaming" && r && e.content === "", a = e.role === "assistant" ? lt(j, e.createdAt) : [], o = a.some((e) => e.status === "running");
2685
+ let r = e.role === "assistant" && t === A.length - 1, i = N === "streaming" && r && e.content === "", a = e.role === "assistant" ? dt(j, e.createdAt) : [], o = a.some((e) => e.status === "running");
2666
2686
  return /* @__PURE__ */ v("div", {
2667
2687
  className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
2668
2688
  children: e.role === "user" ? /* @__PURE__ */ y("div", {
@@ -2672,58 +2692,58 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2672
2692
  children: [/* @__PURE__ */ v("span", {
2673
2693
  className: "bailey-message-meta-name",
2674
2694
  children: L.youLabel
2675
- }), e.createdAt !== void 0 && /* @__PURE__ */ v("span", { children: se(e.createdAt) })]
2695
+ }), e.createdAt !== void 0 && /* @__PURE__ */ v("span", { children: R(e.createdAt) })]
2676
2696
  }), /* @__PURE__ */ v("div", {
2677
2697
  className: "bailey-user-bubble",
2678
2698
  children: e.content
2679
2699
  })]
2680
- }) : i ? o ? /* @__PURE__ */ v(sn, {
2700
+ }) : i ? o ? /* @__PURE__ */ v(ln, {
2681
2701
  steps: a,
2682
2702
  resolveActivityIcon: b
2683
2703
  }) : /* @__PURE__ */ v("div", {
2684
2704
  className: "bailey-thinking-hint",
2685
- children: G ?? L.thinkingHint
2705
+ children: K ?? L.thinkingHint
2686
2706
  }) : /* @__PURE__ */ y("div", {
2687
2707
  className: "bailey-assistant-message",
2688
2708
  children: [
2689
- !e.streaming && /* @__PURE__ */ v(cn, {
2709
+ !e.streaming && /* @__PURE__ */ v(un, {
2690
2710
  steps: a,
2691
2711
  labels: L,
2692
2712
  resolveActivityIcon: b
2693
2713
  }),
2694
- /* @__PURE__ */ v(En, {
2714
+ /* @__PURE__ */ v(On, {
2695
2715
  content: e.content,
2696
- components: he
2716
+ components: me
2697
2717
  }),
2698
- e.parts?.map((e, t) => e.type === "image" ? /* @__PURE__ */ v(Zt, {
2718
+ e.parts?.map((e, t) => e.type === "image" ? /* @__PURE__ */ v($t, {
2699
2719
  src: e.src,
2700
2720
  alt: e.alt
2701
- }, t) : e.type === "mcp_app" ? /* @__PURE__ */ v(n, { children: D ? D(e) : /* @__PURE__ */ v(an, {
2721
+ }, t) : e.type === "mcp_app" ? /* @__PURE__ */ v(n, { children: O ? O(e) : /* @__PURE__ */ v(sn, {
2702
2722
  ...e,
2703
2723
  title: e.title ?? L.mcpAppDefaultTitle
2704
2724
  }) }, t) : null),
2705
- e.streaming && /* @__PURE__ */ v(sn, {
2725
+ e.streaming && /* @__PURE__ */ v(ln, {
2706
2726
  steps: a,
2707
2727
  resolveActivityIcon: b
2708
2728
  }),
2709
- e.streaming && be && !o && /* @__PURE__ */ v("div", {
2729
+ e.streaming && ye && !o && /* @__PURE__ */ v("div", {
2710
2730
  className: "bailey-streaming-hint",
2711
- children: be
2731
+ children: ye
2712
2732
  }),
2713
2733
  !e.streaming && /* @__PURE__ */ y("div", {
2714
2734
  className: "bailey-message-actions",
2715
- children: [/* @__PURE__ */ v(Vt, {
2735
+ children: [/* @__PURE__ */ v(Ut, {
2716
2736
  markdown: e.content,
2717
2737
  ariaLabel: L.copyButtonAriaLabel,
2718
2738
  tooltipDefaultText: L.copyButtonTooltipDefault,
2719
2739
  tooltipCopiedText: L.copyButtonTooltipCopied
2720
- }), w?.(e)]
2740
+ }), T?.(e)]
2721
2741
  })
2722
2742
  ]
2723
2743
  })
2724
2744
  }, e.id);
2725
2745
  }),
2726
- /* @__PURE__ */ v("div", { ref: pe })
2746
+ /* @__PURE__ */ v("div", { ref: fe })
2727
2747
  ]
2728
2748
  }),
2729
2749
  te && /* @__PURE__ */ y("div", {
@@ -2745,7 +2765,7 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2745
2765
  })]
2746
2766
  })]
2747
2767
  }),
2748
- !C && /* @__PURE__ */ v(Xt, {
2768
+ !w && /* @__PURE__ */ v(Qt, {
2749
2769
  events: j,
2750
2770
  lastRequest: M,
2751
2771
  onClear: ie
@@ -2754,14 +2774,14 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2754
2774
  className: "bailey-input-area",
2755
2775
  children: [/* @__PURE__ */ y("form", {
2756
2776
  onSubmit: (e) => {
2757
- e.preventDefault(), !(!I.trim() || N === "streaming") && (Y(I), oe(""));
2777
+ e.preventDefault(), !(!I.trim() || N === "streaming") && (be(I), oe(""));
2758
2778
  },
2759
2779
  className: "bailey-input-row",
2760
2780
  children: [/* @__PURE__ */ v("input", {
2761
- ref: ue,
2781
+ ref: le,
2762
2782
  type: "text",
2763
- placeholder: J,
2764
- "aria-label": J,
2783
+ placeholder: X,
2784
+ "aria-label": X,
2765
2785
  value: I,
2766
2786
  onChange: (e) => oe(e.target.value),
2767
2787
  disabled: N === "streaming",
@@ -2775,10 +2795,10 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2775
2795
  onClick: ne,
2776
2796
  "aria-label": L.stopAriaLabel,
2777
2797
  className: "bailey-stop-button",
2778
- children: /* @__PURE__ */ v(Tt, { className: "bailey-stop-icon" })
2798
+ children: /* @__PURE__ */ v(Dt, { className: "bailey-stop-icon" })
2779
2799
  })
2780
2800
  }), /* @__PURE__ */ v(g.Portal, {
2781
- container: H instanceof ShadowRoot ? H : void 0,
2801
+ container: U instanceof ShadowRoot ? U : void 0,
2782
2802
  children: /* @__PURE__ */ y(g.Content, {
2783
2803
  side: "top",
2784
2804
  className: "bailey-tooltip-content",
@@ -2790,56 +2810,56 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2790
2810
  "aria-label": L.sendAriaLabel,
2791
2811
  disabled: !I.trim(),
2792
2812
  className: "bailey-send-button",
2793
- children: /* @__PURE__ */ v(wt, { className: "bailey-send-icon" })
2813
+ children: /* @__PURE__ */ v(Et, { className: "bailey-send-icon" })
2794
2814
  })]
2795
- }), (!xe || V) && /* @__PURE__ */ y(h.Root, { children: [/* @__PURE__ */ v(h.Trigger, {
2815
+ }), (!Y || H) && /* @__PURE__ */ y(h.Root, { children: [/* @__PURE__ */ v(h.Trigger, {
2796
2816
  asChild: !0,
2797
2817
  children: /* @__PURE__ */ v("button", {
2798
2818
  type: "button",
2799
- ref: de,
2819
+ ref: ue,
2800
2820
  "aria-label": L.menuAriaLabel,
2801
2821
  className: "bailey-menu-button",
2802
- children: /* @__PURE__ */ v(jt, { className: "bailey-menu-icon" })
2822
+ children: /* @__PURE__ */ v(Nt, { className: "bailey-menu-icon" })
2803
2823
  })
2804
2824
  }), /* @__PURE__ */ v(h.Portal, {
2805
- container: H instanceof ShadowRoot ? H : void 0,
2825
+ container: U instanceof ShadowRoot ? U : void 0,
2806
2826
  children: /* @__PURE__ */ y(h.Content, {
2807
2827
  side: "top",
2808
2828
  align: "end",
2809
2829
  sideOffset: 8,
2810
2830
  className: "bailey-menu-content",
2811
2831
  onCloseAutoFocus: (e) => {
2812
- B.current &&= (e.preventDefault(), !1);
2832
+ V.current &&= (e.preventDefault(), !1);
2813
2833
  },
2814
- children: [!xe && /* @__PURE__ */ y(h.Item, {
2834
+ children: [!Y && /* @__PURE__ */ y(h.Item, {
2815
2835
  onSelect: () => F(),
2816
2836
  className: "bailey-menu-item",
2817
- children: [/* @__PURE__ */ v(Mt, { className: "bailey-menu-item-icon" }), L.newChatButtonText]
2818
- }), V && /* @__PURE__ */ y(h.Item, {
2837
+ children: [/* @__PURE__ */ v(Pt, { className: "bailey-menu-item-icon" }), L.newChatButtonText]
2838
+ }), H && /* @__PURE__ */ y(h.Item, {
2819
2839
  onSelect: () => {
2820
2840
  if (c) {
2821
2841
  c();
2822
2842
  return;
2823
2843
  }
2824
- B.current = !0, z(!0);
2844
+ V.current = !0, B(!0);
2825
2845
  },
2826
2846
  className: "bailey-menu-item",
2827
- children: [/* @__PURE__ */ v(kt, { className: "bailey-menu-item-icon" }), L.historyMenuItemText]
2847
+ children: [/* @__PURE__ */ v(jt, { className: "bailey-menu-item-icon" }), L.historyMenuItemText]
2828
2848
  })]
2829
2849
  })
2830
2850
  })] })]
2831
2851
  }),
2832
- (xe || _?.alwaysVisible) && _ && /* @__PURE__ */ v("div", {
2852
+ (Y || _?.alwaysVisible) && _ && /* @__PURE__ */ v("div", {
2833
2853
  className: "bailey-privacy-note",
2834
2854
  children: /* @__PURE__ */ v(p, {
2835
- remarkPlugins: wn,
2836
- components: Tn,
2855
+ remarkPlugins: En,
2856
+ components: Dn,
2837
2857
  skipHtml: !0,
2838
2858
  children: _.markdown
2839
2859
  })
2840
2860
  })
2841
2861
  ]
2842
- }), R && l && !c && /* @__PURE__ */ v(gn, {
2862
+ }), z && l && !c && /* @__PURE__ */ v(vn, {
2843
2863
  client: l.client,
2844
2864
  pageSize: l.pageSize,
2845
2865
  chat: e,
@@ -2852,7 +2872,7 @@ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholde
2852
2872
  }
2853
2873
  //#endregion
2854
2874
  //#region src/ui/BaileyFeedbackButtons.tsx
2855
- var jn = {
2875
+ var Nn = {
2856
2876
  feedbackGroupLabel: "Rate this response",
2857
2877
  feedbackThumbsUpAriaLabel: "Good response",
2858
2878
  feedbackThumbsDownAriaLabel: "Bad response",
@@ -2873,48 +2893,48 @@ var jn = {
2873
2893
  feedbackReasonUnsafe: "Unsafe",
2874
2894
  feedbackReasonTooLong: "Too long",
2875
2895
  feedbackReasonOther: "Other"
2876
- }, Mn = 2e3, Nn = [
2896
+ }, Pn = 2e3, Fn = [
2877
2897
  "inaccurate",
2878
2898
  "unhelpful",
2879
2899
  "unsafe",
2880
2900
  "too_long",
2881
2901
  "other"
2882
- ], Pn = {
2902
+ ], In = {
2883
2903
  inaccurate: "feedbackReasonInaccurate",
2884
2904
  unhelpful: "feedbackReasonUnhelpful",
2885
2905
  unsafe: "feedbackReasonUnsafe",
2886
2906
  too_long: "feedbackReasonTooLong",
2887
2907
  other: "feedbackReasonOther"
2888
- }, Fn = (e) => Nn.includes(e) ? e : "other";
2889
- function In(e) {
2890
- return Array.from(new Set((e ?? Nn).map(Fn)));
2908
+ }, Ln = (e) => Fn.includes(e) ? e : "other";
2909
+ function Rn(e) {
2910
+ return Array.from(new Set((e ?? Fn).map(Ln)));
2891
2911
  }
2892
- function Ln(e) {
2893
- return typeof e == "number" && e > 0 ? Math.min(Math.floor(e), Mn) : Mn;
2912
+ function zn(e) {
2913
+ return typeof e == "number" && e > 0 ? Math.min(Math.floor(e), Pn) : Pn;
2894
2914
  }
2895
- function Rn(e, t) {
2915
+ function Bn(e, t) {
2896
2916
  if (e === null || t === null) return e === t;
2897
2917
  let n = e.reasonCodes ?? [], r = t.reasonCodes ?? [];
2898
2918
  return e.rating === t.rating && (e.comment ?? "") === (t.comment ?? "") && n.length === r.length && n.every((e, t) => e === r[t]);
2899
2919
  }
2900
- function zn(e) {
2901
- return e.messageId ? /* @__PURE__ */ v(Bn, { ...e }, e.messageId) : null;
2920
+ function Vn(e) {
2921
+ return e.messageId ? /* @__PURE__ */ v(Hn, { ...e }, e.messageId) : null;
2902
2922
  }
2903
- function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOptions: i, maxCommentLength: a, labels: o, className: l }) {
2923
+ function Hn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOptions: i, maxCommentLength: a, labels: o, className: l }) {
2904
2924
  let u = {
2905
- ...jn,
2925
+ ...Nn,
2906
2926
  ...o
2907
- }, p = In(i), m = Ln(a), h = r ? { rating: r } : null, [b, ee] = f(h), [x, S] = f(r ?? null), [C, w] = f(!1), [T, E] = f("down"), [D, O] = f([]), [k, A] = f(""), [j, M] = f(!1), [N, te] = f(!1), [P, ne] = f(!1), [re, ie] = f(!1), ae = d(h), F = d(null), I = d(0), oe = d(!1), L = d(!0), se = d(null), ce = d(null), le = d(null), ue = d(null), de = d(null), R = St(ce), z = c(), fe = `${z}-comment`, B = `${z}-counter`, V = `${z}-privacy`;
2927
+ }, p = Rn(i), m = zn(a), h = r ? { rating: r } : null, [b, x] = f(h), [S, C] = f(r ?? null), [w, T] = f(!1), [E, D] = f("down"), [O, k] = f([]), [ee, A] = f(""), [j, M] = f(!1), [N, te] = f(!1), [P, ne] = f(!1), [re, ie] = f(!1), ae = d(h), F = d(null), I = d(0), oe = d(!1), L = d(!0), R = d(null), se = d(null), ce = d(null), le = d(null), ue = d(null), z = wt(se), B = c(), de = `${B}-comment`, V = `${B}-counter`, H = `${B}-privacy`;
2908
2928
  s(() => (L.current = !0, () => {
2909
2929
  L.current = !1;
2910
2930
  }), []), s(() => {
2911
- C && de.current?.focus();
2912
- }, [C]), s(() => {
2913
- se.current && !P && !C && ((se.current === "up" ? le : ue).current?.focus(), se.current = null);
2931
+ w && ue.current?.focus();
2932
+ }, [w]), s(() => {
2933
+ R.current && !P && !w && ((R.current === "up" ? ce : le).current?.focus(), R.current = null);
2914
2934
  });
2915
- let H = () => {
2916
- O([]), A("");
2917
- }, pe = async (r) => {
2935
+ let U = () => {
2936
+ k([]), A("");
2937
+ }, fe = async (r) => {
2918
2938
  try {
2919
2939
  return r.kind === "clear" ? await n({ messageId: e }) : await t({
2920
2940
  messageId: e,
@@ -2923,79 +2943,79 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
2923
2943
  } catch {
2924
2944
  return !1;
2925
2945
  }
2926
- }, U = async () => {
2946
+ }, W = async () => {
2927
2947
  if (!oe.current) {
2928
2948
  oe.current = !0, te(!0);
2929
2949
  try {
2930
2950
  for (; F.current && L.current;) {
2931
- let e = F.current, t = e.kind === "clear" ? null : e.snapshot, n = !(e.kind === "submit" && e.formSubmit) && Rn(t, ae.current) || await pe(e);
2951
+ let e = F.current, t = e.kind === "clear" ? null : e.snapshot, n = !(e.kind === "submit" && e.formSubmit) && Bn(t, ae.current) || await fe(e);
2932
2952
  if (!L.current) return;
2933
2953
  let r = F.current?.version !== e.version;
2934
- !n && r || (n ? (ae.current = t, ee(t)) : (S(ae.current?.rating ?? null), ie(!0)), r || (F.current = null, ne(!1), n && e.kind === "submit" && e.formSubmit && (w(!1), M(!0), se.current = e.snapshot.rating)));
2954
+ !n && r || (n ? (ae.current = t, x(t)) : (C(ae.current?.rating ?? null), ie(!0)), r || (F.current = null, ne(!1), n && e.kind === "submit" && e.formSubmit && (T(!1), M(!0), R.current = e.snapshot.rating)));
2935
2955
  }
2936
2956
  } finally {
2937
2957
  oe.current = !1, L.current && te(!1);
2938
2958
  }
2939
2959
  }
2940
- }, me = (e) => {
2960
+ }, pe = (e) => {
2941
2961
  I.current += 1, F.current = {
2942
2962
  ...e,
2943
2963
  version: I.current
2944
- }, ie(!1), U();
2945
- }, he = () => {
2946
- S(null), w(!1), M(!1), H(), me({ kind: "clear" });
2947
- }, W = (e) => {
2964
+ }, ie(!1), W();
2965
+ }, me = () => {
2966
+ C(null), T(!1), M(!1), U(), pe({ kind: "clear" });
2967
+ }, G = (e) => {
2948
2968
  if (!P) {
2949
- if (x === e) {
2950
- he();
2969
+ if (S === e) {
2970
+ me();
2951
2971
  return;
2952
2972
  }
2953
- S(e), M(!1), H(), e === "down" ? (E("down"), w(!0)) : w(!1), me({
2973
+ C(e), M(!1), U(), e === "down" ? (D("down"), T(!0)) : T(!1), pe({
2954
2974
  kind: "submit",
2955
2975
  snapshot: { rating: e },
2956
2976
  formSubmit: !1
2957
2977
  });
2958
2978
  }
2959
- }, G = (e) => {
2960
- x !== null && (E(x), O((e?.reasonCodes ?? []).map(Fn)), A(e?.comment ?? ""), ie(!1), w(!0));
2961
- }, K = () => {
2962
- P || (w(!1), ie(!1), H(), se.current = T);
2963
- }, ge = () => {
2979
+ }, K = (e) => {
2980
+ S !== null && (D(S), k((e?.reasonCodes ?? []).map(Ln)), A(e?.comment ?? ""), ie(!1), T(!0));
2981
+ }, q = () => {
2982
+ P || (T(!1), ie(!1), U(), R.current = E);
2983
+ }, he = () => {
2964
2984
  if (P) return;
2965
- let e = k.trim(), t = p.filter((e) => D.includes(e)), n = {
2966
- rating: T,
2985
+ let e = ee.trim(), t = p.filter((e) => O.includes(e)), n = {
2986
+ rating: E,
2967
2987
  ...t.length > 0 ? { reasonCodes: t } : {},
2968
2988
  ...e ? { comment: e } : {}
2969
2989
  };
2970
- ne(!0), S(T), me({
2990
+ ne(!0), C(E), pe({
2971
2991
  kind: "submit",
2972
2992
  snapshot: n,
2973
2993
  formSubmit: !0
2974
2994
  });
2995
+ }, ge = (e) => {
2996
+ k((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
2975
2997
  }, _e = (e) => {
2976
- O((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
2977
- }, ve = (e) => {
2978
- e.key === "Escape" && (e.stopPropagation(), K());
2979
- }, ye = x !== null && b?.rating === x && !N && !C, q = !!b && (!!b.comment || (b.reasonCodes?.length ?? 0) > 0), be = N ? u.feedbackSavingText : ye ? u.feedbackThanksText : "", xe = (e) => {
2980
- let t = x === e, n = e === "up" ? u.feedbackThumbsUpAriaLabel : u.feedbackThumbsDownAriaLabel, r = e === "up" ? Ft : It;
2998
+ e.key === "Escape" && (e.stopPropagation(), q());
2999
+ }, ve = S !== null && b?.rating === S && !N && !w, J = !!b && (!!b.comment || (b.reasonCodes?.length ?? 0) > 0), ye = N ? u.feedbackSavingText : ve ? u.feedbackThanksText : "", Y = (e) => {
3000
+ let t = S === e, n = e === "up" ? u.feedbackThumbsUpAriaLabel : u.feedbackThumbsDownAriaLabel, r = e === "up" ? Lt : Rt;
2981
3001
  return /* @__PURE__ */ y(g.Root, { children: [/* @__PURE__ */ v(g.Trigger, {
2982
3002
  asChild: !0,
2983
3003
  children: /* @__PURE__ */ v("button", {
2984
- ref: e === "up" ? le : ue,
3004
+ ref: e === "up" ? ce : le,
2985
3005
  type: "button",
2986
3006
  className: "bailey-feedback-thumb",
2987
3007
  "aria-pressed": t,
2988
3008
  "aria-label": n,
2989
3009
  "aria-busy": t && N ? !0 : void 0,
2990
3010
  disabled: P,
2991
- onClick: () => W(e),
3011
+ onClick: () => G(e),
2992
3012
  children: /* @__PURE__ */ v(r, {
2993
3013
  className: "bailey-feedback-icon",
2994
3014
  filled: t
2995
3015
  })
2996
3016
  })
2997
3017
  }), /* @__PURE__ */ v(g.Portal, {
2998
- container: R instanceof ShadowRoot ? R : void 0,
3018
+ container: z instanceof ShadowRoot ? z : void 0,
2999
3019
  children: /* @__PURE__ */ y(g.Content, {
3000
3020
  side: "top",
3001
3021
  className: "bailey-tooltip-content",
@@ -3004,7 +3024,7 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3004
3024
  })] });
3005
3025
  };
3006
3026
  return /* @__PURE__ */ y("div", {
3007
- ref: ce,
3027
+ ref: se,
3008
3028
  className: `bailey-feedback${l ? ` ${l}` : ""}`,
3009
3029
  children: [
3010
3030
  /* @__PURE__ */ v(g.Provider, {
@@ -3014,7 +3034,7 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3014
3034
  "aria-label": u.feedbackGroupLabel,
3015
3035
  "aria-busy": N ? !0 : void 0,
3016
3036
  className: "bailey-feedback-thumbs",
3017
- children: [xe("up"), xe("down")]
3037
+ children: [Y("up"), Y("down")]
3018
3038
  })
3019
3039
  }),
3020
3040
  /* @__PURE__ */ y("span", {
@@ -3023,17 +3043,17 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3023
3043
  children: [N && /* @__PURE__ */ v("span", {
3024
3044
  className: "bailey-feedback-spinner",
3025
3045
  "aria-hidden": "true"
3026
- }), be]
3046
+ }), ye]
3027
3047
  }),
3028
- ye && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
3048
+ ve && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
3029
3049
  type: "button",
3030
3050
  className: "bailey-feedback-link",
3031
- onClick: () => G(b),
3032
- children: j || q ? u.feedbackEditText : u.feedbackAddCommentText
3051
+ onClick: () => K(b),
3052
+ children: j || J ? u.feedbackEditText : u.feedbackAddCommentText
3033
3053
  }), /* @__PURE__ */ v("button", {
3034
3054
  type: "button",
3035
3055
  className: "bailey-feedback-link",
3036
- onClick: he,
3056
+ onClick: me,
3037
3057
  children: u.feedbackUndoText
3038
3058
  })] }),
3039
3059
  re && /* @__PURE__ */ v("span", {
@@ -3041,9 +3061,9 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3041
3061
  className: "bailey-feedback-error",
3042
3062
  children: u.feedbackErrorText
3043
3063
  }),
3044
- C && /* @__PURE__ */ y("div", {
3064
+ w && /* @__PURE__ */ y("div", {
3045
3065
  className: "bailey-feedback-form",
3046
- onKeyDown: ve,
3066
+ onKeyDown: _e,
3047
3067
  children: [
3048
3068
  p.length > 0 && /* @__PURE__ */ y("fieldset", {
3049
3069
  className: "bailey-feedback-reasons",
@@ -3054,45 +3074,45 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3054
3074
  className: "bailey-feedback-chips",
3055
3075
  children: p.map((e, t) => /* @__PURE__ */ v("button", {
3056
3076
  ref: t === 0 ? (e) => {
3057
- de.current = e;
3077
+ ue.current = e;
3058
3078
  } : void 0,
3059
3079
  type: "button",
3060
3080
  className: "bailey-feedback-chip",
3061
- "aria-pressed": D.includes(e),
3081
+ "aria-pressed": O.includes(e),
3062
3082
  disabled: P,
3063
- onClick: () => _e(e),
3064
- children: u[Pn[e]]
3083
+ onClick: () => ge(e),
3084
+ children: u[In[e]]
3065
3085
  }, e))
3066
3086
  })]
3067
3087
  }),
3068
3088
  /* @__PURE__ */ v("label", {
3069
- htmlFor: fe,
3089
+ htmlFor: de,
3070
3090
  className: "bailey-feedback-legend",
3071
3091
  children: u.feedbackCommentLabel
3072
3092
  }),
3073
3093
  /* @__PURE__ */ v("textarea", {
3074
- id: fe,
3094
+ id: de,
3075
3095
  ref: p.length === 0 ? (e) => {
3076
- de.current = e;
3096
+ ue.current = e;
3077
3097
  } : void 0,
3078
3098
  className: "bailey-feedback-textarea",
3079
- value: k,
3099
+ value: ee,
3080
3100
  maxLength: m,
3081
3101
  placeholder: u.feedbackCommentPlaceholder,
3082
- "aria-describedby": `${B} ${V}`,
3102
+ "aria-describedby": `${V} ${H}`,
3083
3103
  disabled: P,
3084
3104
  onChange: (e) => A(e.target.value.slice(0, m))
3085
3105
  }),
3086
3106
  /* @__PURE__ */ y("div", {
3087
3107
  className: "bailey-feedback-meta",
3088
3108
  children: [/* @__PURE__ */ v("span", {
3089
- id: V,
3109
+ id: H,
3090
3110
  className: "bailey-feedback-privacy",
3091
3111
  children: u.feedbackPrivacyNote
3092
3112
  }), /* @__PURE__ */ v("span", {
3093
- id: B,
3113
+ id: V,
3094
3114
  className: "bailey-feedback-counter",
3095
- children: `${k.length} / ${m}`
3115
+ children: `${ee.length} / ${m}`
3096
3116
  })]
3097
3117
  }),
3098
3118
  /* @__PURE__ */ y("div", {
@@ -3101,13 +3121,13 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3101
3121
  type: "button",
3102
3122
  className: "bailey-feedback-button",
3103
3123
  disabled: P,
3104
- onClick: K,
3124
+ onClick: q,
3105
3125
  children: u.feedbackCancelText
3106
3126
  }), /* @__PURE__ */ v("button", {
3107
3127
  type: "button",
3108
3128
  className: "bailey-feedback-button bailey-feedback-button-primary",
3109
3129
  disabled: P,
3110
- onClick: ge,
3130
+ onClick: he,
3111
3131
  children: P ? u.feedbackSavingText : u.feedbackSubmitText
3112
3132
  })]
3113
3133
  })
@@ -3118,6 +3138,6 @@ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3118
3138
  }
3119
3139
  //#endregion
3120
3140
  //#region src/index.ts
3121
- var Vn = "0.3.1-pre.2";
3141
+ var Un = "0.3.1-pre.2";
3122
3142
  //#endregion
3123
- export { At as ActivityIcon, Et as ArrowUpRightIcon, Vn as BAILEYAI_CHAT_UI_VERSION, ze as BAILEY_CHART_PROMPT_FRAGMENT, je as BAILEY_TABLE_GRID_ROW_THRESHOLD, V as BaileyApiError, An as BaileyChatPanel, pe as BaileyCleanupError, zn as BaileyFeedbackButtons, gn as BaileyHistoryDrawer, Xt as BaileyTracePanel, Vt as CopyMarkdownButton, ie as DEFAULT_CONVERSATION_STORAGE_KEY, wt as HeartIcon, qe as TRACE_KIND_LABEL, It as ThumbDownIcon, Ft as ThumbUpIcon, De as createBaileyClient, Q as createBaileyFeedbackHandlers, Ct as createBaileyMarkdownComponents, F as createMemoryConversationStorage, ae as createSessionConversationStorage, O as extractPseudoToolCalls, Le as extractTableData, hn as formatRelativeTime, rt as formatTraceGap, nt as formatTraceTime, st as hasTraceFailure, re as isConversationIdForSub, e as isSafeMarkdownUrl, Oe as joinInstructions, te as mapTranscript, ne as mergeEarlierPage, Ke as parseBaileyChartSpec, A as parseSseFrames, $ as resolveToolCall, Re as shouldUseGrid, ct as toActivityLines, lt as toToolSteps, it as toTraceRows, ot as toTraceSegments, Ze as traceEventArgsDetail, tt as traceEventHint, Qe as traceEventOutputDetail, et as traceEventRawDetail, Xe as traceEventSummary, Ye as traceEventToolName, at as traceSummaryLine, B as useBaileyChat, me as useBaileyConversations };
3143
+ export { Mt as ActivityIcon, Ot as ArrowUpRightIcon, Un as BAILEYAI_CHAT_UI_VERSION, Ve as BAILEY_CHART_PROMPT_FRAGMENT, Ne as BAILEY_TABLE_GRID_ROW_THRESHOLD, H as BaileyApiError, Mn as BaileyChatPanel, fe as BaileyCleanupError, Vn as BaileyFeedbackButtons, vn as BaileyHistoryDrawer, Qt as BaileyTracePanel, Ut as CopyMarkdownButton, ie as DEFAULT_CONVERSATION_STORAGE_KEY, Et as HeartIcon, Ye as TRACE_KIND_LABEL, Rt as ThumbDownIcon, Lt as ThumbUpIcon, Oe as createBaileyClient, ke as createBaileyFeedbackHandlers, Tt as createBaileyMarkdownComponents, F as createMemoryConversationStorage, ae as createSessionConversationStorage, k as extractPseudoToolCalls, ze as extractTableData, _n as formatRelativeTime, at as formatTraceGap, it as formatTraceTime, lt as hasTraceFailure, re as isConversationIdForSub, e as isSafeMarkdownUrl, Ae as joinInstructions, te as mapTranscript, ne as mergeEarlierPage, Je as parseBaileyChartSpec, A as parseSseFrames, $ as resolveToolCall, Be as shouldUseGrid, ut as toActivityLines, dt as toToolSteps, ot as toTraceRows, ct as toTraceSegments, $e as traceEventArgsDetail, rt as traceEventHint, et as traceEventOutputDetail, nt as traceEventRawDetail, Qe as traceEventSummary, Ze as traceEventToolName, st as traceSummaryLine, V as useBaileyChat, pe as useBaileyConversations };