@useago/sdk 1.0.5 → 1.0.7
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/README.md +53 -0
- package/dist/angular.d.cts +2 -0
- package/dist/angular.d.ts +2 -0
- package/dist/{createConversationSession-lJWANT6T.cjs → createConversationSession-BuMXp0Ia.cjs} +1 -1
- package/dist/{createConversationSession-Boi0PjDU.js → createConversationSession-CCT1hCf8.js} +1 -1
- package/dist/createFormCollector-BwM7qTrp.js +276 -0
- package/dist/createFormCollector-DWzGKDwO.cjs +1 -0
- package/dist/devtools.d.cts +2 -0
- package/dist/devtools.d.ts +2 -0
- package/dist/{functions-C1-5vadY.js → functions-CApuQZ2b.js} +50 -43
- package/dist/{functions-DsmzgHjC.cjs → functions-Djnq-JAo.cjs} +1 -1
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +35 -35
- package/dist/react.cjs +3 -31
- package/dist/react.d.cts +19 -0
- package/dist/react.d.ts +19 -0
- package/dist/react.js +603 -8158
- package/dist/rolldown-runtime-16Nf8qvH.cjs +1 -0
- package/dist/testing.d.cts +2 -0
- package/dist/testing.d.ts +2 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +2 -0
- package/dist/vue.d.ts +2 -0
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +22 -0
- package/dist/widget.d.ts +22 -0
- package/dist/widget.js +347 -297
- package/package.json +3 -3
- package/dist/createFormCollector-BUqSA2Qw.js +0 -257
- package/dist/createFormCollector-CSG5ioym.cjs +0 -1
- package/dist/rolldown-runtime-CaekUdDJ.cjs +0 -1
- package/dist/rolldown-runtime-DxmricAu.js +0 -25
package/dist/widget.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { r as
|
|
3
|
-
import { t as
|
|
4
|
-
var
|
|
1
|
+
import { t as Ze, u as Je } from "./AgoClient-DYdIe_R4.js";
|
|
2
|
+
import { r as et, t as tt } from "./createFormCollector-BwM7qTrp.js";
|
|
3
|
+
import { t as nt } from "./createConversationSession-CCT1hCf8.js";
|
|
4
|
+
var ot = {
|
|
5
5
|
"&": "&",
|
|
6
6
|
"<": "<",
|
|
7
7
|
">": ">",
|
|
@@ -9,41 +9,41 @@ var Ye = {
|
|
|
9
9
|
"'": "'"
|
|
10
10
|
};
|
|
11
11
|
function U(o) {
|
|
12
|
-
return o.replace(/[&<>"']/g, (n) =>
|
|
12
|
+
return o.replace(/[&<>"']/g, (n) => ot[n]);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function Ne(o) {
|
|
15
15
|
const n = o.trim();
|
|
16
16
|
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(n) || !/^[a-z][a-z0-9+.-]*:/i.test(n) ? n : null;
|
|
17
17
|
}
|
|
18
|
-
var
|
|
19
|
-
function
|
|
20
|
-
const n = [],
|
|
18
|
+
var Me = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Q = "";
|
|
19
|
+
function B(o) {
|
|
20
|
+
const n = [], a = (u) => (n.push(u), `${Q}${n.length - 1}${Q}`);
|
|
21
21
|
let t = o;
|
|
22
|
-
return t = t.replace(/`([^`]+)`/g, (u, i) =>
|
|
23
|
-
const
|
|
24
|
-
return
|
|
22
|
+
return t = t.replace(/`([^`]+)`/g, (u, i) => a(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Me}">${U(i)}</code>`)), t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (u, i, f) => {
|
|
23
|
+
const l = Ne(f);
|
|
24
|
+
return l ? a(`<img alt="${U(i)}" src="${U(l)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : u;
|
|
25
25
|
}), t = t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (u, i, f) => {
|
|
26
|
-
const
|
|
27
|
-
return
|
|
26
|
+
const l = Ne(f);
|
|
27
|
+
return l ? a(`<a href="${U(l)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${B(i)}</a>`) : u;
|
|
28
28
|
}), t = U(t), t = t.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>"), t = t.replace(new RegExp(`${Q}(\\d+)${Q}`, "g"), (u, i) => n[Number(i)]), t;
|
|
29
29
|
}
|
|
30
|
-
function R(o, n,
|
|
30
|
+
function R(o, n, a) {
|
|
31
31
|
const t = document.createElement(o);
|
|
32
|
-
return Object.assign(t.style, n),
|
|
32
|
+
return Object.assign(t.style, n), a !== void 0 && (t.innerHTML = a), t;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var Be = /^ {0,3}([-*_])( *\1){2,} *$/, ze = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Fe = /^ {0,3}(```+|~~~+)/, Z = /^ {0,3}>\s?/, W = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, rt = [
|
|
35
35
|
"20px",
|
|
36
36
|
"18px",
|
|
37
37
|
"16px",
|
|
38
38
|
"15px",
|
|
39
39
|
"14px",
|
|
40
40
|
"13px"
|
|
41
|
-
],
|
|
42
|
-
function
|
|
43
|
-
return o.trim() === "" ||
|
|
41
|
+
], ue = (o) => o.match(/^\s*/)?.[0].length ?? 0;
|
|
42
|
+
function at(o) {
|
|
43
|
+
return o.trim() === "" || Be.test(o) || ze.test(o) || Fe.test(o) || Z.test(o) || W.test(o);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const n = o[0].match(
|
|
45
|
+
function He(o) {
|
|
46
|
+
const n = o[0].match(W), a = n[1].length, t = /\d/.test(n[2]), u = R(t ? "ol" : "ul", {
|
|
47
47
|
margin: "0 0 8px 0",
|
|
48
48
|
paddingLeft: "20px",
|
|
49
49
|
listStyleType: t ? "decimal" : "disc",
|
|
@@ -51,20 +51,20 @@ function Me(o) {
|
|
|
51
51
|
});
|
|
52
52
|
let i = 0;
|
|
53
53
|
for (; i < o.length; ) {
|
|
54
|
-
const f = o[i].match(
|
|
55
|
-
for (i++; i < o.length &&
|
|
56
|
-
|
|
54
|
+
const f = o[i].match(W), l = [];
|
|
55
|
+
for (i++; i < o.length && ue(o[i]) > a; )
|
|
56
|
+
l.push(o[i]), i++;
|
|
57
57
|
const p = R("li", {
|
|
58
58
|
display: "list-item",
|
|
59
59
|
margin: "2px 0",
|
|
60
60
|
lineHeight: "1.6"
|
|
61
61
|
}), c = f[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
62
|
-
c ? (p.style.listStyleType = "none", p.style.marginLeft = "-20px", p.innerHTML = `<span style="margin-right:6px">${c[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${
|
|
62
|
+
c ? (p.style.listStyleType = "none", p.style.marginLeft = "-20px", p.innerHTML = `<span style="margin-right:6px">${c[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${B(c[2])}`) : p.innerHTML = B(f[3]), l.filter((g) => W.test(g)).length > 0 && p.appendChild(He(l.filter((g) => g.trim() !== ""))), u.appendChild(p);
|
|
63
63
|
}
|
|
64
64
|
return u;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const n = (
|
|
66
|
+
function st(o) {
|
|
67
|
+
const n = (l) => l.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((p) => p.trim()), a = R("div", {
|
|
68
68
|
overflowX: "auto",
|
|
69
69
|
margin: "0 0 8px 0"
|
|
70
70
|
}), t = R("table", {
|
|
@@ -72,58 +72,58 @@ function et(o) {
|
|
|
72
72
|
width: "100%",
|
|
73
73
|
fontSize: "13px"
|
|
74
74
|
}), u = document.createElement("thead"), i = document.createElement("tr");
|
|
75
|
-
for (const
|
|
75
|
+
for (const l of n(o[0])) i.appendChild(R("th", {
|
|
76
76
|
border: "1px solid #dee3e8",
|
|
77
77
|
padding: "6px 10px",
|
|
78
78
|
textAlign: "left",
|
|
79
79
|
backgroundColor: "#f5f7fa",
|
|
80
80
|
fontWeight: "600"
|
|
81
|
-
},
|
|
81
|
+
}, B(l)));
|
|
82
82
|
u.appendChild(i), t.appendChild(u);
|
|
83
83
|
const f = document.createElement("tbody");
|
|
84
|
-
for (const
|
|
84
|
+
for (const l of o.slice(2)) {
|
|
85
85
|
const p = document.createElement("tr");
|
|
86
|
-
for (const c of n(
|
|
86
|
+
for (const c of n(l)) p.appendChild(R("td", {
|
|
87
87
|
border: "1px solid #dee3e8",
|
|
88
88
|
padding: "6px 10px"
|
|
89
|
-
},
|
|
89
|
+
}, B(c)));
|
|
90
90
|
f.appendChild(p);
|
|
91
91
|
}
|
|
92
|
-
return t.appendChild(f),
|
|
92
|
+
return t.appendChild(f), a.appendChild(t), a;
|
|
93
93
|
}
|
|
94
|
-
var
|
|
95
|
-
function
|
|
96
|
-
const n = document.createDocumentFragment(),
|
|
94
|
+
var it = (o) => !!o && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);
|
|
95
|
+
function ge(o) {
|
|
96
|
+
const n = document.createDocumentFragment(), a = o.replace(/\r\n?/g, `
|
|
97
97
|
`).split(`
|
|
98
98
|
`);
|
|
99
99
|
let t = 0;
|
|
100
|
-
for (; t <
|
|
101
|
-
const i =
|
|
100
|
+
for (; t < a.length; ) {
|
|
101
|
+
const i = a[t];
|
|
102
102
|
if (i.trim() === "") {
|
|
103
103
|
t++;
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
-
const f = i.match(
|
|
106
|
+
const f = i.match(Fe);
|
|
107
107
|
if (f) {
|
|
108
|
-
const c = f[1][0],
|
|
109
|
-
for (t++; t <
|
|
110
|
-
|
|
108
|
+
const c = f[1][0], g = [];
|
|
109
|
+
for (t++; t < a.length && !new RegExp(`^ {0,3}${c === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(a[t]); )
|
|
110
|
+
g.push(a[t]), t++;
|
|
111
111
|
t++;
|
|
112
|
-
const
|
|
113
|
-
|
|
112
|
+
const T = R("pre", { margin: "0 0 8px 0" });
|
|
113
|
+
T.appendChild(R("code", {
|
|
114
114
|
display: "block",
|
|
115
115
|
background: "#f5f5f5",
|
|
116
116
|
padding: "8px 12px",
|
|
117
117
|
borderRadius: "6px",
|
|
118
118
|
fontSize: "13px",
|
|
119
119
|
overflowX: "auto",
|
|
120
|
-
fontFamily:
|
|
120
|
+
fontFamily: Me,
|
|
121
121
|
whiteSpace: "pre"
|
|
122
|
-
}, U(
|
|
123
|
-
`)))), n.appendChild(
|
|
122
|
+
}, U(g.join(`
|
|
123
|
+
`)))), n.appendChild(T);
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
126
|
+
if (Be.test(i)) {
|
|
127
127
|
n.appendChild(R("hr", {
|
|
128
128
|
border: "none",
|
|
129
129
|
borderTop: "1px solid #dee3e8",
|
|
@@ -131,60 +131,60 @@ function fe(o) {
|
|
|
131
131
|
})), t++;
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const c =
|
|
134
|
+
const l = i.match(ze);
|
|
135
|
+
if (l) {
|
|
136
|
+
const c = l[1].length;
|
|
137
137
|
n.appendChild(R(`h${c}`, {
|
|
138
138
|
margin: "16px 0 8px 0",
|
|
139
|
-
fontSize:
|
|
139
|
+
fontSize: rt[c - 1],
|
|
140
140
|
fontWeight: "600",
|
|
141
141
|
lineHeight: "1.3"
|
|
142
|
-
},
|
|
142
|
+
}, B(l[2]))), t++;
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
145
|
if (Z.test(i)) {
|
|
146
146
|
const c = [];
|
|
147
|
-
for (; t <
|
|
148
|
-
c.push(
|
|
149
|
-
const
|
|
147
|
+
for (; t < a.length && Z.test(a[t]); )
|
|
148
|
+
c.push(a[t].replace(Z, "")), t++;
|
|
149
|
+
const g = R("blockquote", {
|
|
150
150
|
borderLeft: "4px solid #dee3e8",
|
|
151
151
|
paddingLeft: "12px",
|
|
152
152
|
margin: "0 0 8px 0",
|
|
153
153
|
fontStyle: "italic",
|
|
154
154
|
color: "#6b6d6f"
|
|
155
155
|
});
|
|
156
|
-
|
|
157
|
-
`))), n.appendChild(
|
|
156
|
+
g.appendChild(ge(c.join(`
|
|
157
|
+
`))), n.appendChild(g);
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
|
-
if (i.includes("|") &&
|
|
161
|
-
const c = [i,
|
|
162
|
-
for (t += 2; t <
|
|
163
|
-
c.push(
|
|
164
|
-
n.appendChild(
|
|
160
|
+
if (i.includes("|") && it(a[t + 1])) {
|
|
161
|
+
const c = [i, a[t + 1]];
|
|
162
|
+
for (t += 2; t < a.length && a[t].includes("|") && a[t].trim(); )
|
|
163
|
+
c.push(a[t]), t++;
|
|
164
|
+
n.appendChild(st(c));
|
|
165
165
|
continue;
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
168
|
-
const c = [],
|
|
169
|
-
for (; t <
|
|
170
|
-
if (
|
|
171
|
-
c.push(
|
|
167
|
+
if (W.test(i)) {
|
|
168
|
+
const c = [], g = ue(i);
|
|
169
|
+
for (; t < a.length && a[t].trim() !== ""; )
|
|
170
|
+
if (W.test(a[t]) || ue(a[t]) > g)
|
|
171
|
+
c.push(a[t]), t++;
|
|
172
172
|
else break;
|
|
173
|
-
n.appendChild(
|
|
173
|
+
n.appendChild(He(c));
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
176
|
const p = [i];
|
|
177
|
-
for (t++; t <
|
|
178
|
-
p.push(
|
|
177
|
+
for (t++; t < a.length && !at(a[t]); )
|
|
178
|
+
p.push(a[t]), t++;
|
|
179
179
|
n.appendChild(R("p", {
|
|
180
180
|
margin: "0 0 8px 0",
|
|
181
181
|
lineHeight: "1.6"
|
|
182
|
-
}, p.map((c) =>
|
|
182
|
+
}, p.map((c) => B(c)).join("<br>")));
|
|
183
183
|
}
|
|
184
184
|
const u = n.lastElementChild;
|
|
185
185
|
return u && (u.style.marginBottom = "0"), n;
|
|
186
186
|
}
|
|
187
|
-
var
|
|
187
|
+
var me = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)', Te = {
|
|
188
188
|
font: "--ago-font",
|
|
189
189
|
radius: "--ago-radius",
|
|
190
190
|
messageRadius: "--ago-message-radius",
|
|
@@ -198,172 +198,195 @@ var ue = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "S
|
|
|
198
198
|
mutedText: "--ago-muted-text-color",
|
|
199
199
|
border: "--ago-border-color",
|
|
200
200
|
accent: "--ago-accent-color"
|
|
201
|
-
},
|
|
202
|
-
function
|
|
201
|
+
}, he = "var(--ago-brand-color, #03182f)", xe = "var(--ago-brand-text-color, #fff)", lt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", Le = "var(--ago-header-text-color, #e8f0fe)", j = "var(--ago-panel-background, #fff)", dt = "var(--ago-messages-background, #fbfbfb)", Y = "var(--ago-text-color, #30373e)", ct = "var(--ago-muted-text-color, #6b6d6f)", I = "var(--ago-border-color, #dee3e8)", pe = "var(--ago-accent-color, #1b5fc4)", pt = "var(--ago-radius, 16px)", fe = "var(--ago-message-radius, 16px)";
|
|
202
|
+
function ft(o, n) {
|
|
203
203
|
if (n)
|
|
204
|
-
for (const
|
|
205
|
-
const t = n[
|
|
206
|
-
t != null && o.style.setProperty(
|
|
204
|
+
for (const a of Object.keys(Te)) {
|
|
205
|
+
const t = n[a];
|
|
206
|
+
t != null && o.style.setProperty(Te[a], t);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function w(o, n) {
|
|
210
210
|
Object.assign(o.style, n);
|
|
211
211
|
}
|
|
212
212
|
function x(o = {}) {
|
|
213
213
|
const n = document.createElement("div");
|
|
214
|
-
return
|
|
214
|
+
return w(n, o), n;
|
|
215
215
|
}
|
|
216
|
-
var
|
|
217
|
-
function
|
|
218
|
-
if (typeof
|
|
216
|
+
var Oe = "Form submitted.";
|
|
217
|
+
function ut(o) {
|
|
218
|
+
if (typeof o == "string") return o || null;
|
|
219
|
+
if (!o || typeof o != "object") return null;
|
|
220
|
+
const n = o;
|
|
221
|
+
if (typeof n.message == "string" && n.message) return n.message;
|
|
222
|
+
const a = n.result;
|
|
223
|
+
if (typeof a == "string" && a) return a;
|
|
224
|
+
if (a && typeof a == "object") {
|
|
225
|
+
const t = a.message;
|
|
226
|
+
if (typeof t == "string" && t) return t;
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
var De = "ago-chat-widget-keyframes";
|
|
231
|
+
function gt() {
|
|
232
|
+
if (typeof document > "u" || document.getElementById(De)) return;
|
|
219
233
|
const o = document.createElement("style");
|
|
220
|
-
o.id =
|
|
234
|
+
o.id = De, o.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(o);
|
|
221
235
|
}
|
|
222
|
-
function
|
|
236
|
+
function mt(o) {
|
|
223
237
|
const n = typeof o == "string" ? document.querySelector(o) : o;
|
|
224
238
|
if (!n) throw new Error(`mountChatWidget: target "${String(o)}" not found.`);
|
|
225
239
|
return n;
|
|
226
240
|
}
|
|
227
|
-
function
|
|
228
|
-
const { title:
|
|
229
|
-
if (!n.client && !n.config?.baseUrl) throw new
|
|
230
|
-
const
|
|
231
|
-
let
|
|
232
|
-
const
|
|
233
|
-
let k = n.conversationId ?? K?.getLastActiveThread() ?? void 0, d = [], O = !1,
|
|
234
|
-
const
|
|
241
|
+
function yt(o, n) {
|
|
242
|
+
const { title: a = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: u = "Type a message...", allowFiles: i = !1, height: f = 500, placement: l = "inline", width: p = 400, defaultOpen: c = !1, logoUrl: g, showAgentName: T = !1, theme: m, loadThreads: _ = !1, forms: X, formSubmittedMessage: L = Oe, onFollowUpClick: $, onMessageSent: be, onMessageReceived: J } = n;
|
|
243
|
+
if (!n.client && !n.config?.baseUrl) throw new Je("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
|
|
244
|
+
const b = n.client ?? new Ze(n.config), Ce = mt(o), z = l === "left" || l === "right", Ue = z && (n.launcher ?? !0);
|
|
245
|
+
let F = z ? c : !0;
|
|
246
|
+
const ee = n.persistConversation, K = ee ? nt(ee === !0 ? {} : ee) : void 0;
|
|
247
|
+
let k = n.conversationId ?? K?.getLastActiveThread() ?? void 0, d = [], O = !1, P = null;
|
|
248
|
+
const ye = [];
|
|
249
|
+
function We(e) {
|
|
250
|
+
if (typeof L == "function") {
|
|
251
|
+
const s = L(e);
|
|
252
|
+
if (typeof s == "string" && s) return s;
|
|
253
|
+
}
|
|
254
|
+
const r = ut(e);
|
|
255
|
+
return r || (typeof L == "string" ? L : Oe);
|
|
256
|
+
}
|
|
257
|
+
const q = [], H = x({
|
|
235
258
|
display: "flex",
|
|
236
259
|
flexDirection: "column",
|
|
237
260
|
height: z ? "100%" : typeof f == "number" ? `${f}px` : f,
|
|
238
|
-
border: `1px solid ${
|
|
239
|
-
borderRadius:
|
|
261
|
+
border: `1px solid ${I}`,
|
|
262
|
+
borderRadius: pt,
|
|
240
263
|
overflow: "hidden",
|
|
241
264
|
backgroundColor: j,
|
|
242
|
-
fontFamily:
|
|
265
|
+
fontFamily: me,
|
|
243
266
|
textAlign: "left",
|
|
244
267
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
245
268
|
});
|
|
246
|
-
|
|
269
|
+
H.className = "ago-chat-widget", ft(H, m);
|
|
247
270
|
const G = x({
|
|
248
271
|
padding: "14px 16px",
|
|
249
|
-
borderBottom: `1px solid ${
|
|
250
|
-
backgroundColor:
|
|
251
|
-
color:
|
|
272
|
+
borderBottom: `1px solid ${I}`,
|
|
273
|
+
backgroundColor: lt,
|
|
274
|
+
color: Le,
|
|
252
275
|
display: "flex",
|
|
253
276
|
alignItems: "center",
|
|
254
277
|
gap: "10px"
|
|
255
278
|
});
|
|
256
|
-
if (G.className = "ago-chat-widget__header",
|
|
279
|
+
if (G.className = "ago-chat-widget__header", g) {
|
|
257
280
|
const e = document.createElement("img");
|
|
258
|
-
e.src =
|
|
281
|
+
e.src = g, e.alt = "Logo", w(e, {
|
|
259
282
|
height: "24px",
|
|
260
283
|
width: "auto"
|
|
261
284
|
}), G.appendChild(e);
|
|
262
285
|
}
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
286
|
+
const te = document.createElement("h3");
|
|
287
|
+
if (te.textContent = a, w(te, {
|
|
265
288
|
margin: "0",
|
|
266
289
|
fontSize: "15px",
|
|
267
290
|
fontWeight: "600"
|
|
268
|
-
}), G.appendChild(
|
|
291
|
+
}), G.appendChild(te), z) {
|
|
269
292
|
const e = document.createElement("button");
|
|
270
|
-
e.type = "button", e.className = "ago-chat-widget__close", e.setAttribute("aria-label", "Close"), e.textContent = "×",
|
|
293
|
+
e.type = "button", e.className = "ago-chat-widget__close", e.setAttribute("aria-label", "Close"), e.textContent = "×", w(e, {
|
|
271
294
|
marginLeft: "auto",
|
|
272
295
|
background: "transparent",
|
|
273
296
|
border: "none",
|
|
274
|
-
color:
|
|
297
|
+
color: Le,
|
|
275
298
|
fontSize: "22px",
|
|
276
299
|
lineHeight: "1",
|
|
277
300
|
cursor: "pointer",
|
|
278
301
|
padding: "0 2px"
|
|
279
|
-
}), e.addEventListener("click", () =>
|
|
302
|
+
}), e.addEventListener("click", () => de()), G.appendChild(e);
|
|
280
303
|
}
|
|
281
|
-
const
|
|
304
|
+
const N = x({
|
|
282
305
|
flex: "1",
|
|
283
306
|
overflow: "auto",
|
|
284
307
|
padding: "16px",
|
|
285
|
-
backgroundColor:
|
|
308
|
+
backgroundColor: dt
|
|
286
309
|
});
|
|
287
|
-
|
|
288
|
-
const { inputRow:
|
|
310
|
+
N.className = "ago-chat-widget__messages";
|
|
311
|
+
const { inputRow: Pe, setDisabled: Ge, focus: ne } = ht({
|
|
289
312
|
placeholder: u,
|
|
290
313
|
allowFiles: i,
|
|
291
|
-
onSend: (e,
|
|
292
|
-
|
|
314
|
+
onSend: (e, r) => {
|
|
315
|
+
ae(e, r);
|
|
293
316
|
}
|
|
294
317
|
});
|
|
295
|
-
|
|
296
|
-
let V =
|
|
297
|
-
const
|
|
298
|
-
if (z && (
|
|
318
|
+
gt(), H.append(G, N, Pe);
|
|
319
|
+
let V = H, D, S;
|
|
320
|
+
const oe = l === "left" ? "left" : "right";
|
|
321
|
+
if (z && (D = x({
|
|
299
322
|
position: "fixed",
|
|
300
323
|
top: "0",
|
|
301
324
|
bottom: "0",
|
|
302
|
-
[
|
|
325
|
+
[oe]: "0",
|
|
303
326
|
width: typeof p == "number" ? `${p}px` : p,
|
|
304
327
|
maxWidth: "100vw",
|
|
305
328
|
display: "flex",
|
|
306
329
|
zIndex: "2147483000",
|
|
307
330
|
transition: "transform 0.3s ease",
|
|
308
331
|
boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
|
|
309
|
-
}),
|
|
332
|
+
}), D.className = "ago-chat-widget-panel", w(H, {
|
|
310
333
|
height: "100%",
|
|
311
334
|
width: "100%",
|
|
312
335
|
borderRadius: "0",
|
|
313
336
|
border: "none",
|
|
314
337
|
boxShadow: "none",
|
|
315
|
-
[
|
|
316
|
-
}),
|
|
317
|
-
if (
|
|
338
|
+
[oe === "left" ? "borderRight" : "borderLeft"]: `1px solid ${I}`
|
|
339
|
+
}), D.appendChild(H), V = D), Ue) {
|
|
340
|
+
if (S = document.createElement("button"), S.type = "button", S.className = "ago-chat-widget-launcher", S.setAttribute("aria-label", `Open ${a}`), w(S, {
|
|
318
341
|
position: "fixed",
|
|
319
342
|
bottom: "20px",
|
|
320
|
-
[
|
|
343
|
+
[oe]: "20px",
|
|
321
344
|
width: "56px",
|
|
322
345
|
height: "56px",
|
|
323
346
|
borderRadius: "50%",
|
|
324
347
|
border: "none",
|
|
325
|
-
backgroundColor:
|
|
326
|
-
color:
|
|
348
|
+
backgroundColor: he,
|
|
349
|
+
color: xe,
|
|
327
350
|
cursor: "pointer",
|
|
328
351
|
display: "flex",
|
|
329
352
|
alignItems: "center",
|
|
330
353
|
justifyContent: "center",
|
|
331
354
|
zIndex: "2147483000",
|
|
332
355
|
boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
|
|
333
|
-
fontFamily:
|
|
334
|
-
}),
|
|
356
|
+
fontFamily: me
|
|
357
|
+
}), g) {
|
|
335
358
|
const e = document.createElement("img");
|
|
336
|
-
e.src =
|
|
359
|
+
e.src = g, e.alt = "", w(e, {
|
|
337
360
|
width: "26px",
|
|
338
361
|
height: "26px",
|
|
339
362
|
objectFit: "contain"
|
|
340
|
-
}),
|
|
341
|
-
} else
|
|
342
|
-
|
|
363
|
+
}), S.appendChild(e);
|
|
364
|
+
} else S.appendChild(Qe());
|
|
365
|
+
S.addEventListener("click", () => le());
|
|
343
366
|
}
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
367
|
+
Ce.appendChild(V), S && Ce.appendChild(S), ie();
|
|
368
|
+
const ve = $ !== !1, we = $ === !1 ? void 0 : $ ?? ((e) => {
|
|
369
|
+
ae(e);
|
|
347
370
|
});
|
|
348
|
-
function
|
|
349
|
-
const
|
|
371
|
+
function je(e, r) {
|
|
372
|
+
const s = e.role === "user", h = x({
|
|
350
373
|
display: "flex",
|
|
351
374
|
flexDirection: "column",
|
|
352
|
-
alignItems:
|
|
375
|
+
alignItems: s ? "flex-end" : "flex-start",
|
|
353
376
|
marginBottom: "16px"
|
|
354
377
|
});
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
378
|
+
if (h.className = `ago-message ago-message--${e.role}`, !s && T && e.agent) {
|
|
379
|
+
const C = x({
|
|
357
380
|
fontSize: "13px",
|
|
358
381
|
fontWeight: "500",
|
|
359
382
|
color: Y,
|
|
360
383
|
marginBottom: "6px",
|
|
361
384
|
padding: "0 4px"
|
|
362
385
|
});
|
|
363
|
-
|
|
386
|
+
C.className = "ago-message__agent", C.textContent = e.agent.displayName || e.agent.name, h.appendChild(C);
|
|
364
387
|
}
|
|
365
|
-
if (!
|
|
366
|
-
const
|
|
388
|
+
if (!s && e.sources && e.sources.length > 0) {
|
|
389
|
+
const C = x({
|
|
367
390
|
display: "grid",
|
|
368
391
|
gridTemplateColumns: "1fr 1fr",
|
|
369
392
|
gap: "6px",
|
|
@@ -371,14 +394,14 @@ function ut(o, n) {
|
|
|
371
394
|
width: "100%",
|
|
372
395
|
maxWidth: "85%"
|
|
373
396
|
});
|
|
374
|
-
|
|
375
|
-
const
|
|
376
|
-
|
|
397
|
+
C.className = "ago-message__sources", e.sources.forEach((y, E) => {
|
|
398
|
+
const M = y.url ? document.createElement("a") : document.createElement("div");
|
|
399
|
+
y.url && M instanceof HTMLAnchorElement && (M.href = y.url, M.target = "_blank", M.rel = "noopener noreferrer"), w(M, {
|
|
377
400
|
display: "flex",
|
|
378
401
|
alignItems: "center",
|
|
379
402
|
gap: "8px",
|
|
380
403
|
padding: "8px 10px",
|
|
381
|
-
border: `1px solid ${
|
|
404
|
+
border: `1px solid ${I}`,
|
|
382
405
|
borderRadius: "8px",
|
|
383
406
|
backgroundColor: j,
|
|
384
407
|
textDecoration: "none",
|
|
@@ -386,13 +409,13 @@ function ut(o, n) {
|
|
|
386
409
|
fontSize: "12px",
|
|
387
410
|
overflow: "hidden"
|
|
388
411
|
});
|
|
389
|
-
const
|
|
412
|
+
const $e = x({
|
|
390
413
|
flexShrink: "0",
|
|
391
414
|
width: "18px",
|
|
392
415
|
height: "18px",
|
|
393
416
|
borderRadius: "3px",
|
|
394
|
-
border: `1px solid ${
|
|
395
|
-
color:
|
|
417
|
+
border: `1px solid ${pe}`,
|
|
418
|
+
color: pe,
|
|
396
419
|
fontSize: "11px",
|
|
397
420
|
fontWeight: "500",
|
|
398
421
|
display: "flex",
|
|
@@ -400,69 +423,89 @@ function ut(o, n) {
|
|
|
400
423
|
justifyContent: "center",
|
|
401
424
|
backgroundColor: "#f0f4ff"
|
|
402
425
|
});
|
|
403
|
-
|
|
404
|
-
const
|
|
426
|
+
$e.textContent = String(E + 1);
|
|
427
|
+
const ce = x({
|
|
405
428
|
overflow: "hidden",
|
|
406
429
|
textOverflow: "ellipsis",
|
|
407
430
|
whiteSpace: "nowrap"
|
|
408
431
|
});
|
|
409
|
-
|
|
410
|
-
}),
|
|
432
|
+
ce.textContent = y.title, ce.title = y.title, M.append($e, ce), C.appendChild(M);
|
|
433
|
+
}), h.appendChild(C);
|
|
411
434
|
}
|
|
412
435
|
const v = x({
|
|
413
|
-
maxWidth:
|
|
414
|
-
padding:
|
|
415
|
-
borderRadius:
|
|
416
|
-
backgroundColor:
|
|
417
|
-
color:
|
|
436
|
+
maxWidth: s ? "75%" : "100%",
|
|
437
|
+
padding: s ? "10px 14px" : "2px 8px",
|
|
438
|
+
borderRadius: s ? fe : "0",
|
|
439
|
+
backgroundColor: s ? he : "transparent",
|
|
440
|
+
color: s ? xe : Y,
|
|
418
441
|
wordBreak: "break-word",
|
|
419
|
-
fontSize: "
|
|
442
|
+
fontSize: "16px",
|
|
420
443
|
lineHeight: "1.6"
|
|
421
444
|
});
|
|
422
|
-
if (v.className = "ago-message__content", e.content ? v.appendChild(
|
|
423
|
-
const
|
|
445
|
+
if (v.className = "ago-message__content", e.content ? v.appendChild(ge(e.content)) : e.status === "IN_PROGRESS" && v.appendChild(Ye()), h.appendChild(v), r && e.followUpReplies && e.followUpReplies.length > 0) {
|
|
446
|
+
const C = x({
|
|
424
447
|
display: "flex",
|
|
425
448
|
flexWrap: "wrap",
|
|
426
449
|
gap: "8px",
|
|
427
450
|
marginTop: "10px"
|
|
428
451
|
});
|
|
429
|
-
|
|
430
|
-
for (const
|
|
431
|
-
const
|
|
432
|
-
|
|
452
|
+
C.className = "ago-message__followups";
|
|
453
|
+
for (const y of e.followUpReplies) {
|
|
454
|
+
const E = document.createElement("button");
|
|
455
|
+
E.type = "button", E.className = "ago-message__followup-btn", E.textContent = y, E.disabled = !ve, w(E, {
|
|
433
456
|
padding: "6px 14px",
|
|
434
457
|
fontSize: "14px",
|
|
435
|
-
borderRadius:
|
|
436
|
-
border: `1px solid ${
|
|
458
|
+
borderRadius: fe,
|
|
459
|
+
border: `1px solid ${I}`,
|
|
437
460
|
backgroundColor: j,
|
|
438
461
|
color: Y,
|
|
439
|
-
cursor:
|
|
462
|
+
cursor: ve ? "pointer" : "default",
|
|
440
463
|
transition: "border-color 0.15s"
|
|
441
|
-
}),
|
|
442
|
-
|
|
443
|
-
}),
|
|
444
|
-
|
|
445
|
-
}),
|
|
464
|
+
}), we && E.addEventListener("click", () => we(y)), E.addEventListener("mouseenter", () => {
|
|
465
|
+
E.style.borderColor = pe;
|
|
466
|
+
}), E.addEventListener("mouseleave", () => {
|
|
467
|
+
E.style.borderColor = I;
|
|
468
|
+
}), C.appendChild(E);
|
|
446
469
|
}
|
|
447
|
-
|
|
470
|
+
h.appendChild(C);
|
|
448
471
|
}
|
|
449
|
-
return
|
|
472
|
+
return h;
|
|
473
|
+
}
|
|
474
|
+
function Xe(e) {
|
|
475
|
+
const r = x({
|
|
476
|
+
display: "flex",
|
|
477
|
+
alignItems: "center",
|
|
478
|
+
gap: "8px",
|
|
479
|
+
padding: "10px 14px",
|
|
480
|
+
backgroundColor: "#f0fdf4",
|
|
481
|
+
color: "#15803d",
|
|
482
|
+
borderRadius: fe,
|
|
483
|
+
marginTop: "8px",
|
|
484
|
+
fontSize: "13px",
|
|
485
|
+
border: "1px solid #bbf7d0"
|
|
486
|
+
});
|
|
487
|
+
r.className = "ago-form-notice", r.setAttribute("role", "status");
|
|
488
|
+
const s = document.createElement("span");
|
|
489
|
+
s.textContent = "✓", s.setAttribute("aria-hidden", "true"), w(s, { fontWeight: "700" });
|
|
490
|
+
const h = document.createElement("span");
|
|
491
|
+
return h.textContent = e, r.append(s, h), r;
|
|
450
492
|
}
|
|
451
|
-
function
|
|
452
|
-
if (
|
|
453
|
-
const
|
|
493
|
+
function A() {
|
|
494
|
+
if (N.replaceChildren(), d.length === 0) {
|
|
495
|
+
const r = x({
|
|
454
496
|
textAlign: "center",
|
|
455
|
-
color:
|
|
497
|
+
color: ct,
|
|
456
498
|
padding: "24px 16px",
|
|
457
|
-
fontSize: "
|
|
499
|
+
fontSize: "16px",
|
|
458
500
|
lineHeight: "1.5"
|
|
459
501
|
});
|
|
460
|
-
|
|
461
|
-
} else d.forEach((
|
|
462
|
-
|
|
502
|
+
r.appendChild(ge(t)), N.appendChild(r);
|
|
503
|
+
} else d.forEach((r, s) => {
|
|
504
|
+
N.appendChild(je(r, s === d.length - 1));
|
|
463
505
|
});
|
|
464
|
-
|
|
465
|
-
|
|
506
|
+
for (const r of ye) N.appendChild(Xe(r));
|
|
507
|
+
if (P) {
|
|
508
|
+
const r = x({
|
|
466
509
|
padding: "10px 14px",
|
|
467
510
|
backgroundColor: "#fef2f2",
|
|
468
511
|
color: "#dc2626",
|
|
@@ -471,161 +514,168 @@ function ut(o, n) {
|
|
|
471
514
|
fontSize: "13px",
|
|
472
515
|
border: "1px solid #fecaca"
|
|
473
516
|
});
|
|
474
|
-
|
|
517
|
+
r.textContent = P, N.appendChild(r);
|
|
475
518
|
}
|
|
476
|
-
|
|
519
|
+
N.scrollTop = N.scrollHeight;
|
|
477
520
|
const e = d[d.length - 1];
|
|
478
|
-
|
|
521
|
+
Ge(O && e?.role === "assistant" && e.status === "IN_PROGRESS");
|
|
479
522
|
}
|
|
480
|
-
function
|
|
523
|
+
function Ke() {
|
|
481
524
|
for (let e = d.length - 1; e >= 0; e--) {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
525
|
+
const r = d[e];
|
|
526
|
+
if (r.role === "assistant" && r.status === "IN_PROGRESS") return r;
|
|
484
527
|
}
|
|
485
528
|
}
|
|
486
|
-
const
|
|
529
|
+
const Ee = (e) => {
|
|
487
530
|
k || (k = e.conversationId);
|
|
488
|
-
},
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
},
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
},
|
|
495
|
-
const
|
|
496
|
-
|
|
531
|
+
}, Se = (e) => {
|
|
532
|
+
const r = Ke();
|
|
533
|
+
r && (r.content += e.content, A());
|
|
534
|
+
}, Re = (e) => {
|
|
535
|
+
const r = d.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
536
|
+
r >= 0 ? d[r] = e : d.push(e), A(), ne();
|
|
537
|
+
}, _e = (e) => {
|
|
538
|
+
const r = d.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
|
|
539
|
+
r >= 0 ? d[r] = e : d.push(e), O = !1, A(), e.status === "DONE" && J?.({
|
|
497
540
|
id: e.id,
|
|
498
541
|
content: e.content
|
|
499
542
|
});
|
|
500
|
-
},
|
|
501
|
-
|
|
543
|
+
}, ke = (e) => {
|
|
544
|
+
P = e.error, O = !1, d = d.filter((r) => !r.id.startsWith("temp-")), A();
|
|
502
545
|
};
|
|
503
|
-
|
|
504
|
-
const
|
|
505
|
-
let
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
546
|
+
b.on("message:start", Ee), b.on("message:chunk", Se), b.on("message:answer-complete", Re), b.on("message:complete", _e), b.on("message:error", ke);
|
|
547
|
+
const re = [];
|
|
548
|
+
let Ae = !1;
|
|
549
|
+
const Ie = (e) => {
|
|
550
|
+
if (Ae) return;
|
|
551
|
+
re.push(e.install(b));
|
|
552
|
+
let r = e.store.get().submitted;
|
|
553
|
+
const s = e.store.subscribe((h) => {
|
|
554
|
+
h.submitted && !r && (ye.push(We(h.submitResult)), A()), r = h.submitted;
|
|
555
|
+
});
|
|
556
|
+
re.push(s);
|
|
557
|
+
};
|
|
558
|
+
for (const e of X ?? []) e.schema != null ? Ie(tt(e)) : et(b, e).then((r) => Ie(r)).catch(() => {
|
|
509
559
|
});
|
|
510
|
-
async function
|
|
511
|
-
const
|
|
512
|
-
if (!
|
|
513
|
-
|
|
514
|
-
const
|
|
560
|
+
async function ae(e, r) {
|
|
561
|
+
const s = e.trim();
|
|
562
|
+
if (!s && !r?.length || O) return;
|
|
563
|
+
be?.(s), O = !0, P = null;
|
|
564
|
+
const h = Date.now();
|
|
515
565
|
d.push({
|
|
516
|
-
id: `temp-user-${
|
|
566
|
+
id: `temp-user-${h}`,
|
|
517
567
|
conversationId: k || "",
|
|
518
|
-
content:
|
|
568
|
+
content: s,
|
|
519
569
|
role: "user",
|
|
520
570
|
status: "DONE",
|
|
521
571
|
createdAt: /* @__PURE__ */ new Date()
|
|
522
572
|
}), d.push({
|
|
523
|
-
id: `temp-assistant-${
|
|
573
|
+
id: `temp-assistant-${h}`,
|
|
524
574
|
conversationId: k || "",
|
|
525
575
|
content: "",
|
|
526
576
|
role: "assistant",
|
|
527
577
|
status: "IN_PROGRESS",
|
|
528
578
|
createdAt: /* @__PURE__ */ new Date()
|
|
529
|
-
}),
|
|
579
|
+
}), A();
|
|
530
580
|
try {
|
|
531
|
-
const v = await
|
|
581
|
+
const v = await b.sendMessage(s, {
|
|
532
582
|
conversationId: k,
|
|
533
|
-
files:
|
|
583
|
+
files: r
|
|
534
584
|
});
|
|
535
585
|
v.conversationId && (k || (k = v.conversationId), K?.setActiveThread(v.conversationId, v.createdAt));
|
|
536
|
-
const
|
|
537
|
-
if (
|
|
538
|
-
const
|
|
539
|
-
|
|
586
|
+
const C = d.find((y) => y.id === `temp-user-${h}`);
|
|
587
|
+
if (C && (C.id = `user-${h}`, C.conversationId = v.conversationId), !d.some((y) => y.id === v.id)) {
|
|
588
|
+
const y = d.findIndex((E) => E.id === `temp-assistant-${h}`);
|
|
589
|
+
y >= 0 ? d[y] = v : d.push(v);
|
|
540
590
|
}
|
|
541
|
-
d = d.filter((
|
|
591
|
+
d = d.filter((y) => !y.id.startsWith("temp-")), O = !1, A(), _ && se();
|
|
542
592
|
} catch (v) {
|
|
543
|
-
|
|
593
|
+
P = v instanceof Error ? v.message : "Failed to send message", O = !1, d = d.filter((C) => !C.id.startsWith("temp-")), A();
|
|
544
594
|
}
|
|
545
595
|
}
|
|
546
|
-
async function
|
|
596
|
+
async function se() {
|
|
547
597
|
try {
|
|
548
|
-
const e = await
|
|
598
|
+
const e = await b.getConversations();
|
|
549
599
|
q.splice(0, q.length, ...e);
|
|
550
600
|
} catch {
|
|
551
601
|
}
|
|
552
602
|
return q;
|
|
553
603
|
}
|
|
554
|
-
async function
|
|
604
|
+
async function qe(e) {
|
|
555
605
|
try {
|
|
556
|
-
const
|
|
557
|
-
|
|
606
|
+
const r = (await b.getConversation(e))?.messages ?? [];
|
|
607
|
+
r.length > 0 && d.length === 0 && (d = r, A());
|
|
558
608
|
} catch {
|
|
559
609
|
d.length === 0 && (K?.clear(), k = void 0);
|
|
560
610
|
}
|
|
561
611
|
}
|
|
562
|
-
return
|
|
563
|
-
client:
|
|
612
|
+
return A(), ne(), k && qe(k), _ && se(), {
|
|
613
|
+
client: b,
|
|
564
614
|
element: V,
|
|
565
|
-
sendMessage:
|
|
615
|
+
sendMessage: ae,
|
|
566
616
|
...z ? {
|
|
567
|
-
open:
|
|
568
|
-
close:
|
|
569
|
-
toggle:
|
|
617
|
+
open: le,
|
|
618
|
+
close: de,
|
|
619
|
+
toggle: Ve
|
|
570
620
|
} : {},
|
|
571
621
|
session: K,
|
|
572
622
|
threads: q,
|
|
573
|
-
refreshThreads:
|
|
623
|
+
refreshThreads: se,
|
|
574
624
|
destroy() {
|
|
575
|
-
|
|
625
|
+
b.off("message:start", Ee), b.off("message:chunk", Se), b.off("message:answer-complete", Re), b.off("message:complete", _e), b.off("message:error", ke), Ae = !0, re.forEach((e) => e()), V.remove(), S?.remove(), n.client || b.destroy();
|
|
576
626
|
}
|
|
577
627
|
};
|
|
578
628
|
function ie() {
|
|
579
|
-
if (!
|
|
580
|
-
const e =
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
function se() {
|
|
584
|
-
H = !0, ie(), te();
|
|
629
|
+
if (!D) return;
|
|
630
|
+
const e = l === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
631
|
+
D.style.transform = F ? "translateX(0)" : e, D.setAttribute("aria-hidden", F ? "false" : "true"), S && (S.style.display = F ? "none" : "flex");
|
|
585
632
|
}
|
|
586
633
|
function le() {
|
|
587
|
-
|
|
634
|
+
F = !0, ie(), ne();
|
|
635
|
+
}
|
|
636
|
+
function de() {
|
|
637
|
+
F = !1, ie();
|
|
588
638
|
}
|
|
589
|
-
function
|
|
590
|
-
|
|
639
|
+
function Ve() {
|
|
640
|
+
F ? de() : le();
|
|
591
641
|
}
|
|
592
|
-
function
|
|
593
|
-
const e = "http://www.w3.org/2000/svg",
|
|
594
|
-
|
|
595
|
-
const
|
|
596
|
-
return
|
|
642
|
+
function Qe() {
|
|
643
|
+
const e = "http://www.w3.org/2000/svg", r = document.createElementNS(e, "svg");
|
|
644
|
+
r.setAttribute("width", "26"), r.setAttribute("height", "26"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none");
|
|
645
|
+
const s = document.createElementNS(e, "path");
|
|
646
|
+
return s.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"), s.setAttribute("stroke", "currentColor"), s.setAttribute("stroke-width", "2"), s.setAttribute("stroke-linecap", "round"), s.setAttribute("stroke-linejoin", "round"), r.appendChild(s), r;
|
|
597
647
|
}
|
|
598
|
-
function
|
|
648
|
+
function Ye() {
|
|
599
649
|
const e = x({
|
|
600
650
|
display: "flex",
|
|
601
651
|
gap: "4px",
|
|
602
652
|
padding: "4px 0"
|
|
603
653
|
});
|
|
604
|
-
for (let
|
|
605
|
-
const
|
|
654
|
+
for (let r = 0; r < 3; r++) {
|
|
655
|
+
const s = x({
|
|
606
656
|
width: "6px",
|
|
607
657
|
height: "6px",
|
|
608
658
|
borderRadius: "50%",
|
|
609
659
|
backgroundColor: "#b5bfc8",
|
|
610
660
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
611
|
-
animationDelay: `${
|
|
661
|
+
animationDelay: `${r * 0.2}s`
|
|
612
662
|
});
|
|
613
|
-
e.appendChild(
|
|
663
|
+
e.appendChild(s);
|
|
614
664
|
}
|
|
615
665
|
return e;
|
|
616
666
|
}
|
|
617
667
|
}
|
|
618
|
-
function
|
|
668
|
+
function ht(o) {
|
|
619
669
|
let n = [];
|
|
620
|
-
const
|
|
621
|
-
|
|
670
|
+
const a = document.createElement("form");
|
|
671
|
+
w(a, {
|
|
622
672
|
display: "flex",
|
|
623
673
|
flexDirection: "column",
|
|
624
674
|
gap: "8px",
|
|
625
675
|
padding: "12px",
|
|
626
|
-
borderTop: `1px solid ${
|
|
676
|
+
borderTop: `1px solid ${I}`,
|
|
627
677
|
backgroundColor: j
|
|
628
|
-
}),
|
|
678
|
+
}), a.className = "ago-chat-input";
|
|
629
679
|
const t = x({
|
|
630
680
|
display: "flex",
|
|
631
681
|
flexWrap: "wrap",
|
|
@@ -635,39 +685,39 @@ function dt(o) {
|
|
|
635
685
|
gap: "8px",
|
|
636
686
|
alignItems: "flex-end"
|
|
637
687
|
}), i = document.createElement("textarea");
|
|
638
|
-
i.placeholder = o.placeholder, i.rows = 1,
|
|
688
|
+
i.placeholder = o.placeholder, i.rows = 1, w(i, {
|
|
639
689
|
flex: "1",
|
|
640
690
|
resize: "none",
|
|
641
691
|
padding: "10px 12px",
|
|
642
|
-
border: `1px solid ${
|
|
692
|
+
border: `1px solid ${I}`,
|
|
643
693
|
borderRadius: "12px",
|
|
644
|
-
fontSize: "
|
|
645
|
-
fontFamily:
|
|
694
|
+
fontSize: "16px",
|
|
695
|
+
fontFamily: me,
|
|
646
696
|
lineHeight: "1.4",
|
|
647
697
|
maxHeight: "120px",
|
|
648
698
|
outline: "none"
|
|
649
699
|
});
|
|
650
700
|
const f = document.createElement("button");
|
|
651
|
-
f.type = "submit", f.textContent = "Send",
|
|
701
|
+
f.type = "submit", f.textContent = "Send", w(f, {
|
|
652
702
|
padding: "10px 16px",
|
|
653
703
|
border: "none",
|
|
654
704
|
borderRadius: "12px",
|
|
655
|
-
backgroundColor:
|
|
656
|
-
color:
|
|
657
|
-
fontSize: "
|
|
705
|
+
backgroundColor: he,
|
|
706
|
+
color: xe,
|
|
707
|
+
fontSize: "16px",
|
|
658
708
|
fontWeight: "500",
|
|
659
709
|
cursor: "pointer"
|
|
660
710
|
});
|
|
661
|
-
let
|
|
662
|
-
o.allowFiles && (
|
|
711
|
+
let l = null, p = null;
|
|
712
|
+
o.allowFiles && (l = document.createElement("input"), l.type = "file", l.multiple = !0, w(l, { display: "none" }), p = document.createElement("button"), p.type = "button", p.textContent = "📎", w(p, {
|
|
663
713
|
padding: "10px 12px",
|
|
664
|
-
border: `1px solid ${
|
|
714
|
+
border: `1px solid ${I}`,
|
|
665
715
|
borderRadius: "12px",
|
|
666
716
|
backgroundColor: j,
|
|
667
717
|
cursor: "pointer",
|
|
668
718
|
fontSize: "14px"
|
|
669
|
-
}), p.addEventListener("click", () =>
|
|
670
|
-
n = [...n, ...Array.from(
|
|
719
|
+
}), p.addEventListener("click", () => l?.click()), l.addEventListener("change", () => {
|
|
720
|
+
n = [...n, ...Array.from(l?.files ?? [])], c();
|
|
671
721
|
}));
|
|
672
722
|
function c() {
|
|
673
723
|
t.replaceChildren(), n.forEach((m, _) => {
|
|
@@ -677,40 +727,40 @@ function dt(o) {
|
|
|
677
727
|
gap: "4px",
|
|
678
728
|
padding: "4px 8px",
|
|
679
729
|
backgroundColor: "#f0f4ff",
|
|
680
|
-
border: `1px solid ${
|
|
730
|
+
border: `1px solid ${I}`,
|
|
681
731
|
borderRadius: "8px",
|
|
682
732
|
fontSize: "12px"
|
|
683
|
-
}),
|
|
684
|
-
|
|
685
|
-
const
|
|
686
|
-
|
|
733
|
+
}), L = document.createElement("span");
|
|
734
|
+
L.textContent = m.name;
|
|
735
|
+
const $ = document.createElement("button");
|
|
736
|
+
$.type = "button", $.textContent = "×", w($, {
|
|
687
737
|
border: "none",
|
|
688
738
|
background: "transparent",
|
|
689
739
|
cursor: "pointer",
|
|
690
740
|
fontSize: "14px",
|
|
691
741
|
lineHeight: "1"
|
|
692
|
-
}),
|
|
693
|
-
n = n.filter((
|
|
694
|
-
}), X.append(
|
|
742
|
+
}), $.addEventListener("click", () => {
|
|
743
|
+
n = n.filter((be, J) => J !== _), c();
|
|
744
|
+
}), X.append(L, $), t.appendChild(X);
|
|
695
745
|
});
|
|
696
746
|
}
|
|
697
|
-
const
|
|
747
|
+
const g = () => {
|
|
698
748
|
const m = i.value, _ = n;
|
|
699
749
|
return i.value = "", n = [], c(), {
|
|
700
750
|
content: m,
|
|
701
751
|
files: _
|
|
702
752
|
};
|
|
703
|
-
},
|
|
704
|
-
const { content: m, files: _ } =
|
|
753
|
+
}, T = () => {
|
|
754
|
+
const { content: m, files: _ } = g();
|
|
705
755
|
(m.trim() || _.length > 0) && o.onSend(m.trim(), _.length > 0 ? _ : void 0);
|
|
706
756
|
};
|
|
707
|
-
return
|
|
708
|
-
m.preventDefault(),
|
|
757
|
+
return a.addEventListener("submit", (m) => {
|
|
758
|
+
m.preventDefault(), T();
|
|
709
759
|
}), i.addEventListener("keydown", (m) => {
|
|
710
|
-
m.key === "Enter" && !m.shiftKey && (m.preventDefault(),
|
|
711
|
-
}), p && u.appendChild(p), u.append(i, f),
|
|
712
|
-
inputRow:
|
|
713
|
-
getValueAndClear:
|
|
760
|
+
m.key === "Enter" && !m.shiftKey && (m.preventDefault(), T());
|
|
761
|
+
}), p && u.appendChild(p), u.append(i, f), l && a.appendChild(l), a.append(t, u), {
|
|
762
|
+
inputRow: a,
|
|
763
|
+
getValueAndClear: g,
|
|
714
764
|
setDisabled: (m) => {
|
|
715
765
|
i.disabled = m, f.disabled = m, f.style.opacity = m ? "0.6" : "1", f.style.cursor = m ? "not-allowed" : "pointer";
|
|
716
766
|
},
|
|
@@ -718,6 +768,6 @@ function dt(o) {
|
|
|
718
768
|
};
|
|
719
769
|
}
|
|
720
770
|
export {
|
|
721
|
-
|
|
722
|
-
|
|
771
|
+
yt as mountChatWidget,
|
|
772
|
+
ge as renderMarkdown
|
|
723
773
|
};
|