"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__, {
    useLinkageCollectionFieldOptions: ()=>useLinkageCollectionFieldOptions
});
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../collection-manager/index.js");
const external_type_js_namespaceObject = require("./type.js");
const useLinkageCollectionFieldOptions = (collectionName)=>{
    const { getCollectionFields, getInterface } = (0, index_js_namespaceObject.useCollectionManager_deprecated)();
    const fields = getCollectionFields(collectionName).filter((v)=>![
            'id',
            'createdAt',
            'createdBy',
            'updatedAt',
            'updatedBy'
        ].includes(v.name));
    const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
    const operators = [
        {
            label: t('Visible'),
            value: external_type_js_namespaceObject.ActionType.Visible,
            selected: true,
            schema: {}
        },
        {
            label: t('Editable'),
            value: external_type_js_namespaceObject.ActionType.Editable,
            selected: false,
            schema: {}
        },
        {
            label: t('Disabled'),
            value: external_type_js_namespaceObject.ActionType.ReadOnly,
            selected: false,
            schema: {}
        },
        {
            label: t('Easy reading'),
            value: external_type_js_namespaceObject.ActionType.ReadPretty,
            selected: false,
            schema: {}
        },
        {
            label: t('Hidden'),
            value: external_type_js_namespaceObject.ActionType.None,
            selected: false,
            schema: {}
        },
        {
            label: t('Hidden(reserved value)'),
            value: external_type_js_namespaceObject.ActionType.Hidden,
            selected: false,
            schema: {}
        },
        {
            label: t('Required'),
            value: external_type_js_namespaceObject.ActionType.Required,
            selected: false,
            schema: {}
        },
        {
            label: t('Not required'),
            value: external_type_js_namespaceObject.ActionType.InRequired,
            selected: false,
            schema: {}
        },
        {
            label: t('Value'),
            value: external_type_js_namespaceObject.ActionType.Value,
            selected: false,
            schema: {}
        }
    ];
    const field2option = (field, depth)=>{
        var _field_uiSchema, _operators_filter;
        const fieldInterface = getInterface(field.interface);
        if (!fieldInterface) return;
        const { nested, children } = (null == fieldInterface ? void 0 : fieldInterface.filterable) || {};
        const option = {
            name: field.name,
            title: (null == field ? void 0 : null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : _field_uiSchema.title) || field.name,
            schema: null == field ? void 0 : field.uiSchema,
            interface: field.interface,
            target: field.target,
            operators: (null == operators ? void 0 : null === (_operators_filter = operators.filter) || void 0 === _operators_filter ? void 0 : _operators_filter.call(operators, (operator)=>{
                if (nested || children || [
                    'formula',
                    'richText',
                    'sequence'
                ].includes(fieldInterface.name)) return (null == operator ? void 0 : operator.value) !== external_type_js_namespaceObject.ActionType.Value;
                return true;
            })) || []
        };
        if (field.target && depth > 2) return;
        return option;
    };
    const getOptions = (fields, depth)=>{
        const options = [];
        fields.forEach((field)=>{
            const option = field2option(field, depth);
            if (option) options.push(option);
        });
        return options;
    };
    return getOptions(fields, 1);
};
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
});
