!function(){var e="googima",t="TYPE_API",i="TYPE_SCHEDULE",r="viewable",a="-1",n="jw-flag-ads-googleima",o="jw-flag-ads-vpaid",s="jw-flag-ads-vpaid-controls",d="playing",l="adBreakStart",u="adBreakEnd",p="adCompanions",c="adError",g="adStarted",h="viewable",f=2e3,m=4096,y=1e3;function v(e,t,i){if(!e)return e;for(var r=t.getPlaylistItem(),a=t.getConfig(),n=e.replace("__random-number__",Math.random()*Math.pow(10,18)).replace("__timestamp__",(new Date).getTime()).replace("__page-url__",encodeURIComponent(window.location.href)).replace("__referrer__",encodeURIComponent(document.referrer)).replace("__player-height__",t.getHeight()||a.height).replace("__player-width__",t.getWidth()||a.width).replace("__item-duration__",function(e,t){var i=Math.pow(10,t);return Math.round(e*i)/i}(t.getDuration(),3)).replace("__domain__",encodeURIComponent(function(){var e=window.location.href.match(new RegExp(/^[^/]*:\/\/\/?([^/]*)/));return e&&e.length>1?e[1]:""}())),o=(n=i.companiondiv&&i.companiondiv.id?n.replace("__companion-div__",i.companiondiv.id):n.replace("__companion-div__","")).match(new RegExp(/__item-[a-z 0-9 A-Z]*__/g)),s=0;o&&sp&&(u=u.substring(0,p)),n=n.replace(d,encodeURIComponent(u))}else n=n.replace(d,"")}if(r.title&&-1===n.indexOf("vid_t=")){var c=r.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");n+=(g=n,(-1!==g.indexOf("?")?"&":"?")+"vid_t="+encodeURIComponent(c))}var g;return n}var b=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")};function w(e,t){if("start"===e||"0%"===e)return"pre";if("end"===e||"100%"===e)return"post";if("string"==typeof e&&("pre"===e||"post"===e||e.indexOf("%")>=0))return e;var i=t.seconds(e);return"number"==typeof i&&i}function A(e,t,i){var r=w(e,t);return r?i.isNumber(r)?function(e){var t=parseInt(e,10),i=Math.floor(t)%1e3,r=Math.floor(t/1e3)%60,a=Math.floor(t/6e4)%60,n=Math.floor(t/36e5)%24;return(n=n<10?"0"+n:n)+":"+(a=a<10?"0"+a:a)+":"+(r=r<10?"0"+r:r)+"."+(i=("000"+i).slice(-3))}(1e3*r):r:"pre"}function P(e,t,i){if(!i)return e;var r=e.indexOf("?")>=0?"&":"?",a=e.indexOf("cust_params="),n="cust_params=".length,o="",s="";if(t.foreach(i,function(e,t){o=""+o+s+e+"="+t,s="&"}),o=encodeURIComponent(o),a>=0){var d=e.substr(0,a+n),l=e.substr(a+n);return""+d+o+"%26"+l}return""+e+r+"cust_params="+o}function E(e,t,i){var r={};return t.foreach(e,function(e,a){var n={},o=a.ad||a;n.offset=A(o.offset||o.position||a.offset||"",t,i),n.tag=P(o.tag,t,o.custParams),n.type=o.type||a.type||"linear,nonlinear",r[e]=n}),r}var C=function(){function e(t,i){b(this,e),this.player=t,this.options=i}return e.prototype.getAdsResponse=function(e){var t=this,i=this.player,r=i.utils,a='',n=[],o=[],s=[];return r.foreach(E(e,r,i._),function(e,r){var d=r.offset.replace("pre","start").replace("post","end"),l=a.replace(/_type_/g,r.type).replace(/_adbreakname_/g,e).replace(/_offset_/g,d).replace(/_url_/g,v(r.tag,i,t.options,r.custParams));"start"===d?n.push(l):"end"===d?s.push(l):o.push(l)}),''+n.join("")+o.join("")+s.join("")+""},e.prototype.getTagMap=function(e){var t=this,i=this.player,r=i.utils,a={};return r.foreach(E(e,r,i._),function(e,n){var o=w(n.offset,r);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),i._.isNumber(o)&&(a[o]={tag:v(n.tag,i,t.options)})}),a},e.prototype.getTagList=function(e){var t=this,i=this.player,r=i.utils,a=[];return r.foreach(E(e,r,i._),function(e,n){var o=w(n.offset,r);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),a.push({offset:o,tag:v(n.tag,i,t.options)})}),a},e}(),M={adcountercountkey:"__AD_POD_CURRENT__",adcounterdynamic:"Ad __AD_POD_CURRENT__ of __AD_POD_LENGTH__. ",adcountertotalkey:"__AD_POD_LENGTH__",admessage:"This ad will end in xx",admessagedynamickey:/(\b)xx(s?\b)/g,admessagestatic:"This is an Advertisement",advideoheight:0,advideowidth:0,allowadskip:!1,allowadskippastseconds:0,allowplayercontrols:!1,allowvolumeslider:!1,autoplayadsmuted:!1,click_tracking:!0,companiondiv:null,companionResourceType:"",cuetext:"Advertisement",debug:!1,enablePreloading:!1,invertmutebutton:!1,loadVideoTimeout:15e3,locale:"",maxRedirects:-1,overlayslotheight:0,overlayslotwidth:0,preloadAds:!1,premiumAds:!1,requestTimeout:1e4,scaled_ads:!0,truncateMacros:!0,usestaticmessage:!1,vastLoadTimeout:1e4,vpaidcontrols:!1,vpaidmode:"insecure"};function _(e){if("true"===e)return!0;if("false"===e)return!1;var t=parseFloat(e);return isNaN(t)?e:t}var L=function(){function e(t,i){b(this,e),this.config=t,this.utils=i,this.bidsResponse={};for(var r in M)if(M.hasOwnProperty(r)){var a=t[r],n=M[r],o=typeof n;if(void 0!==a){if("boolean"!==o&&"number"!==o||(a=_(a)),typeof a!==o)throw new Error("invalid parameter: "+r+" should be a "+o);this[r]=a}else this[r]=n}this.admessagedynamic=this.admessage}return e.prototype.getSingleTagPrerollBlock=function(){var e=this.getConfigSchedule(),t=this.singleTagBidsResponse;if("string"==typeof e){if(!t)return e;var i=t.custParams;return P(t.tag,this.utils,i)}return null},e.prototype.addBidsResponse=function(e,t){var i=void 0;i=e&&!e.error&&(e.bidWon||e.tag)?e:null,t?this.bidsResponse[t]=i:this.singleTagBidsResponse=i},e.prototype.resetBidsResponse=function(){this.bidsResponse={},this.singleTagBidsResponse=null},e.prototype.getSchedule=function(){var e=this,t=this.getConfigSchedule();if(!t)return t;var i=this.utils.extend({},t),r=this.getSingleTagPrerollBlock();return r||Object.keys(this.bidsResponse).reduce(function(t,i){var r=t[i],a=e.bidsResponse[i];return r&&a&&(t[i]=Object.assign({},r,{tag:a.tag,custParams:Object.assign({},r.custParams,a.custParams)})),t},i)},e.prototype.getConfigSchedule=function(){var e=this.config;return e.tag||this.adschedule||e.schedule||e.ad},e.prototype.getAdRules=function(){var e=this.config.rules||{},t=parseInt(e.frequency,10);return{startOn:e.startOn||1,frequency:isNaN(t)?1:t}},e}(),j=function(){function e(t,i,r){b(this,e);var a=document.createElement("div");this.visible=!1,this.style=r,this.div=t,this.adDiv=a,a.id=i+"_ad",r(t,{overflow:"hidden",width:"100%",height:"100%",display:"block",visibility:"hidden",pointerEvents:"none",opacity:0}),r(a,{position:"absolute",width:"100%",height:"100%"}),t.appendChild(a)}return e.prototype.resizeNonLinear=function(e,t){this.style(this.div,{height:t+"px",top:"auto",width:"100%"})},e.prototype.resizeLinear=function(){this.style(this.div,{top:"0px",left:"0px",width:"100%",height:"100%"})},e.prototype.getAdDiv=function(){return this.adDiv},e.prototype.adSetup=function(){this.visible=!0,this.style(this.div,{visibility:"visible",display:"block",pointerEvents:"all",opacity:1},!0);for(var e=this.adDiv.childNodes,t=0;t=t.floorPriceCents&&(l.tag=(u=r,p=d,c=t.playerWidth,g=t.playerHeight,["https://an.facebook.com/v1/instream/vast.xml?placementid="+u,"&playerwidth="+c,"&playerheight="+g,"&sdk="+z,"&bidid="+p,"&pageurl="+de].join("")));var u,p,c,g;return l}).catch(function(e){return{result:re,message:"FAN header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var ue=null;function pe(){return null===ue&&(ue=Promise.resolve(window.apstag).then(function(e){if(e&&e.init&&e.fetchBids)return e;return se(["file"===document.location.protocol?"https:":"",V].join(""),q).then(function(){return window.apstag})}).catch(function(e){throw ue=null,e})),ue}var ce={requestBids:function(e,t){if(!e.id||!e.slotID)return Promise.resolve({result:ae,message:"Missing id or slotID in configuration"});return pe().then(function(i){return i.init({id:e.pubId,adServer:e.adServer}),new Promise(function(r){i.fetchBids({slots:[{slotID:e.slotID}],timeout:t.bidTimeout},r)})}).then(function(i){return i&&i[0]&&i[0].slotID===e.slotID?{result:ie,tag:t.tag,custParams:{amznbid:i[0].amznbid,amzniid:i[0].amzniid}}:{result:ne,message:"No bids for pubID and slotID"}}).catch(function(e){return{result:re,message:"Amazon header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var ge=null,he=null;function fe(e){if(null===he){var t=oe(),i=ge||window.SpotX;if(i&&i.DirectAdOS)return he=Promise.resolve({SpotX:i,loadingTime:0});var r=["file"===document.location.protocol?"https:":"",J,e,".js"].join("");(he="function"==typeof require?(a=r,n=q,new Promise(function(e,t){setTimeout(t,n),require([a],e,t)}).catch(function(){return Promise.reject("Error loading script")})).then(function(e){return{SpotX:ge=e,loadingTime:oe()-t}}).catch(function(){return me(r,t)}):me(r,t)).catch(function(e){throw he=null,e})}var a,n;return he}function me(e,t){return se(e,q).then(function(){return{SpotX:window.SpotX,loadingTime:oe()-t}})}var ye=void 0,ve={requestBids:function(e,t){if(!e.id)return Promise.resolve({result:ae,message:"Missing id in configuration"});var i=Object.assign({channel_id:e.id,slot:t.playerContainer,content_width:t.playerWidth,content_height:t.playerHeight,player_vendor:"SpotXJW",player_vendor_id:t.playerId,ad_volume:t.adVolume,ad_mute:t.mute?1:0,autoplay:t.autoplay,blocked_autoplay_override_mode:t.autoplayAdsMuted,start_delay:function(e){if("start"===e||"0%"===e||!e||"pre"===e||"00:00:00"===e)return 0;if("end"===e||"100%"===e||"post"===e)return-2;if("string"==typeof e&&e.indexOf("%")>=0)return-1;var t=parseInt(e);return t>0?t:-1}(t.offset),placement:1,hide_skin:!0},e.optionalParams);e.passFloorPrice&&t.floorPriceCents&&(i.price_floor=t.floorPriceCents/100);return fe(e.id).then(function(e){var t=e.SpotX,r=e.loadingTime;ye=r;var a=new t.DirectAdOS(i),n=oe();return a.getAdServerKVPs().then(function(e){return{response:e,bidNetworkStartTime:n}})}).then(function(e){var i=e.response,r=e.bidNetworkStartTime,a=oe()-r,n=i.spotx_ad_key,o={spotx_bid:i.spotx_bid,spotx_ad_key:n},s=100*parseFloat(i.spotx_bid),d={result:ie,priceInCents:s,custParams:o,scriptLoadingTime:ye,bidNetworkResponseTime:a};if(t.mediationLayerAdServer===F)return d;var l=["file:"===document.location.protocol?"https:":"",H,n].join("");return Object.assign(d,{tag:l,tagKey:n})}).catch(function(e){return"SpotX :: Unable to find ad"===e.message?{result:ne,message:e.message,scriptLoadingTime:ye}:{result:re,message:"SpotX header bidding failed: "+e,scriptLoadingTime:ye}})},getCustomResponse:function(){return{scriptLoadingTime:ye}}};var be=null;function we(e){return null===be&&(be=Promise.resolve(window.indexapi).then(function(t){if(t)return t;return se(["file"===document.location.protocol?"https:":"",e||G].join(""),q).then(function(){return window.indexapi})}).catch(function(e){throw be=null,e})),be}var Ae={requestBids:function(e,t){if(!e.id&&!e.script)return Promise.resolve({result:ae,message:"Missing id or script in configuration"});var i=Object.assign({videoCommonArgs:{protocols:[2,3,5,6],mimes:["video/mp4","video/webm","application/javascript"],apiList:[1,2]},siteID:e.id},e);return we().then(function(e){return new Promise(function(r){e.deferQueue=e.deferQueue||[],e.deferQueue.push(function(){e.solicitIndexVideoAds(t.tag,function(e,t){r({updatedTag:e,indexTargeting:t})},i)})})}).then(function(e){var i=e.indexTargeting;return void 0!==i?{result:ie,tag:t.tag,custParams:i}:{result:ne,message:"No bids for site id"}}).catch(function(e){return{result:re,message:"Index Exchange header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var Pe,Ee=(Pe={},Pe[[$]]=ce,Pe[["FAN"]]=le,Pe[[Z]]=Ae,Pe[[ee]]=ve,Pe);var Ce=function(){function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.settings,a=void 0===r?{}:r,n=i.bidders,o=void 0===n?[]:n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};b(this,e),this.settings=function(e,t){var i=Object.assign({bidTimeout:O,offset:"",playerContainer:t.container,playerHeight:t.height||0,playerWidth:t.width||0,tag:""},t,e);return te[i.mediationLayerAdServer]||(i.mediationLayerAdServer=Y),i.mediationLayerAdServer===K&&(i.floorPriceCents=N),i}(a,s),this.bidders=(d=o,d.reduce(function(e,t){return t.name&&(e[t.name]=Object.assign(t,t.custom_params)),e},{}));var d;if("pre"!==this.settings.offset&&0!==parseInt(this.settings.offset)){var l;this.bidders=this.bidders[ee]?(l={},l[[ee]]=this.bidders[ee],l):{}}this.bidders[$]&&this.bidders[$].id&&this.bidders[$].slotID&&pe(),this.bidders[Z]&&(this.bidders[Z].script||this.bidders[Z].id)&&we(this.bidders[Z].script),this.bidders[ee]&&this.bidders[ee].id&&fe(this.bidders[ee].id),this._bidRequest=null,this._currentTimeout=null,this._onCancelTrigger=null,this.onCancel=new Promise(function(e){t._onCancelTrigger=e})}return e.prototype.start=function(){return this._bidRequest||(this._bidRequest=function(e){var t=e.config,i=e.settings,r=e.onCancel,a=te[i.mediationLayerAdServer].filter(function(e){return t[e]}).map(function(e){var a=oe();return Promise.race([Ee[e].requestBids(t[e],i,r),r]).then(function(i){var r=Ee[e].getCustomResponse();return Object.assign({},t[e],i,r,{timeForBidResponse:oe()-a|0})})});return Promise.all(a).then(function(e){var t=i.mediationLayerAdServer===F||i.mediationLayerAdServer===Q,r=i.mediationLayerAdServer===X||i.mediationLayerAdServer===Q||i.mediationLayerAdServer===K,a={priceInCents:i.floorPriceCents,timeForBidResponse:1/0},n=[],o={},s={};return s.bidders=e.map(function(e){return t||(e.winner=!1),e.result===ie&&(n.push(e),Object.assign(o,e.custParams),r&&(e.priceInCents>a.priceInCents||e.priceInCents===a&&e.timeForBidResponse4&&void 0!==arguments[4]?arguments[4]:null;return{type:t,client:e,adBreakId:r,adPlayId:a,adposition:null!==n?n:function(e){if(e.isBeforePlay()||0===e.getPosition())return"pre";if(e.isBeforeComplete()||e.getPosition()===e.getDuration())return"post";return"mid"}(i),viewable:i.getViewable()}}var _e=function(){function t(e,i,r,a,n,o,s){b(this,t),r.utils.extend(this,r.Events),this.item=e,this.options=i,this.player=r,this.env=r.getEnvironment(),this.utils=r.utils,this.instreamProvider=a,this.view=n,this.initAdsManagerPromise=null,this.blockingInstreamPlayer=null,this.currentAd=null,this.bids=[],this.timeoutAdStart=-1,this.progressIntervalId=-1,this.fullscreenIcon=r.getContainer().querySelector(".jw-icon-fullscreen"),this.adsLoaderManager=o,this.playbackProxy={currentTime:0,duration:0},this.video=s,this.paused=!1,this.pausedByViewable=!1,this._qoe=new r.utils.Timer,this.debugConsoleLog=r.utils.noop,i.debug&&(this.debugConsoleLog=function(){var e;(e=console).log.apply(e,arguments)})}return t.prototype.startBid=function(t,i,r){var a=this,n=this.utils.extend({},t.config.bids),o=i.offset,s=new Ce(n,{tag:i.tag,offset:o,width:this.player.getWidth(),height:this.player.getHeight(),container:this.player.getContainer(),playerId:this.player.id,autoplay:this.player.getConfig().autostart,autoplayAdsMuted:t.autoplayadsmuted,adVolume:this.player.getVolume(),mute:this.player.getMute()});this.bids.push(s),s.start();var d=this.adsLoaderManager.getAdBreakId(o),l=this.adsLoaderManager.getAdPlayId(o);return this.trigger("adBidRequest",s.getEventObject(e,n.bidders,{offset:o,adBreakId:d,adPlayId:l})),s.then(function(i){if(a.trigger("adBidResponse",s.getEventObject(e,i.bidders,{offset:o,adBreakId:d,adPlayId:l})),a.destroyed())return null;a.adsLoaderManager.setBid(o,s,i.bidders),t.addBidsResponse(i.result,r)})},t.prototype.init=function(e,t){var i=this,r=t.config.bids;if(r){var a=t.getSchedule();if("string"==typeof a)this.startBid(t,{tag:a,offset:"pre"});else{var n=parseInt(r.bidOnBreaks);n=n>0?n:1/0,Object.keys(a).slice(0,n).forEach(function(e){i.startBid(t,a[e],e)})}}var o=this.adsLoaderManager;return this.initAdsManagerPromise=S().then(function(){return i.destroyed()?null:(i.debugConsoleLog("[JW DEBUG] Open adsLoaderManager"),o.open(e,t,i.video))}).then(function(e){if(i.destroyed())return null;var r=o.getAdsManager(e,i.playbackProxy,i.options);i.instreamProvider.setProxy(r),o.bindEvents({LOADED:i.adLoaded.bind(i),AD_ERROR:i.adError.bind(i),CONTENT_PAUSE_REQUESTED:i.pauseRequested.bind(i),CONTENT_RESUME_REQUESTED:i.resumeRequested.bind(i),LOG:i.adLog.bind(i),STARTED:i.adStarted.bind(i),IMPRESSION:i.adImpression.bind(i),LINEAR_CHANGED:i.resize.bind(i),CLICK:i.adClick.bind(i),PAUSED:i.adPaused.bind(i),RESUMED:i.adResumed.bind(i),SKIPPED:i.adSkipped.bind(i),USER_CLOSE:i.adUserClose.bind(i),ALL_ADS_COMPLETED:i.allAdsCompleted.bind(i)});var a=r.getCuePoints();if(!t.preloadAds||-1===a.indexOf(0)){var n=i.player.getSafeRegion(!1),s=n.width,d=n.height,l=i.getViewMode();i.debugConsoleLog("[JW DEBUG] adsManager init with",s,d,l),o.init(s,d,l)}if(a.length){var u=a.filter(function(e){return e>0}).map(function(e){return{begin:e,text:i.options.cuetext}});i.player.setCues(u)}return r}).catch(function(e){throw i.asyncError&&i.asyncError(e),e}),this.initAdsManagerPromise},t.prototype.getViewMode=function(){var e=google.ima.ViewMode;return this.player.getFullscreen()?e.FULLSCREEN:e.NORMAL},t.prototype.prepareToPlayAd=function(e){if(!this.destroyed())if(this.blockingInstreamPlayer){var t=e?"":this.player.getConfig().localization.loadingAd;this.blockingInstreamPlayer.setText(t)}else clearTimeout(this.timeoutAdStart),this.startBlocking(e)},t.prototype.requestAds=function(e,t){var i=this,r=this.bids.concat(S());Promise.all(r).then(function(){i.destroyed()||null===i.adsLoaderManager.adsRequest&&(i.debugConsoleLog("[JW DEBUG] Request ads to IMA SDK"),i.adsLoaderManager.requestAds(e,t,i.options))})},t.prototype.muteInstreamProvider=function(){var e=this.video.muted||this.player.getMute();this.debugConsoleLog("[JW DEBUG] Setting mute on instreamProvider",e),this.instreamProvider.mute(e)},t.prototype.exitFullscreenOnInlineIOS=function(){if(this.env.OS.iOS){this.env.Browser.version.major<10||(this.debugConsoleLog("[JW DEBUG] Exiting fullscreen mode on iOS 10+"),this.player.setFullscreen(!1),this.utils.style(this.fullscreenIcon,{display:"none"}))}},t.prototype.startBlocking=function(e){var t=this;if(!this.blockingInstreamPlayer&&!this.destroyed()){this.debugConsoleLog("[JW DEBUG] JW Player startBlocking"),this.exitFullscreenOnInlineIOS(),this.options.premiumAds&&this.player.on("viewable",function(e){e.viewable?t.pausedByViewable&&(t.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Start playing the ad on viewable"),t.player.play()):t.paused||(t.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Pause the ad on not viewable"),t.player.pause(),t.pausedByViewable=!0)},this),this._qoe.tick("adLoading"),this.player.utils.addClass(this.player.getContainer(),n),this.blockingInstreamPlayer=this.player.createInstream().init();var i=e?"":this.player.getConfig().localization.loadingAd;this.blockingInstreamPlayer.setText(i),this.blockingInstreamPlayer.applyProviderListeners(this.instreamProvider),clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){if(t.bids.forEach(function(e){return e.stop()}),t.debugConsoleLog("[JW DEBUG] Ad request timeout"),!t.destroyed()){t.asyncError=null,t.stopBlocking(),t.asyncDiscardAdBreak();var e={message:"Ad Request timeout after "+t.options.requestTimeout+" milliseconds",getErrorCode:function(){return 60004}},i=t.adsLoaderManager.adErrorEventObject(e,{});t.trigger(c,i)}},this.options.requestTimeout)}},t.prototype.stopBlocking=function(){this.destroyed()||(this.debugConsoleLog("[JW DEBUG] JW Player stopBlocking"),this.player.off("viewable",null,this),clearTimeout(this.timeoutAdStart),this.utils.style(this.fullscreenIcon,{display:""}),this.player.utils.removeClass(this.player.getContainer(),[o,s,n]),this.blockingInstreamPlayer&&(this.instreamProvider.off(),this.blockingInstreamPlayer.destroy(),this.blockingInstreamPlayer=null,this.view.adTakeDown()))},t.prototype.pauseRequested=function(e){var t=this;this.prepareToPlayAd();var i=this.adsLoaderManager.adEventObject(e.getAd());this.player.trigger(l,Me(l,this.player,i.adBreakId,i.adPlayId,i.adposition)),this.blockingInstreamPlayer.on("destroyed",function(){var r=t.adsLoaderManager?t.adsLoaderManager.getLastAdPlayId(e.getAd()):i.adPlayId;t.player.trigger(u,Me(u,t.player,i.adBreakId,r,i.adposition))})},t.prototype.resumeRequested=function(){this.debugConsoleLog("[JW DEBUG] ResumeRequest from IMA SDK"),this.currentAd&&this.currentAd.isLinear()&&(this.finishAd(),this.view.adTakeDown()),this.stopBlocking()},t.prototype.finishAd=function(){this.currentAd&&(clearInterval(this.progressIntervalId),clearTimeout(this.viewableTimeout),this.currentAd=null)},t.prototype.discardAdBreak=function(e){!e&&this.adsLoaderManager&&(e=this.adsLoaderManager.adsManager),!this.destroyed()&&e&&(e.discardAdBreak(),e.stop())},t.prototype.asyncDiscardAdBreak=function(){var e=this;this.initAdsManagerPromise&&this.initAdsManagerPromise.then(function(t){return e.discardAdBreak(t)}).catch(this.utils.noop)},t.prototype.pause=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player pause ad"),e.pause())},t.prototype.resume=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player resume ad"),e.resume())},t.prototype.beforePlay=function(e){var t=this;if(this.initAdsManagerPromise){this.bids.forEach(function(e){return e.timeout()}),this.player.off("beforePlay",null,this);var i=!!e;this.prepareToPlayAd(i),this.adsLoaderManager.initializeDisplay({restrict:!0}),this._qoe.tick("adBeforePlay"),this.initAdsManagerPromise.then(function(e){if(!t.destroyed()){var i=t.adsLoaderManager;if(!i.initialized){var r=t.player.getSafeRegion(!1),a=r.width,n=r.height,o=t.getViewMode();t.debugConsoleLog("[JW DEBUG] adsManager init with",a,n,o),i.init(a,n,o)}t.debugConsoleLog("[JW DEBUG] Start adsManager"),i.start();var s=e.getCuePoints();"string"==typeof t.adsLoaderManager.schedule&&0===s.length||-1!==s.indexOf(0)||(t.debugConsoleLog("[JW DEBUG] Stop blocking since there is no preroll"),t.stopBlocking())}}).catch(this.utils.noop)}},t.prototype.beforeComplete=function(){var e=this.adsLoaderManager.adsManager;e&&e.getCuePoints().indexOf(-1)>-1&&this.prepareToPlayAd(),this.adsLoaderManager.unbindEvents(["CONTENT_RESUME_REQUESTED"]),this.playbackProxy.currentTime=this.playbackProxy.duration,this.debugConsoleLog("[JW DEBUG] Call contentComplete on IMA SDK"),this.adsLoaderManager.contentComplete()},t.prototype.time=function(e){this.playbackProxy.currentTime=e.position,e.duration>=e.position?this.playbackProxy.duration=e.duration:this.playbackProxy.duration=1/0},t.prototype.resize=function(){var e=this.currentAd,t=this.adsLoaderManager.adsManager;if(t){var i=e&&!e.isLinear(),r=this.player.getSafeRegion(i);if(i){var a=e.getHeight();a=this.player.getFullscreen()?r.height/2:Math.max(100,a+10),this.debugConsoleLog("[JW DEBUG] Resize adsManager",r.width,a,this.getViewMode()),t.resize(r.width,a,this.getViewMode()),this.view.resizeNonLinear(r,a)}else this.debugConsoleLog("[JW DEBUG] Resize adsManager",r.width,r.height,this.getViewMode()),t.resize(r.width,r.height,this.getViewMode()),this.view.resizeLinear()}},t.prototype.triggerAdPlay=function(e,t,i,r){if(e.isLinear()){this.instreamProvider.trigger("state",{newstate:i,oldstate:r});var a=this.adsLoaderManager.adEventObject(e);a.oldstate=r,a.newstate=i,this.trigger(t,a)}},t.prototype.progressInterval=function(e,t){var i=this;if(clearInterval(this.progressIntervalId),t){var r=e.getAdId(),a=-1,n=this.options.admessage||"",o=this.options.admessagedynamickey,s=this.options.adcounterdynamic||"",d=new RegExp(this.options.adcountercountkey,"g"),l=new RegExp(this.options.adcountertotalkey,"g");this.progressIntervalId=setInterval(function(){if(i.currentAd&&i.currentAd.getAdId()===r){var e=t.getRemainingTime();if(!(isNaN(e)||e<=0)&&a!==e){a=e;var u=i.currentAd.getDuration(),p=u-e,c=Math.round(u-p);if(i.blockingInstreamPlayer){var g=n.replace(o,"$1"+c+"$2"),h=i.currentAd.getAdPodInfo(),f=h.getTotalAds();if(f>1){var m=h.getAdPosition();g=s.replace(d,m).replace(l,f)+" "+g}i.blockingInstreamPlayer.setText(g),i.instreamProvider.trigger("time",{duration:u,position:p})}if(u>0){var y=i.adsLoaderManager.adEventObject(i.currentAd);y.position=p,y.duration=u,i.trigger("adTime",y)}}}else clearInterval(i.progressIntervalId)},250)}},t.prototype.adLoaded=function(e){this.muteInstreamProvider();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adRequest",t)},t.prototype.adStarted=function(e){this.paused=!1;var t=this.currentAd=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger(g,i)},t.prototype.adImpression=function(e){var t=this,i=e.getAd(),r=i.isLinear(),a=r&&(i.getContentType().indexOf("image")>=0||-1===i.getDuration()),n=i.getContentType(),l="application/javascript"===n||"application/x-shockwave-flash"===n,u=r&&l&&this.options.vpaidcontrols;this.currentAd=i,this.blockingInstreamPlayer&&this.blockingInstreamPlayer.setSkipOffset(i.getSkipTimeOffset()),this.adsLoaderManager.bindEvents({COMPLETE:this.adComplete.bind(this)}),l&&this.env.OS.mobile&&this.options.autoplayadsmuted&&this.adsLoaderManager.bindEvents({VOLUME_CHANGED:function(){t.adsLoaderManager.unbindEvents(["VOLUME_CHANGED"]),t.player.setMute(!!t.adsLoaderManager.adsManager.getVolume())}}),a?this.startBlocking():r||this.stopBlocking(),this.player.utils.toggleClass(this.player.getContainer(),o,r&&(a||l)),this.player.utils.toggleClass(this.player.getContainer(),s,u),this.view.adSetup(),this.resize(),this.muteInstreamProvider(),clearTimeout(this.timeoutAdStart);var p=this.adsLoaderManager.adsManager;this.progressInterval(i,p);var c=this.adsLoaderManager.adEventObject(i);"pre"!==c.adposition||void 0!==c.podcount&&1!==c.sequence||(this._qoe.tick("adImpression"),c.timeLoading=this._qoe.between("adBeforePlay","adImpression")),this.trigger("adImpression",c),this.addViewableImpressionHandler(),this.triggerAdPlay(i,"adPlay",d,"buffering")},t.prototype.addViewableImpressionHandler=function(){this.player.off(h,this.viewableHandler,this),this.player.on(h,this.viewableHandler,this),this.viewableHandler()},t.prototype.viewableHandler=function(e){var t=this;clearTimeout(this.viewableTimeout),this.viewableTimeout=null;(e?e.viewable:this.player.getViewable())&&(this.viewableTimeout=setTimeout(function(){t.player.off(h,t.viewableHandler,t),t.trigger("adViewableImpression",t.adsLoaderManager.adEventObject(t.currentAd))},2e3))},t.prototype.adComplete=function(e){this.finishAd();var t=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger("adComplete",i),this.adsLoaderManager.unbindEvents(["VOLUME_CHANGED"])},t.prototype.adClick=function(e){var t=this.adsLoaderManager.adsManager,i=e.getAd(),r=i.getContentType();"application/javascript"===r||"application/x-shockwave-flash"===r||(this.debugConsoleLog("[JW DEBUG] Ad paused due to ad click"),t.pause());var a=this.adsLoaderManager.adEventObject(i);this.trigger("adClick",a),this.pausedByViewable=!1},t.prototype.adPaused=function(e){this.paused||(this.paused=!0,this.triggerAdPlay(e.getAd(),"adPause","paused",d))},t.prototype.adResumed=function(e){this.paused&&(this.paused=!1,this.triggerAdPlay(e.getAd(),"adPlay",d,"paused"))},t.prototype.adSkipped=function(e){this.debugConsoleLog("[JW DEBUG] AdSkipped"),this.adsLoaderManager.unbindEvents(["COMPLETE","VOLUME_CHANGED"]),this.finishAd();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adSkipped",t)},t.prototype.adUserClose=function(e){this.debugConsoleLog("[JW DEBUG] AdUserClose"),this.currentAd&&this.currentAd.isLinear()&&-1===this.currentAd.getDuration()?this.adSkipped(e):(this.adsLoaderManager.unbindEvents(["COMPLETE","VOLUME_CHANGED"]),this.finishAd())},t.prototype.allAdsCompleted=function(){this.resumeRequested(),this.view.adTakeDown(),this.stopAdsManager()},t.prototype.stopAdsManager=function(){var e=this;this.initAdsManagerPromise.then(function(t){e.destroyed()||(e.debugConsoleLog("[JW DEBUG] Stop IMA SDK adsManager"),t.stop(),t.destroy(),e.initAdsManagerPromise=null,e.bids=[])}).catch(this.utils.noop)},t.prototype.adLog=function(e){this.debugConsoleLog("[JW DEBUG]",e.type,e);var t=e.getAdData();if(t&&t.adError){var i=this.adsLoaderManager.adErrorEventObject(t.adError,e);402===i.code?this.handleAdError(t.adError,e):this.trigger(c,i)}},t.prototype.adError=function(e){var t=e.getError();this.handleAdError(t,e)},t.prototype.asyncError=function(e){var t=this;if(!this.destroyed())if(clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){return t.destroy()},0),e&&e.getError){var i=e.getError();this.handleAdError(i,e,!0)}else e.target&&e.target.src?console.error("Failed to load "+e.target.src):console.error(e)},t.prototype.handleAdError=function(e,t,i){var r=this;this.options.debug&&console.error(e),900===e.getErrorCode()||i?(clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){return r.destroy()},0)):(this.stopBlocking(),this.view.adTakeDown());var a=this.adsLoaderManager.adErrorEventObject(e,t);this.player&&0===this.player.getPosition()&&(this._qoe.tick("adError"),a.timeLoading=this._qoe.between("adBeforePlay","adError")),this.trigger(c,a)},t.prototype.destroy=function(){if(this.debugConsoleLog("[JW DEBUG] JW Player destroy PlaylistItemManager"),this.off(),!this.destroyed()){this.player.off(null,null,this),this.bids.map(function(e){e.stop()}),this.bids=[],clearTimeout(this.timeoutAdStart),clearTimeout(this.viewableTimeout),clearInterval(this.progressIntervalId),this.currentAd=null,this.options=null,this.video=null,this.initAdsManagerPromise=null;var e=this.adsLoaderManager;e&&(e.reset(),this.adsLoaderManager=null),this.blockingInstreamPlayer&&this.stopBlocking(),this.instreamProvider.off(),this.instreamProvider.setProxy(null),this.instreamProvider=null,this.view.adTakeDown(),this.view=null,this.player=null,this.item=null}},t.prototype.destroyed=function(){return!this.item},t}();function Le(e){return new Array(e+1).join((Math.random().toString(36)+"00000000000000000").slice(2,18)).slice(0,e)}function je(e){try{return e.getAdPodInfo()}catch(e){return null}}function ke(e,t){var i=w(e,t);return"pre"===i?0:"post"===i?-1:i}var Te=function(){function t(e,i){b(this,t),this.adsLoader=null,this.adDisplayContainer=null,this.displayInitialized=!1,this.initialized=!1,this.started=!1,this.adsRequest=null,this.userRequestContext=null,this.adsManager=null,this.adsManagerEvents={},this.container=i,this.schedule=null,this.breakMap={},this.player=e}return t.prototype.getVpaidMode=function(e){var t=google.ima.ImaSdkSettings.VpaidMode;return"disabled"===e||"none"===e?t.DISABLED:"enabled"===e?t.ENABLED:t.INSECURE},t.prototype.initializeDisplay=function(e){this.adDisplayContainer&&!this.displayInitialized&&(this.adDisplayContainer.initialize(),e&&e.restrict&&(this.displayInitialized=!0))},t.prototype.contentComplete=function(){if(null!==this.adsRequest){var e=this.adsLoader;e&&e.contentComplete(),this.adsRequest=null}},t.prototype.reset=function(){this.userRequestContext=null;var e=this.adsManager;e&&(e.destroy(),this.adsManager=null),this.contentComplete(!0),this.schedule=null,this.breakMap={},this.adsManagerEvents={},this.initialized=this.started=!1},t.prototype.prepare=function(e){return null===this.adsLoader&&(this.adDisplayContainer=new google.ima.AdDisplayContainer(this.container,e),this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer)),this.adsLoader},t.prototype.open=function(e,t,i){var r=google.ima.settings;r.setDisableCustomPlaybackForIOS10Plus(!0),t.locale&&r.setLocale(t.locale),t.maxRedirects>=0&&r.setNumRedirects(t.maxRedirects);var a=this.prepare(i);return new Promise(function(e,t){a.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,t,!1),a.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e,!1)})},t.prototype.requestAds=function(e,t,i){if(null===this.adsRequest){var r=t.getSchedule();if(r){var a=this.adsRequest=new google.ima.AdsRequest,n=this.userRequestContext={requestType:e,vpaidMode:t.vpaidmode,playerVersion:this.player.version.split("+")[0]};a.setAdWillAutoPlay(!1!==this.player.getConfig().autostart),a.setAdWillPlayMuted(this.player.getMute());var o=this.player.getSafeRegion(!1);a.linearAdSlotWidth=o.width,a.linearAdSlotHeight=o.height;var s=this.player.getSafeRegion(!0);a.nonLinearAdSlotWidth=s.width,a.nonLinearAdSlotHeight=s.height,a.forceNonLinearFullSlot=i.forceNonLinearFullSlot,a.vastLoadTimeout=i.vastLoadTimeout;var d=new C(this.player,i);if("object"==typeof r){var l=d.getTagList(r);1===l.length&&0===l[0].offset&&(r=l[0].tag)}"string"==typeof r?r=a.adTagUrl=n.adTagUrl=v(r,this.player,i):a.adsResponse=n.adsResponse=d.getAdsResponse(r),this.schedule=r,this.breakMap=Object.assign(d.getTagMap(r),this.breakMap);var u=this.adsLoader.getSettings(),p=this.getVpaidMode(n.vpaidMode);u.setPlayerType("jwplayer"),u.setPlayerVersion(n.playerVersion),u.setVpaidMode(p),this.adsLoader.requestAds(a,n)}}},t.prototype.getAdsManager=function(e,t,i){var r=new google.ima.AdsRenderingSettings;return r.enablePreloading=i.enablePreloading||i.preloadAds,r.loadVideoTimeout=i.loadVideoTimeout,r.uiElements=null,r.useStyledNonLinearAds=!0,this.adsManager=e.getAdsManager(t,r),this.userRequestContext=e.getUserRequestContext(),this.adsManager},t.prototype.init=function(e,t,i){null!==this.adsManager&&!1===this.initialized&&(this.adsManager.init(e,t,i),this.initialized=!0)},t.prototype.start=function(){null!==this.adsManager&&!1===this.started&&(this.initializeDisplay({restrict:!0}),this.adsManager.start(),this.started=!0)},t.prototype.bindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,r=google.ima.AdErrorEvent.Type;Object.keys(e).forEach(function(a){var n=i[a]||r[a],o=t.adsManagerEvents[n];o&&t.adsManager.removeEventListener(n,o),t.adsManager.addEventListener(n,e[a],!1),t.adsManagerEvents[n]=e[a]})},t.prototype.unbindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,r=google.ima.AdErrorEvent.Type;e.forEach(function(e){var a=i[e]||r[e],n=t.adsManagerEvents[a];n&&(t.adsManager.removeEventListener(a,n),delete t.adsManagerEvents[a])})},t.prototype.getTag=function(e,t){if("string"==typeof this.schedule)return this.schedule;var i=je(e);if(i){var r=this.breakMap[i.getTimeOffset()]||{};if(r.tag)return r.tag}var a=this.userRequestContext;return t&&t.getUserRequestContext&&(a=t.getUserRequestContext()||a),a?a.adTagUrl||a.adsResponse||"":(console.error("invalid request context",a),"")},t.prototype.getAdBreakId=function(e){var t=ke(e,this.player.utils);return this.breakMap[t]=this.breakMap[t]||{},this.breakMap[t].adBreakId=this.breakMap[t].adBreakId||Le(12),this.breakMap[t].adBreakId},t.prototype.getAdPlayId=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=ke(e,this.player.utils);return this.breakMap[i].adPlayId=this.breakMap[i].adPlayId||{1:Le(12)},this.breakMap[i].adPlayId[t]=this.breakMap[i].adPlayId[t]||Le(12),this.breakMap[i].adPlayId[t]},t.prototype.getLastAdPlayId=function(e){var t=je(e);if(!t)return a;var i=t.getTimeOffset(),r=this.breakMap[i].adPlayId;return r[Object.keys(r).reduce(function(e,t){return Math.max(e,t)})]},t.prototype.getTimeoffsetFromPosition_=function(){var e=this.player.getPosition(),t=1/0,i=void 0;return Object.keys(this.breakMap).forEach(function(r){var a=r-e;a>=0&&a1&&(r.sequence=n,r.podcount=o);var s="mid";0===(a=i.getTimeOffset())?s="pre":-1===a&&(s="post"),r.adposition=s}else a=this.getTimeoffsetFromPosition_();return r.id=r.adBreakId=this.getAdBreakId(a),r.adPlayId=this.getAdPlayId(a,n),Object.assign(r,function(t,i,r){var a=r.bidders,n=r.bid,o={};if(!a)return o;if(n&&a.length){var s=n.getEventObject(e,a,{offset:i}),d=t&&t.getWrapperAdSystems?t.getWrapperAdSystems():[],l=t&&t.getAdSystem?t.getAdSystem():[];o.mediationLayerAdServer=s.mediationLayerAdServer,o.bidders=s.bidders,s.floorPriceCents&&(o.floorPriceCents=s.floorPriceCents),"dfp"===o.mediationLayerAdServer&&("SpotXJW"===l||d.indexOf("SpotXJW")>=0)&&o.bidders.forEach(function(e){e.winner="SpotX"===e.name})}return o}(t,a,this.breakMap[a]))},t.prototype.setBid=function(e,t,i){var r=ke(e,this.player.utils);this.breakMap[r]=this.breakMap[r]||{},this.breakMap[r].bid=t,this.breakMap[r].bidders=i},t.prototype.adEventObject=function(t){var i={client:e,tag:this.getTag(t),ima:{ad:t,userRequestContext:this.userRequestContext}};return t?(i.adtitle=t.getTitle(),i.adsystem=t.getAdSystem(),i.creativetype=t.getContentType(),i.linear=t.isLinear()?"linear":"nonlinear",i.viewable=this.player.getViewable(),Object.assign(i,this.adPodEventObject(t)),i):i},t.prototype.adErrorEventObject=function(t,i){var r=t.getMessage&&t.getMessage()||t.message,a=t.getVastErrorCode&&t.getVastErrorCode()||900,n=t.getErrorCode&&t.getErrorCode()||900;n<1e4&&(n+=2e4);var o=i.getAd&&i.getAd(),s=this.getTag(o,i);return Object.assign({client:e,message:"Ad Error: "+r,code:a,adErrorCode:n,tag:s},this.adPodEventObject(o))},t}();!function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}}(".jwplayer.jw-flag-ads-googleima.jw-flag-small-player.jw-flag-ads.jw-state-playing.jw-flag-touch:not(.jw-flag-ads-vpaid) .jw-controls .jw-controlbar,.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-display-icon-display,.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-display-icon-display .jw-icon-display{pointer-events:none}.jwplayer.jw-flag-ads-googleima.jw-flag-touch .jw-controlbar{font-size:1em}.jwplayer.jw-flag-ads-googleima .jw-controlbar{background:0 0!important;pointer-events:none}.jwplayer.jw-flag-ads-googleima .jw-controls-backdrop{display:none}.jwplayer.jw-flag-ads-googleima.jw-ie .jw-slider-volume,.jwplayer.jw-flag-ads-googleima.jw-ie .jw-svg-icon{background:rgba(0,0,0,.25);border-radius:3px}.jwplayer.jw-flag-ads-googleima.jw-ie .jw-slider-volume{margin:0 10px}@supports (filter:drop-shadow(0 0 3px #000)){.jwplayer.jw-flag-ads-googleima.jw-ie .jw-slider-volume,.jwplayer.jw-flag-ads-googleima.jw-ie .jw-svg-icon{background:0 0;border-radius:0}.jwplayer.jw-flag-ads-googleima.jw-ie .jw-slider-volume{margin:0}}.jwplayer.jw-flag-ads-googleima .jw-svg-icon{fill:#fff;filter:drop-shadow(0 0 3px #000)}.jwplayer.jw-flag-ads-googleima .jw-spacer,.jwplayer.jw-flag-ads-googleima .jw-text{order:1}.jwplayer.jw-flag-ads-googleima .jw-text{text-shadow:0 0 3px #000}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-controlbar{flex-flow:column-reverse nowrap;height:100%;max-height:none}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-button-container{align-items:flex-end;flex-wrap:wrap;margin-bottom:7px}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-controlbar .jw-icon{height:30px}.jwplayer.jw-flag-ads-googleima.jw-flag-small-player .jw-text{align-self:flex-start;margin:16px 0 0 16px;order:-1;width:100%}");(window.jwplayerPluginJsonp||window.jwplayer().registerPlugin)(e,"8.1",function(n,o,s){var d=this,l=this,u=n.utils,h=n.getConfig(),m=new L(o||{},u),y=null,v=void 0,b=0;if(m.premiumAds){if(n.getMute()||h.autostart)return console.log("Premium Ads: Cannot play ads in autostart or muted"),void(this.destroy&&this.destroy());if(function(){var e=(window.performance||{}).timing;if(e){var t=e.loadEventEnd||(new Date).getTime(),i=t-e.navigationStart;if(i>0)return i}return f}()>=f)return console.log("Premium Ads: Page load took too long to start an ad"),void(this.destroy&&this.destroy())}S(u).then(function(){if(v){var e=I();e>=0&&e-v>=f&&(console.log("Premium Ads: IMA SDK load took too long to start an ad"),d.destroy&&d.destroy())}}).catch(u.noop);var w=n._,A=h.key;u.addClass(s,"jw-plugin-googima");var P=new j(s,n.id,u.style),E=new B(u,n.Events,P),C=new Te(n,P.getAdDiv()),M=null;this.version="8.5.0",this.bidsVersion="0.0.37",n.utils.extend(this,n.Events);function _(e,t,i,r){try{return e.getCompanionAds(t,i,r)}catch(e){return[]}}function k(e){var t=new google.ima.CompanionAdSelectionSettings;t.sizeCriteria=google.ima.CompanionAdSelectionSettings.SizeCriteria.IGNORE;var i=m.companiondiv||{width:300,height:250},r=function(e){for(var t=[],i=0;i0}function T(){M&&!M.destroyed()&&(n.off(null,null,M),M.destroy(),M=null)}function R(e){M&&M.discardAdBreak(),C.contentComplete(),T(),e&&e.adschedule?m.adschedule=e.adschedule:m.adschedule=null,n.setCues([])}function x(e,t,a){var o=e.item||{};R(o);var s=a.getSchedule();if(t===i&&!function(){var e=m.getAdRules(),t=0===e.frequency&&1===b,i=b>=e.startOn&&(b-e.startOn)%e.frequency==0;return t||i}()||!s||"string"!=typeof s&&!Object.keys(s).length)return m.adschedule=null,void S(u).then(function(){C.prepare(y)}).catch(u.noop);if(C.reset(),(M=new _e(o,m,n,E,P,C,y)).on("all",function(e,t){return n.trigger(e,t)}),M.init(t,a).then(function(e){n.trigger("adsManager",{adsManager:e,videoElement:y})}),M.on(g,function(e){k(e.ima.ad)}),a.preloadAds){var d=n.getConfig().autostart;!1===d||d===r&&0===n.getViewable()?M.requestAds(t,a):n.once("autostartNotAllowed",function(){M.requestAds(t,a)},M)}n.once("beforePlay",function(e){if(m.premiumAds){var i=n.getHeight(),r=n.getWidth();if(i<270||r<480)return console.log("Premium Ads: Player size is smaller than 480x270 to play an ad"),void l.destroy();I()<0&&(v=Date.now())}M.beforePlay(e),M.requestAds(t,a)},M).on("beforeComplete",function(){return M.beforeComplete()},M).on("time",function(e){return M.time(e)},M).on("resize",function(){return M.resize()},M).on("fullscreen",function(){return M.resize()},M)}n.pauseAd=function(e){M&&(e?M.pause():M.resume())},n.playAd=function(e){var i=u.extend({},o);delete i.ad,delete i.tag,delete i.schedule,delete i.adschedule,n._.isArray(e)?i.tag=e[0]:i.tag=e;var r=new L(i,u),a=M?M.blockingInstreamPlayer:null;a&&(a.noResume=!0),x({},t,r),M&&(M.beforePlay(null),M.requestAds(t,r))},n.on("ready",function(){y||(y=n.createInstream().getMediaElement()),S().catch(function(e){e.message.match(/Failed to load/)&&q("Ad playback blocked by an ad blocker",2e4)}),O.catch(function(e){q("Ad Error: "+e.message,60002)});var e=document.body,t=function(){e.removeEventListener("mouseup",t),e.removeEventListener("touchend",t),C.initializeDisplay()};e.addEventListener("mouseup",t,!1),e.addEventListener("touchend",t,!1)},this).on("playlistItem",function(e){b++,m.resetBidsResponse(),x(e,i,m)},this).on("playlistComplete",function(){R()},this).on("cast",function(e){e.active&&R()},this).on("mute",function(e){var t=e.mute;E.mute(t)}).on("destroyPlugin",function(){d.destroy()},this);var O=D.call(this,u,A);O.catch(u.noop);var q=function(t,i){T(),n.off(null,null,d),n.playAd=u.noop,n.trigger(c,{id:a,client:e,message:t,code:900,adErrorCode:i,tag:""})};this.destroy=T,this.adsDebugMode=function(){m.debug=!0,M&&(M.debugConsoleLog=function(){var e;(e=console).log.apply(e,arguments)})}})}();