"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardMenuSidebarButton = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const Collapse_1 = require("../Collapse");
const DashboardSidebarButton_1 = require("../DashboardSidebarButton");
const DashboardSidebarProvider_1 = require("../DashboardSidebarProvider");
const useLogic_1 = require("./useLogic");
exports.DashboardMenuSidebarButton = (0, react_1.forwardRef)((props, ref) => {
    const { collapsedIn, isPopupOpen, setIsPopupOpen } = (0, react_1.useContext)(DashboardSidebarProvider_1.DashboardSidebarContext);
    const { handleTogglePopover, popoverAnchorRef } = (0, useLogic_1.useLogic)({
        isPopupOpen,
        setIsPopupOpen,
        ref,
    });
    const { children, popover, ...buttonProps } = props;
    return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(DashboardSidebarButton_1.DashboardSidebarButton, { ref: popoverAnchorRef, ...buttonProps, onClick: handleTogglePopover, selected: isPopupOpen, children: (0, jsx_runtime_1.jsx)(Collapse_1.Collapse, { orientation: "horizontal", in: collapsedIn, children: children }) }), popover] }));
});
