/* Constants */
    window.toast_duration = window.toast_duration || 4000;

    window.loader = window.loader || {
        show(text = translateAndReplace("common_responses_and_messages.loading")) {
            Swal.fire({
                title: text,
                html: '<p style="margin-top:0.5rem;">' + translateAndReplace("common_responses_and_messages.please_wait") + '</p>',
                allowOutsideClick: false,
                allowEscapeKey: false,
                backdrop: true,
                didOpen: () => {
                    Swal.showLoading();
                }
            });
        },
        hide() {
            if (Swal.isVisible()) Swal.close();
        }
    };

/* Control del Modal */
$(document).on('hide.bs.modal', "[id^='edit_modal_']", function (e) {
  // Mueve el foco a un lugar seguro fuera del modal
  const safe = document.querySelector('[data-focus-sentinel]') || document.body;
  if (!safe.hasAttribute('tabindex')) safe.setAttribute('tabindex','-1');
  safe.focus({ preventScroll: true });
});
