<commit_before>function MorphingBarLandscape(info) {
  this._pointCount = info.pointCount;
  this._attrs = info.attrs;
  this._morphingIndex = info.morphingIndex;
  this._morphingVisibility = info.morphingVisibility || 0;
}

MorphingBarLandscape.prototype.computeRange = function(region) {
  var leadingSpacing = this._leadingSpacing();

  var startIndex = 0;
  if (region.left < leadingSpacing - this._morphingBarSpacing()) {
    // NOTE: we have to use Math.min() because the regular attrs might report an index of
    // this._morphingIndex since the morphing bar spacing is smaller than the regular bar spacing.
    startIndex = Math.min(this._attrs.computeRange(region, this._pointCount).startIndex,
      this._morphingIndex-1);
  } else if (region.left >= leadingSpace + this._morphingBarWidth()) {
    var shift = leadingSpace + this._morphingBarWidth() + this._morphingBarSpacing() +
      this._attrs.getBarWidth();
    if (region.left < shift) {
      startIndex = this._morphingIndex + 1;
    } else {
      var shifted = region.left - shift;
      startIndex = this._morphingIndex + 2 +
        Math.floor(shifted/(this._attrs.getBarWidth()+this._attrs.getBarSpacing()));
    }
  } else {
    startIndex = this._morphingIndex;
  }

  var endIndex = 0;
  var right = region.left + region.width;
  if (right < leadingSpacing) {
    var finalRange = this._attrs.computeRange(region, this._pointCount);
    endIndex = finalRange.startIndex + finalRange.length;
  } else if (right < leadingSpacing + this._morphingBarWidth() + this._morphingBarSpacing()) {
    endIndex = this._morphingIndex + 1;
  } else {
    var shifted = right - (leadingSpacing + this._morphingBarWidth() + this._morphingBarSpacing());
    endIndex = this._morphingIndex + 2 +
      Math.floor(shifted/(this._attrs.getBarWidth()+this._attrs.getBarSpacing()));
  }

  return {
    startIndex: Math.max(0, Math.min(this._pointCount-1, startIndex)),
    length: Math.max(0, Math.min(this._pointCount-startIndex, endIndex - startIndex))
  };
};

MorphingBarLandscape.prototype.computeRegion = function(range) {
  // TODO: this.
};

// _width returns the width of the complete morphing landscape.<commit_msg>BarStyle: drafted MorphingBarLandscape.computeRegion()<commit_after>function MorphingBarLandscape(info) {
  this._pointCount = info.pointCount;
  this._attrs = info.attrs;
  this._morphingIndex = info.morphingIndex;
  this._morphingVisibility = info.morphingVisibility || 0;
}

MorphingBarLandscape.prototype.computeRange = function(region) {
  var leadingSpacing = this._leadingSpacing();

  var startIndex = 0;
  if (region.left < leadingSpacing - this._morphingBarSpacing()) {
    // NOTE: we have to use Math.min() because the regular attrs might report an index of
    // this._morphingIndex since the morphing bar spacing is smaller than the regular bar spacing.
    startIndex = Math.min(this._attrs.computeRange(region, this._pointCount).startIndex,
      this._morphingIndex-1);
  } else if (region.left >= leadingSpace + this._morphingBarWidth()) {
    var shift = leadingSpace + this._morphingBarWidth() + this._morphingBarSpacing() +
      this._attrs.getBarWidth();
    if (region.left < shift) {
      startIndex = this._morphingIndex + 1;
    } else {
      var shifted = region.left - shift;
      startIndex = this._morphingIndex + 2 +
        Math.floor(shifted/(this._attrs.getBarWidth()+this._attrs.getBarSpacing()));
    }
  } else {
    startIndex = this._morphingIndex;
  }

  var endIndex = 0;
  var right = region.left + region.width;
  if (right < leadingSpacing) {
    var finalRange = this._attrs.computeRange(region, this._pointCount);
    endIndex = finalRange.startIndex + finalRange.length;
  } else if (right < leadingSpacing + this._morphingBarWidth() + this._morphingBarSpacing()) {
    endIndex = this._morphingIndex + 1;
  } else {
    var shifted = right - (leadingSpacing + this._morphingBarWidth() + this._morphingBarSpacing());
    endIndex = this._morphingIndex + 2 +
      Math.floor(shifted/(this._attrs.getBarWidth()+this._attrs.getBarSpacing()));
  }

  return {
    startIndex: Math.max(0, Math.min(this._pointCount-1, startIndex)),
    length: Math.max(0, Math.min(this._pointCount-startIndex, endIndex - startIndex))
  };
};

MorphingBarLandscape.prototype.computeRegion = function(range) {
  var leadingSpace = this._leadingSpace();
  var width = this._width();

  var left = 0;
  if (range.startIndex > 0 && range.startIndex < this._morphingIndex) {
    left = this._attrs.getLeftMargin() + range.startIndex*this._attrs.getBarWidth() +
      (range.startIndex-1)*this._attrs.getBarSpacing();
  } else if (range.startIndex > 0 && range.startIndex === this._morphingIndex) {
    left = leadingSpace - this._morphingBarSpacing();
  } else if (range.startIndex === this._morphingIndex + 1) {
    left = leadingSpace + this._morphingBarWidth();
  } else if (range.startIndex > this._morphingIndex + 1) {
    var shiftedIndex = range.startIndex - (this._morphingIndex + 2);
    var shiftedOffset = leadingSpace + this._morphingBarWidth() + this._morphingBarSpacing() +
      this._attrs.getBarWidth();
    left = shiftedOffset + shiftedIndex*(this._attrs.getBarWidth()+this._attrs.getBarSpacing());
  }

  var right = 0;
  var endIndex = range.startIndex + range.length;
  if (endIndex >= this._pointCount) {
    right = width;
  } else if (endIndex > 0 && endIndex < this._morphingIndex) {
    right = endIndex*(this._attrs.getBarWidth()+this._attrs.getBarSpacing()) +
      this._attrs.getLeftMargin();
  } else if (endIndex > 0 && endIndex === this._morphingIndex) {
    right = leadingSpace;
  } else if (endIndex >= this._morphingIndex + 1) {
    var shiftedIndex = endIndex - (this._morphingIndex + 1);
    var shiftedOffset = leadingSpace + this._morphingBarWidth() + this._morphingBarSpacing();
    right = shifteOffset + shiftedIndex*(this._attrs.getBarWidth()+this._attrs.getBarSpacing());
  }

  return {
    left: Math.max(0, Math.min(width, left)),
    width: Math.max(0, Math.min(width-left, right-left))
  };
};

// _width returns the width of the complete morphing landscape.
{'fraction_non_alphanumeric': 0.12583755515607126, 'fraction_numerical': 0.005883314267037098, 'mean_word_length': 3.907778668805132, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4121138', 'n_tokens_mistral': 1968, 'n_tokens_neox': 1929, 'n_words': 397}