'use strict';

var jsxRuntime = require('../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.cjs');
var reactIcons_esm = require('../../node_modules/.pnpm/@radix-ui_react-icons@1.3.0_react@18.2.0/node_modules/@radix-ui/react-icons/dist/react-icons.esm.cjs');
var index = require('../../node_modules/.pnpm/class-variance-authority@0.6.0_typescript@5.4.3/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var dropdownMenu = require('../dropdownMenu/dropdownMenu.cjs');
var breadcrumb_module = require('./breadcrumb.module.css.cjs');

const breadcrumb = index.cva(breadcrumb_module.default['breadcrumb'], {
    variants: {
        size: {
            small: breadcrumb_module.default["breadcrumb-small"],
            medium: breadcrumb_module.default["breadcrumb-medium"],
        },
    },
    defaultVariants: {
        size: "medium",
    },
});
const Breadcrumb = React.forwardRef(({ className, size = 'medium', items, maxVisibleItems, separator = '/', onItemClick, ...props }, ref) => {
    const visibleItems = maxVisibleItems && items.length > maxVisibleItems
        ? [
            ...items.slice(0, 1),
            { label: 'ellipsis', href: '#' },
            ...items.slice(-Math.min(maxVisibleItems - 1, items.length - 1))
        ]
        : items;
    const renderItem = (item, index, isLast) => (jsxRuntime.jsxRuntimeExports.jsxs("li", { className: breadcrumb_module.default['breadcrumb-item'], children: [item.label === 'ellipsis' ? (jsxRuntime.jsxRuntimeExports.jsx("span", { className: breadcrumb_module.default['breadcrumb-ellipsis'], children: jsxRuntime.jsxRuntimeExports.jsx(reactIcons_esm.DotsHorizontalIcon, {}) })) : item?.dropdownItems ? (jsxRuntime.jsxRuntimeExports.jsxs(dropdownMenu.DropdownMenu, { children: [jsxRuntime.jsxRuntimeExports.jsxs(dropdownMenu.DropdownMenu.Trigger, { className: breadcrumb_module.default['breadcrumb-dropdown-trigger'], children: [item.icon && jsxRuntime.jsxRuntimeExports.jsx("span", { className: breadcrumb_module.default['breadcrumb-icon'], children: item.icon }), jsxRuntime.jsxRuntimeExports.jsx("span", { children: item.label }), jsxRuntime.jsxRuntimeExports.jsx(reactIcons_esm.ChevronDownIcon, { className: breadcrumb_module.default['breadcrumb-dropdown-icon'] })] }), jsxRuntime.jsxRuntimeExports.jsx(dropdownMenu.DropdownMenu.Content, { className: breadcrumb_module.default['breadcrumb-dropdown-content'], children: item.dropdownItems.map((dropdownItem, dropdownIndex) => (jsxRuntime.jsxRuntimeExports.jsx(dropdownMenu.DropdownMenu.Item, { className: breadcrumb_module.default['breadcrumb-dropdown-item'], onSelect: () => onItemClick && onItemClick({
                                label: dropdownItem.label,
                                href: dropdownItem.href
                            }), children: dropdownItem.label }, dropdownIndex))) })] })) : (jsxRuntime.jsxRuntimeExports.jsxs("a", { href: item.href, className: `${breadcrumb_module.default['breadcrumb-link']} ${isLast ? breadcrumb_module.default['breadcrumb-link-active'] : ''}`, onClick: (e) => {
                    if (onItemClick && item.href !== '#') {
                        e.preventDefault();
                        onItemClick(item);
                    }
                }, children: [item.icon && jsxRuntime.jsxRuntimeExports.jsx("span", { className: breadcrumb_module.default['breadcrumb-icon'], children: item.icon }), jsxRuntime.jsxRuntimeExports.jsx("span", { children: item.label })] })), !isLast && jsxRuntime.jsxRuntimeExports.jsx("span", { className: breadcrumb_module.default['breadcrumb-separator'], children: separator })] }, index));
    return (jsxRuntime.jsxRuntimeExports.jsx("nav", { className: breadcrumb({ size: size, className }), ref: ref, ...props, children: jsxRuntime.jsxRuntimeExports.jsx("ol", { className: breadcrumb_module.default['breadcrumb-list'], children: visibleItems.map((item, index) => renderItem(item, index, index === visibleItems.length - 1)) }) }));
});
Breadcrumb.displayName = "Breadcrumb";

exports.Breadcrumb = Breadcrumb;
//# sourceMappingURL=breadcrumb.cjs.map
