deep-chat-dev 9.0.12 → 9.0.15
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 +4906 -4497
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.d.ts.map +1 -1
- package/dist/deepChat.js +378 -227
- package/dist/types/html.d.ts +6 -5
- package/dist/types/html.d.ts.map +1 -1
- package/dist/utils/HTTP/customHandler.d.ts.map +1 -1
- package/dist/utils/HTTP/requestUtils.d.ts +2 -0
- package/dist/utils/HTTP/requestUtils.d.ts.map +1 -1
- package/dist/utils/element/styleUtils.d.ts +1 -0
- package/dist/utils/element/styleUtils.d.ts.map +1 -1
- package/dist/views/chat/messages/html/htmlDeepChatElements.d.ts +11 -0
- package/dist/views/chat/messages/html/htmlDeepChatElements.d.ts.map +1 -0
- package/dist/views/chat/messages/html/htmlMessageUtils.d.ts +10 -0
- package/dist/views/chat/messages/html/htmlMessageUtils.d.ts.map +1 -0
- package/dist/views/chat/messages/html/htmlMessages.d.ts +8 -0
- package/dist/views/chat/messages/html/htmlMessages.d.ts.map +1 -0
- package/dist/views/chat/messages/messages.d.ts +3 -1
- package/dist/views/chat/messages/messages.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/views/chat/messages/htmlMessageUtils.d.ts +0 -5
- package/dist/views/chat/messages/htmlMessageUtils.d.ts.map +0 -1
package/dist/deepChat.js
CHANGED
@@ -134,6 +134,18 @@ var StyleUtils = /*#__PURE__*/function () {
|
|
134
134
|
click: a
|
135
135
|
};
|
136
136
|
}
|
137
|
+
}, {
|
138
|
+
key: "mergeStatefulStyles",
|
139
|
+
value: function mergeStatefulStyles(e) {
|
140
|
+
var t = {
|
141
|
+
"default": {},
|
142
|
+
hover: {},
|
143
|
+
click: {}
|
144
|
+
};
|
145
|
+
return e.forEach(function (n) {
|
146
|
+
t["default"] = Object.assign(t["default"], n["default"]), t.hover = Object.assign(t.hover, n.hover), t.click = Object.assign(t.click, n.click);
|
147
|
+
}), t;
|
148
|
+
}
|
137
149
|
}]);
|
138
150
|
return StyleUtils;
|
139
151
|
}();
|
@@ -319,12 +331,109 @@ function getInvalidResponseMessage(r, e, t, n) {
|
|
319
331
|
return "".concat(s + o, "Make sure the ").concat(e, " message is using the Response format: https://deepchat.dev/docs/connect/#Response \n You can also augment it using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor");
|
320
332
|
}
|
321
333
|
var ErrorMessages = {
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
}
|
327
|
-
function
|
334
|
+
INVALID_KEY: "Invalid API Key",
|
335
|
+
CONNECTION_FAILED: "Failed to connect",
|
336
|
+
INVALID_RESPONSE: getInvalidResponseMessage,
|
337
|
+
INVALID_STREAM_RESPONSE: "Make sure the events are using the Response format: https://deepchat.dev/docs/connect/#Response \nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor"
|
338
|
+
},
|
339
|
+
_RequestUtils = /*#__PURE__*/function () {
|
340
|
+
function D() {
|
341
|
+
_classCallCheck(this, D);
|
342
|
+
}
|
343
|
+
_createClass(D, null, [{
|
344
|
+
key: "temporarilyRemoveHeader",
|
345
|
+
value: // need to pass stringifyBody boolean separately as binding is throwing an error for some reason
|
346
|
+
// prettier-ignore
|
347
|
+
function () {
|
348
|
+
var _temporarilyRemoveHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e, t, n) {
|
349
|
+
var s;
|
350
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
351
|
+
while (1) switch (_context.prev = _context.next) {
|
352
|
+
case 0:
|
353
|
+
if (e != null && e.headers) {
|
354
|
+
_context.next = 2;
|
355
|
+
break;
|
356
|
+
}
|
357
|
+
throw new Error("Request settings have not been set up");
|
358
|
+
case 2:
|
359
|
+
s = e.headers[D.CONTENT_TYPE];
|
360
|
+
delete e.headers[D.CONTENT_TYPE];
|
361
|
+
_context.next = 6;
|
362
|
+
return t(n);
|
363
|
+
case 6:
|
364
|
+
e.headers[D.CONTENT_TYPE] = s;
|
365
|
+
case 7:
|
366
|
+
case "end":
|
367
|
+
return _context.stop();
|
368
|
+
}
|
369
|
+
}, _callee);
|
370
|
+
}));
|
371
|
+
function temporarilyRemoveHeader(_x, _x2, _x3) {
|
372
|
+
return _temporarilyRemoveHeader.apply(this, arguments);
|
373
|
+
}
|
374
|
+
return temporarilyRemoveHeader;
|
375
|
+
}()
|
376
|
+
}, {
|
377
|
+
key: "displayError",
|
378
|
+
value: function displayError(e, t) {
|
379
|
+
var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Service error, please try again.";
|
380
|
+
if (console.error(t), _typeof(t) == "object") return Object.keys(t).length === 0 ? e.addNewErrorMessage("service", n) : e.addNewErrorMessage("service", JSON.stringify(t));
|
381
|
+
e.addNewErrorMessage("service", t);
|
382
|
+
}
|
383
|
+
}, {
|
384
|
+
key: "processResponseByType",
|
385
|
+
value: function processResponseByType(e) {
|
386
|
+
var t = e.headers.get("content-type");
|
387
|
+
return t != null && t.includes("application/json") ? e.json() : t != null && t.includes("text/plain") || !t ? e : e.blob();
|
388
|
+
}
|
389
|
+
}, {
|
390
|
+
key: "processRequestInterceptor",
|
391
|
+
value: function () {
|
392
|
+
var _processRequestInterceptor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e, t) {
|
393
|
+
var a, n, s, o;
|
394
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
395
|
+
while (1) switch (_context2.prev = _context2.next) {
|
396
|
+
case 0:
|
397
|
+
_context2.next = 2;
|
398
|
+
return (a = e.requestInterceptor) == null ? void 0 : a.call(e, t);
|
399
|
+
case 2:
|
400
|
+
_context2.t0 = _context2.sent;
|
401
|
+
if (_context2.t0) {
|
402
|
+
_context2.next = 5;
|
403
|
+
break;
|
404
|
+
}
|
405
|
+
_context2.t0 = t;
|
406
|
+
case 5:
|
407
|
+
n = _context2.t0;
|
408
|
+
s = n;
|
409
|
+
o = n;
|
410
|
+
return _context2.abrupt("return", {
|
411
|
+
body: s.body,
|
412
|
+
headers: s.headers,
|
413
|
+
error: o.error
|
414
|
+
});
|
415
|
+
case 9:
|
416
|
+
case "end":
|
417
|
+
return _context2.stop();
|
418
|
+
}
|
419
|
+
}, _callee2);
|
420
|
+
}));
|
421
|
+
function processRequestInterceptor(_x4, _x5) {
|
422
|
+
return _processRequestInterceptor.apply(this, arguments);
|
423
|
+
}
|
424
|
+
return processRequestInterceptor;
|
425
|
+
}()
|
426
|
+
}, {
|
427
|
+
key: "validateResponseFormat",
|
428
|
+
value: function validateResponseFormat(e) {
|
429
|
+
return e && _typeof(e) == "object" && (typeof e.error == "string" || typeof e.text == "string" || typeof e.html == "string" || _typeof(e.files) == "object");
|
430
|
+
}
|
431
|
+
}]);
|
432
|
+
return D;
|
433
|
+
}();
|
434
|
+
_RequestUtils.CONTENT_TYPE = "Content-Type";
|
435
|
+
var RequestUtils = _RequestUtils;
|
436
|
+
function getBytes(_x6, _x7) {
|
328
437
|
return _getBytes.apply(this, arguments);
|
329
438
|
}
|
330
439
|
function _getBytes() {
|
@@ -456,56 +565,56 @@ function fetchEventSource(r, e) {
|
|
456
565
|
y(), h();
|
457
566
|
});
|
458
567
|
var S = u !== null && u !== void 0 ? u : window.fetch,
|
459
|
-
|
568
|
+
_ = s !== null && s !== void 0 ? s : defaultOnOpen;
|
460
569
|
function x() {
|
461
|
-
return
|
570
|
+
return _x8.apply(this, arguments);
|
462
571
|
}
|
463
|
-
function
|
464
|
-
|
465
|
-
var R, w,
|
466
|
-
return _regeneratorRuntime().wrap(function
|
467
|
-
while (1) switch (
|
572
|
+
function _x8() {
|
573
|
+
_x8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
574
|
+
var R, w, E;
|
575
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
576
|
+
while (1) switch (_context3.prev = _context3.next) {
|
468
577
|
case 0:
|
469
578
|
b = new AbortController();
|
470
|
-
|
471
|
-
|
579
|
+
_context3.prev = 1;
|
580
|
+
_context3.next = 4;
|
472
581
|
return S(r, Object.assign(Object.assign({}, d), {
|
473
582
|
headers: p,
|
474
583
|
signal: b.signal
|
475
584
|
}));
|
476
585
|
case 4:
|
477
|
-
w =
|
478
|
-
|
479
|
-
return
|
586
|
+
w = _context3.sent;
|
587
|
+
_context3.next = 7;
|
588
|
+
return _(w);
|
480
589
|
case 7:
|
481
|
-
|
482
|
-
return getBytes(w.body, getLines(getMessages(function (
|
483
|
-
|
484
|
-
}, function (
|
485
|
-
g =
|
590
|
+
_context3.next = 9;
|
591
|
+
return getBytes(w.body, getLines(getMessages(function (E) {
|
592
|
+
E ? p[LastEventId] = E : delete p[LastEventId];
|
593
|
+
}, function (E) {
|
594
|
+
g = E;
|
486
595
|
}, o)));
|
487
596
|
case 9:
|
488
597
|
a == null || a();
|
489
598
|
y();
|
490
599
|
h();
|
491
|
-
|
600
|
+
_context3.next = 17;
|
492
601
|
break;
|
493
602
|
case 14:
|
494
|
-
|
495
|
-
|
603
|
+
_context3.prev = 14;
|
604
|
+
_context3.t0 = _context3["catch"](1);
|
496
605
|
if (!b.signal.aborted) try {
|
497
|
-
|
498
|
-
window.clearTimeout(v), v = window.setTimeout(x,
|
499
|
-
} catch (
|
500
|
-
y(), f(
|
606
|
+
E = (R = l == null ? void 0 : l(_context3.t0)) !== null && R !== void 0 ? R : g;
|
607
|
+
window.clearTimeout(v), v = window.setTimeout(x, E);
|
608
|
+
} catch (E) {
|
609
|
+
y(), f(E);
|
501
610
|
}
|
502
611
|
case 17:
|
503
612
|
case "end":
|
504
|
-
return
|
613
|
+
return _context3.stop();
|
505
614
|
}
|
506
|
-
},
|
615
|
+
}, _callee3, null, [[1, 14]]);
|
507
616
|
}));
|
508
|
-
return
|
617
|
+
return _x8.apply(this, arguments);
|
509
618
|
}
|
510
619
|
x();
|
511
620
|
});
|
@@ -514,103 +623,11 @@ function defaultOnOpen(r) {
|
|
514
623
|
var e = r.headers.get("content-type");
|
515
624
|
if (!(e != null && e.startsWith(EventStreamContentType))) throw new Error("Expected content-type to be ".concat(EventStreamContentType, ", Actual: ").concat(e));
|
516
625
|
}
|
517
|
-
var _RequestUtils = /*#__PURE__*/function () {
|
518
|
-
function D() {
|
519
|
-
_classCallCheck(this, D);
|
520
|
-
}
|
521
|
-
_createClass(D, null, [{
|
522
|
-
key: "temporarilyRemoveHeader",
|
523
|
-
value: // need to pass stringifyBody boolean separately as binding is throwing an error for some reason
|
524
|
-
// prettier-ignore
|
525
|
-
function () {
|
526
|
-
var _temporarilyRemoveHeader = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(e, t, n) {
|
527
|
-
var s;
|
528
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
529
|
-
while (1) switch (_context2.prev = _context2.next) {
|
530
|
-
case 0:
|
531
|
-
if (e != null && e.headers) {
|
532
|
-
_context2.next = 2;
|
533
|
-
break;
|
534
|
-
}
|
535
|
-
throw new Error("Request settings have not been set up");
|
536
|
-
case 2:
|
537
|
-
s = e.headers[D.CONTENT_TYPE];
|
538
|
-
delete e.headers[D.CONTENT_TYPE];
|
539
|
-
_context2.next = 6;
|
540
|
-
return t(n);
|
541
|
-
case 6:
|
542
|
-
e.headers[D.CONTENT_TYPE] = s;
|
543
|
-
case 7:
|
544
|
-
case "end":
|
545
|
-
return _context2.stop();
|
546
|
-
}
|
547
|
-
}, _callee2);
|
548
|
-
}));
|
549
|
-
function temporarilyRemoveHeader(_x4, _x5, _x6) {
|
550
|
-
return _temporarilyRemoveHeader.apply(this, arguments);
|
551
|
-
}
|
552
|
-
return temporarilyRemoveHeader;
|
553
|
-
}()
|
554
|
-
}, {
|
555
|
-
key: "displayError",
|
556
|
-
value: function displayError(e, t) {
|
557
|
-
var n = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Service error, please try again.";
|
558
|
-
if (console.error(t), _typeof(t) == "object") return Object.keys(t).length === 0 ? e.addNewErrorMessage("service", n) : e.addNewErrorMessage("service", JSON.stringify(t));
|
559
|
-
e.addNewErrorMessage("service", t);
|
560
|
-
}
|
561
|
-
}, {
|
562
|
-
key: "processResponseByType",
|
563
|
-
value: function processResponseByType(e) {
|
564
|
-
var t = e.headers.get("content-type");
|
565
|
-
return t != null && t.includes("application/json") ? e.json() : t != null && t.includes("text/plain") || !t ? e : e.blob();
|
566
|
-
}
|
567
|
-
}, {
|
568
|
-
key: "processRequestInterceptor",
|
569
|
-
value: function () {
|
570
|
-
var _processRequestInterceptor = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(e, t) {
|
571
|
-
var a, n, s, o;
|
572
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
573
|
-
while (1) switch (_context3.prev = _context3.next) {
|
574
|
-
case 0:
|
575
|
-
_context3.next = 2;
|
576
|
-
return (a = e.requestInterceptor) == null ? void 0 : a.call(e, t);
|
577
|
-
case 2:
|
578
|
-
_context3.t0 = _context3.sent;
|
579
|
-
if (_context3.t0) {
|
580
|
-
_context3.next = 5;
|
581
|
-
break;
|
582
|
-
}
|
583
|
-
_context3.t0 = t;
|
584
|
-
case 5:
|
585
|
-
n = _context3.t0;
|
586
|
-
s = n;
|
587
|
-
o = n;
|
588
|
-
return _context3.abrupt("return", {
|
589
|
-
body: s.body,
|
590
|
-
headers: s.headers,
|
591
|
-
error: o.error
|
592
|
-
});
|
593
|
-
case 9:
|
594
|
-
case "end":
|
595
|
-
return _context3.stop();
|
596
|
-
}
|
597
|
-
}, _callee3);
|
598
|
-
}));
|
599
|
-
function processRequestInterceptor(_x7, _x8) {
|
600
|
-
return _processRequestInterceptor.apply(this, arguments);
|
601
|
-
}
|
602
|
-
return processRequestInterceptor;
|
603
|
-
}()
|
604
|
-
}]);
|
605
|
-
return D;
|
606
|
-
}();
|
607
|
-
_RequestUtils.CONTENT_TYPE = "Content-Type";
|
608
|
-
var RequestUtils = _RequestUtils;
|
609
626
|
var _Demo = /*#__PURE__*/function () {
|
610
|
-
function
|
611
|
-
_classCallCheck(this,
|
627
|
+
function M() {
|
628
|
+
_classCallCheck(this, M);
|
612
629
|
}
|
613
|
-
_createClass(
|
630
|
+
_createClass(M, null, [{
|
614
631
|
key: "generateResponseForOneMessage",
|
615
632
|
value: function generateResponseForOneMessage(e) {
|
616
633
|
if (e.file) return e.file.type === "image" ? "That is a nice image!" : e.file.type === "audio" ? "I like the sound of that!" : e.file.type === "gif" ? "That is a nice gif!" : "That is an interesting file!";
|
@@ -625,11 +642,11 @@ var _Demo = /*#__PURE__*/function () {
|
|
625
642
|
value: function generateResponse(e) {
|
626
643
|
var t = [];
|
627
644
|
for (var s = e.messages.length - 1; s >= 0 && e.messages[s].role !== "ai"; s -= 1) t.push(e.messages[s]);
|
628
|
-
if (t.length === 1) return
|
645
|
+
if (t.length === 1) return M.generateResponseForOneMessage(e.messages[e.messages.length - 1]);
|
629
646
|
var n = e.messages.findIndex(function (s) {
|
630
647
|
return s.text;
|
631
648
|
});
|
632
|
-
return n !== -1 && t.splice(n, 1), t.length === 1 ?
|
649
|
+
return n !== -1 && t.splice(n, 1), t.length === 1 ? M.generateResponseForOneMessage(e.messages[e.messages.length - 1]) : "Wow, very cool files!";
|
633
650
|
}
|
634
651
|
}, {
|
635
652
|
key: "getCustomResponse",
|
@@ -639,15 +656,15 @@ var _Demo = /*#__PURE__*/function () {
|
|
639
656
|
}, {
|
640
657
|
key: "getResponse",
|
641
658
|
value: function getResponse(e) {
|
642
|
-
return e.customDemoResponse ?
|
643
|
-
text:
|
659
|
+
return e.customDemoResponse ? M.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
|
660
|
+
text: M.generateResponse(e)
|
644
661
|
};
|
645
662
|
}
|
646
663
|
// timeout is used to simulate a timeout for a response to come back
|
647
664
|
}, {
|
648
665
|
key: "request",
|
649
666
|
value: function request(e, t, n) {
|
650
|
-
var s =
|
667
|
+
var s = M.getResponse(e);
|
651
668
|
setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
652
669
|
var o;
|
653
670
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
@@ -678,12 +695,12 @@ var _Demo = /*#__PURE__*/function () {
|
|
678
695
|
value: function requestStream(e, t) {
|
679
696
|
setTimeout(function () {
|
680
697
|
var s;
|
681
|
-
var n = (s =
|
698
|
+
var n = (s = M.getResponse(e)) == null ? void 0 : s.text;
|
682
699
|
Stream.simulate(e, t, n);
|
683
700
|
}, 400);
|
684
701
|
}
|
685
702
|
}]);
|
686
|
-
return
|
703
|
+
return M;
|
687
704
|
}();
|
688
705
|
_Demo.URL = "deep-chat-demo";
|
689
706
|
var Demo = _Demo;
|
@@ -782,8 +799,8 @@ var Stream = /*#__PURE__*/function () {
|
|
782
799
|
onmessage: function onmessage(y) {
|
783
800
|
var S;
|
784
801
|
if (JSON.stringify(y.data) !== JSON.stringify("[DONE]")) {
|
785
|
-
var
|
786
|
-
(S = e.extractResultData) == null || S.call(e,
|
802
|
+
var _ = JSON.parse(y.data);
|
803
|
+
(S = e.extractResultData) == null || S.call(e, _).then(function (x) {
|
787
804
|
(x == null ? void 0 : x.text) === void 0 ? console.error("Response data: ".concat(y.data, " \n ").concat(ErrorMessages.INVALID_STREAM_RESPONSE)) : f && n.updateStreamedMessage(x.text, f);
|
788
805
|
})["catch"](function (x) {
|
789
806
|
return RequestUtils.displayError(n, x);
|
@@ -801,8 +818,8 @@ var Stream = /*#__PURE__*/function () {
|
|
801
818
|
var S;
|
802
819
|
(S = e.extractResultData) == null || S.call(e, y).then(function () {
|
803
820
|
RequestUtils.displayError(n, y);
|
804
|
-
})["catch"](function (
|
805
|
-
RequestUtils.displayError(n,
|
821
|
+
})["catch"](function (_) {
|
822
|
+
RequestUtils.displayError(n, _);
|
806
823
|
});
|
807
824
|
});
|
808
825
|
case 20:
|
@@ -890,7 +907,7 @@ var CustomHandler = /*#__PURE__*/function () {
|
|
890
907
|
_context7.t0 = u;
|
891
908
|
case 8:
|
892
909
|
d = _context7.t0;
|
893
|
-
|
910
|
+
RequestUtils.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), n.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) : e.deepChat.stream && d.text ? Stream.simulate(n, e.streamHandlers, d.text) : (n.addNewMessage(d, !0, !0), e.completionsHandlers.onFinish()) : (console.error(ErrorMessages.INVALID_RESPONSE(u, "server", !!e.deepChat.responseInterceptor, d)), n.addNewErrorMessage("service", "Error in server message"), e.completionsHandlers.onFinish());
|
894
911
|
case 10:
|
895
912
|
case "end":
|
896
913
|
return _context7.stop();
|
@@ -983,7 +1000,7 @@ var CustomHandler = /*#__PURE__*/function () {
|
|
983
1000
|
_context9.t0 = d;
|
984
1001
|
case 7:
|
985
1002
|
h = _context9.t0;
|
986
|
-
|
1003
|
+
RequestUtils.validateResponseFormat(h) ? typeof h.error == "string" ? (console.error(h.error), t.isLastMessageError() || t.addNewErrorMessage("service", h.error)) : e.deepChat.stream ? Stream.simulate(t, e.streamHandlers, h.text) : t.addNewMessage(h, !0, !0) : (console.error(ErrorMessages.INVALID_RESPONSE(d, "server", !!e.deepChat.responseInterceptor, h)), t.addNewErrorMessage("service", "Error in server message"));
|
987
1004
|
case 9:
|
988
1005
|
case "end":
|
989
1006
|
return _context9.stop();
|
@@ -1087,7 +1104,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
1087
1104
|
return RequestUtils.processResponseByType(g);
|
1088
1105
|
}).then( /*#__PURE__*/function () {
|
1089
1106
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(g) {
|
1090
|
-
var S,
|
1107
|
+
var S, _, v, y;
|
1091
1108
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
1092
1109
|
while (1) switch (_context10.prev = _context10.next) {
|
1093
1110
|
case 0:
|
@@ -1098,7 +1115,7 @@ var HTTPRequest = /*#__PURE__*/function () {
|
|
1098
1115
|
return _context10.abrupt("return");
|
1099
1116
|
case 2:
|
1100
1117
|
_context10.next = 4;
|
1101
|
-
return (
|
1118
|
+
return (_ = (S = e.deepChat).responseInterceptor) == null ? void 0 : _.call(S, g);
|
1102
1119
|
case 4:
|
1103
1120
|
_context10.t0 = _context10.sent;
|
1104
1121
|
if (_context10.t0) {
|
@@ -2376,11 +2393,11 @@ function list(r, e, t, n) {
|
|
2376
2393
|
v,
|
2377
2394
|
y,
|
2378
2395
|
S,
|
2379
|
-
|
2396
|
+
_,
|
2380
2397
|
x,
|
2381
2398
|
R = !0,
|
2382
2399
|
w,
|
2383
|
-
|
2400
|
+
E,
|
2384
2401
|
H,
|
2385
2402
|
F;
|
2386
2403
|
if ((h = skipOrderedListMarker(r, e)) >= 0) g = !0;else if ((h = skipBulletListMarker(r, e)) >= 0) g = !1;else return !1;
|
@@ -2389,11 +2406,11 @@ function list(r, e, t, n) {
|
|
2389
2406
|
for (y = r.tokens.length, g ? (d = r.bMarks[e] + r.tShift[e], b = Number(r.src.substr(d, h - d - 1)), r.tokens.push({
|
2390
2407
|
type: "ordered_list_open",
|
2391
2408
|
order: b,
|
2392
|
-
lines:
|
2409
|
+
lines: _ = [e, 0],
|
2393
2410
|
level: r.level++
|
2394
2411
|
})) : r.tokens.push({
|
2395
2412
|
type: "bullet_list_open",
|
2396
|
-
lines:
|
2413
|
+
lines: _ = [e, 0],
|
2397
2414
|
level: r.level++
|
2398
2415
|
}), s = e, S = !1, w = r.parser.ruler.getRules("list"); s < t && (v = r.skipSpaces(h), f = r.eMarks[s], v >= f ? p = 1 : p = v - h, p > 4 && (p = 1), p < 1 && (p = 1), o = h - r.bMarks[s] + p, r.tokens.push({
|
2399
2416
|
type: "list_item_open",
|
@@ -2403,7 +2420,7 @@ function list(r, e, t, n) {
|
|
2403
2420
|
type: "list_item_close",
|
2404
2421
|
level: --r.level
|
2405
2422
|
}), s = e = r.line, x[1] = s, v = r.bMarks[e], !(s >= t || r.isEmpty(s) || r.tShift[s] < r.blkIndent));) {
|
2406
|
-
for (F = !1,
|
2423
|
+
for (F = !1, E = 0, H = w.length; E < H; E++) if (w[E](r, s, t, !0)) {
|
2407
2424
|
F = !0;
|
2408
2425
|
break;
|
2409
2426
|
}
|
@@ -2416,7 +2433,7 @@ function list(r, e, t, n) {
|
|
2416
2433
|
return r.tokens.push({
|
2417
2434
|
type: g ? "ordered_list_close" : "bullet_list_close",
|
2418
2435
|
level: --r.level
|
2419
|
-
}),
|
2436
|
+
}), _[1] = s, r.line = s, R && markTightParagraphs(r, y), !0;
|
2420
2437
|
}
|
2421
2438
|
function footnote(r, e, t, n) {
|
2422
2439
|
var s,
|
@@ -6116,11 +6133,11 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
|
|
6116
6133
|
return AzureTranslationIO;
|
6117
6134
|
}(DirectServiceIO);
|
6118
6135
|
var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
6119
|
-
_inherits(
|
6120
|
-
var _super30 = _createSuper(
|
6121
|
-
function
|
6136
|
+
_inherits(A, _DirectServiceIO9);
|
6137
|
+
var _super30 = _createSuper(A);
|
6138
|
+
function A(e) {
|
6122
6139
|
var _this23;
|
6123
|
-
_classCallCheck(this,
|
6140
|
+
_classCallCheck(this, A);
|
6124
6141
|
var l;
|
6125
6142
|
var t = e.directConnection,
|
6126
6143
|
n = e.textInput,
|
@@ -6144,10 +6161,10 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6144
6161
|
}
|
6145
6162
|
};
|
6146
6163
|
}
|
6147
|
-
_typeof(a) == "object" && Object.assign(_this23.rawBody, a), _this23.canSendMessage =
|
6164
|
+
_typeof(a) == "object" && Object.assign(_this23.rawBody, a), _this23.canSendMessage = A.canFileSendMessage;
|
6148
6165
|
return _this23;
|
6149
6166
|
}
|
6150
|
-
_createClass(
|
6167
|
+
_createClass(A, [{
|
6151
6168
|
key: "preprocessBody",
|
6152
6169
|
value: function preprocessBody(e, t) {
|
6153
6170
|
var n = JSON.parse(JSON.stringify(e));
|
@@ -6165,10 +6182,10 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6165
6182
|
var s;
|
6166
6183
|
var o = (l = (a = t[t.length - 1]) == null ? void 0 : a.text) == null ? void 0 : l.trim();
|
6167
6184
|
if (n[1] || o && o !== "") {
|
6168
|
-
this.url =
|
6185
|
+
this.url = A.IMAGE_EDIT_URL;
|
6169
6186
|
var c = this.preprocessBody(this.rawBody, o);
|
6170
|
-
s =
|
6171
|
-
} else this.url =
|
6187
|
+
s = A.createFormDataBody(c, n[0], n[1]);
|
6188
|
+
} else this.url = A.IMAGE_VARIATIONS_URL, s = A.createFormDataBody(this.rawBody, n[0]);
|
6172
6189
|
RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, s, e), !1);
|
6173
6190
|
}
|
6174
6191
|
}, {
|
@@ -6199,7 +6216,7 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6199
6216
|
}
|
6200
6217
|
throw new Error("Request settings have not been set up");
|
6201
6218
|
case 8:
|
6202
|
-
this.url =
|
6219
|
+
this.url = A.IMAGE_GENERATION_URL;
|
6203
6220
|
o = this.preprocessBody(this.rawBody, t[t.length - 1].text);
|
6204
6221
|
HTTPRequest.request(this, o, e);
|
6205
6222
|
case 11:
|
@@ -6270,7 +6287,7 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
|
|
6270
6287
|
}), s;
|
6271
6288
|
}
|
6272
6289
|
}]);
|
6273
|
-
return
|
6290
|
+
return A;
|
6274
6291
|
}(DirectServiceIO);
|
6275
6292
|
_OpenAIImagesIO.IMAGE_GENERATION_URL = "https://api.openai.com/v1/images/generations";
|
6276
6293
|
_OpenAIImagesIO.IMAGE_VARIATIONS_URL = "https://api.openai.com/v1/images/variations";
|
@@ -6785,6 +6802,170 @@ var LoadingMessageDotsStyle = /*#__PURE__*/function () {
|
|
6785
6802
|
}]);
|
6786
6803
|
return LoadingMessageDotsStyle;
|
6787
6804
|
}();
|
6805
|
+
var StatefulEvents = /*#__PURE__*/function () {
|
6806
|
+
function StatefulEvents() {
|
6807
|
+
_classCallCheck(this, StatefulEvents);
|
6808
|
+
}
|
6809
|
+
_createClass(StatefulEvents, null, [{
|
6810
|
+
key: "mouseUp",
|
6811
|
+
value: function mouseUp(e, t) {
|
6812
|
+
var n = t.target;
|
6813
|
+
StyleUtils.unsetAllCSSMouseStates(n, e), Object.assign(n.style, e["default"]), Object.assign(n.style, e.hover);
|
6814
|
+
}
|
6815
|
+
}, {
|
6816
|
+
key: "mouseDown",
|
6817
|
+
value: function mouseDown(e, t) {
|
6818
|
+
var n = t.target;
|
6819
|
+
Object.assign(n.style, e.click);
|
6820
|
+
}
|
6821
|
+
}, {
|
6822
|
+
key: "mouseLeave",
|
6823
|
+
value: function mouseLeave(e, t) {
|
6824
|
+
var n = t.target;
|
6825
|
+
StyleUtils.unsetAllCSSMouseStates(n, e), Object.assign(n.style, e["default"]);
|
6826
|
+
}
|
6827
|
+
}, {
|
6828
|
+
key: "mouseEnter",
|
6829
|
+
value: function mouseEnter(e, t) {
|
6830
|
+
var n = t.target;
|
6831
|
+
Object.assign(n.style, e.hover);
|
6832
|
+
}
|
6833
|
+
// note that children elements can not be selectable
|
6834
|
+
}, {
|
6835
|
+
key: "add",
|
6836
|
+
value: function add(e, t) {
|
6837
|
+
e.addEventListener("mouseenter", StatefulEvents.mouseEnter.bind(this, t)), e.addEventListener("mouseleave", StatefulEvents.mouseLeave.bind(this, t)), e.addEventListener("mousedown", StatefulEvents.mouseDown.bind(this, t)), e.addEventListener("mouseup", StatefulEvents.mouseUp.bind(this, t));
|
6838
|
+
}
|
6839
|
+
}]);
|
6840
|
+
return StatefulEvents;
|
6841
|
+
}();
|
6842
|
+
var HTMLMessageUtils = /*#__PURE__*/function () {
|
6843
|
+
function HTMLMessageUtils() {
|
6844
|
+
_classCallCheck(this, HTMLMessageUtils);
|
6845
|
+
}
|
6846
|
+
_createClass(HTMLMessageUtils, null, [{
|
6847
|
+
key: "applyStylesToElement",
|
6848
|
+
value: function applyStylesToElement(e, t) {
|
6849
|
+
var n = StyleUtils.processStateful(t, {}, {});
|
6850
|
+
StatefulEvents.add(e, n), Object.assign(e.style, n["default"]);
|
6851
|
+
}
|
6852
|
+
}, {
|
6853
|
+
key: "applyEventsToElement",
|
6854
|
+
value: function applyEventsToElement(e, t) {
|
6855
|
+
Object.keys(t).forEach(function (n) {
|
6856
|
+
var s = t[n];
|
6857
|
+
s && e.addEventListener(n, s);
|
6858
|
+
});
|
6859
|
+
}
|
6860
|
+
}, {
|
6861
|
+
key: "applyClassUtilitiesToElement",
|
6862
|
+
value: function applyClassUtilitiesToElement(e, t) {
|
6863
|
+
var n = t.events,
|
6864
|
+
s = t.styles;
|
6865
|
+
n && HTMLMessageUtils.applyEventsToElement(e, n), s && !HTMLDeepChatElements.doesElementContainDeepChatClass(e) && HTMLMessageUtils.applyStylesToElement(e, s);
|
6866
|
+
}
|
6867
|
+
}, {
|
6868
|
+
key: "applyCustomClassUtilities",
|
6869
|
+
value: function applyCustomClassUtilities(e, t) {
|
6870
|
+
Object.keys(e).forEach(function (n) {
|
6871
|
+
var s = t.getElementsByClassName(n);
|
6872
|
+
Array.from(s).forEach(function (o) {
|
6873
|
+
e[n] && HTMLMessageUtils.applyClassUtilitiesToElement(o, e[n]);
|
6874
|
+
});
|
6875
|
+
});
|
6876
|
+
}
|
6877
|
+
}, {
|
6878
|
+
key: "apply",
|
6879
|
+
value: function apply(e, t) {
|
6880
|
+
HTMLDeepChatElements.applyDeepChatUtilities(e, e._htmlClassUtilities, t), HTMLMessageUtils.applyCustomClassUtilities(e._htmlClassUtilities, t);
|
6881
|
+
}
|
6882
|
+
}]);
|
6883
|
+
return HTMLMessageUtils;
|
6884
|
+
}();
|
6885
|
+
var DEEP_CHAT_TEMPORARY_ELEMENT = "deep-chat-temporary-element",
|
6886
|
+
DEEP_CHAT_ELEMENTS = {
|
6887
|
+
"deep-chat-suggestion-button": {
|
6888
|
+
styles: {
|
6889
|
+
"default": {
|
6890
|
+
backgroundColor: "white",
|
6891
|
+
padding: "5px",
|
6892
|
+
paddingLeft: "7px",
|
6893
|
+
paddingRight: "7px",
|
6894
|
+
border: "1px solid #c2c2c2",
|
6895
|
+
borderRadius: "6px",
|
6896
|
+
cursor: "pointer"
|
6897
|
+
},
|
6898
|
+
hover: {
|
6899
|
+
backgroundColor: "#fafafa"
|
6900
|
+
},
|
6901
|
+
click: {
|
6902
|
+
backgroundColor: "#f1f1f1"
|
6903
|
+
}
|
6904
|
+
}
|
6905
|
+
}
|
6906
|
+
},
|
6907
|
+
DEEP_CHAT_ELEMENT_CLASSES = Object.keys(DEEP_CHAT_ELEMENTS);
|
6908
|
+
var HTMLDeepChatElements = /*#__PURE__*/function () {
|
6909
|
+
function HTMLDeepChatElements() {
|
6910
|
+
_classCallCheck(this, HTMLDeepChatElements);
|
6911
|
+
}
|
6912
|
+
_createClass(HTMLDeepChatElements, null, [{
|
6913
|
+
key: "isElementTemporary",
|
6914
|
+
value: function isElementTemporary(e) {
|
6915
|
+
return e ? e.bubbleElement.children[0].classList.contains(DEEP_CHAT_TEMPORARY_ELEMENT) : !1;
|
6916
|
+
}
|
6917
|
+
}, {
|
6918
|
+
key: "doesElementContainDeepChatClass",
|
6919
|
+
value: function doesElementContainDeepChatClass(e) {
|
6920
|
+
return DEEP_CHAT_ELEMENT_CLASSES.find(function (t) {
|
6921
|
+
return e.classList.contains(t);
|
6922
|
+
});
|
6923
|
+
}
|
6924
|
+
}, {
|
6925
|
+
key: "applyCustomSuggestionEvent",
|
6926
|
+
value: function applyCustomSuggestionEvent(e, t) {
|
6927
|
+
setTimeout(function () {
|
6928
|
+
t.addEventListener("click", function () {
|
6929
|
+
var n, s;
|
6930
|
+
(s = e.submitUserMessage) == null || s.call(e, ((n = t.textContent) == null ? void 0 : n.trim()) || "");
|
6931
|
+
});
|
6932
|
+
});
|
6933
|
+
}
|
6934
|
+
}, {
|
6935
|
+
key: "applyEvents",
|
6936
|
+
value: function applyEvents(e, t, n) {
|
6937
|
+
var s = DEEP_CHAT_ELEMENTS[n].events;
|
6938
|
+
Object.keys(s || []).forEach(function (o) {
|
6939
|
+
t.addEventListener(o, s == null ? void 0 : s[o]);
|
6940
|
+
}), n === "deep-chat-suggestion-button" && HTMLDeepChatElements.applyCustomSuggestionEvent(e, t);
|
6941
|
+
}
|
6942
|
+
}, {
|
6943
|
+
key: "getProcessedStyles",
|
6944
|
+
value: function getProcessedStyles(e, t, n) {
|
6945
|
+
var s = Array.from(t.classList).reduce(function (l, c) {
|
6946
|
+
var d;
|
6947
|
+
var u = (d = e[c]) == null ? void 0 : d.styles;
|
6948
|
+
return u && e[c].styles && l.push(u), l;
|
6949
|
+
}, []),
|
6950
|
+
o = DEEP_CHAT_ELEMENTS[n].styles;
|
6951
|
+
o && s.unshift(o);
|
6952
|
+
var a = StyleUtils.mergeStatefulStyles(s);
|
6953
|
+
return StyleUtils.processStateful(a, {}, {});
|
6954
|
+
}
|
6955
|
+
}, {
|
6956
|
+
key: "applyDeepChatUtilities",
|
6957
|
+
value: function applyDeepChatUtilities(e, t, n) {
|
6958
|
+
DEEP_CHAT_ELEMENT_CLASSES.forEach(function (s) {
|
6959
|
+
var o = n.getElementsByClassName(s);
|
6960
|
+
Array.from(o || []).forEach(function (a) {
|
6961
|
+
var l = HTMLDeepChatElements.getProcessedStyles(t, a, s);
|
6962
|
+
HTMLMessageUtils.applyStylesToElement(a, l), HTMLDeepChatElements.applyEvents(e, a, s);
|
6963
|
+
});
|
6964
|
+
});
|
6965
|
+
}
|
6966
|
+
}]);
|
6967
|
+
return HTMLDeepChatElements;
|
6968
|
+
}();
|
6788
6969
|
var MessageStyleUtils = /*#__PURE__*/function () {
|
6789
6970
|
function MessageStyleUtils() {
|
6790
6971
|
_classCallCheck(this, MessageStyleUtils);
|
@@ -6924,75 +7105,39 @@ var _FileMessageUtils = /*#__PURE__*/function () {
|
|
6924
7105
|
}();
|
6925
7106
|
_FileMessageUtils.DEFAULT_FILE_NAME = "file";
|
6926
7107
|
var FileMessageUtils = _FileMessageUtils;
|
6927
|
-
var
|
6928
|
-
function
|
6929
|
-
_classCallCheck(this,
|
7108
|
+
var HTMLMessages = /*#__PURE__*/function () {
|
7109
|
+
function HTMLMessages() {
|
7110
|
+
_classCallCheck(this, HTMLMessages);
|
6930
7111
|
}
|
6931
|
-
_createClass(
|
6932
|
-
key: "
|
6933
|
-
value: function
|
6934
|
-
|
6935
|
-
StyleUtils.unsetAllCSSMouseStates(n, e), Object.assign(n.style, e["default"]), Object.assign(n.style, e.hover);
|
6936
|
-
}
|
6937
|
-
}, {
|
6938
|
-
key: "mouseDown",
|
6939
|
-
value: function mouseDown(e, t) {
|
6940
|
-
var n = t.target;
|
6941
|
-
Object.assign(n.style, e.click);
|
7112
|
+
_createClass(HTMLMessages, null, [{
|
7113
|
+
key: "addElement",
|
7114
|
+
value: function addElement(e, t) {
|
7115
|
+
e.elementRef.appendChild(t), e.elementRef.scrollTop = e.elementRef.scrollHeight;
|
6942
7116
|
}
|
6943
7117
|
}, {
|
6944
|
-
key: "
|
6945
|
-
value: function
|
6946
|
-
var
|
6947
|
-
|
7118
|
+
key: "update",
|
7119
|
+
value: function update(e, t, n, s) {
|
7120
|
+
var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : !1;
|
7121
|
+
var a = Messages.createMessageContent(n, {
|
7122
|
+
html: t
|
7123
|
+
});
|
7124
|
+
o || e.messages.push(a), s && e.sendClientUpdate(a, o);
|
6948
7125
|
}
|
6949
7126
|
}, {
|
6950
|
-
key: "
|
6951
|
-
value: function
|
6952
|
-
var
|
6953
|
-
|
7127
|
+
key: "createElements",
|
7128
|
+
value: function createElements(e, t, n) {
|
7129
|
+
var s = e.createNewMessageElement("", n);
|
7130
|
+
return s.bubbleElement.style.maxWidth = "unset", s.bubbleElement.innerHTML = t, s;
|
6954
7131
|
}
|
6955
|
-
// note that children elements can not be selectable
|
6956
7132
|
}, {
|
6957
|
-
key: "add",
|
6958
|
-
value: function add(e, t) {
|
6959
|
-
e.addEventListener("mouseenter", StatefulEvents.mouseEnter.bind(this, t)), e.addEventListener("mouseleave", StatefulEvents.mouseLeave.bind(this, t)), e.addEventListener("mousedown", StatefulEvents.mouseDown.bind(this, t)), e.addEventListener("mouseup", StatefulEvents.mouseUp.bind(this, t));
|
6960
|
-
}
|
6961
|
-
}]);
|
6962
|
-
return StatefulEvents;
|
6963
|
-
}();
|
6964
|
-
var HTMLMessageUtils = /*#__PURE__*/function () {
|
6965
|
-
function HTMLMessageUtils() {
|
6966
|
-
_classCallCheck(this, HTMLMessageUtils);
|
6967
|
-
}
|
6968
|
-
_createClass(HTMLMessageUtils, null, [{
|
6969
7133
|
key: "addNewHTMLMessage",
|
6970
7134
|
value: function addNewHTMLMessage(e, t, n, s) {
|
6971
7135
|
var o = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : !1;
|
6972
|
-
var a =
|
6973
|
-
|
6974
|
-
var l = Messages.createMessageContent(n, {
|
6975
|
-
html: t
|
6976
|
-
});
|
6977
|
-
return o || e.messages.push(l), s && e.sendClientUpdate(l, o), Object.keys(e._htmlClassUtilities).forEach(function (c) {
|
6978
|
-
var u = a.outerContainer.getElementsByClassName(c);
|
6979
|
-
Array.from(u).forEach(function (d) {
|
6980
|
-
var p, b;
|
6981
|
-
var h = (p = e._htmlClassUtilities[c]) == null ? void 0 : p.events;
|
6982
|
-
h && Object.keys(h).forEach(function (m) {
|
6983
|
-
var g = h[m];
|
6984
|
-
g && d.addEventListener(m, g);
|
6985
|
-
});
|
6986
|
-
var f = (b = e._htmlClassUtilities[c]) == null ? void 0 : b.styles;
|
6987
|
-
if (f) {
|
6988
|
-
var m = StyleUtils.processStateful(f, {}, {});
|
6989
|
-
StatefulEvents.add(d, m), Object.assign(d.style, m["default"]);
|
6990
|
-
}
|
6991
|
-
});
|
6992
|
-
}), a;
|
7136
|
+
var a = HTMLMessages.createElements(e, t, n);
|
7137
|
+
return t.trim().length === 0 && Messages.editEmptyMessageElement(a.bubbleElement), HTMLMessageUtils.apply(e, a.outerContainer), HTMLDeepChatElements.isElementTemporary(a) || HTMLMessages.update(e, t, n, s, o), HTMLMessages.addElement(e, a.outerContainer), a;
|
6993
7138
|
}
|
6994
7139
|
}]);
|
6995
|
-
return
|
7140
|
+
return HTMLMessages;
|
6996
7141
|
}();
|
6997
7142
|
var SetupMessages = /*#__PURE__*/function () {
|
6998
7143
|
function SetupMessages() {
|
@@ -7185,6 +7330,8 @@ var Messages = /*#__PURE__*/function () {
|
|
7185
7330
|
return JSON.parse(JSON.stringify(_this28.messages));
|
7186
7331
|
}, e.clearMessages = this.clearMessages.bind(this), e.refreshMessages = this.refreshTextMessages.bind(this), a && this.prepareDemo(a), e.textToSpeech && TextToSpeech.processConfig(e.textToSpeech, function (u) {
|
7187
7332
|
_this28._textToSpeech = u;
|
7333
|
+
}), setTimeout(function () {
|
7334
|
+
_this28.submitUserMessage = e.submitUserMessage;
|
7188
7335
|
});
|
7189
7336
|
}
|
7190
7337
|
_createClass(Messages, [{
|
@@ -7209,7 +7356,7 @@ var Messages = /*#__PURE__*/function () {
|
|
7209
7356
|
var l = this.createAndAppendNewMessageElement(this._introMessage.text, !0);
|
7210
7357
|
this.applyCustomStyles(l, !0, !1, (n = this.messageStyles) == null ? void 0 : n.intro);
|
7211
7358
|
} else if ((s = this._introMessage) != null && s.html) {
|
7212
|
-
var _l =
|
7359
|
+
var _l = HTMLMessages.addNewHTMLMessage(this, this._introMessage.html, !0, !1, !0);
|
7213
7360
|
this.applyCustomStyles(_l, !0, !1, (o = this.messageStyles) == null ? void 0 : o.html), this.applyCustomStyles(_l, !0, !1, (a = this.messageStyles) == null ? void 0 : a.intro);
|
7214
7361
|
}
|
7215
7362
|
}
|
@@ -7251,7 +7398,7 @@ var Messages = /*#__PURE__*/function () {
|
|
7251
7398
|
var s;
|
7252
7399
|
(s = this._introPanel) == null || s.hide();
|
7253
7400
|
var n = this._messageElementRefs[this._messageElementRefs.length - 1];
|
7254
|
-
return
|
7401
|
+
return Messages.isTemporaryElement(n) && (n.outerContainer.remove(), this._messageElementRefs.pop()), this.createMessageElements(e, t);
|
7255
7402
|
}
|
7256
7403
|
}, {
|
7257
7404
|
key: "createAndAppendNewMessageElement",
|
@@ -7280,8 +7427,8 @@ var Messages = /*#__PURE__*/function () {
|
|
7280
7427
|
if (e.text !== void 0 && e.text !== null) this.addNewTextMessage(e.text, t, n, s), !s && this._textToSpeech && t && TextToSpeech.speak(e.text, this._textToSpeech);else if (e.files) e.files.forEach(function (a) {
|
7281
7428
|
var l, c;
|
7282
7429
|
a.type === "audio" || (l = a.src) != null && l.startsWith("data:audio") ? FileMessages.addNewAudioMessage(_this30, a, t, s) : a.type === "image" || a.type === "gif" || (c = a.src) != null && c.startsWith("data:image") ? FileMessages.addNewImageMessage(_this30, a, t, s) : FileMessages.addNewAnyFileMessage(_this30, a, t, s);
|
7283
|
-
});else if (e.html) {
|
7284
|
-
var a =
|
7430
|
+
});else if (e.html !== void 0 && e.html !== null) {
|
7431
|
+
var a = HTMLMessages.addNewHTMLMessage(this, e.html, t, n, s);
|
7285
7432
|
this.applyCustomStyles(a, t, !1, (o = this.messageStyles) == null ? void 0 : o.html);
|
7286
7433
|
}
|
7287
7434
|
}
|
@@ -7298,7 +7445,7 @@ var Messages = /*#__PURE__*/function () {
|
|
7298
7445
|
value: function removeMessageOnError() {
|
7299
7446
|
var e = this._messageElementRefs[this._messageElementRefs.length - 1],
|
7300
7447
|
t = e == null ? void 0 : e.bubbleElement;
|
7301
|
-
(t != null && t.classList.contains("streamed-message") && t.textContent === "" ||
|
7448
|
+
(t != null && t.classList.contains("streamed-message") && t.textContent === "" || Messages.isTemporaryElement(e)) && (e.outerContainer.remove(), this._messageElementRefs.pop());
|
7302
7449
|
}
|
7303
7450
|
// prettier-ignore
|
7304
7451
|
}, {
|
@@ -7329,7 +7476,6 @@ var Messages = /*#__PURE__*/function () {
|
|
7329
7476
|
}
|
7330
7477
|
}
|
7331
7478
|
}
|
7332
|
-
// WORK - check if this works correctly
|
7333
7479
|
}, {
|
7334
7480
|
key: "getLastMessageElement",
|
7335
7481
|
value: function getLastMessageElement() {
|
@@ -7338,9 +7484,9 @@ var Messages = /*#__PURE__*/function () {
|
|
7338
7484
|
}, {
|
7339
7485
|
key: "getLastMessageBubbleElement",
|
7340
7486
|
value: function getLastMessageBubbleElement() {
|
7341
|
-
var e, t;
|
7342
|
-
return Array.from(((t = (e = this.getLastMessageElement()) == null ? void 0 : e.children) == null ? void 0 : t[0].children) || []).find(function (
|
7343
|
-
return
|
7487
|
+
var e, t, n;
|
7488
|
+
return Array.from(((n = (t = (e = this.getLastMessageElement()) == null ? void 0 : e.children) == null ? void 0 : t[0]) == null ? void 0 : n.children) || []).find(function (s) {
|
7489
|
+
return s.classList.contains("message-bubble");
|
7344
7490
|
});
|
7345
7491
|
}
|
7346
7492
|
}, {
|
@@ -7438,7 +7584,7 @@ var Messages = /*#__PURE__*/function () {
|
|
7438
7584
|
return _addMultipleFiles.apply(this, arguments);
|
7439
7585
|
}
|
7440
7586
|
return addMultipleFiles;
|
7441
|
-
}()
|
7587
|
+
}() // WORK - update all message classes to use deep-chat prefix
|
7442
7588
|
}, {
|
7443
7589
|
key: "clearMessages",
|
7444
7590
|
value: function clearMessages(e) {
|
@@ -7505,6 +7651,11 @@ var Messages = /*#__PURE__*/function () {
|
|
7505
7651
|
bubbleElement: n
|
7506
7652
|
};
|
7507
7653
|
}
|
7654
|
+
}, {
|
7655
|
+
key: "isTemporaryElement",
|
7656
|
+
value: function isTemporaryElement(e) {
|
7657
|
+
return (e == null ? void 0 : e.bubbleElement.classList.contains("loading-message-text")) || HTMLDeepChatElements.isElementTemporary(e);
|
7658
|
+
}
|
7508
7659
|
}, {
|
7509
7660
|
key: "editEmptyMessageElement",
|
7510
7661
|
value: function editEmptyMessageElement(e) {
|