@copilotkit/vue 1.62.0 → 1.62.2-canary.1783457132

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 (53) hide show
  1. package/PARITY.md +7 -7
  2. package/dist/index-By5nIKxT.js +1632 -0
  3. package/dist/index-By5nIKxT.js.map +1 -0
  4. package/dist/index-LFxZI63k.cjs +748 -0
  5. package/dist/index-LFxZI63k.cjs.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.mjs +70 -69
  8. package/dist/styles.css +1 -1
  9. package/dist/{use-render-activity-message-Bzh3Bckz.js → use-render-activity-message-DbGuwvBd.js} +3363 -3064
  10. package/dist/use-render-activity-message-DbGuwvBd.js.map +1 -0
  11. package/dist/use-render-activity-message-hlNcbV9l.cjs +85 -0
  12. package/dist/use-render-activity-message-hlNcbV9l.cjs.map +1 -0
  13. package/dist/v2/components/chat/CopilotChat.vue.d.ts.map +1 -1
  14. package/dist/v2/components/chat/CopilotModalHeader.vue.d.ts.map +1 -1
  15. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts +42 -0
  16. package/dist/v2/components/chat/CopilotThreadsDrawer.vue.d.ts.map +1 -0
  17. package/dist/v2/components/chat/index.d.ts +1 -0
  18. package/dist/v2/components/chat/index.d.ts.map +1 -1
  19. package/dist/v2/components/icons/index.d.ts +1 -1
  20. package/dist/v2/components/icons/index.d.ts.map +1 -1
  21. package/dist/v2/hooks/use-agent.d.ts.map +1 -1
  22. package/dist/v2/hooks/use-threads.d.ts +12 -0
  23. package/dist/v2/hooks/use-threads.d.ts.map +1 -1
  24. package/dist/v2/index.cjs +1 -1
  25. package/dist/v2/index.mjs +44 -43
  26. package/dist/v2/lib/is-mobile-viewport.d.ts +15 -0
  27. package/dist/v2/lib/is-mobile-viewport.d.ts.map +1 -0
  28. package/dist/v2/providers/CopilotChatConfigurationProvider.vue.d.ts.map +1 -1
  29. package/dist/v2/providers/types.d.ts +24 -0
  30. package/dist/v2/providers/types.d.ts.map +1 -1
  31. package/package.json +7 -6
  32. package/src/v2/components/chat/CopilotChat.vue +22 -4
  33. package/src/v2/components/chat/CopilotModalHeader.vue +61 -2
  34. package/src/v2/components/chat/CopilotThreadsDrawer.vue +285 -0
  35. package/src/v2/components/chat/__tests__/CopilotChat.clearOnFresh.test.ts +160 -0
  36. package/src/v2/components/chat/__tests__/CopilotModalHeader.drawerLauncher.test.ts +125 -0
  37. package/src/v2/components/chat/__tests__/CopilotThreadsDrawer.ssr.test.ts +25 -0
  38. package/src/v2/components/chat/__tests__/CopilotThreadsDrawer.test.ts +835 -0
  39. package/src/v2/components/chat/index.ts +1 -0
  40. package/src/v2/components/icons/index.ts +1 -0
  41. package/src/v2/hooks/__tests__/use-agent.test.ts +60 -1
  42. package/src/v2/hooks/__tests__/use-human-in-the-loop.e2e.test.ts +4 -4
  43. package/src/v2/hooks/__tests__/use-threads.test.ts +303 -6
  44. package/src/v2/hooks/use-agent.ts +4 -1
  45. package/src/v2/hooks/use-threads.ts +137 -8
  46. package/src/v2/lib/__tests__/is-mobile-viewport.test.ts +48 -0
  47. package/src/v2/lib/is-mobile-viewport.ts +23 -0
  48. package/src/v2/providers/CopilotChatConfigurationProvider.vue +120 -4
  49. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.ts +105 -1
  50. package/src/v2/providers/types.ts +25 -0
  51. package/dist/use-render-activity-message-Bzh3Bckz.js.map +0 -1
  52. package/dist/use-render-activity-message-CW3vipBB.cjs +0 -85
  53. package/dist/use-render-activity-message-CW3vipBB.cjs.map +0 -1
@@ -0,0 +1,1632 @@
1
+ const Ae = {
2
+ bg: "oklch(1 0 0)",
3
+ fg: "oklch(0.145 0 0)",
4
+ surface: "oklch(1 0 0)",
5
+ "surface-fg": "oklch(0.145 0 0)",
6
+ muted: "oklch(0.97 0 0)",
7
+ "muted-fg": "oklch(0.556 0 0)",
8
+ accent: "oklch(0.97 0 0)",
9
+ "accent-fg": "oklch(0.205 0 0)",
10
+ primary: "oklch(0.205 0 0)",
11
+ "primary-fg": "oklch(0.985 0 0)",
12
+ danger: "oklch(0.577 0.245 27.325)",
13
+ border: "oklch(0.922 0 0)",
14
+ ring: "oklch(0.708 0 0)",
15
+ radius: "0.625rem"
16
+ };
17
+ const I = globalThis, V = I.ShadowRoot && (I.ShadyCSS === void 0 || I.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Q = /* @__PURE__ */ Symbol(), X = /* @__PURE__ */ new WeakMap();
18
+ let fe = class {
19
+ constructor(e, t, r) {
20
+ if (this._$cssResult$ = !0, r !== Q) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
21
+ this.cssText = e, this.t = t;
22
+ }
23
+ get styleSheet() {
24
+ let e = this.o;
25
+ const t = this.t;
26
+ if (V && e === void 0) {
27
+ const r = t !== void 0 && t.length === 1;
28
+ r && (e = X.get(t)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), r && X.set(t, e));
29
+ }
30
+ return e;
31
+ }
32
+ toString() {
33
+ return this.cssText;
34
+ }
35
+ };
36
+ const me = (s) => new fe(typeof s == "string" ? s : s + "", void 0, Q), ke = (s, ...e) => {
37
+ const t = s.length === 1 ? s[0] : e.reduce((r, i, o) => r + ((n) => {
38
+ if (n._$cssResult$ === !0) return n.cssText;
39
+ if (typeof n == "number") return n;
40
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + n + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
41
+ })(i) + s[o + 1], s[0]);
42
+ return new fe(t, s, Q);
43
+ }, Ee = (s, e) => {
44
+ if (V) s.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet);
45
+ else for (const t of e) {
46
+ const r = document.createElement("style"), i = I.litNonce;
47
+ i !== void 0 && r.setAttribute("nonce", i), r.textContent = t.cssText, s.appendChild(r);
48
+ }
49
+ }, ee = V ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((e) => {
50
+ let t = "";
51
+ for (const r of e.cssRules) t += r.cssText;
52
+ return me(t);
53
+ })(s) : s;
54
+ const { is: Se, defineProperty: Me, getOwnPropertyDescriptor: Ce, getOwnPropertyNames: Te, getOwnPropertySymbols: Ne, getPrototypeOf: Pe } = Object, H = globalThis, te = H.trustedTypes, Oe = te ? te.emptyScript : "", Ue = H.reactiveElementPolyfillSupport, P = (s, e) => s, W = { toAttribute(s, e) {
55
+ switch (e) {
56
+ case Boolean:
57
+ s = s ? Oe : null;
58
+ break;
59
+ case Object:
60
+ case Array:
61
+ s = s == null ? s : JSON.stringify(s);
62
+ }
63
+ return s;
64
+ }, fromAttribute(s, e) {
65
+ let t = s;
66
+ switch (e) {
67
+ case Boolean:
68
+ t = s !== null;
69
+ break;
70
+ case Number:
71
+ t = s === null ? null : Number(s);
72
+ break;
73
+ case Object:
74
+ case Array:
75
+ try {
76
+ t = JSON.parse(s);
77
+ } catch {
78
+ t = null;
79
+ }
80
+ }
81
+ return t;
82
+ } }, _e = (s, e) => !Se(s, e), re = { attribute: !0, type: String, converter: W, reflect: !1, useDefault: !1, hasChanged: _e };
83
+ Symbol.metadata ??= /* @__PURE__ */ Symbol("metadata"), H.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
84
+ let S = class extends HTMLElement {
85
+ static addInitializer(e) {
86
+ this._$Ei(), (this.l ??= []).push(e);
87
+ }
88
+ static get observedAttributes() {
89
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
90
+ }
91
+ static createProperty(e, t = re) {
92
+ if (t.state && (t.attribute = !1), this._$Ei(), this.prototype.hasOwnProperty(e) && ((t = Object.create(t)).wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) {
93
+ const r = /* @__PURE__ */ Symbol(), i = this.getPropertyDescriptor(e, r, t);
94
+ i !== void 0 && Me(this.prototype, e, i);
95
+ }
96
+ }
97
+ static getPropertyDescriptor(e, t, r) {
98
+ const { get: i, set: o } = Ce(this.prototype, e) ?? { get() {
99
+ return this[t];
100
+ }, set(n) {
101
+ this[t] = n;
102
+ } };
103
+ return { get: i, set(n) {
104
+ const d = i?.call(this);
105
+ o?.call(this, n), this.requestUpdate(e, d, r);
106
+ }, configurable: !0, enumerable: !0 };
107
+ }
108
+ static getPropertyOptions(e) {
109
+ return this.elementProperties.get(e) ?? re;
110
+ }
111
+ static _$Ei() {
112
+ if (this.hasOwnProperty(P("elementProperties"))) return;
113
+ const e = Pe(this);
114
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
115
+ }
116
+ static finalize() {
117
+ if (this.hasOwnProperty(P("finalized"))) return;
118
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(P("properties"))) {
119
+ const t = this.properties, r = [...Te(t), ...Ne(t)];
120
+ for (const i of r) this.createProperty(i, t[i]);
121
+ }
122
+ const e = this[Symbol.metadata];
123
+ if (e !== null) {
124
+ const t = litPropertyMetadata.get(e);
125
+ if (t !== void 0) for (const [r, i] of t) this.elementProperties.set(r, i);
126
+ }
127
+ this._$Eh = /* @__PURE__ */ new Map();
128
+ for (const [t, r] of this.elementProperties) {
129
+ const i = this._$Eu(t, r);
130
+ i !== void 0 && this._$Eh.set(i, t);
131
+ }
132
+ this.elementStyles = this.finalizeStyles(this.styles);
133
+ }
134
+ static finalizeStyles(e) {
135
+ const t = [];
136
+ if (Array.isArray(e)) {
137
+ const r = new Set(e.flat(1 / 0).reverse());
138
+ for (const i of r) t.unshift(ee(i));
139
+ } else e !== void 0 && t.push(ee(e));
140
+ return t;
141
+ }
142
+ static _$Eu(e, t) {
143
+ const r = t.attribute;
144
+ return r === !1 ? void 0 : typeof r == "string" ? r : typeof e == "string" ? e.toLowerCase() : void 0;
145
+ }
146
+ constructor() {
147
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
148
+ }
149
+ _$Ev() {
150
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach((e) => e(this));
151
+ }
152
+ addController(e) {
153
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && e.hostConnected?.();
154
+ }
155
+ removeController(e) {
156
+ this._$EO?.delete(e);
157
+ }
158
+ _$E_() {
159
+ const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
160
+ for (const r of t.keys()) this.hasOwnProperty(r) && (e.set(r, this[r]), delete this[r]);
161
+ e.size > 0 && (this._$Ep = e);
162
+ }
163
+ createRenderRoot() {
164
+ const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
165
+ return Ee(e, this.constructor.elementStyles), e;
166
+ }
167
+ connectedCallback() {
168
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), this._$EO?.forEach((e) => e.hostConnected?.());
169
+ }
170
+ enableUpdating(e) {
171
+ }
172
+ disconnectedCallback() {
173
+ this._$EO?.forEach((e) => e.hostDisconnected?.());
174
+ }
175
+ attributeChangedCallback(e, t, r) {
176
+ this._$AK(e, r);
177
+ }
178
+ _$ET(e, t) {
179
+ const r = this.constructor.elementProperties.get(e), i = this.constructor._$Eu(e, r);
180
+ if (i !== void 0 && r.reflect === !0) {
181
+ const o = (r.converter?.toAttribute !== void 0 ? r.converter : W).toAttribute(t, r.type);
182
+ this._$Em = e, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
183
+ }
184
+ }
185
+ _$AK(e, t) {
186
+ const r = this.constructor, i = r._$Eh.get(e);
187
+ if (i !== void 0 && this._$Em !== i) {
188
+ const o = r.getPropertyOptions(i), n = typeof o.converter == "function" ? { fromAttribute: o.converter } : o.converter?.fromAttribute !== void 0 ? o.converter : W;
189
+ this._$Em = i;
190
+ const d = n.fromAttribute(t, o.type);
191
+ this[i] = d ?? this._$Ej?.get(i) ?? d, this._$Em = null;
192
+ }
193
+ }
194
+ requestUpdate(e, t, r, i = !1, o) {
195
+ if (e !== void 0) {
196
+ const n = this.constructor;
197
+ if (i === !1 && (o = this[e]), r ??= n.getPropertyOptions(e), !((r.hasChanged ?? _e)(o, t) || r.useDefault && r.reflect && o === this._$Ej?.get(e) && !this.hasAttribute(n._$Eu(e, r)))) return;
198
+ this.C(e, t, r);
199
+ }
200
+ this.isUpdatePending === !1 && (this._$ES = this._$EP());
201
+ }
202
+ C(e, t, { useDefault: r, reflect: i, wrapped: o }, n) {
203
+ r && !(this._$Ej ??= /* @__PURE__ */ new Map()).has(e) && (this._$Ej.set(e, n ?? t ?? this[e]), o !== !0 || n !== void 0) || (this._$AL.has(e) || (this.hasUpdated || r || (t = void 0), this._$AL.set(e, t)), i === !0 && this._$Em !== e && (this._$Eq ??= /* @__PURE__ */ new Set()).add(e));
204
+ }
205
+ async _$EP() {
206
+ this.isUpdatePending = !0;
207
+ try {
208
+ await this._$ES;
209
+ } catch (t) {
210
+ Promise.reject(t);
211
+ }
212
+ const e = this.scheduleUpdate();
213
+ return e != null && await e, !this.isUpdatePending;
214
+ }
215
+ scheduleUpdate() {
216
+ return this.performUpdate();
217
+ }
218
+ performUpdate() {
219
+ if (!this.isUpdatePending) return;
220
+ if (!this.hasUpdated) {
221
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
222
+ for (const [i, o] of this._$Ep) this[i] = o;
223
+ this._$Ep = void 0;
224
+ }
225
+ const r = this.constructor.elementProperties;
226
+ if (r.size > 0) for (const [i, o] of r) {
227
+ const { wrapped: n } = o, d = this[i];
228
+ n !== !0 || this._$AL.has(i) || d === void 0 || this.C(i, void 0, o, d);
229
+ }
230
+ }
231
+ let e = !1;
232
+ const t = this._$AL;
233
+ try {
234
+ e = this.shouldUpdate(t), e ? (this.willUpdate(t), this._$EO?.forEach((r) => r.hostUpdate?.()), this.update(t)) : this._$EM();
235
+ } catch (r) {
236
+ throw e = !1, this._$EM(), r;
237
+ }
238
+ e && this._$AE(t);
239
+ }
240
+ willUpdate(e) {
241
+ }
242
+ _$AE(e) {
243
+ this._$EO?.forEach((t) => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
244
+ }
245
+ _$EM() {
246
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
247
+ }
248
+ get updateComplete() {
249
+ return this.getUpdateComplete();
250
+ }
251
+ getUpdateComplete() {
252
+ return this._$ES;
253
+ }
254
+ shouldUpdate(e) {
255
+ return !0;
256
+ }
257
+ update(e) {
258
+ this._$Eq &&= this._$Eq.forEach((t) => this._$ET(t, this[t])), this._$EM();
259
+ }
260
+ updated(e) {
261
+ }
262
+ firstUpdated(e) {
263
+ }
264
+ };
265
+ S.elementStyles = [], S.shadowRootOptions = { mode: "open" }, S[P("elementProperties")] = /* @__PURE__ */ new Map(), S[P("finalized")] = /* @__PURE__ */ new Map(), Ue?.({ ReactiveElement: S }), (H.reactiveElementVersions ??= []).push("2.1.2");
266
+ const Y = globalThis, ie = (s) => s, L = Y.trustedTypes, se = L ? L.createPolicy("lit-html", { createHTML: (s) => s }) : void 0, ge = "$lit$", $ = `lit$${Math.random().toFixed(9).slice(2)}$`, ve = "?" + $, Re = `<${ve}>`, E = document, U = () => E.createComment(""), R = (s) => s === null || typeof s != "object" && typeof s != "function", Z = Array.isArray, De = (s) => Z(s) || typeof s?.[Symbol.iterator] == "function", j = `[
267
+ \f\r]`, T = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, oe = /-->/g, ne = />/g, y = RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
268
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), ae = /'/g, le = /"/g, be = /^(?:script|style|textarea|title)$/i, Ie = (s) => (e, ...t) => ({ _$litType$: s, strings: e, values: t }), u = Ie(1), w = /* @__PURE__ */ Symbol.for("lit-noChange"), f = /* @__PURE__ */ Symbol.for("lit-nothing"), de = /* @__PURE__ */ new WeakMap(), A = E.createTreeWalker(E, 129);
269
+ function $e(s, e) {
270
+ if (!Z(s) || !s.hasOwnProperty("raw")) throw Error("invalid template strings array");
271
+ return se !== void 0 ? se.createHTML(e) : e;
272
+ }
273
+ const Le = (s, e) => {
274
+ const t = s.length - 1, r = [];
275
+ let i, o = e === 2 ? "<svg>" : e === 3 ? "<math>" : "", n = T;
276
+ for (let d = 0; d < t; d++) {
277
+ const a = s[d];
278
+ let c, m, l = -1, p = 0;
279
+ for (; p < a.length && (n.lastIndex = p, m = n.exec(a), m !== null); ) p = n.lastIndex, n === T ? m[1] === "!--" ? n = oe : m[1] !== void 0 ? n = ne : m[2] !== void 0 ? (be.test(m[2]) && (i = RegExp("</" + m[2], "g")), n = y) : m[3] !== void 0 && (n = y) : n === y ? m[0] === ">" ? (n = i ?? T, l = -1) : m[1] === void 0 ? l = -2 : (l = n.lastIndex - m[2].length, c = m[1], n = m[3] === void 0 ? y : m[3] === '"' ? le : ae) : n === le || n === ae ? n = y : n === oe || n === ne ? n = T : (n = y, i = void 0);
280
+ const h = n === y && s[d + 1].startsWith("/>") ? " " : "";
281
+ o += n === T ? a + Re : l >= 0 ? (r.push(c), a.slice(0, l) + ge + a.slice(l) + $ + h) : a + $ + (l === -2 ? d : h);
282
+ }
283
+ return [$e(s, o + (s[t] || "<?>") + (e === 2 ? "</svg>" : e === 3 ? "</math>" : "")), r];
284
+ };
285
+ class D {
286
+ constructor({ strings: e, _$litType$: t }, r) {
287
+ let i;
288
+ this.parts = [];
289
+ let o = 0, n = 0;
290
+ const d = e.length - 1, a = this.parts, [c, m] = Le(e, t);
291
+ if (this.el = D.createElement(c, r), A.currentNode = this.el.content, t === 2 || t === 3) {
292
+ const l = this.el.content.firstChild;
293
+ l.replaceWith(...l.childNodes);
294
+ }
295
+ for (; (i = A.nextNode()) !== null && a.length < d; ) {
296
+ if (i.nodeType === 1) {
297
+ if (i.hasAttributes()) for (const l of i.getAttributeNames()) if (l.endsWith(ge)) {
298
+ const p = m[n++], h = i.getAttribute(l).split($), _ = /([.?@])?(.*)/.exec(p);
299
+ a.push({ type: 1, index: o, name: _[2], strings: h, ctor: _[1] === "." ? Be : _[1] === "?" ? ze : _[1] === "@" ? je : B }), i.removeAttribute(l);
300
+ } else l.startsWith($) && (a.push({ type: 6, index: o }), i.removeAttribute(l));
301
+ if (be.test(i.tagName)) {
302
+ const l = i.textContent.split($), p = l.length - 1;
303
+ if (p > 0) {
304
+ i.textContent = L ? L.emptyScript : "";
305
+ for (let h = 0; h < p; h++) i.append(l[h], U()), A.nextNode(), a.push({ type: 2, index: ++o });
306
+ i.append(l[p], U());
307
+ }
308
+ }
309
+ } else if (i.nodeType === 8) if (i.data === ve) a.push({ type: 2, index: o });
310
+ else {
311
+ let l = -1;
312
+ for (; (l = i.data.indexOf($, l + 1)) !== -1; ) a.push({ type: 7, index: o }), l += $.length - 1;
313
+ }
314
+ o++;
315
+ }
316
+ }
317
+ static createElement(e, t) {
318
+ const r = E.createElement("template");
319
+ return r.innerHTML = e, r;
320
+ }
321
+ }
322
+ function M(s, e, t = s, r) {
323
+ if (e === w) return e;
324
+ let i = r !== void 0 ? t._$Co?.[r] : t._$Cl;
325
+ const o = R(e) ? void 0 : e._$litDirective$;
326
+ return i?.constructor !== o && (i?._$AO?.(!1), o === void 0 ? i = void 0 : (i = new o(s), i._$AT(s, t, r)), r !== void 0 ? (t._$Co ??= [])[r] = i : t._$Cl = i), i !== void 0 && (e = M(s, i._$AS(s, e.values), i, r)), e;
327
+ }
328
+ class He {
329
+ constructor(e, t) {
330
+ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
331
+ }
332
+ get parentNode() {
333
+ return this._$AM.parentNode;
334
+ }
335
+ get _$AU() {
336
+ return this._$AM._$AU;
337
+ }
338
+ u(e) {
339
+ const { el: { content: t }, parts: r } = this._$AD, i = (e?.creationScope ?? E).importNode(t, !0);
340
+ A.currentNode = i;
341
+ let o = A.nextNode(), n = 0, d = 0, a = r[0];
342
+ for (; a !== void 0; ) {
343
+ if (n === a.index) {
344
+ let c;
345
+ a.type === 2 ? c = new C(o, o.nextSibling, this, e) : a.type === 1 ? c = new a.ctor(o, a.name, a.strings, this, e) : a.type === 6 && (c = new Fe(o, this, e)), this._$AV.push(c), a = r[++d];
346
+ }
347
+ n !== a?.index && (o = A.nextNode(), n++);
348
+ }
349
+ return A.currentNode = E, i;
350
+ }
351
+ p(e) {
352
+ let t = 0;
353
+ for (const r of this._$AV) r !== void 0 && (r.strings !== void 0 ? (r._$AI(e, r, t), t += r.strings.length - 2) : r._$AI(e[t])), t++;
354
+ }
355
+ }
356
+ class C {
357
+ get _$AU() {
358
+ return this._$AM?._$AU ?? this._$Cv;
359
+ }
360
+ constructor(e, t, r, i) {
361
+ this.type = 2, this._$AH = f, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = r, this.options = i, this._$Cv = i?.isConnected ?? !0;
362
+ }
363
+ get parentNode() {
364
+ let e = this._$AA.parentNode;
365
+ const t = this._$AM;
366
+ return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
367
+ }
368
+ get startNode() {
369
+ return this._$AA;
370
+ }
371
+ get endNode() {
372
+ return this._$AB;
373
+ }
374
+ _$AI(e, t = this) {
375
+ e = M(this, e, t), R(e) ? e === f || e == null || e === "" ? (this._$AH !== f && this._$AR(), this._$AH = f) : e !== this._$AH && e !== w && this._(e) : e._$litType$ !== void 0 ? this.$(e) : e.nodeType !== void 0 ? this.T(e) : De(e) ? this.k(e) : this._(e);
376
+ }
377
+ O(e) {
378
+ return this._$AA.parentNode.insertBefore(e, this._$AB);
379
+ }
380
+ T(e) {
381
+ this._$AH !== e && (this._$AR(), this._$AH = this.O(e));
382
+ }
383
+ _(e) {
384
+ this._$AH !== f && R(this._$AH) ? this._$AA.nextSibling.data = e : this.T(E.createTextNode(e)), this._$AH = e;
385
+ }
386
+ $(e) {
387
+ const { values: t, _$litType$: r } = e, i = typeof r == "number" ? this._$AC(e) : (r.el === void 0 && (r.el = D.createElement($e(r.h, r.h[0]), this.options)), r);
388
+ if (this._$AH?._$AD === i) this._$AH.p(t);
389
+ else {
390
+ const o = new He(i, this), n = o.u(this.options);
391
+ o.p(t), this.T(n), this._$AH = o;
392
+ }
393
+ }
394
+ _$AC(e) {
395
+ let t = de.get(e.strings);
396
+ return t === void 0 && de.set(e.strings, t = new D(e)), t;
397
+ }
398
+ k(e) {
399
+ Z(this._$AH) || (this._$AH = [], this._$AR());
400
+ const t = this._$AH;
401
+ let r, i = 0;
402
+ for (const o of e) i === t.length ? t.push(r = new C(this.O(U()), this.O(U()), this, this.options)) : r = t[i], r._$AI(o), i++;
403
+ i < t.length && (this._$AR(r && r._$AB.nextSibling, i), t.length = i);
404
+ }
405
+ _$AR(e = this._$AA.nextSibling, t) {
406
+ for (this._$AP?.(!1, !0, t); e !== this._$AB; ) {
407
+ const r = ie(e).nextSibling;
408
+ ie(e).remove(), e = r;
409
+ }
410
+ }
411
+ setConnected(e) {
412
+ this._$AM === void 0 && (this._$Cv = e, this._$AP?.(e));
413
+ }
414
+ }
415
+ class B {
416
+ get tagName() {
417
+ return this.element.tagName;
418
+ }
419
+ get _$AU() {
420
+ return this._$AM._$AU;
421
+ }
422
+ constructor(e, t, r, i, o) {
423
+ this.type = 1, this._$AH = f, this._$AN = void 0, this.element = e, this.name = t, this._$AM = i, this.options = o, r.length > 2 || r[0] !== "" || r[1] !== "" ? (this._$AH = Array(r.length - 1).fill(new String()), this.strings = r) : this._$AH = f;
424
+ }
425
+ _$AI(e, t = this, r, i) {
426
+ const o = this.strings;
427
+ let n = !1;
428
+ if (o === void 0) e = M(this, e, t, 0), n = !R(e) || e !== this._$AH && e !== w, n && (this._$AH = e);
429
+ else {
430
+ const d = e;
431
+ let a, c;
432
+ for (e = o[0], a = 0; a < o.length - 1; a++) c = M(this, d[r + a], t, a), c === w && (c = this._$AH[a]), n ||= !R(c) || c !== this._$AH[a], c === f ? e = f : e !== f && (e += (c ?? "") + o[a + 1]), this._$AH[a] = c;
433
+ }
434
+ n && !i && this.j(e);
435
+ }
436
+ j(e) {
437
+ e === f ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
438
+ }
439
+ }
440
+ class Be extends B {
441
+ constructor() {
442
+ super(...arguments), this.type = 3;
443
+ }
444
+ j(e) {
445
+ this.element[this.name] = e === f ? void 0 : e;
446
+ }
447
+ }
448
+ class ze extends B {
449
+ constructor() {
450
+ super(...arguments), this.type = 4;
451
+ }
452
+ j(e) {
453
+ this.element.toggleAttribute(this.name, !!e && e !== f);
454
+ }
455
+ }
456
+ class je extends B {
457
+ constructor(e, t, r, i, o) {
458
+ super(e, t, r, i, o), this.type = 5;
459
+ }
460
+ _$AI(e, t = this) {
461
+ if ((e = M(this, e, t, 0) ?? f) === w) return;
462
+ const r = this._$AH, i = e === f && r !== f || e.capture !== r.capture || e.once !== r.once || e.passive !== r.passive, o = e !== f && (r === f || i);
463
+ i && this.element.removeEventListener(this.name, this, r), o && this.element.addEventListener(this.name, this, e), this._$AH = e;
464
+ }
465
+ handleEvent(e) {
466
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
467
+ }
468
+ }
469
+ class Fe {
470
+ constructor(e, t, r) {
471
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = r;
472
+ }
473
+ get _$AU() {
474
+ return this._$AM._$AU;
475
+ }
476
+ _$AI(e) {
477
+ M(this, e);
478
+ }
479
+ }
480
+ const qe = { I: C }, Ke = Y.litHtmlPolyfillSupport;
481
+ Ke?.(D, C), (Y.litHtmlVersions ??= []).push("3.3.2");
482
+ const We = (s, e, t) => {
483
+ const r = t?.renderBefore ?? e;
484
+ let i = r._$litPart$;
485
+ if (i === void 0) {
486
+ const o = t?.renderBefore ?? null;
487
+ r._$litPart$ = i = new C(e.insertBefore(U(), o), o, void 0, t ?? {});
488
+ }
489
+ return i._$AI(s), i;
490
+ };
491
+ const G = globalThis;
492
+ let O = class extends S {
493
+ constructor() {
494
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
495
+ }
496
+ createRenderRoot() {
497
+ const e = super.createRenderRoot();
498
+ return this.renderOptions.renderBefore ??= e.firstChild, e;
499
+ }
500
+ update(e) {
501
+ const t = this.render();
502
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = We(t, this.renderRoot, this.renderOptions);
503
+ }
504
+ connectedCallback() {
505
+ super.connectedCallback(), this._$Do?.setConnected(!0);
506
+ }
507
+ disconnectedCallback() {
508
+ super.disconnectedCallback(), this._$Do?.setConnected(!1);
509
+ }
510
+ render() {
511
+ return w;
512
+ }
513
+ };
514
+ O._$litElement$ = !0, O.finalized = !0, G.litElementHydrateSupport?.({ LitElement: O });
515
+ const Ve = G.litElementPolyfillSupport;
516
+ Ve?.({ LitElement: O });
517
+ (G.litElementVersions ??= []).push("4.2.2");
518
+ const g = (s) => me(s), v = Ae, Qe = ke`
519
+ :host {
520
+ /* Re-pin inheritable properties to close inheritance leaks from hostile
521
+ host CSS. These are the only properties that cross the shadow boundary
522
+ via inheritance, so we hard-set them at the root. */
523
+ all: initial;
524
+ display: block;
525
+ height: 100%;
526
+ box-sizing: border-box;
527
+ font-family:
528
+ var(--cpk-drawer-font-family, ui-sans-serif, system-ui, sans-serif);
529
+ font-size: var(--cpk-drawer-font-size, 14px);
530
+ line-height: var(--cpk-drawer-line-height, 1.4);
531
+ color: var(--cpk-drawer-fg, var(--foreground, ${g(v.fg)}));
532
+
533
+ /* Three-level token resolution, highest priority first:
534
+ 1. explicit per-token override (--cpk-drawer-*),
535
+ 2. the host app's theme variable (--background/--card/… — the standard
536
+ react-core/shadcn names), so the drawer follows the host's light/dark
537
+ theme by inheritance (custom properties are NOT reset by all:initial),
538
+ 3. the built-in light default derived from react-core at build time, so a
539
+ host with no theme still renders correctly (self-contained). */
540
+ --_bg: var(--cpk-drawer-bg, var(--background, ${g(v.bg)}));
541
+ --_surface: var(--cpk-drawer-surface, var(--card, ${g(v.surface)}));
542
+ --_surface-fg: var(
543
+ --cpk-drawer-surface-fg,
544
+ var(--card-foreground, ${g(v["surface-fg"])})
545
+ );
546
+ --_muted: var(--cpk-drawer-muted, var(--muted, ${g(v.muted)}));
547
+ --_muted-fg: var(
548
+ --cpk-drawer-muted-fg,
549
+ var(--muted-foreground, ${g(v["muted-fg"])})
550
+ );
551
+ --_accent: var(--cpk-drawer-accent, var(--accent, ${g(v.accent)}));
552
+ --_accent-fg: var(
553
+ --cpk-drawer-accent-fg,
554
+ var(--accent-foreground, ${g(v["accent-fg"])})
555
+ );
556
+ --_primary: var(--cpk-drawer-primary, var(--primary, ${g(v.primary)}));
557
+ --_primary-fg: var(
558
+ --cpk-drawer-primary-fg,
559
+ var(--primary-foreground, ${g(v["primary-fg"])})
560
+ );
561
+ --_danger: var(--cpk-drawer-danger, var(--destructive, ${g(v.danger)}));
562
+ --_border: var(--cpk-drawer-border, var(--border, ${g(v.border)}));
563
+ --_ring: var(--cpk-drawer-ring, var(--ring, ${g(v.ring)}));
564
+ --_radius: var(--cpk-drawer-radius, var(--radius, ${g(v.radius)}));
565
+ --_width: var(--cpk-drawer-width, 320px);
566
+ --_rail-width: var(--cpk-drawer-rail-width, 56px);
567
+ }
568
+
569
+ :host([hidden]) {
570
+ display: none;
571
+ }
572
+
573
+ * {
574
+ box-sizing: border-box;
575
+ }
576
+
577
+ .root {
578
+ display: flex;
579
+ flex-direction: column;
580
+ height: 100%;
581
+ width: var(--_width);
582
+ background: var(--_bg);
583
+ border-right: 1px solid var(--_border);
584
+ overflow: hidden;
585
+ transition: width 0.2s ease;
586
+ /* Positioning context for the confirm-delete dialog's absolutely-positioned
587
+ backdrop (see .dialog-backdrop). Without this the backdrop's inset:0
588
+ resolves against the initial containing block (the viewport) and its
589
+ low z-index competes in the light-DOM root stacking context, so on
590
+ desktop the dialog escapes the drawer column and paints UNDER the chat
591
+ input (which sits in a sibling column). Anchoring here confines the
592
+ modal to the drawer, where its z-index only needs to beat the rows.
593
+ The mobile path already establishes its own context via position:fixed. */
594
+ position: relative;
595
+ }
596
+
597
+ .root.collapsed {
598
+ width: var(--_rail-width);
599
+ }
600
+
601
+ /* Mobile: off-canvas overlay (modal pattern). */
602
+ .root.mobile {
603
+ position: fixed;
604
+ inset: 0 auto 0 0;
605
+ z-index: 1000;
606
+ width: min(var(--_width), 85vw);
607
+ transform: translateX(-100%);
608
+ transition: transform 0.2s ease;
609
+ box-shadow: 0 0 0 100vmax transparent;
610
+ }
611
+
612
+ .root.mobile.open {
613
+ transform: translateX(0);
614
+ }
615
+
616
+ .backdrop {
617
+ position: fixed;
618
+ inset: 0;
619
+ z-index: 999;
620
+ background: rgba(0, 0, 0, 0.4);
621
+ border: 0;
622
+ padding: 0;
623
+ margin: 0;
624
+ cursor: pointer;
625
+ }
626
+
627
+ /* Mobile-only floating affordance to OPEN the off-canvas drawer. Rendered by
628
+ the element itself so phones always have a way in with no host wiring. */
629
+ .launcher {
630
+ position: fixed;
631
+ z-index: 998;
632
+ /* Position is themeable so a host can line the launcher up with its own
633
+ header controls (e.g. vertically centering it on a toggle group). */
634
+ top: var(--cpk-drawer-launcher-top, 12px);
635
+ left: var(--cpk-drawer-launcher-left, 12px);
636
+ display: inline-flex;
637
+ align-items: center;
638
+ justify-content: center;
639
+ width: 40px;
640
+ height: 40px;
641
+ border-radius: 999px;
642
+ border: 1px solid var(--_border);
643
+ background: var(--_surface);
644
+ color: var(--_surface-fg);
645
+ cursor: pointer;
646
+ box-shadow: 0 2px 8px rgb(0 0 0 / 0.12);
647
+ }
648
+
649
+ .launcher-icon {
650
+ width: 18px;
651
+ height: 18px;
652
+ display: block;
653
+ }
654
+
655
+ .header {
656
+ display: flex;
657
+ align-items: center;
658
+ justify-content: space-between;
659
+ gap: 8px;
660
+ padding: 12px;
661
+ border-bottom: 1px solid var(--_border);
662
+ }
663
+
664
+ .filters {
665
+ display: flex;
666
+ gap: 4px;
667
+ padding: 8px 12px;
668
+ }
669
+
670
+ .filter-btn {
671
+ flex: 1;
672
+ padding: 6px 10px;
673
+ border: 1px solid var(--_border);
674
+ border-radius: var(--_radius);
675
+ background: var(--_bg);
676
+ color: var(--_muted-fg);
677
+ cursor: pointer;
678
+ font: inherit;
679
+ }
680
+
681
+ .filter-btn[aria-pressed="true"] {
682
+ background: var(--_accent);
683
+ color: var(--_accent-fg);
684
+ border-color: var(--_ring);
685
+ }
686
+
687
+ .list {
688
+ flex: 1;
689
+ min-height: 0;
690
+ overflow-y: auto;
691
+ padding: 8px 12px;
692
+ margin: 0;
693
+ list-style: none;
694
+ display: flex;
695
+ flex-direction: column;
696
+ gap: 4px;
697
+ }
698
+
699
+ .row {
700
+ display: flex;
701
+ align-items: center;
702
+ gap: 8px;
703
+ padding: 8px 10px;
704
+ border-radius: var(--_radius);
705
+ cursor: pointer;
706
+ background: transparent;
707
+ color: inherit;
708
+ border: 1px solid transparent;
709
+ opacity: 0;
710
+ transform: translateY(4px);
711
+ animation: cpk-drawer-row-in 0.18s ease forwards;
712
+ /* Positioned so the hovered row can be lifted above later rows (below). */
713
+ position: relative;
714
+ }
715
+
716
+ /* The entry animation leaves each row with a (non-none) transform, making it
717
+ its own stacking context — which would paint the name tooltip UNDER the
718
+ following rows (their text bled through the bubble). Lifting the hovered
719
+ row's z-index re-floats its tooltip above the rows beneath it. */
720
+ .row.name-clipped:hover {
721
+ z-index: 2;
722
+ }
723
+
724
+ @keyframes cpk-drawer-row-in {
725
+ to {
726
+ opacity: 1;
727
+ transform: translateY(0);
728
+ }
729
+ }
730
+
731
+ .row.active {
732
+ background: var(--_accent);
733
+ color: var(--_accent-fg);
734
+ border-color: var(--_ring);
735
+ }
736
+
737
+ .row.archived .row-name {
738
+ color: var(--_muted-fg);
739
+ }
740
+
741
+ .row-name {
742
+ /* The outer name element owns NO overflow clip so it can host the name
743
+ tooltip pseudo-element; the inner .row-name-text does the ellipsis. */
744
+ flex: 1;
745
+ min-width: 0;
746
+ position: relative;
747
+ }
748
+
749
+ .row-name-text {
750
+ display: block;
751
+ overflow: hidden;
752
+ text-overflow: ellipsis;
753
+ white-space: nowrap;
754
+ }
755
+
756
+ /* Name tooltip: matches the row-action tooltip (instant primary bubble with
757
+ an arrow), shown ONLY when the name is clipped. Positioned below the name,
758
+ wrapping within the drawer width (a long name can't fit one line). */
759
+ .row-name.name-clipped[data-tooltip]:hover::after {
760
+ content: attr(data-tooltip);
761
+ position: absolute;
762
+ left: 0;
763
+ top: calc(100% + 6px);
764
+ white-space: normal;
765
+ max-width: 240px;
766
+ background: var(--_primary);
767
+ color: var(--_primary-fg);
768
+ border-radius: 6px;
769
+ padding: 4px 8px;
770
+ font-size: 12px;
771
+ line-height: 1.4;
772
+ box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
773
+ pointer-events: none;
774
+ z-index: 20;
775
+ }
776
+
777
+ .row-name.name-clipped[data-tooltip]:hover::before {
778
+ content: "";
779
+ position: absolute;
780
+ left: 10px;
781
+ top: calc(100% + 1.5px);
782
+ transform: rotate(45deg);
783
+ width: 7px;
784
+ height: 7px;
785
+ background: var(--_primary);
786
+ border-radius: 1px;
787
+ pointer-events: none;
788
+ z-index: 21;
789
+ }
790
+
791
+ .row-name.placeholder {
792
+ color: var(--_muted-fg);
793
+ font-style: italic;
794
+ }
795
+
796
+ .row-name.revealed {
797
+ animation: cpk-drawer-name-reveal 0.3s ease;
798
+ }
799
+
800
+ @keyframes cpk-drawer-name-reveal {
801
+ from {
802
+ opacity: 0.4;
803
+ }
804
+ to {
805
+ opacity: 1;
806
+ }
807
+ }
808
+
809
+ .row-action {
810
+ position: relative;
811
+ display: inline-flex;
812
+ align-items: center;
813
+ justify-content: center;
814
+ flex: none;
815
+ border: 0;
816
+ background: transparent;
817
+ color: var(--_muted-fg);
818
+ cursor: pointer;
819
+ font: inherit;
820
+ padding: 5px;
821
+ border-radius: 6px;
822
+ }
823
+
824
+ /* Instant tooltip (matches the react components' delayDuration:0) styled to
825
+ match the CPK standard tooltip: a solid primary-colored bubble with
826
+ primary-foreground text, rounded corners, no border, and a small arrow —
827
+ NOT a surface/bordered box (which reads as a button). Rendered to the LEFT
828
+ of the action so the list's vertical overflow never clips it; the native
829
+ \`title\` tooltip is avoided because its show-delay is browser-fixed (~1.5s)
830
+ and cannot be tuned. */
831
+ .row-action[data-tooltip]:hover::after,
832
+ .row-action[data-tooltip]:focus-visible::after {
833
+ content: attr(data-tooltip);
834
+ position: absolute;
835
+ right: calc(100% + 8px);
836
+ top: 50%;
837
+ transform: translateY(-50%);
838
+ white-space: nowrap;
839
+ background: var(--_primary);
840
+ color: var(--_primary-fg);
841
+ border-radius: 6px;
842
+ padding: 4px 8px;
843
+ font-size: 12px;
844
+ line-height: 1.4;
845
+ box-shadow: 0 4px 12px rgb(0 0 0 / 0.18);
846
+ pointer-events: none;
847
+ z-index: 20;
848
+ }
849
+
850
+ /* Arrow: a small rotated square at the bubble's right edge, pointing at the
851
+ action — same primary fill as the bubble. */
852
+ .row-action[data-tooltip]:hover::before,
853
+ .row-action[data-tooltip]:focus-visible::before {
854
+ content: "";
855
+ position: absolute;
856
+ right: calc(100% + 4.5px);
857
+ top: 50%;
858
+ transform: translateY(-50%) rotate(45deg);
859
+ width: 7px;
860
+ height: 7px;
861
+ background: var(--_primary);
862
+ border-radius: 1px;
863
+ pointer-events: none;
864
+ z-index: 21;
865
+ }
866
+
867
+ /* While the delete-confirmation dialog is open, suppress row-action tooltips:
868
+ the clicked trash button keeps :focus-visible (and may stay hovered), which
869
+ would otherwise leave its "Delete" tooltip floating over the dialog. */
870
+ .root.confirming .row-action[data-tooltip]:hover::after,
871
+ .root.confirming .row-action[data-tooltip]:focus-visible::after,
872
+ .root.confirming .row-action[data-tooltip]:hover::before,
873
+ .root.confirming .row-action[data-tooltip]:focus-visible::before {
874
+ content: none;
875
+ display: none;
876
+ }
877
+
878
+ .row-action:hover,
879
+ .row-action:focus-visible {
880
+ background: var(--_muted);
881
+ color: inherit;
882
+ }
883
+
884
+ .row-action.danger:hover,
885
+ .row-action.danger:focus-visible {
886
+ color: var(--_danger);
887
+ }
888
+
889
+ .row-action-icon {
890
+ width: 15px;
891
+ height: 15px;
892
+ display: block;
893
+ }
894
+
895
+ button.primary {
896
+ background: var(--_primary);
897
+ color: var(--_primary-fg);
898
+ border: 0;
899
+ border-radius: var(--_radius);
900
+ padding: 8px 12px;
901
+ cursor: pointer;
902
+ font: inherit;
903
+ }
904
+
905
+ .state {
906
+ padding: 24px 16px;
907
+ text-align: center;
908
+ color: var(--_muted-fg);
909
+ }
910
+
911
+ .state.error {
912
+ color: var(--_danger);
913
+ }
914
+
915
+ .fetch-more-error {
916
+ padding: 8px 12px;
917
+ text-align: center;
918
+ color: var(--_danger);
919
+ font-size: 0.9em;
920
+ }
921
+
922
+ .load-more {
923
+ display: block;
924
+ width: 100%;
925
+ padding: 8px 12px;
926
+ background: none;
927
+ border: none;
928
+ color: var(--_muted-fg);
929
+ font: inherit;
930
+ font-size: 0.9em;
931
+ cursor: pointer;
932
+ }
933
+
934
+ .load-more:hover,
935
+ .load-more:focus-visible {
936
+ color: var(--_surface-fg);
937
+ background: var(--_muted);
938
+ }
939
+
940
+ .licensed {
941
+ padding: 24px 16px;
942
+ text-align: center;
943
+ display: flex;
944
+ flex-direction: column;
945
+ gap: 12px;
946
+ }
947
+
948
+ .memories {
949
+ border-top: 1px solid var(--_border);
950
+ padding: 8px 12px;
951
+ }
952
+
953
+ .memories[hidden] {
954
+ display: none;
955
+ }
956
+
957
+ .dialog-backdrop {
958
+ position: absolute;
959
+ inset: 0;
960
+ background: rgba(0, 0, 0, 0.3);
961
+ display: flex;
962
+ align-items: center;
963
+ justify-content: center;
964
+ z-index: 10;
965
+ }
966
+
967
+ .dialog {
968
+ background: var(--_surface);
969
+ color: var(--_surface-fg);
970
+ border-radius: var(--_radius);
971
+ padding: 16px;
972
+ max-width: 80%;
973
+ display: flex;
974
+ flex-direction: column;
975
+ gap: 12px;
976
+ }
977
+
978
+ .dialog-actions {
979
+ display: flex;
980
+ justify-content: flex-end;
981
+ gap: 8px;
982
+ }
983
+
984
+ .footer {
985
+ border-top: 1px solid var(--_border);
986
+ padding: 12px;
987
+ }
988
+
989
+ .footer[hidden] {
990
+ display: none;
991
+ }
992
+ `;
993
+ const we = { ATTRIBUTE: 1, CHILD: 2 }, ye = (s) => (...e) => ({ _$litDirective$: s, values: e });
994
+ let xe = class {
995
+ constructor(e) {
996
+ }
997
+ get _$AU() {
998
+ return this._$AM._$AU;
999
+ }
1000
+ _$AT(e, t, r) {
1001
+ this._$Ct = e, this._$AM = t, this._$Ci = r;
1002
+ }
1003
+ _$AS(e, t) {
1004
+ return this.update(e, t);
1005
+ }
1006
+ update(e, t) {
1007
+ return this.render(...t);
1008
+ }
1009
+ };
1010
+ const { I: Ye } = qe, ce = (s) => s, he = () => document.createComment(""), N = (s, e, t) => {
1011
+ const r = s._$AA.parentNode, i = e === void 0 ? s._$AB : e._$AA;
1012
+ if (t === void 0) {
1013
+ const o = r.insertBefore(he(), i), n = r.insertBefore(he(), i);
1014
+ t = new Ye(o, n, s, s.options);
1015
+ } else {
1016
+ const o = t._$AB.nextSibling, n = t._$AM, d = n !== s;
1017
+ if (d) {
1018
+ let a;
1019
+ t._$AQ?.(s), t._$AM = s, t._$AP !== void 0 && (a = s._$AU) !== n._$AU && t._$AP(a);
1020
+ }
1021
+ if (o !== i || d) {
1022
+ let a = t._$AA;
1023
+ for (; a !== o; ) {
1024
+ const c = ce(a).nextSibling;
1025
+ ce(r).insertBefore(a, i), a = c;
1026
+ }
1027
+ }
1028
+ }
1029
+ return t;
1030
+ }, x = (s, e, t = s) => (s._$AI(e, t), s), Ze = {}, Ge = (s, e = Ze) => s._$AH = e, Je = (s) => s._$AH, F = (s) => {
1031
+ s._$AR(), s._$AA.remove();
1032
+ };
1033
+ const pe = (s, e, t) => {
1034
+ const r = /* @__PURE__ */ new Map();
1035
+ for (let i = e; i <= t; i++) r.set(s[i], i);
1036
+ return r;
1037
+ }, Xe = ye(class extends xe {
1038
+ constructor(s) {
1039
+ if (super(s), s.type !== we.CHILD) throw Error("repeat() can only be used in text expressions");
1040
+ }
1041
+ dt(s, e, t) {
1042
+ let r;
1043
+ t === void 0 ? t = e : e !== void 0 && (r = e);
1044
+ const i = [], o = [];
1045
+ let n = 0;
1046
+ for (const d of s) i[n] = r ? r(d, n) : n, o[n] = t(d, n), n++;
1047
+ return { values: o, keys: i };
1048
+ }
1049
+ render(s, e, t) {
1050
+ return this.dt(s, e, t).values;
1051
+ }
1052
+ update(s, [e, t, r]) {
1053
+ const i = Je(s), { values: o, keys: n } = this.dt(e, t, r);
1054
+ if (!Array.isArray(i)) return this.ut = n, o;
1055
+ const d = this.ut ??= [], a = [];
1056
+ let c, m, l = 0, p = i.length - 1, h = 0, _ = o.length - 1;
1057
+ for (; l <= p && h <= _; ) if (i[l] === null) l++;
1058
+ else if (i[p] === null) p--;
1059
+ else if (d[l] === n[h]) a[h] = x(i[l], o[h]), l++, h++;
1060
+ else if (d[p] === n[_]) a[_] = x(i[p], o[_]), p--, _--;
1061
+ else if (d[l] === n[_]) a[_] = x(i[l], o[_]), N(s, a[_ + 1], i[l]), l++, _--;
1062
+ else if (d[p] === n[h]) a[h] = x(i[p], o[h]), N(s, i[l], i[p]), p--, h++;
1063
+ else if (c === void 0 && (c = pe(n, h, _), m = pe(d, l, p)), c.has(d[l])) if (c.has(d[p])) {
1064
+ const b = m.get(n[h]), z = b !== void 0 ? i[b] : null;
1065
+ if (z === null) {
1066
+ const J = N(s, i[l]);
1067
+ x(J, o[h]), a[h] = J;
1068
+ } else a[h] = x(z, o[h]), N(s, i[l], z), i[b] = null;
1069
+ h++;
1070
+ } else F(i[p]), p--;
1071
+ else F(i[l]), l++;
1072
+ for (; h <= _; ) {
1073
+ const b = N(s, a[_ + 1]);
1074
+ x(b, o[h]), a[h++] = b;
1075
+ }
1076
+ for (; l <= p; ) {
1077
+ const b = i[l++];
1078
+ b !== null && F(b);
1079
+ }
1080
+ return this.ut = n, Ge(s, a), w;
1081
+ }
1082
+ });
1083
+ const q = ye(class extends xe {
1084
+ constructor(s) {
1085
+ if (super(s), s.type !== we.ATTRIBUTE || s.name !== "class" || s.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.");
1086
+ }
1087
+ render(s) {
1088
+ return " " + Object.keys(s).filter((e) => s[e]).join(" ") + " ";
1089
+ }
1090
+ update(s, [e]) {
1091
+ if (this.st === void 0) {
1092
+ this.st = /* @__PURE__ */ new Set(), s.strings !== void 0 && (this.nt = new Set(s.strings.join(" ").split(/\s/).filter((r) => r !== "")));
1093
+ for (const r in e) e[r] && !this.nt?.has(r) && this.st.add(r);
1094
+ return this.render(e);
1095
+ }
1096
+ const t = s.element.classList;
1097
+ for (const r of this.st) r in e || (t.remove(r), this.st.delete(r));
1098
+ for (const r in e) {
1099
+ const i = !!e[r];
1100
+ i === this.st.has(r) || this.nt?.has(r) || (i ? (t.add(r), this.st.add(r)) : (t.remove(r), this.st.delete(r)));
1101
+ }
1102
+ return w;
1103
+ }
1104
+ }), ue = "copilotkit-threads-drawer", et = 768;
1105
+ function K(s) {
1106
+ return s !== null && s.trim().length > 0;
1107
+ }
1108
+ function tt(s) {
1109
+ return s.length === 0 || /[\s"'<>=]/.test(s) ? null : `row:${s}`;
1110
+ }
1111
+ const rt = u`
1112
+ <svg
1113
+ class="row-action-icon"
1114
+ viewBox="0 0 24 24"
1115
+ fill="none"
1116
+ stroke="currentColor"
1117
+ stroke-width="2"
1118
+ stroke-linecap="round"
1119
+ stroke-linejoin="round"
1120
+ aria-hidden="true"
1121
+ >
1122
+ <rect width="20" height="5" x="2" y="3" rx="1" />
1123
+ <path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8" />
1124
+ <path d="M10 12h4" />
1125
+ </svg>
1126
+ `, it = u`
1127
+ <svg
1128
+ class="row-action-icon"
1129
+ viewBox="0 0 24 24"
1130
+ fill="none"
1131
+ stroke="currentColor"
1132
+ stroke-width="2"
1133
+ stroke-linecap="round"
1134
+ stroke-linejoin="round"
1135
+ aria-hidden="true"
1136
+ >
1137
+ <rect width="20" height="5" x="2" y="3" rx="1" />
1138
+ <path d="M4 8v11a2 2 0 0 0 2 2h2" />
1139
+ <path d="M20 8v11a2 2 0 0 1-2 2h-2" />
1140
+ <path d="m9 15 3-3 3 3" />
1141
+ <path d="M12 12v9" />
1142
+ </svg>
1143
+ `, st = u`
1144
+ <svg
1145
+ class="row-action-icon"
1146
+ viewBox="0 0 24 24"
1147
+ fill="none"
1148
+ stroke="currentColor"
1149
+ stroke-width="2"
1150
+ stroke-linecap="round"
1151
+ stroke-linejoin="round"
1152
+ aria-hidden="true"
1153
+ >
1154
+ <path d="M3 6h18" />
1155
+ <path
1156
+ d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"
1157
+ />
1158
+ <line x1="10" x2="10" y1="11" y2="17" />
1159
+ <line x1="14" x2="14" y1="11" y2="17" />
1160
+ </svg>
1161
+ `, ot = u`
1162
+ <svg
1163
+ class="launcher-icon"
1164
+ viewBox="0 0 24 24"
1165
+ fill="none"
1166
+ stroke="currentColor"
1167
+ stroke-width="2"
1168
+ stroke-linecap="round"
1169
+ stroke-linejoin="round"
1170
+ aria-hidden="true"
1171
+ >
1172
+ <rect width="18" height="18" x="3" y="3" rx="2" />
1173
+ <path d="M9 3v18" />
1174
+ <path d="m14 9 3 3-3 3" />
1175
+ </svg>
1176
+ `;
1177
+ var k, nt = (k = class extends O {
1178
+ constructor(...e) {
1179
+ super(...e), this.label = "Threads", this.threads = [], this.loading = !1, this.error = null, this.activeThreadId = null, this.licensed = !0, this.licenseUrl = "https://docs.copilotkit.ai/intelligence", this.hasMore = !1, this.fetchingMore = !1, this.fetchMoreError = null, this.open = !0, this.collapsed = !1, this._filter = "active", this._confirmingDeleteId = null, this._viewportIsMobile = !1, this._hasMemories = !1, this._hasFooter = !1, this._mediaQuery = null, this._onMediaChange = (t) => {
1180
+ this._viewportIsMobile = t.matches;
1181
+ }, this._onKeyDown = (t) => {
1182
+ if (t.key === "Escape") {
1183
+ if (this._confirmingDeleteId !== null) {
1184
+ this._confirmingDeleteId = null, t.stopPropagation();
1185
+ return;
1186
+ }
1187
+ this._viewportIsMobile && this.open && (this._setOpen(!1), t.stopPropagation());
1188
+ return;
1189
+ }
1190
+ t.key === "Tab" && this._trapTab(t);
1191
+ }, this._seenNamed = /* @__PURE__ */ new Set(), this._justRevealed = /* @__PURE__ */ new Set(), this._scrollLocked = !1, this._prevBodyOverflow = "", this._trapTab = (t) => {
1192
+ if (t.key !== "Tab" || !this._isMobileModalOpen()) return;
1193
+ const r = this._composedFocusable();
1194
+ if (r.length === 0) return;
1195
+ const i = r[0], o = r[r.length - 1], n = this.renderRoot.activeElement ?? document.activeElement;
1196
+ t.shiftKey && n === i ? (o.focus(), t.preventDefault()) : !t.shiftKey && n === o && (i.focus(), t.preventDefault());
1197
+ };
1198
+ }
1199
+ connectedCallback() {
1200
+ super.connectedCallback(), typeof window < "u" && window.matchMedia && (this._mediaQuery = window.matchMedia(`(max-width: ${et}px)`), this._viewportIsMobile = this._mediaQuery.matches, this._mediaQuery.addEventListener("change", this._onMediaChange)), this.addEventListener("keydown", this._onKeyDown);
1201
+ }
1202
+ disconnectedCallback() {
1203
+ super.disconnectedCallback(), this._mediaQuery?.removeEventListener("change", this._onMediaChange), this.removeEventListener("keydown", this._onKeyDown), this._releaseScrollLock();
1204
+ }
1205
+ willUpdate(e) {
1206
+ if (e.has("threads")) {
1207
+ const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
1208
+ for (const i of this.threads) {
1209
+ t.add(i.id);
1210
+ const o = i.name !== null && i.name !== "";
1211
+ o && !this._seenNamed.has(i.id) && r.add(i.id), o && this._seenNamed.add(i.id);
1212
+ }
1213
+ for (const i of this._seenNamed) t.has(i) || this._seenNamed.delete(i);
1214
+ this._justRevealed = r, this._confirmingDeleteId !== null && (this._visibleThreads().some((i) => i.id === this._confirmingDeleteId) || (this._confirmingDeleteId = null));
1215
+ }
1216
+ }
1217
+ updated(e) {
1218
+ (e.has("open") || e.has("_viewportIsMobile")) && (this._isMobileModalOpen() ? (this._applyScrollLock(), this._focusFirstFocusable()) : this._releaseScrollLock()), this._justRevealed.size > 0 && (this._justRevealed = /* @__PURE__ */ new Set()), this._syncNameClipping();
1219
+ }
1220
+ /**
1221
+ * Marks each row whose name text is truncated with `name-clipped`, so the CSS
1222
+ * shows the name tooltip ONLY when the full name isn't already visible (an
1223
+ * always-on bubble over every row on hover would be noise). Measured after
1224
+ * render because truncation depends on the laid-out width.
1225
+ */
1226
+ _syncNameClipping() {
1227
+ this.renderRoot.querySelectorAll(".row-name").forEach((e) => {
1228
+ const t = e.querySelector(".row-name-text"), r = !!t && t.scrollWidth > t.clientWidth;
1229
+ e.classList.toggle("name-clipped", r), e.closest(".row")?.classList.toggle("name-clipped", r);
1230
+ });
1231
+ }
1232
+ _isMobileModalOpen() {
1233
+ return this._viewportIsMobile && this.open;
1234
+ }
1235
+ _setOpen(e) {
1236
+ this.open !== e && (this.open = e, this._emit("open-change", { open: e }));
1237
+ }
1238
+ _setFilter(e) {
1239
+ this._filter !== e && (this._filter = e, this._emit("filter-change", { filter: e }));
1240
+ }
1241
+ /**
1242
+ * Element-authoritative ordering + filtering. Active filter hides archived
1243
+ * threads; ordering is most-recent-first by `lastRunAt`/`updatedAt`.
1244
+ */
1245
+ _visibleThreads() {
1246
+ const e = this._filter === "active" ? this.threads.filter((r) => !r.archived) : this.threads, t = (r) => {
1247
+ const i = r.lastRunAt ?? r.updatedAt ?? r.createdAt, o = Date.parse(i);
1248
+ return Number.isNaN(o) ? null : o;
1249
+ };
1250
+ return [...e].map((r, i) => ({
1251
+ thread: r,
1252
+ index: i,
1253
+ ts: t(r)
1254
+ })).sort((r, i) => r.ts === null && i.ts === null ? r.index - i.index : r.ts === null ? 1 : i.ts === null ? -1 : r.ts !== i.ts ? i.ts - r.ts : r.index - i.index).map((r) => r.thread);
1255
+ }
1256
+ _emit(e, t) {
1257
+ this.dispatchEvent(new CustomEvent(e, {
1258
+ detail: t,
1259
+ bubbles: !0,
1260
+ composed: !0
1261
+ }));
1262
+ }
1263
+ _applyScrollLock() {
1264
+ this._scrollLocked || typeof document > "u" || (this._prevBodyOverflow = document.body.style.overflow, document.body.style.overflow = "hidden", this._scrollLocked = !0);
1265
+ }
1266
+ _releaseScrollLock() {
1267
+ !this._scrollLocked || typeof document > "u" || (document.body.style.overflow = this._prevBodyOverflow, this._scrollLocked = !1);
1268
+ }
1269
+ /**
1270
+ * Returns the focusable elements in the composed/flattened tree of the drawer
1271
+ * root, INCLUDING slotted light-DOM content (so a focus trap covers slotted
1272
+ * rows). Walks assigned nodes of each `<slot>`.
1273
+ */
1274
+ _composedFocusable() {
1275
+ const e = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])', t = [], r = this.renderRoot.querySelector(".backdrop");
1276
+ r && t.push(r);
1277
+ const i = this.renderRoot.querySelector(".root");
1278
+ if (!i) return t;
1279
+ const o = (n) => {
1280
+ n.querySelectorAll(e).forEach((d) => t.push(d));
1281
+ };
1282
+ return o(i), i.querySelectorAll("slot").forEach((n) => {
1283
+ n.assignedElements({ flatten: !0 }).forEach((d) => {
1284
+ d.matches(e) && t.push(d), o(d);
1285
+ });
1286
+ }), t;
1287
+ }
1288
+ _focusFirstFocusable() {
1289
+ queueMicrotask(() => {
1290
+ const e = this._composedFocusable(), t = this.renderRoot.querySelector(".backdrop");
1291
+ (e.find((r) => r !== t) ?? e[0])?.focus();
1292
+ });
1293
+ }
1294
+ render() {
1295
+ const e = {
1296
+ root: !0,
1297
+ collapsed: this.collapsed && !this._viewportIsMobile,
1298
+ mobile: this._viewportIsMobile,
1299
+ open: this.open,
1300
+ confirming: this._confirmingDeleteId !== null
1301
+ };
1302
+ return u`
1303
+ ${this._viewportIsMobile && !this.open ? u`<button
1304
+ class="launcher"
1305
+ part="launcher"
1306
+ aria-label="Open threads"
1307
+ @click=${() => this._setOpen(!0)}
1308
+ >
1309
+ <slot name="launcher-icon">${ot}</slot>
1310
+ </button>` : f}
1311
+ ${this._isMobileModalOpen() ? u`<button
1312
+ class="backdrop"
1313
+ part="backdrop"
1314
+ aria-label="Close threads drawer"
1315
+ @click=${() => this._setOpen(!1)}
1316
+ ></button>` : f}
1317
+ <div
1318
+ class=${q(e)}
1319
+ part="root"
1320
+ role=${this._isMobileModalOpen() ? "dialog" : "region"}
1321
+ aria-modal=${this._isMobileModalOpen() ? "true" : f}
1322
+ aria-label=${this.label}
1323
+ >
1324
+ ${this._renderHeader()} ${this._renderBody()} ${this._renderMemories()}
1325
+ ${this._renderFooter()} ${this._renderConfirmDialog()}
1326
+ </div>
1327
+ `;
1328
+ }
1329
+ _renderHeader() {
1330
+ return u`
1331
+ <div class="header" part="header">
1332
+ <slot name="header"><span>${this.label}</span></slot>
1333
+ <button
1334
+ class="primary"
1335
+ part="new-thread-button"
1336
+ aria-label="New thread"
1337
+ @click=${() => this._emit("new-thread", {})}
1338
+ >
1339
+ + New
1340
+ </button>
1341
+ </div>
1342
+ ${this.licensed && (!K(this.error) || this.threads.length > 0) ? u`
1343
+ <div class="filters" part="filters" role="group" aria-label="Filter threads">
1344
+ <button
1345
+ class="filter-btn"
1346
+ part="filter-active"
1347
+ aria-pressed=${this._filter === "active"}
1348
+ @click=${() => this._setFilter("active")}
1349
+ >
1350
+ Active
1351
+ </button>
1352
+ <button
1353
+ class="filter-btn"
1354
+ part="filter-all"
1355
+ aria-pressed=${this._filter === "all"}
1356
+ @click=${() => this._setFilter("all")}
1357
+ >
1358
+ All
1359
+ </button>
1360
+ </div>
1361
+ ` : f}
1362
+ `;
1363
+ }
1364
+ _renderBody() {
1365
+ return this.licensed ? K(this.error) && this.threads.length === 0 ? this._renderError() : this.loading && this.threads.length === 0 ? this._renderLoading() : this._renderList() : this._renderLicensed();
1366
+ }
1367
+ /**
1368
+ * Handles the Upgrade CTA click in the locked view. Dispatches a cancelable
1369
+ * `licensed` event carrying the resolved `licenseUrl`; unless a host calls
1370
+ * `preventDefault()`, opens that URL in a new tab. A blank `licenseUrl`
1371
+ * suppresses navigation so the event alone drives host behavior.
1372
+ */
1373
+ _onLicensedCta() {
1374
+ this.dispatchEvent(new CustomEvent("licensed", {
1375
+ detail: { licenseUrl: this.licenseUrl },
1376
+ bubbles: !0,
1377
+ composed: !0,
1378
+ cancelable: !0
1379
+ })) && this.licenseUrl && typeof window < "u" && window.open(this.licenseUrl, "_blank", "noopener,noreferrer");
1380
+ }
1381
+ _renderLicensed() {
1382
+ return u`
1383
+ <div class="licensed" part="licensed" data-testid="drawer-licensed">
1384
+ <slot name="licensed">
1385
+ <p>Threads are a CopilotKit Intelligence feature.</p>
1386
+ <button
1387
+ class="primary"
1388
+ part="licensed-cta"
1389
+ @click=${() => this._onLicensedCta()}
1390
+ >
1391
+ Upgrade
1392
+ </button>
1393
+ </slot>
1394
+ </div>
1395
+ `;
1396
+ }
1397
+ _renderError() {
1398
+ return u`
1399
+ <div class="state error" part="error" role="alert" data-testid="drawer-error">
1400
+ <p>${this.error}</p>
1401
+ <button
1402
+ class="primary"
1403
+ part="retry-button"
1404
+ @click=${() => this._emit("retry", { scope: "initial" })}
1405
+ >
1406
+ Retry
1407
+ </button>
1408
+ </div>
1409
+ `;
1410
+ }
1411
+ _renderLoading() {
1412
+ return u`
1413
+ <div class="state" part="loading" data-testid="drawer-loading" aria-busy="true">
1414
+ Loading threads…
1415
+ </div>
1416
+ `;
1417
+ }
1418
+ _renderList() {
1419
+ const e = this._visibleThreads();
1420
+ return e.length === 0 ? u`
1421
+ <div class="state" part="empty" data-testid="drawer-empty">
1422
+ <slot name="empty">No threads yet.</slot>
1423
+ </div>
1424
+ ` : u`
1425
+ <ul class="list" part="list" role="listbox" aria-label=${this.label}>
1426
+ ${Xe(e, (t) => t.id, (t) => this._renderRow(t))}
1427
+ </ul>
1428
+ ${this._renderFetchMore()}
1429
+ `;
1430
+ }
1431
+ _renderRow(e) {
1432
+ const t = e.id === this.activeThreadId, r = e.name !== null && e.name !== "", i = this._justRevealed.has(e.id), o = {
1433
+ row: !0,
1434
+ active: t,
1435
+ archived: e.archived
1436
+ }, n = {
1437
+ "row-name": !0,
1438
+ placeholder: !r,
1439
+ revealed: i
1440
+ }, d = tt(e.id), a = u`<span
1441
+ class=${q(n)}
1442
+ part="row-name"
1443
+ data-tooltip=${r ? e.name : f}
1444
+ >
1445
+ <span class="row-name-text"
1446
+ >${r ? e.name : "New thread"}</span
1447
+ >
1448
+ </span>`;
1449
+ return u`
1450
+ <li
1451
+ class=${q(o)}
1452
+ part=${t ? "row row-active" : "row"}
1453
+ role="option"
1454
+ aria-selected=${t ? "true" : "false"}
1455
+ tabindex="0"
1456
+ data-thread-id=${e.id}
1457
+ @click=${() => this._emit("thread-selected", { threadId: e.id })}
1458
+ @keydown=${(c) => {
1459
+ (c.key === "Enter" || c.key === " ") && (c.preventDefault(), this._emit("thread-selected", { threadId: e.id }));
1460
+ }}
1461
+ >
1462
+ ${d !== null ? u`<slot name=${d}>${a}</slot>` : a}
1463
+ ${e.archived ? u`<button
1464
+ class="row-action"
1465
+ part="row-unarchive"
1466
+ data-tooltip="Unarchive"
1467
+ aria-label=${`Unarchive thread ${e.name ?? "New thread"}`}
1468
+ @click=${(c) => {
1469
+ c.stopPropagation(), this._emit("unarchive", { threadId: e.id });
1470
+ }}
1471
+ >
1472
+ ${it}
1473
+ </button>` : u`<button
1474
+ class="row-action"
1475
+ part="row-archive"
1476
+ data-tooltip="Archive"
1477
+ aria-label=${`Archive thread ${e.name ?? "New thread"}`}
1478
+ @click=${(c) => {
1479
+ c.stopPropagation(), this._emit("archive", { threadId: e.id });
1480
+ }}
1481
+ >
1482
+ ${rt}
1483
+ </button>`}
1484
+ <button
1485
+ class="row-action danger"
1486
+ part="row-delete"
1487
+ data-tooltip="Delete"
1488
+ aria-label=${`Delete thread ${e.name ?? "New thread"}`}
1489
+ @click=${(c) => {
1490
+ c.stopPropagation(), this._confirmingDeleteId = e.id;
1491
+ }}
1492
+ >
1493
+ ${st}
1494
+ </button>
1495
+ </li>
1496
+ `;
1497
+ }
1498
+ _renderFetchMore() {
1499
+ return K(this.fetchMoreError) ? u`
1500
+ <div class="fetch-more-error" part="fetch-more-error" role="alert">
1501
+ Couldn't load more —
1502
+ <button
1503
+ class="row-action"
1504
+ part="fetch-more-retry"
1505
+ @click=${() => this._emit("retry", { scope: "fetch-more" })}
1506
+ >
1507
+ retry
1508
+ </button>
1509
+ </div>
1510
+ ` : this.fetchingMore ? u`
1511
+ <div class="state" part="fetching-more" aria-busy="true">Loading more…</div>
1512
+ ` : this.hasMore ? u`
1513
+ <button
1514
+ class="load-more"
1515
+ part="load-more"
1516
+ @click=${() => this._emit("load-more", {})}
1517
+ >
1518
+ Load more
1519
+ </button>
1520
+ ` : f;
1521
+ }
1522
+ _renderMemories() {
1523
+ return u`
1524
+ <div class="memories" part="memories" ?hidden=${!this._hasMemories}>
1525
+ <slot
1526
+ name="memories"
1527
+ @slotchange=${(e) => {
1528
+ this._hasMemories = e.target.assignedElements().length > 0;
1529
+ }}
1530
+ ></slot>
1531
+ </div>
1532
+ `;
1533
+ }
1534
+ _renderFooter() {
1535
+ return u`
1536
+ <div class="footer" part="footer" ?hidden=${!this._hasFooter}>
1537
+ <slot
1538
+ name="footer"
1539
+ @slotchange=${(e) => {
1540
+ this._hasFooter = e.target.assignedElements().length > 0;
1541
+ }}
1542
+ ></slot>
1543
+ </div>
1544
+ `;
1545
+ }
1546
+ _renderConfirmDialog() {
1547
+ if (this._confirmingDeleteId === null) return f;
1548
+ const e = this._confirmingDeleteId;
1549
+ return u`
1550
+ <div class="dialog-backdrop" part="dialog-backdrop">
1551
+ <div
1552
+ class="dialog"
1553
+ part="confirm-dialog"
1554
+ role="alertdialog"
1555
+ aria-modal="true"
1556
+ aria-label="Confirm delete"
1557
+ data-testid="drawer-confirm-delete"
1558
+ >
1559
+ <p>Delete this thread? This cannot be undone.</p>
1560
+ <div class="dialog-actions">
1561
+ <button
1562
+ class="row-action"
1563
+ part="confirm-cancel"
1564
+ @click=${() => this._confirmingDeleteId = null}
1565
+ >
1566
+ Cancel
1567
+ </button>
1568
+ <button
1569
+ class="primary"
1570
+ part="confirm-delete"
1571
+ @click=${() => {
1572
+ this._confirmingDeleteId = null, this._emit("delete", { threadId: e });
1573
+ }}
1574
+ >
1575
+ Delete
1576
+ </button>
1577
+ </div>
1578
+ </div>
1579
+ </div>
1580
+ `;
1581
+ }
1582
+ }, k.styles = Qe, k.properties = {
1583
+ threads: { attribute: !1 },
1584
+ loading: { type: Boolean },
1585
+ error: { type: String },
1586
+ activeThreadId: {
1587
+ attribute: "active-thread-id",
1588
+ type: String
1589
+ },
1590
+ licensed: { type: Boolean },
1591
+ licenseUrl: {
1592
+ attribute: "license-url",
1593
+ type: String
1594
+ },
1595
+ hasMore: {
1596
+ attribute: "has-more",
1597
+ type: Boolean
1598
+ },
1599
+ fetchingMore: {
1600
+ attribute: "fetching-more",
1601
+ type: Boolean
1602
+ },
1603
+ fetchMoreError: {
1604
+ attribute: "fetch-more-error",
1605
+ type: String
1606
+ },
1607
+ label: { type: String },
1608
+ open: {
1609
+ type: Boolean,
1610
+ reflect: !0
1611
+ },
1612
+ collapsed: {
1613
+ type: Boolean,
1614
+ reflect: !0
1615
+ },
1616
+ _filter: { state: !0 },
1617
+ _confirmingDeleteId: { state: !0 },
1618
+ _viewportIsMobile: { state: !0 },
1619
+ _hasMemories: { state: !0 },
1620
+ _hasFooter: { state: !0 }
1621
+ }, k);
1622
+ function ht() {
1623
+ typeof customElements < "u" && !customElements.get(ue) && customElements.define(ue, nt);
1624
+ }
1625
+ export {
1626
+ ue as COPILOTKIT_THREADS_DRAWER_TAG,
1627
+ nt as CopilotKitThreadsDrawer,
1628
+ Ae as GENERATED_DRAWER_TOKEN_DEFAULTS,
1629
+ ht as defineCopilotKitThreadsDrawer,
1630
+ Qe as drawerStyles
1631
+ };
1632
+ //# sourceMappingURL=index-By5nIKxT.js.map