"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const kit_Dropdown = require("../Dropdown.cjs");
function useOutsideClickHandler(ref, handler) {
  React.useEffect(() => {
    function handleClickOutside(event) {
      if (ref.current && !ref.current.contains(event.target)) {
        handler();
      }
    }
    document.addEventListener("mouseup", handleClickOutside);
    return () => {
      document.removeEventListener("mouseup", handleClickOutside);
    };
  }, [ref, handler]);
}
const HeaderMenu = ({ bounds, open, handleClose, items }) => {
  const divRef = React.useRef(null);
  useOutsideClickHandler(divRef, handleClose);
  return /* @__PURE__ */ jsxRuntime.jsx(kit_Dropdown, { autoWidthOverlay: true, menu: items, open, placement: "bottomLeft", children: /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      ref: divRef,
      style: open ? {
        height: bounds.height,
        left: bounds.x,
        position: "fixed",
        top: bounds.y,
        width: bounds.width
      } : {
        display: "none"
      },
      onClick: handleClose
    }
  ) });
};
exports.HeaderMenu = HeaderMenu;
