"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = function(exports1, definition) {
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = function(obj, prop) {
        return Object.prototype.hasOwnProperty.call(obj, prop);
    };
})();
(()=>{
    __webpack_require__.r = function(exports1) {
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    fullScreen: ()=>fullScreen,
    disableRightMenu: ()=>disableRightMenu,
    showScrollArea: ()=>ContextMenuItemsProps_rslib_entry_showScrollArea,
    designerMode: ()=>designerMode
});
const client_namespaceObject = require("@tachybase/utils/client");
const external_antd_namespaceObject = require("antd");
const external_react_i18next_namespaceObject = require("react-i18next");
const index_js_namespaceObject = require("../../schema-component/index.js");
const designerMode = {
    name: 'designerMode',
    useLoadMethod: ()=>{
        const { designable, setDesignable } = (0, index_js_namespaceObject.useDesignable)();
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        return {
            title: t('Designer mode'),
            actionProps: {
                onClick: ()=>{
                    setDesignable(!designable);
                }
            }
        };
    }
};
const fullScreen = {
    name: 'fullScreen',
    useLoadMethod: (param)=>{
        let { position } = param;
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        const { message } = external_antd_namespaceObject.App.useApp();
        return {
            title: t('Fullscreen'),
            actionProps: {
                onClick: ()=>{
                    checkedAutoPage(position, message, t);
                }
            }
        };
    }
};
const disableRightMenu = {
    name: 'disableRightMenu',
    sort: 4,
    useLoadMethod: (param)=>{
        let { enable, setEnable } = param;
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        return {
            title: t('Disable contextmenu'),
            actionProps: {
                onClick: ()=>{
                    setEnable(!enable);
                }
            }
        };
    }
};
const ContextMenuItemsProps_rslib_entry_showScrollArea = {
    name: 'showScrollArea',
    sort: 3,
    useLoadMethod: (param)=>{
        let { showScrollArea, setShowScrollArea } = param;
        const { t } = (0, external_react_i18next_namespaceObject.useTranslation)();
        return {
            title: showScrollArea ? t('Hidden scroll area') : t('Show scroll area'),
            actionProps: {
                onClick: ()=>{
                    setShowScrollArea(!showScrollArea);
                }
            }
        };
    }
};
const checkedAutoPage = (position, message, t)=>{
    const element = document.elementFromPoint(null == position ? void 0 : position.x, null == position ? void 0 : position.y);
    const blockElement = element.closest('.ant-card');
    const gridRow = null == blockElement ? void 0 : blockElement.closest('.CardRow');
    const navbar = document.querySelector('.ant-layout-header');
    blockElement.closest('.ant-modal-body');
    const amplifierBlock = blockElement.closest('.amplifier-block');
    const navbarHeight = navbar.getBoundingClientRect();
    const classId = (0, client_namespaceObject.uid)();
    if (blockElement) {
        const page = null == blockElement ? void 0 : blockElement.closest('.ant-tb-page ');
        const drawer = null == blockElement ? void 0 : blockElement.closest('.ant-drawer-body');
        const modal = null == blockElement ? void 0 : blockElement.closest('.ant-modal-body');
        const tabNav = amplifierBlock.querySelector('.ant-tabs-nav');
        if (tabNav) tabNav.style.display = 'none';
        const parentNode = gridRow.parentNode;
        Array.from(parentNode.children).forEach((sibling)=>{
            if (sibling !== gridRow) sibling.style.display = 'none';
        });
        const autoNode = document.createElement('div');
        autoNode.style.width = amplifierBlock.getBoundingClientRect().width + 'px';
        autoNode.className = 'autoPage' + classId;
        autoNode.style.position = 'fixed';
        autoNode.style.top = '0';
        autoNode.style.zIndex = '100';
        const exitNode = document.createElement('div');
        exitNode.style.width = '100%';
        exitNode.style.height = '30px';
        exitNode.style.textAlign = 'center';
        exitNode.style.lineHeight = '30px';
        exitNode.style.backgroundColor = '#e6e6e6';
        exitNode.textContent = "".concat(t('Exit fullscreen'));
        autoNode.appendChild(exitNode);
        autoNode.addEventListener('click', ()=>{
            removeNode({
                gridRow,
                classId
            });
        });
        if (page) {
            autoNode.style.marginTop = "".concat(navbarHeight.height, "px");
            const header = document.querySelector('.ant-page-header');
            const layoutSider = document.querySelector('.ant-layout-sider');
            header.style.display = 'none';
            layoutSider.style.display = 'none';
            page.style.marginTop = '30px';
            page.insertAdjacentElement('beforebegin', autoNode);
        } else if (drawer) {
            autoNode.style.position = '';
            drawer.insertAdjacentElement('beforebegin', autoNode);
        } else if (modal) {
            autoNode.style.position = '';
            autoNode.style.width = '100%';
            modal.insertAdjacentElement('beforebegin', autoNode);
        }
    } else message.warning(t('There are no fullscreen blocks available at the current location'));
};
const removeNode = (param)=>{
    let { gridRow: blockElement, classId } = param;
    const page = null == blockElement ? void 0 : blockElement.closest('.ant-tb-page');
    const drawer = null == blockElement ? void 0 : blockElement.closest('.ant-drawer-body');
    const parentNode = blockElement.parentNode;
    const tabNav = document.querySelector('.ant-tabs-nav');
    if (tabNav) tabNav.style.display = '';
    Array.from(parentNode.children).forEach((sibling)=>{
        if (sibling !== blockElement) sibling.style.display = '';
        if (sibling.id.includes('DndDescribedBy')) sibling.style.display = 'none';
    });
    if (page) {
        page.style.marginTop = '';
        const layoutSider = document.querySelector('.ant-layout-sider');
        const header = document.querySelector('.ant-page-header');
        layoutSider.style.display = '';
        header.style.display = '';
    } else if (drawer) drawer.style.marginTop = '';
    const autoPage = document.querySelector('.autoPage' + classId);
    if (autoPage) autoPage.parentNode.removeChild(autoPage);
};
var __webpack_export_target__ = exports;
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
    value: true
});
