/* Essentials YOOtheme Pro 2.2.16 build 0813.1608; ZOOlanders https://www.zoolanders.com; Copyright (C) Joolanders, SL; http://www.gnu.org/licenses/gpl.html GNU/GPL */

export default ({ util: { on, addClass }, modal }) => {
    on(document, 'yooessentials-form:submitted', (e, { response }) => {
        if (response?.message_action) {
            try {
                const { content, stack, center } = response.message_action;
                const instance = modal.alert(content, { stack }).dialog;

                addClass(instance.$el, 'ye-form-modal');

                on(instance.$el, 'beforeshow', () => {
                    if (center) {
                        addClass(instance.panel, 'uk-margin-auto-vertical');
                    }
                });
            } catch {
                e;
            }
        }
    });
};
