"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Navigation = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const React = tslib_1.__importStar(require("react"));
const OutsideClick_1 = tslib_1.__importDefault(require("../../../../components/OutsideClick/OutsideClick.js"));
const utils_1 = require("../../../../utils/index.js");
const grid_1 = require("../../../grid/index.js");
const hooks_1 = require("../../hooks/index.js");
const DesktopNavigation_1 = tslib_1.__importDefault(require("../DesktopNavigation/DesktopNavigation.js"));
const MobileNavigation_1 = tslib_1.__importDefault(require("../MobileNavigation/MobileNavigation.js"));
const b = (0, utils_1.block)('navigation');
const Navigation = ({ data, logo, className, mobilePortalContainer, onSidebarChange, }) => {
    const { leftItems = [], rightItems, customMobileHeaderItems, iconSize = 20, withBorder = false, withBorderOnScroll = true, } = data || {};
    const [isSidebarOpened, setIsSidebarOpened] = React.useState(false);
    const [showBorder] = (0, hooks_1.useShowBorder)(withBorder, withBorderOnScroll);
    const { activeItemId, leftItemsWithIconSize, rightItemsWithIconSize, onActiveItemChange } = (0, hooks_1.useActiveNavItem)(iconSize, leftItems, rightItems);
    const onSidebarOpenedChange = (isOpen) => {
        onSidebarChange?.(isOpen);
        setIsSidebarOpened(isOpen);
    };
    return ((0, jsx_runtime_1.jsx)(grid_1.Grid, { className: b({ 'with-border': showBorder }, className), children: (0, jsx_runtime_1.jsx)(grid_1.Row, { children: (0, jsx_runtime_1.jsx)(grid_1.Col, { children: (0, jsx_runtime_1.jsxs)("nav", { children: [(0, jsx_runtime_1.jsx)(DesktopNavigation_1.default, { logo: logo, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange, leftItemsWithIconSize: leftItemsWithIconSize, rightItemsWithIconSize: rightItemsWithIconSize, customMobileHeaderItems: customMobileHeaderItems, isSidebarOpened: isSidebarOpened, onSidebarOpenedChange: onSidebarOpenedChange }), (0, jsx_runtime_1.jsx)(OutsideClick_1.default, { onOutsideClick: () => onSidebarOpenedChange(false), children: (0, jsx_runtime_1.jsx)(MobileNavigation_1.default, { topItems: leftItemsWithIconSize, bottomItems: rightItemsWithIconSize, isOpened: isSidebarOpened, activeItemId: activeItemId, onActiveItemChange: onActiveItemChange, portalContainer: mobilePortalContainer }) })] }) }) }) }));
};
exports.Navigation = Navigation;
exports.default = exports.Navigation;
//# sourceMappingURL=Navigation.js.map
