"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (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 = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > 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__, {
    PaneContextMenu: ()=>PaneContextMenu
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const styled_namespaceObject = require("@emotion/styled");
var styled_default = /*#__PURE__*/ __webpack_require__.n(styled_namespaceObject);
const react_namespaceObject = require("motion/react");
const external_react_namespaceObject = require("react");
const MenuContainer = styled_default()(react_namespaceObject.motion.div)`
  position: fixed;
  left: ${(props)=>props.$x}px;
  top: ${(props)=>props.$y}px;
  min-width: 180px;
  background: var(--canvas-background);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.08),
    0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 6px 0px;
  z-index: 10000;
  pointer-events: auto;
`;
const MenuItem = styled_default().button`
  display: flex;
  align-items: center;
  width: 100%;
  padding: 6px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
  font-size: 12px;
  font-weight: 400;
  color: var(--canvas-foreground-de-emp);
  text-align: left;

  &:hover {
    background: var(--canvas-background-secondary);
  }
`;
const PaneContextMenu = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(({ isOpen, position, items, onClose })=>{
    const menuRef = (0, external_react_namespaceObject.useRef)(null);
    (0, external_react_namespaceObject.useEffect)(()=>{
        if (!isOpen) return;
        const handleClickOutside = (event)=>{
            if (menuRef.current && !menuRef.current.contains(event.target)) onClose();
        };
        const handleEscape = (event)=>{
            if ('Escape' === event.key) onClose();
        };
        const timeoutId = setTimeout(()=>{
            document.addEventListener('click', handleClickOutside);
            document.addEventListener('keydown', handleEscape);
        }, 0);
        return ()=>{
            clearTimeout(timeoutId);
            document.removeEventListener('click', handleClickOutside);
            document.removeEventListener('keydown', handleEscape);
        };
    }, [
        isOpen,
        onClose
    ]);
    const handleItemClick = (0, external_react_namespaceObject.useCallback)((item)=>{
        item.onClick();
        onClose();
    }, [
        onClose
    ]);
    if (0 === items.length) return null;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.AnimatePresence, {
        children: isOpen && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MenuContainer, {
            ref: menuRef,
            $x: position.x,
            $y: position.y,
            initial: {
                opacity: 0,
                scale: 0.95
            },
            animate: {
                opacity: 1,
                scale: 1
            },
            exit: {
                opacity: 0,
                scale: 0.95
            },
            transition: {
                duration: 0.1,
                ease: 'easeOut'
            },
            children: items.map((item)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(MenuItem, {
                    onClick: ()=>handleItemClick(item),
                    children: item.label
                }, item.label))
        })
    });
});
PaneContextMenu.displayName = 'PaneContextMenu';
exports.PaneContextMenu = __webpack_exports__.PaneContextMenu;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "PaneContextMenu"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
