"use strict";

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

var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");

_Object$defineProperty(exports, "__esModule", {
  value: true
});

exports.get = get;
exports.set = void 0;

var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));

var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));

var _objectPathImmutable = require("object-path-immutable");

var _helpers = require("./helpers");

function get(object, path, defaultValue) {
  if (typeof path === 'string') path = [path];
  if (!(0, _isArray.default)(path)) return object;

  if (!(0, _helpers.isObj)(object) || path.length === 0) {
    return defaultValue === undefined && path.length === 0 ? object : defaultValue;
  }

  if (!Object.prototype.propertyIsEnumerable.call(object, path[0])) {
    return defaultValue;
  }

  return get(object[path[0]], (0, _slice.default)(path).call(path, 1), defaultValue);
}

var set = _objectPathImmutable.set;
exports.set = set;
//# sourceMappingURL=get_set.js.map