deep-chat-dev 9.0.123 → 9.0.124
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/custom-elements.json +11337 -11246
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.js +711 -671
- package/dist/utils/HTTP/customHandler.d.ts +1 -0
- package/dist/utils/HTTP/customHandler.d.ts.map +1 -1
- package/dist/utils/HTTP/stream.d.ts +5 -0
- package/dist/utils/HTTP/stream.d.ts.map +1 -1
- package/dist/utils/HTTP/websocket.d.ts +2 -3
- package/dist/utils/HTTP/websocket.d.ts.map +1 -1
- package/dist/views/chat/messages/stream/messageStream.d.ts +2 -0
- package/dist/views/chat/messages/stream/messageStream.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/deepChat.js
CHANGED
@@ -40,11 +40,11 @@ var _s = /*#__PURE__*/function () {
|
|
40
40
|
}]);
|
41
41
|
return _s;
|
42
42
|
}();
|
43
|
-
var
|
44
|
-
function
|
45
|
-
_classCallCheck(this,
|
43
|
+
var Ft = /*#__PURE__*/function () {
|
44
|
+
function Ft() {
|
45
|
+
_classCallCheck(this, Ft);
|
46
46
|
}
|
47
|
-
_createClass(
|
47
|
+
_createClass(Ft, null, [{
|
48
48
|
key: "onLoad",
|
49
49
|
value: function onLoad(e) {
|
50
50
|
e.innerHTML = '<div id="large-loading-ring"></div>';
|
@@ -58,22 +58,22 @@ var Bt = /*#__PURE__*/function () {
|
|
58
58
|
}, {
|
59
59
|
key: "render",
|
60
60
|
value: function render(e, t, i) {
|
61
|
-
var n =
|
61
|
+
var n = Ft.createElements(),
|
62
62
|
r = {
|
63
63
|
onSuccess: t,
|
64
64
|
onFail: _s.render.bind(this, e, "Your 'key' has failed authentication"),
|
65
|
-
onLoad:
|
65
|
+
onLoad: Ft.onLoad.bind(this, n)
|
66
66
|
};
|
67
67
|
i.key && i.verifyKey(i.key, r), e.replaceChildren(n);
|
68
68
|
}
|
69
69
|
}]);
|
70
|
-
return
|
70
|
+
return Ft;
|
71
71
|
}();
|
72
|
-
var
|
73
|
-
function
|
74
|
-
_classCallCheck(this,
|
72
|
+
var C = /*#__PURE__*/function () {
|
73
|
+
function C() {
|
74
|
+
_classCallCheck(this, C);
|
75
75
|
}
|
76
|
-
_createClass(
|
76
|
+
_createClass(C, null, [{
|
77
77
|
key: "unsetStyle",
|
78
78
|
value: function unsetStyle(e, t) {
|
79
79
|
var i = Object.keys(t).reduce(function (n, r) {
|
@@ -84,12 +84,12 @@ var T = /*#__PURE__*/function () {
|
|
84
84
|
}, {
|
85
85
|
key: "unsetActivityCSSMouseStates",
|
86
86
|
value: function unsetActivityCSSMouseStates(e, t) {
|
87
|
-
t.click &&
|
87
|
+
t.click && C.unsetStyle(e, t.click), t.hover && C.unsetStyle(e, t.hover);
|
88
88
|
}
|
89
89
|
}, {
|
90
90
|
key: "unsetAllCSSMouseStates",
|
91
91
|
value: function unsetAllCSSMouseStates(e, t) {
|
92
|
-
|
92
|
+
C.unsetActivityCSSMouseStates(e, t), t["default"] && C.unsetStyle(e, t["default"]);
|
93
93
|
}
|
94
94
|
}, {
|
95
95
|
key: "processStateful",
|
@@ -133,7 +133,7 @@ var T = /*#__PURE__*/function () {
|
|
133
133
|
}
|
134
134
|
}
|
135
135
|
}]);
|
136
|
-
return
|
136
|
+
return C;
|
137
137
|
}();
|
138
138
|
var qn = /*#__PURE__*/function () {
|
139
139
|
function Dt() {
|
@@ -163,7 +163,7 @@ var qn = /*#__PURE__*/function () {
|
|
163
163
|
}, {
|
164
164
|
key: "applyDefaultStyleToComponent",
|
165
165
|
value: function applyDefaultStyleToComponent(e, t) {
|
166
|
-
t &&
|
166
|
+
t && C.applyToStyleIfNotDefined(e, t), C.applyToStyleIfNotDefined(e, Dt.DEFAULT_COMPONENT_STYLE);
|
167
167
|
}
|
168
168
|
}]);
|
169
169
|
return Dt;
|
@@ -186,11 +186,11 @@ var wi = qn;
|
|
186
186
|
var R = /* @__PURE__ */function (s) {
|
187
187
|
return s.ESCAPE = "Escape", s.ENTER = "Enter", s.TAB = "Tab", s.ARROW_UP = "ArrowUp", s.ARROW_DOWN = "ArrowDown", s.ARROW_RIGHT = "ArrowRight", s.ARROW_LEFT = "ArrowLeft", s.BACKSPACE = "Backspace", s.DELETE = "Delete", s.META = "Meta", s.CONTROL = "Control", s;
|
188
188
|
}(R || {});
|
189
|
-
var
|
190
|
-
_classCallCheck(this,
|
189
|
+
var ve = /*#__PURE__*/_createClass(function ve() {
|
190
|
+
_classCallCheck(this, ve);
|
191
191
|
});
|
192
|
-
|
193
|
-
|
192
|
+
ve.IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
193
|
+
ve.IS_CHROMIUM = window.chrome;
|
194
194
|
var Hn = /*#__PURE__*/function () {
|
195
195
|
function rt() {
|
196
196
|
_classCallCheck(this, rt);
|
@@ -256,13 +256,13 @@ var Gn = /*#__PURE__*/function () {
|
|
256
256
|
value: function createInputElement(e) {
|
257
257
|
var i, n, r;
|
258
258
|
var t = document.createElement("div");
|
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!",
|
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!", ve.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 && (
|
265
|
+
this.inputElementRef.classList.contains("text-input-placeholder") && !this.inputElementRef.classList.contains("text-input-disabled") && ((e = this._config.placeholder) != null && e.style && (C.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",
|
@@ -274,14 +274,14 @@ var Gn = /*#__PURE__*/function () {
|
|
274
274
|
key: "onFocus",
|
275
275
|
value: function onFocus(e) {
|
276
276
|
var _this2 = this;
|
277
|
-
|
277
|
+
ve.IS_SAFARI ? setTimeout(function () {
|
278
278
|
_this2.removeTextIfPlaceholder();
|
279
279
|
}) : this.removeTextIfPlaceholder(), Object.assign(this.elementRef.style, e);
|
280
280
|
}
|
281
281
|
}, {
|
282
282
|
key: "onBlur",
|
283
283
|
value: function onBlur(e, t) {
|
284
|
-
|
284
|
+
C.unsetStyle(this.elementRef, e), t && Object.assign(this.elementRef.style, t);
|
285
285
|
}
|
286
286
|
}, {
|
287
287
|
key: "onKeydown",
|
@@ -318,7 +318,7 @@ var Gn = /*#__PURE__*/function () {
|
|
318
318
|
key: "clear",
|
319
319
|
value: function clear(e) {
|
320
320
|
var t = window.scrollY;
|
321
|
-
e.classList.contains("text-input-disabled") || (e.textContent = ""),
|
321
|
+
e.classList.contains("text-input-disabled") || (e.textContent = ""), ve.IS_CHROMIUM && window.scrollTo({
|
322
322
|
top: t
|
323
323
|
});
|
324
324
|
}
|
@@ -382,7 +382,7 @@ function As(s, e) {
|
|
382
382
|
return "".concat(Vi(s, t, e), "Make sure the ").concat(t, " message is using the {body: {text: string}} format, e.g: {body: {text: \"Model Response\"}}");
|
383
383
|
}
|
384
384
|
var ln = "Make sure the events are using {text: string} or {html: string} format.\nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor",
|
385
|
-
|
385
|
+
A = {
|
386
386
|
INVALID_KEY: "Invalid API Key",
|
387
387
|
CONNECTION_FAILED: "Failed to connect",
|
388
388
|
INVALID_RESPONSE: Ts,
|
@@ -569,13 +569,13 @@ var ks = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNv
|
|
569
569
|
Kn.CONTAINER_CLASS = "avatar-container";
|
570
570
|
var cn = Kn;
|
571
571
|
var Yn = /*#__PURE__*/function () {
|
572
|
-
function
|
573
|
-
_classCallCheck(this,
|
572
|
+
function Se() {
|
573
|
+
_classCallCheck(this, Se);
|
574
574
|
}
|
575
|
-
_createClass(
|
575
|
+
_createClass(Se, null, [{
|
576
576
|
key: "hide",
|
577
577
|
value: function hide(e) {
|
578
|
-
e.getElementsByClassName(
|
578
|
+
e.getElementsByClassName(Se.NAME_CLASS)[0].style.visibility = "hidden";
|
579
579
|
}
|
580
580
|
}, {
|
581
581
|
key: "getPosition",
|
@@ -601,26 +601,26 @@ var Yn = /*#__PURE__*/function () {
|
|
601
601
|
key: "createName",
|
602
602
|
value: function createName(e, t) {
|
603
603
|
var i = document.createElement("div");
|
604
|
-
return i.classList.add(
|
604
|
+
return i.classList.add(Se.NAME_CLASS), i.textContent = Se.getNameText(e, t), Se.applyStyle(i, e, t), i;
|
605
605
|
}
|
606
606
|
}, {
|
607
607
|
key: "add",
|
608
608
|
value: function add(e, t, i) {
|
609
609
|
var n = typeof i == "boolean" ? {} : i,
|
610
|
-
r =
|
611
|
-
o =
|
610
|
+
r = Se.createName(t, n),
|
611
|
+
o = Se.getPosition(t, n);
|
612
612
|
r.classList.add(o === "left" ? "left-item-position" : "right-item-position"), e.insertAdjacentElement(o === "left" ? "beforebegin" : "afterend", r);
|
613
613
|
}
|
614
614
|
}]);
|
615
|
-
return
|
615
|
+
return Se;
|
616
616
|
}();
|
617
617
|
Yn.NAME_CLASS = "name";
|
618
618
|
var dn = Yn;
|
619
619
|
var ii = /*#__PURE__*/function () {
|
620
|
-
function
|
621
|
-
_classCallCheck(this,
|
620
|
+
function we() {
|
621
|
+
_classCallCheck(this, we);
|
622
622
|
}
|
623
|
-
_createClass(
|
623
|
+
_createClass(we, null, [{
|
624
624
|
key: "getLastElementsByClass",
|
625
625
|
value: function getLastElementsByClass(e, t, i) {
|
626
626
|
var _loop = function _loop() {
|
@@ -661,8 +661,8 @@ var ii = /*#__PURE__*/function () {
|
|
661
661
|
}, {
|
662
662
|
key: "overwriteMessage",
|
663
663
|
value: function overwriteMessage(e, t, i, n, r, o) {
|
664
|
-
var a =
|
665
|
-
l =
|
664
|
+
var a = we.getLastElementsByClass(t, [we.getRoleClass(n), o], ["loading-message-text"]),
|
665
|
+
l = we.getLastMessage(e, n, r);
|
666
666
|
return l && (l[r] = i), a;
|
667
667
|
}
|
668
668
|
}, {
|
@@ -674,18 +674,18 @@ var ii = /*#__PURE__*/function () {
|
|
674
674
|
}, {
|
675
675
|
key: "fillEmptyMessageElement",
|
676
676
|
value: function fillEmptyMessageElement(e, t) {
|
677
|
-
t.trim().length === 0 && (e.classList.add(
|
677
|
+
t.trim().length === 0 && (e.classList.add(we.EMPTY_MESSAGE_CLASS), e.innerHTML = '<div style="color:#00000000">.</div>');
|
678
678
|
}
|
679
679
|
}, {
|
680
680
|
key: "unfillEmptyMessageElement",
|
681
681
|
value: function unfillEmptyMessageElement(e, t) {
|
682
|
-
e.classList.contains(
|
682
|
+
e.classList.contains(we.EMPTY_MESSAGE_CLASS) && t.trim().length > 0 && e.replaceChildren();
|
683
683
|
}
|
684
684
|
}, {
|
685
685
|
key: "getLastMessageBubbleElement",
|
686
686
|
value: function getLastMessageBubbleElement(e) {
|
687
687
|
var t, i, n;
|
688
|
-
return Array.from(((n = (i = (t =
|
688
|
+
return Array.from(((n = (i = (t = we.getLastMessageElement(e)) == null ? void 0 : t.children) == null ? void 0 : i[0]) == null ? void 0 : n.children) || []).find(function (r) {
|
689
689
|
return r.classList.contains("message-bubble");
|
690
690
|
});
|
691
691
|
}
|
@@ -706,20 +706,20 @@ var ii = /*#__PURE__*/function () {
|
|
706
706
|
t && cn.hide(n), i && dn.hide(n);
|
707
707
|
}
|
708
708
|
}]);
|
709
|
-
return
|
709
|
+
return we;
|
710
710
|
}();
|
711
711
|
ii.AI_ROLE = "ai";
|
712
712
|
ii.USER_ROLE = "user";
|
713
713
|
ii.EMPTY_MESSAGE_CLASS = "empty-message";
|
714
714
|
var b = ii;
|
715
|
-
var
|
716
|
-
function
|
717
|
-
_classCallCheck(this,
|
715
|
+
var Ie = /*#__PURE__*/function () {
|
716
|
+
function Ie() {
|
717
|
+
_classCallCheck(this, Ie);
|
718
718
|
}
|
719
|
-
_createClass(
|
719
|
+
_createClass(Ie, null, [{
|
720
720
|
key: "mouseUp",
|
721
721
|
value: function mouseUp(e, t) {
|
722
|
-
|
722
|
+
C.unsetAllCSSMouseStates(e, t), Object.assign(e.style, t["default"]), Object.assign(e.style, t.hover);
|
723
723
|
}
|
724
724
|
}, {
|
725
725
|
key: "mouseDown",
|
@@ -729,7 +729,7 @@ var ke = /*#__PURE__*/function () {
|
|
729
729
|
}, {
|
730
730
|
key: "mouseLeave",
|
731
731
|
value: function mouseLeave(e, t) {
|
732
|
-
|
732
|
+
C.unsetAllCSSMouseStates(e, t), Object.assign(e.style, t["default"]);
|
733
733
|
}
|
734
734
|
}, {
|
735
735
|
key: "mouseEnter",
|
@@ -739,10 +739,10 @@ var ke = /*#__PURE__*/function () {
|
|
739
739
|
}, {
|
740
740
|
key: "add",
|
741
741
|
value: function add(e, t) {
|
742
|
-
e.addEventListener("mouseenter",
|
742
|
+
e.addEventListener("mouseenter", Ie.mouseEnter.bind(this, e, t)), e.addEventListener("mouseleave", Ie.mouseLeave.bind(this, e, t)), e.addEventListener("mousedown", Ie.mouseDown.bind(this, e, t)), e.addEventListener("mouseup", Ie.mouseUp.bind(this, e, t));
|
743
743
|
}
|
744
744
|
}]);
|
745
|
-
return
|
745
|
+
return Ie;
|
746
746
|
}();
|
747
747
|
var Ls = "deep-chat-temporary-message",
|
748
748
|
Rs = "deep-chat-suggestion-button",
|
@@ -768,11 +768,11 @@ var Ls = "deep-chat-temporary-message",
|
|
768
768
|
}
|
769
769
|
},
|
770
770
|
un = Object.keys(Pi);
|
771
|
-
var
|
772
|
-
function
|
773
|
-
_classCallCheck(this,
|
771
|
+
var ye = /*#__PURE__*/function () {
|
772
|
+
function ye() {
|
773
|
+
_classCallCheck(this, ye);
|
774
774
|
}
|
775
|
-
_createClass(
|
775
|
+
_createClass(ye, null, [{
|
776
776
|
key: "applySuggestionEvent",
|
777
777
|
value: function applySuggestionEvent(e, t) {
|
778
778
|
setTimeout(function () {
|
@@ -816,10 +816,10 @@ var ve = /*#__PURE__*/function () {
|
|
816
816
|
r = Pi[i].styles;
|
817
817
|
if (r) {
|
818
818
|
var a = JSON.parse(JSON.stringify(r));
|
819
|
-
a["default"] &&
|
819
|
+
a["default"] && C.overwriteDefaultWithAlreadyApplied(a, t), n.unshift(a);
|
820
820
|
}
|
821
|
-
var o =
|
822
|
-
return
|
821
|
+
var o = C.mergeStatefulStyles(n);
|
822
|
+
return C.processStateful(o, {}, {});
|
823
823
|
}
|
824
824
|
}, {
|
825
825
|
key: "applyDeepChatUtilities",
|
@@ -827,17 +827,17 @@ var ve = /*#__PURE__*/function () {
|
|
827
827
|
un.forEach(function (r) {
|
828
828
|
var o = i.getElementsByClassName(r);
|
829
829
|
Array.from(o || []).forEach(function (a) {
|
830
|
-
var l =
|
831
|
-
oe.applyStylesToElement(a, l),
|
830
|
+
var l = ye.getProcessedStyles(t, a, r);
|
831
|
+
oe.applyStylesToElement(a, l), ye.applyEvents(a, r);
|
832
832
|
});
|
833
833
|
});
|
834
834
|
var n = i.getElementsByClassName(Rs);
|
835
835
|
Array.from(n).forEach(function (r) {
|
836
|
-
return
|
836
|
+
return ye.applySuggestionEvent(e, r);
|
837
837
|
});
|
838
838
|
}
|
839
839
|
}]);
|
840
|
-
return
|
840
|
+
return ye;
|
841
841
|
}();
|
842
842
|
var oe = /*#__PURE__*/function () {
|
843
843
|
function oe() {
|
@@ -846,8 +846,8 @@ var oe = /*#__PURE__*/function () {
|
|
846
846
|
_createClass(oe, null, [{
|
847
847
|
key: "applyStylesToElement",
|
848
848
|
value: function applyStylesToElement(e, t) {
|
849
|
-
var i =
|
850
|
-
|
849
|
+
var i = C.processStateful(t, {}, {});
|
850
|
+
Ie.add(e, i), Object.assign(e.style, i["default"]);
|
851
851
|
}
|
852
852
|
}, {
|
853
853
|
key: "applyEventsToElement",
|
@@ -862,7 +862,7 @@ var oe = /*#__PURE__*/function () {
|
|
862
862
|
value: function applyClassUtilitiesToElement(e, t) {
|
863
863
|
var i = t.events,
|
864
864
|
n = t.styles;
|
865
|
-
i && oe.applyEventsToElement(e, i), n && !
|
865
|
+
i && oe.applyEventsToElement(e, i), n && !ye.doesElementContainDeepChatClass(e) && oe.applyStylesToElement(e, n);
|
866
866
|
}
|
867
867
|
}, {
|
868
868
|
key: "applyCustomClassUtilities",
|
@@ -877,7 +877,7 @@ var oe = /*#__PURE__*/function () {
|
|
877
877
|
}, {
|
878
878
|
key: "apply",
|
879
879
|
value: function apply(e, t) {
|
880
|
-
|
880
|
+
ye.applyDeepChatUtilities(e, e.htmlClassUtilities, t), oe.applyCustomClassUtilities(e.htmlClassUtilities, t);
|
881
881
|
}
|
882
882
|
}]);
|
883
883
|
return oe;
|
@@ -957,15 +957,15 @@ function Di(s) {
|
|
957
957
|
}
|
958
958
|
var Ds = /&([a-z#][a-z0-9]{1,31});/gi,
|
959
959
|
js = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
|
960
|
-
function
|
960
|
+
function Fs(s, e) {
|
961
961
|
var t = 0,
|
962
962
|
i = Zn(e);
|
963
963
|
return e !== i ? i : e.charCodeAt(0) === 35 && js.test(e) && (t = e[1].toLowerCase() === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10), Qn(t)) ? Di(t) : s;
|
964
964
|
}
|
965
965
|
function Ne(s) {
|
966
|
-
return s.indexOf("&") < 0 ? s : s.replace(Ds,
|
966
|
+
return s.indexOf("&") < 0 ? s : s.replace(Ds, Fs);
|
967
967
|
}
|
968
|
-
var
|
968
|
+
var Bs = /[&<>"]/,
|
969
969
|
zs = /[&<>"]/g,
|
970
970
|
Us = {
|
971
971
|
"&": "&",
|
@@ -977,7 +977,7 @@ function qs(s) {
|
|
977
977
|
return Us[s];
|
978
978
|
}
|
979
979
|
function U(s) {
|
980
|
-
return
|
980
|
+
return Bs.test(s) ? s.replace(zs, qs) : s;
|
981
981
|
}
|
982
982
|
var m = {};
|
983
983
|
m.blockquote_open = function () {
|
@@ -1609,7 +1609,7 @@ 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 Fe(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 Be(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
|
+
Fe.prototype.isEmpty = function (e) {
|
1624
1624
|
return this.bMarks[e] + this.tShift[e] >= this.eMarks[e];
|
1625
1625
|
};
|
1626
|
-
|
1626
|
+
Fe.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
|
+
Fe.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
|
+
Fe.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
|
+
Fe.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
|
+
Fe.prototype.getLines = function (e, t, i, n) {
|
1644
1644
|
var r,
|
1645
1645
|
o,
|
1646
1646
|
a,
|
@@ -1793,13 +1793,13 @@ function dr(s, e, t, i) {
|
|
1793
1793
|
E,
|
1794
1794
|
S,
|
1795
1795
|
W,
|
1796
|
-
|
1796
|
+
k,
|
1797
1797
|
J,
|
1798
1798
|
Q,
|
1799
1799
|
le = !0,
|
1800
1800
|
H,
|
1801
1801
|
O,
|
1802
|
-
|
1802
|
+
_e,
|
1803
1803
|
Si;
|
1804
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;
|
@@ -1813,15 +1813,15 @@ function dr(s, e, t, i) {
|
|
1813
1813
|
type: "bullet_list_open",
|
1814
1814
|
lines: J = [e, 0],
|
1815
1815
|
level: s.level++
|
1816
|
-
}), n = e,
|
1816
|
+
}), n = e, k = !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++
|
1820
|
-
}), a = s.blkIndent, l = s.tight, o = s.tShift[e], c = s.parentType, s.tShift[e] = S - s.bMarks[e], s.blkIndent = r, s.tight = !0, s.parentType = "list", s.parser.tokenize(s, e, t, !0), (!s.tight ||
|
1820
|
+
}), a = s.blkIndent, l = s.tight, o = s.tShift[e], c = s.parentType, s.tShift[e] = S - s.bMarks[e], s.blkIndent = r, s.tight = !0, s.parentType = "list", s.parser.tokenize(s, e, t, !0), (!s.tight || k) && (le = !1), k = s.line - e > 1 && s.isEmpty(s.line - 1), s.blkIndent = a, s.tShift[e] = o, s.tight = l, s.parentType = c, s.tokens.push({
|
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,
|
1824
|
+
for (Si = !1, O = 0, _e = H.length; O < _e; O++) if (H[O](s, n, t, !0)) {
|
1825
1825
|
Si = !0;
|
1826
1826
|
break;
|
1827
1827
|
}
|
@@ -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 Fe(s, this, e, t, i), this.tokenize(n, n.line, n.lineMax);
|
2145
2145
|
};
|
2146
2146
|
function Mr(s) {
|
2147
2147
|
switch (s) {
|
@@ -2432,7 +2432,7 @@ function jr(s, e) {
|
|
2432
2432
|
content: i.replace(Dr, "$1")
|
2433
2433
|
}), s.pos = s.posMax + 1, s.posMax = n, !0);
|
2434
2434
|
}
|
2435
|
-
function
|
2435
|
+
function Fr(s, e) {
|
2436
2436
|
var t,
|
2437
2437
|
i,
|
2438
2438
|
n,
|
@@ -2476,7 +2476,7 @@ function Br(s, e) {
|
|
2476
2476
|
level: --s.level
|
2477
2477
|
}))), s.pos = a, s.posMax = h, !0;
|
2478
2478
|
}
|
2479
|
-
function
|
2479
|
+
function Br(s, e) {
|
2480
2480
|
var t,
|
2481
2481
|
i,
|
2482
2482
|
n,
|
@@ -2599,7 +2599,7 @@ function lo(s, e) {
|
|
2599
2599
|
}
|
2600
2600
|
return e || (s.pending += "&"), s.pos++, !0;
|
2601
2601
|
}
|
2602
|
-
var Ai = [["text", Tr], ["newline", Cr], ["escape", Ar], ["backticks", kr], ["del", Ir], ["ins", Lr], ["mark", Rr], ["emphasis", Nr], ["sub", Pr], ["sup", jr], ["links",
|
2602
|
+
var Ai = [["text", Tr], ["newline", Cr], ["escape", Ar], ["backticks", kr], ["del", Ir], ["ins", Lr], ["mark", Rr], ["emphasis", Nr], ["sub", Pr], ["sup", jr], ["links", Fr], ["footnote_inline", Br], ["footnote_ref", zr], ["autolink", Gr], ["htmltag", ro], ["entity", lo]];
|
2603
2603
|
function si() {
|
2604
2604
|
this.ruler = new V();
|
2605
2605
|
for (var s = 0; s < Ai.length; s++) this.ruler.push(Ai[s][0], Ai[s][1]);
|
@@ -2758,34 +2758,34 @@ var uo = {
|
|
2758
2758
|
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
|
-
function
|
2761
|
+
function pe(s, e) {
|
2762
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
|
+
pe.prototype.set = function (s) {
|
2765
2765
|
Xn(this.options, s);
|
2766
2766
|
};
|
2767
|
-
|
2767
|
+
pe.prototype.configure = function (s) {
|
2768
2768
|
var e = this;
|
2769
2769
|
if (!s) throw new Error("Wrong `remarkable` preset, check name/content");
|
2770
2770
|
s.options && e.set(s.options), s.components && Object.keys(s.components).forEach(function (t) {
|
2771
2771
|
s.components[t].rules && e[t].ruler.enable(s.components[t].rules, !0);
|
2772
2772
|
});
|
2773
2773
|
};
|
2774
|
-
|
2774
|
+
pe.prototype.use = function (s, e) {
|
2775
2775
|
return s(this, e), this;
|
2776
2776
|
};
|
2777
|
-
|
2777
|
+
pe.prototype.parse = function (s, e) {
|
2778
2778
|
var t = new os(this, s, e);
|
2779
2779
|
return this.core.process(t), t.tokens;
|
2780
2780
|
};
|
2781
|
-
|
2781
|
+
pe.prototype.render = function (s, e) {
|
2782
2782
|
return e = e || {}, this.renderer.render(this.parse(s, e), this.options, e);
|
2783
2783
|
};
|
2784
|
-
|
2784
|
+
pe.prototype.parseInline = function (s, e) {
|
2785
2785
|
var t = new os(this, s, e);
|
2786
2786
|
return t.inlineMode = !0, this.core.process(t), t.tokens;
|
2787
2787
|
};
|
2788
|
-
|
2788
|
+
pe.prototype.renderInline = function (s, e) {
|
2789
2789
|
return e = e || {}, this.renderer.render(this.parseInline(s, e), this.options, e);
|
2790
2790
|
};
|
2791
2791
|
var vt = /*#__PURE__*/function () {
|
@@ -2796,7 +2796,7 @@ var vt = /*#__PURE__*/function () {
|
|
2796
2796
|
key: "instantiate",
|
2797
2797
|
value: function instantiate() {
|
2798
2798
|
var e = window.hljs;
|
2799
|
-
return e ? new
|
2799
|
+
return e ? new pe({
|
2800
2800
|
highlight: function highlight(t, i) {
|
2801
2801
|
if (i && e.getLanguage(i)) try {
|
2802
2802
|
return e.highlight(i, t).value;
|
@@ -2822,7 +2822,7 @@ var vt = /*#__PURE__*/function () {
|
|
2822
2822
|
// set target to open in a new tab
|
2823
2823
|
typographer: !0
|
2824
2824
|
// Enable smartypants and other sweet transforms
|
2825
|
-
}) : new
|
2825
|
+
}) : new pe({
|
2826
2826
|
highlight: function highlight(t) {
|
2827
2827
|
return t;
|
2828
2828
|
},
|
@@ -2911,11 +2911,11 @@ var as = /*#__PURE__*/function () {
|
|
2911
2911
|
}();
|
2912
2912
|
as.DEFAULT_FILE_NAME = "file";
|
2913
2913
|
var re = as;
|
2914
|
-
var
|
2915
|
-
function
|
2916
|
-
_classCallCheck(this,
|
2914
|
+
var Bt = /*#__PURE__*/function () {
|
2915
|
+
function Bt() {
|
2916
|
+
_classCallCheck(this, Bt);
|
2917
2917
|
}
|
2918
|
-
_createClass(
|
2918
|
+
_createClass(Bt, null, [{
|
2919
2919
|
key: "onNewMessage",
|
2920
2920
|
value: function onNewMessage(e, t, i) {
|
2921
2921
|
var r;
|
@@ -2950,7 +2950,7 @@ var Ft = /*#__PURE__*/function () {
|
|
2950
2950
|
}));
|
2951
2951
|
}
|
2952
2952
|
}]);
|
2953
|
-
return
|
2953
|
+
return Bt;
|
2954
2954
|
}();
|
2955
2955
|
var D = /*#__PURE__*/function () {
|
2956
2956
|
function D() {
|
@@ -3006,7 +3006,7 @@ var Ye = /*#__PURE__*/function () {
|
|
3006
3006
|
function Ye(e) {
|
3007
3007
|
var _this3 = this;
|
3008
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 =
|
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 = Bt.onNewMessage.bind(this, e), e.htmlClassUtilities && (this.htmlClassUtilities = e.htmlClassUtilities), setTimeout(function () {
|
3010
3010
|
_this3.submitUserMessage = e.submitUserMessage;
|
3011
3011
|
});
|
3012
3012
|
}
|
@@ -3115,7 +3115,7 @@ var Ye = /*#__PURE__*/function () {
|
|
3115
3115
|
}, {
|
3116
3116
|
key: "isTemporaryElement",
|
3117
3117
|
value: function isTemporaryElement(e) {
|
3118
|
-
return (e == null ? void 0 : e.bubbleElement.classList.contains("loading-message-text")) ||
|
3118
|
+
return (e == null ? void 0 : e.bubbleElement.classList.contains("loading-message-text")) || ye.isElementTemporary(e);
|
3119
3119
|
}
|
3120
3120
|
}, {
|
3121
3121
|
key: "createBaseElements",
|
@@ -3150,19 +3150,19 @@ var Ki = /*#__PURE__*/function () {
|
|
3150
3150
|
// used for extracting at end and for isStreaming
|
3151
3151
|
function ot(e) {
|
3152
3152
|
_classCallCheck(this, ot);
|
3153
|
-
this._streamedContent = "", this._streamType = "", this._hasStreamEnded = !1, this._messages = e;
|
3153
|
+
this._fileAdded = !1, this._streamedContent = "", this._streamType = "", this._hasStreamEnded = !1, this._messages = e;
|
3154
3154
|
}
|
3155
3155
|
_createClass(ot, [{
|
3156
3156
|
key: "upsertStreamedMessage",
|
3157
3157
|
value: function upsertStreamedMessage(e) {
|
3158
3158
|
var r;
|
3159
3159
|
if (this._hasStreamEnded) return;
|
3160
|
-
if ((e == null ? void 0 : e.text) === void 0 && (e == null ? void 0 : e.html) === void 0) return console.error(
|
3160
|
+
if ((e == null ? void 0 : e.text) === void 0 && (e == null ? void 0 : e.html) === void 0) return console.error(A.INVALID_STREAM_EVENT);
|
3161
3161
|
var t = (e == null ? void 0 : e.text) || (e == null ? void 0 : e.html) || "",
|
3162
3162
|
i = Z.isScrollbarAtBottomOfElement(this._messages.elementRef),
|
3163
3163
|
n = (e == null ? void 0 : e.text) !== void 0 ? "text" : "html";
|
3164
3164
|
if (!this._elements && this._streamedContent === "") this.setInitialState(n, t, e == null ? void 0 : e.role);else {
|
3165
|
-
if (this._streamType !== n) return console.error(
|
3165
|
+
if (this._streamType !== n) return console.error(A.INVALID_STREAM_EVENT_MIX);
|
3166
3166
|
this.updateBasedOnType(t, n, (r = this._elements) == null ? void 0 : r.bubbleElement, e == null ? void 0 : e.overwrite);
|
3167
3167
|
}
|
3168
3168
|
i && Z.scrollToBottom(this._messages.elementRef);
|
@@ -3195,17 +3195,20 @@ var Ki = /*#__PURE__*/function () {
|
|
3195
3195
|
}, {
|
3196
3196
|
key: "finaliseStreamedMessage",
|
3197
3197
|
value: function finaliseStreamedMessage() {
|
3198
|
-
var
|
3199
|
-
var
|
3200
|
-
|
3201
|
-
|
3202
|
-
|
3203
|
-
|
3204
|
-
if (!(i != null && i.contains(ot.MESSAGE_CLASS))) return;
|
3205
|
-
var n = {
|
3198
|
+
var i, n;
|
3199
|
+
var e = this._messages.textElementsToText;
|
3200
|
+
if (this._fileAdded && !this._elements) return;
|
3201
|
+
if (!this._elements) throw Error(A.NO_VALID_STREAM_EVENTS_SENT);
|
3202
|
+
if (!((i = this._elements.bubbleElement) != null && i.classList.contains(ot.MESSAGE_CLASS))) return;
|
3203
|
+
var t = {
|
3206
3204
|
role: this._activeMessageRole || b.AI_ROLE
|
3207
3205
|
};
|
3208
|
-
this._streamType === "text" ? (e[e.length - 1][1] = this._streamedContent,
|
3206
|
+
this._streamType === "text" ? (e[e.length - 1][1] = this._streamedContent, t.text = this._streamedContent, this._messages.textToSpeech && jt.speak(this._streamedContent, this._messages.textToSpeech)) : this._streamType === "html" && (this._streamedContent === ot.HTML_CONTENT_PLACEHOLDER && (this._streamedContent = ((n = this._elements.bubbleElement) == null ? void 0 : n.innerHTML) || ""), this._elements && oe.apply(this._messages, this._elements.outerContainer), t.html = this._streamedContent), t && (this._messages.messages.push(t), this._messages.sendClientUpdate(Ye.createMessageContent(t), !1)), this._hasStreamEnded = !0;
|
3207
|
+
}
|
3208
|
+
}, {
|
3209
|
+
key: "markFileAded",
|
3210
|
+
value: function markFileAded() {
|
3211
|
+
this._fileAdded = !0;
|
3209
3212
|
}
|
3210
3213
|
}]);
|
3211
3214
|
return ot;
|
@@ -3445,7 +3448,7 @@ var yo = globalThis && globalThis.__rest || function (s, e) {
|
|
3445
3448
|
if (s != null && typeof Object.getOwnPropertySymbols == "function") for (var n = 0, i = Object.getOwnPropertySymbols(s); n < i.length; n++) e.indexOf(i[n]) < 0 && Object.prototype.propertyIsEnumerable.call(s, i[n]) && (t[i[n]] = s[i[n]]);
|
3446
3449
|
return t;
|
3447
3450
|
};
|
3448
|
-
var
|
3451
|
+
var Fi = "text/event-stream",
|
3449
3452
|
xo = 1e3,
|
3450
3453
|
_n = "last-event-id";
|
3451
3454
|
function Eo(s, e) {
|
@@ -3460,7 +3463,7 @@ function Eo(s, e) {
|
|
3460
3463
|
d = yo(e, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
3461
3464
|
return new Promise(function (u, h) {
|
3462
3465
|
var p = Object.assign({}, i);
|
3463
|
-
p.accept || (p.accept =
|
3466
|
+
p.accept || (p.accept = Fi);
|
3464
3467
|
var g;
|
3465
3468
|
function f() {
|
3466
3469
|
g.abort(), document.hidden || Q();
|
@@ -3474,7 +3477,7 @@ function Eo(s, e) {
|
|
3474
3477
|
t == null || t.addEventListener("abort", function () {
|
3475
3478
|
W(), u();
|
3476
3479
|
});
|
3477
|
-
var
|
3480
|
+
var k = c !== null && c !== void 0 ? c : window.fetch,
|
3478
3481
|
J = n !== null && n !== void 0 ? n : _o;
|
3479
3482
|
function Q() {
|
3480
3483
|
return _Q.apply(this, arguments);
|
@@ -3488,7 +3491,7 @@ function Eo(s, e) {
|
|
3488
3491
|
g = new AbortController();
|
3489
3492
|
_context3.prev = 1;
|
3490
3493
|
_context3.next = 4;
|
3491
|
-
return
|
3494
|
+
return k(s, Object.assign(Object.assign({}, d), {
|
3492
3495
|
headers: p,
|
3493
3496
|
signal: g.signal
|
3494
3497
|
}));
|
@@ -3531,13 +3534,13 @@ function Eo(s, e) {
|
|
3531
3534
|
}
|
3532
3535
|
function _o(s) {
|
3533
3536
|
var e = s.headers.get("content-type");
|
3534
|
-
if (!(e != null && e.startsWith(
|
3537
|
+
if (!(e != null && e.startsWith(Fi))) throw new Error("Expected content-type to be ".concat(Fi, ", Actual: ").concat(e));
|
3535
3538
|
}
|
3536
|
-
var
|
3537
|
-
function
|
3538
|
-
_classCallCheck(this,
|
3539
|
+
var T = /*#__PURE__*/function () {
|
3540
|
+
function T() {
|
3541
|
+
_classCallCheck(this, T);
|
3539
3542
|
}
|
3540
|
-
_createClass(
|
3543
|
+
_createClass(T, null, [{
|
3541
3544
|
key: "request",
|
3542
3545
|
value: // prettier-ignore
|
3543
3546
|
function () {
|
@@ -3589,13 +3592,13 @@ var I = /*#__PURE__*/function () {
|
|
3589
3592
|
_context6.next = 16;
|
3590
3593
|
break;
|
3591
3594
|
}
|
3592
|
-
return _context6.abrupt("return",
|
3595
|
+
return _context6.abrupt("return", ue.stream(e, o, i));
|
3593
3596
|
case 16:
|
3594
|
-
if (!(((f = e.requestSettings) == null ? void 0 : f.url) ===
|
3597
|
+
if (!(((f = e.requestSettings) == null ? void 0 : f.url) === xe.URL)) {
|
3595
3598
|
_context6.next = 18;
|
3596
3599
|
break;
|
3597
3600
|
}
|
3598
|
-
return _context6.abrupt("return",
|
3601
|
+
return _context6.abrupt("return", xe.requestStream(i, e.streamHandlers));
|
3599
3602
|
case 18:
|
3600
3603
|
h = new Oe(i);
|
3601
3604
|
Eo(((E = e.requestSettings) == null ? void 0 : E.url) || e.url || "", {
|
@@ -3605,19 +3608,19 @@ var I = /*#__PURE__*/function () {
|
|
3605
3608
|
body: n ? JSON.stringify(o) : o,
|
3606
3609
|
openWhenHidden: !0,
|
3607
3610
|
// keep stream open when browser tab not open
|
3608
|
-
onopen: function onopen(
|
3611
|
+
onopen: function onopen(k) {
|
3609
3612
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
3610
3613
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
3611
3614
|
while (1) switch (_context4.prev = _context4.next) {
|
3612
3615
|
case 0:
|
3613
|
-
if (!
|
3616
|
+
if (!k.ok) {
|
3614
3617
|
_context4.next = 2;
|
3615
3618
|
break;
|
3616
3619
|
}
|
3617
3620
|
return _context4.abrupt("return", c());
|
3618
3621
|
case 2:
|
3619
3622
|
_context4.next = 4;
|
3620
|
-
return _.processResponseByType(
|
3623
|
+
return _.processResponseByType(k);
|
3621
3624
|
case 4:
|
3622
3625
|
throw _context4.sent;
|
3623
3626
|
case 5:
|
@@ -3627,18 +3630,18 @@ var I = /*#__PURE__*/function () {
|
|
3627
3630
|
}, _callee4);
|
3628
3631
|
}))();
|
3629
3632
|
},
|
3630
|
-
onmessage: function onmessage(
|
3633
|
+
onmessage: function onmessage(k) {
|
3631
3634
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
3632
3635
|
var J, Q, le, H, O;
|
3633
3636
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
3634
3637
|
while (1) switch (_context5.prev = _context5.next) {
|
3635
3638
|
case 0:
|
3636
|
-
if (!(JSON.stringify(
|
3639
|
+
if (!(JSON.stringify(k.data) !== JSON.stringify("[DONE]"))) {
|
3637
3640
|
_context5.next = 9;
|
3638
3641
|
break;
|
3639
3642
|
}
|
3640
3643
|
try {
|
3641
|
-
H = JSON.parse(
|
3644
|
+
H = JSON.parse(k.data);
|
3642
3645
|
} catch (_unused6) {
|
3643
3646
|
H = {};
|
3644
3647
|
}
|
@@ -3653,10 +3656,10 @@ var I = /*#__PURE__*/function () {
|
|
3653
3656
|
_context5.t0 = H;
|
3654
3657
|
case 7:
|
3655
3658
|
O = _context5.t0;
|
3656
|
-
(le = e.extractResultData) == null || le.call(e, O).then(function (
|
3657
|
-
h.upsertStreamedMessage(
|
3658
|
-
})["catch"](function (
|
3659
|
-
return _.displayError(i,
|
3659
|
+
(le = e.extractResultData) == null || le.call(e, O).then(function (_e) {
|
3660
|
+
T.upsertWFiles(i, h.upsertStreamedMessage.bind(h), h, _e);
|
3661
|
+
})["catch"](function (_e) {
|
3662
|
+
return _.displayError(i, _e);
|
3660
3663
|
});
|
3661
3664
|
case 9:
|
3662
3665
|
case "end":
|
@@ -3665,17 +3668,17 @@ var I = /*#__PURE__*/function () {
|
|
3665
3668
|
}, _callee5);
|
3666
3669
|
}))();
|
3667
3670
|
},
|
3668
|
-
onerror: function onerror(
|
3669
|
-
throw d(),
|
3671
|
+
onerror: function onerror(k) {
|
3672
|
+
throw d(), k;
|
3670
3673
|
},
|
3671
3674
|
onclose: function onclose() {
|
3672
3675
|
h.finaliseStreamedMessage(), d();
|
3673
3676
|
},
|
3674
3677
|
signal: u.signal
|
3675
|
-
})["catch"](function (
|
3678
|
+
})["catch"](function (k) {
|
3676
3679
|
var J;
|
3677
|
-
(J = e.extractResultData) == null || J.call(e,
|
3678
|
-
_.displayError(i,
|
3680
|
+
(J = e.extractResultData) == null || J.call(e, k).then(function () {
|
3681
|
+
_.displayError(i, k);
|
3679
3682
|
})["catch"](function (Q) {
|
3680
3683
|
_.displayError(i, Q);
|
3681
3684
|
});
|
@@ -3701,7 +3704,7 @@ var I = /*#__PURE__*/function () {
|
|
3701
3704
|
}, i), !1), i.text) {
|
3702
3705
|
t.onOpen();
|
3703
3706
|
var r = i.text.split("");
|
3704
|
-
|
3707
|
+
T.populateMessages(r, new Oe(e), n);
|
3705
3708
|
}
|
3706
3709
|
}
|
3707
3710
|
}, {
|
@@ -3714,10 +3717,10 @@ var I = /*#__PURE__*/function () {
|
|
3714
3717
|
text: r
|
3715
3718
|
});
|
3716
3719
|
var o = setTimeout(function () {
|
3717
|
-
|
3720
|
+
T.populateMessages(e, t, i, n + 1);
|
3718
3721
|
}, i.simulationInterim || 6);
|
3719
3722
|
i.abortStream.abort = function () {
|
3720
|
-
|
3723
|
+
T.abort(o, t, i.onClose);
|
3721
3724
|
};
|
3722
3725
|
} else t.finaliseStreamedMessage(), i.onClose();
|
3723
3726
|
}
|
@@ -3726,13 +3729,30 @@ var I = /*#__PURE__*/function () {
|
|
3726
3729
|
value: function isSimulation(e) {
|
3727
3730
|
return _typeof(e) == "object" && !!e.simulation;
|
3728
3731
|
}
|
3732
|
+
}, {
|
3733
|
+
key: "isSimulatable",
|
3734
|
+
value: function isSimulatable(e, t) {
|
3735
|
+
return T.isSimulation(e) && t && (t.text || t.html);
|
3736
|
+
}
|
3729
3737
|
}, {
|
3730
3738
|
key: "abort",
|
3731
3739
|
value: function abort(e, t, i) {
|
3732
3740
|
clearTimeout(e), t.finaliseStreamedMessage(), i();
|
3733
3741
|
}
|
3742
|
+
}, {
|
3743
|
+
key: "upsertWFiles",
|
3744
|
+
value: function upsertWFiles(e, t, i, n) {
|
3745
|
+
if (n != null && n.text || n != null && n.html) {
|
3746
|
+
var _i9;
|
3747
|
+
var r = t(n);
|
3748
|
+
(_i9 = i) !== null && _i9 !== void 0 ? _i9 : i = r || void 0;
|
3749
|
+
}
|
3750
|
+
n != null && n.files && (e.addNewMessage({
|
3751
|
+
files: n.files
|
3752
|
+
}), i == null || i.markFileAded());
|
3753
|
+
}
|
3734
3754
|
}]);
|
3735
|
-
return
|
3755
|
+
return T;
|
3736
3756
|
}();
|
3737
3757
|
var cs = /*#__PURE__*/function () {
|
3738
3758
|
function lt() {
|
@@ -3786,7 +3806,7 @@ var cs = /*#__PURE__*/function () {
|
|
3786
3806
|
_context7.t0 = i;
|
3787
3807
|
case 5:
|
3788
3808
|
n = _context7.t0;
|
3789
|
-
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) :
|
3809
|
+
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) : T.isSimulatable(e.deepChat.stream, n) ? T.simulate(t, e.streamHandlers, n) : (t.addNewMessage(n), e.completionsHandlers.onFinish());
|
3790
3810
|
case 7:
|
3791
3811
|
case "end":
|
3792
3812
|
return _context7.stop();
|
@@ -3800,22 +3820,22 @@ var cs = /*#__PURE__*/function () {
|
|
3800
3820
|
value: function requestStream(e, t) {
|
3801
3821
|
setTimeout(function () {
|
3802
3822
|
var i = lt.getResponse(e);
|
3803
|
-
|
3823
|
+
T.simulate(e, t, i);
|
3804
3824
|
}, 400);
|
3805
3825
|
}
|
3806
3826
|
}]);
|
3807
3827
|
return lt;
|
3808
3828
|
}();
|
3809
3829
|
cs.URL = "deep-chat-demo";
|
3810
|
-
var
|
3811
|
-
var
|
3812
|
-
function
|
3813
|
-
_classCallCheck(this,
|
3830
|
+
var xe = cs;
|
3831
|
+
var B = /*#__PURE__*/function () {
|
3832
|
+
function B() {
|
3833
|
+
_classCallCheck(this, B);
|
3814
3834
|
}
|
3815
|
-
_createClass(
|
3835
|
+
_createClass(B, null, [{
|
3816
3836
|
key: "setup",
|
3817
3837
|
value: function setup(e) {
|
3818
|
-
e.requestSettings.url !==
|
3838
|
+
e.requestSettings.url !== xe.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
|
3819
3839
|
}
|
3820
3840
|
}, {
|
3821
3841
|
key: "createConnection",
|
@@ -3823,18 +3843,18 @@ var F = /*#__PURE__*/function () {
|
|
3823
3843
|
if (!document.body.contains(e.deepChat)) return;
|
3824
3844
|
var i = e.requestSettings.websocket;
|
3825
3845
|
if (i) {
|
3826
|
-
if (e.requestSettings.handler) return
|
3846
|
+
if (e.requestSettings.handler) return ue.websocket(e, t);
|
3827
3847
|
try {
|
3828
3848
|
var n = typeof i != "boolean" ? i : void 0,
|
3829
3849
|
r = new WebSocket(e.requestSettings.url || "", n);
|
3830
3850
|
e.websocket = r, e.websocket.onopen = function () {
|
3831
3851
|
var o, a;
|
3832
|
-
t.removeError(), e.websocket && _typeof(e.websocket) == "object" &&
|
3852
|
+
t.removeError(), e.websocket && _typeof(e.websocket) == "object" && B.assignListeners(e, r, t), (a = (o = e.deepChat)._validationHandler) == null || a.call(o);
|
3833
3853
|
}, e.websocket.onerror = function (o) {
|
3834
|
-
console.error(o),
|
3854
|
+
console.error(o), B.retryConnection(e, t);
|
3835
3855
|
};
|
3836
3856
|
} catch (n) {
|
3837
|
-
console.error(n),
|
3857
|
+
console.error(n), B.retryConnection(e, t);
|
3838
3858
|
}
|
3839
3859
|
}
|
3840
3860
|
}
|
@@ -3843,16 +3863,17 @@ var F = /*#__PURE__*/function () {
|
|
3843
3863
|
value: function retryConnection(e, t) {
|
3844
3864
|
var i, n;
|
3845
3865
|
(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
|
-
|
3866
|
+
B.createConnection(e, t);
|
3847
3867
|
}, 5e3));
|
3848
3868
|
}
|
3849
3869
|
}, {
|
3850
3870
|
key: "assignListeners",
|
3851
3871
|
value: function assignListeners(e, t, i) {
|
3872
|
+
var _this6 = this;
|
3852
3873
|
var n = {};
|
3853
3874
|
t.onmessage = /*#__PURE__*/function () {
|
3854
3875
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(r) {
|
3855
|
-
var o, a, l, c, d;
|
3876
|
+
var o, a, l, c, d, u, h;
|
3856
3877
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
3857
3878
|
while (1) switch (_context8.prev = _context8.next) {
|
3858
3879
|
case 0:
|
@@ -3881,9 +3902,12 @@ var F = /*#__PURE__*/function () {
|
|
3881
3902
|
_context8.next = 14;
|
3882
3903
|
break;
|
3883
3904
|
}
|
3884
|
-
throw Error(
|
3905
|
+
throw Error(A.INVALID_RESPONSE(l, "server", !!e.deepChat.responseInterceptor, c));
|
3885
3906
|
case 14:
|
3886
|
-
|
3907
|
+
if (T.isSimulation(e.deepChat.stream)) {
|
3908
|
+
u = B.stream.bind(_this6, e, i, n), h = n[l.role || b.AI_ROLE];
|
3909
|
+
T.upsertWFiles(i, u, h, d);
|
3910
|
+
} else i.addNewMessage(d);
|
3887
3911
|
_context8.next = 20;
|
3888
3912
|
break;
|
3889
3913
|
case 17:
|
@@ -3900,7 +3924,7 @@ var F = /*#__PURE__*/function () {
|
|
3900
3924
|
return _ref2.apply(this, arguments);
|
3901
3925
|
};
|
3902
3926
|
}(), t.onclose = function () {
|
3903
|
-
console.error("Connection closed"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error"), e.deepChat.stream && e.streamHandlers.abortStream.abort(),
|
3927
|
+
console.error("Connection closed"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error"), e.deepChat.stream && e.streamHandlers.abortStream.abort(), B.createConnection(e, i);
|
3904
3928
|
};
|
3905
3929
|
}
|
3906
3930
|
}, {
|
@@ -3944,18 +3968,18 @@ var F = /*#__PURE__*/function () {
|
|
3944
3968
|
}
|
3945
3969
|
return _context9.abrupt("return", i.addNewErrorMessage("service", l));
|
3946
3970
|
case 12:
|
3947
|
-
if (
|
3971
|
+
if (B.isWebSocket(r)) {
|
3948
3972
|
_context9.next = 14;
|
3949
3973
|
break;
|
3950
3974
|
}
|
3951
3975
|
return _context9.abrupt("return", r.newUserMessage.listener(a));
|
3952
3976
|
case 14:
|
3953
3977
|
c = n ? JSON.stringify(a) : a;
|
3954
|
-
if (!(((u = e.requestSettings) == null ? void 0 : u.url) ===
|
3978
|
+
if (!(((u = e.requestSettings) == null ? void 0 : u.url) === xe.URL)) {
|
3955
3979
|
_context9.next = 17;
|
3956
3980
|
break;
|
3957
3981
|
}
|
3958
|
-
return _context9.abrupt("return",
|
3982
|
+
return _context9.abrupt("return", xe.request(e, i));
|
3959
3983
|
case 17:
|
3960
3984
|
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
3985
|
case 18:
|
@@ -3972,7 +3996,7 @@ var F = /*#__PURE__*/function () {
|
|
3972
3996
|
}, {
|
3973
3997
|
key: "canSendMessage",
|
3974
3998
|
value: function canSendMessage(e) {
|
3975
|
-
return e ? e === "pending" ? !1 :
|
3999
|
+
return e ? e === "pending" ? !1 : B.isWebSocket(e) ? e.readyState !== void 0 && e.readyState === e.OPEN : e.isOpen : !0;
|
3976
4000
|
}
|
3977
4001
|
// if false then it is the internal websocket handler
|
3978
4002
|
}, {
|
@@ -3983,22 +4007,23 @@ var F = /*#__PURE__*/function () {
|
|
3983
4007
|
}, {
|
3984
4008
|
key: "stream",
|
3985
4009
|
value: function stream(e, t, i, n) {
|
4010
|
+
if (!n) return;
|
3986
4011
|
var r = e.deepChat.stream.simulation;
|
3987
4012
|
if (typeof r == "string") {
|
3988
|
-
var
|
3989
|
-
var o =
|
3990
|
-
a =
|
3991
|
-
|
3992
|
-
} else
|
4013
|
+
var _i$o;
|
4014
|
+
var o = n.role || b.AI_ROLE,
|
4015
|
+
a = i[o];
|
4016
|
+
n.text === r ? (a == null || a.finaliseStreamedMessage(), delete i[o]) : ((_i$o = i[o]) !== null && _i$o !== void 0 ? _i$o : i[o] = new Oe(t), i[o].upsertStreamedMessage(n));
|
4017
|
+
} else T.simulate(t, e.streamHandlers, n);
|
3993
4018
|
}
|
3994
4019
|
}]);
|
3995
|
-
return
|
4020
|
+
return B;
|
3996
4021
|
}();
|
3997
|
-
var
|
3998
|
-
function
|
3999
|
-
_classCallCheck(this,
|
4022
|
+
var ue = /*#__PURE__*/function () {
|
4023
|
+
function ue() {
|
4024
|
+
_classCallCheck(this, ue);
|
4000
4025
|
}
|
4001
|
-
_createClass(
|
4026
|
+
_createClass(ue, null, [{
|
4002
4027
|
key: "request",
|
4003
4028
|
value: function () {
|
4004
4029
|
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(e, t, i) {
|
@@ -4031,7 +4056,7 @@ var Le = /*#__PURE__*/function () {
|
|
4031
4056
|
_context10.t0 = c;
|
4032
4057
|
case 8:
|
4033
4058
|
d = _context10.t0;
|
4034
|
-
_.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), i.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) :
|
4059
|
+
_.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), i.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) : T.isSimulatable(e.deepChat.stream, d) ? T.simulate(i, e.streamHandlers, d) : (i.addNewMessage(d), e.completionsHandlers.onFinish()) : (console.error(A.INVALID_RESPONSE(c, "server", !!e.deepChat.responseInterceptor, d)), i.addNewErrorMessage("service", "Error in server message"), e.completionsHandlers.onFinish());
|
4035
4060
|
case 10:
|
4036
4061
|
case "end":
|
4037
4062
|
return _context10.stop();
|
@@ -4041,7 +4066,7 @@ var Le = /*#__PURE__*/function () {
|
|
4041
4066
|
return function r(_x22) {
|
4042
4067
|
return _ref3.apply(this, arguments);
|
4043
4068
|
};
|
4044
|
-
}(), o =
|
4069
|
+
}(), o = ue.generateOptionalSignals();
|
4045
4070
|
(l = (a = e.requestSettings).handler) == null || l.call(a, t, _objectSpread(_objectSpread({}, o), {}, {
|
4046
4071
|
onResponse: r
|
4047
4072
|
}));
|
@@ -4055,7 +4080,18 @@ var Le = /*#__PURE__*/function () {
|
|
4055
4080
|
return _request2.apply(this, arguments);
|
4056
4081
|
}
|
4057
4082
|
return request;
|
4058
|
-
}()
|
4083
|
+
}()
|
4084
|
+
}, {
|
4085
|
+
key: "attemptToFinaliseStream",
|
4086
|
+
value: function attemptToFinaliseStream(e, t) {
|
4087
|
+
try {
|
4088
|
+
e.finaliseStreamedMessage();
|
4089
|
+
} catch (i) {
|
4090
|
+
console.error(i), t.addNewErrorMessage("service", i);
|
4091
|
+
}
|
4092
|
+
}
|
4093
|
+
// interceptor?
|
4094
|
+
// prettier-ignore
|
4059
4095
|
}, {
|
4060
4096
|
key: "stream",
|
4061
4097
|
value: function stream(e, t, i) {
|
@@ -4067,15 +4103,15 @@ var Le = /*#__PURE__*/function () {
|
|
4067
4103
|
r || !n || (e.streamHandlers.onOpen(), r = !0);
|
4068
4104
|
},
|
4069
4105
|
l = function l() {
|
4070
|
-
n && (
|
4106
|
+
n && (ue.attemptToFinaliseStream(o, i), e.streamHandlers.onClose(), n = !1);
|
4071
4107
|
},
|
4072
4108
|
c = function c(p) {
|
4073
|
-
n && (!p || _typeof(p) != "object"
|
4109
|
+
n && (!p || _typeof(p) != "object" ? console.error(A.INVALID_RESPONSE(p, "server", !1)) : p.error ? (console.error(p.error), i.addNewErrorMessage("service", p.error), e.streamHandlers.onClose(), n = !1) : T.upsertWFiles(i, o.upsertStreamedMessage.bind(o), o, p));
|
4074
4110
|
};
|
4075
4111
|
e.streamHandlers.abortStream.abort = function () {
|
4076
|
-
|
4112
|
+
ue.attemptToFinaliseStream(o, i), e.streamHandlers.onClose(), n = !1;
|
4077
4113
|
};
|
4078
|
-
var d =
|
4114
|
+
var d = ue.generateOptionalSignals();
|
4079
4115
|
(h = (u = e.requestSettings).handler) == null || h.call(u, t, _objectSpread(_objectSpread({}, d), {}, {
|
4080
4116
|
onOpen: a,
|
4081
4117
|
onResponse: c,
|
@@ -4087,6 +4123,7 @@ var Le = /*#__PURE__*/function () {
|
|
4087
4123
|
}, {
|
4088
4124
|
key: "websocket",
|
4089
4125
|
value: function websocket(e, t) {
|
4126
|
+
var _this7 = this;
|
4090
4127
|
var l, c;
|
4091
4128
|
var i = {
|
4092
4129
|
isOpen: !1,
|
@@ -4104,7 +4141,7 @@ var Le = /*#__PURE__*/function () {
|
|
4104
4141
|
},
|
4105
4142
|
o = /*#__PURE__*/function () {
|
4106
4143
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(d) {
|
4107
|
-
var h, p, u;
|
4144
|
+
var h, p, u, g, f;
|
4108
4145
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
4109
4146
|
while (1) switch (_context12.prev = _context12.next) {
|
4110
4147
|
case 0:
|
@@ -4125,7 +4162,10 @@ var Le = /*#__PURE__*/function () {
|
|
4125
4162
|
_context12.t0 = d;
|
4126
4163
|
case 7:
|
4127
4164
|
u = _context12.t0;
|
4128
|
-
_.validateResponseFormat(u)
|
4165
|
+
if (!_.validateResponseFormat(u)) console.error(A.INVALID_RESPONSE(d, "server", !!e.deepChat.responseInterceptor, u)), t.addNewErrorMessage("service", "Error in server message");else if (typeof u.error == "string") console.error(u.error), t.isLastMessageError() || t.addNewErrorMessage("service", u.error);else if (T.isSimulation(e.deepChat.stream)) {
|
4166
|
+
g = B.stream.bind(_this7, e, t, i.roleToStream), f = i.roleToStream[d.role || b.AI_ROLE];
|
4167
|
+
T.upsertWFiles(t, g, f, d);
|
4168
|
+
} else t.addNewMessage(u);
|
4129
4169
|
case 9:
|
4130
4170
|
case "end":
|
4131
4171
|
return _context12.stop();
|
@@ -4136,7 +4176,7 @@ var Le = /*#__PURE__*/function () {
|
|
4136
4176
|
return _ref4.apply(this, arguments);
|
4137
4177
|
};
|
4138
4178
|
}(),
|
4139
|
-
a =
|
4179
|
+
a = ue.generateOptionalSignals();
|
4140
4180
|
(c = (l = e.requestSettings).handler) == null || c.call(l, void 0, _objectSpread(_objectSpread({}, a), {}, {
|
4141
4181
|
onOpen: n,
|
4142
4182
|
onResponse: o,
|
@@ -4159,7 +4199,7 @@ var Le = /*#__PURE__*/function () {
|
|
4159
4199
|
};
|
4160
4200
|
}
|
4161
4201
|
}]);
|
4162
|
-
return
|
4202
|
+
return ue;
|
4163
4203
|
}();
|
4164
4204
|
var w = /*#__PURE__*/function () {
|
4165
4205
|
function w() {
|
@@ -4209,13 +4249,13 @@ var w = /*#__PURE__*/function () {
|
|
4209
4249
|
_context14.next = 13;
|
4210
4250
|
break;
|
4211
4251
|
}
|
4212
|
-
return _context14.abrupt("return",
|
4252
|
+
return _context14.abrupt("return", ue.request(e, o, i));
|
4213
4253
|
case 13:
|
4214
|
-
if (!(((g = e.requestSettings) == null ? void 0 : g.url) ===
|
4254
|
+
if (!(((g = e.requestSettings) == null ? void 0 : g.url) === xe.URL)) {
|
4215
4255
|
_context14.next = 15;
|
4216
4256
|
break;
|
4217
4257
|
}
|
4218
|
-
return _context14.abrupt("return",
|
4258
|
+
return _context14.abrupt("return", xe.request(e, i));
|
4219
4259
|
case 15:
|
4220
4260
|
d = !0;
|
4221
4261
|
u = _.fetch.bind(this, e, a, n);
|
@@ -4225,7 +4265,7 @@ var w = /*#__PURE__*/function () {
|
|
4225
4265
|
return _.processResponseByType(f);
|
4226
4266
|
}).then( /*#__PURE__*/function () {
|
4227
4267
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(f) {
|
4228
|
-
var W,
|
4268
|
+
var W, k, E, S;
|
4229
4269
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
4230
4270
|
while (1) switch (_context13.prev = _context13.next) {
|
4231
4271
|
case 0:
|
@@ -4236,7 +4276,7 @@ var w = /*#__PURE__*/function () {
|
|
4236
4276
|
return _context13.abrupt("return");
|
4237
4277
|
case 2:
|
4238
4278
|
_context13.next = 4;
|
4239
|
-
return (
|
4279
|
+
return (k = (W = e.deepChat).responseInterceptor) == null ? void 0 : k.call(W, f);
|
4240
4280
|
case 4:
|
4241
4281
|
_context13.t0 = _context13.sent;
|
4242
4282
|
if (_context13.t0) {
|
@@ -4260,9 +4300,9 @@ var w = /*#__PURE__*/function () {
|
|
4260
4300
|
_context13.next = 15;
|
4261
4301
|
break;
|
4262
4302
|
}
|
4263
|
-
throw Error(
|
4303
|
+
throw Error(A.INVALID_RESPONSE(f, "response", !!e.deepChat.responseInterceptor, E));
|
4264
4304
|
case 15:
|
4265
|
-
S.makingAnotherRequest || (
|
4305
|
+
S.makingAnotherRequest || (T.isSimulatable(e.deepChat.stream, S) ? T.simulate(i, e.streamHandlers, S) : (i.addNewMessage(S), c()));
|
4266
4306
|
case 16:
|
4267
4307
|
case "end":
|
4268
4308
|
return _context13.stop();
|
@@ -4322,7 +4362,7 @@ var w = /*#__PURE__*/function () {
|
|
4322
4362
|
a = _context15.sent;
|
4323
4363
|
a.timeoutMS ? setTimeout(function () {
|
4324
4364
|
w.executePollRequest(e, t, i, n);
|
4325
|
-
}, a.timeoutMS) :
|
4365
|
+
}, a.timeoutMS) : T.isSimulatable(e.deepChat.stream, o) ? T.simulate(n, e.streamHandlers, a) : (n.addNewMessage(a), r());
|
4326
4366
|
case 13:
|
4327
4367
|
case "end":
|
4328
4368
|
return _context15.stop();
|
@@ -4396,7 +4436,7 @@ var w = /*#__PURE__*/function () {
|
|
4396
4436
|
}, {
|
4397
4437
|
key: "verifyKey",
|
4398
4438
|
value: function verifyKey(e, t, i, n, r, o, a, l, c) {
|
4399
|
-
if (e === "") return o(
|
4439
|
+
if (e === "") return o(A.INVALID_KEY);
|
4400
4440
|
a(), fetch(t, {
|
4401
4441
|
method: n,
|
4402
4442
|
headers: i,
|
@@ -4406,7 +4446,7 @@ var w = /*#__PURE__*/function () {
|
|
4406
4446
|
}).then(function (d) {
|
4407
4447
|
l(d, e, r, o);
|
4408
4448
|
})["catch"](function (d) {
|
4409
|
-
o(
|
4449
|
+
o(A.CONNECTION_FAILED), console.error(d);
|
4410
4450
|
});
|
4411
4451
|
}
|
4412
4452
|
}]);
|
@@ -4562,7 +4602,7 @@ var Pe = /*#__PURE__*/function () {
|
|
4562
4602
|
var _a$url;
|
4563
4603
|
_classCallCheck(this, Pe);
|
4564
4604
|
var n, r, o, a;
|
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 =
|
4605
|
+
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 = xe.URL), this.requestSettings.websocket && B.setup(this);
|
4566
4606
|
}
|
4567
4607
|
_createClass(Pe, [{
|
4568
4608
|
key: "verifyKey",
|
@@ -4590,7 +4630,7 @@ var Pe = /*#__PURE__*/function () {
|
|
4590
4630
|
case 0:
|
4591
4631
|
i = _args17.length > 2 && _args17[2] !== undefined ? _args17[2] : !0;
|
4592
4632
|
n = this.deepChat.stream;
|
4593
|
-
return _context17.abrupt("return", n && !
|
4633
|
+
return _context17.abrupt("return", n && !T.isSimulation(n) ? T.request(this, e, t) : w.request(this, e, t, i));
|
4594
4634
|
case 3:
|
4595
4635
|
case "end":
|
4596
4636
|
return _context17.stop();
|
@@ -4694,7 +4734,7 @@ var Pe = /*#__PURE__*/function () {
|
|
4694
4734
|
n = _objectSpread({
|
4695
4735
|
messages: i
|
4696
4736
|
}, this.rawBody);
|
4697
|
-
|
4737
|
+
B.sendWebsocket(this, n, t, !1);
|
4698
4738
|
} else this.callServiceAPI(t, i, e.files);
|
4699
4739
|
case 4:
|
4700
4740
|
case "end":
|
@@ -4780,11 +4820,11 @@ var q = /*#__PURE__*/function (_Pe) {
|
|
4780
4820
|
_inherits(q, _Pe);
|
4781
4821
|
// prettier-ignore
|
4782
4822
|
function q(e, t, i, n, r) {
|
4783
|
-
var
|
4823
|
+
var _this8;
|
4784
4824
|
_classCallCheck(this, q);
|
4785
4825
|
var o;
|
4786
|
-
|
4787
|
-
return
|
4826
|
+
_this8 = _callSuper(this, q, [e, r]), _this8.insertKeyPlaceholderText = "API Key", _this8.keyHelpUrl = "", Object.assign(_this8.rawBody, (o = e.request) == null ? void 0 : o.additionalBodyProps), _this8.keyVerificationDetails = t, _this8.buildHeadersFunc = i, n && _this8.setApiKeyProperties(n), _this8.requestSettings = _this8.buildRequestSettings(_this8.key || "", e.request);
|
4827
|
+
return _this8;
|
4788
4828
|
}
|
4789
4829
|
_createClass(q, [{
|
4790
4830
|
key: "setApiKeyProperties",
|
@@ -4847,13 +4887,13 @@ var Yi = /*#__PURE__*/function (_HTMLElement) {
|
|
4847
4887
|
_inherits(Je, _HTMLElement);
|
4848
4888
|
// If this is not working, try using propertyName directly
|
4849
4889
|
function Je() {
|
4850
|
-
var
|
4890
|
+
var _this9;
|
4851
4891
|
_classCallCheck(this, Je);
|
4852
|
-
|
4892
|
+
_this9 = _callSuper(this, Je), _this9._waitingToRender_ = !1, _this9._propUpdated_ = !1, Object.keys(Je._attributeToProperty_).forEach(function (e) {
|
4853
4893
|
var t = Je._attributeToProperty_[e];
|
4854
|
-
|
4894
|
+
_this9.constructPropertyAccessors(t), _this9.hasOwnProperty(e) || _this9.constructPropertyAccessors(t, e);
|
4855
4895
|
});
|
4856
|
-
return
|
4896
|
+
return _this9;
|
4857
4897
|
}
|
4858
4898
|
_createClass(Je, [{
|
4859
4899
|
key: "constructPropertyAccessors",
|
@@ -5068,24 +5108,24 @@ var P = /*#__PURE__*/function () {
|
|
5068
5108
|
return P;
|
5069
5109
|
}();
|
5070
5110
|
var _t = /*#__PURE__*/function () {
|
5071
|
-
function
|
5072
|
-
_classCallCheck(this,
|
5111
|
+
function fe() {
|
5112
|
+
_classCallCheck(this, fe);
|
5073
5113
|
}
|
5074
|
-
_createClass(
|
5114
|
+
_createClass(fe, null, [{
|
5075
5115
|
key: "enableButtons",
|
5076
5116
|
value: function enableButtons(e, t) {
|
5077
5117
|
var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
5078
5118
|
window.webLLM ? (e && (e.disabled = !1), t && (t.disabled = !1)) : i < Zi.MODULE_SEARCH_LIMIT_S * 4 && setTimeout(function () {
|
5079
|
-
return
|
5119
|
+
return fe.enableButtons(e, t, i + 1);
|
5080
5120
|
}, 250);
|
5081
5121
|
}
|
5082
5122
|
// prettier-ignore
|
5083
5123
|
}, {
|
5084
5124
|
key: "setUpInitial",
|
5085
5125
|
value: function setUpInitial(e, t, i, n) {
|
5086
|
-
var r = (t == null ? void 0 : t.downloadClass) ||
|
5087
|
-
o = (t == null ? void 0 : t.uploadClass) ||
|
5088
|
-
a = (t == null ? void 0 : t.fileInputClass) ||
|
5126
|
+
var r = (t == null ? void 0 : t.downloadClass) || fe.DOWNLOAD_BUTTON_CLASS,
|
5127
|
+
o = (t == null ? void 0 : t.uploadClass) || fe.UPLOAD_BUTTON_CLASS,
|
5128
|
+
a = (t == null ? void 0 : t.fileInputClass) || fe.FILE_INPUT_CLASS;
|
5089
5129
|
return setTimeout(function () {
|
5090
5130
|
var l = i == null ? void 0 : i.getElementsByClassName(r)[0],
|
5091
5131
|
c = i == null ? void 0 : i.getElementsByClassName(a)[0],
|
@@ -5096,7 +5136,7 @@ var _t = /*#__PURE__*/function () {
|
|
5096
5136
|
c.files && c.files.length > 0 && e(c.files);
|
5097
5137
|
}), d && (d.onclick = function () {
|
5098
5138
|
return c.click();
|
5099
|
-
}), (l || d) &&
|
5139
|
+
}), (l || d) && fe.enableButtons(l, d);
|
5100
5140
|
}), (t == null ? void 0 : t.initialHtml) || "<div>\n Download or upload a web model that will run entirely on your browser: <br/> \n <button disabled class=\"".concat(r, " deep-chat-button deep-chat-web-model-button\">Download</button>\n ").concat(n ? "" : "<input type=\"file\" class=\"".concat(a, "\" hidden multiple />\n <button disabled class=\"").concat(o, " deep-chat-button deep-chat-web-model-button\">Upload</button>"), "\n </div>");
|
5101
5141
|
}
|
5102
5142
|
}, {
|
@@ -5121,16 +5161,16 @@ var _t = /*#__PURE__*/function () {
|
|
5121
5161
|
}, {
|
5122
5162
|
key: "setUpAfterLoad",
|
5123
5163
|
value: function setUpAfterLoad(e, t, i, n) {
|
5124
|
-
var r = (t == null ? void 0 : t.exportFilesClass) ||
|
5164
|
+
var r = (t == null ? void 0 : t.exportFilesClass) || fe.EXPORT_BUTTON_CLASS;
|
5125
5165
|
return setTimeout(function () {
|
5126
5166
|
var o = i == null ? void 0 : i.getElementsByClassName(r)[0];
|
5127
5167
|
o && (o.onclick = function () {
|
5128
|
-
return
|
5168
|
+
return fe.exportFile(e);
|
5129
5169
|
});
|
5130
5170
|
}), (t == null ? void 0 : t.afterLoadHtml) || "<div>\n Model loaded successfully and has been cached for future requests.\n ".concat(n ? "" : "<br/> <button style=\"margin-top: 5px\" class=\"".concat(r, " deep-chat-button\">Export</button>"), "\n </div>");
|
5131
5171
|
}
|
5132
5172
|
}]);
|
5133
|
-
return
|
5173
|
+
return fe;
|
5134
5174
|
}();
|
5135
5175
|
_t.DOWNLOAD_BUTTON_CLASS = "deep-chat-download-button";
|
5136
5176
|
_t.UPLOAD_BUTTON_CLASS = "deep-chat-upload-button";
|
@@ -5266,29 +5306,29 @@ var wn = {
|
|
5266
5306
|
it = /*#__PURE__*/function (_Pe2) {
|
5267
5307
|
_inherits(M, _Pe2);
|
5268
5308
|
function M(e) {
|
5269
|
-
var
|
5309
|
+
var _this10;
|
5270
5310
|
_classCallCheck(this, M);
|
5271
5311
|
var t, i;
|
5272
|
-
|
5273
|
-
return
|
5312
|
+
_this10 = _callSuper(this, M, [e]), _this10._isModelLoaded = !1, _this10._isModelLoading = !1, _this10._loadOnFirstMessage = !1, _this10._webModel = {}, _this10.permittedErrorPrefixes = [M.MULTIPLE_MODELS_ERROR, M.WEB_LLM_NOT_FOUND_ERROR, M.GENERIC_ERROR], _this10._conversationHistory = [], _typeof(e.webModel) == "object" && (_this10._webModel = e.webModel), (t = _this10._webModel.load) != null && t.clearCache && M.clearAllCache(), _this10.findModelInWindow(e), _this10.canSendMessage = _this10.canSubmit.bind(_assertThisInitialized(_this10)), _this10._chatEl = (i = e.shadowRoot) == null ? void 0 : i.children[0], e.initialMessages && M.setUpHistory(_this10._conversationHistory, e.initialMessages);
|
5313
|
+
return _this10;
|
5274
5314
|
}
|
5275
5315
|
// need ref of messages object as web model exhibits unique behaviour to manipulate chat
|
5276
5316
|
_createClass(M, [{
|
5277
5317
|
key: "setUpMessages",
|
5278
5318
|
value: function setUpMessages(e) {
|
5279
|
-
var
|
5319
|
+
var _this11 = this;
|
5280
5320
|
this._messages = e, this._removeIntro = function () {
|
5281
|
-
e.removeIntroductoryMessage(),
|
5321
|
+
e.removeIntroductoryMessage(), _this11._removeIntro = void 0;
|
5282
5322
|
};
|
5283
5323
|
}
|
5284
5324
|
}, {
|
5285
5325
|
key: "findModelInWindow",
|
5286
5326
|
value: function findModelInWindow(e) {
|
5287
|
-
var
|
5327
|
+
var _this12 = this;
|
5288
5328
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
5289
5329
|
var i;
|
5290
5330
|
window.webLLM ? this.configureInit(this.shouldAddInitialMessage(e.introMessage)) : t > M.MODULE_SEARCH_LIMIT_S ? ((i = this._messages) == null || i.addNewErrorMessage("service", M.WEB_LLM_NOT_FOUND_ERROR), console.error("The deep-chat-web-llm module has not been attached to the window object. Please see the following guide:"), console.error("https://deepchat.dev/examples/externalModules")) : setTimeout(function () {
|
5291
|
-
return
|
5331
|
+
return _this12.findModelInWindow(e, t + 1);
|
5292
5332
|
}, 1e3);
|
5293
5333
|
}
|
5294
5334
|
}, {
|
@@ -5300,11 +5340,11 @@ var wn = {
|
|
5300
5340
|
}, {
|
5301
5341
|
key: "scrollToTop",
|
5302
5342
|
value: function scrollToTop(e) {
|
5303
|
-
var
|
5343
|
+
var _this13 = this;
|
5304
5344
|
var t;
|
5305
5345
|
((t = this._webModel.introMessage) == null ? void 0 : t.autoScroll) !== !1 && setTimeout(function () {
|
5306
5346
|
var i, n;
|
5307
|
-
(i =
|
5347
|
+
(i = _this13._messages) != null && i.elementRef && Z.scrollToTop((n = _this13._messages) == null ? void 0 : n.elementRef);
|
5308
5348
|
}, e);
|
5309
5349
|
}
|
5310
5350
|
// prettier-ignore
|
@@ -5421,7 +5461,7 @@ var wn = {
|
|
5421
5461
|
key: "loadModel",
|
5422
5462
|
value: function () {
|
5423
5463
|
var _loadModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(e, t) {
|
5424
|
-
var
|
5464
|
+
var _this14 = this;
|
5425
5465
|
var o, a, l, c, d, u, h, i, n, r, _this$getConfig, p, g, f, _p;
|
5426
5466
|
return _regeneratorRuntime().wrap(function _callee25$(_context25) {
|
5427
5467
|
while (1) switch (_context25.prev = _context25.next) {
|
@@ -5430,13 +5470,13 @@ var wn = {
|
|
5430
5470
|
i = ((o = this._webModel.introMessage) == null ? void 0 : o.displayed) === !1;
|
5431
5471
|
n = function n(p) {
|
5432
5472
|
var g;
|
5433
|
-
(g =
|
5473
|
+
(g = _this14._messages) == null || g.addNewMessage({
|
5434
5474
|
html: "<div>".concat(p.text, "</div>"),
|
5435
5475
|
overwrite: !0,
|
5436
5476
|
sendUpdate: !1
|
5437
5477
|
}), i && (setTimeout(function () {
|
5438
5478
|
var f;
|
5439
|
-
return Z.scrollToBottom((f =
|
5479
|
+
return Z.scrollToBottom((f = _this14._messages) == null ? void 0 : f.elementRef);
|
5440
5480
|
}), i = !1);
|
5441
5481
|
};
|
5442
5482
|
M.chat.setInitProgressCallback(n);
|
@@ -5544,7 +5584,7 @@ var wn = {
|
|
5544
5584
|
key: "streamResp",
|
5545
5585
|
value: function () {
|
5546
5586
|
var _streamResp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(e, t, i) {
|
5547
|
-
var
|
5587
|
+
var _this15 = this;
|
5548
5588
|
var n;
|
5549
5589
|
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
5550
5590
|
while (1) switch (_context29.prev = _context29.next) {
|
@@ -5561,7 +5601,7 @@ var wn = {
|
|
5561
5601
|
while (1) switch (_context28.prev = _context28.next) {
|
5562
5602
|
case 0:
|
5563
5603
|
_context28.next = 2;
|
5564
|
-
return M.processResponse(
|
5604
|
+
return M.processResponse(_this15.deepChat, e, {
|
5565
5605
|
text: o
|
5566
5606
|
});
|
5567
5607
|
case 2:
|
@@ -5655,7 +5695,7 @@ var wn = {
|
|
5655
5695
|
a = !!this.deepChat.stream;
|
5656
5696
|
try {
|
5657
5697
|
if (o) _.displayError(e, new Error(o)), (a ? this.streamHandlers.onClose : this.completionsHandlers.onFinish)();else if (!r || !r.text) {
|
5658
|
-
l =
|
5698
|
+
l = A.INVALID_MODEL_REQUEST({
|
5659
5699
|
body: r
|
5660
5700
|
}, !1);
|
5661
5701
|
console.error(l);
|
@@ -5762,7 +5802,7 @@ var wn = {
|
|
5762
5802
|
_context33.next = 15;
|
5763
5803
|
break;
|
5764
5804
|
}
|
5765
|
-
o =
|
5805
|
+
o = A.INVALID_MODEL_RESPONSE(i, !!e.responseInterceptor, n);
|
5766
5806
|
_.displayError(t, new Error(o));
|
5767
5807
|
return _context33.abrupt("return");
|
5768
5808
|
case 15:
|
@@ -5821,7 +5861,7 @@ var Ut = /*#__PURE__*/function () {
|
|
5821
5861
|
key: "handleVerificationResult",
|
5822
5862
|
value: function handleVerificationResult(e, t, i, n) {
|
5823
5863
|
var r = e;
|
5824
|
-
Array.isArray(r.error) && r.error[0] === "Error in `parameters`: field required" ? i(t) : n(
|
5864
|
+
Array.isArray(r.error) && r.error[0] === "Error in `parameters`: field required" ? i(t) : n(A.INVALID_KEY);
|
5825
5865
|
}
|
5826
5866
|
}, {
|
5827
5867
|
key: "buildKeyVerificationDetails",
|
@@ -5836,16 +5876,16 @@ var Ut = /*#__PURE__*/function () {
|
|
5836
5876
|
return Ut;
|
5837
5877
|
}();
|
5838
5878
|
var us = /*#__PURE__*/function (_q) {
|
5839
|
-
_inherits(
|
5879
|
+
_inherits(Bi, _q);
|
5840
5880
|
// prettier-ignore
|
5841
|
-
function
|
5842
|
-
var
|
5843
|
-
_classCallCheck(this,
|
5844
|
-
|
5845
|
-
return
|
5881
|
+
function Bi(e, t, i, n, r, o) {
|
5882
|
+
var _this16;
|
5883
|
+
_classCallCheck(this, Bi);
|
5884
|
+
_this16 = _callSuper(this, Bi, [e, Ut.buildKeyVerificationDetails(), Ut.buildHeaders, r, o]), _this16.insertKeyPlaceholderText = "Hugging Face Token", _this16.keyHelpUrl = "https://huggingface.co/settings/tokens", _this16.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Hugging Face</b></div>\n <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>", _this16.permittedErrorPrefixes = ["Authorization header"], _this16.url = "".concat(Bi.URL_PREFIX).concat(i), _this16.textInputPlaceholderText = t, _typeof(n) == "object" && (n.model && (_this16.url = "".concat(Bi.URL_PREFIX).concat(n.model)), n.options && (_this16.rawBody.options = n.options), n.parameters && (_this16.rawBody.parameters = n.parameters));
|
5885
|
+
return _this16;
|
5846
5886
|
}
|
5847
5887
|
// prettier-ignore
|
5848
|
-
_createClass(
|
5888
|
+
_createClass(Bi, [{
|
5849
5889
|
key: "preprocessBody",
|
5850
5890
|
value: function preprocessBody(e, t, i) {
|
5851
5891
|
var _n$options;
|
@@ -5883,18 +5923,18 @@ var us = /*#__PURE__*/function (_q) {
|
|
5883
5923
|
return callServiceAPI;
|
5884
5924
|
}()
|
5885
5925
|
}]);
|
5886
|
-
return
|
5926
|
+
return Bi;
|
5887
5927
|
}(q);
|
5888
5928
|
us.URL_PREFIX = "https://api-inference.huggingface.co/models/";
|
5889
|
-
var
|
5890
|
-
var St = /*#__PURE__*/function (
|
5891
|
-
_inherits(St,
|
5929
|
+
var Be = us;
|
5930
|
+
var St = /*#__PURE__*/function (_Be) {
|
5931
|
+
_inherits(St, _Be);
|
5892
5932
|
// prettier-ignore
|
5893
5933
|
function St(e, t, i, n, r, o) {
|
5894
|
-
var
|
5934
|
+
var _this17;
|
5895
5935
|
_classCallCheck(this, St);
|
5896
|
-
|
5897
|
-
return
|
5936
|
+
_this17 = _callSuper(this, St, [e, t, i, n, r, o]), _this17.isTextInputDisabled = !0, _this17.canSendMessage = St.canSendFile;
|
5937
|
+
return _this17;
|
5898
5938
|
}
|
5899
5939
|
_createClass(St, [{
|
5900
5940
|
key: "preprocessBody",
|
@@ -5940,7 +5980,7 @@ var St = /*#__PURE__*/function (_Fe) {
|
|
5940
5980
|
}
|
5941
5981
|
}]);
|
5942
5982
|
return St;
|
5943
|
-
}(
|
5983
|
+
}(Be);
|
5944
5984
|
var Co = /*#__PURE__*/function (_St) {
|
5945
5985
|
_inherits(Co, _St);
|
5946
5986
|
// prettier-ignore
|
@@ -6059,7 +6099,7 @@ var ae = /*#__PURE__*/function () {
|
|
6059
6099
|
}, {
|
6060
6100
|
key: "handleVerificationResult",
|
6061
6101
|
value: function handleVerificationResult(e, t, i, n) {
|
6062
|
-
e.message ? n(
|
6102
|
+
e.message ? n(A.INVALID_KEY) : i(t);
|
6063
6103
|
}
|
6064
6104
|
}, {
|
6065
6105
|
key: "buildKeyVerificationDetails",
|
@@ -6077,17 +6117,17 @@ var ri = /*#__PURE__*/function (_q2) {
|
|
6077
6117
|
_inherits(ri, _q2);
|
6078
6118
|
// prettier-ignore
|
6079
6119
|
function ri(e, t, i, n, r) {
|
6080
|
-
var
|
6120
|
+
var _this18;
|
6081
6121
|
_classCallCheck(this, ri);
|
6082
|
-
|
6083
|
-
return
|
6122
|
+
_this18 = _callSuper(this, ri, [e, t, i, n, r]), _this18.insertKeyPlaceholderText = "Stability AI API Key", _this18.keyHelpUrl = "https://platform.stability.ai/docs/getting-started/authentication", _this18.permittedErrorPrefixes = ["Incorrect", "invalid_"];
|
6123
|
+
return _this18;
|
6084
6124
|
}
|
6085
6125
|
return _createClass(ri);
|
6086
6126
|
}(q);
|
6087
6127
|
var qt = /*#__PURE__*/function (_ri) {
|
6088
6128
|
_inherits(qt, _ri);
|
6089
6129
|
function qt(e) {
|
6090
|
-
var
|
6130
|
+
var _this19;
|
6091
6131
|
_classCallCheck(this, qt);
|
6092
6132
|
var o;
|
6093
6133
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
@@ -6100,10 +6140,10 @@ var qt = /*#__PURE__*/function (_ri) {
|
|
6100
6140
|
}
|
6101
6141
|
}
|
6102
6142
|
};
|
6103
|
-
|
6143
|
+
_this19 = _callSuper(this, qt, [e, ae.buildKeyVerificationDetails(), ae.buildHeaders, i, n]), _this19.url = "https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale", _this19.textInputPlaceholderText = "Describe image changes", _this19.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI</b></div>\n <div style=\"width: 100%; text-align: center; margin-left: -10px; margin-top: 5px\"><b>Image to Image Upscale</b></div>\n <p>Upload an image to generate a new one with higher resolution.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6104
6144
|
var r = (o = t == null ? void 0 : t.stabilityAI) == null ? void 0 : o.imageToImageUpscale;
|
6105
|
-
_typeof(r) == "object" && (r.engine_id && (
|
6106
|
-
return
|
6145
|
+
_typeof(r) == "object" && (r.engine_id && (_this19.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/image-to-image/upscale")), qt.cleanConfig(r), Object.assign(_this19.rawBody, r)), _this19.canSendMessage = qt.canSendFileMessage;
|
6146
|
+
return _this19;
|
6107
6147
|
}
|
6108
6148
|
_createClass(qt, [{
|
6109
6149
|
key: "createFormDataBody",
|
@@ -6195,7 +6235,7 @@ var qt = /*#__PURE__*/function (_ri) {
|
|
6195
6235
|
var Ht = /*#__PURE__*/function (_ri2) {
|
6196
6236
|
_inherits(Ht, _ri2);
|
6197
6237
|
function Ht(e) {
|
6198
|
-
var
|
6238
|
+
var _this20;
|
6199
6239
|
_classCallCheck(this, Ht);
|
6200
6240
|
var o;
|
6201
6241
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
@@ -6208,10 +6248,10 @@ var Ht = /*#__PURE__*/function (_ri2) {
|
|
6208
6248
|
}
|
6209
6249
|
}
|
6210
6250
|
};
|
6211
|
-
|
6251
|
+
_this20 = _callSuper(this, Ht, [e, ae.buildKeyVerificationDetails(), ae.buildHeaders, i, n]), _this20.url = "https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image/masking", _this20._maskSource = "MASK_IMAGE_WHITE", _this20.textInputPlaceholderText = "Describe image changes", _this20.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI</b></div>\n <div style=\"width: 100%; text-align: center; margin-left: -10px; margin-top: 5px\"><b>Image to Image Masking</b></div>\n <p>Upload an image, its mask image to create a new one based on the changes you have described for the mask area.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6212
6252
|
var r = (o = t == null ? void 0 : t.stabilityAI) == null ? void 0 : o.imageToImageMasking;
|
6213
|
-
_typeof(r) == "object" && (r.engine_id && (
|
6214
|
-
return
|
6253
|
+
_typeof(r) == "object" && (r.engine_id && (_this20.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/image-to-image/masking")), r.weight !== void 0 && r.weight !== null && (_this20._imageWeight = r.weight), r.mask_source !== void 0 && r.mask_source !== null && (_this20._maskSource = r.mask_source), Ht.cleanConfig(r), Object.assign(_this20.rawBody, r)), _this20.canSendMessage = Ht.canSendFileTextMessage;
|
6254
|
+
return _this20;
|
6215
6255
|
}
|
6216
6256
|
_createClass(Ht, [{
|
6217
6257
|
key: "createFormDataBody",
|
@@ -6349,8 +6389,8 @@ var ko = /*#__PURE__*/function (_St3) {
|
|
6349
6389
|
}]);
|
6350
6390
|
return ko;
|
6351
6391
|
}(St);
|
6352
|
-
var Io = /*#__PURE__*/function (
|
6353
|
-
_inherits(Io,
|
6392
|
+
var Io = /*#__PURE__*/function (_Be2) {
|
6393
|
+
_inherits(Io, _Be2);
|
6354
6394
|
function Io(e) {
|
6355
6395
|
_classCallCheck(this, Io);
|
6356
6396
|
var n, r, o;
|
@@ -6387,17 +6427,17 @@ var Io = /*#__PURE__*/function (_Fe2) {
|
|
6387
6427
|
}()
|
6388
6428
|
}]);
|
6389
6429
|
return Io;
|
6390
|
-
}(
|
6391
|
-
var Lo = /*#__PURE__*/function (
|
6392
|
-
_inherits(Lo,
|
6430
|
+
}(Be);
|
6431
|
+
var Lo = /*#__PURE__*/function (_Be3) {
|
6432
|
+
_inherits(Lo, _Be3);
|
6393
6433
|
function Lo(e) {
|
6394
|
-
var
|
6434
|
+
var _this21;
|
6395
6435
|
_classCallCheck(this, Lo);
|
6396
6436
|
var n, r, o;
|
6397
6437
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.huggingFace) == null ? void 0 : r.questionAnswer,
|
6398
6438
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6399
|
-
|
6400
|
-
return
|
6439
|
+
_this21 = _callSuper(this, Lo, [e, "Ask a question", "bert-large-uncased-whole-word-masking-finetuned-squad", t, i]), _this21.permittedErrorPrefixes = ["Authorization header", "Error in"], _this21.context = t.context;
|
6440
|
+
return _this21;
|
6401
6441
|
}
|
6402
6442
|
_createClass(Lo, [{
|
6403
6443
|
key: "preprocessBody",
|
@@ -6442,9 +6482,9 @@ var Lo = /*#__PURE__*/function (_Fe3) {
|
|
6442
6482
|
}()
|
6443
6483
|
}]);
|
6444
6484
|
return Lo;
|
6445
|
-
}(
|
6446
|
-
var Ro = /*#__PURE__*/function (
|
6447
|
-
_inherits(Ro,
|
6485
|
+
}(Be);
|
6486
|
+
var Ro = /*#__PURE__*/function (_Be4) {
|
6487
|
+
_inherits(Ro, _Be4);
|
6448
6488
|
function Ro(e) {
|
6449
6489
|
_classCallCheck(this, Ro);
|
6450
6490
|
var n, r, o;
|
@@ -6481,18 +6521,18 @@ var Ro = /*#__PURE__*/function (_Fe4) {
|
|
6481
6521
|
}()
|
6482
6522
|
}]);
|
6483
6523
|
return Ro;
|
6484
|
-
}(
|
6485
|
-
var No = /*#__PURE__*/function (
|
6486
|
-
_inherits(No,
|
6524
|
+
}(Be);
|
6525
|
+
var No = /*#__PURE__*/function (_Be5) {
|
6526
|
+
_inherits(No, _Be5);
|
6487
6527
|
function No(e) {
|
6488
|
-
var
|
6489
|
-
var
|
6528
|
+
var _this22$maxMessages;
|
6529
|
+
var _this22;
|
6490
6530
|
_classCallCheck(this, No);
|
6491
6531
|
var n, r, o;
|
6492
6532
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.huggingFace) == null ? void 0 : r.conversation,
|
6493
6533
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6494
|
-
|
6495
|
-
return
|
6534
|
+
_this22 = _callSuper(this, No, [e, "Ask me anything!", "facebook/blenderbot-400M-distill", t, i]), (_this22$maxMessages = _this22.maxMessages) !== null && _this22$maxMessages !== void 0 ? _this22$maxMessages : _this22.maxMessages = -1;
|
6535
|
+
return _this22;
|
6496
6536
|
}
|
6497
6537
|
// prettier-ignore
|
6498
6538
|
_createClass(No, [{
|
@@ -6564,11 +6604,11 @@ var No = /*#__PURE__*/function (_Fe5) {
|
|
6564
6604
|
}()
|
6565
6605
|
}]);
|
6566
6606
|
return No;
|
6567
|
-
}(
|
6607
|
+
}(Be);
|
6568
6608
|
var Gt = /*#__PURE__*/function (_ri3) {
|
6569
6609
|
_inherits(Gt, _ri3);
|
6570
6610
|
function Gt(e) {
|
6571
|
-
var
|
6611
|
+
var _this23;
|
6572
6612
|
_classCallCheck(this, Gt);
|
6573
6613
|
var o;
|
6574
6614
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
@@ -6581,10 +6621,10 @@ var Gt = /*#__PURE__*/function (_ri3) {
|
|
6581
6621
|
}
|
6582
6622
|
}
|
6583
6623
|
};
|
6584
|
-
|
6624
|
+
_this23 = _callSuper(this, Gt, [e, ae.buildKeyVerificationDetails(), ae.buildHeaders, i, n]), _this23.url = "https://api.stability.ai/v1/generation/stable-diffusion-v1-6/image-to-image", _this23.textInputPlaceholderText = "Describe image changes", _this23.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI: Image to Image</b></div>\n <p>Upload an image to create a new one with the changes you have described.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6585
6625
|
var r = (o = t.stabilityAI) == null ? void 0 : o.imageToImage;
|
6586
|
-
_typeof(r) == "object" && (r.engine_id && (
|
6587
|
-
return
|
6626
|
+
_typeof(r) == "object" && (r.engine_id && (_this23.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/text-to-image")), r.weight !== void 0 && r.weight !== null && (_this23._imageWeight = r.weight), Gt.cleanConfig(r), Object.assign(_this23.rawBody, r)), _this23.canSendMessage = Gt.canSendFileTextMessage;
|
6627
|
+
return _this23;
|
6588
6628
|
}
|
6589
6629
|
_createClass(Gt, [{
|
6590
6630
|
key: "createFormDataBody",
|
@@ -6673,8 +6713,8 @@ var Gt = /*#__PURE__*/function (_ri3) {
|
|
6673
6713
|
}]);
|
6674
6714
|
return Gt;
|
6675
6715
|
}(ri);
|
6676
|
-
var Oo = /*#__PURE__*/function (
|
6677
|
-
_inherits(Oo,
|
6716
|
+
var Oo = /*#__PURE__*/function (_Be6) {
|
6717
|
+
_inherits(Oo, _Be6);
|
6678
6718
|
function Oo(e) {
|
6679
6719
|
_classCallCheck(this, Oo);
|
6680
6720
|
var n, r, o;
|
@@ -6711,19 +6751,19 @@ var Oo = /*#__PURE__*/function (_Fe6) {
|
|
6711
6751
|
}()
|
6712
6752
|
}]);
|
6713
6753
|
return Oo;
|
6714
|
-
}(
|
6754
|
+
}(Be);
|
6715
6755
|
var Vt = /*#__PURE__*/function (_ri4) {
|
6716
6756
|
_inherits(Vt, _ri4);
|
6717
6757
|
function Vt(e) {
|
6718
|
-
var
|
6758
|
+
var _this24;
|
6719
6759
|
_classCallCheck(this, Vt);
|
6720
6760
|
var r;
|
6721
6761
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
6722
6762
|
i = t.stabilityAI;
|
6723
|
-
|
6763
|
+
_this24 = _callSuper(this, Vt, [e, ae.buildKeyVerificationDetails(), ae.buildHeaders, i]), _this24.url = "https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image", _this24.textInputPlaceholderText = "Describe an image", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI: Text to Image</b></div>\n <p>Insert text to generate an image.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6724
6764
|
var n = (r = t.stabilityAI) == null ? void 0 : r.textToImage;
|
6725
|
-
_typeof(n) == "object" && (n.engine_id && (
|
6726
|
-
return
|
6765
|
+
_typeof(n) == "object" && (n.engine_id && (_this24.url = "https://api.stability.ai/v1/generation/".concat(n.engine_id, "/text-to-image")), n.weight !== void 0 && n.weight !== null && (_this24._imageWeight = n.weight), Vt.cleanConfig(n), Object.assign(_this24.rawBody, n)), _this24.canSendMessage = Vt.canSendTextMessage;
|
6766
|
+
return _this24;
|
6727
6767
|
}
|
6728
6768
|
_createClass(Vt, [{
|
6729
6769
|
key: "preprocessBody",
|
@@ -6806,16 +6846,16 @@ var Vt = /*#__PURE__*/function (_ri4) {
|
|
6806
6846
|
}]);
|
6807
6847
|
return Vt;
|
6808
6848
|
}(ri);
|
6809
|
-
var Po = /*#__PURE__*/function (
|
6810
|
-
_inherits(Po,
|
6849
|
+
var Po = /*#__PURE__*/function (_Be7) {
|
6850
|
+
_inherits(Po, _Be7);
|
6811
6851
|
function Po(e) {
|
6812
|
-
var
|
6852
|
+
var _this25;
|
6813
6853
|
_classCallCheck(this, Po);
|
6814
6854
|
var n, r, o;
|
6815
6855
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.huggingFace) == null ? void 0 : r.fillMask,
|
6816
6856
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6817
|
-
|
6818
|
-
return
|
6857
|
+
_this25 = _callSuper(this, Po, [e, "The goal of life is [MASK].", "bert-base-uncased", t, i]), _this25.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Hugging Face</b></div>\n <p>Insert a sentence with the word [MASK] and the model will try to fill it for you. E.g. I want [MASK].</p>\n <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>", _this25.permittedErrorPrefixes = ["Authorization header", "No mask_token"];
|
6858
|
+
return _this25;
|
6819
6859
|
}
|
6820
6860
|
_createClass(Po, [{
|
6821
6861
|
key: "extractResultData",
|
@@ -6846,7 +6886,7 @@ var Po = /*#__PURE__*/function (_Fe7) {
|
|
6846
6886
|
}()
|
6847
6887
|
}]);
|
6848
6888
|
return Po;
|
6849
|
-
}(
|
6889
|
+
}(Be);
|
6850
6890
|
var Wt = /*#__PURE__*/function () {
|
6851
6891
|
function Wt() {
|
6852
6892
|
_classCallCheck(this, Wt);
|
@@ -6865,7 +6905,7 @@ var Wt = /*#__PURE__*/function () {
|
|
6865
6905
|
key: "handleVerificationResult",
|
6866
6906
|
value: function handleVerificationResult(e, t, i, n) {
|
6867
6907
|
var o;
|
6868
|
-
(o = e.message) != null && o.includes("invalid request: prompt must be at least 1 token long") ? i(t) : n(
|
6908
|
+
(o = e.message) != null && o.includes("invalid request: prompt must be at least 1 token long") ? i(t) : n(A.INVALID_KEY);
|
6869
6909
|
}
|
6870
6910
|
}, {
|
6871
6911
|
key: "buildKeyVerificationDetails",
|
@@ -6885,10 +6925,10 @@ var Wt = /*#__PURE__*/function () {
|
|
6885
6925
|
var Xi = /*#__PURE__*/function (_q3) {
|
6886
6926
|
_inherits(Xi, _q3);
|
6887
6927
|
function Xi(e, t, i, n, r) {
|
6888
|
-
var
|
6928
|
+
var _this26;
|
6889
6929
|
_classCallCheck(this, Xi);
|
6890
|
-
|
6891
|
-
return
|
6930
|
+
_this26 = _callSuper(this, Xi, [e, Wt.buildKeyVerificationDetails(), Wt.buildHeaders, r]), _this26.insertKeyPlaceholderText = "Cohere API Key", _this26.keyHelpUrl = "https://dashboard.cohere.ai/api-keys", _this26.permittedErrorPrefixes = ["invalid"], _this26.url = t, _this26.textInputPlaceholderText = i, n && _typeof(n) == "object" && Object.assign(_this26.rawBody, n);
|
6931
|
+
return _this26;
|
6892
6932
|
}
|
6893
6933
|
return _createClass(Xi);
|
6894
6934
|
}(q);
|
@@ -7060,7 +7100,7 @@ var N = /*#__PURE__*/function () {
|
|
7060
7100
|
key: "handleVerificationResult",
|
7061
7101
|
value: function handleVerificationResult(e, t, i, n) {
|
7062
7102
|
var r = e;
|
7063
|
-
r.error ? r.error.code === "invalid_api_key" ? n(
|
7103
|
+
r.error ? r.error.code === "invalid_api_key" ? n(A.INVALID_KEY) : n(A.CONNECTION_FAILED) : i(t);
|
7064
7104
|
}
|
7065
7105
|
}, {
|
7066
7106
|
key: "buildKeyVerificationDetails",
|
@@ -7115,15 +7155,15 @@ var Qi = /*#__PURE__*/function (_q4) {
|
|
7115
7155
|
_inherits(zi, _q4);
|
7116
7156
|
function zi(e) {
|
7117
7157
|
var _o$model, _a$voice;
|
7118
|
-
var
|
7158
|
+
var _this27;
|
7119
7159
|
_classCallCheck(this, zi);
|
7120
7160
|
var r, o, a;
|
7121
7161
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
7122
7162
|
i = t == null ? void 0 : t.openAI;
|
7123
|
-
|
7163
|
+
_this27 = _callSuper(this, zi, [e, N.buildKeyVerificationDetails(), N.buildHeaders, i]), _this27.insertKeyPlaceholderText = "OpenAI API Key", _this27.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this27.url = "https://api.openai.com/v1/audio/speech", _this27.permittedErrorPrefixes = ["Invalid"], _this27.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI : Text To Speech</b></div>\n <p>Generate an audio file based on your text input.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/text-to-speech\">here</a> for more information.</p>";
|
7124
7164
|
var n = (r = t == null ? void 0 : t.openAI) == null ? void 0 : r.textToSpeech;
|
7125
|
-
_typeof(n) == "object" && Object.assign(
|
7126
|
-
return
|
7165
|
+
_typeof(n) == "object" && Object.assign(_this27.rawBody, n), (_o$model = (o = _this27.rawBody).model) !== null && _o$model !== void 0 ? _o$model : o.model = zi.DEFAULT_MODEL, (_a$voice = (a = _this27.rawBody).voice) !== null && _a$voice !== void 0 ? _a$voice : a.voice = zi.DEFAULT_VOIDE, _this27.textInputPlaceholderText = "Insert text to generate audio", _this27.rawBody.response_format = "mp3";
|
7166
|
+
return _this27;
|
7127
7167
|
}
|
7128
7168
|
_createClass(zi, [{
|
7129
7169
|
key: "preprocessBody",
|
@@ -7209,27 +7249,27 @@ var Qi = /*#__PURE__*/function (_q4) {
|
|
7209
7249
|
}(q);
|
7210
7250
|
Qi.DEFAULT_MODEL = "tts-1";
|
7211
7251
|
Qi.DEFAULT_VOIDE = "alloy";
|
7212
|
-
var
|
7252
|
+
var Fo = Qi;
|
7213
7253
|
var oi = /*#__PURE__*/function (_q5) {
|
7214
|
-
_inherits(
|
7215
|
-
function
|
7254
|
+
_inherits(Me, _q5);
|
7255
|
+
function Me(e) {
|
7216
7256
|
var _o$model2;
|
7217
|
-
var
|
7218
|
-
_classCallCheck(this,
|
7257
|
+
var _this28;
|
7258
|
+
_classCallCheck(this, Me);
|
7219
7259
|
var r, o;
|
7220
7260
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
7221
7261
|
i = t == null ? void 0 : t.openAI;
|
7222
|
-
|
7262
|
+
_this28 = _callSuper(this, Me, [e, N.buildKeyVerificationDetails(), N.buildHeaders, i, {
|
7223
7263
|
audio: {}
|
7224
|
-
}]),
|
7264
|
+
}]), _this28.insertKeyPlaceholderText = "OpenAI API Key", _this28.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this28.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI : Speech To Text</b></div>\n <p><b>Upload an audio file</b> to transcribe it into text. You can optionally provide text to guide the audio\n processing.\n <p>Click <a href=\"https://platform.openai.com/docs/guides/speech-to-text\">here</a> for more info.</p>", _this28.url = "", _this28.permittedErrorPrefixes = ["Invalid"], _this28.textInputPlaceholderText = "Upload an audio file", _this28._service_url = Me.AUDIO_TRANSCRIPTIONS_URL;
|
7225
7265
|
var n = (r = t == null ? void 0 : t.openAI) == null ? void 0 : r.audio;
|
7226
|
-
_typeof(n) == "object" && (
|
7227
|
-
return
|
7266
|
+
_typeof(n) == "object" && (_this28.processConfig(n), Me.cleanConfig(n), Object.assign(_this28.rawBody, n)), (_o$model2 = (o = _this28.rawBody).model) !== null && _o$model2 !== void 0 ? _o$model2 : o.model = Me.DEFAULT_MODEL, _this28.rawBody.response_format = "json", _this28.canSendMessage = Me.canSendFileMessage;
|
7267
|
+
return _this28;
|
7228
7268
|
}
|
7229
|
-
_createClass(
|
7269
|
+
_createClass(Me, [{
|
7230
7270
|
key: "processConfig",
|
7231
7271
|
value: function processConfig(e) {
|
7232
|
-
e != null && e.type && e.type === "translation" && (this._service_url =
|
7272
|
+
e != null && e.type && e.type === "translation" && (this._service_url = Me.AUDIO_TRANSLATIONS_URL, delete e.language);
|
7233
7273
|
}
|
7234
7274
|
}, {
|
7235
7275
|
key: "preprocessBody",
|
@@ -7261,7 +7301,7 @@ var oi = /*#__PURE__*/function (_q5) {
|
|
7261
7301
|
throw new Error("No file was added");
|
7262
7302
|
case 4:
|
7263
7303
|
this.url = this.requestSettings.url || this._service_url;
|
7264
|
-
n = this.preprocessBody(this.rawBody, t), r =
|
7304
|
+
n = this.preprocessBody(this.rawBody, t), r = Me.createFormDataBody(n, i[0]);
|
7265
7305
|
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, r, e), !1);
|
7266
7306
|
case 7:
|
7267
7307
|
case "end":
|
@@ -7320,12 +7360,12 @@ var oi = /*#__PURE__*/function (_q5) {
|
|
7320
7360
|
}), i;
|
7321
7361
|
}
|
7322
7362
|
}]);
|
7323
|
-
return
|
7363
|
+
return Me;
|
7324
7364
|
}(q);
|
7325
7365
|
oi.AUDIO_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions";
|
7326
7366
|
oi.AUDIO_TRANSLATIONS_URL = "https://api.openai.com/v1/audio/translations";
|
7327
7367
|
oi.DEFAULT_MODEL = "whisper-1";
|
7328
|
-
var
|
7368
|
+
var Bo = oi;
|
7329
7369
|
var X = /*#__PURE__*/function () {
|
7330
7370
|
function X() {
|
7331
7371
|
_classCallCheck(this, X);
|
@@ -7351,7 +7391,7 @@ var X = /*#__PURE__*/function () {
|
|
7351
7391
|
}, {
|
7352
7392
|
key: "handleSpeechVerificationResult",
|
7353
7393
|
value: function handleSpeechVerificationResult(e, t, i, n) {
|
7354
|
-
e.error ? n(
|
7394
|
+
e.error ? n(A.INVALID_KEY) : i(t);
|
7355
7395
|
}
|
7356
7396
|
}, {
|
7357
7397
|
key: "buildSpeechKeyVerificationDetails",
|
@@ -7380,7 +7420,7 @@ var X = /*#__PURE__*/function () {
|
|
7380
7420
|
key: "handleLanguageVerificationResult",
|
7381
7421
|
value: function handleLanguageVerificationResult(e, t, i, n) {
|
7382
7422
|
var o;
|
7383
|
-
((o = e.error) == null ? void 0 : o.code) === "401" ? n(
|
7423
|
+
((o = e.error) == null ? void 0 : o.code) === "401" ? n(A.INVALID_KEY) : i(t);
|
7384
7424
|
}
|
7385
7425
|
}, {
|
7386
7426
|
key: "buildLanguageKeyVerificationDetails",
|
@@ -7401,7 +7441,7 @@ var X = /*#__PURE__*/function () {
|
|
7401
7441
|
key: "handleTranslationVerificationResult",
|
7402
7442
|
value: function handleTranslationVerificationResult(e, t, i, n) {
|
7403
7443
|
e.json().then(function (o) {
|
7404
|
-
!Array.isArray(o) && o.error.code === 401e3 ? n(
|
7444
|
+
!Array.isArray(o) && o.error.code === 401e3 ? n(A.INVALID_KEY) : i(t);
|
7405
7445
|
});
|
7406
7446
|
}
|
7407
7447
|
}, {
|
@@ -7432,12 +7472,12 @@ var zo = /*#__PURE__*/function (_q6) {
|
|
7432
7472
|
_inherits(zo, _q6);
|
7433
7473
|
// prettier-ignore
|
7434
7474
|
function zo(e, t, i, n, r) {
|
7435
|
-
var
|
7475
|
+
var _this29;
|
7436
7476
|
_classCallCheck(this, zo);
|
7437
|
-
|
7477
|
+
_this29 = _callSuper(this, zo, [e, X.buildLanguageKeyVerificationDetails(i), t, n, r]), _this29.insertKeyPlaceholderText = "Azure Language Subscription Key", _this29.keyHelpUrl =
|
7438
7478
|
// eslint-disable-next-line max-len
|
7439
|
-
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",
|
7440
|
-
return
|
7479
|
+
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal", _this29.permittedErrorPrefixes = ["Access"];
|
7480
|
+
return _this29;
|
7441
7481
|
}
|
7442
7482
|
return _createClass(zo);
|
7443
7483
|
}(q);
|
@@ -7445,13 +7485,13 @@ var Uo = /*#__PURE__*/function (_zo) {
|
|
7445
7485
|
_inherits(Uo, _zo);
|
7446
7486
|
function Uo(e) {
|
7447
7487
|
var _a$language;
|
7448
|
-
var
|
7488
|
+
var _this30;
|
7449
7489
|
_classCallCheck(this, Uo);
|
7450
7490
|
var n, r, o, a;
|
7451
7491
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.azure) == null ? void 0 : r.summarization,
|
7452
7492
|
i = (o = e.directConnection) == null ? void 0 : o.azure;
|
7453
|
-
|
7454
|
-
return
|
7493
|
+
_this30 = _callSuper(this, Uo, [e, X.buildSummarizationHeader, t.endpoint, i]), _this30.url = "", _this30.textInputPlaceholderText = "Insert text to summarize", (_a$language = (a = _this30.rawBody).language) !== null && _a$language !== void 0 ? _a$language : a.language = "en", Object.assign(_this30.rawBody, t), _this30.url = "".concat(t.endpoint, "/language/analyze-text/jobs?api-version=2022-10-01-preview");
|
7494
|
+
return _this30;
|
7455
7495
|
}
|
7456
7496
|
_createClass(Uo, [{
|
7457
7497
|
key: "preprocessBody",
|
@@ -7501,7 +7541,7 @@ var Uo = /*#__PURE__*/function (_zo) {
|
|
7501
7541
|
key: "extractResultData",
|
7502
7542
|
value: function () {
|
7503
7543
|
var _extractResultData16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(e) {
|
7504
|
-
var t,
|
7544
|
+
var t, _i10, n;
|
7505
7545
|
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
7506
7546
|
while (1) switch (_context63.prev = _context63.next) {
|
7507
7547
|
case 0:
|
@@ -7512,11 +7552,11 @@ var Uo = /*#__PURE__*/function (_zo) {
|
|
7512
7552
|
throw e.error.message;
|
7513
7553
|
case 2:
|
7514
7554
|
if (this.messages && this.completionsHandlers) {
|
7515
|
-
|
7555
|
+
_i10 = e.headers.get("operation-location"), n = {
|
7516
7556
|
method: "GET",
|
7517
7557
|
headers: (t = this.requestSettings) == null ? void 0 : t.headers
|
7518
7558
|
};
|
7519
|
-
w.executePollRequest(this,
|
7559
|
+
w.executePollRequest(this, _i10, n, this.messages);
|
7520
7560
|
}
|
7521
7561
|
return _context63.abrupt("return", {
|
7522
7562
|
makingAnotherRequest: !0
|
@@ -7536,7 +7576,7 @@ var Uo = /*#__PURE__*/function (_zo) {
|
|
7536
7576
|
key: "extractPollResultData",
|
7537
7577
|
value: function () {
|
7538
7578
|
var _extractPollResultData4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(e) {
|
7539
|
-
var t, _iterator, _step,
|
7579
|
+
var t, _iterator, _step, _i11;
|
7540
7580
|
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
7541
7581
|
while (1) switch (_context64.prev = _context64.next) {
|
7542
7582
|
case 0:
|
@@ -7570,8 +7610,8 @@ var Uo = /*#__PURE__*/function (_zo) {
|
|
7570
7610
|
_iterator = _createForOfIteratorHelper(e.tasks.items[0].results.documents[0].sentences);
|
7571
7611
|
try {
|
7572
7612
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
7573
|
-
|
7574
|
-
t +=
|
7613
|
+
_i11 = _step.value;
|
7614
|
+
t += _i11.text;
|
7575
7615
|
}
|
7576
7616
|
} catch (err) {
|
7577
7617
|
_iterator.e(err);
|
@@ -7687,7 +7727,7 @@ var ut = /*#__PURE__*/function () {
|
|
7687
7727
|
key: "handleVerificationResult",
|
7688
7728
|
value: function handleVerificationResult(e, t, i, n) {
|
7689
7729
|
var r = e;
|
7690
|
-
r.error ? r.error.code === "invalid_api_key" ? n(
|
7730
|
+
r.error ? r.error.code === "invalid_api_key" ? n(A.INVALID_KEY) : n(A.CONNECTION_FAILED) : i(t);
|
7691
7731
|
}
|
7692
7732
|
}, {
|
7693
7733
|
key: "buildKeyVerificationDetails",
|
@@ -7704,14 +7744,14 @@ var ut = /*#__PURE__*/function () {
|
|
7704
7744
|
var en = /*#__PURE__*/function (_q7) {
|
7705
7745
|
_inherits(en, _q7);
|
7706
7746
|
function en(e) {
|
7707
|
-
var
|
7747
|
+
var _this31;
|
7708
7748
|
_classCallCheck(this, en);
|
7709
7749
|
var i;
|
7710
7750
|
var t = (i = e.directConnection) == null ? void 0 : i.assemblyAI;
|
7711
|
-
|
7751
|
+
_this31 = _callSuper(this, en, [e, ut.buildKeyVerificationDetails(), ut.buildHeaders, t, {
|
7712
7752
|
audio: {}
|
7713
|
-
}]),
|
7714
|
-
return
|
7753
|
+
}]), _this31.insertKeyPlaceholderText = "AssemblyAI API Key", _this31.keyHelpUrl = "https://www.assemblyai.com/app/account", _this31.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>AssemblyAI Audio</b></div>\n <p><b>Upload an audio file</b> to transcribe it into text.\n <p>\n Click <a href=\"https://www.assemblyai.com/docs/Guides/transcribing_an_audio_file#get-started\">here</a> for more info.\n </p>", _this31.url = "https://api.assemblyai.com/v2/upload", _this31.isTextInputDisabled = !0, _this31.textInputPlaceholderText = "Upload an audio file", _this31.permittedErrorPrefixes = ["Authentication", "Invalid"], _this31.canSendMessage = en.canFileSendMessage;
|
7754
|
+
return _this31;
|
7715
7755
|
}
|
7716
7756
|
_createClass(en, [{
|
7717
7757
|
key: "callServiceAPI",
|
@@ -7790,12 +7830,12 @@ var hs = /*#__PURE__*/function (_q8) {
|
|
7790
7830
|
_inherits(hs, _q8);
|
7791
7831
|
// prettier-ignore
|
7792
7832
|
function hs(e, t, i, n, r) {
|
7793
|
-
var
|
7833
|
+
var _this32;
|
7794
7834
|
_classCallCheck(this, hs);
|
7795
|
-
|
7835
|
+
_this32 = _callSuper(this, hs, [e, X.buildSpeechKeyVerificationDetails(i), t, n, r]), _this32.insertKeyPlaceholderText = "Azure Speech Subscription Key", _this32.keyHelpUrl =
|
7796
7836
|
// eslint-disable-next-line max-len
|
7797
7837
|
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal";
|
7798
|
-
return
|
7838
|
+
return _this32;
|
7799
7839
|
}
|
7800
7840
|
return _createClass(hs);
|
7801
7841
|
}(q);
|
@@ -7804,13 +7844,13 @@ var ps = /*#__PURE__*/function (_hs) {
|
|
7804
7844
|
// prettier-ignore
|
7805
7845
|
function fs(e) {
|
7806
7846
|
var _a$lang, _l$name, _c$gender;
|
7807
|
-
var
|
7847
|
+
var _this33;
|
7808
7848
|
_classCallCheck(this, fs);
|
7809
7849
|
var n, r, o, a, l, c;
|
7810
7850
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.azure) == null ? void 0 : r.textToSpeech,
|
7811
7851
|
i = (o = e.directConnection) == null ? void 0 : o.azure;
|
7812
|
-
|
7813
|
-
return
|
7852
|
+
_this33 = _callSuper(this, fs, [e, X.buildTextToSpeechHeaders.bind({}, (t == null ? void 0 : t.outputFormat) || "audio-16khz-128kbitrate-mono-mp3"), t.region, i]), _this33.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Azure Text To Speech</b></div>\n <p>Insert text to synthesize it to audio.\n <p>\n Click <a href=\"".concat(fs.HELP_LINK, "\">here</a> for more info.\n </p>"), _this33.url = "", Object.assign(_this33.rawBody, t), (_a$lang = (a = _this33.rawBody).lang) !== null && _a$lang !== void 0 ? _a$lang : a.lang = "en-US", (_l$name = (l = _this33.rawBody).name) !== null && _l$name !== void 0 ? _l$name : l.name = "en-US-JennyNeural", (_c$gender = (c = _this33.rawBody).gender) !== null && _c$gender !== void 0 ? _c$gender : c.gender = "Female", _this33.url = "https://".concat(t.region, ".tts.speech.microsoft.com/cognitiveservices/v1");
|
7853
|
+
return _this33;
|
7814
7854
|
}
|
7815
7855
|
_createClass(fs, [{
|
7816
7856
|
key: "preprocessBody",
|
@@ -7884,7 +7924,7 @@ var qo = ps;
|
|
7884
7924
|
var ms = /*#__PURE__*/function (_hs2) {
|
7885
7925
|
_inherits(Ui, _hs2);
|
7886
7926
|
function Ui(e) {
|
7887
|
-
var
|
7927
|
+
var _this34;
|
7888
7928
|
_classCallCheck(this, Ui);
|
7889
7929
|
var o, a, l;
|
7890
7930
|
var t = (a = (o = e.directConnection) == null ? void 0 : o.azure) == null ? void 0 : a.speechToText,
|
@@ -7896,10 +7936,10 @@ var ms = /*#__PURE__*/function (_hs2) {
|
|
7896
7936
|
}
|
7897
7937
|
}
|
7898
7938
|
};
|
7899
|
-
|
7939
|
+
_this34 = _callSuper(this, Ui, [e, X.buildSpeechToTextHeaders, t.region, i, n]), _this34.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Azure Speech To Text</b></div>\n <p><b>Upload a .wav or .ogg audio file</b> to transcribe it into text.\n <p>\n Click <a href=\"".concat(Ui.HELP_LINK, "\">here</a> for more info.\n </p>"), _this34.url = "", _this34.isTextInputDisabled = !0, _this34.textInputPlaceholderText = "Upload an audio file", _this34.canSendMessage = Ui.canFileSendMessage;
|
7900
7940
|
var r = t.lang || "en-US";
|
7901
|
-
|
7902
|
-
return
|
7941
|
+
_this34.url = "https://".concat(t.region, ".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(r, "&format=detailed"), _this34.recordAudio = void 0;
|
7942
|
+
return _this34;
|
7903
7943
|
}
|
7904
7944
|
_createClass(Ui, [{
|
7905
7945
|
key: "callServiceAPI",
|
@@ -7976,15 +8016,15 @@ var Go = /*#__PURE__*/function (_q9) {
|
|
7976
8016
|
_inherits(Go, _q9);
|
7977
8017
|
// prettier-ignore
|
7978
8018
|
function Go(e) {
|
7979
|
-
var
|
8019
|
+
var _this35;
|
7980
8020
|
_classCallCheck(this, Go);
|
7981
8021
|
var n, r, o;
|
7982
8022
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.azure) == null ? void 0 : r.translation,
|
7983
8023
|
i = (o = e.directConnection) == null ? void 0 : o.azure;
|
7984
|
-
|
8024
|
+
_this35 = _callSuper(this, Go, [e, X.buildTranslationKeyVerificationDetails(t.region), X.buildTranslationHeaders.bind({}, t == null ? void 0 : t.region), i]), _this35.insertKeyPlaceholderText = "Azure Translate Subscription Key", _this35.keyHelpUrl =
|
7985
8025
|
// eslint-disable-next-line max-len
|
7986
|
-
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",
|
7987
|
-
return
|
8026
|
+
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal", _this35.url = "", _this35.url = "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(t.language || "es");
|
8027
|
+
return _this35;
|
7988
8028
|
}
|
7989
8029
|
_createClass(Go, [{
|
7990
8030
|
key: "preprocessBody",
|
@@ -8052,11 +8092,11 @@ var Go = /*#__PURE__*/function (_q9) {
|
|
8052
8092
|
}]);
|
8053
8093
|
return Go;
|
8054
8094
|
}(q);
|
8055
|
-
var
|
8056
|
-
function
|
8057
|
-
_classCallCheck(this,
|
8095
|
+
var be = /*#__PURE__*/function () {
|
8096
|
+
function be() {
|
8097
|
+
_classCallCheck(this, be);
|
8058
8098
|
}
|
8059
|
-
_createClass(
|
8099
|
+
_createClass(be, null, [{
|
8060
8100
|
key: "storeFiles",
|
8061
8101
|
value: function () {
|
8062
8102
|
var _storeFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(e, t, i) {
|
@@ -8147,7 +8187,7 @@ var ge = /*#__PURE__*/function () {
|
|
8147
8187
|
l({
|
8148
8188
|
src: d.target.result,
|
8149
8189
|
name: t[a].name,
|
8150
|
-
type:
|
8190
|
+
type: be.getType(t, a)
|
8151
8191
|
});
|
8152
8192
|
};
|
8153
8193
|
});
|
@@ -8185,7 +8225,7 @@ var ge = /*#__PURE__*/function () {
|
|
8185
8225
|
l.text && l.text.startsWith("sandbox:") && (c = l.file_path) != null && c.file_id && i.push({
|
8186
8226
|
path: l.text,
|
8187
8227
|
fileId: l.file_path.file_id,
|
8188
|
-
name:
|
8228
|
+
name: be.getFileName(l.text)
|
8189
8229
|
});
|
8190
8230
|
});
|
8191
8231
|
}), t != null && t.image_file && i.push({
|
@@ -8206,7 +8246,7 @@ var ge = /*#__PURE__*/function () {
|
|
8206
8246
|
break;
|
8207
8247
|
}
|
8208
8248
|
_context77.next = 4;
|
8209
|
-
return
|
8249
|
+
return be.getFiles(e, t);
|
8210
8250
|
case 4:
|
8211
8251
|
n = _context77.sent;
|
8212
8252
|
(r = i == null ? void 0 : i.text) != null && r.value && n.forEach(function (a, l) {
|
@@ -8239,9 +8279,9 @@ var ge = /*#__PURE__*/function () {
|
|
8239
8279
|
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
8240
8280
|
while (1) switch (_context78.prev = _context78.next) {
|
8241
8281
|
case 0:
|
8242
|
-
n =
|
8282
|
+
n = be.getFileDetails(t, i);
|
8243
8283
|
_context78.next = 3;
|
8244
|
-
return
|
8284
|
+
return be.getFilesAndNewText(e, n, i);
|
8245
8285
|
case 3:
|
8246
8286
|
return _context78.abrupt("return", _context78.sent);
|
8247
8287
|
case 4:
|
@@ -8256,29 +8296,29 @@ var ge = /*#__PURE__*/function () {
|
|
8256
8296
|
return getFilesAndText;
|
8257
8297
|
}()
|
8258
8298
|
}]);
|
8259
|
-
return
|
8299
|
+
return be;
|
8260
8300
|
}();
|
8261
8301
|
var ai = /*#__PURE__*/function (_q10) {
|
8262
8302
|
_inherits(se, _q10);
|
8263
8303
|
function se(e) {
|
8264
8304
|
var _c$headers, _d$OpenAIBeta;
|
8265
|
-
var
|
8305
|
+
var _this36;
|
8266
8306
|
_classCallCheck(this, se);
|
8267
8307
|
var r, o, a, l, c, d;
|
8268
8308
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
8269
8309
|
i = t.openAI;
|
8270
|
-
|
8310
|
+
_this36 = _callSuper(this, se, [e, N.buildKeyVerificationDetails(), N.buildHeaders, i]), _this36.insertKeyPlaceholderText = "OpenAI API Key", _this36.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this36.url = "", _this36.permittedErrorPrefixes = ["Incorrect"], _this36.searchedForThreadId = !1, _this36.config = {}, _this36.newAssistantDetails = {
|
8271
8311
|
model: "gpt-4"
|
8272
8312
|
};
|
8273
8313
|
var n = (r = t.openAI) == null ? void 0 : r.assistant;
|
8274
8314
|
if (_typeof(n) == "object") {
|
8275
|
-
|
8315
|
+
_this36.config = n, Object.assign(_this36.newAssistantDetails, _this36.config.new_assistant);
|
8276
8316
|
var _ref10 = (a = (o = e.directConnection) == null ? void 0 : o.openAI) == null ? void 0 : a.assistant,
|
8277
8317
|
u = _ref10.function_handler;
|
8278
|
-
u && (
|
8318
|
+
u && (_this36._functionHandler = u);
|
8279
8319
|
} else (l = t.openAI) != null && l.assistant && (t.openAI.assistant = n);
|
8280
|
-
(_c$headers = (c =
|
8281
|
-
return
|
8320
|
+
(_c$headers = (c = _this36.requestSettings).headers) !== null && _c$headers !== void 0 ? _c$headers : c.headers = {}, (_d$OpenAIBeta = (d = _this36.requestSettings.headers)["OpenAI-Beta"]) !== null && _d$OpenAIBeta !== void 0 ? _d$OpenAIBeta : d["OpenAI-Beta"] = "assistants=v1", _this36.maxMessages = 1;
|
8321
|
+
return _this36;
|
8282
8322
|
}
|
8283
8323
|
_createClass(se, [{
|
8284
8324
|
key: "processMessage",
|
@@ -8354,7 +8394,7 @@ var ai = /*#__PURE__*/function (_q10) {
|
|
8354
8394
|
break;
|
8355
8395
|
}
|
8356
8396
|
_context79.next = 16;
|
8357
|
-
return
|
8397
|
+
return be.storeFiles(this, e, i);
|
8358
8398
|
case 16:
|
8359
8399
|
_context79.t1 = _context79.sent;
|
8360
8400
|
_context79.next = 20;
|
@@ -8485,7 +8525,7 @@ var ai = /*#__PURE__*/function (_q10) {
|
|
8485
8525
|
key: "extractPollResultData",
|
8486
8526
|
value: function () {
|
8487
8527
|
var _extractPollResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(e) {
|
8488
|
-
var r, o, a, l, c, t, i, d, u, h, _yield$
|
8528
|
+
var r, o, a, l, c, t, i, d, u, h, _yield$be$getFilesAnd, p, g, n, _d;
|
8489
8529
|
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
8490
8530
|
while (1) switch (_context83.prev = _context83.next) {
|
8491
8531
|
case 0:
|
@@ -8522,11 +8562,11 @@ var ai = /*#__PURE__*/function (_q10) {
|
|
8522
8562
|
return !!f.text || !!f.image_file;
|
8523
8563
|
});
|
8524
8564
|
_context83.next = 17;
|
8525
|
-
return
|
8565
|
+
return be.getFilesAndText(this, u, h);
|
8526
8566
|
case 17:
|
8527
|
-
_yield$
|
8528
|
-
p = _yield$
|
8529
|
-
g = _yield$
|
8567
|
+
_yield$be$getFilesAnd = _context83.sent;
|
8568
|
+
p = _yield$be$getFilesAnd.text;
|
8569
|
+
g = _yield$be$getFilesAnd.files;
|
8530
8570
|
return _context83.abrupt("return", {
|
8531
8571
|
text: p,
|
8532
8572
|
_sessionId: this.sessionId,
|
@@ -8632,10 +8672,10 @@ ai.NEW_ASSISTANT_URL = "https://api.openai.com/v1/assistants";
|
|
8632
8672
|
ai.POLLING_TIMEOUT_MS = 800;
|
8633
8673
|
var Vo = ai;
|
8634
8674
|
var li = /*#__PURE__*/function (_q11) {
|
8635
|
-
_inherits(
|
8636
|
-
function
|
8637
|
-
var
|
8638
|
-
_classCallCheck(this,
|
8675
|
+
_inherits(Te, _q11);
|
8676
|
+
function Te(e) {
|
8677
|
+
var _this37;
|
8678
|
+
_classCallCheck(this, Te);
|
8639
8679
|
var o;
|
8640
8680
|
var t = e.directConnection,
|
8641
8681
|
i = t == null ? void 0 : t.openAI,
|
@@ -8647,21 +8687,21 @@ var li = /*#__PURE__*/function (_q11) {
|
|
8647
8687
|
}
|
8648
8688
|
}
|
8649
8689
|
};
|
8650
|
-
|
8690
|
+
_this37 = _callSuper(this, Te, [e, N.buildKeyVerificationDetails(), N.buildHeaders, i, n]), _this37.insertKeyPlaceholderText = "OpenAI API Key", _this37.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this37.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI DALL\xB7E</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/images/introduction\">here</a> for more info.</p>", _this37.url = "", _this37.permittedErrorPrefixes = ["Incorrect", "Invalid input image"];
|
8651
8691
|
var r = (o = t == null ? void 0 : t.openAI) == null ? void 0 : o.images;
|
8652
|
-
if (
|
8692
|
+
if (_this37.camera) {
|
8653
8693
|
var a = _typeof(r) == "object" && r.size ? Number.parseInt(r.size) : 1024;
|
8654
|
-
|
8694
|
+
_this37.camera.files = {
|
8655
8695
|
dimensions: {
|
8656
8696
|
width: a,
|
8657
8697
|
height: a
|
8658
8698
|
}
|
8659
8699
|
};
|
8660
8700
|
}
|
8661
|
-
_typeof(r) == "object" && Object.assign(
|
8662
|
-
return
|
8701
|
+
_typeof(r) == "object" && Object.assign(_this37.rawBody, r), _this37.canSendMessage = Te.canFileSendMessage;
|
8702
|
+
return _this37;
|
8663
8703
|
}
|
8664
|
-
_createClass(
|
8704
|
+
_createClass(Te, [{
|
8665
8705
|
key: "preprocessBody",
|
8666
8706
|
value: function preprocessBody(e, t) {
|
8667
8707
|
var i = JSON.parse(JSON.stringify(e));
|
@@ -8675,10 +8715,10 @@ var li = /*#__PURE__*/function (_q11) {
|
|
8675
8715
|
var n;
|
8676
8716
|
var r = (a = (o = t[t.length - 1]) == null ? void 0 : o.text) == null ? void 0 : a.trim();
|
8677
8717
|
if (i[1] || r && r !== "") {
|
8678
|
-
this.url =
|
8718
|
+
this.url = Te.IMAGE_EDIT_URL;
|
8679
8719
|
var l = this.preprocessBody(this.rawBody, r);
|
8680
|
-
n =
|
8681
|
-
} else this.url =
|
8720
|
+
n = Te.createFormDataBody(l, i[0], i[1]);
|
8721
|
+
} else this.url = Te.IMAGE_VARIATIONS_URL, n = Te.createFormDataBody(this.rawBody, i[0]);
|
8682
8722
|
_.tempRemoveContentHeader(this.requestSettings, w.request.bind(this, this, n, e), !1);
|
8683
8723
|
}
|
8684
8724
|
}, {
|
@@ -8709,7 +8749,7 @@ var li = /*#__PURE__*/function (_q11) {
|
|
8709
8749
|
}
|
8710
8750
|
throw new Error("Request settings have not been set up");
|
8711
8751
|
case 8:
|
8712
|
-
this.url =
|
8752
|
+
this.url = Te.IMAGE_GENERATION_URL;
|
8713
8753
|
r = this.preprocessBody(this.rawBody, t[t.length - 1].text);
|
8714
8754
|
w.request(this, r, e);
|
8715
8755
|
case 11:
|
@@ -8780,7 +8820,7 @@ var li = /*#__PURE__*/function (_q11) {
|
|
8780
8820
|
}), n;
|
8781
8821
|
}
|
8782
8822
|
}]);
|
8783
|
-
return
|
8823
|
+
return Te;
|
8784
8824
|
}(q);
|
8785
8825
|
li.IMAGE_GENERATION_URL = "https://api.openai.com/v1/images/generations";
|
8786
8826
|
li.IMAGE_VARIATIONS_URL = "https://api.openai.com/v1/images/variations";
|
@@ -8789,22 +8829,22 @@ var Wo = li;
|
|
8789
8829
|
var ht = /*#__PURE__*/function (_q12) {
|
8790
8830
|
_inherits(ht, _q12);
|
8791
8831
|
function ht(e) {
|
8792
|
-
var
|
8793
|
-
var
|
8832
|
+
var _this38$maxMessages, _l$model;
|
8833
|
+
var _this38;
|
8794
8834
|
_classCallCheck(this, ht);
|
8795
8835
|
var r, o, a, l;
|
8796
8836
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
8797
8837
|
i = t.openAI;
|
8798
|
-
|
8838
|
+
_this38 = _callSuper(this, ht, [e, N.buildKeyVerificationDetails(), N.buildHeaders, i]), _this38.insertKeyPlaceholderText = "OpenAI API Key", _this38.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this38.url = "https://api.openai.com/v1/chat/completions", _this38.permittedErrorPrefixes = ["Incorrect"], _this38._systemMessage = ht.generateSystemMessage("You are a helpful assistant.");
|
8799
8839
|
var n = (r = t.openAI) == null ? void 0 : r.chat;
|
8800
8840
|
if (_typeof(n) == "object") {
|
8801
|
-
n.system_prompt && (
|
8841
|
+
n.system_prompt && (_this38._systemMessage = ht.generateSystemMessage(n.system_prompt));
|
8802
8842
|
var _ref11 = (a = (o = e.directConnection) == null ? void 0 : o.openAI) == null ? void 0 : a.chat,
|
8803
8843
|
c = _ref11.function_handler;
|
8804
|
-
c && (
|
8844
|
+
c && (_this38._functionHandler = c), _this38.cleanConfig(n), Object.assign(_this38.rawBody, n);
|
8805
8845
|
}
|
8806
|
-
(
|
8807
|
-
return
|
8846
|
+
(_this38$maxMessages = _this38.maxMessages) !== null && _this38$maxMessages !== void 0 ? _this38$maxMessages : _this38.maxMessages = -1, (_l$model = (l = _this38.rawBody).model) !== null && _l$model !== void 0 ? _l$model : l.model = "gpt-3.5-turbo";
|
8847
|
+
return _this38;
|
8808
8848
|
}
|
8809
8849
|
_createClass(ht, [{
|
8810
8850
|
key: "cleanConfig",
|
@@ -8843,7 +8883,7 @@ var ht = /*#__PURE__*/function (_q12) {
|
|
8843
8883
|
throw new Error("Request settings have not been set up");
|
8844
8884
|
case 2:
|
8845
8885
|
i = this.preprocessBody(this.rawBody, t), n = this.deepChat.stream;
|
8846
|
-
n && (_typeof(n) != "object" || !n.simulation) || i.stream ? (i.stream = !0,
|
8886
|
+
n && (_typeof(n) != "object" || !n.simulation) || i.stream ? (i.stream = !0, T.request(this, i, e)) : w.request(this, i, e);
|
8847
8887
|
case 4:
|
8848
8888
|
case "end":
|
8849
8889
|
return _context87.stop();
|
@@ -9018,15 +9058,15 @@ var ht = /*#__PURE__*/function (_q12) {
|
|
9018
9058
|
var Jo = /*#__PURE__*/function (_Xi3) {
|
9019
9059
|
_inherits(Jo, _Xi3);
|
9020
9060
|
function Jo(e) {
|
9021
|
-
var
|
9022
|
-
var
|
9061
|
+
var _this39$maxMessages;
|
9062
|
+
var _this39;
|
9023
9063
|
_classCallCheck(this, Jo);
|
9024
9064
|
var r;
|
9025
9065
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
9026
9066
|
i = (r = t.cohere) == null ? void 0 : r.chat,
|
9027
9067
|
n = t.cohere;
|
9028
|
-
|
9029
|
-
return
|
9068
|
+
_this39 = _callSuper(this, Jo, [e, "https://api.cohere.ai/v1/chat", "Ask me anything!", i, n]), _typeof(i) == "object" && Object.assign(_this39.rawBody, i), (_this39$maxMessages = _this39.maxMessages) !== null && _this39$maxMessages !== void 0 ? _this39$maxMessages : _this39.maxMessages = -1;
|
9069
|
+
return _this39;
|
9030
9070
|
}
|
9031
9071
|
_createClass(Jo, [{
|
9032
9072
|
key: "preprocessBody",
|
@@ -9114,7 +9154,7 @@ var $o = /*#__PURE__*/function () {
|
|
9114
9154
|
r = e.webModel;
|
9115
9155
|
if (r) return new Zi(e);
|
9116
9156
|
if (t) {
|
9117
|
-
if (t.openAI) return t.openAI.images ? new Wo(e) : t.openAI.speechToText ? new
|
9157
|
+
if (t.openAI) return t.openAI.images ? new Wo(e) : t.openAI.speechToText ? new Bo(e) : t.openAI.textToSpeech ? new Fo(e) : t.openAI.assistant ? new Vo(e) : new ht(e);
|
9118
9158
|
if (t.assemblyAI) return new en(e);
|
9119
9159
|
if (t.cohere) return t.cohere.textGeneration ? new Do(e) : t.cohere.summarization ? new jo(e) : new Jo(e);
|
9120
9160
|
if (t.huggingFace) return t.huggingFace.textGeneration ? new Io(e) : t.huggingFace.summarization ? new Ro(e) : t.huggingFace.translation ? new Oo(e) : t.huggingFace.fillMask ? new Po(e) : t.huggingFace.questionAnswer ? new Lo(e) : t.huggingFace.audioSpeechRecognition ? new ko(e) : t.huggingFace.audioClassification ? new Co(e) : t.huggingFace.imageClassification ? new Ao(e) : new No(e);
|
@@ -9142,8 +9182,8 @@ var gs = /*#__PURE__*/function () {
|
|
9142
9182
|
if (!Array.from(e.getElementsByTagName("link")).some(function (i) {
|
9143
9183
|
return i.getAttribute("href") === qi.FONT_URL;
|
9144
9184
|
})) {
|
9145
|
-
var
|
9146
|
-
|
9185
|
+
var _i12 = document.createElement("link");
|
9186
|
+
_i12.rel = "stylesheet", _i12.href = qi.FONT_URL, e.appendChild(_i12);
|
9147
9187
|
}
|
9148
9188
|
}
|
9149
9189
|
}]);
|
@@ -9262,11 +9302,11 @@ var Yo = /*#__PURE__*/function () {
|
|
9262
9302
|
return Yo;
|
9263
9303
|
}();
|
9264
9304
|
var Zo = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n\t viewBox=\"50 30 420 450\" xml:space=\"preserve\">\n<g filter=\"brightness(0) saturate(100%) invert(16%) sepia(0%) saturate(1942%) hue-rotate(215deg) brightness(99%) contrast(93%)\">\n\t<g>\n\t\t<path d=\"M447.933,103.629c-0.034-3.076-1.224-6.09-3.485-8.352L352.683,3.511c-0.004-0.004-0.007-0.005-0.011-0.008\n\t\t\tC350.505,1.338,347.511,0,344.206,0H89.278C75.361,0,64.04,11.32,64.04,25.237v461.525c0,13.916,11.32,25.237,25.237,25.237\n\t\t\th333.444c13.916,0,25.237-11.32,25.237-25.237V103.753C447.96,103.709,447.937,103.672,447.933,103.629z M356.194,40.931\n\t\t\tl50.834,50.834h-49.572c-0.695,0-1.262-0.567-1.262-1.262V40.931z M423.983,486.763c0,0.695-0.566,1.261-1.261,1.261H89.278\n\t\t\tc-0.695,0-1.261-0.566-1.261-1.261V25.237c0-0.695,0.566-1.261,1.261-1.261h242.94v66.527c0,13.916,11.322,25.239,25.239,25.239\n\t\t\th66.527V486.763z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,164.014H149.912c-6.62,0-11.988,5.367-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,169.381,368.707,164.014,362.088,164.014z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,236.353H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,241.721,368.707,236.353,362.088,236.353z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,308.691H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C374.076,314.06,368.707,308.691,362.088,308.691z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M256,381.031H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988H256\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C267.988,386.398,262.62,381.031,256,381.031z\"/>\n\t</g>\n</g>\n</svg>";
|
9265
|
-
var
|
9266
|
-
function
|
9267
|
-
_classCallCheck(this,
|
9305
|
+
var me = /*#__PURE__*/function () {
|
9306
|
+
function me() {
|
9307
|
+
_classCallCheck(this, me);
|
9268
9308
|
}
|
9269
|
-
_createClass(
|
9309
|
+
_createClass(me, null, [{
|
9270
9310
|
key: "createImage",
|
9271
9311
|
value: function createImage(e, t) {
|
9272
9312
|
var i = new Image();
|
@@ -9281,7 +9321,7 @@ var fe = /*#__PURE__*/function () {
|
|
9281
9321
|
return _regeneratorRuntime().wrap(function _callee92$(_context92) {
|
9282
9322
|
while (1) switch (_context92.prev = _context92.next) {
|
9283
9323
|
case 0:
|
9284
|
-
n =
|
9324
|
+
n = me.createImage(t, e.elementRef), r = e.createNewMessageElement("", i);
|
9285
9325
|
r.bubbleElement.appendChild(n), r.bubbleElement.classList.add("image-message"), re.addMessage(e, r, "image", i);
|
9286
9326
|
case 2:
|
9287
9327
|
case "end":
|
@@ -9298,12 +9338,12 @@ var fe = /*#__PURE__*/function () {
|
|
9298
9338
|
key: "createAudioElement",
|
9299
9339
|
value: function createAudioElement(e, t) {
|
9300
9340
|
var i = document.createElement("audio");
|
9301
|
-
return i.src = e.src, i.classList.add("audio-player"), i.controls = !0,
|
9341
|
+
return i.src = e.src, i.classList.add("audio-player"), i.controls = !0, ve.IS_SAFARI && (i.classList.add("audio-player-safari"), i.classList.add(t === b.USER_ROLE ? "audio-player-safari-right" : "audio-player-safari-left")), i;
|
9302
9342
|
}
|
9303
9343
|
}, {
|
9304
9344
|
key: "addNewAudioMessage",
|
9305
9345
|
value: function addNewAudioMessage(e, t, i) {
|
9306
|
-
var n =
|
9346
|
+
var n = me.createAudioElement(t, i),
|
9307
9347
|
r = e.createNewMessageElement("", i);
|
9308
9348
|
r.bubbleElement.appendChild(n), r.bubbleElement.classList.add("audio-message"), re.addMessage(e, r, "audio", i);
|
9309
9349
|
}
|
@@ -9323,7 +9363,7 @@ var fe = /*#__PURE__*/function () {
|
|
9323
9363
|
key: "addNewAnyFileMessage",
|
9324
9364
|
value: function addNewAnyFileMessage(e, t, i) {
|
9325
9365
|
var n = e.createNewMessageElement("", i),
|
9326
|
-
r =
|
9366
|
+
r = me.createAnyFile(t);
|
9327
9367
|
n.bubbleElement.classList.add("any-file-message-bubble"), n.bubbleElement.appendChild(r), re.addMessage(e, n, "file", i);
|
9328
9368
|
}
|
9329
9369
|
// no overwrite previous message logic as it is complex to track which files are to be overwritten
|
@@ -9332,34 +9372,34 @@ var fe = /*#__PURE__*/function () {
|
|
9332
9372
|
value: function addMessages(e, t, i) {
|
9333
9373
|
t.forEach(function (n) {
|
9334
9374
|
var r, o;
|
9335
|
-
n.ref && (n = re.removeFileRef(n)), n.type === "audio" || (r = n.src) != null && r.startsWith("data:audio") ?
|
9375
|
+
n.ref && (n = re.removeFileRef(n)), n.type === "audio" || (r = n.src) != null && r.startsWith("data:audio") ? me.addNewAudioMessage(e, n, i) : n.type === "image" || (o = n.src) != null && o.startsWith("data:image") ? me.addNewImageMessage(e, n, i) : me.addNewAnyFileMessage(e, n, i);
|
9336
9376
|
});
|
9337
9377
|
}
|
9338
9378
|
}]);
|
9339
|
-
return
|
9379
|
+
return me;
|
9340
9380
|
}();
|
9341
|
-
var
|
9342
|
-
_inherits(
|
9343
|
-
function
|
9344
|
-
var
|
9345
|
-
_classCallCheck(this,
|
9381
|
+
var ge = /*#__PURE__*/function (_Ye) {
|
9382
|
+
_inherits(ge, _Ye);
|
9383
|
+
function ge(e, t, i) {
|
9384
|
+
var _this40;
|
9385
|
+
_classCallCheck(this, ge);
|
9346
9386
|
var a, l;
|
9347
|
-
|
9387
|
+
_this40 = _callSuper(this, ge, [e]);
|
9348
9388
|
var n = t.permittedErrorPrefixes,
|
9349
9389
|
r = t.introPanelMarkUp,
|
9350
9390
|
o = t.demo;
|
9351
|
-
|
9352
|
-
return JSON.parse(JSON.stringify(
|
9353
|
-
}, e.clearMessages =
|
9354
|
-
|
9391
|
+
_this40._errorMessageOverrides = (a = e.errorMessages) == null ? void 0 : a.overrides, _this40._onClearMessages = Bt.onClearMessages.bind(_assertThisInitialized(_this40), e), _this40._onError = Bt.onError.bind(_assertThisInitialized(_this40), e), _this40._displayLoadingMessage = ge.getDisplayLoadingMessage(e, t), _this40._permittedErrorPrefixes = n, _this40.addSetupMessageIfNeeded(e, t) || _this40.populateIntroPanel(i, r, e.introPanelStyle), _this40.addIntroductoryMessage(e, t), e.initialMessages && _this40.populateInitialMessages(e.initialMessages), _this40._displayServiceErrorMessages = (l = e.errorMessages) == null ? void 0 : l.displayServiceErrorMessages, e.getMessages = function () {
|
9392
|
+
return JSON.parse(JSON.stringify(_this40.messages));
|
9393
|
+
}, e.clearMessages = _this40.clearMessages.bind(_assertThisInitialized(_this40), t), e.refreshMessages = _this40.refreshTextMessages.bind(_assertThisInitialized(_this40)), e.scrollToBottom = Z.scrollToBottom.bind(_assertThisInitialized(_this40), _this40.elementRef), e._addMessage = function (c, d) {
|
9394
|
+
_this40.addNewMessage(_objectSpread(_objectSpread({}, c), {}, {
|
9355
9395
|
sendUpdate: !!d
|
9356
9396
|
}), !d);
|
9357
|
-
}, t.isWebModel() && t.setUpMessages(_assertThisInitialized(
|
9358
|
-
|
9397
|
+
}, t.isWebModel() && t.setUpMessages(_assertThisInitialized(_this40)), o && _this40.prepareDemo(o), e.textToSpeech && jt.processConfig(e.textToSpeech, function (c) {
|
9398
|
+
_this40.textToSpeech = c;
|
9359
9399
|
});
|
9360
|
-
return
|
9400
|
+
return _this40;
|
9361
9401
|
}
|
9362
|
-
_createClass(
|
9402
|
+
_createClass(ge, [{
|
9363
9403
|
key: "prepareDemo",
|
9364
9404
|
value: function prepareDemo(e) {
|
9365
9405
|
_typeof(e) == "object" && (e.response && (this.customDemoResponse = e.response), e.displayErrors && (e.displayErrors["default"] && this.addNewErrorMessage("", ""), e.displayErrors.service && this.addNewErrorMessage("service", ""), e.displayErrors.speechToText && this.addNewErrorMessage("speechToText", "")), e.displayLoadingBubble && this.addLoadingMessage());
|
@@ -9378,11 +9418,11 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9378
9418
|
}, {
|
9379
9419
|
key: "addIntroductoryMessage",
|
9380
9420
|
value: function addIntroductoryMessage(e, t) {
|
9381
|
-
var
|
9421
|
+
var _i13;
|
9382
9422
|
var n;
|
9383
9423
|
e != null && e.shadowRoot && (this._introMessage = e.introMessage);
|
9384
9424
|
var i = this._introMessage;
|
9385
|
-
if (t != null && t.isWebModel() && ((
|
9425
|
+
if (t != null && t.isWebModel() && ((_i13 = i) !== null && _i13 !== void 0 ? _i13 : i = t.getIntroMessage(i)), i) {
|
9386
9426
|
var r;
|
9387
9427
|
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"));
|
9388
9428
|
}
|
@@ -9396,11 +9436,11 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9396
9436
|
}, {
|
9397
9437
|
key: "populateInitialMessages",
|
9398
9438
|
value: function populateInitialMessages(e) {
|
9399
|
-
var
|
9439
|
+
var _this41 = this;
|
9400
9440
|
e.forEach(function (t) {
|
9401
|
-
Re.processInitialMessageFile(t),
|
9441
|
+
Re.processInitialMessageFile(t), _this41.addNewMessage(t, !0);
|
9402
9442
|
}), setTimeout(function () {
|
9403
|
-
return Z.scrollToBottom(
|
9443
|
+
return Z.scrollToBottom(_this41.elementRef);
|
9404
9444
|
}, 0);
|
9405
9445
|
}
|
9406
9446
|
// this should not be activated by streamed messages
|
@@ -9408,13 +9448,13 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9408
9448
|
key: "addNewMessage",
|
9409
9449
|
value: function addNewMessage(e) {
|
9410
9450
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
9411
|
-
var i =
|
9451
|
+
var i = ge.createMessageContent(e),
|
9412
9452
|
n = {
|
9413
9453
|
status: e.overwrite
|
9414
9454
|
};
|
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) &&
|
9455
|
+
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) && me.addMessages(this, i.files, i.role), i.html !== void 0 && i.html !== null) {
|
9416
9456
|
var r = Qe.add(this, i.html, i.role, this.messageElementRefs, n);
|
9417
|
-
|
9457
|
+
ye.isElementTemporary(r) && delete i.html;
|
9418
9458
|
}
|
9419
9459
|
this.isValidMessageContent(i) && this.updateStateOnMessage(i, e.overwrite, e.sendUpdate, t);
|
9420
9460
|
}
|
@@ -9436,7 +9476,7 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9436
9476
|
value: function removeMessageOnError() {
|
9437
9477
|
var e = this.messageElementRefs[this.messageElementRefs.length - 1],
|
9438
9478
|
t = e == null ? void 0 : e.bubbleElement;
|
9439
|
-
(t != null && t.classList.contains(Oe.MESSAGE_CLASS) && t.textContent === "" ||
|
9479
|
+
(t != null && t.classList.contains(Oe.MESSAGE_CLASS) && t.textContent === "" || ge.isTemporaryElement(e)) && this.removeLastMessage();
|
9440
9480
|
}
|
9441
9481
|
// prettier-ignore
|
9442
9482
|
}, {
|
@@ -9444,7 +9484,7 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9444
9484
|
value: function addNewErrorMessage(e, t) {
|
9445
9485
|
var l, c, d, u, h;
|
9446
9486
|
this.removeMessageOnError();
|
9447
|
-
var i =
|
9487
|
+
var i = ge.createBaseElements(),
|
9448
9488
|
n = i.outerContainer,
|
9449
9489
|
r = i.bubbleElement;
|
9450
9490
|
r.classList.add("error-message-text");
|
@@ -9459,11 +9499,11 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9459
9499
|
if (e) {
|
9460
9500
|
if (this._displayServiceErrorMessages) return e;
|
9461
9501
|
if (typeof e == "string" && this._permittedErrorPrefixes) {
|
9462
|
-
var t =
|
9502
|
+
var t = ge.checkPermittedErrorPrefixes(this._permittedErrorPrefixes, e);
|
9463
9503
|
if (t) return t;
|
9464
9504
|
} else if (Array.isArray(e) && this._permittedErrorPrefixes) for (var _t3 = 0; _t3 < e.length; _t3 += 1) {
|
9465
|
-
var
|
9466
|
-
if (
|
9505
|
+
var _i14 = ge.checkPermittedErrorPrefixes(this._permittedErrorPrefixes, e[_t3]);
|
9506
|
+
if (_i14) return _i14;
|
9467
9507
|
}
|
9468
9508
|
}
|
9469
9509
|
}
|
@@ -9551,10 +9591,10 @@ var me = /*#__PURE__*/function (_Ye) {
|
|
9551
9591
|
}, {
|
9552
9592
|
key: "checkPermittedErrorPrefixes",
|
9553
9593
|
value: function checkPermittedErrorPrefixes(e, t) {
|
9554
|
-
for (var
|
9594
|
+
for (var _i15 = 0; _i15 < e.length; _i15 += 1) if (t.startsWith(e[_i15])) return t;
|
9555
9595
|
}
|
9556
9596
|
}]);
|
9557
|
-
return
|
9597
|
+
return ge;
|
9558
9598
|
}(Ye);
|
9559
9599
|
var Mt = /*#__PURE__*/function () {
|
9560
9600
|
function $() {
|
@@ -9694,13 +9734,13 @@ var te = /*#__PURE__*/function () {
|
|
9694
9734
|
key: "unsetAllCSS",
|
9695
9735
|
value: function unsetAllCSS(e, t) {
|
9696
9736
|
var i, n;
|
9697
|
-
t.container &&
|
9737
|
+
t.container && C.unsetAllCSSMouseStates(e, t.container), (i = t.svg) != null && i.styles && C.unsetAllCSSMouseStates(e.children[0], t.svg.styles), (n = t.text) != null && n.styles && C.unsetAllCSSMouseStates(e.children[0], t.text.styles);
|
9698
9738
|
}
|
9699
9739
|
}, {
|
9700
9740
|
key: "unsetActionCSS",
|
9701
9741
|
value: function unsetActionCSS(e, t) {
|
9702
9742
|
var i, n;
|
9703
|
-
t.container &&
|
9743
|
+
t.container && C.unsetActivityCSSMouseStates(e, t.container), (i = t.svg) != null && i.styles && C.unsetActivityCSSMouseStates(e.children[0], t.svg.styles), (n = t.text) != null && n.styles && C.unsetActivityCSSMouseStates(e.children[0], t.text.styles);
|
9704
9744
|
}
|
9705
9745
|
}, {
|
9706
9746
|
key: "setElementsCSS",
|
@@ -9753,8 +9793,8 @@ var Tt = /*#__PURE__*/function () {
|
|
9753
9793
|
key: "unsetCustomStateStyles",
|
9754
9794
|
value: function unsetCustomStateStyles(e) {
|
9755
9795
|
if (this._customStyles) for (var t = 0; t < e.length; t += 1) {
|
9756
|
-
var
|
9757
|
-
n =
|
9796
|
+
var _i16 = e[t],
|
9797
|
+
n = _i16 && this._customStyles[_i16];
|
9758
9798
|
n && te.unsetActionCSS(this.elementRef, n);
|
9759
9799
|
}
|
9760
9800
|
}
|
@@ -9791,14 +9831,14 @@ var yt = /*#__PURE__*/function () {
|
|
9791
9831
|
}]);
|
9792
9832
|
return yt;
|
9793
9833
|
}();
|
9794
|
-
var
|
9795
|
-
function
|
9796
|
-
_classCallCheck(this,
|
9834
|
+
var Ae = /*#__PURE__*/function () {
|
9835
|
+
function Ae() {
|
9836
|
+
_classCallCheck(this, Ae);
|
9797
9837
|
}
|
9798
|
-
_createClass(
|
9838
|
+
_createClass(Ae, null, [{
|
9799
9839
|
key: "addItemEvents",
|
9800
9840
|
value: function addItemEvents(e, t, i, n) {
|
9801
|
-
|
9841
|
+
Ie.add(t, n), t.addEventListener("click", function () {
|
9802
9842
|
i.click();
|
9803
9843
|
}), t.addEventListener("mouseenter", function (r) {
|
9804
9844
|
e.highlightedItem = r.target;
|
@@ -9822,7 +9862,7 @@ var Ce = /*#__PURE__*/function () {
|
|
9822
9862
|
key: "populateItem",
|
9823
9863
|
value: function populateItem(e, t, i, n) {
|
9824
9864
|
var r = e.children[0];
|
9825
|
-
r.classList.contains("text-button") ? t.appendChild(
|
9865
|
+
r.classList.contains("text-button") ? t.appendChild(Ae.createItemText(r.textContent, n == null ? void 0 : n.text)) : (t.appendChild(Ae.createItemIcon(e, n == null ? void 0 : n.iconContainer)), t.appendChild(Ae.createItemText(i, n == null ? void 0 : n.text)));
|
9826
9866
|
}
|
9827
9867
|
// prettier-ignore
|
9828
9868
|
}, {
|
@@ -9832,24 +9872,24 @@ var Ce = /*#__PURE__*/function () {
|
|
9832
9872
|
var n = t.elementRef,
|
9833
9873
|
r = t.dropupText,
|
9834
9874
|
o = document.createElement("div");
|
9835
|
-
Object.assign(o.style, (l = i == null ? void 0 : i.item) == null ? void 0 : l["default"]),
|
9836
|
-
var a =
|
9875
|
+
Object.assign(o.style, (l = i == null ? void 0 : i.item) == null ? void 0 : l["default"]), Ae.populateItem(n, o, r, i), o.classList.add("dropup-menu-item");
|
9876
|
+
var a = C.processStateful((i == null ? void 0 : i.item) || {}, {
|
9837
9877
|
backgroundColor: "#f3f3f3"
|
9838
9878
|
}, {
|
9839
9879
|
backgroundColor: "#ebebeb"
|
9840
9880
|
});
|
9841
|
-
return
|
9881
|
+
return Ae.addItemEvents(e, o, n, a), o;
|
9842
9882
|
}
|
9843
9883
|
}]);
|
9844
|
-
return
|
9884
|
+
return Ae;
|
9845
9885
|
}();
|
9846
9886
|
var nn = /*#__PURE__*/function () {
|
9847
9887
|
function nn(e, t) {
|
9848
|
-
var
|
9888
|
+
var _this42 = this;
|
9849
9889
|
_classCallCheck(this, nn);
|
9850
9890
|
var i;
|
9851
9891
|
this._isOpen = !0, this._styles = t, this.elementRef = nn.createElement((i = this._styles) == null ? void 0 : i.container), this.close(), setTimeout(function () {
|
9852
|
-
return
|
9892
|
+
return _this42.addWindowEvents(e);
|
9853
9893
|
});
|
9854
9894
|
}
|
9855
9895
|
_createClass(nn, [{
|
@@ -9870,7 +9910,7 @@ var nn = /*#__PURE__*/function () {
|
|
9870
9910
|
}, {
|
9871
9911
|
key: "addItem",
|
9872
9912
|
value: function addItem(e) {
|
9873
|
-
var t =
|
9913
|
+
var t = Ae.createItem(this, e, this._styles);
|
9874
9914
|
this.elementRef.appendChild(t);
|
9875
9915
|
}
|
9876
9916
|
// prettier-ignore
|
@@ -9904,15 +9944,15 @@ var nn = /*#__PURE__*/function () {
|
|
9904
9944
|
var Ze = /*#__PURE__*/function (_Tt) {
|
9905
9945
|
_inherits(Ze, _Tt);
|
9906
9946
|
function Ze(e, t) {
|
9907
|
-
var
|
9947
|
+
var _this43;
|
9908
9948
|
_classCallCheck(this, Ze);
|
9909
9949
|
var n;
|
9910
|
-
|
9950
|
+
_this43 = _callSuper(this, Ze, [Ze.createButtonElement(), void 0, {
|
9911
9951
|
styles: (n = t == null ? void 0 : t.button) == null ? void 0 : n.styles
|
9912
9952
|
}]);
|
9913
|
-
var i =
|
9914
|
-
|
9915
|
-
return
|
9953
|
+
var i = _this43.createInnerElements(_this43._customStyles);
|
9954
|
+
_this43._menu = new nn(e, t == null ? void 0 : t.menu), _this43.addClickEvent(), _this43.buttonContainer = Ze.createButtonContainer(), _this43.elementRef.appendChild(i.styles), _this43.buttonContainer.appendChild(_this43.elementRef), _this43.elementRef.classList.add("dropup-icon", "upload-file-button"), _this43.elementRef.children[0].id = "dropup-icon", _this43.buttonContainer.appendChild(_this43._menu.elementRef), _this43.reapplyStateStyle("styles"), _this43.addContainerEvents(e);
|
9955
|
+
return _this43;
|
9916
9956
|
}
|
9917
9957
|
_createClass(Ze, [{
|
9918
9958
|
key: "createInnerElements",
|
@@ -9939,9 +9979,9 @@ var Ze = /*#__PURE__*/function (_Tt) {
|
|
9939
9979
|
}, {
|
9940
9980
|
key: "addContainerEvents",
|
9941
9981
|
value: function addContainerEvents(e) {
|
9942
|
-
var
|
9982
|
+
var _this44 = this;
|
9943
9983
|
e.addEventListener("click", function (t) {
|
9944
|
-
t.target.classList.contains("dropup-icon") ||
|
9984
|
+
t.target.classList.contains("dropup-icon") || _this44._menu.close();
|
9945
9985
|
});
|
9946
9986
|
}
|
9947
9987
|
}], [{
|
@@ -9970,11 +10010,11 @@ var Ze = /*#__PURE__*/function (_Tt) {
|
|
9970
10010
|
}]);
|
9971
10011
|
return Ze;
|
9972
10012
|
}(Tt);
|
9973
|
-
var
|
9974
|
-
function
|
9975
|
-
_classCallCheck(this,
|
10013
|
+
var F = /*#__PURE__*/function () {
|
10014
|
+
function F() {
|
10015
|
+
_classCallCheck(this, F);
|
9976
10016
|
}
|
9977
|
-
_createClass(
|
10017
|
+
_createClass(F, null, [{
|
9978
10018
|
key: "addToDropup",
|
9979
10019
|
value:
|
9980
10020
|
// prettier-ignore
|
@@ -10023,28 +10063,28 @@ var B = /*#__PURE__*/function () {
|
|
10023
10063
|
}, {
|
10024
10064
|
key: "generatePositions",
|
10025
10065
|
value: function generatePositions(e) {
|
10026
|
-
var t =
|
10066
|
+
var t = F.createPositionsObj();
|
10027
10067
|
Object.keys(e).forEach(function (n) {
|
10028
10068
|
var o;
|
10029
10069
|
var r = (o = e[n]) == null ? void 0 : o.button.position;
|
10030
|
-
r &&
|
10031
|
-
}), t["inside-right"].length === 0 && e.submit &&
|
10070
|
+
r && F.setPosition(e, n, t[r]);
|
10071
|
+
}), t["inside-right"].length === 0 && e.submit && F.setPosition(e, "submit", t["inside-right"]), t["outside-right"].length === 0 && (e.submit ? F.setPosition(e, "submit", t["outside-right"]) : e.microphone ? F.setPosition(e, "microphone", t["outside-right"]) : e.camera && F.setPosition(e, "camera", t["outside-right"])), e.submit && F.setPosition(e, "submit", t["outside-left"].length === 0 ? t["outside-left"] : t["inside-right"]), e.microphone && F.setPosition(e, "microphone", t["outside-left"].length === 0 ? t["outside-left"] : t["inside-right"]);
|
10032
10072
|
var i = Object.keys(e);
|
10033
10073
|
return i.length > 1 || t["dropup-menu"].length > 0 ? Mn.forEach(function (n) {
|
10034
10074
|
e[n] && t["dropup-menu"].push(_objectSpread(_objectSpread({}, e[n]), {}, {
|
10035
10075
|
buttonType: n
|
10036
10076
|
}));
|
10037
|
-
}) : i.length === 1 &&
|
10077
|
+
}) : i.length === 1 && F.setPosition(e, i[0], t["outside-right"].length === 0 ? t["outside-right"] : t["outside-left"]), t;
|
10038
10078
|
}
|
10039
10079
|
// prettier-ignore
|
10040
10080
|
}, {
|
10041
10081
|
key: "addButtons",
|
10042
10082
|
value: function addButtons(e, t, i, n) {
|
10043
|
-
var r =
|
10044
|
-
return
|
10083
|
+
var r = F.generatePositions(t);
|
10084
|
+
return F.addToSideContainer(e, r), r["dropup-menu"].length > 0 && F.addToDropup(e, r, i, n), r;
|
10045
10085
|
}
|
10046
10086
|
}]);
|
10047
|
-
return
|
10087
|
+
return F;
|
10048
10088
|
}();
|
10049
10089
|
var ea = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<title>file</title>\n<path d=\"M20 10.9696L11.9628 18.5497C10.9782 19.4783 9.64274 20 8.25028 20C6.85782 20 5.52239 19.4783 4.53777 18.5497C3.55315 17.6211 3 16.3616 3 15.0483C3 13.7351 3.55315 12.4756 4.53777 11.547L12.575 3.96687C13.2314 3.34779 14.1217 3 15.05 3C15.9783 3 16.8686 3.34779 17.525 3.96687C18.1814 4.58595 18.5502 5.4256 18.5502 6.30111C18.5502 7.17662 18.1814 8.01628 17.525 8.63535L9.47904 16.2154C9.15083 16.525 8.70569 16.6989 8.24154 16.6989C7.77738 16.6989 7.33224 16.525 7.00403 16.2154C6.67583 15.9059 6.49144 15.4861 6.49144 15.0483C6.49144 14.6106 6.67583 14.1907 7.00403 13.8812L14.429 6.88674\" stroke=\"#000000\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>",
|
10050
10090
|
ta = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M20,15.2928932 L20,5.5 C20,4.67157288 19.3284271,4 18.5,4 L5.5,4 C4.67157288,4 4,4.67157288 4,5.5 L4,12.2928932 L7.14644661,9.14644661 C7.34170876,8.95118446 7.65829124,8.95118446 7.85355339,9.14644661 L13.5,14.7928932 L16.1464466,12.1464466 C16.3417088,11.9511845 16.6582912,11.9511845 16.8535534,12.1464466 L20,15.2928932 Z M20,16.7071068 L16.5,13.2071068 L13.8535534,15.8535534 C13.6582912,16.0488155 13.3417088,16.0488155 13.1464466,15.8535534 L7.5,10.2071068 L4,13.7071068 L4,18.5 C4,19.3284271 4.67157288,20 5.5,20 L18.5,20 C19.3284271,20 20,19.3284271 20,18.5 L20,16.7071068 Z M3,5.5 C3,4.11928813 4.11928813,3 5.5,3 L18.5,3 C19.8807119,3 21,4.11928813 21,5.5 L21,18.5 C21,19.8807119 19.8807119,21 18.5,21 L5.5,21 C4.11928813,21 3,19.8807119 3,18.5 L3,5.5 Z M15,6 L17,6 C17.5522847,6 18,6.44771525 18,7 L18,9 C18,9.55228475 17.5522847,10 17,10 L15,10 C14.4477153,10 14,9.55228475 14,9 L14,7 C14,6.44771525 14.4477153,6 15,6 Z M15,7 L15,9 L17,9 L17,7 L15,7 Z\"/>\n</svg>\n",
|
@@ -10072,32 +10112,32 @@ var ea = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\"
|
|
10072
10112
|
dropupText: "File"
|
10073
10113
|
}
|
10074
10114
|
};
|
10075
|
-
var
|
10115
|
+
var he = /*#__PURE__*/function () {
|
10076
10116
|
// prettier-ignore
|
10077
|
-
function
|
10078
|
-
var
|
10079
|
-
_classCallCheck(this,
|
10117
|
+
function he(e, t, i, n) {
|
10118
|
+
var _this45 = this;
|
10119
|
+
_classCallCheck(this, he);
|
10080
10120
|
this._attachments = [], this._fileCountLimit = 99, this._acceptedFormat = "", t.maxNumberOfFiles && (this._fileCountLimit = t.maxNumberOfFiles), this._toggleContainerDisplay = i, this._fileAttachmentsContainerRef = n, t.acceptedFormats && (this._acceptedFormat = t.acceptedFormats), setTimeout(function () {
|
10081
|
-
|
10121
|
+
_this45._validationHandler = e._validationHandler;
|
10082
10122
|
});
|
10083
10123
|
}
|
10084
|
-
_createClass(
|
10124
|
+
_createClass(he, [{
|
10085
10125
|
key: "attemptAddFile",
|
10086
10126
|
value: function attemptAddFile(e, t) {
|
10087
|
-
return
|
10127
|
+
return he.isFileTypeValid(e, this._acceptedFormat) ? (this.addAttachmentBasedOnType(e, t, !0), !0) : !1;
|
10088
10128
|
}
|
10089
10129
|
}, {
|
10090
10130
|
key: "addAttachmentBasedOnType",
|
10091
10131
|
value: function addAttachmentBasedOnType(e, t, i) {
|
10092
|
-
var n =
|
10132
|
+
var n = he.getTypeFromBlob(e);
|
10093
10133
|
if (n === "image") {
|
10094
|
-
var r =
|
10134
|
+
var r = he.createImageAttachment(t);
|
10095
10135
|
this.addFileAttachment(e, "image", r, i);
|
10096
10136
|
} else if (n === "audio") {
|
10097
10137
|
var _r2 = Hi.createAudioAttachment(t);
|
10098
10138
|
this.addFileAttachment(e, "audio", _r2, i);
|
10099
10139
|
} else {
|
10100
|
-
var _r3 =
|
10140
|
+
var _r3 = he.createAnyFileAttachment(e.name);
|
10101
10141
|
this.addFileAttachment(e, "any", _r3, i);
|
10102
10142
|
}
|
10103
10143
|
}
|
@@ -10105,7 +10145,7 @@ var ue = /*#__PURE__*/function () {
|
|
10105
10145
|
key: "addFileAttachment",
|
10106
10146
|
value: function addFileAttachment(e, t, i, n) {
|
10107
10147
|
var a;
|
10108
|
-
var r =
|
10148
|
+
var r = he.createContainer(i);
|
10109
10149
|
if (this._attachments.length >= this._fileCountLimit) {
|
10110
10150
|
var l = this._attachments[this._attachments.length - 1].removeButton;
|
10111
10151
|
l == null || l.click();
|
@@ -10191,7 +10231,7 @@ var ue = /*#__PURE__*/function () {
|
|
10191
10231
|
key: "createAnyFileAttachment",
|
10192
10232
|
value: function createAnyFileAttachment(e) {
|
10193
10233
|
var t = document.createElement("div");
|
10194
|
-
t.classList.add("border-bound-attachment"),
|
10234
|
+
t.classList.add("border-bound-attachment"), ve.IS_SAFARI && t.classList.add("border-bound-attachment-safari");
|
10195
10235
|
var i = document.createElement("div");
|
10196
10236
|
i.classList.add("any-file-attachment-text");
|
10197
10237
|
var n = document.createElement("div");
|
@@ -10204,26 +10244,26 @@ var ue = /*#__PURE__*/function () {
|
|
10204
10244
|
return t.classList.add("file-attachment"), t.appendChild(e), t;
|
10205
10245
|
}
|
10206
10246
|
}]);
|
10207
|
-
return
|
10247
|
+
return he;
|
10208
10248
|
}();
|
10209
10249
|
var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <title>play</title>\n <path d=\"M5.92 24.096q0 1.088 0.928 1.728 0.512 0.288 1.088 0.288 0.448 0 0.896-0.224l16.16-8.064q0.48-0.256 0.8-0.736t0.288-1.088-0.288-1.056-0.8-0.736l-16.16-8.064q-0.448-0.224-0.896-0.224-0.544 0-1.088 0.288-0.928 0.608-0.928 1.728v16.16z\"></path>\n</svg>",
|
10210
10250
|
Tn = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n<title>stop</title>\n<path d=\"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z\"></path>\n</svg>",
|
10211
|
-
vs = /*#__PURE__*/function (
|
10212
|
-
_inherits(
|
10251
|
+
vs = /*#__PURE__*/function (_he) {
|
10252
|
+
_inherits(Ce, _he);
|
10213
10253
|
// prettier-ignore
|
10214
|
-
function
|
10215
|
-
_classCallCheck(this,
|
10216
|
-
return _callSuper(this,
|
10254
|
+
function Ce(e, t, i, n) {
|
10255
|
+
_classCallCheck(this, Ce);
|
10256
|
+
return _callSuper(this, Ce, [e, t, i, n]);
|
10217
10257
|
}
|
10218
|
-
_createClass(
|
10258
|
+
_createClass(Ce, [{
|
10219
10259
|
key: "createTimer",
|
10220
10260
|
value: function createTimer(e, t) {
|
10221
|
-
var
|
10261
|
+
var _this46 = this;
|
10222
10262
|
var i = 0;
|
10223
|
-
var n = t !== void 0 && t <
|
10263
|
+
var n = t !== void 0 && t < Ce.TIMER_LIMIT_S ? t : Ce.TIMER_LIMIT_S;
|
10224
10264
|
return setInterval(function () {
|
10225
10265
|
var a;
|
10226
|
-
i += 1, i === n && ((a =
|
10266
|
+
i += 1, i === n && ((a = _this46.stopPlaceholderCallback) == null || a.call(_this46), _this46.clearTimer()), i === 600 && e.classList.add("audio-placeholder-text-4-digits");
|
10227
10267
|
var r = Math.floor(i / 60),
|
10228
10268
|
o = (i % 60).toString().padStart(2, "0");
|
10229
10269
|
e.textContent = "".concat(r, ":").concat(o);
|
@@ -10232,7 +10272,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10232
10272
|
}, {
|
10233
10273
|
key: "createPlaceholderAudioAttachment",
|
10234
10274
|
value: function createPlaceholderAudioAttachment(e) {
|
10235
|
-
var t =
|
10275
|
+
var t = Ce.createAudioContainer(),
|
10236
10276
|
i = document.createElement("div");
|
10237
10277
|
i.classList.add("audio-placeholder-text-3-digits");
|
10238
10278
|
var n = document.createElement("div");
|
@@ -10243,7 +10283,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10243
10283
|
}, {
|
10244
10284
|
key: "addPlaceholderAudioAttachmentEvents",
|
10245
10285
|
value: function addPlaceholderAudioAttachmentEvents(e, t, i) {
|
10246
|
-
var
|
10286
|
+
var _this47 = this;
|
10247
10287
|
var n = function n() {
|
10248
10288
|
return e.replaceChildren(t);
|
10249
10289
|
};
|
@@ -10254,7 +10294,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10254
10294
|
e.addEventListener("mouseleave", r);
|
10255
10295
|
var o = function o() {
|
10256
10296
|
var a;
|
10257
|
-
return (a =
|
10297
|
+
return (a = _this47.stopPlaceholderCallback) == null ? void 0 : a.call(_this47);
|
10258
10298
|
};
|
10259
10299
|
e.addEventListener("click", o);
|
10260
10300
|
}
|
@@ -10269,7 +10309,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10269
10309
|
key: "completePlaceholderAttachment",
|
10270
10310
|
value: function completePlaceholderAttachment(e, t) {
|
10271
10311
|
var i = this._activePlaceholderAttachment;
|
10272
|
-
i && (i.file = e,
|
10312
|
+
i && (i.file = e, Ce.addAudioElements(i.attachmentContainerElement.children[0], t), i.removeButton = this.createRemoveAttachmentButton(i), i.attachmentContainerElement.appendChild(i.removeButton), this._activePlaceholderAttachment = void 0, this.clearTimer());
|
10273
10313
|
}
|
10274
10314
|
}, {
|
10275
10315
|
key: "removePlaceholderAttachment",
|
@@ -10285,7 +10325,7 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10285
10325
|
key: "createAudioContainer",
|
10286
10326
|
value: function createAudioContainer() {
|
10287
10327
|
var e = document.createElement("div");
|
10288
|
-
return e.classList.add("border-bound-attachment", "audio-attachment-icon-container"),
|
10328
|
+
return e.classList.add("border-bound-attachment", "audio-attachment-icon-container"), ve.IS_SAFARI && e.classList.add("border-bound-attachment-safari"), e;
|
10289
10329
|
}
|
10290
10330
|
}, {
|
10291
10331
|
key: "addAudioElements",
|
@@ -10309,8 +10349,8 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10309
10349
|
}, {
|
10310
10350
|
key: "createAudioAttachment",
|
10311
10351
|
value: function createAudioAttachment(e) {
|
10312
|
-
var t =
|
10313
|
-
return
|
10352
|
+
var t = Ce.createAudioContainer();
|
10353
|
+
return Ce.addAudioElements(t, e), t;
|
10314
10354
|
}
|
10315
10355
|
}, {
|
10316
10356
|
key: "stopAttachmentPlayback",
|
@@ -10319,8 +10359,8 @@ var ra = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
10319
10359
|
(n = (i = (t = e.children[0]) == null ? void 0 : t.children) == null ? void 0 : i[0]) != null && n.classList.contains("stop-icon") && e.children[0].click();
|
10320
10360
|
}
|
10321
10361
|
}]);
|
10322
|
-
return
|
10323
|
-
}(
|
10362
|
+
return Ce;
|
10363
|
+
}(he);
|
10324
10364
|
vs.TIMER_LIMIT_S = 5999;
|
10325
10365
|
var Hi = vs;
|
10326
10366
|
var oa = /*#__PURE__*/function () {
|
@@ -10332,7 +10372,7 @@ var oa = /*#__PURE__*/function () {
|
|
10332
10372
|
value:
|
10333
10373
|
// prettier-ignore
|
10334
10374
|
function create(e, t, i, n, r) {
|
10335
|
-
return r === "audio" ? new Hi(e, t, i, n) : new
|
10375
|
+
return r === "audio" ? new Hi(e, t, i, n) : new he(e, t, i, n);
|
10336
10376
|
}
|
10337
10377
|
}]);
|
10338
10378
|
return oa;
|
@@ -10449,20 +10489,20 @@ var ys = /*#__PURE__*/function () {
|
|
10449
10489
|
}, {
|
10450
10490
|
key: "addButtons",
|
10451
10491
|
value: function addButtons() {
|
10452
|
-
var
|
10492
|
+
var _this48 = this;
|
10453
10493
|
for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
10454
10494
|
e[_key2] = arguments[_key2];
|
10455
10495
|
}
|
10456
10496
|
e.forEach(function (t) {
|
10457
|
-
return
|
10497
|
+
return _this48._buttonPanel.appendChild(t);
|
10458
10498
|
});
|
10459
10499
|
}
|
10460
10500
|
}, {
|
10461
10501
|
key: "close",
|
10462
10502
|
value: function close() {
|
10463
|
-
var
|
10503
|
+
var _this49 = this;
|
10464
10504
|
this._elementRef.classList.remove("show-modal"), this._elementRef.classList.add("hide-modal"), this._backgroundPanelRef.classList.remove("show-modal-background"), this._backgroundPanelRef.classList.add("hide-modal-background"), this._isOpen = !1, setTimeout(function () {
|
10465
|
-
|
10505
|
+
_this49._elementRef.style.display = "none", _this49._backgroundPanelRef.style.display = "none";
|
10466
10506
|
}, ce.MODAL_CLOSE_TIMEOUT_MS);
|
10467
10507
|
}
|
10468
10508
|
}, {
|
@@ -10478,10 +10518,10 @@ var ys = /*#__PURE__*/function () {
|
|
10478
10518
|
}, {
|
10479
10519
|
key: "addCloseButton",
|
10480
10520
|
value: function addCloseButton(e, t, i) {
|
10481
|
-
var
|
10521
|
+
var _this50 = this;
|
10482
10522
|
var n = t ? ce.createSVGButton(e) : ce.createTextButton(e);
|
10483
10523
|
return this.addButtons(n), n.onclick = function () {
|
10484
|
-
|
10524
|
+
_this50.close(), setTimeout(function () {
|
10485
10525
|
i == null || i();
|
10486
10526
|
}, 140);
|
10487
10527
|
}, n;
|
@@ -10554,13 +10594,13 @@ var pt = /*#__PURE__*/function (_Tt2) {
|
|
10554
10594
|
_inherits(pt, _Tt2);
|
10555
10595
|
// prettier-ignore
|
10556
10596
|
function pt(e, t, i, n, r, o) {
|
10557
|
-
var
|
10597
|
+
var _this51;
|
10558
10598
|
_classCallCheck(this, pt);
|
10559
10599
|
var l, c, d, u, h, p;
|
10560
|
-
|
10561
|
-
var a =
|
10562
|
-
|
10563
|
-
return
|
10600
|
+
_this51 = _callSuper(this, pt, [pt.createButtonElement(), (l = i.button) == null ? void 0 : l.position, i.button, o]);
|
10601
|
+
var a = _this51.createInnerElements(n, r, _this51._customStyles);
|
10602
|
+
_this51._inputElement = pt.createInputElement((c = i == null ? void 0 : i.files) == null ? void 0 : c.acceptedFormats), _this51.addClickEvent(e, i), _this51.elementRef.replaceChildren(a.styles), _this51.reapplyStateStyle("styles"), _this51._fileAttachmentsType = t, _this51._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;
|
10603
|
+
return _this51;
|
10564
10604
|
}
|
10565
10605
|
_createClass(pt, [{
|
10566
10606
|
key: "createInnerElements",
|
@@ -10672,11 +10712,11 @@ var de = /*#__PURE__*/function () {
|
|
10672
10712
|
}]);
|
10673
10713
|
return de;
|
10674
10714
|
}();
|
10675
|
-
var
|
10676
|
-
function
|
10677
|
-
_classCallCheck(this,
|
10715
|
+
var ke = /*#__PURE__*/function () {
|
10716
|
+
function ke() {
|
10717
|
+
_classCallCheck(this, ke);
|
10678
10718
|
}
|
10679
|
-
_createClass(
|
10719
|
+
_createClass(ke, null, [{
|
10680
10720
|
key: "validate",
|
10681
10721
|
value:
|
10682
10722
|
// prettier-ignore
|
@@ -10700,7 +10740,7 @@ var Ae = /*#__PURE__*/function () {
|
|
10700
10740
|
a = i.getAllFileData(), l = a == null ? void 0 : a.map(function (c) {
|
10701
10741
|
return c.file;
|
10702
10742
|
});
|
10703
|
-
return _context96.abrupt("return",
|
10743
|
+
return _context96.abrupt("return", ke.validate(e, n, o, l));
|
10704
10744
|
case 5:
|
10705
10745
|
case "end":
|
10706
10746
|
return _context96.stop();
|
@@ -10723,7 +10763,7 @@ var Ae = /*#__PURE__*/function () {
|
|
10723
10763
|
n = (r = t.files) == null ? void 0 : r.map(function (o) {
|
10724
10764
|
return o.file;
|
10725
10765
|
});
|
10726
|
-
return _context97.abrupt("return",
|
10766
|
+
return _context97.abrupt("return", ke.validate(e, i, t.text, n, !0));
|
10727
10767
|
case 2:
|
10728
10768
|
case "end":
|
10729
10769
|
return _context97.stop();
|
@@ -10738,7 +10778,7 @@ var Ae = /*#__PURE__*/function () {
|
|
10738
10778
|
}, {
|
10739
10779
|
key: "validateWebsocket",
|
10740
10780
|
value: function validateWebsocket(e, t) {
|
10741
|
-
return e.websocket && !
|
10781
|
+
return e.websocket && !B.canSendMessage(e.websocket) ? (t.changeToDisabledIcon(), !1) : !0;
|
10742
10782
|
}
|
10743
10783
|
// prettier-ignore
|
10744
10784
|
}, {
|
@@ -10751,14 +10791,14 @@ var Ae = /*#__PURE__*/function () {
|
|
10751
10791
|
return _regeneratorRuntime().wrap(function _callee98$(_context98) {
|
10752
10792
|
while (1) switch (_context98.prev = _context98.next) {
|
10753
10793
|
case 0:
|
10754
|
-
if (!(r.status.loadingActive || r.status.requestInProgress || t.isSubmitProgrammaticallyDisabled === !0 || !
|
10794
|
+
if (!(r.status.loadingActive || r.status.requestInProgress || t.isSubmitProgrammaticallyDisabled === !0 || !ke.validateWebsocket(t, r))) {
|
10755
10795
|
_context98.next = 2;
|
10756
10796
|
break;
|
10757
10797
|
}
|
10758
10798
|
return _context98.abrupt("return", !1);
|
10759
10799
|
case 2:
|
10760
10800
|
l = o || t.canSendMessage;
|
10761
|
-
return _context98.abrupt("return", l ? a ?
|
10801
|
+
return _context98.abrupt("return", l ? a ? ke.useValidationFuncProgrammatic(l, a, r) : ke.useValidationFunc(l, i, n, r) : null);
|
10762
10802
|
case 4:
|
10763
10803
|
case "end":
|
10764
10804
|
return _context98.stop();
|
@@ -10771,16 +10811,16 @@ var Ae = /*#__PURE__*/function () {
|
|
10771
10811
|
}();
|
10772
10812
|
}
|
10773
10813
|
}]);
|
10774
|
-
return
|
10814
|
+
return ke;
|
10775
10815
|
}();
|
10776
10816
|
var aa = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg height=\"1.4em\" width=\"1.4em\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t viewBox=\"0 0 490.9 490.9\" xml:space=\"preserve\">\n\t<g>\n\t\t<g>\n\t\t\t<path d=\"M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v130.5\n\t\t\t\tC149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5\n\t\t\t\tc0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z\"/>\n\t\t\t<path d=\"M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3\n\t\t\t\ts5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8\n\t\t\t\tc0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9\n\t\t\t\tC106.6,220,101.2,214.5,94.4,214.5z\"/>\n\t\t</g>\n\t</g>\n</svg>\n";
|
10777
10817
|
var xt = /*#__PURE__*/function (_Tt3) {
|
10778
10818
|
_inherits(xt, _Tt3);
|
10779
10819
|
function xt(e) {
|
10780
|
-
var
|
10820
|
+
var _this52;
|
10781
10821
|
_classCallCheck(this, xt);
|
10782
|
-
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"),
|
10783
|
-
return
|
10822
|
+
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"), _this52 = _callSuper(this, xt, [xt.createMicrophoneElement(), e == null ? void 0 : e.position, e]), _this52.isActive = !1, _this52._innerElements = _this52.createInnerElements(_this52._customStyles), _this52.changeToDefault();
|
10823
|
+
return _this52;
|
10784
10824
|
}
|
10785
10825
|
_createClass(xt, [{
|
10786
10826
|
key: "createInnerElements",
|
@@ -10859,21 +10899,21 @@ Object.defineProperty(ze, "__esModule", {
|
|
10859
10899
|
value: !0
|
10860
10900
|
});
|
10861
10901
|
ze.Text = void 0;
|
10862
|
-
var
|
10863
|
-
function
|
10864
|
-
_classCallCheck(this,
|
10902
|
+
var Ee = /*#__PURE__*/function () {
|
10903
|
+
function Ee() {
|
10904
|
+
_classCallCheck(this, Ee);
|
10865
10905
|
}
|
10866
|
-
_createClass(
|
10906
|
+
_createClass(Ee, null, [{
|
10867
10907
|
key: "capitalize",
|
10868
10908
|
value: function capitalize(e) {
|
10869
|
-
return e.replace(
|
10909
|
+
return e.replace(Ee.FIRST_CHAR_REGEX, function (t) {
|
10870
10910
|
return t.toUpperCase();
|
10871
10911
|
});
|
10872
10912
|
}
|
10873
10913
|
}, {
|
10874
10914
|
key: "lineBreak",
|
10875
10915
|
value: function lineBreak(e) {
|
10876
|
-
return e.replace(
|
10916
|
+
return e.replace(Ee.DOUBLE_LINE, "<p></p>").replace(Ee.ONE_LINE, "<br>");
|
10877
10917
|
}
|
10878
10918
|
}, {
|
10879
10919
|
key: "isCharDefined",
|
@@ -10887,12 +10927,12 @@ var xe = /*#__PURE__*/function () {
|
|
10887
10927
|
return e.split(/(\W+)/);
|
10888
10928
|
}
|
10889
10929
|
}]);
|
10890
|
-
return
|
10930
|
+
return Ee;
|
10891
10931
|
}();
|
10892
|
-
ze.Text =
|
10893
|
-
|
10894
|
-
|
10895
|
-
|
10932
|
+
ze.Text = Ee;
|
10933
|
+
Ee.FIRST_CHAR_REGEX = /\S/;
|
10934
|
+
Ee.DOUBLE_LINE = /\n\n/g;
|
10935
|
+
Ee.ONE_LINE = /\n/g;
|
10896
10936
|
Object.defineProperty(At, "__esModule", {
|
10897
10937
|
value: !0
|
10898
10938
|
});
|
@@ -10987,9 +11027,9 @@ var Y = /*#__PURE__*/function () {
|
|
10987
11027
|
}, {
|
10988
11028
|
key: "keyDownWindow",
|
10989
11029
|
value: function keyDownWindow(e) {
|
10990
|
-
var
|
11030
|
+
var _this53 = this;
|
10991
11031
|
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,
|
11032
|
+
Y.KEY_DOWN_TIMEOUT = null, _this53.resetRecording(e);
|
10993
11033
|
}, 500));
|
10994
11034
|
}
|
10995
11035
|
}, {
|
@@ -11112,10 +11152,10 @@ var ha = /*#__PURE__*/function () {
|
|
11112
11152
|
key: "appendSpans",
|
11113
11153
|
value: function appendSpans(e, t) {
|
11114
11154
|
if (e.spansPopulated = !0, e.insertInCursorLocation && document.activeElement === t) {
|
11115
|
-
var
|
11116
|
-
if (
|
11117
|
-
var n =
|
11118
|
-
n.insertNode(e.scrollingSpan), n.insertNode(e.interimSpan), n.insertNode(e.finalSpan), n.collapse(!1),
|
11155
|
+
var _i17 = window.getSelection();
|
11156
|
+
if (_i17 != null && _i17.focusNode) {
|
11157
|
+
var n = _i17.getRangeAt(0);
|
11158
|
+
n.insertNode(e.scrollingSpan), n.insertNode(e.interimSpan), n.insertNode(e.finalSpan), n.collapse(!1), _i17.removeAllRanges(), _i17.addRange(n);
|
11119
11159
|
return;
|
11120
11160
|
}
|
11121
11161
|
}
|
@@ -11609,22 +11649,22 @@ var Yt = /*#__PURE__*/function (_ya$Speech) {
|
|
11609
11649
|
}, {
|
11610
11650
|
key: "setEvents",
|
11611
11651
|
value: function setEvents() {
|
11612
|
-
var
|
11652
|
+
var _this54 = this;
|
11613
11653
|
this._service && (this._service.onstart = function () {
|
11614
|
-
|
11654
|
+
_this54.setStateOnStart();
|
11615
11655
|
}, this._service.onerror = function (e) {
|
11616
|
-
jn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" &&
|
11656
|
+
jn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" && _this54.isRestarting || e.error !== "no-speech" && _this54.error(e.message || e.error);
|
11617
11657
|
}, this._service.onaudioend = function () {
|
11618
|
-
|
11658
|
+
_this54.setStateOnStop();
|
11619
11659
|
}, this._service.onend = function () {
|
11620
|
-
|
11660
|
+
_this54._stopping = !1;
|
11621
11661
|
}, this._service.onresult = function (e) {
|
11622
|
-
if (_typeof(e.results) > "u" &&
|
11623
|
-
var
|
11624
|
-
t =
|
11625
|
-
|
11626
|
-
n =
|
11627
|
-
|
11662
|
+
if (_typeof(e.results) > "u" && _this54._service) _this54._service.onend = null, _this54._service.stop();else if (_this54._extractText && !_this54._stopping) {
|
11663
|
+
var _this54$_extractText = _this54._extractText(e, _this54.finalTranscript, _this54._translations),
|
11664
|
+
t = _this54$_extractText.interimTranscript,
|
11665
|
+
_i18 = _this54$_extractText.finalTranscript,
|
11666
|
+
n = _this54$_extractText.newText;
|
11667
|
+
_this54.updateElements(t, _i18, n);
|
11628
11668
|
}
|
11629
11669
|
});
|
11630
11670
|
}
|
@@ -11835,23 +11875,23 @@ Object.defineProperty(gi, "__esModule", {
|
|
11835
11875
|
value: !0
|
11836
11876
|
});
|
11837
11877
|
gi.Azure = void 0;
|
11838
|
-
var
|
11839
|
-
|
11878
|
+
var Fn = bi,
|
11879
|
+
Bn = vi,
|
11840
11880
|
Ni = xi,
|
11841
11881
|
zn = Ei,
|
11842
11882
|
Sa = kt;
|
11843
11883
|
var Xt = /*#__PURE__*/function (_Sa$Speech) {
|
11844
11884
|
_inherits(Xt, _Sa$Speech);
|
11845
11885
|
function Xt() {
|
11846
|
-
var
|
11886
|
+
var _this55;
|
11847
11887
|
_classCallCheck(this, Xt);
|
11848
|
-
|
11849
|
-
return
|
11888
|
+
_this55 = _callSuper(this, Xt, arguments), _this55._newTextPadding = "";
|
11889
|
+
return _this55;
|
11850
11890
|
}
|
11851
11891
|
_createClass(Xt, [{
|
11852
11892
|
key: "start",
|
11853
11893
|
value: function start(e, t) {
|
11854
|
-
this._newTextPadding = "", this.stopTimeout === void 0 && Ni.StopTimeout.reset(this, e == null ? void 0 : e.stopAfterSilenceMs), this.prepareBeforeStart(e), this.startAsync(e), t ||
|
11894
|
+
this._newTextPadding = "", this.stopTimeout === void 0 && Ni.StopTimeout.reset(this, e == null ? void 0 : e.stopAfterSilenceMs), this.prepareBeforeStart(e), this.startAsync(e), t || Fn.PreventConnectionStop.applyPrevention(this);
|
11855
11895
|
}
|
11856
11896
|
}, {
|
11857
11897
|
key: "startAsync",
|
@@ -11885,7 +11925,7 @@ var Xt = /*#__PURE__*/function (_Sa$Speech) {
|
|
11885
11925
|
}, {
|
11886
11926
|
key: "validate",
|
11887
11927
|
value: function validate(e) {
|
11888
|
-
return Xt.getAPI() ?
|
11928
|
+
return Xt.getAPI() ? Bn.AzureSpeechConfig.validateOptions(this.error.bind(this), e) : (this.moduleNotFound(), !1);
|
11889
11929
|
}
|
11890
11930
|
}, {
|
11891
11931
|
key: "instantiateService",
|
@@ -11898,7 +11938,7 @@ var Xt = /*#__PURE__*/function (_Sa$Speech) {
|
|
11898
11938
|
t = Xt.getAPI();
|
11899
11939
|
i = t.AudioConfig.fromDefaultMicrophoneInput();
|
11900
11940
|
_context102.next = 4;
|
11901
|
-
return
|
11941
|
+
return Bn.AzureSpeechConfig.get(t.SpeechConfig, e);
|
11902
11942
|
case 4:
|
11903
11943
|
n = _context102.sent;
|
11904
11944
|
if (n) {
|
@@ -11964,7 +12004,7 @@ var Xt = /*#__PURE__*/function (_Sa$Speech) {
|
|
11964
12004
|
}, {
|
11965
12005
|
key: "onSessionStarted",
|
11966
12006
|
value: function onSessionStarted() {
|
11967
|
-
|
12007
|
+
Fn.PreventConnectionStop.clearPrevention(this), this.setStateOnStart();
|
11968
12008
|
}
|
11969
12009
|
}, {
|
11970
12010
|
key: "onSessionStopped",
|
@@ -11974,12 +12014,12 @@ var Xt = /*#__PURE__*/function (_Sa$Speech) {
|
|
11974
12014
|
}, {
|
11975
12015
|
key: "retrieveTokenInterval",
|
11976
12016
|
value: function retrieveTokenInterval(e) {
|
11977
|
-
var
|
12017
|
+
var _this56 = this;
|
11978
12018
|
this._retrieveTokenInterval = setInterval(function () {
|
11979
12019
|
e == null || e().then(function (t) {
|
11980
|
-
|
12020
|
+
_this56._service && (_this56._service.authorizationToken = (t == null ? void 0 : t.trim()) || "");
|
11981
12021
|
})["catch"](function (t) {
|
11982
|
-
|
12022
|
+
_this56.error(t);
|
11983
12023
|
});
|
11984
12024
|
}, 1e4);
|
11985
12025
|
}
|
@@ -12060,18 +12100,18 @@ var Oi = xs["default"] = Ke;
|
|
12060
12100
|
var Qt = /*#__PURE__*/function (_xt) {
|
12061
12101
|
_inherits(Qt, _xt);
|
12062
12102
|
function Qt(e, t, i) {
|
12063
|
-
var
|
12103
|
+
var _this57;
|
12064
12104
|
_classCallCheck(this, Qt);
|
12065
12105
|
var o;
|
12066
|
-
|
12106
|
+
_this57 = _callSuper(this, Qt, [_typeof(e.speechToText) == "object" ? (o = e.speechToText) == null ? void 0 : o.button : {}]);
|
12067
12107
|
var _Qt$processConfigurat = Qt.processConfiguration(t, e.speechToText),
|
12068
12108
|
n = _Qt$processConfigurat.serviceName,
|
12069
12109
|
r = _Qt$processConfigurat.processedConfig;
|
12070
|
-
if (
|
12110
|
+
if (_this57._addErrorMessage = i, n === "webspeech" && !Oi.isWebSpeechSupported()) _this57.changeToUnsupported();else {
|
12071
12111
|
var a = !e.textInput || !e.textInput.disabled;
|
12072
|
-
|
12112
|
+
_this57.elementRef.onclick = _this57.buttonClick.bind(_assertThisInitialized(_this57), t, a, n, r);
|
12073
12113
|
}
|
12074
|
-
return
|
12114
|
+
return _this57;
|
12075
12115
|
}
|
12076
12116
|
// prettier-ignore
|
12077
12117
|
_createClass(Qt, [{
|
@@ -12151,11 +12191,11 @@ var Es = /*#__PURE__*/function () {
|
|
12151
12191
|
var Ta = /*#__PURE__*/function (_xt2) {
|
12152
12192
|
_inherits(Ta, _xt2);
|
12153
12193
|
function Ta(e, t) {
|
12154
|
-
var
|
12194
|
+
var _this58;
|
12155
12195
|
_classCallCheck(this, Ta);
|
12156
12196
|
var i, n;
|
12157
|
-
|
12158
|
-
return
|
12197
|
+
_this58 = _callSuper(this, Ta, [t.button]), _this58._waitingForBrowserApproval = !1, _this58._audioType = e, _this58._extension = ((i = t.files) == null ? void 0 : i.format) || "mp3", _this58._maxDurationSeconds = (n = t.files) == null ? void 0 : n.maxDurationSeconds, _this58.elementRef.onclick = _this58.buttonClick.bind(_assertThisInitialized(_this58));
|
12198
|
+
return _this58;
|
12159
12199
|
}
|
12160
12200
|
_createClass(Ta, [{
|
12161
12201
|
key: "buttonClick",
|
@@ -12165,10 +12205,10 @@ var Ta = /*#__PURE__*/function (_xt2) {
|
|
12165
12205
|
}, {
|
12166
12206
|
key: "stop",
|
12167
12207
|
value: function stop() {
|
12168
|
-
var
|
12208
|
+
var _this59 = this;
|
12169
12209
|
return new Promise(function (e) {
|
12170
12210
|
var t, i;
|
12171
|
-
|
12211
|
+
_this59.changeToDefault(), (t = _this59._mediaRecorder) == null || t.stop(), (i = _this59._mediaStream) == null || i.getTracks().forEach(function (n) {
|
12172
12212
|
return n.stop();
|
12173
12213
|
}), setTimeout(function () {
|
12174
12214
|
e();
|
@@ -12178,23 +12218,23 @@ var Ta = /*#__PURE__*/function (_xt2) {
|
|
12178
12218
|
}, {
|
12179
12219
|
key: "record",
|
12180
12220
|
value: function record() {
|
12181
|
-
var
|
12221
|
+
var _this60 = this;
|
12182
12222
|
navigator.mediaDevices.getUserMedia({
|
12183
12223
|
audio: !0
|
12184
12224
|
}).then(function (e) {
|
12185
|
-
|
12186
|
-
|
12187
|
-
}),
|
12225
|
+
_this60.changeToActive(), _this60._mediaRecorder = new MediaRecorder(e), _this60._audioType.addPlaceholderAttachment(_this60.stop.bind(_this60), _this60._maxDurationSeconds), _this60._mediaStream = e, _this60._mediaRecorder.addEventListener("dataavailable", function (t) {
|
12226
|
+
_this60.createFile(t);
|
12227
|
+
}), _this60._mediaRecorder.start();
|
12188
12228
|
})["catch"](function (e) {
|
12189
|
-
console.error(e),
|
12229
|
+
console.error(e), _this60.stop();
|
12190
12230
|
})["finally"](function () {
|
12191
|
-
|
12231
|
+
_this60._waitingForBrowserApproval = !1;
|
12192
12232
|
});
|
12193
12233
|
}
|
12194
12234
|
}, {
|
12195
12235
|
key: "createFile",
|
12196
12236
|
value: function createFile(e) {
|
12197
|
-
var
|
12237
|
+
var _this61 = this;
|
12198
12238
|
var t = new Blob([e.data], {
|
12199
12239
|
type: "audio/".concat(this._extension)
|
12200
12240
|
}),
|
@@ -12204,7 +12244,7 @@ var Ta = /*#__PURE__*/function (_xt2) {
|
|
12204
12244
|
}),
|
12205
12245
|
r = new FileReader();
|
12206
12246
|
r.readAsDataURL(n), r.onload = function (o) {
|
12207
|
-
|
12247
|
+
_this61._audioType.completePlaceholderAttachment(n, o.target.result);
|
12208
12248
|
};
|
12209
12249
|
}
|
12210
12250
|
}]);
|
@@ -12248,11 +12288,11 @@ var z = /*#__PURE__*/function () {
|
|
12248
12288
|
}]);
|
12249
12289
|
return z;
|
12250
12290
|
}();
|
12251
|
-
var
|
12252
|
-
function
|
12253
|
-
_classCallCheck(this,
|
12291
|
+
var Le = /*#__PURE__*/function () {
|
12292
|
+
function Le() {
|
12293
|
+
_classCallCheck(this, Le);
|
12254
12294
|
}
|
12255
|
-
_createClass(
|
12295
|
+
_createClass(Le, null, [{
|
12256
12296
|
key: "resetSubmit",
|
12257
12297
|
value: function resetSubmit(e, t) {
|
12258
12298
|
t ? e.unsetCustomStateStyles(["loading", "submit"]) : e.unsetCustomStateStyles(["stop", "loading", "submit"]), e.reapplyStateStyle("submit");
|
@@ -12268,48 +12308,48 @@ var Ie = /*#__PURE__*/function () {
|
|
12268
12308
|
}, {
|
12269
12309
|
key: "setUpDisabledButton",
|
12270
12310
|
value: function setUpDisabledButton(e) {
|
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%)"),
|
12311
|
+
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%)"), Le.overwriteDefaultStyleWithSubmit(e, "disabled");
|
12272
12312
|
}
|
12273
12313
|
}, {
|
12274
12314
|
key: "process",
|
12275
12315
|
value: function process(e) {
|
12276
12316
|
var t = JSON.parse(JSON.stringify(e || {}));
|
12277
|
-
return
|
12317
|
+
return Le.overwriteDefaultStyleWithSubmit(t, "loading"), Le.overwriteDefaultStyleWithSubmit(t, "stop"), e != null && e.alwaysEnabled || Le.setUpDisabledButton(t), t;
|
12278
12318
|
}
|
12279
12319
|
}]);
|
12280
|
-
return
|
12320
|
+
return Le;
|
12281
12321
|
}();
|
12282
12322
|
var _i = /*#__PURE__*/function (_Tt4) {
|
12283
|
-
_inherits(
|
12323
|
+
_inherits(I, _Tt4);
|
12284
12324
|
// prettier-ignore
|
12285
|
-
function
|
12286
|
-
var
|
12287
|
-
_classCallCheck(this,
|
12288
|
-
var o =
|
12289
|
-
|
12325
|
+
function I(e, t, i, n, r) {
|
12326
|
+
var _this62;
|
12327
|
+
_classCallCheck(this, I);
|
12328
|
+
var o = Le.process(e.submitButtonStyles);
|
12329
|
+
_this62 = _callSuper(this, I, [I.createButtonContainerElement(), o == null ? void 0 : o.position, o]), _this62._isSVGLoadingIconOverriden = !1, _this62.status = {
|
12290
12330
|
requestInProgress: !1,
|
12291
12331
|
loadingActive: !1
|
12292
|
-
},
|
12332
|
+
}, _this62._messages = i, _this62._inputElementRef = t, _this62._fileAttachments = r, _this62._innerElements = _this62.createInnerElements(), _this62._abortStream = new AbortController(), _this62._stopClicked = {
|
12293
12333
|
listener: function listener() {}
|
12294
|
-
},
|
12334
|
+
}, _this62._serviceIO = n, _this62._alwaysEnabled = !!(o != null && o.alwaysEnabled), e.disableSubmitButton = _this62.disableSubmitButton.bind(_assertThisInitialized(_this62), n), _this62.attemptOverwriteLoadingStyle(e), setTimeout(function () {
|
12295
12335
|
var a;
|
12296
|
-
|
12336
|
+
_this62._validationHandler = e._validationHandler, _this62.assignHandlers(_this62._validationHandler), (a = _this62._validationHandler) == null || a.call(_assertThisInitialized(_this62));
|
12297
12337
|
});
|
12298
|
-
return
|
12338
|
+
return _this62;
|
12299
12339
|
}
|
12300
12340
|
// prettier-ignore
|
12301
|
-
_createClass(
|
12341
|
+
_createClass(I, [{
|
12302
12342
|
key: "createInnerElements",
|
12303
12343
|
value: function createInnerElements() {
|
12304
12344
|
var _j$create = j.create(this.elementRef, ["submit", "loading", "stop"], this._customStyles),
|
12305
12345
|
e = _j$create.submit,
|
12306
12346
|
t = _j$create.loading,
|
12307
12347
|
i = _j$create.stop,
|
12308
|
-
n = e ||
|
12348
|
+
n = e || I.createSubmitIconElement();
|
12309
12349
|
return {
|
12310
12350
|
submit: n,
|
12311
|
-
loading: t ||
|
12312
|
-
stop: i ||
|
12351
|
+
loading: t || I.createLoadingIconElement(),
|
12352
|
+
stop: i || I.createStopIconElement(),
|
12313
12353
|
disabled: this.createDisabledIconElement(n)
|
12314
12354
|
};
|
12315
12355
|
}
|
@@ -12351,7 +12391,7 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12351
12391
|
key: "submitFromInput",
|
12352
12392
|
value: function () {
|
12353
12393
|
var _submitFromInput = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee103() {
|
12354
|
-
var t, e,
|
12394
|
+
var t, e, _i19;
|
12355
12395
|
return _regeneratorRuntime().wrap(function _callee103$(_context103) {
|
12356
12396
|
while (1) switch (_context103.prev = _context103.next) {
|
12357
12397
|
case 0:
|
@@ -12363,9 +12403,9 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12363
12403
|
text: "",
|
12364
12404
|
files: e
|
12365
12405
|
});else {
|
12366
|
-
|
12406
|
+
_i19 = (t = this._inputElementRef.textContent) == null ? void 0 : t.trim();
|
12367
12407
|
this.attemptSubmit({
|
12368
|
-
text:
|
12408
|
+
text: _i19,
|
12369
12409
|
files: e
|
12370
12410
|
});
|
12371
12411
|
}
|
@@ -12384,7 +12424,7 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12384
12424
|
key: "programmaticSubmit",
|
12385
12425
|
value: function () {
|
12386
12426
|
var _programmaticSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee104(e) {
|
12387
|
-
var
|
12427
|
+
var _this63 = this;
|
12388
12428
|
var t;
|
12389
12429
|
return _regeneratorRuntime().wrap(function _callee104$(_context104) {
|
12390
12430
|
while (1) switch (_context104.prev = _context104.next) {
|
@@ -12396,10 +12436,10 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12396
12436
|
e.files && (t.files = Array.from(e.files).map(function (i) {
|
12397
12437
|
return {
|
12398
12438
|
file: i,
|
12399
|
-
type:
|
12439
|
+
type: he.getTypeFromBlob(i)
|
12400
12440
|
};
|
12401
12441
|
})), setTimeout(function () {
|
12402
|
-
return
|
12442
|
+
return _this63.attemptSubmit(t, !0);
|
12403
12443
|
});
|
12404
12444
|
case 3:
|
12405
12445
|
case "end":
|
@@ -12510,26 +12550,26 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12510
12550
|
}, {
|
12511
12551
|
key: "changeToStopIcon",
|
12512
12552
|
value: function changeToStopIcon() {
|
12513
|
-
this._serviceIO.websocket || (this.elementRef.classList.remove(
|
12553
|
+
this._serviceIO.websocket || (this.elementRef.classList.remove(I.LOADING_CLASS, I.DISABLED_CLASS, I.SUBMIT_CLASS), this.elementRef.replaceChildren(this._innerElements.stop), this.reapplyStateStyle("stop", ["loading", "submit"]), this.elementRef.onclick = this.stopStream.bind(this), this.status.loadingActive = !1);
|
12514
12554
|
}
|
12515
12555
|
// WORK - animation needs to be lowered
|
12516
12556
|
}, {
|
12517
12557
|
key: "changeToLoadingIcon",
|
12518
12558
|
value: function changeToLoadingIcon() {
|
12519
|
-
this._serviceIO.websocket || (this._isSVGLoadingIconOverriden || this.elementRef.replaceChildren(this._innerElements.loading), this.elementRef.classList.remove(
|
12559
|
+
this._serviceIO.websocket || (this._isSVGLoadingIconOverriden || this.elementRef.replaceChildren(this._innerElements.loading), this.elementRef.classList.remove(I.SUBMIT_CLASS, I.DISABLED_CLASS), this.elementRef.classList.add(I.LOADING_CLASS), this.reapplyStateStyle("loading", ["submit"]), this.elementRef.onclick = function () {}, this.status.requestInProgress = !0, this.status.loadingActive = !0);
|
12520
12560
|
}
|
12521
12561
|
// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
|
12522
12562
|
}, {
|
12523
12563
|
key: "changeToSubmitIcon",
|
12524
12564
|
value: function changeToSubmitIcon() {
|
12525
|
-
this.elementRef.classList.contains(
|
12565
|
+
this.elementRef.classList.contains(I.SUBMIT_CLASS) || (this.elementRef.classList.remove(I.LOADING_CLASS, I.DISABLED_CLASS), this.elementRef.classList.add(I.SUBMIT_CLASS), this.elementRef.replaceChildren(this._innerElements.submit), Le.resetSubmit(this, this.status.loadingActive), this.elementRef.onclick = this.submitFromInput.bind(this));
|
12526
12566
|
}
|
12527
12567
|
// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
|
12528
12568
|
}, {
|
12529
12569
|
key: "changeToDisabledIcon",
|
12530
12570
|
value: function changeToDisabledIcon() {
|
12531
12571
|
var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : !1;
|
12532
|
-
this._alwaysEnabled && !e ? this.changeToSubmitIcon() : this.elementRef.classList.contains(
|
12572
|
+
this._alwaysEnabled && !e ? this.changeToSubmitIcon() : this.elementRef.classList.contains(I.DISABLED_CLASS) || (this.elementRef.classList.remove(I.LOADING_CLASS, I.SUBMIT_CLASS), this.elementRef.classList.add(I.DISABLED_CLASS), this.elementRef.replaceChildren(this._innerElements.disabled), this.reapplyStateStyle("disabled", ["submit"]), this.elementRef.onclick = function () {});
|
12533
12573
|
}
|
12534
12574
|
}, {
|
12535
12575
|
key: "disableSubmitButton",
|
@@ -12562,7 +12602,7 @@ var _i = /*#__PURE__*/function (_Tt4) {
|
|
12562
12602
|
return e.id = "stop-icon", e;
|
12563
12603
|
}
|
12564
12604
|
}]);
|
12565
|
-
return
|
12605
|
+
return I;
|
12566
12606
|
}(Tt);
|
12567
12607
|
_i.SUBMIT_CLASS = "submit-button";
|
12568
12608
|
_i.LOADING_CLASS = "loading-button";
|
@@ -12576,14 +12616,14 @@ var rn = /*#__PURE__*/function (_ct) {
|
|
12576
12616
|
_inherits(rn, _ct);
|
12577
12617
|
// prettier-ignore
|
12578
12618
|
function rn(e, t, i, n) {
|
12579
|
-
var
|
12619
|
+
var _this64;
|
12580
12620
|
_classCallCheck(this, rn);
|
12581
|
-
|
12582
|
-
var
|
12583
|
-
r =
|
12584
|
-
o =
|
12585
|
-
|
12586
|
-
return
|
12621
|
+
_this64 = _callSuper(this, rn, [e, ["modal-content", "modal-camera-content"], i]), _this64._stopped = !1, _this64._format = "image/png", _this64._canvas = document.createElement("canvas"), _this64._canvas.classList.add("camera-modal-canvas");
|
12622
|
+
var _this64$addButtonsAnd = _this64.addButtonsAndTheirEvents(t),
|
12623
|
+
r = _this64$addButtonsAnd.captureButton,
|
12624
|
+
o = _this64$addButtonsAnd.submitButton;
|
12625
|
+
_this64._captureButton = r, _this64._submitButton = o, _this64._captureIcon = _this64._captureButton.children[0], _this64._refreshIcon = G.createSVGElement(ka), _this64._refreshIcon.classList.add("modal-svg-button-icon", "modal-svg-refresh-icon"), (n == null ? void 0 : n.format) === "jpeg" && (_this64._format = "image/jpeg"), n != null && n.dimensions && (_this64._dimensions = n.dimensions), _this64._contentRef.appendChild(_this64._canvas), _this64.extensionCloseCallback = _this64.stop;
|
12626
|
+
return _this64;
|
12587
12627
|
}
|
12588
12628
|
_createClass(rn, [{
|
12589
12629
|
key: "addButtonsAndTheirEvents",
|
@@ -12602,38 +12642,38 @@ var rn = /*#__PURE__*/function (_ct) {
|
|
12602
12642
|
}, {
|
12603
12643
|
key: "addButtonEvents",
|
12604
12644
|
value: function addButtonEvents(e, t, i, n) {
|
12605
|
-
var
|
12645
|
+
var _this65 = this;
|
12606
12646
|
e.onclick = function () {
|
12607
|
-
|
12647
|
+
_this65.capture();
|
12608
12648
|
}, t.addEventListener("click", this.stop.bind(this)), i.onclick = function () {
|
12609
|
-
var r =
|
12610
|
-
r && Ct.addFilesToType([r], [n]),
|
12649
|
+
var r = _this65.getFile();
|
12650
|
+
r && Ct.addFilesToType([r], [n]), _this65.stop(), _this65.close();
|
12611
12651
|
};
|
12612
12652
|
}
|
12613
12653
|
}, {
|
12614
12654
|
key: "stop",
|
12615
12655
|
value: function stop() {
|
12616
|
-
var
|
12656
|
+
var _this66 = this;
|
12617
12657
|
this._mediaStream && this._mediaStream.getTracks().forEach(function (e) {
|
12618
12658
|
return e.stop();
|
12619
12659
|
}), this._stopped = !0, setTimeout(function () {
|
12620
|
-
|
12621
|
-
var e =
|
12622
|
-
e == null || e.clearRect(0, 0,
|
12660
|
+
_this66._captureButton.replaceChildren(_this66._captureIcon), _this66._captureButton.classList.replace("modal-svg-refresh-button", "modal-svg-camera-button");
|
12661
|
+
var e = _this66._canvas.getContext("2d");
|
12662
|
+
e == null || e.clearRect(0, 0, _this66._canvas.width, _this66._canvas.height);
|
12623
12663
|
}, ct.MODAL_CLOSE_TIMEOUT_MS);
|
12624
12664
|
}
|
12625
12665
|
}, {
|
12626
12666
|
key: "start",
|
12627
12667
|
value: function start() {
|
12628
|
-
var
|
12668
|
+
var _this67 = this;
|
12629
12669
|
this._dataURL = void 0, this._submitButton.classList.add("modal-svg-submit-disabled"), this._stopped = !1, navigator.mediaDevices.getUserMedia({
|
12630
12670
|
video: this._dimensions || !0
|
12631
12671
|
}).then(function (e) {
|
12632
|
-
if (
|
12672
|
+
if (_this67._mediaStream = e, !_this67.isOpen()) return _this67.stop();
|
12633
12673
|
var t = document.createElement("video");
|
12634
|
-
t.srcObject = e, t.play(), requestAnimationFrame(
|
12674
|
+
t.srcObject = e, t.play(), requestAnimationFrame(_this67.updateCanvas.bind(_this67, t, _this67._canvas));
|
12635
12675
|
})["catch"](function (e) {
|
12636
|
-
console.error(e),
|
12676
|
+
console.error(e), _this67.stop(), _this67.close();
|
12637
12677
|
});
|
12638
12678
|
}
|
12639
12679
|
}, {
|
@@ -12648,8 +12688,8 @@ var rn = /*#__PURE__*/function (_ct) {
|
|
12648
12688
|
var e = atob(this._dataURL.split(",")[1]),
|
12649
12689
|
t = new Array(e.length);
|
12650
12690
|
for (var a = 0; a < e.length; a++) t[a] = e.charCodeAt(a);
|
12651
|
-
var
|
12652
|
-
n = new Blob([
|
12691
|
+
var _i20 = new Uint8Array(t),
|
12692
|
+
n = new Blob([_i20], {
|
12653
12693
|
type: this._format
|
12654
12694
|
}),
|
12655
12695
|
r = this._format === "image/jpeg" ? "jpeg" : "png",
|
@@ -12665,8 +12705,8 @@ var rn = /*#__PURE__*/function (_ct) {
|
|
12665
12705
|
if (!this._stopped) {
|
12666
12706
|
if (!this._dataURL) {
|
12667
12707
|
t.width = e.videoWidth, t.height = e.videoHeight;
|
12668
|
-
var
|
12669
|
-
|
12708
|
+
var _i21 = t.getContext("2d");
|
12709
|
+
_i21 == null || _i21.drawImage(e, 0, 0, t.width, t.height);
|
12670
12710
|
}
|
12671
12711
|
requestAnimationFrame(this.updateCanvas.bind(this, e, t));
|
12672
12712
|
}
|
@@ -12690,13 +12730,13 @@ var Na = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12690
12730
|
var ei = /*#__PURE__*/function (_Tt5) {
|
12691
12731
|
_inherits(ei, _Tt5);
|
12692
12732
|
function ei(e, t, i) {
|
12693
|
-
var
|
12733
|
+
var _this68;
|
12694
12734
|
_classCallCheck(this, ei);
|
12695
12735
|
var r;
|
12696
|
-
|
12697
|
-
var n =
|
12698
|
-
i &&
|
12699
|
-
return
|
12736
|
+
_this68 = _callSuper(this, ei, [ei.createButtonElement(), (r = i == null ? void 0 : i.button) == null ? void 0 : r.position, (i == null ? void 0 : i.button) || {}, "Photo"]);
|
12737
|
+
var n = _this68.createInnerElements(_this68._customStyles);
|
12738
|
+
i && _this68.addClickEvent(e, t, i.modalContainerStyle, i.files), _this68.elementRef.classList.add("upload-file-button"), _this68.elementRef.appendChild(n.styles), _this68.reapplyStateStyle("styles");
|
12739
|
+
return _this68;
|
12700
12740
|
}
|
12701
12741
|
_createClass(ei, [{
|
12702
12742
|
key: "createInnerElements",
|
@@ -12744,7 +12784,7 @@ var mt = /*#__PURE__*/function () {
|
|
12744
12784
|
button: new Qt(e, r, t.addNewErrorMessage.bind(t))
|
12745
12785
|
});
|
12746
12786
|
var l = new Aa(e, r.inputElementRef, t, i, a);
|
12747
|
-
r.submit = l.submitFromInput.bind(l),
|
12787
|
+
r.submit = l.submitFromInput.bind(l), ke.attach(e, i, r, a, l), e.submitUserMessage = l.programmaticSubmit.bind(l), o.submit = {
|
12748
12788
|
button: l
|
12749
12789
|
}, mt.addElements(this.elementRef, r, o, n, a, e.dropupStyles);
|
12750
12790
|
}
|
@@ -12802,7 +12842,7 @@ var mt = /*#__PURE__*/function () {
|
|
12802
12842
|
value: function addElements(e, t, i, n, r, o) {
|
12803
12843
|
Z.addElements(e, t.elementRef);
|
12804
12844
|
var a = tt.create(),
|
12805
|
-
l =
|
12845
|
+
l = F.addButtons(a, i, n, o);
|
12806
12846
|
Xo.set(t.inputElementRef, a, r.elementRef, l), tt.add(e, a);
|
12807
12847
|
}
|
12808
12848
|
}]);
|
@@ -12817,8 +12857,8 @@ var on = /*#__PURE__*/function () {
|
|
12817
12857
|
value: function createElements(e, t, i) {
|
12818
12858
|
var n = document.createElement("div");
|
12819
12859
|
n.id = "chat-view";
|
12820
|
-
var r = new
|
12821
|
-
t.websocket &&
|
12860
|
+
var r = new ge(e, t, i);
|
12861
|
+
t.websocket && B.createConnection(t, r);
|
12822
12862
|
var o = new mt(e, r, t, n);
|
12823
12863
|
return Z.addElements(n, r.elementRef, o.elementRef), n;
|
12824
12864
|
}
|
@@ -12841,22 +12881,22 @@ var Pa = Object.defineProperty,
|
|
12841
12881
|
var v = /*#__PURE__*/function (_So) {
|
12842
12882
|
_inherits(v, _So);
|
12843
12883
|
function v() {
|
12844
|
-
var
|
12884
|
+
var _this69;
|
12845
12885
|
_classCallCheck(this, v);
|
12846
|
-
|
12886
|
+
_this69 = _callSuper(this, v), _this69.getMessages = function () {
|
12847
12887
|
return [];
|
12848
|
-
},
|
12888
|
+
}, _this69.submitUserMessage = function () {
|
12849
12889
|
return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");
|
12850
|
-
},
|
12851
|
-
return ti.focusFromParentElement(
|
12852
|
-
},
|
12890
|
+
}, _this69.focusInput = function () {
|
12891
|
+
return ti.focusFromParentElement(_this69._elementRef);
|
12892
|
+
}, _this69.refreshMessages = function () {}, _this69.clearMessages = function () {}, _this69.scrollToBottom = function () {}, _this69.disableSubmitButton = function () {}, _this69._hasBeenRendered = !1, _this69._auxiliaryStyleApplied = !1, _this69._addMessage = function () {
|
12853
12893
|
return console.warn("addMessage failed - please wait for chat view to render before calling this property.");
|
12854
|
-
}, Ko.appendStyleSheetToHead(),
|
12894
|
+
}, Ko.appendStyleSheetToHead(), _this69._elementRef = document.createElement("div"), _this69._elementRef.id = "container", _this69.attachShadow({
|
12855
12895
|
mode: "open"
|
12856
|
-
}).appendChild(
|
12857
|
-
|
12896
|
+
}).appendChild(_this69._elementRef), wi.apply(Oa, _this69.shadowRoot), setTimeout(function () {
|
12897
|
+
_this69._hasBeenRendered || _this69.onRender();
|
12858
12898
|
}, 20);
|
12859
|
-
return
|
12899
|
+
return _this69;
|
12860
12900
|
}
|
12861
12901
|
_createClass(v, [{
|
12862
12902
|
key: "changeToChatView",
|
@@ -12868,7 +12908,7 @@ var v = /*#__PURE__*/function (_So) {
|
|
12868
12908
|
key: "onRender",
|
12869
12909
|
value: function onRender() {
|
12870
12910
|
var _this$_childElement;
|
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 ?
|
12911
|
+
(!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 ? Ft.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, Bt.onRender(this);
|
12872
12912
|
}
|
12873
12913
|
}, {
|
12874
12914
|
key: "disconnectedCallback",
|