import getAnnotationNameAndStartStopString from "../utils/getAnnotationNameAndStartStopString";
import React from "react";
import orfFrameToColorMap from "../constants/orfFrameToColorMap";
function Orf(props) {
  var height = props.height,
    rangeType = props.rangeType,
    _props$normalizedInte = props.normalizedInternalStartCodonIndices,
    normalizedInternalStartCodonIndices = _props$normalizedInte === void 0 ? [] : _props$normalizedInte,
    forward = props.forward,
    _props$frame = props.frame,
    frame = _props$frame === void 0 ? 0 : _props$frame,
    annotation = props.annotation,
    width = props.width,
    _onClick = props.onClick,
    isProtein = props.isProtein,
    onRightClick = props.onRightClick,
    charWidth = props.charWidth,
    readOnly = props.readOnly,
    gapsInside = props.gapsInside,
    gapsBefore = props.gapsBefore;
  var heightToUse = height / 1.5;
  var color = orfFrameToColorMap[frame];
  var arrow = null;
  var endCircle = null;
  var circle = /*#__PURE__*/React.createElement("circle", {
    key: "circle",
    r: heightToUse / 2,
    cx: heightToUse / 2,
    cy: heightToUse / 2
  });
  if (rangeType === "end" || rangeType === "beginningAndEnd") {
    arrow = /*#__PURE__*/React.createElement("path", {
      transform: "translate(" + (width + gapsInside - Math.max(charWidth, 5)) + ",0) scale(" + Math.max(charWidth, 8) / 64 + "," + heightToUse / 64 + ")",
      d: rangeType === "start" ? "M0 16 L0 48 L16 64 L48 64 L64 48 L64 16 L48 0 L16 0 Z" : "M0 64 L64 32 L0 0 Z"
    });
  }
  if (rangeType === "start" || rangeType === "beginningAndEnd") {
    endCircle = circle;
  }
  var internalStartCodonCircles = normalizedInternalStartCodonIndices.map(function (internalStartCodon, index) {
    return React.cloneElement(circle, {
      key: index,
      transform: "translate(" + charWidth * internalStartCodon + ",0)"
    });
  });
  return /*#__PURE__*/React.createElement("g", {
    onClick: function onClick(event) {
      _onClick({
        annotation: annotation,
        event: event,
        gapsInside: gapsInside,
        gapsBefore: gapsBefore
      });
    },
    onContextMenu: function onContextMenu(event) {
      onRightClick({
        annotation: annotation,
        event: event,
        gapsInside: gapsInside,
        gapsBefore: gapsBefore
      });
    },
    className: "veRowViewOrf clickable frame" + frame,
    strokeWidth: "1",
    stroke: color,
    fillOpacity: 1,
    fill: color,
    transform: forward ? null : "translate(" + (width + gapsInside) + ",0) scale(-1,1)"
  }, /*#__PURE__*/React.createElement("path", {
    transform: (rangeType === "start" ? "translate(" + charWidth + ",0)" : "") + ("scale(" + (width + gapsInside - (rangeType === "middle" ? 0 : charWidth)) / 64 + "," + heightToUse / 64 + ")"),
    d: "M0 40 L64 40 L64 20 L0 20 Z"
  }), arrow, endCircle, internalStartCodonCircles, /*#__PURE__*/React.createElement("title", null, " ", getAnnotationNameAndStartStopString(annotation, {
    startText: "Open Reading Frame:",
    isProtein: isProtein,
    readOnly: readOnly
  }), " "));
}

// Orf.propTypes = {
//   width: PropTypes.number.isRequired,
//   charWidth: PropTypes.number.isRequired,
//   frame: PropTypes.number.isRequired,
//   height: PropTypes.number.isRequired,
//   rangeType: PropTypes.string.isRequired,
//   forward: PropTypes.bool.isRequired
// };

export default Orf;