import { s as setMode } from './index-102a6ed2.js';
import { U as UUID } from './uuid-a982202a.js';
import { F as FileManager } from './file-manager-74eecfa2.js';

var bce = {
    file: FileManager.inMemory(),
    generateId: function () { return UUID.v4(); },
    FileManager: FileManager
};
var main = function () {
    // Setup global config
    window.BCE = window.BCE || bce;
    setMode(function (el) {
        // Component specific mode's (e.g. bce-button within bce-fab)
        if (chain(el, 'bce-button', 'bce-fab'))
            return 'bce-fab';
        if (chain(el, 'bce-button', 'bce-menu'))
            return 'bce-menu';
        if (chain(el, 'bce-link', 'bce-link'))
            return 'bce-link';
        if (chain(el, 'bce-nav', 'bce-header'))
            return 'bce-header';
        if (chain(el, 'bce-nav', 'bce-side-bar'))
            return 'bce-side-bar';
        var root = el.closest('bce-root');
        return el.getAttribute('mode') || (root && root.mode) || 'default';
    });
};
var chain = function (el, child) {
    var parents = [];
    for (var _i = 2; _i < arguments.length; _i++) {
        parents[_i - 2] = arguments[_i];
    }
    if (!el.matches(child))
        return false;
    for (var _a = 0, parents_1 = parents; _a < parents_1.length; _a++) {
        var parent = parents_1[_a];
        var cur = el.parentElement;
        if (!cur || !cur.matches(parent))
            return false;
        el = cur;
    }
    return true;
};

const globalScripts = main;

export { globalScripts as g };
