doctype html
html
    include includes/head.pug
    body.maximized(data-manage-window)
        include ../../app/data/icons.svg
        root-tag
        div#theLoadingScreen Loading…
        script.
            try {
                require('gulp');
                /* eslint no-console: 0 */
                console.log(`
            ╭──────────────────────────────────────────╮
            │                                          ├──╮
            │           O-o-oh, a developer!           │  │
            │                                          │  │
            │   If you have recently pulled changes    │  │
            │   and face issues unseen before, run     │  │
            │   this command in your console:          │  │
            │                                          │  │
            │   $ gulp -f devSetup.gulpfile.js         │  │
            │                                          │  │
            ╰─┬────────────────────────────────────────╯  │
              ╰───────────────────────────────────────────╯
                `);
            } catch (e) {
                void e;
            }
        script.
            process.versions.ctjs = require('./package.json').version;
        script.
            // A polyfill for different nw.js versions
            if (!window.__dirname) {
                window.__dirname = global.__dirname;
            }
        script(src="data/bundle.js")
        script.
            'use strict';
            window.signals = window.signals || riot.observable({});
            window.orders = window.orders || riot.observable({});
            // ⚠️⚠️⚠️ BAND-AIDS START

            // @see https://github.com/pixijs/particle-emitter/issues/209
            {
                const hexToRGB = (color, output) => {
                    if (!output) {
                        output = {};
                    }
                    if (color.charAt(0) === '#') {
                        color = color.substr(1);
                    } else if (color.indexOf('0x') === 0) {
                        color = color.substr(2);
                    }
                    let alpha;
                    if (color.length === 8) {
                        alpha = color.substr(0, 2);
                        color = color.substr(2);
                    }
                    output.r = parseInt(color.substr(0, 2), 16); // Red
                    output.g = parseInt(color.substr(2, 2), 16); // Green
                    output.b = parseInt(color.substr(4, 2), 16); // Blue
                    if (alpha) {
                        output.a = parseInt(alpha, 16);
                    }
                    return output;
                };
                /* eslint-disable id-blacklist */
                PIXI.particles.PropertyNode.createList = (data) => {
                    const array = data.list;
                    let node;
                    // eslint-disable-next-line prefer-destructuring
                    const {value, time} = array[0];
                    // eslint-disable-next-line max-len
                    const first = node = new PIXI.particles.PropertyNode(typeof value === 'string' ? hexToRGB(value) : value, time, data.ease);
                    // only set up subsequent nodes if there are a bunch of them
                    if (array.length > 1) {
                        for (let i = 1; i < array.length; ++i) {
                            const {value, time} = array[i];
                            node.next = new PIXI.particles.PropertyNode(typeof value === 'string' ? hexToRGB(value) : value, time);
                            node = node.next;
                        }
                    }
                    first.isStepped = Boolean(data.isStepped);
                    return first;
                };
                /* eslint-enable id-blacklist */
            }
            // @see https://github.com/pixijs/pixijs/issues/9495
            window.PIXI.particles.Particle.prototype.isInteractive = () => false;

            // ⚠️⚠️⚠️ BAND-AIDS END
            riot.mount('*');
            setTimeout(() => {
                document.getElementById('theLoadingScreen').remove();
            }, 0);
