funda-ui 4.6.151 → 4.6.333
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Chatbox/index.css +88 -14
- package/Chatbox/index.d.ts +5 -0
- package/Chatbox/index.js +457 -281
- package/Utils/format-string.d.ts +64 -0
- package/Utils/format-string.js +157 -0
- package/lib/cjs/Chatbox/index.d.ts +5 -0
- package/lib/cjs/Chatbox/index.js +457 -281
- package/lib/cjs/Utils/format-string.d.ts +64 -0
- package/lib/cjs/Utils/format-string.js +157 -0
- package/lib/css/Chatbox/index.css +88 -14
- package/lib/esm/Chatbox/PureLoader.tsx +4 -2
- package/lib/esm/Chatbox/TypingEffect.tsx +12 -41
- package/lib/esm/Chatbox/index.scss +118 -28
- package/lib/esm/Chatbox/index.tsx +148 -36
- package/lib/esm/Chatbox/utils/func.ts +52 -1
- package/lib/esm/Textarea/index.tsx +0 -2
- package/lib/esm/Utils/libs/format-string.ts +106 -0
- package/package.json +1 -1
package/lib/cjs/Chatbox/index.js
CHANGED
|
@@ -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
|
|
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: "
|
|
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: "
|
|
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,19 +4201,19 @@ 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; } } }; }
|
|
4188
|
-
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
|
-
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
4205
|
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; }
|
|
4191
4206
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4192
4207
|
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
4208
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return src_typeof(key) === "symbol" ? key : String(key); }
|
|
4194
4209
|
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); }
|
|
4210
|
+
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; }
|
|
4211
|
+
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); } }
|
|
4212
|
+
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); }); }; }
|
|
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); }
|
|
@@ -4298,8 +4320,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
4298
4320
|
setShow(false);
|
|
4299
4321
|
},
|
|
4300
4322
|
clearData: function clearData() {
|
|
4301
|
-
|
|
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
|
},
|
|
@@ -4387,9 +4415,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4387
4415
|
maxHistoryLength = currentProps.maxHistoryLength,
|
|
4388
4416
|
customRequest = currentProps.customRequest,
|
|
4389
4417
|
onQuestionClick = currentProps.onQuestionClick,
|
|
4418
|
+
onCopyCallback = currentProps.onCopyCallback,
|
|
4390
4419
|
renderParser = currentProps.renderParser,
|
|
4391
4420
|
requestBodyFormatter = currentProps.requestBodyFormatter,
|
|
4421
|
+
copiedContentFormatter = currentProps.copiedContentFormatter,
|
|
4392
4422
|
nameFormatter = currentProps.nameFormatter,
|
|
4423
|
+
showCopyBtn = currentProps.showCopyBtn,
|
|
4424
|
+
autoCopyReply = currentProps.autoCopyReply,
|
|
4393
4425
|
onInputChange = currentProps.onInputChange,
|
|
4394
4426
|
onInputCallback = currentProps.onInputCallback,
|
|
4395
4427
|
onChunk = currentProps.onChunk,
|
|
@@ -4453,9 +4485,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4453
4485
|
newChatButton: newChatButton,
|
|
4454
4486
|
customRequest: customRequest,
|
|
4455
4487
|
onQuestionClick: onQuestionClick,
|
|
4488
|
+
onCopyCallback: onCopyCallback,
|
|
4456
4489
|
renderParser: renderParser,
|
|
4457
4490
|
requestBodyFormatter: requestBodyFormatter,
|
|
4491
|
+
copiedContentFormatter: copiedContentFormatter,
|
|
4458
4492
|
nameFormatter: nameFormatter,
|
|
4493
|
+
showCopyBtn: showCopyBtn,
|
|
4494
|
+
autoCopyReply: autoCopyReply,
|
|
4459
4495
|
onInputChange: onInputChange,
|
|
4460
4496
|
onInputCallback: onInputCallback,
|
|
4461
4497
|
onChunk: onChunk,
|
|
@@ -4474,6 +4510,77 @@ var Chatbox = function Chatbox(props) {
|
|
|
4474
4510
|
};
|
|
4475
4511
|
};
|
|
4476
4512
|
|
|
4513
|
+
//================================================================
|
|
4514
|
+
// Clipboard
|
|
4515
|
+
//================================================================
|
|
4516
|
+
var chatboxCopyToClipboard = /*#__PURE__*/function () {
|
|
4517
|
+
var _ref = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(text) {
|
|
4518
|
+
var _content, _args$onCopyCallback, _args, textArea, _args$onCopyCallback2, _args2, _args$onCopyCallback3, _args3;
|
|
4519
|
+
return src_regeneratorRuntime().wrap(function _callee$(_context) {
|
|
4520
|
+
while (1) switch (_context.prev = _context.next) {
|
|
4521
|
+
case 0:
|
|
4522
|
+
_content = text;
|
|
4523
|
+
if (typeof args().copiedContentFormatter === 'function') {
|
|
4524
|
+
_content = args().copiedContentFormatter(text);
|
|
4525
|
+
}
|
|
4526
|
+
_context.prev = 2;
|
|
4527
|
+
if (!(navigator.clipboard && window.isSecureContext)) {
|
|
4528
|
+
_context.next = 8;
|
|
4529
|
+
break;
|
|
4530
|
+
}
|
|
4531
|
+
_context.next = 6;
|
|
4532
|
+
return navigator.clipboard.writeText(_content);
|
|
4533
|
+
case 6:
|
|
4534
|
+
(_args$onCopyCallback = (_args = args()).onCopyCallback) === null || _args$onCopyCallback === void 0 ? void 0 : _args$onCopyCallback.call(_args, {
|
|
4535
|
+
success: true,
|
|
4536
|
+
message: 'Text copied to clipboard'
|
|
4537
|
+
});
|
|
4538
|
+
return _context.abrupt("return", true);
|
|
4539
|
+
case 8:
|
|
4540
|
+
// Fallback for older browsers
|
|
4541
|
+
textArea = document.createElement('textarea');
|
|
4542
|
+
textArea.value = _content;
|
|
4543
|
+
textArea.style.position = 'fixed';
|
|
4544
|
+
textArea.style.left = '-999999px';
|
|
4545
|
+
textArea.style.top = '-999999px';
|
|
4546
|
+
document.body.appendChild(textArea);
|
|
4547
|
+
textArea.focus();
|
|
4548
|
+
textArea.select();
|
|
4549
|
+
_context.prev = 16;
|
|
4550
|
+
document.execCommand('copy');
|
|
4551
|
+
textArea.remove();
|
|
4552
|
+
(_args$onCopyCallback2 = (_args2 = args()).onCopyCallback) === null || _args$onCopyCallback2 === void 0 ? void 0 : _args$onCopyCallback2.call(_args2, {
|
|
4553
|
+
success: true,
|
|
4554
|
+
message: 'Text copied to clipboard'
|
|
4555
|
+
});
|
|
4556
|
+
return _context.abrupt("return", true);
|
|
4557
|
+
case 23:
|
|
4558
|
+
_context.prev = 23;
|
|
4559
|
+
_context.t0 = _context["catch"](16);
|
|
4560
|
+
textArea.remove();
|
|
4561
|
+
return _context.abrupt("return", false);
|
|
4562
|
+
case 27:
|
|
4563
|
+
_context.next = 33;
|
|
4564
|
+
break;
|
|
4565
|
+
case 29:
|
|
4566
|
+
_context.prev = 29;
|
|
4567
|
+
_context.t1 = _context["catch"](2);
|
|
4568
|
+
(_args$onCopyCallback3 = (_args3 = args()).onCopyCallback) === null || _args$onCopyCallback3 === void 0 ? void 0 : _args$onCopyCallback3.call(_args3, {
|
|
4569
|
+
success: false,
|
|
4570
|
+
message: "Failed to copy text: ".concat(_context.t1)
|
|
4571
|
+
});
|
|
4572
|
+
return _context.abrupt("return", false);
|
|
4573
|
+
case 33:
|
|
4574
|
+
case "end":
|
|
4575
|
+
return _context.stop();
|
|
4576
|
+
}
|
|
4577
|
+
}, _callee, null, [[2, 29], [16, 23]]);
|
|
4578
|
+
}));
|
|
4579
|
+
return function chatboxCopyToClipboard(_x2) {
|
|
4580
|
+
return _ref.apply(this, arguments);
|
|
4581
|
+
};
|
|
4582
|
+
}();
|
|
4583
|
+
|
|
4477
4584
|
//================================================================
|
|
4478
4585
|
// Custom Questions
|
|
4479
4586
|
//================================================================
|
|
@@ -4490,11 +4597,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
4490
4597
|
return args().defaultQuestionsRes && args().defaultQuestionsRes.list.length > 0;
|
|
4491
4598
|
};
|
|
4492
4599
|
var handleQuestionClick = function handleQuestionClick(text) {
|
|
4493
|
-
var _args$onQuestionClick,
|
|
4600
|
+
var _args$onQuestionClick, _args5;
|
|
4494
4601
|
if (inputContentRef.current) {
|
|
4495
4602
|
inputContentRef.current.set(text);
|
|
4496
4603
|
}
|
|
4497
|
-
(_args$onQuestionClick = (
|
|
4604
|
+
(_args$onQuestionClick = (_args5 = args()).onQuestionClick) === null || _args$onQuestionClick === void 0 ? void 0 : _args$onQuestionClick.call(_args5, text, exposedMethods());
|
|
4498
4605
|
};
|
|
4499
4606
|
|
|
4500
4607
|
//================================================================
|
|
@@ -4519,34 +4626,83 @@ var Chatbox = function Chatbox(props) {
|
|
|
4519
4626
|
return newState;
|
|
4520
4627
|
});
|
|
4521
4628
|
};
|
|
4522
|
-
var executeButtonAction = function
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4629
|
+
var executeButtonAction = /*#__PURE__*/function () {
|
|
4630
|
+
var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(actionStr, buttonId, buttonElement) {
|
|
4631
|
+
var actionFn, result, options, newState;
|
|
4632
|
+
return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
4633
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
4634
|
+
case 0:
|
|
4635
|
+
_context2.prev = 0;
|
|
4636
|
+
actionFn = new Function('method', 'isActive', 'button', actionStr); // !!!REQUIRED "await"
|
|
4637
|
+
// "customMethods" may be asynchronous
|
|
4638
|
+
_context2.next = 4;
|
|
4639
|
+
return actionFn(exposedMethods(), !activeButtons[buttonId], buttonElement);
|
|
4640
|
+
case 4:
|
|
4641
|
+
result = _context2.sent;
|
|
4642
|
+
// If the returned result is an array, it is a dynamic option
|
|
4643
|
+
if (Array.isArray(result) && Object.keys(dynamicOptions).length === 0) {
|
|
4644
|
+
options = result.map(function (item) {
|
|
4645
|
+
var _Object$entries$ = src_slicedToArray(Object.entries(item)[0], 2),
|
|
4646
|
+
key = _Object$entries$[0],
|
|
4647
|
+
value = _Object$entries$[1];
|
|
4648
|
+
var _split$map = value.split('{#}').map(function (s) {
|
|
4649
|
+
return s.trim();
|
|
4650
|
+
}),
|
|
4651
|
+
_split$map2 = src_slicedToArray(_split$map, 3),
|
|
4652
|
+
label = _split$map2[0],
|
|
4653
|
+
val = _split$map2[1],
|
|
4654
|
+
onClick = _split$map2[2];
|
|
4655
|
+
return {
|
|
4656
|
+
label: label,
|
|
4657
|
+
value: val,
|
|
4658
|
+
onClick: onClick
|
|
4659
|
+
};
|
|
4660
|
+
}); // Update dynamic options
|
|
4661
|
+
setDynamicOptions(function (prev) {
|
|
4662
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, options));
|
|
4663
|
+
});
|
|
4664
|
+
}
|
|
4532
4665
|
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4542
|
-
|
|
4666
|
+
// Update the button status
|
|
4667
|
+
newState = !activeButtons[buttonId];
|
|
4668
|
+
setActiveButtons(function (prev) {
|
|
4669
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, buttonId, newState));
|
|
4670
|
+
});
|
|
4671
|
+
return _context2.abrupt("return", result);
|
|
4672
|
+
case 11:
|
|
4673
|
+
_context2.prev = 11;
|
|
4674
|
+
_context2.t0 = _context2["catch"](0);
|
|
4675
|
+
console.error('Error executing button action:', _context2.t0);
|
|
4676
|
+
case 14:
|
|
4677
|
+
case "end":
|
|
4678
|
+
return _context2.stop();
|
|
4679
|
+
}
|
|
4680
|
+
}, _callee2, null, [[0, 11]]);
|
|
4681
|
+
}));
|
|
4682
|
+
return function executeButtonAction(_x3, _x4, _x5) {
|
|
4683
|
+
return _ref2.apply(this, arguments);
|
|
4684
|
+
};
|
|
4685
|
+
}();
|
|
4543
4686
|
|
|
4544
4687
|
// options
|
|
4545
4688
|
var _useState21 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4546
4689
|
_useState22 = src_slicedToArray(_useState21, 2),
|
|
4547
4690
|
selectedOpt = _useState22[0],
|
|
4548
4691
|
setSelectedOpt = _useState22[1];
|
|
4549
|
-
|
|
4692
|
+
// Store dynamic options
|
|
4693
|
+
var _useState23 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
|
|
4694
|
+
_useState24 = src_slicedToArray(_useState23, 2),
|
|
4695
|
+
dynamicOptions = _useState24[0],
|
|
4696
|
+
setDynamicOptions = _useState24[1];
|
|
4697
|
+
var getButtonOptions = function getButtonOptions(btn, buttonId) {
|
|
4698
|
+
// If you are using the dynamic option and already have a cache, return the option for caching
|
|
4699
|
+
//---------
|
|
4700
|
+
if (btn.dynamicOptions && dynamicOptions[buttonId]) {
|
|
4701
|
+
return dynamicOptions[buttonId];
|
|
4702
|
+
}
|
|
4703
|
+
|
|
4704
|
+
// Use the static option from "props"
|
|
4705
|
+
//---------
|
|
4550
4706
|
var options = [];
|
|
4551
4707
|
var index = 1;
|
|
4552
4708
|
while (true) {
|
|
@@ -4580,8 +4736,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
4580
4736
|
});
|
|
4581
4737
|
} else {
|
|
4582
4738
|
setSelectedOpt(function (prev) {
|
|
4583
|
-
var
|
|
4584
|
-
return _objectSpread(_objectSpread({}, prev), {}, (
|
|
4739
|
+
var _objectSpread4;
|
|
4740
|
+
return _objectSpread(_objectSpread({}, prev), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, buttonId, option.label), _defineProperty(_objectSpread4, "curIndex", index), _defineProperty(_objectSpread4, "curValue", value), _objectSpread4));
|
|
4585
4741
|
});
|
|
4586
4742
|
}
|
|
4587
4743
|
executeButtonAction(option.onClick, buttonId, document.getElementById(buttonId));
|
|
@@ -4644,25 +4800,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
4644
4800
|
|
|
4645
4801
|
// parse chunk data
|
|
4646
4802
|
var parseChunkData = /*#__PURE__*/function () {
|
|
4647
|
-
var
|
|
4803
|
+
var _ref3 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3(chunk, index, complete) {
|
|
4648
4804
|
var lastContent, _args$responseExtract, extractPath, lines, _iterator, _step, line, _content, result, _iterator2, _step2, path, content, parsedContent, latestRes;
|
|
4649
|
-
return src_regeneratorRuntime().wrap(function
|
|
4650
|
-
while (1) switch (
|
|
4805
|
+
return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
4806
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
4651
4807
|
case 0:
|
|
4652
4808
|
// Store the final content and bind it to loading
|
|
4653
4809
|
lastContent = '';
|
|
4654
|
-
|
|
4810
|
+
_context3.prev = 1;
|
|
4655
4811
|
// Extract response using the path
|
|
4656
4812
|
extractPath = (_args$responseExtract = args().responseExtractPath) === null || _args$responseExtract === void 0 ? void 0 : _args$responseExtract.slice(1); // Streaming data is JSON split by rows
|
|
4657
4813
|
lines = chunk.split("\n").filter(function (line) {
|
|
4658
4814
|
return line.trim() !== "";
|
|
4659
4815
|
});
|
|
4660
4816
|
_iterator = _createForOfIteratorHelper(lines);
|
|
4661
|
-
|
|
4817
|
+
_context3.prev = 5;
|
|
4662
4818
|
_iterator.s();
|
|
4663
4819
|
case 7:
|
|
4664
4820
|
if ((_step = _iterator.n()).done) {
|
|
4665
|
-
|
|
4821
|
+
_context3.next = 45;
|
|
4666
4822
|
break;
|
|
4667
4823
|
}
|
|
4668
4824
|
line = _step.value;
|
|
@@ -4673,7 +4829,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
4673
4829
|
|
|
4674
4830
|
// Send the streamed data to the front end
|
|
4675
4831
|
if (!(line.indexOf('[DONE]') < 0)) {
|
|
4676
|
-
|
|
4832
|
+
_context3.next = 40;
|
|
4677
4833
|
break;
|
|
4678
4834
|
}
|
|
4679
4835
|
// STEP 1:
|
|
@@ -4681,14 +4837,14 @@ var Chatbox = function Chatbox(props) {
|
|
|
4681
4837
|
// Create a JSON string
|
|
4682
4838
|
_content = "".concat(line.replace(/^data:\s*/, '')); // Determine whether it is in JSON format
|
|
4683
4839
|
if (isValidJSON(_content)) {
|
|
4684
|
-
|
|
4840
|
+
_context3.next = 16;
|
|
4685
4841
|
break;
|
|
4686
4842
|
}
|
|
4687
4843
|
console.log('--> [ERROR] Wrong JSON format');
|
|
4688
4844
|
|
|
4689
4845
|
//reset SSE
|
|
4690
4846
|
closeSSE();
|
|
4691
|
-
return
|
|
4847
|
+
return _context3.abrupt("break", 45);
|
|
4692
4848
|
case 16:
|
|
4693
4849
|
// STEP 2:
|
|
4694
4850
|
// ------
|
|
@@ -4697,18 +4853,18 @@ var Chatbox = function Chatbox(props) {
|
|
|
4697
4853
|
// for Ollama API (STREAM END)
|
|
4698
4854
|
//*******
|
|
4699
4855
|
if (!(typeof result.done !== 'undefined')) {
|
|
4700
|
-
|
|
4856
|
+
_context3.next = 22;
|
|
4701
4857
|
break;
|
|
4702
4858
|
}
|
|
4703
4859
|
if (!(result.done === true)) {
|
|
4704
|
-
|
|
4860
|
+
_context3.next = 22;
|
|
4705
4861
|
break;
|
|
4706
4862
|
}
|
|
4707
4863
|
console.log('--> [DONE]');
|
|
4708
4864
|
|
|
4709
4865
|
//reset SSE
|
|
4710
4866
|
closeSSE();
|
|
4711
|
-
return
|
|
4867
|
+
return _context3.abrupt("break", 45);
|
|
4712
4868
|
case 22:
|
|
4713
4869
|
//*******
|
|
4714
4870
|
// for OpenAI API
|
|
@@ -4730,10 +4886,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
4730
4886
|
// ------
|
|
4731
4887
|
// 🚀 !! IMPORTANT: Skip the error content
|
|
4732
4888
|
if (!(typeof content === 'undefined')) {
|
|
4733
|
-
|
|
4889
|
+
_context3.next = 26;
|
|
4734
4890
|
break;
|
|
4735
4891
|
}
|
|
4736
|
-
return
|
|
4892
|
+
return _context3.abrupt("continue", 43);
|
|
4737
4893
|
case 26:
|
|
4738
4894
|
// STEP 4:
|
|
4739
4895
|
// ------
|
|
@@ -4760,13 +4916,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4760
4916
|
// ------
|
|
4761
4917
|
parsedContent = tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4762
4918
|
if (!(typeof args().renderParser === 'function')) {
|
|
4763
|
-
|
|
4919
|
+
_context3.next = 36;
|
|
4764
4920
|
break;
|
|
4765
4921
|
}
|
|
4766
|
-
|
|
4922
|
+
_context3.next = 35;
|
|
4767
4923
|
return args().renderParser(parsedContent);
|
|
4768
4924
|
case 35:
|
|
4769
|
-
parsedContent =
|
|
4925
|
+
parsedContent = _context3.sent;
|
|
4770
4926
|
case 36:
|
|
4771
4927
|
// STEP 8:
|
|
4772
4928
|
// ------
|
|
@@ -4783,55 +4939,55 @@ var Chatbox = function Chatbox(props) {
|
|
|
4783
4939
|
// ------
|
|
4784
4940
|
// Scroll to the bottom
|
|
4785
4941
|
scrollToBottom();
|
|
4786
|
-
|
|
4942
|
+
_context3.next = 43;
|
|
4787
4943
|
break;
|
|
4788
4944
|
case 40:
|
|
4789
4945
|
console.log('--> [DONE]');
|
|
4790
4946
|
|
|
4791
4947
|
//reset SSE
|
|
4792
4948
|
closeSSE();
|
|
4793
|
-
return
|
|
4949
|
+
return _context3.abrupt("break", 45);
|
|
4794
4950
|
case 43:
|
|
4795
|
-
|
|
4951
|
+
_context3.next = 7;
|
|
4796
4952
|
break;
|
|
4797
4953
|
case 45:
|
|
4798
|
-
|
|
4954
|
+
_context3.next = 50;
|
|
4799
4955
|
break;
|
|
4800
4956
|
case 47:
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
_iterator.e(
|
|
4957
|
+
_context3.prev = 47;
|
|
4958
|
+
_context3.t0 = _context3["catch"](5);
|
|
4959
|
+
_iterator.e(_context3.t0);
|
|
4804
4960
|
case 50:
|
|
4805
|
-
|
|
4961
|
+
_context3.prev = 50;
|
|
4806
4962
|
_iterator.f();
|
|
4807
|
-
return
|
|
4963
|
+
return _context3.finish(50);
|
|
4808
4964
|
case 53:
|
|
4809
|
-
|
|
4965
|
+
_context3.next = 58;
|
|
4810
4966
|
break;
|
|
4811
4967
|
case 55:
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
console.error('--> Error processing chunk:',
|
|
4968
|
+
_context3.prev = 55;
|
|
4969
|
+
_context3.t1 = _context3["catch"](1);
|
|
4970
|
+
console.error('--> Error processing chunk:', _context3.t1);
|
|
4815
4971
|
case 58:
|
|
4816
4972
|
latestRes = complete ? lastContent : tempLastContent.current; // If a render parser exists, it is used to process the string
|
|
4817
4973
|
if (!(typeof args().renderParser === 'function')) {
|
|
4818
|
-
|
|
4974
|
+
_context3.next = 63;
|
|
4819
4975
|
break;
|
|
4820
4976
|
}
|
|
4821
|
-
|
|
4977
|
+
_context3.next = 62;
|
|
4822
4978
|
return args().renderParser(latestRes);
|
|
4823
4979
|
case 62:
|
|
4824
|
-
latestRes =
|
|
4980
|
+
latestRes = _context3.sent;
|
|
4825
4981
|
case 63:
|
|
4826
|
-
return
|
|
4982
|
+
return _context3.abrupt("return", formatLatestDisplayContent(latestRes));
|
|
4827
4983
|
case 64:
|
|
4828
4984
|
case "end":
|
|
4829
|
-
return
|
|
4985
|
+
return _context3.stop();
|
|
4830
4986
|
}
|
|
4831
|
-
},
|
|
4987
|
+
}, _callee3, null, [[1, 55], [5, 47, 50, 53]]);
|
|
4832
4988
|
}));
|
|
4833
|
-
return function parseChunkData(
|
|
4834
|
-
return
|
|
4989
|
+
return function parseChunkData(_x6, _x7, _x8) {
|
|
4990
|
+
return _ref3.apply(this, arguments);
|
|
4835
4991
|
};
|
|
4836
4992
|
}();
|
|
4837
4993
|
|
|
@@ -4839,11 +4995,11 @@ var Chatbox = function Chatbox(props) {
|
|
|
4839
4995
|
var tempLastContent = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)('');
|
|
4840
4996
|
var streamController = src_useStreamController({
|
|
4841
4997
|
onChunk: function () {
|
|
4842
|
-
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
4843
|
-
var _args$onChunk,
|
|
4998
|
+
var _onChunk = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4(chunk, index) {
|
|
4999
|
+
var _args$onChunk, _args8;
|
|
4844
5000
|
var res;
|
|
4845
|
-
return src_regeneratorRuntime().wrap(function
|
|
4846
|
-
while (1) switch (
|
|
5001
|
+
return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
5002
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
4847
5003
|
case 0:
|
|
4848
5004
|
// start (Execute it only once)
|
|
4849
5005
|
if (index === 0) {
|
|
@@ -4852,50 +5008,50 @@ var Chatbox = function Chatbox(props) {
|
|
|
4852
5008
|
}
|
|
4853
5009
|
|
|
4854
5010
|
//
|
|
4855
|
-
|
|
5011
|
+
_context4.next = 3;
|
|
4856
5012
|
return parseChunkData(chunk, index, false);
|
|
4857
5013
|
case 3:
|
|
4858
|
-
res =
|
|
5014
|
+
res = _context4.sent;
|
|
4859
5015
|
//
|
|
4860
|
-
(_args$onChunk = (
|
|
5016
|
+
(_args$onChunk = (_args8 = args()).onChunk) === null || _args$onChunk === void 0 ? void 0 : _args$onChunk.call(_args8, inputContentRef.current, res, conversationHistory.current);
|
|
4861
5017
|
case 5:
|
|
4862
5018
|
case "end":
|
|
4863
|
-
return
|
|
5019
|
+
return _context4.stop();
|
|
4864
5020
|
}
|
|
4865
|
-
},
|
|
5021
|
+
}, _callee4);
|
|
4866
5022
|
}));
|
|
4867
|
-
function onChunk(
|
|
5023
|
+
function onChunk(_x9, _x10) {
|
|
4868
5024
|
return _onChunk.apply(this, arguments);
|
|
4869
5025
|
}
|
|
4870
5026
|
return onChunk;
|
|
4871
5027
|
}(),
|
|
4872
5028
|
onComplete: function () {
|
|
4873
|
-
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function
|
|
4874
|
-
var _args$onComplete,
|
|
5029
|
+
var _onComplete = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5(lastContent) {
|
|
5030
|
+
var _args$onComplete, _args10;
|
|
4875
5031
|
var res;
|
|
4876
|
-
return src_regeneratorRuntime().wrap(function
|
|
4877
|
-
while (1) switch (
|
|
5032
|
+
return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
5033
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
4878
5034
|
case 0:
|
|
4879
5035
|
console.log('--> Stream complete');
|
|
4880
|
-
|
|
5036
|
+
_context5.next = 3;
|
|
4881
5037
|
return parseChunkData(lastContent, 0, true);
|
|
4882
5038
|
case 3:
|
|
4883
|
-
res =
|
|
5039
|
+
res = _context5.sent;
|
|
4884
5040
|
// Display AI reply
|
|
4885
5041
|
displayMessage(args().answerNameRes, res);
|
|
4886
5042
|
|
|
4887
5043
|
//
|
|
4888
|
-
(_args$onComplete = (
|
|
5044
|
+
(_args$onComplete = (_args10 = args()).onComplete) === null || _args$onComplete === void 0 ? void 0 : _args$onComplete.call(_args10, inputContentRef.current, res, conversationHistory.current);
|
|
4889
5045
|
|
|
4890
5046
|
//
|
|
4891
5047
|
closeSSE();
|
|
4892
5048
|
case 7:
|
|
4893
5049
|
case "end":
|
|
4894
|
-
return
|
|
5050
|
+
return _context5.stop();
|
|
4895
5051
|
}
|
|
4896
|
-
},
|
|
5052
|
+
}, _callee5);
|
|
4897
5053
|
}));
|
|
4898
|
-
function onComplete(
|
|
5054
|
+
function onComplete(_x11) {
|
|
4899
5055
|
return _onComplete.apply(this, arguments);
|
|
4900
5056
|
}
|
|
4901
5057
|
return onComplete;
|
|
@@ -4942,36 +5098,41 @@ var Chatbox = function Chatbox(props) {
|
|
|
4942
5098
|
setMsgList(function (prevMessages) {
|
|
4943
5099
|
return [].concat(_toConsumableArray(prevMessages), [newMessage]);
|
|
4944
5100
|
});
|
|
5101
|
+
|
|
5102
|
+
// Auto copy reply if enabled
|
|
5103
|
+
if (args().autoCopyReply && sender === args().answerNameRes) {
|
|
5104
|
+
chatboxCopyToClipboard(content);
|
|
5105
|
+
}
|
|
4945
5106
|
};
|
|
4946
5107
|
var sendMessage = /*#__PURE__*/function () {
|
|
4947
|
-
var
|
|
4948
|
-
var messageInput, message, inputMsg,
|
|
4949
|
-
return src_regeneratorRuntime().wrap(function
|
|
4950
|
-
while (1) switch (
|
|
5108
|
+
var _ref4 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee6() {
|
|
5109
|
+
var messageInput, message, inputMsg, _res, _args$onChunk2, _args12, _args$onComplete2, _args13, reply, replyRes;
|
|
5110
|
+
return src_regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
5111
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
4951
5112
|
case 0:
|
|
4952
5113
|
if (!(rootRef.current === null || msgContainerRef.current === null || msInput.current === null)) {
|
|
4953
|
-
|
|
5114
|
+
_context6.next = 2;
|
|
4954
5115
|
break;
|
|
4955
5116
|
}
|
|
4956
|
-
return
|
|
5117
|
+
return _context6.abrupt("return");
|
|
4957
5118
|
case 2:
|
|
4958
5119
|
messageInput = msInput.current;
|
|
4959
5120
|
message = (0,sanitize.htmlEncode)(messageInput.value); // It fires in real time as the user enters
|
|
4960
5121
|
// Sanitizing input is the process of securing/cleaning/filtering input data.
|
|
4961
5122
|
if (!(typeof args().onInputCallback === 'function')) {
|
|
4962
|
-
|
|
5123
|
+
_context6.next = 8;
|
|
4963
5124
|
break;
|
|
4964
5125
|
}
|
|
4965
|
-
|
|
5126
|
+
_context6.next = 7;
|
|
4966
5127
|
return args().onInputCallback(message);
|
|
4967
5128
|
case 7:
|
|
4968
|
-
message =
|
|
5129
|
+
message = _context6.sent;
|
|
4969
5130
|
case 8:
|
|
4970
5131
|
if (!(message.trim() === '')) {
|
|
4971
|
-
|
|
5132
|
+
_context6.next = 10;
|
|
4972
5133
|
break;
|
|
4973
5134
|
}
|
|
4974
|
-
return
|
|
5135
|
+
return _context6.abrupt("return");
|
|
4975
5136
|
case 10:
|
|
4976
5137
|
// Start the timer
|
|
4977
5138
|
setElapsedTime(0); // Reset elapsed time
|
|
@@ -4984,13 +5145,13 @@ var Chatbox = function Chatbox(props) {
|
|
|
4984
5145
|
// user message
|
|
4985
5146
|
inputMsg = "".concat(message); // If a render parser exists, it is used to process the string
|
|
4986
5147
|
if (!(typeof args().renderParser === 'function')) {
|
|
4987
|
-
|
|
5148
|
+
_context6.next = 17;
|
|
4988
5149
|
break;
|
|
4989
5150
|
}
|
|
4990
|
-
|
|
5151
|
+
_context6.next = 16;
|
|
4991
5152
|
return args().renderParser(inputMsg);
|
|
4992
5153
|
case 16:
|
|
4993
|
-
inputMsg =
|
|
5154
|
+
inputMsg = _context6.sent;
|
|
4994
5155
|
case 17:
|
|
4995
5156
|
displayMessage(args().questionNameRes, inputMsg); // Display user message
|
|
4996
5157
|
|
|
@@ -5002,48 +5163,48 @@ var Chatbox = function Chatbox(props) {
|
|
|
5002
5163
|
|
|
5003
5164
|
// clear
|
|
5004
5165
|
if (inputContentRef.current) inputContentRef.current.clear();
|
|
5005
|
-
|
|
5006
|
-
|
|
5166
|
+
_context6.prev = 21;
|
|
5167
|
+
_context6.next = 24;
|
|
5007
5168
|
return mainRequest(message);
|
|
5008
5169
|
case 24:
|
|
5009
|
-
|
|
5010
|
-
if (
|
|
5011
|
-
|
|
5170
|
+
_res = _context6.sent;
|
|
5171
|
+
if (_res.useStreamRender) {
|
|
5172
|
+
_context6.next = 36;
|
|
5012
5173
|
break;
|
|
5013
5174
|
}
|
|
5014
|
-
reply =
|
|
5175
|
+
reply = _res.reply;
|
|
5015
5176
|
replyRes = "".concat(reply); // If a render parser exists, it is used to process the string
|
|
5016
5177
|
if (!(typeof args().renderParser === 'function')) {
|
|
5017
|
-
|
|
5178
|
+
_context6.next = 32;
|
|
5018
5179
|
break;
|
|
5019
5180
|
}
|
|
5020
|
-
|
|
5181
|
+
_context6.next = 31;
|
|
5021
5182
|
return args().renderParser(replyRes);
|
|
5022
5183
|
case 31:
|
|
5023
|
-
replyRes =
|
|
5184
|
+
replyRes = _context6.sent;
|
|
5024
5185
|
case 32:
|
|
5025
5186
|
displayMessage(args().answerNameRes, replyRes); // Display AI reply
|
|
5026
5187
|
|
|
5027
5188
|
//
|
|
5028
|
-
(_args$onChunk2 = (
|
|
5029
|
-
(_args$onComplete2 = (
|
|
5189
|
+
(_args$onChunk2 = (_args12 = args()).onChunk) === null || _args$onChunk2 === void 0 ? void 0 : _args$onChunk2.call(_args12, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5190
|
+
(_args$onComplete2 = (_args13 = args()).onComplete) === null || _args$onComplete2 === void 0 ? void 0 : _args$onComplete2.call(_args13, inputContentRef.current, replyRes, conversationHistory.current);
|
|
5030
5191
|
|
|
5031
5192
|
//reset SSE
|
|
5032
5193
|
closeSSE();
|
|
5033
5194
|
case 36:
|
|
5034
|
-
|
|
5195
|
+
_context6.next = 45;
|
|
5035
5196
|
break;
|
|
5036
5197
|
case 38:
|
|
5037
|
-
|
|
5038
|
-
|
|
5198
|
+
_context6.prev = 38;
|
|
5199
|
+
_context6.t0 = _context6["catch"](21);
|
|
5039
5200
|
// loading
|
|
5040
5201
|
setLoading(false);
|
|
5041
5202
|
|
|
5042
5203
|
// Stop the timer
|
|
5043
5204
|
clearInterval(timer.current);
|
|
5044
5205
|
timer.current = null;
|
|
5045
|
-
console.error('--> Error sending message:',
|
|
5046
|
-
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(
|
|
5206
|
+
console.error('--> Error sending message:', _context6.t0);
|
|
5207
|
+
displayMessage(args().answerNameRes, "Error: Unable to send message: ".concat(String(_context6.t0))); // Display AI reply
|
|
5047
5208
|
case 45:
|
|
5048
5209
|
// clear
|
|
5049
5210
|
messageInput.value = '';
|
|
@@ -5055,12 +5216,12 @@ var Chatbox = function Chatbox(props) {
|
|
|
5055
5216
|
scrollToBottom();
|
|
5056
5217
|
case 48:
|
|
5057
5218
|
case "end":
|
|
5058
|
-
return
|
|
5219
|
+
return _context6.stop();
|
|
5059
5220
|
}
|
|
5060
|
-
},
|
|
5221
|
+
}, _callee6, null, [[21, 38]]);
|
|
5061
5222
|
}));
|
|
5062
5223
|
return function sendMessage() {
|
|
5063
|
-
return
|
|
5224
|
+
return _ref4.apply(this, arguments);
|
|
5064
5225
|
};
|
|
5065
5226
|
}();
|
|
5066
5227
|
var handleClickSafe = useDebounce_default()(function () {
|
|
@@ -5072,25 +5233,25 @@ var Chatbox = function Chatbox(props) {
|
|
|
5072
5233
|
setShow(false);
|
|
5073
5234
|
};
|
|
5074
5235
|
var mainRequest = /*#__PURE__*/function () {
|
|
5075
|
-
var
|
|
5236
|
+
var _ref5 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee7(msg) {
|
|
5076
5237
|
var currentStreamMode, requestBodyRes, customResponse, content, isStream, contentRes, response, _errInfo, _args$responseExtract2, extractPath, _response, _errInfo2, jsonResponse, result, _iterator3, _step3, path, _content2, _err;
|
|
5077
|
-
return src_regeneratorRuntime().wrap(function
|
|
5078
|
-
while (1) switch (
|
|
5238
|
+
return src_regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
5239
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
5079
5240
|
case 0:
|
|
5080
5241
|
currentStreamMode = args().isStream; // Update stream mode
|
|
5081
5242
|
setEnableStreamMode(currentStreamMode);
|
|
5082
|
-
|
|
5243
|
+
_context7.prev = 2;
|
|
5083
5244
|
// Parse and interpolate request body template
|
|
5084
5245
|
requestBodyRes = JSON.parse((args().requestBodyTmpl || '{}').replace(/\{model\}/g, args().model).replace(/\{message\}/g, msg).replace(/\{token\}/g, chatId)); //
|
|
5085
5246
|
// If a formatter function exists, it is used to process the request body
|
|
5086
5247
|
if (!(typeof args().requestBodyFormatter === 'function')) {
|
|
5087
|
-
|
|
5248
|
+
_context7.next = 8;
|
|
5088
5249
|
break;
|
|
5089
5250
|
}
|
|
5090
|
-
|
|
5251
|
+
_context7.next = 7;
|
|
5091
5252
|
return args().requestBodyFormatter(requestBodyRes, args().latestContextData, conversationHistory.current);
|
|
5092
5253
|
case 7:
|
|
5093
|
-
requestBodyRes =
|
|
5254
|
+
requestBodyRes = _context7.sent;
|
|
5094
5255
|
case 8:
|
|
5095
5256
|
// Scroll to the bottom
|
|
5096
5257
|
setTimeout(function () {
|
|
@@ -5098,19 +5259,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5098
5259
|
scrollToBottom();
|
|
5099
5260
|
}, 500);
|
|
5100
5261
|
if (!(typeof args().customRequest === 'function')) {
|
|
5101
|
-
|
|
5262
|
+
_context7.next = 25;
|
|
5102
5263
|
break;
|
|
5103
5264
|
}
|
|
5104
5265
|
// Update stream mode
|
|
5105
5266
|
setEnableStreamMode(false);
|
|
5106
|
-
|
|
5267
|
+
_context7.next = 13;
|
|
5107
5268
|
return args().customRequest(msg, {
|
|
5108
5269
|
requestBody: requestBodyRes,
|
|
5109
5270
|
apiUrl: args().requestApiUrl || '',
|
|
5110
5271
|
headers: args().headerConfigRes
|
|
5111
5272
|
});
|
|
5112
5273
|
case 13:
|
|
5113
|
-
customResponse =
|
|
5274
|
+
customResponse = _context7.sent;
|
|
5114
5275
|
content = customResponse.content, isStream = customResponse.isStream;
|
|
5115
5276
|
contentRes = content; // Update stream mode
|
|
5116
5277
|
setEnableStreamMode(isStream);
|
|
@@ -5118,24 +5279,24 @@ var Chatbox = function Chatbox(props) {
|
|
|
5118
5279
|
// NORMAL
|
|
5119
5280
|
//++++++++++++++++++++++++++++++++++++++++++++++++
|
|
5120
5281
|
if (!(!isStream && typeof contentRes === 'string' && contentRes.trim() !== '')) {
|
|
5121
|
-
|
|
5282
|
+
_context7.next = 20;
|
|
5122
5283
|
break;
|
|
5123
5284
|
}
|
|
5124
5285
|
// Replace with a valid label
|
|
5125
5286
|
contentRes = fixHtmlTags(contentRes, args().withReasoning, args().reasoningSwitchLabel);
|
|
5126
|
-
return
|
|
5287
|
+
return _context7.abrupt("return", {
|
|
5127
5288
|
reply: formatLatestDisplayContent(contentRes),
|
|
5128
5289
|
useStreamRender: false
|
|
5129
5290
|
});
|
|
5130
5291
|
case 20:
|
|
5131
5292
|
if (!(isStream && isStreamResponse(contentRes))) {
|
|
5132
|
-
|
|
5293
|
+
_context7.next = 24;
|
|
5133
5294
|
break;
|
|
5134
5295
|
}
|
|
5135
|
-
|
|
5296
|
+
_context7.next = 23;
|
|
5136
5297
|
return streamController.start(contentRes);
|
|
5137
5298
|
case 23:
|
|
5138
|
-
return
|
|
5299
|
+
return _context7.abrupt("return", {
|
|
5139
5300
|
reply: tempAnimText,
|
|
5140
5301
|
// The final content will be in tempAnimText
|
|
5141
5302
|
useStreamRender: true
|
|
@@ -5149,19 +5310,19 @@ var Chatbox = function Chatbox(props) {
|
|
|
5149
5310
|
}
|
|
5150
5311
|
case 25:
|
|
5151
5312
|
if (!currentStreamMode) {
|
|
5152
|
-
|
|
5313
|
+
_context7.next = 39;
|
|
5153
5314
|
break;
|
|
5154
5315
|
}
|
|
5155
|
-
|
|
5316
|
+
_context7.next = 28;
|
|
5156
5317
|
return fetch(args().requestApiUrl || '', {
|
|
5157
5318
|
method: "POST",
|
|
5158
5319
|
body: JSON.stringify(requestBodyRes),
|
|
5159
5320
|
headers: args().headerConfigRes
|
|
5160
5321
|
});
|
|
5161
5322
|
case 28:
|
|
5162
|
-
response =
|
|
5323
|
+
response = _context7.sent;
|
|
5163
5324
|
if (response.ok) {
|
|
5164
|
-
|
|
5325
|
+
_context7.next = 34;
|
|
5165
5326
|
break;
|
|
5166
5327
|
}
|
|
5167
5328
|
_errInfo = "[ERROR] HTTP Error ".concat(response.status, ": ").concat(response.statusText);
|
|
@@ -5169,15 +5330,15 @@ var Chatbox = function Chatbox(props) {
|
|
|
5169
5330
|
|
|
5170
5331
|
// hide loader
|
|
5171
5332
|
setLoaderDisplay(false);
|
|
5172
|
-
return
|
|
5333
|
+
return _context7.abrupt("return", {
|
|
5173
5334
|
reply: _errInfo,
|
|
5174
5335
|
useStreamRender: false
|
|
5175
5336
|
});
|
|
5176
5337
|
case 34:
|
|
5177
|
-
|
|
5338
|
+
_context7.next = 36;
|
|
5178
5339
|
return streamController.start(response);
|
|
5179
5340
|
case 36:
|
|
5180
|
-
return
|
|
5341
|
+
return _context7.abrupt("return", {
|
|
5181
5342
|
reply: tempAnimText,
|
|
5182
5343
|
// The final content will be in tempAnimText
|
|
5183
5344
|
useStreamRender: true
|
|
@@ -5185,7 +5346,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5185
5346
|
case 39:
|
|
5186
5347
|
// Extract response using the path
|
|
5187
5348
|
extractPath = (_args$responseExtract2 = args().responseExtractPath) === null || _args$responseExtract2 === void 0 ? void 0 : _args$responseExtract2.slice(1);
|
|
5188
|
-
|
|
5349
|
+
_context7.next = 42;
|
|
5189
5350
|
return fetch(args().requestApiUrl || '', {
|
|
5190
5351
|
method: "POST",
|
|
5191
5352
|
headers: args().headerConfigRes,
|
|
@@ -5193,22 +5354,22 @@ var Chatbox = function Chatbox(props) {
|
|
|
5193
5354
|
signal: abortController.current.signal
|
|
5194
5355
|
});
|
|
5195
5356
|
case 42:
|
|
5196
|
-
_response =
|
|
5357
|
+
_response = _context7.sent;
|
|
5197
5358
|
if (_response.ok) {
|
|
5198
|
-
|
|
5359
|
+
_context7.next = 47;
|
|
5199
5360
|
break;
|
|
5200
5361
|
}
|
|
5201
5362
|
_errInfo2 = "[ERROR] HTTP Error ".concat(_response.status, ": ").concat(_response.statusText); // hide loader
|
|
5202
5363
|
setLoaderDisplay(false);
|
|
5203
|
-
return
|
|
5364
|
+
return _context7.abrupt("return", {
|
|
5204
5365
|
reply: _errInfo2,
|
|
5205
5366
|
useStreamRender: false
|
|
5206
5367
|
});
|
|
5207
5368
|
case 47:
|
|
5208
|
-
|
|
5369
|
+
_context7.next = 49;
|
|
5209
5370
|
return _response.json();
|
|
5210
5371
|
case 49:
|
|
5211
|
-
jsonResponse =
|
|
5372
|
+
jsonResponse = _context7.sent;
|
|
5212
5373
|
// hide loader
|
|
5213
5374
|
setLoaderDisplay(false);
|
|
5214
5375
|
result = jsonResponse;
|
|
@@ -5227,33 +5388,33 @@ var Chatbox = function Chatbox(props) {
|
|
|
5227
5388
|
}
|
|
5228
5389
|
_content2 = result; // Replace with a valid label
|
|
5229
5390
|
_content2 = fixHtmlTags(_content2, args().withReasoning, args().reasoningSwitchLabel);
|
|
5230
|
-
return
|
|
5391
|
+
return _context7.abrupt("return", {
|
|
5231
5392
|
reply: formatLatestDisplayContent(_content2),
|
|
5232
5393
|
useStreamRender: false
|
|
5233
5394
|
});
|
|
5234
5395
|
case 56:
|
|
5235
|
-
|
|
5396
|
+
_context7.next = 64;
|
|
5236
5397
|
break;
|
|
5237
5398
|
case 58:
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
_err = "--> Error in mainRequest: ".concat(
|
|
5399
|
+
_context7.prev = 58;
|
|
5400
|
+
_context7.t0 = _context7["catch"](2);
|
|
5401
|
+
_err = "--> Error in mainRequest: ".concat(_context7.t0);
|
|
5241
5402
|
console.error(_err);
|
|
5242
5403
|
|
|
5243
5404
|
//reset SSE
|
|
5244
5405
|
closeSSE();
|
|
5245
|
-
return
|
|
5406
|
+
return _context7.abrupt("return", {
|
|
5246
5407
|
reply: _err,
|
|
5247
5408
|
useStreamRender: false
|
|
5248
5409
|
});
|
|
5249
5410
|
case 64:
|
|
5250
5411
|
case "end":
|
|
5251
|
-
return
|
|
5412
|
+
return _context7.stop();
|
|
5252
5413
|
}
|
|
5253
|
-
},
|
|
5414
|
+
}, _callee7, null, [[2, 58]]);
|
|
5254
5415
|
}));
|
|
5255
|
-
return function mainRequest(
|
|
5256
|
-
return
|
|
5416
|
+
return function mainRequest(_x12) {
|
|
5417
|
+
return _ref5.apply(this, arguments);
|
|
5257
5418
|
};
|
|
5258
5419
|
}();
|
|
5259
5420
|
|
|
@@ -5286,6 +5447,10 @@ var Chatbox = function Chatbox(props) {
|
|
|
5286
5447
|
setMsgList(props.defaultMessages);
|
|
5287
5448
|
}
|
|
5288
5449
|
}, [props.defaultMessages]);
|
|
5450
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
|
|
5451
|
+
// Bind chatboxCopyToClipboard to window so it can be called in HTML code
|
|
5452
|
+
window.chatboxCopyToClipboard = chatboxCopyToClipboard;
|
|
5453
|
+
}, []);
|
|
5289
5454
|
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((dist_cjs_default()), {
|
|
5290
5455
|
show: true,
|
|
5291
5456
|
containerClassName: "Chatbox"
|
|
@@ -5374,15 +5539,17 @@ var Chatbox = function Chatbox(props) {
|
|
|
5374
5539
|
className: "messages",
|
|
5375
5540
|
ref: msgContainerRef
|
|
5376
5541
|
}, msgList.map(function (msg, index) {
|
|
5377
|
-
var _msg$tag;
|
|
5542
|
+
var _msg$tag, _msg$tag2;
|
|
5543
|
+
var copyTargetId = "".concat(args().prefix || 'custom-', "chatbox-content--").concat(chatId).concat(index);
|
|
5378
5544
|
var isAnimProgress = tempAnimText !== '' && msg.sender !== args().questionNameRes && index === msgList.length - 1 && loading;
|
|
5379
5545
|
var hasAnimated = animatedMessagesRef.current.has(index);
|
|
5380
5546
|
|
|
5381
5547
|
// Mark the message as animated;
|
|
5382
5548
|
animatedMessagesRef.current.add(index);
|
|
5549
|
+
var timeShow = "<span class=\"qa-timestamp\">".concat(msg.timestamp, "</span>").concat(args().showCopyBtn && ((_msg$tag = msg.tag) === null || _msg$tag === void 0 ? void 0 : _msg$tag.indexOf('[reply]')) >= 0 ? "<button class=\"copy-btn\" onclick=\"window.chatboxCopyToClipboard(document.querySelector('#".concat(copyTargetId, " .qa-content-inner').innerHTML)\"><svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\"><path d=\"M8 4v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7.242a2 2 0 0 0-.602-1.43L16.083 2.57A2 2 0 0 0 14.685 2H10a2 2 0 0 0-2 2z\"/><path d=\"M16 18v2a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h2\"/></svg></button>") : '');
|
|
5383
5550
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5384
5551
|
key: index,
|
|
5385
|
-
className: ((_msg$
|
|
5552
|
+
className: ((_msg$tag2 = msg.tag) === null || _msg$tag2 === void 0 ? void 0 : _msg$tag2.indexOf('[reply]')) < 0 ? 'request' : 'reply',
|
|
5386
5553
|
style: {
|
|
5387
5554
|
display: isAnimProgress ? 'none' : ''
|
|
5388
5555
|
}
|
|
@@ -5393,25 +5560,28 @@ var Chatbox = function Chatbox(props) {
|
|
|
5393
5560
|
}
|
|
5394
5561
|
}), msg.sender === args().questionNameRes ? /*#__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", {
|
|
5395
5562
|
className: "qa-content",
|
|
5563
|
+
id: copyTargetId,
|
|
5396
5564
|
dangerouslySetInnerHTML: {
|
|
5397
|
-
__html: "
|
|
5565
|
+
__html: "<div class=\"qa-content-inner\">".concat(msg.content, "</div> ").concat(timeShow)
|
|
5398
5566
|
}
|
|
5399
5567
|
})) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, enableStreamMode ? /*#__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", {
|
|
5400
5568
|
className: "qa-content",
|
|
5569
|
+
id: copyTargetId,
|
|
5401
5570
|
dangerouslySetInnerHTML: {
|
|
5402
|
-
__html: "
|
|
5571
|
+
__html: "<div class=\"qa-content-inner\">".concat(msg.content, "</div> ").concat(timeShow)
|
|
5403
5572
|
}
|
|
5404
5573
|
})) : /*#__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", {
|
|
5405
|
-
className: "qa-content"
|
|
5574
|
+
className: "qa-content",
|
|
5575
|
+
id: copyTargetId
|
|
5406
5576
|
}, hasAnimated ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5407
5577
|
dangerouslySetInnerHTML: {
|
|
5408
|
-
__html: "
|
|
5578
|
+
__html: "<div class=\"qa-content-inner\">".concat(msg.content, "</div> ").concat(timeShow)
|
|
5409
5579
|
}
|
|
5410
5580
|
}) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_TypingEffect, {
|
|
5411
5581
|
onUpdate: function onUpdate() {
|
|
5412
5582
|
scrollToBottom();
|
|
5413
5583
|
},
|
|
5414
|
-
content: "
|
|
5584
|
+
content: "<div class=\"qa-content-inner\">".concat(msg.content, "</div> ").concat(timeShow),
|
|
5415
5585
|
speed: 10
|
|
5416
5586
|
})))));
|
|
5417
5587
|
}), enableStreamMode ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, args().verbose ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, tempAnimText !== '' && loading ? /*#__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", {
|
|
@@ -5508,8 +5678,8 @@ var Chatbox = function Chatbox(props) {
|
|
|
5508
5678
|
}
|
|
5509
5679
|
},
|
|
5510
5680
|
onChange: function onChange(e) {
|
|
5511
|
-
var _args$onInputChange,
|
|
5512
|
-
(_args$onInputChange = (
|
|
5681
|
+
var _args$onInputChange, _args16;
|
|
5682
|
+
(_args$onInputChange = (_args16 = args()).onInputChange) === null || _args$onInputChange === void 0 ? void 0 : _args$onInputChange.call(_args16, inputContentRef.current, e.target.value);
|
|
5513
5683
|
},
|
|
5514
5684
|
rows: args().defaultRows || 3,
|
|
5515
5685
|
autoSize: true,
|
|
@@ -5556,6 +5726,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5556
5726
|
display: loading ? 'block' : 'none'
|
|
5557
5727
|
}
|
|
5558
5728
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_PureLoader, {
|
|
5729
|
+
prefix: args().prefix,
|
|
5559
5730
|
customClassName: "w-100",
|
|
5560
5731
|
txt: ""
|
|
5561
5732
|
}))) : null, args().toolkitButtons && args().toolkitButtons.length > 0 && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
@@ -5565,7 +5736,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5565
5736
|
var _id = "".concat(args().prefix || 'custom-', "chatbox-btn-tools-").concat(chatId).concat(index);
|
|
5566
5737
|
var isActive = activeButtons[_id];
|
|
5567
5738
|
if (btn.isSelect) {
|
|
5568
|
-
var options = getButtonOptions(btn);
|
|
5739
|
+
var options = getButtonOptions(btn, _id);
|
|
5569
5740
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5570
5741
|
key: index,
|
|
5571
5742
|
className: "toolkit-select-wrapper"
|
|
@@ -5577,6 +5748,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
5577
5748
|
setActiveButtons(function (prev) {
|
|
5578
5749
|
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, _id, !prev[_id]));
|
|
5579
5750
|
});
|
|
5751
|
+
|
|
5752
|
+
//
|
|
5753
|
+
executeButtonAction(btn.onClick, _id, e.currentTarget);
|
|
5580
5754
|
}
|
|
5581
5755
|
}, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
5582
5756
|
dangerouslySetInnerHTML: {
|
|
@@ -5602,7 +5776,7 @@ var Chatbox = function Chatbox(props) {
|
|
|
5602
5776
|
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"
|
|
5603
5777
|
}))))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5604
5778
|
className: "toolkit-select-options ".concat(isActive ? 'active' : '')
|
|
5605
|
-
}, options.map(function (option, optIndex) {
|
|
5779
|
+
}, 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) {
|
|
5606
5780
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
|
|
5607
5781
|
key: optIndex,
|
|
5608
5782
|
className: "toolkit-select-option ".concat(option.value || '', " ").concat(selectedOpt.curIndex === optIndex ? 'selected' : ''),
|
|
@@ -5614,7 +5788,9 @@ var Chatbox = function Chatbox(props) {
|
|
|
5614
5788
|
__html: option.label
|
|
5615
5789
|
}
|
|
5616
5790
|
}));
|
|
5617
|
-
})))
|
|
5791
|
+
})) : /*#__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", {
|
|
5792
|
+
className: "".concat(args().prefix || 'custom-', "chatbox-mini-loader")
|
|
5793
|
+
}))));
|
|
5618
5794
|
}
|
|
5619
5795
|
|
|
5620
5796
|
// The rendering of the normal button
|