!function(){var e,t={669:function(e,t,r){e.exports=r(609)},448:function(e,t,r){"use strict";var n=r(867),s=r(26),i=r(372),a=r(327),o=r(97),u=r(109),c=r(985),l=r(61);e.exports=function(e){return new Promise((function(t,r){var h=e.data,f=e.headers,p=e.responseType;n.isFormData(h)&&delete f["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var _=e.auth.username||"",v=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";f.Authorization="Basic "+btoa(_+":"+v)}var g=o(e.baseURL,e.url);function m(){if(d){var n="getAllResponseHeaders"in d?u(d.getAllResponseHeaders()):null,i={data:p&&"text"!==p&&"json"!==p?d.response:d.responseText,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};s(t,r,i),d=null}}if(d.open(e.method.toUpperCase(),a(g,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,"onloadend"in d?d.onloadend=m:d.onreadystatechange=function(){d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))&&setTimeout(m)},d.onabort=function(){d&&(r(l("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){r(l("Network Error",e,null,d)),d=null},d.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(l(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",d)),d=null},n.isStandardBrowserEnv()){var b=(e.withCredentials||c(g))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;b&&(f[e.xsrfHeaderName]=b)}"setRequestHeader"in d&&n.forEach(f,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete f[t]:d.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(d.withCredentials=!!e.withCredentials),p&&"json"!==p&&(d.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){d&&(d.abort(),r(e),d=null)})),h||(h=null),d.send(h)}))}},609:function(e,t,r){"use strict";var n=r(867),s=r(849),i=r(321),a=r(185);function o(e){var t=new i(e),r=s(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var u=o(r(655));u.Axios=i,u.create=function(e){return o(a(u.defaults,e))},u.Cancel=r(263),u.CancelToken=r(972),u.isCancel=r(502),u.all=function(e){return Promise.all(e)},u.spread=r(713),u.isAxiosError=r(268),e.exports=u,e.exports.default=u},263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:function(e,t,r){"use strict";var n=r(263);function s(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}s.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},s.source=function(){var e;return{token:new s((function(t){e=t})),cancel:e}},e.exports=s},502:function(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:function(e,t,r){"use strict";var n=r(867),s=r(327),i=r(782),a=r(572),o=r(185),u=r(875),c=u.validators;function l(e){this.defaults=e,this.interceptors={request:new i,response:new i}}l.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=o(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var s,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!n){var l=[a,void 0];for(Array.prototype.unshift.apply(l,r),l=l.concat(i),s=Promise.resolve(e);l.length;)s=s.then(l.shift(),l.shift());return s}for(var h=e;r.length;){var f=r.shift(),p=r.shift();try{h=f(h)}catch(e){p(e);break}}try{s=a(h)}catch(e){return Promise.reject(e)}for(;i.length;)s=s.then(i.shift(),i.shift());return s},l.prototype.getUri=function(e){return e=o(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){l.prototype[e]=function(t,r){return this.request(o(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){l.prototype[e]=function(t,r,n){return this.request(o(n||{},{method:e,url:t,data:r}))}})),e.exports=l},782:function(e,t,r){"use strict";var n=r(867);function s(){this.handlers=[]}s.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},s.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},s.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=s},97:function(e,t,r){"use strict";var n=r(793),s=r(303);e.exports=function(e,t){return e&&!n(t)?s(e,t):t}},61:function(e,t,r){"use strict";var n=r(481);e.exports=function(e,t,r,s,i){var a=new Error(e);return n(a,t,r,s,i)}},572:function(e,t,r){"use strict";var n=r(867),s=r(527),i=r(502),a=r(655);function o(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return o(e),e.headers=e.headers||{},e.data=s.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||a.adapter)(e).then((function(t){return o(e),t.data=s.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(o(e),t&&t.response&&(t.response.data=s.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:function(e){"use strict";e.exports=function(e,t,r,n,s){return e.config=t,r&&(e.code=r),e.request=n,e.response=s,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},s=["url","method","data"],i=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function u(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(r[s]=u(void 0,e[s])):r[s]=u(e[s],t[s])}n.forEach(s,(function(e){n.isUndefined(t[e])||(r[e]=u(void 0,t[e]))})),n.forEach(i,c),n.forEach(a,(function(s){n.isUndefined(t[s])?n.isUndefined(e[s])||(r[s]=u(void 0,e[s])):r[s]=u(void 0,t[s])})),n.forEach(o,(function(n){n in t?r[n]=u(e[n],t[n]):n in e&&(r[n]=u(void 0,e[n]))}));var l=s.concat(i).concat(a).concat(o),h=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===l.indexOf(e)}));return n.forEach(h,c),r}},26:function(e,t,r){"use strict";var n=r(61);e.exports=function(e,t,r){var s=r.config.validateStatus;r.status&&s&&!s(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:function(e,t,r){"use strict";var n=r(867),s=r(655);e.exports=function(e,t,r){var i=this||s;return n.forEach(r,(function(r){e=r.call(i,e,t)})),e}},655:function(e,t,r){"use strict";var n=r(155),s=r(867),i=r(16),a=r(481),o={"Content-Type":"application/x-www-form-urlencoded"};function u(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,l={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==n&&"[object process]"===Object.prototype.toString.call(n))&&(c=r(448)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)?e:s.isArrayBufferView(e)?e.buffer:s.isURLSearchParams(e)?(u(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):s.isObject(e)||t&&"application/json"===t["Content-Type"]?(u(t,"application/json"),function(e,t,r){if(s.isString(e))try{return(t||JSON.parse)(e),s.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&s.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw a(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};l.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],(function(e){l.headers[e]={}})),s.forEach(["post","put","patch"],(function(e){l.headers[e]=s.merge(o)})),e.exports=l},849:function(e){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n=0)return;a[t]="set-cookie"===t?(a[t]?a[t]:[]).concat([r]):a[t]?a[t]+", "+r:r}})),a):a}},713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:function(e,t,r){"use strict";var n=r(593),s={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){s[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={},a=n.version.split(".");function o(e,t){for(var r=t?t.split("."):a,n=e.split("."),s=0;s<3;s++){if(r[s]>n[s])return!0;if(r[s]0;){var i=n[s],a=t[i];if(a){var o=e[i],u=void 0===o||a(o,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:s}},867:function(e,t,r){"use strict";var n=r(849),s=Object.prototype.toString;function i(e){return"[object Array]"===s.call(e)}function a(e){return void 0===e}function o(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==s.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===s.call(e)}function l(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r0&&(this.data.popup_active=!1),this.data.webp_converted=0,this.data.webp_unconverted=this.data.webp_all,this.refresh_stats())}},{key:"set_files_avif",value:function(e,t){this.status&&(this.data.avif_converted+=e,this.data.avif_unconverted=t-e,this.data.avif_all=t,this.refresh_stats())}},{key:"set_error",value:function(){this.counter_webp_loader.setAttribute("hidden","hidden"),this.counter_avif_loader.setAttribute("hidden","hidden")}},{key:"reset_files_avif",value:function(){this.status&&(this.data.avif_converted=0,this.data.avif_unconverted=this.data.avif_all,this.refresh_stats())}},{key:"add_files_webp",value:function(e){this.status&&(this.data.popup_active&&0===this.data.webp_converted&&this.data.webp_unconverted>0&&this.open_popup(),this.data.webp_converted+=e,this.data.webp_unconverted-=e,this.refresh_stats())}},{key:"add_files_avif",value:function(e){this.status&&(this.data.avif_converted+=e,this.data.avif_unconverted-=e,this.refresh_stats())}},{key:"refresh_stats",value:function(){var e=this.data,t=e.webp_converted,r=e.webp_unconverted,n=e.webp_all,s=e.avif_converted,i=e.avif_unconverted,a=e.avif_all,o=this.atts.counter_percent,u=n>0?Math.floor(t/n*100):0,c=a>0?Math.floor(s/a*100):0;this.counter_webp.setAttribute(o,u),this.counter_webp_percent.innerText=u,this.counter_webp_images.innerText=Math.max(r,0).toString().replace(/\B(?=(\d{3})+(?!\d))/g," "),this.counter_avif.setAttribute(o,c),this.counter_avif_percent.innerText=c,this.counter_avif_images.innerText=Math.max(i,0).toString().replace(/\B(?=(\d{3})+(?!\d))/g," ")}},{key:"open_popup",value:function(){var e=this;this.data.popup_active=!1,this.popup_wrapper&&(this.popup_wrapper.removeAttribute("hidden"),setTimeout((function(){e.popup_wrapper.addEventListener("click",e.close_popup.bind(e)),e.popup_close.addEventListener("click",e.close_popup.bind(e)),e.popup_content.addEventListener("click",(function(e){e.stopPropagation()}))}),0))}},{key:"close_popup",value:function(){this.popup_wrapper.setAttribute("hidden","hidden")}}])&&h(t.prototype,r),n&&h(t,n),e}();function p(e,t){for(var r=0;r=0)return!0;return!1}}])&&p(t.prototype,r),n&&p(t,n),e}();function _(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0;if(0===this.data.max&&this.update_progress(),!(this.data.count>=this.data.max)){e>=3?e=0:e>0&&this.data.count--;var t=this.data.items[this.data.count];this.data.count++,this.send_request_for_regeneration(t,e)}}},{key:"send_request_for_regeneration",value:function(e,t){var r=this,n=this.settings.ajax,i=n.url_regenerate,a=n.url_regenerate_nonce;s()({method:"POST",url:i,data:{regenerate_force:this.option_force.checked?1:0,paths:e},headers:{"X-WP-Nonce":a},timeout:this.settings.connection_timeout}).then((function(e){var t=e.data.is_fatal_error;r.update_errors(e.data.errors,t),t||(r.update_size(e.data),r.update_files_count(e.data),r.update_progress(),r.regenerate_next_images())})).catch((function(n){n.response?(r.catch_request_error(n,!1,e),setTimeout(r.regenerate_next_images.bind(r),1e3)):setTimeout(r.regenerate_next_images.bind(r,t+1),1e3)}))}},{key:"update_errors",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.data.errors>this.settings.max_errors&&(this.data.errors=0,this.errors_output.innerHTML="");for(var r=this.get_date(),n=0;n2&&void 0!==arguments[2]?arguments[2]:null;t&&(this.print_error_message([this.settings.ajax.error_message],!0,!1),this.set_fatal_error());var n=null!==r?'["'.concat(r.join('", "'),'"]'):"";this.print_error_message("".concat(e.response.status," - ").concat(e.response.statusText," (").concat(e.response.config.url,") ").concat(n),!0,!0)}},{key:"print_error_message",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,s=document.createElement("p"),i=n||this.get_date();if(r){var a=document.createElement("pre");a.innerText=e,s.appendChild(a)}else s.innerHTML="".concat(i," - ").concat(e);t&&s.classList.add(this.classes.error_message),this.wrapper_errors.removeAttribute("hidden"),this.errors_output.appendChild(s)}},{key:"update_size",value:function(e){var t=this.data.size;t.before+=e.size.before,t.after+=e.size.after;var r=t.before-t.after;if(r<0&&(r=0),0!==r){var n=Math.round(100*(1-t.after/t.before));n<0&&(n=0);var s=-1;do{s++,r/=1024}while(r>1024);var i=r.toFixed(2),a=this.settings.units[s];this.progress_size.innerHTML="".concat(i," ").concat(a," (").concat(n,"%)")}}},{key:"update_files_count",value:function(e){var t=this.data.files_counter,r=e.files;this.conversion_stats_manager.add_files_webp(r.webp_available),this.conversion_stats_manager.add_files_avif(r.avif_available),t.converted+=r.webp_converted+r.avif_converted,t.all+=r.webp_available+r.avif_available,this.progress_success.innerText=t.converted.toString().replace(/\B(?=(\d{3})+(?!\d))/g," "),this.progress_failed.innerText=(t.all-t.converted).toString().replace(/\B(?=(\d{3})+(?!\d))/g," ")}},{key:"update_progress",value:function(){var e=this.data.max>0?Math.floor(this.data.count/this.data.max*100):100;e>100&&(e=100),100===e&&this.wrapper_success.removeAttribute("hidden"),this.progress.setAttribute(this.atts.progress,e.toString())}}])&&_(t.prototype,r),n&&_(t,n),e}();function g(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0;if(t>=3)return this.conversion_stats_manager.set_error(),this.images_tree_generator.set_error(),void this.plans_button_generator.set_error();var r=new Date;s()({method:"GET",url:this.settings.ajax_url,headers:{"X-WP-Nonce":this.settings.ajax_nonce}}).then((function(n){if(n.data){var s=n.data.value_webp_all||0,i=n.data.value_webp_converted||0,a=n.data.value_avif_all||0,o=n.data.value_avif_converted||0;e.conversion_stats_manager.set_files_webp(i,s),e.conversion_stats_manager.set_files_avif(o,a),e.images_tree_generator.generate_tree(n.data.tree),e.plans_button_generator.show_button(s-i,a-o)}else e.send_request(t+1),e.show_request_error(r,n)})).catch((function(n){e.send_request(t+1),n.response&&e.show_request_error(r,n.response)}))}},{key:"show_request_error",value:function(e,t){var r=(new Date-e)/1e3,n=t.status,s=JSON.stringify(t.data);this.error_output.innerText="HTTP Error ".concat(n," (").concat(r,"s): ").concat(s),this.error_output.removeAttribute("hidden")}}])&&g(t.prototype,r),n&&g(t,n),e}();function b(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"tree",n="",s=e.length;if(!s)return n;0===t&&(n+='
    ');for(var i=0;i',n+=''),n+='",n+='
      ',u&&(n+=this.draw_tree(e[i].items,t+1,a));for(var c=0;c',n+=''.concat(e[i].files[c],""),n+="";if(o>this.settings.max_items){var l=(o-this.settings.max_items).toString().replace(/\B(?=(\d{3})+(?!\d))/g," ");n+='
    • ',n+=''.concat(this.settings.message_files_count.replace("%s",l),""),n+="
    • "}n+="
    ",n+=""}return 0===t&&(n+="
"),n}},{key:"hide_child_items",value:function(e){if(!e.currentTarget.checked)for(var t=e.currentTarget.parentNode.querySelectorAll(".webpcTree__itemCheckbox"),r=0;r1)for(var r=1;r=i)&&Object.keys(n.O).every((function(e){return n.O[e](r[u])}))?r.splice(u--,1):(o=!1,i0&&e[l-1][2]>i;l--)e[l]=e[l-1];e[l]=[r,s,i]},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={794:0,505:0};n.O.j=function(t){return 0===e[t]};var t=function(t,r){var s,i,a=r[0],o=r[1],u=r[2],c=0;if(a.some((function(t){return 0!==e[t]}))){for(s in o)n.o(o,s)&&(n.m[s]=o[s]);if(u)var l=u(n)}for(t&&t(r);c