(function () {

    ready(function () {
        Nonstop.default.initialize({
            environment: window.environment,
            platform: 'web',
            cdnUrl: '../../dist/'
        });

        var userInput = {
            firstName: chance.first(),
            externalId: chance.guid(),
            email: chance.email()
        };
        Nonstop.default.login(userInput, true);

        var presentCardButton = document.querySelectorAll('.btn-present-card')[0];
        presentCardButton.addEventListener('click', function () {
            Nonstop.default.presentChoiceCard('VDKA4220171', document.querySelectorAll('.choice-card-content')[0], true);
        });

        document.addEventListener(Nonstop.default.Events.OnWatchStandard, function() {
            alert('On Watch Standard Event fired');
        });

        document.addEventListener(Nonstop.default.Events.OnWatchNonstop, function() {
            alert('On Watch Nonstop Event fired');
        });
    });

    function ready(fn) {
        if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading") {
            fn();
        } else {
            document.addEventListener('DOMContentLoaded', fn);
        }
    }

})();