!function(){"use strict";class e{constructor(e){let t={root:null,rootMargin:"150px 0px 500px",threshold:this.buildThresholdList(),classTarget:this};this.observer=new IntersectionObserver(e,t)}addToObserver(e){this.observer.observe(e)}removeFromObserver(e){this.observer.unobserve(e)}buildThresholdList(){let e=[];for(let t=1;t<=6;t++){let a=t/6;e.push(a)}return e}}function t(e){let t=e.clientWidth,a=e.attributes.width?e.attributes.width.value:"auto",i=e.attributes.height?e.attributes.height.value:"auto",r="auto"===a||"auto"===i||"100%"===a||"100%"===i?e.clientHeight:parseInt(i/a*t);return t=parseInt(t),r=parseInt(r),isNaN(r)&&(r="auto"),{width:t,height:r}}function a(e,t){if(e.width<=t.width&&e.height<=t.height)return e;const a=Math.min(t.width/e.width,t.height/e.height);return a<1&&(e.width=Math.round(e.width*a),e.height=Math.round(e.height*a)),e}function i(e,t){return Object.keys(t).forEach((function(a){e[a]=t[a]})),e}let r=new class{constructor(){this.serviceDomain=".i.optimole.com",this.serviceData={key:"undefined",quality:"auto",network_optimizations:!1,backgroundReplaceClasses:[],backgroundLazySelectors:"",watchClasses:[],lazyloadOnly:"",scalingDisabled:!1,ignoreDpr:!0,customDomain:!1,maxWidth:0,maxHeight:0},"undefined"!=typeof optimoleData&&optimoleData===Object(optimoleData)&&(this.serviceData=i(this.serviceData,optimoleData)),this.hasSizeLimit=Number.isInteger(this.serviceData.maxWidth)&&Number.isInteger(this.serviceData.maxHeight)&&this.serviceData.maxWidth>0&&this.serviceData.maxHeight>0,this.hasSizeLimit&&(this.serviceData.ignoreDpr=!0),this.aTag=null}_cdnKey(){return this.serviceData.key.toLowerCase()}_sortByKey(e){const t={};return Object.keys(e).sort().forEach(a=>{t[a]=e[a]}),t}getAbsoluteUrl(e){return null===this.aTag&&(this.aTag=document.createElement("a")),this.aTag.href=e,this.aTag.href}getImageCDNUrl(e,t){const i=void 0!==this.serviceData.customDomain&&!1!==this.serviceData.customDomain;if(e.includes(this.serviceDomain)||!0===i&&e.includes(this.serviceData.customDomain))return e;if(("undefined"===this._cdnKey()||""===this._cdnKey())&&!1===i)return e;e=this.getAbsoluteUrl(e);let r=`https://${this._cdnKey()}${this.serviceDomain}`;!0===i&&(r="https://"+this.serviceData.customDomain);let s=this.serviceData.quality,o=e.split("://"),l=o[0],n=o[1];if("auto"===t.width?t.width=this.hasSizeLimit?this.serviceData.maxWidth:"auto":t.width=Math.round(t.width),"auto"===t.height?t.height=this.hasSizeLimit?this.serviceData.maxHeight:"auto":t.height=Math.round(t.height),this.hasSizeLimit){const e=a({width:t.width,height:t.height},{width:this.serviceData.maxWidth,height:this.serviceData.maxHeight});t.width=e.width,t.height=e.height}"eco"===t.quality&&(s=t.quality);let c={path:encodeURIComponent(n.replace(/\/$/,"")),scheme:l+":/",width:"w:"+t.width.toString(),height:"h:"+t.height.toString(),quality:"q:"+s.toString()};c=this._sortByKey(c);let d=[r,c.width,c.height,c.quality,c.scheme,n];return!1===this.serviceData.ignoreDpr&&window.devicePixelRatio>1&&d.splice(4,0,"dpr:"+window.devicePixelRatio.toFixed(1).toString()),d.join("/")}updateImages(e){let t=document.getElementsByTagName("img");for(let a=0;a1&&(e+="/dpr:"+window.devicePixelRatio.toFixed(1).toString())}let a=s[1]+":"+s[2],i=s[1]+":"+e;o.push({find:a.toString(),replace:i.toString()})}}let c=e;if(0===o.length)return e;for(let e in o)void 0!==o[e].find&&void 0!==o[e].replace&&(c=c.replace(o[e].find.toString(),o[e].replace.toString()));return c}sizeSafe(e){return null===e||"undefined"===e||"0"===e||0===e||isNaN(e)?"auto":e}qualityForConnection(e,t){if(!0!==this.network_optimizations)return t;let a;switch(e){case"4g":case"3g":a=t;break;case"2g":case"slow-2g":a="45";break;default:a=t}return a}sizeForConnection(e,t){if(!0!==this.network_optimizations)return t;let a=window.devicePixelRatio;switch(e){case"3g":return Math.round(t/a);case"2g":case"slow-2g":return Math.round(t/a);case"4g":default:return t}}getCDNForImage(e,a){let r=t(e);return r=i(r,a),{url:this.transformURL(this.getImageCDNUrl(e.dataset.optSrc,r),r),size:r}}},s=new class{constructor(e=null){this.replacerService=e,this.loadEarlyClass="optimole-load-early"}onlyLazyload(e){return void 0!==this.replacerService.serviceData.scalingDisabled&&!0===this.replacerService.serviceData.scalingDisabled||(!(!e.classList||!e.classList.contains(this.loadEarlyClass))||""!==this.replacerService.serviceData.lazyloadOnly&&e.classList.contains(this.replacerService.serviceData.lazyloadOnly))}requiresBetterQuality(e){return null===this.replacerService||"undefined"===this.replacerService||this.replacerService.requiresBetterQuality(e)}getImageSrc(e,r={}){let s=t(e);return this.replacerService.hasSizeLimit&&(s=a(s,{height:this.replacerService.serviceData.maxHeight,width:this.replacerService.serviceData.maxWidth})),s=i(s,r),Math.abs(e.naturalWidth-s.width)<50&&Math.abs(e.naturalHeight-s.height)<50&&(s={width:e.naturalWidth,height:e.naturalHeight}),null!==this.replacerService&&"undefined"!==this.replacerService?this.onlyLazyload(e)?{url:e.dataset.optSrc,size:s}:this.replacerService.getCDNForImage(e,s):"undefined"!==r&&"undefined"!==r.quality&&"eco"===r.quality?{url:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",size:s}:{url:e.dataset.optSrc,size:s}}prepareImage(e,t){let a=e.target;if((void 0===a.src||""===a.src)&&a.dataset.optSrc){let e={quality:"eco"},t=this.getImageSrc(a,e);a.src=t.url}t.addToObserver(a)}prepareEmbeddedVideo(e,t){let a=e.target;t.addToObserver(a)}skipLazyLoad(e){let t=e.target;if("IFRAME"===t.tagName&&t.dataset.optSrc)return t.src=t.dataset.optSrc,void(t.dataset.optLazyLoaded="true");if(t.dataset.optSrc){let e=this.getImageSrc(t);t.src=e.url,t.dataset.optLazyLoaded="true"}}lazyLoadImage(e){let t=e.target;if(void 0!==t.dataset.optSrc&&this.requiresBetterQuality(t)&&"true"!==t.dataset.optLazyLoaded){let e=this.getImageSrc(t),a=e.url,i=new Image;t.classList.add("optml_lazyload_img");let r=this;i.onload=async function(){this.complete&&(t.src=this.src,t.dataset.optLazyLoaded="true",null!==r.replacerService.serviceData&&!1===r.replacerService.serviceData.ignoreDpr&&window.devicePixelRatio>1&&(!r.onlyLazyload(t)&&"auto"!==e.size.width&&e.size.width>0&&(void 0!==t.style.maxWidth&&""!==t.style.maxWidth||"undefined"!==getComputedStyle(t).maxWidth&&""!==getComputedStyle(t).maxWidth||(t.style.maxWidth=e.size.width+"px")),!t.width&&!t.height&&!t.classList.contains(r.replacerService.serviceData.lazyloadOnly)&&"auto"!==e.size.width&&"auto"!==e.size.height&&e.size.width>0&&e.size.height>0&&(t.width=""+e.size.width,t.height=""+e.size.height)),t.dataset.optOptimizedWidth=""+e.size.width,t.dataset.optOptimizedHeight=""+e.size.height,t.classList.remove("optml_lazyload_img"))};let s=t.parentNode;if(s&&/^picture$/i.test(s.nodeName||""))for(let e of s.getElementsByTagName("source"))if(e.srcset===t.currentSrc)return void(i.src=t.currentSrc);i.src=a}else if(null!==this.replacerService&&void 0!==this.replacerService){if("true"!==t.dataset.optLazyLoaded&&this.replacerService.serviceData.watchClasses.length>0)for(let e=0;e0)for(let e=0;e0){if(void 0===e.classList||0===e.classList.length)return!1;for(let t=0;t=e)&&r.updateImages(s),g=e}))}();