'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isOfMetaType = isOfMetaType;
exports.isShiftMousedown = isShiftMousedown;
exports.isActiveFeature = isActiveFeature;
exports.isInactiveFeature = isInactiveFeature;
exports.noTarget = noTarget;
exports.isFeature = isFeature;
exports.isVertex = isVertex;
exports.isMidPoint = isMidPoint;
exports.isShiftDown = isShiftDown;
exports.isEscapeKey = isEscapeKey;
exports.isEnterKey = isEnterKey;
exports.isDeleteKey = isDeleteKey;
exports.isTrue = isTrue;

var _constants = require('../constants');

var _constants2 = _interopRequireDefault(_constants);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

function isOfMetaType(type) {
  return function (e) {
    var featureTarget = e.featureTarget;
    if (!featureTarget) return false;
    if (!featureTarget.properties) return false;
    return featureTarget.properties['draw:meta'] === type;
  };
} /**
   * @文件说明: 定义绘图的选中交互的函数方法
   * @创建人: pjtools@vip.qq.com
   * @创建时间: 2020-05-28 19:10:56
   */

function isShiftMousedown(e) {
  if (!e.originalEvent) return false;
  if (!e.originalEvent.shiftKey) return false;
  return e.originalEvent.button === 0;
}

function isActiveFeature(e) {
  if (!e.featureTarget) return false;
  if (!e.featureTarget.properties) return false;
  return e.featureTarget.properties['draw:active'] === _constants2['default'].activeStates.ACTIVE && e.featureTarget.properties['draw:meta'] === _constants2['default'].meta.FEATURE;
}

function isInactiveFeature(e) {
  if (!e.featureTarget) return false;
  if (!e.featureTarget.properties) return false;
  return e.featureTarget.properties['draw:active'] === _constants2['default'].activeStates.INACTIVE && e.featureTarget.properties['draw:meta'] === _constants2['default'].meta.FEATURE;
}

function noTarget(e) {
  return e.featureTarget === undefined;
}

function isFeature(e) {
  if (!e.featureTarget) return false;
  if (!e.featureTarget.properties) return false;
  return e.featureTarget.properties['draw:meta'] === _constants2['default'].meta.FEATURE;
}

function isVertex(e) {
  var featureTarget = e.featureTarget;
  if (!featureTarget) return false;
  if (!featureTarget.properties) return false;
  return featureTarget.properties['draw:meta'] === _constants2['default'].meta.VERTEX;
}

function isMidPoint(e) {
  var featureTarget = e.featureTarget;
  if (!featureTarget) return false;
  if (!featureTarget.properties) return false;
  return featureTarget.properties['draw:meta'] === _constants2['default'].meta.MIDPOINT;
}

function isShiftDown(e) {
  if (!e.originalEvent) return false;
  return e.originalEvent.shiftKey === true;
}

// ESC键
function isEscapeKey(e) {
  return e.keyCode === 27;
}

// Enter键
function isEnterKey(e) {
  return e.keyCode === 13;
}

// Delete键
function isDeleteKey(e) {
  return e.keyCode === 46;
}

function isTrue() {
  return true;
}