"use strict";

exports.__esModule = true;
exports["default"] = RowItem;
var _rangeUtils = require("@teselagen/range-utils");
var _lodash = require("lodash");
var _sequenceUtils = require("@teselagen/sequence-utils");
var _react = _interopRequireWildcard(require("react"));
var _pluralize = _interopRequireDefault(require("pluralize"));
var _SelectionLayer = _interopRequireDefault(require("./SelectionLayer"));
var _Sequence = _interopRequireDefault(require("./Sequence"));
var _Axis = _interopRequireDefault(require("./Axis"));
var _Orfs = _interopRequireDefault(require("./Orfs"));
var _Translations = _interopRequireDefault(require("./Translations"));
var _Labels = _interopRequireDefault(require("./Labels"));
var _Cutsites = _interopRequireDefault(require("./Cutsites"));
var _Caret = _interopRequireDefault(require("./Caret"));
var _StackedAnnotations = _interopRequireDefault(require("./StackedAnnotations"));
require("./style.css");
var _Chromatogram = _interopRequireDefault(require("./Chromatograms/Chromatogram"));
var _estimateRowHeight = require("../RowView/estimateRowHeight");
var _selectionLayer = require("../utils/selectionLayer");
var _rowviewContants = require("../constants/rowviewContants");
var _CutsiteSelectionLayers = require("./CutsiteSelectionLayers");
var _excluded = ["filterOpts"],
  _excluded2 = ["CompOverride", "shouldShow", "noPlural", "alignmentType", "onlyForward", "onlyReverse"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
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; }
function noop() {}
function filterRanges(ranges, extraProps) {
  if (extraProps === void 0) {
    extraProps = {};
  }
  if (!ranges) return ranges;
  if (extraProps.onlyForward) {
    ranges = (0, _lodash.filter)(ranges, function (a) {
      return a.annotation.forward;
    });
  }
  if (extraProps.onlyReverse) {
    ranges = (0, _lodash.filter)(ranges, function (a) {
      return !a.annotation.forward;
    });
  }
  return ranges;
}
function getPropsForType(props, type, pluralType, extraProps) {
  var upperPluralType = (0, _lodash.startCase)(pluralType);
  var annotationRanges = filterRanges(props.row[pluralType], extraProps);
  var toRet = {
    annotationColor: props[pluralType + "Color"],
    annotationHeight: props[pluralType + "Height"] || _estimateRowHeight.rowHeights[pluralType].height,
    spaceBetweenAnnotations: props["spaceBetweenAnnotations" + upperPluralType] || _estimateRowHeight.rowHeights[pluralType].spaceBetweenAnnotations,
    marginTop: props[pluralType + "MarginTop"] || _estimateRowHeight.rowHeights[pluralType].marginTop,
    marginBottom: props[pluralType + "MarginBottom"] || _estimateRowHeight.rowHeights[pluralType].marginBottom,
    annotationRanges: annotationRanges,
    showLabels: props.annotationLabelVisibility && props.annotationLabelVisibility[pluralType],
    onClick: props[type + "Clicked"],
    onRightClick: props[type + "RightClicked"],
    onDoubleClick: props[type + "DoubleClicked"]
  };
  return toRet;
}
function RowItem(props) {
  var noRedux = props.noRedux,
    _props$charWidth = props.charWidth,
    charWidth = _props$charWidth === void 0 ? _rowviewContants.defaultCharWidth : _props$charWidth,
    _props$selectionLayer = props.selectionLayer,
    selectionLayer = _props$selectionLayer === void 0 ? {
      start: -1,
      end: -1
    } : _props$selectionLayer,
    _props$deletionLayers = props.deletionLayers,
    deletionLayers = _props$deletionLayers === void 0 ? {} : _props$deletionLayers,
    _props$replacementLay = props.replacementLayers,
    replacementLayers = _props$replacementLay === void 0 ? {} : _props$replacementLay,
    _props$searchLayers = props.searchLayers,
    searchLayers = _props$searchLayers === void 0 ? [] : _props$searchLayers,
    rowTopComp = props.rowTopComp,
    rowBottomComp = props.rowBottomComp,
    isProtein = props.isProtein,
    tickSpacing = props.tickSpacing,
    _props$truncateLabels = props.truncateLabelsThatDoNotFit,
    truncateLabelsThatDoNotFit = _props$truncateLabels === void 0 ? true : _props$truncateLabels,
    _props$aminoAcidNumbe = props.aminoAcidNumbersHeight,
    aminoAcidNumbersHeight = _props$aminoAcidNumbe === void 0 ? _estimateRowHeight.rowHeights.aminoAcidNumbers.height : _props$aminoAcidNumbe,
    _props$cutsiteLabelHe = props.cutsiteLabelHeight,
    cutsiteLabelHeight = _props$cutsiteLabelHe === void 0 ? _estimateRowHeight.rowHeights.cutsiteLabels.height : _props$cutsiteLabelHe,
    _props$sequenceHeight = props.sequenceHeight,
    sequenceHeight = _props$sequenceHeight === void 0 ? _estimateRowHeight.rowHeights.sequence.height : _props$sequenceHeight,
    _props$axisHeight = props.axisHeight,
    axisHeight = _props$axisHeight === void 0 ? _estimateRowHeight.rowHeights.axis.height : _props$axisHeight,
    _props$primerHeight = props.primerHeight,
    primerHeight = _props$primerHeight === void 0 ? _estimateRowHeight.rowHeights.primers.height : _props$primerHeight,
    _props$axisMarginTop = props.axisMarginTop,
    axisMarginTop = _props$axisMarginTop === void 0 ? _estimateRowHeight.rowHeights.axis.marginTop : _props$axisMarginTop,
    width = props.width,
    _props$annotationVisi = props.annotationVisibility,
    annotationVisibility = _props$annotationVisi === void 0 ? {} : _props$annotationVisi,
    _props$annotationLabe = props.annotationLabelVisibility,
    annotationLabelVisibility = _props$annotationLabe === void 0 ? {} : _props$annotationLabe,
    _props$additionalSele = props.additionalSelectionLayers,
    additionalSelectionLayers = _props$additionalSele === void 0 ? [] : _props$additionalSele,
    _props$caretPosition = props.caretPosition,
    caretPosition = _props$caretPosition === void 0 ? -1 : _props$caretPosition,
    _props$row = props.row,
    row = _props$row === void 0 ? {
      sequence: "",
      start: 0,
      end: 0,
      rowNumber: 0
    } : _props$row,
    readOnly = props.readOnly,
    isRowView = props.isRowView,
    emptyText = props.emptyText,
    alignmentType = props.alignmentType,
    alignmentData = props.alignmentData,
    _props$sequenceLength = props.sequenceLength,
    sequenceLength = _props$sequenceLength === void 0 ? row.sequence.length : _props$sequenceLength,
    chromatogramData = props.chromatogramData,
    _props$fullSequence = props.fullSequence,
    fullSequence = _props$fullSequence === void 0 ? "" : _props$fullSequence,
    _props$replacementLay2 = props.replacementLayerClicked,
    replacementLayerClicked = _props$replacementLay2 === void 0 ? noop : _props$replacementLay2,
    _props$replacementLay3 = props.replacementLayerRightClicked,
    replacementLayerRightClicked = _props$replacementLay3 === void 0 ? noop : _props$replacementLay3,
    _props$searchLayerCli = props.searchLayerClicked,
    searchLayerClicked = _props$searchLayerCli === void 0 ? noop : _props$searchLayerCli,
    _props$backgroundRigh = props.backgroundRightClicked,
    backgroundRightClicked = _props$backgroundRigh === void 0 ? noop : _props$backgroundRigh,
    _props$selectionLayer2 = props.selectionLayerRightClicked,
    selectionLayerRightClicked = _props$selectionLayer2 === void 0 ? noop : _props$selectionLayer2,
    _props$searchLayerRig = props.searchLayerRightClicked,
    searchLayerRightClicked = _props$searchLayerRig === void 0 ? noop : _props$searchLayerRig,
    _props$translationDou = props.translationDoubleClicked,
    translationDoubleClicked = _props$translationDou === void 0 ? noop : _props$translationDou,
    _props$minHeight = props.minHeight,
    minHeight = _props$minHeight === void 0 ? 22 : _props$minHeight,
    _props$bpsPerRow = props.bpsPerRow,
    bpsPerRow = _props$bpsPerRow === void 0 ? sequenceLength : _props$bpsPerRow,
    editorName = props.editorName,
    rowContainerStyle = props.rowContainerStyle,
    onScroll = props.onScroll,
    scrollData = props.scrollData,
    onlyShowLabelsThatDoNotFit = props.onlyShowLabelsThatDoNotFit,
    labelLineIntensity = props.labelLineIntensity,
    isLinearView = props.isLinearView,
    scalePct = props.scalePct,
    setScalePct = props.setScalePct,
    _props$extraAnnotatio = props.extraAnnotationProps,
    extraAnnotationProps = _props$extraAnnotatio === void 0 ? {} : _props$extraAnnotatio;
  var showChromatogram = annotationVisibility.chromatogram,
    showCutsites = annotationVisibility.cutsites,
    showCutsitesInSequence = annotationVisibility.cutsitesInSequence,
    showAxis = annotationVisibility.axis,
    showAxisNumbers = annotationVisibility.axisNumbers,
    showAminoAcidNumbers = annotationVisibility.aminoAcidNumbers,
    showDnaColors = annotationVisibility.dnaColors,
    fivePrimeThreePrimeHints = annotationVisibility.fivePrimeThreePrimeHints,
    showReverseSequence = annotationVisibility.reverseSequence,
    showSequence = annotationVisibility.sequence,
    height = annotationVisibility.height;
  var _row$sequence = row.sequence,
    sequence = _row$sequence === void 0 ? "" : _row$sequence,
    _row$cutsites = row.cutsites,
    cutsites = _row$cutsites === void 0 ? [] : _row$cutsites;
  var reverseSequence = (0, _sequenceUtils.getComplementSequenceString)(alignmentData && alignmentData.sequence || sequence);
  var getGaps = (0, _react.useMemo)(function () {
    if (alignmentData) {
      var gapMap = getGapMap(alignmentData.sequence);
      //this function is used to calculate the number of spaces that come before or inside a range
      return function (rangeOrCaretPosition) {
        if (typeof rangeOrCaretPosition !== "object") {
          return {
            gapsBefore: gapMap[Math.min(rangeOrCaretPosition, gapMap.length - 1)]
          };
        }
        //otherwise it is a range!
        var start = rangeOrCaretPosition.start,
          end = rangeOrCaretPosition.end;
        var toReturn = {
          gapsBefore: gapMap[start],
          gapsInside: gapMap[Math.min(end, gapMap.length - 1)] - gapMap[Math.min(start, gapMap.length - 1)]
        };
        return toReturn;
      };
    } else {
      return getGapsDefault;
    }
  }, [alignmentData]);
  if (!row) {
    return null;
  }
  if (!width) {
    width = bpsPerRow * charWidth;
  }
  if (isLinearView) {
    width -= (charWidth || 12) * bpsPerRow.toString().length / 2;
  }
  charWidth = charWidth || width / Math.max(bpsPerRow, 1);
  var rowStyle = {
    position: "relative",
    minHeight: minHeight,
    height: height,
    width: width + "px"
  };
  var annotationCommonProps = {
    noRedux: noRedux,
    editorName: editorName,
    charWidth: charWidth,
    bpsPerRow: bpsPerRow,
    getGaps: getGaps,
    isProtein: isProtein,
    readOnly: readOnly,
    sequenceLength: sequenceLength,
    isRowView: isRowView,
    row: {
      start: row.start,
      end: row.end
    }
  };
  var drawLabels = function drawLabels(type, noDraw, _temp) {
    var _ref = _temp === void 0 ? {} : _temp,
      filterOpts = _ref.filterOpts,
      extraProps = _objectWithoutPropertiesLoose(_ref, _excluded);
    if (noDraw) {
      return null;
    }
    var pluralType = (0, _pluralize["default"])(type);
    var ranges = filterRanges(annotationLabelVisibility[pluralType] && annotationVisibility[pluralType] ? (0, _lodash.map)(row[pluralType], function (a) {
      return (0, _lodash.assign)(a, {
        onClick: props[type + "Clicked"],
        onRightClick: props[type + "RightClicked"],
        onDoubleClick: props[type + "DoubleClicked"]
      });
    }) : [], filterOpts);
    if (!ranges.length) return null;
    return /*#__PURE__*/_react["default"].createElement(_Labels["default"], _extends({}, annotationCommonProps, {
      onlyShowLabelsThatDoNotFit: onlyShowLabelsThatDoNotFit,
      labelLineIntensity: labelLineIntensity,
      rangeMax: bpsPerRow,
      annotationRanges: ranges,
      annotationHeight: cutsiteLabelHeight
    }, extraProps));
  };
  var drawAnnotations = function drawAnnotations(type, extraProps) {
    if (extraProps === void 0) {
      extraProps = {};
    }
    var _extraProps = extraProps,
      CompOverride = _extraProps.CompOverride,
      shouldShow = _extraProps.shouldShow,
      noPlural = _extraProps.noPlural,
      alignmentType = _extraProps.alignmentType,
      onlyForward = _extraProps.onlyForward,
      onlyReverse = _extraProps.onlyReverse,
      otherExtraProps = _objectWithoutPropertiesLoose(_extraProps, _excluded2);
    var pluralType = noPlural ? type : (0, _pluralize["default"])(type);
    if (shouldShow !== undefined ? !shouldShow : !annotationVisibility[pluralType] || Object.keys(row[pluralType] || {}).length <= 0) {
      return null;
    }
    var CompToUse = CompOverride || _StackedAnnotations["default"];
    return /*#__PURE__*/_react["default"].createElement(CompToUse, _extends({
      truncateLabelsThatDoNotFit: truncateLabelsThatDoNotFit,
      onlyShowLabelsThatDoNotFit: onlyShowLabelsThatDoNotFit,
      type: type,
      fullSequence: fullSequence,
      containerClassName: (0, _lodash.camelCase)("veRowView-" + pluralType + "Container"),
      alignmentType: alignmentType
    }, annotationCommonProps, getPropsForType(props, type, pluralType, extraProps), otherExtraProps));
  };

  // a t g a t c a g g
  // 0 1 2 3 4 5 6 8 9
  //0 1 2 3 4 5 6 7 9

  var deletionLayersToDisplay = (0, _lodash.flatMap)(_extends({}, replacementLayers, deletionLayers), function (layer) {
    if (layer.caretPosition > -1) {
      return [];
    }
    var overlaps = (0, _rangeUtils.getOverlapsOfPotentiallyCircularRanges)(layer, row, sequenceLength);
    return overlaps;
  });
  var deletionLayerStrikeThrough = deletionLayersToDisplay.length ? deletionLayersToDisplay.map(function (layer, index) {
    var left = (layer.start - row.start) * charWidth;
    var width = (layer.end - layer.start + 1) * charWidth;
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: "deletionLayer" + index,
      className: "ve_sequence_strikethrough",
      style: {
        left: left,
        width: width,
        top: 10,
        height: 2,
        position: "absolute",
        background: "black"
      }
    });
  }) : null;
  var translationCommonProps = {
    CompOverride: _Translations["default"],
    showAminoAcidNumbers: showAminoAcidNumbers,
    sequenceLength: sequenceLength,
    aminoAcidNumbersHeight: aminoAcidNumbersHeight
  };
  var partProps = {
    getExtraInnerCompProps: function getExtraInnerCompProps(annotationRange) {
      var annotation = annotationRange.annotation;
      var color = annotation.color;
      var colorToUse = (0, _lodash.startsWith)(color, "override_") ? color.replace("override_", "") : "#ac68cc";
      var extraProps = {};
      if (typeof extraAnnotationProps["part"] === "function") {
        extraProps = extraAnnotationProps["part"](annotation);
      }
      return _extends({
        textColor: colorToUse,
        stroke: colorToUse
      }, extraProps);
    },
    alignmentType: alignmentType
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    style: rowContainerStyle,
    onContextMenu: backgroundRightClicked,
    onScroll: onScroll,
    className: "veRowItemWrapper"
  }, rowTopComp && rowTopComp, /*#__PURE__*/_react["default"].createElement("div", {
    className: "veRowItem",
    style: rowStyle
  }, /*#__PURE__*/_react["default"].createElement(_SelectionLayer["default"], _extends({
    className: "veSearchLayerContainer",
    customTitleStart: "Search match"
    // color="yellow"
    // hideCarets
    ,
    regions: searchLayers
  }, annotationCommonProps, {
    selectionLayerRightClicked: searchLayerRightClicked,
    row: alignmentData ? {
      start: 0,
      end: alignmentData.sequence.length - 1
    } : row,
    onClick: searchLayerClicked
  })), /*#__PURE__*/_react["default"].createElement(_SelectionLayer["default"], _extends({
    isDraggable: true,
    selectionLayerRightClicked: selectionLayerRightClicked
  }, annotationCommonProps, {
    row: alignmentData ? {
      start: 0,
      end: alignmentData.sequence.length - 1
    } : row,
    regions: (0, _selectionLayer.getAllSelectionLayers)({
      additionalSelectionLayers: additionalSelectionLayers,
      selectionLayer: selectionLayer
    })
  })), drawAnnotations("warning"), drawAnnotations("assemblyPiece"), drawAnnotations("lineageAnnotation"), drawLabels("part"), drawAnnotations("part", partProps), drawAnnotations("orf", {
    CompOverride: _Orfs["default"]
  }), charWidth > 4 && drawAnnotations("translation", _extends({}, translationCommonProps, {
    onDoubleClick: translationDoubleClicked
  })), showChromatogram && chromatogramData && /*#__PURE__*/_react["default"].createElement(_Chromatogram["default"], _extends({
    chromatogramData: chromatogramData,
    alignmentData: alignmentData,
    scalePct: scalePct,
    setScalePct: setScalePct
  }, annotationCommonProps)), drawLabels("cutsite", !isRowView), drawLabels("primer", false, {
    filterOpts: {
      onlyForward: true
    }
  }), drawAnnotations("primer", {
    sequence: fullSequence,
    isStriped: true,
    annotationHeight: primerHeight,
    onlyForward: true
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "veRowItemSequenceContainer",
    style: {
      position: "relative"
    }
  }, showSequence && /*#__PURE__*/_react["default"].createElement(_Sequence["default"], _extends({
    sequenceLength: sequenceLength,
    cutsites: cutsites //pass this in order to get children cutsites to re-render
    ,
    showDnaColors: showDnaColors,
    fivePrimeThreePrimeHints: fivePrimeThreePrimeHints,
    scrollData: scrollData,
    hideBps: charWidth < 7,
    sequence: alignmentData ? alignmentData.sequence : row.sequence //from alignment data and has "-"" chars in it
    ,
    rowStart: row.start,
    rowEnd: row.end,
    height: sequenceHeight,
    showCutsites: showCutsites,
    charWidth: charWidth,
    alignmentData: alignmentData
  }, annotationCommonProps), showCutsites && Object.keys(cutsites).length > 0 && /*#__PURE__*/_react["default"].createElement(_Cutsites["default"], _extends({
    sequenceLength: sequenceLength,
    annotationRanges: cutsites,
    topStrand: true
  }, annotationCommonProps)), deletionLayerStrikeThrough), emptyText, showReverseSequence && /*#__PURE__*/_react["default"].createElement(_Sequence["default"], {
    scrollData: scrollData,
    sequenceLength: sequenceLength,
    fivePrimeThreePrimeHints: fivePrimeThreePrimeHints,
    isReverse: true,
    cutsites: cutsites //pass this in order to get children cutsites to re-render
    ,
    showDnaColors: showDnaColors,
    hideBps: charWidth < 7,
    length: reverseSequence.length,
    showCutsites: showCutsites,
    rowStart: row.start,
    rowEnd: row.end,
    sequence: reverseSequence,
    height: sequenceHeight,
    charWidth: charWidth
  }, showCutsites && Object.keys(cutsites).length > 0 && /*#__PURE__*/_react["default"].createElement(_Cutsites["default"], _extends({
    topStrand: false,
    annotationRanges: cutsites
  }, annotationCommonProps)), deletionLayerStrikeThrough), showCutsites && showCutsitesInSequence && /*#__PURE__*/_react["default"].createElement(_CutsiteSelectionLayers.CutsiteSelectionLayers, {
    editorName: editorName,
    cutsites: cutsites,
    annotationCommonProps: annotationCommonProps,
    showReverseSequence: showReverseSequence,
    sequenceHeight: sequenceHeight,
    alignmentData: alignmentData,
    row: row
  })), drawAnnotations("primer", {
    sequence: fullSequence,
    isStriped: true,
    annotationHeight: primerHeight,
    onlyReverse: true
  }), drawLabels("primer", false, {
    filterOpts: {
      onlyReverse: true
    }
  }), drawLabels("feature"), drawAnnotations("feature"), (0, _lodash.map)(replacementLayers, function (replacementLayer) {
    if (!replacementLayer) return null;
    var atCaret = replacementLayer.caretPosition > -1;
    var normedCaretPos;
    if (atCaret) {
      normedCaretPos = (0, _rangeUtils.normalizePositionByRangeLength)(replacementLayer.caretPosition, sequenceLength);
    }
    var insertedBpsLayer = _extends({}, replacementLayer, {
      start: atCaret ? normedCaretPos : replacementLayer.start,
      end: (atCaret ? normedCaretPos : replacementLayer.start) + replacementLayer.sequence.length
    });
    var sequence = insertedBpsLayer.sequence;
    var layerRangeOverlaps = (0, _rangeUtils.getOverlapsOfPotentiallyCircularRanges)(insertedBpsLayer, row, sequenceLength);
    return layerRangeOverlaps.map(function (layer, index) {
      var isStart = layer.start === insertedBpsLayer.start;
      var seqInRow = (0, _rangeUtils.getSequenceWithinRange)({
        start: layer.start - insertedBpsLayer.start,
        end: layer.end - insertedBpsLayer.start
      }, sequence);
      var startOffset = layer.start - row.start;
      var width = seqInRow.length * charWidth;
      var height = sequenceHeight;
      var bufferBottom = 4;
      var bufferLeft = 2;
      var arrowHeight = isStart ? 8 : 0;
      return /*#__PURE__*/_react["default"].createElement(_Sequence["default"], {
        sequenceLength: sequenceLength,
        isReplacementLayer: true,
        showDnaColors: showDnaColors,
        key: index,
        sequence: seqInRow,
        startOffset: startOffset,
        height: height,
        length: seqInRow.length,
        charWidth: charWidth
      }, /*#__PURE__*/_react["default"].createElement("svg", {
        style: {
          left: startOffset * charWidth,
          height: sequenceHeight,
          position: "absolute"
        },
        ref: "rowViewTextContainer",
        onClick: function onClick(event) {
          replacementLayerClicked({
            annotation: replacementLayer,
            event: event
          });
        },
        onContextMenu: function onContextMenu(event) {
          replacementLayerRightClicked({
            annotation: replacementLayer,
            event: event
          });
        },
        className: "rowViewTextContainer clickable",
        width: Math.max(0, Number(width)),
        height: Math.max(0, Number(height))
      }, /*#__PURE__*/_react["default"].createElement("polyline", {
        points: -bufferLeft + ",0 " + -bufferLeft + "," + -arrowHeight + ", " + charWidth / 2 + ",0 " + width + ",0 " + width + "," + (height + bufferBottom) + " " + -bufferLeft + "," + (height + bufferBottom) + " " + -bufferLeft + ",0",
        fill: "none",
        stroke: "black",
        strokeWidth: "2px"
      })));
    });
  }), drawAnnotations("primaryProteinSequence", _extends({}, translationCommonProps, {
    noPlural: true
  })), drawLabels("cutsite", isRowView), showAxis && /*#__PURE__*/_react["default"].createElement(_Axis["default"], _extends({
    scrollData: scrollData,
    tickSpacing: tickSpacing,
    showAxisNumbers: showAxisNumbers,
    annotationHeight: axisHeight,
    marginTop: axisMarginTop
  }, annotationCommonProps, {
    isLinearView: isLinearView
  })), caretPosition > -1 && /*#__PURE__*/_react["default"].createElement(_Caret["default"], _extends({
    caretPosition: caretPosition
  }, _extends({}, annotationCommonProps, {
    getGaps: undefined
  }), {
    row: alignmentData ? {
      start: 0,
      end: alignmentData.sequence.length - 1
    } : row
  }))), rowBottomComp && rowBottomComp);
}
function getGapMap(sequence) {
  var gapMap = [0]; //a map of position to how many gaps come before that position [0,0,0,5,5,5,5,17,17,17, ]
  sequence.split("").forEach(function (_char) {
    if (_char === "-") {
      gapMap[Math.max(0, gapMap.length - 1)] = (gapMap[Math.max(0, gapMap.length - 1)] || 0) + 1;
    } else {
      gapMap.push(gapMap[gapMap.length - 1] || 0);
      // gapMap[gapMap.length] =
    }
  });

  return gapMap;
}
// var a = getGapMap("---tagccc---tagasdfw--gg")
function getGapsDefault() {
  return {
    gapsBefore: 0,
    gapsInside: 0
  };
}
module.exports = exports.default;