peertube-plugin-vast-loop-ads 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of peertube-plugin-vast-loop-ads might be problematic. Click here for more details.
- package/LICENSE +28 -0
- package/README.md +18 -0
- package/assets/style.css +115 -0
- package/dist/embed-client-plugin.js +2964 -0
- package/dist/video-watch-client-plugin.js +2988 -0
- package/lib/pluginSettings.js +127 -0
- package/lib/shared.js +154 -0
- package/main.js +22 -0
- package/package.json +56 -0
- package/public/scripts/videojs.ads.min.js +2 -0
- package/public/scripts/videojsx.vast.js +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var e={248:function(e,t){!function(e){"use strict";function t(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function i(e){for(var i=1;i<arguments.length;i++){var r=null!=arguments[i]?arguments[i]:{};i%2?t(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):t(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function o(e,t,i){return t&&a(e.prototype,t),i&&a(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function l(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function c(e){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},c(e)}function u(e,t){return u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function p(e){var t=function(){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(e){return!1}}();return function(){var i,r=c(e);if(t){var n=c(this).constructor;i=Reflect.construct(r,arguments,n)}else i=r.apply(this,arguments);return d(this,i)}}function h(e){return function(e){if(Array.isArray(e))return f(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return f(e,t);var i=Object.prototype.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?f(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,r=new Array(t);i<t;i++)r[i]=e[i];return r}function m(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,adId:e.adId||null,sequence:e.sequence||null,apiFramework:e.apiFramework||null,universalAdIds:[],creativeExtensions:[]}}var v=["ADCATEGORIES","ADCOUNT","ADPLAYHEAD","ADSERVINGID","ADTYPE","APIFRAMEWORKS","APPBUNDLE","ASSETURI","BLOCKEDADCATEGORIES","BREAKMAXADLENGTH","BREAKMAXADS","BREAKMAXDURATION","BREAKMINADLENGTH","BREAKMINDURATION","BREAKPOSITION","CLICKPOS","CLICKTYPE","CLIENTUA","CONTENTID","CONTENTPLAYHEAD","CONTENTURI","DEVICEIP","DEVICEUA","DOMAIN","EXTENSIONS","GDPRCONSENT","IFA","IFATYPE","INVENTORYSTATE","LATLONG","LIMITADTRACKING","MEDIAMIME","MEDIAPLAYHEAD","OMIDPARTNER","PAGEURL","PLACEMENTTYPE","PLAYERCAPABILITIES","PLAYERSIZE","PLAYERSTATE","PODSEQUENCE","REGULATIONS","SERVERSIDE","SERVERUA","TRANSACTIONID","UNIVERSALADID","VASTVERSIONS","VERIFICATIONVENDORS"];function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=[],n=T(e);for(var a in!t.ERRORCODE||i.isCustomCode||/^[0-9]{3}$/.test(t.ERRORCODE)||(t.ERRORCODE=900),t.CACHEBUSTING=R(Math.round(1e8*Math.random())),t.TIMESTAMP=(new Date).toISOString(),t.RANDOM=t.random=t.CACHEBUSTING,t)t[a]=E(t[a]);for(var o in n){var s=n[o];"string"==typeof s&&r.push(y(s,t))}return r}function y(e,t){var i=(e=A(e,t)).match(/[^[\]]+(?=])/g);if(!i)return e;var r=i.filter((function(e){return v.indexOf(e)>-1}));return 0===r.length?e:A(e,r=r.reduce((function(e,t){return e[t]=-1,e}),{}))}function A(e,t){var i=e;for(var r in t){var n=t[r];i=i.replace(new RegExp("(?:\\[|%%)(".concat(r,")(?:\\]|%%)"),"g"),n)}return i}function T(e){return Array.isArray(e)?e.map((function(e){return e&&e.hasOwnProperty("url")?e.url:e})):e}function k(e,t){for(var i=0;i<t.length;i++)if(b(t[i],e))return!0;return!1}function b(e,t){if(e&&t){var i=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(t);return i.length===r.length&&e.id===t.id&&e.url===t.url}return!1}function E(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16))}))}function R(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return e.toString().padStart(t,"0")}var w={track:function(e,t,i){g(e,t,i).forEach((function(e){"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:g,extractURLsFromTemplates:T,containsTemplateObject:k,isTemplateObjectEqual:b,encodeURIComponentRFC3986:E,replaceUrlMacros:y,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce((function(t,i){return t.concat(Array.isArray(i)?e(i):i)}),[])},joinArrayOfUniqueTemplateObjs:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i=Array.isArray(e)?e:[],r=Array.isArray(t)?t:[];return i.concat(r).reduce((function(e,t){return k(t,e)||e.push(t),e}),[])},isValidTimeValue:function(e){return Number.isFinite(e)&&e>=-2},addLeadingZeros:R};function N(e){return-1!==["true","TRUE","True","1"].indexOf(e)}var C={childByName:function(e,t){var i=e.childNodes;for(var r in i){var n=i[r];if(n.nodeName===t)return n}},childrenByName:function(e,t){var i=[],r=e.childNodes;for(var n in r){var a=r[n];a.nodeName===t&&i.push(a)}return i},resolveVastAdTagURI:function(e,t){if(!t)return e;if(0===e.indexOf("//")){var i=location.protocol;return"".concat(i).concat(e)}if(-1===e.indexOf("://")){var r=t.slice(0,t.lastIndexOf("/"));return"".concat(r,"/").concat(e)}return e},parseBoolean:N,parseNodeText:function(e){return e&&(e.textContent||e.text||"").trim()},copyNodeAttribute:function(e,t,i){var r=t.getAttribute(e);r&&i.setAttribute(e,r)},parseAttributes:function(e){for(var t=e.attributes,i={},r=0;r<t.length;r++)i[t[r].nodeName]=t[r].nodeValue;return i},parseDuration:function(e){if(null==e)return-1;if(w.isNumeric(e))return parseInt(e);var t=e.split(":");if(3!==t.length)return-1;var i=t[2].split("."),r=parseInt(i[0]);2===i.length&&(r+=parseFloat("0.".concat(i[1])));var n=parseInt(60*t[1]),a=parseInt(60*t[0]*60);return isNaN(a)||isNaN(n)||isNaN(r)||n>3600||r>60?-1:a+n+r},splitVAST:function(e){var t=[],i=null;return e.forEach((function(r,n){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var a=e[n-1];if(a&&a.sequence===r.sequence-1)return void(i&&i.push(r));delete r.sequence}i=[r],t.push(i)})),t},assignAttributes:function(e,t){if(e)for(var i in e){var r=e[i];if(r.nodeName&&r.nodeValue&&t.hasOwnProperty(r.nodeName)){var n=r.nodeValue;"boolean"==typeof t[r.nodeName]&&(n=N(n)),t[r.nodeName]=n}}},mergeWrapperAdData:function(e,t){e.errorURLTemplates=t.errorURLTemplates.concat(e.errorURLTemplates),e.impressionURLTemplates=t.impressionURLTemplates.concat(e.impressionURLTemplates),e.extensions=t.extensions.concat(e.extensions),t.viewableImpression.length>0&&(e.viewableImpression=[].concat(h(e.viewableImpression),h(t.viewableImpression))),e.followAdditionalWrappers=t.followAdditionalWrappers,e.allowMultipleAds=t.allowMultipleAds,e.fallbackOnNoAd=t.fallbackOnNoAd;var i=(t.creatives||[]).filter((function(e){return e&&"companion"===e.type})),r=i.reduce((function(e,t){return(t.variations||[]).forEach((function(t){(t.companionClickTrackingURLTemplates||[]).forEach((function(t){w.containsTemplateObject(t,e)||e.push(t)}))})),e}),[]);e.creatives=i.concat(e.creatives);var n=t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length,a=t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length;e.creatives.forEach((function(e){if(t.trackingEvents&&t.trackingEvents[e.type])for(var i in t.trackingEvents[e.type]){var o=t.trackingEvents[e.type][i];Array.isArray(e.trackingEvents[i])||(e.trackingEvents[i]=[]),e.trackingEvents[i]=e.trackingEvents[i].concat(o)}"linear"===e.type&&(n&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates)),a&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates)),!t.videoClickThroughURLTemplate||null!==e.videoClickThroughURLTemplate&&void 0!==e.videoClickThroughURLTemplate||(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)),"companion"===e.type&&r.length&&(e.variations||[]).forEach((function(e){e.companionClickTrackingURLTemplates=w.joinArrayOfUniqueTemplateObjs(e.companionClickTrackingURLTemplates,r)}))})),t.adVerifications&&(e.adVerifications=e.adVerifications.concat(t.adVerifications)),t.blockedAdCategories&&(e.blockedAdCategories=e.blockedAdCategories.concat(t.blockedAdCategories))}};function L(e,t){var i=function(){var e=m(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"companion",required:null,variations:[]}}(t);return i.required=e.getAttribute("required")||null,i.variations=C.childrenByName(e,"Companion").map((function(e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,adType:"companionAd",width:e.width||0,height:e.height||0,assetWidth:e.assetWidth||null,assetHeight:e.assetHeight||null,expandedWidth:e.expandedWidth||null,expandedHeight:e.expandedHeight||null,apiFramework:e.apiFramework||null,adSlotID:e.adSlotID||null,pxratio:e.pxratio||"1",renderingMode:e.renderingMode||"default",staticResources:[],htmlResources:[],iframeResources:[],adParameters:null,xmlEncoded:null,altText:null,companionClickThroughURLTemplate:null,companionClickTrackingURLTemplates:[],trackingEvents:{}}}(C.parseAttributes(e));t.htmlResources=C.childrenByName(e,"HTMLResource").reduce((function(e,t){var i=C.parseNodeText(t);return i?e.concat(i):e}),[]),t.iframeResources=C.childrenByName(e,"IFrameResource").reduce((function(e,t){var i=C.parseNodeText(t);return i?e.concat(i):e}),[]),t.staticResources=C.childrenByName(e,"StaticResource").reduce((function(e,t){var i=C.parseNodeText(t);return i?e.concat({url:i,creativeType:t.getAttribute("creativeType")||null}):e}),[]),t.altText=C.parseNodeText(C.childByName(e,"AltText"))||null;var i=C.childByName(e,"TrackingEvents");i&&C.childrenByName(i,"Tracking").forEach((function(e){var i=e.getAttribute("event"),r=C.parseNodeText(e);i&&r&&(Array.isArray(t.trackingEvents[i])||(t.trackingEvents[i]=[]),t.trackingEvents[i].push(r))})),t.companionClickTrackingURLTemplates=C.childrenByName(e,"CompanionClickTracking").map((function(e){return{id:e.getAttribute("id")||null,url:C.parseNodeText(e)}})),t.companionClickThroughURLTemplate=C.parseNodeText(C.childByName(e,"CompanionClickThrough"))||null;var r=C.childByName(e,"AdParameters");return r&&(t.adParameters=C.parseNodeText(r),t.xmlEncoded=r.getAttribute("xmlEncoded")||null),t})),i}function I(e){return"linear"===e.type}function U(e,t){var i,r=function(){var e=m(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"linear",duration:0,skipDelay:null,mediaFiles:[],mezzanine:null,interactiveCreativeFile:null,closedCaptionFiles:[],videoClickThroughURLTemplate:null,videoClickTrackingURLTemplates:[],videoCustomClickURLTemplates:[],adParameters:null,icons:[],trackingEvents:{}}}(t);r.duration=C.parseDuration(C.parseNodeText(C.childByName(e,"Duration")));var n=e.getAttribute("skipoffset");if(null==n)r.skipDelay=null;else if("%"===n.charAt(n.length-1)&&-1!==r.duration){var a=parseInt(n,10);r.skipDelay=r.duration*(a/100)}else r.skipDelay=C.parseDuration(n);var o=C.childByName(e,"VideoClicks");if(o){var s=C.childByName(o,"ClickThrough");r.videoClickThroughURLTemplate=s?{id:s.getAttribute("id")||null,url:C.parseNodeText(s)}:null,C.childrenByName(o,"ClickTracking").forEach((function(e){r.videoClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:C.parseNodeText(e)})})),C.childrenByName(o,"CustomClick").forEach((function(e){r.videoCustomClickURLTemplates.push({id:e.getAttribute("id")||null,url:C.parseNodeText(e)})}))}var l=C.childByName(e,"AdParameters");l&&(r.adParameters=C.parseNodeText(l)),C.childrenByName(e,"TrackingEvents").forEach((function(e){C.childrenByName(e,"Tracking").forEach((function(e){var t=e.getAttribute("event"),n=C.parseNodeText(e);if(t&&n){if("progress"===t){if(!(i=e.getAttribute("offset")))return;t="%"===i.charAt(i.length-1)?"progress-".concat(i):"progress-".concat(Math.round(C.parseDuration(i)))}Array.isArray(r.trackingEvents[t])||(r.trackingEvents[t]=[]),r.trackingEvents[t].push(n)}}))})),C.childrenByName(e,"MediaFiles").forEach((function(e){C.childrenByName(e,"MediaFile").forEach((function(e){r.mediaFiles.push(function(e){var t={id:null,fileURL:null,fileSize:0,deliveryType:"progressive",mimeType:null,mediaType:null,codec:null,bitrate:0,minBitrate:0,maxBitrate:0,width:0,height:0,apiFramework:null,scalable:null,maintainAspectRatio:null};t.id=e.getAttribute("id"),t.fileURL=C.parseNodeText(e),t.deliveryType=e.getAttribute("delivery"),t.codec=e.getAttribute("codec"),t.mimeType=e.getAttribute("type"),t.mediaType=e.getAttribute("mediaType")||"2D",t.apiFramework=e.getAttribute("apiFramework"),t.fileSize=parseInt(e.getAttribute("fileSize")||0),t.bitrate=parseInt(e.getAttribute("bitrate")||0),t.minBitrate=parseInt(e.getAttribute("minBitrate")||0),t.maxBitrate=parseInt(e.getAttribute("maxBitrate")||0),t.width=parseInt(e.getAttribute("width")||0),t.height=parseInt(e.getAttribute("height")||0);var i=e.getAttribute("scalable");i&&"string"==typeof i&&(t.scalable=C.parseBoolean(i));var r=e.getAttribute("maintainAspectRatio");return r&&"string"==typeof r&&(t.maintainAspectRatio=C.parseBoolean(r)),t}(e))}));var t=C.childByName(e,"InteractiveCreativeFile");t&&(r.interactiveCreativeFile=function(e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,apiFramework:e.apiFramework||null,variableDuration:C.parseBoolean(e.variableDuration),fileURL:null}}(C.parseAttributes(e));return t.fileURL=C.parseNodeText(e),t}(t));var i=C.childByName(e,"ClosedCaptionFiles");i&&C.childrenByName(i,"ClosedCaptionFile").forEach((function(e){var t=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:e.type||null,language:e.language||null,fileURL:null}}(C.parseAttributes(e));t.fileURL=C.parseNodeText(e),r.closedCaptionFiles.push(t)}));var n,a,o,s=C.childByName(e,"Mezzanine"),l=(n=s,a={},o=!1,["delivery","type","width","height"].forEach((function(e){n&&n.getAttribute(e)?a[e]=n.getAttribute(e):o=!0})),o?null:a);if(l){var c={id:null,fileURL:null,delivery:null,codec:null,type:null,width:0,height:0,fileSize:0,mediaType:"2D"};c.id=s.getAttribute("id"),c.fileURL=C.parseNodeText(s),c.delivery=l.delivery,c.codec=s.getAttribute("codec"),c.type=l.type,c.width=parseInt(l.width,10),c.height=parseInt(l.height,10),c.fileSize=parseInt(s.getAttribute("fileSize"),10),c.mediaType=s.getAttribute("mediaType")||"2D",r.mezzanine=c}}));var c=C.childByName(e,"Icons");return c&&C.childrenByName(c,"Icon").forEach((function(e){r.icons.push(function(e){var t={program:null,height:0,width:0,xPosition:0,yPosition:0,apiFramework:null,offset:null,duration:0,type:null,staticResource:null,htmlResource:null,iframeResource:null,pxratio:"1",iconClickThroughURLTemplate:null,iconClickTrackingURLTemplates:[],iconViewTrackingURLTemplate:null};t.program=e.getAttribute("program"),t.height=parseInt(e.getAttribute("height")||0),t.width=parseInt(e.getAttribute("width")||0),t.xPosition=function(e){return-1!==["left","right"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("xPosition")),t.yPosition=function(e){return-1!==["top","bottom"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("yPosition")),t.apiFramework=e.getAttribute("apiFramework"),t.pxratio=e.getAttribute("pxratio")||"1",t.offset=C.parseDuration(e.getAttribute("offset")),t.duration=C.parseDuration(e.getAttribute("duration")),C.childrenByName(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=C.parseNodeText(e)})),C.childrenByName(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=C.parseNodeText(e)})),C.childrenByName(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=C.parseNodeText(e)}));var i=C.childByName(e,"IconClicks");return i&&(t.iconClickThroughURLTemplate=C.parseNodeText(C.childByName(i,"IconClickThrough")),C.childrenByName(i,"IconClickTracking").forEach((function(e){t.iconClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:C.parseNodeText(e)})}))),t.iconViewTrackingURLTemplate=C.parseNodeText(C.childByName(e,"IconViewTracking")),t}(e))})),r}function S(e,t){var i=function(){var e=m(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return{id:e.id,adId:e.adId,sequence:e.sequence,apiFramework:e.apiFramework,type:"nonlinear",variations:[],trackingEvents:{}}}(t);return C.childrenByName(e,"TrackingEvents").forEach((function(e){var t,r;C.childrenByName(e,"Tracking").forEach((function(e){t=e.getAttribute("event"),r=C.parseNodeText(e),t&&r&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(r))}))})),C.childrenByName(e,"NonLinear").forEach((function(e){var t={id:null,width:0,height:0,expandedWidth:0,expandedHeight:0,scalable:!0,maintainAspectRatio:!0,minSuggestedDuration:0,apiFramework:"static",adType:"nonLinearAd",type:null,staticResource:null,htmlResource:null,iframeResource:null,nonlinearClickThroughURLTemplate:null,nonlinearClickTrackingURLTemplates:[],adParameters:null};t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.expandedWidth=e.getAttribute("expandedWidth"),t.expandedHeight=e.getAttribute("expandedHeight"),t.scalable=C.parseBoolean(e.getAttribute("scalable")),t.maintainAspectRatio=C.parseBoolean(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=C.parseDuration(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),C.childrenByName(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=C.parseNodeText(e)})),C.childrenByName(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=C.parseNodeText(e)})),C.childrenByName(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=C.parseNodeText(e)}));var r=C.childByName(e,"AdParameters");r&&(t.adParameters=C.parseNodeText(r)),t.nonlinearClickThroughURLTemplate=C.parseNodeText(C.childByName(e,"NonLinearClickThrough")),C.childrenByName(e,"NonLinearClickTracking").forEach((function(e){t.nonlinearClickTrackingURLTemplates.push({id:e.getAttribute("id")||null,url:C.parseNodeText(e)})})),i.variations.push(t)})),i}function x(e){var t=[];return e.forEach((function(e){var i=D(e);i&&t.push(i)})),t}function D(e){if("#comment"===e.nodeName)return null;var t,i={name:null,value:null,attributes:{},children:[]},r=e.attributes,n=e.childNodes;if(i.name=e.nodeName,e.attributes)for(var a in r)if(r.hasOwnProperty(a)){var o=r[a];o.nodeName&&o.nodeValue&&(i.attributes[o.nodeName]=o.nodeValue)}for(var s in n)if(n.hasOwnProperty(s)){var l=D(n[s]);l&&i.children.push(l)}if(0===i.children.length||1===i.children.length&&["#cdata-section","#text"].indexOf(i.children[0].name)>=0){var c=C.parseNodeText(e);""!==c&&(i.value=c),i.children=[]}return null===(t=i).value&&0===Object.keys(t.attributes).length&&0===t.children.length?null:i}function O(e){var t=[];return e.forEach((function(e){var i,r={id:e.getAttribute("id")||null,adId:V(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null},n=[];C.childrenByName(e,"UniversalAdId").forEach((function(e){var t={idRegistry:e.getAttribute("idRegistry")||"unknown",value:C.parseNodeText(e)};n.push(t)}));var a=C.childByName(e,"CreativeExtensions");for(var o in a&&(i=x(C.childrenByName(a,"CreativeExtension"))),e.childNodes){var s=e.childNodes[o],l=void 0;switch(s.nodeName){case"Linear":l=U(s,r);break;case"NonLinearAds":l=S(s,r);break;case"CompanionAds":l=L(s,r)}l&&(n&&(l.universalAdIds=n),i&&(l.creativeExtensions=i),t.push(l))}})),t}function V(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}var P={Wrapper:{subElements:["VASTAdTagURI","Impression"]},BlockedAdCategories:{attributes:["authority"]},InLine:{subElements:["AdSystem","AdTitle","Impression","AdServingId","Creatives"]},Category:{attributes:["authority"]},Pricing:{attributes:["model","currency"]},Verification:{oneOfinLineResources:["JavaScriptResource","ExecutableResource"],attributes:["vendor"]},UniversalAdId:{attributes:["idRegistry"]},JavaScriptResource:{attributes:["apiFramework","browserOptional"]},ExecutableResource:{attributes:["apiFramework","type"]},Tracking:{attributes:["event"]},Creatives:{subElements:["Creative"]},Creative:{subElements:["UniversalAdId"]},Linear:{subElements:["MediaFiles","Duration"]},MediaFiles:{subElements:["MediaFile"]},MediaFile:{attributes:["delivery","type","width","height"]},Mezzanine:{attributes:["delivery","type","width","height"]},NonLinear:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},Companion:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"],attributes:["width","height"]},StaticResource:{attributes:["creativeType"]},Icons:{subElements:["Icon"]},Icon:{oneOfinLineResources:["StaticResource","IFrameResource","HTMLResource"]}};function M(e,t){if(P[e.nodeName]&&P[e.nodeName].attributes){var i=P[e.nodeName].attributes.filter((function(t){return!e.getAttribute(t)}));i.length>0&&F({name:e.nodeName,parentName:e.parentNode.nodeName,attributes:i},t)}}function B(e,t,i){var r=P[e.nodeName],n=!i&&"Wrapper"!==e.nodeName;if(r&&!n){if(r.subElements){var a=r.subElements.filter((function(t){return!C.childByName(e,t)}));a.length>0&&F({name:e.nodeName,parentName:e.parentNode.nodeName,subElements:a},t)}i&&r.oneOfinLineResources&&(r.oneOfinLineResources.some((function(t){return C.childByName(e,t)}))||F({name:e.nodeName,parentName:e.parentNode.nodeName,oneOfResources:r.oneOfinLineResources},t))}}function _(e){return e.children&&0!==e.children.length}function F(e,t){var i=e.name,r=e.parentName,n=e.attributes,a=e.subElements,o=e.oneOfResources,s="Element '".concat(i,"'");t("VAST-warning",{message:s+=n?" missing required attribute(s) '".concat(n.join(", "),"' "):a?" missing required sub element(s) '".concat(a.join(", "),"' "):o?" must provide one of the following '".concat(o.join(", "),"' "):" is empty",parentElement:r,specVersion:4.1})}var j={verifyRequiredValues:function e(t,i,r){if(t&&t.nodeName)if("InLine"===t.nodeName&&(r=!0),M(t,i),_(t)){B(t,i,r);for(var n=0;n<t.children.length;n++)e(t.children[n],i,r)}else 0===C.parseNodeText(t).length&&F({name:t.nodeName,parentName:t.parentNode.nodeName},i)},hasSubElements:_,emitMissingValueWarning:F,verifyRequiredAttributes:M,verifyRequiredSubElements:B};function W(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=i.allowMultipleAds,n=i.followAdditionalWrappers,a=e.childNodes;for(var o in a){var s=a[o];if(-1!==["Wrapper","InLine"].indexOf(s.nodeName)&&("Wrapper"!==s.nodeName||!1!==n)){if(C.copyNodeAttribute("id",e,s),C.copyNodeAttribute("sequence",e,s),C.copyNodeAttribute("adType",e,s),"Wrapper"===s.nodeName)return{ad:z(s,t),type:"WRAPPER"};if("InLine"===s.nodeName)return{ad:H(s,t,{allowMultipleAds:r}),type:"INLINE"}}}}function H(e,t){return!1===(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).allowMultipleAds&&e.getAttribute("sequence")?null:q(e,t)}function q(e,t){var i=[];t&&j.verifyRequiredValues(e,t);var r=e.childNodes,n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||null,sequence:e.sequence||null,adType:e.adType||null,adServingId:null,categories:[],expires:null,viewableImpression:[],system:null,title:null,description:null,advertiser:null,pricing:null,survey:null,errorURLTemplates:[],impressionURLTemplates:[],creatives:[],extensions:[],adVerifications:[],blockedAdCategories:[],followAdditionalWrappers:!0,allowMultipleAds:!1,fallbackOnNoAd:null}}(C.parseAttributes(e));for(var a in r){var o=r[a];switch(o.nodeName){case"Error":n.errorURLTemplates.push(C.parseNodeText(o));break;case"Impression":n.impressionURLTemplates.push({id:o.getAttribute("id")||null,url:C.parseNodeText(o)});break;case"Creatives":n.creatives=O(C.childrenByName(o,"Creative"));break;case"Extensions":var s=C.childrenByName(o,"Extension");n.extensions=x(s),n.adVerifications.length||(i=Q(s));break;case"AdVerifications":n.adVerifications=G(C.childrenByName(o,"Verification"));break;case"AdSystem":n.system={value:C.parseNodeText(o),version:o.getAttribute("version")||null};break;case"AdTitle":n.title=C.parseNodeText(o);break;case"AdServingId":n.adServingId=C.parseNodeText(o);break;case"Category":n.categories.push({authority:o.getAttribute("authority")||null,value:C.parseNodeText(o)});break;case"Expires":n.expires=parseInt(C.parseNodeText(o),10);break;case"ViewableImpression":n.viewableImpression.push(X(o));break;case"Description":n.description=C.parseNodeText(o);break;case"Advertiser":n.advertiser={id:o.getAttribute("id")||null,value:C.parseNodeText(o)};break;case"Pricing":n.pricing={value:C.parseNodeText(o),model:o.getAttribute("model")||null,currency:o.getAttribute("currency")||null};break;case"Survey":n.survey=C.parseNodeText(o);break;case"BlockedAdCategories":n.blockedAdCategories.push({authority:o.getAttribute("authority")||null,value:C.parseNodeText(o)})}}return i.length&&(n.adVerifications=n.adVerifications.concat(i)),n}function z(e,t){var i=q(e,t),r=e.getAttribute("followAdditionalWrappers"),n=e.getAttribute("allowMultipleAds"),a=e.getAttribute("fallbackOnNoAd");i.followAdditionalWrappers=!r||C.parseBoolean(r),i.allowMultipleAds=!!n&&C.parseBoolean(n),i.fallbackOnNoAd=a?C.parseBoolean(a):null;var o=C.childByName(e,"VASTAdTagURI");if(o?i.nextWrapperURL=C.parseNodeText(o):(o=C.childByName(e,"VASTAdTagURL"))&&(i.nextWrapperURL=C.parseNodeText(C.childByName(o,"URL"))),i.creatives.forEach((function(e){if(-1!==["linear","nonlinear"].indexOf(e.type)){if(e.trackingEvents){i.trackingEvents||(i.trackingEvents={}),i.trackingEvents[e.type]||(i.trackingEvents[e.type]={});var t=function(t){var r=e.trackingEvents[t];Array.isArray(i.trackingEvents[e.type][t])||(i.trackingEvents[e.type][t]=[]),r.forEach((function(r){i.trackingEvents[e.type][t].push(r)}))};for(var r in e.trackingEvents)t(r)}e.videoClickTrackingURLTemplates&&(Array.isArray(i.videoClickTrackingURLTemplates)||(i.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((function(e){i.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(i.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(Array.isArray(i.videoCustomClickURLTemplates)||(i.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((function(e){i.videoCustomClickURLTemplates.push(e)})))}})),i.nextWrapperURL)return i}function G(e){var t=[];return e.forEach((function(e){var i={resource:null,vendor:null,browserOptional:!1,apiFramework:null,type:null,parameters:null,trackingEvents:{}},r=e.childNodes;for(var n in C.assignAttributes(e.attributes,i),r){var a=r[n];switch(a.nodeName){case"JavaScriptResource":case"ExecutableResource":i.resource=C.parseNodeText(a),C.assignAttributes(a.attributes,i);break;case"VerificationParameters":i.parameters=C.parseNodeText(a)}}var o=C.childByName(e,"TrackingEvents");o&&C.childrenByName(o,"Tracking").forEach((function(e){var t=e.getAttribute("event"),r=C.parseNodeText(e);t&&r&&(Array.isArray(i.trackingEvents[t])||(i.trackingEvents[t]=[]),i.trackingEvents[t].push(r))})),t.push(i)})),t}function Q(e){var t=null,i=[];return e.some((function(e){return t=C.childByName(e,"AdVerifications")})),t&&(i=G(C.childrenByName(t,"Verification"))),i}function X(e){var t={};t.id=e.getAttribute("id")||null;var i=e.childNodes;for(var r in i){var n=i[r],a=n.nodeName,o=C.parseNodeText(n);if(("Viewable"===a||"NotViewable"===a||"ViewUndetermined"===a)&&o){var s=a.toLowerCase();Array.isArray(t[s])||(t[s]=[]),t[s].push(o)}}return t}var Y=function(){function e(){n(this,e),this._handlers=[]}return o(e,[{key:"on",value:function(e,t){if("function"!=typeof t)throw new TypeError("The handler argument must be of type Function. Received type ".concat(r(t)));if(!e)throw new TypeError("The event argument must be of type String. Received type ".concat(r(e)));return this._handlers.push({event:e,handler:t}),this}},{key:"once",value:function(e,t){return this.on(e,function(e,t,i){var r={fired:!1,wrapFn:void 0};function n(){r.fired||(e.off(t,r.wrapFn),r.fired=!0,i.bind(e).apply(void 0,arguments))}return r.wrapFn=n,n}(this,e,t))}},{key:"off",value:function(e,t){return this._handlers=this._handlers.filter((function(i){return i.event!==e||i.handler!==t})),this}},{key:"emit",value:function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r<t;r++)i[r-1]=arguments[r];var n=!1;return this._handlers.forEach((function(t){"*"===t.event&&(n=!0,t.handler.apply(t,[e].concat(i))),t.event===e&&(n=!0,t.handler.apply(t,i))})),n}},{key:"removeAllListeners",value:function(e){return e?(this._handlers=this._handlers.filter((function(t){return t.event!==e})),this):(this._handlers=[],this)}},{key:"listenerCount",value:function(e){return this._handlers.filter((function(t){return t.event===e})).length}},{key:"listeners",value:function(e){return this._handlers.reduce((function(t,i){return i.event===e&&t.push(i.handler),t}),[])}},{key:"eventNames",value:function(){return this._handlers.map((function(e){return e.event}))}}]),e}(),K={get:function(e,t,i){i(new Error("Please bundle the library for node to use the node urlHandler"))}},J=12e4;function Z(){try{var e=new window.XMLHttpRequest;return"withCredentials"in e?e:null}catch(e){return null}}function $(e,t,i){var r=i?408:e.status,n=i?"XHRURLHandler: Request timed out after ".concat(e.timeout," ms (").concat(r,")"):"XHRURLHandler: ".concat(e.statusText," (").concat(r,")");t(new Error(n),null,{statusCode:r})}var ee={get:function(e,t,i){if("https:"===window.location.protocol&&0===e.indexOf("http://"))return i(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=Z();r.open("GET",e),r.timeout=t.timeout||J,r.withCredentials=t.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onload=function(){return function(e,t){200===e.status?t(null,e.responseXML,{byteLength:e.response.length,statusCode:e.status}):$(e,t,!1)}(r,i)},r.onerror=function(){return $(r,i,!1)},r.onabort=function(){return $(r,i,!1)},r.ontimeout=function(){return $(r,i,!0)},r.send()}catch(e){i(new Error("XHRURLHandler: Unexpected error"))}},supported:function(){return!!Z()}},te={get:function(e,t,i){return i||("function"==typeof t&&(i=t),t={}),"undefined"==typeof window||null===window?K.get(e,t,i):ee.supported()?ee.get(e,t,i):i(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},ie=0,re=0,ne=function(e,t){!e||!t||e<=0||t<=0||(re=(re*ie+8*e/t)/++ie)},ae={ERRORCODE:900,extensions:[]},oe=function(e){l(i,e);var t=p(i);function i(){var e;return n(this,i),(e=t.call(this)).remainingAds=[],e.parentURLs=[],e.errorURLTemplates=[],e.rootErrorURLTemplates=[],e.maxWrapperDepth=null,e.URLTemplateFilters=[],e.fetchingOptions={},e.parsingOptions={},e}return o(i,[{key:"addURLTemplateFilter",value:function(e){"function"==typeof e&&this.URLTemplateFilters.push(e)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(e,t){for(var i=arguments.length,r=new Array(i>2?i-2:0),n=2;n<i;n++)r[n-2]=arguments[n];this.emit("VAST-error",Object.assign.apply(Object,[{},ae,t].concat(r))),w.track(e,t)}},{key:"getErrorURLTemplates",value:function(){return this.rootErrorURLTemplates.concat(this.errorURLTemplates)}},{key:"getEstimatedBitrate",value:function(){return re}},{key:"fetchVAST",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return new Promise((function(a,o){t.URLTemplateFilters.forEach((function(t){e=t(e)})),t.parentURLs.push(e);var s=Date.now();t.emit("VAST-resolving",{url:e,previousUrl:r,wrapperDepth:i,maxWrapperDepth:t.maxWrapperDepth,timeout:t.fetchingOptions.timeout,wrapperAd:n}),t.urlHandler.get(e,t.fetchingOptions,(function(n,l){var c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},u=Math.round(Date.now()-s),d=Object.assign({url:e,previousUrl:r,wrapperDepth:i,error:n,duration:u},c);t.emit("VAST-resolved",d),ne(c.byteLength,u),n?o(n):a(l)}))}))}},{key:"initParsingStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.errorURLTemplates=[],this.fetchingOptions={timeout:e.timeout||J,withCredentials:e.withCredentials},this.maxWrapperDepth=e.wrapperLimit||10,this.parentURLs=[],this.parsingOptions={allowMultipleAds:e.allowMultipleAds},this.remainingAds=[],this.rootErrorURLTemplates=[],this.rootURL="",this.urlHandler=e.urlHandler||e.urlhandler||te,this.vastVersion=null,ne(e.byteLength,e.requestDuration)}},{key:"getRemainingAds",value:function(e){var t=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var i=e?w.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(i,{wrapperDepth:0,url:this.rootURL}).then((function(e){return t.buildVASTResponse(e)}))}},{key:"getAndParseVAST",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(i),this.URLTemplateFilters.forEach((function(t){e=t(e)})),this.rootURL=e,this.fetchVAST(e).then((function(r){return i.previousUrl=e,i.isRootVAST=!0,i.url=e,t.parse(r,i).then((function(e){return t.buildVASTResponse(e)}))}))}},{key:"parseVAST",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(i),i.isRootVAST=!0,this.parse(e,i).then((function(e){return t.buildVASTResponse(e)}))}},{key:"buildVASTResponse",value:function(e){var t,i={ads:(t={ads:e,errorURLTemplates:this.getErrorURLTemplates(),version:this.vastVersion}).ads||[],errorURLTemplates:t.errorURLTemplates||[],version:t.version||null};return this.completeWrapperResolving(i),i}},{key:"parseVastXml",value:function(e,t){var i=t.isRootVAST,r=void 0!==i&&i,n=t.url,a=void 0===n?null:n,o=t.wrapperDepth,s=void 0===o?0:o,l=t.allowMultipleAds,c=t.followAdditionalWrappers;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName)throw this.emit("VAST-ad-parsed",{type:"ERROR",url:a,wrapperDepth:s}),new Error("Invalid VAST XMLDocument");var u=[],d=e.documentElement.childNodes,p=e.documentElement.getAttribute("version");for(var h in r&&p&&(this.vastVersion=p),d){var f=d[h];if("Error"===f.nodeName){var m=C.parseNodeText(f);r?this.rootErrorURLTemplates.push(m):this.errorURLTemplates.push(m)}else if("Ad"===f.nodeName){if(this.vastVersion&&parseFloat(this.vastVersion)<3)l=!0;else if(!1===l&&u.length>1)break;var v=W(f,this.emit.bind(this),{allowMultipleAds:l,followAdditionalWrappers:c});v.ad?(u.push(v.ad),this.emit("VAST-ad-parsed",{type:v.type,url:a,wrapperDepth:s,adIndex:u.length-1,vastVersion:p})):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}return u}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.url,r=void 0===i?null:i,n=t.resolveAll,a=void 0===n||n,o=t.wrapperSequence,s=void 0===o?null:o,l=t.previousUrl,c=void 0===l?null:l,u=t.wrapperDepth,d=void 0===u?0:u,p=t.isRootVAST,h=void 0!==p&&p,f=t.followAdditionalWrappers,m=t.allowMultipleAds,v=[];this.vastVersion&&parseFloat(this.vastVersion)<3&&h&&(m=!0);try{v=this.parseVastXml(e,{isRootVAST:h,url:r,wrapperDepth:d,allowMultipleAds:m,followAdditionalWrappers:f})}catch(e){return Promise.reject(e)}return 1===v.length&&null!=s&&(v[0].sequence=s),!1===a&&(this.remainingAds=C.splitVAST(v),v=this.remainingAds.shift()),this.resolveAds(v,{wrapperDepth:d,previousUrl:c,url:r})}},{key:"resolveAds",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],i=arguments.length>1?arguments[1]:void 0,r=i.wrapperDepth,n=i.previousUrl,a=i.url,o=[];return n=a,t.forEach((function(t){var i=e.resolveWrappers(t,r,n);o.push(i)})),Promise.all(o).then((function(t){var i=w.flatten(t);if(!i&&e.remainingAds.length>0){var o=e.remainingAds.shift();return e.resolveAds(o,{wrapperDepth:r,previousUrl:n,url:a})}return i}))}},{key:"resolveWrappers",value:function(e,t,i){var r=this;return new Promise((function(n){var a;if(t++,!e.nextWrapperURL)return delete e.nextWrapperURL,n(e);if(t>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(e.nextWrapperURL))return e.errorCode=302,delete e.nextWrapperURL,n(e);e.nextWrapperURL=C.resolveVastAdTagURI(e.nextWrapperURL,i),r.URLTemplateFilters.forEach((function(t){e.nextWrapperURL=t(e.nextWrapperURL)}));var o=null!==(a=r.parsingOptions.allowMultipleAds)&&void 0!==a?a:e.allowMultipleAds,s=e.sequence;r.fetchVAST(e.nextWrapperURL,t,i,e).then((function(a){return r.parse(a,{url:e.nextWrapperURL,previousUrl:i,wrapperSequence:s,wrapperDepth:t,followAdditionalWrappers:e.followAdditionalWrappers,allowMultipleAds:o}).then((function(t){if(delete e.nextWrapperURL,0===t.length)return e.creatives=[],n(e);t.forEach((function(t){t&&C.mergeWrapperAdData(t,e)})),n(t)}))})).catch((function(t){e.errorCode=301,e.errorMessage=t.message,n(e)}))}))}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;t>=0;t--){var i=e.ads[t];(i.errorCode||0===i.creatives.length)&&(this.trackVastError(i.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:i.errorCode||303},{ERRORMESSAGE:i.errorMessage||""},{extensions:i.extensions},{system:i.system}),e.ads.splice(t,1))}}}]),i}(Y),se=null,le={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete this.data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},ce=function(){function e(){n(this,e),this.storage=this.initStorage()}return o(e,[{key:"initStorage",value:function(){if(se)return se;try{se="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){se=null}return se&&!this.isStorageDisabled(se)||(se=le).clear(),se}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),ue=function(){function e(t,i,r){n(this,e),this.cappingFreeLunch=t||0,this.cappingMinimumTimeInterval=i||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new oe,this.storage=r||new ce,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return o(e,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(e){this.storage.setItem("vast-client-last-successful-ad",e)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(e){this.storage.setItem("vast-client-total-calls",e)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(e){this.storage.setItem("vast-client-total-calls-timeout",e)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(e){return this.vastParser.getRemainingAds(e)}},{key:"get",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(i=Object.assign({},this.defaultOptions,i)).hasOwnProperty("resolveAll")||(i.resolveAll=!1),this.totalCallsTimeout<r?(this.totalCalls=1,this.totalCallsTimeout=r+36e5):this.totalCalls++,new Promise((function(n,a){if(t.cappingFreeLunch>=t.totalCalls)return a(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(t.totalCalls,"/").concat(t.cappingFreeLunch)));var o=r-t.lastSuccessfulAd;if(o<0)t.lastSuccessfulAd=0;else if(o<t.cappingMinimumTimeInterval)return a(new Error("VAST call canceled – (".concat(t.cappingMinimumTimeInterval,")ms minimum interval reached")));t.vastParser.getAndParseVAST(e,i).then((function(e){return n(e)})).catch((function(e){return a(e)}))}))}}]),e}(),de=function(e){l(a,e);var t=p(a);function a(e,i,r){var o,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;for(var l in n(this,a),(o=t.call(this)).ad=i,o.creative=r,o.variation=s,o.muted=!1,o.impressed=!1,o.skippable=!1,o.trackingEvents={},o.lastPercentage=0,o._alreadyTriggeredQuartiles={},o.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],o.creative.trackingEvents){var c=o.creative.trackingEvents[l];o.trackingEvents[l]=c.slice(0)}return I(o.creative)?o._initLinearTracking():o._initVariationTracking(),e&&o.on("start",(function(){e.lastSuccessfulAd=Date.now()})),o}return o(a,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var e in this.variation.trackingEvents){var t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}"nonLinearAd"===this.variation.adType?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):function(e){return"companionAd"===e.adType}(this.variation)&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(e){w.isValidTimeValue(e)&&(this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100})}},{key:"setProgress",value:function(e){var t=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(w.isValidTimeValue(e)&&"object"===r(i)){var n=this.skipDelay||-1;if(-1===n||this.skippable||(n>e?this.emit("skip-countdown",n-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var a=Math.round(e/this.assetDuration*100),o=[];if(e>0){o.push("start");for(var s=this.lastPercentage;s<a;s++)o.push("progress-".concat(s+1,"%"));for(var l in o.push("progress-".concat(Math.round(e))),this.quartiles)this.isQuartileReached(l,this.quartiles[l],e)&&(o.push(l),this._alreadyTriggeredQuartiles[l]=!0);this.lastPercentage=a}o.forEach((function(e){t.track(e,{macros:i,once:!0})})),e<this.progress&&this.track("rewind",{macros:i})}this.progress=e}}},{key:"isQuartileReached",value:function(e,t,i){var r=!1;return t<=i&&!this._alreadyTriggeredQuartiles[e]&&(r=!0),r}},{key:"setMuted",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.muted!==e&&this.track(e?"mute":"unmute",{macros:t}),this.muted=e)}},{key:"setPaused",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.paused!==e&&this.track(e?"pause":"resume",{macros:t}),this.paused=e)}},{key:"setFullscreen",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.fullscreen!==e&&this.track(e?"fullscreen":"exitFullscreen",{macros:t}),this.fullscreen=e)}},{key:"setExpand",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"boolean"==typeof e&&"object"===r(t)&&(this.expanded!==e&&(this.track(e?"expand":"collapse",{macros:t}),this.track(e?"playerExpand":"playerCollapse",{macros:t})),this.expanded=e)}},{key:"setSkipDelay",value:function(e){w.isValidTimeValue(e)&&(this.skipDelay=e)}},{key:"trackImpression",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&(this.impressed||(this.impressed=!0,this.trackURLs(this.ad.impressionURLTemplates,e),this.track("creativeView",{macros:e})))}},{key:"error",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"object"===r(e)&&"boolean"==typeof t&&this.trackURLs(this.ad.errorURLTemplates,e,{isCustomCode:t})}},{key:"errorWithCode",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"string"==typeof e&&"boolean"==typeof t&&this.error({ERRORCODE:e},t)}},{key:"complete",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("complete",{macros:e})}},{key:"notUsed",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&(this.track("notUsed",{macros:e}),this.trackingEvents=[])}},{key:"otherAdInteraction",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("otherAdInteraction",{macros:e})}},{key:"acceptInvitation",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("acceptInvitation",{macros:e})}},{key:"adExpand",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("adExpand",{macros:e})}},{key:"adCollapse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("adCollapse",{macros:e})}},{key:"minimize",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("minimize",{macros:e})}},{key:"verificationNotExecuted",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"==typeof e&&"object"===r(t)){if(!this.ad||!this.ad.adVerifications||!this.ad.adVerifications.length)throw new Error("No adVerifications provided");if(!e)throw new Error("No vendor provided, unable to find associated verificationNotExecuted");var i=this.ad.adVerifications.find((function(t){return t.vendor===e}));if(!i)throw new Error("No associated verification element found for vendor: ".concat(e));var n=i.trackingEvents;if(n&&n.verificationNotExecuted){var a=n.verificationNotExecuted;this.trackURLs(a,t),this.emit("verificationNotExecuted",{trackingURLTemplates:a})}}}},{key:"overlayViewDuration",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"string"==typeof e&&"object"===r(t)&&(t.ADPLAYHEAD=e,this.track("overlayViewDuration",{macros:t}))}},{key:"close",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track(this.linear?"closeLinear":"close",{macros:e})}},{key:"skip",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("skip",{macros:e})}},{key:"load",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"object"===r(e)&&this.track("loaded",{macros:e})}},{key:"click",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if((null===e||"string"==typeof e)&&"object"===r(t)){this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates,t);var n=this.clickThroughURLTemplate||e,a=i({},t);if(n){this.progress&&(a.ADPLAYHEAD=this.progressFormatted());var o=w.resolveURLTemplates([n],a)[0];this.emit("clickthrough",o)}}}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=t.macros,n=void 0===i?{}:i,a=t.once,o=void 0!==a&&a;if("object"===r(n)){"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close");var s=this.trackingEvents[e],l=this.emitAlwaysEvents.indexOf(e)>-1;s?(this.emit(e,{trackingURLTemplates:s}),this.trackURLs(s,n)):l&&this.emit(e,null),o&&(delete this.trackingEvents[e],l&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}}},{key:"trackURLs",value:function(e){var t,r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=i({},arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(a.ASSETURI=this.creative.mediaFiles[0].fileURL),this.progress&&(a.ADPLAYHEAD=this.progressFormatted())),null!==(t=this.creative)&&void 0!==t&&null!==(r=t.universalAdIds)&&void 0!==r&&r.length&&(a.UNIVERSALADID=this.creative.universalAdIds.map((function(e){return e.idRegistry.concat(" ",e.value)})).join(",")),this.ad&&(this.ad.sequence&&(a.PODSEQUENCE=this.ad.sequence),this.ad.adType&&(a.ADTYPE=this.ad.adType),this.ad.adServingId&&(a.ADSERVINGID=this.ad.adServingId),this.ad.categories&&this.ad.categories.length&&(a.ADCATEGORIES=this.ad.categories.map((function(e){return e.value})).join(",")),this.ad.blockedAdCategories&&this.ad.blockedAdCategories.length&&(a.BLOCKEDADCATEGORIES=this.ad.blockedAdCategories)),w.track(e,a,n)}},{key:"convertToTimecode",value:function(e){if(!w.isValidTimeValue(e))return"";var t=1e3*e,i=Math.floor(t/36e5),r=Math.floor(t/6e4%60),n=Math.floor(t/1e3%60),a=Math.floor(t%1e3);return"".concat(w.addLeadingZeros(i,2),":").concat(w.addLeadingZeros(r,2),":").concat(w.addLeadingZeros(n,2),".").concat(w.addLeadingZeros(a,3))}},{key:"progressFormatted",value:function(){return this.convertToTimecode(this.progress)}}]),a}(Y);e.VASTClient=ue,e.VASTParser=oe,e.VASTTracker=de,Object.defineProperty(e,"__esModule",{value:!0})}(t)},144:(e,t,i)=>{var r,n=void 0!==i.g?i.g:"undefined"!=typeof window?window:{},a=i(893);"undefined"!=typeof document?r=document:(r=n["__GLOBAL_DOCUMENT_CACHE@4"])||(r=n["__GLOBAL_DOCUMENT_CACHE@4"]=a),e.exports=r},908:(e,t,i)=>{var r;r="undefined"!=typeof window?window:void 0!==i.g?i.g:"undefined"!=typeof self?self:{},e.exports=r},596:e=>{"use strict";var t=["handshakeVersion","initAd","startAd","stopAd","skipAd","resizeAd","pauseAd","resumeAd","expandAd","collapseAd","subscribe","unsubscribe"];function i(e,t,i){}i.prototype.handshakeVersion=function(e,t){},i.prototype.initAd=function(e,t,i,r,n,a,o){},i.prototype.startAd=function(e){},i.prototype.stopAd=function(e){},i.prototype.skipAd=function(e){},i.prototype.resizeAd=function(e,t,i,r){},i.prototype.pauseAd=function(e){},i.prototype.resumeAd=function(e){},i.prototype.expandAd=function(e){},i.prototype.collapseAd=function(e){},i.prototype.subscribe=function(e,t,i){},i.prototype.unsubscribe=function(e,t){},i.prototype.getAdLinear=function(e){},i.prototype.getAdWidth=function(e){},i.prototype.getAdHeight=function(e){},i.prototype.getAdExpanded=function(e){},i.prototype.getAdSkippableState=function(e){},i.prototype.getAdRemainingTime=function(e){},i.prototype.getAdDuration=function(e){},i.prototype.getAdVolume=function(e){},i.prototype.getAdCompanions=function(e){},i.prototype.getAdIcons=function(e){},i.prototype.setAdVolume=function(e,t){},n(i,"METHODS",t),n(i,"GETTERS",["getAdLinear","getAdWidth","getAdHeight","getAdExpanded","getAdSkippableState","getAdRemainingTime","getAdDuration","getAdVolume","getAdCompanions","getAdIcons"]),n(i,"SETTERS",["setAdVolume"]),n(i,"EVENTS",["AdLoaded","AdStarted","AdStopped","AdSkipped","AdSkippableStateChange","AdSizeChange","AdLinearChange","AdDurationChange","AdExpandedChange","AdRemainingTimeChange","AdVolumeChange","AdImpression","AdVideoStart","AdVideoFirstQuartile","AdVideoMidpoint","AdVideoThirdQuartile","AdVideoComplete","AdClickThru","AdInteraction","AdUserAcceptInvitation","AdUserMinimize","AdUserClose","AdPaused","AdPlaying","AdLog","AdError"]);var r=t.filter((function(e){return-1===["skipAd"].indexOf(e)}));function n(e,t,i){Object.defineProperty(e,t,{writable:!1,configurable:!1,value:i})}n(i,"checkVPAIDInterface",(function(e){return r.every((function(t){return"function"==typeof e[t]}))})),e.exports=i},13:(e,t,i)=>{"use strict";var r=i(596),n=i(437),a=r.checkVPAIDInterface,o=i(77),s=(r.METHODS,"AdClickThru"),l=r.EVENTS.filter((function(e){return e!=s}));function c(e,t,i,r){this._isValid=a(e),this._isValid&&(this._creative=e,this._el=t,this._videoEl=i,this._iframe=r,this._subscribers=new n,o.setFullSizeStyle(t),u.call(this))}function u(){if(l.forEach(function(e){this._creative.subscribe(p.bind(this,e),e)}.bind(this)),this._creative.subscribe(d.bind(this),s),this._videoEl){var e=this._iframe.contentDocument.documentElement,t=this._videoEl;e.addEventListener("click",(function(i){i.target===e&&t.click()}))}}function d(e,t,i){this._subscribers.triggerSync(s,{url:e,id:t,playerHandles:i})}function p(e){this._subscribers.trigger.apply(this._subscribers,Array.prototype.slice.call(arguments))}function h(e,t,i,r){e?e(i,r):i&&t.trigger("AdError",i)}c.prototype=Object.create(r.prototype),c.prototype.isValidVPAIDAd=function(){return this._isValid},r.METHODS.forEach((function(e){-1===["subscribe","unsubscribe","initAd"].indexOf(e)&&(c.prototype[e]=function(){var t=r.prototype[e].length,i=Array.prototype.slice.call(arguments),n=t===i.length?i.pop():void 0;setTimeout(function(){var t,r=null;try{t=this._creative[e].apply(this._creative,i)}catch(e){r=e}h(n,this._subscribers,r,t)}.bind(this),0)})})),c.prototype.initAd=function(e,t,i,r,n,a,s){n=n||{},a=o.extend({slot:this._el,videoSlot:this._videoEl},a||{}),setTimeout(function(){var o;try{this._creative.initAd(e,t,i,r,n,a)}catch(e){o=e}h(s,this._subscribers,o)}.bind(this),0)},c.prototype.subscribe=function(e,t,i){this._subscribers.subscribe(t,e,i)},c.prototype.unsubscribe=function(e,t){this._subscribers.unsubscribe(t,e)},c.prototype.on=c.prototype.subscribe,c.prototype.off=c.prototype.unsubscribe,r.GETTERS.forEach((function(e){c.prototype[e]=function(t){setTimeout(function(){var i,r=null;try{i=this._creative[e]()}catch(e){r=e}h(t,this._subscribers,r,i)}.bind(this),0)}})),c.prototype.setAdVolume=function(e,t){setTimeout(function(){var i,r=null;try{this._creative.setAdVolume(e),i=this._creative.getAdVolume()}catch(e){r=e}r||(r=o.validate(i===e,"failed to apply volume: "+e)),h(t,this._subscribers,r,i)}.bind(this),0)},c.prototype._destroy=function(){this.stopAd(),this._subscribers.unsubscribeAll()},e.exports=c},178:(e,t,i)=>{"use strict";var r=i(77),n=r.unique("vpaidIframe"),a=i(13);function o(e,t,i,a){i=i||{},this._id=n(),this._destroyed=!1,this._frameContainer=r.createElementInEl(e,"div"),this._videoEl=t,this._vpaidOptions=a||{timeout:1e4},this._templateConfig={template:i.template||'<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"></head><body style="margin:0;padding:0"><div class="ad-element"></div><script type="text/javascript" src="{{iframeURL_JS}}"><\/script><script type="text/javascript">window.parent.postMessage(\'{"event": "ready", "id": "{{iframeID}}"}\', \'{{origin}}\');<\/script></body></html>',extraOptions:i.extraOptions||{}}}function s(e){var t=this[e];t&&t.parentNode&&(t.parentNode.removeChild(t),delete this[e])}function l(){u.call(this),delete this._adUnit}function c(){u.call(this),p.call(this)}function u(){s.call(this,"_frame"),d.call(this)}function d(){this._onLoad&&(window.removeEventListener("message",this._onLoad),delete this._onLoad)}function p(){this._adUnit&&(this._adUnit.stopAd(),delete this._adUnit)}function h(){if(this._destroyed)throw new Error("VPAIDHTML5Client already destroyed!")}function f(){return window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"")}o.prototype.destroy=function(){this._destroyed||(this._destroyed=!0,c.call(this))},o.prototype.isDestroyed=function(){return this._destroyed},o.prototype.loadAdUnit=function(e,t){if(!this._onLoad){h.call(this),c.call(this);var i=this,n=r.createIframeWithContent(this._frameContainer,this._templateConfig.template,r.extend({iframeURL_JS:e,iframeID:this.getID(),origin:f()},this._templateConfig.extraOptions));this._frame=n,this._onLoad=r.callbackTimeout(this._vpaidOptions.timeout,function(e){if(e.origin!==f())return;var n,o,s,c;try{n=JSON.parse(e.data)}catch(e){throw e}if(n.id!==i.getID())return;i._frame.contentWindow?(c=i._frame.contentWindow.getVPAIDAd,s=r.validate("function"==typeof c,"the ad didn't return a function to create an ad")):s="the iframe is not anymore in the DOM tree";if(!s){var u=i._frame.contentWindow.document.querySelector(".ad-element");(o=new a(c(),u,i._videoEl,i._frame)).subscribe("AdStopped",l.bind(i)),s=r.validate(o.isValidVPAIDAd(),"the add is not fully complaint with VPAID specification")}return i._adUnit=o,d.call(i),t(s,s?null:o),!0}.bind(this),function(){t("timeout",null)}.bind(this)),window.addEventListener("message",this._onLoad)}},o.prototype.unloadAdUnit=function(){c.call(this)},o.prototype.getID=function(){return this._id},e.exports=o,window.VPAIDHTML5Client=o},437:e=>{"use strict";function t(){this._subscribers={}}t.prototype.subscribe=function(e,t,i){this.isHandlerAttached(e,t)||this.get(t).push({handler:e,context:i,eventName:t})},t.prototype.unsubscribe=function(e,t){this._subscribers[t]=this.get(t).filter((function(t){return e!==t.handler}))},t.prototype.unsubscribeAll=function(){this._subscribers={}},t.prototype.trigger=function(e,t){var i=this;this.get(e).concat(this.get("*")).forEach((function(e){setTimeout((function(){i.isHandlerAttached(e.handler,e.eventName)&&e.handler.call(e.context,t)}),0)}))},t.prototype.triggerSync=function(e,t){this.get(e).concat(this.get("*")).forEach((function(e){e.handler.call(e.context,t)}))},t.prototype.get=function(e){return this._subscribers[e]||(this._subscribers[e]=[]),this._subscribers[e]},t.prototype.isHandlerAttached=function(e,t){return this.get(t).some((function(t){return e===t.handler}))},e.exports=t},77:e=>{"use strict";function t(){}function i(e,t,i){var n=document.createElement("iframe");return n.src=t||"about:blank",n.marginWidth="0",n.marginHeight="0",n.frameBorder="0",n.width="100%",n.height="100%",r(n),i&&(n.style.zIndex=i),n.setAttribute("SCROLLING","NO"),e.innerHTML="",e.appendChild(n),n}function r(e){e&&(e.style.position="absolute",e.style.left="0",e.style.top="0",e.style.margin="0px",e.style.padding="0px",e.style.border="none",e.style.width="100%",e.style.height="100%")}function n(e,t){return Object.keys(t).forEach((function(i){var r="object"==typeof r?JSON.stringify(t[i]):t[i];e=e.replace(new RegExp("{{"+i+"}}","g"),r)})),e}function a(e,t){var i=e.contentWindow&&e.contentWindow.document;return!!i&&(i.write(t),!0)}e.exports={noop:t,validate:function(e,t){return e?null:new Error(t)},callbackTimeout:function(e,i,r){var n;return n=setTimeout((function(){i=t,r()}),e),function(){var e=Array.prototype.slice.call(arguments);i.apply(this,e)&&clearTimeout(n)}},createElementInEl:function(e,t,i){var r=document.createElement(t);return i&&(r.id=i),e.appendChild(r),r},createIframeWithContent:function(e,t,r){var o=i(e,null,r.zIndex);if(a(o,n(t,r)))return o},createIframe:i,setFullSizeStyle:r,simpleTemplate:n,setIframeContent:a,extend:function(e,t){return Object.keys(t).forEach((function(i){e[i]=t[i]})),e},unique:function(e){var t=-1;return function(){return e+"_"+ ++t}}}},893:()=>{}},t={};function i(r){var n=t[r];if(void 0!==n)return n.exports;var a=t[r]={exports:{}};return e[r].call(a.exports,a,a.exports,i),a.exports}i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),(()=>{"use strict";const e=videojs;var t=i(248),r=i(144),n=i(908);class a extends e.EventTarget{constructor(e,t){super(),this.player=e,this.options=t,this.duration=0,this.originalState={controlsEnabled:e.controls(),seekEnabled:e.controlBar.progressControl.enabled()}}setUp(){const e=this.player,t=this.options,i=i=>{if(!t.displayRemainingTimeIcons)return;const{className:r,action:n,toggleClasses:a,events:o,initialState:s}={play:{className:"vjs-icon-play vast-remaining-time-icon-play",action:e=>e.paused()?e.play():e.pause(),toggleClasses:["vjs-icon-pause","vjs-icon-play"],events:["adplay","adpause"],initialState:e=>e.paused()?"vjs-icon-play":"vjs-icon-pause"},mute:{className:"vast-remaining-time-icon-mute",action:e=>e.muted(!e.muted()),toggleClasses:["vjs-icon-volume-high","vjs-icon-volume-mute"],events:["advolumechange"],initialState:e=>e.muted()?"vjs-icon-volume-mute":"vjs-icon-volume-high"}}[i],l=e.addChild("button",{className:`vjs-hidden vjs-visible-text vjs-button vast-remaining-time-icon ${r}`,clickHandler:function(){n(this.player)}.bind(this)});l.removeClass("vjs-control"),l.addClass(s(e));const c=()=>{a.forEach((e=>l.toggleClass(e)))};this[`remainingTime${i.charAt(0).toUpperCase()+i.slice(1)}Element`]=l.el(),o.forEach((t=>e.on(t,c)))};e.controls(t.controlsEnabled),t.seekEnabled?e.controlBar.progressControl.enable():e.controlBar.progressControl.disable(),(()=>{const t=this.blocker=n.document.createElement("div");t.className="vast-blocker",t.onclick=()=>{if(e.paused())return e.play(),!1;this.trigger("click")},e.el().insertBefore(t,e.controlBar.el())})(),(()=>{const t=this.skipButtonElement=n.document.createElement("div");t.className="vast-skip-button",t.style.display="none",e.el().appendChild(t),e.one("adplay",this.#e),t.onclick=e=>{if((" "+t.className+" ").indexOf(" enabled ")>=0&&this.trigger("skip"),void 0===n.Event.prototype.stopPropagation)return!1;e.stopPropagation()}})(),(()=>{if(!t.displayRemainingTime)return;const i=this.remainingTimeElement=n.document.createElement("div");i.className="vast-remaining-time",i.style.display="none",e.el().appendChild(i)})(),i("play"),i("mute")}tearDown(){const e=this.player,t=this.originalState;e.controls(t.controlsEnabled),t.seekEnabled?e.controlBar.progressControl.enable():e.controlBar.progressControl.disable(),this.blocker.parentElement.removeChild(this.blocker),this.skipButtonElement.parentElement.removeChild(this.skipButtonElement),this.options.displayRemainingTime&&this.remainingTimeElement.parentElement.removeChild(this.remainingTimeElement),this.options.displayRemainingTimeIcons&&(this.remainingTimePlayElement.parentElement.removeChild(this.remainingTimePlayElement),this.remainingTimeMuteElement.parentElement.removeChild(this.remainingTimeMuteElement)),e.off("adtimeupdate",this.#t),e.off("adplay",this.#e)}#e=()=>{const e=this.options.skip,t=this.player;e>0&&(t.duration()||this.duration)>=e&&(this.skipButtonElement.style.display="block",this.options.displayRemainingTime&&(this.remainingTimeElement.style.display="block"),this.options.displayRemainingTimeIcons&&(this.remainingTimePlayElement.classList.remove("vjs-hidden"),this.remainingTimeMuteElement.classList.remove("vjs-hidden")),t.on("adtimeupdate",this.#t)),t.loadingSpinner.el().style.display="none"};#t=()=>{this.player.loadingSpinner.el().style.display="none";const e=Math.ceil(this.options.skip-this.player.currentTime());if(this.options.displayRemainingTime){const e=Math.ceil(this.player.remainingTime());this.remainingTimeElement.innerHTML=this.options.messages.remainingTime.replace("{seconds}",e)}var t;e>0?(o(t=this.skipButtonElement)&&(t.className=t.className.replace(" enabled ","")),this.skipButtonElement.innerHTML=this.options.messages.skipCountdown.replace("{seconds}",e)):(!function(e){o(e)||(e.className+=" enabled ")}(this.skipButtonElement),this.skipButtonElement.innerHTML=this.options.messages.skip)}}function o(e){return(" "+e.className+" ").indexOf(" enabled ")>-1}function s(e,t=null){let i;return function(){return e&&(i=e.apply(t||this,arguments),e=null),i}}function l(e){return"linear"===e.type&&e.mediaFiles.length}function c(e){return"companion"===e.type}function u(e,t=null){let i=null;if("string"==typeof e)if(e.includes("%")){if(null!=t){i=e.replace("%","")/100*t}}else if(e.includes(":")){const[t,r,n]=e.split(":").slice(-3);i=3600*parseInt(t||0,10)+60*parseInt(r||0,10)+parseInt(n||0,10)}else i=parseInt(e);return null==i&&(i=Number(e)),isNaN(i)?null:i}class d{#i;#r;#n;constructor(e,t){this.#i=e,this.#r=t,this.#n=!1}get linearCreative(){return this.#i.creative}get linearAdTracker(){return this.#i}get companionTracker(){return this.#r}get skipAfterDuration(){return this.#n}set skipAfterDuration(e){this.#n=e}hasVideoMedia(){return this.linearCreative.mediaFiles.some((e=>e&&null==e.apiFramework))}}class p{#a;#o;#s;#l;constructor(e,t,i,r){this.#a=e,this.#o=t,this.#l=i,this.#s=r}loadAds(e={}){return new Promise(((t,i)=>{const{url:r,xml:n}=e,a=(Array.isArray(r)?r:[r]).filter((e=>null!=e));let o;if(a.length)o=Promise.resolve([]),a.forEach((e=>{o=o.then((t=>null==t||0===t.length?this.loadAdsWithUrl(e):t)).catch((e=>[]))}));else{if(null==n)throw new Error("xml or url must be set");o=this.loadAdsWithXml(n)}o.then(t).catch(i)}))}loadAdsWithXml(e){return new Promise(((t,i)=>{let r;if(e.constructor===n.XMLDocument)r=e;else{if(e.constructor!==String)throw new Error("xml config option must be a String or XMLDocument");r=(new n.DOMParser).parseFromString(e,"application/xml")}this.#o.parseVAST(r).then(this.#l.selectAds).then(this.#c).then(t).catch(i)}))}loadAdsWithUrl(e){return new Promise(((t,i)=>{this.#a.get(e,{withCredentials:this.#s.withCredentials,wrapperLimit:this.#s.wrapperLimit}).then(this.#l.selectAds).then(this.#c).then(t).catch(i)}))}#c=e=>e.map((e=>{const i=new t.VASTTracker(this.#a,e,e.creatives.find(l),e.creatives.find(c));i.on("clickthrough",h);let r=null;const n=e.creatives.find(c);if(n){const i=this.#s,a=n.variations.filter((e=>e.staticResource)).filter((e=>0===e.type.indexOf("image"))).find((e=>parseInt(e.width,10)<=i.companion.maxWidth&&parseInt(e.height,10)<=i.companion.maxHeight));a&&(r=new t.VASTTracker(this.#a,e,n,a),r.on("clickthrough",h))}return new d(i,r)}))}function h(e){n.open(e,"_blank")}class f{selectAds(e){if(!e.ads||0===e.ads.length)throw new Error("no ads found in VAST");const t=e.ads.filter((e=>e.creatives.some(l)));if(!t.length)throw new Error("no linear ads found in VAST");const i=t.filter((e=>e.sequence));if(i.length)return i.sort(((e,t)=>e.sequence-t.sequence));return t.filter((e=>!i.includes(e))).slice(0,1)}}var m=i(178);function v(e){if(e){const t=e.ad,i=e.creative;return{mediaFiles:i.mediaFiles.map((e=>Object.assign({},e))),adSequenceId:t.sequence,adId:t.id,creativeAdId:i.id}}}const g=["application/x-javascript","text/javascript","application/javascript"];class y{#u;#d;#p;#h;#s;#f;constructor(e,t){this.#h=e,this.#s=t,this.#f=new videojs.EventTarget}handle(e){return this.#d=!1,this.#p=!1,this.#u=!1,new Promise(((t,i)=>{const a=this.#s,o=this.#h;let l=null,c={},u=!1;const d=e.creative,p=d.mediaFiles.find((e=>"VPAID"===e.apiFramework&&function(e){return g.indexOf(e.mimeType.trim())>-1}(e)));if(!p)throw new Error("Invalid VPAID media file: only JavaScript is supported");const h=o.el().querySelector(".vjs-tech");l=function(e){const t=e.vpaid.containerId,i=e.vpaid.containerClass;let n=r.getElementById(t);n||(n=r.getElementsByClassName(i)[0]);return n}(a),l?u=!0:(l=function(e){const t=e.vpaid.containerId,i=e.vpaid.containerClass,n=r.createElement("div");t&&n.setAttribute("id",t);i&&n.classList.add(i);return n}(a),u=!1),c=A(l),o.el().insertBefore(l,o.controlBar.el());const f=new m(l,h,{});f.loadAdUnit(p.fileURL,((r,p)=>{let h;if(r)return void i(r);const m=()=>{y(),t(),o.trigger("vpaid.AdStopped"),o.trigger({type:"vast.adEnd",vast:v(e)})};p.subscribe("AdStopped",m);const g=e=>{if(p&&!this.#u){p.unsubscribe("AdStopped",m);const t=()=>{this.#u=!0,y(),i(e),o.trigger("vpaid.AdStopped")};k(p,"AdStopped",t,t),p.stopAd()}else this.#u=!0,i(e)};if(this.#f.on("forceStopAd",g),this.#d)return void g("Received cancel signal from player");function y(){if(o.controlBar.show(),o.off("playerresize",R),"new"===a.vpaid.videoInstance&&h.parentElement&&h.parentElement.removeChild(h),f.destroy(),l){if(u){l.innerHTML="";const e=c,t=A(l);for(const[i,r]of Object.entries(t))e.hasOwnProperty(i)?e[i]!==r&&l.setAttribute(i,e[i]):l.removeAttribute(i);for(const[i,r]of Object.entries(e))t.hasOwnProperty(i)||l.setAttribute(i,r)}else l.parentElement&&l.parentElement.removeChild(l);l=null}}const b=()=>{if(this.#d)return void g("Received cancel signal");p.subscribe("AdSkipped",(()=>{e.skip(),o.trigger("vpaid.AdSkipped"),o.trigger({type:"vast.adSkip",vast:v(e)})})),p.subscribe("AdVolumeChange",(()=>{const t=o.volume();p.getAdVolume(((i,r)=>{i||(0===r&&t>0?e.setMuted(!0):r>0&&0===t&&e.setMuted(!1),o.volume(r),o.trigger("vpaid.AdVolumeChange"))}))})),p.subscribe("AdImpression",(()=>{e.trackImpression(),o.trigger("vpaid.AdImpression")})),p.subscribe("AdClickThru",((t,i,r)=>{r&&e.once("clickthrough",(e=>{n.open(e,"_blank")})),e.click(t),o.trigger("vpaid.AdClickThru")})),p.subscribe("AdVideoFirstQuartile",(()=>{e.track("firstQuartile"),o.trigger("vpaid.AdVideoFirstQuartile")})),p.subscribe("AdVideoMidpoint",(()=>{e.track("midpoint"),o.trigger("vpaid.AdVideoMidpoint")})),p.subscribe("AdVideoThirdQuartile",(()=>{e.track("thirdQuartile"),o.trigger("vpaid.AdVideoThirdQuartile")})),p.subscribe("AdVideoComplete",(()=>{e.track("complete"),o.trigger("vpaid.AdVideoComplete")})),p.subscribe("AdUserAcceptInvitation",(()=>{e.acceptInvitation(),o.trigger("vpaid.AdUserAcceptInvitation")})),p.subscribe("AdUserMinimize",(()=>{e.minimize(),o.trigger("vpaid.AdUserMinimize")})),p.subscribe("AdUserClose",(()=>{e.close(),o.trigger("vpaid.AdUserClose")})),p.subscribe("AdPaused",(()=>{e.setPaused(!0),o.trigger("vpaid.AdPaused")})),p.subscribe("AdPlaying",(()=>{e.setPaused(!1),o.trigger("vpaid.AdPlaying")})),p.getAdLinear(T(((e,i)=>{this.#d?g("Received cancel signal"):e?g(e):i?t():g("Non-linear not supported")}),(()=>{g("Unable to get mode of operation: linear or non-linear")})));const t=()=>{o.controlBar.hide();const e=s(E);k(p,"AdStarted",e,g),p.startAd()}},E=()=>{this.#d?g("Received cancel signal"):(this.#p=!0,e.track("start"),o.on("playerresize",R),o.trigger("ads-ad-started"),o.trigger({type:"vast.adStart",vast:v(e)}))},R=()=>{p.resizeAd(o.currentWidth(),o.currentHeight(),o.isFullscreen()?"fullscreen":"normal")};p.handshakeVersion("2.0",((t,r)=>{if(t)return log.console(t),void g("Error on VPAID handshake");const s={AdParameters:d.adParameters||""},c=a.vpaid.videoInstance;"same"===c?h=o.tech({kindaKnowWhatImDoing:!0}).el():"new"===c?(h=n.document.createElement("video"),h.style.cssText="position:absolute; top:0; left:0; z-index:2 !important;",l.appendChild(h)):h=null;const u={slot:l,videoSlot:h};k(p,"AdLoaded",b,g);const f=o.isFullscreen()?"fullscreen":"normal";p.subscribe("AdError",(t=>{e.error({ERRORCODE:901}),this.#u=!0,y(),i(`Fatal VPAID Error: ${"object"==typeof t?JSON.stringify(t):t}`),o.trigger({type:"vpaid.AdError",error:t})})),p.initAd(o.currentWidth(),o.currentHeight(),f,-1,s,u)}))}))}))}cancel(){this.#d=!0,this.#p&&this.#f.trigger("forceStopAd")}}function A(e){const t={};for(const i of e.attributes)t[i.name]=i.value;return t}function T(e,t=null){const i=setTimeout((()=>{e=()=>{},t&&t()}),1e4);return function(){clearTimeout(i),e.apply(null,arguments)}}function k(e,t,i,r){const n=T(i,(()=>{r&&r(new Error(`Timeout while waiting for ${t} event.`))}));e.subscribe(t,n)}const b=e.getPlugin("plugin"),E=Object.freeze({seekEnabled:!1,controlsEnabled:!1,wrapperLimit:10,withCredentials:!0,skip:0,displayRemainingTime:!1,displayRemainingTimeIcons:!1,messages:{skip:"Skip",skipCountdown:"Skip in {seconds}...",remainingTime:"This ad will end in {seconds}"},vpaid:{containerId:void 0,containerClass:"vjs-vpaid-container",videoInstance:"none"},companion:{elementId:null,maxWidth:0,maxHeight:0}});e.registerPlugin("vast",class extends b{constructor(i,n){super(i),"function"==typeof i.ads&&i.ads({debug:!1,liveCuePoints:!1}),i.on("play",(function(){}));const o=parseInt(e.VERSION,10)>=8?e.obj.merge:e.mergeOptions;n=o(E,n||{});const l=new t.VASTClient,c=[];let d=null,h=0,m=0;const g=new y(i,n);let A=!1,T=n.schedule;var k;null==T||0===T.length?T=[{offset:0,url:n.url||null,xml:n.xml||null}]:(k=T,T=JSON.parse(JSON.stringify(k)),T.forEach((e=>delete e.offsetInSeconds)));const b=function(e){return e.find(B)}(T),R=function(e){return e.find(_)}(T),w=function(e){return e.filter((e=>!B(e)&&!_(e)))}(T).sort(((e,t)=>e.offset-t.offset)),N=i.autoplay();i.on("adtimeout",(()=>{A=!0}));const C=new a(i,n);function L(){d?.hasVideoMedia()&&(d.linearAdTracker.skip(),i.trigger({type:"vast.skipAd",vast:v(d.linearAdTracker)}),D())}C.on("skip",L),C.on("click",(()=>{d.linearAdTracker.click()}));const I=(()=>{let e=!1;return()=>{if(e)return;let t=null;for(;w.length>0&&(t=w[0].offsetInSeconds,null==t);){const{offset:e}=w[0];t=u(e,i.duration()),null==t?w.shift():w[0].offsetInSeconds=t}if(null!=t&&this.player.currentTime()>t){e=!0;const t=w.shift();S.loadAds(t).then((e=>{e.length>0&&(c.push(...e),d=null,M())})).catch((e=>{})).finally((()=>{e=!1}))}}})();w.length>0&&i.on("timeupdate",I),i.on("readyforpostroll",(()=>{A=!1,S.loadAds(R).then((e=>{A?e.forEach((e=>{e.linearAdTracker.error({ERRORCODE:301})})):e.length>0?(c.push(...e),d=null,M()):i.trigger("nopostroll")})).catch((e=>{i.trigger("nopostroll")}))})),i.on("readyforpreroll",(()=>{M()}));const U=s((()=>{i.trigger("adsready")}));setTimeout(U,3e3);const S=new p(l,new t.VASTParser,new f,n);S.loadAds(b).then((e=>{A?e.forEach((e=>{e.linearAdTracker.error({ERRORCODE:301})})):e.length>0?(c.push(...e),d=null):i.trigger("nopreroll")})).catch((e=>{i.trigger("nopreroll")})).finally((()=>{U(),N&&i.play()}));const x=e=>e.filter((e=>null==e.apiFramework)).map((e=>({type:e.mimeType,src:e.fileURL}))),D=()=>{const e=c.shift();if(e?.hasVideoMedia()?d?.hasVideoMedia()||C.setUp():d?.hasVideoMedia()&&C.tearDown(),e){if(d=e,h++,d.hasVideoMedia()){const e=d.linearCreative.mediaFiles,t=e.filter((e=>"streaming"===e.deliveryType)),r=e.filter((e=>"streaming"!==e.deliveryType));if(r.length>0)i.src(x(r));else if(t.length>0){let e=d.linearAdTracker.assetDuration;if(null==e||e<1)return void D();i.src(x(t)),d.skipAfterDuration=!0}C.duration=d.linearAdTracker.assetDuration||0}else g.handle(d.linearAdTracker).then((()=>{D()})).catch((e=>{D()}));P()}else d=null,h=0,F()},{setUpEvents:O,tearDownEvents:V}=(()=>{const e=()=>{if(d.skipAfterDuration){const e=d;setTimeout((()=>{d===e&&L()}),1e3*e.linearAdTracker.assetDuration)}!d.linearAdTracker.impressed&&d.hasVideoMedia()&&(d.linearAdTracker.trackImpression(),i.trigger({type:"vast.adStart",vast:v(d.linearAdTracker)}))},t=()=>{d&&(isNaN(d.linearAdTracker.assetDuration)&&(d.linearAdTracker.assetDuration=i.duration()),d.linearAdTracker.setProgress(i.currentTime()))},r=()=>{i.remainingTime()>0&&(d.linearAdTracker.setPaused(!0),i.one("adplay",(()=>{d.linearAdTracker.setPaused(!1)})))},n=()=>{d.linearAdTracker.error({ERRORCODE:405}),i.error(null),D()},a=()=>{d.linearAdTracker.setFullscreen(i.isFullscreen())},o=(()=>{let e=i.muted(),t=i.volume();return()=>{const r=i.volume(),n=i.muted();e!==n?(d.linearAdTracker.setMuted(n),e=n):t!==r&&(t>0&&0===r?d.linearAdTracker.setMuted(!0):0===t&&r>0&&d.linearAdTracker.setMuted(!1),t=r)}})(),s=()=>{d.hasVideoMedia()&&(d.linearAdTracker.complete(),i.trigger({type:"vast.adEnd",vast:v(d.linearAdTracker)}),D())};return{setUpEvents:()=>{i.on("adended",s),i.on("adplay",e),i.on("adtimeupdate",t),i.on("adpause",r),i.on("aderror",n),i.on("advolumechange",o),i.on("fullscreenchange",a)},tearDownEvents:()=>{i.off("adended",s),i.off("adplay",e),i.off("adtimeupdate",t),i.off("adpause",r),i.off("aderror",n),i.off("advolumechange",o),i.off("fullscreenchange",a)}}})(),P=()=>{const e=d.companionTracker,t=r.getElementById(n.companion.elementId);if(e&&e.variation&&t){const i=e.variation,n=()=>{e.click()},a=r.createElement("a");a.src="#",a.addEventListener("click",n);const o=r.createElement("img");o.src=i.staticResource,a.appendChild(o),t.innerHTML="",t.appendChild(a)}else t&&(t.innerHTML="")},M=()=>{m=c.length,i.ads.startLinearAdMode(),O(),D()};function B(e){return 0===e.offset||null==e.offset||"pre"===e.offset}function _(e){return"post"===e.offset}const F=()=>{i.ads.endLinearAdMode(),V()}}})})()})();
|