!function(e){e.fn.arqPlayer=function(a){var t=e.extend({},e.fn.arqPlayer.defaults,a),o=!1,n=!1,i=!1,l=!1,s=e(this);if(0==s.length)return console.log("Invalid Player Selector"),!1;var d=s.attr("id"),c=s.wrap("<div class='arqplayer-wrapper'></div>").parent();void 0!=s.attr("data-arqtitle")&&(t.title=s.attr("data-arqtitle")),void 0!=s.attr("data-arqdesc")&&(t.description=s.attr("data-arqdesc")),void 0!=s.attr("data-waiting")&&(t.waiting=s.attr("data-waiting")),void 0!=s.attr("data-ending")&&(t.ending=s.attr("data-ending")),void 0!=s.attr("data-poster")&&(t.poster=s.attr("data-poster")),void 0!=s.attr("data-autoplay")&&(t.autoplay=s.attr("data-autoplay"));var p=function(a,o,n){e.when(l||e.getScript(t.domain+"/js/vendor/youbora/5.3.6/sp.min.js"),e.Deferred(function(a){e(a.resolve)})).done(function(){function e(){window.playerState=y.INTENT,youbora.playHandler()}function i(){window.playerState=y.STOPPED,youbora.endedHandler()}if(l=!0,window.player=new Clappr.Player({parentId:"#"+d,disableVideoTagContextMenu:!0,poster:t.poster,plugins:{core:[LevelSelector]}}),player.load(a),"undefined"!=typeof $YB?window.youbora=new $YB.plugins.Clappr(window.player,{accountCode:o,media:{isLive:!0,title:n,resource:a},properties:{content_id:n}}):console.log("No YB Config"),1==r)return console.log("Unsupported Browser..."),void s.html('<h4 style="margin:50px;">Your browser does not support the playback of this video. <br>Please try using a different browser.</h4>');u(),g()&&player.play(),youbora.registerListeners();if(1==function(){var e=["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"];if(navigator.platform)for(;e.length;)if(navigator.platform===e.pop())return!0;return!1}()){var c,p;void 0!==document.hidden?(c="hidden",p="visibilitychange"):void 0!==document.mozHidden?(c="mozHidden",p="mozvisibilitychange"):void 0!==document.webkitHidden&&(c="webkitHidden",p="webkitvisibilitychange"),void 0===document.addEventListener||void 0===document[c]?alert("This video player requires a modern browser that supports the Page Visibility API. Unable to continue!"):document.addEventListener(p,function(){document[c]?player.stop():player.play()},!1)}else{var y={STOPPED:0,INTENT:1,PLAYING:2};window.playerState=y.STOPPED,player.core.getCurrentPlayback().on(Clappr.Events.PLAYBACK_PLAY_INTENT,e),player.core.getCurrentPlayback().on(Clappr.Events.PLAYBACK_PLAY,function(e,a,t){var r;return function(){var o=this,n=arguments,i=t&&!r;clearTimeout(r),r=setTimeout(function(){r=null,t||e.apply(o,n)},a),i&&e.apply(o,n)}}(function(){window.playerState!==y.INTENT&&e(),window.playerState=y.PLAYING,youbora.playingHandler()},500)),player.core.getCurrentPlayback().on(Clappr.Events.PLAYBACK_STOP,i),player.core.getCurrentPlayback().on(Clappr.Events.PLAYBACK_PAUSE,function(){i()}),window.clapprPlaying=!1}})},u=function(){var e=setTimeout(y(),500);clearTimeout(e)},y=function(){try{width=c.outerWidth(),width=width,height=width/16*9,player.resize({height:height,width:width})}catch(e){}},g=function(){return t.autoplay&&!/Mobi/.test(navigator.userAgent)},v=function(e){var a="";if(e>-1){var r="",o="",n="error";switch(e){case 0:r="Sorry, the scheduled event hasn't started yet. Please try again in a little while.",o=t.waiting.length>0?t.waiting:"",n="waiting";break;case 1:r="Sorry, the scheduled event has now finished. The stream is no longer available.",o=t.ended.length>0?t.ended:"",n="ended";break;case 400:r="Sorry, currently CENC DRM stream playback is not supported in our portal. We're hoping to add this feature soon.";break;case 401:r="Sorry, currently PlayReady DRM stream playback is not supported in our portal. We're hoping to add this feature soon.";break;case 402:r="Sorry, currently FairPlay DRM stream playback is not supported in our portal. We're hoping to add this feature soon.";break;case 403:r="Sorry, currently Widevine DRM stream playback is not supported in our portal. We're hoping to add this feature soon.";break;case 410:r="Sorry, we are unable to provide playback of services, using 3rd Party DRM providers.";break;case 490:r="Error: #490 - The correct stream extension is not configured for playback. Please contact support.";break;case 500:r="Error: #500 - Something appears to have gone wrong. The DRM type is not specified.";break;default:r="Error: #404 - Sorry, looks like an error occurred fetching your stream details..."}console.log(e+": "+r),""==o&&(o="data:image/svg+xml;charset=utf-8,%3Csvg xmlns%3D'http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg' viewBox%3D'0 0 16 9'%2F%3E"),a+='<img style="max-width:100%; background-color:#000;" class="arqplayer-'+n+'" src="'+o+'" />'}s.html(a)},f=function(a,o,n,l,c,y,f,h){if(function(){try{player&&("function"==typeof player.stop&&player.stop(),"function"==typeof player.reset&&player.reset(),s.empty())}catch(e){}}(),function(a){e("#"+t.title).length&&(document.getElementById(t.title).innerHTML=a)}(o),function(a){e("#"+t.description).length&&(document.getElementById(t.description).innerHTML=a)}(n),a.length>10)switch(v(-1),e(window).resize(u),parseInt(l)){case 0:if(console.log("HLS Playback"),function(){for(var e=[{os:"android",browser:"firefox"}],a=0;a<e.length;a++){var t=e[0];if(void 0!==t.os&&void 0!==t.browser){if(navigator.userAgent.toLowerCase().indexOf(t.os)>-1&&navigator.userAgent.toLowerCase().indexOf(t.browser)>-1)return!1}else if(void 0!==t.os){if(navigator.userAgent.toLowerCase().indexOf(t.os)>-1)return!1}else if(void 0!==t.browser&&navigator.userAgent.toLowerCase().indexOf(t.browser)>-1)return!1}return!0}())switch(parseInt(c)){case 0:!function(e){window.player=new Clappr.Player({parentId:"#"+d,disableVideoTagContextMenu:!0,poster:t.poster,plugins:{core:[LevelSelector]}}),player.load(e),u(),g()&&player.play(),1==r&&console.log("Unsupported Browser...")}(a);break;case 1:console.log("GA Enabled"),function(e,a){window.player=new Clappr.Player({parentId:"#"+d,gaAccount:a,plugins:{core:[LevelSelector]}}),player.load(e),player.play(),u()}(a,y);break;case 2:console.log("YB Enabled"),p(a,y,f)}else s.html('<h4 style="margin:50px;">Your browser does not support the playback of this video. <br>Please try using a different browser.</h4>');break;case 1:switch(console.log("Clappr DASH Selected"),parseInt(c)){case 0:console.log("No Analytics Required"),function(a){e.when(i||e.getScript(t.domain+"/js/vendor/dash/dash-shaka-playback.js"),e.Deferred(function(a){e(a.resolve)})).done(function(){i=!0,window.player=new Clappr.Player({parentId:"#"+d,plugins:{playback:[DashShakaPlayback],core:[LevelSelector]}}),player.load(a),g()&&(player.play(),u())})}(a);break;case 1:console.log("Google Analytics Enabled"),function(e,a){window.player=new Clappr.Player({parentId:"#"+d,gaAccount:a,plugins:{playback:[DashShakaPlayback],core:[LevelSelector]}}),player.load(e),g()&&(player.play(),u())}(a,y)}break;case 2:switch(console.log("Vualto Selected"),parseInt(c)){case 0:console.log("No Analytics"),function(e,a){var r=new Vuplay.Smart(t.vualtoKey,Vuplay.LogLevel.WARN),o={src:e,vudrmToken:a,autoStart:g(),loadSkin:!0};r.setup(o,document.getElementById(d)),window.player=r}(a,h);break;case 1:console.log("Warning - Google Analytics not possible with Vualto");break;case 2:console.log("Youbora Analytics Enabled"),function(e,a,r,o){var n=new Vuplay.Smart(t.vualtoKey,Vuplay.LogLevel.WARN);n.setStatsConfigs({youbora:{accountCode:r,media:{isLive:!0,title:o,resource:e},properties:{content_id:o}}}),n.startStatsMonitoring();var i={src:e,vudrmToken:a,autoStart:g(),loadSkin:!0};n.setup(i,document.getElementById(d)),window.player=n}(a,h,y,f)}}else v(parseInt(a))};return{play:function(a,r,i,l,s,c,p,u){if(void 0==d)return console.log("ID not set for player"),!1;switch(parseInt(l)){case 0:case 1:o?f(a,r,i,l,s,c,p,u):e.getScript("//cdn.jsdelivr.net/gh/clappr/clappr@0.2.78/dist/clappr.min.js").done(function(t,n){e.getScript("//cdn.jsdelivr.net/gh/clappr/clappr-level-selector-plugin@0.1.10/dist/level-selector.min.js").done(function(e,t){o=!0,f(a,r,i,l,s,c,p,u)})});break;case 2:n?f(a,r,i,l,s,c,p,u):e.getScript(t.domain+"/js/vendor/vuplay/vuplay-smart.min.js").done(function(e,t){n=!0,f(a,r,i,l,s,c,p,u)})}return!0}}},e.fn.arqPlayer.defaults={domain:"https://ott.arqiva.tv/manager",title:"arqtitle",description:"arqdesc",waiting:"",ended:"",poster:"",autoplay:!1,vualtoKey:"arqiva_tests|1d2a3535-c82d-4545-9488-ca66d1508bf3"};var a=!1,t=!1,r=!1;("Microsoft Internet Explorer"==navigator.appName||navigator.userAgent.match(/Trident/)||navigator.userAgent.match(/rv:11/)||void 0!==e.browser&&1==e.browser.msie)&&(a=!0);navigator.appVersion.search("NT 6.1")>-1&&(t=!0),1==t&&1==a&&(r=!0)}(jQuery),function(e){e.fn.arqLoader=function(a,t){var r=e(this),o=null;if(0==r.length)return!1;var n=function(a){if(e.fn.arqPlayer){null==o&&(o=r.arqPlayer());try{var t=atob(a),i=JSON&&JSON.parse(t)||e.parseJSON(t),l="",s=i.start,d=i.stop,c=(new Date).getTime()/1e3;c>s&&c<d?l=i.url:c<s?l="0":c>d&&(l="1"),o.play(l,i.title,i.desc,i.player_type,i.analytics_type,i.analytics_code,i.eid,i.token),"0"==l&&setTimeout(function(){n(a)},5e3)}catch(e){console.log("Error decoding event. Please refresh your page and try again."),console.log(e)}}};return void 0==a&&(a=r.attr("data-arqloader")),void 0!=a&&a.length>0&&n(a),{load:function(e){n(e)}}},e("[data-arqloader]").arqLoader()}(jQuery);