var _createReducer, _createReducer2;
import { combineReducers } from "redux";
import { createReducer } from "redux-act";
import createAction from "./utils/createMetaAction";
import specialCutsiteFilterOptions from "../constants/specialCutsiteFilterOptions";
// ------------------------------------
// Actions
// ------------------------------------
export var filteredRestrictionEnzymesUpdate = createAction("FILTERED_RESTRICTION_ENZYMES_UPDATE");
export var isEnzymeFilterAndUpdate = createAction("IS_ENZYME_FILTER_AND");
export var filteredRestrictionEnzymesReset = createAction("FILTERED_RESTRICTION_ENZYMES_RESET");
export var filteredRestrictionEnzymesAdd = createAction("FILTERED_RESTRICTION_ENZYMES_ADD");
// ------------------------------------
// Reducer
// ------------------------------------
var defaultInitialState = [specialCutsiteFilterOptions.single];
// let initialState = defaultInitialState;
// const localDefault = window.localStorage.getItem("tgInitialCutsiteFilter");

// if (localDefault) {
//   try {
//     initialState = JSON.parse(localDefault);
//     if (!Array.isArray(initialState)) throw new Error("Must be an array");
//   } catch (e) {
//     initialState = defaultInitialState;
//   }
// }

export default combineReducers({
  //filteredRestrictionEnzymes refer to the enzymes actively included in the react-select filter component
  isEnzymeFilterAnd: createReducer((_createReducer = {}, _createReducer[isEnzymeFilterAndUpdate] = function (state, payload) {
    return payload;
  }, _createReducer), false),
  filteredRestrictionEnzymes: createReducer((_createReducer2 = {}, _createReducer2[filteredRestrictionEnzymesReset] = function () {
    return defaultInitialState;
  }, _createReducer2[filteredRestrictionEnzymesUpdate] = function (state, payload) {
    return payload;
  }, _createReducer2[filteredRestrictionEnzymesAdd] = function (state, payload) {
    return [].concat(state, [payload]);
  }, _createReducer2), defaultInitialState)
});