jQuery(document).ready(function ($) {
  //$('#billimagewaitfbl').hide();

  jQuery('.bill-install-now-24').on('click', function (e) {
    e.preventDefault();

    var $link = $(this);
    $link.next('.spinner').css('display', 'inline-block').addClass('is-active');
    $link.hide();

    jQuery('#bill-wrap-install-modal').show();
    jQuery('.bill-install-now').hide();
    var main_slug = jQuery('#main_slug').val();
    var clickedButtonId = this.id;
    var slug = clickedButtonId;
    //$('#billimagewaitfbl').show();
    $billmodal = $('#bill-wrap-install');
    $billmodal.prependTo($('#wpcontent')).slideDown();
    $('html, body').scrollTop(0);
    $("#billpluginslugModal").html(slug);
    var nonce = jQuery('#nonce_install').val();

    $.ajax({
      url: ajaxurl,
      type: 'POST',
      data: {
        action: 'bill_install_plugin3',
        slug: slug,
        nonce: nonce
      },
      success: function (response) {
        // Sucesso da requisição AJAX (sem ação adicional)
      },
      error: function (xhr, status, error) {
        console.error('AJAX Error - Status:', status, 'Erro:', error, 'Resposta:', xhr.responseText);
        //alert('Erro AJAX: ' + status + ' - ' + error);
      },
      complete: function (xhr, status) {
        $link.next('.spinner').removeClass('is-active').css('display', 'none');
        // $link.show();
        //$('#billimagewaitfbl').hide();

        // Esconder o aviso existente sem adicionar mensagem
        var $notice = $('.notice'); // Seleciona o elemento com class="notice"
        $notice.animate({ opacity: 0 }, 500, function () {
          $notice.hide();
        });
      }
    });
  });
});