!function(){var e="googima",t="TYPE_API",i="TYPE_SCHEDULE",r="viewable",n="-1",a="jw-flag-ads-googleima",o="jw-flag-ads-vpaid",s="jw-flag-ads-vpaid-controls",d="playing",l="adBreakStart",u="adBreakEnd",c="adCompanions",p="adError",g="adStarted",h="viewable",f=2e3,m=4096,v=1e3;function y(e,t,i){if(!e)return e;for(var r=t.getPlaylistItem(),n=t.getConfig(),a=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()||n.height).replace("__player-width__",t.getWidth()||n.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=(a=i.companiondiv&&i.companiondiv.id?a.replace("__companion-div__",i.companiondiv.id):a.replace("__companion-div__","")).match(new RegExp(/__item-[a-z 0-9 A-Z]*__/g)),s=0;o&&sc&&(u=u.substring(0,c)),a=a.replace(d,encodeURIComponent(u))}else a=a.replace(d,"")}if(r.title&&-1===a.indexOf("vid_t=")){var p=r.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");a+=(g=a,(-1!==g.indexOf("?")?"&":"?")+"vid_t="+encodeURIComponent(p))}var g;return a}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,n=Math.floor(t/6e4)%60,a=Math.floor(t/36e5)%24;return(a=a<10?"0"+a:a)+":"+(n=n<10?"0"+n:n)+":"+(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?"&":"?",n=e.indexOf("cust_params="),a="cust_params=".length,o="",s="";if(t.foreach(i,function(e,t){o=""+o+s+e+"="+t,s="&"}),o=encodeURIComponent(o),n>=0){var d=e.substr(0,n+a),l=e.substr(n+a);return""+d+o+"%26"+l}return""+e+r+"cust_params="+o}function E(e,t,i){var r={};return t.foreach(e,function(e,n){var a={},o=n.ad||n;a.offset=A(o.offset||o.position||n.offset||"",t,i),a.tag=P(o.tag,t,o.custParams),a.type=o.type||n.type||"linear,nonlinear",r[e]=a}),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,n='',a=[],o=[],s=[];return r.foreach(E(e,r,i._),function(e,r){var d=r.offset.replace("pre","start").replace("post","end"),l=n.replace(/_type_/g,r.type).replace(/_adbreakname_/g,e).replace(/_offset_/g,d).replace(/_url_/g,y(r.tag,i,t.options,r.custParams));"start"===d?a.push(l):"end"===d?s.push(l):o.push(l)}),''+a.join("")+o.join("")+s.join("")+""},e.prototype.getTagMap=function(e){var t=this,i=this.player,r=i.utils,n={};return r.foreach(E(e,r,i._),function(e,a){var o=w(a.offset,r);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),i._.isNumber(o)&&(n[o]={tag:y(a.tag,i,t.options)})}),n},e.prototype.getTagList=function(e){var t=this,i=this.player,r=i.utils,n=[];return r.foreach(E(e,r,i._),function(e,a){var o=w(a.offset,r);i._.isString(o)&&(o=parseFloat(o.replace("pre","0").replace("post","-1"))),n.push({offset:o,tag:y(a.tag,i,t.options)})}),n},e}(),M={autoplayadsmuted:!1,companiondiv:null,companionResourceType:"",debug:!1,enablePreloading:!1,loadVideoTimeout:15e3,locale:"",maxRedirects:-1,preloadAds:!1,premiumAds:!1,requestTimeout:1e4,truncateMacros:!0,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 n=t[r],a=M[r],o=typeof a;if(void 0!==n){if("boolean"!==o&&"number"!==o||(n=_(n)),typeof n!==o)throw new Error("invalid parameter: "+r+" should be a "+o);this[r]=n}else this[r]=a}}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],n=e.bidsResponse[i];return r&&n&&(t[i]=Object.assign({},r,{tag:n.tag,custParams:Object.assign({},r.custParams,n.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.prototype.setLocalizationOptions=function(e){var t=e.admessage,i=e.cuetext,r=e.podmessage,n=e.loadingAd;this.admessage=t,this.cuetext=i,this.podmessage=r,this.loadingAd=n},e}(),j=function(){function e(t,i,r){b(this,e);var n=document.createElement("div");this.visible=!1,this.style=r,this.div=t,this.adDiv=n,n.id=i+"_ad",r(t,{overflow:"hidden",width:"100%",height:"100%",display:"block",visibility:"hidden",pointerEvents:"none",opacity:0}),r(n,{position:"absolute",width:"100%",height:"100%"}),t.appendChild(n)}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=0})[0];return t?t.code:pe}(n[0])};var a=i.bids;if(!a||!a[r]||!a[r][0])return{result:oe,code:se};var o=a[r][0],s=o.bid_price_cents,d=o.bid_id;if(t.mediationLayerAdServer===H)return{result:re,code:de,tag:t.tag,custParams:{jwFANBidPrice:Math.round(s/100),jwFANBidID:d}};var l={result:re,code:de,priceInCents:s,priceCurrency:o.bid_price_currency};s>=t.floorPriceCents&&(l.tag=(u=r,c=d,p=t.playerWidth,g=t.playerHeight,["https://an.facebook.com/v1/instream/vast.xml?placementid="+u,"&playerwidth="+p,"&playerheight="+g,"&SDK[]="+z,"&bidid="+c,"&pageurl="+me].join("")));var u,c,p,g;return l}).catch(function(e){return{result:ne,code:ue,message:"FAN header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var ye=null;function be(){return null===ye&&(ye=Promise.resolve(window.apstag).then(function(e){if(e&&e.init&&e.fetchBids)return e;return fe(["file"===document.location.protocol?"https:":"",V].join(""),q).then(function(){return window.apstag})}).catch(function(e){throw ye=null,e})),ye}var we={requestBids:function(e,t){if(!e.id||!e.slotID)return Promise.resolve({result:ae,code:le});return be().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:re,code:de,tag:t.tag,custParams:{amznbid:i[0].amznbid,amzniid:i[0].amzniid}}:{result:oe,code:se}}).catch(function(e){return{result:ne,code:ue,message:"Amazon header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var Ae=null,Pe=null;function Ee(e){if(null===Pe){var t=he(),i=Ae||window.SpotX;if(i&&i.DirectAdOS)return Pe=Promise.resolve({SpotX:i,loadingTime:0});var r=["file"===document.location.protocol?"https:":"",J,e,".js"].join("");(Pe="function"==typeof require?(n=r,a=q,new Promise(function(e,t){setTimeout(t,a),require([n],e,t)}).catch(function(){return Promise.reject({message:ie})})).then(function(e){return{SpotX:Ae=e,loadingTime:he()-t}}).catch(function(){return Ce(r,t)}):Ce(r,t)).catch(function(){Pe=null})}var n,a;return Pe}function Ce(e,t){return fe(e,q).then(function(){return{SpotX:window.SpotX,loadingTime:he()-t}})}var Me=void 0,_e={requestBids:function(e,t){if(!e.id)return Promise.resolve({result:ae,code:302});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 Ee(e.id).then(function(e){var t=e.SpotX,r=e.loadingTime;Me=r;var n=new t.DirectAdOS(i),a=he();return n.getAdServerKVPs().then(function(e){return{response:e,bidNetworkStartTime:a}})}).then(function(e){var i=e.response,r=e.bidNetworkStartTime,n=he()-r,a=i.spotx_ad_key,o={spotx_bid:i.spotx_bid,spotx_ad_key:a},s=100*parseFloat(i.spotx_bid),d={result:re,code:de,priceInCents:s,custParams:o,scriptLoadingTime:Me,bidNetworkResponseTime:n};if(t.mediationLayerAdServer===H)return d;var l=["file:"===document.location.protocol?"https:":"",F,a].join("");return Object.assign(d,{tag:l,tagKey:a})}).catch(function(e){var t=ce.filter(function(t){return t.message===e.message})[0];return t?{result:t.result||ae,code:t.code,scriptLoadingTime:Me}:{result:ne,message:"SpotX header bidding failed: "+e,code:ue,scriptLoadingTime:Me}})},getCustomResponse:function(){return{scriptLoadingTime:Me}}};var Le=null;function je(e){return null===Le&&(Le=Promise.resolve(window.indexapi).then(function(t){if(t)return t;return fe(["file"===document.location.protocol?"https:":"",e||G].join(""),q).then(function(){return window.indexapi})}).catch(function(e){throw Le=null,e})),Le}var Ie={requestBids:function(e,t){if(!e.id&&!e.script)return Promise.resolve({result:ae,code:le});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 je().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:re,code:de,tag:t.tag,custParams:i}:{result:oe,code:se}}).catch(function(e){return{result:ne,code:ue,message:"Index Exchange header bidding failed: "+e}})},getCustomResponse:function(){return{}}};var Te,Se=(Te={},Te[[Y]]=we,Te[["FAN"]]=ve,Te[[Z]]=Ie,Te[[ee]]=_e,Te);var ke=function(){function e(){var t=this,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=i.settings,n=void 0===r?{}:r,a=i.bidders,o=void 0===a?[]:a,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=$),i.mediationLayerAdServer===K&&(i.floorPriceCents=N),i}(n,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[Y]&&this.bidders[Y].id&&this.bidders[Y].slotID&&be(),this.bidders[Z]&&(this.bidders[Z].script||this.bidders[Z].id)&&je(this.bidders[Z].script),this.bidders[ee]&&this.bidders[ee].id&&Ee(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,n=te[i.mediationLayerAdServer].filter(function(e){return t[e]}).map(function(e){var n=he();return Promise.race([Se[e].requestBids(t[e],i,r),r]).then(function(i){var r=Se[e].getCustomResponse();return Object.assign({},t[e],i,r,{timeForBidResponse:he()-n|0})})});return Promise.all(n).then(function(e){var t=i.mediationLayerAdServer===H||i.mediationLayerAdServer===Q,r=i.mediationLayerAdServer===X||i.mediationLayerAdServer===Q||i.mediationLayerAdServer===K,n={priceInCents:i.floorPriceCents,timeForBidResponse:1/0},a=[],o={},s={};return s.bidders=e.map(function(e){return t||(e.winner=!1),e.result===re&&(a.push(e),Object.assign(o,e.custParams),r&&(e.priceInCents>n.priceInCents||e.priceInCents===n&&e.timeForBidResponse4&&void 0!==arguments[4]?arguments[4]:null;return{type:t,client:e,adBreakId:r,adPlayId:n,adposition:null!==a?a: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 xe=function(){function t(e,i,r,n,a,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=n,this.view=a,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 n=this,a=this.utils.extend({},t.config.bids),o=i.offset,s=new ke(a,{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,a.bidders,{offset:o,adBreakId:d,adPlayId:l})),s.then(function(i){if(n.trigger("adBidResponse",s.getEventObject(e,i.bidders,{offset:o,adBreakId:d,adPlayId:l})),n.destroyed())return null;n.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 n=t.getSchedule();if("string"==typeof n)this.startBid(t,{tag:n,offset:"pre"});else{var a=parseInt(r.bidOnBreaks);a=a>0?a:1/0,Object.keys(n).slice(0,a).forEach(function(e){i.startBid(t,n[e],e)})}}var o=this.adsLoaderManager;return this.initAdsManagerPromise=k().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 n=r.getCuePoints();if(!t.preloadAds||-1===n.indexOf(0)){var a=i.player.getSafeRegion(!1),s=a.width,d=a.height,l=i.getViewMode();i.debugConsoleLog("[JW DEBUG] adsManager init with",s,d,l),o.init(s,d,l)}if(n.length){var u=n.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.options.loadingAd;this.blockingInstreamPlayer.setText(t)}else clearTimeout(this.timeoutAdStart),this.startBlocking(e),this.muteInstreamProvider()},t.prototype.requestAds=function(e,t){var i=this,r=this.bids.concat(k());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)){var e=this.player.getContainer();e.requestFullscreen||e.webkitRequestFullscreen||(this.debugConsoleLog("[JW DEBUG] Exiting fullscreen mode on iOS 10 or 11"),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(),a),this.blockingInstreamPlayer=this.player.createInstream().init();var i=e?"":this.options.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(p,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,a]),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,Re(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,Re(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&&(0===e.getCuePoints().length?this.destroy():(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),n=r.width,a=r.height,o=t.getViewMode();t.debugConsoleLog("[JW DEBUG] adsManager init with",n,a,o),i.init(n,a,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 n=e.getHeight();n=this.player.getFullscreen()?r.height/2:Math.max(100,n+10),this.debugConsoleLog("[JW DEBUG] Resize adsManager",r.width,n,this.getViewMode()),t.resize(r.width,n,this.getViewMode()),this.view.resizeNonLinear(r,n)}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 n=this.adsLoaderManager.adEventObject(e);n.oldstate=r,n.newstate=i,this.trigger(t,n)}},t.prototype.progressInterval=function(e,t){var i=this;if(clearInterval(this.progressIntervalId),t){var r=e.getAdId(),n=-1,a=this.options.admessage||"",o=this.options.podmessage||"",s=new RegExp("__AD_POD_CURRENT__","g"),d=new RegExp("__AD_POD_LENGTH__","g");this.progressIntervalId=setInterval(function(){if(i.currentAd&&i.currentAd.getAdId()===r){var e=t.getRemainingTime();if(!(isNaN(e)||e<=0)&&n!==e){n=e;var l=i.currentAd.getDuration(),u=l-e,c=Math.round(l-u);if(i.blockingInstreamPlayer){var p=a.replace(/(\b)xx(s?\b)/g,"$1"+c+"$2"),g=i.currentAd.getAdPodInfo(),h=g.getTotalAds();if(h>1){var f=g.getAdPosition();p=o.replace(s,f).replace(d,h)+" "+p}i.blockingInstreamPlayer.setText(p),i.instreamProvider.trigger("time",{duration:l,position:u})}if(l>0){var m=i.adsLoaderManager.adEventObject(i.currentAd);m.position=u,m.duration=l,i.trigger("adTime",m)}}}else clearInterval(i.progressIntervalId)},250)}},t.prototype.adLoaded=function(e){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(),n=r&&(i.getContentType().indexOf("image")>=0||-1===i.getDuration()),a=i.getContentType(),l="application/javascript"===a||"application/x-shockwave-flash"===a,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(0===t.adsLoaderManager.adsManager.getVolume())}}),n?this.startBlocking():r||this.stopBlocking(),this.player.utils.toggleClass(this.player.getContainer(),o,r&&(n||l)),this.player.utils.toggleClass(this.player.getContainer(),s,u),this.view.adSetup(),this.resize(),this.muteInstreamProvider(),clearTimeout(this.timeoutAdStart);var c=this.adsLoaderManager.adsManager;this.progressInterval(i,c);var p=this.adsLoaderManager.adEventObject(i);"pre"!==p.adposition||void 0!==p.podcount&&1!==p.sequence||(this._qoe.tick("adImpression"),p.timeLoading=this._qoe.between("adBeforePlay","adImpression")),this.trigger("adImpression",p),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 n=this.adsLoaderManager.adEventObject(i);this.trigger("adClick",n),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(p,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 n=this.adsLoaderManager.adErrorEventObject(e,t);this.player&&0===this.player.getPosition()&&(this._qoe.tick("adError"),n.timeLoading=this._qoe.between("adBeforePlay","adError")),this.trigger(p,n)},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 De(e){return new Array(e+1).join((Math.random().toString(36)+"00000000000000000").slice(2,18)).slice(0,e)}function Be(e){try{return e.getAdPodInfo()}catch(e){return null}}function Oe(e,t){var i=w(e,t);return"pre"===i?0:"post"===i?-1:i}var qe=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);var n=t.locale||this.player.getConfig().language;r.setLocale(n),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 n=this.adsRequest=new google.ima.AdsRequest,a=this.userRequestContext={requestType:e,vpaidMode:t.vpaidmode,playerVersion:this.player.version.split("+")[0]};n.setAdWillAutoPlay(!1!==this.player.getConfig().autostart),n.setAdWillPlayMuted(this.player.getMute());var o=this.player.getSafeRegion(!1);n.linearAdSlotWidth=o.width,n.linearAdSlotHeight=o.height;var s=this.player.getSafeRegion(!0);n.nonLinearAdSlotWidth=s.width,n.nonLinearAdSlotHeight=s.height,n.forceNonLinearFullSlot=i.forceNonLinearFullSlot,n.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=n.adTagUrl=a.adTagUrl=y(r,this.player,i):n.adsResponse=a.adsResponse=d.getAdsResponse(r),this.schedule=r,this.breakMap=Object.assign(d.getTagMap(r),this.breakMap);var u=this.adsLoader.getSettings(),c=this.getVpaidMode(a.vpaidMode);u.setPlayerType("jwplayer"),u.setPlayerVersion(a.playerVersion),u.setVpaidMode(c),this.adsLoader.requestAds(n,a)}}},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(n){var a=i[n]||r[n],o=t.adsManagerEvents[a];o&&t.adsManager.removeEventListener(a,o),t.adsManager.addEventListener(a,e[n],!1),t.adsManagerEvents[a]=e[n]})},t.prototype.unbindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,r=google.ima.AdErrorEvent.Type;e.forEach(function(e){var n=i[e]||r[e],a=t.adsManagerEvents[n];a&&(t.adsManager.removeEventListener(n,a),delete t.adsManagerEvents[n])})},t.prototype.getTag=function(e,t){if("string"==typeof this.schedule)return this.schedule;var i=Be(e);if(i){var r=this.breakMap[i.getTimeOffset()]||{};if(r.tag)return r.tag}var n=this.userRequestContext;return t&&t.getUserRequestContext&&(n=t.getUserRequestContext()||n),n?n.adTagUrl||n.adsResponse||"":(console.error("invalid request context",n),"")},t.prototype.getAdBreakId=function(e){var t=Oe(e,this.player.utils);return this.breakMap[t]=this.breakMap[t]||{},this.breakMap[t].adBreakId=this.breakMap[t].adBreakId||De(12),this.breakMap[t].adBreakId},t.prototype.getAdPlayId=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=Oe(e,this.player.utils);return this.breakMap[i].adPlayId=this.breakMap[i].adPlayId||{1:De(12)},this.breakMap[i].adPlayId[t]=this.breakMap[i].adPlayId[t]||De(12),this.breakMap[i].adPlayId[t]},t.prototype.getLastAdPlayId=function(e){var t=Be(e);if(!t)return n;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 n=r-e;n>=0&&n1&&(r.sequence=a,r.podcount=o);var s="mid";0===(n=i.getTimeOffset())?s="pre":-1===n&&(s="post"),r.adposition=s}else n=this.getTimeoffsetFromPosition_();return r.id=r.adBreakId=this.getAdBreakId(n),r.adPlayId=this.getAdPlayId(n,a),Object.assign(r,function(t,i,r){var n=r.bidders,a=r.bid,o={};if(!n)return o;if(a&&n.length){var s=a.getEventObject(e,n,{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,n,this.breakMap[n]))},t.prototype.setBid=function(e,t,i){var r=Oe(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,n=t.getVastErrorCode&&t.getVastErrorCode()||900,a=t.getErrorCode&&t.getErrorCode()||900;a<1e4&&(a+=2e4);var o=i.getAd&&i.getAd(),s=this.getTag(o,i);return Object.assign({client:e,message:"Ad Error: "+r,code:n,adErrorCode:a,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-controlbar .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-controlbar .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(a,o,s){var d=this,l=this,u=a.utils,h=a.getConfig(),m=new L(o||{},u),v=null,y=void 0,b=0;if(m.premiumAds){if(a.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())}k(u).then(function(){if(y){var e=S();e>=0&&e-y>=f&&(console.log("Premium Ads: IMA SDK load took too long to start an ad"),d.destroy&&d.destroy())}}).catch(u.noop);var w=a._,A=h.key;u.addClass(s,"jw-plugin-googima");var P=new j(s,a.id,u.style),E=new B(u,a.Events,P),C=new qe(a,P.getAdDiv()),M=null;this.version="8.5.6",this.bidsVersion="0.1.6",a.utils.extend(this,a.Events);function _(e,t,i,r){try{return e.getCompanionAds(t,i,r)}catch(e){return[]}}function I(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()&&(a.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,a.setCues([])}function D(e,t,n){var o=e.item||{};R(o);var s=n.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 k(u).then(function(){C.prepare(v)}).catch(u.noop);if(C.reset(),(M=new xe(o,m,a,E,P,C,v)).on("all",function(e,t){return a.trigger(e,t)}),M.init(t,n).then(function(e){a.trigger("adsManager",{adsManager:e,videoElement:v})}).catch(u.noop),M.on(g,function(e){I(e.ima.ad)}),n.preloadAds){var d=a.getConfig().autostart;!1===d||d===r&&0===a.getViewable()?M.requestAds(t,n):a.once("autostartNotAllowed",function(){M.requestAds(t,n)},M)}a.once("beforePlay",function(e){if(m.premiumAds){var i=a.getHeight(),r=a.getWidth();if(i<270||r<480)return console.log("Premium Ads: Player size is smaller than 480x270 to play an ad"),void l.destroy();S()<0&&(y=Date.now())}M.beforePlay(e),M.requestAds(t,n)},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)}a.pauseAd=function(e){M&&(e?M.pause():M.resume())},a.playAd=function(e){var i=u.extend({},o);delete i.ad,delete i.tag,delete i.schedule,delete i.adschedule,a._.isArray(e)?i.tag=e[0]:i.tag=e;var r=new L(i,u);r.setLocalizationOptions(h.localization.advertising);var n=M?M.blockingInstreamPlayer:null;n&&(n.noResume=!0),D({},t,r),M&&(M.beforePlay(null),M.requestAds(t,r))},a.on("ready",function(){h.localization=a.getConfig().localization,m.setLocalizationOptions(h.localization.advertising),v||(v=a.createInstream().getMediaElement()),k().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(),D(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=x.call(this,u,A);O.catch(u.noop);var q=function(t,i){T(),a.off(null,null,d),a.playAd=u.noop,a.trigger(p,{id:n,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)})}})}();