text: 'use strict';
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  
  var _trimStart2 = require('lodash/trimStart');
  
  var _trimStart3 = _interopRequireDefault(_trimStart2);
  
  var _replace2 = require('lodash/replace');
  
  var _replace3 = _interopRequireDefault(_replace2);
  
  var _pick2 = require('lodash/pick');
  
  var _pick3 = _interopRequireDefault(_pick2);
  
  var _isArray2 = require('lodash/isArray');
  
  var _isArray3 = _interopRequireDefault(_isArray2);
  
  var _isBoolean2 = require('lodash/isBoolean');
  
  var _isBoolean3 = _interopRequireDefault(_isBoolean2);
  
  var _isFunction2 = require('lodash/isFunction');
  
  var _isFunction3 = _interopRequireDefault(_isFunction2);
  
  var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  
  exports.pathToArr = pathToArr;
  exports.getSlashStrPath = getSlashStrPath;
  exports.getDotStrPath = getDotStrPath;
  exports.combineReducers = combineReducers;
  exports.pathFromMeta = pathFromMeta;
  exports.updateItemInArray = updateItemInArray;
  exports.createReducer = createReducer;
  exports.preserveValuesFromState = preserveValuesFromState;
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  
  function pathToArr(path) {
    return path ? path.split(/\//).filter(function (p) {
      return !!p;
    }) : [];
  }
  
  function getSlashStrPath(path) {
    return (0, _trimStart3.default)((0, _replace3.default)(path, /[.]/g, '/'), '/');
  }
  
  function getDotStrPath(path) {
    return pathToArr(path).join('.');
  }
  
  function combineReducers(reducers) {
    return function () {
      var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
      var action = arguments[1];
      return Object.keys(reducers).reduce(function (nextState, key) {
        nextState[key] = reducers[key](state[key], action);
  
        return nextState;
      }, {});
    };
  }
  
  function pathFromMeta(meta) {
    if (!meta) {
      throw new Error('Action meta is required to build path for reducers.');
    }
    var collection = meta.collection,
        doc = meta.doc,
        subcollections = meta.subcollections,
        storeAs = meta.storeAs;
  
    if (storeAs) {
      return doc ? storeAs + '.' + doc : storeAs;
    }
    if (meta.path) {
      return meta.path.split('/');
    }
    if (!collection) {
      throw new Error('Collection is required to construct reducer path.');
    }
    var basePath = collection;
    if (doc) {
      basePath += '.' + doc;
    }
    if (!subcollections) {
      return basePath;
    }
    var mappedCollections = subcollections.map(pathFromMeta);
    return basePath.concat('.' + mappedCollections.join('.'));
  }
  
  function updateItemInArray(array, itemId, updateItemCallback) {
    var matchFound = false;
    var modified = array.map(function (item) {
      if (!item || item.id !== itemId) {
        return item;
      }
      matchFound = true;
  
      var updatedItem = updateItemCallback(item);
      return updatedItem;
    });
    if (!matchFound) {
      modified.push(updateItemCallback({ id: itemId }));
    }
    return modified;
  }
  
  function createReducer(initialState, handlers) {
    return function reducer() {
      var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
      var action = arguments[1];
  
      if (handlers.hasOwnProperty(action.type)) {
        return handlers[action.type](state, action);
      }
      return state;
    };
  }
  
  function preserveValuesFromState(state, preserveSetting, nextState) {
    if ((0, _isBoolean3.default)(preserveSetting)) {
      return nextState ? _extends({}, state, nextState) : state;
    }
  
    if ((0, _isFunction3.default)(preserveSetting)) {
      return preserveSetting(state, nextState);
    }
  
    if ((0, _isArray3.default)(preserveSetting)) {
      return (0, _pick3.default)(state, preserveSetting);
    }
  
    throw new Error('Invalid preserve parameter. It must be an Object or an Array.');
  }