import { useEffect, useMemo } from 'react';
import { MapsContext } from '@pega/cosmos-react-core';
export const MAPS_STORAGE_KEY = 'Storybook_Google_Api_Key';
const Provider = ({ children, apiKey }) => {
    const ctx = useMemo(() => ({
        name: 'google',
        apiKey: window.sessionStorage.getItem(MAPS_STORAGE_KEY) ?? undefined
    }), []);
    useEffect(() => {
        if (apiKey && window.sessionStorage.getItem(MAPS_STORAGE_KEY) !== apiKey) {
            window.sessionStorage.setItem(MAPS_STORAGE_KEY, apiKey);
            window.location.reload();
        }
        else {
            window.sessionStorage.removeItem(MAPS_STORAGE_KEY);
        }
    }, [apiKey]);
    return <MapsContext.Provider value={ctx}>{children}</MapsContext.Provider>;
};
export default Provider;
//# sourceMappingURL=MapsProvider.mock.jsx.map