<commit_before>{View} = require 'space-pen'
$ = require 'jquery'
_ = require 'underscore'
telepath = require 'telepath'
PaneRow = require 'pane-row'
PaneColumn = require 'pane-column'

module.exports =
class Pane extends View

  ### Internal ###
  @acceptsDocuments: true

  @content: (wrappedView) ->
    @div class: 'pane', =>
      @div class: 'item-views', outlet: 'itemViews'

  @deserialize: (state) ->
    pane = new Pane(state)
    pane.focusOnAttach = true if state.get('focused')
    pane

  activeItem: null
  items: null
  viewsByClassName: null
  viewsByItem: null

  initialize: (args...) ->
    if args[0] instanceof telepath.Document
      @state = args[0]
      @items = @state.get('items').map (item) -> deserialize(item)
    else
      @items = args
      @state = telepath.Document.create
        deserializer: 'Pane'
        items: @items.map (item) -> item.getState?() ? item.serialize()

    @state.get('items').observe ({index, removed, inserted, site}) =>
      return if site is @state.site.id
      for itemState in removed
        @removeItemAtIndex(index, updateState: false)
      for itemState, i in inserted<commit_msg>Add comments to view cache ivars<commit_after>{View} = require 'space-pen'
$ = require 'jquery'
_ = require 'underscore'
telepath = require 'telepath'
PaneRow = require 'pane-row'
PaneColumn = require 'pane-column'

module.exports =
class Pane extends View

  ### Internal ###
  @acceptsDocuments: true

  @content: (wrappedView) ->
    @div class: 'pane', =>
      @div class: 'item-views', outlet: 'itemViews'

  @deserialize: (state) ->
    pane = new Pane(state)
    pane.focusOnAttach = true if state.get('focused')
    pane

  activeItem: null
  items: null
  viewsByClassName: null # Views with a setModel() method are stored here
  viewsByItem: null      # Views without a setModel() method are stored here

  initialize: (args...) ->
    if args[0] instanceof telepath.Document
      @state = args[0]
      @items = @state.get('items').map (item) -> deserialize(item)
    else
      @items = args
      @state = telepath.Document.create
        deserializer: 'Pane'
        items: @items.map (item) -> item.getState?() ? item.serialize()

    @state.get('items').observe ({index, removed, inserted, site}) =>
      return if site is @state.site.id
      for itemState in removed
        @removeItemAtIndex(index, updateState: false)
      for itemState, i in inserted
{'fraction_non_alphanumeric': 0.1326740832303255, 'fraction_numerical': 0.0016481252575195715, 'mean_word_length': 3.2079722703639515, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '3699693', 'n_tokens_mistral': 774, 'n_tokens_neox': 753, 'n_words': 216}