<commit_before>var NgnCycle = document.registerElement('chassis-cycle', { // eslint-disable-line no-unused-vars
  prototype: Object.create(HTMLElement.prototype, { // eslint-disable-line no-undef
    initTpl: {
      enumerable: false,
      value: function () {
        var tag = 'chassis-cycle'
        var src = document.querySelector('script[src*="' + tag + '"]') || document.querySelector('link[href*="' + tag + '.html"]')

        document.body.classList.add('chassis')

        if (src) {
          src = (src.hasAttribute('src') ? src.getAttribute('src') : src.getAttribute('href')).replace(/\\/g, '/')
          src = src.split('/')
          src.pop()
          src = src.join('/') + '/template.html'
          var req = new XMLHttpRequest()
          var me = this
          req.addEventListener('load', function () {
            var content = this.responseText.replace(/\n|\s+/g, ' ').replace(/\s\s/g, ' ').replace(/<(\/?)template(.*?)>/gi, '')
            var shadow = me.createShadowRoot()
            var ph = document.createElement('p')
            ph.insertAdjacentHTML('afterbegin', content)
            Array.prototype.slice.call(ph.children).forEach(function (el) {
              shadow.appendChild(document.importNode(el, true))
            })
          })
          req.open('GET', src)
          req.send()
        } else {
          this.createShadowRoot()
        }
      }
    },

    createdCallback: {
      value: function () {
        this.initTpl()

        // Identify active element
        Object.defineProperty(this, 'active', {
          enumerable: false,
          writable: true,
          configurable: false,
          value: 0
        })

        // Forcibly hide non-active elements
        var me = this
        for (var i=0; i < this.children.length; i++) {
          if (['', 'true'].indexOf(this.children[i].getAttribute('selected')) >= 0) {
            // Active
            this.active = i
            if (/none/gi.test(this.children[i].style.display)) {
              this.children[i].style.display = ''
            }
          } else {
            // Inactive
            me.processChildStyles(this.children[i])
          }
        }

        // Watch for new children and apply styles appropriately.
        var observer = new MutationObserver(function (mutations) {
          mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
              if (mutation.addedNodes.length > 0) {
                me.processChildStyles(mutation.addedNodes[0])
              }
              if (mutation.removedNodes.length > 0) {
                if (!me.selected) {
                  me.previous()
                }
              }
            }
          })
        })

        observer.observe(this, {
          attributes: false,
          childList: true,
          characterData: false
        })
      }
    },

    /**
     * @method processChildStyles
     * Make the child element a part of the component.
     * @param {HTMLElement} element
     * The HTML element to start managing as a cycle pane.
     * @private
     */
    processChildStyles: {
      enumerable: false,
      value: function (element) {
        var style = ''
        if (element && element.getAttribute && element.getAttribute('style')) {
          style = element.getAttribute('style')
        }

        style = (style + (style.length > 0 ? ';' : '') + "display: none !important;").replace(/;{2,10}/gi, ';')

        element.setAttribute('style', style)
      }
    },

    /**
     * @property selected
     * The current active section.<commit_msg>Ignore text nodes and document fragments when observing changes to chassis-cycle children.<commit_after>var NgnCycle = document.registerElement('chassis-cycle', { // eslint-disable-line no-unused-vars
  prototype: Object.create(HTMLElement.prototype, { // eslint-disable-line no-undef
    initTpl: {
      enumerable: false,
      value: function () {
        var tag = 'chassis-cycle'
        var src = document.querySelector('script[src*="' + tag + '"]') || document.querySelector('link[href*="' + tag + '.html"]')

        document.body.classList.add('chassis')

        if (src) {
          src = (src.hasAttribute('src') ? src.getAttribute('src') : src.getAttribute('href')).replace(/\\/g, '/')
          src = src.split('/')
          src.pop()
          src = src.join('/') + '/template.html'
          var req = new XMLHttpRequest()
          var me = this
          req.addEventListener('load', function () {
            var content = this.responseText.replace(/\n|\s+/g, ' ').replace(/\s\s/g, ' ').replace(/<(\/?)template(.*?)>/gi, '')
            var shadow = me.createShadowRoot()
            var ph = document.createElement('p')
            ph.insertAdjacentHTML('afterbegin', content)
            Array.prototype.slice.call(ph.children).forEach(function (el) {
              shadow.appendChild(document.importNode(el, true))
            })
          })
          req.open('GET', src)
          req.send()
        } else {
          this.createShadowRoot()
        }
      }
    },

    createdCallback: {
      value: function () {
        this.initTpl()

        // Identify active element
        Object.defineProperty(this, 'active', {
          enumerable: false,
          writable: true,
          configurable: false,
          value: 0
        })

        // Forcibly hide non-active elements
        var me = this
        for (var i=0; i < this.children.length; i++) {
          if (['', 'true'].indexOf(this.children[i].getAttribute('selected')) >= 0) {
            // Active
            this.active = i
            if (/none/gi.test(this.children[i].style.display)) {
              this.children[i].style.display = ''
            }
          } else {
            // Inactive
            me.processChildStyles(this.children[i])
          }
        }

        // Watch for new children and apply styles appropriately.
        var observer = new MutationObserver(function (mutations) {
          mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
              if (mutation.addedNodes.length > 0) {
                if (mutation.addedNodes[0].nodeType === Node.ELEMENT_NODE) {
                  me.processChildStyles(mutation.addedNodes[0])
                }
              }

              if (mutation.removedNodes.length > 0) {
                if (!me.selected) {
                  me.previous()
                }
              }
            }
          })
        })

        observer.observe(this, {
          attributes: false,
          childList: true,
          characterData: false
        })
      }
    },

    /**
     * @method processChildStyles
     * Make the child element a part of the component.
     * @param {HTMLElement} element
     * The HTML element to start managing as a cycle pane.
     * @private
     */
    processChildStyles: {
      enumerable: false,
      value: function (element) {
        var style = element.getAttribute('style') || ''

        style = (style + (style.length > 0 ? ';' : '') + "display: none !important;").replace(/;{2,10}/gi, ';')

        element.setAttribute('style', style)
      }
    },

    /**
     * @property selected
     * The current active section.
{'fraction_non_alphanumeric': 0.14295523207909916, 'fraction_numerical': 0.0028838231255149684, 'mean_word_length': 1.7328330206378988, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, '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': '7189216', 'n_tokens_mistral': 2040, 'n_tokens_neox': 2007, 'n_words': 404}