import * as __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__ from "react/jsx-runtime";
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__index_mjs__ from "../../index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__index_mjs__ from "../../../index.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__common_sortable_item_DragHandleMenu_mjs__ from "../../common/sortable-item/DragHandleMenu.mjs";
import * as __WEBPACK_EXTERNAL_MODULE__AdminMenu_style_mjs__ from "./AdminMenu.style.mjs";
const AdminMenu = (props)=>{
    const { items, onClick } = props;
    const { styles } = (0, __WEBPACK_EXTERNAL_MODULE__AdminMenu_style_mjs__.useStyles)();
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Card, {
        className: styles.adminMenuStyle,
        children: null == items ? void 0 : items.map((item)=>/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(AdminMenuCard, {
                item: item,
                onClick: onClick
            }, item.key))
    });
};
const AdminMenuCard = (props)=>{
    const { item, onClick } = props;
    const { icon, field, Designer, schema } = (null == item ? void 0 : item.menu) || {};
    const { t } = (0, __WEBPACK_EXTERNAL_MODULE_react_i18next__.useTranslation)();
    const { styles } = (0, __WEBPACK_EXTERNAL_MODULE__AdminMenu_style_mjs__.useStyles)();
    const handleClick = ()=>onClick(item);
    return /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_antd__.Card.Grid, {
        className: styles.adminMenuCardStyle,
        onClick: handleClick,
        children: item.menu ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.SchemaContext.Provider, {
            value: schema,
            children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__tachybase_schema__.FieldContext.Provider, {
                value: field,
                children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_mjs__.SortableItem, {
                    className: "card-wrapper",
                    role: "button",
                    "aria-label": t(field.title),
                    removeParentsIfNoChildren: false,
                    overStyle: {
                        background: 'transparent'
                    },
                    children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)(__WEBPACK_EXTERNAL_MODULE__common_sortable_item_DragHandleMenu_mjs__.DragHandleMenu, {
                        className: "drag-handle-menu",
                        isAdminMenu: true,
                        children: [
                            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsxs)("div", {
                                className: "field-link",
                                role: "button",
                                "aria-label": t(field.title),
                                title: t(field.title),
                                children: [
                                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                                        className: "icon-wrapper",
                                        children: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE__index_mjs__.Icon, {
                                            type: null != icon ? icon : 'QuestionCircleOutlined'
                                        })
                                    }),
                                    /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)("div", {
                                        className: "field-title",
                                        children: t(field.title)
                                    })
                                ]
                            }),
                            /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(Designer, {
                                isAdminMenu: true
                            })
                        ]
                    })
                })
            })
        }) : /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.jsx)(__WEBPACK_EXTERNAL_MODULE_react_jsx_runtime__.Fragment, {
            children: item.label
        })
    });
};
export { AdminMenu };
