"use strict";

exports.__esModule = true;
exports.LimitAnnotations = LimitAnnotations;
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _core = require("@blueprintjs/core");
var _tgUseLocalStorageState = _interopRequireDefault(require("tg-use-local-storage-state"));
var _excluded = ["type"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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); }
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; }
var useAnnotationLimits = function useAnnotationLimits() {
  return (0, _tgUseLocalStorageState["default"])("annotationLimits", {
    defaultValue: {
      features: 50,
      parts: 50,
      primers: 50,
      warnings: 50,
      assemblyPieces: 50,
      lineageAnnotations: 50,
      cutsites: 100
    }
  });
};
var _default = useAnnotationLimits;
exports["default"] = _default;
function LimitAnnotations(_ref) {
  var type = _ref.type,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var _useAnnotationLimits = useAnnotationLimits(),
    _useAnnotationLimits$ = _useAnnotationLimits[0],
    limits = _useAnnotationLimits$ === void 0 ? {} : _useAnnotationLimits$,
    setLimits = _useAnnotationLimits[1];
  return /*#__PURE__*/_react["default"].createElement(_core.MenuItem, _extends({
    icon: "blank",
    shouldDismissPopover: false
  }, rest), [50, 100, 200, 400].map(function (n) {
    return /*#__PURE__*/_react["default"].createElement(_core.MenuItem, {
      shouldDismissPopover: false,
      icon: (!limits[type] ? n === 50 //if this hasn't been set yet, default it here
      : limits[type] === n) ? "small-tick" : "blank",
      key: n,
      text: n,
      onClick: function onClick() {
        var _extends2;
        return setLimits(_extends({}, limits, (_extends2 = {}, _extends2[type] = n, _extends2)));
      }
    });
  }));
}