(function() {
    var bridgeEvents = APP.bridgeEvents = APP.bridgeEvents || {};

    bridgeEvents.displayMessage = function(code, reference, message, options) {
        // console.log('%c displayMessage Params ', 'background: #222; color: #bada55');
        console.log('code', code)
        console.log('reference', reference)
        console.log('message', message)
        console.log('options', options)

        switch (code) {

            case '1601':
                var messageBox = APP.messageBox('You currently have insufficient funds. In order to continue playing, please make a deposit')
                    .addButton('Deposit', function() {
                        APP.method.postMessageToPortal({
                            message: 'InsufficientFunds'
                        });
                        messageBox.destroy(0);
                    })
                    .addButton('Continue', function() {
                        messageBox.destroy(0);
                    })
                    .show();
                break;


            case '1606':
                var messageBox = APP.messageBox(message)
                    .addButton('Close', function() {
                        messageBox.destroy(0);
                    })
                    .show();
                break;
            case '1012':
                var messageBox = APP.messageBox(message)
                    .addButton('Continue', function() {
                        messageBox.destroy(0);
                    })
                    .show();
                break;
            case '1613':
            case '1616':
                /*PFS Switch to Cash*/
                document.getElementById("btnCash").addEventListener('click', function() {
                    APP.method.postMessageToPortal({
                        message: 'SwitchToCashPlay',
                    });
                    //window.top.location.href = cashPlayURL;
                    APP.slider.hidePopup();
                });

                if (code == 1613) {
                    /*win*/
                    document.getElementById('winAmount').innerHTML = formattedWin;
                    document.getElementById("winTitle").style.display = "block";
                } else {
                    document.getElementById("winTitle").style.display = "none";
                }

                APP.slider.showFullScreenPopup(document.getElementById('pfsEnding'), true);
                break;

            default:
                APP.IGTbridge.console.resume();
                //     var messageBox = APP.messageBox(message, code);
                // options.forEach(function(e, i) {
                //     messageBox.addButton(e, function() {
                //         messageBox.destroy(i);
                //     })
                // });
                // messageBox.show();
                // // APP.IGTbridge.console.resume();
                // break;


        }

    }
})();