text: "use strict";
  
  function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  
  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  exports.DrawEllipseUsingThreePointsHandler = void 0;
  
  var _distance = _interopRequireDefault(require("@turf/distance"));
  
  var _ellipse = _interopRequireDefault(require("@turf/ellipse"));
  
  var _bearing = _interopRequireDefault(require("@turf/bearing"));
  
  var _helpers = require("@turf/helpers");
  
  var _modeHandler = require("./mode-handler");
  
  var _threeClickPolygonHandler = require("./three-click-polygon-handler");
  
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
  
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
  
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  
  function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
  
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
  
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  
  function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  
  function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  
  function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  
  // TODO edit-modes: delete handlers once EditMode fully implemented
  var DrawEllipseUsingThreePointsHandler = /*#__PURE__*/function (_ThreeClickPolygonHan) {
    _inherits(DrawEllipseUsingThreePointsHandler, _ThreeClickPolygonHan);
  
    var _super = _createSuper(DrawEllipseUsingThreePointsHandler);
  
    function DrawEllipseUsingThreePointsHandler() {
      _classCallCheck(this, DrawEllipseUsingThreePointsHandler);
  
      return _super.apply(this, arguments);
    }
  
    _createClass(DrawEllipseUsingThreePointsHandler, [{
      key: "handlePointerMove",
      value: function handlePointerMove(event) {
        var result = {
          editAction: null,
          cancelMapPan: false
        };
        var clickSequence = this.getClickSequence();
  
        if (clickSequence.length === 0) {
          // nothing to do yet
          return result;
        }
  
        var groundCoords = event.groundCoords;
  
        if (clickSequence.length === 1) {
          this._setTentativeFeature({
            type: 'Feature',
            geometry: {
              type: 'LineString',
              coordinates: [clickSequence[0], groundCoords]
            }
          });
        } else if (clickSequence.length === 2) {
          var _clickSequence = _slicedToArray(clickSequence, 2),
              p1 = _clickSequence[0],
              p2 = _clickSequence[1];
  
          var centerCoordinates = (0, _modeHandler.getIntermediatePosition)(p1, p2);
          var xSemiAxis = Math.max((0, _distance["default"])(centerCoordinates, (0, _helpers.point)(groundCoords)), 0.001);
          var ySemiAxis = Math.max((0, _distance["default"])(p1, p2), 0.001) / 2;
          var options = {
            angle: (0, _bearing["default"])(p1, p2)
          }; // @ts-ignore
  
          this._setTentativeFeature((0, _ellipse["default"])(centerCoordinates, xSemiAxis, ySemiAxis, options));
        }
  
        return result;
      }
    }]);
  
    return DrawEllipseUsingThreePointsHandler;
  }(_threeClickPolygonHandler.ThreeClickPolygonHandler);
  
  exports.DrawEllipseUsingThreePointsHandler = DrawEllipseUsingThreePointsHandler;
  //# sourceMappingURL=data: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