cloudinary-video-player
Version:
Cloudinary Video Player
1 lines • 87.8 kB
JavaScript
(self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[]).push([[330],{2650:(t,e,n)=>{var i=n(7938),o=n.n(i),r=n(5204),s=n.n(r),a=n(7509),d=n.n(a),l="7.5.2",A=function(t,e){e.isImmediatePropagationStopped=function(){return!0},e.cancelBubble=!0,e.isPropagationStopped=function(){return!0}},h=function(t,e,n){A(0,n),t.trigger({type:e+n.type,originalEvent:n})};function u(t){"playing"===t.type?function(t,e){t.ads.isInAdMode()&&(t.ads.isContentResuming()?t.ads._contentEnding&&h(t,"content",e):h(t,"ad",e))}(this,t):"ended"===t.type?function(t,e){t.ads.isInAdMode()?t.ads.isContentResuming()?(A(0,e),t.trigger("resumeended")):h(t,"ad",e):t.ads._contentHasEnded||t.ads.stitchedAds()||(h(t,"content",e),t.trigger("readyforpostroll"))}(this,t):"loadstart"===t.type||"loadeddata"===t.type||"loadedmetadata"===t.type?function(t,e){if(!("loadstart"===e.type&&!t.ads._hasThereBeenALoadStartDuringPlayerLife||"loadeddata"===e.type&&!t.ads._hasThereBeenALoadedData||"loadedmetadata"===e.type&&!t.ads._hasThereBeenALoadedMetaData))if(t.ads.inAdBreak())h(t,"ad",e);else{if(t.currentSrc()!==t.ads.contentSrc)return;h(t,"content",e)}}(this,t):"play"===t.type?function(t,e){t.ads.inAdBreak()?h(t,"ad",e):t.ads.isContentResuming()&&h(t,"content",e)}(this,t):this.ads.isInAdMode()&&(this.ads.isContentResuming()?h(this,"content",t):h(this,"ad",t))}function c(){return c=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},c.apply(this,arguments)}function p(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,g(t,e)}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}var y={},m=function(){!function(t){if(o().dom.isInFrame()&&"function"!=typeof s().__tcfapi){for(var e,n=s(),i={};n;){try{if(n.frames.__tcfapiLocator){e=n;break}}catch(t){}if(n===s().top)break;n=n.parent}if(!e)return;s().__tcfapi=function(t,n,o,r){var s=Math.random()+"",a={__tcfapiCall:{command:t,parameter:r,version:n,callId:s}};i[s]=o,e.postMessage(a,"*")},s().addEventListener("message",(function(t){var e={};try{e="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){}var n=e.__tcfapiReturn;n&&"function"==typeof i[n.callId]&&(i[n.callId](n.returnValue,n.success),i[n.callId]=null)}),!1)}}(),"function"==typeof s().__tcfapi&&s().__tcfapi("addEventListener",2,(function(t,e){e&&(y=t)}))},f="",v=function(t,e){if(void 0===e&&(e=s()),e.__uspapi)e.__uspapi("getUSPData",1,(function(e,n){var i=n?e.uspString:null;f=i,t(i)}));else{var n=function(t){for(var e=t.parent;e!==t.top;){try{if(e.frames&&e.frames.__uspapiLocator)return e}catch(t){}e=e.parent}try{if(t.top.frames&&t.top.frames.__uspapiLocator)return t.top}catch(t){}return null}(e);if(!n)return void t(null);var i=Math.random().toString(36).substring(2),o={__uspapiCall:{command:"getUSPData",version:1,callId:i}};e.addEventListener("message",(function n(o){if(o&&o.data&&o.data.__uspapiReturn&&o.data.__uspapiReturn.callId===i){e.removeEventListener("message",n,!1);var r=o.data.__uspapiReturn,s=r.returnValue,a=r.success?s.uspString:null;f=a,t(a)}}),!1),n.postMessage(o,"*")}},P={AdsBeforePrerollError:"ads-before-preroll-error",AdsPrerollError:"ads-preroll-error",AdsMidrollError:"ads-midroll-error",AdsPostrollError:"ads-postroll-error",AdsMacroReplacementFailed:"ads-macro-replacement-failed",AdsResumeContentFailed:"ads-resume-content-failed"},C=function(t,e){return e?encodeURIComponent(t):t},S=function(t,e,n,i,r){for(var s in void 0===i&&(i={}),e){var a=i.hasOwnProperty(s)?i[s]:s;if(a.startsWith("r:"))try{var d=new RegExp(a.slice(2),"g");t=t.replace(d,C(e[s],n))}catch(t){r.ads.error({errorType:P.AdsMacroReplacementFailed,macro:s,error:t}),o().log.warn('Unable to replace macro with regex "'+a+'". The provided regex may be invalid.')}else t=t.split(a).join(C(e[s],n))}return t};function b(t,e,n){void 0===e&&(e=!1),void 0===n&&(n={});var i=n.disableDefaultMacros||!1,r=n.macroNameOverrides||{};delete n.disableDefaultMacros,delete n.macroNameOverrides;var a=n;if(i)return S(t,a,e,r);var l,A,h,u=function(t){var e={},n=t.replace(/{([^}=]+)=([^}]*)}/g,(function(t,n,i){return e["{"+n+"}"]=i,"{"+n+"}"}));return{defaults:e,modifiedString:n}}(t),p=u.defaults,g=u.modifiedString;for(var m in t=g,c(a,{"{player.id}":(h=this).options_["data-player"]||h.id_,"{player.height}":h.currentHeight(),"{player.width}":h.currentWidth(),"{player.heightInt}":Math.round(h.currentHeight()),"{player.widthInt}":Math.round(h.currentWidth()),"{player.autoplay}":h.autoplay()?1:0,"{player.muted}":h.muted()?1:0,"{player.language}":h.language()||"","{mediainfo.id}":h.mediainfo?h.mediainfo.id:"","{mediainfo.name}":h.mediainfo?h.mediainfo.name:"","{mediainfo.duration}":h.mediainfo?h.mediainfo.duration:"","{player.duration}":h.duration(),"{player.durationInt}":Math.round(h.duration()),"{player.live}":h.duration()===1/0?1:0,"{player.pageUrl}":o().dom.isInFrame()?d().referrer:s().location.href,"{playlistinfo.id}":h.playlistinfo?h.playlistinfo.id:"","{playlistinfo.name}":h.playlistinfo?h.playlistinfo.name:"","{timestamp}":(new Date).getTime(),"{document.referrer}":d().referrer,"{window.location.href}":s().location.href,"{random}":Math.floor(1e12*Math.random())},function(t,e){var n={};return["description","tags","reference_id","ad_keys"].forEach((function(i){t&&t[i]?n["{mediainfo."+i+"}"]=t[i]:e["{mediainfo."+i+"}"]?n["{mediainfo."+i+"}"]=e["{mediainfo."+i+"}"]:n["{mediainfo."+i+"}"]=""})),["custom_fields","customFields"].forEach((function(e){!function(t,e,n){if(t&&t[n])for(var i=t[n],o=Object.keys(i),r=0;r<o.length;r++)e["{mediainfo."+n+"."+o[r]+"}"]=i[o[r]]}(t,n,e)})),n}(this.mediainfo,p),(l=y,A={},Object.keys(l).forEach((function(t){A["{tcf."+t+"}"]=l[t]})),A["{tcf.gdprAppliesInt}"]=l.gdprApplies?1:0,A),{"{usp.uspString}":f},function(t,e,n){var i=new RegExp("{pageVariable\\.([^}]+)}","g"),r={},a=(t.match(i)||[]).concat(Object.keys(n).filter((function(e){return i.test(e)&&t.includes(n[e])})));if(a)return a.forEach((function(t){for(var n,i=t,a=t.slice(14,-1),d=a.split("."),l=s(),A=0;A<d.length;A++)if(A===d.length-1)n=l[d[A]];else if(void 0===(l=l[d[A]]))break;var h=typeof n;null===n?r[i]="null":void 0===n?e[i]?r[i]=e[i]:(o().log.warn('Page variable "'+a+'" not found'),r[i]=""):"string"!==h&&"number"!==h&&"boolean"!==h?(o().log.warn('Page variable "'+a+'" is not a supported type'),r[i]=""):r[i]=n})),r}(t,p,r)),t=S(t,a,e,r,this),p)t=t.replace(m,p[m]);return t}var k={processMetadataTracks:function(t,e){for(var n=t.textTracks(),i=function(n){"metadata"===n.kind&&(t.ads.cueTextTracks.setMetadataTrackMode(n),e(t,n))},o=0;o<n.length;o++)i(n[o]);n.addEventListener("addtrack",(function(t){i(t.track)}))},setMetadataTrackMode:function(t){},getSupportedAdCue:function(t,e){return e},isSupportedAdCue:function(t,e){return!0},getCueId:function(t,e){return e.id}},E=function(t,e){return void 0!==e&&t.ads.includedCues[e]},M=function(t,e){void 0!==e&&""!==e&&(t.ads.includedCues[e]=!0)};function T(){!1!==this.ads._shouldBlockPlay&&(this.paused()||(this.ads.debug("Playback was canceled by cancelContentPlay"),this.pause()),this.ads._cancelledPlay=!0)}k.processAdTrack=function(t,e,n,i){t.ads.includedCues={};for(var r=0;r<e.length;r++){var s=e[r],a=this.getSupportedAdCue(t,s);if(!this.isSupportedAdCue(t,s))return void o().log.warn("Skipping as this is not a supported ad cue.",s);var d=this.getCueId(t,s),l=s.startTime;if(E(t,d))return void o().log("Skipping ad already seen with ID "+d);i&&i(t,a,d,l),n(t,a,d,l),M(t,d)}};var L={},w=o();L.isMiddlewareMediatorSupported=function(){return!w.browser.IS_IOS&&!w.browser.IS_ANDROID&&!!(w.use&&w.middleware&&w.middleware.TERMINATOR)},L.playMiddleware=function(t){return{setSource:function(t,e){e(null,t)},callPlay:function(){if(t.ads&&!0===t.ads._shouldBlockPlay)return t.ads.debug("Using playMiddleware to block content playback"),t.ads._playBlocked=!0,w.middleware.TERMINATOR},play:function(e,n){t.ads&&t.ads._playBlocked&&e?(t.ads.debug("Play call to Tech was terminated."),t.trigger("play"),t.addClass("vjs-has-started"),t.ads._playBlocked=!1):n&&n.catch&&n.catch((function(e){"NotAllowedError"!==e.name||o().browser.IS_SAFARI||t.trigger("pause")}))}}},L.testHook=function(t){w=t};var R=L.playMiddleware,D=L.isMiddlewareMediatorSupported,B={src:"data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAxJtZGF03ABMYXZjNjEuMy4xMDAAQiAIwRg4AAACrgYF//+q3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2NCByMzEwOCAzMWUxOWY5IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMyAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTcgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0zIGJfcHlyYW1pZD0yIGJfYWRhcHQ9MSBiX2JpYXM9MCBkaXJlY3Q9MSB3ZWlnaHRiPTEgb3Blbl9nb3A9MCB3ZWlnaHRwPTIga2V5aW50PTI1MCBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NDAgcmM9Y3JmIG1idHJlZT0xIGNyZj0yMy4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAAn//71sXwKaunqigzoMi7hlyTJrrYi4m0AwABFxzcqWKGahTaoBcQAAMWK4AlcFlIICBeldSEQBGCMHAAABVNtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAAIgABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAACQXRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAIgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAABQAAAAPAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAACIAAAAAAAEAAAAAAbltZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAADwAAAACAFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAFkbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABJHN0YmwAAADAc3RzZAAAAAAAAAABAAAAsGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAABQADwAEgAAABIAAAAAAAAAAEUTGF2YzYxLjMuMTAwIGxpYngyNjQAAAAAAAAAAAAAAAAY//8AAAA2YXZjQwFkAA3/4QAZZ2QADazZQUH7ARAAAAMAEAAAAwPA8UKZYAEABmjr48siwP34+AAAAAAQcGFzcAAAAAEAAAABAAAAFGJ0cnQAAAAAAALAEAACwBAAAAAYc3R0cwAAAAAAAAABAAAAAQAAAgAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAC7wAAAAEAAAAUc3RjbwAAAAAAAAABAAAARQAAAj10cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAAABgAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAAXAAAEAAABAAAAAAG1bWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAACsRAAACABVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAABYG1pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABJHN0YmwAAAB+c3RzZAAAAAAAAAABAAAAbm1wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAACsRAAAAAAANmVzZHMAAAAAA4CAgCUAAgAEgICAF0AVAAAAAAH0AAAAEisFgICABRIQVuUABoCAgAECAAAAFGJ0cnQAAAAAAAH0AAAAEisAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAAVAAAABgAAABhzdGNvAAAAAAAAAAIAAAAwAAADNAAAABpzZ3BkAQAAAHJvbGwAAAACAAAAAf//AAAAHHNiZ3AAAAAAcm9sbAAAAAEAAAACAAAAAQAAAGF1ZHRhAAAAWW1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALGlsc3QAAAAkqXRvbwAAABxkYXRhAAAAAQAAAABMYXZmNjEuMS4xMDA=",type:"video/mp4"},I=function(){function t(){}return t.getState=function(e){if(e)return t.states_&&t.states_[e]?t.states_[e]:void 0},t.registerState=function(e,n){if("string"!=typeof e||!e)throw new Error('Illegal state name, "'+e+'"; must be a non-empty string.');return t.states_||(t.states_={}),t.states_[e]=n,n},t}(),j=function(){function t(t){this.player=t}t._getName=function(){return"Anonymous State"};var e=t.prototype;return e.transitionTo=function(t){var e=this.player;this.cleanup(e);var n=new t(e);e.ads._state=n,e.ads.debug(this.constructor._getName()+" -> "+n.constructor._getName());for(var i=arguments.length,o=new Array(i>1?i-1:0),r=1;r<i;r++)o[r-1]=arguments[r];n.init.apply(n,[e].concat(o))},e.init=function(){},e.cleanup=function(){},e.onPlay=function(){},e.onPlaying=function(){},e.onEnded=function(){},e.onAdEnded=function(){},e.onAdsReady=function(){o().log.warn("Unexpected adsready event")},e.onAdsError=function(){},e.onAdsCanceled=function(){},e.onAdTimeout=function(){},e.onAdStarted=function(){},e.onAdSkipped=function(){},e.onContentChanged=function(){},e.onContentResumed=function(){},e.onReadyForPostroll=function(){o().log.warn("Unexpected readyforpostroll event")},e.onNoPreroll=function(){},e.onNoPostroll=function(){},e.startLinearAdMode=function(){o().log.warn("Unexpected startLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.endLinearAdMode=function(){o().log.warn("Unexpected endLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.skipLinearAdMode=function(){o().log.warn("Unexpected skipLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.isAdState=function(){throw new Error("isAdState unimplemented for "+this.constructor._getName())},e.isWaitingForAdBreak=function(){return!1},e.isContentResuming=function(){return!1},e.inAdBreak=function(){return!1},e.handleEvent=function(t){var e=this.player;"play"===t?this.onPlay(e):"adsready"===t?this.onAdsReady(e):"adserror"===t?this.onAdsError(e):"adscanceled"===t?this.onAdsCanceled(e):"adtimeout"===t?this.onAdTimeout(e):"ads-ad-started"===t?this.onAdStarted(e):"ads-ad-skipped"===t?this.onAdSkipped(e):"contentchanged"===t?this.onContentChanged(e):"contentresumed"===t?this.onContentResumed(e):"readyforpostroll"===t?this.onReadyForPostroll(e):"playing"===t?this.onPlaying(e):"ended"===t?this.onEnded(e):"nopreroll"===t?this.onNoPreroll(e):"nopostroll"===t?this.onNoPostroll(e):"adended"===t&&this.onAdEnded(e)},t}();I.registerState("State",j);var _=function(t){function e(e){var n;return(n=t.call(this,e)||this).contentResuming=!1,n.waitingForAdBreak=!1,n}p(e,t);var n=e.prototype;return n.isAdState=function(){return!0},n.onPlaying=function(){var t=I.getState("ContentPlayback");this.contentResuming&&this.transitionTo(t)},n.onContentResumed=function(){var t=I.getState("ContentPlayback");this.contentResuming&&this.transitionTo(t)},n.isWaitingForAdBreak=function(){return this.waitingForAdBreak},n.isContentResuming=function(){return this.contentResuming},n.inAdBreak=function(){return!0===this.player.ads._inLinearAdMode},e}(j);I.registerState("AdState",_);var W=function(t){function e(){return t.apply(this,arguments)||this}p(e,t);var n=e.prototype;return n.isAdState=function(){return!1},n.onContentChanged=function(t){var e=I.getState("BeforePreroll"),n=I.getState("Preroll");t.ads.debug("Received contentchanged event (ContentState)"),t.paused()?this.transitionTo(e):(this.transitionTo(n,!1),t.pause(),t.ads._pausedOnContentupdate=!0)},e}(j);I.registerState("ContentState",W);var N,F=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"AdsDone"};var n=e.prototype;return n.init=function(t){t.ads._contentHasEnded=!0,t.trigger("ended")},n.startLinearAdMode=function(){o().log.warn("Unexpected startLinearAdMode invocation (AdsDone)")},e}(I.getState("ContentState"));I.registerState("AdsDone",F);var O=function(t){t.ads.debug("Starting ad break"),t.ads._inLinearAdMode=!0,t.trigger("adstart"),t.ads.shouldTakeSnapshots()&&(t.ads.snapshot=function(t){var e;e=o().browser.IS_IOS&&t.ads.isLive(t)&&t.seekable().length>0?t.currentTime()-t.seekable().end(0):t.currentTime();var n=t.$(".vjs-tech"),i=t.textTracks?t.textTracks():[],r=[],s={ended:t.ended(),currentSrc:t.currentSrc(),sources:t.currentSources(),src:t.tech_.src(),currentTime:e,type:t.currentType()};n&&(s.style=n.getAttribute("style"));for(var a=0;a<i.length;a++){var d=i[a];r.push({track:d,mode:d.mode}),d.mode="disabled"}return s.suppressedTracks=r,s}(t)),t.ads.shouldPlayContentBehindAd(t)&&!t.ads.settings.stitchedAds&&(t.ads.preAdVolume_=t.volume(),t.volume(0)),t.addClass("vjs-ad-playing"),t.hasClass("vjs-live")&&t.removeClass("vjs-live"),t.ads.removeNativePoster(),t.ads.preAdPlaybackRate_=t.playbackRate(),t.playbackRate(1),t.controlBar&&t.controlBar.playbackRateMenuButton&&t.controlBar.playbackRateMenuButton.playbackRateSupported&&!t.controlBar.playbackRateMenuButton.hasClass("vjs-hidden")?(t.controlBar.playbackRateMenuButton.hide(),t.ads.showPlaybackMenuOnAdEnd_=!0):t.ads.showPlaybackMenuOnAdEnd_=!1},U=function(t,e){t.ads.debug("Ending ad break"),void 0===e&&(e=function(){}),t.ads.adType=null,t.ads._inLinearAdMode=!1,t.trigger("adend"),t.removeClass("vjs-ad-playing"),t.ads.isLive(t)&&t.addClass("vjs-live"),t.ads.shouldTakeSnapshots()?function(t,e){var n=t.ads.snapshot;if(void 0===e&&(e=function(){}),!0===t.ads.disableNextSnapshotRestore)return t.ads.disableNextSnapshotRestore=!1,delete t.ads.snapshot,void e();var i,r=t.$(".vjs-tech"),s=20,a=n.suppressedTracks,d=function(){for(var t=0;t<a.length;t++)(i=a[t]).track.mode=i.mode},l=function(){var e;if(o().browser.IS_IOS&&t.ads.isLive(t)){if(n.currentTime<0&&(e=t.seekable().length>0?t.seekable().end(0)+n.currentTime:t.currentTime(),t.currentTime(e)),t.paused()){var i=t.play();i&&i.catch&&i.catch((function(t){o().log.warn("Play promise rejected in IOS snapshot resume",t)}))}}else if(n.ended)t.currentTime(t.duration());else{t.currentTime(n.currentTime);var r=t.play();r&&r.catch&&r.catch((function(t){o().log.warn("Play promise rejected in snapshot resume",t)}))}t.ads.shouldRemoveAutoplay_&&(t.autoplay(!1),t.ads.shouldRemoveAutoplay_=!1)},A=function e(){if(t.off("contentcanplay",e),N&&t.clearTimeout(N),(r=t.el().querySelector(".vjs-tech")).readyState>1)return l();if(void 0===r.seekable)return l();if(r.seekable.length>0)return l();if(s--)t.setTimeout(e,50);else try{l()}catch(e){t.ads.error({errorType:P.AdsResumeContentFailed,error:e}),o().log.warn("Failed to resume the content after an advertisement",e)}};if("style"in n&&r.setAttribute("style",n.style||""),t.ads.videoElementRecycled())t.one("resumeended",(function(){delete t.ads.snapshot,e()})),t.one("contentloadedmetadata",d),o().browser.IS_IOS&&!t.autoplay()&&"function"==typeof t.techCall_&&(t.techCall_("setAutoplay",!0),t.ads.shouldRemoveAutoplay_=!0),t.src(n.sources),t.one("contentcanplay",A),N=t.setTimeout(A,2e3);else{if(d(),!t.ended()){var h=t.play();h&&h.catch&&h.catch((function(t){o().log.warn("Play promise rejected in snapshot restore",t)}))}delete t.ads.snapshot,e()}}(t,e):(t.ads.preAdVolume_&&t.volume(t.ads.preAdVolume_),e()),t.playbackRate(t.ads.preAdPlaybackRate_),t.ads.showPlaybackMenuOnAdEnd_&&t.controlBar.playbackRateMenuButton.show()},V=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"Preroll"};var n=e.prototype;return n.init=function(t,e,n){if(this.waitingForAdBreak=!0,t.addClass("vjs-ad-loading"),n||t.ads.nopreroll_)return this.resumeAfterNoPreroll(t);var i=t.ads.settings.timeout;"number"==typeof t.ads.settings.prerollTimeout&&(i=t.ads.settings.prerollTimeout),this._timeout=t.setTimeout((function(){t.trigger("adtimeout")}),i),e?this.handleAdsReady():this.adsReady=!1},n.onAdsReady=function(t){t.ads.inAdBreak()?o().log.warn("Unexpected adsready event (Preroll)"):(t.ads.debug("Received adsready event (Preroll)"),this.handleAdsReady())},n.handleAdsReady=function(){this.adsReady=!0,this.readyForPreroll()},n.afterLoadStart=function(t){var e=this.player;e.ads._hasThereBeenALoadStartDuringPlayerLife?t():(e.ads.debug("Waiting for loadstart..."),e.one("loadstart",(function(){e.ads.debug("Received loadstart event"),t()})))},n.noPreroll=function(){var t=this;this.afterLoadStart((function(){t.player.ads.debug("Skipping prerolls due to nopreroll event (Preroll)"),t.resumeAfterNoPreroll(t.player)}))},n.readyForPreroll=function(){var t=this.player;this.afterLoadStart((function(){t.ads.debug("Triggered readyforpreroll event (Preroll)"),t.trigger("readyforpreroll")}))},n.onAdsCanceled=function(t){var e=this;t.ads.debug("adscanceled (Preroll)"),this.afterLoadStart((function(){e.resumeAfterNoPreroll(t)}))},n.onAdsError=function(t){var e=this;o().log("adserror (Preroll)"),t.ads.error({errorType:P.AdsPrerollError}),this.inAdBreak()?t.ads.endLinearAdMode():this.afterLoadStart((function(){e.resumeAfterNoPreroll(t)}))},n.startLinearAdMode=function(){var t=this.player;!this.adsReady||t.ads.inAdBreak()||this.isContentResuming()?o().log.warn("Unexpected startLinearAdMode invocation (Preroll)"):(this.clearTimeout(t),t.ads.adType="preroll",this.waitingForAdBreak=!1,O(t),t.ads._shouldBlockPlay=!1)},n.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},n.endLinearAdMode=function(){var t=this.player;this.inAdBreak()&&(t.removeClass("vjs-ad-loading"),t.addClass("vjs-ad-content-resuming"),this.contentResuming=!0,U(t))},n.skipLinearAdMode=function(){var t=this,e=this.player;e.ads.inAdBreak()||this.isContentResuming()?o().log.warn("Unexpected skipLinearAdMode invocation"):this.afterLoadStart((function(){e.trigger("adskip"),e.ads.debug("skipLinearAdMode (Preroll)"),t.resumeAfterNoPreroll(e)}))},n.onAdTimeout=function(t){var e=this;this.afterLoadStart((function(){t.ads.debug("adtimeout (Preroll)"),e.resumeAfterNoPreroll(t)}))},n.onNoPreroll=function(t){t.ads.inAdBreak()||this.isContentResuming()?o().log.warn("Unexpected nopreroll event (Preroll)"):this.noPreroll()},n.resumeAfterNoPreroll=function(t){if(this.contentResuming=!0,t.ads._shouldBlockPlay=!1,this.cleanupPartial(t),t.ads._playRequested||t.ads._pausedOnContentupdate)if(t.paused()){t.ads.debug("resumeAfterNoPreroll: attempting to resume playback (Preroll)");var e=t.play();e&&e.then&&e.then(null,(function(t){}))}else t.ads.debug("resumeAfterNoPreroll: already playing (Preroll)"),t.trigger("play"),t.trigger("playing")},n.cleanup=function(t){t.ads._hasThereBeenALoadStartDuringPlayerLife||o().log.warn("Leaving Preroll state before loadstart event can cause issues."),this.cleanupPartial(t)},n.cleanupPartial=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming"),this.clearTimeout(t)},n.clearTimeout=function(t){t.clearTimeout(this._timeout),this._timeout=null},e}(I.getState("AdState"));I.registerState("Preroll",V);var H=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"BeforePreroll"};var n=e.prototype;return n.init=function(t){this.adsReady=!1,this.shouldResumeToContent=!1,t.ads._shouldBlockPlay=!t.ads.settings.allowVjsAutoplay||!t.autoplay()},n.onAdsReady=function(t){t.ads.debug("Received adsready event (BeforePreroll)"),this.adsReady=!0},n.onPlay=function(t){var e=I.getState("Preroll");t.ads.debug("Received play event (BeforePreroll)"),this.transitionTo(e,this.adsReady,this.shouldResumeToContent)},n.onAdsCanceled=function(t){t.ads.debug("adscanceled (BeforePreroll)"),this.shouldResumeToContent=!0},n.onAdsError=function(){this.player.ads.debug("adserror (BeforePreroll)"),this.player.ads.error({errorType:P.AdsBeforePrerollError}),this.shouldResumeToContent=!0},n.onNoPreroll=function(){this.player.ads.debug("Skipping prerolls due to nopreroll event (BeforePreroll)"),this.shouldResumeToContent=!0},n.skipLinearAdMode=function(){var t=this.player;t.trigger("adskip"),t.ads.debug("skipLinearAdMode (BeforePreroll)"),this.shouldResumeToContent=!0},n.onContentChanged=function(){this.init(this.player)},e}(I.getState("ContentState"));I.registerState("BeforePreroll",H);var x=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"Midroll"};var n=e.prototype;return n.init=function(t){t.ads.adType="midroll",O(t),t.addClass("vjs-ad-loading")},n.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},n.endLinearAdMode=function(){var t=this.player;this.inAdBreak()&&(this.contentResuming=!0,t.addClass("vjs-ad-content-resuming"),t.removeClass("vjs-ad-loading"),U(t))},n.onAdsError=function(t){t.ads.error({errorType:P.AdsMidrollError}),this.inAdBreak()&&t.ads.endLinearAdMode()},n.cleanup=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming")},e}(I.getState("AdState"));I.registerState("Midroll",x);var Z=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"Postroll"};var n=e.prototype;return n.init=function(t){if(this.waitingForAdBreak=!0,t.ads._contentEnding=!0,t.ads.nopostroll_){this.resumeContent(t);var e=I.getState("AdsDone");this.transitionTo(e)}else{t.addClass("vjs-ad-loading");var n=t.ads.settings.timeout;"number"==typeof t.ads.settings.postrollTimeout&&(n=t.ads.settings.postrollTimeout),this._postrollTimeout=t.setTimeout((function(){t.trigger("adtimeout")}),n)}},n.startLinearAdMode=function(){var t=this.player;t.ads.inAdBreak()||this.isContentResuming()?o().log.warn("Unexpected startLinearAdMode invocation (Postroll)"):(t.ads.adType="postroll",t.clearTimeout(this._postrollTimeout),this.waitingForAdBreak=!1,O(t))},n.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},n.endLinearAdMode=function(){var t=this,e=this.player,n=I.getState("AdsDone");this.inAdBreak()&&(e.removeClass("vjs-ad-loading"),this.resumeContent(e),U(e,(function(){t.transitionTo(n)})))},n.skipLinearAdMode=function(){var t=this.player;t.ads.inAdBreak()||this.isContentResuming()?o().log.warn("Unexpected skipLinearAdMode invocation"):(t.ads.debug("Postroll abort (skipLinearAdMode)"),t.trigger("adskip"),this.abort(t))},n.onAdTimeout=function(t){t.ads.debug("Postroll abort (adtimeout)"),this.abort(t)},n.onAdsError=function(t){t.ads.debug("Postroll abort (adserror)"),t.ads.error({errorType:P.AdsPostrollError}),t.ads.inAdBreak()?t.ads.endLinearAdMode():this.abort(t)},n.onContentChanged=function(t){if(this.isContentResuming()){var e=I.getState("BeforePreroll");this.transitionTo(e)}else if(!this.inAdBreak()){var n=I.getState("Preroll");this.transitionTo(n)}},n.onNoPostroll=function(t){this.isContentResuming()||this.inAdBreak()?o().log.warn("Unexpected nopostroll event (Postroll)"):this.abort(t)},n.resumeContent=function(t){this.contentResuming=!0,t.addClass("vjs-ad-content-resuming")},n.abort=function(t){var e=I.getState("AdsDone");this.resumeContent(t),t.removeClass("vjs-ad-loading"),this.transitionTo(e)},n.cleanup=function(t){t.removeClass("vjs-ad-content-resuming"),t.clearTimeout(this._postrollTimeout),t.ads._contentEnding=!1},e}(I.getState("AdState"));I.registerState("Postroll",Z);var G=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"ContentPlayback"};var n=e.prototype;return n.init=function(t){t.ads._shouldBlockPlay=!1},n.onAdsReady=function(t){t.ads.debug("Received adsready event (ContentPlayback)"),t.ads.nopreroll_||(t.ads.debug("Triggered readyforpreroll event (ContentPlayback)"),t.trigger("readyforpreroll"))},n.onReadyForPostroll=function(t){var e=I.getState("Postroll");t.ads.debug("Received readyforpostroll event"),this.transitionTo(e)},n.startLinearAdMode=function(){var t=I.getState("Midroll");this.transitionTo(t)},e}(I.getState("ContentState"));I.registerState("ContentPlayback",G);var z=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"StitchedContentPlayback"};var n=e.prototype;return n.init=function(){this.player.ads._shouldBlockPlay=!1},n.onContentChanged=function(){this.player.ads.debug("Received contentchanged event ("+this.constructor._getName()+")")},n.startLinearAdMode=function(){var t=I.getState("StitchedAdRoll");this.transitionTo(t)},e}(I.getState("ContentState"));I.registerState("StitchedContentPlayback",z);var Y=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"StitchedAdRoll"};var n=e.prototype;return n.init=function(){this.waitingForAdBreak=!1,this.contentResuming=!1,this.player.ads.adType="stitched",O(this.player)},n.onPlaying=function(){},n.onContentResumed=function(){},n.onAdEnded=function(){this.endLinearAdMode(),this.player.trigger("ended")},n.endLinearAdMode=function(){var t=I.getState("StitchedContentPlayback");U(this.player),this.transitionTo(t)},e}(I.getState("AdState"));I.registerState("StitchedAdRoll",Y);var Q=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"OutstreamPending"};var n=e.prototype;return n.init=function(t){this.adsReady=!1},n.onPlay=function(t){var e=I.getState("OutstreamPlayback");t.ads.debug("Received play event (OutstreamPending)"),this.transitionTo(e,this.adsReady)},n.onAdsReady=function(t){t.ads.debug("Received adsready event (OutstreamPending)"),this.adsReady=!0},n.onAdsError=function(){this.player.ads.debug("adserror (OutstreamPending)"),this.adsReady=!1},e}(I.getState("AdState"));I.registerState("OutstreamPending",Q);var q=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"OutstreamPlayback"};var n=e.prototype;return n.init=function(t,e){t.addClass("vjs-ad-loading"),e?this.handleAdsReady():this.abort(t)},n.onAdsReady=function(t){t.ads.inAdBreak()?o().log.warn("Unexpected adsready event (Preroll)"):(t.ads.debug("Received adsready event (Preroll)"),this.handleAdsReady())},n.abort=function(t){var e=I.getState("OutstreamDone");t.removeClass("vjs-ad-loading"),this.transitionTo(e)},n.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},n.handleAdsReady=function(){this.adsReady=!0,this.readyForOutstreamPlayback()},n.readyForOutstreamPlayback=function(){var t=this.player;this.afterLoadStart((function(){t.trigger("readyforoutstream")}))},n.startLinearAdMode=function(){var t=this.player;this.adsReady&&!t.ads.inAdBreak()&&O(t)},n.cleanup=function(t){t.ads._hasThereBeenALoadStartDuringPlayerLife||o().log.warn("Leaving OutstreamPlayback state before loadstart event can cause issues."),this.cleanupPartial(t)},n.cleanupPartial=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming"),this.clearTimeout(t)},n.clearTimeout=function(t){t.clearTimeout(this._timeout),this._timeout=null},n.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},n.onAdsError=function(t){var e=this;o().log("adserror (OutstreamPlayback)"),this.inAdBreak()?t.ads.endLinearAdMode():this.afterLoadStart((function(){e.abort(t)}))},n.onAdTimeout=function(t){var e=this;this.afterLoadStart((function(){t.ads.debug("adtimeout (OutstreamPlayback)"),e.abort(t)}))},n.onAdsCanceled=function(t){var e=this;t.ads.debug("adscanceled (OutstreamPlaybac)"),this.afterLoadStart((function(){e.abort(t)}))},n.endLinearAdMode=function(){var t=this;if(this.inAdBreak()){this.player.removeClass("vjs-ad-loading");var e=I.getState("OutstreamDone");U(this.player,(function(){t.transitionTo(e)}))}},n.afterLoadStart=function(t){var e=this.player;e.ads._hasThereBeenALoadStartDuringPlayerLife?t():(e.ads.debug("Waiting for loadstart..."),e.one("loadstart",(function(){e.ads.debug("Received loadstart event"),t()})))},n.skipLinearAdMode=function(){var t=this,e=this.player,n=I.getState("OutstreamDone");this.inAdBreak()?o().log.warn("Unexpected skipLinearAdMode invocation"):this.afterLoadStart((function(){e.trigger("adskip"),e.ads.debug("skipLinearAdMode (OutstreamPlayback)"),t.transitionTo(n)}))},e}(I.getState("AdState"));I.registerState("OutstreamPlayback",q);var X=function(t){function e(){return t.apply(this,arguments)||this}p(e,t),e._getName=function(){return"OutstreamDone"};var n=e.prototype;return n.init=function(t){t.trigger("ended")},n.startLinearAdMode=function(){o().log.warn("Unexpected startLinearAdMode invocation (OutstreamDone)")},e}(I.getState("AdState"));I.registerState("OutstreamDone",X);var J=L.isMiddlewareMediatorSupported,K=o().getTech("Html5").Events,$={timeout:5e3,prerollTimeout:void 0,postrollTimeout:void 0,debug:!1,stitchedAds:!1,contentIsLive:void 0,liveCuePoints:!0,allowVjsAutoplay:o().options.normalizeAutoplay||!1},tt=function(t){var e=this,n=o().obj.merge($,t),i=[];K.concat(["firstplay","loadedalldata"]).forEach((function(t){-1===i.indexOf(t)&&i.push(t)})),e.on(i,u),J()||function(t,e){e&&o().log("Using cancelContentPlay to block content playback"),t.on("play",T)}(e,n.debug),e.setTimeout((function(){e.ads._hasThereBeenALoadStartDuringPlayerLife||""===e.src()||o().log.error("videojs-contrib-ads has not seen a loadstart event 5 seconds after being initialized, but a source is present. This indicates that videojs-contrib-ads was initialized too late. It must be initialized immediately after video.js in the same tick. As a result, some ads will not play and some media events will be incorrect. For more information, see http://videojs.github.io/videojs-contrib-ads/integrator/getting-started.html")}),5e3),e.on("ended",(function(){e.hasClass("vjs-has-started")||e.addClass("vjs-has-started")})),e.on("contenttimeupdate",(function(){e.removeClass("vjs-waiting")})),e.on(["addurationchange","adcanplay"],(function(){if(!e.ads.settings.stitchedAds&&!e.hasStarted()&&(!e.ads.snapshot||e.currentSrc()!==e.ads.snapshot.currentSrc)&&e.ads.inAdBreak()){var t=e.play();t&&t.catch&&t.catch((function(t){o().log.warn("Play promise rejected when playing ad",t)}))}})),e.on("nopreroll",(function(){e.ads.debug("Received nopreroll event"),e.ads.nopreroll_=!0})),e.on("nopostroll",(function(){e.ads.debug("Received nopostroll event"),e.ads.nopostroll_=!0})),e.on("playing",(function(){e.ads._cancelledPlay=!1,e.ads._pausedOnContentupdate=!1})),e.on("play",(function(){e.ads._playRequested=!0})),e.one("loadstart",(function(){e.ads._hasThereBeenALoadStartDuringPlayerLife=!0})),e.on("loadeddata",(function(){e.ads._hasThereBeenALoadedData=!0})),e.on("loadedmetadata",(function(){e.ads._hasThereBeenALoadedMetaData=!0})),e.ads=function(t){return{disableNextSnapshotRestore:!1,_contentEnding:!1,_contentHasEnded:!1,_hasThereBeenALoadStartDuringPlayerLife:!1,_hasThereBeenALoadedData:!1,_hasThereBeenALoadedMetaData:!1,_inLinearAdMode:!1,_shouldBlockPlay:!1,_playBlocked:!1,_playRequested:!1,_error:null,adType:null,VERSION:l,reset:function(){t.ads.disableNextSnapshotRestore=!1,t.ads._contentEnding=!1,t.ads._contentHasEnded=!1,t.ads.snapshot=null,t.ads.adType=null,t.ads._hasThereBeenALoadedData=!1,t.ads._hasThereBeenALoadedMetaData=!1,t.ads._cancelledPlay=!1,t.ads._shouldBlockPlay=!1,t.ads._playBlocked=!1,t.ads.nopreroll_=!1,t.ads.nopostroll_=!1,t.ads._playRequested=!1,t.ads._error=null},startLinearAdMode:function(){t.ads._state.startLinearAdMode()},endLinearAdMode:function(){t.ads._state.endLinearAdMode()},skipLinearAdMode:function(){t.ads._state.skipLinearAdMode()},stitchedAds:function(t){return void 0!==t&&(o().log.warn("Using player.ads.stitchedAds() as a setter is deprecated, it should be set as an option upon initialization of contrib-ads."),this.settings.stitchedAds=!!t),this.settings.stitchedAds},videoElementRecycled:function(){if(t.ads.shouldPlayContentBehindAd(t))return!1;if(!this.snapshot)throw new Error("You cannot use videoElementRecycled while there is no snapshot.");var e=t.tech_.src()!==this.snapshot.src,n=t.currentSrc()!==this.snapshot.currentSrc;return e||n},isLive:function(e){return void 0===e&&(e=t),"boolean"==typeof e.ads.settings.contentIsLive?e.ads.settings.contentIsLive:e.duration()===1/0||"8"===o().browser.IOS_VERSION&&0===e.duration()},shouldPlayContentBehindAd:function(e){if(void 0===e&&(e=t),e)return!!e.ads.settings.liveCuePoints&&!o().browser.IS_IOS&&!o().browser.IS_ANDROID&&e.duration()===1/0;throw new Error("shouldPlayContentBehindAd requires a player as a param")},shouldTakeSnapshots:function(e){return void 0===e&&(e=t),!this.shouldPlayContentBehindAd(e)&&!this.stitchedAds()},isInAdMode:function(){return this._state.isAdState()},isWaitingForAdBreak:function(){return this._state.isWaitingForAdBreak()},isContentResuming:function(){return this._state.isContentResuming()},isAdPlaying:function(){return this._state.inAdBreak()},inAdBreak:function(){return this._state.inAdBreak()},removeNativePoster:function(){var e=t.$(".vjs-tech");e&&e.removeAttribute("poster")},debug:function(){if(this.settings.debug){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];1===e.length&&"string"==typeof e[0]?o().log("ADS: "+e[0]):o().log.apply(o(),["ADS:"].concat(e))}},error:function(e){if(void 0===e)return this._error||null;null!==e&&e.errorType?(this._error=e,o().log.error("An error with Ads occured. Type: "+e.errorType+"."),t.trigger({type:"vjsadserror",error:this._error})):this._error=null}}}(e),e.ads.settings=n,n.stitchedAds=!!n.stitchedAds,"outstream"===n.playerMode?(e.src(B),e.ads._state=new(I.getState("OutstreamPending"))(e)):n.stitchedAds?e.ads._state=new(I.getState("StitchedContentPlayback"))(e):e.ads._state=new(I.getState("BeforePreroll"))(e),e.ads._state.init(e),e.ads.cueTextTracks=k,e.ads.adMacroReplacement=b.bind(e),function(t){t.ads.contentSrc=t.currentSrc(),t.ads._seenInitialLoadstart=!1,t.on("loadstart",(function(){if(!t.ads.inAdBreak()){var e=t.currentSrc();e!==t.ads.contentSrc&&(t.ads._seenInitialLoadstart&&t.trigger({type:"contentchanged"}),t.trigger({type:"contentupdate",oldValue:t.ads.contentSrc,newValue:e}),t.ads.contentSrc=e),t.ads._seenInitialLoadstart=!0}}))}(e),e.on("contentchanged",e.ads.reset);var r=function(){var t=e.textTracks();if(!e.ads.shouldPlayContentBehindAd(e)&&e.ads.inAdBreak()&&e.tech_.featuresNativeTextTracks&&o().browser.IS_IOS&&!Array.isArray(e.textTracks()))for(var n=0;n<t.length;n++){var i=t[n];"showing"===i.mode&&(i.mode="disabled")}};e.ready((function(){e.textTracks().addEventListener("change",r)})),e.on(["play","playing","ended","adsready","adscanceled","adskip","adserror","adtimeout","adended","ads-ad-started","ads-ad-skipped","contentchanged","dispose","contentresumed","readyforpostroll","nopreroll","nopostroll"],(function(t){e.ads._state.handleEvent(t.type)})),e.on("dispose",(function(){e.ads.reset(),e.textTracks().removeEventListener("change",r)})),m(),v((function(){})),e.ads.listenToTcf=m,e.ads.updateUsPrivacyString=function(t){return v(t)}};function et(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,"string");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}function nt(t){return nt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},nt(t)}function it(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ot(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,et(i.key),i)}}function rt(t,e,n){return e&&ot(t.prototype,e),n&&ot(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function st(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}tt.Error=P,tt.VERSION=l,function(t){!function(){if(o().getPlugin)return Boolean(o().getPlugin("ads"));var t=o().getComponent("Player");return Boolean(t&&t.prototype.ads)}(o())&&((o().registerPlugin||o().plugin)("ads",t),D()&&!o().usingContribAdsMiddleware_&&(o().use("*",R),o().usingContribAdsMiddleware_=!0,o().log.debug("Play middleware has been registered with videojs")))}(tt);var at=function(t,e,n){this.vjsPlayer=t,this.controller=n,this.contentTrackingTimer=null,this.contentComplete=!1,this.updateTimeIntervalHandle=null,this.updateTimeInterval=1e3,this.seekCheckIntervalHandle=null,this.seekCheckInterval=1e3,this.resizeCheckIntervalHandle=null,this.resizeCheckInterval=250,this.seekThreshold=100,this.contentEndedListeners=[],this.contentSource="",this.contentSourceType="",this.contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this.vjsPlayerDimensions={width:this.getPlayerWidth(),height:this.getPlayerHeight()},this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=null,this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this)),this.boundContentEndedListener=this.localContentEndedListener.bind(this),this.vjsPlayer.on("contentended",this.boundContentEndedListener),this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("readyforpreroll",this.onReadyForPreroll.bind(this)),this.vjsPlayer.on("adtimeout",this.onAdTimeout.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),"onPlay"===this.controller.getSettings().requestMode&&this.vjsPlayer.one("play",this.controller.requestAds.bind(this.controller)),this.vjsPlayer.ads||window.console.warn("You may be using a version of videojs-contrib-ads that is not compatible with your version of video.js."),this.vjsPlayer.ads(e)};at.prototype.setUpPlayerIntervals=function(){this.updateTimeIntervalHandle&&clearInterval(this.updateTimeIntervalHandle),this.seekCheckIntervalHandle&&clearInterval(this.seekCheckIntervalHandle),this.resizeCheckIntervalHandle&&clearInterval(this.resizeCheckIntervalHandle),this.updateTimeIntervalHandle=setInterval(this.updateCurrentTime.bind(this),this.updateTimeInterval),this.seekCheckIntervalHandle=setInterval(this.checkForSeeking.bind(this),this.seekCheckInterval),this.resizeCheckIntervalHandle=setInterval(this.checkForResize.bind(this),this.resizeCheckInterval)},at.prototype.updateCurrentTime=function(){this.contentPlayheadTracker.seeking||(this.contentPlayheadTracker.currentTime=this.vjsPlayer.currentTime())},at.prototype.checkForSeeking=function(){var t=1e3*(this.vjsPlayer.currentTime()-this.contentPlayheadTracker.previousTime);Math.abs(t)>this.seekCheckInterval+this.seekThreshold?this.contentPlayheadTracker.seeking=!0:this.contentPlayheadTracker.seeking=!1,this.contentPlayheadTracker.previousTime=this.vjsPlayer.currentTime()},at.prototype.checkForResize=function(){var t=this.getPlayerWidth(),e=this.getPlayerHeight();t==this.vjsPlayerDimensions.width&&e==this.vjsPlayerDimensions.height||(this.vjsPlayerDimensions.width=t,this.vjsPlayerDimensions.height=e,this.controller.onPlayerResize(t,e))},at.prototype.localContentEndedListener=function(){for(var t in this.contentComplete||(this.contentComplete=!0,this.controller.onContentComplete()),this.contentEndedListeners)"function"==typeof this.contentEndedListeners[t]&&this.contentEndedListeners[t]();this.vjsPlayer.el()&&this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this))},at.prototype.onNoPostroll=function(){this.vjsPlayer.trigger("nopostroll")},at.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.controller.onPlayerDisposed(),this.contentComplete=!0,this.vjsPlayer.off("contentended",this.boundContentEndedListener),this.vjsPlayer.ads.adTimeoutTimeout&&clearTimeout(this.vjsPlayer.ads.adTimeoutTimeout);var t=[this.updateTimeIntervalHandle,this.seekCheckIntervalHandle,this.resizeCheckIntervalHandle];for(var e in t)t[e]&&clearInterval(t[e])},at.prototype.onReadyForPreroll=function(){this.controller.onPlayerReadyForPreroll()},at.prototype.onAdTimeout=function(){this.controller.onAdTimeout()},at.prototype.onPlayerReady=function(){this.h5Player=document.getElementById(this.getPlayerId()).getElementsByClassName("vjs-tech")[0],this.h5Player.hasAttribute("autoplay")&&this.controller.setSetting("adWillAutoPlay",!0),this.onVolumeChange(),this.vjsPlayer.on("fullscreenchange",this.onFullscreenChange.bind(this)),this.vjsPlayer.on("volumechange",this.onVolumeChange.bind(this)),this.controller.onPlayerReady()},at.prototype.onFullscreenChange=function(){this.vjsPlayer.isFullscreen()?this.controller.onPlayerEnterFullscreen():this.controller.onPlayerExitFullscreen()},at.prototype.onVolumeChange=function(){var t=this.vjsPlayer.muted()?0:this.vjsPlayer.volume();this.controller.onPlayerVolumeChanged(t)},at.prototype.injectAdContainerDiv=function(t){this.vjsControls.el().parentNode.appendChild(t)},at.prototype.getContentPlayer=function(){return this.h5Player},at.prototype.getVolume=function(){return this.vjsPlayer.muted()?0:this.vjsPlayer.volume()},at.prototype.setVolume=function(t){this.vjsPlayer.volume(t),0==t?this.vjsPlayer.muted(!0):this.vjsPlayer.muted(!1)},at.prototype.unmute=function(){this.vjsPlayer.muted(!1)},at.prototype.mute=function(){this.vjsPlayer.muted(!0)},at.prototype.play=function(){this.vjsPlayer.play()},at.prototype.togglePlayback=function(){this.vjsPlayer.paused()?this.vjsPlayer.play():this.vjsPlayer.pause()},at.prototype.getPlayerWidth=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).width;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).width),parseFloat(t)||this.vjsPlayer.width()},at.prototype.getPlayerHeight=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).height;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).height),parseFloat(t)||this.vjsPlayer.height()},at.prototype.getPlayerOptions=function(){return this.vjsPlayer.options_},at.prototype.getPlayerId=function(){return this.vjsPlayer.id()},at.prototype.toggleFullscreen=function(){this.vjsPlayer.isFullscreen()?this.vjsPlayer.exitFullscreen():this.vjsPlayer.requestFullscreen()},at.prototype.getContentPlayheadTracker=function(){return this.contentPlayheadTracker},at.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},at.prototype.onAdLog=function(t){var e=t.getAdData(),n=void 0!==e.adError?e.adError.getMessage():void 0;this.vjsPlayer.trigger({type:"adslog",data:{AdError:n,AdEvent:t}})},at.prototype.onAdBreakStart=function(){this.contentSource=this.vjsPlayer.currentSrc(),this.contentSourceType=this.vjsPlayer.currentType(),this.vjsPlayer.off("contentended",this.boundContentEndedListener),this.vjsPlayer.ads.startLinearAdMode(),this.vjsControls.hide(),this.vjsPlayer.pause()},at.prototype.onAdBreakEnd=function(){this.vjsPlayer.on("contentended",this.boundContentEndedListener),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.vjsControls.show()},at.prototype.onAdStart=function(){this.vjsPlayer.trigger("ads-ad-started")},at.prototype.onAllAdsCompleted=function(){1==this.contentComplete&&(this.contentSource&&this.vjsPlayer.currentSrc()!=this.contentSource&&this.vjsPlayer.src({src:this.contentSource,type:this.contentSourceType}),this.controller.onContentAndAdsCompleted())},at.prototype.onAdsReady=function(){this.vjsPlayer.trigger("adsready")},at.prototype.changeSource=function(t){this.vjsPlayer.currentSrc()&&(this.vjsPlayer.currentTime(0),this.vjsPlayer.pause()),t&&this.vjsPlayer.src(t),this.vjsPlayer.one("loadedmetadata",this.seekContentToZero.bind(this))},at.prototype.seekContentToZero=function(){this.vjsPlayer.currentTime(0)},at.prototype.triggerPlayerEvent=function(t,e){this.vjsPlayer.trigger(t,e)},at.prototype.addContentEndedListener=function(t){this.contentEndedListeners.push(t)},at.prototype.reset=function(){this.vjsPlayer.off("contentended",this.boundContentEndedListener),this.vjsPlayer.on("contentended",this.boundContentEndedListener),this.vjsControls.show(),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.contentPlayheadTracker.currentTime=0,this.contentComplete=!1};var dt=function(t){this.controller=t,this.adContainerDiv=document.createElement("div"),this.controlsDiv=document.createElement("div"),this.countdownDiv=document.createElement("div"),this.seekBarDiv=document.createElement("div"),this.progressDiv=document.createElement("div"),this.playPauseDiv=document.createElement("div"),this.muteDiv=document.createElement("div"),this.sliderDiv=document.createElement("div"),this.sliderLevelDiv=document.createElement("div"),this.fullscreenDiv=document.createElement("div"),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundOnMouseMove=this.onMouseMove.bind(this),this.adPlayheadTracker={currentTime:0,duration:0,isPod:!1,adPosition:0,totalAds:0},this.controlPrefix=this.controller.getPlayerId()+"_",this.showCountdown=!0,!1===this.controller.getSettings().showCountdown&&(this.showCountdown=!1),this.isAdNonlinear=!1,this.createAdContainer()};dt.prototype.createAdContainer=function(){this.assignControlAttributes(this.adContainerDiv,"ima-ad-container"),this.adContainerDiv.style.position="absolute",this.adContainerDiv.style.zIndex=1111,this.adContainerDiv.addEventListener("mouseenter",this.showAdControls.bind(this),!1),this.adContainerDiv.addEventListener("mouseleave",this.hideAdControls.bind(this),!1),this.adContainerDiv.addEventListener("click",this.onAdContainerClick.bind(this),!1),this.createControls(),this.controller.injectAdContainerDiv(this.adContainerDiv)},dt.prototype.createControls=function(){this.assignControlAttributes(this.controlsDiv,"ima-controls-div"),this.controlsDiv.style.width="100%",this.controller.getIsMobile()?this.countdownDiv.style.display="none":(this.assignControlAttributes(this.countdownDiv,"ima-countdown-div"),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel,this.countdownDiv.style.display=this.showCountdown?"block":"none"),this.assignControlAttributes(this.seekBarDiv,"ima-seek-bar-div"),this.seekBarDiv.style.width="100%",this.assignControlAttributes(this.progressDiv,"ima-progress-div"),this.assignControlAttributes(this.playPauseDiv,"ima-play-pause-div"),this.addClass(this.playPauseDiv,"ima-playing"),this.playPauseDiv.addEventListener("click",this.onAdPlayPauseClick.bind(this),!1),this.assignControlAttributes(this.muteDiv,"ima-mute-div"),this.addClass(this.muteDiv,"ima-non-muted"),this.muteDiv.addEventListener("click",this.onAdMuteClick.bind(this),!1),this.assignControlAttributes(this.sliderDiv,"ima-slider-div"),this.sliderDiv.addEventListener("mousedown",this.onAdVolumeSliderMouseDown.bind(this),!1),this.controller.getIsIos()&&(this.sliderDiv.style.display="none"),this.assignControlAttributes(this.sliderLevelDiv,"ima-slider-level-div"),this.assignControlAttributes(this.fullscreenDiv,"ima-fullscreen-div"),this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.fullscreenDiv.addEventListener("click",this.onAdFullscreenClick.bind(this),!1),this.adContainerDiv.appendChild(this.controlsDiv),this.controlsDiv.appendChild(this.countdownDiv),this.con