!function(){"use strict";function e(e){if("true"===e)return!0;if("false"===e)return!1;var t=parseFloat(e);return isNaN(t)?e:t}function t(e){var t=Object.keys(e).filter(function(t){return"pre"===e[t].offset||!e[t].offset});return t.length?t[0]:null}function i(){return P}function n(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e}function r(e,t){var i=void 0,n=new Promise(function(e){i=e}),r=document.getElementsByTagName("head")[0]||document.documentElement,o=document.createElement("script");return o.src=e,o.onload=o.onreadystatechange=function(e){this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(i(e),o.onload=o.onreadystatechange=null,r&&o.parentNode&&r.removeChild(o))},o.onerror=function(){i("Error loading script")},r.insertBefore(o,r.firstChild),setTimeout(function(){i()},t),n}function o(e,t){var i=e.xhttpFAN,n=e.settings,r=e.bidders.FAN.placementId,o=e.tag,a=n.floorPriceCents,s=n.playerWidth,d=n.playerHeight,l=function(e,t,i){return e?["https://an.facebook.com/v2/placementbid.json?&placementids[]="+e,"&playerwidth="+t,"&playerheight="+i,"&adformats[]="+_,"&sdk="+I,"&pageurl="+x].join(""):null}(r,s,d),u=e.bidders.APS,h=e.mediationLayer||u.pubID&&u.slotID;if(!function(e,t,i,n){return!(!n||!e&&(!t||"usd"!==i))}(h,a,n.floorPriceCurrency,l))return t({error:!0,message:"Invalid config"});i.onreadystatechange=function(){if(4===this.readyState){if(clearTimeout(e.currentTimeout),200!==this.status)return t({error:!0,message:"Invalid response (status "+this.status+")"});var i=JSON.parse(this.responseText),n=i.errors;if(n&&n.length)return t({error:!0,message:n[0]});var l=i.bids;if(!l||!l[r]||!l[r][0])return t({error:!0,message:"No bids for placement id"});var u=l[r][0],c=u.bid_price_cents,g=u.bid_id;if(h){var p=Math.round(c/100);return t({tag:o,custParams:{jwFANBidPrice:p,jwFANBidID:g}})}var f=u.bid_price_currency,m=c>a,v={bidWon:m,priceCents:c,priceCurrency:f};return m?(v.tag=function(e,t,i,n){return["https://an.facebook.com/v1/instream/vast.xml?placementid="+e,"&playerwidth="+i,"&playerheight="+n,"&sdk="+I,"&bidid="+t,"&pageurl="+x].join("")}(r,g,s,d),t(v)):t(v)}},i.open("GET",l),i.withCredentials=!0,i.send(null)}function a(e,t){var i=e.bidders.APS;if(!i.pubID||!i.slotID)return t({error:!0,message:"Invalid config"});S().then(function(){return apstag.init({pubID:i.pubId,adServer:i.adServer}),apstag.fetchBids({slots:[{slotID:i.slotID}],timeout:e.settings.bidTimeout},function(n){return t(n&&n[0]&&n[0].slotID===i.slotID?{tag:e.tag,custParams:{amznbid:n[0].amznbid,amzniid:n[0].amzniid}}:{error:!0,message:"No bids for pubID and slotID"})})}).catch(function(){t({error:!0,message:"Amazon header bidding failed"})})}function s(e,t){var i=n({videoCommonArgs:{protocols:[2,3,5,6],mimes:["video/mp4","video/webm","application/javascript"],apiList:[1,2]}},e.bidders.index);if(!i.script&&!i.siteID&&!window.indexapi)return t({error:!0,message:"Invalid config"});setTimeout(function(){t({error:!0,message:"Index Exchange header bidding request failed"})},e.settings.bidTimeout),k().then(function(){var n=function(i,n){if(void 0!==n)return t({tag:e.tag,custParams:n});t({error:!0,message:"Index Exchange header bidding request failed"})};window.indexapi=window.indexapi||{},window.indexapi.deferQueue=window.indexapi.deferQueue||[],window.indexapi.deferQueue.push(function(){window.indexapi.solicitIndexVideoAds(e.tag,n,i)})}).catch(function(){t({error:!0,message:"Index Exchange header bidding failed"})})}function d(e){var t=this;t.video=e,t.blocked=!1;var i={},n=function(n){"function"==typeof e[n]?i[n]={get:function(){return function(){var e=t.video[n];if(e){if("pause"===n&&t.blocked)return;return e.apply(t.video,arguments)}}}}:i[n]={get:function(){return t.video[n]},set:function(e){t.video[n]=e}}};for(var r in e)n(r);Object.defineProperties(this,i)}function l(e,t,i){if(!e)return e;for(var n=t.getPlaylistItem(),r=t.getConfig(),o=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()||r.height).replace("__player-width__",t.getWidth()||r.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]:""}())),a=(o=i.companiondiv&&i.companiondiv.id?o.replace("__companion-div__",i.companiondiv.id):o.replace("__companion-div__","")).match(new RegExp(/__item-[a-z 0-9 A-Z]*__/g)),s=0;a&&s1e3&&(u=u.substring(0,1e3)),o=o.replace(d,encodeURIComponent(u))}else o=o.replace(d,"")}if(n.title&&-1===o.indexOf("vid_t=")){var h=n.title.substring(0,100).replace(/[^\x00-\x7F]/g,"");o+=function(e){return-1!==e.indexOf("?")?"&":"?"}(o)+"vid_t="+encodeURIComponent(h)}return o}function u(e,t,i){if("start"===e||"0%"===e)return"pre";if("end"===e||"100%"===e)return"post";if("pre"===e||"post"===e||i.indexOf(e,"%")>-1)return e;var n=t.seconds(e);return!!i.isNumber(n)&&n}function h(e,t,i){var n=u(e,t,i);return n||(n="pre"),i.isNumber(n)&&(n=function(e){var t=parseInt(e,10),i=Math.floor(t)%1e3,n=Math.floor(t/1e3)%60,r=Math.floor(t/6e4)%60,o=Math.floor(t/36e5)%24;return o=o<10?"0"+o:o,r=r<10?"0"+r:r,n=n<10?"0"+n:n,i=("000"+i).slice(-3),o+":"+r+":"+n+"."+i}(1e3*n)),n}function c(e,t,i){var n={};return t.foreach(e,function(e,r){var o={},a=r.ad||r;o.offset=h(a.offset||a.position||r.offset||"",t,i),o.tag=function(e,t,i){if(!i)return e;var n=e.indexOf("?")>=0?"&":"?",r=e.indexOf("cust_params="),o="cust_params=".length,a="",s="";if(t.foreach(i,function(e,t){a=""+a+s+e+"="+t,s="&"}),a=encodeURIComponent(a),r>=0){var d=e.substr(0,r+o),l=e.substr(r+o);return""+d+a+"%26"+l}return""+e+n+"cust_params="+a}(a.tag,t,a.custParams),o.type=a.type||r.type||"linear,nonlinear",n[e]=o}),n}function g(e){try{return e.getAdPodInfo()}catch(e){return null}}var p="adCompanions",f="adStarted",m=2e3,v=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},y={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:"xx",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,premiumAds:!1,requestTimeout:1e4,scaled_ads:!0,usestaticmessage:!1,vpaidcontrols:!1,vpaidmode:"insecure"},b=function(){function i(t,n){v(this,i),this.config=t,this.utils=n;for(var r in y)if(y.hasOwnProperty(r)){var o=t[r],a=y[r],s=typeof a;if(void 0!==o){if("boolean"!==s&&"number"!==s||(o=e(o)),typeof o!==s)throw new Error("invalid parameter: "+r+" should be a "+s);this[r]=o}else this[r]=a}this.admessagedynamic=this.admessage}return i.prototype.getPrerollBlock=function(){var e=this.getConfigSchedule(),i=this.bidsResponse;if("string"==typeof e){if(!i)return e;var n=i.custParams;if(n){var r="jwFANBidPrice="+n.jwFANBidPrice+"&jwFANBidID="+n.jwFANBidID,o=i.tag.indexOf("?")>=0?"&":"?";return""+i.tag+o+r}return i.tag}var a=t(e);if(!a)return null;var s=this.utils.extend({},e[a]);return i&&(s.tag=i.tag,s.custParams=this.utils.extend({},s.custParams,i.custParams)),s},i.prototype.addBidsResponse=function(e){e&&!e.error&&(e.bidWon||e.tag)?this.bidsResponse=e:this.bidsResponse=null},i.prototype.getSchedule=function(){var e=this.utils.extend({},this.getConfigSchedule());if(!this.bidsResponse)return this.getConfigSchedule();var i=this.getPrerollBlock();if("string"==typeof i)return i;return e[t(e)]=i,e},i.prototype.getConfigSchedule=function(){var e=this.config;return e.tag||this.adschedule||e.schedule||e.ad},i}(),A=function(){function e(t,i,n){v(this,e);var r=document.createElement("div");this.visible=!1,this.style=n,this.div=t,this.adDiv=r,r.id=i+"_ad",n(t,{overflow:"hidden",width:"100%",height:"100%",display:"block",visibility:"hidden",pointerEvents:"none",opacity:0}),n(r,{position:"absolute",width:"100%",height:"100%"}),t.appendChild(r)}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;t0&&void 0!==arguments[0]?arguments[0]:{settings:{},bidders:{}},i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;v(this,e),this.tag=i,this.mediationLayer=t.mediationLayerAdServer,this.settings=function(e,t,i){return n({bidTimeout:L,playerWidth:t,playerHeight:i},e)}(t.settings,o,a),this.bidders=function(e){var t={FAN:n({},e.FAN),APS:n({},e.APS)};return e.index&&(t.index=e.index),t}(t.bidders),this.xhttpFAN=new XMLHttpRequest,this.request=new Promise(function(e){r.resolve=e}),t.bidders.APS&&t.bidders.APS.pubID&&t.bidders.APS.slotID&&S(),t.bidders.index&&(t.bidders.index.script||t.bidders.index.siteID)&&k(t.bidders.index.script),this.currentTimeout=null}return e.prototype.start=function(){return this.start=function(){return this.request},function(e){for(var t=[o,a,s],i=[],r=0;r0}).map(function(e){return{begin:e,text:i.options.cuetext}});i.player.setCues(s)}}return r}).catch(function(e){return i.asyncError(e),Promise.reject(e)})},e.prototype.getViewMode=function(){var e=google.ima.ViewMode;return this.player.getFullscreen()?e.FULLSCREEN:e.NORMAL},e.prototype.waitForPlaybackOnMobile=function(){return this.video&&this.env.OS.mobile&&!this.video.__jwMobileCanPlay&&(this.player.isBeforePlay()||0===this.video.currentTime)},e.prototype.prepareToPlayAd=function(){this.destroyed()||this.blockingInstreamPlayer||(clearTimeout(this.timeoutAdStart),this.video&&this.env.OS.iOS&&(this.video.controls=!1),this.waitForPlaybackOnMobile()?(this.debugConsoleLog("[JW DEBUG] Waiting for playback of content on mobile devices"),this.mobilePlayCallback=this.getMobilePlayCallback(),this.video.addEventListener("play",this.mobilePlayCallback)):this.startBlocking())},e.prototype.muteInstreamProvider=function(){var e=this.video&&this.video.muted||this.player.getMute()||0===this.adsLoaderManager.adsManager.getVolume();this.debugConsoleLog("[JW DEBUG] Setting mute on instreamProvider",e),this.instreamProvider.mute(e)},e.prototype.getMobilePlayCallback=function(){var e=this,t=function(i){e.debugConsoleLog("[JW DEBUG] Content started on mobile device. Can start ads now"),i.currentTarget.removeEventListener("play",t),i.currentTarget.__jwMobileCanPlay=!0,e.mobilePlayCallback=null,e.startBlocking(),e.bidsPromise.then(w).then(function(){e.destroyed()||(e.debugConsoleLog("[JW DEBUG] Request ads to IMA SDK"),e.adsLoaderManager.requestAds())})};return t},e.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"}))}},e.prototype.startBlocking=function(){var e=this;this.blockingInstreamPlayer||this.destroyed()||(this.debugConsoleLog("[JW DEBUG] JW Player startBlocking"),this.exitFullscreenOnInlineIOS(),this.options.premiumAds&&this.player.on("viewable",function(t){t.viewable?e.pausedByViewable&&(e.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Start playing the ad on viewable"),e.player.play()):e.paused||(e.debugConsoleLog("[JW DEBUG] PremiumAds mode enabled. Pause the ad on not viewable"),e.player.pause(),e.pausedByViewable=!0)},this),this._qoe.tick("adLoading"),this.player.utils.addClass(this.player.getContainer(),"jw-flag-ads-googleima"),this.adsLoaderManager&&this.adsLoaderManager.videoProxy&&this.adsLoaderManager.videoProxy.unblock(),this.blockingInstreamPlayer=this.player.createInstream().init(),this.blockingInstreamPlayer.setText("Loading"),this.blockingInstreamPlayer.applyProviderListeners(this.instreamProvider),this.initAdsManagerPromise.then(function(t){e.debugConsoleLog("[JW DEBUG] Start adsManager"),t.start()}).catch(function(){}),clearTimeout(this.timeoutAdStart),this.timeoutAdStart=setTimeout(function(){if(e.debugConsoleLog("[JW DEBUG] Ad request timeout"),!e.destroyed()){e.stopBlocking(),e.asyncDiscardAdBreak();var t={message:"Ad Request timeout after "+e.options.requestTimeout+" milliseconds",getErrorCode:function(){return 60004}},i=e.adsLoaderManager.adErrorEventObject(t,{});e.trigger("adError",i)}},this.options.requestTimeout))},e.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(),["jw-flag-ads-vpaid","jw-flag-ads-vpaid-controls","jw-flag-ads-googleima"]),this.mobilePlayCallback&&(this.video&&this.video.removeEventListener("play",this.mobilePlayCallback),this.mobilePlayCallback=null),this.blockingInstreamPlayer&&(this.adsLoaderManager&&this.adsLoaderManager.videoProxy&&this.adsLoaderManager.videoProxy.block(),this.instreamProvider.off(),this.blockingInstreamPlayer.destroy(),this.blockingInstreamPlayer=null,this.view.adTakeDown()))},e.prototype.resumeRequested=function(){this.debugConsoleLog("[JW DEBUG] ResumeRequest from IMA SDK"),this.currentAd&&this.currentAd.isLinear()&&(this.finishAd(),this.view.adTakeDown()),this.stopBlocking()},e.prototype.finishAd=function(){this.currentAd&&(clearInterval(this.progressIntervalId),this.currentAd=null)},e.prototype.discardAdBreak=function(e){!e&&this.adsLoaderManager&&(e=this.adsLoaderManager.adsManager),!this.destroyed()&&e&&(e.discardAdBreak(),e.stop())},e.prototype.asyncDiscardAdBreak=function(){var e=this;this.initAdsManagerPromise.then(function(t){return e.discardAdBreak(t)}).catch(function(){})},e.prototype.pause=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player pause ad"),e.pause())},e.prototype.resume=function(){this.pausedByViewable=!1;var e=this.adsLoaderManager.adsManager;e&&(this.debugConsoleLog("[JW DEBUG] JW Player resume ad"),e.resume())},e.prototype.beforePlay=function(e){var t=this;this.bids&&this.bids.timeout&&this.bids.timeout(),this.player.off("beforePlay",null,this),this.isItemSchedule=!!e,this.prepareToPlayAd(),this.adsLoaderManager.initializeDisplay(),this.waitForPlaybackOnMobile()||this.bidsPromise.then(w).then(function(){t.destroyed()||(t.debugConsoleLog("[JW DEBUG] Request ads to IMA SDK"),t.adsLoaderManager.requestAds())})},e.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()},e.prototype.time=function(e){this.playbackProxy.currentTime=e.position,e.duration>=e.position?this.playbackProxy.duration=e.duration:this.playbackProxy.duration=1/0},e.prototype.resize=function(){var e=this.currentAd,t=this.adsLoaderManager.adsManager;if(t){var i=e&&!e.isLinear(),n=this.player.getSafeRegion(i);if(i){var r=e.getHeight();r=this.player.getFullscreen()?n.height/2:Math.max(100,r+10),this.debugConsoleLog("[JW DEBUG] Resize adsManager",n.width,r,this.getViewMode()),t.resize(n.width,r,this.getViewMode()),this.view.resizeNonLinear(n,r)}else this.debugConsoleLog("[JW DEBUG] Resize adsManager",n.width,n.height,this.getViewMode()),t.resize(n.width,n.height,this.getViewMode()),this.view.resizeLinear()}},e.prototype.triggerAdPlay=function(e,t,i,n){if(e.isLinear()){this.instreamProvider.trigger("state",{newstate:i,oldstate:n});var r=this.adsLoaderManager.adEventObject(e);r.oldstate=n,r.newstate=i,this.trigger(t,r)}},e.prototype.progressInterval=function(e,t){var i=this;if(clearInterval(this.progressIntervalId),t){var n=e.getAdId(),r=e.getAdPodInfo(),o=-1,a=this.options.admessage||"",s=new RegExp(this.options.admessagedynamickey,"g"),d=this.options.adcounterdynamic||"",l=new RegExp(this.options.adcountercountkey,"g"),u=new RegExp(this.options.adcountertotalkey,"g");this.progressIntervalId=setInterval(function(){if(i.currentAd&&i.currentAd.getAdId()===n){var h=t.getRemainingTime();if(!(isNaN(h)||h<=0)&&o!==h){o=h;var c=e.getDuration(),g=c-h;if(i.blockingInstreamPlayer){var p=a.replace(s,Math.round(c-g)),f=r.getTotalAds();if(f>1){var m=r.getAdPosition();p=d.replace(l,m).replace(u,f)+" "+p}i.blockingInstreamPlayer.setText(p),i.instreamProvider.trigger("time",{duration:c,position:g})}if(c>0){var v=i.adsLoaderManager.adEventObject(e);v.position=g,v.duration=c,i.trigger("adTime",v)}}}else clearInterval(i.progressIntervalId)},250)}},e.prototype.adLoaded=function(e){this.muteInstreamProvider();var t=this.adsLoaderManager.adEventObject(e.getAd());this.trigger("adRequest",t)},e.prototype.adStarted=function(e){var t=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger(f,i)},e.prototype.adImpression=function(e){var t=this,i=e.getAd(),n=i.isLinear(),r=n&&(i.getContentType().indexOf("image")>=0||-1===i.getDuration()),o=i.getContentType(),a="application/javascript"===o||"application/x-shockwave-flash"===o,s=n&&a&&this.options.vpaidcontrols;this.currentAd=i,this.adsLoaderManager.bindEvents({COMPLETE:this.adComplete.bind(this)}),a&&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())}}),r?this.startBlocking():n||this.stopBlocking(),this.player.utils.toggleClass(this.player.getContainer(),"jw-flag-ads-vpaid",n&&(r||a)),this.player.utils.toggleClass(this.player.getContainer(),"jw-flag-ads-vpaid-controls",s),this.view.adSetup(),this.resize(),this.muteInstreamProvider(),clearTimeout(this.timeoutAdStart);var d=this.adsLoaderManager.adsManager;this.progressInterval(i,d);var l=this.adsLoaderManager.adEventObject(i);if("pre"===l.adposition&&(void 0===l.podcount||1===l.sequence)){this._qoe.tick("adImpression");var u=this._qoe.between("adLoading","adImpression");l.timeLoading=u}this.trigger("adImpression",l),this.triggerAdPlay(i,"adPlay","playing","buffering")},e.prototype.adComplete=function(e){this.finishAd();var t=e.getAd(),i=this.adsLoaderManager.adEventObject(t);this.trigger("adComplete",i),this.adsLoaderManager.unbindEvents(["VOLUME_CHANGED"])},e.prototype.adClick=function(e){var t=this.adsLoaderManager.adsManager,i=e.getAd(),n=i.getContentType();"application/javascript"===n||"application/x-shockwave-flash"===n||(this.debugConsoleLog("[JW DEBUG] Ad paused due to ad click"),t.pause());var r=this.adsLoaderManager.adEventObject(i);this.trigger("adClick",r),this.pausedByViewable=!1},e.prototype.adPaused=function(e){this.paused||(this.paused=!0,this.triggerAdPlay(e.getAd(),"adPause","paused","playing"))},e.prototype.adResumed=function(e){this.paused&&(this.paused=!1,this.triggerAdPlay(e.getAd(),"adPlay","playing","paused"))},e.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)},e.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())},e.prototype.allAdsCompleted=function(){this.resumeRequested(),this.view.adTakeDown(),this.stopAdsManager()},e.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.bidsPromise=null)}).catch(function(){})},e.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,i):this.trigger("adError",i)}},e.prototype.adError=function(e){var t=e.getError();this.handleAdError(t,e)},e.prototype.asyncError=function(e){var t=this;this.destroyed()||(e&&e.getError?this.adError(e):e.target&&e.target.src?console.error("Failed to load "+e.target.src):console.error(e),this.timeoutAdStart=setTimeout(function(){return t.destroy()},0))},e.prototype.handleAdError=function(e,t){var i=this;this.options.debug&&console.error(e),900===e.getErrorCode()?this.timeoutAdStart=setTimeout(function(){return i.destroy()},0):(this.stopBlocking(),this.view.adTakeDown());var n=this.adsLoaderManager.adErrorEventObject(e,t);this.trigger("adError",n)},e.prototype.destroy=function(){if(this.debugConsoleLog("[JW DEBUG] JW Player destroy PlaylistItemManager"),this.off(),!this.destroyed()){this.player.off(null,null,this),this.bids&&this.bids.stop&&(this.bids.stop(),this.bids=null),clearTimeout(this.timeoutAdStart),clearInterval(this.progressIntervalId),this.currentAd=null,this.options=null,this.video=null,this.initAdsManagerPromise=null,this.bidsPromise=null;var e=this.adsLoaderManager;if(e){var t=e.adsManager;t&&t.isCustomPlaybackUsed(),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}},e.prototype.destroyed=function(){return!this.item},e}();!function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}(d.prototype,{block:function(){this.blocked=!0},unblock:function(){this.blocked=!1}});var B=function(){function e(t,i){v(this,e),this.player=t,this.options=i}return e.prototype.getAdsResponse=function(e){var t=this,i=this.player,n=i.utils,r='',o=[],a=[],s=[];return n.foreach(c(e,n,i._),function(e,n){var d=n.offset.replace("pre","start").replace("post","end"),u=r.replace(/_type_/g,n.type).replace(/_adbreakname_/g,e).replace(/_offset_/g,d).replace(/_url_/g,l(n.tag,i,t.options,n.custParams));"start"===d?o.push(u):"end"===d?s.push(u):a.push(u)}),''+o.join("")+a.join("")+s.join("")+""},e.prototype.getTagMap=function(e){var t=this,i=this.player,n=i.utils,r={};return n.foreach(c(e,n,i._),function(e,o){var a=u(o.offset,n,i._);i._.isString(a)&&(a=parseFloat(a.replace("pre","0").replace("post","-1"))),i._.isNumber(a)&&(r[a]=l(o.tag,i,t.options))}),r},e.prototype.getTagList=function(e){var t=this,i=this.player,n=i.utils,r=[];return n.foreach(c(e,n,i._),function(e,o){var a=u(o.offset,n,i._);i._.isString(a)&&(a=parseFloat(a.replace("pre","0").replace("post","-1"))),r.push({offset:a,tag:l(o.tag,i,t.options)})}),r},e}(),j=function(){function e(t){v(this,e),this.adsLoader=null,this.adDisplayContainer=null,this.displayInitialized=!1,this.adsRequest=null,this.userRequestContext=null,this.adsManager=null,this.adsManagerEvents={},this.container=t,this.adIds={},this.schedule=null,this.tagMap={},this.playerApi=null,this.videoProxy=null}return e.prototype.getVpaidMode=function(e){var t=google.ima.ImaSdkSettings.VpaidMode;return"disabled"===e||"none"===e?t.DISABLED:"enabled"===e?t.ENABLED:t.INSECURE},e.prototype.initializeDisplay=function(){this.videoProxy&&this.videoProxy.unblock(),!this.displayInitialized&&this.adDisplayContainer&&(this.adDisplayContainer.initialize(),this.displayInitialized=!0)},e.prototype.contentComplete=function(){if(null!==this.adsRequest){var e=this.adsLoader;e&&e.contentComplete(),this.adsRequest=null}},e.prototype.reset=function(){this.userRequestContext=null,this.contentComplete(),this.schedule=null,this.videoProxy&&this.videoProxy.block();var e=this.adsManager;e&&(e.destroy(),this.adsManager=null),this.adsManagerEvents={},this.adIds={},this.tagMap={}},e.prototype.prepare=function(e){google.ima.settings.setDisableCustomPlaybackForIOS10Plus(!0);var t=this.adsLoader;if(!t){var i=e.getContainer().querySelector("video");this.videoProxy=new d(i),this.adDisplayContainer=new google.ima.AdDisplayContainer(this.container,this.videoProxy),t=this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer)}return t},e.prototype.open=function(e,t,i,n){t.locale&&google.ima.settings.setLocale(t.locale),t.maxRedirects>=0&&google.ima.settings.setNumRedirects(t.maxRedirects);var r=this.prepare(i);this.playerApi=i;var o={requestType:e,vpaidMode:t.vpaidmode,playerVersion:i.version.split("+")[0]};this.userRequestContext=o;var a=t.getSchedule();if(!a)return Promise.reject();var s=new google.ima.AdsRequest,d=i.getSafeRegion(!1);s.linearAdSlotWidth=d.width,s.linearAdSlotHeight=d.height;var u=i.getSafeRegion(!0);s.nonLinearAdSlotWidth=u.width,s.nonLinearAdSlotHeight=u.height,s.setAdWillAutoPlay(i.getConfig().autostart&&!i.getEnvironment().OS.mobile),s.forceNonLinearFullSlot=n.forceNonLinearFullSlot,this.adsRequest=s;var h=new B(i,n);if("object"==typeof a){var c=h.getTagList(a);1===c.length&&0===c[0].offset&&(a=c[0].tag)}return"string"==typeof a?a=s.adTagUrl=o.adTagUrl=l(a,i,n):(s.adsResponse=o.adsResponse=h.getAdsResponse(a),this.tagMap=h.getTagMap(a)),this.schedule=a,new Promise(function(e,t){r.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,t,!1),r.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,e,!1)})},e.prototype.requestAds=function(){var e=this.adsLoader,t=this.userRequestContext,i=this.getVpaidMode(t.vpaidMode),n=e.getSettings();n.setPlayerType("jwplayer"),n.setPlayerVersion(t.playerVersion),n.setVpaidMode(i),e.requestAds(this.adsRequest,t)},e.prototype.getAdsManager=function(e,t,i){var n=new google.ima.AdsRenderingSettings;return n.loadVideoTimeout=i.loadVideoTimeout,n.enablePreloading=i.enablePreloading,n.uiElements=null,n.autoAlign=!0,n.useStyledNonLinearAds=!0,this.adsManager=e.getAdsManager(t,n),this.userRequestContext=e.getUserRequestContext(),this.adsManager},e.prototype.bindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,n=google.ima.AdErrorEvent.Type;Object.keys(e).forEach(function(r){var o=i[r]||n[r],a=t.adsManagerEvents[o];a&&t.adsManager.removeEventListener(o,a),t.adsManager.addEventListener(o,e[r],!1),t.adsManagerEvents[o]=e[r]})},e.prototype.unbindEvents=function(e){var t=this,i=google.ima.AdEvent.Type,n=google.ima.AdErrorEvent.Type;e.forEach(function(e){var r=i[e]||n[e],o=t.adsManagerEvents[r];o&&(t.adsManager.removeEventListener(r,o),delete t.adsManagerEvents[r])})},e.prototype.getAdId=function(e){if(e){var t=e.getAdId(),i=g(e);if(i&&(t=""+i.getTimeOffset()),t)return void 0===this.adIds[t]&&(this.adIds[t]=function(e){return new Array(e+1).join((Math.random().toString(36)+"00000000000000000").slice(2,18)).slice(0,e)}(12)),this.adIds[t]}return"-1"},e.prototype.getTag=function(e,t){if("string"==typeof this.schedule)return this.schedule;var i=g(e);if(i){var n=this.tagMap[i.getTimeOffset()];if(n)return n}var r=this.userRequestContext;return t&&t.getUserRequestContext&&(r=t.getUserRequestContext()||r),r?r.adTagUrl||r.adsResponse||"":(console.error("invalid request context",r),"")},e.prototype.adEventObject=function(e){var t={client:"googima",tag:this.getTag(e),ima:{ad:e,userRequestContext:this.userRequestContext}};if(!e)return t;t.id=this.getAdId(e),t.adtitle=e.getTitle(),t.adsystem=e.getAdSystem(),t.creativetype=e.getContentType(),t.linear=e.isLinear()?"linear":"nonlinear",t.viewable=this.playerApi.getViewable();var i=g(e);if(i){var n=i.getTotalAds();n>1&&(t.sequence=i.getAdPosition(),t.podcount=n);var r=i.getTimeOffset(),o="mid";0===r?o="pre":-1===r&&(o="post"),t.adposition=o}return t},e.prototype.adErrorEventObject=function(e,t){var i=e.getMessage&&e.getMessage()||e.message,n=e.getVastErrorCode&&e.getVastErrorCode()||900,r=e.getErrorCode&&e.getErrorCode()||900;r<1e4&&(r+=2e4);return{id:"-1",client:"googima",message:"Ad Error: "+i,code:n,adErrorCode:r,tag:this.getTag(t.getAd&&t.getAd(),t)}},e}();(window.jwplayerPluginJsonp||window.jwplayer().registerPlugin)("googima","8.0",function(e,t,n){function r(e,t,i,n){try{return e.getCompanionAds(t,i,n)}catch(e){return[]}}function o(t){var i=new google.ima.CompanionAdSelectionSettings;i.sizeCriteria=google.ima.CompanionAdSelectionSettings.SizeCriteria.IGNORE;var n=c.companiondiv||{width:300,height:250},o=function(e){for(var t=[],i=0;i0}function a(){_&&!_.destroyed()&&(e.off(null,null,_),_.destroy(),_=null)}function s(t){_&&_.discardAdBreak(),L.contentComplete(),a(),t&&t.adschedule?c.adschedule=t.adschedule:c.adschedule=null,e.setCues([])}function d(t,n,r){var a=this;s(t),r.getSchedule()?(L.reset(),(_=new O(t,c,e,P,E,L)).init(n,r),_.on("all",function(t,i){return e.trigger(t,i)}),_.on(f,function(e){o(e.ima.ad)}),e.once("beforePlay",function(t){if(c.premiumAds){var n=e.getHeight(),r=e.getWidth();if(n<270||r<480)return console.log("Premium Ads: Player size is smaller than 480x270 to play an ad"),void a.destroy();i()<0&&(g=Date.now())}_.beforePlay(t)},_).on("beforeComplete",function(){return _.beforeComplete()},_).on("time",function(e){return _.time(e)},_).on("resize",function(){return _.resize()},_).on("fullscreen",function(){return _.resize()},_)):w(u).then(function(){L.prepare(e)}).catch(u.noop)}var l=this,u=e.utils,h=e.getConfig(),c=new b(t||{},u),g=void 0;if(c.premiumAds){if(e.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())-e.navigationStart;if(t>0)return t}return m}()>=m)return console.log("Premium Ads: Page load took too long to start an ad"),void(this.destroy&&this.destroy())}w(u).then(function(){if(g){var e=i();e>=0&&e-g>=m&&(console.log("Premium Ads: IMA SDK load took too long to start an ad"),l.destroy&&l.destroy())}}).catch(u.noop);var v=e._,y=h.key;u.addClass(n,"jw-plugin-googima");var E=new A(n,e.id,u.style),P=new M(u,e.Events,E),L=new j(E.getAdDiv()),_=null;this.version="8.0.2",e.utils.extend(this,e.Events),e.on("destroyPlugin",function(){l.destroy()}),e.pauseAd=function(e){_&&(e?_.pause():_.resume())},e.playAd=function(i){var n=u.extend({},t,{debug:c.debug});delete n.ad,delete n.tag,delete n.schedule,e._.isArray(i)?n.tag=i[0]:n.tag=i,d({},"TYPE_API",new b(n,u)),_&&_.beforePlay(null)},e.on("playlistItem",function(e){d(e.item,"TYPE_SCHEDULE",c)},this).on("playlistComplete",function(){return s()},this).on("cast",function(e){e.active&&s()},this),function(e,t){var i=this,n=C[t];return n||(function(e,t){e.jwplayerEntitlements=function(e,t,i){var n={canPlayAds:!0},r=new e.key(t);if("unlimited"===r.edition())return i(n);var o=["//","entitlements.jwplayer.com","/",r.token(),".json"];"file:"===window.location.protocol&&o.unshift("https:"),e.ajax(o.join(""),function(e){n.canPlayAds=!e||!e.response||!1!==e.response.canPlayAds,i(n)},function(){i(n)},{timeout:1e4,responseType:"json"})}}(this),C[t]=new Promise(function(n,r){i.jwplayerEntitlements(e,t,function(e){e.canPlayAds?n():r({message:"Ad Limit Reached"})})}))}.call(this,u,y).catch(function(t){a(),e.off(null,null,l),e.playAd=u.noop,e.trigger("adError",{id:"-1",client:"googima",message:"Ad Error: "+t.message,code:900,adErrorCode:60002,tag:""})}),this.destroy=a,this.adsDebugMode=function(){c.debug=!0,_&&(_.debugConsoleLog=function(){var e;(e=console).log.apply(e,arguments)})}})}();