@agent-ui-kit/web-components 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1241 @@
1
+ let d = null, b = 0;
2
+ const m = /* @__PURE__ */ new Set(), S = /* @__PURE__ */ new WeakMap(), C = /* @__PURE__ */ new Set();
3
+ function T() {
4
+ return d;
5
+ }
6
+ function v(i) {
7
+ d = i;
8
+ }
9
+ function M() {
10
+ return b;
11
+ }
12
+ function P() {
13
+ b++;
14
+ }
15
+ function N() {
16
+ b--;
17
+ }
18
+ class j {
19
+ _value;
20
+ _subs = /* @__PURE__ */ new Set();
21
+ constructor(t) {
22
+ this._value = t;
23
+ }
24
+ }
25
+ class E {
26
+ _subs = /* @__PURE__ */ new Set();
27
+ _deps = /* @__PURE__ */ new Set();
28
+ _fn;
29
+ _value = void 0;
30
+ _dirty = !0;
31
+ constructor(t) {
32
+ this._fn = t;
33
+ }
34
+ _notify() {
35
+ if (!this._dirty) {
36
+ this._dirty = !0;
37
+ for (const t of [...this._subs])
38
+ t instanceof E ? t._notify() : b > 0 ? m.add(t) : A(t);
39
+ }
40
+ }
41
+ }
42
+ class I {
43
+ _deps = /* @__PURE__ */ new Set();
44
+ _fn;
45
+ _disposed = !1;
46
+ _running = !1;
47
+ constructor(t) {
48
+ this._fn = t;
49
+ }
50
+ }
51
+ function q(i) {
52
+ d !== null && (i._subs.add(d), d._deps.add(i));
53
+ }
54
+ function L(i) {
55
+ for (const t of i._deps)
56
+ t._subs.delete(i);
57
+ i._deps.clear();
58
+ }
59
+ function D(i) {
60
+ for (const t of [...i._subs])
61
+ t instanceof E ? t._notify() : b > 0 ? m.add(t) : A(t);
62
+ }
63
+ function A(i) {
64
+ if (i._disposed || i._running) return;
65
+ L(i);
66
+ const t = d;
67
+ d = i, i._running = !0;
68
+ try {
69
+ i._fn();
70
+ } finally {
71
+ d = t, i._running = !1;
72
+ }
73
+ }
74
+ function F() {
75
+ let i = 0;
76
+ for (; m.size > 0; ) {
77
+ if (++i > 100)
78
+ throw new Error("Reactive flush limit exceeded (100 iterations). Possible infinite loop.");
79
+ const t = [...m];
80
+ m.clear();
81
+ for (const e of t)
82
+ A(e);
83
+ }
84
+ }
85
+ class R {
86
+ [Symbol.toStringTag] = "Signal";
87
+ #t;
88
+ constructor(t) {
89
+ this.#t = t;
90
+ }
91
+ get value() {
92
+ return q(this.#t), this.#t._value;
93
+ }
94
+ set value(t) {
95
+ Object.is(this.#t._value, t) || (this.#t._value = t, D(this.#t));
96
+ }
97
+ peek() {
98
+ return this.#t._value;
99
+ }
100
+ }
101
+ function k(i) {
102
+ const t = new j(i), e = new R(t);
103
+ return S.set(e, t), e;
104
+ }
105
+ class H {
106
+ [Symbol.toStringTag] = "Computed";
107
+ #t;
108
+ constructor(t) {
109
+ this.#t = t;
110
+ }
111
+ get value() {
112
+ return q(this.#t), this.#t._dirty && this.#e(), this.#t._value;
113
+ }
114
+ peek() {
115
+ return this.#t._dirty && this.#e(), this.#t._value;
116
+ }
117
+ #e() {
118
+ const t = this.#t;
119
+ if (C.has(t))
120
+ throw new Error("Circular computed dependency detected.");
121
+ L(t), C.add(t);
122
+ const e = T();
123
+ v(t);
124
+ try {
125
+ t._value = t._fn();
126
+ } finally {
127
+ v(e), C.delete(t), t._dirty = !1;
128
+ }
129
+ }
130
+ }
131
+ function ot(i) {
132
+ const t = new E(i), e = new H(t);
133
+ return S.set(e, t), e;
134
+ }
135
+ function _(i) {
136
+ const t = new I(i);
137
+ return A(t), () => {
138
+ t._disposed || (t._disposed = !0, L(t));
139
+ };
140
+ }
141
+ function W(i) {
142
+ P();
143
+ try {
144
+ i();
145
+ } finally {
146
+ N(), M() === 0 && F();
147
+ }
148
+ }
149
+ function lt(i) {
150
+ const t = T();
151
+ v(null);
152
+ try {
153
+ return i();
154
+ } finally {
155
+ v(t);
156
+ }
157
+ }
158
+ const B = (i) => {
159
+ const t = i.replace(/'/g, '"').replace(/(\w[\w-]*)(?=\s*:)/g, '"$1"');
160
+ try {
161
+ return JSON.parse(t);
162
+ } catch {
163
+ return console.warn(`[agent-ui] Failed to parse trait config: ${i}`), {};
164
+ }
165
+ }, z = (i) => {
166
+ const t = B(i), e = t.trait;
167
+ if (!e)
168
+ return console.warn(`[agent-ui] Trait config missing "trait" key: ${i}`), null;
169
+ const s = {};
170
+ for (const [n, r] of Object.entries(t))
171
+ n !== "trait" && (s[n] = String(r));
172
+ return { name: e, config: s };
173
+ }, J = (i) => {
174
+ if (!i || !i.trim()) return [];
175
+ const t = i.trim();
176
+ if (t.startsWith("{")) {
177
+ const e = z(t);
178
+ return e ? [e] : [];
179
+ }
180
+ if (t.startsWith("["))
181
+ try {
182
+ const e = t.replace(/'/g, '"').replace(/(\w[\w-]*)(?=\s*:)/g, '"$1"'), s = JSON.parse(e), n = [];
183
+ for (const r of s) {
184
+ const o = r.trait;
185
+ if (!o) continue;
186
+ const a = {};
187
+ for (const [l, h] of Object.entries(r))
188
+ l !== "trait" && (a[l] = String(h));
189
+ n.push({ name: o, config: a });
190
+ }
191
+ return n;
192
+ } catch {
193
+ return console.warn(`[agent-ui] Failed to parse traits array: ${t}`), [];
194
+ }
195
+ return t.split(/\s+/).map((e) => ({ name: e, config: {} }));
196
+ }, f = /* @__PURE__ */ new Map(), ct = (i) => {
197
+ f.has(i.name) && console.warn(`[agent-ui] Trait "${i.name}" already registered, overwriting.`), f.set(i.name, i);
198
+ }, K = (i) => f.get(i), ut = () => [...f.keys()], ht = () => {
199
+ const i = /* @__PURE__ */ new Map();
200
+ for (const t of f.values()) {
201
+ let e = i.get(t.category);
202
+ e || (e = [], i.set(t.category, e)), e.push(t.name);
203
+ }
204
+ return i;
205
+ }, G = (i, t) => {
206
+ const e = [], s = [], n = /* @__PURE__ */ new Map();
207
+ for (const r of i) {
208
+ const o = f.get(r.name);
209
+ if (!o) {
210
+ console.warn(
211
+ `[agent-ui] Unknown trait "${r.name}" on <${t}>. Not in registry.`
212
+ );
213
+ continue;
214
+ }
215
+ if (o.category === "focus") {
216
+ if (s.length > 0) {
217
+ console.warn(
218
+ `[agent-ui] Multiple focus traits on <${t}>: "${r.name}" conflicts with "${s[0]}". Only one focus trait allowed per element.`
219
+ );
220
+ continue;
221
+ }
222
+ s.push(r.name);
223
+ }
224
+ if (o.category === "gesture" && o.channel) {
225
+ const a = n.get(o.channel);
226
+ if (a) {
227
+ console.warn(
228
+ `[agent-ui] Gesture conflict on <${t}>: "${r.name}" and "${a}" both use ${o.channel} channel.`
229
+ );
230
+ continue;
231
+ }
232
+ n.set(o.channel, r.name);
233
+ }
234
+ e.push({ entry: r, def: o });
235
+ }
236
+ return e;
237
+ };
238
+ let U = 0;
239
+ const V = (i, t, e) => {
240
+ const s = K(t);
241
+ if (!s)
242
+ return console.warn(`[agent-ui] attachTrait: unknown trait "${t}".`), () => {
243
+ };
244
+ const n = { ...e?.config ?? {} }, r = s.defaults ?? {}, o = [];
245
+ let a = "";
246
+ e?.anchorElement && (a = `aui-anchor-${++U}`, e.anchorElement.setAttribute("data-aui-anchor", a), n.anchor = `[data-aui-anchor="${a}"]`);
247
+ const l = {
248
+ host: i,
249
+ addEffect: (c) => {
250
+ o.push(_(c));
251
+ },
252
+ emit: (c, p) => {
253
+ i.dispatchEvent(new CustomEvent(c, {
254
+ bubbles: !0,
255
+ composed: !0,
256
+ detail: p
257
+ }));
258
+ },
259
+ config: (c) => n[c] ?? r[c],
260
+ expose: (c, p) => {
261
+ const w = `data-${s.name}-${c}`;
262
+ typeof p == "boolean" ? p ? i.setAttribute(w, "") : i.removeAttribute(w) : i.setAttribute(w, p);
263
+ },
264
+ unexpose: (c) => {
265
+ i.removeAttribute(`data-${s.name}-${c}`);
266
+ }
267
+ }, h = s.attach(l);
268
+ return () => {
269
+ h?.();
270
+ for (const c of o) c();
271
+ o.length = 0, a && e?.anchorElement?.removeAttribute("data-aui-anchor");
272
+ };
273
+ }, y = /* @__PURE__ */ new WeakMap(), $ = /* @__PURE__ */ new WeakSet();
274
+ function Z(i) {
275
+ if ($.has(i)) return;
276
+ $.add(i);
277
+ const t = i.attributes;
278
+ if (!t) return;
279
+ const e = Object.keys(t);
280
+ Object.defineProperty(i, "observedAttributes", {
281
+ get() {
282
+ return e;
283
+ },
284
+ configurable: !0
285
+ });
286
+ for (const s of e) {
287
+ const n = t[s];
288
+ s in i.prototype || Object.defineProperty(i.prototype, s, {
289
+ get() {
290
+ return y.get(this)?.get(s)?.value;
291
+ },
292
+ set(r) {
293
+ const a = y.get(this)?.get(s);
294
+ if (a)
295
+ if (a.value = r, n.type === "boolean")
296
+ this.toggleAttribute(s, !!r);
297
+ else {
298
+ const l = String(r);
299
+ l === n.default ? this.removeAttribute(s) : this.setAttribute(s, l);
300
+ }
301
+ },
302
+ configurable: !0,
303
+ enumerable: !0
304
+ });
305
+ }
306
+ }
307
+ class u extends HTMLElement {
308
+ /** Override in subclass to declare component attributes */
309
+ static attributes;
310
+ /** Override in subclass to defer activate() until children are present */
311
+ static deferChildren;
312
+ // ── Lifecycle state ─────────────────────────────────────
313
+ #t = k("idle");
314
+ #e = !1;
315
+ get lifecycleState() {
316
+ return this.#t.peek();
317
+ }
318
+ // ── Ready promise ───────────────────────────────────────
319
+ #s = null;
320
+ #i;
321
+ get ready() {
322
+ return this.#i;
323
+ }
324
+ // ── Trait ownership ─────────────────────────────────────
325
+ #n = [];
326
+ #r() {
327
+ const t = this.getAttribute("traits");
328
+ if (!t) return;
329
+ const e = J(t), s = G(e, this.localName);
330
+ for (const { entry: n } of s) {
331
+ const r = V(this, n.name, {
332
+ config: n.config
333
+ });
334
+ this.#n.push(r);
335
+ }
336
+ }
337
+ #a() {
338
+ for (const t of this.#n) t();
339
+ this.#n.length = 0;
340
+ }
341
+ // ── Effect ownership ────────────────────────────────────
342
+ #o = [];
343
+ addEffect(t) {
344
+ const e = _(t);
345
+ return this.#o.push(e), e;
346
+ }
347
+ #u() {
348
+ for (const t of this.#o) t();
349
+ this.#o.length = 0;
350
+ }
351
+ // ── Constructor ─────────────────────────────────────────
352
+ constructor() {
353
+ super(), this.#i = new Promise((e) => {
354
+ this.#s = e;
355
+ });
356
+ const t = this.constructor.attributes;
357
+ if (t) {
358
+ const e = /* @__PURE__ */ new Map();
359
+ for (const [s, n] of Object.entries(t))
360
+ e.set(s, k(n.default));
361
+ y.set(this, e);
362
+ }
363
+ }
364
+ // ── Native callbacks ────────────────────────────────────
365
+ connectedCallback() {
366
+ const t = this.#t.peek();
367
+ if (t === "exiting") {
368
+ this.#e = !0, this.#t.value = "entering", this.#l();
369
+ return;
370
+ }
371
+ (t === "idle" || t === "suspended") && (t === "suspended" && (this.#i = new Promise((e) => {
372
+ this.#s = e;
373
+ })), this.#t.value = "entering", this.#l());
374
+ }
375
+ disconnectedCallback() {
376
+ const t = this.#t.peek();
377
+ t !== "connected" && t !== "entering" || (this.#t.value = "exiting", this.#e = !1, queueMicrotask(() => {
378
+ this.#e || this.#t.peek() === "exiting" && this.#c();
379
+ }));
380
+ }
381
+ attributeChangedCallback(t, e, s) {
382
+ const n = this.constructor.attributes;
383
+ if (!n) return;
384
+ const r = n[t];
385
+ if (!r) return;
386
+ const a = y.get(this)?.get(t);
387
+ a && W(() => {
388
+ if (r.type === "boolean") {
389
+ const l = s !== null;
390
+ if (Object.is(a.peek(), l)) return;
391
+ a.value = l;
392
+ } else if (r.type === "enum") {
393
+ if (s !== null && !r.values.includes(s)) {
394
+ typeof import.meta < "u" && console.warn(
395
+ `[agent-ui] Invalid value "${s}" for attribute "${t}". Expected one of: ${r.values.join(", ")}`
396
+ );
397
+ return;
398
+ }
399
+ const l = s ?? r.default;
400
+ if (Object.is(a.peek(), l)) return;
401
+ a.value = l;
402
+ } else {
403
+ const l = s ?? r.default;
404
+ if (Object.is(a.peek(), l)) return;
405
+ a.value = l;
406
+ }
407
+ });
408
+ }
409
+ // ── Lifecycle hooks (override in subclass) ──────────────
410
+ /** Called when entering the DOM. Return a promise to animate entry. */
411
+ willEnter() {
412
+ }
413
+ /** Called after entry is complete. Element is fully interactive. */
414
+ didEnter() {
415
+ }
416
+ /** Setup hook — create controllers, wire effects. */
417
+ activate() {
418
+ }
419
+ /** Called when leaving the DOM. Return a promise to animate exit. */
420
+ willExit() {
421
+ }
422
+ /** Called after exit is complete. Safe to teardown. */
423
+ didExit() {
424
+ }
425
+ /** Cleanup hook — destroy controllers. */
426
+ dispose() {
427
+ }
428
+ // ── Internal lifecycle ──────────────────────────────────
429
+ async #l() {
430
+ try {
431
+ await this.willEnter();
432
+ } catch {
433
+ }
434
+ if (this.#t.peek() !== "entering") return;
435
+ this.#t.value = "connected", this.constructor.deferChildren && this.children.length === 0 ? this.#h() : (this.activate(), this.#r()), this.didEnter(), this.#s?.(), this.#s = null;
436
+ }
437
+ async #c() {
438
+ try {
439
+ await this.willExit();
440
+ } catch {
441
+ }
442
+ this.#t.peek() === "exiting" && (this.dispose(), this.#a(), this.#u(), this.didExit(), this.#t.value = "suspended");
443
+ }
444
+ #h() {
445
+ let t = 0;
446
+ const e = () => {
447
+ this.activate(), this.#r();
448
+ }, s = new MutationObserver(() => {
449
+ if (this.children.length > 0) {
450
+ s.disconnect(), e();
451
+ return;
452
+ }
453
+ ++t > 50 && (s.disconnect(), e());
454
+ });
455
+ s.observe(this, { childList: !0 }), queueMicrotask(() => {
456
+ this.children.length > 0 && (s.disconnect(), e());
457
+ });
458
+ }
459
+ }
460
+ function dt(i, t) {
461
+ customElements.get(i) || (Z(t), customElements.define(i, t));
462
+ }
463
+ function ft(i) {
464
+ return { name: i };
465
+ }
466
+ class Y extends Event {
467
+ constructor(t, e, s = !1) {
468
+ super("context-request", { bubbles: !0, composed: !0 }), this.key = t, this.callback = e, this.subscribe = s;
469
+ }
470
+ }
471
+ class pt {
472
+ #t;
473
+ #e;
474
+ #s;
475
+ #i = /* @__PURE__ */ new Set();
476
+ #n = null;
477
+ #r;
478
+ constructor(t, e, s) {
479
+ this.#t = t, this.#e = e, this.#s = k(s), this.#r = (n) => {
480
+ const r = n;
481
+ r.key === this.#e && (n.stopPropagation(), r.callback(this.#s.peek()), r.subscribe && this.#i.add(r.callback));
482
+ }, this.#t.addEventListener("context-request", this.#r), this.#n = _(() => {
483
+ const n = this.#s.value;
484
+ for (const r of this.#i) r(n);
485
+ });
486
+ }
487
+ setValue(t) {
488
+ this.#s.value = t;
489
+ }
490
+ dispose() {
491
+ this.#t.removeEventListener("context-request", this.#r), this.#n?.(), this.#i.clear();
492
+ }
493
+ }
494
+ class mt {
495
+ #t;
496
+ #e;
497
+ #s;
498
+ #i;
499
+ constructor(t, e, s, n = !1) {
500
+ this.#t = t, this.#e = e, this.#s = s, this.#i = n, this.request();
501
+ }
502
+ request() {
503
+ this.#t.dispatchEvent(
504
+ new Y(this.#e, this.#s, this.#i)
505
+ );
506
+ }
507
+ dispose() {
508
+ }
509
+ }
510
+ class bt extends u {
511
+ static attributes = {
512
+ type: { type: "enum", values: ["typing", "thinking", "tool-use"], default: "typing" },
513
+ label: { type: "string", default: "" },
514
+ active: { type: "boolean", default: !1 },
515
+ expandable: { type: "boolean", default: !1 },
516
+ expanded: { type: "boolean", default: !1 }
517
+ };
518
+ #t;
519
+ #e = 0;
520
+ #s = 0;
521
+ #i = null;
522
+ #n = null;
523
+ #r = null;
524
+ #a = null;
525
+ constructor() {
526
+ super(), this.#t = this.attachInternals();
527
+ }
528
+ // ── Lifecycle ─────────────────────────────────────────────
529
+ activate() {
530
+ this.setAttribute("role", "status"), this.setAttribute("aria-live", "polite"), this.#o(), this.addEffect(() => {
531
+ this.active ? this.#u() : this.#l();
532
+ }), this.addEffect(() => {
533
+ if (!this.#i) return;
534
+ const t = this.label || Q(this.type);
535
+ this.#i.textContent = t;
536
+ }), this.addEffect(() => {
537
+ this.#r && (this.#r.hidden = !this.active);
538
+ }), this.addEffect(() => {
539
+ if (!this.#a) return;
540
+ const t = this.expanded && this.expandable;
541
+ this.#a.hidden = !t;
542
+ }), this.addEventListener("click", this.#h);
543
+ }
544
+ dispose() {
545
+ this.#l(), this.removeEventListener("click", this.#h), this.#i = null, this.#n = null, this.#r = null, this.#a = null;
546
+ }
547
+ // ── DOM ───────────────────────────────────────────────────
548
+ #o() {
549
+ const t = document.createDocumentFragment();
550
+ for (; this.firstChild; ) t.appendChild(this.firstChild);
551
+ const e = document.createElement("div");
552
+ e.setAttribute("data-agent-activity-row", ""), this.#n = document.createElement("span"), this.#n.setAttribute("data-agent-activity-time", ""), this.#n.textContent = "0s";
553
+ const s = document.createElement("span");
554
+ s.setAttribute("data-agent-activity-sep", ""), s.textContent = "|", s.setAttribute("aria-hidden", "true"), this.#i = document.createElement("span"), this.#i.setAttribute("data-agent-activity-label", ""), this.#r = document.createElement("span"), this.#r.setAttribute("data-agent-activity-dots", ""), this.#r.setAttribute("aria-hidden", "true"), this.#r.innerHTML = "<i></i><i></i><i></i>", e.append(this.#n, s, this.#i, this.#r), this.#a = document.createElement("div"), this.#a.setAttribute("data-agent-activity-content", ""), this.#a.hidden = !0, this.#a.appendChild(t), this.append(e, this.#a);
555
+ }
556
+ // ── Timer ─────────────────────────────────────────────────
557
+ #u() {
558
+ this.#l(), this.#e = performance.now(), this.#c();
559
+ }
560
+ #l() {
561
+ this.#s && (cancelAnimationFrame(this.#s), this.#s = 0);
562
+ }
563
+ #c = () => {
564
+ if (!this.active || !this.#n) return;
565
+ const t = performance.now() - this.#e;
566
+ this.#n.textContent = X(t), this.#s = requestAnimationFrame(this.#c);
567
+ };
568
+ // ── Expand/collapse ───────────────────────────────────────
569
+ #h = () => {
570
+ this.expandable && (this.expanded = !this.expanded, this.dispatchEvent(new CustomEvent("aui:activity-toggle", {
571
+ bubbles: !0,
572
+ composed: !0,
573
+ detail: { expanded: this.expanded }
574
+ })));
575
+ };
576
+ }
577
+ function Q(i) {
578
+ switch (i) {
579
+ case "thinking":
580
+ return "Thinking…";
581
+ case "tool-use":
582
+ return "Using tools…";
583
+ default:
584
+ return "Host is typing…";
585
+ }
586
+ }
587
+ function X(i) {
588
+ const t = Math.floor(i / 1e3);
589
+ if (t < 60) return `${t}s`;
590
+ const e = Math.floor(t / 60), s = t % 60;
591
+ return `${e}m:${String(s).padStart(2, "0")}s`;
592
+ }
593
+ const tt = 40;
594
+ class gt extends u {
595
+ static attributes = {
596
+ "auto-scroll": { type: "boolean", default: !0 },
597
+ scrollable: { type: "boolean", default: !1 }
598
+ };
599
+ #t = !0;
600
+ #e = null;
601
+ #s = 0;
602
+ #i;
603
+ constructor() {
604
+ super(), this.#i = this.attachInternals();
605
+ }
606
+ // ── Public API ────────────────────────────────────────────
607
+ get isPinned() {
608
+ return this.#t;
609
+ }
610
+ /** Scroll to the bottom of the feed. */
611
+ scrollToBottom(t = !0) {
612
+ this.scrollTo({
613
+ top: this.scrollHeight,
614
+ behavior: t ? "smooth" : "instant"
615
+ }), this.#t = !0;
616
+ }
617
+ // ── Lifecycle ─────────────────────────────────────────────
618
+ activate() {
619
+ this.#i.role = "log", this.setAttribute("aria-live", "polite"), this.setAttribute("aria-label", "Conversation"), this.hasAttribute("scrollable") || this.setAttribute("scrollable", ""), this.hasAttribute("auto-scroll") || this.toggleAttribute("auto-scroll", !0), this.addEffect(() => {
620
+ this["auto-scroll"], this.scrollable;
621
+ }), this.addEventListener("scroll", this.#n, { passive: !0 }), this.#e = new MutationObserver(this.#r), this.#e.observe(this, { childList: !0, subtree: !0 });
622
+ }
623
+ dispose() {
624
+ this.removeEventListener("scroll", this.#n), this.#s && (cancelAnimationFrame(this.#s), this.#s = 0), this.#e?.disconnect(), this.#e = null;
625
+ }
626
+ // ── Scroll management ────────────────────────────────────
627
+ #n = () => {
628
+ const t = this.#t, e = this.scrollTop + this.clientHeight >= this.scrollHeight - tt;
629
+ this.#t = e, e !== t && this.dispatchEvent(new CustomEvent("aui:feed-scroll", {
630
+ bubbles: !0,
631
+ composed: !0,
632
+ detail: { isPinned: e, scrollTop: this.scrollTop }
633
+ }));
634
+ };
635
+ #r = () => {
636
+ this["auto-scroll"] && this.#t && (this.#s && cancelAnimationFrame(this.#s), this.#s = requestAnimationFrame(() => {
637
+ this.#s = 0, this.scrollTo({ top: this.scrollHeight, behavior: "smooth" });
638
+ }));
639
+ };
640
+ }
641
+ class vt extends u {
642
+ static deferChildren = !0;
643
+ static attributes = {
644
+ disabled: { type: "boolean", default: !1 },
645
+ busy: { type: "boolean", default: !1 },
646
+ "no-enter-submit": { type: "boolean", default: !1 },
647
+ "no-auto-clear": { type: "boolean", default: !1 }
648
+ };
649
+ #t = null;
650
+ #e = null;
651
+ // ── Public API ────────────────────────────────────────────
652
+ get value() {
653
+ return this.#t?.value ?? "";
654
+ }
655
+ set value(t) {
656
+ this.#t && (this.#t.value = t);
657
+ }
658
+ /** Focus the composer textarea. */
659
+ focusComposer() {
660
+ this.#t?.focus();
661
+ }
662
+ /** Blur the composer textarea. */
663
+ blurComposer() {
664
+ this.#t?.blur();
665
+ }
666
+ // ── Lifecycle ─────────────────────────────────────────────
667
+ activate() {
668
+ this.#s();
669
+ const t = this.getAttribute("value");
670
+ t && this.#t && (this.#t.value = t), this.addEffect(() => {
671
+ const e = this.disabled;
672
+ this.#t && this.#t.toggleAttribute("disabled", e), this.#e && (e ? this.#e.setAttribute("disabled", "") : this.#n());
673
+ }), this.addEffect(() => {
674
+ const e = this.busy;
675
+ this.#e && (this.disabled || (e ? this.#e.setAttribute("disabled", "") : this.#n()));
676
+ }), this.addEventListener("input", this.#r), this.addEventListener("click", this.#a), this.addEventListener("keydown", this.#l), this.addEventListener("focusin", this.#o), this.addEventListener("focusout", this.#u);
677
+ }
678
+ dispose() {
679
+ this.removeEventListener("input", this.#r), this.removeEventListener("click", this.#a), this.removeEventListener("keydown", this.#l), this.removeEventListener("focusin", this.#o), this.removeEventListener("focusout", this.#u), this.#t = null, this.#e = null;
680
+ }
681
+ // ── Child discovery ───────────────────────────────────────
682
+ #s() {
683
+ this.#t = this.querySelector(":scope > aui-textarea") ?? this.querySelector(":scope > aui-agent-prompt > aui-textarea"), this.#e = this.querySelector("[data-submit]") ?? this.#i();
684
+ }
685
+ #i() {
686
+ const t = this.querySelector(':scope > [data-role="actions"]') ?? this.querySelector(':scope > aui-agent-prompt > [data-role="actions"]');
687
+ if (!t) {
688
+ const s = this.querySelectorAll("aui-button[primary]");
689
+ return s.length ? s[s.length - 1] : null;
690
+ }
691
+ const e = t.querySelectorAll("aui-button[primary]");
692
+ return e.length ? e[e.length - 1] : null;
693
+ }
694
+ // ── Submit button enable/disable based on content ─────────
695
+ #n() {
696
+ if (!this.#e || this.disabled) return;
697
+ !this.value.trim() || this.busy ? (this.#e.setAttribute("disabled", ""), this.#e.removeAttribute("primary"), this.#e.removeAttribute("accent")) : (this.#e.removeAttribute("disabled"), this.#e.setAttribute("primary", ""), this.#e.setAttribute("accent", ""));
698
+ }
699
+ // ── Event handlers ────────────────────────────────────────
700
+ #r = (t) => {
701
+ this.disabled || this.#n();
702
+ };
703
+ #a = (t) => {
704
+ if (this.disabled) return;
705
+ const e = t.target;
706
+ (e === this.#e || this.#e?.contains(e)) && this.#c();
707
+ };
708
+ #o = (t) => {
709
+ const e = t.target;
710
+ !this.#t?.contains(e) && e !== this.#t || this.dispatchEvent(
711
+ new CustomEvent("aui:composer-focus", { bubbles: !0, composed: !0 })
712
+ );
713
+ };
714
+ #u = (t) => {
715
+ const e = t.target;
716
+ !this.#t?.contains(e) && e !== this.#t || this.dispatchEvent(
717
+ new CustomEvent("aui:composer-blur", { bubbles: !0, composed: !0 })
718
+ );
719
+ };
720
+ #l = (t) => {
721
+ if (this.disabled || this["no-enter-submit"]) return;
722
+ const e = t;
723
+ if (e.isComposing) return;
724
+ const s = e.target;
725
+ !this.#t?.contains(s) && s !== this.#t || e.key === "Enter" && (e.metaKey || e.ctrlKey) && !e.shiftKey && (e.preventDefault(), this.value.trim() && this.#c());
726
+ };
727
+ // ── Send ──────────────────────────────────────────────────
728
+ #c() {
729
+ const t = this.value.trim();
730
+ if (!t) return;
731
+ if (this.busy) {
732
+ this.dispatchEvent(
733
+ new CustomEvent("aui:composer-submit-blocked", {
734
+ bubbles: !0,
735
+ composed: !0,
736
+ detail: { value: t }
737
+ })
738
+ );
739
+ return;
740
+ }
741
+ this.dispatchEvent(
742
+ new CustomEvent("aui:send", {
743
+ bubbles: !0,
744
+ composed: !0,
745
+ cancelable: !0,
746
+ detail: { value: t }
747
+ })
748
+ ) && !this["no-auto-clear"] && (this.value = "", this.#e?.setAttribute("disabled", ""));
749
+ }
750
+ }
751
+ const et = {
752
+ copy: { label: "Copy", icon: "copy" },
753
+ retry: { label: "Retry", icon: "arrow-clockwise" },
754
+ edit: { label: "Edit", icon: "pencil-simple" },
755
+ "feedback-up": { label: "Helpful", icon: "thumbs-up" },
756
+ "feedback-down": { label: "Not helpful", icon: "thumbs-down" },
757
+ continue: { label: "Continue", icon: "arrow-right" }
758
+ }, st = {
759
+ assistant: ["copy", "retry", "feedback-up", "feedback-down"],
760
+ user: ["edit", "retry"]
761
+ };
762
+ let it = 0;
763
+ function nt(i) {
764
+ return `${i}-${++it}-${Math.random().toString(36).slice(2, 6)}`;
765
+ }
766
+ class yt extends u {
767
+ static attributes = {
768
+ role: { type: "string", default: "assistant" },
769
+ "message-id": { type: "string", default: "" },
770
+ timestamp: { type: "string", default: "" },
771
+ status: { type: "enum", values: ["sending", "sent", "error", "streaming", "partial"], default: "sent" },
772
+ actions: { type: "string", default: "" },
773
+ "actions-style": { type: "enum", values: ["icon", "label", "icon-label"], default: "icon" },
774
+ "actions-position": { type: "enum", values: ["below", "inside"], default: "below" }
775
+ };
776
+ #t;
777
+ #e = null;
778
+ #s = !1;
779
+ #i = 0;
780
+ #n = 0;
781
+ constructor() {
782
+ super(), this.#t = this.attachInternals();
783
+ }
784
+ // ── Public API ────────────────────────────────────────────
785
+ get messageId() {
786
+ return this.getAttribute("message-id") ?? "";
787
+ }
788
+ // ── Lifecycle ─────────────────────────────────────────────
789
+ activate() {
790
+ this.addEventListener("pointerenter", this.#r), this.addEventListener("pointerleave", this.#a), this.addEffect(() => {
791
+ const t = this.role, e = this.actions, s = this["actions-style"], n = this["actions-position"], r = this.status;
792
+ this.#u(t, e || null, s, n, r);
793
+ }), this.#t.role = "article";
794
+ }
795
+ dispose() {
796
+ this.removeEventListener("pointerenter", this.#r), this.removeEventListener("pointerleave", this.#a), clearTimeout(this.#i), clearTimeout(this.#n), this.#e && (this.#o(), this.#e = null);
797
+ }
798
+ // ── Popover hover handlers ────────────────────────────────
799
+ #r = () => {
800
+ clearTimeout(this.#n), !(!this.#e || !this.#s || this.status === "partial") && (clearTimeout(this.#i), this.#i = window.setTimeout(() => {
801
+ try {
802
+ this.#e?.showPopover();
803
+ } catch {
804
+ }
805
+ }, 300));
806
+ };
807
+ #a = () => {
808
+ !this.#s || this.status === "partial" || (clearTimeout(this.#i), clearTimeout(this.#n), this.#n = window.setTimeout(() => {
809
+ try {
810
+ this.#e?.hidePopover();
811
+ } catch {
812
+ }
813
+ }, 150));
814
+ };
815
+ // ── Actions ───────────────────────────────────────────────
816
+ #o() {
817
+ if (this.#e) {
818
+ if (this.#s) {
819
+ this.#e.removeEventListener("pointerenter", this.#r), this.#e.removeEventListener("pointerleave", this.#a), this.#e.removeEventListener("focusin", this.#r), this.#e.removeEventListener("focusout", this.#a);
820
+ try {
821
+ this.#e.hidePopover();
822
+ } catch {
823
+ }
824
+ this.style.removeProperty("anchor-name"), this.#s = !1;
825
+ }
826
+ this.#e.removeEventListener("click", this.#c), this.#e.remove();
827
+ }
828
+ }
829
+ #u(t, e, s, n, r) {
830
+ if (this.#e && (this.#o(), this.#e = null), clearTimeout(this.#n), e === "none" || this.querySelector('[slot="actions"]')) return;
831
+ let o;
832
+ if (e ? o = e.split(",").map((l) => l.trim()).filter(Boolean) : o = st[t] ?? [], r === "partial" && !o.includes("continue") && (o = [...o, "continue"]), o.length === 0) return;
833
+ const a = document.createElement("div");
834
+ a.setAttribute("data-role", "actions"), a.setAttribute("role", "toolbar"), a.setAttribute("aria-label", "Message actions"), s !== "label" && a.setAttribute("data-style", s);
835
+ for (const l of o) {
836
+ const h = et[l];
837
+ h && a.appendChild(this.#l(l, h, s));
838
+ }
839
+ if (a.children.length !== 0) {
840
+ if (a.addEventListener("click", this.#c), n === "below") {
841
+ a.setAttribute("popover", "manual");
842
+ const l = nt("msg");
843
+ this.style.setProperty("anchor-name", `--${l}`), a.style.setProperty("position-anchor", `--${l}`), this.appendChild(a), this.#s = !0, a.addEventListener("pointerenter", this.#r), a.addEventListener("pointerleave", this.#a), a.addEventListener("focusin", this.#r), a.addEventListener("focusout", this.#a), r === "partial" && a.showPopover();
844
+ } else
845
+ this.appendChild(a);
846
+ this.#e = a;
847
+ }
848
+ }
849
+ #l(t, e, s) {
850
+ const n = document.createElement("aui-button");
851
+ if (n.setAttribute("ghost", ""), n.setAttribute("size", "sm"), n.setAttribute("data-action", t), n.setAttribute("aria-label", e.label), s === "icon" || s === "icon-label") {
852
+ const r = document.createElement("aui-icon");
853
+ r.setAttribute("name", e.icon), r.setAttribute("slot", "leading"), n.appendChild(r);
854
+ }
855
+ return (s === "label" || s === "icon-label") && n.appendChild(document.createTextNode(e.label)), n.addEventListener("keydown", (r) => {
856
+ (r.key === "Enter" || r.key === " ") && (r.preventDefault(), n.click());
857
+ }), n;
858
+ }
859
+ #c = (t) => {
860
+ const e = t.target.closest("[data-action]");
861
+ if (!e) return;
862
+ const s = e.getAttribute("data-action");
863
+ if (s) {
864
+ if (t.stopPropagation(), s === "continue") {
865
+ this.dispatchEvent(new CustomEvent("aui:continue-request", {
866
+ bubbles: !0,
867
+ composed: !0,
868
+ detail: { messageId: this.messageId }
869
+ }));
870
+ return;
871
+ }
872
+ this.dispatchEvent(new CustomEvent("aui:message-action", {
873
+ bubbles: !0,
874
+ composed: !0,
875
+ detail: {
876
+ action: s,
877
+ messageId: this.messageId
878
+ }
879
+ }));
880
+ }
881
+ };
882
+ }
883
+ class Et extends u {
884
+ static attributes = {
885
+ "panel-title": { type: "string", default: "" },
886
+ "auto-focus": { type: "string", default: "ready" }
887
+ // 'ready' | 'open-request' | 'never'
888
+ };
889
+ #t = null;
890
+ #e = null;
891
+ #s;
892
+ constructor() {
893
+ super(), this.#s = this.attachInternals();
894
+ }
895
+ // ── Public API ────────────────────────────────────────────
896
+ /** Delegate focus to the child agent-input composer. */
897
+ focusComposer() {
898
+ this.#e && "focusComposer" in this.#e && this.#e.focusComposer();
899
+ }
900
+ /** Reference to the discovered feed element. */
901
+ get feed() {
902
+ return this.#t;
903
+ }
904
+ /** Reference to the discovered input element. */
905
+ get input() {
906
+ return this.#e;
907
+ }
908
+ // ── Lifecycle ─────────────────────────────────────────────
909
+ activate() {
910
+ this.#s.role = "region", this.addEffect(() => {
911
+ const t = this["panel-title"];
912
+ this.#s.ariaLabel = t || "Chat";
913
+ }), this.#i(), this["auto-focus"] === "ready" && requestAnimationFrame(() => {
914
+ this.focusComposer();
915
+ });
916
+ }
917
+ dispose() {
918
+ this.#t = null, this.#e = null;
919
+ }
920
+ // ── Child discovery ───────────────────────────────────────
921
+ #i() {
922
+ this.#t = this.querySelector("aui-agent-feed"), this.#e = this.querySelector("aui-agent-input");
923
+ }
924
+ }
925
+ class At extends u {
926
+ static attributes = {
927
+ disabled: { type: "boolean", default: !1 }
928
+ };
929
+ // ── Lifecycle ─────────────────────────────────────────────
930
+ activate() {
931
+ this.addEffect(() => {
932
+ this.disabled ? this.setAttribute("aria-disabled", "true") : this.removeAttribute("aria-disabled");
933
+ });
934
+ }
935
+ dispose() {
936
+ }
937
+ }
938
+ class wt extends u {
939
+ static attributes = {
940
+ options: { type: "string", default: "" },
941
+ disabled: { type: "boolean", default: !1 }
942
+ };
943
+ #t = [];
944
+ #e = null;
945
+ // ── Public API ────────────────────────────────────────────
946
+ get options() {
947
+ return this.#t;
948
+ }
949
+ set options(t) {
950
+ this.#t = t, this.setAttribute("options", JSON.stringify(t)), this.#n();
951
+ }
952
+ // ── Lifecycle ─────────────────────────────────────────────
953
+ activate() {
954
+ this.setAttribute("role", "group"), this.setAttribute("aria-label", "Suggestions");
955
+ const t = this.getAttribute("options");
956
+ if (t)
957
+ try {
958
+ this.#t = JSON.parse(t);
959
+ } catch {
960
+ this.#t = [];
961
+ }
962
+ this.addEffect(() => {
963
+ const e = this.getAttribute("options");
964
+ if (e)
965
+ try {
966
+ this.#t = JSON.parse(e);
967
+ } catch {
968
+ this.#t = [];
969
+ }
970
+ this.#n();
971
+ }), this.addEffect(() => {
972
+ this.disabled, this.disabled ? this.setAttribute("aria-disabled", "true") : this.removeAttribute("aria-disabled");
973
+ }), this.addEventListener("click", this.#s), this.addEventListener("keydown", this.#i);
974
+ }
975
+ dispose() {
976
+ this.removeEventListener("click", this.#s), this.removeEventListener("keydown", this.#i), this.#e = null;
977
+ }
978
+ // ── Event delegation ────────────────────────────────────────
979
+ #s = (t) => {
980
+ if (this.disabled) return;
981
+ const e = t.target.closest("[data-seed]");
982
+ if (!e) return;
983
+ const s = e.getAttribute("data-seed") ?? "", n = e.querySelector("span:last-child")?.textContent ?? s;
984
+ this.dispatchEvent(new CustomEvent("aui:seed-select", {
985
+ bubbles: !0,
986
+ composed: !0,
987
+ detail: { value: s, label: n }
988
+ }));
989
+ };
990
+ #i = (t) => {
991
+ const e = t;
992
+ if (e.key === "Enter" || e.key === " ") {
993
+ const s = e.target.closest("[data-seed]");
994
+ if (!s) return;
995
+ e.preventDefault(), s.click();
996
+ }
997
+ };
998
+ // ── Rendering ─────────────────────────────────────────────
999
+ #n() {
1000
+ this.textContent = "";
1001
+ const t = this.#t;
1002
+ if (t.length === 0) return;
1003
+ const e = document.createElement("div");
1004
+ e.setAttribute("data-agent-seeds-wrap", "");
1005
+ for (const s of t) {
1006
+ const n = document.createElement("span");
1007
+ if (n.setAttribute("role", "button"), n.setAttribute("tabindex", "0"), n.setAttribute("data-seed", s.value), n.setAttribute("data-agent-seed-chip", ""), s.icon) {
1008
+ const o = document.createElement("aui-icon");
1009
+ o.setAttribute("name", s.icon), n.appendChild(o);
1010
+ }
1011
+ const r = document.createElement("span");
1012
+ r.textContent = s.label, n.appendChild(r), e.appendChild(n);
1013
+ }
1014
+ this.appendChild(e), this.#e = e;
1015
+ }
1016
+ }
1017
+ class Ct extends u {
1018
+ static deferChildren = !0;
1019
+ static attributes = {
1020
+ format: { type: "enum", values: ["markdown", "plain"], default: "markdown" }
1021
+ };
1022
+ #t = "";
1023
+ #e = null;
1024
+ #s = 0;
1025
+ // ── Public API ────────────────────────────────────────────
1026
+ get content() {
1027
+ return this.#t;
1028
+ }
1029
+ set content(t) {
1030
+ this.#t = t, this.#i();
1031
+ }
1032
+ // ── Lifecycle ─────────────────────────────────────────────
1033
+ activate() {
1034
+ !this.#t && this.textContent?.trim() && (this.#t = this.textContent.trim()), this.#e = document.createElement("div"), this.#e.setAttribute("data-agent-prose", ""), this.textContent = "", this.appendChild(this.#e), this.addEffect(() => {
1035
+ this.format, this.#i();
1036
+ }), this.#n();
1037
+ }
1038
+ dispose() {
1039
+ cancelAnimationFrame(this.#s), this.#e = null;
1040
+ }
1041
+ // ── Rendering ─────────────────────────────────────────────
1042
+ #i() {
1043
+ cancelAnimationFrame(this.#s), this.#s = requestAnimationFrame(() => this.#n());
1044
+ }
1045
+ #n() {
1046
+ if (!this.#e) return;
1047
+ const t = this.#t;
1048
+ this.format === "plain" ? this.#e.textContent = t : this.#e.innerHTML = at(O(t));
1049
+ }
1050
+ }
1051
+ const rt = /* @__PURE__ */ new Set([
1052
+ "p",
1053
+ "br",
1054
+ "strong",
1055
+ "em",
1056
+ "code",
1057
+ "pre",
1058
+ "a",
1059
+ "h1",
1060
+ "h2",
1061
+ "h3",
1062
+ "h4",
1063
+ "h5",
1064
+ "h6",
1065
+ "ul",
1066
+ "ol",
1067
+ "li",
1068
+ "blockquote",
1069
+ "hr"
1070
+ ]);
1071
+ function x(i) {
1072
+ return i.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
1073
+ }
1074
+ function g(i) {
1075
+ let t = x(i);
1076
+ return t = t.replace(/`([^`]+)`/g, "<code>$1</code>"), t = t.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>"), t = t.replace(/__(.+?)__/g, "<strong>$1</strong>"), t = t.replace(/\*(.+?)\*/g, "<em>$1</em>"), t = t.replace(/(?<!\w)_(.+?)_(?!\w)/g, "<em>$1</em>"), t = t.replace(
1077
+ /\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g,
1078
+ '<a href="$2" rel="noopener noreferrer" target="_blank">$1</a>'
1079
+ ), t;
1080
+ }
1081
+ function O(i) {
1082
+ if (!i) return "";
1083
+ const t = i.split(`
1084
+ `), e = [];
1085
+ let s = 0;
1086
+ for (; s < t.length; ) {
1087
+ const n = t[s];
1088
+ if (n.startsWith("```")) {
1089
+ const a = n.slice(3).trim(), l = [];
1090
+ for (s += 1; s < t.length && !t[s].startsWith("```"); )
1091
+ l.push(t[s]), s += 1;
1092
+ s += 1;
1093
+ const h = a ? ` data-lang="${x(a)}"` : "";
1094
+ e.push(`<pre${h}><code>${x(l.join(`
1095
+ `))}</code></pre>`);
1096
+ continue;
1097
+ }
1098
+ const r = n.match(/^(#{1,6})\s+(.+)/);
1099
+ if (r) {
1100
+ const a = r[1].length;
1101
+ e.push(`<h${a}>${g(r[2])}</h${a}>`), s += 1;
1102
+ continue;
1103
+ }
1104
+ if (/^---+$/.test(n.trim()) || /^\*\*\*+$/.test(n.trim())) {
1105
+ e.push("<hr>"), s += 1;
1106
+ continue;
1107
+ }
1108
+ if (n.startsWith("> ")) {
1109
+ const a = [];
1110
+ for (; s < t.length && t[s].startsWith("> "); )
1111
+ a.push(t[s].slice(2)), s += 1;
1112
+ e.push(`<blockquote>${O(a.join(`
1113
+ `))}</blockquote>`);
1114
+ continue;
1115
+ }
1116
+ if (/^[-*+]\s/.test(n)) {
1117
+ const a = [];
1118
+ for (; s < t.length; )
1119
+ if (/^[-*+]\s/.test(t[s]))
1120
+ a.push(t[s].replace(/^[-*+]\s/, "")), s += 1;
1121
+ else if (!t[s].trim() && s + 1 < t.length && /^[-*+]\s/.test(t[s + 1]))
1122
+ s += 1;
1123
+ else
1124
+ break;
1125
+ e.push("<ul>" + a.map((l) => `<li>${g(l)}</li>`).join("") + "</ul>");
1126
+ continue;
1127
+ }
1128
+ if (/^\d+\.\s/.test(n)) {
1129
+ const a = [];
1130
+ for (; s < t.length; )
1131
+ if (/^\d+\.\s/.test(t[s]))
1132
+ a.push(t[s].replace(/^\d+\.\s/, "")), s += 1;
1133
+ else if (!t[s].trim() && s + 1 < t.length && /^\d+\.\s/.test(t[s + 1]))
1134
+ s += 1;
1135
+ else
1136
+ break;
1137
+ e.push("<ol>" + a.map((l) => `<li>${g(l)}</li>`).join("") + "</ol>");
1138
+ continue;
1139
+ }
1140
+ if (!n.trim()) {
1141
+ s += 1;
1142
+ continue;
1143
+ }
1144
+ const o = [];
1145
+ for (; s < t.length && t[s].trim() && !t[s].startsWith("#") && !t[s].startsWith("```") && !t[s].startsWith("> ") && !/^[-*+]\s/.test(t[s]) && !/^\d+\.\s/.test(t[s]) && !/^---+$/.test(t[s].trim()); )
1146
+ o.push(t[s]), s += 1;
1147
+ o.length > 0 && e.push(`<p>${g(o.join(`
1148
+ `))}</p>`);
1149
+ }
1150
+ return e.join("");
1151
+ }
1152
+ function at(i) {
1153
+ return i.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (t, e) => {
1154
+ const s = e.toLowerCase();
1155
+ return rt.has(s) ? t : "";
1156
+ });
1157
+ }
1158
+ class kt extends u {
1159
+ static attributes = {
1160
+ role: { type: "string", default: "" },
1161
+ sender: { type: "string", default: "" },
1162
+ "avatar-align": { type: "enum", values: ["top", "center", "bottom"], default: "" }
1163
+ };
1164
+ #t;
1165
+ #e = null;
1166
+ #s = null;
1167
+ #i = null;
1168
+ constructor() {
1169
+ super(), this.#t = this.attachInternals();
1170
+ }
1171
+ // ── Lifecycle ─────────────────────────────────────────────
1172
+ activate() {
1173
+ this.#t.role = "group";
1174
+ const t = this.getAttribute("sender");
1175
+ t && this.setAttribute("aria-label", `Messages from ${t}`), this.addEffect(() => {
1176
+ const e = this.sender;
1177
+ e ? this.setAttribute("aria-label", `Messages from ${e}`) : this.removeAttribute("aria-label");
1178
+ }), this.#n(), this.#i = new MutationObserver((e) => {
1179
+ for (const s of e)
1180
+ for (const n of s.addedNodes)
1181
+ n instanceof Element && n.localName !== "aui-avatar" && (n === this.#e || n === this.#s || (n.localName === "aui-agent-message" ? this.#s?.appendChild(n) : this.#e?.appendChild(n)));
1182
+ }), this.#i.observe(this, { childList: !0 });
1183
+ }
1184
+ dispose() {
1185
+ if (this.#i?.disconnect(), this.#i = null, this.#s) {
1186
+ for (; this.#s.firstChild; )
1187
+ this.appendChild(this.#s.firstChild);
1188
+ this.#s.remove(), this.#s = null;
1189
+ }
1190
+ if (this.#e) {
1191
+ for (; this.#e.firstChild; )
1192
+ this.appendChild(this.#e.firstChild);
1193
+ this.#e.remove(), this.#e = null;
1194
+ }
1195
+ }
1196
+ // ── DOM wrapping ──────────────────────────────────────────
1197
+ #n() {
1198
+ const t = document.createElement("div");
1199
+ t.setAttribute("data-agent-context", "");
1200
+ const e = document.createElement("div");
1201
+ e.setAttribute("data-agent-bubbles", "");
1202
+ const s = Array.from(this.childNodes);
1203
+ for (const n of s)
1204
+ n instanceof Element && n.localName === "aui-avatar" || (n instanceof Element && n.localName === "aui-agent-message" ? e.appendChild(n) : t.appendChild(n));
1205
+ this.appendChild(t), this.appendChild(e), this.#e = t, this.#s = e;
1206
+ }
1207
+ }
1208
+ export {
1209
+ u as A,
1210
+ mt as B,
1211
+ pt as C,
1212
+ Y as D,
1213
+ st as R,
1214
+ ot as a,
1215
+ W as b,
1216
+ ft as c,
1217
+ V as d,
1218
+ dt as e,
1219
+ gt as f,
1220
+ kt as g,
1221
+ yt as h,
1222
+ Ct as i,
1223
+ bt as j,
1224
+ wt as k,
1225
+ Et as l,
1226
+ vt as m,
1227
+ At as n,
1228
+ K as o,
1229
+ J as p,
1230
+ ut as q,
1231
+ ct as r,
1232
+ k as s,
1233
+ ht as t,
1234
+ lt as u,
1235
+ G as v,
1236
+ et as w,
1237
+ O as x,
1238
+ at as y,
1239
+ _ as z
1240
+ };
1241
+ //# sourceMappingURL=agent-ciCayeod.js.map