require([
    URL_OPT_DIR + 'bin/quiqqer-asset/animejs/animejs/lib/anime.min.js',
    'css!package/ecoyn/core/bin/installationFinish'
], function (anime) {
    "use strict";

    const nodes = [
        document.querySelector('.wizard-content'),
        document.querySelector('.wizard-steps'),
        document.querySelector('.wizard-process'),
        document.querySelector('.wizard-show-process')
    ];

    anime({
        targets : nodes,
        duration: 500,
        opacity : 0,
        left    : -20,
        easing  : 'easeOutSine',
        complete: function () {
            nodes.forEach(function (n) {
                n.parentNode.removeChild(n);
            });

            window.parent.require([
                'Ajax',
                'Locale'
            ], function (QUIAjax, QUILocale) {
                const Content = document.createElement('div');
                Content.classList.add('wizard-finish');
                Content.innerHTML = '<span class="fa fa-circle-o-notch fa-spin"></span>';
                document.body.appendChild(Content);

                anime({
                    targets : Content,
                    duration: 500,
                    opacity : 1,
                    easing  : 'easeOutSine',
                    complete: function () {
                        QUIAjax.post('package_ecoyn_core_ajax_finishInstallation', function () {
                            Content.innerHTML = QUILocale.get('ecoyn/core', 'set.up.finish.step.description');

                            setTimeout(function () {
                                window.finish();
                            }, 5000);

                        }, {
                            'package': 'ecoyn/core'
                        });
                    }
                });
            });
        }
    });
});