<commit_before>/*jslint plusplus: true */
/*global hilary, jQuery, nicephore*/

// Gutentyp - composition root

hilary.use([hilary, jQuery, window, nicephore], function (hilarysInnerContainer, hilary, $, window, nicephore) {
    "use strict";
    var gutentyp;
    
    gutentyp = function () {
        var self = {},
            prep,
            gutenContainer,
            config,
            dom,
            pipeline,
            components,
            toolbar,
            transformer,
            tryResolveComponent,
            componentsAreRegistered = false;

        gutenContainer = hilary.createChildContainer();

        tryResolveComponent = function (moduleName) {
            var modul = gutenContainer.tryResolve(moduleName);

            if (modul) {
                modul.init(components, config, dom);
            }
        };

        prep = function () {
            // Constants & settings
            config = gutenContainer.resolve('gutentyp::config')
                .init();

            /*
            * the configuration constants for gutentyp
            */
            self.config = config;

            // Initialize the base utilities required by this library
            dom = gutenContainer.resolve('gutentyp::dom')
                .init($, config);

            // Initialize the content pipeline, which pipes the editing functions with common helper functions
            pipeline = gutenContainer.resolve('gutentyp::pipeline')
                .init(config, dom);

            /*
            * the pipeline for gutentyp. you can register before and after handlers for all
            * or specific components using this pipeline
            */
            self.pipeline = pipeline.registerPipelineEvent;

            // Initalize the component that controls the editing functions that are provided to the rich text area
            components = gutenContainer.resolve('gutentyp::components')
                .init(config, dom, pipeline);
        };

        // DEFAULT PREPARATION
        prep();
        
        self.registerComponents = function (options) {
            var i;
            options = options || {};
            
            if (options.autoRegisterComponents === undefined) {
                options.autoRegisterComponents = true;
            }
            
            if (options.autoRegisterComponents) {
                // resolve components
                tryResolveComponent('gutentyp::components::emphasis');
                tryResolveComponent('gutentyp::components::colors');
                tryResolveComponent('gutentyp::components::headings');
                tryResolveComponent('gutentyp::components::justification');
                tryResolveComponent('gutentyp::components::lists');
                tryResolveComponent('gutentyp::components::blocks');
                tryResolveComponent('gutentyp::components::link');
                tryResolveComponent('gutentyp::components::image');
                tryResolveComponent('gutentyp::components::embed');
            }
            
            if (options.components) {
                for (i = 0; i < options.components.length; i++) {
                    self.registerComponent(options.components[i]);
                }
            }
            
            componentsAreRegistered = true;
        };

        /*
        * initializes gutentyp
        */
        self.init = function (options) {
            var events;
            
            if (!componentsAreRegistered) {
                self.registerComponents(options);
                if (nicephore) {
                    events = gutenContainer.tryResolve('gutentyp::keyEvents');
                    
                    if (events) {
                        events.init(config, dom, nicephore);
                    }
                }
            }
            
            // Build the toolbar and append it to the rich text area
            toolbar = gutenContainer.resolve('gutentyp::toolbar')
                .init(config, dom, components);

            // Initialize the core component
            transformer = gutenContainer.resolve('gutentyp::transformer')
                .init(config, dom, components, toolbar);

            transformer.transform();

            return self;
        };

        /*
        * registers a component (i.e. typography button) in gutentyp. this should be
        * executed prior to activate, otherwise the component will not be used until the next<commit_msg>passes options to transformer<commit_after>/*jslint plusplus: true */
/*global hilary, jQuery, nicephore*/

// Gutentyp - composition root

hilary.use([hilary, jQuery, window, nicephore], function (hilarysInnerContainer, hilary, $, window, nicephore) {
    "use strict";
    var gutentyp;
    
    gutentyp = function () {
        var self = {},
            prep,
            gutenContainer,
            config,
            dom,
            pipeline,
            components,
            toolbar,
            transformer,
            tryResolveComponent,
            componentsAreRegistered = false;

        gutenContainer = hilary.createChildContainer();

        tryResolveComponent = function (moduleName) {
            var modul = gutenContainer.tryResolve(moduleName);

            if (modul) {
                modul.init(components, config, dom);
            }
        };

        prep = function () {
            // Constants & settings
            config = gutenContainer.resolve('gutentyp::config')
                .init();

            /*
            * the configuration constants for gutentyp
            */
            self.config = config;

            // Initialize the base utilities required by this library
            dom = gutenContainer.resolve('gutentyp::dom')
                .init($, config);

            // Initialize the content pipeline, which pipes the editing functions with common helper functions
            pipeline = gutenContainer.resolve('gutentyp::pipeline')
                .init(config, dom);

            /*
            * the pipeline for gutentyp. you can register before and after handlers for all
            * or specific components using this pipeline
            */
            self.pipeline = pipeline.registerPipelineEvent;

            // Initalize the component that controls the editing functions that are provided to the rich text area
            components = gutenContainer.resolve('gutentyp::components')
                .init(config, dom, pipeline);
        };

        // DEFAULT PREPARATION
        prep();
        
        self.registerComponents = function (options) {
            var i;
            options = options || {};
            
            if (options.autoRegisterComponents === undefined) {
                options.autoRegisterComponents = true;
            }
            
            if (options.autoRegisterComponents) {
                // resolve components
                tryResolveComponent('gutentyp::components::emphasis');
                tryResolveComponent('gutentyp::components::colors');
                tryResolveComponent('gutentyp::components::headings');
                tryResolveComponent('gutentyp::components::justification');
                tryResolveComponent('gutentyp::components::lists');
                tryResolveComponent('gutentyp::components::blocks');
                tryResolveComponent('gutentyp::components::link');
                tryResolveComponent('gutentyp::components::image');
                tryResolveComponent('gutentyp::components::embed');
            }
            
            if (options.components) {
                for (i = 0; i < options.components.length; i++) {
                    self.registerComponent(options.components[i]);
                }
            }
            
            componentsAreRegistered = true;
        };

        /*
        * initializes gutentyp
        */
        self.init = function (options) {
            var events;
            
            if (!componentsAreRegistered) {
                self.registerComponents(options);
                if (nicephore) {
                    events = gutenContainer.tryResolve('gutentyp::keyEvents');
                    
                    if (events) {
                        events.init(config, dom, nicephore);
                    }
                }
            }
            
            // Build the toolbar and append it to the rich text area
            toolbar = gutenContainer.resolve('gutentyp::toolbar')
                .init(config, dom, components);

            // Initialize the core component
            transformer = gutenContainer.resolve('gutentyp::transformer')
                .init(config, dom, components, toolbar, options);

            transformer.transform();

            return self;
        };

        /*
        * registers a component (i.e. typography button) in gutentyp. this should be
        * executed prior to activate, otherwise the component will not be used until the next
{'fraction_non_alphanumeric': 0.09056561840204468, 'fraction_numerical': 0.00022224691632403602, 'mean_word_length': 1.598902685532775, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2712895', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2016, 'n_words': 499}