<commit_before>/**
 * Main mixin for the Bolt module.
 *
 * @mixin
 * @namespace Bolt.app
 *
 * @param {Object} bolt - The Bolt module.
 * @param {Object} $ - jQuery.
 * @param {Object} moment - moment.js.
 * @param {Object} init - Bolts deprectated init object.
 */
(function (bolt, $, moment, init) {
    'use strict';

    /**
     * Bolt.app mixin container.
     *
     * @private
     * @type {Object}
     */
    var app = {};

    /**
     * Next unique Bolt ID to serve by the ID generator.
     *
     * @private
     * @type {integer}
     */
    var buid = 10000;

    /**
     * Loading state of Google Maps API.
     *
     * Values: undefined: initial state; false: pending; true: loaded.
     *
     * @private
     * @type {boolean|undefined}
     */
    var gMapsApiLoaded;

    /**
     * Callback that signals that Google Maps API is fully loaded.
     *
     * See: https://developers.google.com/maps/documentation/javascript/tutorial#asynch
     *
     * @function gMapsApiReady
     * @memberof Bolt.app
     */
    app.gMapsApiReady = function () {
        gMapsApiLoaded = true;
        $(bolt).trigger('bolt:gmaps-loaded');
    };

    /**
     * Initializes and then starts the Bolt module.
     * Is automatically executed on jQueries ``$(document).ready()``.
     *
     * @function run
     * @memberof Bolt.app
     */
    app.run = function () {
        bolt.conf.init();
        bolt.data.init();

        buid = bolt.conf('buid').match(/(\d+)$/)[1];

        initGlobal();
        initHandler();

        bolt.actions.init();
        bolt.secmenu.init();
        bolt.stack.init();
        bolt.filebrowser.init();
        bolt.omnisearch.init();
        bolt.extend.init();

        bolt.ckeditor.init();
        bolt.datetime.init();

        legacyInit();
        bolt.app.initWidgets();
        bolt.fields.init();
    };

    /**
     * Returns an unique Bolt ID.
     *
     * @function buid
     * @memberof Bolt.app
     */
    app.buid = function () {
        return 'buid-' + buid++;
    };

    /**
     * Initializes all bolt widgets in the given context or global.
     *
     * @function initWidgets
     * @memberof Bolt.app
     * @param {Object} context -
     */
    app.initWidgets = function (context) {
        if (typeof context === 'undefined') {
            context = $(document.documentElement);
        }

        // Widgets initialisations
        $('[data-widget]', context).each(function () {
            $(this)[$(this).data('widget')]()
                .removeAttr('data-widget')
                .removeData('widget');
        });
    };

    /*
     * Start when ready.
     */
    $(document).ready(app.run);

    /**
     * Legacy stuff from start.js.
     *
     * @private
     * @static<commit_msg>Automatically inject field config into widget options<commit_after>/**
 * Main mixin for the Bolt module.
 *
 * @mixin
 * @namespace Bolt.app
 *
 * @param {Object} bolt - The Bolt module.
 * @param {Object} $ - jQuery.
 * @param {Object} moment - moment.js.
 * @param {Object} init - Bolts deprectated init object.
 */
(function (bolt, $, moment, init) {
    'use strict';

    /**
     * Bolt.app mixin container.
     *
     * @private
     * @type {Object}
     */
    var app = {};

    /**
     * Next unique Bolt ID to serve by the ID generator.
     *
     * @private
     * @type {integer}
     */
    var buid = 10000;

    /**
     * Loading state of Google Maps API.
     *
     * Values: undefined: initial state; false: pending; true: loaded.
     *
     * @private
     * @type {boolean|undefined}
     */
    var gMapsApiLoaded;

    /**
     * Callback that signals that Google Maps API is fully loaded.
     *
     * See: https://developers.google.com/maps/documentation/javascript/tutorial#asynch
     *
     * @function gMapsApiReady
     * @memberof Bolt.app
     */
    app.gMapsApiReady = function () {
        gMapsApiLoaded = true;
        $(bolt).trigger('bolt:gmaps-loaded');
    };

    /**
     * Initializes and then starts the Bolt module.
     * Is automatically executed on jQueries ``$(document).ready()``.
     *
     * @function run
     * @memberof Bolt.app
     */
    app.run = function () {
        bolt.conf.init();
        bolt.data.init();

        buid = bolt.conf('buid').match(/(\d+)$/)[1];

        initGlobal();
        initHandler();

        bolt.actions.init();
        bolt.secmenu.init();
        bolt.stack.init();
        bolt.filebrowser.init();
        bolt.omnisearch.init();
        bolt.extend.init();

        bolt.ckeditor.init();
        bolt.datetime.init();

        legacyInit();
        bolt.app.initWidgets();
        bolt.fields.init();
    };

    /**
     * Returns an unique Bolt ID.
     *
     * @function buid
     * @memberof Bolt.app
     */
    app.buid = function () {
        return 'buid-' + buid++;
    };

    /**
     * Initializes all bolt widgets in the given context or global.
     *
     * @function initWidgets
     * @memberof Bolt.app
     * @param {Object} context -
     */
    app.initWidgets = function (context) {
        if (typeof context === 'undefined') {
            context = $(document.documentElement);
        }

        // Initialze all uninitialized widgets.
        $('[data-widget]', context).each(function () {
            var element = $(this);

            element[element.data('widget')](element.data('bolt-fconf') || {})
                .removeAttr('data-widget')
                .removeData('widget');
        });
    };

    /*
     * Start when ready.
     */
    $(document).ready(app.run);

    /**
     * Legacy stuff from start.js.
     *
     * @private
     * @static
{'fraction_non_alphanumeric': 0.14949637745184663, 'fraction_numerical': 0.002120515992224775, 'mean_word_length': 1.8005937654626423, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1649373', 'n_tokens_mistral': 1786, 'n_tokens_neox': 1718, 'n_words': 396}