var _excluded = ["editorName", "toggleDropdown", "annotationVisibilityShow", "withDigestTool", "createNewDigest"];
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
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 { Icon, Button, KeyCombo } from "@blueprintjs/core";
import CutsiteFilter from "../CutsiteFilter";
import React from "react";
import ToolbarItem from "./ToolbarItem";
import { connectToEditor } from "../withEditorProps";
import { userDefinedHandlersAndOpts } from "../Editor/userDefinedHandlersAndOpts";
import { pick } from "lodash";
export default connectToEditor(function (_ref) {
  var readOnly = _ref.readOnly,
    _ref$annotationVisibi = _ref.annotationVisibility,
    annotationVisibility = _ref$annotationVisibi === void 0 ? {} : _ref$annotationVisibi,
    _ref$toolBar = _ref.toolBar,
    toolBar = _ref$toolBar === void 0 ? {} : _ref$toolBar;
  return {
    readOnly: readOnly,
    toggled: annotationVisibility.cutsites,
    isOpen: toolBar.openItem === "cutsiteTool"
  };
})(function (_ref2) {
  var toolbarItemProps = _ref2.toolbarItemProps,
    toggled = _ref2.toggled,
    isOpen = _ref2.isOpen,
    annotationVisibilityToggle = _ref2.annotationVisibilityToggle;
  return /*#__PURE__*/React.createElement(ToolbarItem, _extends({
    Icon: /*#__PURE__*/React.createElement(Icon, {
      "data-test": "cutsiteHideShowTool",
      icon: "cut"
    }),
    onIconClick: function onIconClick() {
      annotationVisibilityToggle("cutsites");
    },
    toggled: toggled,
    tooltip: "显示酶切位点",
    tooltipToggled: "隐藏酶切位点",
    Dropdown: CutsiteToolDropDown,
    dropdowntooltip: (!isOpen ? "显示" : "隐藏") + "酶切位点选项"
  }, toolbarItemProps));
});
// import show_cut_sites_img from "./veToolbarIcons/show_cut_sites.png";

// function CutsiteToolIcon({ annotationVisibilityToggle }) {
//   return (
//     <div
//       onClick={function() {
//         annotationVisibilityToggle("cutsites");
//       }}
//     >
//       <img src={show_cut_sites_img} alt="Show cut sites" />
//     </div>
//   );
// }

function CutsiteToolDropDown(_ref3) {
  var editorName = _ref3.editorName,
    toggleDropdown = _ref3.toggleDropdown,
    annotationVisibilityShow = _ref3.annotationVisibilityShow,
    withDigestTool = _ref3.withDigestTool,
    createNewDigest = _ref3.createNewDigest,
    rest = _objectWithoutPropertiesLoose(_ref3, _excluded);
  return /*#__PURE__*/React.createElement("div", {
    className: "veToolbarCutsiteFilterHolder"
  }, /*#__PURE__*/React.createElement("h6", null, "\u8FC7\u6EE4\u9176\u5207\u4F4D\u70B9", " ", /*#__PURE__*/React.createElement("span", {
    style: {
      fontSize: 12,
      color: "grey"
    }
  }, "(\u6309\u540D\u79F0\u6216\u526A\u8F91\u6570\u91CF\u641C\u7D22)")), /*#__PURE__*/React.createElement(CutsiteFilter, _extends({}, pick(rest, userDefinedHandlersAndOpts), {
    editorName: editorName,
    onChangeHook: function onChangeHook() {
      annotationVisibilityShow("cutsites");
    },
    closeDropDown: toggleDropdown
  })), withDigestTool && /*#__PURE__*/React.createElement(Button, {
    onClick: function onClick() {
      createNewDigest();
      toggleDropdown();
    }
  }, /*#__PURE__*/React.createElement("span", {
    style: {
      display: "flex"
    }
  }, "Virtual Digest \xA0 ", /*#__PURE__*/React.createElement(KeyCombo, {
    minimal: true,
    combo: "mod+shift+d"
  }))));
}