"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.configureStore = void 0;
var tslib_1 = require("tslib");
var redux_1 = require("redux");
var redux_thunk_1 = tslib_1.__importDefault(require("redux-thunk"));
var promise_middleware_1 = require("./promise-middleware");
var logger_1 = require("./logger");
var root_1 = require("../reducers/root");
function configureStore(initialState, extraReducers) {
    var root = extraReducers ? (0, redux_1.combineReducers)(tslib_1.__assign(tslib_1.__assign({}, root_1.rootReducer), extraReducers)) : (0, redux_1.combineReducers)(root_1.rootReducer);
    var store = redux_1.compose.apply(void 0, tslib_1.__spreadArray([//HACK: Something bogus about the compose() declaration
        _getMiddleware()], _getEnhancers(), false))(redux_1.createStore)(root, initialState);
    return store;
}
exports.configureStore = configureStore;
function _getMiddleware() {
    var middleware = [
        promise_middleware_1.promiseMiddleware,
        redux_thunk_1.default,
    ];
    if (__DEV__) {
        middleware = tslib_1.__spreadArray(tslib_1.__spreadArray([], middleware, true), [logger_1.logger], false);
    }
    return redux_1.applyMiddleware.apply(void 0, middleware);
}
function _getEnhancers() {
    var enhancers = [];
    if (__DEV__ && window.__REDUX_DEVTOOLS_EXTENSION__) {
        enhancers = tslib_1.__spreadArray(tslib_1.__spreadArray([], enhancers, true), [window.__REDUX_DEVTOOLS_EXTENSION__()], false);
    }
    return enhancers;
}
//# sourceMappingURL=configure-store.js.map