"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MapContextProvider = exports.useMapProviderContext = exports.MapProviderContextProvider = exports.useAppState = exports.useReduxDispatch = exports.ReduxProvider = void 0;
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var react_redux_1 = require("react-redux");
var MapProviderContext = React.createContext({});
/**
 * Wraps the provider component of react-redux
 *
 * @since 0.14
 */
var ReduxProvider = function (_a) {
    var store = _a.store, children = _a.children;
    return React.createElement(react_redux_1.Provider, { store: store }, children);
};
exports.ReduxProvider = ReduxProvider;
/**
 * Wraps useDispatch from react-redux
 *
 * @since 0.14
 */
function useReduxDispatch() {
    return (0, react_redux_1.useDispatch)();
}
exports.useReduxDispatch = useReduxDispatch;
/**
 * Fetches the requested sub-section of the application state
 *
 * @since 0.14
 */
function useAppState(selector, equalityFn) {
    return (0, react_redux_1.useSelector)(selector, equalityFn);
}
exports.useAppState = useAppState;
/**
 * @since 0.14
 */
var MapProviderContextProvider = function (_a) {
    var value = _a.value, children = _a.children;
    return React.createElement(MapProviderContext.Provider, { value: value }, children);
};
exports.MapProviderContextProvider = MapProviderContextProvider;
/**
 * Obtains the current map provider context, which provides imperative access to the current map
 *
 * @since 0.14
 */
function useMapProviderContext() {
    return React.useContext(MapProviderContext);
}
exports.useMapProviderContext = useMapProviderContext;
/**
 * @since 0.14
 */
var MapContextProvider = function (_a) {
    var value = _a.value, store = _a.store, children = _a.children;
    var inner = children;
    if (store) {
        inner = React.createElement(exports.ReduxProvider, { store: store }, children);
    }
    return React.createElement(exports.MapProviderContextProvider, { value: value }, inner);
};
exports.MapContextProvider = MapContextProvider;
//# sourceMappingURL=context.js.map