"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useCelestialControls = void 0;
var _react = require("@xyflow/react");
var _react2 = require("react");
/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * Custom hook for managing celestial view controls
 * Provides zoom and fit view functionality for the celestial map
 * @returns Object containing zoom and fit view control functions
 */
const useCelestialControls = () => {
  // Extract zoom and fit view controls from ReactFlow
  const {
    zoomIn,
    zoomOut,
    fitView
  } = (0, _react.useReactFlow)();

  /**
   * Handler for zooming in the view
   * @param e Mouse event from zoom button click
   */
  const onZoomIn = (0, _react2.useCallback)(e => {
    e.stopPropagation();
    zoomIn === null || zoomIn === void 0 || zoomIn({
      duration: 300
    });
  }, [zoomIn]);

  /**
   * Handler for zooming out the view
   * @param e Mouse event from zoom button click
   */
  const onZoomOut = (0, _react2.useCallback)(e => {
    e.stopPropagation();
    zoomOut === null || zoomOut === void 0 || zoomOut({
      duration: 300
    });
  }, [zoomOut]);

  /**
   * Handler for fitting all elements in view
   * @param e Mouse event from fit view button click
   */
  const onFitView = (0, _react2.useCallback)(e => {
    e.stopPropagation();
    fitView === null || fitView === void 0 || fitView({
      duration: 300
    }); // Animate transition over 300ms
  }, [fitView]);
  return {
    onZoomIn,
    onZoomOut,
    onFitView
  };
};
exports.useCelestialControls = useCelestialControls;