  <div class="modal fade" id="modalGlobal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">

      <!-- HEADER -->
      <div class="modal-header">
        <h5 class="modal-title">Cargando...</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Cerrar">
          <span>&times;</span>
        </button>
      </div>

      <!-- BODY DINÁMICO -->
      <div class="modal-body">
        <div class="text-center p-3">
          <i class="fa fa-spinner fa-spin fa-2x"></i>
          <p class="mt-2">Cargando...</p>
        </div>
      </div>

    </div>
  </div>
</div>
    <!-- /.container-fluid-->
    <!-- /.content-wrapper-->
    <footer class="sticky-footer">
      <div class="container">
        <div class="text-center">
          <small>Copyright © <?= $nameapp; ?> 2026</small>
        </div>
      </div>
    </footer>
    <!-- Scroll to Top Button-->
    <style>
        .bs-tooltip-top{padding:.4rem 0}
        .bs-tooltip-auto[x-placement^=left],.bs-tooltip-left{padding:0 .4rem}
        .bs-tooltip-auto[x-placement^=left] .arrow,.bs-tooltip-left .arrow{left:0;width:.4rem;height:.8rem}
        .bs-tooltip-auto[x-placement^=left] .arrow::before,.bs-tooltip-left .arrow::before{left:0;border-width:.4rem .0rem .4rem .4rem;border-left-color:#007bff}
        .tooltip-inner{margin-left:1.4rem;max-width:200px;padding:.25rem .5rem;color:#fff;text-align:center;background-color:#007bff;border-radius:.25rem}
    </style>
    <!-- Scroll to Top Button-->
    <a class="scroll-to-top rounded" href="#page-top">
      <i class="fa fa-angle-up"></i>
    </a>
    <!-- Button trigger modal -->
   </div>
    <!-- Bootstrap core JavaScript-->
    <script src="<?= $r; ?>vendor/jquery/jquery.min.js"></script>
    <script src="<?= $r; ?>vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    <!-- Core plugin JavaScript-->
    <script src="<?= $r; ?>vendor/jquery-easing/jquery.easing.min.js"></script>
    <!-- Page level plugin JavaScript-->
    <script src="<?= $r; ?>vendor/chart/Chart.min.js"></script>
    <script src="<?= $r; ?>vendor/datatables/jquery.dataTables.js"></script>
    <script src="<?= $r; ?>vendor/datatables/dataTables.bootstrap4.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/dataTables.bootstrap4.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/dataTables.buttons.min.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/buttons.bootstrap.min.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/jszip.min.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/buttons.html5.min.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/buttons.print.min.js"></script>
    <script type="text/javascript" src="<?= $r; ?>vendor/datatables/buttons.colVis.min.js"></script>

    <!-- Form JavaScript-->
    <script src="<?= $r; ?>vendor/base/js/form.js?ver=1.5.8"></script>
    <script src="<?= $r; ?>vendor/base/js/swal.js"></script>
    <script src="<?= $r; ?>vendor/base/js/globals.js?ver=1.0.0"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
    <!-- Custom scripts for all pages-->
    <script src="<?= $r; ?>vendor/base/js/sb-admin.min.js"></script>
    <!-- Custom scripts for this page-->
    <script src="<?= $r; ?>vendor/base/js/sb-admin-datatables.min.js"></script>
    <script src="<?= $r; ?>vendor/base/js/sb-admin-charts.min.js"></script>
    <script src="<?= $r; ?>vendor/sweet/sweetalert.js"></script>
    <script src="<?= $r; ?>vendor/chosen/chosen.jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>

<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet"/>

<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
<style>
    .select2-container--default .select2-results__option--disabled {
    color: #999;
    display: none;
}
</style>
<script>

function normalize(text){
    return text.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase();
}

function customMatcher(params,data){

    if($.trim(params.term)===''){
        return data;
    }

    if(typeof data.text==='undefined'){
        return null;
    }

    var term = normalize(params.term);
    var text = normalize(data.text);

    if(text.indexOf(term) > -1){
        return data;
    }

    return null;
}

function iniciarSelect2(){

    $('select.chosen-select').each(function(){

        if($(this).data('select2')){
            $(this).select2('destroy');
        }

        $(this).removeClass('chosen-select').addClass('select2-auto');

    });

    $('select.select2-auto').each(function(){

        if($(this).data('select2')){
            $(this).select2('destroy');
        }

        var modal = $(this).closest('.modal');

        $(this).select2({
            width:'100%',
            matcher:customMatcher,
            dropdownParent: modal.length ? modal : $(document.body),
            language:{
                noResults:function(){
                    return "No se encontraron resultados";
                }
            }
        });

    });

}

$(document).ready(function(){
    iniciarSelect2();
    
});

function normalizeDT(text){
    if(!text) return '';
    return text.toString()
        .normalize("NFD")
        .replace(/[\u0300-\u036f]/g,"")
        .toLowerCase();
}

if($.fn.dataTable){
    
    $.fn.dataTable.ext.type.search.string = function(data){
        return normalizeDT(data);
    };

    $.fn.dataTable.ext.type.search.html = function(data){
        return normalizeDT(data.replace(/<.*?>/g,""));
    };

}

$(document).on('chosen:updated', 'select', function () {
    
    var el = $(this);

    if(el.data('select2')){
        el.trigger('change');
    }else{
        el.select2({
            width:'100%'
        });
    }

});
</script>