<commit_before>var Emitter = require('emitter-component'),
    events = require('chi-events'),
    classes = require('chi-classes'),
    inheritPrototype = require('mout/lang/inheritPrototype'),
    find = require('mout/array/find'),
    forEach = require('mout/array/forEach'),
    remove = require('mout/array/remove');

module.exports = Accordion;

function Accordion(element) {
    Emitter.call(this);

    this.element = element;
    this.selected = null;
    this._sections = [];

    var sections = element.querySelectorAll('.accordion-section');
    forEach(sections, this._add, this);
}

inheritPrototype(Accordion, Emitter);

Accordion.prototype._add = function(el) {
    var self = this,
        header = el.querySelector('.accordion-header'),
        event = events(header).on('click', select);

    function select(e) {
        e.preventDefault();
        self.toggle(el);
    }

    this._sections.push({
        el: el,
        click: event
    });
};

Accordion.prototype.add = function(el) {
    this.element.appendChild(el);
    this._add(el);
};

Accordion.prototype.remove = function(el) {
    var section = find(
        this._sections,
        function(s) { return s.el === el });
    if (!section) {
        return;
    }

    if (this.selected === el) {
        this.select(null);
    }
    section.click.remove();
    remove(this._sections, section);
    this.element.removeChild(el);
};

Accordion.prototype.clear = function() {
    var sections = this._sections.slice();

    forEach(sections,  function(section) {
        this.remove(section.el);
    }, this);
};

Accordion.prototype.toggle = function(section) {
    if (this.selected === section) {
        section = null;
    }

    this.select(section);
};

Accordion.prototype.select = function(section) {
    if (this.selected === section) {<commit_msg>Lint fixes<commit_after>var Emitter = require('emitter-component'),
    events = require('chi-events'),
    classes = require('chi-classes'),
    inheritPrototype = require('mout/lang/inheritPrototype'),
    find = require('mout/array/find'),
    forEach = require('mout/array/forEach'),
    remove = require('mout/array/remove');

module.exports = Accordion;

function Accordion(element) {
    Emitter.call(this);

    this.element = element;
    this.selected = null;
    this._sections = [];

    var sections = element.querySelectorAll('.accordion-section');
    forEach(sections, this._add, this);
}

inheritPrototype(Accordion, Emitter);

Accordion.prototype._add = function(el) {
    var self = this,
        header = el.querySelector('.accordion-header'),
        event = events(header).on('click', select);

    function select(e) {
        e.preventDefault();
        self.toggle(el);
    }

    this._sections.push({
        el: el,
        click: event
    });
};

Accordion.prototype.add = function(el) {
    this.element.appendChild(el);
    this._add(el);
};

Accordion.prototype.remove = function(el) {
    var section = find(
        this._sections,
        function(s) { return s.el === el; });
    if (!section) {
        return;
    }

    if (this.selected === el) {
        this.select(null);
    }
    section.click.remove();
    remove(this._sections, section);
    this.element.removeChild(el);
};

Accordion.prototype.clear = function() {
    var sections = this._sections.slice();

    forEach(sections,  function(section) {
        this.remove(section.el);
    }, this);
};

Accordion.prototype.toggle = function(section) {
    if (this.selected === section) {
        section = null;
    }

    this.select(section);
};

Accordion.prototype.select = function(section) {
    if (this.selected === section) {
{'fraction_non_alphanumeric': 0.15441176470588236, 'fraction_numerical': 0.0, 'mean_word_length': 2.966522678185745, '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': '3324813', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1117, 'n_words': 199}