"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getSelectionMessage = getSelectionMessage;

var _veRangeUtils = require("ve-range-utils");

var _proteinUtils = require("./proteinUtils");

var _veSequenceUtils = require("ve-sequence-utils");

function getSelectionMessage(_ref) {
  var _ref$caretPosition = _ref.caretPosition,
      caretPosition = _ref$caretPosition === undefined ? -1 : _ref$caretPosition,
      _ref$selectionLayer = _ref.selectionLayer,
      selectionLayer = _ref$selectionLayer === undefined ? { start: -1, end: -1 } : _ref$selectionLayer,
      customTitle = _ref.customTitle,
      sequenceLength = _ref.sequenceLength,
      sequenceData = _ref.sequenceData,
      showGCContent = _ref.showGCContent,
      GCDecimalDigits = _ref.GCDecimalDigits,
      isProtein = _ref.isProtein;

  var isSelecting = selectionLayer.start > -1;
  if (isSelecting) {
    var length = (0, _veRangeUtils.getRangeLength)(selectionLayer, sequenceLength);
    var GCContent = function GCContent() {
      var numDecimalDigits = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
      return (0, _veSequenceUtils.calculatePercentGC)((0, _veSequenceUtils.getSequenceDataBetweenRange)(sequenceData, selectionLayer).sequence).toFixed(numDecimalDigits);
    };
    return (customTitle || "Selecting") + " " + (0, _proteinUtils.divideBy3)(length, isProtein) + " " + (isProtein ? "AAs" : "bps") + " from " + ((0, _proteinUtils.divideBy3)(selectionLayer.start, isProtein) + 1) + " to " + (0, _proteinUtils.divideBy3)(selectionLayer.end + 1, isProtein) + (showGCContent && !isProtein ? " (" + GCContent(GCDecimalDigits) + "% GC)" : "");
  } else if (caretPosition > -1) {
    var insertBetween = (0, _veSequenceUtils.getInsertBetweenVals)(caretPosition, selectionLayer, sequenceLength);
    return "Caret Between " + (isProtein ? "AAs " + (0, _proteinUtils.divideBy3)(insertBetween[0], true) + " and " + (0, _proteinUtils.divideBy3)(insertBetween[1] + 2, true) : "Bases " + insertBetween[0] + " and " + insertBetween[1]);
  } else {
    return "No Selection";
  }
}