import { jsx } from "react/jsx-runtime";
import "react";
import { merge } from "@tachybase/schema";
import { SchemaInitializerSwitch, useSchemaInitializer, useSchemaInitializerItem } from "../../../application/index.mjs";
import { useCurrentSchema } from "../../../schema-initializer/utils.mjs";
const AssociationFilterDesignerDisplayField = ()=>{
    const itemConfig = useSchemaInitializerItem();
    const { schema } = itemConfig;
    const { exists, remove } = useCurrentSchema(schema.name, 'name', itemConfig.find, itemConfig.remove);
    const { insert } = useSchemaInitializer();
    return /*#__PURE__*/ jsx(SchemaInitializerSwitch, {
        checked: exists,
        title: itemConfig.title,
        onClick: ()=>{
            var _itemConfig_schemaInitialize;
            if (exists) return remove();
            const s = merge(schema || {}, itemConfig.schema || {});
            null == itemConfig || null == (_itemConfig_schemaInitialize = itemConfig.schemaInitialize) || _itemConfig_schemaInitialize.call(itemConfig, s);
            insert(s);
        }
    });
};
export { AssociationFilterDesignerDisplayField };
