import React, { useMemo, useRef } from "react";
import { useMap } from "react-map-gl";
import { MapInitialViewContext } from "../contexts/map-initial-view.context.js";
const DEFAULT_CENTER = { lat: 0, lng: 0 };
const MapInitialViewProvider = ({
  children
}) => {
  const { current: map } = useMap();
  const boundaries = useRef(map?.getCenter() ?? DEFAULT_CENTER);
  const zoom = useRef(map?.getZoom()).current;
  const { lng: longitude, lat: latitude } = boundaries.current;
  return /* @__PURE__ */ React.createElement(
    MapInitialViewContext.Provider,
    {
      value: useMemo(
        () => ({ latitude, longitude, zoom }),
        [latitude, longitude, zoom]
      )
    },
    children
  );
};
export {
  MapInitialViewProvider
};
//# sourceMappingURL=map-initial-view.provider.js.map
