@singlebase/elements 0.5.0 → 0.7.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 (52) hide show
  1. package/dist/{authui-display-BCZBP7HR.js → authui-display-BM_F3-5e.js} +426 -436
  2. package/dist/authui-display-BM_F3-5e.js.map +1 -0
  3. package/dist/{authui-display-CLGFSqRi.cjs → authui-display-CMVHTNFz.cjs} +45 -65
  4. package/dist/authui-display-CMVHTNFz.cjs.map +1 -0
  5. package/dist/authui.cjs +1 -1
  6. package/dist/authui.js +2 -2
  7. package/dist/{chat-bXaRWel7.js → chat-BH_3e1jT.js} +2081 -1121
  8. package/dist/chat-BH_3e1jT.js.map +1 -0
  9. package/dist/chat-ezUmd9II.cjs +3281 -0
  10. package/dist/chat-ezUmd9II.cjs.map +1 -0
  11. package/dist/chat-messages.d.ts +19 -6
  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 +1 -1
  19. package/dist/elements/chat.d.ts +192 -11
  20. package/dist/elements/uploader.d.ts +8 -0
  21. package/dist/files-4T62wkwj.cjs +77 -0
  22. package/dist/files-4T62wkwj.cjs.map +1 -0
  23. package/dist/{files-BOwtpYyQ.js → files-DS-H-3yN.js} +93 -47
  24. package/dist/files-DS-H-3yN.js.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +24 -22
  27. package/dist/messages.d.ts +0 -2
  28. package/dist/singlebase-elements.min.js +3838 -2844
  29. package/dist/singlebase-elements.min.js.map +1 -1
  30. package/dist/styles/branding.d.ts +5 -0
  31. package/dist/styles/tokens.d.ts +2 -0
  32. package/dist/upload-messages.d.ts +0 -1
  33. package/dist/{uploader-DGV2y9uT.cjs → uploader-COP8PkJ6.cjs} +53 -76
  34. package/dist/uploader-COP8PkJ6.cjs.map +1 -0
  35. package/dist/{uploader-abQoem5q.js → uploader-tdMU9Gxv.js} +249 -253
  36. package/dist/uploader-tdMU9Gxv.js.map +1 -0
  37. package/dist/uploader.cjs +1 -1
  38. package/dist/uploader.js +2 -2
  39. package/dist/utils/branding.d.ts +8 -0
  40. package/dist/utils/markdown.d.ts +69 -12
  41. package/dist/utils/svg.d.ts +10 -0
  42. package/package.json +3 -3
  43. package/dist/authui-display-BCZBP7HR.js.map +0 -1
  44. package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
  45. package/dist/chat-DRenTJlI.cjs +0 -3001
  46. package/dist/chat-DRenTJlI.cjs.map +0 -1
  47. package/dist/chat-bXaRWel7.js.map +0 -1
  48. package/dist/files-BOwtpYyQ.js.map +0 -1
  49. package/dist/files-DW8A4Jl-.cjs +0 -38
  50. package/dist/files-DW8A4Jl-.cjs.map +0 -1
  51. package/dist/uploader-DGV2y9uT.cjs.map +0 -1
  52. package/dist/uploader-abQoem5q.js.map +0 -1
@@ -0,0 +1,3281 @@
1
+ "use strict";var Jt=Object.defineProperty;var xt=l=>{throw TypeError(l)};var qt=(l,o,e)=>o in l?Jt(l,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[o]=e;var I=(l,o,e)=>qt(l,typeof o!="symbol"?o+"":o,e),yt=(l,o,e)=>o.has(l)||xt("Cannot "+e);var d=(l,o,e)=>(yt(l,o,"read from private field"),e?e.call(l):o.get(l)),p=(l,o,e)=>o.has(l)?xt("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(l):o.set(l,e),u=(l,o,e,t)=>(yt(l,o,"write to private field"),t?t.call(l,e):o.set(l,e),e);const i=require("lit"),g=require("lit/decorators.js"),Gt=require("lit/directives/repeat.js"),Vt=require("@singlebase/core"),T=require("./files-4T62wkwj.cjs");if(typeof CSS<"u"&&"registerProperty"in CSS)try{CSS.registerProperty({name:"--sb-ai-angle",syntax:"<angle>",inherits:!1,initialValue:"0deg"})}catch{}const Xt=i.css`
2
+ :host {
3
+ --c-ink: var(--sb-ink, #16181a);
4
+ --c-ink2: var(--sb-ink-2, #41464b);
5
+ --c-muted: var(--sb-muted-ink, #61666c);
6
+ --c-faint: #8a8f95;
7
+ --c-bg: var(--sb-surface, #ffffff);
8
+ --c-bg2: var(--sb-surface-alt, #fafafa);
9
+ --c-hover: var(--sb-hover, #f2f3f4);
10
+ --c-line: var(--sb-border, #e4e6e9);
11
+ --c-line2: var(--sb-divider, #ecedee);
12
+ --c-strong: var(--sb-border-strong, #cdd1d6);
13
+ --c-brand: var(--sb-accent, #16181a);
14
+ --c-on-brand: var(--sb-on-accent, #ffffff);
15
+ --c-danger: var(--sb-danger, #b4231a);
16
+ --c-ok: var(--sb-ok, #0f6b4a);
17
+ --c-mono: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
18
+ --c-r: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
19
+ --c-r2: calc(var(--c-r) * 1.5);
20
+ --c-r3: calc(var(--c-r) * 2);
21
+ --c-r4: calc(var(--c-r) * 3);
22
+ --c-glow: 0.6;
23
+ --c-conic: conic-gradient(
24
+ from var(--sb-ai-angle, 0deg),
25
+ oklch(0.72 0.15 295),
26
+ oklch(0.74 0.13 245),
27
+ oklch(0.8 0.11 190),
28
+ oklch(0.84 0.12 85),
29
+ oklch(0.78 0.12 350),
30
+ oklch(0.72 0.15 295)
31
+ );
32
+ --c-z: var(--sb-chat-z, 1000);
33
+ display: block;
34
+ height: 100%;
35
+ min-height: 0;
36
+ color-scheme: light;
37
+ }
38
+
39
+ :host([theme="dark"]) {
40
+ --sb-hover: #24272b;
41
+ --sb-ink-2: #c9ccd0;
42
+ --sb-divider: #26292d;
43
+ --c-faint: #7c8187;
44
+ color-scheme: dark;
45
+ }
46
+
47
+ :host([glow="vivid"]) {
48
+ --c-glow: 1;
49
+ }
50
+
51
+ :host([embed="inline"]) {
52
+ height: auto;
53
+ }
54
+
55
+ :host([embed="launcher"]) {
56
+ height: 0;
57
+ }
58
+
59
+ * {
60
+ box-sizing: border-box;
61
+ }
62
+
63
+ button {
64
+ font: inherit;
65
+ color: inherit;
66
+ }
67
+
68
+ button:focus-visible,
69
+ input:focus-visible,
70
+ textarea:focus-visible,
71
+ [role="button"]:focus-visible {
72
+ outline: 2px solid var(--c-ink);
73
+ outline-offset: 1px;
74
+ }
75
+
76
+ .mono {
77
+ font-family: var(--c-mono);
78
+ }
79
+
80
+ .label {
81
+ font-family: var(--c-mono);
82
+ font-size: 11px;
83
+ letter-spacing: 0.07em;
84
+ text-transform: uppercase;
85
+ color: var(--c-muted);
86
+ }
87
+
88
+ /* ── frames ───────────────────────────────────────────── */
89
+
90
+ .frame {
91
+ position: relative;
92
+ display: flex;
93
+ height: 100%;
94
+ min-height: 0;
95
+ background: var(--c-bg);
96
+ color: var(--c-ink);
97
+ overflow: hidden;
98
+ }
99
+
100
+ .frame.boxed {
101
+ border: 1px solid var(--c-line);
102
+ border-radius: var(--c-r4);
103
+ }
104
+
105
+ .frame.inline {
106
+ width: 440px;
107
+ height: 660px;
108
+ min-width: 340px;
109
+ min-height: 480px;
110
+ max-width: 100%;
111
+ resize: both;
112
+ box-shadow: 0 1px 2px rgba(22, 24, 26, 0.06);
113
+ }
114
+
115
+ @media (max-width: 559px) {
116
+ .frame.inline {
117
+ width: 100%;
118
+ min-width: 0;
119
+ resize: none;
120
+ }
121
+ }
122
+
123
+ .frame.launcher {
124
+ position: fixed;
125
+ bottom: 96px;
126
+ right: 24px;
127
+ z-index: var(--c-z);
128
+ width: 420px;
129
+ height: min(680px, calc(100vh - 120px));
130
+ max-width: calc(100vw - 48px);
131
+ box-shadow: 0 24px 60px -24px rgba(22, 24, 26, 0.35);
132
+ transform-origin: bottom right;
133
+ animation: scaleIn 0.2s ease-out;
134
+ }
135
+
136
+ :host([position="left"]) .frame.launcher {
137
+ right: auto;
138
+ left: 24px;
139
+ transform-origin: bottom left;
140
+ }
141
+
142
+ .frame.expanded {
143
+ position: fixed;
144
+ inset: 24px;
145
+ width: auto;
146
+ height: auto;
147
+ max-width: none;
148
+ z-index: var(--c-z);
149
+ resize: none;
150
+ box-shadow: 0 24px 60px -24px rgba(22, 24, 26, 0.35);
151
+ animation: scaleIn 0.2s ease-out;
152
+ }
153
+
154
+ .frame.full {
155
+ position: fixed;
156
+ inset: 0;
157
+ width: auto;
158
+ height: auto;
159
+ max-width: none;
160
+ border-radius: 0;
161
+ border: none;
162
+ z-index: var(--c-z);
163
+ resize: none;
164
+ }
165
+
166
+ .root {
167
+ position: relative;
168
+ display: flex;
169
+ flex: 1;
170
+ min-width: 0;
171
+ min-height: 0;
172
+ font-family: var(--sb-font, "Geist", -apple-system, "Segoe UI", Helvetica, sans-serif);
173
+ background: var(--c-bg);
174
+ color: var(--c-ink);
175
+ }
176
+
177
+ /* ── launcher ─────────────────────────────────────────── */
178
+
179
+ .launcher-btn {
180
+ position: fixed;
181
+ bottom: 24px;
182
+ right: 24px;
183
+ z-index: calc(var(--c-z) + 1);
184
+ width: 56px;
185
+ height: 56px;
186
+ border-radius: 999px;
187
+ display: inline-flex;
188
+ align-items: center;
189
+ justify-content: center;
190
+ border: none;
191
+ cursor: pointer;
192
+ background: var(--c-brand);
193
+ color: var(--c-on-brand);
194
+ box-shadow: 0 12px 28px -10px rgba(22, 24, 26, 0.45);
195
+ }
196
+
197
+ :host([position="left"]) .launcher-btn,
198
+ :host([position="left"]) .bubble {
199
+ right: auto;
200
+ left: 24px;
201
+ }
202
+
203
+ .badge {
204
+ position: absolute;
205
+ top: 2px;
206
+ right: 2px;
207
+ width: 12px;
208
+ height: 12px;
209
+ border-radius: 999px;
210
+ background: var(--c-danger);
211
+ border: 2px solid var(--c-bg);
212
+ }
213
+
214
+ .bubble {
215
+ position: fixed;
216
+ bottom: 96px;
217
+ right: 24px;
218
+ z-index: var(--c-z);
219
+ width: 260px;
220
+ display: flex;
221
+ align-items: flex-start;
222
+ gap: 8px;
223
+ padding: 12px 10px 12px 14px;
224
+ background: var(--c-bg);
225
+ color: var(--c-ink);
226
+ border: 1px solid var(--c-line);
227
+ border-radius: calc(var(--c-r) * 2.5);
228
+ box-shadow: 0 12px 32px -12px rgba(22, 24, 26, 0.25);
229
+ font-family: var(--sb-font, "Geist", -apple-system, "Segoe UI", Helvetica, sans-serif);
230
+ animation: aiIn 0.25s ease-out;
231
+ }
232
+
233
+ .bubble-text {
234
+ flex: 1;
235
+ min-width: 0;
236
+ text-align: left;
237
+ font-size: 13.5px;
238
+ line-height: 1.45;
239
+ background: none;
240
+ border: none;
241
+ padding: 0;
242
+ cursor: pointer;
243
+ }
244
+
245
+ /* ── icon buttons ─────────────────────────────────────── */
246
+
247
+ .icon {
248
+ display: inline-flex;
249
+ align-items: center;
250
+ justify-content: center;
251
+ flex: 0 0 auto;
252
+ width: 28px;
253
+ height: 28px;
254
+ padding: 0;
255
+ border: none;
256
+ border-radius: var(--c-r);
257
+ background: transparent;
258
+ color: var(--c-muted);
259
+ cursor: pointer;
260
+ }
261
+
262
+ .icon:hover:not(:disabled),
263
+ .icon.on {
264
+ color: var(--c-ink);
265
+ }
266
+
267
+ .icon:hover:not(:disabled) {
268
+ background: var(--c-hover);
269
+ }
270
+
271
+ .icon.danger:hover:not(:disabled) {
272
+ color: var(--c-danger);
273
+ }
274
+
275
+ .icon:disabled {
276
+ opacity: 0.4;
277
+ cursor: default;
278
+ }
279
+
280
+ .icon.sm {
281
+ width: 24px;
282
+ height: 24px;
283
+ }
284
+
285
+ svg.i {
286
+ width: 16px;
287
+ height: 16px;
288
+ fill: none;
289
+ stroke: currentColor;
290
+ stroke-width: 1.5;
291
+ stroke-linecap: round;
292
+ stroke-linejoin: round;
293
+ }
294
+
295
+ svg.i.filled path {
296
+ fill: currentColor;
297
+ }
298
+
299
+ @media (pointer: coarse) {
300
+ .icon {
301
+ width: 44px;
302
+ height: 44px;
303
+ }
304
+ }
305
+
306
+ /* ── sidebar ──────────────────────────────────────────── */
307
+
308
+ .scrim {
309
+ position: absolute;
310
+ inset: 0;
311
+ z-index: 29;
312
+ background: rgba(22, 24, 26, 0.18);
313
+ }
314
+
315
+ .sidebar {
316
+ display: flex;
317
+ flex-direction: column;
318
+ min-height: 0;
319
+ min-width: 0;
320
+ background: var(--c-bg2);
321
+ border-right: 1px solid var(--c-line);
322
+ }
323
+
324
+ .sidebar.docked {
325
+ position: relative;
326
+ flex: 0 0 272px;
327
+ width: 272px;
328
+ }
329
+
330
+ .sidebar.overlay {
331
+ position: absolute;
332
+ left: 0;
333
+ top: 0;
334
+ bottom: 0;
335
+ z-index: 30;
336
+ width: min(280px, 86%);
337
+ box-shadow: 12px 0 32px -16px rgba(22, 24, 26, 0.25);
338
+ animation: slideIn 0.15s ease-out;
339
+ }
340
+
341
+ .side-head {
342
+ display: flex;
343
+ align-items: center;
344
+ justify-content: space-between;
345
+ gap: 8px;
346
+ padding: 14px 12px 10px 16px;
347
+ }
348
+
349
+ .side-tools {
350
+ display: flex;
351
+ flex-direction: column;
352
+ gap: 8px;
353
+ padding: 0 12px 8px;
354
+ }
355
+
356
+ .new-chat {
357
+ display: flex;
358
+ align-items: center;
359
+ gap: 8px;
360
+ width: 100%;
361
+ min-height: 34px;
362
+ font-size: 13px;
363
+ font-weight: 500;
364
+ color: var(--c-on-brand);
365
+ background: var(--c-brand);
366
+ border: 1px solid var(--c-brand);
367
+ border-radius: var(--c-r2);
368
+ padding: 8px 12px;
369
+ cursor: pointer;
370
+ }
371
+
372
+ .new-chat:hover {
373
+ filter: brightness(1.2);
374
+ }
375
+
376
+ .search {
377
+ width: 100%;
378
+ font: inherit;
379
+ font-size: 13px;
380
+ color: var(--c-ink);
381
+ background: var(--c-bg);
382
+ border: 1px solid var(--c-line);
383
+ border-radius: var(--c-r2);
384
+ padding: 8px 10px;
385
+ outline: none;
386
+ }
387
+
388
+ .search:focus {
389
+ border-color: var(--c-ink);
390
+ }
391
+
392
+ .threads {
393
+ flex: 1;
394
+ min-height: 0;
395
+ overflow-y: auto;
396
+ display: flex;
397
+ flex-direction: column;
398
+ gap: 1px;
399
+ padding: 4px 12px 12px;
400
+ }
401
+
402
+ .group {
403
+ font-family: var(--c-mono);
404
+ font-size: 11px;
405
+ letter-spacing: 0.07em;
406
+ text-transform: uppercase;
407
+ color: var(--c-muted);
408
+ padding: 10px 8px 6px;
409
+ }
410
+
411
+ .thread {
412
+ display: flex;
413
+ align-items: center;
414
+ gap: 4px;
415
+ min-height: 34px;
416
+ width: 100%;
417
+ font-size: 13px;
418
+ color: var(--c-ink);
419
+ border-radius: var(--c-r2);
420
+ padding: 3px 4px 3px 10px;
421
+ cursor: pointer;
422
+ }
423
+
424
+ .thread:hover {
425
+ background: var(--c-hover);
426
+ }
427
+
428
+ .thread.active {
429
+ background: var(--c-line2);
430
+ font-weight: 500;
431
+ }
432
+
433
+ .thread-title {
434
+ flex: 1;
435
+ min-width: 0;
436
+ overflow: hidden;
437
+ text-overflow: ellipsis;
438
+ white-space: nowrap;
439
+ }
440
+
441
+ .thread-actions {
442
+ display: none;
443
+ gap: 0;
444
+ }
445
+
446
+ .thread:hover .thread-actions,
447
+ .thread:focus-within .thread-actions {
448
+ display: flex;
449
+ }
450
+
451
+ .thread-rename {
452
+ flex: 1;
453
+ min-width: 0;
454
+ font: inherit;
455
+ color: var(--c-ink);
456
+ background: var(--c-bg);
457
+ border: 1px solid var(--c-ink);
458
+ border-radius: var(--c-r);
459
+ padding: 3px 6px;
460
+ outline: none;
461
+ }
462
+
463
+ .side-extra {
464
+ display: none;
465
+ }
466
+
467
+ .side-extra.filled {
468
+ display: block;
469
+ padding: 12px 16px;
470
+ border-top: 1px solid var(--c-line);
471
+ font-size: 12.5px;
472
+ }
473
+
474
+ .side-note {
475
+ font-size: 12.5px;
476
+ color: var(--c-muted);
477
+ padding: 6px 10px;
478
+ }
479
+
480
+ .skeleton {
481
+ height: 28px;
482
+ margin: 3px 0;
483
+ border-radius: var(--c-r2);
484
+ background: linear-gradient(90deg, var(--c-hover) 0%, var(--c-line2) 50%, var(--c-hover) 100%);
485
+ background-size: 200% 100%;
486
+ animation: aiShimmer 1.6s linear infinite;
487
+ }
488
+
489
+ /* ── main column ──────────────────────────────────────── */
490
+
491
+ .main {
492
+ container: chat / inline-size;
493
+ position: relative;
494
+ flex: 1;
495
+ min-width: 0;
496
+ min-height: 0;
497
+ display: flex;
498
+ flex-direction: column;
499
+ }
500
+
501
+ .header {
502
+ display: flex;
503
+ align-items: center;
504
+ justify-content: space-between;
505
+ gap: 12px;
506
+ min-height: 52px;
507
+ padding: 10px 8px 10px 12px;
508
+ border-bottom: 1px solid var(--c-line);
509
+ }
510
+
511
+ .header-left {
512
+ display: flex;
513
+ align-items: center;
514
+ gap: 10px;
515
+ min-width: 0;
516
+ }
517
+
518
+ .header-right {
519
+ flex: 0 0 auto;
520
+ display: flex;
521
+ align-items: center;
522
+ gap: 2px;
523
+ }
524
+
525
+ .title {
526
+ min-width: 0;
527
+ font-size: 14px;
528
+ font-weight: 600;
529
+ letter-spacing: -0.01em;
530
+ overflow: hidden;
531
+ text-overflow: ellipsis;
532
+ white-space: nowrap;
533
+ background: none;
534
+ border: none;
535
+ padding: 2px 4px;
536
+ border-radius: var(--c-r);
537
+ cursor: text;
538
+ animation: aiIn 0.25s ease-out;
539
+ }
540
+
541
+ .title:hover:not(:disabled) {
542
+ background: var(--c-hover);
543
+ }
544
+
545
+ .title:disabled {
546
+ cursor: default;
547
+ }
548
+
549
+ .title-input {
550
+ min-width: 0;
551
+ width: 320px;
552
+ max-width: 100%;
553
+ font: inherit;
554
+ font-size: 14px;
555
+ font-weight: 600;
556
+ color: var(--c-ink);
557
+ background: var(--c-bg);
558
+ border: 1px solid var(--c-ink);
559
+ border-radius: var(--c-r);
560
+ padding: 2px 6px;
561
+ outline: none;
562
+ }
563
+
564
+ .divider {
565
+ width: 1px;
566
+ height: 18px;
567
+ background: var(--c-line);
568
+ margin: 0 4px;
569
+ }
570
+
571
+ .menu-wrap {
572
+ position: relative;
573
+ }
574
+
575
+ .menu-scrim {
576
+ position: fixed;
577
+ inset: 0;
578
+ z-index: 40;
579
+ }
580
+
581
+ .menu {
582
+ position: absolute;
583
+ right: 0;
584
+ top: 34px;
585
+ z-index: 41;
586
+ width: 220px;
587
+ display: flex;
588
+ flex-direction: column;
589
+ padding: 4px;
590
+ background: var(--c-bg);
591
+ border: 1px solid var(--c-line);
592
+ border-radius: var(--c-r2);
593
+ box-shadow: 0 12px 32px -12px rgba(22, 24, 26, 0.22);
594
+ animation: aiIn 0.15s ease-out;
595
+ }
596
+
597
+ .menu .label {
598
+ font-size: 10.5px;
599
+ padding: 8px 10px 6px;
600
+ }
601
+
602
+ .menu-item {
603
+ display: flex;
604
+ align-items: baseline;
605
+ justify-content: space-between;
606
+ gap: 10px;
607
+ width: 100%;
608
+ text-align: left;
609
+ font-size: 13px;
610
+ background: none;
611
+ border: none;
612
+ border-radius: var(--c-r);
613
+ padding: 8px 10px;
614
+ cursor: pointer;
615
+ }
616
+
617
+ .menu-item:hover {
618
+ background: var(--c-hover);
619
+ }
620
+
621
+ .menu-item .ext {
622
+ font-family: var(--c-mono);
623
+ font-size: 11px;
624
+ color: var(--c-muted);
625
+ }
626
+
627
+ .scroller {
628
+ position: relative;
629
+ flex: 1;
630
+ min-height: 0;
631
+ overflow-y: auto;
632
+ }
633
+
634
+ .banner {
635
+ margin: 10px 16px 0;
636
+ padding: 8px 12px;
637
+ font-size: 12.5px;
638
+ color: var(--c-ink2);
639
+ background: var(--c-bg2);
640
+ border: 1px solid var(--c-line);
641
+ border-radius: var(--c-r2);
642
+ }
643
+
644
+ /* ── welcome ──────────────────────────────────────────── */
645
+
646
+ .welcome-slot {
647
+ min-height: 100%;
648
+ display: flex;
649
+ flex-direction: column;
650
+ justify-content: center;
651
+ }
652
+
653
+ ::slotted([slot="welcome"]) {
654
+ box-sizing: border-box;
655
+ width: 100%;
656
+ max-width: 640px;
657
+ margin: 0 auto;
658
+ padding: 28px 18px;
659
+ }
660
+
661
+ .welcome {
662
+ max-width: 640px;
663
+ min-height: 100%;
664
+ margin: 0 auto;
665
+ display: flex;
666
+ flex-direction: column;
667
+ justify-content: center;
668
+ gap: 20px;
669
+ padding: 28px 18px;
670
+ }
671
+
672
+ .welcome-head {
673
+ display: flex;
674
+ flex-direction: column;
675
+ gap: 8px;
676
+ }
677
+
678
+ .welcome-logo {
679
+ width: 32px;
680
+ height: 32px;
681
+ object-fit: contain;
682
+ border-radius: var(--c-r2);
683
+ }
684
+
685
+ .welcome h2 {
686
+ margin: 0;
687
+ font-size: 24px;
688
+ font-weight: 600;
689
+ letter-spacing: -0.01em;
690
+ }
691
+
692
+ .welcome p {
693
+ margin: 0;
694
+ font-size: 14px;
695
+ line-height: 1.55;
696
+ color: var(--c-muted);
697
+ text-wrap: pretty;
698
+ }
699
+
700
+ .prompts {
701
+ display: grid;
702
+ grid-template-columns: repeat(2, minmax(0, 1fr));
703
+ gap: 8px;
704
+ }
705
+
706
+ .prompt {
707
+ display: flex;
708
+ flex-direction: column;
709
+ gap: 4px;
710
+ text-align: left;
711
+ background: var(--c-bg);
712
+ border: 1px solid var(--c-line);
713
+ border-radius: var(--c-r2);
714
+ padding: 12px 14px;
715
+ cursor: pointer;
716
+ transition:
717
+ border-color 0.15s,
718
+ box-shadow 0.15s;
719
+ }
720
+
721
+ .prompt:hover {
722
+ border-color: var(--c-ink);
723
+ box-shadow: 0 6px 18px -10px rgba(22, 24, 26, 0.25);
724
+ }
725
+
726
+ .prompt .label {
727
+ font-size: 10.5px;
728
+ letter-spacing: 0.06em;
729
+ }
730
+
731
+ .prompt-text {
732
+ font-size: 13.5px;
733
+ font-weight: 500;
734
+ line-height: 1.4;
735
+ }
736
+
737
+ @container chat (max-width: 480px) {
738
+ .prompts {
739
+ grid-template-columns: minmax(0, 1fr);
740
+ }
741
+ }
742
+
743
+ /* ── messages ─────────────────────────────────────────── */
744
+
745
+ .thread-view {
746
+ max-width: 760px;
747
+ margin: 0 auto;
748
+ display: flex;
749
+ flex-direction: column;
750
+ gap: 30px;
751
+ padding: 20px 16px 28px;
752
+ }
753
+
754
+ .msg {
755
+ position: relative;
756
+ display: flex;
757
+ flex-direction: column;
758
+ border-radius: var(--c-r3);
759
+ }
760
+
761
+ .msg.user {
762
+ align-self: flex-end;
763
+ max-width: 80%;
764
+ align-items: flex-end;
765
+ gap: 6px;
766
+ margin-bottom: -22px;
767
+ animation: aiIn 0.25s ease-out;
768
+ }
769
+
770
+ .bubble-user {
771
+ padding: 10px 14px;
772
+ font-size: 14.5px;
773
+ line-height: 1.6;
774
+ white-space: pre-wrap;
775
+ overflow-wrap: anywhere;
776
+ background: var(--c-hover);
777
+ border-radius: calc(var(--c-r) * 2.5) calc(var(--c-r) * 2.5) 2px calc(var(--c-r) * 2.5);
778
+ }
779
+
780
+ .attachments {
781
+ display: flex;
782
+ flex-wrap: wrap;
783
+ justify-content: flex-end;
784
+ gap: 6px;
785
+ }
786
+
787
+ .doc-chip {
788
+ display: inline-flex;
789
+ align-items: center;
790
+ gap: 8px;
791
+ padding: 6px 10px;
792
+ font-size: 12.5px;
793
+ border-radius: var(--c-r2);
794
+ border: 1px solid var(--c-line);
795
+ background: var(--c-bg);
796
+ }
797
+
798
+ .doc-chip .ext {
799
+ font-family: var(--c-mono);
800
+ font-size: 10px;
801
+ letter-spacing: 0.04em;
802
+ color: var(--c-muted);
803
+ }
804
+
805
+ .doc-chip .name {
806
+ max-width: 180px;
807
+ overflow: hidden;
808
+ text-overflow: ellipsis;
809
+ white-space: nowrap;
810
+ }
811
+
812
+ .toolbar {
813
+ display: flex;
814
+ align-items: center;
815
+ gap: 2px;
816
+ opacity: 0;
817
+ transition: opacity 0.15s;
818
+ }
819
+
820
+ .msg:hover .toolbar,
821
+ .msg:focus-within .toolbar,
822
+ .toolbar.pinned {
823
+ opacity: 1;
824
+ }
825
+
826
+ @media (hover: none) {
827
+ .toolbar {
828
+ opacity: 1;
829
+ }
830
+ }
831
+
832
+ .msg.bot .toolbar {
833
+ margin-left: -6px;
834
+ }
835
+
836
+ .time {
837
+ font-family: var(--c-mono);
838
+ font-size: 11px;
839
+ color: var(--c-faint);
840
+ padding: 0 6px;
841
+ font-variant-numeric: tabular-nums;
842
+ }
843
+
844
+ .note {
845
+ font-size: 12px;
846
+ color: var(--c-muted);
847
+ }
848
+
849
+ .spacer {
850
+ flex: 1;
851
+ }
852
+
853
+ .saved {
854
+ display: inline-flex;
855
+ align-items: center;
856
+ gap: 4px;
857
+ font-family: var(--c-mono);
858
+ font-size: 10.5px;
859
+ letter-spacing: 0.05em;
860
+ text-transform: uppercase;
861
+ color: var(--c-ink);
862
+ }
863
+
864
+ .saved svg {
865
+ width: 12px;
866
+ height: 12px;
867
+ fill: currentColor;
868
+ stroke: currentColor;
869
+ stroke-width: 1.5;
870
+ }
871
+
872
+ .bot-body {
873
+ position: relative;
874
+ z-index: 1;
875
+ display: flex;
876
+ flex-direction: column;
877
+ gap: 12px;
878
+ }
879
+
880
+ .edit-box {
881
+ width: 440px;
882
+ max-width: 100%;
883
+ display: flex;
884
+ flex-direction: column;
885
+ gap: 8px;
886
+ padding: 8px;
887
+ border: 1px solid var(--c-ink);
888
+ border-radius: var(--c-r3);
889
+ background: var(--c-bg);
890
+ }
891
+
892
+ .edit-box textarea {
893
+ width: 100%;
894
+ resize: vertical;
895
+ font: inherit;
896
+ font-size: 14px;
897
+ line-height: 1.5;
898
+ color: var(--c-ink);
899
+ background: transparent;
900
+ border: none;
901
+ outline: none;
902
+ padding: 4px;
903
+ }
904
+
905
+ .row-end {
906
+ display: flex;
907
+ justify-content: flex-end;
908
+ gap: 8px;
909
+ }
910
+
911
+ .btn {
912
+ font-size: 12.5px;
913
+ font-weight: 500;
914
+ border-radius: var(--c-r);
915
+ padding: 6px 12px;
916
+ cursor: pointer;
917
+ background: transparent;
918
+ color: var(--c-muted);
919
+ border: 1px solid var(--c-line);
920
+ }
921
+
922
+ .btn:hover {
923
+ color: var(--c-ink);
924
+ background: var(--c-bg2);
925
+ }
926
+
927
+ .btn.primary {
928
+ background: var(--c-brand);
929
+ color: var(--c-on-brand);
930
+ border-color: var(--c-brand);
931
+ }
932
+
933
+ .btn.primary:hover {
934
+ filter: brightness(1.2);
935
+ }
936
+
937
+ .error-card {
938
+ display: flex;
939
+ align-items: center;
940
+ justify-content: space-between;
941
+ gap: 12px;
942
+ padding: 10px 12px;
943
+ font-size: 13px;
944
+ color: var(--c-danger);
945
+ border: 1px solid var(--sb-danger-border, #f3d6d3);
946
+ background: var(--sb-danger-bg, #fdf1f0);
947
+ border-radius: var(--c-r2);
948
+ }
949
+
950
+ .followups {
951
+ display: flex;
952
+ flex-direction: column;
953
+ align-items: flex-start;
954
+ gap: 6px;
955
+ }
956
+
957
+ .followup {
958
+ display: inline-flex;
959
+ align-items: baseline;
960
+ gap: 8px;
961
+ text-align: left;
962
+ font-size: 13px;
963
+ background: var(--c-bg);
964
+ border: 1px solid var(--c-line);
965
+ border-radius: var(--c-r2);
966
+ padding: 6px 12px;
967
+ cursor: pointer;
968
+ animation: aiIn 0.25s ease-out;
969
+ }
970
+
971
+ .followup:hover {
972
+ background: var(--c-hover);
973
+ }
974
+
975
+ .followup .arrow {
976
+ font-family: var(--c-mono);
977
+ color: var(--c-muted);
978
+ }
979
+
980
+ .jump {
981
+ position: absolute;
982
+ left: 50%;
983
+ bottom: 8px;
984
+ transform: translateX(-50%);
985
+ z-index: 5;
986
+ font-size: 12.5px;
987
+ font-weight: 500;
988
+ color: var(--c-on-brand);
989
+ background: var(--c-brand);
990
+ border: none;
991
+ border-radius: 999px;
992
+ padding: 6px 14px;
993
+ cursor: pointer;
994
+ box-shadow: 0 8px 20px -10px rgba(22, 24, 26, 0.4);
995
+ animation: aiIn 0.2s ease-out;
996
+ }
997
+
998
+ /* ── rendered answer ──────────────────────────────────── */
999
+
1000
+ .answer {
1001
+ display: flex;
1002
+ flex-direction: column;
1003
+ gap: 14px;
1004
+ font-size: 14.5px;
1005
+ line-height: 1.7;
1006
+ }
1007
+
1008
+ .answer p {
1009
+ margin: 0;
1010
+ text-wrap: pretty;
1011
+ overflow-wrap: anywhere;
1012
+ }
1013
+
1014
+ .answer .raw {
1015
+ white-space: pre-wrap;
1016
+ }
1017
+
1018
+ .answer h3 {
1019
+ margin: 6px 0 0;
1020
+ font-size: 15.5px;
1021
+ font-weight: 600;
1022
+ letter-spacing: -0.01em;
1023
+ line-height: 1.4;
1024
+ }
1025
+
1026
+ .answer ul,
1027
+ .answer ol {
1028
+ margin: 0;
1029
+ padding-left: 20px;
1030
+ display: flex;
1031
+ flex-direction: column;
1032
+ gap: 6px;
1033
+ }
1034
+
1035
+ .answer li {
1036
+ line-height: 1.65;
1037
+ padding-left: 2px;
1038
+ }
1039
+
1040
+ .answer strong {
1041
+ font-weight: 600;
1042
+ }
1043
+
1044
+ .answer a {
1045
+ color: var(--c-ink);
1046
+ text-underline-offset: 3px;
1047
+ }
1048
+
1049
+ .answer code.inline {
1050
+ font-family: var(--c-mono);
1051
+ font-size: 12.5px;
1052
+ background: var(--c-hover);
1053
+ border-radius: calc(var(--c-r) * 0.75);
1054
+ padding: 1px 5px;
1055
+ }
1056
+
1057
+ .answer h3.h1 {
1058
+ font-size: 18px;
1059
+ }
1060
+
1061
+ .answer h3.h2 {
1062
+ font-size: 16.5px;
1063
+ }
1064
+
1065
+ .answer h3.h4 {
1066
+ font-size: 14.5px;
1067
+ }
1068
+
1069
+ .answer hr {
1070
+ width: 100%;
1071
+ border: none;
1072
+ border-top: 1px solid var(--c-line);
1073
+ margin: 4px 0;
1074
+ }
1075
+
1076
+ .answer li.task {
1077
+ list-style: none;
1078
+ margin-left: -18px;
1079
+ }
1080
+
1081
+ .answer li.task input {
1082
+ margin: 0 6px 0 0;
1083
+ vertical-align: -1px;
1084
+ accent-color: var(--c-brand);
1085
+ }
1086
+
1087
+ .callout {
1088
+ display: flex;
1089
+ flex-direction: column;
1090
+ gap: 4px;
1091
+ font-size: 13.5px;
1092
+ line-height: 1.6;
1093
+ padding: 10px 14px;
1094
+ border: 1px solid var(--c-line);
1095
+ border-left: 3px solid var(--callout, var(--c-ink));
1096
+ border-radius: var(--c-r2);
1097
+ background: color-mix(in srgb, var(--callout, var(--c-ink)) 7%, var(--c-bg));
1098
+ }
1099
+
1100
+ .callout-title {
1101
+ font-weight: 600;
1102
+ color: var(--callout, var(--c-ink));
1103
+ }
1104
+
1105
+ .callout.note {
1106
+ --callout: oklch(0.55 0.15 255);
1107
+ }
1108
+
1109
+ .callout.tip {
1110
+ --callout: oklch(0.55 0.12 160);
1111
+ }
1112
+
1113
+ .callout.important {
1114
+ --callout: oklch(0.52 0.17 300);
1115
+ }
1116
+
1117
+ .callout.warning {
1118
+ --callout: oklch(0.6 0.14 70);
1119
+ }
1120
+
1121
+ .callout.caution {
1122
+ --callout: var(--c-danger);
1123
+ }
1124
+
1125
+ .jtree {
1126
+ padding: 10px 14px;
1127
+ overflow-x: auto;
1128
+ font-family: var(--c-mono);
1129
+ font-size: 12.5px;
1130
+ line-height: 1.7;
1131
+ }
1132
+
1133
+ .jtree summary {
1134
+ cursor: pointer;
1135
+ list-style-position: outside;
1136
+ }
1137
+
1138
+ .jkids {
1139
+ padding-left: 16px;
1140
+ border-left: 1px solid var(--c-line);
1141
+ margin-left: 4px;
1142
+ }
1143
+
1144
+ .jkey {
1145
+ color: var(--c-ink2);
1146
+ }
1147
+
1148
+ .jmeta {
1149
+ color: var(--c-muted);
1150
+ }
1151
+
1152
+ .jv.string {
1153
+ color: oklch(0.52 0.12 160);
1154
+ }
1155
+
1156
+ .jv.number {
1157
+ color: oklch(0.55 0.15 255);
1158
+ }
1159
+
1160
+ .jv.boolean,
1161
+ .jv.null {
1162
+ color: oklch(0.52 0.17 300);
1163
+ }
1164
+
1165
+ .table th button.sort {
1166
+ display: inline-flex;
1167
+ align-items: center;
1168
+ gap: 4px;
1169
+ font: inherit;
1170
+ color: inherit;
1171
+ background: none;
1172
+ border: none;
1173
+ padding: 0;
1174
+ cursor: pointer;
1175
+ }
1176
+
1177
+ .table th .arrow {
1178
+ font-size: 10px;
1179
+ opacity: 0.5;
1180
+ }
1181
+
1182
+ .table th[aria-sort="ascending"] .arrow,
1183
+ .table th[aria-sort="descending"] .arrow {
1184
+ opacity: 1;
1185
+ }
1186
+
1187
+ .table-note {
1188
+ padding: 7px 12px;
1189
+ font-size: 12px;
1190
+ color: var(--c-muted);
1191
+ border-top: 1px solid var(--c-line2);
1192
+ background: var(--c-bg2);
1193
+ }
1194
+
1195
+ figure.svg {
1196
+ margin: 0;
1197
+ display: flex;
1198
+ flex-direction: column;
1199
+ gap: 6px;
1200
+ align-items: flex-start;
1201
+ }
1202
+
1203
+ figure.svg img {
1204
+ display: block;
1205
+ width: min(100%, 480px);
1206
+ height: auto;
1207
+ max-height: 420px;
1208
+ object-fit: contain;
1209
+ padding: 12px;
1210
+ border: 1px solid var(--c-line);
1211
+ border-radius: var(--c-r2);
1212
+ background: #ffffff;
1213
+ }
1214
+
1215
+ .custom-block {
1216
+ min-width: 0;
1217
+ }
1218
+
1219
+ .quote {
1220
+ font-size: 13.5px;
1221
+ line-height: 1.6;
1222
+ color: var(--c-ink2);
1223
+ background: var(--c-bg2);
1224
+ border: 1px solid var(--c-line);
1225
+ border-radius: var(--c-r2);
1226
+ padding: 10px 14px;
1227
+ }
1228
+
1229
+ .code {
1230
+ border: 1px solid var(--c-line);
1231
+ border-radius: var(--c-r2);
1232
+ overflow: hidden;
1233
+ background: var(--c-bg2);
1234
+ }
1235
+
1236
+ .code-head {
1237
+ display: flex;
1238
+ align-items: center;
1239
+ justify-content: space-between;
1240
+ padding: 7px 12px;
1241
+ border-bottom: 1px solid var(--c-line);
1242
+ }
1243
+
1244
+ .code-head .label {
1245
+ font-size: 11px;
1246
+ }
1247
+
1248
+ .text-btn {
1249
+ font-size: 12px;
1250
+ color: var(--c-muted);
1251
+ background: none;
1252
+ border: none;
1253
+ padding: 0;
1254
+ cursor: pointer;
1255
+ }
1256
+
1257
+ .text-btn:hover {
1258
+ color: var(--c-ink);
1259
+ }
1260
+
1261
+ .text-btn.underline {
1262
+ text-decoration: underline;
1263
+ text-underline-offset: 3px;
1264
+ }
1265
+
1266
+ .code pre {
1267
+ margin: 0;
1268
+ padding: 12px 14px;
1269
+ overflow-x: auto;
1270
+ font-family: var(--c-mono);
1271
+ font-size: 13px;
1272
+ line-height: 1.6;
1273
+ }
1274
+
1275
+ .table {
1276
+ border: 1px solid var(--c-line);
1277
+ border-radius: var(--c-r2);
1278
+ overflow-x: auto;
1279
+ }
1280
+
1281
+ .table table {
1282
+ width: 100%;
1283
+ border-collapse: collapse;
1284
+ font-size: 13px;
1285
+ font-variant-numeric: tabular-nums;
1286
+ }
1287
+
1288
+ .table th {
1289
+ text-align: left;
1290
+ font-size: 12px;
1291
+ font-weight: 500;
1292
+ color: var(--c-muted);
1293
+ background: var(--c-bg2);
1294
+ border-bottom: 1px solid var(--c-line);
1295
+ padding: 9px 12px;
1296
+ white-space: nowrap;
1297
+ }
1298
+
1299
+ .table td {
1300
+ padding: 9px 12px;
1301
+ border-top: 1px solid var(--c-line2);
1302
+ white-space: nowrap;
1303
+ }
1304
+
1305
+ .table th:first-child,
1306
+ .table td:first-child {
1307
+ min-width: 120px;
1308
+ }
1309
+
1310
+ .cite {
1311
+ display: inline-flex;
1312
+ align-items: center;
1313
+ justify-content: center;
1314
+ min-width: 17px;
1315
+ height: 17px;
1316
+ padding: 0 4px;
1317
+ margin: 0 1px 0 3px;
1318
+ vertical-align: 2px;
1319
+ font: 500 10px var(--c-mono);
1320
+ border-radius: calc(var(--c-r) * 0.75);
1321
+ cursor: pointer;
1322
+ border: 1px solid var(--c-strong);
1323
+ background: var(--c-hover);
1324
+ color: var(--c-ink);
1325
+ }
1326
+
1327
+ .cite:hover,
1328
+ .cite.active {
1329
+ background: var(--c-ink);
1330
+ color: var(--c-bg);
1331
+ border-color: var(--c-ink);
1332
+ }
1333
+
1334
+ .chart {
1335
+ margin: 0;
1336
+ display: flex;
1337
+ flex-direction: column;
1338
+ gap: 14px;
1339
+ border: 1px solid var(--c-line);
1340
+ border-radius: var(--c-r2);
1341
+ padding: 14px 16px 12px;
1342
+ background: var(--c-bg);
1343
+ }
1344
+
1345
+ .chart-head {
1346
+ display: flex;
1347
+ flex-wrap: wrap;
1348
+ align-items: baseline;
1349
+ justify-content: space-between;
1350
+ gap: 8px 16px;
1351
+ }
1352
+
1353
+ .chart-title {
1354
+ font-size: 13px;
1355
+ font-weight: 600;
1356
+ }
1357
+
1358
+ .legend {
1359
+ display: flex;
1360
+ flex-wrap: wrap;
1361
+ gap: 4px 12px;
1362
+ }
1363
+
1364
+ .legend span {
1365
+ display: inline-flex;
1366
+ align-items: center;
1367
+ gap: 6px;
1368
+ font-size: 12px;
1369
+ color: var(--c-ink2);
1370
+ }
1371
+
1372
+ .swatch {
1373
+ width: 8px;
1374
+ height: 8px;
1375
+ border-radius: 2px;
1376
+ }
1377
+
1378
+ .bars {
1379
+ display: flex;
1380
+ flex-direction: column;
1381
+ gap: 10px;
1382
+ }
1383
+
1384
+ .bar-row {
1385
+ display: grid;
1386
+ grid-template-columns: 92px minmax(0, 1fr) 64px;
1387
+ align-items: center;
1388
+ gap: 12px;
1389
+ }
1390
+
1391
+ .bar-label {
1392
+ font-size: 12.5px;
1393
+ color: var(--c-ink2);
1394
+ overflow: hidden;
1395
+ text-overflow: ellipsis;
1396
+ white-space: nowrap;
1397
+ }
1398
+
1399
+ .bar-track {
1400
+ display: flex;
1401
+ height: 12px;
1402
+ background: var(--c-hover);
1403
+ border-radius: 2px;
1404
+ overflow: hidden;
1405
+ }
1406
+
1407
+ .bar-fill {
1408
+ display: flex;
1409
+ height: 100%;
1410
+ transform-origin: left;
1411
+ animation: aiGrow 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
1412
+ }
1413
+
1414
+ .bar-value {
1415
+ font-family: var(--c-mono);
1416
+ font-size: 11.5px;
1417
+ text-align: right;
1418
+ font-variant-numeric: tabular-nums;
1419
+ }
1420
+
1421
+ .line-chart {
1422
+ display: flex;
1423
+ flex-direction: column;
1424
+ gap: 6px;
1425
+ padding-left: 48px;
1426
+ }
1427
+
1428
+ .plot {
1429
+ position: relative;
1430
+ height: 170px;
1431
+ }
1432
+
1433
+ .tick {
1434
+ position: absolute;
1435
+ left: 0;
1436
+ right: 0;
1437
+ border-top: 1px dashed var(--c-line2);
1438
+ }
1439
+
1440
+ .tick.base {
1441
+ border-top: 1px solid var(--c-strong);
1442
+ }
1443
+
1444
+ .tick span,
1445
+ .x-labels span {
1446
+ font-family: var(--c-mono);
1447
+ font-size: 10.5px;
1448
+ color: var(--c-faint);
1449
+ white-space: nowrap;
1450
+ font-variant-numeric: tabular-nums;
1451
+ }
1452
+
1453
+ .tick span {
1454
+ position: absolute;
1455
+ right: calc(100% + 8px);
1456
+ top: -7px;
1457
+ }
1458
+
1459
+ .plot svg {
1460
+ position: absolute;
1461
+ inset: 0;
1462
+ width: 100%;
1463
+ height: 100%;
1464
+ overflow: visible;
1465
+ }
1466
+
1467
+ .plot polyline {
1468
+ fill: none;
1469
+ stroke-width: 2;
1470
+ vector-effect: non-scaling-stroke;
1471
+ stroke-linejoin: round;
1472
+ stroke-linecap: round;
1473
+ stroke-dasharray: 1;
1474
+ animation: aiDraw 1s ease-out;
1475
+ }
1476
+
1477
+ .x-labels {
1478
+ display: flex;
1479
+ justify-content: space-between;
1480
+ gap: 4px;
1481
+ }
1482
+
1483
+ .chart-pending {
1484
+ display: flex;
1485
+ align-items: center;
1486
+ justify-content: center;
1487
+ height: 190px;
1488
+ border: 1px solid var(--c-line);
1489
+ border-radius: var(--c-r2);
1490
+ background: linear-gradient(90deg, var(--c-bg2) 0%, var(--c-hover) 50%, var(--c-bg2) 100%);
1491
+ background-size: 200% 100%;
1492
+ animation: aiShimmer 1.6s linear infinite;
1493
+ }
1494
+
1495
+ .gallery {
1496
+ display: grid;
1497
+ grid-template-columns: minmax(0, 1fr);
1498
+ gap: 10px;
1499
+ max-width: 520px;
1500
+ }
1501
+
1502
+ .gallery.many {
1503
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
1504
+ max-width: 100%;
1505
+ }
1506
+
1507
+ .gallery figure {
1508
+ margin: 0;
1509
+ display: flex;
1510
+ flex-direction: column;
1511
+ gap: 6px;
1512
+ min-width: 0;
1513
+ }
1514
+
1515
+ .gallery img {
1516
+ width: 100%;
1517
+ aspect-ratio: 16 / 10;
1518
+ max-height: 320px;
1519
+ object-fit: contain;
1520
+ border-radius: var(--c-r2);
1521
+ border: 1px solid var(--c-line);
1522
+ background: var(--c-bg2);
1523
+ }
1524
+
1525
+ .img-missing {
1526
+ aspect-ratio: 16 / 9;
1527
+ display: flex;
1528
+ align-items: center;
1529
+ justify-content: center;
1530
+ border-radius: var(--c-r2);
1531
+ border: 1px dashed var(--c-strong);
1532
+ background: repeating-linear-gradient(135deg, var(--c-bg2) 0 10px, var(--c-hover) 10px 20px);
1533
+ }
1534
+
1535
+ figcaption {
1536
+ font-family: var(--c-mono);
1537
+ font-size: 11px;
1538
+ color: var(--c-muted);
1539
+ overflow: hidden;
1540
+ text-overflow: ellipsis;
1541
+ white-space: nowrap;
1542
+ }
1543
+
1544
+ .caret {
1545
+ display: inline-block;
1546
+ width: 7px;
1547
+ height: 15px;
1548
+ margin-top: -6px;
1549
+ background: var(--c-brand);
1550
+ animation: rgcaret 1s steps(1) infinite;
1551
+ }
1552
+
1553
+ /* ── sources ──────────────────────────────────────────── */
1554
+
1555
+ .retrieval {
1556
+ display: flex;
1557
+ flex-direction: column;
1558
+ border: 1px solid var(--c-line);
1559
+ border-radius: var(--c-r2);
1560
+ background: var(--c-bg2);
1561
+ }
1562
+
1563
+ .retrieval-toggle {
1564
+ display: flex;
1565
+ align-items: center;
1566
+ gap: 10px;
1567
+ width: 100%;
1568
+ text-align: left;
1569
+ font-size: 12.5px;
1570
+ color: var(--c-ink2);
1571
+ background: none;
1572
+ border: none;
1573
+ padding: 9px 12px;
1574
+ cursor: pointer;
1575
+ }
1576
+
1577
+ .retrieval-toggle .chev,
1578
+ .retrieval-toggle .ms {
1579
+ font-family: var(--c-mono);
1580
+ font-size: 11px;
1581
+ color: var(--c-muted);
1582
+ }
1583
+
1584
+ .retrieval-list {
1585
+ display: flex;
1586
+ flex-direction: column;
1587
+ border-top: 1px solid var(--c-line);
1588
+ padding: 4px 12px;
1589
+ }
1590
+
1591
+ .passage {
1592
+ display: grid;
1593
+ grid-template-columns: 22px minmax(0, 1fr) 64px;
1594
+ align-items: center;
1595
+ gap: 10px;
1596
+ width: 100%;
1597
+ text-align: left;
1598
+ background: none;
1599
+ border: none;
1600
+ border-bottom: 1px solid var(--c-line2);
1601
+ padding: 8px 0;
1602
+ cursor: pointer;
1603
+ }
1604
+
1605
+ .passage:last-child {
1606
+ border-bottom: none;
1607
+ }
1608
+
1609
+ .passage .n,
1610
+ .passage .score {
1611
+ font-family: var(--c-mono);
1612
+ font-size: 11px;
1613
+ color: var(--c-muted);
1614
+ font-variant-numeric: tabular-nums;
1615
+ }
1616
+
1617
+ .passage .what {
1618
+ display: flex;
1619
+ flex-direction: column;
1620
+ gap: 1px;
1621
+ min-width: 0;
1622
+ }
1623
+
1624
+ .passage .what span:first-child {
1625
+ font-size: 12.5px;
1626
+ overflow: hidden;
1627
+ text-overflow: ellipsis;
1628
+ white-space: nowrap;
1629
+ }
1630
+
1631
+ .passage .what span:last-child {
1632
+ font-size: 11.5px;
1633
+ color: var(--c-muted);
1634
+ }
1635
+
1636
+ .relevance {
1637
+ display: flex;
1638
+ flex-direction: column;
1639
+ gap: 3px;
1640
+ align-items: flex-end;
1641
+ }
1642
+
1643
+ .relevance-track {
1644
+ width: 64px;
1645
+ height: 3px;
1646
+ background: var(--c-line);
1647
+ border-radius: 99px;
1648
+ overflow: hidden;
1649
+ }
1650
+
1651
+ .relevance-fill {
1652
+ display: block;
1653
+ height: 100%;
1654
+ background: var(--c-brand);
1655
+ }
1656
+
1657
+ .cards {
1658
+ display: flex;
1659
+ flex-direction: column;
1660
+ gap: 8px;
1661
+ }
1662
+
1663
+ .card-grid {
1664
+ display: grid;
1665
+ grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
1666
+ gap: 8px;
1667
+ }
1668
+
1669
+ .source-card {
1670
+ display: flex;
1671
+ flex-direction: column;
1672
+ gap: 6px;
1673
+ min-width: 0;
1674
+ text-align: left;
1675
+ padding: 10px 12px;
1676
+ border-radius: var(--c-r2);
1677
+ cursor: pointer;
1678
+ background: var(--c-bg);
1679
+ border: 1px solid var(--c-line);
1680
+ }
1681
+
1682
+ .source-card:hover,
1683
+ .source-card.active {
1684
+ border-color: var(--c-ink);
1685
+ }
1686
+
1687
+ .source-card .top {
1688
+ display: flex;
1689
+ align-items: center;
1690
+ gap: 8px;
1691
+ min-width: 0;
1692
+ }
1693
+
1694
+ .num {
1695
+ min-width: 16px;
1696
+ height: 16px;
1697
+ padding: 0 4px;
1698
+ border-radius: calc(var(--c-r) * 0.75);
1699
+ border: 1px solid var(--c-strong);
1700
+ display: inline-flex;
1701
+ align-items: center;
1702
+ justify-content: center;
1703
+ font-family: var(--c-mono);
1704
+ font-size: 10px;
1705
+ background: var(--c-bg);
1706
+ }
1707
+
1708
+ .source-card .t {
1709
+ font-size: 13px;
1710
+ font-weight: 500;
1711
+ overflow: hidden;
1712
+ text-overflow: ellipsis;
1713
+ white-space: nowrap;
1714
+ }
1715
+
1716
+ .source-card .s {
1717
+ font-size: 12px;
1718
+ line-height: 1.45;
1719
+ color: var(--c-muted);
1720
+ display: -webkit-box;
1721
+ -webkit-line-clamp: 2;
1722
+ -webkit-box-orient: vertical;
1723
+ overflow: hidden;
1724
+ }
1725
+
1726
+ .panel {
1727
+ display: flex;
1728
+ flex-direction: column;
1729
+ min-height: 0;
1730
+ min-width: 0;
1731
+ background: var(--c-bg);
1732
+ border-left: 1px solid var(--c-line);
1733
+ animation: aiIn 0.15s ease-out;
1734
+ }
1735
+
1736
+ .panel.docked {
1737
+ position: relative;
1738
+ flex: 0 0 400px;
1739
+ width: 400px;
1740
+ }
1741
+
1742
+ .panel.overlay {
1743
+ position: absolute;
1744
+ right: 0;
1745
+ top: 0;
1746
+ bottom: 0;
1747
+ z-index: 30;
1748
+ width: min(420px, 100%);
1749
+ box-shadow: -12px 0 32px -16px rgba(22, 24, 26, 0.25);
1750
+ }
1751
+
1752
+ .panel-head {
1753
+ display: flex;
1754
+ align-items: center;
1755
+ justify-content: space-between;
1756
+ gap: 8px;
1757
+ padding: 14px 18px;
1758
+ border-bottom: 1px solid var(--c-line);
1759
+ }
1760
+
1761
+ .panel-body {
1762
+ flex: 1;
1763
+ min-height: 0;
1764
+ overflow-y: auto;
1765
+ display: flex;
1766
+ flex-direction: column;
1767
+ gap: 16px;
1768
+ padding: 18px;
1769
+ }
1770
+
1771
+ .panel-body h3 {
1772
+ margin: 0;
1773
+ font-size: 16px;
1774
+ font-weight: 600;
1775
+ letter-spacing: -0.01em;
1776
+ }
1777
+
1778
+ .panel-meta {
1779
+ display: flex;
1780
+ flex-direction: column;
1781
+ gap: 4px;
1782
+ }
1783
+
1784
+ .panel-meta .path {
1785
+ font-family: var(--c-mono);
1786
+ font-size: 11px;
1787
+ color: var(--c-muted);
1788
+ overflow-wrap: anywhere;
1789
+ }
1790
+
1791
+ .panel-meta .meta {
1792
+ font-size: 12px;
1793
+ color: var(--c-muted);
1794
+ }
1795
+
1796
+ .passage-box {
1797
+ display: flex;
1798
+ flex-direction: column;
1799
+ gap: 8px;
1800
+ padding: 12px 14px;
1801
+ border-radius: var(--c-r2);
1802
+ background: var(--c-hover);
1803
+ border: 1px solid var(--c-strong);
1804
+ }
1805
+
1806
+ .passage-box .text {
1807
+ font-size: 13px;
1808
+ line-height: 1.6;
1809
+ color: var(--c-ink2);
1810
+ white-space: pre-wrap;
1811
+ overflow-wrap: anywhere;
1812
+ }
1813
+
1814
+ .passage-foot {
1815
+ display: flex;
1816
+ align-items: center;
1817
+ justify-content: space-between;
1818
+ gap: 8px;
1819
+ padding-top: 8px;
1820
+ border-top: 1px solid var(--c-line);
1821
+ }
1822
+
1823
+ .copy-ref {
1824
+ display: inline-flex;
1825
+ align-items: center;
1826
+ gap: 6px;
1827
+ font-size: 12px;
1828
+ background: var(--c-bg);
1829
+ border: 1px solid var(--c-line);
1830
+ border-radius: var(--c-r);
1831
+ padding: 4px 8px;
1832
+ cursor: pointer;
1833
+ }
1834
+
1835
+ .copy-ref:hover {
1836
+ border-color: var(--c-strong);
1837
+ }
1838
+
1839
+ .panel-foot {
1840
+ display: flex;
1841
+ flex-direction: column;
1842
+ gap: 6px;
1843
+ padding: 12px 18px 16px;
1844
+ border-top: 1px solid var(--c-line);
1845
+ }
1846
+
1847
+ .chips {
1848
+ display: flex;
1849
+ flex-wrap: wrap;
1850
+ gap: 6px;
1851
+ }
1852
+
1853
+ .chip {
1854
+ font-size: 12px;
1855
+ background: var(--c-bg);
1856
+ border: 1px solid var(--c-line);
1857
+ border-radius: var(--c-r);
1858
+ padding: 4px 8px;
1859
+ cursor: pointer;
1860
+ max-width: 100%;
1861
+ overflow: hidden;
1862
+ text-overflow: ellipsis;
1863
+ white-space: nowrap;
1864
+ }
1865
+
1866
+ .chip:hover {
1867
+ border-color: var(--c-ink);
1868
+ }
1869
+
1870
+ /* ── composer ─────────────────────────────────────────── */
1871
+
1872
+ .composer-wrap {
1873
+ padding: 0 12px 12px;
1874
+ }
1875
+
1876
+ .composer-wrap.reader {
1877
+ padding-top: 10px;
1878
+ }
1879
+
1880
+ .composer-col {
1881
+ max-width: 760px;
1882
+ margin: 0 auto;
1883
+ display: flex;
1884
+ flex-direction: column;
1885
+ gap: 8px;
1886
+ }
1887
+
1888
+ .composer-box {
1889
+ position: relative;
1890
+ }
1891
+
1892
+ .composer {
1893
+ position: relative;
1894
+ z-index: 1;
1895
+ display: flex;
1896
+ flex-direction: column;
1897
+ gap: 4px;
1898
+ padding: 8px;
1899
+ border-radius: calc(var(--c-r) * 2.25);
1900
+ background: var(--c-bg);
1901
+ border: 1px solid var(--c-strong);
1902
+ box-shadow:
1903
+ 0 1px 2px rgba(22, 24, 26, 0.04),
1904
+ 0 12px 32px -18px rgba(22, 24, 26, 0.22);
1905
+ transition: border-color 0.15s;
1906
+ }
1907
+
1908
+ .composer:focus-within {
1909
+ border-color: var(--c-ink);
1910
+ }
1911
+
1912
+ .composer.busy {
1913
+ border-color: transparent;
1914
+ }
1915
+
1916
+ :host([glow="off"]) .composer.busy {
1917
+ border-color: var(--c-strong);
1918
+ }
1919
+
1920
+ .composer textarea {
1921
+ width: 100%;
1922
+ resize: none;
1923
+ font: inherit;
1924
+ font-size: 14.5px;
1925
+ line-height: 1.5;
1926
+ color: var(--c-ink);
1927
+ background: transparent;
1928
+ border: none;
1929
+ outline: none;
1930
+ padding: 6px 6px 2px;
1931
+ max-height: 176px;
1932
+ }
1933
+
1934
+ .composer textarea::placeholder {
1935
+ color: var(--c-faint);
1936
+ }
1937
+
1938
+ .composer-row {
1939
+ display: flex;
1940
+ align-items: center;
1941
+ justify-content: space-between;
1942
+ gap: 8px;
1943
+ }
1944
+
1945
+ .attach {
1946
+ display: inline-flex;
1947
+ align-items: center;
1948
+ gap: 6px;
1949
+ font-size: 12.5px;
1950
+ color: var(--c-muted);
1951
+ background: none;
1952
+ border: none;
1953
+ border-radius: var(--c-r);
1954
+ padding: 6px 8px;
1955
+ cursor: pointer;
1956
+ }
1957
+
1958
+ .attach:hover {
1959
+ background: var(--c-hover);
1960
+ color: var(--c-ink);
1961
+ }
1962
+
1963
+ .send {
1964
+ display: inline-flex;
1965
+ align-items: center;
1966
+ justify-content: center;
1967
+ width: 32px;
1968
+ height: 32px;
1969
+ padding: 0;
1970
+ border-radius: var(--c-r2);
1971
+ border: 1px solid var(--c-brand);
1972
+ cursor: pointer;
1973
+ background: var(--c-brand);
1974
+ color: var(--c-on-brand);
1975
+ transition: background 0.15s;
1976
+ }
1977
+
1978
+ .send:disabled {
1979
+ cursor: default;
1980
+ background: var(--c-line);
1981
+ border-color: var(--c-line);
1982
+ color: var(--c-faint);
1983
+ }
1984
+
1985
+ .send.stop {
1986
+ background: var(--c-bg);
1987
+ color: var(--c-ink);
1988
+ border-color: var(--c-ink);
1989
+ }
1990
+
1991
+ .send.stop svg {
1992
+ fill: currentColor;
1993
+ stroke: none;
1994
+ }
1995
+
1996
+ .pending-files {
1997
+ display: flex;
1998
+ flex-wrap: wrap;
1999
+ gap: 6px;
2000
+ padding: 2px 2px 4px;
2001
+ }
2002
+
2003
+ .pending-file {
2004
+ display: inline-flex;
2005
+ align-items: center;
2006
+ gap: 8px;
2007
+ padding: 4px 8px 4px 4px;
2008
+ font-size: 12.5px;
2009
+ border-radius: var(--c-r2);
2010
+ border: 1px solid var(--c-line);
2011
+ background: var(--c-bg2);
2012
+ animation: aiIn 0.2s ease-out;
2013
+ }
2014
+
2015
+ .pending-file .ext {
2016
+ width: 28px;
2017
+ height: 28px;
2018
+ display: inline-flex;
2019
+ align-items: center;
2020
+ justify-content: center;
2021
+ border-radius: var(--c-r);
2022
+ background: var(--c-bg);
2023
+ border: 1px solid var(--c-line);
2024
+ font-family: var(--c-mono);
2025
+ font-size: 9px;
2026
+ letter-spacing: 0.03em;
2027
+ color: var(--c-muted);
2028
+ }
2029
+
2030
+ .pending-file .meta {
2031
+ display: flex;
2032
+ flex-direction: column;
2033
+ gap: 1px;
2034
+ min-width: 0;
2035
+ }
2036
+
2037
+ .pending-file.kept {
2038
+ background: var(--c-bg);
2039
+ border-style: dashed;
2040
+ }
2041
+
2042
+ .pending-file .name {
2043
+ max-width: 160px;
2044
+ overflow: hidden;
2045
+ text-overflow: ellipsis;
2046
+ white-space: nowrap;
2047
+ }
2048
+
2049
+ .pending-file .size {
2050
+ font-family: var(--c-mono);
2051
+ font-size: 10.5px;
2052
+ color: var(--c-muted);
2053
+ }
2054
+
2055
+ .pending-file button {
2056
+ font-size: 15px;
2057
+ line-height: 1;
2058
+ color: var(--c-muted);
2059
+ background: none;
2060
+ border: none;
2061
+ padding: 0 0 0 2px;
2062
+ cursor: pointer;
2063
+ }
2064
+
2065
+ .pending-file button:hover {
2066
+ color: var(--c-danger);
2067
+ }
2068
+
2069
+ .footnote {
2070
+ text-align: center;
2071
+ font-size: 11.5px;
2072
+ color: var(--c-muted);
2073
+ }
2074
+
2075
+ .branding {
2076
+ padding: 0 12px 10px;
2077
+ margin-top: -4px;
2078
+ }
2079
+
2080
+ .toast {
2081
+ position: absolute;
2082
+ left: 50%;
2083
+ bottom: 124px;
2084
+ transform: translateX(-50%);
2085
+ z-index: 35;
2086
+ display: flex;
2087
+ align-items: center;
2088
+ gap: 14px;
2089
+ padding: 9px 14px;
2090
+ background: var(--c-ink);
2091
+ color: var(--c-bg);
2092
+ font-size: 13px;
2093
+ border-radius: var(--c-r2);
2094
+ box-shadow: 0 12px 32px -12px rgba(22, 24, 26, 0.25);
2095
+ white-space: nowrap;
2096
+ animation: aiIn 0.2s ease-out;
2097
+ }
2098
+
2099
+ .toast button {
2100
+ font-size: 13px;
2101
+ font-weight: 500;
2102
+ color: var(--c-bg);
2103
+ background: none;
2104
+ border: none;
2105
+ padding: 0;
2106
+ cursor: pointer;
2107
+ text-decoration: underline;
2108
+ text-underline-offset: 3px;
2109
+ }
2110
+
2111
+ .drop {
2112
+ position: absolute;
2113
+ inset: 10px;
2114
+ z-index: 36;
2115
+ display: flex;
2116
+ flex-direction: column;
2117
+ align-items: center;
2118
+ justify-content: center;
2119
+ gap: 6px;
2120
+ text-align: center;
2121
+ padding: 16px;
2122
+ border: 1.5px dashed var(--c-ink);
2123
+ border-radius: var(--c-r3);
2124
+ background: color-mix(in srgb, var(--c-bg) 92%, transparent);
2125
+ }
2126
+
2127
+ .drop strong {
2128
+ font-size: 15px;
2129
+ font-weight: 600;
2130
+ }
2131
+
2132
+ .drop span {
2133
+ font-size: 12.5px;
2134
+ color: var(--c-muted);
2135
+ }
2136
+
2137
+ /* ── AI glow ──────────────────────────────────────────── */
2138
+
2139
+ .halo {
2140
+ position: absolute;
2141
+ inset: -18px -24px;
2142
+ z-index: 0;
2143
+ pointer-events: none;
2144
+ opacity: var(--c-glow);
2145
+ }
2146
+
2147
+ .halo::before {
2148
+ content: "";
2149
+ position: absolute;
2150
+ inset: 0;
2151
+ border-radius: 20px;
2152
+ background: var(--c-conic);
2153
+ filter: blur(32px);
2154
+ opacity: 0.45;
2155
+ animation:
2156
+ aiSpin 5s linear infinite,
2157
+ aiBreathe 2.6s ease-in-out infinite;
2158
+ }
2159
+
2160
+ .arrived {
2161
+ position: absolute;
2162
+ inset: -12px -16px;
2163
+ z-index: 0;
2164
+ pointer-events: none;
2165
+ border-radius: var(--c-r4);
2166
+ animation: aiDone 2.6s ease-out forwards;
2167
+ }
2168
+
2169
+ .arrived .wash {
2170
+ position: absolute;
2171
+ inset: 0;
2172
+ border-radius: inherit;
2173
+ background: var(--c-conic);
2174
+ filter: blur(26px);
2175
+ opacity: calc(0.22 * var(--c-glow) + 0.06);
2176
+ animation: aiSpin 2.6s linear infinite;
2177
+ }
2178
+
2179
+ .ring {
2180
+ position: absolute;
2181
+ inset: 0;
2182
+ border-radius: inherit;
2183
+ padding: 1px;
2184
+ background: var(--c-conic);
2185
+ -webkit-mask:
2186
+ linear-gradient(#000 0 0) content-box,
2187
+ linear-gradient(#000 0 0);
2188
+ -webkit-mask-composite: xor;
2189
+ mask-composite: exclude;
2190
+ animation: aiSpin 2.6s linear infinite;
2191
+ pointer-events: none;
2192
+ }
2193
+
2194
+ .arrived .sweep {
2195
+ position: absolute;
2196
+ inset: 0;
2197
+ border-radius: inherit;
2198
+ overflow: hidden;
2199
+ }
2200
+
2201
+ .arrived .sweep::before {
2202
+ content: "";
2203
+ position: absolute;
2204
+ inset: 0;
2205
+ background: linear-gradient(
2206
+ 100deg,
2207
+ transparent 25%,
2208
+ oklch(0.88 0.07 260 / 0.5) 50%,
2209
+ transparent 75%
2210
+ );
2211
+ animation: aiSweep 1.6s cubic-bezier(0.3, 0.6, 0.3, 1) forwards;
2212
+ }
2213
+
2214
+ .pill {
2215
+ position: relative;
2216
+ display: inline-flex;
2217
+ align-self: flex-start;
2218
+ align-items: center;
2219
+ gap: 9px;
2220
+ padding: 6px 14px 6px 10px;
2221
+ border-radius: 999px;
2222
+ background: var(--c-bg);
2223
+ box-shadow: 0 0 24px -6px oklch(0.7 0.15 280 / 0.5);
2224
+ animation: aiIn 0.25s ease-out;
2225
+ }
2226
+
2227
+ .pill .ring {
2228
+ border-radius: 999px;
2229
+ animation-duration: 2.4s;
2230
+ }
2231
+
2232
+ .pill .dot {
2233
+ width: 9px;
2234
+ height: 9px;
2235
+ border-radius: 50%;
2236
+ background: var(--c-conic);
2237
+ animation:
2238
+ aiSpin 1.6s linear infinite,
2239
+ aiPulse 1.6s ease-in-out infinite;
2240
+ }
2241
+
2242
+ .pill .shimmer {
2243
+ font-size: 12.5px;
2244
+ font-weight: 500;
2245
+ background: linear-gradient(90deg, var(--c-faint) 0%, var(--c-ink) 45%, var(--c-faint) 90%);
2246
+ background-size: 200% 100%;
2247
+ -webkit-background-clip: text;
2248
+ background-clip: text;
2249
+ color: transparent;
2250
+ animation: aiShimmer 1.8s linear infinite;
2251
+ }
2252
+
2253
+ .composer-glow {
2254
+ position: absolute;
2255
+ inset: -4px;
2256
+ z-index: 0;
2257
+ border-radius: var(--c-r4);
2258
+ background: var(--c-conic);
2259
+ filter: blur(14px);
2260
+ opacity: calc(0.32 + 0.23 * (var(--c-glow) - 0.6) / 0.4);
2261
+ animation: aiSpin 4s linear infinite;
2262
+ pointer-events: none;
2263
+ }
2264
+
2265
+ .composer-ring {
2266
+ position: absolute;
2267
+ inset: 0;
2268
+ z-index: 2;
2269
+ border-radius: calc(var(--c-r) * 2.25);
2270
+ pointer-events: none;
2271
+ }
2272
+
2273
+ .composer-ring .ring {
2274
+ animation-duration: 3s;
2275
+ }
2276
+
2277
+ :host([glow="off"]) .halo,
2278
+ :host([glow="off"]) .arrived,
2279
+ :host([glow="off"]) .composer-glow,
2280
+ :host([glow="off"]) .composer-ring,
2281
+ :host([glow="off"]) .pill .ring {
2282
+ display: none;
2283
+ }
2284
+
2285
+ :host([glow="off"]) .pill {
2286
+ box-shadow: inset 0 0 0 1px var(--c-line);
2287
+ }
2288
+
2289
+ :host([glow="off"]) .pill .dot {
2290
+ background: var(--c-ink);
2291
+ }
2292
+
2293
+ @keyframes aiSpin {
2294
+ to {
2295
+ --sb-ai-angle: 360deg;
2296
+ }
2297
+ }
2298
+
2299
+ @keyframes aiShimmer {
2300
+ from {
2301
+ background-position: 200% 0;
2302
+ }
2303
+ to {
2304
+ background-position: -200% 0;
2305
+ }
2306
+ }
2307
+
2308
+ @keyframes aiBreathe {
2309
+ 0%,
2310
+ 100% {
2311
+ transform: scale(0.97);
2312
+ }
2313
+ 50% {
2314
+ transform: scale(1.03);
2315
+ }
2316
+ }
2317
+
2318
+ @keyframes aiPulse {
2319
+ 0%,
2320
+ 100% {
2321
+ transform: scale(0.8);
2322
+ }
2323
+ 50% {
2324
+ transform: scale(1.15);
2325
+ }
2326
+ }
2327
+
2328
+ @keyframes aiDone {
2329
+ 0% {
2330
+ opacity: 0;
2331
+ }
2332
+ 12% {
2333
+ opacity: 1;
2334
+ }
2335
+ 100% {
2336
+ opacity: 0;
2337
+ }
2338
+ }
2339
+
2340
+ @keyframes aiSweep {
2341
+ from {
2342
+ transform: translateX(-100%);
2343
+ }
2344
+ to {
2345
+ transform: translateX(100%);
2346
+ }
2347
+ }
2348
+
2349
+ @keyframes aiIn {
2350
+ from {
2351
+ opacity: 0;
2352
+ transform: translateY(4px);
2353
+ }
2354
+ to {
2355
+ opacity: 1;
2356
+ transform: none;
2357
+ }
2358
+ }
2359
+
2360
+ @keyframes scaleIn {
2361
+ from {
2362
+ opacity: 0;
2363
+ transform: translateY(12px) scale(0.98);
2364
+ }
2365
+ to {
2366
+ opacity: 1;
2367
+ transform: none;
2368
+ }
2369
+ }
2370
+
2371
+ @keyframes slideIn {
2372
+ from {
2373
+ opacity: 0;
2374
+ transform: translateX(-8px);
2375
+ }
2376
+ to {
2377
+ opacity: 1;
2378
+ transform: none;
2379
+ }
2380
+ }
2381
+
2382
+ @keyframes aiGrow {
2383
+ from {
2384
+ transform: scaleX(0);
2385
+ }
2386
+ }
2387
+
2388
+ @keyframes aiDraw {
2389
+ from {
2390
+ stroke-dashoffset: 1;
2391
+ }
2392
+ to {
2393
+ stroke-dashoffset: 0;
2394
+ }
2395
+ }
2396
+
2397
+ @keyframes rgcaret {
2398
+ 0%,
2399
+ 100% {
2400
+ opacity: 1;
2401
+ }
2402
+ 50% {
2403
+ opacity: 0;
2404
+ }
2405
+ }
2406
+
2407
+ @media (prefers-reduced-motion: reduce) {
2408
+ *,
2409
+ *::before,
2410
+ *::after {
2411
+ animation-duration: 0.01ms !important;
2412
+ animation-iteration-count: 1 !important;
2413
+ }
2414
+ .caret {
2415
+ display: none;
2416
+ }
2417
+ }
2418
+
2419
+ @media print {
2420
+ .sidebar,
2421
+ .scrim,
2422
+ .header-right,
2423
+ .composer-wrap,
2424
+ .branding,
2425
+ .toolbar,
2426
+ .followups,
2427
+ .panel,
2428
+ .toast {
2429
+ display: none !important;
2430
+ }
2431
+ .frame,
2432
+ .scroller {
2433
+ overflow: visible;
2434
+ height: auto;
2435
+ }
2436
+ }
2437
+ `,Et={eyebrowChat:"Chat",eyebrowRag:"Grounded answers",headingChat:"What can I help with?",headingRag:"Ask your knowledge base",descriptionChat:"Ask anything. Attach text files to give it more context.",descriptionRag:"Answers are grounded in your sources, with a citation for every claim. Attach text files to search them too.",eyebrowKb:"Knowledge base",headingKb:"Ask the knowledge base",descriptionKb:"Answers come only from the knowledge base, with a citation for every claim.",placeholderChat:"Message {name}…",placeholderRag:"Ask about your sources…",placeholderKb:"Ask the knowledge base…",footnote:"{name} can make mistakes. Check important details.",attach:"Attach files",send:"Send message",stop:"Stop generating",removeFile:"Remove file",inThisChat:"In this chat",removeFromChat:"Remove from this chat",attachmentFailed:"Couldn't read {name}.",dropTitle:"Drop files to attach",dropSub:"Text, Markdown, CSV and JSON files are added as context.",thinking:"Thinking",searching:"Searching sources",chats:"Chats",newChat:"New chat",searchChats:"Search chats",groupBookmarked:"Bookmarked",groupToday:"Today",groupYesterday:"Yesterday",groupWeek:"Previous 7 days",groupOlder:"Older",noChats:"No chats yet.",noMatch:"No chats match “{query}”.",loadingChats:"Loading chats",showChats:"Show chats",hideSidebar:"Hide sidebar",untitled:"New chat",renameChat:"Rename chat",bookmarkChat:"Bookmark chat",unbookmarkChat:"Remove chat bookmark",exportChat:"Export chat",deleteChat:"Delete chat",expand:"Expand",restore:"Restore size",minimize:"Minimize chat",exportHeading:"Export this chat",exportMarkdown:"Markdown",exportJson:"JSON",exportText:"Plain text",exportCopy:"Copy as Markdown",copy:"Copy",copied:"Copied",edit:"Edit and resend",saveResend:"Save & resend",cancel:"Cancel",regenerate:"Regenerate",helpful:"Helpful",notHelpful:"Not helpful",markedHelpful:"Marked helpful",thanksFeedback:"Thanks for the feedback",bookmarkMessage:"Bookmark message",unbookmarkMessage:"Remove bookmark",deleteMessage:"Delete message",saved:"Saved",stopped:"Stopped",emptyReply:"(empty response)",newReply:"New reply",you:"You",sourcesCited:"Cited sources",sourcesRetrieved:"Sources",searchedSources:"Searched {n} sources",sourceLabel:"Source {n}",openSource:"Open source {n}",citedPassage:"Cited passage",copyReference:"Copy passage with reference",alsoCited:"Also cited",close:"Close",renderingChart:"Rendering chart",renderingSvg:"Rendering drawing",copySvg:"Copy SVG",showRaw:"View raw",showFormatted:"View formatted",showingRows:"Showing {n} of {total} rows",calloutNote:"Note",calloutTip:"Tip",calloutImportant:"Important",calloutWarning:"Warning",calloutCaution:"Caution",undo:"Undo",chatDeleted:"Chat deleted",messageDeleted:"Message deleted",messageBookmarked:"Message bookmarked",bookmarkRemoved:"Bookmark removed",chatBookmarked:"Chat bookmarked",chatUnbookmarked:"Chat removed from bookmarks",exported:"Exported {name}",copiedMarkdown:"Copied as Markdown",fileTooLarge:"{name} is larger than {size}.",fileType:"{name} isn't a text file.",tooManyFiles:"Attach up to {n} files at a time.",errGeneric:"Something went wrong.",errNotFound:"This chat no longer exists. Retry to start a new one.",errKbSource:"No knowledge base is set up for this chat.",errNoClient:"Chat isn't connected. Create a SinglebaseClient() on this page.",errLoad:"Couldn't load this chat.",retry:"Retry",offline:"You're offline. Messages will send when you reconnect.",bubbleText:"Hi! Questions? Ask me here.",openChat:"Open chat",closeChat:"Close chat",dismiss:"Dismiss"};function Bt(l){return{...Et,...l??{}}}const Yt=/^\|.*\|$/,wt=/^\|[\s:|-]+\|$/,kt=/^!\[([^\]]*)\]\(([^)]*)\)$/,$t=/^(\s*)([-*+]|\d+[.)])\s+(.*)$/,Ct=/^\[( |x|X)\]\s+/,Qt=/^(-{3,}|\*{3,}|_{3,})$/,Zt=/^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i,es=["note","tip","important","warning","caution"];function Dt(l){const o=[],e=(l??"").replace(/\r/g,"").split("```");return e.forEach((t,s)=>{if(s%2===1){const a=t.indexOf(`
2438
+ `),r=(a>-1?t.slice(0,a):t).trim(),n=(a>-1?t.slice(a+1):"").replace(/\n$/,"");o.push(ts(r,n,s===e.length-1));return}for(const a of t.split(/\n{2,}/))a.trim()&&o.push(...Ft(a))}),o}function ts(l,o,e){const[t="",...s]=l.split(/\s+/),a=t.toLowerCase();if(a==="chart"){const r=e?null:is(o);return r?{type:"chart",spec:r}:{type:"pending",kind:"chart"}}if(a==="svg")return e||!/<svg[\s>]/i.test(o)?{type:"pending",kind:"svg"}:{type:"svg",source:o.trim()};if(!e&&(a==="csv"||a==="tsv")){const r=ss(o,a==="tsv"?" ":",");if(r.length>1)return{type:"table",head:r[0],rows:r.slice(1),align:r[0].map(()=>null)}}if(!e&&a==="json")try{return{type:"json",value:JSON.parse(o),source:o}}catch{}if(a==="callout"){const r=(s[0]??"").toLowerCase(),n=es.includes(r);return{type:"callout",kind:n?r:"note",title:(n?s.slice(1):s).join(" "),text:o.trim()}}return{type:"code",lang:a||"code",text:o}}function Ft(l){const o=l.split(`
2439
+ `).filter(s=>s.trim()),e=o.map(s=>s.trim());if(e.length>1&&e.every(s=>Yt.test(s))){const s=c=>c.replace(/^\||\|$/g,"").split("|").map(f=>f.trim()),a=e.findIndex(c=>wt.test(c)),r=a>-1?s(e[a]).map(c=>/^:-+:$/.test(c)?"center":/^-+:$/.test(c)?"right":/^:-+$/.test(c)?"left":null):[],n=e.filter(c=>!wt.test(c)).map(s),h=n[0]??[];return[{type:"table",head:h,rows:n.slice(1),align:h.map((c,f)=>r[f]??null)}]}if(e.length===1&&Qt.test(e[0]))return[{type:"hr"}];if(e.every(s=>kt.test(s)))return[{type:"img",images:e.map(s=>{const a=s.match(kt);return{alt:a[1],src:a[2]}})}];if(e.every(s=>s.startsWith(">"))){const s=e.map(r=>r.replace(/^>\s?/,"")),a=s[0].match(Zt);return a?[{type:"callout",kind:a[1].toLowerCase(),title:a[2].trim(),text:s.slice(1).join(`
2440
+ `).trim()}]:[{type:"quote",text:s.join(" ")}]}if($t.test(o[0])){const s=[];for(const a of o){const r=a.match($t);if(r){const n=r[3].match(Ct);s.push({text:n?r[3].replace(Ct,""):r[3],depth:Math.min(3,Math.floor(r[1].replace(/\t/g," ").length/2)),checked:n?n[1]!==" ":null})}else s[s.length-1].text+=` ${a.trim()}`}return[{type:"list",ordered:/^\s*\d/.test(o[0]),items:s}]}const t=e[0].match(/^(#{1,4})\s+(.*)$/);if(t){const s=o.slice(1).join(`
2441
+ `);return[{type:"h",level:t[1].length,text:t[2]},...s?Ft(s):[]]}return[{type:"p",text:e.join(" ")}]}function ss(l,o=","){var h;const e=[];let t=[],s="",a=!1;const r=l.replace(/\r/g,"");for(let c=0;c<r.length;c++){const f=r[c];a?f==='"'&&r[c+1]==='"'?(s+='"',c++):f==='"'?a=!1:s+=f:f==='"'&&s===""?a=!0:f===o?(t.push(s.trim()),s=""):f===`
2442
+ `?(t.push(s.trim()),t.some(Boolean)&&e.push(t),t=[],s=""):s+=f}t.push(s.trim()),t.some(Boolean)&&e.push(t);const n=((h=e[0])==null?void 0:h.length)??0;return e.map(c=>c.length<n?[...c,...Array(n-c.length).fill("")]:c)}function is(l){let o;try{o=JSON.parse(l)}catch{return null}if(!o||typeof o!="object")return null;const e=(Array.isArray(o.series)?o.series:[]).filter(s=>s&&Array.isArray(s.values)).map((s,a)=>({name:String(s.name??`Series ${a+1}`),values:s.values.map(r=>Number(r)||0)}));if(!e.length)return null;const t=Array.isArray(o.labels)?o.labels.map(String):e[0].values.map((s,a)=>String(a+1));return{type:o.type==="line"?"line":"bar",title:String(o.title??""),unit:String(o.unit??""),labels:t,series:e}}const St=new RegExp([/\*\*([^*]+)\*\*/.source,/~~([^~]+)~~/.source,/`([^`]+)`/.source,/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/.source,/(https?:\/\/[^\s<>()]*[^\s<>().,;:!?'"\]])/.source,new RegExp("(?<![\\w*])\\*(?![\\s*])([^*\\n]+?)\\*(?![\\w*])").source,new RegExp("(?<![\\w_])_(?![\\s_])([^_\\n]+?)_(?![\\w_])").source,/\s?\[(\d+(?:\s*,\s*\d+)*)\]/.source].join("|"),"g");function Kt(l,o=0){const e=[];let t=0,s;St.lastIndex=0;const a=r=>{if(!r)return;const n=e[e.length-1];(n==null?void 0:n.type)==="text"?n.text+=r:e.push({type:"text",text:r})};for(;s=St.exec(l);){if(a(l.slice(t,s.index)),s[1]!==void 0)e.push({type:"bold",text:s[1]});else if(s[2]!==void 0)e.push({type:"strike",text:s[2]});else if(s[3]!==void 0)e.push({type:"code",text:s[3]});else if(s[4]!==void 0)e.push({type:"link",text:s[4],href:s[5]});else if(s[6]!==void 0)e.push({type:"link",text:s[6],href:s[6]});else if(s[7]!==void 0)e.push({type:"italic",text:s[7]});else if(s[8]!==void 0)e.push({type:"italic",text:s[8]});else{const n=s[9].split(",").map(h=>Number(h.trim())).filter(h=>h>=1&&h<=o);o?n.forEach(h=>e.push({type:"cite",n:h})):a(s[0])}t=s.index+s[0].length}return a(l.slice(t)),e}function Pt(l){if(((l??"").match(/```/g)??[]).length%2===1)return l;const o=l.lastIndexOf(`
2443
+
2444
+ `),e=o>-1?l.slice(0,o+2):"";let t=o>-1?l.slice(o+2):l;const s=t.split(`
2445
+ `),a=s[s.length-1];a.trimStart().startsWith("|")&&!a.trimEnd().endsWith("|")&&s.pop(),t=s.join(`
2446
+ `),t=t.replace(/!?\[[^\]\n]*(\]\([^)\n]*)?$/,"");for(const r of["**","~~","`"])if((t.split(r).length-1)%2===1){const h=t.lastIndexOf(r);t=t.slice(0,h)+t.slice(h+r.length)}return e+t}function bt(l){const o=new Set;for(const e of(l??"").match(/\[(\d+(?:\s*,\s*\d+)*)\]/g)??[])e.replace(/[[\]]/g,"").split(",").forEach(t=>o.add(Number(t.trim())));return o}function as(l){return[["",...l.series.map(o=>o.name)],...l.labels.map((o,e)=>[o,...l.series.map(t=>t.values[e]===void 0?"":`${t.values[e]}${l.unit}`)])]}const Tt=l=>l.map(o=>o.join(" · ")).join(`
2447
+ `),rs={note:"Note",tip:"Tip",important:"Important",warning:"Warning",caution:"Caution"};function Ut(l,o){if(o==="rich")return l;const e=o==="plain";return l.map(t=>{switch(t.type){case"chart":{const[s,...a]=as(t.spec);return e?{type:"raw",text:[t.spec.title,Tt([s,...a])].filter(Boolean).join(`
2448
+ `)}:{type:"table",head:t.spec.title?[t.spec.title,...s.slice(1)]:s,rows:a,align:s.map(()=>null)}}case"pending":return t.kind==="svg"&&!e?t:{type:"raw",text:""};case"callout":return{type:"quote",text:`**${t.title||rs[t.kind]}** ${t.text}`.trim()};case"img":return{type:"p",text:t.images.map(s=>`Image: ${s.alt||"untitled"}`).join(" · ")};case"table":return e?{type:"raw",text:Tt([t.head,...t.rows])}:t;case"json":return e?{type:"code",lang:"json",text:t.source}:t;case"svg":return e?{type:"code",lang:"svg",text:t.source}:t;default:return t}})}function ft(l){const o=l??"",e=o.search(/FOLLOWUPS:/i);if(e<0)return{text:o.trim(),followups:[]};const s=o.slice(e).replace(/^FOLLOWUPS:/i,"").split(/\||\n/).map(a=>a.replace(/^\s*(?:[-*↳→]|\d+[.)])\s*/,"").trim()).filter(Boolean).slice(0,3);return{text:o.slice(0,e).trim(),followups:s}}function ns(l){return(l??"").replace(/```(\w*)[\s\S]*?(```|$)/g,(o,e)=>e==="chart"?"[Chart] ":e==="svg"?"[Drawing] ":"[Code] ").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()}function os(l,o=48){const e=ns(l);if(e.length<=o)return e;const t=e.slice(0,o),s=t.lastIndexOf(" ");return(s>o/2?t.slice(0,s):t).trim()}function ls(l){return String(l??"").split(`
2449
+ `)[0].trim().replace(/^["'“”‘’]+|["'“”‘’]+$/g,"").replace(/^title:\s*/i,"").replace(/[.!?:;,]+$/,"").trim().slice(0,80)}function It(l,o=!1){return/^https?:\/\//i.test(l)?!0:o&&/^(blob:|data:image\/)/i.test(l)}const cs=2e5,hs=new Set(["script","foreignobject","iframe","object","embed","image","audio","video","animate","set","animatemotion","animatetransform","handler","listener"]);function Wt(l){if(!l||l.length>cs||typeof DOMParser>"u")return null;const o=new DOMParser().parseFromString(l,"image/svg+xml"),e=o.documentElement;if(!e||e.nodeName.toLowerCase()!=="svg"||o.querySelector("parsererror"))return null;const t=a=>{for(const r of Array.from(a.children)){const n=r.nodeName.toLowerCase();if(hs.has(n))r.remove();else if(n==="a"){const h=Array.from(r.childNodes);r.replaceWith(...h),h.forEach(c=>c instanceof Element&&t(c))}else t(r)}for(const r of Array.from(a.attributes)){const n=r.name.toLowerCase(),h=r.value.trim().toLowerCase(),c=(n==="href"||n.endsWith(":href"))&&!h.startsWith("#"),f=h.includes("javascript:")||/url\(\s*['"]?(?!#)/.test(h);(n.startsWith("on")||c||f)&&a.removeAttribute(r.name)}};t(e);for(const a of Array.from(e.querySelectorAll("style")))a.textContent=(a.textContent??"").replace(/@import[^;]*;?/gi,"").replace(/url\(\s*['"]?(?!#)[^)]*\)/gi,"none");e.setAttribute("xmlns","http://www.w3.org/2000/svg");const s=new XMLSerializer().serializeToString(e);return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`}var Ht=Object.defineProperty,ds=Object.getOwnPropertyDescriptor,ps=(l,o,e)=>o in l?Ht(l,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[o]=e,m=(l,o,e,t)=>{for(var s=t>1?void 0:t?ds(o,e):o,a=l.length-1,r;a>=0;a--)(r=l[a])&&(s=(t?r(o,e,s):r(s))||s);return t&&s&&Ht(o,e,s),s},us=(l,o,e)=>ps(l,o+"",e);const Mt=["embed","mode","format","renderers","beforeSend","afterParse","glow","position","sidebar","showTitle","assistantName","logoUrl","heading","description","eyebrow","prompts","bubbleText","greetingBubble","unreadBadge","allowUpload","allowExport","allowRaw","allowCopy","allowRegenerate","allowBookmark","allowDelete","allowRename","allowFeedback","showTime","showComposer","footnote","branding","followups","docsets","attachmentsMode","saveAttachments","showFollowups","showSources","showNewChat","showBookmarked","allowSearch","autoTitle","model","params","systemMessage","retrieval","metadata","messages","theme","radius"],vt={fromAttribute:l=>{if(l)try{return JSON.parse(l)}catch{console.warn("[singlebase-chat] an attribute holds invalid JSON; ignoring it");return}},toAttribute:l=>JSON.stringify(l??null)},S={fromAttribute:l=>l===null?!0:l!=="false",toAttribute:l=>l?null:"false"},gs={fromAttribute:l=>l===null?"auto":l===""||l==="true"?"open":l==="false"?"closed":["auto","open","closed","none"].includes(l)?l:"auto",toAttribute:l=>l==="auto"?null:l},ms=272,bs=820,fs=940,Ot=5,zt=512*1024,vs=/\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i,xs=5e3,ys=200,_t=2e3,ws={note:"calloutNote",tip:"calloutTip",important:"calloutImportant",warning:"calloutWarning",caution:"calloutCaution"},ks=2600,_=["var(--c-ink)","oklch(0.58 0.13 255)","oklch(0.63 0.1 175)","oklch(0.74 0.12 70)"],Lt={chat:"Be helpful and concise. Use Markdown when it helps: headings, lists, **bold**, code blocks and tables.",rag:"Prefer the sources provided with each message, numbered in the order given, and put a citation like [1] right after each claim they support. If they don't cover the question, you may answer from general knowledge, but say clearly that it isn't from the sources.",kb:"Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim. Do not use outside knowledge. If the sources don't contain the answer, say that you can't find it in the available sources."},$s={raw:"Reply in plain text. Don't use Markdown or any other markup.",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.",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.`,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://…).'},Cs="After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.",jt={chat:[["Write","Draft a short welcome email for new users"],["Explain","Explain how refresh tokens work, simply"],["Code","Write a JavaScript debounce function"],["Plan","Outline a one-week plan to learn TypeScript"]],rag:[["Overview","What topics do these sources cover?"],["Summarize","Summarize the most important points"],["Find","Where is the refund policy described?"],["Explain","Explain the setup steps in plain language"]],kb:[["Find","Where is the refund policy described?"],["How to","How do I reset my password?"],["Limits","What are the plan limits?"],["Policy","What happens when my account is deleted?"]]},M=(l,o="")=>i.html`<svg class="i ${o}" viewBox="0 0 16 16" aria-hidden="true">${l}</svg>`,y={sidebar:()=>M(i.svg`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`),plus:()=>M(i.svg`<path d="M8 3v10M3 8h10"></path>`),bookmark:(l=!1)=>M(i.svg`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`,l?"filled":""),download:()=>M(i.svg`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),trash:()=>M(i.svg`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),pencil:()=>M(i.svg`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),copy:()=>M(i.svg`<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>`),raw:()=>M(i.svg`<path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5"></path>`),refresh:()=>M(i.svg`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),thumb:(l=!1)=>i.html`<svg
2450
+ class="i"
2451
+ viewBox="0 0 16 16"
2452
+ aria-hidden="true"
2453
+ style=${l?"transform:rotate(180deg)":""}
2454
+ >
2455
+ <path
2456
+ 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"
2457
+ ></path>
2458
+ </svg>`,expand:()=>M(i.svg`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),restore:()=>M(i.svg`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),minimize:()=>M(i.svg`<path d="M4 8h8"></path>`),close:()=>M(i.svg`<path d="M4 4l8 8M12 4l-8 8"></path>`),clip:()=>M(i.svg`<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>`),up:()=>M(i.svg`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),stop:()=>M(i.svg`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),chat:()=>i.html`<svg
2459
+ width="22"
2460
+ height="22"
2461
+ viewBox="0 0 22 22"
2462
+ aria-hidden="true"
2463
+ style="fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round"
2464
+ >
2465
+ <path
2466
+ 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"
2467
+ ></path>
2468
+ </svg>`,chevronDown:()=>i.html`<svg
2469
+ width="20"
2470
+ height="20"
2471
+ viewBox="0 0 20 20"
2472
+ aria-hidden="true"
2473
+ style="fill:none;stroke:currentColor;stroke-width:1.6;stroke-linecap:round"
2474
+ >
2475
+ <path d="M5 8l5 5 5-5"></path>
2476
+ </svg>`};let Ss=0;const gt=()=>`m${Date.now().toString(36)}${(Ss++).toString(36)}`;function At(l){var e;const o=l;return(o==null?void 0:o.message)==="NOT_FOUND"||(o==null?void 0:o.code)==="NOT_FOUND"||((e=o==null?void 0:o.details)==null?void 0:e.status)===404}function Ts(l){const o=l;return(o==null?void 0:o.code)||(o==null?void 0:o.message)||"UNKNOWN"}const Is=()=>typeof matchMedia<"u"&&matchMedia("(prefers-reduced-motion: reduce)").matches,ut=(l,o)=>(Number.isInteger(l)?l.toLocaleString("en-US"):l.toFixed(1))+o,mt=l=>{const o=l.lastIndexOf(".");return o>0?l.slice(o+1,o+5).toUpperCase():"FILE"};function L(l,o){const e=l??{},t=e.metadata&&typeof e.metadata=="object"?e.metadata:{},s=(...h)=>h.find(c=>typeof c=="string"&&c.trim()),a=s(e.content,e.text,e.page_content,e.body,e.snippet,e.chunk,t.content)??JSON.stringify(e,null,2),r=[e.score,e.relevance,e._score,t.score].find(h=>typeof h=="number"),n=typeof e.n=="number"&&e.n>0?e.n:o;return{n,title:s(e.title,e.name,e.filename,t.title,t.name)??`Source ${n}`,section:s(e.section,e.heading,t.section)??"",path:s(e.path,e.url,e.key,t.path,t.url)??"",collection:s(e.collection,e.namespace,e.dbname,t.collection)??"",updated:s(e.updated,e._modified_at,t.updated)??"",text:a,score:r===void 0?null:Math.max(0,Math.min(1,r))}}function Nt(l){return Array.isArray(l)?l.filter(o=>o&&typeof o=="object"&&(o._id||o.id)).filter(o=>o.saved!==!1&&o.status!=="failed").map(o=>({id:String(o._id??o.id),name:String(o.name??"file"),type:o.type,mime:o.mime,size:typeof o.size=="number"?o.size:void 0,status:o.status})):[]}function Ms(l){const o=[],e=[];for(const t of l)if(/\.csv$/i.test(t.name))o.push({type:"csv",data:t.content});else if(/\.json$/i.test(t.name))try{o.push({type:"json",data:JSON.parse(t.content)})}catch{e.push({title:t.name,content:t.content})}else e.push({title:t.name,content:t.content});return e.length&&o.push({type:"docs",payload:{documents:e}}),o}function Os(l){const o=l?Date.parse(l):NaN;if(Number.isNaN(o))return"older";const e=new Date;e.setHours(0,0,0,0);const t=864e5;return o>=e.getTime()?"today":o>=e.getTime()-t?"yesterday":o>=e.getTime()-7*t?"week":"older"}var j,A,N,R,E,B,D,F,K,P,U,W,H,J,q,G,V,X,Y,Q,Z,ee,te,se,ie,ae,re,ne,oe,le,ce,he,de,pe,ue,ge,me,be,fe,ve,xe,ye,we,ke,$e,Ce,Se,Te,Ie,Me,Oe,ze,_e,Le,je,Ae,Ne,Re,Ee,Be,De,Fe,Ke,Pe,Ue,We,He,Je,qe,Ge,Ve,Xe,Ye,Qe,Ze,et,tt,st,it,at,rt,nt,ot,lt,ct,ht,dt,pt,Rt;exports.SinglebaseChat=(Rt=class extends i.LitElement{constructor(){super(...arguments);p(this,j,null);p(this,A,{});p(this,N);p(this,R);p(this,E,"chat");p(this,B,"advanced");p(this,D,{});p(this,F,null);p(this,K,null);p(this,P,"subtle");p(this,U,"");p(this,W,"retrieval");p(this,H,!0);p(this,J,!0);p(this,q,!0);p(this,G,!0);p(this,V,!0);p(this,X,!0);p(this,Y,!0);p(this,Q,!0);p(this,Z,"");p(this,ee,{});p(this,te,"");p(this,se,[]);p(this,ie,{});p(this,ae,"page");p(this,re,"right");p(this,ne,"auto");p(this,oe,!0);p(this,le,"");p(this,ce,"Assistant");p(this,he,"");p(this,de,"");p(this,pe,"");p(this,ue);p(this,ge,"");p(this,me,"");p(this,be,!1);p(this,fe,!1);p(this,ve,!0);p(this,xe,!0);p(this,ye,!0);p(this,we,!0);p(this,ke,!0);p(this,$e,!0);p(this,Ce,!0);p(this,Se,!0);p(this,Te,!0);p(this,Ie,!0);p(this,Me);p(this,Oe,!1);p(this,ze,!0);p(this,_e,[]);p(this,Le,"idle");p(this,je,null);p(this,Ae,"");p(this,Ne,!1);p(this,Re,[]);p(this,Ee,!1);p(this,Be,"");p(this,De,!1);p(this,Fe,"");p(this,Ke,[]);p(this,Pe,"");p(this,Ue,null);p(this,We,0);p(this,He,null);p(this,Je,!1);p(this,qe,"");p(this,Ge,"");p(this,Ve,!1);p(this,Xe,"");p(this,Ye,null);p(this,Qe,"");p(this,Ze,new Set);p(this,et,new Set);p(this,tt,[]);p(this,st,!1);p(this,it,new Map);p(this,at,"");p(this,rt,!1);p(this,nt,!1);p(this,ot,!1);p(this,lt,!1);p(this,ct,!1);p(this,ht,!1);p(this,dt,!1);p(this,pt,!1);I(this,"run",0);I(this,"abort",null);I(this,"revealTimer");I(this,"timers",new Set);I(this,"toastTimer");I(this,"stick",!0);I(this,"renamed",new Set);I(this,"observer",null);I(this,"observed",null);I(this,"media",null);I(this,"focusNext","");I(this,"bubbleScheduled",!1);I(this,"pendingChatId","");I(this,"onNetwork",()=>{this.offline=navigator.onLine===!1});I(this,"onMedia",()=>{var e;this.mobile=!!((e=this.media)!=null&&e.matches)})}get client(){return d(this,j)}set client(e){u(this,j,e)}get messages(){return d(this,A)}set messages(e){u(this,A,e)}get theme(){return d(this,N)}set theme(e){u(this,N,e)}get radius(){return d(this,R)}set radius(e){u(this,R,e)}get mode(){return d(this,E)}set mode(e){u(this,E,e)}get format(){return d(this,B)}set format(e){u(this,B,e)}get renderers(){return d(this,D)}set renderers(e){u(this,D,e)}get beforeSend(){return d(this,F)}set beforeSend(e){u(this,F,e)}get afterParse(){return d(this,K)}set afterParse(e){u(this,K,e)}get glow(){return d(this,P)}set glow(e){u(this,P,e)}get docsets(){return d(this,U)}set docsets(e){u(this,U,e)}get attachmentsMode(){return d(this,W)}set attachmentsMode(e){u(this,W,e)}get saveAttachments(){return d(this,H)}set saveAttachments(e){u(this,H,e)}get followups(){return d(this,J)}set followups(e){u(this,J,e)}get showSources(){return d(this,q)}set showSources(e){u(this,q,e)}get showNewChat(){return d(this,G)}set showNewChat(e){u(this,G,e)}get showBookmarked(){return d(this,V)}set showBookmarked(e){u(this,V,e)}get showFollowups(){return d(this,X)}set showFollowups(e){u(this,X,e)}get allowSearch(){return d(this,Y)}set allowSearch(e){u(this,Y,e)}get autoTitle(){return d(this,Q)}set autoTitle(e){u(this,Q,e)}get model(){return d(this,Z)}set model(e){u(this,Z,e)}get params(){return d(this,ee)}set params(e){u(this,ee,e)}get systemMessage(){return d(this,te)}set systemMessage(e){u(this,te,e)}get retrieval(){return d(this,se)}set retrieval(e){u(this,se,e)}get metadata(){return d(this,ie)}set metadata(e){u(this,ie,e)}get embed(){return d(this,ae)}set embed(e){u(this,ae,e)}get position(){return d(this,re)}set position(e){u(this,re,e)}get sidebar(){return d(this,ne)}set sidebar(e){u(this,ne,e)}get showTitle(){return d(this,oe)}set showTitle(e){u(this,oe,e)}get chatIdAttr(){return d(this,le)}set chatIdAttr(e){u(this,le,e)}get assistantName(){return d(this,ce)}set assistantName(e){u(this,ce,e)}get logoUrl(){return d(this,he)}set logoUrl(e){u(this,he,e)}get heading(){return d(this,de)}set heading(e){u(this,de,e)}get description(){return d(this,pe)}set description(e){u(this,pe,e)}get eyebrow(){return d(this,ue)}set eyebrow(e){u(this,ue,e)}get prompts(){return d(this,ge)}set prompts(e){u(this,ge,e)}get bubbleText(){return d(this,me)}set bubbleText(e){u(this,me,e)}get greetingBubble(){return d(this,be)}set greetingBubble(e){u(this,be,e)}get unreadBadge(){return d(this,fe)}set unreadBadge(e){u(this,fe,e)}get allowUpload(){return d(this,ve)}set allowUpload(e){u(this,ve,e)}get allowExport(){return d(this,xe)}set allowExport(e){u(this,xe,e)}get allowCopy(){return d(this,ye)}set allowCopy(e){u(this,ye,e)}get allowRegenerate(){return d(this,we)}set allowRegenerate(e){u(this,we,e)}get allowBookmark(){return d(this,ke)}set allowBookmark(e){u(this,ke,e)}get allowDelete(){return d(this,$e)}set allowDelete(e){u(this,$e,e)}get allowRename(){return d(this,Ce)}set allowRename(e){u(this,Ce,e)}get allowFeedback(){return d(this,Se)}set allowFeedback(e){u(this,Se,e)}get showComposer(){return d(this,Te)}set showComposer(e){u(this,Te,e)}get showTime(){return d(this,Ie)}set showTime(e){u(this,Ie,e)}get footnote(){return d(this,Me)}set footnote(e){u(this,Me,e)}get allowRaw(){return d(this,Oe)}set allowRaw(e){u(this,Oe,e)}get branding(){return d(this,ze)}set branding(e){u(this,ze,e)}get chatList(){return d(this,_e)}set chatList(e){u(this,_e,e)}get listState(){return d(this,Le)}set listState(e){u(this,Le,e)}get activeId(){return d(this,je)}set activeId(e){u(this,je,e)}get chatTitle(){return d(this,Ae)}set chatTitle(e){u(this,Ae,e)}get bookmarked(){return d(this,Ne)}set bookmarked(e){u(this,Ne,e)}get msgs(){return d(this,Re)}set msgs(e){u(this,Re,e)}get loadingThread(){return d(this,Ee)}set loadingThread(e){u(this,Ee,e)}get threadError(){return d(this,Be)}set threadError(e){u(this,Be,e)}get busy(){return d(this,De)}set busy(e){u(this,De,e)}get draft(){return d(this,Fe)}set draft(e){u(this,Fe,e)}get files(){return d(this,Ke)}set files(e){u(this,Ke,e)}get search(){return d(this,Pe)}set search(e){u(this,Pe,e)}get sidebarOpen(){return d(this,Ue)}set sidebarOpen(e){u(this,Ue,e)}get width(){return d(this,We)}set width(e){u(this,We,e)}get panel(){return d(this,He)}set panel(e){u(this,He,e)}get menuOpen(){return d(this,Je)}set menuOpen(e){u(this,Je,e)}get editingKey(){return d(this,qe)}set editingKey(e){u(this,qe,e)}get editDraft(){return d(this,Ge)}set editDraft(e){u(this,Ge,e)}get editingTitle(){return d(this,Ve)}set editingTitle(e){u(this,Ve,e)}get renamingId(){return d(this,Xe)}set renamingId(e){u(this,Xe,e)}get toast(){return d(this,Ye)}set toast(e){u(this,Ye,e)}get copiedKey(){return d(this,Qe)}set copiedKey(e){u(this,Qe,e)}get retrievalOpen(){return d(this,Ze)}set retrievalOpen(e){u(this,Ze,e)}get rawKeys(){return d(this,et)}set rawKeys(e){u(this,et,e)}get savedFiles(){return d(this,tt)}set savedFiles(e){u(this,tt,e)}get hasSidebarContent(){return d(this,st)}set hasSidebarContent(e){u(this,st,e)}get sorts(){return d(this,it)}set sorts(e){u(this,it,e)}get arrivedKey(){return d(this,at)}set arrivedKey(e){u(this,at,e)}get dragging(){return d(this,rt)}set dragging(e){u(this,rt,e)}get showJump(){return d(this,nt)}set showJump(e){u(this,nt,e)}get offline(){return d(this,ot)}set offline(e){u(this,ot,e)}get isOpen(){return d(this,lt)}set isOpen(e){u(this,lt,e)}get expanded(){return d(this,ct)}set expanded(e){u(this,ct,e)}get bubble(){return d(this,ht)}set bubble(e){u(this,ht,e)}get seen(){return d(this,dt)}set seen(e){u(this,dt,e)}get mobile(){return d(this,pt)}set mobile(e){u(this,pt,e)}get msg(){return Bt(this.messages)}get resolvedClient(){return this.client??Vt.getDefaultClient()??null}get chatId(){return this.activeId}get thread(){return this.msgs}get docsetIds(){const e=this.docsets,t=Array.isArray(e)?e:String(e??"").split(/[\s,]+/);return[...new Set(t.map(s=>String(s).trim()).filter(Boolean))]}get attachments(){return this.savedFiles}get formatLevel(){return["raw","plain","advanced","rich"].includes(this.format)?this.format:"advanced"}get chats(){return this.chatList}set config(e){if(!e)return;const t=this;"client"in e&&(this.client=e.client??null);for(const s of Mt)s in e&&(t[s]=e[s]);e.chatId&&e.chatId!==this.activeId&&(this.hasUpdated?this.openChat(e.chatId):this.chatIdAttr=e.chatId)}configure(e){return this.config=e,this}get config(){const e=this;return{client:this.client,chatId:this.activeId??"",...Object.fromEntries(Mt.map(t=>[t,e[t]]))}}connectedCallback(){var e,t;super.connectedCallback(),this.offline=typeof navigator<"u"&&navigator.onLine===!1,window.addEventListener("online",this.onNetwork),window.addEventListener("offline",this.onNetwork),this.media=typeof matchMedia<"u"?matchMedia("(max-width: 559px)"):null,this.mobile=!!((e=this.media)!=null&&e.matches),(t=this.media)==null||t.addEventListener("change",this.onMedia)}disconnectedCallback(){var e,t;super.disconnectedCallback(),window.removeEventListener("online",this.onNetwork),window.removeEventListener("offline",this.onNetwork),(e=this.media)==null||e.removeEventListener("change",this.onMedia),(t=this.observer)==null||t.disconnect(),this.observer=null,this.observed=null,this.flushToast(),this.halt(),this.timers.forEach(clearTimeout),this.timers.clear()}willUpdate(e){if(e.has("retrieval")&&!Array.isArray(this.retrieval)){const t=this.retrieval;this.retrieval=t&&typeof t=="object"?[t]:[]}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(()=>{!this.isOpen&&!this.seen&&(this.bubble=!0)},1200))}firstUpdated(){this.chatIdAttr&&this.openChat(this.chatIdAttr)}updated(){var t;const e=this.renderRoot.querySelector(".root");if(e!==this.observed&&((t=this.observer)==null||t.disconnect(),this.observed=e,e&&typeof ResizeObserver<"u"&&(this.observer??(this.observer=new ResizeObserver(([s])=>{const a=Math.round(s.contentRect.width);a!==this.width&&(this.width=a,this.sidebarOpen===null&&(this.sidebarOpen=this.sidebar==="auto"&&this.docked))})),this.observer.observe(e))),this.sidebarOpen&&this.listState==="idle"&&this.resolvedClient&&this.loadChats(),this.pendingChatId&&this.resolvedClient&&this.openChat(this.pendingChatId),this.focusNext){const s=this.renderRoot.querySelector(this.focusNext);this.focusNext="",s&&(s.focus(),"select"in s&&s.tagName==="INPUT"&&s.select())}}later(e,t){const s=setTimeout(()=>{this.timers.delete(s),e()},t);this.timers.add(s)}emit(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}get docked(){return this.embed==="page"&&this.width>=bs}get panelDocked(){const e=this.docked&&this.sidebarOpen?ms:0;return this.width-e>=fs}newChat(){this.halt(),this.pendingChatId="",this.savedFiles=[],this.loadingThread=!1,this.activeId=null,this.chatTitle="",this.bookmarked=!1,this.msgs=[],this.threadError="",this.resetViewState(),this.focusNext="textarea.input"}async openChat(e){const t=this.resolvedClient;if(!e)return;this.halt(),this.savedFiles=[];const s=this.chatList.find(r=>r._id===e);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){this.pendingChatId=e,this.loadingThread=!0;return}const a=++this.run;this.pendingChatId="",this.loadingThread=!0;try{const r=await t.llm.call("get_chat",{_id:e});if(a!==this.run)return;this.chatTitle=(r==null?void 0:r.title)??"",this.bookmarked=!!(r!=null&&r.bookmarked),this.msgs=((r==null?void 0:r.messages)??[]).filter(n=>n&&(n.role==="user"||n.role==="assistant")).map(n=>this.fromServer(n)),this.savedFiles=Nt(r==null?void 0:r.attachments),this.upsertChat({...s,...r,_id:e}),this.stick=!0,this.scrollToBottom()}catch(r){if(a!==this.run)return;At(r)?(this.chatList=this.chatList.filter(n=>n._id!==e),this.newChat(),this.showToast(this.msg.errNotFound)):this.threadError=this.msg.errLoad}finally{a===this.run&&(this.loadingThread=!1)}}async send(e){const t=(typeof e=="string"?e:this.draft).trim();if(!t||this.busy)return;const s=this.files;this.draft="",this.files=[];const a=this.renderRoot.querySelector("textarea.input");a&&(a.style.height="auto"),await this.runTurn(this.userMessage(t,s))}stop(){if(!this.busy)return;const e=this.msgs[this.msgs.length-1];this.halt(),(e==null?void 0:e.role)==="assistant"&&(e.phase==="pending"||e.phase==="streaming")&&(e.phase="done",e.stopped=!0,e.followups=[],this.msgs=[...this.msgs])}exportChat(e="md"){var O;if(!this.msgs.length)return;this.menuOpen=!1;const t=this.chatTitle||this.msg.untitled,s=v=>v.role==="user"?this.msg.you:this.assistantName,a=v=>new Date(v||Date.now()).toLocaleString(),r=v=>v.sources.map((C,k)=>{const z=L(C,k+1);return`[${z.n}] ${z.title}${z.path?` — ${z.path}`:""}`}),n=v=>(v.attachments??[]).map(C=>C.name);let h,c="text/markdown",f="md";if(e==="json"?(h=JSON.stringify({exportedAt:new Date().toISOString(),id:this.activeId,title:t,mode:this.mode,bookmarked:this.bookmarked,messages:this.msgs.map(v=>({role:v.role,text:v.content,at:new Date(v.at||Date.now()).toISOString(),bookmarked:v.bookmarked,attachments:n(v),sources:r(v)}))},null,2),c="application/json",f="json"):e==="txt"?(h=`${t}
2477
+ ${"=".repeat(t.length)}
2478
+
2479
+ `+this.msgs.map(v=>[`${s(v)} · ${a(v.at)}`,n(v).length?`Attachments: ${n(v).join(", ")}`:"",v.content,r(v).length?`Sources:
2480
+ ${r(v).join(`
2481
+ `)}`:""].filter(Boolean).join(`
2482
+ `)).join(`
2483
+
2484
+ `),c="text/plain",f="txt"):h=`# ${t}
2485
+
2486
+ `+this.msgs.map(v=>[`### ${s(v)} · ${a(v.at)}`,n(v).length?`Attachments: ${n(v).join(", ")}`:"",v.content,r(v).length?`**Sources**
2487
+
2488
+ ${r(v).map(C=>`- ${C}`).join(`
2489
+ `)}`:""].filter(Boolean).join(`
2490
+
2491
+ `)).join(`
2492
+
2493
+ ---
2494
+
2495
+ `)+`
2496
+ `,this.emit("singlebase-chat-export",{chatId:this.activeId,format:e}),e==="copy"){(O=navigator.clipboard)==null||O.writeText(h).catch(()=>{}),this.showToast(this.msg.copiedMarkdown);return}const w=`${t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")||"chat"}-${new Date().toISOString().slice(0,10)}.${f}`,$=URL.createObjectURL(new Blob([h],{type:c})),x=document.createElement("a");x.href=$,x.download=w,document.body.appendChild(x),x.click(),x.remove(),setTimeout(()=>URL.revokeObjectURL($),2e3),this.showToast(T.fill(this.msg.exported,{name:w}))}expand(){this.expanded=!0,this.emit("singlebase-chat-expand",{expanded:!0})}collapse(){this.expanded=!1,this.emit("singlebase-chat-expand",{expanded:!1})}open(){this.isOpen=!0,this.seen=!0,this.bubble=!1,this.focusNext="textarea.input",this.emit("singlebase-chat-open",{})}close(){this.isOpen=!1,this.expanded=!1,this.emit("singlebase-chat-close",{})}userMessage(e,t=[]){return{key:gt(),id:null,role:"user",content:e,at:Date.now(),bookmarked:!1,sources:[],followups:[],phase:"done",attachments:t}}systemPrompt(){return[this.systemMessage,Lt[this.mode]??Lt.chat,$s[this.formatLevel],this.followups?Cs:""].filter(Boolean).join(`
2497
+
2498
+ `)}payloadFor(e){const t={message:e.content,format:"markdown"};this.activeId?t._id=this.activeId:(t.title=os(e.content),t.system_message=this.systemPrompt()),t.mode=this.mode,this.model&&(t.model=this.model),Object.keys(this.params??{}).length&&(t.params=this.params);const s=e.attachments??[],a=this.attachmentsMode==="payload";a&&s.length&&(t.attachments=s.map(c=>({type:"content",content:c.content,name:c.name,...c.mime?{mime:c.mime}:{},size:c.size,save_attachment:this.saveAttachments})));const r=a?[]:s.map(c=>c.name);(Object.keys(this.metadata??{}).length||r.length)&&(t.metadata={...this.metadata,...r.length?{attachments:r}:{}});const n=this.docsetIds,h=[...n.length?[{source:"docset",ids:n}]:[],...this.retrieval??[],...a?[]:Ms(s)];return h.length&&(t.retrieval=h),t}async runTurn(e){const t={key:gt(),id:null,role:"assistant",content:"",at:Date.now(),bookmarked:!1,sources:[],followups:[],phase:"pending"};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});const s=this.resolvedClient;if(!s){this.failTurn(t,this.msg.errNoClient,"NO_CLIENT"),this.busy=!1;return}const a=++this.run,r=new AbortController;this.abort=r;const n=!this.activeId;let h=this.payloadFor(e);if(this.beforeSend){let c;try{c=await this.beforeSend(h,{chatId:this.activeId,isNew:n,message:e})}catch(b){c=b}if(a!==this.run)return;if(c===!1){this.msgs=this.msgs.filter(b=>b!==e&&b!==t),this.draft=e.content,this.busy=!1,this.abort=null;return}if(!(!!c&&typeof c=="object"&&typeof c.message=="string")||!c.message.trim()){console.error("[singlebase-chat] beforeSend must return the request object (with a message) or false to cancel; the message was not sent.",c),this.failTurn(t,this.msg.errGeneric,"BEFORE_SEND_INVALID"),this.busy=!1,this.abort=null;return}h=c}try{const c=await s.llm.call("chat",h,{signal:r.signal}),f=(c==null?void 0:c._id)||(c==null?void 0:c.chat_id)||this.activeId;if(n&&f&&this.upsertChat({_id:f,title:(c==null?void 0:c.title)||h.title,bookmarked:!!(c!=null&&c.bookmarked),_modified_at:new Date().toISOString()}),a!==this.run)return;f&&(this.activeId=f),n&&(this.chatTitle=(c==null?void 0:c.title)||h.title,this.bookmarked=!!(c!=null&&c.bookmarked));const b=(c==null?void 0:c.message)??{},w=typeof b.content=="string"?b.content:(c==null?void 0:c.json)!==void 0?JSON.stringify(c.json,null,2):"",{text:$,followups:x}=ft(w);e.id=b.reply_to??null,this.applyAttachmentResults(c==null?void 0:c.attachments),Object.assign(t,{id:b._id??null,content:$,sources:Array.isArray(b.sources)?b.sources:[],followups:x,execTime:typeof b.exec_time=="number"?b.exec_time:void 0,model:b.model,at:Date.now()}),this.emit("singlebase-chat-response",{chatId:f,message:t}),await this.reveal(t,a),n&&f&&this.autoTitle&&this.retitle(f,e.content,t.content)}catch(c){if(a!==this.run)return;const f=At(c);f&&(this.chatList=this.chatList.filter($=>$._id!==this.activeId),this.activeId=null);const b=Ts(c),w=f?this.msg.errNotFound:b==="KB_SOURCE_REQUIRED"?this.msg.errKbSource:this.msg.errGeneric;this.failTurn(t,w,b)}finally{a===this.run&&(this.busy=!1,this.abort=null,this.stick&&this.scrollToBottom())}}failTurn(e,t,s){e.phase="error",e.error=t,this.msgs=[...this.msgs],this.emit("singlebase-chat-error",{chatId:this.activeId,code:s,message:t})}reveal(e,t){const s=e.content.length,a=()=>{e.phase="done",this.msgs=[...this.msgs],this.arrivedKey=e.key,this.later(()=>{this.arrivedKey===e.key&&(this.arrivedKey="")},ks),this.stick?this.scrollToBottom():this.showJump=!0};if(!s||Is())return a(),Promise.resolve();const r=e.content,n=Math.max(4,Math.ceil(s/90));let h=0;return e.phase="streaming",e.content="",new Promise(c=>{this.revealTimer=setInterval(()=>{if(t!==this.run){clearInterval(this.revealTimer),c();return}if(h=Math.min(s,h+n),e.content=r.slice(0,h),h>=s){clearInterval(this.revealTimer),a(),c();return}this.msgs=[...this.msgs],this.stick&&this.scrollToBottom()},16)})}halt(){var e;this.run++,(e=this.abort)==null||e.abort(),this.abort=null,clearInterval(this.revealTimer),this.busy=!1}async retitle(e,t,s){const a=this.resolvedClient;if(!(!a||this.renamed.has(e)))try{const r=await a.llm.call("generate",{user_input:`user: ${t}
2499
+ assistant: ${s.slice(0,1500)}`,custom_instructions:"Write a concise title (3–6 words, sentence case, no quotes, no trailing punctuation) for this conversation.",format:"text"}),n=ls(r==null?void 0:r.result);if(!n||this.renamed.has(e))return;await a.llm.call("update_chat",{_id:e,title:n}),this.applyTitle(e,n,!0)}catch{}}applyTitle(e,t,s){this.chatList=this.chatList.map(a=>a._id===e?{...a,title:t}:a),this.activeId===e&&(this.chatTitle=t),this.emit("singlebase-chat-title",{chatId:e,title:t,auto:s})}commitTitle(e){this.editingTitle&&(this.editingTitle=!1,this.activeId&&this.renameChat(this.activeId,e))}commitRename(e,t){this.renamingId===e&&(this.renamingId="",this.renameChat(e,t))}async renameChat(e,t){var r,n;const s=t.trim().slice(0,80),a=((r=this.chatList.find(h=>h._id===e))==null?void 0:r.title)??this.chatTitle;if(!(!s||s===a)){this.renamed.add(e),this.applyTitle(e,s,!1);try{await((n=this.resolvedClient)==null?void 0:n.llm.call("update_chat",{_id:e,title:s}))}catch{this.applyTitle(e,a??"",!1),this.showToast(this.msg.errGeneric)}}}fromServer(e){const t=e.role==="assistant",{text:s,followups:a}=t?ft(String(e.content??"")):{text:String(e.content??""),followups:[]};return{key:gt(),id:e._id??null,role:t?"assistant":"user",content:s,at:Date.parse(e._created_at??"")||0,bookmarked:!!e.bookmarked,sources:Array.isArray(e.sources)?e.sources:[],followups:a,phase:"done",execTime:typeof e.exec_time=="number"?e.exec_time:void 0,model:e.model}}async loadChats(){const e=this.resolvedClient;if(e){this.listState="loading";try{const t=await e.llm.call("list_chats",{limit:100});this.chatList=[...(t==null?void 0:t.items)??[]],this.listState="ready"}catch{this.listState="error"}}}upsertChat(e){const t=this.chatList.findIndex(r=>r._id===e._id);if(t<0){this.chatList=[e,...this.chatList];return}const s=this.chatList[t],a=[...this.chatList];a[t]={...s,...e,_created_at:s._created_at??e._created_at,_modified_at:s._modified_at??e._modified_at},this.chatList=a}resetViewState(){this.panel=null,this.menuOpen=!1,this.editingKey="",this.editingTitle=!1,this.showJump=!1,this.retrievalOpen=new Set,this.sidebarOpen&&!this.docked&&(this.sidebarOpen=!1)}async deleteOnServer(e){const t=this.resolvedClient,s=this.activeId;if(!(!t||!s))for(const a of e)a&&await t.llm.call("delete_chat_message",{_id:s,message_id:a}).catch(()=>{})}async regenerate(){if(this.busy)return;const e=this.msgs.map(a=>a.role).lastIndexOf("assistant"),t=this.msgs[e-1];if(e<1||(t==null?void 0:t.role)!=="user")return;const s=this.msgs.slice(e-1);this.msgs=this.msgs.slice(0,e-1),await this.deleteOnServer(s.map(a=>a.id)),await this.runTurn(this.userMessage(t.content,t.attachments))}async retry(e){if(this.busy)return;const t=this.msgs.indexOf(e),s=this.msgs[t-1];(s==null?void 0:s.role)==="user"&&(this.msgs=this.msgs.slice(0,t-1),await this.runTurn(this.userMessage(s.content,s.attachments)))}async saveEdit(e){const t=this.editDraft.trim(),s=this.msgs.indexOf(e);if(this.editingKey="",!t||s<0||this.busy)return;const a=this.msgs.slice(s);this.msgs=this.msgs.slice(0,s),await this.deleteOnServer(a.map(r=>r.id)),await this.runTurn(this.userMessage(t,e.attachments))}toggleRaw(e){const t=new Set(this.rawKeys);t.has(e)?t.delete(e):t.add(e),this.rawKeys=t}applyAttachmentResults(e){if(!Array.isArray(e))return;const t=Nt(e).filter(a=>!this.savedFiles.some(r=>r.id===a.id));t.length&&(this.savedFiles=[...this.savedFiles,...t]);const s=e.filter(a=>(a==null?void 0:a.status)==="failed").map(a=>String(a.name??"file"));s.length&&this.showToast(T.fill(this.msg.attachmentFailed,{name:s.join(", ")}))}async removeSavedFile(e){var a;const t=this.activeId;if(!t)return;const s=this.savedFiles;this.savedFiles=s.filter(r=>r!==e);try{await((a=this.resolvedClient)==null?void 0:a.llm.call("remove_chat_attachment",{_id:t,attachment_id:e.id}))}catch{this.activeId===t&&(this.savedFiles=s),this.showToast(this.msg.errGeneric)}}copy(e,t){var s;(s=navigator.clipboard)==null||s.writeText(t).catch(()=>{}),this.copiedKey=e,this.later(()=>{this.copiedKey===e&&(this.copiedKey="")},1400)}async toggleMessageBookmark(e){var s;const t=this.activeId;if(!(!t||!e.id)){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});try{await((s=this.resolvedClient)==null?void 0:s.llm.call("bookmark_chat_message",{_id:t,message_id:e.id,bookmarked:e.bookmarked}))}catch{e.bookmarked=!e.bookmarked,this.msgs=[...this.msgs],this.showToast(this.msg.errGeneric)}}}async toggleChatBookmark(e){var r,n;const t=((r=this.chatList.find(h=>h._id===e))==null?void 0:r.bookmarked)??(e===this.activeId?this.bookmarked:!1),s=!t,a=h=>{this.chatList=this.chatList.map(c=>c._id===e?{...c,bookmarked:h}:c),e===this.activeId&&(this.bookmarked=h)};a(s),this.showToast(s?this.msg.chatBookmarked:this.msg.chatUnbookmarked),this.emit("singlebase-chat-bookmark",{chatId:e,bookmarked:s});try{await((n=this.resolvedClient)==null?void 0:n.llm.call("bookmark_chat",{_id:e,bookmarked:s}))}catch{a(t),this.showToast(this.msg.errGeneric)}}deleteMessage(e){var a;const t=this.activeId,s=this.msgs.indexOf(e);s<0||(this.msgs=this.msgs.filter(r=>r!==e),((a=this.panel)==null?void 0:a.key)===e.key&&(this.panel=null),this.showToast(this.msg.messageDeleted,{undo:()=>{if(this.activeId!==t)return;const r=[...this.msgs];r.splice(s,0,e),this.msgs=r},commit:()=>{var r;this.emit("singlebase-chat-message-delete",{chatId:t,messageId:e.id}),t&&e.id&&((r=this.resolvedClient)==null||r.llm.call("delete_chat_message",{_id:t,message_id:e.id}).catch(()=>{}))}}))}deleteChat(e){const t=this.chatList.findIndex(n=>n._id===e),s=this.chatList[t]??{_id:e,title:this.chatTitle,bookmarked:this.bookmarked},a=e===this.activeId,r=a?{title:this.chatTitle,bookmarked:this.bookmarked,msgs:this.msgs}:null;this.chatList=this.chatList.filter(n=>n._id!==e),a&&this.newChat(),this.showToast(this.msg.chatDeleted,{undo:()=>{const n=[...this.chatList];n.splice(Math.max(0,t),0,s),this.chatList=n,r&&!this.activeId&&!this.msgs.length&&(this.activeId=e,this.chatTitle=r.title,this.bookmarked=r.bookmarked,this.msgs=r.msgs)},commit:()=>{var n;this.emit("singlebase-chat-delete",{chatId:e}),(n=this.resolvedClient)==null||n.llm.call("delete_chat",{_id:e}).catch(()=>{})}})}feedback(e,t){e.feedback=t,this.msgs=[...this.msgs],this.emit("singlebase-chat-feedback",{chatId:this.activeId,messageId:e.id,value:t,text:e.content})}showToast(e,t={}){this.flushToast();const s={key:Date.now(),text:e,...t};this.toast=s,this.toastTimer=setTimeout(()=>{this.toast===s&&this.flushToast()},xs)}flushToast(){var t;const e=this.toast;clearTimeout(this.toastTimer),this.toast=null,(t=e==null?void 0:e.commit)==null||t.call(e)}undo(){var t;const e=this.toast;clearTimeout(this.toastTimer),this.toast=null,(t=e==null?void 0:e.undo)==null||t.call(e)}async addFiles(e){const t=Array.from(e??[]);if(!t.length)return;const s=[];for(const a of t){if(this.files.length+s.length>=Ot){this.showToast(T.fill(this.msg.tooManyFiles,{n:Ot}));break}if(!vs.test(a.name)&&!a.type.startsWith("text/")){this.showToast(T.fill(this.msg.fileType,{name:a.name}));continue}if(a.size>zt){this.showToast(T.fill(this.msg.fileTooLarge,{name:a.name,size:T.formatSize(zt)}));continue}s.push({name:a.name,size:a.size,content:await a.text(),...a.type?{mime:a.type}:{}})}s.length&&(this.files=[...this.files,...s],this.emit("singlebase-chat-files",{files:s.map(({name:a,size:r})=>({name:a,size:r}))}))}async scrollToBottom(){await this.updateComplete;const e=this.renderRoot.querySelector(".scroller");e&&(e.scrollTop=e.scrollHeight),this.showJump=!1}onScroll(e){const t=e.currentTarget;this.stick=t.scrollHeight-t.scrollTop-t.clientHeight<80,this.stick&&(this.showJump=!1)}jumpToLatest(){this.stick=!0,this.scrollToBottom()}onKeydown(e){if(e.key==="Escape"){if(this.menuOpen)this.menuOpen=!1;else if(this.panel)this.panel=null;else if(this.sidebarOpen&&!this.docked)this.sidebarOpen=!1;else if(this.expanded)this.collapse();else if(this.embed==="launcher"&&this.isOpen)this.close();else return;e.stopPropagation()}}onComposerKey(e){e.key==="Enter"&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),this.send())}onComposerInput(e){const t=e.target;t.style.height="auto",t.style.height=`${Math.min(176,t.scrollHeight)}px`,this.draft=t.value}onDragEnter(e){var t;!this.allowUpload||!this.showComposer||Array.from(((t=e.dataTransfer)==null?void 0:t.types)??[]).includes("Files")&&(e.preventDefault(),this.dragging=!0)}onDragLeave(e){e.currentTarget.contains(e.relatedTarget)||(this.dragging=!1)}onDrop(e){var t;e.preventDefault(),this.dragging=!1,this.allowUpload&&this.addFiles((t=e.dataTransfer)==null?void 0:t.files)}render(){if(this.embed==="launcher")return this.renderLauncher();const e=["frame",this.embed==="inline"?"inline boxed":"",this.expanded?"expanded boxed":""].join(" ");return i.html`<div class=${e} part="frame">${this.renderWorkspace()}</div>`}renderLauncher(){const e=this.msg,t=["frame launcher boxed",this.expanded?"expanded":"",this.mobile?"full":""].join(" "),s=this.isOpen?i.html`<div class=${t} role="dialog" aria-label=${this.assistantName} part="frame">
2500
+ ${this.renderWorkspace()}
2501
+ </div>`:i.nothing,a=this.bubble&&!this.isOpen?i.html`<div class="bubble" part="bubble">
2502
+ <button type="button" class="bubble-text" @click=${()=>this.open()}>
2503
+ ${this.bubbleText||e.bubbleText}
2504
+ </button>
2505
+ <button
2506
+ type="button"
2507
+ class="icon sm"
2508
+ aria-label=${e.dismiss}
2509
+ title=${e.dismiss}
2510
+ @click=${()=>this.bubble=!1}
2511
+ >
2512
+ ${y.close()}
2513
+ </button>
2514
+ </div>`:i.nothing,n=this.isOpen&&(this.expanded||this.mobile)?i.nothing:i.html`<button
2515
+ type="button"
2516
+ class="launcher-btn"
2517
+ part="launcher"
2518
+ aria-label=${this.isOpen?e.closeChat:e.openChat}
2519
+ aria-expanded=${this.isOpen?"true":"false"}
2520
+ @click=${()=>this.isOpen?this.close():this.open()}
2521
+ >
2522
+ ${this.isOpen?y.chevronDown():y.chat()}
2523
+ ${this.unreadBadge&&!this.seen&&!this.isOpen?i.html`<span class="badge"></span>`:i.nothing}
2524
+ </button>`;return i.html`${s}${a}${n}`}renderWorkspace(){const e=!this.docked;return i.html`<div class="root" @keydown=${this.onKeydown}>
2525
+ ${this.sidebarOpen&&e?i.html`<div class="scrim" @click=${()=>this.sidebarOpen=!1}></div>`:i.nothing}
2526
+ ${this.sidebarOpen&&this.sidebar!=="none"?this.renderSidebar(e):i.nothing}
2527
+ <main
2528
+ class="main"
2529
+ @dragenter=${this.onDragEnter}
2530
+ @dragover=${t=>t.preventDefault()}
2531
+ >
2532
+ ${this.renderHeader()}
2533
+ ${this.offline?i.html`<div class="banner" role="status">${this.msg.offline}</div>`:i.nothing}
2534
+ <div
2535
+ class="scroller"
2536
+ role="log"
2537
+ aria-live="polite"
2538
+ aria-busy=${this.busy?"true":"false"}
2539
+ part="messages"
2540
+ @scroll=${this.onScroll}
2541
+ >
2542
+ ${this.msgs.length||this.loadingThread||this.threadError?this.renderThread():this.renderWelcome()}
2543
+ </div>
2544
+ ${this.showJump?i.html`<button type="button" class="jump" @click=${this.jumpToLatest}>
2545
+ ↓ ${this.msg.newReply}
2546
+ </button>`:i.nothing}
2547
+ ${this.renderComposer()} ${T.renderBranding(this.branding,"Chat")}
2548
+ ${this.toast?i.html`<div class="toast" role="status">
2549
+ <span>${this.toast.text}</span>
2550
+ ${this.toast.undo?i.html`<button type="button" @click=${this.undo}>${this.msg.undo}</button>`:i.nothing}
2551
+ </div>`:i.nothing}
2552
+ ${this.dragging?i.html`<div
2553
+ class="drop"
2554
+ @dragover=${t=>t.preventDefault()}
2555
+ @dragleave=${this.onDragLeave}
2556
+ @drop=${this.onDrop}
2557
+ >
2558
+ <strong>${this.msg.dropTitle}</strong><span>${this.msg.dropSub}</span>
2559
+ </div>`:i.nothing}
2560
+ </main>
2561
+ ${this.renderPanel()}
2562
+ </div>`}renderSidebar(e){const t=this.msg,s=this.allowSearch?this.search.trim().toLowerCase():"",a=this.chatList.filter(f=>!s||(f.title??"").toLowerCase().includes(s)),r=f=>this.showBookmarked&&!!f.bookmarked,n=f=>a.filter(b=>!r(b)&&Os(b._modified_at??b._created_at)===f),h=[[t.groupBookmarked,a.filter(r)],[t.groupToday,n("today")],[t.groupYesterday,n("yesterday")],[t.groupWeek,n("week")],[t.groupOlder,n("older")]];let c;return this.listState==="loading"&&!this.chatList.length?c=i.html`<div aria-label=${t.loadingChats}>
2563
+ ${[1,2,3,4].map(()=>i.html`<div class="skeleton"></div>`)}
2564
+ </div>`:a.length?c=h.filter(([,f])=>f.length).map(([f,b])=>i.html`<div class="group">${f}</div>
2565
+ ${b.map(w=>this.renderThreadRow(w))}`):c=i.html`<span class="side-note"
2566
+ >${s?T.fill(t.noMatch,{query:this.search.trim()}):t.noChats}</span
2567
+ >`,i.html`<aside
2568
+ class="sidebar ${e?"overlay":"docked"}"
2569
+ part="sidebar"
2570
+ aria-label=${t.chats}
2571
+ >
2572
+ <div class="side-head">
2573
+ <span class="label">${t.chats}</span>
2574
+ <button
2575
+ type="button"
2576
+ class="icon"
2577
+ title=${t.hideSidebar}
2578
+ aria-label=${t.hideSidebar}
2579
+ @click=${()=>this.sidebarOpen=!1}
2580
+ >
2581
+ ${y.sidebar()}
2582
+ </button>
2583
+ </div>
2584
+ <div class="side-tools">
2585
+ ${this.showNewChat?i.html`<button type="button" class="new-chat" @click=${()=>this.newChat()}>
2586
+ ${y.plus()}<span>${t.newChat}</span>
2587
+ </button>`:i.nothing}
2588
+ ${this.allowSearch?i.html`<input
2589
+ class="search"
2590
+ type="search"
2591
+ placeholder=${t.searchChats}
2592
+ aria-label=${t.searchChats}
2593
+ .value=${this.search}
2594
+ @input=${f=>this.search=f.target.value}
2595
+ />`:i.nothing}
2596
+ </div>
2597
+ <div class="threads">${c}</div>
2598
+ <div class="side-extra ${this.hasSidebarContent?"filled":""}" part="sidebar-extra">
2599
+ <slot
2600
+ name="sidebar"
2601
+ @slotchange=${f=>this.hasSidebarContent=f.target.assignedNodes().length>0}
2602
+ ></slot>
2603
+ </div>
2604
+ </aside>`}renderThreadRow(e){const t=this.msg,s=e._id===this.activeId,a=e.title||t.untitled;if(this.renamingId===e._id)return i.html`<div class="thread active">
2605
+ <input
2606
+ class="thread-rename"
2607
+ maxlength="80"
2608
+ .value=${a}
2609
+ aria-label=${t.renameChat}
2610
+ @keydown=${n=>{n.key==="Enter"&&this.commitRename(e._id,n.target.value),n.key==="Escape"&&(n.stopPropagation(),this.renamingId="")}}
2611
+ @blur=${n=>this.commitRename(e._id,n.target.value)}
2612
+ />
2613
+ </div>`;const r=n=>h=>{h.stopPropagation(),n()};return i.html`<div
2614
+ class="thread ${s?"active":""}"
2615
+ role="button"
2616
+ tabindex="0"
2617
+ aria-current=${s?"true":"false"}
2618
+ @click=${()=>this.openChat(e._id)}
2619
+ @keydown=${n=>n.key==="Enter"&&this.openChat(e._id)}
2620
+ >
2621
+ <span class="thread-title">${a}</span>
2622
+ <span class="thread-actions">
2623
+ ${this.allowBookmark?i.html`<button
2624
+ type="button"
2625
+ class="icon sm ${e.bookmarked?"on":""}"
2626
+ title=${e.bookmarked?t.unbookmarkChat:t.bookmarkChat}
2627
+ aria-label=${e.bookmarked?t.unbookmarkChat:t.bookmarkChat}
2628
+ @click=${r(()=>this.toggleChatBookmark(e._id))}
2629
+ >
2630
+ ${y.bookmark(!!e.bookmarked)}
2631
+ </button>`:i.nothing}
2632
+ ${this.allowRename?i.html`<button
2633
+ type="button"
2634
+ class="icon sm"
2635
+ title=${t.renameChat}
2636
+ aria-label=${t.renameChat}
2637
+ @click=${r(()=>{this.renamingId=e._id,this.focusNext="input.thread-rename"})}
2638
+ >
2639
+ ${y.pencil()}
2640
+ </button>`:i.nothing}
2641
+ ${this.allowDelete?i.html`<button
2642
+ type="button"
2643
+ class="icon sm danger"
2644
+ title=${t.deleteChat}
2645
+ aria-label=${t.deleteChat}
2646
+ @click=${r(()=>this.deleteChat(e._id))}
2647
+ >
2648
+ ${y.trash()}
2649
+ </button>`:i.nothing}
2650
+ </span>
2651
+ </div>`}renderHeader(){const e=this.msg,t=!!this.activeId,s=(this.embed==="inline"||this.embed==="launcher")&&!this.mobile,a=this.embed==="launcher"?()=>this.close():this.expanded?()=>this.collapse():null;let r=i.nothing;return this.showTitle&&(r=this.editingTitle?i.html`<input
2652
+ class="title-input"
2653
+ maxlength="80"
2654
+ .value=${this.chatTitle}
2655
+ aria-label=${e.renameChat}
2656
+ @keydown=${n=>{n.key==="Enter"&&this.commitTitle(n.target.value),n.key==="Escape"&&(n.stopPropagation(),this.editingTitle=!1)}}
2657
+ @blur=${n=>this.commitTitle(n.target.value)}
2658
+ />`:i.html`<button
2659
+ type="button"
2660
+ class="title"
2661
+ part="title"
2662
+ ?disabled=${!t||!this.allowRename}
2663
+ title=${t&&this.allowRename?e.renameChat:""}
2664
+ @click=${()=>{this.editingTitle=!0,this.focusNext="input.title-input"}}
2665
+ >
2666
+ ${this.chatTitle||e.untitled}
2667
+ </button>`),i.html`<header class="header" part="header">
2668
+ <div class="header-left">
2669
+ ${this.sidebar==="none"||this.sidebarOpen&&this.docked?i.nothing:i.html`<button
2670
+ type="button"
2671
+ class="icon"
2672
+ title=${e.showChats}
2673
+ aria-label=${e.showChats}
2674
+ @click=${()=>this.sidebarOpen=!0}
2675
+ >
2676
+ ${y.sidebar()}
2677
+ </button>`}
2678
+ ${r}
2679
+ </div>
2680
+ <div class="header-right">
2681
+ ${this.sidebar==="none"&&this.showNewChat?i.html`<button
2682
+ type="button"
2683
+ class="icon"
2684
+ ?disabled=${!this.msgs.length&&!t}
2685
+ title=${e.newChat}
2686
+ aria-label=${e.newChat}
2687
+ @click=${()=>this.newChat()}
2688
+ >
2689
+ ${y.plus()}
2690
+ </button>`:i.nothing}
2691
+ ${this.allowBookmark?i.html`<button
2692
+ type="button"
2693
+ class="icon ${this.bookmarked?"on":""}"
2694
+ ?disabled=${!t}
2695
+ title=${this.bookmarked?e.unbookmarkChat:e.bookmarkChat}
2696
+ aria-label=${this.bookmarked?e.unbookmarkChat:e.bookmarkChat}
2697
+ @click=${()=>this.activeId&&this.toggleChatBookmark(this.activeId)}
2698
+ >
2699
+ ${y.bookmark(this.bookmarked)}
2700
+ </button>`:i.nothing}
2701
+ ${this.allowExport?i.html`<div class="menu-wrap">
2702
+ <button
2703
+ type="button"
2704
+ class="icon ${this.menuOpen?"on":""}"
2705
+ ?disabled=${!this.msgs.length}
2706
+ title=${e.exportChat}
2707
+ aria-label=${e.exportChat}
2708
+ aria-haspopup="menu"
2709
+ aria-expanded=${this.menuOpen?"true":"false"}
2710
+ @click=${()=>this.menuOpen=!this.menuOpen}
2711
+ >
2712
+ ${y.download()}
2713
+ </button>
2714
+ ${this.menuOpen?this.renderExportMenu():i.nothing}
2715
+ </div>`:i.nothing}
2716
+ ${this.allowDelete?i.html`<button
2717
+ type="button"
2718
+ class="icon danger"
2719
+ ?disabled=${!t}
2720
+ title=${e.deleteChat}
2721
+ aria-label=${e.deleteChat}
2722
+ @click=${()=>this.activeId&&this.deleteChat(this.activeId)}
2723
+ >
2724
+ ${y.trash()}
2725
+ </button>`:i.nothing}
2726
+ ${s||a?i.html`<span class="divider"></span> ${s?i.html`<button
2727
+ type="button"
2728
+ class="icon"
2729
+ title=${this.expanded?e.restore:e.expand}
2730
+ aria-label=${this.expanded?e.restore:e.expand}
2731
+ @click=${()=>this.expanded?this.collapse():this.expand()}
2732
+ >
2733
+ ${this.expanded?y.restore():y.expand()}
2734
+ </button>`:i.nothing}
2735
+ ${a?i.html`<button
2736
+ type="button"
2737
+ class="icon"
2738
+ title=${e.minimize}
2739
+ aria-label=${e.minimize}
2740
+ @click=${a}
2741
+ >
2742
+ ${y.minimize()}
2743
+ </button>`:i.nothing}`:i.nothing}
2744
+ </div>
2745
+ </header>`}renderExportMenu(){const e=this.msg,t=[[e.exportMarkdown,".md","md"],[e.exportJson,".json","json"],[e.exportText,".txt","txt"],[e.exportCopy,"","copy"]];return i.html`<div class="menu-scrim" @click=${()=>this.menuOpen=!1}></div>
2746
+ <div class="menu" role="menu">
2747
+ <span class="label">${e.exportHeading}</span>
2748
+ ${t.map(([s,a,r])=>i.html`<button
2749
+ type="button"
2750
+ role="menuitem"
2751
+ class="menu-item"
2752
+ @click=${()=>this.exportChat(r)}
2753
+ >
2754
+ <span>${s}</span><span class="ext">${a}</span>
2755
+ </button>`)}
2756
+ </div>`}promptList(){const e=this.prompts;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})):(jt[this.mode]??jt.chat).map(([t,s])=>({label:t,text:s}))}renderWelcome(){const e=this.msg,t=this.mode==="rag"?"Rag":this.mode==="kb"?"Kb":"Chat",s=n=>e[`${n}${t}`],a=this.eyebrow??s("eyebrow"),r=this.promptList();return i.html`<div class="welcome-slot">
2757
+ <slot name="welcome"
2758
+ ><div class="welcome" part="welcome">
2759
+ <div class="welcome-head">
2760
+ ${this.logoUrl&&It(this.logoUrl,!0)?i.html`<img class="welcome-logo" src=${this.logoUrl} alt="" />`:i.nothing}
2761
+ ${a?i.html`<span class="label">${a}</span>`:i.nothing}
2762
+ <h2>${this.heading||s("heading")}</h2>
2763
+ <p>${this.description||s("description")}</p>
2764
+ </div>
2765
+ ${r.length?i.html`<div class="prompts">
2766
+ ${r.map(n=>i.html`<button
2767
+ type="button"
2768
+ class="prompt"
2769
+ part="prompt"
2770
+ @click=${()=>this.send(n.text)}
2771
+ >
2772
+ <span class="label">${n.label||"Suggested"}</span>
2773
+ <span class="prompt-text">${n.text}</span>
2774
+ </button>`)}
2775
+ </div>`:i.nothing}
2776
+ </div></slot
2777
+ >
2778
+ </div>`}renderThread(){const e=this.msgs.map(t=>t.role).lastIndexOf("assistant");return i.html`<div class="thread-view">
2779
+ ${this.threadError?i.html`<div class="error-card" role="alert">
2780
+ <span>${this.threadError}</span>
2781
+ ${this.activeId?i.html`<button
2782
+ type="button"
2783
+ class="btn"
2784
+ @click=${()=>this.openChat(this.activeId)}
2785
+ >
2786
+ ${this.msg.retry}
2787
+ </button>`:i.nothing}
2788
+ </div>`:i.nothing}
2789
+ ${this.loadingThread?i.html`${[1,2].map(()=>i.html`<div class="skeleton" style="height:48px"></div>`)}`:i.nothing}
2790
+ ${Gt.repeat(this.msgs,t=>t.key,(t,s)=>t.role==="user"?this.renderUser(t):this.renderBot(t,s===e))}
2791
+ </div>`}renderUser(e){const t=this.msg,s=e.at?new Date(e.at).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):"",a=e.attachments??[];return i.html`<div class="msg user" part="message user">
2792
+ ${a.length?i.html`<div class="attachments">
2793
+ ${a.map(r=>i.html`<span class="doc-chip"><span class="ext">${mt(r.name)}</span><span class="name">${r.name}</span></span>`)}
2794
+ </div>`:i.nothing}
2795
+ ${this.editingKey===e.key?i.html`<div class="edit-box">
2796
+ <textarea
2797
+ rows="3"
2798
+ class="edit-input"
2799
+ .value=${this.editDraft}
2800
+ @input=${r=>this.editDraft=r.target.value}
2801
+ @keydown=${r=>{r.key==="Escape"&&(r.stopPropagation(),this.editingKey="")}}
2802
+ ></textarea>
2803
+ <div class="row-end">
2804
+ <button type="button" class="btn" @click=${()=>this.editingKey=""}>
2805
+ ${t.cancel}
2806
+ </button>
2807
+ <button type="button" class="btn primary" @click=${()=>this.saveEdit(e)}>
2808
+ ${t.saveResend}
2809
+ </button>
2810
+ </div>
2811
+ </div>`:i.html`<div class="bubble-user">${e.content}</div>
2812
+ <div class="toolbar">
2813
+ ${this.allowBookmark&&e.bookmarked?i.html`<span class="saved">${y.bookmark(!0)}${t.saved}</span>`:i.nothing}
2814
+ ${this.showTime?i.html`<span class="time">${s}</span>`:i.nothing}
2815
+ ${this.busy?i.nothing:i.html`<button
2816
+ type="button"
2817
+ class="icon"
2818
+ title=${t.edit}
2819
+ aria-label=${t.edit}
2820
+ @click=${()=>{this.editingKey=e.key,this.editDraft=e.content,this.focusNext="textarea.edit-input"}}
2821
+ >
2822
+ ${y.pencil()}
2823
+ </button>`}
2824
+ ${this.allowCopy?i.html`<button
2825
+ type="button"
2826
+ class="icon"
2827
+ title=${this.copiedKey===e.key?t.copied:t.copy}
2828
+ aria-label=${t.copy}
2829
+ @click=${()=>this.copy(e.key,e.content)}
2830
+ >
2831
+ ${y.copy()}
2832
+ </button>`:i.nothing}
2833
+ ${this.allowBookmark&&e.id?i.html`<button
2834
+ type="button"
2835
+ class="icon ${e.bookmarked?"on":""}"
2836
+ title=${e.bookmarked?t.unbookmarkMessage:t.bookmarkMessage}
2837
+ aria-label=${e.bookmarked?t.unbookmarkMessage:t.bookmarkMessage}
2838
+ @click=${()=>this.toggleMessageBookmark(e)}
2839
+ >
2840
+ ${y.bookmark(e.bookmarked)}
2841
+ </button>`:i.nothing}
2842
+ ${this.allowDelete?i.html`<button
2843
+ type="button"
2844
+ class="icon danger"
2845
+ title=${t.deleteMessage}
2846
+ aria-label=${t.deleteMessage}
2847
+ @click=${()=>this.deleteMessage(e)}
2848
+ >
2849
+ ${y.trash()}
2850
+ </button>`:i.nothing}
2851
+ </div>`}
2852
+ </div>`}pillLabel(){return this.mode==="rag"||this.mode==="kb"?this.msg.searching:this.msg.thinking}renderBot(e,t){const s=this.msg,a=e.phase==="pending",r=e.phase==="done",n=e.sources.length,h=bt(e.content),c=e.sources.map((x,O)=>L(x,O+1)),f=h.size?c.filter(x=>h.has(x.n)):c,b=e.at?new Date(e.at).toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}):"",w=e.content+(f.length?`
2853
+
2854
+ Sources:
2855
+ ${f.map(x=>`[${x.n}] ${x.title}`).join(`
2856
+ `)}`:""),$=this.retrievalOpen.has(e.key);return i.html`<div class="msg bot" part="message assistant">
2857
+ ${a?i.html`<div class="halo"></div>`:i.nothing}
2858
+ ${this.arrivedKey===e.key?i.html`<div class="arrived">
2859
+ <div class="wash"></div>
2860
+ <div class="ring"></div>
2861
+ <div class="sweep"></div>
2862
+ </div>`:i.nothing}
2863
+ <div class="bot-body">
2864
+ ${this.allowBookmark&&e.bookmarked?i.html`<span class="saved">${y.bookmark(!0)}${s.saved}</span>`:i.nothing}
2865
+ ${a?i.html`<div class="pill" role="status">
2866
+ <span class="ring"></span><span class="dot"></span>
2867
+ <span class="shimmer">${this.pillLabel()}</span>
2868
+ </div>`:i.nothing}
2869
+ ${this.showSources&&n&&!a?i.html`<div class="retrieval">
2870
+ <button
2871
+ type="button"
2872
+ class="retrieval-toggle"
2873
+ aria-expanded=${$?"true":"false"}
2874
+ @click=${()=>{const x=new Set(this.retrievalOpen);x.has(e.key)?x.delete(e.key):x.add(e.key),this.retrievalOpen=x}}
2875
+ >
2876
+ <span class="chev">${$?"▾":"▸"}</span>
2877
+ <span style="flex:1">${T.fill(s.searchedSources,{n})}</span>
2878
+ ${e.execTime!==void 0?i.html`<span class="ms">${e.execTime.toFixed(1)}s</span>`:i.nothing}
2879
+ </button>
2880
+ ${$?i.html`<div class="retrieval-list">
2881
+ ${c.map(x=>i.html`<button
2882
+ type="button"
2883
+ class="passage"
2884
+ @click=${()=>this.panel={key:e.key,n:x.n}}
2885
+ >
2886
+ <span class="n">${x.n}</span>
2887
+ <span class="what"
2888
+ ><span>${x.title}${x.section?` · ${x.section}`:""}</span
2889
+ ><span>${x.collection||x.path}</span></span
2890
+ >
2891
+ ${x.score!==null?i.html`<span class="relevance"
2892
+ ><span class="score">${x.score.toFixed(2)}</span>
2893
+ <span class="relevance-track"
2894
+ ><span
2895
+ class="relevance-fill"
2896
+ style="width:${Math.round(x.score*100)}%"
2897
+ ></span></span
2898
+ ></span>`:i.html`<span></span>`}
2899
+ </button>`)}
2900
+ </div>`:i.nothing}
2901
+ </div>`:i.nothing}
2902
+ ${a?i.nothing:this.renderAnswer(e)}
2903
+ ${e.phase==="streaming"?i.html`<span class="caret"></span>`:i.nothing}
2904
+ ${e.phase==="error"?i.html`<div class="error-card" role="alert">
2905
+ <span>${e.error}</span>
2906
+ <button type="button" class="btn" @click=${()=>this.retry(e)}>
2907
+ ${s.retry}
2908
+ </button>
2909
+ </div>`:i.nothing}
2910
+ ${this.showSources&&r&&f.length?i.html`<div class="cards">
2911
+ <span class="label">${h.size?s.sourcesCited:s.sourcesRetrieved}</span>
2912
+ <div class="card-grid">
2913
+ ${f.map(x=>{var O;return i.html`<button
2914
+ type="button"
2915
+ class="source-card ${((O=this.panel)==null?void 0:O.key)===e.key&&this.panel.n===x.n?"active":""}"
2916
+ @click=${()=>this.panel={key:e.key,n:x.n}}
2917
+ >
2918
+ <span class="top"
2919
+ ><span class="num">${x.n}</span
2920
+ >${x.collection?i.html`<span class="label">${x.collection}</span>`:i.nothing}</span
2921
+ >
2922
+ <span class="t">${x.title}${x.section?` · ${x.section}`:""}</span>
2923
+ <span class="s">${x.text}</span>
2924
+ </button>`})}
2925
+ </div>
2926
+ </div>`:i.nothing}
2927
+ ${r?i.html`<div class="toolbar ${t?"pinned":""}">
2928
+ ${this.allowCopy?i.html`<button
2929
+ type="button"
2930
+ class="icon"
2931
+ title=${this.copiedKey===e.key?s.copied:s.copy}
2932
+ aria-label=${s.copy}
2933
+ @click=${()=>this.copy(e.key,w)}
2934
+ >
2935
+ ${y.copy()}
2936
+ </button>`:i.nothing}
2937
+ ${this.allowRaw&&this.formatLevel!=="raw"&&e.content?i.html`<button
2938
+ type="button"
2939
+ class="icon ${this.rawKeys.has(e.key)?"on":""}"
2940
+ title=${this.rawKeys.has(e.key)?s.showFormatted:s.showRaw}
2941
+ aria-label=${s.showRaw}
2942
+ aria-pressed=${this.rawKeys.has(e.key)?"true":"false"}
2943
+ @click=${()=>this.toggleRaw(e.key)}
2944
+ >
2945
+ ${y.raw()}
2946
+ </button>`:i.nothing}
2947
+ ${this.allowRegenerate&&t&&!this.busy?i.html`<button
2948
+ type="button"
2949
+ class="icon"
2950
+ title=${s.regenerate}
2951
+ aria-label=${s.regenerate}
2952
+ @click=${()=>this.regenerate()}
2953
+ >
2954
+ ${y.refresh()}
2955
+ </button>`:i.nothing}
2956
+ ${this.allowBookmark&&e.id?i.html`<button
2957
+ type="button"
2958
+ class="icon ${e.bookmarked?"on":""}"
2959
+ title=${e.bookmarked?s.unbookmarkMessage:s.bookmarkMessage}
2960
+ aria-label=${e.bookmarked?s.unbookmarkMessage:s.bookmarkMessage}
2961
+ @click=${()=>this.toggleMessageBookmark(e)}
2962
+ >
2963
+ ${y.bookmark(e.bookmarked)}
2964
+ </button>`:i.nothing}
2965
+ ${this.allowDelete?i.html`<button
2966
+ type="button"
2967
+ class="icon danger"
2968
+ title=${s.deleteMessage}
2969
+ aria-label=${s.deleteMessage}
2970
+ @click=${()=>this.deleteMessage(e)}
2971
+ >
2972
+ ${y.trash()}
2973
+ </button>`:i.nothing}
2974
+ ${this.showTime?i.html`<span class="time">${b}</span>`:i.nothing}
2975
+ ${e.stopped?i.html`<span class="note">${s.stopped}</span>`:i.nothing}
2976
+ <span class="spacer"></span>
2977
+ ${this.allowFeedback?e.feedback?i.html`<span class="note"
2978
+ >${e.feedback==="up"?s.markedHelpful:s.thanksFeedback}</span
2979
+ >`:i.html`<button
2980
+ type="button"
2981
+ class="icon"
2982
+ title=${s.helpful}
2983
+ aria-label=${s.helpful}
2984
+ @click=${()=>this.feedback(e,"up")}
2985
+ >
2986
+ ${y.thumb()}
2987
+ </button>
2988
+ <button
2989
+ type="button"
2990
+ class="icon"
2991
+ title=${s.notHelpful}
2992
+ aria-label=${s.notHelpful}
2993
+ @click=${()=>this.feedback(e,"down")}
2994
+ >
2995
+ ${y.thumb(!0)}
2996
+ </button>`:i.nothing}
2997
+ </div>`:i.nothing}
2998
+ ${this.showFollowups&&r&&t&&!this.busy&&e.followups.length?i.html`<div class="followups">
2999
+ ${e.followups.map(x=>i.html`<button type="button" class="followup" @click=${()=>this.send(x)}>
3000
+ <span class="arrow">↳</span><span>${x}</span>
3001
+ </button>`)}
3002
+ </div>`:i.nothing}
3003
+ </div>
3004
+ </div>`}renderAnswer(e){if(e.phase==="error"&&!e.content)return i.nothing;if(e.phase==="done"&&!e.content)return e.stopped?i.nothing:i.html`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;const t=this.formatLevel;if(t==="raw"||this.allowRaw&&this.rawKeys.has(e.key))return i.html`<div class="answer" part="answer"><p class="raw">${e.content}</p></div>`;const s=e.phase==="streaming"?Pt(e.content):e.content;let a=Ut(Dt(s),t);if(this.afterParse)try{const n=this.afterParse(a,{message:e,format:t});Array.isArray(n)?a=n:console.warn("[singlebase-chat] afterParse must return an array of blocks; showing the original.")}catch(n){console.warn("[singlebase-chat] afterParse failed; showing the original.",n)}const r=e.sources.reduce((n,h,c)=>Math.max(n,L(h,c+1).n),0);return i.html`<div class="answer" part="answer">
3005
+ ${a.map((n,h)=>this.renderBlock(n,e,r,h))}
3006
+ </div>`}renderInline(e,t,s){return Kt(e,s).map(a=>{var r;switch(a.type){case"bold":return i.html`<strong>${a.text}</strong>`;case"italic":return i.html`<em>${a.text}</em>`;case"strike":return i.html`<s>${a.text}</s>`;case"code":return i.html`<code class="inline">${a.text}</code>`;case"link":return i.html`<a href=${a.href} target="_blank" rel="noopener noreferrer nofollow"
3007
+ >${a.text}</a
3008
+ >`;case"cite":{const n=((r=this.panel)==null?void 0:r.key)===t.key&&this.panel.n===a.n?"cite active":"cite",h=T.fill(this.msg.openSource,{n:a.n}),c=()=>this.panel={key:t.key,n:a.n};return i.html`<button type="button" class=${n} aria-label=${h} @click=${c}>${a.n}</button>`}default:return a.text}})}renderBlock(e,t,s,a){switch(e.type){case"p":return i.html`<p>${this.renderInline(e.text,t,s)}</p>`;case"raw":return i.html`<p class="raw">${e.text}</p>`;case"h":return i.html`<h3 class="h${e.level}">${this.renderInline(e.text,t,s)}</h3>`;case"hr":return i.html`<hr />`;case"list":return this.renderList(e.ordered,e.items,t,s);case"quote":return i.html`<div class="quote">${this.renderInline(e.text,t,s)}</div>`;case"callout":return i.html`<div class="callout ${e.kind}" role="note" part="callout">
3009
+ <strong class="callout-title"
3010
+ >${e.title||this.msg[ws[e.kind]]}</strong
3011
+ >
3012
+ ${e.text.split(`
3013
+ `).filter(r=>r.trim()).map(r=>i.html`<p>${this.renderInline(r,t,s)}</p>`)}
3014
+ </div>`;case"code":return this.renderCustom(e.lang,e.text,t)??this.renderCode(e.lang,e.text,`${t.key}:${a}`);case"table":return this.renderTable(e.head,e.rows,e.align,t,s,`${t.key}:${a}`);case"json":return this.renderJsonBlock(e.value,e.source,`${t.key}:${a}`);case"svg":{const r=Wt(e.source);if(!r)return this.renderCode("svg",e.source,`${t.key}:${a}`);const n=`${t.key}:${a}`;return i.html`<figure class="svg" part="svg">
3015
+ <img src=${r} alt="Drawing" />
3016
+ <figcaption>
3017
+ <button type="button" class="text-btn" @click=${()=>this.copy(n,e.source)}>
3018
+ ${this.copiedKey===n?this.msg.copied:this.msg.copySvg}
3019
+ </button>
3020
+ </figcaption>
3021
+ </figure>`}case"pending":return i.html`<div class="chart-pending">
3022
+ <span class="label"
3023
+ >${e.kind==="svg"?this.msg.renderingSvg:this.msg.renderingChart}</span
3024
+ >
3025
+ </div>`;case"chart":return this.renderChart(e.spec);case"img":return i.html`<div class="gallery ${e.images.length>1?"many":""}">
3026
+ ${e.images.map(r=>i.html`<figure>
3027
+ ${r.src&&It(r.src,!0)?i.html`<img
3028
+ src=${r.src}
3029
+ alt=${r.alt}
3030
+ loading="lazy"
3031
+ referrerpolicy="no-referrer"
3032
+ />`:i.html`<div class="img-missing"><span class="label">Image</span></div>`}
3033
+ ${r.alt?i.html`<figcaption>${r.alt}</figcaption>`:i.nothing}
3034
+ </figure>`)}
3035
+ </div>`;default:return i.nothing}}renderList(e,t,s,a){const r=t.map(n=>i.html`<li
3036
+ class=${n.checked===null?"":"task"}
3037
+ style=${n.depth?`margin-left:${n.depth*20}px`:""}
3038
+ >
3039
+ ${n.checked===null?i.nothing:i.html`<input type="checkbox" disabled .checked=${n.checked} aria-hidden="true" />`}
3040
+ ${this.renderInline(n.text,s,a)}
3041
+ </li>`);return e?i.html`<ol>
3042
+ ${r}
3043
+ </ol>`:i.html`<ul>
3044
+ ${r}
3045
+ </ul>`}renderCode(e,t,s){return i.html`<div class="code">
3046
+ <div class="code-head">
3047
+ <span class="label">${e}</span>
3048
+ <button type="button" class="text-btn" @click=${()=>this.copy(s,t)}>
3049
+ ${this.copiedKey===s?this.msg.copied:this.msg.copy}
3050
+ </button>
3051
+ </div>
3052
+ <pre><code>${t}</code></pre>
3053
+ </div>`}renderCustom(e,t,s){var r;const a=this.formatLevel==="rich"?(r=this.renderers)==null?void 0:r[e]:void 0;if(typeof a!="function"||s.phase==="streaming")return null;try{const n=a(t,{lang:e,message:s});return n==null?null:i.html`<div class="custom-block">${n}</div>`}catch(n){return console.warn(`[singlebase-chat] the "${e}" renderer failed; showing the source`,n),null}}renderTable(e,t,s,a,r,n){const h=v=>/^[-+]?[$€£¥]?\s?[\d,.]+\s?%?$/.test(v.trim())&&/\d/.test(v),c=v=>Number(v.replace(/[^\d.+-]/g,"")),f=e.map((v,C)=>{if(s[C])return s[C];const k=t.map(z=>z[C]??"").filter(Boolean);return k.length&&k.filter(h).length/k.length>=.8?"right":null}),b=this.sorts.get(n);let w=t;b&&(w=[...t].sort((v,C)=>{const k=v[b.col]??"",z=C[b.col]??"";return(h(k)&&h(z)?c(k)-c(z):k.localeCompare(z,void 0,{numeric:!0}))*b.dir}));const $=w.length;w=w.slice(0,ys);const x=v=>{const C=new Map(this.sorts),k=C.get(n);(k==null?void 0:k.col)===v&&k.dir===-1?C.delete(n):C.set(n,{col:v,dir:(k==null?void 0:k.col)===v?-1:1}),this.sorts=C},O=v=>f[v]?`text-align:${f[v]}`:"";return i.html`<div class="table" part="table">
3054
+ <table>
3055
+ <thead>
3056
+ <tr>
3057
+ ${e.map((v,C)=>{const k=(b==null?void 0:b.col)===C?b.dir===1?"ascending":"descending":"none";return i.html`<th style=${O(C)} aria-sort=${k}>
3058
+ ${t.length>1?i.html`<button type="button" class="sort" @click=${()=>x(C)}>
3059
+ ${this.renderInline(v,a,r)}<span class="arrow"
3060
+ >${k==="ascending"?"↑":k==="descending"?"↓":"↕"}</span
3061
+ >
3062
+ </button>`:this.renderInline(v,a,r)}
3063
+ </th>`})}
3064
+ </tr>
3065
+ </thead>
3066
+ <tbody>
3067
+ ${w.map(v=>i.html`<tr>
3068
+ ${e.map((C,k)=>i.html`<td style=${O(k)}>
3069
+ ${this.renderInline(v[k]??"",a,r)}
3070
+ </td>`)}
3071
+ </tr>`)}
3072
+ </tbody>
3073
+ </table>
3074
+ ${$>w.length?i.html`<div class="table-note">
3075
+ ${T.fill(this.msg.showingRows,{n:w.length,total:$})}
3076
+ </div>`:i.nothing}
3077
+ </div>`}renderJsonBlock(e,t,s){let a=0;const r=h=>{a++,a<=_t&&h&&typeof h=="object"&&Object.values(h).forEach(r)};if(r(e),a>_t)return this.renderCode("json",t,s);const n=(h,c,f)=>{const b=f===void 0?i.nothing:i.html`<span class="jkey">${f}</span>: `;if(h&&typeof h=="object"){const $=Object.entries(h),x=Array.isArray(h)?`[${$.length}]`:`{${$.length}}`;return i.html`<details class="jnode" ?open=${c<2}>
3078
+ <summary>${b}<span class="jmeta">${x}</span></summary>
3079
+ <div class="jkids">${$.map(([O,v])=>n(v,c+1,O))}</div>
3080
+ </details>`}const w=h===null?"null":typeof h;return i.html`<div class="jleaf">
3081
+ ${b}<span class="jv ${w}">${JSON.stringify(h)}</span>
3082
+ </div>`};return i.html`<div class="code json" part="json">
3083
+ <div class="code-head">
3084
+ <span class="label">json</span>
3085
+ <button type="button" class="text-btn" @click=${()=>this.copy(s,t)}>
3086
+ ${this.copiedKey===s?this.msg.copied:this.msg.copy}
3087
+ </button>
3088
+ </div>
3089
+ <div class="jtree">${n(e,0)}</div>
3090
+ </div>`}renderChart(e){const t=e.series.length>1?i.html`<span class="legend">
3091
+ ${e.series.map((n,h)=>i.html`<span
3092
+ ><span
3093
+ class="swatch"
3094
+ style="background:${_[h%_.length]}"
3095
+ ></span
3096
+ >${n.name}</span
3097
+ >`)}
3098
+ </span>`:i.nothing,s=i.html`<div class="chart-head">
3099
+ <span class="chart-title">${e.title}</span>${t}
3100
+ </div>`;if(e.type==="line"){const n=Math.max(0,...e.series.flatMap(b=>b.values)),h=Math.pow(10,Math.floor(Math.log10(n||1))),c=Math.ceil(n/h*2)/2*h||1,f=Math.max(e.labels.length,...e.series.map(b=>b.values.length));return i.html`<figure class="chart" part="chart" aria-label=${e.title}>
3101
+ ${s}
3102
+ <div class="line-chart">
3103
+ <div class="plot">
3104
+ ${[1,.5,0].map(b=>i.html`<div class="tick ${b===0?"base":""}" style="top:${(1-b)*100}%">
3105
+ <span>${ut(Math.round(c*b),e.unit)}</span>
3106
+ </div>`)}
3107
+ <svg
3108
+ viewBox="0 0 600 170"
3109
+ preserveAspectRatio="none"
3110
+ role="img"
3111
+ aria-label=${e.title}
3112
+ >
3113
+ ${e.series.map((b,w)=>i.svg`<polyline pathLength="1" stroke=${_[w%_.length]}
3114
+ points=${b.values.map(($,x)=>`${(f>1?x/(f-1)*600:300).toFixed(1)},${(170-$/c*170).toFixed(1)}`).join(" ")}><title>${b.name}: ${b.values.map($=>ut($,e.unit)).join(", ")}</title></polyline>`)}
3115
+ </svg>
3116
+ </div>
3117
+ <div class="x-labels">${e.labels.map(b=>i.html`<span>${b}</span>`)}</div>
3118
+ </div>
3119
+ </figure>`}const a=e.labels.map((n,h)=>e.series.reduce((c,f)=>c+(f.values[h]||0),0)),r=Math.max(0,...a)||1;return i.html`<figure class="chart" part="chart" aria-label=${e.title}>
3120
+ ${s}
3121
+ <div class="bars">
3122
+ ${e.labels.map((n,h)=>i.html`<div class="bar-row" title="${n}: ${ut(a[h],e.unit)}">
3123
+ <span class="bar-label">${n}</span>
3124
+ <span class="bar-track"
3125
+ ><span class="bar-fill" style="width:${Math.max(0,a[h])/r*100}%">
3126
+ ${e.series.map((c,f)=>i.html`<span
3127
+ style="flex:${Math.max(0,c.values[h]||0)};background:${e.series.length>1?_[f%_.length]:"var(--c-ink)"}"
3128
+ ></span>`)}
3129
+ </span></span
3130
+ >
3131
+ <span class="bar-value">${ut(a[h],e.unit)}</span>
3132
+ </div>`)}
3133
+ </div>
3134
+ </figure>`}renderPanel(){if(!this.panel)return i.nothing;const e=this.msgs.find(b=>b.key===this.panel.key);if(!e)return i.nothing;const t=e.sources.map((b,w)=>L(b,w+1)),s=t.find(b=>b.n===this.panel.n);if(!s)return i.nothing;const a=this.msg,r=bt(e.content),n=t.filter(b=>b.n!==s.n&&(!r.size||r.has(b.n))),h=`ref:${e.key}:${s.n}`,c=`"${s.text}"
3135
+ — ${s.title} [${s.n}]${s.path?`
3136
+ ${s.path}`:""}${s.updated?` · Updated ${s.updated}`:""}`,f=[s.updated?`Updated ${s.updated}`:"",s.score!==null?`Relevance ${s.score.toFixed(2)}`:""].filter(Boolean).join(" · ");return i.html`<aside
3137
+ class="panel ${this.panelDocked?"docked":"overlay"}"
3138
+ part="panel"
3139
+ role="region"
3140
+ aria-label=${T.fill(a.sourceLabel,{n:s.n})}
3141
+ >
3142
+ <div class="panel-head">
3143
+ <span class="label"
3144
+ >${T.fill(a.sourceLabel,{n:s.n})}${s.collection?` · ${s.collection}`:""}</span
3145
+ >
3146
+ <button type="button" class="text-btn underline" @click=${()=>this.panel=null}>
3147
+ ${a.close}
3148
+ </button>
3149
+ </div>
3150
+ <div class="panel-body">
3151
+ <div class="panel-meta">
3152
+ <h3>${s.title}</h3>
3153
+ ${s.section?i.html`<span class="meta">${s.section}</span>`:i.nothing}
3154
+ ${s.path?i.html`<span class="path">${s.path}</span>`:i.nothing}
3155
+ ${f?i.html`<span class="meta">${f}</span>`:i.nothing}
3156
+ </div>
3157
+ <div class="passage-box">
3158
+ <span class="text">${s.text}</span>
3159
+ <div class="passage-foot">
3160
+ <span class="label">${a.citedPassage}</span>
3161
+ <button
3162
+ type="button"
3163
+ class="copy-ref"
3164
+ title=${a.copyReference}
3165
+ aria-label=${a.copyReference}
3166
+ @click=${()=>this.copy(h,c)}
3167
+ >
3168
+ ${y.copy()}<span>${this.copiedKey===h?a.copied:a.copy}</span>
3169
+ </button>
3170
+ </div>
3171
+ </div>
3172
+ </div>
3173
+ ${n.length?i.html`<div class="panel-foot">
3174
+ <span class="label">${a.alsoCited}</span>
3175
+ <div class="chips">
3176
+ ${n.map(b=>i.html`<button
3177
+ type="button"
3178
+ class="chip"
3179
+ @click=${()=>this.panel={key:e.key,n:b.n}}
3180
+ >
3181
+ ${b.n} · ${b.title}
3182
+ </button>`)}
3183
+ </div>
3184
+ </div>`:i.nothing}
3185
+ </aside>`}renderComposer(){const e=this.msg,t=this.mode==="rag"?e.placeholderRag:this.mode==="kb"?e.placeholderKb:T.fill(e.placeholderChat,{name:this.assistantName}),s=!this.draft.trim(),a=this.footnote===""?i.nothing:i.html`<span class="footnote" part="footnote"
3186
+ >${this.footnote??T.fill(e.footnote,{name:this.assistantName})}</span
3187
+ >`;return this.showComposer?i.html`<div class="composer-wrap">
3188
+ <div class="composer-col">
3189
+ <input
3190
+ type="file"
3191
+ multiple
3192
+ hidden
3193
+ accept=".md,.markdown,.txt,.csv,.tsv,.json,.html,.htm,.yaml,.yml,.xml,.log,text/*"
3194
+ @change=${r=>{const n=r.target;this.addFiles(n.files).then(()=>n.value="")}}
3195
+ />
3196
+ <div class="composer-box">
3197
+ ${this.busy?i.html`<div class="composer-glow"></div>`:i.nothing}
3198
+ <div class="composer ${this.busy?"busy":""}" part="composer">
3199
+ ${this.savedFiles.length?i.html`<div class="pending-files" part="saved-files">
3200
+ ${this.savedFiles.map(r=>i.html`<div class="pending-file kept">
3201
+ <span class="ext">${mt(r.name)}</span>
3202
+ <span class="meta"
3203
+ ><span class="name">${r.name}</span
3204
+ ><span class="size">${e.inThisChat}</span></span
3205
+ >
3206
+ <button
3207
+ type="button"
3208
+ aria-label=${e.removeFromChat}
3209
+ title=${e.removeFromChat}
3210
+ @click=${()=>this.removeSavedFile(r)}
3211
+ >
3212
+ ×
3213
+ </button>
3214
+ </div>`)}
3215
+ </div>`:i.nothing}
3216
+ ${this.files.length?i.html`<div class="pending-files">
3217
+ ${this.files.map(r=>i.html`<div class="pending-file">
3218
+ <span class="ext">${mt(r.name)}</span>
3219
+ <span class="meta"
3220
+ ><span class="name">${r.name}</span
3221
+ ><span class="size">${T.formatSize(r.size)}</span></span
3222
+ >
3223
+ <button
3224
+ type="button"
3225
+ aria-label=${e.removeFile}
3226
+ title=${e.removeFile}
3227
+ @click=${()=>this.files=this.files.filter(n=>n!==r)}
3228
+ >
3229
+ ×
3230
+ </button>
3231
+ </div>`)}
3232
+ </div>`:i.nothing}
3233
+ <textarea
3234
+ class="input"
3235
+ rows="1"
3236
+ placeholder=${t}
3237
+ aria-label=${t}
3238
+ .value=${this.draft}
3239
+ @input=${this.onComposerInput}
3240
+ @keydown=${this.onComposerKey}
3241
+ ></textarea>
3242
+ <div class="composer-row">
3243
+ <div>
3244
+ ${this.allowUpload?i.html`<button
3245
+ type="button"
3246
+ class="attach"
3247
+ title=${e.attach}
3248
+ aria-label=${e.attach}
3249
+ @click=${()=>{var r;return(r=this.renderRoot.querySelector("input[type=file]"))==null?void 0:r.click()}}
3250
+ >
3251
+ ${y.clip()}
3252
+ </button>`:i.nothing}
3253
+ </div>
3254
+ ${this.busy?i.html`<button
3255
+ type="button"
3256
+ class="send stop"
3257
+ title=${e.stop}
3258
+ aria-label=${e.stop}
3259
+ @click=${()=>this.stop()}
3260
+ >
3261
+ ${y.stop()}
3262
+ </button>`:i.html`<button
3263
+ type="button"
3264
+ class="send"
3265
+ title=${e.send}
3266
+ aria-label=${e.send}
3267
+ ?disabled=${s}
3268
+ @click=${()=>this.send()}
3269
+ >
3270
+ ${y.up()}
3271
+ </button>`}
3272
+ </div>
3273
+ </div>
3274
+ ${this.busy?i.html`<div class="composer-ring"><div class="ring"></div></div>`:i.nothing}
3275
+ </div>
3276
+ ${a}
3277
+ </div>
3278
+ </div>`:i.html`<div class="composer-wrap reader">
3279
+ <div class="composer-col">${a}</div>
3280
+ </div>`}},j=new WeakMap,A=new WeakMap,N=new WeakMap,R=new WeakMap,E=new WeakMap,B=new WeakMap,D=new WeakMap,F=new WeakMap,K=new WeakMap,P=new WeakMap,U=new WeakMap,W=new WeakMap,H=new WeakMap,J=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,se=new WeakMap,ie=new WeakMap,ae=new WeakMap,re=new WeakMap,ne=new WeakMap,oe=new WeakMap,le=new WeakMap,ce=new WeakMap,he=new WeakMap,de=new WeakMap,pe=new WeakMap,ue=new WeakMap,ge=new WeakMap,me=new WeakMap,be=new WeakMap,fe=new WeakMap,ve=new WeakMap,xe=new WeakMap,ye=new WeakMap,we=new WeakMap,ke=new WeakMap,$e=new WeakMap,Ce=new WeakMap,Se=new WeakMap,Te=new WeakMap,Ie=new WeakMap,Me=new WeakMap,Oe=new WeakMap,ze=new WeakMap,_e=new WeakMap,Le=new WeakMap,je=new WeakMap,Ae=new WeakMap,Ne=new WeakMap,Re=new WeakMap,Ee=new WeakMap,Be=new WeakMap,De=new WeakMap,Fe=new WeakMap,Ke=new WeakMap,Pe=new WeakMap,Ue=new WeakMap,We=new WeakMap,He=new WeakMap,Je=new WeakMap,qe=new WeakMap,Ge=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,nt=new WeakMap,ot=new WeakMap,lt=new WeakMap,ct=new WeakMap,ht=new WeakMap,dt=new WeakMap,pt=new WeakMap,Rt);us(exports.SinglebaseChat,"styles",[T.tokenDefaults,T.brandingStyles,Xt]);m([g.property({attribute:!1})],exports.SinglebaseChat.prototype,"client",1);m([g.property({attribute:!1})],exports.SinglebaseChat.prototype,"messages",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"theme",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"radius",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"mode",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"format",1);m([g.property({attribute:!1})],exports.SinglebaseChat.prototype,"renderers",1);m([g.property({attribute:!1})],exports.SinglebaseChat.prototype,"beforeSend",1);m([g.property({attribute:!1})],exports.SinglebaseChat.prototype,"afterParse",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"glow",1);m([g.property()],exports.SinglebaseChat.prototype,"docsets",1);m([g.property({attribute:"attachments-mode"})],exports.SinglebaseChat.prototype,"attachmentsMode",1);m([g.property({converter:S,attribute:"save-attachments"})],exports.SinglebaseChat.prototype,"saveAttachments",1);m([g.property({converter:S})],exports.SinglebaseChat.prototype,"followups",1);m([g.property({converter:S,attribute:"show-sources"})],exports.SinglebaseChat.prototype,"showSources",1);m([g.property({converter:S,attribute:"show-new-chat"})],exports.SinglebaseChat.prototype,"showNewChat",1);m([g.property({converter:S,attribute:"show-bookmarked"})],exports.SinglebaseChat.prototype,"showBookmarked",1);m([g.property({converter:S,attribute:"show-followups"})],exports.SinglebaseChat.prototype,"showFollowups",1);m([g.property({converter:S,attribute:"allow-search"})],exports.SinglebaseChat.prototype,"allowSearch",1);m([g.property({converter:S,attribute:"auto-title"})],exports.SinglebaseChat.prototype,"autoTitle",1);m([g.property()],exports.SinglebaseChat.prototype,"model",1);m([g.property({converter:vt})],exports.SinglebaseChat.prototype,"params",1);m([g.property({attribute:"system-message"})],exports.SinglebaseChat.prototype,"systemMessage",1);m([g.property({converter:vt})],exports.SinglebaseChat.prototype,"retrieval",1);m([g.property({converter:vt})],exports.SinglebaseChat.prototype,"metadata",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"embed",1);m([g.property({reflect:!0})],exports.SinglebaseChat.prototype,"position",1);m([g.property({converter:gs})],exports.SinglebaseChat.prototype,"sidebar",1);m([g.property({converter:S,attribute:"show-title"})],exports.SinglebaseChat.prototype,"showTitle",1);m([g.property({attribute:"chat-id"})],exports.SinglebaseChat.prototype,"chatIdAttr",1);m([g.property({attribute:"assistant-name"})],exports.SinglebaseChat.prototype,"assistantName",1);m([g.property({attribute:"logo-url"})],exports.SinglebaseChat.prototype,"logoUrl",1);m([g.property()],exports.SinglebaseChat.prototype,"heading",1);m([g.property()],exports.SinglebaseChat.prototype,"description",1);m([g.property()],exports.SinglebaseChat.prototype,"eyebrow",1);m([g.property()],exports.SinglebaseChat.prototype,"prompts",1);m([g.property({attribute:"bubble-text"})],exports.SinglebaseChat.prototype,"bubbleText",1);m([g.property({type:Boolean,attribute:"greeting-bubble"})],exports.SinglebaseChat.prototype,"greetingBubble",1);m([g.property({type:Boolean,attribute:"unread-badge"})],exports.SinglebaseChat.prototype,"unreadBadge",1);m([g.property({converter:S,attribute:"allow-upload"})],exports.SinglebaseChat.prototype,"allowUpload",1);m([g.property({converter:S,attribute:"allow-export"})],exports.SinglebaseChat.prototype,"allowExport",1);m([g.property({converter:S,attribute:"allow-copy"})],exports.SinglebaseChat.prototype,"allowCopy",1);m([g.property({converter:S,attribute:"allow-regenerate"})],exports.SinglebaseChat.prototype,"allowRegenerate",1);m([g.property({converter:S,attribute:"allow-bookmark"})],exports.SinglebaseChat.prototype,"allowBookmark",1);m([g.property({converter:S,attribute:"allow-delete"})],exports.SinglebaseChat.prototype,"allowDelete",1);m([g.property({converter:S,attribute:"allow-rename"})],exports.SinglebaseChat.prototype,"allowRename",1);m([g.property({converter:S,attribute:"allow-feedback"})],exports.SinglebaseChat.prototype,"allowFeedback",1);m([g.property({converter:S,attribute:"show-composer"})],exports.SinglebaseChat.prototype,"showComposer",1);m([g.property({converter:S,attribute:"show-time"})],exports.SinglebaseChat.prototype,"showTime",1);m([g.property()],exports.SinglebaseChat.prototype,"footnote",1);m([g.property({type:Boolean,attribute:"allow-raw"})],exports.SinglebaseChat.prototype,"allowRaw",1);m([g.property({converter:S})],exports.SinglebaseChat.prototype,"branding",1);m([g.state()],exports.SinglebaseChat.prototype,"chatList",1);m([g.state()],exports.SinglebaseChat.prototype,"listState",1);m([g.state()],exports.SinglebaseChat.prototype,"activeId",1);m([g.state()],exports.SinglebaseChat.prototype,"chatTitle",1);m([g.state()],exports.SinglebaseChat.prototype,"bookmarked",1);m([g.state()],exports.SinglebaseChat.prototype,"msgs",1);m([g.state()],exports.SinglebaseChat.prototype,"loadingThread",1);m([g.state()],exports.SinglebaseChat.prototype,"threadError",1);m([g.state()],exports.SinglebaseChat.prototype,"busy",1);m([g.state()],exports.SinglebaseChat.prototype,"draft",1);m([g.state()],exports.SinglebaseChat.prototype,"files",1);m([g.state()],exports.SinglebaseChat.prototype,"search",1);m([g.state()],exports.SinglebaseChat.prototype,"sidebarOpen",1);m([g.state()],exports.SinglebaseChat.prototype,"width",1);m([g.state()],exports.SinglebaseChat.prototype,"panel",1);m([g.state()],exports.SinglebaseChat.prototype,"menuOpen",1);m([g.state()],exports.SinglebaseChat.prototype,"editingKey",1);m([g.state()],exports.SinglebaseChat.prototype,"editDraft",1);m([g.state()],exports.SinglebaseChat.prototype,"editingTitle",1);m([g.state()],exports.SinglebaseChat.prototype,"renamingId",1);m([g.state()],exports.SinglebaseChat.prototype,"toast",1);m([g.state()],exports.SinglebaseChat.prototype,"copiedKey",1);m([g.state()],exports.SinglebaseChat.prototype,"retrievalOpen",1);m([g.state()],exports.SinglebaseChat.prototype,"rawKeys",1);m([g.state()],exports.SinglebaseChat.prototype,"savedFiles",1);m([g.state()],exports.SinglebaseChat.prototype,"hasSidebarContent",1);m([g.state()],exports.SinglebaseChat.prototype,"sorts",1);m([g.state()],exports.SinglebaseChat.prototype,"arrivedKey",1);m([g.state()],exports.SinglebaseChat.prototype,"dragging",1);m([g.state()],exports.SinglebaseChat.prototype,"showJump",1);m([g.state()],exports.SinglebaseChat.prototype,"offline",1);m([g.state()],exports.SinglebaseChat.prototype,"isOpen",1);m([g.state()],exports.SinglebaseChat.prototype,"expanded",1);m([g.state()],exports.SinglebaseChat.prototype,"bubble",1);m([g.state()],exports.SinglebaseChat.prototype,"seen",1);m([g.state()],exports.SinglebaseChat.prototype,"mobile",1);exports.SinglebaseChat=m([g.customElement("singlebase-chat")],exports.SinglebaseChat);exports.adaptBlocks=Ut;exports.citedNumbers=bt;exports.defaultChatMessages=Et;exports.describeSource=L;exports.parseInline=Kt;exports.parseMarkdown=Dt;exports.resolveChatMessages=Bt;exports.settleStreaming=Pt;exports.splitFollowups=ft;exports.svgDataUrl=Wt;
3281
+ //# sourceMappingURL=chat-ezUmd9II.cjs.map