@useago/sdk 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +53 -6
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +89 -5
- package/dist/angular.d.ts +89 -5
- package/dist/angular.js +11 -7
- package/dist/{createConversationSession-Bgvx753t.js → createConversationSession-BaaXBQ5b.js} +3 -3
- package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
- package/dist/{createFormCollector-CM3qjGcM.js → createFormCollector-Cf7kGhCB.js} +1 -1
- package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
- package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
- package/dist/createMockClient-BZbOe-23.cjs +1 -0
- package/dist/devtools.cjs +61 -12
- package/dist/devtools.d.cts +90 -5
- package/dist/devtools.d.ts +90 -5
- package/dist/devtools.js +225 -73
- package/dist/errors-BLfjXnLB.js +32 -0
- package/dist/errors-o1IB5fEu.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +100 -3
- package/dist/index.d.ts +100 -3
- package/dist/index.js +77 -75
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +197 -3
- package/dist/react.d.ts +197 -3
- package/dist/react.js +1034 -752
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +80 -3
- package/dist/testing.d.ts +80 -3
- package/dist/testing.js +1 -1
- package/dist/{AgoClient-BJjLTOw4.js → types-CPga11Of.js} +489 -386
- package/dist/types-D3YQl1jx.cjs +9 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +110 -3
- package/dist/vue.d.ts +110 -3
- package/dist/vue.js +202 -154
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +148 -3
- package/dist/widget.d.ts +148 -3
- package/dist/widget.js +871 -651
- package/llms-full.txt +144 -30
- package/package.json +1 -1
- package/dist/AgoClient-B_u_d-XS.cjs +0 -9
- package/dist/createConversationSession-BCdwAhLF.cjs +0 -1
- package/dist/createFormCollector-ssBP8u0p.cjs +0 -1
- package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/widget.js
CHANGED
|
@@ -1,73 +1,74 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { a as Cn, c as En, n as Sn, o as kn, s as An, t as _n } from "./types-CPga11Of.js";
|
|
2
|
+
import { n as Rn } from "./errors-BLfjXnLB.js";
|
|
3
|
+
import { t as In } from "./createConversationSession-BaaXBQ5b.js";
|
|
4
|
+
import { r as Nn, t as Ln } from "./createFormCollector-Cf7kGhCB.js";
|
|
5
|
+
import { C as tt, S as Ot, _ as F, a as R, b, c as ze, d as Pt, f as He, g as Tn, h as Q, i as Bt, l as $n, m as he, n as so, o as Ce, p as On, r as fe, s as Ee, t as lo, u as Mt, v as Bn, x as Mn, y as E } from "./sheetController-CBUVOroo.js";
|
|
6
|
+
function zn(r) {
|
|
7
|
+
let t = [];
|
|
8
|
+
const i = document.createElement("form");
|
|
9
|
+
E(i, {
|
|
9
10
|
display: "flex",
|
|
10
11
|
flexDirection: "column",
|
|
11
12
|
gap: "8px",
|
|
12
13
|
padding: "12px",
|
|
13
|
-
borderTop: `1px solid ${
|
|
14
|
-
backgroundColor:
|
|
15
|
-
}),
|
|
16
|
-
const
|
|
14
|
+
borderTop: `1px solid ${R}`,
|
|
15
|
+
backgroundColor: Q
|
|
16
|
+
}), i.className = "ago-chat-input";
|
|
17
|
+
const n = b({
|
|
17
18
|
display: "flex",
|
|
18
19
|
flexWrap: "wrap",
|
|
19
20
|
gap: "6px"
|
|
20
|
-
}),
|
|
21
|
+
}), m = b({
|
|
21
22
|
display: "flex",
|
|
22
23
|
gap: "8px",
|
|
23
24
|
alignItems: "flex-end"
|
|
24
|
-
}),
|
|
25
|
-
|
|
25
|
+
}), a = document.createElement("textarea");
|
|
26
|
+
a.placeholder = r.placeholder, a.setAttribute("aria-label", r.placeholder), a.rows = 1, E(a, {
|
|
26
27
|
flex: "1",
|
|
27
28
|
resize: "none",
|
|
28
29
|
boxSizing: "border-box",
|
|
29
30
|
padding: "10px 12px",
|
|
30
|
-
border: `1px solid ${
|
|
31
|
+
border: `1px solid ${R}`,
|
|
31
32
|
borderRadius: "12px",
|
|
32
33
|
fontSize: "16px",
|
|
33
|
-
fontFamily:
|
|
34
|
+
fontFamily: ze,
|
|
34
35
|
lineHeight: "1.4",
|
|
35
36
|
maxHeight: "110px",
|
|
36
37
|
overflowY: "hidden"
|
|
37
38
|
});
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
39
|
+
const x = () => {
|
|
40
|
+
a.style.height = "auto";
|
|
41
|
+
const g = Math.min(a.scrollHeight + 2, 110);
|
|
42
|
+
a.style.height = `${g}px`, a.style.overflowY = a.scrollHeight + 2 > 110 ? "auto" : "hidden";
|
|
42
43
|
};
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
a.addEventListener("input", () => {
|
|
45
|
+
x(), I();
|
|
45
46
|
});
|
|
46
|
-
const
|
|
47
|
-
|
|
47
|
+
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>', w = '<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>', d = '<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>', u = document.createElement("button");
|
|
48
|
+
u.type = "submit", u.setAttribute("aria-label", "Send"), u.innerHTML = p, E(u, {
|
|
48
49
|
flexShrink: "0",
|
|
49
50
|
width: "44px",
|
|
50
51
|
height: "44px",
|
|
51
52
|
padding: "0",
|
|
52
53
|
border: "none",
|
|
53
54
|
borderRadius: "50%",
|
|
54
|
-
backgroundColor:
|
|
55
|
-
color:
|
|
55
|
+
backgroundColor: Ce,
|
|
56
|
+
color: Ee,
|
|
56
57
|
display: "flex",
|
|
57
58
|
alignItems: "center",
|
|
58
59
|
justifyContent: "center",
|
|
59
60
|
cursor: "pointer"
|
|
60
61
|
});
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
62
|
+
let h = !1;
|
|
63
|
+
const _ = () => h && !!r.onStop, I = () => {
|
|
64
|
+
const c = a.value.trim() !== "" || t.length > 0, g = _(), N = !g && (h || !c);
|
|
65
|
+
u.disabled = N, u.type = g ? "button" : "submit", u.setAttribute("aria-label", g ? "Stop generating" : "Send"), u.innerHTML = g ? d : h ? w : p, u.style.opacity = N && !h ? "0.5" : "1", u.style.cursor = N ? "default" : "pointer";
|
|
65
66
|
};
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
u.addEventListener("click", () => {
|
|
68
|
+
_() && r.onStop?.();
|
|
68
69
|
});
|
|
69
|
-
let
|
|
70
|
-
|
|
70
|
+
let L = null, W = null;
|
|
71
|
+
r.allowFiles && (L = document.createElement("input"), L.type = "file", L.multiple = !0, E(L, { display: "none" }), W = document.createElement("button"), W.type = "button", W.setAttribute("aria-label", "Attach file"), W.textContent = "📎", E(W, {
|
|
71
72
|
flexShrink: "0",
|
|
72
73
|
minWidth: "44px",
|
|
73
74
|
minHeight: "44px",
|
|
@@ -75,29 +76,29 @@ function In(n) {
|
|
|
75
76
|
alignItems: "center",
|
|
76
77
|
justifyContent: "center",
|
|
77
78
|
padding: "0 12px",
|
|
78
|
-
border: `1px solid ${
|
|
79
|
+
border: `1px solid ${R}`,
|
|
79
80
|
borderRadius: "12px",
|
|
80
|
-
backgroundColor:
|
|
81
|
+
backgroundColor: Q,
|
|
81
82
|
cursor: "pointer",
|
|
82
83
|
fontSize: "14px"
|
|
83
|
-
}),
|
|
84
|
-
|
|
84
|
+
}), W.addEventListener("click", () => L?.click()), L.addEventListener("change", () => {
|
|
85
|
+
t = [...t, ...Array.from(L?.files ?? [])], D();
|
|
85
86
|
}));
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
const
|
|
87
|
+
function D() {
|
|
88
|
+
n.replaceChildren(), t.forEach((c, g) => {
|
|
89
|
+
const N = b({
|
|
89
90
|
display: "flex",
|
|
90
91
|
alignItems: "center",
|
|
91
92
|
gap: "4px",
|
|
92
93
|
padding: "4px 8px",
|
|
93
94
|
backgroundColor: "#f0f4ff",
|
|
94
|
-
border: `1px solid ${
|
|
95
|
+
border: `1px solid ${R}`,
|
|
95
96
|
borderRadius: "8px",
|
|
96
97
|
fontSize: "12px"
|
|
97
|
-
}),
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
98
|
+
}), P = document.createElement("span");
|
|
99
|
+
P.textContent = c.name;
|
|
100
|
+
const U = document.createElement("button");
|
|
101
|
+
U.type = "button", U.setAttribute("aria-label", `Remove ${c.name}`), U.textContent = "×", E(U, {
|
|
101
102
|
flexShrink: "0",
|
|
102
103
|
width: "44px",
|
|
103
104
|
height: "44px",
|
|
@@ -110,239 +111,423 @@ function In(n) {
|
|
|
110
111
|
cursor: "pointer",
|
|
111
112
|
fontSize: "14px",
|
|
112
113
|
lineHeight: "1"
|
|
113
|
-
}),
|
|
114
|
-
|
|
115
|
-
}),
|
|
116
|
-
}),
|
|
114
|
+
}), U.addEventListener("click", () => {
|
|
115
|
+
t = t.filter((oe, T) => T !== g), D();
|
|
116
|
+
}), N.append(P, U), n.appendChild(N);
|
|
117
|
+
}), I();
|
|
117
118
|
}
|
|
118
|
-
const
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
content:
|
|
122
|
-
files:
|
|
119
|
+
const v = () => {
|
|
120
|
+
const c = a.value, g = t;
|
|
121
|
+
return a.value = "", x(), t = [], D(), {
|
|
122
|
+
content: c,
|
|
123
|
+
files: g
|
|
123
124
|
};
|
|
124
|
-
},
|
|
125
|
-
const { content:
|
|
126
|
-
(
|
|
125
|
+
}, S = () => {
|
|
126
|
+
const { content: c, files: g } = v();
|
|
127
|
+
(c.trim() || g.length > 0) && r.onSend(c.trim(), g.length > 0 ? g : void 0);
|
|
127
128
|
};
|
|
128
|
-
return
|
|
129
|
-
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
}),
|
|
133
|
-
inputRow:
|
|
134
|
-
getValueAndClear:
|
|
135
|
-
setDisabled: (
|
|
136
|
-
|
|
129
|
+
return i.addEventListener("submit", (c) => {
|
|
130
|
+
c.preventDefault(), S();
|
|
131
|
+
}), a.addEventListener("keydown", (c) => {
|
|
132
|
+
c.key === "Enter" && !c.shiftKey && (c.preventDefault(), S());
|
|
133
|
+
}), W && m.appendChild(W), m.append(a, u), L && i.appendChild(L), i.append(n, m), I(), {
|
|
134
|
+
inputRow: i,
|
|
135
|
+
getValueAndClear: v,
|
|
136
|
+
setDisabled: (c) => {
|
|
137
|
+
a.disabled = c, h = c, I();
|
|
137
138
|
},
|
|
138
|
-
focus: () =>
|
|
139
|
-
restoreDraft: (
|
|
140
|
-
|
|
139
|
+
focus: () => a.focus(),
|
|
140
|
+
restoreDraft: (c, g) => {
|
|
141
|
+
c && !a.value.trim() && (a.value = c, x()), g?.length && (t = [...g, ...t], D()), I();
|
|
141
142
|
}
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
|
-
var
|
|
145
|
+
var Dn = {
|
|
145
146
|
"&": "&",
|
|
146
147
|
"<": "<",
|
|
147
148
|
">": ">",
|
|
148
149
|
'"': """,
|
|
149
150
|
"'": "'"
|
|
150
151
|
};
|
|
151
|
-
function
|
|
152
|
-
return
|
|
152
|
+
function ue(r) {
|
|
153
|
+
return r.replace(/[&<>"']/g, (t) => Dn[t]);
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
-
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(
|
|
155
|
+
function zt(r) {
|
|
156
|
+
const t = r.trim();
|
|
157
|
+
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(t) || !/^[a-z][a-z0-9+.-]*:/i.test(t) ? t : null;
|
|
157
158
|
}
|
|
158
|
-
var
|
|
159
|
-
function ie(
|
|
160
|
-
const
|
|
161
|
-
let
|
|
162
|
-
return
|
|
163
|
-
const
|
|
164
|
-
return
|
|
165
|
-
}),
|
|
166
|
-
const
|
|
167
|
-
return
|
|
168
|
-
}),
|
|
159
|
+
var Ut = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Me = "";
|
|
160
|
+
function ie(r) {
|
|
161
|
+
const t = [], i = (m) => (t.push(m), `${Me}${t.length - 1}${Me}`);
|
|
162
|
+
let n = r;
|
|
163
|
+
return n = n.replace(/`([^`]+)`/g, (m, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Ut}">${ue(a)}</code>`)), n = n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (m, a, x) => {
|
|
164
|
+
const p = zt(x);
|
|
165
|
+
return p ? i(`<img alt="${ue(a)}" src="${ue(p)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : m;
|
|
166
|
+
}), n = n.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (m, a, x) => {
|
|
167
|
+
const p = zt(x);
|
|
168
|
+
return p ? i(`<a href="${ue(p)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ie(a)}</a>`) : m;
|
|
169
|
+
}), n = ue(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(`${Me}(\\d+)${Me}`, "g"), (m, a) => t[Number(a)]), n;
|
|
169
170
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
return Object.assign(
|
|
171
|
+
function G(r, t, i) {
|
|
172
|
+
const n = document.createElement(r);
|
|
173
|
+
return Object.assign(n.style, t), i !== void 0 && (n.innerHTML = i), n;
|
|
173
174
|
}
|
|
174
|
-
var
|
|
175
|
+
var Gt = /^ {0,3}([-*_])( *\1){2,} *$/, jt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Vt = /^ {0,3}(```+|~~~+)/, De = /^ {0,3}>\s?/, me = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Hn = [
|
|
175
176
|
"20px",
|
|
176
177
|
"18px",
|
|
177
178
|
"16px",
|
|
178
179
|
"15px",
|
|
179
180
|
"14px",
|
|
180
181
|
"13px"
|
|
181
|
-
],
|
|
182
|
-
function
|
|
183
|
-
return
|
|
182
|
+
], nt = (r) => r.match(/^\s*/)?.[0].length ?? 0;
|
|
183
|
+
function Fn(r) {
|
|
184
|
+
return r.trim() === "" || Gt.test(r) || jt.test(r) || Vt.test(r) || De.test(r) || me.test(r);
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
-
const
|
|
186
|
+
function qt(r) {
|
|
187
|
+
const t = r[0].match(me), i = t[1].length, n = /\d/.test(t[2]), m = G(n ? "ol" : "ul", {
|
|
187
188
|
margin: "0 0 8px 0",
|
|
188
189
|
paddingLeft: "20px",
|
|
189
|
-
listStyleType:
|
|
190
|
+
listStyleType: n ? "decimal" : "disc",
|
|
190
191
|
listStylePosition: "outside"
|
|
191
192
|
});
|
|
192
|
-
let
|
|
193
|
-
for (;
|
|
194
|
-
const
|
|
195
|
-
for (
|
|
196
|
-
|
|
197
|
-
const
|
|
193
|
+
let a = 0;
|
|
194
|
+
for (; a < r.length; ) {
|
|
195
|
+
const x = r[a].match(me), p = [];
|
|
196
|
+
for (a++; a < r.length && nt(r[a]) > i; )
|
|
197
|
+
p.push(r[a]), a++;
|
|
198
|
+
const w = G("li", {
|
|
198
199
|
display: "list-item",
|
|
199
200
|
margin: "2px 0",
|
|
200
201
|
lineHeight: "1.6"
|
|
201
|
-
}),
|
|
202
|
-
|
|
202
|
+
}), d = x[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
203
|
+
d ? (w.style.listStyleType = "none", w.style.marginLeft = "-20px", w.innerHTML = `<span style="margin-right:6px">${d[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ie(d[2])}`) : w.innerHTML = ie(x[3]), p.filter((u) => me.test(u)).length > 0 && w.appendChild(qt(p.filter((u) => u.trim() !== ""))), m.appendChild(w);
|
|
203
204
|
}
|
|
204
|
-
return
|
|
205
|
+
return m;
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
-
const
|
|
207
|
+
function Wn(r) {
|
|
208
|
+
const t = (p) => p.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((w) => w.trim()), i = G("div", {
|
|
208
209
|
overflowX: "auto",
|
|
209
210
|
margin: "0 0 8px 0"
|
|
210
|
-
}),
|
|
211
|
+
}), n = G("table", {
|
|
211
212
|
borderCollapse: "collapse",
|
|
212
213
|
width: "100%",
|
|
213
214
|
fontSize: "13px"
|
|
214
|
-
}),
|
|
215
|
-
for (const
|
|
215
|
+
}), m = document.createElement("thead"), a = document.createElement("tr");
|
|
216
|
+
for (const p of t(r[0])) a.appendChild(G("th", {
|
|
216
217
|
border: "1px solid #dee3e8",
|
|
217
218
|
padding: "6px 10px",
|
|
218
219
|
textAlign: "left",
|
|
219
220
|
backgroundColor: "#f5f7fa",
|
|
220
221
|
fontWeight: "600"
|
|
221
|
-
}, ie(
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
for (const
|
|
225
|
-
const
|
|
226
|
-
for (const
|
|
222
|
+
}, ie(p)));
|
|
223
|
+
m.appendChild(a), n.appendChild(m);
|
|
224
|
+
const x = document.createElement("tbody");
|
|
225
|
+
for (const p of r.slice(2)) {
|
|
226
|
+
const w = document.createElement("tr");
|
|
227
|
+
for (const d of t(p)) w.appendChild(G("td", {
|
|
227
228
|
border: "1px solid #dee3e8",
|
|
228
229
|
padding: "6px 10px"
|
|
229
|
-
}, ie(
|
|
230
|
-
|
|
230
|
+
}, ie(d)));
|
|
231
|
+
x.appendChild(w);
|
|
231
232
|
}
|
|
232
|
-
return
|
|
233
|
+
return n.appendChild(x), i.appendChild(n), i;
|
|
233
234
|
}
|
|
234
|
-
var
|
|
235
|
-
function
|
|
236
|
-
const
|
|
235
|
+
var Pn = (r) => !!r && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(r);
|
|
236
|
+
function rt(r) {
|
|
237
|
+
const t = document.createDocumentFragment(), i = r.replace(/\r\n?/g, `
|
|
237
238
|
`).split(`
|
|
238
239
|
`);
|
|
239
|
-
let
|
|
240
|
-
for (;
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
|
|
240
|
+
let n = 0;
|
|
241
|
+
for (; n < i.length; ) {
|
|
242
|
+
const a = i[n];
|
|
243
|
+
if (a.trim() === "") {
|
|
244
|
+
n++;
|
|
244
245
|
continue;
|
|
245
246
|
}
|
|
246
|
-
const
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
for (
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const
|
|
253
|
-
|
|
247
|
+
const x = a.match(Vt);
|
|
248
|
+
if (x) {
|
|
249
|
+
const d = x[1][0], u = [];
|
|
250
|
+
for (n++; n < i.length && !new RegExp(`^ {0,3}${d === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(i[n]); )
|
|
251
|
+
u.push(i[n]), n++;
|
|
252
|
+
n++;
|
|
253
|
+
const h = G("pre", { margin: "0 0 8px 0" });
|
|
254
|
+
h.appendChild(G("code", {
|
|
254
255
|
display: "block",
|
|
255
256
|
background: "#f5f5f5",
|
|
256
257
|
padding: "8px 12px",
|
|
257
258
|
borderRadius: "6px",
|
|
258
259
|
fontSize: "13px",
|
|
259
260
|
overflowX: "auto",
|
|
260
|
-
fontFamily:
|
|
261
|
+
fontFamily: Ut,
|
|
261
262
|
whiteSpace: "pre"
|
|
262
|
-
},
|
|
263
|
-
`)))),
|
|
263
|
+
}, ue(u.join(`
|
|
264
|
+
`)))), t.appendChild(h);
|
|
264
265
|
continue;
|
|
265
266
|
}
|
|
266
|
-
if (
|
|
267
|
-
|
|
267
|
+
if (Gt.test(a)) {
|
|
268
|
+
t.appendChild(G("hr", {
|
|
268
269
|
border: "none",
|
|
269
270
|
borderTop: "1px solid #dee3e8",
|
|
270
271
|
margin: "12px 0"
|
|
271
|
-
})),
|
|
272
|
+
})), n++;
|
|
272
273
|
continue;
|
|
273
274
|
}
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
276
|
-
const
|
|
277
|
-
|
|
275
|
+
const p = a.match(jt);
|
|
276
|
+
if (p) {
|
|
277
|
+
const d = p[1].length;
|
|
278
|
+
t.appendChild(G(`h${d}`, {
|
|
278
279
|
margin: "16px 0 8px 0",
|
|
279
|
-
fontSize:
|
|
280
|
+
fontSize: Hn[d - 1],
|
|
280
281
|
fontWeight: "600",
|
|
281
282
|
lineHeight: "1.3"
|
|
282
|
-
}, ie(
|
|
283
|
+
}, ie(p[2]))), n++;
|
|
283
284
|
continue;
|
|
284
285
|
}
|
|
285
|
-
if (
|
|
286
|
-
const
|
|
287
|
-
for (;
|
|
288
|
-
|
|
289
|
-
const
|
|
286
|
+
if (De.test(a)) {
|
|
287
|
+
const d = [];
|
|
288
|
+
for (; n < i.length && De.test(i[n]); )
|
|
289
|
+
d.push(i[n].replace(De, "")), n++;
|
|
290
|
+
const u = G("blockquote", {
|
|
290
291
|
borderLeft: "4px solid #dee3e8",
|
|
291
292
|
paddingLeft: "12px",
|
|
292
293
|
margin: "0 0 8px 0",
|
|
293
294
|
fontStyle: "italic",
|
|
294
295
|
color: "#6b6d6f"
|
|
295
296
|
});
|
|
296
|
-
|
|
297
|
-
`))),
|
|
297
|
+
u.appendChild(rt(d.join(`
|
|
298
|
+
`))), t.appendChild(u);
|
|
298
299
|
continue;
|
|
299
300
|
}
|
|
300
|
-
if (
|
|
301
|
-
const
|
|
302
|
-
for (
|
|
303
|
-
|
|
304
|
-
|
|
301
|
+
if (a.includes("|") && Pn(i[n + 1])) {
|
|
302
|
+
const d = [a, i[n + 1]];
|
|
303
|
+
for (n += 2; n < i.length && i[n].includes("|") && i[n].trim(); )
|
|
304
|
+
d.push(i[n]), n++;
|
|
305
|
+
t.appendChild(Wn(d));
|
|
305
306
|
continue;
|
|
306
307
|
}
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
for (;
|
|
310
|
-
if (
|
|
311
|
-
|
|
308
|
+
if (me.test(a)) {
|
|
309
|
+
const d = [], u = nt(a);
|
|
310
|
+
for (; n < i.length && i[n].trim() !== ""; )
|
|
311
|
+
if (me.test(i[n]) || nt(i[n]) > u)
|
|
312
|
+
d.push(i[n]), n++;
|
|
312
313
|
else break;
|
|
313
|
-
|
|
314
|
+
t.appendChild(qt(d));
|
|
314
315
|
continue;
|
|
315
316
|
}
|
|
316
|
-
const
|
|
317
|
-
for (
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
const w = [a];
|
|
318
|
+
for (n++; n < i.length && !Fn(i[n]); )
|
|
319
|
+
w.push(i[n]), n++;
|
|
320
|
+
t.appendChild(G("p", {
|
|
320
321
|
margin: "0 0 8px 0",
|
|
321
322
|
lineHeight: "1.6"
|
|
322
|
-
},
|
|
323
|
+
}, w.map((d) => ie(d)).join("<br>")));
|
|
324
|
+
}
|
|
325
|
+
const m = t.lastElementChild;
|
|
326
|
+
return m && (m.style.marginBottom = "0"), t;
|
|
327
|
+
}
|
|
328
|
+
var Dt = {
|
|
329
|
+
helpful: "Helpful",
|
|
330
|
+
notHelpful: "Not helpful",
|
|
331
|
+
whatWentWrong: "What went wrong?",
|
|
332
|
+
reasons: {
|
|
333
|
+
inaccurate: "Inaccurate",
|
|
334
|
+
incomplete: "Incomplete",
|
|
335
|
+
information_not_found: "Information not found",
|
|
336
|
+
technical_issue: "Technical issue"
|
|
337
|
+
},
|
|
338
|
+
commentPlaceholder: "Anything else? (optional)",
|
|
339
|
+
send: "Send",
|
|
340
|
+
thanks: "Thanks, this was reported."
|
|
341
|
+
};
|
|
342
|
+
function Un() {
|
|
343
|
+
return {
|
|
344
|
+
detailsOpen: !1,
|
|
345
|
+
reasons: /* @__PURE__ */ new Set(),
|
|
346
|
+
comment: "",
|
|
347
|
+
reported: !1
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
var Gn = {
|
|
351
|
+
display: "inline-flex",
|
|
352
|
+
alignItems: "center",
|
|
353
|
+
justifyContent: "center",
|
|
354
|
+
width: "44px",
|
|
355
|
+
height: "44px",
|
|
356
|
+
margin: "-8px",
|
|
357
|
+
padding: "0",
|
|
358
|
+
border: "none",
|
|
359
|
+
borderRadius: "8px",
|
|
360
|
+
background: "transparent",
|
|
361
|
+
color: he,
|
|
362
|
+
cursor: "pointer",
|
|
363
|
+
lineHeight: "1"
|
|
364
|
+
};
|
|
365
|
+
function jn(r) {
|
|
366
|
+
const { state: t, labels: i, askWhy: n, onRate: m, onReport: a } = r, x = b({
|
|
367
|
+
marginTop: "6px",
|
|
368
|
+
width: "100%",
|
|
369
|
+
maxWidth: "85%"
|
|
370
|
+
});
|
|
371
|
+
x.className = "ago-feedback";
|
|
372
|
+
const p = b({
|
|
373
|
+
display: "flex",
|
|
374
|
+
alignItems: "center",
|
|
375
|
+
gap: "2px"
|
|
376
|
+
});
|
|
377
|
+
p.className = "ago-feedback__actions";
|
|
378
|
+
const w = Ht("up", i.helpful, t.rating === "positive");
|
|
379
|
+
w.addEventListener("click", () => {
|
|
380
|
+
t.rating = "positive", t.detailsOpen = !1, h(), _(), m("positive");
|
|
381
|
+
});
|
|
382
|
+
const d = Ht("down", i.notHelpful, t.rating === "negative");
|
|
383
|
+
d.addEventListener("click", () => {
|
|
384
|
+
t.rating = "negative", m("negative"), n && !t.reported && (t.detailsOpen = !0), h(), _();
|
|
385
|
+
}), p.append(w, d), x.appendChild(p);
|
|
386
|
+
const u = b();
|
|
387
|
+
u.className = "ago-feedback__panel-slot", x.appendChild(u);
|
|
388
|
+
function h() {
|
|
389
|
+
ot(w, t.rating === "positive"), ot(d, t.rating === "negative");
|
|
390
|
+
}
|
|
391
|
+
function _() {
|
|
392
|
+
if (u.replaceChildren(), t.reported) {
|
|
393
|
+
u.appendChild(Kn(i.thanks));
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
t.detailsOpen && u.appendChild(qn(t, i, async (I) => await a(t.rating ?? "negative", I) ? (t.reported = !0, t.detailsOpen = !1, _(), !0) : !1));
|
|
397
|
+
}
|
|
398
|
+
return h(), _(), x;
|
|
399
|
+
}
|
|
400
|
+
function Ht(r, t, i) {
|
|
401
|
+
const n = document.createElement("button");
|
|
402
|
+
return n.type = "button", n.className = `ago-feedback__thumb ago-feedback__thumb--${r}`, n.setAttribute("aria-label", t), n.title = t, E(n, Gn), n.appendChild(Vn(r)), ot(n, i), n.addEventListener("mouseenter", () => {
|
|
403
|
+
n.getAttribute("aria-pressed") !== "true" && (n.style.color = F);
|
|
404
|
+
}), n.addEventListener("mouseleave", () => {
|
|
405
|
+
n.getAttribute("aria-pressed") !== "true" && (n.style.color = he);
|
|
406
|
+
}), n;
|
|
407
|
+
}
|
|
408
|
+
function ot(r, t) {
|
|
409
|
+
r.setAttribute("aria-pressed", t ? "true" : "false"), r.style.color = t ? fe : he;
|
|
410
|
+
}
|
|
411
|
+
function Vn(r) {
|
|
412
|
+
const t = "http://www.w3.org/2000/svg", i = document.createElementNS(t, "svg");
|
|
413
|
+
i.setAttribute("width", "16"), i.setAttribute("height", "16"), i.setAttribute("viewBox", "0 0 24 24"), i.setAttribute("fill", "none"), i.setAttribute("aria-hidden", "true");
|
|
414
|
+
const n = document.createElementNS(t, "path");
|
|
415
|
+
n.setAttribute("d", "M7 22h9.3a2 2 0 0 0 2-1.7l1.4-9A2 2 0 0 0 17.7 9H14V5a3 3 0 0 0-3-3l-4 10z"), n.setAttribute("stroke", "currentColor"), n.setAttribute("stroke-width", "1.8"), n.setAttribute("stroke-linejoin", "round");
|
|
416
|
+
const m = document.createElementNS(t, "path");
|
|
417
|
+
return m.setAttribute("d", "M7 22V12H4.5A1.5 1.5 0 0 0 3 13.5v7A1.5 1.5 0 0 0 4.5 22z"), m.setAttribute("stroke", "currentColor"), m.setAttribute("stroke-width", "1.8"), m.setAttribute("stroke-linejoin", "round"), i.append(n, m), r === "down" && (i.style.transform = "rotate(180deg)"), i;
|
|
418
|
+
}
|
|
419
|
+
function qn(r, t, i) {
|
|
420
|
+
const n = b({
|
|
421
|
+
marginTop: "8px",
|
|
422
|
+
padding: "12px",
|
|
423
|
+
border: `1px solid ${R}`,
|
|
424
|
+
borderRadius: He,
|
|
425
|
+
backgroundColor: Q
|
|
426
|
+
});
|
|
427
|
+
n.className = "ago-feedback__panel", n.setAttribute("role", "group"), n.setAttribute("aria-label", t.whatWentWrong);
|
|
428
|
+
const m = b({
|
|
429
|
+
fontSize: "13px",
|
|
430
|
+
fontWeight: "500",
|
|
431
|
+
color: F,
|
|
432
|
+
marginBottom: "8px"
|
|
433
|
+
});
|
|
434
|
+
m.textContent = t.whatWentWrong, n.appendChild(m);
|
|
435
|
+
const a = b({
|
|
436
|
+
display: "flex",
|
|
437
|
+
flexWrap: "wrap",
|
|
438
|
+
gap: "6px",
|
|
439
|
+
marginBottom: "8px"
|
|
440
|
+
});
|
|
441
|
+
a.className = "ago-feedback__reasons";
|
|
442
|
+
for (const d of _n) {
|
|
443
|
+
const u = document.createElement("button");
|
|
444
|
+
u.type = "button", u.className = "ago-feedback__reason", u.textContent = t.reasons[d], E(u, {
|
|
445
|
+
minHeight: "44px",
|
|
446
|
+
padding: "4px 12px",
|
|
447
|
+
fontSize: "13px",
|
|
448
|
+
fontFamily: "inherit",
|
|
449
|
+
borderRadius: "999px",
|
|
450
|
+
border: `1px solid ${R}`,
|
|
451
|
+
backgroundColor: "transparent",
|
|
452
|
+
color: F,
|
|
453
|
+
cursor: "pointer"
|
|
454
|
+
});
|
|
455
|
+
const h = () => {
|
|
456
|
+
const _ = r.reasons.has(d);
|
|
457
|
+
u.setAttribute("aria-pressed", _ ? "true" : "false"), u.style.borderColor = _ ? fe : R, u.style.color = _ ? fe : F;
|
|
458
|
+
};
|
|
459
|
+
u.addEventListener("click", () => {
|
|
460
|
+
r.reasons.has(d) ? r.reasons.delete(d) : r.reasons.add(d), h(), w();
|
|
461
|
+
}), h(), a.appendChild(u);
|
|
462
|
+
}
|
|
463
|
+
n.appendChild(a);
|
|
464
|
+
const x = document.createElement("textarea");
|
|
465
|
+
x.className = "ago-feedback__comment", x.rows = 2, x.placeholder = t.commentPlaceholder, x.value = r.comment, x.setAttribute("aria-label", t.commentPlaceholder), E(x, {
|
|
466
|
+
width: "100%",
|
|
467
|
+
boxSizing: "border-box",
|
|
468
|
+
padding: "8px 10px",
|
|
469
|
+
fontSize: "14px",
|
|
470
|
+
fontFamily: "inherit",
|
|
471
|
+
color: F,
|
|
472
|
+
border: `1px solid ${R}`,
|
|
473
|
+
borderRadius: "10px",
|
|
474
|
+
backgroundColor: "transparent",
|
|
475
|
+
resize: "vertical"
|
|
476
|
+
}), x.addEventListener("input", () => {
|
|
477
|
+
r.comment = x.value, w();
|
|
478
|
+
}), n.appendChild(x);
|
|
479
|
+
const p = document.createElement("button");
|
|
480
|
+
return p.type = "button", p.className = "ago-feedback__send", p.textContent = t.send, E(p, {
|
|
481
|
+
marginTop: "8px",
|
|
482
|
+
minHeight: "44px",
|
|
483
|
+
padding: "6px 16px",
|
|
484
|
+
fontSize: "14px",
|
|
485
|
+
fontFamily: "inherit",
|
|
486
|
+
borderRadius: "10px",
|
|
487
|
+
border: "none",
|
|
488
|
+
backgroundColor: Ce,
|
|
489
|
+
color: Ee,
|
|
490
|
+
cursor: "pointer"
|
|
491
|
+
}), p.addEventListener("click", () => {
|
|
492
|
+
p.disabled || (p.disabled = !0, i({
|
|
493
|
+
reasons: [...r.reasons],
|
|
494
|
+
comment: r.comment.trim()
|
|
495
|
+
}).then((d) => {
|
|
496
|
+
d || w();
|
|
497
|
+
}));
|
|
498
|
+
}), n.appendChild(p), w(), n;
|
|
499
|
+
function w() {
|
|
500
|
+
const d = r.reasons.size > 0 || r.comment.trim().length > 0;
|
|
501
|
+
p.disabled = !d, p.style.opacity = d ? "1" : "0.5", p.style.cursor = d ? "pointer" : "default";
|
|
323
502
|
}
|
|
324
|
-
const w = o.lastElementChild;
|
|
325
|
-
return w && (w.style.marginBottom = "0"), o;
|
|
326
503
|
}
|
|
327
|
-
function
|
|
328
|
-
const
|
|
504
|
+
function Kn(r) {
|
|
505
|
+
const t = b({
|
|
506
|
+
marginTop: "6px",
|
|
507
|
+
fontSize: "13px",
|
|
508
|
+
color: he
|
|
509
|
+
});
|
|
510
|
+
return t.className = "ago-feedback__thanks", t.setAttribute("role", "status"), t.textContent = r, t;
|
|
511
|
+
}
|
|
512
|
+
function Ft(r, t) {
|
|
513
|
+
const { isLast: i, isLastOfBlock: n, bubbleStyle: m, showAgentName: a, agentBubble: x, followUpEnabled: p, followUpHandler: w, isMobile: d, feedbackRow: u } = t, h = r.role === "user", _ = m === "imessage", I = b({
|
|
329
514
|
display: "flex",
|
|
330
515
|
flexDirection: "column",
|
|
331
|
-
alignItems:
|
|
332
|
-
marginBottom:
|
|
516
|
+
alignItems: h ? "flex-end" : "flex-start",
|
|
517
|
+
marginBottom: _ && !n ? "2px" : "16px"
|
|
333
518
|
});
|
|
334
|
-
if (
|
|
335
|
-
const
|
|
519
|
+
if (I.className = `ago-message ago-message--${r.role}`, !h && a && r.agent) {
|
|
520
|
+
const v = b({
|
|
336
521
|
fontSize: "13px",
|
|
337
522
|
fontWeight: "500",
|
|
338
|
-
color:
|
|
523
|
+
color: F,
|
|
339
524
|
marginBottom: "6px",
|
|
340
525
|
padding: "0 4px"
|
|
341
526
|
});
|
|
342
|
-
|
|
527
|
+
v.className = "ago-message__agent", v.textContent = r.agent.displayName || r.agent.name, I.appendChild(v);
|
|
343
528
|
}
|
|
344
|
-
if (!
|
|
345
|
-
const
|
|
529
|
+
if (!h && r.sources && r.sources.length > 0) {
|
|
530
|
+
const v = b({
|
|
346
531
|
display: "grid",
|
|
347
532
|
gridTemplateColumns: "1fr 1fr",
|
|
348
533
|
gap: "6px",
|
|
@@ -350,28 +535,28 @@ function Tt(n, o) {
|
|
|
350
535
|
width: "100%",
|
|
351
536
|
maxWidth: "85%"
|
|
352
537
|
});
|
|
353
|
-
|
|
354
|
-
const
|
|
355
|
-
|
|
538
|
+
v.className = "ago-message__sources", r.sources.forEach((S, c) => {
|
|
539
|
+
const g = S.url ? document.createElement("a") : document.createElement("div");
|
|
540
|
+
S.url && g instanceof HTMLAnchorElement && (g.href = S.url, g.target = "_blank", g.rel = "noopener noreferrer"), E(g, {
|
|
356
541
|
display: "flex",
|
|
357
542
|
alignItems: "center",
|
|
358
543
|
gap: "8px",
|
|
359
544
|
padding: "8px 10px",
|
|
360
|
-
border: `1px solid ${
|
|
545
|
+
border: `1px solid ${R}`,
|
|
361
546
|
borderRadius: "8px",
|
|
362
|
-
backgroundColor:
|
|
547
|
+
backgroundColor: Q,
|
|
363
548
|
textDecoration: "none",
|
|
364
|
-
color:
|
|
549
|
+
color: F,
|
|
365
550
|
fontSize: "12px",
|
|
366
551
|
overflow: "hidden"
|
|
367
552
|
});
|
|
368
|
-
const
|
|
553
|
+
const N = b({
|
|
369
554
|
flexShrink: "0",
|
|
370
555
|
width: "18px",
|
|
371
556
|
height: "18px",
|
|
372
557
|
borderRadius: "3px",
|
|
373
|
-
border: `1px solid ${
|
|
374
|
-
color:
|
|
558
|
+
border: `1px solid ${fe}`,
|
|
559
|
+
color: fe,
|
|
375
560
|
fontSize: "11px",
|
|
376
561
|
fontWeight: "500",
|
|
377
562
|
display: "flex",
|
|
@@ -379,273 +564,273 @@ function Tt(n, o) {
|
|
|
379
564
|
justifyContent: "center",
|
|
380
565
|
backgroundColor: "#f0f4ff"
|
|
381
566
|
});
|
|
382
|
-
|
|
383
|
-
const
|
|
567
|
+
N.textContent = String(c + 1);
|
|
568
|
+
const P = b({
|
|
384
569
|
overflow: "hidden",
|
|
385
570
|
textOverflow: "ellipsis",
|
|
386
571
|
whiteSpace: "nowrap"
|
|
387
572
|
});
|
|
388
|
-
|
|
389
|
-
}),
|
|
573
|
+
P.textContent = S.title, P.title = S.title, g.append(N, P), v.appendChild(g);
|
|
574
|
+
}), I.appendChild(v);
|
|
390
575
|
}
|
|
391
|
-
if (
|
|
392
|
-
const
|
|
576
|
+
if (r.attachments && r.attachments.length > 0) {
|
|
577
|
+
const v = b({
|
|
393
578
|
display: "flex",
|
|
394
579
|
flexWrap: "wrap",
|
|
395
580
|
gap: "6px",
|
|
396
581
|
marginBottom: "6px",
|
|
397
|
-
justifyContent:
|
|
582
|
+
justifyContent: h ? "flex-end" : "flex-start",
|
|
398
583
|
maxWidth: "75%"
|
|
399
584
|
});
|
|
400
|
-
|
|
401
|
-
for (const
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
const
|
|
405
|
-
|
|
585
|
+
v.className = "ago-message__attachments";
|
|
586
|
+
for (const S of r.attachments) {
|
|
587
|
+
const c = En(S.url);
|
|
588
|
+
if (kn(S) && c) {
|
|
589
|
+
const T = document.createElement("a");
|
|
590
|
+
T.href = c, T.target = "_blank", T.rel = "noopener noreferrer", E(T, {
|
|
406
591
|
display: "inline-block",
|
|
407
592
|
textDecoration: "none"
|
|
408
593
|
});
|
|
409
|
-
const
|
|
410
|
-
|
|
594
|
+
const J = document.createElement("img");
|
|
595
|
+
J.src = c, J.alt = S.name, J.loading = "lazy", E(J, {
|
|
411
596
|
maxWidth: "180px",
|
|
412
597
|
maxHeight: "160px",
|
|
413
598
|
objectFit: "cover",
|
|
414
599
|
borderRadius: "10px",
|
|
415
|
-
border: `1px solid ${
|
|
600
|
+
border: `1px solid ${R}`,
|
|
416
601
|
display: "block"
|
|
417
|
-
}),
|
|
602
|
+
}), T.appendChild(J), v.appendChild(T);
|
|
418
603
|
continue;
|
|
419
604
|
}
|
|
420
|
-
const
|
|
421
|
-
|
|
605
|
+
const g = c ? document.createElement("a") : document.createElement("div");
|
|
606
|
+
c && g instanceof HTMLAnchorElement && (g.href = c, g.target = "_blank", g.rel = "noopener noreferrer"), E(g, {
|
|
422
607
|
display: "inline-flex",
|
|
423
608
|
alignItems: "center",
|
|
424
609
|
gap: "8px",
|
|
425
610
|
padding: "8px 12px",
|
|
426
611
|
borderRadius: "10px",
|
|
427
|
-
border: `1px solid ${
|
|
428
|
-
backgroundColor:
|
|
429
|
-
color:
|
|
612
|
+
border: `1px solid ${R}`,
|
|
613
|
+
backgroundColor: h ? "rgba(255,255,255,0.12)" : Q,
|
|
614
|
+
color: h ? Ee : F,
|
|
430
615
|
fontSize: "13px",
|
|
431
616
|
textDecoration: "none",
|
|
432
617
|
maxWidth: "220px"
|
|
433
618
|
});
|
|
434
|
-
const
|
|
435
|
-
|
|
619
|
+
const N = document.createElement("span");
|
|
620
|
+
N.textContent = "📄", N.setAttribute("aria-hidden", "true"), E(N, {
|
|
436
621
|
fontSize: "16px",
|
|
437
622
|
lineHeight: "1",
|
|
438
623
|
flexShrink: "0"
|
|
439
624
|
});
|
|
440
|
-
const
|
|
625
|
+
const P = b({
|
|
441
626
|
display: "flex",
|
|
442
627
|
flexDirection: "column",
|
|
443
628
|
minWidth: "0"
|
|
444
|
-
}),
|
|
629
|
+
}), U = b({
|
|
445
630
|
overflow: "hidden",
|
|
446
631
|
textOverflow: "ellipsis",
|
|
447
632
|
whiteSpace: "nowrap",
|
|
448
633
|
maxWidth: "160px"
|
|
449
634
|
});
|
|
450
|
-
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
635
|
+
U.textContent = S.name, U.title = S.name, P.appendChild(U);
|
|
636
|
+
const oe = An(S.fileSize);
|
|
637
|
+
if (oe) {
|
|
638
|
+
const T = b({
|
|
454
639
|
fontSize: "11px",
|
|
455
|
-
color:
|
|
640
|
+
color: he
|
|
456
641
|
});
|
|
457
|
-
|
|
642
|
+
T.textContent = oe, P.appendChild(T);
|
|
458
643
|
}
|
|
459
|
-
|
|
644
|
+
g.append(N, P), v.appendChild(g);
|
|
460
645
|
}
|
|
461
|
-
|
|
646
|
+
I.appendChild(v);
|
|
462
647
|
}
|
|
463
|
-
const
|
|
464
|
-
maxWidth:
|
|
465
|
-
padding:
|
|
466
|
-
borderRadius:
|
|
467
|
-
backgroundColor:
|
|
468
|
-
color:
|
|
648
|
+
const L = h || x || _, W = !!r.content || r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT", D = b({
|
|
649
|
+
maxWidth: L ? _ || h ? d ? "88%" : "75%" : d ? "92%" : "85%" : "100%",
|
|
650
|
+
padding: L ? "10px 14px" : "2px 8px",
|
|
651
|
+
borderRadius: _ ? On : L ? He : "0",
|
|
652
|
+
backgroundColor: h ? Ce : L ? Bt : "transparent",
|
|
653
|
+
color: h ? Ee : F,
|
|
469
654
|
overflowWrap: "break-word",
|
|
470
655
|
textWrap: "pretty",
|
|
471
656
|
fontSize: "16px",
|
|
472
657
|
lineHeight: "1.6"
|
|
473
658
|
});
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
const
|
|
659
|
+
if (D.className = "ago-message__content", _ && n) {
|
|
660
|
+
D.style.position = "relative";
|
|
661
|
+
const v = b({
|
|
477
662
|
position: "absolute",
|
|
478
663
|
zIndex: "0",
|
|
479
664
|
bottom: "-2px",
|
|
480
665
|
width: "20px",
|
|
481
666
|
height: "20px",
|
|
482
|
-
background:
|
|
667
|
+
background: h ? Ce : Bt
|
|
483
668
|
});
|
|
484
|
-
|
|
485
|
-
const
|
|
669
|
+
v.className = "ago-message__tail";
|
|
670
|
+
const S = b({
|
|
486
671
|
position: "absolute",
|
|
487
672
|
zIndex: "1",
|
|
488
673
|
bottom: "-2px",
|
|
489
674
|
width: "10px",
|
|
490
675
|
height: "20px",
|
|
491
|
-
background:
|
|
676
|
+
background: Pt
|
|
492
677
|
});
|
|
493
|
-
|
|
678
|
+
S.className = "ago-message__tail-mask", h ? (v.style.right = "-8px", v.style.borderBottomLeftRadius = "16px 14px", S.style.right = "-10px", S.style.borderBottomLeftRadius = "10px") : (v.style.left = "-7px", v.style.borderBottomRightRadius = "16px 14px", S.style.left = "-10px", S.style.borderBottomRightRadius = "10px"), D.append(v, S);
|
|
494
679
|
}
|
|
495
|
-
if (
|
|
496
|
-
const
|
|
680
|
+
if (r.content ? D.appendChild(rt(r.content)) : (r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT") && D.appendChild(Qn()), W && I.appendChild(D), !h && u && I.appendChild(u), i && r.followUpReplies && r.followUpReplies.length > 0) {
|
|
681
|
+
const v = b({
|
|
497
682
|
display: "flex",
|
|
498
683
|
flexWrap: "wrap",
|
|
499
684
|
gap: "8px",
|
|
500
685
|
marginTop: "10px"
|
|
501
686
|
});
|
|
502
|
-
|
|
503
|
-
for (const
|
|
504
|
-
const
|
|
505
|
-
|
|
687
|
+
v.className = "ago-message__followups";
|
|
688
|
+
for (const S of r.followUpReplies) {
|
|
689
|
+
const c = document.createElement("button");
|
|
690
|
+
c.type = "button", c.className = "ago-message__followup-btn", c.textContent = S, c.disabled = !p, E(c, {
|
|
506
691
|
minHeight: "44px",
|
|
507
692
|
padding: "6px 14px",
|
|
508
693
|
fontSize: "14px",
|
|
509
|
-
borderRadius:
|
|
510
|
-
border: `1px solid ${
|
|
511
|
-
backgroundColor:
|
|
512
|
-
color:
|
|
513
|
-
cursor:
|
|
694
|
+
borderRadius: He,
|
|
695
|
+
border: `1px solid ${R}`,
|
|
696
|
+
backgroundColor: Q,
|
|
697
|
+
color: F,
|
|
698
|
+
cursor: p ? "pointer" : "default",
|
|
514
699
|
transition: "border-color 0.15s"
|
|
515
|
-
}),
|
|
516
|
-
|
|
517
|
-
}),
|
|
518
|
-
|
|
519
|
-
}),
|
|
700
|
+
}), w && c.addEventListener("click", () => w(S)), c.addEventListener("mouseenter", () => {
|
|
701
|
+
c.style.borderColor = fe;
|
|
702
|
+
}), c.addEventListener("mouseleave", () => {
|
|
703
|
+
c.style.borderColor = R;
|
|
704
|
+
}), v.appendChild(c);
|
|
520
705
|
}
|
|
521
|
-
|
|
706
|
+
I.appendChild(v);
|
|
522
707
|
}
|
|
523
|
-
return
|
|
708
|
+
return I;
|
|
524
709
|
}
|
|
525
|
-
function
|
|
526
|
-
const
|
|
710
|
+
function Xn(r) {
|
|
711
|
+
const t = b({
|
|
527
712
|
display: "flex",
|
|
528
713
|
alignItems: "center",
|
|
529
714
|
gap: "8px",
|
|
530
715
|
padding: "10px 14px",
|
|
531
716
|
backgroundColor: "#f0fdf4",
|
|
532
717
|
color: "#15803d",
|
|
533
|
-
borderRadius:
|
|
718
|
+
borderRadius: He,
|
|
534
719
|
marginTop: "8px",
|
|
535
720
|
fontSize: "13px",
|
|
536
721
|
border: "1px solid #bbf7d0"
|
|
537
722
|
});
|
|
538
|
-
|
|
539
|
-
const r = document.createElement("span");
|
|
540
|
-
r.textContent = "✓", r.setAttribute("aria-hidden", "true"), E(r, { fontWeight: "700" });
|
|
723
|
+
t.className = "ago-form-notice", t.setAttribute("role", "status");
|
|
541
724
|
const i = document.createElement("span");
|
|
542
|
-
|
|
725
|
+
i.textContent = "✓", i.setAttribute("aria-hidden", "true"), E(i, { fontWeight: "700" });
|
|
726
|
+
const n = document.createElement("span");
|
|
727
|
+
return n.textContent = r, t.append(i, n), t;
|
|
543
728
|
}
|
|
544
|
-
function
|
|
545
|
-
const
|
|
729
|
+
function Qn() {
|
|
730
|
+
const r = b({
|
|
546
731
|
display: "flex",
|
|
547
732
|
gap: "4px",
|
|
548
733
|
padding: "4px 0"
|
|
549
734
|
});
|
|
550
|
-
for (let
|
|
551
|
-
const
|
|
735
|
+
for (let t = 0; t < 3; t++) {
|
|
736
|
+
const i = b({
|
|
552
737
|
width: "6px",
|
|
553
738
|
height: "6px",
|
|
554
739
|
borderRadius: "50%",
|
|
555
740
|
backgroundColor: "currentColor",
|
|
556
741
|
opacity: "0.55",
|
|
557
742
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
558
|
-
animationDelay: `${
|
|
743
|
+
animationDelay: `${t * 0.2}s`
|
|
559
744
|
});
|
|
560
|
-
|
|
745
|
+
r.appendChild(i);
|
|
561
746
|
}
|
|
562
|
-
return
|
|
747
|
+
return r;
|
|
563
748
|
}
|
|
564
|
-
function
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
return
|
|
749
|
+
function Jn() {
|
|
750
|
+
const r = "http://www.w3.org/2000/svg", t = document.createElementNS(r, "svg");
|
|
751
|
+
t.setAttribute("width", "26"), t.setAttribute("height", "26"), t.setAttribute("viewBox", "0 0 24 24"), t.setAttribute("fill", "none");
|
|
752
|
+
const i = document.createElementNS(r, "path");
|
|
753
|
+
return i.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"), i.setAttribute("stroke", "currentColor"), i.setAttribute("stroke-width", "2"), i.setAttribute("stroke-linecap", "round"), i.setAttribute("stroke-linejoin", "round"), t.appendChild(i), t;
|
|
569
754
|
}
|
|
570
|
-
var
|
|
571
|
-
function
|
|
572
|
-
if (typeof
|
|
573
|
-
if (!
|
|
574
|
-
const
|
|
575
|
-
if (typeof
|
|
576
|
-
const
|
|
577
|
-
if (typeof
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
if (typeof
|
|
755
|
+
var Wt = "Form submitted.";
|
|
756
|
+
function Yn(r) {
|
|
757
|
+
if (typeof r == "string") return r || null;
|
|
758
|
+
if (!r || typeof r != "object") return null;
|
|
759
|
+
const t = r;
|
|
760
|
+
if (typeof t.message == "string" && t.message) return t.message;
|
|
761
|
+
const i = t.result;
|
|
762
|
+
if (typeof i == "string" && i) return i;
|
|
763
|
+
if (i && typeof i == "object") {
|
|
764
|
+
const n = i.message;
|
|
765
|
+
if (typeof n == "string" && n) return n;
|
|
581
766
|
}
|
|
582
767
|
return null;
|
|
583
768
|
}
|
|
584
|
-
var
|
|
585
|
-
function
|
|
586
|
-
const
|
|
587
|
-
if (!
|
|
588
|
-
return
|
|
769
|
+
var Zn = 0;
|
|
770
|
+
function eo(r) {
|
|
771
|
+
const t = typeof r == "string" ? document.querySelector(r) : r;
|
|
772
|
+
if (!t) throw new Error(`mountChatWidget: target "${String(r)}" not found.`);
|
|
773
|
+
return t;
|
|
589
774
|
}
|
|
590
|
-
function
|
|
591
|
-
const { title:
|
|
592
|
-
message:
|
|
775
|
+
function co(r, t) {
|
|
776
|
+
const { title: i = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: m = "Type a message...", allowFiles: a = !1, allowStop: x = !0, height: p = 500, placement: w = "inline", width: d = 400, defaultOpen: u = !1, logoUrl: h, showAgentName: _ = !1, agentBubble: I = !1, bubbleStyle: L = "default", showHeader: W = !0, theme: D, loadThreads: v = !1, forms: S, formSubmittedMessage: c = Wt, feedback: g = !1, onFollowUpClick: N, onMessageSent: P, onMessageReceived: U, onFormSubmitted: oe, onFormError: T, onOpen: J, onClose: it } = t, ae = typeof n == "string" ? {
|
|
777
|
+
message: n,
|
|
593
778
|
mode: "static"
|
|
594
|
-
} :
|
|
595
|
-
if (!
|
|
596
|
-
const
|
|
597
|
-
let
|
|
598
|
-
const
|
|
779
|
+
} : n, at = ae.message, st = ae.mode ?? "static", Kt = "speed" in ae && ae.speed || 45, lt = "followUpReplies" in ae && ae.followUpReplies || void 0;
|
|
780
|
+
if (!t.client && !t.config?.baseUrl) throw new Rn("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
|
|
781
|
+
const k = t.client ?? new Sn(t.config), dt = eo(r), $ = w === "left" || w === "right", Xt = $ && (t.launcher ?? !0);
|
|
782
|
+
let re = $ ? u : !0, Fe = !1;
|
|
783
|
+
const Qt = t.mobile?.breakpoint ?? 768, We = t.mobile?.trigger ?? "tap", ct = typeof window < "u" && !!window.matchMedia, z = ct ? window.matchMedia(`(max-width: ${Qt}px), (max-height: 500px) and (orientation: landscape)`) : void 0, Jt = ct ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Yt = !!z, ge = !$ && !!z, be = /* @__PURE__ */ Symbol("ago-scroll-lock");
|
|
599
784
|
let se = !1;
|
|
600
|
-
const
|
|
601
|
-
let
|
|
602
|
-
const
|
|
603
|
-
function
|
|
604
|
-
if (typeof
|
|
605
|
-
const
|
|
606
|
-
if (typeof
|
|
785
|
+
const Pe = t.persistConversation, Se = Pe ? In(Pe === !0 ? {} : Pe) : void 0;
|
|
786
|
+
let q = t.conversationId ?? Se?.getLastActiveThread() ?? void 0, f = [], ke = [], K = !1, le = null, Y;
|
|
787
|
+
const Ue = [];
|
|
788
|
+
function Zt(e) {
|
|
789
|
+
if (typeof c == "function") {
|
|
790
|
+
const s = c(e);
|
|
791
|
+
if (typeof s == "string" && s) return s;
|
|
607
792
|
}
|
|
608
|
-
const
|
|
609
|
-
return
|
|
793
|
+
const o = Yn(e);
|
|
794
|
+
return o || (typeof c == "string" ? c : Wt);
|
|
610
795
|
}
|
|
611
|
-
const
|
|
796
|
+
const Ae = [], l = b({
|
|
612
797
|
display: "flex",
|
|
613
798
|
flexDirection: "column",
|
|
614
|
-
height:
|
|
615
|
-
border: `1px solid ${
|
|
616
|
-
borderRadius:
|
|
799
|
+
height: $ ? "100%" : typeof p == "number" ? `${p}px` : p,
|
|
800
|
+
border: `1px solid ${R}`,
|
|
801
|
+
borderRadius: Tn,
|
|
617
802
|
overflow: "hidden",
|
|
618
|
-
backgroundColor:
|
|
619
|
-
fontFamily:
|
|
803
|
+
backgroundColor: Q,
|
|
804
|
+
fontFamily: ze,
|
|
620
805
|
textAlign: "left",
|
|
621
806
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
622
807
|
});
|
|
623
|
-
|
|
624
|
-
let
|
|
625
|
-
if (
|
|
626
|
-
if (
|
|
808
|
+
l.className = "ago-chat-widget", Bn(l, D);
|
|
809
|
+
let j;
|
|
810
|
+
if (W) {
|
|
811
|
+
if (j = b({
|
|
627
812
|
padding: "14px 16px",
|
|
628
|
-
borderBottom: `1px solid ${
|
|
629
|
-
backgroundColor:
|
|
630
|
-
color:
|
|
813
|
+
borderBottom: `1px solid ${R}`,
|
|
814
|
+
backgroundColor: $n,
|
|
815
|
+
color: Mt,
|
|
631
816
|
display: "flex",
|
|
632
817
|
alignItems: "center",
|
|
633
818
|
gap: "10px"
|
|
634
|
-
}),
|
|
635
|
-
const
|
|
636
|
-
|
|
819
|
+
}), j.className = "ago-chat-widget__header", h) {
|
|
820
|
+
const o = document.createElement("img");
|
|
821
|
+
o.src = h, o.alt = "Logo", E(o, {
|
|
637
822
|
height: "24px",
|
|
638
823
|
width: "auto"
|
|
639
|
-
}),
|
|
824
|
+
}), j.appendChild(o);
|
|
640
825
|
}
|
|
641
826
|
const e = document.createElement("h3");
|
|
642
|
-
if (e.textContent =
|
|
827
|
+
if (e.textContent = i, E(e, {
|
|
643
828
|
margin: "0",
|
|
644
829
|
fontSize: "15px",
|
|
645
830
|
fontWeight: "600"
|
|
646
|
-
}),
|
|
647
|
-
const
|
|
648
|
-
|
|
831
|
+
}), j.appendChild(e), $) {
|
|
832
|
+
const o = document.createElement("button");
|
|
833
|
+
o.type = "button", o.className = "ago-chat-widget__close", o.setAttribute("aria-label", "Close"), o.textContent = "×", E(o, {
|
|
649
834
|
marginLeft: "auto",
|
|
650
835
|
flexShrink: "0",
|
|
651
836
|
display: "flex",
|
|
@@ -656,40 +841,40 @@ function qn(n, o) {
|
|
|
656
841
|
margin: "-10px -10px -10px auto",
|
|
657
842
|
background: "transparent",
|
|
658
843
|
border: "none",
|
|
659
|
-
color:
|
|
844
|
+
color: Mt,
|
|
660
845
|
fontSize: "22px",
|
|
661
846
|
lineHeight: "1",
|
|
662
847
|
cursor: "pointer",
|
|
663
848
|
padding: "0"
|
|
664
|
-
}),
|
|
849
|
+
}), o.addEventListener("click", () => Oe()), j.appendChild(o);
|
|
665
850
|
}
|
|
666
851
|
}
|
|
667
|
-
const
|
|
852
|
+
const A = b({
|
|
668
853
|
flex: "1",
|
|
669
854
|
overflow: "auto",
|
|
670
855
|
overscrollBehavior: "contain",
|
|
671
856
|
padding: "16px",
|
|
672
|
-
backgroundColor:
|
|
857
|
+
backgroundColor: Pt
|
|
673
858
|
});
|
|
674
|
-
|
|
675
|
-
const
|
|
676
|
-
let
|
|
677
|
-
function
|
|
678
|
-
|
|
859
|
+
A.className = "ago-chat-widget__messages", A.setAttribute("role", "log"), A.setAttribute("aria-live", "polite"), A.setAttribute("aria-relevant", "additions text"), A.setAttribute("aria-atomic", "false");
|
|
860
|
+
const en = 48;
|
|
861
|
+
let de = !0, Ge = 0;
|
|
862
|
+
function _e(e) {
|
|
863
|
+
Ge++;
|
|
679
864
|
try {
|
|
680
865
|
e();
|
|
681
866
|
} finally {
|
|
682
|
-
const
|
|
683
|
-
|
|
867
|
+
const o = () => {
|
|
868
|
+
Ge--;
|
|
684
869
|
};
|
|
685
|
-
typeof queueMicrotask == "function" ? queueMicrotask(
|
|
870
|
+
typeof queueMicrotask == "function" ? queueMicrotask(o) : o();
|
|
686
871
|
}
|
|
687
872
|
}
|
|
688
|
-
function
|
|
689
|
-
return
|
|
873
|
+
function tn() {
|
|
874
|
+
return A.scrollHeight - A.scrollTop - A.clientHeight <= en;
|
|
690
875
|
}
|
|
691
|
-
const
|
|
692
|
-
|
|
876
|
+
const Z = document.createElement("button");
|
|
877
|
+
Z.type = "button", Z.className = "ago-chat-widget__jump", Z.setAttribute("aria-label", "Jump to latest message"), Z.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>', E(Z, {
|
|
693
878
|
position: "absolute",
|
|
694
879
|
left: "50%",
|
|
695
880
|
bottom: "12px",
|
|
@@ -699,162 +884,196 @@ function qn(n, o) {
|
|
|
699
884
|
display: "none",
|
|
700
885
|
alignItems: "center",
|
|
701
886
|
justifyContent: "center",
|
|
702
|
-
border: `1px solid ${
|
|
887
|
+
border: `1px solid ${R}`,
|
|
703
888
|
borderRadius: "50%",
|
|
704
|
-
backgroundColor:
|
|
705
|
-
color:
|
|
889
|
+
backgroundColor: Q,
|
|
890
|
+
color: F,
|
|
706
891
|
boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
|
|
707
892
|
cursor: "pointer",
|
|
708
893
|
zIndex: "2"
|
|
709
|
-
}),
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
}),
|
|
894
|
+
}), Z.addEventListener("click", () => {
|
|
895
|
+
de = !0, _e(() => {
|
|
896
|
+
A.scrollTop = A.scrollHeight;
|
|
897
|
+
}), je();
|
|
713
898
|
});
|
|
714
|
-
function
|
|
715
|
-
|
|
899
|
+
function je() {
|
|
900
|
+
Z.style.display = de ? "none" : "flex";
|
|
716
901
|
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}),
|
|
902
|
+
function Ve() {
|
|
903
|
+
de && _e(() => {
|
|
904
|
+
A.scrollTop = A.scrollHeight;
|
|
905
|
+
}), je();
|
|
721
906
|
}
|
|
722
|
-
|
|
723
|
-
|
|
907
|
+
A.addEventListener("scroll", () => {
|
|
908
|
+
Ge > 0 || (de = tn(), je());
|
|
724
909
|
});
|
|
725
|
-
const
|
|
910
|
+
const pt = b({
|
|
726
911
|
position: "relative",
|
|
727
912
|
flex: "1",
|
|
728
913
|
display: "flex",
|
|
729
914
|
minHeight: "0"
|
|
730
915
|
});
|
|
731
|
-
|
|
732
|
-
const { inputRow:
|
|
733
|
-
placeholder:
|
|
734
|
-
allowFiles:
|
|
735
|
-
onSend: (e,
|
|
736
|
-
|
|
916
|
+
pt.append(A, Z);
|
|
917
|
+
const { inputRow: qe, setDisabled: nn, focus: Re, restoreDraft: on } = zn({
|
|
918
|
+
placeholder: m,
|
|
919
|
+
allowFiles: a,
|
|
920
|
+
onSend: (e, o) => {
|
|
921
|
+
Te(e, o);
|
|
737
922
|
},
|
|
738
|
-
onStop:
|
|
739
|
-
|
|
923
|
+
onStop: x ? () => {
|
|
924
|
+
At();
|
|
740
925
|
} : void 0
|
|
741
926
|
});
|
|
742
|
-
|
|
743
|
-
let
|
|
744
|
-
const
|
|
745
|
-
if (
|
|
927
|
+
Mn(), l.append(...j ? [j] : [], pt, qe);
|
|
928
|
+
let Ie = l, O, H;
|
|
929
|
+
const Ne = w === "left" ? "left" : "right";
|
|
930
|
+
if ($ && (O = b({
|
|
746
931
|
position: "fixed",
|
|
747
932
|
top: "0",
|
|
748
933
|
bottom: "0",
|
|
749
|
-
[
|
|
750
|
-
width: typeof
|
|
934
|
+
[Ne]: "0",
|
|
935
|
+
width: typeof d == "number" ? `${d}px` : d,
|
|
751
936
|
maxWidth: "100vw",
|
|
752
937
|
display: "flex",
|
|
753
938
|
zIndex: "2147483000",
|
|
754
939
|
transition: "transform 0.3s ease",
|
|
755
940
|
boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
|
|
756
|
-
}),
|
|
941
|
+
}), O.className = "ago-chat-widget-panel", E(l, {
|
|
757
942
|
height: "100%",
|
|
758
943
|
width: "100%",
|
|
759
944
|
borderRadius: "0",
|
|
760
945
|
border: "none",
|
|
761
946
|
boxShadow: "none",
|
|
762
|
-
[
|
|
763
|
-
}),
|
|
764
|
-
if (H = document.createElement("button"), H.type = "button", H.className = "ago-chat-widget-launcher", H.setAttribute("aria-label", `Open ${
|
|
947
|
+
[Ne === "left" ? "borderRight" : "borderLeft"]: `1px solid ${R}`
|
|
948
|
+
}), O.appendChild(l), Ie = O), Xt) {
|
|
949
|
+
if (H = document.createElement("button"), H.type = "button", H.className = "ago-chat-widget-launcher", H.setAttribute("aria-label", `Open ${i}`), E(H, {
|
|
765
950
|
position: "fixed",
|
|
766
951
|
bottom: "20px",
|
|
767
|
-
[
|
|
952
|
+
[Ne]: "20px",
|
|
768
953
|
width: "56px",
|
|
769
954
|
height: "56px",
|
|
770
955
|
borderRadius: "50%",
|
|
771
956
|
border: "none",
|
|
772
|
-
backgroundColor:
|
|
773
|
-
color:
|
|
957
|
+
backgroundColor: Ce,
|
|
958
|
+
color: Ee,
|
|
774
959
|
cursor: "pointer",
|
|
775
960
|
display: "flex",
|
|
776
961
|
alignItems: "center",
|
|
777
962
|
justifyContent: "center",
|
|
778
963
|
zIndex: "2147483000",
|
|
779
964
|
boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
|
|
780
|
-
fontFamily:
|
|
781
|
-
}),
|
|
965
|
+
fontFamily: ze
|
|
966
|
+
}), h) {
|
|
782
967
|
const e = document.createElement("img");
|
|
783
|
-
e.src =
|
|
968
|
+
e.src = h, e.alt = "", E(e, {
|
|
784
969
|
width: "26px",
|
|
785
970
|
height: "26px",
|
|
786
971
|
objectFit: "contain"
|
|
787
972
|
}), H.appendChild(e);
|
|
788
|
-
} else H.appendChild(
|
|
789
|
-
H.addEventListener("click", () =>
|
|
973
|
+
} else H.appendChild(Jn());
|
|
974
|
+
H.addEventListener("click", () => Qe());
|
|
790
975
|
}
|
|
791
|
-
const
|
|
792
|
-
let X = !1,
|
|
793
|
-
const
|
|
794
|
-
height:
|
|
795
|
-
border:
|
|
796
|
-
borderRadius:
|
|
797
|
-
boxShadow:
|
|
976
|
+
const xe = ge ? `ago-vt-${++Zn}` : "", ut = 52;
|
|
977
|
+
let X = !1, ee = 0, ce = 0, V, we, te;
|
|
978
|
+
const Le = {
|
|
979
|
+
height: l.style.height,
|
|
980
|
+
border: l.style.border,
|
|
981
|
+
borderRadius: l.style.borderRadius,
|
|
982
|
+
boxShadow: l.style.boxShadow
|
|
798
983
|
};
|
|
799
|
-
|
|
800
|
-
if (X || !
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
984
|
+
dt.appendChild(Ie), H && dt.appendChild(H), $e(), ge && (V = wn(), l.insertBefore(V, l.firstChild), we = document.createElement("style"), we.id = xe, we.textContent = `::view-transition-group(${xe}),::view-transition-group(${xe}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(we), (We === "focus" || We === "tap") && (l.addEventListener("pointerdown", (e) => {
|
|
985
|
+
if (X || !z?.matches) return;
|
|
986
|
+
const o = qe.contains(e.target);
|
|
987
|
+
if (We === "tap") {
|
|
803
988
|
if ((e.target instanceof Element ? e.target : null)?.closest("button,a[href],[role='button']")) return;
|
|
804
|
-
} else if (!
|
|
805
|
-
|
|
806
|
-
}, !0),
|
|
807
|
-
|
|
808
|
-
}))),
|
|
809
|
-
const
|
|
810
|
-
|
|
811
|
-
})
|
|
812
|
-
|
|
813
|
-
|
|
989
|
+
} else if (!o) return;
|
|
990
|
+
o && e.preventDefault(), ye();
|
|
991
|
+
}, !0), l.addEventListener("focusin", (e) => {
|
|
992
|
+
z?.matches && qe.contains(e.target) && ye();
|
|
993
|
+
}))), Yt && document.addEventListener("keydown", Rt), z && z.addEventListener("change", It);
|
|
994
|
+
const rn = N !== !1, an = N === !1 ? void 0 : N ?? ((e) => {
|
|
995
|
+
ge && z?.matches && !X ? ye().then(() => Te(e)) : Te(e);
|
|
996
|
+
}), pe = g === !0 ? {} : g || null, sn = {
|
|
997
|
+
...Dt,
|
|
998
|
+
...pe?.labels,
|
|
999
|
+
reasons: {
|
|
1000
|
+
...Dt.reasons,
|
|
1001
|
+
...pe?.labels?.reasons
|
|
1002
|
+
}
|
|
1003
|
+
}, ft = /* @__PURE__ */ new Map();
|
|
1004
|
+
function ln(e) {
|
|
1005
|
+
if (!pe || !e.id || !e.conversationId || e.status !== "DONE" || !e.content) return null;
|
|
1006
|
+
let o = ft.get(e.id);
|
|
1007
|
+
o || (o = Un(), ft.set(e.id, o));
|
|
1008
|
+
const s = async (C, y) => {
|
|
1009
|
+
try {
|
|
1010
|
+
return await k.submitFeedback(e.id, C, y), pe.onSubmit?.({
|
|
1011
|
+
messageId: e.id,
|
|
1012
|
+
rating: C,
|
|
1013
|
+
reasons: y?.reasons ?? [],
|
|
1014
|
+
comment: y?.comment || void 0
|
|
1015
|
+
}), !0;
|
|
1016
|
+
} catch (M) {
|
|
1017
|
+
return pe.onError?.(M instanceof Error ? M : new Error(String(M))), !1;
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
return jn({
|
|
1021
|
+
state: o,
|
|
1022
|
+
labels: sn,
|
|
1023
|
+
askWhy: pe.askWhy ?? !0,
|
|
1024
|
+
onRate: (C) => {
|
|
1025
|
+
s(C);
|
|
1026
|
+
},
|
|
1027
|
+
onReport: (C, y) => s(C, y)
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
function mt(e) {
|
|
1031
|
+
const o = f.length - 1;
|
|
814
1032
|
return {
|
|
815
|
-
isLast: e ===
|
|
816
|
-
isLastOfBlock: e ===
|
|
817
|
-
bubbleStyle:
|
|
818
|
-
showAgentName:
|
|
819
|
-
agentBubble:
|
|
820
|
-
followUpEnabled:
|
|
821
|
-
followUpHandler:
|
|
822
|
-
isMobile: !!
|
|
1033
|
+
isLast: e === o,
|
|
1034
|
+
isLastOfBlock: e === o || f[e + 1].role !== f[e].role,
|
|
1035
|
+
bubbleStyle: L,
|
|
1036
|
+
showAgentName: _,
|
|
1037
|
+
agentBubble: I,
|
|
1038
|
+
followUpEnabled: rn,
|
|
1039
|
+
followUpHandler: an,
|
|
1040
|
+
isMobile: !!z?.matches,
|
|
1041
|
+
feedbackRow: ln(f[e])
|
|
823
1042
|
};
|
|
824
1043
|
}
|
|
825
|
-
function
|
|
826
|
-
if (
|
|
827
|
-
const e =
|
|
828
|
-
if (!
|
|
829
|
-
const
|
|
830
|
-
if (!
|
|
831
|
-
const
|
|
832
|
-
return
|
|
1044
|
+
function dn() {
|
|
1045
|
+
if (le || Ue.length > 0) return !1;
|
|
1046
|
+
const e = f.length - 1, o = f[e];
|
|
1047
|
+
if (!o || o.role !== "assistant") return !1;
|
|
1048
|
+
const s = ke[e];
|
|
1049
|
+
if (!s || s.parentNode !== A) return !1;
|
|
1050
|
+
const C = Ft(o, mt(e));
|
|
1051
|
+
return _e(() => A.replaceChild(C, s)), ke[e] = C, Ve(), !0;
|
|
833
1052
|
}
|
|
834
|
-
function
|
|
835
|
-
|
|
836
|
-
const e =
|
|
837
|
-
|
|
1053
|
+
function B() {
|
|
1054
|
+
_e(cn), Ve();
|
|
1055
|
+
const e = f[f.length - 1], o = K && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT");
|
|
1056
|
+
A.setAttribute("aria-busy", o ? "true" : "false"), nn(o);
|
|
838
1057
|
}
|
|
839
|
-
function
|
|
840
|
-
if (
|
|
841
|
-
if (
|
|
842
|
-
const e =
|
|
1058
|
+
function cn() {
|
|
1059
|
+
if (A.replaceChildren(), ke = [], f.length === 0) {
|
|
1060
|
+
if (st === "static") {
|
|
1061
|
+
const e = b({
|
|
843
1062
|
textAlign: "center",
|
|
844
|
-
color:
|
|
1063
|
+
color: he,
|
|
845
1064
|
padding: "24px 16px",
|
|
846
1065
|
fontSize: "16px",
|
|
847
1066
|
lineHeight: "1.5"
|
|
848
1067
|
});
|
|
849
|
-
e.appendChild(
|
|
1068
|
+
e.appendChild(rt(at)), A.appendChild(e);
|
|
850
1069
|
}
|
|
851
|
-
} else
|
|
852
|
-
const
|
|
853
|
-
|
|
1070
|
+
} else f.forEach((e, o) => {
|
|
1071
|
+
const s = Ft(e, mt(o));
|
|
1072
|
+
ke[o] = s, A.appendChild(s);
|
|
854
1073
|
});
|
|
855
|
-
for (const e of
|
|
856
|
-
if (
|
|
857
|
-
const e =
|
|
1074
|
+
for (const e of Ue) A.appendChild(Xn(e));
|
|
1075
|
+
if (le) {
|
|
1076
|
+
const e = b({
|
|
858
1077
|
padding: "10px 14px",
|
|
859
1078
|
backgroundColor: "#fef2f2",
|
|
860
1079
|
color: "#dc2626",
|
|
@@ -863,37 +1082,37 @@ function qn(n, o) {
|
|
|
863
1082
|
fontSize: "13px",
|
|
864
1083
|
border: "1px solid #fecaca"
|
|
865
1084
|
});
|
|
866
|
-
e.setAttribute("role", "alert"), e.textContent =
|
|
1085
|
+
e.setAttribute("role", "alert"), e.textContent = le, A.appendChild(e);
|
|
867
1086
|
}
|
|
868
1087
|
}
|
|
869
|
-
function
|
|
870
|
-
for (let e =
|
|
871
|
-
const
|
|
872
|
-
if (
|
|
1088
|
+
function ht() {
|
|
1089
|
+
for (let e = f.length - 1; e >= 0; e--) {
|
|
1090
|
+
const o = f[e];
|
|
1091
|
+
if (o.role === "assistant" && (o.status === "IN_PROGRESS" || o.status === "WAITING_CLIENT")) return o;
|
|
873
1092
|
}
|
|
874
1093
|
}
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
},
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
},
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
},
|
|
884
|
-
const
|
|
885
|
-
|
|
1094
|
+
const gt = (e) => {
|
|
1095
|
+
q || (q = e.conversationId);
|
|
1096
|
+
}, bt = (e) => {
|
|
1097
|
+
const o = ht();
|
|
1098
|
+
o && (o.content += e.content, dn() || B());
|
|
1099
|
+
}, xt = (e) => {
|
|
1100
|
+
const o = f.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
1101
|
+
o >= 0 ? f[o] = e : f.push(e), B(), Je() || Re();
|
|
1102
|
+
}, wt = (e) => {
|
|
1103
|
+
const o = f.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
1104
|
+
o >= 0 ? f[o] = e : f.push(e), K = !1, B(), e.status === "DONE" && U?.({
|
|
886
1105
|
id: e.id,
|
|
887
1106
|
content: e.content
|
|
888
1107
|
});
|
|
889
|
-
},
|
|
890
|
-
const e =
|
|
891
|
-
e && (e.content ? e.status = "CANCELED" :
|
|
892
|
-
},
|
|
893
|
-
|
|
1108
|
+
}, yt = () => {
|
|
1109
|
+
const e = ht();
|
|
1110
|
+
e && (e.content ? e.status = "CANCELED" : f = f.filter((o) => o !== e)), K = !1, B();
|
|
1111
|
+
}, vt = (e) => {
|
|
1112
|
+
le = e.error, K = !1, f = f.filter((o) => !o.id.startsWith("temp-")), B();
|
|
894
1113
|
};
|
|
895
|
-
function
|
|
896
|
-
const
|
|
1114
|
+
function pn(e) {
|
|
1115
|
+
const o = {
|
|
897
1116
|
id: `ago-intro-${Date.now()}`,
|
|
898
1117
|
conversationId: "",
|
|
899
1118
|
content: "",
|
|
@@ -901,232 +1120,232 @@ function qn(n, o) {
|
|
|
901
1120
|
status: "IN_PROGRESS",
|
|
902
1121
|
createdAt: /* @__PURE__ */ new Date()
|
|
903
1122
|
};
|
|
904
|
-
|
|
905
|
-
const
|
|
906
|
-
let
|
|
907
|
-
|
|
908
|
-
if (
|
|
909
|
-
clearInterval(
|
|
1123
|
+
f.push(o), B();
|
|
1124
|
+
const s = e.match(/\S+\s*/g) ?? [e];
|
|
1125
|
+
let C = 0;
|
|
1126
|
+
Y = setInterval(() => {
|
|
1127
|
+
if (C >= s.length) {
|
|
1128
|
+
clearInterval(Y), Y = void 0, o.status = "DONE", lt && (o.followUpReplies = lt), B();
|
|
910
1129
|
return;
|
|
911
1130
|
}
|
|
912
|
-
|
|
913
|
-
},
|
|
1131
|
+
o.content += s[C], C++, B();
|
|
1132
|
+
}, Kt);
|
|
914
1133
|
}
|
|
915
|
-
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
const
|
|
919
|
-
let
|
|
920
|
-
const
|
|
921
|
-
if (
|
|
922
|
-
|
|
923
|
-
let
|
|
924
|
-
const
|
|
925
|
-
|
|
1134
|
+
k.on("message:start", gt), k.on("message:chunk", bt), k.on("message:answer-complete", xt), k.on("message:complete", wt), k.on("message:stopped", yt), k.on("message:error", vt);
|
|
1135
|
+
const Ct = (e) => oe?.(e), Et = (e) => T?.(e);
|
|
1136
|
+
oe && k.on("form:submitted", Ct), T && k.on("form:error", Et);
|
|
1137
|
+
const Ke = [];
|
|
1138
|
+
let St = !1;
|
|
1139
|
+
const kt = (e) => {
|
|
1140
|
+
if (St) return;
|
|
1141
|
+
Ke.push(e.install(k));
|
|
1142
|
+
let o = e.store.get().submitted;
|
|
1143
|
+
const s = e.store.subscribe((C) => {
|
|
1144
|
+
C.submitted && !o && (Ue.push(Zt(C.submitResult)), B()), o = C.submitted;
|
|
926
1145
|
});
|
|
927
|
-
|
|
1146
|
+
Ke.push(s);
|
|
928
1147
|
};
|
|
929
|
-
for (const e of
|
|
1148
|
+
for (const e of S ?? []) e.schema != null ? kt(Ln(e)) : Nn(k, e).then((o) => kt(o)).catch(() => {
|
|
930
1149
|
});
|
|
931
|
-
async function
|
|
932
|
-
const
|
|
933
|
-
if (!
|
|
934
|
-
if (
|
|
935
|
-
clearInterval(
|
|
936
|
-
const
|
|
937
|
-
|
|
1150
|
+
async function Te(e, o) {
|
|
1151
|
+
const s = e.trim();
|
|
1152
|
+
if (!s && !o?.length || K) return;
|
|
1153
|
+
if (P?.(s), K = !0, le = null, de = !0, Y) {
|
|
1154
|
+
clearInterval(Y), Y = void 0;
|
|
1155
|
+
const y = f.find((M) => M.id.startsWith("ago-intro-"));
|
|
1156
|
+
y && !y.content ? f = f.filter((M) => M !== y) : y && (y.status = "DONE");
|
|
938
1157
|
}
|
|
939
|
-
const
|
|
940
|
-
|
|
941
|
-
id: `temp-user-${
|
|
942
|
-
conversationId:
|
|
943
|
-
content:
|
|
1158
|
+
const C = Date.now();
|
|
1159
|
+
f.push({
|
|
1160
|
+
id: `temp-user-${C}`,
|
|
1161
|
+
conversationId: q || "",
|
|
1162
|
+
content: s,
|
|
944
1163
|
role: "user",
|
|
945
1164
|
status: "DONE",
|
|
946
|
-
attachments:
|
|
1165
|
+
attachments: o && o.length > 0 ? Cn(o) : void 0,
|
|
947
1166
|
createdAt: /* @__PURE__ */ new Date()
|
|
948
|
-
}),
|
|
949
|
-
id: `temp-assistant-${
|
|
950
|
-
conversationId:
|
|
1167
|
+
}), f.push({
|
|
1168
|
+
id: `temp-assistant-${C}`,
|
|
1169
|
+
conversationId: q || "",
|
|
951
1170
|
content: "",
|
|
952
1171
|
role: "assistant",
|
|
953
1172
|
status: "IN_PROGRESS",
|
|
954
1173
|
createdAt: /* @__PURE__ */ new Date()
|
|
955
|
-
}),
|
|
1174
|
+
}), B();
|
|
956
1175
|
try {
|
|
957
|
-
const
|
|
958
|
-
conversationId:
|
|
959
|
-
files:
|
|
1176
|
+
const y = await k.sendMessage(s, {
|
|
1177
|
+
conversationId: q,
|
|
1178
|
+
files: o
|
|
960
1179
|
});
|
|
961
|
-
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
|
|
1180
|
+
y.conversationId && (q || (q = y.conversationId), Se?.setActiveThread(y.conversationId, y.createdAt));
|
|
1181
|
+
const M = f.find((ne) => ne.id === `temp-user-${C}`);
|
|
1182
|
+
if (M && (M.id = `user-${C}`, M.conversationId = y.conversationId), y.id && !f.some((ne) => ne.id === y.id)) {
|
|
1183
|
+
const ne = f.findIndex((vn) => vn.id === `temp-assistant-${C}`);
|
|
1184
|
+
ne >= 0 ? f[ne] = y : f.push(y);
|
|
966
1185
|
}
|
|
967
|
-
|
|
968
|
-
} catch (
|
|
969
|
-
|
|
1186
|
+
f = f.filter((ne) => !ne.id.startsWith("temp-")), y.status !== "WAITING_CLIENT" && (K = !1), B(), v && Xe();
|
|
1187
|
+
} catch (y) {
|
|
1188
|
+
le = y instanceof Error ? y.message : "Failed to send message", K = !1, f = f.filter((M) => !M.id.startsWith("temp-")), on(s, o), B();
|
|
970
1189
|
}
|
|
971
1190
|
}
|
|
972
|
-
async function
|
|
973
|
-
|
|
1191
|
+
async function At() {
|
|
1192
|
+
K && await k.stop();
|
|
974
1193
|
}
|
|
975
|
-
async function
|
|
1194
|
+
async function Xe() {
|
|
976
1195
|
try {
|
|
977
|
-
const { data: e } = await
|
|
978
|
-
|
|
1196
|
+
const { data: e } = await k.getConversations();
|
|
1197
|
+
Ae.splice(0, Ae.length, ...e);
|
|
979
1198
|
} catch {
|
|
980
1199
|
}
|
|
981
|
-
return
|
|
1200
|
+
return Ae;
|
|
982
1201
|
}
|
|
983
|
-
async function
|
|
1202
|
+
async function un(e) {
|
|
984
1203
|
try {
|
|
985
|
-
const
|
|
986
|
-
|
|
1204
|
+
const o = (await k.getConversation(e))?.messages ?? [];
|
|
1205
|
+
o.length > 0 && f.length === 0 && (f = o, B());
|
|
987
1206
|
} catch {
|
|
988
|
-
|
|
1207
|
+
f.length === 0 && (Se?.clear(), q = void 0);
|
|
989
1208
|
}
|
|
990
1209
|
}
|
|
991
|
-
return
|
|
992
|
-
client:
|
|
993
|
-
element:
|
|
994
|
-
sendMessage:
|
|
995
|
-
stop:
|
|
996
|
-
|
|
997
|
-
open:
|
|
998
|
-
close:
|
|
999
|
-
toggle:
|
|
1210
|
+
return B(), ge && z?.matches || Re(), q ? un(q) : st === "streaming" && pn(at), v && Xe(), {
|
|
1211
|
+
client: k,
|
|
1212
|
+
element: Ie,
|
|
1213
|
+
sendMessage: Te,
|
|
1214
|
+
stop: At,
|
|
1215
|
+
...$ || ge ? {
|
|
1216
|
+
open: mn,
|
|
1217
|
+
close: hn,
|
|
1218
|
+
toggle: gn
|
|
1000
1219
|
} : {},
|
|
1001
|
-
session:
|
|
1002
|
-
threads:
|
|
1003
|
-
refreshThreads:
|
|
1220
|
+
session: Se,
|
|
1221
|
+
threads: Ae,
|
|
1222
|
+
refreshThreads: Xe,
|
|
1004
1223
|
destroy() {
|
|
1005
|
-
se || (se = !0,
|
|
1224
|
+
se || (se = !0, Y && clearInterval(Y), k.off("message:start", gt), k.off("message:chunk", bt), k.off("message:answer-complete", xt), k.off("message:complete", wt), k.off("message:stopped", yt), k.off("message:error", vt), oe && k.off("form:submitted", Ct), T && k.off("form:error", Et), St = !0, Ke.forEach((e) => e()), Ie.remove(), H?.remove(), V?.remove(), we?.remove(), te?.remove(), z?.removeEventListener("change", It), document.removeEventListener("keydown", Rt), et(), Fe = !1, tt(be), t.client || k.destroy());
|
|
1006
1225
|
}
|
|
1007
1226
|
};
|
|
1008
|
-
function
|
|
1009
|
-
if (
|
|
1227
|
+
function $e() {
|
|
1228
|
+
if (!O) return;
|
|
1010
1229
|
{
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1230
|
+
const s = Ne === "left" ? "border-right" : "border-left";
|
|
1231
|
+
z?.matches ? (O.style.width = "100%", l.style.borderRadius = "0", l.style.removeProperty(s)) : (O.style.width = typeof d == "number" ? `${d}px` : d, l.style.setProperty(s, `1px solid ${R}`));
|
|
1013
1232
|
}
|
|
1014
|
-
const e =
|
|
1015
|
-
|
|
1016
|
-
const
|
|
1017
|
-
|
|
1233
|
+
const e = w === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
1234
|
+
O.style.transform = re ? "translateX(0)" : e, O.setAttribute("aria-hidden", re ? "false" : "true"), H && (H.style.display = re ? "none" : "flex");
|
|
1235
|
+
const o = _t();
|
|
1236
|
+
o !== Fe && (Fe = o, o ? (l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "true"), l.setAttribute("aria-label", i), l.tabIndex = -1, l.style.paddingBottom = "env(safe-area-inset-bottom)", Ot(be), ee = Ye(), Ze(), Nt()) : (et(), xn(), ee = 0, l.removeAttribute("role"), l.removeAttribute("aria-modal"), l.removeAttribute("aria-label"), l.style.removeProperty("padding-bottom"), tt(be)));
|
|
1018
1237
|
}
|
|
1019
|
-
function
|
|
1020
|
-
|
|
1238
|
+
function Qe() {
|
|
1239
|
+
re = !0, $e(), Je() ? l.focus({ preventScroll: !0 }) : Re(), J?.();
|
|
1021
1240
|
}
|
|
1022
|
-
function
|
|
1023
|
-
|
|
1241
|
+
function Oe() {
|
|
1242
|
+
re = !1, $e(), it?.();
|
|
1024
1243
|
}
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1244
|
+
function fn() {
|
|
1245
|
+
re ? Oe() : Qe();
|
|
1027
1246
|
}
|
|
1028
|
-
function
|
|
1029
|
-
|
|
1247
|
+
function mn() {
|
|
1248
|
+
$ ? Qe() : ye();
|
|
1030
1249
|
}
|
|
1031
|
-
function
|
|
1032
|
-
|
|
1250
|
+
function hn() {
|
|
1251
|
+
$ ? Oe() : ve();
|
|
1033
1252
|
}
|
|
1034
|
-
function
|
|
1035
|
-
|
|
1253
|
+
function gn() {
|
|
1254
|
+
$ ? fn() : X ? ve() : ye();
|
|
1036
1255
|
}
|
|
1037
|
-
function
|
|
1038
|
-
return !!
|
|
1256
|
+
function Je() {
|
|
1257
|
+
return !!z?.matches;
|
|
1039
1258
|
}
|
|
1040
|
-
function
|
|
1041
|
-
return
|
|
1259
|
+
function _t() {
|
|
1260
|
+
return Je() && ($ ? re : X);
|
|
1042
1261
|
}
|
|
1043
|
-
function
|
|
1044
|
-
return Array.from(
|
|
1262
|
+
function bn() {
|
|
1263
|
+
return Array.from(l.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
|
|
1045
1264
|
}
|
|
1046
|
-
function
|
|
1047
|
-
if (!
|
|
1265
|
+
function Rt(e) {
|
|
1266
|
+
if (!_t()) return;
|
|
1048
1267
|
if (e.key === "Escape") {
|
|
1049
|
-
|
|
1268
|
+
$ ? Oe() : ve();
|
|
1050
1269
|
return;
|
|
1051
1270
|
}
|
|
1052
1271
|
if (e.key !== "Tab") return;
|
|
1053
|
-
const
|
|
1054
|
-
if (
|
|
1272
|
+
const o = bn();
|
|
1273
|
+
if (o.length === 0) {
|
|
1055
1274
|
e.preventDefault();
|
|
1056
1275
|
return;
|
|
1057
1276
|
}
|
|
1058
|
-
const
|
|
1059
|
-
e.shiftKey && (
|
|
1277
|
+
const s = o[0], C = o[o.length - 1], y = document.activeElement;
|
|
1278
|
+
e.shiftKey && (y === s || !l.contains(y)) ? (e.preventDefault(), C.focus()) : !e.shiftKey && (y === C || !l.contains(y)) && (e.preventDefault(), s.focus());
|
|
1060
1279
|
}
|
|
1061
|
-
function
|
|
1062
|
-
|
|
1280
|
+
function It(e) {
|
|
1281
|
+
$ ? $e() : !e.matches && X && ve(), B();
|
|
1063
1282
|
}
|
|
1064
|
-
function
|
|
1283
|
+
function Ye() {
|
|
1065
1284
|
return window.visualViewport?.height ?? window.innerHeight;
|
|
1066
1285
|
}
|
|
1067
|
-
function
|
|
1068
|
-
const e = window.visualViewport,
|
|
1069
|
-
if (
|
|
1070
|
-
if (
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1286
|
+
function Ze() {
|
|
1287
|
+
const e = window.visualViewport, o = e?.offsetTop ?? 0, s = e?.height ?? ee;
|
|
1288
|
+
if ($) {
|
|
1289
|
+
if (!O) return;
|
|
1290
|
+
const y = window.innerHeight || ee, M = Math.max(0, y - (o + s));
|
|
1291
|
+
O.style.bottom = `${M}px`, O.style.top = `${o}px`;
|
|
1073
1292
|
return;
|
|
1074
1293
|
}
|
|
1075
|
-
const
|
|
1076
|
-
|
|
1294
|
+
const C = Math.min(0, o + s - ee);
|
|
1295
|
+
l.style.top = `${C}px`, V && (V.style.top = `${o}px`);
|
|
1077
1296
|
}
|
|
1078
|
-
function
|
|
1079
|
-
|
|
1297
|
+
function xn() {
|
|
1298
|
+
$ && O && (O.style.removeProperty("bottom"), O.style.removeProperty("top"));
|
|
1080
1299
|
}
|
|
1081
|
-
function
|
|
1082
|
-
|
|
1083
|
-
|
|
1300
|
+
function Be() {
|
|
1301
|
+
ce || (ce = requestAnimationFrame(() => {
|
|
1302
|
+
ce = 0, !se && Ze();
|
|
1084
1303
|
}));
|
|
1085
1304
|
}
|
|
1086
|
-
function
|
|
1087
|
-
window.visualViewport?.addEventListener("resize",
|
|
1305
|
+
function Nt() {
|
|
1306
|
+
window.visualViewport?.addEventListener("resize", Be), window.visualViewport?.addEventListener("scroll", Be);
|
|
1088
1307
|
}
|
|
1089
|
-
function
|
|
1090
|
-
window.visualViewport?.removeEventListener("resize",
|
|
1308
|
+
function et() {
|
|
1309
|
+
window.visualViewport?.removeEventListener("resize", Be), window.visualViewport?.removeEventListener("scroll", Be), ce && (cancelAnimationFrame(ce), ce = 0);
|
|
1091
1310
|
}
|
|
1092
|
-
function
|
|
1093
|
-
|
|
1311
|
+
function Lt() {
|
|
1312
|
+
de = !0, Ve();
|
|
1094
1313
|
}
|
|
1095
|
-
function
|
|
1096
|
-
const e =
|
|
1314
|
+
function wn() {
|
|
1315
|
+
const e = b({
|
|
1097
1316
|
position: "fixed",
|
|
1098
1317
|
top: "0",
|
|
1099
1318
|
left: "0",
|
|
1100
1319
|
right: "0",
|
|
1101
|
-
height: `calc(${
|
|
1320
|
+
height: `calc(${ut}px + env(safe-area-inset-top))`,
|
|
1102
1321
|
display: "none",
|
|
1103
1322
|
alignItems: "center",
|
|
1104
1323
|
justifyContent: "space-between",
|
|
1105
1324
|
padding: "env(safe-area-inset-top) 14px 0",
|
|
1106
|
-
backgroundColor:
|
|
1107
|
-
borderBottom: `1px solid ${
|
|
1325
|
+
backgroundColor: Q,
|
|
1326
|
+
borderBottom: `1px solid ${R}`,
|
|
1108
1327
|
zIndex: "2147483001",
|
|
1109
|
-
fontFamily:
|
|
1328
|
+
fontFamily: ze
|
|
1110
1329
|
});
|
|
1111
|
-
if (e.className = "ago-chat-widget-mobile-bar",
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1330
|
+
if (e.className = "ago-chat-widget-mobile-bar", h) {
|
|
1331
|
+
const s = document.createElement("img");
|
|
1332
|
+
s.src = h, s.alt = "", E(s, {
|
|
1114
1333
|
height: "28px",
|
|
1115
1334
|
width: "auto"
|
|
1116
|
-
}), e.appendChild(
|
|
1117
|
-
} else if (
|
|
1118
|
-
const
|
|
1119
|
-
|
|
1335
|
+
}), e.appendChild(s);
|
|
1336
|
+
} else if (i) {
|
|
1337
|
+
const s = document.createElement("span");
|
|
1338
|
+
s.textContent = i, E(s, {
|
|
1120
1339
|
fontSize: "15px",
|
|
1121
1340
|
fontWeight: "600",
|
|
1122
|
-
color:
|
|
1341
|
+
color: F,
|
|
1123
1342
|
overflow: "hidden",
|
|
1124
1343
|
whiteSpace: "nowrap",
|
|
1125
1344
|
textOverflow: "ellipsis"
|
|
1126
|
-
}), e.appendChild(
|
|
1127
|
-
} else e.appendChild(
|
|
1128
|
-
const
|
|
1129
|
-
return
|
|
1345
|
+
}), e.appendChild(s);
|
|
1346
|
+
} else e.appendChild(b({}));
|
|
1347
|
+
const o = document.createElement("button");
|
|
1348
|
+
return o.type = "button", o.setAttribute("aria-label", "Close"), o.textContent = "×", E(o, {
|
|
1130
1349
|
flexShrink: "0",
|
|
1131
1350
|
width: "44px",
|
|
1132
1351
|
height: "44px",
|
|
@@ -1138,30 +1357,30 @@ function qn(n, o) {
|
|
|
1138
1357
|
background: "transparent",
|
|
1139
1358
|
fontSize: "26px",
|
|
1140
1359
|
lineHeight: "1",
|
|
1141
|
-
color:
|
|
1360
|
+
color: F,
|
|
1142
1361
|
cursor: "pointer",
|
|
1143
1362
|
padding: "0"
|
|
1144
|
-
}),
|
|
1145
|
-
|
|
1146
|
-
}), e.appendChild(
|
|
1363
|
+
}), o.addEventListener("click", () => {
|
|
1364
|
+
ve();
|
|
1365
|
+
}), e.appendChild(o), e;
|
|
1147
1366
|
}
|
|
1148
|
-
function
|
|
1149
|
-
return typeof document.startViewTransition == "function" && !
|
|
1367
|
+
function yn() {
|
|
1368
|
+
return typeof document.startViewTransition == "function" && !Jt?.matches && !!z?.matches;
|
|
1150
1369
|
}
|
|
1151
|
-
function
|
|
1152
|
-
const
|
|
1153
|
-
if (
|
|
1154
|
-
|
|
1155
|
-
const
|
|
1156
|
-
|
|
1370
|
+
function Tt(e) {
|
|
1371
|
+
const o = document;
|
|
1372
|
+
if (yn() && o.startViewTransition) {
|
|
1373
|
+
l.style.setProperty("view-transition-name", xe), V?.style.setProperty("view-transition-name", `${xe}-bar`);
|
|
1374
|
+
const s = () => {
|
|
1375
|
+
l.style.removeProperty("view-transition-name"), V?.style.removeProperty("view-transition-name");
|
|
1157
1376
|
};
|
|
1158
|
-
return
|
|
1377
|
+
return o.startViewTransition(e).finished.then(s, s);
|
|
1159
1378
|
}
|
|
1160
1379
|
return e(), Promise.resolve();
|
|
1161
1380
|
}
|
|
1162
|
-
function
|
|
1381
|
+
function $t(e) {
|
|
1163
1382
|
if (e)
|
|
1164
|
-
|
|
1383
|
+
te && l.parentElement?.insertBefore(te, l), E(l, {
|
|
1165
1384
|
position: "fixed",
|
|
1166
1385
|
top: "0",
|
|
1167
1386
|
left: "0",
|
|
@@ -1172,12 +1391,12 @@ function qn(n, o) {
|
|
|
1172
1391
|
border: "none",
|
|
1173
1392
|
borderRadius: "0",
|
|
1174
1393
|
boxShadow: "none",
|
|
1175
|
-
paddingTop: `calc(${
|
|
1394
|
+
paddingTop: `calc(${ut}px + env(safe-area-inset-top))`,
|
|
1176
1395
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
1177
|
-
}),
|
|
1396
|
+
}), l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "true"), l.setAttribute("aria-label", i), j && (j.style.display = "none"), V && (V.style.display = "flex");
|
|
1178
1397
|
else {
|
|
1179
|
-
|
|
1180
|
-
for (const
|
|
1398
|
+
te?.remove(), te = void 0;
|
|
1399
|
+
for (const o of [
|
|
1181
1400
|
"position",
|
|
1182
1401
|
"top",
|
|
1183
1402
|
"left",
|
|
@@ -1186,35 +1405,36 @@ function qn(n, o) {
|
|
|
1186
1405
|
"z-index",
|
|
1187
1406
|
"padding-top",
|
|
1188
1407
|
"padding-bottom"
|
|
1189
|
-
])
|
|
1190
|
-
|
|
1408
|
+
]) l.style.removeProperty(o);
|
|
1409
|
+
l.style.height = Le.height, l.style.border = Le.border, l.style.borderRadius = Le.borderRadius, l.style.boxShadow = Le.boxShadow, l.removeAttribute("role"), l.removeAttribute("aria-modal"), l.removeAttribute("aria-label"), j && (j.style.display = "flex"), V && (V.style.display = "none");
|
|
1191
1410
|
}
|
|
1192
1411
|
}
|
|
1193
|
-
function
|
|
1194
|
-
if (se || X || !
|
|
1195
|
-
const e =
|
|
1196
|
-
if (e.height >=
|
|
1197
|
-
X = !0,
|
|
1412
|
+
function ye() {
|
|
1413
|
+
if (se || X || !z?.matches) return Promise.resolve();
|
|
1414
|
+
const e = l.getBoundingClientRect();
|
|
1415
|
+
if (e.height >= Ye() * 0.8) return Promise.resolve();
|
|
1416
|
+
X = !0, te = b({
|
|
1198
1417
|
width: `${e.width}px`,
|
|
1199
1418
|
height: `${e.height}px`
|
|
1200
|
-
}),
|
|
1201
|
-
const
|
|
1202
|
-
return
|
|
1203
|
-
se || (
|
|
1204
|
-
}),
|
|
1419
|
+
}), te.className = "ago-chat-widget-spacer", te.setAttribute("aria-hidden", "true"), ee = Ye(), l.style.setProperty("--ago-vh", `${ee}px`), Ze(), Nt(), Ot(be);
|
|
1420
|
+
const o = Tt(() => $t(!0));
|
|
1421
|
+
return o.then(() => {
|
|
1422
|
+
se || (Lt(), Re());
|
|
1423
|
+
}), Lt(), J?.(), o;
|
|
1205
1424
|
}
|
|
1206
|
-
function
|
|
1425
|
+
function ve() {
|
|
1207
1426
|
if (!X) return Promise.resolve();
|
|
1208
|
-
X = !1,
|
|
1209
|
-
const e =
|
|
1427
|
+
X = !1, et(), tt(be), l.querySelector("textarea")?.blur();
|
|
1428
|
+
const e = Tt(() => $t(!1));
|
|
1210
1429
|
return e.then(() => {
|
|
1211
|
-
se ||
|
|
1212
|
-
}),
|
|
1430
|
+
se || l.style.removeProperty("--ago-vh");
|
|
1431
|
+
}), ee = 0, it?.(), e;
|
|
1213
1432
|
}
|
|
1214
1433
|
}
|
|
1215
1434
|
export {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1435
|
+
Dt as DEFAULT_FEEDBACK_LABELS,
|
|
1436
|
+
lo as compactMediaQuery,
|
|
1437
|
+
so as createSheetController,
|
|
1438
|
+
co as mountChatWidget,
|
|
1439
|
+
rt as renderMarkdown
|
|
1220
1440
|
};
|