@useago/sdk 0.4.6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +98 -0
- package/LICENSE +201 -0
- package/NOTICE +10 -0
- package/README.md +19 -11
- package/dist/{AgoClient-rvTz2thR.js → AgoClient-BrYhSO5M.js} +32 -26
- package/dist/AgoClient-CPqPT5s6.cjs +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +5 -0
- package/dist/angular.d.ts +5 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-DGcM_Z3f.cjs → createConversationSession-CGRO0bs2.cjs} +1 -1
- package/dist/{createConversationSession-D-eq8VIo.js → createConversationSession-Dmqd80DX.js} +1 -1
- package/dist/{createFormCollector-DON4vdJV.js → createFormCollector-CPS2phYq.js} +51 -50
- package/dist/createFormCollector-DaWZsBsI.cjs +1 -0
- package/dist/devtools.cjs +3 -3
- package/dist/devtools.d.cts +7 -2
- package/dist/devtools.d.ts +7 -2
- package/dist/devtools.js +41 -35
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +38 -37
- package/dist/react.cjs +19 -19
- package/dist/react.d.cts +16 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +1516 -1490
- package/dist/testing.cjs +1 -0
- package/dist/testing.d.cts +482 -0
- package/dist/testing.d.ts +482 -0
- package/dist/testing.js +4 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +5 -0
- package/dist/vue.d.ts +5 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +6 -1
- package/dist/widget.d.ts +6 -1
- package/dist/widget.js +300 -286
- package/package.json +30 -9
- package/dist/AgoClient-D4EL6nva.cjs +0 -6
- package/dist/createFormCollector-IO6bfPQx.cjs +0 -1
package/dist/widget.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as
|
|
4
|
-
var
|
|
1
|
+
import { t as Ie } from "./AgoClient-BrYhSO5M.js";
|
|
2
|
+
import { t as Te } from "./createFormCollector-CPS2phYq.js";
|
|
3
|
+
import { t as Ne } from "./createConversationSession-Dmqd80DX.js";
|
|
4
|
+
var Oe = {
|
|
5
5
|
"&": "&",
|
|
6
6
|
"<": "<",
|
|
7
7
|
">": ">",
|
|
8
8
|
'"': """,
|
|
9
9
|
"'": "'"
|
|
10
10
|
};
|
|
11
|
-
function
|
|
12
|
-
return o.replace(/[&<>"']/g, (n) =>
|
|
11
|
+
function H(o) {
|
|
12
|
+
return o.replace(/[&<>"']/g, (n) => Oe[n]);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function de(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 = [], r = (g) => (n.push(g), `${
|
|
18
|
+
var ge = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', j = "";
|
|
19
|
+
function L(o) {
|
|
20
|
+
const n = [], r = (g) => (n.push(g), `${j}${n.length - 1}${j}`);
|
|
21
21
|
let e = o;
|
|
22
|
-
return e = e.replace(/`([^`]+)`/g, (g, a) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
}), e = e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (g, a,
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}), e =
|
|
22
|
+
return e = e.replace(/`([^`]+)`/g, (g, a) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${ge}">${H(a)}</code>`)), e = e.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (g, a, p) => {
|
|
23
|
+
const i = de(p);
|
|
24
|
+
return i ? r(`<img alt="${H(a)}" src="${H(i)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : g;
|
|
25
|
+
}), e = e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (g, a, p) => {
|
|
26
|
+
const i = de(p);
|
|
27
|
+
return i ? r(`<a href="${H(i)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${L(a)}</a>`) : g;
|
|
28
|
+
}), e = H(e), e = e.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>"), e = e.replace(new RegExp(`${j}(\\d+)${j}`, "g"), (g, a) => n[Number(a)]), e;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function w(o, n, r) {
|
|
31
31
|
const e = document.createElement(o);
|
|
32
32
|
return Object.assign(e.style, n), r !== void 0 && (e.innerHTML = r), e;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var ue = /^ {0,3}([-*_])( *\1){2,} *$/, me = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, he = /^ {0,3}(```+|~~~+)/, K = /^ {0,3}>\s?/, B = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Ae = [
|
|
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
|
+
], J = (o) => o.match(/^\s*/)?.[0].length ?? 0;
|
|
42
|
+
function Le(o) {
|
|
43
|
+
return o.trim() === "" || ue.test(o) || me.test(o) || he.test(o) || K.test(o) || B.test(o);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
const n = o[0].match(
|
|
45
|
+
function xe(o) {
|
|
46
|
+
const n = o[0].match(B), r = n[1].length, e = /\d/.test(n[2]), g = w(e ? "ol" : "ul", {
|
|
47
47
|
margin: "0 0 8px 0",
|
|
48
48
|
paddingLeft: "20px",
|
|
49
49
|
listStyleType: e ? "decimal" : "disc",
|
|
@@ -51,48 +51,48 @@ function ue(o) {
|
|
|
51
51
|
});
|
|
52
52
|
let a = 0;
|
|
53
53
|
for (; a < o.length; ) {
|
|
54
|
-
const
|
|
55
|
-
for (a++; a < o.length &&
|
|
56
|
-
|
|
57
|
-
const
|
|
54
|
+
const p = o[a].match(B), i = [];
|
|
55
|
+
for (a++; a < o.length && J(o[a]) > r; )
|
|
56
|
+
i.push(o[a]), a++;
|
|
57
|
+
const f = w("li", {
|
|
58
58
|
display: "list-item",
|
|
59
59
|
margin: "2px 0",
|
|
60
60
|
lineHeight: "1.6"
|
|
61
|
-
}),
|
|
62
|
-
|
|
61
|
+
}), d = p[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
62
|
+
d ? (f.style.listStyleType = "none", f.style.marginLeft = "-20px", f.innerHTML = `<span style="margin-right:6px">${d[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${L(d[2])}`) : f.innerHTML = L(p[3]), i.filter((b) => B.test(b)).length > 0 && f.appendChild(xe(i.filter((b) => b.trim() !== ""))), g.appendChild(f);
|
|
63
63
|
}
|
|
64
64
|
return g;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
const n = (
|
|
66
|
+
function De(o) {
|
|
67
|
+
const n = (i) => i.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((f) => f.trim()), r = w("div", {
|
|
68
68
|
overflowX: "auto",
|
|
69
69
|
margin: "0 0 8px 0"
|
|
70
|
-
}), e =
|
|
70
|
+
}), e = w("table", {
|
|
71
71
|
borderCollapse: "collapse",
|
|
72
72
|
width: "100%",
|
|
73
73
|
fontSize: "13px"
|
|
74
74
|
}), g = document.createElement("thead"), a = document.createElement("tr");
|
|
75
|
-
for (const
|
|
75
|
+
for (const i of n(o[0])) a.appendChild(w("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
|
+
}, L(i)));
|
|
82
82
|
g.appendChild(a), e.appendChild(g);
|
|
83
|
-
const
|
|
84
|
-
for (const
|
|
85
|
-
const
|
|
86
|
-
for (const
|
|
83
|
+
const p = document.createElement("tbody");
|
|
84
|
+
for (const i of o.slice(2)) {
|
|
85
|
+
const f = document.createElement("tr");
|
|
86
|
+
for (const d of n(i)) f.appendChild(w("td", {
|
|
87
87
|
border: "1px solid #dee3e8",
|
|
88
88
|
padding: "6px 10px"
|
|
89
|
-
},
|
|
90
|
-
|
|
89
|
+
}, L(d)));
|
|
90
|
+
p.appendChild(f);
|
|
91
91
|
}
|
|
92
|
-
return e.appendChild(
|
|
92
|
+
return e.appendChild(p), r.appendChild(e), r;
|
|
93
93
|
}
|
|
94
|
-
var
|
|
95
|
-
function
|
|
94
|
+
var Me = (o) => !!o && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);
|
|
95
|
+
function be(o) {
|
|
96
96
|
const n = document.createDocumentFragment(), r = o.replace(/\r\n?/g, `
|
|
97
97
|
`).split(`
|
|
98
98
|
`);
|
|
@@ -103,88 +103,88 @@ function me(o) {
|
|
|
103
103
|
e++;
|
|
104
104
|
continue;
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
for (e++; e < r.length && !new RegExp(`^ {0,3}${
|
|
110
|
-
|
|
106
|
+
const p = a.match(he);
|
|
107
|
+
if (p) {
|
|
108
|
+
const d = p[1][0], b = [];
|
|
109
|
+
for (e++; e < r.length && !new RegExp(`^ {0,3}${d === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(r[e]); )
|
|
110
|
+
b.push(r[e]), e++;
|
|
111
111
|
e++;
|
|
112
|
-
const
|
|
113
|
-
|
|
112
|
+
const N = w("pre", { margin: "0 0 8px 0" });
|
|
113
|
+
N.appendChild(w("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: ge,
|
|
121
121
|
whiteSpace: "pre"
|
|
122
|
-
},
|
|
123
|
-
`)))), n.appendChild(
|
|
122
|
+
}, H(b.join(`
|
|
123
|
+
`)))), n.appendChild(N);
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
|
-
if (
|
|
127
|
-
n.appendChild(
|
|
126
|
+
if (ue.test(a)) {
|
|
127
|
+
n.appendChild(w("hr", {
|
|
128
128
|
border: "none",
|
|
129
129
|
borderTop: "1px solid #dee3e8",
|
|
130
130
|
margin: "12px 0"
|
|
131
131
|
})), e++;
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
if (
|
|
136
|
-
const
|
|
137
|
-
n.appendChild(
|
|
134
|
+
const i = a.match(me);
|
|
135
|
+
if (i) {
|
|
136
|
+
const d = i[1].length;
|
|
137
|
+
n.appendChild(w(`h${d}`, {
|
|
138
138
|
margin: "16px 0 8px 0",
|
|
139
|
-
fontSize:
|
|
139
|
+
fontSize: Ae[d - 1],
|
|
140
140
|
fontWeight: "600",
|
|
141
141
|
lineHeight: "1.3"
|
|
142
|
-
},
|
|
142
|
+
}, L(i[2]))), e++;
|
|
143
143
|
continue;
|
|
144
144
|
}
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
147
|
-
for (; e < r.length &&
|
|
148
|
-
|
|
149
|
-
const
|
|
145
|
+
if (K.test(a)) {
|
|
146
|
+
const d = [];
|
|
147
|
+
for (; e < r.length && K.test(r[e]); )
|
|
148
|
+
d.push(r[e].replace(K, "")), e++;
|
|
149
|
+
const b = w("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
|
+
b.appendChild(be(d.join(`
|
|
157
|
+
`))), n.appendChild(b);
|
|
158
158
|
continue;
|
|
159
159
|
}
|
|
160
|
-
if (a.includes("|") &&
|
|
161
|
-
const
|
|
160
|
+
if (a.includes("|") && Me(r[e + 1])) {
|
|
161
|
+
const d = [a, r[e + 1]];
|
|
162
162
|
for (e += 2; e < r.length && r[e].includes("|") && r[e].trim(); )
|
|
163
|
-
|
|
164
|
-
n.appendChild(
|
|
163
|
+
d.push(r[e]), e++;
|
|
164
|
+
n.appendChild(De(d));
|
|
165
165
|
continue;
|
|
166
166
|
}
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
167
|
+
if (B.test(a)) {
|
|
168
|
+
const d = [], b = J(a);
|
|
169
169
|
for (; e < r.length && r[e].trim() !== ""; )
|
|
170
|
-
if (
|
|
171
|
-
|
|
170
|
+
if (B.test(r[e]) || J(r[e]) > b)
|
|
171
|
+
d.push(r[e]), e++;
|
|
172
172
|
else break;
|
|
173
|
-
n.appendChild(
|
|
173
|
+
n.appendChild(xe(d));
|
|
174
174
|
continue;
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
for (e++; e < r.length && !
|
|
178
|
-
|
|
179
|
-
n.appendChild(
|
|
176
|
+
const f = [a];
|
|
177
|
+
for (e++; e < r.length && !Le(r[e]); )
|
|
178
|
+
f.push(r[e]), e++;
|
|
179
|
+
n.appendChild(w("p", {
|
|
180
180
|
margin: "0 0 8px 0",
|
|
181
181
|
lineHeight: "1.6"
|
|
182
|
-
},
|
|
182
|
+
}, f.map((d) => L(d)).join("<br>")));
|
|
183
183
|
}
|
|
184
184
|
const g = n.lastElementChild;
|
|
185
185
|
return g && (g.style.marginBottom = "0"), n;
|
|
186
186
|
}
|
|
187
|
-
var
|
|
187
|
+
var Ce = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)', ce = {
|
|
188
188
|
font: "--ago-font",
|
|
189
189
|
radius: "--ago-radius",
|
|
190
190
|
messageRadius: "--ago-message-radius",
|
|
@@ -198,109 +198,109 @@ var he = '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
|
+
}, ve = "var(--ago-brand-color, #03182f)", Ee = "var(--ago-brand-text-color, #fff)", He = "var(--ago-header-background, var(--ago-brand-color, #03182f))", Be = "var(--ago-header-text-color, #e8f0fe)", z = "var(--ago-panel-background, #fff)", Ue = "var(--ago-messages-background, #fbfbfb)", X = "var(--ago-text-color, #30373e)", ze = "var(--ago-muted-text-color, #6b6d6f)", $ = "var(--ago-border-color, #dee3e8)", Z = "var(--ago-accent-color, #1b5fc4)", Fe = "var(--ago-radius, 16px)", pe = "var(--ago-message-radius, 16px)";
|
|
202
|
+
function We(o, n) {
|
|
203
203
|
if (n)
|
|
204
|
-
for (const r of Object.keys(
|
|
204
|
+
for (const r of Object.keys(ce)) {
|
|
205
205
|
const e = n[r];
|
|
206
|
-
e != null && o.style.setProperty(
|
|
206
|
+
e != null && o.style.setProperty(ce[r], e);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function R(o, n) {
|
|
210
210
|
Object.assign(o.style, n);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function x(o = {}) {
|
|
213
213
|
const n = document.createElement("div");
|
|
214
|
-
return
|
|
214
|
+
return R(n, o), n;
|
|
215
215
|
}
|
|
216
|
-
var
|
|
217
|
-
function
|
|
218
|
-
if (typeof document > "u" || document.getElementById(
|
|
216
|
+
var fe = "ago-chat-widget-keyframes";
|
|
217
|
+
function Pe() {
|
|
218
|
+
if (typeof document > "u" || document.getElementById(fe)) return;
|
|
219
219
|
const o = document.createElement("style");
|
|
220
|
-
o.id =
|
|
220
|
+
o.id = fe, 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
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function Ge(o) {
|
|
223
223
|
const n = typeof o == "string" ? document.querySelector(o) : o;
|
|
224
224
|
if (!n) throw new Error(`mountChatWidget: target "${String(o)}" not found.`);
|
|
225
225
|
return n;
|
|
226
226
|
}
|
|
227
|
-
function
|
|
228
|
-
const { title: r = "Chat", welcomeMessage: e = "Hello! How can I help you today?", placeholder: g = "Type a message...", allowFiles: a = !1, height:
|
|
227
|
+
function Ve(o, n) {
|
|
228
|
+
const { title: r = "Chat", welcomeMessage: e = "Hello! How can I help you today?", placeholder: g = "Type a message...", allowFiles: a = !1, height: p = 500, logoUrl: i, showAgentName: f = !1, theme: d, loadThreads: b = !1, forms: N, onFollowUpClick: u, onMessageSent: _, onMessageReceived: F } = n;
|
|
229
229
|
if (!n.client && !n.config?.baseUrl) throw new Error("mountChatWidget requires either `client` or `config` (with a baseUrl).");
|
|
230
|
-
const
|
|
231
|
-
let
|
|
232
|
-
const
|
|
230
|
+
const h = n.client ?? new Ie(n.config), O = Ge(o), W = n.persistConversation, D = W ? Ne(W === !0 ? {} : W) : void 0;
|
|
231
|
+
let S = n.conversationId ?? D?.getLastActiveThread() ?? void 0, l = [], I = !1, U = null;
|
|
232
|
+
const P = [], M = x({
|
|
233
233
|
display: "flex",
|
|
234
234
|
flexDirection: "column",
|
|
235
|
-
height: typeof
|
|
236
|
-
border: `1px solid ${
|
|
237
|
-
borderRadius:
|
|
235
|
+
height: typeof p == "number" ? `${p}px` : p,
|
|
236
|
+
border: `1px solid ${$}`,
|
|
237
|
+
borderRadius: Fe,
|
|
238
238
|
overflow: "hidden",
|
|
239
239
|
backgroundColor: z,
|
|
240
|
-
fontFamily:
|
|
240
|
+
fontFamily: Ce,
|
|
241
241
|
textAlign: "left",
|
|
242
242
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
243
243
|
});
|
|
244
|
-
|
|
245
|
-
const
|
|
244
|
+
M.className = "ago-chat-widget", We(M, d);
|
|
245
|
+
const G = x({
|
|
246
246
|
padding: "14px 16px",
|
|
247
|
-
borderBottom: `1px solid ${
|
|
248
|
-
backgroundColor:
|
|
249
|
-
color:
|
|
247
|
+
borderBottom: `1px solid ${$}`,
|
|
248
|
+
backgroundColor: He,
|
|
249
|
+
color: Be,
|
|
250
250
|
display: "flex",
|
|
251
251
|
alignItems: "center",
|
|
252
252
|
gap: "10px"
|
|
253
253
|
});
|
|
254
|
-
if (
|
|
254
|
+
if (G.className = "ago-chat-widget__header", i) {
|
|
255
255
|
const t = document.createElement("img");
|
|
256
|
-
t.src =
|
|
256
|
+
t.src = i, t.alt = "Logo", R(t, {
|
|
257
257
|
height: "24px",
|
|
258
258
|
width: "auto"
|
|
259
|
-
}),
|
|
259
|
+
}), G.appendChild(t);
|
|
260
260
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
261
|
+
const q = document.createElement("h3");
|
|
262
|
+
q.textContent = r, R(q, {
|
|
263
263
|
margin: "0",
|
|
264
264
|
fontSize: "15px",
|
|
265
265
|
fontWeight: "600"
|
|
266
|
-
}),
|
|
267
|
-
const
|
|
266
|
+
}), G.appendChild(q);
|
|
267
|
+
const T = x({
|
|
268
268
|
flex: "1",
|
|
269
269
|
overflow: "auto",
|
|
270
270
|
padding: "16px",
|
|
271
|
-
backgroundColor:
|
|
271
|
+
backgroundColor: Ue
|
|
272
272
|
});
|
|
273
|
-
|
|
274
|
-
const { inputRow:
|
|
273
|
+
T.className = "ago-chat-widget__messages";
|
|
274
|
+
const { inputRow: ye, setDisabled: we, focus: Re } = je({
|
|
275
275
|
placeholder: g,
|
|
276
276
|
allowFiles: a,
|
|
277
|
-
onSend: (t,
|
|
278
|
-
|
|
277
|
+
onSend: (t, s) => {
|
|
278
|
+
V(t, s);
|
|
279
279
|
}
|
|
280
280
|
});
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
|
|
281
|
+
Pe(), M.append(G, T, ye), O.appendChild(M);
|
|
282
|
+
const ee = u !== !1, te = u === !1 ? void 0 : u ?? ((t) => {
|
|
283
|
+
V(t);
|
|
284
284
|
});
|
|
285
|
-
function
|
|
286
|
-
const
|
|
285
|
+
function Se(t, s) {
|
|
286
|
+
const c = t.role === "user", y = x({
|
|
287
287
|
display: "flex",
|
|
288
288
|
flexDirection: "column",
|
|
289
|
-
alignItems:
|
|
289
|
+
alignItems: c ? "flex-end" : "flex-start",
|
|
290
290
|
marginBottom: "16px"
|
|
291
291
|
});
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
292
|
+
if (y.className = `ago-message ago-message--${t.role}`, !c && f && t.agent) {
|
|
293
|
+
const m = x({
|
|
294
294
|
fontSize: "13px",
|
|
295
295
|
fontWeight: "500",
|
|
296
|
-
color:
|
|
296
|
+
color: X,
|
|
297
297
|
marginBottom: "6px",
|
|
298
298
|
padding: "0 4px"
|
|
299
299
|
});
|
|
300
|
-
|
|
300
|
+
m.className = "ago-message__agent", m.textContent = t.agent.displayName || t.agent.name, y.appendChild(m);
|
|
301
301
|
}
|
|
302
|
-
if (!
|
|
303
|
-
const
|
|
302
|
+
if (!c && t.sources && t.sources.length > 0) {
|
|
303
|
+
const m = x({
|
|
304
304
|
display: "grid",
|
|
305
305
|
gridTemplateColumns: "1fr 1fr",
|
|
306
306
|
gap: "6px",
|
|
@@ -308,28 +308,28 @@ function Ke(o, n) {
|
|
|
308
308
|
width: "100%",
|
|
309
309
|
maxWidth: "85%"
|
|
310
310
|
});
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
|
|
311
|
+
m.className = "ago-message__sources", t.sources.forEach((C, E) => {
|
|
312
|
+
const A = C.url ? document.createElement("a") : document.createElement("div");
|
|
313
|
+
C.url && A instanceof HTMLAnchorElement && (A.href = C.url, A.target = "_blank", A.rel = "noopener noreferrer"), R(A, {
|
|
314
314
|
display: "flex",
|
|
315
315
|
alignItems: "center",
|
|
316
316
|
gap: "8px",
|
|
317
317
|
padding: "8px 10px",
|
|
318
|
-
border: `1px solid ${
|
|
318
|
+
border: `1px solid ${$}`,
|
|
319
319
|
borderRadius: "8px",
|
|
320
320
|
backgroundColor: z,
|
|
321
321
|
textDecoration: "none",
|
|
322
|
-
color:
|
|
322
|
+
color: X,
|
|
323
323
|
fontSize: "12px",
|
|
324
324
|
overflow: "hidden"
|
|
325
325
|
});
|
|
326
|
-
const
|
|
326
|
+
const le = x({
|
|
327
327
|
flexShrink: "0",
|
|
328
328
|
width: "18px",
|
|
329
329
|
height: "18px",
|
|
330
330
|
borderRadius: "3px",
|
|
331
|
-
border: `1px solid ${
|
|
332
|
-
color:
|
|
331
|
+
border: `1px solid ${Z}`,
|
|
332
|
+
color: Z,
|
|
333
333
|
fontSize: "11px",
|
|
334
334
|
fontWeight: "500",
|
|
335
335
|
display: "flex",
|
|
@@ -337,67 +337,76 @@ function Ke(o, n) {
|
|
|
337
337
|
justifyContent: "center",
|
|
338
338
|
backgroundColor: "#f0f4ff"
|
|
339
339
|
});
|
|
340
|
-
|
|
341
|
-
const
|
|
340
|
+
le.textContent = String(E + 1);
|
|
341
|
+
const Y = x({
|
|
342
342
|
overflow: "hidden",
|
|
343
343
|
textOverflow: "ellipsis",
|
|
344
344
|
whiteSpace: "nowrap"
|
|
345
345
|
});
|
|
346
|
-
|
|
347
|
-
}),
|
|
346
|
+
Y.textContent = C.title, Y.title = C.title, A.append(le, Y), m.appendChild(A);
|
|
347
|
+
}), y.appendChild(m);
|
|
348
348
|
}
|
|
349
|
-
const
|
|
350
|
-
maxWidth:
|
|
351
|
-
padding:
|
|
352
|
-
borderRadius:
|
|
353
|
-
backgroundColor:
|
|
354
|
-
color:
|
|
349
|
+
const v = x({
|
|
350
|
+
maxWidth: c ? "75%" : "100%",
|
|
351
|
+
padding: c ? "10px 14px" : "2px 8px",
|
|
352
|
+
borderRadius: c ? pe : "0",
|
|
353
|
+
backgroundColor: c ? ve : "transparent",
|
|
354
|
+
color: c ? Ee : X,
|
|
355
355
|
wordBreak: "break-word",
|
|
356
356
|
fontSize: "14px",
|
|
357
357
|
lineHeight: "1.6"
|
|
358
358
|
});
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
359
|
+
if (v.className = "ago-message__content", t.content ? v.appendChild(be(t.content)) : t.status === "IN_PROGRESS" && v.appendChild(ie()), y.appendChild(v), s && I && t.role === "assistant" && t.status === "DONE" && !(t.followUpReplies && t.followUpReplies.length > 0)) {
|
|
360
|
+
const m = x({
|
|
361
|
+
marginTop: "10px",
|
|
362
|
+
paddingLeft: "8px"
|
|
363
|
+
});
|
|
364
|
+
m.className = "ago-message__followups-loading", m.appendChild(ie()), y.appendChild(m);
|
|
365
|
+
}
|
|
366
|
+
if (s && t.followUpReplies && t.followUpReplies.length > 0) {
|
|
367
|
+
const m = x({
|
|
361
368
|
display: "flex",
|
|
362
369
|
flexWrap: "wrap",
|
|
363
370
|
gap: "8px",
|
|
364
371
|
marginTop: "10px"
|
|
365
372
|
});
|
|
366
|
-
|
|
367
|
-
for (const
|
|
368
|
-
const
|
|
369
|
-
|
|
373
|
+
m.className = "ago-message__followups";
|
|
374
|
+
for (const C of t.followUpReplies) {
|
|
375
|
+
const E = document.createElement("button");
|
|
376
|
+
E.type = "button", E.className = "ago-message__followup-btn", E.textContent = C, E.disabled = !ee, R(E, {
|
|
370
377
|
padding: "6px 14px",
|
|
371
378
|
fontSize: "13px",
|
|
372
|
-
borderRadius:
|
|
373
|
-
border: `1px solid ${
|
|
379
|
+
borderRadius: pe,
|
|
380
|
+
border: `1px solid ${$}`,
|
|
374
381
|
backgroundColor: z,
|
|
375
|
-
color:
|
|
376
|
-
cursor:
|
|
382
|
+
color: X,
|
|
383
|
+
cursor: ee ? "pointer" : "default",
|
|
377
384
|
transition: "border-color 0.15s"
|
|
378
|
-
}),
|
|
379
|
-
|
|
380
|
-
}),
|
|
381
|
-
|
|
382
|
-
}),
|
|
385
|
+
}), te && E.addEventListener("click", () => te(C)), E.addEventListener("mouseenter", () => {
|
|
386
|
+
E.style.borderColor = Z;
|
|
387
|
+
}), E.addEventListener("mouseleave", () => {
|
|
388
|
+
E.style.borderColor = $;
|
|
389
|
+
}), m.appendChild(E);
|
|
383
390
|
}
|
|
384
|
-
|
|
391
|
+
y.appendChild(m);
|
|
385
392
|
}
|
|
386
|
-
return
|
|
393
|
+
return y;
|
|
387
394
|
}
|
|
388
|
-
function
|
|
389
|
-
if (
|
|
390
|
-
const
|
|
395
|
+
function k() {
|
|
396
|
+
if (T.replaceChildren(), l.length === 0) {
|
|
397
|
+
const s = x({
|
|
391
398
|
textAlign: "center",
|
|
392
|
-
color:
|
|
399
|
+
color: ze,
|
|
393
400
|
padding: "24px 16px",
|
|
394
401
|
fontSize: "14px",
|
|
395
402
|
lineHeight: "1.5"
|
|
396
403
|
});
|
|
397
|
-
|
|
398
|
-
} else
|
|
399
|
-
|
|
400
|
-
|
|
404
|
+
s.textContent = e, T.appendChild(s);
|
|
405
|
+
} else l.forEach((s, c) => {
|
|
406
|
+
T.appendChild(Se(s, c === l.length - 1));
|
|
407
|
+
});
|
|
408
|
+
if (U) {
|
|
409
|
+
const s = x({
|
|
401
410
|
padding: "10px 14px",
|
|
402
411
|
backgroundColor: "#fef2f2",
|
|
403
412
|
color: "#dc2626",
|
|
@@ -406,218 +415,223 @@ function Ke(o, n) {
|
|
|
406
415
|
fontSize: "13px",
|
|
407
416
|
border: "1px solid #fecaca"
|
|
408
417
|
});
|
|
409
|
-
|
|
418
|
+
s.textContent = U, T.appendChild(s);
|
|
410
419
|
}
|
|
411
|
-
|
|
420
|
+
T.scrollTop = T.scrollHeight;
|
|
421
|
+
const t = l[l.length - 1];
|
|
422
|
+
we(I && t?.role === "assistant" && t.status === "IN_PROGRESS");
|
|
412
423
|
}
|
|
413
|
-
function
|
|
414
|
-
for (let t =
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
424
|
+
function _e() {
|
|
425
|
+
for (let t = l.length - 1; t >= 0; t--) {
|
|
426
|
+
const s = l[t];
|
|
427
|
+
if (s.role === "assistant" && s.status === "IN_PROGRESS") return s;
|
|
417
428
|
}
|
|
418
429
|
}
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
}, ne = (t) => {
|
|
422
|
-
const i = we();
|
|
423
|
-
i && (i.content += t.content, I());
|
|
430
|
+
const ne = (t) => {
|
|
431
|
+
S || (S = t.conversationId);
|
|
424
432
|
}, oe = (t) => {
|
|
425
|
-
const
|
|
426
|
-
|
|
433
|
+
const s = _e();
|
|
434
|
+
s && (s.content += t.content, k());
|
|
435
|
+
}, re = (t) => {
|
|
436
|
+
const s = l.findIndex((c) => c.id === t.id || c.role === "assistant" && c.status === "IN_PROGRESS");
|
|
437
|
+
s >= 0 ? l[s] = t : l.push(t), k();
|
|
438
|
+
}, ae = (t) => {
|
|
439
|
+
const s = l.findIndex((c) => c.id === t.id || c.role === "assistant" && c.status === "IN_PROGRESS");
|
|
440
|
+
s >= 0 ? l[s] = t : l.push(t), I = !1, k(), t.status === "DONE" && F?.({
|
|
427
441
|
id: t.id,
|
|
428
442
|
content: t.content
|
|
429
443
|
});
|
|
430
|
-
},
|
|
431
|
-
|
|
444
|
+
}, se = (t) => {
|
|
445
|
+
U = t.error, I = !1, l = l.filter((s) => !s.id.startsWith("temp-")), k();
|
|
432
446
|
};
|
|
433
|
-
|
|
434
|
-
const
|
|
435
|
-
async function
|
|
436
|
-
const
|
|
437
|
-
if (!
|
|
438
|
-
|
|
439
|
-
const
|
|
440
|
-
|
|
441
|
-
id: `temp-user-${
|
|
442
|
-
conversationId:
|
|
443
|
-
content:
|
|
447
|
+
h.on("message:start", ne), h.on("message:chunk", oe), h.on("message:answer-complete", re), h.on("message:complete", ae), h.on("message:error", se);
|
|
448
|
+
const ke = (N ?? []).map((t) => Te(t).install(h));
|
|
449
|
+
async function V(t, s) {
|
|
450
|
+
const c = t.trim();
|
|
451
|
+
if (!c && !s?.length || I) return;
|
|
452
|
+
_?.(c), I = !0, U = null;
|
|
453
|
+
const y = Date.now();
|
|
454
|
+
l.push({
|
|
455
|
+
id: `temp-user-${y}`,
|
|
456
|
+
conversationId: S || "",
|
|
457
|
+
content: c,
|
|
444
458
|
role: "user",
|
|
445
459
|
status: "DONE",
|
|
446
460
|
createdAt: /* @__PURE__ */ new Date()
|
|
447
|
-
}),
|
|
448
|
-
id: `temp-assistant-${
|
|
449
|
-
conversationId:
|
|
461
|
+
}), l.push({
|
|
462
|
+
id: `temp-assistant-${y}`,
|
|
463
|
+
conversationId: S || "",
|
|
450
464
|
content: "",
|
|
451
465
|
role: "assistant",
|
|
452
466
|
status: "IN_PROGRESS",
|
|
453
467
|
createdAt: /* @__PURE__ */ new Date()
|
|
454
|
-
}),
|
|
468
|
+
}), k();
|
|
455
469
|
try {
|
|
456
|
-
const
|
|
457
|
-
conversationId:
|
|
458
|
-
files:
|
|
470
|
+
const v = await h.sendMessage(c, {
|
|
471
|
+
conversationId: S,
|
|
472
|
+
files: s
|
|
459
473
|
});
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
const
|
|
464
|
-
|
|
474
|
+
v.conversationId && (S || (S = v.conversationId), D?.setActiveThread(v.conversationId, v.createdAt));
|
|
475
|
+
const m = l.find((C) => C.id === `temp-user-${y}`);
|
|
476
|
+
if (m && (m.id = `user-${y}`, m.conversationId = v.conversationId), !l.some((C) => C.id === v.id)) {
|
|
477
|
+
const C = l.findIndex((E) => E.id === `temp-assistant-${y}`);
|
|
478
|
+
C >= 0 ? l[C] = v : l.push(v);
|
|
465
479
|
}
|
|
466
|
-
|
|
467
|
-
} catch (
|
|
468
|
-
|
|
480
|
+
l = l.filter((C) => !C.id.startsWith("temp-")), I = !1, k(), b && Q();
|
|
481
|
+
} catch (v) {
|
|
482
|
+
U = v instanceof Error ? v.message : "Failed to send message", I = !1, l = l.filter((m) => !m.id.startsWith("temp-")), k();
|
|
469
483
|
}
|
|
470
484
|
}
|
|
471
|
-
async function
|
|
485
|
+
async function Q() {
|
|
472
486
|
try {
|
|
473
|
-
const t = await
|
|
474
|
-
|
|
487
|
+
const t = await h.getConversations();
|
|
488
|
+
P.splice(0, P.length, ...t);
|
|
475
489
|
} catch {
|
|
476
490
|
}
|
|
477
|
-
return
|
|
491
|
+
return P;
|
|
478
492
|
}
|
|
479
|
-
async function
|
|
493
|
+
async function $e(t) {
|
|
480
494
|
try {
|
|
481
|
-
const
|
|
482
|
-
|
|
495
|
+
const s = (await h.getConversation(t))?.messages ?? [];
|
|
496
|
+
s.length > 0 && l.length === 0 && (l = s, k());
|
|
483
497
|
} catch {
|
|
484
|
-
|
|
498
|
+
l.length === 0 && (D?.clear(), S = void 0);
|
|
485
499
|
}
|
|
486
500
|
}
|
|
487
|
-
return
|
|
488
|
-
client:
|
|
489
|
-
element:
|
|
490
|
-
sendMessage:
|
|
491
|
-
session:
|
|
492
|
-
threads:
|
|
493
|
-
refreshThreads:
|
|
501
|
+
return k(), Re(), S && $e(S), b && Q(), {
|
|
502
|
+
client: h,
|
|
503
|
+
element: M,
|
|
504
|
+
sendMessage: V,
|
|
505
|
+
session: D,
|
|
506
|
+
threads: P,
|
|
507
|
+
refreshThreads: Q,
|
|
494
508
|
destroy() {
|
|
495
|
-
|
|
509
|
+
h.off("message:start", ne), h.off("message:chunk", oe), h.off("message:answer-complete", re), h.off("message:complete", ae), h.off("message:error", se), ke.forEach((t) => t()), M.remove(), n.client || h.destroy();
|
|
496
510
|
}
|
|
497
511
|
};
|
|
498
|
-
function
|
|
499
|
-
const t =
|
|
512
|
+
function ie() {
|
|
513
|
+
const t = x({
|
|
500
514
|
display: "flex",
|
|
501
515
|
gap: "4px",
|
|
502
516
|
padding: "4px 0"
|
|
503
517
|
});
|
|
504
|
-
for (let
|
|
505
|
-
const
|
|
518
|
+
for (let s = 0; s < 3; s++) {
|
|
519
|
+
const c = x({
|
|
506
520
|
width: "6px",
|
|
507
521
|
height: "6px",
|
|
508
522
|
borderRadius: "50%",
|
|
509
523
|
backgroundColor: "#b5bfc8",
|
|
510
524
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
511
|
-
animationDelay: `${
|
|
525
|
+
animationDelay: `${s * 0.2}s`
|
|
512
526
|
});
|
|
513
|
-
t.appendChild(
|
|
527
|
+
t.appendChild(c);
|
|
514
528
|
}
|
|
515
529
|
return t;
|
|
516
530
|
}
|
|
517
531
|
}
|
|
518
|
-
function
|
|
532
|
+
function je(o) {
|
|
519
533
|
let n = [];
|
|
520
534
|
const r = document.createElement("form");
|
|
521
|
-
|
|
535
|
+
R(r, {
|
|
522
536
|
display: "flex",
|
|
523
537
|
flexDirection: "column",
|
|
524
538
|
gap: "8px",
|
|
525
539
|
padding: "12px",
|
|
526
|
-
borderTop: `1px solid ${
|
|
540
|
+
borderTop: `1px solid ${$}`,
|
|
527
541
|
backgroundColor: z
|
|
528
542
|
}), r.className = "ago-chat-input";
|
|
529
|
-
const e =
|
|
543
|
+
const e = x({
|
|
530
544
|
display: "flex",
|
|
531
545
|
flexWrap: "wrap",
|
|
532
546
|
gap: "6px"
|
|
533
|
-
}), g =
|
|
547
|
+
}), g = x({
|
|
534
548
|
display: "flex",
|
|
535
549
|
gap: "8px",
|
|
536
550
|
alignItems: "flex-end"
|
|
537
551
|
}), a = document.createElement("textarea");
|
|
538
|
-
a.placeholder = o.placeholder, a.rows = 1,
|
|
552
|
+
a.placeholder = o.placeholder, a.rows = 1, R(a, {
|
|
539
553
|
flex: "1",
|
|
540
554
|
resize: "none",
|
|
541
555
|
padding: "10px 12px",
|
|
542
|
-
border: `1px solid ${
|
|
556
|
+
border: `1px solid ${$}`,
|
|
543
557
|
borderRadius: "12px",
|
|
544
558
|
fontSize: "14px",
|
|
545
|
-
fontFamily:
|
|
559
|
+
fontFamily: Ce,
|
|
546
560
|
lineHeight: "1.4",
|
|
547
561
|
maxHeight: "120px",
|
|
548
562
|
outline: "none"
|
|
549
563
|
});
|
|
550
|
-
const
|
|
551
|
-
|
|
564
|
+
const p = document.createElement("button");
|
|
565
|
+
p.type = "submit", p.textContent = "Send", R(p, {
|
|
552
566
|
padding: "10px 16px",
|
|
553
567
|
border: "none",
|
|
554
568
|
borderRadius: "12px",
|
|
555
|
-
backgroundColor:
|
|
556
|
-
color:
|
|
569
|
+
backgroundColor: ve,
|
|
570
|
+
color: Ee,
|
|
557
571
|
fontSize: "14px",
|
|
558
572
|
fontWeight: "500",
|
|
559
573
|
cursor: "pointer"
|
|
560
574
|
});
|
|
561
|
-
let
|
|
562
|
-
o.allowFiles && (
|
|
575
|
+
let i = null, f = null;
|
|
576
|
+
o.allowFiles && (i = document.createElement("input"), i.type = "file", i.multiple = !0, R(i, { display: "none" }), f = document.createElement("button"), f.type = "button", f.textContent = "📎", R(f, {
|
|
563
577
|
padding: "10px 12px",
|
|
564
|
-
border: `1px solid ${
|
|
578
|
+
border: `1px solid ${$}`,
|
|
565
579
|
borderRadius: "12px",
|
|
566
580
|
backgroundColor: z,
|
|
567
581
|
cursor: "pointer",
|
|
568
582
|
fontSize: "14px"
|
|
569
|
-
}),
|
|
570
|
-
n = [...n, ...Array.from(
|
|
583
|
+
}), f.addEventListener("click", () => i?.click()), i.addEventListener("change", () => {
|
|
584
|
+
n = [...n, ...Array.from(i?.files ?? [])], d();
|
|
571
585
|
}));
|
|
572
|
-
function
|
|
573
|
-
e.replaceChildren(), n.forEach((
|
|
574
|
-
const
|
|
586
|
+
function d() {
|
|
587
|
+
e.replaceChildren(), n.forEach((u, _) => {
|
|
588
|
+
const F = x({
|
|
575
589
|
display: "flex",
|
|
576
590
|
alignItems: "center",
|
|
577
591
|
gap: "4px",
|
|
578
592
|
padding: "4px 8px",
|
|
579
593
|
backgroundColor: "#f0f4ff",
|
|
580
|
-
border: `1px solid ${
|
|
594
|
+
border: `1px solid ${$}`,
|
|
581
595
|
borderRadius: "8px",
|
|
582
596
|
fontSize: "12px"
|
|
583
|
-
}),
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
|
|
597
|
+
}), h = document.createElement("span");
|
|
598
|
+
h.textContent = u.name;
|
|
599
|
+
const O = document.createElement("button");
|
|
600
|
+
O.type = "button", O.textContent = "×", R(O, {
|
|
587
601
|
border: "none",
|
|
588
602
|
background: "transparent",
|
|
589
603
|
cursor: "pointer",
|
|
590
604
|
fontSize: "14px",
|
|
591
605
|
lineHeight: "1"
|
|
592
|
-
}),
|
|
593
|
-
n = n.filter((
|
|
594
|
-
}),
|
|
606
|
+
}), O.addEventListener("click", () => {
|
|
607
|
+
n = n.filter((W, D) => D !== _), d();
|
|
608
|
+
}), F.append(h, O), e.appendChild(F);
|
|
595
609
|
});
|
|
596
610
|
}
|
|
597
|
-
const
|
|
598
|
-
const
|
|
599
|
-
return a.value = "", n = [],
|
|
600
|
-
content:
|
|
601
|
-
files:
|
|
611
|
+
const b = () => {
|
|
612
|
+
const u = a.value, _ = n;
|
|
613
|
+
return a.value = "", n = [], d(), {
|
|
614
|
+
content: u,
|
|
615
|
+
files: _
|
|
602
616
|
};
|
|
603
|
-
},
|
|
604
|
-
const { content:
|
|
605
|
-
(
|
|
617
|
+
}, N = () => {
|
|
618
|
+
const { content: u, files: _ } = b();
|
|
619
|
+
(u.trim() || _.length > 0) && o.onSend(u.trim(), _.length > 0 ? _ : void 0);
|
|
606
620
|
};
|
|
607
|
-
return r.addEventListener("submit", (
|
|
608
|
-
|
|
609
|
-
}), a.addEventListener("keydown", (
|
|
610
|
-
|
|
611
|
-
}),
|
|
621
|
+
return r.addEventListener("submit", (u) => {
|
|
622
|
+
u.preventDefault(), N();
|
|
623
|
+
}), a.addEventListener("keydown", (u) => {
|
|
624
|
+
u.key === "Enter" && !u.shiftKey && (u.preventDefault(), N());
|
|
625
|
+
}), f && g.appendChild(f), g.append(a, p), i && r.appendChild(i), r.append(e, g), {
|
|
612
626
|
inputRow: r,
|
|
613
|
-
getValueAndClear:
|
|
614
|
-
setDisabled: (
|
|
615
|
-
a.disabled =
|
|
627
|
+
getValueAndClear: b,
|
|
628
|
+
setDisabled: (u) => {
|
|
629
|
+
a.disabled = u, p.disabled = u, p.style.opacity = u ? "0.6" : "1", p.style.cursor = u ? "not-allowed" : "pointer";
|
|
616
630
|
},
|
|
617
631
|
focus: () => a.focus()
|
|
618
632
|
};
|
|
619
633
|
}
|
|
620
634
|
export {
|
|
621
|
-
|
|
622
|
-
|
|
635
|
+
Ve as mountChatWidget,
|
|
636
|
+
be as renderMarkdown
|
|
623
637
|
};
|