"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    associationFilterFilterBlockInitializer: ()=>associationFilterFilterBlockInitializer,
    filterCollapseItemInitializer: ()=>filterCollapseItemInitializer
});
const SchemaInitializer_js_namespaceObject = require("../../../../application/schema-initializer/SchemaInitializer.js");
const index_js_namespaceObject = require("../../../../block-provider/hooks/index.js");
const external_data_source_index_js_namespaceObject = require("../../../../data-source/index.js");
const utils_js_namespaceObject = require("../../../../filter-provider/utils.js");
const associationFilterFilterBlockInitializer = new SchemaInitializer_js_namespaceObject.SchemaInitializer({
    name: 'AssociationFilter.FilterBlockInitializer',
    style: {
        marginTop: 16
    },
    icon: 'SettingOutlined',
    title: '{{t("Configure fields")}}',
    items: [
        {
            type: 'itemGroup',
            name: 'associationFields',
            title: '{{t("Association fields")}}',
            useChildren () {
                const associatedFields = (0, utils_js_namespaceObject.useAssociatedFields)();
                const children = associatedFields.map((field)=>{
                    var _field_uiSchema, _field_uiSchema1;
                    return {
                        name: field.key,
                        title: null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : _field_uiSchema.title,
                        Component: 'AssociationFilterDesignerDisplayField',
                        schema: {
                            name: field.name,
                            title: null === (_field_uiSchema1 = field.uiSchema) || void 0 === _field_uiSchema1 ? void 0 : _field_uiSchema1.title,
                            type: 'void',
                            'x-toolbar': 'CollapseItemSchemaToolbar',
                            'x-settings': 'fieldSettings:FilterCollapseItem',
                            'x-component': 'AssociationFilter.Item',
                            'x-use-component-props': 'useAssociationFilterBlockProps',
                            'x-component-props': {
                                fieldNames: {
                                    label: field.targetKey || 'id'
                                }
                            },
                            properties: {}
                        }
                    };
                });
                return children;
            }
        },
        {
            name: 'choicesFields',
            type: 'itemGroup',
            title: '{{t("Choices fields")}}',
            hideIfNoChildren: true,
            useChildren () {
                const optionalList = (0, index_js_namespaceObject.useOptionalFieldList)();
                const useProps = '{{useAssociationFilterBlockProps}}';
                const optionalChildren = optionalList.map((field)=>({
                        name: field.key,
                        title: field.uiSchema.title,
                        Component: 'AssociationFilterDesignerDisplayField',
                        schema: {
                            name: field.name,
                            title: field.uiSchema.title,
                            interface: field.interface,
                            type: 'void',
                            'x-toolbar': 'CollapseItemSchemaToolbar',
                            'x-settings': 'fieldSettings:FilterCollapseItem',
                            'x-component': 'AssociationFilter.Item',
                            'x-component-props': {
                                fieldNames: {
                                    label: field.name
                                },
                                useProps
                            },
                            properties: {}
                        }
                    }));
                return optionalChildren;
            }
        }
    ]
});
const filterCollapseItemInitializer = new SchemaInitializer_js_namespaceObject.SchemaInitializer({
    name: 'filterCollapse:configureFields',
    style: {
        marginTop: 16
    },
    icon: 'SettingOutlined',
    title: '{{t("Configure fields")}}',
    items: [
        {
            type: 'itemGroup',
            name: 'associationFields',
            title: '{{t("Association fields")}}',
            useChildren () {
                const associatedFields = (0, utils_js_namespaceObject.useAssociatedFields)();
                const cm = (0, external_data_source_index_js_namespaceObject.useCollectionManager)();
                const children = associatedFields.map((field)=>{
                    var _field_uiSchema, _field_uiSchema1, _cm_getCollection;
                    return {
                        name: field.key,
                        title: null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : _field_uiSchema.title,
                        Component: 'AssociationFilterDesignerDisplayField',
                        schema: {
                            name: field.name,
                            title: null === (_field_uiSchema1 = field.uiSchema) || void 0 === _field_uiSchema1 ? void 0 : _field_uiSchema1.title,
                            type: 'void',
                            'x-toolbar': 'CollapseItemSchemaToolbar',
                            'x-settings': 'fieldSettings:FilterCollapseItem',
                            'x-component': 'AssociationFilter.Item',
                            'x-use-component-props': 'useAssociationFilterBlockProps',
                            'x-component-props': {
                                fieldNames: {
                                    label: (null === (_cm_getCollection = cm.getCollection(field.target)) || void 0 === _cm_getCollection ? void 0 : _cm_getCollection.getPrimaryKey()) || 'id'
                                }
                            },
                            properties: {}
                        }
                    };
                });
                return children;
            }
        },
        {
            name: 'choicesFields',
            type: 'itemGroup',
            title: '{{t("Choices fields")}}',
            hideIfNoChildren: true,
            useChildren () {
                const optionalList = (0, index_js_namespaceObject.useOptionalFieldList)();
                const optionalChildren = optionalList.map((field)=>({
                        name: field.key,
                        title: field.uiSchema.title,
                        Component: 'AssociationFilterDesignerDisplayField',
                        schema: {
                            name: field.name,
                            title: field.uiSchema.title,
                            interface: field.interface,
                            type: 'void',
                            'x-toolbar': 'CollapseItemSchemaToolbar',
                            'x-settings': 'fieldSettings:FilterCollapseItem',
                            'x-component': 'AssociationFilter.Item',
                            'x-use-component-props': 'useAssociationFilterBlockProps',
                            'x-component-props': {
                                fieldNames: {
                                    label: field.name
                                }
                            },
                            properties: {}
                        }
                    }));
                return optionalChildren;
            }
        }
    ]
});
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
