import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_components__ from "@tachybase/components";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_lodash__ from "lodash";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__application_schema_settings_index_mjs__ from "../../../application/schema-settings/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__block_provider_FormBlockProvider_mjs__ from "../../../block-provider/FormBlockProvider.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__ from "../../../collection-manager/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__ from "../../../data-source/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__record_provider_index_mjs__ from "../../../record-provider/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Decorator_mjs__ from "../table-v2/Table.Column.Decorator.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_items_GeneralSettings_mjs__ from "../../../schema-items/GeneralSettings.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../../../schema-settings/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_hooks_useIsAllowToSetDefaultValue_mjs__ from "../../../schema-settings/hooks/useIsAllowToSetDefaultValue.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_hooks_useIsShowMultipleSwitch_mjs__ from "../../../schema-settings/hooks/useIsShowMultipleSwitch.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_isPatternDisabled_mjs__ from "../../../schema-settings/isPatternDisabled.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_LinkageRules_type_mjs__ from "../../../schema-settings/LinkageRules/type.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDataScope_mjs__ from "../../../schema-settings/SchemaSettingsDataScope.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDateFormat_mjs__ from "../../../schema-settings/SchemaSettingsDateFormat.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDefaultValue_mjs__ from "../../../schema-settings/SchemaSettingsDefaultValue.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsSortingRule_mjs__ from "../../../schema-settings/SchemaSettingsSortingRule.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_VariableInput_VariableInput_mjs__ from "../../../schema-settings/VariableInput/VariableInput.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__variables_index_mjs__ from "../../../variables/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__ from "../../hooks/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__association_field_util_mjs__ from "../association-field/util.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__filter_index_mjs__ from "../filter/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__form_v2_utils_mjs__ from "../form-v2/utils.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Designer_mjs__ from "../table-v2/Table.Column.Designer.mjs";
const formItemSettings = new __WEBPACK_EXTERNAL_MODULE__application_schema_settings_index_mjs__.SchemaSettings({
    name: 'FormItemSettings',
    items: [
        ...__WEBPACK_EXTERNAL_MODULE__schema_items_GeneralSettings_mjs__.generalSettingsItems,
        {
            name: 'allowAddNewData',
            type: 'switch',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return !readPretty && isAssociationField && [
                    'SubTable'
                ].includes(fieldMode);
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Allow add new'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.allowAddnew) !== false,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field.componentProps.allowAddnew = value;
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props'].allowAddnew = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'allowSelectExistingRecord',
            type: 'switch',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return !readPretty && isAssociationField && [
                    'SubTable'
                ].includes(fieldMode);
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Allow selection of existing records'),
                    checked: null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.allowSelectExistingRecord,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field.componentProps.allowSelectExistingRecord = value;
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props'].allowSelectExistingRecord = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'quickUpload',
            type: 'switch',
            useVisible () {
                const isFileField = useIsFileField();
                const isFormReadPretty = useIsFormReadPretty();
                return !isFormReadPretty && isFileField;
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.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();
                    }
                };
            }
        },
        {
            name: 'selectFile',
            type: 'switch',
            useVisible () {
                const isFileField = useIsFileField();
                const isFormReadPretty = useIsFormReadPretty();
                return !isFormReadPretty && isFileField;
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.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();
                    }
                };
            }
        },
        {
            name: 'validationRules',
            type: 'modal',
            useComponentProps () {
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                const validateSchema = useValidateSchema();
                const { getCollectionJoinField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
                const { getField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
                const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
                return {
                    title: t('Set validation rules'),
                    components: {
                        ArrayCollapse: __WEBPACK_EXTERNAL_MODULE__tachybase_components__.ArrayCollapse,
                        FormLayout: __WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormLayout
                    },
                    schema: {
                        type: 'object',
                        title: t('Set validation rules'),
                        properties: {
                            rules: {
                                type: 'array',
                                default: null == fieldSchema ? void 0 : fieldSchema['x-validator'],
                                'x-component': 'ArrayCollapse',
                                'x-decorator': 'FormItem',
                                'x-component-props': {
                                    accordion: true
                                },
                                maxItems: 3,
                                items: {
                                    type: 'object',
                                    'x-component': 'ArrayCollapse.CollapsePanel',
                                    'x-component-props': {
                                        header: '{{ t("Validation rule") }}'
                                    },
                                    properties: {
                                        index: {
                                            type: 'void',
                                            'x-component': 'ArrayCollapse.Index'
                                        },
                                        layout: {
                                            type: 'void',
                                            'x-component': 'FormLayout',
                                            'x-component-props': {
                                                labelStyle: {
                                                    marginTop: '6px'
                                                },
                                                labelCol: 8,
                                                wrapperCol: 16
                                            },
                                            properties: {
                                                ...validateSchema,
                                                message: {
                                                    type: 'string',
                                                    title: '{{ t("Error message") }}',
                                                    'x-decorator': 'FormItem',
                                                    'x-component': 'Input.TextArea',
                                                    'x-component-props': {
                                                        autoSize: {
                                                            minRows: 2,
                                                            maxRows: 2
                                                        }
                                                    }
                                                }
                                            }
                                        },
                                        remove: {
                                            type: 'void',
                                            'x-component': 'ArrayCollapse.Remove'
                                        },
                                        moveUp: {
                                            type: 'void',
                                            'x-component': 'ArrayCollapse.MoveUp'
                                        },
                                        moveDown: {
                                            type: 'void',
                                            'x-component': 'ArrayCollapse.MoveDown'
                                        }
                                    }
                                },
                                properties: {
                                    add: {
                                        type: 'void',
                                        title: '{{ t("Add validation rule") }}',
                                        'x-component': 'ArrayCollapse.Addition',
                                        'x-reactions': {
                                            dependencies: [
                                                'rules'
                                            ],
                                            fulfill: {
                                                state: {
                                                    disabled: '{{$deps[0].length >= 3}}'
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    onSubmit (v) {
                        var _collectionField_uiSchema;
                        const rules = [];
                        for (const rule of v.rules)rules.push(__WEBPACK_EXTERNAL_MODULE_lodash__["default"].pickBy(rule, __WEBPACK_EXTERNAL_MODULE_lodash__["default"].identity));
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        if ([
                            'percent'
                        ].includes(null == collectionField ? void 0 : collectionField.interface)) for (const rule of rules){
                            if (!!rule.maxValue || !!rule.minValue) rule['percentMode'] = true;
                            if (rule.percentFormat) rule['percentFormats'] = true;
                        }
                        const concatValidator = __WEBPACK_EXTERNAL_MODULE_lodash__["default"].concat([], (null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : _collectionField_uiSchema['x-validator']) || [], rules);
                        field.validator = concatValidator;
                        fieldSchema['x-validator'] = rules;
                        schema['x-validator'] = rules;
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            },
            useVisible () {
                const { form } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_FormBlockProvider_mjs__.useFormBlockContext)();
                const isFormReadPretty = useIsFormReadPretty();
                const validateSchema = useValidateSchema();
                return form && !isFormReadPretty && validateSchema;
            }
        },
        {
            name: 'isquickaddtabs',
            type: 'switch',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return !readPretty && isAssociationField && [
                    'SubTable'
                ].includes(fieldMode);
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Is Quick Add Tabs'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.isQuickAdd) || false,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field.componentProps['isQuickAdd'] = value;
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['isQuickAdd'] = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'setquickaddtabs',
            type: 'select',
            useComponentProps () {
                const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                const compile = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCompile)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
                const options = cm.getCollection(fieldSchema['x-collection-field']);
                const defVal = fieldSchema['x-component-props']['quickAddField'] || 'none';
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                const isAddNewForm = useIsAddNewForm();
                const fieldTabsOptions = options.fields.map((item)=>{
                    if ('m2o' === item.interface || 'select' === item.interface) {
                        var _item_uiSchema;
                        return {
                            ...item,
                            label: compile(null === (_item_uiSchema = item.uiSchema) || void 0 === _item_uiSchema ? void 0 : _item_uiSchema.title),
                            value: item.name
                        };
                    }
                }).filter(Boolean);
                fieldTabsOptions.unshift({
                    label: 'none',
                    value: 'none'
                });
                return {
                    title: t('Set Quick Add Tabs'),
                    options: fieldTabsOptions,
                    value: defVal,
                    onChange (mode) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['quickAddField'] = {
                            fieldInterface: fieldTabsOptions.find((item)=>item.value === mode)['interface'] || 'none',
                            value: mode
                        };
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps = field.componentProps || {};
                        field.componentProps['quickAddField'] = fieldSchema['x-component-props']['quickAddField'];
                        if ((0, __WEBPACK_EXTERNAL_MODULE__association_field_util_mjs__.isSubMode)(fieldSchema) && isAddNewForm) {
                            schema.default = null;
                            fieldSchema.default = null;
                            field.setInitialValue(null);
                            field.setValue(null);
                        }
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            },
            useVisible () {
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                return fieldSchema['x-component-props']['isQuickAdd'];
            }
        },
        {
            name: 'setquickaddparenttabs',
            type: 'select',
            useComponentProps () {
                var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops_quickAddParentCollection, _fieldSchema_xcomponentprops1;
                const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                const compile = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCompile)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const cm = (0, __WEBPACK_EXTERNAL_MODULE__data_source_index_mjs__.useCollectionManager)();
                const { value: quickField } = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['quickAddField']) || {};
                const options = cm.getCollectionFields("".concat(fieldSchema['x-collection-field'], ".").concat(quickField));
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                const isAddNewForm = useIsAddNewForm();
                const fieldTabsOptions = options.map((item)=>{
                    if ('m2o' === item.interface) return {
                        ...item,
                        label: compile(item.uiSchema.title),
                        value: item.name
                    };
                }).filter(Boolean);
                fieldTabsOptions.unshift({
                    label: t('none'),
                    value: 'none'
                });
                const defValue = (null === (_fieldSchema_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : null === (_fieldSchema_xcomponentprops_quickAddParentCollection = _fieldSchema_xcomponentprops1['quickAddParentCollection']) || void 0 === _fieldSchema_xcomponentprops_quickAddParentCollection ? void 0 : _fieldSchema_xcomponentprops_quickAddParentCollection.value) || 'none';
                return {
                    title: t('Set Quick Add Parent Tabs'),
                    options: fieldTabsOptions,
                    value: defValue,
                    onChange (mode) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['quickAddParentCollection'] = {
                            collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(quickField, ".").concat(mode),
                            value: mode
                        };
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps = field.componentProps || {};
                        field.componentProps['quickAddParentCollection'] = {
                            collectionField: "".concat(fieldSchema['x-collection-field'], ".").concat(quickField, ".").concat(mode),
                            value: mode
                        };
                        if ((0, __WEBPACK_EXTERNAL_MODULE__association_field_util_mjs__.isSubMode)(fieldSchema) && isAddNewForm) {
                            schema.default = null;
                            fieldSchema.default = null;
                            field.setInitialValue(null);
                            field.setValue(null);
                        }
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            },
            useVisible () {
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                return fieldSchema['x-component-props']['isQuickAdd'] && fieldSchema['x-component-props']['quickAddField'] && 'none' !== fieldSchema['x-component-props']['quickAddField'];
            }
        },
        {
            name: 'defaultValue',
            Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDefaultValue_mjs__.SchemaSettingsDefaultValue,
            useVisible () {
                const { isAllowToSetDefaultValue } = (0, __WEBPACK_EXTERNAL_MODULE__schema_settings_hooks_useIsAllowToSetDefaultValue_mjs__.useIsAllowToSetDefaultValue)();
                return isAllowToSetDefaultValue();
            }
        },
        {
            name: 'dataScope',
            Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDataScope_mjs__.SchemaSettingsDataScope,
            useVisible () {
                const isSelectFieldMode = useIsSelectFieldMode();
                const isFormReadPretty = useIsFormReadPretty();
                return isSelectFieldMode && !isFormReadPretty;
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops_service_params, _fieldSchema_xcomponentprops_service, _fieldSchema_xcomponentprops;
                const { getCollectionJoinField, getAllCollectionsInheritChain } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
                const { getField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
                const { form } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_FormBlockProvider_mjs__.useFormBlockContext)();
                const record = (0, __WEBPACK_EXTERNAL_MODULE__record_provider_index_mjs__.useRecord)();
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
                const variables = (0, __WEBPACK_EXTERNAL_MODULE__variables_index_mjs__.useVariables)();
                const localVariables = (0, __WEBPACK_EXTERNAL_MODULE__variables_index_mjs__.useLocalVariables)();
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    collectionName: null == collectionField ? void 0 : collectionField.target,
                    defaultFilter: (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : null === (_fieldSchema_xcomponentprops_service = _fieldSchema_xcomponentprops.service) || void 0 === _fieldSchema_xcomponentprops_service ? void 0 : null === (_fieldSchema_xcomponentprops_service_params = _fieldSchema_xcomponentprops_service.params) || void 0 === _fieldSchema_xcomponentprops_service_params ? void 0 : _fieldSchema_xcomponentprops_service_params.filter) || {},
                    form,
                    dynamicComponent: (props)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_VariableInput_VariableInput_mjs__.VariableInput, {
                            ...props,
                            form: form,
                            collectionField: props.collectionField,
                            record: record,
                            shouldChange: (0, __WEBPACK_EXTERNAL_MODULE__schema_settings_VariableInput_VariableInput_mjs__.getShouldChange)({
                                collectionField: props.collectionField,
                                variables,
                                localVariables,
                                getAllCollectionsInheritChain
                            })
                        }),
                    onSubmit: (param)=>{
                        let { filter } = param;
                        filter = (0, __WEBPACK_EXTERNAL_MODULE__filter_index_mjs__.removeNullCondition)(filter);
                        __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(field.componentProps, 'service.params.filter', filter);
                        fieldSchema['x-component-props'] = field.componentProps;
                        dn.emit('patch', {
                            schema: {
                                ['x-uid']: fieldSchema['x-uid'],
                                'x-component-props': field.componentProps
                            }
                        });
                    }
                };
            }
        },
        {
            name: 'sortingRule',
            Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsSortingRule_mjs__.SchemaSettingsSortingRule,
            useVisible () {
                const isSelectFieldMode = useIsSelectFieldMode();
                const isFormReadPretty = useIsFormReadPretty();
                return isSelectFieldMode && !isFormReadPretty;
            }
        },
        {
            name: 'fieldMode',
            type: 'select',
            useComponentProps () {
                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__hooks_index_mjs__.useDesignable)();
                const fieldModeOptions = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useFieldModeOptions)();
                const isAddNewForm = useIsAddNewForm();
                const fieldMode = useFieldMode();
                return {
                    title: t('Field component'),
                    options: fieldModeOptions,
                    value: fieldMode,
                    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, __WEBPACK_EXTERNAL_MODULE__association_field_util_mjs__.isSubMode)(fieldSchema) && isAddNewForm) {
                            schema.default = null;
                            fieldSchema.default = null;
                            field.setInitialValue(null);
                            field.setValue(null);
                        }
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            },
            useVisible: useShowFieldMode
        },
        {
            name: 'customTitle',
            type: 'modal',
            useComponentProps () {
                var _fieldSchema_xcomponentprops_fieldNames, _fieldSchema_xcomponentprops;
                const schema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
                const fieldSchema = tableColumnSchema || schema;
                const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                const options = (0, __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.useFormulaTitleOptions)();
                const def = null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : null === (_fieldSchema_xcomponentprops_fieldNames = _fieldSchema_xcomponentprops.fieldNames) || void 0 === _fieldSchema_xcomponentprops_fieldNames ? void 0 : _fieldSchema_xcomponentprops_fieldNames.formula;
                const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
                return {
                    title: t('Custom option label'),
                    schema: {
                        type: 'object',
                        title: t('Custom option label'),
                        properties: {
                            formula: {
                                required: true,
                                'x-decorator': 'FormItem',
                                'x-component': 'Variable.TextArea',
                                'x-component-props': {
                                    scope: options
                                },
                                default: def || ''
                            }
                        }
                    },
                    onSubmit: (param)=>{
                        let { formula } = param;
                        if (formula) {
                            var _fieldSchema_xcomponentprops, _field_componentProps;
                            const componentProps = {
                                ...fieldSchema['x-component-props'],
                                fieldNames: {
                                    ...null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['fieldNames'],
                                    formula
                                },
                                appends: [
                                    fieldSchema['name']
                                ]
                            };
                            const regex = /{{(.*?)}}/g;
                            let match;
                            while(match = regex.exec(formula))if (match[1].includes('.')) {
                                const matchList = match[1].split('.');
                                let appendsValue = fieldSchema['name'];
                                matchList.forEach((item, index)=>{
                                    if (index === matchList.length - 1) return;
                                    appendsValue += '.' + item;
                                    componentProps.appends.push(appendsValue);
                                });
                            }
                            field.componentProps = {
                                ...field.componentProps,
                                fieldNames: {
                                    ...null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.fieldNames,
                                    formula
                                }
                            };
                            fieldSchema['x-component-props'] = componentProps;
                            dn.emit('patch', {
                                schema: {
                                    'x-uid': fieldSchema['x-uid'],
                                    'x-component-props': componentProps
                                }
                            });
                        }
                        dn.refresh();
                    }
                };
            },
            useVisible: ()=>{
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const formula = 'CustomTitle' === fieldSchema['x-component-props'].mode;
                return useShowFieldMode() && formula;
            }
        },
        {
            name: 'popupSize',
            type: 'select',
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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__hooks_index_mjs__.useDesignable)();
                var _fieldSchema_xcomponentprops_openSize;
                return {
                    title: t('Popup size'),
                    options: [
                        {
                            label: t('Small'),
                            value: 'small'
                        },
                        {
                            label: t('Middle'),
                            value: 'middle'
                        },
                        {
                            label: t('Large'),
                            value: 'large'
                        }
                    ],
                    value: null !== (_fieldSchema_xcomponentprops_openSize = null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['openSize']) && void 0 !== _fieldSchema_xcomponentprops_openSize ? _fieldSchema_xcomponentprops_openSize : 'middle',
                    onChange: (value)=>{
                        field.componentProps.openSize = value;
                        fieldSchema['x-component-props'] = field.componentProps;
                        dn.emit('patch', {
                            schema: {
                                'x-uid': fieldSchema['x-uid'],
                                'x-component-props': fieldSchema['x-component-props']
                            }
                        });
                        dn.refresh();
                    }
                };
            },
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const showFieldMode = useShowFieldMode();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const isPickerMode = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.mode) === 'Picker';
                const showModeSelect = showFieldMode && isPickerMode;
                return showModeSelect;
            }
        },
        {
            name: 'allowAddNew',
            type: 'switch',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return !readPretty && isAssociationField && [
                    'Picker'
                ].includes(fieldMode);
            },
            useComponentProps () {
                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, refresh, insertAdjacent } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Allow add new data'),
                    checked: fieldSchema['x-add-new'],
                    onChange (allowAddNew) {
                        const hasAddNew = fieldSchema.reduceProperties((buf, schema)=>{
                            if ('Action' === schema['x-component']) return schema;
                            return buf;
                        }, null);
                        if (!hasAddNew) {
                            const addNewActionschema = {
                                'x-action': 'create',
                                'x-acl-action': 'create',
                                title: "{{t('Add new')}}",
                                'x-toolbar': 'ActionSchemaToolbar',
                                'x-settings': 'actonSettings:addNew',
                                'x-component': 'Action',
                                'x-decorator': 'ACLActionProvider',
                                'x-component-props': {
                                    openMode: 'drawer',
                                    type: 'default',
                                    component: 'CreateRecordAction'
                                }
                            };
                            insertAdjacent('afterBegin', addNewActionschema);
                        }
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        field['x-add-new'] = allowAddNew;
                        fieldSchema['x-add-new'] = allowAddNew;
                        schema['x-add-new'] = allowAddNew;
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'addMode',
            type: 'select',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return !readPretty && isAssociationField && [
                    'Select'
                ].includes(fieldMode);
            },
            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, insertAdjacent } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Quick create'),
                    options: [
                        {
                            label: t('None'),
                            value: 'none'
                        },
                        {
                            label: t('Dropdown'),
                            value: 'quickAdd'
                        },
                        {
                            label: t('Pop-up'),
                            value: 'modalAdd'
                        }
                    ],
                    value: (null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.addMode) || 'none',
                    onChange (mode) {
                        if ('modalAdd' === mode) {
                            const hasAddNew = fieldSchema.reduceProperties((buf, schema)=>{
                                if ('Action' === schema['x-component']) return schema;
                                return buf;
                            }, null);
                            if (!hasAddNew) {
                                const addNewActionschema = {
                                    'x-action': 'create',
                                    'x-acl-action': 'create',
                                    title: "{{t('Add new')}}",
                                    'x-toolbar': 'ActionSchemaToolbar',
                                    'x-settings': 'actonSettings:addNew',
                                    'x-component': 'Action',
                                    'x-decorator': 'ACLActionProvider',
                                    'x-component-props': {
                                        openMode: 'drawer',
                                        type: 'default',
                                        component: 'CreateRecordAction'
                                    }
                                };
                                insertAdjacent('afterBegin', addNewActionschema);
                            }
                        }
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['addMode'] = mode;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps = field.componentProps || {};
                        field.componentProps.addMode = mode;
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'multiple',
            type: 'switch',
            useVisible () {
                const isAssociationField = useIsAssociationField();
                const IsShowMultipleSwitch = (0, __WEBPACK_EXTERNAL_MODULE__schema_settings_hooks_useIsShowMultipleSwitch_mjs__.useIsShowMultipleSwitch)();
                return isAssociationField && IsShowMultipleSwitch();
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Allow multiple'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.multiple) === void 0 || fieldSchema['x-component-props'].multiple,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        field.componentProps = field.componentProps || {};
                        fieldSchema['x-component-props'].multiple = value;
                        field.componentProps.multiple = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'allowDissociate',
            type: 'switch',
            useVisible () {
                var _fieldSchema_xcomponentprops;
                const IsShowMultipleSwitch = (0, __WEBPACK_EXTERNAL_MODULE__schema_settings_hooks_useIsShowMultipleSwitch_mjs__.useIsShowMultipleSwitch)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                const isSubFormMode = (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.mode) === 'Nester';
                return isSubFormMode && IsShowMultipleSwitch();
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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, refresh } = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Allow dissociate'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.allowDissociate) !== false,
                    onChange (value) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        field.componentProps = field.componentProps || {};
                        fieldSchema['x-component-props'].allowDissociate = value;
                        field.componentProps.allowDissociate = value;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        dn.emit('patch', {
                            schema
                        });
                        refresh();
                    }
                };
            }
        },
        {
            name: 'enableLink',
            type: 'switch',
            useVisible () {
                const options = useTitleFieldOptions();
                const readPretty = useIsFieldReadPretty();
                const isFileField = useIsFileField();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                return readPretty && options.length > 0 && !isFileField && 'CollectionField' === fieldSchema['x-component'];
            },
            useComponentProps () {
                var _fieldSchema_xcomponentprops;
                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__hooks_index_mjs__.useDesignable)();
                return {
                    title: t('Enable link'),
                    checked: (null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops.enableLink) !== false,
                    onChange (flag) {
                        fieldSchema['x-component-props'] = {
                            ...null == fieldSchema ? void 0 : fieldSchema['x-component-props'],
                            enableLink: flag
                        };
                        field.componentProps['enableLink'] = flag;
                        dn.emit('patch', {
                            schema: {
                                'x-uid': fieldSchema['x-uid'],
                                'x-component-props': {
                                    ...null == fieldSchema ? void 0 : fieldSchema['x-component-props']
                                }
                            }
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'pattern',
            type: 'select',
            useVisible () {
                const { form } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_FormBlockProvider_mjs__.useFormBlockContext)();
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                return form && !(null == form ? void 0 : form.readPretty) && !(0, __WEBPACK_EXTERNAL_MODULE__schema_settings_isPatternDisabled_mjs__.isPatternDisabled)(fieldSchema);
            },
            useComponentProps () {
                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__hooks_index_mjs__.useDesignable)();
                let readOnlyMode = 'editable';
                if (true === fieldSchema['x-disabled']) readOnlyMode = 'readonly';
                if (true === fieldSchema['x-read-pretty']) readOnlyMode = 'read-pretty';
                return {
                    title: t('Pattern'),
                    options: [
                        {
                            label: t('Editable'),
                            value: 'editable'
                        },
                        {
                            label: t('Readonly'),
                            value: 'readonly'
                        },
                        {
                            label: t('Easy-reading'),
                            value: 'read-pretty'
                        }
                    ],
                    value: readOnlyMode,
                    onChange (v) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        switch(v){
                            case 'readonly':
                                fieldSchema['x-read-pretty'] = false;
                                fieldSchema['x-disabled'] = true;
                                schema['x-read-pretty'] = false;
                                schema['x-disabled'] = true;
                                field.readPretty = false;
                                field.disabled = true;
                                __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(field, 'initStateOfLinkageRules.pattern', (0, __WEBPACK_EXTERNAL_MODULE__form_v2_utils_mjs__.getTempFieldState)(true, __WEBPACK_EXTERNAL_MODULE__schema_settings_LinkageRules_type_mjs__.ActionType.ReadOnly));
                                break;
                            case 'read-pretty':
                                fieldSchema['x-read-pretty'] = true;
                                fieldSchema['x-disabled'] = false;
                                schema['x-read-pretty'] = true;
                                schema['x-disabled'] = false;
                                field.readPretty = true;
                                __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(field, 'initStateOfLinkageRules.pattern', (0, __WEBPACK_EXTERNAL_MODULE__form_v2_utils_mjs__.getTempFieldState)(true, __WEBPACK_EXTERNAL_MODULE__schema_settings_LinkageRules_type_mjs__.ActionType.ReadPretty));
                                break;
                            default:
                                fieldSchema['x-read-pretty'] = false;
                                fieldSchema['x-disabled'] = false;
                                schema['x-read-pretty'] = false;
                                schema['x-disabled'] = false;
                                field.readPretty = false;
                                field.disabled = false;
                                __WEBPACK_EXTERNAL_MODULE_lodash__["default"].set(field, 'initStateOfLinkageRules.pattern', (0, __WEBPACK_EXTERNAL_MODULE__form_v2_utils_mjs__.getTempFieldState)(true, __WEBPACK_EXTERNAL_MODULE__schema_settings_LinkageRules_type_mjs__.ActionType.Editable));
                                break;
                        }
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'titleField',
            type: 'select',
            useVisible () {
                const options = useTitleFieldOptions();
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return options.length > 0 && isAssociationField && 'SubTable' !== fieldMode && 'CustomTitle' !== fieldMode;
            },
            useComponentProps () {
                var _field_componentProps_fieldNames, _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__hooks_index_mjs__.useDesignable)();
                const options = useTitleFieldOptions();
                const collectionField = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionField_deprecated)();
                return {
                    title: t('Title field'),
                    options,
                    value: null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : null === (_field_componentProps_fieldNames = _field_componentProps.fieldNames) || void 0 === _field_componentProps_fieldNames ? void 0 : _field_componentProps_fieldNames.label,
                    onChange (label) {
                        var _collectionField_uiSchema_xcomponentprops, _collectionField_uiSchema;
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        const fieldNames = {
                            ...null == collectionField ? void 0 : null === (_collectionField_uiSchema = collectionField.uiSchema) || void 0 === _collectionField_uiSchema ? void 0 : null === (_collectionField_uiSchema_xcomponentprops = _collectionField_uiSchema['x-component-props']) || void 0 === _collectionField_uiSchema_xcomponentprops ? void 0 : _collectionField_uiSchema_xcomponentprops['fieldNames'],
                            ...field.componentProps.fieldNames,
                            label
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['fieldNames'] = fieldNames;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps.fieldNames = fieldSchema['x-component-props'].fieldNames;
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'dateFormat',
            Component: __WEBPACK_EXTERNAL_MODULE__schema_settings_SchemaSettingsDateFormat_mjs__.SchemaSettingsDateFormat,
            useVisible () {
                const collectionField = useFormItemCollectionField();
                const isDateField = [
                    'datetime',
                    'createdAt',
                    'updatedAt'
                ].includes(null == collectionField ? void 0 : collectionField.interface);
                return isDateField;
            },
            useComponentProps () {
                const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
                return {
                    fieldSchema
                };
            }
        },
        {
            name: 'size',
            type: 'select',
            useVisible () {
                const readPretty = useIsFieldReadPretty();
                const collectionField = useFormItemCollectionField();
                const { getCollection } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
                const targetCollection = getCollection(null == collectionField ? void 0 : collectionField.target);
                const isAttachmentField = [
                    'attachment'
                ].includes(null == collectionField ? void 0 : collectionField.interface) || (null == targetCollection ? void 0 : targetCollection.template) === 'file';
                return readPretty && isAttachmentField;
            },
            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__hooks_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: 'tagColor',
            type: 'select',
            useVisible () {
                const isAssociationField = useIsAssociationField();
                const fieldMode = useFieldMode();
                return isAssociationField && [
                    'Tag'
                ].includes(fieldMode);
            },
            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__hooks_index_mjs__.useDesignable)();
                const collectionField = useFormItemCollectionField();
                var _collectionField_target;
                const colorFieldOptions = (0, __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Designer_mjs__.useColorFields)(null !== (_collectionField_target = null == collectionField ? void 0 : collectionField.target) && void 0 !== _collectionField_target ? _collectionField_target : null == collectionField ? void 0 : collectionField.targetCollection);
                return {
                    title: t('Tag color field'),
                    options: colorFieldOptions,
                    value: null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps.tagColorField,
                    onChange (tagColorField) {
                        const schema = {
                            ['x-uid']: fieldSchema['x-uid']
                        };
                        fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
                        fieldSchema['x-component-props']['tagColorField'] = tagColorField;
                        schema['x-component-props'] = fieldSchema['x-component-props'];
                        field.componentProps.tagColorField = tagColorField;
                        dn.emit('patch', {
                            schema
                        });
                        dn.refresh();
                    }
                };
            }
        },
        {
            name: 'divider',
            type: 'divider',
            useVisible () {
                const collectionField = useFormItemCollectionField();
                return !!collectionField;
            }
        },
        {
            name: 'remove',
            type: 'remove',
            useComponentProps () {
                const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
                return {
                    removeParentsIfNoChildren: true,
                    confirm: {
                        title: t('Delete field')
                    },
                    breakRemoveOn: {
                        'x-component': 'Grid'
                    }
                };
            }
        }
    ]
});
function useIsAddNewForm() {
    const record = (0, __WEBPACK_EXTERNAL_MODULE__record_provider_index_mjs__.useRecord)();
    const isAddNewForm = __WEBPACK_EXTERNAL_MODULE_lodash__["default"].isEmpty(__WEBPACK_EXTERNAL_MODULE_lodash__["default"].omit(record, [
        '__parent',
        '__collectionName'
    ]));
    return isAddNewForm;
}
function isFileCollection(collection) {
    return (null == collection ? void 0 : collection.template) === 'file';
}
function useIsFormReadPretty() {
    const { form } = (0, __WEBPACK_EXTERNAL_MODULE__block_provider_FormBlockProvider_mjs__.useFormBlockContext)();
    return !!(null == form ? void 0 : form.readPretty);
}
function useIsFieldReadPretty() {
    const { fieldSchema: tableColumnSchema } = (0, __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    return field.readPretty || (null == tableColumnSchema ? void 0 : tableColumnSchema['x-read-pretty']);
}
function useFormItemCollectionField() {
    const { getCollectionJoinField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const { getField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollection_deprecated)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const collectionField = getField(fieldSchema['name']) || getCollectionJoinField(fieldSchema['x-collection-field']);
    const { collectionField: columnCollectionField } = (0, __WEBPACK_EXTERNAL_MODULE__table_v2_Table_Column_Decorator_mjs__.useColumnSchema)();
    return collectionField || columnCollectionField;
}
function useIsAssociationField() {
    const collectionField = useFormItemCollectionField();
    const isAssociationField = [
        'obo',
        'oho',
        'o2o',
        'o2m',
        'm2m',
        'm2o',
        'updatedBy',
        'createdBy'
    ].includes(null == collectionField ? void 0 : collectionField.interface);
    return isAssociationField;
}
function useIsMultipleSelect() {
    const collectionField = useFormItemCollectionField();
    const isMultipleSelect = [
        'select',
        'radioGroup'
    ].includes(null == collectionField ? void 0 : collectionField.interface);
    return isMultipleSelect;
}
function useIsMuiltipleAble() {
    const isAssociationField = useIsAssociationField();
    const isMultipleSelect = useIsMultipleSelect();
    return isAssociationField || isMultipleSelect;
}
function useIsFileField() {
    const { getCollection } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const collectionField = useFormItemCollectionField();
    const targetCollection = getCollection(null == collectionField ? void 0 : collectionField.target);
    const isFileField = isFileCollection(targetCollection);
    return isFileField;
}
function useFieldMode() {
    var _field_componentProps;
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const isFileField = useIsFileField();
    const fieldMode = (null == field ? void 0 : null === (_field_componentProps = field.componentProps) || void 0 === _field_componentProps ? void 0 : _field_componentProps['mode']) || (isFileField ? 'FileManager' : 'Select');
    return fieldMode;
}
function useIsSelectFieldMode() {
    const fieldMode = useFieldMode();
    const isAssociationField = useIsAssociationField();
    const isSelectFieldMode = isAssociationField && ('Select' === fieldMode || 'CustomTitle' === fieldMode);
    return isSelectFieldMode;
}
function useValidateSchema() {
    var _interfaceConfig_validateSchema;
    const { getInterface } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const collectionField = useFormItemCollectionField();
    const interfaceConfig = getInterface(null == collectionField ? void 0 : collectionField.interface);
    const validateSchema = null == interfaceConfig ? void 0 : null === (_interfaceConfig_validateSchema = interfaceConfig['validateSchema']) || void 0 === _interfaceConfig_validateSchema ? void 0 : _interfaceConfig_validateSchema.call(interfaceConfig, fieldSchema);
    return validateSchema;
}
function useShowFieldMode() {
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const fieldModeOptions = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useFieldModeOptions)();
    const isTableField = 'TableField' === fieldSchema['x-component'];
    const isAssociationField = useIsAssociationField();
    const showFieldMode = isAssociationField && fieldModeOptions && !isTableField;
    return showFieldMode;
}
function useTitleFieldOptions() {
    const { getCollectionFields, isTitleField } = (0, __WEBPACK_EXTERNAL_MODULE__collection_manager_index_mjs__.useCollectionManager_deprecated)();
    const compile = (0, __WEBPACK_EXTERNAL_MODULE__hooks_index_mjs__.useCompile)();
    const collectionField = useFormItemCollectionField();
    var _getCollectionFields;
    const targetFields = (null == collectionField ? void 0 : collectionField.target) ? getCollectionFields(null == collectionField ? void 0 : collectionField.target) : null !== (_getCollectionFields = getCollectionFields(null == collectionField ? void 0 : collectionField.targetCollection)) && void 0 !== _getCollectionFields ? _getCollectionFields : [];
    const options = targetFields.map((field)=>{
        var _field_uiSchema;
        return {
            value: null == field ? void 0 : field.name,
            label: compile(null == field ? void 0 : null === (_field_uiSchema = field.uiSchema) || void 0 === _field_uiSchema ? void 0 : _field_uiSchema.title) || (null == field ? void 0 : field.name)
        };
    });
    return options;
}
export { formItemSettings, useFieldMode, useIsAddNewForm, useIsAssociationField, useIsFieldReadPretty, useIsFileField, useIsFormReadPretty, useIsMuiltipleAble, useIsMultipleSelect, useIsSelectFieldMode, useTitleFieldOptions, useValidateSchema };
