!function(e){function a(a,t){let o=a.siblings(".fea-error-message");o.length||(o=e('<div class="fea-error-message"></div>'),a.after(o)),o.text(t).show()}e(document).ready((function(){e("body").on("click",".fea-delete-button",(function(t){let o=e(this);if(o.hasClass("disabled"))return;o.addClass("disabled");acf.newTooltip({confirm:!0,text:o.data("confirm"),target:o,context:o.closest(".acf-field"),confirm:function(){!function(t){if(!(e(window).off("beforeunload"),t.after('<span class="fea-loader"></span>'),$form=t.closest("form"),$form[0]||($form=t.siblings("form"),$form[0])))return;$form.find(".fea-submit-button").addClass("disabled");let o=new FormData($form[0]),n=t.closest(".acf-field"),d=$form.data("field");d||(d=n.data("key")||t.data("key"));if(!d)return;o.append("action","frontend_admin/delete_object"),o.append("field",d),o.append("delete_object",t.data("object")),o.append("nonce",t.data("nonce")),e.ajax({url:acf.get("ajaxurl"),type:"post",data:o,cache:!1,processData:!1,contentType:!1,success:function(e){if(e.success){if(e.data?.redirect){let a=e.data.redirect.replace(/&amp;/g,"&");window.location=decodeURIComponent(a)}}else{let o=e.data||"Failed to delete object.";a(t,o)}},error:function(e,o,n){a(t,"Something went wrong. Please try again.")},complete:function(){t.siblings(".fea-loader").remove(),$form.find(".fea-submit-button").removeClass("disabled")}})}(o)},cancel:function(){o.removeClass("disabled")}})}))}))}(jQuery);