var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
import { configureStore } from '@reduxjs/toolkit';
import logger from 'redux-logger';
import { combineReducers } from 'redux';
import swAuthSliceReducer, { initialState as initAuthState } from './sw-auth.reducer';
import swUserDataReducer, { initialState as initUserDataState } from './sw-user-data.reducer';
import swUIReducer, { initialState as initUIState } from './sw-ui-reducer';
var appReducer = combineReducers({
    swAuth: swAuthSliceReducer,
    swUserData: swUserDataReducer,
    swUI: swUIReducer,
});
var rootReducer = function (state, action) {
    if (action.type === 'RESET_UI') {
        console.log(state);
        state = {
            swAuth: __assign(__assign({}, initAuthState), { partnerKey: state.swAuth.partnerKey, partnerMode: state.swAuth.partnerMode, partnerAddress: state.swAuth.partnerAddress }),
            swUserData: __assign({}, initUserDataState),
            swUI: __assign(__assign({}, initUIState), { showDialog: state.swUI.showDialog }),
        };
    }
    return appReducer(state, action);
};
export var resetUIState = { type: 'RESET_UI' };
export var store = configureStore({
    middleware: function (getDefaultMiddleware) {
        return getDefaultMiddleware({
            serializableCheck: false,
        }).concat(logger);
    },
    reducer: rootReducer,
});
export default store;
