'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var index = require('../../store/index.js');
var React = require('react');
var reactRedux = require('react-redux');
var redux = require('redux');
var modal = require('../../store/modal.js');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var React__default = /*#__PURE__*/_interopDefault(React);

const ctx = React.createContext({
  store: index.UIKitStore,
  storeState: index.UIKitStore.getState()
});
const KitStoreProvider = (props) => {
  const { children } = props;
  const storeRef = React.useRef(redux.createStore(index.rootReducer));
  return /* @__PURE__ */ React__default.default.createElement(reactRedux.Provider, { context: ctx, store: storeRef.current }, children);
};
var KitStoreProvider$1 = KitStoreProvider;
const useKitDispatch = reactRedux.createDispatchHook(ctx);
const useKitSelector = reactRedux.createSelectorHook(ctx);
const usePushModal = () => {
  const dispatch = useKitDispatch();
  const pushModal = React.useCallback(
    (modal$1) => {
      dispatch({
        type: modal.ModalActions.PUSH_MODAL,
        payload: modal$1
      });
    },
    [dispatch]
  );
  return pushModal;
};
const useCloseModal = () => {
  const dispatch = useKitDispatch();
  const closeModal = React.useCallback(
    (id) => {
      dispatch({
        type: modal.ModalActions.CLOSE_MODAL,
        id
      });
    },
    [dispatch]
  );
  return closeModal;
};
const usePopModal = () => {
  const dispatch = useKitDispatch();
  const popModal = React.useCallback(() => {
    dispatch({
      type: modal.ModalActions.POP_MODAL
    });
  }, [dispatch]);
  return popModal;
};
const useResetModal = () => {
  const dispatch = useKitDispatch();
  const resetModal = React.useCallback(() => {
    dispatch({
      type: modal.ModalActions.RESET_MODAL
    });
  }, [dispatch]);
  return resetModal;
};

exports.default = KitStoreProvider$1;
exports.useCloseModal = useCloseModal;
exports.useKitDispatch = useKitDispatch;
exports.useKitSelector = useKitSelector;
exports.usePopModal = usePopModal;
exports.usePushModal = usePushModal;
exports.useResetModal = useResetModal;
