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 { CopyLottie, DislikeLottie, LikeLottie, RefreshLottie } from "../..";
import { DislikeFilled, LikeFilled } from "@ant-design/icons";
import { ConfigProvider, Divider } from "antd";
import classNames from "clsx";
import copy from "copy-to-clipboard";
import { motion } from "framer-motion";
import React, { useContext, useEffect, useMemo, useState } from "react";
import { ActionIconBox } from "../../Components/ActionIconBox";
import { Loading } from "../../Components/Loading";
import { useLocale } from "../../I18n";
import { BubbleConfigContext } from "../BubbleConfigProvide";
import { CopyButton } from "./CopyButton";
import { VoiceButton } from "./VoiceButton";
/**
 * BubbleExtra 组件用于显示聊天项的额外操作按钮，如点赞、踩、复制等。
 *
 * @param {BubbleExtraProps} props - 组件的属性。
 * @param {Function} props.onReply - 回复操作的回调函数。
 * @param {Object} props.bubble - 聊天项的数据对象。
 * @param {boolean} props.readonly - 是否为只读模式。
 * @param {Function} [props.onLike] - 点赞操作的回调函数。
 * @param {Function} [props.onDislike] - 踩操作的回调函数（符合命名规范）
 * @param {Function} [props.onDisLike] - 踩操作的回调函数（已废弃，请使用 onDislike）
 *
 * @returns {JSX.Element} 返回一个包含操作按钮的 JSX 元素。
 *
 * @example
 * ```tsx
 * <BubbleExtra
 *   onReply={handleReply}
 *   bubble={bubbleData}
 *   readonly={false}
 *   onLike={handleLike}
 *   onDisLike={handleDisLike}
 * />
 * ```
 */ export var BubbleExtra = function BubbleExtra(_0) {
    var onReply = _0.onReply, bubble = _0.bubble, readonly = _0.readonly, pure = _0.pure, placement = _0.placement, props = _object_without_properties(_0, [
        "onReply",
        "bubble",
        "readonly",
        "pure",
        "placement"
    ]);
    var _originalData_extra, _originalData_extra1, _originalData_extra2, _originalData_extra3, _bubble_originData, _bubble_originData1, _props_rightRender;
    var getPrefixCls = useContext(ConfigProvider.ConfigContext).getPrefixCls;
    var context = useContext(BubbleConfigContext);
    var locale = useLocale();
    var _useState = _sliced_to_array(useState(false), 2), feedbackLoading = _useState[0], setFeedbackLoading = _useState[1];
    // 获取聊天项的原始数据
    var originalData = bubble === null || bubble === void 0 ? void 0 : bubble.originData;
    var prefixCls = getPrefixCls('chat-item-extra');
    var chatCls = getPrefixCls('agentic-ui');
    // 判断是否已经点过赞或踩
    var alreadyFeedback = [
        'thumbsDown',
        'thumbsUp'
    ].includes((originalData === null || originalData === void 0 ? void 0 : originalData.feedback) || '');
    // 判断是否应该显示点赞
    var shouldShowLike = !(originalData === null || originalData === void 0 ? void 0 : (_originalData_extra = originalData.extra) === null || _originalData_extra === void 0 ? void 0 : _originalData_extra.answerStatus) && !readonly && (props.onLike || (originalData === null || originalData === void 0 ? void 0 : originalData.feedback)) && (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) !== 'thumbsDown';
    // 判断是否应该显示踩
    var shouldShowDisLike = !(originalData === null || originalData === void 0 ? void 0 : (_originalData_extra1 = originalData.extra) === null || _originalData_extra1 === void 0 ? void 0 : _originalData_extra1.answerStatus) && !readonly && (props.onDislike || props.onDisLike || (originalData === null || originalData === void 0 ? void 0 : originalData.feedback)) && (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) !== 'thumbsUp';
    // 获取点赞按钮的标题文本
    var likeButtonTitle = useMemo(function() {
        if (alreadyFeedback && (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) === 'thumbsUp') {
            // 已经点赞的情况
            if (props.onLikeCancel || props.onCancelLike) {
                return (locale === null || locale === void 0 ? void 0 : locale['chat.message.cancel-like']) || '取消点赞';
            } else {
                return (locale === null || locale === void 0 ? void 0 : locale['chat.message.feedback-success']) || '已经反馈过了哦';
            }
        } else {
            // 未点赞的情况
            return (locale === null || locale === void 0 ? void 0 : locale['chat.message.like']) || '喜欢';
        }
    }, [
        alreadyFeedback,
        originalData === null || originalData === void 0 ? void 0 : originalData.feedback,
        !!(props.onLikeCancel || props.onCancelLike),
        locale
    ]);
    // 获取点踩按钮的标题文本
    var getDislikeButtonTitle = useMemo(function() {
        if (alreadyFeedback) {
            return (locale === null || locale === void 0 ? void 0 : locale['chat.message.feedback-success']) || '已经反馈过了哦';
        } else {
            return (locale === null || locale === void 0 ? void 0 : locale['chat.message.dislike']) || '不喜欢';
        }
    }, [
        alreadyFeedback,
        locale
    ]);
    var typing = (originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) !== true && (originalData === null || originalData === void 0 ? void 0 : originalData.isFinished) === false && (originalData === null || originalData === void 0 ? void 0 : (_originalData_extra2 = originalData.extra) === null || _originalData_extra2 === void 0 ? void 0 : _originalData_extra2.isHistory) === undefined && (originalData === null || originalData === void 0 ? void 0 : originalData.isFinished) !== undefined;
    var like = useMemo(function() {
        return shouldShowLike && !typing ? /*#__PURE__*/ React.createElement(ActionIconBox, {
            "data-testid": "like-button",
            active: (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) === 'thumbsUp',
            title: likeButtonTitle,
            onClick: function onClick(e) {
                return _async_to_generator(function() {
                    var _e_preventDefault, _e_stopPropagation, _props_onLike, error;
                    return _ts_generator(this, function(_state) {
                        switch(_state.label){
                            case 0:
                                e === null || e === void 0 ? void 0 : (_e_preventDefault = e.preventDefault) === null || _e_preventDefault === void 0 ? void 0 : _e_preventDefault.call(e);
                                e === null || e === void 0 ? void 0 : (_e_stopPropagation = e.stopPropagation) === null || _e_stopPropagation === void 0 ? void 0 : _e_stopPropagation.call(e);
                                _state.label = 1;
                            case 1:
                                _state.trys.push([
                                    1,
                                    8,
                                    ,
                                    9
                                ]);
                                if (!alreadyFeedback) return [
                                    3,
                                    6
                                ];
                                if (!((originalData === null || originalData === void 0 ? void 0 : originalData.feedback) === 'thumbsUp')) return [
                                    3,
                                    5
                                ];
                                if (!props.onLikeCancel) return [
                                    3,
                                    3
                                ];
                                return [
                                    4,
                                    props.onLikeCancel(bubble.originData)
                                ];
                            case 2:
                                _state.sent();
                                return [
                                    3,
                                    5
                                ];
                            case 3:
                                if (!props.onCancelLike) return [
                                    3,
                                    5
                                ];
                                return [
                                    4,
                                    props.onCancelLike(bubble.originData)
                                ];
                            case 4:
                                _state.sent();
                                _state.label = 5;
                            case 5:
                                return [
                                    2
                                ];
                            case 6:
                                return [
                                    4,
                                    (_props_onLike = props.onLike) === null || _props_onLike === void 0 ? void 0 : _props_onLike.call(props)
                                ];
                            case 7:
                                _state.sent();
                                return [
                                    3,
                                    9
                                ];
                            case 8:
                                error = _state.sent();
                                return [
                                    3,
                                    9
                                ];
                            case 9:
                                return [
                                    2
                                ];
                        }
                    });
                })();
            }
        }, function(isHovered) {
            return (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) === 'thumbsUp' ? /*#__PURE__*/ React.createElement(LikeFilled, null) : /*#__PURE__*/ React.createElement(LikeLottie, {
                active: isHovered
            });
        }) : null;
    }, [
        shouldShowLike,
        alreadyFeedback,
        originalData === null || originalData === void 0 ? void 0 : originalData.isFinished,
        typing,
        feedbackLoading,
        props.onLikeCancel,
        props.onCancelLike
    ]);
    var disLike = useMemo(function() {
        return shouldShowDisLike && !typing ? /*#__PURE__*/ React.createElement(ActionIconBox, {
            "data-testid": "dislike-button",
            loading: feedbackLoading,
            onLoadingChange: setFeedbackLoading,
            title: getDislikeButtonTitle,
            onClick: function onClick() {
                return _async_to_generator(function() {
                    var error;
                    return _ts_generator(this, function(_state) {
                        switch(_state.label){
                            case 0:
                                _state.trys.push([
                                    0,
                                    5,
                                    ,
                                    6
                                ]);
                                if (alreadyFeedback) {
                                    // message.error('您已经点过赞或踩了');
                                    return [
                                        2
                                    ];
                                }
                                if (!props.onDislike) return [
                                    3,
                                    2
                                ];
                                return [
                                    4,
                                    props.onDislike()
                                ];
                            case 1:
                                _state.sent();
                                return [
                                    3,
                                    4
                                ];
                            case 2:
                                if (!props.onDisLike) return [
                                    3,
                                    4
                                ];
                                return [
                                    4,
                                    props.onDisLike()
                                ];
                            case 3:
                                _state.sent();
                                _state.label = 4;
                            case 4:
                                return [
                                    3,
                                    6
                                ];
                            case 5:
                                error = _state.sent();
                                return [
                                    3,
                                    6
                                ];
                            case 6:
                                return [
                                    2
                                ];
                        }
                    });
                })();
            }
        }, function(isHovered) {
            return (originalData === null || originalData === void 0 ? void 0 : originalData.feedback) === 'thumbsDown' ? /*#__PURE__*/ React.createElement(DislikeFilled, null) : /*#__PURE__*/ React.createElement(DislikeLottie, {
                active: isHovered
            });
        }) : null;
    }, [
        shouldShowDisLike,
        feedbackLoading,
        alreadyFeedback,
        originalData === null || originalData === void 0 ? void 0 : originalData.isFinished,
        typing
    ]);
    /**
   * 判断是否应该显示复制选项。
   *
   * 复制选项显示需要满足以下条件：
   * 1. 基础条件（必须全部满足）：
   *    - `navigator.clipboard` API 可用。
   *    - 聊天项的原始数据包含内容
   *    - 聊天项的原始数据在额外字段中没有回答状态
   *    - 聊天项的内容不等于本地化的 'chat.message.aborted' 消息或其默认值 '回答已停止生成'
   * 2. 第4个条件：shouldShowCopy 控制
   *    - 如果用户传递了 shouldShowCopy 函数，则调用函数判断
   *    - 如果用户传递了 shouldShowCopy 布尔值，则直接使用该值
   *    - 如果用户未传递 shouldShowCopy（undefined），则默认为 true
   *
   * @constant
   * @type {boolean}
   */ var shouldShowCopy = useMemo(function() {
        var _originalData_extra;
        var defaultConditions = (originalData === null || originalData === void 0 ? void 0 : originalData.content) && !(originalData === null || originalData === void 0 ? void 0 : (_originalData_extra = originalData.extra) === null || _originalData_extra === void 0 ? void 0 : _originalData_extra.answerStatus) && (originalData === null || originalData === void 0 ? void 0 : originalData.content) !== ((locale === null || locale === void 0 ? void 0 : locale['chat.message.aborted']) || '回答已停止生成');
        if (!defaultConditions) {
            return false;
        }
        if (typeof props.shouldShowCopy === 'function') {
            return props.shouldShowCopy(bubble);
        } else if (typeof props.shouldShowCopy === 'boolean') {
            return props.shouldShowCopy;
        }
        return true;
    }, [
        props.shouldShowCopy,
        bubble,
        originalData === null || originalData === void 0 ? void 0 : originalData.content,
        originalData === null || originalData === void 0 ? void 0 : (_originalData_extra3 = originalData.extra) === null || _originalData_extra3 === void 0 ? void 0 : _originalData_extra3.answerStatus,
        locale
    ]);
    var copyDom = useMemo(function() {
        return shouldShowCopy ? /*#__PURE__*/ React.createElement(CopyButton, {
            "data-testid": "chat-item-copy-button",
            title: (locale === null || locale === void 0 ? void 0 : locale['chat.message.copy']) || '复制',
            onClick: function onClick() {
                try {
                    var _bubble_originData;
                    copy(((_bubble_originData = bubble.originData) === null || _bubble_originData === void 0 ? void 0 : _bubble_originData.content) || '');
                } catch (error) {
                    // 复制失败时静默处理
                    console.error('复制失败:', error);
                }
            },
            showTitle: false
        }, function(isHovered) {
            return /*#__PURE__*/ React.createElement(CopyLottie, {
                active: isHovered
            });
        }) : null;
    }, [
        shouldShowCopy,
        locale,
        (_bubble_originData = bubble.originData) === null || _bubble_originData === void 0 ? void 0 : _bubble_originData.content
    ]);
    var voiceDom = useMemo(function() {
        var _originalData_extra, _bubble_originData;
        /**
     * 判断是否应该显示语音选项。
     *
     * 语音选项显示需要满足以下条件：
     * 基础条件（必须全部满足）：
     *    - 聊天项的原始数据包含内容
     *    - 聊天项的原始数据在额外字段中没有回答状态
     *    - 聊天项的内容不等于本地化的 'chat.message.aborted' 消息或其默认值 '回答已停止生成'
     * */ var defaultShow = !!(originalData === null || originalData === void 0 ? void 0 : originalData.content) && !(originalData === null || originalData === void 0 ? void 0 : (_originalData_extra = originalData.extra) === null || _originalData_extra === void 0 ? void 0 : _originalData_extra.answerStatus) && !typing && (originalData === null || originalData === void 0 ? void 0 : originalData.content) !== ((locale === null || locale === void 0 ? void 0 : locale['chat.message.aborted']) || '回答已停止生成');
        if (!props.shouldShowVoice || !defaultShow) return null;
        return /*#__PURE__*/ React.createElement(VoiceButton, {
            text: ((_bubble_originData = bubble.originData) === null || _bubble_originData === void 0 ? void 0 : _bubble_originData.content) || '',
            defaultRate: 1,
            rateOptions: [
                1.5,
                1.25,
                1,
                0.75
            ],
            useSpeech: props.useSpeech
        });
    }, [
        props.shouldShowVoice,
        props.useSpeech,
        (_bubble_originData1 = bubble.originData) === null || _bubble_originData1 === void 0 ? void 0 : _bubble_originData1.content
    ]);
    var dom = useMemo(function() {
        return voiceDom || copyDom || like || disLike ? /*#__PURE__*/ React.createElement(motion.div, {
            style: {
                display: 'flex',
                gap: 8,
                alignItems: 'center'
            },
            variants: {
                visible: {
                    opacity: 1,
                    transition: {
                        when: 'beforeChildren',
                        staggerChildren: 0.1,
                        delayChildren: 0.5
                    }
                },
                hidden: {
                    opacity: 0,
                    transition: {
                        when: 'afterChildren'
                    }
                }
            },
            whileInView: "visible",
            initial: "hidden",
            animate: "visible",
            className: classNames("".concat(prefixCls, "-action-box"))
        }, voiceDom ? voiceDom : null, copyDom ? copyDom : null, (voiceDom || copyDom) && (like || disLike) && /*#__PURE__*/ React.createElement(Divider, {
            type: "vertical",
            style: {
                margin: '0px 2px'
            }
        }), like ? like : null, disLike ? disLike : null) : null;
    }, [
        voiceDom,
        copyDom,
        like,
        disLike,
        prefixCls
    ]);
    var reSend = useMemo(function() {
        var _originalData_extra_preMessage, _originalData_extra;
        if ((originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) && !originalData.isFinished) {
            return /*#__PURE__*/ React.createElement("span", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.aborted']) || '回答已停止生成');
        }
        if (!(originalData === null || originalData === void 0 ? void 0 : (_originalData_extra = originalData.extra) === null || _originalData_extra === void 0 ? void 0 : (_originalData_extra_preMessage = _originalData_extra.preMessage) === null || _originalData_extra_preMessage === void 0 ? void 0 : _originalData_extra_preMessage.content)) return null;
        if (typing) return null;
        return /*#__PURE__*/ React.createElement(ActionIconBox, {
            "data-testid": "reply-button",
            borderLess: true,
            onClick: function onClick() {
                return _async_to_generator(function() {
                    var _bubble_originData_extra_preMessage, _bubble_originData_extra, _bubble_originData;
                    return _ts_generator(this, function(_state) {
                        onReply === null || onReply === void 0 ? void 0 : onReply(((_bubble_originData = bubble.originData) === null || _bubble_originData === void 0 ? void 0 : (_bubble_originData_extra = _bubble_originData.extra) === null || _bubble_originData_extra === void 0 ? void 0 : (_bubble_originData_extra_preMessage = _bubble_originData_extra.preMessage) === null || _bubble_originData_extra_preMessage === void 0 ? void 0 : _bubble_originData_extra_preMessage.content) || (locale === null || locale === void 0 ? void 0 : locale['chat.message.retrySend']) || '重新生成');
                        return [
                            2
                        ];
                    });
                })();
            },
            title: (locale === null || locale === void 0 ? void 0 : locale['chat.message.retrySend']) || '重新生成'
        }, function(isHovered) {
            return /*#__PURE__*/ React.createElement("div", {
                className: classNames("".concat(chatCls, "-messages-content-retry")),
                "data-messages-content-retry": true
            }, /*#__PURE__*/ React.createElement(RefreshLottie, {
                active: isHovered
            }), /*#__PURE__*/ React.createElement("span", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.retrySend']) || '重新生成'));
        });
    }, [
        originalData === null || originalData === void 0 ? void 0 : originalData.isAborted,
        typing,
        originalData === null || originalData === void 0 ? void 0 : originalData.isFinished,
        locale
    ]);
    useEffect(function() {
        var _props_onRenderExtraNull;
        (_props_onRenderExtraNull = props.onRenderExtraNull) === null || _props_onRenderExtraNull === void 0 ? void 0 : _props_onRenderExtraNull.call(props, !dom && !reSend);
    }, [
        dom,
        reSend
    ]);
    // 检查是否有任何内容需要渲染
    var hasLeftContent = typing && originalData.content !== '...' || reSend;
    var rightDom = props.rightRender === false ? null : props.rightRender ? (_props_rightRender = props.rightRender) === null || _props_rightRender === void 0 ? void 0 : _props_rightRender.call(props, _object_spread_props(_object_spread({}, props), {
        bubble: bubble,
        onReply: onReply,
        onRenderExtraNull: props.onRenderExtraNull
    }), {
        like: like,
        disLike: disLike,
        copy: copyDom,
        reply: reSend
    }) : dom;
    var hasRightContent = (originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) ? copyDom : props.rightRender === false ? false : !!rightDom;
    // 如果没有任何内容，直接返回 null
    if (!hasLeftContent && !hasRightContent) return null;
    if (!copyDom && (originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) && !reSend) {
        return null;
    }
    if (pure) {
        return [
            reSend,
            like,
            disLike,
            copyDom,
            voiceDom
        ];
    }
    var inPopover = context === null || context === void 0 ? void 0 : context.extraShowOnHover;
    return /*#__PURE__*/ React.createElement("div", {
        className: prefixCls,
        style: _object_spread(_object_spread_props(_object_spread({
            display: 'flex',
            alignItems: 'center',
            justifyContent: 'space-between',
            width: '100%'
        }, inPopover ? {
            padding: 0
        } : {
            paddingLeft: placement === 'right' ? 0 : 'var(--padding-5x)',
            paddingRight: placement === 'right' ? 0 : 'var(--padding-5x)',
            paddingTop: placement === 'right' ? 0 : 'var(--padding-1x)',
            paddingBottom: placement === 'right' ? 0 : 'var(--padding-2x)'
        }), {
            color: 'var(--color-gray-text-secondary)',
            fontSize: (context === null || context === void 0 ? void 0 : context.compact) ? '11px' : '13px',
            gap: 4
        }), props.style)
    }, typing && originalData.content !== '...' ? /*#__PURE__*/ React.createElement("div", {
        style: {
            display: 'flex',
            alignItems: 'center',
            gap: 4
        }
    }, /*#__PURE__*/ React.createElement(Loading, {
        style: {
            fontSize: (context === null || context === void 0 ? void 0 : context.compact) ? 20 : 16
        }
    }), /*#__PURE__*/ React.createElement("span", null, (locale === null || locale === void 0 ? void 0 : locale['chat.message.generating']) || '')) : null, reSend || null, (originalData === null || originalData === void 0 ? void 0 : originalData.isAborted) ? copyDom : rightDom);
};
