import { jsx as _jsx } from "react/jsx-runtime";
import { Divider } from "../divider/Divider.js";
import { CollapsibleNavGroup } from "./CollapsibleNavGroup.js";
import { NavItemLink } from "./NavItemLink.js";
import { NavSubheader } from "./NavSubheader.js";
import { getHrefFromParents } from "./getHrefFromParents.js";
/**
 * **Client Component**
 *
 * The default behavior is attempt to render in order:
 * - `const { type, items, ...props } = item`
 * - `type === "divider"` - `<Divider {...props} />`
 * - `type === "subheader"` - `<NavSubheader {...props} />`
 * - `type === "group"` - `<><NavSubheader {...props} />{children}</>`
 * - `!!items` - `<CollapsibleNavGroup />`
 * - `<NavItemLink {...item} as={linkComponent} active={pathname === href} />`
 *
 * @since 6.0.0
 */ export function DefaultNavigationRenderer(props) {
    const { item, data, children, parents } = props;
    switch(item.type){
        case "divider":
            {
                const { type: _type, items: _items, ...divider } = item;
                return /*#__PURE__*/ _jsx(Divider, {
                    ...divider
                });
            }
        case "subheader":
            {
                const { type: _type, items: _items, ...subheader } = item;
                return /*#__PURE__*/ _jsx(NavSubheader, {
                    ...subheader
                });
            }
    }
    if (item.items) {
        const nextParents = [
            item,
            ...parents
        ];
        return /*#__PURE__*/ _jsx(CollapsibleNavGroup, {
            depth: nextParents.length,
            defaultCollapsed: ()=>!data?.pathname.includes(getHrefFromParents(nextParents)),
            buttonChildren: item.children,
            children: children
        });
    }
    const href = `${getHrefFromParents(parents)}${item.href}`;
    return /*#__PURE__*/ _jsx(NavItemLink, {
        ...item,
        as: data?.linkComponent,
        active: "active" in item && !!item.active || data?.pathname === href,
        href: href
    });
}

//# sourceMappingURL=DefaultNavigationRenderer.js.map