import React, { useRef } from "react";
import { useIntl } from "react-intl";
import { useMap } from "react-map-gl/maplibre";
import { _ChartToolbarRenderer as ChartToolbarRenderer } from "@dynatrace/strato-components-preview/charts";
import { ResetIcon } from "@dynatrace/strato-icons";
import { useInitialViewContext } from "../../../hooks/use-initial-view-context.js";
import { TOOLBAR_MESSAGES } from "../constants.js";
import { useA11yToolbarTabIndex } from "../hooks/use-a11y-toolbar-tab-index.js";
const MapResetButton = () => {
  const { current: map } = useMap();
  const { longitude = 0, latitude = 0, zoom = 0 } = useInitialViewContext();
  const intl = useIntl();
  const resetButtonRef = useRef();
  const tabIndex = useA11yToolbarTabIndex("reset");
  const handleReset = () => {
    map?.flyTo({ center: [longitude, latitude], zoom });
  };
  const handleKeyDown = (event) => {
    if (event.code === "Enter") {
      handleReset();
    }
  };
  return /* @__PURE__ */ React.createElement(
    ChartToolbarRenderer.Control,
    {
      ref: resetButtonRef,
      prefixIcon: /* @__PURE__ */ React.createElement(ResetIcon, null),
      tooltipText: intl.formatMessage(TOOLBAR_MESSAGES.zoomActionReset),
      testId: "map-toolbar-reset",
      onKeyDown: handleKeyDown,
      onClick: handleReset,
      tabIndex
    }
  );
};
export {
  MapResetButton
};
//# sourceMappingURL=MapResetButton.js.map
