import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__ from "../../../../application/schema-settings/SchemaSettings.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_FormItem_Settings_mjs__ from "../../../../schema-component/antd/form-item/FormItem.Settings.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_table_v2_Table_Column_Decorator_mjs__ from "../../../../schema-component/antd/table-v2/Table.Column.Decorator.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsNumberFormat_mjs__ from "../../../../schema-settings/SchemaSettingsNumberFormat.mjs";
const inputNumberComponentFieldSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__.SchemaSettings({
    name: 'fieldSettings:component:InputNumber',
    items: [
        {
            name: 'setSliderMAXNumber',
            type: 'modal',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.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, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.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 __WEBPACK_EXTERNAL_MODULE_antd__.message.warning(t('Cannot be less than or equal to the minimum value'));
                    }
                };
            }
        },
        {
            name: 'setSliderMinNumber',
            type: 'modal',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.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, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.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 __WEBPACK_EXTERNAL_MODULE_antd__.message.warning(t('Cannot be greater than or equal to the maximum value'));
                    }
                };
            }
        },
        {
            name: 'displayFormat',
            Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsNumberFormat_mjs__.SchemaSettingsNumberFormat,
            useComponentProps () {
                const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
                const fieldSchema = tableColumnSchema || schema;
                return {
                    fieldSchema
                };
            },
            useVisible () {
                const isFieldReadPretty = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_FormItem_Settings_mjs__.useIsFieldReadPretty)();
                return isFieldReadPretty;
            }
        }
    ]
});
export { inputNumberComponentFieldSettings };
