@green-on-grey/ui-kit 1.10.3 → 1.11.1

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/chat.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as e, f as t, i as n, l as r, s as i, u as a } from "./ui-sV5t0cp1.js";
1
+ import { c as e, f as t, i as n, l as r, s as i, u as a } from "./ui-BrAaLui6.js";
2
2
  import { n as o, t as s } from "./i18n-BJ8rsBp6.js";
3
3
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
4
4
  import { useCallback as d, useEffect as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
@@ -77,25 +77,25 @@ function x(e, t) {
77
77
  maximumFractionDigits: 1
78
78
  }).format(e);
79
79
  }
80
- function S({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
81
- let a = o(), { i18n: d } = _(s), [f, p] = g(!1), m = i(f, () => p(!1)), h = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, v = Math.round(h * 100), y = h >= .9 ? "full" : h >= .7 ? "warn" : "", b = 2 * Math.PI * 7, S = d.language;
80
+ function S({ context: e, onCompact: t, onReset: n, busy: r = !1, queued: a = !1 }) {
81
+ let d = o(), { i18n: f } = _(s), [p, m] = g(!1), h = i(p, () => m(!1)), v = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, y = Math.round(v * 100), b = v >= .9 ? "full" : v >= .7 ? "warn" : "", S = 2 * Math.PI * 7, w = f.language;
82
82
  return /* @__PURE__ */ u("div", {
83
83
  className: "ctxmeter",
84
- ref: m,
84
+ ref: h,
85
85
  children: [/* @__PURE__ */ l("button", {
86
86
  type: "button",
87
- className: `ctxring ${y}`,
88
- "aria-expanded": f,
89
- onClick: () => p((e) => !e),
90
- "aria-label": a("chat.context.meter", {
91
- used: x(e.tokens, S),
92
- total: x(e.window, S),
93
- pct: v
87
+ className: `ctxring ${b}`,
88
+ "aria-expanded": p,
89
+ onClick: () => m((e) => !e),
90
+ "aria-label": d("chat.context.meter", {
91
+ used: x(e.tokens, w),
92
+ total: x(e.window, w),
93
+ pct: y
94
94
  }),
95
- title: a("chat.context.meter", {
96
- used: x(e.tokens, S),
97
- total: x(e.window, S),
98
- pct: v
95
+ title: d("chat.context.meter", {
96
+ used: x(e.tokens, w),
97
+ total: x(e.window, w),
98
+ pct: y
99
99
  }),
100
100
  children: /* @__PURE__ */ u("svg", {
101
101
  viewBox: "0 0 18 18",
@@ -110,25 +110,25 @@ function S({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
110
110
  cx: "9",
111
111
  cy: "9",
112
112
  r: 7,
113
- strokeDasharray: `${(b * h).toFixed(1)} ${b.toFixed(1)}`,
113
+ strokeDasharray: `${(S * v).toFixed(1)} ${S.toFixed(1)}`,
114
114
  transform: "rotate(-90 9 9)"
115
115
  })]
116
116
  })
117
- }), f && /* @__PURE__ */ u("div", {
117
+ }), p && /* @__PURE__ */ u("div", {
118
118
  className: "ctxtip",
119
119
  role: "dialog",
120
120
  children: [
121
- /* @__PURE__ */ l("div", { children: a("chat.context.meter", {
122
- used: x(e.tokens, S),
123
- total: x(e.window, S),
124
- pct: v
121
+ /* @__PURE__ */ l("div", { children: d("chat.context.meter", {
122
+ used: x(e.tokens, w),
123
+ total: x(e.window, w),
124
+ pct: y
125
125
  }) }),
126
- y === "full" && /* @__PURE__ */ l("div", {
126
+ b === "full" && /* @__PURE__ */ l("div", {
127
127
  className: "small muted",
128
128
  style: { marginTop: 4 },
129
- children: a("chat.context.full")
129
+ children: d("chat.context.full")
130
130
  }),
131
- y === "full" && (t || n) && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
131
+ b === "full" && (t || n) && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
132
132
  className: "row",
133
133
  style: {
134
134
  marginTop: 8,
@@ -136,24 +136,24 @@ function S({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
136
136
  },
137
137
  children: [t && /* @__PURE__ */ l(C, {
138
138
  icon: "compress",
139
- label: a("chat.context.compact"),
139
+ label: d("chat.context.compact"),
140
140
  busy: r,
141
141
  run: () => {
142
- p(!1), t();
142
+ m(!1), t();
143
143
  }
144
144
  }), n && /* @__PURE__ */ l(C, {
145
145
  icon: "reset",
146
- label: a("chat.context.reset"),
146
+ label: d("chat.context.reset"),
147
147
  busy: r,
148
148
  run: () => {
149
- p(!1), n();
149
+ m(!1), n();
150
150
  }
151
151
  })]
152
152
  }), r && /* @__PURE__ */ l("div", {
153
153
  id: "ctx-wait",
154
154
  className: "small muted",
155
155
  style: { marginTop: 6 },
156
- children: a("chat.context.waitTurn")
156
+ children: d(a ? "chat.context.waitQueue" : "chat.context.waitTurn")
157
157
  })] })
158
158
  ]
159
159
  })]
@@ -214,22 +214,22 @@ function M(e, t) {
214
214
  }).format(r);
215
215
  }
216
216
  var N = "default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:";
217
- function P(e) {
217
+ function te(e) {
218
218
  let t = `<meta http-equiv="Content-Security-Policy" content="${N}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
219
219
  if (typeof DOMParser > "u") return n + t + e.slice(n.length);
220
220
  let r = new DOMParser().parseFromString(e, "text/html");
221
221
  r.querySelectorAll("script, noscript, iframe, frame, frameset, object, embed, applet, base, link, meta[http-equiv], portal").forEach((e) => e.remove()), r.querySelectorAll("*").forEach((e) => {
222
222
  for (let t of Array.from(e.attributes)) {
223
223
  let n = t.name.toLowerCase();
224
- n.startsWith("on") || F.has(n) && !I.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !I.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", L(t.value));
224
+ n.startsWith("on") || ne.has(n) && !P.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !P.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", F(t.value));
225
225
  }
226
226
  }), r.querySelectorAll("style").forEach((e) => {
227
- e.textContent = L(e.textContent ?? "");
227
+ e.textContent = F(e.textContent ?? "");
228
228
  });
229
229
  let i = r.createElement("meta");
230
230
  return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", N), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
231
231
  }
232
- var F = /* @__PURE__ */ new Set([
232
+ var ne = /* @__PURE__ */ new Set([
233
233
  "src",
234
234
  "href",
235
235
  "xlink:href",
@@ -247,11 +247,11 @@ var F = /* @__PURE__ */ new Set([
247
247
  "codebase",
248
248
  "archive",
249
249
  "usemap"
250
- ]), I = /^\s*(data:|#|$)/i;
251
- function L(e) {
252
- return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => I.test(n) && n.trim() !== "" ? e : "none");
250
+ ]), P = /^\s*(data:|#|$)/i;
251
+ function F(e) {
252
+ return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => P.test(n) && n.trim() !== "" ? e : "none");
253
253
  }
254
- var R = {
254
+ var I = {
255
255
  png: "image/png",
256
256
  jpg: "image/jpeg",
257
257
  jpeg: "image/jpeg",
@@ -266,11 +266,11 @@ var R = {
266
266
  html: "text/html",
267
267
  htm: "text/html"
268
268
  };
269
- function z(e) {
269
+ function L(e) {
270
270
  let t = (e.mimeType ?? "").split(";")[0].trim().toLowerCase();
271
- return t && t !== "application/octet-stream" ? t : R[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
271
+ return t && t !== "application/octet-stream" ? t : I[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
272
272
  }
273
- function B(e, t) {
273
+ function R(e, t) {
274
274
  if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
275
275
  let n = [], r = [], i = "", a = !1;
276
276
  for (let t = 0; t < e.length; t++) {
@@ -279,7 +279,7 @@ function B(e, t) {
279
279
  }
280
280
  return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
281
281
  }
282
- function V(e, t, n = !0) {
282
+ function z(e, t, n = !0) {
283
283
  let [r, i] = g({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
284
284
  return f(() => {
285
285
  if (!n) return;
@@ -292,7 +292,7 @@ function V(e, t, n = !0) {
292
292
  size: l
293
293
  }).then((t) => {
294
294
  if (!r) return;
295
- let n = z({
295
+ let n = L({
296
296
  fileName: s,
297
297
  mimeType: c
298
298
  }), a = n && t.type !== n ? new Blob([t], { type: n }) : t;
@@ -313,9 +313,9 @@ function V(e, t, n = !0) {
313
313
  l
314
314
  ]), r;
315
315
  }
316
- function H({ a: e, load: t, onOpen: n }) {
317
- let r = o(), { url: i, failed: a } = V(e, t);
318
- return a ? /* @__PURE__ */ l(te, {
316
+ function B({ a: e, load: t, onOpen: n }) {
317
+ let r = o(), { url: i, failed: a } = z(e, t);
318
+ return a ? /* @__PURE__ */ l(V, {
319
319
  a: e,
320
320
  kind: "image",
321
321
  onOpen: n
@@ -337,7 +337,7 @@ function H({ a: e, load: t, onOpen: n }) {
337
337
  })]
338
338
  });
339
339
  }
340
- function te({ a: e, kind: n, onOpen: r }) {
340
+ function V({ a: e, kind: n, onOpen: r }) {
341
341
  let i = o(), { i18n: a } = _(s), d = n !== null && r !== void 0, f = /* @__PURE__ */ u(c, { children: [
342
342
  /* @__PURE__ */ u("span", {
343
343
  className: "att-ic",
@@ -374,16 +374,16 @@ function te({ a: e, kind: n, onOpen: r }) {
374
374
  children: f
375
375
  });
376
376
  }
377
- function U({ items: e, load: t, onOpen: n, office: r = !1 }) {
377
+ function H({ items: e, load: t, onOpen: n, office: r = !1 }) {
378
378
  return /* @__PURE__ */ l("div", {
379
379
  className: "atts",
380
380
  children: e.map((e) => {
381
381
  let i = t && n ? () => n(e) : void 0, a = k(e, r);
382
- return t && i && a === "image" ? /* @__PURE__ */ l(H, {
382
+ return t && i && a === "image" ? /* @__PURE__ */ l(B, {
383
383
  a: e,
384
384
  load: t,
385
385
  onOpen: i
386
- }, e.id) : /* @__PURE__ */ l(te, {
386
+ }, e.id) : /* @__PURE__ */ l(V, {
387
387
  a: e,
388
388
  kind: a,
389
389
  onOpen: i
@@ -391,8 +391,8 @@ function U({ items: e, load: t, onOpen: n, office: r = !1 }) {
391
391
  })
392
392
  });
393
393
  }
394
- function W({ text: e, tab: t }) {
395
- let n = o(), [r, ...i] = B(e, t), a = i.slice(0, 500);
394
+ function U({ text: e, tab: t }) {
395
+ let n = o(), [r, ...i] = R(e, t), a = i.slice(0, 500);
396
396
  return /* @__PURE__ */ u("div", {
397
397
  className: "att-table",
398
398
  children: [/* @__PURE__ */ u("table", { children: [r && /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: r.map((e, t) => /* @__PURE__ */ l("th", { children: e }, t)) }) }), /* @__PURE__ */ l("tbody", { children: a.map((e, t) => /* @__PURE__ */ l("tr", { children: e.map((e, t) => /* @__PURE__ */ l("td", { children: e }, t)) }, t)) })] }), i.length > a.length && /* @__PURE__ */ l("div", {
@@ -404,9 +404,9 @@ function W({ text: e, tab: t }) {
404
404
  })]
405
405
  });
406
406
  }
407
- var G = 1280;
408
- function K({ text: e, title: t }) {
409
- let n = h(null), [r, i] = g(G), [a, o] = g(G);
407
+ var W = 1280;
408
+ function re({ text: e, title: t }) {
409
+ let n = h(null), [r, i] = g(W), [a, o] = g(W);
410
410
  f(() => {
411
411
  let e = n.current;
412
412
  if (!e) return;
@@ -415,12 +415,12 @@ function K({ text: e, title: t }) {
415
415
  let r = new ResizeObserver(t);
416
416
  return r.observe(e), () => r.disconnect();
417
417
  }, []);
418
- let s = m(() => P(e), [e]), [c, u] = g(s);
419
- c !== s && (u(s), o(G));
418
+ let s = m(() => te(e), [e]), [c, u] = g(s);
419
+ c !== s && (u(s), o(W));
420
420
  let d = (e) => {
421
421
  let t = e.currentTarget, n = () => {
422
422
  let e = t.contentDocument?.documentElement;
423
- e && o(Math.max(G, e.scrollWidth));
423
+ e && o(Math.max(W, e.scrollWidth));
424
424
  };
425
425
  n(), t.contentDocument?.fonts?.ready.then(n);
426
426
  }, p = Math.min(1, r / a);
@@ -442,8 +442,8 @@ function K({ text: e, title: t }) {
442
442
  })
443
443
  });
444
444
  }
445
- function ne({ a: e, load: r, loadPreview: i, onClose: d }) {
446
- let p = o(), { i18n: m } = _(s), h = k(e, !!i), v = h === "office-doc" || h === "office-sheet", y = h === "markdown" || h === "table" || h === "html" || h === "text", [b, x] = g(!1), S = y && (e.size ?? 0) > 1048576, { url: C, blob: w, failed: T } = V(e, r, !S && !v), [E, D] = g(null), O = S || y && (w?.size ?? 0) > 1048576;
445
+ function ie({ a: e, load: r, loadPreview: i, onClose: d }) {
446
+ let p = o(), { i18n: m } = _(s), h = k(e, !!i), v = h === "office-doc" || h === "office-sheet", y = h === "markdown" || h === "table" || h === "html" || h === "text", [b, x] = g(!1), S = y && (e.size ?? 0) > 1048576, { url: C, blob: w, failed: T } = z(e, r, !S && !v), [E, D] = g(null), O = S || y && (w?.size ?? 0) > 1048576;
447
447
  f(() => {
448
448
  y && w && !O && w.arrayBuffer().then((e) => {
449
449
  try {
@@ -458,7 +458,7 @@ function ne({ a: e, load: r, loadPreview: i, onClose: d }) {
458
458
  O
459
459
  ]);
460
460
  let A = E?.text, j;
461
- return j = v && i ? /* @__PURE__ */ l(Y, {
461
+ return j = v && i ? /* @__PURE__ */ l(oe, {
462
462
  a: e,
463
463
  load: i
464
464
  }) : T ? /* @__PURE__ */ l("div", {
@@ -496,10 +496,10 @@ function ne({ a: e, load: r, loadPreview: i, onClose: d }) {
496
496
  }) : h === "markdown" ? /* @__PURE__ */ l("div", {
497
497
  className: "att-md",
498
498
  children: /* @__PURE__ */ l(a, { text: A ?? "" })
499
- }) : h === "table" ? /* @__PURE__ */ l(W, {
499
+ }) : h === "table" ? /* @__PURE__ */ l(U, {
500
500
  text: A ?? "",
501
501
  tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
502
- }) : h === "html" && !b ? /* @__PURE__ */ l(K, {
502
+ }) : h === "html" && !b ? /* @__PURE__ */ l(re, {
503
503
  text: A ?? "",
504
504
  title: e.fileName
505
505
  }) : /* @__PURE__ */ l("pre", {
@@ -558,8 +558,8 @@ function ne({ a: e, load: r, loadPreview: i, onClose: d }) {
558
558
  })
559
559
  });
560
560
  }
561
- var re = 4e4, ie = 2e3, q = 25, J = 50;
562
- function Y({ a: e, load: n }) {
561
+ var ae = 4e4, G = 2e3, K = 25, q = 50;
562
+ function oe({ a: e, load: n }) {
563
563
  let r = o(), [i, a] = g({ state: "loading" }), { id: s, href: c, fileName: d, mimeType: p, size: m } = e;
564
564
  return f(() => {
565
565
  let e = !0, t, r = Date.now(), i = () => {
@@ -570,10 +570,10 @@ function Y({ a: e, load: n }) {
570
570
  mimeType: p,
571
571
  size: m
572
572
  }).then((n) => {
573
- e && (n.state === "pending" ? Date.now() - r > re ? a({
573
+ e && (n.state === "pending" ? Date.now() - r > ae ? a({
574
574
  state: "error",
575
575
  reason: "timeout"
576
- }) : (a(n), t = setTimeout(i, ie)) : a(n));
576
+ }) : (a(n), t = setTimeout(i, G)) : a(n));
577
577
  }, () => e && a({ state: "failed" }));
578
578
  };
579
579
  return i(), () => {
@@ -612,18 +612,18 @@ function Y({ a: e, load: n }) {
612
612
  /* @__PURE__ */ l("b", { children: r("chat.files.unavailable") }),
613
613
  /* @__PURE__ */ l("span", {
614
614
  className: "muted small",
615
- children: r(`chat.files.reasons.${i.reason}`, { limit: i.limitMb ?? q })
615
+ children: r(`chat.files.reasons.${i.reason}`, { limit: i.limitMb ?? K })
616
616
  })
617
617
  ]
618
- }) : i.state === "doc" ? /* @__PURE__ */ l(X, {
618
+ }) : i.state === "doc" ? /* @__PURE__ */ l(se, {
619
619
  blob: i.blob,
620
620
  shown: i.shown,
621
621
  total: i.total,
622
622
  from: i.from,
623
623
  name: e.fileName
624
- }) : /* @__PURE__ */ l(se, { sheets: i.sheets });
624
+ }) : /* @__PURE__ */ l(X, { sheets: i.sheets });
625
625
  }
626
- function X({ blob: e, shown: t, total: n, from: r, name: i }) {
626
+ function se({ blob: e, shown: t, total: n, from: r, name: i }) {
627
627
  let a = o(), s = m(() => URL.createObjectURL(e.type === "application/pdf" ? e : new Blob([e], { type: "application/pdf" })), [e]);
628
628
  return f(() => () => URL.revokeObjectURL(s), [s]), /* @__PURE__ */ u("div", {
629
629
  className: "att-office",
@@ -649,24 +649,24 @@ function X({ blob: e, shown: t, total: n, from: r, name: i }) {
649
649
  total: n
650
650
  })
651
651
  }),
652
- n == null && t >= J && /* @__PURE__ */ l("div", {
652
+ n == null && t >= q && /* @__PURE__ */ l("div", {
653
653
  className: "att-more",
654
654
  children: a("chat.files.firstPages", { shown: t })
655
655
  })
656
656
  ]
657
657
  });
658
658
  }
659
- function ae(e) {
659
+ function ce(e) {
660
660
  let t = /^([A-Z]+)(\d+)$/.exec(e);
661
661
  if (!t) return null;
662
662
  let n = 0;
663
663
  for (let e of t[1]) n = n * 26 + e.charCodeAt(0) - 64;
664
664
  return [Number(t[2]) - 1, n - 1];
665
665
  }
666
- function oe(e) {
666
+ function J(e) {
667
667
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
668
668
  for (let r of e) {
669
- let [e, i] = r.split(":").map(ae);
669
+ let [e, i] = r.split(":").map(ce);
670
670
  if (e && i) {
671
671
  t.set(`${e[0]}:${e[1]}`, [i[0] - e[0] + 1, i[1] - e[1] + 1]);
672
672
  for (let t = e[0]; t <= i[0]; t++) for (let r = e[1]; r <= i[1]; r++) (t !== e[0] || r !== e[1]) && n.add(`${t}:${r}`);
@@ -677,18 +677,18 @@ function oe(e) {
677
677
  covered: n
678
678
  };
679
679
  }
680
- function Z(e) {
680
+ function Y(e) {
681
681
  let t = "";
682
682
  for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
683
683
  return t;
684
684
  }
685
- function se({ sheets: e }) {
685
+ function X({ sheets: e }) {
686
686
  let t = o(), [n, i] = g(0), a = e[Math.min(n, e.length - 1)];
687
687
  if (!a) return /* @__PURE__ */ l("div", {
688
688
  className: "att-msg",
689
689
  children: t("chat.files.failed")
690
690
  });
691
- let s = Math.max(0, ...a.cells.map((e) => e.length)), d = Array.from({ length: s }, (e, t) => Z(t + 1)), { spans: f, covered: p } = oe(a.merges), m = a.rows > a.cells.length, h = a.cols > s;
691
+ let s = Math.max(0, ...a.cells.map((e) => e.length)), d = Array.from({ length: s }, (e, t) => Y(t + 1)), { spans: f, covered: p } = J(a.merges), m = a.rows > a.cells.length, h = a.cols > s;
692
692
  return /* @__PURE__ */ u("div", {
693
693
  className: "att-office",
694
694
  children: [
@@ -735,7 +735,7 @@ function se({ sheets: e }) {
735
735
  }
736
736
  //#endregion
737
737
  //#region src/chat/MessageView.tsx
738
- function ce(e, t) {
738
+ function Z(e, t) {
739
739
  return new Intl.DateTimeFormat(b(t), {
740
740
  hour: "2-digit",
741
741
  minute: "2-digit"
@@ -758,14 +758,14 @@ var Q = {
758
758
  cls: "run"
759
759
  }
760
760
  };
761
- function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOpenAttachment: d }) {
762
- let { t: f, i18n: p } = _(s), [m, h] = g(!1);
761
+ function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOpenAttachment: d, queuePosition: f, onCancelQueued: p, stopping: m }) {
762
+ let { t: h, i18n: v } = _(s), [y, b] = g(!1);
763
763
  if (e.role === "note") return /* @__PURE__ */ l("div", {
764
764
  className: "sysnote",
765
765
  children: e.text
766
766
  });
767
- if (e.role === "event" && e.event) return /* @__PURE__ */ l(pe, { m: e });
768
- let v = e.mark && /* @__PURE__ */ u("div", {
767
+ if (e.role === "event" && e.event) return /* @__PURE__ */ l(he, { m: e });
768
+ let x = e.mark && /* @__PURE__ */ u("div", {
769
769
  className: "chan",
770
770
  children: [
771
771
  /* @__PURE__ */ l(t, {
@@ -775,54 +775,73 @@ function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOp
775
775
  " ",
776
776
  e.mark.text,
777
777
  " · ",
778
- ce(e.createdAt, p.language)
778
+ Z(e.createdAt, v.language)
779
779
  ]
780
- }), y = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l(U, {
780
+ }), S = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l(H, {
781
781
  items: e.attachments,
782
782
  load: i,
783
783
  office: !!o,
784
784
  onOpen: d
785
785
  });
786
786
  if (e.role === "user") return /* @__PURE__ */ u("div", {
787
- className: "m u",
787
+ className: `m u${e.queued ? " queued" : ""}`,
788
788
  children: [
789
- v,
789
+ x,
790
790
  e.content,
791
791
  e.text && /* @__PURE__ */ l("div", {
792
792
  className: "bub",
793
793
  children: e.text
794
794
  }),
795
- y,
795
+ S,
796
+ e.queued && /* @__PURE__ */ u("div", {
797
+ className: "qmark",
798
+ children: [
799
+ /* @__PURE__ */ l(t, {
800
+ name: "clock",
801
+ size: 12
802
+ }),
803
+ h("chat.queue.position", { n: f ?? 1 }),
804
+ p && /* @__PURE__ */ u("button", {
805
+ type: "button",
806
+ className: "textbtn",
807
+ onClick: p,
808
+ children: [/* @__PURE__ */ l(t, {
809
+ name: "x",
810
+ size: 12
811
+ }), h("chat.queue.cancel")]
812
+ })
813
+ ]
814
+ }),
796
815
  e.wait && /* @__PURE__ */ l("div", {
797
816
  className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
798
817
  role: "status",
799
818
  children: e.wait.state === "queued" ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(t, {
800
819
  name: "clock",
801
820
  size: 12
802
- }), f("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
821
+ }), h("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
803
822
  className: "spin",
804
823
  "aria-hidden": "true"
805
- }), f("chat.wait.starting")] })
824
+ }), h("chat.wait.starting")] })
806
825
  })
807
826
  ]
808
827
  });
809
- if (e.variant === "notice") return /* @__PURE__ */ l(fe, {
828
+ if (e.variant === "notice") return /* @__PURE__ */ l(me, {
810
829
  m: e,
811
- mark: v,
812
- atts: y
830
+ mark: x,
831
+ atts: S
813
832
  });
814
- let b = e.steps ?? [], x = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
833
+ let C = e.steps ?? [], w = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
815
834
  return /* @__PURE__ */ u("div", {
816
835
  className: "m a",
817
836
  children: [
818
- v,
819
- b.length > 3 && /* @__PURE__ */ l("button", {
837
+ x,
838
+ C.length > 3 && /* @__PURE__ */ l("button", {
820
839
  className: "tools-fold",
821
- onClick: () => h((e) => !e),
822
- "aria-expanded": m,
823
- children: m ? f("chat.hideSteps") : f("chat.moreSteps", { count: b.length - 2 })
840
+ onClick: () => b((e) => !e),
841
+ "aria-expanded": y,
842
+ children: y ? h("chat.hideSteps") : h("chat.moreSteps", { count: C.length - 2 })
824
843
  }),
825
- le(b, m).map((e) => /* @__PURE__ */ u("div", {
844
+ le(C, y).map((e) => e.subagents && e.subagents.length > 0 ? /* @__PURE__ */ l(fe, { tasks: e.subagents }, e.id) : /* @__PURE__ */ u("div", {
826
845
  className: "tool",
827
846
  title: e.title,
828
847
  children: [/* @__PURE__ */ l(t, {
@@ -834,11 +853,11 @@ function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOp
834
853
  children: e.text
835
854
  })]
836
855
  }, e.id)),
837
- x && /* @__PURE__ */ l("div", {
856
+ w && !m && /* @__PURE__ */ l("div", {
838
857
  className: "bub",
839
858
  children: /* @__PURE__ */ u("span", {
840
859
  className: "typing",
841
- "aria-label": f("chat.typing"),
860
+ "aria-label": h("chat.typing"),
842
861
  children: [
843
862
  /* @__PURE__ */ l("i", {}),
844
863
  /* @__PURE__ */ l("i", {}),
@@ -846,17 +865,51 @@ function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOp
846
865
  ]
847
866
  })
848
867
  }),
868
+ m && (e.status === "streaming" || e.status === "pending") && /* @__PURE__ */ l("div", {
869
+ className: "stopmark",
870
+ role: "status",
871
+ children: h("chat.stopping")
872
+ }),
849
873
  e.content ?? (e.text && /* @__PURE__ */ l("div", {
850
874
  className: "bub",
851
875
  title: e.hint,
852
876
  children: /* @__PURE__ */ l(a, { text: e.text })
853
877
  })),
854
- y,
878
+ S,
879
+ e.status === "stopped" && /* @__PURE__ */ u("div", {
880
+ className: "stopmark",
881
+ children: [
882
+ /* @__PURE__ */ l(t, {
883
+ name: "stop",
884
+ size: 12
885
+ }),
886
+ h("chat.stopped"),
887
+ e.retryQueued ? /* @__PURE__ */ u("span", {
888
+ className: "qmark-inline",
889
+ children: [/* @__PURE__ */ l(t, {
890
+ name: "clock",
891
+ size: 12
892
+ }), h("chat.retryQueued")]
893
+ }) : r && /* @__PURE__ */ l("button", {
894
+ type: "button",
895
+ className: "textbtn",
896
+ disabled: n,
897
+ onClick: r,
898
+ children: h("chat.retry")
899
+ })
900
+ ]
901
+ }),
855
902
  e.error && /* @__PURE__ */ u("div", {
856
903
  className: `llmerr${e.error.transient ? " amber" : ""}`,
857
904
  role: "alert",
858
905
  style: { marginTop: 6 },
859
- children: [/* @__PURE__ */ l("span", { children: e.error.text }), r && /* @__PURE__ */ l("div", {
906
+ children: [/* @__PURE__ */ l("span", { children: e.error.text }), e.retryQueued ? /* @__PURE__ */ u("div", {
907
+ className: "row qmark-inline",
908
+ children: [/* @__PURE__ */ l(t, {
909
+ name: "clock",
910
+ size: 12
911
+ }), h("chat.retryQueued")]
912
+ }) : r && /* @__PURE__ */ l("div", {
860
913
  className: "row",
861
914
  children: /* @__PURE__ */ u("button", {
862
915
  className: "btn sm",
@@ -865,15 +918,107 @@ function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOp
865
918
  children: [/* @__PURE__ */ l(t, {
866
919
  name: "refresh",
867
920
  size: 14
868
- }), f("chat.retry")]
921
+ }), h("chat.retry")]
869
922
  })
870
923
  })]
871
924
  })
872
925
  ]
873
926
  });
874
927
  }
875
- var de = 12;
876
- function fe({ m: e, mark: t, atts: n }) {
928
+ var de = {
929
+ done: {
930
+ icon: "check",
931
+ cls: "ok"
932
+ },
933
+ failed: {
934
+ icon: "x",
935
+ cls: "er"
936
+ },
937
+ timeout: {
938
+ icon: "stop",
939
+ cls: "off"
940
+ },
941
+ aborted: {
942
+ icon: "stop",
943
+ cls: "off"
944
+ }
945
+ };
946
+ function fe({ tasks: e }) {
947
+ let { t: n } = _(s), r = e.some((e) => e.state === "running"), [i, o] = g(null), [d, f] = g(null), p = i ?? r, m = e.filter((e) => e.state !== "done" && e.state !== "running").length;
948
+ return /* @__PURE__ */ u("div", {
949
+ className: `tool subagents${p ? " open" : ""}`,
950
+ children: [/* @__PURE__ */ u("button", {
951
+ type: "button",
952
+ className: "sa-head",
953
+ "aria-expanded": p,
954
+ onClick: () => o(!p),
955
+ children: [
956
+ r ? /* @__PURE__ */ l("span", {
957
+ className: "spin",
958
+ "aria-hidden": "true"
959
+ }) : /* @__PURE__ */ l(t, {
960
+ name: m ? "alert" : "check",
961
+ size: 14,
962
+ className: m ? "er" : "ok"
963
+ }),
964
+ /* @__PURE__ */ l(t, {
965
+ name: "users",
966
+ size: 14
967
+ }),
968
+ /* @__PURE__ */ u("span", {
969
+ className: "tx",
970
+ children: [n("chat.subagents.title", { count: e.length }), !r && /* @__PURE__ */ u(c, { children: [" — ", m ? n("chat.subagents.failed", { count: m }) : n("chat.subagents.done")] })]
971
+ })
972
+ ]
973
+ }), p && e.map((e) => /* @__PURE__ */ u("div", {
974
+ className: "sa-task",
975
+ children: [
976
+ /* @__PURE__ */ u("button", {
977
+ type: "button",
978
+ className: "sa-row",
979
+ "aria-expanded": d === e.task,
980
+ disabled: !e.result,
981
+ onClick: () => f(d === e.task ? null : e.task),
982
+ children: [
983
+ e.state === "running" ? /* @__PURE__ */ l("span", {
984
+ className: "spin",
985
+ "aria-hidden": "true"
986
+ }) : /* @__PURE__ */ l(t, {
987
+ name: de[e.state].icon,
988
+ size: 12,
989
+ className: de[e.state].cls
990
+ }),
991
+ /* @__PURE__ */ l("span", {
992
+ className: "sa-desc",
993
+ children: e.description
994
+ }),
995
+ /* @__PURE__ */ u("span", {
996
+ className: "sa-meta",
997
+ children: [
998
+ n("chat.subagents.tools", { count: e.tools }),
999
+ " · ",
1000
+ /* @__PURE__ */ l("span", {
1001
+ className: `sa-state ${e.state}`,
1002
+ children: n(`chat.subagents.state.${e.state === "aborted" && !e.error ? "turnStopped" : e.state}`)
1003
+ })
1004
+ ]
1005
+ })
1006
+ ]
1007
+ }),
1008
+ e.error && e.state !== "running" && /* @__PURE__ */ l("div", {
1009
+ className: "sa-err",
1010
+ children: e.error
1011
+ }),
1012
+ d === e.task && e.result && /* @__PURE__ */ l("div", {
1013
+ className: "sa-result",
1014
+ children: /* @__PURE__ */ l(a, { text: e.result })
1015
+ })
1016
+ ]
1017
+ }, e.task))]
1018
+ });
1019
+ }
1020
+ var pe = 12;
1021
+ function me({ m: e, mark: t, atts: n }) {
877
1022
  let { t: r } = _(s), [i, o] = g(!1), c = !e.content && e.text.split("\n").length > 12;
878
1023
  return /* @__PURE__ */ u("div", {
879
1024
  className: "m a notice",
@@ -893,7 +1038,7 @@ function fe({ m: e, mark: t, atts: n }) {
893
1038
  ]
894
1039
  });
895
1040
  }
896
- function pe({ m: e }) {
1041
+ function he({ m: e }) {
897
1042
  let { t: n, i18n: r } = _(s), [i, a] = g(!1), o = e.event;
898
1043
  return /* @__PURE__ */ u("div", {
899
1044
  className: "evdiv",
@@ -909,7 +1054,7 @@ function pe({ m: e }) {
909
1054
  }),
910
1055
  o.text,
911
1056
  " · ",
912
- ce(e.createdAt, r.language),
1057
+ Z(e.createdAt, r.language),
913
1058
  o.details && /* @__PURE__ */ u("button", {
914
1059
  type: "button",
915
1060
  className: "textbtn",
@@ -931,20 +1076,20 @@ function pe({ m: e }) {
931
1076
  }
932
1077
  //#endregion
933
1078
  //#region src/chat/transcription.ts
934
- async function me(e, t, n) {
1079
+ async function ge(e, t, n) {
935
1080
  n.busy(!0);
936
1081
  let r;
937
1082
  try {
938
1083
  r = await t(e);
939
1084
  } catch (r) {
940
- n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void me(e, t, n));
1085
+ n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void ge(e, t, n));
941
1086
  return;
942
1087
  }
943
1088
  n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
944
1089
  }
945
1090
  //#endregion
946
1091
  //#region src/chat/useRecorder.ts
947
- function he(e = 300, t) {
1092
+ function _e(e = 300, t) {
948
1093
  let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = g(!1), [a, o] = g(0), [s, c] = g(0), [l, u] = g(!1), p = h(null), m = h([]), _ = h(void 0), v = h(null), y = h(null), b = h(!1), x = h(t);
949
1094
  f(() => {
950
1095
  x.current = t;
@@ -1006,55 +1151,55 @@ function he(e = 300, t) {
1006
1151
  cancel: T
1007
1152
  };
1008
1153
  }
1009
- function ge(e) {
1154
+ function ve(e) {
1010
1155
  return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
1011
1156
  }
1012
1157
  //#endregion
1013
1158
  //#region src/chat/Chat.tsx
1014
- function _e(n) {
1015
- let r = o(), i = e(), [a, s] = g(""), [d, m] = g([]), [_, b] = g(!1), [x, C] = g(null), [w, T] = g(0), [E, D] = g(!1), [O, k] = g(null), [A, j] = g(!1), [ee, M] = g(null), N = Ce(n.loadAttachment), P = Ce(n.loadPreview), F = h(!1), I = h(null), L = h(null), R = h(null), z = n.voiceMaxSeconds ?? 300, B = he(z, () => void Q()), { messages: V, busy: H = !1 } = n, te = H || V.some((e) => e.status === "pending" || e.status === "streaming"), U = n.onPendingChange;
1016
- f(() => U?.(d), [d, U]);
1017
- let W = V[0]?.id, G = V[V.length - 1], K = G?.id, re = G?.text.length, ie = G?.steps?.length, q = h({ height: 0 });
1159
+ function ye(n) {
1160
+ let r = o(), i = e(), [a, s] = g(""), [d, m] = g([]), [_, b] = g(!1), [x, C] = g(null), [w, T] = g(0), [E, D] = g(!1), [O, k] = g(null), [A, j] = g(!1), [ee, M] = g(null), [N, te] = g(null), ne = Te(n.loadAttachment), P = Te(n.loadPreview), F = h(!1), I = h(null), L = h(null), R = h(null), z = n.voiceMaxSeconds ?? 300, B = _e(z, () => void me()), { messages: V, busy: H = !1 } = n, U = V.findLast((e) => e.role === "assistant" && (e.status === "pending" || e.status === "streaming")), W = V.filter((e) => e.role === "user" && e.queued).map((e) => e.id), re = H || !!U || W.length > 0, ae = n.onPendingChange;
1161
+ f(() => ae?.(d), [d, ae]);
1162
+ let G = V[0]?.id, K = V[V.length - 1], q = K?.id, oe = K?.text.length, se = K?.steps?.length, ce = h({ height: 0 });
1018
1163
  p(() => {
1019
1164
  let e = I.current;
1020
1165
  if (!e) return;
1021
- let t = q.current;
1022
- e.scrollTop = t.first !== void 0 && W !== t.first && K === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, q.current = {
1023
- first: W,
1024
- last: K,
1166
+ let t = ce.current;
1167
+ e.scrollTop = t.first !== void 0 && G !== t.first && q === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, ce.current = {
1168
+ first: G,
1169
+ last: q,
1025
1170
  height: e.scrollHeight
1026
1171
  };
1027
1172
  }, [
1028
1173
  V.length,
1029
- W,
1030
- K,
1031
- re,
1032
- ie
1174
+ G,
1175
+ q,
1176
+ oe,
1177
+ se
1033
1178
  ]);
1034
- let J = n.commands && !x && a.startsWith("/") && !/\s/.test(a) ? a.slice(1) : null, Y = J === null ? [] : v(n.commands ?? [], J), X = J !== null && !E, ae = () => {
1179
+ let J = n.commands && !x && a.startsWith("/") && !/\s/.test(a) ? a.slice(1) : null, Y = J === null ? [] : v(n.commands ?? [], J), X = J !== null && !E, Z = () => {
1035
1180
  s(""), m([]), C(null), k(null), F.current = !1;
1036
- }, oe = async (e, t) => {
1181
+ }, le = async (e, t) => {
1037
1182
  if (n.onCommand) try {
1038
- await n.onCommand(e, t), ae();
1183
+ await n.onCommand(e, t), Z();
1039
1184
  } catch {}
1040
- }, Z = async (e, t = !1) => {
1185
+ }, Q = async (e, t = !1) => {
1041
1186
  let r = e.trim();
1042
- if (!(!r && d.length === 0 && !x || H || n.readOnly)) {
1187
+ if (!(!r && d.length === 0 && !x || H || U && !n.allowQueue || n.readOnly)) {
1043
1188
  if (!t && !x && n.commands && r.startsWith("/")) {
1044
1189
  let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
1045
- if (i) return oe(i.name, t.join(" "));
1190
+ if (i) return le(i.name, t.join(" "));
1046
1191
  if (e && !r.includes("\n")) {
1047
1192
  k("/" + e);
1048
1193
  return;
1049
1194
  }
1050
1195
  }
1051
1196
  try {
1052
- await n.onSend(r, d.map((e) => e.id), F.current, x ?? void 0), ae();
1197
+ await n.onSend(r, d.map((e) => e.id), F.current, x ?? void 0), Z();
1053
1198
  } catch {}
1054
1199
  }
1055
- }, se = (e) => {
1056
- T(0), e.kind === "skill" ? (C(e.name), s("")) : e.takesText ? s("/" + e.name + " ") : oe(e.name, ""), R.current?.focus();
1057
- }, ce = (e) => {
1200
+ }, de = (e) => {
1201
+ T(0), e.kind === "skill" ? (C(e.name), s("")) : e.takesText ? s("/" + e.name + " ") : le(e.name, ""), R.current?.focus();
1202
+ }, fe = (e) => {
1058
1203
  if (X && Y.length > 0) {
1059
1204
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1060
1205
  e.preventDefault();
@@ -1063,21 +1208,21 @@ function _e(n) {
1063
1208
  return;
1064
1209
  }
1065
1210
  if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
1066
- e.preventDefault(), se(Y[Math.min(w, Y.length - 1)]);
1211
+ e.preventDefault(), de(Y[Math.min(w, Y.length - 1)]);
1067
1212
  return;
1068
1213
  }
1069
1214
  }
1070
- X && e.key === "Escape" ? (e.preventDefault(), D(!0)) : e.key === "Backspace" && x && a === "" ? C(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && !ye() && (e.preventDefault(), Z(a));
1215
+ X && e.key === "Escape" ? (e.preventDefault(), D(!0)) : e.key === "Backspace" && x && a === "" ? C(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && !xe() && (e.preventDefault(), Q(a));
1071
1216
  };
1072
- p(() => xe(I.current, () => Se(R.current)), [a]), f(() => {
1217
+ p(() => Ce(I.current, () => we(R.current)), [a]), f(() => {
1073
1218
  let e = R.current;
1074
1219
  if (!e || typeof ResizeObserver > "u") return;
1075
1220
  let t = e.clientWidth, n = new ResizeObserver(() => {
1076
- e.clientWidth !== t && (t = e.clientWidth, xe(I.current, () => Se(e)));
1221
+ e.clientWidth !== t && (t = e.clientWidth, Ce(I.current, () => we(e)));
1077
1222
  });
1078
1223
  return n.observe(e), () => n.disconnect();
1079
1224
  }, [B.recording]);
1080
- let le = async (e) => {
1225
+ let pe = async (e) => {
1081
1226
  if (e?.length && n.onUpload) {
1082
1227
  b(!0);
1083
1228
  for (let t of Array.from(e)) {
@@ -1095,9 +1240,9 @@ function _e(n) {
1095
1240
  b(!1), L.current && (L.current.value = "");
1096
1241
  }
1097
1242
  };
1098
- async function Q() {
1243
+ async function me() {
1099
1244
  let e = await B.stop();
1100
- e && n.onTranscribe && await me(e, n.onTranscribe, {
1245
+ e && n.onTranscribe && await ge(e, n.onTranscribe, {
1101
1246
  busy: j,
1102
1247
  empty: () => i({
1103
1248
  kind: "error",
@@ -1117,9 +1262,11 @@ function _e(n) {
1117
1262
  }
1118
1263
  });
1119
1264
  }
1120
- let de = (e) => {
1265
+ let he = (e) => {
1121
1266
  e.key === "Escape" && B.recording && (e.preventDefault(), B.cancel());
1122
- }, fe = x ? r("chat.skillPlaceholder") : n.placeholder ?? r("chat.placeholder", { name: n.agentName }), pe = z - B.seconds;
1267
+ }, ye = x ? r("chat.skillPlaceholder") : n.allowQueue && U ? r("chat.queuePlaceholder") : n.placeholder ?? r("chat.placeholder", { name: n.agentName }), Se = n.onStop && U && !a.trim() && d.length === 0 && !x, Ee = (e) => {
1268
+ M(e), n.onStop?.(e).catch(() => M(null));
1269
+ }, De = z - B.seconds;
1123
1270
  return /* @__PURE__ */ u("section", {
1124
1271
  className: "nb-chat",
1125
1272
  "aria-label": r("chat.title"),
@@ -1156,9 +1303,12 @@ function _e(n) {
1156
1303
  m: e,
1157
1304
  busy: H,
1158
1305
  onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
1159
- loadAttachment: N,
1306
+ loadAttachment: ne,
1160
1307
  loadPreview: P,
1161
- onOpenAttachment: M
1308
+ onOpenAttachment: te,
1309
+ queuePosition: e.queued ? W.indexOf(e.id) + 1 : void 0,
1310
+ onCancelQueued: n.onCancelQueued && (() => void n.onCancelQueued?.(e.id).catch(() => {})),
1311
+ stopping: ee === e.id
1162
1312
  }, e.id)),
1163
1313
  n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ u("div", {
1164
1314
  className: "confirm",
@@ -1203,7 +1353,7 @@ function _e(n) {
1203
1353
  X && /* @__PURE__ */ l(y, {
1204
1354
  items: Y,
1205
1355
  active: Math.min(w, Math.max(Y.length - 1, 0)),
1206
- onPick: se,
1356
+ onPick: de,
1207
1357
  onHover: T
1208
1358
  }),
1209
1359
  n.aboveComposer,
@@ -1239,7 +1389,7 @@ function _e(n) {
1239
1389
  children: [r("chat.unknownCommand", { name: O }), /* @__PURE__ */ l("button", {
1240
1390
  type: "button",
1241
1391
  className: "textbtn",
1242
- onClick: () => void Z(a, !0),
1392
+ onClick: () => void Q(a, !0),
1243
1393
  children: r("chat.sendAsText")
1244
1394
  })]
1245
1395
  }),
@@ -1258,10 +1408,10 @@ function _e(n) {
1258
1408
  multiple: !0,
1259
1409
  hidden: !0,
1260
1410
  accept: n.upload?.accept,
1261
- onChange: (e) => le(e.target.files)
1411
+ onChange: (e) => pe(e.target.files)
1262
1412
  })] }),
1263
1413
  B.recording ? /* @__PURE__ */ u("div", {
1264
- className: `recbar${pe <= 15 ? " ending" : ""}`,
1414
+ className: `recbar${De <= 15 ? " ending" : ""}`,
1265
1415
  role: "status",
1266
1416
  "aria-label": r("chat.voice.recordingNow"),
1267
1417
  children: [
@@ -1272,9 +1422,9 @@ function _e(n) {
1272
1422
  /* @__PURE__ */ u("span", {
1273
1423
  className: "tm",
1274
1424
  children: [
1275
- ge(B.seconds),
1425
+ ve(B.seconds),
1276
1426
  " / ",
1277
- ge(z)
1427
+ ve(z)
1278
1428
  ]
1279
1429
  }),
1280
1430
  /* @__PURE__ */ l("span", {
@@ -1291,8 +1441,8 @@ function _e(n) {
1291
1441
  /* @__PURE__ */ l("button", {
1292
1442
  type: "button",
1293
1443
  className: "btn primary sm",
1294
- onKeyDown: de,
1295
- onClick: () => void Q(),
1444
+ onKeyDown: he,
1445
+ onClick: () => void me(),
1296
1446
  children: r("chat.voice.done")
1297
1447
  })
1298
1448
  ]
@@ -1325,29 +1475,37 @@ function _e(n) {
1325
1475
  ref: R,
1326
1476
  rows: 1,
1327
1477
  value: a,
1328
- placeholder: A ? r("chat.voice.recognizing") : fe,
1329
- "aria-label": fe,
1478
+ placeholder: A ? r("chat.voice.recognizing") : ye,
1479
+ "aria-label": ye,
1330
1480
  disabled: A,
1331
1481
  "aria-expanded": X,
1332
1482
  "aria-autocomplete": n.commands ? "list" : void 0,
1333
1483
  onChange: (e) => {
1334
1484
  s(e.target.value), D(!1), T(0), k(null);
1335
1485
  },
1336
- onKeyDown: ce
1486
+ onKeyDown: fe
1337
1487
  })]
1338
1488
  }),
1339
1489
  n.context && !B.recording && /* @__PURE__ */ l(S, {
1340
1490
  context: n.context,
1341
1491
  onCompact: n.onCompact,
1342
1492
  onReset: n.onReset,
1343
- busy: te
1493
+ busy: re,
1494
+ queued: W.length > 0
1344
1495
  }),
1345
- n.onTranscribe && !B.recording && /* @__PURE__ */ l(ve, {
1496
+ n.onTranscribe && !B.recording && /* @__PURE__ */ l(be, {
1346
1497
  supported: B.supported,
1347
1498
  recognizing: A,
1348
1499
  onStart: () => void B.start()
1349
1500
  }),
1350
- !B.recording && (n.onCancel && H ? /* @__PURE__ */ l("button", {
1501
+ !B.recording && (Se ? /* @__PURE__ */ l("button", {
1502
+ className: "iconbtn stopbtn",
1503
+ "aria-label": r("chat.stopAnswer"),
1504
+ title: r("chat.stopAnswer"),
1505
+ disabled: ee === U.id,
1506
+ onClick: () => Ee(U.id),
1507
+ children: /* @__PURE__ */ l(t, { name: "stop" })
1508
+ }) : n.onCancel && H ? /* @__PURE__ */ l("button", {
1351
1509
  className: "iconbtn fill",
1352
1510
  "aria-label": r("chat.stop"),
1353
1511
  onClick: n.onCancel,
@@ -1355,8 +1513,8 @@ function _e(n) {
1355
1513
  }) : /* @__PURE__ */ l("button", {
1356
1514
  className: "iconbtn fill",
1357
1515
  "aria-label": r("chat.send"),
1358
- disabled: !a.trim() && d.length === 0 && !x || H || A,
1359
- onClick: () => Z(a),
1516
+ disabled: !a.trim() && d.length === 0 && !x || H || !!U && !n.allowQueue || A,
1517
+ onClick: () => Q(a),
1360
1518
  children: /* @__PURE__ */ l(t, { name: "send" })
1361
1519
  }))
1362
1520
  ]
@@ -1368,16 +1526,16 @@ function _e(n) {
1368
1526
  })
1369
1527
  ]
1370
1528
  }),
1371
- ee && N && /* @__PURE__ */ l(ne, {
1372
- a: ee,
1373
- load: N,
1529
+ N && ne && /* @__PURE__ */ l(ie, {
1530
+ a: N,
1531
+ load: ne,
1374
1532
  loadPreview: P,
1375
- onClose: () => M(null)
1533
+ onClose: () => te(null)
1376
1534
  })
1377
1535
  ]
1378
1536
  });
1379
1537
  }
1380
- function ve({ supported: e, recognizing: n, onStart: r }) {
1538
+ function be({ supported: e, recognizing: n, onStart: r }) {
1381
1539
  let i = o();
1382
1540
  return n ? /* @__PURE__ */ u("span", {
1383
1541
  className: "voicewait",
@@ -1400,21 +1558,21 @@ function ve({ supported: e, recognizing: n, onStart: r }) {
1400
1558
  children: /* @__PURE__ */ l(t, { name: "mic" })
1401
1559
  });
1402
1560
  }
1403
- function ye() {
1561
+ function xe() {
1404
1562
  return typeof window < "u" && !!window.matchMedia?.("(hover: none) and (pointer: coarse)").matches;
1405
1563
  }
1406
- var be = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
1407
- function xe(e, t) {
1408
- let n = !!e && be(e);
1564
+ var Se = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
1565
+ function Ce(e, t) {
1566
+ let n = !!e && Se(e);
1409
1567
  t(), e && n && (e.scrollTop = e.scrollHeight);
1410
1568
  }
1411
- function Se(e) {
1569
+ function we(e) {
1412
1570
  if (!e) return;
1413
1571
  e.style.overflowY = "hidden", e.style.height = "auto";
1414
1572
  let t = e.scrollHeight + e.offsetHeight - e.clientHeight;
1415
1573
  e.style.height = `${t}px`, e.style.overflowY = e.offsetHeight < t ? "auto" : "hidden";
1416
1574
  }
1417
- function Ce(e) {
1575
+ function Te(e) {
1418
1576
  let t = h(e);
1419
1577
  f(() => {
1420
1578
  t.current = e;
@@ -1424,7 +1582,7 @@ function Ce(e) {
1424
1582
  }
1425
1583
  //#endregion
1426
1584
  //#region src/chat/ConversationList.tsx
1427
- function we({ conversations: e, currentId: n, open: r, onPick: i, onClose: a, onCreate: s }) {
1585
+ function Ee({ conversations: e, currentId: n, open: r, onPick: i, onClose: a, onCreate: s }) {
1428
1586
  let d = o(), [p, m] = g(!1);
1429
1587
  f(() => {
1430
1588
  if (!r) return;
@@ -1500,19 +1658,19 @@ function we({ conversations: e, currentId: n, open: r, onPick: i, onClose: a, on
1500
1658
  "aria-label": d("close"),
1501
1659
  onClick: a
1502
1660
  }),
1503
- p && s && /* @__PURE__ */ l(Ee, {
1661
+ p && s && /* @__PURE__ */ l(Oe, {
1504
1662
  onClose: () => m(!1),
1505
1663
  onCreate: s
1506
1664
  })
1507
1665
  ] });
1508
1666
  }
1509
- function Te({ narrow: e, children: t }) {
1667
+ function De({ narrow: e, children: t }) {
1510
1668
  return /* @__PURE__ */ l("div", {
1511
1669
  className: `nb-app${e ? " narrow" : ""}`,
1512
1670
  children: t
1513
1671
  });
1514
1672
  }
1515
- function Ee({ onClose: e, onCreate: t }) {
1673
+ function Oe({ onClose: e, onCreate: t }) {
1516
1674
  let r = o(), [i, a] = g(""), [s, d] = g(!1), [f, p] = g(null), m = async () => {
1517
1675
  if (i.trim() && !s) {
1518
1676
  d(!0), p(null);
@@ -1564,7 +1722,7 @@ function Ee({ onClose: e, onCreate: t }) {
1564
1722
  }
1565
1723
  //#endregion
1566
1724
  //#region src/chat/AgentMenu.tsx
1567
- function De({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1725
+ function ke({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1568
1726
  return /* @__PURE__ */ l("button", {
1569
1727
  type: "button",
1570
1728
  className: `agentbtn${a ? " s" : ""}`,
@@ -1580,7 +1738,7 @@ function De({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, o
1580
1738
  })
1581
1739
  });
1582
1740
  }
1583
- function Oe({ label: e, name: n, options: r, value: a, optionsLabel: s, hint: d, narrow: f, models: p, onRename: m, onPick: h, onClose: _ }) {
1741
+ function Ae({ label: e, name: n, options: r, value: a, optionsLabel: s, hint: d, narrow: f, models: p, onRename: m, onPick: h, onClose: _ }) {
1584
1742
  let v = o(), [y, b] = g(n), x = i(!0, _);
1585
1743
  return /* @__PURE__ */ u("div", {
1586
1744
  className: `agentmenu${f ? " narrow" : ""}`,
@@ -1693,7 +1851,7 @@ function Oe({ label: e, name: n, options: r, value: a, optionsLabel: s, hint: d,
1693
1851
  //#endregion
1694
1852
  //#region src/chat/AgentSettingsMenu.tsx
1695
1853
  var $ = (e) => `${e.connectionId}/${e.model}`;
1696
- function ke(e, t, n) {
1854
+ function je(e, t, n) {
1697
1855
  let r = (n) => [
1698
1856
  ...n.caps.image ? [{
1699
1857
  icon: "image",
@@ -1721,9 +1879,9 @@ function ke(e, t, n) {
1721
1879
  value: n.chosen && n.model ? $(n.model) : a ? "" : n.model ? $(n.model) : ""
1722
1880
  };
1723
1881
  }
1724
- function Ae({ name: e, value: t, options: n, models: r, hint: i, onRename: a, onPick: s, onModel: c, onClose: u }) {
1725
- let d = o(), { i18n: f } = _(), p = r && c ? ke(d, f.language, r) : null;
1726
- return /* @__PURE__ */ l(Oe, {
1882
+ function Me({ name: e, value: t, options: n, models: r, hint: i, onRename: a, onPick: s, onModel: c, onClose: u }) {
1883
+ let d = o(), { i18n: f } = _(), p = r && c ? je(d, f.language, r) : null;
1884
+ return /* @__PURE__ */ l(Ae, {
1727
1885
  label: d("agent.menu"),
1728
1886
  name: e,
1729
1887
  value: t,
@@ -1751,6 +1909,6 @@ function Ae({ name: e, value: t, options: n, models: r, hint: i, onRename: a, on
1751
1909
  });
1752
1910
  }
1753
1911
  //#endregion
1754
- export { De as AgentButton, Oe as AgentMenu, Ae as AgentSettingsMenu, U as AttachmentList, ne as AttachmentPreview, _e as Chat, Te as ChatLayout, y as CommandPalette, S as ContextMeter, we as ConversationList, ue as MessageView, de as NOTICE_LINES, Ee as NewTopicModal, ve as VoiceButton, $ as agentModelKey, ke as agentModelOptions, Z as columnName, M as fileSize, B as parseTable, j as previewIcon, k as previewKind, x as tokens, he as useRecorder };
1912
+ export { ke as AgentButton, Ae as AgentMenu, Me as AgentSettingsMenu, H as AttachmentList, ie as AttachmentPreview, ye as Chat, De as ChatLayout, y as CommandPalette, S as ContextMeter, Ee as ConversationList, ue as MessageView, pe as NOTICE_LINES, Oe as NewTopicModal, fe as SubagentStep, be as VoiceButton, $ as agentModelKey, je as agentModelOptions, Y as columnName, M as fileSize, R as parseTable, j as previewIcon, k as previewKind, x as tokens, _e as useRecorder };
1755
1913
 
1756
1914
  //# sourceMappingURL=chat.js.map