(()=>{var s={669:e=>{e.exports=jQuery}},o={};var v,e,p,r=function e(r){var t=o[r];return void 0===t&&(t=o[r]={exports:{}},s[r](t,t.exports,e)),t.exports}(669);v=r,e=document,p=envira_gallery_convert,v(function(){v(e).on("click",".convert-envira-gallery-tab-btn",function(e){var i,c,d,r,t;e.preventDefault(),window.confirm(p.bulk_confirmation_alert)&&(v(".envira-posttype-dropdown-error").hide(),v(".envira-convert-gallery-message").html("").removeClass("success error").hide(),v(".envira-convert-process-logs").html("").hide(),e=(i=v(this)).attr("data-converting"),c=i.attr("title"),(r=(d=v("#envira_convert_post_types_dropdown")).val())?((t=new FormData).append("selected_posttype",r),d.attr("disabled",!0),i.attr("disabled",!0),i.html(e),fetch(p.bulk_convert_rest_url,{method:"POST",body:t,headers:{"X-WP-Nonce":p.gallery_convert_rest_nonce}}).then(function(e){return e.json()}).then(function(e){var s,o,r,n,a,l;e.posts?(s=function(){var e=Math.round(a/n*100);v(".envira-convert-progress-bar").css("width",e+"%"),v(".envira-convert-progress-counts").html(e+"%")},o=function(){var t,e;a<n?(t=r[a],(e=new FormData).append("post_id",t),fetch(p.process_item_rest_url,{method:"POST",body:e,headers:{"X-WP-Nonce":p.gallery_convert_rest_nonce}}).then(function(e){return e.json()}).then(function(e){var r;e.error&&(r="",e.edit_url&&(r=' (<a target="_blank" href="'+e.edit_url+'" target="_blank">'+p.edit_post_text+"</a>)"),0===l&&v(".envira-convert-process-logs").show().append("<p><strong>"+p.failed_conversion_logs+"</strong></p>"),v(".envira-convert-process-logs").show().append("<p><strong>"+p.post_id_text+" "+t+r+"</strong>: "+e.error+"</p>"),l++),a++,s(),o()}).catch(function(e){v(".envira-convert-gallery-message").addClass("error").html(e).show()})):(s(),v(".envira-convert-gallery-message").addClass("success").html(p.conversion_completed).show(),d.attr("disabled",!1),i.attr("disabled",!1),i.html(c))},r=e.posts,n=r.length,l=a=0,v(".envira-convert-gallery-message").addClass("success").html(p.bulk_conversion_started).show(),v(".envira-convert-process-logs").show().html("<p><strong>"+n+" "+p.found_posts_text+'</strong></p><div class="envira-convert-progress-bar-container"><div class="envira-convert-progress-bar"></div></div><div class="envira-convert-progress-counts"></div>'),s(),o()):(d.attr("disabled",!1),i.attr("disabled",!1),i.html(c),v(".envira-convert-gallery-message").addClass("error").html(e.message).show())}).catch(function(e){d.attr("disabled",!1),i.attr("disabled",!1),i.html(c),v(".envira-convert-gallery-message").addClass("error").html(e).show()}).finally(function(){d.attr("disabled",!1),i.attr("disabled",!1),i.html(c)})):v(".envira-posttype-dropdown-error").show())})})})();