var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var store_exports = {};
__export(store_exports, {
  useSetState: () => useSetState,
  useSetStateOverlay: () => useSetStateOverlay,
  useSetStateSelection: () => useSetStateSelection,
  useSetStateTooltip: () => useSetStateTooltip,
  useToggleStatePinnedTooltip: () => useToggleStatePinnedTooltip
});
module.exports = __toCommonJS(store_exports);
var import_react = require("react");
var import_map_store_context = require("./map-store.context.js");
__reExport(store_exports, require("./selectors.js"), module.exports);
const useSetState = () => {
  const { setState } = (0, import_react.useContext)(import_map_store_context.MapStore);
  return setState;
};
const useSetStateSelection = () => {
  const setState = useSetState();
  return (newSelectionState) => {
    setState((prev) => ({
      ...prev,
      selection: {
        ...prev.selection,
        ...newSelectionState
      }
    }));
  };
};
const useSetStateTooltip = () => {
  const setState = useSetState();
  return (newTooltipState) => {
    setState((prev) => ({
      ...prev,
      tooltip: {
        ...prev.tooltip,
        ...newTooltipState
      }
    }));
  };
};
const useSetStateOverlay = () => {
  const setState = useSetState();
  return (newOverlayState) => {
    setState((prev) => ({
      ...prev,
      overlay: {
        ...prev.overlay,
        ...newOverlayState
      }
    }));
  };
};
const useToggleStatePinnedTooltip = () => {
  const setState = useSetState();
  return () => {
    setState((prev) => {
      if (prev.tooltip.visible || prev.tooltip.pinned) {
        return {
          ...prev,
          tooltip: {
            ...prev.tooltip,
            pinned: !prev.tooltip.pinned
          }
        };
      }
      return { ...prev };
    });
  };
};
