"use strict";

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

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

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

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

var _immutable = require("immutable");

var _store = _interopRequireDefault(require("store"));

var _sessionStore = _interopRequireDefault(require("./sessionStore"));

var _constants = require("@instructure/quiz-common/lib/constants");

var PersistedState =
/*#__PURE__*/
function () {
  function PersistedState() {
    (0, _classCallCheck2.default)(this, PersistedState);
  }

  (0, _createClass2.default)(PersistedState, [{
    key: "load",

    /**
     * Some of our redux store values are stored in browser client-side storage
     * for easy recall in the event of a page refresh, etc. This provides a single
     * place to load all of those values in a form mimicking our redux store so
     * that it can easily be used, for example, for setting the redux initial
     * state.
     *
     * See also src/common/middleware/persistedStorageMiddleware.js for how these
     * values are set.
     */
    value: function load() {
      if (!_sessionStore.default.enabled) {
        return;
      }

      return (0, _immutable.Map)({
        taking: (0, _immutable.Map)({
          sessionIdForCurrentItem: _store.default.get(_constants.CACHED_SESSION_ID),
          currentSessionItemPosition: parseInt(_store.default.get(_constants.ACTIVE_QUESTION), 10) || 1
        })
      });
    }
  }]);
  return PersistedState;
}();

var _default = new PersistedState();

exports.default = _default;