import React, { useReducer, useEffect, useCallback, useContext } from "react";
// actions
// it makes them available and current from connector events handlers
export let setSide = () => { };
// reducer
const reducer = (state, update) => {
    return Object.assign(Object.assign({}, state), update);
};
const initialState = {
    Component: null,
    open: false,
};
export const context = React.createContext({
    state: initialState,
    setSide: () => { },
});
export const useSide = () => {
    return useContext(context);
};
const SideProvider = ({ children }) => {
    const [state, dispatch] = useReducer(reducer, initialState);
    const _setSide = useCallback((Component, props) => {
        dispatch({
            Component,
            props,
            open: !!Component,
        });
    }, []);
    useEffect(() => {
        setSide = _setSide;
    }, [_setSide]);
    return (React.createElement(context.Provider, { value: {
            state,
            setSide: _setSide,
        } }, children));
};
export default SideProvider;
//# sourceMappingURL=Provider.js.map