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;
}
import { PlusOutlined } from "@ant-design/icons";
import { Button, ConfigProvider, Tooltip, Typography } from "antd";
import classNames from "clsx";
import { motion } from "framer-motion";
import React, { memo, useContext, useMemo } from "react";
import { I18nContext } from "../I18n";
import { PauseIcon, PlayIcon, SimplePauseIcon, SimplePlayIcon, SimpleStopIcon, StopIcon } from "./icons";
import Robot from "./Robot";
import { useStyle } from "./style";
export * from "./Robot";
/**
 * 任务状态枚举
 * @enum {string}
 */ export var TASK_STATUS = /*#__PURE__*/ function(TASK_STATUS) {
    /** 任务正在运行中 */ TASK_STATUS["RUNNING"] = "running";
    /** 任务已成功完成 */ TASK_STATUS["SUCCESS"] = "success";
    /** 任务执行出错 */ TASK_STATUS["ERROR"] = "error";
    /** 任务已暂停 */ TASK_STATUS["PAUSE"] = "pause";
    /** 任务已停止 */ TASK_STATUS["STOPPED"] = "stopped";
    /** 任务已取消 */ TASK_STATUS["CANCELLED"] = "cancelled";
    return TASK_STATUS;
}({});
/**
 * 任务运行状态枚举
 * @enum {string}
 */ export var TASK_RUNNING_STATUS = /*#__PURE__*/ function(TASK_RUNNING_STATUS) {
    /** 正在运行中 */ TASK_RUNNING_STATUS["RUNNING"] = "running";
    /** 已完成 */ TASK_RUNNING_STATUS["COMPLETE"] = "complete";
    /** 已暂停 */ TASK_RUNNING_STATUS["PAUSE"] = "pause";
    return TASK_RUNNING_STATUS;
}({});
/**
 * 渲染按钮组的函数
 * 使用提前返回优化代码可读性
 *
 * @param status 任务状态
 * @param runningStatus 运行状态
 * @param callbacks 回调函数对象
 * @param baseCls 基础类名
 * @param hashId 哈希ID
 * @param locale 国际化配置
 * @returns 按钮组JSX
 */ var renderButtonGroup = function renderButtonGroup(param) {
    var taskStatus = param.taskStatus, taskRunningStatus = param.taskRunningStatus, actionsRender = param.actionsRender, baseCls = param.baseCls, hashId = param.hashId, locale = param.locale, onCreateNewTask = param.onCreateNewTask, onReplay = param.onReplay, onViewResult = param.onViewResult, onPause = param.onPause, onResume = param.onResume, onStop = param.onStop, variant = param.variant;
    var _locale_agentRunBar, _locale_agentRunBar1, _locale_agentRunBar2;
    // 任务运行中状态
    var isRunning = taskStatus === "running" && taskRunningStatus === "running";
    // 任务已暂停状态
    var isPause = taskStatus === "pause" || taskStatus === "running" && taskRunningStatus === "pause";
    // 处理自定义操作按钮（提前返回）
    if (actionsRender !== undefined) {
        var _locale_agentRunBar3, _locale_agentRunBar4, _locale_agentRunBar5, _locale_agentRunBar6, _locale_agentRunBar7, _locale_agentRunBar8;
        var actionNode = typeof actionsRender === 'function' ? actionsRender({
            status: taskStatus,
            runningStatus: taskRunningStatus
        }) : actionsRender;
        return /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(baseCls, "-button-wrapper"), hashId)
        }, actionNode, (isRunning || isPause) && onStop && /*#__PURE__*/ React.createElement(Tooltip, {
            mouseEnterDelay: 0.3,
            title: locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar3 = locale.agentRunBar) === null || _locale_agentRunBar3 === void 0 ? void 0 : _locale_agentRunBar3.stop
        }, /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(baseCls, "-pause"), hashId),
            role: "button",
            tabIndex: 0,
            "aria-label": locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar4 = locale.agentRunBar) === null || _locale_agentRunBar4 === void 0 ? void 0 : _locale_agentRunBar4.stop,
            onClick: onStop
        }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimpleStopIcon, null) : /*#__PURE__*/ React.createElement(StopIcon, null))), isRunning && onPause && /*#__PURE__*/ React.createElement(Tooltip, {
            title: locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar5 = locale.agentRunBar) === null || _locale_agentRunBar5 === void 0 ? void 0 : _locale_agentRunBar5.pause,
            mouseEnterDelay: 0.3
        }, /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(baseCls, "-pause"), hashId),
            role: "button",
            tabIndex: 0,
            "aria-label": locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar6 = locale.agentRunBar) === null || _locale_agentRunBar6 === void 0 ? void 0 : _locale_agentRunBar6.pause,
            onClick: onPause
        }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimplePauseIcon, null) : /*#__PURE__*/ React.createElement(PauseIcon, null))), isPause && onResume && /*#__PURE__*/ React.createElement(Tooltip, {
            title: locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar7 = locale.agentRunBar) === null || _locale_agentRunBar7 === void 0 ? void 0 : _locale_agentRunBar7.play,
            mouseEnterDelay: 0.3
        }, /*#__PURE__*/ React.createElement("div", {
            className: classNames("".concat(baseCls, "-play"), hashId),
            role: "button",
            tabIndex: 0,
            "aria-label": locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar8 = locale.agentRunBar) === null || _locale_agentRunBar8 === void 0 ? void 0 : _locale_agentRunBar8.play,
            onClick: onResume
        }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimplePlayIcon, null) : /*#__PURE__*/ React.createElement(PlayIcon, null))));
    }
    // 根据任务状态渲染不同的操作按钮
    var actionNode1 = null;
    // 任务已暂停状态
    if (isPause) {
        if (onCreateNewTask) {
            var _locale_agentRunBar9;
            actionNode1 = /*#__PURE__*/ React.createElement(Button, {
                onClick: onCreateNewTask,
                icon: /*#__PURE__*/ React.createElement(PlusOutlined, null),
                color: "default",
                variant: "solid"
            }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar9 = locale.agentRunBar) === null || _locale_agentRunBar9 === void 0 ? void 0 : _locale_agentRunBar9.newTask);
        }
    } else if (taskStatus === "stopped" || taskStatus === "cancelled") {
        var _locale_agentRunBar10, _locale_agentRunBar11;
        actionNode1 = /*#__PURE__*/ React.createElement(React.Fragment, null, onViewResult && /*#__PURE__*/ React.createElement(Button, {
            onClick: onViewResult,
            color: "default",
            variant: "solid",
            autoInsertSpace: false
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar10 = locale.agentRunBar) === null || _locale_agentRunBar10 === void 0 ? void 0 : _locale_agentRunBar10.submitTask), onCreateNewTask && /*#__PURE__*/ React.createElement(Button, {
            type: "primary",
            onClick: onCreateNewTask,
            icon: /*#__PURE__*/ React.createElement(PlusOutlined, null),
            color: "default",
            variant: "solid"
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar11 = locale.agentRunBar) === null || _locale_agentRunBar11 === void 0 ? void 0 : _locale_agentRunBar11.createNewTask));
    } else if (taskStatus === "success" && taskRunningStatus === "complete") {
        var _locale_agentRunBar12, _locale_agentRunBar13, _locale_agentRunBar14;
        actionNode1 = /*#__PURE__*/ React.createElement(React.Fragment, null, onReplay && /*#__PURE__*/ React.createElement(Button, {
            onClick: onReplay,
            variant: "solid",
            autoInsertSpace: false
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar12 = locale.agentRunBar) === null || _locale_agentRunBar12 === void 0 ? void 0 : _locale_agentRunBar12.replayTask), onViewResult && /*#__PURE__*/ React.createElement(Button, {
            onClick: onViewResult,
            color: "default",
            variant: "solid",
            autoInsertSpace: false
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar13 = locale.agentRunBar) === null || _locale_agentRunBar13 === void 0 ? void 0 : _locale_agentRunBar13.submitTask), onCreateNewTask && /*#__PURE__*/ React.createElement(Button, {
            onClick: onCreateNewTask,
            icon: /*#__PURE__*/ React.createElement(PlusOutlined, null),
            color: "default",
            variant: "solid"
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar14 = locale.agentRunBar) === null || _locale_agentRunBar14 === void 0 ? void 0 : _locale_agentRunBar14.newTask));
    } else if (taskStatus === "error") {
        var _locale_agentRunBar15, _locale_agentRunBar16, _locale_agentRunBar17;
        actionNode1 = /*#__PURE__*/ React.createElement(React.Fragment, null, onReplay && /*#__PURE__*/ React.createElement(Button, {
            onClick: onReplay,
            variant: "solid",
            autoInsertSpace: false
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar15 = locale.agentRunBar) === null || _locale_agentRunBar15 === void 0 ? void 0 : _locale_agentRunBar15.replayTask), onViewResult && /*#__PURE__*/ React.createElement(Button, {
            onClick: onViewResult,
            color: "default",
            variant: "solid",
            autoInsertSpace: false
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar16 = locale.agentRunBar) === null || _locale_agentRunBar16 === void 0 ? void 0 : _locale_agentRunBar16.submitTask), onCreateNewTask && /*#__PURE__*/ React.createElement(Button, {
            onClick: onCreateNewTask,
            icon: /*#__PURE__*/ React.createElement(PlusOutlined, null),
            color: "default",
            variant: "solid"
        }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar17 = locale.agentRunBar) === null || _locale_agentRunBar17 === void 0 ? void 0 : _locale_agentRunBar17.newTask));
    } else if (!isRunning && !isPause) {
        if (onCreateNewTask) {
            var _locale_agentRunBar18;
            actionNode1 = /*#__PURE__*/ React.createElement(Button, {
                onClick: onCreateNewTask,
                icon: /*#__PURE__*/ React.createElement(PlusOutlined, null),
                color: "default",
                variant: "solid"
            }, locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar18 = locale.agentRunBar) === null || _locale_agentRunBar18 === void 0 ? void 0 : _locale_agentRunBar18.createNewTask);
        }
    }
    var stopTitle = locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar = locale.agentRunBar) === null || _locale_agentRunBar === void 0 ? void 0 : _locale_agentRunBar.stop;
    var pauseTitle = locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar1 = locale.agentRunBar) === null || _locale_agentRunBar1 === void 0 ? void 0 : _locale_agentRunBar1.pause;
    var playTitle = locale === null || locale === void 0 ? void 0 : (_locale_agentRunBar2 = locale.agentRunBar) === null || _locale_agentRunBar2 === void 0 ? void 0 : _locale_agentRunBar2.play;
    return /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-button-wrapper"), hashId)
    }, actionNode1, (isRunning || isPause) && onStop && /*#__PURE__*/ React.createElement(Tooltip, {
        mouseEnterDelay: 0.3,
        title: stopTitle
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-pause"), hashId),
        role: "button",
        tabIndex: 0,
        "aria-label": stopTitle,
        onClick: onStop
    }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimpleStopIcon, null) : /*#__PURE__*/ React.createElement(StopIcon, null))), isRunning && onPause && /*#__PURE__*/ React.createElement(Tooltip, {
        title: pauseTitle,
        mouseEnterDelay: 0.3
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-pause"), hashId),
        role: "button",
        tabIndex: 0,
        "aria-label": pauseTitle,
        onClick: onPause
    }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimplePauseIcon, null) : /*#__PURE__*/ React.createElement(PauseIcon, null))), isPause && onResume && /*#__PURE__*/ React.createElement(Tooltip, {
        title: playTitle,
        mouseEnterDelay: 0.3
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-play"), hashId),
        role: "button",
        tabIndex: 0,
        "aria-label": playTitle,
        onClick: onResume
    }, variant === 'simple' ? /*#__PURE__*/ React.createElement(SimplePlayIcon, null) : /*#__PURE__*/ React.createElement(PlayIcon, null))));
};
/**
 * TaskRunning 组件 - 任务运行状态组件
 *
 * 该组件显示AI任务运行的状态信息，包括运行时间、状态指示、操作按钮等。
 * 支持多种任务状态：运行中、暂停、完成、重播等，提供完整的任务管理功能。
 *
 * @component
 * @description 任务运行状态组件，显示AI任务运行信息和操作按钮
 * @param {TaskRunningProps} props - 组件属性
 * @param {string} [props.className] - 自定义CSS类名
 * @param {React.CSSProperties} [props.style] - 自定义样式
 * @param {TASK_RUNNING_STATUS} [props.taskRunningStatus] - 任务运行状态
 * @param {TASK_STATUS} [props.taskStatus] - 任务状态
 * @param {() => void} [props.onPause] - 暂停任务回调
 * @param {() => void} [props.onResume] - 继续任务回调
 * @param {() => void} [props.onStop] - 停止任务回调
 * @param {() => void} [props.onCreateNewTask] - 创建新任务回调
 * @param {() => void} [props.onViewResult] - 查看结果回调
 * @param {() => void} [props.onReplay] - 重播任务回调
 * @param {string} [props.title] - 标题文案
 * @param {string} [props.description] - 描述文案
 * @param {React.ReactNode} [props.icon] - 自定义图标
 * @param {string} [props.iconTooltip] - 图标提示文案
 * @param {TaskRunningActionsRender | false} [props.actionsRender] - 自定义操作按钮
 * @param {TaskRunningVariant} [props.variant] - 样式变体
 *
 * @example
 * ```tsx
 * <TaskRunning
 *   title="正在运行中"
 *   description="任务执行中..."
 *   taskStatus={TASK_STATUS.RUNNING}
 *   taskRunningStatus={TASK_RUNNING_STATUS.RUNNING}
 *   onCreateNewTask={() => {}}
 *   onPause={() => {}}
 *   onResume={() => {}}
 *   onStop={() => {}}
 *   onReplay={() => {}}
 *   onViewResult={() => {}}
 *   icon="https://example.com/icon.png"
 *   iconTooltip="AI助手图标"
 * />
 * ```
 *
 * @returns {React.ReactElement} 渲染的任务运行状态组件
 *
 * @remarks
 * - 支持多种任务状态显示
 * - 提供任务操作按钮（暂停、继续、停止、重播、查看结果等）
 * - 支持自定义标题和描述文案
 * - 支持自定义图标和图标提示
 * - 提供机器人状态动画
 */ var TaskRunningComponent = function TaskRunningComponent(rest) {
    var className = rest.className, taskRunningStatus = rest.taskRunningStatus, taskStatus = rest.taskStatus, onPause = rest.onPause, onResume = rest.onResume, onCreateNewTask = rest.onCreateNewTask, onViewResult = rest.onViewResult, onReplay = rest.onReplay, onStop = rest.onStop, title = rest.title, description = rest.description, icon = rest.icon, iconTooltip = rest.iconTooltip, actionsRender = rest.actionsRender, _rest_variant = rest.variant, variant = _rest_variant === void 0 ? 'default' : _rest_variant;
    var context = useContext(ConfigProvider.ConfigContext);
    var baseCls = context === null || context === void 0 ? void 0 : context.getPrefixCls('task-running');
    var _useStyle = useStyle(baseCls), wrapSSR = _useStyle.wrapSSR, hashId = _useStyle.hashId;
    // 从context获取国际化配置
    var locale = useContext(I18nContext).locale;
    // 获取机器人状态
    var robotStatus = useMemo(function() {
        if (taskRunningStatus === "complete") {
            return 'dazing';
        }
        if (taskRunningStatus === "pause" || taskStatus === "pause") {
            return 'pause';
        }
        if (taskStatus === "success" || taskStatus === "error") {
            return 'default';
        }
        return 'thinking';
    }, [
        taskRunningStatus,
        taskStatus
    ]);
    var _obj;
    return wrapSSR(/*#__PURE__*/ React.createElement(motion.div, {
        className: classNames(baseCls, hashId, className, "".concat(baseCls, "-").concat(variant), (_obj = {}, _define_property(_obj, "".concat(baseCls, "-with-description"), description), _define_property(_obj, "".concat(baseCls, "-status-").concat(robotStatus), robotStatus), _obj)),
        "data-testid": baseCls,
        layout: "size",
        transition: {
            duration: 0.25,
            ease: 'easeOut'
        },
        style: rest.style
    }, /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-border"), hashId)
    }), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-background"), hashId)
    }), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-left"), hashId)
    }, icon !== false && /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-left-icon-wrapper"), hashId)
    }, /*#__PURE__*/ React.createElement(Tooltip, {
        title: iconTooltip
    }, /*#__PURE__*/ React.createElement(Robot, {
        icon: icon,
        status: robotStatus,
        size: 40
    }))), /*#__PURE__*/ React.createElement("div", {
        className: classNames("".concat(baseCls, "-left-content"), hashId)
    }, title && /*#__PURE__*/ React.createElement(Typography.Title, {
        className: classNames("".concat(baseCls, "-left-main-text"), hashId),
        ellipsis: {
            tooltip: title,
            rows: description ? 1 : 2
        }
    }, title), variant !== 'simple' && description && /*#__PURE__*/ React.createElement(Typography.Text, {
        className: classNames("".concat(baseCls, "-left-text"), hashId),
        ellipsis: {
            tooltip: description
        }
    }, description))), renderButtonGroup({
        taskStatus: taskStatus,
        taskRunningStatus: taskRunningStatus,
        onCreateNewTask: onCreateNewTask,
        onPause: onPause,
        onResume: onResume,
        onStop: onStop,
        onReplay: onReplay,
        onViewResult: onViewResult,
        actionsRender: actionsRender,
        baseCls: baseCls,
        hashId: hashId,
        locale: locale,
        variant: variant
    })));
};
// 使用 React.memo 优化性能，避免不必要的重新渲染
export var TaskRunning = /*#__PURE__*/ memo(TaskRunningComponent);
