<commit_before>define [
  'backbone'
  'cs!collections/media-types'
  'cs!collections/content'
  'cs!mixins/loadable'
  'cs!models/utils'
  'cs!gh-book/xhtml-file'
  'cs!gh-book/toc-node'
  'cs!gh-book/toc-pointer-node'
  'cs!gh-book/uuid'
  'hbs!templates/gh-book/defaults/opf'
  'hbs!templates/gh-book/defaults/nav'
  'hbs!templates/gh-book/nav-body-metadata'
  'hbs!templates/gh-book/nav-head-metadata'
], (
  Backbone,
  mediaTypes,
  allContent,
  loadable,
  Utils,
  XhtmlFile,
  TocNode,
  TocPointerNode,
  uuid,
  defaultOpf,
  defaultNav,
  navBodyMetadata,
  navHeadMetadata
) ->

  SAVE_DELAY = 10 # ms

  # Mix in the loadable
  return class PackageFile extends (TocNode.extend loadable)
    serializer = new XMLSerializer()

    mediaType: 'application/oebps-package+xml'
    accept: [XhtmlFile::mediaType, TocNode::mediaType]

    branch: true # This element will show up in the sidebar listing

    addAction: =>
      @triggerMetadataEdit()

    triggerMetadataEdit: =>
      require ['cs!views/layouts/workspace/bookshelf'], (Bookshelf) =>
        Bookshelf::editBook(@)

    initialize: (options) ->
      options.root = @

      @$xml = $($.parseXML defaultOpf(options))

      # Give the content an id if it does not already have one
      if not @id
        @setNew()
        @id = "content/#{uuid(@get('title'))}.opf"
        @$xml.find('#uid').text(uuid(@get('title')))

     # For TocNode, let it know this is the root
      super options

      # Contains all entries in the OPF file (including images)
      @manifest = new Backbone.Collection()
      # Contains all items in the ToC (including internal nodes like "Chapter 3")
      @tocNodes = new Backbone.Collection()
      @tocNodes.add @

      # Use the `parse:true` option instead of `loading:true` because
      # Backbone sets this option when a model is being parsed.
      # This way we can ignore firing events when Backbone is parsing as well as
      # when we are internally updating models.
      setNavModel = (options) =>
        console.log 'here'
        if not options.doNotReparse
          console.log 'here2'
          options.doNotReparse = true
          @navModel.set 'head', @_serializeNavModelHead(), options
          @navModel.set 'body', @_serializeNavModelBody(), options<commit_msg>remove console.logs in the opf<commit_after>define [
  'backbone'
  'cs!collections/media-types'
  'cs!collections/content'
  'cs!mixins/loadable'
  'cs!models/utils'
  'cs!gh-book/xhtml-file'
  'cs!gh-book/toc-node'
  'cs!gh-book/toc-pointer-node'
  'cs!gh-book/uuid'
  'hbs!templates/gh-book/defaults/opf'
  'hbs!templates/gh-book/defaults/nav'
  'hbs!templates/gh-book/nav-body-metadata'
  'hbs!templates/gh-book/nav-head-metadata'
], (
  Backbone,
  mediaTypes,
  allContent,
  loadable,
  Utils,
  XhtmlFile,
  TocNode,
  TocPointerNode,
  uuid,
  defaultOpf,
  defaultNav,
  navBodyMetadata,
  navHeadMetadata
) ->

  SAVE_DELAY = 10 # ms

  # Mix in the loadable
  return class PackageFile extends (TocNode.extend loadable)
    serializer = new XMLSerializer()

    mediaType: 'application/oebps-package+xml'
    accept: [XhtmlFile::mediaType, TocNode::mediaType]

    branch: true # This element will show up in the sidebar listing

    addAction: =>
      @triggerMetadataEdit()

    triggerMetadataEdit: =>
      require ['cs!views/layouts/workspace/bookshelf'], (Bookshelf) =>
        Bookshelf::editBook(@)

    initialize: (options) ->
      options.root = @

      @$xml = $($.parseXML defaultOpf(options))

      # Give the content an id if it does not already have one
      if not @id
        @setNew()
        @id = "content/#{uuid(@get('title'))}.opf"
        @$xml.find('#uid').text(uuid(@get('title')))

     # For TocNode, let it know this is the root
      super options

      # Contains all entries in the OPF file (including images)
      @manifest = new Backbone.Collection()
      # Contains all items in the ToC (including internal nodes like "Chapter 3")
      @tocNodes = new Backbone.Collection()
      @tocNodes.add @

      # Use the `parse:true` option instead of `loading:true` because
      # Backbone sets this option when a model is being parsed.
      # This way we can ignore firing events when Backbone is parsing as well as
      # when we are internally updating models.
      setNavModel = (options) =>
        if not options.doNotReparse
          options.doNotReparse = true
          @navModel.set 'head', @_serializeNavModelHead(), options
          @navModel.set 'body', @_serializeNavModelBody(), options
{'fraction_non_alphanumeric': 0.11802197802197802, 'fraction_numerical': 0.0015384615384615385, 'mean_word_length': 3.048932384341637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '1984362', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1438, 'n_words': 373}