import { jsx, jsxs } from "react/jsx-runtime";
import { memo, useCallback, useRef } from "react";
import { StageTask } from "./StageNode.styles.js";
import { StageTaskEntryConditionIcon } from "./StageTaskEntryConditionIcon.js";
import { TaskContent } from "./TaskContent.js";
import { TaskMenu } from "./TaskMenu.js";
const EventDrivenTaskItemComponent = ({ task, taskExecution, isSelected, getContextMenuItems, onTaskClick, isTaskLoading })=>{
    const taskRef = useRef(null);
    const menuRef = useRef(null);
    const handleClick = useCallback((e)=>{
        onTaskClick(e, task.id);
    }, [
        onTaskClick,
        task.id
    ]);
    const handleContextMenu = useCallback((e)=>{
        menuRef.current?.handleContextMenu(e);
    }, []);
    return /*#__PURE__*/ jsxs(StageTask, {
        ref: taskRef,
        "data-testid": `stage-task-${task.id}`,
        selected: isSelected,
        status: taskExecution?.status,
        onClick: handleClick,
        ...getContextMenuItems && !isTaskLoading && {
            onContextMenu: handleContextMenu
        },
        children: [
            /*#__PURE__*/ jsx(TaskContent, {
                task: task,
                taskExecution: taskExecution
            }),
            /*#__PURE__*/ jsx(StageTaskEntryConditionIcon, {
                task: task
            }),
            getContextMenuItems && /*#__PURE__*/ jsx(TaskMenu, {
                ref: menuRef,
                taskId: task.id,
                getContextMenuItems: getContextMenuItems,
                disabled: isTaskLoading
            })
        ]
    });
};
const EventDrivenTaskItem = /*#__PURE__*/ memo(EventDrivenTaskItemComponent);
export { EventDrivenTaskItem };
