'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getKeyword = exports.getAdvanced = undefined;

var _immutable = require('immutable');

var _immutable2 = _interopRequireDefault(_immutable);

var _searchPage = require('../actions/searchPage');

var _prefs = require('../actions/prefs');

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

exports.default = (state = _immutable2.default.Map(), action) => {
  switch (action.type) {
    case _searchPage.SET_SEARCH_PAGE_ADVANCED:
      return state.set('advanced', _immutable2.default.fromJS(action.payload));
    case _searchPage.SET_SEARCH_PAGE_KEYWORD:
      return state.set('keyword', action.payload);
    case _prefs.SET_SEARCH_PAGE_RECORD_TYPE:
      return state.delete('advanced');
    default:
      return state;
  }
};

const getAdvanced = exports.getAdvanced = state => state.get('advanced');
const getKeyword = exports.getKeyword = state => state.get('keyword');