funda-ui 4.6.111 → 4.6.222

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.
@@ -3565,124 +3565,22 @@ var sanitize = __webpack_require__(959);
3565
3565
  ;// CONCATENATED MODULE: ./src/PureLoader.tsx
3566
3566
 
3567
3567
  var PureLoader = function PureLoader(props) {
3568
- var txt = props.txt,
3568
+ var _props$prefix = props.prefix,
3569
+ prefix = _props$prefix === void 0 ? 'custom-' : _props$prefix,
3570
+ txt = props.txt,
3569
3571
  center = props.center,
3570
3572
  customClassName = props.customClassName;
3571
3573
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
3572
- className: "app-chatbox-loader-container ".concat(customClassName || '')
3574
+ className: "".concat(prefix, "chatbox-loader-container ").concat(customClassName || '')
3573
3575
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
3574
3576
  className: "row g-0 align-items-center"
3575
3577
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
3576
3578
  className: center ? 'text-center' : ''
3577
3579
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("small", null, txt || txt === '' ? txt : 'Loading...')), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
3578
- className: "app-chatbox-loader"
3580
+ className: "${prefix}chatbox-loader"
3579
3581
  })))));
3580
3582
  };
3581
3583
  /* harmony default export */ const src_PureLoader = (PureLoader);
3582
- ;// CONCATENATED MODULE: ./src/TypingEffect.tsx
3583
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3584
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3585
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3586
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
3587
- function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
3588
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3589
-
3590
- var TypingEffect = function TypingEffect(_ref) {
3591
- var content = _ref.content,
3592
- speed = _ref.speed,
3593
- onComplete = _ref.onComplete,
3594
- onUpdate = _ref.onUpdate;
3595
- var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
3596
- _useState2 = _slicedToArray(_useState, 2),
3597
- displayedContent = _useState2[0],
3598
- setDisplayedContent = _useState2[1];
3599
- var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
3600
- _useState4 = _slicedToArray(_useState3, 2),
3601
- index = _useState4[0],
3602
- setIndex = _useState4[1];
3603
- var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
3604
- _useState6 = _slicedToArray(_useState5, 2),
3605
- imagePlaceholders = _useState6[0],
3606
- setImagePlaceholders = _useState6[1];
3607
- var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
3608
- _useState8 = _slicedToArray(_useState7, 2),
3609
- processedContent = _useState8[0],
3610
- setProcessedContent = _useState8[1];
3611
-
3612
- // Extract and replace image tags
3613
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
3614
- var extractImages = function extractImages(html) {
3615
- var placeholders = [];
3616
- var processedHtml = html;
3617
-
3618
- // <img>
3619
- processedHtml = processedHtml.replace(/<img[^>]*>/g, function (match) {
3620
- var placeholder = "[IMG_".concat(placeholders.length, "]");
3621
- placeholders.push({
3622
- original: match,
3623
- placeholder: placeholder,
3624
- type: 'img'
3625
- });
3626
- return placeholder;
3627
- });
3628
-
3629
- // <svg>
3630
- processedHtml = processedHtml.replace(/<svg[^>]*>[\s\S]*?<\/svg>/g, function (match) {
3631
- var placeholder = "[SVG_".concat(placeholders.length, "]");
3632
- placeholders.push({
3633
- original: match,
3634
- placeholder: placeholder,
3635
- type: 'svg'
3636
- });
3637
- return placeholder;
3638
- });
3639
- return {
3640
- processedHtml: processedHtml,
3641
- placeholders: placeholders
3642
- };
3643
- };
3644
- var _extractImages = extractImages(content),
3645
- processedHtml = _extractImages.processedHtml,
3646
- placeholders = _extractImages.placeholders;
3647
- setProcessedContent(processedHtml);
3648
- setImagePlaceholders(placeholders);
3649
- }, [content]);
3650
-
3651
- // Handle typing effects
3652
- (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
3653
- var timer = setInterval(function () {
3654
- if (index < processedContent.length) {
3655
- var newContent = processedContent.substring(0, index + 1);
3656
-
3657
- // Replace the completed placeholder
3658
- imagePlaceholders.forEach(function (_ref2) {
3659
- var original = _ref2.original,
3660
- placeholder = _ref2.placeholder;
3661
- if (newContent.includes(placeholder)) {
3662
- newContent = newContent.replace(placeholder, original);
3663
- }
3664
- });
3665
- setDisplayedContent(newContent);
3666
- setIndex(function (prev) {
3667
- return prev + 1;
3668
- });
3669
- onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate();
3670
- } else {
3671
- clearInterval(timer);
3672
- onComplete === null || onComplete === void 0 ? void 0 : onComplete();
3673
- }
3674
- }, speed);
3675
- return function () {
3676
- return clearInterval(timer);
3677
- };
3678
- }, [processedContent, index, speed, onComplete, onUpdate, imagePlaceholders]);
3679
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
3680
- dangerouslySetInnerHTML: {
3681
- __html: displayedContent
3682
- }
3683
- });
3684
- };
3685
- /* harmony default export */ const src_TypingEffect = (TypingEffect);
3686
3584
  ;// CONCATENATED MODULE: ./src/utils/func.ts
3687
3585
  // app.ts
3688
3586
 
@@ -3711,6 +3609,11 @@ function formatLatestDisplayContent(str) {
3711
3609
  return match; // If not empty, return the original matched content
3712
3610
  });
3713
3611
 
3612
+ // Then handle tables without is-init class
3613
+ output = output.replace(/<table(?![^>]*\bis-init\b)([^>]*)>([\s\S]*?)<\/table>/g, function (match, attributes, content) {
3614
+ // Add is-init class to table and wrap it in container div
3615
+ return "<div class=\"table-container\"><table class=\"is-init\"".concat(attributes, ">").concat(content, "</table></div>");
3616
+ });
3714
3617
  return output;
3715
3618
  }
3716
3619
  function formatName(str, isAnswer, props) {
@@ -3787,6 +3690,125 @@ function isStreamResponse(response) {
3787
3690
  return response.body instanceof ReadableStream;
3788
3691
  }
3789
3692
  ;
3693
+ function extractHtmlTags(html) {
3694
+ var placeholders = [];
3695
+ var processedHtml = html;
3696
+
3697
+ // <table>
3698
+ processedHtml = processedHtml.replace(/<table[^>]*>[\s\S]*?<\/table>/g, function (match) {
3699
+ var placeholder = "[TABLE_".concat(placeholders.length, "]");
3700
+ placeholders.push({
3701
+ original: "<div class=\"table-container\">".concat(match === null || match === void 0 ? void 0 : match.replace('<table', '<table class="is-init"'), "</div>"),
3702
+ placeholder: placeholder,
3703
+ type: 'table'
3704
+ });
3705
+ return placeholder;
3706
+ });
3707
+
3708
+ // <img>
3709
+ processedHtml = processedHtml.replace(/<img[^>]*>/g, function (match) {
3710
+ var placeholder = "[IMG_".concat(placeholders.length, "]");
3711
+ placeholders.push({
3712
+ original: match,
3713
+ placeholder: placeholder,
3714
+ type: 'img'
3715
+ });
3716
+ return placeholder;
3717
+ });
3718
+
3719
+ // <svg>
3720
+ processedHtml = processedHtml.replace(/<svg[^>]*>[\s\S]*?<\/svg>/g, function (match) {
3721
+ var placeholder = "[SVG_".concat(placeholders.length, "]");
3722
+ placeholders.push({
3723
+ original: match,
3724
+ placeholder: placeholder,
3725
+ type: 'svg'
3726
+ });
3727
+ return placeholder;
3728
+ });
3729
+ return {
3730
+ processedHtml: processedHtml,
3731
+ placeholders: placeholders
3732
+ };
3733
+ }
3734
+ ;
3735
+ ;// CONCATENATED MODULE: ./src/TypingEffect.tsx
3736
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3737
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3738
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
3739
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
3740
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
3741
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3742
+
3743
+
3744
+ // extract
3745
+
3746
+ var TypingEffect = function TypingEffect(_ref) {
3747
+ var content = _ref.content,
3748
+ speed = _ref.speed,
3749
+ onComplete = _ref.onComplete,
3750
+ onUpdate = _ref.onUpdate;
3751
+ var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
3752
+ _useState2 = _slicedToArray(_useState, 2),
3753
+ displayedContent = _useState2[0],
3754
+ setDisplayedContent = _useState2[1];
3755
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(0),
3756
+ _useState4 = _slicedToArray(_useState3, 2),
3757
+ index = _useState4[0],
3758
+ setIndex = _useState4[1];
3759
+ var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
3760
+ _useState6 = _slicedToArray(_useState5, 2),
3761
+ htmlTagPlaceholder = _useState6[0],
3762
+ setHtmlTagPlaceholders = _useState6[1];
3763
+ var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(''),
3764
+ _useState8 = _slicedToArray(_useState7, 2),
3765
+ processedContent = _useState8[0],
3766
+ setProcessedContent = _useState8[1];
3767
+
3768
+ // Extract and replace image tags
3769
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
3770
+ var _extractHtmlTags = extractHtmlTags(content),
3771
+ processedHtml = _extractHtmlTags.processedHtml,
3772
+ placeholders = _extractHtmlTags.placeholders;
3773
+ setProcessedContent(processedHtml);
3774
+ setHtmlTagPlaceholders(placeholders);
3775
+ }, [content]);
3776
+
3777
+ // Handle typing effects
3778
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
3779
+ var timer = setInterval(function () {
3780
+ if (index < processedContent.length) {
3781
+ var newContent = processedContent.substring(0, index + 1);
3782
+
3783
+ // Replace the completed placeholder
3784
+ htmlTagPlaceholder.forEach(function (_ref2) {
3785
+ var original = _ref2.original,
3786
+ placeholder = _ref2.placeholder;
3787
+ if (newContent.includes(placeholder)) {
3788
+ newContent = newContent.replace(placeholder, original);
3789
+ }
3790
+ });
3791
+ setDisplayedContent(newContent);
3792
+ setIndex(function (prev) {
3793
+ return prev + 1;
3794
+ });
3795
+ onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate();
3796
+ } else {
3797
+ clearInterval(timer);
3798
+ onComplete === null || onComplete === void 0 ? void 0 : onComplete();
3799
+ }
3800
+ }, speed);
3801
+ return function () {
3802
+ return clearInterval(timer);
3803
+ };
3804
+ }, [processedContent, index, speed, onComplete, onUpdate, htmlTagPlaceholder]);
3805
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
3806
+ dangerouslySetInnerHTML: {
3807
+ __html: displayedContent
3808
+ }
3809
+ });
3810
+ };
3811
+ /* harmony default export */ const src_TypingEffect = (TypingEffect);
3790
3812
  ;// CONCATENATED MODULE: ./src/useStreamController.tsx
3791
3813
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3792
3814
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
@@ -4179,12 +4201,8 @@ var useStreamController = function useStreamController() {
4179
4201
  /* harmony default export */ const src_useStreamController = (useStreamController);
4180
4202
  ;// CONCATENATED MODULE: ./src/index.tsx
4181
4203
  function src_typeof(obj) { "@babel/helpers - typeof"; return src_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, src_typeof(obj); }
4182
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || src_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4183
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4184
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4185
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return src_arrayLikeToArray(arr); }
4186
- function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4187
4204
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = src_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
4205
+ function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
4188
4206
  function src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4189
4207
  function src_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
4190
4208
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -4192,6 +4210,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4192
4210
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4193
4211
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return src_typeof(key) === "symbol" ? key : String(key); }
4194
4212
  function _toPrimitive(input, hint) { if (src_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (src_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4213
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || src_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4214
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4215
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
4216
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return src_arrayLikeToArray(arr); }
4195
4217
  function src_slicedToArray(arr, i) { return src_arrayWithHoles(arr) || src_iterableToArrayLimit(arr, i) || src_unsupportedIterableToArray(arr, i) || src_nonIterableRest(); }
4196
4218
  function src_nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4197
4219
  function src_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return src_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return src_arrayLikeToArray(o, minLen); }
@@ -4213,7 +4235,7 @@ function src_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
4213
4235
 
4214
4236
 
4215
4237
  var Chatbox = function Chatbox(props) {
4216
- var _args$newChatButton;
4238
+ var _list, _args$newChatButton;
4217
4239
  var chatId = useComId_default()().replace(/\-/g, '_');
4218
4240
 
4219
4241
  // Store latest props in refs
@@ -4298,8 +4320,9 @@ var Chatbox = function Chatbox(props) {
4298
4320
  setShow(false);
4299
4321
  },
4300
4322
  clearData: function clearData() {
4301
- setMsgList([]);
4323
+ // Update both the conversation history and displayed messages
4302
4324
  conversationHistory.current = [];
4325
+ setMsgList([]);
4303
4326
  },
4304
4327
  sendMsg: function sendMsg() {
4305
4328
  handleClickSafe();
@@ -4313,6 +4336,11 @@ var Chatbox = function Chatbox(props) {
4313
4336
  conversationHistory.current = conversationHistory.current.slice(-maxLength);
4314
4337
  }
4315
4338
  },
4339
+ setHistory: function setHistory(messages) {
4340
+ // Update both the conversation history and displayed messages
4341
+ conversationHistory.current = _toConsumableArray(messages);
4342
+ setMsgList(_toConsumableArray(messages));
4343
+ },
4316
4344
  setVal: function setVal(v) {
4317
4345
  if (inputContentRef.current) inputContentRef.current.set(v);
4318
4346
  },
@@ -4386,6 +4414,7 @@ var Chatbox = function Chatbox(props) {
4386
4414
  newChatButton = currentProps.newChatButton,
4387
4415
  maxHistoryLength = currentProps.maxHistoryLength,
4388
4416
  customRequest = currentProps.customRequest,
4417
+ onQuestionClick = currentProps.onQuestionClick,
4389
4418
  renderParser = currentProps.renderParser,
4390
4419
  requestBodyFormatter = currentProps.requestBodyFormatter,
4391
4420
  nameFormatter = currentProps.nameFormatter,
@@ -4451,6 +4480,7 @@ var Chatbox = function Chatbox(props) {
4451
4480
  toolkitButtons: toolkitButtons,
4452
4481
  newChatButton: newChatButton,
4453
4482
  customRequest: customRequest,
4483
+ onQuestionClick: onQuestionClick,
4454
4484
  renderParser: renderParser,
4455
4485
  requestBodyFormatter: requestBodyFormatter,
4456
4486
  nameFormatter: nameFormatter,
@@ -4459,6 +4489,7 @@ var Chatbox = function Chatbox(props) {
4459
4489
  onChunk: onChunk,
4460
4490
  onComplete: onComplete,
4461
4491
  //
4492
+ defaultQuestionsRes: questions,
4462
4493
  latestContextData: latestContextData,
4463
4494
  questionNameRes: _questionName,
4464
4495
  answerNameRes: _answerName,
@@ -4471,14 +4502,37 @@ var Chatbox = function Chatbox(props) {
4471
4502
  };
4472
4503
  };
4473
4504
 
4505
+ //================================================================
4506
+ // Custom Questions
4507
+ //================================================================
4508
+ var _useState17 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(props.defaultQuestions),
4509
+ _useState18 = src_slicedToArray(_useState17, 2),
4510
+ questions = _useState18[0],
4511
+ setQuestions = _useState18[1];
4512
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
4513
+ if (props.defaultQuestions) {
4514
+ setQuestions(props.defaultQuestions);
4515
+ }
4516
+ }, [props.defaultQuestions]);
4517
+ var hasQuestion = function hasQuestion() {
4518
+ return args().defaultQuestionsRes && args().defaultQuestionsRes.list.length > 0;
4519
+ };
4520
+ var handleQuestionClick = function handleQuestionClick(text) {
4521
+ var _args$onQuestionClick, _args;
4522
+ if (inputContentRef.current) {
4523
+ inputContentRef.current.set(text);
4524
+ }
4525
+ (_args$onQuestionClick = (_args = args()).onQuestionClick) === null || _args$onQuestionClick === void 0 ? void 0 : _args$onQuestionClick.call(_args, text, exposedMethods());
4526
+ };
4527
+
4474
4528
  //================================================================
4475
4529
  // Custom buttons
4476
4530
  //================================================================
4477
4531
  var toolkitBtnsRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
4478
- var _useState17 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
4479
- _useState18 = src_slicedToArray(_useState17, 2),
4480
- activeButtons = _useState18[0],
4481
- setActiveButtons = _useState18[1];
4532
+ var _useState19 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
4533
+ _useState20 = src_slicedToArray(_useState19, 2),
4534
+ activeButtons = _useState20[0],
4535
+ setActiveButtons = _useState20[1];
4482
4536
  var closeDropdowns = function closeDropdowns() {
4483
4537
  setActiveButtons(function (prev) {
4484
4538
  var _args$toolkitButtons;
@@ -4493,34 +4547,83 @@ var Chatbox = function Chatbox(props) {
4493
4547
  return newState;
4494
4548
  });
4495
4549
  };
4496
- var executeButtonAction = function executeButtonAction(actionStr, buttonId, buttonElement) {
4497
- try {
4498
- // Create a new function to execute
4499
- var actionFn = new Function('method', 'isActive', 'button', actionStr);
4500
- /*
4501
- function (method, isActive, button) {
4502
- console.log('Clearing chat');
4503
- method.clearData();
4504
- }
4505
- */
4550
+ var executeButtonAction = /*#__PURE__*/function () {
4551
+ var _ref = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(actionStr, buttonId, buttonElement) {
4552
+ var actionFn, result, options, newState;
4553
+ return src_regeneratorRuntime().wrap(function _callee$(_context) {
4554
+ while (1) switch (_context.prev = _context.next) {
4555
+ case 0:
4556
+ _context.prev = 0;
4557
+ actionFn = new Function('method', 'isActive', 'button', actionStr); // !!!REQUIRED "await"
4558
+ // "customMethods" may be asynchronous
4559
+ _context.next = 4;
4560
+ return actionFn(exposedMethods(), !activeButtons[buttonId], buttonElement);
4561
+ case 4:
4562
+ result = _context.sent;
4563
+ // If the returned result is an array, it is a dynamic option
4564
+ if (Array.isArray(result) && Object.keys(dynamicOptions).length === 0) {
4565
+ options = result.map(function (item) {
4566
+ var _Object$entries$ = src_slicedToArray(Object.entries(item)[0], 2),
4567
+ key = _Object$entries$[0],
4568
+ value = _Object$entries$[1];
4569
+ var _split$map = value.split('{#}').map(function (s) {
4570
+ return s.trim();
4571
+ }),
4572
+ _split$map2 = src_slicedToArray(_split$map, 3),
4573
+ label = _split$map2[0],
4574
+ val = _split$map2[1],
4575
+ onClick = _split$map2[2];
4576
+ return {
4577
+ label: label,
4578
+ value: val,
4579
+ onClick: onClick
4580
+ };
4581
+ }); // Update dynamic options
4582
+ setDynamicOptions(function (prev) {
4583
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, options));
4584
+ });
4585
+ }
4506
4586
 
4507
- // Update the button status
4508
- var newState = !activeButtons[buttonId];
4509
- setActiveButtons(function (prev) {
4510
- return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, newState));
4511
- });
4512
- return actionFn(exposedMethods(), newState, buttonElement);
4513
- } catch (error) {
4514
- console.error('Error executing button action:', error);
4515
- }
4516
- };
4587
+ // Update the button status
4588
+ newState = !activeButtons[buttonId];
4589
+ setActiveButtons(function (prev) {
4590
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, newState));
4591
+ });
4592
+ return _context.abrupt("return", result);
4593
+ case 11:
4594
+ _context.prev = 11;
4595
+ _context.t0 = _context["catch"](0);
4596
+ console.error('Error executing button action:', _context.t0);
4597
+ case 14:
4598
+ case "end":
4599
+ return _context.stop();
4600
+ }
4601
+ }, _callee, null, [[0, 11]]);
4602
+ }));
4603
+ return function executeButtonAction(_x2, _x3, _x4) {
4604
+ return _ref.apply(this, arguments);
4605
+ };
4606
+ }();
4517
4607
 
4518
4608
  // options
4519
- var _useState19 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
4520
- _useState20 = src_slicedToArray(_useState19, 2),
4521
- selectedOpt = _useState20[0],
4522
- setSelectedOpt = _useState20[1];
4523
- var getButtonOptions = function getButtonOptions(btn) {
4609
+ var _useState21 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
4610
+ _useState22 = src_slicedToArray(_useState21, 2),
4611
+ selectedOpt = _useState22[0],
4612
+ setSelectedOpt = _useState22[1];
4613
+ // Store dynamic options
4614
+ var _useState23 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
4615
+ _useState24 = src_slicedToArray(_useState23, 2),
4616
+ dynamicOptions = _useState24[0],
4617
+ setDynamicOptions = _useState24[1];
4618
+ var getButtonOptions = function getButtonOptions(btn, buttonId) {
4619
+ // If you are using the dynamic option and already have a cache, return the option for caching
4620
+ //---------
4621
+ if (btn.dynamicOptions && dynamicOptions[buttonId]) {
4622
+ return dynamicOptions[buttonId];
4623
+ }
4624
+
4625
+ // Use the static option from "props"
4626
+ //---------
4524
4627
  var options = [];
4525
4628
  var index = 1;
4526
4629
  while (true) {
@@ -4554,8 +4657,8 @@ var Chatbox = function Chatbox(props) {
4554
4657
  });
4555
4658
  } else {
4556
4659
  setSelectedOpt(function (prev) {
4557
- var _objectSpread3;
4558
- return _objectSpread(_objectSpread({}, prev), {}, (_objectSpread3 = {}, _defineProperty(_objectSpread3, buttonId, option.label), _defineProperty(_objectSpread3, "curIndex", index), _defineProperty(_objectSpread3, "curValue", value), _objectSpread3));
4660
+ var _objectSpread4;
4661
+ return _objectSpread(_objectSpread({}, prev), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, buttonId, option.label), _defineProperty(_objectSpread4, "curIndex", index), _defineProperty(_objectSpread4, "curValue", value), _objectSpread4));
4559
4662
  });
4560
4663
  }
4561
4664
  executeButtonAction(option.onClick, buttonId, document.getElementById(buttonId));
@@ -4618,25 +4721,25 @@ var Chatbox = function Chatbox(props) {
4618
4721
 
4619
4722
  // parse chunk data
4620
4723
  var parseChunkData = /*#__PURE__*/function () {
4621
- var _ref = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(chunk, index, complete) {
4724
+ var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(chunk, index, complete) {
4622
4725
  var lastContent, _args$responseExtract, extractPath, lines, _iterator, _step, line, _content, result, _iterator2, _step2, path, content, parsedContent, latestRes;
4623
- return src_regeneratorRuntime().wrap(function _callee$(_context) {
4624
- while (1) switch (_context.prev = _context.next) {
4726
+ return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
4727
+ while (1) switch (_context2.prev = _context2.next) {
4625
4728
  case 0:
4626
4729
  // Store the final content and bind it to loading
4627
4730
  lastContent = '';
4628
- _context.prev = 1;
4731
+ _context2.prev = 1;
4629
4732
  // Extract response using the path
4630
4733
  extractPath = (_args$responseExtract = args().responseExtractPath) === null || _args$responseExtract === void 0 ? void 0 : _args$responseExtract.slice(1); // Streaming data is JSON split by rows
4631
4734
  lines = chunk.split("\n").filter(function (line) {
4632
4735
  return line.trim() !== "";
4633
4736
  });
4634
4737
  _iterator = _createForOfIteratorHelper(lines);
4635
- _context.prev = 5;
4738
+ _context2.prev = 5;
4636
4739
  _iterator.s();
4637
4740
  case 7:
4638
4741
  if ((_step = _iterator.n()).done) {
4639
- _context.next = 45;
4742
+ _context2.next = 45;
4640
4743
  break;
4641
4744
  }
4642
4745
  line = _step.value;
@@ -4647,7 +4750,7 @@ var Chatbox = function Chatbox(props) {
4647
4750
 
4648
4751
  // Send the streamed data to the front end
4649
4752
  if (!(line.indexOf('[DONE]') < 0)) {
4650
- _context.next = 40;
4753
+ _context2.next = 40;
4651
4754
  break;
4652
4755
  }
4653
4756
  // STEP 1:
@@ -4655,14 +4758,14 @@ var Chatbox = function Chatbox(props) {
4655
4758
  // Create a JSON string
4656
4759
  _content = "".concat(line.replace(/^data:\s*/, '')); // Determine whether it is in JSON format
4657
4760
  if (isValidJSON(_content)) {
4658
- _context.next = 16;
4761
+ _context2.next = 16;
4659
4762
  break;
4660
4763
  }
4661
4764
  console.log('--> [ERROR] Wrong JSON format');
4662
4765
 
4663
4766
  //reset SSE
4664
4767
  closeSSE();
4665
- return _context.abrupt("break", 45);
4768
+ return _context2.abrupt("break", 45);
4666
4769
  case 16:
4667
4770
  // STEP 2:
4668
4771
  // ------
@@ -4671,18 +4774,18 @@ var Chatbox = function Chatbox(props) {
4671
4774
  // for Ollama API (STREAM END)
4672
4775
  //*******
4673
4776
  if (!(typeof result.done !== 'undefined')) {
4674
- _context.next = 22;
4777
+ _context2.next = 22;
4675
4778
  break;
4676
4779
  }
4677
4780
  if (!(result.done === true)) {
4678
- _context.next = 22;
4781
+ _context2.next = 22;
4679
4782
  break;
4680
4783
  }
4681
4784
  console.log('--> [DONE]');
4682
4785
 
4683
4786
  //reset SSE
4684
4787
  closeSSE();
4685
- return _context.abrupt("break", 45);
4788
+ return _context2.abrupt("break", 45);
4686
4789
  case 22:
4687
4790
  //*******
4688
4791
  // for OpenAI API
@@ -4704,10 +4807,10 @@ var Chatbox = function Chatbox(props) {
4704
4807
  // ------
4705
4808
  // 🚀 !! IMPORTANT: Skip the error content
4706
4809
  if (!(typeof content === 'undefined')) {
4707
- _context.next = 26;
4810
+ _context2.next = 26;
4708
4811
  break;
4709
4812
  }
4710
- return _context.abrupt("continue", 43);
4813
+ return _context2.abrupt("continue", 43);
4711
4814
  case 26:
4712
4815
  // STEP 4:
4713
4816
  // ------
@@ -4734,13 +4837,13 @@ var Chatbox = function Chatbox(props) {
4734
4837
  // ------
4735
4838
  parsedContent = tempLastContent.current; // If a render parser exists, it is used to process the string
4736
4839
  if (!(typeof args().renderParser === 'function')) {
4737
- _context.next = 36;
4840
+ _context2.next = 36;
4738
4841
  break;
4739
4842
  }
4740
- _context.next = 35;
4843
+ _context2.next = 35;
4741
4844
  return args().renderParser(parsedContent);
4742
4845
  case 35:
4743
- parsedContent = _context.sent;
4846
+ parsedContent = _context2.sent;
4744
4847
  case 36:
4745
4848
  // STEP 8:
4746
4849
  // ------
@@ -4757,55 +4860,55 @@ var Chatbox = function Chatbox(props) {
4757
4860
  // ------
4758
4861
  // Scroll to the bottom
4759
4862
  scrollToBottom();
4760
- _context.next = 43;
4863
+ _context2.next = 43;
4761
4864
  break;
4762
4865
  case 40:
4763
4866
  console.log('--> [DONE]');
4764
4867
 
4765
4868
  //reset SSE
4766
4869
  closeSSE();
4767
- return _context.abrupt("break", 45);
4870
+ return _context2.abrupt("break", 45);
4768
4871
  case 43:
4769
- _context.next = 7;
4872
+ _context2.next = 7;
4770
4873
  break;
4771
4874
  case 45:
4772
- _context.next = 50;
4875
+ _context2.next = 50;
4773
4876
  break;
4774
4877
  case 47:
4775
- _context.prev = 47;
4776
- _context.t0 = _context["catch"](5);
4777
- _iterator.e(_context.t0);
4878
+ _context2.prev = 47;
4879
+ _context2.t0 = _context2["catch"](5);
4880
+ _iterator.e(_context2.t0);
4778
4881
  case 50:
4779
- _context.prev = 50;
4882
+ _context2.prev = 50;
4780
4883
  _iterator.f();
4781
- return _context.finish(50);
4884
+ return _context2.finish(50);
4782
4885
  case 53:
4783
- _context.next = 58;
4886
+ _context2.next = 58;
4784
4887
  break;
4785
4888
  case 55:
4786
- _context.prev = 55;
4787
- _context.t1 = _context["catch"](1);
4788
- console.error('--> Error processing chunk:', _context.t1);
4889
+ _context2.prev = 55;
4890
+ _context2.t1 = _context2["catch"](1);
4891
+ console.error('--> Error processing chunk:', _context2.t1);
4789
4892
  case 58:
4790
4893
  latestRes = complete ? lastContent : tempLastContent.current; // If a render parser exists, it is used to process the string
4791
4894
  if (!(typeof args().renderParser === 'function')) {
4792
- _context.next = 63;
4895
+ _context2.next = 63;
4793
4896
  break;
4794
4897
  }
4795
- _context.next = 62;
4898
+ _context2.next = 62;
4796
4899
  return args().renderParser(latestRes);
4797
4900
  case 62:
4798
- latestRes = _context.sent;
4901
+ latestRes = _context2.sent;
4799
4902
  case 63:
4800
- return _context.abrupt("return", formatLatestDisplayContent(latestRes));
4903
+ return _context2.abrupt("return", formatLatestDisplayContent(latestRes));
4801
4904
  case 64:
4802
4905
  case "end":
4803
- return _context.stop();
4906
+ return _context2.stop();
4804
4907
  }
4805
- }, _callee, null, [[1, 55], [5, 47, 50, 53]]);
4908
+ }, _callee2, null, [[1, 55], [5, 47, 50, 53]]);
4806
4909
  }));
4807
- return function parseChunkData(_x2, _x3, _x4) {
4808
- return _ref.apply(this, arguments);
4910
+ return function parseChunkData(_x5, _x6, _x7) {
4911
+ return _ref2.apply(this, arguments);
4809
4912
  };
4810
4913
  }();
4811
4914
 
@@ -4813,11 +4916,11 @@ var Chatbox = function Chatbox(props) {
4813
4916
  var tempLastContent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('');
4814
4917
  var streamController = src_useStreamController({
4815
4918
  onChunk: function () {
4816
- var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(chunk, index) {
4817
- var _args$onChunk, _args2;
4919
+ var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3(chunk, index) {
4920
+ var _args$onChunk, _args4;
4818
4921
  var res;
4819
- return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
4820
- while (1) switch (_context2.prev = _context2.next) {
4922
+ return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
4923
+ while (1) switch (_context3.prev = _context3.next) {
4821
4924
  case 0:
4822
4925
  // start (Execute it only once)
4823
4926
  if (index === 0) {
@@ -4826,50 +4929,50 @@ var Chatbox = function Chatbox(props) {
4826
4929
  }
4827
4930
 
4828
4931
  //
4829
- _context2.next = 3;
4932
+ _context3.next = 3;
4830
4933
  return parseChunkData(chunk, index, false);
4831
4934
  case 3:
4832
- res = _context2.sent;
4935
+ res = _context3.sent;
4833
4936
  //
4834
- (_args$onChunk = (_args2 = args()).onChunk) === null || _args$onChunk === void 0 ? void 0 : _args$onChunk.call(_args2, inputContentRef.current, res, conversationHistory.current);
4937
+ (_args$onChunk = (_args4 = args()).onChunk) === null || _args$onChunk === void 0 ? void 0 : _args$onChunk.call(_args4, inputContentRef.current, res, conversationHistory.current);
4835
4938
  case 5:
4836
4939
  case "end":
4837
- return _context2.stop();
4940
+ return _context3.stop();
4838
4941
  }
4839
- }, _callee2);
4942
+ }, _callee3);
4840
4943
  }));
4841
- function onChunk(_x5, _x6) {
4944
+ function onChunk(_x8, _x9) {
4842
4945
  return _onChunk.apply(this, arguments);
4843
4946
  }
4844
4947
  return onChunk;
4845
4948
  }(),
4846
4949
  onComplete: function () {
4847
- var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3(lastContent) {
4848
- var _args$onComplete, _args4;
4950
+ var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4(lastContent) {
4951
+ var _args$onComplete, _args6;
4849
4952
  var res;
4850
- return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
4851
- while (1) switch (_context3.prev = _context3.next) {
4953
+ return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
4954
+ while (1) switch (_context4.prev = _context4.next) {
4852
4955
  case 0:
4853
4956
  console.log('--> Stream complete');
4854
- _context3.next = 3;
4957
+ _context4.next = 3;
4855
4958
  return parseChunkData(lastContent, 0, true);
4856
4959
  case 3:
4857
- res = _context3.sent;
4960
+ res = _context4.sent;
4858
4961
  // Display AI reply
4859
4962
  displayMessage(args().answerNameRes, res);
4860
4963
 
4861
4964
  //
4862
- (_args$onComplete = (_args4 = args()).onComplete) === null || _args$onComplete === void 0 ? void 0 : _args$onComplete.call(_args4, inputContentRef.current, res, conversationHistory.current);
4965
+ (_args$onComplete = (_args6 = args()).onComplete) === null || _args$onComplete === void 0 ? void 0 : _args$onComplete.call(_args6, inputContentRef.current, res, conversationHistory.current);
4863
4966
 
4864
4967
  //
4865
4968
  closeSSE();
4866
4969
  case 7:
4867
4970
  case "end":
4868
- return _context3.stop();
4971
+ return _context4.stop();
4869
4972
  }
4870
- }, _callee3);
4973
+ }, _callee4);
4871
4974
  }));
4872
- function onComplete(_x7) {
4975
+ function onComplete(_x10) {
4873
4976
  return _onComplete.apply(this, arguments);
4874
4977
  }
4875
4978
  return onComplete;
@@ -4918,34 +5021,34 @@ var Chatbox = function Chatbox(props) {
4918
5021
  });
4919
5022
  };
4920
5023
  var sendMessage = /*#__PURE__*/function () {
4921
- var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4() {
4922
- var messageInput, message, inputMsg, res, _args$onChunk2, _args6, _args$onComplete2, _args7, reply, replyRes;
4923
- return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
4924
- while (1) switch (_context4.prev = _context4.next) {
5024
+ var _ref3 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5() {
5025
+ var messageInput, message, inputMsg, res, _args$onChunk2, _args8, _args$onComplete2, _args9, reply, replyRes;
5026
+ return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
5027
+ while (1) switch (_context5.prev = _context5.next) {
4925
5028
  case 0:
4926
5029
  if (!(rootRef.current === null || msgContainerRef.current === null || msInput.current === null)) {
4927
- _context4.next = 2;
5030
+ _context5.next = 2;
4928
5031
  break;
4929
5032
  }
4930
- return _context4.abrupt("return");
5033
+ return _context5.abrupt("return");
4931
5034
  case 2:
4932
5035
  messageInput = msInput.current;
4933
5036
  message = (0,sanitize.htmlEncode)(messageInput.value); // It fires in real time as the user enters
4934
5037
  // Sanitizing input is the process of securing/cleaning/filtering input data.
4935
5038
  if (!(typeof args().onInputCallback === 'function')) {
4936
- _context4.next = 8;
5039
+ _context5.next = 8;
4937
5040
  break;
4938
5041
  }
4939
- _context4.next = 7;
5042
+ _context5.next = 7;
4940
5043
  return args().onInputCallback(message);
4941
5044
  case 7:
4942
- message = _context4.sent;
5045
+ message = _context5.sent;
4943
5046
  case 8:
4944
5047
  if (!(message.trim() === '')) {
4945
- _context4.next = 10;
5048
+ _context5.next = 10;
4946
5049
  break;
4947
5050
  }
4948
- return _context4.abrupt("return");
5051
+ return _context5.abrupt("return");
4949
5052
  case 10:
4950
5053
  // Start the timer
4951
5054
  setElapsedTime(0); // Reset elapsed time
@@ -4958,13 +5061,13 @@ var Chatbox = function Chatbox(props) {
4958
5061
  // user message
4959
5062
  inputMsg = "".concat(message); // If a render parser exists, it is used to process the string
4960
5063
  if (!(typeof args().renderParser === 'function')) {
4961
- _context4.next = 17;
5064
+ _context5.next = 17;
4962
5065
  break;
4963
5066
  }
4964
- _context4.next = 16;
5067
+ _context5.next = 16;
4965
5068
  return args().renderParser(inputMsg);
4966
5069
  case 16:
4967
- inputMsg = _context4.sent;
5070
+ inputMsg = _context5.sent;
4968
5071
  case 17:
4969
5072
  displayMessage(args().questionNameRes, inputMsg); // Display user message
4970
5073
 
@@ -4976,48 +5079,48 @@ var Chatbox = function Chatbox(props) {
4976
5079
 
4977
5080
  // clear
4978
5081
  if (inputContentRef.current) inputContentRef.current.clear();
4979
- _context4.prev = 21;
4980
- _context4.next = 24;
5082
+ _context5.prev = 21;
5083
+ _context5.next = 24;
4981
5084
  return mainRequest(message);
4982
5085
  case 24:
4983
- res = _context4.sent;
5086
+ res = _context5.sent;
4984
5087
  if (res.useStreamRender) {
4985
- _context4.next = 36;
5088
+ _context5.next = 36;
4986
5089
  break;
4987
5090
  }
4988
5091
  reply = res.reply;
4989
5092
  replyRes = "".concat(reply); // If a render parser exists, it is used to process the string
4990
5093
  if (!(typeof args().renderParser === 'function')) {
4991
- _context4.next = 32;
5094
+ _context5.next = 32;
4992
5095
  break;
4993
5096
  }
4994
- _context4.next = 31;
5097
+ _context5.next = 31;
4995
5098
  return args().renderParser(replyRes);
4996
5099
  case 31:
4997
- replyRes = _context4.sent;
5100
+ replyRes = _context5.sent;
4998
5101
  case 32:
4999
5102
  displayMessage(args().answerNameRes, replyRes); // Display AI reply
5000
5103
 
5001
5104
  //
5002
- (_args$onChunk2 = (_args6 = args()).onChunk) === null || _args$onChunk2 === void 0 ? void 0 : _args$onChunk2.call(_args6, inputContentRef.current, replyRes, conversationHistory.current);
5003
- (_args$onComplete2 = (_args7 = args()).onComplete) === null || _args$onComplete2 === void 0 ? void 0 : _args$onComplete2.call(_args7, inputContentRef.current, replyRes, conversationHistory.current);
5105
+ (_args$onChunk2 = (_args8 = args()).onChunk) === null || _args$onChunk2 === void 0 ? void 0 : _args$onChunk2.call(_args8, inputContentRef.current, replyRes, conversationHistory.current);
5106
+ (_args$onComplete2 = (_args9 = args()).onComplete) === null || _args$onComplete2 === void 0 ? void 0 : _args$onComplete2.call(_args9, inputContentRef.current, replyRes, conversationHistory.current);
5004
5107
 
5005
5108
  //reset SSE
5006
5109
  closeSSE();
5007
5110
  case 36:
5008
- _context4.next = 45;
5111
+ _context5.next = 45;
5009
5112
  break;
5010
5113
  case 38:
5011
- _context4.prev = 38;
5012
- _context4.t0 = _context4["catch"](21);
5114
+ _context5.prev = 38;
5115
+ _context5.t0 = _context5["catch"](21);
5013
5116
  // loading
5014
5117
  setLoading(false);
5015
5118
 
5016
5119
  // Stop the timer
5017
5120
  clearInterval(timer.current);
5018
5121
  timer.current = null;
5019
- console.error('--> Error sending message:', _context4.t0);
5020
- displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(_context4.t0))); // Display AI reply
5122
+ console.error('--> Error sending message:', _context5.t0);
5123
+ displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(_context5.t0))); // Display AI reply
5021
5124
  case 45:
5022
5125
  // clear
5023
5126
  messageInput.value = '';
@@ -5029,12 +5132,12 @@ var Chatbox = function Chatbox(props) {
5029
5132
  scrollToBottom();
5030
5133
  case 48:
5031
5134
  case "end":
5032
- return _context4.stop();
5135
+ return _context5.stop();
5033
5136
  }
5034
- }, _callee4, null, [[21, 38]]);
5137
+ }, _callee5, null, [[21, 38]]);
5035
5138
  }));
5036
5139
  return function sendMessage() {
5037
- return _ref2.apply(this, arguments);
5140
+ return _ref3.apply(this, arguments);
5038
5141
  };
5039
5142
  }();
5040
5143
  var handleClickSafe = useDebounce_default()(function () {
@@ -5046,25 +5149,25 @@ var Chatbox = function Chatbox(props) {
5046
5149
  setShow(false);
5047
5150
  };
5048
5151
  var mainRequest = /*#__PURE__*/function () {
5049
- var _ref3 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5(msg) {
5152
+ var _ref4 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee6(msg) {
5050
5153
  var currentStreamMode, requestBodyRes, customResponse, content, isStream, contentRes, response, _errInfo, _args$responseExtract2, extractPath, _response, _errInfo2, jsonResponse, result, _iterator3, _step3, path, _content2, _err;
5051
- return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
5052
- while (1) switch (_context5.prev = _context5.next) {
5154
+ return src_regeneratorRuntime().wrap(function _callee6$(_context6) {
5155
+ while (1) switch (_context6.prev = _context6.next) {
5053
5156
  case 0:
5054
5157
  currentStreamMode = args().isStream; // Update stream mode
5055
5158
  setEnableStreamMode(currentStreamMode);
5056
- _context5.prev = 2;
5159
+ _context6.prev = 2;
5057
5160
  // Parse and interpolate request body template
5058
5161
  requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
5059
5162
  // If a formatter function exists, it is used to process the request body
5060
5163
  if (!(typeof args().requestBodyFormatter === 'function')) {
5061
- _context5.next = 8;
5164
+ _context6.next = 8;
5062
5165
  break;
5063
5166
  }
5064
- _context5.next = 7;
5167
+ _context6.next = 7;
5065
5168
  return args().requestBodyFormatter(requestBodyRes, args().latestContextData, conversationHistory.current);
5066
5169
  case 7:
5067
- requestBodyRes = _context5.sent;
5170
+ requestBodyRes = _context6.sent;
5068
5171
  case 8:
5069
5172
  // Scroll to the bottom
5070
5173
  setTimeout(function () {
@@ -5072,19 +5175,19 @@ var Chatbox = function Chatbox(props) {
5072
5175
  scrollToBottom();
5073
5176
  }, 500);
5074
5177
  if (!(typeof args().customRequest === 'function')) {
5075
- _context5.next = 25;
5178
+ _context6.next = 25;
5076
5179
  break;
5077
5180
  }
5078
5181
  // Update stream mode
5079
5182
  setEnableStreamMode(false);
5080
- _context5.next = 13;
5183
+ _context6.next = 13;
5081
5184
  return args().customRequest(msg, {
5082
5185
  requestBody: requestBodyRes,
5083
5186
  apiUrl: args().requestApiUrl || '',
5084
5187
  headers: args().headerConfigRes
5085
5188
  });
5086
5189
  case 13:
5087
- customResponse = _context5.sent;
5190
+ customResponse = _context6.sent;
5088
5191
  content = customResponse.content, isStream = customResponse.isStream;
5089
5192
  contentRes = content; // Update stream mode
5090
5193
  setEnableStreamMode(isStream);
@@ -5092,24 +5195,24 @@ var Chatbox = function Chatbox(props) {
5092
5195
  // NORMAL
5093
5196
  //++++++++++++++++++++++++++++++++++++++++++++++++
5094
5197
  if (!(!isStream && typeof contentRes === 'string' && contentRes.trim() !== '')) {
5095
- _context5.next = 20;
5198
+ _context6.next = 20;
5096
5199
  break;
5097
5200
  }
5098
5201
  // Replace with a valid label
5099
5202
  contentRes = fixHtmlTags(contentRes, args().withReasoning, args().reasoningSwitchLabel);
5100
- return _context5.abrupt("return", {
5203
+ return _context6.abrupt("return", {
5101
5204
  reply: formatLatestDisplayContent(contentRes),
5102
5205
  useStreamRender: false
5103
5206
  });
5104
5207
  case 20:
5105
5208
  if (!(isStream && isStreamResponse(contentRes))) {
5106
- _context5.next = 24;
5209
+ _context6.next = 24;
5107
5210
  break;
5108
5211
  }
5109
- _context5.next = 23;
5212
+ _context6.next = 23;
5110
5213
  return streamController.start(contentRes);
5111
5214
  case 23:
5112
- return _context5.abrupt("return", {
5215
+ return _context6.abrupt("return", {
5113
5216
  reply: tempAnimText,
5114
5217
  // The final content will be in tempAnimText
5115
5218
  useStreamRender: true
@@ -5123,19 +5226,19 @@ var Chatbox = function Chatbox(props) {
5123
5226
  }
5124
5227
  case 25:
5125
5228
  if (!currentStreamMode) {
5126
- _context5.next = 39;
5229
+ _context6.next = 39;
5127
5230
  break;
5128
5231
  }
5129
- _context5.next = 28;
5232
+ _context6.next = 28;
5130
5233
  return fetch(args().requestApiUrl || '', {
5131
5234
  method: "POST",
5132
5235
  body: JSON.stringify(requestBodyRes),
5133
5236
  headers: args().headerConfigRes
5134
5237
  });
5135
5238
  case 28:
5136
- response = _context5.sent;
5239
+ response = _context6.sent;
5137
5240
  if (response.ok) {
5138
- _context5.next = 34;
5241
+ _context6.next = 34;
5139
5242
  break;
5140
5243
  }
5141
5244
  _errInfo = "[ERROR] HTTP Error ".concat(response.status, ": ").concat(response.statusText);
@@ -5143,15 +5246,15 @@ var Chatbox = function Chatbox(props) {
5143
5246
 
5144
5247
  // hide loader
5145
5248
  setLoaderDisplay(false);
5146
- return _context5.abrupt("return", {
5249
+ return _context6.abrupt("return", {
5147
5250
  reply: _errInfo,
5148
5251
  useStreamRender: false
5149
5252
  });
5150
5253
  case 34:
5151
- _context5.next = 36;
5254
+ _context6.next = 36;
5152
5255
  return streamController.start(response);
5153
5256
  case 36:
5154
- return _context5.abrupt("return", {
5257
+ return _context6.abrupt("return", {
5155
5258
  reply: tempAnimText,
5156
5259
  // The final content will be in tempAnimText
5157
5260
  useStreamRender: true
@@ -5159,7 +5262,7 @@ var Chatbox = function Chatbox(props) {
5159
5262
  case 39:
5160
5263
  // Extract response using the path
5161
5264
  extractPath = (_args$responseExtract2 = args().responseExtractPath) === null || _args$responseExtract2 === void 0 ? void 0 : _args$responseExtract2.slice(1);
5162
- _context5.next = 42;
5265
+ _context6.next = 42;
5163
5266
  return fetch(args().requestApiUrl || '', {
5164
5267
  method: "POST",
5165
5268
  headers: args().headerConfigRes,
@@ -5167,22 +5270,22 @@ var Chatbox = function Chatbox(props) {
5167
5270
  signal: abortController.current.signal
5168
5271
  });
5169
5272
  case 42:
5170
- _response = _context5.sent;
5273
+ _response = _context6.sent;
5171
5274
  if (_response.ok) {
5172
- _context5.next = 47;
5275
+ _context6.next = 47;
5173
5276
  break;
5174
5277
  }
5175
5278
  _errInfo2 = "[ERROR] HTTP Error ".concat(_response.status, ": ").concat(_response.statusText); // hide loader
5176
5279
  setLoaderDisplay(false);
5177
- return _context5.abrupt("return", {
5280
+ return _context6.abrupt("return", {
5178
5281
  reply: _errInfo2,
5179
5282
  useStreamRender: false
5180
5283
  });
5181
5284
  case 47:
5182
- _context5.next = 49;
5285
+ _context6.next = 49;
5183
5286
  return _response.json();
5184
5287
  case 49:
5185
- jsonResponse = _context5.sent;
5288
+ jsonResponse = _context6.sent;
5186
5289
  // hide loader
5187
5290
  setLoaderDisplay(false);
5188
5291
  result = jsonResponse;
@@ -5201,33 +5304,33 @@ var Chatbox = function Chatbox(props) {
5201
5304
  }
5202
5305
  _content2 = result; // Replace with a valid label
5203
5306
  _content2 = fixHtmlTags(_content2, args().withReasoning, args().reasoningSwitchLabel);
5204
- return _context5.abrupt("return", {
5307
+ return _context6.abrupt("return", {
5205
5308
  reply: formatLatestDisplayContent(_content2),
5206
5309
  useStreamRender: false
5207
5310
  });
5208
5311
  case 56:
5209
- _context5.next = 64;
5312
+ _context6.next = 64;
5210
5313
  break;
5211
5314
  case 58:
5212
- _context5.prev = 58;
5213
- _context5.t0 = _context5["catch"](2);
5214
- _err = "--> Error in mainRequest: ".concat(_context5.t0);
5315
+ _context6.prev = 58;
5316
+ _context6.t0 = _context6["catch"](2);
5317
+ _err = "--> Error in mainRequest: ".concat(_context6.t0);
5215
5318
  console.error(_err);
5216
5319
 
5217
5320
  //reset SSE
5218
5321
  closeSSE();
5219
- return _context5.abrupt("return", {
5322
+ return _context6.abrupt("return", {
5220
5323
  reply: _err,
5221
5324
  useStreamRender: false
5222
5325
  });
5223
5326
  case 64:
5224
5327
  case "end":
5225
- return _context5.stop();
5328
+ return _context6.stop();
5226
5329
  }
5227
- }, _callee5, null, [[2, 58]]);
5330
+ }, _callee6, null, [[2, 58]]);
5228
5331
  }));
5229
- return function mainRequest(_x8) {
5230
- return _ref3.apply(this, arguments);
5332
+ return function mainRequest(_x11) {
5333
+ return _ref4.apply(this, arguments);
5231
5334
  };
5232
5335
  }();
5233
5336
 
@@ -5299,7 +5402,7 @@ var Chatbox = function Chatbox(props) {
5299
5402
  className: "".concat(args().prefix || 'custom-', "chatbox-container"),
5300
5403
  ref: rootRef
5301
5404
  }, msgList.length === 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5302
- className: "d-flex flex-column align-items-center justify-content-center h-50"
5405
+ className: "d-flex flex-column align-items-center justify-content-center ".concat(hasQuestion() ? '' : 'h-50')
5303
5406
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("p", null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
5304
5407
  width: "70px",
5305
5408
  height: "70px",
@@ -5326,7 +5429,25 @@ var Chatbox = function Chatbox(props) {
5326
5429
  dangerouslySetInnerHTML: {
5327
5430
  __html: "".concat(args().noDataPlaceholder)
5328
5431
  }
5329
- }))) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5432
+ }), hasQuestion() && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5433
+ className: "default-questions"
5434
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5435
+ className: "default-questions-title",
5436
+ dangerouslySetInnerHTML: {
5437
+ __html: "".concat(args().defaultQuestionsRes.title)
5438
+ }
5439
+ }), (_list = args().defaultQuestionsRes.list) === null || _list === void 0 ? void 0 : _list.map(function (question, index) {
5440
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5441
+ key: index,
5442
+ className: "default-question-item",
5443
+ onClick: function onClick() {
5444
+ return handleQuestionClick(question);
5445
+ },
5446
+ dangerouslySetInnerHTML: {
5447
+ __html: "".concat(question)
5448
+ }
5449
+ });
5450
+ })))) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5330
5451
  className: "messages",
5331
5452
  ref: msgContainerRef
5332
5453
  }, msgList.map(function (msg, index) {
@@ -5464,8 +5585,8 @@ var Chatbox = function Chatbox(props) {
5464
5585
  }
5465
5586
  },
5466
5587
  onChange: function onChange(e) {
5467
- var _args$onInputChange, _args10;
5468
- (_args$onInputChange = (_args10 = args()).onInputChange) === null || _args$onInputChange === void 0 ? void 0 : _args$onInputChange.call(_args10, inputContentRef.current, e.target.value);
5588
+ var _args$onInputChange, _args12;
5589
+ (_args$onInputChange = (_args12 = args()).onInputChange) === null || _args$onInputChange === void 0 ? void 0 : _args$onInputChange.call(_args12, inputContentRef.current, e.target.value);
5469
5590
  },
5470
5591
  rows: args().defaultRows || 3,
5471
5592
  autoSize: true,
@@ -5512,6 +5633,7 @@ var Chatbox = function Chatbox(props) {
5512
5633
  display: loading ? 'block' : 'none'
5513
5634
  }
5514
5635
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_PureLoader, {
5636
+ prefix: args().prefix,
5515
5637
  customClassName: "w-100",
5516
5638
  txt: ""
5517
5639
  }))) : null, args().toolkitButtons && args().toolkitButtons.length > 0 && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
@@ -5521,7 +5643,7 @@ var Chatbox = function Chatbox(props) {
5521
5643
  var _id = "".concat(args().prefix || 'custom-', "chatbox-btn-tools-").concat(chatId).concat(index);
5522
5644
  var isActive = activeButtons[_id];
5523
5645
  if (btn.isSelect) {
5524
- var options = getButtonOptions(btn);
5646
+ var options = getButtonOptions(btn, _id);
5525
5647
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5526
5648
  key: index,
5527
5649
  className: "toolkit-select-wrapper"
@@ -5533,6 +5655,9 @@ var Chatbox = function Chatbox(props) {
5533
5655
  setActiveButtons(function (prev) {
5534
5656
  return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, _id, !prev[_id]));
5535
5657
  });
5658
+
5659
+ //
5660
+ executeButtonAction(btn.onClick, _id, e.currentTarget);
5536
5661
  }
5537
5662
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
5538
5663
  dangerouslySetInnerHTML: {
@@ -5558,7 +5683,7 @@ var Chatbox = function Chatbox(props) {
5558
5683
  d: "M144,6525.39 L142.594,6524 L133.987,6532.261 L133.069,6531.38 L133.074,6531.385 L125.427,6524.045 L124,6525.414 C126.113,6527.443 132.014,6533.107 133.987,6535 C135.453,6533.594 134.024,6534.965 144,6525.39"
5559
5684
  }))))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5560
5685
  className: "toolkit-select-options ".concat(isActive ? 'active' : '')
5561
- }, options.map(function (option, optIndex) {
5686
+ }, options.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, options.map(function (option, optIndex) {
5562
5687
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5563
5688
  key: optIndex,
5564
5689
  className: "toolkit-select-option ".concat(option.value || '', " ").concat(selectedOpt.curIndex === optIndex ? 'selected' : ''),
@@ -5570,7 +5695,9 @@ var Chatbox = function Chatbox(props) {
5570
5695
  __html: option.label
5571
5696
  }
5572
5697
  }));
5573
- })));
5698
+ })) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
5699
+ className: "".concat(args().prefix || 'custom-', "chatbox-mini-loader")
5700
+ }))));
5574
5701
  }
5575
5702
 
5576
5703
  // The rendering of the normal button