"use strict";

exports.__esModule = true;
exports.ZoomCircularViewSlider = ZoomCircularViewSlider;
var _react = _interopRequireDefault(require("react"));
var _constants = require("../constants/constants");
var _UncontrolledSliderWithPlusMinusBtns = _interopRequireDefault(require("../helperComponents/UncontrolledSliderWithPlusMinusBtns"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function ZoomCircularViewSlider(_ref) {
  var zoomHelper = _ref.zoomHelper,
    zoomLevel = _ref.zoomLevel,
    setZoomLevel = _ref.setZoomLevel,
    maxZoomLevel = _ref.maxZoomLevel,
    onZoom = _ref.onZoom,
    smallSlider = _ref.smallSlider;
  var clickStepSize = (maxZoomLevel - 1) / 440;
  clickStepSize = clickStepSize * Math.max(1, Math.log(zoomLevel + 2));
  clickStepSize = Math.round(clickStepSize * 1000) / 1000;
  var stepSize = clickStepSize;
  var min = 1;
  function setZoom(val) {
    var newZoomLev = val;
    setZoomLevel(newZoomLev);
    onZoom(newZoomLev);
  }
  if (zoomLevel > maxZoomLevel) {
    setTimeout(function () {
      if (zoomHelper.current && zoomHelper.current.triggerChange) {
        zoomHelper.current.triggerChange(function (_ref2) {
          var changeValue = _ref2.changeValue;
          changeValue(maxZoomLevel);
        });
      }
    }, 0);
  }
  return /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      position: "absolute",
      left: smallSlider ? 100 : 150,
      top: 0,
      zIndex: 900
    }
  }, /*#__PURE__*/_react["default"].createElement(_UncontrolledSliderWithPlusMinusBtns["default"], {
    bindOutsideChangeHelper: zoomHelper.current,
    onChange: setZoom,
    onRelease: setZoom,
    title: "Adjust Zoom Level",
    style: {
      paddingTop: "4px",
      width: smallSlider ? _constants.SLIDER_SMALL_WIDTH : _constants.SLIDER_NORM_WIDTH
    },
    smallSlider: true,
    noWraparound: true,
    className: "veZoomCircularSlider ove-slider",
    labelRenderer: false,
    stepSize: stepSize,
    clickStepSize: clickStepSize,
    initialValue: zoomLevel || 1,
    justUpdateInitialValOnce: true,
    max: maxZoomLevel || 14,
    min: min
  }));
}