import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "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_react_i18next__ from "react-i18next";
import * as __WEBPACK_EXTERNAL_MODULE__api_client_hooks_useAPIClient_mjs__ from "../../api-client/hooks/useAPIClient.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__application_index_mjs__ from "../../application/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__icon_index_mjs__ from "../../icon/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__ from "../../schema-component/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__schema_component_antd_menu_MenuItemInitializers_index_mjs__ from "../../schema-component/antd/menu/MenuItemInitializers/index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__style_theme_index_mjs__ from "../../style/theme/index.mjs";
const UploadMenuItem = ()=>{
    const { insert } = (0, __WEBPACK_EXTERNAL_MODULE__application_index_mjs__.useSchemaInitializer)();
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const options = (0, __WEBPACK_EXTERNAL_MODULE_react__.useContext)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.SchemaOptionsContext);
    const { theme } = (0, __WEBPACK_EXTERNAL_MODULE__style_theme_index_mjs__.useGlobalTheme)();
    const { styles } = (0, __WEBPACK_EXTERNAL_MODULE__schema_component_antd_menu_MenuItemInitializers_index_mjs__.useStyles)();
    (0, __WEBPACK_EXTERNAL_MODULE__api_client_hooks_useAPIClient_mjs__.useAPIClient)();
    const handleClick = (0, __WEBPACK_EXTERNAL_MODULE_react__.useCallback)(async ()=>{
        const values = await (0, __WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.FormDialog)(t('Load menu config'), ()=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.SchemaComponentOptions, {
                scope: options.scope,
                components: {
                    ...options.components
                },
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_components__.FormLayout, {
                    layout: 'vertical',
                    children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__schema_component_index_mjs__.SchemaComponent, {
                        schema: {
                            type: 'object',
                            title: t('Load menu config'),
                            properties: {
                                title: {
                                    'x-decorator': 'FormItem',
                                    'x-component': 'Input',
                                    title: t('Menu item title'),
                                    required: true,
                                    'x-component-props': {}
                                },
                                bindMenuToRole: {
                                    type: 'boolean',
                                    title: '{{ t("Automatically assign permissions to all matching roles") }}',
                                    'x-decorator': 'FormItem',
                                    'x-component': 'Checkbox',
                                    default: true
                                },
                                file: {
                                    type: 'object',
                                    title: '{{ t("File") }}',
                                    required: true,
                                    'x-decorator': 'FormItem',
                                    'x-component': 'Upload.Attachment',
                                    'x-component-props': {
                                        action: 'attachments:create',
                                        multiple: false
                                    }
                                }
                            }
                        }
                    })
                })
            }), theme).open({
            initialValues: {}
        });
        const { title, icon } = values;
    }, [
        insert,
        options.components,
        options.scope,
        t,
        theme
    ]);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__application_index_mjs__.SchemaInitializerItem, {
        className: styles.menuItem,
        icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__icon_index_mjs__.Icon, {
            type: 'UploadOutlined'
        }),
        title: t('Load menu config'),
        onClick: handleClick
    });
};
export { UploadMenuItem };
