import { __assign } from "tslib";
var isObject = function (item) {
    return item && typeof item === "object" && !Array.isArray(item);
};
var deepmerge = function (target, source, options) {
    if (options === void 0) { options = { clone: true }; }
    var output = options.clone ? __assign({}, target) : target;
    if (isObject(target) && isObject(source)) {
        Object.keys(source).forEach(function (key) {
            if (key === "__proto__") {
                return;
            }
            if (isObject(source[key]) && key in target) {
                output[key] = deepmerge(target[key], source[key], options);
            }
            else {
                output[key] = source[key];
            }
        });
    }
    return output;
};
export default deepmerge;
