"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var updateElement_1 = require("./updateElement");
function patch(topLevelDomElement, patchesDict, component) {
    if (!patchesDict) {
        return topLevelDomElement;
    }
    var keysToUpdate = Object.keys(patchesDict);
    if (keysToUpdate.length < 1) {
        return topLevelDomElement;
    }
    for (var flexId in patchesDict) {
        var virtualElement = patchesDict[flexId];
        var domElement = component._getRealElementAtId(flexId);
        if (domElement) {
            var nestedModuleElement = component._nestedComponentElements[flexId];
            updateElement_1.default(domElement, virtualElement, domElement.parentNode, virtualElement.__parent, component, true);
            if (nestedModuleElement && nestedModuleElement.__instance) {
                patch(domElement, nestedModuleElement.__instance._getPrecalcedPatches(), nestedModuleElement.__instance);
            }
        }
    }
}
exports.default = patch;
//# sourceMappingURL=patch.js.map