"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__, {
    fileManagerComponentFieldSettings: ()=>fileManagerComponentFieldSettings
});
const schema_namespaceObject = require("@tachybase/schema");
const external_react_i18next_namespaceObject = require("react-i18next");
const SchemaSettings_js_namespaceObject = require("../../../../application/schema-settings/SchemaSettings.js");
const useFieldComponentName_js_namespaceObject = require("../../../../common/useFieldComponentName.js");
const index_js_namespaceObject = require("../../../../schema-component/index.js");
const util_js_namespaceObject = require("../../../../schema-component/antd/association-field/util.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 useIsShowMultipleSwitch_js_namespaceObject = require("../../../../schema-settings/hooks/useIsShowMultipleSwitch.js");
const selectComponentFieldSettings_js_namespaceObject = require("../Select/selectComponentFieldSettings.js");
const fieldComponent = {
    name: 'fieldComponent',
    type: 'select',
    useComponentProps () {
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        const field = (0, schema_namespaceObject.useField)();
        const isAddNewForm = (0, index_js_namespaceObject.useIsAddNewForm)();
        const fieldComponentName = (0, useFieldComponentName_js_namespaceObject.useFieldComponentName)();
        const { fieldSchema: tableColumnSchema, collectionField } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
        const schema = (0, schema_namespaceObject.useFieldSchema)();
        const fieldSchema = tableColumnSchema || schema;
        const fieldModeOptions = (0, index_js_namespaceObject.useFieldModeOptions)({
            fieldSchema: tableColumnSchema,
            collectionField
        });
        const { dn } = (0, index_js_namespaceObject.useDesignable)();
        return {
            title: t('Field component'),
            options: fieldModeOptions,
            value: fieldComponentName,
            onChange (mode) {
                const schema = {
                    ['x-uid']: fieldSchema['x-uid']
                };
                fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                fieldSchema['x-component-props']['mode'] = mode;
                schema['x-component-props'] = fieldSchema['x-component-props'];
                field.componentProps = field.componentProps || {};
                field.componentProps.mode = mode;
                if ((0, util_js_namespaceObject.isSubMode)(fieldSchema) && isAddNewForm) {
                    schema.default = null;
                    fieldSchema.default = null;
                    field.setInitialValue(null);
                    field.setValue(null);
                }
                dn.emit('patch', {
                    schema
                });
                dn.refresh();
            }
        };
    }
};
const fileManagerComponentFieldSettings = new SchemaSettings_js_namespaceObject.SchemaSettings({
    name: 'fieldSettings:component:FileManager',
    items: [
        fieldComponent,
        {
            name: 'quickUpload',
            type: 'switch',
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const field = (0, schema_namespaceObject.useField)();
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                const schema = (0, schema_namespaceObject.useFieldSchema)();
                const fieldSchema = tableColumnSchema || schema;
                const { dn, refresh } = (0, index_js_namespaceObject.useDesignable)();
                return {
                    title: t('Quick upload'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.quickUpload) !== false,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field.componentProps.quickUpload = value;
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props'].quickUpload = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            },
            useVisible () {
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                const field = (0, schema_namespaceObject.useField)();
                const form = (0, schema_namespaceObject.useForm)();
                const isReadPretty = (null == tableColumnSchema ? void 0 : tableColumnSchema['x-read-pretty']) || field.readPretty || form.readPretty;
                return !isReadPretty;
            }
        },
        {
            name: 'selectFile',
            type: 'switch',
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
                const field = (0, schema_namespaceObject.useField)();
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                const schema = (0, schema_namespaceObject.useFieldSchema)();
                const fieldSchema = tableColumnSchema || schema;
                const { dn, refresh } = (0, index_js_namespaceObject.useDesignable)();
                return {
                    title: t('Select file'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.selectFile) !== false,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field.componentProps.selectFile = value;
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props'].selectFile = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            },
            useVisible () {
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                const field = (0, schema_namespaceObject.useField)();
                const form = (0, schema_namespaceObject.useForm)();
                const isReadPretty = (null == tableColumnSchema ? void 0 : tableColumnSchema['x-read-pretty']) || field.readPretty || form.readPretty;
                return !isReadPretty;
            }
        },
        {
            name: 'size',
            type: 'select',
            useVisible () {
                const readPretty = (0, FormItem_Settings_js_namespaceObject.useIsFieldReadPretty)();
                const { fieldSchema: tableColumnSchema } = (0, Table_Column_Decorator_js_namespaceObject.useColumnSchema)();
                return readPretty && !tableColumnSchema;
            },
            useComponentProps () {
                var _field_componentProps;
                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('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();
                    }
                };
            }
        },
        {
            ...selectComponentFieldSettings_js_namespaceObject.allowMultiple,
            useVisible () {
                const isAssociationField = (0, FormItem_Settings_js_namespaceObject.useIsAssociationField)();
                const IsShowMultipleSwitch = (0, useIsShowMultipleSwitch_js_namespaceObject.useIsShowMultipleSwitch)();
                return isAssociationField && IsShowMultipleSwitch();
            }
        }
    ]
});
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
});
