"use strict";

exports.__esModule = true;
exports["default"] = Feature;
var _lodash = require("lodash");
var _react = _interopRequireDefault(require("react"));
var _drawDirectedPiePiece2 = _interopRequireDefault(require("./drawDirectedPiePiece"));
var _getInternalLabel = require("./getInternalLabel");
var _shouldFlipText = _interopRequireDefault(require("./shouldFlipText"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function Feature(props) {
  var _props$color = props.color,
    color = _props$color === void 0 ? "orange" : _props$color,
    radius = props.radius,
    containsLocations = props.containsLocations,
    _props$arrowheadLengt = props.arrowheadLength,
    arrowheadLength = _props$arrowheadLengt === void 0 ? 0.5 : _props$arrowheadLengt,
    annotationHeight = props.annotationHeight,
    className = props.className,
    ellipsizedName = props.ellipsizedName,
    annotationType = props.annotationType,
    arrowheadType = props.arrowheadType,
    overlapsSelf = props.overlapsSelf,
    rotationRadians = props.rotationRadians,
    centerAngle = props.centerAngle,
    totalAngle = props.totalAngle,
    locationNumber = props.locationNumber;
  var isPart = annotationType === "part";
  var colorToUse = color;
  if (isPart) {
    colorToUse = (0, _lodash.startsWith)(color, "override_") ? color.replace("override_", "") : "#ac68cc";
  }
  var labelNeedsFlip = (0, _shouldFlipText["default"])(centerAngle + rotationRadians);
  if (containsLocations) {
    var _path = (0, _drawDirectedPiePiece2["default"])({
      radius: radius,
      labelNeedsFlip: labelNeedsFlip,
      annotationHeight: annotationHeight / 8,
      totalAngle: totalAngle,
      arrowheadLength: 80 / radius,
      tailThickness: 1 //feature specific
    });

    return /*#__PURE__*/_react["default"].createElement("path", {
      className: className,
      strokeWidth: ".5",
      stroke: "black",
      fill: colorToUse,
      d: _path.print()
    });
  }
  var _drawDirectedPiePiece = (0, _drawDirectedPiePiece2["default"])({
      returnTextPath: true,
      overlapsSelf: overlapsSelf,
      arrowheadType: arrowheadType,
      hasLabel: ellipsizedName,
      labelNeedsFlip: labelNeedsFlip,
      radius: radius,
      annotationHeight: annotationHeight,
      totalAngle: totalAngle,
      arrowheadLength: arrowheadLength,
      tailThickness: 1 //feature specific
    }),
    path = _drawDirectedPiePiece[0],
    textPath = _drawDirectedPiePiece[1];
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("path", {
    className: className,
    strokeWidth: ".5",
    stroke: isPart ? colorToUse : "black",
    fill: isPart ? undefined : colorToUse,
    d: path.print()
  }), (0, _getInternalLabel.getInternalLabel)(_extends({}, props, {
    colorToUse: colorToUse,
    textPath: textPath,
    isPart: isPart,
    locationNumber: locationNumber
  })));
}
module.exports = exports.default;