@icanbwell/baileyai-chat-ui 1.0.4 → 1.0.5

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.
@@ -5,23 +5,23 @@ import d from "remark-gfm";
5
5
  import * as f from "@radix-ui/react-tooltip";
6
6
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
7
7
  //#region src/utils/pseudoToolCalls.ts
8
- var g = /<(search_tools|call_tool|function_calls|function_result)>([\s\S]*?)<\/\1>/g, _ = /<name>([\s\S]*?)<\/name>/, v = /<arguments>([\s\S]*?)<\/arguments>/, y = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, b = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
- function x(e) {
10
- let t = _.exec(e)?.[1]?.trim() || "unknown_tool", n = v.exec(e)?.[1]?.trim();
8
+ var g = "search_tools|call_tool|function_calls|function_result", _ = RegExp(`<(${g})>([\\s\\S]*?)<\\/\\1>`, "g"), v = RegExp(`<(?:${g})>[\\s\\S]*$`), y = /<name>([\s\S]*?)<\/name>/, b = /<arguments>([\s\S]*?)<\/arguments>/, x = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, S = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
+ function C(e) {
10
+ let t = y.exec(e)?.[1]?.trim() || "unknown_tool", n = b.exec(e)?.[1]?.trim();
11
11
  return n ? {
12
12
  name: t,
13
13
  args: n
14
14
  } : { name: t };
15
15
  }
16
- function S(e) {
16
+ function w(e) {
17
17
  let t = [];
18
- y.lastIndex = 0;
18
+ x.lastIndex = 0;
19
19
  let n;
20
- for (; (n = y.exec(e)) !== null;) {
20
+ for (; (n = x.exec(e)) !== null;) {
21
21
  let [, e, r] = n, i = {};
22
- b.lastIndex = 0;
22
+ S.lastIndex = 0;
23
23
  let a;
24
- for (; (a = b.exec(r)) !== null;) i[a[1]] = a[2].trim();
24
+ for (; (a = S.exec(r)) !== null;) i[a[1]] = a[2].trim();
25
25
  let o = e.trim() || "unknown_tool";
26
26
  t.push(Object.keys(i).length > 0 ? {
27
27
  name: o,
@@ -30,25 +30,25 @@ function S(e) {
30
30
  }
31
31
  return t;
32
32
  }
33
- function C(e) {
34
- let t = [], n = e.replace(g, (e, n, r) => (n === "call_tool" ? t.push(x(r)) : n === "search_tools" ? t.push({
33
+ function T(e, t = {}) {
34
+ let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(_, (e, t, n) => (t === "call_tool" ? r.push(C(n)) : t === "search_tools" ? r.push({
35
35
  name: "search_tools",
36
- args: r.trim()
37
- }) : n === "function_calls" ? t.push(...S(r)) : t.push({
36
+ args: n.trim()
37
+ }) : t === "function_calls" ? r.push(...w(n)) : r.push({
38
38
  name: "function_result",
39
- args: r.trim()
40
- }), ""));
41
- return t.length === 0 ? {
42
- cleanedText: n,
43
- matches: t
39
+ args: n.trim()
40
+ }), "")), a = n ? i.replace(v, "") : i;
41
+ return r.length === 0 && a === i ? {
42
+ cleanedText: i,
43
+ matches: r
44
44
  } : {
45
- cleanedText: n.replace(/\n{3,}/g, "\n\n"),
46
- matches: t
45
+ cleanedText: a.replace(/\n{3,}/g, "\n\n"),
46
+ matches: r
47
47
  };
48
48
  }
49
49
  //#endregion
50
50
  //#region src/logic/sse.ts
51
- function w(e) {
51
+ function E(e) {
52
52
  if (!e.startsWith("data: ")) return e;
53
53
  let t = "";
54
54
  for (let n of e.split("\n")) {
@@ -62,7 +62,7 @@ function w(e) {
62
62
  }
63
63
  return t || null;
64
64
  }
65
- function T(e) {
65
+ function D(e) {
66
66
  let t = e.replace(/\r\n/g, "\n").split("\n\n"), n = t.pop() ?? "", r = [], i = !1;
67
67
  for (let e of t) {
68
68
  let t = e.split("\n").filter((e) => e.length > 0), n = "message", a = [];
@@ -87,7 +87,7 @@ function T(e) {
87
87
  message: e
88
88
  });
89
89
  } else if (c?.type === "response.output_text.delta" && typeof c.delta == "string") {
90
- let e = w(c.delta);
90
+ let e = E(c.delta);
91
91
  e && r.push({
92
92
  type: "response.output_text.delta",
93
93
  delta: e
@@ -105,42 +105,42 @@ function T(e) {
105
105
  }
106
106
  //#endregion
107
107
  //#region src/logic/useBaileyChat.ts
108
- var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, k = (e, t, n) => {
108
+ var O = 200, k = 15e4, A = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ee = (e, t, n) => {
109
109
  if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
110
110
  let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
111
- return i ? `${r} ${i.length > E ? `${i.slice(0, E)}…` : i}` : r;
112
- }, A = ({ transport: e, model: t, instructions: n, tools: i = [], toolChoice: o, firstUserMessagePrefix: s, onAssistantMessageComplete: u, idleTimeoutMs: d = D }) => {
113
- let [f, p] = l([]), [m, h] = l([]), [g, _] = l(null), [v, y] = l("idle"), [b, x] = l(null), S = c(null), w = c(""), E = c(0), A = c([]);
111
+ return i ? `${r} ${i.length > O ? `${i.slice(0, O)}…` : i}` : r;
112
+ }, j = ({ transport: e, model: t, instructions: n, tools: i = [], toolChoice: o, firstUserMessagePrefix: s, onAssistantMessageComplete: u, idleTimeoutMs: d = k }) => {
113
+ let [f, p] = l([]), [m, h] = l([]), [g, _] = l(null), [v, y] = l("idle"), [b, x] = l(null), S = c(null), C = c(""), w = c(0), E = c([]);
114
114
  a(() => {
115
- A.current = f;
115
+ E.current = f;
116
116
  }, [f]);
117
- let j = c([]), M = c(/* @__PURE__ */ new Map()), N = c(/* @__PURE__ */ new Map()), P = c(null), F = r(() => {
118
- P.current !== null && (clearTimeout(P.current), P.current = null);
119
- }, []), I = r((e) => {
120
- F(), P.current = setTimeout(() => {
117
+ let O = c([]), j = c(/* @__PURE__ */ new Map()), M = c(/* @__PURE__ */ new Map()), N = c(null), P = r(() => {
118
+ N.current !== null && (clearTimeout(N.current), N.current = null);
119
+ }, []), F = r((e) => {
120
+ P(), N.current = setTimeout(() => {
121
121
  e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
122
122
  }, d);
123
- }, [F, d]);
123
+ }, [P, d]);
124
124
  a(() => () => {
125
- S.current?.abort(), F();
126
- }, [F]);
127
- let L = r((e, t, n) => {
125
+ S.current?.abort(), P();
126
+ }, [P]);
127
+ let I = r((e, t, n) => {
128
128
  let r = (e) => {
129
129
  n.push(e), h((t) => [...t, e]);
130
130
  };
131
131
  if (t.type === "response.output_text.delta") {
132
132
  if (!t.delta) return !1;
133
- let n = M.current.get(e) ?? {
133
+ let n = j.current.get(e) ?? {
134
134
  raw: "",
135
135
  emittedCount: 0
136
136
  };
137
137
  n.raw += t.delta;
138
- let { cleanedText: i, matches: a } = C(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
139
- if (n.emittedCount = a.length, M.current.set(e, n), N.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
138
+ let { cleanedText: i, matches: a } = T(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
139
+ if (n.emittedCount = a.length, j.current.set(e, n), M.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
140
140
  ...t,
141
141
  content: o
142
142
  } : t)), s.length > 0) {
143
- let e = Date.now(), t = E.current;
143
+ let e = Date.now(), t = w.current;
144
144
  s.forEach((n) => r({
145
145
  kind: "pseudo_tool_call",
146
146
  name: n.name,
@@ -154,7 +154,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
154
154
  if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
155
155
  let e = t.item;
156
156
  if (e.type === "function_call" || e.type === "mcp_call") {
157
- let n = Date.now(), i = E.current, a = e.name || "unknown_tool";
157
+ let n = Date.now(), i = w.current, a = e.name || "unknown_tool";
158
158
  return r(t.type === "response.output_item.added" ? {
159
159
  kind: "tool_start",
160
160
  name: a,
@@ -174,36 +174,49 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
174
174
  }
175
175
  return !1;
176
176
  }
177
- return t.type === "task.progress" ? (r({
177
+ if (t.type === "task.progress") return r({
178
178
  kind: "progress",
179
179
  status: t.status,
180
180
  message: t.message,
181
181
  at: Date.now(),
182
- turnSentAt: E.current
183
- }), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
182
+ turnSentAt: w.current
183
+ }), !0;
184
+ if (t.type === "response.output_text.done" || t.type === "response.created") return !1;
185
+ if (t.type === "response.completed") {
186
+ let t = j.current.get(e);
187
+ if (t) {
188
+ let { cleanedText: n } = T(t.raw, { hideOpenBlock: !1 }), r = n.trim();
189
+ r !== M.current.get(e) && (M.current.set(e, r), p((t) => t.map((t) => t.id === e ? {
190
+ ...t,
191
+ content: r
192
+ } : t)));
193
+ }
194
+ return !1;
195
+ }
196
+ return t.type === "info" ? (r({
184
197
  kind: "info",
185
198
  message: t.message,
186
199
  at: Date.now(),
187
- turnSentAt: E.current
200
+ turnSentAt: w.current
188
201
  }), !0) : (r({
189
202
  kind: "raw",
190
203
  eventType: t.type,
191
204
  raw: JSON.stringify(t),
192
205
  at: Date.now(),
193
- turnSentAt: E.current
206
+ turnSentAt: w.current
194
207
  }), !0);
195
- }, []), R = r(async (r) => {
208
+ }, []), L = r(async (r) => {
196
209
  y("streaming"), x(null);
197
210
  let a = Date.now();
198
- E.current = a;
199
- let c = O(), l = {
211
+ w.current = a;
212
+ let c = A(), l = {
200
213
  id: c,
201
214
  role: "assistant",
202
215
  content: "",
203
216
  streaming: !0,
204
217
  createdAt: a
205
218
  };
206
- p((e) => [...e, l]), j.current = [...r, l];
219
+ p((e) => [...e, l]), O.current = [...r, l];
207
220
  let d = r.findIndex((e) => e.role === "user" && !e.hidden), f = r.map((e, t) => t === d && s ? {
208
221
  role: e.role,
209
222
  content: `${s}${e.content}`,
@@ -230,8 +243,8 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
230
243
  }
231
244
  });
232
245
  let m = new AbortController();
233
- S.current = m, I(m);
234
- let g = "", v = null, b = !1, C = !1, w = [], D = (e, t) => {
246
+ S.current = m, F(m);
247
+ let g = "", v = null, b = !1, C = !1, T = [], E = (e, t) => {
235
248
  y("error"), x(e);
236
249
  let n = {
237
250
  kind: "error",
@@ -240,8 +253,8 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
240
253
  turnSentAt: a,
241
254
  ...t
242
255
  };
243
- w.push(n), h((e) => [...e, n]);
244
- }, A = (e, t) => {
256
+ T.push(n), h((e) => [...e, n]);
257
+ }, k = (e, t) => {
245
258
  e.forEach((e) => {
246
259
  if (e.type === "error") {
247
260
  v = e.message;
@@ -251,10 +264,10 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
251
264
  at: Date.now(),
252
265
  turnSentAt: a
253
266
  };
254
- w.push(t), h((e) => [...e, t]);
267
+ T.push(t), h((e) => [...e, t]);
255
268
  return;
256
269
  }
257
- e.type === "response.output_text.delta" && e.delta && (C = !0), L(c, e, w) && (b = !0);
270
+ e.type === "response.output_text.delta" && e.delta && (C = !0), I(c, e, T) && (b = !0);
258
271
  }), t && p((e) => e.map((e) => e.id === c ? {
259
272
  ...e,
260
273
  streaming: !1
@@ -269,9 +282,9 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
269
282
  toolChoice: o,
270
283
  signal: m.signal,
271
284
  onChunk: (e) => {
272
- I(m), g += e;
273
- let { events: t, remainder: n, done: r } = T(g);
274
- g = n, A(t, r);
285
+ F(m), g += e;
286
+ let { events: t, remainder: n, done: r } = D(g);
287
+ g = n, k(t, r);
275
288
  let i = Date.now();
276
289
  _((e) => e && e.sentAt === a ? {
277
290
  ...e,
@@ -290,30 +303,30 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
290
303
  }
291
304
  });
292
305
  if (g.trim()) {
293
- let { events: e, done: t } = T(`${g}\n\n`);
294
- g = "", A(e, t);
306
+ let { events: e, done: t } = D(`${g}\n\n`);
307
+ g = "", k(e, t);
295
308
  }
296
309
  if (v) {
297
310
  y("error"), x(v);
298
311
  return;
299
312
  }
300
313
  if (r === void 0 || r >= 400) {
301
- D(k(r, s, l), {
314
+ E(ee(r, s, l), {
302
315
  httpStatus: r,
303
316
  rawBody: s || void 0
304
317
  });
305
318
  return;
306
319
  }
307
320
  if (!b) {
308
- D("Bailey returned an empty response.");
321
+ E("Bailey returned an empty response.");
309
322
  return;
310
323
  }
311
324
  if (!C) {
312
- D("Bailey ran some tools but didn't return an answer. Try asking again.");
325
+ E("Bailey ran some tools but didn't return an answer. Try asking again.");
313
326
  return;
314
327
  }
315
328
  y("idle");
316
- let d = N.current.get(c) ?? "";
329
+ let d = M.current.get(c) ?? "";
317
330
  _((e) => e && e.sentAt === a ? {
318
331
  ...e,
319
332
  response: { content: d }
@@ -322,25 +335,25 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
322
335
  role: "assistant",
323
336
  content: d,
324
337
  streaming: !1
325
- }, w);
338
+ }, T);
326
339
  } catch (e) {
327
340
  let t = e;
328
341
  if (t?.name === "TimeoutError") {
329
- D(t.message, { source: "client-timeout" });
342
+ E(t.message, { source: "client-timeout" });
330
343
  return;
331
344
  }
332
345
  if (t?.name === "AbortError") {
333
346
  y("idle");
334
347
  return;
335
348
  }
336
- D(t?.message || "Bailey request failed.");
349
+ E(t?.message || "Bailey request failed.");
337
350
  } finally {
338
- F();
339
- let e = N.current.get(c) ?? "";
340
- M.current.delete(c), N.current.delete(c), p((e) => e.flatMap((e) => e.id === c ? e.content ? [{
351
+ P();
352
+ let e = M.current.get(c) ?? "";
353
+ j.current.delete(c), M.current.delete(c), p((e) => e.flatMap((e) => e.id === c ? e.content ? [{
341
354
  ...e,
342
355
  streaming: !1
343
- }] : [] : [e])), j.current = j.current.flatMap((t) => t.id === c ? e ? [{
356
+ }] : [] : [e])), O.current = O.current.flatMap((t) => t.id === c ? e ? [{
344
357
  ...t,
345
358
  content: e,
346
359
  streaming: !1
@@ -354,11 +367,11 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
354
367
  o,
355
368
  s,
356
369
  u,
357
- L,
358
370
  I,
359
- F
360
- ]), z = r((e) => {
361
- A.current = e, p(e);
371
+ F,
372
+ P
373
+ ]), R = r((e) => {
374
+ E.current = e, p(e);
362
375
  }, []);
363
376
  return {
364
377
  messages: f,
@@ -369,42 +382,42 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
369
382
  send: r((e) => {
370
383
  let t = e.trim();
371
384
  if (!t) return;
372
- w.current = t;
385
+ C.current = t;
373
386
  let n = {
374
- id: O(),
387
+ id: A(),
375
388
  role: "user",
376
389
  content: t,
377
390
  createdAt: Date.now()
378
- }, r = [...j.current, n];
379
- j.current = r, z([...A.current, n]), R(r);
380
- }, [R, z]),
391
+ }, r = [...O.current, n];
392
+ O.current = r, R([...E.current, n]), L(r);
393
+ }, [L, R]),
381
394
  sendHidden: r((e, t) => {
382
395
  if (v === "streaming") return;
383
396
  let n = e.trim();
384
397
  if (!n) return;
385
- w.current = n;
398
+ C.current = n;
386
399
  let r = t?.trim(), i = {
387
- id: O(),
400
+ id: A(),
388
401
  role: "user",
389
402
  content: n,
390
403
  createdAt: Date.now(),
391
404
  hidden: !0,
392
405
  ...r ? { titleHint: r } : {}
393
- }, a = [...j.current, i];
394
- j.current = a, R(a);
395
- }, [R, v]),
406
+ }, a = [...O.current, i];
407
+ O.current = a, L(a);
408
+ }, [L, v]),
396
409
  stop: r(() => {
397
410
  S.current?.abort();
398
411
  }, []),
399
412
  retryLast: r(() => {
400
- if (v === "streaming" || !w.current) return;
401
- let e = A.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
402
- z(n);
403
- let r = j.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
404
- j.current = a, R(a);
413
+ if (v === "streaming" || !C.current) return;
414
+ let e = E.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
415
+ R(n);
416
+ let r = O.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
417
+ O.current = a, L(a);
405
418
  }, [
419
+ L,
406
420
  R,
407
- z,
408
421
  v
409
422
  ]),
410
423
  clearTrace: r(() => h([]), []),
@@ -412,29 +425,29 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
412
425
  x(null), y((e) => e === "error" ? "idle" : e);
413
426
  }, []),
414
427
  newChat: r(() => {
415
- S.current?.abort(), z([]), j.current = [], h([]), _(null), y("idle"), x(null), w.current = "";
416
- }, [z]),
428
+ S.current?.abort(), R([]), O.current = [], h([]), _(null), y("idle"), x(null), C.current = "";
429
+ }, [R]),
417
430
  loadMessages: r((e) => {
418
431
  S.current?.abort();
419
432
  let t = e.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
420
433
  ...e,
421
434
  streaming: !1
422
435
  }));
423
- z(t.filter((e) => !e.hidden)), j.current = t, h([]), _(null), y("idle"), x(null), w.current = "";
424
- }, [z])
436
+ R(t.filter((e) => !e.hidden)), O.current = t, h([]), _(null), y("idle"), x(null), C.current = "";
437
+ }, [R])
425
438
  };
426
439
  };
427
440
  //#endregion
428
441
  //#region src/utils/prompt.ts
429
- function j(...e) {
442
+ function M(...e) {
430
443
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
431
444
  }
432
445
  //#endregion
433
446
  //#region src/utils/toolCalls.ts
434
- var M = "call_tool", N = "a tool";
435
- function P(e, t) {
447
+ var N = "call_tool", P = "a tool";
448
+ function F(e, t) {
436
449
  let n = {
437
- name: e === M ? N : e,
450
+ name: e === N ? P : e,
438
451
  args: null,
439
452
  viaCallTool: !1
440
453
  };
@@ -447,7 +460,7 @@ function P(e, t) {
447
460
  }
448
461
  if (typeof r != "object" || !r) return n;
449
462
  let i = r;
450
- if (e === M) {
463
+ if (e === N) {
451
464
  let e = typeof i.name == "string" ? i.name : void 0;
452
465
  if (!e) return n;
453
466
  let t = i.arguments;
@@ -465,32 +478,32 @@ function P(e, t) {
465
478
  }
466
479
  //#endregion
467
480
  //#region src/utils/table.ts
468
- var F = 5, I = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(I).join(""), L = (e) => {
481
+ var I = 5, L = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(L).join(""), R = (e) => {
469
482
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
470
483
  for (let t of e.children ?? []) {
471
- let e = L(t);
484
+ let e = R(t);
472
485
  if (e) return e;
473
486
  }
474
- }, R = (e, t) => (e.children ?? []).find((e) => e.tagName === t), z = (e) => {
475
- let t = I(e), n = L(e);
487
+ }, z = (e, t) => (e.children ?? []).find((e) => e.tagName === t), B = (e) => {
488
+ let t = L(e), n = R(e);
476
489
  return n ? {
477
490
  text: t,
478
491
  href: n
479
492
  } : { text: t };
480
- }, B = (e) => (e.children ?? []).filter((e) => e.type === "element").map(z), V = (e) => {
493
+ }, V = (e) => (e.children ?? []).filter((e) => e.type === "element").map(B), H = (e) => {
481
494
  if (e.tagName !== "table") return null;
482
- let t = R(e, "thead"), n = t && R(t, "tr");
495
+ let t = z(e, "thead"), n = t && z(t, "tr");
483
496
  return {
484
- headers: n ? B(n).map((e) => e.text) : [],
485
- rows: (R(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(B)
497
+ headers: n ? V(n).map((e) => e.text) : [],
498
+ rows: (z(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(V)
486
499
  };
487
- }, H = (e) => e.length > 5, ee = "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```", U = [
500
+ }, U = (e) => e.length > 5, te = "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```", W = [
488
501
  "bar",
489
502
  "line",
490
503
  "pie",
491
504
  "doughnut",
492
505
  "scatter"
493
- ], te = 8, W = 50, G = 8, K = 500, ne = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", re = (e) => {
506
+ ], G = 8, K = 50, q = 8, ne = 500, re = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", ie = (e) => {
494
507
  let t;
495
508
  try {
496
509
  t = JSON.parse(e);
@@ -499,17 +512,17 @@ var F = 5, I = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
499
512
  }
500
513
  if (typeof t != "object" || !t) return null;
501
514
  let n = t;
502
- if (typeof n.type != "string" || !U.includes(n.type)) return null;
515
+ if (typeof n.type != "string" || !W.includes(n.type)) return null;
503
516
  let r = n.type;
504
517
  if (n.title !== void 0 && typeof n.title != "string") return null;
505
518
  let i = n.title;
506
519
  if (typeof n.data != "object" || n.data === null) return null;
507
520
  let a = n.data;
508
- if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > te || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
521
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > G || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
509
522
  for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
510
523
  let o = a.datasets;
511
524
  if (r === "scatter") {
512
- for (let e of o) if (e.data.length < 1 || e.data.length > K || !e.data.every(ne)) return null;
525
+ for (let e of o) if (e.data.length < 1 || e.data.length > ne || !e.data.every(re)) return null;
513
526
  return {
514
527
  type: r,
515
528
  title: i,
@@ -517,7 +530,7 @@ var F = 5, I = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
517
530
  };
518
531
  }
519
532
  if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
520
- let s = a.labels, c = r === "pie" || r === "doughnut" ? G : W;
533
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? q : K;
521
534
  if (s.length < 1 || s.length > c) return null;
522
535
  for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
523
536
  return {
@@ -528,7 +541,7 @@ var F = 5, I = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
528
541
  datasets: o
529
542
  }
530
543
  };
531
- }, ie = {
544
+ }, ae = {
532
545
  tool_start: "Tool start",
533
546
  tool_end: "Tool end",
534
547
  pseudo_tool_call: "Narrated tool call",
@@ -537,13 +550,13 @@ var F = 5, I = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
537
550
  error: "Error",
538
551
  raw: "Raw event"
539
552
  };
540
- function q(e) {
541
- return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : P(e.name, e.args);
553
+ function J(e) {
554
+ return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : F(e.name, e.args);
542
555
  }
543
- function J(e, t = q(e)) {
556
+ function Y(e, t = J(e)) {
544
557
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
545
558
  }
546
- function ae(e, t = q(e)) {
559
+ function oe(e, t = J(e)) {
547
560
  switch (e.kind) {
548
561
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
549
562
  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" : ""}`;
@@ -554,20 +567,20 @@ function ae(e, t = q(e)) {
554
567
  case "raw": return `Unrecognized event: ${e.eventType}`;
555
568
  }
556
569
  }
557
- function oe(e, t = q(e)) {
570
+ function se(e, t = J(e)) {
558
571
  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 : null;
559
572
  }
560
- function se(e) {
573
+ function ce(e) {
561
574
  return e.kind === "tool_end" ? e.output ?? null : null;
562
575
  }
563
- function ce(e) {
576
+ function le(e) {
564
577
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
565
578
  }
566
- function Y(e) {
579
+ function X(e) {
567
580
  switch (e.kind) {
568
- case "tool_start": return `Calling ${P(e.name, e.args).name}...`;
581
+ case "tool_start": return `Calling ${F(e.name, e.args).name}...`;
569
582
  case "tool_end": {
570
- let t = P(e.name, e.args).name;
583
+ let t = F(e.name, e.args).name;
571
584
  return e.isError ? `${t} failed` : `${t} returned`;
572
585
  }
573
586
  case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
@@ -577,11 +590,11 @@ function Y(e) {
577
590
  case "raw": return `Unrecognized event: ${e.eventType}`;
578
591
  }
579
592
  }
580
- function le(e) {
593
+ function ue(e) {
581
594
  let t = new Date(e);
582
595
  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")}`;
583
596
  }
584
- function ue(e) {
597
+ function de(e) {
585
598
  if (e <= 0) return "+0ms";
586
599
  if (e < 1e3) return `+${Math.round(e)}ms`;
587
600
  let t = e / 1e3;
@@ -589,30 +602,30 @@ function ue(e) {
589
602
  let n = Math.floor(t / 60), r = Math.round(t % 60);
590
603
  return `+${n}m${String(r).padStart(2, "0")}s`;
591
604
  }
592
- function de(e) {
605
+ function fe(e) {
593
606
  return e.map((t, n) => {
594
- let r = q(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
607
+ let r = J(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
595
608
  return {
596
609
  key: `${t.at}-${n}`,
597
610
  kind: t.kind,
598
- toolName: J(t, r),
611
+ toolName: Y(t, r),
599
612
  isToolStart: t.kind === "tool_start",
600
613
  failed: t.kind === "tool_end" && t.isError === !0,
601
- time: le(t.at),
614
+ time: ue(t.at),
602
615
  gapMs: t.at - i,
603
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ie[t.kind],
604
- summary: ae(t, r),
605
- argsDetail: oe(t, r),
606
- outputDetail: se(t),
607
- rawDetail: ce(t)
616
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ae[t.kind],
617
+ summary: oe(t, r),
618
+ argsDetail: se(t, r),
619
+ outputDetail: ce(t),
620
+ rawDetail: le(t)
608
621
  };
609
622
  });
610
623
  }
611
- function fe(e) {
624
+ function pe(e) {
612
625
  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 === "error"), i = [];
613
626
  return t.length > 0 && i.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), r.length > 0 && i.push(`${r.length} stream error${r.length === 1 ? "" : "s"}`), i.join(" · ");
614
627
  }
615
- function pe(e) {
628
+ function me(e) {
616
629
  let t = [];
617
630
  for (let n of e) {
618
631
  let e = t[t.length - 1];
@@ -631,57 +644,57 @@ function pe(e) {
631
644
  }
632
645
  return t;
633
646
  }
634
- function me(e) {
647
+ function he(e) {
635
648
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
636
649
  }
637
- function he(e, t) {
650
+ function ge(e, t) {
638
651
  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) => ({
639
652
  key: `${e.at}-${t}`,
640
- text: Y(e),
641
- toolName: J(e)
653
+ text: X(e),
654
+ toolName: Y(e)
642
655
  }));
643
656
  }
644
657
  //#endregion
645
658
  //#region src/styles.css?inline
646
- var ge = "/*! 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}}}@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-100:oklch(93.6% .032 17.717);--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-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-700:oklch(37.3% .034 259.733);--color-black:#000;--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-2xl:1rem;--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}.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-toolbar-row{justify-content:flex-end;align-items:center;gap:calc(var(--spacing) * 3);display:flex}.bailey-new-chat-button{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-new-chat-button:hover{text-decoration-line:underline}}.bailey-new-chat-button:disabled{cursor:default;opacity:.5;text-decoration-line:none}.bailey-history-button{height:calc(var(--spacing) * 8);width:calc(var(--spacing) * 8);color:var(--color-gray-700);border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-button:hover{background-color:var(--color-gray-100)}}.bailey-history-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.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-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);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-activity-line{margin-bottom:calc(var(--spacing) * 2);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-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-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);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;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-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)}@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}", _e = t(void 0), ve = /:root\s*,\s*:host\s*\{/, ye = ".bailey-chat-panel{";
647
- function be(e) {
648
- let t = e.match(new RegExp(ve, "g"))?.length ?? 0;
659
+ var _e = "/*! 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}}}@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-100:oklch(93.6% .032 17.717);--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-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-700:oklch(37.3% .034 259.733);--color-black:#000;--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-2xl:1rem;--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}.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-toolbar-row{justify-content:flex-end;align-items:center;gap:calc(var(--spacing) * 3);display:flex}.bailey-new-chat-button{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-new-chat-button:hover{text-decoration-line:underline}}.bailey-new-chat-button:disabled{cursor:default;opacity:.5;text-decoration-line:none}.bailey-history-button{height:calc(var(--spacing) * 8);width:calc(var(--spacing) * 8);color:var(--color-gray-700);border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-button:hover{background-color:var(--color-gray-100)}}.bailey-history-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.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-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);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-activity-line{margin-bottom:calc(var(--spacing) * 2);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-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-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);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;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-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)}@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}", ve = t(void 0), ye = /:root\s*,\s*:host\s*\{/, be = ".bailey-chat-panel{";
660
+ function xe(e) {
661
+ let t = e.match(new RegExp(ye, "g"))?.length ?? 0;
649
662
  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.`);
650
- return e.replace(ve, ye);
663
+ return e.replace(ye, be);
651
664
  }
652
- var xe = be(ge), X = "data-source", Z = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
653
- function Se(e) {
665
+ var Se = xe(_e), Z = "data-source", Ce = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
666
+ function we(e) {
654
667
  let t = e.getRootNode();
655
668
  return t instanceof ShadowRoot ? t : document;
656
669
  }
657
- function Ce(e) {
670
+ function Te(e) {
658
671
  let t = e instanceof ShadowRoot ? e : document.head, n = Q.get(e) ?? 0;
659
- if (n === 0 && !t.querySelector(`style[${X}="${Z}"]`)) {
672
+ if (n === 0 && !t.querySelector(`style[${Z}="${Ce}"]`)) {
660
673
  let e = document.createElement("style");
661
- e.setAttribute(X, Z), e.textContent = xe, t.appendChild(e);
674
+ e.setAttribute(Z, Ce), e.textContent = Se, t.appendChild(e);
662
675
  }
663
676
  return Q.set(e, n + 1), () => {
664
677
  let n = (Q.get(e) ?? 1) - 1;
665
- n <= 0 ? (Q.delete(e), t.querySelector(`style[${X}="${Z}"]`)?.remove()) : Q.set(e, n);
678
+ n <= 0 ? (Q.delete(e), t.querySelector(`style[${Z}="${Ce}"]`)?.remove()) : Q.set(e, n);
666
679
  };
667
680
  }
668
- function we(e, t = !1) {
681
+ function Ee(e, t = !1) {
669
682
  let [n, r] = l(null);
670
683
  return o(() => {
671
684
  if (t) return;
672
685
  let n = e.current;
673
686
  if (!n) return;
674
- let i = Se(n);
675
- return r(i), Ce(i);
687
+ let i = we(n);
688
+ return r(i), Te(i);
676
689
  }, [t, e]), n;
677
690
  }
678
- function Te(e) {
679
- let t = i(_e), n = t !== void 0, r = we(e, n);
691
+ function De(e) {
692
+ let t = i(ve), n = t !== void 0, r = Ee(e, n);
680
693
  return n ? t : r;
681
694
  }
682
695
  //#endregion
683
696
  //#region src/ui/markdown.tsx
684
- function Ee({ renderTable: t, renderChart: n } = {}) {
697
+ function Oe({ renderTable: t, renderChart: n } = {}) {
685
698
  return {
686
699
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ m(p, { children: n }) : /* @__PURE__ */ m("a", {
687
700
  href: t,
@@ -690,8 +703,8 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
690
703
  children: n
691
704
  }),
692
705
  table: ({ node: n, children: r }) => {
693
- let i = n && V(n);
694
- if (i && H(i.rows) && t) {
706
+ let i = n && H(n);
707
+ if (i && U(i.rows) && t) {
695
708
  let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
696
709
  return /* @__PURE__ */ m(p, { children: t({
697
710
  headers: i.headers,
@@ -703,7 +716,7 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
703
716
  pre: ({ children: e }) => {
704
717
  let t = (Array.isArray(e) ? e[0] : e)?.props;
705
718
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
706
- let e = t?.children, r = re(Array.isArray(e) ? e.join("") : String(e ?? ""));
719
+ let e = t?.children, r = ie(Array.isArray(e) ? e.join("") : String(e ?? ""));
707
720
  if (r) return /* @__PURE__ */ m(p, { children: n(r) });
708
721
  }
709
722
  return /* @__PURE__ */ m("pre", { children: e });
@@ -712,7 +725,7 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
712
725
  }
713
726
  //#endregion
714
727
  //#region src/ui/icons.tsx
715
- function De({ className: e }) {
728
+ function ke({ className: e }) {
716
729
  return /* @__PURE__ */ m("svg", {
717
730
  viewBox: "0 0 24 24",
718
731
  fill: "currentColor",
@@ -721,7 +734,7 @@ function De({ className: e }) {
721
734
  children: /* @__PURE__ */ m("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" })
722
735
  });
723
736
  }
724
- function Oe({ className: e }) {
737
+ function Ae({ className: e }) {
725
738
  return /* @__PURE__ */ m("svg", {
726
739
  viewBox: "0 0 24 24",
727
740
  fill: "currentColor",
@@ -736,7 +749,7 @@ function Oe({ className: e }) {
736
749
  })
737
750
  });
738
751
  }
739
- function ke({ className: e }) {
752
+ function je({ className: e }) {
740
753
  return /* @__PURE__ */ h("svg", {
741
754
  viewBox: "0 0 24 24",
742
755
  fill: "none",
@@ -749,7 +762,7 @@ function ke({ className: e }) {
749
762
  children: [/* @__PURE__ */ m("path", { d: "M7 17 17 7" }), /* @__PURE__ */ m("path", { d: "M9 7h8v8" })]
750
763
  });
751
764
  }
752
- function Ae({ className: e }) {
765
+ function Me({ className: e }) {
753
766
  return /* @__PURE__ */ h("svg", {
754
767
  viewBox: "0 0 24 24",
755
768
  fill: "none",
@@ -768,7 +781,7 @@ function Ae({ className: e }) {
768
781
  }), /* @__PURE__ */ m("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
769
782
  });
770
783
  }
771
- function je({ className: e }) {
784
+ function Ne({ className: e }) {
772
785
  return /* @__PURE__ */ m("svg", {
773
786
  viewBox: "0 0 24 24",
774
787
  fill: "none",
@@ -781,7 +794,7 @@ function je({ className: e }) {
781
794
  children: /* @__PURE__ */ m("path", { d: "M5 12.5 9.5 17 19 7" })
782
795
  });
783
796
  }
784
- function Me({ className: e }) {
797
+ function Pe({ className: e }) {
785
798
  return /* @__PURE__ */ m("svg", {
786
799
  viewBox: "0 0 24 24",
787
800
  fill: "none",
@@ -794,7 +807,7 @@ function Me({ className: e }) {
794
807
  children: /* @__PURE__ */ m("path", { d: "m22.7 13.5-2-2-2 2M21 12a9 9 0 1 1-1.245-4.57M12 7v5l3 2" })
795
808
  });
796
809
  }
797
- function Ne({ className: e }) {
810
+ function Fe({ className: e }) {
798
811
  return /* @__PURE__ */ h("svg", {
799
812
  viewBox: "0 0 24 24",
800
813
  fill: "none",
@@ -813,9 +826,9 @@ function Ne({ className: e }) {
813
826
  }
814
827
  //#endregion
815
828
  //#region src/ui/CopyMarkdownButton.tsx
816
- var Pe = 1500;
817
- function Fe({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
818
- let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = Te(g);
829
+ var Ie = 1500;
830
+ function Le({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
831
+ let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = De(g);
819
832
  return a(() => () => {
820
833
  p.current !== null && clearTimeout(p.current);
821
834
  }, []), /* @__PURE__ */ m(f.Provider, {
@@ -834,11 +847,11 @@ function Fe({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
834
847
  } catch {
835
848
  return;
836
849
  }
837
- s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Pe);
850
+ s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Ie);
838
851
  },
839
852
  "aria-label": n,
840
853
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
841
- children: m(o ? je : Ae, { className: "bailey-copy-icon" })
854
+ children: m(o ? Ne : Me, { className: "bailey-copy-icon" })
842
855
  })
843
856
  }), /* @__PURE__ */ m(f.Portal, {
844
857
  container: _ instanceof ShadowRoot ? _ : void 0,
@@ -853,20 +866,20 @@ function Fe({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
853
866
  }
854
867
  //#endregion
855
868
  //#region src/ui/BaileyTracePanel.tsx
856
- async function Ie(e) {
869
+ async function Re(e) {
857
870
  try {
858
871
  await navigator.clipboard.writeText(e);
859
872
  } catch {}
860
873
  }
861
- function Le({ text: e, label: t = "Copy" }) {
874
+ function ze({ text: e, label: t = "Copy" }) {
862
875
  return /* @__PURE__ */ m("button", {
863
876
  type: "button",
864
- onClick: () => Ie(e),
877
+ onClick: () => Re(e),
865
878
  className: "bailey-trace-copy-button",
866
879
  children: t
867
880
  });
868
881
  }
869
- function Re(e) {
882
+ function Be(e) {
870
883
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
871
884
  switch (e.kind) {
872
885
  case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
@@ -885,7 +898,7 @@ function $({ label: e, content: t, copyable: n }) {
885
898
  }),
886
899
  n && /* @__PURE__ */ m("div", {
887
900
  className: "bailey-trace-disclosure-actions",
888
- children: /* @__PURE__ */ m(Le, { text: t })
901
+ children: /* @__PURE__ */ m(ze, { text: t })
889
902
  }),
890
903
  /* @__PURE__ */ m("pre", {
891
904
  className: "bailey-trace-disclosure-content",
@@ -894,7 +907,7 @@ function $({ label: e, content: t, copyable: n }) {
894
907
  ]
895
908
  });
896
909
  }
897
- function ze({ row: e }) {
910
+ function Ve({ row: e }) {
898
911
  return /* @__PURE__ */ h("div", {
899
912
  className: "bailey-trace-row",
900
913
  children: [
@@ -908,10 +921,10 @@ function ze({ row: e }) {
908
921
  /* @__PURE__ */ m("span", {
909
922
  className: "bailey-trace-row-gap",
910
923
  title: "Time since the previous event",
911
- children: ue(e.gapMs)
924
+ children: de(e.gapMs)
912
925
  }),
913
926
  /* @__PURE__ */ m("span", {
914
- className: Re(e),
927
+ className: Be(e),
915
928
  children: e.label
916
929
  }),
917
930
  /* @__PURE__ */ m("span", {
@@ -935,13 +948,13 @@ function ze({ row: e }) {
935
948
  ]
936
949
  });
937
950
  }
938
- function Be(e, t) {
951
+ function He(e, t) {
939
952
  if (e.chunkCount === 0) return "Streamed: no chunks received";
940
953
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
941
954
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
942
955
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
943
956
  }
944
- function Ve({ request: e }) {
957
+ function Ue({ request: e }) {
945
958
  let t = s(() => JSON.stringify({
946
959
  model: e.model,
947
960
  instructions: e.systemPrompt,
@@ -965,7 +978,7 @@ function Ve({ request: e }) {
965
978
  }),
966
979
  /* @__PURE__ */ m("span", {
967
980
  className: "bailey-trace-request-meta",
968
- children: Be(e.streamStats, e.sentAt)
981
+ children: He(e.streamStats, e.sentAt)
969
982
  }),
970
983
  /* @__PURE__ */ m($, {
971
984
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
@@ -990,14 +1003,14 @@ function Ve({ request: e }) {
990
1003
  ]
991
1004
  });
992
1005
  }
993
- function He({ events: e, lastRequest: t, onClear: n }) {
994
- let r = s(() => de(e), [e]), i = s(() => pe(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
1006
+ function We({ events: e, lastRequest: t, onClear: n }) {
1007
+ let r = s(() => fe(e), [e]), i = s(() => me(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
995
1008
  return /* @__PURE__ */ h("div", {
996
1009
  className: "bailey-trace-body",
997
1010
  children: [
998
1011
  /* @__PURE__ */ h("div", {
999
1012
  className: "bailey-trace-actions-row",
1000
- children: [e.length > 0 && /* @__PURE__ */ m(Le, {
1013
+ children: [e.length > 0 && /* @__PURE__ */ m(ze, {
1001
1014
  text: a,
1002
1015
  label: "Copy trace as JSON"
1003
1016
  }), /* @__PURE__ */ m("button", {
@@ -1007,15 +1020,15 @@ function He({ events: e, lastRequest: t, onClear: n }) {
1007
1020
  children: "Clear"
1008
1021
  })]
1009
1022
  }),
1010
- t && /* @__PURE__ */ m(Ve, { request: t }),
1023
+ t && /* @__PURE__ */ m(Ue, { request: t }),
1011
1024
  /* @__PURE__ */ m("div", {
1012
1025
  className: "bailey-trace-rows",
1013
1026
  children: i.map((e, t) => {
1014
- if (e.type === "single") return /* @__PURE__ */ m(ze, { row: e.row }, e.row.key);
1027
+ if (e.type === "single") return /* @__PURE__ */ m(Ve, { row: e.row }, e.row.key);
1015
1028
  let n = e.rows.filter((e) => e.isToolStart).length;
1016
1029
  if (n <= 1) return /* @__PURE__ */ m("div", {
1017
1030
  className: "bailey-trace-rows",
1018
- children: e.rows.map((e) => /* @__PURE__ */ m(ze, { row: e }, e.key))
1031
+ children: e.rows.map((e) => /* @__PURE__ */ m(Ve, { row: e }, e.key))
1019
1032
  }, `group-${t}`);
1020
1033
  let r = e.rows.filter((e) => e.failed).length;
1021
1034
  return /* @__PURE__ */ h("details", {
@@ -1037,7 +1050,7 @@ function He({ events: e, lastRequest: t, onClear: n }) {
1037
1050
  ]
1038
1051
  }), /* @__PURE__ */ m("div", {
1039
1052
  className: "bailey-trace-rows",
1040
- children: e.rows.map((e) => /* @__PURE__ */ m(ze, { row: e }, e.key))
1053
+ children: e.rows.map((e) => /* @__PURE__ */ m(Ve, { row: e }, e.key))
1041
1054
  })]
1042
1055
  }, `group-${t}`);
1043
1056
  })
@@ -1045,8 +1058,8 @@ function He({ events: e, lastRequest: t, onClear: n }) {
1045
1058
  ]
1046
1059
  });
1047
1060
  }
1048
- function Ue({ events: e, lastRequest: t, onClear: n }) {
1049
- let [r, i] = l(!1), a = s(() => me(e), [e]), o = s(() => fe(e), [e]);
1061
+ function Ge({ events: e, lastRequest: t, onClear: n }) {
1062
+ let [r, i] = l(!1), a = s(() => he(e), [e]), o = s(() => pe(e), [e]);
1050
1063
  return e.length === 0 && !t ? null : /* @__PURE__ */ h("div", {
1051
1064
  className: "bailey-trace-panel",
1052
1065
  children: [/* @__PURE__ */ h("div", {
@@ -1067,7 +1080,7 @@ function Ue({ events: e, lastRequest: t, onClear: n }) {
1067
1080
  className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
1068
1081
  children: o
1069
1082
  })]
1070
- }), r && /* @__PURE__ */ m(He, {
1083
+ }), r && /* @__PURE__ */ m(We, {
1071
1084
  events: e,
1072
1085
  lastRequest: t,
1073
1086
  onClear: n
@@ -1076,7 +1089,7 @@ function Ue({ events: e, lastRequest: t, onClear: n }) {
1076
1089
  }
1077
1090
  //#endregion
1078
1091
  //#region src/ui/BaileyChatPanel.tsx
1079
- var We = "How can bailey AI help you today?", Ge = "Reply to bailey AI", Ke = {
1092
+ var Ke = "How can bailey AI help you today?", qe = "Reply to bailey AI", Je = {
1080
1093
  newChatButtonText: "New chat",
1081
1094
  newChatAriaLabel: "new chat",
1082
1095
  historyAriaLabel: "conversation history",
@@ -1092,46 +1105,46 @@ var We = "How can bailey AI help you today?", Ge = "Reply to bailey AI", Ke = {
1092
1105
  copyButtonAriaLabel: "copy response as markdown",
1093
1106
  copyButtonTooltipDefault: "Copy as markdown",
1094
1107
  copyButtonTooltipCopied: "Copied!"
1095
- }, qe = [d], Je = {
1096
- ...Ee(),
1108
+ }, Ye = [d], Xe = {
1109
+ ...Oe(),
1097
1110
  p: ({ children: e }) => /* @__PURE__ */ m(p, { children: e })
1098
- }, Ye = n(function({ content: e, components: t }) {
1111
+ }, Ze = n(function({ content: e, components: t }) {
1099
1112
  return /* @__PURE__ */ m("div", {
1100
1113
  className: "bailey-markdown-content",
1101
1114
  children: /* @__PURE__ */ m(u, {
1102
- remarkPlugins: qe,
1115
+ remarkPlugins: Ye,
1103
1116
  components: t,
1104
1117
  skipHtml: !0,
1105
1118
  children: e
1106
1119
  })
1107
1120
  });
1108
1121
  });
1109
- function Xe(e, t, n) {
1122
+ function Qe(e, t, n) {
1110
1123
  if (e !== "streaming") return;
1111
1124
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
1112
- if (r.length !== 0) return Y(r[r.length - 1]);
1125
+ if (r.length !== 0) return X(r[r.length - 1]);
1113
1126
  }
1114
- function Ze(e) {
1127
+ function $e(e) {
1115
1128
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
1116
1129
  hour: "numeric",
1117
1130
  minute: "2-digit"
1118
1131
  });
1119
1132
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
1120
1133
  }
1121
- function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholder: r, suggestions: i, onHistoryClick: o, privacyNote: d, resolveActivityIcon: p, className: g, height: _, width: v, hideDeveloperDetails: y = !1, renderMessageActions: b, renderTable: x, renderChart: S, labels: C, formatMessageTime: w }) {
1122
- let { messages: T, traceEvents: E, lastRequest: D, status: O, error: k, send: A, stop: j, retryLast: M, clearTrace: N, clearError: P, newChat: F } = e, [I, L] = l(""), R = {
1123
- ...Ke,
1134
+ function et({ chat: e, placeholder: t, replyPlaceholder: n = qe, emptyPlaceholder: r, suggestions: i, onHistoryClick: o, privacyNote: d, resolveActivityIcon: p, className: g, height: _, width: v, hideDeveloperDetails: y = !1, renderMessageActions: b, renderTable: x, renderChart: S, labels: C, formatMessageTime: w }) {
1135
+ let { messages: T, traceEvents: E, lastRequest: D, status: O, error: k, send: A, stop: ee, retryLast: j, clearTrace: M, clearError: N, newChat: P } = e, [F, I] = l(""), L = {
1136
+ ...Je,
1124
1137
  ...C
1125
- }, z = w ?? Ze, B = c(null), V = we(B), H = c(null), ee = c(null), U = c(!0), te = s(() => Ee({
1138
+ }, R = w ?? $e, z = c(null), B = Ee(z), V = c(null), H = c(null), U = c(!0), te = s(() => Oe({
1126
1139
  renderTable: x,
1127
1140
  renderChart: S
1128
- }), [x, S]), W = s(() => Xe(O, E, D), [
1141
+ }), [x, S]), W = s(() => Qe(O, E, D), [
1129
1142
  O,
1130
1143
  E,
1131
1144
  D
1132
- ]), G = T.length === 0, K = t ?? (G ? r ?? We : n);
1145
+ ]), G = T.length === 0, K = t ?? (G ? r ?? Ke : n);
1133
1146
  a(() => {
1134
- let e = ee.current;
1147
+ let e = H.current;
1135
1148
  if (!e) return;
1136
1149
  let t = () => {
1137
1150
  let t = e.scrollHeight - e.scrollTop - e.clientHeight;
@@ -1139,18 +1152,18 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1139
1152
  };
1140
1153
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1141
1154
  }, []), a(() => {
1142
- U.current && H.current?.scrollIntoView({
1155
+ U.current && V.current?.scrollIntoView({
1143
1156
  behavior: O === "streaming" ? "auto" : "smooth",
1144
1157
  block: "nearest"
1145
1158
  });
1146
1159
  }, [T, O]);
1147
- let ne = (e) => {
1160
+ let q = (e) => {
1148
1161
  U.current = !0, A(e);
1149
1162
  };
1150
- return /* @__PURE__ */ m(_e.Provider, {
1151
- value: V,
1163
+ return /* @__PURE__ */ m(ve.Provider, {
1164
+ value: B,
1152
1165
  children: /* @__PURE__ */ m("div", {
1153
- ref: B,
1166
+ ref: z,
1154
1167
  className: `bailey-chat-panel${g ? ` ${g}` : ""}`,
1155
1168
  style: _ !== void 0 || v !== void 0 ? {
1156
1169
  height: _,
@@ -1163,39 +1176,39 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1163
1176
  className: "bailey-toolbar-row",
1164
1177
  children: [!G && /* @__PURE__ */ m("button", {
1165
1178
  type: "button",
1166
- onClick: F,
1167
- "aria-label": R.newChatAriaLabel,
1179
+ onClick: P,
1180
+ "aria-label": L.newChatAriaLabel,
1168
1181
  className: "bailey-new-chat-button",
1169
- children: R.newChatButtonText
1182
+ children: L.newChatButtonText
1170
1183
  }), o && /* @__PURE__ */ m("button", {
1171
1184
  type: "button",
1172
1185
  onClick: o,
1173
- "aria-label": R.historyAriaLabel,
1186
+ "aria-label": L.historyAriaLabel,
1174
1187
  className: "bailey-history-button",
1175
- children: /* @__PURE__ */ m(Me, { className: "bailey-history-icon" })
1188
+ children: /* @__PURE__ */ m(Pe, { className: "bailey-history-icon" })
1176
1189
  })]
1177
1190
  }),
1178
1191
  /* @__PURE__ */ h("div", {
1179
1192
  className: "bailey-chat-transcript",
1180
- ref: ee,
1193
+ ref: H,
1181
1194
  children: [
1182
1195
  G && (i && i.length > 0 ? /* @__PURE__ */ h("div", {
1183
1196
  className: "bailey-suggestions",
1184
1197
  children: [/* @__PURE__ */ m("div", {
1185
1198
  className: "bailey-suggestions-title",
1186
- children: R.suggestionsTitle
1199
+ children: L.suggestionsTitle
1187
1200
  }), i.map((e, t) => /* @__PURE__ */ h("button", {
1188
1201
  type: "button",
1189
- onClick: () => ne(e.value ?? e.label),
1202
+ onClick: () => q(e.value ?? e.label),
1190
1203
  className: "bailey-suggestion-card",
1191
- children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(ke, { className: "bailey-suggestion-icon" })]
1204
+ children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(je, { className: "bailey-suggestion-icon" })]
1192
1205
  }, `${e.label}-${t}`))]
1193
1206
  }) : /* @__PURE__ */ m("div", {
1194
1207
  className: "bailey-empty-state",
1195
- children: R.emptyStateMessage
1208
+ children: L.emptyStateMessage
1196
1209
  })),
1197
1210
  T.map((e, t) => {
1198
- let n = e.role === "assistant" && t === T.length - 1, r = O === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? he(E, e.createdAt) : [], a = i[i.length - 1];
1211
+ let n = e.role === "assistant" && t === T.length - 1, r = O === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? ge(E, e.createdAt) : [], a = i[i.length - 1];
1199
1212
  return /* @__PURE__ */ m("div", {
1200
1213
  className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1201
1214
  children: e.role === "user" ? /* @__PURE__ */ h("div", {
@@ -1204,15 +1217,15 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1204
1217
  className: "bailey-message-meta",
1205
1218
  children: [/* @__PURE__ */ m("span", {
1206
1219
  className: "bailey-message-meta-name",
1207
- children: R.youLabel
1208
- }), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: z(e.createdAt) })]
1220
+ children: L.youLabel
1221
+ }), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: R(e.createdAt) })]
1209
1222
  }), /* @__PURE__ */ m("div", {
1210
1223
  className: "bailey-user-bubble",
1211
1224
  children: e.content
1212
1225
  })]
1213
1226
  }) : r ? /* @__PURE__ */ m("div", {
1214
1227
  className: "bailey-thinking-hint",
1215
- children: W ?? R.thinkingHint
1228
+ children: W ?? L.thinkingHint
1216
1229
  }) : /* @__PURE__ */ h("div", {
1217
1230
  className: "bailey-assistant-message",
1218
1231
  children: [
@@ -1220,10 +1233,10 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1220
1233
  className: "bailey-activity-line",
1221
1234
  children: [/* @__PURE__ */ m("span", {
1222
1235
  className: "bailey-activity-icon",
1223
- children: p?.(a.toolName) ?? /* @__PURE__ */ m(Ne, {})
1236
+ children: p?.(a.toolName) ?? /* @__PURE__ */ m(Fe, {})
1224
1237
  }), /* @__PURE__ */ m("span", { children: a.text })]
1225
1238
  }),
1226
- /* @__PURE__ */ m(Ye, {
1239
+ /* @__PURE__ */ m(Ze, {
1227
1240
  content: e.content,
1228
1241
  components: te
1229
1242
  }),
@@ -1233,18 +1246,18 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1233
1246
  }),
1234
1247
  !e.streaming && /* @__PURE__ */ h("div", {
1235
1248
  className: "bailey-message-actions",
1236
- children: [/* @__PURE__ */ m(Fe, {
1249
+ children: [/* @__PURE__ */ m(Le, {
1237
1250
  markdown: e.content,
1238
- ariaLabel: R.copyButtonAriaLabel,
1239
- tooltipDefaultText: R.copyButtonTooltipDefault,
1240
- tooltipCopiedText: R.copyButtonTooltipCopied
1251
+ ariaLabel: L.copyButtonAriaLabel,
1252
+ tooltipDefaultText: L.copyButtonTooltipDefault,
1253
+ tooltipCopiedText: L.copyButtonTooltipCopied
1241
1254
  }), b?.(e)]
1242
1255
  })
1243
1256
  ]
1244
1257
  })
1245
1258
  }, e.id);
1246
1259
  }),
1247
- /* @__PURE__ */ m("div", { ref: H })
1260
+ /* @__PURE__ */ m("div", { ref: V })
1248
1261
  ]
1249
1262
  }),
1250
1263
  k && /* @__PURE__ */ h("div", {
@@ -1254,34 +1267,34 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1254
1267
  className: "bailey-error-actions",
1255
1268
  children: [/* @__PURE__ */ m("button", {
1256
1269
  type: "button",
1257
- onClick: M,
1270
+ onClick: j,
1258
1271
  className: "bailey-retry-button",
1259
- children: R.retryButtonText
1272
+ children: L.retryButtonText
1260
1273
  }), /* @__PURE__ */ m("button", {
1261
1274
  type: "button",
1262
- onClick: P,
1263
- "aria-label": R.dismissErrorAriaLabel,
1275
+ onClick: N,
1276
+ "aria-label": L.dismissErrorAriaLabel,
1264
1277
  className: "bailey-dismiss-button",
1265
1278
  children: "✕"
1266
1279
  })]
1267
1280
  })]
1268
1281
  }),
1269
- !y && /* @__PURE__ */ m(Ue, {
1282
+ !y && /* @__PURE__ */ m(Ge, {
1270
1283
  events: E,
1271
1284
  lastRequest: D,
1272
- onClear: N
1285
+ onClear: M
1273
1286
  }),
1274
1287
  /* @__PURE__ */ h("form", {
1275
1288
  onSubmit: (e) => {
1276
- e.preventDefault(), !(!I.trim() || O === "streaming") && (ne(I), L(""));
1289
+ e.preventDefault(), !(!F.trim() || O === "streaming") && (q(F), I(""));
1277
1290
  },
1278
1291
  className: "bailey-input-row",
1279
1292
  children: [/* @__PURE__ */ m("input", {
1280
1293
  type: "text",
1281
1294
  placeholder: K,
1282
1295
  "aria-label": K,
1283
- value: I,
1284
- onChange: (e) => L(e.target.value),
1296
+ value: F,
1297
+ onChange: (e) => I(e.target.value),
1285
1298
  disabled: O === "streaming",
1286
1299
  className: "bailey-input"
1287
1300
  }), O === "streaming" ? /* @__PURE__ */ m(f.Provider, {
@@ -1290,32 +1303,32 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1290
1303
  asChild: !0,
1291
1304
  children: /* @__PURE__ */ m("button", {
1292
1305
  type: "button",
1293
- onClick: j,
1294
- "aria-label": R.stopAriaLabel,
1306
+ onClick: ee,
1307
+ "aria-label": L.stopAriaLabel,
1295
1308
  className: "bailey-stop-button",
1296
- children: /* @__PURE__ */ m(Oe, { className: "bailey-stop-icon" })
1309
+ children: /* @__PURE__ */ m(Ae, { className: "bailey-stop-icon" })
1297
1310
  })
1298
1311
  }), /* @__PURE__ */ m(f.Portal, {
1299
- container: V instanceof ShadowRoot ? V : void 0,
1312
+ container: B instanceof ShadowRoot ? B : void 0,
1300
1313
  children: /* @__PURE__ */ h(f.Content, {
1301
1314
  side: "top",
1302
1315
  className: "bailey-tooltip-content",
1303
- children: [R.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
1316
+ children: [L.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
1304
1317
  })
1305
1318
  })] })
1306
1319
  }) : /* @__PURE__ */ m("button", {
1307
1320
  type: "submit",
1308
- "aria-label": R.sendAriaLabel,
1309
- disabled: !I.trim(),
1321
+ "aria-label": L.sendAriaLabel,
1322
+ disabled: !F.trim(),
1310
1323
  className: "bailey-send-button",
1311
- children: /* @__PURE__ */ m(De, { className: "bailey-send-icon" })
1324
+ children: /* @__PURE__ */ m(ke, { className: "bailey-send-icon" })
1312
1325
  })]
1313
1326
  }),
1314
1327
  (G || d?.alwaysVisible) && d && /* @__PURE__ */ m("div", {
1315
1328
  className: "bailey-privacy-note",
1316
1329
  children: /* @__PURE__ */ m(u, {
1317
- remarkPlugins: qe,
1318
- components: Je,
1330
+ remarkPlugins: Ye,
1331
+ components: Xe,
1319
1332
  skipHtml: !0,
1320
1333
  children: d.markdown
1321
1334
  })
@@ -1327,6 +1340,6 @@ function Qe({ chat: e, placeholder: t, replyPlaceholder: n = Ge, emptyPlaceholde
1327
1340
  }
1328
1341
  //#endregion
1329
1342
  //#region src/index.ts
1330
- var $e = "0.3.1-pre.2";
1343
+ var tt = "0.3.1-pre.2";
1331
1344
  //#endregion
1332
- export { Ne as ActivityIcon, ke as ArrowUpRightIcon, $e as BAILEYAI_CHAT_UI_VERSION, ee as BAILEY_CHART_PROMPT_FRAGMENT, F as BAILEY_TABLE_GRID_ROW_THRESHOLD, Qe as BaileyChatPanel, Ue as BaileyTracePanel, Fe as CopyMarkdownButton, De as HeartIcon, ie as TRACE_KIND_LABEL, Ee as createBaileyMarkdownComponents, C as extractPseudoToolCalls, V as extractTableData, ue as formatTraceGap, le as formatTraceTime, me as hasTraceFailure, e as isSafeMarkdownUrl, j as joinInstructions, re as parseBaileyChartSpec, T as parseSseFrames, P as resolveToolCall, H as shouldUseGrid, he as toActivityLines, de as toTraceRows, pe as toTraceSegments, oe as traceEventArgsDetail, Y as traceEventHint, se as traceEventOutputDetail, ce as traceEventRawDetail, ae as traceEventSummary, J as traceEventToolName, fe as traceSummaryLine, A as useBaileyChat };
1345
+ export { Fe as ActivityIcon, je as ArrowUpRightIcon, tt as BAILEYAI_CHAT_UI_VERSION, te as BAILEY_CHART_PROMPT_FRAGMENT, I as BAILEY_TABLE_GRID_ROW_THRESHOLD, et as BaileyChatPanel, Ge as BaileyTracePanel, Le as CopyMarkdownButton, ke as HeartIcon, ae as TRACE_KIND_LABEL, Oe as createBaileyMarkdownComponents, T as extractPseudoToolCalls, H as extractTableData, de as formatTraceGap, ue as formatTraceTime, he as hasTraceFailure, e as isSafeMarkdownUrl, M as joinInstructions, ie as parseBaileyChartSpec, D as parseSseFrames, F as resolveToolCall, U as shouldUseGrid, ge as toActivityLines, fe as toTraceRows, me as toTraceSegments, se as traceEventArgsDetail, X as traceEventHint, ce as traceEventOutputDetail, le as traceEventRawDetail, oe as traceEventSummary, Y as traceEventToolName, pe as traceSummaryLine, j as useBaileyChat };