import _objectSpread from "@babel/runtime/helpers/objectSpread";
import { combineReducers, createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import createSagaMiddleware from 'redux-saga';
import { persistStore, persistReducer } from 'redux-persist';
import storage from 'redux-persist/lib/storage';
import controlsBus from '../controlsBus/reducer';
import dataBus from '../dataBus/reducer';
import namespaceIntegration from '../namespaceIntegration/reducer';
import rootSaga from './sagas';
export default (function () {
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
      extraReducers = _ref.extraReducers;

  var sagaMiddleware = createSagaMiddleware();
  var composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
  var persistConfig = {
    key: 'codecrumbs-config-storage',
    whitelist: ['controlsBus'],
    storage: storage
  };
  var persistedReducer = persistReducer(persistConfig, combineReducers(_objectSpread({
    controlsBus: controlsBus,
    dataBus: dataBus,
    namespaceIntegration: namespaceIntegration
  }, extraReducers)));
  var store = createStore(persistedReducer, composeEnhancers(applyMiddleware(thunk, sagaMiddleware)));
  var persistor = persistStore(store);
  sagaMiddleware.run(rootSaga);
  return {
    store: store,
    persistor: persistor
  };
});