@zenera/chat-widget 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { jsx as n, jsxs as d, Fragment as _e } from "react/jsx-runtime";
2
2
  import * as Ae from "react";
3
- import { useSyncExternalStore as Rt, useState as O, useRef as $, useId as It, useLayoutEffect as Se, useEffect as P, useContext as it, createContext as at, useMemo as de, useCallback as ue, Fragment as $t } from "react";
3
+ import { useSyncExternalStore as Rt, useState as O, useRef as $, useId as It, useLayoutEffect as Se, useEffect as P, useContext as it, createContext as st, useMemo as de, useCallback as ue, Fragment as $t } from "react";
4
4
  import { clsx as Pt } from "clsx";
5
5
  import { twMerge as Mt } from "tailwind-merge";
6
- import { ChevronDown as st, Check as Te, Copy as Dt, PauseCircle as Wt, Wrench as Ht, Plug as qt, Users as Bt, Globe as Ft, Terminal as Ut, Files as Kt, Brain as ot, LoaderCircle as ge, ChevronRight as lt, MessageSquarePlus as Jt, Square as Xt, SendHorizontal as Zt, Trash2 as Gt, PanelRightOpen as Yt, PanelRightClose as Vt, PanelLeftOpen as Qt, PanelLeftClose as er, Plus as tr, SquarePen as rr } from "lucide-react";
6
+ import { ChevronDown as at, Check as Te, Copy as Dt, PauseCircle as Wt, Wrench as Ht, Plug as qt, Users as Bt, Globe as Ft, Terminal as Ut, Files as Kt, Brain as ot, LoaderCircle as ge, ChevronRight as lt, MessageSquarePlus as Jt, Square as Xt, SendHorizontal as Zt, Trash2 as Gt, PanelRightOpen as Yt, PanelRightClose as Vt, PanelLeftOpen as Qt, PanelLeftClose as er, Plus as tr, SquarePen as rr } from "lucide-react";
7
7
  import { u as nr, j as ir } from "./useThreadList-Pg29akQ4.js";
8
- import { Slot as ar } from "@radix-ui/react-slot";
9
- import { cva as sr } from "class-variance-authority";
8
+ import { Slot as sr } from "@radix-ui/react-slot";
9
+ import { cva as ar } from "class-variance-authority";
10
10
  import * as pe from "@radix-ui/react-tooltip";
11
11
  import or from "react-markdown";
12
12
  import lr from "rehype-sanitize";
@@ -40,7 +40,7 @@ function je() {
40
40
  function k(...e) {
41
41
  return Mt(Pt(e));
42
42
  }
43
- const _r = sr(
43
+ const _r = ar(
44
44
  "inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
45
45
  {
46
46
  variants: {
@@ -62,12 +62,12 @@ const _r = sr(
62
62
  defaultVariants: { variant: "default", size: "default" }
63
63
  }
64
64
  ), re = Ae.forwardRef(
65
- ({ className: e, variant: t, size: i, asChild: a = !1, ...s }, r) => /* @__PURE__ */ n(
66
- a ? ar : "button",
65
+ ({ className: e, variant: t, size: i, asChild: s = !1, ...a }, r) => /* @__PURE__ */ n(
66
+ s ? sr : "button",
67
67
  {
68
68
  ref: r,
69
69
  className: k(_r({ variant: t, size: i, className: e })),
70
- ...s
70
+ ...a
71
71
  }
72
72
  )
73
73
  );
@@ -77,7 +77,7 @@ function Er({
77
77
  children: e,
78
78
  className: t
79
79
  }) {
80
- const [i, a] = O(!1), [s, r] = O(!1), o = $(null), l = It();
80
+ const [i, s] = O(!1), [a, r] = O(!1), o = $(null), l = It();
81
81
  Se(() => {
82
82
  const p = o.current;
83
83
  if (!p) return;
@@ -86,7 +86,7 @@ function Er({
86
86
  const u = new ResizeObserver(h);
87
87
  return u.observe(p), () => u.disconnect();
88
88
  }, []);
89
- const c = s && !i;
89
+ const c = a && !i;
90
90
  return /* @__PURE__ */ d("div", { className: t, children: [
91
91
  /* @__PURE__ */ n(
92
92
  "div",
@@ -99,17 +99,17 @@ function Er({
99
99
  children: /* @__PURE__ */ n("div", { ref: o, children: e })
100
100
  }
101
101
  ),
102
- s && /* @__PURE__ */ d(
102
+ a && /* @__PURE__ */ d(
103
103
  "button",
104
104
  {
105
105
  type: "button",
106
106
  "aria-expanded": i,
107
107
  "aria-controls": l,
108
- onClick: () => a((p) => !p),
108
+ onClick: () => s((p) => !p),
109
109
  className: "mt-1 flex cursor-pointer items-center gap-1 rounded-sm text-xs text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
110
110
  children: [
111
111
  i ? "Show less" : "Show more",
112
- /* @__PURE__ */ n(st, { className: k("transition-transform", i && "rotate-180") })
112
+ /* @__PURE__ */ n(at, { className: k("transition-transform", i && "rotate-180") })
113
113
  ]
114
114
  }
115
115
  )
@@ -133,8 +133,8 @@ async function zr(e) {
133
133
  }
134
134
  const ut = (e) => e.replace(/[\r\n]+$/, "");
135
135
  function He(e) {
136
- var a;
137
- const t = ((a = window.getSelection()) == null ? void 0 : a.toString()) ?? "", i = ut(t);
136
+ var s;
137
+ const t = ((s = window.getSelection()) == null ? void 0 : s.toString()) ?? "", i = ut(t);
138
138
  !t || i === t || (e.clipboardData.setData("text/plain", i), e.preventDefault());
139
139
  }
140
140
  const Lr = 1500, qe = "opacity-0 group-hover/msg:opacity-100 [@media(hover:none)]:opacity-100";
@@ -143,16 +143,16 @@ function ze({
143
143
  label: t = "Copy",
144
144
  className: i
145
145
  }) {
146
- const [a, s] = O("idle"), r = $(void 0);
146
+ const [s, a] = O("idle"), r = $(void 0);
147
147
  P(() => () => clearTimeout(r.current), []);
148
148
  const o = async () => {
149
149
  try {
150
- await zr(ut(e)), s("copied");
150
+ await zr(ut(e)), a("copied");
151
151
  } catch {
152
- s("failed");
152
+ a("failed");
153
153
  }
154
- clearTimeout(r.current), r.current = setTimeout(() => s("idle"), Lr);
155
- }, l = a === "copied" ? "Copied" : a === "failed" ? "Copy failed" : t;
154
+ clearTimeout(r.current), r.current = setTimeout(() => a("idle"), Lr);
155
+ }, l = s === "copied" ? "Copied" : s === "failed" ? "Copy failed" : t;
156
156
  return /* @__PURE__ */ d(
157
157
  "button",
158
158
  {
@@ -164,27 +164,27 @@ function ze({
164
164
  // `relative` anchors the absolutely positioned sr-only status: without it the status
165
165
  // is placed against the page, outside the scrolling panes, and makes the page scroll.
166
166
  "relative inline-flex size-6 cursor-pointer select-none items-center justify-center rounded-md text-muted-foreground outline-none hover:bg-accent hover:text-foreground focus-visible:opacity-100 focus-visible:ring-2 focus-visible:ring-ring [&_svg]:size-3.5",
167
- a === "failed" && "text-danger",
167
+ s === "failed" && "text-danger",
168
168
  i
169
169
  ),
170
170
  children: [
171
- a === "copied" ? /* @__PURE__ */ n(Te, {}) : /* @__PURE__ */ n(Dt, {}),
172
- /* @__PURE__ */ n("span", { role: "status", className: "sr-only", children: a === "idle" ? "" : l })
171
+ s === "copied" ? /* @__PURE__ */ n(Te, {}) : /* @__PURE__ */ n(Dt, {}),
172
+ /* @__PURE__ */ n("span", { role: "status", className: "sr-only", children: s === "idle" ? "" : l })
173
173
  ]
174
174
  }
175
175
  );
176
176
  }
177
- const mt = at(null), Or = () => it(mt);
177
+ const mt = st(null), Or = () => it(mt);
178
178
  function ye({
179
179
  label: e,
180
180
  side: t,
181
181
  className: i,
182
- children: a
182
+ children: s
183
183
  }) {
184
- const s = Or();
184
+ const a = Or();
185
185
  return /* @__PURE__ */ n(pe.Provider, { delayDuration: 300, children: /* @__PURE__ */ d(pe.Root, { children: [
186
- /* @__PURE__ */ n(pe.Trigger, { asChild: !0, children: a }),
187
- /* @__PURE__ */ n(pe.Portal, { container: s, children: /* @__PURE__ */ n(
186
+ /* @__PURE__ */ n(pe.Trigger, { asChild: !0, children: s }),
187
+ /* @__PURE__ */ n(pe.Portal, { container: a, children: /* @__PURE__ */ n(
188
188
  pe.Content,
189
189
  {
190
190
  side: t,
@@ -226,9 +226,9 @@ function Z({
226
226
  lang: t,
227
227
  className: i
228
228
  }) {
229
- const a = de(() => Rr(e, t), [e, t]);
229
+ const s = de(() => Rr(e, t), [e, t]);
230
230
  return /* @__PURE__ */ d("div", { className: "group/code relative min-w-0", children: [
231
- /* @__PURE__ */ n("pre", { className: k("overflow-x-auto font-mono text-xs", i), children: a === null ? /* @__PURE__ */ n("code", { children: e }) : /* @__PURE__ */ n("code", { dangerouslySetInnerHTML: { __html: a } }) }),
231
+ /* @__PURE__ */ n("pre", { className: k("overflow-x-auto font-mono text-xs", i), children: s === null ? /* @__PURE__ */ n("code", { children: e }) : /* @__PURE__ */ n("code", { dangerouslySetInnerHTML: { __html: s } }) }),
232
232
  e && /* @__PURE__ */ n(
233
233
  ze,
234
234
  {
@@ -242,7 +242,7 @@ function Z({
242
242
  let Ir, $r = 0;
243
243
  const Pr = () => Ir ?? (Ir = import("mermaid").then(({ default: e }) => e));
244
244
  function Mr({ code: e, natural: t = !1 }) {
245
- const [i, a] = O(null), [s, r] = O(null), o = je();
245
+ const [i, s] = O(null), [a, r] = O(null), o = je();
246
246
  return P(() => {
247
247
  let l = !0;
248
248
  return Pr().then((c) => (c.initialize({
@@ -255,18 +255,18 @@ function Mr({ code: e, natural: t = !1 }) {
255
255
  themeVariables: { fontSize: "14px" }
256
256
  }), c.render(`mermaid-${++$r}`, e))).then(
257
257
  (c) => {
258
- l && (a(c.svg), r(null));
258
+ l && (s(c.svg), r(null));
259
259
  },
260
260
  (c) => {
261
- l && (a(null), r(c instanceof Error ? c.message : String(c)));
261
+ l && (s(null), r(c instanceof Error ? c.message : String(c)));
262
262
  }
263
263
  ), () => {
264
264
  l = !1;
265
265
  };
266
266
  }, [e, o, t]), i === null ? /* @__PURE__ */ d("div", { children: [
267
- s && /* @__PURE__ */ d("p", { className: "mb-1 text-xs text-danger", children: [
267
+ a && /* @__PURE__ */ d("p", { className: "mb-1 text-xs text-danger", children: [
268
268
  "Mermaid: ",
269
- s
269
+ a
270
270
  ] }),
271
271
  /* @__PURE__ */ n(Z, { code: e })
272
272
  ] }) : t ? /* @__PURE__ */ n("div", { className: "overflow-x-auto", children: /* @__PURE__ */ n("div", { className: "mx-auto w-max", dangerouslySetInnerHTML: { __html: i } }) }) : /* @__PURE__ */ n(
@@ -292,24 +292,24 @@ const Dr = [
292
292
  "table"
293
293
  ];
294
294
  function Wr(e) {
295
- return function({ node: i, ...a }) {
295
+ return function({ node: i, ...s }) {
296
296
  var r;
297
- return /* @__PURE__ */ n(e, { ...a, "data-line": (r = i == null ? void 0 : i.position) == null ? void 0 : r.start.line });
297
+ return /* @__PURE__ */ n(e, { ...s, "data-line": (r = i == null ? void 0 : i.position) == null ? void 0 : r.start.line });
298
298
  };
299
299
  }
300
300
  function ie({
301
301
  children: e,
302
302
  className: t,
303
303
  lines: i,
304
- linkAction: a
304
+ linkAction: s
305
305
  }) {
306
- const s = de(
306
+ const a = de(
307
307
  () => ({
308
308
  ...i ? Object.fromEntries(Dr.map((r) => [r, Wr(r)])) : void 0,
309
309
  a: ({ href: r, children: o }) => {
310
310
  if (r && /^https?:\/\//.test(r))
311
311
  return /* @__PURE__ */ n("a", { href: r, target: "_blank", rel: "noreferrer", children: o });
312
- const l = r ? a == null ? void 0 : a(r) : void 0;
312
+ const l = r ? s == null ? void 0 : s(r) : void 0;
313
313
  return l ? /* @__PURE__ */ n(
314
314
  "button",
315
315
  {
@@ -329,14 +329,14 @@ function ie({
329
329
  return i ? /* @__PURE__ */ n("div", { "data-line": (m = r == null ? void 0 : r.position) == null ? void 0 : m.start.line, children: u }) : u;
330
330
  }
331
331
  }),
332
- [i, a]
332
+ [i, s]
333
333
  );
334
334
  return /* @__PURE__ */ n("div", { className: k("markdown", t), children: /* @__PURE__ */ n(
335
335
  or,
336
336
  {
337
337
  remarkPlugins: [cr],
338
338
  rehypePlugins: [lr],
339
- components: s,
339
+ components: a,
340
340
  children: e
341
341
  }
342
342
  ) });
@@ -360,8 +360,8 @@ function Hr() {
360
360
  return e;
361
361
  }
362
362
  function qr(e) {
363
- var a;
364
- if ((a = window.matchMedia) != null && a.call(window, "(pointer: coarse)").matches) return !1;
363
+ var s;
364
+ if ((s = window.matchMedia) != null && s.call(window, "(pointer: coarse)").matches) return !1;
365
365
  const t = Hr();
366
366
  return !t || t === document.body ? !0 : t.closest('[role="dialog"], [role="menu"], [role="listbox"]') || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName) || t.isContentEditable === !0 ? !1 : e === void 0 || !!(e != null && e.contains(t));
367
367
  }
@@ -381,28 +381,28 @@ function Kr(e, t) {
381
381
  const i = t.trim();
382
382
  if (!(!i || i.length > Ur))
383
383
  try {
384
- const a = [...pt(e).filter((s) => s !== i), i];
385
- localStorage.setItem(e, JSON.stringify(a.slice(-Fr)));
384
+ const s = [...pt(e).filter((a) => a !== i), i];
385
+ localStorage.setItem(e, JSON.stringify(s.slice(-Fr)));
386
386
  } catch {
387
387
  }
388
388
  }
389
389
  function Jr(e) {
390
390
  const t = /* @__PURE__ */ new Set(), i = [];
391
- for (let a = e.length - 1; a >= 0; a--)
392
- !e[a].trim() || t.has(e[a]) || (t.add(e[a]), i.unshift(e[a]));
391
+ for (let s = e.length - 1; s >= 0; s--)
392
+ !e[s].trim() || t.has(e[s]) || (t.add(e[s]), i.unshift(e[s]));
393
393
  return i;
394
394
  }
395
- function Xr(e, t, i, a) {
395
+ function Xr(e, t, i, s) {
396
396
  if (i === "up") {
397
397
  if (!e.length) return null;
398
- const r = t ? t.draft : a, o = t ? Math.max(0, t.index - 1) : e.length - 1;
398
+ const r = t ? t.draft : s, o = t ? Math.max(0, t.index - 1) : e.length - 1;
399
399
  return { value: e[o], browsing: { index: o, draft: r, shown: e[o] } };
400
400
  }
401
401
  if (!t) return null;
402
- const s = t.index + 1;
403
- return s >= e.length ? { value: t.draft, browsing: null } : {
404
- value: e[s],
405
- browsing: { index: s, draft: t.draft, shown: e[s] }
402
+ const a = t.index + 1;
403
+ return a >= e.length ? { value: t.draft, browsing: null } : {
404
+ value: e[a],
405
+ browsing: { index: a, draft: t.draft, shown: e[a] }
406
406
  };
407
407
  }
408
408
  const Zr = (e, t, i) => t === i && !e.slice(0, t).includes(`
@@ -412,7 +412,7 @@ function Gr(e) {
412
412
  P(() => {
413
413
  i.current = e;
414
414
  });
415
- const a = ue(() => {
415
+ const s = ue(() => {
416
416
  t.current = null;
417
417
  }, []);
418
418
  return { onKeyDown: ue(
@@ -435,9 +435,9 @@ function Gr(e) {
435
435
  ));
436
436
  },
437
437
  []
438
- ), reset: a };
438
+ ), reset: s };
439
439
  }
440
- const Yr = "zenera.draft.chat", ki = (e, t, i, a) => `${Yr}.${e}.${t}.${i}.${a ?? "new"}`;
440
+ const Yr = "zenera.draft.chat", ki = (e, t, i, s) => `${Yr}.${e}.${t}.${i}.${s ?? "new"}`;
441
441
  function Vr(e) {
442
442
  try {
443
443
  return localStorage.getItem(e) ?? "";
@@ -451,7 +451,7 @@ function Be(e, t) {
451
451
  } catch {
452
452
  }
453
453
  }
454
- const ht = at(null);
454
+ const ht = st(null);
455
455
  function Qr(e, t) {
456
456
  return e.ended ? e.ended : !t || t.status === "pending" ? "waiting" : t.status === "superseded" || t.resumeState === "stale" ? "superseded" : t.resumeState === "failed" ? "failed" : t.resumeState === "queued" ? "resuming" : t.status;
457
457
  }
@@ -459,8 +459,8 @@ function Fe({
459
459
  icon: e,
460
460
  title: t,
461
461
  text: i,
462
- tone: a,
463
- children: s
462
+ tone: s,
463
+ children: a
464
464
  }) {
465
465
  return /* @__PURE__ */ d(
466
466
  "div",
@@ -469,10 +469,10 @@ function Fe({
469
469
  "aria-label": "The agent is waiting for you",
470
470
  className: k(
471
471
  "my-1 flex flex-col gap-2 rounded-lg border px-3 py-2.5 text-sm sm:flex-row sm:items-center",
472
- a === "active" && "border-primary/40 bg-primary/5",
473
- a === "done" && "border-border bg-secondary/40",
474
- a === "muted" && "border-border bg-transparent text-muted-foreground",
475
- a === "danger" && "border-danger/40 text-danger"
472
+ s === "active" && "border-primary/40 bg-primary/5",
473
+ s === "done" && "border-border bg-secondary/40",
474
+ s === "muted" && "border-border bg-transparent text-muted-foreground",
475
+ s === "danger" && "border-danger/40 text-danger"
476
476
  ),
477
477
  children: [
478
478
  /* @__PURE__ */ d("div", { className: "flex min-w-0 flex-1 items-center gap-3", children: [
@@ -482,19 +482,19 @@ function Fe({
482
482
  i && /* @__PURE__ */ n("div", { className: "text-xs text-muted-foreground", children: i })
483
483
  ] })
484
484
  ] }),
485
- s && /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-2", children: s })
485
+ a && /* @__PURE__ */ n("div", { className: "flex shrink-0 items-center gap-2", children: a })
486
486
  ]
487
487
  }
488
488
  );
489
489
  }
490
490
  function en({ interrupt: e, info: t, actions: i }) {
491
- const a = Qr(e, t);
492
- return a !== "waiting" ? /* @__PURE__ */ n(
491
+ const s = Qr(e, t);
492
+ return s !== "waiting" ? /* @__PURE__ */ n(
493
493
  Fe,
494
494
  {
495
495
  tone: "muted",
496
496
  icon: /* @__PURE__ */ n(Te, { className: "size-4" }),
497
- title: a === "cancelled" || a === "superseded" ? "Skipped" : "Done - continuing"
497
+ title: s === "cancelled" || s === "superseded" ? "Skipped" : "Done - continuing"
498
498
  }
499
499
  ) : /* @__PURE__ */ n(
500
500
  Fe,
@@ -516,11 +516,11 @@ function en({ interrupt: e, info: t, actions: i }) {
516
516
  );
517
517
  }
518
518
  function tn({ interrupt: e }) {
519
- var s, r;
519
+ var a, r;
520
520
  const t = it(ht);
521
521
  if (!t) return null;
522
- const i = typeof ((s = e.metadata) == null ? void 0 : s.kind) == "string" ? e.metadata.kind : e.reason, a = ((r = t.cards) == null ? void 0 : r[i]) ?? en;
523
- return /* @__PURE__ */ n(a, { interrupt: e, info: t.info[e.id], actions: t });
522
+ const i = typeof ((a = e.metadata) == null ? void 0 : a.kind) == "string" ? e.metadata.kind : e.reason, s = ((r = t.cards) == null ? void 0 : r[i]) ?? en;
523
+ return /* @__PURE__ */ n(s, { interrupt: e, info: t.info[e.id], actions: t });
524
524
  }
525
525
  const Ue = {
526
526
  stdout: "Output",
@@ -561,21 +561,21 @@ function I({
561
561
  return /* @__PURE__ */ n("span", { className: "font-mono", children: String(e) });
562
562
  if (i >= 3) return /* @__PURE__ */ n(Z, { code: JSON.stringify(e, null, 2), lang: "json" });
563
563
  if (Array.isArray(e))
564
- return e.length ? /* @__PURE__ */ n("div", { className: "space-y-2", children: e.map((s, r) => /* @__PURE__ */ n(I, { value: s, field: t, depth: i + 1 }, r)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "None" });
565
- const a = Object.entries(e);
566
- return a.length ? /* @__PURE__ */ n("dl", { className: "grid min-w-0 grid-cols-[minmax(0,6rem)_minmax(0,1fr)] items-start gap-x-3 gap-y-2", children: a.map(([s, r]) => /* @__PURE__ */ d($t, { children: [
564
+ return e.length ? /* @__PURE__ */ n("div", { className: "space-y-2", children: e.map((a, r) => /* @__PURE__ */ n(I, { value: a, field: t, depth: i + 1 }, r)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "None" });
565
+ const s = Object.entries(e);
566
+ return s.length ? /* @__PURE__ */ n("dl", { className: "grid min-w-0 grid-cols-[minmax(0,6rem)_minmax(0,1fr)] items-start gap-x-3 gap-y-2", children: s.map(([a, r]) => /* @__PURE__ */ d($t, { children: [
567
567
  /* @__PURE__ */ n(
568
568
  "dt",
569
569
  {
570
570
  className: k(
571
571
  "break-words text-[11px] text-muted-foreground",
572
- (s === "error" || s === "failed") && "text-danger"
572
+ (a === "error" || a === "failed") && "text-danger"
573
573
  ),
574
- children: gt(s)
574
+ children: gt(a)
575
575
  }
576
576
  ),
577
- /* @__PURE__ */ n("dd", { className: "min-w-0", children: /* @__PURE__ */ n(I, { value: r, field: s, depth: i + 1 }) })
578
- ] }, s)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "No fields" });
577
+ /* @__PURE__ */ n("dd", { className: "min-w-0", children: /* @__PURE__ */ n(I, { value: r, field: a, depth: i + 1 }) })
578
+ ] }, a)) }) : /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: "No fields" });
579
579
  }
580
580
  function be({ value: e }) {
581
581
  return /* @__PURE__ */ n("dl", { className: "flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-[11px] text-muted-foreground", children: Object.entries(e).map(([t, i]) => /* @__PURE__ */ d("div", { className: "flex min-w-0 max-w-full items-baseline gap-1", children: [
@@ -589,12 +589,12 @@ function be({ value: e }) {
589
589
  function K({
590
590
  value: e,
591
591
  omit: t,
592
- renderValue: i = (a) => /* @__PURE__ */ n(I, { value: a })
592
+ renderValue: i = (s) => /* @__PURE__ */ n(I, { value: s })
593
593
  }) {
594
- const a = Object.fromEntries(Object.entries(e).filter(([s]) => !t.includes(s)));
595
- return Object.keys(a).length ? /* @__PURE__ */ d("details", { className: "mt-2 text-muted-foreground", children: [
594
+ const s = Object.fromEntries(Object.entries(e).filter(([a]) => !t.includes(a)));
595
+ return Object.keys(s).length ? /* @__PURE__ */ d("details", { className: "mt-2 text-muted-foreground", children: [
596
596
  /* @__PURE__ */ n("summary", { className: "w-fit cursor-pointer rounded-sm text-[11px] outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground", children: "Details" }),
597
- /* @__PURE__ */ n("div", { className: "mt-2", children: i(a) })
597
+ /* @__PURE__ */ n("div", { className: "mt-2", children: i(s) })
598
598
  ] }) : null;
599
599
  }
600
600
  function A(e) {
@@ -609,27 +609,27 @@ function xe(e) {
609
609
  }
610
610
  }
611
611
  function rn(e) {
612
- let t = "", i = 0, a = !1, s = !1;
612
+ let t = "", i = 0, s = !1, a = !1;
613
613
  const r = () => {
614
614
  t = t.trimEnd() + `
615
615
  ` + " ".repeat(i);
616
616
  };
617
617
  for (const o of e) {
618
- if (a) {
619
- t += o, s ? s = !1 : o === "\\" ? s = !0 : o === '"' && (a = !1);
618
+ if (s) {
619
+ t += o, a ? a = !1 : o === "\\" ? a = !0 : o === '"' && (s = !1);
620
620
  continue;
621
621
  }
622
- o === '"' ? (a = !0, t += o) : o === "{" || o === "[" ? (t += o, i++, r()) : o === "}" || o === "]" ? (i = Math.max(0, i - 1), r(), t += o) : o === "," ? (t += o, r()) : o === ":" ? t += ": " : /\s/.test(o) ? t && !/\s$/.test(t) && (t += " ") : t += o;
622
+ o === '"' ? (s = !0, t += o) : o === "{" || o === "[" ? (t += o, i++, r()) : o === "}" || o === "]" ? (i = Math.max(0, i - 1), r(), t += o) : o === "," ? (t += o, r()) : o === ":" ? t += ": " : /\s/.test(o) ? t && !/\s$/.test(t) && (t += " ") : t += o;
623
623
  }
624
624
  return t;
625
625
  }
626
626
  function nn(e) {
627
- var a;
627
+ var s;
628
628
  let t = 1;
629
629
  for (; t < e.length; ) {
630
- const s = e[t];
631
- if (s === '"' || s.charCodeAt(0) < 32) break;
632
- if (s === "\\") {
630
+ const a = e[t];
631
+ if (a === '"' || a.charCodeAt(0) < 32) break;
632
+ if (a === "\\") {
633
633
  const r = e[t + 1];
634
634
  if (!r) break;
635
635
  if (r === "u") {
@@ -642,25 +642,25 @@ function nn(e) {
642
642
  } else
643
643
  t++;
644
644
  }
645
- const i = (a = xe(e.slice(0, t) + '"')) == null ? void 0 : a.value;
645
+ const i = (s = xe(e.slice(0, t) + '"')) == null ? void 0 : s.value;
646
646
  return typeof i == "string" ? i : void 0;
647
647
  }
648
- function an(e) {
648
+ function sn(e) {
649
649
  var c, p, h;
650
650
  if (!e.startsWith("{")) return;
651
651
  const t = [];
652
- let i = 1, a = 1, s = !1, r = !1;
652
+ let i = 1, s = 1, a = !1, r = !1;
653
653
  for (let u = 1; u < e.length; u++) {
654
654
  const f = e[u];
655
- if (s)
656
- r ? r = !1 : f === "\\" ? r = !0 : f === '"' && (s = !1);
655
+ if (a)
656
+ r ? r = !1 : f === "\\" ? r = !0 : f === '"' && (a = !1);
657
657
  else if (f === '"')
658
- s = !0;
658
+ a = !0;
659
659
  else if (f === "{" || f === "[")
660
- a++;
660
+ s++;
661
661
  else if (f === "}" || f === "]")
662
- a--;
663
- else if (f === "," && a === 1) {
662
+ s--;
663
+ else if (f === "," && s === 1) {
664
664
  const m = A((c = xe("{" + e.slice(i, u) + "}")) == null ? void 0 : c.value);
665
665
  if (!m) return t.length ? Object.fromEntries(t) : void 0;
666
666
  t.push(...Object.entries(m)), i = u + 1;
@@ -679,20 +679,20 @@ function an(e) {
679
679
  return t.length ? Object.fromEntries(t) : void 0;
680
680
  }
681
681
  function Ke(e) {
682
- const t = /\n\u2026 (\d+) more characters$/.exec(e), i = (t ? e.slice(0, t.index) : e).trimStart(), a = xe(i), s = t ? Number(t[1]) : void 0;
683
- if (a)
682
+ const t = /\n\u2026 (\d+) more characters$/.exec(e), i = (t ? e.slice(0, t.index) : e).trimStart(), s = xe(i), a = t ? Number(t[1]) : void 0;
683
+ if (s)
684
684
  return {
685
- value: a.value,
686
- raw: JSON.stringify(a.value, null, 2) + (t ? t[0] : ""),
685
+ value: s.value,
686
+ raw: JSON.stringify(s.value, null, 2) + (t ? t[0] : ""),
687
687
  incomplete: !1,
688
- omitted: s
688
+ omitted: a
689
689
  };
690
690
  const r = /^[{["]/.test(i);
691
691
  return {
692
- value: r ? an(i) : void 0,
692
+ value: r ? sn(i) : void 0,
693
693
  raw: r ? rn(i) + (t ? t[0] : "") : e,
694
694
  incomplete: r,
695
- omitted: s
695
+ omitted: a
696
696
  };
697
697
  }
698
698
  const Je = {
@@ -726,7 +726,7 @@ const Je = {
726
726
  function ne(e) {
727
727
  return e.replace(/[_-]+/g, " ").trim();
728
728
  }
729
- function sn(e) {
729
+ function an(e) {
730
730
  return Object.values(A(e) ?? {}).filter(
731
731
  (t) => ["string", "number", "boolean"].includes(typeof t) && String(t).length <= 80
732
732
  ).slice(0, 3).map(String).join(" · ");
@@ -740,7 +740,7 @@ function T(e) {
740
740
  }
741
741
  function on(e, t, i) {
742
742
  var p, h;
743
- const a = e.startsWith("transfer_to_") ? e.slice(12) : "", s = Object.hasOwn(Je, e) ? Je[e] : void 0, r = A(t.value) ?? {}, o = a ? "Transfer to agent" : e === "mcp_call" && T(r.tool) ? T(r.tool) : (s == null ? void 0 : s.title) ?? e, l = a ? "agent" : (s == null ? void 0 : s.family) ?? "other";
743
+ const s = e.startsWith("transfer_to_") ? e.slice(12) : "", a = Object.hasOwn(Je, e) ? Je[e] : void 0, r = A(t.value) ?? {}, o = s ? "Transfer to agent" : e === "mcp_call" && T(r.tool) ? T(r.tool) : (a == null ? void 0 : a.title) ?? e, l = s ? "agent" : (a == null ? void 0 : a.family) ?? "other";
744
744
  let c = "";
745
745
  switch (e) {
746
746
  case "memory_search":
@@ -809,18 +809,18 @@ function on(e, t, i) {
809
809
  c = [ne(T(r.server)), T(r.tool)].filter(Boolean).join(" · ");
810
810
  break;
811
811
  case "mcp_call":
812
- c = [ne(T(r.server)), sn(r.arguments)].filter(Boolean).join(" · ");
812
+ c = [ne(T(r.server)), an(r.arguments)].filter(Boolean).join(" · ");
813
813
  break;
814
814
  default:
815
- c = a ? [a, T(r.reason)].filter(Boolean).join(" - ") : T(r.reason) || T(Object.values(r).find((u) => typeof u == "string"));
815
+ c = s ? [s, T(r.reason)].filter(Boolean).join(" - ") : T(r.reason) || T(Object.values(r).find((u) => typeof u == "string"));
816
816
  }
817
817
  return !c && typeof t.value == "string" && (c = t.value), !c && l === "other" && Object.keys(r).length && (c = ee(Object.keys(r), "argument") ?? ""), { title: o, family: l, preview: c.replace(/\s+/g, " ").trim() };
818
818
  }
819
819
  function ln(e, t, i) {
820
820
  if (!e)
821
821
  return i ? { label: "Running", tone: "muted", pending: !0 } : { label: "No result", tone: "muted" };
822
- const a = A(e.value);
823
- return t || a != null && a.error || (a == null ? void 0 : a.isError) === !0 || (a == null ? void 0 : a.stopped) === !1 ? { label: "Failed", tone: "danger" } : (a == null ? void 0 : a.auth_required) === !0 ? { label: "Needs connection", tone: "warning" } : (a == null ? void 0 : a.timed_out) === !0 ? { label: "Timed out", tone: "danger" } : typeof (a == null ? void 0 : a.exit_code) == "number" && a.exit_code !== 0 ? { label: `Exit ${a.exit_code}`, tone: "danger" } : e.omitted !== void 0 ? { label: "Truncated", tone: "warning" } : e.incomplete ? { label: "Invalid JSON", tone: "warning" } : a != null && a.truncated ? { label: "Truncated", tone: "warning" } : Array.isArray(a == null ? void 0 : a.failed) && a.failed.length ? { label: "Partial failure", tone: "warning" } : (a == null ? void 0 : a.running) === !0 ? { label: "Job running", tone: "muted" } : (a == null ? void 0 : a.started) === !0 ? { label: "Started", tone: "success" } : typeof (a == null ? void 0 : a.exit_code) == "number" ? { label: `Exit ${a.exit_code}`, tone: "success" } : { label: "Done", tone: "success" };
822
+ const s = A(e.value);
823
+ return t || s != null && s.error || (s == null ? void 0 : s.isError) === !0 || (s == null ? void 0 : s.stopped) === !1 ? { label: "Failed", tone: "danger" } : (s == null ? void 0 : s.auth_required) === !0 ? { label: "Needs connection", tone: "warning" } : (s == null ? void 0 : s.timed_out) === !0 ? { label: "Timed out", tone: "danger" } : typeof (s == null ? void 0 : s.exit_code) == "number" && s.exit_code !== 0 ? { label: `Exit ${s.exit_code}`, tone: "danger" } : e.omitted !== void 0 ? { label: "Truncated", tone: "warning" } : e.incomplete ? { label: "Invalid JSON", tone: "warning" } : s != null && s.truncated ? { label: "Truncated", tone: "warning" } : Array.isArray(s == null ? void 0 : s.failed) && s.failed.length ? { label: "Partial failure", tone: "warning" } : (s == null ? void 0 : s.running) === !0 ? { label: "Job running", tone: "muted" } : (s == null ? void 0 : s.started) === !0 ? { label: "Started", tone: "success" } : typeof (s == null ? void 0 : s.exit_code) == "number" ? { label: `Exit ${s.exit_code}`, tone: "success" } : { label: "Done", tone: "success" };
824
824
  }
825
825
  function Ne(e, t) {
826
826
  return Object.fromEntries(Object.entries(e).filter(([i]) => t.includes(i)));
@@ -860,13 +860,13 @@ function xt({
860
860
  name: e,
861
861
  input: t,
862
862
  value: i,
863
- args: a,
864
- partial: s
863
+ args: s,
864
+ partial: a
865
865
  }) {
866
866
  var h;
867
867
  const r = A(i);
868
868
  if (!r) return /* @__PURE__ */ n(I, { value: i });
869
- const o = A(a), l = (u, f, m = []) => /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
869
+ const o = A(s), l = (u, f, m = []) => /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
870
870
  r.error !== void 0 && /* @__PURE__ */ n("div", { className: "text-danger", children: /* @__PURE__ */ n(I, { value: r.error }) }),
871
871
  r.hint !== void 0 && /* @__PURE__ */ n("div", { className: "text-muted-foreground", children: /* @__PURE__ */ n(I, { value: r.hint }) }),
872
872
  u,
@@ -1042,7 +1042,7 @@ function xt({
1042
1042
  if (u.length)
1043
1043
  return l(
1044
1044
  /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1045
- u.every((f) => r[f] === "") && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: s ? "No output in the received prefix" : "No output" }),
1045
+ u.every((f) => r[f] === "") && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: a ? "No output in the received prefix" : "No output" }),
1046
1046
  u.filter((f) => r[f] !== "").map((f) => /* @__PURE__ */ d(
1047
1047
  "div",
1048
1048
  {
@@ -1154,8 +1154,8 @@ function V({ children: e }) {
1154
1154
  return /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: e });
1155
1155
  }
1156
1156
  function dn({ tools: e }) {
1157
- const [t, i] = O(""), a = t.trim().toLowerCase(), s = a ? e.filter(
1158
- (r) => `${_(r.name) ?? ""} ${_(r.description) ?? ""}`.toLowerCase().includes(a)
1157
+ const [t, i] = O(""), s = t.trim().toLowerCase(), a = s ? e.filter(
1158
+ (r) => `${_(r.name) ?? ""} ${_(r.description) ?? ""}`.toLowerCase().includes(s)
1159
1159
  ) : e;
1160
1160
  return e.length ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1161
1161
  e.length > 12 && /* @__PURE__ */ n(
@@ -1168,7 +1168,7 @@ function dn({ tools: e }) {
1168
1168
  onChange: (r) => i(r.target.value)
1169
1169
  }
1170
1170
  ),
1171
- /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: s.map((r, o) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
1171
+ /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: a.map((r, o) => /* @__PURE__ */ d("li", { className: "min-w-0", children: [
1172
1172
  /* @__PURE__ */ n("code", { className: "break-all text-foreground", children: _(r.name) ?? "?" }),
1173
1173
  _(r.description) && /* @__PURE__ */ n(
1174
1174
  "p",
@@ -1179,22 +1179,22 @@ function dn({ tools: e }) {
1179
1179
  }
1180
1180
  )
1181
1181
  ] }, o)) }),
1182
- a && !s.length && /* @__PURE__ */ n(V, { children: "No matching tools" })
1182
+ s && !a.length && /* @__PURE__ */ n(V, { children: "No matching tools" })
1183
1183
  ] }) : /* @__PURE__ */ n(V, { children: "No tools" });
1184
1184
  }
1185
1185
  function un({ schema: e }) {
1186
- const t = A(e), i = Object.entries(A(t == null ? void 0 : t.properties) ?? {}), a = Array.isArray(t == null ? void 0 : t.required) ? t.required : [];
1187
- return i.length ? /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: i.map(([s, r]) => {
1186
+ const t = A(e), i = Object.entries(A(t == null ? void 0 : t.properties) ?? {}), s = Array.isArray(t == null ? void 0 : t.required) ? t.required : [];
1187
+ return i.length ? /* @__PURE__ */ n("ul", { className: "space-y-1.5", children: i.map(([a, r]) => {
1188
1188
  var c;
1189
1189
  const o = A(r) ?? {}, l = Array.isArray(o.enum) ? o.enum.map(String).join(" | ") : o.type === "array" ? `${_((c = A(o.items)) == null ? void 0 : c.type) ?? "any"}[]` : Array.isArray(o.type) ? o.type.join(" | ") : _(o.type) ?? "";
1190
1190
  return /* @__PURE__ */ d("li", { className: "min-w-0", children: [
1191
1191
  /* @__PURE__ */ d("div", { className: "flex flex-wrap items-baseline gap-x-2", children: [
1192
- /* @__PURE__ */ n("code", { className: "break-all text-foreground", children: s }),
1192
+ /* @__PURE__ */ n("code", { className: "break-all text-foreground", children: a }),
1193
1193
  l && /* @__PURE__ */ n("span", { className: "text-muted-foreground", children: l }),
1194
- a.includes(s) && /* @__PURE__ */ n("span", { className: "text-[11px] text-warning", children: "required" })
1194
+ s.includes(a) && /* @__PURE__ */ n("span", { className: "text-[11px] text-warning", children: "required" })
1195
1195
  ] }),
1196
1196
  _(o.description) && /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: _(o.description) })
1197
- ] }, s);
1197
+ ] }, a);
1198
1198
  }) }) : /* @__PURE__ */ n(V, { children: "Takes no arguments" });
1199
1199
  }
1200
1200
  function mn(e) {
@@ -1239,21 +1239,21 @@ function vt({ part: e }) {
1239
1239
  }
1240
1240
  function fn({ object: e }) {
1241
1241
  if (e.auth_required === !0) {
1242
- const s = _(e.connect_url);
1242
+ const a = _(e.connect_url);
1243
1243
  return /* @__PURE__ */ d("div", { className: "space-y-1 text-warning", children: [
1244
1244
  /* @__PURE__ */ n("p", { children: _(e.message) ?? "This service needs a connected account." }),
1245
- s && /* @__PURE__ */ d(me, { url: s, children: [
1245
+ a && /* @__PURE__ */ d(me, { url: a, children: [
1246
1246
  "Connect ",
1247
1247
  ne(_(e.server) ?? "")
1248
1248
  ] })
1249
1249
  ] });
1250
1250
  }
1251
- const t = Le(e.content) ?? [], i = e.structuredContent, a = i !== void 0 ? t.filter((s) => s.type !== "text") : t;
1251
+ const t = Le(e.content) ?? [], i = e.structuredContent, s = i !== void 0 ? t.filter((a) => a.type !== "text") : t;
1252
1252
  return /* @__PURE__ */ d("div", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1253
1253
  e.isError === !0 && /* @__PURE__ */ n("p", { className: "text-danger", children: "The service returned an error." }),
1254
1254
  /* @__PURE__ */ d("div", { className: k("space-y-2", e.isError === !0 && "text-danger"), children: [
1255
1255
  i !== void 0 && /* @__PURE__ */ n(I, { value: i }),
1256
- a.map((s, r) => /* @__PURE__ */ n(vt, { part: s }, r)),
1256
+ s.map((a, r) => /* @__PURE__ */ n(vt, { part: a }, r)),
1257
1257
  i === void 0 && !t.length && /* @__PURE__ */ n(V, { children: "No content" })
1258
1258
  ] }),
1259
1259
  e.truncated === !0 && /* @__PURE__ */ n("p", { className: "text-warning", children: _(e.note) ?? "Only part of the result is included." })
@@ -1263,10 +1263,10 @@ function pn({
1263
1263
  name: e,
1264
1264
  input: t,
1265
1265
  value: i,
1266
- args: a,
1267
- partial: s
1266
+ args: s,
1267
+ partial: a
1268
1268
  }) {
1269
- const r = A(i), o = /* @__PURE__ */ n(xt, { name: e, input: t, value: i, args: a, partial: s });
1269
+ const r = A(i), o = /* @__PURE__ */ n(xt, { name: e, input: t, value: i, args: s, partial: a });
1270
1270
  if (!r || r.error !== void 0) return o;
1271
1271
  if (t) {
1272
1272
  const l = _(r.server);
@@ -1338,11 +1338,11 @@ function pn({
1338
1338
  }
1339
1339
  function hn(e) {
1340
1340
  const t = [], i = [];
1341
- for (const a of e.split(/\r?\n/)) {
1342
- const s = a.trim();
1343
- if (!s || /^<\/?memory-recollection>$/.test(a)) continue;
1341
+ for (const s of e.split(/\r?\n/)) {
1342
+ const a = s.trim();
1343
+ if (!a || /^<\/?memory-recollection>$/.test(s)) continue;
1344
1344
  const r = /^( *)(?:(\d+\.\d+|--) {2,}|([\u2190\u2192][\w-]+) {2,}(?:(\d+\.\d+) {2,})?)([A-Za-z0-9_ -]+?) {2,}(\S+)\s*$/.exec(
1345
- a
1345
+ s
1346
1346
  );
1347
1347
  if (r && (r[3] || r[1].length <= 2))
1348
1348
  t.push({
@@ -1353,10 +1353,10 @@ function hn(e) {
1353
1353
  relation: r[3],
1354
1354
  lines: []
1355
1355
  });
1356
- else if (s.startsWith("(more memory matched than fits;") || /^\u2026 \d+ more characters$/.test(s))
1357
- i.push(s);
1358
- else if (t.length && /^ {6,}\S/.test(a))
1359
- t[t.length - 1].lines.push(s);
1356
+ else if (a.startsWith("(more memory matched than fits;") || /^\u2026 \d+ more characters$/.test(a))
1357
+ i.push(a);
1358
+ else if (t.length && /^ {6,}\S/.test(s))
1359
+ t[t.length - 1].lines.push(a);
1360
1360
  else
1361
1361
  return;
1362
1362
  }
@@ -1377,16 +1377,16 @@ function Xe({
1377
1377
  nodes: e,
1378
1378
  renderValue: t
1379
1379
  }) {
1380
- return e.length ? /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((i, a) => {
1381
- const s = A(i.file), r = typeof i.file == "string" ? i.file : s == null ? void 0 : s.path;
1380
+ return e.length ? /* @__PURE__ */ n("div", { className: "space-y-4", children: e.map((i, s) => {
1381
+ const a = A(i.file), r = typeof i.file == "string" ? i.file : a == null ? void 0 : a.path;
1382
1382
  return /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1383
1383
  /* @__PURE__ */ n(wt, { node: i }),
1384
1384
  typeof i.text == "string" && /* @__PURE__ */ n(ie, { className: "text-xs", children: i.text }),
1385
1385
  typeof r == "string" && /* @__PURE__ */ d("div", { className: "text-[11px] text-muted-foreground", children: [
1386
1386
  /* @__PURE__ */ n("code", { className: "break-all", children: r }),
1387
- typeof (s == null ? void 0 : s.bytes) == "number" && /* @__PURE__ */ d("span", { children: [
1387
+ typeof (a == null ? void 0 : a.bytes) == "number" && /* @__PURE__ */ d("span", { children: [
1388
1388
  " (",
1389
- s.bytes.toLocaleString(),
1389
+ a.bytes.toLocaleString(),
1390
1390
  " bytes)"
1391
1391
  ] })
1392
1392
  ] }),
@@ -1412,7 +1412,7 @@ function Xe({
1412
1412
  renderValue: t
1413
1413
  }
1414
1414
  )
1415
- ] }, a);
1415
+ ] }, s);
1416
1416
  }) }) : /* @__PURE__ */ n("p", { className: "text-muted-foreground", children: "No memories" });
1417
1417
  }
1418
1418
  function Ze(e) {
@@ -1420,33 +1420,33 @@ function Ze(e) {
1420
1420
  const t = e.map(A);
1421
1421
  if (t.every(
1422
1422
  (i) => i !== void 0 && ["id", "ref", "kind", "text", "content"].every(
1423
- (a) => i[a] === void 0 || typeof i[a] == "string"
1424
- ) && ["id", "ref", "text", "file"].some((a) => i[a] !== void 0)
1423
+ (s) => i[s] === void 0 || typeof i[s] == "string"
1424
+ ) && ["id", "ref", "text", "file"].some((s) => i[s] !== void 0)
1425
1425
  ))
1426
1426
  return t;
1427
1427
  }
1428
1428
  function gn({ value: e, renderValue: t }) {
1429
1429
  const i = Array.isArray(e) ? e.map(A) : void 0;
1430
1430
  return !i || !i.every(
1431
- (a) => a !== void 0 && typeof a.in == "string" && typeof a.line == "number" && typeof a.text == "string"
1432
- ) ? /* @__PURE__ */ n(_e, { children: t({ hits: e }) }) : /* @__PURE__ */ n("div", { className: "space-y-2", children: i.map((a, s) => /* @__PURE__ */ d("div", { children: [
1431
+ (s) => s !== void 0 && typeof s.in == "string" && typeof s.line == "number" && typeof s.text == "string"
1432
+ ) ? /* @__PURE__ */ n(_e, { children: t({ hits: e }) }) : /* @__PURE__ */ n("div", { className: "space-y-2", children: i.map((s, a) => /* @__PURE__ */ d("div", { children: [
1433
1433
  /* @__PURE__ */ d("div", { className: "mb-1 text-[11px] text-muted-foreground", children: [
1434
- String(a.in),
1434
+ String(s.in),
1435
1435
  ":",
1436
- String(a.line)
1436
+ String(s.line)
1437
1437
  ] }),
1438
- /* @__PURE__ */ n("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs", children: String(a.text) }),
1439
- /* @__PURE__ */ n(K, { value: a, omit: ["in", "line", "text"], renderValue: t })
1440
- ] }, s)) });
1438
+ /* @__PURE__ */ n("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs", children: String(s.text) }),
1439
+ /* @__PURE__ */ n(K, { value: s, omit: ["in", "line", "text"], renderValue: t })
1440
+ ] }, a)) });
1441
1441
  }
1442
1442
  function bn({
1443
1443
  name: e,
1444
1444
  input: t,
1445
1445
  value: i,
1446
- text: a,
1447
- renderValue: s
1446
+ text: s,
1447
+ renderValue: a
1448
1448
  }) {
1449
- const r = A(i), o = typeof i == "string" ? i : a;
1449
+ const r = A(i), o = typeof i == "string" ? i : s;
1450
1450
  if (!t && e === "memory_search" && (i === void 0 || typeof i == "string")) {
1451
1451
  const l = hn(o);
1452
1452
  return l ? /* @__PURE__ */ d("div", { className: "space-y-3", children: [
@@ -1482,22 +1482,22 @@ function bn({
1482
1482
  }
1483
1483
  if (!t && e === "memory_load") {
1484
1484
  const l = Ze(i);
1485
- if (l) return /* @__PURE__ */ n(Xe, { nodes: l, renderValue: s });
1485
+ if (l) return /* @__PURE__ */ n(Xe, { nodes: l, renderValue: a });
1486
1486
  }
1487
1487
  if (t && e === "memory_commit" && r) {
1488
1488
  const l = Ze(r.nodes);
1489
1489
  if (l)
1490
1490
  return /* @__PURE__ */ d("div", { children: [
1491
- /* @__PURE__ */ n(Xe, { nodes: l, renderValue: s }),
1492
- r.edges !== void 0 && /* @__PURE__ */ n("div", { className: "mt-3", children: s({ links: r.edges }) }),
1493
- /* @__PURE__ */ n(K, { value: r, omit: ["nodes", "edges"], renderValue: s })
1491
+ /* @__PURE__ */ n(Xe, { nodes: l, renderValue: a }),
1492
+ r.edges !== void 0 && /* @__PURE__ */ n("div", { className: "mt-3", children: a({ links: r.edges }) }),
1493
+ /* @__PURE__ */ n(K, { value: r, omit: ["nodes", "edges"], renderValue: a })
1494
1494
  ] });
1495
1495
  }
1496
1496
  if (t && r && (e === "memory_load" || e === "memory_forget") && Array.isArray(r.ids) && r.ids.every((l) => typeof l == "string"))
1497
1497
  return /* @__PURE__ */ d("div", { children: [
1498
1498
  /* @__PURE__ */ n("div", { className: "flex flex-wrap gap-x-3 gap-y-1 font-mono text-[11px]", children: r.ids.map((l, c) => /* @__PURE__ */ n("code", { className: "break-all", children: l }, c)) }),
1499
- r.reason !== void 0 && /* @__PURE__ */ n("div", { className: "mt-2", children: s({ reason: r.reason }) }),
1500
- /* @__PURE__ */ n(K, { value: r, omit: ["ids", "reason"], renderValue: s })
1499
+ r.reason !== void 0 && /* @__PURE__ */ n("div", { className: "mt-2", children: a({ reason: r.reason }) }),
1500
+ /* @__PURE__ */ n(K, { value: r, omit: ["ids", "reason"], renderValue: a })
1501
1501
  ] });
1502
1502
  if (!t && e === "memory_grep" && r && Array.isArray(r.matches)) {
1503
1503
  const l = r.matches.map(A);
@@ -1514,7 +1514,7 @@ function bn({
1514
1514
  l.map((c, p) => /* @__PURE__ */ d("article", { className: "min-w-0 space-y-2 [overflow-wrap:anywhere]", children: [
1515
1515
  /* @__PURE__ */ n(wt, { node: c }),
1516
1516
  typeof c.file == "string" && /* @__PURE__ */ n("code", { className: "block break-all text-[11px] text-muted-foreground", children: c.file }),
1517
- /* @__PURE__ */ n(gn, { value: c.hits, renderValue: s }),
1517
+ /* @__PURE__ */ n(gn, { value: c.hits, renderValue: a }),
1518
1518
  typeof c.more == "number" && c.more > 0 && /* @__PURE__ */ d("p", { className: "text-warning", children: [
1519
1519
  c.more,
1520
1520
  " additional hits"
@@ -1531,13 +1531,13 @@ function bn({
1531
1531
  ...typeof c.file == "string" ? ["file"] : [],
1532
1532
  ...typeof c.more == "number" ? ["more"] : []
1533
1533
  ],
1534
- renderValue: s
1534
+ renderValue: a
1535
1535
  }
1536
1536
  )
1537
1537
  ] }, p)),
1538
1538
  r.unsearched !== void 0 && /* @__PURE__ */ d("div", { className: "text-warning", children: [
1539
1539
  /* @__PURE__ */ n("p", { className: "mb-1", children: "Some memories were not searched." }),
1540
- s({ unsearched: r.unsearched })
1540
+ a({ unsearched: r.unsearched })
1541
1541
  ] }),
1542
1542
  /* @__PURE__ */ n(
1543
1543
  K,
@@ -1549,16 +1549,16 @@ function bn({
1549
1549
  ...typeof r.found == "number" ? ["found"] : [],
1550
1550
  ...typeof r.truncated == "boolean" ? ["truncated"] : []
1551
1551
  ],
1552
- renderValue: s
1552
+ renderValue: a
1553
1553
  }
1554
1554
  )
1555
1555
  ] });
1556
1556
  }
1557
1557
  return !t && e === "memory_commit" && r && typeof r.summary == "string" ? /* @__PURE__ */ d("div", { className: "space-y-2", children: [
1558
1558
  /* @__PURE__ */ n("p", { children: r.summary.replace(/^memory_commit /, "Remembered ") }),
1559
- r.ids !== void 0 && s({ "Memory IDs": r.ids }),
1560
- /* @__PURE__ */ n(K, { value: r, omit: ["summary", "ids"], renderValue: s })
1561
- ] }) : i !== void 0 ? s(i) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
1559
+ r.ids !== void 0 && a({ "Memory IDs": r.ids }),
1560
+ /* @__PURE__ */ n(K, { value: r, omit: ["summary", "ids"], renderValue: a })
1561
+ ] }) : i !== void 0 ? a(i) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap [overflow-wrap:anywhere]", children: o || "(empty)" });
1562
1562
  }
1563
1563
  const xn = {
1564
1564
  memory: ot,
@@ -1588,8 +1588,8 @@ function Ge({
1588
1588
  payload: e,
1589
1589
  raw: t,
1590
1590
  markdown: i,
1591
- receiving: a,
1592
- tool: s
1591
+ receiving: s,
1592
+ tool: a
1593
1593
  }) {
1594
1594
  return /* @__PURE__ */ d(_e, { children: [
1595
1595
  e.omitted !== void 0 ? /* @__PURE__ */ d("p", { className: "mb-2 text-warning", children: [
@@ -1597,38 +1597,38 @@ function Ge({
1597
1597
  e.omitted.toLocaleString(),
1598
1598
  " more characters were not sent.",
1599
1599
  e.incomplete && " Showing only the available prefix."
1600
- ] }) : e.incomplete ? /* @__PURE__ */ n("p", { className: "mb-2 text-muted-foreground", children: a ? "Receiving arguments..." : "Incomplete or invalid JSON. Only the available content is shown." }) : null,
1600
+ ] }) : e.incomplete ? /* @__PURE__ */ n("p", { className: "mb-2 text-muted-foreground", children: s ? "Receiving arguments..." : "Incomplete or invalid JSON. Only the available content is shown." }) : null,
1601
1601
  t ? /* @__PURE__ */ n(
1602
1602
  Z,
1603
1603
  {
1604
1604
  code: e.raw || "(empty)",
1605
1605
  lang: e.incomplete ? void 0 : "json"
1606
1606
  }
1607
- ) : (s == null ? void 0 : s.family) === "memory" && !e.incomplete ? /* @__PURE__ */ n(
1607
+ ) : (a == null ? void 0 : a.family) === "memory" && !e.incomplete ? /* @__PURE__ */ n(
1608
1608
  bn,
1609
1609
  {
1610
- name: s.name,
1611
- input: s.input,
1610
+ name: a.name,
1611
+ input: a.input,
1612
1612
  value: e.value,
1613
1613
  text: e.raw,
1614
1614
  renderValue: (r) => /* @__PURE__ */ n(I, { value: r })
1615
1615
  }
1616
- ) : (s == null ? void 0 : s.family) === "mcp" && e.value !== void 0 ? /* @__PURE__ */ n(
1616
+ ) : (a == null ? void 0 : a.family) === "mcp" && e.value !== void 0 ? /* @__PURE__ */ n(
1617
1617
  pn,
1618
1618
  {
1619
- name: s.name,
1620
- input: s.input,
1619
+ name: a.name,
1620
+ input: a.input,
1621
1621
  value: e.value,
1622
- args: s.args,
1622
+ args: a.args,
1623
1623
  partial: e.incomplete || e.omitted !== void 0
1624
1624
  }
1625
- ) : s && e.value !== void 0 ? /* @__PURE__ */ n(
1625
+ ) : a && e.value !== void 0 ? /* @__PURE__ */ n(
1626
1626
  xt,
1627
1627
  {
1628
- name: s.name,
1629
- input: s.input,
1628
+ name: a.name,
1629
+ input: a.input,
1630
1630
  value: e.value,
1631
- args: s.args,
1631
+ args: a.args,
1632
1632
  partial: e.incomplete || e.omitted !== void 0
1633
1633
  }
1634
1634
  ) : e.value !== void 0 ? /* @__PURE__ */ n(I, { value: e.value }) : e.incomplete ? /* @__PURE__ */ n(Z, { code: e.raw }) : i ? /* @__PURE__ */ n(ie, { children: e.raw }) : /* @__PURE__ */ n("div", { className: "whitespace-pre-wrap break-words [overflow-wrap:anywhere]", children: e.raw || "(empty)" })
@@ -1638,14 +1638,14 @@ function yn({
1638
1638
  item: e,
1639
1639
  running: t
1640
1640
  }) {
1641
- const [i, a] = O(!1), [s, r] = O(!1), o = de(() => Ke(e.args), [e.args]), l = de(
1641
+ const [i, s] = O(!1), [a, r] = O(!1), o = de(() => Ke(e.args), [e.args]), l = de(
1642
1642
  () => e.result === void 0 ? void 0 : Ke(e.result),
1643
1643
  [e.result]
1644
1644
  ), { title: c, family: p, preview: h } = on(e.name, o, l), u = t && l === void 0 && (o.incomplete || !e.args.trim()), f = A(o.value), m = !u && !o.incomplete && (!e.args.trim() || f !== void 0 && !Object.keys(f).length), x = ln(l, e.isError, t), v = xn[p], g = e.interrupt && !e.interrupt.ended && l === void 0, y = /* @__PURE__ */ d(
1645
1645
  "details",
1646
1646
  {
1647
1647
  className: "group min-w-0 text-xs",
1648
- onToggle: (C) => a(C.currentTarget.open),
1648
+ onToggle: (C) => s(C.currentTarget.open),
1649
1649
  children: [
1650
1650
  /* @__PURE__ */ d("summary", { className: "group/row flex min-w-0 cursor-pointer list-none items-center gap-2 -mx-1.5 rounded-sm px-1.5 py-1.5 text-muted-foreground outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground [&::-webkit-details-marker]:hidden", children: [
1651
1651
  /* @__PURE__ */ n(v, { className: "size-3.5 shrink-0 text-muted-foreground" }),
@@ -1684,9 +1684,9 @@ function yn({
1684
1684
  {
1685
1685
  type: "button",
1686
1686
  "aria-label": "Show raw arguments and result",
1687
- "aria-pressed": s,
1687
+ "aria-pressed": a,
1688
1688
  className: k("shrink-0 cursor-pointer rounded-sm outline-none"),
1689
- onClick: () => r(!s),
1689
+ onClick: () => r(!a),
1690
1690
  children: "Raw"
1691
1691
  }
1692
1692
  )
@@ -1697,7 +1697,7 @@ function yn({
1697
1697
  Ge,
1698
1698
  {
1699
1699
  payload: o,
1700
- raw: s,
1700
+ raw: a,
1701
1701
  receiving: t && l === void 0,
1702
1702
  tool: {
1703
1703
  name: e.name,
@@ -1714,7 +1714,7 @@ function yn({
1714
1714
  Ge,
1715
1715
  {
1716
1716
  payload: l,
1717
- raw: s,
1717
+ raw: a,
1718
1718
  markdown: e.name === "fork",
1719
1719
  tool: {
1720
1720
  name: e.name,
@@ -1736,55 +1736,55 @@ function yn({
1736
1736
  }
1737
1737
  function vn(e) {
1738
1738
  const t = /* @__PURE__ */ new Map();
1739
- let i, a;
1740
- for (const s of e)
1741
- if (s.kind === "assistant") {
1742
- if (s.subagent) {
1743
- const r = [s.agent, s.branch].filter((o, l, c) => o && c.indexOf(o) === l).join(" · ");
1744
- a !== s.subagent && t.set(s.id, r || "Subagent");
1745
- } else s.agent && ((i && i !== s.agent || a && i) && t.set(s.id, s.agent), i = s.agent);
1746
- a = s.subagent;
1739
+ let i, s;
1740
+ for (const a of e)
1741
+ if (a.kind === "assistant") {
1742
+ if (a.subagent) {
1743
+ const r = [a.agent, a.branch].filter((o, l, c) => o && c.indexOf(o) === l).join(" · ");
1744
+ s !== a.subagent && t.set(a.id, r || "Subagent");
1745
+ } else a.agent && ((i && i !== a.agent || s && i) && t.set(a.id, a.agent), i = a.agent);
1746
+ s = a.subagent;
1747
1747
  }
1748
1748
  return t;
1749
1749
  }
1750
1750
  function Ye(e, t) {
1751
- const i = (a) => a.kind === "tool" || a.kind === "reasoning";
1752
- return t.kind === "user" ? "mt-6" : i(e) && i(t) ? "" : "mt-3";
1751
+ const i = (s) => s.kind === "tool" || s.kind === "reasoning";
1752
+ return i(e) && i(t) ? "" : "mt-3";
1753
1753
  }
1754
1754
  const kt = (e) => e.kind === "tool" || e.kind === "reasoning";
1755
1755
  function wn(e) {
1756
1756
  let t = e.length;
1757
1757
  for (; t > 0 && e[t - 1].item.kind === "assistant"; ) t--;
1758
- const i = e.slice(t), a = e.findIndex(({ item: o }) => o.kind !== "user"), s = a < 0 ? [] : e.slice(a, t);
1759
- return s.some(({ item: o }) => kt(o)) && i.some(({ item: o }) => o.kind === "assistant" && o.text.trim() !== "") && !s.some(({ item: o }) => o.kind === "tool" && o.interrupt && !o.interrupt.ended) ? { before: e.slice(0, a), steps: s, answer: i } : { before: e, steps: [], answer: [] };
1758
+ const i = e.slice(t), s = e.findIndex(({ item: o }) => o.kind !== "user"), a = s < 0 ? [] : e.slice(s, t);
1759
+ return a.some(({ item: o }) => kt(o)) && i.some(({ item: o }) => o.kind === "assistant" && o.text.trim() !== "") && !a.some(({ item: o }) => o.kind === "tool" && o.interrupt && !o.interrupt.ended) ? { before: e.slice(0, s), steps: a, answer: i } : { before: e, steps: [], answer: [] };
1760
1760
  }
1761
1761
  function Nn({
1762
1762
  count: e,
1763
1763
  className: t,
1764
1764
  children: i
1765
1765
  }) {
1766
- const [a, s] = O(!1);
1766
+ const [s, a] = O(!1);
1767
1767
  return /* @__PURE__ */ d("div", { className: t, children: [
1768
1768
  /* @__PURE__ */ d(
1769
1769
  "button",
1770
1770
  {
1771
1771
  type: "button",
1772
- "aria-expanded": a,
1773
- onClick: () => s(!a),
1772
+ "aria-expanded": s,
1773
+ onClick: () => a(!s),
1774
1774
  className: k(
1775
1775
  "-mx-1.5 flex cursor-pointer items-center gap-1.5 rounded-sm px-1.5 py-1.5 text-sm outline-none hover:text-foreground focus-visible:bg-accent focus-visible:text-foreground",
1776
- a ? "text-foreground" : "text-muted-foreground"
1776
+ s ? "text-foreground" : "text-muted-foreground"
1777
1777
  ),
1778
1778
  children: [
1779
1779
  "Completed ",
1780
1780
  e,
1781
1781
  " ",
1782
1782
  e === 1 ? "step" : "steps",
1783
- a ? /* @__PURE__ */ n(st, { className: "size-4" }) : /* @__PURE__ */ n(lt, { className: "size-4" })
1783
+ s ? /* @__PURE__ */ n(at, { className: "size-4" }) : /* @__PURE__ */ n(lt, { className: "size-4" })
1784
1784
  ]
1785
1785
  }
1786
1786
  ),
1787
- a && /* @__PURE__ */ n("div", { className: "mb-1 ml-1.5 border-l border-border pl-3", children: i })
1787
+ s && /* @__PURE__ */ n("div", { className: "mb-1 ml-1.5 border-l border-border pl-3", children: i })
1788
1788
  ] });
1789
1789
  }
1790
1790
  function kn({ item: e, running: t, agent: i }) {
@@ -1845,30 +1845,29 @@ function _n({
1845
1845
  interrupts: i
1846
1846
  }) {
1847
1847
  var u, f;
1848
- const a = de(() => vn(e), [e]), s = de(() => {
1848
+ const s = de(() => vn(e), [e]), a = de(() => {
1849
1849
  const m = [];
1850
1850
  return e.forEach((x, v) => {
1851
1851
  (x.kind === "user" || m.length === 0) && m.push({ key: x.kind === "user" ? x.id : "head", rows: [] }), m.at(-1).rows.push({ item: x, index: v });
1852
1852
  }), m;
1853
1853
  }, [e]), r = (u = e.findLast((m) => m.kind === "user")) == null ? void 0 : u.id, o = $(null), l = $(null), c = $(void 0), p = $(void 0), h = (f = e[0]) == null ? void 0 : f.id;
1854
1854
  return Se(() => {
1855
- var x, v;
1855
+ var x, v, g;
1856
1856
  const m = c.current;
1857
- c.current = r, h !== p.current ? (p.current = h, (x = l.current) == null || x.scrollIntoView({ block: "end", behavior: "instant" })) : t && m && r !== m && ((v = o.current) == null || v.scrollIntoView({ block: "start", behavior: "smooth" }));
1857
+ c.current = r, h !== p.current ? (p.current = h, t && r ? (x = o.current) == null || x.scrollIntoView({ block: "start", behavior: "instant" }) : (v = l.current) == null || v.scrollIntoView({ block: "end", behavior: "instant" })) : t && r && r !== m && ((g = o.current) == null || g.scrollIntoView({ block: "start", behavior: "smooth" }));
1858
1858
  }, [h, r, t]), /* @__PURE__ */ n(ht.Provider, { value: i ?? null, children: /* @__PURE__ */ d("div", { className: "mx-auto flex w-full max-w-5xl flex-col p-4", children: [
1859
- s.map((m, x) => {
1859
+ a.map((m, x) => {
1860
1860
  var C;
1861
- const v = x === s.length - 1, g = v && t ? { before: m.rows, steps: [], answer: [] } : wn(m.rows), y = (w, j = !1) => w.map(({ item: L, index: E }) => /* @__PURE__ */ n(
1861
+ const v = x === a.length - 1, g = v && t ? { before: m.rows, steps: [], answer: [] } : wn(m.rows), y = (w, j = !1) => w.map(({ item: L, index: E }) => /* @__PURE__ */ n(
1862
1862
  "div",
1863
1863
  {
1864
- ref: v && L.id === r ? o : void 0,
1865
1864
  className: k(
1866
- "min-w-0 scroll-mt-4",
1867
- E > 0 && !j && Ye(e[E - 1], L),
1865
+ "min-w-0",
1866
+ E > 0 && !j && L.kind !== "user" && Ye(e[E - 1], L),
1868
1867
  // Folded steps are evenly spaced, remarks as tall as a step row.
1869
1868
  j && L.kind === "assistant" && "py-1.5"
1870
1869
  ),
1871
- children: /* @__PURE__ */ n(kn, { item: L, running: t, agent: a.get(L.id) })
1870
+ children: /* @__PURE__ */ n(kn, { item: L, running: t, agent: s.get(L.id) })
1872
1871
  },
1873
1872
  `${L.kind}:${L.id}`
1874
1873
  ));
@@ -1877,9 +1876,11 @@ function _n({
1877
1876
  /* @__PURE__ */ d(
1878
1877
  "div",
1879
1878
  {
1879
+ ref: v && m.rows[0].item.kind === "user" ? o : void 0,
1880
1880
  className: k(
1881
- "flex flex-col",
1882
- v && "min-h-[var(--chat-turn-min,calc(100dvh-168px))]"
1881
+ "flex flex-col scroll-mt-4",
1882
+ x > 0 && "mt-6",
1883
+ v && "min-h-[var(--chat-turn-min,calc(100cqh-var(--chat-turn-gap,2rem)))]"
1883
1884
  ),
1884
1885
  children: [
1885
1886
  y(g.before),
@@ -1911,10 +1912,10 @@ function Sn({
1911
1912
  nudge: t = 0,
1912
1913
  variants: i
1913
1914
  }) {
1914
- const a = i != null && i.length ? Cn(i, t) : void 0, s = (a == null ? void 0 : a.title) ?? "Start your chat here", r = a ? a.subtitle : e;
1915
+ const s = i != null && i.length ? Cn(i, t) : void 0, a = (s == null ? void 0 : s.title) ?? "Start your chat here", r = s ? s.subtitle : e;
1915
1916
  return /* @__PURE__ */ n("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 p-6 text-center", children: /* @__PURE__ */ d("div", { className: "empty-chat-nudge flex flex-col items-center gap-2", children: [
1916
1917
  /* @__PURE__ */ n(Jt, { className: "size-8 text-muted-foreground" }),
1917
- /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: s }),
1918
+ /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: a }),
1918
1919
  r && /* @__PURE__ */ n("p", { className: "text-sm text-muted-foreground", children: r })
1919
1920
  ] }, t) });
1920
1921
  }
@@ -1929,17 +1930,17 @@ function zn({
1929
1930
  disabled: e,
1930
1931
  running: t,
1931
1932
  placeholder: i,
1932
- historyKey: a,
1933
- draftKey: s,
1933
+ historyKey: s,
1934
+ draftKey: a,
1934
1935
  focusSignal: r,
1935
1936
  onSend: o,
1936
1937
  onStop: l
1937
1938
  }) {
1938
- const [c, p] = O(() => s ? Vr(s) : "");
1939
+ const [c, p] = O(() => a ? Vr(a) : "");
1939
1940
  P(() => {
1940
- s && Be(s, c);
1941
- }, [s, c]);
1942
- const h = Gr(() => a ? pt(a) : []), u = $(null), f = $(null), m = ue(
1941
+ a && Be(a, c);
1942
+ }, [a, c]);
1943
+ const h = Gr(() => s ? pt(s) : []), u = $(null), f = $(null), m = ue(
1943
1944
  (y) => Br(u.current, y),
1944
1945
  []
1945
1946
  );
@@ -1956,7 +1957,7 @@ function zn({
1956
1957
  y && (y.style.height = "auto", y.style.height = `${y.scrollHeight}px`);
1957
1958
  }, [c]);
1958
1959
  const v = (y) => {
1959
- y == null || y.preventDefault(), !(e || t || !c.trim()) && (o(c), a && Kr(a, c), h.reset(), s && Be(s, ""), p(""), m(f.current));
1960
+ y == null || y.preventDefault(), !(e || t || !c.trim()) && (o(c), s && Kr(s, c), h.reset(), a && Be(a, ""), p(""), m(f.current));
1960
1961
  };
1961
1962
  return /* @__PURE__ */ n("form", { ref: f, onSubmit: v, className: "mx-auto w-full max-w-5xl p-4", children: /* @__PURE__ */ d(
1962
1963
  "div",
@@ -1973,7 +1974,7 @@ function zn({
1973
1974
  value: c,
1974
1975
  onChange: (y) => p(y.target.value),
1975
1976
  onKeyDown: (y) => {
1976
- y.key === "Enter" && !y.shiftKey && !y.nativeEvent.isComposing ? v(y) : a && h.onKeyDown(y, c, p);
1977
+ y.key === "Enter" && !y.shiftKey && !y.nativeEvent.isComposing ? v(y) : s && h.onKeyDown(y, c, p);
1977
1978
  },
1978
1979
  placeholder: i,
1979
1980
  className: "max-h-60 min-h-9 resize-none overflow-y-auto border-0 bg-transparent leading-5 focus-visible:ring-0"
@@ -2007,7 +2008,7 @@ function zn({
2007
2008
  ) });
2008
2009
  }
2009
2010
  let Ln;
2010
- const On = () => Ln ?? (Ln = import("./shadow-DmEgvnQS.js").then((e) => e.default));
2011
+ const On = () => Ln ?? (Ln = import("./shadow-BRAwePHz.js").then((e) => e.default));
2011
2012
  function An(e) {
2012
2013
  if (document.querySelector("style[data-zenera-chat-properties]")) return;
2013
2014
  const t = e.match(/@property\s+[^{]+\{[^}]*\}/g);
@@ -2021,9 +2022,9 @@ function _t({
2021
2022
  className: t,
2022
2023
  style: i
2023
2024
  }) {
2024
- const a = $(null), [s, r] = O(null);
2025
+ const s = $(null), [a, r] = O(null);
2025
2026
  return Se(() => {
2026
- const o = a.current;
2027
+ const o = s.current;
2027
2028
  if (!o) return;
2028
2029
  const l = o.shadowRoot ?? o.attachShadow({ mode: "open" }), c = document.createElement("style"), p = document.createElement("div");
2029
2030
  p.style.height = "100%", l.append(c, p);
@@ -2036,12 +2037,12 @@ function _t({
2036
2037
  }, []), /* @__PURE__ */ n(
2037
2038
  "div",
2038
2039
  {
2039
- ref: a,
2040
+ ref: s,
2040
2041
  className: t,
2041
2042
  style: { display: "block", height: "100%", ...i },
2042
- children: s && ct(
2043
- /* @__PURE__ */ n(mt.Provider, { value: s, children: e }),
2044
- s
2043
+ children: a && ct(
2044
+ /* @__PURE__ */ n(mt.Provider, { value: a, children: e }),
2045
+ a
2045
2046
  )
2046
2047
  }
2047
2048
  );
@@ -2049,14 +2050,14 @@ function _t({
2049
2050
  const ke = (e) => e && Object.fromEntries(
2050
2051
  Object.entries(e).map(([t, i]) => [`--${t}`, i])
2051
2052
  );
2052
- function _i({ isolate: e = !0, className: t, style: i, theme: a, ...s }) {
2053
+ function _i({ isolate: e = !0, className: t, style: i, theme: s, ...a }) {
2053
2054
  const r = je();
2054
- return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(Oe, { ...s, dark: r === "dark", rootStyle: ke(a) }) }) : /* @__PURE__ */ n(
2055
+ return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(Oe, { ...a, dark: r === "dark", rootStyle: ke(s) }) }) : /* @__PURE__ */ n(
2055
2056
  Oe,
2056
2057
  {
2057
- ...s,
2058
+ ...a,
2058
2059
  rootClassName: t,
2059
- rootStyle: { ...ke(a), ...i }
2060
+ rootStyle: { ...ke(s), ...i }
2060
2061
  }
2061
2062
  );
2062
2063
  }
@@ -2064,8 +2065,8 @@ function Oe({
2064
2065
  transport: e,
2065
2066
  threadId: t,
2066
2067
  onThreadChange: i,
2067
- onTurnEnd: a,
2068
- placeholder: s = "Message…",
2068
+ onTurnEnd: s,
2069
+ placeholder: a = "Message…",
2069
2070
  starterMessages: r,
2070
2071
  newChatSignal: o = 0,
2071
2072
  historyKey: l,
@@ -2083,16 +2084,16 @@ function Oe({
2083
2084
  }, [y, v, g]);
2084
2085
  const L = g.status === "running", [E, q] = O(!1);
2085
2086
  P(() => {
2086
- E && !L && (a == null || a()), q(L);
2087
- }, [L, E, a]);
2087
+ E && !L && (s == null || s()), q(L);
2088
+ }, [L, E, s]);
2088
2089
  const D = ue(
2089
- (ae) => {
2090
+ (se) => {
2090
2091
  if (v) {
2091
- g.send(ae);
2092
+ g.send(se);
2092
2093
  return;
2093
2094
  }
2094
2095
  e && (j(!0), e.createThread().then(({ thread: B }) => {
2095
- C(ae), x(B.id), i == null || i(B.id);
2096
+ C(se), x(B.id), i == null || i(B.id);
2096
2097
  }).catch(() => {
2097
2098
  }).finally(() => j(!1)));
2098
2099
  },
@@ -2109,7 +2110,7 @@ function Oe({
2109
2110
  ),
2110
2111
  style: h,
2111
2112
  children: [
2112
- J ? /* @__PURE__ */ n("div", { className: "flex flex-1 items-center justify-center p-6 text-center", children: /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: g.error }) }) : !v && !g.items.length && (r != null && r.length) ? /* @__PURE__ */ n(Sn, { nudge: o, variants: r }) : /* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-y-auto [--chat-turn-min:calc(100cqh_-_2rem)] [container-type:size]", children: [
2113
+ J ? /* @__PURE__ */ n("div", { className: "flex flex-1 items-center justify-center p-6 text-center", children: /* @__PURE__ */ n("h2", { className: "text-xl font-semibold", children: g.error }) }) : !v && !g.items.length && (r != null && r.length) ? /* @__PURE__ */ n(Sn, { nudge: o, variants: r }) : /* @__PURE__ */ d("div", { className: "min-h-0 flex-1 overflow-y-auto [container-type:size]", children: [
2113
2114
  /* @__PURE__ */ n(
2114
2115
  _n,
2115
2116
  {
@@ -2140,7 +2141,7 @@ function Oe({
2140
2141
  {
2141
2142
  disabled: !e || !!g.starting || w,
2142
2143
  running: L,
2143
- placeholder: s,
2144
+ placeholder: a,
2144
2145
  historyKey: l,
2145
2146
  draftKey: c,
2146
2147
  onSend: D,
@@ -2152,28 +2153,28 @@ function Oe({
2152
2153
  );
2153
2154
  }
2154
2155
  function Tn(e, t = 4e3) {
2155
- const [i, a] = O(null), s = $(void 0);
2156
- P(() => () => clearTimeout(s.current), []);
2156
+ const [i, s] = O(null), a = $(void 0);
2157
+ P(() => () => clearTimeout(a.current), []);
2157
2158
  const r = ue(() => {
2158
- clearTimeout(s.current), a(null);
2159
+ clearTimeout(a.current), s(null);
2159
2160
  }, []);
2160
2161
  return { armed: i, request: (l) => {
2161
- if (clearTimeout(s.current), i !== l) {
2162
- a(l), s.current = setTimeout(() => a(null), t);
2162
+ if (clearTimeout(a.current), i !== l) {
2163
+ s(l), a.current = setTimeout(() => s(null), t);
2163
2164
  return;
2164
2165
  }
2165
- a(null), e(l);
2166
+ s(null), e(l);
2166
2167
  }, disarm: r };
2167
2168
  }
2168
2169
  function jn({
2169
2170
  armed: e,
2170
2171
  onClick: t,
2171
2172
  disabled: i,
2172
- label: a = "Delete",
2173
- alwaysShown: s,
2173
+ label: s = "Delete",
2174
+ alwaysShown: a,
2174
2175
  className: r
2175
2176
  }) {
2176
- const o = e ? "Click again to delete" : a;
2177
+ const o = e ? "Click again to delete" : s;
2177
2178
  return /* @__PURE__ */ n(ye, { label: o, children: /* @__PURE__ */ d(
2178
2179
  "button",
2179
2180
  {
@@ -2185,7 +2186,7 @@ function jn({
2185
2186
  },
2186
2187
  className: k(
2187
2188
  "cursor-pointer items-center gap-1 rounded p-1 text-xs text-muted-foreground hover:text-danger disabled:opacity-50",
2188
- e ? "flex bg-danger/15 px-1.5 text-danger" : s ? "flex" : "hidden group-focus-within:flex group-hover:flex [@media(hover:none)]:flex",
2189
+ e ? "flex bg-danger/15 px-1.5 text-danger" : a ? "flex" : "hidden group-focus-within:flex group-hover:flex [@media(hover:none)]:flex",
2189
2190
  r
2190
2191
  ),
2191
2192
  children: [
@@ -2200,15 +2201,15 @@ function Pn(e, t, i) {
2200
2201
  return e === "right" ? i.right - t : t - i.left;
2201
2202
  }
2202
2203
  function Mn(e = "zenera.chatSidebar", t = "left", i) {
2203
- const a = `${e}Collapsed`, s = `${e}Width`, [r, o] = O(() => {
2204
+ const s = `${e}Collapsed`, a = `${e}Width`, [r, o] = O(() => {
2204
2205
  if (i !== void 0) return i;
2205
- const m = Qe(a);
2206
+ const m = Qe(s);
2206
2207
  return m !== null ? m === "1" : typeof window < "u" && window.matchMedia("(max-width: 767px)").matches;
2207
2208
  }), [l, c] = O(() => {
2208
- const m = Number(Qe(s));
2209
+ const m = Number(Qe(a));
2209
2210
  return m >= Ee && m <= Ve ? m : In;
2210
2211
  }), [p, h] = O(!1);
2211
- return { collapsed: r, width: l, resizing: p, toggle: () => o((m) => (localStorage.setItem(a, m ? "0" : "1"), !m)), setCollapsed: o, startResize: (m) => {
2212
+ return { collapsed: r, width: l, resizing: p, toggle: () => o((m) => (localStorage.setItem(s, m ? "0" : "1"), !m)), setCollapsed: o, startResize: (m) => {
2212
2213
  var q;
2213
2214
  const x = m.currentTarget.parentElement;
2214
2215
  if (!x) return;
@@ -2224,7 +2225,7 @@ function Mn(e = "zenera.chatSidebar", t = "left", i) {
2224
2225
  const J = Pn(t, D.clientX, C);
2225
2226
  w = J < $n, o(w), w || (j = Math.round(Math.min(Math.max(J, Ee), g)), c(j));
2226
2227
  }, E = () => {
2227
- y.removeEventListener("pointermove", L), y.removeEventListener("lostpointercapture", E), h(!1), localStorage.setItem(a, w ? "1" : "0"), localStorage.setItem(s, String(j));
2228
+ y.removeEventListener("pointermove", L), y.removeEventListener("lostpointercapture", E), h(!1), localStorage.setItem(s, w ? "1" : "0"), localStorage.setItem(a, String(j));
2228
2229
  };
2229
2230
  y.addEventListener("pointermove", L), y.addEventListener("lostpointercapture", E);
2230
2231
  } };
@@ -2233,8 +2234,8 @@ function Dn({
2233
2234
  transport: e,
2234
2235
  layout: t,
2235
2236
  activeThreadId: i,
2236
- onSelect: a,
2237
- onNew: s,
2237
+ onSelect: s,
2238
+ onNew: a,
2238
2239
  onDelete: r,
2239
2240
  renderLink: o,
2240
2241
  newDisabled: l,
@@ -2305,7 +2306,7 @@ function Dn({
2305
2306
  size: "icon",
2306
2307
  "aria-label": "New chat",
2307
2308
  disabled: w,
2308
- onClick: s,
2309
+ onClick: a,
2309
2310
  children: /* @__PURE__ */ n(tr, {})
2310
2311
  }
2311
2312
  ) }) : /* @__PURE__ */ d(
@@ -2314,7 +2315,7 @@ function Dn({
2314
2315
  variant: "outline",
2315
2316
  className: "min-w-0 flex-1 justify-start overflow",
2316
2317
  disabled: w,
2317
- onClick: s,
2318
+ onClick: a,
2318
2319
  children: [
2319
2320
  /* @__PURE__ */ n(rr, {}),
2320
2321
  "New chat"
@@ -2352,7 +2353,7 @@ function Dn({
2352
2353
  {
2353
2354
  type: "button",
2354
2355
  className: D.className,
2355
- onClick: () => a == null ? void 0 : a(E.id),
2356
+ onClick: () => s == null ? void 0 : s(E.id),
2356
2357
  children: D.children
2357
2358
  }
2358
2359
  ),
@@ -2382,16 +2383,16 @@ function Si({
2382
2383
  isolate: e = !0,
2383
2384
  className: t,
2384
2385
  style: i,
2385
- theme: a,
2386
- ...s
2386
+ theme: s,
2387
+ ...a
2387
2388
  }) {
2388
2389
  const r = je();
2389
- return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(et, { ...s, dark: r === "dark", rootStyle: ke(a) }) }) : /* @__PURE__ */ n(
2390
+ return e ? /* @__PURE__ */ n(_t, { className: t, style: i, children: /* @__PURE__ */ n(et, { ...a, dark: r === "dark", rootStyle: ke(s) }) }) : /* @__PURE__ */ n(
2390
2391
  et,
2391
2392
  {
2392
- ...s,
2393
+ ...a,
2393
2394
  rootClassName: t,
2394
- rootStyle: { ...ke(a), ...i }
2395
+ rootStyle: { ...ke(s), ...i }
2395
2396
  }
2396
2397
  );
2397
2398
  }
@@ -2399,8 +2400,8 @@ function et({
2399
2400
  transport: e,
2400
2401
  threadId: t,
2401
2402
  onThreadChange: i,
2402
- onTurnEnd: a,
2403
- renderLink: s,
2403
+ onTurnEnd: s,
2404
+ renderLink: a,
2404
2405
  sidebarStorageKey: r,
2405
2406
  sidebarSide: o = "left",
2406
2407
  sidebarCollapsed: l,
@@ -2428,9 +2429,9 @@ function et({
2428
2429
  var R;
2429
2430
  return (R = D.current) == null ? void 0 : R.call(D, g);
2430
2431
  }, [g]);
2431
- const [J, ae] = O(null), [B, ve] = O(0), se = t === void 0 ? J : t, [Ce, we] = O(0), H = ue(
2432
+ const [J, se] = O(null), [B, ve] = O(0), ae = t === void 0 ? J : t, [Ce, we] = O(0), H = ue(
2432
2433
  (R) => {
2433
- ae(R), i == null || i(R);
2434
+ se(R), i == null || i(R);
2434
2435
  },
2435
2436
  [i]
2436
2437
  ), G = /* @__PURE__ */ n(
@@ -2440,13 +2441,13 @@ function et({
2440
2441
  layout: E,
2441
2442
  side: o,
2442
2443
  showToggle: p,
2443
- activeThreadId: se,
2444
+ activeThreadId: ae,
2444
2445
  onSelect: H,
2445
2446
  onNew: () => {
2446
2447
  ve((R) => R + 1), H(null);
2447
2448
  },
2448
- onDelete: (R) => R === se && H(null),
2449
- renderLink: s,
2449
+ onDelete: (R) => R === ae && H(null),
2450
+ renderLink: a,
2450
2451
  refreshKey: Ce,
2451
2452
  className: h
2452
2453
  }
@@ -2470,12 +2471,12 @@ function et({
2470
2471
  nested: !0,
2471
2472
  newChatSignal: B,
2472
2473
  transport: e,
2473
- threadId: se,
2474
+ threadId: ae,
2474
2475
  onThreadChange: (R) => {
2475
2476
  we((Q) => Q + 1), H(R);
2476
2477
  },
2477
2478
  onTurnEnd: () => {
2478
- we((R) => R + 1), a == null || a();
2479
+ we((R) => R + 1), s == null || s();
2479
2480
  }
2480
2481
  }
2481
2482
  ) }),
@@ -2490,25 +2491,25 @@ function Lt(e, t) {
2490
2491
  e.width,
2491
2492
  fe(Ct, t.width),
2492
2493
  Math.max(t.width, 0)
2493
- ), a = Y(
2494
+ ), s = Y(
2494
2495
  e.height,
2495
2496
  fe(Et, t.height),
2496
2497
  Math.max(t.height, 0)
2497
2498
  );
2498
2499
  return {
2499
2500
  width: i,
2500
- height: a,
2501
+ height: s,
2501
2502
  left: Y(e.left, 0, t.width - i),
2502
- top: Y(e.top, 0, t.height - a)
2503
+ top: Y(e.top, 0, t.height - s)
2503
2504
  };
2504
2505
  }
2505
- function Hn(e, t, i, a) {
2506
- return Lt({ ...e, left: e.left + t, top: e.top + i }, a);
2506
+ function Hn(e, t, i, s) {
2507
+ return Lt({ ...e, left: e.left + t, top: e.top + i }, s);
2507
2508
  }
2508
- function qn(e, t, i, a, s) {
2509
- const r = fe(Ct, s.width), o = fe(Et, s.height);
2509
+ function qn(e, t, i, s, a) {
2510
+ const r = fe(Ct, a.width), o = fe(Et, a.height);
2510
2511
  let l = e.left, c = e.top, p = e.left + e.width, h = e.top + e.height;
2511
- return t.includes("w") && (l = Y(l + i, 0, p - r)), t.includes("e") && (p = Y(p + i, l + r, s.width)), t.includes("n") && (c = Y(c + a, 0, h - o)), t.includes("s") && (h = Y(h + a, c + o, s.height)), { left: l, top: c, width: p - l, height: h - c };
2512
+ return t.includes("w") && (l = Y(l + i, 0, p - r)), t.includes("e") && (p = Y(p + i, l + r, a.width)), t.includes("n") && (c = Y(c + s, 0, h - o)), t.includes("s") && (h = Y(h + s, c + o, a.height)), { left: l, top: c, width: p - l, height: h - c };
2512
2513
  }
2513
2514
  function Bn(e, t) {
2514
2515
  const i = t ? e - Wn : e;
@@ -2521,22 +2522,22 @@ function Ot(e, t, i) {
2521
2522
  Bn(t, i)
2522
2523
  );
2523
2524
  }
2524
- function tt(e, t, i, a, s) {
2525
+ function tt(e, t, i, s, a) {
2525
2526
  const r = t === "right" ? e - i : e + i;
2526
- return Ot(r, a, s);
2527
+ return Ot(r, s, a);
2527
2528
  }
2528
2529
  const he = (e) => {
2529
2530
  throw new Error(`ZeneraChatLauncher: ${e}`);
2530
2531
  };
2531
2532
  function rt(e, t) {
2532
- const { mode: i, side: a = "right", width: s, resizable: r = !0, defaultOpen: o = !1 } = e, { placement: l, height: c, contentTarget: p, draggable: h = !0 } = e;
2533
- i !== "popup" && i !== "sidebar" && he(`presentation.mode must be 'popup' or 'sidebar', not ${String(i)}`), a !== "left" && a !== "right" && he(`presentation.side must be 'left' or 'right', not ${String(a)}`);
2533
+ const { mode: i, side: s = "right", width: a, resizable: r = !0, defaultOpen: o = !1 } = e, { placement: l, height: c, contentTarget: p, draggable: h = !0 } = e;
2534
+ i !== "popup" && i !== "sidebar" && he(`presentation.mode must be 'popup' or 'sidebar', not ${String(i)}`), s !== "left" && s !== "right" && he(`presentation.side must be 'left' or 'right', not ${String(s)}`);
2534
2535
  let u = null;
2535
2536
  return i === "sidebar" && (l !== "overlay" && l !== "docked" && he("a sidebar needs presentation.placement: 'overlay' or 'docked'"), l === "docked" && (p || he("a docked sidebar needs presentation.contentTarget"), u = typeof p == "string" ? t(p) : p, u || he(`contentTarget ${String(p)} matches no element`))), {
2536
2537
  mode: i,
2537
2538
  docked: i === "sidebar" && l === "docked",
2538
- side: a,
2539
- width: s ?? (i === "popup" ? "380px" : "820px"),
2539
+ side: s,
2540
+ width: a ?? (i === "popup" ? "380px" : "820px"),
2540
2541
  height: c ?? "600px",
2541
2542
  contentTarget: u,
2542
2543
  resizable: r,
@@ -2606,7 +2607,7 @@ slot { display: block; height: 100%; }
2606
2607
  :host([data-scheme='dark']) .header { border-color: #374151; }
2607
2608
  `, Jn = '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>', U = (e, t = {}) => {
2608
2609
  const i = document.createElement(e);
2609
- for (const [a, s] of Object.entries(t)) i.setAttribute(a, s);
2610
+ for (const [s, a] of Object.entries(t)) i.setAttribute(s, a);
2610
2611
  return i;
2611
2612
  };
2612
2613
  function Xn(e) {
@@ -2615,8 +2616,8 @@ function Xn(e) {
2615
2616
  if (!t) throw new Error("ZeneraChatLauncher: chatId is required");
2616
2617
  if (document.getElementById(t))
2617
2618
  throw new Error(`ZeneraChatLauncher: the page already has an element with id "${t}"`);
2618
- const a = (b) => document.querySelector(b), s = (De = window.matchMedia) == null ? void 0 : De.call(window, Fn);
2619
- let r = e.presentation, o = rt(r, a), l = o.defaultOpen, c = !1, p = (s == null ? void 0 : s.matches) ?? !1, h = null, u = null, f = null, m = null;
2619
+ const s = (b) => document.querySelector(b), a = (De = window.matchMedia) == null ? void 0 : De.call(window, Fn);
2620
+ let r = e.presentation, o = rt(r, s), l = o.defaultOpen, c = !1, p = (a == null ? void 0 : a.matches) ?? !1, h = null, u = null, f = null, m = null;
2620
2621
  const x = U("div", { "data-zenera-chat-launcher": "" }), v = U("div", { id: t });
2621
2622
  v.style.cssText = "display:block;height:100%", x.append(v);
2622
2623
  const g = x.attachShadow({ mode: "open" }), y = U("style");
@@ -2645,7 +2646,7 @@ function Xn(e) {
2645
2646
  if (!h) return;
2646
2647
  const { target: b, property: S, value: N, priority: z } = h;
2647
2648
  N ? b.style.setProperty(S, N, z) : b.style.removeProperty(S), h = null;
2648
- }, ae = (b, S) => {
2649
+ }, se = (b, S) => {
2649
2650
  const N = b.contentTarget, z = b.side === "left" ? "margin-left" : "margin-right";
2650
2651
  h = {
2651
2652
  target: N,
@@ -2659,7 +2660,7 @@ function Xn(e) {
2659
2660
  }), ve = () => {
2660
2661
  const { left: b, top: S, width: N, height: z } = w.getBoundingClientRect();
2661
2662
  return { left: b, top: S, width: N, height: z };
2662
- }, se = () => l && o.docked && !p, Ce = (b) => {
2663
+ }, ae = () => l && o.docked && !p, Ce = (b) => {
2663
2664
  const { mode: S, side: N, width: z, height: F, resizable: X, draggable: oe } = o, le = S === "popup", W = w.style;
2664
2665
  le && f ? (f = Lt(f, B()), W.left = `${f.left}px`, W.top = `${f.top}px`, W.width = `${f.width}px`, W.height = `${f.height}px`, W.right = W.bottom = "auto", W.maxWidth = W.maxHeight = "none") : (W.left = W.top = W.right = W.bottom = "", W.maxWidth = W.maxHeight = "", W.width = le ? z : we(b), W.height = le ? F : ""), j.toggleAttribute("data-draggable", le && oe);
2665
2666
  const At = N === "right" ? "w" : "e";
@@ -2673,7 +2674,7 @@ function Xn(e) {
2673
2674
  }
2674
2675
  }, we = (b) => m === null ? o.width : `${Ot(m, B().width, b)}px`, H = () => {
2675
2676
  const { mode: b, side: S, docked: N } = o, z = l && N && !p;
2676
- w.dataset.mode = b, w.dataset.side = S, C.dataset.side = S, w.toggleAttribute("data-overlay", b === "sidebar" && !z), w.hidden = !l, C.hidden = l && b === "sidebar", C.setAttribute("aria-expanded", String(l)), C.setAttribute("aria-label", l ? "Close chat" : "Open chat"), Ce(z), J(), z && ae(o, w.style.width);
2677
+ w.dataset.mode = b, w.dataset.side = S, C.dataset.side = S, w.toggleAttribute("data-overlay", b === "sidebar" && !z), w.hidden = !l, C.hidden = l && b === "sidebar", C.setAttribute("aria-expanded", String(l)), C.setAttribute("aria-label", l ? "Close chat" : "Open chat"), Ce(z), J(), z && se(o, w.style.width);
2677
2678
  }, G = (b) => {
2678
2679
  if (b === l) return;
2679
2680
  b && (u = document.activeElement);
@@ -2708,7 +2709,7 @@ function Xn(e) {
2708
2709
  f = qn(F, b, X, oe, B()), H();
2709
2710
  };
2710
2711
  }
2711
- const N = w.getBoundingClientRect().width, z = se();
2712
+ const N = w.getBoundingClientRect().width, z = ae();
2712
2713
  return (F) => {
2713
2714
  m = tt(
2714
2715
  N,
@@ -2732,7 +2733,7 @@ function Xn(e) {
2732
2733
  o.side,
2733
2734
  S === "ArrowLeft" ? -nt : nt,
2734
2735
  B().width,
2735
- se()
2736
+ ae()
2736
2737
  ), H());
2737
2738
  });
2738
2739
  const Pe = () => x.setAttribute(
@@ -2742,7 +2743,7 @@ function Xn(e) {
2742
2743
  return Me.observe(document.documentElement, {
2743
2744
  attributes: !0,
2744
2745
  attributeFilter: ["class"]
2745
- }), C.addEventListener("click", () => G(!l)), E.addEventListener("click", () => G(!1)), document.addEventListener("keydown", Q), s == null || s.addEventListener("change", Re), window.addEventListener("resize", Ie), Pe(), H(), document.body.append(x), {
2746
+ }), C.addEventListener("click", () => G(!l)), E.addEventListener("click", () => G(!1)), document.addEventListener("keydown", Q), a == null || a.addEventListener("change", Re), window.addEventListener("resize", Ie), Pe(), H(), document.body.append(x), {
2746
2747
  container: v,
2747
2748
  get isOpen() {
2748
2749
  return l;
@@ -2760,11 +2761,11 @@ function Xn(e) {
2760
2761
  R();
2761
2762
  const S = Object.fromEntries(
2762
2763
  Object.entries(b).filter(([, X]) => X !== void 0)
2763
- ), N = { ...r, ...S }, z = rt(N, a), F = z.width !== o.width;
2764
+ ), N = { ...r, ...S }, z = rt(N, s), F = z.width !== o.width;
2764
2765
  (F || z.side !== o.side || z.height !== o.height) && (f = null), F && (m = null), o = z, r = N, H();
2765
2766
  },
2766
2767
  unmount() {
2767
- c || (c = !0, J(), document.removeEventListener("keydown", Q), s == null || s.removeEventListener("change", Re), window.removeEventListener("resize", Ie), Me.disconnect(), x.remove());
2768
+ c || (c = !0, J(), document.removeEventListener("keydown", Q), a == null || a.removeEventListener("change", Re), window.removeEventListener("resize", Ie), Me.disconnect(), x.remove());
2768
2769
  }
2769
2770
  };
2770
2771
  }
@@ -2772,11 +2773,11 @@ function Ci({
2772
2773
  chatId: e,
2773
2774
  presentation: t,
2774
2775
  open: i,
2775
- onOpenChange: a,
2776
- children: s
2776
+ onOpenChange: s,
2777
+ children: a
2777
2778
  }) {
2778
- const [r, o] = O(null), l = $({ presentation: t, open: i, onOpenChange: a });
2779
- l.current = { presentation: t, open: i, onOpenChange: a }, P(() => {
2779
+ const [r, o] = O(null), l = $({ presentation: t, open: i, onOpenChange: s });
2780
+ l.current = { presentation: t, open: i, onOpenChange: s }, P(() => {
2780
2781
  const { presentation: g, open: y } = l.current, C = Xn({
2781
2782
  chatId: e,
2782
2783
  presentation: { ...g, defaultOpen: y ?? g.defaultOpen },
@@ -2803,7 +2804,7 @@ function Ci({
2803
2804
  });
2804
2805
  }, [r, c, u, p, h, f, m, v, x]), P(() => {
2805
2806
  !r || i === void 0 || i === r.isOpen || (i ? r.open() : r.close());
2806
- }, [r, i]), r ? ct(s, r.container) : null;
2807
+ }, [r, i]), r ? ct(a, r.container) : null;
2807
2808
  }
2808
2809
  export {
2809
2810
  _n as ChatMessages,