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); }
import { startsWith } from "lodash";
import React from "react";
import drawDirectedPiePiece from "./drawDirectedPiePiece";
import { getInternalLabel } from "./getInternalLabel";
import shouldFlipText from "./shouldFlipText";
export default 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 = startsWith(color, "override_") ? color.replace("override_", "") : "#ac68cc";
  }
  var labelNeedsFlip = shouldFlipText(centerAngle + rotationRadians);
  if (containsLocations) {
    var _path = drawDirectedPiePiece({
      radius: radius,
      labelNeedsFlip: labelNeedsFlip,
      annotationHeight: annotationHeight / 8,
      totalAngle: totalAngle,
      arrowheadLength: 80 / radius,
      tailThickness: 1 //feature specific
    });

    return /*#__PURE__*/React.createElement("path", {
      className: className,
      strokeWidth: ".5",
      stroke: "black",
      fill: colorToUse,
      d: _path.print()
    });
  }
  var _drawDirectedPiePiece = drawDirectedPiePiece({
      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.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("path", {
    className: className,
    strokeWidth: ".5",
    stroke: isPart ? colorToUse : "black",
    fill: isPart ? undefined : colorToUse,
    d: path.print()
  }), getInternalLabel(_extends({}, props, {
    colorToUse: colorToUse,
    textPath: textPath,
    isPart: isPart,
    locationNumber: locationNumber
  })));
}