"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = configureStore;
var _redux = require("redux");
var _localforage = _interopRequireDefault(require("localforage"));
var _reduxPersist = require("redux-persist");
var _api = require("../middlewares/api");
var _exportState = require("../middlewares/exportState");
var _reducers = require("../reducers");
const persistConfig = {
  key: 'redux-devtools',
  blacklist: ['instances', 'socket'],
  storage: _localforage.default
};
const persistedReducer = (0, _reduxPersist.persistReducer)(persistConfig, _reducers.rootReducer);
function configureStore(callback) {
  let composeEnhancers = _redux.compose;
  if (process.env.NODE_ENV !== 'production') {
    if (window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) {
      composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
    }
  }
  const store = (0, _redux.createStore)(persistedReducer, composeEnhancers((0, _redux.applyMiddleware)(_exportState.exportStateMiddleware, _api.api)));
  const persistor = (0, _reduxPersist.persistStore)(store, null, () => {
    callback(store);
  });
  return {
    store,
    persistor
  };
}