"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "syncCheckedState", {
    enumerable: true,
    get: function() {
        return syncCheckedState;
    }
});
const _utils = require("../../../utils");
const _ = require(".");
const syncCheckedState = (value, valueToCheckedMap, valueToItemMap)=>{
    const checked = new Map(valueToCheckedMap);
    checked.forEach((_, key)=>{
        checked.set(key, false);
    });
    if (Array.isArray(value)) {
        value.forEach((currentValue)=>{
            const currentItem = valueToItemMap.get(currentValue);
            if (!currentItem) {
                return;
            }
            checked.set(currentValue, true);
            (0, _.updateDescendants)(currentItem, checked, true);
            (0, _.updateAncestors)(currentItem, checked);
        });
        return checked;
    }
    const currentItem = valueToItemMap.get(value);
    if (!(0, _utils.isEmpty)(value) && currentItem) {
        checked.set(value, 'done');
        (0, _.updateSingleAncestors)(currentItem, checked, 'dot');
    }
    return checked;
};
