"use strict";

exports.__esModule = true;
exports["default"] = MeltingTemp;
var _react = _interopRequireDefault(require("react"));
var _core = require("@blueprintjs/core");
var _sequenceUtils = require("@teselagen/sequence-utils");
var _lodash = require("lodash");
var _teselagenReactComponents = require("teselagen-react-components");
var _useTmType2 = _interopRequireDefault(require("../utils/useTmType"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function MeltingTemp(_ref) {
  var sequence = _ref.sequence,
    _ref$WrapperToUse = _ref.WrapperToUse,
    WrapperToUse = _ref$WrapperToUse === void 0 ? function (p) {
      return /*#__PURE__*/_react["default"].createElement("div", null, p.children);
    } : _ref$WrapperToUse,
    _ref$InnerWrapper = _ref.InnerWrapper,
    InnerWrapper = _ref$InnerWrapper === void 0 ? function (p) {
      return /*#__PURE__*/_react["default"].createElement(_core.Button, {
        minimal: true,
        small: true
      }, p.children);
    } : _ref$InnerWrapper;
  var _useTmType = (0, _useTmType2["default"])(),
    tmType = _useTmType[0],
    setTmType = _useTmType[1];
  var tm = ({
    "default": _sequenceUtils.calculateTm,
    neb_tm: _sequenceUtils.calculateNebTm
  }[tmType] || _sequenceUtils.calculateTm)((sequence || "").toLowerCase());
  var hasWarning = (0, _lodash.isString)(tm) && tm.length > 7 && tm;
  return /*#__PURE__*/_react["default"].createElement(WrapperToUse, {
    dataTest: "veStatusBar-selection-tm"
  }, /*#__PURE__*/_react["default"].createElement(_core.Popover, {
    modifiers: _teselagenReactComponents.popoverOverflowModifiers,
    content: /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        maxWidth: 300,
        padding: 20
      }
    }, "\u4F7F\u7528\u57FA\u4E8E\u8FD9\u4E9B\u7684Tm\u8BA1\u7B97", " ", /*#__PURE__*/_react["default"].createElement("a", {
      rel: "noopener noreferrer",
      target: "_blank",
      href: "https://github.com/TeselaGen/@teselagen/sequence-utils"
    }, "\u7B97\u6CD5"), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_core.RadioGroup, {
      label: "\u9009\u62E9Tm\u7C7B\u578B:",
      options: [{
        value: "default",
        label: "默认Tm"
      }, {
        value: "neb_tm",
        label: "NEB Tm"
      }],
      onChange: function onChange(e) {
        return setTmType(e.target.value);
      },
      selectedValue: tmType
    }), hasWarning && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_core.Icon, {
      style: {
        marginLeft: 5,
        marginRight: 5
      },
      size: 10,
      icon: "warning-sign"
    }), hasWarning, /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement("br", null), "\u5C1D\u8BD5\u4F7F\u7528\u9ED8\u8BA4Tm"))
  }, /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(InnerWrapper, null, "Tm\u503C: ", Number(tm) || 0, " "), hasWarning && /*#__PURE__*/_react["default"].createElement(_core.Icon, {
    style: {
      marginLeft: 5,
      marginRight: 5
    },
    size: 10,
    icon: "warning-sign"
  }))));
}
module.exports = exports.default;