@useago/sdk 1.14.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,10 +1,10 @@
1
- import { a as tr, c as ti, n as nr, o as ni, s as oi, t as or } from "./types-C39MJUE3.js";
2
- import { n as ir } from "./errors-BLfjXnLB.js";
3
- import { t as rr } from "./createConversationSession-CybQdMpK.js";
4
- import { r as ar, t as sr } from "./createFormCollector-DJjms78E.js";
5
- import { $ as ne, A as Rn, B as lr, C as ss, D as Q, E as cr, F as zn, G as $o, H as ii, I as dr, J as pr, K as On, L as ur, M as Hn, N as Re, O as ve, P as ri, Q as Jt, R as ai, S as ls, T as Bn, U as Ee, V as rt, W as $n, X as fr, Y as Do, Z as si, _ as mr, a as gr, at as d, b as hr, c as br, ct as xr, d as li, dt as Ln, et as yr, f as ci, ft as je, g as Cr, h as wr, i as vr, it as u, j as Er, k as at, l as kr, lt as Sr, m as _r, mt as Vn, n as Tr, nt as Mo, o as Ar, ot as Fr, p as Lr, pt as Me, q as di, r as qn, rt as Nr, s as Ir, st as Rr, t as cs, tt as zr, u as Or, ut as jo, v as Hr, w as st, x as Br, y as $r, z as nn } from "./speechToText-BLvTis4S.js";
6
- var Dr = 10 * 1024 * 1024;
7
- var Wo = [
1
+ import { a as nr, c as ni, n as or, o as oi, s as ii, t as ir } from "./types-C39MJUE3.js";
2
+ import { n as rr } from "./errors-BLfjXnLB.js";
3
+ import { t as ar } from "./createConversationSession-CybQdMpK.js";
4
+ import { r as sr, t as lr } from "./createFormCollector-DJjms78E.js";
5
+ import { $ as ne, A as On, B as cr, C as cs, D as Q, E as dr, F as Hn, G as Mo, H as ri, I as pr, J as ur, K as Bn, L as fr, M as $n, N as Re, O as ve, P as ai, Q as en, R as si, S as ds, T as Dn, U as Ee, V as st, W as Mn, X as mr, Y as jo, Z as li, _ as gr, a as hr, at as d, b as br, c as xr, ct as yr, d as ci, dt as Nn, et as Cr, f as di, ft as We, g as wr, h as vr, i as Er, it as u, j as kr, k as lt, l as Sr, lt as _r, m as Tr, mt as Gn, n as Ar, nt as In, o as Fr, ot as Lr, p as Nr, pt as Me, q as pi, r as Xn, rt as Ir, s as Rr, st as zr, t as ps, tt as Or, u as Hr, ut as Wo, v as Br, w as ct, x as $r, y as Dr, z as on } from "./speechToText-BLvTis4S.js";
6
+ var Mr = 10 * 1024 * 1024;
7
+ var Uo = [
8
8
  "image/jpeg",
9
9
  "image/png",
10
10
  "image/gif",
@@ -27,19 +27,19 @@ var Wo = [
27
27
  "text/html",
28
28
  "application/epub+zip"
29
29
  ];
30
- function Uo(t) {
30
+ function Po(t) {
31
31
  return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
32
32
  }
33
- function Mr(t) {
33
+ function jr(t) {
34
34
  const e = t.look === "embed";
35
35
  let o = [];
36
36
  const n = /* @__PURE__ */ new Map(), i = document.createElement("form");
37
37
  i.className = e ? "ago-chat-input ago-chat-input--embed" : "ago-chat-input", e ? u(i, {
38
38
  width: "100%",
39
39
  borderRadius: "24px",
40
- border: `2px solid ${di}`,
40
+ border: `2px solid ${pi}`,
41
41
  backgroundColor: "#fff",
42
- boxShadow: fr,
42
+ boxShadow: mr,
43
43
  position: "relative",
44
44
  boxSizing: "border-box",
45
45
  display: "block",
@@ -74,12 +74,12 @@ function Mr(t) {
74
74
  alignItems: "flex-end"
75
75
  }), c = document.createElement("textarea");
76
76
  c.placeholder = t.placeholder, c.setAttribute("aria-label", t.placeholder), c.rows = 1, c.autocapitalize = "off", c.setAttribute("autocorrect", "off");
77
- const b = e ? 208 : 110;
77
+ const x = e ? 208 : 110;
78
78
  e ? u(c, {
79
79
  display: "block",
80
80
  width: "100%",
81
81
  minHeight: "40px",
82
- maxHeight: `${b}px`,
82
+ maxHeight: `${x}px`,
83
83
  overflowY: "auto",
84
84
  resize: "none",
85
85
  border: "none",
@@ -102,34 +102,34 @@ function Mr(t) {
102
102
  fontSize: "16px",
103
103
  fontFamily: Re,
104
104
  lineHeight: "1.4",
105
- maxHeight: `${b}px`,
105
+ maxHeight: `${x}px`,
106
106
  overflowY: "hidden"
107
107
  });
108
- const m = () => {
109
- const f = e ? 0 : 2;
108
+ const f = () => {
109
+ const g = e ? 0 : 2;
110
110
  c.style.height = "auto";
111
- const H = Math.min(c.scrollHeight + f, b);
112
- c.style.height = `${H}px`, c.style.overflowY = c.scrollHeight + f > b ? "auto" : "hidden";
111
+ const B = Math.min(c.scrollHeight + g, x);
112
+ c.style.height = `${B}px`, c.style.overflowY = c.scrollHeight + g > x ? "auto" : "hidden";
113
113
  };
114
114
  c.addEventListener("input", () => {
115
- m(), S();
115
+ f(), _();
116
116
  });
117
- const p = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>', x = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>', B = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="5" width="14" height="14" rx="2"/></svg>', _ = document.createElement("button");
118
- _.type = "submit", _.className = "ago-chat-input__send", _.setAttribute("aria-label", t.labels?.send ?? "Send"), e ? u(_, {
117
+ const p = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>', b = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>', F = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="5" width="14" height="14" rx="2"/></svg>', y = document.createElement("button");
118
+ y.type = "submit", y.className = "ago-chat-input__send", y.setAttribute("aria-label", t.labels?.send ?? "Send"), e ? u(y, {
119
119
  flexShrink: "0",
120
120
  width: "40px",
121
121
  height: "40px",
122
122
  padding: "0",
123
123
  border: "none",
124
124
  borderRadius: "50%",
125
- backgroundColor: Do,
125
+ backgroundColor: jo,
126
126
  color: "#fafafa",
127
127
  display: "flex",
128
128
  alignItems: "center",
129
129
  justifyContent: "center",
130
130
  cursor: "pointer",
131
131
  transition: "background-color 0.15s, color 0.15s"
132
- }) : (_.innerHTML = p, u(_, {
132
+ }) : (y.innerHTML = p, u(y, {
133
133
  flexShrink: "0",
134
134
  width: "44px",
135
135
  height: "44px",
@@ -137,27 +137,27 @@ function Mr(t) {
137
137
  border: "none",
138
138
  borderRadius: "50%",
139
139
  backgroundColor: ve,
140
- color: at,
140
+ color: lt,
141
141
  display: "flex",
142
142
  alignItems: "center",
143
143
  justifyContent: "center",
144
144
  cursor: "pointer"
145
145
  }));
146
- let h = !1, E = !1;
147
- const L = () => h && !!t.onStop, S = () => {
148
- const f = c.value.trim() !== "", H = L(), P = !H && (h || E || !f);
149
- if (_.disabled = P, _.type = H ? "button" : "submit", _.setAttribute("aria-label", H ? t.labels?.stop ?? "Stop generating" : t.labels?.send ?? "Send"), e) {
150
- _.replaceChildren(H ? $r({ size: 16 }) : Ir({ size: 16 }));
151
- const D = P && !h;
152
- _.style.backgroundColor = D ? "#f1f5f9" : Do, _.style.color = D ? "#cbd5e1" : "#fafafa", _.style.pointerEvents = P ? "none" : "auto", _.style.cursor = P ? "default" : "pointer", ee.style.opacity = h ? "0.5" : "1";
146
+ let m = !1, k = !1;
147
+ const N = () => m && !!t.onStop, _ = () => {
148
+ const g = c.value.trim() !== "", B = N(), P = !B && (m || k || !g);
149
+ if (y.disabled = P, y.type = B ? "button" : "submit", y.setAttribute("aria-label", B ? t.labels?.stop ?? "Stop generating" : t.labels?.send ?? "Send"), e) {
150
+ y.replaceChildren(B ? Dr({ size: 16 }) : Rr({ size: 16 }));
151
+ const D = P && !m;
152
+ y.style.backgroundColor = D ? "#f1f5f9" : jo, y.style.color = D ? "#cbd5e1" : "#fafafa", y.style.pointerEvents = P ? "none" : "auto", y.style.cursor = P ? "default" : "pointer", ee.style.opacity = m ? "0.5" : "1";
153
153
  return;
154
154
  }
155
- _.innerHTML = H ? B : h ? x : p, _.style.opacity = P && !h ? "0.5" : "1", _.style.cursor = P ? "default" : "pointer";
155
+ y.innerHTML = B ? F : m ? b : p, y.style.opacity = P && !m ? "0.5" : "1", y.style.cursor = P ? "default" : "pointer";
156
156
  };
157
- _.addEventListener("click", () => {
158
- L() && t.onStop?.();
157
+ y.addEventListener("click", () => {
158
+ N() && t.onStop?.();
159
159
  });
160
- const N = d({
160
+ const I = d({
161
161
  display: "none",
162
162
  alignItems: "flex-start",
163
163
  justifyContent: "space-between",
@@ -171,9 +171,9 @@ function Mr(t) {
171
171
  fontSize: "14px",
172
172
  lineHeight: "20px"
173
173
  });
174
- N.className = "ago-chat-input__error", N.setAttribute("role", "alert");
175
- const j = document.createElement("span"), C = document.createElement("button");
176
- C.type = "button", C.textContent = t.labels?.dismiss ?? "Dismiss", u(C, {
174
+ I.className = "ago-chat-input__error", I.setAttribute("role", "alert");
175
+ const j = document.createElement("span"), w = document.createElement("button");
176
+ w.type = "button", w.textContent = t.labels?.dismiss ?? "Dismiss", u(w, {
177
177
  border: "none",
178
178
  background: "transparent",
179
179
  color: "inherit",
@@ -183,33 +183,33 @@ function Mr(t) {
183
183
  padding: "0",
184
184
  minHeight: "20px"
185
185
  });
186
- let z;
187
- C.addEventListener("click", () => {
188
- z = void 0, G?.clearError(), N.style.display = "none";
189
- }), N.append(j, C);
190
- const v = (f) => {
191
- j.textContent = f, N.style.display = "flex";
192
- }, k = (f, H) => f.replace(/\{(\w+)\}/g, (P, D) => Object.prototype.hasOwnProperty.call(H, D) ? H[D] : P), I = (f) => {
193
- if (!e) return f;
194
- const H = (D, oe) => {
195
- G?.clearError(), z = {
186
+ let O;
187
+ w.addEventListener("click", () => {
188
+ O = void 0, G?.clearError(), I.style.display = "none";
189
+ }), I.append(j, w);
190
+ const E = (g) => {
191
+ j.textContent = g, I.style.display = "flex";
192
+ }, S = (g, B) => g.replace(/\{(\w+)\}/g, (P, D) => Object.prototype.hasOwnProperty.call(B, D) ? B[D] : P), R = (g) => {
193
+ if (!e) return g;
194
+ const B = (D, oe) => {
195
+ G?.clearError(), O = {
196
196
  key: D,
197
197
  values: oe
198
- }, v(k(t.labels?.[D] ?? je("en").widget[D], oe));
198
+ }, E(S(t.labels?.[D] ?? We("en").widget[D], oe));
199
199
  }, P = [];
200
- for (const D of f) {
200
+ for (const D of g) {
201
201
  if (o.length + P.length >= 5) {
202
- H("tooManyFiles", { max: String(5) });
202
+ B("tooManyFiles", { max: String(5) });
203
203
  break;
204
204
  }
205
- if (D.type && !Wo.includes(D.type)) {
206
- H("invalidFileType", { name: D.name });
205
+ if (D.type && !Uo.includes(D.type)) {
206
+ B("invalidFileType", { name: D.name });
207
207
  continue;
208
208
  }
209
209
  if (D.size > 10485760) {
210
- H("fileTooLarge", {
210
+ B("fileTooLarge", {
211
211
  name: D.name,
212
- max: Uo(Dr)
212
+ max: Po(Mr)
213
213
  });
214
214
  continue;
215
215
  }
@@ -217,8 +217,8 @@ function Mr(t) {
217
217
  }
218
218
  return P;
219
219
  };
220
- let O = null, $ = null;
221
- t.allowFiles && (O = document.createElement("input"), O.type = "file", O.multiple = !0, e && (O.accept = Wo.join(",")), u(O, { display: "none" }), $ = document.createElement("button"), $.type = "button", $.className = "ago-chat-input__attach", $.setAttribute("aria-label", t.labels?.attachFiles ?? "Attach file"), e ? ($.appendChild(br({ size: 16 })), u($, {
220
+ let H = null, $ = null;
221
+ t.allowFiles && (H = document.createElement("input"), H.type = "file", H.multiple = !0, e && (H.accept = Uo.join(",")), u(H, { display: "none" }), $ = document.createElement("button"), $.type = "button", $.className = "ago-chat-input__attach", $.setAttribute("aria-label", t.labels?.attachFiles ?? "Attach file"), e ? ($.appendChild(xr({ size: 16 })), u($, {
222
222
  height: "40px",
223
223
  padding: "8px",
224
224
  display: "flex",
@@ -243,21 +243,21 @@ function Mr(t) {
243
243
  backgroundColor: Ee,
244
244
  cursor: "pointer",
245
245
  fontSize: "14px"
246
- })), $.addEventListener("click", () => O?.click()), O.addEventListener("change", () => {
247
- const f = Array.from(O?.files ?? []);
248
- o = [...o, ...I(f)], O && (O.value = ""), w();
246
+ })), $.addEventListener("click", () => H?.click()), H.addEventListener("change", () => {
247
+ const g = Array.from(H?.files ?? []);
248
+ o = [...o, ...R(g)], H && (H.value = ""), v();
249
249
  }));
250
- function W(f) {
251
- if (!e || !f.type.startsWith("image/") || typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
252
- let H = n.get(f);
253
- return H || (H = URL.createObjectURL(f), n.set(f, H)), H;
250
+ function W(g) {
251
+ if (!e || !g.type.startsWith("image/") || typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
252
+ let B = n.get(g);
253
+ return B || (B = URL.createObjectURL(g), n.set(g, B)), B;
254
254
  }
255
- function q(f) {
256
- const H = n.get(f);
257
- H && (URL.revokeObjectURL(H), n.delete(f));
255
+ function q(g) {
256
+ const B = n.get(g);
257
+ B && (URL.revokeObjectURL(B), n.delete(g));
258
258
  }
259
- function w() {
260
- a.replaceChildren(), e && (a.style.display = o.length > 0 ? "flex" : "none"), o.forEach((f, H) => {
259
+ function v() {
260
+ a.replaceChildren(), e && (a.style.display = o.length > 0 ? "flex" : "none"), o.forEach((g, B) => {
261
261
  const P = d(e ? {
262
262
  display: "flex",
263
263
  alignItems: "center",
@@ -278,34 +278,34 @@ function Mr(t) {
278
278
  fontSize: "12px"
279
279
  });
280
280
  if (P.className = "ago-chat-input__file", e) {
281
- const me = W(f);
282
- if (me) {
283
- const se = document.createElement("img");
284
- se.src = me, se.alt = "", u(se, {
281
+ const ge = W(g);
282
+ if (ge) {
283
+ const ae = document.createElement("img");
284
+ ae.src = ge, ae.alt = "", u(ae, {
285
285
  width: "32px",
286
286
  height: "32px",
287
287
  objectFit: "cover",
288
288
  borderRadius: "4px",
289
289
  flexShrink: "0"
290
- }), P.appendChild(se);
291
- } else P.appendChild(Lr({ size: 20 }));
290
+ }), P.appendChild(ae);
291
+ } else P.appendChild(Nr({ size: 20 }));
292
292
  }
293
293
  const D = document.createElement("span");
294
- if (D.textContent = f.name, D.title = f.name, e && u(D, {
294
+ if (D.textContent = g.name, D.title = g.name, e && u(D, {
295
295
  maxWidth: "150px",
296
296
  overflow: "hidden",
297
297
  textOverflow: "ellipsis",
298
298
  whiteSpace: "nowrap"
299
299
  }), P.appendChild(D), e) {
300
- const me = document.createElement("span");
301
- me.textContent = Uo(f.size), u(me, {
300
+ const ge = document.createElement("span");
301
+ ge.textContent = Po(g.size), u(ge, {
302
302
  fontSize: "12px",
303
303
  lineHeight: "16px",
304
304
  color: "#6b7280"
305
- }), P.appendChild(me);
305
+ }), P.appendChild(ge);
306
306
  }
307
307
  const oe = document.createElement("button");
308
- oe.type = "button", oe.setAttribute("aria-label", (t.labels?.removeFile ?? "Remove {filename}").replace("{filename}", () => f.name)), e ? oe.appendChild(li({ size: 16 })) : oe.textContent = "×", u(oe, {
308
+ oe.type = "button", oe.setAttribute("aria-label", (t.labels?.removeFile ?? "Remove {filename}").replace("{filename}", () => g.name)), e ? oe.appendChild(ci({ size: 16 })) : oe.textContent = "×", u(oe, {
309
309
  flexShrink: "0",
310
310
  width: "44px",
311
311
  height: "44px",
@@ -320,44 +320,44 @@ function Mr(t) {
320
320
  lineHeight: "1",
321
321
  color: "inherit"
322
322
  }), oe.addEventListener("click", () => {
323
- q(f), o = o.filter((me, se) => se !== H), w();
323
+ q(g), o = o.filter((ge, ae) => ae !== B), v();
324
324
  }), P.appendChild(oe), a.appendChild(P);
325
- }), S();
325
+ }), _();
326
326
  }
327
- const R = () => {
327
+ const z = () => {
328
328
  G?.cancel();
329
- const f = c.value, H = o;
330
- c.value = "", m(), o = [];
331
- for (const P of H) q(P);
332
- return w(), {
333
- content: f,
334
- files: H
329
+ const g = c.value, B = o;
330
+ c.value = "", f(), o = [];
331
+ for (const P of B) q(P);
332
+ return v(), {
333
+ content: g,
334
+ files: B
335
335
  };
336
336
  }, K = () => {
337
- if (h || E || !c.value.trim()) return;
338
- const { content: f, files: H } = R();
339
- t.onSend(f.trim(), H.length > 0 ? H : void 0), e && typeof window < "u" && window.innerWidth < (t.blurOnSubmitBelow ?? 600) && c.blur();
337
+ if (m || k || !c.value.trim()) return;
338
+ const { content: g, files: B } = z();
339
+ t.onSend(g.trim(), B.length > 0 ? B : void 0), e && typeof window < "u" && window.innerWidth < (t.blurOnSubmitBelow ?? 600) && c.blur();
340
340
  };
341
- i.addEventListener("submit", (f) => {
342
- f.preventDefault(), K();
343
- }), c.addEventListener("keydown", (f) => {
344
- if (f.key === "Enter" && !f.shiftKey) {
345
- if (f.isComposing || f.keyCode === 229) return;
346
- f.preventDefault(), K();
341
+ i.addEventListener("submit", (g) => {
342
+ g.preventDefault(), K();
343
+ }), c.addEventListener("keydown", (g) => {
344
+ if (g.key === "Enter" && !g.shiftKey) {
345
+ if (g.isComposing || g.keyCode === 229) return;
346
+ g.preventDefault(), K();
347
347
  }
348
348
  });
349
- const G = t.transcribeAudio ? Tr({
349
+ const G = t.transcribeAudio ? Ar({
350
350
  transcribe: t.transcribeAudio,
351
351
  labels: t.speechToTextLabels,
352
- onBusy: (f) => {
353
- const H = E && !f && !h && i.contains(document.activeElement);
354
- E = f, c.disabled = h || f, e ? (ee.style.display = f ? "none" : "", Y.style.display = f ? "none" : "flex", s.style.padding = f ? "8px" : "16px", G && (f ? s.append(G.el) : Y.prepend(G.el))) : (c.style.display = f ? "none" : "", _.style.display = f ? "none" : "flex", $ && ($.style.display = f ? "none" : "flex")), S(), H && c.focus();
352
+ onBusy: (g) => {
353
+ const B = k && !g && !m && i.contains(document.activeElement);
354
+ k = g, c.disabled = m || g, e ? (ee.style.display = g ? "none" : "", Y.style.display = g ? "none" : "flex", s.style.padding = g ? "8px" : "16px", G && (g ? s.append(G.el) : Y.prepend(G.el))) : (c.style.display = g ? "none" : "", y.style.display = g ? "none" : "flex", $ && ($.style.display = g ? "none" : "flex")), _(), B && c.focus();
355
355
  },
356
- onText: (f) => {
357
- c.value += `${c.value && !/\s$/.test(c.value) ? " " : ""}${f}`, m(), S(), c.focus();
356
+ onText: (g) => {
357
+ c.value += `${c.value && !/\s$/.test(c.value) ? " " : ""}${g}`, f(), _(), c.focus();
358
358
  },
359
- onError: (f) => {
360
- z = void 0, v(f);
359
+ onError: (g) => {
360
+ O = void 0, E(g);
361
361
  }
362
362
  }) : void 0, ee = d({
363
363
  flex: "1",
@@ -371,43 +371,43 @@ function Mr(t) {
371
371
  gap: "4px"
372
372
  });
373
373
  if (e) {
374
- ee.append(N, a, c);
375
- const f = d({
374
+ ee.append(I, a, c);
375
+ const g = d({
376
376
  display: "flex",
377
377
  alignItems: "center"
378
378
  });
379
- f.className = "ago-chat-input__toolbar", $ && f.appendChild($), $ && ee.appendChild(f), G && Y.appendChild(G.el), Y.appendChild(_), s.append(ee, Y), O && i.appendChild(O), i.appendChild(s), i.addEventListener("click", (H) => {
380
- (H.target instanceof Element ? H.target : null)?.closest("button,a,input,textarea") || c.focus();
379
+ g.className = "ago-chat-input__toolbar", $ && g.appendChild($), $ && ee.appendChild(g), G && Y.appendChild(G.el), Y.appendChild(y), s.append(ee, Y), H && i.appendChild(H), i.appendChild(s), i.addEventListener("click", (B) => {
380
+ (B.target instanceof Element ? B.target : null)?.closest("button,a,input,textarea") || c.focus();
381
381
  });
382
382
  } else
383
- $ && s.appendChild($), s.append(c), G && s.appendChild(G.el), s.append(_), O && i.appendChild(O), i.append(N, a, s);
384
- return S(), {
383
+ $ && s.appendChild($), s.append(c), G && s.appendChild(G.el), s.append(y), H && i.appendChild(H), i.append(I, a, s);
384
+ return _(), {
385
385
  inputRow: i,
386
- getValueAndClear: R,
387
- setDisabled: (f) => {
388
- h = f, G?.setDisabled(f), c.disabled = f || E, S();
386
+ getValueAndClear: z,
387
+ setDisabled: (g) => {
388
+ m = g, G?.setDisabled(g), c.disabled = g || k, _();
389
389
  },
390
390
  focus: () => c.focus(),
391
391
  blur: () => c.blur(),
392
- restoreDraft: (f, H) => {
393
- f && !c.value.trim() && (c.value = f, m()), H?.length && (o = [...H, ...o], w()), S();
392
+ restoreDraft: (g, B) => {
393
+ g && !c.value.trim() && (c.value = g, f()), B?.length && (o = [...B, ...o], v()), _();
394
394
  },
395
- setPlaceholder: (f) => {
396
- c.placeholder = f, f && c.setAttribute("aria-label", f);
395
+ setPlaceholder: (g) => {
396
+ c.placeholder = g, g && c.setAttribute("aria-label", g);
397
397
  },
398
- setLabels: (f, H) => {
399
- t.labels = f, $?.setAttribute("aria-label", f.attachFiles), C.textContent = f.dismiss, C.setAttribute("aria-label", f.dismiss), z && N.style.display !== "none" && (j.textContent = k(f[z.key], z.values)), G?.setLabels(H ?? je("en").speech), w(), S();
398
+ setLabels: (g, B) => {
399
+ t.labels = g, $?.setAttribute("aria-label", g.attachFiles), w.textContent = g.dismiss, w.setAttribute("aria-label", g.dismiss), O && I.style.display !== "none" && (j.textContent = S(g[O.key], O.values)), G?.setLabels(B ?? We("en").speech), v(), _();
400
400
  },
401
- setSpeechToTextEnabled: (f) => G?.setEnabled(f),
401
+ setSpeechToTextEnabled: (g) => G?.setEnabled(g),
402
402
  cancelRecording: () => G?.cancel(),
403
403
  destroy: () => {
404
404
  G?.destroy();
405
- for (const f of n.keys()) q(f);
405
+ for (const g of n.keys()) q(g);
406
406
  }
407
407
  };
408
408
  }
409
- var Nn = "rgba(3, 24, 47, 0.07)";
410
- function jr(t) {
409
+ var Rn = "rgba(3, 24, 47, 0.07)";
410
+ function Wr(t) {
411
411
  const e = document.createElement("footer");
412
412
  e.className = "ago-chat-widget__footer", u(e, {
413
413
  padding: "12px",
@@ -423,7 +423,7 @@ function jr(t) {
423
423
  });
424
424
  const n = /* @__PURE__ */ new Map();
425
425
  let i = "home";
426
- function a(c, b, m) {
426
+ function a(c, x, f) {
427
427
  const p = document.createElement("button");
428
428
  p.type = "button", p.className = "ago-chat-widget__tab", p.dataset.agoScreen = c, u(p, {
429
429
  flex: "1",
@@ -442,28 +442,28 @@ function jr(t) {
442
442
  transition: "background-color 0.15s",
443
443
  font: "inherit"
444
444
  });
445
- const x = document.createElement("span");
446
- return x.textContent = b, u(x, {
445
+ const b = document.createElement("span");
446
+ return b.textContent = x, u(b, {
447
447
  fontSize: "12px",
448
448
  lineHeight: "16px",
449
449
  maxWidth: "100%",
450
450
  whiteSpace: "nowrap",
451
451
  overflow: "hidden",
452
452
  textOverflow: "ellipsis"
453
- }), p.append(m, x), p.addEventListener("mouseenter", () => {
454
- p.style.backgroundColor = Nn;
453
+ }), p.append(f, b), p.addEventListener("mouseenter", () => {
454
+ p.style.backgroundColor = Rn;
455
455
  }), p.addEventListener("mouseleave", () => {
456
- p.style.backgroundColor = i === c ? Nn : "transparent";
456
+ p.style.backgroundColor = i === c ? Rn : "transparent";
457
457
  }), p.addEventListener("click", () => t.onNavigate(c)), n.set(c, p), p;
458
458
  }
459
- o.append(a("home", t.labels.home, wr({ size: 24 })), a("history", t.labels.chats, ci({ size: 24 }))), e.appendChild(o);
459
+ o.append(a("home", t.labels.home, vr({ size: 24 })), a("history", t.labels.chats, di({ size: 24 }))), e.appendChild(o);
460
460
  const s = (c) => {
461
461
  i = c === "history" ? "history" : "home";
462
- for (const [b, m] of n) {
463
- const p = m.querySelector("span");
464
- p && (p.textContent = b === "home" ? t.labels.home : t.labels.chats);
465
- const x = b === i;
466
- m.style.color = x ? On : ve, m.style.backgroundColor = x ? Nn : "transparent", x ? m.setAttribute("aria-current", "page") : m.removeAttribute("aria-current");
462
+ for (const [x, f] of n) {
463
+ const p = f.querySelector("span");
464
+ p && (p.textContent = x === "home" ? t.labels.home : t.labels.chats);
465
+ const b = x === i;
466
+ f.style.color = b ? Bn : ve, f.style.backgroundColor = b ? Rn : "transparent", b ? f.setAttribute("aria-current", "page") : f.removeAttribute("aria-current");
467
467
  }
468
468
  };
469
469
  return s("home"), {
@@ -474,7 +474,7 @@ function jr(t) {
474
474
  }
475
475
  };
476
476
  }
477
- function In(t, e, o, n) {
477
+ function zn(t, e, o, n) {
478
478
  const i = document.createElement("button");
479
479
  return i.type = "button", i.className = t, i.setAttribute("aria-label", e), i.title = e, u(i, {
480
480
  display: "flex",
@@ -497,7 +497,7 @@ function In(t, e, o, n) {
497
497
  i.style.opacity = "0.8";
498
498
  }), i.addEventListener("click", n), i.appendChild(o), i;
499
499
  }
500
- function Wr(t) {
500
+ function Ur(t) {
501
501
  const e = document.createElement("header");
502
502
  e.className = "ago-chat-widget__header", u(e, {
503
503
  display: "flex",
@@ -506,10 +506,10 @@ function Wr(t) {
506
506
  height: "56px",
507
507
  padding: "0 16px",
508
508
  boxSizing: "border-box",
509
- background: ri,
510
- color: zn,
509
+ background: ai,
510
+ color: Hn,
511
511
  borderBottom: "1px solid #e5e7eb",
512
- boxShadow: Jt,
512
+ boxShadow: en,
513
513
  flexShrink: "0"
514
514
  });
515
515
  const o = d({
@@ -517,7 +517,7 @@ function Wr(t) {
517
517
  alignItems: "center",
518
518
  gap: "12px",
519
519
  minWidth: "0"
520
- }), n = In("ago-chat-widget__back", t.labels.back, kr({ size: 20 }), t.onBack);
520
+ }), n = zn("ago-chat-widget__back", t.labels.back, Sr({ size: 20 }), t.onBack);
521
521
  n.style.marginRight = "-8px";
522
522
  const i = document.createElement("span");
523
523
  i.className = "ago-chat-widget__title", u(i, {
@@ -534,88 +534,103 @@ function Wr(t) {
534
534
  alignItems: "center",
535
535
  gap: "8px",
536
536
  flexShrink: "0"
537
- }), s = In("ago-chat-widget__new", t.labels.newChat, qn({ size: 20 }), t.onNewChat), c = In("ago-chat-widget__close", t.labels.close, li({ size: 20 }), t.onClose);
537
+ }), s = zn("ago-chat-widget__new", t.labels.newChat, Xn({ size: 20 }), t.onNewChat), c = zn("ago-chat-widget__close", t.labels.close, ci({ size: 20 }), t.onClose);
538
538
  return a.append(s, c), e.append(o, a), {
539
539
  el: e,
540
- update: ({ screen: b }) => {
541
- n.setAttribute("aria-label", t.labels.back), s.setAttribute("aria-label", t.labels.newChat), c.setAttribute("aria-label", t.labels.close), n.style.display = b === "chat" ? "flex" : "none", s.style.display = b === "home" ? "none" : "flex", i.textContent = b === "history" ? t.labels.history : t.title;
540
+ update: ({ screen: x }) => {
541
+ n.setAttribute("aria-label", t.labels.back), s.setAttribute("aria-label", t.labels.newChat), c.setAttribute("aria-label", t.labels.close), n.style.display = x === "chat" ? "flex" : "none", s.style.display = x === "home" ? "none" : "flex", i.textContent = x === "history" ? t.labels.history : t.title;
542
542
  }
543
543
  };
544
544
  }
545
- var ds = {
546
- ...je("en").widget,
547
- timeAgo: je("en").timeAgo
545
+ var us = {
546
+ ...We("en").widget,
547
+ timeAgo: We("en").timeAgo
548
548
  };
549
- function Po(t, e) {
549
+ function Vo(t, e) {
550
550
  return {
551
- ...Me(je(e).widget, t),
552
- timeAgo: Me(je(e).timeAgo, t?.timeAgo)
551
+ ...Me(We(e).widget, t),
552
+ timeAgo: Me(We(e).timeAgo, t?.timeAgo)
553
553
  };
554
554
  }
555
- var Ur = {
555
+ var Pr = {
556
556
  "&": "&amp;",
557
557
  "<": "&lt;",
558
558
  ">": "&gt;",
559
559
  '"': "&quot;",
560
560
  "'": "&#39;"
561
561
  };
562
- function nt(t) {
563
- return t.replace(/[&<>"']/g, (e) => Ur[e]);
562
+ function it(t) {
563
+ return t.replace(/[&<>"']/g, (e) => Pr[e]);
564
564
  }
565
- function Vo(t) {
565
+ function qo(t) {
566
566
  const e = t.trim();
567
567
  return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(e) || !/^[a-z][a-z0-9+.-]*:/i.test(e) ? e : null;
568
568
  }
569
- var pi = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Yt = "";
570
- function Xe(t) {
571
- const e = [], o = (i) => (e.push(i), `${Yt}${e.length - 1}${Yt}`);
569
+ var ui = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Qt = "";
570
+ function je(t) {
571
+ const e = [], o = (i) => (e.push(i), `${Qt}${e.length - 1}${Qt}`);
572
572
  let n = t;
573
- return n = n.replace(/`([^`]+)`/g, (i, a) => o(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${pi}">${nt(a)}</code>`)), n = n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (i, a, s) => {
574
- const c = Vo(s);
575
- return c ? o(`<img alt="${nt(a)}" src="${nt(c)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : i;
573
+ return n = n.replace(/`([^`]+)`/g, (i, a) => o(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${ui}">${it(a)}</code>`)), n = n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (i, a, s) => {
574
+ const c = qo(s);
575
+ return c ? o(`<img alt="${it(a)}" src="${it(c)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : i;
576
576
  }), n = n.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (i, a, s) => {
577
- const c = Vo(s);
578
- return c ? o(`<a href="${nt(c)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${Xe(a)}</a>`) : i;
579
- }), n = nt(n), n = n.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), n = n.replace(new RegExp(`${Yt}(\\d+)${Yt}`, "g"), (i, a) => e[Number(a)]), n;
577
+ const c = qo(s);
578
+ return c ? o(`<a href="${it(c)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${je(a)}</a>`) : i;
579
+ }), n = it(n), n = n.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), n = n.replace(new RegExp(`${Qt}(\\d+)${Qt}`, "g"), (i, a) => e[Number(a)]), n;
580
580
  }
581
581
  function we(t, e, o) {
582
582
  const n = document.createElement(t);
583
583
  return Object.assign(n.style, e), o !== void 0 && (n.innerHTML = o), n;
584
584
  }
585
- var ui = /^ {0,3}([-*_])( *\1){2,} *$/, fi = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, mi = /^ {0,3}(```+|~~~+)/, Qt = /^ {0,3}>\s?/, it = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Pr = [
585
+ var fi = /^ {0,3}([-*_])( *\1){2,} *$/, mi = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, gi = /^ {0,3}(```+|~~~+)/, Zt = /^ {0,3}>\s?/, Ke = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Vr = [
586
586
  "20px",
587
587
  "18px",
588
588
  "16px",
589
589
  "15px",
590
590
  "14px",
591
591
  "13px"
592
- ], Dn = (t) => t.match(/^\s*/)?.[0].length ?? 0;
593
- function Vr(t) {
594
- return t.trim() === "" || ui.test(t) || fi.test(t) || mi.test(t) || Qt.test(t) || it.test(t);
592
+ ], at = (t) => t.match(/^\s*/)?.[0].length ?? 0;
593
+ function hi(t) {
594
+ return t.trim() === "" || fi.test(t) || mi.test(t) || gi.test(t) || Zt.test(t) || Ke.test(t);
595
+ }
596
+ var jn = (t) => /\d/.test(t);
597
+ function qr(t) {
598
+ const e = t.filter((n) => n.trim() !== "").map(at), o = e.length > 0 ? Math.min(...e) : 0;
599
+ return t.map((n) => n.slice(Math.min(o, at(n))));
595
600
  }
596
- function gi(t) {
597
- const e = t[0].match(it), o = e[1].length, n = /\d/.test(e[2]), i = we(n ? "ol" : "ul", {
601
+ function Gr(t) {
602
+ const e = t[0].match(Ke), o = e[1].length, n = jn(e[2]), i = we(n ? "ol" : "ul", {
598
603
  margin: "0 0 8px 0",
599
604
  paddingLeft: "20px",
600
605
  listStyleType: n ? "decimal" : "disc",
601
606
  listStylePosition: "outside"
602
- });
603
- let a = 0;
604
- for (; a < t.length; ) {
605
- const s = t[a].match(it), c = [];
606
- for (a++; a < t.length && Dn(t[a]) > o; )
607
- c.push(t[a]), a++;
608
- const b = we("li", {
607
+ }), a = parseInt(e[2], 10);
608
+ n && a !== 1 && i.setAttribute("start", String(a));
609
+ let s = 0;
610
+ for (; s < t.length; ) {
611
+ const c = t[s].match(Ke);
612
+ if (s++, !c) continue;
613
+ const x = [];
614
+ for (; s < t.length && (t[s].trim() === "" || at(t[s]) > o); )
615
+ x.push(t[s]), s++;
616
+ const f = we("li", {
609
617
  display: "list-item",
610
618
  margin: "2px 0",
611
619
  lineHeight: "1.6"
612
- }), m = s[3].match(/^\[([ xX])\]\s+(.*)$/);
613
- m ? (b.style.listStyleType = "none", b.style.marginLeft = "-20px", b.innerHTML = `<span style="margin-right:6px">${m[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${Xe(m[2])}`) : b.innerHTML = Xe(s[3]), c.filter((p) => it.test(p)).length > 0 && b.appendChild(gi(c.filter((p) => p.trim() !== ""))), i.appendChild(b);
620
+ }), p = c[3].match(/^\[([ xX])\]\s+(.*)$/);
621
+ p ? (f.style.listStyleType = "none", f.style.marginLeft = "-20px", f.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${je(p[2])}`) : f.innerHTML = je(c[3]);
622
+ const b = qr(x);
623
+ let F = 0;
624
+ for (; F < b.length && !hi(b[F]); )
625
+ f.innerHTML += `<br>${je(b[F])}`, F++;
626
+ const y = b.slice(F);
627
+ y.some((m) => m.trim() !== "") && f.appendChild(Ye(y.join(`
628
+ `))), i.appendChild(f);
614
629
  }
615
630
  return i;
616
631
  }
617
- function qr(t) {
618
- const e = (c) => c.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((b) => b.trim()), o = we("div", {
632
+ function Xr(t) {
633
+ const e = (c) => c.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), o = we("div", {
619
634
  overflowX: "auto",
620
635
  margin: "0 0 8px 0"
621
636
  }), n = we("table", {
@@ -629,21 +644,21 @@ function qr(t) {
629
644
  textAlign: "left",
630
645
  backgroundColor: "#f5f7fa",
631
646
  fontWeight: "600"
632
- }, Xe(c)));
647
+ }, je(c)));
633
648
  i.appendChild(a), n.appendChild(i);
634
649
  const s = document.createElement("tbody");
635
650
  for (const c of t.slice(2)) {
636
- const b = document.createElement("tr");
637
- for (const m of e(c)) b.appendChild(we("td", {
651
+ const x = document.createElement("tr");
652
+ for (const f of e(c)) x.appendChild(we("td", {
638
653
  border: "1px solid #dee3e8",
639
654
  padding: "6px 10px"
640
- }, Xe(m)));
641
- s.appendChild(b);
655
+ }, je(f)));
656
+ s.appendChild(x);
642
657
  }
643
658
  return n.appendChild(s), o.appendChild(n), o;
644
659
  }
645
- var Gr = (t) => !!t && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);
646
- function lt(t) {
660
+ var Kr = (t) => !!t && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);
661
+ function Ye(t) {
647
662
  const e = document.createDocumentFragment(), o = t.replace(/\r\n?/g, `
648
663
  `).split(`
649
664
  `);
@@ -654,27 +669,27 @@ function lt(t) {
654
669
  n++;
655
670
  continue;
656
671
  }
657
- const s = a.match(mi);
672
+ const s = a.match(gi);
658
673
  if (s) {
659
- const m = s[1][0], p = [];
660
- for (n++; n < o.length && !new RegExp(`^ {0,3}${m === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(o[n]); )
674
+ const f = s[1][0], p = [];
675
+ for (n++; n < o.length && !new RegExp(`^ {0,3}${f === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(o[n]); )
661
676
  p.push(o[n]), n++;
662
677
  n++;
663
- const x = we("pre", { margin: "0 0 8px 0" });
664
- x.appendChild(we("code", {
678
+ const b = we("pre", { margin: "0 0 8px 0" });
679
+ b.appendChild(we("code", {
665
680
  display: "block",
666
681
  background: "#f5f5f5",
667
682
  padding: "8px 12px",
668
683
  borderRadius: "6px",
669
684
  fontSize: "13px",
670
685
  overflowX: "auto",
671
- fontFamily: pi,
686
+ fontFamily: ui,
672
687
  whiteSpace: "pre"
673
- }, nt(p.join(`
674
- `)))), e.appendChild(x);
688
+ }, it(p.join(`
689
+ `)))), e.appendChild(b);
675
690
  continue;
676
691
  }
677
- if (ui.test(a)) {
692
+ if (fi.test(a)) {
678
693
  e.appendChild(we("hr", {
679
694
  border: "none",
680
695
  borderTop: "1px solid #dee3e8",
@@ -682,21 +697,21 @@ function lt(t) {
682
697
  })), n++;
683
698
  continue;
684
699
  }
685
- const c = a.match(fi);
700
+ const c = a.match(mi);
686
701
  if (c) {
687
- const m = c[1].length;
688
- e.appendChild(we(`h${m}`, {
702
+ const f = c[1].length;
703
+ e.appendChild(we(`h${f}`, {
689
704
  margin: "16px 0 8px 0",
690
- fontSize: Pr[m - 1],
705
+ fontSize: Vr[f - 1],
691
706
  fontWeight: "600",
692
707
  lineHeight: "1.3"
693
- }, Xe(c[2]))), n++;
708
+ }, je(c[2]))), n++;
694
709
  continue;
695
710
  }
696
- if (Qt.test(a)) {
697
- const m = [];
698
- for (; n < o.length && Qt.test(o[n]); )
699
- m.push(o[n].replace(Qt, "")), n++;
711
+ if (Zt.test(a)) {
712
+ const f = [];
713
+ for (; n < o.length && Zt.test(o[n]); )
714
+ f.push(o[n].replace(Zt, "")), n++;
700
715
  const p = we("blockquote", {
701
716
  borderLeft: "4px solid #dee3e8",
702
717
  paddingLeft: "12px",
@@ -704,38 +719,47 @@ function lt(t) {
704
719
  fontStyle: "italic",
705
720
  color: "#6b6d6f"
706
721
  });
707
- p.appendChild(lt(m.join(`
722
+ p.appendChild(Ye(f.join(`
708
723
  `))), e.appendChild(p);
709
724
  continue;
710
725
  }
711
- if (a.includes("|") && Gr(o[n + 1])) {
712
- const m = [a, o[n + 1]];
726
+ if (a.includes("|") && Kr(o[n + 1])) {
727
+ const f = [a, o[n + 1]];
713
728
  for (n += 2; n < o.length && o[n].includes("|") && o[n].trim(); )
714
- m.push(o[n]), n++;
715
- e.appendChild(qr(m));
729
+ f.push(o[n]), n++;
730
+ e.appendChild(Xr(f));
716
731
  continue;
717
732
  }
718
- if (it.test(a)) {
719
- const m = [], p = Dn(a);
720
- for (; n < o.length && o[n].trim() !== ""; )
721
- if (it.test(o[n]) || Dn(o[n]) > p)
722
- m.push(o[n]), n++;
733
+ if (Ke.test(a)) {
734
+ const f = [], p = at(a), b = jn(a.match(Ke)[2]);
735
+ for (; n < o.length; ) {
736
+ if (o[n].trim() === "") {
737
+ let F = n + 1;
738
+ for (; F < o.length && o[F].trim() === ""; ) F++;
739
+ const y = o[F], m = y?.match(Ke);
740
+ if (!(y !== void 0 && (at(y) > p || m && jn(m[2]) === b))) break;
741
+ f.push(...o.slice(n, F)), n = F;
742
+ continue;
743
+ }
744
+ if (Ke.test(o[n]) || at(o[n]) > p)
745
+ f.push(o[n]), n++;
723
746
  else break;
724
- e.appendChild(gi(m));
747
+ }
748
+ e.appendChild(Gr(f));
725
749
  continue;
726
750
  }
727
- const b = [a];
728
- for (n++; n < o.length && !Vr(o[n]); )
729
- b.push(o[n]), n++;
751
+ const x = [a];
752
+ for (n++; n < o.length && !hi(o[n]); )
753
+ x.push(o[n]), n++;
730
754
  e.appendChild(we("p", {
731
755
  margin: "0 0 8px 0",
732
756
  lineHeight: "1.6"
733
- }, b.map((m) => Xe(m)).join("<br>")));
757
+ }, x.map((f) => je(f)).join("<br>")));
734
758
  }
735
759
  const i = e.lastElementChild;
736
760
  return i && (i.style.marginBottom = "0"), e;
737
761
  }
738
- function Xr(t, e) {
762
+ function Yr(t, e) {
739
763
  const o = d({
740
764
  display: "flex",
741
765
  flexWrap: "wrap",
@@ -746,22 +770,22 @@ function Xr(t, e) {
746
770
  });
747
771
  o.className = "ago-message__attachments";
748
772
  for (const n of t) {
749
- const i = ti(n.url);
750
- if (ni(n) && i) {
773
+ const i = ni(n.url);
774
+ if (oi(n) && i) {
751
775
  const p = document.createElement("a");
752
776
  p.href = i, p.target = "_blank", p.rel = "noopener noreferrer", u(p, {
753
777
  display: "inline-block",
754
778
  textDecoration: "none"
755
779
  });
756
- const x = document.createElement("img");
757
- x.src = i, x.alt = n.name, x.loading = "lazy", u(x, {
780
+ const b = document.createElement("img");
781
+ b.src = i, b.alt = n.name, b.loading = "lazy", u(b, {
758
782
  maxWidth: "180px",
759
783
  maxHeight: "160px",
760
784
  objectFit: "cover",
761
785
  borderRadius: "10px",
762
786
  border: `1px solid ${Q}`,
763
787
  display: "block"
764
- }), p.appendChild(x), o.appendChild(p);
788
+ }), p.appendChild(b), o.appendChild(p);
765
789
  continue;
766
790
  }
767
791
  const a = i ? document.createElement("a") : document.createElement("div");
@@ -788,26 +812,26 @@ function Xr(t, e) {
788
812
  display: "flex",
789
813
  flexDirection: "column",
790
814
  minWidth: "0"
791
- }), b = d({
815
+ }), x = d({
792
816
  overflow: "hidden",
793
817
  textOverflow: "ellipsis",
794
818
  whiteSpace: "nowrap",
795
819
  maxWidth: "160px"
796
820
  });
797
- b.textContent = n.name, b.title = n.name, c.appendChild(b);
798
- const m = oi(n.fileSize);
799
- if (m) {
821
+ x.textContent = n.name, x.title = n.name, c.appendChild(x);
822
+ const f = ii(n.fileSize);
823
+ if (f) {
800
824
  const p = d({
801
825
  fontSize: "11px",
802
- color: rt
826
+ color: st
803
827
  });
804
- p.textContent = m, c.appendChild(p);
828
+ p.textContent = f, c.appendChild(p);
805
829
  }
806
830
  a.append(s, c), o.appendChild(a);
807
831
  }
808
832
  return o;
809
833
  }
810
- function hi(t, e) {
834
+ function bi(t, e) {
811
835
  const o = e.look === "embed", n = d({
812
836
  display: "flex",
813
837
  flexWrap: "wrap",
@@ -835,7 +859,7 @@ function hi(t, e) {
835
859
  minHeight: "44px",
836
860
  padding: "6px 14px",
837
861
  fontSize: "14px",
838
- borderRadius: nn,
862
+ borderRadius: on,
839
863
  border: `1px solid ${Q}`,
840
864
  backgroundColor: Ee,
841
865
  color: ne,
@@ -846,32 +870,32 @@ function hi(t, e) {
846
870
  a.addEventListener("click", () => s(i));
847
871
  }
848
872
  a.addEventListener("mouseenter", () => {
849
- o ? a.style.backgroundColor = "#fafafa" : a.style.borderColor = st;
873
+ o ? a.style.backgroundColor = "#fafafa" : a.style.borderColor = ct;
850
874
  }), a.addEventListener("mouseleave", () => {
851
875
  o ? a.style.backgroundColor = "#fff" : a.style.borderColor = Q;
852
876
  }), n.appendChild(a);
853
877
  }
854
878
  return n;
855
879
  }
856
- function Kr(t, e) {
857
- const { isLast: o, isLastOfBlock: n, bubbleStyle: i, showAgentName: a, agentBubble: s, followUpEnabled: c, followUpHandler: b, isMobile: m, feedbackRow: p } = e, x = t.role === "user", B = i === "imessage", _ = d({
880
+ function Qr(t, e) {
881
+ const { isLast: o, isLastOfBlock: n, bubbleStyle: i, showAgentName: a, agentBubble: s, followUpEnabled: c, followUpHandler: x, isMobile: f, feedbackRow: p } = e, b = t.role === "user", F = i === "imessage", y = d({
858
882
  display: "flex",
859
883
  flexDirection: "column",
860
- alignItems: x ? "flex-end" : "flex-start",
861
- marginBottom: B && !n ? "2px" : "16px"
884
+ alignItems: b ? "flex-end" : "flex-start",
885
+ marginBottom: F && !n ? "2px" : "16px"
862
886
  });
863
- if (_.className = `ago-message ago-message--${t.role}`, !x && a && t.agent) {
864
- const S = d({
887
+ if (y.className = `ago-message ago-message--${t.role}`, !b && a && t.agent) {
888
+ const _ = d({
865
889
  fontSize: "13px",
866
890
  fontWeight: "500",
867
891
  color: ne,
868
892
  marginBottom: "6px",
869
893
  padding: "0 4px"
870
894
  });
871
- S.className = "ago-message__agent", S.textContent = t.agent.displayName || t.agent.name, _.appendChild(S);
895
+ _.className = "ago-message__agent", _.textContent = t.agent.displayName || t.agent.name, y.appendChild(_);
872
896
  }
873
- if (!x && t.sources && t.sources.length > 0) {
874
- const S = d({
897
+ if (!b && t.sources && t.sources.length > 0) {
898
+ const _ = d({
875
899
  display: "grid",
876
900
  gridTemplateColumns: "1fr 1fr",
877
901
  gap: "6px",
@@ -879,9 +903,9 @@ function Kr(t, e) {
879
903
  width: "100%",
880
904
  maxWidth: "85%"
881
905
  });
882
- S.className = "ago-message__sources", t.sources.forEach((N, j) => {
883
- const C = N.url ? document.createElement("a") : document.createElement("div");
884
- N.url && C instanceof HTMLAnchorElement && (C.href = N.url, C.target = "_blank", C.rel = "noopener noreferrer"), u(C, {
906
+ _.className = "ago-message__sources", t.sources.forEach((I, j) => {
907
+ const w = I.url ? document.createElement("a") : document.createElement("div");
908
+ I.url && w instanceof HTMLAnchorElement && (w.href = I.url, w.target = "_blank", w.rel = "noopener noreferrer"), u(w, {
885
909
  display: "flex",
886
910
  alignItems: "center",
887
911
  gap: "8px",
@@ -894,13 +918,13 @@ function Kr(t, e) {
894
918
  fontSize: "12px",
895
919
  overflow: "hidden"
896
920
  });
897
- const z = d({
921
+ const O = d({
898
922
  flexShrink: "0",
899
923
  width: "18px",
900
924
  height: "18px",
901
925
  borderRadius: "3px",
902
- border: `1px solid ${st}`,
903
- color: st,
926
+ border: `1px solid ${ct}`,
927
+ color: ct,
904
928
  fontSize: "11px",
905
929
  fontWeight: "500",
906
930
  display: "flex",
@@ -908,62 +932,62 @@ function Kr(t, e) {
908
932
  justifyContent: "center",
909
933
  backgroundColor: "#f0f4ff"
910
934
  });
911
- z.textContent = String(j + 1);
912
- const v = d({
935
+ O.textContent = String(j + 1);
936
+ const E = d({
913
937
  overflow: "hidden",
914
938
  textOverflow: "ellipsis",
915
939
  whiteSpace: "nowrap"
916
940
  });
917
- v.textContent = N.title, v.title = N.title, C.append(z, v), S.appendChild(C);
918
- }), _.appendChild(S);
941
+ E.textContent = I.title, E.title = I.title, w.append(O, E), _.appendChild(w);
942
+ }), y.appendChild(_);
919
943
  }
920
- if (t.attachments && t.attachments.length > 0 && _.appendChild(Xr(t.attachments, {
921
- isUser: x,
922
- cardBackground: x ? "rgba(255,255,255,0.12)" : Ee,
923
- cardColor: x ? at : ne
924
- })), !x && e.renderToolCall && t.toolCalls?.length) for (const S of t.toolCalls) {
925
- const N = e.renderToolCall(S, t);
926
- N && _.appendChild(N);
944
+ if (t.attachments && t.attachments.length > 0 && y.appendChild(Yr(t.attachments, {
945
+ isUser: b,
946
+ cardBackground: b ? "rgba(255,255,255,0.12)" : Ee,
947
+ cardColor: b ? lt : ne
948
+ })), !b && e.renderToolCall && t.toolCalls?.length) for (const _ of t.toolCalls) {
949
+ const I = e.renderToolCall(_, t);
950
+ I && y.appendChild(I);
927
951
  }
928
- const h = x || s || B, E = !!t.content || t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", L = d({
929
- maxWidth: h ? B || x ? m ? "88%" : "75%" : m ? "92%" : "85%" : "100%",
930
- padding: h ? "10px 14px" : "2px 8px",
931
- borderRadius: B ? lr : h ? nn : "0",
932
- backgroundColor: x ? ve : h ? Bn : "transparent",
933
- color: x ? at : ne,
952
+ const m = b || s || F, k = !!t.content || t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", N = d({
953
+ maxWidth: m ? F || b ? f ? "88%" : "75%" : f ? "92%" : "85%" : "100%",
954
+ padding: m ? "10px 14px" : "2px 8px",
955
+ borderRadius: F ? cr : m ? on : "0",
956
+ backgroundColor: b ? ve : m ? Dn : "transparent",
957
+ color: b ? lt : ne,
934
958
  overflowWrap: "break-word",
935
959
  textWrap: "pretty",
936
960
  fontSize: "16px",
937
961
  lineHeight: "1.6"
938
962
  });
939
- if (L.className = "ago-message__content", B && n) {
940
- L.style.position = "relative";
941
- const S = d({
963
+ if (N.className = "ago-message__content", F && n) {
964
+ N.style.position = "relative";
965
+ const _ = d({
942
966
  position: "absolute",
943
967
  zIndex: "0",
944
968
  bottom: "-2px",
945
969
  width: "20px",
946
970
  height: "20px",
947
- background: x ? ve : Bn
971
+ background: b ? ve : Dn
948
972
  });
949
- S.className = "ago-message__tail";
950
- const N = d({
973
+ _.className = "ago-message__tail";
974
+ const I = d({
951
975
  position: "absolute",
952
976
  zIndex: "1",
953
977
  bottom: "-2px",
954
978
  width: "10px",
955
979
  height: "20px",
956
- background: ai
980
+ background: si
957
981
  });
958
- N.className = "ago-message__tail-mask", x ? (S.style.right = "-8px", S.style.borderBottomLeftRadius = "16px 14px", N.style.right = "-10px", N.style.borderBottomLeftRadius = "10px") : (S.style.left = "-7px", S.style.borderBottomRightRadius = "16px 14px", N.style.left = "-10px", N.style.borderBottomRightRadius = "10px"), L.append(S, N);
982
+ I.className = "ago-message__tail-mask", b ? (_.style.right = "-8px", _.style.borderBottomLeftRadius = "16px 14px", I.style.right = "-10px", I.style.borderBottomLeftRadius = "10px") : (_.style.left = "-7px", _.style.borderBottomRightRadius = "16px 14px", I.style.left = "-10px", I.style.borderBottomRightRadius = "10px"), N.append(_, I);
959
983
  }
960
- return t.content ? L.appendChild(lt(t.content)) : (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT") && L.appendChild(Qr()), E && _.appendChild(L), !x && p && _.appendChild(p), o && t.followUpReplies && t.followUpReplies.length > 0 && _.appendChild(hi(t.followUpReplies, {
984
+ return t.content ? N.appendChild(Ye(t.content)) : (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT") && N.appendChild(Jr()), k && y.appendChild(N), !b && p && y.appendChild(p), o && t.followUpReplies && t.followUpReplies.length > 0 && y.appendChild(bi(t.followUpReplies, {
961
985
  enabled: c,
962
- handler: b,
986
+ handler: x,
963
987
  look: "classic"
964
- })), _;
988
+ })), y;
965
989
  }
966
- function Yr(t) {
990
+ function Zr(t) {
967
991
  const e = d({
968
992
  display: "flex",
969
993
  alignItems: "center",
@@ -971,7 +995,7 @@ function Yr(t) {
971
995
  padding: "10px 14px",
972
996
  backgroundColor: "#f0fdf4",
973
997
  color: "#15803d",
974
- borderRadius: nn,
998
+ borderRadius: on,
975
999
  marginTop: "8px",
976
1000
  fontSize: "13px",
977
1001
  border: "1px solid #bbf7d0"
@@ -982,7 +1006,7 @@ function Yr(t) {
982
1006
  const n = document.createElement("span");
983
1007
  return n.textContent = t, e.append(o, n), e;
984
1008
  }
985
- function Qr() {
1009
+ function Jr() {
986
1010
  const t = d({
987
1011
  display: "flex",
988
1012
  gap: "4px",
@@ -1002,13 +1026,13 @@ function Qr() {
1002
1026
  }
1003
1027
  return t;
1004
1028
  }
1005
- function Zr() {
1029
+ function ea() {
1006
1030
  const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
1007
1031
  e.setAttribute("width", "26"), e.setAttribute("height", "26"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("fill", "none");
1008
1032
  const o = document.createElementNS(t, "path");
1009
1033
  return o.setAttribute("d", "M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"), o.setAttribute("stroke", "currentColor"), o.setAttribute("stroke-width", "2"), o.setAttribute("stroke-linecap", "round"), o.setAttribute("stroke-linejoin", "round"), e.appendChild(o), e;
1010
1034
  }
1011
- function Jr(t) {
1035
+ function ta(t) {
1012
1036
  const e = document.createElement("button");
1013
1037
  if (e.type = "button", e.className = "ago-chat-widget-launcher", e.setAttribute("aria-label", t.labels?.open ?? `Open ${t.title}`), e.setAttribute("aria-expanded", "false"), t.look === "classic") {
1014
1038
  if (u(e, {
@@ -1020,7 +1044,7 @@ function Jr(t) {
1020
1044
  borderRadius: "50%",
1021
1045
  border: "none",
1022
1046
  backgroundColor: ve,
1023
- color: at,
1047
+ color: lt,
1024
1048
  cursor: "pointer",
1025
1049
  display: "flex",
1026
1050
  alignItems: "center",
@@ -1035,7 +1059,7 @@ function Jr(t) {
1035
1059
  height: "26px",
1036
1060
  objectFit: "contain"
1037
1061
  }), e.appendChild(i);
1038
- } else e.appendChild(Zr());
1062
+ } else e.appendChild(ea());
1039
1063
  return e.addEventListener("click", t.onClick), {
1040
1064
  el: e,
1041
1065
  setOpen: (i) => {
@@ -1054,8 +1078,8 @@ function Jr(t) {
1054
1078
  boxSizing: "border-box",
1055
1079
  border: "none",
1056
1080
  borderRadius: "50%",
1057
- backgroundColor: dr,
1058
- color: ur,
1081
+ backgroundColor: pr,
1082
+ color: fr,
1059
1083
  display: "flex",
1060
1084
  alignItems: "center",
1061
1085
  justifyContent: "center",
@@ -1080,9 +1104,9 @@ function Jr(t) {
1080
1104
  width: "32px",
1081
1105
  height: "32px",
1082
1106
  objectFit: "contain"
1083
- }), o = i, n = Cr(), e.append(i, n);
1107
+ }), o = i, n = wr(), e.append(i, n);
1084
1108
  } else {
1085
- const i = mr();
1109
+ const i = gr();
1086
1110
  o = i.querySelector('[data-ago-path="open"]'), n = i.querySelector('[data-ago-path="close"]'), e.appendChild(i);
1087
1111
  }
1088
1112
  return n.style.display = "none", e.addEventListener("click", t.onClick), {
@@ -1092,7 +1116,7 @@ function Jr(t) {
1092
1116
  }
1093
1117
  };
1094
1118
  }
1095
- function ea(t) {
1119
+ function na(t) {
1096
1120
  const e = d({
1097
1121
  marginBottom: "12px",
1098
1122
  display: "flex",
@@ -1101,7 +1125,7 @@ function ea(t) {
1101
1125
  });
1102
1126
  e.className = "ago-message__attachments";
1103
1127
  for (const o of t.attachments ?? []) {
1104
- const n = ti(o.url), i = d({
1128
+ const n = ni(o.url), i = d({
1105
1129
  display: "flex",
1106
1130
  alignItems: "center",
1107
1131
  gap: "8px",
@@ -1113,7 +1137,7 @@ function ea(t) {
1113
1137
  maxWidth: "100%",
1114
1138
  boxSizing: "border-box"
1115
1139
  });
1116
- if (ni(o) && n) {
1140
+ if (oi(o) && n) {
1117
1141
  const a = document.createElement("a");
1118
1142
  a.href = n, a.target = "_blank", a.rel = "noopener noreferrer", u(a, {
1119
1143
  display: "flex",
@@ -1156,15 +1180,15 @@ function ea(t) {
1156
1180
  overflow: "hidden",
1157
1181
  textOverflow: "ellipsis",
1158
1182
  whiteSpace: "nowrap"
1159
- }), a.append(_r({ size: 20 }), s);
1160
- const c = oi(o.fileSize);
1183
+ }), a.append(Tr({ size: 20 }), s);
1184
+ const c = ii(o.fileSize);
1161
1185
  if (c) {
1162
- const b = document.createElement("span");
1163
- b.textContent = c, u(b, {
1186
+ const x = document.createElement("span");
1187
+ x.textContent = c, u(x, {
1164
1188
  fontSize: "12px",
1165
1189
  lineHeight: "16px",
1166
1190
  color: "#6b7280"
1167
- }), a.appendChild(b);
1191
+ }), a.appendChild(x);
1168
1192
  }
1169
1193
  i.appendChild(a);
1170
1194
  }
@@ -1172,7 +1196,7 @@ function ea(t) {
1172
1196
  }
1173
1197
  return e;
1174
1198
  }
1175
- function ta(t) {
1199
+ function oa(t) {
1176
1200
  const e = d({
1177
1201
  display: "flex",
1178
1202
  justifyContent: "flex-end"
@@ -1181,20 +1205,20 @@ function ta(t) {
1181
1205
  borderRadius: "16px",
1182
1206
  marginBottom: "16px",
1183
1207
  padding: "16px",
1184
- backgroundColor: yr,
1185
- color: zr,
1208
+ backgroundColor: Cr,
1209
+ color: Or,
1186
1210
  boxSizing: "border-box",
1187
1211
  fontSize: "14px",
1188
1212
  lineHeight: "24px"
1189
1213
  });
1190
- o.className = "ago-message__content", t.attachments?.length && o.appendChild(ea(t));
1214
+ o.className = "ago-message__content", t.attachments?.length && o.appendChild(na(t));
1191
1215
  const n = d({
1192
1216
  whiteSpace: "pre-wrap",
1193
1217
  overflowWrap: "break-word"
1194
1218
  });
1195
1219
  return n.textContent = t.content, o.appendChild(n), e.appendChild(o), e;
1196
1220
  }
1197
- function na(t) {
1221
+ function ia(t) {
1198
1222
  const e = d({
1199
1223
  display: "grid",
1200
1224
  gridTemplateColumns: "1fr 1fr",
@@ -1209,10 +1233,10 @@ function na(t) {
1209
1233
  height: "48px",
1210
1234
  justifyContent: "flex-start",
1211
1235
  padding: "8px 16px",
1212
- border: `1px solid ${ii}`,
1236
+ border: `1px solid ${ri}`,
1213
1237
  backgroundColor: "#fff",
1214
1238
  borderRadius: "6px",
1215
- boxShadow: Jt,
1239
+ boxShadow: en,
1216
1240
  fontSize: "14px",
1217
1241
  fontWeight: "500",
1218
1242
  color: ne,
@@ -1236,9 +1260,9 @@ function na(t) {
1236
1260
  width: "16px",
1237
1261
  height: "16px",
1238
1262
  borderRadius: "4px",
1239
- border: `1px solid ${On}`,
1240
- color: On,
1241
- backgroundColor: di,
1263
+ border: `1px solid ${Bn}`,
1264
+ color: Bn,
1265
+ backgroundColor: pi,
1242
1266
  fontSize: "12px",
1243
1267
  lineHeight: "1",
1244
1268
  display: "flex",
@@ -1257,13 +1281,13 @@ function na(t) {
1257
1281
  c.textContent = o.title, c.title = o.title, a.append(s, c), i.appendChild(a), e.appendChild(i);
1258
1282
  }), e;
1259
1283
  }
1260
- function qo(t, e) {
1261
- return bi({
1284
+ function Go(t, e) {
1285
+ return xi({
1262
1286
  errorTitle: t,
1263
1287
  errorDescription: e
1264
1288
  });
1265
1289
  }
1266
- function bi(t) {
1290
+ function xi(t) {
1267
1291
  const e = d({
1268
1292
  position: "relative",
1269
1293
  width: "100%",
@@ -1277,7 +1301,7 @@ function bi(t) {
1277
1301
  boxSizing: "border-box"
1278
1302
  });
1279
1303
  e.className = "ago-message__error", e.setAttribute("role", "alert");
1280
- const o = vr({ size: 16 });
1304
+ const o = Er({ size: 16 });
1281
1305
  u(o, {
1282
1306
  position: "absolute",
1283
1307
  left: "16px",
@@ -1297,7 +1321,7 @@ function bi(t) {
1297
1321
  });
1298
1322
  return i.textContent = t.errorDescription, e.append(o, n, i), e;
1299
1323
  }
1300
- function oa() {
1324
+ function ra() {
1301
1325
  const t = d({
1302
1326
  marginTop: "4px",
1303
1327
  animation: "ago-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
@@ -1312,7 +1336,7 @@ function oa() {
1312
1336
  });
1313
1337
  return t.appendChild(e), t;
1314
1338
  }
1315
- function ia() {
1339
+ function aa() {
1316
1340
  const t = d({
1317
1341
  display: "flex",
1318
1342
  alignItems: "center",
@@ -1320,13 +1344,13 @@ function ia() {
1320
1344
  gap: "8px"
1321
1345
  });
1322
1346
  t.className = "ago-message__spinner";
1323
- const e = Hr({ size: 20 });
1347
+ const e = Br({ size: 20 });
1324
1348
  return u(e, {
1325
1349
  color: "#a1a1aa",
1326
1350
  animation: "ago-spin 1s linear infinite"
1327
1351
  }), t.appendChild(e), t;
1328
1352
  }
1329
- function ra(t, e) {
1353
+ function sa(t, e) {
1330
1354
  const o = t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", n = d({
1331
1355
  position: "relative",
1332
1356
  display: "flex",
@@ -1336,7 +1360,7 @@ function ra(t, e) {
1336
1360
  marginBottom: "16px",
1337
1361
  boxSizing: "border-box"
1338
1362
  });
1339
- n.className = "ago-message__row", e.agentRowTinted && (n.style.backgroundColor = Bn), e.agentRowTextTinted && (n.style.color = cr);
1363
+ n.className = "ago-message__row", e.agentRowTinted && (n.style.backgroundColor = Dn), e.agentRowTextTinted && (n.style.color = dr);
1340
1364
  const i = d({
1341
1365
  flex: "1",
1342
1366
  minWidth: "0",
@@ -1345,47 +1369,47 @@ function ra(t, e) {
1345
1369
  fontSize: "14px",
1346
1370
  lineHeight: "24px"
1347
1371
  });
1348
- if (i.className = "ago-message__body", o && i.appendChild(ia()), t.sources?.length && i.appendChild(na(t)), e.renderToolCall && t.toolCalls?.length) for (const a of t.toolCalls) {
1372
+ if (i.className = "ago-message__body", o && i.appendChild(aa()), t.sources?.length && i.appendChild(ia(t)), e.renderToolCall && t.toolCalls?.length) for (const a of t.toolCalls) {
1349
1373
  const s = e.renderToolCall(a, t);
1350
1374
  s && i.appendChild(s);
1351
1375
  }
1352
- if (t.status === "ERROR") i.appendChild(bi(e.labels));
1376
+ if (t.status === "ERROR") i.appendChild(xi(e.labels));
1353
1377
  else if (t.content) {
1354
1378
  const a = d({});
1355
- a.className = "ago-message__markdown ago-message__content", a.appendChild(lt(t.content)), i.appendChild(a);
1356
- } else o && i.appendChild(oa());
1357
- return e.isLast && t.status === "DONE" && t.followUpReplies?.length && i.appendChild(hi(t.followUpReplies, {
1379
+ a.className = "ago-message__markdown ago-message__content", a.appendChild(Ye(t.content)), i.appendChild(a);
1380
+ } else o && i.appendChild(ra());
1381
+ return e.isLast && t.status === "DONE" && t.followUpReplies?.length && i.appendChild(bi(t.followUpReplies, {
1358
1382
  enabled: e.followUpEnabled,
1359
1383
  handler: e.followUpHandler,
1360
1384
  look: "embed"
1361
1385
  })), e.actionsRow && !o && i.appendChild(e.actionsRow), n.appendChild(i), n;
1362
1386
  }
1363
- function aa(t, e) {
1387
+ function la(t, e) {
1364
1388
  const o = d({});
1365
- return o.className = `ago-message ago-message--${t.role}`, o.dataset.messageId = t.id, o.dataset.messageRole = t.role, o.appendChild(t.role === "user" ? ta(t) : ra(t, e)), o;
1389
+ return o.className = `ago-message ago-message--${t.role}`, o.dataset.messageId = t.id, o.dataset.messageRole = t.role, o.appendChild(t.role === "user" ? oa(t) : sa(t, e)), o;
1366
1390
  }
1367
- var Mn = "ago-hs-form-ready";
1368
- function sa(t, e) {
1391
+ var Wn = "ago-hs-form-ready";
1392
+ function ca(t, e) {
1369
1393
  const o = t.tagName === "TEXTAREA" ? Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value") : Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value"), n = t._valueTracker;
1370
1394
  n && n.setValue(""), t.focus(), t.dispatchEvent(new Event("focus", { bubbles: !0 })), o?.set ? o.set.call(t, e) : t.value = e, t.setAttribute("value", e), t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 })), t.dispatchEvent(new Event("blur", { bubbles: !0 }));
1371
1395
  }
1372
- function en(t, e) {
1396
+ function tn(t, e) {
1373
1397
  const o = t.querySelectorAll("input, textarea, select");
1374
1398
  let n = !1;
1375
1399
  for (const i of o) {
1376
1400
  if (i.type === "hidden" || i.type === "submit" || i.type === "button") continue;
1377
1401
  const a = e[i.name] ?? (i.name.includes("/") ? e[i.name.split("/").pop()] : void 0);
1378
- a && !i.value && (sa(i, a), n = !0);
1402
+ a && !i.value && (ca(i, a), n = !0);
1379
1403
  }
1380
1404
  return n;
1381
1405
  }
1382
- function la(t) {
1383
- return `function($f){document.dispatchEvent(new CustomEvent(${JSON.stringify(Mn)},{detail:{token:${JSON.stringify(t)},form:$f}}))}`;
1406
+ function da(t) {
1407
+ return `function($f){document.dispatchEvent(new CustomEvent(${JSON.stringify(Wn)},{detail:{token:${JSON.stringify(t)},form:$f}}))}`;
1384
1408
  }
1385
- function ca(t, e, o) {
1386
- return !t || !e || Object.keys(e).length === 0 ? t : /hbspt\.forms\.create\s*\(\s*\{/.test(t) && !/onFormReady/.test(t) ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormReady:${la(o)},`) : t;
1409
+ function pa(t, e, o) {
1410
+ return !t || !e || Object.keys(e).length === 0 ? t : /hbspt\.forms\.create\s*\(\s*\{/.test(t) && !/onFormReady/.test(t) ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormReady:${da(o)},`) : t;
1387
1411
  }
1388
- function da(t, e) {
1412
+ function ua(t, e) {
1389
1413
  if (!t || Object.keys(t).length === 0) return () => {
1390
1414
  };
1391
1415
  const o = {};
@@ -1393,25 +1417,25 @@ function da(t, e) {
1393
1417
  const n = [], i = [], a = (s) => {
1394
1418
  const c = s.detail;
1395
1419
  if (!c || c.token !== e) return;
1396
- const b = c.form, m = b && typeof b == "object" && "jquery" in b && b.jquery ? b[0] : b;
1397
- if (!m || typeof m.querySelectorAll != "function") return;
1398
- en(m, o);
1420
+ const x = c.form, f = x && typeof x == "object" && "jquery" in x && x.jquery ? x[0] : x;
1421
+ if (!f || typeof f.querySelectorAll != "function") return;
1422
+ tn(f, o);
1399
1423
  const p = new MutationObserver(() => {
1400
- en(m, o);
1424
+ tn(f, o);
1401
1425
  });
1402
- p.observe(m, {
1426
+ p.observe(f, {
1403
1427
  childList: !0,
1404
1428
  subtree: !0
1405
1429
  }), n.push(p), i.push(setTimeout(() => p.disconnect(), 1e4));
1406
1430
  };
1407
- return document.addEventListener(Mn, a), () => {
1408
- document.removeEventListener(Mn, a), n.forEach((s) => s.disconnect()), i.forEach((s) => clearTimeout(s));
1431
+ return document.addEventListener(Wn, a), () => {
1432
+ document.removeEventListener(Wn, a), n.forEach((s) => s.disconnect()), i.forEach((s) => clearTimeout(s));
1409
1433
  };
1410
1434
  }
1411
- function xi() {
1435
+ function yi() {
1412
1436
  return globalThis.HubSpotFormsV4;
1413
1437
  }
1414
- async function yi(t, e) {
1438
+ async function Ci(t, e) {
1415
1439
  let o = null;
1416
1440
  if (t.getFormFieldValues) try {
1417
1441
  const n = await t.getFormFieldValues();
@@ -1434,28 +1458,28 @@ async function yi(t, e) {
1434
1458
  }
1435
1459
  }
1436
1460
  }
1437
- function Go(t) {
1461
+ function Xo(t) {
1438
1462
  if (!t || Object.keys(t).length === 0) return () => {
1439
1463
  };
1440
1464
  const e = (o) => {
1441
1465
  try {
1442
- const n = xi()?.getFormFromEvent?.(o);
1466
+ const n = yi()?.getFormFromEvent?.(o);
1443
1467
  if (!n?.setFieldValue) return;
1444
- yi(n, t);
1468
+ Ci(n, t);
1445
1469
  } catch {
1446
1470
  }
1447
1471
  };
1448
1472
  return window.addEventListener("hs-form-event:on-ready", e), () => window.removeEventListener("hs-form-event:on-ready", e);
1449
1473
  }
1450
- function pa(t) {
1451
- const e = xi()?.getForms?.();
1474
+ function fa(t) {
1475
+ const e = yi()?.getForms?.();
1452
1476
  if (!Array.isArray(e) || e.length === 0) return !1;
1453
1477
  for (const o of e)
1454
- o?.setFieldValue && yi(o, t);
1478
+ o?.setFieldValue && Ci(o, t);
1455
1479
  return !0;
1456
1480
  }
1457
- var jn = "ago-hs-form-submit", Wn = "ago-hs-form-submitted";
1458
- function Zt(t) {
1481
+ var Un = "ago-hs-form-submit", Pn = "ago-hs-form-submitted";
1482
+ function Jt(t) {
1459
1483
  if (!t || typeof t != "object") return t;
1460
1484
  let e;
1461
1485
  if (Array.isArray(t)) {
@@ -1469,7 +1493,7 @@ function Zt(t) {
1469
1493
  }
1470
1494
  return Object.keys(o).length > 0 ? o : null;
1471
1495
  }
1472
- function ua(t) {
1496
+ function ma(t) {
1473
1497
  try {
1474
1498
  const e = new FormData(t), o = {};
1475
1499
  return e.forEach((n, i) => {
@@ -1479,131 +1503,131 @@ function ua(t) {
1479
1503
  return null;
1480
1504
  }
1481
1505
  }
1482
- function Xo(t, e, o) {
1506
+ function Ko(t, e, o) {
1483
1507
  const n = o ? `{token:${JSON.stringify(e)},form:$f}` : `{token:${JSON.stringify(e)}}`;
1484
1508
  return `function(${o ? "$f" : ""}){document.dispatchEvent(new CustomEvent(${JSON.stringify(t)},{detail:${n}}))}`;
1485
1509
  }
1486
- function fa(t, e) {
1487
- return t && (/hbspt\.forms\.create\s*\(\s*\{/.test(t) && !t.includes("ago-hs-form-submitted") ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormSubmit:${Xo(jn, e, !0)},onFormSubmitted:${Xo(Wn, e, !1)},`) : t);
1510
+ function ga(t, e) {
1511
+ return t && (/hbspt\.forms\.create\s*\(\s*\{/.test(t) && !t.includes("ago-hs-form-submitted") ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormSubmit:${Ko(Un, e, !0)},onFormSubmitted:${Ko(Pn, e, !1)},`) : t);
1488
1512
  }
1489
- function ma(t, e, o, n) {
1513
+ function ha(t, e, o, n) {
1490
1514
  let i = !1, a = null;
1491
1515
  function s() {
1492
- i || (i = !0, e(Zt(a)));
1516
+ i || (i = !0, e(Jt(a)));
1493
1517
  }
1494
- function c(h) {
1495
- if (a || (a = ua(h)), h.closest(".hs-form, .hbspt-form, [data-hs-forms]")) {
1518
+ function c(m) {
1519
+ if (a || (a = ma(m)), m.closest(".hs-form, .hbspt-form, [data-hs-forms]")) {
1496
1520
  o?.();
1497
1521
  return;
1498
1522
  }
1499
1523
  s();
1500
1524
  }
1501
- const b = (h) => {
1502
- const E = h.target;
1503
- E?.tagName === "FORM" && c(E);
1525
+ const x = (m) => {
1526
+ const k = m.target;
1527
+ k?.tagName === "FORM" && c(k);
1504
1528
  };
1505
- t.addEventListener("submit", b, !0);
1506
- const m = /* @__PURE__ */ new WeakSet();
1507
- function p(h) {
1508
- m.has(h) || (m.add(h), h.addEventListener("submit", () => c(h)));
1529
+ t.addEventListener("submit", x, !0);
1530
+ const f = /* @__PURE__ */ new WeakSet();
1531
+ function p(m) {
1532
+ f.has(m) || (f.add(m), m.addEventListener("submit", () => c(m)));
1509
1533
  }
1510
- for (const h of t.querySelectorAll("form")) p(h);
1511
- const x = new MutationObserver(() => {
1512
- for (const h of t.querySelectorAll("form")) p(h);
1534
+ for (const m of t.querySelectorAll("form")) p(m);
1535
+ const b = new MutationObserver(() => {
1536
+ for (const m of t.querySelectorAll("form")) p(m);
1513
1537
  });
1514
- x.observe(t, {
1538
+ b.observe(t, {
1515
1539
  childList: !0,
1516
1540
  subtree: !0
1517
1541
  });
1518
- const B = (h) => {
1519
- const E = h.detail;
1520
- if (!(!E || E.token !== n))
1542
+ const F = (m) => {
1543
+ const k = m.detail;
1544
+ if (!(!k || k.token !== n))
1521
1545
  try {
1522
- const L = E.form, S = L && typeof L == "object" && "jquery" in L && L.jquery ? L[0] : L;
1523
- if (S?.querySelectorAll) {
1524
- const N = S.querySelectorAll("input, textarea, select"), j = {};
1525
- for (const C of N) C.name && C.type !== "submit" && C.type !== "button" && (j[C.name] = C.value || "");
1546
+ const N = k.form, _ = N && typeof N == "object" && "jquery" in N && N.jquery ? N[0] : N;
1547
+ if (_?.querySelectorAll) {
1548
+ const I = _.querySelectorAll("input, textarea, select"), j = {};
1549
+ for (const w of I) w.name && w.type !== "submit" && w.type !== "button" && (j[w.name] = w.value || "");
1526
1550
  Object.keys(j).length > 0 && (a = j);
1527
1551
  }
1528
1552
  } catch {
1529
1553
  }
1530
- }, _ = (h) => {
1531
- const E = h.detail;
1532
- !E || E.token !== n || s();
1554
+ }, y = (m) => {
1555
+ const k = m.detail;
1556
+ !k || k.token !== n || s();
1533
1557
  };
1534
- return document.addEventListener(jn, B), document.addEventListener(Wn, _), () => {
1535
- t.removeEventListener("submit", b, !0), x.disconnect(), document.removeEventListener(jn, B), document.removeEventListener(Wn, _);
1558
+ return document.addEventListener(Un, F), document.addEventListener(Pn, y), () => {
1559
+ t.removeEventListener("submit", x, !0), b.disconnect(), document.removeEventListener(Un, F), document.removeEventListener(Pn, y);
1536
1560
  };
1537
1561
  }
1538
- function fe(t) {
1562
+ function me(t) {
1539
1563
  return t.externalId || t.id;
1540
1564
  }
1541
- function Ci(t) {
1565
+ function wi(t) {
1542
1566
  return t.conditionalFieldValues?.length ? t.conditionalFieldValues : t.conditionalFieldValue?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
1543
1567
  }
1544
- function wi(t, e) {
1568
+ function vi(t, e) {
1545
1569
  return !t.priorityTypologies?.length || !e || t.priorityTypologies.includes(e);
1546
1570
  }
1547
- function vi(t, e, o, n, i, a) {
1571
+ function Ei(t, e, o, n, i, a) {
1548
1572
  if (!e || !o.length) return !0;
1549
1573
  const s = t.fields.find((c) => c.id === e || c.externalId === e);
1550
- return s ? on(t, s, n, i, a) && o.includes(n[fe(s)]) : !0;
1574
+ return s ? rn(t, s, n, i, a) && o.includes(n[me(s)]) : !0;
1551
1575
  }
1552
- function on(t, e, o, n = "", i = /* @__PURE__ */ new Set()) {
1576
+ function rn(t, e, o, n = "", i = /* @__PURE__ */ new Set()) {
1553
1577
  if (e.active === !1 || i.has(e.id)) return !1;
1554
1578
  const a = new Set(i).add(e.id);
1555
- return vi(t, e.conditionalFieldId, Ci(e), o, n, a);
1579
+ return Ei(t, e.conditionalFieldId, wi(e), o, n, a);
1556
1580
  }
1557
- function Ei(t, e, o, n = "") {
1558
- return e.options.filter((i) => vi(t, i.conditionalFieldId, i.conditionalFieldValues ?? [], o, n, /* @__PURE__ */ new Set())).sort((i, a) => (i.position ?? 0) - (a.position ?? 0));
1581
+ function ki(t, e, o, n = "") {
1582
+ return e.options.filter((i) => Ei(t, i.conditionalFieldId, i.conditionalFieldValues ?? [], o, n, /* @__PURE__ */ new Set())).sort((i, a) => (i.position ?? 0) - (a.position ?? 0));
1559
1583
  }
1560
- function ot(t, e, o = "") {
1584
+ function rt(t, e, o = "") {
1561
1585
  let n;
1562
1586
  do {
1563
1587
  n = !1;
1564
1588
  for (const i of t.fields) {
1565
- const a = fe(i);
1589
+ const a = me(i);
1566
1590
  if (!(a in e)) continue;
1567
- const s = !i.options.length || !e[a] || Ei(t, i, e, o).some((c) => (c.value ?? c.name ?? "") === e[a]);
1568
- (!on(t, i, e, o) || !s) && (delete e[a], n = !0);
1591
+ const s = !i.options.length || !e[a] || ki(t, i, e, o).some((c) => (c.value ?? c.name ?? "") === e[a]);
1592
+ (!rn(t, i, e, o) || !s) && (delete e[a], n = !0);
1569
1593
  }
1570
1594
  } while (n);
1571
1595
  }
1572
- function ga(t, e, o = "") {
1573
- const n = [...t.fields].sort((i, a) => i.position - a.position).filter((i) => !i.hidden && on(t, i, e, o));
1596
+ function ba(t, e, o = "") {
1597
+ const n = [...t.fields].sort((i, a) => i.position - a.position).filter((i) => !i.hidden && rn(t, i, e, o));
1574
1598
  return n.filter((i, a) => {
1575
- if (a === 0 || i.alwaysVisible || i.conditionalFieldId && Ci(i).length) return !0;
1599
+ if (a === 0 || i.alwaysVisible || i.conditionalFieldId && wi(i).length) return !0;
1576
1600
  const s = n[a - 1];
1577
- return s.type === "checkbox" || !!e[fe(s)]?.trim();
1601
+ return s.type === "checkbox" || !!e[me(s)]?.trim();
1578
1602
  });
1579
1603
  }
1580
- var ha = Vn.form;
1581
- function Ko(t, e) {
1582
- return Me(Me(ha, t), e);
1604
+ var xa = Gn.form;
1605
+ function Yo(t, e) {
1606
+ return Me(Me(xa, t), e);
1583
1607
  }
1584
- function tn(t, e) {
1608
+ function nn(t, e) {
1585
1609
  return t.replace(/(?<!\{)\{(\w+)\}(?!\})/g, (o, n) => Object.prototype.hasOwnProperty.call(e, n) ? e[n] : o);
1586
1610
  }
1587
- var ba = "var(--ago-send-button-background, var(--ago-accent-color, #003edf))", xa = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
1588
- function ya(t) {
1611
+ var ya = "var(--ago-send-button-background, var(--ago-accent-color, #003edf))", Ca = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
1612
+ function wa(t) {
1589
1613
  return t.toLowerCase().trim().replace(/[^a-z0-9_]/g, "_");
1590
1614
  }
1591
- function Gn(t, e, o) {
1615
+ function Kn(t, e, o) {
1592
1616
  const n = {};
1593
1617
  if (e) {
1594
1618
  for (const i of e.fields) {
1595
1619
  if (i.active === !1) continue;
1596
1620
  const a = i.options.find((s) => s.default);
1597
- a && (n[fe(i)] = a.value ?? a.name ?? "");
1621
+ a && (n[me(i)] = a.value ?? a.name ?? "");
1598
1622
  }
1599
1623
  if (t?.tag)
1600
- for (const i of e.fields) i.type === "tagger" && (n[fe(i)] = t.tag);
1624
+ for (const i of e.fields) i.type === "tagger" && (n[me(i)] = t.tag);
1601
1625
  if (t?.custom_fields) for (const [i, a] of Object.entries(t.custom_fields)) {
1602
- const s = e.fields.find((c) => c.externalId === i || c.id === i || (c.prefillAliases?.length ? c.prefillAliases.includes(i) : c.title ? ya(c.title) === i : !1));
1603
- s && (n[fe(s)] = a);
1626
+ const s = e.fields.find((c) => c.externalId === i || c.id === i || (c.prefillAliases?.length ? c.prefillAliases.includes(i) : c.title ? wa(c.title) === i : !1));
1627
+ s && (n[me(s)] = a);
1604
1628
  }
1605
1629
  }
1606
- return e && ot(e, n, t?.typology ?? "Question"), {
1630
+ return e && rt(e, n, t?.typology ?? "Question"), {
1607
1631
  ticket: {
1608
1632
  subject: t?.subject ?? "",
1609
1633
  typology: t?.typology ?? "Question",
@@ -1620,27 +1644,27 @@ function Gn(t, e, o) {
1620
1644
  submitError: null
1621
1645
  };
1622
1646
  }
1623
- function Ca(t, e, o) {
1647
+ function va(t, e, o) {
1624
1648
  t.customFields = {
1625
- ...Gn(e, o, t.email).customFields,
1649
+ ...Kn(e, o, t.email).customFields,
1626
1650
  ...t.customFields
1627
- }, ot(o, t.customFields, t.ticket.typology);
1651
+ }, rt(o, t.customFields, t.ticket.typology);
1628
1652
  }
1629
- function wa(t, e, o, n) {
1653
+ function Ea(t, e, o, n) {
1630
1654
  const i = {}, a = e.ticket;
1631
- t.showSubject && !a.subject.trim() && (i.subject = o.subjectRequired), t.showTypology && !a.typology.trim() && (i.typology = o.typologyRequired), t.showPriority && wi(t, a.typology) && !a.priority.trim() && (i.priority = o.priorityRequired), t.showBody && !a.body.trim() && (i.body = o.detailedContextRequired);
1655
+ t.showSubject && !a.subject.trim() && (i.subject = o.subjectRequired), t.showTypology && !a.typology.trim() && (i.typology = o.typologyRequired), t.showPriority && vi(t, a.typology) && !a.priority.trim() && (i.priority = o.priorityRequired), t.showBody && !a.body.trim() && (i.body = o.detailedContextRequired);
1632
1656
  for (const s of t.fields) {
1633
- if (s.hidden || !on(t, s, e.customFields, a.typology)) continue;
1634
- const c = e.customFields[fe(s)];
1635
- if (s.required && !c?.trim()) i[fe(s)] = tn(o.fieldRequired, { fieldTitle: s.title ?? "" });
1657
+ if (s.hidden || !rn(t, s, e.customFields, a.typology)) continue;
1658
+ const c = e.customFields[me(s)];
1659
+ if (s.required && !c?.trim()) i[me(s)] = nn(o.fieldRequired, { fieldTitle: s.title ?? "" });
1636
1660
  else if (s.regexpForValidation && c?.trim()) try {
1637
- new RegExp(s.regexpForValidation).test(c) || (i[fe(s)] = tn(o.fieldFormatInvalid, { fieldTitle: s.title ?? "" }));
1661
+ new RegExp(s.regexpForValidation).test(c) || (i[me(s)] = nn(o.fieldFormatInvalid, { fieldTitle: s.title ?? "" }));
1638
1662
  } catch {
1639
1663
  }
1640
1664
  }
1641
- return n && (e.email.trim() ? xa.test(e.email) || (i.userEmail = o.emailInvalid) : i.userEmail = o.emailRequired), i;
1665
+ return n && (e.email.trim() ? Ca.test(e.email) || (i.userEmail = o.emailInvalid) : i.userEmail = o.emailRequired), i;
1642
1666
  }
1643
- var va = {
1667
+ var ka = {
1644
1668
  border: `1px solid ${Q}`,
1645
1669
  borderRadius: "4px",
1646
1670
  width: "100%",
@@ -1652,7 +1676,7 @@ var va = {
1652
1676
  color: ne,
1653
1677
  backgroundColor: Ee
1654
1678
  };
1655
- function Ve(t, e) {
1679
+ function qe(t, e) {
1656
1680
  const o = document.createElement("label");
1657
1681
  return o.htmlFor = e, o.textContent = t, u(o, {
1658
1682
  display: "block",
@@ -1668,7 +1692,7 @@ function Te(t) {
1668
1692
  margin: "0"
1669
1693
  }), e;
1670
1694
  }
1671
- function qe() {
1695
+ function Ge() {
1672
1696
  const t = d({
1673
1697
  display: "flex",
1674
1698
  flexDirection: "column",
@@ -1676,14 +1700,14 @@ function qe() {
1676
1700
  });
1677
1701
  return t.className = "ago-ticket-form__field", t;
1678
1702
  }
1679
- function Ge(t, e, o) {
1680
- u(t, va), e && (t.style.borderColor = "#ef4444"), t.disabled = o, o && (t.style.opacity = "0.5", t.style.cursor = "not-allowed"), t.addEventListener("focus", () => {
1703
+ function Xe(t, e, o) {
1704
+ u(t, ka), e && (t.style.borderColor = "#ef4444"), t.disabled = o, o && (t.style.opacity = "0.5", t.style.cursor = "not-allowed"), t.addEventListener("focus", () => {
1681
1705
  t.style.outline = "2px solid var(--ago-accent-color, #003edf)", t.style.outlineOffset = "1px";
1682
1706
  }), t.addEventListener("blur", () => {
1683
1707
  t.style.outline = "", t.style.outlineOffset = "";
1684
1708
  });
1685
1709
  }
1686
- function ki(t) {
1710
+ function Si(t) {
1687
1711
  const e = d({
1688
1712
  padding: "16px",
1689
1713
  borderRadius: "4px",
@@ -1714,7 +1738,7 @@ function ki(t) {
1714
1738
  }
1715
1739
  return e;
1716
1740
  }
1717
- function Yo(t) {
1741
+ function Qo(t) {
1718
1742
  const e = d({
1719
1743
  width: "100%",
1720
1744
  padding: "16px",
@@ -1747,9 +1771,9 @@ function Yo(t) {
1747
1771
  lineHeight: "1"
1748
1772
  });
1749
1773
  const n = d({ minWidth: "0" });
1750
- return n.appendChild(lt(t)), e.append(o, n), e;
1774
+ return n.appendChild(Ye(t)), e.append(o, n), e;
1751
1775
  }
1752
- function Ea(t) {
1776
+ function Sa(t) {
1753
1777
  const { state: e, labels: o } = t;
1754
1778
  let n = t.ticketForm, i = 0, a = t.allowFiles;
1755
1779
  const s = d({
@@ -1766,95 +1790,95 @@ function Ea(t) {
1766
1790
  });
1767
1791
  s.className = "ago-ticket-form";
1768
1792
  function c() {
1769
- return n ? (e.errors = wa(n, e, o, t.requireEmail), Object.keys(e.errors).length === 0) : !1;
1793
+ return n ? (e.errors = Ea(n, e, o, t.requireEmail), Object.keys(e.errors).length === 0) : !1;
1770
1794
  }
1771
- async function b() {
1795
+ async function x() {
1772
1796
  if (e.loading || e.submitted || !n) return;
1773
- if (ot(n, e.customFields, e.ticket.typology), e.submittedOnce = !0, e.submitError = null, !c()) {
1797
+ if (rt(n, e.customFields, e.ticket.typology), e.submittedOnce = !0, e.submitError = null, !c()) {
1774
1798
  e.submitError = {
1775
1799
  title: "validationFailed",
1776
1800
  description: "pleaseCheckFields"
1777
- }, _();
1801
+ }, y();
1778
1802
  return;
1779
1803
  }
1780
1804
  e.loading = !0;
1781
- const h = i;
1782
- _();
1805
+ const m = i;
1806
+ y();
1783
1807
  try {
1784
- const E = await t.createTicket({
1808
+ const k = await t.createTicket({
1785
1809
  subject: e.ticket.subject,
1786
1810
  typology: e.ticket.typology || "Question",
1787
1811
  priority: e.ticket.priority || "Normal",
1788
1812
  body: e.ticket.body,
1789
1813
  files: e.files,
1790
- customFields: Object.entries(e.customFields).map(([L, S]) => ({
1791
- id: L,
1792
- value: S
1814
+ customFields: Object.entries(e.customFields).map(([N, _]) => ({
1815
+ id: N,
1816
+ value: _
1793
1817
  })),
1794
1818
  email: t.requireEmail ? e.email : void 0,
1795
1819
  ticketFormId: n.id
1796
1820
  });
1797
- if (h !== i) return;
1821
+ if (m !== i) return;
1798
1822
  e.loading = !1, e.submitted = {
1799
- ticketId: E.id,
1800
- ticketUrl: E.url
1801
- }, _(), t.onCreated(E, e);
1802
- } catch (E) {
1803
- if (h !== i) return;
1823
+ ticketId: k.id,
1824
+ ticketUrl: k.url
1825
+ }, y(), t.onCreated(k, e);
1826
+ } catch (k) {
1827
+ if (m !== i) return;
1804
1828
  e.loading = !1;
1805
- const L = E instanceof Error ? E : new Error(String(E)), S = L.statusCode ?? L.status;
1829
+ const N = k instanceof Error ? k : new Error(String(k)), _ = N.statusCode ?? N.status;
1806
1830
  e.submitError = {
1807
- title: S === 413 ? "fileTooLarge" : S === 403 ? "permissionDenied" : S === 422 ? "validationFailed" : "submissionFailed",
1808
- description: S === 422 ? "pleaseCheckFields" : "submissionFailedDescription",
1809
- detail: S === 413 || S === 403 ? void 0 : L.message
1810
- }, _(), t.onError?.(L);
1831
+ title: _ === 413 ? "fileTooLarge" : _ === 403 ? "permissionDenied" : _ === 422 ? "validationFailed" : "submissionFailed",
1832
+ description: _ === 422 ? "pleaseCheckFields" : "submissionFailedDescription",
1833
+ detail: _ === 413 || _ === 403 ? void 0 : N.message
1834
+ }, y(), t.onError?.(N);
1811
1835
  }
1812
1836
  }
1813
- function m(h, E) {
1814
- const L = fe(h);
1815
- e.customFields[L] = E, n && ot(n, e.customFields, e.ticket.typology), e.submittedOnce && c(), _();
1837
+ function f(m, k) {
1838
+ const N = me(m);
1839
+ e.customFields[N] = k, n && rt(n, e.customFields, e.ticket.typology), e.submittedOnce && c(), y();
1816
1840
  }
1817
1841
  function p() {
1818
1842
  e.submittedOnce && c();
1819
1843
  }
1820
- function x(h) {
1821
- const E = fe(h), L = `ago-ticket-field-${E}`, S = e.customFields[E] ?? "", N = e.loading, j = e.errors[E];
1822
- if (h.type === "checkbox") {
1823
- const k = d({
1844
+ function b(m) {
1845
+ const k = me(m), N = `ago-ticket-field-${k}`, _ = e.customFields[k] ?? "", I = e.loading, j = e.errors[k];
1846
+ if (m.type === "checkbox") {
1847
+ const S = d({
1824
1848
  display: "flex",
1825
1849
  alignItems: "center",
1826
1850
  gap: "8px",
1827
1851
  flexWrap: "wrap"
1828
1852
  });
1829
- k.className = "ago-ticket-form__field";
1830
- const I = document.createElement("input");
1831
- I.type = "checkbox", I.id = L, I.checked = S === "true", I.disabled = N, u(I, {
1853
+ S.className = "ago-ticket-form__field";
1854
+ const R = document.createElement("input");
1855
+ R.type = "checkbox", R.id = N, R.checked = _ === "true", R.disabled = I, u(R, {
1832
1856
  width: "16px",
1833
1857
  height: "16px",
1834
1858
  margin: "0"
1835
- }), I.addEventListener("change", () => m(h, I.checked ? "true" : "false"));
1836
- const O = document.createElement("label");
1837
- return O.htmlFor = L, O.textContent = h.title ?? "", O.style.fontWeight = "600", k.append(I, O), j && k.appendChild(Te(j)), k;
1859
+ }), R.addEventListener("change", () => f(m, R.checked ? "true" : "false"));
1860
+ const H = document.createElement("label");
1861
+ return H.htmlFor = N, H.textContent = m.title ?? "", H.style.fontWeight = "600", S.append(R, H), j && S.appendChild(Te(j)), S;
1838
1862
  }
1839
- const C = qe();
1840
- C.appendChild(Ve(h.title ?? "", L));
1841
- const z = Ei(n, h, e.customFields, e.ticket.typology).filter((k) => !k.noDisplay);
1842
- if (h.options.length > 0) {
1843
- const k = document.createElement("select");
1844
- k.id = L;
1845
- const I = document.createElement("option");
1846
- I.value = "", I.textContent = "----", k.appendChild(I);
1847
- const O = /* @__PURE__ */ new Map();
1848
- for (const W of z) {
1863
+ const w = Ge();
1864
+ w.appendChild(qe(m.title ?? "", N));
1865
+ const O = ki(n, m, e.customFields, e.ticket.typology).filter((S) => !S.noDisplay);
1866
+ if (m.options.length > 0) {
1867
+ const S = document.createElement("select");
1868
+ S.id = N;
1869
+ const R = document.createElement("option");
1870
+ R.value = "", R.textContent = "----", S.appendChild(R);
1871
+ const H = /* @__PURE__ */ new Map();
1872
+ for (const W of O) {
1849
1873
  const q = document.createElement("option");
1850
1874
  if (q.value = W.value ?? W.name ?? "", q.textContent = W.name ?? W.value ?? "", W.group) {
1851
- let w = O.get(W.group);
1852
- w || (w = document.createElement("optgroup"), w.label = W.group, O.set(W.group, w), k.appendChild(w)), w.appendChild(q);
1853
- } else k.appendChild(q);
1875
+ let v = H.get(W.group);
1876
+ v || (v = document.createElement("optgroup"), v.label = W.group, H.set(W.group, v), S.appendChild(v)), v.appendChild(q);
1877
+ } else S.appendChild(q);
1854
1878
  }
1855
- k.value = S, Ge(k, !!j, N), k.addEventListener("change", () => m(h, k.value)), C.appendChild(k);
1856
- const $ = z.find((W) => (W.value ?? W.name) === S);
1857
- if (j && C.appendChild(Te(j)), $?.message) {
1879
+ S.value = _, Xe(S, !!j, I), S.addEventListener("change", () => f(m, S.value)), w.appendChild(S);
1880
+ const $ = O.find((W) => (W.value ?? W.name) === _);
1881
+ if (j && w.appendChild(Te(j)), $?.message) {
1858
1882
  const W = {
1859
1883
  info: {
1860
1884
  bg: "#eff6ff",
@@ -1882,34 +1906,34 @@ function Ea(t) {
1882
1906
  padding: "8px",
1883
1907
  whiteSpace: "pre-line",
1884
1908
  margin: "0"
1885
- }), C.appendChild(q);
1909
+ }), w.appendChild(q);
1886
1910
  }
1887
- return C;
1911
+ return w;
1888
1912
  }
1889
- const v = document.createElement("input");
1890
- return v.type = "text", v.id = L, v.value = S, Ge(v, !!j, N), v.addEventListener("input", () => {
1891
- e.customFields[E] = v.value, n && ot(n, e.customFields, e.ticket.typology), e.submittedOnce && (c(), B());
1892
- }), v.addEventListener("change", () => _()), C.appendChild(v), j && C.appendChild(Te(j)), C;
1913
+ const E = document.createElement("input");
1914
+ return E.type = "text", E.id = N, E.value = _, Xe(E, !!j, I), E.addEventListener("input", () => {
1915
+ e.customFields[k] = E.value, n && rt(n, e.customFields, e.ticket.typology), e.submittedOnce && (c(), F());
1916
+ }), E.addEventListener("change", () => y()), w.appendChild(E), j && w.appendChild(Te(j)), w;
1893
1917
  }
1894
- function B() {
1895
- for (const h of s.querySelectorAll("[data-ago-error-for]")) {
1896
- const E = h.dataset.agoErrorFor, L = h.querySelector(".ago-ticket-form__error"), S = e.errors[E], N = h.querySelector("input, select, textarea");
1897
- N && (N.style.borderColor = S ? "#ef4444" : ""), N && !S && (N.style.border = `1px solid ${Q}`), S && !L ? h.appendChild(Te(S)) : S && L ? L.textContent = S : !S && L && L.remove();
1918
+ function F() {
1919
+ for (const m of s.querySelectorAll("[data-ago-error-for]")) {
1920
+ const k = m.dataset.agoErrorFor, N = m.querySelector(".ago-ticket-form__error"), _ = e.errors[k], I = m.querySelector("input, select, textarea");
1921
+ I && (I.style.borderColor = _ ? "#ef4444" : ""), I && !_ && (I.style.border = `1px solid ${Q}`), _ && !N ? m.appendChild(Te(_)) : _ && N ? N.textContent = _ : !_ && N && N.remove();
1898
1922
  }
1899
1923
  }
1900
- function _() {
1924
+ function y() {
1901
1925
  if (s.replaceChildren(), t.message) {
1902
- const w = d({
1926
+ const v = d({
1903
1927
  fontWeight: "500",
1904
1928
  color: "#1e40af",
1905
1929
  backgroundColor: "#eff6ff",
1906
1930
  padding: "12px",
1907
1931
  borderRadius: "4px"
1908
1932
  });
1909
- w.className = "ago-ticket-form__message", w.textContent = t.message, s.appendChild(w);
1933
+ v.className = "ago-ticket-form__message", v.textContent = t.message, s.appendChild(v);
1910
1934
  }
1911
1935
  if (e.submitted) {
1912
- s.appendChild(ki({
1936
+ s.appendChild(Si({
1913
1937
  text: t.successMessage || n?.successMessageText || o.ticketSubmitted,
1914
1938
  ticketUrl: e.submitted.ticketUrl,
1915
1939
  urlLabel: t.successUrlLabel || n?.successMessageUrlLabel || o.findTicketHere
@@ -1917,18 +1941,18 @@ function Ea(t) {
1917
1941
  return;
1918
1942
  }
1919
1943
  if (!n) {
1920
- const w = d({
1944
+ const v = d({
1921
1945
  backgroundColor: "#fee2e2",
1922
1946
  color: "#991b1b",
1923
1947
  padding: "16px",
1924
1948
  borderRadius: "4px"
1925
1949
  });
1926
- w.className = "ago-ticket-form__missing", w.textContent = o.noTicketForm, s.appendChild(w);
1950
+ v.className = "ago-ticket-form__missing", v.textContent = o.noTicketForm, s.appendChild(v);
1927
1951
  return;
1928
1952
  }
1929
- const h = n, E = e.loading;
1953
+ const m = n, k = e.loading;
1930
1954
  if (e.loading) {
1931
- const w = d({
1955
+ const v = d({
1932
1956
  position: "absolute",
1933
1957
  inset: "0",
1934
1958
  display: "flex",
@@ -1940,36 +1964,36 @@ function Ea(t) {
1940
1964
  fontSize: "20px",
1941
1965
  fontWeight: "700"
1942
1966
  });
1943
- w.className = "ago-ticket-form__loading", w.setAttribute("role", "status"), w.textContent = o.loading, s.appendChild(w);
1967
+ v.className = "ago-ticket-form__loading", v.setAttribute("role", "status"), v.textContent = o.loading, s.appendChild(v);
1944
1968
  }
1945
- const L = d({
1969
+ const N = d({
1946
1970
  fontWeight: "600",
1947
1971
  backgroundColor: "#bfdbfe",
1948
1972
  padding: "16px",
1949
1973
  borderRadius: "4px"
1950
1974
  });
1951
- if (L.className = "ago-ticket-form__intro", L.textContent = o.useFormToCreateTicket, s.appendChild(L), t.requireEmail) {
1952
- const w = qe();
1953
- w.dataset.agoErrorFor = "userEmail", w.appendChild(Ve(`${o.yourEmail} *`, "ago-ticket-email"));
1954
- const R = document.createElement("input");
1955
- R.type = "email", R.id = "ago-ticket-email", R.placeholder = o.emailPlaceholder, R.value = e.email, Ge(R, !!e.errors.userEmail, E), R.addEventListener("input", () => {
1956
- e.email = R.value, e.submittedOnce && (c(), B());
1957
- }), w.appendChild(R), e.errors.userEmail && w.appendChild(Te(e.errors.userEmail)), s.appendChild(w);
1975
+ if (N.className = "ago-ticket-form__intro", N.textContent = o.useFormToCreateTicket, s.appendChild(N), t.requireEmail) {
1976
+ const v = Ge();
1977
+ v.dataset.agoErrorFor = "userEmail", v.appendChild(qe(`${o.yourEmail} *`, "ago-ticket-email"));
1978
+ const z = document.createElement("input");
1979
+ z.type = "email", z.id = "ago-ticket-email", z.placeholder = o.emailPlaceholder, z.value = e.email, Xe(z, !!e.errors.userEmail, k), z.addEventListener("input", () => {
1980
+ e.email = z.value, e.submittedOnce && (c(), F());
1981
+ }), v.appendChild(z), e.errors.userEmail && v.appendChild(Te(e.errors.userEmail)), s.appendChild(v);
1958
1982
  }
1959
- const S = h.showSubject && !!e.ticket.subject || !h.showSubject, N = S && (!!e.ticket.typology || !h.showTypology), j = h.showPriority && wi(h, e.ticket.typology), C = N && (!!e.ticket.priority || !j);
1960
- if (h.showSubject) {
1961
- const w = qe();
1962
- w.dataset.agoErrorFor = "subject", w.appendChild(Ve(o.subject, "ago-ticket-subject"));
1963
- const R = document.createElement("input");
1964
- R.type = "text", R.id = "ago-ticket-subject", R.value = e.ticket.subject, Ge(R, !!e.errors.subject, E), R.addEventListener("input", () => {
1965
- e.ticket.subject = R.value, p(), B();
1966
- }), R.addEventListener("change", () => _()), w.appendChild(R), e.errors.subject && w.appendChild(Te(e.errors.subject)), s.appendChild(w);
1983
+ const _ = m.showSubject && !!e.ticket.subject || !m.showSubject, I = _ && (!!e.ticket.typology || !m.showTypology), j = m.showPriority && vi(m, e.ticket.typology), w = I && (!!e.ticket.priority || !j);
1984
+ if (m.showSubject) {
1985
+ const v = Ge();
1986
+ v.dataset.agoErrorFor = "subject", v.appendChild(qe(o.subject, "ago-ticket-subject"));
1987
+ const z = document.createElement("input");
1988
+ z.type = "text", z.id = "ago-ticket-subject", z.value = e.ticket.subject, Xe(z, !!e.errors.subject, k), z.addEventListener("input", () => {
1989
+ e.ticket.subject = z.value, p(), F();
1990
+ }), z.addEventListener("change", () => y()), v.appendChild(z), e.errors.subject && v.appendChild(Te(e.errors.subject)), s.appendChild(v);
1967
1991
  }
1968
- if (S && h.showTypology) {
1969
- const w = qe();
1970
- w.dataset.agoErrorFor = "typology", w.appendChild(Ve(o.typology, "ago-ticket-typology"));
1971
- const R = document.createElement("select");
1972
- R.id = "ago-ticket-typology";
1992
+ if (_ && m.showTypology) {
1993
+ const v = Ge();
1994
+ v.dataset.agoErrorFor = "typology", v.appendChild(qe(o.typology, "ago-ticket-typology"));
1995
+ const z = document.createElement("select");
1996
+ z.id = "ago-ticket-typology";
1973
1997
  for (const [K, G] of [
1974
1998
  ["", o.selectTypology],
1975
1999
  ["Question", o.question],
@@ -1977,17 +2001,17 @@ function Ea(t) {
1977
2001
  ["Incident", o.incident]
1978
2002
  ]) {
1979
2003
  const ee = document.createElement("option");
1980
- ee.value = K, ee.textContent = G, R.appendChild(ee);
2004
+ ee.value = K, ee.textContent = G, z.appendChild(ee);
1981
2005
  }
1982
- R.value = e.ticket.typology, Ge(R, !!e.errors.typology, E), R.addEventListener("change", () => {
1983
- e.ticket.typology = R.value, ot(h, e.customFields, e.ticket.typology), p(), _();
1984
- }), w.appendChild(R), e.errors.typology && w.appendChild(Te(e.errors.typology)), s.appendChild(w);
2006
+ z.value = e.ticket.typology, Xe(z, !!e.errors.typology, k), z.addEventListener("change", () => {
2007
+ e.ticket.typology = z.value, rt(m, e.customFields, e.ticket.typology), p(), y();
2008
+ }), v.appendChild(z), e.errors.typology && v.appendChild(Te(e.errors.typology)), s.appendChild(v);
1985
2009
  }
1986
- if (N && j) {
1987
- const w = qe();
1988
- w.dataset.agoErrorFor = "priority", w.appendChild(Ve(o.priority, "ago-ticket-priority"));
1989
- const R = document.createElement("select");
1990
- R.id = "ago-ticket-priority";
2010
+ if (I && j) {
2011
+ const v = Ge();
2012
+ v.dataset.agoErrorFor = "priority", v.appendChild(qe(o.priority, "ago-ticket-priority"));
2013
+ const z = document.createElement("select");
2014
+ z.id = "ago-ticket-priority";
1991
2015
  for (const [K, G] of [
1992
2016
  ["", o.selectPriority],
1993
2017
  ["Low", o.low],
@@ -1996,49 +2020,49 @@ function Ea(t) {
1996
2020
  ["Urgent", o.urgent]
1997
2021
  ]) {
1998
2022
  const ee = document.createElement("option");
1999
- ee.value = K, ee.textContent = G, R.appendChild(ee);
2023
+ ee.value = K, ee.textContent = G, z.appendChild(ee);
2000
2024
  }
2001
- R.value = e.ticket.priority, Ge(R, !!e.errors.priority, E), R.addEventListener("change", () => {
2002
- e.ticket.priority = R.value, p(), _();
2003
- }), w.appendChild(R), e.errors.priority && w.appendChild(Te(e.errors.priority)), s.appendChild(w);
2025
+ z.value = e.ticket.priority, Xe(z, !!e.errors.priority, k), z.addEventListener("change", () => {
2026
+ e.ticket.priority = z.value, p(), y();
2027
+ }), v.appendChild(z), e.errors.priority && v.appendChild(Te(e.errors.priority)), s.appendChild(v);
2004
2028
  }
2005
- if (C) {
2006
- const w = new Set(ga(h, e.customFields, e.ticket.typology));
2007
- for (const R of [...h.fields].sort((K, G) => K.position - G.position)) {
2008
- if (!w.has(R) && !e.errors[fe(R)]) continue;
2009
- const K = x(R);
2010
- K.dataset.agoErrorFor = fe(R), s.appendChild(K);
2029
+ if (w) {
2030
+ const v = new Set(ba(m, e.customFields, e.ticket.typology));
2031
+ for (const z of [...m.fields].sort((K, G) => K.position - G.position)) {
2032
+ if (!v.has(z) && !e.errors[me(z)]) continue;
2033
+ const K = b(z);
2034
+ K.dataset.agoErrorFor = me(z), s.appendChild(K);
2011
2035
  }
2012
2036
  }
2013
- const z = qe();
2014
- z.dataset.agoErrorFor = "body", z.appendChild(Ve(o.detailedContext, "ago-ticket-body"));
2015
- const v = document.createElement("textarea");
2016
- v.id = "ago-ticket-body", v.rows = 4, v.value = e.ticket.body, Ge(v, !!e.errors.body, E), u(v, {
2037
+ const O = Ge();
2038
+ O.dataset.agoErrorFor = "body", O.appendChild(qe(o.detailedContext, "ago-ticket-body"));
2039
+ const E = document.createElement("textarea");
2040
+ E.id = "ago-ticket-body", E.rows = 4, E.value = e.ticket.body, Xe(E, !!e.errors.body, k), u(E, {
2017
2041
  resize: "vertical",
2018
2042
  maxHeight: "240px",
2019
2043
  overflowY: "auto"
2020
2044
  });
2021
- const k = d({
2045
+ const S = d({
2022
2046
  fontSize: "14px",
2023
2047
  lineHeight: "20px",
2024
2048
  marginTop: "4px",
2025
2049
  textAlign: "right",
2026
2050
  display: "none"
2027
2051
  });
2028
- k.className = "ago-ticket-form__counter";
2029
- const I = () => {
2030
- const w = e.ticket.body.length;
2031
- k.style.display = w > 6e4 ? "block" : "none", k.style.color = w > 65535 ? "#dc2626" : "#d97706", k.textContent = `${w} / 65,535 · ${o.maxCharacters}`;
2032
- }, O = () => {
2033
- v.style.height = "auto", v.style.height = `${v.scrollHeight}px`;
2052
+ S.className = "ago-ticket-form__counter";
2053
+ const R = () => {
2054
+ const v = e.ticket.body.length;
2055
+ S.style.display = v > 6e4 ? "block" : "none", S.style.color = v > 65535 ? "#dc2626" : "#d97706", S.textContent = `${v} / 65,535 · ${o.maxCharacters}`;
2056
+ }, H = () => {
2057
+ E.style.height = "auto", E.style.height = `${E.scrollHeight}px`;
2034
2058
  };
2035
- if (v.addEventListener("input", () => {
2036
- e.ticket.body = v.value, p(), B(), I(), O();
2037
- }), z.append(v, k), I(), e.errors.body && z.appendChild(Te(e.errors.body)), s.appendChild(z), a) {
2038
- const w = qe();
2039
- w.className = "ago-ticket-form__field ago-ticket-form__attachments", w.appendChild(Ve(o.attachments, "ago-ticket-files"));
2040
- const R = document.createElement("label");
2041
- R.htmlFor = "ago-ticket-files", R.textContent = o.selectFile, u(R, {
2059
+ if (E.addEventListener("input", () => {
2060
+ e.ticket.body = E.value, p(), F(), R(), H();
2061
+ }), O.append(E, S), R(), e.errors.body && O.appendChild(Te(e.errors.body)), s.appendChild(O), a) {
2062
+ const v = Ge();
2063
+ v.className = "ago-ticket-form__field ago-ticket-form__attachments", v.appendChild(qe(o.attachments, "ago-ticket-files"));
2064
+ const z = document.createElement("label");
2065
+ z.htmlFor = "ago-ticket-files", z.textContent = o.selectFile, u(z, {
2042
2066
  display: "inline-block",
2043
2067
  alignSelf: "flex-start",
2044
2068
  backgroundColor: "#e5e7eb",
@@ -2049,26 +2073,26 @@ function Ea(t) {
2049
2073
  minHeight: "24px"
2050
2074
  });
2051
2075
  const K = document.createElement("input");
2052
- K.type = "file", K.id = "ago-ticket-files", K.multiple = !0, K.disabled = E, u(K, { display: "none" }), K.addEventListener("change", () => {
2053
- e.files = [...e.files, ...Array.from(K.files ?? [])], K.value = "", _();
2054
- }), w.append(R, K);
2076
+ K.type = "file", K.id = "ago-ticket-files", K.multiple = !0, K.disabled = k, u(K, { display: "none" }), K.addEventListener("change", () => {
2077
+ e.files = [...e.files, ...Array.from(K.files ?? [])], K.value = "", y();
2078
+ }), v.append(z, K);
2055
2079
  const G = d({
2056
2080
  display: "flex",
2057
2081
  flexDirection: "column",
2058
2082
  gap: "4px"
2059
2083
  });
2060
2084
  e.files.forEach((ee, Y) => {
2061
- const f = d({
2085
+ const g = d({
2062
2086
  display: "flex",
2063
2087
  alignItems: "center",
2064
2088
  justifyContent: "space-between",
2065
2089
  backgroundColor: "#f3f4f6",
2066
2090
  padding: "4px 8px",
2067
2091
  borderRadius: "4px"
2068
- }), H = document.createElement("span");
2069
- H.textContent = `${ee.name} - ${tn(o.fileSize, { size: (ee.size / 1024).toFixed(1) })}`;
2092
+ }), B = document.createElement("span");
2093
+ B.textContent = `${ee.name} - ${nn(o.fileSize, { size: (ee.size / 1024).toFixed(1) })}`;
2070
2094
  const P = document.createElement("button");
2071
- P.type = "button", P.textContent = "×", P.setAttribute("aria-label", tn(o.removeFile, { filename: ee.name })), P.disabled = E, u(P, {
2095
+ P.type = "button", P.textContent = "×", P.setAttribute("aria-label", nn(o.removeFile, { filename: ee.name })), P.disabled = k, u(P, {
2072
2096
  color: "#dc2626",
2073
2097
  fontWeight: "700",
2074
2098
  background: "none",
@@ -2080,19 +2104,19 @@ function Ea(t) {
2080
2104
  height: "44px",
2081
2105
  margin: "-10px -12px -10px 0"
2082
2106
  }), P.addEventListener("click", () => {
2083
- e.files = e.files.filter((D, oe) => oe !== Y), _();
2084
- }), f.append(H, P), G.appendChild(f);
2085
- }), w.appendChild(G), s.appendChild(w);
2107
+ e.files = e.files.filter((D, oe) => oe !== Y), y();
2108
+ }), g.append(B, P), G.appendChild(g);
2109
+ }), v.appendChild(G), s.appendChild(v);
2086
2110
  }
2087
2111
  if (e.submitError) {
2088
- const { title: w, description: R, detail: K } = e.submitError, G = Te(`${o[w]}: ${K || o[R]}`);
2112
+ const { title: v, description: z, detail: K } = e.submitError, G = Te(`${o[v]}: ${K || o[z]}`);
2089
2113
  G.setAttribute("role", "alert"), G.className = "ago-ticket-form__error ago-ticket-form__submit-error", s.appendChild(G);
2090
2114
  }
2091
2115
  const $ = document.createElement("button");
2092
- $.type = "button", $.className = "ago-ticket-form__submit", $.disabled = E, u($, {
2116
+ $.type = "button", $.className = "ago-ticket-form__submit", $.disabled = k, u($, {
2093
2117
  width: "100%",
2094
- backgroundColor: ba,
2095
- color: at,
2118
+ backgroundColor: ya,
2119
+ color: lt,
2096
2120
  padding: "8px 16px",
2097
2121
  borderRadius: "4px",
2098
2122
  border: "none",
@@ -2100,7 +2124,7 @@ function Ea(t) {
2100
2124
  alignItems: "center",
2101
2125
  justifyContent: "center",
2102
2126
  gap: "8px",
2103
- cursor: E ? "default" : "pointer",
2127
+ cursor: k ? "default" : "pointer",
2104
2128
  fontSize: "16px",
2105
2129
  lineHeight: "24px",
2106
2130
  minHeight: "44px",
@@ -2119,22 +2143,22 @@ function Ea(t) {
2119
2143
  }), $.addEventListener("mouseleave", () => {
2120
2144
  $.style.filter = "", q.style.transform = "";
2121
2145
  }), $.addEventListener("click", () => {
2122
- b();
2146
+ x();
2123
2147
  }), s.appendChild($);
2124
2148
  }
2125
- return _(), {
2149
+ return y(), {
2126
2150
  el: s,
2127
- rebuild: (h) => {
2128
- if (h && "ticketForm" in h) {
2129
- const E = h.ticketForm ?? null;
2130
- n && n.id !== E?.id && (i += 1, Object.assign(e, Gn(void 0, E, e.email), { submitted: void 0 })), n = E, e.submittedOnce && !e.submitted && c();
2151
+ rebuild: (m) => {
2152
+ if (m && "ticketForm" in m) {
2153
+ const k = m.ticketForm ?? null;
2154
+ n && n.id !== k?.id && (i += 1, Object.assign(e, Kn(void 0, k, e.email), { submitted: void 0 })), n = k, e.submittedOnce && !e.submitted && c();
2131
2155
  }
2132
- h && "allowFiles" in h && (a = !!h.allowFiles), _();
2156
+ m && "allowFiles" in m && (a = !!m.allowFiles), y();
2133
2157
  }
2134
2158
  };
2135
2159
  }
2136
- var ka = 0;
2137
- async function Sa(t) {
2160
+ var _a = 0;
2161
+ async function Ta(t) {
2138
2162
  const e = Array.from(t.querySelectorAll("script"));
2139
2163
  for (const o of e) {
2140
2164
  const n = document.createElement("script");
@@ -2144,7 +2168,7 @@ async function Sa(t) {
2144
2168
  }) : (n.textContent = o.textContent, o.parentNode?.replaceChild(n, o));
2145
2169
  }
2146
2170
  }
2147
- function _a(t, e) {
2171
+ function Aa(t, e) {
2148
2172
  const o = {};
2149
2173
  if (t)
2150
2174
  for (const [n, i] of Object.entries(t)) if (n === "custom_fields" && i && typeof i == "object")
@@ -2152,7 +2176,7 @@ function _a(t, e) {
2152
2176
  else typeof i == "string" && i && (o[n] = i);
2153
2177
  return e && (o.email = e), Object.keys(o).length > 0 ? o : null;
2154
2178
  }
2155
- function Ta(t) {
2179
+ function Fa(t) {
2156
2180
  const e = d({
2157
2181
  fontWeight: "500",
2158
2182
  color: "#1e40af",
@@ -2164,13 +2188,13 @@ function Ta(t) {
2164
2188
  });
2165
2189
  return e.className = "ago-ticket-form__message", e.textContent = t, e;
2166
2190
  }
2167
- function Aa(t) {
2168
- const { state: e, labels: o } = t, n = `ago-embed-${Date.now().toString(36)}-${++ka}`, i = d({
2191
+ function La(t) {
2192
+ const { state: e, labels: o } = t, n = `ago-embed-${Date.now().toString(36)}-${++_a}`, i = d({
2169
2193
  display: "flex",
2170
2194
  flexDirection: "column",
2171
2195
  gap: "16px"
2172
2196
  });
2173
- i.className = "ago-embed-form", t.message && i.appendChild(Ta(t.message));
2197
+ i.className = "ago-embed-form", t.message && i.appendChild(Fa(t.message));
2174
2198
  const a = d({
2175
2199
  display: "flex",
2176
2200
  flexDirection: "column",
@@ -2178,80 +2202,80 @@ function Aa(t) {
2178
2202
  });
2179
2203
  a.className = "ago-embed-form__body", i.appendChild(a);
2180
2204
  const s = [];
2181
- let c, b = !1, m = e.status === "submitted", p = null;
2182
- const x = _a(t.ticket, t.email), B = (v) => {
2183
- m || b || (m = !0, c && (clearTimeout(c), c = void 0), e.status = "submitted", e.captured = v ?? null, z(), t.onSubmitted(v ?? null));
2184
- }, _ = () => {
2185
- m || c || (b = !1, c = setTimeout(() => {
2186
- m || (c = void 0, e.status = "timeout", z());
2205
+ let c, x = !1, f = e.status === "submitted", p = null;
2206
+ const b = Aa(t.ticket, t.email), F = (E) => {
2207
+ f || x || (f = !0, c && (clearTimeout(c), c = void 0), e.status = "submitted", e.captured = E ?? null, O(), t.onSubmitted(E ?? null));
2208
+ }, y = () => {
2209
+ f || c || (x = !1, c = setTimeout(() => {
2210
+ f || (c = void 0, e.status = "timeout", O());
2187
2211
  }, 3e4));
2188
- }, h = () => {
2212
+ }, m = () => {
2189
2213
  try {
2190
- const v = globalThis.HubSpotFormsV4?.getForms?.()?.[0];
2191
- if (v?.getFormFieldValues) {
2192
- const k = new Promise((I, O) => setTimeout(() => O(/* @__PURE__ */ new Error("timeout")), 3e3));
2193
- Promise.race([v.getFormFieldValues(), k]).then((I) => B(Zt(I))).catch(() => B(p));
2214
+ const E = globalThis.HubSpotFormsV4?.getForms?.()?.[0];
2215
+ if (E?.getFormFieldValues) {
2216
+ const S = new Promise((R, H) => setTimeout(() => H(/* @__PURE__ */ new Error("timeout")), 3e3));
2217
+ Promise.race([E.getFormFieldValues(), S]).then((R) => F(Jt(R))).catch(() => F(p));
2194
2218
  return;
2195
2219
  }
2196
2220
  } catch {
2197
2221
  }
2198
- B(p);
2222
+ F(p);
2199
2223
  };
2200
- window.addEventListener("hs-form-event:on-submission:success", h), s.push(() => window.removeEventListener("hs-form-event:on-submission:success", h));
2201
- const E = [], L = (v) => {
2202
- const k = v.data;
2203
- if (k?.type === "hsFormCallback" && k.eventName === "onFormSubmit") {
2224
+ window.addEventListener("hs-form-event:on-submission:success", m), s.push(() => window.removeEventListener("hs-form-event:on-submission:success", m));
2225
+ const k = [], N = (E) => {
2226
+ const S = E.data;
2227
+ if (S?.type === "hsFormCallback" && S.eventName === "onFormSubmit") {
2204
2228
  try {
2205
- const I = k.data;
2206
- if (Array.isArray(I)) {
2207
- const O = {};
2208
- for (const W of I) W?.name && W.value !== void 0 && (O[W.name] = W.value);
2209
- const $ = Zt(O);
2229
+ const R = S.data;
2230
+ if (Array.isArray(R)) {
2231
+ const H = {};
2232
+ for (const W of R) W?.name && W.value !== void 0 && (H[W.name] = W.value);
2233
+ const $ = Jt(H);
2210
2234
  $ && (p = $);
2211
2235
  }
2212
2236
  } catch {
2213
2237
  }
2214
2238
  return;
2215
2239
  }
2216
- if (k?.type === "hsFormCallback" && k.eventName === "onFormSubmitted") {
2217
- B(p);
2240
+ if (S?.type === "hsFormCallback" && S.eventName === "onFormSubmitted") {
2241
+ F(p);
2218
2242
  return;
2219
2243
  }
2220
- if (k?.type === "HS_CTA_PARENT_INIT" && v.ports?.[0]) {
2221
- const I = v.ports[0], O = ($) => {
2244
+ if (S?.type === "HS_CTA_PARENT_INIT" && E.ports?.[0]) {
2245
+ const R = E.ports[0], H = ($) => {
2222
2246
  const W = $.data;
2223
2247
  if (W?.type === "HS_SEND_FORM_FIELD_VALUES") {
2224
2248
  const q = W.payload?.formFieldValues;
2225
2249
  if (q && typeof q == "object") {
2226
- const w = Zt(q);
2227
- w && (p = w);
2250
+ const v = Jt(q);
2251
+ v && (p = v);
2228
2252
  }
2229
2253
  }
2230
- W?.type === "HS_SEND_FORM_SUBMISSION_SUCCESS" && B(p);
2254
+ W?.type === "HS_SEND_FORM_SUBMISSION_SUCCESS" && F(p);
2231
2255
  };
2232
- I.addEventListener("message", O), I.start(), E.push(() => I.removeEventListener("message", O));
2256
+ R.addEventListener("message", H), R.start(), k.push(() => R.removeEventListener("message", H));
2233
2257
  }
2234
2258
  };
2235
- window.addEventListener("message", L), s.push(() => {
2236
- window.removeEventListener("message", L), E.forEach((v) => v());
2259
+ window.addEventListener("message", N), s.push(() => {
2260
+ window.removeEventListener("message", N), k.forEach((E) => E());
2237
2261
  });
2238
- let S;
2239
- function N(v) {
2262
+ let _;
2263
+ function I(E) {
2240
2264
  if (!t.embedHtml) return;
2241
- let k = ca(t.embedHtml, x, n);
2242
- k = fa(k, n);
2243
- const I = da(x, n), O = Go(x);
2244
- v.innerHTML = k;
2245
- const $ = ma(v, B, _, n);
2246
- let W, q, w;
2247
- Sa(v).catch(() => {
2265
+ let S = pa(t.embedHtml, b, n);
2266
+ S = ga(S, n);
2267
+ const R = ua(b, n), H = Xo(b);
2268
+ E.innerHTML = S;
2269
+ const $ = ha(E, F, y, n);
2270
+ let W, q, v;
2271
+ Ta(E).catch(() => {
2248
2272
  }).then(() => {
2249
- e.status === "loading" && (e.status = "ready", j.style.display = "none", x && (en(v, x), pa(x), w = Go(x), W = new MutationObserver(() => en(v, x)), W.observe(v, {
2273
+ e.status === "loading" && (e.status = "ready", j.style.display = "none", b && (tn(E, b), fa(b), v = Xo(b), W = new MutationObserver(() => tn(E, b)), W.observe(E, {
2250
2274
  childList: !0,
2251
2275
  subtree: !0
2252
2276
  }), q = setTimeout(() => W?.disconnect(), 1e4)));
2253
- }), S = () => {
2254
- I(), O(), $(), W?.disconnect(), q && clearTimeout(q), w?.(), v.innerHTML = "";
2277
+ }), _ = () => {
2278
+ R(), H(), $(), W?.disconnect(), q && clearTimeout(q), v?.(), E.innerHTML = "";
2255
2279
  };
2256
2280
  }
2257
2281
  const j = d({
@@ -2264,18 +2288,18 @@ function Aa(t) {
2264
2288
  zIndex: "10"
2265
2289
  });
2266
2290
  j.className = "ago-embed-form__loading";
2267
- const C = d({
2291
+ const w = d({
2268
2292
  width: "24px",
2269
2293
  height: "24px",
2270
2294
  borderRadius: "50%",
2271
- border: `2px solid ${Hn}`,
2295
+ border: `2px solid ${$n}`,
2272
2296
  borderTopColor: "transparent",
2273
2297
  animation: "ago-spin 1s linear infinite"
2274
2298
  });
2275
- C.setAttribute("role", "status"), C.setAttribute("aria-label", o.loading), j.appendChild(C);
2276
- function z() {
2299
+ w.setAttribute("role", "status"), w.setAttribute("aria-label", o.loading), j.appendChild(w);
2300
+ function O() {
2277
2301
  if (a.replaceChildren(), e.status === "timeout") {
2278
- const k = d({
2302
+ const S = d({
2279
2303
  borderRadius: "8px",
2280
2304
  border: "1px solid #fef08a",
2281
2305
  backgroundColor: "#fefce8",
@@ -2284,16 +2308,16 @@ function Aa(t) {
2284
2308
  flexDirection: "column",
2285
2309
  gap: "12px"
2286
2310
  });
2287
- k.className = "ago-embed-form__timeout";
2288
- const I = document.createElement("p");
2289
- I.textContent = o.embedSubmitTimeout, u(I, {
2311
+ S.className = "ago-embed-form__timeout";
2312
+ const R = document.createElement("p");
2313
+ R.textContent = o.embedSubmitTimeout, u(R, {
2290
2314
  fontSize: "14px",
2291
2315
  lineHeight: "20px",
2292
2316
  color: "#854d0e",
2293
2317
  margin: "0"
2294
2318
  });
2295
- const O = document.createElement("button");
2296
- O.type = "button", O.textContent = o.tryAgain, u(O, {
2319
+ const H = document.createElement("button");
2320
+ H.type = "button", H.textContent = o.tryAgain, u(H, {
2297
2321
  alignSelf: "flex-start",
2298
2322
  fontSize: "14px",
2299
2323
  fontWeight: "500",
@@ -2305,98 +2329,98 @@ function Aa(t) {
2305
2329
  cursor: "pointer",
2306
2330
  minHeight: "44px",
2307
2331
  font: "inherit"
2308
- }), O.addEventListener("click", () => {
2309
- b = !0, m = !1, c = void 0, e.status = "ready", z();
2310
- }), k.append(I, O), a.appendChild(k);
2332
+ }), H.addEventListener("click", () => {
2333
+ x = !0, f = !1, c = void 0, e.status = "ready", O();
2334
+ }), S.append(R, H), a.appendChild(S);
2311
2335
  return;
2312
2336
  }
2313
2337
  if (e.status === "submitted") {
2314
- a.appendChild(ki({
2338
+ a.appendChild(Si({
2315
2339
  text: t.successMessage || o.embeddedFormSubmitted,
2316
2340
  urlLabel: o.findTicketHere
2317
2341
  }));
2318
2342
  return;
2319
2343
  }
2320
2344
  if (t.description) {
2321
- const k = document.createElement("p");
2322
- k.className = "ago-embed-form__description", k.textContent = t.description, u(k, {
2345
+ const S = document.createElement("p");
2346
+ S.className = "ago-embed-form__description", S.textContent = t.description, u(S, {
2323
2347
  fontSize: "14px",
2324
2348
  lineHeight: "20px",
2325
2349
  margin: "0"
2326
- }), a.appendChild(k);
2350
+ }), a.appendChild(S);
2327
2351
  }
2328
- const v = d({
2352
+ const E = d({
2329
2353
  position: "relative",
2330
2354
  borderRadius: "8px",
2331
2355
  border: `1px solid ${Q}`,
2332
2356
  overflow: "hidden"
2333
2357
  });
2334
- if (v.className = "ago-embed-form__frame", t.embedHtml) {
2335
- j.style.display = e.status === "loading" ? "flex" : "none", v.appendChild(j);
2336
- const k = d({
2358
+ if (E.className = "ago-embed-form__frame", t.embedHtml) {
2359
+ j.style.display = e.status === "loading" ? "flex" : "none", E.appendChild(j);
2360
+ const S = d({
2337
2361
  width: "100%",
2338
2362
  minHeight: "200px"
2339
2363
  });
2340
- k.className = "ago-embed-form__host", v.appendChild(k), S?.(), N(k);
2364
+ S.className = "ago-embed-form__host", E.appendChild(S), _?.(), I(S);
2341
2365
  } else {
2342
- const k = d({
2366
+ const S = d({
2343
2367
  padding: "24px",
2344
2368
  textAlign: "center",
2345
- color: Hn,
2369
+ color: $n,
2346
2370
  fontSize: "14px"
2347
2371
  });
2348
- k.className = "ago-embed-form__empty", k.textContent = o.noEmbedConfigured, v.appendChild(k);
2372
+ S.className = "ago-embed-form__empty", S.textContent = o.noEmbedConfigured, E.appendChild(S);
2349
2373
  }
2350
- a.appendChild(v);
2374
+ a.appendChild(E);
2351
2375
  }
2352
- return z(), {
2376
+ return O(), {
2353
2377
  el: i,
2354
- updateText: (v) => {
2355
- if (Object.assign(t, v), C.setAttribute("aria-label", o.loading), e.status === "submitted" || e.status === "timeout") {
2356
- z();
2378
+ updateText: (E) => {
2379
+ if (Object.assign(t, E), w.setAttribute("aria-label", o.loading), e.status === "submitted" || e.status === "timeout") {
2380
+ O();
2357
2381
  return;
2358
2382
  }
2359
- const k = a.querySelector(".ago-embed-form__description");
2360
- if (k) k.textContent = t.description ?? "";
2383
+ const S = a.querySelector(".ago-embed-form__description");
2384
+ if (S) S.textContent = t.description ?? "";
2361
2385
  else if (t.description) {
2362
- const O = document.createElement("p");
2363
- O.className = "ago-embed-form__description", O.textContent = t.description, u(O, {
2386
+ const H = document.createElement("p");
2387
+ H.className = "ago-embed-form__description", H.textContent = t.description, u(H, {
2364
2388
  fontSize: "14px",
2365
2389
  lineHeight: "20px",
2366
2390
  margin: "0"
2367
- }), a.prepend(O);
2391
+ }), a.prepend(H);
2368
2392
  }
2369
- const I = a.querySelector(".ago-embed-form__empty");
2370
- I && (I.textContent = o.noEmbedConfigured);
2393
+ const R = a.querySelector(".ago-embed-form__empty");
2394
+ R && (R.textContent = o.noEmbedConfigured);
2371
2395
  },
2372
2396
  destroy: () => {
2373
- c && clearTimeout(c), S?.(), s.forEach((v) => v());
2397
+ c && clearTimeout(c), _?.(), s.forEach((E) => E());
2374
2398
  }
2375
2399
  };
2376
2400
  }
2377
- function Qo(t) {
2401
+ function Zo(t) {
2378
2402
  return t.type === "form" && t.toolName === "ago_ticketing";
2379
2403
  }
2380
- function Zo(t) {
2404
+ function Jo(t) {
2381
2405
  let e = null;
2382
2406
  for (const o of t) for (const n of o.toolCalls ?? []) n.type === "form" && (e = n.id);
2383
2407
  return e;
2384
2408
  }
2385
- function Fa(t) {
2409
+ function Na(t) {
2386
2410
  return t.some((e) => (e.toolCalls ?? []).some((o) => {
2387
2411
  if (o.type !== "form") return !1;
2388
2412
  const n = o.data;
2389
2413
  return n?.success === !0 && !!n.ticket?.ticket_id;
2390
2414
  }));
2391
2415
  }
2392
- function Jo(t) {
2416
+ function ei(t) {
2393
2417
  const e = t.data;
2394
2418
  return e?.success !== !0 || !e.ticket?.ticket_id ? null : {
2395
2419
  ticketId: String(e.ticket.ticket_id),
2396
2420
  ticketUrl: typeof e.ticket.ticket_url == "string" && e.ticket.ticket_url ? e.ticket.ticket_url : void 0
2397
2421
  };
2398
2422
  }
2399
- var La = {
2423
+ var Ia = {
2400
2424
  info: {
2401
2425
  border: "#bfdbfe",
2402
2426
  bg: "#eff6ff",
@@ -2418,8 +2442,8 @@ var La = {
2418
2442
  text: "#991b1b"
2419
2443
  }
2420
2444
  };
2421
- function Na(t, e = "info", o) {
2422
- const n = La[e], i = d({
2445
+ function Ra(t, e = "info", o) {
2446
+ const n = Ia[e], i = d({
2423
2447
  margin: "8px 0",
2424
2448
  padding: "12px 16px",
2425
2449
  border: `1px solid ${n.border}`,
@@ -2444,7 +2468,7 @@ function Na(t, e = "info", o) {
2444
2468
  const a = document.createElement("span");
2445
2469
  return a.textContent = t, a.style.whiteSpace = "pre-wrap", i.appendChild(a), i;
2446
2470
  }
2447
- function Ia(t, e) {
2471
+ function za(t, e) {
2448
2472
  const o = d({
2449
2473
  margin: "8px 0",
2450
2474
  padding: "12px 16px",
@@ -2492,8 +2516,8 @@ function Ia(t, e) {
2492
2516
  }
2493
2517
  return o.appendChild(i), o;
2494
2518
  }
2495
- var ps = Vn.feedback;
2496
- function Ra() {
2519
+ var fs = Gn.feedback;
2520
+ function Oa() {
2497
2521
  return {
2498
2522
  detailsOpen: !1,
2499
2523
  reasons: /* @__PURE__ */ new Set(),
@@ -2501,7 +2525,7 @@ function Ra() {
2501
2525
  reported: !1
2502
2526
  };
2503
2527
  }
2504
- var za = {
2528
+ var Ha = {
2505
2529
  display: "inline-flex",
2506
2530
  alignItems: "center",
2507
2531
  justifyContent: "center",
@@ -2512,20 +2536,20 @@ var za = {
2512
2536
  border: "none",
2513
2537
  borderRadius: "8px",
2514
2538
  background: "transparent",
2515
- color: rt,
2539
+ color: st,
2516
2540
  cursor: "pointer",
2517
2541
  lineHeight: "1"
2518
2542
  };
2519
- function Oa(t) {
2543
+ function Ba(t) {
2520
2544
  const { state: e, labels: o, askWhy: n, onRate: i, onReport: a } = t, s = t.look === "embed", c = s ? {
2521
2545
  idle: "#78716c",
2522
2546
  hover: "#1c1917",
2523
2547
  active: "#1c1917"
2524
2548
  } : {
2525
- idle: rt,
2549
+ idle: st,
2526
2550
  hover: ne,
2527
- active: st
2528
- }, b = d(s ? {
2551
+ active: ct
2552
+ }, x = d(s ? {
2529
2553
  display: "flex",
2530
2554
  justifyContent: "space-between",
2531
2555
  alignItems: "center",
@@ -2536,47 +2560,47 @@ function Oa(t) {
2536
2560
  width: "100%",
2537
2561
  maxWidth: "85%"
2538
2562
  });
2539
- b.className = "ago-feedback";
2540
- const m = d({
2563
+ x.className = "ago-feedback";
2564
+ const f = d({
2541
2565
  display: "flex",
2542
2566
  alignItems: "center",
2543
2567
  gap: s ? "8px" : "2px"
2544
2568
  });
2545
- m.className = "ago-feedback__actions";
2546
- const p = ei("up", o.helpful, e.rating === "positive", c, s);
2569
+ f.className = "ago-feedback__actions";
2570
+ const p = ti("up", o.helpful, e.rating === "positive", c, s);
2547
2571
  p.addEventListener("click", () => {
2548
- e.rating = "positive", e.detailsOpen = !1, _(), h(), i("positive");
2572
+ e.rating = "positive", e.detailsOpen = !1, y(), m(), i("positive");
2549
2573
  });
2550
- const x = ei("down", o.notHelpful, e.rating === "negative", c, s);
2551
- x.addEventListener("click", () => {
2552
- e.rating = "negative", i("negative"), n && !e.reported && (e.detailsOpen = !0), _(), h();
2553
- }), m.append(p, x), s && b.appendChild(d({ flex: "1" })), b.appendChild(m);
2554
- const B = d();
2555
- B.className = "ago-feedback__panel-slot", s && (B.style.flexBasis = "100%"), b.appendChild(B);
2556
- function _() {
2557
- Un(p, e.rating === "positive", c), Un(x, e.rating === "negative", c);
2574
+ const b = ti("down", o.notHelpful, e.rating === "negative", c, s);
2575
+ b.addEventListener("click", () => {
2576
+ e.rating = "negative", i("negative"), n && !e.reported && (e.detailsOpen = !0), y(), m();
2577
+ }), f.append(p, b), s && x.appendChild(d({ flex: "1" })), x.appendChild(f);
2578
+ const F = d();
2579
+ F.className = "ago-feedback__panel-slot", s && (F.style.flexBasis = "100%"), x.appendChild(F);
2580
+ function y() {
2581
+ Vn(p, e.rating === "positive", c), Vn(b, e.rating === "negative", c);
2558
2582
  }
2559
- function h() {
2560
- if (B.replaceChildren(), e.reported) {
2561
- B.appendChild($a(o.thanks));
2583
+ function m() {
2584
+ if (F.replaceChildren(), e.reported) {
2585
+ F.appendChild(Ma(o.thanks));
2562
2586
  return;
2563
2587
  }
2564
- e.detailsOpen && B.appendChild(Ba(e, o, async (E) => await a(e.rating ?? "negative", E) ? (e.reported = !0, e.detailsOpen = !1, h(), !0) : !1));
2588
+ e.detailsOpen && F.appendChild(Da(e, o, async (k) => await a(e.rating ?? "negative", k) ? (e.reported = !0, e.detailsOpen = !1, m(), !0) : !1));
2565
2589
  }
2566
- return _(), h(), b;
2590
+ return y(), m(), x;
2567
2591
  }
2568
- function ei(t, e, o, n, i = !1) {
2592
+ function ti(t, e, o, n, i = !1) {
2569
2593
  const a = document.createElement("button");
2570
- return a.type = "button", a.className = `ago-feedback__thumb ago-feedback__thumb--${t}`, a.setAttribute("aria-label", e), a.title = e, u(a, za), i ? (a.style.margin = "-14px", a.appendChild(t === "up" ? Br({ size: 18 }) : hr({ size: 18 }))) : a.appendChild(Ha(t)), Un(a, o, n), a.addEventListener("mouseenter", () => {
2594
+ return a.type = "button", a.className = `ago-feedback__thumb ago-feedback__thumb--${t}`, a.setAttribute("aria-label", e), a.title = e, u(a, Ha), i ? (a.style.margin = "-14px", a.appendChild(t === "up" ? $r({ size: 18 }) : br({ size: 18 }))) : a.appendChild($a(t)), Vn(a, o, n), a.addEventListener("mouseenter", () => {
2571
2595
  a.getAttribute("aria-pressed") !== "true" && (a.style.color = n.hover);
2572
2596
  }), a.addEventListener("mouseleave", () => {
2573
2597
  a.getAttribute("aria-pressed") !== "true" && (a.style.color = n.idle);
2574
2598
  }), a;
2575
2599
  }
2576
- function Un(t, e, o) {
2600
+ function Vn(t, e, o) {
2577
2601
  t.setAttribute("aria-pressed", e ? "true" : "false"), t.style.color = e ? o.active : o.idle;
2578
2602
  }
2579
- function Ha(t) {
2603
+ function $a(t) {
2580
2604
  const e = "http://www.w3.org/2000/svg", o = document.createElementNS(e, "svg");
2581
2605
  o.setAttribute("width", "16"), o.setAttribute("height", "16"), o.setAttribute("viewBox", "0 0 24 24"), o.setAttribute("fill", "none"), o.setAttribute("aria-hidden", "true");
2582
2606
  const n = document.createElementNS(e, "path");
@@ -2584,12 +2608,12 @@ function Ha(t) {
2584
2608
  const i = document.createElementNS(e, "path");
2585
2609
  return i.setAttribute("d", "M7 22V12H4.5A1.5 1.5 0 0 0 3 13.5v7A1.5 1.5 0 0 0 4.5 22z"), i.setAttribute("stroke", "currentColor"), i.setAttribute("stroke-width", "1.8"), i.setAttribute("stroke-linejoin", "round"), o.append(n, i), t === "down" && (o.style.transform = "rotate(180deg)"), o;
2586
2610
  }
2587
- function Ba(t, e, o) {
2611
+ function Da(t, e, o) {
2588
2612
  const n = d({
2589
2613
  marginTop: "8px",
2590
2614
  padding: "12px",
2591
2615
  border: `1px solid ${Q}`,
2592
- borderRadius: nn,
2616
+ borderRadius: on,
2593
2617
  backgroundColor: Ee
2594
2618
  });
2595
2619
  n.className = "ago-feedback__panel", n.setAttribute("role", "group"), n.setAttribute("aria-label", e.whatWentWrong);
@@ -2607,9 +2631,9 @@ function Ba(t, e, o) {
2607
2631
  marginBottom: "8px"
2608
2632
  });
2609
2633
  a.className = "ago-feedback__reasons";
2610
- for (const m of or) {
2634
+ for (const f of ir) {
2611
2635
  const p = document.createElement("button");
2612
- p.type = "button", p.className = "ago-feedback__reason", p.textContent = e.reasons[m], u(p, {
2636
+ p.type = "button", p.className = "ago-feedback__reason", p.textContent = e.reasons[f], u(p, {
2613
2637
  minHeight: "44px",
2614
2638
  padding: "4px 12px",
2615
2639
  fontSize: "13px",
@@ -2620,13 +2644,13 @@ function Ba(t, e, o) {
2620
2644
  color: ne,
2621
2645
  cursor: "pointer"
2622
2646
  });
2623
- const x = () => {
2624
- const B = t.reasons.has(m);
2625
- p.setAttribute("aria-pressed", B ? "true" : "false"), p.style.borderColor = B ? st : Q, p.style.color = B ? st : ne;
2647
+ const b = () => {
2648
+ const F = t.reasons.has(f);
2649
+ p.setAttribute("aria-pressed", F ? "true" : "false"), p.style.borderColor = F ? ct : Q, p.style.color = F ? ct : ne;
2626
2650
  };
2627
2651
  p.addEventListener("click", () => {
2628
- t.reasons.has(m) ? t.reasons.delete(m) : t.reasons.add(m), x(), b();
2629
- }), x(), a.appendChild(p);
2652
+ t.reasons.has(f) ? t.reasons.delete(f) : t.reasons.add(f), b(), x();
2653
+ }), b(), a.appendChild(p);
2630
2654
  }
2631
2655
  n.appendChild(a);
2632
2656
  const s = document.createElement("textarea");
@@ -2642,7 +2666,7 @@ function Ba(t, e, o) {
2642
2666
  backgroundColor: "transparent",
2643
2667
  resize: "vertical"
2644
2668
  }), s.addEventListener("input", () => {
2645
- t.comment = s.value, b();
2669
+ t.comment = s.value, x();
2646
2670
  }), n.appendChild(s);
2647
2671
  const c = document.createElement("button");
2648
2672
  return c.type = "button", c.className = "ago-feedback__send", c.textContent = e.send, u(c, {
@@ -2654,30 +2678,30 @@ function Ba(t, e, o) {
2654
2678
  borderRadius: "10px",
2655
2679
  border: "none",
2656
2680
  backgroundColor: ve,
2657
- color: at,
2681
+ color: lt,
2658
2682
  cursor: "pointer"
2659
2683
  }), c.addEventListener("click", () => {
2660
2684
  c.disabled || (c.disabled = !0, o({
2661
2685
  reasons: [...t.reasons],
2662
2686
  comment: t.comment.trim()
2663
- }).then((m) => {
2664
- m || b();
2687
+ }).then((f) => {
2688
+ f || x();
2665
2689
  }));
2666
- }), n.appendChild(c), b(), n;
2667
- function b() {
2668
- const m = t.reasons.size > 0 || t.comment.trim().length > 0;
2669
- c.disabled = !m, c.style.opacity = m ? "1" : "0.5", c.style.cursor = m ? "pointer" : "default";
2690
+ }), n.appendChild(c), x(), n;
2691
+ function x() {
2692
+ const f = t.reasons.size > 0 || t.comment.trim().length > 0;
2693
+ c.disabled = !f, c.style.opacity = f ? "1" : "0.5", c.style.cursor = f ? "pointer" : "default";
2670
2694
  }
2671
2695
  }
2672
- function $a(t) {
2696
+ function Ma(t) {
2673
2697
  const e = d({
2674
2698
  marginTop: "6px",
2675
2699
  fontSize: "13px",
2676
- color: rt
2700
+ color: st
2677
2701
  });
2678
2702
  return e.className = "ago-feedback__thanks", e.setAttribute("role", "status"), e.textContent = t, e;
2679
2703
  }
2680
- function Da(t) {
2704
+ function ja(t) {
2681
2705
  const e = d({
2682
2706
  display: "flex",
2683
2707
  flexDirection: "column",
@@ -2713,28 +2737,28 @@ function Da(t) {
2713
2737
  composerSlot: n
2714
2738
  };
2715
2739
  }
2716
- var Ma = Vn.timeAgo, ja = 60 * 1e3;
2717
- function Wa(t, e = Date.now(), o = Ma) {
2718
- const n = t instanceof Date ? t.getTime() : new Date(t).getTime(), i = (p, x) => p.replace("{n}", String(x));
2740
+ var Wa = Gn.timeAgo, Ua = 60 * 1e3;
2741
+ function Pa(t, e = Date.now(), o = Wa) {
2742
+ const n = t instanceof Date ? t.getTime() : new Date(t).getTime(), i = (p, b) => p.replace("{n}", String(b));
2719
2743
  if (!Number.isFinite(n)) return i(o.minutes, 0);
2720
- const a = Math.max(0, Math.floor((e - n) / ja)), s = Math.floor(a / 60), c = Math.floor(s / 24), b = Math.floor(c / 7), m = Math.max(1, Math.floor(c / 30));
2721
- return a < 60 ? i(o.minutes, a) : s < 24 ? i(o.hours, s) : c < 7 ? i(o.days, c) : b < 4 ? i(o.weeks, b) : i(o.months, m);
2744
+ const a = Math.max(0, Math.floor((e - n) / Ua)), s = Math.floor(a / 60), c = Math.floor(s / 24), x = Math.floor(c / 7), f = Math.max(1, Math.floor(c / 30));
2745
+ return a < 60 ? i(o.minutes, a) : s < 24 ? i(o.hours, s) : c < 7 ? i(o.days, c) : x < 4 ? i(o.weeks, x) : i(o.months, f);
2722
2746
  }
2723
- var Ua = 7200 * 1e3;
2724
- function Pn(t) {
2747
+ var Va = 7200 * 1e3;
2748
+ function qn(t) {
2725
2749
  const e = t.lastMessageDate instanceof Date ? t.lastMessageDate.getTime() : new Date(t.lastMessageDate).getTime();
2726
2750
  return Number.isFinite(e) ? e : Number.NEGATIVE_INFINITY;
2727
2751
  }
2728
- function Si(t) {
2729
- return [...t].sort((e, o) => Pn(o) - Pn(e));
2752
+ function _i(t) {
2753
+ return [...t].sort((e, o) => qn(o) - qn(e));
2730
2754
  }
2731
- function Pa(t, e = Date.now(), o = Ua) {
2732
- const n = Si(t)[0];
2755
+ function qa(t, e = Date.now(), o = Va) {
2756
+ const n = _i(t)[0];
2733
2757
  if (!n) return null;
2734
- const i = Pn(n);
2758
+ const i = qn(n);
2735
2759
  return Number.isFinite(i) && e - i < o ? n : null;
2736
2760
  }
2737
- function Va(t) {
2761
+ function Ga(t) {
2738
2762
  const e = d({
2739
2763
  position: "relative",
2740
2764
  display: "flex",
@@ -2758,7 +2782,7 @@ function Va(t) {
2758
2782
  bottom: "0",
2759
2783
  zIndex: "10",
2760
2784
  padding: "32px 16px 16px",
2761
- backgroundImage: `linear-gradient(to top, ${Rn} 72px, transparent 104px)`
2785
+ backgroundImage: `linear-gradient(to top, ${On} 72px, transparent 104px)`
2762
2786
  });
2763
2787
  n.className = "ago-chat-widget__new-strip";
2764
2788
  const i = document.createElement("button");
@@ -2783,9 +2807,9 @@ function Va(t) {
2783
2807
  fontSize: "14px",
2784
2808
  lineHeight: "20px",
2785
2809
  fontWeight: "500"
2786
- }), i.append(qn({ size: 16 }), a), i.addEventListener("click", t.onNew), n.appendChild(i), e.append(o, n);
2810
+ }), i.append(Xn({ size: 16 }), a), i.addEventListener("click", t.onNew), n.appendChild(i), e.append(o, n);
2787
2811
  const s = (p) => {
2788
- t.customFont ? p.style.opacity = "0.7" : p.style.color = Hn;
2812
+ t.customFont ? p.style.opacity = "0.7" : p.style.color = $n;
2789
2813
  };
2790
2814
  function c() {
2791
2815
  const p = d({
@@ -2796,16 +2820,16 @@ function Va(t) {
2796
2820
  paddingBottom: "112px"
2797
2821
  });
2798
2822
  p.className = "ago-chat-widget__history-loading";
2799
- const x = d({
2823
+ const b = d({
2800
2824
  width: "32px",
2801
2825
  height: "32px",
2802
2826
  borderRadius: "50%",
2803
2827
  borderBottom: `2px solid ${ve}`,
2804
2828
  animation: "ago-spin 1s linear infinite"
2805
2829
  });
2806
- x.setAttribute("role", "status"), p.appendChild(x), o.replaceChildren(p);
2830
+ b.setAttribute("role", "status"), p.appendChild(b), o.replaceChildren(p);
2807
2831
  }
2808
- function b() {
2832
+ function x() {
2809
2833
  const p = d({
2810
2834
  display: "flex",
2811
2835
  flex: "1",
@@ -2814,27 +2838,27 @@ function Va(t) {
2814
2838
  justifyContent: "center"
2815
2839
  });
2816
2840
  p.className = "ago-chat-widget__history-empty", s(p);
2817
- const x = ci({ size: 36 });
2818
- x.style.marginBottom = "8px";
2819
- const B = document.createElement("p");
2820
- B.textContent = t.labels.noHistory, u(B, {
2841
+ const b = di({ size: 36 });
2842
+ b.style.marginBottom = "8px";
2843
+ const F = document.createElement("p");
2844
+ F.textContent = t.labels.noHistory, u(F, {
2821
2845
  fontSize: "14px",
2822
2846
  lineHeight: "20px",
2823
2847
  margin: "0"
2824
- }), p.append(x, B), o.replaceChildren(p);
2848
+ }), p.append(b, F), o.replaceChildren(p);
2825
2849
  }
2826
- function m(p) {
2827
- const x = d({
2850
+ function f(p) {
2851
+ const b = d({
2828
2852
  flex: "1",
2829
2853
  overflowY: "auto",
2830
2854
  padding: "0 16px 112px",
2831
2855
  minHeight: "0"
2832
2856
  });
2833
- x.className = "ago-chat-widget__history-list";
2834
- const B = Si(p);
2835
- B.forEach((_, h) => {
2836
- const E = document.createElement("button");
2837
- if (E.type = "button", E.className = "ago-chat-widget__thread", E.dataset.agoConversationId = _.id, u(E, {
2857
+ b.className = "ago-chat-widget__history-list";
2858
+ const F = _i(p);
2859
+ F.forEach((y, m) => {
2860
+ const k = document.createElement("button");
2861
+ if (k.type = "button", k.className = "ago-chat-widget__thread", k.dataset.agoConversationId = y.id, u(k, {
2838
2862
  display: "flex",
2839
2863
  alignItems: "center",
2840
2864
  gap: "8px",
@@ -2843,26 +2867,26 @@ function Va(t) {
2843
2867
  textAlign: "left",
2844
2868
  backgroundColor: "transparent",
2845
2869
  border: "none",
2846
- borderBottom: h === B.length - 1 ? "none" : `1px solid ${Er}`,
2870
+ borderBottom: m === F.length - 1 ? "none" : `1px solid ${kr}`,
2847
2871
  cursor: "pointer",
2848
2872
  font: "inherit",
2849
2873
  color: "inherit"
2850
2874
  }), t.hoverBackground) {
2851
- const C = t.hoverBackground;
2852
- E.addEventListener("mouseenter", () => {
2853
- E.style.backgroundColor = C;
2854
- }), E.addEventListener("mouseleave", () => {
2855
- E.style.backgroundColor = "transparent";
2875
+ const w = t.hoverBackground;
2876
+ k.addEventListener("mouseenter", () => {
2877
+ k.style.backgroundColor = w;
2878
+ }), k.addEventListener("mouseleave", () => {
2879
+ k.style.backgroundColor = "transparent";
2856
2880
  });
2857
2881
  }
2858
- const L = d({
2882
+ const N = d({
2859
2883
  flex: "1",
2860
2884
  minWidth: "0",
2861
2885
  display: "flex",
2862
2886
  flexDirection: "column",
2863
2887
  gap: "4px"
2864
- }), S = document.createElement("h3");
2865
- S.textContent = _.title || t.labels.newConversation, u(S, {
2888
+ }), _ = document.createElement("h3");
2889
+ _.textContent = y.title || t.labels.newConversation, u(_, {
2866
2890
  margin: "0",
2867
2891
  fontSize: "14px",
2868
2892
  lineHeight: "20px",
@@ -2872,23 +2896,23 @@ function Va(t) {
2872
2896
  overflow: "hidden",
2873
2897
  textOverflow: "ellipsis"
2874
2898
  });
2875
- const N = document.createElement("span");
2876
- N.textContent = Wa(_.lastMessageDate, Date.now(), t.labels.timeAgo), u(N, {
2899
+ const I = document.createElement("span");
2900
+ I.textContent = Pa(y.lastMessageDate, Date.now(), t.labels.timeAgo), u(I, {
2877
2901
  fontSize: "12px",
2878
2902
  lineHeight: "16px"
2879
- }), s(N), L.append(S, N);
2880
- const j = Or({ size: 16 });
2881
- t.customFont ? j.style.opacity = "0.6" : j.style.color = ve, E.append(L, j), E.addEventListener("click", () => t.onSelect(_)), x.appendChild(E);
2882
- }), o.replaceChildren(x);
2903
+ }), s(I), N.append(_, I);
2904
+ const j = Hr({ size: 16 });
2905
+ t.customFont ? j.style.opacity = "0.6" : j.style.color = ve, k.append(N, j), k.addEventListener("click", () => t.onSelect(y)), b.appendChild(k);
2906
+ }), o.replaceChildren(b);
2883
2907
  }
2884
2908
  return {
2885
2909
  el: e,
2886
- render: ({ threads: p, loading: x }) => {
2887
- a.textContent = t.labels.newConversation, x ? c() : p.length === 0 ? b() : m(p);
2910
+ render: ({ threads: p, loading: b }) => {
2911
+ a.textContent = t.labels.newConversation, b ? c() : p.length === 0 ? x() : f(p);
2888
2912
  }
2889
2913
  };
2890
2914
  }
2891
- function qa(t) {
2915
+ function Xa(t) {
2892
2916
  const e = d({
2893
2917
  position: "relative",
2894
2918
  display: "flex",
@@ -2935,18 +2959,18 @@ function qa(t) {
2935
2959
  maxWidth: "512px"
2936
2960
  });
2937
2961
  a.className = "ago-chat-widget__home-subtitle", n.appendChild(a);
2938
- const s = (C) => {
2962
+ const s = (w) => {
2939
2963
  i.replaceChildren();
2940
- for (const z of C.split(`
2964
+ for (const O of w.split(`
2941
2965
  `)) {
2942
- const v = d({});
2943
- v.textContent = z, i.appendChild(v);
2966
+ const E = d({});
2967
+ E.textContent = O, i.appendChild(E);
2944
2968
  }
2945
- }, c = (C) => {
2946
- a.replaceChildren(), a.style.display = C ? "" : "none", C && a.appendChild(lt(C));
2969
+ }, c = (w) => {
2970
+ a.replaceChildren(), a.style.display = w ? "" : "none", w && a.appendChild(Ye(w));
2947
2971
  };
2948
2972
  s(t.title), c(t.subtitle);
2949
- const b = d({
2973
+ const x = d({
2950
2974
  flex: "1",
2951
2975
  display: "flex",
2952
2976
  flexDirection: "column",
@@ -2954,7 +2978,7 @@ function qa(t) {
2954
2978
  justifyContent: "center",
2955
2979
  width: "100%",
2956
2980
  position: "relative"
2957
- }), m = d({
2981
+ }), f = d({
2958
2982
  display: "grid",
2959
2983
  gridTemplateColumns: "1fr",
2960
2984
  gap: "12px",
@@ -2964,35 +2988,35 @@ function qa(t) {
2964
2988
  padding: "0 16px",
2965
2989
  boxSizing: "border-box"
2966
2990
  });
2967
- m.className = "ago-chat-widget__starters";
2991
+ f.className = "ago-chat-widget__starters";
2968
2992
  const p = [];
2969
- let x = null;
2970
- const B = (C) => {
2971
- m.replaceChildren(), p.length = 0;
2972
- for (const z of C) _(z);
2973
- C.length > 0 ? m.parentNode || b.insertBefore(m, h) : m.remove();
2993
+ let b = null;
2994
+ const F = (w) => {
2995
+ f.replaceChildren(), p.length = 0;
2996
+ for (const O of w) y(O);
2997
+ w.length > 0 ? f.parentNode || x.insertBefore(f, m) : f.remove();
2974
2998
  };
2975
- function _(C) {
2976
- const z = document.createElement("button");
2977
- z.type = "button", z.className = "ago-chat-widget__starter", u(z, {
2999
+ function y(w) {
3000
+ const O = document.createElement("button");
3001
+ O.type = "button", O.className = "ago-chat-widget__starter", u(O, {
2978
3002
  textAlign: "left",
2979
3003
  borderRadius: "12px",
2980
3004
  border: "1px solid rgba(228, 228, 231, 0.6)",
2981
3005
  backgroundColor: "#fff",
2982
3006
  padding: "14px 16px",
2983
- boxShadow: Jt,
3007
+ boxShadow: en,
2984
3008
  transition: "all 0.2s",
2985
3009
  cursor: "pointer",
2986
3010
  font: "inherit",
2987
3011
  color: ne,
2988
3012
  position: "relative"
2989
3013
  });
2990
- const v = d({
3014
+ const E = d({
2991
3015
  display: "flex",
2992
3016
  alignItems: "flex-start",
2993
3017
  justifyContent: "space-between",
2994
3018
  gap: "8px"
2995
- }), k = d({
3019
+ }), S = d({
2996
3020
  minWidth: "0",
2997
3021
  flex: "1",
2998
3022
  fontSize: "14px",
@@ -3000,52 +3024,52 @@ function qa(t) {
3000
3024
  display: "-webkit-box",
3001
3025
  overflow: "hidden"
3002
3026
  });
3003
- k.style.setProperty("-webkit-line-clamp", "2"), k.style.setProperty("-webkit-box-orient", "vertical"), k.textContent = C.label;
3004
- const I = Ar({ size: 16 });
3005
- u(I, {
3027
+ S.style.setProperty("-webkit-line-clamp", "2"), S.style.setProperty("-webkit-box-orient", "vertical"), S.textContent = w.label;
3028
+ const R = Fr({ size: 16 });
3029
+ u(R, {
3006
3030
  marginTop: "2px",
3007
3031
  color: "rgba(113, 113, 122, 0.5)",
3008
3032
  transition: "all 0.15s"
3009
- }), v.append(k, I), z.appendChild(v), z.addEventListener("mouseenter", () => {
3010
- z.disabled || (z.style.borderColor = "#e4e4e7", z.style.boxShadow = si, z.style.transform = "translateY(-2px)", I.style.color = ne, I.style.transform = "translate(2px, -2px)");
3011
- }), z.addEventListener("mouseleave", () => {
3012
- z.style.borderColor = "rgba(228, 228, 231, 0.6)", z.style.boxShadow = Jt, z.style.transform = "", I.style.color = "rgba(113, 113, 122, 0.5)", I.style.transform = "";
3013
- }), z.addEventListener("click", () => {
3014
- x || t.onStarter(C);
3033
+ }), E.append(S, R), O.appendChild(E), O.addEventListener("mouseenter", () => {
3034
+ O.disabled || (O.style.borderColor = "#e4e4e7", O.style.boxShadow = li, O.style.transform = "translateY(-2px)", R.style.color = ne, R.style.transform = "translate(2px, -2px)");
3035
+ }), O.addEventListener("mouseleave", () => {
3036
+ O.style.borderColor = "rgba(228, 228, 231, 0.6)", O.style.boxShadow = en, O.style.transform = "", R.style.color = "rgba(113, 113, 122, 0.5)", R.style.transform = "";
3037
+ }), O.addEventListener("click", () => {
3038
+ b || t.onStarter(w);
3015
3039
  }), p.push({
3016
- starter: C,
3017
- btn: z
3018
- }), m.appendChild(z);
3040
+ starter: w,
3041
+ btn: O
3042
+ }), f.appendChild(O);
3019
3043
  }
3020
- const h = d({ width: "100%" });
3021
- h.className = "ago-chat-widget__home-composer", b.appendChild(h), B(t.starters);
3022
- const E = d({ flex: "1" });
3023
- o.append(n, b, E), e.appendChild(o);
3024
- const L = t.twoColumnsFrom ?? 640, S = () => {
3025
- const C = typeof window < "u" && window.innerWidth >= L;
3026
- m.style.gridTemplateColumns = C ? "1fr 1fr" : "1fr";
3044
+ const m = d({ width: "100%" });
3045
+ m.className = "ago-chat-widget__home-composer", x.appendChild(m), F(t.starters);
3046
+ const k = d({ flex: "1" });
3047
+ o.append(n, x, k), e.appendChild(o);
3048
+ const N = t.twoColumnsFrom ?? 640, _ = () => {
3049
+ const w = typeof window < "u" && window.innerWidth >= N;
3050
+ f.style.gridTemplateColumns = w ? "1fr 1fr" : "1fr";
3027
3051
  };
3028
- S();
3029
- const N = (C) => {
3030
- x = C;
3031
- for (const { starter: z, btn: v } of p) {
3032
- const k = z === C;
3033
- v.disabled = !!C, v.style.opacity = C ? "0.6" : "", v.style.cursor = C ? "not-allowed" : "pointer";
3034
- const I = v.querySelector("svg");
3035
- I && (I.style.animation = k ? "ago-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite" : "");
3052
+ _();
3053
+ const I = (w) => {
3054
+ b = w;
3055
+ for (const { starter: O, btn: E } of p) {
3056
+ const S = O === w;
3057
+ E.disabled = !!w, E.style.opacity = w ? "0.6" : "", E.style.cursor = w ? "not-allowed" : "pointer";
3058
+ const R = E.querySelector("svg");
3059
+ R && (R.style.animation = S ? "ago-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite" : "");
3036
3060
  }
3037
3061
  };
3038
3062
  return {
3039
3063
  el: e,
3040
- composerSlot: h,
3041
- syncColumns: S,
3042
- setPending: N,
3043
- setContent: (C) => {
3044
- C.title !== void 0 && s(C.title), C.subtitle !== void 0 && c(C.subtitle), C.starters && (B(C.starters), S(), x && N(x));
3064
+ composerSlot: m,
3065
+ syncColumns: _,
3066
+ setPending: I,
3067
+ setContent: (w) => {
3068
+ w.title !== void 0 && s(w.title), w.subtitle !== void 0 && c(w.subtitle), w.starters && (F(w.starters), _(), b && I(b));
3045
3069
  }
3046
3070
  };
3047
3071
  }
3048
- function Ga(t) {
3072
+ function Ka(t) {
3049
3073
  const e = d({
3050
3074
  position: "fixed",
3051
3075
  bottom: "80px",
@@ -3066,7 +3090,7 @@ function Ga(t) {
3066
3090
  background: "#fff",
3067
3091
  border: "1px solid #efefef",
3068
3092
  borderRadius: "50%",
3069
- boxShadow: $n,
3093
+ boxShadow: Mn,
3070
3094
  color: "#333",
3071
3095
  cursor: "pointer",
3072
3096
  display: "inline-block",
@@ -3085,7 +3109,7 @@ function Ga(t) {
3085
3109
  alignItems: "center",
3086
3110
  backgroundColor: "#fff",
3087
3111
  borderRadius: "16px",
3088
- boxShadow: $n,
3112
+ boxShadow: Mn,
3089
3113
  color: "#333",
3090
3114
  display: "flex",
3091
3115
  fontFamily: "Arial, Helvetica, sans-serif",
@@ -3120,7 +3144,7 @@ function Ga(t) {
3120
3144
  remove: a
3121
3145
  };
3122
3146
  }
3123
- function Xa(t) {
3147
+ function Ya(t) {
3124
3148
  if (typeof t == "string") return t || null;
3125
3149
  if (!t || typeof t != "object") return null;
3126
3150
  const e = t;
@@ -3133,94 +3157,94 @@ function Xa(t) {
3133
3157
  }
3134
3158
  return null;
3135
3159
  }
3136
- var Ka = 0, Ya = 6, Qa = 800, Za = /^(?:\d+(?:\.\d+)?(?:px|rem|em|vw|vmin|vmax|%)|(?:min|max|clamp|calc)\([^;{}]+\))$/i;
3137
- function Ja(t) {
3160
+ var Qa = 0, Za = 6, Ja = 800, es = /^(?:\d+(?:\.\d+)?(?:px|rem|em|vw|vmin|vmax|%)|(?:min|max|clamp|calc)\([^;{}]+\))$/i;
3161
+ function ts(t) {
3138
3162
  const e = typeof t == "number" ? `${t}px` : String(t).trim();
3139
- return !Za.test(e) || typeof CSS < "u" && typeof CSS.supports == "function" && !CSS.supports("width", `min(max(400px, ${e}), 100% - 40px)`) ? null : e;
3163
+ return !es.test(e) || typeof CSS < "u" && typeof CSS.supports == "function" && !CSS.supports("width", `min(max(400px, ${e}), 100% - 40px)`) ? null : e;
3140
3164
  }
3141
- function es(t) {
3165
+ function ns(t) {
3142
3166
  const e = typeof t == "string" ? document.querySelector(t) : t;
3143
3167
  if (!e) throw new Error(`mountChatWidget: target "${String(t)}" not found.`);
3144
3168
  return e;
3145
3169
  }
3146
- function us(t, e) {
3170
+ function ms(t, e) {
3147
3171
  const o = e.placement ?? "inline", n = o === "bubble";
3148
- if (!e.client && !e.config?.baseUrl) throw new ir("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
3149
- const i = e.client ?? new nr(e.config);
3150
- let a = i.getLanguage?.() ?? null, s = je(a);
3151
- const { welcomeMessage: c = s.common.welcome, allowFiles: b = !1, allowStop: m = !0, autoScroll: p = !0, height: x = 500, defaultOpen: B = !1, logoUrl: _, showAgentName: h = !1, agentBubble: E = !1, bubbleStyle: L = "default", showHeader: S = !0, forms: N, formSubmittedMessage: j, onFollowUpClick: C, onMessageSent: z, onMessageReceived: v, onFormSubmitting: k, onFormSubmitted: I, onFormError: O, onOpen: $, onClose: W, icon: q, subtitle: w, conversationStarters: R = [], autoResume: K = !0, hideFooter: G = !1, loadHomeConfig: ee = !1 } = e;
3172
+ if (!e.client && !e.config?.baseUrl) throw new rr("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
3173
+ const i = e.client ?? new or(e.config);
3174
+ let a = i.getLanguage?.() ?? null, s = We(a);
3175
+ const { welcomeMessage: c = s.common.welcome, allowFiles: x = !1, allowStop: f = !0, autoScroll: p = !0, height: b = 500, defaultOpen: F = !1, logoUrl: y, showAgentName: m = !1, agentBubble: k = !1, bubbleStyle: N = "default", showHeader: _ = !0, forms: I, formSubmittedMessage: j, onFollowUpClick: w, onMessageSent: O, onMessageReceived: E, onFormSubmitting: S, onFormSubmitted: R, onFormError: H, onOpen: $, onClose: W, icon: q, subtitle: v, conversationStarters: z = [], autoResume: K = !0, hideFooter: G = !1, loadHomeConfig: ee = !1 } = e;
3152
3176
  let Y = e.title ?? (n ? "AGO Chatbot" : s.common.chat);
3153
- const f = e.width ?? (n ? 550 : 400), H = e.loadThreads ?? n, P = e.feedback ?? n, D = Po(e.labels, a);
3154
- let oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), me = e.prompt === void 0 ? s.common.prompt : e.prompt;
3155
- const se = n ? {
3156
- ...Nr(e.colors),
3177
+ const g = e.width ?? (n ? 550 : 400), B = e.loadThreads ?? n, P = e.feedback ?? n, D = Vo(e.labels, a);
3178
+ let oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), ge = e.prompt === void 0 ? s.common.prompt : e.prompt;
3179
+ const ae = n ? {
3180
+ ...Ir(e.colors),
3157
3181
  ...e.theme
3158
- } : e.theme, Ke = typeof c == "string" ? {
3182
+ } : e.theme, Qe = typeof c == "string" ? {
3159
3183
  message: c,
3160
3184
  mode: "static"
3161
3185
  } : c;
3162
- let rn = Ke.message;
3163
- const Xn = Ke.mode ?? "static", _i = "speed" in Ke && Ke.speed || 45, Kn = "followUpReplies" in Ke && Ke.followUpReplies || void 0, an = es(t), Nt = o === "left" || o === "right", ge = Nt || n, Ti = ge && (e.launcher ?? !0);
3164
- let ie = ge ? B : !0, sn = !1;
3165
- const Ai = e.mobile?.breakpoint ?? (n ? 450 : 768), ln = e.mobile?.trigger ?? "tap", Yn = typeof window < "u" && !!window.matchMedia, ce = Yn ? window.matchMedia(`(max-width: ${Ai}px), (max-height: 500px) and (orientation: landscape)`) : void 0, Fi = Yn ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Li = !!ce, ct = !ge && !!ce, dt = /* @__PURE__ */ Symbol("ago-scroll-lock");
3186
+ let an = Qe.message;
3187
+ const Yn = Qe.mode ?? "static", Ti = "speed" in Qe && Qe.speed || 45, Qn = "followUpReplies" in Qe && Qe.followUpReplies || void 0, sn = ns(t), It = o === "left" || o === "right", he = It || n, Ai = he && (e.launcher ?? !0);
3188
+ let ie = he ? F : !0, ln = !1;
3189
+ const Fi = e.mobile?.breakpoint ?? (n ? 450 : 768), cn = e.mobile?.trigger ?? "tap", Zn = typeof window < "u" && !!window.matchMedia, ce = Zn ? window.matchMedia(`(max-width: ${Fi}px), (max-height: 500px) and (orientation: landscape)`) : void 0, Li = Zn ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Ni = !!ce, dt = !he && !!ce, pt = /* @__PURE__ */ Symbol("ago-scroll-lock");
3166
3190
  let re = !1;
3167
- const cn = e.persistConversation ?? (n ? !0 : void 0), Ye = cn ? rr(cn === !0 ? {} : cn) : void 0;
3168
- let J = e.conversationId ?? Ye?.getLastActiveThread() ?? void 0, F = [], It = [], he = !1, Ae = null, ze;
3169
- const pt = [];
3170
- function Ni(r) {
3191
+ const dn = e.persistConversation ?? (n ? !0 : void 0), Ze = dn ? ar(dn === !0 ? {} : dn) : void 0;
3192
+ let J = e.conversationId ?? Ze?.getLastActiveThread() ?? void 0, L = [], Rt = [], be = !1, Ae = null, ze;
3193
+ const ut = [];
3194
+ function Ii(r) {
3171
3195
  if (typeof j == "function") {
3172
- const g = j(r);
3173
- if (typeof g == "string" && g) return g;
3196
+ const h = j(r);
3197
+ if (typeof h == "string" && h) return h;
3174
3198
  }
3175
- const l = Xa(r);
3199
+ const l = Ya(r);
3176
3200
  return l || (typeof j == "string" ? j : null);
3177
3201
  }
3178
3202
  const ke = [], A = d({
3179
3203
  display: "flex",
3180
3204
  flexDirection: "column",
3181
- height: Nt ? "100%" : typeof x == "number" ? `${x}px` : x,
3205
+ height: It ? "100%" : typeof b == "number" ? `${b}px` : b,
3182
3206
  border: `1px solid ${Q}`,
3183
- borderRadius: pr,
3207
+ borderRadius: ur,
3184
3208
  overflow: "hidden",
3185
3209
  backgroundColor: Ee,
3186
3210
  fontFamily: Re,
3187
3211
  textAlign: "left",
3188
3212
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
3189
3213
  });
3190
- A.className = "ago-chat-widget", Mo(A, se), n && (u(A, {
3214
+ A.className = "ago-chat-widget", In(A, ae), n && (u(A, {
3191
3215
  height: "100%",
3192
3216
  width: "100%",
3193
3217
  border: "none",
3194
3218
  borderRadius: "0",
3195
3219
  boxShadow: "none",
3196
- backgroundColor: Rn,
3220
+ backgroundColor: On,
3197
3221
  color: ne,
3198
3222
  fontSize: "14px",
3199
3223
  lineHeight: "24px"
3200
- }), se?.headerText || A.style.setProperty("--ago-header-text-color", Sr(se?.headerBg ?? se?.brand ?? "#03182f")));
3201
- let be;
3202
- if (S && !n) {
3203
- if (be = d({
3224
+ }), ae?.headerText || A.style.setProperty("--ago-header-text-color", _r(ae?.headerBg ?? ae?.brand ?? "#03182f")));
3225
+ let xe;
3226
+ if (_ && !n) {
3227
+ if (xe = d({
3204
3228
  padding: "14px 16px",
3205
3229
  borderBottom: `1px solid ${Q}`,
3206
- backgroundColor: ri,
3207
- color: zn,
3230
+ backgroundColor: ai,
3231
+ color: Hn,
3208
3232
  display: "flex",
3209
3233
  alignItems: "center",
3210
3234
  gap: "10px"
3211
- }), be.className = "ago-chat-widget__header", _) {
3235
+ }), xe.className = "ago-chat-widget__header", y) {
3212
3236
  const l = document.createElement("img");
3213
- l.src = _, l.alt = "Logo", u(l, {
3237
+ l.src = y, l.alt = "Logo", u(l, {
3214
3238
  height: "24px",
3215
3239
  width: "auto"
3216
- }), be.appendChild(l);
3240
+ }), xe.appendChild(l);
3217
3241
  }
3218
3242
  const r = document.createElement("h3");
3219
3243
  if (r.className = "ago-chat-widget__title", r.textContent = Y, u(r, {
3220
3244
  margin: "0",
3221
3245
  fontSize: "15px",
3222
3246
  fontWeight: "600"
3223
- }), be.appendChild(r), Nt) {
3247
+ }), xe.appendChild(r), It) {
3224
3248
  const l = document.createElement("button");
3225
3249
  l.type = "button", l.className = "ago-chat-widget__close", l.setAttribute("aria-label", s.common.close), l.textContent = "×", u(l, {
3226
3250
  marginLeft: "auto",
@@ -3233,12 +3257,12 @@ function us(t, e) {
3233
3257
  margin: "-10px -10px -10px auto",
3234
3258
  background: "transparent",
3235
3259
  border: "none",
3236
- color: zn,
3260
+ color: Hn,
3237
3261
  fontSize: "22px",
3238
3262
  lineHeight: "1",
3239
3263
  cursor: "pointer",
3240
3264
  padding: "0"
3241
- }), l.addEventListener("click", () => tt()), be.appendChild(l);
3265
+ }), l.addEventListener("click", () => ot()), xe.appendChild(l);
3242
3266
  }
3243
3267
  }
3244
3268
  const te = d({
@@ -3247,10 +3271,10 @@ function us(t, e) {
3247
3271
  overflowAnchor: p ? "auto" : "none",
3248
3272
  overscrollBehavior: "contain",
3249
3273
  padding: "16px",
3250
- backgroundColor: ai
3274
+ backgroundColor: si
3251
3275
  });
3252
3276
  te.className = "ago-chat-widget__messages", te.setAttribute("role", "log"), te.setAttribute("aria-live", "polite"), te.setAttribute("aria-relevant", "additions text"), te.setAttribute("aria-atomic", "false");
3253
- const xe = n ? d({
3277
+ const ye = n ? d({
3254
3278
  maxWidth: "768px",
3255
3279
  margin: "0 auto",
3256
3280
  padding: "0 8px",
@@ -3259,22 +3283,22 @@ function us(t, e) {
3259
3283
  n && (u(te, {
3260
3284
  padding: "16px 0",
3261
3285
  backgroundColor: "transparent"
3262
- }), xe.className = "ago-chat-widget__list", te.appendChild(xe));
3263
- const Ii = 48;
3264
- let Oe = !0, dn = 0;
3265
- function pn(r) {
3266
- dn++;
3286
+ }), ye.className = "ago-chat-widget__list", te.appendChild(ye));
3287
+ const Ri = 48;
3288
+ let Oe = !0, pn = 0;
3289
+ function un(r) {
3290
+ pn++;
3267
3291
  try {
3268
3292
  r();
3269
3293
  } finally {
3270
3294
  const l = () => {
3271
- dn--;
3295
+ pn--;
3272
3296
  };
3273
3297
  typeof queueMicrotask == "function" ? queueMicrotask(l) : l();
3274
3298
  }
3275
3299
  }
3276
- function Qn() {
3277
- return te.scrollHeight - te.scrollTop - te.clientHeight <= Ii;
3300
+ function Jn() {
3301
+ return te.scrollHeight - te.scrollTop - te.clientHeight <= Ri;
3278
3302
  }
3279
3303
  const le = document.createElement("button");
3280
3304
  le.type = "button", le.className = "ago-chat-widget__jump", le.setAttribute("aria-label", s.common.jumpToLatest), le.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>', u(le, {
@@ -3294,64 +3318,64 @@ function us(t, e) {
3294
3318
  boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
3295
3319
  cursor: "pointer",
3296
3320
  zIndex: "2"
3297
- }), n && (le.setAttribute("aria-label", D.scrollToBottom), le.replaceChildren(gr({ size: 20 })), u(le, {
3321
+ }), n && (le.setAttribute("aria-label", D.scrollToBottom), le.replaceChildren(hr({ size: 20 })), u(le, {
3298
3322
  display: "flex",
3299
3323
  width: "36px",
3300
3324
  height: "36px",
3301
3325
  padding: "8px",
3302
3326
  boxSizing: "border-box",
3303
- border: `1px solid ${ii}`,
3327
+ border: `1px solid ${ri}`,
3304
3328
  backgroundColor: "#fff",
3305
- boxShadow: si,
3329
+ boxShadow: li,
3306
3330
  transition: "opacity 0.3s",
3307
3331
  opacity: "0",
3308
3332
  pointerEvents: "none"
3309
3333
  }));
3310
- function Zn() {
3311
- Oe = !0, pn(() => {
3334
+ function eo() {
3335
+ Oe = !0, un(() => {
3312
3336
  te.scrollTop = te.scrollHeight;
3313
- }), un();
3337
+ }), fn();
3314
3338
  }
3315
- le.addEventListener("click", Zn);
3316
- function un() {
3317
- const r = p ? Oe : Qn();
3339
+ le.addEventListener("click", eo);
3340
+ function fn() {
3341
+ const r = p ? Oe : Jn();
3318
3342
  if (n) {
3319
3343
  le.style.opacity = r ? "0" : "1", le.style.pointerEvents = r ? "none" : "auto";
3320
3344
  return;
3321
3345
  }
3322
3346
  le.style.display = r ? "none" : "flex";
3323
3347
  }
3324
- function fn() {
3325
- p && Oe && pn(() => {
3348
+ function mn() {
3349
+ p && Oe && un(() => {
3326
3350
  te.scrollTop = te.scrollHeight;
3327
- }), un();
3351
+ }), fn();
3328
3352
  }
3329
- function Jn(r) {
3330
- pn(() => {
3353
+ function to(r) {
3354
+ un(() => {
3331
3355
  const l = te.scrollTop;
3332
3356
  r(), (!p || !Oe) && (te.scrollTop = l);
3333
- }), fn();
3357
+ }), mn();
3334
3358
  }
3335
3359
  te.addEventListener("scroll", () => {
3336
- dn > 0 || (Oe = Qn(), un());
3360
+ pn > 0 || (Oe = Jn(), fn());
3337
3361
  });
3338
- const mn = d({
3362
+ const gn = d({
3339
3363
  position: "relative",
3340
3364
  flex: "1",
3341
3365
  display: "flex",
3342
3366
  minHeight: "0"
3343
3367
  });
3344
- mn.append(te, le);
3345
- const { inputRow: Se, setDisabled: Ri, focus: Rt, restoreDraft: zi, setPlaceholder: gn, getValueAndClear: Oi, setSpeechToTextEnabled: Hi, setLabels: Bi, cancelRecording: ut, destroy: $i } = Mr({
3368
+ gn.append(te, le);
3369
+ const { inputRow: Se, setDisabled: zi, focus: zt, restoreDraft: Oi, setPlaceholder: hn, getValueAndClear: Hi, setSpeechToTextEnabled: Bi, setLabels: $i, cancelRecording: ft, destroy: Di } = jr({
3346
3370
  placeholder: oe,
3347
- allowFiles: b,
3371
+ allowFiles: x,
3348
3372
  transcribeAudio: e.speechToText ? (r, l) => i.transcribeAudio(r, l) : void 0,
3349
3373
  speechToTextLabels: Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0),
3350
3374
  onSend: (r, l) => {
3351
- et(r, l);
3375
+ nt(r, l);
3352
3376
  },
3353
- onStop: m ? () => {
3354
- Pt();
3377
+ onStop: f ? () => {
3378
+ Vt();
3355
3379
  } : void 0,
3356
3380
  look: n ? "embed" : "classic",
3357
3381
  labels: {
@@ -3362,76 +3386,76 @@ function us(t, e) {
3362
3386
  removeFile: s.form.removeFile
3363
3387
  }
3364
3388
  });
3365
- Fr(), e.speechToText && i.getConfig().then((r) => {
3366
- re || Hi(r.permissions.some((l) => l.speechToTextEnabled));
3389
+ Lr(), e.speechToText && i.getConfig().then((r) => {
3390
+ re || Bi(r.permissions.some((l) => l.speechToTextEnabled));
3367
3391
  }).catch(() => {
3368
- }), n || A.append(...be ? [be] : [], mn, Se);
3369
- let ft = A, U, ye, zt;
3370
- const mt = o === "left" ? "left" : "right";
3371
- let Ot, gt, Fe, We, Ht, ht, de, Ue, Qe, pe = "home", Bt = "home", Ze = !1, bt = H, xt = !1, yt = !1, hn;
3392
+ }), n || A.append(...xe ? [xe] : [], gn, Se);
3393
+ let mt = A, U, pe, Ot;
3394
+ const gt = o === "left" ? "left" : "right";
3395
+ let Ht, ht, Fe, Ue, Bt, bt, de, Pe, Je, ue = "home", $t = "home", et = !1, xt = B, yt = !1, Ct = !1, bn;
3372
3396
  if (n) {
3373
3397
  if (U = d({
3374
3398
  position: "fixed",
3375
3399
  right: "20px",
3376
3400
  bottom: "80px",
3377
3401
  top: "max(40px, calc(100% - 880px))",
3378
- width: `min(max(400px, ${$o}), var(--ago-panel-max, calc(100% - 40px)))`,
3402
+ width: `min(max(400px, ${Mo}), var(--ago-panel-max, calc(100% - 40px)))`,
3379
3403
  height: "auto",
3380
3404
  borderRadius: "16px",
3381
- boxShadow: $n,
3405
+ boxShadow: Mn,
3382
3406
  overflow: "hidden",
3383
3407
  transformOrigin: "right bottom",
3384
3408
  zIndex: "2147483000",
3385
- backgroundColor: Rn,
3409
+ backgroundColor: On,
3386
3410
  display: "none",
3387
3411
  fontFamily: Re
3388
- }), U.className = "ago-chat-widget-bubble", U.dataset.agoLayout = "panel", Mo(U, se), !se?.panelWidth) {
3389
- const l = Ja(f);
3390
- l ? U.style.setProperty("--ago-panel-width", l) : console.warn(`[AGO] mountChatWidget width "${String(f)}" is not a valid CSS length, ignoring. Expected e.g. 700 or "45rem". Falling back to 550px.`);
3412
+ }), U.className = "ago-chat-widget-bubble", U.dataset.agoLayout = "panel", In(U, ae), !ae?.panelWidth) {
3413
+ const l = ts(g);
3414
+ l ? U.style.setProperty("--ago-panel-width", l) : console.warn(`[AGO] mountChatWidget width "${String(g)}" is not a valid CSS length, ignoring. Expected e.g. 700 or "45rem". Falling back to 550px.`);
3391
3415
  }
3392
- S && (Ot = Wr({
3416
+ _ && (Ht = Ur({
3393
3417
  title: Y,
3394
3418
  labels: D,
3395
- onBack: () => De(Bt, { byUser: !0 }),
3396
- onNewChat: () => Vt(),
3397
- onClose: () => tt()
3398
- }), A.appendChild(Ot.el)), ht = d({
3419
+ onBack: () => De($t, { byUser: !0 }),
3420
+ onNewChat: () => qt(),
3421
+ onClose: () => ot()
3422
+ }), A.appendChild(Ht.el)), bt = d({
3399
3423
  flex: "1",
3400
3424
  display: "flex",
3401
3425
  flexDirection: "column",
3402
3426
  minHeight: "0",
3403
3427
  overflow: "hidden"
3404
- }), ht.className = "ago-chat-widget__main", A.appendChild(ht), G || (gt = jr({
3428
+ }), bt.className = "ago-chat-widget__main", A.appendChild(bt), G || (ht = Wr({
3405
3429
  labels: D,
3406
3430
  onNavigate: (l) => De(l, { byUser: !0 })
3407
- }), A.appendChild(gt.el)), Fe = qa({
3431
+ }), A.appendChild(ht.el)), Fe = Xa({
3408
3432
  title: Y,
3409
- subtitle: w,
3410
- starters: R,
3433
+ subtitle: v,
3434
+ starters: z,
3411
3435
  onStarter: (l) => {
3412
- Fe?.setPending(l), et(l.message ?? l.label, void 0, { agentId: l.agentId }).finally(() => Fe?.setPending(null));
3436
+ Fe?.setPending(l), nt(l.message ?? l.label, void 0, { agentId: l.agentId }).finally(() => Fe?.setPending(null));
3413
3437
  }
3414
3438
  });
3415
3439
  const r = e.colors?.background;
3416
- We = Va({
3440
+ Ue = Ga({
3417
3441
  labels: D,
3418
3442
  onSelect: (l) => {
3419
- Ze = !0, Bt = "history", _t(l.id);
3443
+ et = !0, $t = "history", Tt(l.id);
3420
3444
  },
3421
- onNew: () => Vt(),
3422
- hoverBackground: r && Rr(r) ? xr(r, 10) : void 0,
3445
+ onNew: () => qt(),
3446
+ hoverBackground: r && zr(r) ? yr(r, 10) : void 0,
3423
3447
  customFont: !!e.colors?.font
3424
- }), Ht = Da({
3425
- messagesWrap: mn,
3448
+ }), Bt = ja({
3449
+ messagesWrap: gn,
3426
3450
  jumpBtn: le
3427
- }), U.appendChild(A), ft = U;
3451
+ }), U.appendChild(A), mt = U;
3428
3452
  }
3429
- Nt && (U = d({
3453
+ It && (U = d({
3430
3454
  position: "fixed",
3431
3455
  top: "0",
3432
3456
  bottom: "0",
3433
- [mt]: "0",
3434
- width: typeof f == "number" ? `${f}px` : f,
3457
+ [gt]: "0",
3458
+ width: typeof g == "number" ? `${g}px` : g,
3435
3459
  maxWidth: "100vw",
3436
3460
  display: "flex",
3437
3461
  zIndex: "2147483000",
@@ -3443,57 +3467,57 @@ function us(t, e) {
3443
3467
  borderRadius: "0",
3444
3468
  border: "none",
3445
3469
  boxShadow: "none",
3446
- [mt === "left" ? "borderRight" : "borderLeft"]: `1px solid ${Q}`
3447
- }), U.appendChild(A), ft = U);
3448
- const Ct = {
3470
+ [gt === "left" ? "borderRight" : "borderLeft"]: `1px solid ${Q}`
3471
+ }), U.appendChild(A), mt = U);
3472
+ const wt = {
3449
3473
  open: s.common.openTitle.replace("{title}", () => Y),
3450
3474
  close: s.common.closeTitle.replace("{title}", () => Y)
3451
3475
  };
3452
- Ti && (zt = Jr({
3476
+ Ai && (Ot = ta({
3453
3477
  look: n ? "bubble" : "classic",
3454
- labels: Ct,
3455
- edge: mt,
3478
+ labels: wt,
3479
+ edge: gt,
3456
3480
  title: Y,
3457
- icon: n ? q : _,
3458
- onClick: () => n ? No() : Xt()
3459
- }), ye = zt.el);
3460
- const wt = ct ? `ago-vt-${++Ka}` : "", eo = 52;
3461
- let Le = !1, He = 0, Je = 0, ue, vt, Be;
3462
- const $t = {
3481
+ icon: n ? q : y,
3482
+ onClick: () => n ? Ro() : Kt()
3483
+ }), pe = Ot.el, In(pe, ae));
3484
+ const vt = dt ? `ago-vt-${++Qa}` : "", no = 52;
3485
+ let Le = !1, He = 0, tt = 0, fe, Et, Be;
3486
+ const Dt = {
3463
3487
  height: A.style.height,
3464
3488
  border: A.style.border,
3465
3489
  borderRadius: A.style.borderRadius,
3466
3490
  boxShadow: A.style.boxShadow
3467
3491
  };
3468
- an.appendChild(ft), ye && an.appendChild(ye), Gt(), n && (me !== !1 && !ie && (Ue = setTimeout(_o, 1e3)), document.addEventListener("keydown", To), window.addEventListener("resize", Ao)), ct && (ue = Zi(), A.insertBefore(ue, A.firstChild), vt = document.createElement("style"), vt.id = wt, vt.textContent = `::view-transition-group(${wt}),::view-transition-group(${wt}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(vt), (ln === "focus" || ln === "tap") && (A.addEventListener("pointerdown", (r) => {
3492
+ sn.appendChild(mt), pe && sn.appendChild(pe), Xt(), n && (ge !== !1 && !ie && (Pe = setTimeout(Ao, 1e3)), document.addEventListener("keydown", Fo), window.addEventListener("resize", Lo)), dt && (fe = Ji(), A.insertBefore(fe, A.firstChild), Et = document.createElement("style"), Et.id = vt, Et.textContent = `::view-transition-group(${vt}),::view-transition-group(${vt}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(Et), (cn === "focus" || cn === "tap") && (A.addEventListener("pointerdown", (r) => {
3469
3493
  if (Le || !ce?.matches) return;
3470
3494
  const l = Se.contains(r.target);
3471
- if (ln === "tap") {
3495
+ if (cn === "tap") {
3472
3496
  if ((r.target instanceof Element ? r.target : null)?.closest("button,a[href],[role='button']")) return;
3473
3497
  } else if (!l) return;
3474
- l && r.preventDefault(), At();
3498
+ l && r.preventDefault(), Ft();
3475
3499
  }, !0), A.addEventListener("focusin", (r) => {
3476
- ce?.matches && Se.contains(r.target) && At();
3477
- }))), Li && document.addEventListener("keydown", Io), ce && ce.addEventListener("change", Ro);
3478
- const to = C !== !1, no = C === !1 ? void 0 : C ?? ((r) => {
3479
- ct && ce?.matches && !Le ? At().then(() => et(r)) : et(r);
3480
- }), $e = P === !0 ? {} : P || null, bn = {
3500
+ ce?.matches && Se.contains(r.target) && Ft();
3501
+ }))), Ni && document.addEventListener("keydown", zo), ce && ce.addEventListener("change", Oo);
3502
+ const oo = w !== !1, io = w === !1 ? void 0 : w ?? ((r) => {
3503
+ dt && ce?.matches && !Le ? Ft().then(() => nt(r)) : nt(r);
3504
+ }), $e = P === !0 ? {} : P || null, xn = {
3481
3505
  ...s.feedback,
3482
3506
  ...$e?.labels,
3483
3507
  reasons: {
3484
3508
  ...s.feedback.reasons,
3485
3509
  ...$e?.labels?.reasons
3486
3510
  }
3487
- }, Dt = /* @__PURE__ */ new Map();
3488
- function oo(r) {
3511
+ }, Mt = /* @__PURE__ */ new Map();
3512
+ function ro(r) {
3489
3513
  if (!$e || !r.id || !r.conversationId || r.status !== "DONE" || !r.content) return null;
3490
- let l = Dt.get(r.id);
3491
- l || (l = Ra(), Dt.set(r.id, l));
3492
- const g = async (y, T) => {
3514
+ let l = Mt.get(r.id);
3515
+ l || (l = Oa(), Mt.set(r.id, l));
3516
+ const h = async (C, T) => {
3493
3517
  try {
3494
- return await i.submitFeedback(r.id, y, T), $e.onSubmit?.({
3518
+ return await i.submitFeedback(r.id, C, T), $e.onSubmit?.({
3495
3519
  messageId: r.id,
3496
- rating: y,
3520
+ rating: C,
3497
3521
  reasons: T?.reasons ?? [],
3498
3522
  comment: T?.comment || void 0
3499
3523
  }), !0;
@@ -3501,128 +3525,128 @@ function us(t, e) {
3501
3525
  return $e.onError?.(M instanceof Error ? M : new Error(String(M))), !1;
3502
3526
  }
3503
3527
  };
3504
- return Oa({
3528
+ return Ba({
3505
3529
  state: l,
3506
- labels: bn,
3530
+ labels: xn,
3507
3531
  askWhy: $e.askWhy ?? !n,
3508
- onRate: (y) => {
3509
- g(y);
3532
+ onRate: (C) => {
3533
+ h(C);
3510
3534
  },
3511
- onReport: (y, T) => g(y, T),
3535
+ onReport: (C, T) => h(C, T),
3512
3536
  look: n ? "embed" : "classic"
3513
3537
  });
3514
3538
  }
3515
- const ae = e.toolCallForm ?? {}, _e = Ko(s.form, e.toolCallForm?.labels);
3516
- let Et = !1;
3517
- const io = i.getUserIdentity(), xn = ae.userEmail ?? io.email, ro = !xn && !io.hasJwt;
3518
- let Ce = null, Ne = !1, kt, Mt = 0, yn = !1;
3519
- const Pe = /* @__PURE__ */ new Map(), jt = /* @__PURE__ */ new Set();
3520
- function Cn() {
3521
- if (kt || Ne) return;
3522
- const r = ++Mt, l = a;
3523
- kt = i.getConfig().then((g) => {
3524
- if (re || r !== Mt) return;
3525
- Et = !0, ao(l);
3526
- const y = g.permissions[0];
3527
- Ce = y?.ticketForm ?? null, yn = !!y?.fileAttachmentsEnabled, Ne = !1;
3528
- for (const T of Pe.values()) {
3539
+ const se = e.toolCallForm ?? {}, _e = Yo(s.form, e.toolCallForm?.labels);
3540
+ let kt = !1;
3541
+ const ao = i.getUserIdentity(), yn = se.userEmail ?? ao.email, so = !yn && !ao.hasJwt;
3542
+ let Ce = null, Ne = !1, St, jt = 0, Cn = !1;
3543
+ const Ve = /* @__PURE__ */ new Map(), Wt = /* @__PURE__ */ new Set();
3544
+ function wn() {
3545
+ if (St || Ne) return;
3546
+ const r = ++jt, l = a;
3547
+ St = i.getConfig().then((h) => {
3548
+ if (re || r !== jt) return;
3549
+ kt = !0, lo(l);
3550
+ const C = h.permissions[0];
3551
+ Ce = C?.ticketForm ?? null, Cn = !!C?.fileAttachmentsEnabled, Ne = !1;
3552
+ for (const T of Ve.values()) {
3529
3553
  if (T.kind === "embed") {
3530
3554
  T.view.updateText({
3531
3555
  description: Ce?.embedDescription ?? T.call.embedDescription,
3532
- successMessage: ae.successMessage || ae.labels?.embeddedFormSubmitted || Ce?.successMessageText
3556
+ successMessage: se.successMessage || se.labels?.embeddedFormSubmitted || Ce?.successMessageText
3533
3557
  });
3534
3558
  continue;
3535
3559
  }
3536
- T.kind !== "static" && (Ce && !T.hydrated && (Ca(T.state, T.call.ticket, Ce), T.hydrated = !0), T.view.rebuild({
3560
+ T.kind !== "static" && (Ce && !T.hydrated && (va(T.state, T.call.ticket, Ce), T.hydrated = !0), T.view.rebuild({
3537
3561
  ticketForm: Ce,
3538
- allowFiles: b || yn
3562
+ allowFiles: x || Cn
3539
3563
  }));
3540
3564
  }
3541
3565
  X();
3542
- }).catch((g) => {
3543
- if (re || r !== Mt) return;
3544
- kt = void 0;
3545
- const y = g.statusCode ?? g.status;
3546
- if (Ne = !0, y === 401 || y === 403) {
3547
- Ce = null, Et = !1;
3548
- for (const T of Pe.values()) T.kind === "ticket" && T.view.rebuild({ ticketForm: null });
3549
- Ut();
3566
+ }).catch((h) => {
3567
+ if (re || r !== jt) return;
3568
+ St = void 0;
3569
+ const C = h.statusCode ?? h.status;
3570
+ if (Ne = !0, C === 401 || C === 403) {
3571
+ Ce = null, kt = !1;
3572
+ for (const T of Ve.values()) T.kind === "ticket" && T.view.rebuild({ ticketForm: null });
3573
+ Pt();
3550
3574
  }
3551
- St() && X();
3575
+ _t() && X();
3552
3576
  });
3553
3577
  }
3554
- function ao(r) {
3555
- s = je(r), Object.assign(D, Po(e.labels, r)), Object.assign(_e, Ko(s.form, ae.labels));
3556
- for (const y of Pe.values()) y.kind === "static" && y.el.replaceChildren(Yo(_e.notAllowed));
3557
- Object.assign(bn, Me(s.feedback, $e?.labels)), bn.reasons = Me(s.feedback.reasons, $e?.labels?.reasons), oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), e.welcomeMessage === void 0 && (rn = s.common.welcome), e.title === void 0 && !n && (Y = s.common.chat), e.prompt === void 0 && (me = s.common.prompt), Bi({
3578
+ function lo(r) {
3579
+ s = We(r), Object.assign(D, Vo(e.labels, r)), Object.assign(_e, Yo(s.form, se.labels));
3580
+ for (const C of Ve.values()) C.kind === "static" && C.el.replaceChildren(Qo(_e.notAllowed));
3581
+ Object.assign(xn, Me(s.feedback, $e?.labels)), xn.reasons = Me(s.feedback.reasons, $e?.labels?.reasons), oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), e.welcomeMessage === void 0 && (an = s.common.welcome), e.title === void 0 && !n && (Y = s.common.chat), e.prompt === void 0 && (ge = s.common.prompt), $i({
3558
3582
  ...D,
3559
3583
  attachFiles: n ? D.attachFiles : e.labels?.attachFiles ?? s.common.attachFile,
3560
3584
  send: s.common.send,
3561
3585
  stop: s.common.stop,
3562
3586
  removeFile: s.form.removeFile
3563
- }, Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0)), gn(n && pe === "chat" ? "" : oe), le.setAttribute("aria-label", D.scrollToBottom), Ot?.update({ screen: pe }), gt?.setActive(pe), pe === "history" && We?.render({
3587
+ }, Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0)), hn(n && ue === "chat" ? "" : oe), le.setAttribute("aria-label", D.scrollToBottom), Ht?.update({ screen: ue }), ht?.setActive(ue), ue === "history" && Ue?.render({
3564
3588
  threads: ke,
3565
- loading: bt
3589
+ loading: xt
3566
3590
  });
3567
- for (const y of A.querySelectorAll(".ago-chat-widget__close")) y.setAttribute("aria-label", n ? D.close : s.common.close);
3568
- const l = be?.querySelector(".ago-chat-widget__title");
3591
+ for (const C of A.querySelectorAll(".ago-chat-widget__close")) C.setAttribute("aria-label", n ? D.close : s.common.close);
3592
+ const l = xe?.querySelector(".ago-chat-widget__title");
3569
3593
  l && (l.textContent = Y);
3570
- const g = ue?.querySelector(".ago-chat-widget__title");
3571
- g && (g.textContent = Y), ue?.querySelector("button")?.setAttribute("aria-label", s.common.close), A.hasAttribute("aria-label") && A.setAttribute("aria-label", Y), Ct.open = s.common.openTitle.replace("{title}", () => Y), Ct.close = s.common.closeTitle.replace("{title}", () => Y), zt?.setOpen(ie), de && (de.remove(), de = void 0, ie || _o());
3572
- }
3573
- function so({ language: r }) {
3574
- a = r, Mt += 1, kt = void 0, Ne = !1, St() ? Cn() : (Et = !1, ao(a), X());
3594
+ const h = fe?.querySelector(".ago-chat-widget__title");
3595
+ h && (h.textContent = Y), fe?.querySelector("button")?.setAttribute("aria-label", s.common.close), A.hasAttribute("aria-label") && A.setAttribute("aria-label", Y), wt.open = s.common.openTitle.replace("{title}", () => Y), wt.close = s.common.closeTitle.replace("{title}", () => Y), Ot?.setOpen(ie), de && (de.remove(), de = void 0, ie || Ao());
3575
3596
  }
3576
- function Wt() {
3577
- St() && !kt && (Ne = !1, Cn(), X());
3597
+ function co({ language: r }) {
3598
+ a = r, jt += 1, St = void 0, Ne = !1, _t() ? wn() : (kt = !1, lo(a), X());
3578
3599
  }
3579
3600
  function Ut() {
3580
- for (const r of Pe.values()) r.kind === "embed" && r.view.destroy();
3581
- Pe.clear(), jt.clear();
3601
+ _t() && !St && (Ne = !1, wn(), X());
3582
3602
  }
3583
- function lo(r) {
3584
- for (const l of F) {
3585
- const g = l.toolCalls?.find((y) => y.id === r);
3586
- if (g) return g;
3603
+ function Pt() {
3604
+ for (const r of Ve.values()) r.kind === "embed" && r.view.destroy();
3605
+ Ve.clear(), Wt.clear();
3606
+ }
3607
+ function po(r) {
3608
+ for (const l of L) {
3609
+ const h = l.toolCalls?.find((C) => C.id === r);
3610
+ if (h) return h;
3587
3611
  }
3588
3612
  }
3589
- function Di(r, l) {
3590
- const g = Pe.get(r.id);
3591
- if (g) return g;
3592
- let y;
3613
+ function Mi(r, l) {
3614
+ const h = Ve.get(r.id);
3615
+ if (h) return h;
3616
+ let C;
3593
3617
  if (r.allowedToCreateTicket === !1) {
3594
3618
  const T = d({
3595
3619
  display: "flex",
3596
3620
  flexDirection: "column",
3597
3621
  gap: "16px"
3598
3622
  });
3599
- T.className = "ago-ticket-form ago-ticket-form--denied", T.appendChild(Yo(l.notAllowed)), y = {
3623
+ T.className = "ago-ticket-form ago-ticket-form--denied", T.appendChild(Qo(l.notAllowed)), C = {
3600
3624
  kind: "static",
3601
3625
  el: T
3602
3626
  };
3603
3627
  } else if (r.mode === "embed") {
3604
- const T = { status: Jo(r) ? "submitted" : "loading" };
3605
- y = {
3628
+ const T = { status: ei(r) ? "submitted" : "loading" };
3629
+ C = {
3606
3630
  kind: "embed",
3607
3631
  state: T,
3608
- view: Aa({
3632
+ view: La({
3609
3633
  state: T,
3610
3634
  embedHtml: r.embedHtml,
3611
3635
  description: Ce?.embedDescription ?? r.embedDescription,
3612
3636
  ticket: r.ticket,
3613
- email: xn,
3637
+ email: yn,
3614
3638
  labels: l,
3615
3639
  message: r.message,
3616
- successMessage: ae.successMessage || ae.labels?.embeddedFormSubmitted || Ce?.successMessageText,
3640
+ successMessage: se.successMessage || se.labels?.embeddedFormSubmitted || Ce?.successMessageText,
3617
3641
  onSubmitted: (M) => {
3618
- jt.add(r.id), i.submitToolCallForm(r.id, {
3642
+ Wt.add(r.id), i.submitToolCallForm(r.id, {
3619
3643
  success: !0,
3620
3644
  source: "embed",
3621
3645
  thread_id: J,
3622
3646
  captured_form_data: M
3623
3647
  }).then((V) => {
3624
3648
  const Z = V.ticket ?? V.result?.ticket;
3625
- ae.onSubmitted?.({
3649
+ se.onSubmitted?.({
3626
3650
  toolCallId: r.id,
3627
3651
  toolName: r.toolName,
3628
3652
  mode: "embed",
@@ -3633,7 +3657,7 @@ function us(t, e) {
3633
3657
  values: M ?? {}
3634
3658
  });
3635
3659
  }).catch((V) => {
3636
- ae.onError?.(V instanceof Error ? V : new Error(String(V)));
3660
+ se.onError?.(V instanceof Error ? V : new Error(String(V)));
3637
3661
  }).finally(() => {
3638
3662
  re || X();
3639
3663
  });
@@ -3642,19 +3666,19 @@ function us(t, e) {
3642
3666
  call: r
3643
3667
  };
3644
3668
  } else {
3645
- const T = Gn(r.ticket, Ce, xn ?? ""), M = Jo(r);
3646
- M && (T.submitted = M), y = {
3669
+ const T = Kn(r.ticket, Ce, yn ?? ""), M = ei(r);
3670
+ M && (T.submitted = M), C = {
3647
3671
  kind: "ticket",
3648
3672
  state: T,
3649
- view: Ea({
3673
+ view: Sa({
3650
3674
  state: T,
3651
3675
  ticketForm: Ce,
3652
3676
  labels: l,
3653
3677
  message: r.message,
3654
- requireEmail: ro,
3655
- allowFiles: b || yn,
3656
- successMessage: ae.successMessage || ae.labels?.ticketSubmitted,
3657
- successUrlLabel: ae.successUrlLabel || ae.labels?.findTicketHere,
3678
+ requireEmail: so,
3679
+ allowFiles: x || Cn,
3680
+ successMessage: se.successMessage || se.labels?.ticketSubmitted,
3681
+ successUrlLabel: se.successUrlLabel || se.labels?.findTicketHere,
3658
3682
  createTicket: (V) => i.createTicket({
3659
3683
  subject: V.subject,
3660
3684
  body: V.body,
@@ -3667,10 +3691,10 @@ function us(t, e) {
3667
3691
  ticketFormId: V.ticketFormId
3668
3692
  }),
3669
3693
  onCreated: (V, Z) => {
3670
- jt.add(r.id);
3671
- const Fn = Object.entries(Z.customFields).map(([Lt, er]) => ({
3672
- id: Lt,
3673
- value: er
3694
+ Wt.add(r.id);
3695
+ const Ln = Object.entries(Z.customFields).map(([Nt, tr]) => ({
3696
+ id: Nt,
3697
+ value: tr
3674
3698
  }));
3675
3699
  i.submitToolCallForm(r.id, {
3676
3700
  success: !0,
@@ -3681,12 +3705,12 @@ function us(t, e) {
3681
3705
  priority: Z.ticket.priority,
3682
3706
  body: Z.ticket.body,
3683
3707
  tag: Z.ticket.tag,
3684
- custom_fields: Fn,
3708
+ custom_fields: Ln,
3685
3709
  created_at: (/* @__PURE__ */ new Date()).toISOString()
3686
- }).catch((Lt) => {
3687
- ae.onError?.(Lt instanceof Error ? Lt : new Error(String(Lt)));
3710
+ }).catch((Nt) => {
3711
+ se.onError?.(Nt instanceof Error ? Nt : new Error(String(Nt)));
3688
3712
  }).finally(() => {
3689
- ae.onSubmitted?.({
3713
+ se.onSubmitted?.({
3690
3714
  toolCallId: r.id,
3691
3715
  toolName: r.toolName,
3692
3716
  mode: "form",
@@ -3697,48 +3721,48 @@ function us(t, e) {
3697
3721
  values: {
3698
3722
  ...Z.ticket,
3699
3723
  custom_fields: Z.customFields,
3700
- email: ro ? Z.email : void 0
3724
+ email: so ? Z.email : void 0
3701
3725
  }
3702
3726
  }), re || X();
3703
3727
  });
3704
3728
  },
3705
- onError: ae.onError
3729
+ onError: se.onError
3706
3730
  }),
3707
3731
  call: r,
3708
3732
  hydrated: !!Ce
3709
3733
  };
3710
3734
  }
3711
- return Pe.set(r.id, y), y;
3735
+ return Ve.set(r.id, C), C;
3712
3736
  }
3713
- function co(r) {
3737
+ function uo(r) {
3714
3738
  if (r.type !== "form" || r.displayMode === "collapsible") return null;
3715
- const l = Zo(F);
3739
+ const l = Jo(L);
3716
3740
  if (l && l !== r.id) {
3717
- const y = lo(l), T = !!y?.askToTalkToHuman && y.allowedToCreateTicket === !1;
3718
- return Na(T ? _e.contactFormRejected : _e.contactFormCreated, T ? "warning" : "info");
3741
+ const C = po(l), T = !!C?.askToTalkToHuman && C.allowedToCreateTicket === !1;
3742
+ return Ra(T ? _e.contactFormRejected : _e.contactFormCreated, T ? "warning" : "info");
3719
3743
  }
3720
- if (!Qo(r)) return Ia(r, _e);
3721
- if (r.allowedToCreateTicket !== !1 && (Cn(), !Et)) {
3744
+ if (!Zo(r)) return za(r, _e);
3745
+ if (r.allowedToCreateTicket !== !1 && (wn(), !kt)) {
3722
3746
  if (Ne) return null;
3723
- const y = d({
3747
+ const C = d({
3724
3748
  padding: "16px",
3725
3749
  textAlign: "center",
3726
3750
  fontWeight: "700",
3727
3751
  fontSize: "20px"
3728
3752
  });
3729
- return y.className = "ago-ticket-form__config-loading", y.setAttribute("role", "status"), y.textContent = _e.loading, y;
3753
+ return C.className = "ago-ticket-form__config-loading", C.setAttribute("role", "status"), C.textContent = _e.loading, C;
3730
3754
  }
3731
- const g = Di(r, _e);
3732
- return g.kind === "static" ? g.el : g.view.el;
3755
+ const h = Mi(r, _e);
3756
+ return h.kind === "static" ? h.el : h.view.el;
3733
3757
  }
3734
3758
  let Ie;
3735
- function Mi() {
3736
- const r = F.some((y) => y.toolCalls?.some((T) => T.type === "form")), l = jt.size > 0 || Fa(F);
3759
+ function ji() {
3760
+ const r = L.some((C) => C.toolCalls?.some((T) => T.type === "form")), l = Wt.size > 0 || Na(L);
3737
3761
  if (!r && !l) {
3738
3762
  Se.style.display = "", Ie?.remove();
3739
3763
  return;
3740
3764
  }
3741
- if (!Et && St()) {
3765
+ if (!kt && _t()) {
3742
3766
  Se.style.display = "none", Ie?.remove();
3743
3767
  return;
3744
3768
  }
@@ -3756,16 +3780,16 @@ function us(t, e) {
3756
3780
  textAlign: "center",
3757
3781
  fontFamily: Re
3758
3782
  }), Ie.className = "ago-chat-blocked"), Ie.replaceChildren();
3759
- const g = document.createElement("p");
3760
- if (g.textContent = l ? _e.ticketCreatedBlocked : _e.formPending, u(g, {
3761
- color: rt,
3783
+ const h = document.createElement("p");
3784
+ if (h.textContent = l ? _e.ticketCreatedBlocked : _e.formPending, u(h, {
3785
+ color: st,
3762
3786
  lineHeight: "1.625",
3763
3787
  fontSize: "16px",
3764
3788
  margin: "0",
3765
3789
  whiteSpace: "pre-line"
3766
- }), Ie.appendChild(g), l) {
3767
- const y = document.createElement("button");
3768
- y.type = "button", y.className = "ago-chat-blocked__new", u(y, {
3790
+ }), Ie.appendChild(h), l) {
3791
+ const C = document.createElement("button");
3792
+ C.type = "button", C.className = "ago-chat-blocked__new", u(C, {
3769
3793
  display: "inline-flex",
3770
3794
  alignItems: "center",
3771
3795
  gap: "8px",
@@ -3779,66 +3803,66 @@ function us(t, e) {
3779
3803
  font: "inherit",
3780
3804
  fontSize: "14px",
3781
3805
  fontWeight: "500"
3782
- }), y.append(qn({ size: 18 }));
3806
+ }), C.append(Xn({ size: 18 }));
3783
3807
  const T = document.createElement("span");
3784
- T.textContent = _e.newConversation, y.appendChild(T), y.addEventListener("click", () => {
3785
- Vt(), ae.onNewConversation?.();
3786
- }), Ie.appendChild(y);
3808
+ T.textContent = _e.newConversation, C.appendChild(T), C.addEventListener("click", () => {
3809
+ qt(), se.onNewConversation?.();
3810
+ }), Ie.appendChild(C);
3787
3811
  }
3788
3812
  Se.style.display = "none", Se.parentElement?.insertBefore(Ie, Se);
3789
3813
  }
3790
- function St() {
3791
- const r = Zo(F), l = r ? lo(r) : void 0;
3792
- return !!l && Qo(l) && l.displayMode !== "collapsible" && l.allowedToCreateTicket !== !1;
3814
+ function _t() {
3815
+ const r = Jo(L), l = r ? po(r) : void 0;
3816
+ return !!l && Zo(l) && l.displayMode !== "collapsible" && l.allowedToCreateTicket !== !1;
3793
3817
  }
3794
- function po(r) {
3795
- const l = F[r];
3796
- return n ? aa(l, {
3797
- isLast: r === F.length - 1,
3798
- followUpEnabled: to,
3799
- followUpHandler: no,
3800
- agentRowTinted: !!se?.agentBubbleBg,
3801
- agentRowTextTinted: !!se?.agentBubbleText,
3818
+ function fo(r) {
3819
+ const l = L[r];
3820
+ return n ? la(l, {
3821
+ isLast: r === L.length - 1,
3822
+ followUpEnabled: oo,
3823
+ followUpHandler: io,
3824
+ agentRowTinted: !!ae?.agentBubbleBg,
3825
+ agentRowTextTinted: !!ae?.agentBubbleText,
3802
3826
  labels: D,
3803
- actionsRow: oo(l),
3804
- renderToolCall: co
3805
- }) : Kr(l, {
3806
- ...ji(r),
3807
- renderToolCall: co
3827
+ actionsRow: ro(l),
3828
+ renderToolCall: uo
3829
+ }) : Qr(l, {
3830
+ ...Wi(r),
3831
+ renderToolCall: uo
3808
3832
  });
3809
3833
  }
3810
- function ji(r) {
3811
- const l = F.length - 1;
3834
+ function Wi(r) {
3835
+ const l = L.length - 1;
3812
3836
  return {
3813
3837
  isLast: r === l,
3814
- isLastOfBlock: r === l || F[r + 1].role !== F[r].role,
3815
- bubbleStyle: L,
3816
- showAgentName: h,
3817
- agentBubble: E,
3818
- followUpEnabled: to,
3819
- followUpHandler: no,
3838
+ isLastOfBlock: r === l || L[r + 1].role !== L[r].role,
3839
+ bubbleStyle: N,
3840
+ showAgentName: m,
3841
+ agentBubble: k,
3842
+ followUpEnabled: oo,
3843
+ followUpHandler: io,
3820
3844
  isMobile: !!ce?.matches,
3821
- feedbackRow: oo(F[r])
3845
+ feedbackRow: ro(L[r])
3822
3846
  };
3823
3847
  }
3824
- function Wi() {
3825
- if (Ae || pt.length > 0) return !1;
3826
- const r = F.length - 1, l = F[r];
3848
+ function Ui() {
3849
+ if (Ae || ut.length > 0) return !1;
3850
+ const r = L.length - 1, l = L[r];
3827
3851
  if (!l || l.role !== "assistant") return !1;
3828
- const g = It[r];
3829
- if (!g || g.parentNode !== xe) return !1;
3830
- const y = po(r), T = document.activeElement, M = T instanceof HTMLElement && g.contains(T) ? T : null;
3831
- return Jn(() => xe.replaceChild(y, g)), M && y.contains(M) && M.focus({ preventScroll: !0 }), It[r] = y, !0;
3852
+ const h = Rt[r];
3853
+ if (!h || h.parentNode !== ye) return !1;
3854
+ const C = fo(r), T = document.activeElement, M = T instanceof HTMLElement && h.contains(T) ? T : null;
3855
+ return to(() => ye.replaceChild(C, h)), M && C.contains(M) && M.focus({ preventScroll: !0 }), Rt[r] = C, !0;
3832
3856
  }
3833
3857
  function X() {
3834
- Jn(Ui);
3835
- const r = F[F.length - 1], l = he && r?.role === "assistant" && (r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT");
3836
- te.setAttribute("aria-busy", l ? "true" : "false"), Ri(l), Mi();
3858
+ to(Pi);
3859
+ const r = L[L.length - 1], l = be && r?.role === "assistant" && (r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT");
3860
+ te.setAttribute("aria-busy", l ? "true" : "false"), zi(l), ji();
3837
3861
  }
3838
- function Ui() {
3839
- if (xe.replaceChildren(), It = [], F.length === 0) {
3862
+ function Pi() {
3863
+ if (ye.replaceChildren(), Rt = [], L.length === 0) {
3840
3864
  if (n) {
3841
- if (xt) {
3865
+ if (yt) {
3842
3866
  const r = d({
3843
3867
  display: "flex",
3844
3868
  justifyContent: "center",
@@ -3852,30 +3876,30 @@ function us(t, e) {
3852
3876
  borderBottom: "2px solid var(--ago-brand-color, #03182f)",
3853
3877
  animation: "ago-spin 1s linear infinite"
3854
3878
  });
3855
- l.setAttribute("role", "status"), r.appendChild(l), xe.appendChild(r);
3879
+ l.setAttribute("role", "status"), r.appendChild(l), ye.appendChild(r);
3856
3880
  }
3857
- } else if (Xn === "static") {
3881
+ } else if (Yn === "static") {
3858
3882
  const r = d({
3859
3883
  textAlign: "center",
3860
- color: rt,
3884
+ color: st,
3861
3885
  padding: "24px 16px",
3862
3886
  fontSize: "16px",
3863
3887
  lineHeight: "1.5"
3864
3888
  });
3865
- r.appendChild(lt(rn)), xe.appendChild(r);
3889
+ r.appendChild(Ye(an)), ye.appendChild(r);
3866
3890
  }
3867
- } else F.forEach((r, l) => {
3868
- const g = po(l);
3869
- It[l] = g, xe.appendChild(g);
3891
+ } else L.forEach((r, l) => {
3892
+ const h = fo(l);
3893
+ Rt[l] = h, ye.appendChild(h);
3870
3894
  });
3871
- for (const r of pt) xe.appendChild(Yr(r ?? s.common.formSubmitted));
3872
- if (Ne && St()) {
3873
- const r = qo(D.errorTitle, "");
3874
- r.classList.add("ago-ticket-form-config-error"), xe.appendChild(r);
3895
+ for (const r of ut) ye.appendChild(Zr(r ?? s.common.formSubmitted));
3896
+ if (Ne && _t()) {
3897
+ const r = Go(D.errorTitle, "");
3898
+ r.classList.add("ago-ticket-form-config-error"), ye.appendChild(r);
3875
3899
  }
3876
3900
  if (Ae) {
3877
3901
  if (n) {
3878
- xe.appendChild(qo(D.errorTitle, Ae));
3902
+ ye.appendChild(Go(D.errorTitle, Ae));
3879
3903
  return;
3880
3904
  }
3881
3905
  const r = d({
@@ -3887,36 +3911,36 @@ function us(t, e) {
3887
3911
  fontSize: "13px",
3888
3912
  border: "1px solid #fecaca"
3889
3913
  });
3890
- r.setAttribute("role", "alert"), r.textContent = Ae, xe.appendChild(r);
3914
+ r.setAttribute("role", "alert"), r.textContent = Ae, ye.appendChild(r);
3891
3915
  }
3892
3916
  }
3893
- function wn() {
3894
- for (let r = F.length - 1; r >= 0; r--) {
3895
- const l = F[r];
3917
+ function vn() {
3918
+ for (let r = L.length - 1; r >= 0; r--) {
3919
+ const l = L[r];
3896
3920
  if (l.role === "assistant" && (l.status === "IN_PROGRESS" || l.status === "WAITING_CLIENT")) return l;
3897
3921
  }
3898
3922
  }
3899
- const uo = (r) => {
3923
+ const mo = (r) => {
3900
3924
  J || (J = r.conversationId);
3901
- }, fo = (r) => {
3902
- const l = wn();
3903
- l && (l.content += r.content, Wi() || X());
3904
- }, mo = (r) => {
3905
- const l = F.findIndex((g) => g.id === r.id || g.role === "assistant" && g.status === "IN_PROGRESS");
3906
- l >= 0 ? F[l] = r : F.push(r), X(), Tt() || Rt();
3907
3925
  }, go = (r) => {
3908
- const l = F.findIndex((g) => g.id === r.id || g.role === "assistant" && g.status === "IN_PROGRESS");
3909
- l >= 0 ? F[l] = r : F.push(r), he = !1, X(), r.status === "DONE" && v?.({
3926
+ const l = vn();
3927
+ l && (l.content += r.content, Ui() || X());
3928
+ }, ho = (r) => {
3929
+ const l = L.findIndex((h) => h.id === r.id || h.role === "assistant" && h.status === "IN_PROGRESS");
3930
+ l >= 0 ? L[l] = r : L.push(r), X(), At() || zt();
3931
+ }, bo = (r) => {
3932
+ const l = L.findIndex((h) => h.id === r.id || h.role === "assistant" && h.status === "IN_PROGRESS");
3933
+ l >= 0 ? L[l] = r : L.push(r), be = !1, X(), r.status === "DONE" && E?.({
3910
3934
  id: r.id,
3911
3935
  content: r.content
3912
3936
  });
3913
- }, ho = () => {
3914
- const r = wn();
3915
- r && (r.content ? r.status = "CANCELED" : F = F.filter((l) => l !== r)), he = !1, X();
3916
- }, bo = (r) => {
3917
- Ae = r.error, he = !1, F = F.filter((l) => !l.id.startsWith("temp-")), X();
3937
+ }, xo = () => {
3938
+ const r = vn();
3939
+ r && (r.content ? r.status = "CANCELED" : L = L.filter((l) => l !== r)), be = !1, X();
3940
+ }, yo = (r) => {
3941
+ Ae = r.error, be = !1, L = L.filter((l) => !l.id.startsWith("temp-")), X();
3918
3942
  };
3919
- function Pi(r) {
3943
+ function Vi(r) {
3920
3944
  const l = {
3921
3945
  id: `ago-intro-${Date.now()}`,
3922
3946
  conversationId: "",
@@ -3925,139 +3949,139 @@ function us(t, e) {
3925
3949
  status: "IN_PROGRESS",
3926
3950
  createdAt: /* @__PURE__ */ new Date()
3927
3951
  };
3928
- F.push(l), X();
3929
- const g = r.match(/\S+\s*/g) ?? [r];
3930
- let y = 0;
3952
+ L.push(l), X();
3953
+ const h = r.match(/\S+\s*/g) ?? [r];
3954
+ let C = 0;
3931
3955
  ze = setInterval(() => {
3932
- if (y >= g.length) {
3933
- clearInterval(ze), ze = void 0, l.status = "DONE", Kn && (l.followUpReplies = Kn), X();
3956
+ if (C >= h.length) {
3957
+ clearInterval(ze), ze = void 0, l.status = "DONE", Qn && (l.followUpReplies = Qn), X();
3934
3958
  return;
3935
3959
  }
3936
- l.content += g[y], y++, X();
3937
- }, _i);
3960
+ l.content += h[C], C++, X();
3961
+ }, Ti);
3938
3962
  }
3939
- const xo = (r) => {
3940
- const l = ke.find((g) => g.id === r.conversationId);
3941
- l && (l.title = r.title), n && pe === "history" && We?.render({
3963
+ const Co = (r) => {
3964
+ const l = ke.find((h) => h.id === r.conversationId);
3965
+ l && (l.title = r.title), n && ue === "history" && Ue?.render({
3942
3966
  threads: ke,
3943
- loading: bt
3967
+ loading: xt
3944
3968
  });
3945
- }, yo = (r) => {
3969
+ }, wo = (r) => {
3946
3970
  if (r.type !== "form") return;
3947
- const l = wn() ?? [...F].reverse().find((T) => T.role === "assistant");
3971
+ const l = vn() ?? [...L].reverse().find((T) => T.role === "assistant");
3948
3972
  if (!l) return;
3949
- const g = l.toolCalls ?? [], y = g.findIndex((T) => T.id === r.id);
3950
- y >= 0 ? g[y] = r : g.push(r), l.toolCalls = g, X();
3973
+ const h = l.toolCalls ?? [], C = h.findIndex((T) => T.id === r.id);
3974
+ C >= 0 ? h[C] = r : h.push(r), l.toolCalls = h, X();
3951
3975
  };
3952
- i.on("config:changed", so), window.addEventListener("online", Wt), window.addEventListener("focus", Wt), i.on("message:start", uo), i.on("message:chunk", fo), i.on("message:answer-complete", mo), i.on("message:complete", go), i.on("message:stopped", ho), i.on("message:error", bo), i.on("conversation:title", xo), i.on("toolCall:received", yo);
3953
- const Co = (r) => k?.(r), wo = (r) => I?.(r), vo = (r) => O?.(r);
3954
- k && i.on("form:submitting", Co), I && i.on("form:submitted", wo), O && i.on("form:error", vo);
3955
- const vn = [];
3956
- let Eo = !1;
3957
- const ko = (r) => {
3958
- if (Eo) return;
3959
- vn.push(r.install(i));
3976
+ i.on("config:changed", co), window.addEventListener("online", Ut), window.addEventListener("focus", Ut), i.on("message:start", mo), i.on("message:chunk", go), i.on("message:answer-complete", ho), i.on("message:complete", bo), i.on("message:stopped", xo), i.on("message:error", yo), i.on("conversation:title", Co), i.on("toolCall:received", wo);
3977
+ const vo = (r) => S?.(r), Eo = (r) => R?.(r), ko = (r) => H?.(r);
3978
+ S && i.on("form:submitting", vo), R && i.on("form:submitted", Eo), H && i.on("form:error", ko);
3979
+ const En = [];
3980
+ let So = !1;
3981
+ const _o = (r) => {
3982
+ if (So) return;
3983
+ En.push(r.install(i));
3960
3984
  let l = r.store.get().submitted;
3961
- const g = r.store.subscribe((y) => {
3962
- y.submitted && !l && (pt.push(Ni(y.submitResult)), X()), l = y.submitted;
3985
+ const h = r.store.subscribe((C) => {
3986
+ C.submitted && !l && (ut.push(Ii(C.submitResult)), X()), l = C.submitted;
3963
3987
  });
3964
- vn.push(g);
3988
+ En.push(h);
3965
3989
  };
3966
- for (const r of N ?? []) r.schema != null ? ko(sr(r)) : ar(i, r).then((l) => ko(l)).catch(() => {
3990
+ for (const r of I ?? []) r.schema != null ? _o(lr(r)) : sr(i, r).then((l) => _o(l)).catch(() => {
3967
3991
  });
3968
- async function et(r, l, g) {
3969
- const y = r.trim();
3970
- if (!y || he) return;
3971
- if (n && pe !== "chat" && (Bt = "home", De("chat", { byUser: !0 })), z?.(y), he = !0, Ae = null, Ne = !1, Oe = !0, ze) {
3992
+ async function nt(r, l, h) {
3993
+ const C = r.trim();
3994
+ if (!C || be) return;
3995
+ if (n && ue !== "chat" && ($t = "home", De("chat", { byUser: !0 })), O?.(C), be = !0, Ae = null, Ne = !1, Oe = !0, ze) {
3972
3996
  clearInterval(ze), ze = void 0;
3973
- const M = F.find((V) => V.id.startsWith("ago-intro-"));
3974
- M && !M.content ? F = F.filter((V) => V !== M) : M && (M.status = "DONE");
3997
+ const M = L.find((V) => V.id.startsWith("ago-intro-"));
3998
+ M && !M.content ? L = L.filter((V) => V !== M) : M && (M.status = "DONE");
3975
3999
  }
3976
4000
  const T = Date.now();
3977
- F.push({
4001
+ L.push({
3978
4002
  id: `temp-user-${T}`,
3979
4003
  conversationId: J || "",
3980
- content: y,
4004
+ content: C,
3981
4005
  role: "user",
3982
4006
  status: "DONE",
3983
- attachments: l && l.length > 0 ? tr(l) : void 0,
4007
+ attachments: l && l.length > 0 ? nr(l) : void 0,
3984
4008
  createdAt: /* @__PURE__ */ new Date()
3985
- }), F.push({
4009
+ }), L.push({
3986
4010
  id: `temp-assistant-${T}`,
3987
4011
  conversationId: J || "",
3988
4012
  content: "",
3989
4013
  role: "assistant",
3990
4014
  status: "IN_PROGRESS",
3991
4015
  createdAt: /* @__PURE__ */ new Date()
3992
- }), X(), p || Zn();
4016
+ }), X(), p || eo();
3993
4017
  try {
3994
- const M = await i.sendMessage(y, {
4018
+ const M = await i.sendMessage(C, {
3995
4019
  conversationId: J,
3996
4020
  files: l,
3997
- ...g?.agentId ? { agentId: g.agentId } : {}
4021
+ ...h?.agentId ? { agentId: h.agentId } : {}
3998
4022
  });
3999
- M.conversationId && (J || (J = M.conversationId), Ye?.setActiveThread(M.conversationId, M.createdAt));
4000
- const V = F.find((Z) => Z.id === `temp-user-${T}`);
4001
- if (V && (V.id = `user-${T}`, V.conversationId = M.conversationId), M.id && !F.some((Z) => Z.id === M.id)) {
4002
- const Z = F.findIndex((Fn) => Fn.id === `temp-assistant-${T}`);
4003
- Z >= 0 ? F[Z] = M : F.push(M);
4023
+ M.conversationId && (J || (J = M.conversationId), Ze?.setActiveThread(M.conversationId, M.createdAt));
4024
+ const V = L.find((Z) => Z.id === `temp-user-${T}`);
4025
+ if (V && (V.id = `user-${T}`, V.conversationId = M.conversationId), M.id && !L.some((Z) => Z.id === M.id)) {
4026
+ const Z = L.findIndex((Ln) => Ln.id === `temp-assistant-${T}`);
4027
+ Z >= 0 ? L[Z] = M : L.push(M);
4004
4028
  }
4005
- F = F.filter((Z) => !Z.id.startsWith("temp-")), M.status !== "WAITING_CLIENT" && (he = !1), X(), H && En();
4029
+ L = L.filter((Z) => !Z.id.startsWith("temp-")), M.status !== "WAITING_CLIENT" && (be = !1), X(), B && kn();
4006
4030
  } catch (M) {
4007
- Ae = M instanceof Error ? M.message : s.common.sendFailed, he = !1, F = F.filter((V) => !V.id.startsWith("temp-")), zi(y, l), X();
4031
+ Ae = M instanceof Error ? M.message : s.common.sendFailed, be = !1, L = L.filter((V) => !V.id.startsWith("temp-")), Oi(C, l), X();
4008
4032
  }
4009
4033
  }
4010
- async function Pt() {
4011
- he && await i.stop();
4034
+ async function Vt() {
4035
+ be && await i.stop();
4012
4036
  }
4013
- async function En() {
4037
+ async function kn() {
4014
4038
  try {
4015
4039
  const { data: r } = await i.getConversations();
4016
4040
  ke.splice(0, ke.length, ...r);
4017
4041
  } catch {
4018
4042
  }
4019
- return bt = !1, n && !re && (pe === "history" && We?.render({
4043
+ return xt = !1, n && !re && (ue === "history" && Ue?.render({
4020
4044
  threads: ke,
4021
4045
  loading: !1
4022
- }), Vi()), ke;
4046
+ }), qi()), ke;
4023
4047
  }
4024
- async function So(r) {
4048
+ async function To(r) {
4025
4049
  Ne = !1;
4026
4050
  try {
4027
4051
  const l = await i.getConversation(r);
4028
4052
  if (J !== r) return;
4029
- const g = l?.messages ?? [];
4030
- xt = !1, g.length > 0 && F.length === 0 ? (F = g, X()) : n && X(), n && Ye?.setActiveThread(r, l.lastMessageDate);
4053
+ const h = l?.messages ?? [];
4054
+ yt = !1, h.length > 0 && L.length === 0 ? (L = h, X()) : n && X(), n && Ze?.setActiveThread(r, l.lastMessageDate);
4031
4055
  } catch {
4032
4056
  if (J !== r) return;
4033
- xt = !1, F.length === 0 && (Ye?.clear(), J = void 0, n && (pe === "chat" && De("home"), X()));
4057
+ yt = !1, L.length === 0 && (Ze?.clear(), J = void 0, n && (ue === "chat" && De("home"), X()));
4034
4058
  }
4035
4059
  }
4036
4060
  function De(r, l) {
4037
- if (!n || !ht || !Fe || !Ht || !We) return;
4038
- l?.byUser && (Ze = !0), pe !== r && ut(), pe = r, r === "home" ? (Fe.composerSlot.appendChild(Se), gn(oe)) : r === "chat" && (Ht.composerSlot.appendChild(Se), gn(""));
4039
- const g = r === "home" ? Fe.el : r === "chat" ? Ht.el : We.el;
4040
- ht.replaceChildren(g), r === "history" && We.render({
4061
+ if (!n || !bt || !Fe || !Bt || !Ue) return;
4062
+ l?.byUser && (et = !0), ue !== r && ft(), ue = r, r === "home" ? (Fe.composerSlot.appendChild(Se), hn(oe)) : r === "chat" && (Bt.composerSlot.appendChild(Se), hn(""));
4063
+ const h = r === "home" ? Fe.el : r === "chat" ? Bt.el : Ue.el;
4064
+ bt.replaceChildren(h), r === "history" && Ue.render({
4041
4065
  threads: ke,
4042
- loading: bt
4043
- }), r === "chat" && (Oe = !0, fn()), Ot?.update({ screen: r }), gt?.setActive(r), gt?.setVisible(r !== "chat");
4066
+ loading: xt
4067
+ }), r === "chat" && (Oe = !0, mn()), Ht?.update({ screen: r }), ht?.setActive(r), ht?.setVisible(r !== "chat");
4044
4068
  }
4045
- async function _t(r) {
4046
- n && (ut(), he && await Pt(), J = r, F = [], Ae = null, pt.length = 0, Dt.clear(), Ut(), xt = !0, De("chat"), X(), await So(r));
4069
+ async function Tt(r) {
4070
+ n && (ft(), be && await Vt(), J = r, L = [], Ae = null, ut.length = 0, Mt.clear(), Pt(), yt = !0, De("chat"), X(), await To(r));
4047
4071
  }
4048
- function Vt() {
4049
- he && Pt(), J = void 0, F = [], Ae = null, pt.length = 0, Dt.clear(), Ut(), xt = !1, Ye?.clear(), Oi(), Fe?.setPending(null), Bt = "home", n && De("home", { byUser: !0 }), X();
4072
+ function qt() {
4073
+ be && Vt(), J = void 0, L = [], Ae = null, ut.length = 0, Mt.clear(), Pt(), yt = !1, Ze?.clear(), Hi(), Fe?.setPending(null), $t = "home", n && De("home", { byUser: !0 }), X();
4050
4074
  }
4051
- function Vi() {
4052
- if (!n || yt) return;
4053
- if (yt = !0, !K || Ze || pe !== "home" || F.length > 0 || J) {
4054
- qt();
4075
+ function qi() {
4076
+ if (!n || Ct) return;
4077
+ if (Ct = !0, !K || et || ue !== "home" || L.length > 0 || J) {
4078
+ Gt();
4055
4079
  return;
4056
4080
  }
4057
- const r = Pa(ke);
4058
- r && _t(r.id), qt();
4081
+ const r = qa(ke);
4082
+ r && Tt(r.id), Gt();
4059
4083
  }
4060
- async function qi() {
4084
+ async function Gi() {
4061
4085
  let r;
4062
4086
  try {
4063
4087
  r = (await i.getConfig()).permissions[0]?.homePage;
@@ -4072,86 +4096,86 @@ function us(t, e) {
4072
4096
  message: l.message,
4073
4097
  agentId: l.agentId
4074
4098
  })) : void 0
4075
- }), r.widgetStarter && (hn = r.widgetStarter, qt()));
4099
+ }), r.widgetStarter && (bn = r.widgetStarter, Gt()));
4076
4100
  }
4077
- function qt() {
4078
- const r = hn;
4079
- !r || re || ie && (bt && !yt || (hn = void 0, !(Ze || J || F.length > 0 || he || pe !== "home") && et(r.message, void 0, { agentId: r.agentId })));
4101
+ function Gt() {
4102
+ const r = bn;
4103
+ !r || re || ie && (xt && !Ct || (bn = void 0, !(et || J || L.length > 0 || be || ue !== "home") && nt(r.message, void 0, { agentId: r.agentId })));
4080
4104
  }
4081
- function _o() {
4082
- Ue = void 0, !(re || ie || me === !1 || de) && (de = Ga({
4083
- text: me,
4105
+ function Ao() {
4106
+ Pe = void 0, !(re || ie || ge === !1 || de) && (de = Ka({
4107
+ text: ge,
4084
4108
  dismissLabel: D.dismiss,
4085
- edge: mt,
4086
- onOpen: () => Xt(),
4109
+ edge: gt,
4110
+ onOpen: () => Kt(),
4087
4111
  onDismiss: () => {
4088
4112
  de = void 0;
4089
4113
  }
4090
- }), an.appendChild(de.el), kn());
4114
+ }), sn.appendChild(de.el), Sn());
4091
4115
  }
4092
- function kn() {
4093
- if (!n || !U || !ye || Tt() || !ye.offsetHeight) return;
4094
- const r = getComputedStyle(ye), l = parseFloat(r.bottom), g = parseFloat(r.right);
4095
- if (Number.isNaN(l) || Number.isNaN(g)) return;
4096
- const y = Math.round(l + ye.offsetHeight) + Ya, T = Math.round(g), M = [U];
4116
+ function Sn() {
4117
+ if (!n || !U || !pe || At() || !pe.offsetHeight) return;
4118
+ const r = getComputedStyle(pe), l = parseFloat(r.bottom), h = parseFloat(r.right);
4119
+ if (Number.isNaN(l) || Number.isNaN(h)) return;
4120
+ const C = Math.round(l + pe.offsetHeight) + Za, T = Math.round(h), M = [U];
4097
4121
  de && M.push(de.el);
4098
4122
  for (const V of M)
4099
- V.style.setProperty("bottom", `${y}px`, "important"), V.style.setProperty("right", `${T}px`, "important");
4100
- U.style.setProperty("top", `max(40px, calc(100% - ${y + Qa}px))`, "important"), U.style.setProperty("--ago-panel-max", `calc(100% - ${T + 20}px)`);
4123
+ V.style.setProperty("bottom", `${C}px`, "important"), V.style.setProperty("right", `${T}px`, "important");
4124
+ U.style.setProperty("top", `max(40px, calc(100% - ${C + Ja}px))`, "important"), U.style.setProperty("--ago-panel-max", `calc(100% - ${T + 20}px)`);
4101
4125
  }
4102
- function To(r) {
4103
- r.key !== "Escape" || !ie || r.defaultPrevented || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement || Sn() || tt();
4126
+ function Fo(r) {
4127
+ r.key !== "Escape" || !ie || r.defaultPrevented || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement || _n() || ot();
4104
4128
  }
4105
- function Ao() {
4106
- Qe && clearTimeout(Qe), Qe = setTimeout(() => {
4107
- Qe = void 0, !re && (kn(), Fe?.syncColumns());
4129
+ function Lo() {
4130
+ Je && clearTimeout(Je), Je = setTimeout(() => {
4131
+ Je = void 0, !re && (Sn(), Fe?.syncColumns());
4108
4132
  }, 150);
4109
4133
  }
4110
- n ? (De("home"), X(), ee && qi(), e.conversationId ? (Ze = !0, yt = !0, _t(e.conversationId)) : J && K ? (yt = !0, _t(J)) : J = void 0) : (X(), ct && ce?.matches || Rt(), J ? So(J) : Xn === "streaming" && Pi(rn)), H && En();
4111
- const Fo = {
4134
+ n ? (De("home"), X(), ee && Gi(), e.conversationId ? (et = !0, Ct = !0, Tt(e.conversationId)) : J && K ? (Ct = !0, Tt(J)) : J = void 0) : (X(), dt && ce?.matches || zt(), J ? To(J) : Yn === "streaming" && Vi(an)), B && kn();
4135
+ const No = {
4112
4136
  client: i,
4113
- element: ft,
4114
- sendMessage: et,
4115
- stop: Pt,
4116
- ...ge || ct ? {
4117
- open: Gi,
4118
- close: Xi,
4119
- toggle: Ki
4137
+ element: mt,
4138
+ sendMessage: nt,
4139
+ stop: Vt,
4140
+ ...he || dt ? {
4141
+ open: Xi,
4142
+ close: Ki,
4143
+ toggle: Yi
4120
4144
  } : {},
4121
- newConversation: Vt,
4145
+ newConversation: qt,
4122
4146
  ...n ? {
4123
4147
  showScreen: (r) => De(r, { byUser: !0 }),
4124
- openConversation: (r) => (Ze = !0, _t(r))
4148
+ openConversation: (r) => (et = !0, Tt(r))
4125
4149
  } : {},
4126
- session: Ye,
4150
+ session: Ze,
4127
4151
  threads: ke,
4128
- refreshThreads: En,
4152
+ refreshThreads: kn,
4129
4153
  destroy() {
4130
- re || (re = !0, $i(), ze && clearInterval(ze), Ue && clearTimeout(Ue), Qe && clearTimeout(Qe), de?.remove(), i.off("config:changed", so), window.removeEventListener("online", Wt), window.removeEventListener("focus", Wt), i.off("message:start", uo), i.off("message:chunk", fo), i.off("message:answer-complete", mo), i.off("message:complete", go), i.off("message:stopped", ho), i.off("message:error", bo), i.off("conversation:title", xo), i.off("toolCall:received", yo), Ut(), k && i.off("form:submitting", Co), I && i.off("form:submitted", wo), O && i.off("form:error", vo), Eo = !0, vn.forEach((r) => r()), ft.remove(), ye?.remove(), ue?.remove(), document.removeEventListener("keydown", To), window.removeEventListener("resize", Ao), vt?.remove(), Be?.remove(), ce?.removeEventListener("change", Ro), document.removeEventListener("keydown", Io), An(), sn = !1, Ln(dt), e.client || i.destroy());
4154
+ re || (re = !0, Di(), ze && clearInterval(ze), Pe && clearTimeout(Pe), Je && clearTimeout(Je), de?.remove(), i.off("config:changed", co), window.removeEventListener("online", Ut), window.removeEventListener("focus", Ut), i.off("message:start", mo), i.off("message:chunk", go), i.off("message:answer-complete", ho), i.off("message:complete", bo), i.off("message:stopped", xo), i.off("message:error", yo), i.off("conversation:title", Co), i.off("toolCall:received", wo), Pt(), S && i.off("form:submitting", vo), R && i.off("form:submitted", Eo), H && i.off("form:error", ko), So = !0, En.forEach((r) => r()), mt.remove(), pe?.remove(), fe?.remove(), document.removeEventListener("keydown", Fo), window.removeEventListener("resize", Lo), Et?.remove(), Be?.remove(), ce?.removeEventListener("change", Oo), document.removeEventListener("keydown", zo), Fn(), ln = !1, Nn(pt), e.client || i.destroy());
4131
4155
  }
4132
4156
  };
4133
- return n && Object.defineProperty(Fo, "screen", {
4134
- get: () => pe,
4157
+ return n && Object.defineProperty(No, "screen", {
4158
+ get: () => ue,
4135
4159
  enumerable: !0
4136
- }), Fo;
4137
- function Gt() {
4160
+ }), No;
4161
+ function Xt() {
4138
4162
  if (!U) return;
4139
- if (n) Lo();
4163
+ if (n) Io();
4140
4164
  else {
4141
- const l = mt === "left" ? "border-right" : "border-left";
4142
- ce?.matches ? (U.style.width = "100%", A.style.borderRadius = "0", A.style.removeProperty(l)) : (U.style.width = typeof f == "number" ? `${f}px` : f, A.style.setProperty(l, `1px solid ${Q}`));
4143
- const g = o === "left" ? "translateX(-100%)" : "translateX(100%)";
4144
- U.style.transform = ie ? "translateX(0)" : g, ye && (ye.style.display = ie ? "none" : "flex");
4165
+ const l = gt === "left" ? "border-right" : "border-left";
4166
+ ce?.matches ? (U.style.width = "100%", A.style.borderRadius = "0", A.style.removeProperty(l)) : (U.style.width = typeof g == "number" ? `${g}px` : g, A.style.setProperty(l, `1px solid ${Q}`));
4167
+ const h = o === "left" ? "translateX(-100%)" : "translateX(100%)";
4168
+ U.style.transform = ie ? "translateX(0)" : h, pe && (pe.style.display = ie ? "none" : "flex");
4145
4169
  }
4146
4170
  U.setAttribute("aria-hidden", ie ? "false" : "true");
4147
- const r = Sn();
4148
- r !== sn && (sn = r, r ? (A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), A.tabIndex = -1, A.style.paddingBottom = "env(safe-area-inset-bottom)", jo(dt), He = _n(), Tn(), zo()) : (An(), Qi(), He = 0, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), A.style.removeProperty("padding-bottom"), Ln(dt)));
4171
+ const r = _n();
4172
+ r !== ln && (ln = r, r ? (A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), A.tabIndex = -1, A.style.paddingBottom = "env(safe-area-inset-bottom)", Wo(pt), He = Tn(), An(), Ho()) : (Fn(), Zi(), He = 0, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), A.style.removeProperty("padding-bottom"), Nn(pt)));
4149
4173
  }
4150
- function Lo() {
4174
+ function Io() {
4151
4175
  if (!U) return;
4152
- U.style.display = ie ? "block" : "none", Ct.open = s.common.openTitle.replace("{title}", () => Y), Ct.close = s.common.closeTitle.replace("{title}", () => Y), zt?.setOpen(ie);
4153
- const r = Tt();
4154
- if (ye && (ye.style.display = r && ie ? "none" : "flex"), r) {
4176
+ U.style.display = ie ? "block" : "none", wt.open = s.common.openTitle.replace("{title}", () => Y), wt.close = s.common.closeTitle.replace("{title}", () => Y), Ot?.setOpen(ie);
4177
+ const r = At();
4178
+ if (pe && (pe.style.display = r && ie ? "none" : "flex"), r) {
4155
4179
  for (const l of [
4156
4180
  "bottom",
4157
4181
  "right",
@@ -4186,95 +4210,95 @@ function us(t, e) {
4186
4210
  right: "20px",
4187
4211
  bottom: "80px",
4188
4212
  top: "max(40px, calc(100% - 880px))",
4189
- width: `min(max(400px, ${$o}), var(--ago-panel-max, calc(100% - 40px)))`,
4213
+ width: `min(max(400px, ${Mo}), var(--ago-panel-max, calc(100% - 40px)))`,
4190
4214
  height: "auto",
4191
4215
  borderRadius: "16px"
4192
- }), U.dataset.agoLayout = "panel", kn();
4216
+ }), U.dataset.agoLayout = "panel", Sn();
4193
4217
  }
4194
4218
  }
4195
- function Xt() {
4196
- ie = !0, Ue && (clearTimeout(Ue), Ue = void 0), de?.remove(), de = void 0, Gt(), Tt() ? A.focus({ preventScroll: !0 }) : Rt(), qt(), $?.();
4197
- }
4198
- function tt() {
4199
- ut(), ie = !1, Gt(), W?.();
4219
+ function Kt() {
4220
+ ie = !0, Pe && (clearTimeout(Pe), Pe = void 0), de?.remove(), de = void 0, Xt(), At() ? A.focus({ preventScroll: !0 }) : zt(), Gt(), $?.();
4200
4221
  }
4201
- function No() {
4202
- ie ? tt() : Xt();
4222
+ function ot() {
4223
+ ft(), ie = !1, Xt(), W?.();
4203
4224
  }
4204
- function Gi() {
4205
- ge ? Xt() : At();
4225
+ function Ro() {
4226
+ ie ? ot() : Kt();
4206
4227
  }
4207
4228
  function Xi() {
4208
- ut(), ge ? tt() : Ft();
4229
+ he ? Kt() : Ft();
4209
4230
  }
4210
4231
  function Ki() {
4211
- ge ? No() : Le ? Ft() : At();
4232
+ ft(), he ? ot() : Lt();
4233
+ }
4234
+ function Yi() {
4235
+ he ? Ro() : Le ? Lt() : Ft();
4212
4236
  }
4213
- function Tt() {
4237
+ function At() {
4214
4238
  return !!ce?.matches;
4215
4239
  }
4216
- function Sn() {
4217
- return Tt() && (ge ? ie : Le);
4240
+ function _n() {
4241
+ return At() && (he ? ie : Le);
4218
4242
  }
4219
- function Yi() {
4243
+ function Qi() {
4220
4244
  return Array.from(A.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((r) => r.getClientRects().length > 0);
4221
4245
  }
4222
- function Io(r) {
4223
- if (!Sn()) return;
4246
+ function zo(r) {
4247
+ if (!_n()) return;
4224
4248
  if (r.key === "Escape") {
4225
- ge ? tt() : Ft();
4249
+ he ? ot() : Lt();
4226
4250
  return;
4227
4251
  }
4228
4252
  if (r.key !== "Tab") return;
4229
- const l = Yi();
4253
+ const l = Qi();
4230
4254
  if (l.length === 0) {
4231
4255
  r.preventDefault();
4232
4256
  return;
4233
4257
  }
4234
- const g = l[0], y = l[l.length - 1], T = document.activeElement;
4235
- r.shiftKey && (T === g || !A.contains(T)) ? (r.preventDefault(), y.focus()) : !r.shiftKey && (T === y || !A.contains(T)) && (r.preventDefault(), g.focus());
4258
+ const h = l[0], C = l[l.length - 1], T = document.activeElement;
4259
+ r.shiftKey && (T === h || !A.contains(T)) ? (r.preventDefault(), C.focus()) : !r.shiftKey && (T === C || !A.contains(T)) && (r.preventDefault(), h.focus());
4236
4260
  }
4237
- function Ro(r) {
4238
- ge ? Gt() : !r.matches && Le && Ft(), X();
4261
+ function Oo(r) {
4262
+ he ? Xt() : !r.matches && Le && Lt(), X();
4239
4263
  }
4240
- function _n() {
4264
+ function Tn() {
4241
4265
  return window.visualViewport?.height ?? window.innerHeight;
4242
4266
  }
4243
- function Tn() {
4244
- const r = window.visualViewport, l = r?.offsetTop ?? 0, g = r?.height ?? He;
4245
- if (ge) {
4267
+ function An() {
4268
+ const r = window.visualViewport, l = r?.offsetTop ?? 0, h = r?.height ?? He;
4269
+ if (he) {
4246
4270
  if (!U) return;
4247
- const T = window.innerHeight || He, M = Math.max(0, T - (l + g));
4271
+ const T = window.innerHeight || He, M = Math.max(0, T - (l + h));
4248
4272
  U.style.bottom = `${M}px`, U.style.top = `${l}px`;
4249
4273
  return;
4250
4274
  }
4251
- const y = Math.min(0, l + g - He);
4252
- A.style.top = `${y}px`, ue && (ue.style.top = `${l}px`);
4275
+ const C = Math.min(0, l + h - He);
4276
+ A.style.top = `${C}px`, fe && (fe.style.top = `${l}px`);
4253
4277
  }
4254
- function Qi() {
4255
- ge && U && (U.style.removeProperty("bottom"), U.style.removeProperty("top"), n && !re && Lo());
4278
+ function Zi() {
4279
+ he && U && (U.style.removeProperty("bottom"), U.style.removeProperty("top"), n && !re && Io());
4256
4280
  }
4257
- function Kt() {
4258
- Je || (Je = requestAnimationFrame(() => {
4259
- Je = 0, !re && Tn();
4281
+ function Yt() {
4282
+ tt || (tt = requestAnimationFrame(() => {
4283
+ tt = 0, !re && An();
4260
4284
  }));
4261
4285
  }
4262
- function zo() {
4263
- window.visualViewport?.addEventListener("resize", Kt), window.visualViewport?.addEventListener("scroll", Kt);
4286
+ function Ho() {
4287
+ window.visualViewport?.addEventListener("resize", Yt), window.visualViewport?.addEventListener("scroll", Yt);
4264
4288
  }
4265
- function An() {
4266
- window.visualViewport?.removeEventListener("resize", Kt), window.visualViewport?.removeEventListener("scroll", Kt), Je && (cancelAnimationFrame(Je), Je = 0);
4289
+ function Fn() {
4290
+ window.visualViewport?.removeEventListener("resize", Yt), window.visualViewport?.removeEventListener("scroll", Yt), tt && (cancelAnimationFrame(tt), tt = 0);
4267
4291
  }
4268
- function Oo() {
4269
- Oe = !0, fn();
4292
+ function Bo() {
4293
+ Oe = !0, mn();
4270
4294
  }
4271
- function Zi() {
4295
+ function Ji() {
4272
4296
  const r = d({
4273
4297
  position: "fixed",
4274
4298
  top: "0",
4275
4299
  left: "0",
4276
4300
  right: "0",
4277
- height: `calc(${eo}px + env(safe-area-inset-top))`,
4301
+ height: `calc(${no}px + env(safe-area-inset-top))`,
4278
4302
  display: "none",
4279
4303
  alignItems: "center",
4280
4304
  justifyContent: "space-between",
@@ -4284,22 +4308,22 @@ function us(t, e) {
4284
4308
  zIndex: "2147483001",
4285
4309
  fontFamily: Re
4286
4310
  });
4287
- if (r.className = "ago-chat-widget-mobile-bar", _) {
4288
- const g = document.createElement("img");
4289
- g.src = _, g.alt = "", u(g, {
4311
+ if (r.className = "ago-chat-widget-mobile-bar", y) {
4312
+ const h = document.createElement("img");
4313
+ h.src = y, h.alt = "", u(h, {
4290
4314
  height: "28px",
4291
4315
  width: "auto"
4292
- }), r.appendChild(g);
4316
+ }), r.appendChild(h);
4293
4317
  } else if (Y) {
4294
- const g = document.createElement("span");
4295
- g.className = "ago-chat-widget__title", g.textContent = Y, u(g, {
4318
+ const h = document.createElement("span");
4319
+ h.className = "ago-chat-widget__title", h.textContent = Y, u(h, {
4296
4320
  fontSize: "15px",
4297
4321
  fontWeight: "600",
4298
4322
  color: ne,
4299
4323
  overflow: "hidden",
4300
4324
  whiteSpace: "nowrap",
4301
4325
  textOverflow: "ellipsis"
4302
- }), r.appendChild(g);
4326
+ }), r.appendChild(h);
4303
4327
  } else r.appendChild(d({}));
4304
4328
  const l = document.createElement("button");
4305
4329
  return l.type = "button", l.setAttribute("aria-label", s.common.close), l.textContent = "×", u(l, {
@@ -4318,24 +4342,24 @@ function us(t, e) {
4318
4342
  cursor: "pointer",
4319
4343
  padding: "0"
4320
4344
  }), l.addEventListener("click", () => {
4321
- Ft();
4345
+ Lt();
4322
4346
  }), r.appendChild(l), r;
4323
4347
  }
4324
- function Ji() {
4325
- return typeof document.startViewTransition == "function" && !Fi?.matches && !!ce?.matches;
4348
+ function er() {
4349
+ return typeof document.startViewTransition == "function" && !Li?.matches && !!ce?.matches;
4326
4350
  }
4327
- function Ho(r) {
4351
+ function $o(r) {
4328
4352
  const l = document;
4329
- if (Ji() && l.startViewTransition) {
4330
- A.style.setProperty("view-transition-name", wt), ue?.style.setProperty("view-transition-name", `${wt}-bar`);
4331
- const g = () => {
4332
- A.style.removeProperty("view-transition-name"), ue?.style.removeProperty("view-transition-name");
4353
+ if (er() && l.startViewTransition) {
4354
+ A.style.setProperty("view-transition-name", vt), fe?.style.setProperty("view-transition-name", `${vt}-bar`);
4355
+ const h = () => {
4356
+ A.style.removeProperty("view-transition-name"), fe?.style.removeProperty("view-transition-name");
4333
4357
  };
4334
- return l.startViewTransition(r).finished.then(g, g);
4358
+ return l.startViewTransition(r).finished.then(h, h);
4335
4359
  }
4336
4360
  return r(), Promise.resolve();
4337
4361
  }
4338
- function Bo(r) {
4362
+ function Do(r) {
4339
4363
  if (r)
4340
4364
  Be && A.parentElement?.insertBefore(Be, A), u(A, {
4341
4365
  position: "fixed",
@@ -4348,9 +4372,9 @@ function us(t, e) {
4348
4372
  border: "none",
4349
4373
  borderRadius: "0",
4350
4374
  boxShadow: "none",
4351
- paddingTop: `calc(${eo}px + env(safe-area-inset-top))`,
4375
+ paddingTop: `calc(${no}px + env(safe-area-inset-top))`,
4352
4376
  paddingBottom: "env(safe-area-inset-bottom)"
4353
- }), A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), be && (be.style.display = "none"), ue && (ue.style.display = "flex");
4377
+ }), A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), xe && (xe.style.display = "none"), fe && (fe.style.display = "flex");
4354
4378
  else {
4355
4379
  Be?.remove(), Be = void 0;
4356
4380
  for (const l of [
@@ -4363,40 +4387,40 @@ function us(t, e) {
4363
4387
  "padding-top",
4364
4388
  "padding-bottom"
4365
4389
  ]) A.style.removeProperty(l);
4366
- A.style.height = $t.height, A.style.border = $t.border, A.style.borderRadius = $t.borderRadius, A.style.boxShadow = $t.boxShadow, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), be && (be.style.display = "flex"), ue && (ue.style.display = "none");
4390
+ A.style.height = Dt.height, A.style.border = Dt.border, A.style.borderRadius = Dt.borderRadius, A.style.boxShadow = Dt.boxShadow, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), xe && (xe.style.display = "flex"), fe && (fe.style.display = "none");
4367
4391
  }
4368
4392
  }
4369
- function At() {
4393
+ function Ft() {
4370
4394
  if (re || Le || !ce?.matches) return Promise.resolve();
4371
4395
  const r = A.getBoundingClientRect();
4372
- if (r.height >= _n() * 0.8) return Promise.resolve();
4396
+ if (r.height >= Tn() * 0.8) return Promise.resolve();
4373
4397
  Le = !0, Be = d({
4374
4398
  width: `${r.width}px`,
4375
4399
  height: `${r.height}px`
4376
- }), Be.className = "ago-chat-widget-spacer", Be.setAttribute("aria-hidden", "true"), He = _n(), A.style.setProperty("--ago-vh", `${He}px`), Tn(), zo(), jo(dt);
4377
- const l = Ho(() => Bo(!0));
4400
+ }), Be.className = "ago-chat-widget-spacer", Be.setAttribute("aria-hidden", "true"), He = Tn(), A.style.setProperty("--ago-vh", `${He}px`), An(), Ho(), Wo(pt);
4401
+ const l = $o(() => Do(!0));
4378
4402
  return l.then(() => {
4379
- re || (Oo(), Rt());
4380
- }), Oo(), $?.(), l;
4403
+ re || (Bo(), zt());
4404
+ }), Bo(), $?.(), l;
4381
4405
  }
4382
- function Ft() {
4406
+ function Lt() {
4383
4407
  if (!Le) return Promise.resolve();
4384
- ut(), Le = !1, An(), Ln(dt), A.querySelector("textarea")?.blur();
4385
- const r = Ho(() => Bo(!1));
4408
+ ft(), Le = !1, Fn(), Nn(pt), A.querySelector("textarea")?.blur();
4409
+ const r = $o(() => Do(!1));
4386
4410
  return r.then(() => {
4387
4411
  re || A.style.removeProperty("--ago-vh");
4388
4412
  }), He = 0, W?.(), r;
4389
4413
  }
4390
4414
  }
4391
4415
  export {
4392
- ps as DEFAULT_FEEDBACK_LABELS,
4393
- cs as DEFAULT_SPEECH_TO_TEXT_LABELS,
4394
- ha as DEFAULT_TOOL_CALL_FORM_LABELS,
4395
- ds as DEFAULT_WIDGET_LABELS,
4396
- Nr as colorsToTheme,
4397
- ls as compactMediaQuery,
4398
- ss as createSheetController,
4399
- us as mountChatWidget,
4400
- Sr as readableTextColor,
4401
- lt as renderMarkdown
4416
+ fs as DEFAULT_FEEDBACK_LABELS,
4417
+ ps as DEFAULT_SPEECH_TO_TEXT_LABELS,
4418
+ xa as DEFAULT_TOOL_CALL_FORM_LABELS,
4419
+ us as DEFAULT_WIDGET_LABELS,
4420
+ Ir as colorsToTheme,
4421
+ ds as compactMediaQuery,
4422
+ cs as createSheetController,
4423
+ ms as mountChatWidget,
4424
+ _r as readableTextColor,
4425
+ Ye as renderMarkdown
4402
4426
  };