'use strict';

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

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.sweep = sweep;

var _difference = require('lodash/difference');

var _difference2 = _interopRequireDefault(_difference);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function sweep(liftedState) {
  var state = _extends({}, liftedState);
  state.skippedActionIds.forEach(function (id) {
    delete state.actionsById[id];
    var idx = liftedState.stagedActionIds.indexOf(id);
    if (idx !== -1) state.computedStates.splice(idx, 1);
  });
  state.stagedActionIds = (0, _difference2.default)(state.stagedActionIds, state.skippedActionIds);
  state.skippedActionIds = [];
  state.currentStateIndex = Math.min(state.currentStateIndex, state.stagedActionIds.length - 1);
  return state;
}