"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var avatar = require('../avatar/avatar.cjs');
var flex = require('../flex/flex.cjs');
var tooltip = require('../tooltip/tooltip.cjs');
var sidebarRoot = require('./sidebar-root.cjs');
var sidebar_module = require('./sidebar.module.css.cjs');

const SidebarItem = React.forwardRef(({ classNames, leadingIcon, children, active, disabled, as = jsxRuntime.jsx("a", {}), ...props }, ref) => {
    const { isCollapsed, hideCollapsedItemTooltip } = React.useContext(sidebarRoot.SidebarContext);
    const shouldShowFallback = leadingIcon == undefined &&
        isCollapsed &&
        typeof children === 'string' &&
        children.length > 0;
    const content = React.cloneElement(as, {
        ref,
        className: index.cx(sidebar_module.default['nav-item'], classNames?.root),
        'data-active': active,
        'data-disabled': disabled,
        role: 'menuitem',
        'aria-current': active ? 'page' : undefined,
        'aria-disabled': disabled,
        ...props
    }, jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(flex.Flex, { align: 'center', gap: 3, className: index.cx(sidebar_module.default['nav-leading-icon'], classNames?.leadingIcon), "aria-hidden": 'true', children: shouldShowFallback ? (jsxRuntime.jsx(avatar.Avatar, { size: 1, variant: 'soft', color: 'neutral', fallback: children[0].toUpperCase(), style: { cursor: 'pointer' } })) : (leadingIcon) }), !isCollapsed && jsxRuntime.jsx("span", { className: sidebar_module.default['nav-text'], children: children })] }));
    if (isCollapsed && !hideCollapsedItemTooltip) {
        return (jsxRuntime.jsx(tooltip.Tooltip, { message: children, side: 'right', children: content }));
    }
    return content;
});
SidebarItem.displayName = 'Sidebar.Item';

exports.SidebarItem = SidebarItem;
//# sourceMappingURL=sidebar-item.cjs.map
