@alxxsck/ai-assistant 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4772 @@
1
+ import { jsxs as N, jsx as i, Fragment as Ce } from "react/jsx-runtime";
2
+ import * as we from "react";
3
+ import V, { useContext as Ee, createContext as Ue, useId as Qe, useState as F, useMemo as ue, useCallback as U, useEffect as R, useRef as S, useSyncExternalStore as Nn, Fragment as Kt, useReducer as Mr, createRef as ja, useLayoutEffect as ye, forwardRef as _r, createElement as fn, memo as kr } from "react";
4
+ import { Y as be, K as Ne, a as An, y as He, n as et, b as tt, o as oe, c as St, s as Ht, u as At, l as Mt, d as _t, r as Qn, e as za, t as Sn, T as Wa, p as Lr, f as Rr, g as Ir, h as Ga, O as zt, i as Or, j as ze, k as Ft, m as qa, A as er, $ as Ka, q as Ya, V as Za, v as ne, P as Te, w as me, x as kt, L as Q, z as Xa, B as Ja, S as $r, C as Qa, D as eo, E as to, F as Yt, G as Mn, H as Fr, I as _n, J as Se, M as ve, N as st, Q as $e, R as no, U as ro, W as ao, X as oo, Z as Pr, _ as so, a0 as io, a1 as co, a2 as kn, a3 as lo, a4 as uo, a5 as Ln, a6 as Xe, a7 as ho, a8 as fo, a9 as mo, aa as po, ab as go, ac as Dr, ad as Ur, ae as vo, af as wo, ag as yo, ah as bo, ai as xo, aj as Co, ak as Hr, al as Rn, am as Br, an as To, ao as Eo, ap as No, aq as Ao, ar as In, as as So, at as Bt, au as Mo, av as _o, aw as ko, ax as Lo, ay as Ro, az as Io, aA as it, aB as Oo, aC as on, aD as $o, aE as pt, aF as mn } from "./mount-B4JOSFpY.js";
5
+ import { o as Fo, L as Po, a as Do } from "./index-C6_FMpJa.js";
6
+ import { createPortal as Uo } from "react-dom";
7
+ let Ho = "span";
8
+ var Wt = ((e) => (e[e.None = 1] = "None", e[e.Focusable = 2] = "Focusable", e[e.Hidden = 4] = "Hidden", e))(Wt || {});
9
+ function Bo(e, t) {
10
+ var n;
11
+ let { features: r = 1, ...a } = e, o = { ref: t, "aria-hidden": (r & 2) === 2 ? !0 : (n = a["aria-hidden"]) != null ? n : void 0, hidden: (r & 4) === 4 ? !0 : void 0, style: { position: "fixed", top: 1, left: 1, width: 1, height: 0, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0", ...(r & 4) === 4 && (r & 2) !== 2 && { display: "none" } } };
12
+ return Ne()({ ourProps: o, theirProps: a, slot: {}, defaultTag: Ho, name: "Hidden" });
13
+ }
14
+ let pn = be(Bo), Vo = Ue(void 0);
15
+ function Vr() {
16
+ return Ee(Vo);
17
+ }
18
+ function jo(e) {
19
+ return typeof e != "object" || e === null ? !1 : "nodeType" in e;
20
+ }
21
+ function Pe(e) {
22
+ return jo(e) && "tagName" in e;
23
+ }
24
+ function qe(e) {
25
+ return Pe(e) && "accessKey" in e;
26
+ }
27
+ function Ge(e) {
28
+ return Pe(e) && "tabIndex" in e;
29
+ }
30
+ function zo(e) {
31
+ return Pe(e) && "style" in e;
32
+ }
33
+ function Wo(e) {
34
+ return qe(e) && e.nodeName === "IFRAME";
35
+ }
36
+ function jr(e) {
37
+ return qe(e) && e.nodeName === "INPUT";
38
+ }
39
+ function tr(e) {
40
+ return qe(e) && e.nodeName === "LABEL";
41
+ }
42
+ function Go(e) {
43
+ return Pe(e) ? e.matches('a[href],audio[controls],button,details,embed,iframe,img[usemap],input:not([type="hidden"]),label,select,textarea,video[controls]') : !1;
44
+ }
45
+ let Zt = Ue(null);
46
+ Zt.displayName = "DescriptionContext";
47
+ function zr() {
48
+ let e = Ee(Zt);
49
+ if (e === null) {
50
+ let t = new Error("You used a <Description /> component, but it is not inside a relevant parent.");
51
+ throw Error.captureStackTrace && Error.captureStackTrace(t, zr), t;
52
+ }
53
+ return e;
54
+ }
55
+ function qo() {
56
+ var e, t;
57
+ return (t = (e = Ee(Zt)) == null ? void 0 : e.value) != null ? t : void 0;
58
+ }
59
+ function Ko() {
60
+ let [e, t] = F([]);
61
+ return [e.length > 0 ? e.join(" ") : void 0, ue(() => function(n) {
62
+ let r = oe((o) => (t((c) => [...c, o]), () => t((c) => {
63
+ let s = c.slice(), l = s.indexOf(o);
64
+ return l !== -1 && s.splice(l, 1), s;
65
+ }))), a = ue(() => ({ register: r, slot: n.slot, name: n.name, props: n.props, value: n.value }), [r, n.slot, n.name, n.props, n.value]);
66
+ return V.createElement(Zt.Provider, { value: a }, n.children);
67
+ }, [t])];
68
+ }
69
+ let Yo = "p";
70
+ function Zo(e, t) {
71
+ let n = Qe(), r = An(), { id: a = `headlessui-description-${n}`, ...o } = e, c = zr(), s = He(t);
72
+ et(() => c.register(a), [a, c.register]);
73
+ let l = tt({ ...c.slot, disabled: r || !1 }), u = { ref: s, ...c.props, id: a };
74
+ return Ne()({ ourProps: u, theirProps: o, slot: l, defaultTag: Yo, name: c.name || "Description" });
75
+ }
76
+ let Xo = be(Zo), Jo = Object.assign(Xo, {});
77
+ var Wr = ((e) => (e.Space = " ", e.Enter = "Enter", e.Escape = "Escape", e.Backspace = "Backspace", e.Delete = "Delete", e.ArrowLeft = "ArrowLeft", e.ArrowUp = "ArrowUp", e.ArrowRight = "ArrowRight", e.ArrowDown = "ArrowDown", e.Home = "Home", e.End = "End", e.PageUp = "PageUp", e.PageDown = "PageDown", e.Tab = "Tab", e))(Wr || {});
78
+ let On = Ue(null);
79
+ On.displayName = "LabelContext";
80
+ function Gr() {
81
+ let e = Ee(On);
82
+ if (e === null) {
83
+ let t = new Error("You used a <Label /> component, but it is not inside a relevant parent.");
84
+ throw Error.captureStackTrace && Error.captureStackTrace(t, Gr), t;
85
+ }
86
+ return e;
87
+ }
88
+ function Qo(e) {
89
+ var t, n, r;
90
+ let a = (n = (t = Ee(On)) == null ? void 0 : t.value) != null ? n : void 0;
91
+ return ((r = void 0) != null ? r : 0) > 0 ? [a, ...e].filter(Boolean).join(" ") : a;
92
+ }
93
+ let es = "label";
94
+ function ts(e, t) {
95
+ var n;
96
+ let r = Qe(), a = Gr(), o = Vr(), c = An(), { id: s = `headlessui-label-${r}`, htmlFor: l = o ?? ((n = a.props) == null ? void 0 : n.htmlFor), passive: u = !1, ...w } = e, p = He(t);
97
+ et(() => a.register(s), [s, a.register]);
98
+ let d = oe((g) => {
99
+ let b = g.currentTarget;
100
+ if (!(g.target !== g.currentTarget && Go(g.target)) && (tr(b) && g.preventDefault(), a.props && "onClick" in a.props && typeof a.props.onClick == "function" && a.props.onClick(g), tr(b))) {
101
+ let C = document.getElementById(b.htmlFor);
102
+ if (C) {
103
+ let v = C.getAttribute("disabled");
104
+ if (v === "true" || v === "") return;
105
+ let y = C.getAttribute("aria-disabled");
106
+ if (y === "true" || y === "") return;
107
+ (jr(C) && (C.type === "file" || C.type === "radio" || C.type === "checkbox") || C.role === "radio" || C.role === "checkbox" || C.role === "switch") && C.click(), C.focus({ preventScroll: !0 });
108
+ }
109
+ }
110
+ }), h = tt({ ...a.slot, disabled: c || !1 }), m = { ref: p, ...a.props, id: s, htmlFor: l, onClick: d };
111
+ return u && ("onClick" in m && (delete m.htmlFor, delete m.onClick), "onClick" in w && delete w.onClick), Ne()({ ourProps: m, theirProps: w, slot: h, defaultTag: l ? es : "div", name: a.name || "Label" });
112
+ }
113
+ let ns = be(ts);
114
+ Object.assign(ns, {});
115
+ let rs = Ue(() => {
116
+ });
117
+ function as({ value: e, children: t }) {
118
+ return V.createElement(rs.Provider, { value: e }, t);
119
+ }
120
+ let qr = class extends Map {
121
+ constructor(t) {
122
+ super(), this.factory = t;
123
+ }
124
+ get(t) {
125
+ let n = super.get(t);
126
+ return n === void 0 && (n = this.factory(t), this.set(t, n)), n;
127
+ }
128
+ };
129
+ var os = Object.defineProperty, ss = (e, t, n) => t in e ? os(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, is = (e, t, n) => (ss(e, t + "", n), n), Kr = (e, t, n) => {
130
+ if (!t.has(e)) throw TypeError("Cannot " + n);
131
+ }, xe = (e, t, n) => (Kr(e, t, "read from private field"), n ? n.call(e) : t.get(e)), sn = (e, t, n) => {
132
+ if (t.has(e)) throw TypeError("Cannot add the same private member more than once");
133
+ t instanceof WeakSet ? t.add(e) : t.set(e, n);
134
+ }, nr = (e, t, n, r) => (Kr(e, t, "write to private field"), t.set(e, n), n), Le, bt, xt;
135
+ let cs = class {
136
+ constructor(t) {
137
+ sn(this, Le, {}), sn(this, bt, new qr(() => /* @__PURE__ */ new Set())), sn(this, xt, /* @__PURE__ */ new Set()), is(this, "disposables", St()), nr(this, Le, t), Ht.isServer && this.disposables.microTask(() => {
138
+ this.dispose();
139
+ });
140
+ }
141
+ dispose() {
142
+ this.disposables.dispose();
143
+ }
144
+ get state() {
145
+ return xe(this, Le);
146
+ }
147
+ subscribe(t, n) {
148
+ if (Ht.isServer) return () => {
149
+ };
150
+ let r = { selector: t, callback: n, current: t(xe(this, Le)) };
151
+ return xe(this, xt).add(r), this.disposables.add(() => {
152
+ xe(this, xt).delete(r);
153
+ });
154
+ }
155
+ on(t, n) {
156
+ return Ht.isServer ? () => {
157
+ } : (xe(this, bt).get(t).add(n), this.disposables.add(() => {
158
+ xe(this, bt).get(t).delete(n);
159
+ }));
160
+ }
161
+ send(t) {
162
+ let n = this.reduce(xe(this, Le), t);
163
+ if (n !== xe(this, Le)) {
164
+ nr(this, Le, n);
165
+ for (let r of xe(this, xt)) {
166
+ let a = r.selector(xe(this, Le));
167
+ Yr(r.current, a) || (r.current = a, r.callback(a));
168
+ }
169
+ for (let r of xe(this, bt).get(t.type)) r(xe(this, Le), t);
170
+ }
171
+ }
172
+ };
173
+ Le = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), xt = /* @__PURE__ */ new WeakMap();
174
+ function Yr(e, t) {
175
+ return Object.is(e, t) ? !0 : typeof e != "object" || e === null || typeof t != "object" || t === null ? !1 : Array.isArray(e) && Array.isArray(t) ? e.length !== t.length ? !1 : cn(e[Symbol.iterator](), t[Symbol.iterator]()) : e instanceof Map && t instanceof Map || e instanceof Set && t instanceof Set ? e.size !== t.size ? !1 : cn(e.entries(), t.entries()) : rr(e) && rr(t) ? cn(Object.entries(e)[Symbol.iterator](), Object.entries(t)[Symbol.iterator]()) : !1;
176
+ }
177
+ function cn(e, t) {
178
+ do {
179
+ let n = e.next(), r = t.next();
180
+ if (n.done && r.done) return !0;
181
+ if (n.done || r.done || !Object.is(n.value, r.value)) return !1;
182
+ } while (!0);
183
+ }
184
+ function rr(e) {
185
+ if (Object.prototype.toString.call(e) !== "[object Object]") return !1;
186
+ let t = Object.getPrototypeOf(e);
187
+ return t === null || Object.getPrototypeOf(t) === null;
188
+ }
189
+ var ls = Object.defineProperty, us = (e, t, n) => t in e ? ls(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, ar = (e, t, n) => (us(e, typeof t != "symbol" ? t + "" : t, n), n), ds = ((e) => (e[e.Push = 0] = "Push", e[e.Pop = 1] = "Pop", e))(ds || {});
190
+ let hs = { 0(e, t) {
191
+ let n = t.id, r = e.stack, a = e.stack.indexOf(n);
192
+ if (a !== -1) {
193
+ let o = e.stack.slice();
194
+ return o.splice(a, 1), o.push(n), r = o, { ...e, stack: r };
195
+ }
196
+ return { ...e, stack: [...e.stack, n] };
197
+ }, 1(e, t) {
198
+ let n = t.id, r = e.stack.indexOf(n);
199
+ if (r === -1) return e;
200
+ let a = e.stack.slice();
201
+ return a.splice(r, 1), { ...e, stack: a };
202
+ } }, fs = class Zr extends cs {
203
+ constructor() {
204
+ super(...arguments), ar(this, "actions", { push: (t) => this.send({ type: 0, id: t }), pop: (t) => this.send({ type: 1, id: t }) }), ar(this, "selectors", { isTop: (t, n) => t.stack[t.stack.length - 1] === n, inStack: (t, n) => t.stack.includes(n) });
205
+ }
206
+ static new() {
207
+ return new Zr({ stack: [] });
208
+ }
209
+ reduce(t, n) {
210
+ return At(n.type, hs, t, n);
211
+ }
212
+ };
213
+ const Xr = new qr(() => fs.new());
214
+ var Pt = { exports: {} }, ln = {};
215
+ var or;
216
+ function ms() {
217
+ if (or) return ln;
218
+ or = 1;
219
+ var e = V;
220
+ function t(l, u) {
221
+ return l === u && (l !== 0 || 1 / l === 1 / u) || l !== l && u !== u;
222
+ }
223
+ var n = typeof Object.is == "function" ? Object.is : t, r = e.useSyncExternalStore, a = e.useRef, o = e.useEffect, c = e.useMemo, s = e.useDebugValue;
224
+ return ln.useSyncExternalStoreWithSelector = function(l, u, w, p, d) {
225
+ var h = a(null);
226
+ if (h.current === null) {
227
+ var m = { hasValue: !1, value: null };
228
+ h.current = m;
229
+ } else m = h.current;
230
+ h = c(
231
+ function() {
232
+ function b(E) {
233
+ if (!C) {
234
+ if (C = !0, v = E, E = p(E), d !== void 0 && m.hasValue) {
235
+ var A = m.value;
236
+ if (d(A, E))
237
+ return y = A;
238
+ }
239
+ return y = E;
240
+ }
241
+ if (A = y, n(v, E)) return A;
242
+ var _ = p(E);
243
+ return d !== void 0 && d(A, _) ? (v = E, A) : (v = E, y = _);
244
+ }
245
+ var C = !1, v, y, T = w === void 0 ? null : w;
246
+ return [
247
+ function() {
248
+ return b(u());
249
+ },
250
+ T === null ? void 0 : function() {
251
+ return b(T());
252
+ }
253
+ ];
254
+ },
255
+ [u, w, p, d]
256
+ );
257
+ var g = r(l, h[0], h[1]);
258
+ return o(
259
+ function() {
260
+ m.hasValue = !0, m.value = g;
261
+ },
262
+ [g]
263
+ ), s(g), g;
264
+ }, ln;
265
+ }
266
+ var un = {};
267
+ var sr;
268
+ function ps() {
269
+ return sr || (sr = 1, process.env.NODE_ENV !== "production" && (function() {
270
+ function e(l, u) {
271
+ return l === u && (l !== 0 || 1 / l === 1 / u) || l !== l && u !== u;
272
+ }
273
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
274
+ var t = V, n = typeof Object.is == "function" ? Object.is : e, r = t.useSyncExternalStore, a = t.useRef, o = t.useEffect, c = t.useMemo, s = t.useDebugValue;
275
+ un.useSyncExternalStoreWithSelector = function(l, u, w, p, d) {
276
+ var h = a(null);
277
+ if (h.current === null) {
278
+ var m = { hasValue: !1, value: null };
279
+ h.current = m;
280
+ } else m = h.current;
281
+ h = c(
282
+ function() {
283
+ function b(E) {
284
+ if (!C) {
285
+ if (C = !0, v = E, E = p(E), d !== void 0 && m.hasValue) {
286
+ var A = m.value;
287
+ if (d(A, E))
288
+ return y = A;
289
+ }
290
+ return y = E;
291
+ }
292
+ if (A = y, n(v, E))
293
+ return A;
294
+ var _ = p(E);
295
+ return d !== void 0 && d(A, _) ? (v = E, A) : (v = E, y = _);
296
+ }
297
+ var C = !1, v, y, T = w === void 0 ? null : w;
298
+ return [
299
+ function() {
300
+ return b(u());
301
+ },
302
+ T === null ? void 0 : function() {
303
+ return b(T());
304
+ }
305
+ ];
306
+ },
307
+ [u, w, p, d]
308
+ );
309
+ var g = r(l, h[0], h[1]);
310
+ return o(
311
+ function() {
312
+ m.hasValue = !0, m.value = g;
313
+ },
314
+ [g]
315
+ ), s(g), g;
316
+ }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
317
+ })()), un;
318
+ }
319
+ var ir;
320
+ function gs() {
321
+ return ir || (ir = 1, process.env.NODE_ENV === "production" ? Pt.exports = ms() : Pt.exports = ps()), Pt.exports;
322
+ }
323
+ var vs = gs();
324
+ function Jr(e, t, n = Yr) {
325
+ return vs.useSyncExternalStoreWithSelector(oe((r) => e.subscribe(ws, r)), oe(() => e.state), oe(() => e.state), oe(t), n);
326
+ }
327
+ function ws(e) {
328
+ return e;
329
+ }
330
+ function Lt(e, t) {
331
+ let n = Qe(), r = Xr.get(t), [a, o] = Jr(r, U((c) => [r.selectors.isTop(c, n), r.selectors.inStack(c, n)], [r, n]));
332
+ return et(() => {
333
+ if (e) return r.actions.push(n), () => r.actions.pop(n);
334
+ }, [r, e, n]), e ? o ? a : !0 : !1;
335
+ }
336
+ let gn = /* @__PURE__ */ new Map(), Tt = /* @__PURE__ */ new Map();
337
+ function cr(e) {
338
+ var t;
339
+ let n = (t = Tt.get(e)) != null ? t : 0;
340
+ return Tt.set(e, n + 1), n !== 0 ? () => lr(e) : (gn.set(e, { "aria-hidden": e.getAttribute("aria-hidden"), inert: e.inert }), e.setAttribute("aria-hidden", "true"), e.inert = !0, () => lr(e));
341
+ }
342
+ function lr(e) {
343
+ var t;
344
+ let n = (t = Tt.get(e)) != null ? t : 1;
345
+ if (n === 1 ? Tt.delete(e) : Tt.set(e, n - 1), n !== 1) return;
346
+ let r = gn.get(e);
347
+ r && (r["aria-hidden"] === null ? e.removeAttribute("aria-hidden") : e.setAttribute("aria-hidden", r["aria-hidden"]), e.inert = r.inert, gn.delete(e));
348
+ }
349
+ function ys(e, { allowed: t, disallowed: n } = {}) {
350
+ let r = Lt(e, "inert-others");
351
+ et(() => {
352
+ var a, o;
353
+ if (!r) return;
354
+ let c = St();
355
+ for (let l of (a = n?.()) != null ? a : []) l && c.add(cr(l));
356
+ let s = (o = t?.()) != null ? o : [];
357
+ for (let l of s) {
358
+ if (!l) continue;
359
+ let u = Mt(l);
360
+ if (!u) continue;
361
+ let w = l.parentElement;
362
+ for (; w && w !== u.body; ) {
363
+ for (let p of w.children) s.some((d) => p.contains(d)) || c.add(cr(p));
364
+ w = w.parentElement;
365
+ }
366
+ }
367
+ return c.dispose;
368
+ }, [r, t, n]);
369
+ }
370
+ function bs(e, t, n) {
371
+ let r = _t((a) => {
372
+ let o = a.getBoundingClientRect();
373
+ o.x === 0 && o.y === 0 && o.width === 0 && o.height === 0 && n();
374
+ });
375
+ R(() => {
376
+ if (!e) return;
377
+ let a = t === null ? null : qe(t) ? t : t.current;
378
+ if (!a) return;
379
+ let o = St();
380
+ if (typeof ResizeObserver < "u") {
381
+ let c = new ResizeObserver(() => r.current(a));
382
+ c.observe(a), o.add(() => c.disconnect());
383
+ }
384
+ if (typeof IntersectionObserver < "u") {
385
+ let c = new IntersectionObserver(() => r.current(a));
386
+ c.observe(a), o.add(() => c.disconnect());
387
+ }
388
+ return () => o.dispose();
389
+ }, [t, r, e]);
390
+ }
391
+ let Gt = ["[contentEditable=true]", "[tabindex]", "a[href]", "area[href]", "button:not([disabled])", "iframe", "input:not([disabled])", "select:not([disabled])", "details>summary", "textarea:not([disabled])"].map((e) => `${e}:not([tabindex='-1'])`).join(","), xs = ["[data-autofocus]"].map((e) => `${e}:not([tabindex='-1'])`).join(",");
392
+ var Fe = ((e) => (e[e.First = 1] = "First", e[e.Previous = 2] = "Previous", e[e.Next = 4] = "Next", e[e.Last = 8] = "Last", e[e.WrapAround = 16] = "WrapAround", e[e.NoScroll = 32] = "NoScroll", e[e.AutoFocus = 64] = "AutoFocus", e))(Fe || {}), vn = ((e) => (e[e.Error = 0] = "Error", e[e.Overflow = 1] = "Overflow", e[e.Success = 2] = "Success", e[e.Underflow = 3] = "Underflow", e))(vn || {}), Cs = ((e) => (e[e.Previous = -1] = "Previous", e[e.Next = 1] = "Next", e))(Cs || {});
393
+ function Ts(e = document.body) {
394
+ return e == null ? [] : Array.from(e.querySelectorAll(Gt)).sort((t, n) => Math.sign((t.tabIndex || Number.MAX_SAFE_INTEGER) - (n.tabIndex || Number.MAX_SAFE_INTEGER)));
395
+ }
396
+ function Es(e = document.body) {
397
+ return e == null ? [] : Array.from(e.querySelectorAll(xs)).sort((t, n) => Math.sign((t.tabIndex || Number.MAX_SAFE_INTEGER) - (n.tabIndex || Number.MAX_SAFE_INTEGER)));
398
+ }
399
+ var Qr = ((e) => (e[e.Strict = 0] = "Strict", e[e.Loose = 1] = "Loose", e))(Qr || {});
400
+ function Ns(e, t = 0) {
401
+ var n;
402
+ return e === ((n = Mt(e)) == null ? void 0 : n.body) ? !1 : At(t, { 0() {
403
+ return e.matches(Gt);
404
+ }, 1() {
405
+ let r = e;
406
+ for (; r !== null; ) {
407
+ if (r.matches(Gt)) return !0;
408
+ r = r.parentElement;
409
+ }
410
+ return !1;
411
+ } });
412
+ }
413
+ var As = ((e) => (e[e.Keyboard = 0] = "Keyboard", e[e.Mouse = 1] = "Mouse", e))(As || {});
414
+ typeof window < "u" && typeof document < "u" && (document.addEventListener("keydown", (e) => {
415
+ e.metaKey || e.altKey || e.ctrlKey || (document.documentElement.dataset.headlessuiFocusVisible = "");
416
+ }, !0), document.addEventListener("click", (e) => {
417
+ e.detail === 1 ? delete document.documentElement.dataset.headlessuiFocusVisible : e.detail === 0 && (document.documentElement.dataset.headlessuiFocusVisible = "");
418
+ }, !0));
419
+ function De(e) {
420
+ e?.focus({ preventScroll: !0 });
421
+ }
422
+ let Ss = ["textarea", "input"].join(",");
423
+ function Ms(e) {
424
+ var t, n;
425
+ return (n = (t = e?.matches) == null ? void 0 : t.call(e, Ss)) != null ? n : !1;
426
+ }
427
+ function _s(e, t = (n) => n) {
428
+ return e.slice().sort((n, r) => {
429
+ let a = t(n), o = t(r);
430
+ if (a === null || o === null) return 0;
431
+ let c = a.compareDocumentPosition(o);
432
+ return c & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : c & Node.DOCUMENT_POSITION_PRECEDING ? 1 : 0;
433
+ });
434
+ }
435
+ function Et(e, t, { sorted: n = !0, relativeTo: r = null, skipElements: a = [] } = {}) {
436
+ let o = Array.isArray(e) ? e.length > 0 ? Qn(e[0]) : document : Qn(e), c = Array.isArray(e) ? n ? _s(e) : e : t & 64 ? Es(e) : Ts(e);
437
+ a.length > 0 && c.length > 1 && (c = c.filter((h) => !a.some((m) => m != null && "current" in m ? m?.current === h : m === h))), r = r ?? o?.activeElement;
438
+ let s = (() => {
439
+ if (t & 5) return 1;
440
+ if (t & 10) return -1;
441
+ throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last");
442
+ })(), l = (() => {
443
+ if (t & 1) return 0;
444
+ if (t & 2) return Math.max(0, c.indexOf(r)) - 1;
445
+ if (t & 4) return Math.max(0, c.indexOf(r)) + 1;
446
+ if (t & 8) return c.length - 1;
447
+ throw new Error("Missing Focus.First, Focus.Previous, Focus.Next or Focus.Last");
448
+ })(), u = t & 32 ? { preventScroll: !0 } : {}, w = 0, p = c.length, d;
449
+ do {
450
+ if (w >= p || w + p <= 0) return 0;
451
+ let h = l + w;
452
+ if (t & 16) h = (h + p) % p;
453
+ else {
454
+ if (h < 0) return 3;
455
+ if (h >= p) return 1;
456
+ }
457
+ d = c[h], d?.focus(u), w += s;
458
+ } while (d !== za(d));
459
+ return t & 6 && Ms(d) && d.select(), 2;
460
+ }
461
+ function ea() {
462
+ return /iPhone/gi.test(window.navigator.platform) || /Mac/gi.test(window.navigator.platform) && window.navigator.maxTouchPoints > 0;
463
+ }
464
+ function ks() {
465
+ return /Android/gi.test(window.navigator.userAgent);
466
+ }
467
+ function ur() {
468
+ return ea() || ks();
469
+ }
470
+ function Dt(e, t, n, r) {
471
+ let a = _t(n);
472
+ R(() => {
473
+ if (!e) return;
474
+ function o(c) {
475
+ a.current(c);
476
+ }
477
+ return document.addEventListener(t, o, r), () => document.removeEventListener(t, o, r);
478
+ }, [e, t, r]);
479
+ }
480
+ function ta(e, t, n, r) {
481
+ let a = _t(n);
482
+ R(() => {
483
+ if (!e) return;
484
+ function o(c) {
485
+ a.current(c);
486
+ }
487
+ return window.addEventListener(t, o, r), () => window.removeEventListener(t, o, r);
488
+ }, [e, t, r]);
489
+ }
490
+ const dr = 30;
491
+ function Ls(e, t, n) {
492
+ let r = _t(n), a = U(function(s, l) {
493
+ if (s.defaultPrevented) return;
494
+ let u = l(s);
495
+ if (u === null || !u.getRootNode().contains(u) || !u.isConnected) return;
496
+ let w = (function p(d) {
497
+ return typeof d == "function" ? p(d()) : Array.isArray(d) || d instanceof Set ? d : [d];
498
+ })(t);
499
+ for (let p of w) if (p !== null && (p.contains(u) || s.composed && s.composedPath().includes(p))) return;
500
+ return !Ns(u, Qr.Loose) && u.tabIndex !== -1 && s.preventDefault(), r.current(s, u);
501
+ }, [r, t]), o = S(null);
502
+ Dt(e, "pointerdown", (s) => {
503
+ var l, u;
504
+ ur() || (o.current = ((u = (l = s.composedPath) == null ? void 0 : l.call(s)) == null ? void 0 : u[0]) || s.target);
505
+ }, !0), Dt(e, "pointerup", (s) => {
506
+ if (ur() || !o.current) return;
507
+ let l = o.current;
508
+ return o.current = null, a(s, () => l);
509
+ }, !0);
510
+ let c = S({ x: 0, y: 0 });
511
+ Dt(e, "touchstart", (s) => {
512
+ c.current.x = s.touches[0].clientX, c.current.y = s.touches[0].clientY;
513
+ }, !0), Dt(e, "touchend", (s) => {
514
+ let l = { x: s.changedTouches[0].clientX, y: s.changedTouches[0].clientY };
515
+ if (!(Math.abs(l.x - c.current.x) >= dr || Math.abs(l.y - c.current.y) >= dr)) return a(s, () => Ge(s.target) ? s.target : null);
516
+ }, !0), ta(e, "blur", (s) => a(s, () => Wo(window.document.activeElement) ? window.document.activeElement : null), !0);
517
+ }
518
+ function $n(...e) {
519
+ return ue(() => Mt(...e), [...e]);
520
+ }
521
+ function na(e, t, n, r) {
522
+ let a = _t(n);
523
+ R(() => {
524
+ e = e ?? window;
525
+ function o(c) {
526
+ a.current(c);
527
+ }
528
+ return e.addEventListener(t, o, r), () => e.removeEventListener(t, o, r);
529
+ }, [e, t, r]);
530
+ }
531
+ function Rs(e) {
532
+ return Nn(e.subscribe, e.getSnapshot, e.getSnapshot);
533
+ }
534
+ function Is(e, t) {
535
+ let n = e(), r = /* @__PURE__ */ new Set();
536
+ return { getSnapshot() {
537
+ return n;
538
+ }, subscribe(a) {
539
+ return r.add(a), () => r.delete(a);
540
+ }, dispatch(a, ...o) {
541
+ let c = t[a].call(n, ...o);
542
+ c && (n = c, r.forEach((s) => s()));
543
+ } };
544
+ }
545
+ function Os() {
546
+ let e;
547
+ return { before({ doc: t }) {
548
+ var n;
549
+ let r = t.documentElement, a = (n = t.defaultView) != null ? n : window;
550
+ e = Math.max(0, a.innerWidth - r.clientWidth);
551
+ }, after({ doc: t, d: n }) {
552
+ let r = t.documentElement, a = Math.max(0, r.clientWidth - r.offsetWidth), o = Math.max(0, e - a);
553
+ n.style(r, "paddingRight", `${o}px`);
554
+ } };
555
+ }
556
+ function $s() {
557
+ return ea() ? { before({ doc: e, d: t, meta: n }) {
558
+ function r(a) {
559
+ for (let o of n().containers) for (let c of o()) if (c.contains(a)) return !0;
560
+ return !1;
561
+ }
562
+ t.microTask(() => {
563
+ var a;
564
+ if (window.getComputedStyle(e.documentElement).scrollBehavior !== "auto") {
565
+ let s = St();
566
+ s.style(e.documentElement, "scrollBehavior", "auto"), t.add(() => t.microTask(() => s.dispose()));
567
+ }
568
+ let o = (a = window.scrollY) != null ? a : window.pageYOffset, c = null;
569
+ t.addEventListener(e, "click", (s) => {
570
+ if (Ge(s.target)) try {
571
+ let l = s.target.closest("a");
572
+ if (!l) return;
573
+ let { hash: u } = new URL(l.href), w = e.querySelector(u);
574
+ Ge(w) && !r(w) && (c = w);
575
+ } catch {
576
+ }
577
+ }, !0), t.group((s) => {
578
+ t.addEventListener(e, "touchstart", (l) => {
579
+ if (s.dispose(), Ge(l.target) && zo(l.target)) if (r(l.target)) {
580
+ let u = l.target;
581
+ for (; u.parentElement && r(u.parentElement); ) u = u.parentElement;
582
+ s.style(u, "overscrollBehavior", "contain");
583
+ } else s.style(l.target, "touchAction", "none");
584
+ });
585
+ }), t.addEventListener(e, "touchmove", (s) => {
586
+ if (Ge(s.target)) {
587
+ if (jr(s.target)) return;
588
+ if (r(s.target)) {
589
+ let l = s.target;
590
+ for (; l.parentElement && l.dataset.headlessuiPortal !== "" && !(l.scrollHeight > l.clientHeight || l.scrollWidth > l.clientWidth); ) l = l.parentElement;
591
+ l.dataset.headlessuiPortal === "" && s.preventDefault();
592
+ } else s.preventDefault();
593
+ }
594
+ }, { passive: !1 }), t.add(() => {
595
+ var s;
596
+ let l = (s = window.scrollY) != null ? s : window.pageYOffset;
597
+ o !== l && window.scrollTo(0, o), c && c.isConnected && (c.scrollIntoView({ block: "nearest" }), c = null);
598
+ });
599
+ });
600
+ } } : {};
601
+ }
602
+ function Fs() {
603
+ return { before({ doc: e, d: t }) {
604
+ t.style(e.documentElement, "overflow", "hidden");
605
+ } };
606
+ }
607
+ function hr(e) {
608
+ let t = {};
609
+ for (let n of e) Object.assign(t, n(t));
610
+ return t;
611
+ }
612
+ let Je = Is(() => /* @__PURE__ */ new Map(), { PUSH(e, t) {
613
+ var n;
614
+ let r = (n = this.get(e)) != null ? n : { doc: e, count: 0, d: St(), meta: /* @__PURE__ */ new Set(), computedMeta: {} };
615
+ return r.count++, r.meta.add(t), r.computedMeta = hr(r.meta), this.set(e, r), this;
616
+ }, POP(e, t) {
617
+ let n = this.get(e);
618
+ return n && (n.count--, n.meta.delete(t), n.computedMeta = hr(n.meta)), this;
619
+ }, SCROLL_PREVENT(e) {
620
+ let t = { doc: e.doc, d: e.d, meta() {
621
+ return e.computedMeta;
622
+ } }, n = [$s(), Os(), Fs()];
623
+ n.forEach(({ before: r }) => r?.(t)), n.forEach(({ after: r }) => r?.(t));
624
+ }, SCROLL_ALLOW({ d: e }) {
625
+ e.dispose();
626
+ }, TEARDOWN({ doc: e }) {
627
+ this.delete(e);
628
+ } });
629
+ Je.subscribe(() => {
630
+ let e = Je.getSnapshot(), t = /* @__PURE__ */ new Map();
631
+ for (let [n] of e) t.set(n, n.documentElement.style.overflow);
632
+ for (let n of e.values()) {
633
+ let r = t.get(n.doc) === "hidden", a = n.count !== 0;
634
+ (a && !r || !a && r) && Je.dispatch(n.count > 0 ? "SCROLL_PREVENT" : "SCROLL_ALLOW", n), n.count === 0 && Je.dispatch("TEARDOWN", n);
635
+ }
636
+ });
637
+ function Ps(e, t, n = () => ({ containers: [] })) {
638
+ let r = Rs(Je), a = t ? r.get(t) : void 0, o = a ? a.count > 0 : !1;
639
+ return et(() => {
640
+ if (!(!t || !e)) return Je.dispatch("PUSH", t, n), () => Je.dispatch("POP", t, n);
641
+ }, [e, t]), o;
642
+ }
643
+ function Ds(e, t, n = () => [document.body]) {
644
+ let r = Lt(e, "scroll-lock");
645
+ Ps(r, t, (a) => {
646
+ var o;
647
+ return { containers: [...(o = a.containers) != null ? o : [], n] };
648
+ });
649
+ }
650
+ function Fn(e, t) {
651
+ let n = S([]), r = oe(e);
652
+ R(() => {
653
+ let a = [...n.current];
654
+ for (let [o, c] of t.entries()) if (n.current[o] !== c) {
655
+ let s = r(t, a);
656
+ return n.current = t, s;
657
+ }
658
+ }, [r, ...t]);
659
+ }
660
+ function Us(e) {
661
+ function t() {
662
+ document.readyState !== "loading" && (e(), document.removeEventListener("DOMContentLoaded", t));
663
+ }
664
+ typeof window < "u" && typeof document < "u" && (document.addEventListener("DOMContentLoaded", t), t());
665
+ }
666
+ let We = [];
667
+ Us(() => {
668
+ function e(t) {
669
+ if (!Ge(t.target) || t.target === document.body || We[0] === t.target) return;
670
+ let n = t.target;
671
+ n = n.closest(Gt), We.unshift(n ?? t.target), We = We.filter((r) => r != null && r.isConnected), We.splice(10);
672
+ }
673
+ window.addEventListener("click", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("focus", e, { capture: !0 }), document.body.addEventListener("click", e, { capture: !0 }), document.body.addEventListener("mousedown", e, { capture: !0 }), document.body.addEventListener("focus", e, { capture: !0 });
674
+ });
675
+ function ra(e) {
676
+ let t = oe(e), n = S(!1);
677
+ R(() => (n.current = !1, () => {
678
+ n.current = !0, Sn(() => {
679
+ n.current && t();
680
+ });
681
+ }), [t]);
682
+ }
683
+ let aa = Ue(!1);
684
+ function Hs() {
685
+ return Ee(aa);
686
+ }
687
+ function fr(e) {
688
+ return V.createElement(aa.Provider, { value: e.force }, e.children);
689
+ }
690
+ function Bs(e) {
691
+ let t = Hs(), n = Ee(sa), [r, a] = F(() => {
692
+ var o;
693
+ if (!t && n !== null) return (o = n.current) != null ? o : null;
694
+ if (Ht.isServer) return null;
695
+ let c = e?.getElementById("headlessui-portal-root");
696
+ if (c) return c;
697
+ if (e === null) return null;
698
+ let s = e.createElement("div");
699
+ return s.setAttribute("id", "headlessui-portal-root"), e.body.appendChild(s);
700
+ });
701
+ return R(() => {
702
+ r !== null && (e != null && e.body.contains(r) || e == null || e.body.appendChild(r));
703
+ }, [r, e]), R(() => {
704
+ t || n !== null && a(n.current);
705
+ }, [n, a, t]), r;
706
+ }
707
+ let oa = Kt, Vs = be(function(e, t) {
708
+ let { ownerDocument: n = null, ...r } = e, a = S(null), o = He(Wa((d) => {
709
+ a.current = d;
710
+ }), t), c = $n(a.current), s = n ?? c, l = Bs(s), u = Ee(wn), w = Lr(), p = Ne();
711
+ return ra(() => {
712
+ var d;
713
+ l && l.childNodes.length <= 0 && ((d = l.parentElement) == null || d.removeChild(l));
714
+ }), l ? Uo(V.createElement("div", { "data-headlessui-portal": "", ref: (d) => {
715
+ w.dispose(), u && d && w.add(u.register(d));
716
+ } }, p({ ourProps: { ref: o }, theirProps: r, slot: {}, defaultTag: oa, name: "Portal" })), l) : null;
717
+ });
718
+ function js(e, t) {
719
+ let n = He(t), { enabled: r = !0, ownerDocument: a, ...o } = e, c = Ne();
720
+ return r ? V.createElement(Vs, { ...o, ownerDocument: a, ref: n }) : c({ ourProps: { ref: n }, theirProps: o, slot: {}, defaultTag: oa, name: "Portal" });
721
+ }
722
+ let zs = Kt, sa = Ue(null);
723
+ function Ws(e, t) {
724
+ let { target: n, ...r } = e, a = { ref: He(t) }, o = Ne();
725
+ return V.createElement(sa.Provider, { value: n }, o({ ourProps: a, theirProps: r, defaultTag: zs, name: "Popover.Group" }));
726
+ }
727
+ let wn = Ue(null);
728
+ function Gs() {
729
+ let e = Ee(wn), t = S([]), n = oe((o) => (t.current.push(o), e && e.register(o), () => r(o))), r = oe((o) => {
730
+ let c = t.current.indexOf(o);
731
+ c !== -1 && t.current.splice(c, 1), e && e.unregister(o);
732
+ }), a = ue(() => ({ register: n, unregister: r, portals: t }), [n, r, t]);
733
+ return [t, ue(() => function({ children: o }) {
734
+ return V.createElement(wn.Provider, { value: a }, o);
735
+ }, [a])];
736
+ }
737
+ let qs = be(js), ia = be(Ws), Ks = Object.assign(qs, { Group: ia });
738
+ function Ys(e, t = typeof document < "u" ? document.defaultView : null, n) {
739
+ let r = Lt(e, "escape");
740
+ na(t, "keydown", (a) => {
741
+ r && (a.defaultPrevented || a.key === Wr.Escape && n(a));
742
+ });
743
+ }
744
+ function Zs() {
745
+ var e;
746
+ let [t] = F(() => typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(pointer: coarse)") : null), [n, r] = F((e = t?.matches) != null ? e : !1);
747
+ return et(() => {
748
+ if (!t) return;
749
+ function a(o) {
750
+ r(o.matches);
751
+ }
752
+ return t.addEventListener("change", a), () => t.removeEventListener("change", a);
753
+ }, [t]), n;
754
+ }
755
+ function Xs({ defaultContainers: e = [], portals: t, mainTreeNode: n } = {}) {
756
+ let r = oe(() => {
757
+ var a, o;
758
+ let c = Mt(n), s = [];
759
+ for (let l of e) l !== null && (Pe(l) ? s.push(l) : "current" in l && Pe(l.current) && s.push(l.current));
760
+ if (t != null && t.current) for (let l of t.current) s.push(l);
761
+ for (let l of (a = c?.querySelectorAll("html > *, body > *")) != null ? a : []) l !== document.body && l !== document.head && Pe(l) && l.id !== "headlessui-portal-root" && (n && (l.contains(n) || l.contains((o = n?.getRootNode()) == null ? void 0 : o.host)) || s.some((u) => l.contains(u)) || s.push(l));
762
+ return s;
763
+ });
764
+ return { resolveContainers: r, contains: oe((a) => r().some((o) => o.contains(a))) };
765
+ }
766
+ let ca = Ue(null);
767
+ function mr({ children: e, node: t }) {
768
+ let [n, r] = F(null), a = la(t ?? n);
769
+ return V.createElement(ca.Provider, { value: a }, e, a === null && V.createElement(pn, { features: Wt.Hidden, ref: (o) => {
770
+ var c, s;
771
+ if (o) {
772
+ for (let l of (s = (c = Mt(o)) == null ? void 0 : c.querySelectorAll("html > *, body > *")) != null ? s : []) if (l !== document.body && l !== document.head && Pe(l) && l != null && l.contains(o)) {
773
+ r(l);
774
+ break;
775
+ }
776
+ }
777
+ } }));
778
+ }
779
+ function la(e = null) {
780
+ var t;
781
+ return (t = Ee(ca)) != null ? t : e;
782
+ }
783
+ var Ct = ((e) => (e[e.Forwards = 0] = "Forwards", e[e.Backwards = 1] = "Backwards", e))(Ct || {});
784
+ function Js() {
785
+ let e = S(0);
786
+ return ta(!0, "keydown", (t) => {
787
+ t.key === "Tab" && (e.current = t.shiftKey ? 1 : 0);
788
+ }, !0), e;
789
+ }
790
+ function ua(e) {
791
+ if (!e) return /* @__PURE__ */ new Set();
792
+ if (typeof e == "function") return new Set(e());
793
+ let t = /* @__PURE__ */ new Set();
794
+ for (let n of e.current) Pe(n.current) && t.add(n.current);
795
+ return t;
796
+ }
797
+ let Qs = "div";
798
+ var Ze = ((e) => (e[e.None = 0] = "None", e[e.InitialFocus = 1] = "InitialFocus", e[e.TabLock = 2] = "TabLock", e[e.FocusLock = 4] = "FocusLock", e[e.RestoreFocus = 8] = "RestoreFocus", e[e.AutoFocus = 16] = "AutoFocus", e))(Ze || {});
799
+ function ei(e, t) {
800
+ let n = S(null), r = He(n, t), { initialFocus: a, initialFocusFallback: o, containers: c, features: s = 15, ...l } = e;
801
+ Rr() || (s = 0);
802
+ let u = $n(n.current);
803
+ ai(s, { ownerDocument: u });
804
+ let w = oi(s, { ownerDocument: u, container: n, initialFocus: a, initialFocusFallback: o });
805
+ si(s, { ownerDocument: u, container: n, containers: c, previousActiveElement: w });
806
+ let p = Js(), d = oe((v) => {
807
+ if (!qe(n.current)) return;
808
+ let y = n.current;
809
+ ((T) => T())(() => {
810
+ At(p.current, { [Ct.Forwards]: () => {
811
+ Et(y, Fe.First, { skipElements: [v.relatedTarget, o] });
812
+ }, [Ct.Backwards]: () => {
813
+ Et(y, Fe.Last, { skipElements: [v.relatedTarget, o] });
814
+ } });
815
+ });
816
+ }), h = Lt(!!(s & 2), "focus-trap#tab-lock"), m = Lr(), g = S(!1), b = { ref: r, onKeyDown(v) {
817
+ v.key == "Tab" && (g.current = !0, m.requestAnimationFrame(() => {
818
+ g.current = !1;
819
+ }));
820
+ }, onBlur(v) {
821
+ if (!(s & 4)) return;
822
+ let y = ua(c);
823
+ qe(n.current) && y.add(n.current);
824
+ let T = v.relatedTarget;
825
+ Ge(T) && T.dataset.headlessuiFocusGuard !== "true" && (da(y, T) || (g.current ? Et(n.current, At(p.current, { [Ct.Forwards]: () => Fe.Next, [Ct.Backwards]: () => Fe.Previous }) | Fe.WrapAround, { relativeTo: v.target }) : Ge(v.target) && De(v.target)));
826
+ } }, C = Ne();
827
+ return V.createElement(V.Fragment, null, h && V.createElement(pn, { as: "button", type: "button", "data-headlessui-focus-guard": !0, onFocus: d, features: Wt.Focusable }), C({ ourProps: b, theirProps: l, defaultTag: Qs, name: "FocusTrap" }), h && V.createElement(pn, { as: "button", type: "button", "data-headlessui-focus-guard": !0, onFocus: d, features: Wt.Focusable }));
828
+ }
829
+ let ti = be(ei), ni = Object.assign(ti, { features: Ze });
830
+ function ri(e = !0) {
831
+ let t = S(We.slice());
832
+ return Fn(([n], [r]) => {
833
+ r === !0 && n === !1 && Sn(() => {
834
+ t.current.splice(0);
835
+ }), r === !1 && n === !0 && (t.current = We.slice());
836
+ }, [e, We, t]), oe(() => {
837
+ var n;
838
+ return (n = t.current.find((r) => r != null && r.isConnected)) != null ? n : null;
839
+ });
840
+ }
841
+ function ai(e, { ownerDocument: t }) {
842
+ let n = !!(e & 8), r = ri(n);
843
+ Fn(() => {
844
+ n || Ga(t?.body) && De(r());
845
+ }, [n]), ra(() => {
846
+ n && De(r());
847
+ });
848
+ }
849
+ function oi(e, { ownerDocument: t, container: n, initialFocus: r, initialFocusFallback: a }) {
850
+ let o = S(null), c = Lt(!!(e & 1), "focus-trap#initial-focus"), s = Ir();
851
+ return Fn(() => {
852
+ if (e === 0) return;
853
+ if (!c) {
854
+ a != null && a.current && De(a.current);
855
+ return;
856
+ }
857
+ let l = n.current;
858
+ l && Sn(() => {
859
+ if (!s.current) return;
860
+ let u = t?.activeElement;
861
+ if (r != null && r.current) {
862
+ if (r?.current === u) {
863
+ o.current = u;
864
+ return;
865
+ }
866
+ } else if (l.contains(u)) {
867
+ o.current = u;
868
+ return;
869
+ }
870
+ if (r != null && r.current) De(r.current);
871
+ else {
872
+ if (e & 16) {
873
+ if (Et(l, Fe.First | Fe.AutoFocus) !== vn.Error) return;
874
+ } else if (Et(l, Fe.First) !== vn.Error) return;
875
+ if (a != null && a.current && (De(a.current), t?.activeElement === a.current)) return;
876
+ console.warn("There are no focusable elements inside the <FocusTrap />");
877
+ }
878
+ o.current = t?.activeElement;
879
+ });
880
+ }, [a, c, e]), o;
881
+ }
882
+ function si(e, { ownerDocument: t, container: n, containers: r, previousActiveElement: a }) {
883
+ let o = Ir(), c = !!(e & 4);
884
+ na(t?.defaultView, "focus", (s) => {
885
+ if (!c || !o.current) return;
886
+ let l = ua(r);
887
+ qe(n.current) && l.add(n.current);
888
+ let u = a.current;
889
+ if (!u) return;
890
+ let w = s.target;
891
+ qe(w) ? da(l, w) ? (a.current = w, De(w)) : (s.preventDefault(), s.stopPropagation(), De(u)) : De(a.current);
892
+ }, !0);
893
+ }
894
+ function da(e, t) {
895
+ for (let n of e) if (n.contains(t)) return !0;
896
+ return !1;
897
+ }
898
+ var ii = ((e) => (e[e.Open = 0] = "Open", e[e.Closed = 1] = "Closed", e))(ii || {}), ci = ((e) => (e[e.SetTitleId = 0] = "SetTitleId", e))(ci || {});
899
+ let li = { 0(e, t) {
900
+ return e.titleId === t.id ? e : { ...e, titleId: t.id };
901
+ } }, Pn = Ue(null);
902
+ Pn.displayName = "DialogContext";
903
+ function Xt(e) {
904
+ let t = Ee(Pn);
905
+ if (t === null) {
906
+ let n = new Error(`<${e} /> is missing a parent <Dialog /> component.`);
907
+ throw Error.captureStackTrace && Error.captureStackTrace(n, Xt), n;
908
+ }
909
+ return t;
910
+ }
911
+ function ui(e, t) {
912
+ return At(t.type, li, e, t);
913
+ }
914
+ let pr = be(function(e, t) {
915
+ let n = Qe(), { id: r = `headlessui-dialog-${n}`, open: a, onClose: o, initialFocus: c, role: s = "dialog", autoFocus: l = !0, __demoMode: u = !1, unmount: w = !1, ...p } = e, d = S(!1);
916
+ s = (function() {
917
+ return s === "dialog" || s === "alertdialog" ? s : (d.current || (d.current = !0, console.warn(`Invalid role [${s}] passed to <Dialog />. Only \`dialog\` and and \`alertdialog\` are supported. Using \`dialog\` instead.`)), "dialog");
918
+ })();
919
+ let h = Or();
920
+ a === void 0 && h !== null && (a = (h & Ft.Open) === Ft.Open);
921
+ let m = S(null), g = He(m, t), b = $n(m.current), C = a ? 0 : 1, [v, y] = Mr(ui, { titleId: null, descriptionId: null, panelRef: ja() }), T = oe(() => o(!1)), E = oe((D) => y({ type: 0, id: D })), A = Rr() ? C === 0 : !1, [_, L] = Gs(), I = { get current() {
922
+ var D;
923
+ return (D = v.panelRef.current) != null ? D : m.current;
924
+ } }, X = la(), { resolveContainers: M } = Xs({ mainTreeNode: X, portals: _, defaultContainers: [I] }), G = h !== null ? (h & Ft.Closing) === Ft.Closing : !1;
925
+ ys(u || G ? !1 : A, { allowed: oe(() => {
926
+ var D, K;
927
+ return [(K = (D = m.current) == null ? void 0 : D.closest("[data-headlessui-portal]")) != null ? K : null];
928
+ }), disallowed: oe(() => {
929
+ var D;
930
+ return [(D = X?.closest("body > *:not(#headlessui-portal-root)")) != null ? D : null];
931
+ }) });
932
+ let j = Xr.get(null);
933
+ et(() => {
934
+ if (A) return j.actions.push(r), () => j.actions.pop(r);
935
+ }, [j, r, A]);
936
+ let P = Jr(j, U((D) => j.selectors.isTop(D, r), [j, r]));
937
+ Ls(P, M, (D) => {
938
+ D.preventDefault(), T();
939
+ }), Ys(P, b?.defaultView, (D) => {
940
+ D.preventDefault(), D.stopPropagation(), document.activeElement && "blur" in document.activeElement && typeof document.activeElement.blur == "function" && document.activeElement.blur(), T();
941
+ }), Ds(u || G ? !1 : A, b, M), bs(A, m, T);
942
+ let [re, se] = Ko(), B = ue(() => [{ dialogState: C, close: T, setTitleId: E, unmount: w }, v], [C, T, E, w, v]), J = tt({ open: C === 0 }), ae = { ref: g, id: r, role: s, tabIndex: -1, "aria-modal": u ? void 0 : C === 0 ? !0 : void 0, "aria-labelledby": v.titleId, "aria-describedby": re, unmount: w }, ie = !Zs(), Z = Ze.None;
943
+ A && !u && (Z |= Ze.RestoreFocus, Z |= Ze.TabLock, l && (Z |= Ze.AutoFocus), ie && (Z |= Ze.InitialFocus));
944
+ let ee = Ne();
945
+ return V.createElement(qa, null, V.createElement(fr, { force: !0 }, V.createElement(Ks, null, V.createElement(Pn.Provider, { value: B }, V.createElement(ia, { target: m }, V.createElement(fr, { force: !1 }, V.createElement(se, { slot: J }, V.createElement(L, null, V.createElement(ni, { initialFocus: c, initialFocusFallback: m, containers: M, features: Z }, V.createElement(as, { value: T }, ee({ ourProps: ae, theirProps: p, slot: J, defaultTag: di, features: hi, visible: C === 0, name: "Dialog" })))))))))));
946
+ }), di = "div", hi = er.RenderStrategy | er.Static;
947
+ function fi(e, t) {
948
+ let { transition: n = !1, open: r, ...a } = e, o = Or(), c = e.hasOwnProperty("open") || o !== null, s = e.hasOwnProperty("onClose");
949
+ if (!c && !s) throw new Error("You have to provide an `open` and an `onClose` prop to the `Dialog` component.");
950
+ if (!c) throw new Error("You provided an `onClose` prop to the `Dialog`, but forgot an `open` prop.");
951
+ if (!s) throw new Error("You provided an `open` prop to the `Dialog`, but forgot an `onClose` prop.");
952
+ if (!o && typeof e.open != "boolean") throw new Error(`You provided an \`open\` prop to the \`Dialog\`, but the value is not a boolean. Received: ${e.open}`);
953
+ if (typeof e.onClose != "function") throw new Error(`You provided an \`onClose\` prop to the \`Dialog\`, but the value is not a function. Received: ${e.onClose}`);
954
+ return (r !== void 0 || n) && !a.static ? V.createElement(mr, null, V.createElement(ze, { show: r, transition: n, unmount: a.unmount }, V.createElement(pr, { ref: t, ...a }))) : V.createElement(mr, null, V.createElement(pr, { ref: t, open: r, ...a }));
955
+ }
956
+ let mi = "div";
957
+ function pi(e, t) {
958
+ let n = Qe(), { id: r = `headlessui-dialog-panel-${n}`, transition: a = !1, ...o } = e, [{ dialogState: c, unmount: s }, l] = Xt("Dialog.Panel"), u = He(t, l.panelRef), w = tt({ open: c === 0 }), p = oe((b) => {
959
+ b.stopPropagation();
960
+ }), d = { ref: u, id: r, onClick: p }, h = a ? zt : Kt, m = a ? { unmount: s } : {}, g = Ne();
961
+ return V.createElement(h, { ...m }, g({ ourProps: d, theirProps: o, slot: w, defaultTag: mi, name: "Dialog.Panel" }));
962
+ }
963
+ let gi = "div";
964
+ function vi(e, t) {
965
+ let { transition: n = !1, ...r } = e, [{ dialogState: a, unmount: o }] = Xt("Dialog.Backdrop"), c = tt({ open: a === 0 }), s = { ref: t, "aria-hidden": !0 }, l = n ? zt : Kt, u = n ? { unmount: o } : {}, w = Ne();
966
+ return V.createElement(l, { ...u }, w({ ourProps: s, theirProps: r, slot: c, defaultTag: gi, name: "Dialog.Backdrop" }));
967
+ }
968
+ let wi = "h2";
969
+ function yi(e, t) {
970
+ let n = Qe(), { id: r = `headlessui-dialog-title-${n}`, ...a } = e, [{ dialogState: o, setTitleId: c }] = Xt("Dialog.Title"), s = He(t);
971
+ R(() => (c(r), () => c(null)), [r, c]);
972
+ let l = tt({ open: o === 0 }), u = { ref: s, id: r };
973
+ return Ne()({ ourProps: u, theirProps: a, slot: l, defaultTag: wi, name: "Dialog.Title" });
974
+ }
975
+ let bi = be(fi), ha = be(pi), xi = be(vi), fa = be(yi), Ci = Object.assign(bi, { Panel: ha, Title: fa, Description: Jo }), Ti = "textarea";
976
+ function Ei(e, t) {
977
+ let n = Qe(), r = Vr(), a = An(), { id: o = r || `headlessui-textarea-${n}`, disabled: c = a || !1, autoFocus: s = !1, invalid: l = !1, ...u } = e, w = Qo(), p = qo(), { isFocused: d, focusProps: h } = Ka({ autoFocus: s }), { isHovered: m, hoverProps: g } = Ya({ isDisabled: c }), b = Za({ ref: t, id: o, "aria-labelledby": w, "aria-describedby": p, "aria-invalid": l ? "true" : void 0, disabled: c || void 0, autoFocus: s }, h, g), C = tt({ disabled: c, invalid: l, hover: m, focus: d, autofocus: s });
978
+ return Ne()({ ourProps: b, theirProps: u, slot: C, defaultTag: Ti, name: "Textarea" });
979
+ }
980
+ let Ni = be(Ei);
981
+ const Ai = (e) => /* @__PURE__ */ we.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M8 1.25C6.66498 1.25 5.35994 1.64588 4.2499 2.38758C3.13987 3.12928 2.27471 4.18349 1.76382 5.41689C1.25292 6.65029 1.11925 8.00749 1.3797 9.31686C1.64015 10.6262 2.28303 11.829 3.22703 12.773C4.17104 13.717 5.37377 14.3598 6.68314 14.6203C7.99252 14.8808 9.34971 14.7471 10.5831 14.2362C11.8165 13.7253 12.8707 12.8601 13.6124 11.7501C14.3541 10.6401 14.75 9.33502 14.75 8C14.748 6.2104 14.0362 4.49466 12.7708 3.22922C11.5053 1.96378 9.78961 1.25199 8 1.25ZM8 13.25C6.96165 13.25 5.94662 12.9421 5.08326 12.3652C4.2199 11.7883 3.547 10.9684 3.14964 10.0091C2.75228 9.04978 2.64831 7.99418 2.85088 6.97578C3.05345 5.95738 3.55347 5.02191 4.28769 4.28769C5.02192 3.55346 5.95738 3.05345 6.97578 2.85088C7.99418 2.6483 9.04978 2.75227 10.0091 3.14963C10.9684 3.54699 11.7883 4.2199 12.3652 5.08326C12.9421 5.94661 13.25 6.96165 13.25 8C13.2485 9.39193 12.6949 10.7264 11.7107 11.7107C10.7264 12.6949 9.39193 13.2485 8 13.25ZM7.25 8.25V5C7.25 4.80109 7.32902 4.61032 7.46967 4.46967C7.61032 4.32902 7.80109 4.25 8 4.25C8.19892 4.25 8.38968 4.32902 8.53033 4.46967C8.67098 4.61032 8.75 4.80109 8.75 5V8.25C8.75 8.44891 8.67098 8.63968 8.53033 8.78033C8.38968 8.92098 8.19892 9 8 9C7.80109 9 7.61032 8.92098 7.46967 8.78033C7.32902 8.63968 7.25 8.44891 7.25 8.25ZM9 10.75C9 10.9478 8.94135 11.1411 8.83147 11.3056C8.72159 11.47 8.56541 11.5982 8.38269 11.6739C8.19996 11.7496 7.99889 11.7694 7.80491 11.7308C7.61093 11.6922 7.43275 11.597 7.2929 11.4571C7.15304 11.3173 7.0578 11.1391 7.01922 10.9451C6.98063 10.7511 7.00044 10.55 7.07612 10.3673C7.15181 10.1846 7.27998 10.0284 7.44443 9.91853C7.60888 9.80865 7.80222 9.75 8 9.75C8.26522 9.75 8.51957 9.85536 8.70711 10.0429C8.89465 10.2304 9 10.4848 9 10.75Z", fill: "currentColor" }));
982
+ function ma({
983
+ message: e,
984
+ className: t,
985
+ ...n
986
+ }) {
987
+ return /* @__PURE__ */ N(
988
+ "div",
989
+ {
990
+ ...n,
991
+ className: ne(
992
+ "message flex h-fit min-h-9 w-fit max-w-70 flex-row items-center justify-center gap-1 bg-black",
993
+ t
994
+ ),
995
+ children: [
996
+ /* @__PURE__ */ i(Ai, {}),
997
+ /* @__PURE__ */ i("span", { children: e })
998
+ ]
999
+ }
1000
+ );
1001
+ }
1002
+ var pa = /* @__PURE__ */ ((e) => (e.ReactionMessage = "REACTION_MESSAGE", e))(pa || {});
1003
+ function Si({
1004
+ message: e,
1005
+ source: t,
1006
+ className: n,
1007
+ ...r
1008
+ }) {
1009
+ return /* @__PURE__ */ i(
1010
+ "div",
1011
+ {
1012
+ ...r,
1013
+ "data-author": t === Te.Customer ? "customer" : "agent",
1014
+ className: ne(
1015
+ "message flex h-fit min-h-8 w-fit max-w-[86%] items-center justify-center text-start",
1016
+ {
1017
+ "ms-2 self-start rounded-es-[5px]": t === Te.Agent,
1018
+ "ms-2 self-center rounded-es-[5px]": t === "REACTION_MESSAGE",
1019
+ "me-2 self-end rounded-ee-[5px]": t === Te.Customer
1020
+ },
1021
+ n
1022
+ ),
1023
+ children: e
1024
+ }
1025
+ );
1026
+ }
1027
+ const yn = (e, t, n, r, a, o) => {
1028
+ R(() => {
1029
+ const c = t.current;
1030
+ if (!(!e || !n || !r || !a || !c))
1031
+ return Fo({
1032
+ element: c,
1033
+ isActive: () => n && e.getSurfaceState() === "OPEN" && e.getSurfaceEpisodeId() === r,
1034
+ ...o ? { isPresentable: o } : {},
1035
+ onPresented: () => e.recordPresented(a, r)
1036
+ });
1037
+ }, [n, r, o, t, e, a]);
1038
+ };
1039
+ function ga({ className: e }) {
1040
+ const { t } = me(), {
1041
+ cta: n,
1042
+ ctaBusy: r,
1043
+ ctaButtonLabel: a,
1044
+ ctaFeedback: o,
1045
+ ctaTelegramBotUsername: c,
1046
+ ctaTelegramDeepLink: s,
1047
+ ctaManualCommand: l,
1048
+ executeCta: u,
1049
+ dismissCta: w,
1050
+ open: p,
1051
+ surfaceEpisodeId: d,
1052
+ api: h
1053
+ } = kt(), m = S(null), [g, b] = F(() => /* @__PURE__ */ new Set()), C = n?.commandId, v = U(() => {
1054
+ C && b((E) => {
1055
+ if (E.has(C)) return E;
1056
+ const A = new Set(E);
1057
+ if (A.add(C), A.size > 64) {
1058
+ const _ = A.values().next().value;
1059
+ _ !== void 0 && A.delete(_);
1060
+ }
1061
+ return A;
1062
+ });
1063
+ }, [C]), y = ue(
1064
+ () => n ? {
1065
+ subjectKind: "CTA",
1066
+ subjectId: n.commandId,
1067
+ attributionHandle: n.commandId
1068
+ } : null,
1069
+ [n]
1070
+ );
1071
+ if (yn(
1072
+ h?.scenarioInteractionRuntime,
1073
+ m,
1074
+ p,
1075
+ d,
1076
+ y
1077
+ ), !n) return null;
1078
+ const T = p && !r && n.attention === "NUDGE_ONCE" && !g.has(n.commandId);
1079
+ return /* @__PURE__ */ N(
1080
+ "div",
1081
+ {
1082
+ ref: m,
1083
+ className: ne("flex max-w-full flex-col gap-1.5", e),
1084
+ children: [
1085
+ n.text && /* @__PURE__ */ i("p", { className: "max-w-72 text-sm leading-5 break-words whitespace-pre-wrap text-white/90", children: n.text }),
1086
+ /* @__PURE__ */ N("div", { className: "flex items-center gap-2", children: [
1087
+ /* @__PURE__ */ i(
1088
+ Q,
1089
+ {
1090
+ type: "button",
1091
+ disabled: r,
1092
+ onClick: () => {
1093
+ v(), u();
1094
+ },
1095
+ className: ne(
1096
+ "chat-cta-primary chat-cta-action data-disabled:opacity-50",
1097
+ T && "chat-attention-nudge-once"
1098
+ ),
1099
+ children: a
1100
+ }
1101
+ ),
1102
+ /* @__PURE__ */ i(
1103
+ Q,
1104
+ {
1105
+ type: "button",
1106
+ disabled: r,
1107
+ "aria-label": t("cta.dismiss"),
1108
+ onClick: () => {
1109
+ v(), w();
1110
+ },
1111
+ className: "chat-cta-secondary data-disabled:opacity-50",
1112
+ children: "×"
1113
+ }
1114
+ )
1115
+ ] }),
1116
+ o && /* @__PURE__ */ i("p", { role: "status", className: "max-w-72 text-xs text-white/75", children: o }),
1117
+ s && c && /* @__PURE__ */ i(
1118
+ "a",
1119
+ {
1120
+ href: s,
1121
+ target: "_blank",
1122
+ rel: "noopener noreferrer",
1123
+ className: "w-fit text-xs text-violet-200 underline underline-offset-2",
1124
+ children: t("cta.openTelegram", { username: c })
1125
+ }
1126
+ ),
1127
+ l && /* @__PURE__ */ N("p", { className: "max-w-72 text-xs text-white/65", children: [
1128
+ t("cta.manualCommand"),
1129
+ " ",
1130
+ /* @__PURE__ */ i("code", { className: "break-all", dir: "ltr", children: l })
1131
+ ] })
1132
+ ]
1133
+ }
1134
+ );
1135
+ }
1136
+ const bn = 54, Ve = 2, gt = 10, vt = 8, Mi = 6.5, gr = 7, wt = 27, vr = (e, t, n, r) => {
1137
+ const a = (bn - n) / 2;
1138
+ if (typeof e.roundRect != "function") {
1139
+ e.fillRect(t, a, r, n);
1140
+ return;
1141
+ }
1142
+ e.roundRect(t, a, r, n, r / 2);
1143
+ };
1144
+ function _i({
1145
+ phase: e = "ready",
1146
+ assistantActivity: t = "idle",
1147
+ microphoneEnabled: n = !0,
1148
+ statusLabel: r,
1149
+ microphoneLabel: a,
1150
+ closeLabel: o,
1151
+ disabled: c = !1,
1152
+ frozen: s = !1,
1153
+ onToggleMicrophone: l,
1154
+ onClose: u,
1155
+ className: w,
1156
+ meter: p = Ja,
1157
+ spectrumSource: d
1158
+ }) {
1159
+ const h = S(null), m = S(null), g = S(null), b = S(s), C = U((v) => g.current?.(v) ?? !1, []);
1160
+ return ye(() => {
1161
+ b.current = s;
1162
+ }, [s]), R(() => {
1163
+ const v = h.current;
1164
+ if (!v) return;
1165
+ let y = null;
1166
+ try {
1167
+ y = v.getContext("2d");
1168
+ } catch {
1169
+ return;
1170
+ }
1171
+ if (!y) return;
1172
+ let T = 0, E = 1, A = new Float32Array(2), _ = new Float32Array(2), L = new Float32Array(1), I = new Float32Array(1), X = null;
1173
+ const M = e === "ready" && n, G = (se, B, J, ae, ie, Z) => {
1174
+ const ee = typeof y.roundRect == "function";
1175
+ ee && y.beginPath();
1176
+ for (let D = 0; D < se.length; D += 1) {
1177
+ const K = se[D];
1178
+ vr(
1179
+ y,
1180
+ J + D * ae,
1181
+ K,
1182
+ Ve
1183
+ );
1184
+ }
1185
+ for (let D = 0; D < B.length; D += 1) {
1186
+ const K = B[D];
1187
+ vr(
1188
+ y,
1189
+ ie + D * Z,
1190
+ K,
1191
+ Ve
1192
+ );
1193
+ }
1194
+ ee && y.fill();
1195
+ }, j = ({
1196
+ frameTime: se,
1197
+ elapsedMs: B,
1198
+ inputLevel: J,
1199
+ smoothedInputLevel: ae,
1200
+ reducedMotion: ie
1201
+ }) => {
1202
+ if (T <= 0 || b.current) return !1;
1203
+ if (A.fill(0), M && !ie)
1204
+ if (d)
1205
+ try {
1206
+ d.readBands(A);
1207
+ } catch {
1208
+ A.fill(0);
1209
+ }
1210
+ else
1211
+ Qa(A, J, 0);
1212
+ if (ie)
1213
+ _.fill(0);
1214
+ else
1215
+ for (let de = 0; de < _.length; de += 1)
1216
+ _[de] = eo(
1217
+ _[de],
1218
+ A[de],
1219
+ B
1220
+ );
1221
+ const Z = to(
1222
+ L,
1223
+ I,
1224
+ ae,
1225
+ n,
1226
+ _,
1227
+ se
1228
+ ), ee = T / 2 + gr, D = Math.max(
1229
+ Ve,
1230
+ ee - wt - gt - vt
1231
+ ), K = Math.max(
1232
+ Ve,
1233
+ T - vt - ee - wt - gt
1234
+ ), he = E > 1 ? (D - Ve) / (E - 1) : 0, Ae = E > 1 ? (K - Ve) / (E - 1) : 0, Ie = vt, fe = ee + wt + gt;
1235
+ y.clearRect(0, 0, T, bn), y.fillStyle = "#8b889b", y.globalAlpha = 0.52, G(
1236
+ L,
1237
+ I,
1238
+ Ie,
1239
+ he,
1240
+ fe,
1241
+ Ae
1242
+ ), Z > 0.01 && X && (y.fillStyle = X, y.globalAlpha = Math.min(1, Z * 1.2), G(
1243
+ L,
1244
+ I,
1245
+ Ie,
1246
+ he,
1247
+ fe,
1248
+ Ae
1249
+ )), y.globalAlpha = 1;
1250
+ let ce = !1;
1251
+ for (let de = 0; de < _.length; de += 1)
1252
+ if (Math.abs(_[de] - A[de]) > 3e-3) {
1253
+ ce = !0;
1254
+ break;
1255
+ }
1256
+ return !!(!ie && M && (d !== void 0 && J > 3e-3 || ce));
1257
+ };
1258
+ g.current = j;
1259
+ const P = () => {
1260
+ const se = Math.round(v.getBoundingClientRect().width);
1261
+ if (se <= 0 || b.current) return;
1262
+ const B = Math.min(window.devicePixelRatio || 1, 2);
1263
+ T = se;
1264
+ const J = T / 2 + gr, ae = Math.max(
1265
+ Ve,
1266
+ J - wt - gt - vt
1267
+ ), ie = Math.max(
1268
+ Ve,
1269
+ T - vt - J - wt - gt
1270
+ ), Z = Math.max(
1271
+ 1,
1272
+ Math.floor(Math.min(ae, ie) / Mi)
1273
+ );
1274
+ Z !== E && (E = Z, A = new Float32Array(E * 2), _ = new Float32Array(E * 2), L = new Float32Array(E), I = new Float32Array(E)), v.width = Math.round(T * B), v.height = Math.round(bn * B), y.setTransform(B, 0, 0, B, 0, 0), X = y.createLinearGradient(0, 12, 0, 42), X.addColorStop(0, "#06e1fd"), X.addColorStop(1, "#ff28b7"), m.current?.requestFrame();
1275
+ }, re = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => P());
1276
+ return re?.observe(v), window.addEventListener("resize", P), P(), () => {
1277
+ re?.disconnect(), window.removeEventListener("resize", P), g.current === j && (g.current = null);
1278
+ };
1279
+ }, [s, n, e, d]), /* @__PURE__ */ N(
1280
+ "div",
1281
+ {
1282
+ className: ne("voice-composer", w),
1283
+ "data-voice-activity": t,
1284
+ "data-voice-frozen": s,
1285
+ "data-voice-muted": !n,
1286
+ "data-voice-phase": e,
1287
+ children: [
1288
+ /* @__PURE__ */ i("span", { "aria-live": "polite", className: "sr-only", children: r }),
1289
+ /* @__PURE__ */ N("div", { className: "voice-composer__track", children: [
1290
+ /* @__PURE__ */ i(
1291
+ "span",
1292
+ {
1293
+ "aria-hidden": e !== "connecting",
1294
+ className: "voice-composer__loader",
1295
+ children: Array.from({ length: 5 }, (v, y) => /* @__PURE__ */ i("span", { className: "voice-composer__loader-bar" }, y))
1296
+ }
1297
+ ),
1298
+ /* @__PURE__ */ i(
1299
+ "canvas",
1300
+ {
1301
+ ref: h,
1302
+ "aria-hidden": "true",
1303
+ className: "voice-composer__wave-canvas",
1304
+ "data-voice-wave-canvas": !0
1305
+ }
1306
+ ),
1307
+ /* @__PURE__ */ i(
1308
+ Xa,
1309
+ {
1310
+ ref: m,
1311
+ phase: e,
1312
+ microphoneEnabled: n,
1313
+ microphoneLabel: a,
1314
+ disabled: c,
1315
+ frozen: s,
1316
+ onToggleMicrophone: l,
1317
+ meter: p,
1318
+ onInputFrame: C
1319
+ }
1320
+ )
1321
+ ] }),
1322
+ /* @__PURE__ */ i(
1323
+ Q,
1324
+ {
1325
+ type: "button",
1326
+ "aria-label": o,
1327
+ "data-chat-route-focus": !0,
1328
+ className: "voice-composer__close",
1329
+ onClick: u,
1330
+ children: /* @__PURE__ */ i($r, { "aria-hidden": "true" })
1331
+ }
1332
+ )
1333
+ ]
1334
+ }
1335
+ );
1336
+ }
1337
+ function ki({
1338
+ className: e,
1339
+ freezePresentation: t = !1
1340
+ }) {
1341
+ const { t: n } = me(), { open: r, config: a, api: o, reactionMessage: c } = kt(), s = Yt(), { networkStatus: l } = Mn(), u = Fr(), {
1342
+ startListening: w,
1343
+ stopListening: p,
1344
+ endVoiceChat: d,
1345
+ acceptConversation: h,
1346
+ declineConversation: m
1347
+ } = _n(), g = Se((k) => k.pendingInvitation), b = Se((k) => k.status), C = Se((k) => k.errorMessage), v = Se((k) => k.errorCode), y = Se((k) => k.generation), T = Se((k) => k.microphoneMutedByUser), E = Se(
1348
+ (k) => k.session !== null || k.socket !== null
1349
+ ), A = Se(
1350
+ (k) => k.assistantResponseInProgress
1351
+ ), _ = Se((k) => k.assistantAudioPlaying), [L, I] = F(!1), [X, M] = F(null), G = S(!1), j = S(y), P = S(t), [re, se] = F(
1352
+ !!g
1353
+ ), B = r && !u && !re && !g && !E && b === "idle" && !v && !C;
1354
+ R(() => {
1355
+ g && se(!0);
1356
+ }, [g]), ye(() => {
1357
+ j.current !== y && (j.current = y, G.current = !1);
1358
+ }, [y]), ye(() => {
1359
+ const k = P.current && !t;
1360
+ P.current = t, k && (G.current = !1, M(null));
1361
+ }, [t]);
1362
+ const J = U(async () => {
1363
+ I(!0);
1364
+ try {
1365
+ await h(a, o);
1366
+ } catch (k) {
1367
+ console.error("voice invitation failed", k);
1368
+ } finally {
1369
+ I(!1);
1370
+ }
1371
+ }, [h, o, a]), ae = U(async () => {
1372
+ s(ve.text), await m(a, o);
1373
+ }, [o, a, m, s]), ie = U(async () => {
1374
+ if (g) {
1375
+ await J();
1376
+ return;
1377
+ }
1378
+ if (!T) {
1379
+ p();
1380
+ return;
1381
+ }
1382
+ try {
1383
+ await w(a, o);
1384
+ } catch (k) {
1385
+ console.error("voice init error", k);
1386
+ }
1387
+ }, [
1388
+ J,
1389
+ o,
1390
+ a,
1391
+ T,
1392
+ g,
1393
+ w,
1394
+ p
1395
+ ]);
1396
+ R(() => {
1397
+ if (!r) {
1398
+ re || (G.current = !1);
1399
+ return;
1400
+ }
1401
+ t || X || G.current || !B || (G.current = !0, w(a, o).catch((k) => {
1402
+ console.error("voice init error", k);
1403
+ }));
1404
+ }, [
1405
+ o,
1406
+ B,
1407
+ a,
1408
+ X,
1409
+ t,
1410
+ re,
1411
+ r,
1412
+ w
1413
+ ]);
1414
+ const Z = ue(() => l === st.Unavailable ? n($e.connectionFailed) : l === st.Offline ? n($e.offline) : v ? n(no[v]) : C || null, [l, n, v, C]), ee = ue(() => n(_ ? "voice.speaking" : u || b === "connecting" || B ? "voice.connecting" : A ? "chat.thinking" : b === "speaking" ? "voice.speaking" : g ? "voice.incoming" : T ? "voice.muted" : "voice.startTalking"), [
1415
+ _,
1416
+ A,
1417
+ B,
1418
+ u,
1419
+ T,
1420
+ g,
1421
+ n,
1422
+ b
1423
+ ]), D = !c && Z, K = u || b === "connecting" || B ? "connecting" : "ready", he = _ ? "speaking" : A ? "thinking" : "idle", Ae = {
1424
+ phase: K,
1425
+ assistantActivity: he,
1426
+ microphoneEnabled: !T
1427
+ }, [Ie, fe] = F(Ae);
1428
+ ye(() => {
1429
+ t || fe({
1430
+ phase: K,
1431
+ assistantActivity: he,
1432
+ microphoneEnabled: !T
1433
+ });
1434
+ }, [
1435
+ he,
1436
+ K,
1437
+ t,
1438
+ T
1439
+ ]);
1440
+ const ce = X ?? (t ? Ie : Ae), de = U(() => {
1441
+ M({
1442
+ phase: K,
1443
+ assistantActivity: he,
1444
+ microphoneEnabled: !T
1445
+ }), d(), s(ve.text);
1446
+ }, [
1447
+ he,
1448
+ K,
1449
+ d,
1450
+ T,
1451
+ s
1452
+ ]);
1453
+ return /* @__PURE__ */ N(
1454
+ "div",
1455
+ {
1456
+ className: ne(
1457
+ "z-1 flex min-h-0 flex-1 flex-col items-center justify-end px-4 pb-3",
1458
+ e
1459
+ ),
1460
+ children: [
1461
+ c && /* @__PURE__ */ i(
1462
+ Si,
1463
+ {
1464
+ className: "mb-5",
1465
+ message: c,
1466
+ source: pa.ReactionMessage
1467
+ }
1468
+ ),
1469
+ g && !c && /* @__PURE__ */ N("div", { className: "chat-voice-card mb-5 flex max-w-70 flex-col items-center gap-2.5 p-4 text-center text-white", children: [
1470
+ /* @__PURE__ */ i("p", { className: "text-sm font-semibold", children: n("voice.calling") }),
1471
+ /* @__PURE__ */ i("p", { className: "text-[13px] leading-5 text-white/80", children: g.text }),
1472
+ /* @__PURE__ */ i("p", { className: "text-xs text-white/70", children: n("voice.aiDisclosure") }),
1473
+ /* @__PURE__ */ N("div", { className: "flex gap-2", children: [
1474
+ /* @__PURE__ */ i(
1475
+ Q,
1476
+ {
1477
+ type: "button",
1478
+ disabled: L,
1479
+ onClick: () => {
1480
+ J();
1481
+ },
1482
+ className: "chat-cta-primary data-disabled:opacity-50",
1483
+ children: n(L ? "voice.connecting" : "voice.accept")
1484
+ }
1485
+ ),
1486
+ /* @__PURE__ */ i(
1487
+ Q,
1488
+ {
1489
+ type: "button",
1490
+ disabled: L,
1491
+ onClick: () => {
1492
+ ae();
1493
+ },
1494
+ className: "chat-cta-secondary data-disabled:opacity-50",
1495
+ children: n("voice.decline")
1496
+ }
1497
+ )
1498
+ ] })
1499
+ ] }),
1500
+ D && /* @__PURE__ */ i(ma, { className: "mb-5", message: Z }),
1501
+ /* @__PURE__ */ i(ga, { className: "mb-5 items-center text-center" }),
1502
+ /* @__PURE__ */ i(
1503
+ _i,
1504
+ {
1505
+ phase: ce.phase,
1506
+ assistantActivity: ce.assistantActivity,
1507
+ microphoneEnabled: ce.microphoneEnabled,
1508
+ statusLabel: ee,
1509
+ microphoneLabel: n(g ? "voice.accept" : T ? "voice.unmuteMicrophone" : "voice.muteMicrophone"),
1510
+ closeLabel: n("voice.switchToText"),
1511
+ disabled: L || u,
1512
+ frozen: !!(X || t || !r),
1513
+ spectrumSource: ro,
1514
+ onToggleMicrophone: () => {
1515
+ ie();
1516
+ },
1517
+ onClose: () => {
1518
+ de();
1519
+ }
1520
+ }
1521
+ )
1522
+ ]
1523
+ }
1524
+ );
1525
+ }
1526
+ const Li = (e) => /* @__PURE__ */ we.createElement("svg", { width: 21, height: 19, viewBox: "0 0 21 19", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M11.3359 18C11.3359 18.5523 10.8882 19 10.3359 19C9.78365 19 9.33594 18.5523 9.33594 18V1C9.33594 0.447715 9.78365 0 10.3359 0C10.8882 0 11.3359 0.447715 11.3359 1V18ZM16.2461 15.5C16.2461 16.0523 15.7984 16.5 15.2461 16.5C14.6938 16.5 14.2461 16.0523 14.2461 15.5V4.5C14.2461 3.94772 14.6938 3.5 15.2461 3.5C15.7984 3.5 16.2461 3.94772 16.2461 4.5V15.5ZM6.58594 13.583C6.58594 14.1353 6.13822 14.583 5.58594 14.583C5.03365 14.583 4.58594 14.1353 4.58594 13.583V6.58301C4.58594 6.03072 5.03365 5.58301 5.58594 5.58301C6.13822 5.58301 6.58594 6.03072 6.58594 6.58301V13.583ZM2 10.583C2 11.1353 1.55228 11.583 1 11.583C0.447715 11.583 0 11.1353 0 10.583V9.58301C0 9.03072 0.447715 8.58301 1 8.58301C1.55228 8.58301 2 9.03072 2 9.58301V10.583ZM20.4922 10.583C20.4922 11.1353 20.0445 11.583 19.4922 11.583C18.9399 11.583 18.4922 11.1353 18.4922 10.583V9.58301C18.4922 9.03072 18.9399 8.58301 19.4922 8.58301C20.0445 8.58301 20.4922 9.03072 20.4922 9.58301V10.583Z" })), Ri = (e) => /* @__PURE__ */ we.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M14.2199 21.6303C13.0399 21.6303 11.3699 20.8003 10.0499 16.8303L9.32988 14.6703L7.16988 13.9503C3.20988 12.6303 2.37988 10.9603 2.37988 9.78031C2.37988 8.61031 3.20988 6.93032 7.16988 5.60032L15.6599 2.77032C17.7799 2.06032 19.5499 2.27032 20.6399 3.35032C21.7299 4.43032 21.9399 6.21032 21.2299 8.33032L18.3999 16.8203C17.0699 20.8003 15.3999 21.6303 14.2199 21.6303ZM7.63988 7.03032C4.85988 7.96032 3.86988 9.06032 3.86988 9.78031C3.86988 10.5003 4.85988 11.6003 7.63988 12.5203L10.1599 13.3603C10.3799 13.4303 10.5599 13.6103 10.6299 13.8303L11.4699 16.3503C12.3899 19.1303 13.4999 20.1203 14.2199 20.1203C14.9399 20.1203 16.0399 19.1303 16.9699 16.3503L19.7999 7.86032C20.3099 6.32032 20.2199 5.06032 19.5699 4.41032C18.9199 3.76032 17.6599 3.68032 16.1299 4.19032L7.63988 7.03032Z" }), /* @__PURE__ */ we.createElement("path", { d: "M10.1098 14.4C9.9198 14.4 9.7298 14.33 9.5798 14.18C9.2898 13.89 9.2898 13.41 9.5798 13.12L13.1598 9.53C13.4498 9.24 13.9298 9.24 14.2198 9.53C14.5098 9.82 14.5098 10.3 14.2198 10.59L10.6398 14.18C10.4998 14.33 10.2998 14.4 10.1098 14.4Z" }));
1527
+ const Ii = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Oi = (e) => e.replace(
1528
+ /^([A-Z])|[\s-_]+(\w)/g,
1529
+ (t, n, r) => r ? r.toUpperCase() : n.toLowerCase()
1530
+ ), wr = (e) => {
1531
+ const t = Oi(e);
1532
+ return t.charAt(0).toUpperCase() + t.slice(1);
1533
+ }, va = (...e) => e.filter((t, n, r) => !!t && t.trim() !== "" && r.indexOf(t) === n).join(" ").trim(), $i = (e) => {
1534
+ for (const t in e)
1535
+ if (t.startsWith("aria-") || t === "role" || t === "title")
1536
+ return !0;
1537
+ };
1538
+ var Fi = {
1539
+ xmlns: "http://www.w3.org/2000/svg",
1540
+ width: 24,
1541
+ height: 24,
1542
+ viewBox: "0 0 24 24",
1543
+ fill: "none",
1544
+ stroke: "currentColor",
1545
+ strokeWidth: 2,
1546
+ strokeLinecap: "round",
1547
+ strokeLinejoin: "round"
1548
+ };
1549
+ const Pi = _r(
1550
+ ({
1551
+ color: e = "currentColor",
1552
+ size: t = 24,
1553
+ strokeWidth: n = 2,
1554
+ absoluteStrokeWidth: r,
1555
+ className: a = "",
1556
+ children: o,
1557
+ iconNode: c,
1558
+ ...s
1559
+ }, l) => fn(
1560
+ "svg",
1561
+ {
1562
+ ref: l,
1563
+ ...Fi,
1564
+ width: t,
1565
+ height: t,
1566
+ stroke: e,
1567
+ strokeWidth: r ? Number(n) * 24 / Number(t) : n,
1568
+ className: va("lucide", a),
1569
+ ...!o && !$i(s) && { "aria-hidden": "true" },
1570
+ ...s
1571
+ },
1572
+ [
1573
+ ...c.map(([u, w]) => fn(u, w)),
1574
+ ...Array.isArray(o) ? o : [o]
1575
+ ]
1576
+ )
1577
+ );
1578
+ const pe = (e, t) => {
1579
+ const n = _r(
1580
+ ({ className: r, ...a }, o) => fn(Pi, {
1581
+ ref: o,
1582
+ iconNode: t,
1583
+ className: va(
1584
+ `lucide-${Ii(wr(e))}`,
1585
+ `lucide-${e}`,
1586
+ r
1587
+ ),
1588
+ ...a
1589
+ })
1590
+ );
1591
+ return n.displayName = wr(e), n;
1592
+ };
1593
+ const Di = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], Ui = pe("check", Di);
1594
+ const Hi = [
1595
+ ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }],
1596
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
1597
+ ], Bi = pe("clock", Hi);
1598
+ const Vi = [
1599
+ ["path", { d: "M12 15V3", key: "m9g1x1" }],
1600
+ ["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4", key: "ih7n3h" }],
1601
+ ["path", { d: "m7 10 5 5 5-5", key: "brsn70" }]
1602
+ ], xn = pe("download", Vi);
1603
+ const ji = [
1604
+ [
1605
+ "path",
1606
+ {
1607
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
1608
+ key: "1nclc0"
1609
+ }
1610
+ ],
1611
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
1612
+ ], zi = pe("eye", ji);
1613
+ const Wi = [
1614
+ [
1615
+ "path",
1616
+ {
1617
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
1618
+ key: "1oefj6"
1619
+ }
1620
+ ],
1621
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
1622
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
1623
+ ], Gi = pe("file-exclamation-point", Wi);
1624
+ const qi = [
1625
+ [
1626
+ "path",
1627
+ {
1628
+ d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
1629
+ key: "1oefj6"
1630
+ }
1631
+ ],
1632
+ ["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }],
1633
+ ["path", { d: "M10 9H8", key: "b1mrlr" }],
1634
+ ["path", { d: "M16 13H8", key: "t4e002" }],
1635
+ ["path", { d: "M16 17H8", key: "z1uh3a" }]
1636
+ ], Dn = pe("file-text", qi);
1637
+ const Ki = [
1638
+ [
1639
+ "path",
1640
+ {
1641
+ d: "M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",
1642
+ key: "1xhozi"
1643
+ }
1644
+ ]
1645
+ ], wa = pe("headphones", Ki);
1646
+ const Yi = [
1647
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
1648
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
1649
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
1650
+ ], Zi = pe("image", Yi);
1651
+ const Xi = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]], Vt = pe("loader-circle", Xi);
1652
+ const Ji = [
1653
+ [
1654
+ "path",
1655
+ {
1656
+ d: "m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",
1657
+ key: "1miecu"
1658
+ }
1659
+ ]
1660
+ ], yr = pe("paperclip", Ji);
1661
+ const Qi = [
1662
+ ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
1663
+ ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
1664
+ ], br = pe("rotate-ccw", Qi);
1665
+ const ec = [
1666
+ [
1667
+ "path",
1668
+ {
1669
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
1670
+ key: "oel41y"
1671
+ }
1672
+ ],
1673
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
1674
+ ], xr = pe("shield-check", ec);
1675
+ const tc = [
1676
+ [
1677
+ "path",
1678
+ {
1679
+ d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
1680
+ key: "oel41y"
1681
+ }
1682
+ ]
1683
+ ], nc = pe("shield", tc);
1684
+ const rc = [
1685
+ ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
1686
+ ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
1687
+ ], ya = pe("x", rc);
1688
+ function ba({
1689
+ className: e,
1690
+ label: t,
1691
+ ...n
1692
+ }) {
1693
+ const { t: r } = me();
1694
+ return /* @__PURE__ */ N(
1695
+ "div",
1696
+ {
1697
+ ...n,
1698
+ role: "status",
1699
+ className: ne("chat-typing-indicator", e),
1700
+ children: [
1701
+ /* @__PURE__ */ i("span", { className: "sr-only", children: t ?? r("chat.thinking") }),
1702
+ /* @__PURE__ */ i(
1703
+ "span",
1704
+ {
1705
+ "aria-hidden": "true",
1706
+ className: "chat-typing-indicator__dot chat-typing-indicator__dot_left"
1707
+ }
1708
+ ),
1709
+ /* @__PURE__ */ i(
1710
+ "span",
1711
+ {
1712
+ "aria-hidden": "true",
1713
+ className: "chat-typing-indicator__dot chat-typing-indicator__dot_center"
1714
+ }
1715
+ ),
1716
+ /* @__PURE__ */ i(
1717
+ "span",
1718
+ {
1719
+ "aria-hidden": "true",
1720
+ className: "chat-typing-indicator__dot chat-typing-indicator__dot_right"
1721
+ }
1722
+ )
1723
+ ]
1724
+ }
1725
+ );
1726
+ }
1727
+ const ac = () => document.visibilityState === "hidden", oc = (e, t) => {
1728
+ const [n] = F(() => {
1729
+ const c = ao();
1730
+ return t && e.startsWith(t) && (c.setTarget(t), c.flush()), c;
1731
+ }), r = S(null), [a, o] = F(
1732
+ () => n.getSnapshot()
1733
+ );
1734
+ return R(() => {
1735
+ const c = typeof window.matchMedia == "function" ? window.matchMedia("(prefers-reduced-motion: reduce)") : null;
1736
+ let s = null, l = !1;
1737
+ const u = () => {
1738
+ s !== null && (window.cancelAnimationFrame(s), s = null);
1739
+ }, w = () => {
1740
+ u();
1741
+ const g = n.flush();
1742
+ g && !l && o(g);
1743
+ }, p = () => c?.matches || ac() || typeof Intl.Segmenter != "function", d = (g) => {
1744
+ if (s = null, l) return;
1745
+ if (p()) {
1746
+ w();
1747
+ return;
1748
+ }
1749
+ const b = n.advance(g);
1750
+ b && o(b), n.isSettled() || (s = window.requestAnimationFrame(d));
1751
+ }, h = () => {
1752
+ n.isSettled() || (p() ? w() : s === null && (s = window.requestAnimationFrame(d)));
1753
+ };
1754
+ r.current = { start: h };
1755
+ const m = () => h();
1756
+ return c?.addEventListener("change", m), document.addEventListener("visibilitychange", m), () => {
1757
+ l = !0, r.current = null, u(), c?.removeEventListener("change", m), document.removeEventListener(
1758
+ "visibilitychange",
1759
+ m
1760
+ );
1761
+ };
1762
+ }, [n]), R(() => {
1763
+ n.setTarget(e), r.current?.start();
1764
+ }, [n, e]), {
1765
+ ...a,
1766
+ isSettled: a.displayedText === e
1767
+ };
1768
+ };
1769
+ function sc({
1770
+ stableText: e,
1771
+ incomingText: t,
1772
+ initialText: n = "",
1773
+ targetText: r = e + t,
1774
+ finished: a = !1,
1775
+ onSettled: o
1776
+ }) {
1777
+ const c = oc(r, n), s = S(void 0), l = S(o), u = ue(
1778
+ () => oo(c.displayedText),
1779
+ [c.displayedText]
1780
+ );
1781
+ return R(() => {
1782
+ l.current = o;
1783
+ }, [o]), R(() => {
1784
+ s.current = void 0;
1785
+ }, [r]), R(() => {
1786
+ !a || !c.isSettled || s.current !== r && (s.current = r, l.current?.());
1787
+ }, [a, c.isSettled, r]), /* @__PURE__ */ i(
1788
+ "div",
1789
+ {
1790
+ className: c.animatedText ? "chat-stream-markdown chat-stream-markdown--animated" : "chat-stream-markdown",
1791
+ dangerouslySetInnerHTML: { __html: u }
1792
+ }
1793
+ );
1794
+ }
1795
+ const xa = (e) => e < 1024 * 1024 ? `${Math.max(1, Math.round(e / 1024))} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`, Ca = (e) => e.mediaType === "image/jpeg" || e.mediaType === "image/png" || e.mediaType === "image/webp" ? "image" : e.mediaType === "application/pdf" ? "pdf" : null, yt = (e, t) => t.every((n, r) => e[r] === n), Ta = (e, t) => {
1796
+ switch (e) {
1797
+ case "application/pdf":
1798
+ return t.some(
1799
+ (n, r) => r <= t.length - 5 && yt(t.slice(r), [37, 80, 68, 70, 45])
1800
+ );
1801
+ case "image/png":
1802
+ return yt(
1803
+ t,
1804
+ [137, 80, 78, 71, 13, 10, 26, 10]
1805
+ );
1806
+ case "image/jpeg":
1807
+ return yt(t, [255, 216, 255]);
1808
+ case "image/webp":
1809
+ return yt(t, [82, 73, 70, 70]) && yt(t.slice(8), [87, 69, 66, 80]);
1810
+ default:
1811
+ return !1;
1812
+ }
1813
+ }, ic = async (e, t, n) => {
1814
+ const r = await fetch(e, { signal: n, credentials: "omit" });
1815
+ if (!r.ok) throw new Error("ATTACHMENT_PREVIEW_FETCH_FAILED");
1816
+ const a = await r.blob();
1817
+ if (t.size > 0 && a.size !== t.size)
1818
+ throw new Error("ATTACHMENT_PREVIEW_SIZE_MISMATCH");
1819
+ const o = new Uint8Array(await a.slice(0, 1024).arrayBuffer());
1820
+ if (!Ta(t.mediaType, o))
1821
+ throw new Error("ATTACHMENT_PREVIEW_SIGNATURE_MISMATCH");
1822
+ const c = new Blob([a], { type: t.mediaType });
1823
+ return URL.createObjectURL(c);
1824
+ }, cc = async (e, t) => {
1825
+ if (!t.startsWith("image/"))
1826
+ throw new Error("ATTACHMENT_LOCAL_PREVIEW_TYPE_UNSUPPORTED");
1827
+ const n = new Uint8Array(await e.slice(0, 1024).arrayBuffer());
1828
+ if (!Ta(t, n))
1829
+ throw new Error("ATTACHMENT_PREVIEW_SIGNATURE_MISMATCH");
1830
+ return URL.createObjectURL(new Blob([e], { type: t }));
1831
+ }, Cn = (e) => {
1832
+ const t = typeof window > "u" ? "https://sdk.invalid/" : window.location.href, n = new URL(e, t), r = n.hostname === "localhost" || n.hostname === "127.0.0.1" || n.hostname === "::1" || n.hostname.endsWith(".localhost");
1833
+ if (!(n.protocol === "https:" || n.protocol === "blob:" || n.protocol === "mock:" || n.protocol === "http:" && r))
1834
+ throw new Error("ATTACHMENT_GRANT_URL_UNSAFE");
1835
+ return n.href;
1836
+ }, Ea = async (e, t, n) => {
1837
+ if (e.downloadUrl)
1838
+ return Cn(e.downloadUrl);
1839
+ if (!n.grant) throw new Error("ATTACHMENT_GRANT_UNAVAILABLE");
1840
+ const r = await n.grant({
1841
+ attachmentId: e.id,
1842
+ conversationId: t
1843
+ });
1844
+ return Cn(r.url);
1845
+ }, Na = async (e, t, n) => {
1846
+ if (e.downloadUrl) {
1847
+ const a = document.createElement("a");
1848
+ a.href = Cn(e.downloadUrl), a.download = e.fileName, a.rel = "noreferrer", a.click();
1849
+ return;
1850
+ }
1851
+ const r = window.open("about:blank", "_blank");
1852
+ if (!r) throw new Error("ATTACHMENT_DOWNLOAD_WINDOW_BLOCKED");
1853
+ r.opener = null;
1854
+ try {
1855
+ const a = await Ea(
1856
+ e,
1857
+ t,
1858
+ n
1859
+ );
1860
+ r.location.replace(a);
1861
+ } catch (a) {
1862
+ throw r.close(), a;
1863
+ }
1864
+ };
1865
+ function Aa({
1866
+ attachments: e,
1867
+ onPreview: t,
1868
+ onDownload: n
1869
+ }) {
1870
+ const { t: r } = me();
1871
+ return e?.length ? /* @__PURE__ */ N("div", { className: "chat-attachments", "aria-label": r("attachment.listLabel"), children: [
1872
+ e.map((a) => {
1873
+ const o = !!Ca(a), c = a.kind === "image" ? Zi : Dn;
1874
+ return /* @__PURE__ */ N("article", { className: "chat-attachment-card", children: [
1875
+ a.previewUrl && a.kind === "image" ? /* @__PURE__ */ i(
1876
+ "img",
1877
+ {
1878
+ src: a.previewUrl,
1879
+ alt: "",
1880
+ className: "chat-attachment-card__thumbnail"
1881
+ }
1882
+ ) : /* @__PURE__ */ i("span", { className: "chat-attachment-card__icon", "aria-hidden": "true", children: /* @__PURE__ */ i(c, { className: "h-4 w-4" }) }),
1883
+ /* @__PURE__ */ N("div", { className: "min-w-0 flex-1", children: [
1884
+ /* @__PURE__ */ i("p", { className: "truncate text-xs font-semibold text-white/90", children: a.fileName }),
1885
+ /* @__PURE__ */ i("p", { className: "mt-0.5 truncate text-[10px] text-white/48", children: xa(a.size) })
1886
+ ] }),
1887
+ /* @__PURE__ */ N("div", { className: "flex shrink-0 items-center gap-0.5", children: [
1888
+ o && t && /* @__PURE__ */ i(
1889
+ Q,
1890
+ {
1891
+ type: "button",
1892
+ "aria-label": `${r("attachment.preview")} ${a.fileName}`,
1893
+ onClick: () => t(a),
1894
+ className: "chat-attachment-card__action",
1895
+ children: /* @__PURE__ */ i(zi, { "aria-hidden": "true", className: "h-3.5 w-3.5" })
1896
+ }
1897
+ ),
1898
+ n ? /* @__PURE__ */ i(
1899
+ Q,
1900
+ {
1901
+ type: "button",
1902
+ "aria-label": `${r("attachment.download")} ${a.fileName}`,
1903
+ onClick: () => n(a),
1904
+ className: "chat-attachment-card__action",
1905
+ children: /* @__PURE__ */ i(xn, { "aria-hidden": "true", className: "h-3.5 w-3.5" })
1906
+ }
1907
+ ) : a.downloadUrl ? /* @__PURE__ */ i(
1908
+ "a",
1909
+ {
1910
+ href: a.downloadUrl,
1911
+ download: a.fileName,
1912
+ "aria-label": `${r("attachment.download")} ${a.fileName}`,
1913
+ className: "chat-attachment-card__action",
1914
+ children: /* @__PURE__ */ i(xn, { "aria-hidden": "true", className: "h-3.5 w-3.5" })
1915
+ }
1916
+ ) : null
1917
+ ] })
1918
+ ] }, a.id);
1919
+ }),
1920
+ /* @__PURE__ */ i("span", { className: "sr-only", children: e.length === 1 ? r("attachment.oneAttachment") : r("attachment.manyAttachments", { count: e.length }) })
1921
+ ] }) : null;
1922
+ }
1923
+ const Cr = (e) => typeof Intl.Segmenter == "function" ? Array.from(
1924
+ new Intl.Segmenter(void 0, { granularity: "grapheme" }).segment(e),
1925
+ ({ segment: t }) => t
1926
+ ) : Array.from(e);
1927
+ function lc(e) {
1928
+ const t = e.trim().split(/\s+/u).filter(Boolean);
1929
+ return t.length === 0 ? "?" : (t.length > 1 ? t.slice(0, 2).map((r) => Cr(r)[0]) : Cr(t[0]).slice(0, 2)).filter(Boolean).join("").toLocaleUpperCase() || "?";
1930
+ }
1931
+ const uc = {
1932
+ message: "h-7 w-7 text-[10px]",
1933
+ header: "h-8 w-8 text-[11px]"
1934
+ }, dc = () => () => {
1935
+ };
1936
+ function Un({
1937
+ conversationId: e,
1938
+ presentation: t,
1939
+ ...n
1940
+ }) {
1941
+ const r = Pr(), a = so(e), o = Nn(
1942
+ r?.subscribeAuthority ?? dc,
1943
+ () => r?.getAuthoritySnapshot(e) ?? "none",
1944
+ () => r?.getAuthoritySnapshot(e) ?? "none"
1945
+ ), c = t?.contractState === "LEGACY" ? t.legacyAvatarUrl : null, s = [
1946
+ o,
1947
+ a ? "authorized" : "denied",
1948
+ e,
1949
+ t?.avatarAsset?.id ?? "no-asset",
1950
+ t?.avatarAsset?.version ?? "no-version",
1951
+ c ?? "no-legacy"
1952
+ ].join(":");
1953
+ return /* @__PURE__ */ i(
1954
+ hc,
1955
+ {
1956
+ conversationId: e,
1957
+ isAuthorized: a,
1958
+ presentation: t,
1959
+ ...n
1960
+ },
1961
+ s
1962
+ );
1963
+ }
1964
+ function hc({
1965
+ conversationId: e,
1966
+ isAuthorized: t,
1967
+ displayName: n,
1968
+ fallbackKind: r,
1969
+ presentation: a,
1970
+ size: o,
1971
+ className: c
1972
+ }) {
1973
+ const s = Pr(), l = S(null), [u, w] = F(!1), [p, d] = F(null), [h, m] = F(!1), [g, b] = F(0), [C, v] = F(0), [y, T] = F(
1974
+ () => typeof IntersectionObserver != "function"
1975
+ ), E = a?.avatarAsset ?? null, A = a?.contractState === "LEGACY" ? a.legacyAvatarUrl : null, _ = !!(A && !u);
1976
+ return R(() => {
1977
+ const L = l.current;
1978
+ if (!L || y || typeof IntersectionObserver != "function")
1979
+ return;
1980
+ const I = new IntersectionObserver(
1981
+ (X) => {
1982
+ X.some(({ isIntersecting: M }) => M) && (T(!0), I.disconnect());
1983
+ },
1984
+ { rootMargin: "160px" }
1985
+ );
1986
+ return I.observe(L), () => I.disconnect();
1987
+ }, [y]), R(() => {
1988
+ if (!s || !t || !E || !y || g > 1)
1989
+ return;
1990
+ let L = !0, I;
1991
+ const X = { conversationId: e, asset: E };
1992
+ return s.resolve(X).then((M) => {
1993
+ if (!L) return;
1994
+ if (!M) {
1995
+ d(null), m(!1);
1996
+ return;
1997
+ }
1998
+ d(M.url);
1999
+ const G = Date.parse(M.expiresAt) - Date.now() - 5e3;
2000
+ I = window.setTimeout(
2001
+ () => {
2002
+ v((j) => j + 1);
2003
+ },
2004
+ Math.max(0, Math.min(G, 2147e6))
2005
+ );
2006
+ }), () => {
2007
+ L = !1, I !== void 0 && window.clearTimeout(I);
2008
+ };
2009
+ }, [
2010
+ E,
2011
+ e,
2012
+ g,
2013
+ t,
2014
+ y,
2015
+ C,
2016
+ s
2017
+ ]), /* @__PURE__ */ N(
2018
+ "span",
2019
+ {
2020
+ ref: l,
2021
+ "aria-hidden": "true",
2022
+ className: ne(
2023
+ "presentation-avatar relative grid shrink-0 place-items-center overflow-hidden rounded-full bg-black/45 font-semibold tracking-[-0.02em] text-white/88 shadow-[inset_0_0_0_1px_rgba(255,255,255,0.11)]",
2024
+ uc[o],
2025
+ r === "LOLA" && "bg-[#111923]",
2026
+ r === "HUMAN" && "bg-[linear-gradient(145deg,#684d6d_0%,#3f3348_100%)]",
2027
+ r === "SUPPORT" && "bg-[#171b15] text-[#a5fc4c] shadow-[inset_0_0_0_1px_rgba(165,252,76,0.24),0_0_18px_rgba(165,252,76,0.1)]",
2028
+ c
2029
+ ),
2030
+ children: [
2031
+ r === "LOLA" ? /* @__PURE__ */ i(
2032
+ "img",
2033
+ {
2034
+ src: io,
2035
+ alt: "",
2036
+ draggable: !1,
2037
+ className: "h-full w-full object-cover object-[50%_20%]"
2038
+ }
2039
+ ) : r === "HUMAN" ? /* @__PURE__ */ i("span", { children: lc(n) }) : r === "SYSTEM" ? /* @__PURE__ */ i(nc, { className: "h-[50%] w-[50%] text-white/55" }) : /* @__PURE__ */ i(wa, { className: "h-[52%] w-[52%] text-current opacity-80" }),
2040
+ _ && /* @__PURE__ */ i(
2041
+ "img",
2042
+ {
2043
+ src: A ?? void 0,
2044
+ alt: "",
2045
+ draggable: !1,
2046
+ loading: "lazy",
2047
+ decoding: "async",
2048
+ referrerPolicy: "no-referrer",
2049
+ onError: () => w(!0),
2050
+ className: "absolute inset-0 h-full w-full object-cover shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)]"
2051
+ }
2052
+ ),
2053
+ p && g <= 1 && /* @__PURE__ */ i(
2054
+ "img",
2055
+ {
2056
+ src: p,
2057
+ alt: "",
2058
+ draggable: !1,
2059
+ loading: "lazy",
2060
+ decoding: "async",
2061
+ referrerPolicy: "no-referrer",
2062
+ onLoad: () => m(!0),
2063
+ onError: () => {
2064
+ !E || !s || (s.invalidate({ conversationId: e, asset: E }), d(null), m(!1), b((L) => L + 1));
2065
+ },
2066
+ className: ne(
2067
+ "absolute inset-0 h-full w-full object-cover opacity-0 shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1)] transition-opacity duration-150 motion-reduce:transition-none",
2068
+ h && "opacity-100"
2069
+ )
2070
+ }
2071
+ )
2072
+ ]
2073
+ }
2074
+ );
2075
+ }
2076
+ const fc = kr(function({
2077
+ message: t,
2078
+ onPreviewAttachment: n,
2079
+ onDownloadAttachment: r,
2080
+ className: a,
2081
+ ref: o,
2082
+ ...c
2083
+ }) {
2084
+ const { t: s } = me(), l = Ee(co), { scenarioChoiceSubmissionController: u } = Mn(), { settleMessageStream: w } = kn(), p = lo(t), d = t.author.type === Te.Agent, h = uo(t.id), [m, g] = F(() => Date.now()), [b, C] = F(), [v, y] = F(() => ({
2085
+ active: !!(d && h),
2086
+ text: d && h ? "" : p
2087
+ })), T = S(null), E = S(null), [A, _] = F(() => /* @__PURE__ */ new Set()), L = Ln(), I = !!l?.open && t.conversationId === L, X = l ? I : !0, { author: M } = t, G = t.status === Xe.Failed || t.status === Xe.Cancelled, j = t.status === Xe.Completed || G, P = ue(() => ho(t), [t]), re = ue(
2088
+ () => ({
2089
+ principalId: l?.runtime.getPrincipalSessionId() ?? "anonymous",
2090
+ inputRequestId: P?.inputRequestId ?? `none:${t.id}`
2091
+ }),
2092
+ [P?.inputRequestId, t.id, l?.runtime]
2093
+ ), se = U(
2094
+ (H) => u.subscribe(
2095
+ re,
2096
+ H
2097
+ ),
2098
+ [re, u]
2099
+ ), B = U(
2100
+ () => u.getSnapshot(re),
2101
+ [re, u]
2102
+ ), J = Nn(
2103
+ se,
2104
+ B,
2105
+ B
2106
+ ), ae = J.status, ie = J.selectedOptionId ?? void 0, Z = !!(P && fo(P, m)), ee = P?.inputRequestId ?? null, D = U(() => {
2107
+ ee && _((H) => {
2108
+ if (H.has(ee)) return H;
2109
+ const le = new Set(H);
2110
+ if (le.add(ee), le.size > 64) {
2111
+ const Be = le.values().next().value;
2112
+ Be !== void 0 && le.delete(Be);
2113
+ }
2114
+ return le;
2115
+ });
2116
+ }, [ee]), K = M.role === "ADMIN" || M.role === "ASSISTANT" || M.role === "SCENARIO" || M.role === "SYSTEM" ? M.presentation ?? null : null, he = M.role === "ASSISTANT" || M.role === "SCENARIO" ? "LOLA" : M.role === "SYSTEM" ? "SYSTEM" : M.role === "ADMIN" && (K?.presentationVersion || K?.legacyAvatarUrl) ? "HUMAN" : "SUPPORT", Ae = (K?.displayName === "Support" && K.avatarAsset === null && K.presentationVersion === null ? s("identity.support") : K?.displayName) ?? (M.role === "ADMIN" ? M.displayName : void 0) ?? (he === "LOLA" ? "Lola" : s(he === "SYSTEM" ? "identity.system" : "identity.support")), Ie = ue(
2117
+ () => M.role === "SCENARIO" ? {
2118
+ subjectKind: "MESSAGE",
2119
+ subjectId: t.id,
2120
+ attributionHandle: t.id,
2121
+ ...t.ordinal !== void 0 ? { presentationOrdinal: t.ordinal } : {}
2122
+ } : null,
2123
+ [M.role, t.id, t.ordinal]
2124
+ ), fe = ue(
2125
+ () => P ? {
2126
+ subjectKind: "CHOICE",
2127
+ subjectId: P.inputRequestId,
2128
+ attributionHandle: P.inputRequestId
2129
+ } : null,
2130
+ [P]
2131
+ ), ce = U(() => {
2132
+ const H = T.current;
2133
+ return H ? !!(H.querySelector(
2134
+ ".chat-message-content"
2135
+ )?.textContent?.trim() || H.querySelector(".chat-attachments")) : !1;
2136
+ }, []);
2137
+ yn(
2138
+ l?.runtime,
2139
+ T,
2140
+ I,
2141
+ l?.surfaceEpisodeId ?? null,
2142
+ Ie,
2143
+ ce
2144
+ ), yn(
2145
+ l?.runtime,
2146
+ E,
2147
+ I && Z,
2148
+ l?.surfaceEpisodeId ?? null,
2149
+ fe
2150
+ );
2151
+ const de = U(
2152
+ (H) => {
2153
+ T.current = H, typeof o == "function" ? o(H) : o && (o.current = H);
2154
+ },
2155
+ [o]
2156
+ ), k = d ? h : void 0;
2157
+ !k && (v.active || v.text !== p) ? y({ active: !1, text: p }) : k && !v.active && y({ active: !0, text: v.text });
2158
+ const ct = (j ? p : "") || k?.text || "", Me = !!(k && (k.done || j)), nt = !!(k && ct && (!Me || b !== k.sequence)), lt = nt ? "" : mo(t);
2159
+ R(() => {
2160
+ if (!P || P.lifecycle?.status !== "PENDING") return;
2161
+ const H = po(P, Date.now());
2162
+ if (H === null || H <= 0) return;
2163
+ const le = window.setTimeout(
2164
+ () => g(Date.now()),
2165
+ Math.min(H + 1, 2147483647)
2166
+ );
2167
+ return () => window.clearTimeout(le);
2168
+ }, [P, m]), R(() => {
2169
+ P?.lifecycle && u.handleLifecycle(
2170
+ re,
2171
+ P.lifecycle
2172
+ );
2173
+ }, [
2174
+ P?.lifecycle,
2175
+ re,
2176
+ u
2177
+ ]);
2178
+ const Rt = U(
2179
+ (H) => !P || !Z ? Promise.resolve() : u.submit({
2180
+ ...re,
2181
+ optionId: H,
2182
+ ...I && l?.surfaceEpisodeId ? {
2183
+ presentationContext: {
2184
+ surface: "CHAT",
2185
+ surfaceEpisodeId: l.surfaceEpisodeId
2186
+ }
2187
+ } : {}
2188
+ }),
2189
+ [
2190
+ P,
2191
+ Z,
2192
+ re,
2193
+ I,
2194
+ l,
2195
+ u
2196
+ ]
2197
+ );
2198
+ return G ? null : /* @__PURE__ */ N(
2199
+ "div",
2200
+ {
2201
+ ref: de,
2202
+ ...c,
2203
+ "data-author": d ? "agent" : "customer",
2204
+ className: ne(
2205
+ "chat-message-row flex w-fit max-w-[86%] flex-col gap-2",
2206
+ M.type === Te.Agent ? "self-start" : "self-end",
2207
+ a
2208
+ ),
2209
+ children: [
2210
+ d && /* @__PURE__ */ N("div", { className: "chat-message-identity flex max-w-full items-center gap-1.5 ps-0.5", children: [
2211
+ /* @__PURE__ */ i(
2212
+ Un,
2213
+ {
2214
+ conversationId: t.conversationId,
2215
+ displayName: Ae,
2216
+ fallbackKind: he,
2217
+ presentation: K,
2218
+ size: "message"
2219
+ }
2220
+ ),
2221
+ /* @__PURE__ */ i("span", { className: "chat-message-author-name min-w-0 truncate text-[11px] leading-4 font-semibold text-white/72", children: Ae })
2222
+ ] }),
2223
+ /* @__PURE__ */ i(
2224
+ "div",
2225
+ {
2226
+ "data-author": d ? "agent" : "customer",
2227
+ className: ne(
2228
+ "message flex h-fit min-h-8 w-fit max-w-full items-center justify-center text-start",
2229
+ {
2230
+ "rounded-es-[5px]": M.type === Te.Agent,
2231
+ "self-start": M.type === Te.Agent,
2232
+ "rounded-ee-[5px]": M.type === Te.Customer,
2233
+ "self-end": M.type === Te.Customer
2234
+ }
2235
+ ),
2236
+ children: nt && k ? /* @__PURE__ */ i("div", { className: "chat-message-content w-full min-w-0 break-words", children: /* @__PURE__ */ i(
2237
+ sc,
2238
+ {
2239
+ stableText: k.stableText,
2240
+ incomingText: k.incomingText,
2241
+ sequence: k.sequence,
2242
+ initialText: v.text,
2243
+ targetText: ct,
2244
+ finished: Me,
2245
+ onSettled: () => {
2246
+ C(k.sequence), w(t.id);
2247
+ }
2248
+ }
2249
+ ) }) : lt || j ? /* @__PURE__ */ i(
2250
+ "div",
2251
+ {
2252
+ className: ne(
2253
+ "chat-message-content w-full min-w-0 break-words",
2254
+ !d && "whitespace-pre-wrap"
2255
+ ),
2256
+ dangerouslySetInnerHTML: { __html: lt }
2257
+ }
2258
+ ) : /* @__PURE__ */ i(ba, {})
2259
+ }
2260
+ ),
2261
+ /* @__PURE__ */ i(
2262
+ Aa,
2263
+ {
2264
+ attachments: t.attachments,
2265
+ onPreview: n ? (H) => n(H, t.conversationId) : void 0,
2266
+ onDownload: r ? (H) => r(H, t.conversationId) : void 0
2267
+ }
2268
+ ),
2269
+ P && Z && ae !== "terminal" && /* @__PURE__ */ N(
2270
+ "div",
2271
+ {
2272
+ ref: E,
2273
+ className: "flex flex-wrap gap-[10px] self-start",
2274
+ role: "group",
2275
+ "aria-label": s("chat.chooseAnswer"),
2276
+ children: [
2277
+ P.options.map((H) => {
2278
+ const le = ie === H.id, Be = ae === "submitting", ut = X && H.attention === "NUDGE_ONCE" && !Be && !A.has(P.inputRequestId);
2279
+ return /* @__PURE__ */ i(
2280
+ Q,
2281
+ {
2282
+ type: "button",
2283
+ disabled: Be,
2284
+ "aria-pressed": le,
2285
+ "data-presentation": H.presentation,
2286
+ "data-attention": ut ? "NUDGE_ONCE" : "NONE",
2287
+ onClick: () => {
2288
+ D(), Rt(H.id);
2289
+ },
2290
+ className: ne(
2291
+ "chat-choice-option",
2292
+ ut && "chat-attention-nudge-once",
2293
+ le && "chat-choice-option--selected"
2294
+ ),
2295
+ children: H.label
2296
+ },
2297
+ H.id
2298
+ );
2299
+ }),
2300
+ ae === "error" && /* @__PURE__ */ i("span", { className: "self-center text-xs text-red-200", children: s("chat.answerFailed") })
2301
+ ]
2302
+ }
2303
+ )
2304
+ ]
2305
+ }
2306
+ );
2307
+ }), mc = 600, pc = () => window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
2308
+ function gc({
2309
+ containerRef: e,
2310
+ contentRef: t,
2311
+ firstMessageId: n,
2312
+ messageCount: r,
2313
+ threadId: a,
2314
+ threshold: o = 80
2315
+ }) {
2316
+ const c = S(!0), s = S(!1), l = S(null), u = S(null), w = S(r), p = S(n), d = S(a), h = U(() => {
2317
+ l.current !== null && (window.cancelAnimationFrame(l.current), l.current = null);
2318
+ }, []), m = U(() => {
2319
+ u.current !== null && (window.clearTimeout(u.current), u.current = null);
2320
+ }, []), g = U(() => {
2321
+ if (!s.current) return;
2322
+ s.current = !1, m();
2323
+ const v = e.current;
2324
+ !v || !c.current || (h(), v.scrollTo({ top: v.scrollHeight, behavior: "auto" }));
2325
+ }, [h, m, e]), b = U(() => {
2326
+ if (!s.current) return;
2327
+ s.current = !1, m();
2328
+ const v = e.current;
2329
+ if (!v) return;
2330
+ const y = v.scrollHeight - v.scrollTop - v.clientHeight;
2331
+ c.current = y <= o;
2332
+ }, [m, e, o]), C = U(
2333
+ (v) => {
2334
+ if (s.current) return;
2335
+ const y = v.currentTarget, T = y.scrollHeight - y.scrollTop - y.clientHeight;
2336
+ c.current = T <= o;
2337
+ },
2338
+ [o]
2339
+ );
2340
+ return ye(() => {
2341
+ const v = e.current;
2342
+ if (!v) return;
2343
+ const y = w.current, T = d.current !== a, E = r > y, A = E && !T && p.current !== void 0 && p.current !== n;
2344
+ if (T && (c.current = !0), A)
2345
+ h(), m(), s.current = !1;
2346
+ else if (c.current) {
2347
+ h(), m();
2348
+ const _ = E && y > 0 && !pc();
2349
+ s.current = _, _ && (u.current = window.setTimeout(
2350
+ g,
2351
+ mc
2352
+ )), v.scrollTo({
2353
+ top: v.scrollHeight,
2354
+ behavior: _ ? "smooth" : "auto"
2355
+ });
2356
+ }
2357
+ w.current = r, p.current = n, d.current = a;
2358
+ }, [
2359
+ h,
2360
+ m,
2361
+ e,
2362
+ g,
2363
+ n,
2364
+ r,
2365
+ a
2366
+ ]), R(() => {
2367
+ const v = e.current, y = t.current;
2368
+ if (!v || !y) return;
2369
+ let T = null;
2370
+ return typeof ResizeObserver < "u" && (T = new ResizeObserver(() => {
2371
+ s.current || !c.current || l.current !== null || (l.current = window.requestAnimationFrame(() => {
2372
+ l.current = null, c.current && v.scrollTo({ top: v.scrollHeight, behavior: "auto" });
2373
+ }));
2374
+ }), T.observe(y)), v.addEventListener("scrollend", g), v.addEventListener("wheel", b, {
2375
+ passive: !0
2376
+ }), v.addEventListener("touchstart", b, {
2377
+ passive: !0
2378
+ }), v.addEventListener("pointerdown", b, {
2379
+ passive: !0
2380
+ }), () => {
2381
+ T?.disconnect(), v.removeEventListener("scrollend", g), v.removeEventListener("wheel", b), v.removeEventListener("touchstart", b), v.removeEventListener("pointerdown", b), h(), m(), s.current = !1;
2382
+ };
2383
+ }, [
2384
+ h,
2385
+ m,
2386
+ e,
2387
+ t,
2388
+ g,
2389
+ b
2390
+ ]), C;
2391
+ }
2392
+ function vc({
2393
+ className: e,
2394
+ label: t,
2395
+ ...n
2396
+ }) {
2397
+ return /* @__PURE__ */ i(
2398
+ "div",
2399
+ {
2400
+ ...n,
2401
+ "data-author": "agent",
2402
+ className: ne(
2403
+ "chat-message-row chat-pending-assistant-message flex w-fit max-w-[86%] flex-col gap-2 self-start",
2404
+ e
2405
+ ),
2406
+ children: /* @__PURE__ */ i("div", { className: "message flex h-fit min-h-8 w-fit max-w-full items-center justify-center self-start rounded-es-[5px] text-start", children: /* @__PURE__ */ i(ba, { label: t }) })
2407
+ }
2408
+ );
2409
+ }
2410
+ function wc({
2411
+ message: e,
2412
+ onPreviewAttachment: t,
2413
+ onDownloadAttachment: n
2414
+ }) {
2415
+ return /* @__PURE__ */ N(
2416
+ "div",
2417
+ {
2418
+ "data-author": "customer",
2419
+ className: "chat-message-row flex w-fit max-w-[86%] flex-col gap-2 self-end",
2420
+ children: [
2421
+ /* @__PURE__ */ i(
2422
+ "div",
2423
+ {
2424
+ "data-author": "customer",
2425
+ className: "message flex h-fit min-h-8 w-fit max-w-full items-center justify-center rounded-ee-[5px] text-start",
2426
+ children: /* @__PURE__ */ i("div", { className: "chat-message-content w-full min-w-0 break-words whitespace-pre-wrap", children: e.text })
2427
+ }
2428
+ ),
2429
+ /* @__PURE__ */ i(
2430
+ Aa,
2431
+ {
2432
+ attachments: e.attachments,
2433
+ onPreview: t ? (r) => t(r, e.conversationId) : void 0,
2434
+ onDownload: n ? (r) => n(r, e.conversationId) : void 0
2435
+ }
2436
+ ),
2437
+ e.readByAssistant && /* @__PURE__ */ i("span", { className: "chat-message-receipt", children: "Прочитано Lola" })
2438
+ ]
2439
+ }
2440
+ );
2441
+ }
2442
+ const yc = [
2443
+ {
2444
+ align: "self-start",
2445
+ delay: "-1280ms",
2446
+ tone: "agent",
2447
+ width: "w-[66%]",
2448
+ lines: ["w-full", "w-[72%]"]
2449
+ },
2450
+ {
2451
+ align: "self-end",
2452
+ delay: "-1120ms",
2453
+ tone: "customer",
2454
+ width: "w-[62%]",
2455
+ lines: ["w-full", "w-[56%]"]
2456
+ },
2457
+ {
2458
+ align: "self-start",
2459
+ delay: "-960ms",
2460
+ tone: "agent",
2461
+ width: "w-[78%]",
2462
+ lines: ["w-full", "w-[86%]", "w-[58%]"]
2463
+ },
2464
+ {
2465
+ align: "self-end",
2466
+ delay: "-800ms",
2467
+ tone: "customer",
2468
+ width: "w-[56%]",
2469
+ lines: ["w-full"]
2470
+ },
2471
+ {
2472
+ align: "self-start",
2473
+ delay: "-640ms",
2474
+ tone: "agent",
2475
+ width: "w-[64%]",
2476
+ lines: ["w-full", "w-[52%]"]
2477
+ },
2478
+ {
2479
+ align: "self-end",
2480
+ delay: "-480ms",
2481
+ tone: "customer",
2482
+ width: "w-[70%]",
2483
+ lines: ["w-full", "w-[64%]"]
2484
+ },
2485
+ {
2486
+ align: "self-start",
2487
+ delay: "-320ms",
2488
+ tone: "agent",
2489
+ width: "w-[72%]",
2490
+ lines: ["w-full", "w-[74%]"]
2491
+ },
2492
+ {
2493
+ align: "self-end",
2494
+ delay: "-160ms",
2495
+ tone: "customer",
2496
+ width: "w-[48%]",
2497
+ lines: ["w-full"]
2498
+ },
2499
+ {
2500
+ align: "self-start",
2501
+ delay: "0ms",
2502
+ tone: "agent",
2503
+ width: "w-[58%]",
2504
+ lines: ["w-full", "w-[62%]"]
2505
+ }
2506
+ ];
2507
+ function bc() {
2508
+ const { t: e } = me();
2509
+ return /* @__PURE__ */ i(
2510
+ "div",
2511
+ {
2512
+ role: "status",
2513
+ "aria-label": e("chat.loadingMessages"),
2514
+ className: "chat-message-skeleton flex w-full flex-col gap-2 pb-1",
2515
+ children: /* @__PURE__ */ i("div", { "aria-hidden": "true", className: "flex flex-col gap-2", children: yc.map((t, n) => /* @__PURE__ */ i(
2516
+ "div",
2517
+ {
2518
+ style: {
2519
+ "--chat-skeleton-delay": t.delay
2520
+ },
2521
+ className: `${t.align} ${t.width} chat-message-skeleton-bubble flex flex-col gap-2 border px-3 py-2.5 ${t.tone === "agent" ? "rounded-[17px] rounded-es-[5px] border-[#68d8ff]/10 bg-[var(--chat-surface-agent)]" : "rounded-[17px] rounded-ee-[5px] border-white/[0.06] bg-[#5b405f]/70"}`,
2522
+ children: t.lines.map((r, a) => /* @__PURE__ */ i(
2523
+ "span",
2524
+ {
2525
+ className: `${r} chat-message-skeleton-line h-2 rounded-full ${t.tone === "agent" ? "bg-[#68d8ff]/[0.13]" : "bg-white/[0.11]"}`
2526
+ },
2527
+ a
2528
+ ))
2529
+ },
2530
+ n
2531
+ )) })
2532
+ }
2533
+ );
2534
+ }
2535
+ const xc = ["-320ms", "-160ms", "0ms"];
2536
+ function Cc() {
2537
+ const { t: e } = me();
2538
+ return /* @__PURE__ */ i(
2539
+ "div",
2540
+ {
2541
+ role: "status",
2542
+ "aria-label": e("chat.loadingOlder"),
2543
+ className: "flex flex-col gap-2 px-2 py-3",
2544
+ children: /* @__PURE__ */ i("div", { "aria-hidden": "true", className: "flex flex-col gap-2", children: xc.map((t) => /* @__PURE__ */ N(
2545
+ "div",
2546
+ {
2547
+ style: { "--chat-skeleton-delay": t },
2548
+ className: "chat-list-pagination-skeleton chat-message-skeleton-bubble flex h-14 items-center gap-3 rounded-2xl border border-white/[0.05] bg-white/[0.035] px-3",
2549
+ children: [
2550
+ /* @__PURE__ */ i("span", { className: "h-8 w-8 shrink-0 rounded-full bg-[#68d8ff]/[0.1]" }),
2551
+ /* @__PURE__ */ N("span", { className: "flex flex-1 flex-col gap-2", children: [
2552
+ /* @__PURE__ */ i("span", { className: "h-2 w-[42%] rounded-full bg-white/[0.11]" }),
2553
+ /* @__PURE__ */ i("span", { className: "h-2 w-[76%] rounded-full bg-white/[0.07]" })
2554
+ ] })
2555
+ ]
2556
+ },
2557
+ t
2558
+ )) })
2559
+ }
2560
+ );
2561
+ }
2562
+ function Tc() {
2563
+ const { t: e } = me();
2564
+ return /* @__PURE__ */ i(
2565
+ go,
2566
+ {
2567
+ label: e("chat.loadingOlderMessages"),
2568
+ className: "chat-history-pagination-status",
2569
+ dotClassName: "chat-history-pagination-dot"
2570
+ }
2571
+ );
2572
+ }
2573
+ function Sa({
2574
+ rootRef: e,
2575
+ enabled: t,
2576
+ isLoading: n,
2577
+ onLoad: r,
2578
+ resetKey: a,
2579
+ rootMargin: o = "160px 0px"
2580
+ }) {
2581
+ const c = S(null), s = S(!1), l = S(0), u = S(!0), [w, p] = F(null), d = U(async () => {
2582
+ if (!t || n || s.current) return;
2583
+ const h = l.current;
2584
+ s.current = !0, p(null);
2585
+ try {
2586
+ await r();
2587
+ } catch (m) {
2588
+ u.current && l.current === h && p(
2589
+ m instanceof Error ? m : new Error("Failed to load more items")
2590
+ );
2591
+ } finally {
2592
+ l.current === h && (s.current = !1);
2593
+ }
2594
+ }, [t, n, r]);
2595
+ return R(() => {
2596
+ l.current += 1, s.current = !1, p(null);
2597
+ }, [a]), R(() => (u.current = !0, () => {
2598
+ u.current = !1;
2599
+ }), []), R(() => {
2600
+ const h = e.current, m = c.current;
2601
+ if (!t || !h || !m)
2602
+ return;
2603
+ const g = () => {
2604
+ const C = h.getBoundingClientRect(), v = m.getBoundingClientRect();
2605
+ v.bottom >= C.top && v.top <= C.bottom && d();
2606
+ };
2607
+ h.addEventListener("scroll", g, { passive: !0 });
2608
+ const b = typeof IntersectionObserver > "u" ? null : new IntersectionObserver(
2609
+ (C) => {
2610
+ C.some(({ isIntersecting: v }) => v) && d();
2611
+ },
2612
+ { root: h, rootMargin: o }
2613
+ );
2614
+ return b?.observe(m), () => {
2615
+ b?.disconnect(), h.removeEventListener("scroll", g);
2616
+ };
2617
+ }, [t, d, o, e]), { error: w, loadMore: d, sentinelRef: c };
2618
+ }
2619
+ const jt = (e) => [
2620
+ ...e.querySelectorAll("[data-chat-message-id]")
2621
+ ], Tr = (e) => {
2622
+ const t = e.getBoundingClientRect();
2623
+ return jt(e).find((n) => {
2624
+ const r = n.getBoundingClientRect();
2625
+ return r.bottom > t.top && r.top < t.bottom;
2626
+ });
2627
+ };
2628
+ function Ec({
2629
+ containerRef: e,
2630
+ contextId: t,
2631
+ firstItemId: n,
2632
+ isLoading: r,
2633
+ itemCount: a
2634
+ }) {
2635
+ const o = S(null), c = S(null), [s, l] = F(0), u = U(() => {
2636
+ o.current = null, c.current?.(), c.current = null;
2637
+ }, []), w = U(() => {
2638
+ const p = e.current;
2639
+ if (!p || !t) return;
2640
+ const d = Tr(p);
2641
+ d?.dataset.chatMessageId && (c.current?.(), c.current = null, o.current = {
2642
+ contextId: t,
2643
+ firstItemId: n,
2644
+ itemId: d.dataset.chatMessageId,
2645
+ itemCount: a,
2646
+ top: d.getBoundingClientRect().top
2647
+ }, l((h) => h + 1));
2648
+ }, [e, t, n, a]);
2649
+ return R(() => {
2650
+ const p = e.current;
2651
+ if (!p || !r) return;
2652
+ const d = () => {
2653
+ const h = o.current;
2654
+ if (!h || h.contextId !== t) return;
2655
+ const m = Tr(p);
2656
+ m?.dataset.chatMessageId && (h.itemId = m.dataset.chatMessageId, h.top = m.getBoundingClientRect().top);
2657
+ };
2658
+ return p.addEventListener("scroll", d, {
2659
+ passive: !0
2660
+ }), () => p.removeEventListener("scroll", d);
2661
+ }, [e, t, r]), ye(() => {
2662
+ const p = o.current;
2663
+ if (!p) return;
2664
+ if (p.contextId !== t) {
2665
+ u();
2666
+ return;
2667
+ }
2668
+ if (r && p.firstItemId === n) return;
2669
+ if (p.itemCount !== a && p.firstItemId === n) {
2670
+ u();
2671
+ return;
2672
+ }
2673
+ const d = e.current, h = d ? jt(d).find(
2674
+ (m) => m.dataset.chatMessageId === p.itemId
2675
+ ) : void 0;
2676
+ d && h ? (d.scrollTop += h.getBoundingClientRect().top - p.top, p.firstItemId = n, p.itemCount = a) : u();
2677
+ }, [u, e, t, n, r, a]), R(() => {
2678
+ const p = o.current, d = e.current;
2679
+ if (!p || !d || r || p.contextId !== t)
2680
+ return;
2681
+ let h = null, m = d.scrollTop;
2682
+ const g = () => {
2683
+ h = null;
2684
+ const A = o.current;
2685
+ if (!A) return;
2686
+ const _ = jt(d).find(
2687
+ (L) => L.dataset.chatMessageId === A.itemId
2688
+ );
2689
+ if (!_) {
2690
+ u();
2691
+ return;
2692
+ }
2693
+ m = d.scrollTop + _.getBoundingClientRect().top - A.top, d.scrollTop = m;
2694
+ }, b = typeof ResizeObserver > "u" ? null : new ResizeObserver(() => {
2695
+ h === null && (h = window.requestAnimationFrame(g));
2696
+ }), C = jt(d), v = C.findIndex(
2697
+ (A) => A.dataset.chatMessageId === p.itemId
2698
+ );
2699
+ for (const A of C.slice(0, v + 1))
2700
+ b?.observe(A);
2701
+ const y = () => u(), T = () => {
2702
+ Math.abs(d.scrollTop - m) > 1 && u();
2703
+ };
2704
+ d.addEventListener("scroll", T, {
2705
+ passive: !0
2706
+ }), d.addEventListener("wheel", y, { passive: !0 }), d.addEventListener("touchstart", y, {
2707
+ passive: !0
2708
+ }), d.addEventListener("pointerdown", y, {
2709
+ passive: !0
2710
+ });
2711
+ const E = () => {
2712
+ b?.disconnect(), h !== null && window.cancelAnimationFrame(h), d.removeEventListener("scroll", T), d.removeEventListener("wheel", y), d.removeEventListener("touchstart", y), d.removeEventListener("pointerdown", y);
2713
+ };
2714
+ return c.current = E, () => {
2715
+ c.current === E && (c.current = null), E();
2716
+ };
2717
+ }, [
2718
+ s,
2719
+ u,
2720
+ e,
2721
+ t,
2722
+ r,
2723
+ a
2724
+ ]), { captureAnchor: w, clearAnchor: u };
2725
+ }
2726
+ const Er = 10, Tn = 20 * 1024 * 1024, Nr = 50 * 1024 * 1024, Ma = [
2727
+ "application/pdf",
2728
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2729
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
2730
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
2731
+ "image/jpeg",
2732
+ "image/png",
2733
+ "image/webp",
2734
+ "text/csv",
2735
+ "text/plain"
2736
+ ], Nc = [
2737
+ ...Ma,
2738
+ ".pdf",
2739
+ ".docx",
2740
+ ".xlsx",
2741
+ ".pptx",
2742
+ ".jpg",
2743
+ ".jpeg",
2744
+ ".png",
2745
+ ".webp",
2746
+ ".csv",
2747
+ ".txt"
2748
+ ].join(",");
2749
+ class Re extends Error {
2750
+ constructor(t, n) {
2751
+ super(t), this.code = t, this.status = n, this.name = "ChatAttachmentApiError";
2752
+ }
2753
+ }
2754
+ const Ac = {
2755
+ csv: "text/csv",
2756
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
2757
+ jpeg: "image/jpeg",
2758
+ jpg: "image/jpeg",
2759
+ pdf: "application/pdf",
2760
+ png: "image/png",
2761
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
2762
+ txt: "text/plain",
2763
+ webp: "image/webp",
2764
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
2765
+ }, Sc = new Set(Ma), _a = (e) => {
2766
+ const t = e.normalize("NFC").trim();
2767
+ return !!(t && new TextEncoder().encode(t).byteLength <= 255 && !/[\0\r\n\\/\u202a-\u202e\u2066-\u2069]/u.test(t));
2768
+ }, En = (e) => {
2769
+ const t = e.type.trim().toLowerCase();
2770
+ if (Sc.has(t)) return t;
2771
+ if (t) return null;
2772
+ const n = e.name.split(".").at(-1)?.toLowerCase() ?? "";
2773
+ return Ac[n] ?? null;
2774
+ }, Ut = (e) => e ? `?${new URLSearchParams({ conversationId: e }).toString()}` : "", Mc = (e) => {
2775
+ const t = new URL(e), n = t.hostname === "localhost" || t.hostname === "127.0.0.1" || t.hostname === "::1" || t.hostname.endsWith(".localhost");
2776
+ if (t.protocol !== "https:" && !(t.protocol === "http:" && n))
2777
+ throw new Re("CHAT_ATTACHMENT_UPLOAD_URL_UNSAFE");
2778
+ return t.href;
2779
+ }, _c = async (e) => {
2780
+ try {
2781
+ const t = await e.json();
2782
+ if (typeof t.code == "string" && t.code) return t.code;
2783
+ if (typeof t.message == "string" && t.message) return t.message;
2784
+ } catch {
2785
+ }
2786
+ return `CHAT_ATTACHMENT_HTTP_${e.status}`;
2787
+ }, Nt = (e) => {
2788
+ if (e?.aborted) throw new DOMException("Upload aborted", "AbortError");
2789
+ }, kc = (e, t) => new Promise((n, r) => {
2790
+ Nt(t);
2791
+ const a = window.setTimeout(() => {
2792
+ t?.removeEventListener("abort", o), n();
2793
+ }, e), o = () => {
2794
+ window.clearTimeout(a), r(new DOMException("Upload aborted", "AbortError"));
2795
+ };
2796
+ t?.addEventListener("abort", o, { once: !0 });
2797
+ }), Lc = async (e) => {
2798
+ const t = await e.arrayBuffer(), n = await crypto.subtle.digest("SHA-256", t);
2799
+ return Array.from(
2800
+ new Uint8Array(n),
2801
+ (r) => r.toString(16).padStart(2, "0")
2802
+ ).join("");
2803
+ }, Rc = ({
2804
+ file: e,
2805
+ requiredHeaders: t,
2806
+ signal: n,
2807
+ uploadUrl: r,
2808
+ onProgress: a
2809
+ }) => new Promise((o, c) => {
2810
+ Nt(n);
2811
+ const s = new XMLHttpRequest();
2812
+ let l = !1;
2813
+ const u = (p) => {
2814
+ l || (l = !0, n?.removeEventListener("abort", w), p());
2815
+ }, w = () => s.abort();
2816
+ s.open("PUT", r), Object.entries(t).forEach(
2817
+ ([p, d]) => s.setRequestHeader(p, d)
2818
+ ), s.upload.addEventListener("progress", (p) => {
2819
+ p.lengthComputable && p.total > 0 && a?.(Math.min(1, p.loaded / p.total));
2820
+ }), s.addEventListener("load", () => {
2821
+ s.status >= 200 && s.status < 300 ? u(o) : u(
2822
+ () => c(
2823
+ new Re(
2824
+ `CHAT_ATTACHMENT_STORAGE_HTTP_${s.status}`,
2825
+ s.status
2826
+ )
2827
+ )
2828
+ );
2829
+ }), s.addEventListener(
2830
+ "error",
2831
+ () => u(
2832
+ () => c(new Re("CHAT_ATTACHMENT_UPLOAD_FAILED"))
2833
+ )
2834
+ ), s.addEventListener(
2835
+ "abort",
2836
+ () => u(() => c(new DOMException("Upload aborted", "AbortError")))
2837
+ ), n?.addEventListener("abort", w, { once: !0 }), a?.(0), s.send(e);
2838
+ }), Ic = (e, t, n = {}) => {
2839
+ const r = n.fetchImpl ?? fetch, a = n.uploadFile ?? Rc, o = n.digest ?? Lc, c = n.wait ?? kc, s = n.pollIntervalMs ?? 750, l = n.maxPolls ?? 160, u = async (h, m) => {
2840
+ const g = await r(`${Po}${h}`, {
2841
+ ...m,
2842
+ headers: {
2843
+ Authorization: `Bearer ${e.customerInteractionSession.accessToken}`,
2844
+ ...m?.body ? { "Content-Type": "application/json" } : {},
2845
+ ...m?.headers
2846
+ }
2847
+ });
2848
+ if (!g.ok)
2849
+ throw g.status === 401 && t.onSessionExpired(), new Re(
2850
+ await _c(g),
2851
+ g.status
2852
+ );
2853
+ return await g.json();
2854
+ }, w = async ({
2855
+ attachmentId: h,
2856
+ conversationId: m
2857
+ }) => {
2858
+ await u(
2859
+ `/chat/attachments/${encodeURIComponent(h)}/revoke${Ut(
2860
+ m
2861
+ )}`,
2862
+ {
2863
+ method: "POST"
2864
+ }
2865
+ );
2866
+ }, p = (h, m, g) => u(
2867
+ `/chat/attachments/${encodeURIComponent(h)}${Ut(
2868
+ m
2869
+ )}`,
2870
+ { signal: g }
2871
+ ), d = (h, m) => {
2872
+ if (h.state !== "READY" || !h.canAttach)
2873
+ throw new Re(
2874
+ h.failureCode || `CHAT_ATTACHMENT_${h.state}`
2875
+ );
2876
+ if (h.id !== m.id || h.contentType !== m.contentType || h.sizeBytes !== m.sizeBytes)
2877
+ throw new Re("CHAT_ATTACHMENT_CONTRACT_MISMATCH");
2878
+ return {
2879
+ id: h.id,
2880
+ fileName: h.displayFilename,
2881
+ mediaType: h.contentType,
2882
+ size: h.sizeBytes,
2883
+ kind: Do(h.contentType)
2884
+ };
2885
+ };
2886
+ return {
2887
+ async upload({
2888
+ file: h,
2889
+ conversationId: m,
2890
+ signal: g,
2891
+ onProgress: b,
2892
+ onStage: C
2893
+ }) {
2894
+ const v = h.name.normalize("NFC").trim();
2895
+ if (!_a(v))
2896
+ throw new Re("CHAT_ATTACHMENT_FILENAME_INVALID");
2897
+ if (h.size < 1 || h.size > Tn)
2898
+ throw new Re("CHAT_ATTACHMENT_SIZE_INVALID");
2899
+ const y = En(h);
2900
+ if (!y)
2901
+ throw new Re(
2902
+ "CHAT_ATTACHMENT_CONTENT_TYPE_UNSUPPORTED"
2903
+ );
2904
+ let T;
2905
+ try {
2906
+ Nt(g), C?.("preparing");
2907
+ const E = await o(h);
2908
+ Nt(g);
2909
+ const A = await u(
2910
+ "/chat/attachments/uploads",
2911
+ {
2912
+ method: "POST",
2913
+ body: JSON.stringify({
2914
+ displayFilename: v,
2915
+ contentType: y,
2916
+ sizeBytes: h.size,
2917
+ checksumSha256: E,
2918
+ ...m ? { conversationId: m } : {}
2919
+ }),
2920
+ signal: g
2921
+ }
2922
+ );
2923
+ T = A.id, C?.("uploading"), await a({
2924
+ file: h,
2925
+ uploadUrl: Mc(A.uploadUrl),
2926
+ requiredHeaders: A.requiredHeaders,
2927
+ signal: g,
2928
+ onProgress: b
2929
+ }), Nt(g), b?.(1), C?.("scanning");
2930
+ let _ = await u(
2931
+ `/chat/attachments/${encodeURIComponent(A.id)}/complete${Ut(
2932
+ m
2933
+ )}`,
2934
+ {
2935
+ method: "POST",
2936
+ signal: g
2937
+ }
2938
+ );
2939
+ for (let L = 0; _.state === "SCANNING"; L += 1) {
2940
+ if (L >= l)
2941
+ throw new Re("CHAT_ATTACHMENT_SCAN_TIMEOUT");
2942
+ await c(s, g), _ = await p(A.id, m, g);
2943
+ }
2944
+ return d(_, {
2945
+ id: A.id,
2946
+ contentType: y,
2947
+ sizeBytes: h.size
2948
+ });
2949
+ } catch (E) {
2950
+ throw T && w({ attachmentId: T, conversationId: m }).catch(() => {
2951
+ }), E;
2952
+ }
2953
+ },
2954
+ async grant({ attachmentId: h, conversationId: m }) {
2955
+ return u(
2956
+ `/chat/attachments/${encodeURIComponent(h)}/grant${Ut(
2957
+ m
2958
+ )}`
2959
+ );
2960
+ },
2961
+ revoke: w
2962
+ };
2963
+ };
2964
+ function Oc({
2965
+ attachment: e,
2966
+ conversationId: t,
2967
+ transport: n,
2968
+ onClose: r
2969
+ }) {
2970
+ const { t: a } = me(), o = e ? Ca(e) : null, [c, s] = F(void 0), [l, u] = F(!1), [w, p] = F(!1), [d, h] = F(!1), m = S(0), g = S(void 0), b = S(void 0), C = U(() => {
2971
+ g.current && URL.revokeObjectURL(g.current), g.current = void 0, s(void 0);
2972
+ }, []), v = U(async () => {
2973
+ if (!e || !o) return;
2974
+ const T = ++m.current;
2975
+ b.current?.abort();
2976
+ const E = new AbortController();
2977
+ b.current = E, C(), u(!1), p(!1), h(!0);
2978
+ try {
2979
+ const A = await Ea(
2980
+ e,
2981
+ t,
2982
+ n
2983
+ ), _ = await ic(
2984
+ A,
2985
+ e,
2986
+ E.signal
2987
+ );
2988
+ if (T !== m.current) {
2989
+ URL.revokeObjectURL(_);
2990
+ return;
2991
+ }
2992
+ g.current = _, s(_);
2993
+ } catch {
2994
+ T === m.current && u(!0);
2995
+ } finally {
2996
+ T === m.current && (h(!1), b.current === E && (b.current = void 0));
2997
+ }
2998
+ }, [e, t, o, C, n]);
2999
+ R(() => {
3000
+ if (!e || !o) {
3001
+ b.current?.abort(), b.current = void 0, C();
3002
+ return;
3003
+ }
3004
+ return v(), () => {
3005
+ m.current += 1, b.current?.abort(), b.current = void 0;
3006
+ };
3007
+ }, [e, v, o, C]), R(
3008
+ () => () => {
3009
+ m.current += 1, b.current?.abort(), g.current && URL.revokeObjectURL(g.current);
3010
+ },
3011
+ []
3012
+ );
3013
+ const y = ue(() => {
3014
+ if (!e) return "";
3015
+ const T = e.size / (1024 * 1024), E = T >= 0.1 ? `${T.toFixed(1)} MB` : `${Math.max(1, Math.round(e.size / 1024))} KB`;
3016
+ return `${e.mediaType} · ${E}`;
3017
+ }, [e]);
3018
+ return /* @__PURE__ */ i(ze, { show: !!e, children: /* @__PURE__ */ N(
3019
+ Ci,
3020
+ {
3021
+ open: !!e,
3022
+ onClose: r,
3023
+ className: "fixed inset-0 z-[70]",
3024
+ children: [
3025
+ /* @__PURE__ */ i(
3026
+ zt,
3027
+ {
3028
+ enter: "duration-200 ease-out",
3029
+ enterFrom: "opacity-0",
3030
+ enterTo: "opacity-100",
3031
+ leave: "duration-150 ease-in",
3032
+ leaveFrom: "opacity-100",
3033
+ leaveTo: "opacity-0",
3034
+ children: /* @__PURE__ */ i(xi, { className: "fixed inset-0 bg-[#05080d]/82 backdrop-blur-md" })
3035
+ }
3036
+ ),
3037
+ /* @__PURE__ */ i("div", { className: "fixed inset-0 flex items-center justify-center p-3 sm:p-6", children: /* @__PURE__ */ i(
3038
+ zt,
3039
+ {
3040
+ enter: "duration-200 ease-out",
3041
+ enterFrom: "translate-y-3 scale-[0.98] opacity-0",
3042
+ enterTo: "translate-y-0 scale-100 opacity-100",
3043
+ leave: "duration-150 ease-in",
3044
+ leaveFrom: "translate-y-0 scale-100 opacity-100",
3045
+ leaveTo: "translate-y-2 scale-[0.98] opacity-0",
3046
+ children: /* @__PURE__ */ N(ha, { className: "flex max-h-[min(82vh,760px)] w-[min(92vw,920px)] flex-col overflow-hidden rounded-2xl border border-white/14 bg-[#0c1119]/96 text-white shadow-[0_30px_90px_rgba(0,0,0,.58),0_0_0_1px_rgba(104,216,255,.05)]", children: [
3047
+ /* @__PURE__ */ N("header", { className: "flex min-h-14 items-center gap-3 border-b border-white/10 px-4 py-3", children: [
3048
+ /* @__PURE__ */ i("div", { className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-xl border border-[#68d8ff]/24 bg-[#68d8ff]/10 text-[#68d8ff]", children: /* @__PURE__ */ i(Dn, { "aria-hidden": "true", className: "h-4.5 w-4.5" }) }),
3049
+ /* @__PURE__ */ N("div", { className: "min-w-0 flex-1", children: [
3050
+ /* @__PURE__ */ i(fa, { className: "truncate text-sm font-semibold", children: e?.fileName ?? "" }),
3051
+ /* @__PURE__ */ i("p", { className: "truncate text-[11px] text-white/50", children: y })
3052
+ ] }),
3053
+ e && /* @__PURE__ */ N(
3054
+ Q,
3055
+ {
3056
+ type: "button",
3057
+ "aria-label": `${a("attachment.download")} ${e.fileName}`,
3058
+ onClick: () => {
3059
+ Na(
3060
+ e,
3061
+ t,
3062
+ n
3063
+ ).catch(() => p(!0));
3064
+ },
3065
+ className: "flex h-9 items-center gap-2 rounded-xl border border-white/12 bg-white/5 px-3 text-xs font-medium text-white/82 transition-colors outline-none data-focus:ring-2 data-focus:ring-[#68d8ff]/65 data-hover:border-[#68d8ff]/42 data-hover:bg-[#68d8ff]/10 data-hover:text-white",
3066
+ children: [
3067
+ /* @__PURE__ */ i(xn, { "aria-hidden": "true", className: "h-4 w-4" }),
3068
+ /* @__PURE__ */ i("span", { className: "hidden sm:inline", children: a("attachment.download") })
3069
+ ]
3070
+ }
3071
+ ),
3072
+ /* @__PURE__ */ i(
3073
+ Q,
3074
+ {
3075
+ type: "button",
3076
+ "aria-label": a("attachment.closePreview"),
3077
+ onClick: r,
3078
+ className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-xl text-white/60 transition-colors outline-none data-focus:ring-2 data-focus:ring-[#68d8ff]/65 data-hover:bg-white/8 data-hover:text-white",
3079
+ children: /* @__PURE__ */ i(ya, { "aria-hidden": "true", className: "h-4.5 w-4.5" })
3080
+ }
3081
+ )
3082
+ ] }),
3083
+ w && /* @__PURE__ */ i(
3084
+ "p",
3085
+ {
3086
+ role: "alert",
3087
+ className: "border-b border-red-200/10 bg-red-300/8 px-4 py-2 text-[11px] text-red-100/88",
3088
+ children: a("attachment.downloadFailed")
3089
+ }
3090
+ ),
3091
+ /* @__PURE__ */ i("div", { className: "relative flex min-h-64 flex-1 items-center justify-center overflow-auto bg-[radial-gradient(circle_at_50%_20%,rgba(104,216,255,.08),transparent_46%),#080c12] p-3 sm:p-5", children: d ? /* @__PURE__ */ N(
3092
+ "div",
3093
+ {
3094
+ role: "status",
3095
+ className: "flex items-center gap-2 text-sm text-white/64",
3096
+ children: [
3097
+ /* @__PURE__ */ i(Vt, { className: "h-4 w-4 animate-spin text-[#68d8ff]" }),
3098
+ a("attachment.loadingPreview")
3099
+ ]
3100
+ }
3101
+ ) : l ? /* @__PURE__ */ N("div", { className: "max-w-sm text-center", children: [
3102
+ /* @__PURE__ */ i(
3103
+ "p",
3104
+ {
3105
+ role: "alert",
3106
+ className: "text-sm font-medium text-white/86",
3107
+ children: a("attachment.previewFailed")
3108
+ }
3109
+ ),
3110
+ /* @__PURE__ */ i(
3111
+ Q,
3112
+ {
3113
+ type: "button",
3114
+ onClick: () => {
3115
+ v();
3116
+ },
3117
+ className: "mt-3 rounded-xl border border-[#68d8ff]/35 bg-[#68d8ff]/10 px-3 py-2 text-xs font-semibold text-[#bcecff] transition-colors data-hover:bg-[#68d8ff]/16",
3118
+ children: a("attachment.retry")
3119
+ }
3120
+ )
3121
+ ] }) : c && o === "image" ? /* @__PURE__ */ i(
3122
+ "img",
3123
+ {
3124
+ src: c,
3125
+ alt: e?.fileName ?? "",
3126
+ className: "max-h-[66vh] max-w-full rounded-xl object-contain shadow-2xl"
3127
+ }
3128
+ ) : c && o === "pdf" ? /* @__PURE__ */ i(
3129
+ "iframe",
3130
+ {
3131
+ src: c,
3132
+ title: e?.fileName ?? a("attachment.pdfPreview"),
3133
+ sandbox: "allow-same-origin",
3134
+ referrerPolicy: "no-referrer",
3135
+ className: "h-[66vh] min-h-96 w-full rounded-xl border border-white/10 bg-white"
3136
+ }
3137
+ ) : null })
3138
+ ] })
3139
+ }
3140
+ ) })
3141
+ ]
3142
+ }
3143
+ ) });
3144
+ }
3145
+ const Ar = [], $c = 220, qt = 8e3, ka = (e) => Math.max(0, Date.now() - e.occurredAt), Fc = (e, t) => t.type === "dismiss" ? { ...e, dismissedKey: t.key } : {
3146
+ trackedKey: t.candidate?.key ?? null,
3147
+ notice: t.candidate ?? e.notice,
3148
+ dismissedKey: t.candidate ? e.dismissedKey : null
3149
+ };
3150
+ function Pc(e) {
3151
+ const [t, n] = Mr(Fc, {
3152
+ trackedKey: e?.key ?? null,
3153
+ notice: e,
3154
+ dismissedKey: null
3155
+ }), r = e?.key ?? null, a = e?.occurredAt;
3156
+ return (t.trackedKey !== r || e && t.notice?.message !== e.message) && n({ type: "sync", candidate: e }), R(() => {
3157
+ if (!r || a === void 0 || t.dismissedKey === r)
3158
+ return;
3159
+ const o = Math.max(0, Date.now() - a), c = qt - o, s = window.setTimeout(
3160
+ () => {
3161
+ n({ type: "dismiss", key: r });
3162
+ },
3163
+ Math.max(0, c)
3164
+ );
3165
+ return () => window.clearTimeout(s);
3166
+ }, [r, a, t.dismissedKey]), {
3167
+ notice: t.notice,
3168
+ visible: !!(e && t.dismissedKey !== e.key && ka(e) < qt)
3169
+ };
3170
+ }
3171
+ const dn = (e, t, n) => typeof e == "number" && Number.isFinite(e) ? Math.min(n, Math.max(1, Math.floor(e))) : t;
3172
+ function Dc({
3173
+ timeline: e,
3174
+ isInitialHistoryLoading: t,
3175
+ isOlderHistoryLoading: n,
3176
+ onPreviewAttachment: r,
3177
+ onDownloadAttachment: a
3178
+ }) {
3179
+ const o = S(!1), c = S(!0);
3180
+ ye(() => {
3181
+ c.current = t || n, t || (o.current = !0);
3182
+ }, [t, n]);
3183
+ const s = U(
3184
+ (l) => {
3185
+ if (!l || !o.current || c.current)
3186
+ return;
3187
+ l.classList.add("chat-support-message-enter");
3188
+ const u = (w) => {
3189
+ w.target !== l || w.animationName !== "chat-support-message-in" || (l.classList.remove("chat-support-message-enter"), l.removeEventListener("animationend", u));
3190
+ };
3191
+ l.addEventListener("animationend", u);
3192
+ },
3193
+ []
3194
+ );
3195
+ return /* @__PURE__ */ i(Ce, { children: e.map(
3196
+ (l) => l.type === "canonical" ? /* @__PURE__ */ i(
3197
+ fc,
3198
+ {
3199
+ ref: l.message.author.role === "ADMIN" ? s : void 0,
3200
+ "data-chat-message-id": l.message.id,
3201
+ message: l.message,
3202
+ onPreviewAttachment: r,
3203
+ onDownloadAttachment: a
3204
+ },
3205
+ l.message.id
3206
+ ) : l.type === "optimistic" ? /* @__PURE__ */ i(
3207
+ wc,
3208
+ {
3209
+ message: l.message,
3210
+ onPreviewAttachment: r,
3211
+ onDownloadAttachment: a
3212
+ },
3213
+ l.message.id
3214
+ ) : /* @__PURE__ */ i(ga, { className: "self-start" }, `cta:${l.commandId}`)
3215
+ ) });
3216
+ }
3217
+ function Uc() {
3218
+ const { direction: e, t } = me(), { open: n, cta: r, ctaAfterMessageId: a, config: o, api: c } = kt(), s = Yt(), { startListening: l } = _n(), u = Ln(), [w, p] = F(() => /* @__PURE__ */ new Map()), d = w.get(u) ?? "", h = U(
3219
+ (f) => {
3220
+ p((x) => {
3221
+ const z = new Map(x);
3222
+ return z.set(u, f), z;
3223
+ });
3224
+ },
3225
+ [u]
3226
+ ), m = U(() => {
3227
+ l(o, c).catch((f) => {
3228
+ console.error("voice init error", f);
3229
+ }), s(ve.voice);
3230
+ }, [c, o, s, l]), [g, b] = F(!1), [C, v] = F(), [y, T] = F(null), [E, A] = F(() => /* @__PURE__ */ new Map()), _ = S(E), L = E.get(u) ?? Ar, I = U(
3231
+ (f, x) => {
3232
+ A((z) => {
3233
+ const O = z.get(f) ?? Ar, Y = typeof x == "function" ? x(O) : x, $ = new Map(z);
3234
+ return $.set(f, Y), _.current = $, $;
3235
+ });
3236
+ },
3237
+ []
3238
+ ), X = U(
3239
+ (f) => I(u, f),
3240
+ [u, I]
3241
+ ), M = S(null), G = S(null), j = S(null), P = S(null), re = S(null), se = S(/* @__PURE__ */ new Set()), B = S(/* @__PURE__ */ new Map()), J = S(/* @__PURE__ */ new Map()), ae = S(/* @__PURE__ */ new Set()), ie = S(/* @__PURE__ */ new Set()), Z = S(/* @__PURE__ */ new Set()), ee = S(0), {
3242
+ cancelThreadMessagesRequest: D,
3243
+ clearSendError: K,
3244
+ fetchOlderThreadMessages: he,
3245
+ sendMessage: Ae,
3246
+ setLatestReadMessageDate: Ie
3247
+ } = kn(), fe = Dr(), ce = Ur(), de = vo(), k = Fr(), Jt = wo(), ct = yo(), Me = bo(), nt = xo(), lt = Co("ASSISTANT"), Rt = Hr(), H = Rn(), le = Br(
3248
+ H,
3249
+ Rt
3250
+ ), [Be, ut] = F(
3251
+ () => !le
3252
+ ), [La, Hn] = F(
3253
+ () => !le
3254
+ ), Ke = To(), ge = Eo(), {
3255
+ networkStatus: dt,
3256
+ networkStatusChangedAt: ht,
3257
+ anycableService: Qt,
3258
+ endUserTypingClient: _e
3259
+ } = Mn(), ke = o.attachments?.enabled !== !1 && H.contractState === "CURRENT" && H.humanSupport === "ASSIGNED", Ye = !!d.trim() ? "send" : le ? null : "voice";
3260
+ ye(() => {
3261
+ if (le) {
3262
+ Hn(!1);
3263
+ const x = window.setTimeout(
3264
+ () => ut(!1),
3265
+ $c
3266
+ );
3267
+ return () => window.clearTimeout(x);
3268
+ }
3269
+ ut(!0);
3270
+ const f = window.requestAnimationFrame(
3271
+ () => Hn(!0)
3272
+ );
3273
+ return () => window.cancelAnimationFrame(f);
3274
+ }, [le]);
3275
+ const rt = dn(
3276
+ o.attachments?.maxFiles,
3277
+ Er,
3278
+ Er
3279
+ ), en = dn(
3280
+ o.attachments?.maxBytes,
3281
+ Tn,
3282
+ Tn
3283
+ ), ft = dn(
3284
+ o.attachments?.maxTotalBytes,
3285
+ Nr,
3286
+ Nr
3287
+ ), Bn = L.reduce(
3288
+ (f, x) => f + x.file.size,
3289
+ 0
3290
+ ), It = ke && !k && L.length < rt && Bn < ft, Oe = ue(
3291
+ () => o.attachments?.transport ?? Ic(o, c),
3292
+ [c, o]
3293
+ ), Vn = S(Oe);
3294
+ Vn.current = Oe;
3295
+ const at = S(!0), jn = !Rt && (!!lt?.active || de), zn = ue(() => {
3296
+ const f = ge.map((x) => ({
3297
+ type: "canonical",
3298
+ message: x
3299
+ }));
3300
+ if (Ke) {
3301
+ const x = Ke.afterMessageId ? ge.findIndex(
3302
+ ({ id: O }) => O === Ke.afterMessageId
3303
+ ) : -1, z = Ke.afterMessageId ? x >= 0 ? x + 1 : f.length : 0;
3304
+ f.splice(z, 0, {
3305
+ type: "optimistic",
3306
+ message: Ke
3307
+ });
3308
+ }
3309
+ if (r) {
3310
+ const x = a ? f.findIndex(
3311
+ (z) => z.type !== "cta" && z.message.id === a
3312
+ ) : -1;
3313
+ f.splice(x + 1, 0, {
3314
+ type: "cta",
3315
+ commandId: r.commandId
3316
+ });
3317
+ }
3318
+ return f;
3319
+ }, [r, a, Ke, ge]), tn = Jt && zn.length === 0, Ra = gc({
3320
+ containerRef: P,
3321
+ contentRef: re,
3322
+ firstMessageId: ge[0]?.id,
3323
+ messageCount: ge.length + +!!Ke + Number(jn) + +!!r + Number(Be),
3324
+ threadId: u
3325
+ }), { captureAnchor: Wn, clearAnchor: Gn } = Ec({
3326
+ containerRef: P,
3327
+ contextId: u,
3328
+ firstItemId: ge[0]?.id,
3329
+ isLoading: Me,
3330
+ itemCount: ge.length
3331
+ }), Ia = U(async () => {
3332
+ if (u) {
3333
+ Wn();
3334
+ try {
3335
+ await he(u);
3336
+ } catch (f) {
3337
+ throw Gn(), f;
3338
+ }
3339
+ }
3340
+ }, [Wn, Gn, u, he]), {
3341
+ error: qn,
3342
+ loadMore: Kn,
3343
+ sentinelRef: Oa
3344
+ } = Sa({
3345
+ rootRef: P,
3346
+ enabled: ct,
3347
+ isLoading: Me,
3348
+ onLoad: Ia,
3349
+ resetKey: u
3350
+ });
3351
+ R(() => {
3352
+ at.current = !0;
3353
+ const f = B.current, x = J.current, z = ae.current, O = ie.current, Y = Z.current;
3354
+ return () => {
3355
+ at.current = !1, j.current !== null && window.clearTimeout(j.current);
3356
+ const $ = Vn.current;
3357
+ if ($.revoke)
3358
+ for (const [W, te] of _.current)
3359
+ for (const q of te)
3360
+ q.state !== "ready" || !q.attachment || O.has(q.id) || Y.has(q.id) || (Y.add(q.id), $.revoke({
3361
+ attachmentId: q.attachment.id,
3362
+ conversationId: W
3363
+ }).catch(() => {
3364
+ }).finally(() => Y.delete(q.id)));
3365
+ f.forEach((W) => W.abort()), x.forEach((W) => URL.revokeObjectURL(W)), f.clear(), x.clear(), z.clear();
3366
+ };
3367
+ }, []), R(
3368
+ () => () => _e?.stop(),
3369
+ [u, _e]
3370
+ ), R(() => {
3371
+ const f = () => {
3372
+ document.visibilityState === "hidden" && _e?.stop();
3373
+ };
3374
+ return document.addEventListener("visibilitychange", f), () => document.removeEventListener("visibilitychange", f);
3375
+ }, [_e]), R(() => {
3376
+ dt !== st.Available && _e?.stop();
3377
+ }, [_e, dt]), R(
3378
+ () => () => {
3379
+ u && D(u);
3380
+ },
3381
+ [D, u]
3382
+ ), R(() => {
3383
+ if (n && ge.length > 0) {
3384
+ const f = ge.findLast(
3385
+ (x) => x.author.type === Te.Customer || x.status === Xe.Completed || x.status === Xe.Failed || x.status === Xe.Cancelled
3386
+ );
3387
+ f && Ie(f.updatedAt);
3388
+ }
3389
+ }, [ge, n, Ie]), R(() => {
3390
+ if (!(!n || !Qt))
3391
+ for (const f of ge)
3392
+ !f.delivery || f.delivery.status === "READ" || se.current.has(f.id) || (se.current.add(f.id), Qt.acknowledgeMessageDelivery({ messageId: f.id, status: "read" }).catch(() => se.current.delete(f.id)));
3393
+ }, [Qt, n, ge]);
3394
+ const nn = fe === $e.connectionFailed && ce !== null && dt === st.Available && ht >= ce;
3395
+ R(() => {
3396
+ nn && K();
3397
+ }, [K, nn]), R(() => {
3398
+ if (!fe || ce === null) return;
3399
+ const f = qt - Math.max(0, Date.now() - ce), x = window.setTimeout(K, Math.max(0, f));
3400
+ return () => window.clearTimeout(x);
3401
+ }, [K, fe, ce]);
3402
+ const mt = [];
3403
+ fe && fe !== $e.openChatFailed && ce !== null && !nn && mt.push({
3404
+ key: `send:${fe}:${ce}`,
3405
+ message: No(fe, t),
3406
+ source: "send",
3407
+ occurredAt: ce
3408
+ });
3409
+ const Ot = ge.findLast(
3410
+ (f) => f.author.type === Te.Agent && f.author.role === "ASSISTANT"
3411
+ );
3412
+ if (!nt && Ot?.status === Xe.Failed) {
3413
+ const f = Date.parse(Ot.updatedAt);
3414
+ Number.isFinite(f) && mt.push({
3415
+ key: `assistant:${Ot.id}:${Ot.updatedAt}`,
3416
+ message: t($e.agentResponseFailed),
3417
+ source: "assistant",
3418
+ occurredAt: f
3419
+ });
3420
+ }
3421
+ dt === st.Unavailable && mt.push({
3422
+ key: `network:unavailable:${ht}`,
3423
+ message: t($e.connectionFailed),
3424
+ source: "network",
3425
+ occurredAt: ht
3426
+ }), dt === st.Offline && mt.push({
3427
+ key: `network:offline:${ht}`,
3428
+ message: t($e.offline),
3429
+ source: "network",
3430
+ occurredAt: ht
3431
+ });
3432
+ const $a = mt.reduce(
3433
+ (f, x) => ka(x) >= qt ? f : !f || x.occurredAt > f.occurredAt ? x : f,
3434
+ null
3435
+ ), rn = Pc($a), Yn = U(
3436
+ (f, x, z) => {
3437
+ B.current.get(x)?.abort();
3438
+ const O = new AbortController();
3439
+ B.current.set(x, O), I(
3440
+ f,
3441
+ (Y) => Y.map(
3442
+ ($) => $.id === x ? { ...$, progress: 0, state: "preparing" } : $
3443
+ )
3444
+ ), Oe.upload({
3445
+ file: z,
3446
+ conversationId: f,
3447
+ signal: O.signal,
3448
+ onStage: (Y) => {
3449
+ B.current.get(x) === O && I(
3450
+ f,
3451
+ ($) => $.map(
3452
+ (W) => W.id === x ? { ...W, state: Y } : W
3453
+ )
3454
+ );
3455
+ },
3456
+ onProgress: (Y) => B.current.get(x) === O ? I(
3457
+ f,
3458
+ ($) => $.map(
3459
+ (W) => W.id === x ? { ...W, progress: Y, state: "uploading" } : W
3460
+ )
3461
+ ) : void 0
3462
+ }).then((Y) => {
3463
+ B.current.get(x) === O && I(
3464
+ f,
3465
+ ($) => $.map(
3466
+ (W) => W.id === x ? { ...W, progress: 1, state: "ready", attachment: Y } : W
3467
+ )
3468
+ );
3469
+ }).catch((Y) => {
3470
+ B.current.get(x) !== O || Y instanceof DOMException && Y.name === "AbortError" || I(
3471
+ f,
3472
+ ($) => $.map(
3473
+ (W) => W.id === x ? { ...W, state: "failed" } : W
3474
+ )
3475
+ );
3476
+ }).finally(() => {
3477
+ B.current.get(x) === O && B.current.delete(x);
3478
+ });
3479
+ },
3480
+ [Oe, I]
3481
+ ), Zn = (f) => {
3482
+ if (k || !ke || !f) return;
3483
+ const x = [];
3484
+ let z = Bn, O;
3485
+ for (const $ of Array.from(f)) {
3486
+ if (L.length + x.length >= rt) {
3487
+ O ??= t("attachment.tooMany", { count: rt });
3488
+ continue;
3489
+ }
3490
+ if ($.size <= 0) {
3491
+ O ??= t("attachment.emptyFile");
3492
+ continue;
3493
+ }
3494
+ if (!_a($.name)) {
3495
+ O ??= t("attachment.invalidFileName");
3496
+ continue;
3497
+ }
3498
+ if (!En($)) {
3499
+ O ??= t("attachment.unsupportedType");
3500
+ continue;
3501
+ }
3502
+ if ($.size > en) {
3503
+ O ??= t("attachment.fileTooLarge", {
3504
+ size: Math.round(en / (1024 * 1024))
3505
+ });
3506
+ continue;
3507
+ }
3508
+ if (z + $.size > ft) {
3509
+ O ??= t("attachment.totalTooLarge", {
3510
+ size: Math.round(ft / (1024 * 1024))
3511
+ });
3512
+ continue;
3513
+ }
3514
+ x.push($), z += $.size;
3515
+ }
3516
+ v(O);
3517
+ const Y = x.map(($) => ({
3518
+ id: crypto.randomUUID(),
3519
+ file: $,
3520
+ progress: 0,
3521
+ state: "preparing"
3522
+ }));
3523
+ Y.length && (Y.forEach(({ id: $, file: W }) => {
3524
+ ae.current.add($);
3525
+ const te = En(W);
3526
+ te?.startsWith("image/") && cc(W, te).then((q) => {
3527
+ if (!ae.current.has($)) {
3528
+ URL.revokeObjectURL(q);
3529
+ return;
3530
+ }
3531
+ J.current.set($, q), I(
3532
+ u,
3533
+ (ot) => ot.map(
3534
+ (an) => an.id === $ ? { ...an, localPreviewUrl: q } : an
3535
+ )
3536
+ );
3537
+ }).catch(() => {
3538
+ });
3539
+ }), X(($) => [...$, ...Y]), Y.forEach(
3540
+ ({ id: $, file: W }) => Yn(u, $, W)
3541
+ ));
3542
+ }, Xn = U(
3543
+ (f, x) => {
3544
+ B.current.get(x)?.abort(), B.current.delete(x), ae.current.delete(x);
3545
+ const z = J.current.get(x);
3546
+ z && URL.revokeObjectURL(z), J.current.delete(x), I(
3547
+ f,
3548
+ (O) => O.filter((Y) => Y.id !== x)
3549
+ );
3550
+ },
3551
+ [I]
3552
+ ), Fa = (f, x) => {
3553
+ if (!(f.state === "removing" || f.state === "sending")) {
3554
+ if (f.state === "ready" && f.attachment && Oe.revoke) {
3555
+ if (Z.current.has(f.id)) return;
3556
+ Z.current.add(f.id), v(void 0), I(
3557
+ x,
3558
+ (z) => z.map(
3559
+ (O) => O.id === f.id ? { ...O, state: "removing" } : O
3560
+ )
3561
+ ), (async () => {
3562
+ try {
3563
+ await Oe.revoke?.({
3564
+ attachmentId: f.attachment.id,
3565
+ conversationId: x
3566
+ }), at.current && Xn(x, f.id);
3567
+ } catch {
3568
+ at.current && (I(
3569
+ x,
3570
+ (z) => z.map(
3571
+ (O) => O.id === f.id && O.state === "removing" ? { ...O, state: "ready" } : O
3572
+ )
3573
+ ), v(t("attachment.revokeFailed")));
3574
+ } finally {
3575
+ Z.current.delete(f.id);
3576
+ }
3577
+ })();
3578
+ return;
3579
+ }
3580
+ Xn(x, f.id);
3581
+ }
3582
+ }, $t = (f) => Array.from(f.dataTransfer.types).includes("Files"), Pa = (f) => {
3583
+ if ($t(f)) {
3584
+ if (f.preventDefault(), !It) {
3585
+ f.dataTransfer.dropEffect = "none";
3586
+ return;
3587
+ }
3588
+ ee.current += 1, b(!0);
3589
+ }
3590
+ }, Da = (f) => {
3591
+ !$t(f) && !g || (f.preventDefault(), f.dataTransfer.dropEffect = It ? "copy" : "none");
3592
+ }, Ua = (f) => {
3593
+ !$t(f) && !g || (f.preventDefault(), ee.current = Math.max(0, ee.current - 1), ee.current === 0 && b(!1));
3594
+ }, Ha = (f) => {
3595
+ !$t(f) && !g || (f.preventDefault(), ee.current = 0, b(!1), !(k || !ke) && (It ? Zn(f.dataTransfer.files) : L.length >= rt ? v(t("attachment.tooMany", { count: rt })) : v(
3596
+ t("attachment.totalTooLarge", {
3597
+ size: Math.round(ft / (1024 * 1024))
3598
+ })
3599
+ )));
3600
+ }, Jn = () => {
3601
+ const f = u, x = d.trim(), z = L.flatMap(
3602
+ ({ attachment: te, state: q }) => q === "ready" && te ? [te] : []
3603
+ );
3604
+ if (k || !x || nt || !ke && L.length > 0 || L.some(({ state: te }) => te !== "ready"))
3605
+ return;
3606
+ _e?.stop(), j.current !== null && (window.clearTimeout(j.current), j.current = null), h(""), M.current && (M.current.style.height = "auto");
3607
+ const O = L.map(({ id: te }) => te), Y = new Set(O);
3608
+ O.forEach(
3609
+ (te) => ie.current.add(te)
3610
+ ), O.length > 0 && I(
3611
+ f,
3612
+ (te) => te.map(
3613
+ (q) => Y.has(q.id) ? { ...q, state: "sending" } : q
3614
+ )
3615
+ );
3616
+ const $ = () => {
3617
+ O.forEach(
3618
+ (te) => ie.current.delete(te)
3619
+ ), at.current && I(
3620
+ f,
3621
+ (te) => te.map(
3622
+ (q) => Y.has(q.id) && q.state === "sending" ? { ...q, state: "ready" } : q
3623
+ )
3624
+ );
3625
+ };
3626
+ let W;
3627
+ try {
3628
+ W = z.length ? Ae(x, z) : Ae(x);
3629
+ } catch {
3630
+ h(x), $();
3631
+ return;
3632
+ }
3633
+ W.then((te) => {
3634
+ if (!te) {
3635
+ $();
3636
+ return;
3637
+ }
3638
+ O.forEach((q) => {
3639
+ ae.current.delete(q);
3640
+ const ot = J.current.get(q);
3641
+ ot && URL.revokeObjectURL(ot), J.current.delete(q);
3642
+ }), at.current && I(
3643
+ f,
3644
+ (q) => q.filter((ot) => !Y.has(ot.id))
3645
+ );
3646
+ }).catch($);
3647
+ }, Ba = U(
3648
+ (f, x) => T({ attachment: f, conversationId: x }),
3649
+ []
3650
+ ), Va = U(
3651
+ (f, x) => {
3652
+ Na(
3653
+ f,
3654
+ x,
3655
+ Oe
3656
+ ).catch(() => v(t("attachment.downloadFailed")));
3657
+ },
3658
+ [Oe, t]
3659
+ );
3660
+ return /* @__PURE__ */ N(
3661
+ "div",
3662
+ {
3663
+ "aria-busy": k,
3664
+ onDragEnter: Pa,
3665
+ onDragOver: Da,
3666
+ onDragLeave: Ua,
3667
+ onDrop: Ha,
3668
+ className: "relative z-1 flex min-h-0 flex-1 flex-col overflow-hidden px-3 pb-2",
3669
+ children: [
3670
+ /* @__PURE__ */ i(
3671
+ ze,
3672
+ {
3673
+ show: Me,
3674
+ enter: "transition-opacity duration-[120ms] ease-[var(--chat-ease-out)] motion-reduce:duration-75",
3675
+ enterFrom: "opacity-0",
3676
+ enterTo: "opacity-100",
3677
+ leave: "transition-opacity duration-100 ease-[var(--chat-ease-out)] motion-reduce:duration-75",
3678
+ leaveFrom: "opacity-100",
3679
+ leaveTo: "opacity-0",
3680
+ children: /* @__PURE__ */ i("div", { className: "pointer-events-none absolute top-2 right-0 left-0 z-20 flex justify-center px-4", children: /* @__PURE__ */ i(Tc, {}) })
3681
+ }
3682
+ ),
3683
+ /* @__PURE__ */ i(
3684
+ ze,
3685
+ {
3686
+ show: !!qn,
3687
+ enter: "transition-opacity duration-[120ms] ease-[var(--chat-ease-out)] motion-reduce:duration-75",
3688
+ enterFrom: "opacity-0",
3689
+ enterTo: "opacity-100",
3690
+ leave: "transition-opacity duration-100 ease-[var(--chat-ease-out)] motion-reduce:duration-75",
3691
+ leaveFrom: "opacity-100",
3692
+ leaveTo: "opacity-0",
3693
+ children: /* @__PURE__ */ i(
3694
+ "div",
3695
+ {
3696
+ role: "alert",
3697
+ className: "pointer-events-none absolute top-2 right-0 left-0 z-20 flex justify-center px-4",
3698
+ children: /* @__PURE__ */ N(
3699
+ Q,
3700
+ {
3701
+ type: "button",
3702
+ onClick: () => {
3703
+ Kn();
3704
+ },
3705
+ className: "pointer-events-auto flex max-w-full items-center gap-2 rounded-full border border-white/[0.08] bg-[#161616]/92 px-3 py-2 text-[11px] leading-4 font-medium text-white/68 shadow-[0_8px_24px_rgb(0_0_0/0.26)] backdrop-blur-md transition-colors hover:border-[var(--chat-action-primary)]/30 hover:text-white/90",
3706
+ children: [
3707
+ /* @__PURE__ */ i(br, { "aria-hidden": "true", className: "h-3.5 w-3.5 shrink-0" }),
3708
+ /* @__PURE__ */ i("span", { className: "truncate", children: t("chat.previousLoadFailed") }),
3709
+ /* @__PURE__ */ i("span", { className: "shrink-0 text-[var(--chat-action-primary)]", children: t("chat.retryPreviousMessages") })
3710
+ ]
3711
+ }
3712
+ )
3713
+ }
3714
+ )
3715
+ }
3716
+ ),
3717
+ ke && g && /* @__PURE__ */ i("div", { className: "chat-attachment-dropzone", "aria-hidden": "true", children: /* @__PURE__ */ N("div", { className: "chat-attachment-dropzone__content", children: [
3718
+ /* @__PURE__ */ i(yr, { className: "h-5 w-5" }),
3719
+ /* @__PURE__ */ i("span", { children: t("attachment.dropFiles") }),
3720
+ /* @__PURE__ */ i("small", { children: t("attachment.limits", {
3721
+ count: rt,
3722
+ size: Math.round(en / (1024 * 1024)),
3723
+ total: Math.round(ft / (1024 * 1024))
3724
+ }) })
3725
+ ] }) }),
3726
+ /* @__PURE__ */ N(
3727
+ "div",
3728
+ {
3729
+ ref: P,
3730
+ onScroll: Ra,
3731
+ "data-message-veil": Be ? La ? "on" : "revealing" : "off",
3732
+ className: "chat-message-viewport chat-scrollbar flex h-0 min-h-0 flex-1 flex-col overflow-y-auto px-1 [overflow-anchor:none]",
3733
+ children: [
3734
+ /* @__PURE__ */ i("div", { className: "chat-message-veil-spacer", "aria-hidden": "true" }),
3735
+ /* @__PURE__ */ N(
3736
+ "div",
3737
+ {
3738
+ ref: re,
3739
+ "aria-busy": tn || Me,
3740
+ className: "chat-timeline relative z-1 flex min-h-full shrink-0 flex-col justify-end gap-2 pt-3 pb-3",
3741
+ children: [
3742
+ (ct || Me) && /* @__PURE__ */ N("div", { className: "relative flex h-7 shrink-0 items-center justify-center", children: [
3743
+ /* @__PURE__ */ i(
3744
+ "div",
3745
+ {
3746
+ ref: Oa,
3747
+ "aria-hidden": "true",
3748
+ className: "absolute top-0 h-px w-full"
3749
+ }
3750
+ ),
3751
+ !Me && !qn && /* @__PURE__ */ i(
3752
+ Q,
3753
+ {
3754
+ type: "button",
3755
+ "aria-label": t("chat.loadPreviousMessages"),
3756
+ onClick: () => {
3757
+ Kn();
3758
+ },
3759
+ className: "rounded-full border border-white/10 bg-black/20 px-3 py-1 text-[11px] text-white/65 transition-colors hover:border-[#68d8ff]/30 hover:text-white/90",
3760
+ children: t("chat.loadPreviousMessages")
3761
+ }
3762
+ )
3763
+ ] }),
3764
+ /* @__PURE__ */ N("div", { className: "relative w-full", children: [
3765
+ /* @__PURE__ */ i(
3766
+ ze,
3767
+ {
3768
+ show: tn,
3769
+ enter: "transition-[opacity,transform] duration-[220ms] ease-out motion-reduce:transition-none",
3770
+ enterFrom: "translate-y-1.5 opacity-0 motion-reduce:translate-y-0",
3771
+ enterTo: "translate-y-0 opacity-100",
3772
+ leave: "transition-[opacity,transform] duration-[180ms] ease-in motion-reduce:transition-none",
3773
+ leaveFrom: "translate-y-0 opacity-100",
3774
+ leaveTo: "-translate-y-1 opacity-0 motion-reduce:translate-y-0",
3775
+ children: /* @__PURE__ */ i("div", { className: "pointer-events-none absolute right-0 bottom-0 left-0", children: /* @__PURE__ */ i(bc, {}) })
3776
+ }
3777
+ ),
3778
+ /* @__PURE__ */ i(
3779
+ ze,
3780
+ {
3781
+ show: !tn,
3782
+ enter: "transition-[opacity,transform] delay-75 duration-[220ms] ease-out motion-reduce:transition-none motion-reduce:delay-0",
3783
+ enterFrom: "translate-y-2 opacity-0 motion-reduce:translate-y-0",
3784
+ enterTo: "translate-y-0 opacity-100",
3785
+ leave: "transition-opacity duration-100 ease-out motion-reduce:transition-none",
3786
+ leaveFrom: "opacity-100",
3787
+ leaveTo: "opacity-0",
3788
+ children: /* @__PURE__ */ i("div", { className: "flex w-full flex-col gap-2", children: /* @__PURE__ */ i(
3789
+ Dc,
3790
+ {
3791
+ timeline: zn,
3792
+ isInitialHistoryLoading: Jt,
3793
+ isOlderHistoryLoading: Me,
3794
+ onPreviewAttachment: Ba,
3795
+ onDownloadAttachment: Va
3796
+ },
3797
+ u ?? "new-conversation"
3798
+ ) })
3799
+ }
3800
+ )
3801
+ ] }),
3802
+ jn && /* @__PURE__ */ i(
3803
+ vc,
3804
+ {
3805
+ label: lt?.active ? "Lola is typing" : void 0
3806
+ }
3807
+ ),
3808
+ /* @__PURE__ */ i(
3809
+ ze,
3810
+ {
3811
+ show: rn.visible,
3812
+ enter: "transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-opacity motion-reduce:duration-100",
3813
+ enterFrom: "translate-y-1.5 opacity-0 motion-reduce:translate-y-0",
3814
+ enterTo: "translate-y-0 opacity-100",
3815
+ leave: "transition-[opacity,transform] duration-150 ease-out motion-reduce:transition-opacity motion-reduce:duration-100",
3816
+ leaveFrom: "translate-y-0 opacity-100",
3817
+ leaveTo: "translate-y-1 opacity-0 motion-reduce:translate-y-0",
3818
+ children: /* @__PURE__ */ i(
3819
+ ma,
3820
+ {
3821
+ role: "status",
3822
+ "aria-live": "polite",
3823
+ message: rn.notice?.message ?? "",
3824
+ className: "mt-2"
3825
+ }
3826
+ )
3827
+ },
3828
+ rn.notice?.key ?? "no-chat-error"
3829
+ )
3830
+ ]
3831
+ }
3832
+ )
3833
+ ]
3834
+ }
3835
+ ),
3836
+ L.length > 0 && /* @__PURE__ */ i(
3837
+ "div",
3838
+ {
3839
+ className: "chat-composer-attachments",
3840
+ "aria-label": t("attachment.filesToSend"),
3841
+ "aria-live": "polite",
3842
+ children: L.map((f) => /* @__PURE__ */ N("div", { className: "chat-composer-attachment", children: [
3843
+ /* @__PURE__ */ i("div", { className: "chat-composer-attachment__preview", children: f.localPreviewUrl ? /* @__PURE__ */ i("img", { src: f.localPreviewUrl, alt: "" }) : /* @__PURE__ */ i(Dn, { "aria-hidden": "true", className: "h-4 w-4" }) }),
3844
+ /* @__PURE__ */ N("div", { className: "min-w-0 flex-1", children: [
3845
+ /* @__PURE__ */ i("p", { className: "truncate text-[11px] font-semibold text-white/88", children: f.file.name }),
3846
+ /* @__PURE__ */ i("div", { className: "mt-0.5 flex items-center gap-1.5 text-[10px]", children: f.state === "preparing" ? /* @__PURE__ */ N(Ce, { children: [
3847
+ /* @__PURE__ */ i(Vt, { className: "h-3 w-3 animate-spin text-[#68d8ff]" }),
3848
+ /* @__PURE__ */ i("span", { className: "text-white/52", children: t("attachment.preparing") })
3849
+ ] }) : f.state === "uploading" ? /* @__PURE__ */ N(Ce, { children: [
3850
+ /* @__PURE__ */ i("span", { className: "text-[#a9eaff]", children: t("attachment.uploading") }),
3851
+ /* @__PURE__ */ N("span", { className: "text-white/44 tabular-nums", children: [
3852
+ Math.round(f.progress * 100),
3853
+ "%"
3854
+ ] })
3855
+ ] }) : f.state === "scanning" ? /* @__PURE__ */ N(Ce, { children: [
3856
+ /* @__PURE__ */ i(xr, { className: "h-3 w-3 animate-pulse text-amber-200" }),
3857
+ /* @__PURE__ */ i("span", { className: "text-amber-100/74", children: t("attachment.scanning") })
3858
+ ] }) : f.state === "ready" ? /* @__PURE__ */ N(Ce, { children: [
3859
+ /* @__PURE__ */ i(Ui, { className: "h-3 w-3 text-[#8df0c8]" }),
3860
+ /* @__PURE__ */ i("span", { className: "text-[#a6ebce]", children: t("attachment.ready") }),
3861
+ /* @__PURE__ */ i("span", { className: "text-white/38", children: xa(f.file.size) })
3862
+ ] }) : f.state === "removing" ? /* @__PURE__ */ N(Ce, { children: [
3863
+ /* @__PURE__ */ i(Vt, { className: "h-3 w-3 animate-spin text-[#68d8ff]" }),
3864
+ /* @__PURE__ */ i("span", { className: "text-[#a9eaff]", children: t("attachment.removing") })
3865
+ ] }) : f.state === "sending" ? /* @__PURE__ */ N(Ce, { children: [
3866
+ /* @__PURE__ */ i(xr, { className: "h-3 w-3 animate-pulse text-[#8df0c8]" }),
3867
+ /* @__PURE__ */ i("span", { className: "text-[#a6ebce]", children: t("attachment.sending") })
3868
+ ] }) : /* @__PURE__ */ N(Ce, { children: [
3869
+ /* @__PURE__ */ i(Gi, { className: "h-3 w-3 text-red-200" }),
3870
+ /* @__PURE__ */ i("span", { className: "text-red-100/80", children: t("attachment.uploadFailed") })
3871
+ ] }) }),
3872
+ (f.state === "uploading" || f.state === "scanning") && /* @__PURE__ */ i("div", { className: "chat-composer-attachment__progress", children: /* @__PURE__ */ i(
3873
+ "span",
3874
+ {
3875
+ className: f.state === "scanning" ? "is-scanning" : "",
3876
+ style: f.state === "uploading" ? { width: `${Math.max(4, f.progress * 100)}%` } : void 0
3877
+ }
3878
+ ) })
3879
+ ] }),
3880
+ f.state === "failed" && ke && /* @__PURE__ */ i(
3881
+ Q,
3882
+ {
3883
+ type: "button",
3884
+ "aria-label": `${t("attachment.retry")} ${f.file.name}`,
3885
+ onClick: () => Yn(
3886
+ u,
3887
+ f.id,
3888
+ f.file
3889
+ ),
3890
+ className: "chat-composer-attachment__action text-[#68d8ff]",
3891
+ children: /* @__PURE__ */ i(br, { "aria-hidden": "true", className: "h-3.5 w-3.5" })
3892
+ }
3893
+ ),
3894
+ /* @__PURE__ */ i(
3895
+ Q,
3896
+ {
3897
+ type: "button",
3898
+ "aria-label": `${t("attachment.remove")} ${f.file.name}`,
3899
+ "aria-busy": f.state === "removing",
3900
+ disabled: f.state === "removing" || f.state === "sending",
3901
+ onClick: () => Fa(f, u),
3902
+ className: "chat-composer-attachment__action text-white/58",
3903
+ children: f.state === "removing" ? /* @__PURE__ */ i(
3904
+ Vt,
3905
+ {
3906
+ "aria-hidden": "true",
3907
+ className: "h-3.5 w-3.5 animate-spin"
3908
+ }
3909
+ ) : /* @__PURE__ */ i(ya, { "aria-hidden": "true", className: "h-3.5 w-3.5" })
3910
+ }
3911
+ )
3912
+ ] }, f.id))
3913
+ }
3914
+ ),
3915
+ C && /* @__PURE__ */ i(
3916
+ "p",
3917
+ {
3918
+ role: "alert",
3919
+ className: "px-2 pb-1 text-[10px] leading-4 text-amber-100/86",
3920
+ children: C
3921
+ }
3922
+ ),
3923
+ ke && L.some(({ state: f }) => f === "ready") && !d.trim() && /* @__PURE__ */ i("p", { className: "px-2 pb-1 text-[10px] leading-4 text-white/48", children: t("attachment.messageRequired") }),
3924
+ !ke && L.length > 0 && /* @__PURE__ */ i(
3925
+ "p",
3926
+ {
3927
+ role: "status",
3928
+ className: "px-2 pb-1 text-[10px] leading-4 text-white/48",
3929
+ children: t("attachment.disabled")
3930
+ }
3931
+ ),
3932
+ /* @__PURE__ */ N("div", { className: "chat-composer flex shrink-0 flex-row items-end", children: [
3933
+ /* @__PURE__ */ i("div", { className: "chat-composer__input flex min-w-0 flex-1 items-end", children: /* @__PURE__ */ i(
3934
+ Ni,
3935
+ {
3936
+ ref: M,
3937
+ value: d,
3938
+ rows: 1,
3939
+ disabled: k,
3940
+ "aria-label": t("chat.messageLabel"),
3941
+ "data-chat-route-focus": !0,
3942
+ placeholder: t("chat.messagePlaceholder"),
3943
+ onBlur: () => _e?.stop(),
3944
+ onChange: (f) => {
3945
+ const x = f.target.value;
3946
+ h(x), u && x.trim() ? _e?.markActivity(u) : _e?.stop();
3947
+ },
3948
+ onInput: (f) => {
3949
+ const x = f.currentTarget;
3950
+ j.current !== null && window.clearTimeout(j.current), j.current = null;
3951
+ const z = x.clientHeight + "px";
3952
+ x.style.height = "auto";
3953
+ const O = Math.min(x.scrollHeight, 160) + "px";
3954
+ x.style.height = z, z !== O && (j.current = window.setTimeout(() => {
3955
+ x.style.height = O, j.current = null;
3956
+ }));
3957
+ },
3958
+ onKeyDown: (f) => {
3959
+ f.key === "Enter" && !f.nativeEvent.isComposing && (f.preventDefault(), Jn());
3960
+ },
3961
+ className: "no-scrollbar block h-[38px] min-h-[38px] w-full resize-none overflow-y-auto border-none bg-transparent px-4 py-[9px] text-[16px] leading-5 font-normal text-white outline-none placeholder:text-[14px] placeholder:text-[#858585]"
3962
+ }
3963
+ ) }),
3964
+ /* @__PURE__ */ N("div", { className: "chat-composer__actions flex shrink-0 items-center", children: [
3965
+ ke && /* @__PURE__ */ N(Ce, { children: [
3966
+ /* @__PURE__ */ i(
3967
+ "input",
3968
+ {
3969
+ ref: G,
3970
+ type: "file",
3971
+ multiple: !0,
3972
+ accept: Nc,
3973
+ className: "sr-only",
3974
+ onChange: (f) => {
3975
+ Zn(f.currentTarget.files), f.currentTarget.value = "";
3976
+ }
3977
+ }
3978
+ ),
3979
+ /* @__PURE__ */ i(
3980
+ Q,
3981
+ {
3982
+ type: "button",
3983
+ "aria-label": t("attachment.attachFiles"),
3984
+ disabled: !It,
3985
+ onClick: () => G.current?.click(),
3986
+ className: "chat-attach-button chat-composer-action",
3987
+ children: /* @__PURE__ */ i(yr, { "aria-hidden": "true", className: "h-5 w-5" })
3988
+ }
3989
+ )
3990
+ ] }),
3991
+ Ye && /* @__PURE__ */ N(
3992
+ Q,
3993
+ {
3994
+ type: "button",
3995
+ "aria-label": t(Ye === "send" ? "chat.send" : "chat.switchToVoice"),
3996
+ "data-mode": Ye,
3997
+ disabled: k || Ye === "send" && (nt || !ke && L.length > 0 || L.some(({ state: f }) => f !== "ready")),
3998
+ className: "chat-composer-action chat-composer-primary-action",
3999
+ onClick: () => {
4000
+ Ye === "send" ? Jn() : m();
4001
+ },
4002
+ children: [
4003
+ /* @__PURE__ */ i(
4004
+ "span",
4005
+ {
4006
+ "aria-hidden": "true",
4007
+ className: "chat-composer-primary-action__icon",
4008
+ "data-active": Ye === "voice",
4009
+ "data-icon": "voice",
4010
+ children: /* @__PURE__ */ i(Li, { className: "h-[19px] w-[21px]" })
4011
+ }
4012
+ ),
4013
+ /* @__PURE__ */ i(
4014
+ "span",
4015
+ {
4016
+ "aria-hidden": "true",
4017
+ className: "chat-composer-primary-action__icon",
4018
+ "data-active": Ye === "send",
4019
+ "data-icon": "send",
4020
+ children: /* @__PURE__ */ i(
4021
+ Ri,
4022
+ {
4023
+ className: ne(
4024
+ "h-6 w-6",
4025
+ e === "rtl" && "-scale-x-100"
4026
+ )
4027
+ }
4028
+ )
4029
+ }
4030
+ )
4031
+ ]
4032
+ }
4033
+ )
4034
+ ] })
4035
+ ] }),
4036
+ /* @__PURE__ */ i(
4037
+ Oc,
4038
+ {
4039
+ attachment: y?.attachment ?? null,
4040
+ conversationId: y?.conversationId,
4041
+ transport: Oe,
4042
+ onClose: () => T(null)
4043
+ }
4044
+ )
4045
+ ]
4046
+ }
4047
+ );
4048
+ }
4049
+ const Hc = (e) => /* @__PURE__ */ we.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M17.5999 6.3999L13.8666 10.1332M16.9777 10.1332L13.8666 10.1332V7.02212M7.02212 13.8666H10.1332L10.1332 16.9777M10.1332 13.8666L6.3999 17.5999", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round" }));
4050
+ function Bc({
4051
+ conversationId: e,
4052
+ presentation: t
4053
+ }) {
4054
+ const { t: n } = me(), r = t.contractState === "CURRENT" && t.humanSupport === "ROUTING", a = t.identity === "SUPPORT" && t.displayName === "Support" && t.avatarAsset === null && t.presentationVersion === null, o = (r || a ? null : t.displayName) ?? (t.identity === "LOLA" ? "Lola" : n("identity.support")), c = n("identity.online"), s = r ? "SUPPORT" : t.identity === "LOLA" ? "LOLA" : t.avatarAsset ? "HUMAN" : "SUPPORT", l = t.contractState === "CURRENT" && !r ? t : null;
4055
+ return /* @__PURE__ */ N(
4056
+ "div",
4057
+ {
4058
+ "data-contract-state": t.contractState.toLowerCase(),
4059
+ "data-human-support": t.humanSupport.toLowerCase(),
4060
+ "data-ai": t.ai.toLowerCase(),
4061
+ className: "chat-responder-identity flex w-full max-w-none min-w-0 items-center gap-3 bg-transparent py-0 ps-0 pe-0 shadow-none",
4062
+ children: [
4063
+ /* @__PURE__ */ i(
4064
+ Un,
4065
+ {
4066
+ conversationId: e,
4067
+ displayName: o,
4068
+ fallbackKind: s,
4069
+ presentation: l,
4070
+ size: "header",
4071
+ className: "chat-responder-avatar h-10 w-10 text-[13px]"
4072
+ }
4073
+ ),
4074
+ /* @__PURE__ */ N("span", { className: "flex min-w-0 flex-col gap-1 text-start", children: [
4075
+ /* @__PURE__ */ N("strong", { className: "chat-responder-name flex min-w-0 items-center gap-1.5 text-[16px] leading-4 font-bold text-white", children: [
4076
+ /* @__PURE__ */ i("span", { className: "truncate", children: o }),
4077
+ t.humanSupport === "ASSIGNED" ? /* @__PURE__ */ i(
4078
+ "span",
4079
+ {
4080
+ "data-support-badge": !0,
4081
+ role: "img",
4082
+ "aria-label": n("identity.operator"),
4083
+ className: "inline-flex shrink-0",
4084
+ children: /* @__PURE__ */ i(
4085
+ wa,
4086
+ {
4087
+ "aria-hidden": "true",
4088
+ className: "h-4 w-4 text-white/78",
4089
+ strokeWidth: 2.2
4090
+ }
4091
+ )
4092
+ }
4093
+ ) : null
4094
+ ] }),
4095
+ /* @__PURE__ */ i("small", { className: "chat-responder-status flex min-w-0 items-center text-[11px] leading-[13px] font-normal text-[#8b889b]", children: /* @__PURE__ */ N(
4096
+ "span",
4097
+ {
4098
+ "data-human-support-status": !0,
4099
+ className: "flex max-w-full items-center gap-1",
4100
+ children: [
4101
+ /* @__PURE__ */ i(
4102
+ "span",
4103
+ {
4104
+ "aria-hidden": "true",
4105
+ className: "h-2 w-2 shrink-0 rounded-full bg-[#8fff37] shadow-[0_0_10px_rgba(143,255,55,0.32)]"
4106
+ }
4107
+ ),
4108
+ /* @__PURE__ */ i("span", { className: "truncate", children: c })
4109
+ ]
4110
+ }
4111
+ ) })
4112
+ ] }),
4113
+ /* @__PURE__ */ N(
4114
+ "span",
4115
+ {
4116
+ role: "status",
4117
+ "aria-live": "polite",
4118
+ "aria-atomic": "true",
4119
+ className: "sr-only",
4120
+ children: [
4121
+ o,
4122
+ ". ",
4123
+ c
4124
+ ]
4125
+ },
4126
+ `${t.humanSupport}:${t.ai}:${o}`
4127
+ )
4128
+ ]
4129
+ }
4130
+ );
4131
+ }
4132
+ const Vc = 200, hn = (e) => ({
4133
+ contractState: e.contractState,
4134
+ humanSupport: e.humanSupport,
4135
+ ai: e.ai,
4136
+ identity: e.identity,
4137
+ displayName: e.displayName,
4138
+ avatarAsset: e.avatarAsset,
4139
+ presentationVersion: e.presentationVersion
4140
+ }), jc = (e, t) => e.contractState === "CURRENT" && e.humanSupport === "NONE" && t.contractState === "CURRENT" && t.humanSupport === "ROUTING", zc = (e, t) => ({
4141
+ ...t,
4142
+ humanSupport: e.humanSupport,
4143
+ identity: e.identity,
4144
+ displayName: e.displayName,
4145
+ avatarAsset: e.avatarAsset,
4146
+ presentationVersion: e.presentationVersion
4147
+ });
4148
+ function Wc(e, t) {
4149
+ const n = {
4150
+ conversationId: e,
4151
+ presentation: hn(t)
4152
+ }, r = S(n), a = S(n), [o, c] = F(n), s = S(null), l = () => {
4153
+ s.current !== null && (window.clearTimeout(s.current), s.current = null);
4154
+ };
4155
+ return ye(() => {
4156
+ const u = hn(t);
4157
+ r.current = { conversationId: e, presentation: u };
4158
+ const w = a.current, p = r.current;
4159
+ if (w.conversationId !== p.conversationId) {
4160
+ l(), a.current = p, c(p);
4161
+ return;
4162
+ }
4163
+ if (jc(w.presentation, p.presentation)) {
4164
+ const d = {
4165
+ ...p,
4166
+ presentation: zc(
4167
+ w.presentation,
4168
+ p.presentation
4169
+ )
4170
+ };
4171
+ a.current = d, c(d), s.current === null && (s.current = window.setTimeout(() => {
4172
+ s.current = null;
4173
+ const h = r.current;
4174
+ h.conversationId !== w.conversationId || h.presentation.contractState !== "CURRENT" || h.presentation.humanSupport !== "ROUTING" || (a.current = h, c(h));
4175
+ }, Vc));
4176
+ return;
4177
+ }
4178
+ l(), a.current = p, c(p);
4179
+ }, [e, t]), R(() => () => l(), []), o.conversationId === e ? o.presentation : hn(t);
4180
+ }
4181
+ function Gc({
4182
+ identity: e,
4183
+ actions: t,
4184
+ draggable: n = !1,
4185
+ dragLabel: r
4186
+ }) {
4187
+ return /* @__PURE__ */ N(
4188
+ "div",
4189
+ {
4190
+ className: ne(
4191
+ "chat-top-controls__bar relative flex h-14 items-center gap-2 overflow-hidden border-b border-[#161616] bg-[#111111] px-4",
4192
+ n && "cursor-grab touch-none select-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-[#68d8ff] active:cursor-grabbing"
4193
+ ),
4194
+ "data-lola-drag-handle": n || void 0,
4195
+ role: n ? "group" : void 0,
4196
+ "aria-label": n ? r : void 0,
4197
+ tabIndex: n ? 0 : void 0,
4198
+ children: [
4199
+ /* @__PURE__ */ i("div", { className: "min-w-0 flex-1", children: e }),
4200
+ /* @__PURE__ */ i(
4201
+ "div",
4202
+ {
4203
+ "data-controls": "right",
4204
+ "data-lola-drag-exclude": !0,
4205
+ className: "flex shrink-0 items-center gap-2",
4206
+ children: t
4207
+ }
4208
+ )
4209
+ ]
4210
+ }
4211
+ );
4212
+ }
4213
+ function qc({
4214
+ className: e,
4215
+ ...t
4216
+ }) {
4217
+ const { closeAssistant: n, minimizeAssistant: r } = kt(), a = Ao(), { t: o } = me(), c = Yt(), s = In(), l = So(s.pathname), { endVoiceChat: u } = _n(), w = Bt(s.pathname), p = Ln(), d = Rn(), h = Wc(
4218
+ p,
4219
+ d
4220
+ ), m = () => {
4221
+ w && u();
4222
+ }, g = () => {
4223
+ r({
4224
+ actor: "USER",
4225
+ reason: "USER_CLOSE_BUTTON"
4226
+ });
4227
+ }, b = () => {
4228
+ n({
4229
+ actor: "USER",
4230
+ reason: "USER_CLOSE_BUTTON"
4231
+ });
4232
+ }, C = () => {
4233
+ c(ve.list, {
4234
+ state: { chatMode: l }
4235
+ }), m();
4236
+ };
4237
+ return /* @__PURE__ */ i(
4238
+ "div",
4239
+ {
4240
+ ...t,
4241
+ className: ne("chat-top-controls relative z-10", e),
4242
+ children: /* @__PURE__ */ i(
4243
+ Gc,
4244
+ {
4245
+ draggable: a.presentation === "windowed",
4246
+ dragLabel: o("controls.move"),
4247
+ identity: /* @__PURE__ */ i(
4248
+ Bc,
4249
+ {
4250
+ conversationId: p ?? "lola-default",
4251
+ presentation: h
4252
+ }
4253
+ ),
4254
+ actions: /* @__PURE__ */ N(Ce, { children: [
4255
+ /* @__PURE__ */ i(
4256
+ Q,
4257
+ {
4258
+ onClick: C,
4259
+ "aria-label": o("controls.openChatList"),
4260
+ "data-lola-drag-exclude": !0,
4261
+ className: "chat-icon-button",
4262
+ children: /* @__PURE__ */ i(Bi, { "aria-hidden": "true", className: "h-5 w-5", strokeWidth: 2 })
4263
+ }
4264
+ ),
4265
+ /* @__PURE__ */ i(
4266
+ Q,
4267
+ {
4268
+ type: "button",
4269
+ "aria-label": o("controls.collapse"),
4270
+ "data-lola-drag-exclude": !0,
4271
+ className: "chat-icon-button",
4272
+ onClick: g,
4273
+ children: /* @__PURE__ */ i(Hc, { "aria-hidden": "true", className: "h-5 w-5" })
4274
+ }
4275
+ ),
4276
+ /* @__PURE__ */ i(
4277
+ Q,
4278
+ {
4279
+ type: "button",
4280
+ "aria-label": o("controls.close"),
4281
+ "data-lola-drag-exclude": !0,
4282
+ className: "chat-icon-button",
4283
+ onClick: b,
4284
+ children: /* @__PURE__ */ i($r, { "aria-hidden": "true", className: "h-4 w-4" })
4285
+ }
4286
+ )
4287
+ ] })
4288
+ }
4289
+ )
4290
+ }
4291
+ );
4292
+ }
4293
+ function Kc({
4294
+ className: e
4295
+ }) {
4296
+ return /* @__PURE__ */ N(
4297
+ "div",
4298
+ {
4299
+ className: ne(
4300
+ "absolute bottom-0 h-24 w-full transition-opacity",
4301
+ e
4302
+ ),
4303
+ children: [
4304
+ /* @__PURE__ */ i(
4305
+ "div",
4306
+ {
4307
+ className: "h-full backdrop-blur-xs",
4308
+ style: {
4309
+ maskImage: `linear-gradient(
4310
+ to bottom,
4311
+ transparent 0%,
4312
+ black 100%
4313
+ )`
4314
+ }
4315
+ }
4316
+ ),
4317
+ /* @__PURE__ */ i("div", { className: "absolute inset-0 bg-[linear-gradient(to_top,rgba(8,10,15,0.78)_0%,rgba(8,10,15,0.42)_42%,rgba(8,10,15,0)_100%)]" })
4318
+ ]
4319
+ }
4320
+ );
4321
+ }
4322
+ const Yc = (e) => /* @__PURE__ */ we.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M15 18L9 12L15 6", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "round", strokeLinejoin: "round" })), Zc = (e) => /* @__PURE__ */ we.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ we.createElement("path", { d: "M12 5V19M5 12H19", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), je = (e) => e < 10 ? `0${e}` : String(e);
4323
+ function Xc(e, t) {
4324
+ const n = new Date(e), r = /* @__PURE__ */ new Date(), a = r.getTime() - n.getTime(), o = Math.floor(a / 6e4), c = typeof Intl < "u" && typeof Intl.DateTimeFormat == "function" ? Intl.DateTimeFormat : null, s = typeof Intl < "u" && typeof Intl.RelativeTimeFormat == "function" ? new Intl.RelativeTimeFormat(t, {
4325
+ numeric: "auto",
4326
+ style: "short"
4327
+ }) : null;
4328
+ if (s && o < 1) return s.format(0, "second");
4329
+ if (s && o < 60)
4330
+ return s.format(-o, "minute");
4331
+ const l = Math.floor(o / 60);
4332
+ if (s && l < 24)
4333
+ return s.format(-l, "hour");
4334
+ const u = new Date(
4335
+ n.getFullYear(),
4336
+ n.getMonth(),
4337
+ n.getDate()
4338
+ ), w = new Date(
4339
+ r.getFullYear(),
4340
+ r.getMonth(),
4341
+ r.getDate()
4342
+ ), p = Math.round(
4343
+ (w.getTime() - u.getTime()) / 864e5
4344
+ );
4345
+ return !s && p === 0 ? c ? new c(t, {
4346
+ hour: "2-digit",
4347
+ minute: "2-digit"
4348
+ }).format(n) : `${je(n.getHours())}:${je(n.getMinutes())}` : s && p === 1 ? s.format(-1, "day") : p >= 2 && p <= 7 ? c ? new c(t, { weekday: "short" }).format(n) : `${je(n.getDate())}.${je(n.getMonth() + 1)}` : r.getFullYear() - n.getFullYear() === 0 ? c ? new c(t, {
4349
+ month: "short",
4350
+ day: "numeric"
4351
+ }).format(n) : `${je(n.getDate())}.${je(n.getMonth() + 1)}` : c ? new c(t, {
4352
+ day: "2-digit",
4353
+ month: "2-digit",
4354
+ year: "numeric"
4355
+ }).format(n) : `${je(n.getDate())}.${je(
4356
+ n.getMonth() + 1
4357
+ )}.${n.getFullYear()}`;
4358
+ }
4359
+ const Jc = kr(function({
4360
+ threadId: t,
4361
+ title: n,
4362
+ message: r,
4363
+ responderPresentation: a,
4364
+ isSelected: o,
4365
+ onSelect: c
4366
+ }) {
4367
+ const { locale: s, t: l } = me(), u = Mo(r), p = (a.identity === "SUPPORT" && a.displayName === "Support" && a.avatarAsset === null && a.presentationVersion === null ? null : a.displayName?.trim()) || (a.identity === "LOLA" ? "Lola" : l("identity.support")), d = r.author.presentation, h = d?.displayName === "Support" && d.avatarAsset === null && d.presentationVersion === null ? l("identity.support") : d?.displayName?.trim(), m = r.author.type === Te.Agent ? h ?? r.author.displayName?.trim() ?? (r.author.role === "ADMIN" ? a.identity === "SUPPORT" ? p : l("identity.support") : r.author.role === "SYSTEM" ? l("identity.system") : "Lola") : null, g = a.identity === "LOLA" ? "LOLA" : a.avatarAsset !== null ? "HUMAN" : "SUPPORT", b = n?.trim() || l("chat.new");
4368
+ return /* @__PURE__ */ N(
4369
+ "button",
4370
+ {
4371
+ type: "button",
4372
+ onClick: () => c(t),
4373
+ "aria-current": o ? "page" : void 0,
4374
+ "data-responder": a.identity.toLowerCase(),
4375
+ "data-human-support": a.humanSupport.toLowerCase(),
4376
+ className: ne(
4377
+ "chat-list-item group relative flex h-[88px] w-full flex-row items-center gap-3 rounded-3xl border border-white/[0.08] bg-white/[0.025] p-3 text-start transition-[background-color,border-color,transform] duration-150 ease-out motion-reduce:transition-none",
4378
+ "active:scale-[0.97] active:bg-white/[0.055] motion-reduce:active:scale-100",
4379
+ "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--chat-action-primary)]",
4380
+ o && "chat-list-item_selected"
4381
+ ),
4382
+ children: [
4383
+ /* @__PURE__ */ i(
4384
+ Un,
4385
+ {
4386
+ conversationId: t,
4387
+ displayName: p,
4388
+ fallbackKind: g,
4389
+ presentation: a,
4390
+ size: "header",
4391
+ className: "chat-list-item-avatar h-12 w-12 text-[14px]"
4392
+ }
4393
+ ),
4394
+ /* @__PURE__ */ N("span", { className: "chat-list-item-copy flex min-w-0 flex-1 items-start gap-2", children: [
4395
+ /* @__PURE__ */ N("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
4396
+ /* @__PURE__ */ i(
4397
+ "strong",
4398
+ {
4399
+ dir: "auto",
4400
+ className: "chat-list-item-title truncate text-[16px] leading-5 font-bold tracking-[-0.012em] text-white/94",
4401
+ children: b
4402
+ }
4403
+ ),
4404
+ /* @__PURE__ */ N(
4405
+ "span",
4406
+ {
4407
+ dir: "auto",
4408
+ className: "chat-list-item-preview line-clamp-2 text-[14px] leading-[19px] text-white/56",
4409
+ children: [
4410
+ m ? /* @__PURE__ */ N("span", { className: "font-medium text-white/58", children: [
4411
+ m,
4412
+ ":",
4413
+ " "
4414
+ ] }) : null,
4415
+ u
4416
+ ]
4417
+ }
4418
+ )
4419
+ ] }),
4420
+ /* @__PURE__ */ i(
4421
+ "time",
4422
+ {
4423
+ dateTime: r.updatedAt,
4424
+ className: "chat-list-item-time shrink-0 pt-0.5 text-[12px] leading-4 text-white/40 tabular-nums",
4425
+ children: Xc(r.updatedAt, s)
4426
+ }
4427
+ )
4428
+ ] })
4429
+ ]
4430
+ }
4431
+ );
4432
+ }), Qc = 8e3;
4433
+ function el({
4434
+ className: e,
4435
+ ...t
4436
+ }) {
4437
+ const { direction: n, t: r } = me(), a = Yt(), o = In(), c = S(null), s = _o(), {
4438
+ cancelConversationPagination: l,
4439
+ clearSendError: u,
4440
+ createNewConversation: w,
4441
+ fetchMoreConversations: p,
4442
+ setCurrentThread: d
4443
+ } = kn(), h = Dr(), m = Ur(), g = ko(), b = Lo(), C = Ro(), v = Io(o.state), y = v === it.Voice ? ve.voice : ve.text;
4444
+ function T() {
4445
+ a(-1);
4446
+ }
4447
+ function E() {
4448
+ const M = w();
4449
+ a(y), M.catch((G) => {
4450
+ G && typeof G == "object" && "name" in G && G.name === "AbortError" || a(ve.list, {
4451
+ replace: !0,
4452
+ state: {
4453
+ chatMode: v ?? it.Text
4454
+ }
4455
+ });
4456
+ });
4457
+ }
4458
+ const A = h === $e.openChatFailed && m !== null;
4459
+ R(() => {
4460
+ if (h !== $e.openChatFailed || m === null)
4461
+ return;
4462
+ const M = Qc - Math.max(0, Date.now() - m), G = window.setTimeout(u, Math.max(0, M));
4463
+ return () => window.clearTimeout(G);
4464
+ }, [u, h, m]);
4465
+ const _ = U(
4466
+ (M) => {
4467
+ const G = d(M);
4468
+ a(y), G.catch((j) => {
4469
+ console.error("Failed to select conversation", j);
4470
+ });
4471
+ },
4472
+ [y, a, d]
4473
+ ), {
4474
+ error: L,
4475
+ loadMore: I,
4476
+ sentinelRef: X
4477
+ } = Sa({
4478
+ rootRef: c,
4479
+ enabled: b,
4480
+ isLoading: C,
4481
+ onLoad: p
4482
+ });
4483
+ return R(
4484
+ () => () => {
4485
+ l();
4486
+ },
4487
+ [l]
4488
+ ), /* @__PURE__ */ N(
4489
+ "div",
4490
+ {
4491
+ ...t,
4492
+ className: ne(
4493
+ "chat-list-surface chat-history-page z-51 flex h-full flex-col rounded-[inherit]",
4494
+ e
4495
+ ),
4496
+ children: [
4497
+ /* @__PURE__ */ N("header", { className: "chat-list-header flex min-h-16 shrink-0 items-center gap-3 px-4 pt-1", children: [
4498
+ /* @__PURE__ */ i(
4499
+ Q,
4500
+ {
4501
+ onClick: T,
4502
+ "aria-label": r("chat.back"),
4503
+ "data-chat-route-focus": !0,
4504
+ className: "chat-icon-button chat-history-back-button h-8 w-8 shrink-0 rounded-[13px]",
4505
+ children: /* @__PURE__ */ i(
4506
+ Yc,
4507
+ {
4508
+ className: ne("h-5 w-5", n === "rtl" && "rotate-180")
4509
+ }
4510
+ )
4511
+ }
4512
+ ),
4513
+ /* @__PURE__ */ i("h1", { className: "chat-list-title min-w-0 flex-1 text-start text-[20px] leading-6 font-bold tracking-[-0.02em] text-white/95", children: r("chat.listTitle") })
4514
+ ] }),
4515
+ /* @__PURE__ */ N(
4516
+ "div",
4517
+ {
4518
+ ref: c,
4519
+ role: "region",
4520
+ "aria-label": r("chat.listTitle"),
4521
+ "aria-busy": C,
4522
+ className: "chat-list-content chat-scrollbar flex flex-1 flex-col overflow-y-auto px-4 pt-5 pb-[max(16px,var(--lola-safe-area-inset-bottom))]",
4523
+ children: [
4524
+ /* @__PURE__ */ N(
4525
+ Q,
4526
+ {
4527
+ onClick: E,
4528
+ "aria-label": r("chat.createNew"),
4529
+ className: "chat-list-new-button mb-2 flex h-12 w-full shrink-0 items-center gap-3 rounded-2xl border border-[var(--chat-action-primary)]/12 bg-[var(--chat-action-primary)]/10 px-4 text-start text-[16px] leading-5 font-medium text-white/90 transition-[background-color,border-color,transform] duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none motion-reduce:active:scale-100",
4530
+ children: [
4531
+ /* @__PURE__ */ i(
4532
+ "span",
4533
+ {
4534
+ "aria-hidden": "true",
4535
+ className: "chat-list-new-icon grid h-6 w-6 shrink-0 place-items-center rounded-full border-2 border-[var(--chat-action-primary)] text-[var(--chat-action-primary)]",
4536
+ children: /* @__PURE__ */ i(Zc, { className: "h-[18px] w-[18px]" })
4537
+ }
4538
+ ),
4539
+ /* @__PURE__ */ i("span", { className: "truncate", children: r("chat.createNew") })
4540
+ ]
4541
+ }
4542
+ ),
4543
+ /* @__PURE__ */ i(
4544
+ ze,
4545
+ {
4546
+ appear: !0,
4547
+ show: A,
4548
+ enter: "transition-[opacity,transform] duration-[160ms] ease-[var(--chat-ease-out)] motion-reduce:transition-opacity motion-reduce:duration-100",
4549
+ enterFrom: "translate-y-1 opacity-0 motion-reduce:translate-y-0",
4550
+ enterTo: "translate-y-0 opacity-100",
4551
+ leave: "transition-[opacity,transform] duration-[140ms] ease-[var(--chat-ease-out)] motion-reduce:transition-opacity motion-reduce:duration-100",
4552
+ leaveFrom: "translate-y-0 opacity-100",
4553
+ leaveTo: "-translate-y-1 opacity-0 motion-reduce:translate-y-0",
4554
+ children: /* @__PURE__ */ i(
4555
+ "p",
4556
+ {
4557
+ role: "status",
4558
+ "aria-live": "polite",
4559
+ className: "mb-2 rounded-xl border border-white/[0.06] bg-white/[0.035] px-3 py-2 text-[12px] leading-4 text-white/62",
4560
+ children: r("compact.openFailed")
4561
+ }
4562
+ )
4563
+ }
4564
+ ),
4565
+ /* @__PURE__ */ i(
4566
+ "div",
4567
+ {
4568
+ role: "list",
4569
+ "aria-label": r("chat.listTitle"),
4570
+ className: "chat-list-items flex flex-col gap-2",
4571
+ children: g.map((M) => /* @__PURE__ */ i(
4572
+ "div",
4573
+ {
4574
+ role: "listitem",
4575
+ className: "chat-list-entry",
4576
+ children: /* @__PURE__ */ i(
4577
+ Jc,
4578
+ {
4579
+ threadId: M.threadId,
4580
+ title: M.title,
4581
+ message: M.lastMessage,
4582
+ responderPresentation: M.responderPresentation,
4583
+ isSelected: s === M.threadId,
4584
+ onSelect: _
4585
+ }
4586
+ )
4587
+ },
4588
+ M.threadId
4589
+ ))
4590
+ }
4591
+ ),
4592
+ C && /* @__PURE__ */ i(Cc, {}),
4593
+ /* @__PURE__ */ i("div", { ref: X, "aria-hidden": "true", className: "h-px shrink-0" }),
4594
+ b && !C && /* @__PURE__ */ i(
4595
+ Q,
4596
+ {
4597
+ type: "button",
4598
+ "aria-label": r("chat.loadOlder"),
4599
+ onClick: () => {
4600
+ I();
4601
+ },
4602
+ className: "mx-auto my-2 rounded-full border border-white/10 bg-white/[0.04] px-3 py-1.5 text-xs text-white/65 transition-colors hover:border-[#68d8ff]/30 hover:text-white/90",
4603
+ children: r(L ? "chat.retryOlder" : "chat.loadOlder")
4604
+ }
4605
+ ),
4606
+ L && /* @__PURE__ */ i(
4607
+ "p",
4608
+ {
4609
+ role: "alert",
4610
+ className: "px-3 pb-2 text-center text-xs text-red-200",
4611
+ children: r("chat.olderLoadFailed")
4612
+ }
4613
+ )
4614
+ ]
4615
+ }
4616
+ )
4617
+ ]
4618
+ }
4619
+ );
4620
+ }
4621
+ function Sr({
4622
+ mode: e,
4623
+ freezeVoicePresentation: t = !1
4624
+ }) {
4625
+ const n = e === it.Text;
4626
+ return /* @__PURE__ */ N(Ce, { children: [
4627
+ /* @__PURE__ */ i("div", { className: "pointer-events-none absolute inset-0", children: /* @__PURE__ */ i(
4628
+ Kc,
4629
+ {
4630
+ className: n ? "opacity-100" : "opacity-0"
4631
+ }
4632
+ ) }),
4633
+ /* @__PURE__ */ N("div", { className: "relative z-5 flex h-full min-h-0 w-full flex-col", children: [
4634
+ /* @__PURE__ */ i(qc, { className: "shrink-0" }),
4635
+ /* @__PURE__ */ i("div", { className: "chat-mode-content flex min-h-0 flex-1 flex-col justify-end", children: e === it.Voice ? /* @__PURE__ */ i(ki, { freezePresentation: t }) : /* @__PURE__ */ i(Uc, {}) })
4636
+ ] })
4637
+ ] });
4638
+ }
4639
+ function tl({
4640
+ location: e,
4641
+ freezeVoicePresentation: t = !1,
4642
+ isCurrentLocation: n = !0
4643
+ }) {
4644
+ const r = Hr(), a = Rn(), c = Br(
4645
+ a,
4646
+ r
4647
+ ) && n;
4648
+ return /* @__PURE__ */ N($o, { location: e, children: [
4649
+ /* @__PURE__ */ i(
4650
+ pt,
4651
+ {
4652
+ path: ve.list,
4653
+ element: /* @__PURE__ */ i(el, { className: "h-full w-full" })
4654
+ }
4655
+ ),
4656
+ /* @__PURE__ */ i(
4657
+ pt,
4658
+ {
4659
+ path: ve.voice,
4660
+ element: /* @__PURE__ */ N(Ce, { children: [
4661
+ /* @__PURE__ */ i(
4662
+ Sr,
4663
+ {
4664
+ mode: it.Voice,
4665
+ freezeVoicePresentation: t || c
4666
+ }
4667
+ ),
4668
+ c && /* @__PURE__ */ i(nl, {})
4669
+ ] })
4670
+ }
4671
+ ),
4672
+ /* @__PURE__ */ i(pt, { path: ve.text, element: /* @__PURE__ */ i(Sr, { mode: it.Text }) }),
4673
+ /* @__PURE__ */ i(pt, { path: "/", element: /* @__PURE__ */ i(mn, { to: ve.text, replace: !0 }) }),
4674
+ /* @__PURE__ */ i(pt, { path: "*", element: /* @__PURE__ */ i(mn, { to: ve.text, replace: !0 }) })
4675
+ ] });
4676
+ }
4677
+ function nl() {
4678
+ return ye(() => {
4679
+ Se.getState().actions.endVoiceChat("responder_changed");
4680
+ }, []), /* @__PURE__ */ i(mn, { to: ve.text, replace: !0 });
4681
+ }
4682
+ function dl() {
4683
+ const { setAvatarCoveredByChatList: e } = kt(), t = In(), n = S(null), r = S(t.pathname), [a, o] = F(!1), [c, s] = F(() => ({ location: t, transition: null }));
4684
+ if (t.key !== c.location.key) {
4685
+ const d = c.transition?.to ?? c.location, h = Oo(
4686
+ d.pathname,
4687
+ t.pathname
4688
+ );
4689
+ s({
4690
+ location: t,
4691
+ transition: h ? {
4692
+ id: t.key,
4693
+ direction: h,
4694
+ kind: on(d.pathname) || on(t.pathname) ? "list" : "mode",
4695
+ transferFocus: a,
4696
+ from: d,
4697
+ to: t
4698
+ } : null
4699
+ });
4700
+ }
4701
+ const { location: l, transition: u } = c, w = u ? [u.from, u.to] : [l];
4702
+ ye(() => {
4703
+ e(
4704
+ !u && on(l.pathname)
4705
+ );
4706
+ }, [l.pathname, e, u]), ye(() => {
4707
+ const d = r.current;
4708
+ r.current = t.pathname, Bt(d) && !Bt(t.pathname) && Se.getState().actions.endVoiceChat("route_changed");
4709
+ }, [t.pathname]), ye(() => {
4710
+ if (!u?.transferFocus) return;
4711
+ const d = n.current?.querySelector(
4712
+ '[data-chat-route-state="incoming"]'
4713
+ );
4714
+ (d?.querySelector(
4715
+ "[data-chat-route-focus]:not(:disabled)"
4716
+ ) ?? d?.querySelector(
4717
+ "textarea:not(:disabled), button:not(:disabled), a[href]"
4718
+ ) ?? d)?.focus({ preventScroll: !0 });
4719
+ }, [u]);
4720
+ const p = (d) => {
4721
+ if (!u) return;
4722
+ if (u.kind === "mode") {
4723
+ if (!(d.target instanceof HTMLElement) || !d.target.classList.contains("chat-mode-content"))
4724
+ return;
4725
+ } else if (d.target !== d.currentTarget)
4726
+ return;
4727
+ const h = u.id;
4728
+ s((m) => ({
4729
+ ...m,
4730
+ transition: m.transition?.id === h ? null : m.transition
4731
+ }));
4732
+ };
4733
+ return /* @__PURE__ */ i(
4734
+ "div",
4735
+ {
4736
+ ref: n,
4737
+ className: "chat-route-stage relative z-5 h-full rounded-[inherit]",
4738
+ onFocusCapture: () => o(!0),
4739
+ onBlurCapture: (d) => {
4740
+ const h = d.relatedTarget;
4741
+ (!h || !d.currentTarget.contains(h)) && o(!1);
4742
+ },
4743
+ children: w.map((d) => {
4744
+ const h = d.key === u?.to.key, m = u ? u.kind === "mode" ? !0 : u.direction === "forward" ? h : !h : !1, g = h ? "enter" : "exit", b = !!(m && u && (u.kind !== "mode" || (u.direction === "forward" ? h : !h))), C = m && u ? `chat-route-pane chat-route-pane_${g} chat-route-pane_${u.direction} chat-route-pane_${u.kind}` : "chat-route-page_background";
4745
+ return /* @__PURE__ */ i(
4746
+ "div",
4747
+ {
4748
+ className: `chat-route-page rounded-[inherit] ${C}`,
4749
+ "data-chat-route-state": u ? h ? "incoming" : "outgoing" : "active",
4750
+ "aria-hidden": u ? !h : void 0,
4751
+ inert: u && !h ? !0 : void 0,
4752
+ tabIndex: h ? -1 : void 0,
4753
+ "data-chat-route-completes": b ? "true" : void 0,
4754
+ onAnimationEnd: b ? p : void 0,
4755
+ children: /* @__PURE__ */ i(
4756
+ tl,
4757
+ {
4758
+ location: d,
4759
+ isCurrentLocation: d.key === t.key,
4760
+ freezeVoicePresentation: !!(u && !h && Bt(d.pathname))
4761
+ }
4762
+ )
4763
+ },
4764
+ d.key
4765
+ );
4766
+ })
4767
+ }
4768
+ );
4769
+ }
4770
+ export {
4771
+ dl as default
4772
+ };