@useago/sdk 1.5.0 → 1.5.2
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 +48 -0
- package/dist/AgoClient-5VGybmvz.cjs +8 -0
- package/dist/AgoClient-DXrH2AMi.js +964 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +79 -2
- package/dist/angular.d.ts +79 -2
- package/dist/angular.js +2 -2
- package/dist/{createConversationSession-BBYfQLLS.cjs → createConversationSession-0WTqcCLK.cjs} +1 -1
- package/dist/{createConversationSession-DCSWShaW.js → createConversationSession-DPrrr70o.js} +1 -1
- package/dist/createFormCollector-1GKKwQV_.cjs +1 -0
- package/dist/{createFormCollector-sB6rMccD.js → createFormCollector-DYh90kiG.js} +97 -91
- package/dist/devtools.d.cts +79 -2
- package/dist/devtools.d.ts +79 -2
- package/dist/functions-CPs7omgM.cjs +1 -0
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.d.cts +5 -0
- package/dist/helpers.d.ts +5 -0
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +95 -4
- package/dist/index.d.ts +95 -4
- package/dist/index.js +6 -6
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +186 -4
- package/dist/react.d.ts +186 -4
- package/dist/react.js +670 -475
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +79 -2
- package/dist/testing.d.ts +79 -2
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +79 -2
- package/dist/vue.d.ts +79 -2
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +79 -2
- package/dist/widget.d.ts +79 -2
- package/dist/widget.js +437 -423
- package/llms-full.txt +74 -2
- package/package.json +1 -1
- package/dist/AgoClient-q39FIjSC.js +0 -912
- package/dist/AgoClient-wcPRaIMs.cjs +0 -8
- package/dist/createFormCollector-eimwwWEi.cjs +0 -1
- package/dist/functions-IGSjjvF4.cjs +0 -1
- package/dist/rolldown-runtime-16Nf8qvH.cjs +0 -1
- /package/dist/{autoContinue-D3Mmaaca.js → autoContinue-CC8K9mBU.js} +0 -0
- /package/dist/{autoContinue-CcCTva-D.cjs → autoContinue-CP9pJR-V.cjs} +0 -0
- /package/dist/{createMockClient-CjdCqixj.cjs → createMockClient-C-wrjb2C.cjs} +0 -0
- /package/dist/{createMockClient-BUc9PSbo.js → createMockClient-we-XoPom.js} +0 -0
- /package/dist/{functions-CApuQZ2b.js → functions-tzyOZNp6.js} +0 -0
package/dist/widget.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { r as
|
|
3
|
-
import { t as
|
|
4
|
-
var
|
|
1
|
+
import { a as qt, i as Kt, m as Xt, o as Yt, s as Qt, t as Zt } from "./AgoClient-DXrH2AMi.js";
|
|
2
|
+
import { r as Jt, t as en } from "./createFormCollector-DYh90kiG.js";
|
|
3
|
+
import { t as tn } from "./createConversationSession-DPrrr70o.js";
|
|
4
|
+
var nn = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', ke = `var(--ago-font, ${nn})`, ut = {
|
|
5
5
|
font: "--ago-font",
|
|
6
6
|
radius: "--ago-radius",
|
|
7
7
|
messageRadius: "--ago-message-radius",
|
|
@@ -16,28 +16,28 @@ var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto
|
|
|
16
16
|
border: "--ago-border-color",
|
|
17
17
|
accent: "--ago-accent-color",
|
|
18
18
|
agentBubbleBg: "--ago-agent-bubble-background"
|
|
19
|
-
},
|
|
20
|
-
function
|
|
19
|
+
}, Ae = "var(--ago-brand-color, #03182f)", _e = "var(--ago-brand-text-color, #fff)", on = "var(--ago-header-background, var(--ago-brand-color, #03182f))", mt = "var(--ago-header-text-color, #e8f0fe)", te = "var(--ago-panel-background, #fff)", yt = "var(--ago-messages-background, #fbfbfb)", ee = "var(--ago-text-color, #30373e)", wt = "var(--ago-muted-text-color, #6b6d6f)", N = "var(--ago-border-color, #dee3e8)", De = "var(--ago-accent-color, #1b5fc4)", gt = "var(--ago-agent-bubble-background, #f1f3f5)", rn = "var(--ago-radius, 16px)", ze = "var(--ago-message-radius, 16px)", an = "var(--ago-message-radius, 20px)";
|
|
20
|
+
function sn(t, o) {
|
|
21
21
|
if (o)
|
|
22
|
-
for (const i of Object.keys(
|
|
22
|
+
for (const i of Object.keys(ut)) {
|
|
23
23
|
const r = o[i];
|
|
24
|
-
r != null &&
|
|
24
|
+
r != null && t.style.setProperty(ut[i], r);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function v(
|
|
28
|
-
Object.assign(
|
|
27
|
+
function v(t, o) {
|
|
28
|
+
Object.assign(t.style, o);
|
|
29
29
|
}
|
|
30
|
-
function h(
|
|
30
|
+
function h(t = {}) {
|
|
31
31
|
const o = document.createElement("div");
|
|
32
|
-
return v(o,
|
|
32
|
+
return v(o, t), o;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
35
|
-
function
|
|
36
|
-
if (typeof document > "u" || document.getElementById(
|
|
37
|
-
const
|
|
38
|
-
|
|
34
|
+
var ht = "ago-chat-widget-keyframes";
|
|
35
|
+
function ln() {
|
|
36
|
+
if (typeof document > "u" || document.getElementById(ht)) return;
|
|
37
|
+
const t = document.createElement("style");
|
|
38
|
+
t.id = ht, t.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }@keyframes ago-spin { to { transform: rotate(360deg); } }", document.head.appendChild(t);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function dn(t) {
|
|
41
41
|
let o = [];
|
|
42
42
|
const i = document.createElement("form");
|
|
43
43
|
v(i, {
|
|
@@ -45,8 +45,8 @@ function on(n) {
|
|
|
45
45
|
flexDirection: "column",
|
|
46
46
|
gap: "8px",
|
|
47
47
|
padding: "12px",
|
|
48
|
-
borderTop: `1px solid ${
|
|
49
|
-
backgroundColor:
|
|
48
|
+
borderTop: `1px solid ${N}`,
|
|
49
|
+
backgroundColor: te
|
|
50
50
|
}), i.className = "ago-chat-input";
|
|
51
51
|
const r = h({
|
|
52
52
|
display: "flex",
|
|
@@ -57,15 +57,15 @@ function on(n) {
|
|
|
57
57
|
gap: "8px",
|
|
58
58
|
alignItems: "flex-end"
|
|
59
59
|
}), a = document.createElement("textarea");
|
|
60
|
-
a.placeholder =
|
|
60
|
+
a.placeholder = t.placeholder, a.setAttribute("aria-label", t.placeholder), a.rows = 1, v(a, {
|
|
61
61
|
flex: "1",
|
|
62
62
|
resize: "none",
|
|
63
63
|
boxSizing: "border-box",
|
|
64
64
|
padding: "10px 12px",
|
|
65
|
-
border: `1px solid ${
|
|
65
|
+
border: `1px solid ${N}`,
|
|
66
66
|
borderRadius: "12px",
|
|
67
67
|
fontSize: "16px",
|
|
68
|
-
fontFamily:
|
|
68
|
+
fontFamily: ke,
|
|
69
69
|
lineHeight: "1.4",
|
|
70
70
|
maxHeight: "110px",
|
|
71
71
|
overflowY: "hidden"
|
|
@@ -76,7 +76,7 @@ function on(n) {
|
|
|
76
76
|
a.style.height = `${c}px`, a.style.overflowY = a.scrollHeight + 2 > 110 ? "auto" : "hidden";
|
|
77
77
|
};
|
|
78
78
|
a.addEventListener("input", () => {
|
|
79
|
-
C(),
|
|
79
|
+
C(), I();
|
|
80
80
|
});
|
|
81
81
|
const m = '<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>', p = document.createElement("button");
|
|
82
82
|
p.type = "submit", p.setAttribute("aria-label", "Send"), p.innerHTML = m, v(p, {
|
|
@@ -86,140 +86,140 @@ function on(n) {
|
|
|
86
86
|
padding: "0",
|
|
87
87
|
border: "none",
|
|
88
88
|
borderRadius: "50%",
|
|
89
|
-
backgroundColor:
|
|
90
|
-
color:
|
|
89
|
+
backgroundColor: Ae,
|
|
90
|
+
color: _e,
|
|
91
91
|
display: "flex",
|
|
92
92
|
alignItems: "center",
|
|
93
93
|
justifyContent: "center",
|
|
94
94
|
cursor: "pointer"
|
|
95
95
|
});
|
|
96
96
|
let f = !1;
|
|
97
|
-
const
|
|
98
|
-
const
|
|
97
|
+
const I = () => {
|
|
98
|
+
const l = a.value.trim() !== "" || o.length > 0, c = f || !l;
|
|
99
99
|
p.disabled = c, p.innerHTML = f ? x : m, p.style.opacity = c && !f ? "0.5" : "1", p.style.cursor = c ? "default" : "pointer";
|
|
100
100
|
};
|
|
101
|
-
let R = null,
|
|
102
|
-
|
|
101
|
+
let R = null, A = null;
|
|
102
|
+
t.allowFiles && (R = document.createElement("input"), R.type = "file", R.multiple = !0, v(R, { display: "none" }), A = document.createElement("button"), A.type = "button", A.setAttribute("aria-label", "Attach file"), A.textContent = "📎", v(A, {
|
|
103
103
|
padding: "10px 12px",
|
|
104
|
-
border: `1px solid ${
|
|
104
|
+
border: `1px solid ${N}`,
|
|
105
105
|
borderRadius: "12px",
|
|
106
|
-
backgroundColor:
|
|
106
|
+
backgroundColor: te,
|
|
107
107
|
cursor: "pointer",
|
|
108
108
|
fontSize: "14px"
|
|
109
|
-
}),
|
|
110
|
-
o = [...o, ...Array.from(R?.files ?? [])],
|
|
109
|
+
}), A.addEventListener("click", () => R?.click()), R.addEventListener("change", () => {
|
|
110
|
+
o = [...o, ...Array.from(R?.files ?? [])], Q();
|
|
111
111
|
}));
|
|
112
|
-
function
|
|
113
|
-
r.replaceChildren(), o.forEach((
|
|
112
|
+
function Q() {
|
|
113
|
+
r.replaceChildren(), o.forEach((l, c) => {
|
|
114
114
|
const w = h({
|
|
115
115
|
display: "flex",
|
|
116
116
|
alignItems: "center",
|
|
117
117
|
gap: "4px",
|
|
118
118
|
padding: "4px 8px",
|
|
119
119
|
backgroundColor: "#f0f4ff",
|
|
120
|
-
border: `1px solid ${
|
|
120
|
+
border: `1px solid ${N}`,
|
|
121
121
|
borderRadius: "8px",
|
|
122
122
|
fontSize: "12px"
|
|
123
|
-
}),
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
123
|
+
}), B = document.createElement("span");
|
|
124
|
+
B.textContent = l.name;
|
|
125
|
+
const k = document.createElement("button");
|
|
126
|
+
k.type = "button", k.setAttribute("aria-label", `Remove ${l.name}`), k.textContent = "×", v(k, {
|
|
127
127
|
border: "none",
|
|
128
128
|
background: "transparent",
|
|
129
129
|
cursor: "pointer",
|
|
130
130
|
fontSize: "14px",
|
|
131
131
|
lineHeight: "1"
|
|
132
|
-
}),
|
|
133
|
-
o = o.filter((V, j) => j !== c),
|
|
134
|
-
}), w.append(
|
|
135
|
-
}),
|
|
132
|
+
}), k.addEventListener("click", () => {
|
|
133
|
+
o = o.filter((V, j) => j !== c), Q();
|
|
134
|
+
}), w.append(B, k), r.appendChild(w);
|
|
135
|
+
}), I();
|
|
136
136
|
}
|
|
137
137
|
const D = () => {
|
|
138
|
-
const
|
|
139
|
-
return a.value = "", C(), o = [],
|
|
140
|
-
content:
|
|
138
|
+
const l = a.value, c = o;
|
|
139
|
+
return a.value = "", C(), o = [], Q(), {
|
|
140
|
+
content: l,
|
|
141
141
|
files: c
|
|
142
142
|
};
|
|
143
143
|
}, g = () => {
|
|
144
|
-
const { content:
|
|
145
|
-
(
|
|
144
|
+
const { content: l, files: c } = D();
|
|
145
|
+
(l.trim() || c.length > 0) && t.onSend(l.trim(), c.length > 0 ? c : void 0);
|
|
146
146
|
};
|
|
147
|
-
return i.addEventListener("submit", (
|
|
148
|
-
|
|
149
|
-
}), a.addEventListener("keydown", (
|
|
150
|
-
|
|
151
|
-
}),
|
|
147
|
+
return i.addEventListener("submit", (l) => {
|
|
148
|
+
l.preventDefault(), g();
|
|
149
|
+
}), a.addEventListener("keydown", (l) => {
|
|
150
|
+
l.key === "Enter" && !l.shiftKey && (l.preventDefault(), g());
|
|
151
|
+
}), A && b.appendChild(A), b.append(a, p), R && i.appendChild(R), i.append(r, b), I(), {
|
|
152
152
|
inputRow: i,
|
|
153
153
|
getValueAndClear: D,
|
|
154
|
-
setDisabled: (
|
|
155
|
-
a.disabled =
|
|
154
|
+
setDisabled: (l) => {
|
|
155
|
+
a.disabled = l, f = l, I();
|
|
156
156
|
},
|
|
157
157
|
focus: () => a.focus()
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
var
|
|
160
|
+
var cn = {
|
|
161
161
|
"&": "&",
|
|
162
162
|
"<": "<",
|
|
163
163
|
">": ">",
|
|
164
164
|
'"': """,
|
|
165
165
|
"'": "'"
|
|
166
166
|
};
|
|
167
|
-
function ae(
|
|
168
|
-
return
|
|
167
|
+
function ae(t) {
|
|
168
|
+
return t.replace(/[&<>"']/g, (o) => cn[o]);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const o =
|
|
170
|
+
function xt(t) {
|
|
171
|
+
const o = t.trim();
|
|
172
172
|
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o) || !/^[a-z][a-z0-9+.-]*:/i.test(o) ? o : null;
|
|
173
173
|
}
|
|
174
|
-
var
|
|
175
|
-
function
|
|
176
|
-
const o = [], i = (b) => (o.push(b), `${
|
|
177
|
-
let r =
|
|
178
|
-
return r = r.replace(/`([^`]+)`/g, (b, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${
|
|
179
|
-
const m =
|
|
174
|
+
var Ct = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Se = "";
|
|
175
|
+
function ne(t) {
|
|
176
|
+
const o = [], i = (b) => (o.push(b), `${Se}${o.length - 1}${Se}`);
|
|
177
|
+
let r = t;
|
|
178
|
+
return r = r.replace(/`([^`]+)`/g, (b, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Ct}">${ae(a)}</code>`)), r = r.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (b, a, C) => {
|
|
179
|
+
const m = xt(C);
|
|
180
180
|
return m ? i(`<img alt="${ae(a)}" src="${ae(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : b;
|
|
181
181
|
}), r = r.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (b, a, C) => {
|
|
182
|
-
const m =
|
|
183
|
-
return m ? i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${
|
|
184
|
-
}), r = ae(r), r = r.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>"), r = r.replace(new RegExp(`${
|
|
182
|
+
const m = xt(C);
|
|
183
|
+
return m ? i(`<a href="${ae(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ne(a)}</a>`) : b;
|
|
184
|
+
}), r = ae(r), r = r.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>"), r = r.replace(new RegExp(`${Se}(\\d+)${Se}`, "g"), (b, a) => o[Number(a)]), r;
|
|
185
185
|
}
|
|
186
|
-
function O(
|
|
187
|
-
const r = document.createElement(
|
|
186
|
+
function O(t, o, i) {
|
|
187
|
+
const r = document.createElement(t);
|
|
188
188
|
return Object.assign(r.style, o), i !== void 0 && (r.innerHTML = i), r;
|
|
189
189
|
}
|
|
190
|
-
var
|
|
190
|
+
var Et = /^ {0,3}([-*_])( *\1){2,} *$/, St = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Rt = /^ {0,3}(```+|~~~+)/, Ie = /^ {0,3}>\s?/, se = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, pn = [
|
|
191
191
|
"20px",
|
|
192
192
|
"18px",
|
|
193
193
|
"16px",
|
|
194
194
|
"15px",
|
|
195
195
|
"14px",
|
|
196
196
|
"13px"
|
|
197
|
-
],
|
|
198
|
-
function
|
|
199
|
-
return
|
|
197
|
+
], Fe = (t) => t.match(/^\s*/)?.[0].length ?? 0;
|
|
198
|
+
function fn(t) {
|
|
199
|
+
return t.trim() === "" || Et.test(t) || St.test(t) || Rt.test(t) || Ie.test(t) || se.test(t);
|
|
200
200
|
}
|
|
201
|
-
function
|
|
202
|
-
const o =
|
|
201
|
+
function kt(t) {
|
|
202
|
+
const o = t[0].match(se), i = o[1].length, r = /\d/.test(o[2]), b = O(r ? "ol" : "ul", {
|
|
203
203
|
margin: "0 0 8px 0",
|
|
204
204
|
paddingLeft: "20px",
|
|
205
205
|
listStyleType: r ? "decimal" : "disc",
|
|
206
206
|
listStylePosition: "outside"
|
|
207
207
|
});
|
|
208
208
|
let a = 0;
|
|
209
|
-
for (; a <
|
|
210
|
-
const C =
|
|
211
|
-
for (a++; a <
|
|
212
|
-
m.push(
|
|
209
|
+
for (; a < t.length; ) {
|
|
210
|
+
const C = t[a].match(se), m = [];
|
|
211
|
+
for (a++; a < t.length && Fe(t[a]) > i; )
|
|
212
|
+
m.push(t[a]), a++;
|
|
213
213
|
const x = O("li", {
|
|
214
214
|
display: "list-item",
|
|
215
215
|
margin: "2px 0",
|
|
216
216
|
lineHeight: "1.6"
|
|
217
217
|
}), p = C[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
218
|
-
p ? (x.style.listStyleType = "none", x.style.marginLeft = "-20px", x.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${
|
|
218
|
+
p ? (x.style.listStyleType = "none", x.style.marginLeft = "-20px", x.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ne(p[2])}`) : x.innerHTML = ne(C[3]), m.filter((f) => se.test(f)).length > 0 && x.appendChild(kt(m.filter((f) => f.trim() !== ""))), b.appendChild(x);
|
|
219
219
|
}
|
|
220
220
|
return b;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function un(t) {
|
|
223
223
|
const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), i = O("div", {
|
|
224
224
|
overflowX: "auto",
|
|
225
225
|
margin: "0 0 8px 0"
|
|
@@ -228,28 +228,28 @@ function ln(n) {
|
|
|
228
228
|
width: "100%",
|
|
229
229
|
fontSize: "13px"
|
|
230
230
|
}), b = document.createElement("thead"), a = document.createElement("tr");
|
|
231
|
-
for (const m of o(
|
|
231
|
+
for (const m of o(t[0])) a.appendChild(O("th", {
|
|
232
232
|
border: "1px solid #dee3e8",
|
|
233
233
|
padding: "6px 10px",
|
|
234
234
|
textAlign: "left",
|
|
235
235
|
backgroundColor: "#f5f7fa",
|
|
236
236
|
fontWeight: "600"
|
|
237
|
-
},
|
|
237
|
+
}, ne(m)));
|
|
238
238
|
b.appendChild(a), r.appendChild(b);
|
|
239
239
|
const C = document.createElement("tbody");
|
|
240
|
-
for (const m of
|
|
240
|
+
for (const m of t.slice(2)) {
|
|
241
241
|
const x = document.createElement("tr");
|
|
242
242
|
for (const p of o(m)) x.appendChild(O("td", {
|
|
243
243
|
border: "1px solid #dee3e8",
|
|
244
244
|
padding: "6px 10px"
|
|
245
|
-
},
|
|
245
|
+
}, ne(p)));
|
|
246
246
|
C.appendChild(x);
|
|
247
247
|
}
|
|
248
248
|
return r.appendChild(C), i.appendChild(r), i;
|
|
249
249
|
}
|
|
250
|
-
var
|
|
251
|
-
function
|
|
252
|
-
const o = document.createDocumentFragment(), i =
|
|
250
|
+
var mn = (t) => !!t && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);
|
|
251
|
+
function We(t) {
|
|
252
|
+
const o = document.createDocumentFragment(), i = t.replace(/\r\n?/g, `
|
|
253
253
|
`).split(`
|
|
254
254
|
`);
|
|
255
255
|
let r = 0;
|
|
@@ -259,27 +259,27 @@ function ze(n) {
|
|
|
259
259
|
r++;
|
|
260
260
|
continue;
|
|
261
261
|
}
|
|
262
|
-
const C = a.match(
|
|
262
|
+
const C = a.match(Rt);
|
|
263
263
|
if (C) {
|
|
264
264
|
const p = C[1][0], f = [];
|
|
265
265
|
for (r++; r < i.length && !new RegExp(`^ {0,3}${p === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(i[r]); )
|
|
266
266
|
f.push(i[r]), r++;
|
|
267
267
|
r++;
|
|
268
|
-
const
|
|
269
|
-
|
|
268
|
+
const I = O("pre", { margin: "0 0 8px 0" });
|
|
269
|
+
I.appendChild(O("code", {
|
|
270
270
|
display: "block",
|
|
271
271
|
background: "#f5f5f5",
|
|
272
272
|
padding: "8px 12px",
|
|
273
273
|
borderRadius: "6px",
|
|
274
274
|
fontSize: "13px",
|
|
275
275
|
overflowX: "auto",
|
|
276
|
-
fontFamily:
|
|
276
|
+
fontFamily: Ct,
|
|
277
277
|
whiteSpace: "pre"
|
|
278
278
|
}, ae(f.join(`
|
|
279
|
-
`)))), o.appendChild(
|
|
279
|
+
`)))), o.appendChild(I);
|
|
280
280
|
continue;
|
|
281
281
|
}
|
|
282
|
-
if (
|
|
282
|
+
if (Et.test(a)) {
|
|
283
283
|
o.appendChild(O("hr", {
|
|
284
284
|
border: "none",
|
|
285
285
|
borderTop: "1px solid #dee3e8",
|
|
@@ -287,21 +287,21 @@ function ze(n) {
|
|
|
287
287
|
})), r++;
|
|
288
288
|
continue;
|
|
289
289
|
}
|
|
290
|
-
const m = a.match(
|
|
290
|
+
const m = a.match(St);
|
|
291
291
|
if (m) {
|
|
292
292
|
const p = m[1].length;
|
|
293
293
|
o.appendChild(O(`h${p}`, {
|
|
294
294
|
margin: "16px 0 8px 0",
|
|
295
|
-
fontSize:
|
|
295
|
+
fontSize: pn[p - 1],
|
|
296
296
|
fontWeight: "600",
|
|
297
297
|
lineHeight: "1.3"
|
|
298
|
-
},
|
|
298
|
+
}, ne(m[2]))), r++;
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
301
|
-
if (
|
|
301
|
+
if (Ie.test(a)) {
|
|
302
302
|
const p = [];
|
|
303
|
-
for (; r < i.length &&
|
|
304
|
-
p.push(i[r].replace(
|
|
303
|
+
for (; r < i.length && Ie.test(i[r]); )
|
|
304
|
+
p.push(i[r].replace(Ie, "")), r++;
|
|
305
305
|
const f = O("blockquote", {
|
|
306
306
|
borderLeft: "4px solid #dee3e8",
|
|
307
307
|
paddingLeft: "12px",
|
|
@@ -309,55 +309,55 @@ function ze(n) {
|
|
|
309
309
|
fontStyle: "italic",
|
|
310
310
|
color: "#6b6d6f"
|
|
311
311
|
});
|
|
312
|
-
f.appendChild(
|
|
312
|
+
f.appendChild(We(p.join(`
|
|
313
313
|
`))), o.appendChild(f);
|
|
314
314
|
continue;
|
|
315
315
|
}
|
|
316
|
-
if (a.includes("|") &&
|
|
316
|
+
if (a.includes("|") && mn(i[r + 1])) {
|
|
317
317
|
const p = [a, i[r + 1]];
|
|
318
318
|
for (r += 2; r < i.length && i[r].includes("|") && i[r].trim(); )
|
|
319
319
|
p.push(i[r]), r++;
|
|
320
|
-
o.appendChild(
|
|
320
|
+
o.appendChild(un(p));
|
|
321
321
|
continue;
|
|
322
322
|
}
|
|
323
323
|
if (se.test(a)) {
|
|
324
|
-
const p = [], f =
|
|
324
|
+
const p = [], f = Fe(a);
|
|
325
325
|
for (; r < i.length && i[r].trim() !== ""; )
|
|
326
|
-
if (se.test(i[r]) ||
|
|
326
|
+
if (se.test(i[r]) || Fe(i[r]) > f)
|
|
327
327
|
p.push(i[r]), r++;
|
|
328
328
|
else break;
|
|
329
|
-
o.appendChild(
|
|
329
|
+
o.appendChild(kt(p));
|
|
330
330
|
continue;
|
|
331
331
|
}
|
|
332
332
|
const x = [a];
|
|
333
|
-
for (r++; r < i.length && !
|
|
333
|
+
for (r++; r < i.length && !fn(i[r]); )
|
|
334
334
|
x.push(i[r]), r++;
|
|
335
335
|
o.appendChild(O("p", {
|
|
336
336
|
margin: "0 0 8px 0",
|
|
337
337
|
lineHeight: "1.6"
|
|
338
|
-
}, x.map((p) =>
|
|
338
|
+
}, x.map((p) => ne(p)).join("<br>")));
|
|
339
339
|
}
|
|
340
340
|
const b = o.lastElementChild;
|
|
341
341
|
return b && (b.style.marginBottom = "0"), o;
|
|
342
342
|
}
|
|
343
|
-
function
|
|
344
|
-
const { isLast: i, isLastOfBlock: r, bubbleStyle: b, showAgentName: a, agentBubble: C, followUpEnabled: m, followUpHandler: x, isMobile: p } = o, f =
|
|
343
|
+
function gn(t, o) {
|
|
344
|
+
const { isLast: i, isLastOfBlock: r, bubbleStyle: b, showAgentName: a, agentBubble: C, followUpEnabled: m, followUpHandler: x, isMobile: p } = o, f = t.role === "user", I = b === "imessage", R = h({
|
|
345
345
|
display: "flex",
|
|
346
346
|
flexDirection: "column",
|
|
347
347
|
alignItems: f ? "flex-end" : "flex-start",
|
|
348
|
-
marginBottom:
|
|
348
|
+
marginBottom: I && !r ? "2px" : "16px"
|
|
349
349
|
});
|
|
350
|
-
if (R.className = `ago-message ago-message--${
|
|
350
|
+
if (R.className = `ago-message ago-message--${t.role}`, !f && a && t.agent) {
|
|
351
351
|
const g = h({
|
|
352
352
|
fontSize: "13px",
|
|
353
353
|
fontWeight: "500",
|
|
354
|
-
color:
|
|
354
|
+
color: ee,
|
|
355
355
|
marginBottom: "6px",
|
|
356
356
|
padding: "0 4px"
|
|
357
357
|
});
|
|
358
|
-
g.className = "ago-message__agent", g.textContent =
|
|
358
|
+
g.className = "ago-message__agent", g.textContent = t.agent.displayName || t.agent.name, R.appendChild(g);
|
|
359
359
|
}
|
|
360
|
-
if (!f &&
|
|
360
|
+
if (!f && t.sources && t.sources.length > 0) {
|
|
361
361
|
const g = h({
|
|
362
362
|
display: "grid",
|
|
363
363
|
gridTemplateColumns: "1fr 1fr",
|
|
@@ -366,28 +366,28 @@ function cn(n, o) {
|
|
|
366
366
|
width: "100%",
|
|
367
367
|
maxWidth: "85%"
|
|
368
368
|
});
|
|
369
|
-
g.className = "ago-message__sources",
|
|
370
|
-
const w =
|
|
371
|
-
|
|
369
|
+
g.className = "ago-message__sources", t.sources.forEach((l, c) => {
|
|
370
|
+
const w = l.url ? document.createElement("a") : document.createElement("div");
|
|
371
|
+
l.url && w instanceof HTMLAnchorElement && (w.href = l.url, w.target = "_blank", w.rel = "noopener noreferrer"), v(w, {
|
|
372
372
|
display: "flex",
|
|
373
373
|
alignItems: "center",
|
|
374
374
|
gap: "8px",
|
|
375
375
|
padding: "8px 10px",
|
|
376
|
-
border: `1px solid ${
|
|
376
|
+
border: `1px solid ${N}`,
|
|
377
377
|
borderRadius: "8px",
|
|
378
|
-
backgroundColor:
|
|
378
|
+
backgroundColor: te,
|
|
379
379
|
textDecoration: "none",
|
|
380
|
-
color:
|
|
380
|
+
color: ee,
|
|
381
381
|
fontSize: "12px",
|
|
382
382
|
overflow: "hidden"
|
|
383
383
|
});
|
|
384
|
-
const
|
|
384
|
+
const B = h({
|
|
385
385
|
flexShrink: "0",
|
|
386
386
|
width: "18px",
|
|
387
387
|
height: "18px",
|
|
388
388
|
borderRadius: "3px",
|
|
389
|
-
border: `1px solid ${
|
|
390
|
-
color:
|
|
389
|
+
border: `1px solid ${De}`,
|
|
390
|
+
color: De,
|
|
391
391
|
fontSize: "11px",
|
|
392
392
|
fontWeight: "500",
|
|
393
393
|
display: "flex",
|
|
@@ -395,16 +395,16 @@ function cn(n, o) {
|
|
|
395
395
|
justifyContent: "center",
|
|
396
396
|
backgroundColor: "#f0f4ff"
|
|
397
397
|
});
|
|
398
|
-
|
|
399
|
-
const
|
|
398
|
+
B.textContent = String(c + 1);
|
|
399
|
+
const k = h({
|
|
400
400
|
overflow: "hidden",
|
|
401
401
|
textOverflow: "ellipsis",
|
|
402
402
|
whiteSpace: "nowrap"
|
|
403
403
|
});
|
|
404
|
-
|
|
404
|
+
k.textContent = l.title, k.title = l.title, w.append(B, k), g.appendChild(w);
|
|
405
405
|
}), R.appendChild(g);
|
|
406
406
|
}
|
|
407
|
-
if (
|
|
407
|
+
if (t.attachments && t.attachments.length > 0) {
|
|
408
408
|
const g = h({
|
|
409
409
|
display: "flex",
|
|
410
410
|
flexWrap: "wrap",
|
|
@@ -414,23 +414,23 @@ function cn(n, o) {
|
|
|
414
414
|
maxWidth: "75%"
|
|
415
415
|
});
|
|
416
416
|
g.className = "ago-message__attachments";
|
|
417
|
-
for (const
|
|
418
|
-
const c =
|
|
419
|
-
if (
|
|
420
|
-
const
|
|
421
|
-
|
|
417
|
+
for (const l of t.attachments) {
|
|
418
|
+
const c = Qt(l.url);
|
|
419
|
+
if (qt(l) && c) {
|
|
420
|
+
const M = document.createElement("a");
|
|
421
|
+
M.href = c, M.target = "_blank", M.rel = "noopener noreferrer", v(M, {
|
|
422
422
|
display: "inline-block",
|
|
423
423
|
textDecoration: "none"
|
|
424
424
|
});
|
|
425
425
|
const q = document.createElement("img");
|
|
426
|
-
q.src = c, q.alt =
|
|
426
|
+
q.src = c, q.alt = l.name, q.loading = "lazy", v(q, {
|
|
427
427
|
maxWidth: "180px",
|
|
428
428
|
maxHeight: "160px",
|
|
429
429
|
objectFit: "cover",
|
|
430
430
|
borderRadius: "10px",
|
|
431
|
-
border: `1px solid ${
|
|
431
|
+
border: `1px solid ${N}`,
|
|
432
432
|
display: "block"
|
|
433
|
-
}),
|
|
433
|
+
}), M.appendChild(q), g.appendChild(M);
|
|
434
434
|
continue;
|
|
435
435
|
}
|
|
436
436
|
const w = c ? document.createElement("a") : document.createElement("div");
|
|
@@ -440,20 +440,20 @@ function cn(n, o) {
|
|
|
440
440
|
gap: "8px",
|
|
441
441
|
padding: "8px 12px",
|
|
442
442
|
borderRadius: "10px",
|
|
443
|
-
border: `1px solid ${
|
|
444
|
-
backgroundColor: f ? "rgba(255,255,255,0.12)" :
|
|
445
|
-
color: f ?
|
|
443
|
+
border: `1px solid ${N}`,
|
|
444
|
+
backgroundColor: f ? "rgba(255,255,255,0.12)" : te,
|
|
445
|
+
color: f ? _e : ee,
|
|
446
446
|
fontSize: "13px",
|
|
447
447
|
textDecoration: "none",
|
|
448
448
|
maxWidth: "220px"
|
|
449
449
|
});
|
|
450
|
-
const
|
|
451
|
-
|
|
450
|
+
const B = document.createElement("span");
|
|
451
|
+
B.textContent = "📄", B.setAttribute("aria-hidden", "true"), v(B, {
|
|
452
452
|
fontSize: "16px",
|
|
453
453
|
lineHeight: "1",
|
|
454
454
|
flexShrink: "0"
|
|
455
455
|
});
|
|
456
|
-
const
|
|
456
|
+
const k = h({
|
|
457
457
|
display: "flex",
|
|
458
458
|
flexDirection: "column",
|
|
459
459
|
minWidth: "0"
|
|
@@ -463,31 +463,31 @@ function cn(n, o) {
|
|
|
463
463
|
whiteSpace: "nowrap",
|
|
464
464
|
maxWidth: "160px"
|
|
465
465
|
});
|
|
466
|
-
V.textContent =
|
|
467
|
-
const j =
|
|
466
|
+
V.textContent = l.name, V.title = l.name, k.appendChild(V);
|
|
467
|
+
const j = Yt(l.fileSize);
|
|
468
468
|
if (j) {
|
|
469
|
-
const
|
|
469
|
+
const M = h({
|
|
470
470
|
fontSize: "11px",
|
|
471
|
-
color:
|
|
471
|
+
color: wt
|
|
472
472
|
});
|
|
473
|
-
|
|
473
|
+
M.textContent = j, k.appendChild(M);
|
|
474
474
|
}
|
|
475
|
-
w.append(
|
|
475
|
+
w.append(B, k), g.appendChild(w);
|
|
476
476
|
}
|
|
477
477
|
R.appendChild(g);
|
|
478
478
|
}
|
|
479
|
-
const
|
|
480
|
-
maxWidth:
|
|
481
|
-
padding:
|
|
482
|
-
borderRadius:
|
|
483
|
-
backgroundColor: f ?
|
|
484
|
-
color: f ?
|
|
479
|
+
const A = f || C || I, Q = !!t.content || t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", D = h({
|
|
480
|
+
maxWidth: A ? I || f ? p ? "88%" : "75%" : p ? "92%" : "85%" : "100%",
|
|
481
|
+
padding: A ? "10px 14px" : "2px 8px",
|
|
482
|
+
borderRadius: I ? an : A ? ze : "0",
|
|
483
|
+
backgroundColor: f ? Ae : A ? gt : "transparent",
|
|
484
|
+
color: f ? _e : ee,
|
|
485
485
|
overflowWrap: "break-word",
|
|
486
486
|
textWrap: "pretty",
|
|
487
487
|
fontSize: "16px",
|
|
488
488
|
lineHeight: "1.6"
|
|
489
489
|
});
|
|
490
|
-
if (D.className = "ago-message__content",
|
|
490
|
+
if (D.className = "ago-message__content", I && r) {
|
|
491
491
|
D.style.position = "relative";
|
|
492
492
|
const g = h({
|
|
493
493
|
position: "absolute",
|
|
@@ -495,20 +495,20 @@ function cn(n, o) {
|
|
|
495
495
|
bottom: "-2px",
|
|
496
496
|
width: "20px",
|
|
497
497
|
height: "20px",
|
|
498
|
-
background: f ?
|
|
498
|
+
background: f ? Ae : gt
|
|
499
499
|
});
|
|
500
500
|
g.className = "ago-message__tail";
|
|
501
|
-
const
|
|
501
|
+
const l = h({
|
|
502
502
|
position: "absolute",
|
|
503
503
|
zIndex: "1",
|
|
504
504
|
bottom: "-2px",
|
|
505
505
|
width: "10px",
|
|
506
506
|
height: "20px",
|
|
507
|
-
background:
|
|
507
|
+
background: yt
|
|
508
508
|
});
|
|
509
|
-
|
|
509
|
+
l.className = "ago-message__tail-mask", f ? (g.style.right = "-8px", g.style.borderBottomLeftRadius = "16px 14px", l.style.right = "-10px", l.style.borderBottomLeftRadius = "10px") : (g.style.left = "-7px", g.style.borderBottomRightRadius = "16px 14px", l.style.left = "-10px", l.style.borderBottomRightRadius = "10px"), D.append(g, l);
|
|
510
510
|
}
|
|
511
|
-
if (
|
|
511
|
+
if (t.content ? D.appendChild(We(t.content)) : (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT") && D.appendChild(xn()), Q && R.appendChild(D), i && t.followUpReplies && t.followUpReplies.length > 0) {
|
|
512
512
|
const g = h({
|
|
513
513
|
display: "flex",
|
|
514
514
|
flexWrap: "wrap",
|
|
@@ -516,29 +516,29 @@ function cn(n, o) {
|
|
|
516
516
|
marginTop: "10px"
|
|
517
517
|
});
|
|
518
518
|
g.className = "ago-message__followups";
|
|
519
|
-
for (const
|
|
519
|
+
for (const l of t.followUpReplies) {
|
|
520
520
|
const c = document.createElement("button");
|
|
521
|
-
c.type = "button", c.className = "ago-message__followup-btn", c.textContent =
|
|
521
|
+
c.type = "button", c.className = "ago-message__followup-btn", c.textContent = l, c.disabled = !m, v(c, {
|
|
522
522
|
minHeight: "36px",
|
|
523
523
|
padding: "6px 14px",
|
|
524
524
|
fontSize: "14px",
|
|
525
|
-
borderRadius:
|
|
526
|
-
border: `1px solid ${
|
|
527
|
-
backgroundColor:
|
|
528
|
-
color:
|
|
525
|
+
borderRadius: ze,
|
|
526
|
+
border: `1px solid ${N}`,
|
|
527
|
+
backgroundColor: te,
|
|
528
|
+
color: ee,
|
|
529
529
|
cursor: m ? "pointer" : "default",
|
|
530
530
|
transition: "border-color 0.15s"
|
|
531
|
-
}), x && c.addEventListener("click", () => x(
|
|
532
|
-
c.style.borderColor =
|
|
531
|
+
}), x && c.addEventListener("click", () => x(l)), c.addEventListener("mouseenter", () => {
|
|
532
|
+
c.style.borderColor = De;
|
|
533
533
|
}), c.addEventListener("mouseleave", () => {
|
|
534
|
-
c.style.borderColor =
|
|
534
|
+
c.style.borderColor = N;
|
|
535
535
|
}), g.appendChild(c);
|
|
536
536
|
}
|
|
537
537
|
R.appendChild(g);
|
|
538
538
|
}
|
|
539
539
|
return R;
|
|
540
540
|
}
|
|
541
|
-
function
|
|
541
|
+
function hn(t) {
|
|
542
542
|
const o = h({
|
|
543
543
|
display: "flex",
|
|
544
544
|
alignItems: "center",
|
|
@@ -546,7 +546,7 @@ function pn(n) {
|
|
|
546
546
|
padding: "10px 14px",
|
|
547
547
|
backgroundColor: "#f0fdf4",
|
|
548
548
|
color: "#15803d",
|
|
549
|
-
borderRadius:
|
|
549
|
+
borderRadius: ze,
|
|
550
550
|
marginTop: "8px",
|
|
551
551
|
fontSize: "13px",
|
|
552
552
|
border: "1px solid #bbf7d0"
|
|
@@ -555,10 +555,10 @@ function pn(n) {
|
|
|
555
555
|
const i = document.createElement("span");
|
|
556
556
|
i.textContent = "✓", i.setAttribute("aria-hidden", "true"), v(i, { fontWeight: "700" });
|
|
557
557
|
const r = document.createElement("span");
|
|
558
|
-
return r.textContent =
|
|
558
|
+
return r.textContent = t, o.append(i, r), o;
|
|
559
559
|
}
|
|
560
|
-
function
|
|
561
|
-
const
|
|
560
|
+
function xn() {
|
|
561
|
+
const t = h({
|
|
562
562
|
display: "flex",
|
|
563
563
|
gap: "4px",
|
|
564
564
|
padding: "4px 0"
|
|
@@ -572,21 +572,21 @@ function fn() {
|
|
|
572
572
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
573
573
|
animationDelay: `${o * 0.2}s`
|
|
574
574
|
});
|
|
575
|
-
|
|
575
|
+
t.appendChild(i);
|
|
576
576
|
}
|
|
577
|
-
return
|
|
577
|
+
return t;
|
|
578
578
|
}
|
|
579
|
-
function
|
|
580
|
-
const
|
|
579
|
+
function bn() {
|
|
580
|
+
const t = "http://www.w3.org/2000/svg", o = document.createElementNS(t, "svg");
|
|
581
581
|
o.setAttribute("width", "26"), o.setAttribute("height", "26"), o.setAttribute("viewBox", "0 0 24 24"), o.setAttribute("fill", "none");
|
|
582
|
-
const i = document.createElementNS(
|
|
582
|
+
const i = document.createElementNS(t, "path");
|
|
583
583
|
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"), o.appendChild(i), o;
|
|
584
584
|
}
|
|
585
|
-
var
|
|
586
|
-
function
|
|
587
|
-
if (typeof
|
|
588
|
-
if (!
|
|
589
|
-
const o =
|
|
585
|
+
var bt = "Form submitted.";
|
|
586
|
+
function vn(t) {
|
|
587
|
+
if (typeof t == "string") return t || null;
|
|
588
|
+
if (!t || typeof t != "object") return null;
|
|
589
|
+
const o = t;
|
|
590
590
|
if (typeof o.message == "string" && o.message) return o.message;
|
|
591
591
|
const i = o.result;
|
|
592
592
|
if (typeof i == "string" && i) return i;
|
|
@@ -596,60 +596,71 @@ function mn(n) {
|
|
|
596
596
|
}
|
|
597
597
|
return null;
|
|
598
598
|
}
|
|
599
|
-
var
|
|
600
|
-
function
|
|
601
|
-
|
|
602
|
-
|
|
599
|
+
var yn = 0, He = 0, Pe = 0;
|
|
600
|
+
function vt() {
|
|
601
|
+
if (He++ > 0) return;
|
|
602
|
+
Pe = window.scrollY;
|
|
603
|
+
const { style: t } = document.body;
|
|
604
|
+
t.position = "fixed", t.top = `-${Pe}px`, t.left = "0", t.right = "0", t.width = "100%", document.documentElement.style.overflow = "hidden";
|
|
605
|
+
}
|
|
606
|
+
function Re() {
|
|
607
|
+
if (He === 0 || --He > 0) return;
|
|
608
|
+
const { style: t } = document.body;
|
|
609
|
+
t.removeProperty("position"), t.removeProperty("top"), t.removeProperty("left"), t.removeProperty("right"), t.removeProperty("width"), document.documentElement.style.removeProperty("overflow"), window.scrollTo(0, Pe);
|
|
610
|
+
}
|
|
611
|
+
function wn(t) {
|
|
612
|
+
const o = typeof t == "string" ? document.querySelector(t) : t;
|
|
613
|
+
if (!o) throw new Error(`mountChatWidget: target "${String(t)}" not found.`);
|
|
603
614
|
return o;
|
|
604
615
|
}
|
|
605
|
-
function
|
|
606
|
-
const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName:
|
|
616
|
+
function kn(t, o) {
|
|
617
|
+
const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: I = !1, agentBubble: R = !1, bubbleStyle: A = "default", showHeader: Q = !0, theme: D, loadThreads: g = !1, forms: l, formSubmittedMessage: c = bt, onFollowUpClick: w, onMessageSent: B, onMessageReceived: k, onFormSubmitted: V, onFormError: j, onOpen: M, onClose: q } = o, oe = typeof r == "string" ? {
|
|
607
618
|
message: r,
|
|
608
619
|
mode: "static"
|
|
609
|
-
} : r,
|
|
610
|
-
if (!o.client && !o.config?.baseUrl) throw new
|
|
611
|
-
const E = o.client ?? new
|
|
612
|
-
let
|
|
613
|
-
const
|
|
614
|
-
let P = o.conversationId ??
|
|
615
|
-
const
|
|
616
|
-
function
|
|
620
|
+
} : r, Ue = oe.message, Ge = oe.mode ?? "static", It = "speed" in oe && oe.speed || 45, Ve = "followUpReplies" in oe && oe.followUpReplies || void 0;
|
|
621
|
+
if (!o.client && !o.config?.baseUrl) throw new Xt("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
|
|
622
|
+
const E = o.client ?? new Zt(o.config), je = wn(t), z = m === "left" || m === "right", At = z && (o.launcher ?? !0);
|
|
623
|
+
let Z = z ? p : !0, me = !1;
|
|
624
|
+
const _t = o.mobile?.breakpoint ?? 768, Le = o.mobile?.trigger ?? "tap", qe = typeof window < "u" && !!window.matchMedia, T = qe ? window.matchMedia(`(max-width: ${_t}px)`) : void 0, Lt = qe ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, re = !z && !!T, Ne = o.persistConversation, ge = Ne ? tn(Ne === !0 ? {} : Ne) : void 0;
|
|
625
|
+
let P = o.conversationId ?? ge?.getLastActiveThread() ?? void 0, u = [], J = !1, le = null, K;
|
|
626
|
+
const Ke = [];
|
|
627
|
+
function Nt(e) {
|
|
617
628
|
if (typeof c == "function") {
|
|
618
|
-
const
|
|
619
|
-
if (typeof
|
|
629
|
+
const s = c(e);
|
|
630
|
+
if (typeof s == "string" && s) return s;
|
|
620
631
|
}
|
|
621
|
-
const
|
|
622
|
-
return
|
|
632
|
+
const n = vn(e);
|
|
633
|
+
return n || (typeof c == "string" ? c : bt);
|
|
623
634
|
}
|
|
624
|
-
const
|
|
635
|
+
const he = [], d = h({
|
|
625
636
|
display: "flex",
|
|
626
637
|
flexDirection: "column",
|
|
627
638
|
height: z ? "100%" : typeof C == "number" ? `${C}px` : C,
|
|
628
|
-
border: `1px solid ${
|
|
629
|
-
borderRadius:
|
|
639
|
+
border: `1px solid ${N}`,
|
|
640
|
+
borderRadius: rn,
|
|
630
641
|
overflow: "hidden",
|
|
631
|
-
backgroundColor:
|
|
632
|
-
fontFamily:
|
|
642
|
+
backgroundColor: te,
|
|
643
|
+
fontFamily: ke,
|
|
633
644
|
textAlign: "left",
|
|
634
645
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
635
646
|
});
|
|
636
|
-
d.className = "ago-chat-widget",
|
|
647
|
+
d.className = "ago-chat-widget", sn(d, D);
|
|
637
648
|
let F;
|
|
638
|
-
if (
|
|
649
|
+
if (Q) {
|
|
639
650
|
if (F = h({
|
|
640
651
|
padding: "14px 16px",
|
|
641
|
-
borderBottom: `1px solid ${
|
|
642
|
-
backgroundColor:
|
|
643
|
-
color:
|
|
652
|
+
borderBottom: `1px solid ${N}`,
|
|
653
|
+
backgroundColor: on,
|
|
654
|
+
color: mt,
|
|
644
655
|
display: "flex",
|
|
645
656
|
alignItems: "center",
|
|
646
657
|
gap: "10px"
|
|
647
658
|
}), F.className = "ago-chat-widget__header", f) {
|
|
648
|
-
const
|
|
649
|
-
|
|
659
|
+
const n = document.createElement("img");
|
|
660
|
+
n.src = f, n.alt = "Logo", v(n, {
|
|
650
661
|
height: "24px",
|
|
651
662
|
width: "auto"
|
|
652
|
-
}), F.appendChild(
|
|
663
|
+
}), F.appendChild(n);
|
|
653
664
|
}
|
|
654
665
|
const e = document.createElement("h3");
|
|
655
666
|
if (e.textContent = i, v(e, {
|
|
@@ -657,131 +668,132 @@ function wn(n, o) {
|
|
|
657
668
|
fontSize: "15px",
|
|
658
669
|
fontWeight: "600"
|
|
659
670
|
}), F.appendChild(e), z) {
|
|
660
|
-
const
|
|
661
|
-
|
|
671
|
+
const n = document.createElement("button");
|
|
672
|
+
n.type = "button", n.className = "ago-chat-widget__close", n.setAttribute("aria-label", "Close"), n.textContent = "×", v(n, {
|
|
662
673
|
marginLeft: "auto",
|
|
663
674
|
background: "transparent",
|
|
664
675
|
border: "none",
|
|
665
|
-
color:
|
|
676
|
+
color: mt,
|
|
666
677
|
fontSize: "22px",
|
|
667
678
|
lineHeight: "1",
|
|
668
679
|
cursor: "pointer",
|
|
669
680
|
padding: "0 2px"
|
|
670
|
-
}),
|
|
681
|
+
}), n.addEventListener("click", () => Oe()), F.appendChild(n);
|
|
671
682
|
}
|
|
672
683
|
}
|
|
673
684
|
const _ = h({
|
|
674
685
|
flex: "1",
|
|
675
686
|
overflow: "auto",
|
|
687
|
+
overscrollBehavior: "contain",
|
|
676
688
|
padding: "16px",
|
|
677
|
-
backgroundColor:
|
|
689
|
+
backgroundColor: yt
|
|
678
690
|
});
|
|
679
691
|
_.className = "ago-chat-widget__messages", _.setAttribute("role", "log"), _.setAttribute("aria-live", "polite"), _.setAttribute("aria-relevant", "additions text"), _.setAttribute("aria-atomic", "false");
|
|
680
|
-
const { inputRow:
|
|
692
|
+
const { inputRow: Te, setDisabled: Tt, focus: xe } = dn({
|
|
681
693
|
placeholder: b,
|
|
682
694
|
allowFiles: a,
|
|
683
|
-
onSend: (e,
|
|
684
|
-
|
|
695
|
+
onSend: (e, n) => {
|
|
696
|
+
we(e, n);
|
|
685
697
|
}
|
|
686
698
|
});
|
|
687
|
-
|
|
688
|
-
let
|
|
689
|
-
const
|
|
690
|
-
if (z && (
|
|
699
|
+
ln(), d.append(...F ? [F] : [], _, Te);
|
|
700
|
+
let be = d, U, $;
|
|
701
|
+
const ve = m === "left" ? "left" : "right";
|
|
702
|
+
if (z && (U = h({
|
|
691
703
|
position: "fixed",
|
|
692
704
|
top: "0",
|
|
693
705
|
bottom: "0",
|
|
694
|
-
[
|
|
706
|
+
[ve]: "0",
|
|
695
707
|
width: typeof x == "number" ? `${x}px` : x,
|
|
696
708
|
maxWidth: "100vw",
|
|
697
709
|
display: "flex",
|
|
698
710
|
zIndex: "2147483000",
|
|
699
711
|
transition: "transform 0.3s ease",
|
|
700
712
|
boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
|
|
701
|
-
}),
|
|
713
|
+
}), U.className = "ago-chat-widget-panel", v(d, {
|
|
702
714
|
height: "100%",
|
|
703
715
|
width: "100%",
|
|
704
716
|
borderRadius: "0",
|
|
705
717
|
border: "none",
|
|
706
718
|
boxShadow: "none",
|
|
707
|
-
[
|
|
708
|
-
}),
|
|
709
|
-
if (
|
|
719
|
+
[ve === "left" ? "borderRight" : "borderLeft"]: `1px solid ${N}`
|
|
720
|
+
}), U.appendChild(d), be = U), At) {
|
|
721
|
+
if ($ = document.createElement("button"), $.type = "button", $.className = "ago-chat-widget-launcher", $.setAttribute("aria-label", `Open ${i}`), v($, {
|
|
710
722
|
position: "fixed",
|
|
711
723
|
bottom: "20px",
|
|
712
|
-
[
|
|
724
|
+
[ve]: "20px",
|
|
713
725
|
width: "56px",
|
|
714
726
|
height: "56px",
|
|
715
727
|
borderRadius: "50%",
|
|
716
728
|
border: "none",
|
|
717
|
-
backgroundColor:
|
|
718
|
-
color:
|
|
729
|
+
backgroundColor: Ae,
|
|
730
|
+
color: _e,
|
|
719
731
|
cursor: "pointer",
|
|
720
732
|
display: "flex",
|
|
721
733
|
alignItems: "center",
|
|
722
734
|
justifyContent: "center",
|
|
723
735
|
zIndex: "2147483000",
|
|
724
736
|
boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
|
|
725
|
-
fontFamily:
|
|
737
|
+
fontFamily: ke
|
|
726
738
|
}), f) {
|
|
727
739
|
const e = document.createElement("img");
|
|
728
740
|
e.src = f, e.alt = "", v(e, {
|
|
729
741
|
width: "26px",
|
|
730
742
|
height: "26px",
|
|
731
743
|
objectFit: "contain"
|
|
732
|
-
}),
|
|
733
|
-
} else
|
|
734
|
-
|
|
744
|
+
}), $.appendChild(e);
|
|
745
|
+
} else $.appendChild(bn());
|
|
746
|
+
$.addEventListener("click", () => Me());
|
|
735
747
|
}
|
|
736
|
-
const de = re ? `ago-vt-${++
|
|
737
|
-
let
|
|
738
|
-
const
|
|
748
|
+
const de = re ? `ago-vt-${++yn}` : "", Xe = 52;
|
|
749
|
+
let W = !1, ce = 0, ie = 0, H, pe, X;
|
|
750
|
+
const ye = {
|
|
739
751
|
height: d.style.height,
|
|
740
752
|
border: d.style.border,
|
|
741
753
|
borderRadius: d.style.borderRadius,
|
|
742
754
|
boxShadow: d.style.boxShadow
|
|
743
755
|
};
|
|
744
|
-
|
|
745
|
-
if (
|
|
746
|
-
const
|
|
747
|
-
if (
|
|
756
|
+
je.appendChild(be), $ && je.appendChild($), Ce(), re && (H = Gt(), d.insertBefore(H, d.firstChild), pe = document.createElement("style"), pe.id = de, pe.textContent = `::view-transition-group(${de}),::view-transition-group(${de}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(pe), (Le === "focus" || Le === "tap") && (d.addEventListener("pointerdown", (e) => {
|
|
757
|
+
if (W || !T?.matches) return;
|
|
758
|
+
const n = Te.contains(e.target);
|
|
759
|
+
if (Le === "tap") {
|
|
748
760
|
if ((e.target instanceof Element ? e.target : null)?.closest("button,a[href],[role='button']")) return;
|
|
749
|
-
} else if (!
|
|
750
|
-
|
|
761
|
+
} else if (!n) return;
|
|
762
|
+
n && e.preventDefault(), fe();
|
|
751
763
|
}, !0), d.addEventListener("focusin", (e) => {
|
|
752
|
-
|
|
753
|
-
})), document.addEventListener("keydown",
|
|
754
|
-
const
|
|
755
|
-
re &&
|
|
764
|
+
T?.matches && Te.contains(e.target) && fe();
|
|
765
|
+
})), document.addEventListener("keydown", it)), T && T.addEventListener("change", at);
|
|
766
|
+
const $t = w !== !1, Bt = w === !1 ? void 0 : w ?? ((e) => {
|
|
767
|
+
re && T?.matches && !W ? fe().then(() => we(e)) : we(e);
|
|
756
768
|
});
|
|
757
|
-
function
|
|
769
|
+
function L() {
|
|
758
770
|
if (_.replaceChildren(), u.length === 0) {
|
|
759
|
-
if (
|
|
760
|
-
const
|
|
771
|
+
if (Ge === "static") {
|
|
772
|
+
const n = h({
|
|
761
773
|
textAlign: "center",
|
|
762
|
-
color:
|
|
774
|
+
color: wt,
|
|
763
775
|
padding: "24px 16px",
|
|
764
776
|
fontSize: "16px",
|
|
765
777
|
lineHeight: "1.5"
|
|
766
778
|
});
|
|
767
|
-
|
|
779
|
+
n.appendChild(We(Ue)), _.appendChild(n);
|
|
768
780
|
}
|
|
769
|
-
} else u.forEach((
|
|
770
|
-
const S =
|
|
771
|
-
_.appendChild(
|
|
772
|
-
isLast:
|
|
781
|
+
} else u.forEach((n, s) => {
|
|
782
|
+
const S = s === u.length - 1 || u[s + 1].role !== n.role;
|
|
783
|
+
_.appendChild(gn(n, {
|
|
784
|
+
isLast: s === u.length - 1,
|
|
773
785
|
isLastOfBlock: S,
|
|
774
|
-
bubbleStyle:
|
|
775
|
-
showAgentName:
|
|
786
|
+
bubbleStyle: A,
|
|
787
|
+
showAgentName: I,
|
|
776
788
|
agentBubble: R,
|
|
777
|
-
followUpEnabled:
|
|
778
|
-
followUpHandler:
|
|
779
|
-
isMobile: !!
|
|
789
|
+
followUpEnabled: $t,
|
|
790
|
+
followUpHandler: Bt,
|
|
791
|
+
isMobile: !!T?.matches
|
|
780
792
|
}));
|
|
781
793
|
});
|
|
782
|
-
for (const
|
|
794
|
+
for (const n of Ke) _.appendChild(hn(n));
|
|
783
795
|
if (le) {
|
|
784
|
-
const
|
|
796
|
+
const n = h({
|
|
785
797
|
padding: "10px 14px",
|
|
786
798
|
backgroundColor: "#fef2f2",
|
|
787
799
|
color: "#dc2626",
|
|
@@ -790,37 +802,37 @@ function wn(n, o) {
|
|
|
790
802
|
fontSize: "13px",
|
|
791
803
|
border: "1px solid #fecaca"
|
|
792
804
|
});
|
|
793
|
-
|
|
805
|
+
n.setAttribute("role", "alert"), n.textContent = le, _.appendChild(n);
|
|
794
806
|
}
|
|
795
807
|
_.scrollTop = _.scrollHeight;
|
|
796
808
|
const e = u[u.length - 1];
|
|
797
|
-
|
|
809
|
+
Tt(J && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT"));
|
|
798
810
|
}
|
|
799
|
-
function
|
|
811
|
+
function Mt() {
|
|
800
812
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
801
|
-
const
|
|
802
|
-
if (
|
|
813
|
+
const n = u[e];
|
|
814
|
+
if (n.role === "assistant" && (n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT")) return n;
|
|
803
815
|
}
|
|
804
816
|
}
|
|
805
|
-
const
|
|
817
|
+
const Ye = (e) => {
|
|
806
818
|
P || (P = e.conversationId);
|
|
807
|
-
},
|
|
808
|
-
const
|
|
809
|
-
|
|
810
|
-
},
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
},
|
|
814
|
-
const
|
|
815
|
-
|
|
819
|
+
}, Qe = (e) => {
|
|
820
|
+
const n = Mt();
|
|
821
|
+
n && (n.content += e.content, L());
|
|
822
|
+
}, Ze = (e) => {
|
|
823
|
+
const n = u.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
824
|
+
n >= 0 ? u[n] = e : u.push(e), L(), xe();
|
|
825
|
+
}, Je = (e) => {
|
|
826
|
+
const n = u.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
827
|
+
n >= 0 ? u[n] = e : u.push(e), J = !1, L(), e.status === "DONE" && k?.({
|
|
816
828
|
id: e.id,
|
|
817
829
|
content: e.content
|
|
818
830
|
});
|
|
819
|
-
},
|
|
820
|
-
le = e.error,
|
|
831
|
+
}, et = (e) => {
|
|
832
|
+
le = e.error, J = !1, u = u.filter((n) => !n.id.startsWith("temp-")), L();
|
|
821
833
|
};
|
|
822
|
-
function
|
|
823
|
-
const
|
|
834
|
+
function Ot(e) {
|
|
835
|
+
const n = {
|
|
824
836
|
id: `ago-intro-${Date.now()}`,
|
|
825
837
|
conversationId: "",
|
|
826
838
|
content: "",
|
|
@@ -828,37 +840,37 @@ function wn(n, o) {
|
|
|
828
840
|
status: "IN_PROGRESS",
|
|
829
841
|
createdAt: /* @__PURE__ */ new Date()
|
|
830
842
|
};
|
|
831
|
-
u.push(
|
|
832
|
-
const
|
|
843
|
+
u.push(n), L();
|
|
844
|
+
const s = e.match(/\S+\s*/g) ?? [e];
|
|
833
845
|
let S = 0;
|
|
834
846
|
K = setInterval(() => {
|
|
835
|
-
if (S >=
|
|
836
|
-
clearInterval(K), K = void 0,
|
|
847
|
+
if (S >= s.length) {
|
|
848
|
+
clearInterval(K), K = void 0, n.status = "DONE", Ve && (n.followUpReplies = Ve), L();
|
|
837
849
|
return;
|
|
838
850
|
}
|
|
839
|
-
|
|
840
|
-
},
|
|
851
|
+
n.content += s[S], S++, L();
|
|
852
|
+
}, It);
|
|
841
853
|
}
|
|
842
|
-
E.on("message:start",
|
|
843
|
-
const
|
|
844
|
-
V && E.on("form:submitted",
|
|
845
|
-
const
|
|
846
|
-
let
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
849
|
-
|
|
850
|
-
let
|
|
851
|
-
const
|
|
852
|
-
S.submitted && !
|
|
854
|
+
E.on("message:start", Ye), E.on("message:chunk", Qe), E.on("message:answer-complete", Ze), E.on("message:complete", Je), E.on("message:error", et);
|
|
855
|
+
const tt = (e) => V?.(e), nt = (e) => j?.(e);
|
|
856
|
+
V && E.on("form:submitted", tt), j && E.on("form:error", nt);
|
|
857
|
+
const $e = [];
|
|
858
|
+
let ot = !1;
|
|
859
|
+
const rt = (e) => {
|
|
860
|
+
if (ot) return;
|
|
861
|
+
$e.push(e.install(E));
|
|
862
|
+
let n = e.store.get().submitted;
|
|
863
|
+
const s = e.store.subscribe((S) => {
|
|
864
|
+
S.submitted && !n && (Ke.push(Nt(S.submitResult)), L()), n = S.submitted;
|
|
853
865
|
});
|
|
854
|
-
|
|
866
|
+
$e.push(s);
|
|
855
867
|
};
|
|
856
|
-
for (const e of
|
|
868
|
+
for (const e of l ?? []) e.schema != null ? rt(en(e)) : Jt(E, e).then((n) => rt(n)).catch(() => {
|
|
857
869
|
});
|
|
858
|
-
async function
|
|
859
|
-
const
|
|
860
|
-
if (!
|
|
861
|
-
if (
|
|
870
|
+
async function we(e, n) {
|
|
871
|
+
const s = e.trim();
|
|
872
|
+
if (!s && !n?.length || J) return;
|
|
873
|
+
if (B?.(s), J = !0, le = null, K) {
|
|
862
874
|
clearInterval(K), K = void 0;
|
|
863
875
|
const y = u.find((G) => G.id.startsWith("ago-intro-"));
|
|
864
876
|
y && !y.content ? u = u.filter((G) => G !== y) : y && (y.status = "DONE");
|
|
@@ -867,10 +879,10 @@ function wn(n, o) {
|
|
|
867
879
|
u.push({
|
|
868
880
|
id: `temp-user-${S}`,
|
|
869
881
|
conversationId: P || "",
|
|
870
|
-
content:
|
|
882
|
+
content: s,
|
|
871
883
|
role: "user",
|
|
872
884
|
status: "DONE",
|
|
873
|
-
attachments:
|
|
885
|
+
attachments: n && n.length > 0 ? Kt(n) : void 0,
|
|
874
886
|
createdAt: /* @__PURE__ */ new Date()
|
|
875
887
|
}), u.push({
|
|
876
888
|
id: `temp-assistant-${S}`,
|
|
@@ -879,185 +891,187 @@ function wn(n, o) {
|
|
|
879
891
|
role: "assistant",
|
|
880
892
|
status: "IN_PROGRESS",
|
|
881
893
|
createdAt: /* @__PURE__ */ new Date()
|
|
882
|
-
}),
|
|
894
|
+
}), L();
|
|
883
895
|
try {
|
|
884
|
-
const y = await E.sendMessage(
|
|
896
|
+
const y = await E.sendMessage(s, {
|
|
885
897
|
conversationId: P,
|
|
886
|
-
files:
|
|
898
|
+
files: n
|
|
887
899
|
});
|
|
888
|
-
y.conversationId && (P || (P = y.conversationId),
|
|
889
|
-
const G = u.find((
|
|
890
|
-
if (G && (G.id = `user-${S}`, G.conversationId = y.conversationId), !u.some((
|
|
891
|
-
const
|
|
892
|
-
|
|
900
|
+
y.conversationId && (P || (P = y.conversationId), ge?.setActiveThread(y.conversationId, y.createdAt));
|
|
901
|
+
const G = u.find((Y) => Y.id === `temp-user-${S}`);
|
|
902
|
+
if (G && (G.id = `user-${S}`, G.conversationId = y.conversationId), !u.some((Y) => Y.id === y.id)) {
|
|
903
|
+
const Y = u.findIndex((jt) => jt.id === `temp-assistant-${S}`);
|
|
904
|
+
Y >= 0 ? u[Y] = y : u.push(y);
|
|
893
905
|
}
|
|
894
|
-
u = u.filter((
|
|
906
|
+
u = u.filter((Y) => !Y.id.startsWith("temp-")), y.status !== "WAITING_CLIENT" && (J = !1), L(), g && Be();
|
|
895
907
|
} catch (y) {
|
|
896
|
-
le = y instanceof Error ? y.message : "Failed to send message",
|
|
908
|
+
le = y instanceof Error ? y.message : "Failed to send message", J = !1, u = u.filter((G) => !G.id.startsWith("temp-")), L();
|
|
897
909
|
}
|
|
898
910
|
}
|
|
899
|
-
async function
|
|
911
|
+
async function Be() {
|
|
900
912
|
try {
|
|
901
913
|
const e = await E.getConversations();
|
|
902
|
-
|
|
914
|
+
he.splice(0, he.length, ...e);
|
|
903
915
|
} catch {
|
|
904
916
|
}
|
|
905
|
-
return
|
|
917
|
+
return he;
|
|
906
918
|
}
|
|
907
|
-
async function
|
|
919
|
+
async function Dt(e) {
|
|
908
920
|
try {
|
|
909
|
-
const
|
|
910
|
-
|
|
921
|
+
const n = (await E.getConversation(e))?.messages ?? [];
|
|
922
|
+
n.length > 0 && u.length === 0 && (u = n, L());
|
|
911
923
|
} catch {
|
|
912
|
-
u.length === 0 && (
|
|
924
|
+
u.length === 0 && (ge?.clear(), P = void 0);
|
|
913
925
|
}
|
|
914
926
|
}
|
|
915
|
-
return
|
|
927
|
+
return L(), re && T?.matches || xe(), P ? Dt(P) : Ge === "streaming" && Ot(Ue), g && Be(), {
|
|
916
928
|
client: E,
|
|
917
|
-
element:
|
|
918
|
-
sendMessage:
|
|
929
|
+
element: be,
|
|
930
|
+
sendMessage: we,
|
|
919
931
|
...z || re ? {
|
|
920
|
-
open:
|
|
921
|
-
close:
|
|
922
|
-
toggle:
|
|
932
|
+
open: Ft,
|
|
933
|
+
close: Ht,
|
|
934
|
+
toggle: Pt
|
|
923
935
|
} : {},
|
|
924
|
-
session:
|
|
925
|
-
threads:
|
|
926
|
-
refreshThreads:
|
|
936
|
+
session: ge,
|
|
937
|
+
threads: he,
|
|
938
|
+
refreshThreads: Be,
|
|
927
939
|
destroy() {
|
|
928
|
-
K && clearInterval(K), E.off("message:start",
|
|
940
|
+
K && clearInterval(K), E.off("message:start", Ye), E.off("message:chunk", Qe), E.off("message:answer-complete", Ze), E.off("message:complete", Je), E.off("message:error", et), V && E.off("form:submitted", tt), j && E.off("form:error", nt), ot = !0, $e.forEach((e) => e()), be.remove(), $?.remove(), H?.remove(), pe?.remove(), X?.remove(), T?.removeEventListener("change", at), re && (document.removeEventListener("keydown", it), dt(), W && Re()), me && (me = !1, Re()), o.client || E.destroy();
|
|
929
941
|
}
|
|
930
942
|
};
|
|
931
|
-
function
|
|
932
|
-
if (!
|
|
943
|
+
function Ce() {
|
|
944
|
+
if (!U) return;
|
|
933
945
|
{
|
|
934
|
-
const
|
|
935
|
-
|
|
946
|
+
const s = ve === "left" ? "border-right" : "border-left";
|
|
947
|
+
T?.matches ? (U.style.width = "100%", d.style.borderRadius = "0", d.style.removeProperty(s)) : (U.style.width = typeof x == "number" ? `${x}px` : x, d.style.setProperty(s, `1px solid ${N}`));
|
|
936
948
|
}
|
|
937
949
|
const e = m === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
938
|
-
|
|
950
|
+
U.style.transform = Z ? "translateX(0)" : e, U.setAttribute("aria-hidden", Z ? "false" : "true"), $ && ($.style.display = Z ? "none" : "flex");
|
|
951
|
+
const n = Z && !!T?.matches;
|
|
952
|
+
n !== me && (me = n, n ? vt() : Re());
|
|
939
953
|
}
|
|
940
|
-
function
|
|
941
|
-
|
|
954
|
+
function Me() {
|
|
955
|
+
Z = !0, Ce(), xe(), M?.();
|
|
942
956
|
}
|
|
943
|
-
function
|
|
944
|
-
|
|
957
|
+
function Oe() {
|
|
958
|
+
Z = !1, Ce(), q?.();
|
|
945
959
|
}
|
|
946
|
-
function
|
|
947
|
-
|
|
960
|
+
function zt() {
|
|
961
|
+
Z ? Oe() : Me();
|
|
948
962
|
}
|
|
949
|
-
function
|
|
950
|
-
z ?
|
|
963
|
+
function Ft() {
|
|
964
|
+
z ? Me() : fe();
|
|
951
965
|
}
|
|
952
|
-
function
|
|
953
|
-
z ?
|
|
966
|
+
function Ht() {
|
|
967
|
+
z ? Oe() : ue();
|
|
954
968
|
}
|
|
955
|
-
function
|
|
956
|
-
z ?
|
|
969
|
+
function Pt() {
|
|
970
|
+
z ? zt() : W ? ue() : fe();
|
|
957
971
|
}
|
|
958
|
-
function
|
|
972
|
+
function Wt() {
|
|
959
973
|
return Array.from(d.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);
|
|
960
974
|
}
|
|
961
|
-
function
|
|
962
|
-
if (!
|
|
975
|
+
function it(e) {
|
|
976
|
+
if (!W) return;
|
|
963
977
|
if (e.key === "Escape") {
|
|
964
978
|
ue();
|
|
965
979
|
return;
|
|
966
980
|
}
|
|
967
981
|
if (e.key !== "Tab") return;
|
|
968
|
-
const
|
|
969
|
-
if (
|
|
982
|
+
const n = Wt();
|
|
983
|
+
if (n.length === 0) {
|
|
970
984
|
e.preventDefault();
|
|
971
985
|
return;
|
|
972
986
|
}
|
|
973
|
-
const
|
|
974
|
-
e.shiftKey && (y ===
|
|
987
|
+
const s = n[0], S = n[n.length - 1], y = document.activeElement;
|
|
988
|
+
e.shiftKey && (y === s || !d.contains(y)) ? (e.preventDefault(), S.focus()) : !e.shiftKey && (y === S || !d.contains(y)) && (e.preventDefault(), s.focus());
|
|
975
989
|
}
|
|
976
|
-
function
|
|
977
|
-
z ?
|
|
990
|
+
function at(e) {
|
|
991
|
+
z ? Ce() : !e.matches && W && ue(), L();
|
|
978
992
|
}
|
|
979
|
-
function
|
|
993
|
+
function st() {
|
|
980
994
|
return window.visualViewport?.height ?? window.innerHeight;
|
|
981
995
|
}
|
|
982
|
-
function
|
|
983
|
-
const e = window.visualViewport,
|
|
984
|
-
d.style.top = `${S}px`, H && (H.style.top = `${
|
|
996
|
+
function lt() {
|
|
997
|
+
const e = window.visualViewport, n = e?.offsetTop ?? 0, s = e?.height ?? ce, S = Math.min(0, n + s - ce);
|
|
998
|
+
d.style.top = `${S}px`, H && (H.style.top = `${n}px`);
|
|
985
999
|
}
|
|
986
|
-
function
|
|
1000
|
+
function Ee() {
|
|
987
1001
|
ie || (ie = requestAnimationFrame(() => {
|
|
988
|
-
ie = 0,
|
|
1002
|
+
ie = 0, lt();
|
|
989
1003
|
}));
|
|
990
1004
|
}
|
|
991
|
-
function
|
|
992
|
-
window.visualViewport?.addEventListener("resize",
|
|
1005
|
+
function Ut() {
|
|
1006
|
+
window.visualViewport?.addEventListener("resize", Ee), window.visualViewport?.addEventListener("scroll", Ee);
|
|
993
1007
|
}
|
|
994
|
-
function
|
|
995
|
-
window.visualViewport?.removeEventListener("resize",
|
|
1008
|
+
function dt() {
|
|
1009
|
+
window.visualViewport?.removeEventListener("resize", Ee), window.visualViewport?.removeEventListener("scroll", Ee), ie && (cancelAnimationFrame(ie), ie = 0);
|
|
996
1010
|
}
|
|
997
|
-
function
|
|
1011
|
+
function ct() {
|
|
998
1012
|
_.scrollTop = _.scrollHeight;
|
|
999
1013
|
}
|
|
1000
|
-
function
|
|
1014
|
+
function Gt() {
|
|
1001
1015
|
const e = h({
|
|
1002
1016
|
position: "fixed",
|
|
1003
1017
|
top: "0",
|
|
1004
1018
|
left: "0",
|
|
1005
1019
|
right: "0",
|
|
1006
|
-
height: `calc(${
|
|
1020
|
+
height: `calc(${Xe}px + env(safe-area-inset-top))`,
|
|
1007
1021
|
display: "none",
|
|
1008
1022
|
alignItems: "center",
|
|
1009
1023
|
justifyContent: "space-between",
|
|
1010
1024
|
padding: "env(safe-area-inset-top) 14px 0",
|
|
1011
|
-
backgroundColor:
|
|
1012
|
-
borderBottom: `1px solid ${
|
|
1025
|
+
backgroundColor: te,
|
|
1026
|
+
borderBottom: `1px solid ${N}`,
|
|
1013
1027
|
zIndex: "2147483001",
|
|
1014
|
-
fontFamily:
|
|
1028
|
+
fontFamily: ke
|
|
1015
1029
|
});
|
|
1016
1030
|
if (e.className = "ago-chat-widget-mobile-bar", f) {
|
|
1017
|
-
const
|
|
1018
|
-
|
|
1031
|
+
const s = document.createElement("img");
|
|
1032
|
+
s.src = f, s.alt = "", v(s, {
|
|
1019
1033
|
height: "28px",
|
|
1020
1034
|
width: "auto"
|
|
1021
|
-
}), e.appendChild(
|
|
1035
|
+
}), e.appendChild(s);
|
|
1022
1036
|
} else if (i) {
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1037
|
+
const s = document.createElement("span");
|
|
1038
|
+
s.textContent = i, v(s, {
|
|
1025
1039
|
fontSize: "15px",
|
|
1026
1040
|
fontWeight: "600",
|
|
1027
|
-
color:
|
|
1041
|
+
color: ee,
|
|
1028
1042
|
overflow: "hidden",
|
|
1029
1043
|
whiteSpace: "nowrap",
|
|
1030
1044
|
textOverflow: "ellipsis"
|
|
1031
|
-
}), e.appendChild(
|
|
1045
|
+
}), e.appendChild(s);
|
|
1032
1046
|
} else e.appendChild(h({}));
|
|
1033
|
-
const
|
|
1034
|
-
return
|
|
1047
|
+
const n = document.createElement("button");
|
|
1048
|
+
return n.type = "button", n.setAttribute("aria-label", "Close"), n.textContent = "×", v(n, {
|
|
1035
1049
|
border: "none",
|
|
1036
1050
|
background: "transparent",
|
|
1037
1051
|
fontSize: "26px",
|
|
1038
1052
|
lineHeight: "1",
|
|
1039
|
-
color:
|
|
1053
|
+
color: ee,
|
|
1040
1054
|
cursor: "pointer",
|
|
1041
1055
|
padding: "4px 8px"
|
|
1042
|
-
}),
|
|
1056
|
+
}), n.addEventListener("click", () => {
|
|
1043
1057
|
ue();
|
|
1044
|
-
}), e.appendChild(
|
|
1058
|
+
}), e.appendChild(n), e;
|
|
1045
1059
|
}
|
|
1046
|
-
function
|
|
1047
|
-
return typeof document.startViewTransition == "function" && !
|
|
1060
|
+
function Vt() {
|
|
1061
|
+
return typeof document.startViewTransition == "function" && !Lt?.matches && !!T?.matches;
|
|
1048
1062
|
}
|
|
1049
|
-
function
|
|
1050
|
-
const
|
|
1051
|
-
if (
|
|
1063
|
+
function pt(e) {
|
|
1064
|
+
const n = document;
|
|
1065
|
+
if (Vt() && n.startViewTransition) {
|
|
1052
1066
|
d.style.setProperty("view-transition-name", de), H?.style.setProperty("view-transition-name", `${de}-bar`);
|
|
1053
|
-
const
|
|
1067
|
+
const s = () => {
|
|
1054
1068
|
d.style.removeProperty("view-transition-name"), H?.style.removeProperty("view-transition-name");
|
|
1055
1069
|
};
|
|
1056
|
-
return
|
|
1070
|
+
return n.startViewTransition(e).finished.then(s, s);
|
|
1057
1071
|
}
|
|
1058
1072
|
return e(), Promise.resolve();
|
|
1059
1073
|
}
|
|
1060
|
-
function
|
|
1074
|
+
function ft(e) {
|
|
1061
1075
|
if (e)
|
|
1062
1076
|
X && d.parentElement?.insertBefore(X, d), v(d, {
|
|
1063
1077
|
position: "fixed",
|
|
@@ -1070,12 +1084,12 @@ function wn(n, o) {
|
|
|
1070
1084
|
border: "none",
|
|
1071
1085
|
borderRadius: "0",
|
|
1072
1086
|
boxShadow: "none",
|
|
1073
|
-
paddingTop: `calc(${
|
|
1087
|
+
paddingTop: `calc(${Xe}px + env(safe-area-inset-top))`,
|
|
1074
1088
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
1075
|
-
}), d.setAttribute("role", "dialog"), d.setAttribute("aria-modal", "true"), d.setAttribute("aria-label", i),
|
|
1089
|
+
}), d.setAttribute("role", "dialog"), d.setAttribute("aria-modal", "true"), d.setAttribute("aria-label", i), vt(), F && (F.style.display = "none"), H && (H.style.display = "flex");
|
|
1076
1090
|
else {
|
|
1077
1091
|
X?.remove(), X = void 0;
|
|
1078
|
-
for (const
|
|
1092
|
+
for (const n of [
|
|
1079
1093
|
"position",
|
|
1080
1094
|
"top",
|
|
1081
1095
|
"left",
|
|
@@ -1084,31 +1098,31 @@ function wn(n, o) {
|
|
|
1084
1098
|
"z-index",
|
|
1085
1099
|
"padding-top",
|
|
1086
1100
|
"padding-bottom"
|
|
1087
|
-
]) d.style.removeProperty(
|
|
1088
|
-
d.style.height =
|
|
1101
|
+
]) d.style.removeProperty(n);
|
|
1102
|
+
d.style.height = ye.height, d.style.border = ye.border, d.style.borderRadius = ye.borderRadius, d.style.boxShadow = ye.boxShadow, d.removeAttribute("role"), d.removeAttribute("aria-modal"), d.removeAttribute("aria-label"), Re(), F && (F.style.display = "flex"), H && (H.style.display = "none");
|
|
1089
1103
|
}
|
|
1090
1104
|
}
|
|
1091
1105
|
function fe() {
|
|
1092
|
-
if (
|
|
1106
|
+
if (W || !T?.matches) return Promise.resolve();
|
|
1093
1107
|
const e = d.getBoundingClientRect();
|
|
1094
|
-
if (e.height >=
|
|
1095
|
-
|
|
1108
|
+
if (e.height >= st() * 0.8) return Promise.resolve();
|
|
1109
|
+
W = !0, X = h({
|
|
1096
1110
|
width: `${e.width}px`,
|
|
1097
1111
|
height: `${e.height}px`
|
|
1098
|
-
}), X.className = "ago-chat-widget-spacer", X.setAttribute("aria-hidden", "true"), ce =
|
|
1099
|
-
const
|
|
1100
|
-
return
|
|
1101
|
-
|
|
1102
|
-
}),
|
|
1112
|
+
}), X.className = "ago-chat-widget-spacer", X.setAttribute("aria-hidden", "true"), ce = st(), d.style.setProperty("--ago-vh", `${ce}px`), lt(), Ut();
|
|
1113
|
+
const n = pt(() => ft(!0));
|
|
1114
|
+
return n.then(() => {
|
|
1115
|
+
ct(), xe();
|
|
1116
|
+
}), ct(), M?.(), n;
|
|
1103
1117
|
}
|
|
1104
1118
|
function ue() {
|
|
1105
|
-
if (!
|
|
1106
|
-
|
|
1107
|
-
const e =
|
|
1119
|
+
if (!W) return Promise.resolve();
|
|
1120
|
+
W = !1, dt(), d.querySelector("textarea")?.blur();
|
|
1121
|
+
const e = pt(() => ft(!1));
|
|
1108
1122
|
return e.then(() => d.style.removeProperty("--ago-vh")), ce = 0, q?.(), e;
|
|
1109
1123
|
}
|
|
1110
1124
|
}
|
|
1111
1125
|
export {
|
|
1112
|
-
|
|
1113
|
-
|
|
1126
|
+
kn as mountChatWidget,
|
|
1127
|
+
We as renderMarkdown
|
|
1114
1128
|
};
|