text: /*
   DemandJS - v.1.0.0-rc.10
  
   https://github.com/hannasm/demandjs
   MIT License
  
  Copyright (c) 2017 Sean Hanna
  
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  SOFTWARE.
  */
  var _createClass=function(){function h(g,a){for(var b=0;b<a.length;b++){var c=a[b];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(g,c.key,c)}}return function(g,a,b){a&&h(g.prototype,a);b&&h(g,b);return g}}(),_typeof="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(h){return typeof h}:function(h){return h&&"function"===typeof Symbol&&h.constructor===Symbol&&h!==Symbol.prototype?"symbol":typeof h};
  function _classCallCheck(h,g){if(!(h instanceof g))throw new TypeError("Cannot call a class as a function");}
  (function(h,g){"function"===typeof define&&define.amd?define([],g):"object"===("undefined"===typeof module?"undefined":_typeof(module))&&module.exports?module.exports=g():h.DemandJS=g()})("undefined"!==typeof self?self:void 0,function(h){return function(){function g(a){var b=this;_classCallCheck(this,g);this.phRegistry=new WeakMap;this.injecting=new WeakMap;this.observed=new WeakMap;this.queuedFuncs=[];var c={};a&&"linkHandler"in a&&(c=a.linkHandler,delete a.linkHandler);this.defaultLoadingHtml='<div style="width:100%;height:100%">Loading In Progress</div>';
  this.defaultFailureHtml='<div style="background-color:#F00;color:#FFF;font-size:20pt;">ERROR</div>';this.options=Object.assign({previewLoading:!1,previewFailure:!1,demandClassAttribute:"data-demand",defaultDemandClass:"default",loadingHtml:this.defaultLoadingHtml,failureHtml:this.defaultFailureHtml,createLoadingNode:function(a){return b.createLoadingNode(a)},createFailureNode:function(a,c){return b.createFailureNode(a,c)},shouldRemove:function(a){return!("tagName"in a)||!a.tagName.match(/link/i)},
  shouldInsertOnLoad:function(a){return b.options.shouldRemove(a)},selector:"img,video,picture,iframe,link.demand",ignoreSelector:".nodemand",rootMargin:"256px",threshold:.001,rootMarginOuter:"2048px",thresholdOuter:.001,enableOffloading:!1,onLoadBegin:function(a){return b.onLoadBegin(a)},onLoadSuccess:function(a){return b.onLoadSuccess(a)},onLoadFailure:function(a,c){return b.onLoadFailure(a,c)},onLoadComplete:function(a){return b.onLoadComplete(a)},alternatives:[],urlPerformance:{},defaultFileSize:524288,
  maxPerformanceRecords:7,retryOnError:!0,maxRetries:2,emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",linkHandler:{"text/html":function(a,c){return b.injectHtml(a,c)},"application/xhtml+xml":function(a,c){return b.injectHtml(a,c)}}},a);this.options.linkHandler=Object.assign(this.options.linkHandler,c);this.mutation=new MutationObserver(function(a,c){return b.observeMutation(a,c)});this.mutationOptions={childList:!0,subtree:!0};this.intersectionOptions=
  {root:null,rootMargin:this.options.rootMargin,threshold:this.options.threshold};this.intersection=new IntersectionObserver(function(a,c){return b.observeIntersection(a,c)},this.intersectionOptions);this.options.enableOffloading&&(this.outersectionOptions={root:null,rootMargin:this.options.rootMarginOuter,threshold:this.options.thresholdOuter},this.outersection=new IntersectionObserver(function(a,c){return b.observeOutersection(a,c)},this.outersectionOptions));this.attributeMutations=new MutationObserver(function(a,
  c){return b.observeAttributeMutation(a,c)});this.attributeMutationOptions={attributes:!0,attributeFilter:["src","href","srcset","sizes","type"],attributeOldValue:!1};a=this.queryTargets();this.observeTargets(a);this.mutation.observe(document.body,this.mutationOptions)}_createClass(g,[{key:"observeMutation",value:function(a){for(var b=0;b<a.length;b++){var c=a[b];if("childList"===c.type){for(var d=0;d<c.addedNodes.length;d++){var e=c.addedNodes[d];e.parentNode&&this.checkAdditionRecursive(e)}for(d=
  0;d<c.removedNodes.length;d++)this.checkRemovalsRecursive(c.removedNodes[d])}}}},{key:"checkRemovalsRecursive",value:function(a){for(var b=[a];0<b.length;)if(a=b.shift(),this.hasRegistration(a)){var c=this.resolveTarget(a);a=c.target;c=c.registration;c.loaded&&(c.expectRemove?c.expectRemove=!1:a.node===a.target?this.cleanupRegistrationTarget(c):this.cleanupPlaceholder(c))}else if(a.children)for(c=0;c<a.children.length;c++)b.push(a.children[c])}},{key:"checkAdditionRecursive",value:function(a){for(var b=
  [a];0<b.length;)if(a=b.shift(),!this.observed.has(a)){this.observed.set(a,!0);var c=this.isTargetMatch(a);if(!c.loaded)if(c.isScript&&c.injecting){this.injectedScript(a,c.injecting);continue}else if(c.isMatch){this.observeTarget(a);continue}if(a.children)for(c=0;c<a.children.length;c++)b.push(a.children[c])}}},{key:"observeAttributeMutation",value:function(a){for(var b=0;b<a.length;b++){var c=a[b];if("attributes"===c.type){var d=c.attributeName,e=this.resolveTarget(c.target);c=e.target;e=e.registration;
  if(e.loaded){if(this.cleanupRegistrationTarget(c),this.isTargetMatch(c).isMatch){this.observeTarget(c);break}}else if(c.hasAttribute(d)&&k!=e.extraData[d]&&""!==k){var f=e,k=c.getAttribute(d);switch(d){case "src":f.extraData.src=k;f.extraData.hasSrc=!0;e.loading||c.removeAttribute("src");break;case "href":f.extraData.href=k;f.extraData.hasHref=!0;break;case "srcset":f.extraData.srcset=k;f.extraData.hasSrcset=!0;e.loading||c.removeAttribute("srcset");break;case "sizes":f.extraData.sizes=k;f.extraData.hasSizes=
  !0;e.loading||c.removeAttribute("sizes");break;case "type":f.extraData.type=k,f.extraData.hasType=!0}}}}}},{key:"cooperativeExecute",value:function(){this.queuedFuncs.shift()();if(0<this.queuedFuncs.length){var a=this;setTimeout(function(){a.cooperativeExecute()},0)}}},{key:"cooperativeQueue",value:function(a){this.queuedFuncs.push(a);if(1===this.queuedFuncs.length){var b=this;setTimeout(function(){b.cooperativeExecute()},0)}}},{key:"observeIntersection",value:function(a){for(var b=this,c=this,d=
  0;d<a.length;d++){var e=a[d];e.isIntersecting&&0<e.intersectionRatio&&function(){var a=b.phRegistry.get(e.target);if(void 0===a||a.loading)return"continue";a=b.phRegistry.get(a.target);if(void 0===a||a.loading)return"continue";b.cooperativeQueue(function(){c.beginLoad(a)})}()}}},{key:"observeOutersection",value:function(a){for(var b=this,c=this,d=0;d<a.length;d++){var e=a[d];(!e.isIntersecting||0>=e.intersectionRatio)&&function(){var a=b.phRegistry.get(e.target);if(void 0===a)return"continue";a=b.phRegistry.get(a.target);
  if(void 0===a||!a.loaded)return"continue";var d=a.target,g=d.getBoundingClientRect();d.setAttribute("data-demandjs-width",g.width);d.setAttribute("data-demandjs-height",g.height);b.cooperativeQueue(function(){c.cleanupRegistrationTarget(d);c.isTargetMatch(d).isMatch&&c.observeTarget(d,a)})}()}}},{key:"beginLoad",value:function(a){var b=this,c=this.resolveTarget(a);a=c.target;var d=c.registration;if(!d.loading)if(d.loading=!0,d.extraData.shouldInjectLink){var e=d.extraData.href;this.selectByDemandClass(a,
  this.options.onLoadBegin,this.options.demandClassAttribute,this.options.defaultDemandClass,this.onLoadBegin).call(this,a);e=this.predictUrl(a,e);d.extraData.startTime=performance.now();fetch(e).then(function(a){if(!a.ok){var b=Error('Fetching "'+e+'" failed with '+a.status+" "+a.statusText);b.responseDetail=a;throw b;}return a.text()}).then(function(a){b.injectLink(d,a)}).catch(function(a){b.handleError(d,a)})}else d.extraData.shouldRestore?setTimeout(function(){return b.restoreTarget(d)},0):console.warn("DEMANDJS: unknown load operation - ignored")}},
  {key:"isResourceLoaded",value:function(a){return a.loaded||!1}},{key:"injectLink",value:function(a,b){var c=this.resolveTarget(a);a=c.target;c=c.registration;if(!this.selectByDemandClass(a,this.options.previewLoading,this.options.demandClassAttribute,this.options.defaultDemandClass,!1))if(this.selectByDemandClass(a,this.options.previewFailure,this.options.demandClassAttribute,this.options.defaultDemandClass,!1))this.handleError(a,Error("found failure preview in options"));else{var d=c.extraData.type;
  if(d in this.options.linkHandler)(0,this.options.linkHandler[d])(a,b);else console.warn("DEMANDJS: Unknown link demand with content type: "+d);this.processSuccess(c)}}},{key:"injectedScript",value:function(a,b){var c=this,d=b.id,e=Promise.resolve(a.innerHTML);"src"in a&&a.src&&(e=fetch(a.src).then(function(a){if(!a.ok)throw Error(a.status+"_"+a.statusText);return a.text()}),d=a.src+"#"+d);e=e.then(function(e){c.injectScript(a,b.href+".demand["+d+"].js",e)});e=e.catch(function(b){c.handleError(a,b)})}},
  {key:"injectScript",value:function(a,b,c){var d=document.write,e="";document.write=function(a){return e+=a};(new Function(c+"\n//@ sourceURL="+b))();""!==e&&this.injectHtml(a,"<body>"+e+"</body>");document.write=d}},{key:"injectHtml",value:function(a,b){var c=this.resolveTarget(a);a=c.target;c=c.registration;var d=document.createElement("html");d.innerHTML=b;b=d.getElementsByTagName("body");d=1;b=Array.prototype.slice.call(b);for(var e=0;e<b.length;e++)for(var f=Array.prototype.slice.call(b[e].children),
  k=0;k<f.length;k++){var g=f[k];this.injecting.set(g,{href:a.href,id:d});d+=1;this.scrollSave();a.parentNode.insertBefore(g,a);this.scrollRestore();c&&c.elements&&c.elements.push(g)}}},{key:"isOffloadingEnabled",value:function(a){return this.selectByDemandClass(a,this.options.enableOffloading,this.options.demandClassAttribute,this.options.defaultDemandClass,!1)}},{key:"shouldTrackOffloading",value:function(a){return"IMG"!==a.nodeName&&"VIDEO"!==a.nodeName&&"PICTURE"!==a.nodeName?!1:this.isOffloadingEnabled(a)}},
  {key:"processSuccess",value:function(a){var b=this.resolveTarget(a);a=b.target;b=b.registration;if(!this.selectByDemandClass(a,this.options.previewLoading,this.options.demandClassAttribute,this.options.defaultDemandClass,!1))if(this.selectByDemandClass(a,this.options.previewFailure,this.options.demandClassAttribute,this.options.defaultDemandClass,!1))this.handleError(a,Error("found failure preview in options"));else if(b&&!b.loaded){if(b.extraData.insertToLoad){var c=b.placeholders[0],d=b.extraData;
  b.target.style.display=d.display;b.expectRemove=!0;this.scrollSave();c.parentNode.insertBefore(b.target,c);this.scrollRestore()}else this.options.shouldInsertOnLoad(b.target)&&(d=b.extraData,b.target.style.display=d.display);this.cleanupPlaceholders(b);b.loaded=!0;b.extraData.endTime=performance.now();this.recordPerformance(a,!1);this.shouldTrackOffloading(a)&&this.outersection.observe(a);this.selectByDemandClass(a,this.options.onLoadSuccess,this.options.demandClassAttribute,this.options.defaultDemandClass,
  this.onLoadSuccess).call(this,a);this.selectByDemandClass(a,this.options.onLoadComplete,this.options.demandClassAttribute,this.options.defaultDemandClass,this.onLoadComplete).call(this,a)}}},{key:"cleanupPlaceholders",value:function(a){a=this.resolveTarget(a).registration;for(var b=0;b<a.placeholders.length;b++)this.cleanupPlaceholder(a.placeholders[b],!1);a.placeholders=[]}},{key:"scrollSave",value:function(){}},{key:"scrollRestore",value:function(){}},{key:"cleanupPlaceholder",value:function(a,
  b){"undefined"===typeof b&&(b=!0);this.intersection.unobserve(a);this.scrollSave();a.remove();this.scrollRestore();this.phRegistry.delete(a);this.observed.delete(a);this.injecting.delete(a);b&&(b=this.resolveTarget(a),b=this.resolveTarget(b.registration.target).registration,b.placeholders=b.placeholders.filter(function(b){return b!=a}))}},{key:"cleanupRegistrationTarget",value:function(a){a=this.resolveTarget(a);var b=a.target;a=a.registration;this.cleanupPlaceholders(a);this.observed.delete(b);this.injecting.delete(b);
  this.intersection.unobserve(b);this.isOffloadingEnabled(b)&&this.outersection.unobserve(b);this.phRegistry.delete(b);a.extraData.listeners.forEach(function(a){return b.removeEventListener(a.type,a.listener)});for(var c=0;c<a.extraData.children.length;c++)this.releaseTarget(a.extraData.children[c],targetRoot);var d=this;a.elements.forEach(function(a){d.scrollSave();a.remove();d.scrollRestore()})}},{key:"handleError",value:function(a,b){var c=this.resolveTarget(a);a=c.target;if(c=c.registration){b&&
  b.stack&&b.message||(b=b?Error(b):Error("No error was provided on load"));var d=this.selectByDemandClass(a,this.options.onLoadFailure,this.options.demandClassAttribute,this.options.defaultDemandClass,this.onLoadFailure);c.extraData.insertToLoad&&(this.scrollSave(),a.remove(),this.scrollRestore(),a.style.display="none");d.call(this,a,b);this.cleanupPlaceholders(c);c.loaded=!0;c.extraData.endTime=performance.now();this.recordPerformance(a,!0);b=this.selectByDemandClass(a,this.options.retryOnError,this.options.demandClassAttribute,
  this.options.defaultDemandClass,!1);d=this.selectByDemandClass(a,this.options.maxRetries,this.options.demandClassAttribute,this.options.defaultDemandClass,2);if(b&&c.retryCount<d){c.loading=!1;c.loaded=!1;c.retryCount+=1;c.retryDelay=500*Math.pow(2,c.retryCount);this.clearAttributes(a,c.extraData);var e=this;setTimeout(function(){e.beginLoad(a)},c.retryDelay)}else this.selectByDemandClass(a,this.options.onLoadComplete,this.options.demandClassAttribute,this.options.defaultDemandClass,this.onLoadComplete).call(this,
  a)}}},{key:"onLoadBegin",value:function(a){}},{key:"onLoadSuccess",value:function(a){}},{key:"onLoadComplete",value:function(a){}},{key:"onLoadFailure",value:function(a,b){var c=this.resolveTarget(a);a=c.target;c=c.registration;b=this.selectByDemandClass(a,this.options.createFailureNode,this.options.demandClassAttribute,this.options.defaultDemandClass,this.createFailureNode).call(this,a,b);b=Array.prototype.slice.call(b);for(var d=c.placeholders=c.placeholders.concat(b),e=0;e<b.length;e++){var f=
  b[e];this.registerPlaceholder(f,a,d,c.extraData).loaded=!0;this.scrollSave();a.parentNode.insertBefore(f,a);this.scrollRestore()}this.options.shouldRemove(a)&&(c.extraData.insertToLoad?(c.expectRemove=!0,this.scrollSave(),a.remove(),this.scrollRestore()):a.style.display="none")}},{key:"selectByDemandClass",value:function(a,b,c,d,e){if(!b)return e;if("object"===("undefined"===typeof b?"undefined":_typeof(b))){var f=d;a.hasAttribute(c)&&(f=a.getAttribute(c));do{if(f in b){b=b[f];break}else if(f===d){b=
  e;break}f=d}while(1)}return b}},{key:"createFailureNode",value:function(a,b){b=document.createElement("div");a=this.selectByDemandClass(a,this.options.failureHtml,this.options.demandClassAttribute,this.options.defaultDemandClass,this.defaultFailureHtml);b.innerHTML=a;return b.childNodes}},{key:"createLoadingNode",value:function(a){var b=document.createElement("div");a=this.selectByDemandClass(a,this.options.loadingHtml,this.options.demandClassAttribute,this.options.defaultDemandClass,this.defaultLoadingHtml);
  b.innerHTML=a;return b.childNodes}},{key:"registerPlaceholder",value:function(a,b,c,d){b={isRegistration:!0,target:b,node:a,placeholders:c,extraData:d,loading:!1,elements:[],loaded:!1,expectRemove:!1,retryCount:0};this.phRegistry.set(a,b);return b}},{key:"hasRegistration",value:function(a){"isRegistration"in a&&a.isRegistration&&(a=a.node);return this.phRegistry.has(a)}},{key:"resolveTarget",value:function(a){var b=a;"isRegistration"in a&&a.isRegistration?a=b.target:b=this.phRegistry.get(a);return{target:a,
  registration:b}}},{key:"restoreTarget",value:function(a){var b=this.resolveTarget(a);a=b.target;b=b.registration;var c=b.extraData;this.selectByDemandClass(a,this.options.onLoadBegin,this.options.demandClassAttribute,this.options.defaultDemandClass,this.onLoadBegin).call(this,a);this._restoreTargetInternal(a,c);c.canLoad||this.processSuccess(b)}},{key:"_restoreTargetInternal",value:function(a,b){b.hasSrcset&&a.setAttribute("srcset",b.srcset);b.hasSizes&&a.setAttribute("sizes",b.sizes);b.hasSrc&&a.setAttribute("src",
  this.predictUrl(a,b.src));if(0<b.children.length)for(var c=0;c<b.children.length;c++){var d=b.children[c];this._restoreTargetInternal(d.target,d)}b.insertToLoad&&(a.style.display="none",this.scrollSave(),document.body.appendChild(a),this.scrollRestore());b.startTime=performance.now()}},{key:"clearAttributes",value:function(a,b){b.hasSrc&&a.removeAttribute("src");b.hasSrcset&&a.removeAttribute("srcset");b.hasSizes&&a.removeAttribute("sizes")}},{key:"captureTarget",value:function(a,b){var c=this,d=
  {target:a,hasSrc:a.hasAttribute("src"),src:a.getAttribute("src"),hasSrcset:a.hasAttribute("srcset"),srcset:a.getAttribute("srcset"),hasSizes:a.hasAttribute("sizes"),sizes:a.getAttribute("sizes"),isLink:"tagName"in a&&a.tagName.match(/link/i),insertToLoad:"tagName"in a&&a.tagName.match(/iframe/i),hasHref:a.hasAttribute("href"),href:a.getAttribute("href"),hasType:a.hasAttribute("type"),type:a.getAttribute("type"),hasDemandWidth:a.hasAttribute("data-demandjs-width"),demandWidth:a.getAttribute("data-demandjs-width"),
  hasDemandHeight:a.hasAttribute("data-demandjs-height"),demandHeight:a.getAttribute("data-demandjs-height"),hasDisplay:a.style&&a.style.display,display:a.style.display||"",children:[],shouldRestore:!1,canLoad:!1,shouldInjectLink:!1,listeners:[],performancePrediction:{}};d.isOffloading=d.hasDemandWidth||d.hasDemandHeight;this.clearAttributes(a,d);d.isLink&&d.hasHref&&(d.shouldInjectLink=!0,d.hasType||(d.type="text/html"));if((d.hasSrc||d.hasSrcset)&&a===b){d.shouldRestore=!0;d.canLoad=!0;var e=[];"tagName"in
  a&&a.tagName.match(/video|audio/i)?(e.push({type:"loadedmetadata",listener:function(a){return c.processSuccess(b)}}),e.push({type:"loadeddata",listener:function(a){return c.processSuccess(b)}})):e.push({type:"load",listener:function(a){return c.processSuccess(b)}});d.hasSrcset&&d.hasSrc?e.push({type:"error",listener:function(a){c.handleError(b,Error("Loading for srcset and src failed ("+d.srcset+")("+d.src+")"))}}):d.hasSrcset?e.push({type:"error",listener:function(a){c.handleError(b,Error("Loading for srcset failed ("+
  d.srcset+")"))}}):d.hasSrc?e.push({type:"error",listener:function(a){c.handleError(b,Error("Loading for src failed ("+d.src+")"))}}):e.push({type:"error",listener:function(a){c.handleError(b,Error("Loading srced element failed (FALLBACK ERROR MSG)"))}});e.forEach(function(b){return a.addEventListener(b.type,b.listener)});d.listeners=e}if("tagName"in a&&a.tagName.match(/picture|video|audio/i))for(a===b&&(d.shouldRestore=!0),e=0;e<a.children.length;e++){var f=this.captureTarget(a.children[e],b);f.index=
  e;d.children.push(f)}return d}},{key:"getPerformanceRecord",value:function(a){a in this.options.urlPerformance||(this.options.urlPerformance[a]={predictedSpeed:0,bitsPerMillisecond:[],currentUsage:0});return this.options.urlPerformance[a]}},{key:"getPerformanceSize",value:function(a,b){a=performance.getEntriesByName(a);for(var c=0;c<a.length;c++){var d=a[c];if(d.transferSize)return d.transferSize}return this._defaultFileSize(b)}},{key:"_defaultFileSize",value:function(a){return this.selectByDemandClass(a,
  this.options.defaultFileSize,this.options.demandClassAttribute,this.options.defaultDemandClass,524288)}},{key:"_defaultPerfSpeed",value:function(a){return this._defaultFileSize(a)/1E3}},{key:"_getFailureMultiplier",value:function(){return 1E5}},{key:"_recordPerformance",value:function(a,b,c,d){a=this.getPerformanceRecord(b);a.bitsPerMillisecond.push(c);for(b=c=0;b<a.bitsPerMillisecond.length;b++)c+=a.bitsPerMillisecond[b];for(c/=a.bitsPerMillisecond.length;a.bitsPerMillisecond.length>this.options.maxPerformanceRecords;)a.bitsPerMillisecond.shift();
  a.predictedSpeed=c;a.currentUsage-=d}},{key:"recordPerformance",value:function(a,b){a=this.resolveTarget(a);var c=a.registration;a=a.target;var d=c.extraData,e=d.endTime-d.startTime;b&&(e*=this._getFailureMultiplier());if(d.hasSrc){b=d.src;b=e/this.getPerformanceSize(b);var f=c.extraData.performancePrediction;this._recordPerformance(a,f.prefix,b,f.speed)}d.hasHref&&(b=d.href,b=e/this.getPerformanceSize(b),f=c.extraData.performancePrediction,this._recordPerformance(a,f.prefix,b,f.speed))}},{key:"predictUrl",
  value:function(a,b){var c=this.resolveTarget(a),d=c.registration;a=c.target;var e=this.getAlternatives(b);c=e.suffix;e=e.alternatives;a=this._defaultPerfSpeed(a);for(var f=null,g=0;g<e.length;g++){var h=e[g],l=this.getPerformanceRecord(h),m=l.currentUsage+l.predictedSpeed;if(null===f||m<f)f=m,a=l.predictedSpeed,b=h}this.getPerformanceRecord(b).currentUsage+=a;d.extraData.performancePrediction={prefix:b,speed:a};return b+c}},{key:"getAlternatives",value:function(a){if("string"!==typeof a)throw"Expected url but got "+
  ("undefined"===typeof a?"undefined":_typeof(a));for(var b=0;b<this.options.alternatives.length;b++){var c=this.options.alternatives[b];if(Array.isArray(c))for(var d=0;d<c.length;d++){var e=c[d];if("string"===typeof e&&a.startsWith(e))return{suffix:a.substring(e.length),alternatives:c}}}c=b=0;d=a;for(e="";0<=b&&3>c;)c++,b=a.indexOf("/",b+1);0<=b&&(d=a.substring(0,b),e=a.substring(b));return{suffix:e,alternatives:[d]}}},{key:"isContextExcluded",value:function(a){return a&&"parentNode"in a?(a=a.parentNode)&&
  "tagName"in a?a.tagName.match(/picture|video|audio/i)?!0:this.isContextExcluded(a):!1:!1}},{key:"observeTarget",value:function(a,b){if(!this.isResourceLoaded(a)&&!this.isContextExcluded(a)){b=this.captureTarget(a,a);var c=this.selectByDemandClass(a,this.options.createLoadingNode,this.options.demandClassAttribute,this.options.defaultDemandClass,this.createLoadingNode).call(this,a,b);c=Array.prototype.slice.call(c);for(var d=0;d<c.length;d++){var e=c[d];this.registerPlaceholder(e,a,c,b).loaded=!0;this.scrollSave();
  a.insertAdjacentElement("beforeBegin",e);this.scrollRestore();this.intersection.observe(e)}c=this.registerPlaceholder(a,a,c,b);this.attributeMutations.observe(a,this.attributeMutationOptions);this.options.shouldRemove(a)?b.insertToLoad?(c.expectRemove=!0,this.scrollSave(),a.remove(),this.scrollRestore()):a.style.display="none":this.intersection.observe(a)}}},{key:"observeTargets",value:function(a){for(var b=0;b<a.length;b++)this.observeTarget(a[b])}},{key:"isLoadedRecursive",value:function(a,b){var c=
  this.resolveTarget(a);a=c.target;c=c.registration;return"undefined"!==typeof c&&c&&c.loaded?{loaded:!0,injecting:b||this.injecting.get(a)}:!b&&a.parentNode?this.isLoadedRecursive(a.parentNode,b||this.injecting.get(a)):{loaded:!1,injecting:b||this.injecting.get(a)}}},{key:"isScript",value:function(a){return!!("tagName"in a&&a.tagName.match(/^script$/i))}},{key:"isTargetMatch",value:function(a){var b="matches"in a&&a.matches(this.options.selector);b=b&&!(this.options.ignoreSelector&&a.matches(this.options.ignoreSelector));
  var c=this.isScript(a);if(!b&&!c)return{isMatch:b,isScript:c,loaded:!1,injecting:!1};a=this.isLoadedRecursive(a,!1);a.isMatch=b;a.isScript=c;return a}},{key:"queryTargets",value:function(){for(var a=[],b=document.querySelectorAll(this.options.selector),c=0;c<b.length;c++){var d=b[c];this.options.ignoreSelector&&"matches"in d&&d.matches(this.options.ignoreSelector)||a.push(d)}return a}},{key:"shouldRemove",value:function(a){return!("tagName"in a)||!a.tagName.match(/link/i)}}]);return g}()});
  