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 _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;
}
import { CloseCircleFilled } from "@ant-design/icons";
import { Typography } from "antd";
import React, { useContext, useMemo } from "react";
import { LoadingSpinnerIcon } from "../Components/icons/LoadingSpinnerIcon";
import { I18nContext } from "../I18n";
import { DotLoading } from "./DotAni";
import { MarkdownEditorUpdate } from "./MarkdownEditor";
/**
 * DeepThink 组件 - 深度思考组件
 *
 * 该组件用于显示AI的深度思考过程，包括思考状态、思考内容、错误信息等。
 * 提供打字机效果、加载动画、错误处理等功能，展示AI的思考过程。
 *
 * @component
 * @description 深度思考组件，显示AI思考过程
 * @param {Object} props - 组件属性
 * @param {string} [props['data-testid']] - 测试ID
 * @param {boolean} [props.isFinished] - 是否已完成
 * @param {MarkdownEditorProps} [props.markdownRenderProps] - Markdown渲染配置
 * @param {Function} [props.onItemChange] - 项目变更回调（Item 子组件事件）
 * @param {Object} [props.output] - 输出结果
 * @param {Object} [props.output.response] - 响应数据
 * @param {string} [props.output.errorMsg] - 错误消息
 * @param {string} props.info - 思考信息
 * @param {string} props.category - 思考类别
 *
 * @example
 * ```tsx
 * <DeepThink
 *   info="分析用户需求"
 *   category="thinking"
 *   output={{ response: { content: "思考结果..." } }}
 *   isFinished={true}
 * />
 * ```
 *
 * @returns {React.ReactElement} 渲染的深度思考组件
 *
 * @remarks
 * - 显示AI思考过程
 * - 提供打字机效果
 * - 支持加载动画
 * - 处理错误信息
 * - 支持Markdown渲染
 * - 提供状态指示
 * - 支持国际化
 * - 提供自定义配置
 */ export var DeepThink = function(props) {
    var _props_output, _props_output_response, _props_output1, _props_output_response1, _props_output2;
    var errorMsg = ((_props_output = props.output) === null || _props_output === void 0 ? void 0 : _props_output.errorMsg) || ((_props_output1 = props.output) === null || _props_output1 === void 0 ? void 0 : (_props_output_response = _props_output1.response) === null || _props_output_response === void 0 ? void 0 : _props_output_response.error) || ((_props_output2 = props.output) === null || _props_output2 === void 0 ? void 0 : (_props_output_response1 = _props_output2.response) === null || _props_output_response1 === void 0 ? void 0 : _props_output_response1.errorMsg);
    var i18n = useContext(I18nContext);
    return useMemo(function() {
        var _i18n_locale, _props_output_response, _props_output, _props_output1, _props_output2, _props_output3, _i18n_locale1;
        return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement("div", {
            "data-testid": props['data-testid'],
            style: {
                display: 'flex',
                gap: '10px',
                flexDirection: 'column'
            }
        }, !props.output && !(props === null || props === void 0 ? void 0 : props.isFinished) ? /*#__PURE__*/ React.createElement("div", {
            style: {
                display: 'flex',
                alignItems: 'center',
                height: '38px',
                borderRadius: '12px',
                opacity: 1,
                wordBreak: 'break-all',
                wordWrap: 'break-word',
                flexDirection: 'row',
                padding: '8px',
                gap: '10px',
                alignSelf: 'stretch',
                background: '#FBFCFD',
                zIndex: 2
            }
        }, /*#__PURE__*/ React.createElement(LoadingSpinnerIcon, {
            size: 24
        }), (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale = i18n.locale) === null || _i18n_locale === void 0 ? void 0 : _i18n_locale.deepThinkingInProgress) || '正在深度思考中', /*#__PURE__*/ React.createElement(DotLoading, null)) : null, !errorMsg && props.output ? /*#__PURE__*/ React.createElement("div", {
            style: {
                flex: 1,
                display: 'flex',
                flexDirection: 'column',
                justifyContent: 'center',
                wordBreak: 'break-all',
                wordWrap: 'break-word',
                padding: '8px 12px',
                gap: '10px',
                alignSelf: 'stretch',
                background: '#FBFCFD',
                zIndex: 1,
                borderRadius: '12px'
            }
        }, /*#__PURE__*/ React.createElement("div", {
            style: {
                display: 'flex',
                gap: '10px',
                borderRadius: '12px',
                opacity: 1,
                wordBreak: 'break-all',
                wordWrap: 'break-word',
                flexDirection: 'column',
                alignSelf: 'stretch'
            },
            className: "code-view"
        }, /*#__PURE__*/ React.createElement(MarkdownEditorUpdate, _object_spread_props(_object_spread({}, props.markdownRenderProps), {
            typewriter: !((_props_output = props.output) === null || _props_output === void 0 ? void 0 : (_props_output_response = _props_output.response) === null || _props_output_response === void 0 ? void 0 : _props_output_response.error) && !props.isFinished && ((_props_output1 = props.output) === null || _props_output1 === void 0 ? void 0 : _props_output1.type) === 'TOKEN',
            isFinished: props.isFinished || ((_props_output2 = props.output) === null || _props_output2 === void 0 ? void 0 : _props_output2.type) !== 'TOKEN',
            initValue: ((_props_output3 = props.output) === null || _props_output3 === void 0 ? void 0 : _props_output3.data) || ''
        })))) : null, errorMsg ? /*#__PURE__*/ React.createElement("div", {
            style: {
                borderRadius: '12px',
                opacity: 1,
                display: 'flex',
                padding: '12px 12px',
                alignSelf: 'stretch',
                background: '#FFEDEC',
                wordBreak: 'break-all',
                minHeight: 18,
                wordWrap: 'break-word',
                zIndex: 2,
                backgroundColor: '#FFEDEC',
                border: '1px solid rgba(244, 244, 247, 0.7473)',
                gap: 8,
                alignItems: 'center',
                justifyContent: 'space-between'
            }
        }, /*#__PURE__*/ React.createElement("div", {
            style: {
                display: 'flex',
                flexDirection: 'column',
                gap: 12
            }
        }, /*#__PURE__*/ React.createElement("div", null, /*#__PURE__*/ React.createElement(CloseCircleFilled, {
            style: {
                color: '#FF4141',
                marginRight: 8
            }
        }), /*#__PURE__*/ React.createElement(Typography.Text, null, (i18n === null || i18n === void 0 ? void 0 : (_i18n_locale1 = i18n.locale) === null || _i18n_locale1 === void 0 ? void 0 : _i18n_locale1.taskExecutionFailed) || '任务执行失败，需要修改')), /*#__PURE__*/ React.createElement(Typography, {
            style: {
                color: '#FF4141',
                wordBreak: 'break-all',
                wordWrap: 'break-word'
            }
        }, JSON.stringify(errorMsg)))) : null));
    }, [
        props.category,
        JSON.stringify(props.output),
        props.costMillis
    ]);
};
