@green-on-grey/ui-kit 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.js CHANGED
@@ -1,15 +1,15 @@
1
- import { c as e, d as t, i as n, l as r, s as i } from "./ui-DvmjcG-d.js";
2
- import { n as a, t as o } from "./i18n-BJ8rsBp6.js";
3
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
4
- import { useCallback as u, useEffect as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
5
- import { useTranslation as g } from "react-i18next";
1
+ import { c as e, f as t, i as n, l as r, s as i, u as a } from "./ui-sV5t0cp1.js";
2
+ import { n as o, t as s } from "./i18n-BJ8rsBp6.js";
3
+ import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
4
+ import { useCallback as d, useEffect as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
5
+ import { useTranslation as _ } from "react-i18next";
6
6
  //#region src/chat/CommandPalette.tsx
7
- function _(e, t) {
7
+ function v(e, t) {
8
8
  let n = t.toLowerCase();
9
9
  return e.filter((e) => e.name.toLowerCase().includes(n) || (e.description ?? "").toLowerCase().includes(n));
10
10
  }
11
- function v({ items: e, active: n, onPick: r, onHover: i }) {
12
- let o = a(), s = e.filter((e) => e.kind === "command"), u = e.filter((e) => e.kind === "skill"), d = (e, a) => /* @__PURE__ */ l("button", {
11
+ function y({ items: e, active: n, onPick: r, onHover: i }) {
12
+ let a = o(), s = e.filter((e) => e.kind === "command"), c = e.filter((e) => e.kind === "skill"), d = (e, a) => /* @__PURE__ */ u("button", {
13
13
  type: "button",
14
14
  role: "option",
15
15
  "aria-selected": a === n,
@@ -19,154 +19,154 @@ function v({ items: e, active: n, onPick: r, onHover: i }) {
19
19
  },
20
20
  onMouseEnter: () => i(a),
21
21
  children: [
22
- e.kind === "skill" ? /* @__PURE__ */ c(t, {
22
+ e.kind === "skill" ? /* @__PURE__ */ l(t, {
23
23
  name: "spark",
24
24
  size: 14
25
- }) : /* @__PURE__ */ c("span", {
25
+ }) : /* @__PURE__ */ l("span", {
26
26
  className: "slash",
27
27
  "aria-hidden": "true"
28
28
  }),
29
- /* @__PURE__ */ c("span", {
29
+ /* @__PURE__ */ l("span", {
30
30
  className: "nm",
31
31
  children: e.kind === "command" ? "/" + e.name : e.name
32
32
  }),
33
- /* @__PURE__ */ c("span", {
33
+ /* @__PURE__ */ l("span", {
34
34
  className: "ds",
35
35
  children: e.description
36
36
  }),
37
- e.source && /* @__PURE__ */ c("span", {
37
+ e.source && /* @__PURE__ */ l("span", {
38
38
  className: "src",
39
39
  children: e.source
40
40
  })
41
41
  ]
42
42
  }, e.kind + e.name);
43
- return /* @__PURE__ */ l("div", {
43
+ return /* @__PURE__ */ u("div", {
44
44
  className: "palette",
45
45
  role: "listbox",
46
- "aria-label": o("chat.palette.title"),
46
+ "aria-label": a("chat.palette.title"),
47
47
  children: [
48
- e.length === 0 && /* @__PURE__ */ c("div", {
48
+ e.length === 0 && /* @__PURE__ */ l("div", {
49
49
  className: "palette-empty",
50
- children: o("chat.palette.empty")
50
+ children: a("chat.palette.empty")
51
51
  }),
52
- s.length > 0 && /* @__PURE__ */ c("div", {
52
+ s.length > 0 && /* @__PURE__ */ l("div", {
53
53
  className: "palette-h",
54
- children: o("chat.palette.commands")
54
+ children: a("chat.palette.commands")
55
55
  }),
56
56
  s.map((t) => d(t, e.indexOf(t))),
57
- e.length > 0 && /* @__PURE__ */ c("div", {
57
+ e.length > 0 && /* @__PURE__ */ l("div", {
58
58
  className: "palette-h",
59
- children: o("chat.palette.skills")
59
+ children: a("chat.palette.skills")
60
60
  }),
61
- u.length === 0 && e.length > 0 && /* @__PURE__ */ c("div", {
61
+ c.length === 0 && e.length > 0 && /* @__PURE__ */ l("div", {
62
62
  className: "palette-empty",
63
- children: o("chat.palette.noSkills")
63
+ children: a("chat.palette.noSkills")
64
64
  }),
65
- u.map((t) => d(t, e.indexOf(t)))
65
+ c.map((t) => d(t, e.indexOf(t)))
66
66
  ]
67
67
  });
68
68
  }
69
69
  //#endregion
70
70
  //#region src/chat/intl.ts
71
- var y = (e) => e === "zh" ? "zh-CN" : e;
71
+ var b = (e) => e === "zh" ? "zh-CN" : e;
72
72
  //#endregion
73
73
  //#region src/chat/ContextMeter.tsx
74
- function b(e, t) {
75
- return new Intl.NumberFormat(y(t), {
74
+ function x(e, t) {
75
+ return new Intl.NumberFormat(b(t), {
76
76
  notation: "compact",
77
77
  maximumFractionDigits: 1
78
78
  }).format(e);
79
79
  }
80
- function x({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
81
- let u = a(), { i18n: d } = g(o), [f, p] = h(!1), m = i(f, () => p(!1)), _ = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, v = Math.round(_ * 100), y = _ >= .9 ? "full" : _ >= .7 ? "warn" : "", x = 2 * Math.PI * 7, C = d.language;
82
- return /* @__PURE__ */ l("div", {
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;
82
+ return /* @__PURE__ */ u("div", {
83
83
  className: "ctxmeter",
84
84
  ref: m,
85
- children: [/* @__PURE__ */ c("button", {
85
+ children: [/* @__PURE__ */ l("button", {
86
86
  type: "button",
87
87
  className: `ctxring ${y}`,
88
88
  "aria-expanded": f,
89
89
  onClick: () => p((e) => !e),
90
- "aria-label": u("chat.context.meter", {
91
- used: b(e.tokens, C),
92
- total: b(e.window, C),
90
+ "aria-label": a("chat.context.meter", {
91
+ used: x(e.tokens, S),
92
+ total: x(e.window, S),
93
93
  pct: v
94
94
  }),
95
- title: u("chat.context.meter", {
96
- used: b(e.tokens, C),
97
- total: b(e.window, C),
95
+ title: a("chat.context.meter", {
96
+ used: x(e.tokens, S),
97
+ total: x(e.window, S),
98
98
  pct: v
99
99
  }),
100
- children: /* @__PURE__ */ l("svg", {
100
+ children: /* @__PURE__ */ u("svg", {
101
101
  viewBox: "0 0 18 18",
102
102
  "aria-hidden": "true",
103
- children: [/* @__PURE__ */ c("circle", {
103
+ children: [/* @__PURE__ */ l("circle", {
104
104
  className: "bg",
105
105
  cx: "9",
106
106
  cy: "9",
107
107
  r: 7
108
- }), /* @__PURE__ */ c("circle", {
108
+ }), /* @__PURE__ */ l("circle", {
109
109
  className: "fg",
110
110
  cx: "9",
111
111
  cy: "9",
112
112
  r: 7,
113
- strokeDasharray: `${(x * _).toFixed(1)} ${x.toFixed(1)}`,
113
+ strokeDasharray: `${(b * h).toFixed(1)} ${b.toFixed(1)}`,
114
114
  transform: "rotate(-90 9 9)"
115
115
  })]
116
116
  })
117
- }), f && /* @__PURE__ */ l("div", {
117
+ }), f && /* @__PURE__ */ u("div", {
118
118
  className: "ctxtip",
119
119
  role: "dialog",
120
120
  children: [
121
- /* @__PURE__ */ c("div", { children: u("chat.context.meter", {
122
- used: b(e.tokens, C),
123
- total: b(e.window, C),
121
+ /* @__PURE__ */ l("div", { children: a("chat.context.meter", {
122
+ used: x(e.tokens, S),
123
+ total: x(e.window, S),
124
124
  pct: v
125
125
  }) }),
126
- y === "full" && /* @__PURE__ */ c("div", {
126
+ y === "full" && /* @__PURE__ */ l("div", {
127
127
  className: "small muted",
128
128
  style: { marginTop: 4 },
129
- children: u("chat.context.full")
129
+ children: a("chat.context.full")
130
130
  }),
131
- y === "full" && (t || n) && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("div", {
131
+ y === "full" && (t || n) && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
132
132
  className: "row",
133
133
  style: {
134
134
  marginTop: 8,
135
135
  gap: 6
136
136
  },
137
- children: [t && /* @__PURE__ */ c(S, {
137
+ children: [t && /* @__PURE__ */ l(C, {
138
138
  icon: "compress",
139
- label: u("chat.context.compact"),
139
+ label: a("chat.context.compact"),
140
140
  busy: r,
141
141
  run: () => {
142
142
  p(!1), t();
143
143
  }
144
- }), n && /* @__PURE__ */ c(S, {
144
+ }), n && /* @__PURE__ */ l(C, {
145
145
  icon: "reset",
146
- label: u("chat.context.reset"),
146
+ label: a("chat.context.reset"),
147
147
  busy: r,
148
148
  run: () => {
149
149
  p(!1), n();
150
150
  }
151
151
  })]
152
- }), r && /* @__PURE__ */ c("div", {
152
+ }), r && /* @__PURE__ */ l("div", {
153
153
  id: "ctx-wait",
154
154
  className: "small muted",
155
155
  style: { marginTop: 6 },
156
- children: u("chat.context.waitTurn")
156
+ children: a("chat.context.waitTurn")
157
157
  })] })
158
158
  ]
159
159
  })]
160
160
  });
161
161
  }
162
- function S({ icon: e, label: n, busy: r, run: i }) {
163
- return /* @__PURE__ */ l("button", {
162
+ function C({ icon: e, label: n, busy: r, run: i }) {
163
+ return /* @__PURE__ */ u("button", {
164
164
  type: "button",
165
165
  className: "btn sm",
166
166
  disabled: r,
167
167
  "aria-describedby": r ? "ctx-wait" : void 0,
168
168
  onClick: i,
169
- children: [/* @__PURE__ */ c(t, {
169
+ children: [/* @__PURE__ */ l(t, {
170
170
  name: e,
171
171
  size: 14
172
172
  }), n]
@@ -174,29 +174,31 @@ function S({ icon: e, label: n, busy: r, run: i }) {
174
174
  }
175
175
  //#endregion
176
176
  //#region src/chat/Attachments.tsx
177
- var C = /* @__PURE__ */ new Set([
177
+ var w = /\.(docx|doc|docm|odt|rtf|pptx|ppt|pptm|odp)$/, T = /\.(xlsx|xlsm|xls|ods)$/, E = /* @__PURE__ */ new Set([
178
178
  "image/png",
179
179
  "image/jpeg",
180
180
  "image/gif",
181
181
  "image/webp",
182
182
  "image/svg+xml"
183
- ]), w = /\.(png|jpe?g|gif|webp|svg)$/, T = /\.(txt|log|json|ya?ml|xml|ini|toml|sql|sh|py|go|js|ts|tsx|java|kt|rb|rs|c|cpp|h|css)$/;
184
- function E(e) {
185
- let t = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), n = e.fileName.toLowerCase();
186
- return C.has(t) || (!t || t === "application/octet-stream") && w.test(n) ? "image" : t === "application/pdf" || n.endsWith(".pdf") ? "pdf" : t === "text/markdown" || /\.(md|markdown)$/.test(n) ? "markdown" : t === "text/csv" || t === "text/tab-separated-values" || /\.(csv|tsv)$/.test(n) ? "table" : t === "text/html" || /\.html?$/.test(n) ? "html" : t.startsWith("text/") || t === "application/json" || t === "application/xml" || T.test(n) ? "text" : null;
183
+ ]), D = /\.(png|jpe?g|gif|webp|svg)$/, O = /\.(txt|log|json|ya?ml|xml|ini|toml|sql|sh|py|go|js|ts|tsx|java|kt|rb|rs|c|cpp|h|css)$/;
184
+ function k(e, t = !1) {
185
+ let n = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), r = e.fileName.toLowerCase();
186
+ return t && w.test(r) ? "office-doc" : t && T.test(r) ? "office-sheet" : E.has(n) || (!n || n === "application/octet-stream") && D.test(r) ? "image" : n === "application/pdf" || r.endsWith(".pdf") ? "pdf" : n === "text/markdown" || /\.(md|markdown)$/.test(r) ? "markdown" : n === "text/csv" || n === "text/tab-separated-values" || /\.(csv|tsv)$/.test(r) ? "table" : n === "text/html" || /\.html?$/.test(r) ? "html" : n.startsWith("text/") || n === "application/json" || n === "application/xml" || O.test(r) ? "text" : null;
187
187
  }
188
- var D = {
188
+ var A = {
189
189
  image: "image",
190
190
  pdf: "pdf",
191
191
  markdown: "markdown",
192
192
  table: "table",
193
193
  html: "globe",
194
- text: "source"
195
- }, O = (e) => D[e];
196
- function k(e, t) {
194
+ text: "source",
195
+ "office-doc": "files",
196
+ "office-sheet": "table"
197
+ }, j = (e) => A[e];
198
+ function ee(e, t) {
197
199
  return t === "pdf" ? "PDF" : t === "markdown" ? "MD" : t === "html" ? "HTML" : /\.([a-z0-9]{1,5})$/i.exec(e.fileName)?.[1]?.toUpperCase() ?? (t ? "TXT" : "FILE");
198
200
  }
199
- function A(e, t) {
201
+ function M(e, t) {
200
202
  let n = [
201
203
  "byte",
202
204
  "kilobyte",
@@ -204,30 +206,30 @@ function A(e, t) {
204
206
  "gigabyte"
205
207
  ], r = e, i = 0;
206
208
  for (; r >= 1024 && i < n.length - 1;) r /= 1024, i++;
207
- return new Intl.NumberFormat(y(t), {
209
+ return new Intl.NumberFormat(b(t), {
208
210
  style: "unit",
209
211
  unit: n[i],
210
212
  unitDisplay: "short",
211
213
  maximumFractionDigits: i === 0 ? 0 : 1
212
214
  }).format(r);
213
215
  }
214
- var j = "default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:";
215
- function ee(e) {
216
- let t = `<meta http-equiv="Content-Security-Policy" content="${j}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
216
+ var N = "default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:";
217
+ function P(e) {
218
+ let t = `<meta http-equiv="Content-Security-Policy" content="${N}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
217
219
  if (typeof DOMParser > "u") return n + t + e.slice(n.length);
218
220
  let r = new DOMParser().parseFromString(e, "text/html");
219
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) => {
220
222
  for (let t of Array.from(e.attributes)) {
221
223
  let n = t.name.toLowerCase();
222
- n.startsWith("on") || M.has(n) && !N.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !N.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", P(t.value));
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));
223
225
  }
224
226
  }), r.querySelectorAll("style").forEach((e) => {
225
- e.textContent = P(e.textContent ?? "");
227
+ e.textContent = L(e.textContent ?? "");
226
228
  });
227
229
  let i = r.createElement("meta");
228
- return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", j), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
230
+ return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", N), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
229
231
  }
230
- var M = /* @__PURE__ */ new Set([
232
+ var F = /* @__PURE__ */ new Set([
231
233
  "src",
232
234
  "href",
233
235
  "xlink:href",
@@ -245,11 +247,11 @@ var M = /* @__PURE__ */ new Set([
245
247
  "codebase",
246
248
  "archive",
247
249
  "usemap"
248
- ]), N = /^\s*(data:|#|$)/i;
249
- function P(e) {
250
- return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => N.test(n) && n.trim() !== "" ? e : "none");
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");
251
253
  }
252
- var F = {
254
+ var R = {
253
255
  png: "image/png",
254
256
  jpg: "image/jpeg",
255
257
  jpeg: "image/jpeg",
@@ -264,11 +266,11 @@ var F = {
264
266
  html: "text/html",
265
267
  htm: "text/html"
266
268
  };
267
- function I(e) {
269
+ function z(e) {
268
270
  let t = (e.mimeType ?? "").split(";")[0].trim().toLowerCase();
269
- return t && t !== "application/octet-stream" ? t : F[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
271
+ return t && t !== "application/octet-stream" ? t : R[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
270
272
  }
271
- function L(e, t) {
273
+ function B(e, t) {
272
274
  if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
273
275
  let n = [], r = [], i = "", a = !1;
274
276
  for (let t = 0; t < e.length; t++) {
@@ -277,9 +279,9 @@ function L(e, t) {
277
279
  }
278
280
  return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
279
281
  }
280
- function R(e, t, n = !0) {
281
- let [r, i] = h({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
282
- return d(() => {
282
+ function V(e, t, n = !0) {
283
+ let [r, i] = g({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
284
+ return f(() => {
283
285
  if (!n) return;
284
286
  let e, r = !0;
285
287
  return t({
@@ -290,7 +292,7 @@ function R(e, t, n = !0) {
290
292
  size: l
291
293
  }).then((t) => {
292
294
  if (!r) return;
293
- let n = I({
295
+ let n = z({
294
296
  fileName: s,
295
297
  mimeType: c
296
298
  }), a = n && t.type !== n ? new Blob([t], { type: n }) : t;
@@ -311,59 +313,59 @@ function R(e, t, n = !0) {
311
313
  l
312
314
  ]), r;
313
315
  }
314
- function z({ a: e, load: t, onOpen: n }) {
315
- let r = a(), { url: i, failed: o } = R(e, t);
316
- return o ? /* @__PURE__ */ c(B, {
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, {
317
319
  a: e,
318
320
  kind: "image",
319
321
  onOpen: n
320
- }) : /* @__PURE__ */ l("button", {
322
+ }) : /* @__PURE__ */ u("button", {
321
323
  type: "button",
322
324
  className: "att-thumb",
323
325
  onClick: n,
324
326
  "aria-label": r("chat.files.open", { name: e.fileName }),
325
327
  title: e.fileName,
326
- children: [i ? /* @__PURE__ */ c("img", {
328
+ children: [i ? /* @__PURE__ */ l("img", {
327
329
  src: i,
328
330
  alt: ""
329
- }) : /* @__PURE__ */ c("span", {
331
+ }) : /* @__PURE__ */ l("span", {
330
332
  className: "spin",
331
333
  "aria-hidden": "true"
332
- }), /* @__PURE__ */ c("span", {
334
+ }), /* @__PURE__ */ l("span", {
333
335
  className: "att-cap",
334
336
  children: e.fileName
335
337
  })]
336
338
  });
337
339
  }
338
- function B({ a: e, kind: n, onOpen: r }) {
339
- let i = a(), { i18n: u } = g(o), d = n !== null && r !== void 0, f = /* @__PURE__ */ l(s, { children: [
340
- /* @__PURE__ */ l("span", {
340
+ function te({ a: e, kind: n, onOpen: r }) {
341
+ let i = o(), { i18n: a } = _(s), d = n !== null && r !== void 0, f = /* @__PURE__ */ u(c, { children: [
342
+ /* @__PURE__ */ u("span", {
341
343
  className: "att-ic",
342
- children: [/* @__PURE__ */ c(t, {
343
- name: d && n ? D[n] : "download",
344
+ children: [/* @__PURE__ */ l(t, {
345
+ name: d && n ? A[n] : "download",
344
346
  size: 24
345
- }), /* @__PURE__ */ c("span", {
347
+ }), /* @__PURE__ */ l("span", {
346
348
  className: "att-kl",
347
- children: k(e, n)
349
+ children: ee(e, n)
348
350
  })]
349
351
  }),
350
- /* @__PURE__ */ c("span", {
352
+ /* @__PURE__ */ l("span", {
351
353
  className: "att-name",
352
354
  children: e.fileName
353
355
  }),
354
- e.size != null && /* @__PURE__ */ c("span", {
356
+ e.size != null && /* @__PURE__ */ l("span", {
355
357
  className: "att-size",
356
- children: A(e.size, u.language)
358
+ children: M(e.size, a.language)
357
359
  })
358
360
  ] });
359
- return d ? /* @__PURE__ */ c("button", {
361
+ return d ? /* @__PURE__ */ l("button", {
360
362
  type: "button",
361
363
  className: `att-tile ${n}`,
362
364
  onClick: r,
363
365
  "aria-label": i("chat.files.open", { name: e.fileName }),
364
366
  title: e.fileName,
365
367
  children: f
366
- }) : /* @__PURE__ */ c("a", {
368
+ }) : /* @__PURE__ */ l("a", {
367
369
  className: "att-tile dl",
368
370
  href: e.href,
369
371
  download: e.fileName,
@@ -372,40 +374,40 @@ function B({ a: e, kind: n, onOpen: r }) {
372
374
  children: f
373
375
  });
374
376
  }
375
- function V({ items: e, load: t, onOpen: n }) {
376
- return /* @__PURE__ */ c("div", {
377
+ function U({ items: e, load: t, onOpen: n, office: r = !1 }) {
378
+ return /* @__PURE__ */ l("div", {
377
379
  className: "atts",
378
380
  children: e.map((e) => {
379
- let r = t && n ? () => n(e) : void 0, i = E(e);
380
- return t && r && i === "image" ? /* @__PURE__ */ c(z, {
381
+ let i = t && n ? () => n(e) : void 0, a = k(e, r);
382
+ return t && i && a === "image" ? /* @__PURE__ */ l(H, {
381
383
  a: e,
382
384
  load: t,
383
- onOpen: r
384
- }, e.id) : /* @__PURE__ */ c(B, {
385
+ onOpen: i
386
+ }, e.id) : /* @__PURE__ */ l(te, {
385
387
  a: e,
386
- kind: i,
387
- onOpen: r
388
+ kind: a,
389
+ onOpen: i
388
390
  }, e.id);
389
391
  })
390
392
  });
391
393
  }
392
- function H({ text: e, tab: t }) {
393
- let n = a(), [r, ...i] = L(e, t), o = i.slice(0, 500);
394
- return /* @__PURE__ */ l("div", {
394
+ function W({ text: e, tab: t }) {
395
+ let n = o(), [r, ...i] = B(e, t), a = i.slice(0, 500);
396
+ return /* @__PURE__ */ u("div", {
395
397
  className: "att-table",
396
- children: [/* @__PURE__ */ l("table", { children: [r && /* @__PURE__ */ c("thead", { children: /* @__PURE__ */ c("tr", { children: r.map((e, t) => /* @__PURE__ */ c("th", { children: e }, t)) }) }), /* @__PURE__ */ c("tbody", { children: o.map((e, t) => /* @__PURE__ */ c("tr", { children: e.map((e, t) => /* @__PURE__ */ c("td", { children: e }, t)) }, t)) })] }), i.length > o.length && /* @__PURE__ */ c("div", {
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", {
397
399
  className: "att-more",
398
400
  children: n("chat.files.rows", {
399
- shown: o.length,
401
+ shown: a.length,
400
402
  total: i.length
401
403
  })
402
404
  })]
403
405
  });
404
406
  }
405
- var U = 1280;
406
- function W({ text: e, title: t }) {
407
- let n = m(null), [r, i] = h(U), [a, o] = h(U);
408
- d(() => {
407
+ var G = 1280;
408
+ function K({ text: e, title: t }) {
409
+ let n = h(null), [r, i] = g(G), [a, o] = g(G);
410
+ f(() => {
409
411
  let e = n.current;
410
412
  if (!e) return;
411
413
  let t = () => i(e.clientWidth);
@@ -413,158 +415,336 @@ function W({ text: e, title: t }) {
413
415
  let r = new ResizeObserver(t);
414
416
  return r.observe(e), () => r.disconnect();
415
417
  }, []);
416
- let s = p(() => ee(e), [e]), [l, u] = h(s);
417
- l !== s && (u(s), o(U));
418
- let f = (e) => {
418
+ let s = m(() => P(e), [e]), [c, u] = g(s);
419
+ c !== s && (u(s), o(G));
420
+ let d = (e) => {
419
421
  let t = e.currentTarget, n = () => {
420
422
  let e = t.contentDocument?.documentElement;
421
- e && o(Math.max(U, e.scrollWidth));
423
+ e && o(Math.max(G, e.scrollWidth));
422
424
  };
423
425
  n(), t.contentDocument?.fonts?.ready.then(n);
424
- }, g = Math.min(1, r / a);
425
- return /* @__PURE__ */ c("div", {
426
+ }, p = Math.min(1, r / a);
427
+ return /* @__PURE__ */ l("div", {
426
428
  className: "att-htmlbox",
427
429
  ref: n,
428
- children: /* @__PURE__ */ c("iframe", {
430
+ children: /* @__PURE__ */ l("iframe", {
429
431
  className: "att-html",
430
432
  sandbox: "allow-same-origin",
431
433
  srcDoc: s,
432
434
  title: t,
433
435
  referrerPolicy: "no-referrer",
434
- onLoad: f,
436
+ onLoad: d,
435
437
  style: {
436
438
  width: a,
437
- height: `${100 / g}%`,
438
- transform: `scale(${g})`
439
+ height: `${100 / p}%`,
440
+ transform: `scale(${p})`
439
441
  }
440
442
  })
441
443
  });
442
444
  }
443
- function te({ a: e, load: i, onClose: u }) {
444
- let f = a(), { i18n: p } = g(o), m = E(e), _ = m === "markdown" || m === "table" || m === "html" || m === "text", [v, y] = h(!1), b = _ && (e.size ?? 0) > 1048576, { url: x, blob: S, failed: C } = R(e, i, !b), [w, T] = h(null), D = b || _ && (S?.size ?? 0) > 1048576;
445
- d(() => {
446
- _ && S && !D && S.arrayBuffer().then((e) => {
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;
447
+ f(() => {
448
+ y && w && !O && w.arrayBuffer().then((e) => {
447
449
  try {
448
- T({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
450
+ D({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
449
451
  } catch {
450
- T({ text: null });
452
+ D({ text: null });
451
453
  }
452
- }, () => T({ text: null }));
454
+ }, () => D({ text: null }));
453
455
  }, [
454
- _,
455
- S,
456
- D
456
+ y,
457
+ w,
458
+ O
457
459
  ]);
458
- let O = w?.text, k;
459
- return k = C ? /* @__PURE__ */ c("div", {
460
+ let A = E?.text, j;
461
+ return j = v && i ? /* @__PURE__ */ l(Y, {
462
+ a: e,
463
+ load: i
464
+ }) : T ? /* @__PURE__ */ l("div", {
460
465
  className: "att-msg err-text",
461
- children: f("chat.files.failed")
462
- }) : D ? /* @__PURE__ */ c("div", {
466
+ children: p("chat.files.failed")
467
+ }) : O ? /* @__PURE__ */ l("div", {
463
468
  className: "att-msg",
464
- children: f("chat.files.tooLarge")
465
- }) : w && O === null ? /* @__PURE__ */ c("div", {
469
+ children: p("chat.files.tooLarge")
470
+ }) : E && A === null ? /* @__PURE__ */ l("div", {
466
471
  className: "att-msg",
467
- children: f("chat.files.notUtf8")
468
- }) : !x || _ && O == null ? /* @__PURE__ */ l("div", {
472
+ children: p("chat.files.notUtf8")
473
+ }) : !C || y && A == null ? /* @__PURE__ */ u("div", {
469
474
  className: "att-msg",
470
475
  children: [
471
- /* @__PURE__ */ c("span", {
476
+ /* @__PURE__ */ l("span", {
472
477
  className: "spin",
473
478
  "aria-hidden": "true"
474
479
  }),
475
480
  " ",
476
- f("loading")
481
+ p("loading")
477
482
  ]
478
- }) : m === "image" ? /* @__PURE__ */ c("img", {
483
+ }) : h === "image" ? /* @__PURE__ */ l("img", {
479
484
  className: "att-img",
480
- src: x,
485
+ src: C,
481
486
  alt: e.fileName
482
- }) : m === "pdf" ? /* @__PURE__ */ c("object", {
487
+ }) : h === "pdf" ? /* @__PURE__ */ l("object", {
483
488
  className: "att-pdf",
484
- data: x,
489
+ data: C,
485
490
  type: "application/pdf",
486
491
  "aria-label": e.fileName,
487
- children: /* @__PURE__ */ c("div", {
492
+ children: /* @__PURE__ */ l("div", {
488
493
  className: "att-msg",
489
- children: f("chat.files.failed")
494
+ children: p("chat.files.failed")
490
495
  })
491
- }) : m === "markdown" ? /* @__PURE__ */ c("div", {
496
+ }) : h === "markdown" ? /* @__PURE__ */ l("div", {
492
497
  className: "att-md",
493
- children: /* @__PURE__ */ c(r, { text: O ?? "" })
494
- }) : m === "table" ? /* @__PURE__ */ c(H, {
495
- text: O ?? "",
498
+ children: /* @__PURE__ */ l(a, { text: A ?? "" })
499
+ }) : h === "table" ? /* @__PURE__ */ l(W, {
500
+ text: A ?? "",
496
501
  tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
497
- }) : m === "html" && !v ? /* @__PURE__ */ c(W, {
498
- text: O ?? "",
502
+ }) : h === "html" && !b ? /* @__PURE__ */ l(K, {
503
+ text: A ?? "",
499
504
  title: e.fileName
500
- }) : /* @__PURE__ */ c("pre", {
505
+ }) : /* @__PURE__ */ l("pre", {
501
506
  className: "att-text",
502
- children: O
503
- }), /* @__PURE__ */ c(n, {
507
+ children: A
508
+ }), /* @__PURE__ */ l(n, {
504
509
  wide: !0,
505
- onClose: u,
506
- title: /* @__PURE__ */ l("span", {
510
+ onClose: d,
511
+ title: /* @__PURE__ */ u("span", {
507
512
  className: "att-title",
508
- children: [/* @__PURE__ */ c("span", {
513
+ children: [/* @__PURE__ */ l("span", {
509
514
  className: "att-name",
510
515
  children: e.fileName
511
- }), e.size != null && /* @__PURE__ */ c("span", {
516
+ }), e.size != null && /* @__PURE__ */ l("span", {
512
517
  className: "muted small",
513
- children: A(e.size, p.language)
518
+ children: M(e.size, m.language)
514
519
  })]
515
520
  }),
516
- footer: /* @__PURE__ */ l(s, { children: [
517
- m === "html" && /* @__PURE__ */ l("button", {
521
+ footer: /* @__PURE__ */ u(c, { children: [
522
+ h === "html" && /* @__PURE__ */ u("button", {
518
523
  type: "button",
519
524
  className: "btn ghost",
520
- onClick: () => y((e) => !e),
525
+ onClick: () => x((e) => !e),
521
526
  children: [
522
- /* @__PURE__ */ c(t, {
523
- name: v ? "globe" : "code",
527
+ /* @__PURE__ */ l(t, {
528
+ name: b ? "globe" : "code",
524
529
  size: 14
525
530
  }),
526
531
  " ",
527
- f(v ? "chat.files.page" : "chat.files.source")
532
+ p(b ? "chat.files.page" : "chat.files.source")
528
533
  ]
529
534
  }),
530
- /* @__PURE__ */ l("a", {
535
+ /* @__PURE__ */ u("a", {
531
536
  className: "btn ghost",
532
- href: x ?? e.href,
537
+ href: C ?? e.href,
533
538
  download: e.fileName,
534
539
  children: [
535
- /* @__PURE__ */ c(t, {
540
+ /* @__PURE__ */ l(t, {
536
541
  name: "download",
537
542
  size: 14
538
543
  }),
539
544
  " ",
540
- f("chat.files.download")
545
+ p("chat.files.download")
541
546
  ]
542
547
  }),
543
- /* @__PURE__ */ c("button", {
548
+ /* @__PURE__ */ l("button", {
544
549
  type: "button",
545
550
  className: "btn primary",
546
- onClick: u,
547
- children: f("close")
551
+ onClick: d,
552
+ children: p("close")
548
553
  })
549
554
  ] }),
550
- children: /* @__PURE__ */ c("div", {
551
- className: `att-view ${m ?? ""}`,
552
- children: k
555
+ children: /* @__PURE__ */ l("div", {
556
+ className: `att-view ${h ?? ""}`,
557
+ children: j
553
558
  })
554
559
  });
555
560
  }
561
+ var re = 4e4, ie = 2e3, q = 25, J = 50;
562
+ function Y({ a: e, load: n }) {
563
+ let r = o(), [i, a] = g({ state: "loading" }), { id: s, href: c, fileName: d, mimeType: p, size: m } = e;
564
+ return f(() => {
565
+ let e = !0, t, r = Date.now(), i = () => {
566
+ n({
567
+ id: s,
568
+ href: c,
569
+ fileName: d,
570
+ mimeType: p,
571
+ size: m
572
+ }).then((n) => {
573
+ e && (n.state === "pending" ? Date.now() - r > re ? a({
574
+ state: "error",
575
+ reason: "timeout"
576
+ }) : (a(n), t = setTimeout(i, ie)) : a(n));
577
+ }, () => e && a({ state: "failed" }));
578
+ };
579
+ return i(), () => {
580
+ e = !1, t && clearTimeout(t);
581
+ };
582
+ }, [
583
+ n,
584
+ s,
585
+ c,
586
+ d,
587
+ p,
588
+ m
589
+ ]), i.state === "loading" || i.state === "pending" ? /* @__PURE__ */ u("div", {
590
+ className: "att-msg att-wait",
591
+ children: [
592
+ /* @__PURE__ */ l("span", {
593
+ className: "spin",
594
+ "aria-hidden": "true"
595
+ }),
596
+ /* @__PURE__ */ l("b", { children: r("chat.files.preparing") }),
597
+ /* @__PURE__ */ l("span", {
598
+ className: "muted small",
599
+ children: r("chat.files.preparingHint")
600
+ })
601
+ ]
602
+ }) : i.state === "failed" ? /* @__PURE__ */ l("div", {
603
+ className: "att-msg err-text",
604
+ children: r("chat.files.failed")
605
+ }) : i.state === "error" ? /* @__PURE__ */ u("div", {
606
+ className: "att-msg att-wait",
607
+ children: [
608
+ /* @__PURE__ */ l(t, {
609
+ name: "alert",
610
+ size: 28
611
+ }),
612
+ /* @__PURE__ */ l("b", { children: r("chat.files.unavailable") }),
613
+ /* @__PURE__ */ l("span", {
614
+ className: "muted small",
615
+ children: r(`chat.files.reasons.${i.reason}`, { limit: i.limitMb ?? q })
616
+ })
617
+ ]
618
+ }) : i.state === "doc" ? /* @__PURE__ */ l(X, {
619
+ blob: i.blob,
620
+ shown: i.shown,
621
+ total: i.total,
622
+ from: i.from,
623
+ name: e.fileName
624
+ }) : /* @__PURE__ */ l(se, { sheets: i.sheets });
625
+ }
626
+ function X({ blob: e, shown: t, total: n, from: r, name: i }) {
627
+ let a = o(), s = m(() => URL.createObjectURL(e.type === "application/pdf" ? e : new Blob([e], { type: "application/pdf" })), [e]);
628
+ return f(() => () => URL.revokeObjectURL(s), [s]), /* @__PURE__ */ u("div", {
629
+ className: "att-office",
630
+ children: [
631
+ /* @__PURE__ */ l("div", {
632
+ className: "att-converted",
633
+ children: a("chat.files.converted", { format: r })
634
+ }),
635
+ /* @__PURE__ */ l("object", {
636
+ className: "att-pdf",
637
+ data: s,
638
+ type: "application/pdf",
639
+ "aria-label": i,
640
+ children: /* @__PURE__ */ l("div", {
641
+ className: "att-msg",
642
+ children: a("chat.files.failed")
643
+ })
644
+ }),
645
+ n != null && n > t && /* @__PURE__ */ l("div", {
646
+ className: "att-more",
647
+ children: a("chat.files.pagesShown", {
648
+ shown: t,
649
+ total: n
650
+ })
651
+ }),
652
+ n == null && t >= J && /* @__PURE__ */ l("div", {
653
+ className: "att-more",
654
+ children: a("chat.files.firstPages", { shown: t })
655
+ })
656
+ ]
657
+ });
658
+ }
659
+ function ae(e) {
660
+ let t = /^([A-Z]+)(\d+)$/.exec(e);
661
+ if (!t) return null;
662
+ let n = 0;
663
+ for (let e of t[1]) n = n * 26 + e.charCodeAt(0) - 64;
664
+ return [Number(t[2]) - 1, n - 1];
665
+ }
666
+ function oe(e) {
667
+ let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
668
+ for (let r of e) {
669
+ let [e, i] = r.split(":").map(ae);
670
+ if (e && i) {
671
+ t.set(`${e[0]}:${e[1]}`, [i[0] - e[0] + 1, i[1] - e[1] + 1]);
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}`);
673
+ }
674
+ }
675
+ return {
676
+ spans: t,
677
+ covered: n
678
+ };
679
+ }
680
+ function Z(e) {
681
+ let t = "";
682
+ for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
683
+ return t;
684
+ }
685
+ function se({ sheets: e }) {
686
+ let t = o(), [n, i] = g(0), a = e[Math.min(n, e.length - 1)];
687
+ if (!a) return /* @__PURE__ */ l("div", {
688
+ className: "att-msg",
689
+ children: t("chat.files.failed")
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;
692
+ return /* @__PURE__ */ u("div", {
693
+ className: "att-office",
694
+ children: [
695
+ e.length > 1 && /* @__PURE__ */ l(r, {
696
+ label: t("chat.files.sheets"),
697
+ items: e.map((e, t) => ({
698
+ key: String(t),
699
+ label: e.name
700
+ })),
701
+ value: String(n),
702
+ onChange: (e) => i(Number(e))
703
+ }),
704
+ /* @__PURE__ */ l("div", {
705
+ className: "att-table att-sheet",
706
+ children: /* @__PURE__ */ u("table", { children: [/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [/* @__PURE__ */ l("th", {}), d.map((e) => /* @__PURE__ */ l("th", { children: e }, e))] }) }), /* @__PURE__ */ l("tbody", { children: a.cells.map((e, n) => /* @__PURE__ */ u("tr", { children: [/* @__PURE__ */ l("th", { children: n + 1 }), e.map((e, r) => {
707
+ if (p.has(`${n}:${r}`)) return null;
708
+ let [i, a] = f.get(`${n}:${r}`) ?? [1, 1], o = i > 1 ? i : void 0, s = a > 1 ? a : void 0;
709
+ return e.f ? /* @__PURE__ */ l("td", {
710
+ rowSpan: o,
711
+ colSpan: s,
712
+ className: "att-formula",
713
+ title: t("chat.files.formulaHint"),
714
+ children: e.f
715
+ }, r) : /* @__PURE__ */ l("td", {
716
+ rowSpan: o,
717
+ colSpan: s,
718
+ className: e.n == null ? void 0 : "att-num",
719
+ children: e.v ?? ""
720
+ }, r);
721
+ })] }, n)) })] })
722
+ }),
723
+ (m || h) && /* @__PURE__ */ u("div", {
724
+ className: "att-more",
725
+ children: [t("chat.files.rows", {
726
+ shown: a.cells.length,
727
+ total: a.rows
728
+ }), h && /* @__PURE__ */ u(c, { children: [" ", t("chat.files.cols", {
729
+ shown: s,
730
+ total: a.cols
731
+ })] })]
732
+ })
733
+ ]
734
+ });
735
+ }
556
736
  //#endregion
557
737
  //#region src/chat/MessageView.tsx
558
- function ne(e, t) {
559
- return new Intl.DateTimeFormat(y(t), {
738
+ function ce(e, t) {
739
+ return new Intl.DateTimeFormat(b(t), {
560
740
  hour: "2-digit",
561
741
  minute: "2-digit"
562
742
  }).format(new Date(e));
563
743
  }
564
- function re(e, t) {
744
+ function le(e, t) {
565
745
  return t || e.length <= 3 ? e : e.slice(-2);
566
746
  }
567
- var G = {
747
+ var Q = {
568
748
  done: {
569
749
  icon: "check",
570
750
  cls: "ok"
@@ -578,158 +758,159 @@ var G = {
578
758
  cls: "run"
579
759
  }
580
760
  };
581
- function ie({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u }) {
582
- let { t: d, i18n: f } = g(o), [p, m] = h(!1);
583
- if (e.role === "note") return /* @__PURE__ */ c("div", {
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);
763
+ if (e.role === "note") return /* @__PURE__ */ l("div", {
584
764
  className: "sysnote",
585
765
  children: e.text
586
766
  });
587
- if (e.role === "event" && e.event) return /* @__PURE__ */ c(ae, { m: e });
588
- let _ = e.mark && /* @__PURE__ */ l("div", {
767
+ if (e.role === "event" && e.event) return /* @__PURE__ */ l(pe, { m: e });
768
+ let v = e.mark && /* @__PURE__ */ u("div", {
589
769
  className: "chan",
590
770
  children: [
591
- /* @__PURE__ */ c(t, {
771
+ /* @__PURE__ */ l(t, {
592
772
  name: e.mark.icon,
593
773
  size: 12
594
774
  }),
595
775
  " ",
596
776
  e.mark.text,
597
777
  " · ",
598
- ne(e.createdAt, f.language)
778
+ ce(e.createdAt, p.language)
599
779
  ]
600
- }), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(V, {
780
+ }), y = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l(U, {
601
781
  items: e.attachments,
602
- load: a,
603
- onOpen: u
782
+ load: i,
783
+ office: !!o,
784
+ onOpen: d
604
785
  });
605
- if (e.role === "user") return /* @__PURE__ */ l("div", {
786
+ if (e.role === "user") return /* @__PURE__ */ u("div", {
606
787
  className: "m u",
607
788
  children: [
608
- _,
789
+ v,
609
790
  e.content,
610
- e.text && /* @__PURE__ */ c("div", {
791
+ e.text && /* @__PURE__ */ l("div", {
611
792
  className: "bub",
612
793
  children: e.text
613
794
  }),
614
- v,
615
- e.wait && /* @__PURE__ */ c("div", {
795
+ y,
796
+ e.wait && /* @__PURE__ */ l("div", {
616
797
  className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
617
798
  role: "status",
618
- children: e.wait.state === "queued" ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
799
+ children: e.wait.state === "queued" ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(t, {
619
800
  name: "clock",
620
801
  size: 12
621
- }), d("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
802
+ }), f("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
622
803
  className: "spin",
623
804
  "aria-hidden": "true"
624
- }), d("chat.wait.starting")] })
805
+ }), f("chat.wait.starting")] })
625
806
  })
626
807
  ]
627
808
  });
628
- if (e.variant === "notice") return /* @__PURE__ */ c(q, {
809
+ if (e.variant === "notice") return /* @__PURE__ */ l(fe, {
629
810
  m: e,
630
- mark: _,
631
- atts: v
811
+ mark: v,
812
+ atts: y
632
813
  });
633
- let y = e.steps ?? [], b = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
634
- return /* @__PURE__ */ l("div", {
814
+ let b = e.steps ?? [], x = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
815
+ return /* @__PURE__ */ u("div", {
635
816
  className: "m a",
636
817
  children: [
637
- _,
638
- y.length > 3 && /* @__PURE__ */ c("button", {
818
+ v,
819
+ b.length > 3 && /* @__PURE__ */ l("button", {
639
820
  className: "tools-fold",
640
- onClick: () => m((e) => !e),
641
- "aria-expanded": p,
642
- children: p ? d("chat.hideSteps") : d("chat.moreSteps", { count: y.length - 2 })
821
+ onClick: () => h((e) => !e),
822
+ "aria-expanded": m,
823
+ children: m ? f("chat.hideSteps") : f("chat.moreSteps", { count: b.length - 2 })
643
824
  }),
644
- re(y, p).map((e) => /* @__PURE__ */ l("div", {
825
+ le(b, m).map((e) => /* @__PURE__ */ u("div", {
645
826
  className: "tool",
646
827
  title: e.title,
647
- children: [/* @__PURE__ */ c(t, {
648
- name: G[e.status].icon,
828
+ children: [/* @__PURE__ */ l(t, {
829
+ name: Q[e.status].icon,
649
830
  size: 14,
650
- className: G[e.status].cls
651
- }), /* @__PURE__ */ c("span", {
831
+ className: Q[e.status].cls
832
+ }), /* @__PURE__ */ l("span", {
652
833
  className: "tx",
653
834
  children: e.text
654
835
  })]
655
836
  }, e.id)),
656
- b && /* @__PURE__ */ c("div", {
837
+ x && /* @__PURE__ */ l("div", {
657
838
  className: "bub",
658
- children: /* @__PURE__ */ l("span", {
839
+ children: /* @__PURE__ */ u("span", {
659
840
  className: "typing",
660
- "aria-label": d("chat.typing"),
841
+ "aria-label": f("chat.typing"),
661
842
  children: [
662
- /* @__PURE__ */ c("i", {}),
663
- /* @__PURE__ */ c("i", {}),
664
- /* @__PURE__ */ c("i", {})
843
+ /* @__PURE__ */ l("i", {}),
844
+ /* @__PURE__ */ l("i", {}),
845
+ /* @__PURE__ */ l("i", {})
665
846
  ]
666
847
  })
667
848
  }),
668
- e.content ?? (e.text && /* @__PURE__ */ c("div", {
849
+ e.content ?? (e.text && /* @__PURE__ */ l("div", {
669
850
  className: "bub",
670
851
  title: e.hint,
671
- children: /* @__PURE__ */ c(r, { text: e.text })
852
+ children: /* @__PURE__ */ l(a, { text: e.text })
672
853
  })),
673
- v,
674
- e.error && /* @__PURE__ */ l("div", {
854
+ y,
855
+ e.error && /* @__PURE__ */ u("div", {
675
856
  className: `llmerr${e.error.transient ? " amber" : ""}`,
676
857
  role: "alert",
677
858
  style: { marginTop: 6 },
678
- children: [/* @__PURE__ */ c("span", { children: e.error.text }), i && /* @__PURE__ */ c("div", {
859
+ children: [/* @__PURE__ */ l("span", { children: e.error.text }), r && /* @__PURE__ */ l("div", {
679
860
  className: "row",
680
- children: /* @__PURE__ */ l("button", {
861
+ children: /* @__PURE__ */ u("button", {
681
862
  className: "btn sm",
682
863
  disabled: n,
683
- onClick: i,
684
- children: [/* @__PURE__ */ c(t, {
864
+ onClick: r,
865
+ children: [/* @__PURE__ */ l(t, {
685
866
  name: "refresh",
686
867
  size: 14
687
- }), d("chat.retry")]
868
+ }), f("chat.retry")]
688
869
  })
689
870
  })]
690
871
  })
691
872
  ]
692
873
  });
693
874
  }
694
- var K = 12;
695
- function q({ m: e, mark: t, atts: n }) {
696
- let { t: i } = g(o), [a, s] = h(!1), u = !e.content && e.text.split("\n").length > 12;
697
- return /* @__PURE__ */ l("div", {
875
+ var de = 12;
876
+ function fe({ m: e, mark: t, atts: n }) {
877
+ let { t: r } = _(s), [i, o] = g(!1), c = !e.content && e.text.split("\n").length > 12;
878
+ return /* @__PURE__ */ u("div", {
698
879
  className: "m a notice",
699
880
  children: [
700
881
  t,
701
- e.content ?? /* @__PURE__ */ l("div", {
702
- className: `bub${u && !a ? " folded" : ""}`,
703
- children: [/* @__PURE__ */ c(r, { text: e.text }), u && /* @__PURE__ */ c("button", {
882
+ e.content ?? /* @__PURE__ */ u("div", {
883
+ className: `bub${c && !i ? " folded" : ""}`,
884
+ children: [/* @__PURE__ */ l(a, { text: e.text }), c && /* @__PURE__ */ l("button", {
704
885
  type: "button",
705
886
  className: "textbtn",
706
- "aria-expanded": a,
707
- onClick: () => s((e) => !e),
708
- children: i(a ? "chat.notice.less" : "chat.notice.more")
887
+ "aria-expanded": i,
888
+ onClick: () => o((e) => !e),
889
+ children: r(i ? "chat.notice.less" : "chat.notice.more")
709
890
  })]
710
891
  }),
711
892
  n
712
893
  ]
713
894
  });
714
895
  }
715
- function ae({ m: e }) {
716
- let { t: n, i18n: r } = g(o), [i, a] = h(!1), s = e.event;
717
- return /* @__PURE__ */ l("div", {
896
+ function pe({ m: e }) {
897
+ let { t: n, i18n: r } = _(s), [i, a] = g(!1), o = e.event;
898
+ return /* @__PURE__ */ u("div", {
718
899
  className: "evdiv",
719
- children: [/* @__PURE__ */ c("div", {
900
+ children: [/* @__PURE__ */ l("div", {
720
901
  className: "evline",
721
902
  role: "separator",
722
- children: /* @__PURE__ */ l("span", {
903
+ children: /* @__PURE__ */ u("span", {
723
904
  className: "evchip",
724
905
  children: [
725
- /* @__PURE__ */ c(t, {
726
- name: s.icon,
906
+ /* @__PURE__ */ l(t, {
907
+ name: o.icon,
727
908
  size: 12
728
909
  }),
729
- s.text,
910
+ o.text,
730
911
  " · ",
731
- ne(e.createdAt, r.language),
732
- s.details && /* @__PURE__ */ l("button", {
912
+ ce(e.createdAt, r.language),
913
+ o.details && /* @__PURE__ */ u("button", {
733
914
  type: "button",
734
915
  className: "textbtn",
735
916
  "aria-expanded": i,
@@ -742,41 +923,41 @@ function ae({ m: e }) {
742
923
  })
743
924
  ]
744
925
  })
745
- }), i && s.details && /* @__PURE__ */ c("div", {
926
+ }), i && o.details && /* @__PURE__ */ l("div", {
746
927
  className: "evdetails",
747
- children: s.details
928
+ children: o.details
748
929
  })]
749
930
  });
750
931
  }
751
932
  //#endregion
752
933
  //#region src/chat/transcription.ts
753
- async function oe(e, t, n) {
934
+ async function me(e, t, n) {
754
935
  n.busy(!0);
755
936
  let r;
756
937
  try {
757
938
  r = await t(e);
758
939
  } catch (r) {
759
- n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void oe(e, t, n));
940
+ n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void me(e, t, n));
760
941
  return;
761
942
  }
762
943
  n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
763
944
  }
764
945
  //#endregion
765
946
  //#region src/chat/useRecorder.ts
766
- function se(e = 300, t) {
767
- let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = h(!1), [a, o] = h(0), [s, c] = h(0), [l, f] = h(!1), p = m(null), g = m([]), _ = m(void 0), v = m(null), y = m(null), b = m(!1), x = m(t);
768
- d(() => {
947
+ function he(e = 300, t) {
948
+ 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
+ f(() => {
769
950
  x.current = t;
770
951
  });
771
- let S = u(() => {
952
+ let S = d(() => {
772
953
  window.clearInterval(_.current), p.current?.stream.getTracks().forEach((e) => e.stop()), p.current = null, v.current?.close().catch(() => void 0), v.current = null, i(!1), c(0);
773
- }, []), C = u(async () => {
954
+ }, []), C = d(async () => {
774
955
  if (n && !p.current) {
775
- f(!1);
956
+ u(!1);
776
957
  try {
777
958
  let t = await navigator.mediaDevices.getUserMedia({ audio: !0 }), n = new MediaRecorder(t);
778
- g.current = [], b.current = !1, n.ondataavailable = (e) => e.data.size > 0 && g.current.push(e.data), n.onstop = () => {
779
- let e = !b.current && g.current.length ? new Blob(g.current, { type: n.mimeType || "audio/webm" }) : null;
959
+ m.current = [], b.current = !1, n.ondataavailable = (e) => e.data.size > 0 && m.current.push(e.data), n.onstop = () => {
960
+ let e = !b.current && m.current.length ? new Blob(m.current, { type: n.mimeType || "audio/webm" }) : null;
780
961
  S(), y.current?.(e), y.current = null;
781
962
  };
782
963
  let r = null;
@@ -800,21 +981,21 @@ function se(e = 300, t) {
800
981
  t >= e && !l && (l = !0, x.current?.());
801
982
  }, 100);
802
983
  } catch {
803
- f(!0), S();
984
+ u(!0), S();
804
985
  }
805
986
  }
806
987
  }, [
807
988
  n,
808
989
  S,
809
990
  e
810
- ]), w = u(() => new Promise((e) => {
991
+ ]), w = d(() => new Promise((e) => {
811
992
  let t = p.current;
812
993
  if (!t || t.state === "inactive") return e(null);
813
994
  y.current = e, t.stop();
814
- }), []), T = u(() => {
995
+ }), []), T = d(() => {
815
996
  b.current = !0, w();
816
997
  }, [w]);
817
- return d(() => () => S(), [S]), {
998
+ return f(() => () => S(), [S]), {
818
999
  supported: n,
819
1000
  recording: r,
820
1001
  seconds: a,
@@ -825,84 +1006,80 @@ function se(e = 300, t) {
825
1006
  cancel: T
826
1007
  };
827
1008
  }
828
- function ce(e) {
1009
+ function ge(e) {
829
1010
  return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
830
1011
  }
831
1012
  //#endregion
832
1013
  //#region src/chat/Chat.tsx
833
- function le(n) {
834
- let r = a(), i = e(), [o, u] = h(""), [g, y] = h([]), [b, S] = h(!1), [C, w] = h(null), [T, E] = h(0), [D, O] = h(!1), [k, A] = h(null), [j, ee] = h(!1), [M, N] = h(null), P = m(n.loadAttachment);
835
- d(() => {
836
- P.current = n.loadAttachment;
837
- });
838
- let F = !!n.loadAttachment, I = p(() => F ? (e) => P.current ? P.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [F]), L = m(!1), R = m(null), z = m(null), B = m(null), V = n.voiceMaxSeconds ?? 300, H = se(V, () => void ve()), { messages: U, busy: W = !1 } = n, ne = W || U.some((e) => e.status === "pending" || e.status === "streaming"), re = n.onPendingChange;
839
- d(() => re?.(g), [g, re]);
840
- let G = U[0]?.id, K = U[U.length - 1], q = K?.id, ae = K?.text.length, le = K?.steps?.length, fe = m({ height: 0 });
841
- f(() => {
842
- let e = R.current;
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 });
1018
+ p(() => {
1019
+ let e = I.current;
843
1020
  if (!e) return;
844
- let t = fe.current;
845
- e.scrollTop = t.first !== void 0 && G !== t.first && q === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, fe.current = {
846
- first: G,
847
- last: q,
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,
848
1025
  height: e.scrollHeight
849
1026
  };
850
1027
  }, [
851
- U.length,
852
- G,
853
- q,
854
- ae,
855
- le
1028
+ V.length,
1029
+ W,
1030
+ K,
1031
+ re,
1032
+ ie
856
1033
  ]);
857
- let J = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Y = J === null ? [] : _(n.commands ?? [], J), X = J !== null && !D, he = () => {
858
- u(""), y([]), w(null), A(null), L.current = !1;
859
- }, Z = async (e, t) => {
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 = () => {
1035
+ s(""), m([]), C(null), k(null), F.current = !1;
1036
+ }, oe = async (e, t) => {
860
1037
  if (n.onCommand) try {
861
- await n.onCommand(e, t), he();
1038
+ await n.onCommand(e, t), ae();
862
1039
  } catch {}
863
- }, Q = async (e, t = !1) => {
1040
+ }, Z = async (e, t = !1) => {
864
1041
  let r = e.trim();
865
- if (!(!r && g.length === 0 && !C || W || n.readOnly)) {
866
- if (!t && !C && n.commands && r.startsWith("/")) {
1042
+ if (!(!r && d.length === 0 && !x || H || n.readOnly)) {
1043
+ if (!t && !x && n.commands && r.startsWith("/")) {
867
1044
  let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
868
- if (i) return Z(i.name, t.join(" "));
1045
+ if (i) return oe(i.name, t.join(" "));
869
1046
  if (e && !r.includes("\n")) {
870
- A("/" + e);
1047
+ k("/" + e);
871
1048
  return;
872
1049
  }
873
1050
  }
874
1051
  try {
875
- await n.onSend(r, g.map((e) => e.id), L.current, C ?? void 0), he();
1052
+ await n.onSend(r, d.map((e) => e.id), F.current, x ?? void 0), ae();
876
1053
  } catch {}
877
1054
  }
878
- }, $ = (e) => {
879
- E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : Z(e.name, ""), B.current?.focus();
880
- }, ge = (e) => {
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) => {
881
1058
  if (X && Y.length > 0) {
882
1059
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
883
1060
  e.preventDefault();
884
1061
  let t = e.key === "ArrowDown" ? 1 : -1;
885
- E((e) => (e + t + Y.length) % Y.length);
1062
+ T((e) => (e + t + Y.length) % Y.length);
886
1063
  return;
887
1064
  }
888
1065
  if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
889
- e.preventDefault(), $(Y[Math.min(T, Y.length - 1)]);
1066
+ e.preventDefault(), se(Y[Math.min(w, Y.length - 1)]);
890
1067
  return;
891
1068
  }
892
1069
  }
893
- X && e.key === "Escape" ? (e.preventDefault(), O(!0)) : e.key === "Backspace" && C && o === "" ? w(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && !de() && (e.preventDefault(), Q(o));
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));
894
1071
  };
895
- f(() => pe(R.current, () => me(B.current)), [o]), d(() => {
896
- let e = B.current;
1072
+ p(() => xe(I.current, () => Se(R.current)), [a]), f(() => {
1073
+ let e = R.current;
897
1074
  if (!e || typeof ResizeObserver > "u") return;
898
1075
  let t = e.clientWidth, n = new ResizeObserver(() => {
899
- e.clientWidth !== t && (t = e.clientWidth, pe(R.current, () => me(e)));
1076
+ e.clientWidth !== t && (t = e.clientWidth, xe(I.current, () => Se(e)));
900
1077
  });
901
1078
  return n.observe(e), () => n.disconnect();
902
- }, [H.recording]);
903
- let _e = async (e) => {
1079
+ }, [B.recording]);
1080
+ let le = async (e) => {
904
1081
  if (e?.length && n.onUpload) {
905
- S(!0);
1082
+ b(!0);
906
1083
  for (let t of Array.from(e)) {
907
1084
  if (n.upload && t.size > n.upload.maxBytes) {
908
1085
  i({
@@ -913,15 +1090,15 @@ function le(n) {
913
1090
  continue;
914
1091
  }
915
1092
  let e = await n.onUpload(t).catch(() => null);
916
- e && y((t) => [...t, e]);
1093
+ e && m((t) => [...t, e]);
917
1094
  }
918
- S(!1), z.current && (z.current.value = "");
1095
+ b(!1), L.current && (L.current.value = "");
919
1096
  }
920
1097
  };
921
- async function ve() {
922
- let e = await H.stop();
923
- e && n.onTranscribe && await oe(e, n.onTranscribe, {
924
- busy: ee,
1098
+ async function Q() {
1099
+ let e = await B.stop();
1100
+ e && n.onTranscribe && await me(e, n.onTranscribe, {
1101
+ busy: j,
925
1102
  empty: () => i({
926
1103
  kind: "error",
927
1104
  title: r("chat.voice.notRecognized")
@@ -936,73 +1113,74 @@ function le(n) {
936
1113
  }]
937
1114
  }),
938
1115
  text: (e) => {
939
- L.current = !0, u((t) => t.trim() ? t.trimEnd() + " " + e : e), B.current?.focus();
1116
+ F.current = !0, s((t) => t.trim() ? t.trimEnd() + " " + e : e), R.current?.focus();
940
1117
  }
941
1118
  });
942
1119
  }
943
- let ye = (e) => {
944
- e.key === "Escape" && H.recording && (e.preventDefault(), H.cancel());
945
- }, be = C ? r("chat.skillPlaceholder") : n.placeholder ?? r("chat.placeholder", { name: n.agentName }), xe = V - H.seconds;
946
- return /* @__PURE__ */ l("section", {
1120
+ let de = (e) => {
1121
+ 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;
1123
+ return /* @__PURE__ */ u("section", {
947
1124
  className: "nb-chat",
948
1125
  "aria-label": r("chat.title"),
949
1126
  children: [
950
1127
  n.header,
951
- /* @__PURE__ */ l("div", {
1128
+ /* @__PURE__ */ u("div", {
952
1129
  className: "msgs",
953
- ref: R,
1130
+ ref: I,
954
1131
  "aria-live": "polite",
955
1132
  children: [
956
- n.hasOlder && n.onLoadOlder && /* @__PURE__ */ c("button", {
1133
+ n.hasOlder && n.onLoadOlder && /* @__PURE__ */ l("button", {
957
1134
  className: "btn ghost sm",
958
1135
  style: { alignSelf: "center" },
959
1136
  disabled: n.loadingOlder,
960
1137
  onClick: n.onLoadOlder,
961
1138
  children: r("chat.loadOlder")
962
1139
  }),
963
- n.historyError && /* @__PURE__ */ c("div", {
1140
+ n.historyError && /* @__PURE__ */ l("div", {
964
1141
  className: "err-text",
965
1142
  children: n.historyError
966
1143
  }),
967
- U.length === 0 && !n.loading && !n.historyError && (n.empty ?? /* @__PURE__ */ l("div", {
1144
+ V.length === 0 && !n.loading && !n.historyError && (n.empty ?? /* @__PURE__ */ u("div", {
968
1145
  className: "empty",
969
1146
  children: [
970
- /* @__PURE__ */ c("div", {
1147
+ /* @__PURE__ */ l("div", {
971
1148
  className: "ic",
972
- children: /* @__PURE__ */ c(t, { name: "spark" })
1149
+ children: /* @__PURE__ */ l(t, { name: "spark" })
973
1150
  }),
974
- /* @__PURE__ */ c("b", { children: r("chat.emptyTitle", { name: n.agentName }) }),
1151
+ /* @__PURE__ */ l("b", { children: r("chat.emptyTitle", { name: n.agentName }) }),
975
1152
  n.emptyHint
976
1153
  ]
977
1154
  })),
978
- U.map((e) => /* @__PURE__ */ c(ie, {
1155
+ V.map((e) => /* @__PURE__ */ l(ue, {
979
1156
  m: e,
980
- busy: W,
1157
+ busy: H,
981
1158
  onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
982
- loadAttachment: I,
983
- onOpenAttachment: N
1159
+ loadAttachment: N,
1160
+ loadPreview: P,
1161
+ onOpenAttachment: M
984
1162
  }, e.id)),
985
- n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ l("div", {
1163
+ n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ u("div", {
986
1164
  className: "confirm",
987
1165
  role: "group",
988
1166
  "aria-label": r("chat.confirm.title"),
989
1167
  children: [
990
- /* @__PURE__ */ l("div", {
1168
+ /* @__PURE__ */ u("div", {
991
1169
  className: "h",
992
- children: [/* @__PURE__ */ c(t, {
1170
+ children: [/* @__PURE__ */ l(t, {
993
1171
  name: "alert",
994
1172
  size: 16
995
1173
  }), r("chat.confirm.title")]
996
1174
  }),
997
- /* @__PURE__ */ c("div", { children: r("chat.confirm.text", { action: e.summary }) }),
998
- e.preview !== void 0 && /* @__PURE__ */ c("pre", { children: e.preview }),
999
- /* @__PURE__ */ l("div", {
1175
+ /* @__PURE__ */ l("div", { children: r("chat.confirm.text", { action: e.summary }) }),
1176
+ e.preview !== void 0 && /* @__PURE__ */ l("pre", { children: e.preview }),
1177
+ /* @__PURE__ */ u("div", {
1000
1178
  className: "acts",
1001
- children: [/* @__PURE__ */ c("button", {
1179
+ children: [/* @__PURE__ */ l("button", {
1002
1180
  className: "btn sm primary",
1003
1181
  onClick: () => n.onConfirm?.(e.id, !0),
1004
1182
  children: r("chat.confirm.approve")
1005
- }), /* @__PURE__ */ c("button", {
1183
+ }), /* @__PURE__ */ l("button", {
1006
1184
  className: "btn sm",
1007
1185
  onClick: () => n.onConfirm?.(e.id, !1),
1008
1186
  children: r("chat.confirm.reject")
@@ -1012,42 +1190,42 @@ function le(n) {
1012
1190
  }, e.id))
1013
1191
  ]
1014
1192
  }),
1015
- n.readOnly ? /* @__PURE__ */ c("div", {
1193
+ n.readOnly ? /* @__PURE__ */ l("div", {
1016
1194
  className: "composer",
1017
1195
  style: {
1018
1196
  justifyContent: "space-between",
1019
1197
  alignItems: "center"
1020
1198
  },
1021
1199
  children: n.readOnly
1022
- }) : /* @__PURE__ */ l("div", {
1200
+ }) : /* @__PURE__ */ u("div", {
1023
1201
  className: "composer-wrap",
1024
1202
  children: [
1025
- X && /* @__PURE__ */ c(v, {
1203
+ X && /* @__PURE__ */ l(y, {
1026
1204
  items: Y,
1027
- active: Math.min(T, Math.max(Y.length - 1, 0)),
1028
- onPick: $,
1029
- onHover: E
1205
+ active: Math.min(w, Math.max(Y.length - 1, 0)),
1206
+ onPick: se,
1207
+ onHover: T
1030
1208
  }),
1031
1209
  n.aboveComposer,
1032
- g.length > 0 && /* @__PURE__ */ c("div", {
1210
+ d.length > 0 && /* @__PURE__ */ l("div", {
1033
1211
  className: "pending-files",
1034
- children: g.map((e) => /* @__PURE__ */ l("span", {
1212
+ children: d.map((e) => /* @__PURE__ */ u("span", {
1035
1213
  className: "chip",
1036
1214
  children: [
1037
- /* @__PURE__ */ c(t, {
1215
+ /* @__PURE__ */ l(t, {
1038
1216
  name: "clip",
1039
1217
  size: 12
1040
1218
  }),
1041
1219
  e.fileName,
1042
- /* @__PURE__ */ c("button", {
1220
+ /* @__PURE__ */ l("button", {
1043
1221
  className: "iconbtn",
1044
1222
  style: {
1045
1223
  width: 18,
1046
1224
  height: 18
1047
1225
  },
1048
1226
  "aria-label": r("remove"),
1049
- onClick: () => y((t) => t.filter((t) => t.id !== e.id)),
1050
- children: /* @__PURE__ */ c(t, {
1227
+ onClick: () => m((t) => t.filter((t) => t.id !== e.id)),
1228
+ children: /* @__PURE__ */ l(t, {
1051
1229
  name: "x",
1052
1230
  size: 12
1053
1231
  })
@@ -1055,279 +1233,288 @@ function le(n) {
1055
1233
  ]
1056
1234
  }, e.id))
1057
1235
  }),
1058
- k && /* @__PURE__ */ l("div", {
1236
+ O && /* @__PURE__ */ u("div", {
1059
1237
  className: "cmd-unknown",
1060
1238
  role: "status",
1061
- children: [r("chat.unknownCommand", { name: k }), /* @__PURE__ */ c("button", {
1239
+ children: [r("chat.unknownCommand", { name: O }), /* @__PURE__ */ l("button", {
1062
1240
  type: "button",
1063
1241
  className: "textbtn",
1064
- onClick: () => void Q(o, !0),
1242
+ onClick: () => void Z(a, !0),
1065
1243
  children: r("chat.sendAsText")
1066
1244
  })]
1067
1245
  }),
1068
- /* @__PURE__ */ l("div", {
1246
+ /* @__PURE__ */ u("div", {
1069
1247
  className: "composer",
1070
1248
  children: [
1071
- n.onUpload && !H.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
1249
+ n.onUpload && !B.recording && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
1072
1250
  className: "iconbtn",
1073
1251
  "aria-label": r("chat.attach"),
1074
- disabled: b,
1075
- onClick: () => z.current?.click(),
1076
- children: /* @__PURE__ */ c(t, { name: "clip" })
1077
- }), /* @__PURE__ */ c("input", {
1078
- ref: z,
1252
+ disabled: _,
1253
+ onClick: () => L.current?.click(),
1254
+ children: /* @__PURE__ */ l(t, { name: "clip" })
1255
+ }), /* @__PURE__ */ l("input", {
1256
+ ref: L,
1079
1257
  type: "file",
1080
1258
  multiple: !0,
1081
1259
  hidden: !0,
1082
1260
  accept: n.upload?.accept,
1083
- onChange: (e) => _e(e.target.files)
1261
+ onChange: (e) => le(e.target.files)
1084
1262
  })] }),
1085
- H.recording ? /* @__PURE__ */ l("div", {
1086
- className: `recbar${xe <= 15 ? " ending" : ""}`,
1263
+ B.recording ? /* @__PURE__ */ u("div", {
1264
+ className: `recbar${pe <= 15 ? " ending" : ""}`,
1087
1265
  role: "status",
1088
1266
  "aria-label": r("chat.voice.recordingNow"),
1089
1267
  children: [
1090
- /* @__PURE__ */ c("span", {
1268
+ /* @__PURE__ */ l("span", {
1091
1269
  className: "dot",
1092
1270
  "aria-hidden": "true"
1093
1271
  }),
1094
- /* @__PURE__ */ l("span", {
1272
+ /* @__PURE__ */ u("span", {
1095
1273
  className: "tm",
1096
1274
  children: [
1097
- ce(H.seconds),
1275
+ ge(B.seconds),
1098
1276
  " / ",
1099
- ce(V)
1277
+ ge(z)
1100
1278
  ]
1101
1279
  }),
1102
- /* @__PURE__ */ c("span", {
1280
+ /* @__PURE__ */ l("span", {
1103
1281
  className: "lvl",
1104
1282
  "aria-hidden": "true",
1105
- children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, H.level)})` } })
1283
+ children: /* @__PURE__ */ l("i", { style: { transform: `scaleX(${Math.max(.04, B.level)})` } })
1106
1284
  }),
1107
- /* @__PURE__ */ c("button", {
1285
+ /* @__PURE__ */ l("button", {
1108
1286
  type: "button",
1109
1287
  className: "btn ghost sm",
1110
- onClick: H.cancel,
1288
+ onClick: B.cancel,
1111
1289
  children: r("cancel")
1112
1290
  }),
1113
- /* @__PURE__ */ c("button", {
1291
+ /* @__PURE__ */ l("button", {
1114
1292
  type: "button",
1115
1293
  className: "btn primary sm",
1116
- onKeyDown: ye,
1117
- onClick: () => void ve(),
1294
+ onKeyDown: de,
1295
+ onClick: () => void Q(),
1118
1296
  children: r("chat.voice.done")
1119
1297
  })
1120
1298
  ]
1121
- }) : /* @__PURE__ */ l("div", {
1122
- className: `field${C ? " with-skill" : ""}${j ? " recognizing" : ""}`,
1123
- "aria-busy": j || void 0,
1124
- children: [C && /* @__PURE__ */ l("span", {
1299
+ }) : /* @__PURE__ */ u("div", {
1300
+ className: `field${x ? " with-skill" : ""}${A ? " recognizing" : ""}`,
1301
+ "aria-busy": A || void 0,
1302
+ children: [x && /* @__PURE__ */ u("span", {
1125
1303
  className: "chip skill-chip",
1126
1304
  children: [
1127
- /* @__PURE__ */ c(t, {
1305
+ /* @__PURE__ */ l(t, {
1128
1306
  name: "spark",
1129
1307
  size: 12
1130
1308
  }),
1131
- C,
1132
- /* @__PURE__ */ c("button", {
1309
+ x,
1310
+ /* @__PURE__ */ l("button", {
1133
1311
  className: "iconbtn",
1134
1312
  style: {
1135
1313
  width: 18,
1136
1314
  height: 18
1137
1315
  },
1138
1316
  "aria-label": r("remove"),
1139
- onClick: () => w(null),
1140
- children: /* @__PURE__ */ c(t, {
1317
+ onClick: () => C(null),
1318
+ children: /* @__PURE__ */ l(t, {
1141
1319
  name: "x",
1142
1320
  size: 12
1143
1321
  })
1144
1322
  })
1145
1323
  ]
1146
- }), /* @__PURE__ */ c("textarea", {
1147
- ref: B,
1324
+ }), /* @__PURE__ */ l("textarea", {
1325
+ ref: R,
1148
1326
  rows: 1,
1149
- value: o,
1150
- placeholder: j ? r("chat.voice.recognizing") : be,
1151
- "aria-label": be,
1152
- disabled: j,
1327
+ value: a,
1328
+ placeholder: A ? r("chat.voice.recognizing") : fe,
1329
+ "aria-label": fe,
1330
+ disabled: A,
1153
1331
  "aria-expanded": X,
1154
1332
  "aria-autocomplete": n.commands ? "list" : void 0,
1155
1333
  onChange: (e) => {
1156
- u(e.target.value), O(!1), E(0), A(null);
1334
+ s(e.target.value), D(!1), T(0), k(null);
1157
1335
  },
1158
- onKeyDown: ge
1336
+ onKeyDown: ce
1159
1337
  })]
1160
1338
  }),
1161
- n.context && !H.recording && /* @__PURE__ */ c(x, {
1339
+ n.context && !B.recording && /* @__PURE__ */ l(S, {
1162
1340
  context: n.context,
1163
1341
  onCompact: n.onCompact,
1164
1342
  onReset: n.onReset,
1165
- busy: ne
1343
+ busy: te
1166
1344
  }),
1167
- n.onTranscribe && !H.recording && /* @__PURE__ */ c(ue, {
1168
- supported: H.supported,
1169
- recognizing: j,
1170
- onStart: () => void H.start()
1345
+ n.onTranscribe && !B.recording && /* @__PURE__ */ l(ve, {
1346
+ supported: B.supported,
1347
+ recognizing: A,
1348
+ onStart: () => void B.start()
1171
1349
  }),
1172
- !H.recording && (n.onCancel && W ? /* @__PURE__ */ c("button", {
1350
+ !B.recording && (n.onCancel && H ? /* @__PURE__ */ l("button", {
1173
1351
  className: "iconbtn fill",
1174
1352
  "aria-label": r("chat.stop"),
1175
1353
  onClick: n.onCancel,
1176
- children: /* @__PURE__ */ c(t, { name: "stop" })
1177
- }) : /* @__PURE__ */ c("button", {
1354
+ children: /* @__PURE__ */ l(t, { name: "stop" })
1355
+ }) : /* @__PURE__ */ l("button", {
1178
1356
  className: "iconbtn fill",
1179
1357
  "aria-label": r("chat.send"),
1180
- disabled: !o.trim() && g.length === 0 && !C || W || j,
1181
- onClick: () => Q(o),
1182
- children: /* @__PURE__ */ c(t, { name: "send" })
1358
+ disabled: !a.trim() && d.length === 0 && !x || H || A,
1359
+ onClick: () => Z(a),
1360
+ children: /* @__PURE__ */ l(t, { name: "send" })
1183
1361
  }))
1184
1362
  ]
1185
1363
  }),
1186
- H.error && /* @__PURE__ */ c("div", {
1364
+ B.error && /* @__PURE__ */ l("div", {
1187
1365
  className: "err-text",
1188
1366
  style: { padding: "0 12px 8px" },
1189
1367
  children: r("chat.voice.micDenied")
1190
1368
  })
1191
1369
  ]
1192
1370
  }),
1193
- M && I && /* @__PURE__ */ c(te, {
1194
- a: M,
1195
- load: I,
1196
- onClose: () => N(null)
1371
+ ee && N && /* @__PURE__ */ l(ne, {
1372
+ a: ee,
1373
+ load: N,
1374
+ loadPreview: P,
1375
+ onClose: () => M(null)
1197
1376
  })
1198
1377
  ]
1199
1378
  });
1200
1379
  }
1201
- function ue({ supported: e, recognizing: n, onStart: r }) {
1202
- let i = a();
1203
- return n ? /* @__PURE__ */ l("span", {
1380
+ function ve({ supported: e, recognizing: n, onStart: r }) {
1381
+ let i = o();
1382
+ return n ? /* @__PURE__ */ u("span", {
1204
1383
  className: "voicewait",
1205
1384
  role: "status",
1206
1385
  "aria-label": i("chat.voice.recognizing"),
1207
1386
  title: i("chat.voice.recognizing"),
1208
1387
  children: [
1209
- /* @__PURE__ */ c("i", {}),
1210
- /* @__PURE__ */ c("i", {}),
1211
- /* @__PURE__ */ c("i", {}),
1212
- /* @__PURE__ */ c("i", {}),
1213
- /* @__PURE__ */ c("i", {})
1388
+ /* @__PURE__ */ l("i", {}),
1389
+ /* @__PURE__ */ l("i", {}),
1390
+ /* @__PURE__ */ l("i", {}),
1391
+ /* @__PURE__ */ l("i", {}),
1392
+ /* @__PURE__ */ l("i", {})
1214
1393
  ]
1215
- }) : /* @__PURE__ */ c("button", {
1394
+ }) : /* @__PURE__ */ l("button", {
1216
1395
  className: "iconbtn",
1217
1396
  disabled: !e,
1218
1397
  "aria-label": i("chat.voice.start"),
1219
1398
  title: i(e ? "chat.voice.start" : "chat.voice.unsupported"),
1220
1399
  onClick: r,
1221
- children: /* @__PURE__ */ c(t, { name: "mic" })
1400
+ children: /* @__PURE__ */ l(t, { name: "mic" })
1222
1401
  });
1223
1402
  }
1224
- function de() {
1403
+ function ye() {
1225
1404
  return typeof window < "u" && !!window.matchMedia?.("(hover: none) and (pointer: coarse)").matches;
1226
1405
  }
1227
- var fe = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
1228
- function pe(e, t) {
1229
- let n = !!e && fe(e);
1406
+ var be = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
1407
+ function xe(e, t) {
1408
+ let n = !!e && be(e);
1230
1409
  t(), e && n && (e.scrollTop = e.scrollHeight);
1231
1410
  }
1232
- function me(e) {
1411
+ function Se(e) {
1233
1412
  if (!e) return;
1234
1413
  e.style.overflowY = "hidden", e.style.height = "auto";
1235
1414
  let t = e.scrollHeight + e.offsetHeight - e.clientHeight;
1236
1415
  e.style.height = `${t}px`, e.style.overflowY = e.offsetHeight < t ? "auto" : "hidden";
1237
1416
  }
1417
+ function Ce(e) {
1418
+ let t = h(e);
1419
+ f(() => {
1420
+ t.current = e;
1421
+ });
1422
+ let n = !!e;
1423
+ return m(() => n ? (e) => t.current ? t.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [n]);
1424
+ }
1238
1425
  //#endregion
1239
1426
  //#region src/chat/ConversationList.tsx
1240
- function J({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
1241
- let f = a(), [p, m] = h(!1);
1242
- d(() => {
1427
+ function we({ conversations: e, currentId: n, open: r, onPick: i, onClose: a, onCreate: s }) {
1428
+ let d = o(), [p, m] = g(!1);
1429
+ f(() => {
1243
1430
  if (!r) return;
1244
- let e = (e) => e.key === "Escape" && o();
1431
+ let e = (e) => e.key === "Escape" && a();
1245
1432
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
1246
- }, [r, o]);
1247
- let g = (e) => /* @__PURE__ */ l("button", {
1433
+ }, [r, a]);
1434
+ let h = (e) => /* @__PURE__ */ u("button", {
1248
1435
  className: `it${e.id === n ? " on" : ""}${e.group === "archive" ? " arch" : ""}`,
1249
1436
  onClick: () => i(e.id),
1250
1437
  "aria-current": e.id === n,
1251
1438
  children: [
1252
- /* @__PURE__ */ c(t, {
1439
+ /* @__PURE__ */ l(t, {
1253
1440
  name: e.icon ?? "msg2",
1254
1441
  size: 16
1255
1442
  }),
1256
- /* @__PURE__ */ c("span", {
1443
+ /* @__PURE__ */ l("span", {
1257
1444
  className: "nm",
1258
1445
  children: e.title
1259
1446
  }),
1260
- !!e.unread && /* @__PURE__ */ c("span", {
1447
+ !!e.unread && /* @__PURE__ */ l("span", {
1261
1448
  className: "unread",
1262
- "aria-label": f("chat.unread", { count: e.unread }),
1449
+ "aria-label": d("chat.unread", { count: e.unread }),
1263
1450
  children: e.unread
1264
1451
  }),
1265
- /* @__PURE__ */ c("span", {
1452
+ /* @__PURE__ */ l("span", {
1266
1453
  className: "sub",
1267
1454
  children: e.when
1268
1455
  })
1269
1456
  ]
1270
1457
  }, e.id), _ = (t) => e.filter((e) => e.group === t), v = _("topic"), y = _("archive");
1271
- return /* @__PURE__ */ l(s, { children: [
1272
- /* @__PURE__ */ l("nav", {
1458
+ return /* @__PURE__ */ u(c, { children: [
1459
+ /* @__PURE__ */ u("nav", {
1273
1460
  className: `nb-side${r ? " open" : ""}`,
1274
- "aria-label": f("chat.conversations"),
1461
+ "aria-label": d("chat.conversations"),
1275
1462
  children: [
1276
- u && /* @__PURE__ */ l("button", {
1463
+ s && /* @__PURE__ */ u("button", {
1277
1464
  className: "btn sm",
1278
1465
  style: {
1279
1466
  width: "100%",
1280
1467
  justifyContent: "center"
1281
1468
  },
1282
1469
  onClick: () => m(!0),
1283
- children: [/* @__PURE__ */ c(t, {
1470
+ children: [/* @__PURE__ */ l(t, {
1284
1471
  name: "plus",
1285
1472
  size: 15
1286
- }), f("chat.newTopic")]
1473
+ }), d("chat.newTopic")]
1287
1474
  }),
1288
- /* @__PURE__ */ c("div", {
1475
+ /* @__PURE__ */ l("div", {
1289
1476
  className: "h",
1290
- children: f("chat.conversation")
1477
+ children: d("chat.conversation")
1291
1478
  }),
1292
- _("main").map(g),
1293
- /* @__PURE__ */ c("div", {
1479
+ _("main").map(h),
1480
+ /* @__PURE__ */ l("div", {
1294
1481
  className: "h",
1295
- children: f("chat.topics")
1482
+ children: d("chat.topics")
1296
1483
  }),
1297
- v.length === 0 && /* @__PURE__ */ c("div", {
1484
+ v.length === 0 && /* @__PURE__ */ l("div", {
1298
1485
  className: "small muted",
1299
1486
  style: { padding: "0 10px" },
1300
- children: f("chat.noTopics")
1487
+ children: d("chat.noTopics")
1301
1488
  }),
1302
- v.map(g),
1303
- y.length > 0 && /* @__PURE__ */ c("div", {
1489
+ v.map(h),
1490
+ y.length > 0 && /* @__PURE__ */ l("div", {
1304
1491
  className: "h",
1305
- children: f("chat.archive")
1492
+ children: d("chat.archive")
1306
1493
  }),
1307
- y.map(g)
1494
+ y.map(h)
1308
1495
  ]
1309
1496
  }),
1310
- r && /* @__PURE__ */ c("button", {
1497
+ r && /* @__PURE__ */ l("button", {
1311
1498
  type: "button",
1312
1499
  className: "nb-scrim",
1313
- "aria-label": f("close"),
1314
- onClick: o
1500
+ "aria-label": d("close"),
1501
+ onClick: a
1315
1502
  }),
1316
- p && u && /* @__PURE__ */ c(X, {
1503
+ p && s && /* @__PURE__ */ l(Ee, {
1317
1504
  onClose: () => m(!1),
1318
- onCreate: u
1505
+ onCreate: s
1319
1506
  })
1320
1507
  ] });
1321
1508
  }
1322
- function Y({ narrow: e, children: t }) {
1323
- return /* @__PURE__ */ c("div", {
1509
+ function Te({ narrow: e, children: t }) {
1510
+ return /* @__PURE__ */ l("div", {
1324
1511
  className: `nb-app${e ? " narrow" : ""}`,
1325
1512
  children: t
1326
1513
  });
1327
1514
  }
1328
- function X({ onClose: e, onCreate: t }) {
1329
- let r = a(), [i, o] = h(""), [u, d] = h(!1), [f, p] = h(null), m = async () => {
1330
- if (i.trim() && !u) {
1515
+ function Ee({ onClose: e, onCreate: t }) {
1516
+ let r = o(), [i, a] = g(""), [s, d] = g(!1), [f, p] = g(null), m = async () => {
1517
+ if (i.trim() && !s) {
1331
1518
  d(!0), p(null);
1332
1519
  try {
1333
1520
  await t(i.trim()), e();
@@ -1336,40 +1523,40 @@ function X({ onClose: e, onCreate: t }) {
1336
1523
  }
1337
1524
  }
1338
1525
  };
1339
- return /* @__PURE__ */ l(n, {
1526
+ return /* @__PURE__ */ u(n, {
1340
1527
  title: r("chat.newTopic"),
1341
1528
  onClose: e,
1342
- footer: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
1529
+ footer: /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
1343
1530
  className: "btn ghost",
1344
1531
  onClick: e,
1345
1532
  children: r("cancel")
1346
- }), /* @__PURE__ */ c("button", {
1533
+ }), /* @__PURE__ */ l("button", {
1347
1534
  className: "btn primary",
1348
- disabled: !i.trim() || u,
1535
+ disabled: !i.trim() || s,
1349
1536
  onClick: m,
1350
1537
  children: r("create")
1351
1538
  })] }),
1352
- children: [/* @__PURE__ */ l("div", {
1539
+ children: [/* @__PURE__ */ u("div", {
1353
1540
  className: "field",
1354
1541
  children: [
1355
- /* @__PURE__ */ c("label", {
1542
+ /* @__PURE__ */ l("label", {
1356
1543
  htmlFor: "topic-title",
1357
1544
  children: r("chat.topicTitle")
1358
1545
  }),
1359
- /* @__PURE__ */ c("input", {
1546
+ /* @__PURE__ */ l("input", {
1360
1547
  id: "topic-title",
1361
1548
  className: "inp",
1362
1549
  value: i,
1363
1550
  maxLength: 120,
1364
- onChange: (e) => o(e.target.value),
1551
+ onChange: (e) => a(e.target.value),
1365
1552
  onKeyDown: (e) => e.key === "Enter" && m()
1366
1553
  }),
1367
- /* @__PURE__ */ c("div", {
1554
+ /* @__PURE__ */ l("div", {
1368
1555
  className: "hint",
1369
1556
  children: r("chat.topicHint")
1370
1557
  })
1371
1558
  ]
1372
- }), f && /* @__PURE__ */ c("div", {
1559
+ }), f && /* @__PURE__ */ l("div", {
1373
1560
  className: "err-text",
1374
1561
  children: f
1375
1562
  })]
@@ -1377,8 +1564,8 @@ function X({ onClose: e, onCreate: t }) {
1377
1564
  }
1378
1565
  //#endregion
1379
1566
  //#region src/chat/AgentMenu.tsx
1380
- function he({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1381
- return /* @__PURE__ */ c("button", {
1567
+ function De({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1568
+ return /* @__PURE__ */ l("button", {
1382
1569
  type: "button",
1383
1570
  className: `agentbtn${a ? " s" : ""}`,
1384
1571
  disabled: o,
@@ -1387,25 +1574,25 @@ function he({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, o
1387
1574
  title: r,
1388
1575
  onMouseDown: (e) => i && e.stopPropagation(),
1389
1576
  onClick: s,
1390
- children: /* @__PURE__ */ c(t, {
1577
+ children: /* @__PURE__ */ l(t, {
1391
1578
  name: e,
1392
1579
  size: a ? 15 : 18
1393
1580
  })
1394
1581
  });
1395
1582
  }
1396
- function Z({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: m, onPick: g, onClose: _ }) {
1397
- let v = a(), [y, b] = h(n), x = i(!0, _);
1398
- return /* @__PURE__ */ l("div", {
1583
+ function Oe({ label: e, name: n, options: r, value: a, optionsLabel: s, hint: d, narrow: f, models: p, onRename: m, onPick: h, onClose: _ }) {
1584
+ let v = o(), [y, b] = g(n), x = i(!0, _);
1585
+ return /* @__PURE__ */ u("div", {
1399
1586
  className: `agentmenu${f ? " narrow" : ""}`,
1400
1587
  ref: x,
1401
1588
  role: "dialog",
1402
1589
  "aria-label": e,
1403
1590
  children: [
1404
- /* @__PURE__ */ c("div", {
1591
+ /* @__PURE__ */ l("div", {
1405
1592
  className: "lab",
1406
1593
  children: v("agentName")
1407
1594
  }),
1408
- /* @__PURE__ */ c("input", {
1595
+ /* @__PURE__ */ l("input", {
1409
1596
  className: "inp",
1410
1597
  value: y,
1411
1598
  maxLength: 40,
@@ -1418,74 +1605,74 @@ function Z({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
1418
1605
  },
1419
1606
  onKeyDown: (e) => e.key === "Enter" && e.target.blur()
1420
1607
  }),
1421
- /* @__PURE__ */ c("div", {
1608
+ /* @__PURE__ */ l("div", {
1422
1609
  className: "lab",
1423
1610
  style: { marginTop: 14 },
1424
- children: u
1611
+ children: s
1425
1612
  }),
1426
- /* @__PURE__ */ c("div", {
1613
+ /* @__PURE__ */ l("div", {
1427
1614
  className: "agentoptions",
1428
- children: r.map((e) => /* @__PURE__ */ l("button", {
1615
+ children: r.map((e) => /* @__PURE__ */ u("button", {
1429
1616
  type: "button",
1430
- className: `agentoption${o === e.key ? " on" : ""}`,
1431
- "aria-pressed": o === e.key,
1432
- onClick: () => g(e.key),
1433
- children: [/* @__PURE__ */ c("span", {
1617
+ className: `agentoption${a === e.key ? " on" : ""}`,
1618
+ "aria-pressed": a === e.key,
1619
+ onClick: () => h(e.key),
1620
+ children: [/* @__PURE__ */ l("span", {
1434
1621
  className: "ic",
1435
- children: /* @__PURE__ */ c(t, {
1622
+ children: /* @__PURE__ */ l(t, {
1436
1623
  name: e.icon,
1437
1624
  size: 15
1438
1625
  })
1439
1626
  }), e.label]
1440
1627
  }, e.key))
1441
1628
  }),
1442
- p && /* @__PURE__ */ l(s, { children: [
1443
- /* @__PURE__ */ c("div", {
1629
+ p && /* @__PURE__ */ u(c, { children: [
1630
+ /* @__PURE__ */ l("div", {
1444
1631
  className: "lab",
1445
1632
  style: { marginTop: 14 },
1446
1633
  children: p.label
1447
1634
  }),
1448
- p.options.length === 0 && /* @__PURE__ */ c("div", {
1635
+ p.options.length === 0 && /* @__PURE__ */ l("div", {
1449
1636
  className: "hint",
1450
1637
  children: p.empty
1451
1638
  }),
1452
- /* @__PURE__ */ c("div", {
1639
+ /* @__PURE__ */ l("div", {
1453
1640
  className: "agentmodels",
1454
1641
  role: "radiogroup",
1455
1642
  children: p.options.map((e) => {
1456
1643
  let n = p.options.length === 1, r = n || p.value === e.key;
1457
- return /* @__PURE__ */ l("button", {
1644
+ return /* @__PURE__ */ u("button", {
1458
1645
  type: "button",
1459
1646
  role: "radio",
1460
1647
  "aria-checked": r,
1461
1648
  disabled: n,
1462
1649
  className: `agentmodel${r ? " on" : ""}`,
1463
1650
  onClick: () => !r && p.onPick(e.key),
1464
- children: [!n && /* @__PURE__ */ c("span", {
1651
+ children: [!n && /* @__PURE__ */ l("span", {
1465
1652
  className: `radio${r ? " on" : ""}`,
1466
1653
  "aria-hidden": "true"
1467
- }), /* @__PURE__ */ l("span", {
1654
+ }), /* @__PURE__ */ u("span", {
1468
1655
  className: "body",
1469
1656
  children: [
1470
- /* @__PURE__ */ c("span", {
1657
+ /* @__PURE__ */ l("span", {
1471
1658
  className: "nm",
1472
1659
  children: e.label
1473
1660
  }),
1474
- e.sub && /* @__PURE__ */ c("span", {
1661
+ e.sub && /* @__PURE__ */ l("span", {
1475
1662
  className: "sub",
1476
1663
  children: e.sub
1477
1664
  }),
1478
- e.badges && e.badges.length > 0 && /* @__PURE__ */ c("span", {
1665
+ e.badges && e.badges.length > 0 && /* @__PURE__ */ l("span", {
1479
1666
  className: "badges",
1480
- children: e.badges.map((e) => /* @__PURE__ */ l("span", {
1667
+ children: e.badges.map((e) => /* @__PURE__ */ u("span", {
1481
1668
  className: "cap",
1482
- children: [e.icon && /* @__PURE__ */ c(t, {
1669
+ children: [e.icon && /* @__PURE__ */ l(t, {
1483
1670
  name: e.icon,
1484
1671
  size: 11
1485
1672
  }), e.text]
1486
1673
  }, e.text))
1487
1674
  }),
1488
- r && e.warn && /* @__PURE__ */ c("span", {
1675
+ r && e.warn && /* @__PURE__ */ l("span", {
1489
1676
  className: "warn",
1490
1677
  children: e.warn
1491
1678
  })
@@ -1495,7 +1682,7 @@ function Z({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
1495
1682
  })
1496
1683
  })
1497
1684
  ] }),
1498
- d && /* @__PURE__ */ c("div", {
1685
+ d && /* @__PURE__ */ l("div", {
1499
1686
  className: "hint",
1500
1687
  style: { marginTop: 10 },
1501
1688
  children: d
@@ -1505,8 +1692,8 @@ function Z({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
1505
1692
  }
1506
1693
  //#endregion
1507
1694
  //#region src/chat/AgentSettingsMenu.tsx
1508
- var Q = (e) => `${e.connectionId}/${e.model}`;
1509
- function $(e, t, n) {
1695
+ var $ = (e) => `${e.connectionId}/${e.model}`;
1696
+ function ke(e, t, n) {
1510
1697
  let r = (n) => [
1511
1698
  ...n.caps.image ? [{
1512
1699
  icon: "image",
@@ -1516,9 +1703,9 @@ function $(e, t, n) {
1516
1703
  icon: "brain",
1517
1704
  text: e("agent.capReasoning")
1518
1705
  }] : [],
1519
- ...n.caps.contextWindow > 0 ? [{ text: b(n.caps.contextWindow, t) }] : []
1706
+ ...n.caps.contextWindow > 0 ? [{ text: x(n.caps.contextWindow, t) }] : []
1520
1707
  ], i = (t) => t.caps.contextWindow > 0 && n.contextTokens > .8 * t.caps.contextWindow ? e("agent.modelCompactWarn") : void 0, a = n.available.length > 1, o = n.available.map((e) => ({
1521
- key: Q(e),
1708
+ key: $(e),
1522
1709
  label: e.name,
1523
1710
  sub: e.connection,
1524
1711
  badges: r(e),
@@ -1531,12 +1718,12 @@ function $(e, t, n) {
1531
1718
  sub: n.defaultModel?.name ?? "—",
1532
1719
  warn: n.defaultModel ? i(n.defaultModel) : void 0
1533
1720
  }, ...o] : o,
1534
- value: n.chosen && n.model ? Q(n.model) : a ? "" : n.model ? Q(n.model) : ""
1721
+ value: n.chosen && n.model ? $(n.model) : a ? "" : n.model ? $(n.model) : ""
1535
1722
  };
1536
1723
  }
1537
- function ge({ name: e, value: t, options: n, models: r, hint: i, onRename: o, onPick: s, onModel: l, onClose: u }) {
1538
- let d = a(), { i18n: f } = g(), p = r && l ? $(d, f.language, r) : null;
1539
- return /* @__PURE__ */ c(Z, {
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, {
1540
1727
  label: d("agent.menu"),
1541
1728
  name: e,
1542
1729
  value: t,
@@ -1548,22 +1735,22 @@ function ge({ name: e, value: t, options: n, models: r, hint: i, onRename: o, on
1548
1735
  options: p.options,
1549
1736
  value: p.value,
1550
1737
  onPick: (e) => {
1551
- if (!r || !l) return;
1552
- if (!e) return l(null);
1553
- let t = r.available.find((t) => Q(t) === e);
1554
- t && l({
1738
+ if (!r || !c) return;
1739
+ if (!e) return c(null);
1740
+ let t = r.available.find((t) => $(t) === e);
1741
+ t && c({
1555
1742
  connectionId: t.connectionId,
1556
1743
  model: t.model
1557
1744
  });
1558
1745
  },
1559
1746
  empty: d("agent.noModels")
1560
1747
  } : void 0,
1561
- onRename: o,
1748
+ onRename: a,
1562
1749
  onPick: s,
1563
1750
  onClose: u
1564
1751
  });
1565
1752
  }
1566
1753
  //#endregion
1567
- export { he as AgentButton, Z as AgentMenu, ge as AgentSettingsMenu, V as AttachmentList, te as AttachmentPreview, le as Chat, Y as ChatLayout, v as CommandPalette, x as ContextMeter, J as ConversationList, ie as MessageView, K as NOTICE_LINES, X as NewTopicModal, ue as VoiceButton, Q as agentModelKey, $ as agentModelOptions, A as fileSize, L as parseTable, O as previewIcon, E as previewKind, b as tokens, se as useRecorder };
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 };
1568
1755
 
1569
1756
  //# sourceMappingURL=chat.js.map