"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "usePathMaps", {
    enumerable: true,
    get: function() {
        return usePathMaps;
    }
});
const _react = require("react");
const _utils = require("../../../utils");
const createPathMaps = (items = [])=>{
    const pathMap = new Map();
    const focusedToValueMap = new Map();
    const valueToCheckedMap = new Map();
    const valueToItemMap = new Map();
    const valueToPathMap = new Map();
    pathMap.set('root', items.length);
    const rec = (itemsToMap, prevIndex = '', path = [])=>{
        itemsToMap.forEach((item, index)=>{
            const { value, items: innerItems } = item;
            const currIndex = `${prevIndex}/${index}`.replace(/^(\/)/, '');
            focusedToValueMap.set(currIndex, item);
            valueToCheckedMap.set(value, false);
            valueToPathMap.set(value.toString(), [
                ...path,
                value.toString()
            ]);
            if (!innerItems || (0, _utils.isEmpty)(innerItems)) {
                valueToItemMap.set(value, item);
            } else {
                pathMap.set(value, innerItems.length);
                rec(innerItems, currIndex, [
                    ...path,
                    value.toString()
                ]);
            }
        });
    };
    rec(items);
    return [
        pathMap,
        focusedToValueMap,
        valueToCheckedMap,
        valueToItemMap,
        valueToPathMap
    ];
};
const usePathMaps = (items = [])=>{
    return (0, _react.useMemo)(()=>createPathMaps(items), [
        items
    ]);
};
