import { jsx as _jsx } from "react/jsx-runtime";
import { RenderRecursively, getRecursiveItemKey } from "../utils/RenderRecursively.js";
import { DefaultNavigationRenderer } from "./DefaultNavigationRenderer.js";
import { NavGroup } from "./NavGroup.js";
/**
 * The default implementation for the nav item keys. It will attempt to set the
 * key in the following order:
 * - `href` if it exists and has length
 * - `children` if it's a string and has length
 * - default {@link getRecursiveItemKey} behavior of `${depth}-${index}`
 *
 * @since 6.0.0
 */ export function getRecursiveNavItemKey(options) {
    const { item } = options;
    // if it's a route, try setting the key to the href since they are generally
    // unique
    if ("href" in item && item.href) {
        return item.href;
    }
    // if children exist in the item (group, route, subheader), try to set that as
    // the key since they are usually unique
    if ("children" in item && typeof item.children === "string" && item.children) {
        return item.children;
    }
    // use the default key behavior if all else fails
    return getRecursiveItemKey(options);
}
/**
 * **Client Component**
 *
 * @since 6.0.0
 */ export function Navigation(props) {
    const { data, items, render = DefaultNavigationRenderer, getItemKey = getRecursiveNavItemKey, ...remaining } = props;
    return /*#__PURE__*/ _jsx(NavGroup, {
        depth: 0,
        ...remaining,
        children: /*#__PURE__*/ _jsx(RenderRecursively, {
            data: data,
            items: items,
            render: render,
            getItemKey: getItemKey
        })
    });
}

//# sourceMappingURL=Navigation.js.map