"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = set;

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));

var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));

// @ts-nocheck
function set(entity, paths, value) {
  if (!paths.length) {
    return value;
  }

  var _paths = (0, _toArray2.default)(paths),
      path = _paths[0],
      restPath = _paths.slice(1);

  var clone;

  if (!entity && typeof path === 'number') {
    clone = [];
  } else if (Array.isArray(entity)) {
    clone = (0, _toConsumableArray2.default)(entity);
  } else {
    clone = (0, _objectSpread2.default)({}, entity);
  }

  clone[path] = set(clone[path], restPath, value);
  return clone;
}