<commit_before># How long should it take for the bar to animate to a new
# point after receiving it
CATCHUP_TIME = 500

# How quickly should the bar be moving before it has any progress
# info from a new source in %/ms
INITIAL_RATE = .03

# What is the minimum amount of time the bar should be on the
# screen
MIN_TIME = 500

# What is the minimum amount of time the bar should sit after the last
# update before disappearing
GHOST_TIME = 250

# How frequently in ms should we check for the elements being tested for
# using the element monitor?
ELEMENT_CHECK_INTERVAL = 100

# Its easy for a bunch of the bar to be eaten in the first few frames
# before we know how much there is to load.  This limits how much of
# the bar can be used per frame
MAX_PROGRESS_PER_FRAME = 10

# This tweaks how the animation easing looks
EASE_FACTOR = 1.25

now = ->
  performance?.now?() ? +new Date

runAnimation = (fn) ->
  last = now()
  tick = ->
    diff = now() - last
    last = now()

    fn diff, ->
      requestAnimationFrame tick

  tick()

result = (obj, key, args...) ->
  if typeof obj[key] is 'function'
    obj[key](args...)
  else
    obj[key]

avgKey = (arr, key, args...) ->
  sum = 0
  for item in arr
    sum += result(item, key, args...)

  sum / arr.length

class Bar
  constructor: ->
    @progress = 0

  getElement: ->
    if not @el?
      @el = document.createElement 'div'
      @el.className = 'pace'

      @el.innerHTML = '''
      <div class="pace-progress">
        <div class="pace-progress-inner"></div>
      </div>
      <div class="pace-activity"></div>'''

      if document.body.firstChild?
        document.body.insertBefore @el, document.body.firstChild
      else
        document.body.appendChild @el

    @el

  hide: ->
    @getElement().style.display = 'none'

  update: (prog) ->
    @progress = prog

    do @render

  destroy: ->
    @getElement().parentNode.removeChild(@getElement)

    @el = undefined

  render: ->
    if not document.body?
      return false

    @getElement().style.width = "#{ @progress }%"

  done: ->
    @progress >= 100

# Every 100ms, we decide what the next progress should be
# Every time a new thing happens, we decide what the progress should be
# CSS animations can't give us backoff

class Events
  constructor: ->
    @bindings = {}

  trigger: (name, val) ->
    if @bindings[name]?
      for binding in @bindings[name]
        binding.call @, val

  on: (name, fn) ->
    @bindings[name] ?= []
    @bindings[name].push fn

# We should only ever instantiate one of these
_XMLHttpRequest = window.XMLHttpRequest
class RequestIntercept extends Events
  constructor: ->
    super<commit_msg>Set the width of .pace-progress not .pace<commit_after># How long should it take for the bar to animate to a new
# point after receiving it
CATCHUP_TIME = 500

# How quickly should the bar be moving before it has any progress
# info from a new source in %/ms
INITIAL_RATE = .03

# What is the minimum amount of time the bar should be on the
# screen
MIN_TIME = 500

# What is the minimum amount of time the bar should sit after the last
# update before disappearing
GHOST_TIME = 250

# How frequently in ms should we check for the elements being tested for
# using the element monitor?
ELEMENT_CHECK_INTERVAL = 100

# Its easy for a bunch of the bar to be eaten in the first few frames
# before we know how much there is to load.  This limits how much of
# the bar can be used per frame
MAX_PROGRESS_PER_FRAME = 10

# This tweaks how the animation easing looks
EASE_FACTOR = 1.25

now = ->
  performance?.now?() ? +new Date

runAnimation = (fn) ->
  last = now()
  tick = ->
    diff = now() - last
    last = now()

    fn diff, ->
      requestAnimationFrame tick

  tick()

result = (obj, key, args...) ->
  if typeof obj[key] is 'function'
    obj[key](args...)
  else
    obj[key]

avgKey = (arr, key, args...) ->
  sum = 0
  for item in arr
    sum += result(item, key, args...)

  sum / arr.length

class Bar
  constructor: ->
    @progress = 0

  getElement: ->
    if not @el?
      @el = document.createElement 'div'
      @el.className = 'pace'

      @el.innerHTML = '''
      <div class="pace-progress">
        <div class="pace-progress-inner"></div>
      </div>
      <div class="pace-activity"></div>'''

      if document.body.firstChild?
        document.body.insertBefore @el, document.body.firstChild
      else
        document.body.appendChild @el

    @el

  hide: ->
    @getElement().style.display = 'none'

  update: (prog) ->
    @progress = prog

    do @render

  destroy: ->
    @getElement().parentNode.removeChild(@getElement)

    @el = undefined

  render: ->
    if not document.body?
      return false

    $(@getElement()).find('.pace-progress').css width: "#{ @progress }%"

  done: ->
    @progress >= 100

# Every 100ms, we decide what the next progress should be
# Every time a new thing happens, we decide what the progress should be
# CSS animations can't give us backoff

class Events
  constructor: ->
    @bindings = {}

  trigger: (name, val) ->
    if @bindings[name]?
      for binding in @bindings[name]
        binding.call @, val

  on: (name, fn) ->
    @bindings[name] ?= []
    @bindings[name].push fn

# We should only ever instantiate one of these
_XMLHttpRequest = window.XMLHttpRequest
class RequestIntercept extends Events
  constructor: ->
    super
{'fraction_non_alphanumeric': 0.10869160617904336, 'fraction_numerical': 0.010050251256281407, 'mean_word_length': 2.779184247538678, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 51, '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': '2297286', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1608, 'n_words': 628}