"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deepSet = deepSet;
exports.deepSet_ = deepSet_;
const clone_1 = require("./util/clone");
function deepSet(obj, path, value) {
    let _obj = (0, clone_1.clone)(obj);
    if (path.length > 0) {
        const [head, ...tail] = path;
        _obj[head] = deepSet(_obj[head] || {}, tail, value);
        return _obj;
    }
    else {
        return value;
    }
}
function deepSet_(obj, path, value) {
    if (path.length > 1) {
        const [head, ...tail] = path;
        obj[head] = obj[head] ?? {};
        deepSet_(obj[head], tail, value);
    }
    else {
        const [head] = path;
        obj[head] = value;
    }
}
//# sourceMappingURL=deepSet.js.map