<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')

const ImmutableComponent = require('./immutableComponent')

const windowActions = require('../actions/windowActions')
const dragTypes = require('../constants/dragTypes')
const cx = require('../lib/classSet.js')
const {getTextColorForBackground} = require('../lib/color')

const contextMenus = require('../contextMenus')
const dnd = require('../dnd')

class Tab extends ImmutableComponent {
  get isPinned () {
    return !!this.props.frameProps.get('pinnedLocation')
  }

  get draggingOverData () {
    if (!this.props.draggingOverData ||
        this.props.draggingOverData.get('dragOverKey') !== this.props.frameProps.get('key')) {
      return
    }

    return this.props.draggingOverData
  }

  get isDragging () {
    const sourceDragData = dnd.getInProcessDragData()
    return sourceDragData && this.props.frameProps.get('key') === sourceDragData.get('key')
  }

  get isDraggingOverLeft () {
    if (!this.draggingOverData) {
      return false
    }
    return this.draggingOverData.get('draggingOverLeftHalf')
  }

  get isDraggingOverRight () {
    if (!this.draggingOverData) {
      return false
    }
    return this.draggingOverData.get('draggingOverRightHalf')
  }

  get displayValue () {
    // YouTube tries to change the title to add a play icon when
    // there is audio. Since we have our own audio indicator we get
    // rid of it.
    return (this.props.frameProps.get('title') ||
      this.props.frameProps.get('location')).replace('▶ ', '')
  }

  onDragStart (e) {
    dnd.onDragStart(dragTypes.TAB, this.props.frameProps, e)
  }

  onDragEnd (e) {
    dnd.onDragEnd(dragTypes.TAB, this.props.frameProps, e)
  }

  onDragOver (e) {
    dnd.onDragOver(dragTypes.TAB, this.tab.getBoundingClientRect(), this.props.frameProps.get('key'), this.draggingOverData, e)
  }

  setActiveFrame () {
    windowActions.setActiveFrame(this.props.frameProps)
  }

  onCloseFrame (event) {
    event.stopPropagation()
    windowActions.closeFrame(this.props.frames, this.props.frameProps)
  }

  onMuteFrame (muted) {
    windowActions.setAudioMuted(this.props.frameProps, muted)
  }

  get loading () {
    return this.props.frameProps &&
    this.props.frameProps.get('loading') &&
    (!this.props.frameProps.get('provisionalLocation') ||
    !this.props.frameProps.get('provisionalLocation').startsWith('chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/'))
  }

  onMouseLeave () {
    window.clearTimeout(this.hoverTimeout)
    this.lastPreviewClearTime = new Date().getTime()
    windowActions.setPreviewFrame(null)
  }

  onMouseEnter () {
    // If a user has recently seen a preview they likely are scrolling through<commit_msg>mute/unmute audio without activating tab<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */

const React = require('react')

const ImmutableComponent = require('./immutableComponent')

const windowActions = require('../actions/windowActions')
const dragTypes = require('../constants/dragTypes')
const cx = require('../lib/classSet.js')
const {getTextColorForBackground} = require('../lib/color')

const contextMenus = require('../contextMenus')
const dnd = require('../dnd')

class Tab extends ImmutableComponent {
  get isPinned () {
    return !!this.props.frameProps.get('pinnedLocation')
  }

  get draggingOverData () {
    if (!this.props.draggingOverData ||
        this.props.draggingOverData.get('dragOverKey') !== this.props.frameProps.get('key')) {
      return
    }

    return this.props.draggingOverData
  }

  get isDragging () {
    const sourceDragData = dnd.getInProcessDragData()
    return sourceDragData && this.props.frameProps.get('key') === sourceDragData.get('key')
  }

  get isDraggingOverLeft () {
    if (!this.draggingOverData) {
      return false
    }
    return this.draggingOverData.get('draggingOverLeftHalf')
  }

  get isDraggingOverRight () {
    if (!this.draggingOverData) {
      return false
    }
    return this.draggingOverData.get('draggingOverRightHalf')
  }

  get displayValue () {
    // YouTube tries to change the title to add a play icon when
    // there is audio. Since we have our own audio indicator we get
    // rid of it.
    return (this.props.frameProps.get('title') ||
      this.props.frameProps.get('location')).replace('▶ ', '')
  }

  onDragStart (e) {
    dnd.onDragStart(dragTypes.TAB, this.props.frameProps, e)
  }

  onDragEnd (e) {
    dnd.onDragEnd(dragTypes.TAB, this.props.frameProps, e)
  }

  onDragOver (e) {
    dnd.onDragOver(dragTypes.TAB, this.tab.getBoundingClientRect(), this.props.frameProps.get('key'), this.draggingOverData, e)
  }

  setActiveFrame () {
    windowActions.setActiveFrame(this.props.frameProps)
  }

  onCloseFrame (event) {
    event.stopPropagation()
    windowActions.closeFrame(this.props.frames, this.props.frameProps)
  }

  onMuteFrame (muted, event) {
    event.stopPropagation()
    windowActions.setAudioMuted(this.props.frameProps, muted)
  }

  get loading () {
    return this.props.frameProps &&
    this.props.frameProps.get('loading') &&
    (!this.props.frameProps.get('provisionalLocation') ||
    !this.props.frameProps.get('provisionalLocation').startsWith('chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/'))
  }

  onMouseLeave () {
    window.clearTimeout(this.hoverTimeout)
    this.lastPreviewClearTime = new Date().getTime()
    windowActions.setPreviewFrame(null)
  }

  onMouseEnter () {
    // If a user has recently seen a preview they likely are scrolling through
{'fraction_non_alphanumeric': 0.13150731541340593, 'fraction_numerical': 0.0013610071452875127, 'mean_word_length': 3.662172878667724, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '470466', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1846, 'n_words': 381}