(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("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 ? (0, tslib_1.__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;
    };
    exports.default = deepmerge;
});
