function _array_like_to_array(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;
}
function _array_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function 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);
    }
}
function _async_to_generator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}
function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(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(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function _ts_generator(thisArg, body) {
    var f, y, t, _ = {
        label: 0,
        sent: function() {
            if (t[0] & 1) throw t[1];
            return t[1];
        },
        trys: [],
        ops: []
    }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
    return d(g, "next", {
        value: verb(0)
    }), d(g, "throw", {
        value: verb(1)
    }), d(g, "return", {
        value: verb(2)
    }), typeof Symbol === "function" && d(g, Symbol.iterator, {
        value: function() {
            return this;
        }
    }), g;
    function verb(n) {
        return function(v) {
            return step([
                n,
                v
            ]);
        };
    }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while(g && (g = 0, op[0] && (_ = 0)), _)try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [
                op[0] & 2,
                t.value
            ];
            switch(op[0]){
                case 0:
                case 1:
                    t = op;
                    break;
                case 4:
                    _.label++;
                    return {
                        value: op[1],
                        done: false
                    };
                case 5:
                    _.label++;
                    y = op[1];
                    op = [
                        0
                    ];
                    continue;
                case 7:
                    op = _.ops.pop();
                    _.trys.pop();
                    continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                        _ = 0;
                        continue;
                    }
                    if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                        _.label = op[1];
                        break;
                    }
                    if (op[0] === 6 && _.label < t[1]) {
                        _.label = t[1];
                        t = op;
                        break;
                    }
                    if (t && _.label < t[2]) {
                        _.label = t[2];
                        _.ops.push(op);
                        break;
                    }
                    if (t[2]) _.ops.pop();
                    _.trys.pop();
                    continue;
            }
            op = body.call(thisArg, _);
        } catch (e) {
            op = [
                6,
                e
            ];
            y = 0;
        } finally{
            f = t = 0;
        }
        if (op[0] & 5) throw op[1];
        return {
            value: op[0] ? op[1] : void 0,
            done: true
        };
    }
}
import { ExportOutlined } from "@ant-design/icons";
import { ConfigProvider, Popover, Tooltip, Typography } from "antd";
import classNames from "clsx";
import React, { useContext, useMemo } from "react";
import { ActionIconBox } from "../../Components/ActionIconBox";
import { useAdaptiveTooltipProps } from "../../Hooks/useAdaptiveTooltipProps";
import { useRefFunction } from "../../Hooks/useRefFunction";
import { I18nContext } from "../../I18n";
import { MarkdownEditor } from "../../MarkdownEditor";
import { BubbleConfigContext } from "../BubbleConfigProvide";
import { BubbleExtra } from "./BubbleExtra";
import { DocInfoList } from "./DocInfo";
import { EXCEPTION } from "./EXCEPTION";
import { MarkdownPreview } from "./MarkdownPreview";
import { useMessagesContentStyle } from "./style";
export var LOADING_FLAT = '...';
var THINKING_FALLBACK_TEXT = '思考中...';
var THINKING_DOT_INDICES = [
    0,
    1,
    2
];
/**
 * BubbleMessageDisplay 组件 - 聊天气泡消息显示组件
 *
 * 该组件负责渲染聊天气泡中的消息内容，支持多种内容类型的显示，
 * 包括Markdown、异常消息、加载状态等。提供完整的交互功能。
 *
 * @component
 * @description 聊天气泡消息显示组件，处理各种消息内容的渲染
 * @param {BubbleProps & {content: MessageBubbleData['content'], bubbleListItemExtraStyle?: React.CSSProperties}} props - 组件属性
 * @param {string} props.content - 消息内容
 * @param {React.CSSProperties} [props.bubbleListItemExtraStyle] - 额外样式
 * @param {MutableRefObject} [props.bubbleRef] - 气泡引用
 * @param {boolean} [props.readonly] - 是否只读模式
 * @param {BubbleRenderConfig} [props.bubbleRenderConfig] - 渲染配置
 * @param {BubbleMetaData} [props.avatar] - 头像元数据
 *
 * @example
 * ```tsx
 * <BubbleMessageDisplay
 *   content="这是一条消息内容"
 *   readonly={false}
 *   bubbleRef={bubbleRef}
 * />
 * ```
 *
 * @returns {React.ReactElement} 渲染的消息显示组件
 *
 * @remarks
 * - 组件会自动处理 Markdown 内容的渲染
 * - 支持异常消息的特殊展示
 * - 提供完整的交互操作（点赞、点踩、复制等）
 * - 可以通过 extraRender 完全自定义额外操作区域
 *
 * @see {@link BubbleProps} 了解更多关于聊天项属性的信息
 * @see {@link BaseChatProps} 了解更多关于基础聊天属性的信息
 */ export var BubbleMessageDisplay = function BubbleMessageDisplay(_0) {
    var content = _0.content, bubbleRef = _0.bubbleRef, readonly = _0.readonly, contentAfterDom = _0.contentAfterDom, props = _object_without_properties(_0, [
        "content",
        "bubbleRef",
        "readonly",
        "contentAfterDom"
    ]);
    var _props_originData, _props_originData1, _props_originData_extra, _props_originData2, _props_bubbleRenderConfig, _props_originData3, _props_bubbleRenderConfig1, _props_originData4, _props_markdownRenderConfig, _props_originData5, _props_originData6, _props_originData7, _props_originData8, _props_bubbleRenderConfig2, _props_bubbleRenderConfig3;
    /**
   * 获取聊天配置上下文
   * @type {ChatConfigContext}
   */ var context = useContext(BubbleConfigContext);
    var locale = useContext(I18nContext).locale;
    var _React_useState = _sliced_to_array(React.useState(false), 2), isExtraNull = _React_useState[0], setIsExtraNull = _React_useState[1];
    var _React_useState1 = _sliced_to_array(React.useState([]), 2), nodeList = _React_useState1[0], setNodeList = _React_useState1[1];
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var chatCls = getPrefixCls('agentic-ui');
    var baseChatCls = "".concat(chatCls, "-display");
    var _useMessagesContentStyle = useMessagesContentStyle(baseChatCls), hashId = _useMessagesContentStyle.hashId, wrapSSR = _useMessagesContentStyle.wrapSSR;
    var docTagTooltipProps = useAdaptiveTooltipProps('informational');
    var funRender = useRefFunction(function(props) {
        var node = nodeList.find(function(item) {
            return item.placeholder === props.identifier;
        });
        return node;
    });
    var handleFootnoteDefinitionChange = useRefFunction(function(list) {
        setNodeList(list);
    });
    var typing = useMemo(function() {
        var _props_originData, _props_originData1, _props_originData_extra, _props_originData2, _props_originData3;
        return ((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isAborted) !== true && ((_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isFinished) === false && (props === null || props === void 0 ? void 0 : (_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : (_props_originData_extra = _props_originData2.extra) === null || _props_originData_extra === void 0 ? void 0 : _props_originData_extra.isHistory) === undefined && ((_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : _props_originData3.isFinished) !== undefined;
    }, [
        (_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isAborted,
        (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : _props_originData1.isFinished,
        (_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : (_props_originData_extra = _props_originData2.extra) === null || _props_originData_extra === void 0 ? void 0 : _props_originData_extra.isHistory
    ]);
    // 处理 beforeContent 和 afterContent
    var beforeContent = useMemo(function() {
        var _props_bubbleRenderConfig;
        return ((_props_bubbleRenderConfig = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig === void 0 ? void 0 : _props_bubbleRenderConfig.beforeMessageRender) ? props.bubbleRenderConfig.beforeMessageRender(props, null) : null;
    }, [
        (_props_bubbleRenderConfig = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig === void 0 ? void 0 : _props_bubbleRenderConfig.beforeMessageRender,
        typing,
        props.originData,
        (_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : _props_originData3.isLast
    ]);
    var afterContent = useMemo(function() {
        var _props_bubbleRenderConfig;
        var userAfter = ((_props_bubbleRenderConfig = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig === void 0 ? void 0 : _props_bubbleRenderConfig.afterMessageRender) ? props.bubbleRenderConfig.afterMessageRender(props, contentAfterDom) : contentAfterDom;
        return /*#__PURE__*/ React.createElement(React.Fragment, null, userAfter);
    }, [
        (_props_bubbleRenderConfig1 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig1 === void 0 ? void 0 : _props_bubbleRenderConfig1.afterMessageRender,
        typing,
        props.originData,
        (_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : _props_originData4.isLast,
        contentAfterDom
    ]);
    var mdReferenceRender = useRefFunction(function(mdProps, _) {
        var _props_originData_extra, _props_originData, _props_customConfig_PopoverProps, _props_customConfig, _props_customConfig1, _props_customConfig_PopoverProps1, _props_customConfig2, _item_origin_text;
        var reference_url_info_list = ((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : (_props_originData_extra = _props_originData.extra) === null || _props_originData_extra === void 0 ? void 0 : _props_originData_extra.reference_url_info_list) || [];
        var item = reference_url_info_list.find(function(row) {
            return row.placeholder === "[".concat(mdProps.children, "]") || row.placeholder === "[^".concat(mdProps.children, "]");
        }) || funRender(mdProps);
        if (!item) return;
        if (!(item === null || item === void 0 ? void 0 : item.origin_text)) return null;
        return /*#__PURE__*/ React.createElement(Popover, {
            title: /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(baseChatCls, "-messages-content-popover-title"), hashId),
                style: props === null || props === void 0 ? void 0 : (_props_customConfig = props.customConfig) === null || _props_customConfig === void 0 ? void 0 : (_props_customConfig_PopoverProps = _props_customConfig.PopoverProps) === null || _props_customConfig_PopoverProps === void 0 ? void 0 : _props_customConfig_PopoverProps.titleStyle
            }, /*#__PURE__*/ React.createElement("div", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.referenceDocument']) || '参考文档'), (item === null || item === void 0 ? void 0 : item.origin_url) ? /*#__PURE__*/ React.createElement(ActionIconBox, {
                title: (locale === null || locale === void 0 ? void 0 : locale['chat.message.viewOriginal']) || '查看原文',
                tooltipProps: props === null || props === void 0 ? void 0 : (_props_customConfig1 = props.customConfig) === null || _props_customConfig1 === void 0 ? void 0 : _props_customConfig1.TooltipProps,
                onClick: function onClick() {
                    var _props_markdownRenderConfig_fncProps, _props_markdownRenderConfig;
                    if ((_props_markdownRenderConfig = props.markdownRenderConfig) === null || _props_markdownRenderConfig === void 0 ? void 0 : (_props_markdownRenderConfig_fncProps = _props_markdownRenderConfig.fncProps) === null || _props_markdownRenderConfig_fncProps === void 0 ? void 0 : _props_markdownRenderConfig_fncProps.onOriginUrlClick) {
                        props.markdownRenderConfig.fncProps.onOriginUrlClick(item.origin_url);
                        return;
                    }
                    window.open(item.origin_url);
                }
            }, /*#__PURE__*/ React.createElement(ExportOutlined, null)) : null),
            content: /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(baseChatCls, "-messages-content-popover-content"), hashId),
                style: props === null || props === void 0 ? void 0 : (_props_customConfig2 = props.customConfig) === null || _props_customConfig2 === void 0 ? void 0 : (_props_customConfig_PopoverProps1 = _props_customConfig2.PopoverProps) === null || _props_customConfig_PopoverProps1 === void 0 ? void 0 : _props_customConfig_PopoverProps1.contentStyle
            }, /*#__PURE__*/ React.createElement(MarkdownEditor, {
                style: {
                    padding: 0,
                    width: '100%'
                },
                tableConfig: {
                    actions: {
                        fullScreen: 'modal'
                    }
                },
                readonly: true,
                contentStyle: {
                    padding: 0,
                    width: '100%'
                },
                initValue: item === null || item === void 0 ? void 0 : (_item_origin_text = item.origin_text) === null || _item_origin_text === void 0 ? void 0 : _item_origin_text.trim()
            }), (item === null || item === void 0 ? void 0 : item.docId) && item.doc_name ? /*#__PURE__*/ React.createElement(Tooltip, _object_spread({
                mouseEnterDelay: 0.3,
                title: /*#__PURE__*/ React.createElement(Typography.Text, {
                    copyable: {
                        text: item.docId
                    }
                }, item.docId)
            }, docTagTooltipProps), /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(baseChatCls, "-messages-content-doc-tag"), hashId)
            }, /*#__PURE__*/ React.createElement("img", {
                className: classNames("".concat(baseChatCls, "-messages-content-doc-tag-icon"), hashId),
                src: 'https://mdn.alipayobjects.com/huamei_ptjqan/afts/img/A*kF_GTppRbp4AAAAAAAAAAAAADkN6AQ/original'
            }), /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(baseChatCls, "-messages-content-doc-name"), hashId)
            }, item === null || item === void 0 ? void 0 : item.doc_name))) : null)
        }, _);
    });
    var markdownPreviewFncProps = useMemo(function() {
        var _props_markdownRenderConfig;
        return _object_spread({
            render: mdReferenceRender,
            onFootnoteDefinitionChange: handleFootnoteDefinitionChange
        }, ((_props_markdownRenderConfig = props.markdownRenderConfig) === null || _props_markdownRenderConfig === void 0 ? void 0 : _props_markdownRenderConfig.fncProps) || {});
    }, [
        mdReferenceRender,
        handleFootnoteDefinitionChange,
        (_props_markdownRenderConfig = props.markdownRenderConfig) === null || _props_markdownRenderConfig === void 0 ? void 0 : _props_markdownRenderConfig.fncProps
    ]);
    var messageContent = useMemo(function() {
        var _props_originData, _props_bubbleRenderConfig, _props_bubbleRenderConfig1, _props_bubbleRenderConfig2, _props_bubbleRenderConfig3, _props_bubbleRenderConfig_extraRender, _props_bubbleRenderConfig4, _props_originData_extra_tags_includes, _props_originData_extra_tags, _props_originData_extra, _props_originData1, _props_originData2, _props_originData_extra1, _props_originData3, _props_originData_extra2, _props_originData4, _props_originData5, _props_originData_extra3, _props_originData6, _props_docListProps, _props_originData7, _props_originData8, _props_originData_extra4, _props_originData9;
        if (content === LOADING_FLAT || !((_props_originData = props.originData) === null || _props_originData === void 0 ? void 0 : _props_originData.isFinished) && !content) {
            var _context_thoughtChain;
            if ((context === null || context === void 0 ? void 0 : (_context_thoughtChain = context.thoughtChain) === null || _context_thoughtChain === void 0 ? void 0 : _context_thoughtChain.alwaysRender) !== true) {
                var _props_classNames, _props_styles;
                return wrapSSR(/*#__PURE__*/ React.createElement("div", {
                    className: classNames('agent-item-default-content', "".concat(baseChatCls, "-messages-content-loading"), (context === null || context === void 0 ? void 0 : context.compact) ? "".concat(baseChatCls, "-messages-content-loading-compact") : "".concat(baseChatCls, "-messages-content-loading-default"), hashId),
                    "data-testid": "message-content",
                    role: "status",
                    "aria-live": "polite",
                    "aria-atomic": "true",
                    "aria-label": (locale === null || locale === void 0 ? void 0 : locale['chat.message.thinking']) || THINKING_FALLBACK_TEXT
                }, /*#__PURE__*/ React.createElement("span", {
                    className: classNames("".concat(baseChatCls, "-messages-content-loading-dots"), (_props_classNames = props.classNames) === null || _props_classNames === void 0 ? void 0 : _props_classNames.bubbleLoadingIconClassName),
                    style: (_props_styles = props.styles) === null || _props_styles === void 0 ? void 0 : _props_styles.bubbleLoadingIconStyle,
                    "data-testid": "message-thinking-dots",
                    "aria-hidden": "true"
                }, THINKING_DOT_INDICES.map(function(dotIndex) {
                    return /*#__PURE__*/ React.createElement("span", {
                        key: dotIndex,
                        className: "".concat(baseChatCls, "-messages-content-loading-dot"),
                        "data-testid": "message-thinking-dot"
                    });
                }))));
            }
            return null;
        }
        var defaultExtra = (props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig === void 0 ? void 0 : _props_bubbleRenderConfig.extraRender) === false ? null : /*#__PURE__*/ React.createElement(BubbleExtra, {
            placement: props.placement,
            style: props.bubbleListItemExtraStyle,
            readonly: readonly,
            rightRender: props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig1 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig1 === void 0 ? void 0 : _props_bubbleRenderConfig1.extraRightRender,
            onReply: props.onReply,
            onCancelLike: props.onCancelLike,
            onLikeCancel: props.onLikeCancel,
            shouldShowCopy: props.shouldShowCopy,
            useSpeech: props.useSpeech,
            shouldShowVoice: props.shouldShowVoice,
            onDisLike: props.onDisLike ? function() {
                return _async_to_generator(function() {
                    var _props_onDisLike, _bubbleRef_current_setMessageItem, _bubbleRef_current, error;
                    return _ts_generator(this, function(_state) {
                        switch(_state.label){
                            case 0:
                                _state.trys.push([
                                    0,
                                    2,
                                    ,
                                    3
                                ]);
                                return [
                                    4,
                                    (_props_onDisLike = props.onDisLike) === null || _props_onDisLike === void 0 ? void 0 : _props_onDisLike.call(props, props.originData)
                                ];
                            case 1:
                                _state.sent();
                                bubbleRef === null || bubbleRef === void 0 ? void 0 : (_bubbleRef_current = bubbleRef.current) === null || _bubbleRef_current === void 0 ? void 0 : (_bubbleRef_current_setMessageItem = _bubbleRef_current.setMessageItem) === null || _bubbleRef_current_setMessageItem === void 0 ? void 0 : _bubbleRef_current_setMessageItem.call(_bubbleRef_current, props.id, {
                                    feedback: 'thumbsDown'
                                });
                                return [
                                    3,
                                    3
                                ];
                            case 2:
                                error = _state.sent();
                                return [
                                    3,
                                    3
                                ];
                            case 3:
                                return [
                                    2
                                ];
                        }
                    });
                })();
            } : undefined,
            onDislike: props.onDislike ? function() {
                return _async_to_generator(function() {
                    var _props_onDislike, _bubbleRef_current_setMessageItem, _bubbleRef_current, error;
                    return _ts_generator(this, function(_state) {
                        switch(_state.label){
                            case 0:
                                _state.trys.push([
                                    0,
                                    2,
                                    ,
                                    3
                                ]);
                                return [
                                    4,
                                    (_props_onDislike = props.onDislike) === null || _props_onDislike === void 0 ? void 0 : _props_onDislike.call(props, props.originData)
                                ];
                            case 1:
                                _state.sent();
                                bubbleRef === null || bubbleRef === void 0 ? void 0 : (_bubbleRef_current = bubbleRef.current) === null || _bubbleRef_current === void 0 ? void 0 : (_bubbleRef_current_setMessageItem = _bubbleRef_current.setMessageItem) === null || _bubbleRef_current_setMessageItem === void 0 ? void 0 : _bubbleRef_current_setMessageItem.call(_bubbleRef_current, props.id, {
                                    feedback: 'thumbsDown'
                                });
                                return [
                                    3,
                                    3
                                ];
                            case 2:
                                error = _state.sent();
                                return [
                                    3,
                                    3
                                ];
                            case 3:
                                return [
                                    2
                                ];
                        }
                    });
                })();
            } : undefined,
            bubble: props,
            onRenderExtraNull: function onRenderExtraNull(isNull) {
                return setIsExtraNull(isNull);
            },
            onLike: props.onLike ? function() {
                return _async_to_generator(function() {
                    var _props_onLike, _bubbleRef_current_setMessageItem, _bubbleRef_current, error;
                    return _ts_generator(this, function(_state) {
                        switch(_state.label){
                            case 0:
                                _state.trys.push([
                                    0,
                                    2,
                                    ,
                                    3
                                ]);
                                return [
                                    4,
                                    (_props_onLike = props.onLike) === null || _props_onLike === void 0 ? void 0 : _props_onLike.call(props, props.originData)
                                ];
                            case 1:
                                _state.sent();
                                bubbleRef === null || bubbleRef === void 0 ? void 0 : (_bubbleRef_current = bubbleRef.current) === null || _bubbleRef_current === void 0 ? void 0 : (_bubbleRef_current_setMessageItem = _bubbleRef_current.setMessageItem) === null || _bubbleRef_current_setMessageItem === void 0 ? void 0 : _bubbleRef_current_setMessageItem.call(_bubbleRef_current, props.id, {
                                    feedback: 'thumbsUp'
                                });
                                return [
                                    3,
                                    3
                                ];
                            case 2:
                                error = _state.sent();
                                return [
                                    3,
                                    3
                                ];
                            case 3:
                                return [
                                    2
                                ];
                        }
                    });
                })();
            } : undefined
        });
        var extra = (props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig2 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig2 === void 0 ? void 0 : _props_bubbleRenderConfig2.extraRender) !== false && (props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig3 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig3 === void 0 ? void 0 : _props_bubbleRenderConfig3.extraRender) ? props === null || props === void 0 ? void 0 : (_props_bubbleRenderConfig4 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig4 === void 0 ? void 0 : (_props_bubbleRenderConfig_extraRender = _props_bubbleRenderConfig4.extraRender) === null || _props_bubbleRenderConfig_extraRender === void 0 ? void 0 : _props_bubbleRenderConfig_extraRender.call(_props_bubbleRenderConfig4, props, defaultExtra) : defaultExtra;
        if (/*#__PURE__*/ React.isValidElement(content)) {
            return wrapSSR(/*#__PURE__*/ React.createElement("div", {
                className: classNames('agent-item-default-content', "".concat(baseChatCls, "-messages-content-message"), hashId),
                "data-testid": "message-box-content",
                onDoubleClick: props.onDoubleClick
            }, beforeContent, content, afterContent, extra));
        }
        if (content === '...' || props.placement !== 'left' || (props === null || props === void 0 ? void 0 : (_props_originData1 = props.originData) === null || _props_originData1 === void 0 ? void 0 : (_props_originData_extra = _props_originData1.extra) === null || _props_originData_extra === void 0 ? void 0 : (_props_originData_extra_tags = _props_originData_extra.tags) === null || _props_originData_extra_tags === void 0 ? void 0 : (_props_originData_extra_tags_includes = _props_originData_extra_tags.includes) === null || _props_originData_extra_tags_includes === void 0 ? void 0 : _props_originData_extra_tags_includes.call(_props_originData_extra_tags, 'REJECT_TO_ANSWER')) || ((_props_originData2 = props.originData) === null || _props_originData2 === void 0 ? void 0 : _props_originData2.role) === 'bot') {
            var _props_originData10;
            return wrapSSR(/*#__PURE__*/ React.createElement("div", {
                className: classNames('agent-item-default-content', "".concat(baseChatCls, "-messages-content-message"), hashId),
                "data-testid": "message-box-content",
                onDoubleClick: props.onDoubleClick
            }, /*#__PURE__*/ React.createElement(MarkdownPreview, {
                beforeContent: beforeContent,
                afterContent: afterContent,
                placement: props.placement,
                markdownRenderConfig: props.markdownRenderConfig,
                isFinished: true,
                style: ((_props_originData10 = props.originData) === null || _props_originData10 === void 0 ? void 0 : _props_originData10.role) === 'bot' ? {} : {
                    color: '#343A45'
                } // 使用类名方式需要传递className，这里保留style以兼容现有API
                ,
                extra: extra,
                typing: false,
                originData: props.originData,
                content: content
            })));
        }
        // answerStatus= 'EXCEPTION'时 一定是异常情况
        if (((_props_originData3 = props.originData) === null || _props_originData3 === void 0 ? void 0 : (_props_originData_extra1 = _props_originData3.extra) === null || _props_originData_extra1 === void 0 ? void 0 : _props_originData_extra1.answerStatus) === 'EXCEPTION' || ((_props_originData4 = props.originData) === null || _props_originData4 === void 0 ? void 0 : (_props_originData_extra2 = _props_originData4.extra) === null || _props_originData_extra2 === void 0 ? void 0 : _props_originData_extra2.answerStatus) && !((_props_originData5 = props.originData) === null || _props_originData5 === void 0 ? void 0 : _props_originData5.content)) {
            return wrapSSR(/*#__PURE__*/ React.createElement(EXCEPTION, {
                content: props.originData.content,
                originData: props.originData,
                extra: isExtraNull ? null : extra
            }));
        }
        var docInfoList = [
            props === null || props === void 0 ? void 0 : (_props_originData6 = props.originData) === null || _props_originData6 === void 0 ? void 0 : (_props_originData_extra3 = _props_originData6.extra) === null || _props_originData_extra3 === void 0 ? void 0 : _props_originData_extra3.white_box_process
        ].flat(1);
        var docInfoDom = null;
        if (Array.isArray(docInfoList) && docInfoList.length > 0 && (docInfoList === null || docInfoList === void 0 ? void 0 : docInfoList.some(function(item) {
            var _item_output_chunks, _item_output;
            return ((item === null || item === void 0 ? void 0 : (_item_output = item.output) === null || _item_output === void 0 ? void 0 : (_item_output_chunks = _item_output.chunks) === null || _item_output_chunks === void 0 ? void 0 : _item_output_chunks.length) || 0) > 0;
        })) && ((_props_docListProps = props.docListProps) === null || _props_docListProps === void 0 ? void 0 : _props_docListProps.enable) !== false) {
            var _props_docListProps1, _props_originData_extra5, _props_originData11;
            docInfoDom = /*#__PURE__*/ React.createElement(DocInfoList, _object_spread_props(_object_spread({
                options: docInfoList.map(function(item) {
                    var _item_output;
                    return (_item_output = item.output) === null || _item_output === void 0 ? void 0 : _item_output.chunks;
                }).flat(1).filter(function(item) {
                    return item;
                })
            }, props.docListProps), {
                reference_url_info_list: ((_props_docListProps1 = props.docListProps) === null || _props_docListProps1 === void 0 ? void 0 : _props_docListProps1.reference_url_info_list) || ((_props_originData11 = props.originData) === null || _props_originData11 === void 0 ? void 0 : (_props_originData_extra5 = _props_originData11.extra) === null || _props_originData_extra5 === void 0 ? void 0 : _props_originData_extra5.reference_url_info_list) || []
            }));
        }
        return wrapSSR(/*#__PURE__*/ React.createElement(MarkdownPreview, {
            markdownRenderConfig: props.markdownRenderConfig,
            isFinished: (_props_originData7 = props.originData) === null || _props_originData7 === void 0 ? void 0 : _props_originData7.isFinished,
            beforeContent: beforeContent,
            afterContent: afterContent,
            fncProps: markdownPreviewFncProps,
            typing: typing,
            placement: props.placement,
            docListNode: docInfoDom,
            extra: isExtraNull ? null : extra,
            htmlRef: props.bubbleListRef,
            content: ((_props_originData8 = props.originData) === null || _props_originData8 === void 0 ? void 0 : _props_originData8.isFinished) && (props === null || props === void 0 ? void 0 : (_props_originData9 = props.originData) === null || _props_originData9 === void 0 ? void 0 : (_props_originData_extra4 = _props_originData9.extra) === null || _props_originData_extra4 === void 0 ? void 0 : _props_originData_extra4.answerStatus) === 'EXCEPTION' ? content || (locale === null || locale === void 0 ? void 0 : locale['chat.message.generateFailed']) || '生成回答失败，请重试' : content || '',
            originData: props.originData
        }));
    }, [
        content,
        props === null || props === void 0 ? void 0 : (_props_originData5 = props.originData) === null || _props_originData5 === void 0 ? void 0 : _props_originData5.feedback,
        (_props_originData6 = props.originData) === null || _props_originData6 === void 0 ? void 0 : _props_originData6.isFinished,
        (_props_originData7 = props.originData) === null || _props_originData7 === void 0 ? void 0 : _props_originData7.isAborted,
        (_props_originData8 = props.originData) === null || _props_originData8 === void 0 ? void 0 : _props_originData8.isLast,
        isExtraNull,
        props.deps,
        (_props_bubbleRenderConfig2 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig2 === void 0 ? void 0 : _props_bubbleRenderConfig2.beforeMessageRender,
        (_props_bubbleRenderConfig3 = props.bubbleRenderConfig) === null || _props_bubbleRenderConfig3 === void 0 ? void 0 : _props_bubbleRenderConfig3.afterMessageRender,
        markdownPreviewFncProps
    ]);
    return messageContent;
};
