"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "usePathMaps", {
    enumerable: true,
    get: function() {
        return usePathMaps;
    }
});
const _react = require("react");
const usePathMaps = (items)=>{
    return (0, _react.useMemo)(()=>{
        const pathMap = new Map();
        const focusedToValueMap = new Map();
        pathMap.set('root', items.length);
        const rec = (items, prevIndex = '')=>{
            items.forEach((item, index)=>{
                const { value, items: innerItems } = item;
                const currIndex = `${prevIndex}/${index}`.replace(/^(\/)/, '');
                focusedToValueMap.set(currIndex, item);
                if (innerItems) {
                    pathMap.set(value, innerItems.length);
                    rec(innerItems, currIndex);
                }
            });
        };
        rec(items);
        return [
            pathMap,
            focusedToValueMap
        ];
    }, [
        items
    ]);
};
