deep-chat-dev 9.0.121 → 9.0.123
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 +3 -3
- package/custom-elements.json +1719 -1687
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.js +961 -959
- package/dist/services/openAI/openAIChatIO.d.ts.map +1 -1
- package/dist/types/stream.d.ts +4 -3
- package/dist/types/stream.d.ts.map +1 -1
- package/dist/utils/HTTP/customHandler.d.ts.map +1 -1
- package/dist/utils/HTTP/websocket.d.ts +7 -0
- package/dist/utils/HTTP/websocket.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/deepChat.js
CHANGED
@@ -241,28 +241,28 @@ var ws = /*#__PURE__*/function () {
|
|
241
241
|
return ws;
|
242
242
|
}();
|
243
243
|
var Gn = /*#__PURE__*/function () {
|
244
|
-
function
|
244
|
+
function Ve(e, t) {
|
245
245
|
var _this = this;
|
246
|
-
_classCallCheck(this,
|
246
|
+
_classCallCheck(this, Ve);
|
247
247
|
var n;
|
248
|
-
var i =
|
249
|
-
this.elementRef =
|
248
|
+
var i = Ve.processConfig(t, e.textInput);
|
249
|
+
this.elementRef = Ve.createContainerElement((n = i == null ? void 0 : i.styles) == null ? void 0 : n.container), this.inputElementRef = this.createInputElement(i), this._config = i, this.elementRef.appendChild(this.inputElementRef), setTimeout(function () {
|
250
250
|
var r;
|
251
251
|
Ss.add(_this.inputElementRef, (r = e.textInput) == null ? void 0 : r.characterLimit, e._validationHandler);
|
252
252
|
});
|
253
253
|
}
|
254
|
-
_createClass(
|
254
|
+
_createClass(Ve, [{
|
255
255
|
key: "createInputElement",
|
256
256
|
value: function createInputElement(e) {
|
257
257
|
var i, n, r;
|
258
258
|
var t = document.createElement("div");
|
259
|
-
return t.id =
|
259
|
+
return t.id = Ve.TEXT_INPUT_ID, t.classList.add("text-input-styling", "text-input-placeholder"), t.innerText = ((i = e == null ? void 0 : e.placeholder) == null ? void 0 : i.text) || "Ask me anything!", be.IS_CHROMIUM && Ve.preventAutomaticScrollUpOnNewLine(t), typeof (e == null ? void 0 : e.disabled) == "boolean" && e.disabled === !0 ? (t.contentEditable = "false", t.classList.add("text-input-disabled")) : (t.contentEditable = "true", this.addEventListeners(t, e)), Object.assign(t.style, (n = e == null ? void 0 : e.styles) == null ? void 0 : n.text), Object.assign(t.style, (r = e == null ? void 0 : e.placeholder) == null ? void 0 : r.style), t;
|
260
260
|
}
|
261
261
|
}, {
|
262
262
|
key: "removeTextIfPlaceholder",
|
263
263
|
value: function removeTextIfPlaceholder() {
|
264
264
|
var e, t, i, n;
|
265
|
-
this.inputElementRef.classList.contains("text-input-placeholder") && !this.inputElementRef.classList.contains("text-input-disabled") && ((e = this._config.placeholder) != null && e.style && (T.unsetStyle(this.inputElementRef, (t = this._config.placeholder) == null ? void 0 : t.style), Object.assign(this.inputElementRef.style, (n = (i = this._config) == null ? void 0 : i.styles) == null ? void 0 : n.text)),
|
265
|
+
this.inputElementRef.classList.contains("text-input-placeholder") && !this.inputElementRef.classList.contains("text-input-disabled") && ((e = this._config.placeholder) != null && e.style && (T.unsetStyle(this.inputElementRef, (t = this._config.placeholder) == null ? void 0 : t.style), Object.assign(this.inputElementRef.style, (n = (i = this._config) == null ? void 0 : i.styles) == null ? void 0 : n.text)), Ve.clear(this.inputElementRef), this.inputElementRef.classList.remove("text-input-placeholder"));
|
266
266
|
}
|
267
267
|
}, {
|
268
268
|
key: "addEventListeners",
|
@@ -334,7 +334,7 @@ var Gn = /*#__PURE__*/function () {
|
|
334
334
|
return t.id = "text-input-container", Object.assign(t.style, e), t;
|
335
335
|
}
|
336
336
|
}]);
|
337
|
-
return
|
337
|
+
return Ve;
|
338
338
|
}();
|
339
339
|
Gn.TEXT_INPUT_ID = "text-input";
|
340
340
|
var Gi = Gn;
|
@@ -882,11 +882,11 @@ var oe = /*#__PURE__*/function () {
|
|
882
882
|
}]);
|
883
883
|
return oe;
|
884
884
|
}();
|
885
|
-
var
|
886
|
-
function
|
887
|
-
_classCallCheck(this,
|
885
|
+
var Qe = /*#__PURE__*/function () {
|
886
|
+
function Qe() {
|
887
|
+
_classCallCheck(this, Qe);
|
888
888
|
}
|
889
|
-
_createClass(
|
889
|
+
_createClass(Qe, null, [{
|
890
890
|
key: "addElement",
|
891
891
|
value: function addElement(e, t) {
|
892
892
|
e.elementRef.appendChild(t), e.elementRef.scrollTop = e.elementRef.scrollHeight;
|
@@ -914,11 +914,11 @@ var Xe = /*#__PURE__*/function () {
|
|
914
914
|
if (l) return l;
|
915
915
|
r.status = !1;
|
916
916
|
}
|
917
|
-
var o =
|
918
|
-
return b.fillEmptyMessageElement(o.bubbleElement, t), oe.apply(e, o.outerContainer), Re.flagHTMLUpdateClass(o.bubbleElement), e.applyCustomStyles(o, i, !1, (a = e.messageStyles) == null ? void 0 : a.html),
|
917
|
+
var o = Qe.createElements(e, t, i);
|
918
|
+
return b.fillEmptyMessageElement(o.bubbleElement, t), oe.apply(e, o.outerContainer), Re.flagHTMLUpdateClass(o.bubbleElement), e.applyCustomStyles(o, i, !1, (a = e.messageStyles) == null ? void 0 : a.html), Qe.addElement(e, o.outerContainer), o;
|
919
919
|
}
|
920
920
|
}]);
|
921
|
-
return
|
921
|
+
return Qe;
|
922
922
|
}();
|
923
923
|
var Rt;
|
924
924
|
function Zn(s) {
|
@@ -976,7 +976,7 @@ var Fs = /[&<>"]/,
|
|
976
976
|
function qs(s) {
|
977
977
|
return Us[s];
|
978
978
|
}
|
979
|
-
function
|
979
|
+
function U(s) {
|
980
980
|
return Fs.test(s) ? s.replace(zs, qs) : s;
|
981
981
|
}
|
982
982
|
var m = {};
|
@@ -984,10 +984,10 @@ m.blockquote_open = function () {
|
|
984
984
|
return "<blockquote>\n";
|
985
985
|
};
|
986
986
|
m.blockquote_close = function (s, e) {
|
987
|
-
return "</blockquote>" +
|
987
|
+
return "</blockquote>" + De(s, e);
|
988
988
|
};
|
989
989
|
m.code = function (s, e) {
|
990
|
-
return s[e].block ? "<pre><code>" +
|
990
|
+
return s[e].block ? "<pre><code>" + U(s[e].content) + "</code></pre>" + De(s, e) : "<code>" + U(s[e].content) + "</code>";
|
991
991
|
};
|
992
992
|
m.fence = function (s, e, t, i, n) {
|
993
993
|
var r = s[e],
|
@@ -999,9 +999,9 @@ m.fence = function (s, e, t, i, n) {
|
|
999
999
|
u;
|
1000
1000
|
if (r.params) {
|
1001
1001
|
if (c = r.params.split(/\s+/g), d = c.join(" "), Os(n.rules.fence_custom, c[0])) return n.rules.fence_custom[c[0]](s, e, t, i, n);
|
1002
|
-
l =
|
1002
|
+
l = U(Ne(gt(d))), o = ' class="' + a + l + '"';
|
1003
1003
|
}
|
1004
|
-
return t.highlight ? u = t.highlight.apply(t.highlight, [r.content].concat(c)) ||
|
1004
|
+
return t.highlight ? u = t.highlight.apply(t.highlight, [r.content].concat(c)) || U(r.content) : u = U(r.content), "<pre><code" + o + ">" + u + "</code></pre>" + De(s, e);
|
1005
1005
|
};
|
1006
1006
|
m.fence_custom = {};
|
1007
1007
|
m.heading_open = function (s, e) {
|
@@ -1011,13 +1011,13 @@ m.heading_close = function (s, e) {
|
|
1011
1011
|
return "</h" + s[e].hLevel + ">\n";
|
1012
1012
|
};
|
1013
1013
|
m.hr = function (s, e, t) {
|
1014
|
-
return (t.xhtmlOut ? "<hr />" : "<hr>") +
|
1014
|
+
return (t.xhtmlOut ? "<hr />" : "<hr>") + De(s, e);
|
1015
1015
|
};
|
1016
1016
|
m.bullet_list_open = function () {
|
1017
1017
|
return "<ul>\n";
|
1018
1018
|
};
|
1019
1019
|
m.bullet_list_close = function (s, e) {
|
1020
|
-
return "</ul>" +
|
1020
|
+
return "</ul>" + De(s, e);
|
1021
1021
|
};
|
1022
1022
|
m.list_item_open = function () {
|
1023
1023
|
return "<li>";
|
@@ -1031,27 +1031,27 @@ m.ordered_list_open = function (s, e) {
|
|
1031
1031
|
return "<ol" + i + ">\n";
|
1032
1032
|
};
|
1033
1033
|
m.ordered_list_close = function (s, e) {
|
1034
|
-
return "</ol>" +
|
1034
|
+
return "</ol>" + De(s, e);
|
1035
1035
|
};
|
1036
1036
|
m.paragraph_open = function (s, e) {
|
1037
1037
|
return s[e].tight ? "" : "<p>";
|
1038
1038
|
};
|
1039
1039
|
m.paragraph_close = function (s, e) {
|
1040
1040
|
var t = !(s[e].tight && e && s[e - 1].type === "inline" && !s[e - 1].content);
|
1041
|
-
return (s[e].tight ? "" : "</p>") + (t ?
|
1041
|
+
return (s[e].tight ? "" : "</p>") + (t ? De(s, e) : "");
|
1042
1042
|
};
|
1043
1043
|
m.link_open = function (s, e, t) {
|
1044
|
-
var i = s[e].title ? ' title="' +
|
1044
|
+
var i = s[e].title ? ' title="' + U(Ne(s[e].title)) + '"' : "",
|
1045
1045
|
n = t.linkTarget ? ' target="' + t.linkTarget + '"' : "";
|
1046
|
-
return '<a href="' +
|
1046
|
+
return '<a href="' + U(s[e].href) + '"' + i + n + ">";
|
1047
1047
|
};
|
1048
1048
|
m.link_close = function () {
|
1049
1049
|
return "</a>";
|
1050
1050
|
};
|
1051
1051
|
m.image = function (s, e, t) {
|
1052
|
-
var i = ' src="' +
|
1053
|
-
n = s[e].title ? ' title="' +
|
1054
|
-
r = ' alt="' + (s[e].alt ?
|
1052
|
+
var i = ' src="' + U(s[e].src) + '"',
|
1053
|
+
n = s[e].title ? ' title="' + U(Ne(s[e].title)) + '"' : "",
|
1054
|
+
r = ' alt="' + (s[e].alt ? U(Ne(gt(s[e].alt))) : "") + '"',
|
1055
1055
|
o = t.xhtmlOut ? " /" : "";
|
1056
1056
|
return "<img" + i + r + n + o + ">";
|
1057
1057
|
};
|
@@ -1124,10 +1124,10 @@ m.mark_close = function () {
|
|
1124
1124
|
return "</mark>";
|
1125
1125
|
};
|
1126
1126
|
m.sub = function (s, e) {
|
1127
|
-
return "<sub>" +
|
1127
|
+
return "<sub>" + U(s[e].content) + "</sub>";
|
1128
1128
|
};
|
1129
1129
|
m.sup = function (s, e) {
|
1130
|
-
return "<sup>" +
|
1130
|
+
return "<sup>" + U(s[e].content) + "</sup>";
|
1131
1131
|
};
|
1132
1132
|
m.hardbreak = function (s, e, t) {
|
1133
1133
|
return t.xhtmlOut ? "<br />\n" : "<br>\n";
|
@@ -1136,7 +1136,7 @@ m.softbreak = function (s, e, t) {
|
|
1136
1136
|
return t.breaks ? t.xhtmlOut ? "<br />\n" : "<br>\n" : "\n";
|
1137
1137
|
};
|
1138
1138
|
m.text = function (s, e) {
|
1139
|
-
return
|
1139
|
+
return U(s[e].content);
|
1140
1140
|
};
|
1141
1141
|
m.htmlblock = function (s, e) {
|
1142
1142
|
return s[e].content;
|
@@ -1145,7 +1145,7 @@ m.htmltag = function (s, e) {
|
|
1145
1145
|
return s[e].content;
|
1146
1146
|
};
|
1147
1147
|
m.abbr_open = function (s, e) {
|
1148
|
-
return '<abbr title="' +
|
1148
|
+
return '<abbr title="' + U(Ne(s[e].title)) + '">';
|
1149
1149
|
};
|
1150
1150
|
m.abbr_close = function () {
|
1151
1151
|
return "</abbr>";
|
@@ -1195,7 +1195,7 @@ m.dd_close = function () {
|
|
1195
1195
|
function es(s, e) {
|
1196
1196
|
return ++e >= s.length - 2 ? e : s[e].type === "paragraph_open" && s[e].tight && s[e + 1].type === "inline" && s[e + 1].content.length === 0 && s[e + 2].type === "paragraph_close" && s[e + 2].tight ? es(s, e + 2) : e;
|
1197
1197
|
}
|
1198
|
-
var
|
1198
|
+
var De = m.getBreak = function (e, t) {
|
1199
1199
|
return t = es(e, t), t < e.length && e[t].type === "list_item_close" ? "" : "\n";
|
1200
1200
|
};
|
1201
1201
|
function Wi() {
|
@@ -1209,14 +1209,14 @@ Wi.prototype.render = function (s, e, t) {
|
|
1209
1209
|
for (var i = this.rules, n = s.length, r = -1, o = ""; ++r < n;) s[r].type === "inline" ? o += this.renderInline(s[r].children, e, t) : o += i[s[r].type](s, r, e, t, this);
|
1210
1210
|
return o;
|
1211
1211
|
};
|
1212
|
-
function
|
1212
|
+
function V() {
|
1213
1213
|
this.__rules__ = [], this.__cache__ = null;
|
1214
1214
|
}
|
1215
|
-
|
1215
|
+
V.prototype.__find__ = function (s) {
|
1216
1216
|
for (var e = this.__rules__.length, t = -1; e--;) if (this.__rules__[++t].name === s) return t;
|
1217
1217
|
return -1;
|
1218
1218
|
};
|
1219
|
-
|
1219
|
+
V.prototype.__compile__ = function () {
|
1220
1220
|
var s = this,
|
1221
1221
|
e = [""];
|
1222
1222
|
s.__rules__.forEach(function (t) {
|
@@ -1229,13 +1229,13 @@ G.prototype.__compile__ = function () {
|
|
1229
1229
|
});
|
1230
1230
|
});
|
1231
1231
|
};
|
1232
|
-
|
1232
|
+
V.prototype.at = function (s, e, t) {
|
1233
1233
|
var i = this.__find__(s),
|
1234
1234
|
n = t || {};
|
1235
1235
|
if (i === -1) throw new Error("Parser rule not found: " + s);
|
1236
1236
|
this.__rules__[i].fn = e, this.__rules__[i].alt = n.alt || [], this.__cache__ = null;
|
1237
1237
|
};
|
1238
|
-
|
1238
|
+
V.prototype.before = function (s, e, t, i) {
|
1239
1239
|
var n = this.__find__(s),
|
1240
1240
|
r = i || {};
|
1241
1241
|
if (n === -1) throw new Error("Parser rule not found: " + s);
|
@@ -1246,7 +1246,7 @@ G.prototype.before = function (s, e, t, i) {
|
|
1246
1246
|
alt: r.alt || []
|
1247
1247
|
}), this.__cache__ = null;
|
1248
1248
|
};
|
1249
|
-
|
1249
|
+
V.prototype.after = function (s, e, t, i) {
|
1250
1250
|
var n = this.__find__(s),
|
1251
1251
|
r = i || {};
|
1252
1252
|
if (n === -1) throw new Error("Parser rule not found: " + s);
|
@@ -1257,7 +1257,7 @@ G.prototype.after = function (s, e, t, i) {
|
|
1257
1257
|
alt: r.alt || []
|
1258
1258
|
}), this.__cache__ = null;
|
1259
1259
|
};
|
1260
|
-
|
1260
|
+
V.prototype.push = function (s, e, t) {
|
1261
1261
|
var i = t || {};
|
1262
1262
|
this.__rules__.push({
|
1263
1263
|
name: s,
|
@@ -1266,7 +1266,7 @@ G.prototype.push = function (s, e, t) {
|
|
1266
1266
|
alt: i.alt || []
|
1267
1267
|
}), this.__cache__ = null;
|
1268
1268
|
};
|
1269
|
-
|
1269
|
+
V.prototype.enable = function (s, e) {
|
1270
1270
|
s = Array.isArray(s) ? s : [s], e && this.__rules__.forEach(function (t) {
|
1271
1271
|
t.enabled = !1;
|
1272
1272
|
}), s.forEach(function (t) {
|
@@ -1275,14 +1275,14 @@ G.prototype.enable = function (s, e) {
|
|
1275
1275
|
this.__rules__[i].enabled = !0;
|
1276
1276
|
}, this), this.__cache__ = null;
|
1277
1277
|
};
|
1278
|
-
|
1278
|
+
V.prototype.disable = function (s) {
|
1279
1279
|
s = Array.isArray(s) ? s : [s], s.forEach(function (e) {
|
1280
1280
|
var t = this.__find__(e);
|
1281
1281
|
if (t < 0) throw new Error("Rules manager: invalid rule name " + e);
|
1282
1282
|
this.__rules__[t].enabled = !1;
|
1283
1283
|
}, this), this.__cache__ = null;
|
1284
1284
|
};
|
1285
|
-
|
1285
|
+
V.prototype.getRules = function (s) {
|
1286
1286
|
return this.__cache__ === null && this.__compile__(), this.__cache__[s] || [];
|
1287
1287
|
};
|
1288
1288
|
function Hs(s) {
|
@@ -1294,24 +1294,24 @@ function Hs(s) {
|
|
1294
1294
|
children: []
|
1295
1295
|
}) : s.block.parse(s.src, s.options, s.env, s.tokens);
|
1296
1296
|
}
|
1297
|
-
function
|
1297
|
+
function je(s, e, t, i, n) {
|
1298
1298
|
this.src = s, this.env = i, this.options = t, this.parser = e, this.tokens = n, this.pos = 0, this.posMax = this.src.length, this.level = 0, this.pending = "", this.pendingLevel = 0, this.cache = [], this.isInLabel = !1, this.linkLevel = 0, this.linkContent = "", this.labelUnmatchedScopes = 0;
|
1299
1299
|
}
|
1300
|
-
|
1300
|
+
je.prototype.pushPending = function () {
|
1301
1301
|
this.tokens.push({
|
1302
1302
|
type: "text",
|
1303
1303
|
content: this.pending,
|
1304
1304
|
level: this.pendingLevel
|
1305
1305
|
}), this.pending = "";
|
1306
1306
|
};
|
1307
|
-
|
1307
|
+
je.prototype.push = function (s) {
|
1308
1308
|
this.pending && this.pushPending(), this.tokens.push(s), this.pendingLevel = this.level;
|
1309
1309
|
};
|
1310
|
-
|
1310
|
+
je.prototype.cacheSet = function (s, e) {
|
1311
1311
|
for (var t = this.cache.length; t <= s; t++) this.cache.push(0);
|
1312
1312
|
this.cache[s] = e;
|
1313
1313
|
};
|
1314
|
-
|
1314
|
+
je.prototype.cacheGet = function (s) {
|
1315
1315
|
return s < this.cache.length ? this.cache[s] : 0;
|
1316
1316
|
};
|
1317
1317
|
function bt(s, e) {
|
@@ -1335,7 +1335,7 @@ function bt(s, e) {
|
|
1335
1335
|
}
|
1336
1336
|
function Gs(s, e, t, i) {
|
1337
1337
|
var n, r, o, a, l, c;
|
1338
|
-
if (s.charCodeAt(0) !== 42 || s.charCodeAt(1) !== 91 || s.indexOf("]:") === -1 || (n = new
|
1338
|
+
if (s.charCodeAt(0) !== 42 || s.charCodeAt(1) !== 91 || s.indexOf("]:") === -1 || (n = new je(s, e, t, i, []), r = bt(n, 1), r < 0 || s.charCodeAt(r + 1) !== 58)) return -1;
|
1339
1339
|
for (a = n.posMax, o = r + 2; o < a && n.src.charCodeAt(o) !== 10; o++);
|
1340
1340
|
return l = s.slice(2, r), c = s.slice(r + 2, o).trim(), c.length === 0 ? -1 : (i.abbreviations || (i.abbreviations = {}), _typeof(i.abbreviations[":" + l]) > "u" && (i.abbreviations[":" + l] = c), o);
|
1341
1341
|
}
|
@@ -1407,13 +1407,13 @@ function ns(s) {
|
|
1407
1407
|
return s.trim().replace(/\s+/g, " ").toUpperCase();
|
1408
1408
|
}
|
1409
1409
|
function Ws(s, e, t, i) {
|
1410
|
-
var n, r, o, a, l, c, d, u,
|
1411
|
-
if (s.charCodeAt(0) !== 91 || s.indexOf("]:") === -1 || (n = new
|
1410
|
+
var n, r, o, a, l, c, d, u, h;
|
1411
|
+
if (s.charCodeAt(0) !== 91 || s.indexOf("]:") === -1 || (n = new je(s, e, t, i, []), r = bt(n, 0), r < 0 || s.charCodeAt(r + 1) !== 58)) return -1;
|
1412
1412
|
for (a = n.posMax, o = r + 2; o < a && (l = n.src.charCodeAt(o), !(l !== 32 && l !== 10)); o++);
|
1413
1413
|
if (!ts(n, o)) return -1;
|
1414
1414
|
for (d = n.linkContent, o = n.pos, c = o, o = o + 1; o < a && (l = n.src.charCodeAt(o), !(l !== 32 && l !== 10)); o++);
|
1415
1415
|
for (o < a && c !== o && is(n, o) ? (u = n.linkContent, o = n.pos) : (u = "", o = c); o < a && n.src.charCodeAt(o) === 32;) o++;
|
1416
|
-
return o < a && n.src.charCodeAt(o) !== 10 ? -1 : (
|
1416
|
+
return o < a && n.src.charCodeAt(o) !== 10 ? -1 : (h = ns(s.slice(1, r)), _typeof(i.references[h]) > "u" && (i.references[h] = {
|
1417
1417
|
title: u,
|
1418
1418
|
href: d
|
1419
1419
|
}), o);
|
@@ -1450,9 +1450,9 @@ function Ks(s) {
|
|
1450
1450
|
c,
|
1451
1451
|
d = 0,
|
1452
1452
|
u = !1,
|
1453
|
-
|
1454
|
-
if (s.env.footnotes && (s.tokens = s.tokens.filter(function (
|
1455
|
-
return
|
1453
|
+
h = {};
|
1454
|
+
if (s.env.footnotes && (s.tokens = s.tokens.filter(function (p) {
|
1455
|
+
return p.type === "footnote_reference_open" ? (u = !0, l = [], c = p.label, !1) : p.type === "footnote_reference_close" ? (u = !1, h[":" + c] = l, !1) : (u && l.push(p), !u);
|
1456
1456
|
}), !!s.env.footnotes.list)) {
|
1457
1457
|
for (o = s.env.footnotes.list, s.tokens.push({
|
1458
1458
|
type: "footnote_block_open",
|
@@ -1475,7 +1475,7 @@ function Ks(s) {
|
|
1475
1475
|
type: "paragraph_close",
|
1476
1476
|
tight: !1,
|
1477
1477
|
level: --d
|
1478
|
-
})) : o[e].label && (a =
|
1478
|
+
})) : o[e].label && (a = h[":" + o[e].label]), s.tokens = s.tokens.concat(a), s.tokens[s.tokens.length - 1].type === "paragraph_close" ? r = s.tokens.pop() : r = null, n = o[e].count > 0 ? o[e].count : 1, i = 0; i < n; i++) s.tokens.push({
|
1479
1479
|
type: "footnote_anchor",
|
1480
1480
|
id: e,
|
1481
1481
|
subId: i,
|
@@ -1508,15 +1508,15 @@ function Ys(s) {
|
|
1508
1508
|
c,
|
1509
1509
|
d,
|
1510
1510
|
u,
|
1511
|
-
|
1512
|
-
|
1511
|
+
h,
|
1512
|
+
p = s.tokens;
|
1513
1513
|
if (s.env.abbreviations) {
|
1514
|
-
for (s.env.abbrRegExp || (
|
1514
|
+
for (s.env.abbrRegExp || (h = "(^|[" + hn.split("").map(Mi).join("") + "])(" + Object.keys(s.env.abbreviations).map(function (g) {
|
1515
1515
|
return g.substr(1);
|
1516
1516
|
}).sort(function (g, f) {
|
1517
1517
|
return f.length - g.length;
|
1518
|
-
}).map(Mi).join("|") + ")($|[" + hn.split("").map(Mi).join("") + "])", s.env.abbrRegExp = new RegExp(
|
1519
|
-
for (n =
|
1518
|
+
}).map(Mi).join("|") + ")($|[" + hn.split("").map(Mi).join("") + "])", s.env.abbrRegExp = new RegExp(h, "g")), d = s.env.abbrRegExp, t = 0, i = p.length; t < i; t++) if (p[t].type === "inline") {
|
1519
|
+
for (n = p[t].children, e = n.length - 1; e >= 0; e--) if (r = n[e], r.type === "text") {
|
1520
1520
|
for (l = 0, o = r.content, d.lastIndex = 0, c = r.level, a = []; u = d.exec(o);) d.lastIndex > l && a.push({
|
1521
1521
|
type: "text",
|
1522
1522
|
content: o.slice(l, u.index + u[1].length),
|
@@ -1537,7 +1537,7 @@ function Ys(s) {
|
|
1537
1537
|
type: "text",
|
1538
1538
|
content: o.slice(l),
|
1539
1539
|
level: c
|
1540
|
-
}),
|
1540
|
+
}), p[t].children = n = [].concat(n.slice(0, e), a, n.slice(e + 1)));
|
1541
1541
|
}
|
1542
1542
|
}
|
1543
1543
|
}
|
@@ -1568,24 +1568,24 @@ var ir = /['"]/,
|
|
1568
1568
|
function mn(s, e) {
|
1569
1569
|
return e < 0 || e >= s.length ? !1 : !nr.test(s[e]);
|
1570
1570
|
}
|
1571
|
-
function
|
1571
|
+
function He(s, e, t) {
|
1572
1572
|
return s.substr(0, e) + t + s.substr(e + 1);
|
1573
1573
|
}
|
1574
1574
|
function sr(s) {
|
1575
|
-
var e, t, i, n, r, o, a, l, c, d, u,
|
1575
|
+
var e, t, i, n, r, o, a, l, c, d, u, h, p, g, f, E, S;
|
1576
1576
|
if (s.options.typographer) {
|
1577
1577
|
for (S = [], f = s.tokens.length - 1; f >= 0; f--) if (s.tokens[f].type === "inline") {
|
1578
|
-
for (
|
1579
|
-
for (a =
|
1580
|
-
S.length =
|
1578
|
+
for (E = s.tokens[f].children, S.length = 0, e = 0; e < E.length; e++) if (t = E[e], !(t.type !== "text" || ir.test(t.text))) {
|
1579
|
+
for (a = E[e].level, p = S.length - 1; p >= 0 && !(S[p].level <= a); p--);
|
1580
|
+
S.length = p + 1, i = t.content, r = 0, o = i.length;
|
1581
1581
|
e: for (; r < o && (pn.lastIndex = r, n = pn.exec(i), !!n);) {
|
1582
1582
|
if (l = !mn(i, n.index - 1), r = n.index + 1, g = n[0] === "'", c = !mn(i, r), !c && !l) {
|
1583
|
-
g && (t.content =
|
1583
|
+
g && (t.content = He(t.content, n.index, fn));
|
1584
1584
|
continue;
|
1585
1585
|
}
|
1586
|
-
if (u = !c,
|
1587
|
-
for (
|
1588
|
-
d = S[
|
1586
|
+
if (u = !c, h = !l, h) {
|
1587
|
+
for (p = S.length - 1; p >= 0 && (d = S[p], !(S[p].level < a)); p--) if (d.single === g && S[p].level === a) {
|
1588
|
+
d = S[p], g ? (E[d.token].content = He(E[d.token].content, d.pos, s.options.quotes[2]), t.content = He(t.content, n.index, s.options.quotes[3])) : (E[d.token].content = He(E[d.token].content, d.pos, s.options.quotes[0]), t.content = He(t.content, n.index, s.options.quotes[1])), S.length = p;
|
1589
1589
|
continue e;
|
1590
1590
|
}
|
1591
1591
|
}
|
@@ -1594,7 +1594,7 @@ function sr(s) {
|
|
1594
1594
|
pos: n.index,
|
1595
1595
|
single: g,
|
1596
1596
|
level: a
|
1597
|
-
}) :
|
1597
|
+
}) : h && g && (t.content = He(t.content, n.index, fn));
|
1598
1598
|
}
|
1599
1599
|
}
|
1600
1600
|
}
|
@@ -1602,14 +1602,14 @@ function sr(s) {
|
|
1602
1602
|
}
|
1603
1603
|
var Ti = [["block", Hs], ["abbr", Vs], ["references", Js], ["inline", $s], ["footnote_tail", Ks], ["abbr2", Ys], ["replacements", tr], ["smartquotes", sr]];
|
1604
1604
|
function ss() {
|
1605
|
-
this.options = {}, this.ruler = new
|
1605
|
+
this.options = {}, this.ruler = new V();
|
1606
1606
|
for (var s = 0; s < Ti.length; s++) this.ruler.push(Ti[s][0], Ti[s][1]);
|
1607
1607
|
}
|
1608
1608
|
ss.prototype.process = function (s) {
|
1609
1609
|
var e, t, i;
|
1610
1610
|
for (i = this.ruler.getRules(""), e = 0, t = i.length; e < t; e++) i[e](s);
|
1611
1611
|
};
|
1612
|
-
function
|
1612
|
+
function Be(s, e, t, i, n) {
|
1613
1613
|
var r, o, a, l, c, d, u;
|
1614
1614
|
for (this.src = s, this.parser = e, this.options = t, this.env = i, this.tokens = n, this.bMarks = [], this.eMarks = [], this.tShift = [], this.blkIndent = 0, this.line = 0, this.lineMax = 0, this.tight = !1, this.parentType = "root", this.ddIndent = -1, this.level = 0, this.result = "", o = this.src, d = 0, u = !1, a = l = d = 0, c = o.length; l < c; l++) {
|
1615
1615
|
if (r = o.charCodeAt(l), !u) if (r === 32) {
|
@@ -1620,27 +1620,27 @@ function je(s, e, t, i, n) {
|
|
1620
1620
|
}
|
1621
1621
|
this.bMarks.push(o.length), this.eMarks.push(o.length), this.tShift.push(0), this.lineMax = this.bMarks.length - 1;
|
1622
1622
|
}
|
1623
|
-
|
1623
|
+
Be.prototype.isEmpty = function (e) {
|
1624
1624
|
return this.bMarks[e] + this.tShift[e] >= this.eMarks[e];
|
1625
1625
|
};
|
1626
|
-
|
1626
|
+
Be.prototype.skipEmptyLines = function (e) {
|
1627
1627
|
for (var t = this.lineMax; e < t && !(this.bMarks[e] + this.tShift[e] < this.eMarks[e]); e++);
|
1628
1628
|
return e;
|
1629
1629
|
};
|
1630
|
-
|
1630
|
+
Be.prototype.skipSpaces = function (e) {
|
1631
1631
|
for (var t = this.src.length; e < t && this.src.charCodeAt(e) === 32; e++);
|
1632
1632
|
return e;
|
1633
1633
|
};
|
1634
|
-
|
1634
|
+
Be.prototype.skipChars = function (e, t) {
|
1635
1635
|
for (var i = this.src.length; e < i && this.src.charCodeAt(e) === t; e++);
|
1636
1636
|
return e;
|
1637
1637
|
};
|
1638
|
-
|
1638
|
+
Be.prototype.skipCharsBack = function (e, t, i) {
|
1639
1639
|
if (e <= i) return e;
|
1640
1640
|
for (; e > i;) if (t !== this.src.charCodeAt(--e)) return e + 1;
|
1641
1641
|
return e;
|
1642
1642
|
};
|
1643
|
-
|
1643
|
+
Be.prototype.getLines = function (e, t, i, n) {
|
1644
1644
|
var r,
|
1645
1645
|
o,
|
1646
1646
|
a,
|
@@ -1706,20 +1706,20 @@ function ar(s, e, t, i) {
|
|
1706
1706
|
c,
|
1707
1707
|
d,
|
1708
1708
|
u,
|
1709
|
-
p,
|
1710
1709
|
h,
|
1710
|
+
p,
|
1711
1711
|
g,
|
1712
1712
|
f = s.bMarks[e] + s.tShift[e],
|
1713
|
-
|
1714
|
-
if (f >
|
1713
|
+
E = s.eMarks[e];
|
1714
|
+
if (f > E || s.src.charCodeAt(f++) !== 62 || s.level >= s.options.maxNesting) return !1;
|
1715
1715
|
if (i) return !0;
|
1716
|
-
for (s.src.charCodeAt(f) === 32 && f++, l = s.blkIndent, s.blkIndent = 0, a = [s.bMarks[e]], s.bMarks[e] = f, f = f <
|
1716
|
+
for (s.src.charCodeAt(f) === 32 && f++, l = s.blkIndent, s.blkIndent = 0, a = [s.bMarks[e]], s.bMarks[e] = f, f = f < E ? s.skipSpaces(f) : f, r = f >= E, o = [s.tShift[e]], s.tShift[e] = f - s.bMarks[e], u = s.parser.ruler.getRules("blockquote"), n = e + 1; n < t && (f = s.bMarks[n] + s.tShift[n], E = s.eMarks[n], !(f >= E)); n++) {
|
1717
1717
|
if (s.src.charCodeAt(f++) === 62) {
|
1718
|
-
s.src.charCodeAt(f) === 32 && f++, a.push(s.bMarks[n]), s.bMarks[n] = f, f = f <
|
1718
|
+
s.src.charCodeAt(f) === 32 && f++, a.push(s.bMarks[n]), s.bMarks[n] = f, f = f < E ? s.skipSpaces(f) : f, r = f >= E, o.push(s.tShift[n]), s.tShift[n] = f - s.bMarks[n];
|
1719
1719
|
continue;
|
1720
1720
|
}
|
1721
1721
|
if (r) break;
|
1722
|
-
for (g = !1,
|
1722
|
+
for (g = !1, h = 0, p = u.length; h < p; h++) if (u[h](s, n, t, !0)) {
|
1723
1723
|
g = !0;
|
1724
1724
|
break;
|
1725
1725
|
}
|
@@ -1733,7 +1733,7 @@ function ar(s, e, t, i) {
|
|
1733
1733
|
}), s.parser.tokenize(s, e, n), s.tokens.push({
|
1734
1734
|
type: "blockquote_close",
|
1735
1735
|
level: --s.level
|
1736
|
-
}), s.parentType = c, d[1] = s.line,
|
1736
|
+
}), s.parentType = c, d[1] = s.line, h = 0; h < o.length; h++) s.bMarks[h + e] = a[h], s.tShift[h + e] = o[h];
|
1737
1737
|
return s.blkIndent = l, !0;
|
1738
1738
|
}
|
1739
1739
|
function lr(s, e, t, i) {
|
@@ -1786,34 +1786,34 @@ function dr(s, e, t, i) {
|
|
1786
1786
|
c,
|
1787
1787
|
d,
|
1788
1788
|
u,
|
1789
|
-
p,
|
1790
1789
|
h,
|
1790
|
+
p,
|
1791
1791
|
g,
|
1792
1792
|
f,
|
1793
|
-
|
1793
|
+
E,
|
1794
1794
|
S,
|
1795
|
-
V,
|
1796
|
-
A,
|
1797
1795
|
W,
|
1796
|
+
A,
|
1797
|
+
J,
|
1798
1798
|
Q,
|
1799
1799
|
le = !0,
|
1800
|
-
|
1800
|
+
H,
|
1801
1801
|
O,
|
1802
1802
|
Ee,
|
1803
1803
|
Si;
|
1804
|
-
if ((u = bn(s, e)) >= 0)
|
1804
|
+
if ((u = bn(s, e)) >= 0) E = !0;else if ((u = gn(s, e)) >= 0) E = !1;else return !1;
|
1805
1805
|
if (s.level >= s.options.maxNesting) return !1;
|
1806
1806
|
if (f = s.src.charCodeAt(u - 1), i) return !0;
|
1807
|
-
for (
|
1807
|
+
for (W = s.tokens.length, E ? (d = s.bMarks[e] + s.tShift[e], g = Number(s.src.substr(d, u - d - 1)), s.tokens.push({
|
1808
1808
|
type: "ordered_list_open",
|
1809
1809
|
order: g,
|
1810
|
-
lines:
|
1810
|
+
lines: J = [e, 0],
|
1811
1811
|
level: s.level++
|
1812
1812
|
})) : s.tokens.push({
|
1813
1813
|
type: "bullet_list_open",
|
1814
|
-
lines:
|
1814
|
+
lines: J = [e, 0],
|
1815
1815
|
level: s.level++
|
1816
|
-
}), n = e, A = !1,
|
1816
|
+
}), n = e, A = !1, H = s.parser.ruler.getRules("list"); n < t && (S = s.skipSpaces(u), h = s.eMarks[n], S >= h ? p = 1 : p = S - u, p > 4 && (p = 1), p < 1 && (p = 1), r = u - s.bMarks[n] + p, s.tokens.push({
|
1817
1817
|
type: "list_item_open",
|
1818
1818
|
lines: Q = [e, 0],
|
1819
1819
|
level: s.level++
|
@@ -1821,20 +1821,20 @@ function dr(s, e, t, i) {
|
|
1821
1821
|
type: "list_item_close",
|
1822
1822
|
level: --s.level
|
1823
1823
|
}), n = e = s.line, Q[1] = n, S = s.bMarks[e], !(n >= t || s.isEmpty(n) || s.tShift[n] < s.blkIndent));) {
|
1824
|
-
for (Si = !1, O = 0, Ee =
|
1824
|
+
for (Si = !1, O = 0, Ee = H.length; O < Ee; O++) if (H[O](s, n, t, !0)) {
|
1825
1825
|
Si = !0;
|
1826
1826
|
break;
|
1827
1827
|
}
|
1828
1828
|
if (Si) break;
|
1829
|
-
if (
|
1829
|
+
if (E) {
|
1830
1830
|
if (u = bn(s, n), u < 0) break;
|
1831
1831
|
} else if (u = gn(s, n), u < 0) break;
|
1832
1832
|
if (f !== s.src.charCodeAt(u - 1)) break;
|
1833
1833
|
}
|
1834
1834
|
return s.tokens.push({
|
1835
|
-
type:
|
1835
|
+
type: E ? "ordered_list_close" : "bullet_list_close",
|
1836
1836
|
level: --s.level
|
1837
|
-
}),
|
1837
|
+
}), J[1] = n, s.line = n, le && cr(s, W), !0;
|
1838
1838
|
}
|
1839
1839
|
function ur(s, e, t, i) {
|
1840
1840
|
var n,
|
@@ -1946,21 +1946,21 @@ function Ci(s, e) {
|
|
1946
1946
|
return s.src.substr(t, i - t);
|
1947
1947
|
}
|
1948
1948
|
function vr(s, e, t, i) {
|
1949
|
-
var n, r, o, a, l, c, d, u,
|
1949
|
+
var n, r, o, a, l, c, d, u, h, p, g;
|
1950
1950
|
if (e + 2 > t || (l = e + 1, s.tShift[l] < s.blkIndent) || (o = s.bMarks[l] + s.tShift[l], o >= s.eMarks[l]) || (n = s.src.charCodeAt(o), n !== 124 && n !== 45 && n !== 58) || (r = Ci(s, e + 1), !/^[-:| ]+$/.test(r)) || (c = r.split("|"), c <= 2)) return !1;
|
1951
1951
|
for (u = [], a = 0; a < c.length; a++) {
|
1952
|
-
if (
|
1952
|
+
if (h = c[a].trim(), !h) {
|
1953
1953
|
if (a === 0 || a === c.length - 1) continue;
|
1954
1954
|
return !1;
|
1955
1955
|
}
|
1956
|
-
if (!/^:?-+:?$/.test(
|
1957
|
-
|
1956
|
+
if (!/^:?-+:?$/.test(h)) return !1;
|
1957
|
+
h.charCodeAt(h.length - 1) === 58 ? u.push(h.charCodeAt(0) === 58 ? "center" : "right") : h.charCodeAt(0) === 58 ? u.push("left") : u.push("");
|
1958
1958
|
}
|
1959
1959
|
if (r = Ci(s, e).trim(), r.indexOf("|") === -1 || (c = r.replace(/^\||\|$/g, "").split("|"), u.length !== c.length)) return !1;
|
1960
1960
|
if (i) return !0;
|
1961
1961
|
for (s.tokens.push({
|
1962
1962
|
type: "table_open",
|
1963
|
-
lines:
|
1963
|
+
lines: p = [e, 0],
|
1964
1964
|
level: s.level++
|
1965
1965
|
}), s.tokens.push({
|
1966
1966
|
type: "thead_open",
|
@@ -2023,7 +2023,7 @@ function vr(s, e, t, i) {
|
|
2023
2023
|
}), s.tokens.push({
|
2024
2024
|
type: "table_close",
|
2025
2025
|
level: --s.level
|
2026
|
-
}),
|
2026
|
+
}), p[1] = g[1] = l, s.line = l, !0;
|
2027
2027
|
}
|
2028
2028
|
function Nt(s, e) {
|
2029
2029
|
var t,
|
@@ -2039,7 +2039,7 @@ function yr(s, e) {
|
|
2039
2039
|
for (t = e + 2, i = s.tokens.length - 2; t < i; t++) s.tokens[t].level === n && s.tokens[t].type === "paragraph_open" && (s.tokens[t + 2].tight = !0, s.tokens[t].tight = !0, t += 2);
|
2040
2040
|
}
|
2041
2041
|
function xr(s, e, t, i) {
|
2042
|
-
var n, r, o, a, l, c, d, u,
|
2042
|
+
var n, r, o, a, l, c, d, u, h, p, g, f, E, S;
|
2043
2043
|
if (i) return s.ddIndent < 0 ? !1 : Nt(s, e) >= 0;
|
2044
2044
|
if (d = e + 1, s.isEmpty(d) && ++d > t || s.tShift[d] < s.blkIndent || (n = Nt(s, d), n < 0) || s.level >= s.options.maxNesting) return !1;
|
2045
2045
|
c = s.tokens.length, s.tokens.push({
|
@@ -2048,7 +2048,7 @@ function xr(s, e, t, i) {
|
|
2048
2048
|
level: s.level++
|
2049
2049
|
}), o = e, r = d;
|
2050
2050
|
e: for (;;) {
|
2051
|
-
for (S = !0,
|
2051
|
+
for (S = !0, E = !1, s.tokens.push({
|
2052
2052
|
type: "dt_open",
|
2053
2053
|
lines: [o, o],
|
2054
2054
|
level: s.level++
|
@@ -2066,7 +2066,7 @@ function xr(s, e, t, i) {
|
|
2066
2066
|
type: "dd_open",
|
2067
2067
|
lines: a = [d, 0],
|
2068
2068
|
level: s.level++
|
2069
|
-
}), f = s.tight,
|
2069
|
+
}), f = s.tight, h = s.ddIndent, u = s.blkIndent, g = s.tShift[r], p = s.parentType, s.blkIndent = s.ddIndent = s.tShift[r] + 2, s.tShift[r] = n - s.bMarks[r], s.tight = !0, s.parentType = "deflist", s.parser.tokenize(s, r, t, !0), (!s.tight || E) && (S = !1), E = s.line - r > 1 && s.isEmpty(s.line - 1), s.tShift[r] = g, s.tight = f, s.parentType = p, s.blkIndent = u, s.ddIndent = h, s.tokens.push({
|
2070
2070
|
type: "dd_close",
|
2071
2071
|
level: --s.level
|
2072
2072
|
}), a[1] = d = s.line, d >= t || s.tShift[d] < s.blkIndent) break e;
|
@@ -2116,7 +2116,7 @@ function Er(s, e) {
|
|
2116
2116
|
}
|
2117
2117
|
var Ot = [["code", rr], ["fences", or, ["paragraph", "blockquote", "list"]], ["blockquote", ar, ["paragraph", "blockquote", "list"]], ["hr", lr, ["paragraph", "blockquote", "list"]], ["list", dr, ["paragraph", "blockquote"]], ["footnote", ur, ["paragraph"]], ["heading", hr, ["paragraph", "blockquote"]], ["lheading", pr], ["htmlblock", br, ["paragraph", "blockquote"]], ["table", vr, ["paragraph"]], ["deflist", xr, ["paragraph"]], ["paragraph", Er]];
|
2118
2118
|
function Ji() {
|
2119
|
-
this.ruler = new
|
2119
|
+
this.ruler = new V();
|
2120
2120
|
for (var s = 0; s < Ot.length; s++) this.ruler.push(Ot[s][0], Ot[s][1], {
|
2121
2121
|
alt: (Ot[s][2] || []).slice()
|
2122
2122
|
});
|
@@ -2141,7 +2141,7 @@ Ji.prototype.parse = function (s, e, t, i) {
|
|
2141
2141
|
s = s.replace(wr, " "), s = s.replace(Sr, "\n"), s.indexOf(" ") >= 0 && (s = s.replace(_r, function (a, l) {
|
2142
2142
|
var c;
|
2143
2143
|
return s.charCodeAt(l) === 10 ? (r = l + 1, o = 0, a) : (c = " ".slice((l - r - o) % 4), o = l - r + 1, c);
|
2144
|
-
})), n = new
|
2144
|
+
})), n = new Be(s, this, e, t, i), this.tokenize(n, n.line, n.lineMax);
|
2145
2145
|
};
|
2146
2146
|
function Mr(s) {
|
2147
2147
|
switch (s) {
|
@@ -2443,21 +2443,21 @@ function Br(s, e) {
|
|
2443
2443
|
c,
|
2444
2444
|
d = !1,
|
2445
2445
|
u = s.pos,
|
2446
|
-
|
2447
|
-
|
2448
|
-
g = s.src.charCodeAt(
|
2449
|
-
if (g === 33 && (d = !0, g = s.src.charCodeAt(++
|
2450
|
-
if (a = i + 1, a <
|
2451
|
-
for (a++; a <
|
2452
|
-
if (a >=
|
2453
|
-
for (
|
2454
|
-
if (a <
|
2455
|
-
if (a >=
|
2446
|
+
h = s.posMax,
|
2447
|
+
p = s.pos,
|
2448
|
+
g = s.src.charCodeAt(p);
|
2449
|
+
if (g === 33 && (d = !0, g = s.src.charCodeAt(++p)), g !== 91 || s.level >= s.options.maxNesting || (t = p + 1, i = bt(s, p), i < 0)) return !1;
|
2450
|
+
if (a = i + 1, a < h && s.src.charCodeAt(a) === 40) {
|
2451
|
+
for (a++; a < h && (c = s.src.charCodeAt(a), !(c !== 32 && c !== 10)); a++);
|
2452
|
+
if (a >= h) return !1;
|
2453
|
+
for (p = a, ts(s, a) ? (r = s.linkContent, a = s.pos) : r = "", p = a; a < h && (c = s.src.charCodeAt(a), !(c !== 32 && c !== 10)); a++);
|
2454
|
+
if (a < h && p !== a && is(s, a)) for (o = s.linkContent, a = s.pos; a < h && (c = s.src.charCodeAt(a), !(c !== 32 && c !== 10)); a++);else o = "";
|
2455
|
+
if (a >= h || s.src.charCodeAt(a) !== 41) return s.pos = u, !1;
|
2456
2456
|
a++;
|
2457
2457
|
} else {
|
2458
2458
|
if (s.linkLevel > 0) return !1;
|
2459
|
-
for (; a <
|
2460
|
-
if (a <
|
2459
|
+
for (; a < h && (c = s.src.charCodeAt(a), !(c !== 32 && c !== 10)); a++);
|
2460
|
+
if (a < h && s.src.charCodeAt(a) === 91 && (p = a + 1, a = bt(s, a), a >= 0 ? n = s.src.slice(p, a++) : a = p - 1), n || (_typeof(n) > "u" && (a = i + 1), n = s.src.slice(t, i)), l = s.env.references[ns(n)], !l) return s.pos = u, !1;
|
2461
2461
|
r = l.href, o = l.title;
|
2462
2462
|
}
|
2463
2463
|
return e || (s.pos = t, s.posMax = i, d ? s.push({
|
@@ -2474,7 +2474,7 @@ function Br(s, e) {
|
|
2474
2474
|
}), s.linkLevel++, s.parser.tokenize(s), s.linkLevel--, s.push({
|
2475
2475
|
type: "link_close",
|
2476
2476
|
level: --s.level
|
2477
|
-
}))), s.pos = a, s.posMax =
|
2477
|
+
}))), s.pos = a, s.posMax = h, !0;
|
2478
2478
|
}
|
2479
2479
|
function Fr(s, e) {
|
2480
2480
|
var t,
|
@@ -2601,7 +2601,7 @@ function lo(s, e) {
|
|
2601
2601
|
}
|
2602
2602
|
var Ai = [["text", Tr], ["newline", Cr], ["escape", Ar], ["backticks", kr], ["del", Ir], ["ins", Lr], ["mark", Rr], ["emphasis", Nr], ["sub", Pr], ["sup", jr], ["links", Br], ["footnote_inline", Fr], ["footnote_ref", zr], ["autolink", Gr], ["htmltag", ro], ["entity", lo]];
|
2603
2603
|
function si() {
|
2604
|
-
this.ruler = new
|
2604
|
+
this.ruler = new V();
|
2605
2605
|
for (var s = 0; s < Ai.length; s++) this.ruler.push(Ai[s][0], Ai[s][1]);
|
2606
2606
|
this.validateLink = co;
|
2607
2607
|
}
|
@@ -2633,7 +2633,7 @@ si.prototype.tokenize = function (s) {
|
|
2633
2633
|
s.pending && s.pushPending();
|
2634
2634
|
};
|
2635
2635
|
si.prototype.parse = function (s, e, t, i) {
|
2636
|
-
var n = new
|
2636
|
+
var n = new je(s, this, e, t, i);
|
2637
2637
|
this.tokenize(n);
|
2638
2638
|
};
|
2639
2639
|
function co(s) {
|
@@ -2759,7 +2759,7 @@ function os(s, e, t) {
|
|
2759
2759
|
this.src = e, this.env = t, this.options = s.options, this.tokens = [], this.inlineMode = !1, this.inline = s.inline, this.block = s.block, this.renderer = s.renderer, this.typographer = s.typographer;
|
2760
2760
|
}
|
2761
2761
|
function he(s, e) {
|
2762
|
-
typeof s != "string" && (e = s, s = "default"), e && e.linkify != null && console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"), this.inline = new si(), this.block = new Ji(), this.core = new ss(), this.renderer = new Wi(), this.ruler = new
|
2762
|
+
typeof s != "string" && (e = s, s = "default"), e && e.linkify != null && console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"), this.inline = new si(), this.block = new Ji(), this.core = new ss(), this.renderer = new Wi(), this.ruler = new V(), this.options = {}, this.configure(fo[s]), this.set(e || {});
|
2763
2763
|
}
|
2764
2764
|
he.prototype.set = function (s) {
|
2765
2765
|
Xn(this.options, s);
|
@@ -2842,10 +2842,10 @@ var vt = /*#__PURE__*/function () {
|
|
2842
2842
|
return vt;
|
2843
2843
|
}();
|
2844
2844
|
var as = /*#__PURE__*/function () {
|
2845
|
-
function
|
2846
|
-
_classCallCheck(this,
|
2845
|
+
function We() {
|
2846
|
+
_classCallCheck(this, We);
|
2847
2847
|
}
|
2848
|
-
_createClass(
|
2848
|
+
_createClass(We, null, [{
|
2849
2849
|
key: "addMessage",
|
2850
2850
|
value: function addMessage(e, t, i, n) {
|
2851
2851
|
var r;
|
@@ -2855,7 +2855,7 @@ var as = /*#__PURE__*/function () {
|
|
2855
2855
|
key: "wrapInLink",
|
2856
2856
|
value: function wrapInLink(e, t, i) {
|
2857
2857
|
var n = document.createElement("a");
|
2858
|
-
return n.href = t, n.download = i ||
|
2858
|
+
return n.href = t, n.download = i || We.DEFAULT_FILE_NAME, n.target = "_blank", n.appendChild(e), n;
|
2859
2859
|
}
|
2860
2860
|
}, {
|
2861
2861
|
key: "isNonLinkableDataUrl",
|
@@ -2865,7 +2865,7 @@ var as = /*#__PURE__*/function () {
|
|
2865
2865
|
}, {
|
2866
2866
|
key: "processContent",
|
2867
2867
|
value: function processContent(e, t, i, n) {
|
2868
|
-
return !i ||
|
2868
|
+
return !i || We.isNonLinkableDataUrl(e, i) ? t : We.wrapInLink(t, i, n);
|
2869
2869
|
}
|
2870
2870
|
}, {
|
2871
2871
|
key: "waitToLoadThenScroll",
|
@@ -2877,11 +2877,11 @@ var as = /*#__PURE__*/function () {
|
|
2877
2877
|
}, {
|
2878
2878
|
key: "scrollDownOnImageLoad",
|
2879
2879
|
value: function scrollDownOnImageLoad(e, t) {
|
2880
|
-
if (e.startsWith("data"))
|
2880
|
+
if (e.startsWith("data")) We.waitToLoadThenScroll(t);else try {
|
2881
2881
|
fetch(e, {
|
2882
2882
|
mode: "no-cors"
|
2883
2883
|
})["catch"](function () {})["finally"](function () {
|
2884
|
-
|
2884
|
+
We.waitToLoadThenScroll(t);
|
2885
2885
|
});
|
2886
2886
|
} catch (_unused5) {
|
2887
2887
|
t.scrollTop = t.scrollHeight;
|
@@ -2907,7 +2907,7 @@ var as = /*#__PURE__*/function () {
|
|
2907
2907
|
return delete t.ref, t;
|
2908
2908
|
}
|
2909
2909
|
}]);
|
2910
|
-
return
|
2910
|
+
return We;
|
2911
2911
|
}();
|
2912
2912
|
as.DEFAULT_FILE_NAME = "file";
|
2913
2913
|
var re = as;
|
@@ -3002,15 +3002,15 @@ var D = /*#__PURE__*/function () {
|
|
3002
3002
|
}]);
|
3003
3003
|
return D;
|
3004
3004
|
}();
|
3005
|
-
var
|
3006
|
-
function
|
3005
|
+
var Ye = /*#__PURE__*/function () {
|
3006
|
+
function Ye(e) {
|
3007
3007
|
var _this3 = this;
|
3008
|
-
_classCallCheck(this,
|
3009
|
-
this.messageElementRefs = [], this.messages = [], this.htmlClassUtilities = {}, this.textElementsToText = [], this.elementRef =
|
3008
|
+
_classCallCheck(this, Ye);
|
3009
|
+
this.messageElementRefs = [], this.messages = [], this.htmlClassUtilities = {}, this.textElementsToText = [], this.elementRef = Ye.createContainerElement(), this.messageStyles = e.messageStyles, this._remarkable = vt.createNew(), this._avatars = e.avatars, this._names = e.names, this._onNewMessage = Ft.onNewMessage.bind(this, e), e.htmlClassUtilities && (this.htmlClassUtilities = e.htmlClassUtilities), setTimeout(function () {
|
3010
3010
|
_this3.submitUserMessage = e.submitUserMessage;
|
3011
3011
|
});
|
3012
3012
|
}
|
3013
|
-
_createClass(
|
3013
|
+
_createClass(Ye, [{
|
3014
3014
|
key: "addNewTextMessage",
|
3015
3015
|
value: function addNewTextMessage(e, t, i) {
|
3016
3016
|
if (i != null && i.status) {
|
@@ -3047,12 +3047,12 @@ var Ke = /*#__PURE__*/function () {
|
|
3047
3047
|
var n;
|
3048
3048
|
(n = this._introPanel) == null || n.hide();
|
3049
3049
|
var i = this.messageElementRefs[this.messageElementRefs.length - 1];
|
3050
|
-
return
|
3050
|
+
return Ye.isTemporaryElement(i) && (i.outerContainer.remove(), this.messageElementRefs.pop()), this.createMessageElements(e, t);
|
3051
3051
|
}
|
3052
3052
|
}, {
|
3053
3053
|
key: "createMessageElements",
|
3054
3054
|
value: function createMessageElements(e, t) {
|
3055
|
-
var i =
|
3055
|
+
var i = Ye.createBaseElements(),
|
3056
3056
|
n = i.outerContainer,
|
3057
3057
|
r = i.innerContainer,
|
3058
3058
|
o = i.bubbleElement;
|
@@ -3144,7 +3144,7 @@ var Ke = /*#__PURE__*/function () {
|
|
3144
3144
|
return t && (a.text = t), i && (a.files = i), n && (a.html = n), !t && !i && !n && (a.text = ""), r && (a._sessionId = r), a;
|
3145
3145
|
}
|
3146
3146
|
}]);
|
3147
|
-
return
|
3147
|
+
return Ye;
|
3148
3148
|
}();
|
3149
3149
|
var Ki = /*#__PURE__*/function () {
|
3150
3150
|
// used for extracting at end and for isStreaming
|
@@ -3171,7 +3171,7 @@ var Ki = /*#__PURE__*/function () {
|
|
3171
3171
|
key: "setInitialState",
|
3172
3172
|
value: function setInitialState(e, t, i) {
|
3173
3173
|
var _i8;
|
3174
|
-
this._streamType = e, (_i8 = i) !== null && _i8 !== void 0 ? _i8 : i = b.AI_ROLE, this._elements = e === "text" ? this._messages.addNewTextMessage(t, i) :
|
3174
|
+
this._streamType = e, (_i8 = i) !== null && _i8 !== void 0 ? _i8 : i = b.AI_ROLE, this._elements = e === "text" ? this._messages.addNewTextMessage(t, i) : Qe.add(this._messages, t, i, this._messages.messageElementRefs), this._elements.bubbleElement.classList.add(ot.MESSAGE_CLASS), this._streamedContent = t, this._activeMessageRole = i;
|
3175
3175
|
}
|
3176
3176
|
}, {
|
3177
3177
|
key: "updateBasedOnType",
|
@@ -3205,14 +3205,14 @@ var Ki = /*#__PURE__*/function () {
|
|
3205
3205
|
var n = {
|
3206
3206
|
role: this._activeMessageRole || b.AI_ROLE
|
3207
3207
|
};
|
3208
|
-
this._streamType === "text" ? (e[e.length - 1][1] = this._streamedContent, n.text = this._streamedContent, this._messages.textToSpeech && jt.speak(this._streamedContent, this._messages.textToSpeech)) : this._streamType === "html" && (this._streamedContent === ot.HTML_CONTENT_PLACEHOLDER && (this._streamedContent = ((o = b.getLastMessageBubbleElement(t)) == null ? void 0 : o.innerHTML) || ""), this._elements && oe.apply(this._messages, this._elements.outerContainer), n.html = this._streamedContent), n && (this._messages.messages.push(n), this._messages.sendClientUpdate(
|
3208
|
+
this._streamType === "text" ? (e[e.length - 1][1] = this._streamedContent, n.text = this._streamedContent, this._messages.textToSpeech && jt.speak(this._streamedContent, this._messages.textToSpeech)) : this._streamType === "html" && (this._streamedContent === ot.HTML_CONTENT_PLACEHOLDER && (this._streamedContent = ((o = b.getLastMessageBubbleElement(t)) == null ? void 0 : o.innerHTML) || ""), this._elements && oe.apply(this._messages, this._elements.outerContainer), n.html = this._streamedContent), n && (this._messages.messages.push(n), this._messages.sendClientUpdate(Ye.createMessageContent(n), !1)), this._hasStreamEnded = !0;
|
3209
3209
|
}
|
3210
3210
|
}]);
|
3211
3211
|
return ot;
|
3212
3212
|
}();
|
3213
3213
|
Ki.MESSAGE_CLASS = "streamed-message";
|
3214
3214
|
Ki.HTML_CONTENT_PLACEHOLDER = "htmlplaceholder";
|
3215
|
-
var
|
3215
|
+
var Oe = Ki;
|
3216
3216
|
var ls = /*#__PURE__*/function () {
|
3217
3217
|
function at() {
|
3218
3218
|
_classCallCheck(this, at);
|
@@ -3342,7 +3342,7 @@ var ls = /*#__PURE__*/function () {
|
|
3342
3342
|
return at;
|
3343
3343
|
}();
|
3344
3344
|
ls.CONTENT_TYPE = "Content-Type";
|
3345
|
-
var
|
3345
|
+
var _ = ls;
|
3346
3346
|
function mo(_x10, _x11) {
|
3347
3347
|
return _mo.apply(this, arguments);
|
3348
3348
|
}
|
@@ -3458,30 +3458,30 @@ function Eo(s, e) {
|
|
3458
3458
|
l = e.openWhenHidden,
|
3459
3459
|
c = e.fetch,
|
3460
3460
|
d = yo(e, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
3461
|
-
return new Promise(function (u,
|
3462
|
-
var
|
3463
|
-
|
3461
|
+
return new Promise(function (u, h) {
|
3462
|
+
var p = Object.assign({}, i);
|
3463
|
+
p.accept || (p.accept = Bi);
|
3464
3464
|
var g;
|
3465
3465
|
function f() {
|
3466
3466
|
g.abort(), document.hidden || Q();
|
3467
3467
|
}
|
3468
3468
|
l || document.addEventListener("visibilitychange", f);
|
3469
|
-
var
|
3469
|
+
var E = xo,
|
3470
3470
|
S = 0;
|
3471
|
-
function
|
3471
|
+
function W() {
|
3472
3472
|
document.removeEventListener("visibilitychange", f), window.clearTimeout(S), g.abort();
|
3473
3473
|
}
|
3474
3474
|
t == null || t.addEventListener("abort", function () {
|
3475
|
-
|
3475
|
+
W(), u();
|
3476
3476
|
});
|
3477
3477
|
var A = c !== null && c !== void 0 ? c : window.fetch,
|
3478
|
-
|
3478
|
+
J = n !== null && n !== void 0 ? n : _o;
|
3479
3479
|
function Q() {
|
3480
3480
|
return _Q.apply(this, arguments);
|
3481
3481
|
}
|
3482
3482
|
function _Q() {
|
3483
3483
|
_Q = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
3484
|
-
var le,
|
3484
|
+
var le, H, O;
|
3485
3485
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
3486
3486
|
while (1) switch (_context3.prev = _context3.next) {
|
3487
3487
|
case 0:
|
@@ -3489,23 +3489,23 @@ function Eo(s, e) {
|
|
3489
3489
|
_context3.prev = 1;
|
3490
3490
|
_context3.next = 4;
|
3491
3491
|
return A(s, Object.assign(Object.assign({}, d), {
|
3492
|
-
headers:
|
3492
|
+
headers: p,
|
3493
3493
|
signal: g.signal
|
3494
3494
|
}));
|
3495
3495
|
case 4:
|
3496
|
-
|
3496
|
+
H = _context3.sent;
|
3497
3497
|
_context3.next = 7;
|
3498
|
-
return
|
3498
|
+
return J(H);
|
3499
3499
|
case 7:
|
3500
3500
|
_context3.next = 9;
|
3501
|
-
return mo(
|
3502
|
-
O ?
|
3501
|
+
return mo(H.body, go(bo(function (O) {
|
3502
|
+
O ? p[_n] = O : delete p[_n];
|
3503
3503
|
}, function (O) {
|
3504
|
-
|
3504
|
+
E = O;
|
3505
3505
|
}, r)));
|
3506
3506
|
case 9:
|
3507
3507
|
o == null || o();
|
3508
|
-
|
3508
|
+
W();
|
3509
3509
|
u();
|
3510
3510
|
_context3.next = 17;
|
3511
3511
|
break;
|
@@ -3513,10 +3513,10 @@ function Eo(s, e) {
|
|
3513
3513
|
_context3.prev = 14;
|
3514
3514
|
_context3.t0 = _context3["catch"](1);
|
3515
3515
|
if (!g.signal.aborted) try {
|
3516
|
-
O = (le = a == null ? void 0 : a(_context3.t0)) !== null && le !== void 0 ? le :
|
3516
|
+
O = (le = a == null ? void 0 : a(_context3.t0)) !== null && le !== void 0 ? le : E;
|
3517
3517
|
window.clearTimeout(S), S = window.setTimeout(Q, O);
|
3518
3518
|
} catch (O) {
|
3519
|
-
|
3519
|
+
W(), h(O);
|
3520
3520
|
}
|
3521
3521
|
case 17:
|
3522
3522
|
case "end":
|
@@ -3533,80 +3533,6 @@ function _o(s) {
|
|
3533
3533
|
var e = s.headers.get("content-type");
|
3534
3534
|
if (!(e != null && e.startsWith(Bi))) throw new Error("Expected content-type to be ".concat(Bi, ", Actual: ").concat(e));
|
3535
3535
|
}
|
3536
|
-
var cs = /*#__PURE__*/function () {
|
3537
|
-
function lt() {
|
3538
|
-
_classCallCheck(this, lt);
|
3539
|
-
}
|
3540
|
-
_createClass(lt, null, [{
|
3541
|
-
key: "generateResponse",
|
3542
|
-
value: function generateResponse(e) {
|
3543
|
-
var t = e.messages[e.messages.length - 1];
|
3544
|
-
if (t.files && t.files.length > 0) {
|
3545
|
-
if (t.files.length > 1) return "These are interesting files!";
|
3546
|
-
var i = t.files[0];
|
3547
|
-
return i.src && i.src.startsWith("data:image/gif") ? "That is a nice gif!" : i.type === "image" ? "That is a nice image!" : i.type === "audio" ? "I like the sound of that!" : "That is an interesting file!";
|
3548
|
-
}
|
3549
|
-
if (t.text) {
|
3550
|
-
if (t.text.charAt(t.text.length - 1) === "?") return "I'm sorry but I can't answer that question...";
|
3551
|
-
if (t.text.includes("updog")) return "What's updog?";
|
3552
|
-
}
|
3553
|
-
return "Hi there! This is a demo response!";
|
3554
|
-
}
|
3555
|
-
}, {
|
3556
|
-
key: "getCustomResponse",
|
3557
|
-
value: function getCustomResponse(e, t) {
|
3558
|
-
return typeof e == "function" ? e(t) : e;
|
3559
|
-
}
|
3560
|
-
}, {
|
3561
|
-
key: "getResponse",
|
3562
|
-
value: function getResponse(e) {
|
3563
|
-
return e.customDemoResponse ? lt.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
|
3564
|
-
text: lt.generateResponse(e)
|
3565
|
-
};
|
3566
|
-
}
|
3567
|
-
// timeout is used to simulate a timeout for a response to come back
|
3568
|
-
}, {
|
3569
|
-
key: "request",
|
3570
|
-
value: function request(e, t) {
|
3571
|
-
var i = lt.getResponse(t);
|
3572
|
-
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
3573
|
-
var r, o, n;
|
3574
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
3575
|
-
while (1) switch (_context4.prev = _context4.next) {
|
3576
|
-
case 0:
|
3577
|
-
_context4.next = 2;
|
3578
|
-
return (o = (r = e.deepChat).responseInterceptor) == null ? void 0 : o.call(r, i);
|
3579
|
-
case 2:
|
3580
|
-
_context4.t0 = _context4.sent;
|
3581
|
-
if (_context4.t0) {
|
3582
|
-
_context4.next = 5;
|
3583
|
-
break;
|
3584
|
-
}
|
3585
|
-
_context4.t0 = i;
|
3586
|
-
case 5:
|
3587
|
-
n = _context4.t0;
|
3588
|
-
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) : I.isSimulation(e.deepChat.stream) ? I.simulate(t, e.streamHandlers, n) : (t.addNewMessage(n), e.completionsHandlers.onFinish());
|
3589
|
-
case 7:
|
3590
|
-
case "end":
|
3591
|
-
return _context4.stop();
|
3592
|
-
}
|
3593
|
-
}, _callee4);
|
3594
|
-
})), 400);
|
3595
|
-
}
|
3596
|
-
// timeout is used to simulate a timeout for a response to come back
|
3597
|
-
}, {
|
3598
|
-
key: "requestStream",
|
3599
|
-
value: function requestStream(e, t) {
|
3600
|
-
setTimeout(function () {
|
3601
|
-
var i = lt.getResponse(e);
|
3602
|
-
I.simulate(e, t, i);
|
3603
|
-
}, 400);
|
3604
|
-
}
|
3605
|
-
}]);
|
3606
|
-
return lt;
|
3607
|
-
}();
|
3608
|
-
cs.URL = "deep-chat-demo";
|
3609
|
-
var ye = cs;
|
3610
3536
|
var I = /*#__PURE__*/function () {
|
3611
3537
|
function I() {
|
3612
3538
|
_classCallCheck(this, I);
|
@@ -3615,16 +3541,16 @@ var I = /*#__PURE__*/function () {
|
|
3615
3541
|
key: "request",
|
3616
3542
|
value: // prettier-ignore
|
3617
3543
|
function () {
|
3618
|
-
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
3544
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(e, t, i) {
|
3619
3545
|
var n,
|
3620
|
-
|
3546
|
+
p,
|
3621
3547
|
g,
|
3622
3548
|
f,
|
3623
|
-
|
3549
|
+
E,
|
3624
3550
|
S,
|
3625
|
-
|
3551
|
+
W,
|
3626
3552
|
r,
|
3627
|
-
_yield$
|
3553
|
+
_yield$_$processReque,
|
3628
3554
|
o,
|
3629
3555
|
a,
|
3630
3556
|
l,
|
@@ -3632,133 +3558,133 @@ var I = /*#__PURE__*/function () {
|
|
3632
3558
|
c,
|
3633
3559
|
d,
|
3634
3560
|
u,
|
3635
|
-
|
3636
|
-
|
3637
|
-
return _regeneratorRuntime().wrap(function
|
3638
|
-
while (1) switch (
|
3561
|
+
h,
|
3562
|
+
_args6 = arguments;
|
3563
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
3564
|
+
while (1) switch (_context6.prev = _context6.next) {
|
3639
3565
|
case 0:
|
3640
|
-
n =
|
3566
|
+
n = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : !0;
|
3641
3567
|
r = {
|
3642
3568
|
body: t,
|
3643
|
-
headers: (
|
3569
|
+
headers: (p = e.requestSettings) == null ? void 0 : p.headers
|
3644
3570
|
};
|
3645
|
-
|
3646
|
-
return
|
3571
|
+
_context6.next = 4;
|
3572
|
+
return _.processRequestInterceptor(e.deepChat, r);
|
3647
3573
|
case 4:
|
3648
|
-
_yield$
|
3649
|
-
o = _yield$
|
3650
|
-
a = _yield$
|
3651
|
-
l = _yield$
|
3574
|
+
_yield$_$processReque = _context6.sent;
|
3575
|
+
o = _yield$_$processReque.body;
|
3576
|
+
a = _yield$_$processReque.headers;
|
3577
|
+
l = _yield$_$processReque.error;
|
3652
3578
|
_e$streamHandlers = e.streamHandlers;
|
3653
3579
|
c = _e$streamHandlers.onOpen;
|
3654
3580
|
d = _e$streamHandlers.onClose;
|
3655
3581
|
u = _e$streamHandlers.abortStream;
|
3656
3582
|
if (!l) {
|
3657
|
-
|
3583
|
+
_context6.next = 14;
|
3658
3584
|
break;
|
3659
3585
|
}
|
3660
|
-
return
|
3586
|
+
return _context6.abrupt("return", _.onInterceptorError(i, l, d));
|
3661
3587
|
case 14:
|
3662
3588
|
if (!((g = e.requestSettings) != null && g.handler)) {
|
3663
|
-
|
3589
|
+
_context6.next = 16;
|
3664
3590
|
break;
|
3665
3591
|
}
|
3666
|
-
return
|
3592
|
+
return _context6.abrupt("return", Le.stream(e, o, i));
|
3667
3593
|
case 16:
|
3668
3594
|
if (!(((f = e.requestSettings) == null ? void 0 : f.url) === ye.URL)) {
|
3669
|
-
|
3595
|
+
_context6.next = 18;
|
3670
3596
|
break;
|
3671
3597
|
}
|
3672
|
-
return
|
3598
|
+
return _context6.abrupt("return", ye.requestStream(i, e.streamHandlers));
|
3673
3599
|
case 18:
|
3674
|
-
|
3675
|
-
Eo(((
|
3600
|
+
h = new Oe(i);
|
3601
|
+
Eo(((E = e.requestSettings) == null ? void 0 : E.url) || e.url || "", {
|
3676
3602
|
method: ((S = e.requestSettings) == null ? void 0 : S.method) || "POST",
|
3677
3603
|
headers: a,
|
3678
|
-
credentials: (
|
3604
|
+
credentials: (W = e.requestSettings) == null ? void 0 : W.credentials,
|
3679
3605
|
body: n ? JSON.stringify(o) : o,
|
3680
3606
|
openWhenHidden: !0,
|
3681
3607
|
// keep stream open when browser tab not open
|
3682
3608
|
onopen: function onopen(A) {
|
3683
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
3684
|
-
return _regeneratorRuntime().wrap(function
|
3685
|
-
while (1) switch (
|
3609
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
3610
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
3611
|
+
while (1) switch (_context4.prev = _context4.next) {
|
3686
3612
|
case 0:
|
3687
3613
|
if (!A.ok) {
|
3688
|
-
|
3614
|
+
_context4.next = 2;
|
3689
3615
|
break;
|
3690
3616
|
}
|
3691
|
-
return
|
3617
|
+
return _context4.abrupt("return", c());
|
3692
3618
|
case 2:
|
3693
|
-
|
3694
|
-
return
|
3619
|
+
_context4.next = 4;
|
3620
|
+
return _.processResponseByType(A);
|
3695
3621
|
case 4:
|
3696
|
-
throw
|
3622
|
+
throw _context4.sent;
|
3697
3623
|
case 5:
|
3698
3624
|
case "end":
|
3699
|
-
return
|
3625
|
+
return _context4.stop();
|
3700
3626
|
}
|
3701
|
-
},
|
3627
|
+
}, _callee4);
|
3702
3628
|
}))();
|
3703
3629
|
},
|
3704
3630
|
onmessage: function onmessage(A) {
|
3705
|
-
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
3706
|
-
var
|
3707
|
-
return _regeneratorRuntime().wrap(function
|
3708
|
-
while (1) switch (
|
3631
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
3632
|
+
var J, Q, le, H, O;
|
3633
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
3634
|
+
while (1) switch (_context5.prev = _context5.next) {
|
3709
3635
|
case 0:
|
3710
3636
|
if (!(JSON.stringify(A.data) !== JSON.stringify("[DONE]"))) {
|
3711
|
-
|
3637
|
+
_context5.next = 9;
|
3712
3638
|
break;
|
3713
3639
|
}
|
3714
3640
|
try {
|
3715
|
-
|
3641
|
+
H = JSON.parse(A.data);
|
3716
3642
|
} catch (_unused6) {
|
3717
|
-
|
3643
|
+
H = {};
|
3718
3644
|
}
|
3719
|
-
|
3720
|
-
return (Q = (
|
3645
|
+
_context5.next = 4;
|
3646
|
+
return (Q = (J = e.deepChat).responseInterceptor) == null ? void 0 : Q.call(J, H);
|
3721
3647
|
case 4:
|
3722
|
-
|
3723
|
-
if (
|
3724
|
-
|
3648
|
+
_context5.t0 = _context5.sent;
|
3649
|
+
if (_context5.t0) {
|
3650
|
+
_context5.next = 7;
|
3725
3651
|
break;
|
3726
3652
|
}
|
3727
|
-
|
3653
|
+
_context5.t0 = H;
|
3728
3654
|
case 7:
|
3729
|
-
O =
|
3655
|
+
O = _context5.t0;
|
3730
3656
|
(le = e.extractResultData) == null || le.call(e, O).then(function (Ee) {
|
3731
|
-
|
3657
|
+
h.upsertStreamedMessage(Ee);
|
3732
3658
|
})["catch"](function (Ee) {
|
3733
|
-
return
|
3659
|
+
return _.displayError(i, Ee);
|
3734
3660
|
});
|
3735
3661
|
case 9:
|
3736
3662
|
case "end":
|
3737
|
-
return
|
3663
|
+
return _context5.stop();
|
3738
3664
|
}
|
3739
|
-
},
|
3665
|
+
}, _callee5);
|
3740
3666
|
}))();
|
3741
3667
|
},
|
3742
3668
|
onerror: function onerror(A) {
|
3743
3669
|
throw d(), A;
|
3744
3670
|
},
|
3745
3671
|
onclose: function onclose() {
|
3746
|
-
|
3672
|
+
h.finaliseStreamedMessage(), d();
|
3747
3673
|
},
|
3748
3674
|
signal: u.signal
|
3749
3675
|
})["catch"](function (A) {
|
3750
|
-
var
|
3751
|
-
(
|
3752
|
-
|
3676
|
+
var J;
|
3677
|
+
(J = e.extractResultData) == null || J.call(e, A).then(function () {
|
3678
|
+
_.displayError(i, A);
|
3753
3679
|
})["catch"](function (Q) {
|
3754
|
-
|
3680
|
+
_.displayError(i, Q);
|
3755
3681
|
});
|
3756
3682
|
});
|
3757
3683
|
case 20:
|
3758
3684
|
case "end":
|
3759
|
-
return
|
3685
|
+
return _context6.stop();
|
3760
3686
|
}
|
3761
|
-
},
|
3687
|
+
}, _callee6);
|
3762
3688
|
}));
|
3763
3689
|
function request(_x12, _x13, _x14) {
|
3764
3690
|
return _request.apply(this, arguments);
|
@@ -3775,7 +3701,7 @@ var I = /*#__PURE__*/function () {
|
|
3775
3701
|
}, i), !1), i.text) {
|
3776
3702
|
t.onOpen();
|
3777
3703
|
var r = i.text.split("");
|
3778
|
-
I.populateMessages(r, new
|
3704
|
+
I.populateMessages(r, new Oe(e), n);
|
3779
3705
|
}
|
3780
3706
|
}
|
3781
3707
|
}, {
|
@@ -3808,6 +3734,266 @@ var I = /*#__PURE__*/function () {
|
|
3808
3734
|
}]);
|
3809
3735
|
return I;
|
3810
3736
|
}();
|
3737
|
+
var cs = /*#__PURE__*/function () {
|
3738
|
+
function lt() {
|
3739
|
+
_classCallCheck(this, lt);
|
3740
|
+
}
|
3741
|
+
_createClass(lt, null, [{
|
3742
|
+
key: "generateResponse",
|
3743
|
+
value: function generateResponse(e) {
|
3744
|
+
var t = e.messages[e.messages.length - 1];
|
3745
|
+
if (t.files && t.files.length > 0) {
|
3746
|
+
if (t.files.length > 1) return "These are interesting files!";
|
3747
|
+
var i = t.files[0];
|
3748
|
+
return i.src && i.src.startsWith("data:image/gif") ? "That is a nice gif!" : i.type === "image" ? "That is a nice image!" : i.type === "audio" ? "I like the sound of that!" : "That is an interesting file!";
|
3749
|
+
}
|
3750
|
+
if (t.text) {
|
3751
|
+
if (t.text.charAt(t.text.length - 1) === "?") return "I'm sorry but I can't answer that question...";
|
3752
|
+
if (t.text.includes("updog")) return "What's updog?";
|
3753
|
+
}
|
3754
|
+
return "Hi there! This is a demo response!";
|
3755
|
+
}
|
3756
|
+
}, {
|
3757
|
+
key: "getCustomResponse",
|
3758
|
+
value: function getCustomResponse(e, t) {
|
3759
|
+
return typeof e == "function" ? e(t) : e;
|
3760
|
+
}
|
3761
|
+
}, {
|
3762
|
+
key: "getResponse",
|
3763
|
+
value: function getResponse(e) {
|
3764
|
+
return e.customDemoResponse ? lt.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
|
3765
|
+
text: lt.generateResponse(e)
|
3766
|
+
};
|
3767
|
+
}
|
3768
|
+
// timeout is used to simulate a timeout for a response to come back
|
3769
|
+
}, {
|
3770
|
+
key: "request",
|
3771
|
+
value: function request(e, t) {
|
3772
|
+
var i = lt.getResponse(t);
|
3773
|
+
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
3774
|
+
var r, o, n;
|
3775
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
3776
|
+
while (1) switch (_context7.prev = _context7.next) {
|
3777
|
+
case 0:
|
3778
|
+
_context7.next = 2;
|
3779
|
+
return (o = (r = e.deepChat).responseInterceptor) == null ? void 0 : o.call(r, i);
|
3780
|
+
case 2:
|
3781
|
+
_context7.t0 = _context7.sent;
|
3782
|
+
if (_context7.t0) {
|
3783
|
+
_context7.next = 5;
|
3784
|
+
break;
|
3785
|
+
}
|
3786
|
+
_context7.t0 = i;
|
3787
|
+
case 5:
|
3788
|
+
n = _context7.t0;
|
3789
|
+
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) : I.isSimulation(e.deepChat.stream) ? I.simulate(t, e.streamHandlers, n) : (t.addNewMessage(n), e.completionsHandlers.onFinish());
|
3790
|
+
case 7:
|
3791
|
+
case "end":
|
3792
|
+
return _context7.stop();
|
3793
|
+
}
|
3794
|
+
}, _callee7);
|
3795
|
+
})), 400);
|
3796
|
+
}
|
3797
|
+
// timeout is used to simulate a timeout for a response to come back
|
3798
|
+
}, {
|
3799
|
+
key: "requestStream",
|
3800
|
+
value: function requestStream(e, t) {
|
3801
|
+
setTimeout(function () {
|
3802
|
+
var i = lt.getResponse(e);
|
3803
|
+
I.simulate(e, t, i);
|
3804
|
+
}, 400);
|
3805
|
+
}
|
3806
|
+
}]);
|
3807
|
+
return lt;
|
3808
|
+
}();
|
3809
|
+
cs.URL = "deep-chat-demo";
|
3810
|
+
var ye = cs;
|
3811
|
+
var F = /*#__PURE__*/function () {
|
3812
|
+
function F() {
|
3813
|
+
_classCallCheck(this, F);
|
3814
|
+
}
|
3815
|
+
_createClass(F, null, [{
|
3816
|
+
key: "setup",
|
3817
|
+
value: function setup(e) {
|
3818
|
+
e.requestSettings.url !== ye.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
|
3819
|
+
}
|
3820
|
+
}, {
|
3821
|
+
key: "createConnection",
|
3822
|
+
value: function createConnection(e, t) {
|
3823
|
+
if (!document.body.contains(e.deepChat)) return;
|
3824
|
+
var i = e.requestSettings.websocket;
|
3825
|
+
if (i) {
|
3826
|
+
if (e.requestSettings.handler) return Le.websocket(e, t);
|
3827
|
+
try {
|
3828
|
+
var n = typeof i != "boolean" ? i : void 0,
|
3829
|
+
r = new WebSocket(e.requestSettings.url || "", n);
|
3830
|
+
e.websocket = r, e.websocket.onopen = function () {
|
3831
|
+
var o, a;
|
3832
|
+
t.removeError(), e.websocket && _typeof(e.websocket) == "object" && F.assignListeners(e, r, t), (a = (o = e.deepChat)._validationHandler) == null || a.call(o);
|
3833
|
+
}, e.websocket.onerror = function (o) {
|
3834
|
+
console.error(o), F.retryConnection(e, t);
|
3835
|
+
};
|
3836
|
+
} catch (n) {
|
3837
|
+
console.error(n), F.retryConnection(e, t);
|
3838
|
+
}
|
3839
|
+
}
|
3840
|
+
}
|
3841
|
+
}, {
|
3842
|
+
key: "retryConnection",
|
3843
|
+
value: function retryConnection(e, t) {
|
3844
|
+
var i, n;
|
3845
|
+
(n = (i = e.deepChat)._validationHandler) == null || n.call(i), document.body.contains(e.deepChat) && (e.websocket = "pending", t.isLastMessageError() || t.addNewErrorMessage("service", "Connection error"), setTimeout(function () {
|
3846
|
+
F.createConnection(e, t);
|
3847
|
+
}, 5e3));
|
3848
|
+
}
|
3849
|
+
}, {
|
3850
|
+
key: "assignListeners",
|
3851
|
+
value: function assignListeners(e, t, i) {
|
3852
|
+
var n = {};
|
3853
|
+
t.onmessage = /*#__PURE__*/function () {
|
3854
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(r) {
|
3855
|
+
var o, a, l, c, d;
|
3856
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
3857
|
+
while (1) switch (_context8.prev = _context8.next) {
|
3858
|
+
case 0:
|
3859
|
+
if (!e.extractResultData) {
|
3860
|
+
_context8.next = 20;
|
3861
|
+
break;
|
3862
|
+
}
|
3863
|
+
_context8.prev = 1;
|
3864
|
+
l = JSON.parse(r.data);
|
3865
|
+
_context8.next = 5;
|
3866
|
+
return (a = (o = e.deepChat).responseInterceptor) == null ? void 0 : a.call(o, l);
|
3867
|
+
case 5:
|
3868
|
+
_context8.t0 = _context8.sent;
|
3869
|
+
if (_context8.t0) {
|
3870
|
+
_context8.next = 8;
|
3871
|
+
break;
|
3872
|
+
}
|
3873
|
+
_context8.t0 = l;
|
3874
|
+
case 8:
|
3875
|
+
c = _context8.t0;
|
3876
|
+
_context8.next = 11;
|
3877
|
+
return e.extractResultData(c);
|
3878
|
+
case 11:
|
3879
|
+
d = _context8.sent;
|
3880
|
+
if (!(!d || _typeof(d) != "object")) {
|
3881
|
+
_context8.next = 14;
|
3882
|
+
break;
|
3883
|
+
}
|
3884
|
+
throw Error(C.INVALID_RESPONSE(l, "server", !!e.deepChat.responseInterceptor, c));
|
3885
|
+
case 14:
|
3886
|
+
I.isSimulation(e.deepChat.stream) ? F.stream(e, i, l, n) : i.addNewMessage(d);
|
3887
|
+
_context8.next = 20;
|
3888
|
+
break;
|
3889
|
+
case 17:
|
3890
|
+
_context8.prev = 17;
|
3891
|
+
_context8.t1 = _context8["catch"](1);
|
3892
|
+
_.displayError(i, _context8.t1, "Error in server message");
|
3893
|
+
case 20:
|
3894
|
+
case "end":
|
3895
|
+
return _context8.stop();
|
3896
|
+
}
|
3897
|
+
}, _callee8, null, [[1, 17]]);
|
3898
|
+
}));
|
3899
|
+
return function (_x15) {
|
3900
|
+
return _ref2.apply(this, arguments);
|
3901
|
+
};
|
3902
|
+
}(), t.onclose = function () {
|
3903
|
+
console.error("Connection closed"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error"), e.deepChat.stream && e.streamHandlers.abortStream.abort(), F.createConnection(e, i);
|
3904
|
+
};
|
3905
|
+
}
|
3906
|
+
}, {
|
3907
|
+
key: "sendWebsocket",
|
3908
|
+
value: function () {
|
3909
|
+
var _sendWebsocket = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(e, t, i) {
|
3910
|
+
var n,
|
3911
|
+
d,
|
3912
|
+
u,
|
3913
|
+
r,
|
3914
|
+
o,
|
3915
|
+
_yield$_$processReque2,
|
3916
|
+
a,
|
3917
|
+
l,
|
3918
|
+
c,
|
3919
|
+
_args9 = arguments;
|
3920
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
3921
|
+
while (1) switch (_context9.prev = _context9.next) {
|
3922
|
+
case 0:
|
3923
|
+
n = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : !0;
|
3924
|
+
r = e.websocket;
|
3925
|
+
if (!(!r || r === "pending")) {
|
3926
|
+
_context9.next = 4;
|
3927
|
+
break;
|
3928
|
+
}
|
3929
|
+
return _context9.abrupt("return");
|
3930
|
+
case 4:
|
3931
|
+
o = {
|
3932
|
+
body: t,
|
3933
|
+
headers: (d = e.requestSettings) == null ? void 0 : d.headers
|
3934
|
+
};
|
3935
|
+
_context9.next = 7;
|
3936
|
+
return _.processRequestInterceptor(e.deepChat, o);
|
3937
|
+
case 7:
|
3938
|
+
_yield$_$processReque2 = _context9.sent;
|
3939
|
+
a = _yield$_$processReque2.body;
|
3940
|
+
l = _yield$_$processReque2.error;
|
3941
|
+
if (!l) {
|
3942
|
+
_context9.next = 12;
|
3943
|
+
break;
|
3944
|
+
}
|
3945
|
+
return _context9.abrupt("return", i.addNewErrorMessage("service", l));
|
3946
|
+
case 12:
|
3947
|
+
if (F.isWebSocket(r)) {
|
3948
|
+
_context9.next = 14;
|
3949
|
+
break;
|
3950
|
+
}
|
3951
|
+
return _context9.abrupt("return", r.newUserMessage.listener(a));
|
3952
|
+
case 14:
|
3953
|
+
c = n ? JSON.stringify(a) : a;
|
3954
|
+
if (!(((u = e.requestSettings) == null ? void 0 : u.url) === ye.URL)) {
|
3955
|
+
_context9.next = 17;
|
3956
|
+
break;
|
3957
|
+
}
|
3958
|
+
return _context9.abrupt("return", ye.request(e, i));
|
3959
|
+
case 17:
|
3960
|
+
r.readyState === void 0 || r.readyState !== r.OPEN ? (console.error("Connection is not open"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error")) : (r.send(JSON.stringify(c)), e.completionsHandlers.onFinish());
|
3961
|
+
case 18:
|
3962
|
+
case "end":
|
3963
|
+
return _context9.stop();
|
3964
|
+
}
|
3965
|
+
}, _callee9);
|
3966
|
+
}));
|
3967
|
+
function sendWebsocket(_x16, _x17, _x18) {
|
3968
|
+
return _sendWebsocket.apply(this, arguments);
|
3969
|
+
}
|
3970
|
+
return sendWebsocket;
|
3971
|
+
}()
|
3972
|
+
}, {
|
3973
|
+
key: "canSendMessage",
|
3974
|
+
value: function canSendMessage(e) {
|
3975
|
+
return e ? e === "pending" ? !1 : F.isWebSocket(e) ? e.readyState !== void 0 && e.readyState === e.OPEN : e.isOpen : !0;
|
3976
|
+
}
|
3977
|
+
// if false then it is the internal websocket handler
|
3978
|
+
}, {
|
3979
|
+
key: "isWebSocket",
|
3980
|
+
value: function isWebSocket(e) {
|
3981
|
+
return e.send !== void 0;
|
3982
|
+
}
|
3983
|
+
}, {
|
3984
|
+
key: "stream",
|
3985
|
+
value: function stream(e, t, i, n) {
|
3986
|
+
var r = e.deepChat.stream.simulation;
|
3987
|
+
if (typeof r == "string") {
|
3988
|
+
var _n$o;
|
3989
|
+
var o = i.role || b.AI_ROLE,
|
3990
|
+
a = n[o];
|
3991
|
+
a && i.text === r ? (a.finaliseStreamedMessage(), delete n[o]) : ((_n$o = n[o]) !== null && _n$o !== void 0 ? _n$o : n[o] = new Oe(t), n[o].upsertStreamedMessage(i));
|
3992
|
+
} else I.simulate(t, e.streamHandlers, i);
|
3993
|
+
}
|
3994
|
+
}]);
|
3995
|
+
return F;
|
3996
|
+
}();
|
3811
3997
|
var Le = /*#__PURE__*/function () {
|
3812
3998
|
function Le() {
|
3813
3999
|
_classCallCheck(this, Le);
|
@@ -3815,45 +4001,45 @@ var Le = /*#__PURE__*/function () {
|
|
3815
4001
|
_createClass(Le, null, [{
|
3816
4002
|
key: "request",
|
3817
4003
|
value: function () {
|
3818
|
-
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
4004
|
+
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(e, t, i) {
|
3819
4005
|
var a, l, n, r, o;
|
3820
|
-
return _regeneratorRuntime().wrap(function
|
3821
|
-
while (1) switch (
|
4006
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
4007
|
+
while (1) switch (_context11.prev = _context11.next) {
|
3822
4008
|
case 0:
|
3823
4009
|
n = !0;
|
3824
4010
|
r = /*#__PURE__*/function () {
|
3825
|
-
var
|
3826
|
-
var u,
|
3827
|
-
return _regeneratorRuntime().wrap(function
|
3828
|
-
while (1) switch (
|
4011
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(c) {
|
4012
|
+
var u, h, d;
|
4013
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
4014
|
+
while (1) switch (_context10.prev = _context10.next) {
|
3829
4015
|
case 0:
|
3830
4016
|
if (n) {
|
3831
|
-
|
4017
|
+
_context10.next = 2;
|
3832
4018
|
break;
|
3833
4019
|
}
|
3834
|
-
return
|
4020
|
+
return _context10.abrupt("return");
|
3835
4021
|
case 2:
|
3836
4022
|
n = !1;
|
3837
|
-
|
3838
|
-
return (
|
4023
|
+
_context10.next = 5;
|
4024
|
+
return (h = (u = e.deepChat).responseInterceptor) == null ? void 0 : h.call(u, c);
|
3839
4025
|
case 5:
|
3840
|
-
|
3841
|
-
if (
|
3842
|
-
|
4026
|
+
_context10.t0 = _context10.sent;
|
4027
|
+
if (_context10.t0) {
|
4028
|
+
_context10.next = 8;
|
3843
4029
|
break;
|
3844
4030
|
}
|
3845
|
-
|
4031
|
+
_context10.t0 = c;
|
3846
4032
|
case 8:
|
3847
|
-
d =
|
3848
|
-
|
4033
|
+
d = _context10.t0;
|
4034
|
+
_.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), i.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) : I.isSimulation(e.deepChat.stream) ? I.simulate(i, e.streamHandlers, d) : (i.addNewMessage(d), e.completionsHandlers.onFinish()) : (console.error(C.INVALID_RESPONSE(c, "server", !!e.deepChat.responseInterceptor, d)), i.addNewErrorMessage("service", "Error in server message"), e.completionsHandlers.onFinish());
|
3849
4035
|
case 10:
|
3850
4036
|
case "end":
|
3851
|
-
return
|
4037
|
+
return _context10.stop();
|
3852
4038
|
}
|
3853
|
-
},
|
4039
|
+
}, _callee10);
|
3854
4040
|
}));
|
3855
|
-
return function r(
|
3856
|
-
return
|
4041
|
+
return function r(_x22) {
|
4042
|
+
return _ref3.apply(this, arguments);
|
3857
4043
|
};
|
3858
4044
|
}(), o = Le.generateOptionalSignals();
|
3859
4045
|
(l = (a = e.requestSettings).handler) == null || l.call(a, t, _objectSpread(_objectSpread({}, o), {}, {
|
@@ -3861,11 +4047,11 @@ var Le = /*#__PURE__*/function () {
|
|
3861
4047
|
}));
|
3862
4048
|
case 3:
|
3863
4049
|
case "end":
|
3864
|
-
return
|
4050
|
+
return _context11.stop();
|
3865
4051
|
}
|
3866
|
-
},
|
4052
|
+
}, _callee11);
|
3867
4053
|
}));
|
3868
|
-
function request(
|
4054
|
+
function request(_x19, _x20, _x21) {
|
3869
4055
|
return _request2.apply(this, arguments);
|
3870
4056
|
}
|
3871
4057
|
return request;
|
@@ -3873,24 +4059,24 @@ var Le = /*#__PURE__*/function () {
|
|
3873
4059
|
}, {
|
3874
4060
|
key: "stream",
|
3875
4061
|
value: function stream(e, t, i) {
|
3876
|
-
var u,
|
4062
|
+
var u, h;
|
3877
4063
|
var n = !0,
|
3878
4064
|
r = !1;
|
3879
|
-
var o = new
|
4065
|
+
var o = new Oe(i),
|
3880
4066
|
a = function a() {
|
3881
4067
|
r || !n || (e.streamHandlers.onOpen(), r = !0);
|
3882
4068
|
},
|
3883
4069
|
l = function l() {
|
3884
4070
|
n && (o.finaliseStreamedMessage(), e.streamHandlers.onClose(), n = !1);
|
3885
4071
|
},
|
3886
|
-
c = function c(
|
3887
|
-
n && (!
|
4072
|
+
c = function c(p) {
|
4073
|
+
n && (!p || _typeof(p) != "object" || typeof p.error != "string" && typeof p.html != "string" && typeof p.text != "string" ? console.error(C.INVALID_RESPONSE(p, "server", !1)) : p.error ? (console.error(p.error), o.finaliseStreamedMessage(), e.streamHandlers.onClose(), i.addNewErrorMessage("service", p.error), n = !1) : o.upsertStreamedMessage(p));
|
3888
4074
|
};
|
3889
4075
|
e.streamHandlers.abortStream.abort = function () {
|
3890
4076
|
o.finaliseStreamedMessage(), e.streamHandlers.onClose(), n = !1;
|
3891
4077
|
};
|
3892
4078
|
var d = Le.generateOptionalSignals();
|
3893
|
-
(
|
4079
|
+
(h = (u = e.requestSettings).handler) == null || h.call(u, t, _objectSpread(_objectSpread({}, d), {}, {
|
3894
4080
|
onOpen: a,
|
3895
4081
|
onResponse: c,
|
3896
4082
|
onClose: l,
|
@@ -3906,7 +4092,8 @@ var Le = /*#__PURE__*/function () {
|
|
3906
4092
|
isOpen: !1,
|
3907
4093
|
newUserMessage: {
|
3908
4094
|
listener: function listener() {}
|
3909
|
-
}
|
4095
|
+
},
|
4096
|
+
roleToStream: {}
|
3910
4097
|
};
|
3911
4098
|
e.websocket = i;
|
3912
4099
|
var n = function n() {
|
@@ -3916,37 +4103,37 @@ var Le = /*#__PURE__*/function () {
|
|
3916
4103
|
i.isOpen = !1;
|
3917
4104
|
},
|
3918
4105
|
o = /*#__PURE__*/function () {
|
3919
|
-
var
|
3920
|
-
var
|
3921
|
-
return _regeneratorRuntime().wrap(function
|
3922
|
-
while (1) switch (
|
4106
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(d) {
|
4107
|
+
var h, p, u;
|
4108
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
4109
|
+
while (1) switch (_context12.prev = _context12.next) {
|
3923
4110
|
case 0:
|
3924
4111
|
if (i.isOpen) {
|
3925
|
-
|
4112
|
+
_context12.next = 2;
|
3926
4113
|
break;
|
3927
4114
|
}
|
3928
|
-
return
|
4115
|
+
return _context12.abrupt("return");
|
3929
4116
|
case 2:
|
3930
|
-
|
3931
|
-
return (
|
4117
|
+
_context12.next = 4;
|
4118
|
+
return (p = (h = e.deepChat).responseInterceptor) == null ? void 0 : p.call(h, d);
|
3932
4119
|
case 4:
|
3933
|
-
|
3934
|
-
if (
|
3935
|
-
|
4120
|
+
_context12.t0 = _context12.sent;
|
4121
|
+
if (_context12.t0) {
|
4122
|
+
_context12.next = 7;
|
3936
4123
|
break;
|
3937
4124
|
}
|
3938
|
-
|
4125
|
+
_context12.t0 = d;
|
3939
4126
|
case 7:
|
3940
|
-
u =
|
3941
|
-
|
4127
|
+
u = _context12.t0;
|
4128
|
+
_.validateResponseFormat(u) ? typeof u.error == "string" ? (console.error(u.error), t.isLastMessageError() || t.addNewErrorMessage("service", u.error)) : I.isSimulation(e.deepChat.stream) ? F.stream(e, t, d, i.roleToStream) : t.addNewMessage(u) : (console.error(C.INVALID_RESPONSE(d, "server", !!e.deepChat.responseInterceptor, u)), t.addNewErrorMessage("service", "Error in server message"));
|
3942
4129
|
case 9:
|
3943
4130
|
case "end":
|
3944
|
-
return
|
4131
|
+
return _context12.stop();
|
3945
4132
|
}
|
3946
|
-
},
|
4133
|
+
}, _callee12);
|
3947
4134
|
}));
|
3948
|
-
return function o(
|
3949
|
-
return
|
4135
|
+
return function o(_x23) {
|
4136
|
+
return _ref4.apply(this, arguments);
|
3950
4137
|
};
|
3951
4138
|
}(),
|
3952
4139
|
a = Le.generateOptionalSignals();
|
@@ -3982,119 +4169,119 @@ var w = /*#__PURE__*/function () {
|
|
3982
4169
|
key: "request",
|
3983
4170
|
value: // prettier-ignore
|
3984
4171
|
function () {
|
3985
|
-
var _request3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
4172
|
+
var _request3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(e, t, i) {
|
3986
4173
|
var n,
|
3987
|
-
p,
|
3988
4174
|
h,
|
4175
|
+
p,
|
3989
4176
|
g,
|
3990
4177
|
r,
|
3991
|
-
_yield$
|
4178
|
+
_yield$_$processReque3,
|
3992
4179
|
o,
|
3993
4180
|
a,
|
3994
4181
|
l,
|
3995
4182
|
c,
|
3996
4183
|
d,
|
3997
4184
|
u,
|
3998
|
-
|
3999
|
-
return _regeneratorRuntime().wrap(function
|
4000
|
-
while (1) switch (
|
4185
|
+
_args14 = arguments;
|
4186
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
4187
|
+
while (1) switch (_context14.prev = _context14.next) {
|
4001
4188
|
case 0:
|
4002
|
-
n =
|
4189
|
+
n = _args14.length > 3 && _args14[3] !== undefined ? _args14[3] : !0;
|
4003
4190
|
r = {
|
4004
4191
|
body: t,
|
4005
|
-
headers: (
|
4192
|
+
headers: (h = e.requestSettings) == null ? void 0 : h.headers
|
4006
4193
|
};
|
4007
|
-
|
4008
|
-
return
|
4194
|
+
_context14.next = 4;
|
4195
|
+
return _.processRequestInterceptor(e.deepChat, r);
|
4009
4196
|
case 4:
|
4010
|
-
_yield$
|
4011
|
-
o = _yield$
|
4012
|
-
a = _yield$
|
4013
|
-
l = _yield$
|
4197
|
+
_yield$_$processReque3 = _context14.sent;
|
4198
|
+
o = _yield$_$processReque3.body;
|
4199
|
+
a = _yield$_$processReque3.headers;
|
4200
|
+
l = _yield$_$processReque3.error;
|
4014
4201
|
c = e.completionsHandlers.onFinish;
|
4015
4202
|
if (!l) {
|
4016
|
-
|
4203
|
+
_context14.next = 11;
|
4017
4204
|
break;
|
4018
4205
|
}
|
4019
|
-
return
|
4206
|
+
return _context14.abrupt("return", _.onInterceptorError(i, l, c));
|
4020
4207
|
case 11:
|
4021
|
-
if (!((
|
4022
|
-
|
4208
|
+
if (!((p = e.requestSettings) != null && p.handler)) {
|
4209
|
+
_context14.next = 13;
|
4023
4210
|
break;
|
4024
4211
|
}
|
4025
|
-
return
|
4212
|
+
return _context14.abrupt("return", Le.request(e, o, i));
|
4026
4213
|
case 13:
|
4027
4214
|
if (!(((g = e.requestSettings) == null ? void 0 : g.url) === ye.URL)) {
|
4028
|
-
|
4215
|
+
_context14.next = 15;
|
4029
4216
|
break;
|
4030
4217
|
}
|
4031
|
-
return
|
4218
|
+
return _context14.abrupt("return", ye.request(e, i));
|
4032
4219
|
case 15:
|
4033
4220
|
d = !0;
|
4034
|
-
u =
|
4221
|
+
u = _.fetch.bind(this, e, a, n);
|
4035
4222
|
u(o).then(function (f) {
|
4036
4223
|
return d = !!f.ok, f;
|
4037
4224
|
}).then(function (f) {
|
4038
|
-
return
|
4225
|
+
return _.processResponseByType(f);
|
4039
4226
|
}).then( /*#__PURE__*/function () {
|
4040
|
-
var
|
4041
|
-
var
|
4042
|
-
return _regeneratorRuntime().wrap(function
|
4043
|
-
while (1) switch (
|
4227
|
+
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(f) {
|
4228
|
+
var W, A, E, S;
|
4229
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
4230
|
+
while (1) switch (_context13.prev = _context13.next) {
|
4044
4231
|
case 0:
|
4045
4232
|
if (e.extractResultData) {
|
4046
|
-
|
4233
|
+
_context13.next = 2;
|
4047
4234
|
break;
|
4048
4235
|
}
|
4049
|
-
return
|
4236
|
+
return _context13.abrupt("return");
|
4050
4237
|
case 2:
|
4051
|
-
|
4052
|
-
return (A = (
|
4238
|
+
_context13.next = 4;
|
4239
|
+
return (A = (W = e.deepChat).responseInterceptor) == null ? void 0 : A.call(W, f);
|
4053
4240
|
case 4:
|
4054
|
-
|
4055
|
-
if (
|
4056
|
-
|
4241
|
+
_context13.t0 = _context13.sent;
|
4242
|
+
if (_context13.t0) {
|
4243
|
+
_context13.next = 7;
|
4057
4244
|
break;
|
4058
4245
|
}
|
4059
|
-
|
4246
|
+
_context13.t0 = f;
|
4060
4247
|
case 7:
|
4061
|
-
|
4062
|
-
|
4063
|
-
return e.extractResultData(
|
4248
|
+
E = _context13.t0;
|
4249
|
+
_context13.next = 10;
|
4250
|
+
return e.extractResultData(E, u, o);
|
4064
4251
|
case 10:
|
4065
|
-
S =
|
4252
|
+
S = _context13.sent;
|
4066
4253
|
if (d) {
|
4067
|
-
|
4254
|
+
_context13.next = 13;
|
4068
4255
|
break;
|
4069
4256
|
}
|
4070
4257
|
throw f;
|
4071
4258
|
case 13:
|
4072
4259
|
if (!(!S || _typeof(S) != "object")) {
|
4073
|
-
|
4260
|
+
_context13.next = 15;
|
4074
4261
|
break;
|
4075
4262
|
}
|
4076
|
-
throw Error(C.INVALID_RESPONSE(f, "response", !!e.deepChat.responseInterceptor,
|
4263
|
+
throw Error(C.INVALID_RESPONSE(f, "response", !!e.deepChat.responseInterceptor, E));
|
4077
4264
|
case 15:
|
4078
4265
|
S.makingAnotherRequest || (I.isSimulation(e.deepChat.stream) ? I.simulate(i, e.streamHandlers, S) : (i.addNewMessage(S), c()));
|
4079
4266
|
case 16:
|
4080
4267
|
case "end":
|
4081
|
-
return
|
4268
|
+
return _context13.stop();
|
4082
4269
|
}
|
4083
|
-
},
|
4270
|
+
}, _callee13);
|
4084
4271
|
}));
|
4085
|
-
return function (
|
4086
|
-
return
|
4272
|
+
return function (_x27) {
|
4273
|
+
return _ref5.apply(this, arguments);
|
4087
4274
|
};
|
4088
4275
|
}())["catch"](function (f) {
|
4089
|
-
|
4276
|
+
_.displayError(i, f), c();
|
4090
4277
|
});
|
4091
4278
|
case 18:
|
4092
4279
|
case "end":
|
4093
|
-
return
|
4280
|
+
return _context14.stop();
|
4094
4281
|
}
|
4095
|
-
},
|
4282
|
+
}, _callee14, this);
|
4096
4283
|
}));
|
4097
|
-
function request(
|
4284
|
+
function request(_x24, _x25, _x26) {
|
4098
4285
|
return _request3.apply(this, arguments);
|
4099
4286
|
}
|
4100
4287
|
return request;
|
@@ -4106,102 +4293,102 @@ var w = /*#__PURE__*/function () {
|
|
4106
4293
|
fetch(t, i).then(function (o) {
|
4107
4294
|
return o.json();
|
4108
4295
|
}).then( /*#__PURE__*/function () {
|
4109
|
-
var
|
4296
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(o) {
|
4110
4297
|
var l, c, a;
|
4111
|
-
return _regeneratorRuntime().wrap(function
|
4112
|
-
while (1) switch (
|
4298
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
4299
|
+
while (1) switch (_context15.prev = _context15.next) {
|
4113
4300
|
case 0:
|
4114
4301
|
if (e.extractPollResultData) {
|
4115
|
-
|
4302
|
+
_context15.next = 2;
|
4116
4303
|
break;
|
4117
4304
|
}
|
4118
|
-
return
|
4305
|
+
return _context15.abrupt("return");
|
4119
4306
|
case 2:
|
4120
|
-
|
4121
|
-
|
4307
|
+
_context15.t0 = e;
|
4308
|
+
_context15.next = 5;
|
4122
4309
|
return (c = (l = e.deepChat).responseInterceptor) == null ? void 0 : c.call(l, o);
|
4123
4310
|
case 5:
|
4124
|
-
|
4125
|
-
if (
|
4126
|
-
|
4311
|
+
_context15.t1 = _context15.sent;
|
4312
|
+
if (_context15.t1) {
|
4313
|
+
_context15.next = 8;
|
4127
4314
|
break;
|
4128
4315
|
}
|
4129
|
-
|
4316
|
+
_context15.t1 = o;
|
4130
4317
|
case 8:
|
4131
|
-
|
4132
|
-
|
4133
|
-
return
|
4318
|
+
_context15.t2 = _context15.t1;
|
4319
|
+
_context15.next = 11;
|
4320
|
+
return _context15.t0.extractPollResultData.call(_context15.t0, _context15.t2);
|
4134
4321
|
case 11:
|
4135
|
-
a =
|
4322
|
+
a = _context15.sent;
|
4136
4323
|
a.timeoutMS ? setTimeout(function () {
|
4137
4324
|
w.executePollRequest(e, t, i, n);
|
4138
4325
|
}, a.timeoutMS) : I.isSimulation(e.deepChat.stream) ? I.simulate(n, e.streamHandlers, a) : (n.addNewMessage(a), r());
|
4139
4326
|
case 13:
|
4140
4327
|
case "end":
|
4141
|
-
return
|
4328
|
+
return _context15.stop();
|
4142
4329
|
}
|
4143
|
-
},
|
4330
|
+
}, _callee15);
|
4144
4331
|
}));
|
4145
|
-
return function (
|
4146
|
-
return
|
4332
|
+
return function (_x28) {
|
4333
|
+
return _ref6.apply(this, arguments);
|
4147
4334
|
};
|
4148
4335
|
}())["catch"](function (o) {
|
4149
|
-
|
4336
|
+
_.displayError(n, o), r();
|
4150
4337
|
});
|
4151
4338
|
}
|
4152
4339
|
// prettier-ignore
|
4153
4340
|
}, {
|
4154
4341
|
key: "poll",
|
4155
4342
|
value: function () {
|
4156
|
-
var _poll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
4343
|
+
var _poll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(e, t, i) {
|
4157
4344
|
var n,
|
4158
|
-
|
4345
|
+
p,
|
4159
4346
|
g,
|
4160
4347
|
f,
|
4161
4348
|
r,
|
4162
|
-
_yield$
|
4349
|
+
_yield$_$processReque4,
|
4163
4350
|
o,
|
4164
4351
|
a,
|
4165
4352
|
l,
|
4166
4353
|
c,
|
4167
4354
|
d,
|
4168
4355
|
u,
|
4169
|
-
|
4170
|
-
|
4171
|
-
return _regeneratorRuntime().wrap(function
|
4172
|
-
while (1) switch (
|
4356
|
+
h,
|
4357
|
+
_args16 = arguments;
|
4358
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
4359
|
+
while (1) switch (_context16.prev = _context16.next) {
|
4173
4360
|
case 0:
|
4174
|
-
n =
|
4361
|
+
n = _args16.length > 3 && _args16[3] !== undefined ? _args16[3] : !0;
|
4175
4362
|
r = {
|
4176
4363
|
body: t,
|
4177
|
-
headers: (
|
4364
|
+
headers: (p = e.requestSettings) == null ? void 0 : p.headers
|
4178
4365
|
};
|
4179
|
-
|
4180
|
-
return
|
4366
|
+
_context16.next = 4;
|
4367
|
+
return _.processRequestInterceptor(e.deepChat, r);
|
4181
4368
|
case 4:
|
4182
|
-
_yield$
|
4183
|
-
o = _yield$
|
4184
|
-
a = _yield$
|
4185
|
-
l = _yield$
|
4369
|
+
_yield$_$processReque4 = _context16.sent;
|
4370
|
+
o = _yield$_$processReque4.body;
|
4371
|
+
a = _yield$_$processReque4.headers;
|
4372
|
+
l = _yield$_$processReque4.error;
|
4186
4373
|
if (!l) {
|
4187
|
-
|
4374
|
+
_context16.next = 10;
|
4188
4375
|
break;
|
4189
4376
|
}
|
4190
|
-
return
|
4377
|
+
return _context16.abrupt("return", _.onInterceptorError(i, l));
|
4191
4378
|
case 10:
|
4192
|
-
c = ((g = e.requestSettings) == null ? void 0 : g.url) || e.url || "", d = ((f = e.requestSettings) == null ? void 0 : f.method) || "POST", u = n ? JSON.stringify(o) : o,
|
4379
|
+
c = ((g = e.requestSettings) == null ? void 0 : g.url) || e.url || "", d = ((f = e.requestSettings) == null ? void 0 : f.method) || "POST", u = n ? JSON.stringify(o) : o, h = {
|
4193
4380
|
method: d,
|
4194
4381
|
body: u,
|
4195
4382
|
headers: a
|
4196
4383
|
};
|
4197
|
-
e.requestSettings.credentials && (
|
4384
|
+
e.requestSettings.credentials && (h.credentials = e.requestSettings.credentials), w.executePollRequest(e, c, h, i);
|
4198
4385
|
case 12:
|
4199
4386
|
case "end":
|
4200
|
-
return
|
4387
|
+
return _context16.stop();
|
4201
4388
|
}
|
4202
|
-
},
|
4389
|
+
}, _callee16);
|
4203
4390
|
}));
|
4204
|
-
function poll(
|
4391
|
+
function poll(_x29, _x30, _x31) {
|
4205
4392
|
return _poll.apply(this, arguments);
|
4206
4393
|
}
|
4207
4394
|
return poll;
|
@@ -4215,7 +4402,7 @@ var w = /*#__PURE__*/function () {
|
|
4215
4402
|
headers: i,
|
4216
4403
|
body: c || null
|
4217
4404
|
}).then(function (d) {
|
4218
|
-
return
|
4405
|
+
return _.processResponseByType(d);
|
4219
4406
|
}).then(function (d) {
|
4220
4407
|
l(d, e, r, o);
|
4221
4408
|
})["catch"](function (d) {
|
@@ -4262,180 +4449,6 @@ var et = /*#__PURE__*/function () {
|
|
4262
4449
|
}]);
|
4263
4450
|
return et;
|
4264
4451
|
}();
|
4265
|
-
var Y = /*#__PURE__*/function () {
|
4266
|
-
function Y() {
|
4267
|
-
_classCallCheck(this, Y);
|
4268
|
-
}
|
4269
|
-
_createClass(Y, null, [{
|
4270
|
-
key: "setup",
|
4271
|
-
value: function setup(e) {
|
4272
|
-
e.requestSettings.url !== ye.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
|
4273
|
-
}
|
4274
|
-
}, {
|
4275
|
-
key: "createConnection",
|
4276
|
-
value: function createConnection(e, t) {
|
4277
|
-
if (!document.body.contains(e.deepChat)) return;
|
4278
|
-
var i = e.requestSettings.websocket;
|
4279
|
-
if (i) {
|
4280
|
-
if (e.requestSettings.handler) return Le.websocket(e, t);
|
4281
|
-
try {
|
4282
|
-
var n = typeof i != "boolean" ? i : void 0,
|
4283
|
-
r = new WebSocket(e.requestSettings.url || "", n);
|
4284
|
-
e.websocket = r, e.websocket.onopen = function () {
|
4285
|
-
var o, a;
|
4286
|
-
t.removeError(), e.websocket && _typeof(e.websocket) == "object" && Y.assignListeners(e, r, t), (a = (o = e.deepChat)._validationHandler) == null || a.call(o);
|
4287
|
-
}, e.websocket.onerror = function (o) {
|
4288
|
-
console.error(o), Y.retryConnection(e, t);
|
4289
|
-
};
|
4290
|
-
} catch (n) {
|
4291
|
-
console.error(n), Y.retryConnection(e, t);
|
4292
|
-
}
|
4293
|
-
}
|
4294
|
-
}
|
4295
|
-
}, {
|
4296
|
-
key: "retryConnection",
|
4297
|
-
value: function retryConnection(e, t) {
|
4298
|
-
var i, n;
|
4299
|
-
(n = (i = e.deepChat)._validationHandler) == null || n.call(i), document.body.contains(e.deepChat) && (e.websocket = "pending", t.isLastMessageError() || t.addNewErrorMessage("service", "Connection error"), setTimeout(function () {
|
4300
|
-
Y.createConnection(e, t);
|
4301
|
-
}, 5e3));
|
4302
|
-
}
|
4303
|
-
}, {
|
4304
|
-
key: "assignListeners",
|
4305
|
-
value: function assignListeners(e, t, i) {
|
4306
|
-
t.onmessage = /*#__PURE__*/function () {
|
4307
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(n) {
|
4308
|
-
var r, o, a, l, c;
|
4309
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
4310
|
-
while (1) switch (_context15.prev = _context15.next) {
|
4311
|
-
case 0:
|
4312
|
-
if (!e.extractResultData) {
|
4313
|
-
_context15.next = 20;
|
4314
|
-
break;
|
4315
|
-
}
|
4316
|
-
_context15.prev = 1;
|
4317
|
-
a = JSON.parse(n.data);
|
4318
|
-
_context15.next = 5;
|
4319
|
-
return (o = (r = e.deepChat).responseInterceptor) == null ? void 0 : o.call(r, a);
|
4320
|
-
case 5:
|
4321
|
-
_context15.t0 = _context15.sent;
|
4322
|
-
if (_context15.t0) {
|
4323
|
-
_context15.next = 8;
|
4324
|
-
break;
|
4325
|
-
}
|
4326
|
-
_context15.t0 = a;
|
4327
|
-
case 8:
|
4328
|
-
l = _context15.t0;
|
4329
|
-
_context15.next = 11;
|
4330
|
-
return e.extractResultData(l);
|
4331
|
-
case 11:
|
4332
|
-
c = _context15.sent;
|
4333
|
-
if (!(!c || _typeof(c) != "object")) {
|
4334
|
-
_context15.next = 14;
|
4335
|
-
break;
|
4336
|
-
}
|
4337
|
-
throw Error(C.INVALID_RESPONSE(a, "server", !!e.deepChat.responseInterceptor, l));
|
4338
|
-
case 14:
|
4339
|
-
I.isSimulation(e.deepChat.stream) ? I.simulate(i, e.streamHandlers, c) : i.addNewMessage(c);
|
4340
|
-
_context15.next = 20;
|
4341
|
-
break;
|
4342
|
-
case 17:
|
4343
|
-
_context15.prev = 17;
|
4344
|
-
_context15.t1 = _context15["catch"](1);
|
4345
|
-
E.displayError(i, _context15.t1, "Error in server message");
|
4346
|
-
case 20:
|
4347
|
-
case "end":
|
4348
|
-
return _context15.stop();
|
4349
|
-
}
|
4350
|
-
}, _callee15, null, [[1, 17]]);
|
4351
|
-
}));
|
4352
|
-
return function (_x28) {
|
4353
|
-
return _ref6.apply(this, arguments);
|
4354
|
-
};
|
4355
|
-
}(), t.onclose = function () {
|
4356
|
-
console.error("Connection closed"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error"), e.deepChat.stream && e.streamHandlers.abortStream.abort(), Y.createConnection(e, i);
|
4357
|
-
};
|
4358
|
-
}
|
4359
|
-
}, {
|
4360
|
-
key: "sendWebsocket",
|
4361
|
-
value: function () {
|
4362
|
-
var _sendWebsocket = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(e, t, i) {
|
4363
|
-
var n,
|
4364
|
-
d,
|
4365
|
-
u,
|
4366
|
-
r,
|
4367
|
-
o,
|
4368
|
-
_yield$E$processReque4,
|
4369
|
-
a,
|
4370
|
-
l,
|
4371
|
-
c,
|
4372
|
-
_args16 = arguments;
|
4373
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
4374
|
-
while (1) switch (_context16.prev = _context16.next) {
|
4375
|
-
case 0:
|
4376
|
-
n = _args16.length > 3 && _args16[3] !== undefined ? _args16[3] : !0;
|
4377
|
-
r = e.websocket;
|
4378
|
-
if (!(!r || r === "pending")) {
|
4379
|
-
_context16.next = 4;
|
4380
|
-
break;
|
4381
|
-
}
|
4382
|
-
return _context16.abrupt("return");
|
4383
|
-
case 4:
|
4384
|
-
o = {
|
4385
|
-
body: t,
|
4386
|
-
headers: (d = e.requestSettings) == null ? void 0 : d.headers
|
4387
|
-
};
|
4388
|
-
_context16.next = 7;
|
4389
|
-
return E.processRequestInterceptor(e.deepChat, o);
|
4390
|
-
case 7:
|
4391
|
-
_yield$E$processReque4 = _context16.sent;
|
4392
|
-
a = _yield$E$processReque4.body;
|
4393
|
-
l = _yield$E$processReque4.error;
|
4394
|
-
if (!l) {
|
4395
|
-
_context16.next = 12;
|
4396
|
-
break;
|
4397
|
-
}
|
4398
|
-
return _context16.abrupt("return", i.addNewErrorMessage("service", l));
|
4399
|
-
case 12:
|
4400
|
-
if (Y.isWebSocket(r)) {
|
4401
|
-
_context16.next = 14;
|
4402
|
-
break;
|
4403
|
-
}
|
4404
|
-
return _context16.abrupt("return", r.newUserMessage.listener(a));
|
4405
|
-
case 14:
|
4406
|
-
c = n ? JSON.stringify(a) : a;
|
4407
|
-
if (!(((u = e.requestSettings) == null ? void 0 : u.url) === ye.URL)) {
|
4408
|
-
_context16.next = 17;
|
4409
|
-
break;
|
4410
|
-
}
|
4411
|
-
return _context16.abrupt("return", ye.request(e, i));
|
4412
|
-
case 17:
|
4413
|
-
r.readyState === void 0 || r.readyState !== r.OPEN ? (console.error("Connection is not open"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error")) : (r.send(JSON.stringify(c)), e.completionsHandlers.onFinish());
|
4414
|
-
case 18:
|
4415
|
-
case "end":
|
4416
|
-
return _context16.stop();
|
4417
|
-
}
|
4418
|
-
}, _callee16);
|
4419
|
-
}));
|
4420
|
-
function sendWebsocket(_x29, _x30, _x31) {
|
4421
|
-
return _sendWebsocket.apply(this, arguments);
|
4422
|
-
}
|
4423
|
-
return sendWebsocket;
|
4424
|
-
}()
|
4425
|
-
}, {
|
4426
|
-
key: "canSendMessage",
|
4427
|
-
value: function canSendMessage(e) {
|
4428
|
-
return e ? e === "pending" ? !1 : Y.isWebSocket(e) ? e.readyState !== void 0 && e.readyState === e.OPEN : e.isOpen : !0;
|
4429
|
-
}
|
4430
|
-
// if false then it is the internal websocket handler
|
4431
|
-
}, {
|
4432
|
-
key: "isWebSocket",
|
4433
|
-
value: function isWebSocket(e) {
|
4434
|
-
return e.send !== void 0;
|
4435
|
-
}
|
4436
|
-
}]);
|
4437
|
-
return Y;
|
4438
|
-
}();
|
4439
4452
|
var L = /*#__PURE__*/function () {
|
4440
4453
|
function L() {
|
4441
4454
|
_classCallCheck(this, L);
|
@@ -4477,12 +4490,12 @@ var L = /*#__PURE__*/function () {
|
|
4477
4490
|
}, {
|
4478
4491
|
key: "processMicrophone",
|
4479
4492
|
value: function processMicrophone(e, t, i, n) {
|
4480
|
-
var _l$files,
|
4481
|
-
var a, l, c, d, u,
|
4493
|
+
var _l$files, _h$maxNumberOfFiles;
|
4494
|
+
var a, l, c, d, u, h;
|
4482
4495
|
var o = _objectSpread({
|
4483
4496
|
acceptedFormats: "audio/*"
|
4484
4497
|
}, ((a = e.fileTypes.audio) == null ? void 0 : a.files) || {});
|
4485
|
-
i && (navigator.mediaDevices.getUserMedia !== void 0 ? (e.recordAudio = L.parseConfig(e.requestSettings, o, t, i), _typeof(i) == "object" && i.files && ((_l$files = (l = e.recordAudio).files) !== null && _l$files !== void 0 ? _l$files : l.files = {}, e.recordAudio.files.format = (c = i.files) == null ? void 0 : c.format, e.recordAudio.files.maxDurationSeconds = (d = i.files) == null ? void 0 : d.maxDurationSeconds, (u = e.fileTypes.audio) != null && u.files && ((
|
4498
|
+
i && (navigator.mediaDevices.getUserMedia !== void 0 ? (e.recordAudio = L.parseConfig(e.requestSettings, o, t, i), _typeof(i) == "object" && i.files && ((_l$files = (l = e.recordAudio).files) !== null && _l$files !== void 0 ? _l$files : l.files = {}, e.recordAudio.files.format = (c = i.files) == null ? void 0 : c.format, e.recordAudio.files.maxDurationSeconds = (d = i.files) == null ? void 0 : d.maxDurationSeconds, (u = e.fileTypes.audio) != null && u.files && ((_h$maxNumberOfFiles = (h = e.fileTypes.audio.files).maxNumberOfFiles) !== null && _h$maxNumberOfFiles !== void 0 ? _h$maxNumberOfFiles : h.maxNumberOfFiles = i.files.maxNumberOfFiles))) : n || (e.fileTypes.audio = L.parseConfig(e.requestSettings, o, t, i)));
|
4486
4499
|
}
|
4487
4500
|
// prettier-ignore
|
4488
4501
|
}, {
|
@@ -4544,14 +4557,14 @@ var L = /*#__PURE__*/function () {
|
|
4544
4557
|
}]);
|
4545
4558
|
return L;
|
4546
4559
|
}();
|
4547
|
-
var
|
4548
|
-
function
|
4560
|
+
var Pe = /*#__PURE__*/function () {
|
4561
|
+
function Pe(e, t, i) {
|
4549
4562
|
var _a$url;
|
4550
|
-
_classCallCheck(this,
|
4563
|
+
_classCallCheck(this, Pe);
|
4551
4564
|
var n, r, o, a;
|
4552
|
-
this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage =
|
4565
|
+
this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage = Pe.canSendMessage, this.requestSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = i, Object.assign(this.rawBody, (n = e.request) == null ? void 0 : n.additionalBodyProps), this.totalMessagesMaxCharLength = (r = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : r.totalMessagesMaxCharLength, this.maxMessages = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.maxMessages, L.set(e, this, t), e.request && (this.requestSettings = e.request), this.demo && ((_a$url = (a = this.requestSettings).url) !== null && _a$url !== void 0 ? _a$url : a.url = ye.URL), this.requestSettings.websocket && F.setup(this);
|
4553
4566
|
}
|
4554
|
-
_createClass(
|
4567
|
+
_createClass(Pe, [{
|
4555
4568
|
key: "verifyKey",
|
4556
4569
|
value: function verifyKey(e, t) {}
|
4557
4570
|
}, {
|
@@ -4626,7 +4639,7 @@ var Oe = /*#__PURE__*/function () {
|
|
4626
4639
|
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
4627
4640
|
while (1) switch (_context19.prev = _context19.next) {
|
4628
4641
|
case 0:
|
4629
|
-
n =
|
4642
|
+
n = Pe.createCustomFormDataBody(this.rawBody, t, i), r = this.requestSettings, o = this.getServiceIOByType(i[0]);
|
4630
4643
|
this.requestSettings = (o == null ? void 0 : o.request) || this.requestSettings;
|
4631
4644
|
_context19.next = 4;
|
4632
4645
|
return this.request(n, e, !1);
|
@@ -4681,7 +4694,7 @@ var Oe = /*#__PURE__*/function () {
|
|
4681
4694
|
n = _objectSpread({
|
4682
4695
|
messages: i
|
4683
4696
|
}, this.rawBody);
|
4684
|
-
|
4697
|
+
F.sendWebsocket(this, n, t, !1);
|
4685
4698
|
} else this.callServiceAPI(t, i, e.files);
|
4686
4699
|
case 4:
|
4687
4700
|
case "end":
|
@@ -4713,7 +4726,7 @@ var Oe = /*#__PURE__*/function () {
|
|
4713
4726
|
}
|
4714
4727
|
return _context22.abrupt("return", Re.handleResponseProperty(e));
|
4715
4728
|
case 4:
|
4716
|
-
if (!
|
4729
|
+
if (!_.validateResponseFormat(e)) {
|
4717
4730
|
_context22.next = 6;
|
4718
4731
|
break;
|
4719
4732
|
}
|
@@ -4761,19 +4774,19 @@ var Oe = /*#__PURE__*/function () {
|
|
4761
4774
|
return o.text && (delete o.files, n.append("message".concat(r += 1), JSON.stringify(o))), n;
|
4762
4775
|
}
|
4763
4776
|
}]);
|
4764
|
-
return
|
4777
|
+
return Pe;
|
4765
4778
|
}();
|
4766
|
-
var
|
4767
|
-
_inherits(
|
4779
|
+
var q = /*#__PURE__*/function (_Pe) {
|
4780
|
+
_inherits(q, _Pe);
|
4768
4781
|
// prettier-ignore
|
4769
|
-
function
|
4782
|
+
function q(e, t, i, n, r) {
|
4770
4783
|
var _this6;
|
4771
|
-
_classCallCheck(this,
|
4784
|
+
_classCallCheck(this, q);
|
4772
4785
|
var o;
|
4773
|
-
_this6 = _callSuper(this,
|
4786
|
+
_this6 = _callSuper(this, q, [e, r]), _this6.insertKeyPlaceholderText = "API Key", _this6.keyHelpUrl = "", Object.assign(_this6.rawBody, (o = e.request) == null ? void 0 : o.additionalBodyProps), _this6.keyVerificationDetails = t, _this6.buildHeadersFunc = i, n && _this6.setApiKeyProperties(n), _this6.requestSettings = _this6.buildRequestSettings(_this6.key || "", e.request);
|
4774
4787
|
return _this6;
|
4775
4788
|
}
|
4776
|
-
_createClass(
|
4789
|
+
_createClass(q, [{
|
4777
4790
|
key: "setApiKeyProperties",
|
4778
4791
|
value: function setApiKeyProperties(e) {
|
4779
4792
|
this.key = e.key, e.validateKeyProperty && (this.validateConfigKey = e.validateKeyProperty);
|
@@ -4809,8 +4822,8 @@ var U = /*#__PURE__*/function (_Oe) {
|
|
4809
4822
|
return !0;
|
4810
4823
|
}
|
4811
4824
|
}]);
|
4812
|
-
return
|
4813
|
-
}(
|
4825
|
+
return q;
|
4826
|
+
}(Pe);
|
4814
4827
|
var zt = /*#__PURE__*/function () {
|
4815
4828
|
function zt() {
|
4816
4829
|
_classCallCheck(this, zt);
|
@@ -4831,18 +4844,18 @@ var zt = /*#__PURE__*/function () {
|
|
4831
4844
|
return zt;
|
4832
4845
|
}();
|
4833
4846
|
var Yi = /*#__PURE__*/function (_HTMLElement) {
|
4834
|
-
_inherits(
|
4847
|
+
_inherits(Je, _HTMLElement);
|
4835
4848
|
// If this is not working, try using propertyName directly
|
4836
|
-
function
|
4849
|
+
function Je() {
|
4837
4850
|
var _this7;
|
4838
|
-
_classCallCheck(this,
|
4839
|
-
_this7 = _callSuper(this,
|
4840
|
-
var t =
|
4851
|
+
_classCallCheck(this, Je);
|
4852
|
+
_this7 = _callSuper(this, Je), _this7._waitingToRender_ = !1, _this7._propUpdated_ = !1, Object.keys(Je._attributeToProperty_).forEach(function (e) {
|
4853
|
+
var t = Je._attributeToProperty_[e];
|
4841
4854
|
_this7.constructPropertyAccessors(t), _this7.hasOwnProperty(e) || _this7.constructPropertyAccessors(t, e);
|
4842
4855
|
});
|
4843
4856
|
return _this7;
|
4844
4857
|
}
|
4845
|
-
_createClass(
|
4858
|
+
_createClass(Je, [{
|
4846
4859
|
key: "constructPropertyAccessors",
|
4847
4860
|
value:
|
4848
4861
|
// need to be called here as accessors need to be set for the class instance
|
@@ -4861,8 +4874,8 @@ var Yi = /*#__PURE__*/function (_HTMLElement) {
|
|
4861
4874
|
key: "attributeChangedCallback",
|
4862
4875
|
value: function attributeChangedCallback(e, t, i) {
|
4863
4876
|
if (t === i) return;
|
4864
|
-
var n =
|
4865
|
-
r =
|
4877
|
+
var n = Je._attributes_[e](i),
|
4878
|
+
r = Je._attributeToProperty_[e];
|
4866
4879
|
this[r] = n;
|
4867
4880
|
}
|
4868
4881
|
}, {
|
@@ -4871,43 +4884,43 @@ var Yi = /*#__PURE__*/function (_HTMLElement) {
|
|
4871
4884
|
}], [{
|
4872
4885
|
key: "observedAttributes",
|
4873
4886
|
get: function get() {
|
4874
|
-
return Object.keys(
|
4887
|
+
return Object.keys(Je._attributes_) || [];
|
4875
4888
|
}
|
4876
4889
|
}]);
|
4877
|
-
return
|
4890
|
+
return Je;
|
4878
4891
|
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
4879
4892
|
Yi._attributes_ = {};
|
4880
4893
|
Yi._attributeToProperty_ = {};
|
4881
4894
|
var So = Yi;
|
4882
4895
|
var wo = "<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path d=\"\n\t\t\tM669.727,273.516c-22.891-2.476-46.15-3.895-69.727-4.248c-103.025,0.457-209.823,25.517-310.913,73.536\n\t\t\tc-75.058,37.122-148.173,89.529-211.67,154.174C46.232,529.978,6.431,577.76,0,628.74c0.76,44.162,48.153,98.67,77.417,131.764\n\t\t\tc59.543,62.106,130.754,113.013,211.67,154.174c2.75,1.335,5.51,2.654,8.276,3.955l-75.072,131.102l102.005,60.286l551.416-960.033\n\t\t\tl-98.186-60.008L669.727,273.516z M902.563,338.995l-74.927,129.857c34.47,44.782,54.932,100.006,54.932,159.888\n\t\t\tc0,149.257-126.522,270.264-282.642,270.264c-6.749,0-13.29-0.728-19.922-1.172l-49.585,85.84c22.868,2.449,45.99,4.233,69.58,4.541\n\t\t\tc103.123-0.463,209.861-25.812,310.84-73.535c75.058-37.122,148.246-89.529,211.743-154.174\n\t\t\tc31.186-32.999,70.985-80.782,77.417-131.764c-0.76-44.161-48.153-98.669-77.417-131.763\n\t\t\tc-59.543-62.106-130.827-113.013-211.743-154.175C908.108,341.478,905.312,340.287,902.563,338.995L902.563,338.995z\n\t\t\tM599.927,358.478c6.846,0,13.638,0.274,20.361,0.732l-58.081,100.561c-81.514,16.526-142.676,85.88-142.676,168.897\n\t\t\tc0,20.854,3.841,40.819,10.913,59.325c0.008,0.021-0.008,0.053,0,0.074l-58.228,100.854\n\t\t\tc-34.551-44.823-54.932-100.229-54.932-160.182C317.285,479.484,443.808,358.477,599.927,358.478L599.927,358.478z M768.896,570.513\n\t\t\tL638.013,797.271c81.076-16.837,141.797-85.875,141.797-168.603C779.81,608.194,775.724,588.729,768.896,570.513L768.896,570.513z\"\n\t\t\t/>\n</svg>\n",
|
4883
4896
|
Mo = "<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path id=\"path6686\" inkscape:connector-curvature=\"0\" d=\"M779.843,599.925c0,95.331-80.664,172.612-180.169,172.612\n\t\t\tc-99.504,0-180.168-77.281-180.168-172.612c0-95.332,80.664-172.612,180.168-172.612\n\t\t\tC699.179,427.312,779.843,504.594,779.843,599.925z M600,240.521c-103.025,0.457-209.814,25.538-310.904,73.557\n\t\t\tc-75.058,37.122-148.206,89.496-211.702,154.141C46.208,501.218,6.431,549,0,599.981c0.76,44.161,48.13,98.669,77.394,131.763\n\t\t\tc59.543,62.106,130.786,113.018,211.702,154.179c94.271,45.751,198.616,72.092,310.904,73.557\n\t\t\tc103.123-0.464,209.888-25.834,310.866-73.557c75.058-37.122,148.243-89.534,211.74-154.179\n\t\t\tc31.185-32.999,70.962-80.782,77.394-131.763c-0.76-44.161-48.13-98.671-77.394-131.764\n\t\t\tc-59.543-62.106-130.824-112.979-211.74-154.141C816.644,268.36,712.042,242.2,600,240.521z M599.924,329.769\n\t\t\tc156.119,0,282.675,120.994,282.675,270.251c0,149.256-126.556,270.25-282.675,270.25S317.249,749.275,317.249,600.02\n\t\t\tC317.249,450.763,443.805,329.769,599.924,329.769L599.924,329.769z\"/>\n</svg>\n";
|
4884
|
-
var
|
4885
|
-
function
|
4886
|
-
_classCallCheck(this,
|
4897
|
+
var G = /*#__PURE__*/function () {
|
4898
|
+
function G() {
|
4899
|
+
_classCallCheck(this, G);
|
4887
4900
|
}
|
4888
|
-
_createClass(
|
4901
|
+
_createClass(G, null, [{
|
4889
4902
|
key: "createSVGElement",
|
4890
4903
|
value: function createSVGElement(e) {
|
4891
4904
|
return new DOMParser().parseFromString(e, "image/svg+xml").documentElement;
|
4892
4905
|
}
|
4893
4906
|
}]);
|
4894
|
-
return
|
4907
|
+
return G;
|
4895
4908
|
}();
|
4896
4909
|
var ds = /*#__PURE__*/function () {
|
4897
|
-
function
|
4898
|
-
_classCallCheck(this,
|
4910
|
+
function $e() {
|
4911
|
+
_classCallCheck(this, $e);
|
4899
4912
|
}
|
4900
|
-
_createClass(
|
4913
|
+
_createClass($e, null, [{
|
4901
4914
|
key: "changeVisibility",
|
4902
4915
|
value:
|
4903
4916
|
// prettier-ignore
|
4904
4917
|
function changeVisibility(e, t, i, n) {
|
4905
|
-
n.target.id ===
|
4918
|
+
n.target.id === $e.VISIBLE_ICON_ID ? (t.style.display = "none", i.style.display = "block", e.type = "password") : (t.style.display = "block", i.style.display = "none", e.type = "text");
|
4906
4919
|
}
|
4907
4920
|
}, {
|
4908
4921
|
key: "createIconElement",
|
4909
4922
|
value: function createIconElement(e, t) {
|
4910
|
-
var i =
|
4923
|
+
var i = G.createSVGElement(e);
|
4911
4924
|
return i.id = t, i.classList.add("visibility-icon"), i;
|
4912
4925
|
}
|
4913
4926
|
// prettier-ignore
|
@@ -4916,13 +4929,13 @@ var ds = /*#__PURE__*/function () {
|
|
4916
4929
|
value: function create(e) {
|
4917
4930
|
var t = document.createElement("div");
|
4918
4931
|
t.id = "visibility-icon-container";
|
4919
|
-
var i =
|
4932
|
+
var i = $e.createIconElement(Mo, $e.VISIBLE_ICON_ID);
|
4920
4933
|
i.style.display = "none", t.appendChild(i);
|
4921
|
-
var n =
|
4922
|
-
return t.appendChild(n), t.onclick =
|
4934
|
+
var n = $e.createIconElement(wo, "not-visible-icon");
|
4935
|
+
return t.appendChild(n), t.onclick = $e.changeVisibility.bind(this, e, i, n), t;
|
4923
4936
|
}
|
4924
4937
|
}]);
|
4925
|
-
return
|
4938
|
+
return $e;
|
4926
4939
|
}();
|
4927
4940
|
ds.VISIBLE_ICON_ID = "visible-icon";
|
4928
4941
|
var To = ds;
|
@@ -5250,8 +5263,8 @@ var wn = {
|
|
5250
5263
|
}],
|
5251
5264
|
use_web_worker: !0
|
5252
5265
|
},
|
5253
|
-
it = /*#__PURE__*/function (
|
5254
|
-
_inherits(M,
|
5266
|
+
it = /*#__PURE__*/function (_Pe2) {
|
5267
|
+
_inherits(M, _Pe2);
|
5255
5268
|
function M(e) {
|
5256
5269
|
var _this8;
|
5257
5270
|
_classCallCheck(this, M);
|
@@ -5409,16 +5422,16 @@ var wn = {
|
|
5409
5422
|
value: function () {
|
5410
5423
|
var _loadModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(e, t) {
|
5411
5424
|
var _this12 = this;
|
5412
|
-
var o, a, l, c, d, u,
|
5425
|
+
var o, a, l, c, d, u, h, i, n, r, _this$getConfig, p, g, f, _p;
|
5413
5426
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
5414
5427
|
while (1) switch (_context25.prev = _context25.next) {
|
5415
5428
|
case 0:
|
5416
5429
|
this.scrollToTop(), M.chat = e, this._isModelLoading = !0;
|
5417
5430
|
i = ((o = this._webModel.introMessage) == null ? void 0 : o.displayed) === !1;
|
5418
|
-
n = function n(
|
5431
|
+
n = function n(p) {
|
5419
5432
|
var g;
|
5420
5433
|
(g = _this12._messages) == null || g.addNewMessage({
|
5421
|
-
html: "<div>".concat(
|
5434
|
+
html: "<div>".concat(p.text, "</div>"),
|
5422
5435
|
overwrite: !0,
|
5423
5436
|
sendUpdate: !1
|
5424
5437
|
}), i && (setTimeout(function () {
|
@@ -5428,13 +5441,13 @@ var wn = {
|
|
5428
5441
|
};
|
5429
5442
|
M.chat.setInitProgressCallback(n);
|
5430
5443
|
_context25.prev = 4;
|
5431
|
-
_this$getConfig = this.getConfig(),
|
5444
|
+
_this$getConfig = this.getConfig(), p = _this$getConfig.model, g = _this$getConfig.appConfig, f = {};
|
5432
5445
|
this._webModel.instruction && (f.conv_config = {
|
5433
5446
|
system: this._webModel.instruction
|
5434
5447
|
});
|
5435
5448
|
this._conversationHistory.length > 0 && (f.conversation_history = this._conversationHistory);
|
5436
5449
|
_context25.next = 10;
|
5437
|
-
return M.chat.reload(
|
5450
|
+
return M.chat.reload(p, f, g, t);
|
5438
5451
|
case 10:
|
5439
5452
|
r = _context25.sent;
|
5440
5453
|
_context25.next = 16;
|
@@ -5444,10 +5457,10 @@ var wn = {
|
|
5444
5457
|
_context25.t0 = _context25["catch"](4);
|
5445
5458
|
return _context25.abrupt("return", this.unloadChat(_context25.t0));
|
5446
5459
|
case 16:
|
5447
|
-
if ((l = (a = this.deepChat)._validationHandler) == null || l.call(a), (c = this._webModel.introMessage) != null && c.removeAfterLoad) this._webModel.introMessage.displayed === !1 ? (u = this._messages) == null || u.removeLastMessage() : (
|
5448
|
-
|
5460
|
+
if ((l = (a = this.deepChat)._validationHandler) == null || l.call(a), (c = this._webModel.introMessage) != null && c.removeAfterLoad) this._webModel.introMessage.displayed === !1 ? (u = this._messages) == null || u.removeLastMessage() : (h = this._removeIntro) == null || h.call(this);else {
|
5461
|
+
_p = Sn.setUpAfterLoad(r, this._webModel.introMessage, this._chatEl, !!this._webModel.worker);
|
5449
5462
|
(d = this._messages) == null || d.addNewMessage({
|
5450
|
-
html:
|
5463
|
+
html: _p,
|
5451
5464
|
overwrite: !0,
|
5452
5465
|
sendUpdate: !1
|
5453
5466
|
});
|
@@ -5539,7 +5552,7 @@ var wn = {
|
|
5539
5552
|
this.streamHandlers.abortStream.abort = function () {
|
5540
5553
|
i.interruptGenerate();
|
5541
5554
|
}, this.streamHandlers.onOpen();
|
5542
|
-
n = new
|
5555
|
+
n = new Oe(e);
|
5543
5556
|
_context29.next = 4;
|
5544
5557
|
return i.generate(t, /*#__PURE__*/function () {
|
5545
5558
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(r, o) {
|
@@ -5624,30 +5637,30 @@ var wn = {
|
|
5624
5637
|
key: "generateResp",
|
5625
5638
|
value: function () {
|
5626
5639
|
var _generateResp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(e, t, i) {
|
5627
|
-
var n, _yield$
|
5640
|
+
var n, _yield$_$processReque5, r, o, a, l, c;
|
5628
5641
|
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
5629
5642
|
while (1) switch (_context31.prev = _context31.next) {
|
5630
5643
|
case 0:
|
5631
5644
|
n = t[t.length - 1].text;
|
5632
5645
|
_context31.next = 3;
|
5633
|
-
return
|
5646
|
+
return _.processRequestInterceptor(this.deepChat, {
|
5634
5647
|
body: {
|
5635
5648
|
text: n
|
5636
5649
|
}
|
5637
5650
|
});
|
5638
5651
|
case 3:
|
5639
|
-
_yield$
|
5640
|
-
r = _yield$
|
5641
|
-
o = _yield$
|
5652
|
+
_yield$_$processReque5 = _context31.sent;
|
5653
|
+
r = _yield$_$processReque5.body;
|
5654
|
+
o = _yield$_$processReque5.error;
|
5642
5655
|
a = !!this.deepChat.stream;
|
5643
5656
|
try {
|
5644
|
-
if (o)
|
5657
|
+
if (o) _.displayError(e, new Error(o)), (a ? this.streamHandlers.onClose : this.completionsHandlers.onFinish)();else if (!r || !r.text) {
|
5645
5658
|
l = C.INVALID_MODEL_REQUEST({
|
5646
5659
|
body: r
|
5647
5660
|
}, !1);
|
5648
5661
|
console.error(l);
|
5649
5662
|
c = a ? this.streamHandlers.onClose : this.completionsHandlers.onFinish;
|
5650
|
-
|
5663
|
+
_.onInterceptorError(e, l, c);
|
5651
5664
|
} else this.generateRespByType(e, r.text, !!this.deepChat.stream, i);
|
5652
5665
|
} catch (l) {
|
5653
5666
|
this.unloadChat(l);
|
@@ -5742,7 +5755,7 @@ var wn = {
|
|
5742
5755
|
_context33.next = 11;
|
5743
5756
|
break;
|
5744
5757
|
}
|
5745
|
-
|
5758
|
+
_.displayError(t, new Error(n.error));
|
5746
5759
|
return _context33.abrupt("return");
|
5747
5760
|
case 11:
|
5748
5761
|
if (!(!n || !n.text)) {
|
@@ -5750,7 +5763,7 @@ var wn = {
|
|
5750
5763
|
break;
|
5751
5764
|
}
|
5752
5765
|
o = C.INVALID_MODEL_RESPONSE(i, !!e.responseInterceptor, n);
|
5753
|
-
|
5766
|
+
_.displayError(t, new Error(o));
|
5754
5767
|
return _context33.abrupt("return");
|
5755
5768
|
case 15:
|
5756
5769
|
return _context33.abrupt("return", n);
|
@@ -5783,7 +5796,7 @@ var wn = {
|
|
5783
5796
|
}
|
5784
5797
|
}]);
|
5785
5798
|
return M;
|
5786
|
-
}(
|
5799
|
+
}(Pe);
|
5787
5800
|
it.GENERIC_ERROR = "Error, please check the [troubleshooting](https://deepchat.dev/docs/webModel#troubleshooting) section of documentation for help.";
|
5788
5801
|
it.MULTIPLE_MODELS_ERROR = "Cannot run multiple web models";
|
5789
5802
|
it.WEB_LLM_NOT_FOUND_ERROR = "WebLLM module not found";
|
@@ -5822,8 +5835,8 @@ var Ut = /*#__PURE__*/function () {
|
|
5822
5835
|
}]);
|
5823
5836
|
return Ut;
|
5824
5837
|
}();
|
5825
|
-
var us = /*#__PURE__*/function (
|
5826
|
-
_inherits(Fi,
|
5838
|
+
var us = /*#__PURE__*/function (_q) {
|
5839
|
+
_inherits(Fi, _q);
|
5827
5840
|
// prettier-ignore
|
5828
5841
|
function Fi(e, t, i, n, r, o) {
|
5829
5842
|
var _this14;
|
@@ -5871,11 +5884,11 @@ var us = /*#__PURE__*/function (_U) {
|
|
5871
5884
|
}()
|
5872
5885
|
}]);
|
5873
5886
|
return Fi;
|
5874
|
-
}(
|
5887
|
+
}(q);
|
5875
5888
|
us.URL_PREFIX = "https://api-inference.huggingface.co/models/";
|
5876
|
-
var
|
5877
|
-
var St = /*#__PURE__*/function (
|
5878
|
-
_inherits(St,
|
5889
|
+
var Fe = us;
|
5890
|
+
var St = /*#__PURE__*/function (_Fe) {
|
5891
|
+
_inherits(St, _Fe);
|
5879
5892
|
// prettier-ignore
|
5880
5893
|
function St(e, t, i, n, r, o) {
|
5881
5894
|
var _this15;
|
@@ -5927,7 +5940,7 @@ var St = /*#__PURE__*/function (_Be) {
|
|
5927
5940
|
}
|
5928
5941
|
}]);
|
5929
5942
|
return St;
|
5930
|
-
}(
|
5943
|
+
}(Fe);
|
5931
5944
|
var Co = /*#__PURE__*/function (_St) {
|
5932
5945
|
_inherits(Co, _St);
|
5933
5946
|
// prettier-ignore
|
@@ -6060,8 +6073,8 @@ var ae = /*#__PURE__*/function () {
|
|
6060
6073
|
}]);
|
6061
6074
|
return ae;
|
6062
6075
|
}();
|
6063
|
-
var ri = /*#__PURE__*/function (
|
6064
|
-
_inherits(ri,
|
6076
|
+
var ri = /*#__PURE__*/function (_q2) {
|
6077
|
+
_inherits(ri, _q2);
|
6065
6078
|
// prettier-ignore
|
6066
6079
|
function ri(e, t, i, n, r) {
|
6067
6080
|
var _this16;
|
@@ -6070,7 +6083,7 @@ var ri = /*#__PURE__*/function (_U2) {
|
|
6070
6083
|
return _this16;
|
6071
6084
|
}
|
6072
6085
|
return _createClass(ri);
|
6073
|
-
}(
|
6086
|
+
}(q);
|
6074
6087
|
var qt = /*#__PURE__*/function (_ri) {
|
6075
6088
|
_inherits(qt, _ri);
|
6076
6089
|
function qt(e) {
|
@@ -6122,7 +6135,7 @@ var qt = /*#__PURE__*/function (_ri) {
|
|
6122
6135
|
throw new Error("Image was not found");
|
6123
6136
|
case 4:
|
6124
6137
|
n = this.createFormDataBody(this.rawBody, i[0]);
|
6125
|
-
|
6138
|
+
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, n, e), !1);
|
6126
6139
|
case 6:
|
6127
6140
|
case "end":
|
6128
6141
|
return _context38.stop();
|
@@ -6230,7 +6243,7 @@ var Ht = /*#__PURE__*/function (_ri2) {
|
|
6230
6243
|
throw new Error("Image was not found");
|
6231
6244
|
case 4:
|
6232
6245
|
n = (a = (o = t[t.length - 1]) == null ? void 0 : o.text) == null ? void 0 : a.trim(), r = this.createFormDataBody(this.rawBody, i[0], i[1], n);
|
6233
|
-
|
6246
|
+
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, r, e), !1);
|
6234
6247
|
case 6:
|
6235
6248
|
case "end":
|
6236
6249
|
return _context40.stop();
|
@@ -6336,8 +6349,8 @@ var ko = /*#__PURE__*/function (_St3) {
|
|
6336
6349
|
}]);
|
6337
6350
|
return ko;
|
6338
6351
|
}(St);
|
6339
|
-
var Io = /*#__PURE__*/function (
|
6340
|
-
_inherits(Io,
|
6352
|
+
var Io = /*#__PURE__*/function (_Fe2) {
|
6353
|
+
_inherits(Io, _Fe2);
|
6341
6354
|
function Io(e) {
|
6342
6355
|
_classCallCheck(this, Io);
|
6343
6356
|
var n, r, o;
|
@@ -6374,9 +6387,9 @@ var Io = /*#__PURE__*/function (_Be2) {
|
|
6374
6387
|
}()
|
6375
6388
|
}]);
|
6376
6389
|
return Io;
|
6377
|
-
}(
|
6378
|
-
var Lo = /*#__PURE__*/function (
|
6379
|
-
_inherits(Lo,
|
6390
|
+
}(Fe);
|
6391
|
+
var Lo = /*#__PURE__*/function (_Fe3) {
|
6392
|
+
_inherits(Lo, _Fe3);
|
6380
6393
|
function Lo(e) {
|
6381
6394
|
var _this19;
|
6382
6395
|
_classCallCheck(this, Lo);
|
@@ -6429,9 +6442,9 @@ var Lo = /*#__PURE__*/function (_Be3) {
|
|
6429
6442
|
}()
|
6430
6443
|
}]);
|
6431
6444
|
return Lo;
|
6432
|
-
}(
|
6433
|
-
var Ro = /*#__PURE__*/function (
|
6434
|
-
_inherits(Ro,
|
6445
|
+
}(Fe);
|
6446
|
+
var Ro = /*#__PURE__*/function (_Fe4) {
|
6447
|
+
_inherits(Ro, _Fe4);
|
6435
6448
|
function Ro(e) {
|
6436
6449
|
_classCallCheck(this, Ro);
|
6437
6450
|
var n, r, o;
|
@@ -6468,9 +6481,9 @@ var Ro = /*#__PURE__*/function (_Be4) {
|
|
6468
6481
|
}()
|
6469
6482
|
}]);
|
6470
6483
|
return Ro;
|
6471
|
-
}(
|
6472
|
-
var No = /*#__PURE__*/function (
|
6473
|
-
_inherits(No,
|
6484
|
+
}(Fe);
|
6485
|
+
var No = /*#__PURE__*/function (_Fe5) {
|
6486
|
+
_inherits(No, _Fe5);
|
6474
6487
|
function No(e) {
|
6475
6488
|
var _this20$maxMessages;
|
6476
6489
|
var _this20;
|
@@ -6551,7 +6564,7 @@ var No = /*#__PURE__*/function (_Be5) {
|
|
6551
6564
|
}()
|
6552
6565
|
}]);
|
6553
6566
|
return No;
|
6554
|
-
}(
|
6567
|
+
}(Fe);
|
6555
6568
|
var Gt = /*#__PURE__*/function (_ri3) {
|
6556
6569
|
_inherits(Gt, _ri3);
|
6557
6570
|
function Gt(e) {
|
@@ -6603,7 +6616,7 @@ var Gt = /*#__PURE__*/function (_ri3) {
|
|
6603
6616
|
throw new Error("Image was not found");
|
6604
6617
|
case 4:
|
6605
6618
|
n = (a = (o = t[t.length - 1]) == null ? void 0 : o.text) == null ? void 0 : a.trim(), r = this.createFormDataBody(this.rawBody, i[0], n);
|
6606
|
-
|
6619
|
+
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, r, e), !1);
|
6607
6620
|
case 6:
|
6608
6621
|
case "end":
|
6609
6622
|
return _context47.stop();
|
@@ -6660,8 +6673,8 @@ var Gt = /*#__PURE__*/function (_ri3) {
|
|
6660
6673
|
}]);
|
6661
6674
|
return Gt;
|
6662
6675
|
}(ri);
|
6663
|
-
var Oo = /*#__PURE__*/function (
|
6664
|
-
_inherits(Oo,
|
6676
|
+
var Oo = /*#__PURE__*/function (_Fe6) {
|
6677
|
+
_inherits(Oo, _Fe6);
|
6665
6678
|
function Oo(e) {
|
6666
6679
|
_classCallCheck(this, Oo);
|
6667
6680
|
var n, r, o;
|
@@ -6698,7 +6711,7 @@ var Oo = /*#__PURE__*/function (_Be6) {
|
|
6698
6711
|
}()
|
6699
6712
|
}]);
|
6700
6713
|
return Oo;
|
6701
|
-
}(
|
6714
|
+
}(Fe);
|
6702
6715
|
var Vt = /*#__PURE__*/function (_ri4) {
|
6703
6716
|
_inherits(Vt, _ri4);
|
6704
6717
|
function Vt(e) {
|
@@ -6793,8 +6806,8 @@ var Vt = /*#__PURE__*/function (_ri4) {
|
|
6793
6806
|
}]);
|
6794
6807
|
return Vt;
|
6795
6808
|
}(ri);
|
6796
|
-
var Po = /*#__PURE__*/function (
|
6797
|
-
_inherits(Po,
|
6809
|
+
var Po = /*#__PURE__*/function (_Fe7) {
|
6810
|
+
_inherits(Po, _Fe7);
|
6798
6811
|
function Po(e) {
|
6799
6812
|
var _this23;
|
6800
6813
|
_classCallCheck(this, Po);
|
@@ -6833,7 +6846,7 @@ var Po = /*#__PURE__*/function (_Be7) {
|
|
6833
6846
|
}()
|
6834
6847
|
}]);
|
6835
6848
|
return Po;
|
6836
|
-
}(
|
6849
|
+
}(Fe);
|
6837
6850
|
var Wt = /*#__PURE__*/function () {
|
6838
6851
|
function Wt() {
|
6839
6852
|
_classCallCheck(this, Wt);
|
@@ -6869,8 +6882,8 @@ var Wt = /*#__PURE__*/function () {
|
|
6869
6882
|
}]);
|
6870
6883
|
return Wt;
|
6871
6884
|
}();
|
6872
|
-
var Xi = /*#__PURE__*/function (
|
6873
|
-
_inherits(Xi,
|
6885
|
+
var Xi = /*#__PURE__*/function (_q3) {
|
6886
|
+
_inherits(Xi, _q3);
|
6874
6887
|
function Xi(e, t, i, n, r) {
|
6875
6888
|
var _this24;
|
6876
6889
|
_classCallCheck(this, Xi);
|
@@ -6878,7 +6891,7 @@ var Xi = /*#__PURE__*/function (_U3) {
|
|
6878
6891
|
return _this24;
|
6879
6892
|
}
|
6880
6893
|
return _createClass(Xi);
|
6881
|
-
}(
|
6894
|
+
}(q);
|
6882
6895
|
var Do = /*#__PURE__*/function (_Xi) {
|
6883
6896
|
_inherits(Do, _Xi);
|
6884
6897
|
function Do(e) {
|
@@ -7072,8 +7085,8 @@ var N = /*#__PURE__*/function () {
|
|
7072
7085
|
n = _args57.length > 3 && _args57[3] !== undefined ? _args57[3] : !0;
|
7073
7086
|
e.requestSettings.method = i;
|
7074
7087
|
_context57.next = 4;
|
7075
|
-
return
|
7076
|
-
return
|
7088
|
+
return _.fetch(e, e.requestSettings.headers, n, t).then(function (o) {
|
7089
|
+
return _.processResponseByType(o);
|
7077
7090
|
});
|
7078
7091
|
case 4:
|
7079
7092
|
r = _context57.sent;
|
@@ -7098,8 +7111,8 @@ var N = /*#__PURE__*/function () {
|
|
7098
7111
|
}]);
|
7099
7112
|
return N;
|
7100
7113
|
}();
|
7101
|
-
var Qi = /*#__PURE__*/function (
|
7102
|
-
_inherits(zi,
|
7114
|
+
var Qi = /*#__PURE__*/function (_q4) {
|
7115
|
+
_inherits(zi, _q4);
|
7103
7116
|
function zi(e) {
|
7104
7117
|
var _o$model, _a$voice;
|
7105
7118
|
var _this25;
|
@@ -7193,12 +7206,12 @@ var Qi = /*#__PURE__*/function (_U4) {
|
|
7193
7206
|
}()
|
7194
7207
|
}]);
|
7195
7208
|
return zi;
|
7196
|
-
}(
|
7209
|
+
}(q);
|
7197
7210
|
Qi.DEFAULT_MODEL = "tts-1";
|
7198
7211
|
Qi.DEFAULT_VOIDE = "alloy";
|
7199
7212
|
var Bo = Qi;
|
7200
|
-
var oi = /*#__PURE__*/function (
|
7201
|
-
_inherits(we,
|
7213
|
+
var oi = /*#__PURE__*/function (_q5) {
|
7214
|
+
_inherits(we, _q5);
|
7202
7215
|
function we(e) {
|
7203
7216
|
var _o$model2;
|
7204
7217
|
var _this26;
|
@@ -7249,7 +7262,7 @@ var oi = /*#__PURE__*/function (_U5) {
|
|
7249
7262
|
case 4:
|
7250
7263
|
this.url = this.requestSettings.url || this._service_url;
|
7251
7264
|
n = this.preprocessBody(this.rawBody, t), r = we.createFormDataBody(n, i[0]);
|
7252
|
-
|
7265
|
+
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, r, e), !1);
|
7253
7266
|
case 7:
|
7254
7267
|
case "end":
|
7255
7268
|
return _context60.stop();
|
@@ -7308,7 +7321,7 @@ var oi = /*#__PURE__*/function (_U5) {
|
|
7308
7321
|
}
|
7309
7322
|
}]);
|
7310
7323
|
return we;
|
7311
|
-
}(
|
7324
|
+
}(q);
|
7312
7325
|
oi.AUDIO_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions";
|
7313
7326
|
oi.AUDIO_TRANSLATIONS_URL = "https://api.openai.com/v1/audio/translations";
|
7314
7327
|
oi.DEFAULT_MODEL = "whisper-1";
|
@@ -7415,8 +7428,8 @@ var X = /*#__PURE__*/function () {
|
|
7415
7428
|
}]);
|
7416
7429
|
return X;
|
7417
7430
|
}();
|
7418
|
-
var zo = /*#__PURE__*/function (
|
7419
|
-
_inherits(zo,
|
7431
|
+
var zo = /*#__PURE__*/function (_q6) {
|
7432
|
+
_inherits(zo, _q6);
|
7420
7433
|
// prettier-ignore
|
7421
7434
|
function zo(e, t, i, n, r) {
|
7422
7435
|
var _this27;
|
@@ -7427,7 +7440,7 @@ var zo = /*#__PURE__*/function (_U6) {
|
|
7427
7440
|
return _this27;
|
7428
7441
|
}
|
7429
7442
|
return _createClass(zo);
|
7430
|
-
}(
|
7443
|
+
}(q);
|
7431
7444
|
var Uo = /*#__PURE__*/function (_zo) {
|
7432
7445
|
_inherits(Uo, _zo);
|
7433
7446
|
function Uo(e) {
|
@@ -7688,8 +7701,8 @@ var ut = /*#__PURE__*/function () {
|
|
7688
7701
|
}]);
|
7689
7702
|
return ut;
|
7690
7703
|
}();
|
7691
|
-
var en = /*#__PURE__*/function (
|
7692
|
-
_inherits(en,
|
7704
|
+
var en = /*#__PURE__*/function (_q7) {
|
7705
|
+
_inherits(en, _q7);
|
7693
7706
|
function en(e) {
|
7694
7707
|
var _this29;
|
7695
7708
|
_classCallCheck(this, en);
|
@@ -7772,9 +7785,9 @@ var en = /*#__PURE__*/function (_U7) {
|
|
7772
7785
|
}
|
7773
7786
|
}]);
|
7774
7787
|
return en;
|
7775
|
-
}(
|
7776
|
-
var hs = /*#__PURE__*/function (
|
7777
|
-
_inherits(hs,
|
7788
|
+
}(q);
|
7789
|
+
var hs = /*#__PURE__*/function (_q8) {
|
7790
|
+
_inherits(hs, _q8);
|
7778
7791
|
// prettier-ignore
|
7779
7792
|
function hs(e, t, i, n, r) {
|
7780
7793
|
var _this30;
|
@@ -7785,7 +7798,7 @@ var hs = /*#__PURE__*/function (_U8) {
|
|
7785
7798
|
return _this30;
|
7786
7799
|
}
|
7787
7800
|
return _createClass(hs);
|
7788
|
-
}(
|
7801
|
+
}(q);
|
7789
7802
|
var ps = /*#__PURE__*/function (_hs) {
|
7790
7803
|
_inherits(fs, _hs);
|
7791
7804
|
// prettier-ignore
|
@@ -7959,8 +7972,8 @@ ms.HELP_LINK =
|
|
7959
7972
|
// eslint-disable-next-line max-len
|
7960
7973
|
"https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest";
|
7961
7974
|
var Ho = ms;
|
7962
|
-
var Go = /*#__PURE__*/function (
|
7963
|
-
_inherits(Go,
|
7975
|
+
var Go = /*#__PURE__*/function (_q9) {
|
7976
|
+
_inherits(Go, _q9);
|
7964
7977
|
// prettier-ignore
|
7965
7978
|
function Go(e) {
|
7966
7979
|
var _this33;
|
@@ -8038,7 +8051,7 @@ var Go = /*#__PURE__*/function (_U9) {
|
|
8038
8051
|
}()
|
8039
8052
|
}]);
|
8040
8053
|
return Go;
|
8041
|
-
}(
|
8054
|
+
}(q);
|
8042
8055
|
var ge = /*#__PURE__*/function () {
|
8043
8056
|
function ge() {
|
8044
8057
|
_classCallCheck(this, ge);
|
@@ -8059,8 +8072,8 @@ var ge = /*#__PURE__*/function () {
|
|
8059
8072
|
return _context75.abrupt("return");
|
8060
8073
|
case 3:
|
8061
8074
|
e.url = "https://api.openai.com/v1/files";
|
8062
|
-
r = n[
|
8063
|
-
delete n[
|
8075
|
+
r = n[_.CONTENT_TYPE];
|
8076
|
+
delete n[_.CONTENT_TYPE];
|
8064
8077
|
o = i.map( /*#__PURE__*/function () {
|
8065
8078
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(a) {
|
8066
8079
|
var l;
|
@@ -8088,11 +8101,11 @@ var ge = /*#__PURE__*/function () {
|
|
8088
8101
|
a = _context75.sent.map(function (l) {
|
8089
8102
|
return l.id;
|
8090
8103
|
});
|
8091
|
-
return _context75.abrupt("return", (n[
|
8104
|
+
return _context75.abrupt("return", (n[_.CONTENT_TYPE] = r, a));
|
8092
8105
|
case 14:
|
8093
8106
|
_context75.prev = 14;
|
8094
8107
|
_context75.t0 = _context75["catch"](7);
|
8095
|
-
throw n[
|
8108
|
+
throw n[_.CONTENT_TYPE] = r, _.displayError(t, _context75.t0), e.completionsHandlers.onFinish(), _context75.t0;
|
8096
8109
|
case 17:
|
8097
8110
|
case "end":
|
8098
8111
|
return _context75.stop();
|
@@ -8245,8 +8258,8 @@ var ge = /*#__PURE__*/function () {
|
|
8245
8258
|
}]);
|
8246
8259
|
return ge;
|
8247
8260
|
}();
|
8248
|
-
var ai = /*#__PURE__*/function (
|
8249
|
-
_inherits(se,
|
8261
|
+
var ai = /*#__PURE__*/function (_q10) {
|
8262
|
+
_inherits(se, _q10);
|
8250
8263
|
function se(e) {
|
8251
8264
|
var _c$headers, _d$OpenAIBeta;
|
8252
8265
|
var _this34;
|
@@ -8472,7 +8485,7 @@ var ai = /*#__PURE__*/function (_U10) {
|
|
8472
8485
|
key: "extractPollResultData",
|
8473
8486
|
value: function () {
|
8474
8487
|
var _extractPollResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(e) {
|
8475
|
-
var r, o, a, l, c, t, i, d, u,
|
8488
|
+
var r, o, a, l, c, t, i, d, u, h, _yield$ge$getFilesAnd, p, g, n, _d;
|
8476
8489
|
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
8477
8490
|
while (1) switch (_context83.prev = _context83.next) {
|
8478
8491
|
case 0:
|
@@ -8505,17 +8518,17 @@ var ai = /*#__PURE__*/function (_U10) {
|
|
8505
8518
|
d = _context83.sent;
|
8506
8519
|
case 13:
|
8507
8520
|
u = d.data[0];
|
8508
|
-
|
8521
|
+
h = u.content.find(function (f) {
|
8509
8522
|
return !!f.text || !!f.image_file;
|
8510
8523
|
});
|
8511
8524
|
_context83.next = 17;
|
8512
|
-
return ge.getFilesAndText(this, u,
|
8525
|
+
return ge.getFilesAndText(this, u, h);
|
8513
8526
|
case 17:
|
8514
8527
|
_yield$ge$getFilesAnd = _context83.sent;
|
8515
|
-
|
8528
|
+
p = _yield$ge$getFilesAnd.text;
|
8516
8529
|
g = _yield$ge$getFilesAnd.files;
|
8517
8530
|
return _context83.abrupt("return", {
|
8518
|
-
text:
|
8531
|
+
text: p,
|
8519
8532
|
_sessionId: this.sessionId,
|
8520
8533
|
files: g
|
8521
8534
|
});
|
@@ -8613,13 +8626,13 @@ var ai = /*#__PURE__*/function (_U10) {
|
|
8613
8626
|
}()
|
8614
8627
|
}]);
|
8615
8628
|
return se;
|
8616
|
-
}(
|
8629
|
+
}(q);
|
8617
8630
|
ai.THREAD_PREFIX = "https://api.openai.com/v1/threads";
|
8618
8631
|
ai.NEW_ASSISTANT_URL = "https://api.openai.com/v1/assistants";
|
8619
8632
|
ai.POLLING_TIMEOUT_MS = 800;
|
8620
8633
|
var Vo = ai;
|
8621
|
-
var li = /*#__PURE__*/function (
|
8622
|
-
_inherits(Me,
|
8634
|
+
var li = /*#__PURE__*/function (_q11) {
|
8635
|
+
_inherits(Me, _q11);
|
8623
8636
|
function Me(e) {
|
8624
8637
|
var _this35;
|
8625
8638
|
_classCallCheck(this, Me);
|
@@ -8666,7 +8679,7 @@ var li = /*#__PURE__*/function (_U11) {
|
|
8666
8679
|
var l = this.preprocessBody(this.rawBody, r);
|
8667
8680
|
n = Me.createFormDataBody(l, i[0], i[1]);
|
8668
8681
|
} else this.url = Me.IMAGE_VARIATIONS_URL, n = Me.createFormDataBody(this.rawBody, i[0]);
|
8669
|
-
|
8682
|
+
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, n, e), !1);
|
8670
8683
|
}
|
8671
8684
|
}, {
|
8672
8685
|
key: "callServiceAPI",
|
@@ -8768,13 +8781,13 @@ var li = /*#__PURE__*/function (_U11) {
|
|
8768
8781
|
}
|
8769
8782
|
}]);
|
8770
8783
|
return Me;
|
8771
|
-
}(
|
8784
|
+
}(q);
|
8772
8785
|
li.IMAGE_GENERATION_URL = "https://api.openai.com/v1/images/generations";
|
8773
8786
|
li.IMAGE_VARIATIONS_URL = "https://api.openai.com/v1/images/variations";
|
8774
8787
|
li.IMAGE_EDIT_URL = "https://api.openai.com/v1/images/edits";
|
8775
8788
|
var Wo = li;
|
8776
|
-
var ht = /*#__PURE__*/function (
|
8777
|
-
_inherits(ht,
|
8789
|
+
var ht = /*#__PURE__*/function (_q12) {
|
8790
|
+
_inherits(ht, _q12);
|
8778
8791
|
function ht(e) {
|
8779
8792
|
var _this36$maxMessages, _l$model;
|
8780
8793
|
var _this36;
|
@@ -8846,7 +8859,6 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
8846
8859
|
key: "extractResultData",
|
8847
8860
|
value: function () {
|
8848
8861
|
var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(e, t, i) {
|
8849
|
-
var n, r, o;
|
8850
8862
|
return _regeneratorRuntime().wrap(function _callee88$(_context88) {
|
8851
8863
|
while (1) switch (_context88.prev = _context88.next) {
|
8852
8864
|
case 0:
|
@@ -8856,46 +8868,14 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
8856
8868
|
}
|
8857
8869
|
throw e.error.message;
|
8858
8870
|
case 2:
|
8859
|
-
|
8860
|
-
_context88.next = 4;
|
8861
|
-
break;
|
8862
|
-
}
|
8863
|
-
return _context88.abrupt("return", {
|
8871
|
+
return _context88.abrupt("return", e.choices[0].delta ? {
|
8864
8872
|
text: e.choices[0].delta.content || ""
|
8865
|
-
})
|
8866
|
-
case 4:
|
8867
|
-
if (!e.choices[0].message) {
|
8868
|
-
_context88.next = 16;
|
8869
|
-
break;
|
8870
|
-
}
|
8871
|
-
if (!e.choices[0].message.tool_calls) {
|
8872
|
-
_context88.next = 15;
|
8873
|
-
break;
|
8874
|
-
}
|
8875
|
-
_context88.next = 8;
|
8876
|
-
return this.handleTools(e.choices[0].message, t, i);
|
8877
|
-
case 8:
|
8878
|
-
o = _context88.sent;
|
8879
|
-
_context88.next = 11;
|
8880
|
-
return (r = (n = this.deepChat).responseInterceptor) == null ? void 0 : r.call(n, o);
|
8881
|
-
case 11:
|
8882
|
-
_context88.t0 = _context88.sent;
|
8883
|
-
if (_context88.t0) {
|
8884
|
-
_context88.next = 14;
|
8885
|
-
break;
|
8886
|
-
}
|
8887
|
-
_context88.t0 = o;
|
8888
|
-
case 14:
|
8889
|
-
return _context88.abrupt("return", _context88.t0);
|
8890
|
-
case 15:
|
8891
|
-
return _context88.abrupt("return", {
|
8873
|
+
} : e.choices[0].message ? e.choices[0].message.tool_calls ? this.handleTools(e.choices[0].message, t, i) : {
|
8892
8874
|
text: e.choices[0].message.content
|
8893
|
-
}
|
8894
|
-
case 16:
|
8895
|
-
return _context88.abrupt("return", {
|
8875
|
+
} : {
|
8896
8876
|
text: ""
|
8897
8877
|
});
|
8898
|
-
case
|
8878
|
+
case 3:
|
8899
8879
|
case "end":
|
8900
8880
|
return _context88.stop();
|
8901
8881
|
}
|
@@ -8910,7 +8890,7 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
8910
8890
|
key: "handleTools",
|
8911
8891
|
value: function () {
|
8912
8892
|
var _handleTools2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89(e, t, i) {
|
8913
|
-
var a, n, r, o,
|
8893
|
+
var a, l, c, d, u, n, r, o, h, _h;
|
8914
8894
|
return _regeneratorRuntime().wrap(function _callee89$(_context89) {
|
8915
8895
|
while (1) switch (_context89.prev = _context89.next) {
|
8916
8896
|
case 0:
|
@@ -8921,10 +8901,10 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
8921
8901
|
throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Chat) object.");
|
8922
8902
|
case 2:
|
8923
8903
|
n = JSON.parse(JSON.stringify(i));
|
8924
|
-
r = e.tool_calls.map(function (
|
8904
|
+
r = e.tool_calls.map(function (h) {
|
8925
8905
|
return {
|
8926
|
-
name:
|
8927
|
-
arguments:
|
8906
|
+
name: h["function"].name,
|
8907
|
+
arguments: h["function"].arguments
|
8928
8908
|
};
|
8929
8909
|
});
|
8930
8910
|
_context89.next = 6;
|
@@ -8932,47 +8912,69 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
8932
8912
|
case 6:
|
8933
8913
|
o = _context89.sent;
|
8934
8914
|
if (!o.text) {
|
8935
|
-
_context89.next =
|
8915
|
+
_context89.next = 15;
|
8936
8916
|
break;
|
8937
8917
|
}
|
8938
|
-
|
8918
|
+
h = {
|
8939
8919
|
text: o.text
|
8940
|
-
}
|
8941
|
-
|
8942
|
-
|
8943
|
-
|
8920
|
+
};
|
8921
|
+
_context89.next = 11;
|
8922
|
+
return (c = (l = this.deepChat).responseInterceptor) == null ? void 0 : c.call(l, h);
|
8923
|
+
case 11:
|
8924
|
+
_context89.t0 = _context89.sent;
|
8925
|
+
if (_context89.t0) {
|
8926
|
+
_context89.next = 14;
|
8927
|
+
break;
|
8928
|
+
}
|
8929
|
+
_context89.t0 = h;
|
8930
|
+
case 14:
|
8931
|
+
return _context89.abrupt("return", _context89.t0);
|
8932
|
+
case 15:
|
8933
|
+
if (!(n.messages.push(e), Array.isArray(o) && !o.find(function (h) {
|
8934
|
+
return typeof h != "string";
|
8944
8935
|
}) || r.length === o.length)) {
|
8945
|
-
_context89.next =
|
8936
|
+
_context89.next = 29;
|
8946
8937
|
break;
|
8947
8938
|
}
|
8948
|
-
o.forEach(function (
|
8949
|
-
var
|
8950
|
-
var
|
8939
|
+
o.forEach(function (p, g) {
|
8940
|
+
var E;
|
8941
|
+
var f = (E = e.tool_calls) == null ? void 0 : E[g];
|
8951
8942
|
n == null || n.messages.push({
|
8952
8943
|
role: "tool",
|
8953
|
-
tool_call_id:
|
8954
|
-
name:
|
8955
|
-
content:
|
8944
|
+
tool_call_id: f == null ? void 0 : f.id,
|
8945
|
+
name: f == null ? void 0 : f["function"].name,
|
8946
|
+
content: p.response
|
8956
8947
|
});
|
8957
8948
|
}), delete n.tools, delete n.tool_choice;
|
8958
|
-
_context89.next =
|
8959
|
-
return t == null ? void 0 : t(n).then(function (
|
8960
|
-
return
|
8949
|
+
_context89.next = 19;
|
8950
|
+
return t == null ? void 0 : t(n).then(function (p) {
|
8951
|
+
return _.processResponseByType(p);
|
8961
8952
|
});
|
8962
|
-
case
|
8963
|
-
|
8964
|
-
|
8965
|
-
|
8953
|
+
case 19:
|
8954
|
+
_h = _context89.sent;
|
8955
|
+
_context89.next = 22;
|
8956
|
+
return (u = (d = this.deepChat).responseInterceptor) == null ? void 0 : u.call(d, _h);
|
8957
|
+
case 22:
|
8958
|
+
_context89.t1 = _context89.sent;
|
8959
|
+
if (_context89.t1) {
|
8960
|
+
_context89.next = 25;
|
8966
8961
|
break;
|
8967
8962
|
}
|
8968
|
-
|
8969
|
-
case
|
8963
|
+
_context89.t1 = _h;
|
8964
|
+
case 25:
|
8965
|
+
_h = _context89.t1;
|
8966
|
+
if (!_h.error) {
|
8967
|
+
_context89.next = 28;
|
8968
|
+
break;
|
8969
|
+
}
|
8970
|
+
throw _h.error.message;
|
8971
|
+
case 28:
|
8970
8972
|
return _context89.abrupt("return", {
|
8971
|
-
text:
|
8973
|
+
text: _h.choices[0].message.content || ""
|
8972
8974
|
});
|
8973
|
-
case
|
8975
|
+
case 29:
|
8974
8976
|
throw Error("Response object must either be {response: string}[] for each individual function or {text: string} for a direct response, see https://deepchat.dev/docs/directConnection/OpenAI#FunctionHandler.");
|
8975
|
-
case
|
8977
|
+
case 30:
|
8976
8978
|
case "end":
|
8977
8979
|
return _context89.stop();
|
8978
8980
|
}
|
@@ -9012,7 +9014,7 @@ var ht = /*#__PURE__*/function (_U12) {
|
|
9012
9014
|
}
|
9013
9015
|
}]);
|
9014
9016
|
return ht;
|
9015
|
-
}(
|
9017
|
+
}(q);
|
9016
9018
|
var Jo = /*#__PURE__*/function (_Xi3) {
|
9017
9019
|
_inherits(Jo, _Xi3);
|
9018
9020
|
function Jo(e) {
|
@@ -9124,7 +9126,7 @@ var $o = /*#__PURE__*/function () {
|
|
9124
9126
|
}
|
9125
9127
|
if (t.stabilityAI) return t.stabilityAI.imageToImage ? new Gt(e) : t.stabilityAI.imageToImageUpscale ? new qt(e) : t.stabilityAI.imageToImageMasking ? new Ht(e) : new Vt(e);
|
9126
9128
|
}
|
9127
|
-
return i ? new
|
9129
|
+
return i ? new Pe(e) : new Pe(e, void 0, n || !0);
|
9128
9130
|
}
|
9129
9131
|
}]);
|
9130
9132
|
return $o;
|
@@ -9312,7 +9314,7 @@ var fe = /*#__PURE__*/function () {
|
|
9312
9314
|
t.classList.add("any-file-message-contents");
|
9313
9315
|
var i = document.createElement("div");
|
9314
9316
|
i.classList.add("any-file-message-icon-container");
|
9315
|
-
var n =
|
9317
|
+
var n = G.createSVGElement(Zo);
|
9316
9318
|
n.classList.add("any-file-message-icon"), i.appendChild(n);
|
9317
9319
|
var r = document.createElement("div");
|
9318
9320
|
return r.classList.add("any-file-message-text"), r.textContent = e.name || re.DEFAULT_FILE_NAME, t.appendChild(i), t.appendChild(r), re.processContent("any", t, e.src, r.textContent);
|
@@ -9336,8 +9338,8 @@ var fe = /*#__PURE__*/function () {
|
|
9336
9338
|
}]);
|
9337
9339
|
return fe;
|
9338
9340
|
}();
|
9339
|
-
var me = /*#__PURE__*/function (
|
9340
|
-
_inherits(me,
|
9341
|
+
var me = /*#__PURE__*/function (_Ye) {
|
9342
|
+
_inherits(me, _Ye);
|
9341
9343
|
function me(e, t, i) {
|
9342
9344
|
var _this38;
|
9343
9345
|
_classCallCheck(this, me);
|
@@ -9382,7 +9384,7 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9382
9384
|
var i = this._introMessage;
|
9383
9385
|
if (t != null && t.isWebModel() && ((_i12 = i) !== null && _i12 !== void 0 ? _i12 : i = t.getIntroMessage(i)), i) {
|
9384
9386
|
var r;
|
9385
|
-
i != null && i.text ? r = this.createAndAppendNewMessageElement(i.text, b.AI_ROLE) : i != null && i.html && (r =
|
9387
|
+
i != null && i.text ? r = this.createAndAppendNewMessageElement(i.text, b.AI_ROLE) : i != null && i.html && (r = Qe.add(this, i.html, b.AI_ROLE, this.messageElementRefs)), r && (this.applyCustomStyles(r, b.AI_ROLE, !1, (n = this.messageStyles) == null ? void 0 : n.intro), r.outerContainer.classList.add("deep-chat-intro"));
|
9386
9388
|
}
|
9387
9389
|
}
|
9388
9390
|
}, {
|
@@ -9411,7 +9413,7 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9411
9413
|
status: e.overwrite
|
9412
9414
|
};
|
9413
9415
|
if (!e.ignoreText && i.text !== void 0 && e.text !== null && (this.addNewTextMessage(i.text, i.role, n), !t && this.textToSpeech && i.role !== b.USER_ROLE && jt.speak(i.text, this.textToSpeech)), i.files && Array.isArray(i.files) && fe.addMessages(this, i.files, i.role), i.html !== void 0 && i.html !== null) {
|
9414
|
-
var r =
|
9416
|
+
var r = Qe.add(this, i.html, i.role, this.messageElementRefs, n);
|
9415
9417
|
ve.isElementTemporary(r) && delete i.html;
|
9416
9418
|
}
|
9417
9419
|
this.isValidMessageContent(i) && this.updateStateOnMessage(i, e.overwrite, e.sendUpdate, t);
|
@@ -9434,13 +9436,13 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9434
9436
|
value: function removeMessageOnError() {
|
9435
9437
|
var e = this.messageElementRefs[this.messageElementRefs.length - 1],
|
9436
9438
|
t = e == null ? void 0 : e.bubbleElement;
|
9437
|
-
(t != null && t.classList.contains(
|
9439
|
+
(t != null && t.classList.contains(Oe.MESSAGE_CLASS) && t.textContent === "" || me.isTemporaryElement(e)) && this.removeLastMessage();
|
9438
9440
|
}
|
9439
9441
|
// prettier-ignore
|
9440
9442
|
}, {
|
9441
9443
|
key: "addNewErrorMessage",
|
9442
9444
|
value: function addNewErrorMessage(e, t) {
|
9443
|
-
var l, c, d, u,
|
9445
|
+
var l, c, d, u, h;
|
9444
9446
|
this.removeMessageOnError();
|
9445
9447
|
var i = me.createBaseElements(),
|
9446
9448
|
n = i.outerContainer,
|
@@ -9449,7 +9451,7 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9449
9451
|
var o = this.getPermittedMessage(t) || ((l = this._errorMessageOverrides) == null ? void 0 : l[e]) || ((c = this._errorMessageOverrides) == null ? void 0 : c["default"]) || "Error, please try again.";
|
9450
9452
|
this.renderText(r, o);
|
9451
9453
|
var a = D.extractParticularSharedStyles(["fontSize", "fontFamily"], (d = this.messageStyles) == null ? void 0 : d["default"]);
|
9452
|
-
D.applyCustomStylesToElements(i, !1, a), D.applyCustomStylesToElements(i, !1, (u = this.messageStyles) == null ? void 0 : u.error), this.elementRef.appendChild(n), Z.scrollToBottom(this.elementRef), this.textToSpeech && jt.speak(o, this.textToSpeech), (
|
9454
|
+
D.applyCustomStylesToElements(i, !1, a), D.applyCustomStylesToElements(i, !1, (u = this.messageStyles) == null ? void 0 : u.error), this.elementRef.appendChild(n), Z.scrollToBottom(this.elementRef), this.textToSpeech && jt.speak(o, this.textToSpeech), (h = this._onError) == null || h.call(this, o);
|
9453
9455
|
}
|
9454
9456
|
}, {
|
9455
9457
|
key: "getPermittedMessage",
|
@@ -9533,7 +9535,7 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9533
9535
|
var i = [];
|
9534
9536
|
this.messageElementRefs.forEach(function (o) {
|
9535
9537
|
var a = o.bubbleElement.classList;
|
9536
|
-
a.contains("loading-message-text") || a.contains(
|
9538
|
+
a.contains("loading-message-text") || a.contains(Oe.MESSAGE_CLASS) ? i.push(o) : o.outerContainer.remove();
|
9537
9539
|
}), Array.from(this.elementRef.children).forEach(function (o) {
|
9538
9540
|
var l;
|
9539
9541
|
var a = (l = o.children[0]) == null ? void 0 : l.children[0];
|
@@ -9553,12 +9555,12 @@ var me = /*#__PURE__*/function (_Ke) {
|
|
9553
9555
|
}
|
9554
9556
|
}]);
|
9555
9557
|
return me;
|
9556
|
-
}(
|
9558
|
+
}(Ye);
|
9557
9559
|
var Mt = /*#__PURE__*/function () {
|
9558
|
-
function
|
9559
|
-
_classCallCheck(this,
|
9560
|
+
function $() {
|
9561
|
+
_classCallCheck(this, $);
|
9560
9562
|
}
|
9561
|
-
_createClass(
|
9563
|
+
_createClass($, null, [{
|
9562
9564
|
key: "adjustInputPadding",
|
9563
9565
|
value: function adjustInputPadding(e, t) {
|
9564
9566
|
t["inside-left"].length > 0 && e.classList.add("text-input-inner-left-adjustment"), t["inside-right"].length > 0 && e.classList.add("text-input-inner-right-adjustment");
|
@@ -9566,7 +9568,7 @@ var Mt = /*#__PURE__*/function () {
|
|
9566
9568
|
}, {
|
9567
9569
|
key: "adjustForOutsideButton",
|
9568
9570
|
value: function adjustForOutsideButton(e, t, i) {
|
9569
|
-
i["outside-right"].length === 0 && i["outside-left"].length > 0 ? (e[0].classList.add(
|
9571
|
+
i["outside-right"].length === 0 && i["outside-left"].length > 0 ? (e[0].classList.add($.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS), t.classList.add($.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS)) : i["outside-left"].length === 0 && i["outside-right"].length > 0 && (e[3].classList.add($.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS), t.classList.add($.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS));
|
9570
9572
|
}
|
9571
9573
|
// when submit is the only button
|
9572
9574
|
// when submit button is outside by itself - we increase the height for a better look
|
@@ -9574,10 +9576,10 @@ var Mt = /*#__PURE__*/function () {
|
|
9574
9576
|
key: "adjustOutsideSubmit",
|
9575
9577
|
value: function adjustOutsideSubmit(e, t, i) {
|
9576
9578
|
if (!(i["inside-left"].length > 0 || i["inside-right"].length > 0)) {
|
9577
|
-
if (i["outside-right"].length === 0 && i["outside-left"].length > 0) return e[0].classList.add(
|
9579
|
+
if (i["outside-right"].length === 0 && i["outside-left"].length > 0) return e[0].classList.add($.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS), t.classList.add($.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS), i["outside-left"].map(function (n) {
|
9578
9580
|
return n.button.elementRef.classList.add("submit-button-enlarged");
|
9579
9581
|
});
|
9580
|
-
if (i["outside-left"].length === 0 && i["outside-right"].length > 0) return e[3].classList.add(
|
9582
|
+
if (i["outside-left"].length === 0 && i["outside-right"].length > 0) return e[3].classList.add($.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS), t.classList.add($.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS), i["outside-right"].map(function (n) {
|
9581
9583
|
return n.button.elementRef.classList.add("submit-button-enlarged");
|
9582
9584
|
});
|
9583
9585
|
}
|
@@ -9585,10 +9587,10 @@ var Mt = /*#__PURE__*/function () {
|
|
9585
9587
|
}, {
|
9586
9588
|
key: "set",
|
9587
9589
|
value: function set(e, t, i, n) {
|
9588
|
-
|
9590
|
+
!!$.adjustOutsideSubmit(t, i, n) || $.adjustForOutsideButton(t, i, n), $.adjustInputPadding(e, n);
|
9589
9591
|
}
|
9590
9592
|
}]);
|
9591
|
-
return
|
9593
|
+
return $;
|
9592
9594
|
}();
|
9593
9595
|
Mt.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS = "text-input-container-left-adjustment";
|
9594
9596
|
Mt.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS = "text-input-container-right-adjustment";
|
@@ -9643,7 +9645,7 @@ var j = /*#__PURE__*/function () {
|
|
9643
9645
|
}, {
|
9644
9646
|
key: "createElement",
|
9645
9647
|
value: function createElement(e, t) {
|
9646
|
-
return t ? j.createTextElement(e) :
|
9648
|
+
return t ? j.createTextElement(e) : G.createSVGElement(e);
|
9647
9649
|
}
|
9648
9650
|
}, {
|
9649
9651
|
key: "createCustomElement",
|
@@ -9899,24 +9901,24 @@ var nn = /*#__PURE__*/function () {
|
|
9899
9901
|
}]);
|
9900
9902
|
return nn;
|
9901
9903
|
}();
|
9902
|
-
var
|
9903
|
-
_inherits(
|
9904
|
-
function
|
9904
|
+
var Ze = /*#__PURE__*/function (_Tt) {
|
9905
|
+
_inherits(Ze, _Tt);
|
9906
|
+
function Ze(e, t) {
|
9905
9907
|
var _this41;
|
9906
|
-
_classCallCheck(this,
|
9908
|
+
_classCallCheck(this, Ze);
|
9907
9909
|
var n;
|
9908
|
-
_this41 = _callSuper(this,
|
9910
|
+
_this41 = _callSuper(this, Ze, [Ze.createButtonElement(), void 0, {
|
9909
9911
|
styles: (n = t == null ? void 0 : t.button) == null ? void 0 : n.styles
|
9910
9912
|
}]);
|
9911
9913
|
var i = _this41.createInnerElements(_this41._customStyles);
|
9912
|
-
_this41._menu = new nn(e, t == null ? void 0 : t.menu), _this41.addClickEvent(), _this41.buttonContainer =
|
9914
|
+
_this41._menu = new nn(e, t == null ? void 0 : t.menu), _this41.addClickEvent(), _this41.buttonContainer = Ze.createButtonContainer(), _this41.elementRef.appendChild(i.styles), _this41.buttonContainer.appendChild(_this41.elementRef), _this41.elementRef.classList.add("dropup-icon", "upload-file-button"), _this41.elementRef.children[0].id = "dropup-icon", _this41.buttonContainer.appendChild(_this41._menu.elementRef), _this41.reapplyStateStyle("styles"), _this41.addContainerEvents(e);
|
9913
9915
|
return _this41;
|
9914
9916
|
}
|
9915
|
-
_createClass(
|
9917
|
+
_createClass(Ze, [{
|
9916
9918
|
key: "createInnerElements",
|
9917
9919
|
value: function createInnerElements(e) {
|
9918
9920
|
return {
|
9919
|
-
styles: this.createInnerElement(
|
9921
|
+
styles: this.createInnerElement(Ze.createSVGIconElement(), "styles", e)
|
9920
9922
|
};
|
9921
9923
|
}
|
9922
9924
|
}, {
|
@@ -9951,7 +9953,7 @@ var Ye = /*#__PURE__*/function (_Tt) {
|
|
9951
9953
|
}, {
|
9952
9954
|
key: "createSVGIconElement",
|
9953
9955
|
value: function createSVGIconElement() {
|
9954
|
-
return
|
9956
|
+
return G.createSVGElement(Qo);
|
9955
9957
|
}
|
9956
9958
|
}, {
|
9957
9959
|
key: "createButtonContainer",
|
@@ -9966,7 +9968,7 @@ var Ye = /*#__PURE__*/function (_Tt) {
|
|
9966
9968
|
return (i = t == null ? void 0 : t.button) != null && i.position ? (n = t == null ? void 0 : t.button) == null ? void 0 : n.position : e["outside-left"].length > 0 && e["outside-right"].length === 0 ? "outside-right" : "outside-left";
|
9967
9969
|
}
|
9968
9970
|
}]);
|
9969
|
-
return
|
9971
|
+
return Ze;
|
9970
9972
|
}(Tt);
|
9971
9973
|
var B = /*#__PURE__*/function () {
|
9972
9974
|
function B() {
|
@@ -9977,7 +9979,7 @@ var B = /*#__PURE__*/function () {
|
|
9977
9979
|
value:
|
9978
9980
|
// prettier-ignore
|
9979
9981
|
function addToDropup(e, t, i, n) {
|
9980
|
-
var r = new
|
9982
|
+
var r = new Ze(i, n);
|
9981
9983
|
Mn.forEach(function (a) {
|
9982
9984
|
var l = t["dropup-menu"].findIndex(function (d) {
|
9983
9985
|
return d.buttonType === a;
|
@@ -9985,7 +9987,7 @@ var B = /*#__PURE__*/function () {
|
|
9985
9987
|
c = t["dropup-menu"][l];
|
9986
9988
|
c && (r.addItem(c.button), t["dropup-menu"].splice(l, 1));
|
9987
9989
|
});
|
9988
|
-
var o =
|
9990
|
+
var o = Ze.getPosition(t, n);
|
9989
9991
|
tt.addButton(e, r.buttonContainer, o), t[o].push({});
|
9990
9992
|
}
|
9991
9993
|
}, {
|
@@ -10235,7 +10237,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10235
10237
|
i.classList.add("audio-placeholder-text-3-digits");
|
10236
10238
|
var n = document.createElement("div");
|
10237
10239
|
n.classList.add("file-attachment-text-container", "audio-placeholder-text-3-digits-container"), n.appendChild(i);
|
10238
|
-
var r =
|
10240
|
+
var r = G.createSVGElement(Tn);
|
10239
10241
|
return r.classList.add("attachment-icon", "stop-icon", "not-removable-attachment-icon"), i.textContent = "0:00", this._activePlaceholderTimer = this.createTimer(i, e), t.appendChild(n), this.addPlaceholderAudioAttachmentEvents(t, r, n), t;
|
10240
10242
|
}
|
10241
10243
|
}, {
|
@@ -10291,9 +10293,9 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10291
10293
|
var i = e.parentElement ? Z.cloneElement(e) : e,
|
10292
10294
|
n = document.createElement("audio");
|
10293
10295
|
n.src = t;
|
10294
|
-
var r =
|
10296
|
+
var r = G.createSVGElement(ra);
|
10295
10297
|
r.classList.add("attachment-icon", "play-icon");
|
10296
|
-
var o =
|
10298
|
+
var o = G.createSVGElement(Tn);
|
10297
10299
|
o.classList.add("attachment-icon", "stop-icon"), i.replaceChildren(r), n.onplay = function () {
|
10298
10300
|
i.replaceChildren(o);
|
10299
10301
|
}, n.onpause = function () {
|
@@ -10531,7 +10533,7 @@ var ys = /*#__PURE__*/function () {
|
|
10531
10533
|
value: function createSVGButton(e) {
|
10532
10534
|
var t = document.createElement("div");
|
10533
10535
|
t.classList.add("modal-button", "modal-svg-button");
|
10534
|
-
var i =
|
10536
|
+
var i = G.createSVGElement(e);
|
10535
10537
|
return i.classList.add("modal-svg-button-icon"), t.appendChild(i), t;
|
10536
10538
|
}
|
10537
10539
|
}, {
|
@@ -10554,10 +10556,10 @@ var pt = /*#__PURE__*/function (_Tt2) {
|
|
10554
10556
|
function pt(e, t, i, n, r, o) {
|
10555
10557
|
var _this49;
|
10556
10558
|
_classCallCheck(this, pt);
|
10557
|
-
var l, c, d, u,
|
10559
|
+
var l, c, d, u, h, p;
|
10558
10560
|
_this49 = _callSuper(this, pt, [pt.createButtonElement(), (l = i.button) == null ? void 0 : l.position, i.button, o]);
|
10559
10561
|
var a = _this49.createInnerElements(n, r, _this49._customStyles);
|
10560
|
-
_this49._inputElement = pt.createInputElement((c = i == null ? void 0 : i.files) == null ? void 0 : c.acceptedFormats), _this49.addClickEvent(e, i), _this49.elementRef.replaceChildren(a.styles), _this49.reapplyStateStyle("styles"), _this49._fileAttachmentsType = t, _this49._openModalOnce = ((u = (d = i.files) == null ? void 0 : d.infoModal) == null ? void 0 : u.openModalOnce) === !1 || (
|
10562
|
+
_this49._inputElement = pt.createInputElement((c = i == null ? void 0 : i.files) == null ? void 0 : c.acceptedFormats), _this49.addClickEvent(e, i), _this49.elementRef.replaceChildren(a.styles), _this49.reapplyStateStyle("styles"), _this49._fileAttachmentsType = t, _this49._openModalOnce = ((u = (d = i.files) == null ? void 0 : d.infoModal) == null ? void 0 : u.openModalOnce) === !1 || (p = (h = i.files) == null ? void 0 : h.infoModal) == null ? void 0 : p.openModalOnce;
|
10561
10563
|
return _this49;
|
10562
10564
|
}
|
10563
10565
|
_createClass(pt, [{
|
@@ -10610,7 +10612,7 @@ var pt = /*#__PURE__*/function (_Tt2) {
|
|
10610
10612
|
}, {
|
10611
10613
|
key: "createSVGIconElement",
|
10612
10614
|
value: function createSVGIconElement(e, t) {
|
10613
|
-
var i =
|
10615
|
+
var i = G.createSVGElement(t);
|
10614
10616
|
return i.id = e, i;
|
10615
10617
|
}
|
10616
10618
|
}]);
|
@@ -10736,7 +10738,7 @@ var Ae = /*#__PURE__*/function () {
|
|
10736
10738
|
}, {
|
10737
10739
|
key: "validateWebsocket",
|
10738
10740
|
value: function validateWebsocket(e, t) {
|
10739
|
-
return e.websocket && !
|
10741
|
+
return e.websocket && !F.canSendMessage(e.websocket) ? (t.changeToDisabledIcon(), !1) : !0;
|
10740
10742
|
}
|
10741
10743
|
// prettier-ignore
|
10742
10744
|
}, {
|
@@ -10842,7 +10844,7 @@ var xt = /*#__PURE__*/function (_Tt3) {
|
|
10842
10844
|
}, {
|
10843
10845
|
key: "createSVGIconElement",
|
10844
10846
|
value: function createSVGIconElement() {
|
10845
|
-
var e =
|
10847
|
+
var e = G.createSVGElement(aa);
|
10846
10848
|
return e.id = "microphone-icon", e;
|
10847
10849
|
}
|
10848
10850
|
}]);
|
@@ -10852,11 +10854,11 @@ var xs = {},
|
|
10852
10854
|
ci = {},
|
10853
10855
|
di = {},
|
10854
10856
|
At = {},
|
10855
|
-
|
10856
|
-
Object.defineProperty(
|
10857
|
+
ze = {};
|
10858
|
+
Object.defineProperty(ze, "__esModule", {
|
10857
10859
|
value: !0
|
10858
10860
|
});
|
10859
|
-
|
10861
|
+
ze.Text = void 0;
|
10860
10862
|
var xe = /*#__PURE__*/function () {
|
10861
10863
|
function xe() {
|
10862
10864
|
_classCallCheck(this, xe);
|
@@ -10887,7 +10889,7 @@ var xe = /*#__PURE__*/function () {
|
|
10887
10889
|
}]);
|
10888
10890
|
return xe;
|
10889
10891
|
}();
|
10890
|
-
|
10892
|
+
ze.Text = xe;
|
10891
10893
|
xe.FIRST_CHAR_REGEX = /\S/;
|
10892
10894
|
xe.DOUBLE_LINE = /\n\n/g;
|
10893
10895
|
xe.ONE_LINE = /\n/g;
|
@@ -10895,7 +10897,7 @@ Object.defineProperty(At, "__esModule", {
|
|
10895
10897
|
value: !0
|
10896
10898
|
});
|
10897
10899
|
At.Translate = void 0;
|
10898
|
-
var la =
|
10900
|
+
var la = ze;
|
10899
10901
|
var ca = /*#__PURE__*/function () {
|
10900
10902
|
function ca() {
|
10901
10903
|
_classCallCheck(this, ca);
|
@@ -10971,11 +10973,11 @@ Object.defineProperty(ui, "__esModule", {
|
|
10971
10973
|
value: !0
|
10972
10974
|
});
|
10973
10975
|
ui.EventListeners = void 0;
|
10974
|
-
var
|
10975
|
-
function
|
10976
|
-
_classCallCheck(this,
|
10976
|
+
var Y = /*#__PURE__*/function () {
|
10977
|
+
function Y() {
|
10978
|
+
_classCallCheck(this, Y);
|
10977
10979
|
}
|
10978
|
-
_createClass(
|
10980
|
+
_createClass(Y, null, [{
|
10979
10981
|
key: "getElementIfFocusedOnAvailable",
|
10980
10982
|
value: function getElementIfFocusedOnAvailable(e, t) {
|
10981
10983
|
return Array.isArray(e) ? e.find(function (i) {
|
@@ -10986,14 +10988,14 @@ var K = /*#__PURE__*/function () {
|
|
10986
10988
|
key: "keyDownWindow",
|
10987
10989
|
value: function keyDownWindow(e) {
|
10988
10990
|
var _this51 = this;
|
10989
|
-
e.element &&
|
10990
|
-
|
10991
|
+
e.element && Y.getElementIfFocusedOnAvailable(e.element, document.activeElement) && (Y.KEY_DOWN_TIMEOUT !== null && clearTimeout(Y.KEY_DOWN_TIMEOUT), Y.KEY_DOWN_TIMEOUT = setTimeout(function () {
|
10992
|
+
Y.KEY_DOWN_TIMEOUT = null, _this51.resetRecording(e);
|
10991
10993
|
}, 500));
|
10992
10994
|
}
|
10993
10995
|
}, {
|
10994
10996
|
key: "mouseDownWindow",
|
10995
10997
|
value: function mouseDownWindow(e, t) {
|
10996
|
-
this.mouseDownElement =
|
10998
|
+
this.mouseDownElement = Y.getElementIfFocusedOnAvailable(e, t.target);
|
10997
10999
|
}
|
10998
11000
|
}, {
|
10999
11001
|
key: "mouseUpWindow",
|
@@ -11004,7 +11006,7 @@ var K = /*#__PURE__*/function () {
|
|
11004
11006
|
key: "add",
|
11005
11007
|
value: function add(e, t) {
|
11006
11008
|
var i = (t == null ? void 0 : t.insertInCursorLocation) === void 0 || (t == null ? void 0 : t.insertInCursorLocation);
|
11007
|
-
t != null && t.element && i && (e.mouseDownEvent =
|
11009
|
+
t != null && t.element && i && (e.mouseDownEvent = Y.mouseDownWindow.bind(e, t.element), document.addEventListener("mousedown", e.mouseDownEvent), e.mouseUpEvent = Y.mouseUpWindow.bind(e, t), document.addEventListener("mouseup", e.mouseUpEvent), e.keyDownEvent = Y.keyDownWindow.bind(e, t), document.addEventListener("keydown", e.keyDownEvent));
|
11008
11010
|
}
|
11009
11011
|
}, {
|
11010
11012
|
key: "remove",
|
@@ -11012,10 +11014,10 @@ var K = /*#__PURE__*/function () {
|
|
11012
11014
|
document.removeEventListener("mousedown", e.mouseDownEvent), document.removeEventListener("mouseup", e.mouseUpEvent), document.removeEventListener("keydown", e.keyDownEvent);
|
11013
11015
|
}
|
11014
11016
|
}]);
|
11015
|
-
return
|
11017
|
+
return Y;
|
11016
11018
|
}();
|
11017
|
-
ui.EventListeners =
|
11018
|
-
|
11019
|
+
ui.EventListeners = Y;
|
11020
|
+
Y.KEY_DOWN_TIMEOUT = null;
|
11019
11021
|
var hi = {};
|
11020
11022
|
Object.defineProperty(hi, "__esModule", {
|
11021
11023
|
value: !0
|
@@ -11080,11 +11082,11 @@ var sn = /*#__PURE__*/function () {
|
|
11080
11082
|
return sn;
|
11081
11083
|
}();
|
11082
11084
|
Lt.AutoScroll = sn;
|
11083
|
-
var
|
11084
|
-
Object.defineProperty(
|
11085
|
+
var Ue = {};
|
11086
|
+
Object.defineProperty(Ue, "__esModule", {
|
11085
11087
|
value: !0
|
11086
11088
|
});
|
11087
|
-
|
11089
|
+
Ue.Elements = void 0;
|
11088
11090
|
var ha = /*#__PURE__*/function () {
|
11089
11091
|
function ha() {
|
11090
11092
|
_classCallCheck(this, ha);
|
@@ -11132,12 +11134,12 @@ var ha = /*#__PURE__*/function () {
|
|
11132
11134
|
}]);
|
11133
11135
|
return ha;
|
11134
11136
|
}();
|
11135
|
-
|
11136
|
-
var
|
11137
|
-
Object.defineProperty(
|
11137
|
+
Ue.Elements = ha;
|
11138
|
+
var qe = {};
|
11139
|
+
Object.defineProperty(qe, "__esModule", {
|
11138
11140
|
value: !0
|
11139
11141
|
});
|
11140
|
-
|
11142
|
+
qe.Cursor = void 0;
|
11141
11143
|
var ft = /*#__PURE__*/function () {
|
11142
11144
|
function ft() {
|
11143
11145
|
_classCallCheck(this, ft);
|
@@ -11219,21 +11221,21 @@ var ft = /*#__PURE__*/function () {
|
|
11219
11221
|
}]);
|
11220
11222
|
return ft;
|
11221
11223
|
}();
|
11222
|
-
|
11224
|
+
qe.Cursor = ft;
|
11223
11225
|
Object.defineProperty(It, "__esModule", {
|
11224
11226
|
value: !0
|
11225
11227
|
});
|
11226
11228
|
It.CommandUtils = void 0;
|
11227
11229
|
var An = Lt,
|
11228
|
-
pa =
|
11230
|
+
pa = Ue,
|
11229
11231
|
fa = nt,
|
11230
|
-
kn =
|
11231
|
-
In =
|
11232
|
-
var
|
11233
|
-
function
|
11234
|
-
_classCallCheck(this,
|
11232
|
+
kn = qe,
|
11233
|
+
In = ze;
|
11234
|
+
var K = /*#__PURE__*/function () {
|
11235
|
+
function K() {
|
11236
|
+
_classCallCheck(this, K);
|
11235
11237
|
}
|
11236
|
-
_createClass(
|
11238
|
+
_createClass(K, null, [{
|
11237
11239
|
key: "processCommand",
|
11238
11240
|
value: function processCommand(e, t) {
|
11239
11241
|
return (!t || !t.caseSensitive) && (e = e.toLowerCase()), (t == null ? void 0 : t.substrings) === !1 ? In.Text.breakupIntoWordsArr(e) : e;
|
@@ -11244,7 +11246,7 @@ var $ = /*#__PURE__*/function () {
|
|
11244
11246
|
var t;
|
11245
11247
|
return ((t = e.settings) === null || t === void 0 ? void 0 : t.caseSensitive) === !0 ? e : Object.keys(e).reduce(function (n, r) {
|
11246
11248
|
var o = e[r];
|
11247
|
-
return n[r] = typeof o == "string" ?
|
11249
|
+
return n[r] = typeof o == "string" ? K.processCommand(o, e.settings) : o, n;
|
11248
11250
|
}, {});
|
11249
11251
|
}
|
11250
11252
|
}, {
|
@@ -11262,7 +11264,7 @@ var $ = /*#__PURE__*/function () {
|
|
11262
11264
|
}, {
|
11263
11265
|
key: "setText",
|
11264
11266
|
value: function setText(e, t, i, n) {
|
11265
|
-
|
11267
|
+
K.toggleCommandModeOff(e), pa.Elements.isPrimitiveElement(n) ? (n.value = i, e.isTargetInShadow || kn.Cursor.setOffsetForPrimitive(n, i.length, !0), fa.Browser.IS_SAFARI() && e.autoScroll && An.AutoScroll.scrollSafariPrimitiveToEnd(n)) : (n.textContent = i, e.isTargetInShadow || kn.Cursor.focusEndOfGeneric(n), setTimeout(function () {
|
11266
11268
|
return An.AutoScroll.scrollGeneric(e, n);
|
11267
11269
|
})), e.resetRecording(t);
|
11268
11270
|
}
|
@@ -11292,46 +11294,46 @@ var $ = /*#__PURE__*/function () {
|
|
11292
11294
|
if (!c || !n || !i) return;
|
11293
11295
|
var d = ((o = c.settings) === null || o === void 0 ? void 0 : o.caseSensitive) === !0 ? t : t.toLowerCase(),
|
11294
11296
|
u = In.Text.breakupIntoWordsArr(d),
|
11295
|
-
|
11296
|
-
if (c.commandMode &&
|
11297
|
-
return
|
11297
|
+
h = ((a = c.settings) === null || a === void 0 ? void 0 : a.substrings) === !1 ? K.checkIfMatchesWord : K.checkIfMatchesSubstring;
|
11298
|
+
if (c.commandMode && h(c.commandMode, d, u)) return e.setInterimColorToFinal(), setTimeout(function () {
|
11299
|
+
return K.toggleCommandModeOn(e);
|
11298
11300
|
}), {
|
11299
11301
|
doNotProcessTranscription: !1
|
11300
11302
|
};
|
11301
11303
|
if (!(c.commandMode && !e.isWaitingForCommand)) {
|
11302
|
-
if (c.stop &&
|
11304
|
+
if (c.stop && h(c.stop, d, u)) return K.toggleCommandModeOff(e), setTimeout(function () {
|
11303
11305
|
return e.stop();
|
11304
11306
|
}), {
|
11305
11307
|
doNotProcessTranscription: !1
|
11306
11308
|
};
|
11307
|
-
if (c.pause &&
|
11308
|
-
var
|
11309
|
-
e.isPaused = !0, (
|
11309
|
+
if (c.pause && h(c.pause, d, u)) return K.toggleCommandModeOff(e), e.setInterimColorToFinal(), setTimeout(function () {
|
11310
|
+
var p;
|
11311
|
+
e.isPaused = !0, (p = e.onPauseTrigger) === null || p === void 0 || p.call(e, !0);
|
11310
11312
|
}), {
|
11311
11313
|
doNotProcessTranscription: !1
|
11312
11314
|
};
|
11313
|
-
if (c.resume &&
|
11315
|
+
if (c.resume && h(c.resume, d, u)) return e.isPaused = !1, (l = e.onPauseTrigger) === null || l === void 0 || l.call(e, !1), K.toggleCommandModeOff(e), e.resetRecording(i), {
|
11314
11316
|
doNotProcessTranscription: !0
|
11315
11317
|
};
|
11316
|
-
if (c.reset &&
|
11318
|
+
if (c.reset && h(c.reset, d, u)) return r !== void 0 && K.setText(e, i, r, n), {
|
11317
11319
|
doNotProcessTranscription: !0
|
11318
11320
|
};
|
11319
|
-
if (c.removeAllText &&
|
11321
|
+
if (c.removeAllText && h(c.removeAllText, d, u)) return K.setText(e, i, "", n), {
|
11320
11322
|
doNotProcessTranscription: !0
|
11321
11323
|
};
|
11322
11324
|
}
|
11323
11325
|
}
|
11324
11326
|
}]);
|
11325
|
-
return
|
11327
|
+
return K;
|
11326
11328
|
}();
|
11327
|
-
It.CommandUtils =
|
11329
|
+
It.CommandUtils = K;
|
11328
11330
|
var pi = {};
|
11329
11331
|
Object.defineProperty(pi, "__esModule", {
|
11330
11332
|
value: !0
|
11331
11333
|
});
|
11332
11334
|
pi.Highlight = void 0;
|
11333
|
-
var ma =
|
11334
|
-
st =
|
11335
|
+
var ma = Ue,
|
11336
|
+
st = qe;
|
11335
11337
|
var $t = /*#__PURE__*/function () {
|
11336
11338
|
function $t() {
|
11337
11339
|
_classCallCheck(this, $t);
|
@@ -11387,9 +11389,9 @@ Object.defineProperty(fi, "__esModule", {
|
|
11387
11389
|
value: !0
|
11388
11390
|
});
|
11389
11391
|
fi.Padding = void 0;
|
11390
|
-
var ga =
|
11391
|
-
Ln =
|
11392
|
-
|
11392
|
+
var ga = Ue,
|
11393
|
+
Ln = qe,
|
11394
|
+
Ge = ze;
|
11393
11395
|
var Kt = /*#__PURE__*/function () {
|
11394
11396
|
function Kt() {
|
11395
11397
|
_classCallCheck(this, Kt);
|
@@ -11402,11 +11404,11 @@ var Kt = /*#__PURE__*/function () {
|
|
11402
11404
|
r = t.value[n - 1],
|
11403
11405
|
o = t.selectionEnd === null ? n : t.selectionEnd,
|
11404
11406
|
a = t.value[o];
|
11405
|
-
|
11407
|
+
Ge.Text.isCharDefined(r) && (e.startPadding = " ", e.numberOfSpacesBeforeNewText = 1), Ge.Text.isCharDefined(a) && (e.endPadding = " ", e.numberOfSpacesAfterNewText = 1), e.isCursorAtEnd = t.value.length === o;
|
11406
11408
|
return;
|
11407
11409
|
}
|
11408
11410
|
var i = t.value[t.value.length - 1];
|
11409
|
-
|
11411
|
+
Ge.Text.isCharDefined(i) && (e.startPadding = " ", e.numberOfSpacesBeforeNewText = 1), e.isCursorAtEnd = !0;
|
11410
11412
|
}
|
11411
11413
|
}, {
|
11412
11414
|
key: "setStateForGenericElement",
|
@@ -11419,12 +11421,12 @@ var Kt = /*#__PURE__*/function () {
|
|
11419
11421
|
c = (i = t.textContent) === null || i === void 0 ? void 0 : i[l - 1],
|
11420
11422
|
d = Ln.Cursor.getGenericElementCursorOffset(t, a, !1),
|
11421
11423
|
u = (n = t.textContent) === null || n === void 0 ? void 0 : n[d];
|
11422
|
-
|
11424
|
+
Ge.Text.isCharDefined(c) && (e.startPadding = " "), Ge.Text.isCharDefined(u) && (e.endPadding = " "), e.isCursorAtEnd = ((r = t.textContent) === null || r === void 0 ? void 0 : r.length) === d;
|
11423
11425
|
return;
|
11424
11426
|
}
|
11425
11427
|
}
|
11426
11428
|
var o = t.innerText.charAt(t.innerText.length - 1);
|
11427
|
-
|
11429
|
+
Ge.Text.isCharDefined(o) && (e.startPadding = " "), e.isCursorAtEnd = !0;
|
11428
11430
|
}
|
11429
11431
|
}, {
|
11430
11432
|
key: "setState",
|
@@ -11458,11 +11460,11 @@ var Rn = ui,
|
|
11458
11460
|
Nn = It,
|
11459
11461
|
Pt = Lt,
|
11460
11462
|
ki = pi,
|
11461
|
-
ie =
|
11463
|
+
ie = Ue,
|
11462
11464
|
Ii = fi,
|
11463
11465
|
On = nt,
|
11464
|
-
Pn =
|
11465
|
-
Li =
|
11466
|
+
Pn = qe,
|
11467
|
+
Li = ze;
|
11466
11468
|
var va = /*#__PURE__*/function () {
|
11467
11469
|
function va() {
|
11468
11470
|
_classCallCheck(this, va);
|
@@ -11651,22 +11653,22 @@ Object.defineProperty(mi, "__esModule", {
|
|
11651
11653
|
value: !0
|
11652
11654
|
});
|
11653
11655
|
mi.GlobalState = void 0;
|
11654
|
-
var
|
11655
|
-
function
|
11656
|
-
_classCallCheck(this,
|
11656
|
+
var Xe = /*#__PURE__*/function () {
|
11657
|
+
function Xe() {
|
11658
|
+
_classCallCheck(this, Xe);
|
11657
11659
|
}
|
11658
|
-
_createClass(
|
11660
|
+
_createClass(Xe, null, [{
|
11659
11661
|
key: "doubleClickDetector",
|
11660
11662
|
value: function doubleClickDetector() {
|
11661
|
-
return
|
11662
|
-
|
11663
|
+
return Xe.doubleClickPending ? !0 : (Xe.doubleClickPending = !0, setTimeout(function () {
|
11664
|
+
Xe.doubleClickPending = !1;
|
11663
11665
|
}, 300), !1);
|
11664
11666
|
}
|
11665
11667
|
}]);
|
11666
|
-
return
|
11668
|
+
return Xe;
|
11667
11669
|
}();
|
11668
|
-
mi.GlobalState =
|
11669
|
-
|
11670
|
+
mi.GlobalState = Xe;
|
11671
|
+
Xe.doubleClickPending = !1;
|
11670
11672
|
var gi = {},
|
11671
11673
|
bi = {};
|
11672
11674
|
Object.defineProperty(bi, "__esModule", {
|
@@ -12013,21 +12015,21 @@ var Un = ci,
|
|
12013
12015
|
wa = It,
|
12014
12016
|
ee = mi,
|
12015
12017
|
Ma = gi;
|
12016
|
-
var
|
12017
|
-
function
|
12018
|
-
_classCallCheck(this,
|
12018
|
+
var Ke = /*#__PURE__*/function () {
|
12019
|
+
function Ke() {
|
12020
|
+
_classCallCheck(this, Ke);
|
12019
12021
|
}
|
12020
|
-
_createClass(
|
12022
|
+
_createClass(Ke, null, [{
|
12021
12023
|
key: "toggle",
|
12022
12024
|
value: function toggle(e, t) {
|
12023
12025
|
var i, n;
|
12024
12026
|
var r = e.toLocaleLowerCase().trim();
|
12025
|
-
!((i = ee.GlobalState.service) === null || i === void 0) && i.recognizing ? this.stop() : r === "webspeech" ?
|
12027
|
+
!((i = ee.GlobalState.service) === null || i === void 0) && i.recognizing ? this.stop() : r === "webspeech" ? Ke.startWebSpeech(t) : r === "azure" ? Ke.startAzure(t) : (console.error("service not found - must be either 'webspeech' or 'azure'"), (n = t == null ? void 0 : t.onError) === null || n === void 0 || n.call(t, "service not found - must be either 'webspeech' or 'azure'"));
|
12026
12028
|
}
|
12027
12029
|
}, {
|
12028
12030
|
key: "startWebSpeech",
|
12029
12031
|
value: function startWebSpeech(e) {
|
12030
|
-
|
12032
|
+
Ke.stop() || (ee.GlobalState.service = new Un.WebSpeech(), ee.GlobalState.service.start(e));
|
12031
12033
|
}
|
12032
12034
|
}, {
|
12033
12035
|
key: "isWebSpeechSupported",
|
@@ -12038,7 +12040,7 @@ var $e = /*#__PURE__*/function () {
|
|
12038
12040
|
key: "startAzure",
|
12039
12041
|
value: function startAzure(e) {
|
12040
12042
|
var t;
|
12041
|
-
|
12043
|
+
Ke.stop() || !((t = ee.GlobalState.service) === null || t === void 0) && t.cannotBeStopped || (ee.GlobalState.service = new Ma.Azure(), ee.GlobalState.service.start(e));
|
12042
12044
|
}
|
12043
12045
|
}, {
|
12044
12046
|
key: "stop",
|
@@ -12052,9 +12054,9 @@ var $e = /*#__PURE__*/function () {
|
|
12052
12054
|
ee.GlobalState.service && wa.CommandUtils.toggleCommandModeOff(ee.GlobalState.service);
|
12053
12055
|
}
|
12054
12056
|
}]);
|
12055
|
-
return
|
12057
|
+
return Ke;
|
12056
12058
|
}();
|
12057
|
-
var Oi = xs["default"] =
|
12059
|
+
var Oi = xs["default"] = Ke;
|
12058
12060
|
var Qt = /*#__PURE__*/function (_xt) {
|
12059
12061
|
_inherits(Qt, _xt);
|
12060
12062
|
function Qt(e, t, i) {
|
@@ -12209,42 +12211,42 @@ var Ta = /*#__PURE__*/function (_xt2) {
|
|
12209
12211
|
return Ta;
|
12210
12212
|
}(xt);
|
12211
12213
|
var Ca = "<?xml version=\"1.0\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN\" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n<svg xmlns=\"http://www.w3.org/2000/svg\" stroke=\"currentColor\" fill=\"none\" stroke-width=\"1\" viewBox=\"0 0 24 24\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"14\"></line>\n <polygon points=\"22 2 15 22 11 14 2 10 22 2\"></polygon>\n</svg>\n";
|
12212
|
-
var
|
12213
|
-
function
|
12214
|
-
_classCallCheck(this,
|
12214
|
+
var z = /*#__PURE__*/function () {
|
12215
|
+
function z() {
|
12216
|
+
_classCallCheck(this, z);
|
12215
12217
|
}
|
12216
|
-
_createClass(
|
12218
|
+
_createClass(z, null, [{
|
12217
12219
|
key: "setPropertyValueIfDoesNotExist",
|
12218
12220
|
value: function setPropertyValueIfDoesNotExist(e, t, i) {
|
12219
12221
|
var _e$n, _e$n2;
|
12220
12222
|
var n = t[0];
|
12221
|
-
t.length === 1 ? (_e$n = e[n]) !== null && _e$n !== void 0 ? _e$n : e[n] = i : ((_e$n2 = e[n]) !== null && _e$n2 !== void 0 ? _e$n2 : e[n] = {}, t.shift(),
|
12223
|
+
t.length === 1 ? (_e$n = e[n]) !== null && _e$n !== void 0 ? _e$n : e[n] = i : ((_e$n2 = e[n]) !== null && _e$n2 !== void 0 ? _e$n2 : e[n] = {}, t.shift(), z.setPropertyValueIfDoesNotExist(e[n], t, i));
|
12222
12224
|
}
|
12223
12225
|
}, {
|
12224
12226
|
key: "setPropertyValue",
|
12225
12227
|
value: function setPropertyValue(e, t, i) {
|
12226
12228
|
var _e$n3;
|
12227
12229
|
var n = t[0];
|
12228
|
-
t.length === 1 ? e[n] = i : ((_e$n3 = e[n]) !== null && _e$n3 !== void 0 ? _e$n3 : e[n] = {}, t.shift(),
|
12230
|
+
t.length === 1 ? e[n] = i : ((_e$n3 = e[n]) !== null && _e$n3 !== void 0 ? _e$n3 : e[n] = {}, t.shift(), z.setPropertyValue(e[n], t, i));
|
12229
12231
|
}
|
12230
12232
|
}, {
|
12231
12233
|
key: "getObjectValue",
|
12232
12234
|
value: function getObjectValue(e, t) {
|
12233
12235
|
var i = t[0],
|
12234
12236
|
n = e[i];
|
12235
|
-
return n === void 0 || t.length === 1 ? n :
|
12237
|
+
return n === void 0 || t.length === 1 ? n : z.getObjectValue(n, t.slice(1));
|
12236
12238
|
}
|
12237
12239
|
}, {
|
12238
12240
|
key: "overwritePropertyObjectFromAnother",
|
12239
12241
|
value: function overwritePropertyObjectFromAnother(e, t, i) {
|
12240
|
-
var n =
|
12242
|
+
var n = z.getObjectValue(t, i);
|
12241
12243
|
if (n) {
|
12242
|
-
var r = _objectSpread(_objectSpread({}, n),
|
12243
|
-
|
12244
|
+
var r = _objectSpread(_objectSpread({}, n), z.getObjectValue(e, i) || {});
|
12245
|
+
z.setPropertyValue(e, i, r);
|
12244
12246
|
}
|
12245
12247
|
}
|
12246
12248
|
}]);
|
12247
|
-
return
|
12249
|
+
return z;
|
12248
12250
|
}();
|
12249
12251
|
var Ie = /*#__PURE__*/function () {
|
12250
12252
|
function Ie() {
|
@@ -12260,13 +12262,13 @@ var Ie = /*#__PURE__*/function () {
|
|
12260
12262
|
value: function overwriteDefaultStyleWithSubmit(e, t) {
|
12261
12263
|
if (!e.submit) return;
|
12262
12264
|
var i = JSON.parse(JSON.stringify(e[t] || {}));
|
12263
|
-
|
12265
|
+
z.overwritePropertyObjectFromAnother(i, e.submit, ["container", "default"]), z.overwritePropertyObjectFromAnother(i, e.submit, ["text", "styles", "default"]), z.overwritePropertyObjectFromAnother(i, e.submit, ["svg", "styles", "default"]), e[t] = i;
|
12264
12266
|
}
|
12265
12267
|
// prettier-ignore
|
12266
12268
|
}, {
|
12267
12269
|
key: "setUpDisabledButton",
|
12268
12270
|
value: function setUpDisabledButton(e) {
|
12269
|
-
|
12271
|
+
z.setPropertyValueIfDoesNotExist(e, ["submit", "container", "default", "backgroundColor"], ""), z.setPropertyValueIfDoesNotExist(e, ["disabled", "container", "default", "backgroundColor"], "unset"), z.setPropertyValueIfDoesNotExist(e.submit, ["svg", "styles", "default", "filter"], ""), z.setPropertyValueIfDoesNotExist(e.disabled, ["svg", "styles", "default", "filter"], "brightness(0) saturate(100%) invert(70%) sepia(0%) saturate(5564%) hue-rotate(207deg) brightness(100%) contrast(97%)"), Ie.overwriteDefaultStyleWithSubmit(e, "disabled");
|
12270
12272
|
}
|
12271
12273
|
}, {
|
12272
12274
|
key: "process",
|
@@ -12544,7 +12546,7 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12544
12546
|
}, {
|
12545
12547
|
key: "createSubmitIconElement",
|
12546
12548
|
value: function createSubmitIconElement() {
|
12547
|
-
var e =
|
12549
|
+
var e = G.createSVGElement(Ca);
|
12548
12550
|
return e.id = "submit-icon", e;
|
12549
12551
|
}
|
12550
12552
|
}, {
|
@@ -12580,7 +12582,7 @@ var rn = /*#__PURE__*/function (_ct) {
|
|
12580
12582
|
var _this62$addButtonsAnd = _this62.addButtonsAndTheirEvents(t),
|
12581
12583
|
r = _this62$addButtonsAnd.captureButton,
|
12582
12584
|
o = _this62$addButtonsAnd.submitButton;
|
12583
|
-
_this62._captureButton = r, _this62._submitButton = o, _this62._captureIcon = _this62._captureButton.children[0], _this62._refreshIcon =
|
12585
|
+
_this62._captureButton = r, _this62._submitButton = o, _this62._captureIcon = _this62._captureButton.children[0], _this62._refreshIcon = G.createSVGElement(ka), _this62._refreshIcon.classList.add("modal-svg-button-icon", "modal-svg-refresh-icon"), (n == null ? void 0 : n.format) === "jpeg" && (_this62._format = "image/jpeg"), n != null && n.dimensions && (_this62._dimensions = n.dimensions), _this62._contentRef.appendChild(_this62._canvas), _this62.extensionCloseCallback = _this62.stop;
|
12584
12586
|
return _this62;
|
12585
12587
|
}
|
12586
12588
|
_createClass(rn, [{
|
@@ -12725,7 +12727,7 @@ var ei = /*#__PURE__*/function (_Tt5) {
|
|
12725
12727
|
}, {
|
12726
12728
|
key: "createSVGIconElement",
|
12727
12729
|
value: function createSVGIconElement() {
|
12728
|
-
var e =
|
12730
|
+
var e = G.createSVGElement(Na);
|
12729
12731
|
return e.id = "camera-icon", e;
|
12730
12732
|
}
|
12731
12733
|
}]);
|
@@ -12785,10 +12787,10 @@ var mt = /*#__PURE__*/function () {
|
|
12785
12787
|
_sa$a = sa[a],
|
12786
12788
|
d = _sa$a.id,
|
12787
12789
|
u = _sa$a.svgString,
|
12788
|
-
|
12789
|
-
|
12790
|
+
h = _sa$a.dropupText,
|
12791
|
+
p = new pt(n, c, l, d, u, h);
|
12790
12792
|
r[a] = {
|
12791
|
-
button:
|
12793
|
+
button: p,
|
12792
12794
|
fileType: c
|
12793
12795
|
};
|
12794
12796
|
}
|
@@ -12816,7 +12818,7 @@ var on = /*#__PURE__*/function () {
|
|
12816
12818
|
var n = document.createElement("div");
|
12817
12819
|
n.id = "chat-view";
|
12818
12820
|
var r = new me(e, t, i);
|
12819
|
-
t.websocket &&
|
12821
|
+
t.websocket && F.createConnection(t, r);
|
12820
12822
|
var o = new mt(e, r, t, n);
|
12821
12823
|
return Z.addElements(n, r.elementRef, o.elementRef), n;
|
12822
12824
|
}
|
@@ -12866,7 +12868,7 @@ var v = /*#__PURE__*/function (_So) {
|
|
12866
12868
|
key: "onRender",
|
12867
12869
|
value: function onRender() {
|
12868
12870
|
var _this$_childElement;
|
12869
|
-
(!this._activeService || this._activeService.demo) && (this._activeService = $o.create(this)), this.auxiliaryStyle && !this._auxiliaryStyleApplied && (wi.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), wi.applyDefaultStyleToComponent(this.style, this.chatStyle), Re.checkForContainerStyles(this, this._elementRef), this._activeService.key && this._activeService.validateConfigKey ? Bt.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : !(this._activeService instanceof
|
12871
|
+
(!this._activeService || this._activeService.demo) && (this._activeService = $o.create(this)), this.auxiliaryStyle && !this._auxiliaryStyleApplied && (wi.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), wi.applyDefaultStyleToComponent(this.style, this.chatStyle), Re.checkForContainerStyles(this, this._elementRef), this._activeService.key && this._activeService.validateConfigKey ? Bt.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : !(this._activeService instanceof q) || this._activeService.key ? ((_this$_childElement = this._childElement) !== null && _this$_childElement !== void 0 ? _this$_childElement : this._childElement = this.children[0], on.render(this, this._elementRef, this._activeService, this._childElement)) : this._activeService instanceof q && P.render(this._elementRef, this.changeToChatView.bind(this), this._activeService), this._hasBeenRendered = !0, Ft.onRender(this);
|
12870
12872
|
}
|
12871
12873
|
}, {
|
12872
12874
|
key: "disconnectedCallback",
|