"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__, {
    inputNumberComponentFieldSettings: ()=>inputNumberComponentFieldSettings
});
const schema_namespaceObject = require("@tachybase/schema");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const SchemaSettings_js_namespaceObject = require("../../../../application/schema-settings/SchemaSettings.js");
const index_js_namespaceObject = require("../../../../schema-component/index.js");
const FormItem_Settings_js_namespaceObject = require("../../../../schema-component/antd/form-item/FormItem.Settings.js");
const Table_Column_Decorator_js_namespaceObject = require("../../../../schema-component/antd/table-v2/Table.Column.Decorator.js");
const SchemaSettingsNumberFormat_js_namespaceObject = require("../../../../schema-settings/SchemaSettingsNumberFormat.js");
const inputNumberComponentFieldSettings = new SchemaSettings_js_namespaceObject.SchemaSettings({
    name: 'fieldSettings:component:InputNumber',
    items: [
        {
            name: 'setSliderMAXNumber',
            type: 'modal',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                return 'Slider' === fieldSchema['x-component'] || (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.component) === 'Slider';
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const field = (0, schema_namespaceObject.useField)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                const { dn } = (0, index_js_namespaceObject.useDesignable)();
                return {
                    title: t('MAX'),
                    value: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.max,
                    schema: {
                        type: 'object',
                        title: t('Edit Slider Max'),
                        properties: {
                            maxNumber: {
                                default: (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.max) || 100,
                                'x-decorator': 'FormItem',
                                'x-component': 'Input',
                                'x-component-props': {}
                            }
                        }
                    },
                    onSubmit (number) {
                        if (Number(number.maxNumber) > (field.componentProps['min'] || 0)) {
                            fieldSchema['x-component-props']['max'] = Number(number.maxNumber);
                            field.componentProps['max'] = Number(number.maxNumber);
                            dn.emit('patch', {
                                schema: {
                                    'x-uid': fieldSchema['x-uid'],
                                    'x-component-props': fieldSchema['x-component-props']
                                }
                            });
                        } else external_antd_namespaceObject.message.warning(t('Cannot be less than or equal to the minimum value'));
                    }
                };
            }
        },
        {
            name: 'setSliderMinNumber',
            type: 'modal',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                return 'Slider' === fieldSchema['x-component'] || (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.component) === 'Slider';
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1;
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const field = (0, schema_namespaceObject.useField)();
                const fieldSchema = (0, schema_namespaceObject.useFieldSchema)();
                const { dn } = (0, index_js_namespaceObject.useDesignable)();
                return {
                    title: t('MIN'),
                    value: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.min,
                    schema: {
                        type: 'object',
                        title: t('Edit Slider Min'),
                        properties: {
                            minNumber: {
                                default: (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1.min) || 0,
                                'x-decorator': 'FormItem',
                                'x-component': 'Input',
                                'x-component-props': {}
                            }
                        }
                    },
                    onSubmit (number) {
                        if (Number(number.minNumber) < (field.componentProps['max'] || 0)) {
                            fieldSchema['x-component-props']['min'] = Number(number.minNumber);
                            field.componentProps['min'] = Number(number.minNumber);
                            dn.emit('patch', {
                                schema: {
                                    'x-uid': fieldSchema['x-uid'],
                                    'x-component-props': fieldSchema['x-component-props']
                                }
                            });
                        } else external_antd_namespaceObject.message.warning(t('Cannot be greater than or equal to the maximum value'));
                    }
                };
            }
        },
        {
            name: 'displayFormat',
            Component: SchemaSettingsNumberFormat_js_namespaceObject.SchemaSettingsNumberFormat,
            useComponentProps () {
                const schema = (0, schema_namespaceObject.useFieldSchema)();
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                const fieldSchema = tableColumnSchema || schema;
                return {
                    fieldSchema
                };
            },
            useVisible () {
                const isFieldReadPretty = (0, FormItem_Settings_js_namespaceObject.useIsFieldReadPretty)();
                return isFieldReadPretty;
            }
        }
    ]
});
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
});
