"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "updateAncestors", {
    enumerable: true,
    get: function() {
        return updateAncestors;
    }
});
const updateAncestors = (node, checkedMap)=>{
    if (!node?.parent) {
        return;
    }
    const { parent } = node;
    const siblings = parent.items;
    const siblingsLength = siblings.length;
    let checkedFromAllSiblings = 0;
    let isParentIndeterminate = false;
    siblings.forEach((sib)=>{
        if (checkedMap.get(sib.value) === 'indeterminate') {
            isParentIndeterminate = true;
            return;
        }
        if (checkedMap.get(sib.value)) {
            checkedFromAllSiblings += 1;
        }
    });
    if (isParentIndeterminate || checkedFromAllSiblings > 0 && checkedFromAllSiblings < siblingsLength) {
        checkedMap.set(parent.value, 'indeterminate');
    } else if (checkedFromAllSiblings === 0) {
        checkedMap.set(parent.value, false);
    } else {
        checkedMap.set(parent.value, true);
    }
    updateAncestors(parent, checkedMap);
};
