'use strict';

var redux = require('redux');
var chart = require('./chart.js');
var modal = require('./modal.js');

const appReducer = redux.combineReducers({
  chart: chart.chartReducer,
  modal: modal.modalReducer
});
const rootReducer = (state, action) => {
  if (action.type === "RESET_UI_KIT_STORE") {
    state = {
      modal: modal.initialModalState,
      chart: chart.initialChartState
    };
  }
  return appReducer(state, action);
};
const UIKitStore = redux.createStore(rootReducer);
function pushModal(modal$1) {
  UIKitStore.dispatch({
    type: modal.ModalActions.PUSH_MODAL,
    payload: modal$1
  });
}
function popModal() {
  UIKitStore.dispatch({
    type: modal.ModalActions.POP_MODAL
  });
}
function closeModal(id) {
  UIKitStore.dispatch({
    type: modal.ModalActions.CLOSE_MODAL,
    id
  });
}

exports.ChartActions = chart.ChartActions;
exports.chartReducer = chart.chartReducer;
exports.initialChartState = chart.initialChartState;
exports.ModalActions = modal.ModalActions;
exports.initialModalState = modal.initialModalState;
exports.modalReducer = modal.modalReducer;
exports.UIKitStore = UIKitStore;
exports.closeModal = closeModal;
exports.popModal = popModal;
exports.pushModal = pushModal;
exports.rootReducer = rootReducer;
