diff --git a/mopidy_spotmop/__init__.py b/mopidy_spotmop/__init__.py index 6a78b28..5b7fe2f 100755 --- a/mopidy_spotmop/__init__.py +++ b/mopidy_spotmop/__init__.py @@ -11,7 +11,7 @@ from services.auth import auth from mopidy import config, ext -__version__ = '2.7.1' +__version__ = '2.7.2' __ext_name__ = 'spotmop' __verbosemode__ = False @@ -30,7 +30,6 @@ def get_config_schema(self): schema = super(SpotmopExtension, self).get_config_schema() schema['debug'] = config.Boolean() schema['pusherport'] = config.String() - schema['pusherclientmap'] = config.String() schema['artworklocation'] = config.String() return schema @@ -63,6 +62,7 @@ def spotmop_client_factory(config, core): }), ]) application.listen(pusherport) + logger.info( 'Pusher server running on []:'+ str(pusherport) ) return [ @@ -88,4 +88,4 @@ def spotmop_client_factory(config, core): "path": spotmoppath, "default_filename": "index.html" }), - ] \ No newline at end of file + ] diff --git a/mopidy_spotmop/ext.conf b/mopidy_spotmop/ext.conf index 55c6bcf..c9fe6d5 100755 --- a/mopidy_spotmop/ext.conf +++ b/mopidy_spotmop/ext.conf @@ -2,5 +2,4 @@ enabled = true debug = false pusherport = 6681 -pusherclientmap = [{"ip":"192.168.0.152","name":"James"},{"ip":"192.168.0.139","name":"Dev server"},{"ip":"192.168.0.118","name":"Jeremy"}] artworklocation = /root/.local/share/mopidy/local-images/ \ No newline at end of file diff --git a/mopidy_spotmop/static/app.js b/mopidy_spotmop/static/app.js index de722dc..382312b 100644 --- a/mopidy_spotmop/static/app.js +++ b/mopidy_spotmop/static/app.js @@ -29973,7 +29973,7 @@ angular.module('spotmop', [ * Lazy loading **/ - $scope.checkForLazyLoading = function(){ + $scope.checkForLazyLoading = function(){ // get our ducks in a row - these are all the numbers we need var scrollPosition = $(document).scrollTop(); var frameHeight = $(window).height(); @@ -29983,7 +29983,13 @@ angular.module('spotmop', [ if( distanceFromBottom <= 100 ) $scope.$broadcast('spotmop:loadMore'); } + + // listen for completion from our loading bar (which intercepts all http requests) + $rootScope.$on('cfpLoadingBar:completed', function(event){ + $scope.checkForLazyLoading(); + }); + // listen for scrolling to load more stuff $(document).on('scroll', function( event ){ $scope.checkForLazyLoading(); @@ -30063,9 +30069,6 @@ angular.module('spotmop', [ $scope.$on('mopidy:state:online', function(){ Analytics.trackEvent('Mopidy', 'Online'); $rootScope.mopidyOnline = true; - MopidyService.getConsume().then( function( isConsume ){ - SettingsService.setSetting('mopidy',isConsume,'consume'); - }); }); $scope.$on('mopidy:state:offline', function(){ @@ -30396,7 +30399,6 @@ angular.module('spotmop.browse.album', []) if( response.artists ){ for( var i = 0; i < response.artists.length; i++ ){ var artist = response.artists[i]; - artist.images = $filter('sizedImages')(artist.images); $scope.album.artists.push( artist ); }; } @@ -30463,7 +30465,7 @@ angular.module('spotmop.browse.album', []) var callback = function(n){ return function( response ){ if( typeof(response.artist) !== 'undefined'){ - $scope.album.artists[n].images = $filter('sizedImages')(response.artist.image); + $scope.album.artists[n].images = response.artist.image; } }; }(i); @@ -30487,14 +30489,14 @@ angular.module('spotmop.browse.album', []) // we got images from mopidy! if( albumImages.length > 0 ){ - $scope.album.images = $filter('sizedImages')( albumImages ); + $scope.album.images = albumImages; // no mopidy artwork, so get album artwork from LastFM }else if( typeof( $scope.album.musicbrainz_id ) !== 'undefined' ){ LastfmService.albumInfoByMbid( $scope.album.musicbrainz_id ) .then( function( response ){ if( typeof(response.album) !== 'undefined' ){ - $scope.album.images = $filter('sizedImages')(response.album.image); + $scope.album.images = response.album.image; } }); @@ -30504,7 +30506,7 @@ angular.module('spotmop.browse.album', []) LastfmService.albumInfo( firstUniqueArtist.name.trim(), $scope.album.name.trim() ) .then( function( response ){ if( typeof(response.album) !== 'undefined' ){ - $scope.album.images = $filter('sizedImages')(response.album.image); + $scope.album.images = response.album.image; } }); } @@ -30638,7 +30640,7 @@ angular.module('spotmop.browse.artist', []) SpotifyService.getArtist( $stateParams.uri ) .then( function( response ){ $scope.artist = response; - $scope.artist.images = $filter('sizedImages')(response.images) + $scope.artist.images = response.images; }); // figure out if we're following this playlist @@ -30693,13 +30695,13 @@ angular.module('spotmop.browse.artist', []) if( typeof( $scope.artist.musicbrainz_id ) !== 'undefined' ){ LastfmService.artistInfoByMbid( $scope.artist.musicbrainz_id ) .then( function( response ){ - $scope.artist.images = $filter('sizedImages')(response.artist.image); + $scope.artist.images = response.artist.image; $scope.artist.stats = response.artist.stats; }); }else{ LastfmService.artistInfo( $scope.artist.name ) .then( function( response ){ - $scope.artist.images = $filter('sizedImages')(response.artist.image); + $scope.artist.images = response.artist.image; $scope.artist.stats = response.artist.stats; }); } @@ -30749,7 +30751,7 @@ angular.module('spotmop.browse.artist', []) var callback = function(n){ return function( response ){ if( typeof(response.album) !== 'undefined' ){ - $scope.albums.items[n].images = $filter('sizedImages')(response.album.image); + $scope.albums.items[n].images = response.album.image; } }; }(i); @@ -32241,12 +32243,13 @@ angular.module('spotmop.directives', []) * Figure out the best image to use for this set of image sizes * @return image obj **/ -.directive('thumbnail', ['$timeout', '$http', function( $timeout, $http ){ +.directive('thumbnail', ['$timeout', '$http', '$filter', function( $timeout, $http, $filter ){ return { restrict: 'E', scope: { images: '=', - size: '=' + size: '@', + debugging: '@' }, replace: true, // Replace with the template below transclude: true, // we want to insert custom content inside the directive @@ -32255,7 +32258,7 @@ angular.module('spotmop.directives', []) // load thumbnail on init loadThumbnail(); - // listen for changes to our image array (if we're swapping out objects, we need to swap the associated image too!) + // listen for changes to our image array and update when necessary $scope.$watch('images', function(oldValue,newValue){ loadThumbnail(); }); @@ -32263,76 +32266,36 @@ angular.module('spotmop.directives', []) // perform core functionality function loadThumbnail(){ + if( !$scope.images ){ + return false; + } + // fetch this instance's best thumbnail - $scope.image = getThumbnailImage( $scope.images ); + var image = $filter('sizedImages')($scope.images); + + // if we've been told a specific size (small|medium|large), get it + if( $scope.size ){ + image = image[$scope.size]; + + // otherwise just default to the smallest + }else{ + image = image.small; + } - // now actually go get the image - if( $scope.image ){ + // if we have an image + if( image && image != '' ){ $http({ method: 'GET', - url: $scope.image.url, + url: image, cache: true }).success( function(){ // inject to DOM once loaded - $element.css('background-image', 'url('+$scope.image.url+')' ); + $element.css('background-image', 'url('+image+')' ); }); } } - /** - * Get the most appropriate thumbnail image - * @param images = array of image urls - * @return string (image url) - **/ - function getThumbnailImage( images ){ - - // what if there are no images? then nada - if( images.length <= 0 ) - return false; - - // loop all the images - for( var i = 0; i < images.length; i++){ - var image = images[i]; - - // small thumbnails (ie search results) - if( $scope.size == 'small' ){ - - // this is our preferred size - if( image.height >= 100 && image.height <= 200 ){ - return image; - - // let's take it a notch up then - }else if( image.height > 200 && image.height <= 300 ){ - return image; - - // nope? let's take it the next notch up - }else if( image.height > 300 && image.height < 400 ){ - return image; - } - - // standard thumbnails (ie playlists, full related artists, etc) - }else{ - - // this is our preferred size - if( image.height >= 200 && image.height <= 300 ){ - return image; - - // let's take it a notch up then - }else if( image.height > 300 && image.height <= 500 ){ - return image; - - // nope? let's take it a notch down then - }else if( image.height >= 150 && image.height < 200 ){ - return image; - } - } - }; - - // no thumbnail that suits? just get the first (and highest res) one then - return images[0]; - } - }, template: '
' }; @@ -32533,14 +32496,13 @@ angular.module('spotmop.directives', []) /** **/ -.directive('backgroundparallax', ['$rootScope', '$timeout', '$interval', '$http', function( $rootScope, $timeout, $interval, $http ){ +.directive('backgroundparallax', ['$rootScope', '$timeout', '$interval', '$http', '$filter', function( $rootScope, $timeout, $interval, $http, $filter ){ return { restrict: 'E', terminal: true, scope: { - image: '@', // object - useproxy: '@', - detectbackground: '@', + images: '=', + image: '@', opacity: '@' }, link: function($scope, $element, $attrs){ @@ -32558,17 +32520,22 @@ angular.module('spotmop.directives', []) var scrollTop = 0; var canvasDOM = document.getElementById('backgroundparallax'); var context = canvasDOM.getContext('2d'); + var url = ''; + + // if we're using an explicit url, just use that + if( $scope.image ){ + url = $scope.image; + + // we're getting an array of images, so size 'em and get the largest + }else if( $scope.images ){ + var images = $filter('sizedImages')($scope.images); + url = images.large; + } var image = { width: 0, height: 0, - url: $scope.image + url: url } - - /* - REBUILD THIS TO USE TORNADO - if( $scope.useproxy ) - image.url = '/vendor/resource-proxy.php?url='+image.url; - */ // create our new image object (to be plugged into canvas) var imageObject = new Image(); @@ -32760,7 +32727,7 @@ angular.module('spotmop.directives', []) return function( images ){ // what if there are no images? then nada - if( images.length <= 0 ) + if( typeof(images) === 'undefined' || images.length <= 0 ) return false; var standardised = {}; @@ -32776,38 +32743,36 @@ angular.module('spotmop.directives', []) baseUrl += ':'+ SettingsService.getSetting('mopidyport', '6680') image.url = baseUrl +'/spotmop'+ image.uri; - if( image.height >= 650 ){ - - standardised.large = image.url; - - }else if( image.height <= 650 && image.height >= 250 ){ - - standardised.medium = image.url; - if( !standardised.large ) standardised.large = image.url; - - }else{ - if( !standardised.small ) standardised.small = image.url; - if( !standardised.medium ) standardised.medium = image.url; - if( !standardised.large ) standardised.large = image.url; + if( image.height ){ + if( image.height >= 650 ){ + standardised.large = image.url; + }else if( image.height >= 250 ){ + standardised.medium = image.url; + }else{ + standardised.small = image.url; + } } + + if( !standardised.small ) standardised.small = image.url; + if( !standardised.medium ) standardised.medium = image.url; + if( !standardised.large ) standardised.large = image.url; // spotify-styled images }else if( typeof(image.height) !== 'undefined' ){ - - if( image.height >= 650 ){ - - standardised.large = image.url; - - }else if( image.height <= 650 && image.height >= 250 ){ - - standardised.medium = image.url; - if( !standardised.large ) standardised.large = image.url; - - }else{ - if( !standardised.small ) standardised.small = image.url; - if( !standardised.medium ) standardised.medium = image.url; - if( !standardised.large ) standardised.large = image.url; + + if( image.height ){ + if( image.height >= 650 ){ + standardised.large = image.url; + }else if( image.height >= 300 ){ + standardised.medium = image.url; + }else{ + standardised.small = image.url; + } } + + if( !standardised.small ) standardised.small = image.url; + if( !standardised.medium ) standardised.medium = image.url; + if( !standardised.large ) standardised.large = image.url; // lastFM styled images }else if( typeof(image['#text']) !== 'undefined' ){ @@ -33997,10 +33962,10 @@ angular.module('spotmop.library', []) $scope.show = function( playlist ){ if( - typeof($scope.settings.playlists) === 'undefined' || - typeof($scope.settings.playlists.onlyshowowned) === 'undefined' || - !$scope.settings.playlists.onlyshowowned ){ - return true; + typeof($scope.settings.playlists) === 'undefined' || + typeof($scope.settings.playlists.onlyshowowned) === 'undefined' || + !$scope.settings.playlists.onlyshowowned ){ + return true; } if( playlist.owner.id == 'jaedb' ) return true; @@ -34016,27 +33981,44 @@ angular.module('spotmop.library', []) SpotifyService.getPlaylists( userid ) .then( function( response ){ // successful - $scope.playlists = response; // if it was 401, refresh token - if( typeof(response.error) !== 'undefined' && response.error.status == 401 ) + if( typeof(response.error) !== 'undefined' && response.error.status == 401 ){ Spotify.refreshToken(); + }else{ + $scope.playlists = response; + } }); // not authorized, so have to fetch via backend first - }else{ - - NotifyService.notify('Fetching from Mopidy as you haven\'t authorized Spotify. This will take a while!'); + }else{ function fetchPlaylists(){ MopidyService.getPlaylists() - .then( function( response ){ - // fetch more detail from each playlist (individually, d'oh!) - angular.forEach( response, function(value, key){ - SpotifyService.getPlaylist( value.uri ) - .then( function( playlist ){ - $scope.playlists.items.push( playlist ); - }); + .then( function( response ){ + + // add them to our list + $scope.playlists.items = response; + + // now go get the extra info (and artwork) from Spotify + // need to do this individually as there is no bulk endpoint, curses! + angular.forEach( response, function(playlist, i){ + + // process it and add to our $scope + var callback = function(i){ + return function( response ){ + + // make sure our response was not an error + if( typeof(response.error) === 'undefined' ){ + + // update the existing playlist item with our updated data + $scope.playlists.items[i] = response; + } + }; + }(i); + + // run the actual request + SpotifyService.getPlaylist( playlist.uri ).then( callback ); }); }); } @@ -34048,6 +34030,7 @@ angular.module('spotmop.library', []) $scope.$on('mopidy:state:online', function(){ fetchPlaylists(); }); } + /** * Load more of the album's tracks * Triggered by scrolling to the bottom @@ -34584,6 +34567,9 @@ angular.module('spotmop.player', [ $scope.toggleMute = function(){ PlayerService.toggleMute(); }; + $scope.toggleConsume = function(){ + PlayerService.toggleConsume(); + }; /** @@ -34627,6 +34613,7 @@ angular.module('spotmop.services.player', []) isRepeat: false, isRandom: false, isMute: false, + isConsume: false, volume: 100, playPosition: 0, currentTlTrack: false, @@ -34706,6 +34693,9 @@ angular.module('spotmop.services.player', []) MopidyService.getMute().then( function(isMute){ state.isMute = isMute; }); + MopidyService.getConsume().then( function( isConsume ){ + state.isConsume = isConsume; + }); } // listen for current track changes @@ -35050,6 +35040,12 @@ angular.module('spotmop.services.player', []) MopidyService.setMute( false ).then( function(response){ state.isMute = false; } ); else MopidyService.setMute( true ).then( function(response){ state.isMute = true; } ); + }, + toggleConsume: function(){ + if( state.isConsume ) + MopidyService.setConsume( false ).then( function(response){ state.isConsume = false; } ); + else + MopidyService.setConsume( true ).then( function(response){ state.isConsume = true; } ); } }; @@ -36095,39 +36091,24 @@ angular.module('spotmop.services.mopidy', [ }, playStream: function( streamUri, expectedTrackCount ){ + cfpLoadingBar.start(); + cfpLoadingBar.set(0.25); + var self = this; - // pre-fetch our playlist tracks - self.mopidy.library.lookup({ uri: streamUri }) - .then( function(tracks){ - - // if we haven't got as many tracks as expected - // wait 2s before adding to tracklist (to allow mopidy to continue loading them in the background) - if( typeof(expectedTrackCount) !== 'undefined' && tracks.length != expectedTrackCount ){ - console.info(streamUri+ ' expecting '+expectedTrackCount+' tracks, got '+tracks.length+'. Waiting 1 second for server to pre-load playlist...'); - $timeout( function(){ - playStream(); - }, 1000 ); - - // we have the expected track count already (already loaded/cached), go-go-gadget! - }else{ - playStream(); - } - }, consoleError ); - - // play the stream - function playStream(){ - self.stopPlayback(true) - .then(function() { - self.mopidy.tracklist.clear(); - }, consoleError) - .then(function() { - self.mopidy.tracklist.add({ at_position: 0, uri: streamUri }); - }, consoleError) - .then(function() { - self.mopidy.playback.play(); - }, consoleError); - } + self.stopPlayback(true) + .then(function() { + self.mopidy.tracklist.clear(); + }, consoleError) + .then(function() { + self.mopidy.tracklist.add({ at_position: 0, uri: streamUri }) + .then( function(){ + cfpLoadingBar.complete(); + }); + }, consoleError) + .then(function() { + self.mopidy.playback.play(); + }, consoleError); }, play: function(){ return wrapMopidyFunc("mopidy.playback.play", this)(); @@ -37031,15 +37012,15 @@ angular.module('spotmop.services.spotify', []) getMyAlbums: function( userid, limit, offset ){ + var deferred = $q.defer(); + if( !this.isAuthorized() ){ deferred.reject(); return deferred.promise; } - if( typeof( limit ) === 'undefined' || !limit ) limit = 40; + if( typeof( limit ) === 'undefined' || !limit ) limit = 20; if( typeof( offset ) === 'undefined' ) offset = 0; - - var deferred = $q.defer(); $http({ cache: true, @@ -37050,34 +37031,7 @@ angular.module('spotmop.services.spotify', []) } }) .success(function( response ){ - - var readyToResolve = false; - var completeAlbums = []; - var batchesRequired = Math.ceil( response.items.length / 20 ); - - // batch our requests - Spotify only allows a max of 20 albums per request, d'oh! - for( var batchCounter = 1; batchCounter <= batchesRequired; batchCounter++ ){ - - var batch = response.items.splice(0,20); - var albumids = []; - - // loop all our albums to build a list of all the album ids we need - var batchLimiter = 20; - if( batch.length < 20 ) batchLimiter = batch.length; - for( var i = 0; i < batchLimiter; i++ ){ - albumids.push( batch[i].album.id ); - }; - - // go get the albums - service.getAlbums( albumids ) - .then( function(albums){ - completeAlbums = completeAlbums.concat( albums.albums ); - if( batchCounter >= batchesRequired ){ - response.items = completeAlbums; - deferred.resolve( response ); - } - }); - } + deferred.resolve( response ); }) .error(function( response ){ NotifyService.error( response.error.message ); diff --git a/mopidy_spotmop/static/app.min.js b/mopidy_spotmop/static/app.min.js index 40de8e2..26221fb 100644 --- a/mopidy_spotmop/static/app.min.js +++ b/mopidy_spotmop/static/app.min.js @@ -1,6 +1,6 @@ /** * Mopidy-Spotmop - * Built 2016-06-08 + * Built 2016-07-02 **/ !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){function c(a){var b="length"in a&&a.length,c=_.type(a);return"function"===c||_.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}function d(a,b,c){if(_.isFunction(b))return _.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return _.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(ha.test(b))return _.filter(b,a,c);b=_.filter(b,a)}return _.grep(a,function(a){return U.call(b,a)>=0!==c})}function e(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function f(a){var b=oa[a]={};return _.each(a.match(na)||[],function(a,c){b[c]=!0}),b}function g(){Z.removeEventListener("DOMContentLoaded",g,!1),a.removeEventListener("load",g,!1),_.ready()}function h(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=_.expando+h.uid++}function i(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(ua,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:ta.test(c)?_.parseJSON(c):c}catch(e){}sa.set(a,b,c)}else c=void 0;return c}function j(){return!0}function k(){return!1}function l(){try{return Z.activeElement}catch(a){}}function m(a,b){return _.nodeName(a,"table")&&_.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function n(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function o(a){var b=Ka.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function p(a,b){for(var c=0,d=a.length;d>c;c++)ra.set(a[c],"globalEval",!b||ra.get(b[c],"globalEval"))}function q(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(ra.hasData(a)&&(f=ra.access(a),g=ra.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)_.event.add(b,e,j[e][c])}sa.hasData(a)&&(h=sa.access(a),i=_.extend({},h),sa.set(b,i))}}function r(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&_.nodeName(a,b)?_.merge([a],c):c}function s(a,b){var c=b.nodeName.toLowerCase();"input"===c&&ya.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function t(b,c){var d,e=_(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:_.css(e[0],"display");return e.detach(),f}function u(a){var b=Z,c=Oa[a];return c||(c=t(a,b),"none"!==c&&c||(Na=(Na||_("")).appendTo(b.documentElement),b=Na[0].contentDocument,b.write(),b.close(),c=t(a,b),Na.detach()),Oa[a]=c),c}function v(a,b,c){var d,e,f,g,h=a.style;return c=c||Ra(a),c&&(g=c.getPropertyValue(b)||c[b]),c&&(""!==g||_.contains(a.ownerDocument,a)||(g=_.style(a,b)),Qa.test(g)&&Pa.test(b)&&(d=h.width,e=h.minWidth,f=h.maxWidth,h.minWidth=h.maxWidth=h.width=g,g=c.width,h.width=d,h.minWidth=e,h.maxWidth=f)),void 0!==g?g+"":g}function w(a,b){return{get:function(){return a()?void delete this.get:(this.get=b).apply(this,arguments)}}}function x(a,b){if(b in a)return b;for(var c=b[0].toUpperCase()+b.slice(1),d=b,e=Xa.length;e--;)if(b=Xa[e]+c,b in a)return b;return d}function y(a,b,c){var d=Ta.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function z(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=_.css(a,c+wa[f],!0,e)),d?("content"===c&&(g-=_.css(a,"padding"+wa[f],!0,e)),"margin"!==c&&(g-=_.css(a,"border"+wa[f]+"Width",!0,e))):(g+=_.css(a,"padding"+wa[f],!0,e),"padding"!==c&&(g+=_.css(a,"border"+wa[f]+"Width",!0,e)));return g}function A(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=Ra(a),g="border-box"===_.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=v(a,b,f),(0>e||null==e)&&(e=a.style[b]),Qa.test(e))return e;d=g&&(Y.boxSizingReliable()||e===a.style[b]),e=parseFloat(e)||0}return e+z(a,b,c||(g?"border":"content"),d,f)+"px"}function B(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=ra.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&xa(d)&&(f[g]=ra.access(d,"olddisplay",u(d.nodeName)))):(e=xa(d),"none"===c&&e||ra.set(d,"olddisplay",e?c:_.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function C(a,b,c,d,e){return new C.prototype.init(a,b,c,d,e)}function D(){return setTimeout(function(){Ya=void 0}),Ya=_.now()}function E(a,b){var c,d=0,e={height:a};for(b=b?1:0;4>d;d+=2-b)c=wa[d],e["margin"+c]=e["padding"+c]=a;return b&&(e.opacity=e.width=a),e}function F(a,b,c){for(var d,e=(cb[b]||[]).concat(cb["*"]),f=0,g=e.length;g>f;f++)if(d=e[f].call(c,b,a))return d}function G(a,b,c){var d,e,f,g,h,i,j,k,l=this,m={},n=a.style,o=a.nodeType&&xa(a),p=ra.get(a,"fxshow");c.queue||(h=_._queueHooks(a,"fx"),null==h.unqueued&&(h.unqueued=0,i=h.empty.fire,h.empty.fire=function(){h.unqueued||i()}),h.unqueued++,l.always(function(){l.always(function(){h.unqueued--,_.queue(a,"fx").length||h.empty.fire()})})),1===a.nodeType&&("height"in b||"width"in b)&&(c.overflow=[n.overflow,n.overflowX,n.overflowY],j=_.css(a,"display"),k="none"===j?ra.get(a,"olddisplay")||u(a.nodeName):j,"inline"===k&&"none"===_.css(a,"float")&&(n.display="inline-block")),c.overflow&&(n.overflow="hidden",l.always(function(){n.overflow=c.overflow[0],n.overflowX=c.overflow[1],n.overflowY=c.overflow[2]}));for(d in b)if(e=b[d],$a.exec(e)){if(delete b[d],f=f||"toggle"===e,e===(o?"hide":"show")){if("show"!==e||!p||void 0===p[d])continue;o=!0}m[d]=p&&p[d]||_.style(a,d)}else j=void 0;if(_.isEmptyObject(m))"inline"===("none"===j?u(a.nodeName):j)&&(n.display=j);else{p?"hidden"in p&&(o=p.hidden):p=ra.access(a,"fxshow",{}),f&&(p.hidden=!o),o?_(a).show():l.done(function(){_(a).hide()}),l.done(function(){var b;ra.remove(a,"fxshow");for(b in m)_.style(a,b,m[b])});for(d in m)g=F(o?p[d]:0,d,l),d in p||(p[d]=g.start,o&&(g.end=g.start,g.start="width"===d||"height"===d?1:0))}}function H(a,b){var c,d,e,f,g;for(c in a)if(d=_.camelCase(c),e=b[d],f=a[c],_.isArray(f)&&(e=f[1],f=a[c]=f[0]),c!==d&&(a[d]=f,delete a[c]),g=_.cssHooks[d],g&&"expand"in g){f=g.expand(f),delete a[d];for(c in f)c in a||(a[c]=f[c],b[c]=e)}else b[d]=e}function I(a,b,c){var d,e,f=0,g=bb.length,h=_.Deferred().always(function(){delete i.elem}),i=function(){if(e)return!1;for(var b=Ya||D(),c=Math.max(0,j.startTime+j.duration-b),d=c/j.duration||0,f=1-d,g=0,i=j.tweens.length;i>g;g++)j.tweens[g].run(f);return h.notifyWith(a,[j,f,c]),1>f&&i?c:(h.resolveWith(a,[j]),!1)},j=h.promise({elem:a,props:_.extend({},b),opts:_.extend(!0,{specialEasing:{}},c),originalProperties:b,originalOptions:c,startTime:Ya||D(),duration:c.duration,tweens:[],createTween:function(b,c){var d=_.Tween(a,j.opts,b,c,j.opts.specialEasing[b]||j.opts.easing);return j.tweens.push(d),d},stop:function(b){var c=0,d=b?j.tweens.length:0;if(e)return this;for(e=!0;d>c;c++)j.tweens[c].run(1);return b?h.resolveWith(a,[j,b]):h.rejectWith(a,[j,b]),this}}),k=j.props;for(H(k,j.opts.specialEasing);g>f;f++)if(d=bb[f].call(j,a,k,j.opts))return d;return _.map(k,F,j),_.isFunction(j.opts.start)&&j.opts.start.call(a,j),_.fx.timer(_.extend(i,{elem:a,anim:j,queue:j.opts.queue})),j.progress(j.opts.progress).done(j.opts.done,j.opts.complete).fail(j.opts.fail).always(j.opts.always)}function J(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(na)||[];if(_.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function K(a,b,c,d){function e(h){var i;return f[h]=!0,_.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||g||f[j]?g?!(i=j):void 0:(b.dataTypes.unshift(j),e(j),!1)}),i}var f={},g=a===tb;return e(b.dataTypes[0])||!f["*"]&&e("*")}function L(a,b){var c,d,e=_.ajaxSettings.flatOptions||{};for(c in b)void 0!==b[c]&&((e[c]?a:d||(d={}))[c]=b[c]);return d&&_.extend(!0,a,d),a}function M(a,b,c){for(var d,e,f,g,h=a.contents,i=a.dataTypes;"*"===i[0];)i.shift(),void 0===d&&(d=a.mimeType||b.getResponseHeader("Content-Type"));if(d)for(e in h)if(h[e]&&h[e].test(d)){i.unshift(e);break}if(i[0]in c)f=i[0];else{for(e in c){if(!i[0]||a.converters[e+" "+i[0]]){f=e;break}g||(g=e)}f=f||g}return f?(f!==i[0]&&i.unshift(f),c[f]):void 0}function N(a,b,c,d){var e,f,g,h,i,j={},k=a.dataTypes.slice();if(k[1])for(g in a.converters)j[g.toLowerCase()]=a.converters[g];for(f=k.shift();f;)if(a.responseFields[f]&&(c[a.responseFields[f]]=b),!i&&d&&a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i=f,f=k.shift())if("*"===f)f=i;else if("*"!==i&&i!==f){if(g=j[i+" "+f]||j["* "+f],!g)for(e in j)if(h=e.split(" "),h[1]===f&&(g=j[i+" "+h[0]]||j["* "+h[0]])){g===!0?g=j[e]:j[e]!==!0&&(f=h[0],k.unshift(h[1]));break}if(g!==!0)if(g&&a["throws"])b=g(b);else try{b=g(b)}catch(l){return{state:"parsererror",error:g?l:"No conversion from "+i+" to "+f}}}return{state:"success",data:b}}function O(a,b,c,d){var e;if(_.isArray(b))_.each(b,function(b,e){c||yb.test(a)?d(a,e):O(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==_.type(b))d(a,b);else for(e in b)O(a+"["+e+"]",b[e],c,d)}function P(a){return _.isWindow(a)?a:9===a.nodeType&&a.defaultView}var Q=[],R=Q.slice,S=Q.concat,T=Q.push,U=Q.indexOf,V={},W=V.toString,X=V.hasOwnProperty,Y={},Z=a.document,$="2.1.4",_=function(a,b){return new _.fn.init(a,b)},aa=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,ba=/^-ms-/,ca=/-([\da-z])/gi,da=function(a,b){return b.toUpperCase()};_.fn=_.prototype={jquery:$,constructor:_,selector:"",length:0,toArray:function(){return R.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:R.call(this)},pushStack:function(a){var b=_.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return _.each(this,a,b)},map:function(a){return this.pushStack(_.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(R.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:T,sort:Q.sort,splice:Q.splice},_.extend=_.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||_.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(_.isPlainObject(d)||(e=_.isArray(d)))?(e?(e=!1,f=c&&_.isArray(c)?c:[]):f=c&&_.isPlainObject(c)?c:{},g[b]=_.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},_.extend({expando:"jQuery"+($+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===_.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!_.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==_.type(a)||a.nodeType||_.isWindow(a)?!1:a.constructor&&!X.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?V[W.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=_.trim(a),a&&(1===a.indexOf("use strict")?(b=Z.createElement("script"),b.text=a,Z.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(ba,"ms-").replace(ca,da)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;g>f&&(e=b.apply(a[f],d),e!==!1);f++);else for(f in a)if(e=b.apply(a[f],d),e===!1)break}else if(h)for(;g>f&&(e=b.call(a[f],f,a[f]),e!==!1);f++);else for(f in a)if(e=b.call(a[f],f,a[f]),e===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(aa,"")},makeArray:function(a,b){var d=b||[];return null!=a&&(c(Object(a))?_.merge(d,"string"==typeof a?[a]:a):T.call(d,a)),d},inArray:function(a,b,c){return null==b?-1:U.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,d){var e,f=0,g=a.length,h=c(a),i=[];if(h)for(;g>f;f++)e=b(a[f],f,d),null!=e&&i.push(e);else for(f in a)e=b(a[f],f,d),null!=e&&i.push(e);return S.apply([],i)},guid:1,proxy:function(a,b){var c,d,e;return"string"==typeof b&&(c=a[b],b=a,a=c),_.isFunction(a)?(d=R.call(arguments,2),e=function(){return a.apply(b||this,d.concat(R.call(arguments)))},e.guid=a.guid=a.guid||_.guid++,e):void 0},now:Date.now,support:Y}),_.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){V["[object "+b+"]"]=b.toLowerCase()});var ea=function(a){function b(a,b,c,d){var e,f,g,h,i,j,l,n,o,p;if((b?b.ownerDocument||b:O)!==G&&F(b),b=b||G,c=c||[],h=b.nodeType,"string"!=typeof a||!a||1!==h&&9!==h&&11!==h)return c;if(!d&&I){if(11!==h&&(e=sa.exec(a)))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&M(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return $.apply(c,b.getElementsByTagName(a)),c;if((g=e[3])&&v.getElementsByClassName)return $.apply(c,b.getElementsByClassName(g)),c}if(v.qsa&&(!J||!J.test(a))){if(n=l=N,o=b,p=1!==h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=z(a),(l=b.getAttribute("id"))?n=l.replace(ua,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=ta.test(a)&&k(b.parentNode)||b,p=j.join(",")}if(p)try{return $.apply(c,o.querySelectorAll(p)),c}catch(q){}finally{l||b.removeAttribute("id")}}}return B(a.replace(ia,"$1"),b,c,d)}function c(){function a(c,d){return b.push(c+" ")>w.cacheLength&&delete a[b.shift()],a[c+" "]=d}var b=[];return a}function d(a){return a[N]=!0,a}function e(a){var b=G.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function f(a,b){for(var c=a.split("|"),d=a.length;d--;)w.attrHandle[c[d]]=b}function g(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||V)-(~a.sourceIndex||V);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function h(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function i(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function j(a){return d(function(b){return b=+b,d(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function k(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}function l(){}function m(a){for(var b=0,c=a.length,d="";c>b;b++)d+=a[b].value;return d}function n(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=Q++;return b.first?function(b,c,f){for(;b=b[d];)if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[P,f];if(g){for(;b=b[d];)if((1===b.nodeType||e)&&a(b,c,g))return!0}else for(;b=b[d];)if(1===b.nodeType||e){if(i=b[N]||(b[N]={}),(h=i[d])&&h[0]===P&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function o(a){return a.length>1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,c,d){for(var e=0,f=c.length;f>e;e++)b(a,c[e],d);return d}function q(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function r(a,b,c,e,f,g){return e&&!e[N]&&(e=r(e)),f&&!f[N]&&(f=r(f,g)),d(function(d,g,h,i){var j,k,l,m=[],n=[],o=g.length,r=d||p(b||"*",h.nodeType?[h]:h,[]),s=!a||!d&&b?r:q(r,m,a,h,i),t=c?f||(d?a:o||e)?[]:g:s;if(c&&c(s,t,h,i),e)for(j=q(t,n),e(j,[],h,i),k=j.length;k--;)(l=j[k])&&(t[n[k]]=!(s[n[k]]=l));if(d){if(f||a){if(f){for(j=[],k=t.length;k--;)(l=t[k])&&j.push(s[k]=l);f(null,t=[],j,i)}for(k=t.length;k--;)(l=t[k])&&(j=f?aa(d,l):m[k])>-1&&(d[j]=!(g[j]=l))}}else t=q(t===g?t.splice(o,t.length):t),f?f(null,g,t,i):$.apply(g,t)})}function s(a){for(var b,c,d,e=a.length,f=w.relative[a[0].type],g=f||w.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return aa(b,a)>-1},g,!0),k=[function(a,c,d){var e=!f&&(d||c!==C)||((b=c).nodeType?i(a,c,d):j(a,c,d));return b=null,e}];e>h;h++)if(c=w.relative[a[h].type])k=[n(o(k),c)];else{if(c=w.filter[a[h].type].apply(null,a[h].matches),c[N]){for(d=++h;e>d&&!w.relative[a[d].type];d++);return r(h>1&&o(k),h>1&&m(a.slice(0,h-1).concat({value:" "===a[h-2].type?"*":""})).replace(ia,"$1"),c,d>h&&s(a.slice(h,d)),e>d&&s(a=a.slice(d)),e>d&&m(a))}k.push(c)}return o(k)}function t(a,c){var e=c.length>0,f=a.length>0,g=function(d,g,h,i,j){var k,l,m,n=0,o="0",p=d&&[],r=[],s=C,t=d||f&&w.find.TAG("*",j),u=P+=null==s?1:Math.random()||.1,v=t.length;for(j&&(C=g!==G&&g);o!==v&&null!=(k=t[o]);o++){if(f&&k){for(l=0;m=a[l++];)if(m(k,g,h)){i.push(k);break}j&&(P=u)}e&&((k=!m&&k)&&n--,d&&p.push(k))}if(n+=o,e&&o!==n){for(l=0;m=c[l++];)m(p,r,g,h);if(d){if(n>0)for(;o--;)p[o]||r[o]||(r[o]=Y.call(i));r=q(r)}$.apply(i,r),j&&!d&&r.length>0&&n+c.length>1&&b.uniqueSort(i)}return j&&(P=u,C=s),p};return e?d(g):g}var u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+1*new Date,O=a.document,P=0,Q=0,R=c(),S=c(),T=c(),U=function(a,b){return a===b&&(E=!0),0},V=1<<31,W={}.hasOwnProperty,X=[],Y=X.pop,Z=X.push,$=X.push,_=X.slice,aa=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},ba="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",ca="[\\x20\\t\\r\\n\\f]",da="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",ea=da.replace("w","w#"),fa="\\["+ca+"*("+da+")(?:"+ca+"*([*^$|!~]?=)"+ca+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+ea+"))|)"+ca+"*\\]",ga=":("+da+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+fa+")*)|.*)\\)|)",ha=new RegExp(ca+"+","g"),ia=new RegExp("^"+ca+"+|((?:^|[^\\\\])(?:\\\\.)*)"+ca+"+$","g"),ja=new RegExp("^"+ca+"*,"+ca+"*"),ka=new RegExp("^"+ca+"*([>+~]|"+ca+")"+ca+"*"),la=new RegExp("="+ca+"*([^\\]'\"]*?)"+ca+"*\\]","g"),ma=new RegExp(ga),na=new RegExp("^"+ea+"$"),oa={ID:new RegExp("^#("+da+")"),CLASS:new RegExp("^\\.("+da+")"),TAG:new RegExp("^("+da.replace("w","w*")+")"),ATTR:new RegExp("^"+fa),PSEUDO:new RegExp("^"+ga),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+ca+"*(even|odd|(([+-]|)(\\d*)n|)"+ca+"*(?:([+-]|)"+ca+"*(\\d+)|))"+ca+"*\\)|)","i"),bool:new RegExp("^(?:"+ba+")$","i"),needsContext:new RegExp("^"+ca+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+ca+"*((?:-\\d)?\\d*)"+ca+"*\\)|)(?=[^-]|$)","i")},pa=/^(?:input|select|textarea|button)$/i,qa=/^h\d$/i,ra=/^[^{]+\{\s*\[native \w/,sa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ta=/[+~]/,ua=/'|\\/g,va=new RegExp("\\\\([\\da-f]{1,6}"+ca+"?|("+ca+")|.)","ig"),wa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},xa=function(){F()};try{$.apply(X=_.call(O.childNodes),O.childNodes),X[O.childNodes.length].nodeType}catch(ya){$={apply:X.length?function(a,b){Z.apply(a,_.call(b))}:function(a,b){for(var c=a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}v=b.support={},y=b.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},F=b.setDocument=function(a){var b,c,d=a?a.ownerDocument||a:O;return d!==G&&9===d.nodeType&&d.documentElement?(G=d,H=d.documentElement,c=d.defaultView,c&&c!==c.top&&(c.addEventListener?c.addEventListener("unload",xa,!1):c.attachEvent&&c.attachEvent("onunload",xa)),I=!y(d),v.attributes=e(function(a){return a.className="i",!a.getAttribute("className")}),v.getElementsByTagName=e(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),v.getElementsByClassName=ra.test(d.getElementsByClassName),v.getById=e(function(a){return H.appendChild(a).id=N,!d.getElementsByName||!d.getElementsByName(N).length}),v.getById?(w.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&I){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},w.filter.ID=function(a){var b=a.replace(va,wa);return function(a){return a.getAttribute("id")===b}}):(delete w.find.ID,w.filter.ID=function(a){var b=a.replace(va,wa);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),w.find.TAG=v.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):v.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},w.find.CLASS=v.getElementsByClassName&&function(a,b){return I?b.getElementsByClassName(a):void 0},K=[],J=[],(v.qsa=ra.test(d.querySelectorAll))&&(e(function(a){H.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&J.push("[*^$]="+ca+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||J.push("\\["+ca+"*(?:value|"+ba+")"),a.querySelectorAll("[id~="+N+"-]").length||J.push("~="),a.querySelectorAll(":checked").length||J.push(":checked"),a.querySelectorAll("a#"+N+"+*").length||J.push(".#.+[+~]")}),e(function(a){var b=d.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&J.push("name"+ca+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||J.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),J.push(",.*:")})),(v.matchesSelector=ra.test(L=H.matches||H.webkitMatchesSelector||H.mozMatchesSelector||H.oMatchesSelector||H.msMatchesSelector))&&e(function(a){v.disconnectedMatch=L.call(a,"div"),L.call(a,"[s!='']:x"),K.push("!=",ga)}),J=J.length&&new RegExp(J.join("|")),K=K.length&&new RegExp(K.join("|")),b=ra.test(H.compareDocumentPosition),M=b||ra.test(H.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},U=b?function(a,b){if(a===b)return E=!0,0;var c=!a.compareDocumentPosition-!b.compareDocumentPosition;return c?c:(c=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&c||!v.sortDetached&&b.compareDocumentPosition(a)===c?a===d||a.ownerDocument===O&&M(O,a)?-1:b===d||b.ownerDocument===O&&M(O,b)?1:D?aa(D,a)-aa(D,b):0:4&c?-1:1)}:function(a,b){if(a===b)return E=!0,0;var c,e=0,f=a.parentNode,h=b.parentNode,i=[a],j=[b];if(!f||!h)return a===d?-1:b===d?1:f?-1:h?1:D?aa(D,a)-aa(D,b):0;if(f===h)return g(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?g(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},d):G},b.matches=function(a,c){return b(a,null,null,c)},b.matchesSelector=function(a,c){if((a.ownerDocument||a)!==G&&F(a),c=c.replace(la,"='$1']"),!(!v.matchesSelector||!I||K&&K.test(c)||J&&J.test(c)))try{var d=L.call(a,c);if(d||v.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return b(c,G,null,[a]).length>0},b.contains=function(a,b){return(a.ownerDocument||a)!==G&&F(a),M(a,b)},b.attr=function(a,b){(a.ownerDocument||a)!==G&&F(a);var c=w.attrHandle[b.toLowerCase()],d=c&&W.call(w.attrHandle,b.toLowerCase())?c(a,b,!I):void 0;return void 0!==d?d:v.attributes||!I?a.getAttribute(b):(d=a.getAttributeNode(b))&&d.specified?d.value:null},b.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},b.uniqueSort=function(a){var b,c=[],d=0,e=0;if(E=!v.detectDuplicates,D=!v.sortStable&&a.slice(0),a.sort(U),E){for(;b=a[e++];)b===a[e]&&(d=c.push(e));for(;d--;)a.splice(c[d],1)}return D=null,a},x=b.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=x(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d++];)c+=x(b);return c},w=b.selectors={cacheLength:50,createPseudo:d,match:oa,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(va,wa),a[3]=(a[3]||a[4]||a[5]||"").replace(va,wa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||b.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&b.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return oa.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&ma.test(c)&&(b=z(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(va,wa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=R[a+" "];return b||(b=new RegExp("(^|"+ca+")"+a+"("+ca+"|$)"))&&R(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,c,d){return function(e){var f=b.attr(e,a);return null==f?"!="===c:c?(f+="","="===c?f===d:"!="===c?f!==d:"^="===c?d&&0===f.indexOf(d):"*="===c?d&&f.indexOf(d)>-1:"$="===c?d&&f.slice(-d.length)===d:"~="===c?(" "+f.replace(ha," ")+" ").indexOf(d)>-1:"|="===c?f===d||f.slice(0,d.length+1)===d+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===P&&j[1],m=j[0]===P&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[P,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===P)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[P,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,c){var e,f=w.pseudos[a]||w.setFilters[a.toLowerCase()]||b.error("unsupported pseudo: "+a);return f[N]?f(c):f.length>1?(e=[a,a,"",c],w.setFilters.hasOwnProperty(a.toLowerCase())?d(function(a,b){for(var d,e=f(a,c),g=e.length;g--;)d=aa(a,e[g]),a[d]=!(b[d]=e[g])}):function(a){return f(a,0,e)}):f}},pseudos:{not:d(function(a){var b=[],c=[],e=A(a.replace(ia,"$1"));return e[N]?d(function(a,b,c,d){for(var f,g=e(a,null,d,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,d,f){return b[0]=a,e(b,null,f,c),b[0]=null,!c.pop()}}),has:d(function(a){return function(c){return b(a,c).length>0}}),contains:d(function(a){return a=a.replace(va,wa),function(b){return(b.textContent||b.innerText||x(b)).indexOf(a)>-1}}),lang:d(function(a){return na.test(a||"")||b.error("unsupported lang: "+a),a=a.replace(va,wa).toLowerCase(),function(b){var c;do if(c=I?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===H},focus:function(a){return a===G.activeElement&&(!G.hasFocus||G.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!w.pseudos.empty(a)},header:function(a){return qa.test(a.nodeName)},input:function(a){return pa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:j(function(){return[0]}),last:j(function(a,b){return[b-1]}),eq:j(function(a,b,c){return[0>c?c+b:c]}),even:j(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:j(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:j(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:j(function(a,b,c){for(var d=0>c?c+b:c;++d2&&"ID"===(g=f[0]).type&&v.getById&&9===b.nodeType&&I&&w.relative[f[1].type]){if(b=(w.find.ID(g.matches[0].replace(va,wa),b)||[])[0],!b)return c;j&&(b=b.parentNode),a=a.slice(f.shift().value.length)}for(e=oa.needsContext.test(a)?0:f.length;e--&&(g=f[e],!w.relative[h=g.type]);)if((i=w.find[h])&&(d=i(g.matches[0].replace(va,wa),ta.test(f[0].type)&&k(b.parentNode)||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return $.apply(c,d),c;break}}return(j||A(a,l))(d,b,!I,c,ta.test(a)&&k(b.parentNode)||b),c},v.sortStable=N.split("").sort(U).join("")===N,v.detectDuplicates=!!E,F(),v.sortDetached=e(function(a){return 1&a.compareDocumentPosition(G.createElement("div"))}),e(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||f("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),v.attributes&&e(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||f("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),e(function(a){return null==a.getAttribute("disabled")})||f(ba,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),b}(a);_.find=ea,_.expr=ea.selectors,_.expr[":"]=_.expr.pseudos,_.unique=ea.uniqueSort,_.text=ea.getText,_.isXMLDoc=ea.isXML,_.contains=ea.contains;var fa=_.expr.match.needsContext,ga=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,ha=/^.[^:#\[\.,]*$/;_.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?_.find.matchesSelector(d,a)?[d]:[]:_.find.matches(a,_.grep(b,function(a){return 1===a.nodeType}))},_.fn.extend({find:function(a){var b,c=this.length,d=[],e=this; @@ -11,10 +11,10 @@ $httpBackend:yb,$location:Qb,$log:Rb,$parse:hc,$rootScope:mc,$q:ic,$$q:jc,$sce:r })}),e},d.findModels=function(a,b,c){for(var d=["ng-","data-ng-","ng\\:"],e=0;ep)){var b=a.touches&&a.touches.length?a.touches:[a],d=b[0].clientX,e=b[0].clientY;1>d&&1>e||m&&m[0]===d&&m[1]===e||(m&&(m=null),"label"===c(a.target)&&(m=[d,e]),g(l,d,e)||(a.stopPropagation(),a.preventDefault(),a.target&&a.target.blur&&a.target.blur()))}}function i(a){var b=a.touches&&a.touches.length?a.touches:[a],c=b[0].clientX,e=b[0].clientY;l.push(c,e),d(function(){for(var a=0;ac&&o>t&&(j(r,s),g&&g.blur(),b.isDefined(e.disabled)&&e.disabled!==!1||d.triggerHandler("click",[a])),f()}),d.onclick=function(a){},d.on("click",function(a,b){c.$apply(function(){l(c,{$event:b||a})})}),d.on("mousedown",function(a){d.addClass(r)}),d.on("mousemove mouseup",function(a){d.removeClass(r)})}}];e("ngSwipeLeft",-1,"swipeleft"),e("ngSwipeRight",1,"swiperight")}(window,window.angular),function(a,b,c){"use strict";function d(a,c,d){e.directive(a,["$parse","$swipe",function(e,f){return function(g,h,i){function j(a){if(!k)return!1;var b=Math.abs(a.y-k.y);return a=(a.x-k.x)*c,l&&75>b&&a>0&&a>30&&.3>b/a}var k,l,m=e(i[a]),n=["touch"];b.isDefined(i.ngSwipeDisableMouse)||n.push("mouse"),f.bind(h,{start:function(a,b){k=a,l=!0},cancel:function(a){l=!1},end:function(a,b){j(a)&&g.$apply(function(){h.triggerHandler(d),m(g,{$event:b})})}},n)}}])}var e=b.module("ngTouch",[]);e.factory("$swipe",[function(){function a(a){a=a.originalEvent||a;var b=a.touches&&a.touches.length?a.touches:[a];return a=a.changedTouches&&a.changedTouches[0]||b[0],{x:a.clientX,y:a.clientY}}function c(a,c){var e=[];return b.forEach(a,function(a){(a=d[a][c])&&e.push(a)}),e.join(" ")}var d={mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},touch:{start:"touchstart",move:"touchmove",end:"touchend",cancel:"touchcancel"}};return{bind:function(b,d,e){var f,g,h,i,j=!1;e=e||["mouse","touch"],b.on(c(e,"start"),function(b){h=a(b),j=!0,g=f=0,i=h,d.start&&d.start(h,b)});var k=c(e,"cancel");k&&b.on(k,function(a){j=!1,d.cancel&&d.cancel(a)}),b.on(c(e,"move"),function(b){if(j&&h){var c=a(b);f+=Math.abs(c.x-i.x),g+=Math.abs(c.y-i.y),i=c,10>f&&10>g||(g>f?(j=!1,d.cancel&&d.cancel(b)):(b.preventDefault(),d.move&&d.move(c,b)))}}),b.on(c(e,"end"),function(b){j&&(j=!1,d.end&&d.end(a(b),b))})}}}]),e.config(["$provide",function(a){a.decorator("ngClickDirective",["$delegate",function(a){return a.shift(),a}])}]),e.directive("ngClick",["$parse","$timeout","$rootElement",function(a,c,d){function e(a,b,c){for(var d=0;d Math.abs(a[d]-b)&&25>Math.abs(e-f))return a.splice(d,d+2),!0}return!1}function f(a){if(!(2500 c&&1>b||j&&j[0]===c&&j[1]===b||(j&&(j=null),"label"===a.target.tagName.toLowerCase()&&(j=[c,b]),e(i,c,b)||(a.stopPropagation(),a.preventDefault(),a.target&&a.target.blur()))}}function g(a){a=a.touches&&a.touches.length?a.touches:[a];var b=a[0].clientX,d=a[0].clientY; -i.push(b,d),c(function(){for(var a=0;a c&&12>t&&(i||(d[0].addEventListener("click",f,!0),d[0].addEventListener("touchstart",g,!0),i=[]),h=Date.now(),e(i,q,s),m&&m.blur(),b.isDefined(k.disabled)&&!1!==k.disabled||j.triggerHandler("click",[a])),l()}),j.onclick=function(a){},j.on("click",function(a,b){c.$apply(function(){q(c,{$event:b||a})})}),j.on("mousedown",function(a){j.addClass("ng-click-active")}),j.on("mousemove mouseup",function(a){j.removeClass("ng-click-active")})}}]),d("ngSwipeLeft",-1,"swipeleft"),d("ngSwipeRight",1,"swiperight")}(window,window.angular),"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(a,b,c){"use strict";function d(a,b){return N(new(N(function(){},{prototype:a})),b)}function e(a){return M(arguments,function(b){b!==a&&M(b,function(b,c){a.hasOwnProperty(c)||(a[c]=b)})}),a}function f(a,b){var c=[];for(var d in a.path){if(a.path[d]!==b.path[d])break;c.push(a.path[d])}return c}function g(a){if(Object.keys)return Object.keys(a);var b=[];return M(a,function(a,c){b.push(c)}),b}function h(a,b){if(Array.prototype.indexOf)return a.indexOf(b,Number(arguments[2])||0);var c=a.length>>>0,d=Number(arguments[2])||0;for(d=0>d?Math.ceil(d):Math.floor(d),0>d&&(d+=c);c>d;d++)if(d in a&&a[d]===b)return d;return-1}function i(a,b,c,d){var e,i=f(c,d),j={},k=[];for(var l in i)if(i[l].params&&(e=g(i[l].params),e.length))for(var m in e)h(k,e[m])>=0||(k.push(e[m]),j[e[m]]=a[e[m]]);return N({},j,b)}function j(a,b,c){if(!c){c=[];for(var d in a)c.push(d)}for(var e=0;e "));if(s[c]=d,J(a))q.push(c,[function(){return b.get(a)}],j);else{var e=b.annotate(a);M(e,function(a){a!==c&&i.hasOwnProperty(a)&&n(i[a],a)}),q.push(c,a,e)}r.pop(),s[c]=f}}function o(a){return K(a)&&a.then&&a.$$promises}if(!K(i))throw new Error("'invocables' must be an object");var p=g(i||{}),q=[],r=[],s={};return M(i,n),i=r=s=null,function(d,f,g){function h(){--u||(v||e(t,f.$$values),r.$$values=t,r.$$promises=r.$$promises||!0,delete r.$$inheritedValues,n.resolve(t))}function i(a){r.$$failure=a,n.reject(a)}function j(c,e,f){function j(a){l.reject(a),i(a)}function k(){if(!H(r.$$failure))try{l.resolve(b.invoke(e,g,t)),l.promise.then(function(a){t[c]=a,h()},j)}catch(a){j(a)}}var l=a.defer(),m=0;M(f,function(a){s.hasOwnProperty(a)&&!d.hasOwnProperty(a)&&(m++,s[a].then(function(b){t[a]=b,--m||k()},j))}),m||k(),s[c]=l.promise}if(o(d)&&g===c&&(g=f,f=d,d=null),d){if(!K(d))throw new Error("'locals' must be an object")}else d=k;if(f){if(!o(f))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else f=l;var n=a.defer(),r=n.promise,s=r.$$promises={},t=N({},d),u=1+q.length/3,v=!1;if(H(f.$$failure))return i(f.$$failure),r;f.$$inheritedValues&&e(t,m(f.$$inheritedValues,p)),N(s,f.$$promises),f.$$values?(v=e(t,m(f.$$values,p)),r.$$inheritedValues=m(f.$$values,p),h()):(f.$$inheritedValues&&(r.$$inheritedValues=m(f.$$inheritedValues,p)),f.then(h,i));for(var w=0,x=q.length;x>w;w+=3)d.hasOwnProperty(q[w])?h():j(q[w],q[w+1],q[w+2]);return r}},this.resolve=function(a,b,c,d){return this.study(a)(b,c,d)}}function q(a,b,c){this.fromConfig=function(a,b,c){return H(a.template)?this.fromString(a.template,b):H(a.templateUrl)?this.fromUrl(a.templateUrl,b):H(a.templateProvider)?this.fromProvider(a.templateProvider,b,c):null},this.fromString=function(a,b){return I(a)?a(b):a},this.fromUrl=function(c,d){return I(c)&&(c=c(d)),null==c?null:a.get(c,{cache:b,headers:{Accept:"text/html"}}).then(function(a){return a.data})},this.fromProvider=function(a,b,d){return c.invoke(a,null,d||{params:b})}}function r(a,b,e){function f(b,c,d,e){if(q.push(b),o[b])return o[b];if(!/^\w+(-+\w+)*(?:\[\])?$/.test(b))throw new Error("Invalid parameter name '"+b+"' in pattern '"+a+"'");if(p[b])throw new Error("Duplicate parameter name '"+b+"' in pattern '"+a+"'");return p[b]=new P.Param(b,c,d,e),p[b]}function g(a,b,c,d){var e=["",""],f=a.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!b)return f;switch(c){case!1:e=["(",")"+(d?"?":"")];break;case!0:e=["?(",")?"];break;default:e=["("+c+"|",")?"]}return f+e[0]+b+e[1]}function h(e,f){var g,h,i,j,k;return g=e[2]||e[3],k=b.params[g],i=a.substring(m,e.index),h=f?e[4]:e[4]||("*"==e[1]?".*":null),j=P.type(h||"string")||d(P.type("string"),{pattern:new RegExp(h,b.caseInsensitive?"i":c)}),{id:g,regexp:h,segment:i,type:j,cfg:k}}b=N({params:{}},K(b)?b:{});var i,j=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,k=/([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l="^",m=0,n=this.segments=[],o=e?e.params:{},p=this.params=e?e.params.$$new():new P.ParamSet,q=[];this.source=a;for(var r,s,t;(i=j.exec(a))&&(r=h(i,!1),!(r.segment.indexOf("?")>=0));)s=f(r.id,r.type,r.cfg,"path"),l+=g(r.segment,s.type.pattern.source,s.squash,s.isOptional),n.push(r.segment),m=j.lastIndex;t=a.substring(m);var u=t.indexOf("?");if(u>=0){var v=this.sourceSearch=t.substring(u);if(t=t.substring(0,u),this.sourcePath=a.substring(0,m+u),v.length>0)for(m=0;i=k.exec(v);)r=h(i,!0),s=f(r.id,r.type,r.cfg,"search"),m=j.lastIndex}else this.sourcePath=a,this.sourceSearch="";l+=g(t)+(b.strict===!1?"/?":"")+"$",n.push(t),this.regexp=new RegExp(l,b.caseInsensitive?"i":c),this.prefix=n[0],this.$$paramNames=q}function s(a){N(this,a)}function t(){function a(a){return null!=a?a.toString().replace(/\//g,"%2F"):a}function e(a){return null!=a?a.toString().replace(/%2F/g,"/"):a}function f(){return{strict:p,caseInsensitive:m}}function i(a){return I(a)||L(a)&&I(a[a.length-1])}function j(){for(;w.length;){var a=w.shift();if(a.pattern)throw new Error("You cannot override a type's .pattern at runtime.");b.extend(u[a.name],l.invoke(a.def))}}function k(a){N(this,a||{})}P=this;var l,m=!1,p=!0,q=!1,u={},v=!0,w=[],x={string:{encode:a,decode:e,is:function(a){return null==a||!H(a)||"string"==typeof a},pattern:/[^\/]*/},"int":{encode:a,decode:function(a){return parseInt(a,10)},is:function(a){return H(a)&&this.decode(a.toString())===a},pattern:/\d+/},bool:{encode:function(a){return a?1:0},decode:function(a){return 0!==parseInt(a,10)},is:function(a){return a===!0||a===!1},pattern:/0|1/},date:{encode:function(a){return this.is(a)?[a.getFullYear(),("0"+(a.getMonth()+1)).slice(-2),("0"+a.getDate()).slice(-2)].join("-"):c},decode:function(a){if(this.is(a))return a;var b=this.capture.exec(a);return b?new Date(b[1],b[2]-1,b[3]):c},is:function(a){return a instanceof Date&&!isNaN(a.valueOf())},equals:function(a,b){return this.is(a)&&this.is(b)&&a.toISOString()===b.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:b.toJson,decode:b.fromJson,is:b.isObject,equals:b.equals,pattern:/[^\/]*/},any:{encode:b.identity,decode:b.identity,equals:b.equals,pattern:/.*/}};t.$$getDefaultValue=function(a){if(!i(a.value))return a.value;if(!l)throw new Error("Injectable functions cannot be called at configuration time");return l.invoke(a.value)},this.caseInsensitive=function(a){return H(a)&&(m=a),m},this.strictMode=function(a){return H(a)&&(p=a),p},this.defaultSquashPolicy=function(a){if(!H(a))return q;if(a!==!0&&a!==!1&&!J(a))throw new Error("Invalid squash policy: "+a+". Valid policies: false, true, arbitrary-string");return q=a,a},this.compile=function(a,b){return new r(a,N(f(),b))},this.isMatcher=function(a){if(!K(a))return!1;var b=!0;return M(r.prototype,function(c,d){I(c)&&(b=b&&H(a[d])&&I(a[d]))}),b},this.type=function(a,b,c){if(!H(b))return u[a];if(u.hasOwnProperty(a))throw new Error("A type named '"+a+"' has already been defined.");return u[a]=new s(N({name:a},b)),c&&(w.push({name:a,def:c}),v||j()),this},M(x,function(a,b){u[b]=new s(N({name:b},a))}),u=d(u,{}),this.$get=["$injector",function(a){return l=a,v=!1,j(),M(x,function(a,b){u[b]||(u[b]=new s(a))}),this}],this.Param=function(a,b,d,e){function f(a){var b=K(a)?g(a):[],c=-1===h(b,"value")&&-1===h(b,"type")&&-1===h(b,"squash")&&-1===h(b,"array");return c&&(a={value:a}),a.$$fn=i(a.value)?a.value:function(){return a.value},a}function j(b,c,d){if(b.type&&c)throw new Error("Param '"+a+"' has two type configurations.");return c?c:b.type?b.type instanceof s?b.type:new s(b.type):"config"===d?u.any:u.string}function k(){var b={array:"search"===e?"auto":!1},c=a.match(/\[\]$/)?{array:!0}:{};return N(b,c,d).array}function m(a,b){var c=a.squash;if(!b||c===!1)return!1;if(!H(c)||null==c)return q;if(c===!0||J(c))return c;throw new Error("Invalid squash policy: '"+c+"'. Valid policies: false, true, or arbitrary string")}function p(a,b,d,e){var f,g,i=[{from:"",to:d||b?c:""},{from:null,to:d||b?c:""}];return f=L(a.replace)?a.replace:[],J(e)&&f.push({from:e,to:c}),g=o(f,function(a){return a.from}),n(i,function(a){return-1===h(g,a.from)}).concat(f)}function r(){if(!l)throw new Error("Injectable functions cannot be called at configuration time");var a=l.invoke(d.$$fn);if(null!==a&&a!==c&&!w.type.is(a))throw new Error("Default value ("+a+") for parameter '"+w.id+"' is not an instance of Type ("+w.type.name+")");return a}function t(a){function b(a){return function(b){return b.from===a}}function c(a){var c=o(n(w.replace,b(a)),function(a){return a.to});return c.length?c[0]:a}return a=c(a),H(a)?w.type.$normalize(a):r()}function v(){return"{Param:"+a+" "+b+" squash: '"+z+"' optional: "+y+"}"}var w=this;d=f(d),b=j(d,b,e);var x=k();b=x?b.$asArray(x,"search"===e):b,"string"!==b.name||x||"path"!==e||d.value!==c||(d.value="");var y=d.value!==c,z=m(d,y),A=p(d,x,y,z);N(this,{id:a,type:b,location:e,array:x,squash:z,replace:A,isOptional:y,value:t,dynamic:c,config:d,toString:v})},k.prototype={$$new:function(){return d(this,N(new k,{$$parent:this}))},$$keys:function(){for(var a=[],b=[],c=this,d=g(k.prototype);c;)b.push(c),c=c.$$parent;return b.reverse(),M(b,function(b){M(g(b),function(b){-1===h(a,b)&&-1===h(d,b)&&a.push(b)})}),a},$$values:function(a){var b={},c=this;return M(c.$$keys(),function(d){b[d]=c[d].value(a&&a[d])}),b},$$equals:function(a,b){var c=!0,d=this;return M(d.$$keys(),function(e){var f=a&&a[e],g=b&&b[e];d[e].type.equals(f,g)||(c=!1)}),c},$$validates:function(a){var d,e,f,g,h,i=this.$$keys();for(d=0;d e;e++)if(b(j[e]))return;k&&b(k)}}function n(){return i=i||e.$on("$locationChangeSuccess",m)}var o,p=g.baseHref(),q=d.url();return l||n(),{sync:function(){m()},listen:function(){return n()},update:function(a){return a?void(q=d.url()):void(d.url()!==q&&(d.url(q),d.replace()))},push:function(a,b,e){var f=a.format(b||{});null!==f&&b&&b["#"]&&(f+="#"+b["#"]),d.url(f),o=e&&e.$$avoidResync?d.url():c,e&&e.replace&&d.replace()},href:function(c,e,f){if(!c.validates(e))return null;var g=a.html5Mode();b.isObject(g)&&(g=g.enabled);var i=c.format(e);if(f=f||{},g||null===i||(i="#"+a.hashPrefix()+i),null!==i&&e&&e["#"]&&(i+="#"+e["#"]),i=h(i,g,f.absolute),!f.absolute||!i)return i;var j=!g&&i?"/":"",k=d.port();return k=80===k||443===k?"":":"+k,[d.protocol(),"://",d.host(),k,j,i].join("")}}}var i,j=[],k=null,l=!1;this.rule=function(a){if(!I(a))throw new Error("'rule' must be a function");return j.push(a),this},this.otherwise=function(a){if(J(a)){var b=a;a=function(){return b}}else if(!I(a))throw new Error("'rule' must be a function");return k=a,this},this.when=function(a,b){var c,h=J(b);if(J(a)&&(a=d.compile(a)),!h&&!I(b)&&!L(b))throw new Error("invalid 'handler' in when()");var i={matcher:function(a,b){return h&&(c=d.compile(b),b=["$match",function(a){return c.format(a)}]),N(function(c,d){return g(c,b,a.exec(d.path(),d.search()))},{prefix:J(a.prefix)?a.prefix:""})},regex:function(a,b){if(a.global||a.sticky)throw new Error("when() RegExp must not be global or sticky");return h&&(c=b,b=["$match",function(a){return f(c,a)}]),N(function(c,d){return g(c,b,a.exec(d.path()))},{prefix:e(a)})}},j={matcher:d.isMatcher(a),regex:a instanceof RegExp};for(var k in j)if(j[k])return this.rule(i[k](a,b));throw new Error("invalid 'what' in when()")},this.deferIntercept=function(a){a===c&&(a=!0),l=a},this.$get=h,h.$inject=["$location","$rootScope","$injector","$browser"]}function v(a,e){function f(a){return 0===a.indexOf(".")||0===a.indexOf("^")}function m(a,b){if(!a)return c;var d=J(a),e=d?a:a.name,g=f(e);if(g){if(!b)throw new Error("No reference point given for path '"+e+"'");b=m(b);for(var h=e.split("."),i=0,j=h.length,k=b;j>i;i++)if(""!==h[i]||0!==i){if("^"!==h[i])break;if(!k.parent)throw new Error("Path '"+e+"' not valid for state '"+b.name+"'");k=k.parent}else k=b;h=h.slice(i).join("."),e=k.name+(k.name&&h?".":"")+h}var l=z[e];return!l||!d&&(d||l!==a&&l.self!==a)?c:l}function n(a,b){A[a]||(A[a]=[]),A[a].push(b)}function p(a){for(var b=A[a]||[];b.length;)q(b.shift())}function q(b){b=d(b,{self:b,resolve:b.resolve||{},toString:function(){return this.name}});var c=b.name;if(!J(c)||c.indexOf("@")>=0)throw new Error("State must have a valid name");if(z.hasOwnProperty(c))throw new Error("State '"+c+"'' is already defined");var e=-1!==c.indexOf(".")?c.substring(0,c.lastIndexOf(".")):J(b.parent)?b.parent:K(b.parent)&&J(b.parent.name)?b.parent.name:"";if(e&&!z[e])return n(e,b.self);for(var f in C)I(C[f])&&(b[f]=C[f](b,C.$delegates[f]));return z[c]=b,!b[B]&&b.url&&a.when(b.url,["$match","$stateParams",function(a,c){y.$current.navigable==b&&j(a,c)||y.transitionTo(b,a,{inherit:!0,location:!1})}]),p(c),b}function r(a){return a.indexOf("*")>-1}function s(a){for(var b=a.split("."),c=y.$current.name.split("."),d=0,e=b.length;e>d;d++)"*"===b[d]&&(c[d]="*");return"**"===b[0]&&(c=c.slice(h(c,b[1])),c.unshift("**")),"**"===b[b.length-1]&&(c.splice(h(c,b[b.length-2])+1,Number.MAX_VALUE),c.push("**")),b.length!=c.length?!1:c.join("")===b.join("")}function t(a,b){return J(a)&&!H(b)?C[a]:I(b)&&J(a)?(C[a]&&!C.$delegates[a]&&(C.$delegates[a]=C[a]),C[a]=b,this):this}function u(a,b){return K(a)?b=a:b.name=a,q(b),this}function v(a,e,f,h,l,n,p,q,t){function u(b,c,d,f){var g=a.$broadcast("$stateNotFound",b,c,d);if(g.defaultPrevented)return p.update(),D;if(!g.retry)return null;if(f.$retry)return p.update(),E;var h=y.transition=e.when(g.retry);return h.then(function(){return h!==y.transition?A:(b.options.$retry=!0,y.transitionTo(b.to,b.toParams,b.options))},function(){return D}),p.update(),h}function v(a,c,d,g,i,j){function m(){var c=[];return M(a.views,function(d,e){var g=d.resolve&&d.resolve!==a.resolve?d.resolve:{};g.$template=[function(){return f.load(e,{view:d,locals:i.globals,params:n,notify:j.notify})||""}],c.push(l.resolve(g,i.globals,i.resolve,a).then(function(c){if(I(d.controllerProvider)||L(d.controllerProvider)){var f=b.extend({},g,i.globals);c.$$controller=h.invoke(d.controllerProvider,null,f)}else c.$$controller=d.controller;c.$$state=a,c.$$controllerAs=d.controllerAs,i[e]=c}))}),e.all(c).then(function(){return i.globals})}var n=d?c:k(a.params.$$keys(),c),o={$stateParams:n};i.resolve=l.resolve(a.resolve,o,i.resolve,a);var p=[i.resolve.then(function(a){i.globals=a})];return g&&p.push(g),e.all(p).then(m).then(function(a){return i})}var A=e.reject(new Error("transition superseded")),C=e.reject(new Error("transition prevented")),D=e.reject(new Error("transition aborted")),E=e.reject(new Error("transition failed"));return x.locals={resolve:null,globals:{$stateParams:{}}},y={params:{},current:x.self,$current:x,transition:null},y.reload=function(a){return y.transitionTo(y.current,n,{reload:a||!0,inherit:!1,notify:!0})},y.go=function(a,b,c){return y.transitionTo(a,b,N({inherit:!0,relative:y.$current},c))},y.transitionTo=function(b,c,f){c=c||{},f=N({location:!0,inherit:!1,relative:null,notify:!0,reload:!1,$retry:!1},f||{});var g,j=y.$current,l=y.params,o=j.path,q=m(b,f.relative),r=c["#"];if(!H(q)){var s={to:b,toParams:c,options:f},t=u(s,j.self,l,f);if(t)return t;if(b=s.to,c=s.toParams,f=s.options,q=m(b,f.relative),!H(q)){if(!f.relative)throw new Error("No such state '"+b+"'");throw new Error("Could not resolve '"+b+"' from state '"+f.relative+"'")}}if(q[B])throw new Error("Cannot transition to abstract state '"+b+"'");if(f.inherit&&(c=i(n,c||{},y.$current,q)),!q.params.$$validates(c))return E;c=q.params.$$values(c),b=q;var z=b.path,D=0,F=z[D],G=x.locals,I=[];if(f.reload){if(J(f.reload)||K(f.reload)){if(K(f.reload)&&!f.reload.name)throw new Error("Invalid reload state object");var L=f.reload===!0?o[0]:m(f.reload);if(f.reload&&!L)throw new Error("No such reload state '"+(J(f.reload)?f.reload:f.reload.name)+"'");for(;F&&F===o[D]&&F!==L;)G=I[D]=F.locals,D++,F=z[D]}}else for(;F&&F===o[D]&&F.ownParams.$$equals(c,l);)G=I[D]=F.locals,D++,F=z[D];if(w(b,c,j,l,G,f))return r&&(c["#"]=r),y.params=c,O(y.params,n),f.location&&b.navigable&&b.navigable.url&&(p.push(b.navigable.url,c,{$$avoidResync:!0,replace:"replace"===f.location}),p.update(!0)),y.transition=null,e.when(y.current);if(c=k(b.params.$$keys(),c||{}),f.notify&&a.$broadcast("$stateChangeStart",b.self,c,j.self,l).defaultPrevented)return a.$broadcast("$stateChangeCancel",b.self,c,j.self,l),p.update(),C;for(var M=e.when(G),P=D;P =D;d--)g=o[d],g.self.onExit&&h.invoke(g.self.onExit,g.self,g.locals.globals),g.locals=null;for(d=D;d =0?e:e+"@"+(f?f.state.name:"")}function B(a,b){var c,d=a.match(/^\s*({[^}]*})\s*$/);if(d&&(a=b+"("+d[1]+")"),c=a.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/),!c||4!==c.length)throw new Error("Invalid state ref '"+a+"'");return{state:c[1],paramExpr:c[3]||null}}function C(a){var b=a.parent().inheritedData("$uiView");return b&&b.state&&b.state.name?b.state:void 0}function D(a,c){var d=["location","inherit","reload","absolute"];return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(e,f,g,h){var i=B(g.uiSref,a.current.name),j=null,k=C(f)||a.$current,l="[object SVGAnimatedString]"===Object.prototype.toString.call(f.prop("href"))?"xlink:href":"href",m=null,n="A"===f.prop("tagName").toUpperCase(),o="FORM"===f[0].nodeName,p=o?"action":l,q=!0,r={relative:k,inherit:!0},s=e.$eval(g.uiSrefOpts)||{};b.forEach(d,function(a){a in s&&(r[a]=s[a])});var t=function(c){if(c&&(j=b.copy(c)),q){m=a.href(i.state,j,r);var d=h[1]||h[0];return d&&d.$$addStateInfo(i.state,j),null===m?(q=!1,!1):void g.$set(p,m)}};i.paramExpr&&(e.$watch(i.paramExpr,function(a,b){a!==j&&t(a)},!0),j=b.copy(e.$eval(i.paramExpr))),t(),o||f.bind("click",function(b){var d=b.which||b.button;if(!(d>1||b.ctrlKey||b.metaKey||b.shiftKey||f.attr("target"))){var e=c(function(){a.go(i.state,j,r)});b.preventDefault();var g=n&&!m?1:0;b.preventDefault=function(){g--<=0&&c.cancel(e)}}})}}}function E(a,b,c){return{restrict:"A",controller:["$scope","$element","$attrs",function(b,d,e){function f(){g()?d.addClass(i):d.removeClass(i)}function g(){for(var a=0;a e;e++){g=h[e];var l=this.params[g],m=d[e+1];for(f=0;f e;e++)g=h[e],k[g]=this.params[g].value(b[g]);return k},r.prototype.parameters=function(a){return H(a)?this.params[a]||null:this.$$paramNames},r.prototype.validates=function(a){return this.params.$$validates(a)},r.prototype.format=function(a){function b(a){return encodeURIComponent(a).replace(/-/g,function(a){return"%5C%"+a.charCodeAt(0).toString(16).toUpperCase()})}a=a||{};var c=this.segments,d=this.parameters(),e=this.params;if(!this.validates(a))return null;var f,g=!1,h=c.length-1,i=d.length,j=c[0];for(f=0;i>f;f++){var k=h>f,l=d[f],m=e[l],n=m.value(a[l]),p=m.isOptional&&m.type.equals(m.value(),n),q=p?m.squash:!1,r=m.type.encode(n);if(k){var s=c[f+1];if(q===!1)null!=r&&(j+=L(r)?o(r,b).join("-"):encodeURIComponent(r)),j+=s;else if(q===!0){var t=j.match(/\/$/)?/\/?(.*)/:/(.*)/;j+=s.match(t)[1]}else J(q)&&(j+=q+s)}else{if(null==r||p&&q!==!1)continue;L(r)||(r=[r]),r=o(r,encodeURIComponent).join("&"+l+"="),j+=(g?"&":"?")+(l+"="+r),g=!0}}return j},s.prototype.is=function(a,b){return!0},s.prototype.encode=function(a,b){return a},s.prototype.decode=function(a,b){return a},s.prototype.equals=function(a,b){return a==b},s.prototype.$subPattern=function(){var a=this.pattern.toString();return a.substr(1,a.length-2)},s.prototype.pattern=/.*/,s.prototype.toString=function(){return"{Type:"+this.name+"}"},s.prototype.$normalize=function(a){return this.is(a)?a:this.decode(a)},s.prototype.$asArray=function(a,b){function d(a,b){function d(a,b){return function(){return a[b].apply(a,arguments)}}function e(a){return L(a)?a:H(a)?[a]:[]}function f(a){switch(a.length){case 0:return c;case 1:return"auto"===b?a[0]:a;default:return a}}function g(a){return!a}function h(a,b){return function(c){c=e(c);var d=o(c,a);return b===!0?0===n(d,g).length:f(d)}}function i(a){return function(b,c){var d=e(b),f=e(c);if(d.length!==f.length)return!1;for(var g=0;g c&&12>t&&(i||(d[0].addEventListener("click",f,!0),d[0].addEventListener("touchstart",g,!0),i=[]),h=Date.now(),e(i,q,s),m&&m.blur(),b.isDefined(k.disabled)&&!1!==k.disabled||j.triggerHandler("click",[a])),l()}),j.onclick=function(a){},j.on("click",function(a,b){c.$apply(function(){q(c,{$event:b||a})})}),j.on("mousedown",function(a){j.addClass("ng-click-active")}),j.on("mousemove mouseup",function(a){j.removeClass("ng-click-active")})}}]),d("ngSwipeLeft",-1,"swipeleft"),d("ngSwipeRight",1,"swiperight")}(window,window.angular),"undefined"!=typeof module&&"undefined"!=typeof exports&&module.exports===exports&&(module.exports="ui.router"),function(a,b,c){"use strict";function d(a,b){return N(new(N(function(){},{prototype:a})),b)}function e(a){return M(arguments,function(b){b!==a&&M(b,function(b,c){a.hasOwnProperty(c)||(a[c]=b)})}),a}function f(a,b){var c=[];for(var d in a.path){if(a.path[d]!==b.path[d])break;c.push(a.path[d])}return c}function g(a){if(Object.keys)return Object.keys(a);var b=[];return M(a,function(a,c){b.push(c)}),b}function h(a,b){if(Array.prototype.indexOf)return a.indexOf(b,Number(arguments[2])||0);var c=a.length>>>0,d=Number(arguments[2])||0;for(d=0>d?Math.ceil(d):Math.floor(d),0>d&&(d+=c);c>d;d++)if(d in a&&a[d]===b)return d;return-1}function i(a,b,c,d){var e,i=f(c,d),j={},k=[];for(var l in i)if(i[l].params&&(e=g(i[l].params),e.length))for(var m in e)h(k,e[m])>=0||(k.push(e[m]),j[e[m]]=a[e[m]]);return N({},j,b)}function j(a,b,c){if(!c){c=[];for(var d in a)c.push(d)}for(var e=0;e "));if(s[c]=d,J(a))q.push(c,[function(){return b.get(a)}],j);else{var e=b.annotate(a);M(e,function(a){a!==c&&i.hasOwnProperty(a)&&n(i[a],a)}),q.push(c,a,e)}r.pop(),s[c]=f}}function o(a){return K(a)&&a.then&&a.$$promises}if(!K(i))throw new Error("'invocables' must be an object");var p=g(i||{}),q=[],r=[],s={};return M(i,n),i=r=s=null,function(d,f,g){function h(){--u||(v||e(t,f.$$values),r.$$values=t,r.$$promises=r.$$promises||!0,delete r.$$inheritedValues,n.resolve(t))}function i(a){r.$$failure=a,n.reject(a)}function j(c,e,f){function j(a){l.reject(a),i(a)}function k(){if(!H(r.$$failure))try{l.resolve(b.invoke(e,g,t)),l.promise.then(function(a){t[c]=a,h()},j)}catch(a){j(a)}}var l=a.defer(),m=0;M(f,function(a){s.hasOwnProperty(a)&&!d.hasOwnProperty(a)&&(m++,s[a].then(function(b){t[a]=b,--m||k()},j))}),m||k(),s[c]=l.promise}if(o(d)&&g===c&&(g=f,f=d,d=null),d){if(!K(d))throw new Error("'locals' must be an object")}else d=k;if(f){if(!o(f))throw new Error("'parent' must be a promise returned by $resolve.resolve()")}else f=l;var n=a.defer(),r=n.promise,s=r.$$promises={},t=N({},d),u=1+q.length/3,v=!1;if(H(f.$$failure))return i(f.$$failure),r;f.$$inheritedValues&&e(t,m(f.$$inheritedValues,p)),N(s,f.$$promises),f.$$values?(v=e(t,m(f.$$values,p)),r.$$inheritedValues=m(f.$$values,p),h()):(f.$$inheritedValues&&(r.$$inheritedValues=m(f.$$inheritedValues,p)),f.then(h,i));for(var w=0,x=q.length;x>w;w+=3)d.hasOwnProperty(q[w])?h():j(q[w],q[w+1],q[w+2]);return r}},this.resolve=function(a,b,c,d){return this.study(a)(b,c,d)}}function q(a,b,c){this.fromConfig=function(a,b,c){return H(a.template)?this.fromString(a.template,b):H(a.templateUrl)?this.fromUrl(a.templateUrl,b):H(a.templateProvider)?this.fromProvider(a.templateProvider,b,c):null},this.fromString=function(a,b){return I(a)?a(b):a},this.fromUrl=function(c,d){return I(c)&&(c=c(d)),null==c?null:a.get(c,{cache:b,headers:{Accept:"text/html"}}).then(function(a){return a.data})},this.fromProvider=function(a,b,d){return c.invoke(a,null,d||{params:b})}}function r(a,b,e){function f(b,c,d,e){if(q.push(b),o[b])return o[b];if(!/^\w+(-+\w+)*(?:\[\])?$/.test(b))throw new Error("Invalid parameter name '"+b+"' in pattern '"+a+"'");if(p[b])throw new Error("Duplicate parameter name '"+b+"' in pattern '"+a+"'");return p[b]=new P.Param(b,c,d,e),p[b]}function g(a,b,c,d){var e=["",""],f=a.replace(/[\\\[\]\^$*+?.()|{}]/g,"\\$&");if(!b)return f;switch(c){case!1:e=["(",")"+(d?"?":"")];break;case!0:e=["?(",")?"];break;default:e=["("+c+"|",")?"]}return f+e[0]+b+e[1]}function h(e,f){var g,h,i,j,k;return g=e[2]||e[3],k=b.params[g],i=a.substring(m,e.index),h=f?e[4]:e[4]||("*"==e[1]?".*":null),j=P.type(h||"string")||d(P.type("string"),{pattern:new RegExp(h,b.caseInsensitive?"i":c)}),{id:g,regexp:h,segment:i,type:j,cfg:k}}b=N({params:{}},K(b)?b:{});var i,j=/([:*])([\w\[\]]+)|\{([\w\[\]]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,k=/([:]?)([\w\[\]-]+)|\{([\w\[\]-]+)(?:\:((?:[^{}\\]+|\\.|\{(?:[^{}\\]+|\\.)*\})+))?\}/g,l="^",m=0,n=this.segments=[],o=e?e.params:{},p=this.params=e?e.params.$$new():new P.ParamSet,q=[];this.source=a;for(var r,s,t;(i=j.exec(a))&&(r=h(i,!1),!(r.segment.indexOf("?")>=0));)s=f(r.id,r.type,r.cfg,"path"),l+=g(r.segment,s.type.pattern.source,s.squash,s.isOptional),n.push(r.segment),m=j.lastIndex;t=a.substring(m);var u=t.indexOf("?");if(u>=0){var v=this.sourceSearch=t.substring(u);if(t=t.substring(0,u),this.sourcePath=a.substring(0,m+u),v.length>0)for(m=0;i=k.exec(v);)r=h(i,!0),s=f(r.id,r.type,r.cfg,"search"),m=j.lastIndex}else this.sourcePath=a,this.sourceSearch="";l+=g(t)+(b.strict===!1?"/?":"")+"$",n.push(t),this.regexp=new RegExp(l,b.caseInsensitive?"i":c),this.prefix=n[0],this.$$paramNames=q}function s(a){N(this,a)}function t(){function a(a){return null!=a?a.toString().replace(/\//g,"%2F"):a}function e(a){return null!=a?a.toString().replace(/%2F/g,"/"):a}function f(){return{strict:p,caseInsensitive:m}}function i(a){return I(a)||L(a)&&I(a[a.length-1])}function j(){for(;w.length;){var a=w.shift();if(a.pattern)throw new Error("You cannot override a type's .pattern at runtime.");b.extend(u[a.name],l.invoke(a.def))}}function k(a){N(this,a||{})}P=this;var l,m=!1,p=!0,q=!1,u={},v=!0,w=[],x={string:{encode:a,decode:e,is:function(a){return null==a||!H(a)||"string"==typeof a},pattern:/[^/]*/},"int":{encode:a,decode:function(a){return parseInt(a,10)},is:function(a){return H(a)&&this.decode(a.toString())===a},pattern:/\d+/},bool:{encode:function(a){return a?1:0},decode:function(a){return 0!==parseInt(a,10)},is:function(a){return a===!0||a===!1},pattern:/0|1/},date:{encode:function(a){return this.is(a)?[a.getFullYear(),("0"+(a.getMonth()+1)).slice(-2),("0"+a.getDate()).slice(-2)].join("-"):c},decode:function(a){if(this.is(a))return a;var b=this.capture.exec(a);return b?new Date(b[1],b[2]-1,b[3]):c},is:function(a){return a instanceof Date&&!isNaN(a.valueOf())},equals:function(a,b){return this.is(a)&&this.is(b)&&a.toISOString()===b.toISOString()},pattern:/[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,capture:/([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/},json:{encode:b.toJson,decode:b.fromJson,is:b.isObject,equals:b.equals,pattern:/[^/]*/},any:{encode:b.identity,decode:b.identity,equals:b.equals,pattern:/.*/}};t.$$getDefaultValue=function(a){if(!i(a.value))return a.value;if(!l)throw new Error("Injectable functions cannot be called at configuration time");return l.invoke(a.value)},this.caseInsensitive=function(a){return H(a)&&(m=a),m},this.strictMode=function(a){return H(a)&&(p=a),p},this.defaultSquashPolicy=function(a){if(!H(a))return q;if(a!==!0&&a!==!1&&!J(a))throw new Error("Invalid squash policy: "+a+". Valid policies: false, true, arbitrary-string");return q=a,a},this.compile=function(a,b){return new r(a,N(f(),b))},this.isMatcher=function(a){if(!K(a))return!1;var b=!0;return M(r.prototype,function(c,d){I(c)&&(b=b&&H(a[d])&&I(a[d]))}),b},this.type=function(a,b,c){if(!H(b))return u[a];if(u.hasOwnProperty(a))throw new Error("A type named '"+a+"' has already been defined.");return u[a]=new s(N({name:a},b)),c&&(w.push({name:a,def:c}),v||j()),this},M(x,function(a,b){u[b]=new s(N({name:b},a))}),u=d(u,{}),this.$get=["$injector",function(a){return l=a,v=!1,j(),M(x,function(a,b){u[b]||(u[b]=new s(a))}),this}],this.Param=function(a,b,d,e){function f(a){var b=K(a)?g(a):[],c=-1===h(b,"value")&&-1===h(b,"type")&&-1===h(b,"squash")&&-1===h(b,"array");return c&&(a={value:a}),a.$$fn=i(a.value)?a.value:function(){return a.value},a}function j(b,c,d){if(b.type&&c)throw new Error("Param '"+a+"' has two type configurations.");return c?c:b.type?b.type instanceof s?b.type:new s(b.type):"config"===d?u.any:u.string}function k(){var b={array:"search"===e?"auto":!1},c=a.match(/\[\]$/)?{array:!0}:{};return N(b,c,d).array}function m(a,b){var c=a.squash;if(!b||c===!1)return!1;if(!H(c)||null==c)return q;if(c===!0||J(c))return c;throw new Error("Invalid squash policy: '"+c+"'. Valid policies: false, true, or arbitrary string")}function p(a,b,d,e){var f,g,i=[{from:"",to:d||b?c:""},{from:null,to:d||b?c:""}];return f=L(a.replace)?a.replace:[],J(e)&&f.push({from:e,to:c}),g=o(f,function(a){return a.from}),n(i,function(a){return-1===h(g,a.from)}).concat(f)}function r(){if(!l)throw new Error("Injectable functions cannot be called at configuration time");var a=l.invoke(d.$$fn);if(null!==a&&a!==c&&!w.type.is(a))throw new Error("Default value ("+a+") for parameter '"+w.id+"' is not an instance of Type ("+w.type.name+")");return a}function t(a){function b(a){return function(b){return b.from===a}}function c(a){var c=o(n(w.replace,b(a)),function(a){return a.to});return c.length?c[0]:a}return a=c(a),H(a)?w.type.$normalize(a):r()}function v(){return"{Param:"+a+" "+b+" squash: '"+z+"' optional: "+y+"}"}var w=this;d=f(d),b=j(d,b,e);var x=k();b=x?b.$asArray(x,"search"===e):b,"string"!==b.name||x||"path"!==e||d.value!==c||(d.value="");var y=d.value!==c,z=m(d,y),A=p(d,x,y,z);N(this,{id:a,type:b,location:e,array:x,squash:z,replace:A,isOptional:y,value:t,dynamic:c,config:d,toString:v})},k.prototype={$$new:function(){return d(this,N(new k,{$$parent:this}))},$$keys:function(){for(var a=[],b=[],c=this,d=g(k.prototype);c;)b.push(c),c=c.$$parent;return b.reverse(),M(b,function(b){M(g(b),function(b){-1===h(a,b)&&-1===h(d,b)&&a.push(b)})}),a},$$values:function(a){var b={},c=this;return M(c.$$keys(),function(d){b[d]=c[d].value(a&&a[d])}),b},$$equals:function(a,b){var c=!0,d=this;return M(d.$$keys(),function(e){var f=a&&a[e],g=b&&b[e];d[e].type.equals(f,g)||(c=!1)}),c},$$validates:function(a){var d,e,f,g,h,i=this.$$keys();for(d=0;d e;e++)if(b(j[e]))return;k&&b(k)}}function n(){return i=i||e.$on("$locationChangeSuccess",m)}var o,p=g.baseHref(),q=d.url();return l||n(),{sync:function(){m()},listen:function(){return n()},update:function(a){return a?void(q=d.url()):void(d.url()!==q&&(d.url(q),d.replace()))},push:function(a,b,e){var f=a.format(b||{});null!==f&&b&&b["#"]&&(f+="#"+b["#"]),d.url(f),o=e&&e.$$avoidResync?d.url():c,e&&e.replace&&d.replace()},href:function(c,e,f){if(!c.validates(e))return null;var g=a.html5Mode();b.isObject(g)&&(g=g.enabled);var i=c.format(e);if(f=f||{},g||null===i||(i="#"+a.hashPrefix()+i),null!==i&&e&&e["#"]&&(i+="#"+e["#"]),i=h(i,g,f.absolute),!f.absolute||!i)return i;var j=!g&&i?"/":"",k=d.port();return k=80===k||443===k?"":":"+k,[d.protocol(),"://",d.host(),k,j,i].join("")}}}var i,j=[],k=null,l=!1;this.rule=function(a){if(!I(a))throw new Error("'rule' must be a function");return j.push(a),this},this.otherwise=function(a){if(J(a)){var b=a;a=function(){return b}}else if(!I(a))throw new Error("'rule' must be a function");return k=a,this},this.when=function(a,b){var c,h=J(b);if(J(a)&&(a=d.compile(a)),!h&&!I(b)&&!L(b))throw new Error("invalid 'handler' in when()");var i={matcher:function(a,b){return h&&(c=d.compile(b),b=["$match",function(a){return c.format(a)}]),N(function(c,d){return g(c,b,a.exec(d.path(),d.search()))},{prefix:J(a.prefix)?a.prefix:""})},regex:function(a,b){if(a.global||a.sticky)throw new Error("when() RegExp must not be global or sticky");return h&&(c=b,b=["$match",function(a){return f(c,a)}]),N(function(c,d){return g(c,b,a.exec(d.path()))},{prefix:e(a)})}},j={matcher:d.isMatcher(a),regex:a instanceof RegExp};for(var k in j)if(j[k])return this.rule(i[k](a,b));throw new Error("invalid 'what' in when()")},this.deferIntercept=function(a){a===c&&(a=!0),l=a},this.$get=h,h.$inject=["$location","$rootScope","$injector","$browser"]}function v(a,e){function f(a){return 0===a.indexOf(".")||0===a.indexOf("^")}function m(a,b){if(!a)return c;var d=J(a),e=d?a:a.name,g=f(e);if(g){if(!b)throw new Error("No reference point given for path '"+e+"'");b=m(b);for(var h=e.split("."),i=0,j=h.length,k=b;j>i;i++)if(""!==h[i]||0!==i){if("^"!==h[i])break;if(!k.parent)throw new Error("Path '"+e+"' not valid for state '"+b.name+"'");k=k.parent}else k=b;h=h.slice(i).join("."),e=k.name+(k.name&&h?".":"")+h}var l=z[e];return!l||!d&&(d||l!==a&&l.self!==a)?c:l}function n(a,b){A[a]||(A[a]=[]),A[a].push(b)}function p(a){for(var b=A[a]||[];b.length;)q(b.shift())}function q(b){b=d(b,{self:b,resolve:b.resolve||{},toString:function(){return this.name}});var c=b.name;if(!J(c)||c.indexOf("@")>=0)throw new Error("State must have a valid name");if(z.hasOwnProperty(c))throw new Error("State '"+c+"'' is already defined");var e=-1!==c.indexOf(".")?c.substring(0,c.lastIndexOf(".")):J(b.parent)?b.parent:K(b.parent)&&J(b.parent.name)?b.parent.name:"";if(e&&!z[e])return n(e,b.self);for(var f in C)I(C[f])&&(b[f]=C[f](b,C.$delegates[f]));return z[c]=b,!b[B]&&b.url&&a.when(b.url,["$match","$stateParams",function(a,c){y.$current.navigable==b&&j(a,c)||y.transitionTo(b,a,{inherit:!0,location:!1})}]),p(c),b}function r(a){return a.indexOf("*")>-1}function s(a){for(var b=a.split("."),c=y.$current.name.split("."),d=0,e=b.length;e>d;d++)"*"===b[d]&&(c[d]="*");return"**"===b[0]&&(c=c.slice(h(c,b[1])),c.unshift("**")),"**"===b[b.length-1]&&(c.splice(h(c,b[b.length-2])+1,Number.MAX_VALUE),c.push("**")),b.length!=c.length?!1:c.join("")===b.join("")}function t(a,b){return J(a)&&!H(b)?C[a]:I(b)&&J(a)?(C[a]&&!C.$delegates[a]&&(C.$delegates[a]=C[a]),C[a]=b,this):this}function u(a,b){return K(a)?b=a:b.name=a,q(b),this}function v(a,e,f,h,l,n,p,q,t){function u(b,c,d,f){var g=a.$broadcast("$stateNotFound",b,c,d);if(g.defaultPrevented)return p.update(),D;if(!g.retry)return null;if(f.$retry)return p.update(),E;var h=y.transition=e.when(g.retry);return h.then(function(){return h!==y.transition?A:(b.options.$retry=!0,y.transitionTo(b.to,b.toParams,b.options))},function(){return D}),p.update(),h}function v(a,c,d,g,i,j){function m(){var c=[];return M(a.views,function(d,e){var g=d.resolve&&d.resolve!==a.resolve?d.resolve:{};g.$template=[function(){return f.load(e,{view:d,locals:i.globals,params:n,notify:j.notify})||""}],c.push(l.resolve(g,i.globals,i.resolve,a).then(function(c){if(I(d.controllerProvider)||L(d.controllerProvider)){var f=b.extend({},g,i.globals);c.$$controller=h.invoke(d.controllerProvider,null,f)}else c.$$controller=d.controller;c.$$state=a,c.$$controllerAs=d.controllerAs,i[e]=c}))}),e.all(c).then(function(){return i.globals})}var n=d?c:k(a.params.$$keys(),c),o={$stateParams:n};i.resolve=l.resolve(a.resolve,o,i.resolve,a);var p=[i.resolve.then(function(a){i.globals=a})];return g&&p.push(g),e.all(p).then(m).then(function(a){return i})}var A=e.reject(new Error("transition superseded")),C=e.reject(new Error("transition prevented")),D=e.reject(new Error("transition aborted")),E=e.reject(new Error("transition failed"));return x.locals={resolve:null,globals:{$stateParams:{}}},y={params:{},current:x.self,$current:x,transition:null},y.reload=function(a){return y.transitionTo(y.current,n,{reload:a||!0,inherit:!1,notify:!0})},y.go=function(a,b,c){return y.transitionTo(a,b,N({inherit:!0,relative:y.$current},c))},y.transitionTo=function(b,c,f){c=c||{},f=N({location:!0,inherit:!1,relative:null,notify:!0,reload:!1,$retry:!1},f||{});var g,j=y.$current,l=y.params,o=j.path,q=m(b,f.relative),r=c["#"];if(!H(q)){var s={to:b,toParams:c,options:f},t=u(s,j.self,l,f);if(t)return t;if(b=s.to,c=s.toParams,f=s.options,q=m(b,f.relative),!H(q)){if(!f.relative)throw new Error("No such state '"+b+"'");throw new Error("Could not resolve '"+b+"' from state '"+f.relative+"'")}}if(q[B])throw new Error("Cannot transition to abstract state '"+b+"'");if(f.inherit&&(c=i(n,c||{},y.$current,q)),!q.params.$$validates(c))return E;c=q.params.$$values(c),b=q;var z=b.path,D=0,F=z[D],G=x.locals,I=[];if(f.reload){if(J(f.reload)||K(f.reload)){if(K(f.reload)&&!f.reload.name)throw new Error("Invalid reload state object");var L=f.reload===!0?o[0]:m(f.reload);if(f.reload&&!L)throw new Error("No such reload state '"+(J(f.reload)?f.reload:f.reload.name)+"'");for(;F&&F===o[D]&&F!==L;)G=I[D]=F.locals,D++,F=z[D]}}else for(;F&&F===o[D]&&F.ownParams.$$equals(c,l);)G=I[D]=F.locals,D++,F=z[D];if(w(b,c,j,l,G,f))return r&&(c["#"]=r),y.params=c,O(y.params,n),f.location&&b.navigable&&b.navigable.url&&(p.push(b.navigable.url,c,{$$avoidResync:!0,replace:"replace"===f.location}),p.update(!0)),y.transition=null,e.when(y.current);if(c=k(b.params.$$keys(),c||{}),f.notify&&a.$broadcast("$stateChangeStart",b.self,c,j.self,l).defaultPrevented)return a.$broadcast("$stateChangeCancel",b.self,c,j.self,l),p.update(),C;for(var M=e.when(G),P=D;P =D;d--)g=o[d],g.self.onExit&&h.invoke(g.self.onExit,g.self,g.locals.globals),g.locals=null;for(d=D;d =0?e:e+"@"+(f?f.state.name:"")}function B(a,b){var c,d=a.match(/^\s*({[^}]*})\s*$/);if(d&&(a=b+"("+d[1]+")"),c=a.replace(/\n/g," ").match(/^([^(]+?)\s*(\((.*)\))?$/),!c||4!==c.length)throw new Error("Invalid state ref '"+a+"'");return{state:c[1],paramExpr:c[3]||null}}function C(a){var b=a.parent().inheritedData("$uiView");return b&&b.state&&b.state.name?b.state:void 0}function D(a,c){var d=["location","inherit","reload","absolute"];return{restrict:"A",require:["?^uiSrefActive","?^uiSrefActiveEq"],link:function(e,f,g,h){var i=B(g.uiSref,a.current.name),j=null,k=C(f)||a.$current,l="[object SVGAnimatedString]"===Object.prototype.toString.call(f.prop("href"))?"xlink:href":"href",m=null,n="A"===f.prop("tagName").toUpperCase(),o="FORM"===f[0].nodeName,p=o?"action":l,q=!0,r={relative:k,inherit:!0},s=e.$eval(g.uiSrefOpts)||{};b.forEach(d,function(a){a in s&&(r[a]=s[a])});var t=function(c){if(c&&(j=b.copy(c)),q){m=a.href(i.state,j,r);var d=h[1]||h[0];return d&&d.$$addStateInfo(i.state,j),null===m?(q=!1,!1):void g.$set(p,m)}};i.paramExpr&&(e.$watch(i.paramExpr,function(a,b){a!==j&&t(a)},!0),j=b.copy(e.$eval(i.paramExpr))),t(),o||f.bind("click",function(b){var d=b.which||b.button;if(!(d>1||b.ctrlKey||b.metaKey||b.shiftKey||f.attr("target"))){var e=c(function(){a.go(i.state,j,r)});b.preventDefault();var g=n&&!m?1:0;b.preventDefault=function(){g--<=0&&c.cancel(e)}}})}}}function E(a,b,c){return{restrict:"A",controller:["$scope","$element","$attrs",function(b,d,e){function f(){g()?d.addClass(i):d.removeClass(i)}function g(){for(var a=0;a e;e++){g=h[e];var l=this.params[g],m=d[e+1];for(f=0;f e;e++)g=h[e],k[g]=this.params[g].value(b[g]);return k},r.prototype.parameters=function(a){return H(a)?this.params[a]||null:this.$$paramNames},r.prototype.validates=function(a){return this.params.$$validates(a)},r.prototype.format=function(a){function b(a){return encodeURIComponent(a).replace(/-/g,function(a){return"%5C%"+a.charCodeAt(0).toString(16).toUpperCase()})}a=a||{};var c=this.segments,d=this.parameters(),e=this.params;if(!this.validates(a))return null;var f,g=!1,h=c.length-1,i=d.length,j=c[0];for(f=0;i>f;f++){var k=h>f,l=d[f],m=e[l],n=m.value(a[l]),p=m.isOptional&&m.type.equals(m.value(),n),q=p?m.squash:!1,r=m.type.encode(n);if(k){var s=c[f+1];if(q===!1)null!=r&&(j+=L(r)?o(r,b).join("-"):encodeURIComponent(r)),j+=s;else if(q===!0){var t=j.match(/\/$/)?/\/?(.*)/:/(.*)/;j+=s.match(t)[1]}else J(q)&&(j+=q+s)}else{if(null==r||p&&q!==!1)continue;L(r)||(r=[r]),r=o(r,encodeURIComponent).join("&"+l+"="),j+=(g?"&":"?")+(l+"="+r),g=!0}}return j},s.prototype.is=function(a,b){return!0},s.prototype.encode=function(a,b){return a},s.prototype.decode=function(a,b){return a},s.prototype.equals=function(a,b){return a==b},s.prototype.$subPattern=function(){var a=this.pattern.toString();return a.substr(1,a.length-2)},s.prototype.pattern=/.*/,s.prototype.toString=function(){return"{Type:"+this.name+"}"},s.prototype.$normalize=function(a){return this.is(a)?a:this.decode(a)},s.prototype.$asArray=function(a,b){function d(a,b){function d(a,b){return function(){return a[b].apply(a,arguments)}}function e(a){return L(a)?a:H(a)?[a]:[]}function f(a){switch(a.length){case 0:return c;case 1:return"auto"===b?a[0]:a;default:return a}}function g(a){return!a}function h(a,b){return function(c){c=e(c);var d=o(c,a);return b===!0?0===n(d,g).length:f(d)}}function i(a){return function(b,c){var d=e(b),f=e(c);if(d.length!==f.length)return!1;for(var g=0;g 1)throw"Multiple backgrounds are not supported";if(!d||"none"===d)throw"Element is not an but does not have a background-image";e[f]={img:new Image,el:e[f]},d=d.slice(4,-1),d=d.replace(/"/g,""),e[f].img.src=d,c("CSS Image - "+d)}return e}function g(a,b){var c=a;if("string"==typeof a?c=document.querySelectorAll(a):a&&1===a.nodeType&&(c=[a]),!c||0===c.length||void 0===c.length)throw"Elements not found";return b&&(c=f(c)),c=Array.prototype.slice.call(c)}function h(){C=document.createElement("canvas"),C&&C.getContext?(D=C.getContext("2d"),B=!0):B=!1,i()}function i(){z("debugOverlay")?(C.style.opacity=.5,C.style.pointerEvents="none",document.body.appendChild(C)):C.parentNode&&C.parentNode.removeChild(C)}function j(a){var d=(new Date).getTime()-a;c("Duration: "+d+"ms"),d>z("maxDuration")&&(console.log("BackgroundCheck - Killed"),q(),b())}function k(){F={left:0,top:0,right:document.body.clientWidth,bottom:window.innerHeight},C.width=document.body.clientWidth,C.height=window.innerHeight}function l(a,b,c){var d,e;return-1!==a.indexOf("px")?d=parseFloat(a):-1!==a.indexOf("%")?(d=parseFloat(a),e=d/100,d=e*b,c&&(d-=c*e)):d=b,d}function m(a){var b=window.getComputedStyle(a.el);a.el.style.backgroundRepeat="no-repeat",a.el.style.backgroundOrigin="padding-box";var c=b.backgroundSize.split(" "),d=c[0],e=void 0===c[1]?"auto":c[1],f=a.el.clientWidth/a.el.clientHeight,g=a.img.naturalWidth/a.img.naturalHeight;"cover"===d?f>=g?(d="100%",e="auto"):(d="auto",c[0]="auto",e="100%"):"contain"===d&&(1/g>1/f?(d="auto",c[0]="auto",e="100%"):(d="100%",e="auto")),d="auto"===d?a.img.naturalWidth:l(d,a.el.clientWidth),e="auto"===e?d/a.img.naturalWidth*a.img.naturalHeight:l(e,a.el.clientHeight),"auto"===c[0]&&"auto"!==c[1]&&(d=e/a.img.naturalHeight*a.img.naturalWidth);var h=b.backgroundPosition;"top"===h?h="50% 0%":"left"===h?h="0% 50%":"right"===h?h="100% 50%":"bottom"===h?h="50% 100%":"center"===h&&(h="50% 50%"),h=h.split(" ");var i,j;return 4===h.length?(i=h[1],j=h[3]):(i=h[0],j=h[1]),j=j||"50%",i=l(i,a.el.clientWidth,d),j=l(j,a.el.clientHeight,e),4===h.length&&("right"===h[0]&&(i=a.el.clientWidth-a.img.naturalWidth-i),"bottom"===h[2]&&(j=a.el.clientHeight-a.img.naturalHeight-j)),i+=a.el.getBoundingClientRect().left,j+=a.el.getBoundingClientRect().top,{left:Math.floor(i),right:Math.floor(i+d),top:Math.floor(j),bottom:Math.floor(j+e),width:Math.floor(d),height:Math.floor(e)}}function n(a){var b,c,d;if(a.nodeType){var e=a.getBoundingClientRect();b={left:e.left,right:e.right,top:e.top,bottom:e.bottom,width:e.width,height:e.height},d=a.parentNode,c=a}else b=m(a),d=a.el,c=a.img;d=d.getBoundingClientRect(),b.imageTop=0,b.imageLeft=0,b.imageWidth=c.naturalWidth,b.imageHeight=c.naturalHeight;var f,g=b.imageHeight/b.height;return b.top d.bottom&&(f=b.bottom-d.bottom,b.imageHeight-=g*f,b.height-=f),b.right>d.right&&(f=b.right-d.right,b.imageWidth-=g*f,b.width-=f),b.imageTop=Math.floor(b.imageTop),b.imageLeft=Math.floor(b.imageLeft),b.imageHeight=Math.floor(b.imageHeight),b.imageWidth=Math.floor(b.imageWidth),b}function o(a){var b=n(a);a=a.nodeType?a:a.img,b.imageWidth>0&&b.imageHeight>0&&b.width>0&&b.height>0?D.drawImage(a,b.imageLeft,b.imageTop,b.imageWidth,b.imageHeight,b.left,b.top,b.width,b.height):c("Skipping image - "+a.src+" - area too small")}function p(a,b,c){var d=a.className;switch(c){case"add":d+=" "+b;break;case"remove":var e=new RegExp("(?:^|\\s)"+b+"(?!\\S)","g");d=d.replace(e,"")}a.className=d.trim()}function q(a){for(var b,c=a?[a]:z("targets"),d=0;d 0&&g.height>0){q(a),a=z("changeParent")?a.parentNode:a,d=D.getImageData(g.left,g.top,g.width,g.height).data;for(var m=0;m z("minComplexity")/100&&p(a,z("classes").complex,"add"))}}function s(a,b){return a=(a.nodeType?a:a.el).getBoundingClientRect(),b=b===F?b:(b.nodeType?b:b.el).getBoundingClientRect(),!(a.right b.right||a.top>b.bottom||a.bottom g;g++)b=z("targets")[g],s(b,F)&&("targets"!==d||a&&a!==b?"image"===d&&s(b,a)&&r(b):(e=!0,r(b)));if("targets"===d&&!e)throw a+" is not a target";j(c)}function u(a){var b=function(a){var b=0;return"static"!==window.getComputedStyle(a).position&&(b=parseInt(window.getComputedStyle(a).zIndex,10)||0,b>=0&&b++),b},c=a.parentNode,d=c?b(c):0,e=b(a);return 1e5*d+e}function v(a){var b=!1;return a.sort(function(a,c){a=a.nodeType?a:a.el,c=c.nodeType?c:c.el;var d=a.compareDocumentPosition(c),e=0;return a=u(a),c=u(c),a>c&&(b=!0),a===c&&2===d?e=1:a===c&&4===d&&(e=-1),e||a-c}),c("Sorted: "+b),b&&c(a),b}function w(a,b,d){if(B){var e=z("mask");c("--- BackgroundCheck ---"),c("onLoad event: "+(d&&d.src)),b!==!0&&(D.clearRect(0,0,C.width,C.height),D.fillStyle="rgb("+e.r+", "+e.g+", "+e.b+")",D.fillRect(0,0,C.width,C.height));for(var f,g,h=d?[d]:z("images"),i=v(h),j=!1,k=0;k d;d++)c[d].fn.apply(c[d].ctx,b);return this},off:function(a,b){var c=this.e||(this.e={}),d=c[a],e=[];if(d&&b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&d[f].fn._!==b&&e.push(d[f]);return e.length?c[a]=e:delete c[a],this}},b.exports=d},{}],8:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a:{"default":a}}function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}c.__esModule=!0;var f=function(){function a(a,b){for(var c=0;c 0&&e.which!=g.which)&&!a(e.target).is(g.not)&&(!g.handle||a(e.target).closest(g.handle,e.currentTarget).length)&&(d.touched="touchstart"==e.type?this:null,g.propagates=1,g.mousedown=this,g.interactions=[d.interaction(this,g)],g.target=e.target,g.pageX=e.pageX,g.pageY=e.pageY,g.dragging=null,f=d.hijack(e,"draginit",g),g.propagates))return f=d.flatten(f),f&&f.length&&(g.interactions=[],a.each(f,function(){g.interactions.push(d.interaction(this,g))})),g.propagates=g.interactions.length,g.drop!==!1&&c.drop&&c.drop.handler(e,g),d.textselect(!1),d.touched?b.add(d.touched,"touchmove touchend",d.handler,g):b.add(document,"mousemove mouseup",d.handler,g),!d.touched||g.live?!1:void 0}},interaction:function(b,c){var e=a(b)[c.relative?"position":"offset"]()||{top:0,left:0};return{drag:b,callback:new d.callback,droppable:[],offset:e}},handler:function(e){var f=e.data;switch(e.type){case!f.dragging&&"touchmove":e.preventDefault();case!f.dragging&&"mousemove":if(Math.pow(e.pageX-f.pageX,2)+Math.pow(e.pageY-f.pageY,2) 0?void a.removeData(this,"suppress."+b.type):e.apply(this,arguments)};var f=b.fixHooks.touchstart=b.fixHooks.touchmove=b.fixHooks.touchend=b.fixHooks.touchcancel={props:"clientX clientY pageX pageY screenX screenY".split(" "),filter:function(b,c){if(c){var d=c.touches&&c.touches[0]||c.changedTouches&&c.changedTouches[0]||null;d&&a.each(f.props,function(a,c){b[c]=d[c]})}return b}};c.draginit=c.dragstart=c.dragend=d}(jQuery),function(a){a.fn.drop=function(b,c,d){var e="string"==typeof b?b:"",f=a.isFunction(b)?b:a.isFunction(c)?c:null;return 0!==e.indexOf("drop")&&(e="drop"+e),d=(b==f?c:d)||{},f?this.bind(e,d,f):this.trigger(e)},a.drop=function(b){b=b||{},d.multi=b.multi===!0?1/0:b.multi===!1?1:isNaN(b.multi)?d.multi:b.multi,d.delay=b.delay||d.delay,d.tolerance=a.isFunction(b.tolerance)?b.tolerance:null===b.tolerance?null:d.tolerance,d.mode=b.mode||d.mode||"intersect"};var b=a.event,c=b.special,d=a.event.special.drop={multi:1,delay:20,mode:"overlap",targets:[],datakey:"dropdata",noBubble:!0,add:function(b){var c=a.data(this,d.datakey);c.related+=1},remove:function(){a.data(this,d.datakey).related-=1},setup:function(){if(!a.data(this,d.datakey)){var b={related:0,active:[],anyactive:0,winner:0,location:{}};a.data(this,d.datakey,b),d.targets.push(this)}},teardown:function(){var b=a.data(this,d.datakey)||{};if(!b.related){a.removeData(this,d.datakey);var c=this;d.targets=a.grep(d.targets,function(a){return a!==c})}},handler:function(b,e){var f;if(e)switch(b.type){case"mousedown":case"touchstart":f=a(d.targets),"string"==typeof e.drop&&(f=f.filter(e.drop)),f.each(function(){var b=a.data(this,d.datakey);b.active=[],b.anyactive=0,b.winner=0}),e.droppable=f,c.drag.hijack(b,"dropinit",e);break;case"mousemove":case"touchmove":d.event=b,d.timer||d.tolerate(e);break;case"mouseup":case"touchend":d.timer=clearTimeout(d.timer),e.propagates&&(c.drag.hijack(b,"drop",e),c.drag.hijack(b,"dropend",e))}},locate:function(b,c){var e=a.data(b,d.datakey),f=a(b),g=f.offset()||{},h=f.outerHeight(),i=f.outerWidth(),j={elem:b,width:i,height:h,top:g.top,left:g.left,right:g.left+i,bottom:g.top+h};return e&&(e.location=j,e.index=c,e.elem=b),j},contains:function(a,b){return(b[0]||b.left)>=a.left&&(b[0]||b.right)<=a.right&&(b[1]||b.top)>=a.top&&(b[1]||b.bottom)<=a.bottom},modes:{intersect:function(a,b,c){return this.contains(c,[a.pageX,a.pageY])?1e9:this.modes.overlap.apply(this,arguments)},overlap:function(a,b,c){return Math.max(0,Math.min(c.bottom,b.bottom)-Math.max(c.top,b.top))*Math.max(0,Math.min(c.right,b.right)-Math.max(c.left,b.left))},fit:function(a,b,c){return this.contains(c,b)?1:0},middle:function(a,b,c){return this.contains(c,[b.left+.5*b.width,b.top+.5*b.height])?1:0}},sort:function(a,b){return b.winner-a.winner||a.index-b.index},tolerate:function(b){var e,f,g,h,i,j,k,l,m=0,n=b.interactions.length,o=[d.event.pageX,d.event.pageY],p=d.tolerance||d.modes[d.mode];do if(l=b.interactions[m]){if(!l)return;l.drop=[],i=[],j=l.droppable.length,p&&(g=d.locate(l.proxy)),e=0;do if(k=l.droppable[e]){if(h=a.data(k,d.datakey),f=h.location,!f)continue;h.winner=p?p.call(d,d.event,g,f):d.contains(f,o)?1:0,i.push(h)}while(++e =k?h():g.set(l/k)),a):(f.error("Broken interceptor detected: Config object not supplied in response:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),a)},responseError:function(a){return a&&a.config?(a.config.ignoreLoadingBar||i(a.config)||(l++,e.$broadcast("cfpLoadingBar:loaded",{url:a.config.url,result:a}),l>=k?h():g.set(l/k)),b.reject(a)):(f.error("Broken interceptor detected: Config object not supplied in rejection:\n https://github.com/chieffancypants/angular-loading-bar/pull/50"),b.reject(a))}}}];a.interceptors.push(b)}]),angular.module("cfp.loadingBar",[]).provider("cfpLoadingBar",function(){this.autoIncrement=!0,this.includeSpinner=!0,this.includeBar=!0,this.latencyThreshold=100,this.startSize=.02,this.parentSelector="#body",this.spinnerTemplate=' ',this.loadingBarTemplate='',this.$get=["$injector","$document","$timeout","$rootScope",function(a,b,c,d){function e(){k||(k=a.get("$animate"));var e=b.find(n).eq(0);c.cancel(m),r||(d.$broadcast("cfpLoadingBar:started"),r=!0,v&&k.enter(o,e,angular.element(e[0].lastChild)),u&&k.enter(q,e,angular.element(e[0].lastChild)),f(w))}function f(a){if(r){var b=100*a+"%";p.css("width",b),s=a,t&&(c.cancel(l),l=c(function(){g()},250))}}function g(){if(!(h()>=1)){var a=0,b=h();a=b>=0&&.25>b?(3*Math.random()+3)/100:b>=.25&&.65>b?3*Math.random()/100:b>=.65&&.9>b?2*Math.random()/100:b>=.9&&.99>b?.005:0;var c=h()+a;f(c)}}function h(){return s}function i(){s=0,r=!1}function j(){k||(k=a.get("$animate")),d.$broadcast("cfpLoadingBar:completed"),f(1),c.cancel(m),m=c(function(){var a=k.leave(o,i);a&&a.then&&a.then(i),k.leave(q)},500)}var k,l,m,n=this.parentSelector,o=angular.element(this.loadingBarTemplate),p=o.find("div").eq(0),q=angular.element(this.spinnerTemplate),r=!1,s=0,t=this.autoIncrement,u=this.includeSpinner,v=this.includeBar,w=this.startSize;return{start:e,set:f,status:h,inc:g,complete:j,autoIncrement:this.autoIncrement,includeSpinner:this.includeSpinner,latencyThreshold:this.latencyThreshold,parentSelector:this.parentSelector,startSize:this.startSize}}]})}(),!function(a){if("object"==typeof exports)module.exports=a();else if("function"==typeof define&&define.amd)define(a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.Mopidy=a()}}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g0)for(d=0;e>d;++d)c[d](a,b);else setTimeout(function(){throw b.message=a+" listener threw error: "+b.message,b},0)}function b(a){if("function"!=typeof a)throw new TypeError("Listener is not function");return a}function c(a){return a.supervisors||(a.supervisors=[]),a.supervisors}function d(a,b){return a.listeners||(a.listeners={}),b&&!a.listeners[b]&&(a.listeners[b]=[]),b?a.listeners[b]:a.listeners}function e(a){return a.errbacks||(a.errbacks=[]),a.errbacks}function f(f){function h(b,c,d){try{c.listener.apply(c.thisp||f,d)}catch(g){a(b,g,e(f))}}return f=f||{},f.on=function(a,e,f){return"function"==typeof a?c(this).push({listener:a,thisp:e}):void d(this,a).push({listener:b(e),thisp:f})},f.off=function(a,b){var f,g,h,i;if(!a){f=c(this),f.splice(0,f.length),g=d(this);for(h in g)g.hasOwnProperty(h)&&(f=d(this,h),f.splice(0,f.length));return f=e(this),void f.splice(0,f.length)}if("function"==typeof a?(f=c(this),b=a):f=d(this,a),!b)return void f.splice(0,f.length);for(h=0,i=f.length;i>h;++h)if(f[h].listener===b)return void f.splice(h,1)},f.once=function(a,b,c){var d=function(){f.off(a,d),b.apply(this,arguments)};f.on(a,d,c)},f.bind=function(a,b){var c,d,e;if(b)for(d=0,e=b.length;e>d;++d){if("function"!=typeof a[b[d]])throw new Error("No such method "+b[d]);this.on(b[d],a[b[d]],a)}else for(c in a)"function"==typeof a[c]&&this.on(c,a[c],a);return a},f.emit=function(a){var b,e,f=c(this),i=g.call(arguments);for(b=0,e=f.length;e>b;++b)h(a,f[b],i);for(f=d(this,a).slice(),i=g.call(arguments,1),b=0,e=f.length;e>b;++b)h(a,f[b],i)},f.errback=function(a){this.errbacks||(this.errbacks=[]),this.errbacks.push(b(a))},f}var g=Array.prototype.slice;return{createEventEmitter:f,aggregate:function(a){var b=f();return a.forEach(function(a){a.on(function(a,c){b.emit(a,c)})}),b}}})},{}],3:[function(a,b){function c(){}var d=b.exports={};d.nextTick=function(){var a="undefined"!=typeof window&&window.setImmediate,b="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(a)return function(a){return window.setImmediate(a)};if(b){var c=[];return window.addEventListener("message",function(a){var b=a.source;if((b===window||null===b)&&"process-tick"===a.data&&(a.stopPropagation(),c.length>0)){var d=c.shift();d()}},!0),function(a){c.push(a),window.postMessage("process-tick","*")}}return function(a){setTimeout(a,0)}}(),d.title="browser",d.browser=!0,d.env={},d.argv=[],d.on=c,d.addListener=c,d.once=c,d.off=c,d.removeListener=c,d.removeAllListeners=c,d.emit=c,d.binding=function(){throw new Error("process.binding is not supported")},d.cwd=function(){return"/"},d.chdir=function(){throw new Error("process.chdir is not supported")}},{}],4:[function(b,c){!function(a){"use strict";a(function(a){var b=a("./makePromise"),c=a("./Scheduler"),d=a("./env").asap;return b({scheduler:new c(d)})})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"./Scheduler":5,"./env":17,"./makePromise":19}],5:[function(b,c){!function(a){"use strict";a(function(){function a(a){this._async=a,this._running=!1,this._queue=this,this._queueLen=0,this._afterQueue={},this._afterQueueLen=0;var b=this;this.drain=function(){b._drain()}}return a.prototype.enqueue=function(a){this._queue[this._queueLen++]=a,this.run()},a.prototype.afterQueue=function(a){this._afterQueue[this._afterQueueLen++]=a,this.run()},a.prototype.run=function(){this._running||(this._running=!0,this._async(this.drain))},a.prototype._drain=function(){for(var a=0;a >>0,j=i,k=[],l=0;i>l;++l)if(f=b[l],void 0!==f||l in b){if(e=a._handler(f),e.state()>0){h.become(e),a._visitRemaining(b,l,e);break}e.visit(h,c,d)}else--j;return 0===j&&h.reject(new RangeError("any(): array must not be empty")),g}function e(b,c){function d(a){this.resolved||(k.push(a),0===--n&&(l=null,this.resolve(k)))}function e(a){this.resolved||(l.push(a),0===--f&&(k=null,this.reject(l)))}var f,g,h,i=a._defer(),j=i._handler,k=[],l=[],m=b.length>>>0,n=0;for(h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&++n;for(c=Math.max(c,0),f=n-c+1,n=Math.min(c,n),c>n?j.reject(new RangeError("some(): array must contain at least "+c+" item(s), but had "+n)):0===n&&j.resolve(k),h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&a._handler(g).visit(j,d,e,j.notify);return i}function f(b,c){return a._traverse(c,b)}function g(b,c){var d=s.call(b);return a._traverse(c,d).then(function(a){return h(d,a)})}function h(b,c){for(var d=c.length,e=new Array(d),f=0,g=0;d>f;++f)c[f]&&(e[g++]=a._handler(b[f]).value);return e.length=g,e}function i(a){return p(a.map(j))}function j(c){var d=a._handler(c);return 0===d.state()?o(c).then(b.fulfilled,b.rejected):(d._unreport(),b.inspect(d))}function k(a,b){return arguments.length>2?q.call(a,m(b),arguments[2]):q.call(a,m(b))}function l(a,b){return arguments.length>2?r.call(a,m(b),arguments[2]):r.call(a,m(b))}function m(a){return function(b,c,d){return n(a,void 0,[b,c,d])}}var n=c(a),o=a.resolve,p=a.all,q=Array.prototype.reduce,r=Array.prototype.reduceRight,s=Array.prototype.slice;return a.any=d,a.some=e,a.settle=i,a.map=f,a.filter=g,a.reduce=k,a.reduceRight=l,a.prototype.spread=function(a){return this.then(p).then(function(b){return a.apply(this,b)})},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../apply":7,"../state":20}],9:[function(b,c){!function(a){"use strict";a(function(){function a(){throw new TypeError("catch predicate must be a function")}function b(a,b){return c(b)?a instanceof b:b(a)}function c(a){return a===Error||null!=a&&a.prototype instanceof Error}function d(a){return("object"==typeof a||"function"==typeof a)&&null!==a}function e(a){return a}return function(c){function f(a,c){return function(d){return b(d,c)?a.call(this,d):j(d)}}function g(a,b,c,e){var f=a.call(b);return d(f)?h(f,c,e):c(e)}function h(a,b,c){return i(a).then(function(){return b(c)})}var i=c.resolve,j=c.reject,k=c.prototype["catch"];return c.prototype.done=function(a,b){this._handler.visit(this._handler.receiver,a,b)},c.prototype["catch"]=c.prototype.otherwise=function(b){return arguments.length<2?k.call(this,b):"function"!=typeof b?this.ensure(a):k.call(this,f(arguments[1],b))},c.prototype["finally"]=c.prototype.ensure=function(a){return"function"!=typeof a?this:this.then(function(b){return g(a,this,e,b)},function(b){return g(a,this,j,b)})},c.prototype["else"]=c.prototype.orElse=function(a){return this.then(void 0,function(){return a})},c.prototype["yield"]=function(a){return this.then(function(){return a})},c.prototype.tap=function(a){return this.then(a)["yield"](this)},c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],10:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.fold=function(b,c){var d=this._beget();return this._handler.fold(function(c,d,e){a._handler(c).fold(function(a,c,d){d.resolve(b.call(this,c,a))},d,this,e)},c,d._handler.receiver,d._handler),d},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],11:[function(b,c){!function(a){"use strict";a(function(a){var b=a("../state").inspect;return function(a){return a.prototype.inspect=function(){return b(a._handler(this))},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../state":20}],12:[function(b,c){!function(a){"use strict";a(function(){return function(a){function b(a,b,d,e){return c(function(b){return[b,a(b)]},b,d,e)}function c(a,b,e,f){function g(f,g){return d(e(f)).then(function(){return c(a,b,e,g)})}return d(f).then(function(c){return d(b(c)).then(function(b){return b?c:d(a(c)).spread(g)})})}var d=a.resolve;return a.iterate=b,a.unfold=c,a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],13:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.progress=function(a){return this.then(void 0,void 0,a)},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],14:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,d,e){return c.setTimer(function(){a(d,e,b)},b)}var c=a("../env"),d=a("../TimeoutError");return function(a){function e(a,c,d){b(f,a,c,d)}function f(a,b){b.resolve(a)}function g(a,b,c){var e="undefined"==typeof a?new d("timed out after "+c+"ms"):a;b.reject(e)}return a.prototype.delay=function(a){var b=this._beget();return this._handler.fold(e,a,void 0,b._handler),b},a.prototype.timeout=function(a,d){var e=this._beget(),f=e._handler,h=b(g,a,d,e._handler);return this._handler.visit(f,function(a){c.clearTimer(h),this.resolve(a)},function(a){c.clearTimer(h),this.reject(a)},f.notify),e},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../TimeoutError":6,"../env":17}],15:[function(b,c){!function(a){"use strict";a(function(a){function b(a){throw a}function c(){}var d=a("../env").setTimer,e=a("../format");return function(a){function f(a){a.handled||(n.push(a),k("Potentially unhandled rejection ["+a.id+"] "+e.formatError(a.value)))}function g(a){var b=n.indexOf(a);b>=0&&(n.splice(b,1),l("Handled previous rejection ["+a.id+"] "+e.formatObject(a.value)))}function h(a,b){m.push(a,b),null===o&&(o=d(i,0))}function i(){for(o=null;m.length>0;)m.shift()(m.shift())}var j,k=c,l=c;"undefined"!=typeof console&&(j=console,k="undefined"!=typeof j.error?function(a){j.error(a)}:function(a){j.log(a)},l="undefined"!=typeof j.info?function(a){j.info(a)}:function(a){j.log(a)}),a.onPotentiallyUnhandledRejection=function(a){h(f,a)},a.onPotentiallyUnhandledRejectionHandled=function(a){h(g,a)},a.onFatalRejection=function(a){h(b,a.value)};var m=[],n=[],o=null;return a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../env":17,"../format":18}],16:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype["with"]=a.prototype.withThis=function(a){var b=this._beget(),c=b._handler;return c.receiver=a,this._handler.chain(c,a),b},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],17:[function(b,c){(function(d){!function(a){"use strict";a(function(a){function b(){return"undefined"!=typeof d&&null!==d&&"function"==typeof d.nextTick}function c(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function e(a){function b(){var a=c;c=void 0,a()}var c,d=document.createTextNode(""),e=new a(b);e.observe(d,{characterData:!0});var f=0;return function(a){c=a,d.data=f^=1}}var f,g="undefined"!=typeof setTimeout&&setTimeout,h=function(a,b){return setTimeout(a,b)},i=function(a){return clearTimeout(a)},j=function(a){return g(a,0)};if(b())j=function(a){return d.nextTick(a)};else if(f=c())j=e(f);else if(!g){var k=a,l=k("vertx");h=function(a,b){return l.setTimer(b,a)},i=l.cancelTimer,j=l.runOnLoop||l.runOnContext}return{setTimer:h,clearTimer:i,asap:j}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})}).call(this,b("FWaASH"))},{FWaASH:3}],18:[function(b,c){!function(a){"use strict";a(function(){function a(a){var c="object"==typeof a&&null!==a&&a.stack?a.stack:b(a);return a instanceof Error?c:c+" (WARNING: non-Error used)"}function b(a){var b=String(a);return"[object Object]"===b&&"undefined"!=typeof JSON&&(b=c(a,b)),b}function c(a,b){try{return JSON.stringify(a)}catch(c){return b}}return{formatError:a,formatObject:b,tryStringify:c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],19:[function(b,c){(function(b){!function(a){"use strict";a(function(){return function(a){function c(a,b){this._handler=a===u?b:d(a)}function d(a){function b(a){e.resolve(a)}function c(a){e.reject(a)}function d(a){e.notify(a)}var e=new w;try{a(b,c,d)}catch(f){c(f)}return e}function e(a){return J(a)?a:new c(u,new x(r(a)))}function f(a){return new c(u,new x(new A(a)))}function g(){return aa}function h(){return new c(u,new w)}function i(a,b){var c=new w(a.receiver,a.join().context);return new b(u,c)}function j(a){return l(T,null,a)}function k(a,b){return l(O,a,b)}function l(a,b,d){function e(c,e,g){g.resolved||m(d,f,c,a(b,e,c),g)}function f(a,b,c){k[a]=b,0===--j&&c.become(new z(k))}for(var g,h="function"==typeof b?e:f,i=new w,j=d.length>>>0,k=new Array(j),l=0;l 0?b(c,f.value,e):(e.become(f),n(a,c+1,f))}else b(c,d,e)}function n(a,b,c){for(var d=b;d c&&a._unreport()}}function p(a){return"object"!=typeof a||null===a?f(new TypeError("non-iterable passed to race()")):0===a.length?g():1===a.length?e(a[0]):q(a)}function q(a){var b,d,e,f=new w;for(b=0;b 0||"function"!=typeof b&&0>e)return new this.constructor(u,d);var f=this._beget(),g=f._handler;return d.chain(g,d.receiver,a,b,c),f},c.prototype["catch"]=function(a){return this.then(void 0,a)},c.prototype._beget=function(){return i(this._handler,this.constructor)},c.all=j,c.race=p,c._traverse=k,c._visitRemaining=n,u.prototype.when=u.prototype.become=u.prototype.notify=u.prototype.fail=u.prototype._unreport=u.prototype._report=U,u.prototype._state=0,u.prototype.state=function(){return this._state},u.prototype.join=function(){for(var a=this;void 0!==a.handler;)a=a.handler;return a},u.prototype.chain=function(a,b,c,d,e){this.when({resolver:a,receiver:b,fulfilled:c,rejected:d,progress:e})},u.prototype.visit=function(a,b,c,d){this.chain(Z,a,b,c,d)},u.prototype.fold=function(a,b,c,d){this.when(new I(a,b,c,d))},S(u,v),v.prototype.become=function(a){a.fail()};var Z=new v;S(u,w),w.prototype._state=0,w.prototype.resolve=function(a){this.become(r(a))},w.prototype.reject=function(a){this.resolved||this.become(new A(a))},w.prototype.join=function(){if(!this.resolved)return this;for(var a=this;void 0!==a.handler;)if(a=a.handler,a===this)return this.handler=D();return a},w.prototype.run=function(){var a=this.consumers,b=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var c=0;c 0?c(d.value):b(d.value)}return{pending:a,fulfilled:c,rejected:b,inspect:d}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],21:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,c,d){var e=x.resolve(a);return arguments.length<2?e:e.then(b,c,d)}function c(a){return new x(a)}function d(a){return function(){for(var b=0,c=arguments.length,d=new Array(c);c>b;++b)d[b]=arguments[b];return y(a,this,d)}}function e(a){for(var b=0,c=arguments.length-1,d=new Array(c);c>b;++b)d[b]=arguments[b+1];return y(a,this,d)}function f(){return new g}function g(){function a(a){d._handler.resolve(a)}function b(a){d._handler.reject(a)}function c(a){d._handler.notify(a)}var d=x._defer();this.promise=d,this.resolve=a,this.reject=b,this.notify=c,this.resolver={resolve:a,reject:b,notify:c}}function h(a){return a&&"function"==typeof a.then}function i(){return x.all(arguments)}function j(a){return b(a,x.all)}function k(a){return b(a,x.settle)}function l(a,c){return b(a,function(a){return x.map(a,c)})}function m(a,c){return b(a,function(a){return x.filter(a,c)})}var n=a("./lib/decorators/timed"),o=a("./lib/decorators/array"),p=a("./lib/decorators/flow"),q=a("./lib/decorators/fold"),r=a("./lib/decorators/inspect"),s=a("./lib/decorators/iterate"),t=a("./lib/decorators/progress"),u=a("./lib/decorators/with"),v=a("./lib/decorators/unhandledRejection"),w=a("./lib/TimeoutError"),x=[o,p,q,s,t,r,u,n,v].reduce(function(a,b){return b(a)},a("./lib/Promise")),y=a("./lib/apply")(x);return b.promise=c,b.resolve=x.resolve,b.reject=x.reject,b.lift=d,b["try"]=e,b.attempt=e,b.iterate=x.iterate,b.unfold=x.unfold,b.join=i,b.all=j,b.settle=k,b.any=d(x.any),b.some=d(x.some),b.race=d(x.race),b.map=l,b.filter=m,b.reduce=d(x.reduce),b.reduceRight=d(x.reduceRight),b.isPromiseLike=h,b.Promise=x,b.defer=f,b.TimeoutError=w,b})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"./lib/Promise":4,"./lib/TimeoutError":6,"./lib/apply":7,"./lib/decorators/array":8,"./lib/decorators/flow":9,"./lib/decorators/fold":10,"./lib/decorators/inspect":11,"./lib/decorators/iterate":12,"./lib/decorators/progress":13,"./lib/decorators/timed":14,"./lib/decorators/unhandledRejection":15,"./lib/decorators/with":16}],22:[function(a,b){function c(a){return this instanceof c?(this._console=this._getConsole(a||{}),this._settings=this._configure(a||{}),this._backoffDelay=this._settings.backoffDelayMin,this._pendingRequests={},this._webSocket=null,d.createEventEmitter(this),this._delegateEvents(),void(this._settings.autoConnect&&this.connect())):new c(a)}var d=a("bane"),e=a("../lib/websocket/"),f=a("when");c.ConnectionError=function(a){this.name="ConnectionError",this.message=a},c.ConnectionError.prototype=Object.create(Error.prototype),c.ConnectionError.prototype.constructor=c.ConnectionError,c.ServerError=function(a){this.name="ServerError",this.message=a},c.ServerError.prototype=Object.create(Error.prototype),c.ServerError.prototype.constructor=c.ServerError,c.WebSocket=e.Client,c.when=f,c.prototype._getConsole=function(a){if("undefined"!=typeof a.console)return a.console;var b="undefined"!=typeof console&&console||{};return b.log=b.log||function(){},b.warn=b.warn||function(){},b.error=b.error||function(){},b},c.prototype._configure=function(a){var b="undefined"!=typeof document&&"https:"===document.location.protocol?"wss://":"ws://",c="undefined"!=typeof document&&document.location.host||"localhost";return a.webSocketUrl=a.webSocketUrl||b+c+"/mopidy/ws",a.autoConnect!==!1&&(a.autoConnect=!0),a.backoffDelayMin=a.backoffDelayMin||1e3,a.backoffDelayMax=a.backoffDelayMax||64e3,"undefined"==typeof a.callingConvention&&this._console.warn("Mopidy.js is using the default calling convention. The default will change in the future. You should explicitly specify which calling convention you use."),a.callingConvention=a.callingConvention||"by-position-only",a},c.prototype._delegateEvents=function(){this.off("websocket:close"),this.off("websocket:error"),this.off("websocket:incomingMessage"),this.off("websocket:open"),this.off("state:offline"),this.on("websocket:close",this._cleanup),this.on("websocket:error",this._handleWebSocketError),this.on("websocket:incomingMessage",this._handleMessage),this.on("websocket:open",this._resetBackoffDelay),this.on("websocket:open",this._getApiSpec),this.on("state:offline",this._reconnect)},c.prototype.connect=function(){if(this._webSocket){if(this._webSocket.readyState===c.WebSocket.OPEN)return;this._webSocket.close()}this._webSocket=this._settings.webSocket||new c.WebSocket(this._settings.webSocketUrl),this._webSocket.onclose=function(a){this.emit("websocket:close",a)}.bind(this),this._webSocket.onerror=function(a){this.emit("websocket:error",a)}.bind(this),this._webSocket.onopen=function(){this.emit("websocket:open")}.bind(this),this._webSocket.onmessage=function(a){this.emit("websocket:incomingMessage",a)}.bind(this)},c.prototype._cleanup=function(a){Object.keys(this._pendingRequests).forEach(function(b){var d=this._pendingRequests[b];delete this._pendingRequests[b];var e=new c.ConnectionError("WebSocket closed");e.closeEvent=a,d.reject(e)}.bind(this)),this.emit("state:offline")},c.prototype._reconnect=function(){this.emit("reconnectionPending",{timeToAttempt:this._backoffDelay}),setTimeout(function(){this.emit("reconnecting"),this.connect()}.bind(this),this._backoffDelay),this._backoffDelay=2*this._backoffDelay,this._backoffDelay>this._settings.backoffDelayMax&&(this._backoffDelay=this._settings.backoffDelayMax)},c.prototype._resetBackoffDelay=function(){this._backoffDelay=this._settings.backoffDelayMin},c.prototype.close=function(){this.off("state:offline",this._reconnect),this._webSocket.close()},c.prototype._handleWebSocketError=function(a){this._console.warn("WebSocket error:",a.stack||a)},c.prototype._send=function(a){switch(this._webSocket.readyState){case c.WebSocket.CONNECTING:return f.reject(new c.ConnectionError("WebSocket is still connecting"));case c.WebSocket.CLOSING:return f.reject(new c.ConnectionError("WebSocket is closing"));case c.WebSocket.CLOSED:return f.reject(new c.ConnectionError("WebSocket is closed"));default:var b=f.defer();return a.jsonrpc="2.0",a.id=this._nextRequestId(),this._pendingRequests[a.id]=b.resolver,this._webSocket.send(JSON.stringify(a)),this.emit("websocket:outgoingMessage",a),b.promise}},c.prototype._nextRequestId=function(){var a=-1;return function(){return a+=1}}(),c.prototype._handleMessage=function(a){try{var b=JSON.parse(a.data);b.hasOwnProperty("id")?this._handleResponse(b):b.hasOwnProperty("event")?this._handleEvent(b):this._console.warn("Unknown message type received. Message was: "+a.data)}catch(c){if(!(c instanceof SyntaxError))throw c;this._console.warn("WebSocket message parsing failed. Message was: "+a.data)}},c.prototype._handleResponse=function(a){if(!this._pendingRequests.hasOwnProperty(a.id))return void this._console.warn("Unexpected response received. Message was:",a);var b,d=this._pendingRequests[a.id];delete this._pendingRequests[a.id],a.hasOwnProperty("result")?d.resolve(a.result):a.hasOwnProperty("error")?(b=new c.ServerError(a.error.message),b.code=a.error.code,b.data=a.error.data,d.reject(b),this._console.warn("Server returned error:",a.error)):(b=new Error("Response without 'result' or 'error' received"),b.data={response:a},d.reject(b),this._console.warn("Response without 'result' or 'error' received. Message was:",a))},c.prototype._handleEvent=function(a){var b=a.event,c=a;delete c.event,this.emit("event:"+this._snakeToCamel(b),c)},c.prototype._getApiSpec=function(){return this._send({method:"core.describe"}).then(this._createApi.bind(this))["catch"](this._handleWebSocketError)},c.prototype._createApi=function(a){var b="by-position-or-by-name"===this._settings.callingConvention,c=function(a){return function(){var c={method:a};return 0===arguments.length?this._send(c):b?arguments.length>1?f.reject(new Error("Expected zero arguments, a single array, or a single object.")):Array.isArray(arguments[0])||arguments[0]===Object(arguments[0])?(c.params=arguments[0],this._send(c)):f.reject(new TypeError("Expected an array or an object.")):(c.params=Array.prototype.slice.call(arguments),this._send(c))}.bind(this)}.bind(this),d=function(a){var b=a.split(".");return b.length>=1&&"core"===b[0]&&(b=b.slice(1)),b},e=function(a){var b=this;return a.forEach(function(a){a=this._snakeToCamel(a),b[a]=b[a]||{},b=b[a]}.bind(this)),b}.bind(this),g=function(b){var f=d(b),g=this._snakeToCamel(f.slice(-1)[0]),h=e(f.slice(0,-1));h[g]=c(b),h[g].description=a[b].description,h[g].params=a[b].params}.bind(this);Object.keys(a).forEach(g),this.emit("state:online")},c.prototype._snakeToCamel=function(a){return a.replace(/(_[a-z])/g,function(a){return a.toUpperCase().replace("_","")})},b.exports=c},{"../lib/websocket/":1,bane:2,when:21}]},{},[22])(22)}),function(){"use strict";var a,b,c="ngclipboard";"object"==typeof module&&module.exports?(a=require("angular"),b=require("clipboard"),module.exports=c):(a=window.angular,b=window.Clipboard),a.module(c,[]).directive("ngclipboard",["$rootScope",function(a){return{restrict:"A",scope:{ngclipboardSuccess:"&",ngclipboardError:"&"},link:function(c,d){var e=new b(d[0],{text:function(b){return a.selectedTrackURIs}});e.on("success",function(a){c.$apply(function(){c.ngclipboardSuccess({e:a})})}),e.on("error",function(a){c.$apply(function(){c.ngclipboardError({e:a})})})}}}])}(),angular.module("spotmop",["ngResource","ngStorage","ngTouch","ui.router","angular-loading-bar","angular-google-analytics","ngclipboard","spotmop.directives","spotmop.common.contextmenu","spotmop.common.track","spotmop.common.tracklist","spotmop.services.notify","spotmop.services.settings","spotmop.services.player","spotmop.services.spotify","spotmop.services.mopidy","spotmop.services.lastfm","spotmop.services.dialog","spotmop.services.pusher","spotmop.player","spotmop.queue","spotmop.library","spotmop.local","spotmop.search","spotmop.settings","spotmop.discover","spotmop.browse","spotmop.browse.artist","spotmop.browse.album","spotmop.browse.playlist","spotmop.browse.user","spotmop.browse.genre","spotmop.browse.featured","spotmop.browse.new"]).config(["$stateProvider","$locationProvider","$urlRouterProvider","$httpProvider","AnalyticsProvider","cfpLoadingBarProvider",function(a,b,c,d,e,f){c.otherwise("queue"),d.interceptors.push("SpotifyServiceIntercepter"),e.useAnalytics(!0),e.setAccount("UA-64701652-3"),f.parentSelector="body"}]).run(["$rootScope","SettingsService","Analytics",function(a,b,c){}]).controller("ApplicationController",["$scope","$rootScope","$state","$localStorage","$timeout","$location","SpotifyService","MopidyService","PlayerService","SettingsService","NotifyService","PusherService","DialogService","Analytics",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){n.trackEvent("Spotmop","Started"),b.isTouchDevice=function(){return!!("ontouchstart"in window)},b.isTouchMode=function(){var a=j.getSetting("spotmop",!1,"pointerMode");return"touch"==a?!0:"click"==a?!1:b.isTouchDevice()},a.isSameDomainAsMopidy=function(){var a=j.getSetting("mopidyhost","localhost");return a&&"localhost"!=a?f.host()==a?!0:void 0:!0},a.state=i.state,b.currentTracklist=[],a.spotifyUser={},a.menuCollapsable=!1,a.reloadApp=function(){window.location.reload()},a.playlistsMenu=[],a.myPlaylists={},a.popupVolumeControls=function(){m.create("volumeControls",a)},a.updatePlaylists=function(b){g.getPlaylists(b,50).then(function(b){a.myPlaylists=b.items;var c=[];$.each(b.items,function(b,d){if(d.owner.id==a.spotifyUser.id){var e=d;e.link="/browse/playlist/"+d.uri,e.link="/browse/playlist/"+d.uri,c.push(e)}}),a.playlistsMenu=c})},a.windowWidth=$(document).width(),a.windowHeight=$(document).height(),a.mediumScreen=function(){return a.windowWidth<=800?!0:!1},a.smallScreen=function(){return a.windowWidth<=450?!0:!1},$(window).resize(function(){$(document).width()!=a.windowWidth&&(a.windowWidth=$(document).width(),$(document).find("body").removeClass("menu-revealed"))}),b.$on("$stateChangeStart",function(b){a.hideMenu(),a.$broadcast("spotmop:contextMenu:hide"),n.trackPage(f.path())}),$(document).on("click","#body",function(b){$(b.target).closest(".menu-reveal-trigger").length<=0&&a.hideMenu()}),a.showMenu=function(){$(document).find("body").addClass("menu-revealed")},a.hideMenu=function(){$(document).find("body").removeClass("menu-revealed")},a.checkForLazyLoading=function(){var b=$(document).scrollTop(),c=$(window).height(),d=$(document).height(),e=d-(b+c);100>=e&&a.$broadcast("spotmop:loadMore")},$(document).on("scroll",function(c){a.checkForLazyLoading(),b.isTouchMode()||b.$broadcast("spotmop:contextMenu:hide")}),a.searchSubmit=function(a){n.trackEvent("Search","Performed search",a);var b=g.uriType(a);b?(k.notify("You've been redirected because that looked like a Spotify URI"),"artist"==b?($(document).find(".search-form input").val(""),c.go("browse.artist.overview",{uri:a})):"album"==b?($(document).find(".search-form input").val(""),c.go("browse.album",{uri:a})):"playlist"==b&&($(document).find(".search-form input").val(""),c.go("browse.playlist",{uri:a}))):c.go("search",{query:a})},a.linkingMode=function(a){var b="";return $.isArray(a)||(a=[a]),angular.forEach(a,function(a){""==b&&(c.is(a)?b="active":c.includes(a)&&(b="section"))}),b},a.$on("mopidy:state:online",function(){n.trackEvent("Mopidy","Online"),b.mopidyOnline=!0,h.getConsume().then(function(a){j.setSetting("mopidy",a,"consume")})}),a.$on("mopidy:state:offline",function(){b.mopidyOnline=!1}),b.spotifyAuthorized=!1,a.$on("spotmop:spotify:authenticationChanged",function(c,d){"client"==d?(b.spotifyAuthorized=!0,a.spotifyUser=j.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id),n.trackEvent("Spotify","Authorized",a.spotifyUser.id)):(b.spotifyAuthorized=!1,a.playlistsMenu=[])}),a.$on("spotmop:spotify:online",function(){b.spotifyOnline=!0,b.spotifyAuthorized&&(a.spotifyUser=j.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id))}),a.$on("spotmop:spotify:offline",function(){a.playlistsMenu=[],b.spotifyOnline=!1}),b.$on("spotmop:settings:changed",function(a,b){switch(b.name){case"mopidy.consume":h.setConsume(b.value)}}),b.$on("mopidy:event:optionsChanged",function(a,b){h.getConsume().then(function(a){j.setSetting("mopidy",a,"consume")})}),l.start(),b.$on("spotmop:pusher:online",function(b,c){var d=j.getSetting("pushername",null);"undefined"!=typeof d&&d&&""!=d||(m.create("initialsetup",a), -n.trackEvent("Core","Initial setup"))}),b.$on("spotmop:pusher:received",function(a,b){var c="";b.spotifyuser=JSON.parse(b.spotifyuser),"undefined"!=typeof b.spotifyuser.images&&b.spotifyuser.images.length>0&&(c=b.spotifyuser.images[0].url),k.browserNotify(b.title,b.body,c),n.trackEvent("Pusher","Notification received",b.body)}),h.start(),g.start(),b.shiftKeyHeld=!1,b.ctrlKeyHeld=!1,$("body").bind("keydown",function(a){if(16===a.which?b.shiftKeyHeld=!0:17===a.which&&(b.ctrlKeyHeld=!0),!$(document).find(":focus").is(":input")&&j.getSetting("keyboardShortcutsEnabled",!1)){var c=new Array(46,32,13,37,38,39,40,27);$.inArray(a.which,c)>-1&&a.preventDefault()}}).bind("keyup",function(a){!$(document).find(":focus").is(":input")&&j.getSetting("keyboardShortcutsEnabled",!1)&&(46===a.which&&b.$broadcast("spotmop:keyboardShortcut:delete"),32===a.which&&b.$broadcast("spotmop:keyboardShortcut:space"),13===a.which&&b.$broadcast("spotmop:keyboardShortcut:enter"),37===a.which&&b.$broadcast("spotmop:keyboardShortcut:left"),38===a.which&&b.$broadcast("spotmop:keyboardShortcut:up"),39===a.which&&b.$broadcast("spotmop:keyboardShortcut:right"),40===a.which&&b.$broadcast("spotmop:keyboardShortcut:down"),27===a.which&&(b.$broadcast("spotmop:keyboardShortcut:esc"),dragging&&(dragging=!1,$(document).find(".drag-tracer").hide()))),16===a.which&&(b.shiftKeyHeld=!1),17===a.which&&(b.ctrlKeyHeld=!1)})}]),angular.module("spotmop.browse.album",[]).config(["$stateProvider",function(a){a.state("browse.album",{url:"/album/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("AlbumController",["$scope","$rootScope","$stateParams","$filter","$state","MopidyService","SpotifyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h,i){function j(){g.getAlbum(m).then(function(b){a.album=b,a.album.totalTracks=b.tracks.total,a.album.images=d("sizedImages")(b.images),a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items,angular.forEach(a.tracklist.tracks,function(b){b.album=a.album});var e=[];angular.forEach(b.artists,function(a){e.push(a.uri)}),g.getArtists(e).then(function(b){if(a.album.artists=[],b.artists)for(var c=0;c 0)a.album.images=d("sizedImages")(e);else if("undefined"!=typeof a.album.musicbrainz_id)i.albumInfoByMbid(a.album.musicbrainz_id).then(function(b){"undefined"!=typeof b.album&&(a.album.images=d("sizedImages")(b.album.image))});else{var f=c[Object.keys(c)[0]];i.albumInfo(f.name.trim(),a.album.name.trim()).then(function(b){"undefined"!=typeof b.album&&(a.album.images=d("sizedImages")(b.album.image))})}})})}function l(b){return"undefined"==typeof b?!1:(n=!0,void g.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(b.items),a.tracklist.next=b.next,n=!1}))}a.album={},a.tracklist={tracks:[]};var m=c.uri;m=m=m.replace("|","/"),a.origin=d("assetOrigin")(m),a.convertedDate=function(){if("undefined"!=typeof a.album.release_date){if(a.mediumScreen())return d("date")(a.album.release_date,"yyyy");if("day"==a.album.release_date_precision)return d("date")(a.album.release_date,"MMMM d, yyyy");if("month"==a.album.release_date_precision)return d("date")(a.album.release_date,"MMMM yyyy");if("year"==a.album.release_date_precision)return a.album.release_date}else if("undefined"!=typeof a.album.date)return a.album.date;return null},a.totalTime=function(){var b=0;return"undefined"!=typeof a.tracklist.tracks&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a.duration_ms?b+=a.duration_ms:"undefined"!=typeof a.length&&(b+=a.length)}),Math.round(b/1e5)},a.playAlbum=function(){f.playStream(m)},"spotify"==a.origin?(a.addToLibrary=function(){g.addAlbumsToLibrary(a.album.id).then(function(){a.isInLibrary=!0})},a.removeFromLibrary=function(){g.removeAlbumsFromLibrary(a.album.id).then(function(){a.isInLibrary=!1})},j(),a.$on("spotmop:loadMore",function(){!n&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&l(a.tracklist.next)})):a.mopidyOnline?k():a.$on("mopidy:state:online",function(){k()});var n=!1}]),angular.module("spotmop.browse.artist",[]).config(["$stateProvider",function(a){a.state("browse.artist",{url:"/artist/:uri","abstract":!0,templateUrl:"app/browse/artist/template.html",controller:["$scope","$state",function(a,b){"browse.artist"===b.current.name&&b.go("browse.artist.overview")}]}).state("browse.artist.overview",{url:"",templateUrl:"app/browse/artist/overview.template.html",controller:"ArtistOverviewController"}).state("browse.artist.related",{url:"/related",templateUrl:"app/browse/artist/related.template.html",controller:"RelatedArtistsController"}).state("browse.artist.biography",{url:"/biography",templateUrl:"app/browse/artist/biography.template.html",controller:"ArtistBiographyController"}).state("browse.artistalbum",{url:"/artist/:artisturi/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("ArtistController",["$scope","$rootScope","$timeout","$interval","$stateParams","$sce","$filter","SpotifyService","SettingsService","MopidyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(){j.getArtist(n).then(function(b){return b.length<=0?void k.error("Could not load artist: "+n):(a.artist=b[0].artists[0],a.artist.type="localartist","undefined"!=typeof a.artist.musicbrainz_id?l.artistInfoByMbid(a.artist.musicbrainz_id).then(function(b){a.artist.images=g("sizedImages")(b.artist.image),a.artist.stats=b.artist.stats}):l.artistInfo(a.artist.name).then(function(b){a.artist.images=g("sizedImages")(b.artist.image),a.artist.stats=b.artist.stats}),a.tracklist.type="localtrack",void(a.tracklist.tracks=g("limitTo")(b,10)))}),j.getLibraryItems(n).then(function(b){a.albums.items=g("filter")(b,{type:"directory"}&&{type:"album"});for(var c=0;c -1&&(a.albums.items[c].uri=d(a.albums.items[c].uri));var e=function(b){return function(c){"undefined"!=typeof c.album&&(a.albums.items[b].images=g("sizedImages")(c.album.image))}}(c);a.albums.items[c].mbid?l.albumInfoByMbid(a.albums.items[c].mbid).then(e):l.albumInfo(a.albums.items[c].artist.name.trim(),a.albums.items[c].name.trim()).then(e)}})}a.artist={},a.tracklist={type:"track"},a.albums={items:[]},a.relatedArtists={};var n=e.uri;n=n=n.replace("|","/"),a.origin=g("assetOrigin")(n),"spotify"==a.origin?(a.followArtist=function(){h.followArtist(e.uri).then(function(b){a.following=!0})},a.unfollowArtist=function(){h.unfollowArtist(e.uri).then(function(b){a.following=!1})},a.playArtistRadio=function(){k.notify("Playing all top tracks"),h.getTopTracks(e.uri).then(function(a){for(var b=[],c=0;c =4&&9.3>a?"commute":a>=9.3&&11>a?"morning":a>=11&&13.5>a?"midday":a>=13.5&&17>a?"afternoon":a>=17&&19>a?"evening":a>=19&&21>a?"dinner":a>=21&&23>a||a>=0&&4>a?"late":void 0},d.featuredPlaylists(50).then(function(b){a.message=b.message,a.playlists=b.playlists.items})}]),angular.module("spotmop.browse.genre",[]).config(["$stateProvider",function(a){a.state("browse.genre",{url:"/genre",templateUrl:"app/browse/genre/template.html",controller:"GenreController"}).state("browse.genrecategory",{url:"/genre/:categoryid",templateUrl:"app/browse/genre/category.template.html",controller:"GenreCategoryController"}).state("browse.categoryplaylist",{url:"/genre/:categoryid/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("GenreController",["$scope","$rootScope","SpotifyService","NotifyService",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.categories.items=a.categories.items.concat(b.categories.items),a.categories.next=b.categories.next,f=!1}))}a.categories=[],c.browseCategories().then(function(b){a.categories=b.categories});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.categories.next&&a.categories.next&&e(a.categories.next)})}]).controller("GenreCategoryController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists.items=a.playlists.items.concat(b.playlists.items),a.playlists.next=b.playlists.next,f=!1}))}a.category={},a.playlists=[],c.getCategory(d.categoryid).then(function(b){a.category=b,c.getCategoryPlaylists(d.categoryid).then(function(b){a.playlists=b.playlists})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.playlists.next&&a.playlists.next&&e(a.playlists.next)})}]),angular.module("spotmop.browse.new",[]).config(["$stateProvider",function(a){a.state("browse.new",{url:"/new",templateUrl:"app/browse/new/template.html",controller:"NewController"}).state("browse.newalbum",{url:"/new/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("NewController",["$scope","$element","$rootScope","SpotifyService","MopidyService",function(a,b,c,d,e){function f(b){console.log("loading"),h=!0,d.newReleases(!1,b).then(function(b){a.albums.items=a.albums.items.concat(b.albums.items),g=b.albums.offset+b.albums.limit,h=!1})}a.albums=[],d.newReleases().then(function(b){a.albums=b.albums,a.checkForLazyLoading()});var g=50,h=!1;a.$on("spotmop:loadMore",function(){!h&&g&&f(g)})}]),angular.module("spotmop.browse.playlist",[]).config(["$stateProvider",function(a){a.state("browse.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("PlaylistController",["$scope","$rootScope","$filter","$state","$stateParams","$sce","SpotifyService","MopidyService","SettingsService","DialogService","NotifyService",function(a,b,c,d,e,f,g,h,i,j,k){function l(){var b=d.params.uri,e=g.getFromUri("userid",b),f=i.getSetting("spotifyuser",{id:null}).id;if(e!=f)return k.error("Cannot modify to a playlist you don't own"),!1;var h=c("filter")(a.tracklist.tracks,{selected:!0}),j=[];angular.forEach(h,function(b,c){j.push(a.tracklist.tracks.indexOf(b)),b.transitioning=!0}),g.deleteTracksFromPlaylist(a.playlist.uri,a.playlist.snapshot_id,j).then(function(b){"undefined"!=typeof b.error?(k.error(b.error.message),angular.forEach(h,function(a,b){a.transitioning=!1})):(a.tracklist.tracks=c("nullOrUndefined")(a.tracklist.tracks,"selected"),a.playlist.snapshot_id=b.snapshot_id)})}function m(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,c.added_by=a.added_by,c.is_local=a.is_local,b.push(c)}),b}function n(b){return"undefined"==typeof b?!1:(o=!0,void g.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(m(b.items)),a.tracklist.next=b.next,o=!1}))}a.playlist={images:[]},a.tracklist={tracks:[],type:"track"},a.totalTime=0,a.following=!1,a.followPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Following playlist"),a.updatePlaylists()})},a.unfollowPlaylist=function(){g.unfollowPlaylist(e.uri).then(function(b){a.following=!1,k.notify("Playlist removed"),a.updatePlaylists()})},a.recoverPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Playlist recovered"),a.updatePlaylists()})},a.editPlaylist=function(){j.create("editPlaylist",a)},a.playPlaylist=function(){h.playStream(a.playlist.uri,a.tracklist.tracks.length)},a.totalTime=function(){var b=0;return a.tracklist.tracks.length>0&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a&&(b+=a.duration_ms)}),Math.round(b/1e5)},g.getPlaylist(e.uri).then(function(c){a.playlist=c,a.tracklist.next=c.tracks.next,a.tracklist.previous=c.tracks.previous,a.tracklist.offset=c.tracks.offset,a.tracklist.total=c.tracks.total,a.tracklist.tracks=m(c.tracks.items),a.playlist.description=f.trustAsHtml(a.playlist.description),b.spotifyAuthorized&&g.getUser(a.playlist.owner.uri).then(function(b){a.playlist.owner=b}),b.spotifyAuthorized&&g.isFollowingPlaylist(e.uri,i.getSetting("spotifyuser",{id:null}).id).then(function(b){a.following=$.parseJSON(b)}),"undefined"!=typeof e.categoryid&&g.getCategory(e.categoryid).then(function(b){a.category=b})}),a.$on("spotmop:playlist:reorder",function(b,c,e,f){var h=d.params.uri,j=g.getFromUri("userid",h),l=i.getSetting("spotifyuser",{id:null}).id;if(j!=l)k.error("Cannot edit a playlist you don't own");else{g.movePlaylistTracks(h,c,e,f);for(var m=[],n=0;e>n;n++)m.push(a.tracklist.tracks[c+n]);f>c&&(f-=e),m.reverse(),a.$apply(function(){a.tracklist.tracks.splice(c,e),angular.forEach(m,function(b){a.tracklist.tracks.splice(f,0,b)})})}}),a.$on("spotmop:playlist:deleteSelectedTracks",function(a){l()}),a.$on("spotmop:keyboardShortcut:delete",function(a){l()});var o=!1;a.$on("spotmop:loadMore",function(){!o&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&n(a.tracklist.next)})}]),angular.module("spotmop.browse.user",[]).config(["$stateProvider",function(a){a.state("browse.user",{url:"/user/:uri",templateUrl:"app/browse/user/template.html",controller:"UserController"})}]).controller("UserController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists=a.playlists.concat(b.items),a.next=b.next,f=!1}))}a.user={},a.playlists=[],c.getUser(d.uri).then(function(b){a.user=b,c.getPlaylists(b.id).then(function(b){a.playlists=b.items,a.next=b.next,a.totalPlaylists=b.total})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.next&&a.next&&e(a.next)})}]),angular.module("spotmop.common.contextmenu",[]).directive("contextmenu",function(){return{restrict:"E",replace:!0,templateUrl:"app/common/contextmenu/template.html",link:function(a,b,c){},controller:["$scope","$rootScope","$element","$timeout","NotifyService",function(a,b,c,d,e){$(document).on("click",function(a){if(!b.isTouchMode()&&1===a.which){var c=$(a.target);c.is("contextmenu")||(c=c.closest("contextmenu")),c.is("contextmenu")||b.$broadcast("spotmop:contextMenu:hide")}}),a.triggerEvent="",a.play=function(){b.$broadcast("spotmop:tracklist:playSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.enqueue=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.unqueue=function(){b.$broadcast("spotmop:tracklist:unqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.playNext=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks",!0),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.addToPlaylist=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylist"),c.fadeOut("fast")},a.addToPlaylistByUri=function(a){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylistByUri",a),c.fadeOut("fast")},a.removeFromPlaylist=function(){b.$broadcast("spotmop:playlist:deleteSelectedTracks"),c.fadeOut("fast")},a.addToLibrary=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToLibrary"),c.fadeOut("fast")},a.copyURIs=function(){b.$broadcast("spotmop:tracklist:copyURIsToClipboard"),c.fadeOut("fast")},a.copiedToClipboard=function(a){e.notify("Copied selected track URIs to clipboard"),c.fadeOut("fast")},a.selectAll=function(){b.$broadcast("spotmop:tracklist:selectAll")},a.unselectAll=function(){b.$broadcast("spotmop:tracklist:unselectAll"),c.fadeOut("fast")},a.$on("spotmop:contextMenu:show",function(e,f,g){return b.isTouchMode()?!1:void a.$apply(function(){a.context=g,a.triggerEvent="click",d(function(){var a=f.pageY-$(window).scrollTop(),b=f.pageX,d=c.outerWidth(),e=c.outerHeight();b+d>$(window).width()?(b-=d-10,c.addClass("hard-right")):b+d+150>$(window).width()?c.addClass("close-right"):c.removeClass("hard-right close-right"),a+e>$(window).height()?(a-=e,c.addClass("hard-bottom")):a+e+306>$(window).height()?c.addClass("close-bottom"):c.removeClass("hard-bottom close-bottom"),c.css({top:a,left:b+5}).show()})})}),a.$on("spotmop:touchContextMenu:show",function(b,d){c.show(),a.triggerEvent="touch",c.removeClass("hard-bottom close-bottom hard-right close-right"),c.css({top:"auto",left:0}),a.$apply(function(){a.context=d})}),a.$on("spotmop:contextMenu:hide",function(a){c.fadeOut("fast")})}]}}),angular.module("spotmop.directives",[]).config(["cfpLoadingBarProvider",function(a){a.latencyThreshold=250}]).directive("singleclick",function(){return function(a,b,c){b.bind("touchstart click",function(b){b.preventDefault(),b.stopPropagation(),a.$apply(c.singleclick)})}}).directive("candrag",["$rootScope","$filter","MopidyService","SpotifyService","NotifyService","PlayerService",function(a,b,c,d,e,f){return{restrict:"A",scope:{dragobj:"="},link:function(e,g,h){function i(c){a.dragging=!0;var d=!1;if(v.dragActive||(d=!0),v.dragActive=!0,$(document).find(".dropping").removeClass("dropping"),$(document).find(".dropping-within").removeClass("dropping-within"),d){$("body").addClass("dragging");var f="";if("album"==e.dragobj.type||"localalbum"==e.dragobj.type||"artist"==e.dragobj.type||"localartist"==e.dragobj.type||"playlist"==e.dragobj.type){var g=!1;if("undefined"!=typeof e.dragobj.images.small)var g=e.dragobj.images;else if(e.dragobj.images.length>0)var g=b("sizedImages")(e.dragobj.images);g&&(f=''),f+=' '+e.dragobj.name+""}else if("track"==e.dragobj.type||"tltrack"==e.dragobj.type||"localtrack"==e.dragobj.type)for(var h=$(document).find(".track.selected"),i=0;ii;i++)f+=' '+h.eq(i).find(".title").html()+"";u.html(f),u.show(),$.each($(document).find("#dropzones > .dropzone"),function(a,b){t($(b))?$(b).removeClass("disabled"):$(b).addClass("disabled")})}u.css({left:c.clientX,top:c.clientY});var j=s(c),k=t(j);if(k){j.addClass("dropping");var l=$(c.target);l.hasClass("track")||(l=l.closest(".track")),l.hasClass("track")&&l.addClass("dropping"),j.parent().closest(".droppable").addClass("dropping-within")}}function j(b){a.$broadcast("spotmop:contextMenu:hide"),u.fadeOut("medium"),$("body").removeClass("dragging"),$(document).find(".dropping").removeClass("dropping");var c=s(b),d=t(c);if(d)switch(c.attr("droptype")){case"queue":k();break;case"queuenext":var g=f.state().currentTracklistPosition();k(g);break;case"playlist":l(b);break;case"library":"track"==e.dragobj.type?n():"tltrack"==e.dragobj.type?n():"album"==e.dragobj.type?m():"artist"==e.dragobj.type?o():"playlist"==e.dragobj.type&&p();break;case"queuetracklist":q(b);break;case"playlisttracklist":r(b)}a.dragging=!1}function k(a){if("undefined"==typeof a)var a=null;switch(e.dragobj.type){case"album":c.addToTrackList([e.dragobj.uri],a);break;case"localalbum":c.addToTrackList([e.dragobj.uri],a);break;case"track":for(var b=[],d=$(document).find(".track.selected"),f=0;fg&&(e-=d.length),c.moveTlTracks(f,g,e)}function r(b){var c=$(b.target);c.hasClass("track")||(c=c.closest(".track"));var d=$(v.domobj).closest(".tracklist").find(".track.selected"),e=(c.closest(".tracklist").attr("playlisturi"),Number(c.parent().attr("data-index"))),f=Number(d.first().parent().attr("data-index")),g=Number(d.length);a.$broadcast("spotmop:playlist:reorder",f,g,e)}function s(a){var b=$(a.target);return b.hasClass("droppable")||(b=b.closest(".droppable")),b?b:!1}function t(a){var b=a.attr("dropaccept");return b?(b=JSON.parse(b),b.indexOf(e.dragobj.type)>=0?!0:!1):!1}var u=$(document).find(".drag-tracer"),v={threshold:30,dragStarted:!1,dragActive:!1,startX:!1,starY:!1};g.on("mousedown",function(a){v.dragStarted=!0,v.startX=a.clientX,v.startY=a.clientY,v.domobj=a.currentTarget,"undefined"!=typeof e.dragobj.__model__&&"undefined"==typeof e.dragobj.type&&(e.dragobj.type=e.dragobj.__model__.toLowerCase())}),$(document).on("mouseup",function(a){v.dragActive&&j(a),v.dragStarted=!1,v.dragActive=!1,v.startX=!1,v.startY=!1,v.domobj=!1}),$(document).on("mousemove",function(a){if(v.dragStarted){var b=v.startX-v.threshold,c=v.startX+v.threshold,d=v.startY-v.threshold,e=v.startY+v.threshold;(a.clientXc||a.clientY e)&&i(a)}})}}}]).directive("switch",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{name:"@",label:"@",value:"="},replace:!0,transclude:!0,controller:["$scope","$element","$attrs",function(b,c,d){c.bind("touchstart click",function(c){c.preventDefault(),c.stopPropagation(),b.$apply(function(){b.value=!b.value,a.$broadcast("spotmop:settings:changed",{name:b.name,value:b.value})})})}],template:' '}}]).directive("artistlist",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{artists:"="},link:function(a,b,c){a.nolinks=c.hasOwnProperty("nolinks"),a.sentence=c.hasOwnProperty("sentence")},replace:!0,transclude:!0,templateUrl:"app/common/artistlist.template.html"}}]).directive("thumbnail",["$timeout","$http",function(a,b){return{restrict:"E",scope:{images:"=",size:"="},replace:!0,transclude:!0,link:function(a,c,d){function e(){a.image=f(a.images),a.image&&b({method:"GET",url:a.image.url,cache:!0}).success(function(){c.css("background-image","url("+a.image.url+")")})}function f(b){if(b.length<=0)return!1;for(var c=0;c=100&&d.height<=200)return d;if(d.height>200&&d.height<=300)return d;if(d.height>300&&d.height<400)return d}else{if(d.height>=200&&d.height<=300)return d;if(d.height>300&&d.height<=500)return d;if(d.height>=150&&d.height<200)return d}}return b[0]}e(),a.$watch("images",function(a,b){e()})},template:''}}]).directive("confirmationButton",function(){return{restrict:"E",controller:["$scope","$element",function(a,b){a.text="Button text",a.confirming=!1,a.text=a.defaultText,$(document).on("click",function(c){c.target==b[0]&&1==c.which?a.confirming?"function"==typeof a.$parent[a.onConfirmation]()&&a.$parent[a.onConfirmation]():(a.confirming=!0,a.text=a.confirmationText,a.$apply()):(a.confirming=!1,a.text=a.defaultText,a.$apply())})}],scope:{text:"@",extraClasses:"@",confirmationText:"@",defaultText:"@",onConfirmation:"@"},replace:!0,transclude:!0,template:''}}).directive("slider",["$timeout",function(a){return{restrict:"E",scope:{items:"="},link:function(b,c){function d(a){return"prev"==a&&0>=g?!1:"next"==a&&g>=h?!1:!0}function e(){var a=c.find(".item-container").children().first().height();c.css({height:a+"px"})}var f=c.find(".slides-content"),g=0,h=b.items.length/5-1;b.prev=function(){d("prev")&&(g--,f.animate({left:100*-g+"%"},120))},b.next=function(){d("next")&&(g++,f.animate({left:100*-g+"%"},120))},a(function(){e()},0),$(window).resize(function(){e()})},templateUrl:"app/common/slider.template.html"}}]).directive("textOverImage",function(){return{restrict:"A",link:function(a,b){a.$on("spotmop:detectBackgroundColor",function(a){BackgroundCheck.init({targets:$.merge($(b).parent(),$(document).find("#utilities")),images:b.closest(".intro").find(".image")}),BackgroundCheck.refresh()})}}}).directive("preloadedimage",["$rootScope","$timeout",function(a,b){return{restrict:"E",scope:{url:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,c){function d(){var c="";c+=a.url;var d=$('');d.load(function(){b.attr("style",'background-image: url("'+c+'");');var d=1;"undefined"!=typeof a.opacity&&(d=a.opacity),b.animate({opacity:d},200)})}b.attr("watch")&&a.$watch("url",function(a,b){a&&d()},!0),d()},template:""}}]).directive("backgroundparallax",["$rootScope","$timeout","$interval","$http",function(a,b,c,d){return{restrict:"E",terminal:!0,scope:{image:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,d){function e(a){var c=b.outerWidth(),d=b.outerHeight();if((h.canvas.width!=c||h.canvas.height!=d)&&(h.canvas.width=c,h.canvas.height=d),a.width c){var e=c/a.width;a.width=a.width*e,a.height=a.height*e}if(a.height f&&e(i)}})},10)},template:''}}]).filter("splitstring",[function(){return function(a,b){var c=a.split(":");return c[b]}}]).filter("nullOrUndefined",[function(){return function(a,b){for(var c=[],d=0;d =b&&(b="0"+b);var c=Math.floor(a/6e4%60);return c+":"+b}}).filter("stripAccents",function(){return function(a){for(var b=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],c=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],d=0;d =200&&c.height<=300)return c.url;if(c.height>300&&c.height<=500)return c.url;if(c.height>=150&&c.height<200)return c.url}return a[0].url}}).filter("sizedImages",["SettingsService",function(a){return function(b){if(b.length<=0)return!1;for(var c={},d=0;d =650?c.large=e.url:e.height<=650&&e.height>=250?(c.medium=e.url,c.large||(c.large=e.url)):(c.small||(c.small=e.url),c.medium||(c.medium=e.url),c.large||(c.large=e.url))}else if("undefined"!=typeof e.height)e.height>=650?c.large=e.url:e.height<=650&&e.height>=250?(c.medium=e.url,c.large||(c.large=e.url)):(c.small||(c.small=e.url),c.medium||(c.medium=e.url),c.large||(c.large=e.url));else if("undefined"!=typeof e["#text"]){if(e["#text"]&&e["#text"].length>0&&""!=e.size)switch(e.size){case"mega":c.large=e["#text"];break;case"extralarge":c.medium=e["#text"],c.large||(c.large=e["#text"]);break;case"large":c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"]);break;case"medium": -c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"]);break;case"small":c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"])}}else c.large=e,c.medium=e,c.small=e}return c}}]).filter("shuffle",function(){return function(a){var b,c,d;for(b=a.length-1;b>0;b--)c=Math.floor(Math.random()*(b+1)),d=a[b],a[b]=a[c],a[c]=d;return a}}).filter("assetOrigin",function(){return function(a){if("undefined"==typeof a)return!1;var b=a.split(":");return b.length<=0?!1:b[0]}}).filter("assetType",function(){return function(a){if("undefined"==typeof a)return!1;var b=a.split(":");return b.length<=1?!1:b[1]}}).filter("mbid",function(){return function(a){if("undefined"==typeof a)return!1;var b=a.indexOf(":mbid:")+6,c=a.length;return a.substr(b,c)}}),angular.module("spotmop.common.tracklist.service",[]).factory("TracklistService",["$rootScope",function(a){return{getSelectedTracks:function(){console.log("triggered getSelectedTracks")}}}]),angular.module("spotmop.common.track",[]).directive("track",function(){return{restrict:"E",templateUrl:"app/common/tracklist/track.template.html",controller:["$element","$scope","$rootScope","MopidyService","NotifyService",function(a,b,c,d,e){a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"track"))}),a.dblclick(function(a){d.playTrack([b.track.uri],0)})}]}}).directive("tltrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/tltrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService",function(a,b,c,d,e){b.state=e.state,b.isCurrentlyPlaying=function(){return b.track.tlid==b.state().currentTlTrack.tlid},b.sourceIconClasses=function(){if("undefined"==typeof b.track.track)return!1;var a=b.track.track.uri.split(":")[0],c="light";return b.isCurrentlyPlaying()&&("spotify"==a&&(c="green"),"local"==a&&(c="yellow"),"soundcloud"==a&&(c="red")),a+" "+c},a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"tltrack"))}),a.dblclick(function(a){d.getCurrentTlTracks().then(function(a){$.each(a,function(a,c){return c.tlid==b.track.tlid?d.playTlTrack({tl_track:c}):void 0})})})}]}}).directive("localtrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/localtrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService","NotifyService",function(a,b,c,d,e,f){b.state=e.state,a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"localtrack"))}),a.dblclick(function(a){d.playTrack([b.track.uri],0)})}]}}),angular.module("spotmop.common.tracklist",[]).directive("tracklist",["$compile",function(a){return{restrict:"E",templateUrl:"app/common/tracklist/template.html",scope:{tracks:"=",type:"@",limit:"@"},link:function(a,b,c){},controller:["$element","$scope","$filter","$rootScope","$stateParams","MopidyService","SpotifyService","DialogService","NotifyService","SettingsService","PlayerService",function(a,b,c,d,e,f,g,h,i,j,k){function l(){var a=c("filter")(b.tracks,{selected:!0}),e=[];angular.forEach(a,function(a){"undefined"!=typeof a.track?e.push(a.track.uri):e.push(a.uri)}),d.selectedTrackURIs=e}function m(){if(d.tracklistInFocus===b.$id){var a=c("filter")(b.tracks,{selected:!0}),e=a[0];if("tltrack"==b.type)f.getCurrentTlTracks().then(function(a){$.each(a,function(a,b){return b.tlid==e.tlid?f.playTlTrack({tl_track:b}):void 0})});else{for(var g=[],h=1;h 10&&(j+="... this could take some time"),i.notify(j),f.playTrack([e.uri],0).then(function(){g.length>0&&f.addToTrackList(g,1)})}}}function n(){angular.forEach(b.tracks,function(a){a.selected=!1})}d.selectedTrackURIs=[],$(document).contextmenu(function(a){return $(a.target).closest(".tracklist").length>0?!1:void 0}),b.tracksWrapper=function(){return b.limit&&b.limit>0?c("limitTo")(b.tracks,parseInt(b.limit)):b.tracks},b.$on("spotmop:track:dragging",function(a){});var o=d.$on("spotmop:tracklist:focusChanged",function(a,c){d.tracklistInFocus=c,b.$id!=c&&n()});b.$on("$destroy",o),b.trackClicked=function(a){if(d.$broadcast("spotmop:tracklist:focusChanged",b.$id),!d.dragging){if(d.ctrlKeyHeld||d.isTouchMode()?a.track.selected?a.$apply(function(){a.track.selected=!1}):a.$apply(function(){a.track.selected=!0}):d.ctrlKeyHeld||(angular.forEach(b.tracks,function(a){a.selected=!1}),a.$apply(function(){a.track.selected=!0})),d.shiftKeyHeld){if("undefined"==typeof b.lastSelectedTrack)return void a.$apply(function(){a.track.selected=!0});var e=b.lastSelectedTrack.$index,f=a.$index;a.$index =g;g++)b.tracks[g].selected=!0;b.$apply()}b.lastSelectedTrack=a,d.isTouchMode()&&(c("filter")(b.tracks,{selected:!0}).length>0?d.$broadcast("spotmop:touchContextMenu:show",b.type):d.$broadcast("spotmop:contextMenu:hide")),l()}},b.$on("spotmop:tracklist:enqueueSelectedTracks",function(a,e){if(d.tracklistInFocus===b.$id){var g=null;"undefined"!=typeof e&&1==e&&(g=k.state().currentTracklistPosition());var h=c("filter")(b.tracks,{selected:!0}),j=[];angular.forEach(h,function(a){j.push(a.uri)});var l="Adding "+h.length+" tracks to queue";h.length>10&&(l+="... this could take some time"),i.notify(l),f.addToTrackList(j,g)}}),b.$on("spotmop:tracklist:playSelectedTracks",function(){m()}),b.$on("spotmop:keyboardShortcut:enter",function(){m()}),b.$on("spotmop:tracklist:unqueueSelectedTracks",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),g=[];angular.forEach(e,function(a){g.push(a.tlid)}),f.removeFromTrackList(g)}}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylist",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),f=[];angular.forEach(e,function(a){"undefined"!=typeof a.track?f.push(a.track.uri):f.push(a.uri)}),h.create("addToPlaylist",b)}}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylistByUri",function(a,e){if(d.tracklistInFocus===b.$id){var f=c("filter")(b.tracks,{selected:!0}),h=[],j=0;if(angular.forEach(f,function(a){"undefined"!=typeof a.track?"local:"==a.track.uri.substring(0,6)?j++:h.push(a.track.uri):"local:"==a.uri.substring(0,6)?j++:h.push(a.uri)}),j>0){if(h.length<=0)return i.error("Cannot add local tracks to a Spotify playlist"),!1;i.error(j+" local tracks not added to Spotify playlist")}g.addTracksToPlaylist(e,h).then(function(a){i.notify("Added "+h.length+" tracks to playlist")})}}),b.$on("spotmop:tracklist:addSelectedTracksToLibrary",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),f=[];angular.forEach(e,function(a){"undefined"!=typeof a.track?f.push(g.getFromUri("trackid",a.track.uri)):f.push(g.getFromUri("trackid",a.uri))}),g.addTracksToLibrary(f)}}),b.$on("spotmop:tracklist:selectAll",function(a){n()}),b.$on("spotmop:tracklist:unselectAll",function(a){n()}),b.$on("spotmop:tracklist:copyURIsToClipboard",function(a){var d=c("filter")(b.tracks,{selected:!0}),e="";angular.forEach(d,function(a){""!=e&&(e+=","),e+="undefined"!=typeof a.track?a.track.uri:a.uri}),console.log(e)})}]}}]),angular.module("spotmop.discover",[]).config(["$stateProvider",function(a){a.state("discover",{url:"/discover",templateUrl:"app/discover/template.html",controller:"DiscoverController"})}]).controller("DiscoverController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","NotifyService",function(a,b,c,d,e,f){function g(b){var c=[],e="";angular.forEach(b.track.artists,function(a){c.push({name:a.name,name_encoded:encodeURIComponent(a.name),uri:a.uri}),""!=e&&(e+=","),e+=d.getFromUri("artistid",a.uri)}),a.current.artists=c,d.getRecommendations(!1,!1,e).then(function(b){var c=[];angular.forEach(b.tracks,function(a){var b=a.album;b.artists=a.artists,c.push(b)}),a.current.items=c})}a.favorites=[],a.current=[],a.sections=[],d.getMyFavorites("artists",50,!1,"long_term").then(function(b){a.favorites.items=c("shuffle")(b.items)}),d.getMyFavorites("tracks",50,!1,"short_term").then(function(b){var e=b.items;e=c("shuffle")(b.items),e=c("limitTo")(b.items,5),angular.forEach(e,function(b){d.getRecommendations(!1,!1,!1,!1,b.id).then(function(c){var d=[];angular.forEach(c.tracks,function(a){var b=a.album;b.artists=a.artists,d.push(b)});var e={title:"Because you listened to ",artists:b.artists,items:d};a.sections.push(e)})})}),"undefined"!=typeof a.state().currentTlTrack.track&&g(a.state().currentTlTrack),b.$on("spotmop:currenttrack:loaded",function(a,b){g(b)})}]),angular.module("spotmop.library",[]).config(["$stateProvider",function(a){a.state("library",{url:"/library",templateUrl:"app/library/template.html"}).state("library.playlists",{url:"/playlists",templateUrl:"app/library/playlists.template.html",controller:"LibraryPlaylistsController"}).state("library.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"}).state("library.tracks",{url:"/tracks",templateUrl:"app/library/tracks.template.html",controller:"LibraryTracksController"}).state("library.artists",{url:"/artists",templateUrl:"app/library/artists.template.html",controller:"LibraryArtistsController"}).state("library.albums",{url:"/albums",templateUrl:"app/library/albums.template.html",controller:"LibraryAlbumsController"})}]).controller("LibraryTracksController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,b.push(c)}),b}function h(b){return"undefined"==typeof b?!1:(j=!0,void d.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(g(b.items)),a.tracklist.next=b.next,j=!1}))}a.tracklist={tracks:[],type:"track"};var i=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyTracks(i).then(function(b){a.tracklist=b,a.tracklist.tracks=g(b.items),"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()}),a.$on("spotmop:keyboardShortcut:delete",function(b){var e=c("filter")(a.tracklist.tracks,{selected:!0}),f=[];angular.forEach(e,function(a,b){f.push(d.getFromUri("trackid",a.uri))}),d.deleteTracksFromLibrary(f).then(function(b){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})})});var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&h(a.tracklist.next)})}]).controller("LibraryArtistsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(b){return"undefined"==typeof b?!1:(i=!0,void d.getUrl(b).then(function(b){a.artists.items=a.artists.items.concat(b.artists.items),a.artists.next=b.artists.next,i=!1}))}a.artists=[];var h=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyArtists(h).then(function(b){a.artists=b.artists,"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()});var i=!1;a.$on("spotmop:loadMore",function(){!i&&"undefined"!=typeof a.artists.next&&a.artists.next&&g(a.artists.next)})}]).controller("LibraryAlbumsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService","MopidyService","NotifyService",function(a,b,c,d,e,f,g,h){function i(b){return"undefined"==typeof b?!1:(k=!0,void d.getUrl(b).then(function(b){a.albums.items=a.albums.items.concat(b.items),a.albums.next=b.next,k=!1}))}a.settings=e.getSettings(),a.albums={items:[]};var j=e.getSetting("spotifyuser",{id:null}).id;b.spotifyAuthorized&&d.getMyAlbums(j).then(function(b){a.albums=b}),a.playAlbum=function(a){g.playStream(a.uri)},a.removeFromLibrary=function(b){b.transitioning=!0,d.removeAlbumsFromLibrary(b.id).then(function(c){"undefined"==typeof c.error?a.albums.items.splice(a.albums.items.indexOf(b),1):(h.error(c.error.message),b.transitioning=!1)})};var k=!1;a.$on("spotmop:loadMore",function(){!k&&"undefined"!=typeof a.albums.next&&a.albums.next&&i(a.albums.next)})}]).controller("LibraryPlaylistsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService","MopidyService","NotifyService",function(a,b,c,d,e,f,g,h){function i(){g.getPlaylists().then(function(b){angular.forEach(b,function(b,c){d.getPlaylist(b.uri).then(function(b){a.playlists.items.push(b)})})})}function j(b){return"undefined"==typeof b?!1:(l=!0,void d.getUrl(b).then(function(b){a.playlists.items=a.playlists.items.concat(b.items),a.playlists.next=b.next,l=!1}))}a.createPlaylist=function(){f.create("createPlaylist",a)},a.settings=e.getSettings(),a.playlists={items:[]},a.show=function(b){return"undefined"!=typeof a.settings.playlists&&"undefined"!=typeof a.settings.playlists.onlyshowowned&&a.settings.playlists.onlyshowowned?"jaedb"==b.owner.id?!0:!1:!0};var k=e.getSetting("spotifyuser",{id:null}).id;b.spotifyAuthorized?d.getPlaylists(k).then(function(b){a.playlists=b,"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()}):(h.notify("Fetching from Mopidy as you haven't authorized Spotify. This will take a while!"),b.mopidyOnline?i():a.$on("mopidy:state:online",function(){i()}));var l=!1;a.$on("spotmop:loadMore",function(){!l&&"undefined"!=typeof a.playlists.next&&a.playlists.next&&j(a.playlists.next)})}]),angular.module("spotmop.local",[]).config(["$stateProvider",function(a){a.state("local",{url:"/local",templateUrl:"app/local/template.html"}).state("local.index",{url:"/index",templateUrl:"app/local/index.html",controller:"LocalController"}).state("local.directory",{url:"/directory/:uri",templateUrl:"app/local/directory.html",controller:"LocalDirectoryController"}).state("local.albums",{url:"/albums",templateUrl:"app/local/albums.html",controller:"LocalAlbumsController"}).state("local.artists",{url:"/artists",templateUrl:"app/local/artists.html",controller:"LocalArtistsController"})}]).controller("LocalController",["$scope","$rootScope","$filter","$stateParams","$localStorage","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h,i){function j(){i.getLibraryItems("local:directory").then(function(b){for(var d=c("filter")(b,{type:"track"}),e=[],f=0;f 0&&i.getTracks(e).then(function(b){var c=[];for(var d in b){var e=b[d][0];e.type="localtrack",c.push(e)}a.tracks=c,a.allTracks=c});var g=[];for(f=0;f 0){var e=c("filter")(a.allAlbums,{uri:d}),f=a.allAlbums.indexOf(e[0]);a.allAlbums[f].images=c("sizedImages")(b[d])}})}a.settings=h.getSettings(),a.allAlbums=[];var n=50;a.$watch("filterTerm",function(b){n=50,a.albums=c("filter")(a.allAlbums,b),a.albums=c("limitTo")(a.albums,n),a.albums.length>0&&m(a.albums)}),a.mopidyOnline?l():a.$on("mopidy:state:online",function(){l()});var o=!1;a.$on("spotmop:loadMore",function(){o||(o=!0,n+=50,a.filterTerm?(a.albums=c("filter")(a.allAlbums,a.filterTerm),a.albums=c("limitTo")(a.albums,n)):a.albums=c("limitTo")(a.allAlbums,n),f(function(){o=!1,a.albums.length>0&&m(a.albums)},1))})}]).controller("LocalDirectoryController",["$scope","$rootScope","$filter","$stateParams","$localStorage","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h,i){function j(){i.getLibraryItems(l).then(function(b){for(var d=c("filter")(b,{type:"track"}),e=[],f=0;f 0&&i.getTracks(e).then(function(b){var c=[];for(var d in b){var e=b[d][0];e.type="localtrack",c.push(e)}a.tracks=c,a.allTracks=c});var g=[];for(f=0;f -1||l.indexOf("local:directory:")>-1)){var m=l.substring(16,l.length);if(""!=m&&(m=m.split("|")),m.length>0)for(var n=0;n =o;o++)"local:directory:"!=l&&(l+="|"),l+=m[o];a.path.push({title:decodeURIComponent(m[n]),uri:l})}l=l.replace("|","/")}a.mopidyOnline?j():a.$on("mopidy:state:online",function(){j()})}]),angular.module("spotmop.player",["spotmop.services.player","spotmop.services.spotify","spotmop.services.mopidy"]).controller("PlayerController",["$scope","$rootScope","$timeout","$interval","$element","PlayerService","MopidyService","SpotifyService","SettingsService",function(a,b,c,d,e,f,g,h,i){a.state=f.state,a.playPause=function(){f.playPause()},a.stop=function(){f.stop()},a.next=function(){f.next()},a.previous=function(){f.previous()},a.seek=function(b){var c,d,e,g,h;c=$(b.target).hasClass("slider")?$(b.target):$(b.target).closest(".slider"),d=c.offset(),e=b.pageX-d.left,g=e/c.innerWidth(),h=Math.round(g*a.state().currentTlTrack.track.length),f.seek(h)},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)},a.toggleRepeat=function(){f.toggleRepeat()},a.toggleRandom=function(){f.toggleRandom()},a.toggleMute=function(){f.toggleMute()},a.$on("mopidy:event:tracklistChanged",function(b){g.getCurrentTlTracks().then(function(b){a.$parent.currentTracklist=b})})}]),angular.module("spotmop.services.player",[]).factory("PlayerService",["$rootScope","$interval","$filter","SettingsService","MopidyService","SpotifyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h){function i(){e.getRepeat().then(function(a){p.isRepeat=a}),e.getRandom().then(function(a){p.isRandom=a}),e.getMute().then(function(a){p.isMute=a})}function j(a){"undefined"==typeof a?e.getTimePosition().then(function(a){p.playPosition=a}):p.playPosition=a}function k(a){"undefined"!=typeof a?p.volume=a:e.getVolume().then(function(a){p.volume=a})}function l(a){"undefined"!=typeof a?("playing"==a?p.playing=!0:p.playing=!1,o()):e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1,o()})}function m(b){var d=function(b){if(p.currentTlTrack=b,"undefined"!=typeof b.track.album.images&&b.track.album.images.length>0){var d=[{__model__:"Image",uri:b.track.album.images}];p.currentTlTrack.track.images=c("sizedImages")(d),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)}else if("spotify:"==b.track.uri.substring(0,8))f.getTrack(b.track.uri).then(function(b){"undefined"!=typeof b.album&&(p.currentTlTrack.track.images=c("sizedImages")(b.album.images)),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)});else{var e=encodeURIComponent(b.track.artists[0].name),g=encodeURIComponent(b.track.album.name);e&&g&&h.albumInfo(e,g).then(function(b){p.currentTlTrack.track.image=!1,"undefined"!=typeof b.album&&(p.currentTlTrack.track.images=c("sizedImages")(b.album.image)),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)})}j(),o()};"undefined"!=typeof b?d(b):e.getCurrentTlTrack().then(function(a){null!==a&&void 0!==a&&(a.track.name.indexOf("[loading]")>-1?e.lookup(a.track.uri).then(function(a){d(a[0])}):d(a))})}function n(){e.getCurrentTlTracks().then(function(b){a.currentTracklist=b,(!b||b.length<=0)&&(p.currentTlTrack=!1,o())})}function o(){var a=p.currentTlTrack.track,b="No track playing";if(a){var c="\u25a0 ",d="";$.each(a.artists,function(a,b){""!=d&&(d+=", "),d+=b.name}),p.playing&&(c="\u25b6 "),b=c+" "+a.name+" - "+d}document.title=b}var p={playing:!1,isRepeat:!1,isRandom:!1,isMute:!1,volume:100,playPosition:0,currentTlTrack:!1,currentTracklistPosition:function(){if(p.currentTlTrack){var b=c("filter")(a.currentTracklist,{tlid:p.currentTlTrack.tlid}),d=0;return b.length>0&&(d=a.currentTracklist.indexOf(b[0])+1),d}return null},playPositionPercent:function(){return p.currentTlTrack?(p.playPosition/p.currentTlTrack.track.length*100).toFixed(2):0}};a.$on("mopidy:state:online",function(){i(),m(),l(),k(),n(),e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1})}),a.$on("mopidy:event:tracklistChanged",function(a,b){n()}),a.$on("mopidy:event:optionsChanged",function(a,b){i()}),a.$on("mopidy:event:playbackStateChanged",function(a,b){l(b.new_state)}),a.$on("mopidy:event:seeked",function(a,b){j(b.time_position)}),a.$on("mopidy:event:volumeChanged",function(a,b){b.volume!=p.volume&&k(b.volume)}),a.$on("mopidy:event:trackPlaybackStarted",function(a,b){("undefined"==typeof p.currentTlTrack.track||p.currentTlTrack.track.uri!=b.tl_track.track.uri)&&(p.currentTlTrack=b.tl_track,m(b.tl_track),l())}),b(function(){p.playing&&"undefined"!=typeof p.currentTlTrack&&"undefined"!=typeof p.currentTlTrack.track&&p.playPosition =100&&(p.volume=100),q.setVolume(p.volume),g.shortcut("volume-up"))}),a.$on("spotmop:keyboardShortcut:down",function(b){a.ctrlKeyHeld&&(p.volume-=10,p.volume<0&&(p.volume=0),q.setVolume(p.volume),g.shortcut("volume-down"))});var q={state:function(){return p},playPause:function(){p.playing?(e.pause(),p.playing=!1):(e.play(),p.playing=!0)},stop:function(){e.stopPlayback(),p.playing=!1},next:function(){e.next()},previous:function(){e.previous()},seek:function(a){p.playPosition=a,e.seek(a)},setVolume:function(a){p.volume=a,e.setVolume(a)},toggleRepeat:function(){p.isRepeat?e.setRepeat(!1).then(function(a){p.isRepeat=!1}):e.setRepeat(!0).then(function(a){p.isRepeat=!0}),console.log(p)},toggleRandom:function(){p.isRandom?e.setRandom(!1).then(function(a){p.isRandom=!1}):e.setRandom(!0).then(function(a){p.isRandom=!0})},toggleMute:function(){p.isMute?e.setMute(!1).then(function(a){p.isMute=!1}):e.setMute(!0).then(function(a){p.isMute=!0})}};return q}]),angular.module("spotmop.queue",[]).config(["$stateProvider",function(a){a.state("queue",{url:"/queue",templateUrl:"app/queue/template.html",controller:"QueueController"})}]).controller("QueueController",["$scope","$rootScope","$filter","$timeout","$state","MopidyService","SpotifyService","DialogService",function(a,b,c,d,e,f,g,h){function i(b){var c=0;$.each(b,function(a,b){c+=b.track.length}),a.totalTime=Math.round(c/1e5)}a.totalTime=0,a.tracks=b.currentTracklist,a.limit=50;var j=!1;a.$on("spotmop:loadMore",function(){!j&&a.tracks.length>=a.limit&&(a.limit+=50,j=!0,d(function(){j=!1},100))}),a.addUri=function(){h.create("addbyuri",a)},a.clearQueue=function(){f.clearCurrentTrackList()},b.$watch(function(a){return a.currentTracklist},function(b,c){a.tracks=b,i(b)}),a.$on("spotmop:keyboardShortcut:delete",function(b){var d=c("filter")(a.tracks,{selected:!0}),e=[];angular.forEach(d,function(a,b){e.push(a.tlid)}),a.$apply(function(){a.tracks=c("filter")(a.tracks,{selected:!1})}),f.removeFromTrackList(e)})}]),angular.module("spotmop.search",[]).config(["$stateProvider",function(a){a.state("search",{url:"/search/:query/:type",templateUrl:"app/search/template.html",controller:"SearchController",params:{type:{squash:!0,value:"all"},query:{squash:!0,value:null}}})}]).controller("SearchController",["$scope","$rootScope","$state","$stateParams","$timeout","$filter","SpotifyService","MopidyService",function(a,b,c,d,e,f,g,h){function i(c,d){if("undefined"==typeof c)var c=a.type;switch(c){case"track":g.getSearchResults("track",d,50).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(b.tracks.items),a.tracklist.type="track",a.tracklist.next=b.tracks.next,l=b.tracks.next?b.tracks.offset+b.tracks.limit:!1});break;case"album":g.getSearchResults("album",d,50).then(function(b){a.albums=b.albums,l=b.albums.next?b.albums.offset+b.albums.limit:!1});break;case"artist":g.getSearchResults("artist",d,50).then(function(b){a.artists=b.artists,a.next=b.artists.next,a.offset=b.artists.offset});break;case"playlist":g.getSearchResults("playlist",d,50).then(function(b){a.playlists=b.playlists,a.next=b.playlists.next,a.offset=b.playlists.offset});break;case"other":b.mopidyOnline?j(a.query):b.$on("mopidy:state:online",function(){j(a.query)});break;default:g.getSearchResults("track",d,50).then(function(b){a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items}),g.getSearchResults("album",d,50).then(function(b){a.albums=b.albums}),g.getSearchResults("artist",d,50).then(function(b){a.artists=b.artists}),g.getSearchResults("playlist",d,50).then(function(b){a.playlists=b.playlists})}}function j(b){h.search(b,!1,["soundcloud:","local:"]).then(function(b){for(var c=0;c 0&&console.log("A dialog already exists..."),$("body").append(b('')(c))},remove:function(){$("body").children(".dialog").fadeOut(200,function(){$(this).remove()})}}}]).directive("dialog",["$compile",function(a){return{restrict:"E",replace:!0,transclude:!0,scope:{type:"@"},templateUrl:"app/services/dialog/template.html",link:function(b,c){c.find(".content").html(a("<"+b.type+"dialog />")(b))},controller:["$scope","$element","DialogService",function(a,b,c){a.closeDisabled=!1,"initialsetup"==a.type&&(a.closeDisabled=!0),a.closeDialog=function(){c.remove()},a.$on("spotmop:keyboardShortcut:esc",function(b){a.closeDisabled||c.remove()})}]}}]).directive("createplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/createplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f){a.playlistPublic="true",a.savePlaylist=function(){a.playlistName&&""!=a.playlistName?(a.saving=!0,"true"==a.playlistPublic?a.playlistPublic=!0:a.playlistPublic=!1,f.createPlaylist(a.$parent.spotifyUser.id,{name:a.playlistName,"public":a.playlistPublic}).then(function(b){a.$parent.playlists.items.push(b),a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})):a.error=!0}}]}}).directive("editplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/editplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SpotifyService",function(a,b,c,d,e){a.playlistNewName=a.$parent.playlist.name,a.playlistNewPublic=a.$parent.playlist["public"].toString(),a.saving=!1,a.savePlaylist=function(){a.playlistNewName&&""!=a.playlistNewName?(a.saving=!0,"true"==a.playlistNewPublic?a.playlistNewPublic=!0:a.playlistNewPublic=!1,e.updatePlaylist(a.$parent.playlist.uri,{name:a.playlistNewName,"public":a.playlistNewPublic}).then(function(b){a.$parent.playlist.name=a.playlistNewName,a.$parent.playlist["public"]=a.playlistNewPublic,a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})):a.error=!0}}]}}).directive("addtoplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addtoplaylist.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SpotifyService","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){a.playlists=[];var i=g.getSetting("spotifyuser",{id:"undefined"}).id;f.getPlaylists(i,50).then(function(b){a.playlists=d("filter")(b.items,{owner:{id:i}})}),a.playlistSelected=function(b){var g=d("filter")(a.$parent.tracks,{selected:!0}),i=[];angular.forEach(g,function(a){"undefined"!=typeof a.track?i.push(a.track.uri):i.push(a.uri)}),f.addTracksToPlaylist(b.uri,i).then(function(a){e.remove(),c.$broadcast("spotmop:tracklist:unselectAll"),h.notify(i.length+" tracks added to "+b.name)})}}]}}).directive("volumecontrolsdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/volumecontrols.template.html", -controller:["$scope","$element","$rootScope","$filter","DialogService","PlayerService",function(a,b,c,d,e,f){a.state=function(){return f.state()},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)}}]}}).directive("initialsetupdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/initialsetup.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f,g){a.settings=f.getSettings(),f.setSetting("spotify",!0,"authorizationenabled"),f.setSetting("spotmop","default","pointerMode"),a.saving=!1,a.save=function(){a.name&&""!=a.name?(a.saving=!0,f.getSetting("spotify",!1,"authorizationenabled")&&g.authorize(),f.setSetting("pushername",a.name),e.remove()):a.error=!0}}]}}).directive("addbyuridialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addbyuri.template.html",controller:["$scope","$element","DialogService","SpotifyService","MopidyService",function(a,b,c,d,e){a.saving=!1,a.add=function(){a.uri&&""!=a.uri?(a.error=!1,a.saving=!0,e.addToTrackList([a.uri])["catch"](function(b){a.saving=!1,a.error=!0}).then(function(b){a.error||c.remove()})):a.error=!0}}]}}),angular.module("spotmop.services.lastfm",[]).factory("LastfmService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={sendRequest:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"?format=json&api_key="+m+"&"+a}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},trackInfo:function(a,b){return a=encodeURIComponent(a),this.sendRequest("method=track.getInfo&track="+b+"&artist="+a)},albumInfo:function(a,b){return a=encodeURIComponent(a),b=encodeURIComponent(b),this.sendRequest("method=album.getInfo&album="+b+"&artist="+a)},albumInfoByMbid:function(a){return this.sendRequest("method=album.getInfo&mbid="+a)},artistInfo:function(a){return a=encodeURIComponent(a),this.sendRequest("method=artist.getInfo&artist="+a)},artistInfoByMbid:function(a){return this.sendRequest("method=artist.getInfo&mbid="+a)}},l="http://ws.audioscrobbler.com/2.0",m=i.getSetting("lastfmkey","4320a3ef51c9b3d69de552ac083c55e3");return k}]),angular.module("spotmop.services.mopidy",[]).factory("MopidyService",["$q","$rootScope","$cacheFactory","$location","$timeout","SettingsService","PusherService","NotifyService","cfpLoadingBar",function(a,b,c,d,e,f,g,h,i){function j(b,c){return function(){var d=a.defer(),e=Array.prototype.slice.call(arguments),f=c||this;return i.start(),i.set(.25),k(b,f,e).then(function(a){i.complete(),d.resolve(a)},function(a){h.error(a),d.reject(a)}),d.promise}}function k(a,b,c){for(var d=a.split("."),e=d.pop(),f=0;f '+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},error:function(a,b){if("undefined"==typeof b)var b=2500;var c=$(' '+a+" ");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},spotifyAuthenticationError:function(){this.error("Please authenticate with Spotify - you can find this under settings")},shortcut:function(a){$("#notifications").find("notification.keyboard-shortcut").remove();var b=$('');$("#notifications").append(b),d(function(){b.fadeOut(200,function(){b.remove()})},1500)},browserNotify:function(a,b,c){if(e.getSetting("notificationsDisabled",!1))return!1;var d=window.Notification||window.mozNotification||window.webkitNotification;if("undefined"==typeof d)return!1;if("undefined"!=typeof d&&d.requestPermission(function(a){}),"undefined"==typeof c)var c="";new d(a,{body:b,dir:"auto",lang:"EN",tag:"spotmopNotification",icon:c});return!0}}}]).directive("notification",function(){return{restrict:"AE",link:function(a,b,c){console.log(b)}}}),angular.module("spotmop.services.pusher",[]).factory("PusherService",["$rootScope","$http","$q","$localStorage","$cacheFactory","$templateCache","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){"undefined"==typeof d.pusher&&(d.pusher={});var i="http://"+g.getSetting("mopidyhost",window.location.hostname);i+=":"+g.getSetting("mopidyport","6680"),i+="/spotmop/";var j={pusher:{},isConnected:!1,start:function(){var b=g.getSetting("mopidyhost",window.location.hostname),c=g.getSetting("pusherport","6681");try{var d="ws://"+b+":"+c+"/pusher",i=new WebSocket(d);i.onopen=function(){a.$broadcast("spotmop:pusher:online"),this.isConnected=!0},i.onmessage=function(b){var c=JSON.parse(b.data);if(c.pusher)if(c.startup){console.info("Pusher connected as "+c.details.id),g.setSetting("pusherid",c.details.id),g.setSetting("pusherip",c.details.ip),g.getSetting("version",0,"installed")!=c.version&&(h.notify("New version detected, clearing caches..."),e.get("$http").removeAll(),f.removeAll(),g.setSetting("version",c.version,"installed"),g.runUpgrade());var d=g.getSetting("pushername","");d&&j.setMe(d)}else c.id==g.getSetting("pusherid","")||g.getSetting("pusherdisabled",!1)||a.$broadcast("spotmop:pusher:received",c)},i.onclose=function(){a.$broadcast("spotmop:pusher:offline"),j.isConnected=!1,setTimeout(function(){j.start()},5e3)},j.pusher=i}catch(k){console.log("Connecting with Pusher failed with the following error message: "+k)}},stop:function(){this.pusher=null,this.isConnected=!1},send:function(a){a.pusher=!0,a.id=g.getSetting("pusherid",null),j.pusher.send(JSON.stringify(a))},setMe:function(a){var b=g.getSetting("pusherid",null);$.ajax({method:"GET",cache:!1,url:i+"pusher/me?id="+b+"&name="+a})},getConnections:function(){var a=c.defer();return b({method:"GET",cache:!1,url:i+"pusher/connections"}).success(function(b){a.resolve(b)}).error(function(b){h.error(b.error.message),a.reject(b.error.message)}),a.promise}};return j}]),angular.module("spotmop.services.spotify",[]).factory("SpotifyService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","$cacheFactory","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j,k){var l={authenticationMethod:"server",start:function(){var b=$('');$(body).append(b),"undefined"==typeof c.spotify&&(c.spotify={}),"undefined"==typeof c.spotify.AccessToken&&(c.spotify.AccessToken=null),"undefined"==typeof c.spotify.RefreshToken&&(c.spotify.RefreshToken=null),"undefined"==typeof c.spotify.AuthorizationCode&&(c.spotify.AuthorizationCode=null),"undefined"==typeof c.spotify.AccessTokenExpiry&&(c.spotify.AccessTokenExpiry=null),window.addEventListener("message",function(b){if("http://jamesbarnsley.co.nz"!==b.origin)return!1;var d=JSON.parse(b.data);console.info("Spotify authorization successful"),c.spotify.AuthorizationCode=d.authorization_code,c.spotify.AccessToken=d.access_token,c.spotify.RefreshToken=d.refresh_token,a.spotifyOnline=!0,this.authenticationMethod="client",l.getMe().then(function(b){j.setSetting("spotifyuser",b),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)})},!1),this.isAuthorized()?(a.spotifyAuthorized=!0,this.authenticationMethod="client"):(j.setSetting("spotifyuser",!1),a.spotifyAuthorized=!1,this.authenticationMethod="server"),a.$broadcast("spotmop:spotify:online")},logout:function(){c.spotify={},this.authenticationMethod="server",this.refreshToken(),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)},authorize:function(){var a=$(document).find("#authorization-frame");a.attr("src","http://jamesbarnsley.co.nz/spotmop.php?action=authorize&app="+location.protocol+"//"+window.location.host)},isAuthorized:function(){return c.spotify.AuthorizationCode&&c.spotify.RefreshToken?!0:!1},refreshToken:function(){var b=h.defer(),e="";if("client"==this.authenticationMethod)e="http://jamesbarnsley.co.nz/spotmop.php?action=refresh&refresh_token="+c.spotify.RefreshToken;else{if("server"!=this.authenticationMethod)return!1;var f=j.getSetting("mopidyhost",window.location.hostname),g=j.getSetting("mopidyport","6680");e="http://"+f+":"+g+"/spotmop/auth"}return d({method:"GET",url:e,dataType:"json",async:!1,timeout:1e4}).success(function(d){"undefined"!=typeof d.error?(k.error("Spotify authorization error: "+d.error_description),a.spotifyOnline=!1,b.reject(d.error.message)):(c.spotify.AccessToken=d.access_token,c.spotify.AccessTokenExpiry=(new Date).getTime()+36e5,a.spotifyOnline=!0,b.resolve(d))}),b.promise},serviceUnavailable:function(){k.error("Request failed. Spotify API may be temporarily unavailable.")},getFromUri:function(a,b){var c=b.split(":");return"userid"==a&&"user"==c[1]?c[2]:"playlistid"==a&&"playlist"==c[3]?c[4]:"artistid"==a&&"artist"==c[1]?c[2]:"albumid"==a&&"album"==c[1]?c[2]:"trackid"==a&&"track"==c[1]?c[2]:null},uriType:function(a){var b=a.split(":");return"spotify"==b[0]&&"artist"==b[1]?"artist":"spotify"==b[0]&&"album"==b[1]?"album":"spotify"==b[0]&&"user"==b[1]&&"playlist"==b[3]?"playlist":null},getUrl:function(a){var b=h.defer();return d({method:"GET",url:a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getMe:function(){var a=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){a.resolve(b)}).error(function(b){k.error(b.error.message),a.reject(b.error.message)}),a.promise):(a.reject(),a.promise)},getUser:function(a){var b=this.getFromUri("userid",a),c=h.defer();return d({method:"GET",url:m+"users/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},isFollowing:function(a,b){var e=this.getFromUri(a+"id",b),f=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/following/contains?type="+a+"&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},getTrack:function(a){var b=this.getFromUri("trackid",a),c=h.defer();return d({method:"GET",url:m+"tracks/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getMyTracks:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/tracks/?limit=50",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},addTracksToLibrary:function(a){var b=h.defer();if(!this.isAuthorized())return b.reject(),b.promise;var e=i.get("$http");return e.remove(m+"me/tracks/?limit=50"),d({method:"PUT",url:m+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},addAlbumsToLibrary:function(a){if(!this.isAuthorized())return e.reject(),e.promise;var b=i.get("$http");b.remove(m+"me/albums?limit=40&offset=0");var e=h.defer();return"array"!=typeof a&&(a=[a]),d({method:"PUT",url:m+"me/albums",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},removeAlbumsFromLibrary:function(a){if(!this.isAuthorized())return b.reject(),b.promise;var b=h.defer();return"array"!=typeof a&&(a=[a]),d({method:"DELETE",url:m+"me/albums",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},deleteTracksFromLibrary:function(a){var b=h.defer();if(!this.isAuthorized())return b.reject(),b.promise;var e=i.get("$http");return e.remove(m+"me/tracks/?limit=50"),d({method:"DELETE",url:m+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getMyArtists:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/following?type=artist",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getMyAlbums:function(a,b,e){if(!this.isAuthorized())return f.reject(),f.promise;"undefined"!=typeof b&&b||(b=40),"undefined"==typeof e&&(e=0);var f=h.defer();return d({cache:!0,method:"GET",url:m+"me/albums?limit="+b+"&offset="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){for(var b=[],c=Math.ceil(a.items.length/20),d=1;c>=d;d++){var e=a.items.splice(0,20),g=[],h=20;e.length<20&&(h=e.length);for(var i=0;h>i;i++)g.push(e[i].album.id);l.getAlbums(g).then(function(e){b=b.concat(e.albums),d>=c&&(a.items=b,f.resolve(a))})}}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise},isFollowingArtist:function(a,b){var e=this.getFromUri("artistid",a),f=h.defer();return this.isAuthorized()?(d({cache:!1,method:"GET",url:m+"me/following/contains?type=artist&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},followArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"PUT",cache:!1,url:m+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},unfollowArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"DELETE",cache:!1,url:m+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},getPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!1,method:"GET",url:m+"users/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return d({cache:!0,method:"GET",url:m+"users/"+b+"/playlists/"+e+"?market="+n,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise},isFollowingPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({cache:!0,method:"GET",url:m+"users/"+e+"/playlists/"+f+"/followers/contains?ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},followPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"PUT",url:m+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},unfollowPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:m+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},featuredPlaylists:function(a){"undefined"==typeof a&&(a=40);var b=g("date")(new Date,"yyyy-MM-ddTHH:mm:ss"),e=j.getSetting("countrycode","NZ"),f=h.defer();return d({cache:!0,method:"GET",url:m+"browse/featured-playlists?timestamp="+b+"&country="+e+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise},addTracksToPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"POST",url:m+"users/"+e+"/playlists/"+f+"/tracks",dataType:"json",data:JSON.stringify({uris:b}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},movePlaylistTracks:function(a,b,e,f){if(!this.isAuthorized())return l.reject(),l.promise;var g=this.getFromUri("userid",a),i=this.getFromUri("playlistid",a);if(g!=j.getSetting("spotifyuser",{id:null}).id)return!1;var l=h.defer();return d({method:"PUT",url:m+"users/"+g+"/playlists/"+i+"/tracks",dataType:"json",data:JSON.stringify({range_start:b,range_length:e,insert_before:f}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){l.resolve(a)}).error(function(a){k.error(a.error.message),l.reject(a.error.message)}),l.promise},deleteTracksFromPlaylist:function(a,b,e){var f=this.getFromUri("userid",a),g=this.getFromUri("playlistid",a),i=h.defer();return d({method:"DELETE",url:m+"users/"+f+"/playlists/"+g+"/tracks",dataType:"json",data:JSON.stringify({snapshot_id:b,positions:e}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){i.resolve(a)}).error(function(a){k.error(a.error.message),i.reject(a.error.message)}),i.promise},createPlaylist:function(a,b){var e=h.defer();return this.isAuthorized()?(d({method:"POST",url:m+"users/"+a+"/playlists/",dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},updatePlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"PUT",url:m+"users/"+e+"/playlists/"+f,dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},newReleases:function(a,b){"undefined"!=typeof a&&a||(a=40),"undefined"==typeof b&&(b=0);var e=h.defer();return d({cache:!0,method:"GET",url:m+"browse/new-releases?country="+n+"&limit="+a+"&offset="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){for(var b=[],c=Math.ceil(a.albums.items.length/20),d=1;c>d;d++){for(var f=a.albums.items.splice(0,20),g=[],h=0;20>h;h++)g.push(f[h].id);l.getAlbums(g).then(function(f){b=b.concat(f.albums),d>=c&&(a.albums.items=b,e.resolve(a))})}}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},browseCategories:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories?limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategory:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories/"+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategoryPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getMyFavorites:function(a,b,e,f){if("undefined"==typeof b||!b)var b=25;if("undefined"==typeof e||!e)var e=0;if("undefined"==typeof f||!f)var f="long_term";var g=h.defer();return d({cache:!0,method:"GET",url:m+"me/top/"+a+"?limit="+b+"&offset="+e+"&time_range="+f,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise},getRecommendations:function(a,b,e,f,g){var i=m+"recommendations/?";"undefined"!=typeof a&&a&&(i+="limit="+a),"undefined"!=typeof b&&b&&(i+="&offset="+b),"undefined"!=typeof e&&e&&(i+="&seed_artists="+e),"undefined"!=typeof f&&f&&(i+="&seed_albums="+f),"undefined"!=typeof g&&g&&(i+="&seed_tracks="+g);var j=h.defer();return d({cache:!0,method:"GET",url:i,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){j.resolve(a)}).error(function(a){k.error(a.error.message),j.reject(a.error.message)}),j.promise},getArtist:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getArtists:function(a){var b=this,c="";angular.forEach(a,function(a){""!=c&&(c+=","),c+=b.getFromUri("artistid",a)});var e=h.defer();return d({method:"GET",url:m+"artists/?ids="+c}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getTopTracks:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/top-tracks?country="+n}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getRelatedArtists:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/related-artists"}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getAlbum:function(a){var b=h.defer(),c=this.getFromUri("albumid",a);return d({method:"GET",url:m+"albums/"+c}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getAlbums:function(a){for(var b=h.defer(),c="",e=0;e 0&&(c+=","),c+=a[e];return d({cache:!0,method:"GET",url:m+"albums?ids="+c+"&market="+n}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getArtistAlbums:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/albums?album_type=album,single&market="+n}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},isAlbumInLibrary:function(a){for(var b=h.defer(),e="",f=0;f 0&&(e+=","),e+=a[f];return this.isAuthorized()?(d({method:"GET",url:m+"me/albums/contains?ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getSearchResults:function(a,b,e,f){"undefined"==typeof e&&(e=10),"undefined"==typeof f&&(f=0);var g=h.defer();return d({cache:!0,method:"GET",url:m+"search?q="+b+"&type="+a+"&country="+n+"&limit="+e+"&offset="+f,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){if("album"==a)for(var c=[],d=Math.ceil(b.albums.items.length/20),e=1;d>e;e++){for(var f=b.albums.items.splice(0,20),h=[],i=0;20>i;i++)h.push(f[i].id);l.getAlbums(h).then(function(a){c=c.concat(a.albums),e>=d&&(b.albums.items=c,g.resolve(b))})}else g.resolve(b)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise}},m="https://api.spotify.com/v1/",n=j.getSetting("spotifycountry","NZ");j.getSetting("spotifylocale","en_NZ");return l}]).factory("SpotifyServiceIntercepter",["$q","$rootScope","$injector","$localStorage",function(a,b,c,d){"use strict";function e(a,b,d){function e(a){b.resolve(a)}function f(a){b.reject(a)}var g=c.get("$http");a.headers={Authorization:"Bearer "+d},g(a).then(e,f)}var f=0,g={responseError:function(b){if(b.config.url.search("https://api.spotify.com/")>=0&&3>f){if(401==b.status){f++;var d=a.defer();return c.get("SpotifyService").refreshToken().then(function(a){return"undefined"!=typeof a.error?b:(f--,void e(b.config,d,a.access_token))}),d.promise}if(0==b.status){var d=a.defer();return c.get("SpotifyService").serviceUnavailable(),d.promise}}return b}};return g}]),angular.module("spotmop.settings",[]).config(["$stateProvider",function(a){a.state("settings",{url:"/settings",templateUrl:"app/settings/template.html"}).state("testing",{url:"/testing",templateUrl:"app/settings/testing.template.html"})}]).controller("SettingsController",["$scope","$http","$rootScope","$timeout","MopidyService","SpotifyService","SettingsService","NotifyService","PusherService",function(a,b,c,d,e,f,g,h,i){a.version,a.settings=g.getSettings(),a.currentSubpage="mopidy",a.subpageNavigate=function(b){a.currentSubpage=b},a.authorizeSpotify=function(){f.authorize()},a.refreshSpotifyToken=function(){h.notify("Refreshing token"),f.refreshToken().then(function(){})},a.spotifyLogout=function(){f.logout()},a.upgradeCheck=function(){h.notify("Checking for updates"),g.upgradeCheck().then(function(a){g.setSetting("version",a,"latest"),g.getSetting("version",0,"installed")>>0,j=i,k=[],l=0;i>l;++l)if(f=b[l],void 0!==f||l in b){if(e=a._handler(f),e.state()>0){h.become(e),a._visitRemaining(b,l,e);break}e.visit(h,c,d)}else--j;return 0===j&&h.reject(new RangeError("any(): array must not be empty")),g}function e(b,c){function d(a){this.resolved||(k.push(a),0===--n&&(l=null,this.resolve(k)))}function e(a){this.resolved||(l.push(a),0===--f&&(k=null,this.reject(l)))}var f,g,h,i=a._defer(),j=i._handler,k=[],l=[],m=b.length>>>0,n=0;for(h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&++n;for(c=Math.max(c,0),f=n-c+1,n=Math.min(c,n),c>n?j.reject(new RangeError("some(): array must contain at least "+c+" item(s), but had "+n)):0===n&&j.resolve(k),h=0;m>h;++h)g=b[h],(void 0!==g||h in b)&&a._handler(g).visit(j,d,e,j.notify);return i}function f(b,c){return a._traverse(c,b)}function g(b,c){var d=s.call(b);return a._traverse(c,d).then(function(a){return h(d,a)})}function h(b,c){for(var d=c.length,e=new Array(d),f=0,g=0;d>f;++f)c[f]&&(e[g++]=a._handler(b[f]).value);return e.length=g,e}function i(a){return p(a.map(j))}function j(c){var d=a._handler(c);return 0===d.state()?o(c).then(b.fulfilled,b.rejected):(d._unreport(),b.inspect(d))}function k(a,b){return arguments.length>2?q.call(a,m(b),arguments[2]):q.call(a,m(b))}function l(a,b){return arguments.length>2?r.call(a,m(b),arguments[2]):r.call(a,m(b))}function m(a){return function(b,c,d){return n(a,void 0,[b,c,d])}}var n=c(a),o=a.resolve,p=a.all,q=Array.prototype.reduce,r=Array.prototype.reduceRight,s=Array.prototype.slice;return a.any=d,a.some=e,a.settle=i,a.map=f,a.filter=g,a.reduce=k,a.reduceRight=l,a.prototype.spread=function(a){return this.then(p).then(function(b){return a.apply(this,b)})},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../apply":7,"../state":20}],9:[function(b,c){!function(a){"use strict";a(function(){function a(){throw new TypeError("catch predicate must be a function")}function b(a,b){return c(b)?a instanceof b:b(a)}function c(a){return a===Error||null!=a&&a.prototype instanceof Error}function d(a){return("object"==typeof a||"function"==typeof a)&&null!==a}function e(a){return a}return function(c){function f(a,c){return function(d){return b(d,c)?a.call(this,d):j(d)}}function g(a,b,c,e){var f=a.call(b);return d(f)?h(f,c,e):c(e)}function h(a,b,c){return i(a).then(function(){return b(c)})}var i=c.resolve,j=c.reject,k=c.prototype["catch"];return c.prototype.done=function(a,b){this._handler.visit(this._handler.receiver,a,b)},c.prototype["catch"]=c.prototype.otherwise=function(b){return arguments.length<2?k.call(this,b):"function"!=typeof b?this.ensure(a):k.call(this,f(arguments[1],b))},c.prototype["finally"]=c.prototype.ensure=function(a){return"function"!=typeof a?this:this.then(function(b){return g(a,this,e,b)},function(b){return g(a,this,j,b)})},c.prototype["else"]=c.prototype.orElse=function(a){return this.then(void 0,function(){return a})},c.prototype["yield"]=function(a){return this.then(function(){return a})},c.prototype.tap=function(a){return this.then(a)["yield"](this)},c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],10:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.fold=function(b,c){var d=this._beget();return this._handler.fold(function(c,d,e){a._handler(c).fold(function(a,c,d){d.resolve(b.call(this,c,a))},d,this,e)},c,d._handler.receiver,d._handler),d},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],11:[function(b,c){!function(a){"use strict";a(function(a){var b=a("../state").inspect;return function(a){return a.prototype.inspect=function(){return b(a._handler(this))},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../state":20}],12:[function(b,c){!function(a){"use strict";a(function(){return function(a){function b(a,b,d,e){return c(function(b){return[b,a(b)]},b,d,e)}function c(a,b,e,f){function g(f,g){return d(e(f)).then(function(){return c(a,b,e,g)})}return d(f).then(function(c){return d(b(c)).then(function(b){return b?c:d(a(c)).spread(g)})})}var d=a.resolve;return a.iterate=b,a.unfold=c,a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],13:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype.progress=function(a){return this.then(void 0,void 0,a)},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],14:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,d,e){return c.setTimer(function(){a(d,e,b)},b)}var c=a("../env"),d=a("../TimeoutError");return function(a){function e(a,c,d){b(f,a,c,d)}function f(a,b){b.resolve(a)}function g(a,b,c){var e="undefined"==typeof a?new d("timed out after "+c+"ms"):a;b.reject(e)}return a.prototype.delay=function(a){var b=this._beget();return this._handler.fold(e,a,void 0,b._handler),b},a.prototype.timeout=function(a,d){var e=this._beget(),f=e._handler,h=b(g,a,d,e._handler);return this._handler.visit(f,function(a){c.clearTimer(h),this.resolve(a)},function(a){c.clearTimer(h),this.reject(a)},f.notify),e},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../TimeoutError":6,"../env":17}],15:[function(b,c){!function(a){"use strict";a(function(a){function b(a){throw a}function c(){}var d=a("../env").setTimer,e=a("../format");return function(a){function f(a){a.handled||(n.push(a),k("Potentially unhandled rejection ["+a.id+"] "+e.formatError(a.value)))}function g(a){var b=n.indexOf(a);b>=0&&(n.splice(b,1),l("Handled previous rejection ["+a.id+"] "+e.formatObject(a.value)))}function h(a,b){m.push(a,b),null===o&&(o=d(i,0))}function i(){for(o=null;m.length>0;)m.shift()(m.shift())}var j,k=c,l=c;"undefined"!=typeof console&&(j=console,k="undefined"!=typeof j.error?function(a){j.error(a)}:function(a){j.log(a)},l="undefined"!=typeof j.info?function(a){j.info(a)}:function(a){j.log(a)}),a.onPotentiallyUnhandledRejection=function(a){h(f,a)},a.onPotentiallyUnhandledRejectionHandled=function(a){h(g,a)},a.onFatalRejection=function(a){h(b,a.value)};var m=[],n=[],o=null;return a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../env":17,"../format":18}],16:[function(b,c){!function(a){"use strict";a(function(){return function(a){return a.prototype["with"]=a.prototype.withThis=function(a){var b=this._beget(),c=b._handler;return c.receiver=a,this._handler.chain(c,a),b},a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],17:[function(b,c){(function(d){!function(a){"use strict";a(function(a){function b(){return"undefined"!=typeof d&&null!==d&&"function"==typeof d.nextTick}function c(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function e(a){function b(){var a=c;c=void 0,a()}var c,d=document.createTextNode(""),e=new a(b);e.observe(d,{characterData:!0});var f=0;return function(a){c=a,d.data=f^=1}}var f,g="undefined"!=typeof setTimeout&&setTimeout,h=function(a,b){return setTimeout(a,b)},i=function(a){return clearTimeout(a)},j=function(a){return g(a,0)};if(b())j=function(a){return d.nextTick(a)};else if(f=c())j=e(f);else if(!g){var k=a,l=k("vertx");h=function(a,b){return l.setTimer(b,a)},i=l.cancelTimer,j=l.runOnLoop||l.runOnContext}return{setTimer:h,clearTimer:i,asap:j}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})}).call(this,b("FWaASH"))},{FWaASH:3}],18:[function(b,c){!function(a){"use strict";a(function(){function a(a){var c="object"==typeof a&&null!==a&&a.stack?a.stack:b(a);return a instanceof Error?c:c+" (WARNING: non-Error used)"}function b(a){var b=String(a);return"[object Object]"===b&&"undefined"!=typeof JSON&&(b=c(a,b)),b}function c(a,b){try{return JSON.stringify(a)}catch(c){return b}}return{formatError:a,formatObject:b,tryStringify:c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],19:[function(b,c){(function(b){!function(a){"use strict";a(function(){return function(a){function c(a,b){this._handler=a===u?b:d(a)}function d(a){function b(a){e.resolve(a)}function c(a){e.reject(a)}function d(a){e.notify(a)}var e=new w;try{a(b,c,d)}catch(f){c(f)}return e}function e(a){return J(a)?a:new c(u,new x(r(a)))}function f(a){return new c(u,new x(new A(a)))}function g(){return aa}function h(){return new c(u,new w)}function i(a,b){var c=new w(a.receiver,a.join().context);return new b(u,c)}function j(a){return l(T,null,a)}function k(a,b){return l(O,a,b)}function l(a,b,d){function e(c,e,g){g.resolved||m(d,f,c,a(b,e,c),g)}function f(a,b,c){k[a]=b,0===--j&&c.become(new z(k))}for(var g,h="function"==typeof b?e:f,i=new w,j=d.length>>>0,k=new Array(j),l=0;l 0?b(c,f.value,e):(e.become(f),n(a,c+1,f))}else b(c,d,e)}function n(a,b,c){for(var d=b;d c&&a._unreport()}}function p(a){return"object"!=typeof a||null===a?f(new TypeError("non-iterable passed to race()")):0===a.length?g():1===a.length?e(a[0]):q(a)}function q(a){var b,d,e,f=new w;for(b=0;b 0||"function"!=typeof b&&0>e)return new this.constructor(u,d);var f=this._beget(),g=f._handler;return d.chain(g,d.receiver,a,b,c),f},c.prototype["catch"]=function(a){return this.then(void 0,a)},c.prototype._beget=function(){return i(this._handler,this.constructor)},c.all=j,c.race=p,c._traverse=k,c._visitRemaining=n,u.prototype.when=u.prototype.become=u.prototype.notify=u.prototype.fail=u.prototype._unreport=u.prototype._report=U,u.prototype._state=0,u.prototype.state=function(){return this._state},u.prototype.join=function(){for(var a=this;void 0!==a.handler;)a=a.handler;return a},u.prototype.chain=function(a,b,c,d,e){this.when({resolver:a,receiver:b,fulfilled:c,rejected:d,progress:e})},u.prototype.visit=function(a,b,c,d){this.chain(Z,a,b,c,d)},u.prototype.fold=function(a,b,c,d){this.when(new I(a,b,c,d))},S(u,v),v.prototype.become=function(a){a.fail()};var Z=new v;S(u,w),w.prototype._state=0,w.prototype.resolve=function(a){this.become(r(a))},w.prototype.reject=function(a){this.resolved||this.become(new A(a))},w.prototype.join=function(){if(!this.resolved)return this;for(var a=this;void 0!==a.handler;)if(a=a.handler,a===this)return this.handler=D();return a},w.prototype.run=function(){var a=this.consumers,b=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var c=0;c 0?c(d.value):b(d.value)}return{pending:a,fulfilled:c,rejected:b,inspect:d}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],21:[function(b,c){!function(a){"use strict";a(function(a){function b(a,b,c,d){var e=x.resolve(a);return arguments.length<2?e:e.then(b,c,d)}function c(a){return new x(a)}function d(a){return function(){for(var b=0,c=arguments.length,d=new Array(c);c>b;++b)d[b]=arguments[b];return y(a,this,d)}}function e(a){for(var b=0,c=arguments.length-1,d=new Array(c);c>b;++b)d[b]=arguments[b+1];return y(a,this,d)}function f(){return new g}function g(){function a(a){d._handler.resolve(a)}function b(a){d._handler.reject(a)}function c(a){d._handler.notify(a)}var d=x._defer();this.promise=d,this.resolve=a,this.reject=b,this.notify=c,this.resolver={resolve:a,reject:b,notify:c}}function h(a){return a&&"function"==typeof a.then}function i(){return x.all(arguments)}function j(a){return b(a,x.all)}function k(a){return b(a,x.settle)}function l(a,c){return b(a,function(a){return x.map(a,c)})}function m(a,c){return b(a,function(a){return x.filter(a,c)})}var n=a("./lib/decorators/timed"),o=a("./lib/decorators/array"),p=a("./lib/decorators/flow"),q=a("./lib/decorators/fold"),r=a("./lib/decorators/inspect"),s=a("./lib/decorators/iterate"),t=a("./lib/decorators/progress"),u=a("./lib/decorators/with"),v=a("./lib/decorators/unhandledRejection"),w=a("./lib/TimeoutError"),x=[o,p,q,s,t,r,u,n,v].reduce(function(a,b){return b(a)},a("./lib/Promise")),y=a("./lib/apply")(x);return b.promise=c,b.resolve=x.resolve,b.reject=x.reject,b.lift=d,b["try"]=e,b.attempt=e,b.iterate=x.iterate,b.unfold=x.unfold,b.join=i,b.all=j,b.settle=k,b.any=d(x.any),b.some=d(x.some),b.race=d(x.race),b.map=l,b.filter=m,b.reduce=d(x.reduce),b.reduceRight=d(x.reduceRight),b.isPromiseLike=h,b.Promise=x,b.defer=f,b.TimeoutError=w,b})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"./lib/Promise":4,"./lib/TimeoutError":6,"./lib/apply":7,"./lib/decorators/array":8,"./lib/decorators/flow":9,"./lib/decorators/fold":10,"./lib/decorators/inspect":11,"./lib/decorators/iterate":12,"./lib/decorators/progress":13,"./lib/decorators/timed":14,"./lib/decorators/unhandledRejection":15,"./lib/decorators/with":16}],22:[function(a,b){function c(a){return this instanceof c?(this._console=this._getConsole(a||{}),this._settings=this._configure(a||{}),this._backoffDelay=this._settings.backoffDelayMin,this._pendingRequests={},this._webSocket=null,d.createEventEmitter(this),this._delegateEvents(),void(this._settings.autoConnect&&this.connect())):new c(a)}var d=a("bane"),e=a("../lib/websocket/"),f=a("when");c.ConnectionError=function(a){this.name="ConnectionError",this.message=a},c.ConnectionError.prototype=Object.create(Error.prototype),c.ConnectionError.prototype.constructor=c.ConnectionError,c.ServerError=function(a){this.name="ServerError",this.message=a},c.ServerError.prototype=Object.create(Error.prototype),c.ServerError.prototype.constructor=c.ServerError,c.WebSocket=e.Client,c.when=f,c.prototype._getConsole=function(a){if("undefined"!=typeof a.console)return a.console;var b="undefined"!=typeof console&&console||{};return b.log=b.log||function(){},b.warn=b.warn||function(){},b.error=b.error||function(){},b},c.prototype._configure=function(a){var b="undefined"!=typeof document&&"https:"===document.location.protocol?"wss://":"ws://",c="undefined"!=typeof document&&document.location.host||"localhost";return a.webSocketUrl=a.webSocketUrl||b+c+"/mopidy/ws",a.autoConnect!==!1&&(a.autoConnect=!0),a.backoffDelayMin=a.backoffDelayMin||1e3,a.backoffDelayMax=a.backoffDelayMax||64e3,"undefined"==typeof a.callingConvention&&this._console.warn("Mopidy.js is using the default calling convention. The default will change in the future. You should explicitly specify which calling convention you use."),a.callingConvention=a.callingConvention||"by-position-only",a},c.prototype._delegateEvents=function(){this.off("websocket:close"),this.off("websocket:error"),this.off("websocket:incomingMessage"),this.off("websocket:open"),this.off("state:offline"),this.on("websocket:close",this._cleanup),this.on("websocket:error",this._handleWebSocketError),this.on("websocket:incomingMessage",this._handleMessage),this.on("websocket:open",this._resetBackoffDelay),this.on("websocket:open",this._getApiSpec),this.on("state:offline",this._reconnect)},c.prototype.connect=function(){if(this._webSocket){if(this._webSocket.readyState===c.WebSocket.OPEN)return;this._webSocket.close()}this._webSocket=this._settings.webSocket||new c.WebSocket(this._settings.webSocketUrl),this._webSocket.onclose=function(a){this.emit("websocket:close",a)}.bind(this),this._webSocket.onerror=function(a){this.emit("websocket:error",a)}.bind(this),this._webSocket.onopen=function(){this.emit("websocket:open")}.bind(this),this._webSocket.onmessage=function(a){this.emit("websocket:incomingMessage",a)}.bind(this)},c.prototype._cleanup=function(a){Object.keys(this._pendingRequests).forEach(function(b){var d=this._pendingRequests[b];delete this._pendingRequests[b];var e=new c.ConnectionError("WebSocket closed");e.closeEvent=a,d.reject(e)}.bind(this)),this.emit("state:offline")},c.prototype._reconnect=function(){this.emit("reconnectionPending",{timeToAttempt:this._backoffDelay}),setTimeout(function(){this.emit("reconnecting"),this.connect()}.bind(this),this._backoffDelay),this._backoffDelay=2*this._backoffDelay,this._backoffDelay>this._settings.backoffDelayMax&&(this._backoffDelay=this._settings.backoffDelayMax)},c.prototype._resetBackoffDelay=function(){this._backoffDelay=this._settings.backoffDelayMin},c.prototype.close=function(){this.off("state:offline",this._reconnect),this._webSocket.close()},c.prototype._handleWebSocketError=function(a){this._console.warn("WebSocket error:",a.stack||a)},c.prototype._send=function(a){switch(this._webSocket.readyState){case c.WebSocket.CONNECTING:return f.reject(new c.ConnectionError("WebSocket is still connecting"));case c.WebSocket.CLOSING:return f.reject(new c.ConnectionError("WebSocket is closing"));case c.WebSocket.CLOSED:return f.reject(new c.ConnectionError("WebSocket is closed"));default:var b=f.defer();return a.jsonrpc="2.0",a.id=this._nextRequestId(),this._pendingRequests[a.id]=b.resolver,this._webSocket.send(JSON.stringify(a)),this.emit("websocket:outgoingMessage",a),b.promise}},c.prototype._nextRequestId=function(){var a=-1;return function(){return a+=1}}(),c.prototype._handleMessage=function(a){try{var b=JSON.parse(a.data);b.hasOwnProperty("id")?this._handleResponse(b):b.hasOwnProperty("event")?this._handleEvent(b):this._console.warn("Unknown message type received. Message was: "+a.data)}catch(c){if(!(c instanceof SyntaxError))throw c;this._console.warn("WebSocket message parsing failed. Message was: "+a.data)}},c.prototype._handleResponse=function(a){if(!this._pendingRequests.hasOwnProperty(a.id))return void this._console.warn("Unexpected response received. Message was:",a);var b,d=this._pendingRequests[a.id];delete this._pendingRequests[a.id],a.hasOwnProperty("result")?d.resolve(a.result):a.hasOwnProperty("error")?(b=new c.ServerError(a.error.message),b.code=a.error.code,b.data=a.error.data,d.reject(b),this._console.warn("Server returned error:",a.error)):(b=new Error("Response without 'result' or 'error' received"),b.data={response:a},d.reject(b),this._console.warn("Response without 'result' or 'error' received. Message was:",a))},c.prototype._handleEvent=function(a){var b=a.event,c=a;delete c.event,this.emit("event:"+this._snakeToCamel(b),c)},c.prototype._getApiSpec=function(){return this._send({method:"core.describe"}).then(this._createApi.bind(this))["catch"](this._handleWebSocketError)},c.prototype._createApi=function(a){var b="by-position-or-by-name"===this._settings.callingConvention,c=function(a){return function(){var c={method:a};return 0===arguments.length?this._send(c):b?arguments.length>1?f.reject(new Error("Expected zero arguments, a single array, or a single object.")):Array.isArray(arguments[0])||arguments[0]===Object(arguments[0])?(c.params=arguments[0],this._send(c)):f.reject(new TypeError("Expected an array or an object.")):(c.params=Array.prototype.slice.call(arguments),this._send(c))}.bind(this)}.bind(this),d=function(a){var b=a.split(".");return b.length>=1&&"core"===b[0]&&(b=b.slice(1)),b},e=function(a){var b=this;return a.forEach(function(a){a=this._snakeToCamel(a),b[a]=b[a]||{},b=b[a]}.bind(this)),b}.bind(this),g=function(b){var f=d(b),g=this._snakeToCamel(f.slice(-1)[0]),h=e(f.slice(0,-1));h[g]=c(b),h[g].description=a[b].description,h[g].params=a[b].params}.bind(this);Object.keys(a).forEach(g),this.emit("state:online")},c.prototype._snakeToCamel=function(a){return a.replace(/(_[a-z])/g,function(a){return a.toUpperCase().replace("_","")})},b.exports=c},{"../lib/websocket/":1,bane:2,when:21}]},{},[22])(22)}),function(){"use strict";var a,b,c="ngclipboard";"object"==typeof module&&module.exports?(a=require("angular"),b=require("clipboard"),module.exports=c):(a=window.angular,b=window.Clipboard),a.module(c,[]).directive("ngclipboard",["$rootScope",function(a){return{restrict:"A",scope:{ngclipboardSuccess:"&",ngclipboardError:"&"},link:function(c,d){var e=new b(d[0],{text:function(b){return a.selectedTrackURIs}});e.on("success",function(a){c.$apply(function(){c.ngclipboardSuccess({e:a})})}),e.on("error",function(a){c.$apply(function(){c.ngclipboardError({e:a})})})}}}])}(),angular.module("spotmop",["ngResource","ngStorage","ngTouch","ui.router","angular-loading-bar","angular-google-analytics","ngclipboard","spotmop.directives","spotmop.common.contextmenu","spotmop.common.track","spotmop.common.tracklist","spotmop.services.notify","spotmop.services.settings","spotmop.services.player","spotmop.services.spotify","spotmop.services.mopidy","spotmop.services.lastfm","spotmop.services.dialog","spotmop.services.pusher","spotmop.player","spotmop.queue","spotmop.library","spotmop.local","spotmop.search","spotmop.settings","spotmop.discover","spotmop.browse","spotmop.browse.artist","spotmop.browse.album","spotmop.browse.playlist","spotmop.browse.user","spotmop.browse.genre","spotmop.browse.featured","spotmop.browse.new"]).config(["$stateProvider","$locationProvider","$urlRouterProvider","$httpProvider","AnalyticsProvider","cfpLoadingBarProvider",function(a,b,c,d,e,f){c.otherwise("queue"),d.interceptors.push("SpotifyServiceIntercepter"),e.useAnalytics(!0),e.setAccount("UA-64701652-3"),f.parentSelector="body"}]).run(["$rootScope","SettingsService","Analytics",function(a,b,c){}]).controller("ApplicationController",["$scope","$rootScope","$state","$localStorage","$timeout","$location","SpotifyService","MopidyService","PlayerService","SettingsService","NotifyService","PusherService","DialogService","Analytics",function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){n.trackEvent("Spotmop","Started"),b.isTouchDevice=function(){return!!("ontouchstart"in window)},b.isTouchMode=function(){var a=j.getSetting("spotmop",!1,"pointerMode");return"touch"==a?!0:"click"==a?!1:b.isTouchDevice()},a.isSameDomainAsMopidy=function(){var a=j.getSetting("mopidyhost","localhost");return a&&"localhost"!=a?f.host()==a?!0:void 0:!0},a.state=i.state,b.currentTracklist=[],a.spotifyUser={},a.menuCollapsable=!1,a.reloadApp=function(){window.location.reload()},a.playlistsMenu=[],a.myPlaylists={},a.popupVolumeControls=function(){m.create("volumeControls",a)},a.updatePlaylists=function(b){g.getPlaylists(b,50).then(function(b){a.myPlaylists=b.items;var c=[];$.each(b.items,function(b,d){if(d.owner.id==a.spotifyUser.id){var e=d;e.link="/browse/playlist/"+d.uri,e.link="/browse/playlist/"+d.uri,c.push(e)}}),a.playlistsMenu=c})},a.windowWidth=$(document).width(),a.windowHeight=$(document).height(),a.mediumScreen=function(){return a.windowWidth<=800?!0:!1},a.smallScreen=function(){return a.windowWidth<=450?!0:!1},$(window).resize(function(){$(document).width()!=a.windowWidth&&(a.windowWidth=$(document).width(),$(document).find("body").removeClass("menu-revealed"))}),b.$on("$stateChangeStart",function(b){a.hideMenu(),a.$broadcast("spotmop:contextMenu:hide"),n.trackPage(f.path())}),$(document).on("click","#body",function(b){$(b.target).closest(".menu-reveal-trigger").length<=0&&a.hideMenu()}),a.showMenu=function(){$(document).find("body").addClass("menu-revealed")},a.hideMenu=function(){$(document).find("body").removeClass("menu-revealed")},a.checkForLazyLoading=function(){var b=$(document).scrollTop(),c=$(window).height(),d=$(document).height(),e=d-(b+c);100>=e&&a.$broadcast("spotmop:loadMore")},b.$on("cfpLoadingBar:completed",function(b){a.checkForLazyLoading()}),$(document).on("scroll",function(c){a.checkForLazyLoading(),b.isTouchMode()||b.$broadcast("spotmop:contextMenu:hide")}),a.searchSubmit=function(a){n.trackEvent("Search","Performed search",a);var b=g.uriType(a);b?(k.notify("You've been redirected because that looked like a Spotify URI"),"artist"==b?($(document).find(".search-form input").val(""),c.go("browse.artist.overview",{uri:a})):"album"==b?($(document).find(".search-form input").val(""),c.go("browse.album",{uri:a})):"playlist"==b&&($(document).find(".search-form input").val(""),c.go("browse.playlist",{uri:a}))):c.go("search",{query:a})},a.linkingMode=function(a){var b="";return $.isArray(a)||(a=[a]),angular.forEach(a,function(a){""==b&&(c.is(a)?b="active":c.includes(a)&&(b="section"))}),b},a.$on("mopidy:state:online",function(){n.trackEvent("Mopidy","Online"),b.mopidyOnline=!0}),a.$on("mopidy:state:offline",function(){b.mopidyOnline=!1}),b.spotifyAuthorized=!1,a.$on("spotmop:spotify:authenticationChanged",function(c,d){"client"==d?(b.spotifyAuthorized=!0,a.spotifyUser=j.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id),n.trackEvent("Spotify","Authorized",a.spotifyUser.id)):(b.spotifyAuthorized=!1,a.playlistsMenu=[])}),a.$on("spotmop:spotify:online",function(){b.spotifyOnline=!0,b.spotifyAuthorized&&(a.spotifyUser=j.getSetting("spotifyuser"),a.updatePlaylists(a.spotifyUser.id))}),a.$on("spotmop:spotify:offline",function(){a.playlistsMenu=[],b.spotifyOnline=!1}),b.$on("spotmop:settings:changed",function(a,b){switch(b.name){case"mopidy.consume":h.setConsume(b.value)}}),b.$on("mopidy:event:optionsChanged",function(a,b){h.getConsume().then(function(a){j.setSetting("mopidy",a,"consume")})}),l.start(),b.$on("spotmop:pusher:online",function(b,c){var d=j.getSetting("pushername",null);"undefined"!=typeof d&&d&&""!=d||(m.create("initialsetup",a), +n.trackEvent("Core","Initial setup"))}),b.$on("spotmop:pusher:received",function(a,b){var c="";b.spotifyuser=JSON.parse(b.spotifyuser),"undefined"!=typeof b.spotifyuser.images&&b.spotifyuser.images.length>0&&(c=b.spotifyuser.images[0].url),k.browserNotify(b.title,b.body,c),n.trackEvent("Pusher","Notification received",b.body)}),h.start(),g.start(),b.shiftKeyHeld=!1,b.ctrlKeyHeld=!1,$("body").bind("keydown",function(a){if(16===a.which?b.shiftKeyHeld=!0:17===a.which&&(b.ctrlKeyHeld=!0),!$(document).find(":focus").is(":input")&&j.getSetting("keyboardShortcutsEnabled",!1)){var c=new Array(46,32,13,37,38,39,40,27);$.inArray(a.which,c)>-1&&a.preventDefault()}}).bind("keyup",function(a){!$(document).find(":focus").is(":input")&&j.getSetting("keyboardShortcutsEnabled",!1)&&(46===a.which&&b.$broadcast("spotmop:keyboardShortcut:delete"),32===a.which&&b.$broadcast("spotmop:keyboardShortcut:space"),13===a.which&&b.$broadcast("spotmop:keyboardShortcut:enter"),37===a.which&&b.$broadcast("spotmop:keyboardShortcut:left"),38===a.which&&b.$broadcast("spotmop:keyboardShortcut:up"),39===a.which&&b.$broadcast("spotmop:keyboardShortcut:right"),40===a.which&&b.$broadcast("spotmop:keyboardShortcut:down"),27===a.which&&(b.$broadcast("spotmop:keyboardShortcut:esc"),dragging&&(dragging=!1,$(document).find(".drag-tracer").hide()))),16===a.which&&(b.shiftKeyHeld=!1),17===a.which&&(b.ctrlKeyHeld=!1)})}]),angular.module("spotmop.browse.album",[]).config(["$stateProvider",function(a){a.state("browse.album",{url:"/album/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("AlbumController",["$scope","$rootScope","$stateParams","$filter","$state","MopidyService","SpotifyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h,i){function j(){g.getAlbum(m).then(function(b){a.album=b,a.album.totalTracks=b.tracks.total,a.album.images=d("sizedImages")(b.images),a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items,angular.forEach(a.tracklist.tracks,function(b){b.album=a.album});var e=[];angular.forEach(b.artists,function(a){e.push(a.uri)}),g.getArtists(e).then(function(b){if(a.album.artists=[],b.artists)for(var c=0;c 0)a.album.images=d;else if("undefined"!=typeof a.album.musicbrainz_id)i.albumInfoByMbid(a.album.musicbrainz_id).then(function(b){"undefined"!=typeof b.album&&(a.album.images=b.album.image)});else{var e=c[Object.keys(c)[0]];i.albumInfo(e.name.trim(),a.album.name.trim()).then(function(b){"undefined"!=typeof b.album&&(a.album.images=b.album.image)})}})})}function l(b){return"undefined"==typeof b?!1:(n=!0,void g.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(b.items),a.tracklist.next=b.next,n=!1}))}a.album={},a.tracklist={tracks:[]};var m=c.uri;m=m=m.replace("|","/"),a.origin=d("assetOrigin")(m),a.convertedDate=function(){if("undefined"!=typeof a.album.release_date){if(a.mediumScreen())return d("date")(a.album.release_date,"yyyy");if("day"==a.album.release_date_precision)return d("date")(a.album.release_date,"MMMM d, yyyy");if("month"==a.album.release_date_precision)return d("date")(a.album.release_date,"MMMM yyyy");if("year"==a.album.release_date_precision)return a.album.release_date}else if("undefined"!=typeof a.album.date)return a.album.date;return null},a.totalTime=function(){var b=0;return"undefined"!=typeof a.tracklist.tracks&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a.duration_ms?b+=a.duration_ms:"undefined"!=typeof a.length&&(b+=a.length)}),Math.round(b/1e5)},a.playAlbum=function(){f.playStream(m)},"spotify"==a.origin?(a.addToLibrary=function(){g.addAlbumsToLibrary(a.album.id).then(function(){a.isInLibrary=!0})},a.removeFromLibrary=function(){g.removeAlbumsFromLibrary(a.album.id).then(function(){a.isInLibrary=!1})},j(),a.$on("spotmop:loadMore",function(){!n&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&l(a.tracklist.next)})):a.mopidyOnline?k():a.$on("mopidy:state:online",function(){k()});var n=!1}]),angular.module("spotmop.browse.artist",[]).config(["$stateProvider",function(a){a.state("browse.artist",{url:"/artist/:uri","abstract":!0,templateUrl:"app/browse/artist/template.html",controller:["$scope","$state",function(a,b){"browse.artist"===b.current.name&&b.go("browse.artist.overview")}]}).state("browse.artist.overview",{url:"",templateUrl:"app/browse/artist/overview.template.html",controller:"ArtistOverviewController"}).state("browse.artist.related",{url:"/related",templateUrl:"app/browse/artist/related.template.html",controller:"RelatedArtistsController"}).state("browse.artist.biography",{url:"/biography",templateUrl:"app/browse/artist/biography.template.html",controller:"ArtistBiographyController"}).state("browse.artistalbum",{url:"/artist/:artisturi/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("ArtistController",["$scope","$rootScope","$timeout","$interval","$stateParams","$sce","$filter","SpotifyService","SettingsService","MopidyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h,i,j,k,l){function m(){j.getArtist(n).then(function(b){return b.length<=0?void k.error("Could not load artist: "+n):(a.artist=b[0].artists[0],a.artist.type="localartist","undefined"!=typeof a.artist.musicbrainz_id?l.artistInfoByMbid(a.artist.musicbrainz_id).then(function(b){a.artist.images=b.artist.image,a.artist.stats=b.artist.stats}):l.artistInfo(a.artist.name).then(function(b){a.artist.images=b.artist.image,a.artist.stats=b.artist.stats}),a.tracklist.type="localtrack",void(a.tracklist.tracks=g("limitTo")(b,10)))}),j.getLibraryItems(n).then(function(b){a.albums.items=g("filter")(b,{type:"directory"}&&{type:"album"});for(var c=0;c -1&&(a.albums.items[c].uri=d(a.albums.items[c].uri));var e=function(b){return function(c){"undefined"!=typeof c.album&&(a.albums.items[b].images=c.album.image)}}(c);a.albums.items[c].mbid?l.albumInfoByMbid(a.albums.items[c].mbid).then(e):l.albumInfo(a.albums.items[c].artist.name.trim(),a.albums.items[c].name.trim()).then(e)}})}a.artist={},a.tracklist={type:"track"},a.albums={items:[]},a.relatedArtists={};var n=e.uri;n=n=n.replace("|","/"),a.origin=g("assetOrigin")(n),"spotify"==a.origin?(a.followArtist=function(){h.followArtist(e.uri).then(function(b){a.following=!0})},a.unfollowArtist=function(){h.unfollowArtist(e.uri).then(function(b){a.following=!1})},a.playArtistRadio=function(){k.notify("Playing all top tracks"),h.getTopTracks(e.uri).then(function(a){for(var b=[],c=0;c =4&&9.3>a?"commute":a>=9.3&&11>a?"morning":a>=11&&13.5>a?"midday":a>=13.5&&17>a?"afternoon":a>=17&&19>a?"evening":a>=19&&21>a?"dinner":a>=21&&23>a||a>=0&&4>a?"late":void 0},d.featuredPlaylists(50).then(function(b){a.message=b.message,a.playlists=b.playlists.items})}]),angular.module("spotmop.browse.genre",[]).config(["$stateProvider",function(a){a.state("browse.genre",{url:"/genre",templateUrl:"app/browse/genre/template.html",controller:"GenreController"}).state("browse.genrecategory",{url:"/genre/:categoryid",templateUrl:"app/browse/genre/category.template.html",controller:"GenreCategoryController"}).state("browse.categoryplaylist",{url:"/genre/:categoryid/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("GenreController",["$scope","$rootScope","SpotifyService","NotifyService",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.categories.items=a.categories.items.concat(b.categories.items),a.categories.next=b.categories.next,f=!1}))}a.categories=[],c.browseCategories().then(function(b){a.categories=b.categories});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.categories.next&&a.categories.next&&e(a.categories.next)})}]).controller("GenreCategoryController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists.items=a.playlists.items.concat(b.playlists.items),a.playlists.next=b.playlists.next,f=!1}))}a.category={},a.playlists=[],c.getCategory(d.categoryid).then(function(b){a.category=b,c.getCategoryPlaylists(d.categoryid).then(function(b){a.playlists=b.playlists})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.playlists.next&&a.playlists.next&&e(a.playlists.next)})}]),angular.module("spotmop.browse.new",[]).config(["$stateProvider",function(a){a.state("browse.new",{url:"/new",templateUrl:"app/browse/new/template.html",controller:"NewController"}).state("browse.newalbum",{url:"/new/:uri",templateUrl:"app/browse/album/template.html",controller:"AlbumController"})}]).controller("NewController",["$scope","$element","$rootScope","SpotifyService","MopidyService",function(a,b,c,d,e){function f(b){console.log("loading"),h=!0,d.newReleases(!1,b).then(function(b){a.albums.items=a.albums.items.concat(b.albums.items),g=b.albums.offset+b.albums.limit,h=!1})}a.albums=[],d.newReleases().then(function(b){a.albums=b.albums,a.checkForLazyLoading()});var g=50,h=!1;a.$on("spotmop:loadMore",function(){!h&&g&&f(g)})}]),angular.module("spotmop.browse.playlist",[]).config(["$stateProvider",function(a){a.state("browse.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"})}]).controller("PlaylistController",["$scope","$rootScope","$filter","$state","$stateParams","$sce","SpotifyService","MopidyService","SettingsService","DialogService","NotifyService",function(a,b,c,d,e,f,g,h,i,j,k){function l(){var b=d.params.uri,e=g.getFromUri("userid",b),f=i.getSetting("spotifyuser",{id:null}).id;if(e!=f)return k.error("Cannot modify to a playlist you don't own"),!1;var h=c("filter")(a.tracklist.tracks,{selected:!0}),j=[];angular.forEach(h,function(b,c){j.push(a.tracklist.tracks.indexOf(b)),b.transitioning=!0}),g.deleteTracksFromPlaylist(a.playlist.uri,a.playlist.snapshot_id,j).then(function(b){"undefined"!=typeof b.error?(k.error(b.error.message),angular.forEach(h,function(a,b){a.transitioning=!1})):(a.tracklist.tracks=c("nullOrUndefined")(a.tracklist.tracks,"selected"),a.playlist.snapshot_id=b.snapshot_id)})}function m(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,c.added_by=a.added_by,c.is_local=a.is_local,b.push(c)}),b}function n(b){return"undefined"==typeof b?!1:(o=!0,void g.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(m(b.items)),a.tracklist.next=b.next,o=!1}))}a.playlist={images:[]},a.tracklist={tracks:[],type:"track"},a.totalTime=0,a.following=!1,a.followPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Following playlist"),a.updatePlaylists()})},a.unfollowPlaylist=function(){g.unfollowPlaylist(e.uri).then(function(b){a.following=!1,k.notify("Playlist removed"),a.updatePlaylists()})},a.recoverPlaylist=function(){g.followPlaylist(e.uri).then(function(b){a.following=!0,k.notify("Playlist recovered"),a.updatePlaylists()})},a.editPlaylist=function(){j.create("editPlaylist",a)},a.playPlaylist=function(){h.playStream(a.playlist.uri,a.tracklist.tracks.length)},a.totalTime=function(){var b=0;return a.tracklist.tracks.length>0&&angular.forEach(a.tracklist.tracks,function(a){"undefined"!=typeof a&&(b+=a.duration_ms)}),Math.round(b/1e5)},g.getPlaylist(e.uri).then(function(c){a.playlist=c,a.tracklist.next=c.tracks.next,a.tracklist.previous=c.tracks.previous,a.tracklist.offset=c.tracks.offset,a.tracklist.total=c.tracks.total,a.tracklist.tracks=m(c.tracks.items),a.playlist.description=f.trustAsHtml(a.playlist.description),b.spotifyAuthorized&&g.getUser(a.playlist.owner.uri).then(function(b){a.playlist.owner=b}),b.spotifyAuthorized&&g.isFollowingPlaylist(e.uri,i.getSetting("spotifyuser",{id:null}).id).then(function(b){a.following=$.parseJSON(b)}),"undefined"!=typeof e.categoryid&&g.getCategory(e.categoryid).then(function(b){a.category=b})}),a.$on("spotmop:playlist:reorder",function(b,c,e,f){var h=d.params.uri,j=g.getFromUri("userid",h),l=i.getSetting("spotifyuser",{id:null}).id;if(j!=l)k.error("Cannot edit a playlist you don't own");else{g.movePlaylistTracks(h,c,e,f);for(var m=[],n=0;e>n;n++)m.push(a.tracklist.tracks[c+n]);f>c&&(f-=e),m.reverse(),a.$apply(function(){a.tracklist.tracks.splice(c,e),angular.forEach(m,function(b){a.tracklist.tracks.splice(f,0,b)})})}}),a.$on("spotmop:playlist:deleteSelectedTracks",function(a){l()}),a.$on("spotmop:keyboardShortcut:delete",function(a){l()});var o=!1;a.$on("spotmop:loadMore",function(){!o&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&n(a.tracklist.next)})}]),angular.module("spotmop.browse.user",[]).config(["$stateProvider",function(a){a.state("browse.user",{url:"/user/:uri",templateUrl:"app/browse/user/template.html",controller:"UserController"})}]).controller("UserController",["$scope","$rootScope","SpotifyService","$stateParams",function(a,b,c,d){function e(b){return"undefined"==typeof b?!1:(f=!0,void c.getUrl(b).then(function(b){a.playlists=a.playlists.concat(b.items),a.next=b.next,f=!1}))}a.user={},a.playlists=[],c.getUser(d.uri).then(function(b){a.user=b,c.getPlaylists(b.id).then(function(b){a.playlists=b.items,a.next=b.next,a.totalPlaylists=b.total})});var f=!1;a.$on("spotmop:loadMore",function(){!f&&"undefined"!=typeof a.next&&a.next&&e(a.next)})}]),angular.module("spotmop.common.contextmenu",[]).directive("contextmenu",function(){return{restrict:"E",replace:!0,templateUrl:"app/common/contextmenu/template.html",link:function(a,b,c){},controller:["$scope","$rootScope","$element","$timeout","NotifyService",function(a,b,c,d,e){$(document).on("click",function(a){if(!b.isTouchMode()&&1===a.which){var c=$(a.target);c.is("contextmenu")||(c=c.closest("contextmenu")),c.is("contextmenu")||b.$broadcast("spotmop:contextMenu:hide")}}),a.triggerEvent="",a.play=function(){b.$broadcast("spotmop:tracklist:playSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.enqueue=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.unqueue=function(){b.$broadcast("spotmop:tracklist:unqueueSelectedTracks"),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.playNext=function(){b.$broadcast("spotmop:tracklist:enqueueSelectedTracks",!0),c.fadeOut("fast"),a.isTouchMode()&&b.$broadcast("spotmop:tracklist:unselectAll")},a.addToPlaylist=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylist"),c.fadeOut("fast")},a.addToPlaylistByUri=function(a){b.$broadcast("spotmop:tracklist:addSelectedTracksToPlaylistByUri",a),c.fadeOut("fast")},a.removeFromPlaylist=function(){b.$broadcast("spotmop:playlist:deleteSelectedTracks"),c.fadeOut("fast")},a.addToLibrary=function(){b.$broadcast("spotmop:tracklist:addSelectedTracksToLibrary"),c.fadeOut("fast")},a.copyURIs=function(){b.$broadcast("spotmop:tracklist:copyURIsToClipboard"),c.fadeOut("fast")},a.copiedToClipboard=function(a){e.notify("Copied selected track URIs to clipboard"),c.fadeOut("fast")},a.selectAll=function(){b.$broadcast("spotmop:tracklist:selectAll")},a.unselectAll=function(){b.$broadcast("spotmop:tracklist:unselectAll"),c.fadeOut("fast")},a.$on("spotmop:contextMenu:show",function(e,f,g){return b.isTouchMode()?!1:void a.$apply(function(){a.context=g,a.triggerEvent="click",d(function(){var a=f.pageY-$(window).scrollTop(),b=f.pageX,d=c.outerWidth(),e=c.outerHeight();b+d>$(window).width()?(b-=d-10,c.addClass("hard-right")):b+d+150>$(window).width()?c.addClass("close-right"):c.removeClass("hard-right close-right"),a+e>$(window).height()?(a-=e,c.addClass("hard-bottom")):a+e+306>$(window).height()?c.addClass("close-bottom"):c.removeClass("hard-bottom close-bottom"),c.css({top:a,left:b+5}).show()})})}),a.$on("spotmop:touchContextMenu:show",function(b,d){c.show(),a.triggerEvent="touch",c.removeClass("hard-bottom close-bottom hard-right close-right"),c.css({top:"auto",left:0}),a.$apply(function(){a.context=d})}),a.$on("spotmop:contextMenu:hide",function(a){c.fadeOut("fast")})}]}}),angular.module("spotmop.directives",[]).config(["cfpLoadingBarProvider",function(a){a.latencyThreshold=250}]).directive("singleclick",function(){return function(a,b,c){b.bind("touchstart click",function(b){b.preventDefault(),b.stopPropagation(),a.$apply(c.singleclick)})}}).directive("candrag",["$rootScope","$filter","MopidyService","SpotifyService","NotifyService","PlayerService",function(a,b,c,d,e,f){return{restrict:"A",scope:{dragobj:"="},link:function(e,g,h){function i(c){a.dragging=!0;var d=!1;if(v.dragActive||(d=!0),v.dragActive=!0,$(document).find(".dropping").removeClass("dropping"),$(document).find(".dropping-within").removeClass("dropping-within"),d){$("body").addClass("dragging");var f="";if("album"==e.dragobj.type||"localalbum"==e.dragobj.type||"artist"==e.dragobj.type||"localartist"==e.dragobj.type||"playlist"==e.dragobj.type){var g=!1;if("undefined"!=typeof e.dragobj.images.small)var g=e.dragobj.images;else if(e.dragobj.images.length>0)var g=b("sizedImages")(e.dragobj.images);g&&(f=''),f+=' '+e.dragobj.name+""}else if("track"==e.dragobj.type||"tltrack"==e.dragobj.type||"localtrack"==e.dragobj.type)for(var h=$(document).find(".track.selected"),i=0;ii;i++)f+=' '+h.eq(i).find(".title").html()+"";u.html(f),u.show(),$.each($(document).find("#dropzones > .dropzone"),function(a,b){t($(b))?$(b).removeClass("disabled"):$(b).addClass("disabled")})}u.css({left:c.clientX,top:c.clientY});var j=s(c),k=t(j);if(k){j.addClass("dropping");var l=$(c.target);l.hasClass("track")||(l=l.closest(".track")),l.hasClass("track")&&l.addClass("dropping"),j.parent().closest(".droppable").addClass("dropping-within")}}function j(b){a.$broadcast("spotmop:contextMenu:hide"),u.fadeOut("medium"),$("body").removeClass("dragging"),$(document).find(".dropping").removeClass("dropping");var c=s(b),d=t(c);if(d)switch(c.attr("droptype")){case"queue":k();break;case"queuenext":var g=f.state().currentTracklistPosition();k(g);break;case"playlist":l(b);break;case"library":"track"==e.dragobj.type?n():"tltrack"==e.dragobj.type?n():"album"==e.dragobj.type?m():"artist"==e.dragobj.type?o():"playlist"==e.dragobj.type&&p();break;case"queuetracklist":q(b);break;case"playlisttracklist":r(b)}a.dragging=!1}function k(a){if("undefined"==typeof a)var a=null;switch(e.dragobj.type){case"album":c.addToTrackList([e.dragobj.uri],a);break;case"localalbum":c.addToTrackList([e.dragobj.uri],a);break;case"track":for(var b=[],d=$(document).find(".track.selected"),f=0;fg&&(e-=d.length),c.moveTlTracks(f,g,e)}function r(b){var c=$(b.target);c.hasClass("track")||(c=c.closest(".track"));var d=$(v.domobj).closest(".tracklist").find(".track.selected"),e=(c.closest(".tracklist").attr("playlisturi"),Number(c.parent().attr("data-index"))),f=Number(d.first().parent().attr("data-index")),g=Number(d.length);a.$broadcast("spotmop:playlist:reorder",f,g,e)}function s(a){var b=$(a.target);return b.hasClass("droppable")||(b=b.closest(".droppable")),b?b:!1}function t(a){var b=a.attr("dropaccept");return b?(b=JSON.parse(b),b.indexOf(e.dragobj.type)>=0?!0:!1):!1}var u=$(document).find(".drag-tracer"),v={threshold:30,dragStarted:!1,dragActive:!1,startX:!1,starY:!1};g.on("mousedown",function(a){v.dragStarted=!0,v.startX=a.clientX,v.startY=a.clientY,v.domobj=a.currentTarget,"undefined"!=typeof e.dragobj.__model__&&"undefined"==typeof e.dragobj.type&&(e.dragobj.type=e.dragobj.__model__.toLowerCase())}),$(document).on("mouseup",function(a){v.dragActive&&j(a),v.dragStarted=!1,v.dragActive=!1,v.startX=!1,v.startY=!1,v.domobj=!1}),$(document).on("mousemove",function(a){if(v.dragStarted){var b=v.startX-v.threshold,c=v.startX+v.threshold,d=v.startY-v.threshold,e=v.startY+v.threshold;(a.clientXc||a.clientY e)&&i(a)}})}}}]).directive("switch",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{name:"@",label:"@",value:"="},replace:!0,transclude:!0,controller:["$scope","$element","$attrs",function(b,c,d){c.bind("touchstart click",function(c){c.preventDefault(),c.stopPropagation(),b.$apply(function(){b.value=!b.value,a.$broadcast("spotmop:settings:changed",{name:b.name,value:b.value})})})}],template:' '}}]).directive("artistlist",["$rootScope","SettingsService",function(a,b){return{restrict:"E",scope:{artists:"="},link:function(a,b,c){a.nolinks=c.hasOwnProperty("nolinks"),a.sentence=c.hasOwnProperty("sentence")},replace:!0,transclude:!0,templateUrl:"app/common/artistlist.template.html"}}]).directive("thumbnail",["$timeout","$http","$filter",function(a,b,c){return{restrict:"E",scope:{images:"=",size:"@",debugging:"@"},replace:!0,transclude:!0,link:function(a,d,e){function f(){if(!a.images)return!1;var e=c("sizedImages")(a.images);e=a.size?e[a.size]:e.small,e&&""!=e&&b({method:"GET",url:e,cache:!0}).success(function(){d.css("background-image","url("+e+")")})}f(),a.$watch("images",function(a,b){f()})},template:''}}]).directive("confirmationButton",function(){return{restrict:"E",controller:["$scope","$element",function(a,b){a.text="Button text",a.confirming=!1,a.text=a.defaultText,$(document).on("click",function(c){c.target==b[0]&&1==c.which?a.confirming?"function"==typeof a.$parent[a.onConfirmation]()&&a.$parent[a.onConfirmation]():(a.confirming=!0,a.text=a.confirmationText,a.$apply()):(a.confirming=!1,a.text=a.defaultText,a.$apply())})}],scope:{text:"@",extraClasses:"@",confirmationText:"@",defaultText:"@",onConfirmation:"@"},replace:!0,transclude:!0,template:''}}).directive("slider",["$timeout",function(a){return{restrict:"E",scope:{items:"="},link:function(b,c){function d(a){return"prev"==a&&0>=g?!1:"next"==a&&g>=h?!1:!0}function e(){var a=c.find(".item-container").children().first().height();c.css({height:a+"px"})}var f=c.find(".slides-content"),g=0,h=b.items.length/5-1;b.prev=function(){d("prev")&&(g--,f.animate({left:100*-g+"%"},120))},b.next=function(){d("next")&&(g++,f.animate({left:100*-g+"%"},120))},a(function(){e()},0),$(window).resize(function(){e()})},templateUrl:"app/common/slider.template.html"}}]).directive("textOverImage",function(){return{restrict:"A",link:function(a,b){a.$on("spotmop:detectBackgroundColor",function(a){BackgroundCheck.init({targets:$.merge($(b).parent(),$(document).find("#utilities")),images:b.closest(".intro").find(".image")}),BackgroundCheck.refresh()})}}}).directive("preloadedimage",["$rootScope","$timeout",function(a,b){return{restrict:"E",scope:{url:"@",useproxy:"@",detectbackground:"@",opacity:"@"},link:function(a,b,c){function d(){var c="";c+=a.url;var d=$('');d.load(function(){b.attr("style",'background-image: url("'+c+'");');var d=1;"undefined"!=typeof a.opacity&&(d=a.opacity),b.animate({opacity:d},200)})}b.attr("watch")&&a.$watch("url",function(a,b){a&&d()},!0),d()},template:""}}]).directive("backgroundparallax",["$rootScope","$timeout","$interval","$http","$filter",function(a,b,c,d,e){return{restrict:"E",terminal:!0,scope:{images:"=",image:"@",opacity:"@"},link:function(a,b,d){function f(a){var c=b.outerWidth(),d=b.outerHeight();if((i.canvas.width!=c||i.canvas.height!=d)&&(i.canvas.width=c,i.canvas.height=d),a.widthc){var e=c/a.width;a.width=a.width*e,a.height=a.height*e}if(a.height g&&f(l)}})},10)},template:''}}]).filter("splitstring",[function(){return function(a,b){var c=a.split(":");return c[b]}}]).filter("nullOrUndefined",[function(){return function(a,b){for(var c=[],d=0;d =b&&(b="0"+b);var c=Math.floor(a/6e4%60);return c+":"+b}}).filter("stripAccents",function(){return function(a){for(var b=[/[\300-\306]/g,/[\340-\346]/g,/[\310-\313]/g,/[\350-\353]/g,/[\314-\317]/g,/[\354-\357]/g,/[\322-\330]/g,/[\362-\370]/g,/[\331-\334]/g,/[\371-\374]/g,/[\321]/g,/[\361]/g,/[\307]/g,/[\347]/g],c=["A","a","E","e","I","i","O","o","U","u","N","n","C","c"],d=0;d =200&&c.height<=300)return c.url;if(c.height>300&&c.height<=500)return c.url;if(c.height>=150&&c.height<200)return c.url}return a[0].url}}).filter("sizedImages",["SettingsService",function(a){return function(b){if("undefined"==typeof b||b.length<=0)return!1;for(var c={},d=0;d =650?c.large=e.url:e.height>=250?c.medium=e.url:c.small=e.url),c.small||(c.small=e.url),c.medium||(c.medium=e.url),c.large||(c.large=e.url)}else if("undefined"!=typeof e.height)e.height&&(e.height>=650?c.large=e.url:e.height>=300?c.medium=e.url:c.small=e.url),c.small||(c.small=e.url),c.medium||(c.medium=e.url),c.large||(c.large=e.url);else if("undefined"!=typeof e["#text"]){if(e["#text"]&&e["#text"].length>0&&""!=e.size)switch(e.size){case"mega":c.large=e["#text"];break;case"extralarge":c.medium=e["#text"],c.large||(c.large=e["#text"]);break;case"large":c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"]);break;case"medium":c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"]);break;case"small":c.small=e["#text"],c.medium||(c.medium=e["#text"]),c.large||(c.large=e["#text"])}}else c.large=e,c.medium=e,c.small=e}return c}}]).filter("shuffle",function(){return function(a){var b,c,d;for(b=a.length-1;b>0;b--)c=Math.floor(Math.random()*(b+1)),d=a[b],a[b]=a[c],a[c]=d;return a}}).filter("assetOrigin",function(){ +return function(a){if("undefined"==typeof a)return!1;var b=a.split(":");return b.length<=0?!1:b[0]}}).filter("assetType",function(){return function(a){if("undefined"==typeof a)return!1;var b=a.split(":");return b.length<=1?!1:b[1]}}).filter("mbid",function(){return function(a){if("undefined"==typeof a)return!1;var b=a.indexOf(":mbid:")+6,c=a.length;return a.substr(b,c)}}),angular.module("spotmop.common.tracklist.service",[]).factory("TracklistService",["$rootScope",function(a){return{getSelectedTracks:function(){console.log("triggered getSelectedTracks")}}}]),angular.module("spotmop.common.track",[]).directive("track",function(){return{restrict:"E",templateUrl:"app/common/tracklist/track.template.html",controller:["$element","$scope","$rootScope","MopidyService","NotifyService",function(a,b,c,d,e){a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"track"))}),a.dblclick(function(a){d.playTrack([b.track.uri],0)})}]}}).directive("tltrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/tltrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService",function(a,b,c,d,e){b.state=e.state,b.isCurrentlyPlaying=function(){return b.track.tlid==b.state().currentTlTrack.tlid},b.sourceIconClasses=function(){if("undefined"==typeof b.track.track)return!1;var a=b.track.track.uri.split(":")[0],c="light";return b.isCurrentlyPlaying()&&("spotify"==a&&(c="green"),"local"==a&&(c="yellow"),"soundcloud"==a&&(c="red")),a+" "+c},a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"tltrack"))}),a.dblclick(function(a){d.getCurrentTlTracks().then(function(a){$.each(a,function(a,c){return c.tlid==b.track.tlid?d.playTlTrack({tl_track:c}):void 0})})})}]}}).directive("localtrack",function(){return{restrict:"E",templateUrl:"app/common/tracklist/localtrack.template.html",link:function(a,b,c){},controller:["$element","$scope","$rootScope","MopidyService","PlayerService","NotifyService",function(a,b,c,d,e,f){b.state=e.state,a.mouseup(function(a){1===a.which?(c.isTouchMode()||b.$emit("spotmop:contextMenu:hide"),$(a.target).is("a")||b.$parent.trackClicked(b)):3===a.which&&(b.track.selected||b.$parent.trackClicked(b),b.$emit("spotmop:contextMenu:show",a,"localtrack"))}),a.dblclick(function(a){d.playTrack([b.track.uri],0)})}]}}),angular.module("spotmop.common.tracklist",[]).directive("tracklist",["$compile",function(a){return{restrict:"E",templateUrl:"app/common/tracklist/template.html",scope:{tracks:"=",type:"@",limit:"@"},link:function(a,b,c){},controller:["$element","$scope","$filter","$rootScope","$stateParams","MopidyService","SpotifyService","DialogService","NotifyService","SettingsService","PlayerService",function(a,b,c,d,e,f,g,h,i,j,k){function l(){var a=c("filter")(b.tracks,{selected:!0}),e=[];angular.forEach(a,function(a){"undefined"!=typeof a.track?e.push(a.track.uri):e.push(a.uri)}),d.selectedTrackURIs=e}function m(){if(d.tracklistInFocus===b.$id){var a=c("filter")(b.tracks,{selected:!0}),e=a[0];if("tltrack"==b.type)f.getCurrentTlTracks().then(function(a){$.each(a,function(a,b){return b.tlid==e.tlid?f.playTlTrack({tl_track:b}):void 0})});else{for(var g=[],h=1;h 10&&(j+="... this could take some time"),i.notify(j),f.playTrack([e.uri],0).then(function(){g.length>0&&f.addToTrackList(g,1)})}}}function n(){angular.forEach(b.tracks,function(a){a.selected=!1})}d.selectedTrackURIs=[],$(document).contextmenu(function(a){return $(a.target).closest(".tracklist").length>0?!1:void 0}),b.tracksWrapper=function(){return b.limit&&b.limit>0?c("limitTo")(b.tracks,parseInt(b.limit)):b.tracks},b.$on("spotmop:track:dragging",function(a){});var o=d.$on("spotmop:tracklist:focusChanged",function(a,c){d.tracklistInFocus=c,b.$id!=c&&n()});b.$on("$destroy",o),b.trackClicked=function(a){if(d.$broadcast("spotmop:tracklist:focusChanged",b.$id),!d.dragging){if(d.ctrlKeyHeld||d.isTouchMode()?a.track.selected?a.$apply(function(){a.track.selected=!1}):a.$apply(function(){a.track.selected=!0}):d.ctrlKeyHeld||(angular.forEach(b.tracks,function(a){a.selected=!1}),a.$apply(function(){a.track.selected=!0})),d.shiftKeyHeld){if("undefined"==typeof b.lastSelectedTrack)return void a.$apply(function(){a.track.selected=!0});var e=b.lastSelectedTrack.$index,f=a.$index;a.$index =g;g++)b.tracks[g].selected=!0;b.$apply()}b.lastSelectedTrack=a,d.isTouchMode()&&(c("filter")(b.tracks,{selected:!0}).length>0?d.$broadcast("spotmop:touchContextMenu:show",b.type):d.$broadcast("spotmop:contextMenu:hide")),l()}},b.$on("spotmop:tracklist:enqueueSelectedTracks",function(a,e){if(d.tracklistInFocus===b.$id){var g=null;"undefined"!=typeof e&&1==e&&(g=k.state().currentTracklistPosition());var h=c("filter")(b.tracks,{selected:!0}),j=[];angular.forEach(h,function(a){j.push(a.uri)});var l="Adding "+h.length+" tracks to queue";h.length>10&&(l+="... this could take some time"),i.notify(l),f.addToTrackList(j,g)}}),b.$on("spotmop:tracklist:playSelectedTracks",function(){m()}),b.$on("spotmop:keyboardShortcut:enter",function(){m()}),b.$on("spotmop:tracklist:unqueueSelectedTracks",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),g=[];angular.forEach(e,function(a){g.push(a.tlid)}),f.removeFromTrackList(g)}}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylist",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),f=[];angular.forEach(e,function(a){"undefined"!=typeof a.track?f.push(a.track.uri):f.push(a.uri)}),h.create("addToPlaylist",b)}}),b.$on("spotmop:tracklist:addSelectedTracksToPlaylistByUri",function(a,e){if(d.tracklistInFocus===b.$id){var f=c("filter")(b.tracks,{selected:!0}),h=[],j=0;if(angular.forEach(f,function(a){"undefined"!=typeof a.track?"local:"==a.track.uri.substring(0,6)?j++:h.push(a.track.uri):"local:"==a.uri.substring(0,6)?j++:h.push(a.uri)}),j>0){if(h.length<=0)return i.error("Cannot add local tracks to a Spotify playlist"),!1;i.error(j+" local tracks not added to Spotify playlist")}g.addTracksToPlaylist(e,h).then(function(a){i.notify("Added "+h.length+" tracks to playlist")})}}),b.$on("spotmop:tracklist:addSelectedTracksToLibrary",function(a){if(d.tracklistInFocus===b.$id){var e=c("filter")(b.tracks,{selected:!0}),f=[];angular.forEach(e,function(a){"undefined"!=typeof a.track?f.push(g.getFromUri("trackid",a.track.uri)):f.push(g.getFromUri("trackid",a.uri))}),g.addTracksToLibrary(f)}}),b.$on("spotmop:tracklist:selectAll",function(a){n()}),b.$on("spotmop:tracklist:unselectAll",function(a){n()}),b.$on("spotmop:tracklist:copyURIsToClipboard",function(a){var d=c("filter")(b.tracks,{selected:!0}),e="";angular.forEach(d,function(a){""!=e&&(e+=","),e+="undefined"!=typeof a.track?a.track.uri:a.uri}),console.log(e)})}]}}]),angular.module("spotmop.discover",[]).config(["$stateProvider",function(a){a.state("discover",{url:"/discover",templateUrl:"app/discover/template.html",controller:"DiscoverController"})}]).controller("DiscoverController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","NotifyService",function(a,b,c,d,e,f){function g(b){var c=[],e="";angular.forEach(b.track.artists,function(a){c.push({name:a.name,name_encoded:encodeURIComponent(a.name),uri:a.uri}),""!=e&&(e+=","),e+=d.getFromUri("artistid",a.uri)}),a.current.artists=c,d.getRecommendations(!1,!1,e).then(function(b){var c=[];angular.forEach(b.tracks,function(a){var b=a.album;b.artists=a.artists,c.push(b)}),a.current.items=c})}a.favorites=[],a.current=[],a.sections=[],d.getMyFavorites("artists",50,!1,"long_term").then(function(b){a.favorites.items=c("shuffle")(b.items)}),d.getMyFavorites("tracks",50,!1,"short_term").then(function(b){var e=b.items;e=c("shuffle")(b.items),e=c("limitTo")(b.items,5),angular.forEach(e,function(b){d.getRecommendations(!1,!1,!1,!1,b.id).then(function(c){var d=[];angular.forEach(c.tracks,function(a){var b=a.album;b.artists=a.artists,d.push(b)});var e={title:"Because you listened to ",artists:b.artists,items:d};a.sections.push(e)})})}),"undefined"!=typeof a.state().currentTlTrack.track&&g(a.state().currentTlTrack),b.$on("spotmop:currenttrack:loaded",function(a,b){g(b)})}]),angular.module("spotmop.library",[]).config(["$stateProvider",function(a){a.state("library",{url:"/library",templateUrl:"app/library/template.html"}).state("library.playlists",{url:"/playlists",templateUrl:"app/library/playlists.template.html",controller:"LibraryPlaylistsController"}).state("library.playlist",{url:"/playlist/:uri",templateUrl:"app/browse/playlist/template.html",controller:"PlaylistController"}).state("library.tracks",{url:"/tracks",templateUrl:"app/library/tracks.template.html",controller:"LibraryTracksController"}).state("library.artists",{url:"/artists",templateUrl:"app/library/artists.template.html",controller:"LibraryArtistsController"}).state("library.albums",{url:"/albums",templateUrl:"app/library/albums.template.html",controller:"LibraryAlbumsController"})}]).controller("LibraryTracksController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(a){var b=[];return angular.forEach(a,function(a){var c=a.track;c.added_at=a.added_at,b.push(c)}),b}function h(b){return"undefined"==typeof b?!1:(j=!0,void d.getUrl(b).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(g(b.items)),a.tracklist.next=b.next,j=!1}))}a.tracklist={tracks:[],type:"track"};var i=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyTracks(i).then(function(b){a.tracklist=b,a.tracklist.tracks=g(b.items),"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()}),a.$on("spotmop:keyboardShortcut:delete",function(b){var e=c("filter")(a.tracklist.tracks,{selected:!0}),f=[];angular.forEach(e,function(a,b){f.push(d.getFromUri("trackid",a.uri))}),d.deleteTracksFromLibrary(f).then(function(b){a.tracklist.tracks=c("filter")(a.tracklist.tracks,{selected:!1})})});var j=!1;a.$on("spotmop:loadMore",function(){!j&&"undefined"!=typeof a.tracklist.next&&a.tracklist.next&&h(a.tracklist.next)})}]).controller("LibraryArtistsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService",function(a,b,c,d,e,f){function g(b){return"undefined"==typeof b?!1:(i=!0,void d.getUrl(b).then(function(b){a.artists.items=a.artists.items.concat(b.artists.items),a.artists.next=b.artists.next,i=!1}))}a.artists=[];var h=e.getSetting("spotifyuserid",a.$parent.spotifyUser.id);d.getMyArtists(h).then(function(b){a.artists=b.artists,"undefined"!=typeof b.error&&401==b.error.status&&Spotify.refreshToken()});var i=!1;a.$on("spotmop:loadMore",function(){!i&&"undefined"!=typeof a.artists.next&&a.artists.next&&g(a.artists.next)})}]).controller("LibraryAlbumsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService","MopidyService","NotifyService",function(a,b,c,d,e,f,g,h){function i(b){return"undefined"==typeof b?!1:(k=!0,void d.getUrl(b).then(function(b){a.albums.items=a.albums.items.concat(b.items),a.albums.next=b.next,k=!1}))}a.settings=e.getSettings(),a.albums={items:[]};var j=e.getSetting("spotifyuser",{id:null}).id;b.spotifyAuthorized&&d.getMyAlbums(j).then(function(b){a.albums=b}),a.playAlbum=function(a){g.playStream(a.uri)},a.removeFromLibrary=function(b){b.transitioning=!0,d.removeAlbumsFromLibrary(b.id).then(function(c){"undefined"==typeof c.error?a.albums.items.splice(a.albums.items.indexOf(b),1):(h.error(c.error.message),b.transitioning=!1)})};var k=!1;a.$on("spotmop:loadMore",function(){!k&&"undefined"!=typeof a.albums.next&&a.albums.next&&i(a.albums.next)})}]).controller("LibraryPlaylistsController",["$scope","$rootScope","$filter","SpotifyService","SettingsService","DialogService","MopidyService","NotifyService",function(a,b,c,d,e,f,g,h){function i(){g.getPlaylists().then(function(b){a.playlists.items=b,angular.forEach(b,function(b,c){var e=function(b){return function(c){"undefined"==typeof c.error&&(a.playlists.items[b]=c)}}(c);d.getPlaylist(b.uri).then(e)})})}function j(b){return"undefined"==typeof b?!1:(l=!0,void d.getUrl(b).then(function(b){a.playlists.items=a.playlists.items.concat(b.items),a.playlists.next=b.next,l=!1}))}a.createPlaylist=function(){f.create("createPlaylist",a)},a.settings=e.getSettings(),a.playlists={items:[]},a.show=function(b){return"undefined"!=typeof a.settings.playlists&&"undefined"!=typeof a.settings.playlists.onlyshowowned&&a.settings.playlists.onlyshowowned?"jaedb"==b.owner.id?!0:!1:!0};var k=e.getSetting("spotifyuser",{id:null}).id;b.spotifyAuthorized?d.getPlaylists(k).then(function(b){"undefined"!=typeof b.error&&401==b.error.status?Spotify.refreshToken():a.playlists=b}):b.mopidyOnline?i():a.$on("mopidy:state:online",function(){i()});var l=!1;a.$on("spotmop:loadMore",function(){!l&&"undefined"!=typeof a.playlists.next&&a.playlists.next&&j(a.playlists.next)})}]),angular.module("spotmop.local",[]).config(["$stateProvider",function(a){a.state("local",{url:"/local",templateUrl:"app/local/template.html"}).state("local.index",{url:"/index",templateUrl:"app/local/index.html",controller:"LocalController"}).state("local.directory",{url:"/directory/:uri",templateUrl:"app/local/directory.html",controller:"LocalDirectoryController"}).state("local.albums",{url:"/albums",templateUrl:"app/local/albums.html",controller:"LocalAlbumsController"}).state("local.artists",{url:"/artists",templateUrl:"app/local/artists.html",controller:"LocalArtistsController"})}]).controller("LocalController",["$scope","$rootScope","$filter","$stateParams","$localStorage","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h,i){function j(){i.getLibraryItems("local:directory").then(function(b){for(var d=c("filter")(b,{type:"track"}),e=[],f=0;f 0&&i.getTracks(e).then(function(b){var c=[];for(var d in b){var e=b[d][0];e.type="localtrack",c.push(e)}a.tracks=c,a.allTracks=c});var g=[];for(f=0;f 0){var e=c("filter")(a.allAlbums,{uri:d}),f=a.allAlbums.indexOf(e[0]);a.allAlbums[f].images=c("sizedImages")(b[d])}})}a.settings=h.getSettings(),a.allAlbums=[];var n=50;a.$watch("filterTerm",function(b){n=50,a.albums=c("filter")(a.allAlbums,b),a.albums=c("limitTo")(a.albums,n),a.albums.length>0&&m(a.albums)}),a.mopidyOnline?l():a.$on("mopidy:state:online",function(){l()});var o=!1;a.$on("spotmop:loadMore",function(){o||(o=!0,n+=50,a.filterTerm?(a.albums=c("filter")(a.allAlbums,a.filterTerm),a.albums=c("limitTo")(a.albums,n)):a.albums=c("limitTo")(a.allAlbums,n),f(function(){o=!1,a.albums.length>0&&m(a.albums)},1))})}]).controller("LocalDirectoryController",["$scope","$rootScope","$filter","$stateParams","$localStorage","SpotifyService","SettingsService","DialogService","MopidyService",function(a,b,c,d,e,f,g,h,i){function j(){i.getLibraryItems(l).then(function(b){for(var d=c("filter")(b,{type:"track"}),e=[],f=0;f 0&&i.getTracks(e).then(function(b){var c=[];for(var d in b){var e=b[d][0];e.type="localtrack",c.push(e)}a.tracks=c,a.allTracks=c});var g=[];for(f=0;f -1||l.indexOf("local:directory:")>-1)){var m=l.substring(16,l.length);if(""!=m&&(m=m.split("|")),m.length>0)for(var n=0;n =o;o++)"local:directory:"!=l&&(l+="|"),l+=m[o];a.path.push({title:decodeURIComponent(m[n]),uri:l})}l=l.replace("|","/")}a.mopidyOnline?j():a.$on("mopidy:state:online",function(){j()})}]),angular.module("spotmop.player",["spotmop.services.player","spotmop.services.spotify","spotmop.services.mopidy"]).controller("PlayerController",["$scope","$rootScope","$timeout","$interval","$element","PlayerService","MopidyService","SpotifyService","SettingsService",function(a,b,c,d,e,f,g,h,i){a.state=f.state,a.playPause=function(){f.playPause()},a.stop=function(){f.stop()},a.next=function(){f.next()},a.previous=function(){f.previous()},a.seek=function(b){var c,d,e,g,h;c=$(b.target).hasClass("slider")?$(b.target):$(b.target).closest(".slider"),d=c.offset(),e=b.pageX-d.left,g=e/c.innerWidth(),h=Math.round(g*a.state().currentTlTrack.track.length),f.seek(h)},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)},a.toggleRepeat=function(){f.toggleRepeat()},a.toggleRandom=function(){f.toggleRandom()},a.toggleMute=function(){f.toggleMute()},a.toggleConsume=function(){f.toggleConsume()},a.$on("mopidy:event:tracklistChanged",function(b){g.getCurrentTlTracks().then(function(b){a.$parent.currentTracklist=b})})}]),angular.module("spotmop.services.player",[]).factory("PlayerService",["$rootScope","$interval","$filter","SettingsService","MopidyService","SpotifyService","NotifyService","LastfmService",function(a,b,c,d,e,f,g,h){function i(){e.getRepeat().then(function(a){p.isRepeat=a}),e.getRandom().then(function(a){p.isRandom=a}),e.getMute().then(function(a){p.isMute=a}),e.getConsume().then(function(a){p.isConsume=a})}function j(a){"undefined"==typeof a?e.getTimePosition().then(function(a){p.playPosition=a}):p.playPosition=a}function k(a){"undefined"!=typeof a?p.volume=a:e.getVolume().then(function(a){p.volume=a})}function l(a){"undefined"!=typeof a?("playing"==a?p.playing=!0:p.playing=!1,o()):e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1,o()})}function m(b){var d=function(b){if(p.currentTlTrack=b,"undefined"!=typeof b.track.album.images&&b.track.album.images.length>0){var d=[{__model__:"Image",uri:b.track.album.images}];p.currentTlTrack.track.images=c("sizedImages")(d),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)}else if("spotify:"==b.track.uri.substring(0,8))f.getTrack(b.track.uri).then(function(b){"undefined"!=typeof b.album&&(p.currentTlTrack.track.images=c("sizedImages")(b.album.images)),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)});else{var e=encodeURIComponent(b.track.artists[0].name),g=encodeURIComponent(b.track.album.name);e&&g&&h.albumInfo(e,g).then(function(b){p.currentTlTrack.track.image=!1,"undefined"!=typeof b.album&&(p.currentTlTrack.track.images=c("sizedImages")(b.album.image)),a.$broadcast("spotmop:currenttrack:loaded",p.currentTlTrack)})}j(),o()};"undefined"!=typeof b?d(b):e.getCurrentTlTrack().then(function(a){null!==a&&void 0!==a&&(a.track.name.indexOf("[loading]")>-1?e.lookup(a.track.uri).then(function(a){d(a[0])}):d(a))})}function n(){e.getCurrentTlTracks().then(function(b){a.currentTracklist=b,(!b||b.length<=0)&&(p.currentTlTrack=!1,o())})}function o(){var a=p.currentTlTrack.track,b="No track playing";if(a){var c="\u25a0 ",d="";$.each(a.artists,function(a,b){""!=d&&(d+=", "),d+=b.name}),p.playing&&(c="\u25b6 "),b=c+" "+a.name+" - "+d}document.title=b}var p={playing:!1,isRepeat:!1,isRandom:!1,isMute:!1,isConsume:!1,volume:100,playPosition:0,currentTlTrack:!1,currentTracklistPosition:function(){if(p.currentTlTrack){var b=c("filter")(a.currentTracklist,{tlid:p.currentTlTrack.tlid}),d=0;return b.length>0&&(d=a.currentTracklist.indexOf(b[0])+1),d}return null},playPositionPercent:function(){return p.currentTlTrack?(p.playPosition/p.currentTlTrack.track.length*100).toFixed(2):0}};a.$on("mopidy:state:online",function(){i(),m(),l(),k(),n(),e.getState().then(function(a){"playing"==a?p.playing=!0:p.playing=!1})}),a.$on("mopidy:event:tracklistChanged",function(a,b){n()}),a.$on("mopidy:event:optionsChanged",function(a,b){i()}),a.$on("mopidy:event:playbackStateChanged",function(a,b){l(b.new_state)}),a.$on("mopidy:event:seeked",function(a,b){j(b.time_position)}),a.$on("mopidy:event:volumeChanged",function(a,b){b.volume!=p.volume&&k(b.volume)}),a.$on("mopidy:event:trackPlaybackStarted",function(a,b){("undefined"==typeof p.currentTlTrack.track||p.currentTlTrack.track.uri!=b.tl_track.track.uri)&&(p.currentTlTrack=b.tl_track,m(b.tl_track),l())}),b(function(){p.playing&&"undefined"!=typeof p.currentTlTrack&&"undefined"!=typeof p.currentTlTrack.track&&p.playPosition =100&&(p.volume=100),q.setVolume(p.volume),g.shortcut("volume-up"))}),a.$on("spotmop:keyboardShortcut:down",function(b){a.ctrlKeyHeld&&(p.volume-=10,p.volume<0&&(p.volume=0),q.setVolume(p.volume),g.shortcut("volume-down"))});var q={state:function(){return p},playPause:function(){p.playing?(e.pause(),p.playing=!1):(e.play(),p.playing=!0)},stop:function(){e.stopPlayback(),p.playing=!1},next:function(){e.next()},previous:function(){e.previous()},seek:function(a){p.playPosition=a,e.seek(a)},setVolume:function(a){p.volume=a,e.setVolume(a)},toggleRepeat:function(){p.isRepeat?e.setRepeat(!1).then(function(a){p.isRepeat=!1}):e.setRepeat(!0).then(function(a){p.isRepeat=!0}),console.log(p)},toggleRandom:function(){p.isRandom?e.setRandom(!1).then(function(a){p.isRandom=!1}):e.setRandom(!0).then(function(a){p.isRandom=!0})},toggleMute:function(){p.isMute?e.setMute(!1).then(function(a){p.isMute=!1}):e.setMute(!0).then(function(a){p.isMute=!0})},toggleConsume:function(){p.isConsume?e.setConsume(!1).then(function(a){p.isConsume=!1}):e.setConsume(!0).then(function(a){p.isConsume=!0})}};return q}]),angular.module("spotmop.queue",[]).config(["$stateProvider",function(a){a.state("queue",{url:"/queue",templateUrl:"app/queue/template.html",controller:"QueueController"})}]).controller("QueueController",["$scope","$rootScope","$filter","$timeout","$state","MopidyService","SpotifyService","DialogService",function(a,b,c,d,e,f,g,h){function i(b){var c=0;$.each(b,function(a,b){c+=b.track.length}),a.totalTime=Math.round(c/1e5)}a.totalTime=0,a.tracks=b.currentTracklist,a.limit=50;var j=!1;a.$on("spotmop:loadMore",function(){!j&&a.tracks.length>=a.limit&&(a.limit+=50,j=!0,d(function(){j=!1},100))}),a.addUri=function(){h.create("addbyuri",a)},a.clearQueue=function(){f.clearCurrentTrackList()},b.$watch(function(a){return a.currentTracklist},function(b,c){a.tracks=b,i(b)}),a.$on("spotmop:keyboardShortcut:delete",function(b){var d=c("filter")(a.tracks,{selected:!0}),e=[];angular.forEach(d,function(a,b){e.push(a.tlid)}),a.$apply(function(){a.tracks=c("filter")(a.tracks,{selected:!1})}),f.removeFromTrackList(e)})}]),angular.module("spotmop.search",[]).config(["$stateProvider",function(a){a.state("search",{url:"/search/:query/:type",templateUrl:"app/search/template.html",controller:"SearchController",params:{type:{squash:!0,value:"all"},query:{squash:!0,value:null}}})}]).controller("SearchController",["$scope","$rootScope","$state","$stateParams","$timeout","$filter","SpotifyService","MopidyService",function(a,b,c,d,e,f,g,h){function i(c,d){if("undefined"==typeof c)var c=a.type;switch(c){case"track":g.getSearchResults("track",d,50).then(function(b){a.tracklist.tracks=a.tracklist.tracks.concat(b.tracks.items),a.tracklist.type="track",a.tracklist.next=b.tracks.next,l=b.tracks.next?b.tracks.offset+b.tracks.limit:!1});break;case"album":g.getSearchResults("album",d,50).then(function(b){a.albums=b.albums,l=b.albums.next?b.albums.offset+b.albums.limit:!1});break;case"artist":g.getSearchResults("artist",d,50).then(function(b){a.artists=b.artists,a.next=b.artists.next,a.offset=b.artists.offset});break;case"playlist":g.getSearchResults("playlist",d,50).then(function(b){a.playlists=b.playlists,a.next=b.playlists.next,a.offset=b.playlists.offset});break;case"other":b.mopidyOnline?j(a.query):b.$on("mopidy:state:online",function(){j(a.query)});break;default:g.getSearchResults("track",d,50).then(function(b){a.tracklist=b.tracks,a.tracklist.type="track",a.tracklist.tracks=b.tracks.items}),g.getSearchResults("album",d,50).then(function(b){a.albums=b.albums}),g.getSearchResults("artist",d,50).then(function(b){a.artists=b.artists}),g.getSearchResults("playlist",d,50).then(function(b){a.playlists=b.playlists})}}function j(b){h.search(b,!1,["soundcloud:","local:"]).then(function(b){for(var c=0;c 0&&console.log("A dialog already exists..."),$("body").append(b('')(c))},remove:function(){$("body").children(".dialog").fadeOut(200,function(){$(this).remove()})}}}]).directive("dialog",["$compile",function(a){return{restrict:"E",replace:!0,transclude:!0,scope:{type:"@"},templateUrl:"app/services/dialog/template.html",link:function(b,c){c.find(".content").html(a("<"+b.type+"dialog />")(b))},controller:["$scope","$element","DialogService",function(a,b,c){a.closeDisabled=!1,"initialsetup"==a.type&&(a.closeDisabled=!0),a.closeDialog=function(){c.remove()},a.$on("spotmop:keyboardShortcut:esc",function(b){a.closeDisabled||c.remove()})}]}}]).directive("createplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/createplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f){a.playlistPublic="true",a.savePlaylist=function(){a.playlistName&&""!=a.playlistName?(a.saving=!0,"true"==a.playlistPublic?a.playlistPublic=!0:a.playlistPublic=!1,f.createPlaylist(a.$parent.spotifyUser.id,{name:a.playlistName,"public":a.playlistPublic}).then(function(b){a.$parent.playlists.items.push(b),a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})):a.error=!0}}]}}).directive("editplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/editplaylist.template.html",controller:["$scope","$element","$rootScope","DialogService","SpotifyService",function(a,b,c,d,e){a.playlistNewName=a.$parent.playlist.name,a.playlistNewPublic=a.$parent.playlist["public"].toString(),a.saving=!1,a.savePlaylist=function(){a.playlistNewName&&""!=a.playlistNewName?(a.saving=!0,"true"==a.playlistNewPublic?a.playlistNewPublic=!0:a.playlistNewPublic=!1,e.updatePlaylist(a.$parent.playlist.uri,{name:a.playlistNewName,"public":a.playlistNewPublic}).then(function(b){a.$parent.playlist.name=a.playlistNewName,a.$parent.playlist["public"]=a.playlistNewPublic,a.$parent.updatePlaylists(),d.remove(),c.$broadcast("spotmop:notifyUser",{id:"saved",message:"Saved",autoremove:!0})})):a.error=!0}}]}}).directive("addtoplaylistdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addtoplaylist.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SpotifyService","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){a.playlists=[];var i=g.getSetting("spotifyuser",{id:"undefined"}).id;f.getPlaylists(i,50).then(function(b){a.playlists=d("filter")(b.items,{owner:{id:i}})}),a.playlistSelected=function(b){var g=d("filter")(a.$parent.tracks,{selected:!0}),i=[];angular.forEach(g,function(a){"undefined"!=typeof a.track?i.push(a.track.uri):i.push(a.uri)}),f.addTracksToPlaylist(b.uri,i).then(function(a){e.remove(),c.$broadcast("spotmop:tracklist:unselectAll"),h.notify(i.length+" tracks added to "+b.name)})}}]}}).directive("volumecontrolsdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/volumecontrols.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","PlayerService",function(a,b,c,d,e,f){a.state=function(){return f.state(); +},a.setVolume=function(a){var b,c,d,e;b=$(a.target).hasClass("slider")?$(a.target):$(a.target).closest(".slider"),c=b.offset(),d=a.pageX-c.left,e=d/b.innerWidth()*100,e=parseInt(e),f.setVolume(e)}}]}}).directive("initialsetupdialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/initialsetup.template.html",controller:["$scope","$element","$rootScope","$filter","DialogService","SettingsService","SpotifyService",function(a,b,c,d,e,f,g){a.settings=f.getSettings(),f.setSetting("spotify",!0,"authorizationenabled"),f.setSetting("spotmop","default","pointerMode"),a.saving=!1,a.save=function(){a.name&&""!=a.name?(a.saving=!0,f.getSetting("spotify",!1,"authorizationenabled")&&g.authorize(),f.setSetting("pushername",a.name),e.remove()):a.error=!0}}]}}).directive("addbyuridialog",function(){return{restrict:"E",replace:!0,transclude:!0,templateUrl:"app/services/dialog/addbyuri.template.html",controller:["$scope","$element","DialogService","SpotifyService","MopidyService",function(a,b,c,d,e){a.saving=!1,a.add=function(){a.uri&&""!=a.uri?(a.error=!1,a.saving=!0,e.addToTrackList([a.uri])["catch"](function(b){a.saving=!1,a.error=!0}).then(function(b){a.error||c.remove()})):a.error=!0}}]}}),angular.module("spotmop.services.lastfm",[]).factory("LastfmService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j){var k={sendRequest:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:l+"?format=json&api_key="+m+"&"+a}).success(function(a){b.resolve(a)}).error(function(a){j.error(a.error.message),b.reject(a.error.message)}),b.promise},trackInfo:function(a,b){return a=encodeURIComponent(a),this.sendRequest("method=track.getInfo&track="+b+"&artist="+a)},albumInfo:function(a,b){return a=encodeURIComponent(a),b=encodeURIComponent(b),this.sendRequest("method=album.getInfo&album="+b+"&artist="+a)},albumInfoByMbid:function(a){return this.sendRequest("method=album.getInfo&mbid="+a)},artistInfo:function(a){return a=encodeURIComponent(a),this.sendRequest("method=artist.getInfo&artist="+a)},artistInfoByMbid:function(a){return this.sendRequest("method=artist.getInfo&mbid="+a)}},l="http://ws.audioscrobbler.com/2.0",m=i.getSetting("lastfmkey","4320a3ef51c9b3d69de552ac083c55e3");return k}]),angular.module("spotmop.services.mopidy",[]).factory("MopidyService",["$q","$rootScope","$cacheFactory","$location","$timeout","SettingsService","PusherService","NotifyService","cfpLoadingBar",function(a,b,c,d,e,f,g,h,i){function j(b,c){return function(){var d=a.defer(),e=Array.prototype.slice.call(arguments),f=c||this;return i.start(),i.set(.25),k(b,f,e).then(function(a){i.complete(),d.resolve(a)},function(a){h.error(a),d.reject(a)}),d.promise}}function k(a,b,c){for(var d=a.split("."),e=d.pop(),f=0;f '+a+"");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},error:function(a,b){if("undefined"==typeof b)var b=2500;var c=$(' '+a+" ");$("#notifications").append(c),b&&d(function(){c.fadeOut(200,function(){c.remove()})},b)},spotifyAuthenticationError:function(){this.error("Please authenticate with Spotify - you can find this under settings")},shortcut:function(a){$("#notifications").find("notification.keyboard-shortcut").remove();var b=$('');$("#notifications").append(b),d(function(){b.fadeOut(200,function(){b.remove()})},1500)},browserNotify:function(a,b,c){if(e.getSetting("notificationsDisabled",!1))return!1;var d=window.Notification||window.mozNotification||window.webkitNotification;if("undefined"==typeof d)return!1;if("undefined"!=typeof d&&d.requestPermission(function(a){}),"undefined"==typeof c)var c="";new d(a,{body:b,dir:"auto",lang:"EN",tag:"spotmopNotification",icon:c});return!0}}}]).directive("notification",function(){return{restrict:"AE",link:function(a,b,c){console.log(b)}}}),angular.module("spotmop.services.pusher",[]).factory("PusherService",["$rootScope","$http","$q","$localStorage","$cacheFactory","$templateCache","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h){"undefined"==typeof d.pusher&&(d.pusher={});var i="http://"+g.getSetting("mopidyhost",window.location.hostname);i+=":"+g.getSetting("mopidyport","6680"),i+="/spotmop/";var j={pusher:{},isConnected:!1,start:function(){var b=g.getSetting("mopidyhost",window.location.hostname),c=g.getSetting("pusherport","6681");try{var d="ws://"+b+":"+c+"/pusher",i=new WebSocket(d);i.onopen=function(){a.$broadcast("spotmop:pusher:online"),this.isConnected=!0},i.onmessage=function(b){var c=JSON.parse(b.data);if(c.pusher)if(c.startup){console.info("Pusher connected as "+c.details.id),g.setSetting("pusherid",c.details.id),g.setSetting("pusherip",c.details.ip),g.getSetting("version",0,"installed")!=c.version&&(h.notify("New version detected, clearing caches..."),e.get("$http").removeAll(),f.removeAll(),g.setSetting("version",c.version,"installed"),g.runUpgrade());var d=g.getSetting("pushername","");d&&j.setMe(d)}else c.id==g.getSetting("pusherid","")||g.getSetting("pusherdisabled",!1)||a.$broadcast("spotmop:pusher:received",c)},i.onclose=function(){a.$broadcast("spotmop:pusher:offline"),j.isConnected=!1,setTimeout(function(){j.start()},5e3)},j.pusher=i}catch(k){console.log("Connecting with Pusher failed with the following error message: "+k)}},stop:function(){this.pusher=null,this.isConnected=!1},send:function(a){a.pusher=!0,a.id=g.getSetting("pusherid",null),j.pusher.send(JSON.stringify(a))},setMe:function(a){var b=g.getSetting("pusherid",null);$.ajax({method:"GET",cache:!1,url:i+"pusher/me?id="+b+"&name="+a})},getConnections:function(){var a=c.defer();return b({method:"GET",cache:!1,url:i+"pusher/connections"}).success(function(b){a.resolve(b)}).error(function(b){h.error(b.error.message),a.reject(b.error.message)}),a.promise}};return j}]),angular.module("spotmop.services.spotify",[]).factory("SpotifyService",["$rootScope","$resource","$localStorage","$http","$interval","$timeout","$filter","$q","$cacheFactory","SettingsService","NotifyService",function(a,b,c,d,e,f,g,h,i,j,k){var l={authenticationMethod:"server",start:function(){var b=$('');$(body).append(b),"undefined"==typeof c.spotify&&(c.spotify={}),"undefined"==typeof c.spotify.AccessToken&&(c.spotify.AccessToken=null),"undefined"==typeof c.spotify.RefreshToken&&(c.spotify.RefreshToken=null),"undefined"==typeof c.spotify.AuthorizationCode&&(c.spotify.AuthorizationCode=null),"undefined"==typeof c.spotify.AccessTokenExpiry&&(c.spotify.AccessTokenExpiry=null),window.addEventListener("message",function(b){if("http://jamesbarnsley.co.nz"!==b.origin)return!1;var d=JSON.parse(b.data);console.info("Spotify authorization successful"),c.spotify.AuthorizationCode=d.authorization_code,c.spotify.AccessToken=d.access_token,c.spotify.RefreshToken=d.refresh_token,a.spotifyOnline=!0,this.authenticationMethod="client",l.getMe().then(function(b){j.setSetting("spotifyuser",b),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)})},!1),this.isAuthorized()?(a.spotifyAuthorized=!0,this.authenticationMethod="client"):(j.setSetting("spotifyuser",!1),a.spotifyAuthorized=!1,this.authenticationMethod="server"),a.$broadcast("spotmop:spotify:online")},logout:function(){c.spotify={},this.authenticationMethod="server",this.refreshToken(),a.$broadcast("spotmop:spotify:authenticationChanged",this.authenticationMethod)},authorize:function(){var a=$(document).find("#authorization-frame");a.attr("src","http://jamesbarnsley.co.nz/spotmop.php?action=authorize&app="+location.protocol+"//"+window.location.host)},isAuthorized:function(){return c.spotify.AuthorizationCode&&c.spotify.RefreshToken?!0:!1},refreshToken:function(){var b=h.defer(),e="";if("client"==this.authenticationMethod)e="http://jamesbarnsley.co.nz/spotmop.php?action=refresh&refresh_token="+c.spotify.RefreshToken;else{if("server"!=this.authenticationMethod)return!1;var f=j.getSetting("mopidyhost",window.location.hostname),g=j.getSetting("mopidyport","6680");e="http://"+f+":"+g+"/spotmop/auth"}return d({method:"GET",url:e,dataType:"json",async:!1,timeout:1e4}).success(function(d){"undefined"!=typeof d.error?(k.error("Spotify authorization error: "+d.error_description),a.spotifyOnline=!1,b.reject(d.error.message)):(c.spotify.AccessToken=d.access_token,c.spotify.AccessTokenExpiry=(new Date).getTime()+36e5,a.spotifyOnline=!0,b.resolve(d))}),b.promise},serviceUnavailable:function(){k.error("Request failed. Spotify API may be temporarily unavailable.")},getFromUri:function(a,b){var c=b.split(":");return"userid"==a&&"user"==c[1]?c[2]:"playlistid"==a&&"playlist"==c[3]?c[4]:"artistid"==a&&"artist"==c[1]?c[2]:"albumid"==a&&"album"==c[1]?c[2]:"trackid"==a&&"track"==c[1]?c[2]:null},uriType:function(a){var b=a.split(":");return"spotify"==b[0]&&"artist"==b[1]?"artist":"spotify"==b[0]&&"album"==b[1]?"album":"spotify"==b[0]&&"user"==b[1]&&"playlist"==b[3]?"playlist":null},getUrl:function(a){var b=h.defer();return d({method:"GET",url:a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getMe:function(){var a=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){a.resolve(b)}).error(function(b){k.error(b.error.message),a.reject(b.error.message)}),a.promise):(a.reject(),a.promise)},getUser:function(a){var b=this.getFromUri("userid",a),c=h.defer();return d({method:"GET",url:m+"users/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},isFollowing:function(a,b){var e=this.getFromUri(a+"id",b),f=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/following/contains?type="+a+"&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},getTrack:function(a){var b=this.getFromUri("trackid",a),c=h.defer();return d({method:"GET",url:m+"tracks/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getMyTracks:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/tracks/?limit=50",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},addTracksToLibrary:function(a){var b=h.defer();if(!this.isAuthorized())return b.reject(),b.promise;var e=i.get("$http");return e.remove(m+"me/tracks/?limit=50"),d({method:"PUT",url:m+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},addAlbumsToLibrary:function(a){if(!this.isAuthorized())return e.reject(),e.promise;var b=i.get("$http");b.remove(m+"me/albums?limit=40&offset=0");var e=h.defer();return"array"!=typeof a&&(a=[a]),d({method:"PUT",url:m+"me/albums",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},removeAlbumsFromLibrary:function(a){if(!this.isAuthorized())return b.reject(),b.promise;var b=h.defer();return"array"!=typeof a&&(a=[a]),d({method:"DELETE",url:m+"me/albums",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},deleteTracksFromLibrary:function(a){var b=h.defer();if(!this.isAuthorized())return b.reject(),b.promise;var e=i.get("$http");return e.remove(m+"me/tracks/?limit=50"),d({method:"DELETE",url:m+"me/tracks",dataType:"json",data:JSON.stringify({ids:a}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getMyArtists:function(a){var b=h.defer();return this.isAuthorized()?(d({method:"GET",url:m+"me/following?type=artist",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getMyAlbums:function(a,b,e){var f=h.defer();return this.isAuthorized()?("undefined"!=typeof b&&b||(b=20),"undefined"==typeof e&&(e=0),d({cache:!0,method:"GET",url:m+"me/albums?limit="+b+"&offset="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},isFollowingArtist:function(a,b){var e=this.getFromUri("artistid",a),f=h.defer();return this.isAuthorized()?(d({cache:!1,method:"GET",url:m+"me/following/contains?type=artist&ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},followArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"PUT",cache:!1,url:m+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},unfollowArtist:function(a){var b=this.getFromUri("artistid",a),e=h.defer();return this.isAuthorized()?(d({method:"DELETE",cache:!1,url:m+"me/following?type=artist&ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},getPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!1,method:"GET",url:m+"users/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return d({cache:!0,method:"GET",url:m+"users/"+b+"/playlists/"+e+"?market="+n,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise},isFollowingPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({cache:!0,method:"GET",url:m+"users/"+e+"/playlists/"+f+"/followers/contains?ids="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},followPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"PUT",url:m+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},unfollowPlaylist:function(a){var b=this.getFromUri("userid",a),e=this.getFromUri("playlistid",a),f=h.defer();return this.isAuthorized()?(d({method:"DELETE",url:m+"users/"+b+"/playlists/"+e+"/followers",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise):(f.reject(),f.promise)},featuredPlaylists:function(a){"undefined"==typeof a&&(a=40);var b=g("date")(new Date,"yyyy-MM-ddTHH:mm:ss"),e=j.getSetting("countrycode","NZ"),f=h.defer();return d({cache:!0,method:"GET",url:m+"browse/featured-playlists?timestamp="+b+"&country="+e+"&limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){f.resolve(a)}).error(function(a){k.error(a.error.message),f.reject(a.error.message)}),f.promise},addTracksToPlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"POST",url:m+"users/"+e+"/playlists/"+f+"/tracks",dataType:"json",data:JSON.stringify({uris:b}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},movePlaylistTracks:function(a,b,e,f){if(!this.isAuthorized())return l.reject(),l.promise;var g=this.getFromUri("userid",a),i=this.getFromUri("playlistid",a);if(g!=j.getSetting("spotifyuser",{id:null}).id)return!1;var l=h.defer();return d({method:"PUT",url:m+"users/"+g+"/playlists/"+i+"/tracks",dataType:"json",data:JSON.stringify({range_start:b,range_length:e,insert_before:f}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){l.resolve(a)}).error(function(a){k.error(a.error.message),l.reject(a.error.message)}),l.promise},deleteTracksFromPlaylist:function(a,b,e){var f=this.getFromUri("userid",a),g=this.getFromUri("playlistid",a),i=h.defer();return d({method:"DELETE",url:m+"users/"+f+"/playlists/"+g+"/tracks",dataType:"json",data:JSON.stringify({snapshot_id:b,positions:e}),contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){i.resolve(a)}).error(function(a){k.error(a.error.message),i.reject(a.error.message)}),i.promise},createPlaylist:function(a,b){var e=h.defer();return this.isAuthorized()?(d({method:"POST",url:m+"users/"+a+"/playlists/",dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise):(e.reject(),e.promise)},updatePlaylist:function(a,b){var e=this.getFromUri("userid",a),f=this.getFromUri("playlistid",a),g=h.defer();return this.isAuthorized()?(d({method:"PUT",url:m+"users/"+e+"/playlists/"+f,dataType:"json",data:b,contentType:"application/json; charset=utf-8",headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise):(g.reject(),g.promise)},newReleases:function(a,b){"undefined"!=typeof a&&a||(a=40),"undefined"==typeof b&&(b=0);var e=h.defer();return d({cache:!0,method:"GET",url:m+"browse/new-releases?country="+n+"&limit="+a+"&offset="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){for(var b=[],c=Math.ceil(a.albums.items.length/20),d=1;c>d;d++){for(var f=a.albums.items.splice(0,20),g=[],h=0;20>h;h++)g.push(f[h].id);l.getAlbums(g).then(function(f){b=b.concat(f.albums),d>=c&&(a.albums.items=b,e.resolve(a))})}}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},browseCategories:function(a){"undefined"==typeof a&&(a=40);var b=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories?limit="+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategory:function(a){var b=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories/"+a,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getCategoryPlaylists:function(a,b){"undefined"==typeof b&&(b=40);var e=h.defer();return d({cache:!0,method:"GET",url:m+"browse/categories/"+a+"/playlists?limit="+b,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getMyFavorites:function(a,b,e,f){if("undefined"==typeof b||!b)var b=25;if("undefined"==typeof e||!e)var e=0;if("undefined"==typeof f||!f)var f="long_term";var g=h.defer();return d({cache:!0,method:"GET",url:m+"me/top/"+a+"?limit="+b+"&offset="+e+"&time_range="+f,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){g.resolve(a)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise},getRecommendations:function(a,b,e,f,g){var i=m+"recommendations/?";"undefined"!=typeof a&&a&&(i+="limit="+a),"undefined"!=typeof b&&b&&(i+="&offset="+b),"undefined"!=typeof e&&e&&(i+="&seed_artists="+e),"undefined"!=typeof f&&f&&(i+="&seed_albums="+f),"undefined"!=typeof g&&g&&(i+="&seed_tracks="+g);var j=h.defer();return d({cache:!0,method:"GET",url:i,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){j.resolve(a)}).error(function(a){k.error(a.error.message),j.reject(a.error.message)}),j.promise},getArtist:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getArtists:function(a){var b=this,c="";angular.forEach(a,function(a){""!=c&&(c+=","),c+=b.getFromUri("artistid",a)});var e=h.defer();return d({method:"GET",url:m+"artists/?ids="+c}).success(function(a){e.resolve(a)}).error(function(a){k.error(a.error.message),e.reject(a.error.message)}),e.promise},getTopTracks:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/top-tracks?country="+n}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getRelatedArtists:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/related-artists"}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},getAlbum:function(a){var b=h.defer(),c=this.getFromUri("albumid",a);return d({method:"GET",url:m+"albums/"+c}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getAlbums:function(a){for(var b=h.defer(),c="",e=0;e 0&&(c+=","),c+=a[e];return d({cache:!0,method:"GET",url:m+"albums?ids="+c+"&market="+n}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise},getArtistAlbums:function(a){var b=this.getFromUri("artistid",a),c=h.defer();return d({cache:!0,method:"GET",url:m+"artists/"+b+"/albums?album_type=album,single&market="+n}).success(function(a){c.resolve(a)}).error(function(a){k.error(a.error.message),c.reject(a.error.message)}),c.promise},isAlbumInLibrary:function(a){for(var b=h.defer(),e="",f=0;f 0&&(e+=","),e+=a[f];return this.isAuthorized()?(d({method:"GET",url:m+"me/albums/contains?ids="+e,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(a){b.resolve(a)}).error(function(a){k.error(a.error.message),b.reject(a.error.message)}),b.promise):(b.reject(),b.promise)},getSearchResults:function(a,b,e,f){"undefined"==typeof e&&(e=10),"undefined"==typeof f&&(f=0);var g=h.defer();return d({cache:!0,method:"GET",url:m+"search?q="+b+"&type="+a+"&country="+n+"&limit="+e+"&offset="+f,headers:{Authorization:"Bearer "+c.spotify.AccessToken}}).success(function(b){if("album"==a)for(var c=[],d=Math.ceil(b.albums.items.length/20),e=1;d>e;e++){for(var f=b.albums.items.splice(0,20),h=[],i=0;20>i;i++)h.push(f[i].id);l.getAlbums(h).then(function(a){c=c.concat(a.albums),e>=d&&(b.albums.items=c,g.resolve(b))})}else g.resolve(b)}).error(function(a){k.error(a.error.message),g.reject(a.error.message)}),g.promise}},m="https://api.spotify.com/v1/",n=j.getSetting("spotifycountry","NZ");j.getSetting("spotifylocale","en_NZ");return l}]).factory("SpotifyServiceIntercepter",["$q","$rootScope","$injector","$localStorage",function(a,b,c,d){"use strict";function e(a,b,d){function e(a){b.resolve(a)}function f(a){b.reject(a)}var g=c.get("$http");a.headers={Authorization:"Bearer "+d},g(a).then(e,f)}var f=0,g={responseError:function(b){if(b.config.url.search("https://api.spotify.com/")>=0&&3>f){if(401==b.status){f++;var d=a.defer();return c.get("SpotifyService").refreshToken().then(function(a){return"undefined"!=typeof a.error?b:(f--,void e(b.config,d,a.access_token))}),d.promise}if(0==b.status){var d=a.defer();return c.get("SpotifyService").serviceUnavailable(),d.promise}}return b}};return g}]),angular.module("spotmop.settings",[]).config(["$stateProvider",function(a){a.state("settings",{url:"/settings",templateUrl:"app/settings/template.html"}).state("testing",{url:"/testing",templateUrl:"app/settings/testing.template.html"})}]).controller("SettingsController",["$scope","$http","$rootScope","$timeout","MopidyService","SpotifyService","SettingsService","NotifyService","PusherService",function(a,b,c,d,e,f,g,h,i){a.version,a.settings=g.getSettings(),a.currentSubpage="mopidy",a.subpageNavigate=function(b){a.currentSubpage=b},a.authorizeSpotify=function(){f.authorize()},a.refreshSpotifyToken=function(){h.notify("Refreshing token"),f.refreshToken().then(function(){})},a.spotifyLogout=function(){f.logout()},a.upgradeCheck=function(){h.notify("Checking for updates"),g.upgradeCheck().then(function(a){g.setSetting("version",a,"latest"),g.getSetting("version",0,"installed") -diff --git a/mopidy_spotmop/static/app/browse/artist/overview.template.html b/mopidy_spotmop/static/app/browse/artist/overview.template.html index 394aed5..4236027 100644 --- a/mopidy_spotmop/static/app/browse/artist/overview.template.html +++ b/mopidy_spotmop/static/app/browse/artist/overview.template.html @@ -18,8 +18,7 @@+
@@ -33,8 +33,7 @@ draggable="false" candrag dragobj="artist"> - - +
Related Artists
candrag dragobj="artist" draggable="false"> - - +@@ -42,7 +41,7 @@ Albums
dragobj="album" draggable="false">- + @@ -54,8 +53,7 @@Albums
dragobj="album" draggable="false">- - + diff --git a/mopidy_spotmop/static/app/browse/artist/related.template.html b/mopidy_spotmop/static/app/browse/artist/related.template.html index 0597cd1..d2e9430 100644 --- a/mopidy_spotmop/static/app/browse/artist/related.template.html +++ b/mopidy_spotmop/static/app/browse/artist/related.template.html @@ -7,13 +7,14 @@+Related Artists
candrag dragobj="artist">-+ diff --git a/mopidy_spotmop/static/app/browse/artist/template.html b/mopidy_spotmop/static/app/browse/artist/template.html index 895a1a2..86a7779 100644 --- a/mopidy_spotmop/static/app/browse/artist/template.html +++ b/mopidy_spotmop/static/app/browse/artist/template.html @@ -6,7 +6,7 @@@@ -22,7 +22,7 @@ dragobj="playlist" draggable="false">-+ @@ -31,13 +31,11 @@
--- + -+ -+ diff --git a/mopidy_spotmop/static/app/browse/genre/category.template.html b/mopidy_spotmop/static/app/browse/genre/category.template.html index 5145e77..8061608 100644 --- a/mopidy_spotmop/static/app/browse/genre/category.template.html +++ b/mopidy_spotmop/static/app/browse/genre/category.template.html @@ -22,7 +22,7 @@dragobj="playlist" draggable="false">
-+ diff --git a/mopidy_spotmop/static/app/browse/genre/template.html b/mopidy_spotmop/static/app/browse/genre/template.html index 5bdbe6a..56912ea 100644 --- a/mopidy_spotmop/static/app/browse/genre/template.html +++ b/mopidy_spotmop/static/app/browse/genre/template.html @@ -17,7 +17,7 @@
-diff --git a/mopidy_spotmop/static/app/browse/new/template.html b/mopidy_spotmop/static/app/browse/new/template.html index 4e60187..b603f35 100644 --- a/mopidy_spotmop/static/app/browse/new/template.html +++ b/mopidy_spotmop/static/app/browse/new/template.html @@ -22,7 +22,7 @@+ candrag dragobj="album">
-+ diff --git a/mopidy_spotmop/static/app/browse/playlist/template.html b/mopidy_spotmop/static/app/browse/playlist/template.html index d2e68aa..ad147a2 100644 --- a/mopidy_spotmop/static/app/browse/playlist/template.html +++ b/mopidy_spotmop/static/app/browse/playlist/template.html @@ -17,7 +17,7 @@-diff --git a/mopidy_spotmop/static/app/browse/user/template.html b/mopidy_spotmop/static/app/browse/user/template.html index c18f185..9fc1ba8 100644 --- a/mopidy_spotmop/static/app/browse/user/template.html +++ b/mopidy_spotmop/static/app/browse/user/template.html @@ -29,7 +29,7 @@+ Loading
Playlists
-+ diff --git a/mopidy_spotmop/static/app/common/slider.template.html b/mopidy_spotmop/static/app/common/slider.template.html index a099273..310db7c 100644 --- a/mopidy_spotmop/static/app/common/slider.template.html +++ b/mopidy_spotmop/static/app/common/slider.template.html @@ -11,7 +11,7 @@ candrag dragobj="item">-+ @@ -24,7 +24,7 @@ candrag dragobj="item">-+ @@ -40,7 +40,7 @@ candrag dragobj="item">-+ diff --git a/mopidy_spotmop/static/app/library/albums.template.html b/mopidy_spotmop/static/app/library/albums.template.html index 3c7b9bb..55b5b26 100644 --- a/mopidy_spotmop/static/app/library/albums.template.html +++ b/mopidy_spotmop/static/app/library/albums.template.html @@ -39,26 +39,26 @@
-+@@ -66,15 +66,13 @@ @@ -89,15 +87,15 @@-
- ++-+ - +@@ -110,30 +108,32 @@-+
-Name-Artists-Released+Artists+ReleasedTracks+AddedRating- +