<commit_before>{debounce} = require 'underscore-plus'
{CompositeDisposable, Disposable} = require 'event-kit'
{EventsDelegation} = require 'atom-utils'
DOMStylesReader = require './mixins/dom-styles-reader'
CanvasDrawer = require './mixins/canvas-drawer'

MinimapQuickSettingsElement = null

# Public:
class MinimapElement extends HTMLElement
  DOMStylesReader.includeInto(this)
  CanvasDrawer.includeInto(this)
  EventsDelegation.includeInto(this)

  ### Public ###

  displayMinimapOnLeft: false

  #    ##     ##  #######   #######  ##    ##  ######
  #    ##     ## ##     ## ##     ## ##   ##  ##    ##
  #    ##     ## ##     ## ##     ## ##  ##   ##
  #    ######### ##     ## ##     ## #####     ######
  #    ##     ## ##     ## ##     ## ##  ##         ##
  #    ##     ## ##     ## ##     ## ##   ##  ##    ##
  #    ##     ##  #######   #######  ##    ##  ######

  createdCallback: ->
    @subscriptions = new CompositeDisposable
    @initializeContent()

    @subscriptions.add atom.themes.onDidChangeActiveThemes =>
      @invalidateCache()
      @requestForcedUpdate()

    @observeConfig
      'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) =>
        swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft
        @displayMinimapOnLeft = displayMinimapOnLeft

        @swapMinimapPosition() if swapPosition

      'minimap.minimapScrollIndicator': (@minimapScrollIndicator) =>
        if @minimapScrollIndicator and not @scrollIndicator?
          @initializeScrollIndicator()
        else if @scrollIndicator?
          @disposeScrollIndicator()

        @requestUpdate() if @attached

      'minimap.displayPluginsControls': (@displayPluginsControls) =>
        if @displayPluginsControls and not @openQuickSettings?
          @initializeOpenQuickSettings()
        else if @openQuickSettings?
          @disposeOpenQuickSettings()

      'minimap.textOpacity': (@textOpacity) =>
        @requestForcedUpdate() if @attached

      'minimap.displayCodeHighlights': (@displayCodeHighlights) =>
        @requestForcedUpdate() if @attached

      'minimap.adjustMinimapWidthToSoftWrap': (@adjustToSoftWrap) =>
        console.log 'here', @attached
        @measureHeightAndWidth() if @attached

      'minimap.useHardwareAcceleration': (@useHardwareAcceleration) =>
        @requestUpdate() if @attached

  attachedCallback: ->
    @subscriptions.add atom.views.pollDocument => @pollDOM()
    @measureHeightAndWidth()
    @attached = true

  detachedCallback: ->
    @attached = false

  attributeChangedCallback: (attrName, oldValue, newValue) ->

  #       ###    ######## ########    ###     ######  ##     ##
  #      ## ##      ##       ##      ## ##   ##    ## ##     ##
  #     ##   ##     ##       ##     ##   ##  ##       ##     ##
  #    ##     ##    ##       ##    ##     ## ##       #########
  #    #########    ##       ##    ######### ##       ##     ##
  #    ##     ##    ##       ##    ##     ## ##    ## ##     ##
  #    ##     ##    ##       ##    ##     ##  ######  ##     ##

  isVisible: -> @offsetWidth > 0 or @offsetHeight > 0

  attach: ->
    return if @attached<commit_msg>:fire: logs<commit_after>{debounce} = require 'underscore-plus'
{CompositeDisposable, Disposable} = require 'event-kit'
{EventsDelegation} = require 'atom-utils'
DOMStylesReader = require './mixins/dom-styles-reader'
CanvasDrawer = require './mixins/canvas-drawer'

MinimapQuickSettingsElement = null

# Public:
class MinimapElement extends HTMLElement
  DOMStylesReader.includeInto(this)
  CanvasDrawer.includeInto(this)
  EventsDelegation.includeInto(this)

  ### Public ###

  displayMinimapOnLeft: false

  #    ##     ##  #######   #######  ##    ##  ######
  #    ##     ## ##     ## ##     ## ##   ##  ##    ##
  #    ##     ## ##     ## ##     ## ##  ##   ##
  #    ######### ##     ## ##     ## #####     ######
  #    ##     ## ##     ## ##     ## ##  ##         ##
  #    ##     ## ##     ## ##     ## ##   ##  ##    ##
  #    ##     ##  #######   #######  ##    ##  ######

  createdCallback: ->
    @subscriptions = new CompositeDisposable
    @initializeContent()

    @subscriptions.add atom.themes.onDidChangeActiveThemes =>
      @invalidateCache()
      @requestForcedUpdate()

    @observeConfig
      'minimap.displayMinimapOnLeft': (displayMinimapOnLeft) =>
        swapPosition = @minimap? and displayMinimapOnLeft isnt @displayMinimapOnLeft
        @displayMinimapOnLeft = displayMinimapOnLeft

        @swapMinimapPosition() if swapPosition

      'minimap.minimapScrollIndicator': (@minimapScrollIndicator) =>
        if @minimapScrollIndicator and not @scrollIndicator?
          @initializeScrollIndicator()
        else if @scrollIndicator?
          @disposeScrollIndicator()

        @requestUpdate() if @attached

      'minimap.displayPluginsControls': (@displayPluginsControls) =>
        if @displayPluginsControls and not @openQuickSettings?
          @initializeOpenQuickSettings()
        else if @openQuickSettings?
          @disposeOpenQuickSettings()

      'minimap.textOpacity': (@textOpacity) =>
        @requestForcedUpdate() if @attached

      'minimap.displayCodeHighlights': (@displayCodeHighlights) =>
        @requestForcedUpdate() if @attached

      'minimap.adjustMinimapWidthToSoftWrap': (@adjustToSoftWrap) =>
        @measureHeightAndWidth() if @attached

      'minimap.useHardwareAcceleration': (@useHardwareAcceleration) =>
        @requestUpdate() if @attached

  attachedCallback: ->
    @subscriptions.add atom.views.pollDocument => @pollDOM()
    @measureHeightAndWidth()
    @attached = true

  detachedCallback: ->
    @attached = false

  attributeChangedCallback: (attrName, oldValue, newValue) ->

  #       ###    ######## ########    ###     ######  ##     ##
  #      ## ##      ##       ##      ## ##   ##    ## ##     ##
  #     ##   ##     ##       ##     ##   ##  ##       ##     ##
  #    ##     ##    ##       ##    ##     ## ##       #########
  #    #########    ##       ##    ######### ##       ##     ##
  #    ##     ##    ##       ##    ##     ## ##    ## ##     ##
  #    ##     ##    ##       ##    ##     ##  ######  ##     ##

  isVisible: -> @offsetWidth > 0 or @offsetHeight > 0

  attach: ->
    return if @attached
{'fraction_non_alphanumeric': 0.1824432363287496, 'fraction_numerical': 0.0006395906619763352, 'mean_word_length': 2.2886435331230284, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1522294', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1867, 'n_words': 249}