import type { PathProvidedItem, PathRoot } from "./+types.path-table.js"; /** * Transforms a collection of paths into a hierarchical tree structure. * * This function converts the matrix output from `computePathTable` into a * structured tree with well-defined parent-child relationships. Each path * becomes a branch in the tree, with leaf nodes containing the original path data. * * Use cases for the resulting tree structure: * - Hierarchical data navigation * - Building nested UI components (menus, breadcrumbs, etc.) * - Efficient ancestor/descendant lookups * * @example * ```ts * const paths = [ * { id: "x", groupPath: ["A", "B"] }, * { id: "y" }, * { id: "z", groupPath: ["A", "B", "C"] }, * { id: "d", groupPath: ["Y", "X", "C"] }, * { id: "v", groupPath: ["F"] }, * ]; * * const tree = computePathTree(paths); * ``` * * Results in: * ``` * root * ├─ A / root / branch * │ └─ A#B / A / branch * │ ├─ x / A#B / leaf * │ └─ A#B#C / A#B / branch * │ └─ z / A#B#C / leaf * ├─ y / root / leaf * ├─ Y / root / branch * │ └─ Y#X / Y / branch * │ └─ Y#X#C / Y#X / branch * │ └─ d / Y#X#C / leaf * └─ F / root / branch * └─ v / F / leaf * ``` * * @param paths - Array of path items with groupPath properties defining the hierarchy * @param mutableSeenMap - Optional map to track occurrences of path IDs for uniqueness * @param nonAdjacentAreDistinct - When true, treats paths with the same ID but different * occurrences as distinct branches, even when not adjacent * @returns A hierarchical tree structure with all paths organized under a root node */ export declare function computePathTree(paths: T[], mutableSeenMap?: Record, nonAdjacentAreDistinct?: boolean, pathDelimiter?: string): PathRoot;