import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { X } from "lucide-react";
import { Button } from "../../components/ui/button";
import { Splitter } from "../../editor/ui/Splitter";
import { WizardAgentTerminalPanel } from "./WizardAgentTerminalPanel";
import { WizardBlockingSummary, WizardWorkingSummaryCard, } from "./WizardCommunicationCards";
import { WizardTaskDetailsPanel } from "./WizardTaskDetailsPanel";
export function WizardTask(props) {
    const { task, agentId, agentStub, profiles, executionDisplay, canEdit, isPlanTask, isTaskDone, isEditingDescription, localDescriptionMarkdown, isSavingDescription, isEditingPlan, localPlanMarkdown, isSavingPlan, showFullTerminal, hasOpenQuestionnaire, shouldCollapseApprovalCommunication, shouldRenderAgentTerminalPanel, shouldShowWorkingTaskSummary, shouldShowAgentTerminal, shouldShowBlockingSummary, unresolvedBlockingDetails, openChatButton, summaryPlaceholderMessage, hideSummaryWaitingPlaceholder, onDescriptionEdit, onDescriptionChange, onDescriptionSave, onDescriptionCancel, onPlanEdit, onPlanChange, onPlanSave, onPlanCancel, onHideTerminal, onQuestionnaireOpenChange, onTaskChanged, onTaskApproved, onInteractionSubmitted, onCloseTask, onSelectTask, } = props;
    const taskDetailsContent = (_jsx(WizardTaskDetailsPanel, { task: task, agentId: agentId, executionDisplay: executionDisplay, canEdit: canEdit, isPlanTask: isPlanTask, isEditingDescription: isEditingDescription, localDescriptionMarkdown: localDescriptionMarkdown, isSavingDescription: isSavingDescription, isEditingPlan: isEditingPlan, localPlanMarkdown: localPlanMarkdown, isSavingPlan: isSavingPlan, shouldCollapseApprovalCommunication: shouldCollapseApprovalCommunication, openChatButton: openChatButton, onDescriptionEdit: onDescriptionEdit, onDescriptionChange: onDescriptionChange, onDescriptionSave: onDescriptionSave, onDescriptionCancel: onDescriptionCancel, onPlanEdit: onPlanEdit, onPlanChange: onPlanChange, onPlanSave: onPlanSave, onPlanCancel: onPlanCancel, onTaskChanged: onTaskChanged, onTaskApproved: onTaskApproved, onCloseTask: onCloseTask }));
    const fullTerminalPanel = agentStub ? (_jsx(WizardAgentTerminalPanel, { agentStub: agentStub, profiles: profiles, isActive: shouldShowAgentTerminal, displayMode: "full", hideBottomControls: false, className: "h-full", onInteractionSubmitted: onInteractionSubmitted, onQuestionnaireOpenChange: onQuestionnaireOpenChange, openChatButton: openChatButton, summaryPlaceholderMessage: summaryPlaceholderMessage, hideSummaryWaitingPlaceholder: hideSummaryWaitingPlaceholder })) : null;
    const useSplitterLayout = showFullTerminal && shouldRenderAgentTerminalPanel && !!agentStub;
    const hasBottomPanelContent = (shouldRenderAgentTerminalPanel && !showFullTerminal) ||
        shouldShowBlockingSummary;
    const taskDetailsContainerClass = hasOpenQuestionnaire
        ? "flex max-h-[30%] min-h-0 shrink-0 flex-col overflow-hidden"
        : "flex min-h-0 flex-1 flex-col overflow-hidden";
    const bottomPanelContainerClass = isTaskDone || shouldShowBlockingSummary
        ? "flex shrink-0 flex-col"
        : "flex min-h-0 flex-1 flex-col";
    const splitterPanels = [
        {
            name: "task-details",
            defaultSize: 50,
            content: taskDetailsContent,
        },
        {
            name: "terminal",
            defaultSize: 50,
            content: (_jsxs("div", { className: "relative h-full", children: [_jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "absolute top-2 right-2 z-10 shrink-0", "aria-label": "Hide chat", "data-testid": "taskboard-wizard-hide-terminal", onClick: onHideTerminal, children: _jsx(X, { className: "h-4 w-4" }) }), fullTerminalPanel] })),
        },
    ];
    const bottomPanelContent = (_jsx("div", { className: bottomPanelContainerClass, children: _jsxs("div", { className: "min-h-0 flex-1", children: [shouldShowWorkingTaskSummary ? (_jsx(WizardWorkingSummaryCard, { openChatButton: openChatButton })) : shouldRenderAgentTerminalPanel && !showFullTerminal ? (_jsx("div", { className: shouldShowAgentTerminal ? "h-full" : "hidden", children: _jsx(WizardAgentTerminalPanel, { agentStub: agentStub, profiles: profiles, isActive: shouldShowAgentTerminal, displayMode: "summary", hideBottomControls: true, className: "h-full", onInteractionSubmitted: onInteractionSubmitted, onQuestionnaireOpenChange: onQuestionnaireOpenChange, openChatButton: openChatButton, summaryPlaceholderMessage: summaryPlaceholderMessage, hideSummaryWaitingPlaceholder: hideSummaryWaitingPlaceholder }) })) : null, shouldShowBlockingSummary ? (_jsx(WizardBlockingSummary, { unresolvedBlockingDetails: unresolvedBlockingDetails, onSelectTask: onSelectTask })) : null] }) }));
    return useSplitterLayout ? (_jsx(Splitter, { panels: splitterPanels, direction: "vertical", localStorageKey: "taskboard-wizard-full-terminal-splitter", className: "h-full min-h-0 flex-1" })) : (_jsxs(_Fragment, { children: [_jsx("div", { className: taskDetailsContainerClass, children: taskDetailsContent }), hasBottomPanelContent ? bottomPanelContent : null] }));
}
//# sourceMappingURL=WizardTask.js.map