import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { DashboardSidebarSkeleton } from '../DashboardSidebarSkeleton';
import { NavMenu } from '../NavMenu';
import { PinButton } from '../PinButton';
import { cva } from '../utils/cva';
import { getInertProps } from '../utils/getInertProps';
import { dashboardSidebarClassnames } from './constants';
import { SidebarNav } from './SidebarNav';
import { Footer, SidebarContent, SidebarHeader, SidebarRoot, StyledPaper, Wrapper, } from './styles';
import { useLogic } from './useLogic';
const sidebar = cva('', {
    variants: {
        hasProfile: {
            true: dashboardSidebarClassnames.hasProfile,
        },
        hasMenuOrganization: {
            true: dashboardSidebarClassnames.hasMenuOrganization,
        },
    },
});
/**
 * Основной sidebar приложения
 */
export const DashboardSidebar = forwardRef((props, ref) => {
    const { isPinned, isMobile, collapsedIn, onTogglePin, onMouseEnter, onMouseLeave, alertHeight, classnames, menu, header, isLoading, hasMenuOrganization, hasProfile, } = useLogic(props);
    if (isLoading) {
        return _jsx(DashboardSidebarSkeleton, {});
    }
    return (_jsx(Wrapper, { "$isPinned": isPinned, "$alertHeight": alertHeight, className: sidebar({
            hasProfile,
            hasMenuOrganization,
        }), children: _jsx(SidebarRoot, { ref: ref, "$isPinned": isPinned, "$collapsedIn": collapsedIn, className: classnames, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...getInertProps(isMobile && !isPinned), children: _jsxs(StyledPaper, { variant: "outlined", children: [_jsxs(SidebarContent, { "$collapsedIn": collapsedIn, "$isPinned": isPinned, "$hasHeader": Boolean(header), children: [header && _jsx(SidebarHeader, { children: header }), _jsx(SidebarNav, { menu: _jsx(NavMenu, { collapsedIn: collapsedIn, items: menu.items }) })] }), _jsx(Footer, { children: _jsx(PinButton, { isPinned: isPinned, collapsedIn: collapsedIn, onClick: onTogglePin }) })] }) }) }));
});
