-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathspeedsize-local.js
5 lines (5 loc) · 21.9 KB
/
speedsize-local.js
1
2
3
4
5
/* 20-12-2021 */
(function () {
var config = {"clientId":"08612fe1-9391-4cf3-ac1a-6dd49c36b276","isAllowed":true,"ignoredFiles":["captcha_code_file.php"],"forbiddenPaths":["/jira","/jira/*","/confluence","/confluence/*"],"mLinkBaseUrl":"https://speedmedia.jfrog.com","whitelistDomains":["jfrog.com","jfrog.info","jfrog-swampup.site.strattic.io"],"format":"auto","useOriginalCDN":false,"allowedPaths":[],"lazyload":{"hideBackgrounds":false,"blurredPlaceholders":false,"awaitWorker":false,"native":true,"hideImgElements":false,"eagerCheck":false},"maxDpr":1.5,"allowCrossOrigin":false,"enableStatement":""} || {};
var e,t,i,r=10;function n(e){e&&e.postMessage({type:"WINDOW_PARAMS",data:{DPR:window.devicePixelRatio,vpWidth:window.screen.width,vpHeight:window.screen.height}})}navigator.serviceWorker&&navigator.serviceWorker.controller&&n(navigator.serviceWorker.controller);var a=1.5,s=window.screen.width*Math.min(window.devicePixelRatio,config.maxDpr||a),o=window.screen.height*Math.min(window.devicePixelRatio,config.maxDpr||a),d=window.location.origin+window.location.pathname;function c(e){var t=new URL(e,d),i=t.href;return t.hash&&(i=t.origin+t.pathname+t.search),{srcUrl:i.replace(/%7B/g,"{").replace(/%7D/g,"}"),hash:t.hash||"",hostname:t.hostname,pathname:t.pathname}}"/"===d.charAt(d.length-1)||d.endsWith(".html")||d.endsWith(".htm")||d.endsWith(".php")||d.endsWith(".asp")||d.endsWith(".aspx")||d.endsWith(".jsp")||(d+="/");var u=new URL(config.mLinkBaseUrl).hostname;function g(e){var t=!1,{hostname:i}=new URL(e,d);if(i===u)return!1;if(config.whitelistDomains&&config.whitelistDomains.length)for(var r=0;r<config.whitelistDomains.length;r+=1){var n=config.whitelistDomains[r];if(i.indexOf(n)>=0){t=!0;break}}return t}function l(e){if(!config.ignoredFiles||!config.ignoredFiles.length)return!1;for(var t=!1,i=0;i<config.ignoredFiles.length;i+=1){var r=config.ignoredFiles[i];(r.endsWith("*")&&0===e.indexOf(r.substring(0,r.length-1))||r===e)&&(t=!0)}return t}function p(e,t,i,r,n,d){if(0===t.indexOf("data:image"))return t;var u="image"===e?me:ve,{srcUrl:p,hash:f,hostname:m,pathname:v}=c(t),A=n||"";if(!config.allowCrossOrigin&&b(p)&&!g(p))return t;if(config.ignoredFiles&&config.ignoredFiles.length&&l(v))return t;var w=r||{},y=[];A&&(y.push(A),A.indexOf("c_auto")>=0&&-1===A.indexOf("w_")&&-1===A.indexOf("h_")&&(w.w=s,w.h=o)),"string"==typeof i&&(i=parseInt(Number(i.replace("px","")),10));var z=i||window.screen.width,O=h(Math.min(z,window.screen.width)*Math.min(window.devicePixelRatio,config.maxDpr||a));Object.keys(w).forEach((e=>{y.push(`${e}_${w[e]}`)})),config.disableAutoResize||w.w||w.h||d||y.push(`mxw_${O}`),u&&y.push(u),config.format&&y.push(`f_${config.format}`);var _=y.join(",");return`${config.mLinkBaseUrl}/${config.clientId}/${p}/${_}${f}`}function f(e){if(e.hasAttribute("data-speedsize-src")||e.hasAttribute("data-speedsize-srcset")){if(e.hasAttribute("data-speedsize-srcset")&&(e.srcset=e.getAttribute("data-speedsize-srcset")),e.hasAttribute("data-speedsize-src")&&(e.src=p("image",e.getAttribute("data-speedsize-src"),e.getAttribute("data-speedsize-width"),null,e.getAttribute("data-speedsize-params"))),e.hasAttribute("data-speedsize-width")){const t=e.getAttribute("data-speedsize-width");t&&e.setAttribute("width",t)}if(e.hasAttribute("data-speedsize-height")){const t=e.getAttribute("data-speedsize-height");t&&e.setAttribute("height",t)}e.setAttribute("data-processed","true")}}function h(e){if(e<=Z[0])return Z[0];if(e>=Z[Z.length-1])return Z[Z.length-1];for(var t=Z.length-2;t>=0;t--)if(e>=Z[t])return Z[t+1]}function b(e){if(!e||0===e.indexOf("data:image"))return!1;var t=new URL(e,d).hostname;return t===u||!t.endsWith(window.location.hostname)&&0!==e.indexOf(window.location.origin)}function m(e){if(!e)return null;var r=parseInt(e,10);return e.endsWith("px")?r:e.endsWith("vw")?(t||(t=Math.max(document.documentElement.clientWidth||0,window.innerWidth||0)),parseInt(r*t/100,10)):e.endsWith("vh")?(i||(i=Math.max(document.documentElement.clientHeight||0,window.innerHeight||0)),parseInt(r*i/100,10)):null}function v(e){if(!e||"string"!=typeof e)return null;for(var t=null,i=e.split(","),r=0;r<i.length;r+=1){var n=i[r].trim().split(")"),a=n[0]+")",s=n[1]&&n[1].trim();window.matchMedia(a).matches&&(t=m(s))}return t}function A(e){var t=config.lazyload;return!e.isConnected&&config.notConnectedLazyload&&(t=config.notConnectedLazyload),t}function w(e){var t=A(e);if(!(e.dataset["speedsize-ignore"]||e.dataset.speedsizeIgnore||e.hasAttribute("data-speedsize-ignore"))&&!(e.speedsize||e.isObserved||0===e.src.indexOf("data:image")&&!e.hasAttribute("data-srcset"))&&(config.allowCrossOrigin||!b(e.src)||g(e.src))){if(e.hasAttribute("data-src")&&!config.ignoreDataAttributes){var i=p("image",e.getAttribute("data-src"),e.getAttribute("data-speedsize-width"),null,e.getAttribute("data-speedsize-params"));e.setAttribute("data-src",i)}if(e.hasAttribute("data-srcset")&&!config.ignoreDataAttributes){var r=z(e.dataset.srcset,"image",e);e.setAttribute("data-srcset",r)}if(e.speedsize=!0,!e.complete&&(e.hasAttribute("src")||e.hasAttribute("srcset"))){if(!e.hasAttribute("data-speedsize-src")&&e.getAttribute("src")&&(e.setAttribute("data-speedsize-src",e.getAttribute("src")),e.removeAttribute("src")),e.srcset){r=z(e.srcset,"image",e);e.setAttribute("data-speedsize-srcset",r),e.removeAttribute("srcset")}if(!config.ignoreDimensionAttributes&&e.hasAttribute("width")&&(e.setAttribute("data-speedsize-width",e.getAttribute("width")),e.removeAttribute("width")),!config.ignoreDimensionAttributes&&e.hasAttribute("height")&&(e.setAttribute("data-speedsize-height",e.getAttribute("height")),e.removeAttribute("height")),!config.ignoreDimensionAttributes&&e.hasAttribute("sizes")){var n=v(e.getAttribute("sizes"));n&&e.setAttribute("data-speedsize-width",n)}if(t){if(!t.eagerShowNotConnected)return t.native?(e.hasAttribute("loading")||e.setAttribute("loading","lazy"),void f(e)):void 0;f(e)}else f(e)}}}function y(e){for(var t=[],i="url(",r=e;r.indexOf(i)>=0;){var n=r.indexOf(i);if(-1===n)return null;var a=n+i.length,s=r.indexOf(")",a),o=r.substring(a,s);if('"'!==o.charAt(0)&&"'"!==o.charAt(0)||(o=o.substring(1,o.length-1)),0!==o.indexOf("data:")&&t.push(o),r=r.substring(s+1),-1===s)break}return t}function z(e,t,i){var r=t||"image";if(!e)return"";if(e.indexOf(config.mLinkBaseUrl)>=0)return e;for(var n=e.split(","),a=0;a<n.length;a+=1){var s=n[a].trim().split(" ")[0],o=c(s).srcUrl;if(config.allowCrossOrigin||!b(o)||g(o)){var d=p(r,s,i&&(i.getAttribute("data-speedsize-width")||i.getAttribute("width")),null,i&&i.getAttribute("data-speedsize-params"));n[a]=n[a].replace(s,d)}}return n.join(",")}function O(e,t,i){if(String.prototype.replaceAll)return e.replaceAll(t,i);var r=new RegExp(t,"g");return e.replace(r,i)}function _(e){if(!e.hasAttribute("data-processed")){var t=!1;config.disableBackgroundAutoResize&&(t=!0);var i=e.style.backgroundImage,r=!1;if(!i&&e.hasAttribute("style")&&(r=!0,i=e.getAttribute("style")),i){var n=y(i);n=Array.from(new Set(n));for(var a={},s=i,o=0;o<n.length;o+=1){var d=n[o];s=O(s,d,p("image",c(d).srcUrl,null,a,e.getAttribute("data-speedsize-params"),t))}n.length&&(r?e.setAttribute("style",s):e.style.backgroundImage=s),e.setAttribute("data-processed",!0)}}}function k(e){var t,i={};e.hasAttribute("muted")&&!e.hasAttribute("controls")&&(i.v="muted",e.muted=!0);var r,n=e.getAttribute("width");n&&(t=parseInt(n,10));var a=e.getAttribute("height");if(a&&(r=parseInt(a,10)),config.videoComputeStyles||config.enableVideoAutocrop){var s=window.getComputedStyle(e);t||(t=parseInt(s.width.replace("px",""),10)),r||(r=parseInt(s.height.replace("px",""),10))}if(300===t)return e.setAttribute("poster",te),void window.requestAnimationFrame((function(){var t=window.getComputedStyle(e).width.replace("px","");if(t=parseInt(t,10),e.src=p("video",e.getAttribute("data-speedsize-src"),t,i,e.getAttribute("data-speedsize-params")),e.hasAttribute("data-speedsize-poster")){var r=p("image",e.getAttribute("data-speedsize-poster"),t,null,e.getAttribute("data-speedsize-params"));e.setAttribute("poster",r)}}));if(e.src=p("video",e.getAttribute("data-speedsize-src"),t,i,e.getAttribute("data-speedsize-params")),e.hasAttribute("data-speedsize-poster")){var o=p("image",e.getAttribute("data-speedsize-poster"),t,null,e.getAttribute("data-speedsize-params"));e.setAttribute("poster",o)}}var x=window.screen.height;function E(e){if(e.hasAttribute("src"))return e.getAttribute("src");var t=e.querySelectorAll("source");if(!t||!t.length)return"";for(var i,r,n,a=t[t.length-1].src,s=0;s<t.length;s+=1){var o=t[s];o.hasAttribute("type")&&"video/mp4"===o.getAttribute("type")&&(r=o.src),o.src.endsWith(".mp4")&&(n=o.src),o.hasAttribute("media")&&window.matchMedia(o.getAttribute("media")).matches&&(i=o.src)}return r||n||i||a}function I(e){for(var t=e.querySelectorAll("source"),i=0;i<t.length;i+=1){var r=t[i],n=r.getAttribute("data-src");if(n&&!n.speedsize){var a=p("video",n,e.getAttribute("data-speedsize-width"),null,e.getAttribute("data-speedsize-params"));r.setAttribute("data-src",a),n.speedsize=!0}}}function C(e){if(!config.disableVideo&&!e.speedsize&&!(e.dataset["speedsize-ignore"]||e.dataset.speedsizeIgnore||e.hasAttribute("data-speedsize-ignore"))){e.hasAttribute("autoplay")&&e.hasAttribute("poster")&&e.removeAttribute("poster");var t=E(e);if(I(e),t&&(e.speedsize=!0,config.allowCrossOrigin||!b(t)||g(t))){e.hasAttribute("data-speedsize-src")||e.setAttribute("data-speedsize-src",t),e.hasAttribute("poster")&&!e.hasAttribute("data-speedsize-poster")&&e.setAttribute("data-speedsize-poster",e.getAttribute("poster")),e.hasAttribute("autoplay")&&(e.hasAttribute("muted")||e.setAttribute("muted",!0),e.hasAttribute("playsinline")||e.setAttribute("playsinline",!0));var i=A(e);if(i)return i.native?(e.hasAttribute("loading")||e.setAttribute("loading","lazy"),void k(e)):void 0;k(e)}}}function N(e){var t=navigator.userAgentData;if(!e||!t)return null;var i=null;if(t&&t.brands&&t.brands.length)for(var r=t.brands,n=0;n<r.length;n+=1)if(r[n].brand===e){i=r[n].version;break}return i}function L(){return!!N("Opera")||ie.includes("opr")}function S(e,t=null){var i=N("Opera");return i=i?parseInt(i,10):parseInt(ie.substring(ie.indexOf("opr")).split("/")[1],10),t?i>=e&&i<=t:i>=e}function P(){return ie.includes("firefox")}function W(e,t=null){var i=parseInt(ie.substring(ie.indexOf("firefox")).split("/")[1],10);return t?i>=e&&i<=t:i>=e}function D(){return!!N("Microsoft Edge")||ie.includes("edg")}function M(e,t=null){var i=N("Microsoft Edge");return i=i?parseInt(i,10):parseInt(ie.substring(ie.indexOf("edg")).split("/")[1],10),t?i>=e&&i<=t:i>=e}function R(){return!(!ie.includes("safari")||ie.includes("chrome")||ie.includes("crios"))}function U(){return R()&&ie.includes("macintosh")}function B(e,t=null){var i=parseInt(ie.substring(ie.indexOf("version")).split("/")[1],10);return t?i>=e&&i<=t:i>=e}function H(){return ie.includes("iphone")||ie.includes("ipad")||ie.includes("macintosh")}function j(){return ie.includes("android")}function T(){return R()&&(ie.includes("iphone")||ie.includes("ipad"))}function V(){return ie.includes("crios")}function $(e,t=null){var i=parseInt(ie.split(" os")[1],10)||parseInt(ie.split(" os x")[1],10);return t?i>=e&&i<=t:i>=e}function F(){if(N("Google Chrome"))return!0;var e=navigator.vendor&&navigator.vendor.toLowerCase();return!L()&&!P()&&!D()&&!R()&&("google inc."===e||ie.includes("chrome")&&j())}function G(e,t=null){var i=N("Google Chrome");return i=i?parseInt(i,10):parseInt(ie.substring(ie.indexOf("chrome")).split("/")[1],10),t?i>=e&&i<=t:i>=e}function K(){return D()?M(18):P()?W(65):L()?S(19):!(!T()&&!V())&&$(14)}function q(){return!!D()&&M(12,18)}function Q(){return U()?B(5):!(!T()&&!V())&&$(5)}function J(){return U()?B(13):!(!T()&&!V())&&$(11)}function X(){return D()?M(79):P()?W(28):L()?S(16):!!F()&&G(25)}function Y(){return!P()||H()||j()?L()?S(57):!(!F()||j())&&G(70):W(67)}for(var Z=[64,96,100,128,160,192,200,240,256,320,360,480,540,600,640,720,750,768,800,828,1024,1080,1125,1152,1170,1200,1242,1280,1284,1366,1440,1536,1600,1650,1920,2048,2256,2304,2560,2736,2880,3e3,3200,3440,3840],ee='data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="1"/>',te="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAADwAAAAABCAQAAADJJpP6AAAAHklEQVR42u3BAQkAAAACoPp/uh+hNgAAAAAAAABcGDwCAAKXu7/2AAAAAElFTkSuQmCC",ie=navigator.userAgent.toLowerCase(),re=(window.location.search||"").substring(1),ne=re.split("&"),ae=[],se=0;se<ne.length;se+=1){"nospeedsize"!==(ge=ne[se])&&ge!==config.enableStatement&&ae.push(ge)}var oe=ae.join("&"),de=oe?`${window.location.pathname}?${oe}`:window.location.pathname;de=de.toLowerCase();var ce=!0,ue=!1;if(ne&&ne.length)for(se=0;se<ne.length;se+=1){var ge;if("nospeedsize"===(ge=ne[se])){ce=!1;break}}if(config.forbiddenPaths&&config.forbiddenPaths.length){var le=!0;for(se=0;se<config.forbiddenPaths.length;se+=1){var pe=config.forbiddenPaths[se].toLowerCase();if(pe.endsWith("*")&&0===de.indexOf(pe.substring(0,pe.length-1)))le=!1;else if(pe===de){le=!1;break}}le||(ce=!1)}function fe(){navigator.serviceWorker.register(config.workerLocation||"/speedsize-sw.js").then((function(e){if(config.lazyload&&config.lazyload.awaitWorker){var t=e.installing||e.waiting||e.active;"activated"===t.state?(n(t),styleSheet&&styleSheet.parentElement&&styleSheet.parentElement.removeChild(styleSheet)):t.addEventListener("statechange",(function(e){"activated"===e.target.state&&(n(t),styleSheet&&styleSheet.parentElement&&styleSheet.parentElement.removeChild(styleSheet))}))}})).catch((function(e){console.log("Service worker registration failed:",e)}))}"serviceWorker"in navigator&&!ce&&navigator.serviceWorker.getRegistrations().then((function(e){var t="speedsize-sw.js";if(config.workerLocation){var i=config.workerLocation.split("/");t=i[i.length-1]}e.forEach((function(e){if(e.active){var i=e.active.scriptURL.split("/");i[i.length-1].split("?")[0]===t&&e.unregister()}}))}));var he=[],be=[];K()&&he.push("s_webp"),q()&&he.push("s_jxr"),Q()&&he.push("s_jp2"),R()&&he.push("s_videoimg","ns_atwebp"),X()&&be.push("s_vp9"),J()&&be.push("s_hevc"),Y()&&be.push("s_av1");var me=he.join(","),ve=be.join(","),{setAttribute:Ae,setAttributeNS:we,appendChild:ye,insertBefore:ze}=Element.prototype;const Oe=Object.getOwnPropertyDescriptor(HTMLImageElement.prototype,"src"),{set:_e,get:ke}=Oe,xe=Object.getOwnPropertyDescriptor(HTMLMediaElement.prototype,"src"),{set:Ee,get:Ie}=xe,Ce=Object.getOwnPropertyDescriptor(Element.prototype,"innerHTML"),{set:Ne,get:Le}=Ce;var Se=()=>{Element.prototype.setAttribute=Ae,Element.prototype.setAttributeNS=we,Element.prototype.appendChild=ye,Element.prototype.insertBefore=ze,Object.defineProperty(HTMLImageElement.prototype,"src",{configurable:!0,enumerable:!0,__proto__:Oe.__proto__,get:ke,set:_e}),Object.defineProperty(HTMLMediaElement.prototype,"src",{configurable:!0,enumerable:!0,__proto__:xe.__proto__,get:Ie,set:Ee}),Object.defineProperty(Element.prototype,"innerHTML",{configurable:!0,enumerable:!0,__proto__:Ce.__proto__,get:Le,set:Ne}),CSSStyleDeclaration.prototype.__defineSetter__("backgroundImage",(function(e){this.setProperty("background-image",e)}))},Pe=()=>{navigator.serviceWorker&&navigator.serviceWorker.controller&&navigator.serviceWorker.controller.postMessage({type:"DISABLE_WORKER"}),Se(),e&&e.disconnect()},We=()=>{var e=e=>function(){var t=arguments;if("IMG"!==this.tagName||config.skipSrcHookIfNotConnected&&!this.isConnected||"src"!==t[0]&&("data-src"!==t[0]||config.ignoreDataAttributes)||!t[1]||0===t[1].indexOf(config.mLinkBaseUrl)||0===t[1].indexOf("data:image")||b(t[1])&&!g(t[1]))"VIDEO"!==this.tagName||config.skipSrcHookIfNotConnected&&!this.isConnected||"poster"!==t[0]&&"data-poster"!==t[0]||config.ignoreDataAttributes||!t[1]||0===t[1].indexOf(config.mLinkBaseUrl)||0===t[1].indexOf("data:image")||b(t[1])&&!g(t[1])?config.skipSrcHookIfNotConnected&&!this.isConnected||"VIDEO"!==this.tagName||"src"!==t[0]&&"data-src"!==t[0]||config.ignoreDataAttributes||!t[1]||0===t[1].indexOf(config.mLinkBaseUrl)||b(t[1])&&!g(t[1])||(t[1]=p("video",t[1],this.getAttribute("width"),null,this.getAttribute("data-speedsize-params")),this.speedsize=!0):(t[1]=p("image",t[1],this.getAttribute("width"),null,this.getAttribute("data-speedsize-params")),this.speedsize=!0);else{var i=A(this);i&&i.native&&!i.eagerShowNotConnected&&!this.hasAttribute("loading")&&this.setAttribute("loading","lazy");var r=this.getAttribute("width");t[1]=p("image",t[1],r,null,this.getAttribute("data-speedsize-params")),this.speedsize=!0}var n=e.apply(this,t);return n};Element.prototype.setAttribute=e(Ae),Element.prototype.setAttributeNS=e(we);var t=e=>function(){var t=arguments,i=t[0];if(1!==i.nodeType)return e.apply(this,t);"PICTURE"===i.tagName?He(i):"IMG"===i.tagName?w(i):"VIDEO"===i.tagName?config.enableVideoAutocrop&&!i.isConnected||C(i):je(i)&&_(i);var r=e.apply(this,t);return r};Element.prototype.appendChild=t(ye),Element.prototype.insertBefore=t(ze),Object.defineProperty(HTMLImageElement.prototype,"src",{configurable:!0,enumerable:!0,__proto__:Oe.__proto__,get:ke,set:function(){var e=arguments;if("IMG"===this.tagName&&(!config.skipSrcHookIfNotConnected||this.isConnected)&&e[0]&&0!==e[0].indexOf(config.mLinkBaseUrl)&&0!==e[0].indexOf("data:image")&&(!b(e[0])||g(e[0]))){var t=this.getAttribute("width"),i=p("image",e[0],t,null,this.getAttribute("data-speedsize-params")),r=A(this);r&&r.native&&!r.eagerShowNotConnected&&!this.hasAttribute("loading")&&this.setAttribute("loading","lazy"),e[0]=i}_e.apply(this,e)}}),Object.defineProperty(HTMLMediaElement.prototype,"src",{configurable:!0,enumerable:!0,__proto__:xe.__proto__,get:Ie,set:function(){var e=arguments;if("VIDEO"===this.tagName&&e[0]&&0!==e[0].indexOf(config.mLinkBaseUrl)&&(!b(e[0])||g(e[0]))){var t=this.getAttribute("width"),i=p("video",e[0],t,null,this.getAttribute("data-speedsize-params"));e[0]=i}Ee.apply(this,e)}}),CSSStyleDeclaration.prototype.__defineSetter__("backgroundImage",(function(e){var t=e,i=y(t),r={};if(config.enableImgAutocrop){var n=s,a=o;r.w=n,r.h=a,r.c="auto"}for(var d=0;d<i.length;d+=1){var u=i[d],g=p("image",c(u).srcUrl,null,r);t=t.replace(u,g)}this.setProperty("background-image",t)}))},De=()=>{navigator.serviceWorker&&navigator.serviceWorker.controller?navigator.serviceWorker.controller.postMessage({type:"ENABLE_WORKER"}):navigator.serviceWorker&&!config.disableWorker&&fe(),We(),e&&e.observe(document.body,{childList:!0,subtree:!0})};if(config.allowedPaths&&config.allowedPaths.length||config.forbiddenPaths&&config.forbiddenPaths.length){var{pushState:Me}=window.History.prototype;function Re(e){var t=!0,i=!0;if(config.allowedPaths&&config.allowedPaths.length){i=!1;for(var r=0;r<config.allowedPaths.length;r+=1){if((n=config.allowedPaths[r].toLowerCase())===e){i=!0;break}}t=!!i&&!!(!config.enableStatement||config.enableStatement&&ue)}if(config.forbiddenPaths&&config.forbiddenPaths.length){for(i=!0,r=0;r<config.forbiddenPaths.length;r+=1){var n;if((n=config.forbiddenPaths[r].toLowerCase()).endsWith("*")&&0===e.indexOf(n.substring(0,n.length-1)))i=!1;else if(n===e){i=!1;break}}i||(t=!1)}return t}var Ue=e=>function(){var t=arguments[2]||"",i=Re(t="string"==typeof t?t.toLowerCase():"");i?De():Pe();var r=e.apply(this,arguments);return r};window.History.prototype.pushState=Ue(Me),window.addEventListener("popstate",(function(){Re(new URL(document.location).pathname.toLowerCase())?De():Pe()}))}function Be(e){e.speedsize||(e.href=p("image",e.href),e.speedsize=!0)}function He(e){if(!(e.speedsize||e.hasAttribute("data-processed")||(e.speedsize=!0,e.dataset["speedsize-ignore"]||e.dataset.speedsizeIgnore||e.hasAttribute("data-speedsize-ignore")))){for(var t=e.getElementsByTagName("source"),i=e.getElementsByTagName("img")[0],r=0;r<t.length;r+=1){var n=t[r];const i=z(n.srcset,"image",e);n.srcset=i;const a=n.getAttribute("data-srcset");if(a){const t=z(a,"image",e);n.setAttribute("data-srcset",t)}}if(i&&i.src&&i.src!==window.location.href){var a=p("image",i.src,i.getAttribute("data-speedsize-width")||i.getAttribute("width"),null,i.getAttribute("data-speedsize-params"));i.removeAttribute("src");var s=A(e);if(s&&s.native&&!s.eagerShowNotConnected&&!i.hasAttribute("loading")&&i.setAttribute("loading","lazy"),i.src=a,i.hasAttribute("srcset")){var o=z(i.getAttribute("srcset"),"image",i);i.setAttribute("srcset",o)}}e.setAttribute("data-processed","true")}}function je(e){return!(!e.style.backgroundImage||0!==e.style.backgroundImage.indexOf('url("'))||(!!(e.hasAttribute("style")&&e.getAttribute("style").indexOf("background-image")>=0)||!!(e.hasAttribute("style")&&e.getAttribute("style").indexOf("background")>=0&&e.getAttribute("style").indexOf("url(")>=0))}function Te(e){for(var t=0;t<e.length;t+=1){var i=e[t];if(1===i.nodeType&&!i.hasAttribute("data-processed"))if("IMG"===i.tagName){if(i.parentNode&&"PICTURE"===i.parentNode.tagName)continue;w(i)}else if("VIDEO"===i.tagName)C(i);else{if("SOURCE"===i.tagName){i.parentNode&&"VIDEO"===i.parentNode.tagName&&C(i.parentNode);continue}if("PICTURE"===i.tagName)He(i);else if(je(i))_(i);else if("LINK"===i.tagName){if("preload"!==i.rel||"image"!==i.as)continue;Be(i)}else config.searchChildren&&i.childElementCount}}}if(ce){function Ve(){var e=document.createElement("meta");e.content="Viewport-Width, Width, DPR",e.httpEquiv="Accept-CH",document.head.prepend(e)}if(Ve(),window.MutationObserver&&!config.MODisabled){function $e(){return new window.MutationObserver((function(e){if(e&&e.length){for(var t,i=[];t=e.pop();)if(t.addedNodes&&t.addedNodes.length&&i.push(t),i.length>=r){var n=i;i=[],Promise.resolve(n).then((function(e){for(var t;t=e.pop();)Te(t.addedNodes)}))}if(i.length)for(var a;a=i.pop();)Te(a.addedNodes)}}))}if(e=$e(),config.processPreloadImages){var Fe=$e();function Ge(){Fe.disconnect()}Fe.observe(document.head,{childList:!0}),window.addEventListener("DOMContentLoaded",Ge,!1)}if(document.body)e.observe(document.body,{childList:!0,subtree:!0});else{var Ke=new window.MutationObserver((function(t){if(t&&t.length)for(var i;i=t.pop();)if(i.addedNodes&&i.addedNodes.length)for(var r=0;r<i.addedNodes.length;r+=1){var n=i.addedNodes[r];if(n===document.body)if(e.observe(document.body,{childList:!0,subtree:!0}),Ke.disconnect(),!config.onlyImages)Te(n.getElementsByTagName("*"))}}));Ke.observe(document.documentElement,{childList:!0})}}config.disablePrototypeHooks||We(),"serviceWorker"in navigator&&!config.disableWorker&&fe()}
})();