@squadico/chatbot 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +502 -0
  2. package/dist/chatbot.global.js +8 -0
  3. package/dist/chatbot.global.js.map +1 -0
  4. package/dist/components/Approval.d.ts +37 -0
  5. package/dist/components/Approval.d.ts.map +1 -0
  6. package/dist/components/ChatbotWidget.d.ts +19 -0
  7. package/dist/components/ChatbotWidget.d.ts.map +1 -0
  8. package/dist/components/Choices.d.ts +27 -0
  9. package/dist/components/Choices.d.ts.map +1 -0
  10. package/dist/components/Composer.d.ts +35 -0
  11. package/dist/components/Composer.d.ts.map +1 -0
  12. package/dist/components/Confirm.d.ts +16 -0
  13. package/dist/components/Confirm.d.ts.map +1 -0
  14. package/dist/components/MessageList.d.ts +32 -0
  15. package/dist/components/MessageList.d.ts.map +1 -0
  16. package/dist/components/RichText.d.ts +19 -0
  17. package/dist/components/RichText.d.ts.map +1 -0
  18. package/dist/element.d.ts +9 -0
  19. package/dist/element.d.ts.map +1 -0
  20. package/dist/index.cjs +1 -0
  21. package/dist/index.d.ts +15 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +2 -0
  24. package/dist/jsx.d.ts +57 -0
  25. package/dist/jsx.d.ts.map +1 -0
  26. package/dist/lib/client.d.ts +217 -0
  27. package/dist/lib/client.d.ts.map +1 -0
  28. package/dist/lib/confirm.d.ts +17 -0
  29. package/dist/lib/confirm.d.ts.map +1 -0
  30. package/dist/lib/context.d.ts +40 -0
  31. package/dist/lib/context.d.ts.map +1 -0
  32. package/dist/lib/conversation.d.ts +49 -0
  33. package/dist/lib/conversation.d.ts.map +1 -0
  34. package/dist/lib/i18n.d.ts +152 -0
  35. package/dist/lib/i18n.d.ts.map +1 -0
  36. package/dist/lib/openState.d.ts +26 -0
  37. package/dist/lib/openState.d.ts.map +1 -0
  38. package/dist/lib/uid.d.ts +8 -0
  39. package/dist/lib/uid.d.ts.map +1 -0
  40. package/dist/lib/useChat.d.ts +71 -0
  41. package/dist/lib/useChat.d.ts.map +1 -0
  42. package/dist/react.cjs +2 -0
  43. package/dist/react.cjs.map +1 -0
  44. package/dist/react.d.ts +30 -0
  45. package/dist/react.d.ts.map +1 -0
  46. package/dist/react.js +70 -0
  47. package/dist/react.js.map +1 -0
  48. package/dist/src-CN1vDssu.js +2492 -0
  49. package/dist/src-CN1vDssu.js.map +1 -0
  50. package/dist/src-DvRdkFTu.cjs +8 -0
  51. package/dist/src-DvRdkFTu.cjs.map +1 -0
  52. package/dist/types.d.ts +301 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/package.json +76 -0
@@ -0,0 +1,2492 @@
1
+ //#region node_modules/preact/dist/preact.module.js
2
+ var e, t, n, r, i, a, o, s, c, l, u, d, f, p, m = {}, h = [], g = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, _ = Array.isArray;
3
+ function v(e, t) {
4
+ for (var n in t) e[n] = t[n];
5
+ return e;
6
+ }
7
+ function y(e) {
8
+ e && e.parentNode && e.parentNode.removeChild(e);
9
+ }
10
+ function b(t, n, r) {
11
+ var i, a, o, s = {};
12
+ for (o in n) o == "key" ? i = n[o] : o == "ref" ? a = n[o] : s[o] = n[o];
13
+ if (arguments.length > 2 && (s.children = arguments.length > 3 ? e.call(arguments, 2) : r), typeof t == "function" && t.defaultProps != null) for (o in t.defaultProps) s[o] === void 0 && (s[o] = t.defaultProps[o]);
14
+ return x(t, s, i, a, null);
15
+ }
16
+ function x(e, r, i, a, o) {
17
+ var s = {
18
+ type: e,
19
+ props: r,
20
+ key: i,
21
+ ref: a,
22
+ __k: null,
23
+ __: null,
24
+ __b: 0,
25
+ __e: null,
26
+ __c: null,
27
+ constructor: void 0,
28
+ __v: o ?? ++n,
29
+ __i: -1,
30
+ __u: 0
31
+ };
32
+ return o == null && t.vnode != null && t.vnode(s), s;
33
+ }
34
+ function S(e) {
35
+ return e.children;
36
+ }
37
+ function C(e, t) {
38
+ this.props = e, this.context = t;
39
+ }
40
+ function w(e, t) {
41
+ if (t == null) return e.__ ? w(e.__, e.__i + 1) : null;
42
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
43
+ return typeof e.type == "function" ? w(e) : null;
44
+ }
45
+ function T(e) {
46
+ if (e.__P && e.__d) {
47
+ var n = e.__v, r = n.__e, i = [], a = [], o = v({}, n);
48
+ o.__v = n.__v + 1, t.vnode && t.vnode(o), I(e.__P, o, n, e.__n, e.__P.namespaceURI, 32 & n.__u ? [r] : null, i, r ?? w(n), !!(32 & n.__u), a), o.__v = n.__v, o.__.__k[o.__i] = o, ee(i, o, a), n.__e = n.__ = null, o.__e != r && E(o);
49
+ }
50
+ }
51
+ function E(e) {
52
+ if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
53
+ if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
54
+ }), E(e);
55
+ }
56
+ function D(e) {
57
+ (!e.__d && (e.__d = !0) && r.push(e) && !O.__r++ || i != t.debounceRendering) && ((i = t.debounceRendering) || a)(O);
58
+ }
59
+ function O() {
60
+ try {
61
+ for (var e, t = 1; r.length;) r.length > t && r.sort(o), e = r.shift(), t = r.length, T(e);
62
+ } finally {
63
+ r.length = O.__r = 0;
64
+ }
65
+ }
66
+ function k(e, t, n, r, i, a, o, s, c, l, u) {
67
+ var d, f, p, g, _, v, y = r && r.__k || h, b = t.length;
68
+ for (c = A(n, t, y, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && y[p.__i] || m, p.__i = d, v = I(e, p, f, i, a, o, s, c, l, u), g = p.__e, p.ref && f.ref != p.ref && (f.ref && z(f.ref, null, p), u.push(p.ref, p.__c || g, p)), _ == null && g != null && (_ = g), 4 & p.__u ? (c = j(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : g && (c = g.nextSibling), p.__u &= -7);
69
+ return n.__e = _, c;
70
+ }
71
+ function A(e, t, n, r, i) {
72
+ var a, o, s, c, l, u = n.length, d = u, f = 0;
73
+ for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = x(null, o, null, null, null) : _(o) ? o = e.__k[a] = x(S, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = x(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = M(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
74
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = w(s)), ne(s, s));
75
+ return r;
76
+ }
77
+ function j(e, t, n) {
78
+ var r, i;
79
+ if (typeof e.type == "function") {
80
+ for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = j(r[i], t, n));
81
+ return t;
82
+ }
83
+ e.__e != t && (t && e.type && !t.parentNode && (t = w(e)), t = n.insertBefore(e.__e, t || null));
84
+ do
85
+ t = t && t.nextSibling;
86
+ while (t != null && t.nodeType == 8);
87
+ return t;
88
+ }
89
+ function M(e, t, n, r) {
90
+ var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
91
+ if (l === null && s == null || u && s == l.key && c == l.type) return n;
92
+ if (r > +!!u) {
93
+ for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o;
94
+ }
95
+ return -1;
96
+ }
97
+ function N(e, t, n) {
98
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || g.test(t) ? n : n + "px";
99
+ }
100
+ function P(e, t, n, r, i) {
101
+ var a, o;
102
+ n: if (t == "style") {
103
+ if (typeof n == "string") e.style.cssText = n;
104
+ else {
105
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || N(e.style, t, "");
106
+ if (n) for (t in n) r && n[t] == r[t] || N(e.style, t, n[t]);
107
+ }
108
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(u, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + a] = n, n ? r ? n[l] = r[l] : (n[l] = d, e.addEventListener(t, a ? p : f, a)) : e.removeEventListener(t, a ? p : f, a);
109
+ else {
110
+ if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
111
+ else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
112
+ e[t] = n ?? "";
113
+ break n;
114
+ } catch {}
115
+ typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
116
+ }
117
+ }
118
+ function F(e) {
119
+ return function(n) {
120
+ if (this.l) {
121
+ var r = this.l[n.type + e];
122
+ if (n[c] == null) n[c] = d++;
123
+ else if (n[c] < r[l]) return;
124
+ return r(t.event ? t.event(n) : n);
125
+ }
126
+ };
127
+ }
128
+ function I(e, n, r, i, a, o, s, c, l, u) {
129
+ var d, f, p, m, g, b, x, T, E, D, O, A, j, M, N, P, F = n.type;
130
+ if (n.constructor !== void 0) return null;
131
+ 128 & r.__u && (l = !!(32 & r.__u), o = [c = n.__e = r.__e]), (d = t.__b) && d(n);
132
+ n: if (typeof F == "function") {
133
+ f = s.length;
134
+ try {
135
+ if (E = n.props, D = F.prototype && F.prototype.render, O = (d = F.contextType) && i[d.__c], A = d ? O ? O.props.value : d.__ : i, r.__c ? T = (p = n.__c = r.__c).__ = p.__E : (D ? n.__c = p = new F(E, A) : (n.__c = p = new C(E, A), p.constructor = F, p.render = re), O && O.sub(p), p.state || (p.state = {}), p.__n = i, m = p.__d = !0, p.__h = [], p._sb = []), D && p.__s == null && (p.__s = p.state), D && F.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = v({}, p.__s)), v(p.__s, F.getDerivedStateFromProps(E, p.__s))), g = p.props, b = p.state, p.__v = n, m) D && F.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), D && p.componentDidMount != null && p.__h.push(p.componentDidMount);
136
+ else {
137
+ if (D && F.getDerivedStateFromProps == null && E !== g && p.componentWillReceiveProps != null && p.componentWillReceiveProps(E, A), n.__v == r.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(E, p.__s, A)) {
138
+ n.__v != r.__v && (p.props = E, p.state = p.__s, p.__d = !1), n.__e = r.__e, n.__k = r.__k, n.__k.some(function(e) {
139
+ e && (e.__ = n);
140
+ }), h.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = w(r);
141
+ break n;
142
+ }
143
+ p.componentWillUpdate != null && p.componentWillUpdate(E, p.__s, A), D && p.componentDidUpdate != null && p.__h.push(function() {
144
+ p.componentDidUpdate(g, b, x);
145
+ });
146
+ }
147
+ if (p.context = A, p.props = E, p.__P = e, p.__e = !1, j = t.__r, M = 0, D) p.state = p.__s, p.__d = !1, j && j(n), d = p.render(p.props, p.state, p.context), h.push.apply(p.__h, p._sb), p._sb = [];
148
+ else do
149
+ p.__d = !1, j && j(n), d = p.render(p.props, p.state, p.context), p.state = p.__s;
150
+ while (p.__d && ++M < 25);
151
+ p.state = p.__s, p.getChildContext != null && (i = v(v({}, i), p.getChildContext())), D && !m && p.getSnapshotBeforeUpdate != null && (x = p.getSnapshotBeforeUpdate(g, b)), N = d != null && d.type === S && d.key == null ? R(d.props.children) : d, c = k(e, _(N) ? N : [N], n, r, i, a, o, s, c, l, u), p.base = n.__e, n.__u &= -161, p.__h.length && s.push(p), T && (p.__E = p.__ = null);
152
+ } catch (e) {
153
+ if (s.length = f, n.__v = null, l || o != null) {
154
+ if (e.then) {
155
+ for (n.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
156
+ o != null && (o[o.indexOf(c)] = null), n.__e = c;
157
+ } else if (o != null) for (P = o.length; P--;) y(o[P]);
158
+ } else n.__e = r.__e;
159
+ n.__k ?? (n.__k = r.__k || []), e.then || L(n), t.__e(e, n, r);
160
+ }
161
+ } else o == null && n.__v == r.__v ? (n.__k = r.__k, n.__e = r.__e) : c = n.__e = te(r.__e, n, r, i, a, o, s, l, u);
162
+ return (d = t.diffed) && d(n), 128 & n.__u ? void 0 : c;
163
+ }
164
+ function L(e) {
165
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(L));
166
+ }
167
+ function ee(e, n, r) {
168
+ for (var i = 0; i < r.length; i++) z(r[i], r[++i], r[++i]);
169
+ t.__c && t.__c(n, e), e.some(function(n) {
170
+ try {
171
+ e = n.__h, n.__h = [], e.some(function(e) {
172
+ e.call(n);
173
+ });
174
+ } catch (e) {
175
+ t.__e(e, n.__v);
176
+ }
177
+ });
178
+ }
179
+ function R(e) {
180
+ return typeof e != "object" || !e || e.__b > 0 ? e : _(e) ? e.map(R) : e.constructor === void 0 ? v({}, e) : null;
181
+ }
182
+ function te(n, r, i, a, o, s, c, l, u) {
183
+ var d, f, p, h, g, v, b, x = i.props || m, S = r.props, C = r.type;
184
+ if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o || (o = "http://www.w3.org/1999/xhtml"), s != null) {
185
+ for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
186
+ n = g, s[d] = null;
187
+ break;
188
+ }
189
+ }
190
+ if (n == null) {
191
+ if (C == null) return document.createTextNode(S);
192
+ n = document.createElementNS(o, C, S.is && S), l && (t.__m && t.__m(r, s), l = !1), s = null;
193
+ }
194
+ if (C == null) x === S || l && n.data == S || (n.data = S);
195
+ else {
196
+ if (s = C == "textarea" && S.defaultValue != null ? null : s && e.call(n.childNodes), !l && s != null) for (x = {}, d = 0; d < n.attributes.length; d++) x[(g = n.attributes[d]).name] = g.value;
197
+ for (d in x) g = x[d], d == "dangerouslySetInnerHTML" ? p = g : d == "children" || d in S || d == "value" && "defaultValue" in S || d == "checked" && "defaultChecked" in S || P(n, d, null, g, o);
198
+ for (d in S) g = S[d], d == "children" ? h = g : d == "dangerouslySetInnerHTML" ? f = g : d == "value" ? v = g : d == "checked" ? b = g : l && typeof g != "function" || x[d] === g || P(n, d, g, x[d], o);
199
+ if (f) l || p && (f.__html == p.__html || f.__html == n.innerHTML) || (n.innerHTML = f.__html), r.__k = [];
200
+ else if (p && (n.innerHTML = ""), k(r.type == "template" ? n.content : n, _(h) ? h : [h], r, i, a, C == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : i.__k && w(i, 0), l, u), s != null) for (d = s.length; d--;) y(s[d]);
201
+ l && C != "textarea" || (d = "value", C == "progress" && v == null ? n.removeAttribute("value") : v != null && (v !== n[d] || C == "progress" && !v || C == "option" && v != x[d]) && P(n, d, v, x[d], o), d = "checked", b != null && b != n[d] && P(n, d, b, x[d], o));
202
+ }
203
+ return n;
204
+ }
205
+ function z(e, n, r) {
206
+ try {
207
+ if (typeof e == "function") {
208
+ var i = typeof e.__u == "function";
209
+ i && e.__u(), i && n == null || (e.__u = e(n));
210
+ } else e.current = n;
211
+ } catch (e) {
212
+ t.__e(e, r);
213
+ }
214
+ }
215
+ function ne(e, n, r) {
216
+ var i, a;
217
+ if (t.unmount && t.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || z(i, null, n)), (i = e.__c) != null) {
218
+ if (i.componentWillUnmount) try {
219
+ i.componentWillUnmount();
220
+ } catch (e) {
221
+ t.__e(e, n);
222
+ }
223
+ i.base = i.__P = i.__n = null;
224
+ }
225
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && ne(i[a], n, r || typeof e.type != "function");
226
+ r || y(e.__e), e.__c = e.__ = e.__e = void 0;
227
+ }
228
+ function re(e, t, n) {
229
+ return this.constructor(e, n);
230
+ }
231
+ function ie(n, r, i) {
232
+ var a, o, s, c;
233
+ r == document && (r = document.documentElement), t.__ && t.__(n, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], I(r, n = (!a && i || r).__k = b(S, null, [n]), o || m, m, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? e.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ee(s, n, c), n.props.children = null;
234
+ }
235
+ e = h.slice, t = { __e: function(e, t, n, r) {
236
+ for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
237
+ if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
238
+ } catch (t) {
239
+ e = t;
240
+ }
241
+ throw e;
242
+ } }, n = 0, C.prototype.setState = function(e, t) {
243
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = v({}, this.state);
244
+ typeof e == "function" && (e = e(v({}, n), this.props)), e && v(n, e), e != null && this.__v && (t && this._sb.push(t), D(this));
245
+ }, C.prototype.forceUpdate = function(e) {
246
+ this.__v && (this.__e = !0, e && this.__h.push(e), D(this));
247
+ }, C.prototype.render = S, r = [], a = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, o = function(e, t) {
248
+ return e.__v.__b - t.__v.__b;
249
+ }, O.__r = 0, s = Math.random().toString(8), c = "__d" + s, l = "__a" + s, u = /(PointerCapture)$|Capture$/i, d = 0, f = F(!1), p = F(!0);
250
+ //#endregion
251
+ //#region node_modules/preact/hooks/dist/hooks.module.js
252
+ var ae, B, oe, se, ce = 0, le = [], V = t, ue = V.__b, de = V.__r, fe = V.diffed, pe = V.__c, me = V.unmount, he = V.__;
253
+ function ge(e, t) {
254
+ V.__h && V.__h(B, e, ce || t), ce = 0;
255
+ var n = B.__H || (B.__H = {
256
+ __: [],
257
+ __h: []
258
+ });
259
+ return e >= n.__.length && n.__.push({}), n.__[e];
260
+ }
261
+ function H(e) {
262
+ return ce = 1, _e(Te, e);
263
+ }
264
+ function _e(e, t, n) {
265
+ var r = ge(ae++, 2);
266
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Te(void 0, t), function(e) {
267
+ var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
268
+ t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
269
+ }], r.__c = B, !B.__f)) {
270
+ var i = function(e, t, n) {
271
+ if (!r.__c.__H) return !0;
272
+ var i = !1, o = r.__c.props !== e;
273
+ if (r.__c.__H.__.some(function(e) {
274
+ if (e.__N) {
275
+ i = !0;
276
+ var t = e.__[0];
277
+ e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0);
278
+ }
279
+ }), a) {
280
+ var s = a.call(this, e, t, n);
281
+ return i ? s || o : s;
282
+ }
283
+ return !i || o;
284
+ };
285
+ B.__f = !0;
286
+ var a = B.shouldComponentUpdate, o = B.componentWillUpdate;
287
+ B.componentWillUpdate = function(e, t, n) {
288
+ if (this.__e) {
289
+ var r = a;
290
+ a = void 0, i(e, t, n), a = r;
291
+ }
292
+ o && o.call(this, e, t, n);
293
+ }, B.shouldComponentUpdate = i;
294
+ }
295
+ return r.__N || r.__;
296
+ }
297
+ function U(e, t) {
298
+ var n = ge(ae++, 3);
299
+ !V.__s && we(n.__H, t) && (n.__ = e, n.u = t, B.__H.__h.push(n));
300
+ }
301
+ function ve(e, t) {
302
+ var n = ge(ae++, 4);
303
+ !V.__s && we(n.__H, t) && (n.__ = e, n.u = t, B.__h.push(n));
304
+ }
305
+ function W(e) {
306
+ return ce = 5, G(function() {
307
+ return { current: e };
308
+ }, []);
309
+ }
310
+ function G(e, t) {
311
+ var n = ge(ae++, 7);
312
+ return we(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
313
+ }
314
+ function K(e, t) {
315
+ return ce = 8, G(function() {
316
+ return e;
317
+ }, t);
318
+ }
319
+ function ye() {
320
+ for (var e; e = le.shift();) {
321
+ var t = e.__H;
322
+ if (e.__P && t) try {
323
+ t.__h.some(Se), t.__h.some(Ce), t.__h = [];
324
+ } catch (n) {
325
+ t.__h = [], V.__e(n, e.__v);
326
+ }
327
+ }
328
+ }
329
+ V.__b = function(e) {
330
+ B = null, ue && ue(e);
331
+ }, V.__ = function(e, t) {
332
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), he && he(e, t);
333
+ }, V.__r = function(e) {
334
+ de && de(e), ae = 0;
335
+ var t = (B = e.__c).__H;
336
+ t && (oe === B ? (t.__h = [], B.__h = [], t.__.some(function(e) {
337
+ e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
338
+ })) : (t.__h.some(Se), t.__h.some(Ce), t.__h = [], ae = 0)), oe = B;
339
+ }, V.diffed = function(e) {
340
+ fe && fe(e);
341
+ var t = e.__c;
342
+ t && t.__H && (t.__H.__h.length && (le.push(t) !== 1 && se === V.requestAnimationFrame || ((se = V.requestAnimationFrame) || xe)(ye)), t.__H.__.some(function(e) {
343
+ e.u && (e.__H = e.u, e.u = void 0);
344
+ })), oe = B = null;
345
+ }, V.__c = function(e, t) {
346
+ t.some(function(e) {
347
+ try {
348
+ e.__h.some(Se), e.__h = e.__h.filter(function(e) {
349
+ return !e.__ || Ce(e);
350
+ });
351
+ } catch (n) {
352
+ t.some(function(e) {
353
+ e.__h && (e.__h = []);
354
+ }), t = [], V.__e(n, e.__v);
355
+ }
356
+ }), pe && pe(e, t);
357
+ }, V.unmount = function(e) {
358
+ me && me(e);
359
+ var t, n = e.__c;
360
+ n && n.__H && (n.__H.__.some(function(e) {
361
+ try {
362
+ Se(e);
363
+ } catch (e) {
364
+ t = e;
365
+ }
366
+ }), n.__H = void 0, t && V.__e(t, n.__v));
367
+ };
368
+ var be = typeof requestAnimationFrame == "function";
369
+ function xe(e) {
370
+ var t, n = function() {
371
+ clearTimeout(r), be && cancelAnimationFrame(t), setTimeout(e);
372
+ }, r = setTimeout(n, 35);
373
+ be && (t = requestAnimationFrame(n));
374
+ }
375
+ function Se(e) {
376
+ var t = B, n = e.__c;
377
+ typeof n == "function" && (e.__c = void 0, n()), B = t;
378
+ }
379
+ function Ce(e) {
380
+ var t = B;
381
+ e.__c = e.__(), B = t;
382
+ }
383
+ function we(e, t) {
384
+ return !e || e.length !== t.length || t.some(function(t, n) {
385
+ return t !== e[n];
386
+ });
387
+ }
388
+ function Te(e, t) {
389
+ return typeof t == "function" ? t(e) : t;
390
+ }
391
+ //#endregion
392
+ //#region src/lib/context.ts
393
+ var Ee = /* @__PURE__ */ new Set(["sessionId"]);
394
+ function De(e) {
395
+ if (typeof e == "string") return e.length > 0 ? { id: e } : void 0;
396
+ if (!e || typeof e != "object" || Array.isArray(e)) return;
397
+ let { id: t, name: n } = e;
398
+ if (typeof t == "string" && t.length !== 0) return typeof n == "string" && n.length > 0 ? {
399
+ id: t,
400
+ name: n
401
+ } : { id: t };
402
+ }
403
+ function Oe(e) {
404
+ let t = De(e);
405
+ if (t) return t.name ?? t.id;
406
+ }
407
+ function ke(e) {
408
+ return !!e && typeof e == "object" && !Array.isArray(e);
409
+ }
410
+ function Ae(e) {
411
+ let t = {};
412
+ for (let [n, r] of Object.entries(e)) {
413
+ if (Ee.has(n) || !ke(r)) {
414
+ t[n] = r;
415
+ continue;
416
+ }
417
+ let e = De(r);
418
+ e && (t[`${n}Id`] = e.id, e.name && (t[`${n}Name`] = e.name));
419
+ }
420
+ return t;
421
+ }
422
+ //#endregion
423
+ //#region src/lib/i18n.ts
424
+ var je = "en", Me = [
425
+ "en",
426
+ "fr",
427
+ "es"
428
+ ], Ne = {
429
+ en: {
430
+ heading: "Assistant",
431
+ subheading: "Squadico",
432
+ placeholder: "Ask your question…",
433
+ greeting: "Hello! I am your assistant. What would you like to do?",
434
+ hint: "The assistant proposes an action; nothing is applied without your confirmation.",
435
+ assistant: "Assistant",
436
+ typing: "The assistant is writing its answer",
437
+ newConversation: "New conversation",
438
+ close: "Close the assistant",
439
+ closeTitle: "Close",
440
+ history: {
441
+ open: "Conversation history",
442
+ menu: "Previous conversations",
443
+ loading: "Loading…",
444
+ empty: "No previous conversation.",
445
+ untitled: "Conversation"
446
+ },
447
+ context: { region: "Context sent to the assistant" },
448
+ approval: {
449
+ group: "Write confirmation",
450
+ approve: "Yes, apply",
451
+ reject: "No, cancel",
452
+ request: "The agent wants to use {tool}.",
453
+ arguments: "With",
454
+ edit: "Change…",
455
+ correction: "What to change — e.g. “the due date is next Monday”",
456
+ correctionLabel: "Correction to make before approving",
457
+ send: "Send"
458
+ },
459
+ confirm: {
460
+ group: "Confirmation",
461
+ yes: "Yes",
462
+ no: "No",
463
+ yesValue: "yes",
464
+ noValue: "no"
465
+ },
466
+ choices: "Suggested options",
467
+ handles: {
468
+ picker: "Agents you can address",
469
+ unknown: "Nobody answers to that name here:",
470
+ instead: "You can address:"
471
+ },
472
+ selection: {
473
+ group: "Suggested choice",
474
+ single: "Pick one option.",
475
+ multiple: "Pick one or more options, then validate.",
476
+ validate: "Validate"
477
+ },
478
+ composer: {
479
+ label: "Your message",
480
+ send: "Send the message",
481
+ sendTitle: "Send",
482
+ stop: "Stop the answer",
483
+ stopTitle: "Stop",
484
+ attach: "Attach a file",
485
+ attachTitle: "Attach",
486
+ remove: "Remove {name}"
487
+ },
488
+ attachments: {
489
+ unsupported: "This kind of file cannot be attached to a message.",
490
+ tooLarge: "This file is too large.",
491
+ tooMany: "This message already carries as many files as it may.",
492
+ unreadable: "This file could not be read.",
493
+ failed: "This file could not be attached."
494
+ },
495
+ error: "Something went wrong, the assistant could not answer. Try again in a moment.",
496
+ withHuman: "A member of the team will reply to you here."
497
+ },
498
+ fr: {
499
+ heading: "Assistant",
500
+ subheading: "Squadico",
501
+ placeholder: "Posez votre question…",
502
+ greeting: "Bonjour ! Je suis votre assistant. Que souhaitez-vous faire ?",
503
+ hint: "L'assistant propose une action ; rien n'est appliqué sans votre confirmation.",
504
+ assistant: "Assistant",
505
+ typing: "L'assistant rédige sa réponse",
506
+ newConversation: "Nouvelle conversation",
507
+ close: "Fermer l'assistant",
508
+ closeTitle: "Fermer",
509
+ history: {
510
+ open: "Historique des conversations",
511
+ menu: "Conversations précédentes",
512
+ loading: "Chargement…",
513
+ empty: "Aucune conversation précédente.",
514
+ untitled: "Conversation"
515
+ },
516
+ context: { region: "Contexte transmis à l'assistant" },
517
+ approval: {
518
+ group: "Validation de l'écriture",
519
+ approve: "Oui, appliquer",
520
+ reject: "Non, annuler",
521
+ request: "L'agent souhaite utiliser {tool}.",
522
+ arguments: "Avec",
523
+ edit: "Modifier…",
524
+ correction: "Ce qu'il faut changer — ex. « l'échéance est lundi prochain »",
525
+ correctionLabel: "Correction à apporter avant validation",
526
+ send: "Envoyer"
527
+ },
528
+ confirm: {
529
+ group: "Confirmation",
530
+ yes: "Oui",
531
+ no: "Non",
532
+ yesValue: "oui",
533
+ noValue: "non"
534
+ },
535
+ choices: "Options proposées",
536
+ handles: {
537
+ picker: "Agents que vous pouvez adresser",
538
+ unknown: "Personne ne répond à ce nom ici :",
539
+ instead: "Vous pouvez adresser :"
540
+ },
541
+ selection: {
542
+ group: "Choix proposé",
543
+ single: "Sélectionnez une option.",
544
+ multiple: "Sélectionnez une ou plusieurs options, puis validez.",
545
+ validate: "Valider"
546
+ },
547
+ composer: {
548
+ label: "Votre message",
549
+ send: "Envoyer le message",
550
+ sendTitle: "Envoyer",
551
+ stop: "Interrompre la réponse",
552
+ stopTitle: "Interrompre",
553
+ attach: "Joindre un fichier",
554
+ attachTitle: "Joindre",
555
+ remove: "Retirer {name}"
556
+ },
557
+ attachments: {
558
+ unsupported: "Ce format de fichier ne peut pas être joint à un message.",
559
+ tooLarge: "Ce fichier est trop volumineux.",
560
+ tooMany: "Ce message porte déjà autant de fichiers qu'il le peut.",
561
+ unreadable: "Ce fichier n'a pas pu être lu.",
562
+ failed: "Impossible de joindre ce fichier."
563
+ },
564
+ error: "Une erreur est survenue, l'assistant n'a pas pu répondre. Réessayez dans un instant.",
565
+ withHuman: "Un membre de l'équipe va vous répondre ici."
566
+ },
567
+ es: {
568
+ heading: "Asistente",
569
+ subheading: "Squadico",
570
+ placeholder: "Haga su pregunta…",
571
+ greeting: "¡Hola! Soy su asistente. ¿Qué desea hacer?",
572
+ hint: "El asistente propone una acción; no se aplica nada sin su confirmación.",
573
+ assistant: "Asistente",
574
+ typing: "El asistente está redactando su respuesta",
575
+ newConversation: "Nueva conversación",
576
+ close: "Cerrar el asistente",
577
+ closeTitle: "Cerrar",
578
+ history: {
579
+ open: "Historial de conversaciones",
580
+ menu: "Conversaciones anteriores",
581
+ loading: "Cargando…",
582
+ empty: "Ninguna conversación anterior.",
583
+ untitled: "Conversación"
584
+ },
585
+ context: { region: "Contexto enviado al asistente" },
586
+ approval: {
587
+ group: "Validación de la escritura",
588
+ approve: "Sí, aplicar",
589
+ reject: "No, cancelar",
590
+ request: "El agente quiere usar {tool}.",
591
+ arguments: "Con",
592
+ edit: "Modificar…",
593
+ correction: "Lo que hay que cambiar — p. ej. «el vencimiento es el lunes»",
594
+ correctionLabel: "Corrección antes de validar",
595
+ send: "Enviar"
596
+ },
597
+ confirm: {
598
+ group: "Confirmación",
599
+ yes: "Sí",
600
+ no: "No",
601
+ yesValue: "sí",
602
+ noValue: "no"
603
+ },
604
+ choices: "Opciones propuestas",
605
+ handles: {
606
+ picker: "Agentes a los que puedes dirigirte",
607
+ unknown: "Nadie responde a ese nombre aquí:",
608
+ instead: "Puedes dirigirte a:"
609
+ },
610
+ selection: {
611
+ group: "Opción propuesta",
612
+ single: "Seleccione una opción.",
613
+ multiple: "Seleccione una o varias opciones y valide.",
614
+ validate: "Validar"
615
+ },
616
+ composer: {
617
+ label: "Su mensaje",
618
+ send: "Enviar el mensaje",
619
+ sendTitle: "Enviar",
620
+ stop: "Interrumpir la respuesta",
621
+ stopTitle: "Interrumpir",
622
+ attach: "Adjuntar un archivo",
623
+ attachTitle: "Adjuntar",
624
+ remove: "Quitar {name}"
625
+ },
626
+ attachments: {
627
+ unsupported: "Este tipo de archivo no se puede adjuntar a un mensaje.",
628
+ tooLarge: "Este archivo es demasiado grande.",
629
+ tooMany: "Este mensaje ya lleva todos los archivos que puede llevar.",
630
+ unreadable: "No se ha podido leer este archivo.",
631
+ failed: "No se ha podido adjuntar este archivo."
632
+ },
633
+ error: "Se ha producido un error, el asistente no ha podido responder. Inténtelo de nuevo.",
634
+ withHuman: "Un miembro del equipo le responderá aquí."
635
+ }
636
+ }, Pe = {
637
+ en: "en-GB",
638
+ fr: "fr-FR",
639
+ es: "es-ES"
640
+ };
641
+ function Fe(e) {
642
+ let t = e?.trim().toLowerCase().split(/[-_]/)[0];
643
+ return t && t in Ne ? t : void 0;
644
+ }
645
+ function Ie() {
646
+ return typeof navigator > "u" ? [] : navigator.languages?.length ? navigator.languages : [navigator.language];
647
+ }
648
+ function Le(e) {
649
+ let t = e?.trim(), n = (t ? [t] : Ie()).find(Fe), r = Fe(n) ?? "en";
650
+ return {
651
+ code: r,
652
+ tag: n?.includes("-") ? n : Pe[r],
653
+ t: Ne[r]
654
+ };
655
+ }
656
+ //#endregion
657
+ //#region src/lib/openState.ts
658
+ var Re = "squadico-chatbot:open";
659
+ function ze() {
660
+ try {
661
+ if (typeof sessionStorage > "u") return;
662
+ let e = sessionStorage.getItem(Re);
663
+ return e === "1" || e !== "0" && void 0;
664
+ } catch {
665
+ return;
666
+ }
667
+ }
668
+ function Be(e) {
669
+ try {
670
+ if (typeof sessionStorage > "u") return;
671
+ sessionStorage.setItem(Re, e ? "1" : "0");
672
+ } catch {}
673
+ }
674
+ function Ve(e, t) {
675
+ return t === !1 ? e ?? !1 : ze() ?? e ?? !1;
676
+ }
677
+ //#endregion
678
+ //#region src/lib/uid.ts
679
+ function He() {
680
+ let e = globalThis.crypto;
681
+ if (e && typeof e.randomUUID == "function") return e.randomUUID();
682
+ let t = /* @__PURE__ */ new Uint8Array(16);
683
+ if (e && typeof e.getRandomValues == "function") e.getRandomValues(t);
684
+ else for (let e = 0; e < 16; e++) t[e] = Math.floor(Math.random() * 256);
685
+ t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128;
686
+ let n = [];
687
+ for (let e = 0; e < 16; e++) n.push(t[e].toString(16).padStart(2, "0"));
688
+ return n.slice(0, 4).join("") + "-" + n.slice(4, 6).join("") + "-" + n.slice(6, 8).join("") + "-" + n.slice(8, 10).join("") + "-" + n.slice(10, 16).join("");
689
+ }
690
+ //#endregion
691
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/typeof.js
692
+ function Ue(e) {
693
+ "@babel/helpers - typeof";
694
+ return Ue = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
695
+ return typeof e;
696
+ } : function(e) {
697
+ return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
698
+ }, Ue(e);
699
+ }
700
+ //#endregion
701
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPrimitive.js
702
+ function We(e, t) {
703
+ if (Ue(e) != "object" || !e) return e;
704
+ var n = e[Symbol.toPrimitive];
705
+ if (n !== void 0) {
706
+ var r = n.call(e, t || "default");
707
+ if (Ue(r) != "object") return r;
708
+ throw TypeError("@@toPrimitive must return a primitive value.");
709
+ }
710
+ return (t === "string" ? String : Number)(e);
711
+ }
712
+ //#endregion
713
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/toPropertyKey.js
714
+ function Ge(e) {
715
+ var t = We(e, "string");
716
+ return Ue(t) == "symbol" ? t : t + "";
717
+ }
718
+ //#endregion
719
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/defineProperty.js
720
+ function Ke(e, t, n) {
721
+ return (t = Ge(t)) in e ? Object.defineProperty(e, t, {
722
+ value: n,
723
+ enumerable: !0,
724
+ configurable: !0,
725
+ writable: !0
726
+ }) : e[t] = n, e;
727
+ }
728
+ //#endregion
729
+ //#region src/lib/client.ts
730
+ var qe = "https://api.squadico.com", Je = 2e4, q = class extends Error {
731
+ constructor(e, t, n) {
732
+ super(e), Ke(this, "status", void 0), Ke(this, "code", void 0), this.name = "ChatHttpError", this.status = t, this.code = n;
733
+ }
734
+ };
735
+ function Ye(e, t) {
736
+ return `${e.replace(/\/+$/, "")}${t}`;
737
+ }
738
+ function Xe(e) {
739
+ return {
740
+ "Content-Type": "application/json",
741
+ Accept: "text/event-stream, application/json",
742
+ ...e ? { "X-Visitor-Token": e } : {}
743
+ };
744
+ }
745
+ function Ze(e) {
746
+ if (!e || typeof e != "object") return;
747
+ let { loc: t, msg: n } = e;
748
+ if (typeof n != "string" || !n) return;
749
+ let r = (Array.isArray(t) ? t.filter((e) => typeof e == "string") : []).at(-1);
750
+ return r && r !== "body" ? `${r}: ${n}` : n;
751
+ }
752
+ async function Qe(e) {
753
+ let t = "", n;
754
+ try {
755
+ let r = await e.text();
756
+ if (r) try {
757
+ let e = JSON.parse(r), i = e.detail ?? e.message;
758
+ if (Array.isArray(i)) {
759
+ let e = i.map((e) => Ze(e) ?? (typeof e == "string" ? e : void 0)).filter((e) => e !== void 0);
760
+ t = e.length > 0 ? e.join(", ") : r;
761
+ } else t = typeof i == "string" ? i : r;
762
+ n = typeof e.code == "string" ? e.code : void 0;
763
+ } catch {
764
+ t = r;
765
+ }
766
+ } catch {}
767
+ return new q(t || `The API answered ${e.status}`, e.status, n);
768
+ }
769
+ function $e(e) {
770
+ if (!e || typeof e != "object") return;
771
+ let t = e;
772
+ if (!(typeof t.handle != "string" || !t.handle)) return {
773
+ handle: t.handle,
774
+ name: typeof t.name == "string" ? t.name : t.handle,
775
+ avatarEmoji: typeof t.avatar_emoji == "string" ? t.avatar_emoji : void 0,
776
+ color: typeof t.color == "string" ? t.color : void 0
777
+ };
778
+ }
779
+ function et(e) {
780
+ return (Array.isArray(e) ? e : []).map($e).filter((e) => e !== void 0);
781
+ }
782
+ function tt(e) {
783
+ if (!e || typeof e != "object") return;
784
+ let t = e;
785
+ if (!(typeof t.tool_call_id != "string" || !t.tool_call_id)) return {
786
+ toolCallId: t.tool_call_id,
787
+ tool: typeof t.tool == "string" ? t.tool : "",
788
+ arguments: t.arguments && typeof t.arguments == "object" ? t.arguments : {}
789
+ };
790
+ }
791
+ var nt = /* @__PURE__ */ new Set(["user", "assistant"]);
792
+ function rt(e) {
793
+ if (typeof e.role != "string" || !nt.has(e.role) || typeof e.content != "string" || !e.content) return null;
794
+ let t = typeof e.created_at == "string" ? Date.parse(e.created_at) : NaN;
795
+ return {
796
+ id: typeof e.id == "string" && e.id ? e.id : He(),
797
+ role: e.role,
798
+ content: e.content,
799
+ createdAt: Number.isNaN(t) ? Date.now() : t,
800
+ agent: $e(e.agent),
801
+ attachments: it(e.attachments),
802
+ authorName: e.kind === "human" && typeof e.author_name == "string" && e.author_name ? e.author_name : void 0
803
+ };
804
+ }
805
+ function it(e) {
806
+ if (!Array.isArray(e)) return;
807
+ let t = e.map((e) => at(e)).filter((e) => e !== null);
808
+ return t.length > 0 ? t : void 0;
809
+ }
810
+ function at(e) {
811
+ if (!e || typeof e != "object") return null;
812
+ let { id: t, kind: n, filename: r, content_type: i } = e;
813
+ return typeof t != "string" || !t || typeof r != "string" || !r ? null : {
814
+ id: t,
815
+ kind: n === "image" ? "image" : "document",
816
+ filename: r,
817
+ contentType: typeof i == "string" ? i : "application/octet-stream"
818
+ };
819
+ }
820
+ async function ot(e) {
821
+ let t = await fetch(Ye(e.apiUrl, `/public/applications/${encodeURIComponent(e.embedKey)}/conversations`), {
822
+ method: "POST",
823
+ headers: Xe(),
824
+ body: JSON.stringify({
825
+ ...e.user ? { user: e.user } : {},
826
+ ...e.agent ? { agent: e.agent } : {}
827
+ }),
828
+ signal: e.signal
829
+ });
830
+ if (!t.ok) throw await Qe(t);
831
+ let n = await t.json();
832
+ if (typeof n.id != "string" || typeof n.visitor_token != "string") throw new q("The API opened a conversation without an id or a token");
833
+ let r = (Array.isArray(n.messages) ? n.messages : []).map(rt).filter((e) => e !== null);
834
+ return {
835
+ conversationId: n.id,
836
+ visitorToken: n.visitor_token,
837
+ agentName: typeof n.agent_name == "string" ? n.agent_name : "",
838
+ agentSlug: typeof n.agent_slug == "string" ? n.agent_slug : "",
839
+ welcomeMessage: typeof n.welcome_message == "string" && n.welcome_message ? n.welcome_message : void 0,
840
+ messages: r,
841
+ handles: et(n.handles),
842
+ agentHandle: typeof n.agent_handle == "string" && n.agent_handle ? n.agent_handle : void 0,
843
+ withHuman: typeof n.handling == "string" && n.handling !== "agents"
844
+ };
845
+ }
846
+ async function st(e) {
847
+ let t = await fetch(Ye(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}`), {
848
+ method: "GET",
849
+ headers: Xe(e.visitorToken),
850
+ signal: e.signal
851
+ });
852
+ if (!t.ok) throw await Qe(t);
853
+ let n = await t.json();
854
+ if (typeof n.id != "string") throw new q("The API replayed a conversation without an id");
855
+ return {
856
+ conversationId: n.id,
857
+ visitorToken: e.visitorToken,
858
+ agentName: typeof n.agent_name == "string" ? n.agent_name : "",
859
+ agentSlug: typeof n.agent_slug == "string" ? n.agent_slug : "",
860
+ welcomeMessage: typeof n.welcome_message == "string" && n.welcome_message ? n.welcome_message : void 0,
861
+ messages: (Array.isArray(n.messages) ? n.messages : []).map(rt).filter((e) => e !== null),
862
+ handles: et(n.handles),
863
+ agentHandle: typeof n.agent_handle == "string" && n.agent_handle ? n.agent_handle : void 0,
864
+ withHuman: typeof n.handling == "string" && n.handling !== "agents"
865
+ };
866
+ }
867
+ async function ct(e) {
868
+ let t = new FormData();
869
+ t.append("file", e.file);
870
+ let n = await fetch(dt(e), {
871
+ method: "POST",
872
+ headers: { "X-Visitor-Token": e.visitorToken },
873
+ body: t,
874
+ signal: e.signal
875
+ });
876
+ if (!n.ok) throw await Qe(n);
877
+ let r = at(await n.json());
878
+ if (!r) throw new q("The upload could not be read", n.status);
879
+ return r;
880
+ }
881
+ async function lt(e) {
882
+ let t = await fetch(`${dt(e)}/${encodeURIComponent(e.attachmentId)}`, {
883
+ method: "DELETE",
884
+ headers: { "X-Visitor-Token": e.visitorToken },
885
+ signal: e.signal
886
+ });
887
+ if (!t.ok) throw await Qe(t);
888
+ }
889
+ async function ut(e) {
890
+ let t = await fetch(`${dt(e)}/${encodeURIComponent(e.attachmentId)}/content`, {
891
+ headers: { "X-Visitor-Token": e.visitorToken },
892
+ signal: e.signal
893
+ });
894
+ if (!t.ok) throw await Qe(t);
895
+ return t.blob();
896
+ }
897
+ function dt(e) {
898
+ return Ye(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/attachments`);
899
+ }
900
+ async function ft(e) {
901
+ return mt(Ye(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/messages`), {
902
+ content: e.message,
903
+ attachment_ids: e.attachmentIds ?? [],
904
+ ...e.context && Object.keys(e.context).length > 0 ? { context: e.context } : {}
905
+ }, e);
906
+ }
907
+ async function pt(e) {
908
+ return mt(Ye(e.apiUrl, `/public/conversations/${encodeURIComponent(e.conversationId)}/approvals`), {
909
+ tool_call_id: e.toolCallId,
910
+ approved: e.approved
911
+ }, e);
912
+ }
913
+ async function mt(e, t, n) {
914
+ let r = await fetch(e, {
915
+ method: "POST",
916
+ headers: Xe(n.visitorToken),
917
+ body: JSON.stringify(t),
918
+ signal: n.signal
919
+ });
920
+ if (!r.ok) throw await Qe(r);
921
+ if (!r.body) throw new q("Answer with no stream body");
922
+ let i = r.body.getReader(), a = new TextDecoder(), o = "", s = "", c = "", l, u, d = { answer: "" };
923
+ try {
924
+ for (;;) {
925
+ let { value: e, done: t } = await i.read();
926
+ if (t) break;
927
+ o += a.decode(e, { stream: !0 });
928
+ let r = o.split("\n");
929
+ o = r.pop() ?? "";
930
+ for (let e of r) {
931
+ let t = e.trim();
932
+ if (!t) {
933
+ s = "";
934
+ continue;
935
+ }
936
+ if (t.startsWith("event:")) {
937
+ s = t.slice(6).trim();
938
+ continue;
939
+ }
940
+ if (!t.startsWith("data:")) continue;
941
+ let r = t.slice(5).trim();
942
+ if (!r) continue;
943
+ let i;
944
+ try {
945
+ i = JSON.parse(r);
946
+ } catch {
947
+ continue;
948
+ }
949
+ s === "token" && typeof i.text == "string" ? (c += i.text, n.onToken(i.text)) : s === "done" ? (d.answer = typeof i.content == "string" ? i.content : c, d.agent = $e(i.agent), typeof i.unknown_handle == "string" && i.unknown_handle && (d.unknownHandle = i.unknown_handle, d.offered = et(i.handles))) : s === "handoff" ? (typeof i.to_agent_name == "string" && (u = i.to_agent_name), c = "") : s === "escalated" ? d.withHuman = !0 : s === "held" ? (d.held = !0, d.withHuman = !0) : s === "approval_required" ? d.approval = tt(i) : s === "error" && (l = typeof i.detail == "string" ? i.detail : "The turn failed");
950
+ }
951
+ if (l) break;
952
+ }
953
+ } finally {
954
+ i.cancel().catch(() => void 0);
955
+ }
956
+ if (l) throw new q(l);
957
+ return !d.answer && !d.approval && (d.answer = c), u && !d.agent && (d.authorName = u), d;
958
+ }
959
+ //#endregion
960
+ //#region src/lib/conversation.ts
961
+ var ht = "squadico-chatbot:conversation";
962
+ function gt() {
963
+ try {
964
+ if (typeof sessionStorage > "u") return;
965
+ let e = sessionStorage.getItem(ht);
966
+ if (!e) return;
967
+ let t = JSON.parse(e);
968
+ return !t.sessionId || !t.visitorToken || !t.embedKey ? void 0 : {
969
+ sessionId: t.sessionId,
970
+ visitorToken: t.visitorToken,
971
+ embedKey: t.embedKey,
972
+ user: typeof t.user == "string" ? t.user : void 0
973
+ };
974
+ } catch {
975
+ return;
976
+ }
977
+ }
978
+ function _t(e) {
979
+ try {
980
+ if (typeof sessionStorage > "u") return;
981
+ sessionStorage.setItem(ht, JSON.stringify(e));
982
+ } catch {}
983
+ }
984
+ function vt() {
985
+ try {
986
+ if (typeof sessionStorage > "u") return;
987
+ sessionStorage.removeItem(ht);
988
+ } catch {}
989
+ }
990
+ function yt(e, { embedKey: t, user: n }) {
991
+ return e.embedKey === t && e.user === n;
992
+ }
993
+ //#endregion
994
+ //#region src/lib/useChat.ts
995
+ function bt(e) {
996
+ let t = e instanceof q ? e.status : void 0;
997
+ return t === 415 ? "unsupported" : t === 413 ? "tooLarge" : t === 409 ? "tooMany" : t === 422 ? "unreadable" : "failed";
998
+ }
999
+ var xt = 5e3;
1000
+ function St(e) {
1001
+ return e instanceof q && e.code === "conversation_retired";
1002
+ }
1003
+ function Ct(e) {
1004
+ let [t, n] = H([]), [r, i] = H(!1), [a, o] = H(""), [s, c] = H([]), [l, u] = H(""), [d, f] = H(null), [p, m] = H(!1), [h, g] = H([]), [_, v] = H([]), [y, b] = H(null), x = W(null), S = W(e);
1005
+ S.current = e;
1006
+ let C = W(null), w = W(null), T = W(void 0), E = e.greeting, D = G(() => E ? {
1007
+ id: "greeting",
1008
+ role: "assistant",
1009
+ content: E,
1010
+ createdAt: Date.now()
1011
+ } : null, [E]), O = K((e) => {
1012
+ S.current.onEvent?.(e);
1013
+ }, []), k = K((e, t) => {
1014
+ n((n) => n.map((n) => n.id === e ? {
1015
+ ...n,
1016
+ ...t
1017
+ } : n));
1018
+ }, []), A = K((e, t) => {
1019
+ let n = e instanceof q ? e.status : void 0, r = e instanceof Error ? e.message : String(e), i = (S.current.locale ?? Le(void 0)).t.error;
1020
+ t && k(t, {
1021
+ content: i,
1022
+ streaming: !1,
1023
+ error: !0
1024
+ }), O({
1025
+ type: "chatbot-error",
1026
+ message: r,
1027
+ status: n,
1028
+ sessionId: w.current?.sessionId ?? ""
1029
+ }), typeof console < "u" && console.error("[squadico-chatbot]", r);
1030
+ }, [O, k]), j = K(async () => {
1031
+ if (w.current) return w.current;
1032
+ if (C.current) return C.current;
1033
+ let e = S.current;
1034
+ if (!e.embedKey) throw new q("No embed key: nothing says which application to open");
1035
+ let t = e.user, r = e.apiUrl ?? "https://api.squadico.com", i = e.embedKey, a = (r) => {
1036
+ let a = {
1037
+ sessionId: r.conversationId,
1038
+ visitorToken: r.visitorToken
1039
+ };
1040
+ return w.current = a, T.current = t?.id, _t({
1041
+ ...a,
1042
+ embedKey: i,
1043
+ user: t?.id
1044
+ }), o(r.conversationId), c(r.handles), u(e.agent && r.agentHandle ? r.agentHandle : ""), m(!!r.withHuman), r.messages.length > 0 && n((e) => [...r.messages, ...e]), a;
1045
+ }, s = () => ot({
1046
+ apiUrl: r,
1047
+ embedKey: i,
1048
+ user: t,
1049
+ agent: e.agent
1050
+ }).then(a), l = gt(), d = l && yt(l, {
1051
+ embedKey: i,
1052
+ user: t?.id
1053
+ }) ? st({
1054
+ apiUrl: r,
1055
+ conversationId: l.sessionId,
1056
+ visitorToken: l.visitorToken
1057
+ }).then(a).catch(() => (vt(), s())) : s();
1058
+ C.current = d;
1059
+ try {
1060
+ return await d;
1061
+ } finally {
1062
+ C.current = null;
1063
+ }
1064
+ }, []), M = K(() => {
1065
+ w.current || C.current || j().catch((e) => A(e));
1066
+ }, [j, A]), N = K((e, t, { retry: r = !1, carried: a = [] } = {}) => {
1067
+ if (x.current) return;
1068
+ let o = new AbortController();
1069
+ x.current = o, i(!0), f(null);
1070
+ let s = He();
1071
+ n((t) => [
1072
+ ...t,
1073
+ {
1074
+ id: He(),
1075
+ role: "user",
1076
+ content: e,
1077
+ createdAt: Date.now(),
1078
+ attachments: a.length > 0 ? a : void 0
1079
+ },
1080
+ {
1081
+ id: s,
1082
+ role: "assistant",
1083
+ content: "",
1084
+ createdAt: Date.now(),
1085
+ streaming: !0
1086
+ }
1087
+ ]), (async () => {
1088
+ let i = await j();
1089
+ O({
1090
+ type: "chatbot-message",
1091
+ role: "user",
1092
+ content: e,
1093
+ sessionId: i.sessionId
1094
+ });
1095
+ let a = "", c = (e) => {
1096
+ a += e, k(s, { content: a });
1097
+ }, l;
1098
+ try {
1099
+ l = await t(i, c, o.signal);
1100
+ } catch (e) {
1101
+ if (!St(e) || (vt(), w.current = null, C.current = null, !r)) throw e;
1102
+ i = await j(), a = "", k(s, { content: "" }), l = await t(i, c, o.signal);
1103
+ }
1104
+ if (l.withHuman && m(!0), l.held) {
1105
+ n((e) => e.filter((e) => e.id !== s));
1106
+ return;
1107
+ }
1108
+ k(s, {
1109
+ content: l.answer,
1110
+ streaming: !1,
1111
+ agent: l.agent,
1112
+ authorName: l.authorName,
1113
+ approval: l.approval,
1114
+ unknownHandle: l.unknownHandle,
1115
+ offered: l.offered
1116
+ }), f(l.approval ?? null), O({
1117
+ type: "chatbot-message",
1118
+ role: "assistant",
1119
+ content: l.answer,
1120
+ sessionId: i.sessionId,
1121
+ agent: l.agent?.handle
1122
+ });
1123
+ })().catch((e) => {
1124
+ if (o.signal.aborted) {
1125
+ k(s, { streaming: !1 });
1126
+ return;
1127
+ }
1128
+ A(e, s);
1129
+ }).finally(() => {
1130
+ x.current = null, i(!1);
1131
+ });
1132
+ }, [
1133
+ j,
1134
+ O,
1135
+ A,
1136
+ k
1137
+ ]), P = K((e) => {
1138
+ let t = e.trim();
1139
+ if (!t && h.length === 0) return;
1140
+ let n = h;
1141
+ g([]), b(null), N(t, (e, r, i) => ft({
1142
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1143
+ conversationId: e.sessionId,
1144
+ visitorToken: e.visitorToken,
1145
+ message: t,
1146
+ attachmentIds: n.map((e) => e.id),
1147
+ context: S.current.context ? Ae(S.current.context) : void 0,
1148
+ onToken: r,
1149
+ signal: i
1150
+ }), {
1151
+ retry: !0,
1152
+ carried: n
1153
+ });
1154
+ }, [h, N]), F = K((e) => {
1155
+ b(null), v((t) => [...t, e.name]), j().then((t) => ct({
1156
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1157
+ conversationId: t.sessionId,
1158
+ visitorToken: t.visitorToken,
1159
+ file: e
1160
+ })).then((e) => g((t) => [...t, e])).catch((e) => b(bt(e))).finally(() => v((t) => {
1161
+ let n = t.indexOf(e.name);
1162
+ return n < 0 ? t : [...t.slice(0, n), ...t.slice(n + 1)];
1163
+ }));
1164
+ }, [j]), I = K((e) => {
1165
+ g((t) => t.filter((t) => t.id !== e));
1166
+ let t = w.current;
1167
+ t && lt({
1168
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1169
+ conversationId: t.sessionId,
1170
+ visitorToken: t.visitorToken,
1171
+ attachmentId: e
1172
+ }).catch(() => {});
1173
+ }, []), L = K(async (e) => {
1174
+ let t = w.current;
1175
+ if (!t) throw new q("No conversation to read that file from");
1176
+ return ut({
1177
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1178
+ conversationId: t.sessionId,
1179
+ visitorToken: t.visitorToken,
1180
+ attachmentId: e
1181
+ });
1182
+ }, []), ee = K((e, t) => {
1183
+ let n = d;
1184
+ n && N(t, (t, r, i) => pt({
1185
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1186
+ conversationId: t.sessionId,
1187
+ visitorToken: t.visitorToken,
1188
+ toolCallId: n.toolCallId,
1189
+ approved: e,
1190
+ onToken: r,
1191
+ signal: i
1192
+ }));
1193
+ }, [d, N]), R = K(() => {
1194
+ x.current?.abort(), x.current = null, i(!1);
1195
+ }, []), te = K(() => {
1196
+ x.current?.abort(), x.current = null, w.current = null, C.current = null, T.current = void 0, vt(), i(!1), f(null), m(!1), o(""), u(""), n([]), O({
1197
+ type: "chatbot-reset",
1198
+ sessionId: ""
1199
+ });
1200
+ }, [O]), z = e.humanPollMs ?? xt;
1201
+ U(() => {
1202
+ if (!p || !a) return;
1203
+ let e = setInterval(() => {
1204
+ let e = w.current;
1205
+ !e || x.current || st({
1206
+ apiUrl: S.current.apiUrl ?? "https://api.squadico.com",
1207
+ conversationId: e.sessionId,
1208
+ visitorToken: e.visitorToken
1209
+ }).then((e) => {
1210
+ n(e.messages), m(!!e.withHuman);
1211
+ }).catch(() => {});
1212
+ }, z);
1213
+ return () => clearInterval(e);
1214
+ }, [
1215
+ p,
1216
+ a,
1217
+ z
1218
+ ]);
1219
+ let ne = e.user?.id;
1220
+ return U(() => {
1221
+ w.current && T.current !== ne && te();
1222
+ }, [ne, te]), {
1223
+ messages: G(() => t.length === 0 && D ? [D] : t, [D, t]),
1224
+ busy: r,
1225
+ sessionId: a,
1226
+ handles: s,
1227
+ addressee: l,
1228
+ approval: d,
1229
+ withHuman: p,
1230
+ start: M,
1231
+ send: P,
1232
+ attachments: h,
1233
+ uploading: _,
1234
+ attachmentError: y,
1235
+ attach: F,
1236
+ detach: I,
1237
+ loadAttachment: L,
1238
+ decide: ee,
1239
+ stop: R,
1240
+ reset: te
1241
+ };
1242
+ }
1243
+ //#endregion
1244
+ //#region node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
1245
+ var wt = 0;
1246
+ Array.isArray;
1247
+ function J(e, n, r, i, a, o) {
1248
+ n || (n = {});
1249
+ var s, c, l = n;
1250
+ if ("ref" in l) for (c in l = {}, n) c == "ref" ? s = n[c] : l[c] = n[c];
1251
+ var u = {
1252
+ type: e,
1253
+ props: l,
1254
+ key: r,
1255
+ ref: s,
1256
+ __k: null,
1257
+ __: null,
1258
+ __b: 0,
1259
+ __e: null,
1260
+ __c: null,
1261
+ constructor: void 0,
1262
+ __v: --wt,
1263
+ __i: -1,
1264
+ __u: 0,
1265
+ __source: a,
1266
+ __self: o
1267
+ };
1268
+ if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
1269
+ return t.vnode && t.vnode(u), u;
1270
+ }
1271
+ //#endregion
1272
+ //#region src/components/Composer.tsx
1273
+ var Tt = 132, Et = "image/png,image/jpeg,image/gif,image/webp,application/pdf,.docx,.txt,.md,.csv,.json", Dt = /^[a-zA-Z0-9_-]*$/;
1274
+ function Ot(e, t) {
1275
+ let n = e.slice(0, t), r = n.lastIndexOf("@");
1276
+ if (r < 0 || r > 0 && !/\s/.test(n[r - 1] ?? "")) return null;
1277
+ let i = n.slice(r + 1);
1278
+ return Dt.test(i) ? {
1279
+ start: r,
1280
+ query: i
1281
+ } : null;
1282
+ }
1283
+ function kt({ placeholder: e, locale: t, busy: n, autoFocus: r, handles: i, addressee: a, attachments: o = [], uploading: s = [], attachmentError: c, onAttach: l, onDetach: u, onSend: d, onStop: f }) {
1284
+ let [p, m] = H(""), [h, g] = H(null), [_, v] = H(0), [y, b] = H(!1), x = W(null), C = W(null), w = !!l, T = s.length > 0, E = G(() => {
1285
+ if (!h || !i || i.length === 0) return [];
1286
+ let e = h.query.toLowerCase();
1287
+ return i.filter((t) => t.handle.startsWith(e));
1288
+ }, [i, h]), D = E.length > 0, O = K(() => {
1289
+ let e = x.current;
1290
+ if (!e) return;
1291
+ e.style.height = "auto";
1292
+ let t = e.scrollHeight > Tt;
1293
+ e.style.height = `${Math.min(e.scrollHeight, Tt)}px`, e.style.overflowY = t ? "auto" : "hidden";
1294
+ }, []);
1295
+ U(() => {
1296
+ r && x.current?.focus(), O();
1297
+ }, [r, O]), U(() => {
1298
+ a && (m((e) => e || `@${a} `), requestAnimationFrame(O));
1299
+ }, [a, O]);
1300
+ let k = K((e) => {
1301
+ g(Ot(e.value, e.selectionStart ?? e.value.length)), v(0);
1302
+ }, []), A = K((e) => {
1303
+ let t = x.current;
1304
+ if (!t || !h) return;
1305
+ let n = t.selectionStart ?? t.value.length, r = `${p.slice(0, h.start)}@${e} ${p.slice(n)}`, i = h.start + e.length + 2;
1306
+ m(r), g(null), requestAnimationFrame(() => {
1307
+ t.focus(), t.setSelectionRange(i, i), O();
1308
+ });
1309
+ }, [
1310
+ O,
1311
+ h,
1312
+ p
1313
+ ]), j = K((e) => {
1314
+ if (!(!l || !e)) for (let t of Array.from(e)) l(t);
1315
+ }, [l]), M = K(() => {
1316
+ let e = p.trim();
1317
+ !e && o.length === 0 || n || T || (d(e), m(""), g(null), requestAnimationFrame(O));
1318
+ }, [
1319
+ o.length,
1320
+ n,
1321
+ O,
1322
+ d,
1323
+ p,
1324
+ T
1325
+ ]), N = K((e) => {
1326
+ if (D && !e.isComposing) {
1327
+ if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1328
+ e.preventDefault();
1329
+ let t = e.key === "ArrowDown" ? 1 : E.length - 1;
1330
+ v((e) => (e + t) % E.length);
1331
+ return;
1332
+ }
1333
+ if (e.key === "Enter" || e.key === "Tab") {
1334
+ e.preventDefault(), A((E[_] ?? E[0]).handle);
1335
+ return;
1336
+ }
1337
+ if (e.key === "Escape") {
1338
+ e.preventDefault(), e.stopPropagation(), g(null);
1339
+ return;
1340
+ }
1341
+ }
1342
+ e.key === "Enter" && !e.shiftKey && !e.isComposing && (e.preventDefault(), M());
1343
+ }, [
1344
+ _,
1345
+ E,
1346
+ A,
1347
+ D,
1348
+ M
1349
+ ]), P = Je - p.length;
1350
+ return /* @__PURE__ */ J("form", {
1351
+ class: `sqc-composer${y ? " sqc-composer--dropping" : ""}`,
1352
+ onSubmit: (e) => {
1353
+ e.preventDefault(), M();
1354
+ },
1355
+ onDragOver: (e) => {
1356
+ w && (e.preventDefault(), b(!0));
1357
+ },
1358
+ onDragLeave: () => b(!1),
1359
+ onDrop: (e) => {
1360
+ w && (e.preventDefault(), b(!1), j(e.dataTransfer?.files ?? null));
1361
+ },
1362
+ children: [
1363
+ (o.length > 0 || T || c) && /* @__PURE__ */ J("div", {
1364
+ class: "sqc-attachments",
1365
+ children: [
1366
+ o.map((e) => /* @__PURE__ */ J("span", {
1367
+ class: "sqc-chip",
1368
+ "data-kind": e.kind,
1369
+ children: [/* @__PURE__ */ J("span", {
1370
+ class: "sqc-chip__name",
1371
+ children: e.filename
1372
+ }), /* @__PURE__ */ J("button", {
1373
+ type: "button",
1374
+ class: "sqc-chip__remove",
1375
+ "aria-label": t.t.composer.remove.replace("{name}", e.filename),
1376
+ onClick: () => u?.(e.id),
1377
+ children: "×"
1378
+ })]
1379
+ }, e.id)),
1380
+ s.map((e) => /* @__PURE__ */ J("span", {
1381
+ class: "sqc-chip sqc-chip--waiting",
1382
+ children: /* @__PURE__ */ J("span", {
1383
+ class: "sqc-chip__name",
1384
+ children: e
1385
+ })
1386
+ }, e)),
1387
+ c && /* @__PURE__ */ J("p", {
1388
+ class: "sqc-attachments__error",
1389
+ role: "status",
1390
+ children: c
1391
+ })
1392
+ ]
1393
+ }),
1394
+ /* @__PURE__ */ J("div", {
1395
+ class: "sqc-composer__field",
1396
+ children: [
1397
+ D && /* @__PURE__ */ J("ul", {
1398
+ class: "sqc-mentions",
1399
+ role: "listbox",
1400
+ "aria-label": t.t.handles.picker,
1401
+ children: E.map((e, t) => /* @__PURE__ */ J("li", {
1402
+ role: "option",
1403
+ "aria-selected": t === _,
1404
+ class: `sqc-mention${t === _ ? " sqc-mention--active" : ""}`,
1405
+ onMouseDown: (e) => e.preventDefault(),
1406
+ onMouseEnter: () => v(t),
1407
+ onClick: () => A(e.handle),
1408
+ children: [
1409
+ /* @__PURE__ */ J("span", {
1410
+ class: "sqc-mention__icon",
1411
+ "aria-hidden": "true",
1412
+ children: e.avatarEmoji ?? "@"
1413
+ }),
1414
+ /* @__PURE__ */ J("span", {
1415
+ class: "sqc-mention__handle",
1416
+ children: ["@", e.handle]
1417
+ }),
1418
+ /* @__PURE__ */ J("span", {
1419
+ class: "sqc-mention__name",
1420
+ children: e.name
1421
+ })
1422
+ ]
1423
+ }, e.handle))
1424
+ }),
1425
+ /* @__PURE__ */ J("textarea", {
1426
+ ref: x,
1427
+ class: "sqc-composer__input",
1428
+ rows: 1,
1429
+ value: p,
1430
+ placeholder: e,
1431
+ maxLength: Je,
1432
+ "aria-label": t.t.composer.label,
1433
+ onInput: (e) => {
1434
+ m(e.currentTarget.value), k(e.currentTarget), O();
1435
+ },
1436
+ onKeyDown: N,
1437
+ onClick: (e) => k(e.currentTarget),
1438
+ onPaste: (e) => {
1439
+ let t = e.clipboardData?.files;
1440
+ !w || !t || t.length === 0 || (e.preventDefault(), j(t));
1441
+ }
1442
+ }),
1443
+ P <= 200 && /* @__PURE__ */ J("span", {
1444
+ class: "sqc-composer__count",
1445
+ "aria-live": "polite",
1446
+ children: P
1447
+ })
1448
+ ]
1449
+ }),
1450
+ w && /* @__PURE__ */ J(S, { children: [/* @__PURE__ */ J("input", {
1451
+ ref: C,
1452
+ type: "file",
1453
+ multiple: !0,
1454
+ accept: Et,
1455
+ class: "sqc-file-input",
1456
+ onChange: (e) => {
1457
+ j(e.currentTarget.files), e.currentTarget.value = "";
1458
+ }
1459
+ }), /* @__PURE__ */ J("button", {
1460
+ type: "button",
1461
+ class: "sqc-btn sqc-btn--attach",
1462
+ onClick: () => C.current?.click(),
1463
+ "aria-label": t.t.composer.attach,
1464
+ title: t.t.composer.attachTitle,
1465
+ children: /* @__PURE__ */ J("svg", {
1466
+ viewBox: "0 0 24 24",
1467
+ fill: "none",
1468
+ stroke: "currentColor",
1469
+ "stroke-width": "1.9",
1470
+ "stroke-linecap": "round",
1471
+ "stroke-linejoin": "round",
1472
+ "aria-hidden": "true",
1473
+ children: /* @__PURE__ */ J("path", { d: "M21 11.5l-8.8 8.8a5 5 0 01-7.1-7.1l9-9a3.3 3.3 0 014.7 4.7l-9 9a1.6 1.6 0 01-2.3-2.3l8.3-8.3" })
1474
+ })
1475
+ })] }),
1476
+ n ? /* @__PURE__ */ J("button", {
1477
+ type: "button",
1478
+ class: "sqc-btn sqc-btn--stop",
1479
+ onClick: f,
1480
+ "aria-label": t.t.composer.stop,
1481
+ title: t.t.composer.stopTitle,
1482
+ children: /* @__PURE__ */ J("svg", {
1483
+ viewBox: "0 0 24 24",
1484
+ "aria-hidden": "true",
1485
+ children: /* @__PURE__ */ J("rect", {
1486
+ x: "7",
1487
+ y: "7",
1488
+ width: "10",
1489
+ height: "10",
1490
+ rx: "2",
1491
+ fill: "currentColor"
1492
+ })
1493
+ })
1494
+ }) : /* @__PURE__ */ J("button", {
1495
+ type: "submit",
1496
+ class: "sqc-btn sqc-btn--send",
1497
+ disabled: !p.trim() && o.length === 0 || T,
1498
+ "aria-label": t.t.composer.send,
1499
+ title: t.t.composer.sendTitle,
1500
+ children: /* @__PURE__ */ J("svg", {
1501
+ viewBox: "0 0 24 24",
1502
+ fill: "none",
1503
+ stroke: "currentColor",
1504
+ "stroke-width": "1.9",
1505
+ "stroke-linecap": "round",
1506
+ "stroke-linejoin": "round",
1507
+ "aria-hidden": "true",
1508
+ children: /* @__PURE__ */ J("path", { d: "M5 12l14-7-5 14-2.5-5.5L5 12z" })
1509
+ })
1510
+ })
1511
+ ]
1512
+ });
1513
+ }
1514
+ //#endregion
1515
+ //#region src/lib/confirm.ts
1516
+ var At = {
1517
+ fr: /\br[ée]ponde?z? +«?\s*oui\b/i,
1518
+ en: /\b(?:reply|answer|respond) +[“"']?\s*yes\b/i,
1519
+ es: /\bresponda?e?d? +«?\s*s[íi]\b/i
1520
+ }, jt = {
1521
+ fr: [
1522
+ /\b(?:confirmes?[- ]tu|confirmez[- ]vous)\b/i,
1523
+ /\b(?:valides?[- ]tu|validez[- ]vous)\b/i,
1524
+ /\b(?:es[- ]tu s[ûu]re?|[êe]tes[- ]vous s[ûu]re?s?)\b/i,
1525
+ /\b(?:dois[- ]je|puis[- ]je)\b/i,
1526
+ /\b(?:je continue|on continue|on y va|je lance)\b/i,
1527
+ At.fr
1528
+ ],
1529
+ en: [
1530
+ /\bdo you confirm\b/i,
1531
+ /\bdo you (?:want|wish) me to\b/i,
1532
+ /\b(?:shall|should) I\b/i,
1533
+ /\bare you sure\b/i,
1534
+ /\b(?:shall we|should I) (?:proceed|continue|go ahead)\b/i,
1535
+ At.en
1536
+ ],
1537
+ es: [
1538
+ /\b(?:confirmas|confirma|confirm[áa]is)\b/i,
1539
+ /\b(?:validas|valida|valid[áa]is)\b/i,
1540
+ /\best[áa]s? seguro\b/i,
1541
+ /\b(?:contin[úu]o|procedo|lo lanzo|lo hago)\b/i,
1542
+ /\bquieres? que\b/i,
1543
+ At.es
1544
+ ]
1545
+ }, Mt = /^\s*(?:[-*•]\s+)?\[[ xX]\]\s+/m;
1546
+ function Nt(e, t = "en") {
1547
+ if (Mt.test(e)) return !1;
1548
+ let n = e.split("\n").map((e) => e.trim()).filter(Boolean), r = n[n.length - 1];
1549
+ return !r || !r.includes("?") && !At[t].test(r) ? !1 : jt[t].some((e) => e.test(r));
1550
+ }
1551
+ //#endregion
1552
+ //#region src/components/Approval.tsx
1553
+ var Pt = /^mcp_[0-9a-f]{8}_/;
1554
+ function Ft(e) {
1555
+ let t = e.replace(Pt, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().toLowerCase();
1556
+ return t ? t.charAt(0).toUpperCase() + t.slice(1) : e;
1557
+ }
1558
+ function It(e) {
1559
+ return typeof e == "string" ? e : JSON.stringify(e) ?? String(e);
1560
+ }
1561
+ function Lt({ locale: e, call: t, onDecide: n }) {
1562
+ let { approval: r, confirm: i } = e.t, [a, o] = H(null), s = !!n && a === null, c = (e, t) => {
1563
+ o(t), n?.(e, t);
1564
+ }, l = t ? Object.entries(t.arguments) : [];
1565
+ return /* @__PURE__ */ J("div", {
1566
+ class: "sqc-approval",
1567
+ role: "group",
1568
+ "aria-label": r.group,
1569
+ children: [
1570
+ t && /* @__PURE__ */ J("p", {
1571
+ class: "sqc-approval__request",
1572
+ "data-testid": "sqc-approval-tool",
1573
+ children: r.request.replace("{tool}", Ft(t.tool))
1574
+ }),
1575
+ l.length > 0 && /* @__PURE__ */ J("dl", {
1576
+ class: "sqc-approval__args",
1577
+ "data-testid": "sqc-approval-arguments",
1578
+ children: l.map(([e, t]) => /* @__PURE__ */ J("div", {
1579
+ class: "sqc-approval__arg",
1580
+ children: [/* @__PURE__ */ J("dt", {
1581
+ class: "sqc-approval__arg-name",
1582
+ children: Ft(e)
1583
+ }), /* @__PURE__ */ J("dd", {
1584
+ class: "sqc-approval__arg-value",
1585
+ children: It(t)
1586
+ })]
1587
+ }, e))
1588
+ }),
1589
+ /* @__PURE__ */ J("div", {
1590
+ class: "sqc-approval__actions",
1591
+ children: [/* @__PURE__ */ J("button", {
1592
+ type: "button",
1593
+ class: "sqc-approval__btn sqc-approval__btn--yes",
1594
+ "aria-pressed": a === i.yes,
1595
+ disabled: !s,
1596
+ onClick: () => c(!0, i.yes),
1597
+ children: r.approve
1598
+ }), /* @__PURE__ */ J("button", {
1599
+ type: "button",
1600
+ class: "sqc-approval__btn sqc-approval__btn--no",
1601
+ "aria-pressed": a === i.no,
1602
+ disabled: !s,
1603
+ onClick: () => c(!1, i.no),
1604
+ children: r.reject
1605
+ })]
1606
+ })
1607
+ ]
1608
+ });
1609
+ }
1610
+ //#endregion
1611
+ //#region src/components/Confirm.tsx
1612
+ function Rt({ locale: e, onPick: t }) {
1613
+ let [n, r] = H(null), i = !!t && n === null, { confirm: a } = e.t, o = [{
1614
+ value: a.yesValue,
1615
+ label: a.yes,
1616
+ kind: "yes"
1617
+ }, {
1618
+ value: a.noValue,
1619
+ label: a.no,
1620
+ kind: "no"
1621
+ }];
1622
+ return /* @__PURE__ */ J("div", {
1623
+ class: "sqc-confirm",
1624
+ role: "group",
1625
+ "aria-label": a.group,
1626
+ children: o.map((e) => /* @__PURE__ */ J("button", {
1627
+ type: "button",
1628
+ class: `sqc-confirm__btn sqc-confirm__btn--${e.kind}`,
1629
+ "aria-pressed": n === e.value,
1630
+ disabled: !i,
1631
+ onClick: () => {
1632
+ r(e.value), t?.(e.value);
1633
+ },
1634
+ children: e.label
1635
+ }, e.value))
1636
+ });
1637
+ }
1638
+ //#endregion
1639
+ //#region src/components/Choices.tsx
1640
+ function zt() {
1641
+ return /* @__PURE__ */ J("svg", {
1642
+ viewBox: "0 0 16 16",
1643
+ fill: "none",
1644
+ stroke: "currentColor",
1645
+ "stroke-width": "2.2",
1646
+ "aria-hidden": "true",
1647
+ children: /* @__PURE__ */ J("path", {
1648
+ d: "M3.5 8.5l3 3 6-7",
1649
+ "stroke-linecap": "round",
1650
+ "stroke-linejoin": "round"
1651
+ })
1652
+ });
1653
+ }
1654
+ function Bt({ items: e, locale: t, onPick: n }) {
1655
+ let [r, i] = H(null), a = !!n && r === null;
1656
+ return /* @__PURE__ */ J("div", {
1657
+ class: "sqc-choices",
1658
+ role: "group",
1659
+ "aria-label": t.t.choices,
1660
+ children: e.map((e, t) => {
1661
+ let o = r === null ? e.checked : r === e.label;
1662
+ return /* @__PURE__ */ J("button", {
1663
+ type: "button",
1664
+ class: "sqc-choice",
1665
+ "aria-pressed": o,
1666
+ disabled: !a,
1667
+ onClick: () => {
1668
+ i(e.label), n?.(e.label);
1669
+ },
1670
+ children: [/* @__PURE__ */ J("span", {
1671
+ class: `sqc-choice__box${o ? " sqc-choice__box--on" : ""}`,
1672
+ "aria-hidden": "true",
1673
+ children: o && /* @__PURE__ */ J(zt, {})
1674
+ }), /* @__PURE__ */ J("span", {
1675
+ class: "sqc-choice__label",
1676
+ children: e.content
1677
+ })]
1678
+ }, `${t}-${e.label}`);
1679
+ })
1680
+ });
1681
+ }
1682
+ //#endregion
1683
+ //#region src/components/RichText.tsx
1684
+ var Vt = /(\*\*[^*\n]+\*\*|`[^`\n]+`|~~[^~\n]+~~|\[[^\]\n]+\]\([^)\s]+\)|\*[^*\n]+\*|https?:\/\/[^\s<>()]+)/g, Ht = /^\[([^\]\n]+)\]\(([^)\s]+)\)$/, Ut = /^(https?:|mailto:)/i;
1685
+ function Wt(e, t, n) {
1686
+ return Ut.test(e) ? /* @__PURE__ */ J("a", {
1687
+ href: e,
1688
+ target: "_blank",
1689
+ rel: "noopener noreferrer",
1690
+ children: t
1691
+ }, n) : t;
1692
+ }
1693
+ function Y(e, t) {
1694
+ let n = e.split(Vt), r = [];
1695
+ return n.forEach((e, n) => {
1696
+ if (!e) return;
1697
+ let i = `${t}-${n}`, a = Ht.exec(e);
1698
+ e.startsWith("**") && e.endsWith("**") && e.length > 4 ? r.push(/* @__PURE__ */ J("strong", { children: e.slice(2, -2) }, i)) : e.startsWith("`") && e.endsWith("`") && e.length > 2 ? r.push(/* @__PURE__ */ J("code", { children: e.slice(1, -1) }, i)) : e.startsWith("~~") && e.endsWith("~~") && e.length > 4 ? r.push(/* @__PURE__ */ J("del", { children: e.slice(2, -2) }, i)) : a ? r.push(Wt(a[2], a[1], i)) : e.startsWith("*") && e.endsWith("*") && e.length > 2 ? r.push(/* @__PURE__ */ J("em", { children: e.slice(1, -1) }, i)) : /^https?:\/\//.test(e) ? r.push(Wt(e, e, i)) : r.push(e);
1699
+ }), r;
1700
+ }
1701
+ var Gt = /^\s*(?:[-*•]\s+)?\[([ xX])\]\s+(.+)$/;
1702
+ function Kt(e) {
1703
+ return e.replace(/\[([^\]\n]+)\]\([^)\s]+\)/g, "$1").replace(/\*\*|~~|`|\*/g, "").trim();
1704
+ }
1705
+ var qt = /^(\s*)[-*•]\s+/, Jt = /^(\s*)\d+[.)]\s+/, Yt = /^\s{0,3}(#{1,6})\s+(.+?)#*\s*$/, Xt = /^\s*([-*_])(?:\s*\1){2,}\s*$/, Zt = /^\s*>\s?(.*)$/, Qt = /^\s*\|.*\|\s*$/, $t = /^\s*\|(?:\s*:?-{1,}:?\s*\|)+\s*$/, en = /^\s*```/;
1706
+ function tn(e) {
1707
+ return e.replace(/^\s*\|/, "").replace(/\|\s*$/, "").split("|").map((e) => e.trim());
1708
+ }
1709
+ function nn(e, t, n, r) {
1710
+ let i = e[t].ordered, a = [], o = t;
1711
+ for (; o < e.length && e[o].depth >= n;) {
1712
+ let t = e[o];
1713
+ if (t.depth === n && t.ordered !== i) break;
1714
+ if (t.depth > n) {
1715
+ let [n, i] = nn(e, o, t.depth, `${r}-${o}`), s = a[a.length - 1];
1716
+ s ? s.nested.push(n) : a.push({
1717
+ key: `${r}-${o}`,
1718
+ text: null,
1719
+ nested: [n]
1720
+ }), o = i;
1721
+ continue;
1722
+ }
1723
+ a.push({
1724
+ key: `${r}-${o}`,
1725
+ text: t.text,
1726
+ nested: []
1727
+ }), o += 1;
1728
+ }
1729
+ let s = a.map((e) => /* @__PURE__ */ J("li", { children: [e.text === null ? null : Y(e.text, e.key), e.nested] }, e.key));
1730
+ return [J(i ? "ol" : "ul", { children: s }, r), o];
1731
+ }
1732
+ function rn({ text: e, locale: t, onChoice: n }) {
1733
+ let r = e.split("\n"), i = [], a = [], o = [], s = [], c = () => {
1734
+ if (!a.length) return;
1735
+ let e = `p${i.length}`;
1736
+ i.push(/* @__PURE__ */ J("p", { children: Y(a.join("\n"), e) }, e)), a = [];
1737
+ }, l = () => {
1738
+ if (!o.length) return;
1739
+ let e = 0;
1740
+ for (; e < o.length;) {
1741
+ let t = `l${i.length}`, [n, r] = nn(o, e, o[e].depth, t);
1742
+ i.push(n), e = r;
1743
+ }
1744
+ o = [];
1745
+ }, u = () => {
1746
+ if (!s.length) return;
1747
+ let e = `q${i.length}`;
1748
+ i.push(/* @__PURE__ */ J("blockquote", { children: Y(s.join("\n"), e) }, e)), s = [];
1749
+ }, d = () => {
1750
+ c(), l(), u();
1751
+ };
1752
+ for (let e = 0; e < r.length; e += 1) {
1753
+ let f = r[e];
1754
+ if (en.test(f)) {
1755
+ d();
1756
+ let t = [];
1757
+ for (e += 1; e < r.length && !en.test(r[e]);) t.push(r[e]), e += 1;
1758
+ let n = `c${i.length}`;
1759
+ i.push(/* @__PURE__ */ J("pre", { children: /* @__PURE__ */ J("code", { children: t.join("\n") }) }, n));
1760
+ continue;
1761
+ }
1762
+ if (Qt.test(f) && e + 1 < r.length && $t.test(r[e + 1])) {
1763
+ d();
1764
+ let t = tn(f), n = [];
1765
+ for (e += 2; e < r.length && Qt.test(r[e]);) n.push(tn(r[e])), e += 1;
1766
+ --e;
1767
+ let a = `t${i.length}`;
1768
+ i.push(/* @__PURE__ */ J("div", {
1769
+ class: "sqc-table",
1770
+ children: /* @__PURE__ */ J("table", { children: [/* @__PURE__ */ J("thead", { children: /* @__PURE__ */ J("tr", { children: t.map((e, t) => /* @__PURE__ */ J("th", { children: Y(e, `${a}-h${t}`) }, `${a}-h${t}`)) }) }), /* @__PURE__ */ J("tbody", { children: n.map((e, n) => /* @__PURE__ */ J("tr", { children: t.map((t, r) => /* @__PURE__ */ J("td", { children: Y(e[r] ?? "", `${a}-r${n}c${r}`) }, `${a}-r${n}c${r}`)) }, `${a}-r${n}`)) })] })
1771
+ }, a));
1772
+ continue;
1773
+ }
1774
+ if (!f.trim()) {
1775
+ d();
1776
+ continue;
1777
+ }
1778
+ if (Gt.test(f)) {
1779
+ d();
1780
+ let a = [];
1781
+ for (; e < r.length;) {
1782
+ let t = Gt.exec(r[e]);
1783
+ if (!t) break;
1784
+ let n = t[2].trim(), o = `o${i.length}-${a.length}`;
1785
+ a.push({
1786
+ label: Kt(n),
1787
+ checked: t[1].toLowerCase() === "x",
1788
+ content: Y(n, o)
1789
+ }), e += 1;
1790
+ }
1791
+ --e, i.push(/* @__PURE__ */ J(Bt, {
1792
+ items: a,
1793
+ locale: t,
1794
+ onPick: n
1795
+ }, `o${i.length}`));
1796
+ continue;
1797
+ }
1798
+ let p = Yt.exec(f);
1799
+ if (p) {
1800
+ d();
1801
+ let e = p[1].length, t = e <= 2 ? "h3" : e === 3 ? "h4" : "h5", n = `h${i.length}`;
1802
+ i.push(/* @__PURE__ */ J(t, { children: Y(p[2], n) }, n));
1803
+ continue;
1804
+ }
1805
+ if (Xt.test(f)) {
1806
+ d(), i.push(/* @__PURE__ */ J("hr", {}, `r${i.length}`));
1807
+ continue;
1808
+ }
1809
+ let m = Zt.exec(f);
1810
+ if (m) {
1811
+ c(), l(), s.push(m[1]);
1812
+ continue;
1813
+ }
1814
+ let h = qt.exec(f), g = h ? null : Jt.exec(f), _ = h ?? g;
1815
+ if (_) {
1816
+ c(), u(), o.push({
1817
+ depth: _[1].replace(/\t/g, " ").length,
1818
+ ordered: !!g,
1819
+ text: f.slice(_[0].length)
1820
+ });
1821
+ continue;
1822
+ }
1823
+ l(), u(), a.push(f);
1824
+ }
1825
+ return d(), /* @__PURE__ */ J(S, { children: i });
1826
+ }
1827
+ //#endregion
1828
+ //#region src/components/MessageList.tsx
1829
+ var an = 80;
1830
+ function on({ at: e, locale: t }) {
1831
+ let n = new Date(e);
1832
+ return /* @__PURE__ */ J("time", {
1833
+ class: "sqc-msg__time",
1834
+ dateTime: n.toISOString(),
1835
+ children: n.toLocaleTimeString(t.tag, {
1836
+ hour: "2-digit",
1837
+ minute: "2-digit"
1838
+ })
1839
+ });
1840
+ }
1841
+ function sn({ file: e, load: t }) {
1842
+ let [n, r] = H(null);
1843
+ return U(() => {
1844
+ let n = null, i = !0;
1845
+ return t(e.id).then((e) => {
1846
+ i && (n = URL.createObjectURL(e), r(n));
1847
+ }).catch(() => {}), () => {
1848
+ i = !1, n && URL.revokeObjectURL(n);
1849
+ };
1850
+ }, [e.id, t]), n ? /* @__PURE__ */ J("img", {
1851
+ class: "sqc-attachment__image",
1852
+ src: n,
1853
+ alt: e.filename
1854
+ }) : /* @__PURE__ */ J("span", {
1855
+ class: "sqc-chip sqc-chip--waiting",
1856
+ children: e.filename
1857
+ });
1858
+ }
1859
+ function cn({ files: e, load: t }) {
1860
+ return e.length === 0 || !t ? null : /* @__PURE__ */ J("div", {
1861
+ class: "sqc-attachments sqc-attachments--sent",
1862
+ children: e.map((e) => e.kind === "image" ? /* @__PURE__ */ J(sn, {
1863
+ file: e,
1864
+ load: t
1865
+ }, e.id) : /* @__PURE__ */ J("span", {
1866
+ class: "sqc-chip",
1867
+ "data-kind": "document",
1868
+ children: /* @__PURE__ */ J("span", {
1869
+ class: "sqc-chip__name",
1870
+ children: e.filename
1871
+ })
1872
+ }, e.id))
1873
+ });
1874
+ }
1875
+ function ln({ message: e, locale: t, assistantName: n, onChoice: r, onDecide: i, onLoadAttachment: a }) {
1876
+ let o = e.streaming && !e.content, s = !!e.approval;
1877
+ return /* @__PURE__ */ J("div", {
1878
+ class: `sqc-msg sqc-msg--${e.role}${e.error ? " sqc-msg--error" : ""}`,
1879
+ children: [e.role === "assistant" && /* @__PURE__ */ J("div", {
1880
+ class: "sqc-msg__who",
1881
+ children: [e.agent?.avatarEmoji ? /* @__PURE__ */ J("span", {
1882
+ class: "sqc-msg__emoji",
1883
+ "aria-hidden": "true",
1884
+ children: e.agent.avatarEmoji
1885
+ }) : /* @__PURE__ */ J(dn, {}), e.authorName ?? e.agent?.name ?? n]
1886
+ }), /* @__PURE__ */ J("div", {
1887
+ class: "sqc-msg__bubble",
1888
+ children: [o ? /* @__PURE__ */ J("span", {
1889
+ class: "sqc-typing",
1890
+ "aria-label": t.t.typing,
1891
+ children: [
1892
+ /* @__PURE__ */ J("i", {}),
1893
+ /* @__PURE__ */ J("i", {}),
1894
+ /* @__PURE__ */ J("i", {})
1895
+ ]
1896
+ }) : /* @__PURE__ */ J("div", {
1897
+ class: "sqc-msg__body",
1898
+ children: [
1899
+ /* @__PURE__ */ J(rn, {
1900
+ text: e.content,
1901
+ locale: t,
1902
+ onChoice: r
1903
+ }),
1904
+ e.streaming && /* @__PURE__ */ J("span", {
1905
+ class: "sqc-caret",
1906
+ "aria-hidden": "true"
1907
+ }),
1908
+ s && /* @__PURE__ */ J(Lt, {
1909
+ locale: t,
1910
+ call: e.content.trim() === "" ? e.approval : void 0,
1911
+ onDecide: i
1912
+ }),
1913
+ !s && !e.streaming && !e.error && Nt(e.content, t.code) && /* @__PURE__ */ J(Rt, {
1914
+ locale: t,
1915
+ onPick: r
1916
+ }),
1917
+ e.unknownHandle && !e.streaming && /* @__PURE__ */ J(un, {
1918
+ message: e,
1919
+ locale: t
1920
+ }),
1921
+ /* @__PURE__ */ J(cn, {
1922
+ files: e.attachments ?? [],
1923
+ load: a
1924
+ })
1925
+ ]
1926
+ }), !o && /* @__PURE__ */ J(on, {
1927
+ at: e.createdAt,
1928
+ locale: t
1929
+ })]
1930
+ })]
1931
+ });
1932
+ }
1933
+ function un({ message: e, locale: t }) {
1934
+ let n = e.offered ?? [];
1935
+ return /* @__PURE__ */ J("p", {
1936
+ class: "sqc-msg__unaddressed",
1937
+ children: [
1938
+ /* @__PURE__ */ J("span", { children: t.t.handles.unknown }),
1939
+ " ",
1940
+ /* @__PURE__ */ J("code", { children: ["@", e.unknownHandle] }),
1941
+ n.length > 0 && /* @__PURE__ */ J(S, { children: [
1942
+ " ",
1943
+ /* @__PURE__ */ J("span", { children: t.t.handles.instead }),
1944
+ " ",
1945
+ n.map((e) => /* @__PURE__ */ J("code", { children: ["@", e.handle] }, e.handle))
1946
+ ] })
1947
+ ]
1948
+ });
1949
+ }
1950
+ function dn() {
1951
+ return /* @__PURE__ */ J("svg", {
1952
+ viewBox: "0 0 24 24",
1953
+ fill: "none",
1954
+ stroke: "currentColor",
1955
+ "stroke-width": "2",
1956
+ "stroke-linecap": "round",
1957
+ "stroke-linejoin": "round",
1958
+ "aria-hidden": "true",
1959
+ children: /* @__PURE__ */ J("path", { d: "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" })
1960
+ });
1961
+ }
1962
+ function fn({ messages: e, locale: t, assistantName: n, suggestions: r, showSuggestions: i, busy: a, withHuman: o, onSuggestion: s, onChoice: c, onDecide: l, onLoadAttachment: u }) {
1963
+ let d = W(null), f = W(!0);
1964
+ return ve(() => {
1965
+ let e = d.current;
1966
+ e && f.current && (e.scrollTop = e.scrollHeight);
1967
+ }, [e]), U(() => {
1968
+ let e = d.current;
1969
+ if (!e) return;
1970
+ let t = () => {
1971
+ f.current = e.scrollHeight - e.scrollTop - e.clientHeight < an;
1972
+ };
1973
+ return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1974
+ }, []), /* @__PURE__ */ J("div", {
1975
+ class: "sqc-messages",
1976
+ ref: d,
1977
+ role: "log",
1978
+ "aria-live": "polite",
1979
+ "aria-atomic": "false",
1980
+ children: [
1981
+ e.map((r, i) => /* @__PURE__ */ J(ln, {
1982
+ message: r,
1983
+ locale: t,
1984
+ assistantName: n,
1985
+ onChoice: !a && r.role === "assistant" && i === e.length - 1 ? c : void 0,
1986
+ onDecide: !a && r.role === "assistant" && i === e.length - 1 ? l : void 0,
1987
+ onLoadAttachment: u
1988
+ }, r.id)),
1989
+ o && /* @__PURE__ */ J("p", {
1990
+ class: "sqc-with-human",
1991
+ role: "status",
1992
+ children: t.t.withHuman
1993
+ }),
1994
+ i && r && r.length > 0 && /* @__PURE__ */ J("div", {
1995
+ class: "sqc-suggestions",
1996
+ children: r.map((e) => /* @__PURE__ */ J("button", {
1997
+ type: "button",
1998
+ class: "sqc-suggestion",
1999
+ onClick: () => s(e),
2000
+ children: e
2001
+ }, e))
2002
+ })
2003
+ ]
2004
+ });
2005
+ }
2006
+ //#endregion
2007
+ //#region src/components/ChatbotWidget.tsx
2008
+ var pn = { width: "min(392px, 100vw)" }, mn = /* @__PURE__ */ new Set(["sessionId"]);
2009
+ function hn(e) {
2010
+ let t = e.replace(/Id$|Ref$/, "").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[_-]+/g, " ").trim().toLowerCase();
2011
+ return t ? t.charAt(0).toUpperCase() + t.slice(1) : e;
2012
+ }
2013
+ function gn(e) {
2014
+ if (!e) return [];
2015
+ let t = [];
2016
+ for (let [n, r] of Object.entries(e)) {
2017
+ if (mn.has(n) || typeof r != "string" && !ke(r)) continue;
2018
+ let e = Oe(r);
2019
+ e && t.push({
2020
+ label: hn(n),
2021
+ value: e
2022
+ });
2023
+ }
2024
+ return t;
2025
+ }
2026
+ function _n(e, t) {
2027
+ return e?.trim() ? e : t;
2028
+ }
2029
+ function vn(e) {
2030
+ let [t, n] = H(!1);
2031
+ return U(() => {
2032
+ if (e !== "auto" || typeof matchMedia != "function") return;
2033
+ let t = matchMedia("(prefers-color-scheme: dark)");
2034
+ n(t.matches);
2035
+ let r = (e) => n(e.matches);
2036
+ return t.addEventListener("change", r), () => t.removeEventListener("change", r);
2037
+ }, [e]), e === "dark" ? "dark" : e === "light" ? "light" : t ? "dark" : "light";
2038
+ }
2039
+ function yn(e) {
2040
+ let t = e.persistOpen ?? !0, [n, r] = H(() => Ve(e.defaultOpen, t)), [i, a] = H(!1), [o, s] = H(!1), c = W(null), l = W(null), u = vn(e.theme ?? "light"), d = G(() => Le(e.locale), [e.locale]), f = d.t, p = _n(e.heading, f.heading), m = _n(e.assistantName, f.assistant), h = _n(e.greeting, f.greeting), g = e.onEvent, { send: _, reset: v, decide: y, stop: b, start: x, busy: S, messages: C, withHuman: w, sessionId: T, handles: E, addressee: D, attachments: O, uploading: k, attachmentError: A, attach: j, detach: M, loadAttachment: N } = Ct({
2041
+ embedKey: e.embedKey,
2042
+ user: e.user,
2043
+ agent: e.agent,
2044
+ context: e.context,
2045
+ greeting: h,
2046
+ locale: d,
2047
+ onEvent: g
2048
+ });
2049
+ U(() => {
2050
+ !n && C.some((e) => e.role === "assistant" && e.id !== "greeting") && s(!0);
2051
+ }, [C, n]);
2052
+ let P = W(n);
2053
+ P.current = n;
2054
+ let F = K(() => {
2055
+ s(!1), !P.current && (P.current = !0, r(!0), t && Be(!0), g?.({
2056
+ type: "chatbot-open",
2057
+ sessionId: T
2058
+ }));
2059
+ }, [
2060
+ g,
2061
+ t,
2062
+ T
2063
+ ]), I = K(() => {
2064
+ P.current && (P.current = !1, r(!1), t && Be(!1), g?.({
2065
+ type: "chatbot-close",
2066
+ sessionId: T
2067
+ }), l.current?.focus());
2068
+ }, [
2069
+ g,
2070
+ t,
2071
+ T
2072
+ ]);
2073
+ U(() => {
2074
+ n && x();
2075
+ }, [n, x]);
2076
+ let L = K((e) => {
2077
+ a(!0), _(e);
2078
+ }, [_]), ee = K(() => {
2079
+ a(!1), s(!1), v();
2080
+ }, [v]), R = W({
2081
+ openPanel: F,
2082
+ closePanel: I,
2083
+ send: L,
2084
+ reset: ee,
2085
+ sessionId: T
2086
+ });
2087
+ R.current = {
2088
+ openPanel: F,
2089
+ closePanel: I,
2090
+ send: L,
2091
+ reset: ee,
2092
+ sessionId: T
2093
+ };
2094
+ let te = W({
2095
+ open: () => R.current.openPanel(),
2096
+ close: () => R.current.closePanel(),
2097
+ toggle: () => P.current ? R.current.closePanel() : R.current.openPanel(),
2098
+ reset: () => R.current.reset(),
2099
+ send: (e) => {
2100
+ R.current.openPanel(), R.current.send(e);
2101
+ },
2102
+ isOpen: () => P.current,
2103
+ sessionId: () => R.current.sessionId
2104
+ }), z = e.bind;
2105
+ ve(() => (z?.(te.current), () => z?.(null)), [z]), U(() => {
2106
+ if (!n) return;
2107
+ let e = (e) => {
2108
+ e.key === "Escape" && (e.stopPropagation(), I());
2109
+ };
2110
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
2111
+ }, [I, n]);
2112
+ let ne = G(() => C.some((e) => e.id !== "greeting"), [C]), re = G(() => gn(e.context), [e.context]), ie = {
2113
+ ...e.accent ? { "--sqc-accent": e.accent } : {},
2114
+ "--sqc-width": e.width ?? pn.width
2115
+ };
2116
+ return /* @__PURE__ */ J("div", {
2117
+ class: "sqc",
2118
+ "data-theme": u,
2119
+ "data-position": e.position ?? "bottom-right",
2120
+ "data-open": n ? "true" : "false",
2121
+ style: ie,
2122
+ children: [/* @__PURE__ */ J("button", {
2123
+ ref: l,
2124
+ type: "button",
2125
+ class: "sqc-launcher",
2126
+ "aria-label": p,
2127
+ "aria-expanded": n,
2128
+ "aria-haspopup": "dialog",
2129
+ onClick: F,
2130
+ children: [/* @__PURE__ */ J("span", {
2131
+ class: "sqc-launcher__icon",
2132
+ children: /* @__PURE__ */ J("slot", {
2133
+ name: "launcher-icon",
2134
+ class: "sqc-slot-icon",
2135
+ children: /* @__PURE__ */ J(dn, {})
2136
+ })
2137
+ }), o && /* @__PURE__ */ J("span", {
2138
+ class: "sqc-launcher__badge",
2139
+ "aria-hidden": "true"
2140
+ })]
2141
+ }), /* @__PURE__ */ J("aside", {
2142
+ ref: c,
2143
+ class: "sqc-panel",
2144
+ role: "dialog",
2145
+ "aria-modal": "false",
2146
+ "aria-label": p,
2147
+ ...n ? {} : { inert: !0 },
2148
+ children: [
2149
+ /* @__PURE__ */ J("header", {
2150
+ class: "sqc-header",
2151
+ children: [
2152
+ /* @__PURE__ */ J("span", {
2153
+ class: "sqc-header__icon",
2154
+ "aria-hidden": "true",
2155
+ children: /* @__PURE__ */ J(dn, {})
2156
+ }),
2157
+ /* @__PURE__ */ J("div", {
2158
+ class: "sqc-header__titles",
2159
+ children: [/* @__PURE__ */ J("p", {
2160
+ class: "sqc-header__heading",
2161
+ children: p
2162
+ }), /* @__PURE__ */ J("p", {
2163
+ class: "sqc-header__sub",
2164
+ children: _n(e.subheading, f.subheading)
2165
+ })]
2166
+ }),
2167
+ /* @__PURE__ */ J("button", {
2168
+ type: "button",
2169
+ class: "sqc-icon-btn",
2170
+ onClick: ee,
2171
+ "aria-label": f.newConversation,
2172
+ "data-tip": f.newConversation,
2173
+ children: /* @__PURE__ */ J("svg", {
2174
+ viewBox: "0 0 24 24",
2175
+ fill: "none",
2176
+ stroke: "currentColor",
2177
+ "stroke-width": "1.8",
2178
+ children: /* @__PURE__ */ J("path", {
2179
+ d: "M20 12a8 8 0 1 1-2.6-5.9M20 4v4h-4",
2180
+ "stroke-linecap": "round"
2181
+ })
2182
+ })
2183
+ }),
2184
+ /* @__PURE__ */ J("button", {
2185
+ type: "button",
2186
+ class: "sqc-icon-btn",
2187
+ onClick: I,
2188
+ "aria-label": f.close,
2189
+ "data-tip": f.closeTitle,
2190
+ children: /* @__PURE__ */ J("svg", {
2191
+ viewBox: "0 0 24 24",
2192
+ fill: "none",
2193
+ stroke: "currentColor",
2194
+ "stroke-width": "1.8",
2195
+ children: /* @__PURE__ */ J("path", {
2196
+ d: "M6 6l12 12M18 6L6 18",
2197
+ "stroke-linecap": "round"
2198
+ })
2199
+ })
2200
+ })
2201
+ ]
2202
+ }),
2203
+ re.length > 0 && /* @__PURE__ */ J("div", {
2204
+ class: "sqc-context",
2205
+ "aria-label": f.context.region,
2206
+ children: re.map((e) => /* @__PURE__ */ J("span", {
2207
+ class: "sqc-chip",
2208
+ title: `${e.label}: ${e.value}`,
2209
+ children: [/* @__PURE__ */ J("b", { children: e.label }), e.value]
2210
+ }, e.label))
2211
+ }),
2212
+ /* @__PURE__ */ J(fn, {
2213
+ messages: C,
2214
+ locale: d,
2215
+ assistantName: m,
2216
+ suggestions: e.suggestions,
2217
+ showSuggestions: !i && !ne,
2218
+ busy: S,
2219
+ withHuman: w,
2220
+ onSuggestion: L,
2221
+ onChoice: L,
2222
+ onDecide: y,
2223
+ onLoadAttachment: N
2224
+ }),
2225
+ /* @__PURE__ */ J(kt, {
2226
+ placeholder: _n(e.placeholder, f.placeholder),
2227
+ locale: d,
2228
+ busy: S,
2229
+ autoFocus: n,
2230
+ handles: E,
2231
+ addressee: D,
2232
+ attachments: O,
2233
+ uploading: k,
2234
+ attachmentError: A ? f.attachments[A] : void 0,
2235
+ onAttach: j,
2236
+ onDetach: M,
2237
+ onSend: L,
2238
+ onStop: b
2239
+ }),
2240
+ /* @__PURE__ */ J("p", {
2241
+ class: "sqc-hint",
2242
+ children: f.hint
2243
+ })
2244
+ ]
2245
+ })]
2246
+ });
2247
+ }
2248
+ //#endregion
2249
+ //#region src/styles.css?inline
2250
+ var bn = ":host{--sqc-width:min(392px, 100vw);--sqc-z:2147480000;--sqc-radius:16px;--sqc-font-family:\"Plus Jakarta Sans\", ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;--sqc-font-heading:var(--sqc-font-family);z-index:var(--sqc-z);pointer-events:none;font-family:var(--sqc-font-family);-webkit-font-smoothing:antialiased;text-align:left;font-size:14px;line-height:1.5;display:block;position:fixed;top:0;bottom:0;left:0;right:0;margin:0!important}:host([hidden]){display:none}.sqc{--sqc-neutral-50:#f8fafc;--sqc-neutral-100:#f1f5f9;--sqc-neutral-200:#e2e8f0;--sqc-neutral-300:#cbd5e1;--sqc-neutral-400:#94a3b8;--sqc-neutral-500:#64748b;--sqc-neutral-600:#475569;--sqc-neutral-900:#0f172a;--sqc-error-50:#fff1f2;--sqc-error-100:#ffe4e6;--sqc-error-600:#e11d48;--sqc-accent-default:#000;--sqc-accent-color:var(--sqc-accent,var(--sqc-accent-default));--sqc-on-accent:#fff;--sqc-accent-hover:color-mix(in oklab, var(--sqc-accent-color) 84%, var(--sqc-on-accent));--sqc-accent-fg:var(--sqc-accent,var(--sqc-text));--sqc-bg:#fff;--sqc-surface:var(--sqc-neutral-50);--sqc-selected:var(--sqc-neutral-100);--sqc-border:var(--sqc-neutral-200);--sqc-border-strong:var(--sqc-neutral-300);--sqc-text:var(--sqc-neutral-900);--sqc-text-muted:var(--sqc-neutral-500);--sqc-link:#2563eb;--sqc-bubble-user:var(--sqc-accent-color);--sqc-bubble-user-text:var(--sqc-on-accent);--sqc-code-bg:var(--sqc-neutral-100);--sqc-disabled:var(--sqc-neutral-300);--sqc-shadow:0 10px 15px -3px #0f172a1a, 0 4px 6px -4px #0f172a1a;--sqc-shadow-bottom:0 6px 8px -6px #0f172a2e;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #0f172a4d;--sqc-focus-input:0 0 0 3px #0f172a1a;--sqc-danger:var(--sqc-error-600);color:var(--sqc-text);position:absolute;top:0;bottom:0;left:0;right:0}.sqc[data-theme=dark]{--sqc-neutral-50:#172033;--sqc-neutral-100:#1e293b;--sqc-neutral-200:#334155;--sqc-neutral-300:#475569;--sqc-neutral-400:#64748b;--sqc-neutral-500:#94a3b8;--sqc-neutral-600:#cbd5e1;--sqc-neutral-900:#f8fafc;--sqc-error-50:#2a0a12;--sqc-error-100:#4c0519;--sqc-error-600:#fb7185;--sqc-accent-default:#fff;--sqc-on-accent:#0f172a;--sqc-bg:#0f172a;--sqc-link:#60a5fa;--sqc-code-bg:#020617;--sqc-shadow:0 10px 24px -4px #0000008c;--sqc-shadow-bottom:0 6px 8px -6px #0000008c;--sqc-focus:0 0 0 2px var(--sqc-bg), 0 0 0 4px #f8fafc59;--sqc-focus-input:0 0 0 3px #f8fafc1f}@supports (color:oklch(from red l c h)){.sqc{--sqc-on-accent:oklch(from var(--sqc-accent-color) clamp(.208, (.62 - l) * 1000, 1) 0 0)}}.sqc *,.sqc :before,.sqc :after{box-sizing:border-box}.sqc-launcher{background:var(--sqc-accent-color);width:56px;height:56px;color:var(--sqc-on-accent);cursor:pointer;pointer-events:auto;box-shadow:var(--sqc-shadow);border:none;border-radius:50%;place-items:center;padding:0;transition:transform .18s,opacity .18s,background .18s,box-shadow .18s;display:grid;position:absolute;bottom:24px;right:24px}.sqc[data-position=bottom-left] .sqc-launcher{left:24px;right:auto}.sqc-launcher:hover{background:var(--sqc-accent-hover);transform:scale(1.06)}.sqc-launcher:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc[data-open=true] .sqc-launcher{opacity:0;pointer-events:none;transform:scale(.5)}.sqc-launcher__icon svg{width:26px;height:26px;display:block}.sqc-slot-icon::slotted(*){justify-content:center;align-items:center;width:26px;height:26px;display:inline-flex}.sqc-launcher__badge{background:var(--sqc-error-600);border:2px solid var(--sqc-bg);border-radius:50%;width:12px;height:12px;position:absolute;top:6px;right:6px}.sqc-panel{width:var(--sqc-width);background:var(--sqc-bg);border-left:1px solid var(--sqc-border);box-shadow:var(--sqc-shadow);pointer-events:auto;visibility:hidden;flex-direction:column;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility 0s linear .26s;display:flex;position:absolute;top:0;bottom:0;right:0;transform:translate(100%)}.sqc[data-open=true] .sqc-panel{visibility:visible;transition:transform .26s cubic-bezier(.22,1,.36,1),visibility;transform:translate(0)}.sqc-header{background:var(--sqc-bg);color:var(--sqc-text);border-bottom:1px solid var(--sqc-border);flex-shrink:0;align-items:center;gap:8px;padding:13px 12px 13px 16px;display:flex}.sqc-header__icon{color:var(--sqc-accent-fg);flex-shrink:0;place-items:center;display:grid}.sqc-header__icon svg{width:17px;height:17px;display:block}.sqc-header__titles{flex:1;min-width:0}.sqc-header__heading,.sqc-header__sub{text-overflow:ellipsis;white-space:nowrap;margin:0;overflow:hidden}.sqc-header__heading{font-family:var(--sqc-font-heading);letter-spacing:-.2px;font-size:15px;font-weight:700}.sqc-header__sub{color:var(--sqc-text-muted);font-size:12px}.sqc-icon-btn{width:26px;height:26px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:none;border-radius:8px;flex-shrink:0;place-items:center;transition:background .15s;display:grid}.sqc-icon-btn:hover{background:var(--sqc-surface);color:var(--sqc-text)}.sqc-icon-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-icon-btn svg{width:16px;height:16px}.sqc-icon-btn[data-tip]{position:relative}.sqc-icon-btn[data-tip]:after{content:attr(data-tip);z-index:6;background:var(--sqc-text);color:var(--sqc-bg);font-family:var(--sqc-font-family);white-space:nowrap;pointer-events:none;opacity:0;border-radius:8px;padding:4px 8px;font-size:11px;font-weight:500;line-height:1.3;transition:opacity .12s .15s;position:absolute;top:calc(100% + 6px);right:0}.sqc-icon-btn[data-tip]:hover:after{opacity:1}.sqc-icon-btn[data-tip]:focus-visible:after{opacity:1}.sqc-history-pop{z-index:5;position:absolute;top:54px;left:0;right:0}.sqc-history{background:var(--sqc-bg);max-height:320px;box-shadow:var(--sqc-shadow-bottom);flex-direction:column;display:flex;overflow-y:auto}.sqc-history__empty{color:var(--sqc-text-muted);text-align:center;margin:0;padding:14px 16px;font-size:12px}.sqc-history__item{border:none;border-bottom:1px solid var(--sqc-border);width:100%;color:var(--sqc-text);text-align:left;cursor:pointer;background:0 0;flex-direction:column;gap:2px;padding:10px 16px;transition:background .15s;display:flex}.sqc-history__item:last-child{border-bottom:none}.sqc-history__item:hover{background:var(--sqc-surface)}.sqc-history__item:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-history__item[aria-current=true]{background:var(--sqc-selected)}.sqc-history__item[aria-current=true] .sqc-history__title{color:var(--sqc-text);font-weight:600}.sqc-history__title{text-overflow:ellipsis;white-space:nowrap;font-size:13px;overflow:hidden}.sqc-history__date{color:var(--sqc-text-muted);font-size:11px}.sqc-context{background:var(--sqc-selected);border:1px solid var(--sqc-border);color:var(--sqc-text);border-radius:12px;flex-wrap:wrap;flex-shrink:0;align-items:center;gap:8px;margin:12px 16px 4px;padding:8px 11px;font-size:12px;display:flex}.sqc-chip{text-overflow:ellipsis;white-space:nowrap;align-items:baseline;gap:4px;max-width:100%;display:inline-flex;overflow:hidden}.sqc-chip b{font-weight:600}.sqc-chip:not(:last-child):after{content:\"·\";opacity:.5;margin-left:4px}.sqc-messages{overscroll-behavior:contain;background:var(--sqc-bg);scrollbar-width:thin;scrollbar-color:var(--sqc-neutral-300) transparent;flex-direction:column;flex:1;gap:13px;min-height:0;padding:12px 16px;display:flex;overflow-y:auto}.sqc-messages::-webkit-scrollbar{width:6px}.sqc-messages::-webkit-scrollbar-thumb{background:var(--sqc-neutral-300);border-radius:99px}.sqc-msg{flex-direction:column;max-width:93%;font-size:13.5px;display:flex}.sqc-msg--assistant{align-self:flex-start}.sqc-msg--user{align-self:flex-end}.sqc-msg__who{color:var(--sqc-text-muted);align-items:center;gap:6px;margin-bottom:4px;font-size:11px;font-weight:500;display:flex}.sqc-msg__who svg{width:12px;height:12px;color:var(--sqc-accent-fg);flex-shrink:0}.sqc-msg__unaddressed{color:var(--sqc-text-muted);margin:8px 0 0;font-size:11.5px;line-height:1.5}.sqc-msg__unaddressed code{background:var(--sqc-code-bg);color:var(--sqc-text);border-radius:4px;margin-right:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:11px}.sqc-msg--user .sqc-msg__bubble{background:var(--sqc-bubble-user);color:var(--sqc-bubble-user-text);border-radius:var(--sqc-radius) var(--sqc-radius) 4px var(--sqc-radius);padding:9px 13px}.sqc-msg--error .sqc-msg__bubble{background:var(--sqc-error-50);color:var(--sqc-error-600);border:1px solid var(--sqc-error-100);border-radius:12px;padding:11px}.sqc-msg__body{overflow-wrap:anywhere}.sqc-msg--assistant .sqc-msg__body{font-size:14px;line-height:1.6}.sqc-msg__body>:first-child{margin-top:0}.sqc-msg__body>:last-child{margin-bottom:0}.sqc-msg__body p{white-space:pre-wrap;margin:0 0 8px}.sqc-msg__body ul,.sqc-msg__body ol{margin:0 0 8px;padding-left:20px}.sqc-msg__body li{margin-bottom:3px}.sqc-msg__body code{background:var(--sqc-code-bg);border-radius:4px;padding:1px 4px;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.85em}.sqc-msg--user .sqc-msg__body code{background:#ffffff38}.sqc-msg__body pre{background:var(--sqc-code-bg);border-radius:8px;margin:0 0 8px;padding:9px 11px;overflow-x:auto}.sqc-msg__body pre code{background:0 0;padding:0}.sqc-msg__body a{color:inherit;text-underline-offset:2px;text-decoration:underline}.sqc-msg--assistant .sqc-msg__body a{color:var(--sqc-link);text-decoration:none}.sqc-msg--assistant .sqc-msg__body a:hover{text-decoration:underline}.sqc-msg__body h3,.sqc-msg__body h4,.sqc-msg__body h5,.sqc-msg__body h6{font-family:var(--sqc-font-heading);letter-spacing:-.2px;margin:12px 0 6px;font-weight:700;line-height:1.3}.sqc-msg__body h3{font-size:1.05em}.sqc-msg__body h4{font-size:1em}.sqc-msg__body h5,.sqc-msg__body h6{font-size:.94em}.sqc-msg__body ul ul,.sqc-msg__body ul ol,.sqc-msg__body ol ul,.sqc-msg__body ol ol{margin:3px 0 0}.sqc-msg__body blockquote{border-left:2px solid var(--sqc-border-strong);color:var(--sqc-text-muted);white-space:pre-wrap;margin:0 0 8px;padding:2px 0 2px 10px}.sqc-msg--user .sqc-msg__body blockquote{color:inherit;opacity:.85;border-left-color:#ffffff73}.sqc-msg__body hr{border:0;border-top:1px solid var(--sqc-border);margin:10px 0}.sqc-msg--user .sqc-msg__body hr{border-top-color:#ffffff4d}.sqc-msg__body del{opacity:.7}.sqc-approval{flex-direction:column;gap:8px;margin:11px 0 2px;display:flex}.sqc-approval__actions{flex-wrap:wrap;gap:8px;display:flex}.sqc-approval__request{color:var(--sqc-text);margin:0;font-size:13px}.sqc-approval__args{border:1px solid var(--sqc-border);background:var(--sqc-surface);border-radius:12px;flex-direction:column;gap:4px;margin:0;padding:8px 10px;font-size:12px;display:flex}.sqc-approval__arg{gap:8px;display:flex}.sqc-approval__arg-name{color:var(--sqc-text-muted);flex:none;font-weight:500}.sqc-approval__arg-value{overflow-wrap:anywhere;min-width:0;color:var(--sqc-text);margin:0}.sqc-approval__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-approval__btn--yes:not(:disabled),.sqc-approval__btn--send:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-approval__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-approval__btn--yes:hover:not(:disabled),.sqc-approval__btn--send:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-approval__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-approval__btn:disabled{cursor:default}.sqc-approval__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-approval__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-approval__edit{flex-direction:column;gap:8px;display:flex}.sqc-approval__input{width:100%;font-family:var(--sqc-font-family);color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border-strong);resize:vertical;border-radius:12px;padding:8px 10px;font-size:13px;line-height:1.4}.sqc-approval__input:focus-visible{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input);outline:none}.sqc-approval__btn--send{flex:none;align-self:flex-end}.sqc-confirm{gap:8px;margin:11px 0 2px;display:flex}.sqc-confirm__btn{height:32px;font-family:var(--sqc-font-family);border:1px solid var(--sqc-border);background:var(--sqc-bg);color:var(--sqc-text);cursor:pointer;border-radius:12px;flex:1 1 0;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:500;transition:border-color .12s,background .12s;display:inline-flex}.sqc-confirm__btn--yes:not(:disabled){background:var(--sqc-accent-color);color:var(--sqc-on-accent);border-color:#0000;font-weight:600}.sqc-confirm__btn:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-confirm__btn--yes:hover:not(:disabled){background:var(--sqc-accent-hover);border-color:#0000}.sqc-confirm__btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-confirm__btn:disabled{cursor:default}.sqc-confirm__btn:disabled[aria-pressed=false]{opacity:.45}.sqc-confirm__btn[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected);color:var(--sqc-text);font-weight:600}.sqc-choices{flex-direction:column;gap:7px;margin:10px 0 2px;display:flex}.sqc-choice{width:100%;font-family:var(--sqc-font-family);text-align:left;color:var(--sqc-text);background:var(--sqc-bg);border:1px solid var(--sqc-border);cursor:pointer;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:border-color .12s,background .12s;display:flex}.sqc-choice:hover:not(:disabled){border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-choice:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-choice:disabled{cursor:default}.sqc-choice:disabled[aria-pressed=false]{opacity:.55}.sqc-choice[aria-pressed=true]{border-color:var(--sqc-border-strong);background:var(--sqc-selected)}.sqc-choice__box{border:1.5px solid var(--sqc-border-strong);border-radius:4px;flex:none;justify-content:center;align-items:center;width:15px;height:15px;display:inline-flex}.sqc-choice__box--on{color:var(--sqc-on-accent);background:var(--sqc-accent-color);border-color:var(--sqc-accent-color)}.sqc-choice__box svg{width:11px;height:11px}.sqc-choice__label{overflow-wrap:anywhere}.sqc-choice__detail{color:var(--sqc-text-muted);margin-top:1px;font-size:11.5px;display:block}.sqc-selection{flex-direction:column;gap:10px;margin:2px 0;display:flex}.sqc-selection__question{flex-direction:column;gap:2px;display:flex}.sqc-selection__ask{font-family:var(--sqc-font-family);color:var(--sqc-text);margin:0;font-size:13px;font-weight:600}.sqc-selection__actions{display:flex}.sqc-selection__validate{height:32px;font-family:var(--sqc-font-family);color:var(--sqc-on-accent);background:var(--sqc-accent-color);cursor:pointer;border:1px solid #0000;border-radius:12px;flex:auto;justify-content:center;align-items:center;padding:0 12px;font-size:13px;font-weight:600;transition:filter .12s,background .12s;display:inline-flex}.sqc-selection__validate:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-selection__validate:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-selection__validate:disabled{cursor:not-allowed;color:#fff;background:var(--sqc-disabled)}.sqc-selection__hint{font-family:var(--sqc-font-family);color:var(--sqc-text-muted);margin:0;font-size:11.5px}.sqc-table{scrollbar-width:thin;margin:0 0 8px;overflow-x:auto}.sqc-table table{border-collapse:collapse;min-width:100%;font-family:var(--sqc-font-family);white-space:nowrap;font-size:12.5px}.sqc-table th,.sqc-table td{text-align:left;vertical-align:top;border-bottom:1px solid var(--sqc-border);padding:6px 10px 6px 0}.sqc-table thead th{text-transform:uppercase;letter-spacing:.05em;color:var(--sqc-text-muted);font-size:10.5px;font-weight:600}.sqc-table tbody th{font-weight:500}.sqc-msg--user .sqc-table th,.sqc-msg--user .sqc-table td{border-bottom-color:#ffffff40}.sqc-msg--user .sqc-table thead th{color:#fffc}.sqc-table tbody tr:last-child th,.sqc-table tbody tr:last-child td{border-bottom:0}.sqc-msg__time{color:var(--sqc-text-muted);font-variant-numeric:tabular-nums;margin-top:3px;font-size:10px;display:block}.sqc-msg--user .sqc-msg__time{color:#ffffffb3;text-align:right}.sqc-caret{vertical-align:text-bottom;background:currentColor;width:2px;height:1em;margin-left:2px;animation:1s step-end infinite sqc-blink;display:inline-block}@keyframes sqc-blink{0%,to{opacity:1}50%{opacity:0}}.sqc-typing{gap:3px;padding:2px 0;display:inline-flex}.sqc-typing i{background:var(--sqc-neutral-400);border-radius:50%;width:5px;height:5px;animation:1.2s infinite sqc-pulse}.sqc-typing i:nth-child(2){animation-delay:.2s}.sqc-typing i:nth-child(3){animation-delay:.4s}@keyframes sqc-pulse{0%,60%,to{opacity:.25}30%{opacity:1}}.sqc-suggestions{flex-direction:column;gap:7px;display:flex}.sqc-suggestion{border:1px solid var(--sqc-border);background:var(--sqc-bg);width:100%;color:var(--sqc-text);font-family:var(--sqc-font-family);cursor:pointer;text-align:left;border-radius:12px;align-items:center;gap:8px;padding:8px 11px;font-size:12.5px;transition:background .15s,border-color .15s;display:flex}.sqc-suggestion:before{content:\"\";background:var(--sqc-accent-fg);border-radius:50%;flex:none;width:5px;height:5px}.sqc-suggestion:hover{background:var(--sqc-surface);border-color:var(--sqc-border-strong)}.sqc-suggestion:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-composer{border-top:1px solid var(--sqc-border);background:var(--sqc-bg);flex-wrap:wrap;flex-shrink:0;align-items:flex-end;gap:8px;padding:12px 14px;display:flex}.sqc-composer--dropping{outline:2px dashed var(--sqc-accent-color);outline-offset:-4px}.sqc-attachments{flex-wrap:wrap;flex-basis:100%;gap:6px;display:flex}.sqc-attachments--sent{margin-top:8px}.sqc-chip{border:1px solid var(--sqc-border);background:var(--sqc-selected);max-width:100%;color:var(--sqc-text);border-radius:999px;align-items:center;gap:4px;padding:3px 4px 3px 10px;font-size:12px;display:inline-flex}.sqc-chip--waiting{opacity:.6;padding-right:10px}.sqc-chip__name{text-overflow:ellipsis;white-space:nowrap;max-width:180px;overflow:hidden}.sqc-chip__remove{width:18px;height:18px;color:var(--sqc-text-muted);cursor:pointer;background:0 0;border:0;border-radius:999px;justify-content:center;align-items:center;padding:0;font-size:14px;line-height:1;display:inline-flex}.sqc-chip__remove:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-attachments__error{color:var(--sqc-error-600);flex-basis:100%;margin:0;font-size:12px}.sqc-attachment__image{border-radius:12px;max-width:100%;max-height:180px;display:block}.sqc-file-input{display:none}.sqc-btn--attach{color:var(--sqc-text-muted);background:0 0}.sqc-btn--attach:hover{background:var(--sqc-selected);color:var(--sqc-text)}.sqc-composer__field{flex:1;min-width:0;position:relative}.sqc-composer__input{border:1px solid var(--sqc-border-strong);background:var(--sqc-bg);width:100%;min-height:38px;max-height:132px;color:var(--sqc-text);font-family:var(--sqc-font-family);resize:none;border-radius:12px;outline:none;padding:9px 12px;font-size:13.5px;line-height:1.4;transition:border-color .15s,box-shadow .15s;display:block;overflow-y:hidden}.sqc-composer__input::placeholder{color:var(--sqc-neutral-400)}.sqc-composer__input:focus{border-color:var(--sqc-text);box-shadow:var(--sqc-focus-input)}.sqc-mentions{z-index:2;border:1px solid var(--sqc-border);background:var(--sqc-bg);max-height:184px;box-shadow:var(--sqc-shadow);scrollbar-width:thin;border-radius:12px;margin:0;padding:4px;list-style:none;position:absolute;bottom:calc(100% + 6px);left:0;right:0;overflow-y:auto}.sqc-mention{cursor:pointer;color:var(--sqc-text);border-radius:8px;align-items:baseline;gap:6px;padding:6px 8px;font-size:12.5px;display:flex}.sqc-mention--active{background:var(--sqc-neutral-100)}.sqc-mention__icon{flex-shrink:0}.sqc-mention__handle{font-weight:600}.sqc-mention__name{text-overflow:ellipsis;white-space:nowrap;color:var(--sqc-text-muted);overflow:hidden}.sqc-composer__count{color:var(--sqc-text-muted);pointer-events:none;font-variant-numeric:tabular-nums;font-size:10px;position:absolute;bottom:4px;right:8px}.sqc-btn{cursor:pointer;border:none;border-radius:12px;flex-shrink:0;place-items:center;width:38px;height:38px;transition:background .15s,opacity .15s;display:grid}.sqc-btn svg{width:17px;height:17px}.sqc-btn--send{background:var(--sqc-accent-color);color:var(--sqc-on-accent)}.sqc-btn--send:hover:not(:disabled){background:var(--sqc-accent-hover)}.sqc-btn--send:disabled{background:var(--sqc-disabled);color:#fff;cursor:not-allowed}.sqc-btn--stop{background:var(--sqc-bg);color:var(--sqc-text);border:1px solid var(--sqc-border)}.sqc-btn--stop:hover{border-color:var(--sqc-border-strong);background:var(--sqc-surface)}.sqc-btn:focus-visible{box-shadow:var(--sqc-focus);outline:none}.sqc-hint{padding:0 16px max(9px, env(safe-area-inset-bottom));color:var(--sqc-text-muted);text-align:center;flex-shrink:0;margin:0;font-size:10.5px;line-height:1.35}@media (max-width:520px){.sqc{--sqc-width:100vw}.sqc-panel{border-left:none}.sqc-launcher{bottom:16px;right:16px}.sqc[data-position=bottom-left] .sqc-launcher{left:16px}}@media (prefers-reduced-motion:reduce){.sqc-launcher,.sqc-panel,.sqc-btn,.sqc-suggestion,.sqc-choice,.sqc-confirm__btn,.sqc-icon-btn,.sqc-icon-btn[data-tip]:after{transition:none}.sqc-typing i,.sqc-caret{animation:none}}.sqc-with-human{border:1px solid var(--sqc-border);background:var(--sqc-selected);color:var(--sqc-neutral-600);border-radius:12px;margin:8px 0 0;padding:8px 12px;font-size:13px}";
2251
+ //#endregion
2252
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js
2253
+ function xn(e, t) {
2254
+ if (t.has(e)) throw TypeError("Cannot initialize the same private elements twice on an object");
2255
+ }
2256
+ //#endregion
2257
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js
2258
+ function Sn(e, t) {
2259
+ xn(e, t), t.add(e);
2260
+ }
2261
+ //#endregion
2262
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js
2263
+ function X(e, t, n) {
2264
+ xn(e, t), t.set(e, n);
2265
+ }
2266
+ //#endregion
2267
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/assertClassBrand.js
2268
+ function Z(e, t, n) {
2269
+ if (typeof e == "function" ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2270
+ throw TypeError("Private element is not present on this object");
2271
+ }
2272
+ //#endregion
2273
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js
2274
+ function Q(e, t, n) {
2275
+ return e.set(Z(e, t), n), n;
2276
+ }
2277
+ //#endregion
2278
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js
2279
+ function $(e, t) {
2280
+ return e.get(Z(e, t));
2281
+ }
2282
+ //#endregion
2283
+ //#region src/element.tsx
2284
+ var Cn = "squadico-chatbot", wn = [
2285
+ "embed-key",
2286
+ "context",
2287
+ "user",
2288
+ "agent",
2289
+ "heading",
2290
+ "subheading",
2291
+ "assistant-name",
2292
+ "placeholder",
2293
+ "greeting",
2294
+ "suggestions",
2295
+ "width",
2296
+ "accent",
2297
+ "theme",
2298
+ "position",
2299
+ "open",
2300
+ "persist-open",
2301
+ "locale"
2302
+ ], Tn;
2303
+ function En() {
2304
+ if (Tn !== void 0) return Tn;
2305
+ try {
2306
+ let e = new CSSStyleSheet();
2307
+ e.replaceSync(bn), Tn = e;
2308
+ } catch {
2309
+ Tn = null;
2310
+ }
2311
+ return Tn;
2312
+ }
2313
+ function Dn(e, t) {
2314
+ typeof console < "u" && console.warn(`[${Cn}] ${e}`, t ?? "");
2315
+ }
2316
+ function On(e) {
2317
+ if (!(!e || !e.trim())) try {
2318
+ let t = JSON.parse(e);
2319
+ if (t && typeof t == "object" && !Array.isArray(t)) {
2320
+ let e = t;
2321
+ if (typeof e.id == "string" && e.id) return {
2322
+ id: e.id,
2323
+ name: typeof e.name == "string" && e.name ? e.name : void 0,
2324
+ digest: typeof e.digest == "string" && e.digest ? e.digest : void 0
2325
+ };
2326
+ }
2327
+ Dn("the \"user\" attribute needs an object with an id", e);
2328
+ } catch (e) {
2329
+ Dn("the \"user\" attribute is not valid JSON", e);
2330
+ }
2331
+ }
2332
+ function kn(e) {
2333
+ if (!(!e || !e.trim())) try {
2334
+ let t = JSON.parse(e);
2335
+ if (t && typeof t == "object" && !Array.isArray(t)) return t;
2336
+ Dn("the `context` attribute must be a JSON object", e);
2337
+ } catch (e) {
2338
+ Dn("the `context` attribute is not valid JSON", e);
2339
+ }
2340
+ }
2341
+ function An(e) {
2342
+ if (!(!e || !e.trim())) {
2343
+ if (e.trim().startsWith("[")) try {
2344
+ let t = JSON.parse(e);
2345
+ if (Array.isArray(t)) return t.map(String);
2346
+ } catch (e) {
2347
+ Dn("the `suggestions` attribute is not valid JSON", e);
2348
+ return;
2349
+ }
2350
+ return e.split("|").map((e) => e.trim()).filter(Boolean);
2351
+ }
2352
+ }
2353
+ function jn(e) {
2354
+ if (e !== null) return e !== "false" && e !== "0";
2355
+ }
2356
+ function Mn(e) {
2357
+ return e === "dark" || e === "light" || e === "auto" ? e : void 0;
2358
+ }
2359
+ function Nn(e) {
2360
+ return e === "bottom-left" || e === "bottom-right" ? e : void 0;
2361
+ }
2362
+ function Pn() {
2363
+ var e, t, n, r, i, a, o, s, c, l, u, d, f;
2364
+ return t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new WeakSet(), d = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), e = class extends HTMLElement {
2365
+ constructor() {
2366
+ super(), Sn(this, u), X(this, t, void 0), X(this, n, null), X(this, r, !1), X(this, i, !1), X(this, a, ""), X(this, o, void 0), X(this, s, void 0), X(this, c, void 0), X(this, l, void 0), X(this, d, (e) => {
2367
+ let { type: t, ...n } = e;
2368
+ Q(a, this, n.sessionId), this.dispatchEvent(new CustomEvent(t, {
2369
+ detail: n,
2370
+ bubbles: !0,
2371
+ composed: !0
2372
+ }));
2373
+ }), X(this, f, (e) => {
2374
+ Q(n, this, e), e && Q(a, this, e.sessionId());
2375
+ });
2376
+ let e = this.attachShadow({ mode: "open" }), p = En();
2377
+ if (p) e.adoptedStyleSheets = [p];
2378
+ else {
2379
+ let t = document.createElement("style");
2380
+ t.textContent = bn, e.append(t);
2381
+ }
2382
+ Q(t, this, document.createElement("div")), e.append($(t, this));
2383
+ }
2384
+ connectedCallback() {
2385
+ Q(i, this, !0), Z(u, this, m).call(this);
2386
+ }
2387
+ disconnectedCallback() {
2388
+ Q(i, this, !1), ie(null, $(t, this)), Q(n, this, null);
2389
+ }
2390
+ attributeChangedCallback(e, t, r) {
2391
+ if (t !== r) {
2392
+ if (e === "open" && $(n, this)) {
2393
+ jn(r) ? $(n, this).open() : $(n, this).close();
2394
+ return;
2395
+ }
2396
+ Z(u, this, p).call(this);
2397
+ }
2398
+ }
2399
+ get context() {
2400
+ return $(o, this) ?? kn(this.getAttribute("context"));
2401
+ }
2402
+ set context(e) {
2403
+ Q(o, this, e), Z(u, this, p).call(this);
2404
+ }
2405
+ get embedKey() {
2406
+ return $(l, this) ?? this.getAttribute("embed-key") ?? void 0;
2407
+ }
2408
+ set embedKey(e) {
2409
+ Q(l, this, e), Z(u, this, p).call(this);
2410
+ }
2411
+ get user() {
2412
+ return $(s, this) ?? On(this.getAttribute("user"));
2413
+ }
2414
+ set user(e) {
2415
+ Q(s, this, e), Z(u, this, p).call(this);
2416
+ }
2417
+ get agent() {
2418
+ return $(c, this) ?? this.getAttribute("agent") ?? void 0;
2419
+ }
2420
+ set agent(e) {
2421
+ Q(c, this, e), Z(u, this, p).call(this);
2422
+ }
2423
+ get open() {
2424
+ return $(n, this)?.isOpen() ?? jn(this.getAttribute("open")) ?? !1;
2425
+ }
2426
+ set open(e) {
2427
+ e ? this.openChat() : this.closeChat();
2428
+ }
2429
+ get sessionId() {
2430
+ return $(n, this)?.sessionId() ?? $(a, this);
2431
+ }
2432
+ openChat() {
2433
+ $(n, this)?.open();
2434
+ }
2435
+ closeChat() {
2436
+ $(n, this)?.close();
2437
+ }
2438
+ toggleChat() {
2439
+ $(n, this)?.toggle();
2440
+ }
2441
+ reset() {
2442
+ $(n, this)?.reset();
2443
+ }
2444
+ sendMessage(e) {
2445
+ if (!$(n, this)) {
2446
+ Dn("sendMessage() called before the component was mounted — ignored");
2447
+ return;
2448
+ }
2449
+ $(n, this).send(e);
2450
+ }
2451
+ }, Ke(e, "observedAttributes", wn), e;
2452
+ function p() {
2453
+ $(r, this) || !$(i, this) || (Q(r, this, !0), queueMicrotask(() => {
2454
+ Q(r, this, !1), $(i, this) && Z(u, this, m).call(this);
2455
+ }));
2456
+ }
2457
+ function m() {
2458
+ let e = (e) => this.getAttribute(e) ?? void 0;
2459
+ ie(/* @__PURE__ */ J(yn, {
2460
+ embedKey: this.embedKey,
2461
+ context: this.context,
2462
+ user: this.user,
2463
+ agent: this.agent,
2464
+ heading: e("heading"),
2465
+ subheading: e("subheading"),
2466
+ assistantName: e("assistant-name"),
2467
+ placeholder: e("placeholder"),
2468
+ greeting: e("greeting"),
2469
+ suggestions: An(this.getAttribute("suggestions")),
2470
+ width: e("width"),
2471
+ accent: e("accent"),
2472
+ theme: Mn(this.getAttribute("theme")),
2473
+ position: Nn(this.getAttribute("position")),
2474
+ defaultOpen: jn(this.getAttribute("open")) ?? !1,
2475
+ persistOpen: jn(this.getAttribute("persist-open")) ?? !0,
2476
+ locale: e("locale"),
2477
+ onEvent: $(d, this),
2478
+ bind: $(f, this)
2479
+ }), $(t, this));
2480
+ }
2481
+ }
2482
+ var Fn;
2483
+ function In(e = Cn) {
2484
+ typeof window > "u" || typeof HTMLElement > "u" || (Fn ?? (Fn = Pn()), window.customElements.get(e) || window.customElements.define(e, Fn));
2485
+ }
2486
+ //#endregion
2487
+ //#region src/index.ts
2488
+ In();
2489
+ //#endregion
2490
+ export { Je as a, Me as c, q as i, In as n, Ve as o, qe as r, je as s, Cn as t };
2491
+
2492
+ //# sourceMappingURL=src-CN1vDssu.js.map