import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
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";
const uploadAttachmentComponentFieldSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_SchemaSettings_mjs__.SchemaSettings({
    name: 'fieldSettings:component:Upload.Attachment',
    items: [
        {
            name: 'size',
            type: 'select',
            useVisible () {
                const readPretty = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_form_item_FormItem_Settings_mjs__.useIsFieldReadPretty)();
                return readPretty;
            },
            useComponentProps () {
                var _field_componentProps;
                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('Size'),
                    options: [
                        {
                            label: t('Large'),
                            value: 'large'
                        },
                        {
                            label: t('Default'),
                            value: 'default'
                        },
                        {
                            label: t('Small'),
                            value: 'small'
                        }
                    ],
                    value: (null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.size) || 'default',
                    onChange (size) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['size'] = size;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps = field.componentProps || {};
                        field.componentProps.size = size;
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'showCount',
            type: 'modal',
            useComponentProps () {
                var _showCountSchema_xcomponentprops;
                const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
                const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const showCountSchema = tableColumnSchema || schema;
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
                return {
                    title: t('Show Count'),
                    schema: {
                        type: 'object',
                        title: t('Show Count'),
                        properties: {
                            showCount: {
                                default: (null == showCountSchema ? void 0 : null === (_showCountSchema_xcomponentprops = showCountSchema['x-component-props']) || void 0 === _showCountSchema_xcomponentprops ? void 0 : _showCountSchema_xcomponentprops['showCount']) || 1,
                                'x-decorator': 'FormItem',
                                'x-component': 'InputNumber',
                                'x-component-props': {
                                    min: 0,
                                    max: 5
                                }
                            }
                        }
                    },
                    onSubmit: (param)=>{
                        let { showCount } = param;
                        const props = showCountSchema['x-component-props'] || {};
                        props.showCount = showCount;
                        const schema = {
                            ['x-uid']: showCountSchema['x-uid'],
                            ['x-component-props']: props
                        };
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        }
    ]
});
export { uploadAttachmentComponentFieldSettings };
