<commit_before>import _ from 'lodash';
import Atom from './Atom';

/**
* Contains the declaration for the {@link Component} class.
* @module Component
*/
const _events = ["click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "keydown", "keyup"];
const _events_RE = new RegExp('^on\-(' + _events.join('|') + ')');
const args = function () {return arguments};

let _Component_serial_number = 0;

class Component extends Atom {

    constructor(params = {}) {
        super(
              _.assignIn({
                template: '',
                _template: '',
                _a:[],
                _i:[],
                element: undefined,
                directive: undefined,
                on: {}
            }, params || {})
        );

        var e = this.element || this.directive;
        this.$parent = this.$parent || (e && document.querySelector(e));

        this.template = this.template.replace(/[\t\n\r]+/g,'').replace(/\s+/g, ' ');

        this._globalUID = (this.name || "noname") + ':' + _Component_serial_number++;
        antipode['_ap_global'][this._globalUID] = this;
        
        this.init();
        return this;
    }

    /**
    * @private
    */
    insertComponent (component, target) {

        var c = new component.kind(component),
            n = c.name.replace(/_[0-9]+$/, ''),
            nn = n, 
            i = 0;

        while(this.$[nn]) {
            ++i;
            nn = n + '_' + i;
        };

        this.$[nn] = c;
        c.parent = this;

        this.$parent = component.$parent || this.$parent;

        if (this.$parent) {
            var e = document.createElement('c'),
                componentSection = this.$parent.querySelector('components');

            if (!componentSection) {
                componentSection = this.$parent.children[0].appendChild(
                    document.createElement('components')<commit_msg>New features for Component. The addition / exclusion of classes in the field 'classes'.<commit_after>import _ from 'lodash';
import Atom from './Atom';

/**
* Contains the declaration for the {@link Component} class.
* @module Component
*/
const _events = ["click", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout", "keydown", "keyup"];
const _events_RE = new RegExp('^on\-(' + _events.join('|') + ')');
const args = function () {return arguments};

let _Component_serial_number = 0;

class Component extends Atom {

    constructor(params = {}) {

        let classes = ''; 

        if (params.classes) {
            classes = params.classes;
            delete params.classes;
        }

        super(
              _.merge({
                template: '',
                _template: '',
                _a:[],
                _i:[],
                element: undefined,
                directive: undefined,
                on: {}
            }, params || {})
        );

        if (classes) {
            let classes_present = this.get('classes').split(' ');
            let classes_add = classes.split(' ');
            let classes_merge = [];
            if (classes_present.length > 0) {
                let rem = _.filter(classes_add, (i) => /^\-/.test(i)).map((i) => i.replace(/^\-/, ''));
                let add = _.filter(classes_add, (i) => !/^\-/.test(i));
                let after_rem = _.without.apply(null, [classes_present].concat(rem));
                this.set('classes', after_rem.concat(add).join(' '));
            }
        }

        const e = this.element || this.directive;
        this.$parent = this.$parent || (e && document.querySelector(e));

        this.template = this.template.replace(/[\t\n\r]+/g,'').replace(/\s+/g, ' ');

        this._globalUID = (this.name || "noname") + ':' + _Component_serial_number++;
        antipode['_ap_global'][this._globalUID] = this;
        
        this.init();
        return this;
    }

    /**
    * @private
    */
    insertComponent (component, target) {

        let c = new component.kind(component),
            n = c.name.replace(/_[0-9]+$/, ''),
            nn = n, 
            i = 0;

        while(this.$[nn]) {
            ++i;
            nn = n + '_' + i;
        };

        this.$[nn] = c;
        c.parent = this;

        this.$parent = component.$parent || this.$parent;

        if (this.$parent) {
            var e = document.createElement('c'),
                componentSection = this.$parent.querySelector('components');

            if (!componentSection) {
                componentSection = this.$parent.children[0].appendChild(
                    document.createElement('components')
{'fraction_non_alphanumeric': 0.16536458333333334, 'fraction_numerical': 0.002387152777777778, 'mean_word_length': 1.7781796262808922, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5188141', 'n_tokens_mistral': 1336, 'n_tokens_neox': 1280, 'n_words': 277}