import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { PluginUtils } from '@baseplate-dev/project-builder-lib';
import { useProjectDefinition } from '@baseplate-dev/project-builder-lib/web';
import { SelectFieldController } from '@baseplate-dev/ui-components';
import { STORAGE_MODELS } from '#src/storage/constants/model-names.js';
import '#src/styles.css';
export function FileTransformerForm({ name, formProps: { control }, originalModel, pluginKey, }) {
    const prefix = name;
    const controlTyped = control;
    const { definition, definitionContainer } = useProjectDefinition();
    const storageConfig = PluginUtils.configByKeyOrThrow(definition, pluginKey ?? '');
    const fileRelations = originalModel.model.relations?.filter((relation) => definitionContainer.nameFromId(relation.modelRef) ===
        STORAGE_MODELS.file) ?? [];
    const relationOptions = fileRelations.map((relation) => ({
        label: relation.name,
        value: relation.id,
    }));
    // Get available file categories from plugin config
    const categoryOptions = storageConfig.fileCategories.map((category) => ({
        label: category.name,
        value: category.id,
    }));
    return (_jsxs("div", { className: "storage:space-y-6", children: [_jsx(SelectFieldController, { className: "storage:w-full", control: controlTyped, label: "File Relation", name: `${prefix}.fileRelationRef`, options: relationOptions, placeholder: "Select a file relation..." }), _jsx(SelectFieldController, { className: "storage:w-full", control: controlTyped, label: "File Category", name: `${prefix}.categoryRef`, options: categoryOptions, placeholder: "Select a file category...", description: "The file category that defines upload constraints and authorization for this relation" })] }));
}
//# sourceMappingURL=file-transformer-form.js.map