"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = function(module) {
        var getter = module && module.__esModule ? function() {
            return module['default'];
        } : function() {
            return module;
        };
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __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__, {
    FormItem: ()=>FormItem,
    isFileCollection: ()=>isFileCollection
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_react_namespaceObject = require("react");
const components_namespaceObject = require("@tachybase/components");
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_style_namespaceObject = require("antd-style");
const external_classnames_namespaceObject = require("classnames");
var external_classnames_default = /*#__PURE__*/ __webpack_require__.n(external_classnames_namespaceObject);
const index_js_namespaceObject = require("../../../application/index.js");
const useFormActiveFields_js_namespaceObject = require("../../../block-provider/hooks/useFormActiveFields.js");
const acl_index_js_namespaceObject = require("../../../built-in/acl/index.js");
const external_data_source_index_js_namespaceObject = require("../../../data-source/index.js");
const external_schema_settings_index_js_namespaceObject = require("../../../schema-settings/index.js");
const external_variables_index_js_namespaceObject = require("../../../variables/index.js");
const useContextVariable_js_namespaceObject = require("../../../variables/hooks/useContextVariable.js");
var useContextVariable_js_default = /*#__PURE__*/ __webpack_require__.n(useContextVariable_js_namespaceObject);
const external_block_item_index_js_namespaceObject = require("../block-item/index.js");
const shared_js_namespaceObject = require("../input/shared.js");
const external_FormItem_FilterFormDesigner_js_namespaceObject = require("./FormItem.FilterFormDesigner.js");
const useLazyLoadDisplayAssociationFieldsOfForm_js_namespaceObject = require("./hooks/useLazyLoadDisplayAssociationFieldsOfForm.js");
var useLazyLoadDisplayAssociationFieldsOfForm_js_default = /*#__PURE__*/ __webpack_require__.n(useLazyLoadDisplayAssociationFieldsOfForm_js_namespaceObject);
const useParseDefaultValue_js_namespaceObject = require("./hooks/useParseDefaultValue.js");
var useParseDefaultValue_js_default = /*#__PURE__*/ __webpack_require__.n(useParseDefaultValue_js_namespaceObject);
const external_SchemaSettingOptions_js_namespaceObject = require("./SchemaSettingOptions.js");
function _tagged_template_literal(strings, raw) {
    if (!raw) raw = strings.slice(0);
    return Object.freeze(Object.defineProperties(strings, {
        raw: {
            value: Object.freeze(raw)
        }
    }));
}
function _templateObject() {
    const data = _tagged_template_literal([
        "\n      & .ant-space {\n        flex-wrap: wrap;\n      }\n    "
    ]);
    _templateObject = function() {
        return data;
    };
    return data;
}
function _templateObject1() {
    const data = _tagged_template_literal([
        "\n      > .ant-formily-item-label {\n        display: none;\n      }\n    "
    ]);
    _templateObject1 = function() {
        return data;
    };
    return data;
}
function _templateObject2() {
    const data = _tagged_template_literal([
        "\n      display: flex;\n      flex-direction: row;\n      align-items: baseline;\n    "
    ]);
    _templateObject2 = function() {
        return data;
    };
    return data;
}
const useStyles = (0, external_antd_style_namespaceObject.createStyles)((param)=>{
    let { css } = param;
    return {
        space: css(_templateObject()),
        hide: css(_templateObject1()),
        row: css(_templateObject2())
    };
});
const FormItem = (props)=>{
    var _schema_xdecoratorprops;
    const { styles } = useStyles();
    const { layoutDirection: selfLayoutDirection } = props;
    const field = (0, schema_namespaceObject.useField)();
    const schema = (0, schema_namespaceObject.useFieldSchema)();
    const contextVariable = useContextVariable_js_default()();
    const variables = (0, external_variables_index_js_namespaceObject.useVariables)();
    const { addActiveFieldName } = (0, useFormActiveFields_js_namespaceObject.useFormActiveFields)() || {};
    const { layoutDirection } = (0, external_data_source_index_js_namespaceObject.useContextConfigSetting)();
    const finishLayoutDirection = null != selfLayoutDirection ? selfLayoutDirection : layoutDirection;
    (0, external_SchemaSettingOptions_js_namespaceObject.useEnsureOperatorsValid)();
    (0, external_react_namespaceObject.useEffect)(()=>{
        null == variables || variables.registerVariable(contextVariable);
    }, [
        contextVariable
    ]);
    useParseDefaultValue_js_default()();
    useLazyLoadDisplayAssociationFieldsOfForm_js_default()();
    (0, external_react_namespaceObject.useEffect)(()=>{
        null == addActiveFieldName || addActiveFieldName(schema.name);
    }, [
        addActiveFieldName,
        schema.name
    ]);
    var _schema_xdecoratorprops_showTitle;
    const showTitle = null === (_schema_xdecoratorprops_showTitle = null === (_schema_xdecoratorprops = schema['x-decorator-props']) || void 0 === _schema_xdecoratorprops ? void 0 : _schema_xdecoratorprops.showTitle) || void 0 === _schema_xdecoratorprops_showTitle || _schema_xdecoratorprops_showTitle;
    const extra = (0, external_react_namespaceObject.useMemo)(()=>{
        if ('string' == typeof field.description) {
            const desc = field.description.trim();
            if (!desc) return;
            return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
                dangerouslySetInnerHTML: {
                    __html: (0, shared_js_namespaceObject.HTMLEncode)(desc).split('\n').join('<br/>')
                }
            });
        }
        var _field_description;
        return null !== (_field_description = field.description) && void 0 !== _field_description ? _field_description : void 0;
    }, [
        field.description
    ]);
    const className = (0, external_react_namespaceObject.useMemo)(()=>external_classnames_default()(styles.space, {
            [styles.hide]: false === showTitle
        }, {
            [styles.row]: 'row' === finishLayoutDirection
        }), [
        showTitle
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_data_source_index_js_namespaceObject.CollectionFieldProvider, {
        allowNull: true,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_block_item_index_js_namespaceObject.BlockItem, {
            className: 'tb-form-item',
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(acl_index_js_namespaceObject.ACLCollectionFieldProvider, {
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(components_namespaceObject.FormItem, {
                    className: className,
                    ...props,
                    extra: extra
                })
            })
        })
    });
};
FormItem.displayName = 'FormItem';
FormItem.Designer = function() {
    const app = (0, index_js_namespaceObject.useApp)();
    const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
    const settingsName = "FormItemSettings:".concat(fieldSchema['x-interface']);
    const defaultActionSettings = 'FormItemSettings';
    const hasFieldItem = app.schemaSettingsManager.has(settingsName);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_schema_settings_index_js_namespaceObject.GeneralSchemaDesigner, {
        schemaSettings: hasFieldItem ? settingsName : defaultActionSettings
    });
};
function isFileCollection(collection) {
    return (null == collection ? void 0 : collection.template) === 'file';
}
FormItem.FilterFormDesigner = external_FormItem_FilterFormDesigner_js_namespaceObject.FilterFormDesigner;
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
});
