import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { PluginUtils } from '@baseplate-dev/project-builder-lib';
import { useBlockUnsavedChangesNavigate, useDefinitionSchema, useProjectDefinition, useResettableForm, } from '@baseplate-dev/project-builder-lib/web';
import { FormActionBar, MultiSwitchField, SectionList, SectionListSection, SectionListSectionContent, SectionListSectionDescription, SectionListSectionHeader, SectionListSectionTitle, } from '@baseplate-dev/ui-components';
import { zodResolver } from '@hookform/resolvers/zod';
import { useMemo } from 'react';
import { createDevAgentsPluginDefinitionSchema, DEV_AGENT_OPTIONS, } from '../schema/plugin-definition.js';
import '#src/styles.css';
export function DevAgentsDefinitionEditor({ definition: pluginMetadata, metadata, onSave, }) {
    const { definitionContainer, saveDefinitionWithFeedback } = useProjectDefinition();
    const devAgentsPluginDefinitionSchema = useDefinitionSchema(createDevAgentsPluginDefinitionSchema);
    const defaultValues = useMemo(() => pluginMetadata?.config ?? {
        enabledAgents: ['claude-code'],
        devAgentsOptions: {},
    }, [pluginMetadata?.config]);
    const form = useResettableForm({
        resolver: zodResolver(devAgentsPluginDefinitionSchema),
        defaultValues,
    });
    const { control, reset, handleSubmit } = form;
    const onSubmit = handleSubmit((data) => saveDefinitionWithFeedback((draftConfig) => {
        PluginUtils.setPluginConfig(draftConfig, metadata, data, definitionContainer);
    }, {
        successMessage: 'Successfully saved AI development agents configuration!',
        onSuccess: () => {
            onSave();
        },
    }));
    useBlockUnsavedChangesNavigate({ control, reset, onSubmit });
    return (_jsx("div", { className: "devagents:relative devagents:flex devagents:h-full devagents:flex-1 devagents:flex-col devagents:gap-4 devagents:overflow-hidden", children: _jsx("div", { className: "devagents:mb-[--action-bar-height] devagents:flex devagents:flex-1 devagents:overflow-y-auto", style: {
                '--action-bar-height': '52px',
            }, children: _jsxs("form", { onSubmit: onSubmit, className: "devagents:max-w-6xl devagents:flex-1", children: [_jsx("div", { className: "devagents:pb-16", children: _jsx(SectionList, { children: _jsxs(SectionListSection, { children: [_jsxs(SectionListSectionHeader, { children: [_jsx(SectionListSectionTitle, { children: "AI Development Agents" }), _jsx(SectionListSectionDescription, { children: "Select which AI coding agents your team uses. The plugin will generate appropriate configuration files (AGENTS.md, .agents/ directory) for your project. Agent-specific files like CLAUDE.md are generated only for selected agents." })] }), _jsx(SectionListSectionContent, { children: _jsx(MultiSwitchField.Controller, { control: control, name: "enabledAgents", label: "Enabled Agents", options: DEV_AGENT_OPTIONS }) })] }) }) }), _jsx(FormActionBar, { form: form, allowSaveWithoutDirty: !pluginMetadata })] }) }) }));
}
//# sourceMappingURL=dev-agents-definition-editor.js.map