import MapContext from "./MapContext.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect, useRef, useState } from "react";
import { makeStyles } from "@material-ui/core";
import * as ol from "ol";
import { DragRotateAndZoom, defaults } from "ol/interaction";
import "./Map.css";
//#region src/maps/openLayerMaps/Map/Map.jsx
const useStyles = makeStyles((theme) => ({ root: {
	minWidth: 600,
	height: "85vh"
} }));
const Map = (t0) => {
	const $ = c(26);
	const { children, zoom, projection } = t0;
	const classes = useStyles();
	const mapRef = useRef();
	const [map, setMap] = useState(null);
	let t1;
	if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
		t1 = [-73.975535, 40.691783];
		$[0] = t1;
	} else t1 = $[0];
	const center = t1;
	let t2;
	if ($[1] !== projection || $[2] !== zoom) {
		t2 = () => {
			const options = {
				view: new ol.View({
					zoom,
					center,
					projection
				}),
				interactions: defaults().extend([new DragRotateAndZoom()]),
				layers: [],
				controls: [],
				overlays: []
			};
			const mapObject = new ol.Map(options);
			mapObject.setTarget(mapRef.current);
			setMap(mapObject);
			return () => mapObject.setTarget(void 0);
		};
		$[1] = projection;
		$[2] = zoom;
		$[3] = t2;
	} else t2 = $[3];
	let t3;
	if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
		t3 = [];
		$[4] = t3;
	} else t3 = $[4];
	useEffect(t2, t3);
	let t4;
	if ($[5] !== map || $[6] !== zoom) {
		t4 = () => {
			if (!map) return;
			map.getView().setZoom(zoom);
		};
		$[5] = map;
		$[6] = zoom;
		$[7] = t4;
	} else t4 = $[7];
	let t5;
	if ($[8] !== zoom) {
		t5 = [zoom];
		$[8] = zoom;
		$[9] = t5;
	} else t5 = $[9];
	useEffect(t4, t5);
	let t6;
	if ($[10] !== map) {
		t6 = () => {
			if (!map) return;
			map.getView().setCenter(center);
		};
		$[10] = map;
		$[11] = t6;
	} else t6 = $[11];
	let t7;
	if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
		t7 = [center];
		$[12] = t7;
	} else t7 = $[12];
	useEffect(t6, t7);
	let t8;
	if ($[13] !== map || $[14] !== projection) {
		t8 = () => {
			if (!map) return;
			map.getview().getprojection(projection);
		};
		$[13] = map;
		$[14] = projection;
		$[15] = t8;
	} else t8 = $[15];
	let t9;
	if ($[16] !== projection) {
		t9 = [projection];
		$[16] = projection;
		$[17] = t9;
	} else t9 = $[17];
	useEffect(t8, t9);
	let t10;
	if ($[18] !== map) {
		t10 = { map };
		$[18] = map;
		$[19] = t10;
	} else t10 = $[19];
	let t11;
	if ($[20] !== children || $[21] !== classes.root) {
		t11 = /* @__PURE__ */ React.createElement("div", {
			ref: mapRef,
			className: classes.root
		}, children);
		$[20] = children;
		$[21] = classes.root;
		$[22] = t11;
	} else t11 = $[22];
	let t12;
	if ($[23] !== t10 || $[24] !== t11) {
		t12 = /* @__PURE__ */ React.createElement(MapContext.Provider, { value: t10 }, t11);
		$[23] = t10;
		$[24] = t11;
		$[25] = t12;
	} else t12 = $[25];
	return t12;
};
//#endregion
export { Map as default };

//# sourceMappingURL=Map.mjs.map