import { Button, Popover, Intent, Tooltip, Tag, Menu, MenuItem } from "@blueprintjs/core";
import React from "react";
import { map, startCase } from "lodash";
import pureNoFunc from "../utils/pureNoFunc";
// import { fullSequenceTranslationMenu } from "../MenuBar/viewSubmenu";

export default pureNoFunc(function AlignmentVisibilityTool(props) {
  return /*#__PURE__*/React.createElement(Popover, {
    minimal: true,
    position: "bottom",
    content: /*#__PURE__*/React.createElement(VisibilityOptions, props),
    target: /*#__PURE__*/React.createElement(Tooltip, {
      content: "Visibility Options"
    }, /*#__PURE__*/React.createElement(Button, {
      className: "tg-alignment-visibility-toggle",
      small: true,
      rightIcon: "caret-down",
      intent: Intent.PRIMARY,
      minimal: true,
      icon: "eye-open"
    }))
  });
});
function VisibilityOptions(_ref) {
  var alignmentAnnotationVisibilityToggle = _ref.alignmentAnnotationVisibilityToggle,
    _ref$togglableAlignme = _ref.togglableAlignmentAnnotationSettings,
    togglableAlignmentAnnotationSettings = _ref$togglableAlignme === void 0 ? {} : _ref$togglableAlignme,
    annotationsWithCounts = _ref.annotationsWithCounts,
    currentPairwiseAlignmentIndex = _ref.currentPairwiseAlignmentIndex;
  var annotationCountToUse = {};
  if (currentPairwiseAlignmentIndex) {
    annotationCountToUse = annotationsWithCounts[currentPairwiseAlignmentIndex];
  } else {
    annotationCountToUse = annotationsWithCounts[0];
  }
  return /*#__PURE__*/React.createElement(Menu, {
    style: {
      padding: 10
    },
    className: "alignmentAnnotationVisibilityToolInner"
  }, map(togglableAlignmentAnnotationSettings, function (visible, annotationName) {
    return /*#__PURE__*/React.createElement(MenuItem, {
      icon: visible ? "tick" : "",
      onClick: function onClick(e) {
        var _alignmentAnnotationV;
        e.stopPropagation();
        if (annotationName === "axis") {
          return alignmentAnnotationVisibilityToggle({
            axisNumbers: !visible,
            axis: !visible
          });
        }
        if (annotationName === "cdsFeatureTranslations" && !visible) {
          return alignmentAnnotationVisibilityToggle({
            cdsFeatureTranslations: !visible,
            translations: !visible
          });
        }
        alignmentAnnotationVisibilityToggle((_alignmentAnnotationV = {}, _alignmentAnnotationV[annotationName] = !visible, _alignmentAnnotationV));
      },
      text: /*#__PURE__*/React.createElement(React.Fragment, null, startCase(annotationName).replace("Cds", "CDS").replace("Dna", "DNA"), annotationName in annotationCountToUse ? /*#__PURE__*/React.createElement(Tag, {
        round: true,
        style: {
          marginLeft: 7
        }
      }, annotationCountToUse[annotationName]) : ""),
      key: annotationName
    });
  }));
}