!function($){function e(s,t,n,r,o){if(o?t++:t+=Number(s.index_increment),t>Number(s.offset)+Number(s.number_requests)-1)return s.onFinished(),!0;let i={...{action:s.action,nonce:s.nonce,id:s.ids[t],current_index:t,index_increment:s.index_increment,number_requests:s.number_requests,offset:s.offset},...s.data};$.ajax({url:s.url,type:s.type,async:!0,cache:s.cache,dataType:s.dataType,data:i,success:function(o){let i=s.onRequestSuccess(o,t),u=t+Number(s.index_increment);if(u>s.number_requests&&(u=s.number_requests),o.success)n.progressbar("value",Number(u/s.number_requests*100)),$(r).text(u);else{if(1==s.stop_on_error)return void s.onFinished();-1==s.stop_on_error&&(n.progressbar("value",Number(u/s.number_requests*100)),$(r).text(u)),0==s.stop_on_error&&(t-=Number(s.index_increment))}i?o.success||-1===s.stop_on_error?e(s=s.updateSettings(s),t,n,r):setTimeout((function(){e(s,t,n,r)}),s.wait):s.onFinished()},error:function(o,i,u){let c=s.onRequestError(o,i,u,t);1!=s.stop_on_error?(0==s.stop_on_error&&t--,c?setTimeout((function(){e(s,t,n,r)}),s.wait):s.onFinished()):s.onFinished()}})}$.fn.synchronous_request=function(s){let t=$.extend({url:"",number_requests:0,offset:0,index_increment:1,action:"",nonce:"",ids:"",wait:5e3,stop_on_error:0,progress_count:"#progress-number",log:"#log",spinner:"#progress .spinner",cancel_button:".cancel",type:"post",cache:!1,dataType:"json",onRequestSuccess:function(e,s){if(this.maybeResetLog(),e.success)$("ul",$(this.log)).append('<li class="success">'+(s+1)+"/"+this.number_requests+": "+e.data+"</li>");else{let t=s+1+"/"+this.number_requests+": Response Error: "+e.data;switch(this.stop_on_error){case 1:break;case 0:t=t+". Waiting "+this.stop_on_error_pause/1e3+" seconds before reattempting this request.";break;case-1:t=t+". Waiting "+this.stop_on_error_pause/1e3+" seconds before attempting next request."}$("ul",$(this.log)).append('<li class="error">'+t+"</li>")}return 1!=this.cancelled},onRequestError:function(e,s,n,r){return this.maybeResetLog(),$("#log ul").append('<li class="error">'+(r+1)+"/"+t.number_requests+": Request Error: "+e.status+" "+e.statusText+"</li>"),1!=this.cancelled},updateSettings:function(e){return e},onFinished:function(){this.cancelled?$("ul",$(this.log)).append('<li class="success">Process cancelled by user.</li>'):($("ul",$(this.log)).append('<li class="success">Finished.</li>'),$(t.cancel_button).attr("disabled","disabled")),$(this.spinner).remove()},maybeResetLog:function(){$("li.spinner",$(this.log)).length>0&&$("li.spinner",$(this.log)).remove(),$("ul li",$(this.log)).length>=100&&$("ul",$(this.log)).html("")}},s);progressbar=$(this).progressbar({value:0}),t.cancel_button&&$(t.cancel_button).on("click",(function(e){e.preventDefault(),t.cancelled=!0,$(t.cancel_button).attr("disabled","disabled")})),e(t,-1+Number(t.offset),progressbar,t.progress_count,!0)}}(jQuery);