import { useCallback } from "react";
export function useAgentTerminalActions(input) {
    const { commands, prompt, setPrompt, setShowPredefined, setShowAgentSettings, setShowSkillPicker, textareaRef, handleOpenProfileSettings, } = input;
    const handleStopFromComposer = useCallback(() => {
        void commands.stopRun();
    }, [commands]);
    const handleSubmitFromComposer = useCallback(() => {
        void commands.submitPrompt({
            text: prompt,
            source: "composer",
            resolveComposerPlaceholders: true,
        });
    }, [commands, prompt]);
    const handleGreetingPromptClick = useCallback((nextPrompt) => {
        setPrompt(nextPrompt);
        setTimeout(() => {
            const submitButton = document.querySelector('button[data-testid="agent-send-stop-button"]');
            if (submitButton) {
                submitButton.click();
            }
            else {
                void commands.submitPrompt({
                    text: nextPrompt,
                    source: "composer",
                    resolveComposerPlaceholders: true,
                });
            }
        }, 0);
    }, [commands, setPrompt]);
    const handleSelectPredefinedPrompt = useCallback((selectedPrompt) => {
        setPrompt(selectedPrompt);
        setShowPredefined(false);
        textareaRef.current?.focus();
    }, [setPrompt, setShowPredefined, textareaRef]);
    const handleSettingsOpenChange = useCallback((open) => {
        setShowAgentSettings(open);
        if (!open) {
            setShowSkillPicker(false);
        }
    }, [setShowAgentSettings, setShowSkillPicker]);
    const handleOpenProfileSettingsFromSettings = useCallback(async (options) => {
        await handleOpenProfileSettings(options);
        setShowAgentSettings(false);
    }, [handleOpenProfileSettings, setShowAgentSettings]);
    return {
        handleStopFromComposer,
        handleSubmitFromComposer,
        handleGreetingPromptClick,
        handleSelectPredefinedPrompt,
        handleSettingsOpenChange,
        handleOpenProfileSettingsFromSettings,
    };
}
//# sourceMappingURL=useAgentTerminalActions.js.map