@singlebase/elements 0.5.0 → 0.6.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.
Files changed (50) hide show
  1. package/dist/{authui-display-BCZBP7HR.js → authui-display-CKfGK5va.js} +519 -503
  2. package/dist/authui-display-CKfGK5va.js.map +1 -0
  3. package/dist/{authui-display-CLGFSqRi.cjs → authui-display-aWNht0cW.cjs} +38 -58
  4. package/dist/authui-display-aWNht0cW.cjs.map +1 -0
  5. package/dist/authui.cjs +1 -1
  6. package/dist/authui.js +2 -2
  7. package/dist/chat-C-gsskho.cjs +3258 -0
  8. package/dist/chat-C-gsskho.cjs.map +1 -0
  9. package/dist/{chat-bXaRWel7.js → chat-CEh6RygY.js} +1957 -1137
  10. package/dist/chat-CEh6RygY.js.map +1 -0
  11. package/dist/chat-messages.d.ts +11 -5
  12. package/dist/chat.cjs +1 -1
  13. package/dist/chat.d.ts +4 -3
  14. package/dist/chat.js +8 -6
  15. package/dist/elements/authui-base.d.ts +2 -0
  16. package/dist/elements/authui-buttons.d.ts +1 -1
  17. package/dist/elements/authui-display.d.ts +1 -1
  18. package/dist/elements/authui.d.ts +5 -1
  19. package/dist/elements/chat.d.ts +153 -10
  20. package/dist/elements/uploader.d.ts +14 -0
  21. package/dist/{files-BOwtpYyQ.js → files-DDJWPzZW.js} +82 -35
  22. package/dist/files-DDJWPzZW.js.map +1 -0
  23. package/dist/files-DyxcjZsx.cjs +75 -0
  24. package/dist/files-DyxcjZsx.cjs.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +24 -22
  27. package/dist/singlebase-elements.min.js +3799 -2892
  28. package/dist/singlebase-elements.min.js.map +1 -1
  29. package/dist/styles/branding.d.ts +5 -0
  30. package/dist/styles/tokens.d.ts +2 -0
  31. package/dist/{uploader-DGV2y9uT.cjs → uploader-660JIgIN.cjs} +53 -76
  32. package/dist/uploader-660JIgIN.cjs.map +1 -0
  33. package/dist/{uploader-abQoem5q.js → uploader-vfczkX51.js} +294 -271
  34. package/dist/uploader-vfczkX51.js.map +1 -0
  35. package/dist/uploader.cjs +1 -1
  36. package/dist/uploader.js +2 -2
  37. package/dist/utils/branding.d.ts +8 -0
  38. package/dist/utils/markdown.d.ts +69 -12
  39. package/dist/utils/svg.d.ts +10 -0
  40. package/package.json +3 -3
  41. package/dist/authui-display-BCZBP7HR.js.map +0 -1
  42. package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
  43. package/dist/chat-DRenTJlI.cjs +0 -3001
  44. package/dist/chat-DRenTJlI.cjs.map +0 -1
  45. package/dist/chat-bXaRWel7.js.map +0 -1
  46. package/dist/files-BOwtpYyQ.js.map +0 -1
  47. package/dist/files-DW8A4Jl-.cjs +0 -38
  48. package/dist/files-DW8A4Jl-.cjs.map +0 -1
  49. package/dist/uploader-DGV2y9uT.cjs.map +0 -1
  50. package/dist/uploader-abQoem5q.js.map +0 -1
@@ -1,15 +1,15 @@
1
- var gt = Object.defineProperty;
2
- var qe = (n) => {
1
+ var Ft = Object.defineProperty;
2
+ var bt = (n) => {
3
3
  throw TypeError(n);
4
4
  };
5
- var mt = (n, e, t) => e in n ? gt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
- var T = (n, e, t) => mt(n, typeof e != "symbol" ? e + "" : e, t), Ge = (n, e, t) => e.has(n) || qe("Cannot " + t);
7
- var p = (n, e, t) => (Ge(n, e, "read from private field"), t ? t.call(n) : e.get(n)), h = (n, e, t) => e.has(n) ? qe("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), u = (n, e, t, i) => (Ge(n, e, "write to private field"), i ? i.call(n, t) : e.set(n, t), t);
8
- import { css as bt, LitElement as ft, html as r, nothing as m, svg as $ } from "lit";
9
- import { property as w, state as v, customElement as xt } from "lit/decorators.js";
10
- import { repeat as vt } from "lit/directives/repeat.js";
11
- import { getDefaultClient as yt } from "@singlebase/core";
12
- import { f as z, a as Ve, t as kt } from "./files-BOwtpYyQ.js";
5
+ var Ut = (n, e, t) => e in n ? Ft(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
6
+ var M = (n, e, t) => Ut(n, typeof e != "symbol" ? e + "" : e, t), xt = (n, e, t) => e.has(n) || bt("Cannot " + t);
7
+ var p = (n, e, t) => (xt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), h = (n, e, t) => e.has(n) ? bt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), u = (n, e, t, s) => (xt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
8
+ import { css as Pt, LitElement as Kt, html as o, nothing as f, svg as I } from "lit";
9
+ import { property as v, state as y, customElement as Wt } from "lit/decorators.js";
10
+ import { repeat as Jt } from "lit/directives/repeat.js";
11
+ import { getDefaultClient as Ht } from "@singlebase/core";
12
+ import { a as L, e as vt, j as Gt, t as qt, b as Vt } from "./files-DDJWPzZW.js";
13
13
  if (typeof CSS < "u" && "registerProperty" in CSS)
14
14
  try {
15
15
  CSS.registerProperty({
@@ -20,7 +20,7 @@ if (typeof CSS < "u" && "registerProperty" in CSS)
20
20
  });
21
21
  } catch {
22
22
  }
23
- const wt = bt`
23
+ const Xt = Pt`
24
24
  :host {
25
25
  --c-ink: var(--sb-ink, #16181a);
26
26
  --c-ink2: var(--sb-ink-2, #41464b);
@@ -37,7 +37,7 @@ const wt = bt`
37
37
  --c-danger: var(--sb-danger, #b4231a);
38
38
  --c-ok: var(--sb-ok, #0f6b4a);
39
39
  --c-mono: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
40
- --c-r: var(--sb-radius, 4px);
40
+ --c-r: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
41
41
  --c-r2: calc(var(--c-r) * 1.5);
42
42
  --c-r3: calc(var(--c-r) * 2);
43
43
  --c-r4: calc(var(--c-r) * 3);
@@ -482,6 +482,17 @@ const wt = bt`
482
482
  outline: none;
483
483
  }
484
484
 
485
+ .side-extra {
486
+ display: none;
487
+ }
488
+
489
+ .side-extra.filled {
490
+ display: block;
491
+ padding: 12px 16px;
492
+ border-top: 1px solid var(--c-line);
493
+ font-size: 12.5px;
494
+ }
495
+
485
496
  .side-note {
486
497
  font-size: 12.5px;
487
498
  color: var(--c-muted);
@@ -654,6 +665,21 @@ const wt = bt`
654
665
 
655
666
  /* ── welcome ──────────────────────────────────────────── */
656
667
 
668
+ .welcome-slot {
669
+ min-height: 100%;
670
+ display: flex;
671
+ flex-direction: column;
672
+ justify-content: center;
673
+ }
674
+
675
+ ::slotted([slot="welcome"]) {
676
+ box-sizing: border-box;
677
+ width: 100%;
678
+ max-width: 640px;
679
+ margin: 0 auto;
680
+ padding: 28px 18px;
681
+ }
682
+
657
683
  .welcome {
658
684
  max-width: 640px;
659
685
  min-height: 100%;
@@ -1050,6 +1076,168 @@ const wt = bt`
1050
1076
  padding: 1px 5px;
1051
1077
  }
1052
1078
 
1079
+ .answer h3.h1 {
1080
+ font-size: 18px;
1081
+ }
1082
+
1083
+ .answer h3.h2 {
1084
+ font-size: 16.5px;
1085
+ }
1086
+
1087
+ .answer h3.h4 {
1088
+ font-size: 14.5px;
1089
+ }
1090
+
1091
+ .answer hr {
1092
+ width: 100%;
1093
+ border: none;
1094
+ border-top: 1px solid var(--c-line);
1095
+ margin: 4px 0;
1096
+ }
1097
+
1098
+ .answer li.task {
1099
+ list-style: none;
1100
+ margin-left: -18px;
1101
+ }
1102
+
1103
+ .answer li.task input {
1104
+ margin: 0 6px 0 0;
1105
+ vertical-align: -1px;
1106
+ accent-color: var(--c-brand);
1107
+ }
1108
+
1109
+ .callout {
1110
+ display: flex;
1111
+ flex-direction: column;
1112
+ gap: 4px;
1113
+ font-size: 13.5px;
1114
+ line-height: 1.6;
1115
+ padding: 10px 14px;
1116
+ border: 1px solid var(--c-line);
1117
+ border-left: 3px solid var(--callout, var(--c-ink));
1118
+ border-radius: var(--c-r2);
1119
+ background: color-mix(in srgb, var(--callout, var(--c-ink)) 7%, var(--c-bg));
1120
+ }
1121
+
1122
+ .callout-title {
1123
+ font-weight: 600;
1124
+ color: var(--callout, var(--c-ink));
1125
+ }
1126
+
1127
+ .callout.note {
1128
+ --callout: oklch(0.55 0.15 255);
1129
+ }
1130
+
1131
+ .callout.tip {
1132
+ --callout: oklch(0.55 0.12 160);
1133
+ }
1134
+
1135
+ .callout.important {
1136
+ --callout: oklch(0.52 0.17 300);
1137
+ }
1138
+
1139
+ .callout.warning {
1140
+ --callout: oklch(0.6 0.14 70);
1141
+ }
1142
+
1143
+ .callout.caution {
1144
+ --callout: var(--c-danger);
1145
+ }
1146
+
1147
+ .jtree {
1148
+ padding: 10px 14px;
1149
+ overflow-x: auto;
1150
+ font-family: var(--c-mono);
1151
+ font-size: 12.5px;
1152
+ line-height: 1.7;
1153
+ }
1154
+
1155
+ .jtree summary {
1156
+ cursor: pointer;
1157
+ list-style-position: outside;
1158
+ }
1159
+
1160
+ .jkids {
1161
+ padding-left: 16px;
1162
+ border-left: 1px solid var(--c-line);
1163
+ margin-left: 4px;
1164
+ }
1165
+
1166
+ .jkey {
1167
+ color: var(--c-ink2);
1168
+ }
1169
+
1170
+ .jmeta {
1171
+ color: var(--c-muted);
1172
+ }
1173
+
1174
+ .jv.string {
1175
+ color: oklch(0.52 0.12 160);
1176
+ }
1177
+
1178
+ .jv.number {
1179
+ color: oklch(0.55 0.15 255);
1180
+ }
1181
+
1182
+ .jv.boolean,
1183
+ .jv.null {
1184
+ color: oklch(0.52 0.17 300);
1185
+ }
1186
+
1187
+ .table th button.sort {
1188
+ display: inline-flex;
1189
+ align-items: center;
1190
+ gap: 4px;
1191
+ font: inherit;
1192
+ color: inherit;
1193
+ background: none;
1194
+ border: none;
1195
+ padding: 0;
1196
+ cursor: pointer;
1197
+ }
1198
+
1199
+ .table th .arrow {
1200
+ font-size: 10px;
1201
+ opacity: 0.5;
1202
+ }
1203
+
1204
+ .table th[aria-sort="ascending"] .arrow,
1205
+ .table th[aria-sort="descending"] .arrow {
1206
+ opacity: 1;
1207
+ }
1208
+
1209
+ .table-note {
1210
+ padding: 7px 12px;
1211
+ font-size: 12px;
1212
+ color: var(--c-muted);
1213
+ border-top: 1px solid var(--c-line2);
1214
+ background: var(--c-bg2);
1215
+ }
1216
+
1217
+ figure.svg {
1218
+ margin: 0;
1219
+ display: flex;
1220
+ flex-direction: column;
1221
+ gap: 6px;
1222
+ align-items: flex-start;
1223
+ }
1224
+
1225
+ figure.svg img {
1226
+ display: block;
1227
+ width: min(100%, 480px);
1228
+ height: auto;
1229
+ max-height: 420px;
1230
+ object-fit: contain;
1231
+ padding: 12px;
1232
+ border: 1px solid var(--c-line);
1233
+ border-radius: var(--c-r2);
1234
+ background: #ffffff;
1235
+ }
1236
+
1237
+ .custom-block {
1238
+ min-width: 0;
1239
+ }
1240
+
1053
1241
  .quote {
1054
1242
  font-size: 13.5px;
1055
1243
  line-height: 1.6;
@@ -1707,6 +1895,10 @@ const wt = bt`
1707
1895
  padding: 0 12px 12px;
1708
1896
  }
1709
1897
 
1898
+ .composer-wrap.reader {
1899
+ padding-top: 10px;
1900
+ }
1901
+
1710
1902
  .composer-col {
1711
1903
  max-width: 760px;
1712
1904
  margin: 0 auto;
@@ -1891,8 +2083,7 @@ const wt = bt`
1891
2083
  color: var(--c-danger);
1892
2084
  }
1893
2085
 
1894
- .footnote,
1895
- .branding {
2086
+ .footnote {
1896
2087
  text-align: center;
1897
2088
  font-size: 11.5px;
1898
2089
  color: var(--c-muted);
@@ -1903,19 +2094,6 @@ const wt = bt`
1903
2094
  margin-top: -4px;
1904
2095
  }
1905
2096
 
1906
- .branding a {
1907
- font-family: var(--c-mono);
1908
- font-size: 10.5px;
1909
- letter-spacing: 0.06em;
1910
- text-transform: uppercase;
1911
- color: var(--c-muted);
1912
- text-decoration: none;
1913
- }
1914
-
1915
- .branding a:hover {
1916
- color: var(--c-ink);
1917
- }
1918
-
1919
2097
  .toast {
1920
2098
  position: absolute;
1921
2099
  left: 50%;
@@ -2273,19 +2451,15 @@ const wt = bt`
2273
2451
  height: auto;
2274
2452
  }
2275
2453
  }
2276
- `, $t = {
2454
+ `, Yt = {
2277
2455
  eyebrowChat: "Chat",
2278
2456
  eyebrowRag: "Grounded answers",
2279
- eyebrowRich: "Charts · tables · images",
2280
2457
  headingChat: "What can I help with?",
2281
2458
  headingRag: "Ask your knowledge base",
2282
- headingRich: "Ask for a chart or a table",
2283
2459
  descriptionChat: "Ask anything. Attach text files to give it more context.",
2284
2460
  descriptionRag: "Answers are grounded in your sources, with a citation for every claim. Attach text files to search them too.",
2285
- descriptionRich: "Answers come back with charts, tables and images when they help. Attach CSV or JSON files to use your own data.",
2286
2461
  placeholderChat: "Message {name}…",
2287
2462
  placeholderRag: "Ask about your sources…",
2288
- placeholderRich: "Ask for a chart, table or breakdown…",
2289
2463
  footnote: "{name} can make mistakes. Check important details.",
2290
2464
  attach: "Attach files",
2291
2465
  send: "Send message",
@@ -2295,7 +2469,6 @@ const wt = bt`
2295
2469
  dropSub: "Text, Markdown, CSV and JSON files are added as context.",
2296
2470
  thinking: "Thinking",
2297
2471
  searching: "Searching sources",
2298
- building: "Building charts and tables",
2299
2472
  chats: "Chats",
2300
2473
  newChat: "New chat",
2301
2474
  searchChats: "Search chats",
@@ -2350,6 +2523,17 @@ const wt = bt`
2350
2523
  copyReference: "Copy passage with reference",
2351
2524
  alsoCited: "Also cited",
2352
2525
  close: "Close",
2526
+ renderingChart: "Rendering chart",
2527
+ renderingSvg: "Rendering drawing",
2528
+ copySvg: "Copy SVG",
2529
+ showRaw: "View raw",
2530
+ showFormatted: "View formatted",
2531
+ showingRows: "Showing {n} of {total} rows",
2532
+ calloutNote: "Note",
2533
+ calloutTip: "Tip",
2534
+ calloutImportant: "Important",
2535
+ calloutWarning: "Warning",
2536
+ calloutCaution: "Caution",
2353
2537
  undo: "Undo",
2354
2538
  chatDeleted: "Chat deleted",
2355
2539
  messageDeleted: "Message deleted",
@@ -2374,70 +2558,128 @@ const wt = bt`
2374
2558
  dismiss: "Dismiss",
2375
2559
  brandingLabel: "Chat by Singlebase"
2376
2560
  };
2377
- function Tt(n) {
2378
- return { ...$t, ...n ?? {} };
2561
+ function Qt(n) {
2562
+ return { ...Yt, ...n ?? {} };
2379
2563
  }
2380
- const Ct = /^\|.*\|$/, St = /^\|[\s:|-]+\|$/, Xe = /^!\[([^\]]*)\]\(([^)]*)\)$/, Ye = /^([-*]|\d+\.)\s+/;
2381
- function zt(n) {
2564
+ const Zt = /^\|.*\|$/, wt = /^\|[\s:|-]+\|$/, yt = /^!\[([^\]]*)\]\(([^)]*)\)$/, kt = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, $t = /^\[( |x|X)\]\s+/, es = /^(-{3,}|\*{3,}|_{3,})$/, ts = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i, ss = ["note", "tip", "important", "warning", "caution"];
2565
+ function is(n) {
2382
2566
  const e = [], t = (n ?? "").replace(/\r/g, "").split("```");
2383
- return t.forEach((i, s) => {
2384
- if (s % 2 === 1) {
2385
- const a = i.indexOf(`
2386
- `), o = (a > -1 ? i.slice(0, a) : i).trim().toLowerCase(), l = (a > -1 ? i.slice(a + 1) : "").replace(/\n$/, ""), c = s === t.length - 1;
2387
- if (o === "chart") {
2388
- const x = c ? null : Ot(l);
2389
- e.push(x ? { type: "chart", spec: x } : { type: "chartPending" });
2390
- } else
2391
- e.push({ type: "code", lang: o || "code", text: l });
2567
+ return t.forEach((s, i) => {
2568
+ if (i % 2 === 1) {
2569
+ const a = s.indexOf(`
2570
+ `), r = (a > -1 ? s.slice(0, a) : s).trim(), l = (a > -1 ? s.slice(a + 1) : "").replace(/\n$/, "");
2571
+ e.push(as(r, l, i === t.length - 1));
2392
2572
  return;
2393
2573
  }
2394
- for (const a of i.split(/\n{2,}/)) {
2395
- const o = a.trim();
2396
- o && e.push(...pt(o));
2397
- }
2574
+ for (const a of s.split(/\n{2,}/))
2575
+ a.trim() && e.push(...Bt(a));
2398
2576
  }), e;
2399
2577
  }
2400
- function pt(n) {
2578
+ function as(n, e, t) {
2579
+ const [s = "", ...i] = n.split(/\s+/), a = s.toLowerCase();
2580
+ if (a === "chart") {
2581
+ const r = t ? null : os(e);
2582
+ return r ? { type: "chart", spec: r } : { type: "pending", kind: "chart" };
2583
+ }
2584
+ if (a === "svg")
2585
+ return t || !/<svg[\s>]/i.test(e) ? { type: "pending", kind: "svg" } : { type: "svg", source: e.trim() };
2586
+ if (!t && (a === "csv" || a === "tsv")) {
2587
+ const r = rs(e, a === "tsv" ? " " : ",");
2588
+ if (r.length > 1)
2589
+ return { type: "table", head: r[0], rows: r.slice(1), align: r[0].map(() => null) };
2590
+ }
2591
+ if (!t && a === "json")
2592
+ try {
2593
+ return { type: "json", value: JSON.parse(e), source: e };
2594
+ } catch {
2595
+ }
2596
+ if (a === "callout") {
2597
+ const r = (i[0] ?? "").toLowerCase(), l = ss.includes(r);
2598
+ return {
2599
+ type: "callout",
2600
+ kind: l ? r : "note",
2601
+ title: (l ? i.slice(1) : i).join(" "),
2602
+ text: e.trim()
2603
+ };
2604
+ }
2605
+ return { type: "code", lang: a || "code", text: e };
2606
+ }
2607
+ function Bt(n) {
2401
2608
  const e = n.split(`
2402
- `).map((i) => i.trim()).filter(Boolean);
2403
- if (e.length > 1 && e.every((i) => Ct.test(i))) {
2404
- const i = e.filter((s) => !St.test(s)).map(
2405
- (s) => s.replace(/^\||\|$/g, "").split("|").map((a) => a.trim())
2406
- );
2407
- return [{ type: "table", head: i[0] ?? [], rows: i.slice(1) }];
2609
+ `).filter((i) => i.trim()), t = e.map((i) => i.trim());
2610
+ if (t.length > 1 && t.every((i) => Zt.test(i))) {
2611
+ const i = (m) => m.replace(/^\||\|$/g, "").split("|").map((b) => b.trim()), a = t.findIndex((m) => wt.test(m)), r = a > -1 ? i(t[a]).map(
2612
+ (m) => /^:-+:$/.test(m) ? "center" : /^-+:$/.test(m) ? "right" : /^:-+$/.test(m) ? "left" : null
2613
+ ) : [], l = t.filter((m) => !wt.test(m)).map(i), c = l[0] ?? [];
2614
+ return [
2615
+ { type: "table", head: c, rows: l.slice(1), align: c.map((m, b) => r[b] ?? null) }
2616
+ ];
2408
2617
  }
2409
- if (e.every((i) => Xe.test(i)))
2618
+ if (t.length === 1 && es.test(t[0])) return [{ type: "hr" }];
2619
+ if (t.every((i) => yt.test(i)))
2410
2620
  return [
2411
2621
  {
2412
2622
  type: "img",
2413
- images: e.map((i) => {
2414
- const s = i.match(Xe);
2415
- return { alt: s[1], src: s[2] };
2623
+ images: t.map((i) => {
2624
+ const a = i.match(yt);
2625
+ return { alt: a[1], src: a[2] };
2416
2626
  })
2417
2627
  }
2418
2628
  ];
2419
- if (e.every((i) => i.startsWith(">")))
2420
- return [{ type: "quote", text: e.map((i) => i.replace(/^>\s?/, "")).join(" ") }];
2421
- if (e.every((i) => Ye.test(i)))
2422
- return [
2629
+ if (t.every((i) => i.startsWith(">"))) {
2630
+ const i = t.map((r) => r.replace(/^>\s?/, "")), a = i[0].match(ts);
2631
+ return a ? [
2423
2632
  {
2424
- type: "list",
2425
- ordered: /^\d+\./.test(e[0]),
2426
- items: e.map((i) => i.replace(Ye, ""))
2633
+ type: "callout",
2634
+ kind: a[1].toLowerCase(),
2635
+ title: a[2].trim(),
2636
+ text: i.slice(1).join(`
2637
+ `).trim()
2427
2638
  }
2428
- ];
2429
- const t = e[0].match(/^(#{1,4})\s+(.*)$/);
2430
- if (t) {
2639
+ ] : [{ type: "quote", text: i.join(" ") }];
2640
+ }
2641
+ if (kt.test(e[0])) {
2642
+ const i = [];
2643
+ for (const a of e) {
2644
+ const r = a.match(kt);
2645
+ if (r) {
2646
+ const l = r[3].match($t);
2647
+ i.push({
2648
+ text: l ? r[3].replace($t, "") : r[3],
2649
+ depth: Math.min(3, Math.floor(r[1].replace(/\t/g, " ").length / 2)),
2650
+ checked: l ? l[1] !== " " : null
2651
+ });
2652
+ } else
2653
+ i[i.length - 1].text += ` ${a.trim()}`;
2654
+ }
2655
+ return [{ type: "list", ordered: /^\s*\d/.test(e[0]), items: i }];
2656
+ }
2657
+ const s = t[0].match(/^(#{1,4})\s+(.*)$/);
2658
+ if (s) {
2431
2659
  const i = e.slice(1).join(`
2432
2660
  `);
2433
2661
  return [
2434
- { type: "h", level: t[1].length, text: t[2] },
2435
- ...i ? pt(i) : []
2662
+ { type: "h", level: s[1].length, text: s[2] },
2663
+ ...i ? Bt(i) : []
2436
2664
  ];
2437
2665
  }
2438
- return [{ type: "p", text: e.join(" ") }];
2666
+ return [{ type: "p", text: t.join(" ") }];
2439
2667
  }
2440
- function Ot(n) {
2668
+ function rs(n, e = ",") {
2669
+ var c;
2670
+ const t = [];
2671
+ let s = [], i = "", a = !1;
2672
+ const r = n.replace(/\r/g, "");
2673
+ for (let m = 0; m < r.length; m++) {
2674
+ const b = r[m];
2675
+ a ? b === '"' && r[m + 1] === '"' ? (i += '"', m++) : b === '"' ? a = !1 : i += b : b === '"' && i === "" ? a = !0 : b === e ? (s.push(i.trim()), i = "") : b === `
2676
+ ` ? (s.push(i.trim()), s.some(Boolean) && t.push(s), s = [], i = "") : i += b;
2677
+ }
2678
+ s.push(i.trim()), s.some(Boolean) && t.push(s);
2679
+ const l = ((c = t[0]) == null ? void 0 : c.length) ?? 0;
2680
+ return t.map((m) => m.length < l ? [...m, ...Array(l - m.length).fill("")] : m);
2681
+ }
2682
+ function os(n) {
2441
2683
  let e;
2442
2684
  try {
2443
2685
  e = JSON.parse(n);
@@ -2445,136 +2687,226 @@ function Ot(n) {
2445
2687
  return null;
2446
2688
  }
2447
2689
  if (!e || typeof e != "object") return null;
2448
- const t = (Array.isArray(e.series) ? e.series : []).filter((s) => s && Array.isArray(s.values)).map((s, a) => ({
2449
- name: String(s.name ?? `Series ${a + 1}`),
2450
- values: s.values.map((o) => Number(o) || 0)
2690
+ const t = (Array.isArray(e.series) ? e.series : []).filter((i) => i && Array.isArray(i.values)).map((i, a) => ({
2691
+ name: String(i.name ?? `Series ${a + 1}`),
2692
+ values: i.values.map((r) => Number(r) || 0)
2451
2693
  }));
2452
2694
  if (!t.length) return null;
2453
- const i = Array.isArray(e.labels) ? e.labels.map(String) : t[0].values.map((s, a) => String(a + 1));
2695
+ const s = Array.isArray(e.labels) ? e.labels.map(String) : t[0].values.map((i, a) => String(a + 1));
2454
2696
  return {
2455
2697
  type: e.type === "line" ? "line" : "bar",
2456
2698
  title: String(e.title ?? ""),
2457
2699
  unit: String(e.unit ?? ""),
2458
- labels: i,
2700
+ labels: s,
2459
2701
  series: t
2460
2702
  };
2461
2703
  }
2462
- const Qe = /\*\*([^*]+)\*\*|`([^`]+)`|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)|\s?\[(\d+(?:\s*,\s*\d+)*)\]/g;
2463
- function Mt(n, e = 0) {
2704
+ const Ct = new RegExp(
2705
+ [
2706
+ /\*\*([^*]+)\*\*/.source,
2707
+ // 1 bold
2708
+ /~~([^~]+)~~/.source,
2709
+ // 2 strike
2710
+ /`([^`]+)`/.source,
2711
+ // 3 code
2712
+ /\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/.source,
2713
+ // 4, 5 link
2714
+ /(https?:\/\/[^\s<>()]*[^\s<>().,;:!?'"\]])/.source,
2715
+ // 6 bare link
2716
+ new RegExp("(?<![\\w*])\\*(?![\\s*])([^*\\n]+?)\\*(?![\\w*])").source,
2717
+ // 7 *italic*
2718
+ new RegExp("(?<![\\w_])_(?![\\s_])([^_\\n]+?)_(?![\\w_])").source,
2719
+ // 8 _italic_
2720
+ /\s?\[(\d+(?:\s*,\s*\d+)*)\]/.source
2721
+ // 9 citation
2722
+ ].join("|"),
2723
+ "g"
2724
+ );
2725
+ function ns(n, e = 0) {
2464
2726
  const t = [];
2465
- let i = 0, s;
2466
- Qe.lastIndex = 0;
2467
- const a = (o) => {
2468
- if (!o) return;
2727
+ let s = 0, i;
2728
+ Ct.lastIndex = 0;
2729
+ const a = (r) => {
2730
+ if (!r) return;
2469
2731
  const l = t[t.length - 1];
2470
- (l == null ? void 0 : l.type) === "text" ? l.text += o : t.push({ type: "text", text: o });
2732
+ (l == null ? void 0 : l.type) === "text" ? l.text += r : t.push({ type: "text", text: r });
2471
2733
  };
2472
- for (; s = Qe.exec(n); ) {
2473
- if (a(n.slice(i, s.index)), s[1] !== void 0) t.push({ type: "bold", text: s[1] });
2474
- else if (s[2] !== void 0) t.push({ type: "code", text: s[2] });
2475
- else if (s[3] !== void 0) t.push({ type: "link", text: s[3], href: s[4] });
2734
+ for (; i = Ct.exec(n); ) {
2735
+ if (a(n.slice(s, i.index)), i[1] !== void 0) t.push({ type: "bold", text: i[1] });
2736
+ else if (i[2] !== void 0) t.push({ type: "strike", text: i[2] });
2737
+ else if (i[3] !== void 0) t.push({ type: "code", text: i[3] });
2738
+ else if (i[4] !== void 0) t.push({ type: "link", text: i[4], href: i[5] });
2739
+ else if (i[6] !== void 0) t.push({ type: "link", text: i[6], href: i[6] });
2740
+ else if (i[7] !== void 0) t.push({ type: "italic", text: i[7] });
2741
+ else if (i[8] !== void 0) t.push({ type: "italic", text: i[8] });
2476
2742
  else {
2477
- const l = s[5].split(",").map((c) => Number(c.trim())).filter((c) => c >= 1 && c <= e);
2478
- e ? l.forEach((c) => t.push({ type: "cite", n: c })) : a(s[0]);
2743
+ const l = i[9].split(",").map((c) => Number(c.trim())).filter((c) => c >= 1 && c <= e);
2744
+ e ? l.forEach((c) => t.push({ type: "cite", n: c })) : a(i[0]);
2479
2745
  }
2480
- i = s.index + s[0].length;
2746
+ s = i.index + i[0].length;
2481
2747
  }
2482
- return a(n.slice(i)), t;
2748
+ return a(n.slice(s)), t;
2749
+ }
2750
+ function ls(n) {
2751
+ if (((n ?? "").match(/```/g) ?? []).length % 2 === 1) return n;
2752
+ const e = n.lastIndexOf(`
2753
+
2754
+ `), t = e > -1 ? n.slice(0, e + 2) : "";
2755
+ let s = e > -1 ? n.slice(e + 2) : n;
2756
+ const i = s.split(`
2757
+ `), a = i[i.length - 1];
2758
+ a.trimStart().startsWith("|") && !a.trimEnd().endsWith("|") && i.pop(), s = i.join(`
2759
+ `), s = s.replace(/!?\[[^\]\n]*(\]\([^)\n]*)?$/, "");
2760
+ for (const r of ["**", "~~", "`"])
2761
+ if ((s.split(r).length - 1) % 2 === 1) {
2762
+ const c = s.lastIndexOf(r);
2763
+ s = s.slice(0, c) + s.slice(c + r.length);
2764
+ }
2765
+ return t + s;
2483
2766
  }
2484
- function Ze(n) {
2767
+ function Tt(n) {
2485
2768
  const e = /* @__PURE__ */ new Set();
2486
2769
  for (const t of (n ?? "").match(/\[(\d+(?:\s*,\s*\d+)*)\]/g) ?? [])
2487
- t.replace(/[[\]]/g, "").split(",").forEach((i) => e.add(Number(i.trim())));
2770
+ t.replace(/[[\]]/g, "").split(",").forEach((s) => e.add(Number(s.trim())));
2488
2771
  return e;
2489
2772
  }
2490
- function et(n) {
2491
- return {
2492
- head: ["", ...n.series.map((e) => e.name)],
2493
- rows: n.labels.map((e, t) => [
2773
+ function cs(n) {
2774
+ return [
2775
+ ["", ...n.series.map((e) => e.name)],
2776
+ ...n.labels.map((e, t) => [
2494
2777
  e,
2495
- ...n.series.map((i) => i.values[t] === void 0 ? "" : `${i.values[t]}${n.unit}`)
2778
+ ...n.series.map((s) => s.values[t] === void 0 ? "" : `${s.values[t]}${n.unit}`)
2496
2779
  ])
2497
- };
2780
+ ];
2498
2781
  }
2499
- const He = (n) => n.replace(/\*\*/g, "").replace(/`/g, "").replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, "$1");
2500
- function _t(n, e) {
2501
- if (e === "markdown")
2502
- return n.flatMap((t) => {
2503
- if (t.type === "chart") {
2504
- const i = et(t.spec);
2505
- return [
2506
- ...t.spec.title ? [{ type: "p", text: `**${t.spec.title}**` }] : [],
2507
- { type: "table", ...i }
2508
- ];
2509
- }
2510
- return t.type === "img" ? t.images.map((i) => ({
2511
- type: "p",
2512
- text: `Image: ${i.alt || "untitled"}`
2513
- })) : [t];
2514
- });
2515
- if (e === "text") {
2516
- const t = n.map((i) => {
2517
- switch (i.type) {
2518
- case "chart": {
2519
- const s = et(i.spec);
2520
- return [i.spec.title, ...[s.head, ...s.rows].map((a) => a.join(" · "))].filter(Boolean).join(`
2521
- `);
2522
- }
2523
- case "chartPending":
2524
- return "";
2525
- case "img":
2526
- return i.images.map((s) => `Image: ${s.alt || "untitled"}`).join(`
2527
- `);
2528
- case "table":
2529
- return [i.head, ...i.rows].map((s) => s.map(He).join(" · ")).join(`
2530
- `);
2531
- case "list":
2532
- return i.items.map((s) => `- ${He(s)}`).join(`
2533
- `);
2534
- case "code":
2535
- case "raw":
2536
- return i.text;
2537
- default:
2538
- return He(i.text);
2782
+ const St = (n) => n.map((e) => e.join(" · ")).join(`
2783
+ `), ds = {
2784
+ note: "Note",
2785
+ tip: "Tip",
2786
+ important: "Important",
2787
+ warning: "Warning",
2788
+ caution: "Caution"
2789
+ };
2790
+ function ps(n, e) {
2791
+ if (e === "rich") return n;
2792
+ const t = e === "plain";
2793
+ return n.map((s) => {
2794
+ switch (s.type) {
2795
+ case "chart": {
2796
+ const [i, ...a] = cs(s.spec);
2797
+ return t ? {
2798
+ type: "raw",
2799
+ text: [s.spec.title, St([i, ...a])].filter(Boolean).join(`
2800
+ `)
2801
+ } : {
2802
+ type: "table",
2803
+ head: s.spec.title ? [s.spec.title, ...i.slice(1)] : i,
2804
+ rows: a,
2805
+ align: i.map(() => null)
2806
+ };
2539
2807
  }
2540
- }).filter(Boolean).join(`
2541
-
2542
- `);
2543
- return t ? [{ type: "raw", text: t }] : [];
2544
- }
2545
- return n;
2808
+ case "pending":
2809
+ return s.kind === "svg" && !t ? s : { type: "raw", text: "" };
2810
+ case "callout":
2811
+ return {
2812
+ type: "quote",
2813
+ text: `**${s.title || ds[s.kind]}** ${s.text}`.trim()
2814
+ };
2815
+ case "img":
2816
+ return {
2817
+ type: "p",
2818
+ text: s.images.map((i) => `Image: ${i.alt || "untitled"}`).join(" · ")
2819
+ };
2820
+ case "table":
2821
+ return t ? { type: "raw", text: St([s.head, ...s.rows]) } : s;
2822
+ case "json":
2823
+ return t ? { type: "code", lang: "json", text: s.source } : s;
2824
+ case "svg":
2825
+ return t ? { type: "code", lang: "svg", text: s.source } : s;
2826
+ default:
2827
+ return s;
2828
+ }
2829
+ });
2546
2830
  }
2547
- function tt(n) {
2831
+ function Ot(n) {
2548
2832
  const e = n ?? "", t = e.search(/FOLLOWUPS:/i);
2549
2833
  if (t < 0) return { text: e.trim(), followups: [] };
2550
- const s = e.slice(t).replace(/^FOLLOWUPS:/i, "").split(/\||\n/).map((a) => a.replace(/^\s*(?:[-*↳→]|\d+[.)])\s*/, "").trim()).filter(Boolean).slice(0, 3);
2551
- return { text: e.slice(0, t).trim(), followups: s };
2834
+ const i = e.slice(t).replace(/^FOLLOWUPS:/i, "").split(/\||\n/).map((a) => a.replace(/^\s*(?:[-*↳→]|\d+[.)])\s*/, "").trim()).filter(Boolean).slice(0, 3);
2835
+ return { text: e.slice(0, t).trim(), followups: i };
2552
2836
  }
2553
- function It(n) {
2554
- return (n ?? "").replace(/```(\w*)[\s\S]*?(```|$)/g, (e, t) => t === "chart" ? "[Chart] " : "[Code] ").replace(/!\[([^\]]*)\]\([^)]*\)/g, "[Image: $1]").replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, "$1").replace(/[*#>`]/g, "").replace(/\|/g, " ").replace(/\s?\[\d+(?:\s*,\s*\d+)*\]/g, "").replace(/\s+/g, " ").trim();
2837
+ function hs(n) {
2838
+ return (n ?? "").replace(
2839
+ /```(\w*)[\s\S]*?(```|$)/g,
2840
+ (e, t) => t === "chart" ? "[Chart] " : t === "svg" ? "[Drawing] " : "[Code] "
2841
+ ).replace(/!\[([^\]]*)\]\([^)]*\)/g, "[Image: $1]").replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, "$1").replace(/\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/gi, "").replace(/[*#>`~]/g, "").replace(/\|/g, " ").replace(/\s?\[\d+(?:\s*,\s*\d+)*\]/g, "").replace(/\s+/g, " ").trim();
2555
2842
  }
2556
- function Lt(n, e = 48) {
2557
- const t = It(n);
2843
+ function us(n, e = 48) {
2844
+ const t = hs(n);
2558
2845
  if (t.length <= e) return t;
2559
- const i = t.slice(0, e), s = i.lastIndexOf(" ");
2560
- return (s > e / 2 ? i.slice(0, s) : i).trim();
2846
+ const s = t.slice(0, e), i = s.lastIndexOf(" ");
2847
+ return (i > e / 2 ? s.slice(0, i) : s).trim();
2561
2848
  }
2562
- function jt(n) {
2849
+ function gs(n) {
2563
2850
  return String(n ?? "").split(`
2564
2851
  `)[0].trim().replace(/^["'“”‘’]+|["'“”‘’]+$/g, "").replace(/^title:\s*/i, "").replace(/[.!?:;,]+$/, "").trim().slice(0, 80);
2565
2852
  }
2566
- function it(n, e = !1) {
2853
+ function It(n, e = !1) {
2567
2854
  return /^https?:\/\//i.test(n) ? !0 : e && /^(blob:|data:image\/)/i.test(n);
2568
2855
  }
2569
- var ht = Object.defineProperty, At = Object.getOwnPropertyDescriptor, Et = (n, e, t) => e in n ? ht(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t, i) => {
2570
- for (var s = i > 1 ? void 0 : i ? At(e, t) : e, a = n.length - 1, o; a >= 0; a--)
2571
- (o = n[a]) && (s = (i ? o(e, t, s) : o(s)) || s);
2572
- return i && s && ht(e, t, s), s;
2573
- }, Nt = (n, e, t) => Et(n, e + "", t);
2574
- const st = [
2856
+ const ms = 2e5, fs = /* @__PURE__ */ new Set([
2857
+ "script",
2858
+ "foreignobject",
2859
+ "iframe",
2860
+ "object",
2861
+ "embed",
2862
+ "image",
2863
+ "audio",
2864
+ "video",
2865
+ "animate",
2866
+ "set",
2867
+ "animatemotion",
2868
+ "animatetransform",
2869
+ "handler",
2870
+ "listener"
2871
+ ]);
2872
+ function bs(n) {
2873
+ if (!n || n.length > ms || typeof DOMParser > "u") return null;
2874
+ const e = new DOMParser().parseFromString(n, "image/svg+xml"), t = e.documentElement;
2875
+ if (!t || t.nodeName.toLowerCase() !== "svg" || e.querySelector("parsererror"))
2876
+ return null;
2877
+ const s = (a) => {
2878
+ for (const r of Array.from(a.children)) {
2879
+ const l = r.nodeName.toLowerCase();
2880
+ if (fs.has(l)) r.remove();
2881
+ else if (l === "a") {
2882
+ const c = Array.from(r.childNodes);
2883
+ r.replaceWith(...c), c.forEach((m) => m instanceof Element && s(m));
2884
+ } else s(r);
2885
+ }
2886
+ for (const r of Array.from(a.attributes)) {
2887
+ const l = r.name.toLowerCase(), c = r.value.trim().toLowerCase(), m = (l === "href" || l.endsWith(":href")) && !c.startsWith("#"), b = c.includes("javascript:") || /url\(\s*['"]?(?!#)/.test(c);
2888
+ (l.startsWith("on") || m || b) && a.removeAttribute(r.name);
2889
+ }
2890
+ };
2891
+ s(t);
2892
+ for (const a of Array.from(t.querySelectorAll("style")))
2893
+ a.textContent = (a.textContent ?? "").replace(/@import[^;]*;?/gi, "").replace(/url\(\s*['"]?(?!#)[^)]*\)/gi, "none");
2894
+ t.setAttribute("xmlns", "http://www.w3.org/2000/svg");
2895
+ const i = new XMLSerializer().serializeToString(t);
2896
+ return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;
2897
+ }
2898
+ var Dt = Object.defineProperty, xs = Object.getOwnPropertyDescriptor, vs = (n, e, t) => e in n ? Dt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t, s) => {
2899
+ for (var i = s > 1 ? void 0 : s ? xs(e, t) : e, a = n.length - 1, r; a >= 0; a--)
2900
+ (r = n[a]) && (i = (s ? r(e, t, i) : r(i)) || i);
2901
+ return s && i && Dt(e, t, i), i;
2902
+ }, ws = (n, e, t) => vs(n, e + "", t);
2903
+ const Mt = [
2575
2904
  "embed",
2576
2905
  "mode",
2577
- "renderAs",
2906
+ "format",
2907
+ "renderers",
2908
+ "beforeSend",
2909
+ "afterParse",
2578
2910
  "glow",
2579
2911
  "position",
2580
2912
  "sidebar",
@@ -2583,14 +2915,32 @@ const st = [
2583
2915
  "logoUrl",
2584
2916
  "heading",
2585
2917
  "description",
2918
+ "eyebrow",
2586
2919
  "prompts",
2587
2920
  "bubbleText",
2588
2921
  "greetingBubble",
2589
2922
  "unreadBadge",
2590
2923
  "allowUpload",
2591
2924
  "allowExport",
2925
+ "allowRaw",
2926
+ "allowCopy",
2927
+ "allowRegenerate",
2928
+ "allowBookmark",
2929
+ "allowDelete",
2930
+ "allowRename",
2931
+ "allowFeedback",
2932
+ "showTime",
2933
+ "showComposer",
2934
+ "footnote",
2935
+ "brandingText",
2936
+ "brandingUrl",
2592
2937
  "branding",
2593
2938
  "followups",
2939
+ "showFollowups",
2940
+ "showSources",
2941
+ "showNewChat",
2942
+ "showBookmarked",
2943
+ "allowSearch",
2594
2944
  "autoTitle",
2595
2945
  "model",
2596
2946
  "params",
@@ -2598,8 +2948,9 @@ const st = [
2598
2948
  "retrieval",
2599
2949
  "metadata",
2600
2950
  "messages",
2601
- "theme"
2602
- ], We = {
2951
+ "theme",
2952
+ "radius"
2953
+ ], ft = {
2603
2954
  fromAttribute: (n) => {
2604
2955
  if (n)
2605
2956
  try {
@@ -2610,22 +2961,32 @@ const st = [
2610
2961
  }
2611
2962
  },
2612
2963
  toAttribute: (n) => JSON.stringify(n ?? null)
2613
- }, I = {
2964
+ }, O = {
2614
2965
  fromAttribute: (n) => n === null ? !0 : n !== "false",
2615
2966
  toAttribute: (n) => n ? null : "false"
2616
- }, Bt = {
2617
- fromAttribute: (n) => n === null ? void 0 : n !== "false",
2618
- toAttribute: (n) => n === void 0 ? null : String(n)
2619
- }, Dt = 272, Rt = 820, Ut = 940, at = 5, rt = 512 * 1024, Ft = /\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i, Kt = 5e3, Pt = 2600, _ = [
2967
+ }, ys = {
2968
+ fromAttribute: (n) => n === null ? "auto" : n === "" || n === "true" ? "open" : n === "false" ? "closed" : ["auto", "open", "closed", "none"].includes(n) ? n : "auto",
2969
+ toAttribute: (n) => n === "auto" ? null : n
2970
+ }, ks = 272, $s = 820, Cs = 940, zt = 5, _t = 512 * 1024, Ts = /\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i, Ss = 5e3, Os = 200, Lt = 2e3, Is = {
2971
+ note: "calloutNote",
2972
+ tip: "calloutTip",
2973
+ important: "calloutImportant",
2974
+ warning: "calloutWarning",
2975
+ caution: "calloutCaution"
2976
+ }, Ms = 2600, N = [
2620
2977
  "var(--c-ink)",
2621
2978
  "oklch(0.58 0.13 255)",
2622
2979
  "oklch(0.63 0.1 175)",
2623
2980
  "oklch(0.74 0.12 70)"
2624
- ], nt = {
2981
+ ], jt = {
2625
2982
  chat: "Be helpful and concise. Use Markdown when it helps: headings, lists, **bold**, code blocks and tables.",
2626
- rag: "Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim it supports. If the sources don't cover the question, say so plainly.",
2627
- rich: 'Lead with one sentence stating the key finding, with key numbers in **bold**. For trends and comparisons, include a chart as a fenced code block with the language "chart" containing only JSON: {"type":"bar"|"line","title":string,"unit":string,"labels":[string],"series":[{"name":string,"values":[number]}]}. Use Markdown tables for exact values. Keep prose short.'
2628
- }, Ht = "After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.", ot = {
2983
+ rag: "Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim it supports. If the sources don't cover the question, say so plainly."
2984
+ }, zs = {
2985
+ raw: "Reply in plain text. Don't use Markdown or any other markup.",
2986
+ plain: "Format with light Markdown only: short paragraphs, lists, **bold**, *italics*, `inline code`, code blocks and links. Don't use tables, charts, callouts, images or other special blocks.",
2987
+ advanced: `You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. Don't use charts, callouts or images.`,
2988
+ rich: 'When the answer is about data, lead with one sentence stating the key finding, with key numbers in **bold**, then show the data visually. You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. For trends and comparisons, use a fenced "chart" block containing only JSON: {"type":"bar"|"line","title":string,"unit":string,"labels":[string],"series":[{"name":string,"values":[number]}]}. For notes and warnings, use callouts: a quote starting with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION]. Images use ![alt](https://…).'
2989
+ }, _s = "After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.", Nt = {
2629
2990
  chat: [
2630
2991
  ["Write", "Draft a short welcome email for new users"],
2631
2992
  ["Explain", "Explain how refresh tokens work, simply"],
@@ -2637,27 +2998,22 @@ const st = [
2637
2998
  ["Summarize", "Summarize the most important points"],
2638
2999
  ["Find", "Where is the refund policy described?"],
2639
3000
  ["Explain", "Explain the setup steps in plain language"]
2640
- ],
2641
- rich: [
2642
- ["Bar chart", "Compare the five most spoken languages in a bar chart"],
2643
- ["Line chart", "Show world population from 1950 to 2020"],
2644
- ["Table", "List the planets with their diameters in a table"],
2645
- ["Breakdown", "Break down a $4,000 monthly budget by category"]
2646
3001
  ]
2647
- }, C = (n, e = "") => r`<svg class="i ${e}" viewBox="0 0 16 16" aria-hidden="true">${n}</svg>`, y = {
2648
- sidebar: () => C(
2649
- $`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`
3002
+ }, z = (n, e = "") => o`<svg class="i ${e}" viewBox="0 0 16 16" aria-hidden="true">${n}</svg>`, k = {
3003
+ sidebar: () => z(
3004
+ I`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`
2650
3005
  ),
2651
- plus: () => C($`<path d="M8 3v10M3 8h10"></path>`),
2652
- bookmark: (n = !1) => C($`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`, n ? "filled" : ""),
2653
- download: () => C($`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),
2654
- trash: () => C($`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),
2655
- pencil: () => C($`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),
2656
- copy: () => C(
2657
- $`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"></rect><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"></path>`
3006
+ plus: () => z(I`<path d="M8 3v10M3 8h10"></path>`),
3007
+ bookmark: (n = !1) => z(I`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`, n ? "filled" : ""),
3008
+ download: () => z(I`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),
3009
+ trash: () => z(I`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),
3010
+ pencil: () => z(I`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),
3011
+ copy: () => z(
3012
+ I`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"></rect><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"></path>`
2658
3013
  ),
2659
- refresh: () => C($`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),
2660
- thumb: (n = !1) => r`<svg
3014
+ raw: () => z(I`<path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5"></path>`),
3015
+ refresh: () => z(I`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),
3016
+ thumb: (n = !1) => o`<svg
2661
3017
  class="i"
2662
3018
  viewBox="0 0 16 16"
2663
3019
  aria-hidden="true"
@@ -2667,16 +3023,16 @@ const st = [
2667
3023
  d="M5 7v6.5H2.5V7zM5 7l2.5-4.5a1.3 1.3 0 0 1 1.9 1.4L9 6.5h3.6a1 1 0 0 1 1 1.2l-1 4.8a1 1 0 0 1-1 .8H5"
2668
3024
  ></path>
2669
3025
  </svg>`,
2670
- expand: () => C($`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),
2671
- restore: () => C($`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),
2672
- minimize: () => C($`<path d="M4 8h8"></path>`),
2673
- close: () => C($`<path d="M4 4l8 8M12 4l-8 8"></path>`),
2674
- clip: () => C(
2675
- $`<path d="M13 7.5l-5.3 5.3a3 3 0 0 1-4.3-4.3L9 2.9a2 2 0 0 1 2.9 2.9L6.4 11.3a1 1 0 0 1-1.4-1.4L10 5"></path>`
3026
+ expand: () => z(I`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),
3027
+ restore: () => z(I`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),
3028
+ minimize: () => z(I`<path d="M4 8h8"></path>`),
3029
+ close: () => z(I`<path d="M4 4l8 8M12 4l-8 8"></path>`),
3030
+ clip: () => z(
3031
+ I`<path d="M13 7.5l-5.3 5.3a3 3 0 0 1-4.3-4.3L9 2.9a2 2 0 0 1 2.9 2.9L6.4 11.3a1 1 0 0 1-1.4-1.4L10 5"></path>`
2676
3032
  ),
2677
- up: () => C($`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),
2678
- stop: () => C($`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),
2679
- chat: () => r`<svg
3033
+ up: () => z(I`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),
3034
+ stop: () => z(I`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),
3035
+ chat: () => o`<svg
2680
3036
  width="22"
2681
3037
  height="22"
2682
3038
  viewBox="0 0 22 22"
@@ -2687,7 +3043,7 @@ const st = [
2687
3043
  d="M4 5.5A2.5 2.5 0 0 1 6.5 3h9A2.5 2.5 0 0 1 18 5.5v7a2.5 2.5 0 0 1-2.5 2.5H9l-4 3.5V15H6.5"
2688
3044
  ></path>
2689
3045
  </svg>`,
2690
- chevronDown: () => r`<svg
3046
+ chevronDown: () => o`<svg
2691
3047
  width="20"
2692
3048
  height="20"
2693
3049
  viewBox="0 0 20 20"
@@ -2697,150 +3053,176 @@ const st = [
2697
3053
  <path d="M5 8l5 5 5-5"></path>
2698
3054
  </svg>`
2699
3055
  };
2700
- let Jt = 0;
2701
- const Je = () => `m${Date.now().toString(36)}${(Jt++).toString(36)}`;
2702
- function lt(n) {
3056
+ let Ls = 0;
3057
+ const mt = () => `m${Date.now().toString(36)}${(Ls++).toString(36)}`;
3058
+ function At(n) {
2703
3059
  var t;
2704
3060
  const e = n;
2705
3061
  return (e == null ? void 0 : e.message) === "NOT_FOUND" || (e == null ? void 0 : e.code) === "NOT_FOUND" || ((t = e == null ? void 0 : e.details) == null ? void 0 : t.status) === 404;
2706
3062
  }
2707
- function Wt(n) {
3063
+ function js(n) {
2708
3064
  const e = n;
2709
3065
  return (e == null ? void 0 : e.code) || (e == null ? void 0 : e.message) || "UNKNOWN";
2710
3066
  }
2711
- const qt = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, Fe = (n, e) => (Number.isInteger(n) ? n.toLocaleString("en-US") : n.toFixed(1)) + e, ct = (n) => {
3067
+ const Ns = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, ut = (n, e) => (Number.isInteger(n) ? n.toLocaleString("en-US") : n.toFixed(1)) + e, Rt = (n) => {
2712
3068
  const e = n.lastIndexOf(".");
2713
3069
  return e > 0 ? n.slice(e + 1, e + 5).toUpperCase() : "FILE";
2714
3070
  };
2715
- function Ke(n, e) {
2716
- const t = n ?? {}, i = t.metadata && typeof t.metadata == "object" ? t.metadata : {}, s = (...l) => l.find((c) => typeof c == "string" && c.trim()), a = s(t.content, t.text, t.page_content, t.body, t.snippet, t.chunk, i.content) ?? JSON.stringify(t, null, 2), o = [t.score, t.relevance, t._score, i.score].find((l) => typeof l == "number");
3071
+ function gt(n, e) {
3072
+ const t = n ?? {}, s = t.metadata && typeof t.metadata == "object" ? t.metadata : {}, i = (...l) => l.find((c) => typeof c == "string" && c.trim()), a = i(t.content, t.text, t.page_content, t.body, t.snippet, t.chunk, s.content) ?? JSON.stringify(t, null, 2), r = [t.score, t.relevance, t._score, s.score].find((l) => typeof l == "number");
2717
3073
  return {
2718
3074
  n: e,
2719
- title: s(t.title, t.name, t.filename, i.title, i.name) ?? `Source ${e}`,
2720
- path: s(t.path, t.url, t.key, t.source, i.path, i.url) ?? "",
2721
- collection: s(t.collection, t.namespace, t.dbname, i.collection) ?? "",
2722
- updated: s(t.updated, t._modified_at, i.updated) ?? "",
3075
+ title: i(t.title, t.name, t.filename, s.title, s.name) ?? `Source ${e}`,
3076
+ path: i(t.path, t.url, t.key, t.source, s.path, s.url) ?? "",
3077
+ collection: i(t.collection, t.namespace, t.dbname, s.collection) ?? "",
3078
+ updated: i(t.updated, t._modified_at, s.updated) ?? "",
2723
3079
  text: a,
2724
- score: o === void 0 ? null : Math.max(0, Math.min(1, o))
3080
+ score: r === void 0 ? null : Math.max(0, Math.min(1, r))
2725
3081
  };
2726
3082
  }
2727
- function Gt(n) {
3083
+ function As(n) {
2728
3084
  const e = [], t = [];
2729
- for (const i of n)
2730
- if (/\.csv$/i.test(i.name)) e.push({ type: "csv", data: i.content });
2731
- else if (/\.json$/i.test(i.name))
3085
+ for (const s of n)
3086
+ if (/\.csv$/i.test(s.name)) e.push({ type: "csv", data: s.content });
3087
+ else if (/\.json$/i.test(s.name))
2732
3088
  try {
2733
- e.push({ type: "json", data: JSON.parse(i.content) });
3089
+ e.push({ type: "json", data: JSON.parse(s.content) });
2734
3090
  } catch {
2735
- t.push({ title: i.name, content: i.content });
3091
+ t.push({ title: s.name, content: s.content });
2736
3092
  }
2737
- else t.push({ title: i.name, content: i.content });
3093
+ else t.push({ title: s.name, content: s.content });
2738
3094
  return t.length && e.push({ type: "docs", payload: { documents: t } }), e;
2739
3095
  }
2740
- function Pe(n) {
3096
+ function Rs(n) {
2741
3097
  const e = n ? Date.parse(n) : NaN;
2742
3098
  if (Number.isNaN(e)) return "older";
2743
3099
  const t = /* @__PURE__ */ new Date();
2744
3100
  t.setHours(0, 0, 0, 0);
2745
- const i = 864e5;
2746
- return e >= t.getTime() ? "today" : e >= t.getTime() - i ? "yesterday" : e >= t.getTime() - 7 * i ? "week" : "older";
3101
+ const s = 864e5;
3102
+ return e >= t.getTime() ? "today" : e >= t.getTime() - s ? "yesterday" : e >= t.getTime() - 7 * s ? "week" : "older";
2747
3103
  }
2748
- var j, A, E, N, B, D, R, U, F, K, P, H, J, W, q, G, V, X, Y, Q, Z, ee, te, ie, se, ae, re, ne, oe, le, ce, de, pe, he, ue, ge, me, be, fe, xe, ve, ye, ke, we, $e, Te, Ce, Se, ze, Oe, Me, _e, Ie, Le, je, Ae, Ee, Ne, Be, De, Re, dt;
2749
- let d = (dt = class extends ft {
3104
+ var A, R, E, B, D, F, U, P, K, W, J, H, G, q, V, X, Y, Q, Z, ee, te, se, ie, ae, re, oe, ne, le, ce, de, pe, he, ue, ge, me, fe, be, xe, ve, we, ye, ke, $e, Ce, Te, Se, Oe, Ie, Me, ze, _e, Le, je, Ne, Ae, Re, Ee, Be, De, Fe, Ue, Pe, Ke, We, Je, He, Ge, qe, Ve, Xe, Ye, Qe, Ze, et, tt, st, it, at, rt, ot, nt, lt, ct, dt, pt, ht, Et;
3105
+ let d = (Et = class extends Kt {
2750
3106
  constructor() {
2751
3107
  super(...arguments);
2752
- h(this, j, null);
2753
- h(this, A, {});
3108
+ h(this, A, null);
3109
+ h(this, R, {});
2754
3110
  h(this, E);
2755
- h(this, N, "chat");
2756
- h(this, B, "rich");
2757
- h(this, D, "subtle");
2758
- h(this, R, !0);
2759
- h(this, U, !0);
2760
- h(this, F, "");
2761
- h(this, K, {});
2762
- h(this, P, "");
2763
- h(this, H, []);
2764
- h(this, J, {});
2765
- h(this, W, "page");
2766
- h(this, q, "right");
2767
- h(this, G);
3111
+ h(this, B);
3112
+ h(this, D, "chat");
3113
+ h(this, F, "advanced");
3114
+ h(this, U, {});
3115
+ h(this, P, null);
3116
+ h(this, K, null);
3117
+ h(this, W, "subtle");
3118
+ h(this, J, !0);
3119
+ h(this, H, !0);
3120
+ h(this, G, !0);
3121
+ h(this, q, !0);
2768
3122
  h(this, V, !0);
2769
- h(this, X, "");
2770
- h(this, Y, "Assistant");
3123
+ h(this, X, !0);
3124
+ h(this, Y, !0);
2771
3125
  h(this, Q, "");
2772
- h(this, Z, "");
3126
+ h(this, Z, {});
2773
3127
  h(this, ee, "");
2774
- h(this, te, "");
2775
- h(this, ie, "");
2776
- h(this, se, !1);
2777
- h(this, ae, !1);
2778
- h(this, re, !0);
2779
- h(this, ne, !0);
3128
+ h(this, te, []);
3129
+ h(this, se, {});
3130
+ h(this, ie, "page");
3131
+ h(this, ae, "right");
3132
+ h(this, re, "auto");
2780
3133
  h(this, oe, !0);
2781
- h(this, le, []);
2782
- h(this, ce, "idle");
2783
- h(this, de, null);
3134
+ h(this, ne, "");
3135
+ h(this, le, "Assistant");
3136
+ h(this, ce, "");
3137
+ h(this, de, "");
2784
3138
  h(this, pe, "");
2785
- h(this, he, !1);
2786
- h(this, ue, []);
2787
- h(this, ge, !1);
2788
- h(this, me, "");
2789
- h(this, be, !1);
2790
- h(this, fe, "");
2791
- h(this, xe, []);
2792
- h(this, ve, "");
2793
- h(this, ye, null);
2794
- h(this, ke, 0);
2795
- h(this, we, null);
2796
- h(this, $e, !1);
2797
- h(this, Te, "");
2798
- h(this, Ce, "");
2799
- h(this, Se, !1);
3139
+ h(this, he);
3140
+ h(this, ue, "");
3141
+ h(this, ge, "");
3142
+ h(this, me, !1);
3143
+ h(this, fe, !1);
3144
+ h(this, be, !0);
3145
+ h(this, xe, !0);
3146
+ h(this, ve, !0);
3147
+ h(this, we, !0);
3148
+ h(this, ye, !0);
3149
+ h(this, ke, !0);
3150
+ h(this, $e, !0);
3151
+ h(this, Ce, !0);
3152
+ h(this, Te, !0);
3153
+ h(this, Se, !0);
3154
+ h(this, Oe);
3155
+ h(this, Ie, !1);
3156
+ h(this, Me, !0);
2800
3157
  h(this, ze, "");
2801
- h(this, Oe, null);
2802
- h(this, Me, "");
2803
- h(this, _e, /* @__PURE__ */ new Set());
2804
- h(this, Ie, "");
2805
- h(this, Le, !1);
2806
- h(this, je, !1);
2807
- h(this, Ae, !1);
2808
- h(this, Ee, !1);
2809
- h(this, Ne, !1);
2810
- h(this, Be, !1);
2811
- h(this, De, !1);
3158
+ h(this, _e, "");
3159
+ h(this, Le, []);
3160
+ h(this, je, "idle");
3161
+ h(this, Ne, null);
3162
+ h(this, Ae, "");
2812
3163
  h(this, Re, !1);
2813
- T(this, "run", 0);
2814
- T(this, "abort", null);
2815
- T(this, "revealTimer");
2816
- T(this, "timers", /* @__PURE__ */ new Set());
2817
- T(this, "toastTimer");
2818
- T(this, "stick", !0);
2819
- T(this, "renamed", /* @__PURE__ */ new Set());
2820
- T(this, "observer", null);
2821
- T(this, "observed", null);
2822
- T(this, "media", null);
2823
- T(this, "focusNext", "");
2824
- T(this, "bubbleScheduled", !1);
2825
- T(this, "onNetwork", () => {
3164
+ h(this, Ee, []);
3165
+ h(this, Be, !1);
3166
+ h(this, De, "");
3167
+ h(this, Fe, !1);
3168
+ h(this, Ue, "");
3169
+ h(this, Pe, []);
3170
+ h(this, Ke, "");
3171
+ h(this, We, null);
3172
+ h(this, Je, 0);
3173
+ h(this, He, null);
3174
+ h(this, Ge, !1);
3175
+ h(this, qe, "");
3176
+ h(this, Ve, "");
3177
+ h(this, Xe, !1);
3178
+ h(this, Ye, "");
3179
+ h(this, Qe, null);
3180
+ h(this, Ze, "");
3181
+ h(this, et, /* @__PURE__ */ new Set());
3182
+ h(this, tt, /* @__PURE__ */ new Set());
3183
+ h(this, st, !1);
3184
+ h(this, it, /* @__PURE__ */ new Map());
3185
+ h(this, at, "");
3186
+ h(this, rt, !1);
3187
+ h(this, ot, !1);
3188
+ h(this, nt, !1);
3189
+ h(this, lt, !1);
3190
+ h(this, ct, !1);
3191
+ h(this, dt, !1);
3192
+ h(this, pt, !1);
3193
+ h(this, ht, !1);
3194
+ M(this, "run", 0);
3195
+ M(this, "abort", null);
3196
+ M(this, "revealTimer");
3197
+ M(this, "timers", /* @__PURE__ */ new Set());
3198
+ M(this, "toastTimer");
3199
+ M(this, "stick", !0);
3200
+ M(this, "renamed", /* @__PURE__ */ new Set());
3201
+ M(this, "observer", null);
3202
+ M(this, "observed", null);
3203
+ M(this, "media", null);
3204
+ M(this, "focusNext", "");
3205
+ M(this, "bubbleScheduled", !1);
3206
+ M(this, "pendingChatId", "");
3207
+ M(this, "onNetwork", () => {
2826
3208
  this.offline = navigator.onLine === !1;
2827
3209
  });
2828
- T(this, "onMedia", () => {
3210
+ M(this, "onMedia", () => {
2829
3211
  var e;
2830
3212
  this.mobile = !!((e = this.media) != null && e.matches);
2831
3213
  });
2832
3214
  }
2833
3215
  get client() {
2834
- return p(this, j);
3216
+ return p(this, A);
2835
3217
  }
2836
3218
  set client(e) {
2837
- u(this, j, e);
3219
+ u(this, A, e);
2838
3220
  }
2839
3221
  get messages() {
2840
- return p(this, A);
3222
+ return p(this, R);
2841
3223
  }
2842
3224
  set messages(e) {
2843
- u(this, A, e);
3225
+ u(this, R, e);
2844
3226
  }
2845
3227
  get theme() {
2846
3228
  return p(this, E);
@@ -2848,360 +3230,510 @@ let d = (dt = class extends ft {
2848
3230
  set theme(e) {
2849
3231
  u(this, E, e);
2850
3232
  }
2851
- get mode() {
2852
- return p(this, N);
2853
- }
2854
- set mode(e) {
2855
- u(this, N, e);
2856
- }
2857
- get renderAs() {
3233
+ get radius() {
2858
3234
  return p(this, B);
2859
3235
  }
2860
- set renderAs(e) {
3236
+ set radius(e) {
2861
3237
  u(this, B, e);
2862
3238
  }
2863
- get glow() {
3239
+ get mode() {
2864
3240
  return p(this, D);
2865
3241
  }
2866
- set glow(e) {
3242
+ set mode(e) {
2867
3243
  u(this, D, e);
2868
3244
  }
2869
- get followups() {
2870
- return p(this, R);
3245
+ get format() {
3246
+ return p(this, F);
2871
3247
  }
2872
- set followups(e) {
2873
- u(this, R, e);
3248
+ set format(e) {
3249
+ u(this, F, e);
2874
3250
  }
2875
- get autoTitle() {
3251
+ get renderers() {
2876
3252
  return p(this, U);
2877
3253
  }
2878
- set autoTitle(e) {
3254
+ set renderers(e) {
2879
3255
  u(this, U, e);
2880
3256
  }
2881
- get model() {
2882
- return p(this, F);
3257
+ get beforeSend() {
3258
+ return p(this, P);
2883
3259
  }
2884
- set model(e) {
2885
- u(this, F, e);
3260
+ set beforeSend(e) {
3261
+ u(this, P, e);
2886
3262
  }
2887
- get params() {
3263
+ get afterParse() {
2888
3264
  return p(this, K);
2889
3265
  }
2890
- set params(e) {
3266
+ set afterParse(e) {
2891
3267
  u(this, K, e);
2892
3268
  }
2893
- get systemMessage() {
2894
- return p(this, P);
3269
+ get glow() {
3270
+ return p(this, W);
2895
3271
  }
2896
- set systemMessage(e) {
2897
- u(this, P, e);
3272
+ set glow(e) {
3273
+ u(this, W, e);
2898
3274
  }
2899
- get retrieval() {
3275
+ get followups() {
3276
+ return p(this, J);
3277
+ }
3278
+ set followups(e) {
3279
+ u(this, J, e);
3280
+ }
3281
+ get showSources() {
2900
3282
  return p(this, H);
2901
3283
  }
2902
- set retrieval(e) {
3284
+ set showSources(e) {
2903
3285
  u(this, H, e);
2904
3286
  }
2905
- get metadata() {
2906
- return p(this, J);
3287
+ get showNewChat() {
3288
+ return p(this, G);
2907
3289
  }
2908
- set metadata(e) {
2909
- u(this, J, e);
3290
+ set showNewChat(e) {
3291
+ u(this, G, e);
2910
3292
  }
2911
- get embed() {
2912
- return p(this, W);
3293
+ get showBookmarked() {
3294
+ return p(this, q);
2913
3295
  }
2914
- set embed(e) {
2915
- u(this, W, e);
3296
+ set showBookmarked(e) {
3297
+ u(this, q, e);
3298
+ }
3299
+ get showFollowups() {
3300
+ return p(this, V);
3301
+ }
3302
+ set showFollowups(e) {
3303
+ u(this, V, e);
3304
+ }
3305
+ get allowSearch() {
3306
+ return p(this, X);
3307
+ }
3308
+ set allowSearch(e) {
3309
+ u(this, X, e);
3310
+ }
3311
+ get autoTitle() {
3312
+ return p(this, Y);
3313
+ }
3314
+ set autoTitle(e) {
3315
+ u(this, Y, e);
3316
+ }
3317
+ get model() {
3318
+ return p(this, Q);
3319
+ }
3320
+ set model(e) {
3321
+ u(this, Q, e);
3322
+ }
3323
+ get params() {
3324
+ return p(this, Z);
3325
+ }
3326
+ set params(e) {
3327
+ u(this, Z, e);
3328
+ }
3329
+ get systemMessage() {
3330
+ return p(this, ee);
3331
+ }
3332
+ set systemMessage(e) {
3333
+ u(this, ee, e);
3334
+ }
3335
+ get retrieval() {
3336
+ return p(this, te);
3337
+ }
3338
+ set retrieval(e) {
3339
+ u(this, te, e);
3340
+ }
3341
+ get metadata() {
3342
+ return p(this, se);
3343
+ }
3344
+ set metadata(e) {
3345
+ u(this, se, e);
3346
+ }
3347
+ get embed() {
3348
+ return p(this, ie);
3349
+ }
3350
+ set embed(e) {
3351
+ u(this, ie, e);
2916
3352
  }
2917
3353
  get position() {
2918
- return p(this, q);
3354
+ return p(this, ae);
2919
3355
  }
2920
3356
  set position(e) {
2921
- u(this, q, e);
3357
+ u(this, ae, e);
2922
3358
  }
2923
3359
  get sidebar() {
2924
- return p(this, G);
3360
+ return p(this, re);
2925
3361
  }
2926
3362
  set sidebar(e) {
2927
- u(this, G, e);
3363
+ u(this, re, e);
2928
3364
  }
2929
3365
  get showTitle() {
2930
- return p(this, V);
3366
+ return p(this, oe);
2931
3367
  }
2932
3368
  set showTitle(e) {
2933
- u(this, V, e);
3369
+ u(this, oe, e);
2934
3370
  }
2935
3371
  get chatIdAttr() {
2936
- return p(this, X);
3372
+ return p(this, ne);
2937
3373
  }
2938
3374
  set chatIdAttr(e) {
2939
- u(this, X, e);
3375
+ u(this, ne, e);
2940
3376
  }
2941
3377
  get assistantName() {
2942
- return p(this, Y);
3378
+ return p(this, le);
2943
3379
  }
2944
3380
  set assistantName(e) {
2945
- u(this, Y, e);
3381
+ u(this, le, e);
2946
3382
  }
2947
3383
  get logoUrl() {
2948
- return p(this, Q);
3384
+ return p(this, ce);
2949
3385
  }
2950
3386
  set logoUrl(e) {
2951
- u(this, Q, e);
3387
+ u(this, ce, e);
2952
3388
  }
2953
3389
  get heading() {
2954
- return p(this, Z);
3390
+ return p(this, de);
2955
3391
  }
2956
3392
  set heading(e) {
2957
- u(this, Z, e);
3393
+ u(this, de, e);
2958
3394
  }
2959
3395
  get description() {
2960
- return p(this, ee);
3396
+ return p(this, pe);
2961
3397
  }
2962
3398
  set description(e) {
2963
- u(this, ee, e);
3399
+ u(this, pe, e);
3400
+ }
3401
+ get eyebrow() {
3402
+ return p(this, he);
3403
+ }
3404
+ set eyebrow(e) {
3405
+ u(this, he, e);
2964
3406
  }
2965
3407
  get prompts() {
2966
- return p(this, te);
3408
+ return p(this, ue);
2967
3409
  }
2968
3410
  set prompts(e) {
2969
- u(this, te, e);
3411
+ u(this, ue, e);
2970
3412
  }
2971
3413
  get bubbleText() {
2972
- return p(this, ie);
3414
+ return p(this, ge);
2973
3415
  }
2974
3416
  set bubbleText(e) {
2975
- u(this, ie, e);
3417
+ u(this, ge, e);
2976
3418
  }
2977
3419
  get greetingBubble() {
2978
- return p(this, se);
3420
+ return p(this, me);
2979
3421
  }
2980
3422
  set greetingBubble(e) {
2981
- u(this, se, e);
3423
+ u(this, me, e);
2982
3424
  }
2983
3425
  get unreadBadge() {
2984
- return p(this, ae);
3426
+ return p(this, fe);
2985
3427
  }
2986
3428
  set unreadBadge(e) {
2987
- u(this, ae, e);
3429
+ u(this, fe, e);
2988
3430
  }
2989
3431
  get allowUpload() {
2990
- return p(this, re);
3432
+ return p(this, be);
2991
3433
  }
2992
3434
  set allowUpload(e) {
2993
- u(this, re, e);
3435
+ u(this, be, e);
2994
3436
  }
2995
3437
  get allowExport() {
2996
- return p(this, ne);
3438
+ return p(this, xe);
2997
3439
  }
2998
3440
  set allowExport(e) {
2999
- u(this, ne, e);
3441
+ u(this, xe, e);
3442
+ }
3443
+ get allowCopy() {
3444
+ return p(this, ve);
3445
+ }
3446
+ set allowCopy(e) {
3447
+ u(this, ve, e);
3448
+ }
3449
+ get allowRegenerate() {
3450
+ return p(this, we);
3451
+ }
3452
+ set allowRegenerate(e) {
3453
+ u(this, we, e);
3454
+ }
3455
+ get allowBookmark() {
3456
+ return p(this, ye);
3457
+ }
3458
+ set allowBookmark(e) {
3459
+ u(this, ye, e);
3460
+ }
3461
+ get allowDelete() {
3462
+ return p(this, ke);
3463
+ }
3464
+ set allowDelete(e) {
3465
+ u(this, ke, e);
3466
+ }
3467
+ get allowRename() {
3468
+ return p(this, $e);
3469
+ }
3470
+ set allowRename(e) {
3471
+ u(this, $e, e);
3472
+ }
3473
+ get allowFeedback() {
3474
+ return p(this, Ce);
3475
+ }
3476
+ set allowFeedback(e) {
3477
+ u(this, Ce, e);
3478
+ }
3479
+ get showComposer() {
3480
+ return p(this, Te);
3481
+ }
3482
+ set showComposer(e) {
3483
+ u(this, Te, e);
3484
+ }
3485
+ get showTime() {
3486
+ return p(this, Se);
3487
+ }
3488
+ set showTime(e) {
3489
+ u(this, Se, e);
3490
+ }
3491
+ get footnote() {
3492
+ return p(this, Oe);
3493
+ }
3494
+ set footnote(e) {
3495
+ u(this, Oe, e);
3496
+ }
3497
+ get allowRaw() {
3498
+ return p(this, Ie);
3499
+ }
3500
+ set allowRaw(e) {
3501
+ u(this, Ie, e);
3000
3502
  }
3001
3503
  get branding() {
3002
- return p(this, oe);
3504
+ return p(this, Me);
3003
3505
  }
3004
3506
  set branding(e) {
3005
- u(this, oe, e);
3507
+ u(this, Me, e);
3508
+ }
3509
+ get brandingText() {
3510
+ return p(this, ze);
3511
+ }
3512
+ set brandingText(e) {
3513
+ u(this, ze, e);
3514
+ }
3515
+ get brandingUrl() {
3516
+ return p(this, _e);
3517
+ }
3518
+ set brandingUrl(e) {
3519
+ u(this, _e, e);
3006
3520
  }
3007
3521
  get chatList() {
3008
- return p(this, le);
3522
+ return p(this, Le);
3009
3523
  }
3010
3524
  set chatList(e) {
3011
- u(this, le, e);
3525
+ u(this, Le, e);
3012
3526
  }
3013
3527
  get listState() {
3014
- return p(this, ce);
3528
+ return p(this, je);
3015
3529
  }
3016
3530
  set listState(e) {
3017
- u(this, ce, e);
3531
+ u(this, je, e);
3018
3532
  }
3019
3533
  get activeId() {
3020
- return p(this, de);
3534
+ return p(this, Ne);
3021
3535
  }
3022
3536
  set activeId(e) {
3023
- u(this, de, e);
3537
+ u(this, Ne, e);
3024
3538
  }
3025
3539
  get chatTitle() {
3026
- return p(this, pe);
3540
+ return p(this, Ae);
3027
3541
  }
3028
3542
  set chatTitle(e) {
3029
- u(this, pe, e);
3543
+ u(this, Ae, e);
3030
3544
  }
3031
3545
  get bookmarked() {
3032
- return p(this, he);
3546
+ return p(this, Re);
3033
3547
  }
3034
3548
  set bookmarked(e) {
3035
- u(this, he, e);
3549
+ u(this, Re, e);
3036
3550
  }
3037
3551
  get msgs() {
3038
- return p(this, ue);
3552
+ return p(this, Ee);
3039
3553
  }
3040
3554
  set msgs(e) {
3041
- u(this, ue, e);
3555
+ u(this, Ee, e);
3042
3556
  }
3043
3557
  get loadingThread() {
3044
- return p(this, ge);
3558
+ return p(this, Be);
3045
3559
  }
3046
3560
  set loadingThread(e) {
3047
- u(this, ge, e);
3561
+ u(this, Be, e);
3048
3562
  }
3049
3563
  get threadError() {
3050
- return p(this, me);
3564
+ return p(this, De);
3051
3565
  }
3052
3566
  set threadError(e) {
3053
- u(this, me, e);
3567
+ u(this, De, e);
3054
3568
  }
3055
3569
  get busy() {
3056
- return p(this, be);
3570
+ return p(this, Fe);
3057
3571
  }
3058
3572
  set busy(e) {
3059
- u(this, be, e);
3573
+ u(this, Fe, e);
3060
3574
  }
3061
3575
  get draft() {
3062
- return p(this, fe);
3576
+ return p(this, Ue);
3063
3577
  }
3064
3578
  set draft(e) {
3065
- u(this, fe, e);
3579
+ u(this, Ue, e);
3066
3580
  }
3067
3581
  get files() {
3068
- return p(this, xe);
3582
+ return p(this, Pe);
3069
3583
  }
3070
3584
  set files(e) {
3071
- u(this, xe, e);
3585
+ u(this, Pe, e);
3072
3586
  }
3073
3587
  get search() {
3074
- return p(this, ve);
3588
+ return p(this, Ke);
3075
3589
  }
3076
3590
  set search(e) {
3077
- u(this, ve, e);
3591
+ u(this, Ke, e);
3078
3592
  }
3079
3593
  get sidebarOpen() {
3080
- return p(this, ye);
3594
+ return p(this, We);
3081
3595
  }
3082
3596
  set sidebarOpen(e) {
3083
- u(this, ye, e);
3597
+ u(this, We, e);
3084
3598
  }
3085
3599
  get width() {
3086
- return p(this, ke);
3600
+ return p(this, Je);
3087
3601
  }
3088
3602
  set width(e) {
3089
- u(this, ke, e);
3603
+ u(this, Je, e);
3090
3604
  }
3091
3605
  get panel() {
3092
- return p(this, we);
3606
+ return p(this, He);
3093
3607
  }
3094
3608
  set panel(e) {
3095
- u(this, we, e);
3609
+ u(this, He, e);
3096
3610
  }
3097
3611
  get menuOpen() {
3098
- return p(this, $e);
3612
+ return p(this, Ge);
3099
3613
  }
3100
3614
  set menuOpen(e) {
3101
- u(this, $e, e);
3615
+ u(this, Ge, e);
3102
3616
  }
3103
3617
  get editingKey() {
3104
- return p(this, Te);
3618
+ return p(this, qe);
3105
3619
  }
3106
3620
  set editingKey(e) {
3107
- u(this, Te, e);
3621
+ u(this, qe, e);
3108
3622
  }
3109
3623
  get editDraft() {
3110
- return p(this, Ce);
3624
+ return p(this, Ve);
3111
3625
  }
3112
3626
  set editDraft(e) {
3113
- u(this, Ce, e);
3627
+ u(this, Ve, e);
3114
3628
  }
3115
3629
  get editingTitle() {
3116
- return p(this, Se);
3630
+ return p(this, Xe);
3117
3631
  }
3118
3632
  set editingTitle(e) {
3119
- u(this, Se, e);
3633
+ u(this, Xe, e);
3120
3634
  }
3121
3635
  get renamingId() {
3122
- return p(this, ze);
3636
+ return p(this, Ye);
3123
3637
  }
3124
3638
  set renamingId(e) {
3125
- u(this, ze, e);
3639
+ u(this, Ye, e);
3126
3640
  }
3127
3641
  get toast() {
3128
- return p(this, Oe);
3642
+ return p(this, Qe);
3129
3643
  }
3130
3644
  set toast(e) {
3131
- u(this, Oe, e);
3645
+ u(this, Qe, e);
3132
3646
  }
3133
3647
  get copiedKey() {
3134
- return p(this, Me);
3648
+ return p(this, Ze);
3135
3649
  }
3136
3650
  set copiedKey(e) {
3137
- u(this, Me, e);
3651
+ u(this, Ze, e);
3138
3652
  }
3139
3653
  get retrievalOpen() {
3140
- return p(this, _e);
3654
+ return p(this, et);
3141
3655
  }
3142
3656
  set retrievalOpen(e) {
3143
- u(this, _e, e);
3657
+ u(this, et, e);
3658
+ }
3659
+ get rawKeys() {
3660
+ return p(this, tt);
3661
+ }
3662
+ set rawKeys(e) {
3663
+ u(this, tt, e);
3664
+ }
3665
+ get hasSidebarContent() {
3666
+ return p(this, st);
3667
+ }
3668
+ set hasSidebarContent(e) {
3669
+ u(this, st, e);
3670
+ }
3671
+ get sorts() {
3672
+ return p(this, it);
3673
+ }
3674
+ set sorts(e) {
3675
+ u(this, it, e);
3144
3676
  }
3145
3677
  get arrivedKey() {
3146
- return p(this, Ie);
3678
+ return p(this, at);
3147
3679
  }
3148
3680
  set arrivedKey(e) {
3149
- u(this, Ie, e);
3681
+ u(this, at, e);
3150
3682
  }
3151
3683
  get dragging() {
3152
- return p(this, Le);
3684
+ return p(this, rt);
3153
3685
  }
3154
3686
  set dragging(e) {
3155
- u(this, Le, e);
3687
+ u(this, rt, e);
3156
3688
  }
3157
3689
  get showJump() {
3158
- return p(this, je);
3690
+ return p(this, ot);
3159
3691
  }
3160
3692
  set showJump(e) {
3161
- u(this, je, e);
3693
+ u(this, ot, e);
3162
3694
  }
3163
3695
  get offline() {
3164
- return p(this, Ae);
3696
+ return p(this, nt);
3165
3697
  }
3166
3698
  set offline(e) {
3167
- u(this, Ae, e);
3699
+ u(this, nt, e);
3168
3700
  }
3169
3701
  get isOpen() {
3170
- return p(this, Ee);
3702
+ return p(this, lt);
3171
3703
  }
3172
3704
  set isOpen(e) {
3173
- u(this, Ee, e);
3705
+ u(this, lt, e);
3174
3706
  }
3175
3707
  get expanded() {
3176
- return p(this, Ne);
3708
+ return p(this, ct);
3177
3709
  }
3178
3710
  set expanded(e) {
3179
- u(this, Ne, e);
3711
+ u(this, ct, e);
3180
3712
  }
3181
3713
  get bubble() {
3182
- return p(this, Be);
3714
+ return p(this, dt);
3183
3715
  }
3184
3716
  set bubble(e) {
3185
- u(this, Be, e);
3717
+ u(this, dt, e);
3186
3718
  }
3187
3719
  get seen() {
3188
- return p(this, De);
3720
+ return p(this, pt);
3189
3721
  }
3190
3722
  set seen(e) {
3191
- u(this, De, e);
3723
+ u(this, pt, e);
3192
3724
  }
3193
3725
  get mobile() {
3194
- return p(this, Re);
3726
+ return p(this, ht);
3195
3727
  }
3196
3728
  set mobile(e) {
3197
- u(this, Re, e);
3729
+ u(this, ht, e);
3198
3730
  }
3199
3731
  get msg() {
3200
- return Tt(this.messages);
3732
+ return Qt(this.messages);
3201
3733
  }
3202
3734
  /** An explicit `.client`, else the page default. */
3203
3735
  get resolvedClient() {
3204
- return this.client ?? yt() ?? null;
3736
+ return this.client ?? Ht() ?? null;
3205
3737
  }
3206
3738
  /** The open conversation's id, or null for a new chat. */
3207
3739
  get chatId() {
@@ -3211,18 +3743,46 @@ let d = (dt = class extends ft {
3211
3743
  get thread() {
3212
3744
  return this.msgs;
3213
3745
  }
3746
+ /** `format`, falling back to the default for anything unknown. */
3747
+ get formatLevel() {
3748
+ return ["raw", "plain", "advanced", "rich"].includes(this.format) ? this.format : "advanced";
3749
+ }
3214
3750
  /** The loaded chat list. */
3215
3751
  get chats() {
3216
3752
  return this.chatList;
3217
3753
  }
3754
+ /**
3755
+ * Every setting in one object, keyed by property name:
3756
+ *
3757
+ * chat.config = { client, mode: "rag", format: "rich", retrieval: [...], chatId: "…" };
3758
+ *
3759
+ * Unknown keys are ignored. `chatId` opens that chat; reading `config`
3760
+ * returns the current settings with `chatId` as the open chat.
3761
+ */
3218
3762
  set config(e) {
3763
+ if (!e) return;
3219
3764
  const t = this;
3220
- for (const i of st)
3221
- e && i in e && (t[i] = e[i]);
3765
+ "client" in e && (this.client = e.client ?? null);
3766
+ for (const s of Mt)
3767
+ s in e && (t[s] = e[s]);
3768
+ e.chatId && e.chatId !== this.activeId && (this.hasUpdated ? this.openChat(e.chatId) : this.chatIdAttr = e.chatId);
3769
+ }
3770
+ /**
3771
+ * Changes settings on the fly. Only the keys you pass change; the chat keeps
3772
+ * its conversation and re-renders in place. Returns the element, so calls chain.
3773
+ *
3774
+ * chat.configure({ format: "rich" }).configure({ theme: "dark" });
3775
+ */
3776
+ configure(e) {
3777
+ return this.config = e, this;
3222
3778
  }
3223
3779
  get config() {
3224
3780
  const e = this;
3225
- return Object.fromEntries(st.map((t) => [t, e[t]]));
3781
+ return {
3782
+ client: this.client,
3783
+ chatId: this.activeId ?? "",
3784
+ ...Object.fromEntries(Mt.map((t) => [t, e[t]]))
3785
+ };
3226
3786
  }
3227
3787
  // ── lifecycle ─────────────────────────────────────────────
3228
3788
  connectedCallback() {
@@ -3238,7 +3798,7 @@ let d = (dt = class extends ft {
3238
3798
  const t = this.retrieval;
3239
3799
  this.retrieval = t && typeof t == "object" ? [t] : [];
3240
3800
  }
3241
- e.has("params") && (!this.params || typeof this.params != "object") && (this.params = {}), e.has("metadata") && (!this.metadata || typeof this.metadata != "object") && (this.metadata = {}), e.has("sidebar") && this.sidebar !== void 0 && (this.sidebarOpen = this.sidebar), this.embed === "launcher" && this.greetingBubble && !this.bubbleScheduled && (this.bubbleScheduled = !0, this.later(() => {
3801
+ e.has("params") && (!this.params || typeof this.params != "object") && (this.params = {}), e.has("metadata") && (!this.metadata || typeof this.metadata != "object") && (this.metadata = {}), e.has("sidebar") && (this.sidebar === "open" ? this.sidebarOpen = !0 : this.sidebar === "closed" || this.sidebar === "none" ? this.sidebarOpen = !1 : this.width && (this.sidebarOpen = this.docked)), this.embed === "launcher" && this.greetingBubble && !this.bubbleScheduled && (this.bubbleScheduled = !0, this.later(() => {
3242
3802
  !this.isOpen && !this.seen && (this.bubble = !0);
3243
3803
  }, 1200));
3244
3804
  }
@@ -3248,70 +3808,70 @@ let d = (dt = class extends ft {
3248
3808
  updated() {
3249
3809
  var t;
3250
3810
  const e = this.renderRoot.querySelector(".root");
3251
- if (e !== this.observed && ((t = this.observer) == null || t.disconnect(), this.observed = e, e && typeof ResizeObserver < "u" && (this.observer ?? (this.observer = new ResizeObserver(([i]) => {
3252
- const s = Math.round(i.contentRect.width);
3253
- s !== this.width && (this.width = s, this.sidebarOpen === null && (this.sidebarOpen = this.sidebar ?? this.docked));
3254
- })), this.observer.observe(e))), this.sidebarOpen && this.listState === "idle" && this.resolvedClient && this.loadChats(), this.focusNext) {
3255
- const i = this.renderRoot.querySelector(
3811
+ if (e !== this.observed && ((t = this.observer) == null || t.disconnect(), this.observed = e, e && typeof ResizeObserver < "u" && (this.observer ?? (this.observer = new ResizeObserver(([s]) => {
3812
+ const i = Math.round(s.contentRect.width);
3813
+ i !== this.width && (this.width = i, this.sidebarOpen === null && (this.sidebarOpen = this.sidebar === "auto" && this.docked));
3814
+ })), this.observer.observe(e))), this.sidebarOpen && this.listState === "idle" && this.resolvedClient && this.loadChats(), this.pendingChatId && this.resolvedClient && this.openChat(this.pendingChatId), this.focusNext) {
3815
+ const s = this.renderRoot.querySelector(
3256
3816
  this.focusNext
3257
3817
  );
3258
- this.focusNext = "", i && (i.focus(), "select" in i && i.tagName === "INPUT" && i.select());
3818
+ this.focusNext = "", s && (s.focus(), "select" in s && s.tagName === "INPUT" && s.select());
3259
3819
  }
3260
3820
  }
3261
3821
  later(e, t) {
3262
- const i = setTimeout(() => {
3263
- this.timers.delete(i), e();
3822
+ const s = setTimeout(() => {
3823
+ this.timers.delete(s), e();
3264
3824
  }, t);
3265
- this.timers.add(i);
3825
+ this.timers.add(s);
3266
3826
  }
3267
3827
  emit(e, t) {
3268
3828
  this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
3269
3829
  }
3270
3830
  get docked() {
3271
- return this.embed === "page" && this.width >= Rt;
3831
+ return this.embed === "page" && this.width >= $s;
3272
3832
  }
3273
3833
  get panelDocked() {
3274
- const e = this.docked && this.sidebarOpen ? Dt : 0;
3275
- return this.width - e >= Ut;
3834
+ const e = this.docked && this.sidebarOpen ? ks : 0;
3835
+ return this.width - e >= Cs;
3276
3836
  }
3277
3837
  // ── public API ────────────────────────────────────────────
3278
3838
  /** Starts a new, empty conversation. */
3279
3839
  newChat() {
3280
- this.halt(), this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
3840
+ this.halt(), this.pendingChatId = "", this.loadingThread = !1, this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
3281
3841
  }
3282
3842
  /** Opens a saved conversation. */
3283
3843
  async openChat(e) {
3284
3844
  const t = this.resolvedClient;
3285
3845
  if (!e) return;
3286
3846
  this.halt();
3287
- const i = this.chatList.find((a) => a._id === e);
3288
- if (this.activeId = e, this.chatTitle = (i == null ? void 0 : i.title) ?? "", this.bookmarked = !!(i != null && i.bookmarked), this.msgs = [], this.threadError = "", this.resetViewState(), !t) {
3289
- this.threadError = this.msg.errNoClient;
3847
+ const s = this.chatList.find((a) => a._id === e);
3848
+ if (this.activeId = e, this.chatTitle = (s == null ? void 0 : s.title) ?? "", this.bookmarked = !!(s != null && s.bookmarked), this.msgs = [], this.threadError = "", this.resetViewState(), !t) {
3849
+ this.pendingChatId = e, this.loadingThread = !0;
3290
3850
  return;
3291
3851
  }
3292
- const s = ++this.run;
3293
- this.loadingThread = !0;
3852
+ const i = ++this.run;
3853
+ this.pendingChatId = "", this.loadingThread = !0;
3294
3854
  try {
3295
3855
  const a = await t.llm.call("get_chat", {
3296
3856
  _id: e
3297
3857
  });
3298
- if (s !== this.run) return;
3299
- this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((o) => o && (o.role === "user" || o.role === "assistant")).map((o) => this.fromServer(o)), this.upsertChat({ ...i, ...a, _id: e }), this.stick = !0, this.scrollToBottom();
3858
+ if (i !== this.run) return;
3859
+ this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((r) => r && (r.role === "user" || r.role === "assistant")).map((r) => this.fromServer(r)), this.upsertChat({ ...s, ...a, _id: e }), this.stick = !0, this.scrollToBottom();
3300
3860
  } catch (a) {
3301
- if (s !== this.run) return;
3302
- lt(a) ? (this.chatList = this.chatList.filter((o) => o._id !== e), this.newChat(), this.showToast(this.msg.errNotFound)) : this.threadError = this.msg.errLoad;
3861
+ if (i !== this.run) return;
3862
+ At(a) ? (this.chatList = this.chatList.filter((r) => r._id !== e), this.newChat(), this.showToast(this.msg.errNotFound)) : this.threadError = this.msg.errLoad;
3303
3863
  } finally {
3304
- s === this.run && (this.loadingThread = !1);
3864
+ i === this.run && (this.loadingThread = !1);
3305
3865
  }
3306
3866
  }
3307
3867
  /** Sends a message; with no argument, sends the composer's text. */
3308
3868
  async send(e) {
3309
3869
  const t = (typeof e == "string" ? e : this.draft).trim();
3310
3870
  if (!t || this.busy) return;
3311
- const i = this.files;
3871
+ const s = this.files;
3312
3872
  this.draft = "", this.files = [];
3313
- const s = this.renderRoot.querySelector("textarea.input");
3314
- s && (s.style.height = "auto"), await this.runTurn(this.userMessage(t, i));
3873
+ const i = this.renderRoot.querySelector("textarea.input");
3874
+ i && (i.style.height = "auto"), await this.runTurn(this.userMessage(t, s));
3315
3875
  }
3316
3876
  /** Stops waiting for, or revealing, the current reply. */
3317
3877
  stop() {
@@ -3321,14 +3881,14 @@ let d = (dt = class extends ft {
3321
3881
  }
3322
3882
  /** Downloads the open conversation, or copies it as Markdown. */
3323
3883
  exportChat(e = "md") {
3324
- var M;
3884
+ var _;
3325
3885
  if (!this.msgs.length) return;
3326
3886
  this.menuOpen = !1;
3327
- const t = this.chatTitle || this.msg.untitled, i = (k) => k.role === "user" ? this.msg.you : this.assistantName, s = (k) => new Date(k || Date.now()).toLocaleString(), a = (k) => k.sources.map((L, ut) => {
3328
- const Ue = Ke(L, ut + 1);
3329
- return `[${Ue.n}] ${Ue.title}${Ue.path ? ` — ${Ue.path}` : ""}`;
3330
- }), o = (k) => (k.attachments ?? []).map((L) => L.name);
3331
- let l, c = "text/markdown", x = "md";
3887
+ const t = this.chatTitle || this.msg.untitled, s = (x) => x.role === "user" ? this.msg.you : this.assistantName, i = (x) => new Date(x || Date.now()).toLocaleString(), a = (x) => x.sources.map((T, $) => {
3888
+ const j = gt(T, $ + 1);
3889
+ return `[${j.n}] ${j.title}${j.path ? ` — ${j.path}` : ""}`;
3890
+ }), r = (x) => (x.attachments ?? []).map((T) => T.name);
3891
+ let l, c = "text/markdown", m = "md";
3332
3892
  if (e === "json" ? (l = JSON.stringify(
3333
3893
  {
3334
3894
  exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3336,42 +3896,42 @@ let d = (dt = class extends ft {
3336
3896
  title: t,
3337
3897
  mode: this.mode,
3338
3898
  bookmarked: this.bookmarked,
3339
- messages: this.msgs.map((k) => ({
3340
- role: k.role,
3341
- text: k.content,
3342
- at: new Date(k.at || Date.now()).toISOString(),
3343
- bookmarked: k.bookmarked,
3344
- attachments: o(k),
3345
- sources: a(k)
3899
+ messages: this.msgs.map((x) => ({
3900
+ role: x.role,
3901
+ text: x.content,
3902
+ at: new Date(x.at || Date.now()).toISOString(),
3903
+ bookmarked: x.bookmarked,
3904
+ attachments: r(x),
3905
+ sources: a(x)
3346
3906
  }))
3347
3907
  },
3348
3908
  null,
3349
3909
  2
3350
- ), c = "application/json", x = "json") : e === "txt" ? (l = `${t}
3910
+ ), c = "application/json", m = "json") : e === "txt" ? (l = `${t}
3351
3911
  ${"=".repeat(t.length)}
3352
3912
 
3353
3913
  ` + this.msgs.map(
3354
- (k) => [
3355
- `${i(k)} · ${s(k.at)}`,
3356
- o(k).length ? `Attachments: ${o(k).join(", ")}` : "",
3357
- k.content,
3358
- a(k).length ? `Sources:
3359
- ${a(k).join(`
3914
+ (x) => [
3915
+ `${s(x)} · ${i(x.at)}`,
3916
+ r(x).length ? `Attachments: ${r(x).join(", ")}` : "",
3917
+ x.content,
3918
+ a(x).length ? `Sources:
3919
+ ${a(x).join(`
3360
3920
  `)}` : ""
3361
3921
  ].filter(Boolean).join(`
3362
3922
  `)
3363
3923
  ).join(`
3364
3924
 
3365
- `), c = "text/plain", x = "txt") : l = `# ${t}
3925
+ `), c = "text/plain", m = "txt") : l = `# ${t}
3366
3926
 
3367
3927
  ` + this.msgs.map(
3368
- (k) => [
3369
- `### ${i(k)} · ${s(k.at)}`,
3370
- o(k).length ? `Attachments: ${o(k).join(", ")}` : "",
3371
- k.content,
3372
- a(k).length ? `**Sources**
3928
+ (x) => [
3929
+ `### ${s(x)} · ${i(x.at)}`,
3930
+ r(x).length ? `Attachments: ${r(x).join(", ")}` : "",
3931
+ x.content,
3932
+ a(x).length ? `**Sources**
3373
3933
 
3374
- ${a(k).map((L) => `- ${L}`).join(`
3934
+ ${a(x).map((T) => `- ${T}`).join(`
3375
3935
  `)}` : ""
3376
3936
  ].filter(Boolean).join(`
3377
3937
 
@@ -3382,12 +3942,12 @@ ${a(k).map((L) => `- ${L}`).join(`
3382
3942
 
3383
3943
  `) + `
3384
3944
  `, this.emit("singlebase-chat-export", { chatId: this.activeId, format: e }), e === "copy") {
3385
- (M = navigator.clipboard) == null || M.writeText(l).catch(() => {
3945
+ (_ = navigator.clipboard) == null || _.writeText(l).catch(() => {
3386
3946
  }), this.showToast(this.msg.copiedMarkdown);
3387
3947
  return;
3388
3948
  }
3389
- const O = `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "chat"}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.${x}`, S = URL.createObjectURL(new Blob([l], { type: c })), b = document.createElement("a");
3390
- b.href = S, b.download = O, document.body.appendChild(b), b.click(), b.remove(), setTimeout(() => URL.revokeObjectURL(S), 2e3), this.showToast(z(this.msg.exported, { name: O }));
3949
+ const C = `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "chat"}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.${m}`, S = URL.createObjectURL(new Blob([l], { type: c })), w = document.createElement("a");
3950
+ w.href = S, w.download = C, document.body.appendChild(w), w.click(), w.remove(), setTimeout(() => URL.revokeObjectURL(S), 2e3), this.showToast(L(this.msg.exported, { name: C }));
3391
3951
  }
3392
3952
  /** Inline and launcher: fill the window. */
3393
3953
  expand() {
@@ -3407,7 +3967,7 @@ ${a(k).map((L) => `- ${L}`).join(`
3407
3967
  // ── turns ─────────────────────────────────────────────────
3408
3968
  userMessage(e, t = []) {
3409
3969
  return {
3410
- key: Je(),
3970
+ key: mt(),
3411
3971
  id: null,
3412
3972
  role: "user",
3413
3973
  content: e,
@@ -3422,23 +3982,24 @@ ${a(k).map((L) => `- ${L}`).join(`
3422
3982
  systemPrompt() {
3423
3983
  return [
3424
3984
  this.systemMessage,
3425
- nt[this.mode] ?? nt.chat,
3426
- this.followups ? Ht : ""
3985
+ jt[this.mode] ?? jt.chat,
3986
+ zs[this.formatLevel],
3987
+ this.followups ? _s : ""
3427
3988
  ].filter(Boolean).join(`
3428
3989
 
3429
3990
  `);
3430
3991
  }
3431
3992
  payloadFor(e) {
3432
3993
  const t = { message: e.content, format: "markdown" };
3433
- this.activeId ? t._id = this.activeId : (t.title = Lt(e.content), t.system_message = this.systemPrompt()), this.model && (t.model = this.model), Object.keys(this.params ?? {}).length && (t.params = this.params);
3434
- const i = (e.attachments ?? []).map((a) => a.name);
3435
- (Object.keys(this.metadata ?? {}).length || i.length) && (t.metadata = { ...this.metadata, ...i.length ? { attachments: i } : {} });
3436
- const s = [...this.retrieval ?? [], ...Gt(e.attachments ?? [])];
3437
- return s.length && (t.retrieval = s), t;
3994
+ this.activeId ? t._id = this.activeId : (t.title = us(e.content), t.system_message = this.systemPrompt()), this.model && (t.model = this.model), Object.keys(this.params ?? {}).length && (t.params = this.params);
3995
+ const s = (e.attachments ?? []).map((a) => a.name);
3996
+ (Object.keys(this.metadata ?? {}).length || s.length) && (t.metadata = { ...this.metadata, ...s.length ? { attachments: s } : {} });
3997
+ const i = [...this.retrieval ?? [], ...As(e.attachments ?? [])];
3998
+ return i.length && (t.retrieval = i), t;
3438
3999
  }
3439
4000
  async runTurn(e) {
3440
4001
  const t = {
3441
- key: Je(),
4002
+ key: mt(),
3442
4003
  id: null,
3443
4004
  role: "assistant",
3444
4005
  content: "",
@@ -3449,57 +4010,79 @@ ${a(k).map((L) => `- ${L}`).join(`
3449
4010
  phase: "pending"
3450
4011
  };
3451
4012
  this.msgs = [...this.msgs, e, t], this.busy = !0, this.panel = null, this.stick = !0, this.scrollToBottom(), this.emit("singlebase-chat-send", { chatId: this.activeId, text: e.content });
3452
- const i = this.resolvedClient;
3453
- if (!i) {
4013
+ const s = this.resolvedClient;
4014
+ if (!s) {
3454
4015
  this.failTurn(t, this.msg.errNoClient, "NO_CLIENT"), this.busy = !1;
3455
4016
  return;
3456
4017
  }
3457
- const s = ++this.run, a = new AbortController();
4018
+ const i = ++this.run, a = new AbortController();
3458
4019
  this.abort = a;
3459
- const o = !this.activeId, l = this.payloadFor(e);
4020
+ const r = !this.activeId;
4021
+ let l = this.payloadFor(e);
4022
+ if (this.beforeSend) {
4023
+ let c;
4024
+ try {
4025
+ c = await this.beforeSend(l, { chatId: this.activeId, isNew: r, message: e });
4026
+ } catch (b) {
4027
+ c = b;
4028
+ }
4029
+ if (i !== this.run) return;
4030
+ if (c === !1) {
4031
+ this.msgs = this.msgs.filter((b) => b !== e && b !== t), this.draft = e.content, this.busy = !1, this.abort = null;
4032
+ return;
4033
+ }
4034
+ if (!(!!c && typeof c == "object" && typeof c.message == "string") || !c.message.trim()) {
4035
+ console.error(
4036
+ "[singlebase-chat] beforeSend must return the request object (with a message) or false to cancel; the message was not sent.",
4037
+ c
4038
+ ), this.failTurn(t, this.msg.errGeneric, "BEFORE_SEND_INVALID"), this.busy = !1, this.abort = null;
4039
+ return;
4040
+ }
4041
+ l = c;
4042
+ }
3460
4043
  try {
3461
- const c = await i.llm.call("chat", l, { signal: a.signal }), x = (c == null ? void 0 : c._id) || (c == null ? void 0 : c.chat_id) || this.activeId;
3462
- if (o && x && this.upsertChat({
3463
- _id: x,
4044
+ const c = await s.llm.call("chat", l, { signal: a.signal }), m = (c == null ? void 0 : c._id) || (c == null ? void 0 : c.chat_id) || this.activeId;
4045
+ if (r && m && this.upsertChat({
4046
+ _id: m,
3464
4047
  title: (c == null ? void 0 : c.title) || l.title,
3465
4048
  bookmarked: !!(c != null && c.bookmarked),
3466
4049
  _modified_at: (/* @__PURE__ */ new Date()).toISOString()
3467
- }), s !== this.run) return;
3468
- x && (this.activeId = x), o ? (this.chatTitle = (c == null ? void 0 : c.title) || l.title, this.bookmarked = !!(c != null && c.bookmarked)) : x && this.touchChat(x);
3469
- const f = (c == null ? void 0 : c.message) ?? {}, O = typeof f.content == "string" ? f.content : (c == null ? void 0 : c.json) !== void 0 ? JSON.stringify(c.json, null, 2) : "", { text: S, followups: b } = tt(O);
3470
- e.id = f.reply_to ?? null, Object.assign(t, {
3471
- id: f._id ?? null,
4050
+ }), i !== this.run) return;
4051
+ m && (this.activeId = m), r ? (this.chatTitle = (c == null ? void 0 : c.title) || l.title, this.bookmarked = !!(c != null && c.bookmarked)) : m && this.touchChat(m);
4052
+ const b = (c == null ? void 0 : c.message) ?? {}, C = typeof b.content == "string" ? b.content : (c == null ? void 0 : c.json) !== void 0 ? JSON.stringify(c.json, null, 2) : "", { text: S, followups: w } = Ot(C);
4053
+ e.id = b.reply_to ?? null, Object.assign(t, {
4054
+ id: b._id ?? null,
3472
4055
  content: S,
3473
- sources: Array.isArray(f.sources) ? f.sources : [],
3474
- followups: this.followups ? b : [],
3475
- execTime: typeof f.exec_time == "number" ? f.exec_time : void 0,
3476
- model: f.model,
4056
+ sources: Array.isArray(b.sources) ? b.sources : [],
4057
+ followups: w,
4058
+ execTime: typeof b.exec_time == "number" ? b.exec_time : void 0,
4059
+ model: b.model,
3477
4060
  at: Date.now()
3478
- }), this.emit("singlebase-chat-response", { chatId: x, message: t }), await this.reveal(t, s), o && x && this.autoTitle && this.retitle(x, e.content, t.content);
4061
+ }), this.emit("singlebase-chat-response", { chatId: m, message: t }), await this.reveal(t, i), r && m && this.autoTitle && this.retitle(m, e.content, t.content);
3479
4062
  } catch (c) {
3480
- if (s !== this.run) return;
3481
- const x = lt(c);
3482
- x && (this.chatList = this.chatList.filter((f) => f._id !== this.activeId), this.activeId = null), this.failTurn(t, x ? this.msg.errNotFound : this.msg.errGeneric, Wt(c));
4063
+ if (i !== this.run) return;
4064
+ const m = At(c);
4065
+ m && (this.chatList = this.chatList.filter((b) => b._id !== this.activeId), this.activeId = null), this.failTurn(t, m ? this.msg.errNotFound : this.msg.errGeneric, js(c));
3483
4066
  } finally {
3484
- s === this.run && (this.busy = !1, this.abort = null, this.stick && this.scrollToBottom());
4067
+ i === this.run && (this.busy = !1, this.abort = null, this.stick && this.scrollToBottom());
3485
4068
  }
3486
4069
  }
3487
- failTurn(e, t, i) {
3488
- e.phase = "error", e.error = t, this.msgs = [...this.msgs], this.emit("singlebase-chat-error", { chatId: this.activeId, code: i, message: t });
4070
+ failTurn(e, t, s) {
4071
+ e.phase = "error", e.error = t, this.msgs = [...this.msgs], this.emit("singlebase-chat-error", { chatId: this.activeId, code: s, message: t });
3489
4072
  }
3490
4073
  /**
3491
4074
  * The service answers in one piece; this reveals it progressively so it
3492
4075
  * reads like a stream. Capped at about a second and a half.
3493
4076
  */
3494
4077
  reveal(e, t) {
3495
- const i = e.content.length, s = () => {
4078
+ const s = e.content.length, i = () => {
3496
4079
  e.phase = "done", this.msgs = [...this.msgs], this.arrivedKey = e.key, this.later(() => {
3497
4080
  this.arrivedKey === e.key && (this.arrivedKey = "");
3498
- }, Pt), this.stick ? this.scrollToBottom() : this.showJump = !0;
4081
+ }, Ms), this.stick ? this.scrollToBottom() : this.showJump = !0;
3499
4082
  };
3500
- if (!i || qt())
3501
- return s(), Promise.resolve();
3502
- const a = e.content, o = Math.max(4, Math.ceil(i / 90));
4083
+ if (!s || Ns())
4084
+ return i(), Promise.resolve();
4085
+ const a = e.content, r = Math.max(4, Math.ceil(s / 90));
3503
4086
  let l = 0;
3504
4087
  return e.phase = "streaming", e.content = "", new Promise((c) => {
3505
4088
  this.revealTimer = setInterval(() => {
@@ -3507,8 +4090,8 @@ ${a(k).map((L) => `- ${L}`).join(`
3507
4090
  clearInterval(this.revealTimer), c();
3508
4091
  return;
3509
4092
  }
3510
- if (l = Math.min(i, l + o), e.content = a.slice(0, l), l >= i) {
3511
- clearInterval(this.revealTimer), s(), c();
4093
+ if (l = Math.min(s, l + r), e.content = a.slice(0, l), l >= s) {
4094
+ clearInterval(this.revealTimer), i(), c();
3512
4095
  return;
3513
4096
  }
3514
4097
  this.msgs = [...this.msgs], this.stick && this.scrollToBottom();
@@ -3520,23 +4103,23 @@ ${a(k).map((L) => `- ${L}`).join(`
3520
4103
  var e;
3521
4104
  this.run++, (e = this.abort) == null || e.abort(), this.abort = null, clearInterval(this.revealTimer), this.busy = !1;
3522
4105
  }
3523
- async retitle(e, t, i) {
3524
- const s = this.resolvedClient;
3525
- if (!(!s || this.renamed.has(e)))
4106
+ async retitle(e, t, s) {
4107
+ const i = this.resolvedClient;
4108
+ if (!(!i || this.renamed.has(e)))
3526
4109
  try {
3527
- const a = await s.llm.call("generate", {
4110
+ const a = await i.llm.call("generate", {
3528
4111
  user_input: `user: ${t}
3529
- assistant: ${i.slice(0, 1500)}`,
4112
+ assistant: ${s.slice(0, 1500)}`,
3530
4113
  custom_instructions: "Write a concise title (3–6 words, sentence case, no quotes, no trailing punctuation) for this conversation.",
3531
4114
  format: "text"
3532
- }), o = jt(a == null ? void 0 : a.result);
3533
- if (!o || this.renamed.has(e)) return;
3534
- await s.llm.call("update_chat", { _id: e, title: o }), this.applyTitle(e, o, !0);
4115
+ }), r = gs(a == null ? void 0 : a.result);
4116
+ if (!r || this.renamed.has(e)) return;
4117
+ await i.llm.call("update_chat", { _id: e, title: r }), this.applyTitle(e, r, !0);
3535
4118
  } catch {
3536
4119
  }
3537
4120
  }
3538
- applyTitle(e, t, i) {
3539
- this.chatList = this.chatList.map((s) => s._id === e ? { ...s, title: t } : s), this.activeId === e && (this.chatTitle = t), this.emit("singlebase-chat-title", { chatId: e, title: t, auto: i });
4121
+ applyTitle(e, t, s) {
4122
+ this.chatList = this.chatList.map((i) => i._id === e ? { ...i, title: t } : i), this.activeId === e && (this.chatTitle = t), this.emit("singlebase-chat-title", { chatId: e, title: t, auto: s });
3540
4123
  }
3541
4124
  /**
3542
4125
  * Enter and blur both land here. Saving on Enter directly (not via blur())
@@ -3549,28 +4132,28 @@ assistant: ${i.slice(0, 1500)}`,
3549
4132
  this.renamingId === e && (this.renamingId = "", this.renameChat(e, t));
3550
4133
  }
3551
4134
  async renameChat(e, t) {
3552
- var a, o;
3553
- const i = t.trim().slice(0, 80), s = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.title) ?? this.chatTitle;
3554
- if (!(!i || i === s)) {
3555
- this.renamed.add(e), this.applyTitle(e, i, !1);
4135
+ var a, r;
4136
+ const s = t.trim().slice(0, 80), i = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.title) ?? this.chatTitle;
4137
+ if (!(!s || s === i)) {
4138
+ this.renamed.add(e), this.applyTitle(e, s, !1);
3556
4139
  try {
3557
- await ((o = this.resolvedClient) == null ? void 0 : o.llm.call("update_chat", { _id: e, title: i }));
4140
+ await ((r = this.resolvedClient) == null ? void 0 : r.llm.call("update_chat", { _id: e, title: s }));
3558
4141
  } catch {
3559
- this.applyTitle(e, s ?? "", !1), this.showToast(this.msg.errGeneric);
4142
+ this.applyTitle(e, i ?? "", !1), this.showToast(this.msg.errGeneric);
3560
4143
  }
3561
4144
  }
3562
4145
  }
3563
4146
  fromServer(e) {
3564
- const t = e.role === "assistant", { text: i, followups: s } = t ? tt(String(e.content ?? "")) : { text: String(e.content ?? ""), followups: [] };
4147
+ const t = e.role === "assistant", { text: s, followups: i } = t ? Ot(String(e.content ?? "")) : { text: String(e.content ?? ""), followups: [] };
3565
4148
  return {
3566
- key: Je(),
4149
+ key: mt(),
3567
4150
  id: e._id ?? null,
3568
4151
  role: t ? "assistant" : "user",
3569
- content: i,
4152
+ content: s,
3570
4153
  at: Date.parse(e._created_at ?? "") || 0,
3571
4154
  bookmarked: !!e.bookmarked,
3572
4155
  sources: Array.isArray(e.sources) ? e.sources : [],
3573
- followups: this.followups ? s : [],
4156
+ followups: i,
3574
4157
  phase: "done",
3575
4158
  execTime: typeof e.exec_time == "number" ? e.exec_time : void 0,
3576
4159
  model: e.model
@@ -3590,11 +4173,11 @@ assistant: ${i.slice(0, 1500)}`,
3590
4173
  }
3591
4174
  }
3592
4175
  upsertChat(e) {
3593
- const t = this.chatList.filter((s) => s._id !== e._id), i = this.chatList.find((s) => s._id === e._id);
3594
- this.chatList = [{ ...i, ...e }, ...t];
4176
+ const t = this.chatList.filter((i) => i._id !== e._id), s = this.chatList.find((i) => i._id === e._id);
4177
+ this.chatList = [{ ...s, ...e }, ...t];
3595
4178
  }
3596
4179
  touchChat(e) {
3597
- const t = this.chatList.find((i) => i._id === e);
4180
+ const t = this.chatList.find((s) => s._id === e);
3598
4181
  t && this.upsertChat({ ...t, _modified_at: (/* @__PURE__ */ new Date()).toISOString() });
3599
4182
  }
3600
4183
  // ── actions ───────────────────────────────────────────────
@@ -3602,44 +4185,48 @@ assistant: ${i.slice(0, 1500)}`,
3602
4185
  this.panel = null, this.menuOpen = !1, this.editingKey = "", this.editingTitle = !1, this.showJump = !1, this.retrievalOpen = /* @__PURE__ */ new Set(), this.sidebarOpen && !this.docked && (this.sidebarOpen = !1);
3603
4186
  }
3604
4187
  async deleteOnServer(e) {
3605
- const t = this.resolvedClient, i = this.activeId;
3606
- if (!(!t || !i))
3607
- for (const s of e)
3608
- s && await t.llm.call("delete_chat_message", { _id: i, message_id: s }).catch(() => {
4188
+ const t = this.resolvedClient, s = this.activeId;
4189
+ if (!(!t || !s))
4190
+ for (const i of e)
4191
+ i && await t.llm.call("delete_chat_message", { _id: s, message_id: i }).catch(() => {
3609
4192
  });
3610
4193
  }
3611
4194
  async regenerate() {
3612
4195
  if (this.busy) return;
3613
- const e = this.msgs.map((s) => s.role).lastIndexOf("assistant"), t = this.msgs[e - 1];
4196
+ const e = this.msgs.map((i) => i.role).lastIndexOf("assistant"), t = this.msgs[e - 1];
3614
4197
  if (e < 1 || (t == null ? void 0 : t.role) !== "user") return;
3615
- const i = this.msgs.slice(e - 1);
3616
- this.msgs = this.msgs.slice(0, e - 1), await this.deleteOnServer(i.map((s) => s.id)), await this.runTurn(this.userMessage(t.content, t.attachments));
4198
+ const s = this.msgs.slice(e - 1);
4199
+ this.msgs = this.msgs.slice(0, e - 1), await this.deleteOnServer(s.map((i) => i.id)), await this.runTurn(this.userMessage(t.content, t.attachments));
3617
4200
  }
3618
4201
  async retry(e) {
3619
4202
  if (this.busy) return;
3620
- const t = this.msgs.indexOf(e), i = this.msgs[t - 1];
3621
- (i == null ? void 0 : i.role) === "user" && (this.msgs = this.msgs.slice(0, t - 1), await this.runTurn(this.userMessage(i.content, i.attachments)));
4203
+ const t = this.msgs.indexOf(e), s = this.msgs[t - 1];
4204
+ (s == null ? void 0 : s.role) === "user" && (this.msgs = this.msgs.slice(0, t - 1), await this.runTurn(this.userMessage(s.content, s.attachments)));
3622
4205
  }
3623
4206
  async saveEdit(e) {
3624
- const t = this.editDraft.trim(), i = this.msgs.indexOf(e);
3625
- if (this.editingKey = "", !t || i < 0 || this.busy) return;
3626
- const s = this.msgs.slice(i);
3627
- this.msgs = this.msgs.slice(0, i), await this.deleteOnServer(s.map((a) => a.id)), await this.runTurn(this.userMessage(t, e.attachments));
4207
+ const t = this.editDraft.trim(), s = this.msgs.indexOf(e);
4208
+ if (this.editingKey = "", !t || s < 0 || this.busy) return;
4209
+ const i = this.msgs.slice(s);
4210
+ this.msgs = this.msgs.slice(0, s), await this.deleteOnServer(i.map((a) => a.id)), await this.runTurn(this.userMessage(t, e.attachments));
4211
+ }
4212
+ toggleRaw(e) {
4213
+ const t = new Set(this.rawKeys);
4214
+ t.has(e) ? t.delete(e) : t.add(e), this.rawKeys = t;
3628
4215
  }
3629
4216
  copy(e, t) {
3630
- var i;
3631
- (i = navigator.clipboard) == null || i.writeText(t).catch(() => {
4217
+ var s;
4218
+ (s = navigator.clipboard) == null || s.writeText(t).catch(() => {
3632
4219
  }), this.copiedKey = e, this.later(() => {
3633
4220
  this.copiedKey === e && (this.copiedKey = "");
3634
4221
  }, 1400);
3635
4222
  }
3636
4223
  async toggleMessageBookmark(e) {
3637
- var i;
4224
+ var s;
3638
4225
  const t = this.activeId;
3639
4226
  if (!(!t || !e.id)) {
3640
4227
  e.bookmarked = !e.bookmarked, this.msgs = [...this.msgs], this.showToast(e.bookmarked ? this.msg.messageBookmarked : this.msg.bookmarkRemoved), this.emit("singlebase-chat-bookmark", { chatId: t, messageId: e.id, bookmarked: e.bookmarked });
3641
4228
  try {
3642
- await ((i = this.resolvedClient) == null ? void 0 : i.llm.call("bookmark_chat_message", {
4229
+ await ((s = this.resolvedClient) == null ? void 0 : s.llm.call("bookmark_chat_message", {
3643
4230
  _id: t,
3644
4231
  message_id: e.id,
3645
4232
  bookmarked: e.bookmarked
@@ -3650,28 +4237,28 @@ assistant: ${i.slice(0, 1500)}`,
3650
4237
  }
3651
4238
  }
3652
4239
  async toggleChatBookmark(e) {
3653
- var a, o;
3654
- const t = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.bookmarked) ?? (e === this.activeId ? this.bookmarked : !1), i = !t, s = (l) => {
4240
+ var a, r;
4241
+ const t = ((a = this.chatList.find((l) => l._id === e)) == null ? void 0 : a.bookmarked) ?? (e === this.activeId ? this.bookmarked : !1), s = !t, i = (l) => {
3655
4242
  this.chatList = this.chatList.map(
3656
4243
  (c) => c._id === e ? { ...c, bookmarked: l } : c
3657
4244
  ), e === this.activeId && (this.bookmarked = l);
3658
4245
  };
3659
- s(i), this.showToast(i ? this.msg.chatBookmarked : this.msg.chatUnbookmarked), this.emit("singlebase-chat-bookmark", { chatId: e, bookmarked: i });
4246
+ i(s), this.showToast(s ? this.msg.chatBookmarked : this.msg.chatUnbookmarked), this.emit("singlebase-chat-bookmark", { chatId: e, bookmarked: s });
3660
4247
  try {
3661
- await ((o = this.resolvedClient) == null ? void 0 : o.llm.call("bookmark_chat", { _id: e, bookmarked: i }));
4248
+ await ((r = this.resolvedClient) == null ? void 0 : r.llm.call("bookmark_chat", { _id: e, bookmarked: s }));
3662
4249
  } catch {
3663
- s(t), this.showToast(this.msg.errGeneric);
4250
+ i(t), this.showToast(this.msg.errGeneric);
3664
4251
  }
3665
4252
  }
3666
4253
  /** Removed at once; the server call waits out the undo window. */
3667
4254
  deleteMessage(e) {
3668
- var s;
3669
- const t = this.activeId, i = this.msgs.indexOf(e);
3670
- i < 0 || (this.msgs = this.msgs.filter((a) => a !== e), ((s = this.panel) == null ? void 0 : s.key) === e.key && (this.panel = null), this.showToast(this.msg.messageDeleted, {
4255
+ var i;
4256
+ const t = this.activeId, s = this.msgs.indexOf(e);
4257
+ s < 0 || (this.msgs = this.msgs.filter((a) => a !== e), ((i = this.panel) == null ? void 0 : i.key) === e.key && (this.panel = null), this.showToast(this.msg.messageDeleted, {
3671
4258
  undo: () => {
3672
4259
  if (this.activeId !== t) return;
3673
4260
  const a = [...this.msgs];
3674
- a.splice(i, 0, e), this.msgs = a;
4261
+ a.splice(s, 0, e), this.msgs = a;
3675
4262
  },
3676
4263
  commit: () => {
3677
4264
  var a;
@@ -3681,19 +4268,19 @@ assistant: ${i.slice(0, 1500)}`,
3681
4268
  }));
3682
4269
  }
3683
4270
  deleteChat(e) {
3684
- const t = this.chatList.findIndex((o) => o._id === e), i = this.chatList[t] ?? {
4271
+ const t = this.chatList.findIndex((r) => r._id === e), s = this.chatList[t] ?? {
3685
4272
  _id: e,
3686
4273
  title: this.chatTitle,
3687
4274
  bookmarked: this.bookmarked
3688
- }, s = e === this.activeId, a = s ? { title: this.chatTitle, bookmarked: this.bookmarked, msgs: this.msgs } : null;
3689
- this.chatList = this.chatList.filter((o) => o._id !== e), s && this.newChat(), this.showToast(this.msg.chatDeleted, {
4275
+ }, i = e === this.activeId, a = i ? { title: this.chatTitle, bookmarked: this.bookmarked, msgs: this.msgs } : null;
4276
+ this.chatList = this.chatList.filter((r) => r._id !== e), i && this.newChat(), this.showToast(this.msg.chatDeleted, {
3690
4277
  undo: () => {
3691
- const o = [...this.chatList];
3692
- o.splice(Math.max(0, t), 0, i), this.chatList = o, a && !this.activeId && !this.msgs.length && (this.activeId = e, this.chatTitle = a.title, this.bookmarked = a.bookmarked, this.msgs = a.msgs);
4278
+ const r = [...this.chatList];
4279
+ r.splice(Math.max(0, t), 0, s), this.chatList = r, a && !this.activeId && !this.msgs.length && (this.activeId = e, this.chatTitle = a.title, this.bookmarked = a.bookmarked, this.msgs = a.msgs);
3693
4280
  },
3694
4281
  commit: () => {
3695
- var o;
3696
- this.emit("singlebase-chat-delete", { chatId: e }), (o = this.resolvedClient) == null || o.llm.call("delete_chat", { _id: e }).catch(() => {
4282
+ var r;
4283
+ this.emit("singlebase-chat-delete", { chatId: e }), (r = this.resolvedClient) == null || r.llm.call("delete_chat", { _id: e }).catch(() => {
3697
4284
  });
3698
4285
  }
3699
4286
  });
@@ -3709,10 +4296,10 @@ assistant: ${i.slice(0, 1500)}`,
3709
4296
  // ── toasts ────────────────────────────────────────────────
3710
4297
  showToast(e, t = {}) {
3711
4298
  this.flushToast();
3712
- const i = { key: Date.now(), text: e, ...t };
3713
- this.toast = i, this.toastTimer = setTimeout(() => {
3714
- this.toast === i && this.flushToast();
3715
- }, Kt);
4299
+ const s = { key: Date.now(), text: e, ...t };
4300
+ this.toast = s, this.toastTimer = setTimeout(() => {
4301
+ this.toast === s && this.flushToast();
4302
+ }, Ss);
3716
4303
  }
3717
4304
  /** Ends the current toast, committing whatever it was holding back. */
3718
4305
  flushToast() {
@@ -3729,26 +4316,26 @@ assistant: ${i.slice(0, 1500)}`,
3729
4316
  async addFiles(e) {
3730
4317
  const t = Array.from(e ?? []);
3731
4318
  if (!t.length) return;
3732
- const i = [];
3733
- for (const s of t) {
3734
- if (this.files.length + i.length >= at) {
3735
- this.showToast(z(this.msg.tooManyFiles, { n: at }));
4319
+ const s = [];
4320
+ for (const i of t) {
4321
+ if (this.files.length + s.length >= zt) {
4322
+ this.showToast(L(this.msg.tooManyFiles, { n: zt }));
3736
4323
  break;
3737
4324
  }
3738
- if (!Ft.test(s.name) && !s.type.startsWith("text/")) {
3739
- this.showToast(z(this.msg.fileType, { name: s.name }));
4325
+ if (!Ts.test(i.name) && !i.type.startsWith("text/")) {
4326
+ this.showToast(L(this.msg.fileType, { name: i.name }));
3740
4327
  continue;
3741
4328
  }
3742
- if (s.size > rt) {
4329
+ if (i.size > _t) {
3743
4330
  this.showToast(
3744
- z(this.msg.fileTooLarge, { name: s.name, size: Ve(rt) })
4331
+ L(this.msg.fileTooLarge, { name: i.name, size: vt(_t) })
3745
4332
  );
3746
4333
  continue;
3747
4334
  }
3748
- i.push({ name: s.name, size: s.size, content: await s.text() });
4335
+ s.push({ name: i.name, size: i.size, content: await i.text() });
3749
4336
  }
3750
- i.length && (this.files = [...this.files, ...i], this.emit("singlebase-chat-files", {
3751
- files: i.map(({ name: s, size: a }) => ({ name: s, size: a }))
4337
+ s.length && (this.files = [...this.files, ...s], this.emit("singlebase-chat-files", {
4338
+ files: s.map(({ name: i, size: a }) => ({ name: i, size: a }))
3752
4339
  }));
3753
4340
  }
3754
4341
  // ── scrolling ─────────────────────────────────────────────
@@ -3786,7 +4373,7 @@ assistant: ${i.slice(0, 1500)}`,
3786
4373
  // ── drag and drop ─────────────────────────────────────────
3787
4374
  onDragEnter(e) {
3788
4375
  var t;
3789
- !this.allowUpload || !Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files") || (e.preventDefault(), this.dragging = !0);
4376
+ !this.allowUpload || !this.showComposer || Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files") && (e.preventDefault(), this.dragging = !0);
3790
4377
  }
3791
4378
  onDragLeave(e) {
3792
4379
  e.currentTarget.contains(e.relatedTarget) || (this.dragging = !1);
@@ -3803,16 +4390,16 @@ assistant: ${i.slice(0, 1500)}`,
3803
4390
  this.embed === "inline" ? "inline boxed" : "",
3804
4391
  this.expanded ? "expanded boxed" : ""
3805
4392
  ].join(" ");
3806
- return r`<div class=${e} part="frame">${this.renderWorkspace()}</div>`;
4393
+ return o`<div class=${e} part="frame">${this.renderWorkspace()}</div>`;
3807
4394
  }
3808
4395
  renderLauncher() {
3809
4396
  const e = this.msg, t = [
3810
4397
  "frame launcher boxed",
3811
4398
  this.expanded ? "expanded" : "",
3812
4399
  this.mobile ? "full" : ""
3813
- ].join(" "), i = this.isOpen ? r`<div class=${t} role="dialog" aria-label=${this.assistantName} part="frame">
4400
+ ].join(" "), s = this.isOpen ? o`<div class=${t} role="dialog" aria-label=${this.assistantName} part="frame">
3814
4401
  ${this.renderWorkspace()}
3815
- </div>` : m, s = this.bubble && !this.isOpen ? r`<div class="bubble" part="bubble">
4402
+ </div>` : f, i = this.bubble && !this.isOpen ? o`<div class="bubble" part="bubble">
3816
4403
  <button type="button" class="bubble-text" @click=${() => this.open()}>
3817
4404
  ${this.bubbleText || e.bubbleText}
3818
4405
  </button>
@@ -3823,9 +4410,9 @@ assistant: ${i.slice(0, 1500)}`,
3823
4410
  title=${e.dismiss}
3824
4411
  @click=${() => this.bubble = !1}
3825
4412
  >
3826
- ${y.close()}
4413
+ ${k.close()}
3827
4414
  </button>
3828
- </div>` : m, o = this.isOpen && (this.expanded || this.mobile) ? m : r`<button
4415
+ </div>` : f, r = this.isOpen && (this.expanded || this.mobile) ? f : o`<button
3829
4416
  type="button"
3830
4417
  class="launcher-btn"
3831
4418
  part="launcher"
@@ -3833,23 +4420,23 @@ assistant: ${i.slice(0, 1500)}`,
3833
4420
  aria-expanded=${this.isOpen ? "true" : "false"}
3834
4421
  @click=${() => this.isOpen ? this.close() : this.open()}
3835
4422
  >
3836
- ${this.isOpen ? y.chevronDown() : y.chat()}
3837
- ${this.unreadBadge && !this.seen && !this.isOpen ? r`<span class="badge"></span>` : m}
4423
+ ${this.isOpen ? k.chevronDown() : k.chat()}
4424
+ ${this.unreadBadge && !this.seen && !this.isOpen ? o`<span class="badge"></span>` : f}
3838
4425
  </button>`;
3839
- return r`${i}${s}${o}`;
4426
+ return o`${s}${i}${r}`;
3840
4427
  }
3841
4428
  renderWorkspace() {
3842
4429
  const e = !this.docked;
3843
- return r`<div class="root" @keydown=${this.onKeydown}>
3844
- ${this.sidebarOpen && e ? r`<div class="scrim" @click=${() => this.sidebarOpen = !1}></div>` : m}
3845
- ${this.sidebarOpen ? this.renderSidebar(e) : m}
4430
+ return o`<div class="root" @keydown=${this.onKeydown}>
4431
+ ${this.sidebarOpen && e ? o`<div class="scrim" @click=${() => this.sidebarOpen = !1}></div>` : f}
4432
+ ${this.sidebarOpen && this.sidebar !== "none" ? this.renderSidebar(e) : f}
3846
4433
  <main
3847
4434
  class="main"
3848
4435
  @dragenter=${this.onDragEnter}
3849
4436
  @dragover=${(t) => t.preventDefault()}
3850
4437
  >
3851
4438
  ${this.renderHeader()}
3852
- ${this.offline ? r`<div class="banner" role="status">${this.msg.offline}</div>` : m}
4439
+ ${this.offline ? o`<div class="banner" role="status">${this.msg.offline}</div>` : f}
3853
4440
  <div
3854
4441
  class="scroller"
3855
4442
  role="log"
@@ -3860,64 +4447,46 @@ assistant: ${i.slice(0, 1500)}`,
3860
4447
  >
3861
4448
  ${this.msgs.length || this.loadingThread || this.threadError ? this.renderThread() : this.renderWelcome()}
3862
4449
  </div>
3863
- ${this.showJump ? r`<button type="button" class="jump" @click=${this.jumpToLatest}>
4450
+ ${this.showJump ? o`<button type="button" class="jump" @click=${this.jumpToLatest}>
3864
4451
  ↓ ${this.msg.newReply}
3865
- </button>` : m}
4452
+ </button>` : f}
3866
4453
  ${this.renderComposer()}
3867
- ${this.branding ? r`<div class="branding" part="branding">
3868
- <a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
3869
- >${this.msg.brandingLabel}</a
3870
- >
3871
- </div>` : m}
3872
- ${this.toast ? r`<div class="toast" role="status">
4454
+ ${Gt(this.branding, this.brandingText, this.msg.brandingLabel, this.brandingUrl)}
4455
+ ${this.toast ? o`<div class="toast" role="status">
3873
4456
  <span>${this.toast.text}</span>
3874
- ${this.toast.undo ? r`<button type="button" @click=${this.undo}>${this.msg.undo}</button>` : m}
3875
- </div>` : m}
3876
- ${this.dragging ? r`<div
4457
+ ${this.toast.undo ? o`<button type="button" @click=${this.undo}>${this.msg.undo}</button>` : f}
4458
+ </div>` : f}
4459
+ ${this.dragging ? o`<div
3877
4460
  class="drop"
3878
4461
  @dragover=${(t) => t.preventDefault()}
3879
4462
  @dragleave=${this.onDragLeave}
3880
4463
  @drop=${this.onDrop}
3881
4464
  >
3882
4465
  <strong>${this.msg.dropTitle}</strong><span>${this.msg.dropSub}</span>
3883
- </div>` : m}
4466
+ </div>` : f}
3884
4467
  </main>
3885
4468
  ${this.renderPanel()}
3886
4469
  </div>`;
3887
4470
  }
3888
4471
  renderSidebar(e) {
3889
- const t = this.msg, i = this.search.trim().toLowerCase(), s = this.chatList.filter(
3890
- (l) => !i || (l.title ?? "").toLowerCase().includes(i)
3891
- ), a = [
3892
- [t.groupBookmarked, s.filter((l) => l.bookmarked)],
3893
- [
3894
- t.groupToday,
3895
- s.filter((l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "today")
3896
- ],
3897
- [
3898
- t.groupYesterday,
3899
- s.filter(
3900
- (l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "yesterday"
3901
- )
3902
- ],
3903
- [
3904
- t.groupWeek,
3905
- s.filter((l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "week")
3906
- ],
3907
- [
3908
- t.groupOlder,
3909
- s.filter((l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "older")
3910
- ]
4472
+ const t = this.msg, s = this.allowSearch ? this.search.trim().toLowerCase() : "", i = this.chatList.filter(
4473
+ (m) => !s || (m.title ?? "").toLowerCase().includes(s)
4474
+ ), a = (m) => this.showBookmarked && !!m.bookmarked, r = (m) => i.filter((b) => !a(b) && Rs(b._modified_at ?? b._created_at) === m), l = [
4475
+ [t.groupBookmarked, i.filter(a)],
4476
+ [t.groupToday, r("today")],
4477
+ [t.groupYesterday, r("yesterday")],
4478
+ [t.groupWeek, r("week")],
4479
+ [t.groupOlder, r("older")]
3911
4480
  ];
3912
- let o;
3913
- return this.listState === "loading" && !this.chatList.length ? o = r`<div aria-label=${t.loadingChats}>
3914
- ${[1, 2, 3, 4].map(() => r`<div class="skeleton"></div>`)}
3915
- </div>` : s.length ? o = a.filter(([, l]) => l.length).map(
3916
- ([l, c]) => r`<div class="group">${l}</div>
3917
- ${c.map((x) => this.renderThreadRow(x))}`
3918
- ) : o = r`<span class="side-note"
3919
- >${i ? z(t.noMatch, { query: this.search.trim() }) : t.noChats}</span
3920
- >`, r`<aside
4481
+ let c;
4482
+ return this.listState === "loading" && !this.chatList.length ? c = o`<div aria-label=${t.loadingChats}>
4483
+ ${[1, 2, 3, 4].map(() => o`<div class="skeleton"></div>`)}
4484
+ </div>` : i.length ? c = l.filter(([, m]) => m.length).map(
4485
+ ([m, b]) => o`<div class="group">${m}</div>
4486
+ ${b.map((C) => this.renderThreadRow(C))}`
4487
+ ) : c = o`<span class="side-note"
4488
+ >${s ? L(t.noMatch, { query: this.search.trim() }) : t.noChats}</span
4489
+ >`, o`<aside
3921
4490
  class="sidebar ${e ? "overlay" : "docked"}"
3922
4491
  part="sidebar"
3923
4492
  aria-label=${t.chats}
@@ -3931,133 +4500,149 @@ assistant: ${i.slice(0, 1500)}`,
3931
4500
  aria-label=${t.hideSidebar}
3932
4501
  @click=${() => this.sidebarOpen = !1}
3933
4502
  >
3934
- ${y.sidebar()}
4503
+ ${k.sidebar()}
3935
4504
  </button>
3936
4505
  </div>
3937
4506
  <div class="side-tools">
3938
- <button type="button" class="new-chat" @click=${() => this.newChat()}>
3939
- ${y.plus()}<span>${t.newChat}</span>
3940
- </button>
3941
- <input
3942
- class="search"
3943
- type="search"
3944
- placeholder=${t.searchChats}
3945
- aria-label=${t.searchChats}
3946
- .value=${this.search}
3947
- @input=${(l) => this.search = l.target.value}
3948
- />
4507
+ ${this.showNewChat ? o`<button type="button" class="new-chat" @click=${() => this.newChat()}>
4508
+ ${k.plus()}<span>${t.newChat}</span>
4509
+ </button>` : f}
4510
+ ${this.allowSearch ? o`<input
4511
+ class="search"
4512
+ type="search"
4513
+ placeholder=${t.searchChats}
4514
+ aria-label=${t.searchChats}
4515
+ .value=${this.search}
4516
+ @input=${(m) => this.search = m.target.value}
4517
+ />` : f}
4518
+ </div>
4519
+ <div class="threads">${c}</div>
4520
+ <div class="side-extra ${this.hasSidebarContent ? "filled" : ""}" part="sidebar-extra">
4521
+ <slot
4522
+ name="sidebar"
4523
+ @slotchange=${(m) => this.hasSidebarContent = m.target.assignedNodes().length > 0}
4524
+ ></slot>
3949
4525
  </div>
3950
- <div class="threads">${o}</div>
3951
4526
  </aside>`;
3952
4527
  }
3953
4528
  renderThreadRow(e) {
3954
- const t = this.msg, i = e._id === this.activeId, s = e.title || t.untitled;
4529
+ const t = this.msg, s = e._id === this.activeId, i = e.title || t.untitled;
3955
4530
  if (this.renamingId === e._id)
3956
- return r`<div class="thread active">
4531
+ return o`<div class="thread active">
3957
4532
  <input
3958
4533
  class="thread-rename"
3959
4534
  maxlength="80"
3960
- .value=${s}
4535
+ .value=${i}
3961
4536
  aria-label=${t.renameChat}
3962
- @keydown=${(o) => {
3963
- o.key === "Enter" && this.commitRename(e._id, o.target.value), o.key === "Escape" && (o.stopPropagation(), this.renamingId = "");
4537
+ @keydown=${(r) => {
4538
+ r.key === "Enter" && this.commitRename(e._id, r.target.value), r.key === "Escape" && (r.stopPropagation(), this.renamingId = "");
3964
4539
  }}
3965
- @blur=${(o) => this.commitRename(e._id, o.target.value)}
4540
+ @blur=${(r) => this.commitRename(e._id, r.target.value)}
3966
4541
  />
3967
4542
  </div>`;
3968
- const a = (o) => (l) => {
3969
- l.stopPropagation(), o();
4543
+ const a = (r) => (l) => {
4544
+ l.stopPropagation(), r();
3970
4545
  };
3971
- return r`<div
3972
- class="thread ${i ? "active" : ""}"
4546
+ return o`<div
4547
+ class="thread ${s ? "active" : ""}"
3973
4548
  role="button"
3974
4549
  tabindex="0"
3975
- aria-current=${i ? "true" : "false"}
4550
+ aria-current=${s ? "true" : "false"}
3976
4551
  @click=${() => this.openChat(e._id)}
3977
- @keydown=${(o) => o.key === "Enter" && this.openChat(e._id)}
4552
+ @keydown=${(r) => r.key === "Enter" && this.openChat(e._id)}
3978
4553
  >
3979
- <span class="thread-title">${s}</span>
4554
+ <span class="thread-title">${i}</span>
3980
4555
  <span class="thread-actions">
3981
- <button
3982
- type="button"
3983
- class="icon sm ${e.bookmarked ? "on" : ""}"
3984
- title=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
3985
- aria-label=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
3986
- @click=${a(() => this.toggleChatBookmark(e._id))}
3987
- >
3988
- ${y.bookmark(!!e.bookmarked)}
3989
- </button>
3990
- <button
3991
- type="button"
3992
- class="icon sm"
3993
- title=${t.renameChat}
3994
- aria-label=${t.renameChat}
3995
- @click=${a(() => {
4556
+ ${this.allowBookmark ? o`<button
4557
+ type="button"
4558
+ class="icon sm ${e.bookmarked ? "on" : ""}"
4559
+ title=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
4560
+ aria-label=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
4561
+ @click=${a(() => this.toggleChatBookmark(e._id))}
4562
+ >
4563
+ ${k.bookmark(!!e.bookmarked)}
4564
+ </button>` : f}
4565
+ ${this.allowRename ? o`<button
4566
+ type="button"
4567
+ class="icon sm"
4568
+ title=${t.renameChat}
4569
+ aria-label=${t.renameChat}
4570
+ @click=${a(() => {
3996
4571
  this.renamingId = e._id, this.focusNext = "input.thread-rename";
3997
4572
  })}
3998
- >
3999
- ${y.pencil()}
4000
- </button>
4001
- <button
4002
- type="button"
4003
- class="icon sm danger"
4004
- title=${t.deleteChat}
4005
- aria-label=${t.deleteChat}
4006
- @click=${a(() => this.deleteChat(e._id))}
4007
- >
4008
- ${y.trash()}
4009
- </button>
4573
+ >
4574
+ ${k.pencil()}
4575
+ </button>` : f}
4576
+ ${this.allowDelete ? o`<button
4577
+ type="button"
4578
+ class="icon sm danger"
4579
+ title=${t.deleteChat}
4580
+ aria-label=${t.deleteChat}
4581
+ @click=${a(() => this.deleteChat(e._id))}
4582
+ >
4583
+ ${k.trash()}
4584
+ </button>` : f}
4010
4585
  </span>
4011
4586
  </div>`;
4012
4587
  }
4013
4588
  renderHeader() {
4014
- const e = this.msg, t = !!this.activeId, i = (this.embed === "inline" || this.embed === "launcher") && !this.mobile, s = this.embed === "launcher" ? () => this.close() : this.expanded ? () => this.collapse() : null;
4015
- let a = m;
4016
- return this.showTitle && (a = this.editingTitle ? r`<input
4589
+ const e = this.msg, t = !!this.activeId, s = (this.embed === "inline" || this.embed === "launcher") && !this.mobile, i = this.embed === "launcher" ? () => this.close() : this.expanded ? () => this.collapse() : null;
4590
+ let a = f;
4591
+ return this.showTitle && (a = this.editingTitle ? o`<input
4017
4592
  class="title-input"
4018
4593
  maxlength="80"
4019
4594
  .value=${this.chatTitle}
4020
4595
  aria-label=${e.renameChat}
4021
- @keydown=${(o) => {
4022
- o.key === "Enter" && this.commitTitle(o.target.value), o.key === "Escape" && (o.stopPropagation(), this.editingTitle = !1);
4596
+ @keydown=${(r) => {
4597
+ r.key === "Enter" && this.commitTitle(r.target.value), r.key === "Escape" && (r.stopPropagation(), this.editingTitle = !1);
4023
4598
  }}
4024
- @blur=${(o) => this.commitTitle(o.target.value)}
4025
- />` : r`<button
4599
+ @blur=${(r) => this.commitTitle(r.target.value)}
4600
+ />` : o`<button
4026
4601
  type="button"
4027
4602
  class="title"
4028
4603
  part="title"
4029
- ?disabled=${!t}
4030
- title=${t ? e.renameChat : ""}
4604
+ ?disabled=${!t || !this.allowRename}
4605
+ title=${t && this.allowRename ? e.renameChat : ""}
4031
4606
  @click=${() => {
4032
4607
  this.editingTitle = !0, this.focusNext = "input.title-input";
4033
4608
  }}
4034
4609
  >
4035
4610
  ${this.chatTitle || e.untitled}
4036
- </button>`), r`<header class="header" part="header">
4611
+ </button>`), o`<header class="header" part="header">
4037
4612
  <div class="header-left">
4038
- ${this.sidebarOpen && this.docked ? m : r`<button
4613
+ ${this.sidebar === "none" || this.sidebarOpen && this.docked ? f : o`<button
4039
4614
  type="button"
4040
4615
  class="icon"
4041
4616
  title=${e.showChats}
4042
4617
  aria-label=${e.showChats}
4043
4618
  @click=${() => this.sidebarOpen = !0}
4044
4619
  >
4045
- ${y.sidebar()}
4620
+ ${k.sidebar()}
4046
4621
  </button>`}
4047
4622
  ${a}
4048
4623
  </div>
4049
4624
  <div class="header-right">
4050
- <button
4051
- type="button"
4052
- class="icon ${this.bookmarked ? "on" : ""}"
4053
- ?disabled=${!t}
4054
- title=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
4055
- aria-label=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
4056
- @click=${() => this.activeId && this.toggleChatBookmark(this.activeId)}
4057
- >
4058
- ${y.bookmark(this.bookmarked)}
4059
- </button>
4060
- ${this.allowExport ? r`<div class="menu-wrap">
4625
+ ${this.sidebar === "none" && this.showNewChat ? o`<button
4626
+ type="button"
4627
+ class="icon"
4628
+ ?disabled=${!this.msgs.length && !t}
4629
+ title=${e.newChat}
4630
+ aria-label=${e.newChat}
4631
+ @click=${() => this.newChat()}
4632
+ >
4633
+ ${k.plus()}
4634
+ </button>` : f}
4635
+ ${this.allowBookmark ? o`<button
4636
+ type="button"
4637
+ class="icon ${this.bookmarked ? "on" : ""}"
4638
+ ?disabled=${!t}
4639
+ title=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
4640
+ aria-label=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
4641
+ @click=${() => this.activeId && this.toggleChatBookmark(this.activeId)}
4642
+ >
4643
+ ${k.bookmark(this.bookmarked)}
4644
+ </button>` : f}
4645
+ ${this.allowExport ? o`<div class="menu-wrap">
4061
4646
  <button
4062
4647
  type="button"
4063
4648
  class="icon ${this.menuOpen ? "on" : ""}"
@@ -4068,38 +4653,38 @@ assistant: ${i.slice(0, 1500)}`,
4068
4653
  aria-expanded=${this.menuOpen ? "true" : "false"}
4069
4654
  @click=${() => this.menuOpen = !this.menuOpen}
4070
4655
  >
4071
- ${y.download()}
4656
+ ${k.download()}
4072
4657
  </button>
4073
- ${this.menuOpen ? this.renderExportMenu() : m}
4074
- </div>` : m}
4075
- <button
4076
- type="button"
4077
- class="icon danger"
4078
- ?disabled=${!t}
4079
- title=${e.deleteChat}
4080
- aria-label=${e.deleteChat}
4081
- @click=${() => this.activeId && this.deleteChat(this.activeId)}
4082
- >
4083
- ${y.trash()}
4084
- </button>
4085
- ${i || s ? r`<span class="divider"></span> ${i ? r`<button
4658
+ ${this.menuOpen ? this.renderExportMenu() : f}
4659
+ </div>` : f}
4660
+ ${this.allowDelete ? o`<button
4661
+ type="button"
4662
+ class="icon danger"
4663
+ ?disabled=${!t}
4664
+ title=${e.deleteChat}
4665
+ aria-label=${e.deleteChat}
4666
+ @click=${() => this.activeId && this.deleteChat(this.activeId)}
4667
+ >
4668
+ ${k.trash()}
4669
+ </button>` : f}
4670
+ ${s || i ? o`<span class="divider"></span> ${s ? o`<button
4086
4671
  type="button"
4087
4672
  class="icon"
4088
4673
  title=${this.expanded ? e.restore : e.expand}
4089
4674
  aria-label=${this.expanded ? e.restore : e.expand}
4090
4675
  @click=${() => this.expanded ? this.collapse() : this.expand()}
4091
4676
  >
4092
- ${this.expanded ? y.restore() : y.expand()}
4093
- </button>` : m}
4094
- ${s ? r`<button
4677
+ ${this.expanded ? k.restore() : k.expand()}
4678
+ </button>` : f}
4679
+ ${i ? o`<button
4095
4680
  type="button"
4096
4681
  class="icon"
4097
4682
  title=${e.minimize}
4098
4683
  aria-label=${e.minimize}
4099
- @click=${s}
4684
+ @click=${i}
4100
4685
  >
4101
- ${y.minimize()}
4102
- </button>` : m}` : m}
4686
+ ${k.minimize()}
4687
+ </button>` : f}` : f}
4103
4688
  </div>
4104
4689
  </header>`;
4105
4690
  }
@@ -4110,80 +4695,85 @@ assistant: ${i.slice(0, 1500)}`,
4110
4695
  [e.exportText, ".txt", "txt"],
4111
4696
  [e.exportCopy, "", "copy"]
4112
4697
  ];
4113
- return r`<div class="menu-scrim" @click=${() => this.menuOpen = !1}></div>
4698
+ return o`<div class="menu-scrim" @click=${() => this.menuOpen = !1}></div>
4114
4699
  <div class="menu" role="menu">
4115
4700
  <span class="label">${e.exportHeading}</span>
4116
4701
  ${t.map(
4117
- ([i, s, a]) => r`<button
4702
+ ([s, i, a]) => o`<button
4118
4703
  type="button"
4119
4704
  role="menuitem"
4120
4705
  class="menu-item"
4121
4706
  @click=${() => this.exportChat(a)}
4122
4707
  >
4123
- <span>${i}</span><span class="ext">${s}</span>
4708
+ <span>${s}</span><span class="ext">${i}</span>
4124
4709
  </button>`
4125
4710
  )}
4126
4711
  </div>`;
4127
4712
  }
4713
+ /** The suggestion cards. `[]` or `"none"` shows none; unset uses the mode's. */
4128
4714
  promptList() {
4129
4715
  const e = this.prompts;
4130
- return Array.isArray(e) && e.length ? e.map((t) => typeof t == "string" ? { text: t } : t).filter((t) => t == null ? void 0 : t.text).slice(0, 4) : typeof e == "string" && e.trim() ? e.split("|").map((t) => t.trim()).filter(Boolean).slice(0, 4).map((t) => ({ text: t })) : (ot[this.mode] ?? ot.chat).map(([t, i]) => ({
4716
+ return Array.isArray(e) ? e.map((t) => typeof t == "string" ? { text: t } : t).filter((t) => t == null ? void 0 : t.text).slice(0, 4) : typeof e == "string" && e.trim().toLowerCase() === "none" ? [] : typeof e == "string" && e.trim() ? e.split("|").map((t) => t.trim()).filter(Boolean).slice(0, 4).map((t) => ({ text: t })) : (Nt[this.mode] ?? Nt.chat).map(([t, s]) => ({
4131
4717
  label: t,
4132
- text: i
4718
+ text: s
4133
4719
  }));
4134
4720
  }
4135
4721
  renderWelcome() {
4136
- const e = this.msg, t = this.mode === "rag" ? "Rag" : this.mode === "rich" ? "Rich" : "Chat", i = (s) => e[`${s}${t}`];
4137
- return r`<div class="welcome" part="welcome">
4138
- <div class="welcome-head">
4139
- ${this.logoUrl && it(this.logoUrl, !0) ? r`<img class="welcome-logo" src=${this.logoUrl} alt="" />` : m}
4140
- <span class="label">${i("eyebrow")}</span>
4141
- <h2>${this.heading || i("heading")}</h2>
4142
- <p>${this.description || i("description")}</p>
4143
- </div>
4144
- <div class="prompts">
4145
- ${this.promptList().map(
4146
- (s) => r`<button
4147
- type="button"
4148
- class="prompt"
4149
- part="prompt"
4150
- @click=${() => this.send(s.text)}
4151
- >
4152
- <span class="label">${s.label || "Suggested"}</span>
4153
- <span class="prompt-text">${s.text}</span>
4154
- </button>`
4722
+ const e = this.msg, t = this.mode === "rag" ? "Rag" : "Chat", s = (r) => e[`${r}${t}`], i = this.eyebrow ?? s("eyebrow"), a = this.promptList();
4723
+ return o`<div class="welcome-slot">
4724
+ <slot name="welcome"
4725
+ ><div class="welcome" part="welcome">
4726
+ <div class="welcome-head">
4727
+ ${this.logoUrl && It(this.logoUrl, !0) ? o`<img class="welcome-logo" src=${this.logoUrl} alt="" />` : f}
4728
+ ${i ? o`<span class="label">${i}</span>` : f}
4729
+ <h2>${this.heading || s("heading")}</h2>
4730
+ <p>${this.description || s("description")}</p>
4731
+ </div>
4732
+ ${a.length ? o`<div class="prompts">
4733
+ ${a.map(
4734
+ (r) => o`<button
4735
+ type="button"
4736
+ class="prompt"
4737
+ part="prompt"
4738
+ @click=${() => this.send(r.text)}
4739
+ >
4740
+ <span class="label">${r.label || "Suggested"}</span>
4741
+ <span class="prompt-text">${r.text}</span>
4742
+ </button>`
4155
4743
  )}
4156
- </div>
4744
+ </div>` : f}
4745
+ </div></slot
4746
+ >
4157
4747
  </div>`;
4158
4748
  }
4159
4749
  renderThread() {
4160
4750
  const e = this.msgs.map((t) => t.role).lastIndexOf("assistant");
4161
- return r`<div class="thread-view">
4162
- ${this.threadError ? r`<div class="error-card" role="alert">
4751
+ return o`<div class="thread-view">
4752
+ ${this.threadError ? o`<div class="error-card" role="alert">
4163
4753
  <span>${this.threadError}</span>
4164
- ${this.activeId ? r`<button
4754
+ ${this.activeId ? o`<button
4165
4755
  type="button"
4166
4756
  class="btn"
4167
4757
  @click=${() => this.openChat(this.activeId)}
4168
4758
  >
4169
4759
  ${this.msg.retry}
4170
- </button>` : m}
4171
- </div>` : m}
4172
- ${this.loadingThread ? r`${[1, 2].map(() => r`<div class="skeleton" style="height:48px"></div>`)}` : m}
4173
- ${vt(
4760
+ </button>` : f}
4761
+ </div>` : f}
4762
+ ${this.loadingThread ? o`${[1, 2].map(() => o`<div class="skeleton" style="height:48px"></div>`)}` : f}
4763
+ ${Jt(
4174
4764
  this.msgs,
4175
4765
  (t) => t.key,
4176
- (t, i) => t.role === "user" ? this.renderUser(t) : this.renderBot(t, i === e)
4766
+ (t, s) => t.role === "user" ? this.renderUser(t) : this.renderBot(t, s === e)
4177
4767
  )}
4178
4768
  </div>`;
4179
4769
  }
4180
4770
  renderUser(e) {
4181
- const t = this.msg, i = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", s = e.attachments ?? [];
4182
- return r`<div class="msg user" part="message user">
4183
- ${s.length ? r`<div class="attachments">
4184
- ${s.map((a) => r`<span class="doc-chip"><span class="ext">${ct(a.name)}</span><span class="name">${a.name}</span></span>`)}
4185
- </div>` : m}
4186
- ${this.editingKey === e.key ? r`<div class="edit-box">
4771
+ const t = this.msg, s = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", i = e.attachments ?? [];
4772
+ return o`<div class="msg user" part="message user">
4773
+ ${i.length ? o`<div class="attachments">
4774
+ ${i.map((a) => o`<span class="doc-chip"><span class="ext">${Rt(a.name)}</span><span class="name">${a.name}</span></span>`)}
4775
+ </div>` : f}
4776
+ ${this.editingKey === e.key ? o`<div class="edit-box">
4187
4777
  <textarea
4188
4778
  rows="3"
4189
4779
  class="edit-input"
@@ -4201,11 +4791,11 @@ assistant: ${i.slice(0, 1500)}`,
4201
4791
  ${t.saveResend}
4202
4792
  </button>
4203
4793
  </div>
4204
- </div>` : r`<div class="bubble-user">${e.content}</div>
4794
+ </div>` : o`<div class="bubble-user">${e.content}</div>
4205
4795
  <div class="toolbar">
4206
- ${e.bookmarked ? r`<span class="saved">${y.bookmark(!0)}${t.saved}</span>` : m}
4207
- <span class="time">${i}</span>
4208
- ${this.busy ? m : r`<button
4796
+ ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${t.saved}</span>` : f}
4797
+ ${this.showTime ? o`<span class="time">${s}</span>` : f}
4798
+ ${this.busy ? f : o`<button
4209
4799
  type="button"
4210
4800
  class="icon"
4211
4801
  title=${t.edit}
@@ -4214,322 +4804,471 @@ assistant: ${i.slice(0, 1500)}`,
4214
4804
  this.editingKey = e.key, this.editDraft = e.content, this.focusNext = "textarea.edit-input";
4215
4805
  }}
4216
4806
  >
4217
- ${y.pencil()}
4807
+ ${k.pencil()}
4218
4808
  </button>`}
4219
- <button
4220
- type="button"
4221
- class="icon"
4222
- title=${this.copiedKey === e.key ? t.copied : t.copy}
4223
- aria-label=${t.copy}
4224
- @click=${() => this.copy(e.key, e.content)}
4225
- >
4226
- ${y.copy()}
4227
- </button>
4228
- ${e.id ? r`<button
4809
+ ${this.allowCopy ? o`<button
4810
+ type="button"
4811
+ class="icon"
4812
+ title=${this.copiedKey === e.key ? t.copied : t.copy}
4813
+ aria-label=${t.copy}
4814
+ @click=${() => this.copy(e.key, e.content)}
4815
+ >
4816
+ ${k.copy()}
4817
+ </button>` : f}
4818
+ ${this.allowBookmark && e.id ? o`<button
4229
4819
  type="button"
4230
4820
  class="icon ${e.bookmarked ? "on" : ""}"
4231
4821
  title=${e.bookmarked ? t.unbookmarkMessage : t.bookmarkMessage}
4232
4822
  aria-label=${e.bookmarked ? t.unbookmarkMessage : t.bookmarkMessage}
4233
4823
  @click=${() => this.toggleMessageBookmark(e)}
4234
4824
  >
4235
- ${y.bookmark(e.bookmarked)}
4236
- </button>` : m}
4237
- <button
4238
- type="button"
4239
- class="icon danger"
4240
- title=${t.deleteMessage}
4241
- aria-label=${t.deleteMessage}
4242
- @click=${() => this.deleteMessage(e)}
4243
- >
4244
- ${y.trash()}
4245
- </button>
4825
+ ${k.bookmark(e.bookmarked)}
4826
+ </button>` : f}
4827
+ ${this.allowDelete ? o`<button
4828
+ type="button"
4829
+ class="icon danger"
4830
+ title=${t.deleteMessage}
4831
+ aria-label=${t.deleteMessage}
4832
+ @click=${() => this.deleteMessage(e)}
4833
+ >
4834
+ ${k.trash()}
4835
+ </button>` : f}
4246
4836
  </div>`}
4247
4837
  </div>`;
4248
4838
  }
4249
4839
  pillLabel() {
4250
- return this.mode === "rag" ? this.msg.searching : this.mode === "rich" ? this.msg.building : this.msg.thinking;
4840
+ return this.mode === "rag" ? this.msg.searching : this.msg.thinking;
4251
4841
  }
4252
4842
  renderBot(e, t) {
4253
- const i = this.msg, s = e.phase === "pending", a = e.phase === "done", o = e.sources.length, l = Ze(e.content), c = e.sources.map((b, M) => Ke(b, M + 1)), x = l.size ? c.filter((b) => l.has(b.n)) : c, f = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", O = e.content + (x.length ? `
4843
+ const s = this.msg, i = e.phase === "pending", a = e.phase === "done", r = e.sources.length, l = Tt(e.content), c = e.sources.map((w, _) => gt(w, _ + 1)), m = l.size ? c.filter((w) => l.has(w.n)) : c, b = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", C = e.content + (m.length ? `
4254
4844
 
4255
4845
  Sources:
4256
- ${x.map((b) => `[${b.n}] ${b.title}`).join(`
4846
+ ${m.map((w) => `[${w.n}] ${w.title}`).join(`
4257
4847
  `)}` : ""), S = this.retrievalOpen.has(e.key);
4258
- return r`<div class="msg bot" part="message assistant">
4259
- ${s ? r`<div class="halo"></div>` : m}
4260
- ${this.arrivedKey === e.key ? r`<div class="arrived">
4848
+ return o`<div class="msg bot" part="message assistant">
4849
+ ${i ? o`<div class="halo"></div>` : f}
4850
+ ${this.arrivedKey === e.key ? o`<div class="arrived">
4261
4851
  <div class="wash"></div>
4262
4852
  <div class="ring"></div>
4263
4853
  <div class="sweep"></div>
4264
- </div>` : m}
4854
+ </div>` : f}
4265
4855
  <div class="bot-body">
4266
- ${e.bookmarked ? r`<span class="saved">${y.bookmark(!0)}${i.saved}</span>` : m}
4267
- ${s ? r`<div class="pill" role="status">
4856
+ ${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${s.saved}</span>` : f}
4857
+ ${i ? o`<div class="pill" role="status">
4268
4858
  <span class="ring"></span><span class="dot"></span>
4269
4859
  <span class="shimmer">${this.pillLabel()}</span>
4270
- </div>` : m}
4271
- ${o && !s ? r`<div class="retrieval">
4860
+ </div>` : f}
4861
+ ${this.showSources && r && !i ? o`<div class="retrieval">
4272
4862
  <button
4273
4863
  type="button"
4274
4864
  class="retrieval-toggle"
4275
4865
  aria-expanded=${S ? "true" : "false"}
4276
4866
  @click=${() => {
4277
- const b = new Set(this.retrievalOpen);
4278
- b.has(e.key) ? b.delete(e.key) : b.add(e.key), this.retrievalOpen = b;
4867
+ const w = new Set(this.retrievalOpen);
4868
+ w.has(e.key) ? w.delete(e.key) : w.add(e.key), this.retrievalOpen = w;
4279
4869
  }}
4280
4870
  >
4281
4871
  <span class="chev">${S ? "▾" : "▸"}</span>
4282
- <span style="flex:1">${z(i.searchedSources, { n: o })}</span>
4283
- ${e.execTime !== void 0 ? r`<span class="ms">${e.execTime.toFixed(1)}s</span>` : m}
4872
+ <span style="flex:1">${L(s.searchedSources, { n: r })}</span>
4873
+ ${e.execTime !== void 0 ? o`<span class="ms">${e.execTime.toFixed(1)}s</span>` : f}
4284
4874
  </button>
4285
- ${S ? r`<div class="retrieval-list">
4875
+ ${S ? o`<div class="retrieval-list">
4286
4876
  ${c.map(
4287
- (b) => r`<button
4877
+ (w) => o`<button
4288
4878
  type="button"
4289
4879
  class="passage"
4290
- @click=${() => this.panel = { key: e.key, n: b.n }}
4880
+ @click=${() => this.panel = { key: e.key, n: w.n }}
4291
4881
  >
4292
- <span class="n">${b.n}</span>
4882
+ <span class="n">${w.n}</span>
4293
4883
  <span class="what"
4294
- ><span>${b.title}</span><span>${b.collection || b.path}</span></span
4884
+ ><span>${w.title}</span><span>${w.collection || w.path}</span></span
4295
4885
  >
4296
- ${b.score !== null ? r`<span class="relevance"
4297
- ><span class="score">${b.score.toFixed(2)}</span>
4886
+ ${w.score !== null ? o`<span class="relevance"
4887
+ ><span class="score">${w.score.toFixed(2)}</span>
4298
4888
  <span class="relevance-track"
4299
4889
  ><span
4300
4890
  class="relevance-fill"
4301
- style="width:${Math.round(b.score * 100)}%"
4891
+ style="width:${Math.round(w.score * 100)}%"
4302
4892
  ></span></span
4303
- ></span>` : r`<span></span>`}
4893
+ ></span>` : o`<span></span>`}
4304
4894
  </button>`
4305
4895
  )}
4306
- </div>` : m}
4307
- </div>` : m}
4308
- ${s ? m : this.renderAnswer(e)}
4309
- ${e.phase === "streaming" ? r`<span class="caret"></span>` : m}
4310
- ${e.phase === "error" ? r`<div class="error-card" role="alert">
4896
+ </div>` : f}
4897
+ </div>` : f}
4898
+ ${i ? f : this.renderAnswer(e)}
4899
+ ${e.phase === "streaming" ? o`<span class="caret"></span>` : f}
4900
+ ${e.phase === "error" ? o`<div class="error-card" role="alert">
4311
4901
  <span>${e.error}</span>
4312
4902
  <button type="button" class="btn" @click=${() => this.retry(e)}>
4313
- ${i.retry}
4903
+ ${s.retry}
4314
4904
  </button>
4315
- </div>` : m}
4316
- ${a && x.length ? r`<div class="cards">
4317
- <span class="label">${l.size ? i.sourcesCited : i.sourcesRetrieved}</span>
4905
+ </div>` : f}
4906
+ ${this.showSources && a && m.length ? o`<div class="cards">
4907
+ <span class="label">${l.size ? s.sourcesCited : s.sourcesRetrieved}</span>
4318
4908
  <div class="card-grid">
4319
- ${x.map(
4320
- (b) => {
4321
- var M;
4322
- return r`<button
4909
+ ${m.map(
4910
+ (w) => {
4911
+ var _;
4912
+ return o`<button
4323
4913
  type="button"
4324
- class="source-card ${((M = this.panel) == null ? void 0 : M.key) === e.key && this.panel.n === b.n ? "active" : ""}"
4325
- @click=${() => this.panel = { key: e.key, n: b.n }}
4914
+ class="source-card ${((_ = this.panel) == null ? void 0 : _.key) === e.key && this.panel.n === w.n ? "active" : ""}"
4915
+ @click=${() => this.panel = { key: e.key, n: w.n }}
4326
4916
  >
4327
4917
  <span class="top"
4328
- ><span class="num">${b.n}</span
4329
- >${b.collection ? r`<span class="label">${b.collection}</span>` : m}</span
4918
+ ><span class="num">${w.n}</span
4919
+ >${w.collection ? o`<span class="label">${w.collection}</span>` : f}</span
4330
4920
  >
4331
- <span class="t">${b.title}</span>
4332
- <span class="s">${b.text}</span>
4921
+ <span class="t">${w.title}</span>
4922
+ <span class="s">${w.text}</span>
4333
4923
  </button>`;
4334
4924
  }
4335
4925
  )}
4336
4926
  </div>
4337
- </div>` : m}
4338
- ${a ? r`<div class="toolbar ${t ? "pinned" : ""}">
4339
- <button
4340
- type="button"
4341
- class="icon"
4342
- title=${this.copiedKey === e.key ? i.copied : i.copy}
4343
- aria-label=${i.copy}
4344
- @click=${() => this.copy(e.key, O)}
4345
- >
4346
- ${y.copy()}
4347
- </button>
4348
- ${t && !this.busy ? r`<button
4927
+ </div>` : f}
4928
+ ${a ? o`<div class="toolbar ${t ? "pinned" : ""}">
4929
+ ${this.allowCopy ? o`<button
4930
+ type="button"
4931
+ class="icon"
4932
+ title=${this.copiedKey === e.key ? s.copied : s.copy}
4933
+ aria-label=${s.copy}
4934
+ @click=${() => this.copy(e.key, C)}
4935
+ >
4936
+ ${k.copy()}
4937
+ </button>` : f}
4938
+ ${this.allowRaw && this.formatLevel !== "raw" && e.content ? o`<button
4939
+ type="button"
4940
+ class="icon ${this.rawKeys.has(e.key) ? "on" : ""}"
4941
+ title=${this.rawKeys.has(e.key) ? s.showFormatted : s.showRaw}
4942
+ aria-label=${s.showRaw}
4943
+ aria-pressed=${this.rawKeys.has(e.key) ? "true" : "false"}
4944
+ @click=${() => this.toggleRaw(e.key)}
4945
+ >
4946
+ ${k.raw()}
4947
+ </button>` : f}
4948
+ ${this.allowRegenerate && t && !this.busy ? o`<button
4349
4949
  type="button"
4350
4950
  class="icon"
4351
- title=${i.regenerate}
4352
- aria-label=${i.regenerate}
4951
+ title=${s.regenerate}
4952
+ aria-label=${s.regenerate}
4353
4953
  @click=${() => this.regenerate()}
4354
4954
  >
4355
- ${y.refresh()}
4356
- </button>` : m}
4357
- ${e.id ? r`<button
4955
+ ${k.refresh()}
4956
+ </button>` : f}
4957
+ ${this.allowBookmark && e.id ? o`<button
4358
4958
  type="button"
4359
4959
  class="icon ${e.bookmarked ? "on" : ""}"
4360
- title=${e.bookmarked ? i.unbookmarkMessage : i.bookmarkMessage}
4361
- aria-label=${e.bookmarked ? i.unbookmarkMessage : i.bookmarkMessage}
4960
+ title=${e.bookmarked ? s.unbookmarkMessage : s.bookmarkMessage}
4961
+ aria-label=${e.bookmarked ? s.unbookmarkMessage : s.bookmarkMessage}
4362
4962
  @click=${() => this.toggleMessageBookmark(e)}
4363
4963
  >
4364
- ${y.bookmark(e.bookmarked)}
4365
- </button>` : m}
4366
- <button
4367
- type="button"
4368
- class="icon danger"
4369
- title=${i.deleteMessage}
4370
- aria-label=${i.deleteMessage}
4371
- @click=${() => this.deleteMessage(e)}
4372
- >
4373
- ${y.trash()}
4374
- </button>
4375
- <span class="time">${f}</span>
4376
- ${e.stopped ? r`<span class="note">${i.stopped}</span>` : m}
4964
+ ${k.bookmark(e.bookmarked)}
4965
+ </button>` : f}
4966
+ ${this.allowDelete ? o`<button
4967
+ type="button"
4968
+ class="icon danger"
4969
+ title=${s.deleteMessage}
4970
+ aria-label=${s.deleteMessage}
4971
+ @click=${() => this.deleteMessage(e)}
4972
+ >
4973
+ ${k.trash()}
4974
+ </button>` : f}
4975
+ ${this.showTime ? o`<span class="time">${b}</span>` : f}
4976
+ ${e.stopped ? o`<span class="note">${s.stopped}</span>` : f}
4377
4977
  <span class="spacer"></span>
4378
- ${e.feedback ? r`<span class="note"
4379
- >${e.feedback === "up" ? i.markedHelpful : i.thanksFeedback}</span
4380
- >` : r`<button
4381
- type="button"
4382
- class="icon"
4383
- title=${i.helpful}
4384
- aria-label=${i.helpful}
4385
- @click=${() => this.feedback(e, "up")}
4386
- >
4387
- ${y.thumb()}
4388
- </button>
4389
- <button
4390
- type="button"
4391
- class="icon"
4392
- title=${i.notHelpful}
4393
- aria-label=${i.notHelpful}
4394
- @click=${() => this.feedback(e, "down")}
4395
- >
4396
- ${y.thumb(!0)}
4397
- </button>`}
4398
- </div>` : m}
4399
- ${a && t && !this.busy && e.followups.length ? r`<div class="followups">
4978
+ ${this.allowFeedback ? e.feedback ? o`<span class="note"
4979
+ >${e.feedback === "up" ? s.markedHelpful : s.thanksFeedback}</span
4980
+ >` : o`<button
4981
+ type="button"
4982
+ class="icon"
4983
+ title=${s.helpful}
4984
+ aria-label=${s.helpful}
4985
+ @click=${() => this.feedback(e, "up")}
4986
+ >
4987
+ ${k.thumb()}
4988
+ </button>
4989
+ <button
4990
+ type="button"
4991
+ class="icon"
4992
+ title=${s.notHelpful}
4993
+ aria-label=${s.notHelpful}
4994
+ @click=${() => this.feedback(e, "down")}
4995
+ >
4996
+ ${k.thumb(!0)}
4997
+ </button>` : f}
4998
+ </div>` : f}
4999
+ ${this.showFollowups && a && t && !this.busy && e.followups.length ? o`<div class="followups">
4400
5000
  ${e.followups.map(
4401
- (b) => r`<button type="button" class="followup" @click=${() => this.send(b)}>
4402
- <span class="arrow">↳</span><span>${b}</span>
5001
+ (w) => o`<button type="button" class="followup" @click=${() => this.send(w)}>
5002
+ <span class="arrow">↳</span><span>${w}</span>
4403
5003
  </button>`
4404
5004
  )}
4405
- </div>` : m}
5005
+ </div>` : f}
4406
5006
  </div>
4407
5007
  </div>`;
4408
5008
  }
4409
5009
  renderAnswer(e) {
4410
- if (e.phase === "error" && !e.content) return m;
5010
+ if (e.phase === "error" && !e.content) return f;
4411
5011
  if (e.phase === "done" && !e.content)
4412
- return e.stopped ? m : r`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;
4413
- const t = _t(zt(e.content), this.renderAs), i = this.renderAs === "text" ? 0 : e.sources.length;
4414
- return r`<div class="answer" part="answer">
4415
- ${t.map((s, a) => this.renderBlock(s, e, i, a))}
5012
+ return e.stopped ? f : o`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;
5013
+ const t = this.formatLevel;
5014
+ if (t === "raw" || this.allowRaw && this.rawKeys.has(e.key))
5015
+ return o`<div class="answer" part="answer"><p class="raw">${e.content}</p></div>`;
5016
+ const s = e.phase === "streaming" ? ls(e.content) : e.content;
5017
+ let i = ps(is(s), t);
5018
+ if (this.afterParse)
5019
+ try {
5020
+ const r = this.afterParse(i, { message: e, format: t });
5021
+ Array.isArray(r) ? i = r : console.warn(
5022
+ "[singlebase-chat] afterParse must return an array of blocks; showing the original."
5023
+ );
5024
+ } catch (r) {
5025
+ console.warn("[singlebase-chat] afterParse failed; showing the original.", r);
5026
+ }
5027
+ const a = e.sources.length;
5028
+ return o`<div class="answer" part="answer">
5029
+ ${i.map((r, l) => this.renderBlock(r, e, a, l))}
4416
5030
  </div>`;
4417
5031
  }
4418
- renderInline(e, t, i) {
4419
- return Mt(e, i).map((s) => {
5032
+ renderInline(e, t, s) {
5033
+ return ns(e, s).map((i) => {
4420
5034
  var a;
4421
- switch (s.type) {
5035
+ switch (i.type) {
4422
5036
  case "bold":
4423
- return r`<strong>${s.text}</strong>`;
5037
+ return o`<strong>${i.text}</strong>`;
5038
+ case "italic":
5039
+ return o`<em>${i.text}</em>`;
5040
+ case "strike":
5041
+ return o`<s>${i.text}</s>`;
4424
5042
  case "code":
4425
- return r`<code class="inline">${s.text}</code>`;
5043
+ return o`<code class="inline">${i.text}</code>`;
4426
5044
  case "link":
4427
- return r`<a href=${s.href} target="_blank" rel="noopener noreferrer nofollow"
4428
- >${s.text}</a
5045
+ return o`<a href=${i.href} target="_blank" rel="noopener noreferrer nofollow"
5046
+ >${i.text}</a
4429
5047
  >`;
4430
5048
  case "cite": {
4431
- const o = ((a = this.panel) == null ? void 0 : a.key) === t.key && this.panel.n === s.n ? "cite active" : "cite", l = z(this.msg.openSource, { n: s.n });
4432
- return r`<button type="button" class=${o} aria-label=${l} @click=${() => this.panel = { key: t.key, n: s.n }}>${s.n}</button>`;
5049
+ const r = ((a = this.panel) == null ? void 0 : a.key) === t.key && this.panel.n === i.n ? "cite active" : "cite", l = L(this.msg.openSource, { n: i.n });
5050
+ return o`<button type="button" class=${r} aria-label=${l} @click=${() => this.panel = { key: t.key, n: i.n }}>${i.n}</button>`;
4433
5051
  }
4434
5052
  default:
4435
- return s.text;
5053
+ return i.text;
4436
5054
  }
4437
5055
  });
4438
5056
  }
4439
- renderBlock(e, t, i, s) {
5057
+ renderBlock(e, t, s, i) {
4440
5058
  switch (e.type) {
4441
5059
  case "p":
4442
- return r`<p>${this.renderInline(e.text, t, i)}</p>`;
5060
+ return o`<p>${this.renderInline(e.text, t, s)}</p>`;
4443
5061
  case "raw":
4444
- return r`<p class="raw">${e.text}</p>`;
5062
+ return o`<p class="raw">${e.text}</p>`;
4445
5063
  case "h":
4446
- return r`<h3>${this.renderInline(e.text, t, i)}</h3>`;
4447
- case "list": {
4448
- const a = e.items.map(
4449
- (o) => r`<li>${this.renderInline(o, t, i)}</li>`
4450
- );
4451
- return e.ordered ? r`<ol>
4452
- ${a}
4453
- </ol>` : r`<ul>
4454
- ${a}
4455
- </ul>`;
4456
- }
5064
+ return o`<h3 class="h${e.level}">${this.renderInline(e.text, t, s)}</h3>`;
5065
+ case "hr":
5066
+ return o`<hr />`;
5067
+ case "list":
5068
+ return this.renderList(e.ordered, e.items, t, s);
4457
5069
  case "quote":
4458
- return r`<div class="quote">${this.renderInline(e.text, t, i)}</div>`;
4459
- case "code": {
4460
- const a = `${t.key}:${s}`;
4461
- return r`<div class="code">
4462
- <div class="code-head">
4463
- <span class="label">${e.lang}</span>
4464
- <button type="button" class="text-btn" @click=${() => this.copy(a, e.text)}>
4465
- ${this.copiedKey === a ? this.msg.copied : this.msg.copy}
4466
- </button>
4467
- </div>
4468
- <pre><code>${e.text}</code></pre>
5070
+ return o`<div class="quote">${this.renderInline(e.text, t, s)}</div>`;
5071
+ case "callout":
5072
+ return o`<div class="callout ${e.kind}" role="note" part="callout">
5073
+ <strong class="callout-title"
5074
+ >${e.title || this.msg[Is[e.kind]]}</strong
5075
+ >
5076
+ ${e.text.split(`
5077
+ `).filter((a) => a.trim()).map((a) => o`<p>${this.renderInline(a, t, s)}</p>`)}
4469
5078
  </div>`;
4470
- }
5079
+ case "code":
5080
+ return this.renderCustom(e.lang, e.text, t) ?? this.renderCode(e.lang, e.text, `${t.key}:${i}`);
4471
5081
  case "table":
4472
- return r`<div class="table">
4473
- <table>
4474
- <thead>
4475
- <tr>
4476
- ${e.head.map((a) => r`<th>${this.renderInline(a, t, i)}</th>`)}
4477
- </tr>
4478
- </thead>
4479
- <tbody>
4480
- ${e.rows.map(
4481
- (a) => r`<tr>
4482
- ${a.map((o) => r`<td>${this.renderInline(o, t, i)}</td>`)}
4483
- </tr>`
4484
- )}
4485
- </tbody>
4486
- </table>
5082
+ return this.renderTable(
5083
+ e.head,
5084
+ e.rows,
5085
+ e.align,
5086
+ t,
5087
+ s,
5088
+ `${t.key}:${i}`
5089
+ );
5090
+ case "json":
5091
+ return this.renderJsonBlock(e.value, e.source, `${t.key}:${i}`);
5092
+ case "svg": {
5093
+ const a = bs(e.source);
5094
+ if (!a) return this.renderCode("svg", e.source, `${t.key}:${i}`);
5095
+ const r = `${t.key}:${i}`;
5096
+ return o`<figure class="svg" part="svg">
5097
+ <img src=${a} alt="Drawing" />
5098
+ <figcaption>
5099
+ <button type="button" class="text-btn" @click=${() => this.copy(r, e.source)}>
5100
+ ${this.copiedKey === r ? this.msg.copied : this.msg.copySvg}
5101
+ </button>
5102
+ </figcaption>
5103
+ </figure>`;
5104
+ }
5105
+ case "pending":
5106
+ return o`<div class="chart-pending">
5107
+ <span class="label"
5108
+ >${e.kind === "svg" ? this.msg.renderingSvg : this.msg.renderingChart}</span
5109
+ >
4487
5110
  </div>`;
4488
5111
  case "chart":
4489
5112
  return this.renderChart(e.spec);
4490
- case "chartPending":
4491
- return r`<div class="chart-pending"><span class="label">Rendering chart</span></div>`;
4492
5113
  case "img":
4493
- return r`<div class="gallery ${e.images.length > 1 ? "many" : ""}">
5114
+ return o`<div class="gallery ${e.images.length > 1 ? "many" : ""}">
4494
5115
  ${e.images.map(
4495
- (a) => r`<figure>
4496
- ${a.src && it(a.src, !0) ? r`<img
5116
+ (a) => o`<figure>
5117
+ ${a.src && It(a.src, !0) ? o`<img
4497
5118
  src=${a.src}
4498
5119
  alt=${a.alt}
4499
5120
  loading="lazy"
4500
5121
  referrerpolicy="no-referrer"
4501
- />` : r`<div class="img-missing"><span class="label">Image</span></div>`}
4502
- ${a.alt ? r`<figcaption>${a.alt}</figcaption>` : m}
5122
+ />` : o`<div class="img-missing"><span class="label">Image</span></div>`}
5123
+ ${a.alt ? o`<figcaption>${a.alt}</figcaption>` : f}
4503
5124
  </figure>`
4504
5125
  )}
4505
5126
  </div>`;
4506
5127
  default:
4507
- return m;
5128
+ return f;
4508
5129
  }
4509
5130
  }
5131
+ renderList(e, t, s, i) {
5132
+ const a = t.map(
5133
+ (r) => o`<li
5134
+ class=${r.checked === null ? "" : "task"}
5135
+ style=${r.depth ? `margin-left:${r.depth * 20}px` : ""}
5136
+ >
5137
+ ${r.checked === null ? f : o`<input type="checkbox" disabled .checked=${r.checked} aria-hidden="true" />`}
5138
+ ${this.renderInline(r.text, s, i)}
5139
+ </li>`
5140
+ );
5141
+ return e ? o`<ol>
5142
+ ${a}
5143
+ </ol>` : o`<ul>
5144
+ ${a}
5145
+ </ul>`;
5146
+ }
5147
+ renderCode(e, t, s) {
5148
+ return o`<div class="code">
5149
+ <div class="code-head">
5150
+ <span class="label">${e}</span>
5151
+ <button type="button" class="text-btn" @click=${() => this.copy(s, t)}>
5152
+ ${this.copiedKey === s ? this.msg.copied : this.msg.copy}
5153
+ </button>
5154
+ </div>
5155
+ <pre><code>${t}</code></pre>
5156
+ </div>`;
5157
+ }
5158
+ /** A host renderer for this language, at the rich level only. */
5159
+ renderCustom(e, t, s) {
5160
+ var a;
5161
+ const i = this.formatLevel === "rich" ? (a = this.renderers) == null ? void 0 : a[e] : void 0;
5162
+ if (typeof i != "function" || s.phase === "streaming") return null;
5163
+ try {
5164
+ const r = i(t, { lang: e, message: s });
5165
+ return r == null ? null : o`<div class="custom-block">${r}</div>`;
5166
+ } catch (r) {
5167
+ return console.warn(`[singlebase-chat] the "${e}" renderer failed; showing the source`, r), null;
5168
+ }
5169
+ }
5170
+ renderTable(e, t, s, i, a, r) {
5171
+ const l = (x) => /^[-+]?[$€£¥]?\s?[\d,.]+\s?%?$/.test(x.trim()) && /\d/.test(x), c = (x) => Number(x.replace(/[^\d.+-]/g, "")), m = e.map((x, T) => {
5172
+ if (s[T]) return s[T];
5173
+ const $ = t.map((j) => j[T] ?? "").filter(Boolean);
5174
+ return $.length && $.filter(l).length / $.length >= 0.8 ? "right" : null;
5175
+ }), b = this.sorts.get(r);
5176
+ let C = t;
5177
+ b && (C = [...t].sort((x, T) => {
5178
+ const $ = x[b.col] ?? "", j = T[b.col] ?? "";
5179
+ return (l($) && l(j) ? c($) - c(j) : $.localeCompare(j, void 0, { numeric: !0 })) * b.dir;
5180
+ }));
5181
+ const S = C.length;
5182
+ C = C.slice(0, Os);
5183
+ const w = (x) => {
5184
+ const T = new Map(this.sorts), $ = T.get(r);
5185
+ ($ == null ? void 0 : $.col) === x && $.dir === -1 ? T.delete(r) : T.set(r, { col: x, dir: ($ == null ? void 0 : $.col) === x ? -1 : 1 }), this.sorts = T;
5186
+ }, _ = (x) => m[x] ? `text-align:${m[x]}` : "";
5187
+ return o`<div class="table" part="table">
5188
+ <table>
5189
+ <thead>
5190
+ <tr>
5191
+ ${e.map((x, T) => {
5192
+ const $ = (b == null ? void 0 : b.col) === T ? b.dir === 1 ? "ascending" : "descending" : "none";
5193
+ return o`<th style=${_(T)} aria-sort=${$}>
5194
+ ${t.length > 1 ? o`<button type="button" class="sort" @click=${() => w(T)}>
5195
+ ${this.renderInline(x, i, a)}<span class="arrow"
5196
+ >${$ === "ascending" ? "↑" : $ === "descending" ? "↓" : "↕"}</span
5197
+ >
5198
+ </button>` : this.renderInline(x, i, a)}
5199
+ </th>`;
5200
+ })}
5201
+ </tr>
5202
+ </thead>
5203
+ <tbody>
5204
+ ${C.map(
5205
+ (x) => o`<tr>
5206
+ ${e.map(
5207
+ (T, $) => o`<td style=${_($)}>
5208
+ ${this.renderInline(x[$] ?? "", i, a)}
5209
+ </td>`
5210
+ )}
5211
+ </tr>`
5212
+ )}
5213
+ </tbody>
5214
+ </table>
5215
+ ${S > C.length ? o`<div class="table-note">
5216
+ ${L(this.msg.showingRows, { n: C.length, total: S })}
5217
+ </div>` : f}
5218
+ </div>`;
5219
+ }
5220
+ renderJsonBlock(e, t, s) {
5221
+ let i = 0;
5222
+ const a = (l) => {
5223
+ i++, i <= Lt && l && typeof l == "object" && Object.values(l).forEach(a);
5224
+ };
5225
+ if (a(e), i > Lt) return this.renderCode("json", t, s);
5226
+ const r = (l, c, m) => {
5227
+ const b = m === void 0 ? f : o`<span class="jkey">${m}</span>: `;
5228
+ if (l && typeof l == "object") {
5229
+ const S = Object.entries(l), w = Array.isArray(l) ? `[${S.length}]` : `{${S.length}}`;
5230
+ return o`<details class="jnode" ?open=${c < 2}>
5231
+ <summary>${b}<span class="jmeta">${w}</span></summary>
5232
+ <div class="jkids">${S.map(([_, x]) => r(x, c + 1, _))}</div>
5233
+ </details>`;
5234
+ }
5235
+ return o`<div class="jleaf">
5236
+ ${b}<span class="jv ${l === null ? "null" : typeof l}">${JSON.stringify(l)}</span>
5237
+ </div>`;
5238
+ };
5239
+ return o`<div class="code json" part="json">
5240
+ <div class="code-head">
5241
+ <span class="label">json</span>
5242
+ <button type="button" class="text-btn" @click=${() => this.copy(s, t)}>
5243
+ ${this.copiedKey === s ? this.msg.copied : this.msg.copy}
5244
+ </button>
5245
+ </div>
5246
+ <div class="jtree">${r(e, 0)}</div>
5247
+ </div>`;
5248
+ }
4510
5249
  renderChart(e) {
4511
- const t = e.series.length > 1 ? r`<span class="legend">
5250
+ const t = e.series.length > 1 ? o`<span class="legend">
4512
5251
  ${e.series.map(
4513
- (o, l) => r`<span
5252
+ (r, l) => o`<span
4514
5253
  ><span
4515
5254
  class="swatch"
4516
- style="background:${_[l % _.length]}"
5255
+ style="background:${N[l % N.length]}"
4517
5256
  ></span
4518
- >${o.name}</span
5257
+ >${r.name}</span
4519
5258
  >`
4520
5259
  )}
4521
- </span>` : m, i = r`<div class="chart-head">
5260
+ </span>` : f, s = o`<div class="chart-head">
4522
5261
  <span class="chart-title">${e.title}</span>${t}
4523
5262
  </div>`;
4524
5263
  if (e.type === "line") {
4525
- const o = Math.max(0, ...e.series.flatMap((f) => f.values)), l = Math.pow(10, Math.floor(Math.log10(o || 1))), c = Math.ceil(o / l * 2) / 2 * l || 1, x = Math.max(e.labels.length, ...e.series.map((f) => f.values.length));
4526
- return r`<figure class="chart" part="chart" aria-label=${e.title}>
4527
- ${i}
5264
+ const r = Math.max(0, ...e.series.flatMap((b) => b.values)), l = Math.pow(10, Math.floor(Math.log10(r || 1))), c = Math.ceil(r / l * 2) / 2 * l || 1, m = Math.max(e.labels.length, ...e.series.map((b) => b.values.length));
5265
+ return o`<figure class="chart" part="chart" aria-label=${e.title}>
5266
+ ${s}
4528
5267
  <div class="line-chart">
4529
5268
  <div class="plot">
4530
5269
  ${[1, 0.5, 0].map(
4531
- (f) => r`<div class="tick ${f === 0 ? "base" : ""}" style="top:${(1 - f) * 100}%">
4532
- <span>${Fe(Math.round(c * f), e.unit)}</span>
5270
+ (b) => o`<div class="tick ${b === 0 ? "base" : ""}" style="top:${(1 - b) * 100}%">
5271
+ <span>${ut(Math.round(c * b), e.unit)}</span>
4533
5272
  </div>`
4534
5273
  )}
4535
5274
  <svg
@@ -4539,141 +5278,143 @@ ${x.map((b) => `[${b.n}] ${b.title}`).join(`
4539
5278
  aria-label=${e.title}
4540
5279
  >
4541
5280
  ${e.series.map(
4542
- (f, O) => $`<polyline pathLength="1" stroke=${_[O % _.length]}
4543
- points=${f.values.map(
4544
- (S, b) => `${(x > 1 ? b / (x - 1) * 600 : 300).toFixed(1)},${(170 - S / c * 170).toFixed(1)}`
5281
+ (b, C) => I`<polyline pathLength="1" stroke=${N[C % N.length]}
5282
+ points=${b.values.map(
5283
+ (S, w) => `${(m > 1 ? w / (m - 1) * 600 : 300).toFixed(1)},${(170 - S / c * 170).toFixed(1)}`
4545
5284
  ).join(
4546
5285
  " "
4547
- )}><title>${f.name}: ${f.values.map((S) => Fe(S, e.unit)).join(", ")}</title></polyline>`
5286
+ )}><title>${b.name}: ${b.values.map((S) => ut(S, e.unit)).join(", ")}</title></polyline>`
4548
5287
  )}
4549
5288
  </svg>
4550
5289
  </div>
4551
- <div class="x-labels">${e.labels.map((f) => r`<span>${f}</span>`)}</div>
5290
+ <div class="x-labels">${e.labels.map((b) => o`<span>${b}</span>`)}</div>
4552
5291
  </div>
4553
5292
  </figure>`;
4554
5293
  }
4555
- const s = e.labels.map(
4556
- (o, l) => e.series.reduce((c, x) => c + (x.values[l] || 0), 0)
4557
- ), a = Math.max(0, ...s) || 1;
4558
- return r`<figure class="chart" part="chart" aria-label=${e.title}>
4559
- ${i}
5294
+ const i = e.labels.map(
5295
+ (r, l) => e.series.reduce((c, m) => c + (m.values[l] || 0), 0)
5296
+ ), a = Math.max(0, ...i) || 1;
5297
+ return o`<figure class="chart" part="chart" aria-label=${e.title}>
5298
+ ${s}
4560
5299
  <div class="bars">
4561
5300
  ${e.labels.map(
4562
- (o, l) => r`<div class="bar-row" title="${o}: ${Fe(s[l], e.unit)}">
4563
- <span class="bar-label">${o}</span>
5301
+ (r, l) => o`<div class="bar-row" title="${r}: ${ut(i[l], e.unit)}">
5302
+ <span class="bar-label">${r}</span>
4564
5303
  <span class="bar-track"
4565
- ><span class="bar-fill" style="width:${Math.max(0, s[l]) / a * 100}%">
5304
+ ><span class="bar-fill" style="width:${Math.max(0, i[l]) / a * 100}%">
4566
5305
  ${e.series.map(
4567
- (c, x) => r`<span
4568
- style="flex:${Math.max(0, c.values[l] || 0)};background:${e.series.length > 1 ? _[x % _.length] : "var(--c-ink)"}"
5306
+ (c, m) => o`<span
5307
+ style="flex:${Math.max(0, c.values[l] || 0)};background:${e.series.length > 1 ? N[m % N.length] : "var(--c-ink)"}"
4569
5308
  ></span>`
4570
5309
  )}
4571
5310
  </span></span
4572
5311
  >
4573
- <span class="bar-value">${Fe(s[l], e.unit)}</span>
5312
+ <span class="bar-value">${ut(i[l], e.unit)}</span>
4574
5313
  </div>`
4575
5314
  )}
4576
5315
  </div>
4577
5316
  </figure>`;
4578
5317
  }
4579
5318
  renderPanel() {
4580
- if (!this.panel) return m;
4581
- const e = this.msgs.find((f) => f.key === this.panel.key), t = e == null ? void 0 : e.sources[this.panel.n - 1];
4582
- if (!e || !t) return m;
4583
- const i = this.msg, s = Ke(t, this.panel.n), a = Ze(e.content), o = e.sources.map((f, O) => Ke(f, O + 1)).filter((f) => f.n !== s.n && (!a.size || a.has(f.n))), l = `ref:${e.key}:${s.n}`, c = `"${s.text}"
4584
- — ${s.title} [${s.n}]${s.path ? `
4585
- ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
4586
- s.updated ? `Updated ${s.updated}` : "",
4587
- s.score !== null ? `Relevance ${s.score.toFixed(2)}` : ""
5319
+ if (!this.panel) return f;
5320
+ const e = this.msgs.find((b) => b.key === this.panel.key), t = e == null ? void 0 : e.sources[this.panel.n - 1];
5321
+ if (!e || !t) return f;
5322
+ const s = this.msg, i = gt(t, this.panel.n), a = Tt(e.content), r = e.sources.map((b, C) => gt(b, C + 1)).filter((b) => b.n !== i.n && (!a.size || a.has(b.n))), l = `ref:${e.key}:${i.n}`, c = `"${i.text}"
5323
+ — ${i.title} [${i.n}]${i.path ? `
5324
+ ${i.path}` : ""}${i.updated ? ` · Updated ${i.updated}` : ""}`, m = [
5325
+ i.updated ? `Updated ${i.updated}` : "",
5326
+ i.score !== null ? `Relevance ${i.score.toFixed(2)}` : ""
4588
5327
  ].filter(Boolean).join(" · ");
4589
- return r`<aside
5328
+ return o`<aside
4590
5329
  class="panel ${this.panelDocked ? "docked" : "overlay"}"
4591
5330
  part="panel"
4592
5331
  role="region"
4593
- aria-label=${z(i.sourceLabel, { n: s.n })}
5332
+ aria-label=${L(s.sourceLabel, { n: i.n })}
4594
5333
  >
4595
5334
  <div class="panel-head">
4596
5335
  <span class="label"
4597
- >${z(i.sourceLabel, { n: s.n })}${s.collection ? ` · ${s.collection}` : ""}</span
5336
+ >${L(s.sourceLabel, { n: i.n })}${i.collection ? ` · ${i.collection}` : ""}</span
4598
5337
  >
4599
5338
  <button type="button" class="text-btn underline" @click=${() => this.panel = null}>
4600
- ${i.close}
5339
+ ${s.close}
4601
5340
  </button>
4602
5341
  </div>
4603
5342
  <div class="panel-body">
4604
5343
  <div class="panel-meta">
4605
- <h3>${s.title}</h3>
4606
- ${s.path ? r`<span class="path">${s.path}</span>` : m}
4607
- ${x ? r`<span class="meta">${x}</span>` : m}
5344
+ <h3>${i.title}</h3>
5345
+ ${i.path ? o`<span class="path">${i.path}</span>` : f}
5346
+ ${m ? o`<span class="meta">${m}</span>` : f}
4608
5347
  </div>
4609
5348
  <div class="passage-box">
4610
- <span class="text">${s.text}</span>
5349
+ <span class="text">${i.text}</span>
4611
5350
  <div class="passage-foot">
4612
- <span class="label">${i.citedPassage}</span>
5351
+ <span class="label">${s.citedPassage}</span>
4613
5352
  <button
4614
5353
  type="button"
4615
5354
  class="copy-ref"
4616
- title=${i.copyReference}
4617
- aria-label=${i.copyReference}
5355
+ title=${s.copyReference}
5356
+ aria-label=${s.copyReference}
4618
5357
  @click=${() => this.copy(l, c)}
4619
5358
  >
4620
- ${y.copy()}<span>${this.copiedKey === l ? i.copied : i.copy}</span>
5359
+ ${k.copy()}<span>${this.copiedKey === l ? s.copied : s.copy}</span>
4621
5360
  </button>
4622
5361
  </div>
4623
5362
  </div>
4624
5363
  </div>
4625
- ${o.length ? r`<div class="panel-foot">
4626
- <span class="label">${i.alsoCited}</span>
5364
+ ${r.length ? o`<div class="panel-foot">
5365
+ <span class="label">${s.alsoCited}</span>
4627
5366
  <div class="chips">
4628
- ${o.map(
4629
- (f) => r`<button
5367
+ ${r.map(
5368
+ (b) => o`<button
4630
5369
  type="button"
4631
5370
  class="chip"
4632
- @click=${() => this.panel = { key: e.key, n: f.n }}
5371
+ @click=${() => this.panel = { key: e.key, n: b.n }}
4633
5372
  >
4634
- ${f.n} · ${f.title}
5373
+ ${b.n} · ${b.title}
4635
5374
  </button>`
4636
5375
  )}
4637
5376
  </div>
4638
- </div>` : m}
5377
+ </div>` : f}
4639
5378
  </aside>`;
4640
5379
  }
4641
5380
  renderComposer() {
4642
- const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : this.mode === "rich" ? e.placeholderRich : z(e.placeholderChat, { name: this.assistantName }), i = !this.draft.trim();
4643
- return r`<div class="composer-wrap">
5381
+ const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : L(e.placeholderChat, { name: this.assistantName }), s = !this.draft.trim(), i = this.footnote === "" ? f : o`<span class="footnote" part="footnote"
5382
+ >${this.footnote ?? L(e.footnote, { name: this.assistantName })}</span
5383
+ >`;
5384
+ return this.showComposer ? o`<div class="composer-wrap">
4644
5385
  <div class="composer-col">
4645
5386
  <input
4646
5387
  type="file"
4647
5388
  multiple
4648
5389
  hidden
4649
5390
  accept=".md,.markdown,.txt,.csv,.tsv,.json,.html,.htm,.yaml,.yml,.xml,.log,text/*"
4650
- @change=${(s) => {
4651
- const a = s.target;
4652
- this.addFiles(a.files).then(() => a.value = "");
5391
+ @change=${(a) => {
5392
+ const r = a.target;
5393
+ this.addFiles(r.files).then(() => r.value = "");
4653
5394
  }}
4654
5395
  />
4655
5396
  <div class="composer-box">
4656
- ${this.busy ? r`<div class="composer-glow"></div>` : m}
5397
+ ${this.busy ? o`<div class="composer-glow"></div>` : f}
4657
5398
  <div class="composer ${this.busy ? "busy" : ""}" part="composer">
4658
- ${this.files.length ? r`<div class="pending-files">
5399
+ ${this.files.length ? o`<div class="pending-files">
4659
5400
  ${this.files.map(
4660
- (s) => r`<div class="pending-file">
4661
- <span class="ext">${ct(s.name)}</span>
5401
+ (a) => o`<div class="pending-file">
5402
+ <span class="ext">${Rt(a.name)}</span>
4662
5403
  <span class="meta"
4663
- ><span class="name">${s.name}</span
4664
- ><span class="size">${Ve(s.size)}</span></span
5404
+ ><span class="name">${a.name}</span
5405
+ ><span class="size">${vt(a.size)}</span></span
4665
5406
  >
4666
5407
  <button
4667
5408
  type="button"
4668
5409
  aria-label=${e.removeFile}
4669
5410
  title=${e.removeFile}
4670
- @click=${() => this.files = this.files.filter((a) => a !== s)}
5411
+ @click=${() => this.files = this.files.filter((r) => r !== a)}
4671
5412
  >
4672
5413
  ×
4673
5414
  </button>
4674
5415
  </div>`
4675
5416
  )}
4676
- </div>` : m}
5417
+ </div>` : f}
4677
5418
  <textarea
4678
5419
  class="input"
4679
5420
  rows="1"
@@ -4685,242 +5426,321 @@ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
4685
5426
  ></textarea>
4686
5427
  <div class="composer-row">
4687
5428
  <div>
4688
- ${this.allowUpload ? r`<button
5429
+ ${this.allowUpload ? o`<button
4689
5430
  type="button"
4690
5431
  class="attach"
4691
5432
  title=${e.attach}
4692
5433
  aria-label=${e.attach}
4693
5434
  @click=${() => {
4694
- var s;
4695
- return (s = this.renderRoot.querySelector("input[type=file]")) == null ? void 0 : s.click();
5435
+ var a;
5436
+ return (a = this.renderRoot.querySelector("input[type=file]")) == null ? void 0 : a.click();
4696
5437
  }}
4697
5438
  >
4698
- ${y.clip()}
4699
- </button>` : m}
5439
+ ${k.clip()}
5440
+ </button>` : f}
4700
5441
  </div>
4701
- ${this.busy ? r`<button
5442
+ ${this.busy ? o`<button
4702
5443
  type="button"
4703
5444
  class="send stop"
4704
5445
  title=${e.stop}
4705
5446
  aria-label=${e.stop}
4706
5447
  @click=${() => this.stop()}
4707
5448
  >
4708
- ${y.stop()}
4709
- </button>` : r`<button
5449
+ ${k.stop()}
5450
+ </button>` : o`<button
4710
5451
  type="button"
4711
5452
  class="send"
4712
5453
  title=${e.send}
4713
5454
  aria-label=${e.send}
4714
- ?disabled=${i}
5455
+ ?disabled=${s}
4715
5456
  @click=${() => this.send()}
4716
5457
  >
4717
- ${y.up()}
5458
+ ${k.up()}
4718
5459
  </button>`}
4719
5460
  </div>
4720
5461
  </div>
4721
- ${this.busy ? r`<div class="composer-ring"><div class="ring"></div></div>` : m}
5462
+ ${this.busy ? o`<div class="composer-ring"><div class="ring"></div></div>` : f}
4722
5463
  </div>
4723
- <span class="footnote">${z(e.footnote, { name: this.assistantName })}</span>
5464
+ ${i}
4724
5465
  </div>
4725
- </div>`;
5466
+ </div>` : o`<div class="composer-wrap reader">
5467
+ <div class="composer-col">${i}</div>
5468
+ </div>`;
4726
5469
  }
4727
- }, j = new WeakMap(), A = new WeakMap(), E = new WeakMap(), N = new WeakMap(), B = new WeakMap(), D = new WeakMap(), R = new WeakMap(), U = new WeakMap(), F = new WeakMap(), K = new WeakMap(), P = new WeakMap(), H = new WeakMap(), J = new WeakMap(), W = new WeakMap(), q = new WeakMap(), G = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), ie = new WeakMap(), se = new WeakMap(), ae = new WeakMap(), re = new WeakMap(), ne = new WeakMap(), oe = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), he = new WeakMap(), ue = new WeakMap(), ge = new WeakMap(), me = new WeakMap(), be = new WeakMap(), fe = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(), ye = new WeakMap(), ke = new WeakMap(), we = new WeakMap(), $e = new WeakMap(), Te = new WeakMap(), Ce = new WeakMap(), Se = new WeakMap(), ze = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), _e = new WeakMap(), Ie = new WeakMap(), Le = new WeakMap(), je = new WeakMap(), Ae = new WeakMap(), Ee = new WeakMap(), Ne = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), Re = new WeakMap(), dt);
4728
- Nt(d, "styles", [kt, wt]);
5470
+ }, A = new WeakMap(), R = new WeakMap(), E = new WeakMap(), B = new WeakMap(), D = new WeakMap(), F = new WeakMap(), U = new WeakMap(), P = new WeakMap(), K = new WeakMap(), W = new WeakMap(), J = new WeakMap(), H = new WeakMap(), G = new WeakMap(), q = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), re = new WeakMap(), oe = new WeakMap(), ne = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), he = new WeakMap(), ue = new WeakMap(), ge = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(), we = new WeakMap(), ye = new WeakMap(), ke = new WeakMap(), $e = new WeakMap(), Ce = new WeakMap(), Te = new WeakMap(), Se = new WeakMap(), Oe = new WeakMap(), Ie = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), _e = new WeakMap(), Le = new WeakMap(), je = new WeakMap(), Ne = new WeakMap(), Ae = new WeakMap(), Re = new WeakMap(), Ee = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), Fe = new WeakMap(), Ue = new WeakMap(), Pe = new WeakMap(), Ke = new WeakMap(), We = new WeakMap(), Je = new WeakMap(), He = new WeakMap(), Ge = new WeakMap(), qe = new WeakMap(), Ve = new WeakMap(), Xe = new WeakMap(), Ye = new WeakMap(), Qe = new WeakMap(), Ze = new WeakMap(), et = new WeakMap(), tt = new WeakMap(), st = new WeakMap(), it = new WeakMap(), at = new WeakMap(), rt = new WeakMap(), ot = new WeakMap(), nt = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), pt = new WeakMap(), ht = new WeakMap(), Et);
5471
+ ws(d, "styles", [qt, Vt, Xt]);
4729
5472
  g([
4730
- w({ attribute: !1 })
5473
+ v({ attribute: !1 })
4731
5474
  ], d.prototype, "client", 1);
4732
5475
  g([
4733
- w({ attribute: !1 })
5476
+ v({ attribute: !1 })
4734
5477
  ], d.prototype, "messages", 1);
4735
5478
  g([
4736
- w({ reflect: !0 })
5479
+ v({ reflect: !0 })
4737
5480
  ], d.prototype, "theme", 1);
4738
5481
  g([
4739
- w({ reflect: !0 })
5482
+ v({ reflect: !0 })
5483
+ ], d.prototype, "radius", 1);
5484
+ g([
5485
+ v({ reflect: !0 })
4740
5486
  ], d.prototype, "mode", 1);
4741
5487
  g([
4742
- w({ attribute: "render-as" })
4743
- ], d.prototype, "renderAs", 1);
5488
+ v({ reflect: !0 })
5489
+ ], d.prototype, "format", 1);
5490
+ g([
5491
+ v({ attribute: !1 })
5492
+ ], d.prototype, "renderers", 1);
4744
5493
  g([
4745
- w({ reflect: !0 })
5494
+ v({ attribute: !1 })
5495
+ ], d.prototype, "beforeSend", 1);
5496
+ g([
5497
+ v({ attribute: !1 })
5498
+ ], d.prototype, "afterParse", 1);
5499
+ g([
5500
+ v({ reflect: !0 })
4746
5501
  ], d.prototype, "glow", 1);
4747
5502
  g([
4748
- w({ converter: I })
5503
+ v({ converter: O })
4749
5504
  ], d.prototype, "followups", 1);
4750
5505
  g([
4751
- w({ converter: I, attribute: "auto-title" })
5506
+ v({ converter: O, attribute: "show-sources" })
5507
+ ], d.prototype, "showSources", 1);
5508
+ g([
5509
+ v({ converter: O, attribute: "show-new-chat" })
5510
+ ], d.prototype, "showNewChat", 1);
5511
+ g([
5512
+ v({ converter: O, attribute: "show-bookmarked" })
5513
+ ], d.prototype, "showBookmarked", 1);
5514
+ g([
5515
+ v({ converter: O, attribute: "show-followups" })
5516
+ ], d.prototype, "showFollowups", 1);
5517
+ g([
5518
+ v({ converter: O, attribute: "allow-search" })
5519
+ ], d.prototype, "allowSearch", 1);
5520
+ g([
5521
+ v({ converter: O, attribute: "auto-title" })
4752
5522
  ], d.prototype, "autoTitle", 1);
4753
5523
  g([
4754
- w()
5524
+ v()
4755
5525
  ], d.prototype, "model", 1);
4756
5526
  g([
4757
- w({ converter: We })
5527
+ v({ converter: ft })
4758
5528
  ], d.prototype, "params", 1);
4759
5529
  g([
4760
- w({ attribute: "system-message" })
5530
+ v({ attribute: "system-message" })
4761
5531
  ], d.prototype, "systemMessage", 1);
4762
5532
  g([
4763
- w({ converter: We })
5533
+ v({ converter: ft })
4764
5534
  ], d.prototype, "retrieval", 1);
4765
5535
  g([
4766
- w({ converter: We })
5536
+ v({ converter: ft })
4767
5537
  ], d.prototype, "metadata", 1);
4768
5538
  g([
4769
- w({ reflect: !0 })
5539
+ v({ reflect: !0 })
4770
5540
  ], d.prototype, "embed", 1);
4771
5541
  g([
4772
- w({ reflect: !0 })
5542
+ v({ reflect: !0 })
4773
5543
  ], d.prototype, "position", 1);
4774
5544
  g([
4775
- w({ converter: Bt })
5545
+ v({ converter: ys })
4776
5546
  ], d.prototype, "sidebar", 1);
4777
5547
  g([
4778
- w({ converter: I, attribute: "show-title" })
5548
+ v({ converter: O, attribute: "show-title" })
4779
5549
  ], d.prototype, "showTitle", 1);
4780
5550
  g([
4781
- w({ attribute: "chat-id" })
5551
+ v({ attribute: "chat-id" })
4782
5552
  ], d.prototype, "chatIdAttr", 1);
4783
5553
  g([
4784
- w({ attribute: "assistant-name" })
5554
+ v({ attribute: "assistant-name" })
4785
5555
  ], d.prototype, "assistantName", 1);
4786
5556
  g([
4787
- w({ attribute: "logo-url" })
5557
+ v({ attribute: "logo-url" })
4788
5558
  ], d.prototype, "logoUrl", 1);
4789
5559
  g([
4790
- w()
5560
+ v()
4791
5561
  ], d.prototype, "heading", 1);
4792
5562
  g([
4793
- w()
5563
+ v()
4794
5564
  ], d.prototype, "description", 1);
4795
5565
  g([
4796
- w()
5566
+ v()
5567
+ ], d.prototype, "eyebrow", 1);
5568
+ g([
5569
+ v()
4797
5570
  ], d.prototype, "prompts", 1);
4798
5571
  g([
4799
- w({ attribute: "bubble-text" })
5572
+ v({ attribute: "bubble-text" })
4800
5573
  ], d.prototype, "bubbleText", 1);
4801
5574
  g([
4802
- w({ type: Boolean, attribute: "greeting-bubble" })
5575
+ v({ type: Boolean, attribute: "greeting-bubble" })
4803
5576
  ], d.prototype, "greetingBubble", 1);
4804
5577
  g([
4805
- w({ type: Boolean, attribute: "unread-badge" })
5578
+ v({ type: Boolean, attribute: "unread-badge" })
4806
5579
  ], d.prototype, "unreadBadge", 1);
4807
5580
  g([
4808
- w({ converter: I, attribute: "allow-upload" })
5581
+ v({ converter: O, attribute: "allow-upload" })
4809
5582
  ], d.prototype, "allowUpload", 1);
4810
5583
  g([
4811
- w({ converter: I, attribute: "allow-export" })
5584
+ v({ converter: O, attribute: "allow-export" })
4812
5585
  ], d.prototype, "allowExport", 1);
4813
5586
  g([
4814
- w({ converter: I })
4815
- ], d.prototype, "branding", 1);
5587
+ v({ converter: O, attribute: "allow-copy" })
5588
+ ], d.prototype, "allowCopy", 1);
5589
+ g([
5590
+ v({ converter: O, attribute: "allow-regenerate" })
5591
+ ], d.prototype, "allowRegenerate", 1);
5592
+ g([
5593
+ v({ converter: O, attribute: "allow-bookmark" })
5594
+ ], d.prototype, "allowBookmark", 1);
5595
+ g([
5596
+ v({ converter: O, attribute: "allow-delete" })
5597
+ ], d.prototype, "allowDelete", 1);
5598
+ g([
5599
+ v({ converter: O, attribute: "allow-rename" })
5600
+ ], d.prototype, "allowRename", 1);
5601
+ g([
5602
+ v({ converter: O, attribute: "allow-feedback" })
5603
+ ], d.prototype, "allowFeedback", 1);
5604
+ g([
5605
+ v({ converter: O, attribute: "show-composer" })
5606
+ ], d.prototype, "showComposer", 1);
5607
+ g([
5608
+ v({ converter: O, attribute: "show-time" })
5609
+ ], d.prototype, "showTime", 1);
4816
5610
  g([
4817
5611
  v()
5612
+ ], d.prototype, "footnote", 1);
5613
+ g([
5614
+ v({ type: Boolean, attribute: "allow-raw" })
5615
+ ], d.prototype, "allowRaw", 1);
5616
+ g([
5617
+ v({ converter: O })
5618
+ ], d.prototype, "branding", 1);
5619
+ g([
5620
+ v({ attribute: "branding-text" })
5621
+ ], d.prototype, "brandingText", 1);
5622
+ g([
5623
+ v({ attribute: "branding-url" })
5624
+ ], d.prototype, "brandingUrl", 1);
5625
+ g([
5626
+ y()
4818
5627
  ], d.prototype, "chatList", 1);
4819
5628
  g([
4820
- v()
5629
+ y()
4821
5630
  ], d.prototype, "listState", 1);
4822
5631
  g([
4823
- v()
5632
+ y()
4824
5633
  ], d.prototype, "activeId", 1);
4825
5634
  g([
4826
- v()
5635
+ y()
4827
5636
  ], d.prototype, "chatTitle", 1);
4828
5637
  g([
4829
- v()
5638
+ y()
4830
5639
  ], d.prototype, "bookmarked", 1);
4831
5640
  g([
4832
- v()
5641
+ y()
4833
5642
  ], d.prototype, "msgs", 1);
4834
5643
  g([
4835
- v()
5644
+ y()
4836
5645
  ], d.prototype, "loadingThread", 1);
4837
5646
  g([
4838
- v()
5647
+ y()
4839
5648
  ], d.prototype, "threadError", 1);
4840
5649
  g([
4841
- v()
5650
+ y()
4842
5651
  ], d.prototype, "busy", 1);
4843
5652
  g([
4844
- v()
5653
+ y()
4845
5654
  ], d.prototype, "draft", 1);
4846
5655
  g([
4847
- v()
5656
+ y()
4848
5657
  ], d.prototype, "files", 1);
4849
5658
  g([
4850
- v()
5659
+ y()
4851
5660
  ], d.prototype, "search", 1);
4852
5661
  g([
4853
- v()
5662
+ y()
4854
5663
  ], d.prototype, "sidebarOpen", 1);
4855
5664
  g([
4856
- v()
5665
+ y()
4857
5666
  ], d.prototype, "width", 1);
4858
5667
  g([
4859
- v()
5668
+ y()
4860
5669
  ], d.prototype, "panel", 1);
4861
5670
  g([
4862
- v()
5671
+ y()
4863
5672
  ], d.prototype, "menuOpen", 1);
4864
5673
  g([
4865
- v()
5674
+ y()
4866
5675
  ], d.prototype, "editingKey", 1);
4867
5676
  g([
4868
- v()
5677
+ y()
4869
5678
  ], d.prototype, "editDraft", 1);
4870
5679
  g([
4871
- v()
5680
+ y()
4872
5681
  ], d.prototype, "editingTitle", 1);
4873
5682
  g([
4874
- v()
5683
+ y()
4875
5684
  ], d.prototype, "renamingId", 1);
4876
5685
  g([
4877
- v()
5686
+ y()
4878
5687
  ], d.prototype, "toast", 1);
4879
5688
  g([
4880
- v()
5689
+ y()
4881
5690
  ], d.prototype, "copiedKey", 1);
4882
5691
  g([
4883
- v()
5692
+ y()
4884
5693
  ], d.prototype, "retrievalOpen", 1);
4885
5694
  g([
4886
- v()
5695
+ y()
5696
+ ], d.prototype, "rawKeys", 1);
5697
+ g([
5698
+ y()
5699
+ ], d.prototype, "hasSidebarContent", 1);
5700
+ g([
5701
+ y()
5702
+ ], d.prototype, "sorts", 1);
5703
+ g([
5704
+ y()
4887
5705
  ], d.prototype, "arrivedKey", 1);
4888
5706
  g([
4889
- v()
5707
+ y()
4890
5708
  ], d.prototype, "dragging", 1);
4891
5709
  g([
4892
- v()
5710
+ y()
4893
5711
  ], d.prototype, "showJump", 1);
4894
5712
  g([
4895
- v()
5713
+ y()
4896
5714
  ], d.prototype, "offline", 1);
4897
5715
  g([
4898
- v()
5716
+ y()
4899
5717
  ], d.prototype, "isOpen", 1);
4900
5718
  g([
4901
- v()
5719
+ y()
4902
5720
  ], d.prototype, "expanded", 1);
4903
5721
  g([
4904
- v()
5722
+ y()
4905
5723
  ], d.prototype, "bubble", 1);
4906
5724
  g([
4907
- v()
5725
+ y()
4908
5726
  ], d.prototype, "seen", 1);
4909
5727
  g([
4910
- v()
5728
+ y()
4911
5729
  ], d.prototype, "mobile", 1);
4912
5730
  d = g([
4913
- xt("singlebase-chat")
5731
+ Wt("singlebase-chat")
4914
5732
  ], d);
4915
5733
  export {
4916
5734
  d as S,
4917
- _t as a,
4918
- Ke as b,
4919
- Ze as c,
4920
- $t as d,
4921
- zt as e,
4922
- Mt as p,
4923
- Tt as r,
4924
- tt as s
5735
+ ps as a,
5736
+ gt as b,
5737
+ Tt as c,
5738
+ Yt as d,
5739
+ is as e,
5740
+ Ot as f,
5741
+ bs as g,
5742
+ ns as p,
5743
+ Qt as r,
5744
+ ls as s
4925
5745
  };
4926
- //# sourceMappingURL=chat-bXaRWel7.js.map
5746
+ //# sourceMappingURL=chat-CEh6RygY.js.map