@nonoun/native-chat 0.5.15 → 0.5.17

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 (88) hide show
  1. package/README.md +4 -0
  2. package/dist/adapter-mock-0s0RPkdx.js +795 -0
  3. package/dist/avatar/chat-avatar-element.d.ts +18 -0
  4. package/dist/avatar/chat-avatar-element.d.ts.map +1 -0
  5. package/dist/avatar/index.d.ts +2 -0
  6. package/dist/avatar/index.d.ts.map +1 -0
  7. package/dist/avatar/n-chat-avatar.d.ts +2 -0
  8. package/dist/avatar/n-chat-avatar.d.ts.map +1 -0
  9. package/dist/chat-input-element.d.ts +31 -0
  10. package/dist/chat-input-element.d.ts.map +1 -0
  11. package/dist/{chat-input-structured-element-C_5MDbpb.js → chat-input-structured-element-A3nMG2WR.js} +353 -204
  12. package/dist/chat-panel-element.d.ts +94 -0
  13. package/dist/chat-panel-element.d.ts.map +1 -0
  14. package/dist/feed/chat-feed-element.d.ts +48 -0
  15. package/dist/feed/chat-feed-element.d.ts.map +1 -0
  16. package/dist/feed/index.d.ts +2 -0
  17. package/dist/feed/index.d.ts.map +1 -0
  18. package/dist/feed/n-chat-feed.d.ts +2 -0
  19. package/dist/feed/n-chat-feed.d.ts.map +1 -0
  20. package/dist/gateway/adapter-chatgpt.d.ts +68 -0
  21. package/dist/gateway/adapter-chatgpt.d.ts.map +1 -0
  22. package/dist/gateway/adapter-claude.d.ts +69 -0
  23. package/dist/gateway/adapter-claude.d.ts.map +1 -0
  24. package/dist/gateway/adapter-mock.d.ts +3 -0
  25. package/dist/gateway/adapter-mock.d.ts.map +1 -0
  26. package/dist/gateway/adapter.d.ts +71 -0
  27. package/dist/gateway/adapter.d.ts.map +1 -0
  28. package/dist/gateway/controller.d.ts +50 -0
  29. package/dist/gateway/controller.d.ts.map +1 -0
  30. package/dist/gateway/index.d.ts +9 -0
  31. package/dist/gateway/index.d.ts.map +1 -0
  32. package/dist/gateway/runtime.d.ts +43 -0
  33. package/dist/gateway/runtime.d.ts.map +1 -0
  34. package/dist/gateway/types.d.ts +73 -0
  35. package/dist/gateway/types.d.ts.map +1 -0
  36. package/dist/gateway.d.ts +2 -0
  37. package/dist/gateway.d.ts.map +1 -0
  38. package/dist/gateway.js +35 -0
  39. package/dist/index.d.ts +18 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/message/chat-input-structured-element.d.ts +43 -0
  42. package/dist/message/chat-input-structured-element.d.ts.map +1 -0
  43. package/dist/message/chat-message-activity-element.d.ts +32 -0
  44. package/dist/message/chat-message-activity-element.d.ts.map +1 -0
  45. package/dist/message/chat-message-element.d.ts +44 -0
  46. package/dist/message/chat-message-element.d.ts.map +1 -0
  47. package/dist/message/chat-message-genui-element.d.ts +45 -0
  48. package/dist/message/chat-message-genui-element.d.ts.map +1 -0
  49. package/dist/message/chat-message-seed-element.d.ts +33 -0
  50. package/dist/message/chat-message-seed-element.d.ts.map +1 -0
  51. package/dist/message/chat-message-text-element.d.ts +37 -0
  52. package/dist/message/chat-message-text-element.d.ts.map +1 -0
  53. package/dist/message/chat-messages-element.d.ts +39 -0
  54. package/dist/message/chat-messages-element.d.ts.map +1 -0
  55. package/dist/message/index.d.ts +8 -0
  56. package/dist/message/index.d.ts.map +1 -0
  57. package/dist/message/n-chat-message.d.ts +2 -0
  58. package/dist/message/n-chat-message.d.ts.map +1 -0
  59. package/dist/native-chat.css +51 -29
  60. package/dist/native-chat.js +1 -1
  61. package/dist/register.d.ts +13 -0
  62. package/dist/register.d.ts.map +1 -0
  63. package/dist/register.js +3 -3
  64. package/dist/stream/classify.d.ts +19 -0
  65. package/dist/stream/classify.d.ts.map +1 -0
  66. package/dist/stream/create-transport.d.ts +19 -0
  67. package/dist/stream/create-transport.d.ts.map +1 -0
  68. package/dist/stream/index.d.ts +9 -0
  69. package/dist/stream/index.d.ts.map +1 -0
  70. package/dist/stream/parse-json.d.ts +9 -0
  71. package/dist/stream/parse-json.d.ts.map +1 -0
  72. package/dist/stream/parse-ndjson.d.ts +9 -0
  73. package/dist/stream/parse-ndjson.d.ts.map +1 -0
  74. package/dist/stream/parse-sse.d.ts +9 -0
  75. package/dist/stream/parse-sse.d.ts.map +1 -0
  76. package/dist/stream/types.d.ts +42 -0
  77. package/dist/stream/types.d.ts.map +1 -0
  78. package/dist/telemetry/emitter.d.ts +20 -0
  79. package/dist/telemetry/emitter.d.ts.map +1 -0
  80. package/dist/telemetry/events.d.ts +11 -0
  81. package/dist/telemetry/events.d.ts.map +1 -0
  82. package/dist/telemetry/index.d.ts +5 -0
  83. package/dist/telemetry/index.d.ts.map +1 -0
  84. package/dist/telemetry/redactor.d.ts +17 -0
  85. package/dist/telemetry/redactor.d.ts.map +1 -0
  86. package/dist/telemetry/types.d.ts +27 -0
  87. package/dist/telemetry/types.d.ts.map +1 -0
  88. package/package.json +5 -1
@@ -1,4 +1,5 @@
1
- import { NativeElement as e, VirtualScrollController as t, createDisabledEffect as n, signal as r, uid as i } from "@nonoun/native-ui";
1
+ import { o as e, r as t, t as n, u as r } from "./adapter-mock-0s0RPkdx.js";
2
+ import { NativeElement as i, VirtualScrollController as a, createDisabledEffect as o, signal as s, uid as c } from "@nonoun/native-ui";
2
3
  /**
3
4
  * Chat message input with textarea, submit button, and Enter-to-send behavior.
4
5
  * @attr {boolean} disabled - Disables interaction
@@ -10,11 +11,11 @@ import { NativeElement as e, VirtualScrollController as t, createDisabledEffect
10
11
  * @fires native:composer-focus - Fired when the composer textarea gains focus
11
12
  * @fires native:composer-blur - Fired when the composer textarea loses focus
12
13
  */
13
- var a = class extends e {
14
+ var l = class extends i {
14
15
  static observedAttributes = ["disabled", "busy"];
15
16
  #e;
16
- #t = r(!1);
17
- #n = r(!1);
17
+ #t = s(!1);
18
+ #n = s(!1);
18
19
  #r = null;
19
20
  #i = null;
20
21
  constructor() {
@@ -60,7 +61,7 @@ var a = class extends e {
60
61
  }
61
62
  }
62
63
  setup() {
63
- super.setup(), this.addEffect(n(this, this.#t, this.#e)), this.deferChildren(() => {
64
+ super.setup(), this.addEffect(o(this, this.#t, this.#e)), this.deferChildren(() => {
64
65
  this.#a(), this.addEffect(() => {
65
66
  let e = this.#t.value;
66
67
  this.#r && this.#r.toggleAttribute("disabled", e), this.#i && (e ? this.#i.setAttribute("disabled", "") : this.#s());
@@ -131,27 +132,39 @@ var a = class extends e {
131
132
  })) && !this.hasAttribute("no-auto-clear") && (this.value = "", this.#i?.setAttribute("disabled", ""));
132
133
  }
133
134
  }
134
- }, o = class extends e {
135
+ }, u = class extends i {
135
136
  static observedAttributes = [
136
137
  "show-stop",
137
138
  "show-restart",
138
139
  "auto-focus-policy",
139
140
  "open",
140
- "model"
141
+ "model",
142
+ "gateway",
143
+ "gateway-url",
144
+ "gateway-config"
141
145
  ];
142
- #e = r(!1);
143
- #t = r(!1);
144
- #n = r("open-request");
145
- #r = r(!1);
146
- #i = r([]);
147
- #a = r(null);
148
- #o = null;
149
- #s = null;
150
- #c = null;
151
- #l = null;
146
+ #e = s(!1);
147
+ #t = s(!1);
148
+ #n = s("open-request");
149
+ #r = s(!1);
150
+ #i = s([]);
151
+ #a = s(null);
152
+ #o = s(null);
153
+ #s = s(null);
154
+ #c = s(null);
155
+ #l = s(!1);
152
156
  #u = null;
153
- #d = null;
154
- #f = r(!1);
157
+ #d = [];
158
+ #f = null;
159
+ #p = null;
160
+ #m = null;
161
+ #h = null;
162
+ #g = null;
163
+ #_ = null;
164
+ #v = null;
165
+ #y = null;
166
+ #b = null;
167
+ #x = null;
155
168
  attributeChangedCallback(e, t, n) {
156
169
  if (t !== n) {
157
170
  switch (e) {
@@ -166,12 +179,25 @@ var a = class extends e {
166
179
  break;
167
180
  case "open": {
168
181
  let e = this.#r.value;
169
- this.#r.value = n !== null, !e && n !== null ? this.#_(void 0, !1) : e && n === null && this.#v(void 0);
182
+ this.#r.value = n !== null, !e && n !== null ? this.#E(void 0, !1) : e && n === null && this.#D(void 0);
170
183
  break;
171
184
  }
172
185
  case "model":
173
186
  this.#a.value = n;
174
187
  break;
188
+ case "gateway":
189
+ this.#o.value = n;
190
+ break;
191
+ case "gateway-url":
192
+ this.#s.value = n;
193
+ break;
194
+ case "gateway-config":
195
+ try {
196
+ this.#c.value = n ? JSON.parse(n) : null;
197
+ } catch {
198
+ this.#c.value = null;
199
+ }
200
+ break;
175
201
  }
176
202
  super.attributeChangedCallback(e, t, n);
177
203
  }
@@ -208,120 +234,161 @@ var a = class extends e {
208
234
  set model(e) {
209
235
  this.#a.value = e, e === null ? this.removeAttribute("model") : this.setAttribute("model", e);
210
236
  }
237
+ /** Gateway adapter type: 'openai' or 'claude'. When set, panel handles send/stream automatically. */
238
+ get gateway() {
239
+ return this.#o.value;
240
+ }
241
+ set gateway(e) {
242
+ this.#o.value = e, e ? this.setAttribute("gateway", e) : this.removeAttribute("gateway");
243
+ }
244
+ /** Base URL for the gateway API. */
245
+ get gatewayUrl() {
246
+ return this.#s.value;
247
+ }
248
+ set gatewayUrl(e) {
249
+ this.#s.value = e, e ? this.setAttribute("gateway-url", e) : this.removeAttribute("gateway-url");
250
+ }
251
+ /** Configuration for the gateway adapter (model, apiKey, system, etc.). */
252
+ get gatewayConfig() {
253
+ return this.#c.value;
254
+ }
255
+ set gatewayConfig(e) {
256
+ this.#c.value = e, e ? this.setAttribute("gateway-config", JSON.stringify(e)) : this.removeAttribute("gateway-config");
257
+ }
258
+ /** Whether the panel is currently streaming a response. Read-only. */
259
+ get streaming() {
260
+ return this.#l.value;
261
+ }
211
262
  /** Open the panel. Optionally focus the composer. */
212
263
  open(e) {
213
264
  let t = this.#r.value;
214
265
  this.#r.value = !0, this.toggleAttribute("open", !0);
215
266
  let n = this.#n.value, r = e?.focusComposer ?? !1, i = n !== "never" && (n === "open-request" ? r : !1);
216
- t || this.#_(e?.reason, i), i && this.focusComposer({ cursor: "end" }, "api");
267
+ t || this.#E(e?.reason, i), i && this.focusComposer({ cursor: "end" }, "api");
217
268
  }
218
269
  /** Close the panel. */
219
270
  close(e) {
220
271
  let t = this.#r.value;
221
- this.#r.value = !1, this.removeAttribute("open"), t && this.#v(e);
272
+ this.#r.value = !1, this.removeAttribute("open"), t && this.#D(e);
222
273
  }
223
274
  /** Focus the composer input. */
224
275
  focusComposer(e, t = "api") {
225
- this.#m(e ?? {}, t, 0);
276
+ this.#C(e ?? {}, t, 0);
226
277
  }
227
278
  setup() {
228
279
  super.setup(), this.hasAttribute("open") && (this.#r.value = !0);
229
- let e = document.createElement("n-header");
230
- e.setAttribute("dividers", "");
231
- let t = document.createElement("n-icon");
232
- t.setAttribute("name", "chat-dots"), t.setAttribute("slot", "leading"), e.appendChild(t);
233
- let n = document.createElement("span");
234
- n.setAttribute("slot", "label"), n.textContent = "Assistant", e.appendChild(n);
235
- let r = document.createElement("span");
236
- r.setAttribute("slot", "trailing"), r.style.display = "inline-flex", r.style.alignItems = "center", r.style.gap = "calc(var(--n-space) * 2)", e.appendChild(r), this.#l = r;
237
- let i = document.createElement("n-body"), a = document.createElement("n-chat-content");
238
- i.appendChild(a);
239
- let o = document.createElement("n-footer");
240
- o.setAttribute("dividers", ""), this.#o = o;
241
- let s = document.createElement("n-chat-input");
242
- s.setAttribute("variant", "plain");
243
- let c = document.createElement("n-textarea");
244
- c.setAttribute("placeholder", "Ask anything"), c.setAttribute("autogrow", ""), c.setAttribute("rows", "3"), s.appendChild(c);
245
- let l = document.createElement("n-chat-input-actions"), u = document.createElement("n-button");
246
- u.setAttribute("variant", "ghost"), u.setAttribute("inline", ""), u.innerHTML = "<n-icon name=\"plus\"></n-icon>", l.appendChild(u);
247
- let d = document.createElement("n-button");
248
- d.setAttribute("variant", "ghost"), d.setAttribute("inline", ""), d.innerHTML = "<n-icon name=\"microphone\"></n-icon>", l.appendChild(d);
249
- let f = document.createElement("n-button");
250
- f.setAttribute("variant", "primary"), f.setAttribute("intent", "accent"), f.setAttribute("radius", "round"), f.setAttribute("inline", ""), f.setAttribute("disabled", ""), f.dataset.role = "submit", f.innerHTML = "<n-icon name=\"arrow-up\"></n-icon>", l.appendChild(f), s.appendChild(l), o.appendChild(s), this.append(e, i, o), this.addEffect(() => {
280
+ let i = document.createElement("n-header");
281
+ i.setAttribute("dividers", "");
282
+ let a = document.createElement("n-icon");
283
+ a.setAttribute("name", "chat-dots"), a.setAttribute("slot", "leading"), i.appendChild(a);
284
+ let o = document.createElement("span");
285
+ o.setAttribute("slot", "label"), o.textContent = "Assistant", i.appendChild(o);
286
+ let s = document.createElement("span");
287
+ s.setAttribute("slot", "trailing"), s.style.display = "inline-flex", s.style.alignItems = "center", s.style.gap = "calc(var(--n-space) * 2)", i.appendChild(s), this.#v = s;
288
+ let c = document.createElement("n-body"), l = document.createElement("n-chat-content"), u = document.createElement("n-chat-feed");
289
+ u.setAttribute("auto-scroll", ""), l.appendChild(u), this.#h = u, c.appendChild(l);
290
+ let d = document.createElement("n-footer");
291
+ d.setAttribute("dividers", ""), this.#m = d;
292
+ let f = document.createElement("n-chat-input"), p = document.createElement("n-textarea");
293
+ p.setAttribute("placeholder", "Ask anything"), p.setAttribute("autogrow", ""), p.setAttribute("rows", "3"), f.appendChild(p);
294
+ let m = document.createElement("n-chat-input-actions");
295
+ this.#y = m;
296
+ let h = document.createElement("n-button");
297
+ h.setAttribute("variant", "ghost"), h.setAttribute("inline", ""), h.innerHTML = "<n-icon name=\"plus\"></n-icon>", m.appendChild(h);
298
+ let g = document.createElement("n-button");
299
+ g.setAttribute("variant", "ghost"), g.setAttribute("inline", ""), g.innerHTML = "<n-icon name=\"microphone\"></n-icon>", m.appendChild(g);
300
+ let _ = document.createElement("n-button");
301
+ _.setAttribute("variant", "primary"), _.setAttribute("intent", "accent"), _.setAttribute("radius", "round"), _.setAttribute("inline", ""), _.setAttribute("disabled", ""), _.dataset.submit = "", _.dataset.role = "submit", _.innerHTML = "<n-icon name=\"arrow-up\"></n-icon>", m.appendChild(_), f.appendChild(m), d.appendChild(f), this.append(i, c, d), this.addEffect(() => {
251
302
  let e = this.#e.value;
252
- if (e && !this.#s) {
303
+ if (e && !this.#g) {
253
304
  let e = document.createElement("n-button");
254
- e.setAttribute("variant", "ghost"), e.setAttribute("inline", ""), e.setAttribute("aria-label", "Stop"), e.innerHTML = "<n-icon name=\"stop\"></n-icon>", e.addEventListener("native:press", this.#b), this.#s = e, this.#l?.prepend(e);
255
- } else !e && this.#s && (this.#s.removeEventListener("native:press", this.#b), this.#s.remove(), this.#s = null);
305
+ e.setAttribute("variant", "ghost"), e.setAttribute("inline", ""), e.setAttribute("aria-label", "Stop"), e.innerHTML = "<n-icon name=\"stop\"></n-icon>", e.addEventListener("native:press", this.#k), this.#g = e, this.#v?.prepend(e);
306
+ } else !e && this.#g && (this.#g.removeEventListener("native:press", this.#k), this.#g.remove(), this.#g = null);
256
307
  }), this.addEffect(() => {
257
308
  let e = this.#t.value;
258
- if (e && !this.#c) {
309
+ if (e && !this.#_) {
259
310
  let e = document.createElement("n-button");
260
- e.setAttribute("variant", "ghost"), e.setAttribute("inline", ""), e.setAttribute("aria-label", "Restart"), e.innerHTML = "<n-icon name=\"arrow-counter-clockwise\"></n-icon>", e.addEventListener("native:press", this.#x), this.#c = e;
261
- let t = this.#s?.nextSibling ?? this.#l?.firstChild ?? null;
262
- this.#l?.insertBefore(e, t);
263
- } else !e && this.#c && (this.#c.removeEventListener("native:press", this.#x), this.#c.remove(), this.#c = null);
311
+ e.setAttribute("variant", "ghost"), e.setAttribute("inline", ""), e.setAttribute("aria-label", "Restart"), e.innerHTML = "<n-icon name=\"arrow-counter-clockwise\"></n-icon>", e.addEventListener("native:press", this.#A), this.#_ = e;
312
+ let t = this.#g?.nextSibling ?? this.#v?.firstChild ?? null;
313
+ this.#v?.insertBefore(e, t);
314
+ } else !e && this.#_ && (this.#_.removeEventListener("native:press", this.#A), this.#_.remove(), this.#_ = null);
264
315
  }), this.addEffect(() => {
265
316
  let e = this.#i.value;
266
- if (e.length > 0 && !this.#u) {
267
- let e = document.createElement("n-button");
268
- e.setAttribute("variant", "ghost"), e.setAttribute("inline", ""), e.setAttribute("aria-label", "Select model"), e.setAttribute("data-role", "model-picker"), e.innerHTML = "<span data-role=\"model-label\"></span><n-icon name=\"caret-up-down\"></n-icon>", e.addEventListener("native:press", this.#S), this.#u = e;
269
- let t = document.createElement("n-listbox");
270
- t.setAttribute("popover", "auto"), t.setAttribute("data-role", "model-listbox"), t.addEventListener("native:change", this.#C), this.#d = t, this.#l?.prepend(e), this.#l?.appendChild(t);
271
- } else e.length === 0 && this.#u && this.#w();
317
+ if (e.length > 0 && !this.#b) {
318
+ let e = document.createElement("n-select");
319
+ e.setAttribute("aria-label", "Select model"), e.setAttribute("data-role", "model-picker"), e.addEventListener("native:change", this.#j);
320
+ let t = document.createElement("n-button");
321
+ t.setAttribute("variant", "ghost"), t.setAttribute("inline", ""), t.innerHTML = "<n-icon name=\"dots-three-outline-fill\"></n-icon>";
322
+ let n = document.createElement("n-listbox");
323
+ n.setAttribute("popover", "manual"), e.append(t, n), this.#b = e, this.#x = n;
324
+ let r = this.#y?.querySelector("[data-submit]");
325
+ r ? this.#y?.insertBefore(e, r) : this.#y?.appendChild(e);
326
+ } else e.length === 0 && this.#b && this.#z();
272
327
  }), this.addEffect(() => {
273
- let e = this.#i.value, t = this.#a.value, n = this.#d, r = this.#u;
328
+ let e = this.#i.value, t = this.#a.value, n = this.#b, r = this.#x;
274
329
  if (!n || !r || e.length === 0) return;
275
- n.innerHTML = "";
276
- for (let t of e) {
277
- let e = document.createElement("n-option");
278
- e.setAttribute("value", t.value), e.textContent = t.label ?? t.value, n.appendChild(e);
330
+ let i = t ?? e[0]?.value ?? null;
331
+ if (i !== null) {
332
+ r.innerHTML = "";
333
+ for (let [t, n] of this.#R(e)) {
334
+ let e = document.createElement("n-option-group"), a = document.createElement("n-option-group-header");
335
+ a.textContent = t, e.appendChild(a);
336
+ for (let t of n) {
337
+ let n = document.createElement("n-option"), r = t.value === i;
338
+ n.setAttribute("value", t.value), n.setAttribute("aria-selected", String(r)), n.textContent = `${r ? "✓ " : ""}${t.label ?? t.value}`, e.appendChild(n);
339
+ }
340
+ r.appendChild(e);
341
+ }
342
+ t === null && (this.#a.value = i, this.setAttribute("model", i)), n.value = i;
279
343
  }
280
- t && (n.value = t);
281
- let i = r.querySelector("[data-role=\"model-label\"]");
282
- if (i) {
283
- let n = e.find((e) => e.value === t);
284
- i.textContent = n ? n.label ?? n.value : e[0].label ?? e[0].value;
344
+ }), this.addEffect(() => {
345
+ let i = this.#o.value, a = this.#s.value, o = this.#c.value;
346
+ if (!i || !a) {
347
+ this.#u = null;
348
+ return;
285
349
  }
350
+ let s = {
351
+ clientId: this.#p ?? r(),
352
+ baseUrl: a,
353
+ gatewayConfig: o ?? {}
354
+ };
355
+ i === "openai" ? this.#u = e(s) : i === "claude" ? this.#u = t(s) : i === "mock" ? this.#u = n(s) : this.#u = null;
286
356
  }), this.addEffect(() => {
287
- let e = this.#f.value, t = this.#d;
288
- if (t) try {
289
- e ? t.showPopover() : t.hidePopover();
290
- } catch {}
291
- }), this.deferChildren(() => {
292
- this.#p();
357
+ this.#o.value && (this.#e.value = this.#l.value);
358
+ }), this.addEventListener("native:send", this.#M), this.addEventListener("native:chat-stop", this.#I), this.addEventListener("native:chat-restart", this.#L), this.deferChildren(() => {
359
+ this.#S();
293
360
  }), this.#n.value === "ready" && queueMicrotask(() => {
294
361
  this.isConnected && this.focusComposer({ cursor: "end" }, "policy");
295
362
  });
296
363
  }
297
364
  teardown() {
298
- this.#s && this.#s.removeEventListener("native:press", this.#b), this.#c && this.#c.removeEventListener("native:press", this.#x), this.#w(), this.#o = null, this.#s = null, this.#c = null, this.#l = null, this.innerHTML = "", super.teardown();
365
+ this.#f?.abort(), this.removeEventListener("native:send", this.#M), this.removeEventListener("native:chat-stop", this.#I), this.removeEventListener("native:chat-restart", this.#L), this.#g && this.#g.removeEventListener("native:press", this.#k), this.#_ && this.#_.removeEventListener("native:press", this.#A), this.#z(), this.#u = null, this.#d = [], this.#f = null, this.#m = null, this.#h = null, this.#g = null, this.#_ = null, this.#v = null, this.#y = null, this.#x = null, this.innerHTML = "", super.teardown();
299
366
  }
300
- #p() {
367
+ #S() {
301
368
  let e = this.querySelector(":scope > [slot=\"header-trailing\"]");
302
- e && this.#l && this.#l.appendChild(e);
369
+ e && this.#v && this.#v.appendChild(e);
303
370
  let t = this.querySelector(":scope > [slot=\"footer-leading\"]");
304
- if (t && this.#o) {
305
- let e = this.#o.querySelector(":scope > n-chat-input");
306
- this.#o.insertBefore(t, e);
371
+ if (t && this.#m) {
372
+ let e = this.#m.querySelector(":scope > n-chat-input");
373
+ this.#m.insertBefore(t, e);
307
374
  }
308
375
  }
309
- #m(e, t, n) {
310
- let r = this.#h();
376
+ #C(e, t, n) {
377
+ let r = this.#w();
311
378
  if (!r) {
312
379
  if (n < 2) {
313
- queueMicrotask(() => this.#m(e, t, n + 1));
380
+ queueMicrotask(() => this.#C(e, t, n + 1));
314
381
  return;
315
382
  }
316
- this.#y("composer-unavailable", 3);
383
+ this.#O("composer-unavailable", 3);
317
384
  return;
318
385
  }
319
386
  if (r.disabled) {
320
387
  if (n < 2) {
321
- queueMicrotask(() => this.#m(e, t, n + 1));
388
+ queueMicrotask(() => this.#C(e, t, n + 1));
322
389
  return;
323
390
  }
324
- this.#y("disabled", 3);
391
+ this.#O("disabled", 3);
325
392
  return;
326
393
  }
327
394
  let i = r.querySelector("n-textarea"), a = i ?? r;
@@ -329,22 +396,22 @@ var a = class extends e {
329
396
  a.focus();
330
397
  } catch {
331
398
  if (n < 2) {
332
- queueMicrotask(() => this.#m(e, t, n + 1));
399
+ queueMicrotask(() => this.#C(e, t, n + 1));
333
400
  return;
334
401
  }
335
- this.#y("blocked", 3);
402
+ this.#O("blocked", 3);
336
403
  return;
337
404
  }
338
- e.cursor && e.cursor !== "preserve" && i && this.#g(i, e.cursor), this.dispatchEvent(new CustomEvent("native:composer-focused", {
405
+ e.cursor && e.cursor !== "preserve" && i && this.#T(i, e.cursor), this.dispatchEvent(new CustomEvent("native:composer-focused", {
339
406
  bubbles: !0,
340
407
  composed: !0,
341
408
  detail: { by: t }
342
409
  }));
343
410
  }
344
- #h() {
411
+ #w() {
345
412
  return this.querySelector("n-chat-input");
346
413
  }
347
- #g(e, t) {
414
+ #T(e, t) {
348
415
  let n = e.ownerDocument.getSelection?.();
349
416
  if (!n) return;
350
417
  let r = e.firstChild ?? e, i = t === "end" ? r.textContent?.length ?? 0 : 0;
@@ -353,7 +420,7 @@ var a = class extends e {
353
420
  e.setStart(r, i), e.collapse(!0), n.removeAllRanges(), n.addRange(e);
354
421
  } catch {}
355
422
  }
356
- #_(e, t) {
423
+ #E(e, t) {
357
424
  this.dispatchEvent(new CustomEvent("native:chat-opened", {
358
425
  bubbles: !0,
359
426
  composed: !0,
@@ -363,14 +430,14 @@ var a = class extends e {
363
430
  }
364
431
  }));
365
432
  }
366
- #v(e) {
433
+ #D(e) {
367
434
  this.dispatchEvent(new CustomEvent("native:chat-closed", {
368
435
  bubbles: !0,
369
436
  composed: !0,
370
437
  detail: { reason: e }
371
438
  }));
372
439
  }
373
- #y(e, t) {
440
+ #O(e, t) {
374
441
  this.dispatchEvent(new CustomEvent("native:composer-focus-failed", {
375
442
  bubbles: !0,
376
443
  composed: !0,
@@ -380,42 +447,124 @@ var a = class extends e {
380
447
  }
381
448
  }));
382
449
  }
383
- #b = () => {
450
+ #k = () => {
384
451
  this.dispatchEvent(new CustomEvent("native:chat-stop", {
385
452
  bubbles: !0,
386
453
  composed: !0
387
454
  }));
388
455
  };
389
- #x = () => {
456
+ #A = () => {
390
457
  this.dispatchEvent(new CustomEvent("native:chat-restart", {
391
458
  bubbles: !0,
392
459
  composed: !0
393
460
  }));
394
461
  };
395
- #S = () => {
396
- this.#f.value = !this.#f.value;
397
- };
398
- #C = (e) => {
462
+ #j = (e) => {
399
463
  let t = e.detail?.value ?? null;
400
464
  if (t === null) return;
401
465
  let n = this.#a.value;
402
- if (t === n) {
403
- this.#f.value = !1;
404
- return;
405
- }
406
- this.#a.value = t, this.setAttribute("model", t), this.#f.value = !1, this.dispatchEvent(new CustomEvent("native:model-change", {
466
+ t !== n && (this.#a.value = t, this.setAttribute("model", t), this.dispatchEvent(new CustomEvent("native:model-change", {
407
467
  bubbles: !0,
408
468
  composed: !0,
409
469
  detail: {
410
470
  value: t,
411
471
  previousValue: n
412
472
  }
413
- }));
473
+ })));
414
474
  };
415
- #w() {
416
- this.#u &&= (this.#u.removeEventListener("native:press", this.#S), this.#u.remove(), null), this.#d &&= (this.#d.removeEventListener("native:change", this.#C), this.#d.remove(), null), this.#f.value = !1;
475
+ #M = (e) => {
476
+ if (!this.#u) return;
477
+ let t = e.detail?.value;
478
+ t?.trim() && this.#N(t);
479
+ };
480
+ async #N(e) {
481
+ let t = this.#u;
482
+ if (!t || this.#l.value) return;
483
+ this.#f?.abort();
484
+ let n = new AbortController();
485
+ this.#f = n;
486
+ let i = {
487
+ role: "user",
488
+ message: e,
489
+ datetime: Date.now()
490
+ };
491
+ this.#d.push(i), this.#P(i);
492
+ let a = `msg-${Date.now()}-a`, o = this.#F(a), s = o?.querySelector("n-chat-message-text");
493
+ this.#l.value = !0;
494
+ try {
495
+ let i = await t.sendMessageStream({
496
+ id: this.#p ?? r(),
497
+ messages: this.#d,
498
+ query: e,
499
+ model: this.#a.value ?? void 0,
500
+ signal: n.signal,
501
+ onChunk: (e) => {
502
+ s && (s.content = e.fullMessage), e.done && o?.setAttribute("status", e.partial ? "partial" : "sent");
503
+ }
504
+ });
505
+ this.#d.push({
506
+ role: "assistant",
507
+ message: i.message,
508
+ datetime: i.datetime ?? Date.now(),
509
+ partial: i.partial
510
+ });
511
+ } catch (e) {
512
+ if (e.name === "AbortError") return;
513
+ o?.setAttribute("status", "error"), s && (s.content = `Error: ${e.message}`);
514
+ } finally {
515
+ this.#l.value = !1, this.#f = null;
516
+ }
517
+ }
518
+ #P(e) {
519
+ let t = this.#h;
520
+ if (!t) return;
521
+ let n = document.createElement("n-chat-messages");
522
+ n.setAttribute("role", e.role), n.setAttribute("sender", e.role === "user" ? "You" : "Assistant");
523
+ let r = document.createElement("n-chat-message");
524
+ r.setAttribute("role", e.role), r.setAttribute("message-id", `msg-${Date.now()}`), r.setAttribute("status", "sent");
525
+ let i = document.createElement("n-chat-message-text");
526
+ i.content = e.message, r.appendChild(i), n.appendChild(r), t.appendChild(n);
527
+ }
528
+ #F(e) {
529
+ let t = this.#h;
530
+ if (!t) return null;
531
+ let n = document.createElement("n-chat-messages");
532
+ n.setAttribute("role", "assistant"), n.setAttribute("sender", "Assistant");
533
+ let r = document.createElement("n-chat-message");
534
+ r.setAttribute("role", "assistant"), r.setAttribute("message-id", e), r.setAttribute("status", "streaming");
535
+ let i = document.createElement("n-chat-message-text");
536
+ return r.appendChild(i), n.appendChild(r), t.appendChild(n), r;
537
+ }
538
+ #I = () => {
539
+ this.#u && (this.#f?.abort(), this.#l.value = !1);
540
+ };
541
+ #L = () => {
542
+ this.#u && (this.#f?.abort(), this.#l.value = !1, this.#d = [], this.#h && (this.#h.innerHTML = ""));
543
+ };
544
+ #R(e) {
545
+ let t = /* @__PURE__ */ new Map(), n = (e) => {
546
+ let t = `${e.label ?? ""} ${e.value}`.toLowerCase();
547
+ return t.includes("claude") ? "Claude" : t.includes("gpt") || t.includes("openai") ? "ChatGPT" : t.includes("gemini") ? "Gemini" : "Models";
548
+ };
549
+ for (let r of e) {
550
+ let e = n(r);
551
+ t.has(e) || t.set(e, []), t.get(e).push(r);
552
+ }
553
+ let r = [
554
+ "Claude",
555
+ "ChatGPT",
556
+ "Gemini",
557
+ "Models"
558
+ ];
559
+ return Array.from(t.entries()).sort((e, t) => {
560
+ let n = r.indexOf(e[0]), i = r.indexOf(t[0]);
561
+ return (n === -1 ? 999 : n) - (i === -1 ? 999 : i);
562
+ });
563
+ }
564
+ #z() {
565
+ this.#b &&= (this.#b.removeEventListener("native:change", this.#j), this.#b.remove(), null), this.#x = null;
417
566
  }
418
- }, s = 40, c = class extends e {
567
+ }, d = 40, f = class extends i {
419
568
  static observedAttributes = [
420
569
  "auto-scroll",
421
570
  "scrollable",
@@ -424,12 +573,12 @@ var a = class extends e {
424
573
  "virtual-overscan"
425
574
  ];
426
575
  #e;
427
- #t = r(!0);
428
- #n = r(!0);
576
+ #t = s(!0);
577
+ #n = s(!0);
429
578
  #r = null;
430
579
  #i = null;
431
580
  #a = null;
432
- #o = r([]);
581
+ #o = s([]);
433
582
  #s = null;
434
583
  constructor() {
435
584
  super(), this.#e = this.attachInternals();
@@ -488,10 +637,10 @@ var a = class extends e {
488
637
  }
489
638
  #c() {
490
639
  if (this.#i) return;
491
- let e = Number(this.getAttribute("virtual-item-height")) || 80, n = Number(this.getAttribute("virtual-overscan")) || 5;
492
- for (this.#i = new t(this, {
640
+ let e = Number(this.getAttribute("virtual-item-height")) || 80, t = Number(this.getAttribute("virtual-overscan")) || 5;
641
+ for (this.#i = new a(this, {
493
642
  itemHeight: e,
494
- overscan: n
643
+ overscan: t
495
644
  }), this.#a = document.createElement("div"), this.#a.className = "n-chat-feed-virtual-container"; this.firstChild;) this.#a.appendChild(this.firstChild);
496
645
  this.appendChild(this.#a), this.#i.enable(this, this.#a, this.#o.value.length), this.addEventListener("native:virtual-change", this.#u);
497
646
  }
@@ -524,7 +673,7 @@ var a = class extends e {
524
673
  }
525
674
  }
526
675
  #f = () => {
527
- let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight - s;
676
+ let e = this.#n.value, t = this.scrollTop + this.clientHeight >= this.scrollHeight - d;
528
677
  this.#n.value = t, t !== e && this.dispatchEvent(new CustomEvent("native:feed-scroll", {
529
678
  bubbles: !0,
530
679
  composed: !0,
@@ -543,15 +692,15 @@ var a = class extends e {
543
692
  });
544
693
  };
545
694
  #m = (e) => {};
546
- }, l = class extends e {
695
+ }, p = class extends i {
547
696
  static observedAttributes = [
548
697
  "src",
549
698
  "name",
550
699
  "icon"
551
700
  ];
552
- #e = r("");
553
- #t = r("");
554
- #n = r("");
701
+ #e = s("");
702
+ #t = s("");
703
+ #n = s("");
555
704
  attributeChangedCallback(e, t, n) {
556
705
  if (t !== n) {
557
706
  switch (e) {
@@ -583,7 +732,7 @@ var a = class extends e {
583
732
  }
584
733
  if (n) {
585
734
  let e = document.createElement("span");
586
- e.className = "n-chat-avatar-initials", e.textContent = u(n), e.setAttribute("aria-hidden", "true"), this.appendChild(e);
735
+ e.className = "n-chat-avatar-initials", e.textContent = m(n), e.setAttribute("aria-hidden", "true"), this.appendChild(e);
587
736
  return;
588
737
  }
589
738
  let r = document.createElement("n-icon");
@@ -594,11 +743,11 @@ var a = class extends e {
594
743
  this.textContent = "", super.teardown();
595
744
  }
596
745
  };
597
- function u(e) {
746
+ function m(e) {
598
747
  let t = e.trim().split(/\s+/);
599
748
  return t.length === 0 ? "" : t.length === 1 ? t[0][0].toUpperCase() : (t[0][0] + t[t.length - 1][0]).toUpperCase();
600
749
  }
601
- const d = {
750
+ const h = {
602
751
  copy: {
603
752
  label: "Copy",
604
753
  icon: "copy"
@@ -623,7 +772,7 @@ const d = {
623
772
  label: "Continue",
624
773
  icon: "arrow-right"
625
774
  }
626
- }, f = {
775
+ }, g = {
627
776
  assistant: [
628
777
  "copy",
629
778
  "retry",
@@ -648,7 +797,7 @@ const d = {
648
797
  * @fires native:message-action - Fired when an action button is clicked
649
798
  * @fires native:continue-request - Fired when continue is requested for a partial message
650
799
  */
651
- var p = class extends e {
800
+ var _ = class extends i {
652
801
  static observedAttributes = [
653
802
  "role",
654
803
  "message-id",
@@ -659,11 +808,11 @@ var p = class extends e {
659
808
  "actions-position"
660
809
  ];
661
810
  #e;
662
- #t = r("assistant");
663
- #n = r("sent");
664
- #r = r(null);
665
- #i = r("icon");
666
- #a = r("below");
811
+ #t = s("assistant");
812
+ #n = s("sent");
813
+ #r = s(null);
814
+ #i = s("icon");
815
+ #a = s("below");
667
816
  #o = null;
668
817
  #s = !1;
669
818
  #c = 0;
@@ -764,23 +913,23 @@ var p = class extends e {
764
913
  this.#o.removeEventListener("native:press", this.#m), this.#o.remove();
765
914
  }
766
915
  }
767
- #p(e, t, n, r, a) {
916
+ #p(e, t, n, r, i) {
768
917
  if (this.#o &&= (this.#f(), null), clearTimeout(this.#l), t === "none" || this.querySelector("[slot=\"actions\"]")) return;
769
- let o;
770
- if (o = t ? t.split(",").map((e) => e.trim()).filter(Boolean) : f[e] ?? [], a === "partial" && !o.includes("continue") && (o = [...o, "continue"]), o.length === 0) return;
771
- let s = document.createElement("n-toolbar");
772
- s.dataset.role = "actions", s.setAttribute("padding", "tight"), s.setAttribute("aria-label", "Message actions"), n !== "label" && s.setAttribute("data-style", n);
773
- for (let e of o) {
774
- let t = d[e];
775
- t && s.appendChild(m(e, t, n));
918
+ let a;
919
+ if (a = t ? t.split(",").map((e) => e.trim()).filter(Boolean) : g[e] ?? [], i === "partial" && !a.includes("continue") && (a = [...a, "continue"]), a.length === 0) return;
920
+ let o = document.createElement("n-toolbar");
921
+ o.dataset.role = "actions", o.setAttribute("padding", "tight"), o.setAttribute("aria-label", "Message actions"), n !== "label" && o.setAttribute("data-style", n);
922
+ for (let e of a) {
923
+ let t = h[e];
924
+ t && o.appendChild(v(e, t, n));
776
925
  }
777
- if (s.children.length !== 0) {
778
- if (s.addEventListener("native:press", this.#m), r === "below") {
779
- s.setAttribute("popover", "manual");
780
- let e = i("msg");
781
- this.style.setProperty("anchor-name", `--${e}`), s.style.setProperty("position-anchor", `--${e}`), this.appendChild(s), this.#s = !0, s.addEventListener("pointerenter", this.#u), s.addEventListener("pointerleave", this.#d), s.addEventListener("focusin", this.#u), s.addEventListener("focusout", this.#d), a === "partial" && s.showPopover();
782
- } else this.appendChild(s);
783
- this.#o = s;
926
+ if (o.children.length !== 0) {
927
+ if (o.addEventListener("native:press", this.#m), r === "below") {
928
+ o.setAttribute("popover", "manual");
929
+ let e = c("msg");
930
+ this.style.setProperty("anchor-name", `--${e}`), o.style.setProperty("position-anchor", `--${e}`), this.appendChild(o), this.#s = !0, o.addEventListener("pointerenter", this.#u), o.addEventListener("pointerleave", this.#d), o.addEventListener("focusin", this.#u), o.addEventListener("focusout", this.#d), i === "partial" && o.showPopover();
931
+ } else this.appendChild(o);
932
+ this.#o = o;
784
933
  }
785
934
  }
786
935
  #m = (e) => {
@@ -805,7 +954,7 @@ var p = class extends e {
805
954
  }
806
955
  };
807
956
  };
808
- function m(e, t, n) {
957
+ function v(e, t, n) {
809
958
  let r = document.createElement("n-button");
810
959
  if (r.setAttribute("variant", "ghost"), r.setAttribute("size", "sm"), r.setAttribute("inline", ""), r.setAttribute("data-action", e), r.setAttribute("aria-label", t.label), n === "icon" || n === "icon-label") {
811
960
  let e = document.createElement("n-icon");
@@ -842,7 +991,7 @@ function m(e, t, n) {
842
991
  * @attr {string} sender - Display name of the sender
843
992
  * @attr {string} avatar-align - `"top"` | `"center"` | `"bottom"` (default) — avatar vertical alignment
844
993
  */
845
- var h = class extends e {
994
+ var y = class extends i {
846
995
  static observedAttributes = [
847
996
  "role",
848
997
  "sender",
@@ -885,10 +1034,10 @@ var h = class extends e {
885
1034
  for (let r of n) r instanceof Element && r.localName === "n-chat-avatar" || (r instanceof Element && r.localName === "n-chat-message" ? t.appendChild(r) : e.appendChild(r));
886
1035
  this.appendChild(e), this.appendChild(t), this.#t = e, this.#n = t;
887
1036
  }
888
- }, g = class extends e {
1037
+ }, b = class extends i {
889
1038
  static observedAttributes = ["format"];
890
- #e = r("markdown");
891
- #t = r("");
1039
+ #e = s("markdown");
1040
+ #t = s("");
892
1041
  #n = null;
893
1042
  get content() {
894
1043
  return this.#t.value;
@@ -909,14 +1058,14 @@ var h = class extends e {
909
1058
  super.setup(), this.deferChildren(() => {
910
1059
  !this.#t.value && this.textContent?.trim() && (this.#t.value = this.textContent.trim()), this.#n = document.createElement("div"), this.#n.className = "n-chat-prose", this.textContent = "", this.appendChild(this.#n), this.addEffect(() => {
911
1060
  let e = this.#t.value, t = this.#e.value;
912
- this.#n && (t === "plain" ? this.#n.textContent = e : this.#n.innerHTML = b(e));
1061
+ this.#n && (t === "plain" ? this.#n.textContent = e : this.#n.innerHTML = w(e));
913
1062
  });
914
1063
  });
915
1064
  }
916
1065
  teardown() {
917
1066
  this.#n = null, super.teardown();
918
1067
  }
919
- }, _ = new Set([
1068
+ }, x = new Set([
920
1069
  "p",
921
1070
  "br",
922
1071
  "strong",
@@ -936,14 +1085,14 @@ var h = class extends e {
936
1085
  "blockquote",
937
1086
  "hr"
938
1087
  ]);
939
- function v(e) {
1088
+ function S(e) {
940
1089
  return e.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&#39;");
941
1090
  }
942
- function y(e) {
943
- let t = v(e);
1091
+ function C(e) {
1092
+ let t = S(e);
944
1093
  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(/\[([^\]]+)\]\((https?:\/\/[^)]+)\)/g, "<a href=\"$2\" rel=\"noopener noreferrer\" target=\"_blank\">$1</a>"), t;
945
1094
  }
946
- function b(e) {
1095
+ function w(e) {
947
1096
  if (!e) return "";
948
1097
  let t = e.split("\n"), n = [], r = 0;
949
1098
  for (; r < t.length;) {
@@ -952,14 +1101,14 @@ function b(e) {
952
1101
  let i = e.slice(3).trim(), a = [];
953
1102
  for (r += 1; r < t.length && !t[r].startsWith("```");) a.push(t[r]), r += 1;
954
1103
  r += 1;
955
- let o = i ? ` data-lang="${v(i)}"` : "";
956
- n.push(`<pre${o}><code>${v(a.join("\n"))}</code></pre>`);
1104
+ let o = i ? ` data-lang="${S(i)}"` : "";
1105
+ n.push(`<pre${o}><code>${S(a.join("\n"))}</code></pre>`);
957
1106
  continue;
958
1107
  }
959
1108
  let i = e.match(/^(#{1,6})\s+(.+)/);
960
1109
  if (i) {
961
1110
  let e = i[1].length;
962
- n.push(`<h${e}>${y(i[2])}</h${e}>`), r += 1;
1111
+ n.push(`<h${e}>${C(i[2])}</h${e}>`), r += 1;
963
1112
  continue;
964
1113
  }
965
1114
  if (/^---+$/.test(e.trim()) || /^\*\*\*+$/.test(e.trim())) {
@@ -969,19 +1118,19 @@ function b(e) {
969
1118
  if (e.startsWith("> ")) {
970
1119
  let e = [];
971
1120
  for (; r < t.length && t[r].startsWith("> ");) e.push(t[r].slice(2)), r += 1;
972
- n.push(`<blockquote>${b(e.join("\n"))}</blockquote>`);
1121
+ n.push(`<blockquote>${w(e.join("\n"))}</blockquote>`);
973
1122
  continue;
974
1123
  }
975
1124
  if (/^[-*+]\s/.test(e)) {
976
1125
  let e = [];
977
1126
  for (; r < t.length && /^[-*+]\s/.test(t[r]);) e.push(t[r].replace(/^[-*+]\s/, "")), r += 1;
978
- n.push("<ul>" + e.map((e) => `<li>${y(e)}</li>`).join("") + "</ul>");
1127
+ n.push("<ul>" + e.map((e) => `<li>${C(e)}</li>`).join("") + "</ul>");
979
1128
  continue;
980
1129
  }
981
1130
  if (/^\d+\.\s/.test(e)) {
982
1131
  let e = [];
983
1132
  for (; r < t.length && /^\d+\.\s/.test(t[r]);) e.push(t[r].replace(/^\d+\.\s/, "")), r += 1;
984
- n.push("<ol>" + e.map((e) => `<li>${y(e)}</li>`).join("") + "</ol>");
1133
+ n.push("<ol>" + e.map((e) => `<li>${C(e)}</li>`).join("") + "</ol>");
985
1134
  continue;
986
1135
  }
987
1136
  if (!e.trim()) {
@@ -990,15 +1139,15 @@ function b(e) {
990
1139
  }
991
1140
  let a = [];
992
1141
  for (; r < t.length && t[r].trim() && !t[r].startsWith("#") && !t[r].startsWith("```") && !t[r].startsWith("> ") && !/^[-*+]\s/.test(t[r]) && !/^\d+\.\s/.test(t[r]) && !/^---+$/.test(t[r].trim());) a.push(t[r]), r += 1;
993
- a.length > 0 && n.push(`<p>${y(a.join("\n"))}</p>`);
1142
+ a.length > 0 && n.push(`<p>${C(a.join("\n"))}</p>`);
994
1143
  }
995
1144
  return n.join("");
996
1145
  }
997
1146
  /** Sanitize rendered HTML — strip any tags not in allowlist. */
998
- function x(e) {
1147
+ function T(e) {
999
1148
  return e.replace(/<\/?([a-zA-Z][a-zA-Z0-9]*)[^>]*>/g, (e, t) => {
1000
1149
  let n = t.toLowerCase();
1001
- return _.has(n) ? e : "";
1150
+ return x.has(n) ? e : "";
1002
1151
  });
1003
1152
  }
1004
1153
  /**
@@ -1019,7 +1168,7 @@ function x(e) {
1019
1168
  * @attr {boolean} expandable - Allow click to expand trace content
1020
1169
  * @fires native:activity-toggle - Fired when trace is expanded/collapsed
1021
1170
  */
1022
- var S = class extends e {
1171
+ var E = class extends i {
1023
1172
  static observedAttributes = [
1024
1173
  "type",
1025
1174
  "label",
@@ -1027,11 +1176,11 @@ var S = class extends e {
1027
1176
  "expandable"
1028
1177
  ];
1029
1178
  #e;
1030
- #t = r("typing");
1031
- #n = r("");
1032
- #r = r(!1);
1033
- #i = r(!1);
1034
- #a = r(!1);
1179
+ #t = s("typing");
1180
+ #n = s("");
1181
+ #r = s(!1);
1182
+ #i = s(!1);
1183
+ #a = s(!1);
1035
1184
  #o = 0;
1036
1185
  #s = 0;
1037
1186
  #c = null;
@@ -1077,7 +1226,7 @@ var S = class extends e {
1077
1226
  this.#r.value ? (this.#p(), this.#e.states.add("active")) : (this.#m(), this.#e.states.delete("active"));
1078
1227
  }), this.addEffect(() => {
1079
1228
  if (!this.#c) return;
1080
- let e = this.#n.value || C(this.#t.value);
1229
+ let e = this.#n.value || D(this.#t.value);
1081
1230
  this.#c.textContent = e;
1082
1231
  }), this.addEffect(() => {
1083
1232
  this.#u && (this.#u.hidden = !this.#r.value);
@@ -1107,7 +1256,7 @@ var S = class extends e {
1107
1256
  #h = () => {
1108
1257
  if (!this.#r.value || !this.#l) return;
1109
1258
  let e = performance.now() - this.#o;
1110
- this.#l.textContent = w(e), this.#s = requestAnimationFrame(this.#h);
1259
+ this.#l.textContent = O(e), this.#s = requestAnimationFrame(this.#h);
1111
1260
  };
1112
1261
  #g = () => {
1113
1262
  this.#i.value && (this.#a.value = !this.#a.value, this.toggleAttribute("expanded", this.#a.value), this.dispatchEvent(new CustomEvent("native:activity-toggle", {
@@ -1117,14 +1266,14 @@ var S = class extends e {
1117
1266
  })));
1118
1267
  };
1119
1268
  };
1120
- function C(e) {
1269
+ function D(e) {
1121
1270
  switch (e) {
1122
1271
  case "thinking": return "Thinking…";
1123
1272
  case "tool-use": return "Using tools…";
1124
1273
  default: return "Host is typing…";
1125
1274
  }
1126
1275
  }
1127
- function w(e) {
1276
+ function O(e) {
1128
1277
  let t = Math.floor(e / 1e3);
1129
1278
  if (t < 60) return `${t}s`;
1130
1279
  let n = Math.floor(t / 60), r = t % 60;
@@ -1144,11 +1293,11 @@ function w(e) {
1144
1293
  * @attr {boolean} disabled - Disables all chips
1145
1294
  * @fires native:seed-select - Fired when a chip is clicked
1146
1295
  */
1147
- var T = class extends e {
1296
+ var k = class extends i {
1148
1297
  static observedAttributes = ["options", "disabled"];
1149
1298
  #e;
1150
- #t = r([]);
1151
- #n = r(!1);
1299
+ #t = s([]);
1300
+ #n = s(!1);
1152
1301
  constructor() {
1153
1302
  super(), this.#e = this.attachInternals();
1154
1303
  }
@@ -1182,11 +1331,11 @@ var T = class extends e {
1182
1331
  }
1183
1332
  }
1184
1333
  setup() {
1185
- super.setup(), this.addEffect(n(this, this.#n, this.#e)), this.addEffect(() => {
1334
+ super.setup(), this.addEffect(o(this, this.#n, this.#e)), this.addEffect(() => {
1186
1335
  let e = this.#t.value;
1187
1336
  this.textContent = "";
1188
1337
  let t = document.createElement("n-stack");
1189
- t.setAttribute("direction", "row"), t.setAttribute("wrap", ""), t.setAttribute("gap", "1");
1338
+ t.setAttribute("direction", "row"), t.setAttribute("wrap", "");
1190
1339
  for (let n of e) {
1191
1340
  let e = document.createElement("n-button");
1192
1341
  if (e.setAttribute("variant", "outline"), e.setAttribute("size", "sm"), e.setAttribute("inline", ""), e.setAttribute("data-value", n.value), n.icon) {
@@ -1216,7 +1365,7 @@ var T = class extends e {
1216
1365
  }
1217
1366
  }));
1218
1367
  };
1219
- }, E = new Set([
1368
+ }, A = new Set([
1220
1369
  "script",
1221
1370
  "style",
1222
1371
  "link",
@@ -1233,12 +1382,12 @@ var T = class extends e {
1233
1382
  "frame",
1234
1383
  "frameset",
1235
1384
  "noscript"
1236
- ]), D = class extends e {
1385
+ ]), j = class extends i {
1237
1386
  static observedAttributes = ["schema-type", "mode"];
1238
1387
  #e;
1239
- #t = r("a2ui");
1240
- #n = r("inline");
1241
- #r = r(null);
1388
+ #t = s("a2ui");
1389
+ #n = s("inline");
1390
+ #r = s(null);
1242
1391
  #i = null;
1243
1392
  constructor() {
1244
1393
  super(), this.#e = this.attachInternals();
@@ -1278,7 +1427,7 @@ var T = class extends e {
1278
1427
  super.setup(), this.#i = document.createElement("div"), this.#i.className = "n-chat-genui-container", this.appendChild(this.#i), this.addEffect(() => {
1279
1428
  let e = this.#r.value, t = this.#n.value;
1280
1429
  if (!this.#i || (this.#i.textContent = "", !e)) return;
1281
- let n = O(e);
1430
+ let n = M(e);
1282
1431
  if (n.length > 0) {
1283
1432
  this.#a(n), this.dispatchEvent(new CustomEvent("native:genui-error", {
1284
1433
  bubbles: !0,
@@ -1289,7 +1438,7 @@ var T = class extends e {
1289
1438
  }
1290
1439
  if (t === "lightbox") this.#o(e);
1291
1440
  else {
1292
- let t = k(e);
1441
+ let t = N(e);
1293
1442
  t && this.#i.appendChild(t);
1294
1443
  }
1295
1444
  this.#e.states.add("rendered");
@@ -1313,7 +1462,7 @@ var T = class extends e {
1313
1462
  r.setAttribute("variant", "outline"), r.setAttribute("size", "sm"), r.setAttribute("inline", ""), r.textContent = "Open", r.addEventListener("click", () => this.#s(e)), t.appendChild(r), this.#i.appendChild(t);
1314
1463
  }
1315
1464
  #s(e) {
1316
- let t = document.createElement("n-dialog"), n = k(e);
1465
+ let t = document.createElement("n-dialog"), n = N(e);
1317
1466
  n && t.appendChild(n), this.appendChild(t), requestAnimationFrame(() => {
1318
1467
  let e = t.querySelector("dialog");
1319
1468
  e && e.showModal();
@@ -1333,20 +1482,20 @@ var T = class extends e {
1333
1482
  }));
1334
1483
  };
1335
1484
  };
1336
- function O(e, t = 0) {
1485
+ function M(e, t = 0) {
1337
1486
  let n = [];
1338
1487
  if (t > 20) return n.push("Maximum nesting depth (20) exceeded"), n;
1339
1488
  if (!e.tag || typeof e.tag != "string") return n.push("Node missing required \"tag\" property"), n;
1340
- if (E.has(e.tag.toLowerCase()) && n.push(`Forbidden tag: <${e.tag}>`), e.children) for (let r of e.children) n.push(...O(r, t + 1));
1489
+ if (A.has(e.tag.toLowerCase()) && n.push(`Forbidden tag: <${e.tag}>`), e.children) for (let r of e.children) n.push(...M(r, t + 1));
1341
1490
  return n;
1342
1491
  }
1343
- function k(e) {
1344
- if (E.has(e.tag.toLowerCase())) return null;
1492
+ function N(e) {
1493
+ if (A.has(e.tag.toLowerCase())) return null;
1345
1494
  let t = document.createElement(e.tag);
1346
1495
  if (e.id && (t.id = e.id), e.slot && (t.slot = e.slot), e.attributes) for (let [n, r] of Object.entries(e.attributes)) t.setAttribute(n, r);
1347
1496
  if (e.properties) for (let [n, r] of Object.entries(e.properties)) t[n] = r;
1348
1497
  if (e.text && (t.textContent = e.text), e.children) for (let n of e.children) {
1349
- let e = k(n);
1498
+ let e = N(n);
1350
1499
  e && t.appendChild(e);
1351
1500
  }
1352
1501
  return t;
@@ -1371,7 +1520,7 @@ function k(e) {
1371
1520
  * @fires native:structured-submit - Fired on submit with selections
1372
1521
  * @fires native:structured-cancel - Fired when dismissed without selecting
1373
1522
  */
1374
- var A = class extends e {
1523
+ var P = class extends i {
1375
1524
  static observedAttributes = [
1376
1525
  "question",
1377
1526
  "type",
@@ -1380,12 +1529,12 @@ var A = class extends e {
1380
1529
  "disabled"
1381
1530
  ];
1382
1531
  #e;
1383
- #t = r("");
1384
- #n = r("single");
1385
- #r = r([]);
1386
- #i = r(!1);
1387
- #a = r(!1);
1388
- #o = r(/* @__PURE__ */ new Set());
1532
+ #t = s("");
1533
+ #n = s("single");
1534
+ #r = s([]);
1535
+ #i = s(!1);
1536
+ #a = s(!1);
1537
+ #o = s(/* @__PURE__ */ new Set());
1389
1538
  constructor() {
1390
1539
  super(), this.#e = this.attachInternals();
1391
1540
  }
@@ -1438,7 +1587,7 @@ var A = class extends e {
1438
1587
  }
1439
1588
  }
1440
1589
  setup() {
1441
- super.setup(), this.addEffect(n(this, this.#a, this.#e)), this.addEffect(() => {
1590
+ super.setup(), this.addEffect(o(this, this.#a, this.#e)), this.addEffect(() => {
1442
1591
  this.#s();
1443
1592
  }), this.addEventListener("native:press", this.#c);
1444
1593
  }
@@ -1452,7 +1601,7 @@ var A = class extends e {
1452
1601
  t.className = "n-chat-structured-question", t.textContent = e, this.appendChild(t);
1453
1602
  }
1454
1603
  let i = document.createElement("n-stack");
1455
- i.setAttribute("direction", "row"), i.setAttribute("wrap", ""), i.setAttribute("gap", "1"), i.setAttribute("role", r === "multi" ? "group" : "radiogroup");
1604
+ i.setAttribute("direction", "row"), i.setAttribute("wrap", ""), i.setAttribute("role", r === "multi" ? "group" : "radiogroup");
1456
1605
  for (let e of t) {
1457
1606
  let t = document.createElement("n-button"), r = n.has(e.value);
1458
1607
  if (t.setAttribute("variant", r ? "primary" : "outline"), t.setAttribute("data-value", e.value), t.setAttribute("aria-pressed", String(r)), e.icon) {
@@ -1497,4 +1646,4 @@ var A = class extends e {
1497
1646
  }));
1498
1647
  };
1499
1648
  };
1500
- export { g as a, x as c, p as d, f, a as g, o as h, S as i, h as l, c as m, D as n, y as o, l as p, T as r, b as s, A as t, d as u };
1649
+ export { b as a, T as c, _ as d, g as f, l as g, u as h, E as i, y as l, f as m, j as n, C as o, p, k as r, w as s, P as t, h as u };