deep-chat-dev 1.1.38 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/custom-elements.json +1726 -1596
  2. package/dist/deepChat.bundle.js +1 -1
  3. package/dist/deepChat.d.ts +2 -0
  4. package/dist/deepChat.d.ts.map +1 -1
  5. package/dist/deepChat.js +1014 -893
  6. package/dist/services/assemblyAI/assemblyAIAudioIO.d.ts +2 -2
  7. package/dist/services/assemblyAI/assemblyAIAudioIO.d.ts.map +1 -1
  8. package/dist/services/azure/azureSpeechToTextIO.d.ts +2 -2
  9. package/dist/services/azure/azureSpeechToTextIO.d.ts.map +1 -1
  10. package/dist/services/azure/azureTextToSpeechIO.d.ts +2 -2
  11. package/dist/services/azure/azureTextToSpeechIO.d.ts.map +1 -1
  12. package/dist/services/azure/azureTranslationIO.d.ts +2 -2
  13. package/dist/services/azure/azureTranslationIO.d.ts.map +1 -1
  14. package/dist/services/cohere/cohereChatIO.d.ts +2 -2
  15. package/dist/services/cohere/cohereChatIO.d.ts.map +1 -1
  16. package/dist/services/cohere/cohereSummarizationIO.d.ts +2 -2
  17. package/dist/services/cohere/cohereSummarizationIO.d.ts.map +1 -1
  18. package/dist/services/cohere/cohereTextGenerationIO.d.ts +2 -2
  19. package/dist/services/cohere/cohereTextGenerationIO.d.ts.map +1 -1
  20. package/dist/services/huggingFace/huggingFaceConversationIO.d.ts +2 -2
  21. package/dist/services/huggingFace/huggingFaceConversationIO.d.ts.map +1 -1
  22. package/dist/services/huggingFace/huggingFaceFillMaskIO.d.ts +2 -2
  23. package/dist/services/huggingFace/huggingFaceFillMaskIO.d.ts.map +1 -1
  24. package/dist/services/huggingFace/huggingFaceQuestionAnswerIO.d.ts +2 -2
  25. package/dist/services/huggingFace/huggingFaceQuestionAnswerIO.d.ts.map +1 -1
  26. package/dist/services/huggingFace/huggingFaceSummarizationIO.d.ts +2 -2
  27. package/dist/services/huggingFace/huggingFaceSummarizationIO.d.ts.map +1 -1
  28. package/dist/services/huggingFace/huggingFaceTextGenerationIO.d.ts +2 -2
  29. package/dist/services/huggingFace/huggingFaceTextGenerationIO.d.ts.map +1 -1
  30. package/dist/services/huggingFace/huggingFaceTranslationIO.d.ts +2 -2
  31. package/dist/services/huggingFace/huggingFaceTranslationIO.d.ts.map +1 -1
  32. package/dist/services/openAI/openAIAudioIO.d.ts +2 -2
  33. package/dist/services/openAI/openAIAudioIO.d.ts.map +1 -1
  34. package/dist/services/openAI/openAIChatIO.d.ts +2 -2
  35. package/dist/services/openAI/openAIChatIO.d.ts.map +1 -1
  36. package/dist/services/openAI/openAICompletionsIO.d.ts +2 -2
  37. package/dist/services/openAI/openAICompletionsIO.d.ts.map +1 -1
  38. package/dist/services/openAI/openAIImagesIO.d.ts +2 -2
  39. package/dist/services/openAI/openAIImagesIO.d.ts.map +1 -1
  40. package/dist/services/serviceIO.d.ts +4 -4
  41. package/dist/services/serviceIO.d.ts.map +1 -1
  42. package/dist/services/stabilityAI/stabilityAIImageToImageIO.d.ts +2 -2
  43. package/dist/services/stabilityAI/stabilityAIImageToImageIO.d.ts.map +1 -1
  44. package/dist/services/stabilityAI/stabilityAIImageToImageMaskingIO.d.ts +2 -2
  45. package/dist/services/stabilityAI/stabilityAIImageToImageMaskingIO.d.ts.map +1 -1
  46. package/dist/services/stabilityAI/stabilityAIImageToImageUpscaleIO.d.ts +2 -2
  47. package/dist/services/stabilityAI/stabilityAIImageToImageUpscaleIO.d.ts.map +1 -1
  48. package/dist/services/stabilityAI/stabilityAITextToImageIO.d.ts +2 -2
  49. package/dist/services/stabilityAI/stabilityAITextToImageIO.d.ts.map +1 -1
  50. package/dist/services/utils/baseServiceIO.d.ts +2 -3
  51. package/dist/services/utils/baseServiceIO.d.ts.map +1 -1
  52. package/dist/types/demo.d.ts +2 -2
  53. package/dist/types/demo.d.ts.map +1 -1
  54. package/dist/types/interceptors.d.ts +2 -1
  55. package/dist/types/interceptors.d.ts.map +1 -1
  56. package/dist/types/request.d.ts +2 -0
  57. package/dist/types/request.d.ts.map +1 -1
  58. package/dist/types/{result.d.ts → response.d.ts} +3 -2
  59. package/dist/types/response.d.ts.map +1 -0
  60. package/dist/utils/HTTP/HTTPRequest.d.ts.map +1 -1
  61. package/dist/utils/HTTP/customRequest.d.ts +7 -0
  62. package/dist/utils/HTTP/customRequest.d.ts.map +1 -0
  63. package/dist/utils/HTTP/websocket.d.ts +4 -3
  64. package/dist/utils/HTTP/websocket.d.ts.map +1 -1
  65. package/dist/utils/demo/demo.d.ts.map +1 -1
  66. package/dist/utils/events/fireEvents.d.ts +1 -0
  67. package/dist/utils/events/fireEvents.d.ts.map +1 -1
  68. package/dist/views/chat/input/buttons/submit/submitButton.d.ts.map +1 -1
  69. package/dist/views/chat/introPanel/introPanel.d.ts +1 -0
  70. package/dist/views/chat/introPanel/introPanel.d.ts.map +1 -1
  71. package/dist/views/chat/messages/fileMessages.d.ts.map +1 -1
  72. package/dist/views/chat/messages/messages.d.ts +6 -2
  73. package/dist/views/chat/messages/messages.d.ts.map +1 -1
  74. package/package.json +1 -1
  75. package/dist/types/customService.d.ts +0 -6
  76. package/dist/types/customService.d.ts.map +0 -1
  77. package/dist/types/result.d.ts.map +0 -1
package/dist/deepChat.js CHANGED
@@ -316,13 +316,13 @@ function getInterceptorMessage(r) {
316
316
  function getInvalidResponseMessage(r, e, t, n) {
317
317
  var s = "\n".concat(capitalizeFirstLetter(e), " message: ").concat(JSON.stringify(r), " \n"),
318
318
  o = t ? "".concat(capitalizeFirstLetter(e), " message after interceptor: ").concat(getInterceptorMessage(n), " \n") : "";
319
- return "".concat(s + o, "Make sure the ").concat(e, " message is using the Result format: https://deepchat.dev/docs/connect/#Result \n You can also augment it using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor");
319
+ 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
320
  }
321
321
  var ErrorMessages = {
322
322
  INVALID_KEY: "Invalid API Key",
323
323
  CONNECTION_FAILED: "Failed to connect",
324
324
  INVALID_RESPONSE: getInvalidResponseMessage,
325
- INVALID_STREAM_RESPONSE: "Make sure the events are using the Result format: https://deepchat.dev/docs/connect/#Result \nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor"
325
+ 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"
326
326
  },
327
327
  _RequestUtils = /*#__PURE__*/function () {
328
328
  function D() {
@@ -420,29 +420,29 @@ function getBytes(_x6, _x7) {
420
420
  return _getBytes.apply(this, arguments);
421
421
  }
422
422
  function _getBytes() {
423
- _getBytes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(r, e) {
423
+ _getBytes = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(r, e) {
424
424
  var t, n;
425
- return _regeneratorRuntime().wrap(function _callee71$(_context71) {
426
- while (1) switch (_context71.prev = _context71.next) {
425
+ return _regeneratorRuntime().wrap(function _callee73$(_context73) {
426
+ while (1) switch (_context73.prev = _context73.next) {
427
427
  case 0:
428
428
  t = r.getReader();
429
429
  case 1:
430
- _context71.next = 3;
430
+ _context73.next = 3;
431
431
  return t.read();
432
432
  case 3:
433
- if ((n = _context71.sent).done) {
434
- _context71.next = 7;
433
+ if ((n = _context73.sent).done) {
434
+ _context73.next = 7;
435
435
  break;
436
436
  }
437
437
  e(n.value);
438
438
  case 5:
439
- _context71.next = 1;
439
+ _context73.next = 1;
440
440
  break;
441
441
  case 7:
442
442
  case "end":
443
- return _context71.stop();
443
+ return _context73.stop();
444
444
  }
445
- }, _callee71);
445
+ }, _callee73);
446
446
  }));
447
447
  return _getBytes.apply(this, arguments);
448
448
  }
@@ -539,42 +539,42 @@ function fetchEventSource(r, e) {
539
539
  b.abort(), document.hidden || I();
540
540
  }
541
541
  c || document.addEventListener("visibilitychange", m);
542
- var v = DefaultRetryInterval,
543
- g = 0;
542
+ var g = DefaultRetryInterval,
543
+ v = 0;
544
544
  function y() {
545
- document.removeEventListener("visibilitychange", m), window.clearTimeout(g), b.abort();
545
+ document.removeEventListener("visibilitychange", m), window.clearTimeout(v), b.abort();
546
546
  }
547
547
  t == null || t.addEventListener("abort", function () {
548
548
  y(), h();
549
549
  });
550
- var x = u !== null && u !== void 0 ? u : window.fetch,
551
- _ = s !== null && s !== void 0 ? s : defaultOnOpen;
550
+ var _ = u !== null && u !== void 0 ? u : window.fetch,
551
+ S = s !== null && s !== void 0 ? s : defaultOnOpen;
552
552
  function I() {
553
553
  return _I.apply(this, arguments);
554
554
  }
555
555
  function _I() {
556
556
  _I = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
557
- var R, w, S;
557
+ var R, w, x;
558
558
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
559
559
  while (1) switch (_context3.prev = _context3.next) {
560
560
  case 0:
561
561
  b = new AbortController();
562
562
  _context3.prev = 1;
563
563
  _context3.next = 4;
564
- return x(r, Object.assign(Object.assign({}, d), {
564
+ return _(r, Object.assign(Object.assign({}, d), {
565
565
  headers: f,
566
566
  signal: b.signal
567
567
  }));
568
568
  case 4:
569
569
  w = _context3.sent;
570
570
  _context3.next = 7;
571
- return _(w);
571
+ return S(w);
572
572
  case 7:
573
573
  _context3.next = 9;
574
- return getBytes(w.body, getLines(getMessages(function (S) {
575
- S ? f[LastEventId] = S : delete f[LastEventId];
576
- }, function (S) {
577
- v = S;
574
+ return getBytes(w.body, getLines(getMessages(function (x) {
575
+ x ? f[LastEventId] = x : delete f[LastEventId];
576
+ }, function (x) {
577
+ g = x;
578
578
  }, o)));
579
579
  case 9:
580
580
  a == null || a();
@@ -586,10 +586,10 @@ function fetchEventSource(r, e) {
586
586
  _context3.prev = 14;
587
587
  _context3.t0 = _context3["catch"](1);
588
588
  if (!b.signal.aborted) try {
589
- S = (R = l == null ? void 0 : l(_context3.t0)) !== null && R !== void 0 ? R : v;
590
- window.clearTimeout(g), g = window.setTimeout(I, S);
591
- } catch (S) {
592
- y(), p(S);
589
+ x = (R = l == null ? void 0 : l(_context3.t0)) !== null && R !== void 0 ? R : g;
590
+ window.clearTimeout(v), v = window.setTimeout(I, x);
591
+ } catch (x) {
592
+ y(), p(x);
593
593
  }
594
594
  case 17:
595
595
  case "end":
@@ -606,6 +606,87 @@ function defaultOnOpen(r) {
606
606
  var e = r.headers.get("content-type");
607
607
  if (!(e != null && e.startsWith(EventStreamContentType))) throw new Error("Expected content-type to be ".concat(EventStreamContentType, ", Actual: ").concat(e));
608
608
  }
609
+ var _Demo = /*#__PURE__*/function () {
610
+ function C() {
611
+ _classCallCheck(this, C);
612
+ }
613
+ _createClass(C, null, [{
614
+ key: "generateResponseForOneMessage",
615
+ value: function generateResponseForOneMessage(e) {
616
+ 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!";
617
+ if (e.text) {
618
+ if (e.text.charAt(e.text.length - 1) === "?") return "I'm sorry but I can't answer that question...";
619
+ if (e.text.includes("updog")) return "What's updog?";
620
+ }
621
+ return "Hi there! This is a demo response!";
622
+ }
623
+ }, {
624
+ key: "generateResponse",
625
+ value: function generateResponse(e) {
626
+ var t = [];
627
+ 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 C.generateResponseForOneMessage(e.messages[e.messages.length - 1]);
629
+ var n = e.messages.findIndex(function (s) {
630
+ return s.text;
631
+ });
632
+ return n !== -1 && t.splice(n, 1), t.length === 1 ? C.generateResponseForOneMessage(e.messages[e.messages.length - 1]) : "Wow, very cool files!";
633
+ }
634
+ }, {
635
+ key: "getCustomResponse",
636
+ value: function getCustomResponse(e, t) {
637
+ return typeof e == "function" ? e(t) : e;
638
+ }
639
+ }, {
640
+ key: "getResponse",
641
+ value: function getResponse(e) {
642
+ return e.customDemoResponse ? C.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
643
+ text: C.generateResponse(e)
644
+ };
645
+ }
646
+ // timeout is used to simulate a timeout for a response to come back
647
+ }, {
648
+ key: "request",
649
+ value: function request(e, t, n) {
650
+ var s = C.getResponse(e);
651
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
652
+ var o;
653
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
654
+ while (1) switch (_context4.prev = _context4.next) {
655
+ case 0:
656
+ _context4.next = 2;
657
+ return n == null ? void 0 : n(s);
658
+ case 2:
659
+ _context4.t0 = _context4.sent;
660
+ if (_context4.t0) {
661
+ _context4.next = 5;
662
+ break;
663
+ }
664
+ _context4.t0 = s;
665
+ case 5:
666
+ o = _context4.t0;
667
+ o.error ? e.addNewErrorMessage("service", o.error) : e.addNewMessage(o, !0, !0), t();
668
+ case 7:
669
+ case "end":
670
+ return _context4.stop();
671
+ }
672
+ }, _callee4);
673
+ })), 400);
674
+ }
675
+ // timeout is used to simulate a timeout for a response to come back
676
+ }, {
677
+ key: "requestStream",
678
+ value: function requestStream(e, t) {
679
+ setTimeout(function () {
680
+ var s;
681
+ var n = (s = C.getResponse(e)) == null ? void 0 : s.text;
682
+ Stream.simulate(e, t, n);
683
+ }, 400);
684
+ }
685
+ }]);
686
+ return C;
687
+ }();
688
+ _Demo.URL = "deep-chat-demo";
689
+ var Demo = _Demo;
609
690
  var Stream = /*#__PURE__*/function () {
610
691
  function Stream() {
611
692
  _classCallCheck(this, Stream);
@@ -614,12 +695,12 @@ var Stream = /*#__PURE__*/function () {
614
695
  key: "request",
615
696
  value: // prettier-ignore
616
697
  function () {
617
- var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(e, t, n) {
698
+ var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(e, t, n) {
618
699
  var s,
619
700
  f,
620
701
  b,
621
702
  m,
622
- v,
703
+ g,
623
704
  o,
624
705
  _yield$RequestUtils$p,
625
706
  a,
@@ -630,19 +711,19 @@ var Stream = /*#__PURE__*/function () {
630
711
  d,
631
712
  h,
632
713
  p,
633
- _args5 = arguments;
634
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
635
- while (1) switch (_context5.prev = _context5.next) {
714
+ _args6 = arguments;
715
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
716
+ while (1) switch (_context6.prev = _context6.next) {
636
717
  case 0:
637
- s = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : !0;
718
+ s = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : !0;
638
719
  o = {
639
720
  body: t,
640
721
  headers: (f = e.requestSettings) == null ? void 0 : f.headers
641
722
  };
642
- _context5.next = 4;
723
+ _context6.next = 4;
643
724
  return RequestUtils.processResponseInterceptor(e.deepChat, o);
644
725
  case 4:
645
- _yield$RequestUtils$p = _context5.sent;
726
+ _yield$RequestUtils$p = _context6.sent;
646
727
  a = _yield$RequestUtils$p.body;
647
728
  l = _yield$RequestUtils$p.headers;
648
729
  c = _yield$RequestUtils$p.error;
@@ -651,77 +732,77 @@ var Stream = /*#__PURE__*/function () {
651
732
  d = _e$streamHandlers.onClose;
652
733
  h = _e$streamHandlers.abortStream;
653
734
  if (!c) {
654
- _context5.next = 14;
735
+ _context6.next = 14;
655
736
  break;
656
737
  }
657
- return _context5.abrupt("return", Stream.onInterceptorError(n, c, d));
738
+ return _context6.abrupt("return", Stream.onInterceptorError(n, c, d));
658
739
  case 14:
659
740
  if (!(((b = e.requestSettings) == null ? void 0 : b.url) === Demo.URL)) {
660
- _context5.next = 16;
741
+ _context6.next = 16;
661
742
  break;
662
743
  }
663
- return _context5.abrupt("return", Demo.requestStream(n, e.streamHandlers));
744
+ return _context6.abrupt("return", Demo.requestStream(n, e.streamHandlers));
664
745
  case 16:
665
746
  p = null;
666
747
  fetchEventSource(((m = e.requestSettings) == null ? void 0 : m.url) || e.url || "", {
667
- method: ((v = e.requestSettings) == null ? void 0 : v.method) || "POST",
748
+ method: ((g = e.requestSettings) == null ? void 0 : g.method) || "POST",
668
749
  headers: l,
669
750
  body: s ? JSON.stringify(a) : a,
670
751
  openWhenHidden: !0,
671
752
  // keep stream open when browser tab not open
672
- onopen: function onopen(g) {
673
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
674
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
675
- while (1) switch (_context4.prev = _context4.next) {
753
+ onopen: function onopen(v) {
754
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
755
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
756
+ while (1) switch (_context5.prev = _context5.next) {
676
757
  case 0:
677
- if (!g.ok) {
678
- _context4.next = 2;
758
+ if (!v.ok) {
759
+ _context5.next = 2;
679
760
  break;
680
761
  }
681
- return _context4.abrupt("return", (p = n.addNewStreamedMessage(), u()));
762
+ return _context5.abrupt("return", (p = n.addNewStreamedMessage(), u()));
682
763
  case 2:
683
- _context4.next = 4;
684
- return RequestUtils.processResponseByType(g);
764
+ _context5.next = 4;
765
+ return RequestUtils.processResponseByType(v);
685
766
  case 4:
686
- throw _context4.sent;
767
+ throw _context5.sent;
687
768
  case 5:
688
769
  case "end":
689
- return _context4.stop();
770
+ return _context5.stop();
690
771
  }
691
- }, _callee4);
772
+ }, _callee5);
692
773
  }))();
693
774
  },
694
- onmessage: function onmessage(g) {
775
+ onmessage: function onmessage(v) {
695
776
  var y;
696
- if (JSON.stringify(g.data) !== JSON.stringify("[DONE]")) {
697
- var x = JSON.parse(g.data);
698
- (y = e.extractResultData) == null || y.call(e, x).then(function (_) {
699
- (_ == null ? void 0 : _.text) === void 0 ? console.error("Response data: ".concat(g.data, " \n ").concat(ErrorMessages.INVALID_STREAM_RESPONSE)) : p && n.updateStreamedMessage(_.text, p);
700
- })["catch"](function (_) {
701
- return RequestUtils.displayError(n, _);
777
+ if (JSON.stringify(v.data) !== JSON.stringify("[DONE]")) {
778
+ var _ = JSON.parse(v.data);
779
+ (y = e.extractResultData) == null || y.call(e, _).then(function (S) {
780
+ (S == null ? void 0 : S.text) === void 0 ? console.error("Response data: ".concat(v.data, " \n ").concat(ErrorMessages.INVALID_STREAM_RESPONSE)) : p && n.updateStreamedMessage(S.text, p);
781
+ })["catch"](function (S) {
782
+ return RequestUtils.displayError(n, S);
702
783
  });
703
784
  }
704
785
  },
705
- onerror: function onerror(g) {
706
- throw d(), g;
786
+ onerror: function onerror(v) {
787
+ throw d(), v;
707
788
  },
708
789
  onclose: function onclose() {
709
790
  n.finaliseStreamedMessage(), d();
710
791
  },
711
792
  signal: h.signal
712
- })["catch"](function (g) {
793
+ })["catch"](function (v) {
713
794
  var y;
714
- (y = e.extractResultData) == null || y.call(e, g).then(function () {
715
- RequestUtils.displayError(n, g);
716
- })["catch"](function (x) {
717
- RequestUtils.displayError(n, x);
795
+ (y = e.extractResultData) == null || y.call(e, v).then(function () {
796
+ RequestUtils.displayError(n, v);
797
+ })["catch"](function (_) {
798
+ RequestUtils.displayError(n, _);
718
799
  });
719
800
  });
720
801
  case 18:
721
802
  case "end":
722
- return _context5.stop();
803
+ return _context6.stop();
723
804
  }
724
- }, _callee5);
805
+ }, _callee6);
725
806
  }));
726
807
  function request(_x8, _x9, _x10) {
727
808
  return _request.apply(this, arguments);
@@ -765,89 +846,78 @@ var Stream = /*#__PURE__*/function () {
765
846
  }]);
766
847
  return Stream;
767
848
  }();
768
- var _Demo = /*#__PURE__*/function () {
769
- function A() {
770
- _classCallCheck(this, A);
849
+ var CustomRequest = /*#__PURE__*/function () {
850
+ function CustomRequest() {
851
+ _classCallCheck(this, CustomRequest);
771
852
  }
772
- _createClass(A, null, [{
773
- key: "generateResponseForOneMessage",
774
- value: function generateResponseForOneMessage(e) {
775
- 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!";
776
- if (e.text) {
777
- if (e.text.charAt(e.text.length - 1) === "?") return "I'm sorry but I can't answer that question...";
778
- if (e.text.includes("updog")) return "What's updog?";
779
- }
780
- return "Hi there! This is a demo response!";
781
- }
782
- }, {
783
- key: "generateResponse",
784
- value: function generateResponse(e) {
785
- var t = [];
786
- for (var s = e.messages.length - 1; s >= 0 && e.messages[s].role !== "ai"; s -= 1) t.push(e.messages[s]);
787
- if (t.length === 1) return A.generateResponseForOneMessage(e.messages[e.messages.length - 1]);
788
- var n = e.messages.findIndex(function (s) {
789
- return s.text;
790
- });
791
- return n !== -1 && t.splice(n, 1), t.length === 1 ? A.generateResponseForOneMessage(e.messages[e.messages.length - 1]) : "Wow, very cool files!";
792
- }
793
- }, {
794
- key: "getCustomResponse",
795
- value: function getCustomResponse(e, t) {
796
- return typeof e == "function" ? e(t) : e;
797
- }
798
- }, {
799
- key: "getResponse",
800
- value: function getResponse(e) {
801
- return e.customDemoResponse ? A.getCustomResponse(e.customDemoResponse, e.messages[e.messages.length - 1]) : {
802
- result: {
803
- text: A.generateResponse(e)
804
- }
805
- };
806
- }
807
- // timeout is used to simulate a timeout for a response to come back
808
- }, {
853
+ _createClass(CustomRequest, null, [{
809
854
  key: "request",
810
- value: function request(e, t, n) {
811
- var s = A.getResponse(e);
812
- setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
813
- var o;
814
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
815
- while (1) switch (_context6.prev = _context6.next) {
855
+ value: function () {
856
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(e, t, n) {
857
+ var s, o;
858
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
859
+ while (1) switch (_context8.prev = _context8.next) {
816
860
  case 0:
817
- _context6.next = 2;
818
- return n == null ? void 0 : n(s);
819
- case 2:
820
- _context6.t0 = _context6.sent;
821
- if (_context6.t0) {
822
- _context6.next = 5;
823
- break;
824
- }
825
- _context6.t0 = s;
826
- case 5:
827
- o = _context6.t0;
828
- o.error ? e.addNewErrorMessage("service", o.error) : e.addNewMessage(o.result, !0, !0), t();
829
- case 7:
861
+ (o = (s = e.requestSettings).handler) == null || o.call(s, t).then( /*#__PURE__*/function () {
862
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(a) {
863
+ var u, d, l, c;
864
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
865
+ while (1) switch (_context7.prev = _context7.next) {
866
+ case 0:
867
+ if (e.extractResultData) {
868
+ _context7.next = 2;
869
+ break;
870
+ }
871
+ return _context7.abrupt("return");
872
+ case 2:
873
+ _context7.next = 4;
874
+ return (d = (u = e.deepChat).responseInterceptor) == null ? void 0 : d.call(u, a);
875
+ case 4:
876
+ _context7.t0 = _context7.sent;
877
+ if (_context7.t0) {
878
+ _context7.next = 7;
879
+ break;
880
+ }
881
+ _context7.t0 = a;
882
+ case 7:
883
+ l = _context7.t0;
884
+ _context7.next = 10;
885
+ return e.extractResultData(l);
886
+ case 10:
887
+ c = _context7.sent;
888
+ if (!(!c || _typeof(c) != "object")) {
889
+ _context7.next = 13;
890
+ break;
891
+ }
892
+ throw Error(ErrorMessages.INVALID_RESPONSE(a, "response", !!e.deepChat.responseInterceptor, c));
893
+ case 13:
894
+ e.deepChat.stream && c.text ? Stream.simulate(n, e.streamHandlers, c.text) : (n.addNewMessage(c, !0, !0), e.completionsHandlers.onFinish());
895
+ case 14:
896
+ case "end":
897
+ return _context7.stop();
898
+ }
899
+ }, _callee7);
900
+ }));
901
+ return function (_x14) {
902
+ return _ref2.apply(this, arguments);
903
+ };
904
+ }())["catch"](function (a) {
905
+ RequestUtils.displayError(n, a), e.completionsHandlers.onFinish();
906
+ });
907
+ case 1:
830
908
  case "end":
831
- return _context6.stop();
909
+ return _context8.stop();
832
910
  }
833
- }, _callee6);
834
- })), 400);
835
- }
836
- // timeout is used to simulate a timeout for a response to come back
837
- }, {
838
- key: "requestStream",
839
- value: function requestStream(e, t) {
840
- setTimeout(function () {
841
- var s, o;
842
- var n = (o = (s = A.getResponse(e)) == null ? void 0 : s.result) == null ? void 0 : o.text;
843
- Stream.simulate(e, t, n);
844
- }, 400);
845
- }
911
+ }, _callee8);
912
+ }));
913
+ function request(_x11, _x12, _x13) {
914
+ return _request2.apply(this, arguments);
915
+ }
916
+ return request;
917
+ }()
846
918
  }]);
847
- return A;
919
+ return CustomRequest;
848
920
  }();
849
- _Demo.URL = "deep-chat-demo";
850
- var Demo = _Demo;
851
921
  var HTTPRequest = /*#__PURE__*/function () {
852
922
  function HTTPRequest() {
853
923
  _classCallCheck(this, HTTPRequest);
@@ -856,12 +926,13 @@ var HTTPRequest = /*#__PURE__*/function () {
856
926
  key: "request",
857
927
  value: // prettier-ignore
858
928
  function () {
859
- var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(e, t, n) {
929
+ var _request3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(e, t, n) {
860
930
  var s,
861
931
  h,
862
932
  p,
863
933
  f,
864
934
  b,
935
+ m,
865
936
  o,
866
937
  _yield$RequestUtils$p2,
867
938
  a,
@@ -869,104 +940,110 @@ var HTTPRequest = /*#__PURE__*/function () {
869
940
  c,
870
941
  u,
871
942
  d,
872
- _args8 = arguments;
873
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
874
- while (1) switch (_context8.prev = _context8.next) {
943
+ _args10 = arguments;
944
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
945
+ while (1) switch (_context10.prev = _context10.next) {
875
946
  case 0:
876
- s = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : !0;
947
+ s = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : !0;
877
948
  o = {
878
949
  body: t,
879
950
  headers: (h = e.requestSettings) == null ? void 0 : h.headers
880
951
  };
881
- _context8.next = 4;
952
+ _context10.next = 4;
882
953
  return RequestUtils.processResponseInterceptor(e.deepChat, o);
883
954
  case 4:
884
- _yield$RequestUtils$p2 = _context8.sent;
955
+ _yield$RequestUtils$p2 = _context10.sent;
885
956
  a = _yield$RequestUtils$p2.body;
886
957
  l = _yield$RequestUtils$p2.headers;
887
958
  c = _yield$RequestUtils$p2.error;
888
959
  u = e.completionsHandlers.onFinish;
889
960
  if (!c) {
890
- _context8.next = 11;
961
+ _context10.next = 11;
891
962
  break;
892
963
  }
893
- return _context8.abrupt("return", HTTPRequest.onInterceptorError(n, c, u));
964
+ return _context10.abrupt("return", HTTPRequest.onInterceptorError(n, c, u));
894
965
  case 11:
895
- if (!(((p = e.requestSettings) == null ? void 0 : p.url) === Demo.URL)) {
896
- _context8.next = 13;
966
+ if (!((p = e.requestSettings) != null && p.handler)) {
967
+ _context10.next = 13;
897
968
  break;
898
969
  }
899
- return _context8.abrupt("return", Demo.request(n, u, e.deepChat.responseInterceptor));
970
+ return _context10.abrupt("return", CustomRequest.request(e, a, n));
900
971
  case 13:
972
+ if (!(((f = e.requestSettings) == null ? void 0 : f.url) === Demo.URL)) {
973
+ _context10.next = 15;
974
+ break;
975
+ }
976
+ return _context10.abrupt("return", Demo.request(n, u, e.deepChat.responseInterceptor));
977
+ case 15:
901
978
  d = !0;
902
- fetch(((f = e.requestSettings) == null ? void 0 : f.url) || e.url || "", {
903
- method: ((b = e.requestSettings) == null ? void 0 : b.method) || "POST",
979
+ fetch(((b = e.requestSettings) == null ? void 0 : b.url) || e.url || "", {
980
+ method: ((m = e.requestSettings) == null ? void 0 : m.method) || "POST",
904
981
  headers: l,
905
982
  body: s ? JSON.stringify(a) : a
906
- }).then(function (m) {
907
- return d = !!m.ok, m;
908
- }).then(function (m) {
909
- return RequestUtils.processResponseByType(m);
983
+ }).then(function (g) {
984
+ return d = !!g.ok, g;
985
+ }).then(function (g) {
986
+ return RequestUtils.processResponseByType(g);
910
987
  }).then( /*#__PURE__*/function () {
911
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(m) {
912
- var y, x, v, g;
913
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
914
- while (1) switch (_context7.prev = _context7.next) {
988
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(g) {
989
+ var _, S, v, y;
990
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
991
+ while (1) switch (_context9.prev = _context9.next) {
915
992
  case 0:
916
993
  if (e.extractResultData) {
917
- _context7.next = 2;
994
+ _context9.next = 2;
918
995
  break;
919
996
  }
920
- return _context7.abrupt("return");
997
+ return _context9.abrupt("return");
921
998
  case 2:
922
- _context7.next = 4;
923
- return (x = (y = e.deepChat).responseInterceptor) == null ? void 0 : x.call(y, m);
999
+ _context9.next = 4;
1000
+ return (S = (_ = e.deepChat).responseInterceptor) == null ? void 0 : S.call(_, g);
924
1001
  case 4:
925
- _context7.t0 = _context7.sent;
926
- if (_context7.t0) {
927
- _context7.next = 7;
1002
+ _context9.t0 = _context9.sent;
1003
+ if (_context9.t0) {
1004
+ _context9.next = 7;
928
1005
  break;
929
1006
  }
930
- _context7.t0 = m;
1007
+ _context9.t0 = g;
931
1008
  case 7:
932
- v = _context7.t0;
933
- _context7.next = 10;
1009
+ v = _context9.t0;
1010
+ _context9.next = 10;
934
1011
  return e.extractResultData(v);
935
1012
  case 10:
936
- g = _context7.sent;
1013
+ y = _context9.sent;
937
1014
  if (d) {
938
- _context7.next = 13;
1015
+ _context9.next = 13;
939
1016
  break;
940
1017
  }
941
- throw m;
1018
+ throw g;
942
1019
  case 13:
943
- if (!(!g || _typeof(g) != "object")) {
944
- _context7.next = 15;
1020
+ if (!(!y || _typeof(y) != "object")) {
1021
+ _context9.next = 15;
945
1022
  break;
946
1023
  }
947
- throw Error(ErrorMessages.INVALID_RESPONSE(m, "response", !!e.deepChat.responseInterceptor, v));
1024
+ throw Error(ErrorMessages.INVALID_RESPONSE(g, "response", !!e.deepChat.responseInterceptor, v));
948
1025
  case 15:
949
- g.pollingInAnotherRequest || (e.deepChat.stream && g.text ? Stream.simulate(n, e.streamHandlers, g.text) : (n.addNewMessage(g, !0, !0), u()));
1026
+ y.pollingInAnotherRequest || (e.deepChat.stream && y.text ? Stream.simulate(n, e.streamHandlers, y.text) : (n.addNewMessage(y, !0, !0), u()));
950
1027
  case 16:
951
1028
  case "end":
952
- return _context7.stop();
1029
+ return _context9.stop();
953
1030
  }
954
- }, _callee7);
1031
+ }, _callee9);
955
1032
  }));
956
- return function (_x14) {
957
- return _ref2.apply(this, arguments);
1033
+ return function (_x18) {
1034
+ return _ref3.apply(this, arguments);
958
1035
  };
959
- }())["catch"](function (m) {
960
- RequestUtils.displayError(n, m), u();
1036
+ }())["catch"](function (g) {
1037
+ RequestUtils.displayError(n, g), u();
961
1038
  });
962
- case 15:
1039
+ case 17:
963
1040
  case "end":
964
- return _context8.stop();
1041
+ return _context10.stop();
965
1042
  }
966
- }, _callee8);
1043
+ }, _callee10);
967
1044
  }));
968
- function request(_x11, _x12, _x13) {
969
- return _request2.apply(this, arguments);
1045
+ function request(_x15, _x16, _x17) {
1046
+ return _request3.apply(this, arguments);
970
1047
  }
971
1048
  return request;
972
1049
  }() // prettier-ignore
@@ -978,44 +1055,44 @@ var HTTPRequest = /*#__PURE__*/function () {
978
1055
  fetch(t, n).then(function (a) {
979
1056
  return a.json();
980
1057
  }).then( /*#__PURE__*/function () {
981
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(a) {
1058
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(a) {
982
1059
  var c, u, l;
983
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
984
- while (1) switch (_context9.prev = _context9.next) {
1060
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1061
+ while (1) switch (_context11.prev = _context11.next) {
985
1062
  case 0:
986
1063
  if (e.extractPollResultData) {
987
- _context9.next = 2;
1064
+ _context11.next = 2;
988
1065
  break;
989
1066
  }
990
- return _context9.abrupt("return");
1067
+ return _context11.abrupt("return");
991
1068
  case 2:
992
- _context9.t0 = e;
993
- _context9.next = 5;
1069
+ _context11.t0 = e;
1070
+ _context11.next = 5;
994
1071
  return (u = (c = e.deepChat).responseInterceptor) == null ? void 0 : u.call(c, a);
995
1072
  case 5:
996
- _context9.t1 = _context9.sent;
997
- if (_context9.t1) {
998
- _context9.next = 8;
1073
+ _context11.t1 = _context11.sent;
1074
+ if (_context11.t1) {
1075
+ _context11.next = 8;
999
1076
  break;
1000
1077
  }
1001
- _context9.t1 = a;
1078
+ _context11.t1 = a;
1002
1079
  case 8:
1003
- _context9.t2 = _context9.t1;
1004
- _context9.next = 11;
1005
- return _context9.t0.extractPollResultData.call(_context9.t0, _context9.t2);
1080
+ _context11.t2 = _context11.t1;
1081
+ _context11.next = 11;
1082
+ return _context11.t0.extractPollResultData.call(_context11.t0, _context11.t2);
1006
1083
  case 11:
1007
- l = _context9.sent;
1084
+ l = _context11.sent;
1008
1085
  l.timeoutMS ? setTimeout(function () {
1009
1086
  HTTPRequest.executePollRequest(e, t, n, s);
1010
1087
  }, l.timeoutMS) : (console.log("finished polling"), s.addNewMessage(l, !0, !0), o());
1011
1088
  case 13:
1012
1089
  case "end":
1013
- return _context9.stop();
1090
+ return _context11.stop();
1014
1091
  }
1015
- }, _callee9);
1092
+ }, _callee11);
1016
1093
  }));
1017
- return function (_x15) {
1018
- return _ref3.apply(this, arguments);
1094
+ return function (_x19) {
1095
+ return _ref4.apply(this, arguments);
1019
1096
  };
1020
1097
  }())["catch"](function (a) {
1021
1098
  RequestUtils.displayError(s, a), o();
@@ -1025,7 +1102,7 @@ var HTTPRequest = /*#__PURE__*/function () {
1025
1102
  }, {
1026
1103
  key: "poll",
1027
1104
  value: function () {
1028
- var _poll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(e, t, n) {
1105
+ var _poll = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(e, t, n) {
1029
1106
  var s,
1030
1107
  f,
1031
1108
  b,
@@ -1039,27 +1116,27 @@ var HTTPRequest = /*#__PURE__*/function () {
1039
1116
  d,
1040
1117
  h,
1041
1118
  p,
1042
- _args10 = arguments;
1043
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1044
- while (1) switch (_context10.prev = _context10.next) {
1119
+ _args12 = arguments;
1120
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1121
+ while (1) switch (_context12.prev = _context12.next) {
1045
1122
  case 0:
1046
- s = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : !0;
1123
+ s = _args12.length > 3 && _args12[3] !== undefined ? _args12[3] : !0;
1047
1124
  o = {
1048
1125
  body: t,
1049
1126
  headers: (f = e.requestSettings) == null ? void 0 : f.headers
1050
1127
  };
1051
- _context10.next = 4;
1128
+ _context12.next = 4;
1052
1129
  return RequestUtils.processResponseInterceptor(e.deepChat, o);
1053
1130
  case 4:
1054
- _yield$RequestUtils$p3 = _context10.sent;
1131
+ _yield$RequestUtils$p3 = _context12.sent;
1055
1132
  a = _yield$RequestUtils$p3.body;
1056
1133
  l = _yield$RequestUtils$p3.headers;
1057
1134
  c = _yield$RequestUtils$p3.error;
1058
1135
  if (!c) {
1059
- _context10.next = 10;
1136
+ _context12.next = 10;
1060
1137
  break;
1061
1138
  }
1062
- return _context10.abrupt("return", HTTPRequest.onInterceptorError(n, c));
1139
+ return _context12.abrupt("return", HTTPRequest.onInterceptorError(n, c));
1063
1140
  case 10:
1064
1141
  u = ((b = e.requestSettings) == null ? void 0 : b.url) || e.url || "", d = ((m = e.requestSettings) == null ? void 0 : m.method) || "POST", h = s ? JSON.stringify(a) : a, p = {
1065
1142
  method: d,
@@ -1069,11 +1146,11 @@ var HTTPRequest = /*#__PURE__*/function () {
1069
1146
  HTTPRequest.executePollRequest(e, u, p, n);
1070
1147
  case 12:
1071
1148
  case "end":
1072
- return _context10.stop();
1149
+ return _context12.stop();
1073
1150
  }
1074
- }, _callee10);
1151
+ }, _callee12);
1075
1152
  }));
1076
- function poll(_x16, _x17, _x18) {
1153
+ function poll(_x20, _x21, _x22) {
1077
1154
  return _poll.apply(this, arguments);
1078
1155
  }
1079
1156
  return poll;
@@ -1158,79 +1235,94 @@ var Websocket = /*#__PURE__*/function () {
1158
1235
  }
1159
1236
  _createClass(Websocket, null, [{
1160
1237
  key: "setup",
1161
- value: function setup(e, t) {
1162
- if (e.requestSettings.url !== Demo.URL) {
1163
- var n = typeof t != "boolean" ? t : void 0;
1164
- e.websocket = Websocket.connect(e.requestSettings.url, n), e.permittedErrorPrefixes = ["Connection error", "Error in server message"];
1238
+ value: function setup(e) {
1239
+ e.requestSettings.url !== Demo.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
1240
+ }
1241
+ }, {
1242
+ key: "createConnection",
1243
+ value: function createConnection(e, t) {
1244
+ if (!document.body.contains(e.deepChat)) return;
1245
+ var n = e.requestSettings.websocket;
1246
+ if (n) try {
1247
+ var s = typeof n != "boolean" ? n : void 0;
1248
+ e.websocket = new WebSocket(e.requestSettings.url || "", s), e.websocket.onopen = function () {
1249
+ t.removeError(), e.websocket && _typeof(e.websocket) == "object" && Websocket.assignListeners(e, e.websocket, t);
1250
+ }, e.websocket.onerror = function (o) {
1251
+ console.error(o), Websocket.retryConnection(e, t);
1252
+ };
1253
+ } catch (s) {
1254
+ console.error(s), Websocket.retryConnection(e, t);
1165
1255
  }
1166
1256
  }
1167
1257
  }, {
1168
- key: "connect",
1169
- value: function connect(e, t) {
1170
- return new WebSocket(e || "", t);
1258
+ key: "retryConnection",
1259
+ value: function retryConnection(e, t) {
1260
+ document.body.contains(e.deepChat) && (e.websocket = "pending", t.isLastMessageError() || t.addNewErrorMessage("service", "Connection error"), setTimeout(function () {
1261
+ Websocket.createConnection(e, t);
1262
+ }, 5e3));
1171
1263
  }
1172
1264
  }, {
1173
1265
  key: "assignListeners",
1174
- value: function assignListeners(e, t) {
1175
- e.websocket && (e.websocket.onmessage = /*#__PURE__*/function () {
1176
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(n) {
1177
- var s, o, a, l, c;
1178
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1179
- while (1) switch (_context11.prev = _context11.next) {
1266
+ value: function assignListeners(e, t, n) {
1267
+ t.onmessage = /*#__PURE__*/function () {
1268
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(s) {
1269
+ var o, a, l, c, u;
1270
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1271
+ while (1) switch (_context13.prev = _context13.next) {
1180
1272
  case 0:
1181
1273
  if (!e.extractResultData) {
1182
- _context11.next = 20;
1274
+ _context13.next = 20;
1183
1275
  break;
1184
1276
  }
1185
- _context11.prev = 1;
1186
- a = JSON.parse(n.data);
1187
- _context11.next = 5;
1188
- return (o = (s = e.deepChat).responseInterceptor) == null ? void 0 : o.call(s, a);
1277
+ _context13.prev = 1;
1278
+ l = JSON.parse(s.data);
1279
+ _context13.next = 5;
1280
+ return (a = (o = e.deepChat).responseInterceptor) == null ? void 0 : a.call(o, l);
1189
1281
  case 5:
1190
- _context11.t0 = _context11.sent;
1191
- if (_context11.t0) {
1192
- _context11.next = 8;
1282
+ _context13.t0 = _context13.sent;
1283
+ if (_context13.t0) {
1284
+ _context13.next = 8;
1193
1285
  break;
1194
1286
  }
1195
- _context11.t0 = a;
1287
+ _context13.t0 = l;
1196
1288
  case 8:
1197
- l = _context11.t0;
1198
- _context11.next = 11;
1199
- return e.extractResultData(l);
1289
+ c = _context13.t0;
1290
+ _context13.next = 11;
1291
+ return e.extractResultData(c);
1200
1292
  case 11:
1201
- c = _context11.sent;
1202
- if (!(!c || _typeof(c) != "object")) {
1203
- _context11.next = 14;
1293
+ u = _context13.sent;
1294
+ if (!(!u || _typeof(u) != "object")) {
1295
+ _context13.next = 14;
1204
1296
  break;
1205
1297
  }
1206
- throw Error(ErrorMessages.INVALID_RESPONSE(a, "server", !!e.deepChat.responseInterceptor, l));
1298
+ throw Error(ErrorMessages.INVALID_RESPONSE(l, "server", !!e.deepChat.responseInterceptor, c));
1207
1299
  case 14:
1208
- e.deepChat.stream && c.text ? Stream.simulate(t, e.streamHandlers, c.text) : t.addNewMessage(c, !0, !0);
1209
- _context11.next = 20;
1300
+ e.deepChat.stream && u.text ? Stream.simulate(n, e.streamHandlers, u.text) : n.addNewMessage(u, !0, !0);
1301
+ _context13.next = 20;
1210
1302
  break;
1211
1303
  case 17:
1212
- _context11.prev = 17;
1213
- _context11.t1 = _context11["catch"](1);
1214
- RequestUtils.displayError(t, _context11.t1, "Error in server message");
1304
+ _context13.prev = 17;
1305
+ _context13.t1 = _context13["catch"](1);
1306
+ RequestUtils.displayError(n, _context13.t1, "Error in server message");
1215
1307
  case 20:
1216
1308
  case "end":
1217
- return _context11.stop();
1309
+ return _context13.stop();
1218
1310
  }
1219
- }, _callee11, null, [[1, 17]]);
1311
+ }, _callee13, null, [[1, 17]]);
1220
1312
  }));
1221
- return function (_x19) {
1222
- return _ref4.apply(this, arguments);
1313
+ return function (_x23) {
1314
+ return _ref5.apply(this, arguments);
1223
1315
  };
1224
- }(), e.websocket.onerror = function (n) {
1225
- console.error(n), t.addNewErrorMessage("service", "Connection error");
1226
- }, e.websocket.onclose = function () {
1227
- console.error("Connection closed"), t.isLastMessageError() || t.addNewErrorMessage("service", "Connection error");
1228
- });
1316
+ }(), t.onerror = function (s) {
1317
+ console.error(s), n.isLastMessageError() || n.addNewErrorMessage("service", "Connection error");
1318
+ }, t.onclose = function () {
1319
+ console.error("Connection closed"), n.isLastMessageError() || n.addNewErrorMessage("service", "Connection error"), Websocket.createConnection(e, n);
1320
+ };
1229
1321
  }
1230
1322
  }, {
1231
1323
  key: "sendWebsocket",
1232
1324
  value: function () {
1233
- var _sendWebsocket = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(e, t, n, s) {
1325
+ var _sendWebsocket = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(e, t, n, s) {
1234
1326
  var o,
1235
1327
  d,
1236
1328
  h,
@@ -1239,42 +1331,42 @@ var Websocket = /*#__PURE__*/function () {
1239
1331
  l,
1240
1332
  c,
1241
1333
  u,
1242
- _args12 = arguments;
1243
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1244
- while (1) switch (_context12.prev = _context12.next) {
1334
+ _args14 = arguments;
1335
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
1336
+ while (1) switch (_context14.prev = _context14.next) {
1245
1337
  case 0:
1246
- o = _args12.length > 4 && _args12[4] !== undefined ? _args12[4] : !0;
1338
+ o = _args14.length > 4 && _args14[4] !== undefined ? _args14[4] : !0;
1247
1339
  a = {
1248
1340
  body: n,
1249
1341
  headers: (d = t.requestSettings) == null ? void 0 : d.headers
1250
1342
  };
1251
- _context12.next = 4;
1343
+ _context14.next = 4;
1252
1344
  return RequestUtils.processResponseInterceptor(t.deepChat, a);
1253
1345
  case 4:
1254
- _yield$RequestUtils$p4 = _context12.sent;
1346
+ _yield$RequestUtils$p4 = _context14.sent;
1255
1347
  l = _yield$RequestUtils$p4.body;
1256
1348
  c = _yield$RequestUtils$p4.error;
1257
1349
  if (!c) {
1258
- _context12.next = 9;
1350
+ _context14.next = 9;
1259
1351
  break;
1260
1352
  }
1261
- return _context12.abrupt("return", s.addNewErrorMessage("service", c));
1353
+ return _context14.abrupt("return", s.addNewErrorMessage("service", c));
1262
1354
  case 9:
1263
1355
  u = o ? JSON.stringify(l) : l;
1264
1356
  if (!(((h = t.requestSettings) == null ? void 0 : h.url) === Demo.URL)) {
1265
- _context12.next = 12;
1357
+ _context14.next = 12;
1266
1358
  break;
1267
1359
  }
1268
- return _context12.abrupt("return", Demo.request(s, t.completionsHandlers.onFinish, t.deepChat.responseInterceptor));
1360
+ return _context14.abrupt("return", Demo.request(s, t.completionsHandlers.onFinish, t.deepChat.responseInterceptor));
1269
1361
  case 12:
1270
- e.readyState !== e.OPEN ? (console.error("Connection is not open"), s.addNewErrorMessage("service", "Connection error")) : e.send(JSON.stringify(u));
1362
+ e.readyState === void 0 || e.readyState !== e.OPEN ? (console.error("Connection is not open"), s.isLastMessageError() || s.addNewErrorMessage("service", "Connection error")) : e.send(JSON.stringify(u));
1271
1363
  case 13:
1272
1364
  case "end":
1273
- return _context12.stop();
1365
+ return _context14.stop();
1274
1366
  }
1275
- }, _callee12);
1367
+ }, _callee14);
1276
1368
  }));
1277
- function sendWebsocket(_x20, _x21, _x22, _x23) {
1369
+ function sendWebsocket(_x24, _x25, _x26, _x27) {
1278
1370
  return _sendWebsocket.apply(this, arguments);
1279
1371
  }
1280
1372
  return sendWebsocket;
@@ -1934,24 +2026,24 @@ function replaceAt(r, e, t) {
1934
2026
  return r.substr(0, e) + t + r.substr(e + 1);
1935
2027
  }
1936
2028
  function smartquotes(r) {
1937
- var e, t, n, s, o, a, l, c, u, d, h, p, f, b, m, v, g;
2029
+ var e, t, n, s, o, a, l, c, u, d, h, p, f, b, m, g, v;
1938
2030
  if (r.options.typographer) {
1939
- for (g = [], m = r.tokens.length - 1; m >= 0; m--) if (r.tokens[m].type === "inline") {
1940
- for (v = r.tokens[m].children, g.length = 0, e = 0; e < v.length; e++) if (t = v[e], !(t.type !== "text" || QUOTE_TEST_RE.test(t.text))) {
1941
- for (l = v[e].level, f = g.length - 1; f >= 0 && !(g[f].level <= l); f--);
1942
- g.length = f + 1, n = t.content, o = 0, a = n.length;
2031
+ for (v = [], m = r.tokens.length - 1; m >= 0; m--) if (r.tokens[m].type === "inline") {
2032
+ for (g = r.tokens[m].children, v.length = 0, e = 0; e < g.length; e++) if (t = g[e], !(t.type !== "text" || QUOTE_TEST_RE.test(t.text))) {
2033
+ for (l = g[e].level, f = v.length - 1; f >= 0 && !(v[f].level <= l); f--);
2034
+ v.length = f + 1, n = t.content, o = 0, a = n.length;
1943
2035
  e: for (; o < a && (QUOTE_RE.lastIndex = o, s = QUOTE_RE.exec(n), !!s);) {
1944
2036
  if (c = !isLetter(n, s.index - 1), o = s.index + 1, b = s[0] === "'", u = !isLetter(n, o), !u && !c) {
1945
2037
  b && (t.content = replaceAt(t.content, s.index, APOSTROPHE));
1946
2038
  continue;
1947
2039
  }
1948
2040
  if (h = !u, p = !c, p) {
1949
- for (f = g.length - 1; f >= 0 && (d = g[f], !(g[f].level < l)); f--) if (d.single === b && g[f].level === l) {
1950
- d = g[f], b ? (v[d.token].content = replaceAt(v[d.token].content, d.pos, r.options.quotes[2]), t.content = replaceAt(t.content, s.index, r.options.quotes[3])) : (v[d.token].content = replaceAt(v[d.token].content, d.pos, r.options.quotes[0]), t.content = replaceAt(t.content, s.index, r.options.quotes[1])), g.length = f;
2041
+ for (f = v.length - 1; f >= 0 && (d = v[f], !(v[f].level < l)); f--) if (d.single === b && v[f].level === l) {
2042
+ d = v[f], b ? (g[d.token].content = replaceAt(g[d.token].content, d.pos, r.options.quotes[2]), t.content = replaceAt(t.content, s.index, r.options.quotes[3])) : (g[d.token].content = replaceAt(g[d.token].content, d.pos, r.options.quotes[0]), t.content = replaceAt(t.content, s.index, r.options.quotes[1])), v.length = f;
1951
2043
  continue e;
1952
2044
  }
1953
2045
  }
1954
- h ? g.push({
2046
+ h ? v.push({
1955
2047
  token: e,
1956
2048
  pos: s.index,
1957
2049
  single: b,
@@ -2072,12 +2164,12 @@ function blockquote(r, e, t, n) {
2072
2164
  f,
2073
2165
  b,
2074
2166
  m = r.bMarks[e] + r.tShift[e],
2075
- v = r.eMarks[e];
2076
- if (m > v || r.src.charCodeAt(m++) !== 62 || r.level >= r.options.maxNesting) return !1;
2167
+ g = r.eMarks[e];
2168
+ if (m > g || r.src.charCodeAt(m++) !== 62 || r.level >= r.options.maxNesting) return !1;
2077
2169
  if (n) return !0;
2078
- for (r.src.charCodeAt(m) === 32 && m++, c = r.blkIndent, r.blkIndent = 0, l = [r.bMarks[e]], r.bMarks[e] = m, m = m < v ? r.skipSpaces(m) : m, o = m >= v, a = [r.tShift[e]], r.tShift[e] = m - r.bMarks[e], h = r.parser.ruler.getRules("blockquote"), s = e + 1; s < t && (m = r.bMarks[s] + r.tShift[s], v = r.eMarks[s], !(m >= v)); s++) {
2170
+ for (r.src.charCodeAt(m) === 32 && m++, c = r.blkIndent, r.blkIndent = 0, l = [r.bMarks[e]], r.bMarks[e] = m, m = m < g ? r.skipSpaces(m) : m, o = m >= g, a = [r.tShift[e]], r.tShift[e] = m - r.bMarks[e], h = r.parser.ruler.getRules("blockquote"), s = e + 1; s < t && (m = r.bMarks[s] + r.tShift[s], g = r.eMarks[s], !(m >= g)); s++) {
2079
2171
  if (r.src.charCodeAt(m++) === 62) {
2080
- r.src.charCodeAt(m) === 32 && m++, l.push(r.bMarks[s]), r.bMarks[s] = m, m = m < v ? r.skipSpaces(m) : m, o = m >= v, a.push(r.tShift[s]), r.tShift[s] = m - r.bMarks[s];
2172
+ r.src.charCodeAt(m) === 32 && m++, l.push(r.bMarks[s]), r.bMarks[s] = m, m = m < g ? r.skipSpaces(m) : m, o = m >= g, a.push(r.tShift[s]), r.tShift[s] = m - r.bMarks[s];
2081
2173
  continue;
2082
2174
  }
2083
2175
  if (o) break;
@@ -2152,51 +2244,51 @@ function list(r, e, t, n) {
2152
2244
  f,
2153
2245
  b,
2154
2246
  m,
2155
- v,
2156
2247
  g,
2248
+ v,
2157
2249
  y,
2158
- x,
2159
2250
  _,
2251
+ S,
2160
2252
  I,
2161
2253
  R = !0,
2162
2254
  w,
2163
- S,
2255
+ x,
2164
2256
  H,
2165
2257
  F;
2166
- if ((h = skipOrderedListMarker(r, e)) >= 0) v = !0;else if ((h = skipBulletListMarker(r, e)) >= 0) v = !1;else return !1;
2258
+ if ((h = skipOrderedListMarker(r, e)) >= 0) g = !0;else if ((h = skipBulletListMarker(r, e)) >= 0) g = !1;else return !1;
2167
2259
  if (r.level >= r.options.maxNesting) return !1;
2168
2260
  if (m = r.src.charCodeAt(h - 1), n) return !0;
2169
- for (y = r.tokens.length, v ? (d = r.bMarks[e] + r.tShift[e], b = Number(r.src.substr(d, h - d - 1)), r.tokens.push({
2261
+ 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({
2170
2262
  type: "ordered_list_open",
2171
2263
  order: b,
2172
- lines: _ = [e, 0],
2264
+ lines: S = [e, 0],
2173
2265
  level: r.level++
2174
2266
  })) : r.tokens.push({
2175
2267
  type: "bullet_list_open",
2176
- lines: _ = [e, 0],
2268
+ lines: S = [e, 0],
2177
2269
  level: r.level++
2178
- }), s = e, x = !1, w = r.parser.ruler.getRules("list"); s < t && (g = r.skipSpaces(h), p = r.eMarks[s], g >= p ? f = 1 : f = g - h, f > 4 && (f = 1), f < 1 && (f = 1), o = h - r.bMarks[s] + f, r.tokens.push({
2270
+ }), s = e, _ = !1, w = r.parser.ruler.getRules("list"); s < t && (v = r.skipSpaces(h), p = r.eMarks[s], v >= p ? f = 1 : f = v - h, f > 4 && (f = 1), f < 1 && (f = 1), o = h - r.bMarks[s] + f, r.tokens.push({
2179
2271
  type: "list_item_open",
2180
2272
  lines: I = [e, 0],
2181
2273
  level: r.level++
2182
- }), l = r.blkIndent, c = r.tight, a = r.tShift[e], u = r.parentType, r.tShift[e] = g - r.bMarks[e], r.blkIndent = o, r.tight = !0, r.parentType = "list", r.parser.tokenize(r, e, t, !0), (!r.tight || x) && (R = !1), x = r.line - e > 1 && r.isEmpty(r.line - 1), r.blkIndent = l, r.tShift[e] = a, r.tight = c, r.parentType = u, r.tokens.push({
2274
+ }), l = r.blkIndent, c = r.tight, a = r.tShift[e], u = r.parentType, r.tShift[e] = v - r.bMarks[e], r.blkIndent = o, r.tight = !0, r.parentType = "list", r.parser.tokenize(r, e, t, !0), (!r.tight || _) && (R = !1), _ = r.line - e > 1 && r.isEmpty(r.line - 1), r.blkIndent = l, r.tShift[e] = a, r.tight = c, r.parentType = u, r.tokens.push({
2183
2275
  type: "list_item_close",
2184
2276
  level: --r.level
2185
- }), s = e = r.line, I[1] = s, g = r.bMarks[e], !(s >= t || r.isEmpty(s) || r.tShift[s] < r.blkIndent));) {
2186
- for (F = !1, S = 0, H = w.length; S < H; S++) if (w[S](r, s, t, !0)) {
2277
+ }), s = e = r.line, I[1] = s, v = r.bMarks[e], !(s >= t || r.isEmpty(s) || r.tShift[s] < r.blkIndent));) {
2278
+ for (F = !1, x = 0, H = w.length; x < H; x++) if (w[x](r, s, t, !0)) {
2187
2279
  F = !0;
2188
2280
  break;
2189
2281
  }
2190
2282
  if (F) break;
2191
- if (v) {
2283
+ if (g) {
2192
2284
  if (h = skipOrderedListMarker(r, s), h < 0) break;
2193
2285
  } else if (h = skipBulletListMarker(r, s), h < 0) break;
2194
2286
  if (m !== r.src.charCodeAt(h - 1)) break;
2195
2287
  }
2196
2288
  return r.tokens.push({
2197
- type: v ? "ordered_list_close" : "bullet_list_close",
2289
+ type: g ? "ordered_list_close" : "bullet_list_close",
2198
2290
  level: --r.level
2199
- }), _[1] = s, r.line = s, R && markTightParagraphs(r, y), !0;
2291
+ }), S[1] = s, r.line = s, R && markTightParagraphs(r, y), !0;
2200
2292
  }
2201
2293
  function footnote(r, e, t, n) {
2202
2294
  var s,
@@ -2401,7 +2493,7 @@ function markTightParagraphs$1(r, e) {
2401
2493
  for (t = e + 2, n = r.tokens.length - 2; t < n; t++) r.tokens[t].level === s && r.tokens[t].type === "paragraph_open" && (r.tokens[t + 2].tight = !0, r.tokens[t].tight = !0, t += 2);
2402
2494
  }
2403
2495
  function deflist(r, e, t, n) {
2404
- var s, o, a, l, c, u, d, h, p, f, b, m, v, g;
2496
+ var s, o, a, l, c, u, d, h, p, f, b, m, g, v;
2405
2497
  if (n) return r.ddIndent < 0 ? !1 : skipMarker(r, e) >= 0;
2406
2498
  if (d = e + 1, r.isEmpty(d) && ++d > t || r.tShift[d] < r.blkIndent || (s = skipMarker(r, d), s < 0) || r.level >= r.options.maxNesting) return !1;
2407
2499
  u = r.tokens.length, r.tokens.push({
@@ -2410,7 +2502,7 @@ function deflist(r, e, t, n) {
2410
2502
  level: r.level++
2411
2503
  }), a = e, o = d;
2412
2504
  e: for (;;) {
2413
- for (g = !0, v = !1, r.tokens.push({
2505
+ for (v = !0, g = !1, r.tokens.push({
2414
2506
  type: "dt_open",
2415
2507
  lines: [a, a],
2416
2508
  level: r.level++
@@ -2428,7 +2520,7 @@ function deflist(r, e, t, n) {
2428
2520
  type: "dd_open",
2429
2521
  lines: l = [d, 0],
2430
2522
  level: r.level++
2431
- }), m = r.tight, p = r.ddIndent, h = r.blkIndent, b = r.tShift[o], f = r.parentType, r.blkIndent = r.ddIndent = r.tShift[o] + 2, r.tShift[o] = s - r.bMarks[o], r.tight = !0, r.parentType = "deflist", r.parser.tokenize(r, o, t, !0), (!r.tight || v) && (g = !1), v = r.line - o > 1 && r.isEmpty(r.line - 1), r.tShift[o] = b, r.tight = m, r.parentType = f, r.blkIndent = h, r.ddIndent = p, r.tokens.push({
2523
+ }), m = r.tight, p = r.ddIndent, h = r.blkIndent, b = r.tShift[o], f = r.parentType, r.blkIndent = r.ddIndent = r.tShift[o] + 2, r.tShift[o] = s - r.bMarks[o], r.tight = !0, r.parentType = "deflist", r.parser.tokenize(r, o, t, !0), (!r.tight || g) && (v = !1), g = r.line - o > 1 && r.isEmpty(r.line - 1), r.tShift[o] = b, r.tight = m, r.parentType = f, r.blkIndent = h, r.ddIndent = p, r.tokens.push({
2432
2524
  type: "dd_close",
2433
2525
  level: --r.level
2434
2526
  }), l[1] = d = r.line, d >= t || r.tShift[d] < r.blkIndent) break e;
@@ -2440,7 +2532,7 @@ function deflist(r, e, t, n) {
2440
2532
  return r.tokens.push({
2441
2533
  type: "dl_close",
2442
2534
  level: --r.level
2443
- }), c[1] = d, r.line = d, g && markTightParagraphs$1(r, u), !0;
2535
+ }), c[1] = d, r.line = d, v && markTightParagraphs$1(r, u), !0;
2444
2536
  }
2445
2537
  function paragraph(r, e) {
2446
2538
  var t,
@@ -3304,7 +3396,7 @@ var BaseServiceIO = /*#__PURE__*/function () {
3304
3396
  var _l$url;
3305
3397
  _classCallCheck(this, BaseServiceIO);
3306
3398
  var s, o, a, l;
3307
- this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage = BaseServiceIO.canSendMessage, this.requestSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = n, Object.assign(this.rawBody, (s = e.request) == null ? void 0 : s.additionalBodyProps), this.totalMessagesMaxCharLength = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.totalMessagesMaxCharLength, this.maxMessages = (a = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : a.maxMessages, SetFileTypes.set(e, this, t), e.request && (this.requestSettings = e.request), this.demo && ((_l$url = (l = this.requestSettings).url) !== null && _l$url !== void 0 ? _l$url : l.url = Demo.URL), this._directServiceRequiresFiles = !!t && Object.keys(t).length > 0, this.requestSettings.websocket && Websocket.setup(this, this.requestSettings.websocket);
3399
+ this.rawBody = {}, this.validateConfigKey = !1, this.canSendMessage = BaseServiceIO.canSendMessage, this.requestSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = n, Object.assign(this.rawBody, (s = e.request) == null ? void 0 : s.additionalBodyProps), this.totalMessagesMaxCharLength = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.totalMessagesMaxCharLength, this.maxMessages = (a = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : a.maxMessages, SetFileTypes.set(e, this, t), e.request && (this.requestSettings = e.request), this.demo && ((_l$url = (l = this.requestSettings).url) !== null && _l$url !== void 0 ? _l$url : l.url = Demo.URL), this._directServiceRequiresFiles = !!t && Object.keys(t).length > 0, this.requestSettings.websocket && Websocket.setup(this);
3308
3400
  }
3309
3401
  _createClass(BaseServiceIO, [{
3310
3402
  key: "verifyKey",
@@ -3323,11 +3415,11 @@ var BaseServiceIO = /*#__PURE__*/function () {
3323
3415
  }, {
3324
3416
  key: "callServiceAPI",
3325
3417
  value: function () {
3326
- var _callServiceAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(e, t, n) {
3418
+ var _callServiceAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(e, t, n) {
3327
3419
  var _c$headers, _u$ContentType;
3328
3420
  var l, c, u, d, s, o, a;
3329
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
3330
- while (1) switch (_context13.prev = _context13.next) {
3421
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
3422
+ while (1) switch (_context15.prev = _context15.next) {
3331
3423
  case 0:
3332
3424
  s = _objectSpread({
3333
3425
  messages: t
@@ -3336,26 +3428,26 @@ var BaseServiceIO = /*#__PURE__*/function () {
3336
3428
  (l = this.requestSettings.headers) != null && l["Content-Type"] || ((_c$headers = (c = this.requestSettings).headers) !== null && _c$headers !== void 0 ? _c$headers : c.headers = {}, (_u$ContentType = (u = this.requestSettings.headers)["Content-Type"]) !== null && _u$ContentType !== void 0 ? _u$ContentType : u["Content-Type"] = "application/json", o = !0);
3337
3429
  a = this.deepChat.stream;
3338
3430
  if (!(a && (this.demo || _typeof(a) != "object" || !a.simulation))) {
3339
- _context13.next = 9;
3431
+ _context15.next = 9;
3340
3432
  break;
3341
3433
  }
3342
- _context13.next = 7;
3434
+ _context15.next = 7;
3343
3435
  return Stream.request(this, s, e);
3344
3436
  case 7:
3345
- _context13.next = 11;
3437
+ _context15.next = 11;
3346
3438
  break;
3347
3439
  case 9:
3348
- _context13.next = 11;
3440
+ _context15.next = 11;
3349
3441
  return HTTPRequest.request(this, s, e);
3350
3442
  case 11:
3351
3443
  o && ((d = this.requestSettings.headers) == null || delete d["Content-Type"]);
3352
3444
  case 12:
3353
3445
  case "end":
3354
- return _context13.stop();
3446
+ return _context15.stop();
3355
3447
  }
3356
- }, _callee13, this);
3448
+ }, _callee15, this);
3357
3449
  }));
3358
- function callServiceAPI(_x24, _x25, _x26) {
3450
+ function callServiceAPI(_x28, _x29, _x30) {
3359
3451
  return _callServiceAPI.apply(this, arguments);
3360
3452
  }
3361
3453
  return callServiceAPI;
@@ -3363,24 +3455,24 @@ var BaseServiceIO = /*#__PURE__*/function () {
3363
3455
  }, {
3364
3456
  key: "callApiWithFiles",
3365
3457
  value: function () {
3366
- var _callApiWithFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(e, t, n, s) {
3458
+ var _callApiWithFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(e, t, n, s) {
3367
3459
  var o, a, l;
3368
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
3369
- while (1) switch (_context14.prev = _context14.next) {
3460
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
3461
+ while (1) switch (_context16.prev = _context16.next) {
3370
3462
  case 0:
3371
3463
  o = BaseServiceIO.createCustomFormDataBody(e, n, s), a = this.requestSettings, l = this.getServiceIOByType(s[0]);
3372
3464
  this.requestSettings = (l == null ? void 0 : l.request) || this.requestSettings;
3373
- _context14.next = 4;
3465
+ _context16.next = 4;
3374
3466
  return HTTPRequest.request(this, o, t, !1);
3375
3467
  case 4:
3376
3468
  this.requestSettings = a;
3377
3469
  case 5:
3378
3470
  case "end":
3379
- return _context14.stop();
3471
+ return _context16.stop();
3380
3472
  }
3381
- }, _callee14, this);
3473
+ }, _callee16, this);
3382
3474
  }));
3383
- function callApiWithFiles(_x27, _x28, _x29, _x30) {
3475
+ function callApiWithFiles(_x31, _x32, _x33, _x34) {
3384
3476
  return _callApiWithFiles.apply(this, arguments);
3385
3477
  }
3386
3478
  return callApiWithFiles;
@@ -3388,13 +3480,13 @@ var BaseServiceIO = /*#__PURE__*/function () {
3388
3480
  }, {
3389
3481
  key: "callAPI",
3390
3482
  value: function () {
3391
- var _callAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(e, t) {
3483
+ var _callAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(e, t) {
3392
3484
  var n, s;
3393
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
3394
- while (1) switch (_context15.prev = _context15.next) {
3485
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
3486
+ while (1) switch (_context17.prev = _context17.next) {
3395
3487
  case 0:
3396
3488
  if (this.requestSettings) {
3397
- _context15.next = 2;
3489
+ _context17.next = 2;
3398
3490
  break;
3399
3491
  }
3400
3492
  throw new Error("Request settings have not been set up");
@@ -3408,36 +3500,37 @@ var BaseServiceIO = /*#__PURE__*/function () {
3408
3500
  } else e.files && !this._directServiceRequiresFiles ? this.callApiWithFiles(this.rawBody, t, n, e.files) : this.callServiceAPI(t, n, e.files);
3409
3501
  case 4:
3410
3502
  case "end":
3411
- return _context15.stop();
3503
+ return _context17.stop();
3412
3504
  }
3413
- }, _callee15, this);
3505
+ }, _callee17, this);
3414
3506
  }));
3415
- function callAPI(_x31, _x32) {
3507
+ function callAPI(_x35, _x36) {
3416
3508
  return _callAPI.apply(this, arguments);
3417
3509
  }
3418
3510
  return callAPI;
3419
- }()
3511
+ }() // WORK - validation to say that the response should have text, files or error property, link to example
3512
+ // and responseInterceptor
3420
3513
  }, {
3421
3514
  key: "extractResultData",
3422
3515
  value: function () {
3423
- var _extractResultData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(e) {
3424
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
3425
- while (1) switch (_context16.prev = _context16.next) {
3516
+ var _extractResultData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(e) {
3517
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
3518
+ while (1) switch (_context18.prev = _context18.next) {
3426
3519
  case 0:
3427
3520
  if (!e.error) {
3428
- _context16.next = 2;
3521
+ _context18.next = 2;
3429
3522
  break;
3430
3523
  }
3431
3524
  throw e.error;
3432
3525
  case 2:
3433
- return _context16.abrupt("return", e.result);
3526
+ return _context18.abrupt("return", e.result ? (console.error("The {result: ....} response object type is deprecated since version 1.3.0."), console.error("Please change to using the new response object: https://deepchat.dev/docs/connect#Response"), e.result) : e);
3434
3527
  case 3:
3435
3528
  case "end":
3436
- return _context16.stop();
3529
+ return _context18.stop();
3437
3530
  }
3438
- }, _callee16);
3531
+ }, _callee18);
3439
3532
  }));
3440
- function extractResultData(_x33) {
3533
+ function extractResultData(_x37) {
3441
3534
  return _extractResultData.apply(this, arguments);
3442
3535
  }
3443
3536
  return extractResultData;
@@ -3778,17 +3871,17 @@ var HuggingFaceUtils = /*#__PURE__*/function () {
3778
3871
  return HuggingFaceUtils;
3779
3872
  }();
3780
3873
  var _HuggingFaceIO = /*#__PURE__*/function (_DirectServiceIO) {
3781
- _inherits(U, _DirectServiceIO);
3782
- var _super3 = _createSuper(U);
3874
+ _inherits(j, _DirectServiceIO);
3875
+ var _super3 = _createSuper(j);
3783
3876
  // prettier-ignore
3784
- function U(e, t, n, s, o, a) {
3877
+ function j(e, t, n, s, o, a) {
3785
3878
  var _this4;
3786
- _classCallCheck(this, U);
3787
- _this4 = _super3.call(this, e, HuggingFaceUtils.buildKeyVerificationDetails(), HuggingFaceUtils.buildHeaders, o, a), _this4.insertKeyPlaceholderText = "Hugging Face Token", _this4.getKeyLink = "https://huggingface.co/settings/tokens", _this4.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>", _this4.permittedErrorPrefixes = ["Authorization header"], _this4.url = "".concat(U.URL_PREFIX).concat(n), _this4.textInputPlaceholderText = t, _typeof(s) == "object" && (s.model && (_this4.url = "".concat(U.URL_PREFIX).concat(s.model)), s.options && (_this4.rawBody.options = s.options), s.parameters && (_this4.rawBody.parameters = s.parameters));
3879
+ _classCallCheck(this, j);
3880
+ _this4 = _super3.call(this, e, HuggingFaceUtils.buildKeyVerificationDetails(), HuggingFaceUtils.buildHeaders, o, a), _this4.insertKeyPlaceholderText = "Hugging Face Token", _this4.getKeyLink = "https://huggingface.co/settings/tokens", _this4.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>", _this4.permittedErrorPrefixes = ["Authorization header"], _this4.url = "".concat(j.URL_PREFIX).concat(n), _this4.textInputPlaceholderText = t, _typeof(s) == "object" && (s.model && (_this4.url = "".concat(j.URL_PREFIX).concat(s.model)), s.options && (_this4.rawBody.options = s.options), s.parameters && (_this4.rawBody.parameters = s.parameters));
3788
3881
  return _this4;
3789
3882
  }
3790
3883
  // prettier-ignore
3791
- _createClass(U, [{
3884
+ _createClass(j, [{
3792
3885
  key: "preprocessBody",
3793
3886
  value: function preprocessBody(e, t, n) {
3794
3887
  var _s$options;
@@ -3801,13 +3894,13 @@ var _HuggingFaceIO = /*#__PURE__*/function (_DirectServiceIO) {
3801
3894
  }, {
3802
3895
  key: "callServiceAPI",
3803
3896
  value: function () {
3804
- var _callServiceAPI2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(e, t, n) {
3897
+ var _callServiceAPI2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(e, t, n) {
3805
3898
  var s;
3806
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
3807
- while (1) switch (_context17.prev = _context17.next) {
3899
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
3900
+ while (1) switch (_context19.prev = _context19.next) {
3808
3901
  case 0:
3809
3902
  if (this.requestSettings) {
3810
- _context17.next = 2;
3903
+ _context19.next = 2;
3811
3904
  break;
3812
3905
  }
3813
3906
  throw new Error("Request settings have not been set up");
@@ -3816,17 +3909,17 @@ var _HuggingFaceIO = /*#__PURE__*/function (_DirectServiceIO) {
3816
3909
  HTTPRequest.request(this, s, e);
3817
3910
  case 4:
3818
3911
  case "end":
3819
- return _context17.stop();
3912
+ return _context19.stop();
3820
3913
  }
3821
- }, _callee17, this);
3914
+ }, _callee19, this);
3822
3915
  }));
3823
- function callServiceAPI(_x34, _x35, _x36) {
3916
+ function callServiceAPI(_x38, _x39, _x40) {
3824
3917
  return _callServiceAPI2.apply(this, arguments);
3825
3918
  }
3826
3919
  return callServiceAPI;
3827
3920
  }()
3828
3921
  }]);
3829
- return U;
3922
+ return j;
3830
3923
  }(DirectServiceIO);
3831
3924
  _HuggingFaceIO.URL_PREFIX = "https://api-inference.huggingface.co/models/";
3832
3925
  var HuggingFaceIO = _HuggingFaceIO;
@@ -3849,18 +3942,18 @@ var HuggingFaceFileIO = /*#__PURE__*/function (_HuggingFaceIO2) {
3849
3942
  }, {
3850
3943
  key: "callServiceAPI",
3851
3944
  value: function () {
3852
- var _callServiceAPI3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(e, t, n) {
3853
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
3854
- while (1) switch (_context18.prev = _context18.next) {
3945
+ var _callServiceAPI3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(e, t, n) {
3946
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
3947
+ while (1) switch (_context20.prev = _context20.next) {
3855
3948
  case 0:
3856
3949
  if (this.requestSettings) {
3857
- _context18.next = 2;
3950
+ _context20.next = 2;
3858
3951
  break;
3859
3952
  }
3860
3953
  throw new Error("Request settings have not been set up");
3861
3954
  case 2:
3862
3955
  if (n != null && n[0]) {
3863
- _context18.next = 4;
3956
+ _context20.next = 4;
3864
3957
  break;
3865
3958
  }
3866
3959
  throw new Error("No file was added");
@@ -3868,11 +3961,11 @@ var HuggingFaceFileIO = /*#__PURE__*/function (_HuggingFaceIO2) {
3868
3961
  HTTPRequest.poll(this, n[0], e, !1);
3869
3962
  case 5:
3870
3963
  case "end":
3871
- return _context18.stop();
3964
+ return _context20.stop();
3872
3965
  }
3873
- }, _callee18, this);
3966
+ }, _callee20, this);
3874
3967
  }));
3875
- function callServiceAPI(_x37, _x38, _x39) {
3968
+ function callServiceAPI(_x41, _x42, _x43) {
3876
3969
  return _callServiceAPI3.apply(this, arguments);
3877
3970
  }
3878
3971
  return callServiceAPI;
@@ -3901,35 +3994,35 @@ var HuggingFaceAudioClassificationIO = /*#__PURE__*/function (_HuggingFaceFileIO
3901
3994
  _createClass(HuggingFaceAudioClassificationIO, [{
3902
3995
  key: "extractPollResultData",
3903
3996
  value: function () {
3904
- var _extractPollResultData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(e) {
3997
+ var _extractPollResultData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(e) {
3905
3998
  var t;
3906
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
3907
- while (1) switch (_context19.prev = _context19.next) {
3999
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
4000
+ while (1) switch (_context21.prev = _context21.next) {
3908
4001
  case 0:
3909
4002
  if (!e.estimated_time) {
3910
- _context19.next = 2;
4003
+ _context21.next = 2;
3911
4004
  break;
3912
4005
  }
3913
- return _context19.abrupt("return", {
4006
+ return _context21.abrupt("return", {
3914
4007
  timeoutMS: (e.estimated_time + 1) * 1e3
3915
4008
  });
3916
4009
  case 2:
3917
4010
  if (!e.error) {
3918
- _context19.next = 4;
4011
+ _context21.next = 4;
3919
4012
  break;
3920
4013
  }
3921
4014
  throw e.error;
3922
4015
  case 4:
3923
- return _context19.abrupt("return", {
4016
+ return _context21.abrupt("return", {
3924
4017
  text: ((t = e[0]) == null ? void 0 : t.label) || ""
3925
4018
  });
3926
4019
  case 5:
3927
4020
  case "end":
3928
- return _context19.stop();
4021
+ return _context21.stop();
3929
4022
  }
3930
- }, _callee19);
4023
+ }, _callee21);
3931
4024
  }));
3932
- function extractPollResultData(_x40) {
4025
+ function extractPollResultData(_x44) {
3933
4026
  return _extractPollResultData.apply(this, arguments);
3934
4027
  }
3935
4028
  return extractPollResultData;
@@ -3952,35 +4045,35 @@ var HuggingFaceImageClassificationIO = /*#__PURE__*/function (_HuggingFaceFileIO
3952
4045
  _createClass(HuggingFaceImageClassificationIO, [{
3953
4046
  key: "extractPollResultData",
3954
4047
  value: function () {
3955
- var _extractPollResultData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(e) {
4048
+ var _extractPollResultData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(e) {
3956
4049
  var t;
3957
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
3958
- while (1) switch (_context20.prev = _context20.next) {
4050
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
4051
+ while (1) switch (_context22.prev = _context22.next) {
3959
4052
  case 0:
3960
4053
  if (!e.estimated_time) {
3961
- _context20.next = 2;
4054
+ _context22.next = 2;
3962
4055
  break;
3963
4056
  }
3964
- return _context20.abrupt("return", {
4057
+ return _context22.abrupt("return", {
3965
4058
  timeoutMS: (e.estimated_time + 1) * 1e3
3966
4059
  });
3967
4060
  case 2:
3968
4061
  if (!e.error) {
3969
- _context20.next = 4;
4062
+ _context22.next = 4;
3970
4063
  break;
3971
4064
  }
3972
4065
  throw e.error;
3973
4066
  case 4:
3974
- return _context20.abrupt("return", {
4067
+ return _context22.abrupt("return", {
3975
4068
  text: ((t = e[0]) == null ? void 0 : t.label) || ""
3976
4069
  });
3977
4070
  case 5:
3978
4071
  case "end":
3979
- return _context20.stop();
4072
+ return _context22.stop();
3980
4073
  }
3981
- }, _callee20);
4074
+ }, _callee22);
3982
4075
  }));
3983
- function extractPollResultData(_x41) {
4076
+ function extractPollResultData(_x45) {
3984
4077
  return _extractPollResultData2.apply(this, arguments);
3985
4078
  }
3986
4079
  return extractPollResultData;
@@ -4065,19 +4158,19 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
4065
4158
  }, {
4066
4159
  key: "callServiceAPI",
4067
4160
  value: function () {
4068
- var _callServiceAPI4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(e, t, n) {
4161
+ var _callServiceAPI4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(e, t, n) {
4069
4162
  var s;
4070
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
4071
- while (1) switch (_context21.prev = _context21.next) {
4163
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
4164
+ while (1) switch (_context23.prev = _context23.next) {
4072
4165
  case 0:
4073
4166
  if (this.requestSettings) {
4074
- _context21.next = 2;
4167
+ _context23.next = 2;
4075
4168
  break;
4076
4169
  }
4077
4170
  throw new Error("Request settings have not been set up");
4078
4171
  case 2:
4079
4172
  if (n) {
4080
- _context21.next = 4;
4173
+ _context23.next = 4;
4081
4174
  break;
4082
4175
  }
4083
4176
  throw new Error("Image was not found");
@@ -4086,11 +4179,11 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
4086
4179
  RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, s, e), !1);
4087
4180
  case 6:
4088
4181
  case "end":
4089
- return _context21.stop();
4182
+ return _context23.stop();
4090
4183
  }
4091
- }, _callee21, this);
4184
+ }, _callee23, this);
4092
4185
  }));
4093
- function callServiceAPI(_x42, _x43, _x44) {
4186
+ function callServiceAPI(_x46, _x47, _x48) {
4094
4187
  return _callServiceAPI4.apply(this, arguments);
4095
4188
  }
4096
4189
  return callServiceAPI;
@@ -4098,17 +4191,17 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
4098
4191
  }, {
4099
4192
  key: "extractResultData",
4100
4193
  value: function () {
4101
- var _extractResultData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(e) {
4102
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
4103
- while (1) switch (_context22.prev = _context22.next) {
4194
+ var _extractResultData2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(e) {
4195
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
4196
+ while (1) switch (_context24.prev = _context24.next) {
4104
4197
  case 0:
4105
4198
  if (!e.message) {
4106
- _context22.next = 2;
4199
+ _context24.next = 2;
4107
4200
  break;
4108
4201
  }
4109
4202
  throw e.message;
4110
4203
  case 2:
4111
- return _context22.abrupt("return", {
4204
+ return _context24.abrupt("return", {
4112
4205
  files: e.artifacts.map(function (n) {
4113
4206
  return {
4114
4207
  src: "".concat(BASE_64_PREFIX).concat(n.base64),
@@ -4118,11 +4211,11 @@ var StabilityAIImageToImageUpscaleIO = /*#__PURE__*/function (_StabilityAIIO) {
4118
4211
  });
4119
4212
  case 3:
4120
4213
  case "end":
4121
- return _context22.stop();
4214
+ return _context24.stop();
4122
4215
  }
4123
- }, _callee22);
4216
+ }, _callee24);
4124
4217
  }));
4125
- function extractResultData(_x45) {
4218
+ function extractResultData(_x49) {
4126
4219
  return _extractResultData2.apply(this, arguments);
4127
4220
  }
4128
4221
  return extractResultData;
@@ -4174,19 +4267,19 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
4174
4267
  }, {
4175
4268
  key: "callServiceAPI",
4176
4269
  value: function () {
4177
- var _callServiceAPI5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(e, t, n) {
4270
+ var _callServiceAPI5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(e, t, n) {
4178
4271
  var a, l, s, o;
4179
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
4180
- while (1) switch (_context23.prev = _context23.next) {
4272
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
4273
+ while (1) switch (_context25.prev = _context25.next) {
4181
4274
  case 0:
4182
4275
  if (this.requestSettings) {
4183
- _context23.next = 2;
4276
+ _context25.next = 2;
4184
4277
  break;
4185
4278
  }
4186
4279
  throw new Error("Request settings have not been set up");
4187
4280
  case 2:
4188
4281
  if (!(!n || !n[0] || !n[1])) {
4189
- _context23.next = 4;
4282
+ _context25.next = 4;
4190
4283
  break;
4191
4284
  }
4192
4285
  throw new Error("Image was not found");
@@ -4195,11 +4288,11 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
4195
4288
  RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, o, e), !1);
4196
4289
  case 6:
4197
4290
  case "end":
4198
- return _context23.stop();
4291
+ return _context25.stop();
4199
4292
  }
4200
- }, _callee23, this);
4293
+ }, _callee25, this);
4201
4294
  }));
4202
- function callServiceAPI(_x46, _x47, _x48) {
4295
+ function callServiceAPI(_x50, _x51, _x52) {
4203
4296
  return _callServiceAPI5.apply(this, arguments);
4204
4297
  }
4205
4298
  return callServiceAPI;
@@ -4207,17 +4300,17 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
4207
4300
  }, {
4208
4301
  key: "extractResultData",
4209
4302
  value: function () {
4210
- var _extractResultData3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(e) {
4211
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
4212
- while (1) switch (_context24.prev = _context24.next) {
4303
+ var _extractResultData3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(e) {
4304
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
4305
+ while (1) switch (_context26.prev = _context26.next) {
4213
4306
  case 0:
4214
4307
  if (!e.message) {
4215
- _context24.next = 2;
4308
+ _context26.next = 2;
4216
4309
  break;
4217
4310
  }
4218
4311
  throw e.message;
4219
4312
  case 2:
4220
- return _context24.abrupt("return", {
4313
+ return _context26.abrupt("return", {
4221
4314
  files: e.artifacts.map(function (n) {
4222
4315
  return {
4223
4316
  src: "".concat(BASE_64_PREFIX).concat(n.base64),
@@ -4227,11 +4320,11 @@ var StabilityAIImageToImageMaskingIO = /*#__PURE__*/function (_StabilityAIIO2) {
4227
4320
  });
4228
4321
  case 3:
4229
4322
  case "end":
4230
- return _context24.stop();
4323
+ return _context26.stop();
4231
4324
  }
4232
- }, _callee24);
4325
+ }, _callee26);
4233
4326
  }));
4234
- function extractResultData(_x49) {
4327
+ function extractResultData(_x53) {
4235
4328
  return _extractResultData3.apply(this, arguments);
4236
4329
  }
4237
4330
  return extractResultData;
@@ -4264,34 +4357,34 @@ var HuggingFaceAudioRecognitionIO = /*#__PURE__*/function (_HuggingFaceFileIO3)
4264
4357
  _createClass(HuggingFaceAudioRecognitionIO, [{
4265
4358
  key: "extractPollResultData",
4266
4359
  value: function () {
4267
- var _extractPollResultData3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(e) {
4268
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
4269
- while (1) switch (_context25.prev = _context25.next) {
4360
+ var _extractPollResultData3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(e) {
4361
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
4362
+ while (1) switch (_context27.prev = _context27.next) {
4270
4363
  case 0:
4271
4364
  if (!e.estimated_time) {
4272
- _context25.next = 2;
4365
+ _context27.next = 2;
4273
4366
  break;
4274
4367
  }
4275
- return _context25.abrupt("return", {
4368
+ return _context27.abrupt("return", {
4276
4369
  timeoutMS: (e.estimated_time + 1) * 1e3
4277
4370
  });
4278
4371
  case 2:
4279
4372
  if (!e.error) {
4280
- _context25.next = 4;
4373
+ _context27.next = 4;
4281
4374
  break;
4282
4375
  }
4283
4376
  throw e.error;
4284
4377
  case 4:
4285
- return _context25.abrupt("return", {
4378
+ return _context27.abrupt("return", {
4286
4379
  text: e.text || ""
4287
4380
  });
4288
4381
  case 5:
4289
4382
  case "end":
4290
- return _context25.stop();
4383
+ return _context27.stop();
4291
4384
  }
4292
- }, _callee25);
4385
+ }, _callee27);
4293
4386
  }));
4294
- function extractPollResultData(_x50) {
4387
+ function extractPollResultData(_x54) {
4295
4388
  return _extractPollResultData3.apply(this, arguments);
4296
4389
  }
4297
4390
  return extractPollResultData;
@@ -4312,26 +4405,26 @@ var HuggingFaceTextGenerationIO = /*#__PURE__*/function (_HuggingFaceIO3) {
4312
4405
  _createClass(HuggingFaceTextGenerationIO, [{
4313
4406
  key: "extractResultData",
4314
4407
  value: function () {
4315
- var _extractResultData4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(e) {
4316
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
4317
- while (1) switch (_context26.prev = _context26.next) {
4408
+ var _extractResultData4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(e) {
4409
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
4410
+ while (1) switch (_context28.prev = _context28.next) {
4318
4411
  case 0:
4319
4412
  if (!e.error) {
4320
- _context26.next = 2;
4413
+ _context28.next = 2;
4321
4414
  break;
4322
4415
  }
4323
4416
  throw e.error;
4324
4417
  case 2:
4325
- return _context26.abrupt("return", {
4418
+ return _context28.abrupt("return", {
4326
4419
  text: e[0].generated_text || ""
4327
4420
  });
4328
4421
  case 3:
4329
4422
  case "end":
4330
- return _context26.stop();
4423
+ return _context28.stop();
4331
4424
  }
4332
- }, _callee26);
4425
+ }, _callee28);
4333
4426
  }));
4334
- function extractResultData(_x51) {
4427
+ function extractResultData(_x55) {
4335
4428
  return _extractResultData4.apply(this, arguments);
4336
4429
  }
4337
4430
  return extractResultData;
@@ -4368,26 +4461,26 @@ var HuggingFaceQuestionAnswerIO = /*#__PURE__*/function (_HuggingFaceIO4) {
4368
4461
  }, {
4369
4462
  key: "extractResultData",
4370
4463
  value: function () {
4371
- var _extractResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(e) {
4372
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
4373
- while (1) switch (_context27.prev = _context27.next) {
4464
+ var _extractResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(e) {
4465
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
4466
+ while (1) switch (_context29.prev = _context29.next) {
4374
4467
  case 0:
4375
4468
  if (!e.error) {
4376
- _context27.next = 2;
4469
+ _context29.next = 2;
4377
4470
  break;
4378
4471
  }
4379
4472
  throw e.error;
4380
4473
  case 2:
4381
- return _context27.abrupt("return", {
4474
+ return _context29.abrupt("return", {
4382
4475
  text: e.answer || ""
4383
4476
  });
4384
4477
  case 3:
4385
4478
  case "end":
4386
- return _context27.stop();
4479
+ return _context29.stop();
4387
4480
  }
4388
- }, _callee27);
4481
+ }, _callee29);
4389
4482
  }));
4390
- function extractResultData(_x52) {
4483
+ function extractResultData(_x56) {
4391
4484
  return _extractResultData5.apply(this, arguments);
4392
4485
  }
4393
4486
  return extractResultData;
@@ -4408,26 +4501,26 @@ var HuggingFaceSummarizationIO = /*#__PURE__*/function (_HuggingFaceIO5) {
4408
4501
  _createClass(HuggingFaceSummarizationIO, [{
4409
4502
  key: "extractResultData",
4410
4503
  value: function () {
4411
- var _extractResultData6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(e) {
4412
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
4413
- while (1) switch (_context28.prev = _context28.next) {
4504
+ var _extractResultData6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(e) {
4505
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
4506
+ while (1) switch (_context30.prev = _context30.next) {
4414
4507
  case 0:
4415
4508
  if (!e.error) {
4416
- _context28.next = 2;
4509
+ _context30.next = 2;
4417
4510
  break;
4418
4511
  }
4419
4512
  throw e.error;
4420
4513
  case 2:
4421
- return _context28.abrupt("return", {
4514
+ return _context30.abrupt("return", {
4422
4515
  text: e[0].summary_text || ""
4423
4516
  });
4424
4517
  case 3:
4425
4518
  case "end":
4426
- return _context28.stop();
4519
+ return _context30.stop();
4427
4520
  }
4428
- }, _callee28);
4521
+ }, _callee30);
4429
4522
  }));
4430
- function extractResultData(_x53) {
4523
+ function extractResultData(_x57) {
4431
4524
  return _extractResultData6.apply(this, arguments);
4432
4525
  }
4433
4526
  return extractResultData;
@@ -4488,26 +4581,26 @@ var HuggingFaceConversationIO = /*#__PURE__*/function (_HuggingFaceIO6) {
4488
4581
  }, {
4489
4582
  key: "extractResultData",
4490
4583
  value: function () {
4491
- var _extractResultData7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(e) {
4492
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
4493
- while (1) switch (_context29.prev = _context29.next) {
4584
+ var _extractResultData7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(e) {
4585
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
4586
+ while (1) switch (_context31.prev = _context31.next) {
4494
4587
  case 0:
4495
4588
  if (!e.error) {
4496
- _context29.next = 2;
4589
+ _context31.next = 2;
4497
4590
  break;
4498
4591
  }
4499
4592
  throw e.error;
4500
4593
  case 2:
4501
- return _context29.abrupt("return", {
4594
+ return _context31.abrupt("return", {
4502
4595
  text: e.generated_text || ""
4503
4596
  });
4504
4597
  case 3:
4505
4598
  case "end":
4506
- return _context29.stop();
4599
+ return _context31.stop();
4507
4600
  }
4508
- }, _callee29);
4601
+ }, _callee31);
4509
4602
  }));
4510
- function extractResultData(_x54) {
4603
+ function extractResultData(_x58) {
4511
4604
  return _extractResultData7.apply(this, arguments);
4512
4605
  }
4513
4606
  return extractResultData;
@@ -4549,19 +4642,19 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
4549
4642
  }, {
4550
4643
  key: "callServiceAPI",
4551
4644
  value: function () {
4552
- var _callServiceAPI6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(e, t, n) {
4645
+ var _callServiceAPI6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(e, t, n) {
4553
4646
  var a, l, s, o;
4554
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
4555
- while (1) switch (_context30.prev = _context30.next) {
4647
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
4648
+ while (1) switch (_context32.prev = _context32.next) {
4556
4649
  case 0:
4557
4650
  if (this.requestSettings) {
4558
- _context30.next = 2;
4651
+ _context32.next = 2;
4559
4652
  break;
4560
4653
  }
4561
4654
  throw new Error("Request settings have not been set up");
4562
4655
  case 2:
4563
4656
  if (n) {
4564
- _context30.next = 4;
4657
+ _context32.next = 4;
4565
4658
  break;
4566
4659
  }
4567
4660
  throw new Error("Image was not found");
@@ -4570,11 +4663,11 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
4570
4663
  RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, o, e), !1);
4571
4664
  case 6:
4572
4665
  case "end":
4573
- return _context30.stop();
4666
+ return _context32.stop();
4574
4667
  }
4575
- }, _callee30, this);
4668
+ }, _callee32, this);
4576
4669
  }));
4577
- function callServiceAPI(_x55, _x56, _x57) {
4670
+ function callServiceAPI(_x59, _x60, _x61) {
4578
4671
  return _callServiceAPI6.apply(this, arguments);
4579
4672
  }
4580
4673
  return callServiceAPI;
@@ -4582,17 +4675,17 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
4582
4675
  }, {
4583
4676
  key: "extractResultData",
4584
4677
  value: function () {
4585
- var _extractResultData8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(e) {
4586
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
4587
- while (1) switch (_context31.prev = _context31.next) {
4678
+ var _extractResultData8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(e) {
4679
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
4680
+ while (1) switch (_context33.prev = _context33.next) {
4588
4681
  case 0:
4589
4682
  if (!e.message) {
4590
- _context31.next = 2;
4683
+ _context33.next = 2;
4591
4684
  break;
4592
4685
  }
4593
4686
  throw e.message;
4594
4687
  case 2:
4595
- return _context31.abrupt("return", {
4688
+ return _context33.abrupt("return", {
4596
4689
  files: e.artifacts.map(function (n) {
4597
4690
  return {
4598
4691
  src: "".concat(BASE_64_PREFIX).concat(n.base64),
@@ -4602,11 +4695,11 @@ var StabilityAIImageToImageIO = /*#__PURE__*/function (_StabilityAIIO3) {
4602
4695
  });
4603
4696
  case 3:
4604
4697
  case "end":
4605
- return _context31.stop();
4698
+ return _context33.stop();
4606
4699
  }
4607
- }, _callee31);
4700
+ }, _callee33);
4608
4701
  }));
4609
- function extractResultData(_x58) {
4702
+ function extractResultData(_x62) {
4610
4703
  return _extractResultData8.apply(this, arguments);
4611
4704
  }
4612
4705
  return extractResultData;
@@ -4637,26 +4730,26 @@ var HuggingFaceTranslationIO = /*#__PURE__*/function (_HuggingFaceIO7) {
4637
4730
  _createClass(HuggingFaceTranslationIO, [{
4638
4731
  key: "extractResultData",
4639
4732
  value: function () {
4640
- var _extractResultData9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(e) {
4641
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
4642
- while (1) switch (_context32.prev = _context32.next) {
4733
+ var _extractResultData9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(e) {
4734
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4735
+ while (1) switch (_context34.prev = _context34.next) {
4643
4736
  case 0:
4644
4737
  if (!e.error) {
4645
- _context32.next = 2;
4738
+ _context34.next = 2;
4646
4739
  break;
4647
4740
  }
4648
4741
  throw e.error;
4649
4742
  case 2:
4650
- return _context32.abrupt("return", {
4743
+ return _context34.abrupt("return", {
4651
4744
  text: e[0].translation_text || ""
4652
4745
  });
4653
4746
  case 3:
4654
4747
  case "end":
4655
- return _context32.stop();
4748
+ return _context34.stop();
4656
4749
  }
4657
- }, _callee32);
4750
+ }, _callee34);
4658
4751
  }));
4659
- function extractResultData(_x59) {
4752
+ function extractResultData(_x63) {
4660
4753
  return _extractResultData9.apply(this, arguments);
4661
4754
  }
4662
4755
  return extractResultData;
@@ -4690,13 +4783,13 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
4690
4783
  }, {
4691
4784
  key: "callServiceAPI",
4692
4785
  value: function () {
4693
- var _callServiceAPI7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(e, t) {
4786
+ var _callServiceAPI7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(e, t) {
4694
4787
  var n;
4695
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
4696
- while (1) switch (_context33.prev = _context33.next) {
4788
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4789
+ while (1) switch (_context35.prev = _context35.next) {
4697
4790
  case 0:
4698
4791
  if (this.requestSettings) {
4699
- _context33.next = 2;
4792
+ _context35.next = 2;
4700
4793
  break;
4701
4794
  }
4702
4795
  throw new Error("Request settings have not been set up");
@@ -4705,11 +4798,11 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
4705
4798
  HTTPRequest.request(this, n, e);
4706
4799
  case 4:
4707
4800
  case "end":
4708
- return _context33.stop();
4801
+ return _context35.stop();
4709
4802
  }
4710
- }, _callee33, this);
4803
+ }, _callee35, this);
4711
4804
  }));
4712
- function callServiceAPI(_x60, _x61) {
4805
+ function callServiceAPI(_x64, _x65) {
4713
4806
  return _callServiceAPI7.apply(this, arguments);
4714
4807
  }
4715
4808
  return callServiceAPI;
@@ -4717,17 +4810,17 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
4717
4810
  }, {
4718
4811
  key: "extractResultData",
4719
4812
  value: function () {
4720
- var _extractResultData10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(e) {
4721
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4722
- while (1) switch (_context34.prev = _context34.next) {
4813
+ var _extractResultData10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(e) {
4814
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4815
+ while (1) switch (_context36.prev = _context36.next) {
4723
4816
  case 0:
4724
4817
  if (!e.message) {
4725
- _context34.next = 2;
4818
+ _context36.next = 2;
4726
4819
  break;
4727
4820
  }
4728
4821
  throw e.message;
4729
4822
  case 2:
4730
- return _context34.abrupt("return", {
4823
+ return _context36.abrupt("return", {
4731
4824
  files: e.artifacts.map(function (n) {
4732
4825
  return {
4733
4826
  src: "".concat(BASE_64_PREFIX).concat(n.base64),
@@ -4737,11 +4830,11 @@ var StabilityAITextToImageIO = /*#__PURE__*/function (_StabilityAIIO4) {
4737
4830
  });
4738
4831
  case 3:
4739
4832
  case "end":
4740
- return _context34.stop();
4833
+ return _context36.stop();
4741
4834
  }
4742
- }, _callee34);
4835
+ }, _callee36);
4743
4836
  }));
4744
- function extractResultData(_x62) {
4837
+ function extractResultData(_x66) {
4745
4838
  return _extractResultData10.apply(this, arguments);
4746
4839
  }
4747
4840
  return extractResultData;
@@ -4774,26 +4867,26 @@ var HuggingFaceFillMaskIO = /*#__PURE__*/function (_HuggingFaceIO8) {
4774
4867
  _createClass(HuggingFaceFillMaskIO, [{
4775
4868
  key: "extractResultData",
4776
4869
  value: function () {
4777
- var _extractResultData11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(e) {
4778
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4779
- while (1) switch (_context35.prev = _context35.next) {
4870
+ var _extractResultData11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(e) {
4871
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4872
+ while (1) switch (_context37.prev = _context37.next) {
4780
4873
  case 0:
4781
4874
  if (!e.error) {
4782
- _context35.next = 2;
4875
+ _context37.next = 2;
4783
4876
  break;
4784
4877
  }
4785
4878
  throw e.error;
4786
4879
  case 2:
4787
- return _context35.abrupt("return", {
4880
+ return _context37.abrupt("return", {
4788
4881
  text: e[0].sequence || ""
4789
4882
  });
4790
4883
  case 3:
4791
4884
  case "end":
4792
- return _context35.stop();
4885
+ return _context37.stop();
4793
4886
  }
4794
- }, _callee35);
4887
+ }, _callee37);
4795
4888
  }));
4796
- function extractResultData(_x63) {
4889
+ function extractResultData(_x67) {
4797
4890
  return _extractResultData11.apply(this, arguments);
4798
4891
  }
4799
4892
  return extractResultData;
@@ -4868,13 +4961,13 @@ var CohereTextGenerationIO = /*#__PURE__*/function (_CohereIO) {
4868
4961
  }, {
4869
4962
  key: "callServiceAPI",
4870
4963
  value: function () {
4871
- var _callServiceAPI8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(e, t) {
4964
+ var _callServiceAPI8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(e, t) {
4872
4965
  var n;
4873
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4874
- while (1) switch (_context36.prev = _context36.next) {
4966
+ return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4967
+ while (1) switch (_context38.prev = _context38.next) {
4875
4968
  case 0:
4876
4969
  if (this.requestSettings) {
4877
- _context36.next = 2;
4970
+ _context38.next = 2;
4878
4971
  break;
4879
4972
  }
4880
4973
  throw new Error("Request settings have not been set up");
@@ -4883,11 +4976,11 @@ var CohereTextGenerationIO = /*#__PURE__*/function (_CohereIO) {
4883
4976
  HTTPRequest.request(this, n, e);
4884
4977
  case 4:
4885
4978
  case "end":
4886
- return _context36.stop();
4979
+ return _context38.stop();
4887
4980
  }
4888
- }, _callee36, this);
4981
+ }, _callee38, this);
4889
4982
  }));
4890
- function callServiceAPI(_x64, _x65) {
4983
+ function callServiceAPI(_x68, _x69) {
4891
4984
  return _callServiceAPI8.apply(this, arguments);
4892
4985
  }
4893
4986
  return callServiceAPI;
@@ -4895,27 +4988,27 @@ var CohereTextGenerationIO = /*#__PURE__*/function (_CohereIO) {
4895
4988
  }, {
4896
4989
  key: "extractResultData",
4897
4990
  value: function () {
4898
- var _extractResultData12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(e) {
4991
+ var _extractResultData12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(e) {
4899
4992
  var t;
4900
- return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4901
- while (1) switch (_context37.prev = _context37.next) {
4993
+ return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4994
+ while (1) switch (_context39.prev = _context39.next) {
4902
4995
  case 0:
4903
4996
  if (!e.message) {
4904
- _context37.next = 2;
4997
+ _context39.next = 2;
4905
4998
  break;
4906
4999
  }
4907
5000
  throw e.message;
4908
5001
  case 2:
4909
- return _context37.abrupt("return", {
5002
+ return _context39.abrupt("return", {
4910
5003
  text: ((t = e.generations) == null ? void 0 : t[0].text) || ""
4911
5004
  });
4912
5005
  case 3:
4913
5006
  case "end":
4914
- return _context37.stop();
5007
+ return _context39.stop();
4915
5008
  }
4916
- }, _callee37);
5009
+ }, _callee39);
4917
5010
  }));
4918
- function extractResultData(_x66) {
5011
+ function extractResultData(_x70) {
4919
5012
  return _extractResultData12.apply(this, arguments);
4920
5013
  }
4921
5014
  return extractResultData;
@@ -4945,13 +5038,13 @@ var CohereSummarizationIO = /*#__PURE__*/function (_CohereIO2) {
4945
5038
  }, {
4946
5039
  key: "callServiceAPI",
4947
5040
  value: function () {
4948
- var _callServiceAPI9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(e, t) {
5041
+ var _callServiceAPI9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(e, t) {
4949
5042
  var n;
4950
- return _regeneratorRuntime().wrap(function _callee38$(_context38) {
4951
- while (1) switch (_context38.prev = _context38.next) {
5043
+ return _regeneratorRuntime().wrap(function _callee40$(_context40) {
5044
+ while (1) switch (_context40.prev = _context40.next) {
4952
5045
  case 0:
4953
5046
  if (this.requestSettings) {
4954
- _context38.next = 2;
5047
+ _context40.next = 2;
4955
5048
  break;
4956
5049
  }
4957
5050
  throw new Error("Request settings have not been set up");
@@ -4960,11 +5053,11 @@ var CohereSummarizationIO = /*#__PURE__*/function (_CohereIO2) {
4960
5053
  HTTPRequest.request(this, n, e);
4961
5054
  case 4:
4962
5055
  case "end":
4963
- return _context38.stop();
5056
+ return _context40.stop();
4964
5057
  }
4965
- }, _callee38, this);
5058
+ }, _callee40, this);
4966
5059
  }));
4967
- function callServiceAPI(_x67, _x68) {
5060
+ function callServiceAPI(_x71, _x72) {
4968
5061
  return _callServiceAPI9.apply(this, arguments);
4969
5062
  }
4970
5063
  return callServiceAPI;
@@ -4972,26 +5065,26 @@ var CohereSummarizationIO = /*#__PURE__*/function (_CohereIO2) {
4972
5065
  }, {
4973
5066
  key: "extractResultData",
4974
5067
  value: function () {
4975
- var _extractResultData13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(e) {
4976
- return _regeneratorRuntime().wrap(function _callee39$(_context39) {
4977
- while (1) switch (_context39.prev = _context39.next) {
5068
+ var _extractResultData13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(e) {
5069
+ return _regeneratorRuntime().wrap(function _callee41$(_context41) {
5070
+ while (1) switch (_context41.prev = _context41.next) {
4978
5071
  case 0:
4979
5072
  if (!e.message) {
4980
- _context39.next = 2;
5073
+ _context41.next = 2;
4981
5074
  break;
4982
5075
  }
4983
5076
  throw e.message;
4984
5077
  case 2:
4985
- return _context39.abrupt("return", {
5078
+ return _context41.abrupt("return", {
4986
5079
  text: e.summary || ""
4987
5080
  });
4988
5081
  case 3:
4989
5082
  case "end":
4990
- return _context39.stop();
5083
+ return _context41.stop();
4991
5084
  }
4992
- }, _callee39);
5085
+ }, _callee41);
4993
5086
  }));
4994
- function extractResultData(_x69) {
5087
+ function extractResultData(_x73) {
4995
5088
  return _extractResultData13.apply(this, arguments);
4996
5089
  }
4997
5090
  return extractResultData;
@@ -5148,13 +5241,13 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5148
5241
  }, {
5149
5242
  key: "callServiceAPI",
5150
5243
  value: function () {
5151
- var _callServiceAPI10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(e, t) {
5244
+ var _callServiceAPI10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(e, t) {
5152
5245
  var n;
5153
- return _regeneratorRuntime().wrap(function _callee40$(_context40) {
5154
- while (1) switch (_context40.prev = _context40.next) {
5246
+ return _regeneratorRuntime().wrap(function _callee42$(_context42) {
5247
+ while (1) switch (_context42.prev = _context42.next) {
5155
5248
  case 0:
5156
5249
  if (this.requestSettings) {
5157
- _context40.next = 2;
5250
+ _context42.next = 2;
5158
5251
  break;
5159
5252
  }
5160
5253
  throw new Error("Request settings have not been set up");
@@ -5163,11 +5256,11 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5163
5256
  HTTPRequest.request(this, n, e), this.messages = e;
5164
5257
  case 4:
5165
5258
  case "end":
5166
- return _context40.stop();
5259
+ return _context42.stop();
5167
5260
  }
5168
- }, _callee40, this);
5261
+ }, _callee42, this);
5169
5262
  }));
5170
- function callServiceAPI(_x70, _x71) {
5263
+ function callServiceAPI(_x74, _x75) {
5171
5264
  return _callServiceAPI10.apply(this, arguments);
5172
5265
  }
5173
5266
  return callServiceAPI;
@@ -5175,13 +5268,13 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5175
5268
  }, {
5176
5269
  key: "extractResultData",
5177
5270
  value: function () {
5178
- var _extractResultData14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(e) {
5271
+ var _extractResultData14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(e) {
5179
5272
  var t, n, s;
5180
- return _regeneratorRuntime().wrap(function _callee41$(_context41) {
5181
- while (1) switch (_context41.prev = _context41.next) {
5273
+ return _regeneratorRuntime().wrap(function _callee43$(_context43) {
5274
+ while (1) switch (_context43.prev = _context43.next) {
5182
5275
  case 0:
5183
5276
  if (!e.error) {
5184
- _context41.next = 2;
5277
+ _context43.next = 2;
5185
5278
  break;
5186
5279
  }
5187
5280
  throw e.error.message;
@@ -5193,16 +5286,16 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5193
5286
  };
5194
5287
  HTTPRequest.executePollRequest(this, n, s, this.messages);
5195
5288
  }
5196
- return _context41.abrupt("return", {
5289
+ return _context43.abrupt("return", {
5197
5290
  pollingInAnotherRequest: !0
5198
5291
  });
5199
5292
  case 4:
5200
5293
  case "end":
5201
- return _context41.stop();
5294
+ return _context43.stop();
5202
5295
  }
5203
- }, _callee41, this);
5296
+ }, _callee43, this);
5204
5297
  }));
5205
- function extractResultData(_x72) {
5298
+ function extractResultData(_x76) {
5206
5299
  return _extractResultData14.apply(this, arguments);
5207
5300
  }
5208
5301
  return extractResultData;
@@ -5210,33 +5303,33 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5210
5303
  }, {
5211
5304
  key: "extractPollResultData",
5212
5305
  value: function () {
5213
- var _extractPollResultData4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(e) {
5306
+ var _extractPollResultData4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(e) {
5214
5307
  var t, _iterator, _step, n;
5215
- return _regeneratorRuntime().wrap(function _callee42$(_context42) {
5216
- while (1) switch (_context42.prev = _context42.next) {
5308
+ return _regeneratorRuntime().wrap(function _callee44$(_context44) {
5309
+ while (1) switch (_context44.prev = _context44.next) {
5217
5310
  case 0:
5218
5311
  if (!e.error) {
5219
- _context42.next = 2;
5312
+ _context44.next = 2;
5220
5313
  break;
5221
5314
  }
5222
5315
  throw e.error;
5223
5316
  case 2:
5224
5317
  if (!(e.status === "running")) {
5225
- _context42.next = 4;
5318
+ _context44.next = 4;
5226
5319
  break;
5227
5320
  }
5228
- return _context42.abrupt("return", {
5321
+ return _context44.abrupt("return", {
5229
5322
  timeoutMS: 2e3
5230
5323
  });
5231
5324
  case 4:
5232
5325
  if (!(e.errors.length > 0)) {
5233
- _context42.next = 6;
5326
+ _context44.next = 6;
5234
5327
  break;
5235
5328
  }
5236
5329
  throw e.errors[0];
5237
5330
  case 6:
5238
5331
  if (!(e.tasks.items[0].results.errors.length > 0)) {
5239
- _context42.next = 8;
5332
+ _context44.next = 8;
5240
5333
  break;
5241
5334
  }
5242
5335
  throw e.tasks.items[0].results.errors[0];
@@ -5253,16 +5346,16 @@ var AzureSummarizationIO = /*#__PURE__*/function (_AzureLanguageIO) {
5253
5346
  } finally {
5254
5347
  _iterator.f();
5255
5348
  }
5256
- return _context42.abrupt("return", {
5349
+ return _context44.abrupt("return", {
5257
5350
  text: t || ""
5258
5351
  });
5259
5352
  case 12:
5260
5353
  case "end":
5261
- return _context42.stop();
5354
+ return _context44.stop();
5262
5355
  }
5263
- }, _callee42);
5356
+ }, _callee44);
5264
5357
  }));
5265
- function extractPollResultData(_x73) {
5358
+ function extractPollResultData(_x77) {
5266
5359
  return _extractPollResultData4.apply(this, arguments);
5267
5360
  }
5268
5361
  return extractPollResultData;
@@ -5361,13 +5454,13 @@ var OpenAICompletionsIO = /*#__PURE__*/function (_DirectServiceIO5) {
5361
5454
  }, {
5362
5455
  key: "callServiceAPI",
5363
5456
  value: function () {
5364
- var _callServiceAPI11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(e, t) {
5457
+ var _callServiceAPI11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(e, t) {
5365
5458
  var n;
5366
- return _regeneratorRuntime().wrap(function _callee43$(_context43) {
5367
- while (1) switch (_context43.prev = _context43.next) {
5459
+ return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5460
+ while (1) switch (_context45.prev = _context45.next) {
5368
5461
  case 0:
5369
5462
  if (this.requestSettings) {
5370
- _context43.next = 2;
5463
+ _context45.next = 2;
5371
5464
  break;
5372
5465
  }
5373
5466
  throw new Error("Request settings have not been set up");
@@ -5376,11 +5469,11 @@ var OpenAICompletionsIO = /*#__PURE__*/function (_DirectServiceIO5) {
5376
5469
  this.deepChat.stream || n.stream ? (n.stream = !0, Stream.request(this, n, e)) : HTTPRequest.request(this, n, e);
5377
5470
  case 4:
5378
5471
  case "end":
5379
- return _context43.stop();
5472
+ return _context45.stop();
5380
5473
  }
5381
- }, _callee43, this);
5474
+ }, _callee45, this);
5382
5475
  }));
5383
- function callServiceAPI(_x74, _x75) {
5476
+ function callServiceAPI(_x78, _x79) {
5384
5477
  return _callServiceAPI11.apply(this, arguments);
5385
5478
  }
5386
5479
  return callServiceAPI;
@@ -5388,27 +5481,27 @@ var OpenAICompletionsIO = /*#__PURE__*/function (_DirectServiceIO5) {
5388
5481
  }, {
5389
5482
  key: "extractResultData",
5390
5483
  value: function () {
5391
- var _extractResultData15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(e) {
5484
+ var _extractResultData15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(e) {
5392
5485
  var t;
5393
- return _regeneratorRuntime().wrap(function _callee44$(_context44) {
5394
- while (1) switch (_context44.prev = _context44.next) {
5486
+ return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5487
+ while (1) switch (_context46.prev = _context46.next) {
5395
5488
  case 0:
5396
5489
  if (!e.error) {
5397
- _context44.next = 2;
5490
+ _context46.next = 2;
5398
5491
  break;
5399
5492
  }
5400
5493
  throw e.error.message;
5401
5494
  case 2:
5402
- return _context44.abrupt("return", {
5495
+ return _context46.abrupt("return", {
5403
5496
  text: ((t = e.choices[0]) == null ? void 0 : t.text) || ""
5404
5497
  });
5405
5498
  case 3:
5406
5499
  case "end":
5407
- return _context44.stop();
5500
+ return _context46.stop();
5408
5501
  }
5409
- }, _callee44);
5502
+ }, _callee46);
5410
5503
  }));
5411
- function extractResultData(_x76) {
5504
+ function extractResultData(_x80) {
5412
5505
  return _extractResultData15.apply(this, arguments);
5413
5506
  }
5414
5507
  return extractResultData;
@@ -5423,17 +5516,17 @@ var AssemblyAIUtils = /*#__PURE__*/function () {
5423
5516
  _createClass(AssemblyAIUtils, null, [{
5424
5517
  key: "poll",
5425
5518
  value: function () {
5426
- var _poll2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(e, t) {
5519
+ var _poll2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(e, t) {
5427
5520
  var n, l, c, d;
5428
- return _regeneratorRuntime().wrap(function _callee45$(_context45) {
5429
- while (1) switch (_context45.prev = _context45.next) {
5521
+ return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5522
+ while (1) switch (_context47.prev = _context47.next) {
5430
5523
  case 0:
5431
5524
  n = {
5432
5525
  authorization: e,
5433
5526
  "content-type": "application/json"
5434
5527
  };
5435
- _context45.t0 = "https://api.assemblyai.com/v2/transcript/";
5436
- _context45.next = 4;
5528
+ _context47.t0 = "https://api.assemblyai.com/v2/transcript/";
5529
+ _context47.next = 4;
5437
5530
  return fetch("https://api.assemblyai.com/v2/transcript", {
5438
5531
  method: "POST",
5439
5532
  body: JSON.stringify({
@@ -5442,55 +5535,55 @@ var AssemblyAIUtils = /*#__PURE__*/function () {
5442
5535
  headers: n
5443
5536
  });
5444
5537
  case 4:
5445
- _context45.next = 6;
5446
- return _context45.sent.json();
5538
+ _context47.next = 6;
5539
+ return _context47.sent.json();
5447
5540
  case 6:
5448
- _context45.t1 = _context45.sent.id;
5449
- l = _context45.t0.concat.call(_context45.t0, _context45.t1);
5541
+ _context47.t1 = _context47.sent.id;
5542
+ l = _context47.t0.concat.call(_context47.t0, _context47.t1);
5450
5543
  case 8:
5451
5544
  if (c) {
5452
- _context45.next = 24;
5545
+ _context47.next = 24;
5453
5546
  break;
5454
5547
  }
5455
- _context45.next = 11;
5548
+ _context47.next = 11;
5456
5549
  return fetch(l, {
5457
5550
  headers: n
5458
5551
  });
5459
5552
  case 11:
5460
- _context45.next = 13;
5461
- return _context45.sent.json();
5553
+ _context47.next = 13;
5554
+ return _context47.sent.json();
5462
5555
  case 13:
5463
- d = _context45.sent;
5556
+ d = _context47.sent;
5464
5557
  if (!(d.status === "completed")) {
5465
- _context45.next = 18;
5558
+ _context47.next = 18;
5466
5559
  break;
5467
5560
  }
5468
5561
  c = d;
5469
- _context45.next = 22;
5562
+ _context47.next = 22;
5470
5563
  break;
5471
5564
  case 18:
5472
5565
  if (!(d.status === "error")) {
5473
- _context45.next = 20;
5566
+ _context47.next = 20;
5474
5567
  break;
5475
5568
  }
5476
5569
  throw new Error("Transcription failed: ".concat(d.error));
5477
5570
  case 20:
5478
- _context45.next = 22;
5571
+ _context47.next = 22;
5479
5572
  return new Promise(function (h) {
5480
5573
  return setTimeout(h, 3e3);
5481
5574
  });
5482
5575
  case 22:
5483
- _context45.next = 8;
5576
+ _context47.next = 8;
5484
5577
  break;
5485
5578
  case 24:
5486
- return _context45.abrupt("return", c);
5579
+ return _context47.abrupt("return", c);
5487
5580
  case 25:
5488
5581
  case "end":
5489
- return _context45.stop();
5582
+ return _context47.stop();
5490
5583
  }
5491
- }, _callee45);
5584
+ }, _callee47);
5492
5585
  }));
5493
- function poll(_x77, _x78) {
5586
+ function poll(_x81, _x82) {
5494
5587
  return _poll2.apply(this, arguments);
5495
5588
  }
5496
5589
  return poll;
@@ -5538,19 +5631,19 @@ var AssemblyAIAudioIO = /*#__PURE__*/function (_DirectServiceIO6) {
5538
5631
  _createClass(AssemblyAIAudioIO, [{
5539
5632
  key: "callServiceAPI",
5540
5633
  value: function () {
5541
- var _callServiceAPI12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(e, t, n) {
5634
+ var _callServiceAPI12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(e, t, n) {
5542
5635
  var s;
5543
- return _regeneratorRuntime().wrap(function _callee46$(_context46) {
5544
- while (1) switch (_context46.prev = _context46.next) {
5636
+ return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5637
+ while (1) switch (_context48.prev = _context48.next) {
5545
5638
  case 0:
5546
5639
  if ((s = this.requestSettings) != null && s.headers) {
5547
- _context46.next = 2;
5640
+ _context48.next = 2;
5548
5641
  break;
5549
5642
  }
5550
5643
  throw new Error("Request settings have not been set up");
5551
5644
  case 2:
5552
5645
  if (n != null && n[0]) {
5553
- _context46.next = 4;
5646
+ _context48.next = 4;
5554
5647
  break;
5555
5648
  }
5556
5649
  throw new Error("No file was added");
@@ -5558,11 +5651,11 @@ var AssemblyAIAudioIO = /*#__PURE__*/function (_DirectServiceIO6) {
5558
5651
  HTTPRequest.request(this, n[0], e, !1);
5559
5652
  case 5:
5560
5653
  case "end":
5561
- return _context46.stop();
5654
+ return _context48.stop();
5562
5655
  }
5563
- }, _callee46, this);
5656
+ }, _callee48, this);
5564
5657
  }));
5565
- function callServiceAPI(_x79, _x80, _x81) {
5658
+ function callServiceAPI(_x83, _x84, _x85) {
5566
5659
  return _callServiceAPI12.apply(this, arguments);
5567
5660
  }
5568
5661
  return callServiceAPI;
@@ -5570,32 +5663,32 @@ var AssemblyAIAudioIO = /*#__PURE__*/function (_DirectServiceIO6) {
5570
5663
  }, {
5571
5664
  key: "extractResultData",
5572
5665
  value: function () {
5573
- var _extractResultData16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(e) {
5666
+ var _extractResultData16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(e) {
5574
5667
  var s, o, t;
5575
- return _regeneratorRuntime().wrap(function _callee47$(_context47) {
5576
- while (1) switch (_context47.prev = _context47.next) {
5668
+ return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5669
+ while (1) switch (_context49.prev = _context49.next) {
5577
5670
  case 0:
5578
5671
  if (!e.error) {
5579
- _context47.next = 2;
5672
+ _context49.next = 2;
5580
5673
  break;
5581
5674
  }
5582
5675
  throw e.error;
5583
5676
  case 2:
5584
5677
  t = (o = (s = this.requestSettings) == null ? void 0 : s.headers) == null ? void 0 : o.Authorization;
5585
- _context47.next = 5;
5678
+ _context49.next = 5;
5586
5679
  return AssemblyAIUtils.poll(t, e.upload_url);
5587
5680
  case 5:
5588
- _context47.t0 = _context47.sent.text;
5589
- return _context47.abrupt("return", {
5590
- text: _context47.t0
5681
+ _context49.t0 = _context49.sent.text;
5682
+ return _context49.abrupt("return", {
5683
+ text: _context49.t0
5591
5684
  });
5592
5685
  case 7:
5593
5686
  case "end":
5594
- return _context47.stop();
5687
+ return _context49.stop();
5595
5688
  }
5596
- }, _callee47, this);
5689
+ }, _callee49, this);
5597
5690
  }));
5598
- function extractResultData(_x82) {
5691
+ function extractResultData(_x86) {
5599
5692
  return _extractResultData16.apply(this, arguments);
5600
5693
  }
5601
5694
  return extractResultData;
@@ -5645,13 +5738,13 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
5645
5738
  }, {
5646
5739
  key: "callServiceAPI",
5647
5740
  value: function () {
5648
- var _callServiceAPI13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(e, t) {
5741
+ var _callServiceAPI13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(e, t) {
5649
5742
  var n;
5650
- return _regeneratorRuntime().wrap(function _callee48$(_context48) {
5651
- while (1) switch (_context48.prev = _context48.next) {
5743
+ return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5744
+ while (1) switch (_context50.prev = _context50.next) {
5652
5745
  case 0:
5653
5746
  if (this.requestSettings) {
5654
- _context48.next = 2;
5747
+ _context50.next = 2;
5655
5748
  break;
5656
5749
  }
5657
5750
  throw new Error("Request settings have not been set up");
@@ -5660,11 +5753,11 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
5660
5753
  HTTPRequest.request(this, n, e, !1);
5661
5754
  case 4:
5662
5755
  case "end":
5663
- return _context48.stop();
5756
+ return _context50.stop();
5664
5757
  }
5665
- }, _callee48, this);
5758
+ }, _callee50, this);
5666
5759
  }));
5667
- function callServiceAPI(_x83, _x84) {
5760
+ function callServiceAPI(_x87, _x88) {
5668
5761
  return _callServiceAPI13.apply(this, arguments);
5669
5762
  }
5670
5763
  return callServiceAPI;
@@ -5672,11 +5765,11 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
5672
5765
  }, {
5673
5766
  key: "extractResultData",
5674
5767
  value: function () {
5675
- var _extractResultData17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49(e) {
5676
- return _regeneratorRuntime().wrap(function _callee49$(_context49) {
5677
- while (1) switch (_context49.prev = _context49.next) {
5768
+ var _extractResultData17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(e) {
5769
+ return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5770
+ while (1) switch (_context51.prev = _context51.next) {
5678
5771
  case 0:
5679
- return _context49.abrupt("return", new Promise(function (t) {
5772
+ return _context51.abrupt("return", new Promise(function (t) {
5680
5773
  var n = new FileReader();
5681
5774
  n.readAsDataURL(e), n.onload = function (s) {
5682
5775
  t({
@@ -5689,11 +5782,11 @@ var _AzureTextToSpeechIO = /*#__PURE__*/function (_AzureSpeechIO) {
5689
5782
  }));
5690
5783
  case 1:
5691
5784
  case "end":
5692
- return _context49.stop();
5785
+ return _context51.stop();
5693
5786
  }
5694
- }, _callee49);
5787
+ }, _callee51);
5695
5788
  }));
5696
- function extractResultData(_x85) {
5789
+ function extractResultData(_x89) {
5697
5790
  return _extractResultData17.apply(this, arguments);
5698
5791
  }
5699
5792
  return extractResultData;
@@ -5706,11 +5799,11 @@ _AzureTextToSpeechIO.HELP_LINK =
5706
5799
  "https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest";
5707
5800
  var AzureTextToSpeechIO = _AzureTextToSpeechIO;
5708
5801
  var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
5709
- _inherits(j, _AzureSpeechIO2);
5710
- var _super28 = _createSuper(j);
5711
- function j(e) {
5802
+ _inherits(U, _AzureSpeechIO2);
5803
+ var _super28 = _createSuper(U);
5804
+ function U(e) {
5712
5805
  var _this21;
5713
- _classCallCheck(this, j);
5806
+ _classCallCheck(this, U);
5714
5807
  var a, l, c;
5715
5808
  var t = (l = (a = e.directConnection) == null ? void 0 : a.azure) == null ? void 0 : l.speechToText,
5716
5809
  n = (c = e.directConnection) == null ? void 0 : c.azure,
@@ -5721,27 +5814,27 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
5721
5814
  }
5722
5815
  }
5723
5816
  };
5724
- _this21 = _super28.call(this, e, AzureUtils.buildSpeechToTextHeaders, t.region, n, s), _this21.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(j.HELP_LINK, "\">here</a> for more info.\n </p>"), _this21.url = "", _this21.isTextInputDisabled = !0, _this21.textInputPlaceholderText = "Upload an audio file", _this21.canSendMessage = j.canFileSendMessage;
5817
+ _this21 = _super28.call(this, e, AzureUtils.buildSpeechToTextHeaders, t.region, n, s), _this21.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(U.HELP_LINK, "\">here</a> for more info.\n </p>"), _this21.url = "", _this21.isTextInputDisabled = !0, _this21.textInputPlaceholderText = "Upload an audio file", _this21.canSendMessage = U.canFileSendMessage;
5725
5818
  var o = t.lang || "en-US";
5726
5819
  _this21.url = "https://".concat(t.region, ".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(o, "&format=detailed"), _this21.recordAudio = void 0;
5727
5820
  return _this21;
5728
5821
  }
5729
- _createClass(j, [{
5822
+ _createClass(U, [{
5730
5823
  key: "callServiceAPI",
5731
5824
  value: function () {
5732
- var _callServiceAPI14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(e, t, n) {
5825
+ var _callServiceAPI14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(e, t, n) {
5733
5826
  var s, o;
5734
- return _regeneratorRuntime().wrap(function _callee50$(_context50) {
5735
- while (1) switch (_context50.prev = _context50.next) {
5827
+ return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5828
+ while (1) switch (_context52.prev = _context52.next) {
5736
5829
  case 0:
5737
5830
  if ((s = this.requestSettings) != null && s.headers) {
5738
- _context50.next = 2;
5831
+ _context52.next = 2;
5739
5832
  break;
5740
5833
  }
5741
5834
  throw new Error("Request settings have not been set up");
5742
5835
  case 2:
5743
5836
  if (n != null && n[0]) {
5744
- _context50.next = 4;
5837
+ _context52.next = 4;
5745
5838
  break;
5746
5839
  }
5747
5840
  throw new Error("No file was added");
@@ -5749,11 +5842,11 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
5749
5842
  (o = this.requestSettings) != null && o.headers && (this.requestSettings.headers["Content-Type"] = n[0].name.toLocaleLowerCase().endsWith(".wav") ? "audio/wav; codecs=audio/pcm; samplerate=16000" : "audio/ogg; codecs=opus"), HTTPRequest.request(this, n[0], e, !1);
5750
5843
  case 5:
5751
5844
  case "end":
5752
- return _context50.stop();
5845
+ return _context52.stop();
5753
5846
  }
5754
- }, _callee50, this);
5847
+ }, _callee52, this);
5755
5848
  }));
5756
- function callServiceAPI(_x86, _x87, _x88) {
5849
+ function callServiceAPI(_x90, _x91, _x92) {
5757
5850
  return _callServiceAPI14.apply(this, arguments);
5758
5851
  }
5759
5852
  return callServiceAPI;
@@ -5761,26 +5854,26 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
5761
5854
  }, {
5762
5855
  key: "extractResultData",
5763
5856
  value: function () {
5764
- var _extractResultData18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(e) {
5765
- return _regeneratorRuntime().wrap(function _callee51$(_context51) {
5766
- while (1) switch (_context51.prev = _context51.next) {
5857
+ var _extractResultData18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(e) {
5858
+ return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5859
+ while (1) switch (_context53.prev = _context53.next) {
5767
5860
  case 0:
5768
5861
  if (!e.error) {
5769
- _context51.next = 2;
5862
+ _context53.next = 2;
5770
5863
  break;
5771
5864
  }
5772
5865
  throw e.error;
5773
5866
  case 2:
5774
- return _context51.abrupt("return", {
5867
+ return _context53.abrupt("return", {
5775
5868
  text: e.DisplayText || ""
5776
5869
  });
5777
5870
  case 3:
5778
5871
  case "end":
5779
- return _context51.stop();
5872
+ return _context53.stop();
5780
5873
  }
5781
- }, _callee51);
5874
+ }, _callee53);
5782
5875
  }));
5783
- function extractResultData(_x89) {
5876
+ function extractResultData(_x93) {
5784
5877
  return _extractResultData18.apply(this, arguments);
5785
5878
  }
5786
5879
  return extractResultData;
@@ -5791,7 +5884,7 @@ var _AzureSpeechToTextIO = /*#__PURE__*/function (_AzureSpeechIO2) {
5791
5884
  return !!(t != null && t[0]);
5792
5885
  }
5793
5886
  }]);
5794
- return j;
5887
+ return U;
5795
5888
  }(AzureSpeechIO);
5796
5889
  _AzureSpeechToTextIO.HELP_LINK =
5797
5890
  // eslint-disable-next-line max-len
@@ -5823,13 +5916,13 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
5823
5916
  }, {
5824
5917
  key: "callServiceAPI",
5825
5918
  value: function () {
5826
- var _callServiceAPI15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(e, t) {
5919
+ var _callServiceAPI15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(e, t) {
5827
5920
  var n;
5828
- return _regeneratorRuntime().wrap(function _callee52$(_context52) {
5829
- while (1) switch (_context52.prev = _context52.next) {
5921
+ return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5922
+ while (1) switch (_context54.prev = _context54.next) {
5830
5923
  case 0:
5831
5924
  if (this.requestSettings) {
5832
- _context52.next = 2;
5925
+ _context54.next = 2;
5833
5926
  break;
5834
5927
  }
5835
5928
  throw new Error("Request settings have not been set up");
@@ -5838,11 +5931,11 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
5838
5931
  HTTPRequest.request(this, n, e);
5839
5932
  case 4:
5840
5933
  case "end":
5841
- return _context52.stop();
5934
+ return _context54.stop();
5842
5935
  }
5843
- }, _callee52, this);
5936
+ }, _callee54, this);
5844
5937
  }));
5845
- function callServiceAPI(_x90, _x91) {
5938
+ function callServiceAPI(_x94, _x95) {
5846
5939
  return _callServiceAPI15.apply(this, arguments);
5847
5940
  }
5848
5941
  return callServiceAPI;
@@ -5850,27 +5943,27 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
5850
5943
  }, {
5851
5944
  key: "extractResultData",
5852
5945
  value: function () {
5853
- var _extractResultData19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53(e) {
5946
+ var _extractResultData19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(e) {
5854
5947
  var t;
5855
- return _regeneratorRuntime().wrap(function _callee53$(_context53) {
5856
- while (1) switch (_context53.prev = _context53.next) {
5948
+ return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5949
+ while (1) switch (_context55.prev = _context55.next) {
5857
5950
  case 0:
5858
5951
  if (!Array.isArray(e)) {
5859
- _context53.next = 2;
5952
+ _context55.next = 2;
5860
5953
  break;
5861
5954
  }
5862
- return _context53.abrupt("return", {
5955
+ return _context55.abrupt("return", {
5863
5956
  text: ((t = e[0].translations) == null ? void 0 : t[0].text) || ""
5864
5957
  });
5865
5958
  case 2:
5866
5959
  throw e.error;
5867
5960
  case 3:
5868
5961
  case "end":
5869
- return _context53.stop();
5962
+ return _context55.stop();
5870
5963
  }
5871
- }, _callee53);
5964
+ }, _callee55);
5872
5965
  }));
5873
- function extractResultData(_x92) {
5966
+ function extractResultData(_x96) {
5874
5967
  return _extractResultData19.apply(this, arguments);
5875
5968
  }
5876
5969
  return extractResultData;
@@ -5879,11 +5972,11 @@ var AzureTranslationIO = /*#__PURE__*/function (_DirectServiceIO8) {
5879
5972
  return AzureTranslationIO;
5880
5973
  }(DirectServiceIO);
5881
5974
  var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
5882
- _inherits(C, _DirectServiceIO9);
5883
- var _super30 = _createSuper(C);
5884
- function C(e) {
5975
+ _inherits(A, _DirectServiceIO9);
5976
+ var _super30 = _createSuper(A);
5977
+ function A(e) {
5885
5978
  var _this23;
5886
- _classCallCheck(this, C);
5979
+ _classCallCheck(this, A);
5887
5980
  var l;
5888
5981
  var t = e.directConnection,
5889
5982
  n = e.textInput,
@@ -5907,10 +6000,10 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
5907
6000
  }
5908
6001
  };
5909
6002
  }
5910
- _typeof(a) == "object" && Object.assign(_this23.rawBody, a), _this23.canSendMessage = C.canFileSendMessage;
6003
+ _typeof(a) == "object" && Object.assign(_this23.rawBody, a), _this23.canSendMessage = A.canFileSendMessage;
5911
6004
  return _this23;
5912
6005
  }
5913
- _createClass(C, [{
6006
+ _createClass(A, [{
5914
6007
  key: "preprocessBody",
5915
6008
  value: function preprocessBody(e, t) {
5916
6009
  var n = JSON.parse(JSON.stringify(e));
@@ -5928,50 +6021,50 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
5928
6021
  var s;
5929
6022
  var o = (l = (a = t[t.length - 1]) == null ? void 0 : a.text) == null ? void 0 : l.trim();
5930
6023
  if (n[1] || o && o !== "") {
5931
- this.url = C.IMAGE_EDIT_URL;
6024
+ this.url = A.IMAGE_EDIT_URL;
5932
6025
  var c = this.preprocessBody(this.rawBody, o);
5933
- s = C.createFormDataBody(c, n[0], n[1]);
5934
- } else this.url = C.IMAGE_VARIATIONS_URL, s = C.createFormDataBody(this.rawBody, n[0]);
6026
+ s = A.createFormDataBody(c, n[0], n[1]);
6027
+ } else this.url = A.IMAGE_VARIATIONS_URL, s = A.createFormDataBody(this.rawBody, n[0]);
5935
6028
  RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, s, e), !1);
5936
6029
  }
5937
6030
  }, {
5938
6031
  key: "callServiceAPI",
5939
6032
  value: function () {
5940
- var _callServiceAPI16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(e, t, n) {
6033
+ var _callServiceAPI16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(e, t, n) {
5941
6034
  var s, o;
5942
- return _regeneratorRuntime().wrap(function _callee54$(_context54) {
5943
- while (1) switch (_context54.prev = _context54.next) {
6035
+ return _regeneratorRuntime().wrap(function _callee56$(_context56) {
6036
+ while (1) switch (_context56.prev = _context56.next) {
5944
6037
  case 0:
5945
6038
  if ((s = this.requestSettings) != null && s.headers) {
5946
- _context54.next = 2;
6039
+ _context56.next = 2;
5947
6040
  break;
5948
6041
  }
5949
6042
  throw new Error("Request settings have not been set up");
5950
6043
  case 2:
5951
6044
  if (!(n != null && n[0])) {
5952
- _context54.next = 6;
6045
+ _context56.next = 6;
5953
6046
  break;
5954
6047
  }
5955
6048
  this.callApiWithImage(e, t, n);
5956
- _context54.next = 11;
6049
+ _context56.next = 11;
5957
6050
  break;
5958
6051
  case 6:
5959
6052
  if (this.requestSettings) {
5960
- _context54.next = 8;
6053
+ _context56.next = 8;
5961
6054
  break;
5962
6055
  }
5963
6056
  throw new Error("Request settings have not been set up");
5964
6057
  case 8:
5965
- this.url = C.IMAGE_GENERATION_URL;
6058
+ this.url = A.IMAGE_GENERATION_URL;
5966
6059
  o = this.preprocessBody(this.rawBody, t[t.length - 1].text);
5967
6060
  HTTPRequest.request(this, o, e);
5968
6061
  case 11:
5969
6062
  case "end":
5970
- return _context54.stop();
6063
+ return _context56.stop();
5971
6064
  }
5972
- }, _callee54, this);
6065
+ }, _callee56, this);
5973
6066
  }));
5974
- function callServiceAPI(_x93, _x94, _x95) {
6067
+ function callServiceAPI(_x97, _x98, _x99) {
5975
6068
  return _callServiceAPI16.apply(this, arguments);
5976
6069
  }
5977
6070
  return callServiceAPI;
@@ -5979,17 +6072,17 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
5979
6072
  }, {
5980
6073
  key: "extractResultData",
5981
6074
  value: function () {
5982
- var _extractResultData20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(e) {
5983
- return _regeneratorRuntime().wrap(function _callee55$(_context55) {
5984
- while (1) switch (_context55.prev = _context55.next) {
6075
+ var _extractResultData20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(e) {
6076
+ return _regeneratorRuntime().wrap(function _callee57$(_context57) {
6077
+ while (1) switch (_context57.prev = _context57.next) {
5985
6078
  case 0:
5986
6079
  if (!e.error) {
5987
- _context55.next = 2;
6080
+ _context57.next = 2;
5988
6081
  break;
5989
6082
  }
5990
6083
  throw e.error.message;
5991
6084
  case 2:
5992
- return _context55.abrupt("return", {
6085
+ return _context57.abrupt("return", {
5993
6086
  files: e.data.map(function (n) {
5994
6087
  return n.url ? {
5995
6088
  src: n.url,
@@ -6002,11 +6095,11 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
6002
6095
  });
6003
6096
  case 3:
6004
6097
  case "end":
6005
- return _context55.stop();
6098
+ return _context57.stop();
6006
6099
  }
6007
- }, _callee55);
6100
+ }, _callee57);
6008
6101
  }));
6009
- function extractResultData(_x96) {
6102
+ function extractResultData(_x100) {
6010
6103
  return _extractResultData20.apply(this, arguments);
6011
6104
  }
6012
6105
  return extractResultData;
@@ -6033,34 +6126,34 @@ var _OpenAIImagesIO = /*#__PURE__*/function (_DirectServiceIO9) {
6033
6126
  }), s;
6034
6127
  }
6035
6128
  }]);
6036
- return C;
6129
+ return A;
6037
6130
  }(DirectServiceIO);
6038
6131
  _OpenAIImagesIO.IMAGE_GENERATION_URL = "https://api.openai.com/v1/images/generations";
6039
6132
  _OpenAIImagesIO.IMAGE_VARIATIONS_URL = "https://api.openai.com/v1/images/variations";
6040
6133
  _OpenAIImagesIO.IMAGE_EDIT_URL = "https://api.openai.com/v1/images/edits";
6041
6134
  var OpenAIImagesIO = _OpenAIImagesIO;
6042
6135
  var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
6043
- _inherits(k, _DirectServiceIO10);
6044
- var _super31 = _createSuper(k);
6045
- function k(e) {
6136
+ _inherits(M, _DirectServiceIO10);
6137
+ var _super31 = _createSuper(M);
6138
+ function M(e) {
6046
6139
  var _l$model2;
6047
6140
  var _this24;
6048
- _classCallCheck(this, k);
6141
+ _classCallCheck(this, M);
6049
6142
  var a, l;
6050
6143
  var t = e.directConnection,
6051
6144
  n = e.textInput,
6052
6145
  s = t == null ? void 0 : t.openAI;
6053
6146
  _this24 = _super31.call(this, e, OpenAIUtils.buildKeyVerificationDetails(), OpenAIUtils.buildHeaders, s, {
6054
6147
  audio: {}
6055
- }), _this24.insertKeyPlaceholderText = "OpenAI API Key", _this24.getKeyLink = "https://platform.openai.com/account/api-keys", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI Whisper</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/api-reference/audio/create\">here</a> for more info.</p>", _this24.url = "", _this24.permittedErrorPrefixes = ["Invalid"], _this24._maxCharLength = OpenAIUtils.FILE_MAX_CHAR_LENGTH, _this24._service_url = k.AUDIO_TRANSCRIPTIONS_URL, n != null && n.characterLimit && (_this24._maxCharLength = n.characterLimit);
6148
+ }), _this24.insertKeyPlaceholderText = "OpenAI API Key", _this24.getKeyLink = "https://platform.openai.com/account/api-keys", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI Whisper</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/api-reference/audio/create\">here</a> for more info.</p>", _this24.url = "", _this24.permittedErrorPrefixes = ["Invalid"], _this24._maxCharLength = OpenAIUtils.FILE_MAX_CHAR_LENGTH, _this24._service_url = M.AUDIO_TRANSCRIPTIONS_URL, n != null && n.characterLimit && (_this24._maxCharLength = n.characterLimit);
6056
6149
  var o = (a = t == null ? void 0 : t.openAI) == null ? void 0 : a.audio;
6057
- _typeof(o) == "object" && (_this24.processConfig(o), k.cleanConfig(o), Object.assign(_this24.rawBody, o)), (_l$model2 = (l = _this24.rawBody).model) !== null && _l$model2 !== void 0 ? _l$model2 : l.model = k.DEFAULT_MODEL, _this24.rawBody.response_format = "json", _this24.canSendMessage = k.canSendFileMessage;
6150
+ _typeof(o) == "object" && (_this24.processConfig(o), M.cleanConfig(o), Object.assign(_this24.rawBody, o)), (_l$model2 = (l = _this24.rawBody).model) !== null && _l$model2 !== void 0 ? _l$model2 : l.model = M.DEFAULT_MODEL, _this24.rawBody.response_format = "json", _this24.canSendMessage = M.canSendFileMessage;
6058
6151
  return _this24;
6059
6152
  }
6060
- _createClass(k, [{
6153
+ _createClass(M, [{
6061
6154
  key: "processConfig",
6062
6155
  value: function processConfig(e) {
6063
- e != null && e.type && e.type === "translation" && (this._service_url = k.AUDIO_TRANSLATIONS_URL, delete e.language);
6156
+ e != null && e.type && e.type === "translation" && (this._service_url = M.AUDIO_TRANSLATIONS_URL, delete e.language);
6064
6157
  }
6065
6158
  }, {
6066
6159
  key: "preprocessBody",
@@ -6078,33 +6171,33 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
6078
6171
  }, {
6079
6172
  key: "callServiceAPI",
6080
6173
  value: function () {
6081
- var _callServiceAPI17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(e, t, n) {
6174
+ var _callServiceAPI17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(e, t, n) {
6082
6175
  var a, s, o;
6083
- return _regeneratorRuntime().wrap(function _callee56$(_context56) {
6084
- while (1) switch (_context56.prev = _context56.next) {
6176
+ return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6177
+ while (1) switch (_context58.prev = _context58.next) {
6085
6178
  case 0:
6086
6179
  if ((a = this.requestSettings) != null && a.headers) {
6087
- _context56.next = 2;
6180
+ _context58.next = 2;
6088
6181
  break;
6089
6182
  }
6090
6183
  throw new Error("Request settings have not been set up");
6091
6184
  case 2:
6092
6185
  if (n != null && n[0]) {
6093
- _context56.next = 4;
6186
+ _context58.next = 4;
6094
6187
  break;
6095
6188
  }
6096
6189
  throw new Error("No file was added");
6097
6190
  case 4:
6098
6191
  this.url = this.requestSettings.url || this._service_url;
6099
- s = this.preprocessBody(this.rawBody, t, n), o = k.createFormDataBody(s, n[0]);
6192
+ s = this.preprocessBody(this.rawBody, t, n), o = M.createFormDataBody(s, n[0]);
6100
6193
  RequestUtils.temporarilyRemoveHeader(this.requestSettings, HTTPRequest.request.bind(this, this, o, e), !1);
6101
6194
  case 7:
6102
6195
  case "end":
6103
- return _context56.stop();
6196
+ return _context58.stop();
6104
6197
  }
6105
- }, _callee56, this);
6198
+ }, _callee58, this);
6106
6199
  }));
6107
- function callServiceAPI(_x97, _x98, _x99) {
6200
+ function callServiceAPI(_x101, _x102, _x103) {
6108
6201
  return _callServiceAPI17.apply(this, arguments);
6109
6202
  }
6110
6203
  return callServiceAPI;
@@ -6112,26 +6205,26 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
6112
6205
  }, {
6113
6206
  key: "extractResultData",
6114
6207
  value: function () {
6115
- var _extractResultData21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(e) {
6116
- return _regeneratorRuntime().wrap(function _callee57$(_context57) {
6117
- while (1) switch (_context57.prev = _context57.next) {
6208
+ var _extractResultData21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(e) {
6209
+ return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6210
+ while (1) switch (_context59.prev = _context59.next) {
6118
6211
  case 0:
6119
6212
  if (!e.error) {
6120
- _context57.next = 2;
6213
+ _context59.next = 2;
6121
6214
  break;
6122
6215
  }
6123
6216
  throw e.error.message;
6124
6217
  case 2:
6125
- return _context57.abrupt("return", {
6218
+ return _context59.abrupt("return", {
6126
6219
  text: e.text
6127
6220
  });
6128
6221
  case 3:
6129
6222
  case "end":
6130
- return _context57.stop();
6223
+ return _context59.stop();
6131
6224
  }
6132
- }, _callee57);
6225
+ }, _callee59);
6133
6226
  }));
6134
- function extractResultData(_x100) {
6227
+ function extractResultData(_x104) {
6135
6228
  return _extractResultData21.apply(this, arguments);
6136
6229
  }
6137
6230
  return extractResultData;
@@ -6155,7 +6248,7 @@ var _OpenAIAudioIO = /*#__PURE__*/function (_DirectServiceIO10) {
6155
6248
  }), n;
6156
6249
  }
6157
6250
  }]);
6158
- return k;
6251
+ return M;
6159
6252
  }(DirectServiceIO);
6160
6253
  _OpenAIAudioIO.AUDIO_TRANSCRIPTIONS_URL = "https://api.openai.com/v1/audio/transcriptions";
6161
6254
  _OpenAIAudioIO.AUDIO_TRANSLATIONS_URL = "https://api.openai.com/v1/audio/translations";
@@ -6197,13 +6290,13 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
6197
6290
  }, {
6198
6291
  key: "callServiceAPI",
6199
6292
  value: function () {
6200
- var _callServiceAPI18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(e, t) {
6293
+ var _callServiceAPI18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(e, t) {
6201
6294
  var n;
6202
- return _regeneratorRuntime().wrap(function _callee58$(_context58) {
6203
- while (1) switch (_context58.prev = _context58.next) {
6295
+ return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6296
+ while (1) switch (_context60.prev = _context60.next) {
6204
6297
  case 0:
6205
6298
  if (this.requestSettings) {
6206
- _context58.next = 2;
6299
+ _context60.next = 2;
6207
6300
  break;
6208
6301
  }
6209
6302
  throw new Error("Request settings have not been set up");
@@ -6212,11 +6305,11 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
6212
6305
  this.deepChat.stream || n.stream ? (n.stream = !0, Stream.request(this, n, e)) : HTTPRequest.request(this, n, e);
6213
6306
  case 4:
6214
6307
  case "end":
6215
- return _context58.stop();
6308
+ return _context60.stop();
6216
6309
  }
6217
- }, _callee58, this);
6310
+ }, _callee60, this);
6218
6311
  }));
6219
- function callServiceAPI(_x101, _x102) {
6312
+ function callServiceAPI(_x105, _x106) {
6220
6313
  return _callServiceAPI18.apply(this, arguments);
6221
6314
  }
6222
6315
  return callServiceAPI;
@@ -6224,17 +6317,17 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
6224
6317
  }, {
6225
6318
  key: "extractResultData",
6226
6319
  value: function () {
6227
- var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(e) {
6228
- return _regeneratorRuntime().wrap(function _callee59$(_context59) {
6229
- while (1) switch (_context59.prev = _context59.next) {
6320
+ var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(e) {
6321
+ return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6322
+ while (1) switch (_context61.prev = _context61.next) {
6230
6323
  case 0:
6231
6324
  if (!e.error) {
6232
- _context59.next = 2;
6325
+ _context61.next = 2;
6233
6326
  break;
6234
6327
  }
6235
6328
  throw e.error.message;
6236
6329
  case 2:
6237
- return _context59.abrupt("return", e.choices[0].delta ? {
6330
+ return _context61.abrupt("return", e.choices[0].delta ? {
6238
6331
  text: e.choices[0].delta.content || ""
6239
6332
  } : e.choices[0].message ? {
6240
6333
  text: e.choices[0].message.content
@@ -6243,11 +6336,11 @@ var OpenAIChatIO = /*#__PURE__*/function (_DirectServiceIO11) {
6243
6336
  });
6244
6337
  case 3:
6245
6338
  case "end":
6246
- return _context59.stop();
6339
+ return _context61.stop();
6247
6340
  }
6248
- }, _callee59);
6341
+ }, _callee61);
6249
6342
  }));
6250
- function extractResultData(_x103) {
6343
+ function extractResultData(_x107) {
6251
6344
  return _extractResultData22.apply(this, arguments);
6252
6345
  }
6253
6346
  return extractResultData;
@@ -6295,13 +6388,13 @@ var CohereChatIO = /*#__PURE__*/function (_CohereIO3) {
6295
6388
  }, {
6296
6389
  key: "callServiceAPI",
6297
6390
  value: function () {
6298
- var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(e, t) {
6391
+ var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(e, t) {
6299
6392
  var n;
6300
- return _regeneratorRuntime().wrap(function _callee60$(_context60) {
6301
- while (1) switch (_context60.prev = _context60.next) {
6393
+ return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6394
+ while (1) switch (_context62.prev = _context62.next) {
6302
6395
  case 0:
6303
6396
  if (this.requestSettings) {
6304
- _context60.next = 2;
6397
+ _context62.next = 2;
6305
6398
  break;
6306
6399
  }
6307
6400
  throw new Error("Request settings have not been set up");
@@ -6310,11 +6403,11 @@ var CohereChatIO = /*#__PURE__*/function (_CohereIO3) {
6310
6403
  HTTPRequest.request(this, n, e);
6311
6404
  case 4:
6312
6405
  case "end":
6313
- return _context60.stop();
6406
+ return _context62.stop();
6314
6407
  }
6315
- }, _callee60, this);
6408
+ }, _callee62, this);
6316
6409
  }));
6317
- function callServiceAPI(_x104, _x105) {
6410
+ function callServiceAPI(_x108, _x109) {
6318
6411
  return _callServiceAPI19.apply(this, arguments);
6319
6412
  }
6320
6413
  return callServiceAPI;
@@ -6322,26 +6415,26 @@ var CohereChatIO = /*#__PURE__*/function (_CohereIO3) {
6322
6415
  }, {
6323
6416
  key: "extractResultData",
6324
6417
  value: function () {
6325
- var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(e) {
6326
- return _regeneratorRuntime().wrap(function _callee61$(_context61) {
6327
- while (1) switch (_context61.prev = _context61.next) {
6418
+ var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(e) {
6419
+ return _regeneratorRuntime().wrap(function _callee63$(_context63) {
6420
+ while (1) switch (_context63.prev = _context63.next) {
6328
6421
  case 0:
6329
6422
  if (!e.message) {
6330
- _context61.next = 2;
6423
+ _context63.next = 2;
6331
6424
  break;
6332
6425
  }
6333
6426
  throw e.message;
6334
6427
  case 2:
6335
- return _context61.abrupt("return", {
6428
+ return _context63.abrupt("return", {
6336
6429
  text: e.text
6337
6430
  });
6338
6431
  case 3:
6339
6432
  case "end":
6340
- return _context61.stop();
6433
+ return _context63.stop();
6341
6434
  }
6342
- }, _callee61);
6435
+ }, _callee63);
6343
6436
  }));
6344
- function extractResultData(_x106) {
6437
+ function extractResultData(_x110) {
6345
6438
  return _extractResultData23.apply(this, arguments);
6346
6439
  }
6347
6440
  return extractResultData;
@@ -6443,6 +6536,11 @@ var FireEvents = /*#__PURE__*/function () {
6443
6536
  detail: s
6444
6537
  }));
6445
6538
  }
6539
+ }, {
6540
+ key: "onClearMessages",
6541
+ value: function onClearMessages(e) {
6542
+ e.onClearMessages(), e.dispatchEvent(new CustomEvent("clear-messages"));
6543
+ }
6446
6544
  }, {
6447
6545
  key: "onRender",
6448
6546
  value: function onRender(e) {
@@ -6613,6 +6711,11 @@ var IntroPanel = /*#__PURE__*/function () {
6613
6711
  value: function hide() {
6614
6712
  this._isDisplayed && this._elementRef && (this._elementRef.style.display = "none", this._isDisplayed = !1);
6615
6713
  }
6714
+ }, {
6715
+ key: "display",
6716
+ value: function display() {
6717
+ !this._isDisplayed && this._elementRef && (this._elementRef.style.display = "", this._isDisplayed = !0);
6718
+ }
6616
6719
  }], [{
6617
6720
  key: "createIntroPanel",
6618
6721
  value: function createIntroPanel(e) {
@@ -6684,27 +6787,29 @@ var FileMessages = /*#__PURE__*/function () {
6684
6787
  var n = new Image();
6685
6788
  return n.src = e.src, FileMessageUtils.scrollDownOnImageLoad(n.src, t), FileMessageUtils.processContent(n, n.src);
6686
6789
  }
6790
+ // WORK - should base64 images be clickable?
6791
+ // WORK - image still does not scroll down when loaded
6687
6792
  }, {
6688
6793
  key: "addNewImageMessage",
6689
6794
  value: function () {
6690
- var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(e, t, n) {
6795
+ var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(e, t, n) {
6691
6796
  var s,
6692
6797
  o,
6693
6798
  a,
6694
- _args62 = arguments;
6695
- return _regeneratorRuntime().wrap(function _callee62$(_context62) {
6696
- while (1) switch (_context62.prev = _context62.next) {
6799
+ _args64 = arguments;
6800
+ return _regeneratorRuntime().wrap(function _callee64$(_context64) {
6801
+ while (1) switch (_context64.prev = _context64.next) {
6697
6802
  case 0:
6698
- s = _args62.length > 3 && _args62[3] !== undefined ? _args62[3] : !1;
6803
+ s = _args64.length > 3 && _args64[3] !== undefined ? _args64[3] : !1;
6699
6804
  o = FileMessages.createImage(t, e.elementRef), a = e.createNewMessageElement("", n);
6700
6805
  a.bubbleElement.appendChild(o), a.bubbleElement.classList.add("image-message"), e.elementRef.appendChild(a.outerContainer), FileMessageUtils.updateMessages(e, a, t, "image", n, s);
6701
6806
  case 3:
6702
6807
  case "end":
6703
- return _context62.stop();
6808
+ return _context64.stop();
6704
6809
  }
6705
- }, _callee62);
6810
+ }, _callee64);
6706
6811
  }));
6707
- function addNewImageMessage(_x107, _x108, _x109) {
6812
+ function addNewImageMessage(_x111, _x112, _x113) {
6708
6813
  return _addNewImageMessage.apply(this, arguments);
6709
6814
  }
6710
6815
  return addNewImageMessage;
@@ -6842,9 +6947,9 @@ var Messages = /*#__PURE__*/function () {
6842
6947
  var s = t.permittedErrorPrefixes,
6843
6948
  o = t.introPanelMarkUp,
6844
6949
  a = t.demo;
6845
- this._remarkable = RemarkableConfig.createNew(), this.elementRef = Messages.createContainerElement(), this.messageStyles = e.messageStyles, this._avatars = e.avatars, this._names = e.names, this._errorMessageOverrides = (l = e.errorMessages) == null ? void 0 : l.overrides, this._onNewMessage = FireEvents.onNewMessage.bind(this, e), this._displayLoadingMessage = Messages.getDisplayLoadingMessage(e, t), this._permittedErrorPrefixes = s, this.populateIntroPanel(n, o, e.introPanelStyle), e.introMessage && this.addIntroductoryMessage(e.introMessage), e.initialMessages && this.populateInitialMessages(e.initialMessages), this.displayServiceErrorMessages = (c = e.errorMessages) == null ? void 0 : c.displayServiceErrorMessages, e.getMessages = function () {
6950
+ this._remarkable = RemarkableConfig.createNew(), this.elementRef = Messages.createContainerElement(), this.messageStyles = e.messageStyles, this._avatars = e.avatars, this._names = e.names, this._errorMessageOverrides = (l = e.errorMessages) == null ? void 0 : l.overrides, this._onNewMessage = FireEvents.onNewMessage.bind(this, e), this._onClearMessages = FireEvents.onClearMessages.bind(this, e), this._displayLoadingMessage = Messages.getDisplayLoadingMessage(e, t), this._permittedErrorPrefixes = s, this.populateIntroPanel(n, o, e.introPanelStyle), e.introMessage && this.addIntroductoryMessage(e.introMessage), e.initialMessages && this.populateInitialMessages(e.initialMessages), this.displayServiceErrorMessages = (c = e.errorMessages) == null ? void 0 : c.displayServiceErrorMessages, e.getMessages = function () {
6846
6951
  return JSON.parse(JSON.stringify(_this28.messages));
6847
- }, e.refreshMessages = this.refreshTextMessages.bind(this), a && this.prepareDemo(a), e.textToSpeech && TextToSpeech.processConfig(e.textToSpeech, function (u) {
6952
+ }, e.clearMessages = this.clearMessages.bind(this), e.refreshMessages = this.refreshTextMessages.bind(this), a && this.prepareDemo(a), e.textToSpeech && TextToSpeech.processConfig(e.textToSpeech, function (u) {
6848
6953
  _this28._textToSpeech = u;
6849
6954
  });
6850
6955
  }
@@ -6856,9 +6961,11 @@ var Messages = /*#__PURE__*/function () {
6856
6961
  }, {
6857
6962
  key: "addIntroductoryMessage",
6858
6963
  value: function addIntroductoryMessage(e) {
6859
- var n;
6860
- var t = this.createAndAppendNewMessageElement(e, !0);
6861
- this.applyCustomStyles(t, !0, !1, (n = this.messageStyles) == null ? void 0 : n.intro);
6964
+ var t;
6965
+ if (e && (this._introMessage = e), this._introMessage) {
6966
+ var n = this.createAndAppendNewMessageElement(this._introMessage, !0);
6967
+ this.applyCustomStyles(n, !0, !1, (t = this.messageStyles) == null ? void 0 : t.intro);
6968
+ }
6862
6969
  }
6863
6970
  }, {
6864
6971
  key: "populateInitialMessages",
@@ -6979,6 +7086,11 @@ var Messages = /*#__PURE__*/function () {
6979
7086
  var e, t, n, s, o;
6980
7087
  return (o = (s = (n = (t = (e = this.elementRef.children[this.elementRef.children.length - 1]) == null ? void 0 : e.children) == null ? void 0 : t[0]) == null ? void 0 : n.children) == null ? void 0 : s[0]) == null ? void 0 : o.classList.contains("error-message-text");
6981
7088
  }
7089
+ }, {
7090
+ key: "removeError",
7091
+ value: function removeError() {
7092
+ this.isLastMessageError() && this.elementRef.children[this.elementRef.children.length - 1].remove();
7093
+ }
6982
7094
  }, {
6983
7095
  key: "addLoadingMessage",
6984
7096
  value: function addLoadingMessage() {
@@ -7022,12 +7134,12 @@ var Messages = /*#__PURE__*/function () {
7022
7134
  }, {
7023
7135
  key: "addMultipleFiles",
7024
7136
  value: function () {
7025
- var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(e) {
7137
+ var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(e) {
7026
7138
  var _this31 = this;
7027
- return _regeneratorRuntime().wrap(function _callee63$(_context63) {
7028
- while (1) switch (_context63.prev = _context63.next) {
7139
+ return _regeneratorRuntime().wrap(function _callee65$(_context65) {
7140
+ while (1) switch (_context65.prev = _context65.next) {
7029
7141
  case 0:
7030
- return _context63.abrupt("return", Promise.all((e || []).map(function (t) {
7142
+ return _context65.abrupt("return", Promise.all((e || []).map(function (t) {
7031
7143
  return new Promise(function (n) {
7032
7144
  if (!t.type || t.type === "any") {
7033
7145
  var s = t.file.name || FileMessageUtils.DEFAULT_FILE_NAME;
@@ -7052,26 +7164,25 @@ var Messages = /*#__PURE__*/function () {
7052
7164
  })));
7053
7165
  case 1:
7054
7166
  case "end":
7055
- return _context63.stop();
7167
+ return _context65.stop();
7056
7168
  }
7057
- }, _callee63);
7169
+ }, _callee65);
7058
7170
  }));
7059
- function addMultipleFiles(_x110) {
7171
+ function addMultipleFiles(_x114) {
7060
7172
  return _addMultipleFiles.apply(this, arguments);
7061
7173
  }
7062
7174
  return addMultipleFiles;
7063
- }() // private clearMessages() {
7064
- // const retainedElements: MessageElements[] = [];
7065
- // this._messageElementRefs.forEach((message) => {
7066
- // const bubbleClasslist = message.bubbleElement.classList;
7067
- // if (bubbleClasslist.contains('loading-message-text') || bubbleClasslist.contains('streamed-message')) {
7068
- // retainedElements.push(message);
7069
- // } else {
7070
- // message.outerContainer.remove();
7071
- // }
7072
- // });
7073
- // this._messageElementRefs = retainedElements;
7074
- // }
7175
+ }()
7176
+ }, {
7177
+ key: "clearMessages",
7178
+ value: function clearMessages(e) {
7179
+ var n, s;
7180
+ var t = [];
7181
+ this._messageElementRefs.forEach(function (o) {
7182
+ var a = o.bubbleElement.classList;
7183
+ a.contains("loading-message-text") || a.contains("streamed-message") ? t.push(o) : o.outerContainer.remove();
7184
+ }), this._messageElementRefs = t, e !== !1 && ((n = this._introPanel) != null && n._elementRef && this._introPanel.display(), this.addIntroductoryMessage()), (s = this._onClearMessages) == null || s.call(this);
7185
+ }
7075
7186
  // this is mostly used for enabling highlight.js to highlight code if it is downloads later
7076
7187
  }, {
7077
7188
  key: "refreshTextMessages",
@@ -7803,18 +7914,18 @@ var FileAttachmentsType = /*#__PURE__*/function () {
7803
7914
  var PLAY_ICON_STRING = "<?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>",
7804
7915
  STOP_ICON_STRING = "<?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>",
7805
7916
  _AudioFileAttachmentType = /*#__PURE__*/function (_FileAttachmentsType) {
7806
- _inherits(M, _FileAttachmentsType);
7807
- var _super35 = _createSuper(M);
7808
- function M(e, t, n) {
7809
- _classCallCheck(this, M);
7917
+ _inherits(k, _FileAttachmentsType);
7918
+ var _super35 = _createSuper(k);
7919
+ function k(e, t, n) {
7920
+ _classCallCheck(this, k);
7810
7921
  return _super35.call(this, e, t, n);
7811
7922
  }
7812
- _createClass(M, [{
7923
+ _createClass(k, [{
7813
7924
  key: "createTimer",
7814
7925
  value: function createTimer(e, t) {
7815
7926
  var _this37 = this;
7816
7927
  var n = 0;
7817
- var s = t !== void 0 && t < M.TIMER_LIMIT_S ? t : M.TIMER_LIMIT_S;
7928
+ var s = t !== void 0 && t < k.TIMER_LIMIT_S ? t : k.TIMER_LIMIT_S;
7818
7929
  return setInterval(function () {
7819
7930
  var l;
7820
7931
  n += 1, n === s && ((l = _this37.stopPlaceholderCallback) == null || l.call(_this37), _this37.clearTimer()), n === 600 && e.classList.add("audio-placeholder-text-4-digits");
@@ -7826,7 +7937,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
7826
7937
  }, {
7827
7938
  key: "createPlaceholderAudioAttachment",
7828
7939
  value: function createPlaceholderAudioAttachment(e) {
7829
- var t = M.createAudioContainer(),
7940
+ var t = k.createAudioContainer(),
7830
7941
  n = document.createElement("div");
7831
7942
  n.classList.add("audio-placeholder-text-3-digits");
7832
7943
  var s = document.createElement("div");
@@ -7863,7 +7974,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
7863
7974
  key: "completePlaceholderAttachment",
7864
7975
  value: function completePlaceholderAttachment(e, t) {
7865
7976
  var n = this._activePlaceholderAttachment;
7866
- n && (n.file = e, M.addAudioElements(n.attachmentContainerElement.children[0], t), n.removeButton = this.createRemoveAttachmentButton(n), n.attachmentContainerElement.appendChild(n.removeButton), this._activePlaceholderAttachment = void 0, this.clearTimer());
7977
+ n && (n.file = e, k.addAudioElements(n.attachmentContainerElement.children[0], t), n.removeButton = this.createRemoveAttachmentButton(n), n.attachmentContainerElement.appendChild(n.removeButton), this._activePlaceholderAttachment = void 0, this.clearTimer());
7867
7978
  }
7868
7979
  }, {
7869
7980
  key: "removePlaceholderAttachment",
@@ -7903,8 +8014,8 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
7903
8014
  }, {
7904
8015
  key: "createAudioAttachment",
7905
8016
  value: function createAudioAttachment(e) {
7906
- var t = M.createAudioContainer();
7907
- return M.addAudioElements(t, e), t;
8017
+ var t = k.createAudioContainer();
8018
+ return k.addAudioElements(t, e), t;
7908
8019
  }
7909
8020
  }, {
7910
8021
  key: "stopAttachmentPlayback",
@@ -7913,7 +8024,7 @@ var PLAY_ICON_STRING = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox
7913
8024
  (s = (n = (t = e.children[0]) == null ? void 0 : t.children) == null ? void 0 : n[0]) != null && s.classList.contains("stop-icon") && e.children[0].click();
7914
8025
  }
7915
8026
  }]);
7916
- return M;
8027
+ return k;
7917
8028
  }(FileAttachmentsType);
7918
8029
  _AudioFileAttachmentType.TIMER_LIMIT_S = 5999;
7919
8030
  var AudioFileAttachmentType = _AudioFileAttachmentType;
@@ -7967,33 +8078,33 @@ var FileAttachments = /*#__PURE__*/function () {
7967
8078
  }, {
7968
8079
  key: "completePlaceholders",
7969
8080
  value: function () {
7970
- var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65() {
7971
- return _regeneratorRuntime().wrap(function _callee65$(_context65) {
7972
- while (1) switch (_context65.prev = _context65.next) {
8081
+ var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67() {
8082
+ return _regeneratorRuntime().wrap(function _callee67$(_context67) {
8083
+ while (1) switch (_context67.prev = _context67.next) {
7973
8084
  case 0:
7974
- _context65.next = 2;
8085
+ _context67.next = 2;
7975
8086
  return Promise.all(this._fileAttachmentsTypes.map( /*#__PURE__*/function () {
7976
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(e) {
8087
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(e) {
7977
8088
  var t;
7978
- return _regeneratorRuntime().wrap(function _callee64$(_context64) {
7979
- while (1) switch (_context64.prev = _context64.next) {
8089
+ return _regeneratorRuntime().wrap(function _callee66$(_context66) {
8090
+ while (1) switch (_context66.prev = _context66.next) {
7980
8091
  case 0:
7981
- return _context64.abrupt("return", (t = e.stopPlaceholderCallback) == null ? void 0 : t.call(e));
8092
+ return _context66.abrupt("return", (t = e.stopPlaceholderCallback) == null ? void 0 : t.call(e));
7982
8093
  case 1:
7983
8094
  case "end":
7984
- return _context64.stop();
8095
+ return _context66.stop();
7985
8096
  }
7986
- }, _callee64);
8097
+ }, _callee66);
7987
8098
  }));
7988
- return function (_x111) {
7989
- return _ref5.apply(this, arguments);
8099
+ return function (_x115) {
8100
+ return _ref6.apply(this, arguments);
7990
8101
  };
7991
8102
  }()));
7992
8103
  case 2:
7993
8104
  case "end":
7994
- return _context65.stop();
8105
+ return _context67.stop();
7995
8106
  }
7996
- }, _callee65, this);
8107
+ }, _callee67, this);
7997
8108
  }));
7998
8109
  function completePlaceholders() {
7999
8110
  return _completePlaceholders.apply(this, arguments);
@@ -9213,26 +9324,26 @@ var AzureSpeechConfig = /*#__PURE__*/function () {
9213
9324
  }, {
9214
9325
  key: "getNewSpeechConfig",
9215
9326
  value: function () {
9216
- var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(e, t) {
9217
- return _regeneratorRuntime().wrap(function _callee66$(_context66) {
9218
- while (1) switch (_context66.prev = _context66.next) {
9327
+ var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(e, t) {
9328
+ return _regeneratorRuntime().wrap(function _callee68$(_context68) {
9329
+ while (1) switch (_context68.prev = _context68.next) {
9219
9330
  case 0:
9220
9331
  if (!t.region) {
9221
- _context66.next = 2;
9332
+ _context68.next = 2;
9222
9333
  break;
9223
9334
  }
9224
- return _context66.abrupt("return", t.subscriptionKey ? e.fromSubscription(t.subscriptionKey.trim(), t.region.trim()) : t.token ? e.fromAuthorizationToken(t.token.trim(), t.region.trim()) : t.retrieveToken ? t.retrieveToken().then(function (n) {
9335
+ return _context68.abrupt("return", t.subscriptionKey ? e.fromSubscription(t.subscriptionKey.trim(), t.region.trim()) : t.token ? e.fromAuthorizationToken(t.token.trim(), t.region.trim()) : t.retrieveToken ? t.retrieveToken().then(function (n) {
9225
9336
  return t.region ? e.fromAuthorizationToken((n == null ? void 0 : n.trim()) || "", t.region.trim()) : null;
9226
9337
  })["catch"](function (n) {
9227
9338
  return console.error(n), null;
9228
9339
  }) : null);
9229
9340
  case 2:
9230
9341
  case "end":
9231
- return _context66.stop();
9342
+ return _context68.stop();
9232
9343
  }
9233
- }, _callee66);
9344
+ }, _callee68);
9234
9345
  }));
9235
- function getNewSpeechConfig(_x112, _x113) {
9346
+ function getNewSpeechConfig(_x116, _x117) {
9236
9347
  return _getNewSpeechConfig.apply(this, arguments);
9237
9348
  }
9238
9349
  return getNewSpeechConfig;
@@ -9245,23 +9356,23 @@ var AzureSpeechConfig = /*#__PURE__*/function () {
9245
9356
  }, {
9246
9357
  key: "get",
9247
9358
  value: function () {
9248
- var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(e, t) {
9359
+ var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(e, t) {
9249
9360
  var n;
9250
- return _regeneratorRuntime().wrap(function _callee67$(_context67) {
9251
- while (1) switch (_context67.prev = _context67.next) {
9361
+ return _regeneratorRuntime().wrap(function _callee69$(_context69) {
9362
+ while (1) switch (_context69.prev = _context69.next) {
9252
9363
  case 0:
9253
- _context67.next = 2;
9364
+ _context69.next = 2;
9254
9365
  return AzureSpeechConfig.getNewSpeechConfig(e, t);
9255
9366
  case 2:
9256
- n = _context67.sent;
9257
- return _context67.abrupt("return", (n && AzureSpeechConfig.process(n, t), n));
9367
+ n = _context69.sent;
9368
+ return _context69.abrupt("return", (n && AzureSpeechConfig.process(n, t), n));
9258
9369
  case 4:
9259
9370
  case "end":
9260
- return _context67.stop();
9371
+ return _context69.stop();
9261
9372
  }
9262
- }, _callee67);
9373
+ }, _callee69);
9263
9374
  }));
9264
- function get(_x114, _x115) {
9375
+ function get(_x118, _x119) {
9265
9376
  return _get.apply(this, arguments);
9266
9377
  }
9267
9378
  return get;
@@ -9351,28 +9462,28 @@ var Azure = /*#__PURE__*/function (_speech_1$Speech) {
9351
9462
  }, {
9352
9463
  key: "startAsync",
9353
9464
  value: function () {
9354
- var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(e) {
9465
+ var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(e) {
9355
9466
  var t;
9356
- return _regeneratorRuntime().wrap(function _callee68$(_context68) {
9357
- while (1) switch (_context68.prev = _context68.next) {
9467
+ return _regeneratorRuntime().wrap(function _callee70$(_context70) {
9468
+ while (1) switch (_context70.prev = _context70.next) {
9358
9469
  case 0:
9359
- _context68.t0 = this.validate(e);
9360
- if (!_context68.t0) {
9361
- _context68.next = 6;
9470
+ _context70.t0 = this.validate(e);
9471
+ if (!_context70.t0) {
9472
+ _context70.next = 6;
9362
9473
  break;
9363
9474
  }
9364
- _context68.next = 4;
9475
+ _context70.next = 4;
9365
9476
  return this.instantiateService(e);
9366
9477
  case 4:
9367
9478
  this._translations = e == null ? void 0 : e.translations;
9368
9479
  (t = this._service) === null || t === void 0 || t.startContinuousRecognitionAsync(function () {}, this.error);
9369
9480
  case 6:
9370
9481
  case "end":
9371
- return _context68.stop();
9482
+ return _context70.stop();
9372
9483
  }
9373
- }, _callee68, this);
9484
+ }, _callee70, this);
9374
9485
  }));
9375
- function startAsync(_x116) {
9486
+ function startAsync(_x120) {
9376
9487
  return _startAsync.apply(this, arguments);
9377
9488
  }
9378
9489
  return startAsync;
@@ -9385,28 +9496,28 @@ var Azure = /*#__PURE__*/function (_speech_1$Speech) {
9385
9496
  }, {
9386
9497
  key: "instantiateService",
9387
9498
  value: function () {
9388
- var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(e) {
9499
+ var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(e) {
9389
9500
  var t, n, s, o;
9390
- return _regeneratorRuntime().wrap(function _callee69$(_context69) {
9391
- while (1) switch (_context69.prev = _context69.next) {
9501
+ return _regeneratorRuntime().wrap(function _callee71$(_context71) {
9502
+ while (1) switch (_context71.prev = _context71.next) {
9392
9503
  case 0:
9393
9504
  t = Azure.getAPI();
9394
9505
  n = t.AudioConfig.fromDefaultMicrophoneInput();
9395
- _context69.next = 4;
9506
+ _context71.next = 4;
9396
9507
  return azureSpeechConfig_1.AzureSpeechConfig.get(t.SpeechConfig, e);
9397
9508
  case 4:
9398
- s = _context69.sent;
9509
+ s = _context71.sent;
9399
9510
  if (s) {
9400
9511
  o = new t.SpeechRecognizer(s, n);
9401
9512
  this.setEvents(o), this._service = o, e.retrieveToken && this.retrieveTokenInterval(e.retrieveToken);
9402
9513
  } else this.error("Unable to contact Azure server");
9403
9514
  case 6:
9404
9515
  case "end":
9405
- return _context69.stop();
9516
+ return _context71.stop();
9406
9517
  }
9407
- }, _callee69, this);
9518
+ }, _callee71, this);
9408
9519
  }));
9409
- function instantiateService(_x117) {
9520
+ function instantiateService(_x121) {
9410
9521
  return _instantiateService.apply(this, arguments);
9411
9522
  }
9412
9523
  return instantiateService;
@@ -9780,82 +9891,91 @@ var SubmitButton = /*#__PURE__*/function (_InputButton4) {
9780
9891
  }
9781
9892
  // TO-DO - button should be disabled if validateMessageBeforeSending is not valid
9782
9893
  // TO-DO - button should be disabled if websocket connection is not open
9894
+ // TO-DO - should be disabled when websocket is connecting and option when loading history
9895
+ // prettier-ignore
9783
9896
  }, {
9784
9897
  key: "submit",
9785
9898
  value: function () {
9786
- var _submit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(e, t) {
9787
- var l, c, n, s, o, a;
9788
- return _regeneratorRuntime().wrap(function _callee70$(_context70) {
9789
- while (1) switch (_context70.prev = _context70.next) {
9899
+ var _submit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(e, t) {
9900
+ var c, u, n, s, o, a, l;
9901
+ return _regeneratorRuntime().wrap(function _callee72$(_context72) {
9902
+ while (1) switch (_context72.prev = _context72.next) {
9790
9903
  case 0:
9791
- _context70.t0 = e;
9792
- if (_context70.t0) {
9793
- _context70.next = 6;
9904
+ _context72.t0 = e;
9905
+ if (_context72.t0) {
9906
+ _context72.next = 6;
9794
9907
  break;
9795
9908
  }
9796
- _context70.next = 4;
9909
+ _context72.next = 4;
9797
9910
  return this._fileAttachments.completePlaceholders();
9798
9911
  case 4:
9799
9912
  n = this._fileAttachments.getAllFileData();
9800
- s = n == null ? void 0 : n.map(function (u) {
9801
- return u.file;
9913
+ s = n == null ? void 0 : n.map(function (d) {
9914
+ return d.file;
9802
9915
  });
9803
9916
  case 6:
9804
9917
  o = t === "" ? void 0 : t;
9805
9918
  if (!this._isRequestInProgress) {
9806
- _context70.next = 9;
9919
+ _context72.next = 9;
9807
9920
  break;
9808
9921
  }
9809
- return _context70.abrupt("return");
9922
+ return _context72.abrupt("return");
9810
9923
  case 9:
9811
- if (!((l = this._serviceIO.deepChat) != null && l.validateMessageBeforeSending)) {
9812
- _context70.next = 14;
9924
+ a = this._serviceIO.websocket;
9925
+ if (!(a && (a === "pending" || a.readyState === void 0 || a.readyState !== a.OPEN))) {
9926
+ _context72.next = 12;
9927
+ break;
9928
+ }
9929
+ return _context72.abrupt("return");
9930
+ case 12:
9931
+ if (!((c = this._serviceIO.deepChat) != null && c.validateMessageBeforeSending)) {
9932
+ _context72.next = 17;
9813
9933
  break;
9814
9934
  }
9815
9935
  if (this._serviceIO.deepChat.validateMessageBeforeSending(o, s)) {
9816
- _context70.next = 12;
9936
+ _context72.next = 15;
9817
9937
  break;
9818
9938
  }
9819
- return _context70.abrupt("return");
9820
- case 12:
9821
- _context70.next = 16;
9939
+ return _context72.abrupt("return");
9940
+ case 15:
9941
+ _context72.next = 19;
9822
9942
  break;
9823
- case 14:
9943
+ case 17:
9824
9944
  if (this._serviceIO.canSendMessage(o, s)) {
9825
- _context70.next = 16;
9945
+ _context72.next = 19;
9826
9946
  break;
9827
9947
  }
9828
- return _context70.abrupt("return");
9829
- case 16:
9948
+ return _context72.abrupt("return");
9949
+ case 19:
9830
9950
  this.changeToLoadingIcon();
9831
9951
  t !== "" && this._messages.addNewMessage({
9832
9952
  text: t
9833
9953
  }, !1, !0);
9834
- _context70.t1 = n;
9835
- if (!_context70.t1) {
9836
- _context70.next = 22;
9954
+ _context72.t1 = n;
9955
+ if (!_context72.t1) {
9956
+ _context72.next = 25;
9837
9957
  break;
9838
9958
  }
9839
- _context70.next = 22;
9959
+ _context72.next = 25;
9840
9960
  return this._messages.addMultipleFiles(n);
9841
- case 22:
9961
+ case 25:
9842
9962
  this._messages.addLoadingMessage();
9843
9963
  e || TextInputEl.clear(this._inputElementRef);
9844
- a = {
9964
+ l = {
9845
9965
  text: o,
9846
9966
  files: s
9847
9967
  };
9848
- _context70.next = 27;
9849
- return this._serviceIO.callAPI(a, this._messages);
9850
- case 27:
9851
- e || (c = this._fileAttachments) == null || c.removeAllFiles();
9852
- case 28:
9968
+ _context72.next = 30;
9969
+ return this._serviceIO.callAPI(l, this._messages);
9970
+ case 30:
9971
+ e || (u = this._fileAttachments) == null || u.removeAllFiles();
9972
+ case 31:
9853
9973
  case "end":
9854
- return _context70.stop();
9974
+ return _context72.stop();
9855
9975
  }
9856
- }, _callee70, this);
9976
+ }, _callee72, this);
9857
9977
  }));
9858
- function submit(_x118, _x119) {
9978
+ function submit(_x122, _x123) {
9859
9979
  return _submit.apply(this, arguments);
9860
9980
  }
9861
9981
  return submit;
@@ -10160,7 +10280,7 @@ var ChatView = /*#__PURE__*/function () {
10160
10280
  var s = document.createElement("div");
10161
10281
  s.id = "chat-view";
10162
10282
  var o = new Messages(e, t, n);
10163
- t.websocket && Websocket.assignListeners(t, o);
10283
+ t.websocket && Websocket.createConnection(t, o);
10164
10284
  var a = new Input(e, o, t, s);
10165
10285
  return ElementUtils.addElements(s, o.elementRef, a.elementRef), s;
10166
10286
  }
@@ -10193,7 +10313,7 @@ var DeepChat = /*#__PURE__*/function (_InternalHTML2) {
10193
10313
  return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");
10194
10314
  }, _this60.focusInput = function () {
10195
10315
  FocusUtils.focusFromParentElement(_this60._elementRef);
10196
- }, _this60.refreshMessages = function () {}, _this60.onNewMessage = function () {}, _this60.onComponentRender = function () {}, _this60._hasBeenRendered = !1, _this60._auxiliaryStyleApplied = !1, GoogleFont.appendStyleSheetToHead(), _this60._elementRef = document.createElement("div"), _this60._elementRef.id = "container", _this60.attachShadow({
10316
+ }, _this60.refreshMessages = function () {}, _this60.clearMessages = function () {}, _this60.onNewMessage = function () {}, _this60.onClearMessages = function () {}, _this60.onComponentRender = function () {}, _this60._hasBeenRendered = !1, _this60._auxiliaryStyleApplied = !1, GoogleFont.appendStyleSheetToHead(), _this60._elementRef = document.createElement("div"), _this60._elementRef.id = "container", _this60.attachShadow({
10197
10317
  mode: "open"
10198
10318
  }).appendChild(_this60._elementRef), WebComponentStyleUtils.apply(style, _this60.shadowRoot), setTimeout(function () {
10199
10319
  _this60._hasBeenRendered || _this60.onRender();
@@ -10210,8 +10330,8 @@ var DeepChat = /*#__PURE__*/function (_InternalHTML2) {
10210
10330
  key: "onRender",
10211
10331
  value: function onRender() {
10212
10332
  var _this$_activeService, _this$_childElement;
10213
- var e, t;
10214
- (_this$_activeService = this._activeService) !== null && _this$_activeService !== void 0 ? _this$_activeService : this._activeService = ServiceIOFactory.create(this), this._activeService && (this.auxiliaryStyle && !this._auxiliaryStyleApplied && (WebComponentStyleUtils.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), Object.assign(this._elementRef.style, this.containerStyle), this._activeService.key && this._activeService.validateConfigKey ? ValidateKeyPropertyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : this._activeService instanceof DirectServiceIO && this._activeService.key || (e = this.request) != null && e.url || (t = this.directConnection) != null && t.demo ? ((_this$_childElement = this._childElement) !== null && _this$_childElement !== void 0 ? _this$_childElement : this._childElement = this.children[0], ChatView.render(this, this._elementRef, this._activeService, this._childElement)) : this._activeService instanceof DirectServiceIO ? InsertKeyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : ErrorView.render(this._elementRef, 'Please define "request" with a "url"'), this._hasBeenRendered = !0, FireEvents.onRender(this));
10333
+ var e, t, n;
10334
+ (_this$_activeService = this._activeService) !== null && _this$_activeService !== void 0 ? _this$_activeService : this._activeService = ServiceIOFactory.create(this), this._activeService && (this.auxiliaryStyle && !this._auxiliaryStyleApplied && (WebComponentStyleUtils.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), Object.assign(this._elementRef.style, this.containerStyle), this._activeService.key && this._activeService.validateConfigKey ? ValidateKeyPropertyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : this._activeService instanceof DirectServiceIO && this._activeService.key || (e = this.request) != null && e.url || (t = this.request) != null && t.handler || (n = this.directConnection) != null && n.demo ? ((_this$_childElement = this._childElement) !== null && _this$_childElement !== void 0 ? _this$_childElement : this._childElement = this.children[0], ChatView.render(this, this._elementRef, this._activeService, this._childElement)) : this._activeService instanceof DirectServiceIO ? InsertKeyView.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : ErrorView.render(this._elementRef, 'Please define "request" with a "url"'), this._hasBeenRendered = !0, FireEvents.onRender(this));
10215
10335
  }
10216
10336
  }]);
10217
10337
  return DeepChat;
@@ -10248,6 +10368,7 @@ __decorateClass([Property("object")], DeepChat.prototype, "mixedFiles", 2);
10248
10368
  __decorateClass([Property("object")], DeepChat.prototype, "dragAndDrop", 2);
10249
10369
  __decorateClass([Property("object")], DeepChat.prototype, "introPanelStyle", 2);
10250
10370
  __decorateClass([Property("function")], DeepChat.prototype, "onNewMessage", 2);
10371
+ __decorateClass([Property("function")], DeepChat.prototype, "onClearMessages", 2);
10251
10372
  __decorateClass([Property("function")], DeepChat.prototype, "onComponentRender", 2);
10252
10373
  customElements.define("deep-chat", DeepChat);
10253
10374
  export { DeepChat };