import { jsx } from "react/jsx-runtime";
import "react";
import { FormOutlined } from "@ant-design/icons";
import { useSchemaInitializer, useSchemaInitializerItem } from "../../../../application/index.mjs";
import { FilterBlockInitializer } from "../../../../schema-initializer/items/FilterBlockInitializer.mjs";
import { createFilterFormBlockSchema } from "./createFilterFormBlockSchema.mjs";
const FilterFormBlockInitializer = (param)=>{
    let { filterCollections, onlyCurrentDataSource, hideChildrenIfSingleCollection } = param;
    const itemConfig = useSchemaInitializerItem();
    const { insert } = useSchemaInitializer();
    return /*#__PURE__*/ jsx(FilterBlockInitializer, {
        ...itemConfig,
        icon: /*#__PURE__*/ jsx(FormOutlined, {}),
        onlyCurrentDataSource: onlyCurrentDataSource,
        componentType: 'FilterFormItem',
        templateWrap: (templateSchema, param)=>{
            let { item } = param;
            const s = createFilterFormBlockSchema({
                templateSchema: templateSchema,
                dataSource: item.dataSource,
                collectionName: item.name || item.collectionName
            });
            if (item.template && 'reference' === item.mode) s['x-template-key'] = item.template.key;
            return s;
        },
        onCreateBlockSchema: (param)=>{
            let { item } = param;
            return insert(createFilterFormBlockSchema({
                collectionName: item.collectionName || item.name,
                dataSource: item.dataSource
            }));
        },
        filter: filterCollections,
        hideChildrenIfSingleCollection: hideChildrenIfSingleCollection
    });
};
export { FilterFormBlockInitializer };
