"use strict";

exports.__esModule = true;
exports.default = void 0;
var _immutable = _interopRequireDefault(require("immutable"));
var _navigation = require("../actions/navigation");
var _scopes = require("../actions/scopes");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};
var initialState = _immutable.default.fromJS({
  scopeChangeInProgress: false
});

/*
	This reducer and its associated hook is used to prevent a request from being sent out while the application's scope is changing.
	Basically the reducer responds to an action, set a flag to true and then set it to false once another action is triggered (route change).

	This is a pretty hackish way to ensure that the correct requests are being executed (references #74924, #74764) however we know of no other way to achieve the desired result.
* */

var viewStateReducer = function viewStateReducer(state, action) {
  if (state === void 0) {
    state = initialState;
  }
  switch (action.type) {
    case _scopes.APPLICATION_SCOPE_HAS_CHANGED:
      {
        return state.set("scopeChangeInProgress", action.payload.newScope !== action.payload.previousScope);
      }
    case _navigation.SET_ROUTE:
      {
        return state.set("scopeChangeInProgress", false);
      }
    default:
      return state;
  }
};
var _default = viewStateReducer;
var _default2 = _default;
var _default3 = exports.default = _default2;
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
  reactHotLoader.register(viewStateReducer, "viewStateReducer", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();
;
(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;
  if (!reactHotLoader) {
    return;
  }
  reactHotLoader.register(initialState, "initialState", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
  reactHotLoader.register(viewStateReducer, "viewStateReducer", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/reducers/scopeRouteState.js");
})();
;
(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();