import { NavigationItem } from "@lumeweb/portal-framework-core"; //#region src/hooks/useNavigationTree.d.ts /** * The shape of a navigation tree node returned by `useNavigationTree`. * Extends NavigationItem with a `depth` field and a non-optional `children` array. */ interface NavigationTreeNode extends NavigationItem { children: NavigationTreeNode[]; /** Depth in the tree. Root nodes have depth 0. */ depth: number; } interface NavigationGroup { items: NavigationTreeNode[]; section: string | null; } /** * Normalize a nav item's section to a fallback string. */ declare function normalizeSection(item: NavigationItem): string; /** * Sort items by `order` ascending, stable for missing order values. */ declare function sortItems(items: T[]): T[]; /** * Group items by their `section` field, returning an object keyed by section name. * Keys are sorted by the first item's order within each group. * The "default" section (items without a section field) always sorts last. */ declare function groupBySection(items: NavigationItem[]): Record; /** * Convert a flat list of NavigationItems into a recursive tree. * * Supports TWO hierarchy mechanisms: * 1. `parentId` chain — flat items with `parentId` referencing a parent's `id` * 2. Inline `children` array — `NavigationItem.children?: NavigationItem[]` * * Both must produce the same tree structure. When an item appears both as a * flat item with `parentId` AND inside an inline `children` array, the * `parentId` reference wins for deduplication — the item is moved under its * parent exactly once. * * @returns Array of root NavigationTreeNode, each with `depth` and `children`. */ declare function buildTree(items: NavigationItem[]): NavigationTreeNode[]; /** * Hook that groups navigation items by section and builds a memoized N-level tree. * * @returns `{ sections, sectionTrees, tree }` where: * - `tree`: flat array of root NavigationTreeNode[] (all sections combined) * - `sections`: keyed by section name, each NavigationGroup has items + tree nodes * - `sectionTrees`: section-keyed NavigationTreeNode[] for per-section rendering */ declare function useNavigationTree(items?: NavigationItem[]): { sections: Record; sectionTrees: Record; tree: NavigationTreeNode[]; }; //#endregion export { NavigationGroup, NavigationTreeNode, buildTree, groupBySection, normalizeSection, sortItems, useNavigationTree }; //# sourceMappingURL=useNavigationTree.d.ts.map