var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var MapToolbar_exports = {};
__export(MapToolbar_exports, {
  MapToolbar: () => MapToolbar
});
module.exports = __toCommonJS(MapToolbar_exports);
var import_react = __toESM(require("react"));
var import_charts = require("@dynatrace/strato-components-preview/charts");
var import_MapDownloadDataButton = require("./buttons/MapDownloadDataButton.js");
var import_MapResetButton = require("./buttons/MapResetButton.js");
var import_MapZoomInOutButtons = require("./buttons/MapZoomInOutButtons.js");
var import_MapZoomToFitButton = require("./buttons/MapZoomToFitButton.js");
var import_constants = require("./constants.js");
var import_use_map_config = require("../../hooks/use-map-config.js");
var import_map_initial_view_provider = require("../../providers/map-initial-view.provider.js");
var import_selectors = require("../../store/selectors.js");
var import_store = require("../../store/store.js");
const defaultToolbarPlacement = "top-right";
const MapToolbar = () => {
  const { toolbar: toolbarConfig, interactions: interactionsConfig } = (0, import_use_map_config.useMapConfig)();
  const { mouseInBounds } = (0, import_selectors.useMapOverlayState)();
  const setTooltipState = (0, import_store.useSetStateTooltip)();
  const isZoomEnabled = interactionsConfig?.zoom?.enabled ?? false;
  const isZoomToFitEnabled = interactionsConfig?.zoomToFit?.enabled ?? false;
  const isDownloadDataEnabled = toolbarConfig?.downloadData ?? false;
  const hasControls = isZoomEnabled || isZoomToFitEnabled || isDownloadDataEnabled;
  const handleMouseEnter = () => {
    setTooltipState({
      enabled: false
    });
  };
  const handleMouseLeave = () => {
    setTooltipState({
      enabled: true
    });
  };
  return hasControls ? /* @__PURE__ */ import_react.default.createElement(import_map_initial_view_provider.MapInitialViewProvider, null, /* @__PURE__ */ import_react.default.createElement(
    import_charts._ChartToolbarRenderer,
    {
      visible: mouseInBounds,
      collapsed: toolbarConfig?.collapsed,
      draggable: toolbarConfig?.draggable,
      placement: toolbarConfig?.placement ?? defaultToolbarPlacement,
      initialA11yState: import_constants.initialA11yToolbarTabIndexContext,
      onMouseEnter: handleMouseEnter,
      onMouseLeave: handleMouseLeave
    },
    isZoomEnabled && /* @__PURE__ */ import_react.default.createElement(import_MapZoomInOutButtons.MapZoomInOutButtons, null),
    isZoomEnabled && /* @__PURE__ */ import_react.default.createElement(import_MapResetButton.MapResetButton, null),
    isZoomToFitEnabled && /* @__PURE__ */ import_react.default.createElement(import_MapZoomToFitButton.MapZoomToFitButton, null),
    isDownloadDataEnabled && /* @__PURE__ */ import_react.default.createElement(import_MapDownloadDataButton.MapDownloadDataButton, null)
  )) : null;
};
MapToolbar["displayName"] = "MapToolbar";
