!function(){var K="vast",Y="-1",e="time",d="[ERRORCODE]",I="vmap",Z=5e3,tt=15e3,et="jwp",it="jwpspotx",n="state",rt="autostartNotAllowed",nt="viewable",at=5,l="paused",st="playing",ot="adPodError",i="viewable",dt="adBidRequest",lt="adBidResponse",ut="adBreakEnd",a="adBreakIgnored",ht="adBreakStart",r="adClick",pt="adComplete",ct="adError",ft="adImpression",mt="adLoaded",u="adMeta",o="adPause",h="adPlay",vt="adRequest",yt="adSchedule",p="adSkipped",t="adStarted",s="click",c="play",f="error",m="complete",v=[ft,ct,ot],y=[t,pt,ft,r,p,ct,h,o,u],g=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},A=function(){function r(t,e){for(var i=0;i"),n.contentWindow.myCallback=r,a.close(),n}(t.utils,this.vpaidURL,this.playerContainer,this.callback.bind(this)),this.toRemove.push(this.iframe))}return s.prototype.sendEvent=function(t,e){(e=e||{}).tag||(e.tag=this.adTag),this.trigger(t,e)},s.prototype.sendTimeEvent=function(t,e,i){var r=e.getAdDuration(),n=e.getAdRemainingTime(),a=gt({duration:r},i);this.sendEvent(t,a),0this.lastQuartile&&this.lastQuartile<3;)this.lastQuartile++,1===this.lastQuartile?this.trackPings("firstQuartile"):2===this.lastQuartile?this.trackPings("midpoint"):3===this.lastQuartile&&this.trackPings("thirdQuartile");this.trackProgress(t,e)}},o.prototype.trackProgress=function(t,e){for(var i=this.progressEvents.length;i--;){var r=this.progressEvents[i];if(!r.tracked){var n=r.offset;r.percentage&&(n=e*n/100),n<=t&&(r.tracked=!0,this.trackPings(r.key))}}},o.prototype.error=function(){var t=0s[d.file].width)&&(d=t),e.width>=o.width&&(!l||e.widththis.adPodIndex&&(this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null),this.adPodIndex++,this.scheduledAd._adPodIndex=this.adPodIndex,this.playAd())},s.prototype.playVpaid=function(t){var e=this;clearTimeout(this.creativeTimeout),this.creativeTimeout=setTimeout(function(){e.creativeAdError("VPAID tag communication timeout",900,50004)},this.scheduledAd.creativeTimeout);var i=x(this.vastAd=t),r=this.optionalParams.conditionaladoptout&&t.conditionalAd;if(this.vastAd.selectedMedia=i,this.mediaType=i.type,"flash"===R(i))return this.creativeAdError("Flash creatives are not supported",403,10403),!1;var n={adParams:this.vastAd.adParams,vpaidControls:this.optionalParams.vpaidcontrols,adOptOut:r};return this.vpaidPlayer=new P(this.player,this.blockingInstreamPlayer,i.file,this.scheduledAd._currentTag,n),this.blockingInstreamPlayer&&this.blockingInstreamPlayer.applyProviderListeners(this.vpaidPlayer),this.vpaidPlayer.on("play",this.playHandler,this),this.vpaidPlayer.on("pause",this.pauseHandler,this),this.vpaidPlayer.on("quartile",this.quartileHandler,this),this.vpaidPlayer.on("remainingTimeChange",this.remainingTimeHandler,this),this.vpaidPlayer.on("click",this.clickVpaidHandler,this),this.vpaidPlayer.on("error",this.playbackErrorHandler,this),this.vpaidPlayer.on("impression",this.impressionHandler,this),this.vpaidPlayer.on("expandedChange",this.vpaidExpandedHandler,this),this.vpaidPlayer.on("close",this.adCloseHandler,this),this.vpaidPlayer.on("skipped",this.vpaidAdSkipped,this),this.vpaidPlayer.on("stopped",this.endOfVpaidAdHandler,this),this.vpaidPlayer.on("complete",this.adCompleteHandler,this),this.vpaidPlayer.on("started",this.adStartedHandler,this),this.setupSkipButton(t),!0},s.prototype.setupSkipButton=function(t){var e="skipoffset"in t?At.utils.seconds(t.skipoffset):-1,i=0<=this.optionalParams.skipoffset?this.optionalParams.skipoffset:e;0<=i&&this.blockingInstreamPlayer&&(this.blockingInstreamPlayer.off(p,this.skipVpaidAd,this),this.blockingInstreamPlayer.setupSkipButton(i,this.optionalParams,At.utils.noop),this.blockingInstreamPlayer.on(p,this.skipVpaidAd,this))},s.prototype.playInstream=function(t,e){var i=this,r=this.player.getEnvironment().OS;return r.android&&2===r.version.major&&3===r.version.minor?(this.adError("Android 2.3 not supported",900,60007),!1):(clearTimeout(this.creativeTimeout),this.creativeTimeout=setTimeout(function(){i.creativeAdError("VAST tag communication timeout",900,60004)},this.scheduledAd.creativeTimeout),this.blockingInstreamPlayer?this.instreamPlayer=this.blockingInstreamPlayer:this.instreamPlayer=this.player.createInstream().init(),this.instreamPlayer.on("play",this.playHandler,this),this.instreamPlayer.on("pause",this.pauseHandler,this),this.instreamPlayer.on("time",this.timeHandler,this),this.instreamPlayer.on("playlistItem",this.playlistItemHandler,this),this.instreamPlayer.on("complete",this.adCompleteHandler,this),this.instreamPlayer.on("playlistComplete",this.endOfAdBreakHandler,this),this.instreamPlayer.on("mute",this.muteHandler,this),this.instreamPlayer.on("instreamClick",this.clickInstreamHandler,this),this.instreamPlayer.on("adSkipped",this.adSkipped,this),this.instreamPlayer.on("error",this.playbackErrorHandler,this),this.instreamPlayer.on("mediaError",this.playbackErrorHandler,this),this.instreamPlayer.on("destroyed",function(){i.instreamPlayer=null},this),this.instreamPlayer.loadItem(t,e),this.clearBlocking(),!0)},s.prototype.playerFullscreenHandler=function(t){var e=this.getVastAd(this.adPodIndex).tracker;t.fullscreen&&e.started&&e.fullscreen()},s.prototype.playerResizeHandler=function(t){this.vpaidPlayer&&this.vpaidPlayer.resize(t.width,t.height)},s.prototype.playerVolumeHandler=function(t){this.vpaidPlayer&&this.vpaidPlayer.setVolume(t.volume)},s.prototype.playlistItemHandler=function(t){this.instreamPlayer&&(this.scheduledAd._adPodIndex=this.adPodIndex=t.index+this.initialIndex)},s.prototype.impressionHandler=function(t){var e=this.getVastAd(this.adPodIndex),i=e.tracker;i.impression();var r={};r.adposition=this.scheduledAd._position||"",r.adtitle=e.adTitle||"",r.creativeId=e.creativeId||"",b(e,r),r.vastversion=e.vastversion,r.clickThroughUrl=e.clickthrough,r.duration=e.duration||0,r.mediafile={file:e.selectedMedia.file},r.linear=t.linear||i.linear,this.addConditionalAdData(r),C(e,r),S(e,r),this.triggerEvent(ft,r),this.addViewableImpressionHandler()},s.prototype.addViewableImpressionHandler=function(){this.player.off(i,this.viewableHandler,this),this.player.on(i,this.viewableHandler,this),this.viewableHandler()},s.prototype.viewableHandler=function(t){var e=this;clearTimeout(this.viewableTimeout),this.viewableTimeout=null,(t?t.viewable:this.player.getViewable())&&(this.viewableTimeout=setTimeout(function(){e.player.off(i,e.viewableHandler,e),e.triggerEvent("adViewableImpression",{})},2e3))},s.prototype.playHandler=function(t){clearTimeout(this.creativeTimeout);var e,i,r=this.getVastAd(this.adPodIndex),n=r.tracker,a=void 0;if(n.started)t.oldstate===l&&(n.resume(),this.dispatchPlay(t));else{this.vpaidPlayer&&(n.linear=t.linear),this.instreamPlayer&&this.impressionHandler({linear:n.linear});var s=gt({linear:n.linear},this.getInstreamOptions(r));s.adMessage=this.optionalParams.dynamicMessage||"",s.clickThroughUrl=r.clickthrough,s.sequence&&(s.podMessage=this.optionalParams.podMessage||""),r.adTitle&&(s.adtitle=r.adTitle),r.companions&&(s.companions=r.companions),S(r,s),this.triggerEvent(u,s),r.companions&&((a={}).companions=(i=r.companions,At._.map(i,function(t){var e="iframe"===t.type||"html"===t.type?t.type:"static",i=void 0;return t.trackers&&t.trackers.creativeView&&t.trackers.creativeView.length&&(i=t.trackers.creativeView),{width:t.width,height:t.height,type:e,resource:t.source,creativeview:i,click:t.clickthrough}})),a.universalAdIdRegistry=r.companionUniversalAdIdRegistry,a.universalAdIdValue=r.companionUniversalAdIdValue,this.triggerEvent("adCompanions",a));var o=this.companion,d=void 0;9this.adPodIndex)return this.vpaidPlayer&&(this.vpaidPlayer.destroy(),this.vpaidPlayer=null),this.adPodIndex++,void this.playAd();this.endOfAdBreakHandler()},s.prototype.endOfAdBreakHandler=function(){this.removePlayerListeners(),this.trigger(pt)},s.prototype.muteHandler=function(t){var e=this.getVastAd(this.adPodIndex).tracker;e&&(t.mute?e.mute():e.unmute(),this.vpaidPlayer&&this.vpaidPlayer.setVolume(t.mute?0:this.player.getVolume()))},s.prototype.clickStaticHandler=function(){var t=this.getVastAd(this.adPodIndex);this.player.pause(!0),this.clickThrough(t)},s.prototype.clickVpaidHandler=function(t){var e=this.getVastAd(this.adPodIndex),i=!0;t&&void 0!==t.url&&(!1===t.playerHandles&&(i=!1),e.clickthrough=t.url),this.clickThrough(e,i)},s.prototype.clickInstreamHandler=function(){this.instreamPlayer.getState()!==l&&this.clickThrough(this.getVastAd(this.adPodIndex))},s.prototype.clickThrough=function(t){var e=!(1this.playedMidRolls.length){this.sort(i);for(var r=0;this.midRolls[r];){var n=z(this.midRolls[r]._offSet,i);if(t<=n&&-1===this.playedMidRolls.indexOf(r)){var a=Et()+1e3*(n-t);return n<=e&&this.adRules.timeBetweenAdsAllowsAdPlayback(null,a)?r:null}r+=1}}var s=Et()+1e3*(i-t);return this.postRoll&&i<=e&&this.adRules.timeBetweenAdsAllowsAdPlayback(null,s)?-1:null},e.prototype.getNextMidrollIndex=function(t,e,i){if(this.adRules.timeBetweenAds||this.adRules.startOnSeek)return this.getLastMidRollIndexBetweenTime(t,e,i);if(this.midRolls.length>this.playedMidRolls.length){var r=this.getClosestIndex(e,i);if(0<=r&&this.playedMidRolls.indexOf(r)<0)return this.playedMidRolls.push(r),r}return null},e.prototype.getMidRolls=function(){var e=this;return this.midRolls.map(function(t){return W(t,e.requestTimeout,e.creativeTimeout)})},e.prototype.reset=function(){null!==Q&&(X(Q),Q=null),this.playedMidRolls=[],this.duration=0},e.prototype.addMidRoll=function(t){this.midRolls.push(t),this.duration=0},e.prototype.setPostRoll=function(t){this.postRoll=t},e.prototype.sort=function(i,t){(!i||i<1)&&(i=1),(this.duration!==i||t)&&(this.duration=i,this.midRolls.sort(function(t,e){return z(t._offSet,i)-z(e._offSet,i)}),function(t,e){for(var i=0;i=z(this.midRolls[i]._offSet,e))return i;return-1},e}();function W(t,e,i){var r=void 0;if(At.utils.foreach(t,function(t,e){(r=r||{})[t]="_adQueue"===t?e.slice():e}),r)return r.requestTimeout=e,r.creativeTimeout=i,r._errors=[],r._waterfallIndex=0,r}function z(t,e){return"%"===t.toString().slice(-1)?e*parseFloat(t.slice(0,-1))/100:parseFloat(t)}var Ct=function(){function t(){g(this,t)}return t.prototype.getSchedule=function(t,e){var i=new It(e);if(i.requestTimeout=G(t.requestTimeout,Z),i.creativeTimeout=G(t.creativeTimeout,tt),t.tag)i.setPreRoll({_offSet:"pre",_adQueue:$(t.tag),_waterfallIndex:0});else if("string"==typeof t.vastxml)i.setPreRoll({_offSet:"pre",_adXML:t.vastxml});else{if("string"==typeof t.schedule)return i.setVMAP(t.schedule),i;if("string"==typeof t.adschedule)return i.setVMAP(t.adschedule),i;!function(u,h){var p=h.schedule||h.adschedule;if(!p)return;Object.keys(p).forEach(function(t){var e=p[t];e.ad&&(gt(e,e.ad),delete e.ad);var i=function(t){if("start"===t||"0%"===t||!t&&0!==t)return"pre";if("end"===t||"100%"===t)return"post";if("pre"===t||"post"===t||-1=p.floorPriceCents&&(h.tag=(o=c,d=s,l=p.playerWidth,u=p.playerHeight,["https://an.facebook.com/v1/instream/vast.xml?placementid="+o,"&playerwidth="+l,"&playerheight="+u,"&sdk="+jt,"&bidid="+d,"&pageurl="+ne].join(""))),h}).catch(function(t){return{result:Zt,message:"FAN header bidding failed: "+t}})},getCustomResponse:function(){return{}}};var se=null;function oe(){return null===se&&(se=Promise.resolve(window.apstag).then(function(t){return t&&t.init&&t.fetchBids?t:re(["file"===document.location.protocol?"https:":"",Ht].join(""),Lt).then(function(){return window.apstag})}).catch(function(t){throw se=null,t})),se}var de=null,le=null;function ue(t){if(null===le){var e=ie(),i=de||window.SpotX;if(i&&i.DirectAdOS)return le=Promise.resolve({SpotX:i,loadingTime:ie()-e});var r=["file"===document.location.protocol?"https:":"",Ft,t,".js"].join("");(le="function"==typeof require?(n=r,a=Lt,new Promise(function(t,e){setTimeout(e,a),require([n],t,e)}).catch(function(){return Promise.reject("Error loading script")})).then(function(t){return{SpotX:de=t,loadingTime:ie()-e}}):re(r,Lt).then(function(){return{SpotX:window.SpotX,loadingTime:ie()-e}})).catch(function(t){throw le=null,t})}var n,a;return le}var he=void 0,pe={requestBids:function(t,l){if(!t.id)return Promise.resolve({result:te,message:"Missing id in configuration"});var a=gt({channel_id:t.id,slot:l.playerContainer,content_width:l.playerWidth,content_height:l.playerHeight,player_vendor:"SpotXJW",player_vendor_id:l.playerId,ad_volume:l.adVolume,autoplay:l.autoplay,blocked_autoplay_override_mode:l.autoplayAdsMuted,start_delay:function(t){if("start"===t||"0%"===t||!t||"pre"===t||"00:00:00"===t)return 0;if("end"===t||"100%"===t||"post"===t)return-2;if("string"==typeof t&&0<=t.indexOf("%"))return-1;var e=parseInt(t);return 0r.priceInCents||t.priceInCents===r&&t.timeForBidResponse',ke.className="jw-vast-nonlinear-open-button",_e.className="jw-vast-nonlinear-close-button";var we={cursor:"pointer",position:"absolute",margin:"auto",left:0,right:0,bottom:0,display:"block"},Te="opacity 0.2s",be={"-webkit-transition":Te,transition:Te};function Ee(t,e){At.utils.style(t,{opacity:e||1})}function Ie(t){At.utils.style(t,{opacity:0})}function Ce(){Ee(_e)}function Se(){Ee(_e,.75)}function Re(){Ee(ke)}function xe(){Ee(ke,.5)}var Ve=function(){function a(t,e,i,r,n){g(this,a),this.player=t,this.environment=t.getEnvironment(),this.div=r,this.staticURL=e,this.clickURL=i,this.loadTimer=-1,this.animationTimer=-1,this.banner=null,gt(this,t.Events),this.banner=document.createElement("img"),this.banner.className="jw-banner",this.banner.id=this.player.id+"_vast_static",Ie([_e,ke]),this.remove(ke),this.div.appendChild(this.banner),this.div.appendChild(_e),this.loadTimer=setTimeout(this.imageLoadError.bind(this),n),this.banner.onerror=this.imageLoadError.bind(this),this.banner.onload=this.onLoaded.bind(this),this.banner.src=this.staticURL}return a.prototype.onLoaded=function(){clearTimeout(this.loadTimer),0!==this.banner.naturalWidth?(this.removeBannerEventListeners(),At.utils.style(_e,{top:-this.banner.height-8,bottom:this.banner.height-8,left:this.banner.width},!0),At.utils.style(ke,{top:-16},!0),Ee([this.div,this.banner]),Ee(_e,.75),new At.utils.UI(this.banner).on("click tap",this.sendClick.bind(this)),this.environment.OS.mobile&&(this.div.onmouseover=Ce,this.div.onmouseout=Se),_e.onclick=_e.ontouchstart=this.collapse.bind(this),ke.onclick=ke.ontouchstart=this.expand.bind(this),this.trigger(c)):this.imageLoadError()},a.prototype.imageLoadError=function(){clearTimeout(this.loadTimer),this.trigger(f),this.removeBanner()},a.prototype.sendClick=function(){this.trigger(s)},a.prototype.collapse=function(t){var e=this;-1===this.animationTimer&&(t.preventDefault(),this.div.onmouseover=this.div.onmouseout=null,Ie([this.banner,_e,ke]),this.div.appendChild(ke),this.animationTimer=setTimeout(function(){e.remove(e.banner),e.remove(_e),Ee(ke,.5),e.div.onmouseover=Re,e.div.onmouseout=xe,e.animationTimer=-1},250))},a.prototype.expand=function(t){var e=this;-1===this.animationTimer&&(t.preventDefault(),this.div.onmouseover=this.div.onmouseout=null,this.div.appendChild(this.banner),this.div.appendChild(_e),this.animationTimer=setTimeout(function(){Ee([e.banner,_e]),e.div.onmouseover=Ce,e.div.onmouseout=Se,e.animationTimer=-1},50),Ie(ke))},a.prototype.remove=function(t){this.div.contains(t)&&this.div.removeChild(t)},a.prototype.removeBannerEventListeners=function(){this.banner.onload=this.banner.onerror=null},a.prototype.removeBanner=function(){this.removeBannerEventListeners(),this.remove(this.banner)},a.prototype.removeListeners=function(){clearTimeout(this.loadTimer),clearTimeout(this.animationTimer),this.div.onmouseover=this.div.onmouseout=_e.onclick=ke.onclick=null,this.off(),this.removeBannerEventListeners()},a.prototype.stop=function(){Ie([this.div,this.banner,_e,ke]),setTimeout(this.removeBanner.bind(this),400),this.remove(_e),this.remove(ke)},a}(),Me=function(){function i(t,e){g(this,i),this.player=t,this.div=e,this.startTime=0,this.minDur=0,this.environment=t.getEnvironment(),gt(this,t.Events),this.type="static",t.on("time",this.dispatchTime,this)}return i.prototype.playAd=function(t,e,i,r,n){this.minDur=At.utils.seconds(i),this.adTag=r,this.static&&(this.static.removeListeners(),this.static.stop()),this.div.style.opacity=0,this.div.style.visibility="visible";var a=this.environment.Browser.firefox?{}:be;At.utils.style(this.div,At.utils.extend({top:"",position:"absolute",width:"100%"},a)),At.utils.style([_e,ke],gt({width:"18px",height:"18px",opacity:.75},we,a)),At.utils.style(_e,{transform:"rotate(45deg)"}),this.static=new Ve(this.player,t,e,this.div,n),this.static.on(c,this.startAd,this),this.static.on(s,this.clickHandler,this),this.static.on(f,this.errorHandler,this)},i.prototype.dispatchTime=function(t){this.trigger(e,t)},i.prototype.startAd=function(){this.startTime=this.player.getPosition(),0this.minDur&&(this.off(e,this.timeAd,this),this.stop())},i.prototype.clickHandler=function(){this.sendEvent(s)},i.prototype.errorHandler=function(){this.sendEvent(f)},i.prototype.sendEvent=function(t,e){(e=e||{}).tag=e.tag||this.adTag,this.trigger(t,e)},i.prototype.removeEvents=function(){this.off()},i.prototype.getState=function(){return st},i.prototype.stop=function(){this.startTime&&this.static&&(this.startTime=0,this.minDur=0,this.off(e,this.startTimingAd,this),this.off(e,this.timeAd,this),this.static.removeListeners(),this.static.stop(),this.sendEvent(m))},i.prototype.pause=function(){},i}(),Le=function(){function i(t,e){g(this,i),this.player=t,this.options=e,this.ignoreStartOnSeek=!1,this.reset(),e.timeBetweenAds&&t.on({adBreakStart:this.handleAdBreakStart,adSkipped:this.handleAdSkipped,adComplete:this.handleAdComplete,adBreakEnd:this.handleAdBreakEnd,destroyPlugin:this.destroy},this)}return i.prototype.clearStartOnSeek=function(){this.ignoreStartOnSeek=!0},i.prototype.sendAdBreakIgnored=function(t,e){var i,r;t&&this.player.trigger(a,(r=e,{id:(i=t)._breakId,tag:i._adQueue&&0=e.startOn&&(t-e.startOn)%e.frequency==0;return i||r},i.prototype.handleAdBreakStart=function(){this.adSkipped=!1,this.adComplete=!1},i.prototype.handleAdComplete=function(){this.adComplete=!0},i.prototype.handleAdSkipped=function(){this.adSkipped=!0},i.prototype.handleAdBreakEnd=function(){!this.adSkipped&&this.adComplete&&(this.recentCompletedAdTime=Et())},i.prototype.timeBetweenAdsAllowsAdPlayback=function(t){var e=1t.duration){var o=d.getPlaylistItem(d.getPlaylistIndex()+1);I=!o,(o||C)&&((E=D(o||C,w+1)).loadPreRoll({adBlock:b,preload:!0}).catch(u.noop),C=null)}}}},beforeComplete:function(){if(!g){var t=v.schedule.getPostRoll();if(t){"nonlinear"!==t._type&&(H(),O(t));var e=v;e.loadPostRoll({adBlock:b}).then(function(t){return e.isDestroyed()?null:q(t)}).catch(function(t){return e.isDestroyed()?null:z(t)})}}},playlistItem:function(t){w+=1,j();var e,i,r,n=d.getPlaylistItem(t.index);if(E&&n!==E.item&&!1===I&&(E.off(null,null,p),E.destroy(),E=null),v=E||D(n,w),E=null,e=v.schedule,i=e.getMidRolls(),r=[],i.length&&u.foreach(i,function(t,e){"nonlinear"!==e._type&&r.push({begin:e._offSet,text:f.cuetext})}),d.setCues(r),l.preloadAds&&1===w){var a=s.autostart;!1===a||a===nt&&0===d.getViewable()?v.loadPreRoll({adBlock:b,preload:!0}).catch(u.noop):d.once(rt,function(){v.loadPreRoll({adBlock:b,preload:!0}).catch(u.noop)})}},playlistComplete:j,complete:function(){U(),m=!1},destroyPlugin:j},this),d.pauseAd=function(t){if(t="boolean"!=typeof t||t,y.length){var e=y[y.length-1];t?e.pause():e.play()}},d.playAd=function(t){U();var e=void 0,i=0===f.requestTimeout?1/0:f.requestTimeout,r=0===f.creativeTimeout?1/0:f.creativeTimeout;e=Array.isArray(t)?t.slice(0):[t];var n={_id:kt(12),_adQueue:e,_waterfallIndex:0,_offset:0,_position:"api",requestTimeout:i||Z,creativeTimeout:r||tt};v?B(n):d.once("playlistItem",function(){return B(n)})};var J=Oe.call(this,u,t);J.catch(u.noop),this.destroy=j})}();