import { j as jsxRuntimeExports } from '../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.js';
import { Root } from '../../node_modules/.pnpm/@radix-ui_react-collapsible@1.1.2_@types_react-dom@18.0.11_@types_react@18.2.12_react-dom@18._hjslo7xm5vmo3b4sx344jkbtcq/node_modules/@radix-ui/react-collapsible/dist/index.js';
import { cva } from '../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js';
import { createContext, forwardRef, useContext } from 'react';
import { TooltipProvider, Tooltip } from '../tooltip/tooltip.js';
import styles from './sidebar.module.css.js';
import { clsx } from '../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.js';

const SidebarContext = createContext({ isCollapsed: false });
const root = cva(styles.root);
const SidebarRoot = forwardRef(({ className, position = "left", open, onOpenChange, hideCollapsedItemTooltip, children, ...props }, ref) => (jsxRuntimeExports.jsx(SidebarContext.Provider, { value: { isCollapsed: !open, hideCollapsedItemTooltip }, children: jsxRuntimeExports.jsx(TooltipProvider, { children: jsxRuntimeExports.jsx(Root, { ref: ref, className: root({ className }), "data-position": position, "data-state": open ? "expanded" : "collapsed", open: open, onOpenChange: onOpenChange, "aria-label": "Navigation Sidebar", "aria-expanded": open, role: "navigation", ...props, asChild: true, children: jsxRuntimeExports.jsxs("aside", { children: [jsxRuntimeExports.jsx(Tooltip, { message: open ? "Click to collapse" : "Click to expand", side: position === "left" ? "right" : "left", asChild: true, children: jsxRuntimeExports.jsx("div", { className: styles.resizeHandle, onClick: () => onOpenChange?.(!open), role: "button", tabIndex: 0, "aria-label": open ? "Collapse sidebar" : "Expand sidebar", onKeyDown: (e) => {
                                if (e.key === "Enter" || e.key === " ") {
                                    e.preventDefault();
                                    onOpenChange?.(!open);
                                }
                            } }) }), children] }) }) }) })));
const SidebarHeader = forwardRef(({ className, logo, title, onLogoClick, ...props }, ref) => (jsxRuntimeExports.jsxs("div", { ref: ref, className: styles.header, role: "banner", ...props, children: [jsxRuntimeExports.jsx("div", { className: styles.logo, onClick: onLogoClick, role: onLogoClick ? "button" : undefined, tabIndex: onLogoClick ? 0 : undefined, onKeyDown: (e) => {
                if (onLogoClick && (e.key === "Enter" || e.key === " ")) {
                    e.preventDefault();
                    onLogoClick();
                }
            }, style: { cursor: onLogoClick ? "pointer" : undefined }, children: logo }), jsxRuntimeExports.jsx("div", { className: styles.title, role: "heading", "aria-level": 1, children: title })] })));
const SidebarMain = forwardRef(({ className, children, ...props }, ref) => (jsxRuntimeExports.jsx("div", { ref: ref, className: styles.main, role: "group", "aria-label": "Main navigation", ...props, children: children })));
const SidebarFooter = forwardRef(({ className, children, ...props }, ref) => (jsxRuntimeExports.jsx("div", { ref: ref, className: styles.footer, role: "group", "aria-label": "Footer navigation", ...props, children: children })));
const SidebarItem = forwardRef(({ classNames, icon, children, active, disabled, ...props }, ref) => {
    const { isCollapsed, hideCollapsedItemTooltip } = useContext(SidebarContext); // To prevent prop drillng
    const itemContent = (jsxRuntimeExports.jsxs("a", { ref: ref, className: clsx(styles["nav-item"], classNames?.root), "data-active": active, "data-disabled": disabled, role: "menuitem", "aria-current": active ? "page" : undefined, "aria-disabled": disabled, ...props, children: [jsxRuntimeExports.jsx("span", { className: clsx(styles["nav-icon"], classNames?.icon), "aria-hidden": "true", children: icon }), jsxRuntimeExports.jsx("span", { className: styles["nav-text"], children: children })] }));
    return (isCollapsed && !hideCollapsedItemTooltip) ? (jsxRuntimeExports.jsx(Tooltip, { message: children, side: "right", children: itemContent })) : itemContent;
});
const SidebarNavigationGroup = forwardRef(({ className, name, icon, children, ...props }, ref) => (jsxRuntimeExports.jsxs("section", { ref: ref, className: className, "aria-label": name, ...props, children: [jsxRuntimeExports.jsxs("div", { className: styles["nav-group-header"], children: [icon && jsxRuntimeExports.jsx("span", { className: styles["nav-icon"], children: icon }), jsxRuntimeExports.jsx("span", { className: styles["nav-group-name"], children: name })] }), jsxRuntimeExports.jsx("div", { className: styles["nav-group-items"], role: "list", children: children })] })));
SidebarRoot.displayName = "Sidebar.Root";
SidebarHeader.displayName = "Sidebar.Header";
SidebarMain.displayName = "Sidebar.Main";
SidebarFooter.displayName = "Sidebar.Footer";
SidebarItem.displayName = "Sidebar.Item";
SidebarNavigationGroup.displayName = "Sidebar.Group";
const Sidebar = Object.assign(SidebarRoot, {
    Header: SidebarHeader,
    Main: SidebarMain,
    Footer: SidebarFooter,
    Item: SidebarItem,
    Group: SidebarNavigationGroup,
});

export { Sidebar };
//# sourceMappingURL=sidebar.js.map
