(n=>{jQuery(document).ready(function(){jQuery(document).on("click","#action_button",function(e){e.preventDefault();var t,e=n(this).data("page");let a="",o="";"list"===e&&(a=n(this).data("url"),o=n(this).data("event"),t=n(this).data("object"),jQuery('[data-loading="wu_action_button_loading_'+t+'"]').removeClass("hidden")),"edit"===e&&(a=n("input[name=webhook_url]").val(),o=n("select[name=event]").val(),t=n(this).data("object"),jQuery('[data-loading="wu_action_button_loading_'+t+'"]').removeClass("hidden")),n.ajax({method:"post",url:ajaxurl,data:{action:n(this).data("action"),webhook_id:n(this).data("object"),webhook_url:a,webhook_event:o},success(e){e.response?(n('[data-loading="wu_action_button_loading_'+e.id+'"]').addClass("hidden"),Swal.fire({title:"Test Response",icon:"success",html:'
'+JSON.stringify(e.response,null,2)+"
",showCloseButton:!0,showCancelButton:!1})):(n('[data-loading="wu_action_button_loading_'+e.id+'"]').addClass("hidden"),Swal.fire({title:wu_webhook_page.i18n.error_title,icon:"error",html:wu_webhook_page.i18n.error_message,showCloseButton:!0,showCancelButton:!1}))}})});let e;n("#wu_payload").length&&(e=new Vue({el:"#wu_payload",data(){return{payload:"",event:n('select[name="event"]').val(),loading:!0}},watch:{event(){this.get_event_payload()}},methods:{get_event_payload(){let t=this;t.loading=!0,n.ajax({method:"post",url:ajaxurl,data:{action:"wu_get_event_payload_preview",event:t.event},success(e){t.payload=e.data??{},t.loading=!1}})}},mounted(){this.get_event_payload()}})),n(document).on("change",'select[name="event"]',function(){e.event=n('select[name="event"]').val()}),new ClipboardJS(".btn-clipboard").on("success",function(e){let t=n(e.trigger),a=t.text();t.attr("disabled","disabled").text(wu_webhook_page.i18n.copied),setTimeout(function(){t.text(a).removeAttr("disabled")},3e3)})})})(jQuery);