import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import "react";
import * as __WEBPACK_EXTERNAL_MODULE__tachybase_schema__ from "@tachybase/schema";
import * as __WEBPACK_EXTERNAL_MODULE_antd__ from "antd";
import * as __WEBPACK_EXTERNAL_MODULE_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__ from "../schema-settings/index.mjs";
const SchemaInitializerOpenModeSchemaItems = (options)=>{
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2;
    const { openMode = true, openSize = true } = options;
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
    const openModeValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['openMode']) || 'drawer';
    var _fieldSchema_xcomponentprops_openSize;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment, {
        children: [
            openMode ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_index_mjs__.SchemaInitializerSelect, {
                title: t('Open mode'),
                options: [
                    {
                        label: t('Drawer'),
                        value: 'drawer'
                    },
                    {
                        label: t('Dialog'),
                        value: 'modal'
                    }
                ],
                value: openModeValue,
                onChange: (value)=>{
                    field.componentProps.openMode = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openMode = value;
                    fieldSchema['x-component-props'].openMode = value;
                    Reflect.deleteProperty(fieldSchema['x-component-props'], 'openSize');
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : null,
            openSize && [
                'modal',
                'drawer'
            ].includes(openModeValue) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_index_mjs__.SchemaInitializerItem, {
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
                    style: {
                        alignItems: 'center',
                        display: 'flex',
                        justifyContent: 'space-between'
                    },
                    children: [
                        t('Popup size'),
                        /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Select, {
                            "data-testid": "antd-select",
                            bordered: false,
                            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_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['openSize']) && void 0 !== _fieldSchema_xcomponentprops_openSize ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2['openMode']) == 'modal' ? 'large' : 'middle',
                            onChange: (value)=>{
                                field.componentProps.openSize = value;
                                const schema = {
                                    'x-uid': fieldSchema['x-uid']
                                };
                                schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                                schema['x-component-props'].openSize = value;
                                fieldSchema['x-component-props'].openSize = value;
                                dn.emit('patch', {
                                    schema: schema
                                });
                                dn.refresh();
                            },
                            style: {
                                textAlign: 'right',
                                minWidth: 100
                            }
                        })
                    ]
                })
            }) : null
        ]
    });
};
const SchemaSettingOpenModeSchemaItems = (options)=>{
    var _fieldSchema_xcomponentprops, _fieldSchema_xcomponentprops1, _fieldSchema_xcomponentprops2;
    const { openMode = true, openSize = true } = options;
    const fieldSchema = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useFieldSchema)();
    const field = (0, __WEBPACK_EXTERNAL_MODULE__tachybase_schema__.useField)();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { dn } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.useDesignable)();
    const openModeValue = (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops ? void 0 : _fieldSchema_xcomponentprops['openMode']) || 'drawer';
    var _fieldSchema_xcomponentprops_openSize;
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment, {
        children: [
            openMode ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.SchemaSettingsSelectItem, {
                title: t('Open mode'),
                options: [
                    {
                        label: t('Drawer'),
                        value: 'drawer'
                    },
                    {
                        label: t('Dialog'),
                        value: 'modal'
                    },
                    {
                        label: t('Sheet'),
                        value: 'sheet'
                    },
                    {
                        label: t('Page'),
                        value: 'page'
                    }
                ],
                value: openModeValue,
                onChange: (value)=>{
                    field.componentProps.openMode = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openMode = value;
                    fieldSchema['x-component-props'].openMode = value;
                    Reflect.deleteProperty(fieldSchema['x-component-props'], 'openSize');
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : null,
            openSize && [
                'modal',
                'drawer'
            ].includes(openModeValue) ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_settings_index_mjs__.SchemaSettingsSelectItem, {
                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_xcomponentprops1 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops1 ? void 0 : _fieldSchema_xcomponentprops1['openSize']) && void 0 !== _fieldSchema_xcomponentprops_openSize ? _fieldSchema_xcomponentprops_openSize : (null == fieldSchema ? void 0 : null === (_fieldSchema_xcomponentprops2 = fieldSchema['x-component-props']) || void 0 === _fieldSchema_xcomponentprops2 ? void 0 : _fieldSchema_xcomponentprops2['openMode']) == 'modal' ? 'large' : 'middle',
                onChange: (value)=>{
                    field.componentProps.openSize = value;
                    const schema = {
                        'x-uid': fieldSchema['x-uid']
                    };
                    schema['x-component-props'] = fieldSchema['x-component-props'] || {};
                    schema['x-component-props'].openSize = value;
                    fieldSchema['x-component-props'].openSize = value;
                    dn.emit('patch', {
                        schema: schema
                    });
                    dn.refresh();
                }
            }) : null
        ]
    });
};
export { SchemaInitializerOpenModeSchemaItems, SchemaSettingOpenModeSchemaItems };
