import { useContext } from 'react';
import { isNil } from 'lodash';
import { TIMELINE_ACTIONS } from '../context/types';
import { TimelineContext } from '../context';
export function useTimelineZoom() {
  var _useContext = useContext(TimelineContext),
    dispatch = _useContext.dispatch,
    _useContext$state = _useContext.state,
    currentScaleIndex = _useContext$state.currentScaleIndex,
    scaleOptions = _useContext$state.scaleOptions;
  var canZoomIn = !isNil(currentScaleIndex) && currentScaleIndex > 0;
  var canZoomOut = !isNil(currentScaleIndex) && currentScaleIndex < scaleOptions.length - 1;
  function zoomIn() {
    dispatch({
      getScaleIndex: function getScaleIndex(scaleIndex) {
        return scaleIndex - 1;
      },
      type: TIMELINE_ACTIONS.SCALE
    });
  }
  function zoomOut() {
    dispatch({
      getScaleIndex: function getScaleIndex(scaleIndex) {
        return scaleIndex + 1;
      },
      type: TIMELINE_ACTIONS.SCALE
    });
  }
  return {
    canZoomIn: canZoomIn,
    canZoomOut: canZoomOut,
    zoomIn: zoomIn,
    zoomOut: zoomOut
  };
}