Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/plugins/image-optimization/assets/build/control.js
Назад
!function(){"use strict";var t={};function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function e(t,e){for(var o=0;o<e.length;o++){var r=e[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,i=function(t,e){if("object"!==n(t)||null===t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var r=o.call(t,"string");if("object"!==n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===n(i)?i:String(i)),r)}var i}t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,{a:e}),e},t.d=function(n,e){for(var o in e)t.o(e,o)&&!t.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:e[o]})},t.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)};var o=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.init()}var n,o;return n=t,(o=[{key:"init",value:function(){this.extendAttachmentDetails(),this.extendAttachmentDetailsTwoColumn()}},{key:"extendAttachmentDetails",value:function(){var t;null!==(t=wp)&&void 0!==t&&null!==(t=t.media)&&void 0!==t&&null!==(t=t.view)&&void 0!==t&&null!==(t=t.Attachment)&&void 0!==t&&t.Details&&(wp.media.view.Attachment.Details=wp.media.view.Attachment.Details.extend({template:function(t){var n=wp.media.template("attachment-details")(t);if("image"!==this.model.attributes.type)return n;var e=document.createElement("div");e.innerHTML=n;var o=this.getOptimizationControlHTML(t.compat.item);return o?(e.innerHTML+=o,e.innerHTML):e.innerHTML},getOptimizationControlHTML:function(t){var n,e=document.createElement("div");return e.innerHTML=t,null===(n=e.querySelector('input[name*="[image_optimization_modal]"]'))||void 0===n?void 0:n.value}}))}},{key:"extendAttachmentDetailsTwoColumn",value:function(){var t;null!==(t=wp)&&void 0!==t&&null!==(t=t.media)&&void 0!==t&&null!==(t=t.view)&&void 0!==t&&null!==(t=t.Attachment)&&void 0!==t&&null!==(t=t.Details)&&void 0!==t&&t.TwoColumn&&(wp.media.view.Attachment.Details.TwoColumn=wp.media.view.Attachment.Details.TwoColumn.extend({template:function(t){var n=wp.media.template("attachment-details-two-column")(t);if("image"!==this.model.attributes.type)return n;var e=document.createElement("div");e.innerHTML=n;var o=this.getOptimizationControlHTML(t.compat.item);return o?(e.querySelector(".settings").innerHTML+=o,e.innerHTML):e.innerHTML},getOptimizationControlHTML:function(t){var n,e=document.createElement("div");return e.innerHTML=t,null===(n=e.querySelector('input[name*="[image_optimization_modal]"]'))||void 0===n?void 0:n.value}}))}}])&&e(n.prototype,o),Object.defineProperty(n,"prototype",{writable:!1}),t}(),r=window.wp.i18n,i=window.wp.a11y,a="https://go.elementor.com/io-panel-upgrade/",c=Object.freeze({optimizeButtonSelector:".image-optimization-control__button--optimize",reoptimizeButtonSelector:".image-optimization-control__button--reoptimize",tryAgainOptimizeButtonSelector:'[data-image-optimization-action="optimize"] .image-optimization-control__button--try-again',tryAgainReoptimizeButtonSelector:'[data-image-optimization-action="reoptimize"] .image-optimization-control__button--try-again',tryAgainRestoreButtonSelector:'[data-image-optimization-action="restore"] .image-optimization-control__button--try-again',controlWrapperSelector:".image-optimization-control",controlNotOptimizedClassName:"image-optimization-control image-optimization-control--not-optimized",controlLoadingClassName:"image-optimization-control image-optimization-control--loading",controlOptimizedClassName:"image-optimization-control image-optimization-control--optimized",controlErrorClassName:"image-optimization-control image-optimization-control--error",controlWrapper:{"list-view":"image-optimization-control--list-view","meta-box":"image-optimization-control--meta-box","details-view":"image-optimization-control--details-view"},restoreButtonSelector:".image-optimization-control__button--restore-original",loadingControlsSelector:'[data-image-optimization-status="loading"]'}),u=window.wp.apiFetch,s=t.n(u);function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function p(t){var n="function"==typeof Map?new Map:void 0;return p=function(t){if(null===t||(e=t,-1===Function.toString.call(e).indexOf("[native code]")))return t;var e;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,o)}function o(){return m(t,arguments,y(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),g(o,t)},p(t)}function m(t,n,e){return m=f()?Reflect.construct.bind():function(t,n,e){var o=[null];o.push.apply(o,n);var r=new(Function.bind.apply(t,o));return e&&g(r,e.prototype),r},m.apply(null,arguments)}function f(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function g(t,n){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},g(t,n)}function y(t){return y=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},y(t)}var h=function(t){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),n&&g(t,n)}(i,t);var n,e,o,r=(e=i,o=f(),function(){var t,n=y(e);if(o){var r=y(this).constructor;t=Reflect.construct(n,arguments,r)}else t=n.apply(this,arguments);return function(t,n){if(n&&("object"===l(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(this,t)});function i(t){var n;return function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,i),(n=r.call(this,t)).name="APIError",n}return n=i,Object.defineProperty(n,"prototype",{writable:!1}),n}(p(Error));function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function d(){d=function(){return n};var t,n={},e=Object.prototype,o=e.hasOwnProperty,r=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{s({},"")}catch(t){s=function(t,n,e){return t[n]=e}}function l(t,n,e,o){var i=n&&n.prototype instanceof b?n:b,a=Object.create(i.prototype),c=new C(o||[]);return r(a,"_invoke",{value:k(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var m="suspendedStart",f="suspendedYield",g="executing",y="completed",h={};function b(){}function _(){}function w(){}var z={};s(z,a,(function(){return this}));var O=Object.getPrototypeOf,S=O&&O(O(I([])));S&&S!==e&&o.call(S,a)&&(z=S);var x=w.prototype=b.prototype=Object.create(z);function L(t){["next","throw","return"].forEach((function(n){s(t,n,(function(t){return this._invoke(n,t)}))}))}function E(t,n){function e(r,i,a,c){var u=p(t[r],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==v(l)&&o.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;r(this,"_invoke",{value:function(t,o){function r(){return new n((function(n,r){e(t,o,n,r)}))}return i=i?i.then(r,r):r()}})}function k(n,e,o){var r=m;return function(i,a){if(r===g)throw new Error("Generator is already running");if(r===y){if("throw"===i)throw a;return{value:t,done:!0}}for(o.method=i,o.arg=a;;){var c=o.delegate;if(c){var u=j(c,o);if(u){if(u===h)continue;return u}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(r===m)throw r=y,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);r=g;var s=p(n,e,o);if("normal"===s.type){if(r=o.done?y:f,s.arg===h)continue;return{value:s.arg,done:o.done}}"throw"===s.type&&(r=y,o.method="throw",o.arg=s.arg)}}}function j(n,e){var o=e.method,r=n.iterator[o];if(r===t)return e.delegate=null,"throw"===o&&n.iterator.return&&(e.method="return",e.arg=t,j(n,e),"throw"===e.method)||"return"!==o&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+o+"' method")),h;var i=p(r,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,h;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function T(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function P(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function C(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(T,this),this.reset(!0)}function I(n){if(n||""===n){var e=n[a];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,i=function e(){for(;++r<n.length;)if(o.call(n,r))return e.value=n[r],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(v(n)+" is not iterable")}return _.prototype=w,r(x,"constructor",{value:w,configurable:!0}),r(w,"constructor",{value:_,configurable:!0}),_.displayName=s(w,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===_||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,s(t,u,"GeneratorFunction")),t.prototype=Object.create(x),t},n.awrap=function(t){return{__await:t}},L(E.prototype),s(E.prototype,c,(function(){return this})),n.AsyncIterator=E,n.async=function(t,e,o,r,i){void 0===i&&(i=Promise);var a=new E(l(t,e,o,r),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},L(x),s(x,u,"Generator"),s(x,a,(function(){return this})),s(x,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var o in n)e.push(o);return e.reverse(),function t(){for(;e.length;){var o=e.pop();if(o in n)return t.value=o,t.done=!1,t}return t.done=!0,t}},n.values=I,C.prototype={constructor:C,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!n)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function r(o,r){return c.type="throw",c.arg=n,e.next=o,r&&(e.method="next",e.arg=t),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),h},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),P(e),h}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var o=e.completion;if("throw"===o.type){var r=o.arg;P(e)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(n,e,o){return this.delegate={iterator:I(n),resultName:e,nextLoc:o},"next"===this.method&&(this.arg=t),h}},n}function b(t,n,e,o,r,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).then(o,r)}function _(t){return function(){var n=this,e=arguments;return new Promise((function(o,r){var i=t.apply(n,e);function a(t){b(i,o,r,a,c,"next",t)}function c(t){b(i,o,r,a,c,"throw",t)}a(void 0)}))}}function w(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,r=function(t,n){if("object"!==v(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==v(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===v(r)?r:String(r)),o)}var r}var z="/image-optimizer/v1",O=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t)}var n,e,o,r,i,a;return n=t,null,e=[{key:"request",value:(a=_(d().mark((function t(n){var e,o,r,i,a;return d().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.path,o=n.data,r=n.method,i=void 0===r?"POST":r,t.prev=1,t.next=4,s()({path:e,method:i,data:o});case 4:if((a=t.sent).success){t.next=7;break}throw new h(a.data.message);case 7:return t.abrupt("return",a.data);case 10:if(t.prev=10,t.t0=t.catch(1),!(t.t0 instanceof h)){t.next=16;break}throw t.t0;case 16:throw new h(t.t0.message);case 17:case"end":return t.stop()}}),t,null,[[1,10]])}))),function(_x){return a.apply(this,arguments)})},{key:"optimizeSingleImage",value:(i=_(d().mark((function n(e){var o,r,i,a;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return r=e.imageId,i=e.reoptimize,a=void 0!==i&&i,n.abrupt("return",t.request({path:"".concat(z,"/optimize/image"),data:{imageId:r,reoptimize:a,"image-optimization-optimize-image":null===(o=window)||void 0===o||null===(o=o.imageOptimizerControlSettings)||void 0===o?void 0:o.optimizeSingleImageNonce}}));case 2:case"end":return n.stop()}}),n)}))),function(t){return i.apply(this,arguments)})},{key:"restoreSingleImage",value:(r=_(d().mark((function n(e){var o;return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.request({path:"".concat(z,"/backups/restore/").concat(e),data:{"image-optimization-restore-single":null===(o=window)||void 0===o||null===(o=o.imageOptimizerControlSettings)||void 0===o?void 0:o.restoreSingleImageNonce}}));case 1:case"end":return n.stop()}}),n)}))),function(t){return r.apply(this,arguments)})},{key:"getOptimizationStatus",value:(o=_(d().mark((function n(e){return d().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.abrupt("return",t.request({path:"".concat(z,"/optimize/status"),data:{image_ids:e}}));case 1:case"end":return n.stop()}}),n)}))),function(t){return o.apply(this,arguments)})}],e&&w(n,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),S=O;function x(t){return x="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},x(t)}function L(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,r=function(t,n){if("object"!==x(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==x(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===x(r)?r:String(r)),o)}var r}var E=function(){function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.controlNode=n}var n,e;return n=t,(e=[{key:"getImageId",value:function(){var t,n;return null!==(t=this.controlNode.dataset)&&void 0!==t&&t.imageOptimizationImageId?parseInt(null===(n=this.controlNode.dataset)||void 0===n?void 0:n.imageOptimizationImageId,10):null}},{key:"getAction",value:function(){var t;return(null===(t=this.controlNode.dataset)||void 0===t?void 0:t.imageOptimizationAction)||null}},{key:"getContext",value:function(){var t;return(null===(t=this.controlNode.dataset)||void 0===t?void 0:t.imageOptimizationContext)||null}},{key:"getStatus",value:function(){var t;return(null===(t=this.controlNode.dataset)||void 0===t?void 0:t.imageOptimizationStatus)||null}},{key:"canBeRestored",value:function(){var t,n=null===(t=this.controlNode.dataset)||void 0===t?void 0:t.imageOptimizationCanBeRestored;return n?"1"===n:null}},{key:"allowRetry",value:function(){var t;return(null===(t=this.controlNode.dataset)||void 0===t?void 0:t.allowRetry)||null}}])&&L(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),k=window.wp.escapeHtml,j=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,e=[ // translators: %s: file size in bytes (0,r.__)("%s Bytes","image-optimization"), // translators: %s: file size in kilobytes (0,r.__)("%s Kb","image-optimization"), // translators: %s: file size in megabytes (0,r.__)("%s Mb","image-optimization"), // translators: %s: file size in gigabytes (0,r.__)("%s Gb","image-optimization")];if(!t) // translators: %s: file size in bytes return(0,r.sprintf)((0,r.__)("%s Bytes","image-optimization"),0);var o=Math.floor(Math.log(t)/Math.log(1024)),i=parseFloat((t/Math.pow(1024,o)).toFixed(n));return(0,r.sprintf)(e[o],i)},T=Object.freeze({notOptimizedTemplate:function(){return'\n\t\t<button type="button"\n\t\t\t\t\tclass="button button-primary image-optimization-control__button image-optimization-control__button--optimize">\n\t\t\t'.concat((0,r.__)("Optimize now","image-optimization"),"\n\t\t</button>\n\t")},loadingTemplate:function(t){var n;switch(t){case"restore":n=(0,r.__)("Restoring…","image-optimization");break;case"optimize":n=(0,r.__)("Optimizing…","image-optimization");break;case"reoptimize":n=(0,r.__)("Reoptimizing…","image-optimization");break;default:n=(0,r.__)("Loading…","image-optimization")}return'\n\t\t<button class="button button-secondary image-optimization-control__button image-optimization-control__button--optimize"\n\t\t\t\t\t\tdisabled="">\n\t\t\t<span class="spinner is-active"></span> '.concat(n,"\n\t\t</button>\n\t")},errorTemplate:function(t,n){return'\n\t\t<span class="image-optimization-control__error-message">'.concat((0,k.escapeHTML)(t),"</span>\n\n\t\t").concat(0===n?'<a class="button button-secondary button-large image-optimization-control__button"\n\t\t\t\t href="'.concat(a,'"\n\t\t\t\t target="_blank" rel="noopener noreferrer">\n \t\t\t\t').concat((0,r.__)("Upgrade","image-optimization"),"\n\t\t\t</a>\n\t\t"):'\n\t\t<button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again"\n\t\t\t\t\t\ttype="button">\n\t\t\t'.concat((0,r.__)("Try again","image-optimization"),"\n\t\t</button>"),"\n\t")},optimizedTemplate:function(t){var n,e,o,i=j(null==t||null===(n=t.saved)||void 0===n?void 0:n.absolute,1);return'\n\t\t<p class="image-optimization-control__property">\n\t\t\t'.concat((0,r.__)("Image sizes optimized","image-optimization"),":\n\n\t\t\t<span>").concat(null==t?void 0:t.sizesOptimized,'</span>\n\t\t</p>\n\n\t\t<p class="image-optimization-control__property">\n\t\t\t').concat(0!==(null==t||null===(e=t.saved)||void 0===e?void 0:e.absolute)?"".concat((0,r.__)("Overall saving","image-optimization"),": <span>").concat(null==t||null===(o=t.saved)||void 0===o?void 0:o.relative,"% (").concat(i,")</span>"):"<span>".concat((0,r.__)("Image is fully optimized","image-optimization"),"</span>"),'\n\t\t</p>\n\n\t\t<div class="image-optimization-control__buttons-wrapper">\n\t\t\t').concat(null!=t&&t.canBeRestored?'\n\t\t\t\t<button type="button"\n\t\t\t\t\tclass="button button-secondary image-optimization-control__button image-optimization-control__button--restore-original">\n\t\t\t\t\t'.concat((0,r.__)("Restore original","image-optimization"),"\n\t\t\t\t</button>\n\t\t\t"):"",'\n\n\t\t\t<button type="button"\n\t\t\t\tclass="button button-secondary image-optimization-control__button image-optimization-control__button--reoptimize">\n\t\t\t\t').concat((0,r.__)("Reoptimize","image-optimization"),"\n\t\t\t</button>\n\t\t</div>\n\t")}}),P=Object.freeze({notOptimizedTemplate:function(){return'\n\t\t<p class="image-optimization-control__property">\n\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Not optimized","image-optimization"),'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<div class="image-optimization-control__action-button-wrapper">\n\t\t\t<button type="button"\n\t\t\t\t\t\t\tclass="button button-primary image-optimization-control__button image-optimization-control__button--optimize">\n\t\t\t\t').concat((0,r.__)("Optimize now","image-optimization"),"\n\t\t\t</button>\n\t\t</div>\n\t")},loadingTemplate:function(){return'\n\t\t<p class="image-optimization-control__property">\n\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("In Progress","image-optimization"),'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<div class="image-optimization-control__action-spinner-wrapper">\n\t\t\t<span class="spinner is-active"></span>\n\t\t</div>\n\t')},errorTemplate:function(t,n){return'\n\t\t<p class="image-optimization-control__property">\n\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Error","image-optimization"),'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<p class="image-optimization-control__property">\n\t\t\t').concat((0,r.__)("Reason","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,k.escapeHTML)(t),'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<div class="image-optimization-control__action-button-wrapper">\n\t\t\t').concat(0===n?'<a class="button button-secondary button-large image-optimization-control__button"\n\t\t\t\t href="'.concat(a,'"\n\t\t\t\t target="_blank" rel="noopener noreferrer">\n\t\t\t\t').concat((0,r.__)("Upgrade","image-optimization"),"\n\t\t\t</a>\n\t\t\t"):'\n\t\t\t<button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again"\n\t\t\t\t\t\t\ttype="button">\n\t\t\t\t'.concat((0,r.__)("Try again","image-optimization"),"\n\t\t\t</button>"),"\n\t\t</div>\n\t")},optimizedTemplate:function(t){var n,e,o,i=j(null==t||null===(n=t.saved)||void 0===n?void 0:n.absolute,1);return'\n\t\t<p class="image-optimization-control__property">\n\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Optimized","image-optimization"),'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<p class="image-optimization-control__property">\n\t\t\t').concat((0,r.__)("Image sizes optimized","image-optimization"),':\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat(null==t?void 0:t.sizesOptimized,'\n\t\t\t</span>\n\t\t</p>\n\n\t\t<p class="image-optimization-control__property">\n\t\t\t').concat(0!==(null==t||null===(e=t.saved)||void 0===e?void 0:e.absolute)?'\n\t\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t\t'.concat((0,r.__)("Overall saving","image-optimization"),": ").concat(null==t||null===(o=t.saved)||void 0===o?void 0:o.relative,"% (").concat(i,")\n\t\t\t\t</span>\n\t\t\t"):'\n\t\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t\t'.concat((0,r.__)("Image is fully optimized","image-optimization"),"\n\t\t\t\t</span>\n\t\t\t"),'\n\t\t</p>\n\n\t\t<div class="image-optimization-control__action-button-wrapper">\n\t\t\t').concat(null!=t&&t.canBeRestored?'\n\t\t\t\t<button class="button button-link image-optimization-control__button image-optimization-control__button--restore-original"\n\t\t\t\t\t\t\t\ttype="button">\n\t\t\t\t\t'.concat((0,r.__)("Restore original","image-optimization"),"\n\t\t\t\t</button>\n\t\t\t"):"",'\n\n\t\t\t<button class="button button-link image-optimization-control__button image-optimization-control__button--reoptimize"\n\t\t\t\t\t\t\ttype="button">\n\t\t\t\t').concat((0,r.__)("Reoptimize","image-optimization"),"\n\t\t\t</button>\n\t\t</div>\n\t")}}),C=Object.freeze({notOptimizedTemplate:function(){return'\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Not optimized","image-optimization"),'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property"></span>\n\n\t\t\t<span class="image-optimization-control__property-value image-optimization-control__property-value--button">\n\t\t\t\t<button type="button"\n\t\t\t\t\t\t\tclass="button button-primary image-optimization-control__button image-optimization-control__button--optimize">\n\t\t\t\t\t').concat((0,r.__)("Optimize now","image-optimization"),"\n\t\t\t\t</button>\n\t\t\t</span>\n\t\t</span>\n\t")},loadingTemplate:function(){return'\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("In Progress","image-optimization"),'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property"></span>\n\n\t\t\t<span class="image-optimization-control__property-value image-optimization-control__property-value--spinner">\n\t\t\t\t<span class="spinner is-active"></span>\n\t\t\t</span>\n\t\t</span>\n\t')},errorTemplate:function(t,n){return'\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Error","image-optimization"),'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t').concat((0,r.__)("Reason","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,k.escapeHTML)(t),'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property"></span>\n\n\t\t\t<span class="image-optimization-control__property-value image-optimization-control__property-value--button">\n\t\t\t\t').concat(0===n?'<a class="button button-secondary button-large image-optimization-control__button"\n\t\t\t\t\thref="'.concat(a,'"\n\t\t\t\t\ttarget="_blank" rel="noopener noreferrer">\n\t\t\t\t\t').concat((0,r.__)("Upgrade","image-optimization"),"\n\t\t\t\t</a>\n\t\t\t\t"):'\n\t\t\t\t<button class="button button-secondary button-large button-link-delete image-optimization-control__button image-optimization-control__button--try-again"\n\t\t\t\t\t\t\t\ttype="button">\n\t\t\t\t\t'.concat((0,r.__)("Try again","image-optimization"),"\n\t\t\t\t</button>"),"\n\t\t\t</span>\n\t\t</span>\n\t")},optimizedTemplate:function(t){var n,e,o,i=j(null==t||null===(n=t.saved)||void 0===n?void 0:n.absolute,1);return'\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t'.concat((0,r.__)("Status","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat((0,r.__)("Optimized","image-optimization"),'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property">\n\t\t\t\t').concat((0,r.__)("Image sizes optimized","image-optimization"),':\n\t\t\t</span>\n\n\t\t\t<span class="image-optimization-control__property-value">\n\t\t\t\t').concat(null==t?void 0:t.sizesOptimized,'\n\t\t\t</span>\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t').concat(0!==(null==t||null===(e=t.saved)||void 0===e?void 0:e.absolute)?'<span class="name image-optimization-control__property">\n\t\t\t\t'.concat((0,r.__)("Overall saving","image-optimization"),':\n\t\t\t </span>\n\n\t\t\t <span class="image-optimization-control__property-value">\n\t\t\t\t').concat(null==t||null===(o=t.saved)||void 0===o?void 0:o.relative,"% (").concat(i,")\n\t\t\t </span>"):'<span class="name image-optimization-control__property"></span>\n\n\t\t\t <span class="image-optimization-control__property-value">\n\t\t\t\t'.concat((0,r.__)("Image is fully optimized","image-optimization"),"\n\t\t\t </span>"),'\n\t\t</span>\n\n\t\t<span class="setting image-optimization-setting">\n\t\t\t<span class="name image-optimization-control__property"></span>\n\n\t\t\t<span class="image-optimization-control__property-value image-optimization-control__property-value--button">\n\t\t\t\t<button class="button button-link image-optimization-control__button image-optimization-control__button--reoptimize"\n\t\t\t\t\t\t\t\ttype="button">\n\t\t\t\t\t').concat((0,r.__)("Reoptimize","image-optimization"),"\n\t\t\t\t</button>\n\t\t\t</span>\n\t\t</span>\n\n\t\t").concat(null!=t&&t.canBeRestored?'\n\t\t\t<span class="setting image-optimization-setting">\n\t\t\t\t<span class="name image-optimization-control__property"></span>\n\n\t\t\t\t<span class="image-optimization-control__property-value image-optimization-control__property-value--button">\n\t\t\t\t\t<button class="button button-link image-optimization-control__button image-optimization-control__button--restore-original"\n\t\t\t\t\t\t\t\t\ttype="button">\n\t\t\t\t\t\t'.concat((0,r.__)("Restore original","image-optimization"),"\n\t\t\t\t\t</button>\n\t\t\t\t</span>\n\t\t\t</span>\n\t"):"","\n\t")}});function I(t){return I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},I(t)}function N(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);n&&(o=o.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),e.push.apply(e,o)}return e}function R(t){for(var n=1;n<arguments.length;n++){var e=null!=arguments[n]?arguments[n]:{};n%2?N(Object(e),!0).forEach((function(n){var o,r,i;o=t,r=n,i=e[n],(r=B(r))in o?Object.defineProperty(o,r,{value:i,enumerable:!0,configurable:!0,writable:!0}):o[r]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):N(Object(e)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}))}return t}function M(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,B(o.key),o)}}function B(t){var n=function(t,n){if("object"!==I(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==I(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===I(n)?n:String(n)}var A=function(){function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.controlWrapper=n,this.context=new E(n).getContext(),this.action=new E(n).getAction(),this.canBeRestored=new E(n).canBeRestored(),this.templates={"list-view":T,"meta-box":P,"details-view":C}}var n,e;return n=t,(e=[{key:"renderNotOptimized",value:function(t){this.controlWrapper.className=this.mixControlContextClass(c.controlNotOptimizedClassName),this.controlWrapper.innerHTML=this.getTemplates().notOptimizedTemplate(t),this.controlWrapper.dataset.imageOptimizationStatus="not-optimized"}},{key:"renderOptimized",value:function(t){var n,e=this.canBeRestored&&0!==(null==t||null===(n=t.saved)||void 0===n?void 0:n.absolute);this.controlWrapper.className=this.mixControlContextClass(c.controlOptimizedClassName),this.controlWrapper.innerHTML=this.getTemplates().optimizedTemplate(R(R({},t),{},{canBeRestored:e})),this.controlWrapper.dataset.imageOptimizationStatus="optimized"}},{key:"renderError",value:function(t){var n=t.message,e=t.imagesLeft,o=t.action;this.controlWrapper.className=this.mixControlContextClass(c.controlErrorClassName),this.controlWrapper.innerHTML=this.getTemplates().errorTemplate(n,e),this.controlWrapper.dataset.imageOptimizationAction=o,this.controlWrapper.dataset.imageOptimizationStatus="error"}},{key:"renderLoading",value:function(t){this.controlWrapper.className=this.mixControlContextClass(c.controlLoadingClassName),this.controlWrapper.innerHTML=this.getTemplates().loadingTemplate(t),this.controlWrapper.dataset.imageOptimizationStatus="loading"}},{key:"getTemplates",value:function(){var t=this.templates[this.context];if(!t)throw new Error("No templates found for the context ".concat(this.context));return t}},{key:"mixControlContextClass",value:function(t){var n=c.controlWrapper[this.context];if(!n)throw new Error("No context className found for the context ".concat(this.context));return"".concat(t," ").concat(n)}}])&&M(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}();function F(t){return F="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},F(t)}function G(){G=function(){return n};var t,n={},e=Object.prototype,o=e.hasOwnProperty,r=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{s({},"")}catch(t){s=function(t,n,e){return t[n]=e}}function l(t,n,e,o){var i=n&&n.prototype instanceof v?n:v,a=Object.create(i.prototype),c=new T(o||[]);return r(a,"_invoke",{value:L(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var m="suspendedStart",f="suspendedYield",g="executing",y="completed",h={};function v(){}function d(){}function b(){}var _={};s(_,a,(function(){return this}));var w=Object.getPrototypeOf,z=w&&w(w(P([])));z&&z!==e&&o.call(z,a)&&(_=z);var O=b.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(n){s(t,n,(function(t){return this._invoke(n,t)}))}))}function x(t,n){function e(r,i,a,c){var u=p(t[r],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==F(l)&&o.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;r(this,"_invoke",{value:function(t,o){function r(){return new n((function(n,r){e(t,o,n,r)}))}return i=i?i.then(r,r):r()}})}function L(n,e,o){var r=m;return function(i,a){if(r===g)throw new Error("Generator is already running");if(r===y){if("throw"===i)throw a;return{value:t,done:!0}}for(o.method=i,o.arg=a;;){var c=o.delegate;if(c){var u=E(c,o);if(u){if(u===h)continue;return u}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(r===m)throw r=y,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);r=g;var s=p(n,e,o);if("normal"===s.type){if(r=o.done?y:f,s.arg===h)continue;return{value:s.arg,done:o.done}}"throw"===s.type&&(r=y,o.method="throw",o.arg=s.arg)}}}function E(n,e){var o=e.method,r=n.iterator[o];if(r===t)return e.delegate=null,"throw"===o&&n.iterator.return&&(e.method="return",e.arg=t,E(n,e),"throw"===e.method)||"return"!==o&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+o+"' method")),h;var i=p(r,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,h;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function j(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function P(n){if(n||""===n){var e=n[a];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,i=function e(){for(;++r<n.length;)if(o.call(n,r))return e.value=n[r],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(F(n)+" is not iterable")}return d.prototype=b,r(O,"constructor",{value:b,configurable:!0}),r(b,"constructor",{value:d,configurable:!0}),d.displayName=s(b,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===d||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},S(x.prototype),s(x.prototype,c,(function(){return this})),n.AsyncIterator=x,n.async=function(t,e,o,r,i){void 0===i&&(i=Promise);var a=new x(l(t,e,o,r),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var o in n)e.push(o);return e.reverse(),function t(){for(;e.length;){var o=e.pop();if(o in n)return t.value=o,t.done=!1,t}return t.done=!0,t}},n.values=P,T.prototype={constructor:T,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!n)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function r(o,r){return c.type="throw",c.arg=n,e.next=o,r&&(e.method="next",e.arg=t),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),h},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),j(e),h}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var o=e.completion;if("throw"===o.type){var r=o.arg;j(e)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(n,e,o){return this.delegate={iterator:P(n),resultName:e,nextLoc:o},"next"===this.method&&(this.arg=t),h}},n}function H(t,n,e,o,r,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).then(o,r)}function W(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,r=function(t,n){if("object"!==F(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==F(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===F(r)?r:String(r)),o)}var r}var D=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t)}var n,e,o,r;return n=t,e=[{key:"run",value:(o=G().mark((function t(){var n,e,o,r;return G().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if((n=document.querySelectorAll(c.controlWrapperSelector)).length){t.next=3;break}return t.abrupt("return");case 3:return e=this.mapImageIds(n),t.next=6,S.getOptimizationStatus(e);case 6:o=t.sent,r=o.status,n.forEach((function(t){var n=new E(t).getImageId(),e=new E(t).getStatus(),o=r[n],i=new A(t);if(e!==o.status)if("true"!==t.dataset.isFrozen){if("error"!==e||new E(t).allowRetry())switch(o.status){case"optimization-in-progress":i.renderLoading("optimize");break;case"reoptimizing-in-progress":i.renderLoading("reoptimize");break;case"restoring-in-progress":i.renderLoading("restore");break;case"not-optimized":i.renderNotOptimized();break;case"optimized":var a={sizesOptimized:o.stats.optimized_image_count,saved:{absolute:o.stats.initial_image_size-o.stats.current_image_size,relative:Math.max(100-Math.round(o.stats.current_image_size/o.stats.initial_image_size*100),0)}};i.renderOptimized(a);break;case"optimization-failed":i.renderError({message:o.message,imagesLeft:o.images_left,action:"optimize"});break;case"reoptimizing-failed":i.renderError({message:o.message,imagesLeft:o.images_left,action:"reoptimize"});break;case"restoring-failed":i.renderError({message:o.message,action:"restore"})}}else t.dataset.isFrozen=!1}));case 9:case"end":return t.stop()}}),t,this)})),r=function(){var t=this,n=arguments;return new Promise((function(e,r){var i=o.apply(t,n);function a(t){H(i,e,r,a,c,"next",t)}function c(t){H(i,e,r,a,c,"throw",t)}a(void 0)}))},function(){return r.apply(this,arguments)})},{key:"mapImageIds",value:function(t){return Array.prototype.map.call(t,(function(t){return new E(t).getImageId()}))}}],e&&W(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),q=D;function Y(t){return Y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Y(t)}function U(){U=function(){return n};var t,n={},e=Object.prototype,o=e.hasOwnProperty,r=Object.defineProperty||function(t,n,e){t[n]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function s(t,n,e){return Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[n]}try{s({},"")}catch(t){s=function(t,n,e){return t[n]=e}}function l(t,n,e,o){var i=n&&n.prototype instanceof v?n:v,a=Object.create(i.prototype),c=new T(o||[]);return r(a,"_invoke",{value:L(t,e,c)}),a}function p(t,n,e){try{return{type:"normal",arg:t.call(n,e)}}catch(t){return{type:"throw",arg:t}}}n.wrap=l;var m="suspendedStart",f="suspendedYield",g="executing",y="completed",h={};function v(){}function d(){}function b(){}var _={};s(_,a,(function(){return this}));var w=Object.getPrototypeOf,z=w&&w(w(P([])));z&&z!==e&&o.call(z,a)&&(_=z);var O=b.prototype=v.prototype=Object.create(_);function S(t){["next","throw","return"].forEach((function(n){s(t,n,(function(t){return this._invoke(n,t)}))}))}function x(t,n){function e(r,i,a,c){var u=p(t[r],t,i);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==Y(l)&&o.call(l,"__await")?n.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):n.resolve(l).then((function(t){s.value=t,a(s)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;r(this,"_invoke",{value:function(t,o){function r(){return new n((function(n,r){e(t,o,n,r)}))}return i=i?i.then(r,r):r()}})}function L(n,e,o){var r=m;return function(i,a){if(r===g)throw new Error("Generator is already running");if(r===y){if("throw"===i)throw a;return{value:t,done:!0}}for(o.method=i,o.arg=a;;){var c=o.delegate;if(c){var u=E(c,o);if(u){if(u===h)continue;return u}}if("next"===o.method)o.sent=o._sent=o.arg;else if("throw"===o.method){if(r===m)throw r=y,o.arg;o.dispatchException(o.arg)}else"return"===o.method&&o.abrupt("return",o.arg);r=g;var s=p(n,e,o);if("normal"===s.type){if(r=o.done?y:f,s.arg===h)continue;return{value:s.arg,done:o.done}}"throw"===s.type&&(r=y,o.method="throw",o.arg=s.arg)}}}function E(n,e){var o=e.method,r=n.iterator[o];if(r===t)return e.delegate=null,"throw"===o&&n.iterator.return&&(e.method="return",e.arg=t,E(n,e),"throw"===e.method)||"return"!==o&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+o+"' method")),h;var i=p(r,n.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,h;var a=i.arg;return a?a.done?(e[n.resultName]=a.value,e.next=n.nextLoc,"return"!==e.method&&(e.method="next",e.arg=t),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function k(t){var n={tryLoc:t[0]};1 in t&&(n.catchLoc=t[1]),2 in t&&(n.finallyLoc=t[2],n.afterLoc=t[3]),this.tryEntries.push(n)}function j(t){var n=t.completion||{};n.type="normal",delete n.arg,t.completion=n}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function P(n){if(n||""===n){var e=n[a];if(e)return e.call(n);if("function"==typeof n.next)return n;if(!isNaN(n.length)){var r=-1,i=function e(){for(;++r<n.length;)if(o.call(n,r))return e.value=n[r],e.done=!1,e;return e.value=t,e.done=!0,e};return i.next=i}}throw new TypeError(Y(n)+" is not iterable")}return d.prototype=b,r(O,"constructor",{value:b,configurable:!0}),r(b,"constructor",{value:d,configurable:!0}),d.displayName=s(b,u,"GeneratorFunction"),n.isGeneratorFunction=function(t){var n="function"==typeof t&&t.constructor;return!!n&&(n===d||"GeneratorFunction"===(n.displayName||n.name))},n.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,b):(t.__proto__=b,s(t,u,"GeneratorFunction")),t.prototype=Object.create(O),t},n.awrap=function(t){return{__await:t}},S(x.prototype),s(x.prototype,c,(function(){return this})),n.AsyncIterator=x,n.async=function(t,e,o,r,i){void 0===i&&(i=Promise);var a=new x(l(t,e,o,r),i);return n.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},S(O),s(O,u,"Generator"),s(O,a,(function(){return this})),s(O,"toString",(function(){return"[object Generator]"})),n.keys=function(t){var n=Object(t),e=[];for(var o in n)e.push(o);return e.reverse(),function t(){for(;e.length;){var o=e.pop();if(o in n)return t.value=o,t.done=!1,t}return t.done=!0,t}},n.values=P,T.prototype={constructor:T,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(j),!n)for(var e in this)"t"===e.charAt(0)&&o.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var e=this;function r(o,r){return c.type="throw",c.arg=n,e.next=o,r&&(e.method="next",e.arg=t),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var u=o.call(a,"catchLoc"),s=o.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,n){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc<=this.prev&&o.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var i=r;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=n&&n<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=n,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(t,n){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&n&&(this.next=n),h},finish:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),j(e),h}},catch:function(t){for(var n=this.tryEntries.length-1;n>=0;--n){var e=this.tryEntries[n];if(e.tryLoc===t){var o=e.completion;if("throw"===o.type){var r=o.arg;j(e)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(n,e,o){return this.delegate={iterator:P(n),resultName:e,nextLoc:o},"next"===this.method&&(this.arg=t),h}},n}function K(t,n,e,o,r,i,a){try{var c=t[i](a),u=c.value}catch(t){return void e(t)}c.done?n(u):Promise.resolve(u).then(o,r)}function J(t){return function(){var n=this,e=arguments;return new Promise((function(o,r){var i=t.apply(n,e);function a(t){K(i,o,r,a,c,"next",t)}function c(t){K(i,o,r,a,c,"throw",t)}a(void 0)}))}}function Q(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,r=function(t,n){if("object"!==Y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==Y(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===Y(r)?r:String(r)),o)}var r}var V=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.controlSyncRequestInProgress=!1,this.init(),this.controlSync=new q}var n,e,o,a,u,s;return n=t,e=[{key:"init",value:function(){var t=this;this.initEventListeners(),setInterval((function(){return t.runStatusCheckLoop()}),5e3)}},{key:"runStatusCheckLoop",value:(s=J(U().mark((function t(){return U().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.controlSyncRequestInProgress){t.next=2;break}return t.abrupt("return");case 2:return this.controlSyncRequestInProgress=!0,t.next=5,this.controlSync.run();case 5:this.controlSyncRequestInProgress=!1;case 6:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"initEventListeners",value:function(){var t=this;document.addEventListener("click",(function(n){return t.handleOptimizeButtonClick(n)})),document.addEventListener("click",(function(n){return t.handleReoptimizeButtonClick(n)})),document.addEventListener("click",(function(n){return t.handleRestoreButtonClick(n)}))}},{key:"handleOptimizeButtonClick",value:(u=J(U().mark((function t(n){var e,o;return U().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.target.closest("".concat(c.optimizeButtonSelector,", ").concat(c.tryAgainOptimizeButtonSelector))){t.next=2;break}return t.abrupt("return");case 2:return(0,i.speak)((0,r.__)("Optimization is in progress","image-optimization"),"assertive"),e=n.target.closest(c.controlWrapperSelector),(o=new A(e)).renderLoading("optimize"),t.prev=6,e.dataset.isFrozen=!0,t.next=10,S.optimizeSingleImage({imageId:new E(e).getImageId(),reoptimize:!1});case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),o.renderError(t.t0);case 15:case"end":return t.stop()}}),t,null,[[6,12]])}))),function(_x){return u.apply(this,arguments)})},{key:"handleReoptimizeButtonClick",value:(a=J(U().mark((function t(n){var e,o;return U().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.target.closest("".concat(c.reoptimizeButtonSelector,", ").concat(c.tryAgainReoptimizeButtonSelector))){t.next=2;break}return t.abrupt("return");case 2:return(0,i.speak)((0,r.__)("Reoptimizing is in progress","image-optimization"),"assertive"),e=n.target.closest(c.controlWrapperSelector),(o=new A(e)).renderLoading("reoptimize"),t.prev=6,e.dataset.isFrozen=!0,t.next=10,S.optimizeSingleImage({imageId:new E(e).getImageId(),reoptimize:!0});case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),o.renderError(t.t0);case 15:case"end":return t.stop()}}),t,null,[[6,12]])}))),function(t){return a.apply(this,arguments)})},{key:"handleRestoreButtonClick",value:(o=J(U().mark((function t(n){var e,o;return U().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n.target.closest("".concat(c.restoreButtonSelector,", ").concat(c.tryAgainRestoreButtonSelector))){t.next=2;break}return t.abrupt("return");case 2:return(0,i.speak)((0,r.__)("Image restoring is in progress","image-optimization"),"assertive"),e=n.target.closest(c.controlWrapperSelector),(o=new A(e)).renderLoading("restore"),t.prev=6,e.dataset.isFrozen=!0,t.next=10,S.restoreSingleImage(new E(e).getImageId());case 10:t.next=15;break;case 12:t.prev=12,t.t0=t.catch(6),o.renderError(t.t0);case 15:case"end":return t.stop()}}),t,null,[[6,12]])}))),function(t){return o.apply(this,arguments)})}],e&&Q(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}(),X=V;function Z(t){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Z(t)}function $(t,n){for(var e=0;e<n.length;e++){var o=n[e];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(void 0,r=function(t,n){if("object"!==Z(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var o=e.call(t,"string");if("object"!==Z(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(o.key),"symbol"===Z(r)?r:String(r)),o)}var r}var tt=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.init()}var n,e;return n=t,(e=[{key:"init",value:function(){new o,new X}}])&&$(n.prototype,e),Object.defineProperty(n,"prototype",{writable:!1}),t}();document.addEventListener("DOMContentLoaded",(function(){return new tt}))}();
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка