import { useAgentAssignedSkillsSync } from "./useAgentAssignedSkillsSync";
import { useAgentModeState } from "./useAgentModeState";
import { useAgentProfileSelection } from "./useAgentProfileSelection";
import { usePendingAgentSettings } from "./useAgentSettingsCommands";
import { useAgentSettingsData } from "./useAgentSettingsData";
import { useAgentSettingsNavigation } from "./useAgentSettingsNavigation";
import { useAgentSettingsSelectOptions } from "./useAgentSettingsSelectOptions";
import { useAgentSkillActions } from "./useAgentSkillActions";
export function useAgentSettingsPanel(input) {
    const { agent, agentStub, agentMetadata, profiles, editContext, showAgentSettings, onReloadProfiles, buildCurrentContext, sanitizeAgentMetadata, onAgentUpdate, readOnly, setAgent, setAgentMetadata, } = input;
    const isPersistedAgent = !!agent?.userId;
    const isLocalOnlyDraftAgent = agent?.status === "new" && !isPersistedAgent;
    const { mode, setMode, handleSwitchToAutonomous } = useAgentModeState({
        agent,
        agentMetadata,
        setAgent,
        setAgentMetadata,
    });
    const { activeProfile, setActiveProfile, selectedModelId, setSelectedModelId, } = useAgentProfileSelection({
        agent,
        agentStub,
        profiles,
        setAgent,
    });
    const handleAssignedSkillIdsChange = useAgentAssignedSkillsSync({ setAgent });
    const settingsData = useAgentSettingsData({
        agent,
        agentMetadata,
        activeProfile,
        isLocalOnlyDraftAgent,
        mode,
        showAgentSettings,
        onReloadProfiles,
        onAssignedSkillIdsChange: handleAssignedSkillIdsChange,
    });
    const { modeOptions, profileOptions, modelOptions } = useAgentSettingsSelectOptions({
        agent,
        agentStub,
        activeProfile,
        profiles,
    });
    const { handleOpenProfileSettings, handleOpenSkillItem } = useAgentSettingsNavigation({ editContext, activeProfile });
    const { pendingSettingsRef, persistPendingSettingsIfNeeded, getPendingRequestSettings, } = usePendingAgentSettings({
        activeProfile,
        agentId: agent?.id,
        mode,
        profiles,
        selectedModelId,
    });
    const { handleAddSkill, handleRemoveSkill } = useAgentSkillActions({
        agent,
        agentMetadata,
        includeEditorContext: activeProfile?.includeEditorContext === true,
        includeLiveEditorContext: activeProfile?.includeLiveEditorContext === true,
        isLocalOnlyDraftAgent,
        editContext,
        pendingSettingsRef,
        getPendingRequestSettings,
        buildCurrentContext,
        sanitizeAgentMetadata,
        setAgent,
        setAgentMetadata,
        onAgentUpdate,
        metadataSelectedSkillIds: settingsData.metadataSelectedSkillIds,
        selectedSkillSet: settingsData.selectedSkillSet,
        readOnly,
        setSkillActionError: settingsData.setSkillActionError,
    });
    return {
        ...settingsData,
        activeProfile,
        setActiveProfile,
        selectedModelId,
        setSelectedModelId,
        isPersistedAgent,
        isLocalOnlyDraftAgent,
        mode,
        setMode,
        handleSwitchToAutonomous,
        modeOptions,
        profileOptions,
        modelOptions,
        handleOpenProfileSettings,
        handleOpenSkillItem,
        pendingSettingsRef,
        persistPendingSettingsIfNeeded,
        getPendingRequestSettings,
        handleAddSkill,
        handleRemoveSkill,
    };
}
//# sourceMappingURL=useAgentSettingsPanel.js.map