/*! ng-video by Adam Timberlake <adam.timberlake@gmail.com> created on 2017-01-03 */
!function(a){"use strict";var b=a.module("ngVideo",[]);b.constant("ngVideoOptions",{RESTRICT:"CA",REFRESH:50,SCREEN_DIRECTIVE:"vi-screen",SCREEN_CHANGE:!0,TIMELINE_CHANGE:!0,VOLUME_STEPS:.1,VOLUME_MINIMUM:0,VOLUME_MAXIMUM:1,BUFFER_COLOUR:"#dd4b39",BUFFER_HEIGHT:1,BUFFER_WIDTH:485}),b.value("ngVideoPlaylist",[]),b.service("video",["$rootScope","$timeout","ngVideoPlaylist",function(a,b,c){var d={};return d.forceVideo="",d.addSource=function(b,e,f){var g={type:b,src:e};return c.push(g),a.$broadcast("ng-video/add",g),f&&(d.forceVideo=g),g},d.multiSource=function(){function b(){}return b.prototype={sources:[],addSource:function(a,b){this.sources.push({type:a,src:b})},save:function(b){return c.push(this.sources),a.$broadcast("ng-video/add",this.sources),b&&(d.forceVideo=this.sources),this.sources}},new b},d.throwException=function(a){throw"ngVideo: "+a+"."},d.resetSource=function(){c.length=0},d}])}(window.angular),function(a){"use strict";a.module("ngVideo").directive("ngVideo",["$rootScope","video","ngVideoPlaylist","ngVideoOptions",function(b,c,d,e){return{restrict:e.RESTRICT,scope:!0,controller:["$window","$rootScope","$scope","video",function(b,c,e,f){e.video=d[0]||null,e.player={},e.playing=!1,e.loading=!0,e.attachEvents=function(a){!function(){var b=function(a,b){return function(){e[a]=b,e.$apply()}};a.bind("play",b("playing",!0)),a.bind("pause",b("playing",!1)),a.bind("loadstart",b("loading",!0))}(),a.bind("loadeddata",function(){e.$apply(function(){e.loading=!1,c.$broadcast("ng-video/reset"),(e.playing||e.player.autoplay)&&e.player.play()})}),a.bind("ended",function(){e.$apply(function(){var a=function(a){e.open(d[a]),e.video=d[a],e.player.play()},b=d.indexOf(e.video);return b===-1||"undefined"==typeof d[b+1]?e.player.loop?void a(0):void e.player.pause():void a(b+1)})})},e.open=function(b){var c=function(a){var b="src"in a&&"type"in a;b||f.throwException("Passed an invalid video model to open")},d=function(a){e.video=a,e.player.setAttribute("src",a.src),e.player.setAttribute("type",a.type),e.player.load()};if(b instanceof Array){var g=!1;return void a.forEach(b,function(a){if(c(a),!g){var b=e.player.canPlayType("video/"+a.type);b&&d(a)}})}c(b),d(b)},e.toggleState=function(){return e.playing?void e.player.pause():void e.player.play()},e.closeFullScreen=function(){var a=b.document;a.exitFullscreen?a.exitFullscreen():a.mozExitFullscreen?a.mozExitFullscreen():a.webkitExitFullscreen&&a.webkitExitFullscreen()}}],link:function(a,f){a.container=f[0],a.openFullScreen=function(){a.container.requestFullscreen?a.container.requestFullscreen():a.container.mozRequestFullScreen?a.container.mozRequestFullScreen():a.container.webkitRequestFullscreen&&a.container.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)};var g=f.find("video");0!==g.length&&"undefined"!=typeof g.attr(e.SCREEN_DIRECTIVE)||c.throwException("Must add ng-video-screen directive"),a.player=g[0],a.attachEvents(g),b.$broadcast("ng-video/attach-events",g),a.video&&a.open(a.video),a.$on("ng-video/add",function(){1===d.length&&a.open(d[0])}),a.$watch(function(){return c.forceVideo},function(){c.forceVideo&&a.open(c.forceVideo)})}}}])}(window.angular),function(a){"use strict";a.module("ngVideo").directive("viBuffer",["ngVideoOptions",function(a){return{restrict:a.RESTRICT,template:'<canvas height="{{height}}" width="{{width}}"></canvas>',scope:!0,link:function(b,c){b.height=a.BUFFER_HEIGHT,b.width=a.BUFFER_WIDTH;var d=c.find("canvas")[0],e=d.getContext("2d");b.$watch("lastUpdate",function(){var c=b.player.buffered,f=b.player.duration,g=c.length,h=d.width,i=d.height;for(e.fillStyle=a.BUFFER_COLOUR;g--;){var j=c.start(g)/f*h,k=c.end(g)/f*h;e.fillRect(j,0,k-j,i)}})}}}])}(window.angular),function(a){"use strict";var b=a.module("ngVideo"),c=["play","pause"];b.directive("viControls",["ngVideoOptions",function(a){return{restrict:a.RESTRICT,controller:["$scope",function(a){a.play=function(){a.player.play(),a.$apply()},a.pause=function(){a.player.pause(),a.$apply()}}]}}]);var d=function(a){var c=a.charAt(0).toUpperCase()+a.slice(1);b.directive("viControls"+c,["video","ngVideoOptions",function(b,c){return{restrict:c.RESTRICT,link:function(c,d){"function"!=typeof c[a]&&b.throwException("Control type '"+a+"' is unsupported"),d.bind("click",c[a])}}}])};a.forEach(c,function(a){d(a)})}(window.angular),function(a,b){"use strict";var c=["duration","currentTime","volume","playbackRate"];a.module("ngVideo").directive("viFeedback",["ngVideoOptions",function(d){return{restrict:d.RESTRICT,scope:!0,controller:["$rootScope","$scope","$interval","$window","ngVideoOptions",function(d,e,f,g,h){e.interval={},e.lastUpdate=0,e.duration=0,e.volume=1,e.playbackRate=1,e.currentTime=0,e.percentagePlayed=0,e.buffered=0,e.buffering=!1;var i=0;e.grabStatistics=function(){var d=e.player;return i!==d.currentTime||d.paused?(i=d.currentTime,e.buffering=!1,a.forEach(c,function(a){e[a]=isNaN(e.player[a])?e[a]:e.player[a]}),0!==e.player.buffered.length&&(e.buffered=100*b.round(d.buffered.end(0)/d.duration)),e.player.muted&&(e.volume=0),e.percentagePlayed=e.currentTime/e.duration*100,void(e.lastUpdate=(new g.Date).getTime())):void(e.buffering=!0)},e.beginPolling=function(){e.interval=f(e.grabStatistics,h.REFRESH)},e.endPolling=function(){f.cancel(e.interval)},e.$on("ng-video/reset",function(){e.player.currentTime=0,e.grabStatistics()});var j=function(){e.volume=e.player.volume};e.$on("ng-video/volume",j),e.$on("ng-video/feedback/refresh",e.grabStatistics),e.$watch("playing",function(a){return e.grabStatistics(),a?void e.beginPolling():void e.endPolling()}),e.$on("ng-video/attach-events",function(a,b){b.bind("timeupdate",e.grabStatistics),b.bind("volumechange",j)})}]}}])}(window.angular,window.Math),function(a){"use strict";var b=function(b,c){var d=b.charAt(0).toUpperCase()+b.slice(1);a.module("ngVideo").directive("viFullScreen"+d,["$window","ngVideoOptions",function(a,b){return{restrict:b.RESTRICT,link:function(b,d){d.bind("click",function(){c.call(this,b,a.document),b.$apply()})}}}])};b("open",function(a){a.openFullScreen()}),b("close",function(a){a.closeFullScreen()}),b("toggle",function(a,b){var c=function(){return b.fullscreenElement?!!b.fullscreenElement:b.mozFullscreenElement?!!b.mozFullscreenElement:b.webkitFullscreenElement?!!b.webkitFullscreenElement:void 0};return c()?void a.closeFullScreen():void a.openFullScreen()})}(window.angular),function(a){"use strict";var b=a.module("ngVideo"),c={ERROR:1,INFORMATION:2,GENERAL:3};b.constant("ngVideoMessages",{CAN_PLAY:{ref:1,text:"Can Play",type:c.INFORMATION,event:"canplay"},CAN_PLAY_THROUGH:{ref:2,text:"Can Play Through",type:c.INFORMATION,event:"canplaythrough"},DURATION_CHANGE:{ref:3,text:"Duration Change",type:c.GENERAL,event:"durationchange"},EMPTIED:{ref:4,text:"Emptied",type:c.INFORMATION,event:"emptied"},ENDED:{ref:5,text:"Ended",type:c.INFORMATION,event:"ended"},ERROR:{ref:6,text:"Error",type:c.ERROR,event:"error"},LOADED_DATA:{ref:7,text:"Loaded Data",type:c.INFORMATION,event:"loadeddata"},LOADED_META_DATA:{ref:8,text:"Loaded Meta Data",type:c.INFORMATION,event:"loadedmetadata"},LOAD_START:{ref:9,text:"Looking",type:c.INFORMATION,event:"loadstart"},PAUSE:{ref:10,text:"Pause",type:c.GENERAL,event:"pause"},PLAY:{ref:11,text:"Play",type:c.GENERAL,event:"play"},PLAYING:{ref:12,text:"Playing",type:c.GENERAL,event:"playing"},PROGRESS:{ref:13,text:"Progress",type:c.INFORMATION,event:"progress"},RATE_CHANGE:{ref:14,text:"Rate Change",type:c.INFORMATION,event:"ratechange"},SEEKED:{ref:15,text:"Seeked",type:c.INFORMATION,event:"seeked"},SEEKING:{ref:16,text:"Seeking",type:c.INFORMATION,event:"seeking"},STALLED:{ref:17,text:"Stalled",type:c.ERROR,event:"stalled"},SUSPEND:{ref:18,text:"Suspended",type:c.ERROR,event:"suspend"},TIME_UPDATE:{ref:19,text:"Time Update",type:c.GENERAL,event:"timeupdate"},VOLUME_CHANGE:{ref:19,text:"Volume Change",type:c.GENERAL,event:"volumechange"},WAITING:{ref:20,text:"Waiting",type:c.INFORMATION,event:"waiting"}}),b.directive("viMessages",["$window","ngVideoOptions","ngVideoMessages",function(b,c,d){return{restrict:c.RESTRICT,scope:!0,controller:["$scope",function(c){c.messages=[],c.$on("ng-video/attach-events",function(e,f){a.forEach(d,function(d){f.bind(d.event,function(){delete d.$$hashKey,d=a.copy(d),d.date=new b.Date,c.messages.push(d),c.$apply()})})})}]}}])}(window.angular),function(a){"use strict";a.module("ngVideo").directive("viMeta",["$window","ngVideoOptions",function(b,c){return{restrict:c.RESTRICT,scope:!0,require:"ngModel",controller:["$scope",function(a){a.duration=0}],link:function(c,d,e,f){c.player=b.document.createElement("video");var g=a.element(c.player);c.player.setAttribute("preload",!1),g.bind("loadedmetadata",function(){c.duration=c.player.duration,c.$apply(),delete c.player}),c.$watch(function(){return f.$modelValue},function(a){c.player.setAttribute("src",a.src),c.player.load()})}}}])}(window.angular),function(a){"use strict";var b=function(b,c){var d="viPlaybackRate"+b.charAt(0).toUpperCase()+b.slice(1);a.module("ngVideo").directive(d,["$rootScope","ngVideoOptions",function(a,b){return{restrict:b.RESTRICT,link:function(b,e,f){b.setPlaybackRate=function(c){b.player.playbackRate=c,b.player.defaultPlaybackRate=c,a.$broadcast("ng-video/feedback/refresh")},e.bind("click",function(){c.call(this,b,+f[d],+b.player.playbackRate),a.$broadcast("ng-video/feedback/refresh"),b.$apply()})}}}])};b("",function(a,b){a.setPlaybackRate(b)}),b("normalise",function(a){a.setPlaybackRate(1)}),b("increment",function(a,b,c){a.setPlaybackRate(c+b)}),b("decrement",function(a,b,c){a.setPlaybackRate(c-b)})}(window.angular),function(a){"use strict";var b=a.module("ngVideo");b.directive("viPlaylist",["ngVideoPlaylist","ngVideoOptions",function(a,b){return{restrict:b.RESTRICT,scope:!0,controller:["$scope",function(b){b.videos=a,b.currentIndex=function(){return a.currentIndex(b.video)},b.tentativelyOpen=function(c){"undefined"!=typeof a[c]&&b.open(a[c])},b.next=function(){b.tentativelyOpen(b.currentIndex()+1)},b.previous=function(){b.tentativelyOpen(b.currentIndex()-1)},b.first=function(){b.tentativelyOpen(0)},b.last=function(){b.tentativelyOpen(a.length-1)}}]}}]),b.directive("viPlaylistVideo",["ngVideoPlaylist","ngVideoOptions",function(a,b){return{restrict:b.RESTRICT,require:"ngModel",link:function(a,b,c,d){a.$watch(function(){return d.$modelValue},function(c){b.bind("click",function(){a.$apply(function(){a.open(c)})})})}}}])}(window.angular),function(a){"use strict";a.module("ngVideo").directive("viScreen",["ngVideoOptions",function(a){return{restrict:a.RESTRICT,link:function(b,c){a.SCREEN_CHANGE&&c.bind("click",function(){b.loading||b.toggleState()})}}}])}(window.angular),function(a){"use strict";var b=function(b,c){var d="viSeekable"+b.charAt(0).toUpperCase()+b.slice(1);a.module("ngVideo").directive(d,["$rootScope","ngVideoOptions",function(a,b){return{restrict:b.RESTRICT,link:function(b,e,f){e.bind("click",function(){c.call(this,b,+f[d],+b.player.currentTime),a.$broadcast("ng-video/feedback/refresh"),b.$apply()})}}}])};b("",function(a,b){a.player.currentTime=b}),b("increment",function(a,b,c){a.player.currentTime=c+b}),b("decrement",function(a,b,c){a.player.currentTime=c-b})}(window.angular),function(a){"use strict";a.module("ngVideo").directive("viTimeline",["ngVideoOptions",function(a){return{restrict:a.RESTRICT,template:'<input type="range" value="0" />',replace:!0,scope:!0,link:function(b,c){b.wasPlaying=!1,b.$on("ng-video/reset",function(){c.val(0)}),a.TIMELINE_CHANGE&&(c.bind("mousedown",function(){b.wasPlaying=b.playing,b.pause()}),c.bind("mouseup",function(){b.wasPlaying&&b.play()}),c.bind("change",function(){b.player.currentTime=c.val()/100*b.player.duration}));var d=function(){var a=b.player.currentTime/b.duration*100;c.val(a)};b.$watch("lastUpdate",d),b.$on("ng-video/seekable",d)}}}])}(window.angular),function(a){"use strict";var b=a.module("ngVideo");b.directive("viVolume",["ngVideoOptions",function(a){return{restrict:a.RESTRICT,scope:!0,controller:["$rootScope","$scope",function(b,c){c.setVolume=function(d){c.player.muted&&d>0&&(c.player.muted=!1),d<a.VOLUME_MINIMUM&&(d=a.VOLUME_MINIMUM),d>a.VOLUME_MAXIMUM&&(d=a.VOLUME_MAXIMUM),c.player.volume=+d.toFixed(2),b.$broadcast("ng-video/volume",c.player.volume)}}]}}]);var c=function(a,c){var d=a.charAt(0).toUpperCase()+a.slice(1);b.directive("viVolume"+d,["ngVideoOptions",function(a){return{restrict:a.RESTRICT,link:function(b,d){d.bind("click",function(){c.call(this,b,b.player.volume,a.VOLUME_STEPS),b.$apply()})}}}])};c("decrease",function(a,b,c){a.setVolume(b-c)}),c("increase",function(a,b,c){a.setVolume(b+c)}),c("mute",function(a){a.setVolume(0)}),c("loudest",function(a){a.setVolume(1)})}(window.angular);