@green-on-grey/ui-kit 1.2.0 → 1.3.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,14 +1,14 @@
1
- import { c as e, d as t, i as n, l as r, s as i } from "./ui-joAvYmUH.js";
1
+ import { c as e, d as t, i as n, l as r, s as i } from "./ui-ChXUXoIB.js";
2
2
  import { n as a, t as o } from "./i18n-BJ8rsBp6.js";
3
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, useRef as p, useState as m } from "react";
5
- import { useTranslation as h } from "react-i18next";
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";
6
6
  //#region src/chat/CommandPalette.tsx
7
- function g(e, t) {
7
+ function _(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 _({ items: e, active: n, onPick: r, onHover: i }) {
11
+ function v({ items: e, active: n, onPick: r, onHover: i }) {
12
12
  let o = a(), s = e.filter((e) => e.kind === "command"), u = e.filter((e) => e.kind === "skill"), d = (e, a) => /* @__PURE__ */ l("button", {
13
13
  type: "button",
14
14
  role: "option",
@@ -67,31 +67,34 @@ function _({ items: e, active: n, onPick: r, onHover: i }) {
67
67
  });
68
68
  }
69
69
  //#endregion
70
+ //#region src/chat/intl.ts
71
+ var y = (e) => e === "zh" ? "zh-CN" : e;
72
+ //#endregion
70
73
  //#region src/chat/ContextMeter.tsx
71
- function v(e, t) {
72
- return new Intl.NumberFormat(t === "zh" ? "zh-CN" : t, {
74
+ function b(e, t) {
75
+ return new Intl.NumberFormat(y(t), {
73
76
  notation: "compact",
74
77
  maximumFractionDigits: 1
75
78
  }).format(e);
76
79
  }
77
- function y({ context: e, onCompact: n, onReset: r }) {
78
- let s = a(), { i18n: u } = h(o), [d, f] = m(!1), p = i(d, () => f(!1)), g = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, _ = Math.round(g * 100), y = g >= .9 ? "full" : g >= .7 ? "warn" : "", b = 2 * Math.PI * 7, x = u.language;
80
+ function x({ context: e, onCompact: n, onReset: r }) {
81
+ let s = a(), { i18n: u } = g(o), [d, f] = h(!1), p = i(d, () => f(!1)), m = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, _ = Math.round(m * 100), v = m >= .9 ? "full" : m >= .7 ? "warn" : "", y = 2 * Math.PI * 7, x = u.language;
79
82
  return /* @__PURE__ */ l("div", {
80
83
  className: "ctxmeter",
81
84
  ref: p,
82
85
  children: [/* @__PURE__ */ c("button", {
83
86
  type: "button",
84
- className: `ctxring ${y}`,
87
+ className: `ctxring ${v}`,
85
88
  "aria-expanded": d,
86
89
  onClick: () => f((e) => !e),
87
90
  "aria-label": s("chat.context.meter", {
88
- used: v(e.tokens, x),
89
- total: v(e.window, x),
91
+ used: b(e.tokens, x),
92
+ total: b(e.window, x),
90
93
  pct: _
91
94
  }),
92
95
  title: s("chat.context.meter", {
93
- used: v(e.tokens, x),
94
- total: v(e.window, x),
96
+ used: b(e.tokens, x),
97
+ total: b(e.window, x),
95
98
  pct: _
96
99
  }),
97
100
  children: /* @__PURE__ */ l("svg", {
@@ -107,7 +110,7 @@ function y({ context: e, onCompact: n, onReset: r }) {
107
110
  cx: "9",
108
111
  cy: "9",
109
112
  r: 7,
110
- strokeDasharray: `${(b * g).toFixed(1)} ${b.toFixed(1)}`,
113
+ strokeDasharray: `${(y * m).toFixed(1)} ${y.toFixed(1)}`,
111
114
  transform: "rotate(-90 9 9)"
112
115
  })]
113
116
  })
@@ -116,16 +119,16 @@ function y({ context: e, onCompact: n, onReset: r }) {
116
119
  role: "dialog",
117
120
  children: [
118
121
  /* @__PURE__ */ c("div", { children: s("chat.context.meter", {
119
- used: v(e.tokens, x),
120
- total: v(e.window, x),
122
+ used: b(e.tokens, x),
123
+ total: b(e.window, x),
121
124
  pct: _
122
125
  }) }),
123
- y === "full" && /* @__PURE__ */ c("div", {
126
+ v === "full" && /* @__PURE__ */ c("div", {
124
127
  className: "small muted",
125
128
  style: { marginTop: 4 },
126
129
  children: s("chat.context.full")
127
130
  }),
128
- y === "full" && (n || r) && /* @__PURE__ */ l("div", {
131
+ v === "full" && (n || r) && /* @__PURE__ */ l("div", {
129
132
  className: "row",
130
133
  style: {
131
134
  marginTop: 8,
@@ -158,18 +161,280 @@ function y({ context: e, onCompact: n, onReset: r }) {
158
161
  });
159
162
  }
160
163
  //#endregion
164
+ //#region src/chat/Attachments.tsx
165
+ var S = /* @__PURE__ */ new Set([
166
+ "image/png",
167
+ "image/jpeg",
168
+ "image/gif",
169
+ "image/webp",
170
+ "image/svg+xml"
171
+ ]), C = /\.(png|jpe?g|gif|webp|svg)$/, w = /\.(txt|log|json|ya?ml|xml|ini|toml|sql|sh|py|go|js|ts|tsx|java|kt|rb|rs|c|cpp|h|css|html?)$/;
172
+ function T(e) {
173
+ let t = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), n = e.fileName.toLowerCase();
174
+ return S.has(t) || (!t || t === "application/octet-stream") && C.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.startsWith("text/") || t === "application/json" || t === "application/xml" || w.test(n) ? "text" : null;
175
+ }
176
+ var E = {
177
+ image: "image",
178
+ pdf: "pdf",
179
+ markdown: "markdown",
180
+ table: "table",
181
+ text: "source"
182
+ };
183
+ function D(e, t) {
184
+ return t === "pdf" ? "PDF" : t === "markdown" ? "MD" : /\.([a-z0-9]{1,5})$/i.exec(e.fileName)?.[1]?.toUpperCase() ?? (t ? "TXT" : "FILE");
185
+ }
186
+ function O(e, t) {
187
+ let n = [
188
+ "byte",
189
+ "kilobyte",
190
+ "megabyte",
191
+ "gigabyte"
192
+ ], r = e, i = 0;
193
+ for (; r >= 1024 && i < n.length - 1;) r /= 1024, i++;
194
+ return new Intl.NumberFormat(y(t), {
195
+ style: "unit",
196
+ unit: n[i],
197
+ unitDisplay: "short",
198
+ maximumFractionDigits: i === 0 ? 0 : 1
199
+ }).format(r);
200
+ }
201
+ function k(e, t) {
202
+ if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
203
+ let n = [], r = [], i = "", a = !1;
204
+ for (let t = 0; t < e.length; t++) {
205
+ let o = e[t];
206
+ a ? o === "\"" && e[t + 1] === "\"" ? (i += "\"", t++) : o === "\"" ? a = !1 : i += o : o === "\"" ? a = !0 : o === "," ? (r.push(i), i = "") : o === "\n" || o === "\r" ? (o === "\r" && e[t + 1] === "\n" && t++, r.push(i), n.push(r), r = [], i = "") : i += o;
207
+ }
208
+ return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
209
+ }
210
+ function A(e, t, n = !0) {
211
+ let [r, i] = h({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
212
+ return d(() => {
213
+ if (!n) return;
214
+ let e, r = !0;
215
+ return t({
216
+ id: a,
217
+ href: o,
218
+ fileName: s,
219
+ mimeType: c,
220
+ size: l
221
+ }).then((t) => {
222
+ if (!r) return;
223
+ let n = c && t.type !== c ? new Blob([t], { type: c }) : t;
224
+ e = URL.createObjectURL(n), i({
225
+ url: e,
226
+ blob: n
227
+ });
228
+ }, () => r && i({ failed: !0 })), () => {
229
+ r = !1, e && URL.revokeObjectURL(e);
230
+ };
231
+ }, [
232
+ n,
233
+ t,
234
+ a,
235
+ o,
236
+ s,
237
+ c,
238
+ l
239
+ ]), r;
240
+ }
241
+ function j({ a: e, load: t, onOpen: n }) {
242
+ let r = a(), { url: i, failed: o } = A(e, t);
243
+ return o ? /* @__PURE__ */ c(M, {
244
+ a: e,
245
+ kind: "image",
246
+ onOpen: n
247
+ }) : /* @__PURE__ */ l("button", {
248
+ type: "button",
249
+ className: "att-thumb",
250
+ onClick: n,
251
+ "aria-label": r("chat.files.open", { name: e.fileName }),
252
+ title: e.fileName,
253
+ children: [i ? /* @__PURE__ */ c("img", {
254
+ src: i,
255
+ alt: ""
256
+ }) : /* @__PURE__ */ c("span", {
257
+ className: "spin",
258
+ "aria-hidden": "true"
259
+ }), /* @__PURE__ */ c("span", {
260
+ className: "att-cap",
261
+ children: e.fileName
262
+ })]
263
+ });
264
+ }
265
+ function M({ a: e, kind: n, onOpen: r }) {
266
+ let i = a(), { i18n: u } = g(o), d = n !== null && r !== void 0, f = /* @__PURE__ */ l(s, { children: [
267
+ /* @__PURE__ */ l("span", {
268
+ className: "att-ic",
269
+ children: [/* @__PURE__ */ c(t, {
270
+ name: d && n ? E[n] : "download",
271
+ size: 24
272
+ }), /* @__PURE__ */ c("span", {
273
+ className: "att-kl",
274
+ children: D(e, n)
275
+ })]
276
+ }),
277
+ /* @__PURE__ */ c("span", {
278
+ className: "att-name",
279
+ children: e.fileName
280
+ }),
281
+ e.size != null && /* @__PURE__ */ c("span", {
282
+ className: "att-size",
283
+ children: O(e.size, u.language)
284
+ })
285
+ ] });
286
+ return d ? /* @__PURE__ */ c("button", {
287
+ type: "button",
288
+ className: `att-tile ${n}`,
289
+ onClick: r,
290
+ "aria-label": i("chat.files.open", { name: e.fileName }),
291
+ title: e.fileName,
292
+ children: f
293
+ }) : /* @__PURE__ */ c("a", {
294
+ className: "att-tile dl",
295
+ href: e.href,
296
+ download: e.fileName,
297
+ "aria-label": i("chat.files.save", { name: e.fileName }),
298
+ title: e.fileName,
299
+ children: f
300
+ });
301
+ }
302
+ function N({ items: e, load: t, onOpen: n }) {
303
+ return /* @__PURE__ */ c("div", {
304
+ className: "atts",
305
+ children: e.map((e) => {
306
+ let r = t && n ? () => n(e) : void 0, i = T(e);
307
+ return t && r && i === "image" ? /* @__PURE__ */ c(j, {
308
+ a: e,
309
+ load: t,
310
+ onOpen: r
311
+ }, e.id) : /* @__PURE__ */ c(M, {
312
+ a: e,
313
+ kind: i,
314
+ onOpen: r
315
+ }, e.id);
316
+ })
317
+ });
318
+ }
319
+ function P({ text: e, tab: t }) {
320
+ let n = a(), [r, ...i] = k(e, t), o = i.slice(0, 500);
321
+ return /* @__PURE__ */ l("div", {
322
+ className: "att-table",
323
+ 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", {
324
+ className: "att-more",
325
+ children: n("chat.files.rows", {
326
+ shown: o.length,
327
+ total: i.length
328
+ })
329
+ })]
330
+ });
331
+ }
332
+ function ee({ a: e, load: i, onClose: u }) {
333
+ let f = a(), { i18n: p } = g(o), m = T(e), _ = m === "markdown" || m === "table" || m === "text", v = _ && (e.size ?? 0) > 1048576, { url: y, blob: b, failed: x } = A(e, i, !v), [S, C] = h(null), w = v || _ && (b?.size ?? 0) > 1048576;
334
+ d(() => {
335
+ _ && b && !w && b.arrayBuffer().then((e) => {
336
+ try {
337
+ C({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
338
+ } catch {
339
+ C({ text: null });
340
+ }
341
+ }, () => C({ text: null }));
342
+ }, [
343
+ _,
344
+ b,
345
+ w
346
+ ]);
347
+ let E = S?.text, D;
348
+ return D = x ? /* @__PURE__ */ c("div", {
349
+ className: "att-msg err-text",
350
+ children: f("chat.files.failed")
351
+ }) : w ? /* @__PURE__ */ c("div", {
352
+ className: "att-msg",
353
+ children: f("chat.files.tooLarge")
354
+ }) : S && E === null ? /* @__PURE__ */ c("div", {
355
+ className: "att-msg",
356
+ children: f("chat.files.notUtf8")
357
+ }) : !y || _ && E == null ? /* @__PURE__ */ l("div", {
358
+ className: "att-msg",
359
+ children: [
360
+ /* @__PURE__ */ c("span", {
361
+ className: "spin",
362
+ "aria-hidden": "true"
363
+ }),
364
+ " ",
365
+ f("loading")
366
+ ]
367
+ }) : m === "image" ? /* @__PURE__ */ c("img", {
368
+ className: "att-img",
369
+ src: y,
370
+ alt: e.fileName
371
+ }) : m === "pdf" ? /* @__PURE__ */ c("object", {
372
+ className: "att-pdf",
373
+ data: y,
374
+ type: "application/pdf",
375
+ "aria-label": e.fileName,
376
+ children: /* @__PURE__ */ c("div", {
377
+ className: "att-msg",
378
+ children: f("chat.files.failed")
379
+ })
380
+ }) : m === "markdown" ? /* @__PURE__ */ c("div", {
381
+ className: "att-md",
382
+ children: /* @__PURE__ */ c(r, { text: E ?? "" })
383
+ }) : m === "table" ? /* @__PURE__ */ c(P, {
384
+ text: E ?? "",
385
+ tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
386
+ }) : /* @__PURE__ */ c("pre", {
387
+ className: "att-text",
388
+ children: E
389
+ }), /* @__PURE__ */ c(n, {
390
+ wide: !0,
391
+ onClose: u,
392
+ title: /* @__PURE__ */ l("span", {
393
+ className: "att-title",
394
+ children: [/* @__PURE__ */ c("span", {
395
+ className: "att-name",
396
+ children: e.fileName
397
+ }), e.size != null && /* @__PURE__ */ c("span", {
398
+ className: "muted small",
399
+ children: O(e.size, p.language)
400
+ })]
401
+ }),
402
+ footer: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("a", {
403
+ className: "btn ghost",
404
+ href: y ?? e.href,
405
+ download: e.fileName,
406
+ children: [
407
+ /* @__PURE__ */ c(t, {
408
+ name: "download",
409
+ size: 14
410
+ }),
411
+ " ",
412
+ f("chat.files.download")
413
+ ]
414
+ }), /* @__PURE__ */ c("button", {
415
+ type: "button",
416
+ className: "btn primary",
417
+ onClick: u,
418
+ children: f("close")
419
+ })] }),
420
+ children: /* @__PURE__ */ c("div", {
421
+ className: `att-view ${m ?? ""}`,
422
+ children: D
423
+ })
424
+ });
425
+ }
426
+ //#endregion
161
427
  //#region src/chat/MessageView.tsx
162
- var b = (e) => e === "zh" ? "zh-CN" : e;
163
- function x(e, t) {
164
- return new Intl.DateTimeFormat(b(t), {
428
+ function F(e, t) {
429
+ return new Intl.DateTimeFormat(y(t), {
165
430
  hour: "2-digit",
166
431
  minute: "2-digit"
167
432
  }).format(new Date(e));
168
433
  }
169
- function S(e, t) {
434
+ function I(e, t) {
170
435
  return t || e.length <= 3 ? e : e.slice(-2);
171
436
  }
172
- var C = {
437
+ var L = {
173
438
  done: {
174
439
  icon: "check",
175
440
  cls: "ok"
@@ -183,14 +448,14 @@ var C = {
183
448
  cls: "run"
184
449
  }
185
450
  };
186
- function w({ m: e, busy: n, onRetry: i }) {
187
- let { t: a, i18n: u } = h(o), [d, f] = m(!1);
451
+ function R({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u }) {
452
+ let { t: d, i18n: f } = g(o), [p, m] = h(!1);
188
453
  if (e.role === "note") return /* @__PURE__ */ c("div", {
189
454
  className: "sysnote",
190
455
  children: e.text
191
456
  });
192
- if (e.role === "event" && e.event) return /* @__PURE__ */ c(T, { m: e });
193
- let p = e.mark && /* @__PURE__ */ l("div", {
457
+ if (e.role === "event" && e.event) return /* @__PURE__ */ c(z, { m: e });
458
+ let _ = e.mark && /* @__PURE__ */ l("div", {
194
459
  className: "chan",
195
460
  children: [
196
461
  /* @__PURE__ */ c(t, {
@@ -200,73 +465,64 @@ function w({ m: e, busy: n, onRetry: i }) {
200
465
  " ",
201
466
  e.mark.text,
202
467
  " · ",
203
- x(e.createdAt, u.language)
468
+ F(e.createdAt, f.language)
204
469
  ]
205
- }), g = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c("div", {
206
- className: "atts",
207
- children: e.attachments.map((e) => /* @__PURE__ */ l("a", {
208
- href: e.href,
209
- children: [
210
- /* @__PURE__ */ c(t, {
211
- name: "clip",
212
- size: 12
213
- }),
214
- " ",
215
- e.fileName
216
- ]
217
- }, e.id))
470
+ }), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(N, {
471
+ items: e.attachments,
472
+ load: a,
473
+ onOpen: u
218
474
  });
219
475
  if (e.role === "user") return /* @__PURE__ */ l("div", {
220
476
  className: "m u",
221
477
  children: [
222
- p,
478
+ _,
223
479
  e.content,
224
480
  e.text && /* @__PURE__ */ c("div", {
225
481
  className: "bub",
226
482
  children: e.text
227
483
  }),
228
- g,
484
+ v,
229
485
  e.wait && /* @__PURE__ */ c("div", {
230
486
  className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
231
487
  role: "status",
232
488
  children: e.wait.state === "queued" ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
233
489
  name: "clock",
234
490
  size: 12
235
- }), a("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
491
+ }), d("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
236
492
  className: "spin",
237
493
  "aria-hidden": "true"
238
- }), a("chat.wait.starting")] })
494
+ }), d("chat.wait.starting")] })
239
495
  })
240
496
  ]
241
497
  });
242
- let _ = e.steps ?? [], v = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
498
+ let y = e.steps ?? [], b = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
243
499
  return /* @__PURE__ */ l("div", {
244
500
  className: "m a",
245
501
  children: [
246
- p,
247
- _.length > 3 && /* @__PURE__ */ c("button", {
502
+ _,
503
+ y.length > 3 && /* @__PURE__ */ c("button", {
248
504
  className: "tools-fold",
249
- onClick: () => f((e) => !e),
250
- "aria-expanded": d,
251
- children: d ? a("chat.hideSteps") : a("chat.moreSteps", { count: _.length - 2 })
505
+ onClick: () => m((e) => !e),
506
+ "aria-expanded": p,
507
+ children: p ? d("chat.hideSteps") : d("chat.moreSteps", { count: y.length - 2 })
252
508
  }),
253
- S(_, d).map((e) => /* @__PURE__ */ l("div", {
509
+ I(y, p).map((e) => /* @__PURE__ */ l("div", {
254
510
  className: "tool",
255
511
  title: e.title,
256
512
  children: [/* @__PURE__ */ c(t, {
257
- name: C[e.status].icon,
513
+ name: L[e.status].icon,
258
514
  size: 14,
259
- className: C[e.status].cls
515
+ className: L[e.status].cls
260
516
  }), /* @__PURE__ */ c("span", {
261
517
  className: "tx",
262
518
  children: e.text
263
519
  })]
264
520
  }, e.id)),
265
- v && /* @__PURE__ */ c("div", {
521
+ b && /* @__PURE__ */ c("div", {
266
522
  className: "bub",
267
523
  children: /* @__PURE__ */ l("span", {
268
524
  className: "typing",
269
- "aria-label": a("chat.typing"),
525
+ "aria-label": d("chat.typing"),
270
526
  children: [
271
527
  /* @__PURE__ */ c("i", {}),
272
528
  /* @__PURE__ */ c("i", {}),
@@ -279,7 +535,7 @@ function w({ m: e, busy: n, onRetry: i }) {
279
535
  title: e.hint,
280
536
  children: /* @__PURE__ */ c(r, { text: e.text })
281
537
  })),
282
- g,
538
+ v,
283
539
  e.error && /* @__PURE__ */ l("div", {
284
540
  className: `llmerr${e.error.transient ? " amber" : ""}`,
285
541
  role: "alert",
@@ -293,15 +549,15 @@ function w({ m: e, busy: n, onRetry: i }) {
293
549
  children: [/* @__PURE__ */ c(t, {
294
550
  name: "refresh",
295
551
  size: 14
296
- }), a("chat.retry")]
552
+ }), d("chat.retry")]
297
553
  })
298
554
  })]
299
555
  })
300
556
  ]
301
557
  });
302
558
  }
303
- function T({ m: e }) {
304
- let { t: n, i18n: r } = h(o), [i, a] = m(!1), s = e.event;
559
+ function z({ m: e }) {
560
+ let { t: n, i18n: r } = g(o), [i, a] = h(!1), s = e.event;
305
561
  return /* @__PURE__ */ l("div", {
306
562
  className: "evdiv",
307
563
  children: [/* @__PURE__ */ c("div", {
@@ -316,7 +572,7 @@ function T({ m: e }) {
316
572
  }),
317
573
  s.text,
318
574
  " · ",
319
- x(e.createdAt, r.language),
575
+ F(e.createdAt, r.language),
320
576
  s.details && /* @__PURE__ */ l("button", {
321
577
  type: "button",
322
578
  className: "textbtn",
@@ -338,28 +594,28 @@ function T({ m: e }) {
338
594
  }
339
595
  //#endregion
340
596
  //#region src/chat/transcription.ts
341
- async function E(e, t, n) {
597
+ async function te(e, t, n) {
342
598
  n.busy(!0);
343
599
  let r;
344
600
  try {
345
601
  r = await t(e);
346
602
  } catch (r) {
347
- n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void E(e, t, n));
603
+ n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void te(e, t, n));
348
604
  return;
349
605
  }
350
606
  n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
351
607
  }
352
608
  //#endregion
353
609
  //#region src/chat/useRecorder.ts
354
- function D(e = 300, t) {
355
- let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = m(!1), [a, o] = m(0), [s, c] = m(0), [l, f] = m(!1), h = p(null), g = p([]), _ = p(void 0), v = p(null), y = p(null), b = p(!1), x = p(t);
610
+ function ne(e = 300, t) {
611
+ 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);
356
612
  d(() => {
357
613
  x.current = t;
358
614
  });
359
615
  let S = u(() => {
360
- window.clearInterval(_.current), h.current?.stream.getTracks().forEach((e) => e.stop()), h.current = null, v.current?.close().catch(() => void 0), v.current = null, i(!1), c(0);
616
+ 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);
361
617
  }, []), C = u(async () => {
362
- if (n && !h.current) {
618
+ if (n && !p.current) {
363
619
  f(!1);
364
620
  try {
365
621
  let t = await navigator.mediaDevices.getUserMedia({ audio: !0 }), n = new MediaRecorder(t);
@@ -375,7 +631,7 @@ function D(e = 300, t) {
375
631
  r = null;
376
632
  }
377
633
  let a = r ? new Uint8Array(r.fftSize) : null;
378
- h.current = n, n.start(), o(0), i(!0);
634
+ p.current = n, n.start(), o(0), i(!0);
379
635
  let s = Date.now(), l = !1;
380
636
  _.current = window.setInterval(() => {
381
637
  let t = Math.floor((Date.now() - s) / 1e3);
@@ -396,7 +652,7 @@ function D(e = 300, t) {
396
652
  S,
397
653
  e
398
654
  ]), w = u(() => new Promise((e) => {
399
- let t = h.current;
655
+ let t = p.current;
400
656
  if (!t || t.state === "inactive") return e(null);
401
657
  y.current = e, t.stop();
402
658
  }), []), T = u(() => {
@@ -413,71 +669,75 @@ function D(e = 300, t) {
413
669
  cancel: T
414
670
  };
415
671
  }
416
- function O(e) {
672
+ function re(e) {
417
673
  return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
418
674
  }
419
675
  //#endregion
420
676
  //#region src/chat/Chat.tsx
421
- function k(n) {
422
- let r = a(), i = e(), [o, u] = m(""), [h, v] = m([]), [b, x] = m(!1), [S, C] = m(null), [T, k] = m(0), [A, j] = m(!1), [M, N] = m(null), [P, ee] = m(!1), F = p(!1), I = p(null), L = p(null), R = p(null), z = n.voiceMaxSeconds ?? 300, B = D(z, () => void oe()), { messages: V, busy: H = !1 } = n, U = n.onPendingChange;
423
- d(() => U?.(h), [h, U]);
424
- let W = V[0]?.id, G = V[V.length - 1], K = G?.id, te = G?.text.length, ne = G?.steps?.length, q = p({ height: 0 });
677
+ function B(n) {
678
+ 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, M] = h(!1), [N, P] = h(null), F = m(n.loadAttachment);
679
+ d(() => {
680
+ F.current = n.loadAttachment;
681
+ });
682
+ let I = !!n.loadAttachment, L = p(() => I ? (e) => F.current ? F.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [I]), z = m(!1), B = m(null), V = m(null), H = m(null), U = n.voiceMaxSeconds ?? 300, W = ne(U, () => void me()), { messages: G, busy: K = !1 } = n, ae = n.onPendingChange;
683
+ d(() => ae?.(g), [g, ae]);
684
+ let q = G[0]?.id, J = G[G.length - 1], Y = J?.id, oe = J?.text.length, se = J?.steps?.length, ce = m({ height: 0 });
425
685
  f(() => {
426
- let e = I.current;
686
+ let e = B.current;
427
687
  if (!e) return;
428
- let t = q.current;
429
- e.scrollTop = t.first !== void 0 && W !== t.first && K === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, q.current = {
430
- first: W,
431
- last: K,
688
+ let t = ce.current;
689
+ e.scrollTop = t.first !== void 0 && q !== t.first && Y === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, ce.current = {
690
+ first: q,
691
+ last: Y,
432
692
  height: e.scrollHeight
433
693
  };
434
694
  }, [
435
- V.length,
436
- W,
437
- K,
438
- te,
439
- ne
695
+ G.length,
696
+ q,
697
+ Y,
698
+ oe,
699
+ se
440
700
  ]);
441
- let J = n.commands && !S && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Y = J === null ? [] : g(n.commands ?? [], J), X = J !== null && !A, Z = () => {
442
- u(""), v([]), C(null), N(null), F.current = !1;
443
- }, Q = async (e, t) => {
701
+ let X = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Z = X === null ? [] : _(n.commands ?? [], X), Q = X !== null && !D, le = () => {
702
+ u(""), y([]), w(null), A(null), z.current = !1;
703
+ }, ue = async (e, t) => {
444
704
  if (n.onCommand) try {
445
- await n.onCommand(e, t), Z();
705
+ await n.onCommand(e, t), le();
446
706
  } catch {}
447
707
  }, $ = async (e, t = !1) => {
448
708
  let r = e.trim();
449
- if (!(!r && h.length === 0 && !S || H || n.readOnly)) {
450
- if (!t && !S && n.commands && r.startsWith("/")) {
709
+ if (!(!r && g.length === 0 && !C || K || n.readOnly)) {
710
+ if (!t && !C && n.commands && r.startsWith("/")) {
451
711
  let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
452
- if (i) return Q(i.name, t.join(" "));
712
+ if (i) return ue(i.name, t.join(" "));
453
713
  if (e && !r.includes("\n")) {
454
- N("/" + e);
714
+ A("/" + e);
455
715
  return;
456
716
  }
457
717
  }
458
718
  try {
459
- await n.onSend(r, h.map((e) => e.id), F.current, S ?? void 0), Z();
719
+ await n.onSend(r, g.map((e) => e.id), z.current, C ?? void 0), le();
460
720
  } catch {}
461
721
  }
462
- }, re = (e) => {
463
- k(0), e.kind === "skill" ? (C(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : Q(e.name, ""), R.current?.focus();
464
- }, ie = (e) => {
465
- if (X && Y.length > 0) {
722
+ }, de = (e) => {
723
+ E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : ue(e.name, ""), H.current?.focus();
724
+ }, fe = (e) => {
725
+ if (Q && Z.length > 0) {
466
726
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
467
727
  e.preventDefault();
468
728
  let t = e.key === "ArrowDown" ? 1 : -1;
469
- k((e) => (e + t + Y.length) % Y.length);
729
+ E((e) => (e + t + Z.length) % Z.length);
470
730
  return;
471
731
  }
472
732
  if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
473
- e.preventDefault(), re(Y[Math.min(T, Y.length - 1)]);
733
+ e.preventDefault(), de(Z[Math.min(T, Z.length - 1)]);
474
734
  return;
475
735
  }
476
736
  }
477
- X && e.key === "Escape" ? (e.preventDefault(), j(!0)) : e.key === "Backspace" && S && o === "" ? C(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), $(o));
478
- }, ae = async (e) => {
737
+ Q && e.key === "Escape" ? (e.preventDefault(), O(!0)) : e.key === "Backspace" && C && o === "" ? w(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), $(o));
738
+ }, pe = async (e) => {
479
739
  if (e?.length && n.onUpload) {
480
- x(!0);
740
+ S(!0);
481
741
  for (let t of Array.from(e)) {
482
742
  if (n.upload && t.size > n.upload.maxBytes) {
483
743
  i({
@@ -488,15 +748,15 @@ function k(n) {
488
748
  continue;
489
749
  }
490
750
  let e = await n.onUpload(t).catch(() => null);
491
- e && v((t) => [...t, e]);
751
+ e && y((t) => [...t, e]);
492
752
  }
493
- x(!1), L.current && (L.current.value = "");
753
+ S(!1), V.current && (V.current.value = "");
494
754
  }
495
755
  };
496
- async function oe() {
497
- let e = await B.stop();
498
- e && n.onTranscribe && await E(e, n.onTranscribe, {
499
- busy: ee,
756
+ async function me() {
757
+ let e = await W.stop();
758
+ e && n.onTranscribe && await te(e, n.onTranscribe, {
759
+ busy: M,
500
760
  empty: () => i({
501
761
  kind: "error",
502
762
  title: r("chat.voice.notRecognized")
@@ -511,13 +771,13 @@ function k(n) {
511
771
  }]
512
772
  }),
513
773
  text: (e) => {
514
- F.current = !0, u((t) => t.trim() ? t.trimEnd() + " " + e : e), R.current?.focus();
774
+ z.current = !0, u((t) => t.trim() ? t.trimEnd() + " " + e : e), H.current?.focus();
515
775
  }
516
776
  });
517
777
  }
518
- let se = (e) => {
519
- e.key === "Escape" && B.recording && (e.preventDefault(), B.cancel());
520
- }, ce = S ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), le = z - B.seconds;
778
+ let he = (e) => {
779
+ e.key === "Escape" && W.recording && (e.preventDefault(), W.cancel());
780
+ }, ge = C ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), _e = U - W.seconds;
521
781
  return /* @__PURE__ */ l("section", {
522
782
  className: "nb-chat",
523
783
  "aria-label": r("chat.title"),
@@ -525,7 +785,7 @@ function k(n) {
525
785
  n.header,
526
786
  /* @__PURE__ */ l("div", {
527
787
  className: "msgs",
528
- ref: I,
788
+ ref: B,
529
789
  "aria-live": "polite",
530
790
  children: [
531
791
  n.hasOlder && n.onLoadOlder && /* @__PURE__ */ c("button", {
@@ -539,7 +799,7 @@ function k(n) {
539
799
  className: "err-text",
540
800
  children: n.historyError
541
801
  }),
542
- V.length === 0 && !n.loading && !n.historyError && /* @__PURE__ */ l("div", {
802
+ G.length === 0 && !n.loading && !n.historyError && /* @__PURE__ */ l("div", {
543
803
  className: "empty",
544
804
  children: [
545
805
  /* @__PURE__ */ c("div", {
@@ -550,10 +810,12 @@ function k(n) {
550
810
  n.emptyHint
551
811
  ]
552
812
  }),
553
- V.map((e) => /* @__PURE__ */ c(w, {
813
+ G.map((e) => /* @__PURE__ */ c(R, {
554
814
  m: e,
555
- busy: H,
556
- onRetry: n.onRetry && (() => n.onRetry?.(e.id))
815
+ busy: K,
816
+ onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
817
+ loadAttachment: L,
818
+ onOpenAttachment: P
557
819
  }, e.id)),
558
820
  n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ l("div", {
559
821
  className: "confirm",
@@ -595,16 +857,16 @@ function k(n) {
595
857
  }) : /* @__PURE__ */ l("div", {
596
858
  className: "composer-wrap",
597
859
  children: [
598
- X && /* @__PURE__ */ c(_, {
599
- items: Y,
600
- active: Math.min(T, Math.max(Y.length - 1, 0)),
601
- onPick: re,
602
- onHover: k
860
+ Q && /* @__PURE__ */ c(v, {
861
+ items: Z,
862
+ active: Math.min(T, Math.max(Z.length - 1, 0)),
863
+ onPick: de,
864
+ onHover: E
603
865
  }),
604
866
  n.aboveComposer,
605
- h.length > 0 && /* @__PURE__ */ c("div", {
867
+ g.length > 0 && /* @__PURE__ */ c("div", {
606
868
  className: "pending-files",
607
- children: h.map((e) => /* @__PURE__ */ l("span", {
869
+ children: g.map((e) => /* @__PURE__ */ l("span", {
608
870
  className: "chip",
609
871
  children: [
610
872
  /* @__PURE__ */ c(t, {
@@ -619,7 +881,7 @@ function k(n) {
619
881
  height: 18
620
882
  },
621
883
  "aria-label": r("remove"),
622
- onClick: () => v((t) => t.filter((t) => t.id !== e.id)),
884
+ onClick: () => y((t) => t.filter((t) => t.id !== e.id)),
623
885
  children: /* @__PURE__ */ c(t, {
624
886
  name: "x",
625
887
  size: 12
@@ -628,10 +890,10 @@ function k(n) {
628
890
  ]
629
891
  }, e.id))
630
892
  }),
631
- M && /* @__PURE__ */ l("div", {
893
+ k && /* @__PURE__ */ l("div", {
632
894
  className: "cmd-unknown",
633
895
  role: "status",
634
- children: [r("chat.unknownCommand", { name: M }), /* @__PURE__ */ c("button", {
896
+ children: [r("chat.unknownCommand", { name: k }), /* @__PURE__ */ c("button", {
635
897
  type: "button",
636
898
  className: "textbtn",
637
899
  onClick: () => void $(o, !0),
@@ -641,22 +903,22 @@ function k(n) {
641
903
  /* @__PURE__ */ l("div", {
642
904
  className: "composer",
643
905
  children: [
644
- n.onUpload && !B.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
906
+ n.onUpload && !W.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
645
907
  className: "iconbtn",
646
908
  "aria-label": r("chat.attach"),
647
909
  disabled: b,
648
- onClick: () => L.current?.click(),
910
+ onClick: () => V.current?.click(),
649
911
  children: /* @__PURE__ */ c(t, { name: "clip" })
650
912
  }), /* @__PURE__ */ c("input", {
651
- ref: L,
913
+ ref: V,
652
914
  type: "file",
653
915
  multiple: !0,
654
916
  hidden: !0,
655
917
  accept: n.upload?.accept,
656
- onChange: (e) => ae(e.target.files)
918
+ onChange: (e) => pe(e.target.files)
657
919
  })] }),
658
- B.recording ? /* @__PURE__ */ l("div", {
659
- className: `recbar${le <= 15 ? " ending" : ""}`,
920
+ W.recording ? /* @__PURE__ */ l("div", {
921
+ className: `recbar${_e <= 15 ? " ending" : ""}`,
660
922
  role: "status",
661
923
  "aria-label": r("chat.voice.recordingNow"),
662
924
  children: [
@@ -667,40 +929,41 @@ function k(n) {
667
929
  /* @__PURE__ */ l("span", {
668
930
  className: "tm",
669
931
  children: [
670
- O(B.seconds),
932
+ re(W.seconds),
671
933
  " / ",
672
- O(z)
934
+ re(U)
673
935
  ]
674
936
  }),
675
937
  /* @__PURE__ */ c("span", {
676
938
  className: "lvl",
677
939
  "aria-hidden": "true",
678
- children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, B.level)})` } })
940
+ children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, W.level)})` } })
679
941
  }),
680
942
  /* @__PURE__ */ c("button", {
681
943
  type: "button",
682
944
  className: "btn ghost sm",
683
- onClick: B.cancel,
945
+ onClick: W.cancel,
684
946
  children: r("cancel")
685
947
  }),
686
948
  /* @__PURE__ */ c("button", {
687
949
  type: "button",
688
950
  className: "btn primary sm",
689
- onKeyDown: se,
690
- onClick: () => void oe(),
951
+ onKeyDown: he,
952
+ onClick: () => void me(),
691
953
  children: r("chat.voice.done")
692
954
  })
693
955
  ]
694
956
  }) : /* @__PURE__ */ l("div", {
695
- className: `field${S ? " with-skill" : ""}`,
696
- children: [S && /* @__PURE__ */ l("span", {
957
+ className: `field${C ? " with-skill" : ""}${j ? " recognizing" : ""}`,
958
+ "aria-busy": j || void 0,
959
+ children: [C && /* @__PURE__ */ l("span", {
697
960
  className: "chip skill-chip",
698
961
  children: [
699
962
  /* @__PURE__ */ c(t, {
700
963
  name: "spark",
701
964
  size: 12
702
965
  }),
703
- S,
966
+ C,
704
967
  /* @__PURE__ */ c("button", {
705
968
  className: "iconbtn",
706
969
  style: {
@@ -708,7 +971,7 @@ function k(n) {
708
971
  height: 18
709
972
  },
710
973
  "aria-label": r("remove"),
711
- onClick: () => C(null),
974
+ onClick: () => w(null),
712
975
  children: /* @__PURE__ */ c(t, {
713
976
  name: "x",
714
977
  size: 12
@@ -716,34 +979,31 @@ function k(n) {
716
979
  })
717
980
  ]
718
981
  }), /* @__PURE__ */ c("textarea", {
719
- ref: R,
982
+ ref: H,
720
983
  rows: 1,
721
984
  value: o,
722
- placeholder: P ? r("chat.voice.recognizing") : ce,
723
- "aria-label": ce,
724
- disabled: P,
725
- "aria-expanded": X,
985
+ placeholder: j ? r("chat.voice.recognizing") : ge,
986
+ "aria-label": ge,
987
+ disabled: j,
988
+ "aria-expanded": Q,
726
989
  "aria-autocomplete": n.commands ? "list" : void 0,
727
990
  onChange: (e) => {
728
- u(e.target.value), j(!1), k(0), N(null);
991
+ u(e.target.value), O(!1), E(0), A(null);
729
992
  },
730
- onKeyDown: ie
993
+ onKeyDown: fe
731
994
  })]
732
995
  }),
733
- n.context && !B.recording && /* @__PURE__ */ c(y, {
996
+ n.context && !W.recording && /* @__PURE__ */ c(x, {
734
997
  context: n.context,
735
998
  onCompact: n.onCompact,
736
999
  onReset: n.onReset
737
1000
  }),
738
- n.onTranscribe && !B.recording && /* @__PURE__ */ c("button", {
739
- className: "iconbtn",
740
- disabled: !B.supported || P,
741
- "aria-label": r("chat.voice.start"),
742
- title: B.supported ? r("chat.voice.start") : r("chat.voice.unsupported"),
743
- onClick: () => void B.start(),
744
- children: /* @__PURE__ */ c(t, { name: "mic" })
1001
+ n.onTranscribe && !W.recording && /* @__PURE__ */ c(ie, {
1002
+ supported: W.supported,
1003
+ recognizing: j,
1004
+ onStart: () => void W.start()
745
1005
  }),
746
- !B.recording && (n.onCancel && H ? /* @__PURE__ */ c("button", {
1006
+ !W.recording && (n.onCancel && K ? /* @__PURE__ */ c("button", {
747
1007
  className: "iconbtn fill",
748
1008
  "aria-label": r("chat.stop"),
749
1009
  onClick: n.onCancel,
@@ -751,26 +1011,54 @@ function k(n) {
751
1011
  }) : /* @__PURE__ */ c("button", {
752
1012
  className: "iconbtn fill",
753
1013
  "aria-label": r("chat.send"),
754
- disabled: !o.trim() && h.length === 0 && !S || H,
1014
+ disabled: !o.trim() && g.length === 0 && !C || K || j,
755
1015
  onClick: () => $(o),
756
1016
  children: /* @__PURE__ */ c(t, { name: "send" })
757
1017
  }))
758
1018
  ]
759
1019
  }),
760
- B.error && /* @__PURE__ */ c("div", {
1020
+ W.error && /* @__PURE__ */ c("div", {
761
1021
  className: "err-text",
762
1022
  style: { padding: "0 12px 8px" },
763
1023
  children: r("chat.voice.micDenied")
764
1024
  })
765
1025
  ]
1026
+ }),
1027
+ N && L && /* @__PURE__ */ c(ee, {
1028
+ a: N,
1029
+ load: L,
1030
+ onClose: () => P(null)
766
1031
  })
767
1032
  ]
768
1033
  });
769
1034
  }
1035
+ function ie({ supported: e, recognizing: n, onStart: r }) {
1036
+ let i = a();
1037
+ return n ? /* @__PURE__ */ l("span", {
1038
+ className: "voicewait",
1039
+ role: "status",
1040
+ "aria-label": i("chat.voice.recognizing"),
1041
+ title: i("chat.voice.recognizing"),
1042
+ children: [
1043
+ /* @__PURE__ */ c("i", {}),
1044
+ /* @__PURE__ */ c("i", {}),
1045
+ /* @__PURE__ */ c("i", {}),
1046
+ /* @__PURE__ */ c("i", {}),
1047
+ /* @__PURE__ */ c("i", {})
1048
+ ]
1049
+ }) : /* @__PURE__ */ c("button", {
1050
+ className: "iconbtn",
1051
+ disabled: !e,
1052
+ "aria-label": i("chat.voice.start"),
1053
+ title: i(e ? "chat.voice.start" : "chat.voice.unsupported"),
1054
+ onClick: r,
1055
+ children: /* @__PURE__ */ c(t, { name: "mic" })
1056
+ });
1057
+ }
770
1058
  //#endregion
771
1059
  //#region src/chat/ConversationList.tsx
772
- function A({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
773
- let f = a(), [p, h] = m(!1);
1060
+ function V({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
1061
+ let f = a(), [p, m] = h(!1);
774
1062
  d(() => {
775
1063
  if (!r) return;
776
1064
  let e = (e) => e.key === "Escape" && o();
@@ -811,7 +1099,7 @@ function A({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
811
1099
  width: "100%",
812
1100
  justifyContent: "center"
813
1101
  },
814
- onClick: () => h(!0),
1102
+ onClick: () => m(!0),
815
1103
  children: [/* @__PURE__ */ c(t, {
816
1104
  name: "plus",
817
1105
  size: 15
@@ -845,20 +1133,20 @@ function A({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
845
1133
  "aria-label": f("close"),
846
1134
  onClick: o
847
1135
  }),
848
- p && u && /* @__PURE__ */ c(M, {
849
- onClose: () => h(!1),
1136
+ p && u && /* @__PURE__ */ c(U, {
1137
+ onClose: () => m(!1),
850
1138
  onCreate: u
851
1139
  })
852
1140
  ] });
853
1141
  }
854
- function j({ narrow: e, children: t }) {
1142
+ function H({ narrow: e, children: t }) {
855
1143
  return /* @__PURE__ */ c("div", {
856
1144
  className: `nb-app${e ? " narrow" : ""}`,
857
1145
  children: t
858
1146
  });
859
1147
  }
860
- function M({ onClose: e, onCreate: t }) {
861
- let r = a(), [i, o] = m(""), [u, d] = m(!1), [f, p] = m(null), h = async () => {
1148
+ function U({ onClose: e, onCreate: t }) {
1149
+ let r = a(), [i, o] = h(""), [u, d] = h(!1), [f, p] = h(null), m = async () => {
862
1150
  if (i.trim() && !u) {
863
1151
  d(!0), p(null);
864
1152
  try {
@@ -878,7 +1166,7 @@ function M({ onClose: e, onCreate: t }) {
878
1166
  }), /* @__PURE__ */ c("button", {
879
1167
  className: "btn primary",
880
1168
  disabled: !i.trim() || u,
881
- onClick: h,
1169
+ onClick: m,
882
1170
  children: r("create")
883
1171
  })] }),
884
1172
  children: [/* @__PURE__ */ l("div", {
@@ -894,7 +1182,7 @@ function M({ onClose: e, onCreate: t }) {
894
1182
  value: i,
895
1183
  maxLength: 120,
896
1184
  onChange: (e) => o(e.target.value),
897
- onKeyDown: (e) => e.key === "Enter" && h()
1185
+ onKeyDown: (e) => e.key === "Enter" && m()
898
1186
  }),
899
1187
  /* @__PURE__ */ c("div", {
900
1188
  className: "hint",
@@ -909,7 +1197,7 @@ function M({ onClose: e, onCreate: t }) {
909
1197
  }
910
1198
  //#endregion
911
1199
  //#region src/chat/AgentMenu.tsx
912
- function N({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1200
+ function W({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
913
1201
  return /* @__PURE__ */ c("button", {
914
1202
  type: "button",
915
1203
  className: `agentbtn${a ? " s" : ""}`,
@@ -925,8 +1213,8 @@ function N({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, on
925
1213
  })
926
1214
  });
927
1215
  }
928
- function P({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: h, onPick: g, onClose: _ }) {
929
- let v = a(), [y, b] = m(n), x = i(!0, _);
1216
+ function G({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: m, onPick: g, onClose: _ }) {
1217
+ let v = a(), [y, b] = h(n), x = i(!0, _);
930
1218
  return /* @__PURE__ */ l("div", {
931
1219
  className: `agentmenu${f ? " narrow" : ""}`,
932
1220
  ref: x,
@@ -946,7 +1234,7 @@ function P({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
946
1234
  onChange: (e) => b(e.target.value),
947
1235
  onBlur: () => {
948
1236
  let e = y.trim();
949
- e && e !== n && h(e);
1237
+ e && e !== n && m(e);
950
1238
  },
951
1239
  onKeyDown: (e) => e.key === "Enter" && e.target.blur()
952
1240
  }),
@@ -1036,6 +1324,6 @@ function P({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
1036
1324
  });
1037
1325
  }
1038
1326
  //#endregion
1039
- export { N as AgentButton, P as AgentMenu, k as Chat, j as ChatLayout, _ as CommandPalette, y as ContextMeter, A as ConversationList, w as MessageView, M as NewTopicModal, v as tokens, D as useRecorder };
1327
+ export { W as AgentButton, G as AgentMenu, N as AttachmentList, ee as AttachmentPreview, B as Chat, H as ChatLayout, v as CommandPalette, x as ContextMeter, V as ConversationList, R as MessageView, U as NewTopicModal, ie as VoiceButton, O as fileSize, k as parseTable, T as previewKind, b as tokens, ne as useRecorder };
1040
1328
 
1041
1329
  //# sourceMappingURL=chat.js.map